aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-04 12:50:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-04 12:50:07 -0400
commit3c83e61e67256e0bb08c46cc2db43b58fd617251 (patch)
tree0233e1e04e6449c60b01ff5dea8bea85bcf22f08
parent4a4389abdd9822fdf3cc2ac6ed87eb811fd43acc (diff)
parenta83b93a7480441a47856dc9104bea970e84cda87 (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: "The main set of series of patches for media subsystem, including: - document RC sysfs class - added an API to setup scancode to allow waking up systems using the Remote Controller - add API for SDR devices. Drivers are still on staging - some API improvements for getting EDID data from media inputs/outputs - new DVB frontend driver for drx-j (ATSC) - one driver (it913x/it9137) got removed, in favor of an improvement on another driver (af9035) - added a skeleton V4L2 PCI driver at documentation - added a dual flash driver (lm3646) - added a new IR driver (img-ir) - added an IR scancode decoder for the Sharp protocol - some improvements at the usbtv driver, to allow its core to be reused. - added a new SDR driver (rtl2832u_sdr) - added a new tuner driver (msi001) - several improvements at em28xx driver to fix PM support, device removal and to split the V4L2 specific bits into a separate sub-driver - one driver got converted to videobuf2 (s2255drv) - the e4000 tuner driver now follows an improved binding model - some fixes at V4L2 compat32 code - several fixes and enhancements at videobuf2 code - some cleanups at V4L2 API documentation - usual driver enhancements, new board additions and misc fixups" [ NOTE! This merge effective drops commit 4329b93b283c ("of: Reduce indentation in of_graph_get_next_endpoint"). The of_graph_get_next_endpoint() function was moved and renamed by commit fd9fdb78a9bf ("[media] of: move graph helpers from drivers/media/v4l2-core to drivers/of"). It was originally called v4l2_of_get_next_endpoint() and lived in the file drivers/media/v4l2-core/v4l2-of.c. In that original location, it was then fixed to support empty port nodes by commit b9db140c1e46 ("[media] v4l: of: Support empty port nodes"), and that commit clashes badly with the dropped "Reduce intendation" commit. I had to choose one or the other, and decided that the "Support empty port nodes" commit was more important ] * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (426 commits) [media] em28xx-dvb: fix PCTV 461e tuner I2C binding Revert "[media] em28xx-dvb: fix PCTV 461e tuner I2C binding" [media] em28xx: fix PCTV 290e LNA oops [media] em28xx-dvb: fix PCTV 461e tuner I2C binding [media] m88ds3103: fix bug on .set_tone() [media] saa7134: fix WARN_ON during resume [media] v4l2-dv-timings: add module name, description, license [media] videodev2.h: add parenthesis around macro arguments [media] saa6752hs: depends on CRC32 [media] si4713: fix Kconfig dependencies [media] Sensoray 2255 uses videobuf2 [media] adv7180: free an interrupt on failure paths in init_device() [media] e4000: make VIDEO_V4L2 dependency optional [media] af9033: Don't export functions for the hardware filter [media] af9035: use af9033 PID filters [media] af9033: implement PID filter [media] rtl2832_sdr: do not use dynamic stack allocation [media] e4000: fix 32-bit build error [media] em28xx-audio: make sure audio is unmuted on open() [media] DocBook media: v4l2_format_sdr was renamed to v4l2_sdr_format ...
-rw-r--r--CREDITS7
-rw-r--r--Documentation/ABI/testing/sysfs-class-rc111
-rw-r--r--Documentation/DocBook/media/dvb/demux.xml23
-rw-r--r--Documentation/DocBook/media/dvb/dvbapi.xml4
-rw-r--r--Documentation/DocBook/media/dvb/frontend.xml8
-rw-r--r--Documentation/DocBook/media/v4l/common.xml412
-rw-r--r--Documentation/DocBook/media/v4l/compat.xml13
-rw-r--r--Documentation/DocBook/media/v4l/controls.xml176
-rw-r--r--Documentation/DocBook/media/v4l/dev-osd.xml22
-rw-r--r--Documentation/DocBook/media/v4l/dev-sdr.xml110
-rw-r--r--Documentation/DocBook/media/v4l/io.xml189
-rw-r--r--Documentation/DocBook/media/v4l/pixfmt-nv16m.xml9
-rw-r--r--Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml513
-rw-r--r--Documentation/DocBook/media/v4l/pixfmt-sdr-cu08.xml44
-rw-r--r--Documentation/DocBook/media/v4l/pixfmt-sdr-cu16le.xml46
-rw-r--r--Documentation/DocBook/media/v4l/pixfmt.xml34
-rw-r--r--Documentation/DocBook/media/v4l/remote_controllers.xml143
-rw-r--r--Documentation/DocBook/media/v4l/v4l2.xml26
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml8
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-g-edid.xml (renamed from Documentation/DocBook/media/v4l/vidioc-subdev-g-edid.xml)36
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml7
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-g-fmt.xml7
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-g-frequency.xml5
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-g-modulator.xml6
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-g-tuner.xml15
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-querycap.xml6
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml8
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-streamon.xml28
-rw-r--r--Documentation/DocBook/media_api.tmpl88
-rw-r--r--Documentation/devices.txt7
-rw-r--r--Documentation/devicetree/bindings/media/img-ir-rev1.txt34
-rwxr-xr-xDocumentation/dvb/get_dvb_firmware22
-rw-r--r--Documentation/dvb/it9137.txt9
-rw-r--r--Documentation/edac.txt2
-rw-r--r--Documentation/video4linux/CARDLIST.bttv1
-rw-r--r--Documentation/video4linux/CARDLIST.cx238855
-rw-r--r--Documentation/video4linux/CARDLIST.em28xx6
-rw-r--r--Documentation/video4linux/gspca.txt1
-rw-r--r--Documentation/video4linux/v4l2-framework.txt5
-rw-r--r--Documentation/video4linux/v4l2-pci-skeleton.c913
-rw-r--r--MAINTAINERS52
-rw-r--r--arch/arm/mach-omap2/board-cm-t35.c16
-rw-r--r--drivers/edac/edac_mc_sysfs.c2
-rw-r--r--drivers/edac/ghes_edac.c2
-rw-r--r--drivers/edac/i5400_edac.c4
-rw-r--r--drivers/edac/i7300_edac.c4
-rw-r--r--drivers/edac/i7core_edac.c4
-rw-r--r--drivers/edac/sb_edac.c4
-rw-r--r--drivers/hid/hid-picolcd_cir.c2
-rw-r--r--drivers/media/common/siano/smsdvb-debugfs.c2
-rw-r--r--drivers/media/common/siano/smsir.c2
-rw-r--r--drivers/media/dvb-core/dvb-usb-ids.h1
-rw-r--r--drivers/media/dvb-core/dvb_frontend.c10
-rw-r--r--drivers/media/dvb-frontends/Kconfig12
-rw-r--r--drivers/media/dvb-frontends/Makefile2
-rw-r--r--drivers/media/dvb-frontends/af9033.c59
-rw-r--r--drivers/media/dvb-frontends/af9033.h34
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/Kconfig7
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/Makefile6
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/bsp_i2c.h139
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drx39xxj.h45
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drx_dap_fasi.h256
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drx_driver.h2343
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drx_driver_version.h72
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drxj.c12400
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drxj.h650
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drxj_map.h15055
-rw-r--r--drivers/media/dvb-frontends/drxd_hard.c4
-rw-r--r--drivers/media/dvb-frontends/ds3000.c2
-rw-r--r--drivers/media/dvb-frontends/it913x-fe-priv.h1051
-rw-r--r--drivers/media/dvb-frontends/it913x-fe.c1045
-rw-r--r--drivers/media/dvb-frontends/it913x-fe.h237
-rw-r--r--drivers/media/dvb-frontends/m88ds3103.c30
-rw-r--r--drivers/media/dvb-frontends/m88rs2000.c19
-rw-r--r--drivers/media/dvb-frontends/mb86a20s.c4
-rw-r--r--drivers/media/dvb-frontends/mb86a20s.h2
-rw-r--r--drivers/media/dvb-frontends/rtl2832.c191
-rw-r--r--drivers/media/dvb-frontends/rtl2832.h34
-rw-r--r--drivers/media/dvb-frontends/rtl2832_priv.h54
-rw-r--r--drivers/media/dvb-frontends/s921.c4
-rw-r--r--drivers/media/dvb-frontends/s921.h2
-rw-r--r--drivers/media/dvb-frontends/stb6100.c2
-rw-r--r--drivers/media/dvb-frontends/stv0900_sw.c2
-rw-r--r--drivers/media/dvb-frontends/tda10071.c68
-rw-r--r--drivers/media/dvb-frontends/tda10071.h2
-rw-r--r--drivers/media/i2c/Kconfig16
-rw-r--r--drivers/media/i2c/Makefile1
-rw-r--r--drivers/media/i2c/ad9389b.c2
-rw-r--r--drivers/media/i2c/adv7180.c118
-rw-r--r--drivers/media/i2c/adv7511.c2
-rw-r--r--drivers/media/i2c/adv7604.c4
-rw-r--r--drivers/media/i2c/adv7842.c153
-rw-r--r--drivers/media/i2c/ir-kbd-i2c.c4
-rw-r--r--drivers/media/i2c/lm3560.c22
-rw-r--r--drivers/media/i2c/lm3646.c414
-rw-r--r--drivers/media/i2c/mt9p031.c49
-rw-r--r--drivers/media/i2c/mt9t001.c229
-rw-r--r--drivers/media/i2c/mt9v011.c4
-rw-r--r--drivers/media/i2c/mt9v032.c10
-rw-r--r--drivers/media/i2c/sr030pc30.c2
-rw-r--r--drivers/media/i2c/ths8200.c26
-rw-r--r--drivers/media/i2c/tvp5150.c8
-rw-r--r--drivers/media/parport/bw-qcam.c8
-rw-r--r--drivers/media/pci/bt8xx/bttv-cards.c17
-rw-r--r--drivers/media/pci/bt8xx/bttv-input.c1
-rw-r--r--drivers/media/pci/bt8xx/bttv.h1
-rw-r--r--drivers/media/pci/cx23885/cx23885-dvb.c1
-rw-r--r--drivers/media/pci/cx23885/cx23885-input.c2
-rw-r--r--drivers/media/pci/cx88/cx88-input.c2
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-core.c6
-rw-r--r--drivers/media/pci/saa7134/saa7134-cards.c4
-rw-r--r--drivers/media/pci/sta2x11/sta2x11_vip.c7
-rw-r--r--drivers/media/pci/ttpci/av7110_hw.c2
-rw-r--r--drivers/media/platform/Kconfig2
-rw-r--r--drivers/media/platform/arv.c6
-rw-r--r--drivers/media/platform/blackfin/bfin_capture.c2
-rw-r--r--drivers/media/platform/coda.c7
-rw-r--r--drivers/media/platform/davinci/vpbe_display.c9
-rw-r--r--drivers/media/platform/davinci/vpif_capture.c9
-rw-r--r--drivers/media/platform/davinci/vpif_display.c9
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-m2m.c12
-rw-r--r--drivers/media/platform/exynos4-is/fimc-capture.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-lite.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-m2m.c7
-rw-r--r--drivers/media/platform/m2m-deinterlace.c11
-rw-r--r--drivers/media/platform/marvell-ccic/mcam-core.c3
-rw-r--r--drivers/media/platform/mem2mem_testdev.c95
-rw-r--r--drivers/media/platform/mx2_emmaprp.c13
-rw-r--r--drivers/media/platform/omap/omap_vout.c1
-rw-r--r--drivers/media/platform/omap/omap_vout_vrfb.c3
-rw-r--r--drivers/media/platform/omap3isp/isp.c7
-rw-r--r--drivers/media/platform/omap3isp/isp.h12
-rw-r--r--drivers/media/platform/omap3isp/ispccdc.c10
-rw-r--r--drivers/media/platform/omap3isp/ispccdc.h6
-rw-r--r--drivers/media/platform/omap3isp/ispccp2.c6
-rw-r--r--drivers/media/platform/omap3isp/isphist.c4
-rw-r--r--drivers/media/platform/omap3isp/isppreview.c22
-rw-r--r--drivers/media/platform/omap3isp/ispqueue.c2
-rw-r--r--drivers/media/platform/omap3isp/ispresizer.c6
-rw-r--r--drivers/media/platform/omap3isp/ispresizer.h4
-rw-r--r--drivers/media/platform/omap3isp/ispstat.c4
-rw-r--r--drivers/media/platform/omap3isp/ispvideo.c12
-rw-r--r--drivers/media/platform/s3c-camif/camif-capture.c17
-rw-r--r--drivers/media/platform/s5p-g2d/g2d.c7
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-core.c7
-rw-r--r--drivers/media/platform/s5p-mfc/regs-mfc-v6.h1
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc.c17
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_common.h2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_enc.c24
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c8
-rw-r--r--drivers/media/platform/s5p-tv/mixer_video.c6
-rw-r--r--drivers/media/platform/soc_camera/atmel-isi.c2
-rw-r--r--drivers/media/platform/soc_camera/mx2_camera.c2
-rw-r--r--drivers/media/platform/soc_camera/mx3_camera.c2
-rw-r--r--drivers/media/platform/soc_camera/rcar_vin.c11
-rw-r--r--drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c2
-rw-r--r--drivers/media/platform/ti-vpe/vpe.c6
-rw-r--r--drivers/media/platform/vivi.c54
-rw-r--r--drivers/media/platform/vsp1/vsp1.h2
-rw-r--r--drivers/media/platform/vsp1/vsp1_drv.c2
-rw-r--r--drivers/media/platform/vsp1/vsp1_entity.c2
-rw-r--r--drivers/media/platform/vsp1/vsp1_entity.h2
-rw-r--r--drivers/media/platform/vsp1/vsp1_lif.c2
-rw-r--r--drivers/media/platform/vsp1/vsp1_lif.h2
-rw-r--r--drivers/media/platform/vsp1/vsp1_rpf.c2
-rw-r--r--drivers/media/platform/vsp1/vsp1_rwpf.c2
-rw-r--r--drivers/media/platform/vsp1/vsp1_rwpf.h2
-rw-r--r--drivers/media/platform/vsp1/vsp1_uds.c2
-rw-r--r--drivers/media/platform/vsp1/vsp1_uds.h2
-rw-r--r--drivers/media/platform/vsp1/vsp1_video.c4
-rw-r--r--drivers/media/platform/vsp1/vsp1_video.h2
-rw-r--r--drivers/media/platform/vsp1/vsp1_wpf.c2
-rw-r--r--drivers/media/radio/radio-cadet.c46
-rw-r--r--drivers/media/radio/radio-keene.c19
-rw-r--r--drivers/media/radio/si4713/Kconfig6
-rw-r--r--drivers/media/radio/si4713/radio-usb-si4713.c4
-rw-r--r--drivers/media/rc/Kconfig11
-rw-r--r--drivers/media/rc/Makefile2
-rw-r--r--drivers/media/rc/ati_remote.c2
-rw-r--r--drivers/media/rc/ene_ir.c2
-rw-r--r--drivers/media/rc/fintek-cir.c2
-rw-r--r--drivers/media/rc/gpio-ir-recv.c4
-rw-r--r--drivers/media/rc/iguanair.c31
-rw-r--r--drivers/media/rc/img-ir/Kconfig61
-rw-r--r--drivers/media/rc/img-ir/Makefile11
-rw-r--r--drivers/media/rc/img-ir/img-ir-core.c176
-rw-r--r--drivers/media/rc/img-ir/img-ir-hw.c1053
-rw-r--r--drivers/media/rc/img-ir/img-ir-hw.h269
-rw-r--r--drivers/media/rc/img-ir/img-ir-jvc.c81
-rw-r--r--drivers/media/rc/img-ir/img-ir-nec.c148
-rw-r--r--drivers/media/rc/img-ir/img-ir-raw.c151
-rw-r--r--drivers/media/rc/img-ir/img-ir-raw.h60
-rw-r--r--drivers/media/rc/img-ir/img-ir-sanyo.c122
-rw-r--r--drivers/media/rc/img-ir/img-ir-sharp.c99
-rw-r--r--drivers/media/rc/img-ir/img-ir-sony.c145
-rw-r--r--drivers/media/rc/img-ir/img-ir.h166
-rw-r--r--drivers/media/rc/imon.c7
-rw-r--r--drivers/media/rc/ir-jvc-decoder.c2
-rw-r--r--drivers/media/rc/ir-lirc-codec.c2
-rw-r--r--drivers/media/rc/ir-mce_kbd-decoder.c2
-rw-r--r--drivers/media/rc/ir-nec-decoder.c11
-rw-r--r--drivers/media/rc/ir-raw.c5
-rw-r--r--drivers/media/rc/ir-rc5-decoder.c10
-rw-r--r--drivers/media/rc/ir-rc5-sz-decoder.c4
-rw-r--r--drivers/media/rc/ir-rc6-decoder.c6
-rw-r--r--drivers/media/rc/ir-sanyo-decoder.c6
-rw-r--r--drivers/media/rc/ir-sharp-decoder.c200
-rw-r--r--drivers/media/rc/ir-sony-decoder.c10
-rw-r--r--drivers/media/rc/ite-cir.c2
-rw-r--r--drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c4
-rw-r--r--drivers/media/rc/keymaps/rc-apac-viewcomp.c4
-rw-r--r--drivers/media/rc/keymaps/rc-asus-pc39.c4
-rw-r--r--drivers/media/rc/keymaps/rc-asus-ps3-100.c4
-rw-r--r--drivers/media/rc/keymaps/rc-ati-tv-wonder-hd-600.c4
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia-a16d.c4
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia-cardbus.c4
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia-dvbt.c4
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia-m135a.c4
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia-m733a-rm-k6.c2
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia.c4
-rw-r--r--drivers/media/rc/keymaps/rc-avertv-303.c4
-rw-r--r--drivers/media/rc/keymaps/rc-behold-columbus.c4
-rw-r--r--drivers/media/rc/keymaps/rc-behold.c4
-rw-r--r--drivers/media/rc/keymaps/rc-budget-ci-old.c4
-rw-r--r--drivers/media/rc/keymaps/rc-cinergy-1400.c4
-rw-r--r--drivers/media/rc/keymaps/rc-cinergy.c4
-rw-r--r--drivers/media/rc/keymaps/rc-dib0700-nec.c4
-rw-r--r--drivers/media/rc/keymaps/rc-dib0700-rc5.c4
-rw-r--r--drivers/media/rc/keymaps/rc-dm1105-nec.c4
-rw-r--r--drivers/media/rc/keymaps/rc-dntv-live-dvb-t.c4
-rw-r--r--drivers/media/rc/keymaps/rc-dntv-live-dvbt-pro.c4
-rw-r--r--drivers/media/rc/keymaps/rc-em-terratec.c4
-rw-r--r--drivers/media/rc/keymaps/rc-encore-enltv-fm53.c4
-rw-r--r--drivers/media/rc/keymaps/rc-encore-enltv.c4
-rw-r--r--drivers/media/rc/keymaps/rc-encore-enltv2.c4
-rw-r--r--drivers/media/rc/keymaps/rc-evga-indtube.c4
-rw-r--r--drivers/media/rc/keymaps/rc-eztv.c4
-rw-r--r--drivers/media/rc/keymaps/rc-flydvb.c4
-rw-r--r--drivers/media/rc/keymaps/rc-flyvideo.c4
-rw-r--r--drivers/media/rc/keymaps/rc-fusionhdtv-mce.c4
-rw-r--r--drivers/media/rc/keymaps/rc-gadmei-rm008z.c4
-rw-r--r--drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c4
-rw-r--r--drivers/media/rc/keymaps/rc-gotview7135.c4
-rw-r--r--drivers/media/rc/keymaps/rc-hauppauge.c4
-rw-r--r--drivers/media/rc/keymaps/rc-iodata-bctv7e.c4
-rw-r--r--drivers/media/rc/keymaps/rc-kaiomy.c4
-rw-r--r--drivers/media/rc/keymaps/rc-kworld-315u.c4
-rw-r--r--drivers/media/rc/keymaps/rc-kworld-pc150u.c2
-rw-r--r--drivers/media/rc/keymaps/rc-kworld-plus-tv-analog.c4
-rw-r--r--drivers/media/rc/keymaps/rc-manli.c4
-rw-r--r--drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c4
-rw-r--r--drivers/media/rc/keymaps/rc-msi-tvanywhere.c4
-rw-r--r--drivers/media/rc/keymaps/rc-nebula.c4
-rw-r--r--drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c6
-rw-r--r--drivers/media/rc/keymaps/rc-norwood.c4
-rw-r--r--drivers/media/rc/keymaps/rc-npgtech.c4
-rw-r--r--drivers/media/rc/keymaps/rc-pctv-sedna.c4
-rw-r--r--drivers/media/rc/keymaps/rc-pinnacle-color.c4
-rw-r--r--drivers/media/rc/keymaps/rc-pinnacle-grey.c4
-rw-r--r--drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c4
-rw-r--r--drivers/media/rc/keymaps/rc-pixelview-002t.c4
-rw-r--r--drivers/media/rc/keymaps/rc-pixelview-mk12.c4
-rw-r--r--drivers/media/rc/keymaps/rc-pixelview-new.c4
-rw-r--r--drivers/media/rc/keymaps/rc-pixelview.c4
-rw-r--r--drivers/media/rc/keymaps/rc-powercolor-real-angel.c4
-rw-r--r--drivers/media/rc/keymaps/rc-proteus-2309.c4
-rw-r--r--drivers/media/rc/keymaps/rc-purpletv.c4
-rw-r--r--drivers/media/rc/keymaps/rc-pv951.c4
-rw-r--r--drivers/media/rc/keymaps/rc-real-audio-220-32-keys.c4
-rw-r--r--drivers/media/rc/keymaps/rc-tbs-nec.c4
-rw-r--r--drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c4
-rw-r--r--drivers/media/rc/keymaps/rc-tevii-nec.c4
-rw-r--r--drivers/media/rc/keymaps/rc-tivo.c86
-rw-r--r--drivers/media/rc/keymaps/rc-tt-1500.c4
-rw-r--r--drivers/media/rc/keymaps/rc-videomate-s350.c4
-rw-r--r--drivers/media/rc/keymaps/rc-videomate-tv-pvr.c4
-rw-r--r--drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c4
-rw-r--r--drivers/media/rc/keymaps/rc-winfast.c4
-rw-r--r--drivers/media/rc/mceusb.c184
-rw-r--r--drivers/media/rc/nuvoton-cir.c12
-rw-r--r--drivers/media/rc/nuvoton-cir.h1
-rw-r--r--drivers/media/rc/rc-core-priv.h15
-rw-r--r--drivers/media/rc/rc-loopback.c2
-rw-r--r--drivers/media/rc/rc-main.c253
-rw-r--r--drivers/media/rc/redrat3.c2
-rw-r--r--drivers/media/rc/st_rc.c2
-rw-r--r--drivers/media/rc/streamzap.c2
-rw-r--r--drivers/media/rc/ttusbir.c2
-rw-r--r--drivers/media/rc/winbond-cir.c2
-rw-r--r--drivers/media/tuners/Kconfig1
-rw-r--r--drivers/media/tuners/e4000.c608
-rw-r--r--drivers/media/tuners/e4000.h21
-rw-r--r--drivers/media/tuners/e4000_priv.h88
-rw-r--r--drivers/media/tuners/mt2063.c4
-rw-r--r--drivers/media/tuners/r820t.c4
-rw-r--r--drivers/media/tuners/tda18212.c12
-rw-r--r--drivers/media/tuners/tda18212.h2
-rw-r--r--drivers/media/tuners/tuner-xc2028.c3
-rw-r--r--drivers/media/usb/au0828/au0828-cards.c23
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-input.c2
-rw-r--r--drivers/media/usb/dvb-usb-v2/Kconfig9
-rw-r--r--drivers/media/usb/dvb-usb-v2/Makefile4
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.c102
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.h2
-rw-r--r--drivers/media/usb/dvb-usb-v2/az6007.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb_core.c2
-rw-r--r--drivers/media/usb/dvb-usb-v2/it913x.c828
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.c123
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.h2
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-remote.c2
-rw-r--r--drivers/media/usb/em28xx/Kconfig2
-rw-r--r--drivers/media/usb/em28xx/em28xx-audio.c103
-rw-r--r--drivers/media/usb/em28xx/em28xx-camera.c4
-rw-r--r--drivers/media/usb/em28xx/em28xx-cards.c129
-rw-r--r--drivers/media/usb/em28xx/em28xx-core.c54
-rw-r--r--drivers/media/usb/em28xx/em28xx-dvb.c193
-rw-r--r--drivers/media/usb/em28xx/em28xx-i2c.c41
-rw-r--r--drivers/media/usb/em28xx/em28xx-input.c55
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c56
-rw-r--r--drivers/media/usb/em28xx/em28xx.h15
-rw-r--r--drivers/media/usb/gspca/kinect.c7
-rw-r--r--drivers/media/usb/gspca/sn9c20x.c1
-rw-r--r--drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c2
-rw-r--r--drivers/media/usb/gspca/topro.c10
-rw-r--r--drivers/media/usb/pwc/pwc-if.c19
-rw-r--r--drivers/media/usb/s2255/Kconfig2
-rw-r--r--drivers/media/usb/s2255/s2255drv.c1271
-rw-r--r--drivers/media/usb/siano/smsusb.c2
-rw-r--r--drivers/media/usb/stk1160/stk1160-v4l.c2
-rw-r--r--drivers/media/usb/tm6000/tm6000-alsa.c4
-rw-r--r--drivers/media/usb/tm6000/tm6000-dvb.c2
-rw-r--r--drivers/media/usb/tm6000/tm6000-input.c2
-rw-r--r--drivers/media/usb/tm6000/tm6000-stds.c2
-rw-r--r--drivers/media/usb/usbtv/Makefile3
-rw-r--r--drivers/media/usb/usbtv/usbtv-core.c134
-rw-r--r--drivers/media/usb/usbtv/usbtv-video.c (renamed from drivers/media/usb/usbtv/usbtv.c)171
-rw-r--r--drivers/media/usb/usbtv/usbtv.h99
-rw-r--r--drivers/media/usb/usbvision/usbvision.h8
-rw-r--r--drivers/media/usb/uvc/uvc_driver.c24
-rw-r--r--drivers/media/usb/uvc/uvc_queue.c29
-rw-r--r--drivers/media/usb/uvc/uvc_v4l2.c11
-rw-r--r--drivers/media/usb/uvc/uvc_video.c23
-rw-r--r--drivers/media/usb/uvc/uvcvideo.h16
-rw-r--r--drivers/media/v4l2-core/v4l2-compat-ioctl32.c133
-rw-r--r--drivers/media/v4l2-core/v4l2-ctrls.c33
-rw-r--r--drivers/media/v4l2-core/v4l2-dev.c32
-rw-r--r--drivers/media/v4l2-core/v4l2-dv-timings.c8
-rw-r--r--drivers/media/v4l2-core/v4l2-ioctl.c91
-rw-r--r--drivers/media/v4l2-core/v4l2-subdev.c18
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c658
-rw-r--r--drivers/of/base.c81
-rw-r--r--drivers/staging/media/Kconfig2
-rw-r--r--drivers/staging/media/Makefile2
-rw-r--r--drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c2
-rw-r--r--drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c6
-rw-r--r--drivers/staging/media/davinci_vpfe/vpfe_video.c3
-rw-r--r--drivers/staging/media/dt3155v4l/dt3155v4l.c5
-rw-r--r--drivers/staging/media/go7007/go7007-v4l2.c5
-rw-r--r--drivers/staging/media/msi3101/Kconfig7
-rw-r--r--drivers/staging/media/msi3101/Makefile1
-rw-r--r--drivers/staging/media/msi3101/msi001.c500
-rw-r--r--drivers/staging/media/msi3101/sdr-msi3101.c1566
-rw-r--r--drivers/staging/media/omap4iss/iss_video.c2
-rw-r--r--drivers/staging/media/rtl2832u_sdr/Kconfig7
-rw-r--r--drivers/staging/media/rtl2832u_sdr/Makefile6
-rw-r--r--drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c1500
-rw-r--r--drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.h54
-rw-r--r--drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c2
-rw-r--r--drivers/staging/media/solo6x10/solo6x10-v4l2.c2
-rw-r--r--include/media/adv7842.h3
-rw-r--r--include/media/lm3646.h87
-rw-r--r--include/media/rc-core.h80
-rw-r--r--include/media/rc-map.h6
-rw-r--r--include/media/v4l2-dev.h3
-rw-r--r--include/media/v4l2-ioctl.h10
-rw-r--r--include/media/v4l2-subdev.h9
-rw-r--r--include/media/videobuf2-core.h117
-rw-r--r--include/trace/events/v4l2.h1
-rw-r--r--include/uapi/linux/v4l2-common.h8
-rw-r--r--include/uapi/linux/v4l2-controls.h19
-rw-r--r--include/uapi/linux/v4l2-dv-timings.h17
-rw-r--r--include/uapi/linux/v4l2-subdev.h14
-rw-r--r--include/uapi/linux/videodev2.h74
384 files changed, 44014 insertions, 7923 deletions
diff --git a/CREDITS b/CREDITS
index 61eabf7ca376..c322dcfb926d 100644
--- a/CREDITS
+++ b/CREDITS
@@ -630,6 +630,13 @@ N: Michael Elizabeth Chastain
630E: mec@shout.net 630E: mec@shout.net
631D: Configure, Menuconfig, xconfig 631D: Configure, Menuconfig, xconfig
632 632
633N: Mauro Carvalho Chehab
634E: m.chehab@samsung.org
635E: mchehab@infradead.org
636D: Media subsystem (V4L/DVB) drivers and core
637D: EDAC drivers and EDAC 3.0 core rework
638S: Brazil
639
633N: Raymond Chen 640N: Raymond Chen
634E: raymondc@microsoft.com 641E: raymondc@microsoft.com
635D: Author of Configure script 642D: Author of Configure script
diff --git a/Documentation/ABI/testing/sysfs-class-rc b/Documentation/ABI/testing/sysfs-class-rc
new file mode 100644
index 000000000000..b65674da43bb
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-rc
@@ -0,0 +1,111 @@
1What: /sys/class/rc/
2Date: Apr 2010
3KernelVersion: 2.6.35
4Contact: Mauro Carvalho Chehab <m.chehab@samsung.com>
5Description:
6 The rc/ class sub-directory belongs to the Remote Controller
7 core and provides a sysfs interface for configuring infrared
8 remote controller receivers.
9
10What: /sys/class/rc/rcN/
11Date: Apr 2010
12KernelVersion: 2.6.35
13Contact: Mauro Carvalho Chehab <m.chehab@samsung.com>
14Description:
15 A /sys/class/rc/rcN directory is created for each remote
16 control receiver device where N is the number of the receiver.
17
18What: /sys/class/rc/rcN/protocols
19Date: Jun 2010
20KernelVersion: 2.6.36
21Contact: Mauro Carvalho Chehab <m.chehab@samsung.com>
22Description:
23 Reading this file returns a list of available protocols,
24 something like:
25 "rc5 [rc6] nec jvc [sony]"
26 Enabled protocols are shown in [] brackets.
27 Writing "+proto" will add a protocol to the list of enabled
28 protocols.
29 Writing "-proto" will remove a protocol from the list of enabled
30 protocols.
31 Writing "proto" will enable only "proto".
32 Writing "none" will disable all protocols.
33 Write fails with EINVAL if an invalid protocol combination or
34 unknown protocol name is used.
35
36What: /sys/class/rc/rcN/filter
37Date: Jan 2014
38KernelVersion: 3.15
39Contact: Mauro Carvalho Chehab <m.chehab@samsung.com>
40Description:
41 Sets the scancode filter expected value.
42 Use in combination with /sys/class/rc/rcN/filter_mask to set the
43 expected value of the bits set in the filter mask.
44 If the hardware supports it then scancodes which do not match
45 the filter will be ignored. Otherwise the write will fail with
46 an error.
47 This value may be reset to 0 if the current protocol is altered.
48
49What: /sys/class/rc/rcN/filter_mask
50Date: Jan 2014
51KernelVersion: 3.15
52Contact: Mauro Carvalho Chehab <m.chehab@samsung.com>
53Description:
54 Sets the scancode filter mask of bits to compare.
55 Use in combination with /sys/class/rc/rcN/filter to set the bits
56 of the scancode which should be compared against the expected
57 value. A value of 0 disables the filter to allow all valid
58 scancodes to be processed.
59 If the hardware supports it then scancodes which do not match
60 the filter will be ignored. Otherwise the write will fail with
61 an error.
62 This value may be reset to 0 if the current protocol is altered.
63
64What: /sys/class/rc/rcN/wakeup_protocols
65Date: Feb 2014
66KernelVersion: 3.15
67Contact: Mauro Carvalho Chehab <m.chehab@samsung.com>
68Description:
69 Reading this file returns a list of available protocols to use
70 for the wakeup filter, something like:
71 "rc5 rc6 nec jvc [sony]"
72 The enabled wakeup protocol is shown in [] brackets.
73 Writing "+proto" will add a protocol to the list of enabled
74 wakeup protocols.
75 Writing "-proto" will remove a protocol from the list of enabled
76 wakeup protocols.
77 Writing "proto" will use "proto" for wakeup events.
78 Writing "none" will disable wakeup.
79 Write fails with EINVAL if an invalid protocol combination or
80 unknown protocol name is used, or if wakeup is not supported by
81 the hardware.
82
83What: /sys/class/rc/rcN/wakeup_filter
84Date: Jan 2014
85KernelVersion: 3.15
86Contact: Mauro Carvalho Chehab <m.chehab@samsung.com>
87Description:
88 Sets the scancode wakeup filter expected value.
89 Use in combination with /sys/class/rc/rcN/wakeup_filter_mask to
90 set the expected value of the bits set in the wakeup filter mask
91 to trigger a system wake event.
92 If the hardware supports it and wakeup_filter_mask is not 0 then
93 scancodes which match the filter will wake the system from e.g.
94 suspend to RAM or power off.
95 Otherwise the write will fail with an error.
96 This value may be reset to 0 if the wakeup protocol is altered.
97
98What: /sys/class/rc/rcN/wakeup_filter_mask
99Date: Jan 2014
100KernelVersion: 3.15
101Contact: Mauro Carvalho Chehab <m.chehab@samsung.com>
102Description:
103 Sets the scancode wakeup filter mask of bits to compare.
104 Use in combination with /sys/class/rc/rcN/wakeup_filter to set
105 the bits of the scancode which should be compared against the
106 expected value to trigger a system wake event.
107 If the hardware supports it and wakeup_filter_mask is not 0 then
108 scancodes which match the filter will wake the system from e.g.
109 suspend to RAM or power off.
110 Otherwise the write will fail with an error.
111 This value may be reset to 0 if the wakeup protocol is altered.
diff --git a/Documentation/DocBook/media/dvb/demux.xml b/Documentation/DocBook/media/dvb/demux.xml
index 86de89cfbd67..c8683d66f059 100644
--- a/Documentation/DocBook/media/dvb/demux.xml
+++ b/Documentation/DocBook/media/dvb/demux.xml
@@ -1042,7 +1042,14 @@ role="subsection"><title>DMX_ADD_PID</title>
1042</para> 1042</para>
1043<informaltable><tgroup cols="1"><tbody><row><entry 1043<informaltable><tgroup cols="1"><tbody><row><entry
1044 align="char"> 1044 align="char">
1045<para>This ioctl is undocumented. Documentation is welcome.</para> 1045<para>This ioctl call allows to add multiple PIDs to a transport stream filter
1046previously set up with DMX_SET_PES_FILTER and output equal to DMX_OUT_TSDEMUX_TAP.
1047</para></entry></row><row><entry align="char"><para>
1048It is used by readers of /dev/dvb/adapterX/demuxY.
1049</para></entry></row><row><entry align="char"><para>
1050It may be called at any time, i.e. before or after the first filter on the
1051shared file descriptor was started. It makes it possible to record multiple
1052services without the need to de-multiplex or re-multiplex TS packets.</para>
1046</entry> 1053</entry>
1047 </row></tbody></tgroup></informaltable> 1054 </row></tbody></tgroup></informaltable>
1048<para>SYNOPSIS 1055<para>SYNOPSIS
@@ -1075,7 +1082,7 @@ role="subsection"><title>DMX_ADD_PID</title>
1075</para> 1082</para>
1076</entry><entry 1083</entry><entry
1077 align="char"> 1084 align="char">
1078<para>Undocumented.</para> 1085<para>PID number to be filtered.</para>
1079</entry> 1086</entry>
1080 </row></tbody></tgroup></informaltable> 1087 </row></tbody></tgroup></informaltable>
1081&return-value-dvb; 1088&return-value-dvb;
@@ -1087,7 +1094,15 @@ role="subsection"><title>DMX_REMOVE_PID</title>
1087</para> 1094</para>
1088<informaltable><tgroup cols="1"><tbody><row><entry 1095<informaltable><tgroup cols="1"><tbody><row><entry
1089 align="char"> 1096 align="char">
1090<para>This ioctl is undocumented. Documentation is welcome.</para> 1097<para>This ioctl call allows to remove a PID when multiple PIDs are set on a
1098transport stream filter, e. g. a filter previously set up with output equal to
1099DMX_OUT_TSDEMUX_TAP, created via either DMX_SET_PES_FILTER or DMX_ADD_PID.
1100</para></entry></row><row><entry align="char"><para>
1101It is used by readers of /dev/dvb/adapterX/demuxY.
1102</para></entry></row><row><entry align="char"><para>
1103It may be called at any time, i.e. before or after the first filter on the
1104shared file descriptor was started. It makes it possible to record multiple
1105services without the need to de-multiplex or re-multiplex TS packets.</para>
1091</entry> 1106</entry>
1092 </row></tbody></tgroup></informaltable> 1107 </row></tbody></tgroup></informaltable>
1093<para>SYNOPSIS 1108<para>SYNOPSIS
@@ -1120,7 +1135,7 @@ role="subsection"><title>DMX_REMOVE_PID</title>
1120</para> 1135</para>
1121</entry><entry 1136</entry><entry
1122 align="char"> 1137 align="char">
1123<para>Undocumented.</para> 1138<para>PID of the PES filter to be removed.</para>
1124</entry> 1139</entry>
1125 </row></tbody></tgroup></informaltable> 1140 </row></tbody></tgroup></informaltable>
1126&return-value-dvb; 1141&return-value-dvb;
diff --git a/Documentation/DocBook/media/dvb/dvbapi.xml b/Documentation/DocBook/media/dvb/dvbapi.xml
index 0197bcc7842d..4c15396c67e5 100644
--- a/Documentation/DocBook/media/dvb/dvbapi.xml
+++ b/Documentation/DocBook/media/dvb/dvbapi.xml
@@ -18,7 +18,7 @@
18<firstname>Mauro</firstname> 18<firstname>Mauro</firstname>
19<othername role="mi">Carvalho</othername> 19<othername role="mi">Carvalho</othername>
20<surname>Chehab</surname> 20<surname>Chehab</surname>
21<affiliation><address><email>mchehab@redhat.com</email></address></affiliation> 21<affiliation><address><email>m.chehab@samsung.com</email></address></affiliation>
22<contrib>Ported document to Docbook XML.</contrib> 22<contrib>Ported document to Docbook XML.</contrib>
23</author> 23</author>
24</authorgroup> 24</authorgroup>
@@ -28,7 +28,7 @@
28 <holder>Convergence GmbH</holder> 28 <holder>Convergence GmbH</holder>
29</copyright> 29</copyright>
30<copyright> 30<copyright>
31 <year>2009-2012</year> 31 <year>2009-2014</year>
32 <holder>Mauro Carvalho Chehab</holder> 32 <holder>Mauro Carvalho Chehab</holder>
33</copyright> 33</copyright>
34 34
diff --git a/Documentation/DocBook/media/dvb/frontend.xml b/Documentation/DocBook/media/dvb/frontend.xml
index 0d6e81bd9ed2..8a6a6ff27af5 100644
--- a/Documentation/DocBook/media/dvb/frontend.xml
+++ b/Documentation/DocBook/media/dvb/frontend.xml
@@ -744,7 +744,7 @@ typedef enum fe_hierarchy {
744</para> 744</para>
745<informaltable><tgroup cols="1"><tbody><row><entry 745<informaltable><tgroup cols="1"><tbody><row><entry
746 align="char"> 746 align="char">
747<para>int ioctl(int fd, int request = <link linkend="FE_READ_SNR">FE_READ_SNR</link>, int16_t 747<para>int ioctl(int fd, int request = <link linkend="FE_READ_SNR">FE_READ_SNR</link>, uint16_t
748 &#x22C6;snr);</para> 748 &#x22C6;snr);</para>
749</entry> 749</entry>
750 </row></tbody></tgroup></informaltable> 750 </row></tbody></tgroup></informaltable>
@@ -766,7 +766,7 @@ typedef enum fe_hierarchy {
766</entry> 766</entry>
767 </row><row><entry 767 </row><row><entry
768 align="char"> 768 align="char">
769<para>int16_t *snr</para> 769<para>uint16_t *snr</para>
770</entry><entry 770</entry><entry
771 align="char"> 771 align="char">
772<para>The signal-to-noise ratio is stored into *snr.</para> 772<para>The signal-to-noise ratio is stored into *snr.</para>
@@ -791,7 +791,7 @@ typedef enum fe_hierarchy {
791<informaltable><tgroup cols="1"><tbody><row><entry 791<informaltable><tgroup cols="1"><tbody><row><entry
792 align="char"> 792 align="char">
793<para>int ioctl( int fd, int request = 793<para>int ioctl( int fd, int request =
794 <link linkend="FE_READ_SIGNAL_STRENGTH">FE_READ_SIGNAL_STRENGTH</link>, int16_t &#x22C6;strength);</para> 794 <link linkend="FE_READ_SIGNAL_STRENGTH">FE_READ_SIGNAL_STRENGTH</link>, uint16_t &#x22C6;strength);</para>
795</entry> 795</entry>
796 </row></tbody></tgroup></informaltable> 796 </row></tbody></tgroup></informaltable>
797 797
@@ -814,7 +814,7 @@ typedef enum fe_hierarchy {
814</entry> 814</entry>
815 </row><row><entry 815 </row><row><entry
816 align="char"> 816 align="char">
817<para>int16_t *strength</para> 817<para>uint16_t *strength</para>
818</entry><entry 818</entry><entry
819 align="char"> 819 align="char">
820<para>The signal strength value is stored into *strength.</para> 820<para>The signal strength value is stored into *strength.</para>
diff --git a/Documentation/DocBook/media/v4l/common.xml b/Documentation/DocBook/media/v4l/common.xml
index 1ddf354aa997..71f6bf9e735e 100644
--- a/Documentation/DocBook/media/v4l/common.xml
+++ b/Documentation/DocBook/media/v4l/common.xml
@@ -38,70 +38,41 @@ the basic concepts applicable to all devices.</para>
38 38
39 <para>V4L2 drivers are implemented as kernel modules, loaded 39 <para>V4L2 drivers are implemented as kernel modules, loaded
40manually by the system administrator or automatically when a device is 40manually by the system administrator or automatically when a device is
41first opened. The driver modules plug into the "videodev" kernel 41first discovered. The driver modules plug into the "videodev" kernel
42module. It provides helper functions and a common application 42module. It provides helper functions and a common application
43interface specified in this document.</para> 43interface specified in this document.</para>
44 44
45 <para>Each driver thus loaded registers one or more device nodes 45 <para>Each driver thus loaded registers one or more device nodes
46with major number 81 and a minor number between 0 and 255. Assigning 46with major number 81 and a minor number between 0 and 255. Minor numbers
47minor numbers to V4L2 devices is entirely up to the system administrator, 47are allocated dynamically unless the kernel is compiled with the kernel
48this is primarily intended to solve conflicts between devices.<footnote> 48option CONFIG_VIDEO_FIXED_MINOR_RANGES. In that case minor numbers are
49 <para>Access permissions are associated with character 49allocated in ranges depending on the device node type (video, radio, etc.).</para>
50device special files, hence we must ensure device numbers cannot 50
51change with the module load order. To this end minor numbers are no 51 <para>Many drivers support "video_nr", "radio_nr" or "vbi_nr"
52longer automatically assigned by the "videodev" module as in V4L but 52module options to select specific video/radio/vbi node numbers. This allows
53requested by the driver. The defaults will suffice for most people 53the user to request that the device node is named e.g. /dev/video5 instead
54unless two drivers compete for the same minor numbers.</para> 54of leaving it to chance. When the driver supports multiple devices of the same
55 </footnote> The module options to select minor numbers are named 55type more than one device node number can be assigned, separated by commas:
56after the device special file with a "_nr" suffix. For example "video_nr" 56 <informalexample>
57for <filename>/dev/video</filename> video capture devices. The number is
58an offset to the base minor number associated with the device type.
59<footnote>
60 <para>In earlier versions of the V4L2 API the module options
61where named after the device special file with a "unit_" prefix, expressing
62the minor number itself, not an offset. Rationale for this change is unknown.
63Lastly the naming and semantics are just a convention among driver writers,
64the point to note is that minor numbers are not supposed to be hardcoded
65into drivers.</para>
66 </footnote> When the driver supports multiple devices of the same
67type more than one minor number can be assigned, separated by commas:
68<informalexample>
69 <screen> 57 <screen>
70&gt; insmod mydriver.o video_nr=0,1 radio_nr=0,1</screen> 58&gt; modprobe mydriver video_nr=0,1 radio_nr=0,1</screen>
71 </informalexample></para> 59 </informalexample></para>
72 60
73 <para>In <filename>/etc/modules.conf</filename> this may be 61 <para>In <filename>/etc/modules.conf</filename> this may be
74written as: <informalexample> 62written as: <informalexample>
75 <screen> 63 <screen>
76alias char-major-81-0 mydriver 64options mydriver video_nr=0,1 radio_nr=0,1
77alias char-major-81-1 mydriver
78alias char-major-81-64 mydriver <co id="alias" />
79options mydriver video_nr=0,1 radio_nr=0,1 <co id="options" />
80 </screen> 65 </screen>
81 <calloutlist> 66 </informalexample> When no device node number is given as module
82 <callout arearefs="alias"> 67option the driver supplies a default.</para>
83 <para>When an application attempts to open a device 68
84special file with major number 81 and minor number 0, 1, or 64, load 69 <para>Normally udev will create the device nodes in /dev automatically
85"mydriver" (and the "videodev" module it depends upon).</para> 70for you. If udev is not installed, then you need to enable the
86 </callout> 71CONFIG_VIDEO_FIXED_MINOR_RANGES kernel option in order to be able to correctly
87 <callout arearefs="options"> 72relate a minor number to a device node number. I.e., you need to be certain
88 <para>Register the first two video capture devices with 73that minor number 5 maps to device node name video5. With this kernel option
89minor number 0 and 1 (base number is 0), the first two radio device 74different device types have different minor number ranges. These ranges are
90with minor number 64 and 65 (base 64).</para> 75listed in <xref linkend="devices" />.
91 </callout>
92 </calloutlist>
93 </informalexample> When no minor number is given as module
94option the driver supplies a default. <xref linkend="devices" />
95recommends the base minor numbers to be used for the various device
96types. Obviously minor numbers must be unique. When the number is
97already in use the <emphasis>offending device</emphasis> will not be
98registered. <!-- Blessed by Linus Torvalds on
99linux-kernel@vger.kernel.org, 2002-11-20. --></para>
100
101 <para>By convention system administrators create various
102character device special files with these major and minor numbers in
103the <filename>/dev</filename> directory. The names recommended for the
104different V4L2 device types are listed in <xref linkend="devices" />.
105</para> 76</para>
106 77
107 <para>The creation of character special files (with 78 <para>The creation of character special files (with
@@ -110,85 +81,66 @@ devices cannot be opened by major and minor number. That means
110applications cannot <emphasis>reliable</emphasis> scan for loaded or 81applications cannot <emphasis>reliable</emphasis> scan for loaded or
111installed drivers. The user must enter a device name, or the 82installed drivers. The user must enter a device name, or the
112application can try the conventional device names.</para> 83application can try the conventional device names.</para>
113
114 <para>Under the device filesystem (devfs) the minor number
115options are ignored. V4L2 drivers (or by proxy the "videodev" module)
116automatically create the required device files in the
117<filename>/dev/v4l</filename> directory using the conventional device
118names above.</para>
119 </section> 84 </section>
120 85
121 <section id="related"> 86 <section id="related">
122 <title>Related Devices</title> 87 <title>Related Devices</title>
123 88
124 <para>Devices can support several related functions. For example 89 <para>Devices can support several functions. For example
125video capturing, video overlay and VBI capturing are related because 90video capturing, VBI capturing and radio support.</para>
126these functions share, amongst other, the same video input and tuner 91
127frequency. V4L and earlier versions of V4L2 used the same device name 92 <para>The V4L2 API creates different nodes for each of these functions.</para>
128and minor number for video capturing and overlay, but different ones 93
129for VBI. Experience showed this approach has several problems<footnote> 94 <para>The V4L2 API was designed with the idea that one device node could support
130 <para>Given a device file name one cannot reliable find 95all functions. However, in practice this never worked: this 'feature'
131related devices. For once names are arbitrary and in a system with 96was never used by applications and many drivers did not support it and if
132multiple devices, where only some support VBI capturing, a 97they did it was certainly never tested. In addition, switching a device
133<filename>/dev/video2</filename> is not necessarily related to 98node between different functions only works when using the streaming I/O
134<filename>/dev/vbi2</filename>. The V4L 99API, not with the read()/write() API.</para>
135<constant>VIDIOCGUNIT</constant> ioctl would require a search for a 100
136device file with a particular major and minor number.</para> 101 <para>Today each device node supports just one function.</para>
137 </footnote>, and to make things worse the V4L videodev module
138used to prohibit multiple opens of a device.</para>
139
140 <para>As a remedy the present version of the V4L2 API relaxed the
141concept of device types with specific names and minor numbers. For
142compatibility with old applications drivers must still register different
143minor numbers to assign a default function to the device. But if related
144functions are supported by the driver they must be available under all
145registered minor numbers. The desired function can be selected after
146opening the device as described in <xref linkend="devices" />.</para>
147
148 <para>Imagine a driver supporting video capturing, video
149overlay, raw VBI capturing, and FM radio reception. It registers three
150devices with minor number 0, 64 and 224 (this numbering scheme is
151inherited from the V4L API). Regardless if
152<filename>/dev/video</filename> (81, 0) or
153<filename>/dev/vbi</filename> (81, 224) is opened the application can
154select any one of the video capturing, overlay or VBI capturing
155functions. Without programming (e.&nbsp;g. reading from the device
156with <application>dd</application> or <application>cat</application>)
157<filename>/dev/video</filename> captures video images, while
158<filename>/dev/vbi</filename> captures raw VBI data.
159<filename>/dev/radio</filename> (81, 64) is invariable a radio device,
160unrelated to the video functions. Being unrelated does not imply the
161devices can be used at the same time, however. The &func-open;
162function may very well return an &EBUSY;.</para>
163 102
164 <para>Besides video input or output the hardware may also 103 <para>Besides video input or output the hardware may also
165support audio sampling or playback. If so, these functions are 104support audio sampling or playback. If so, these functions are
166implemented as OSS or ALSA PCM devices and eventually OSS or ALSA 105implemented as ALSA PCM devices with optional ALSA audio mixer
167audio mixer. The V4L2 API makes no provisions yet to find these 106devices.</para>
168related devices. If you have an idea please write to the linux-media 107
169mailing list: &v4l-ml;.</para> 108 <para>One problem with all these devices is that the V4L2 API
109makes no provisions to find these related devices. Some really
110complex devices use the Media Controller (see <xref linkend="media_controller" />)
111which can be used for this purpose. But most drivers do not use it,
112and while some code exists that uses sysfs to discover related devices
113(see libmedia_dev in the <ulink url="http://git.linuxtv.org/v4l-utils/">v4l-utils</ulink>
114git repository), there is no library yet that can provide a single API towards
115both Media Controller-based devices and devices that do not use the Media Controller.
116If you want to work on this please write to the linux-media mailing list: &v4l-ml;.</para>
170 </section> 117 </section>
171 118
172 <section> 119 <section>
173 <title>Multiple Opens</title> 120 <title>Multiple Opens</title>
174 121
175 <para>In general, V4L2 devices can be opened more than once. 122 <para>V4L2 devices can be opened more than once.<footnote><para>
123There are still some old and obscure drivers that have not been updated to
124allow for multiple opens. This implies that for such drivers &func-open; can
125return an &EBUSY; when the device is already in use.</para></footnote>
176When this is supported by the driver, users can for example start a 126When this is supported by the driver, users can for example start a
177"panel" application to change controls like brightness or audio 127"panel" application to change controls like brightness or audio
178volume, while another application captures video and audio. In other words, panel 128volume, while another application captures video and audio. In other words, panel
179applications are comparable to an OSS or ALSA audio mixer application. 129applications are comparable to an ALSA audio mixer application.
180When a device supports multiple functions like capturing and overlay 130Just opening a V4L2 device should not change the state of the device.<footnote>
181<emphasis>simultaneously</emphasis>, multiple opens allow concurrent 131<para>Unfortunately, opening a radio device often switches the state of the
182use of the device by forked processes or specialized applications.</para> 132device to radio mode in many drivers. This behavior should be fixed eventually
183 133as it violates the V4L2 specification.</para></footnote></para>
184 <para>Multiple opens are optional, although drivers should 134
185permit at least concurrent accesses without data exchange, &ie; panel 135 <para>Once an application has allocated the memory buffers needed for
186applications. This implies &func-open; can return an &EBUSY; when the 136streaming data (by calling the &VIDIOC-REQBUFS; or &VIDIOC-CREATE-BUFS; ioctls,
187device is already in use, as well as &func-ioctl; functions initiating 137or implicitly by calling the &func-read; or &func-write; functions) that
188data exchange (namely the &VIDIOC-S-FMT; ioctl), and the &func-read; 138application (filehandle) becomes the owner of the device. It is no longer
189and &func-write; functions.</para> 139allowed to make changes that would affect the buffer sizes (e.g. by calling
190 140the &VIDIOC-S-FMT; ioctl) and other applications are no longer allowed to allocate
191 <para>Mere opening a V4L2 device does not grant exclusive 141buffers or start or stop streaming. The &EBUSY; will be returned instead.</para>
142
143 <para>Merely opening a V4L2 device does not grant exclusive
192access.<footnote> 144access.<footnote>
193 <para>Drivers could recognize the 145 <para>Drivers could recognize the
194<constant>O_EXCL</constant> open flag. Presently this is not required, 146<constant>O_EXCL</constant> open flag. Presently this is not required,
@@ -206,12 +158,7 @@ additional access privileges using the priority mechanism described in
206 <para>V4L2 drivers should not support multiple applications 158 <para>V4L2 drivers should not support multiple applications
207reading or writing the same data stream on a device by copying 159reading or writing the same data stream on a device by copying
208buffers, time multiplexing or similar means. This is better handled by 160buffers, time multiplexing or similar means. This is better handled by
209a proxy application in user space. When the driver supports stream 161a proxy application in user space.</para>
210sharing anyway it must be implemented transparently. The V4L2 API does
211not specify how conflicts are solved. <!-- For example O_EXCL when the
212application does not want to be preempted, PROT_READ mmapped buffers
213which can be mapped twice, what happens when image formats do not
214match etc.--></para>
215 </section> 162 </section>
216 163
217 <section> 164 <section>
@@ -240,15 +187,15 @@ methods</link> supported by the device.</para>
240 187
241 <para>Starting with kernel version 3.1, VIDIOC-QUERYCAP will return the 188 <para>Starting with kernel version 3.1, VIDIOC-QUERYCAP will return the
242V4L2 API version used by the driver, with generally matches the Kernel version. 189V4L2 API version used by the driver, with generally matches the Kernel version.
243There's no need of using &VIDIOC-QUERYCAP; to check if an specific ioctl is 190There's no need of using &VIDIOC-QUERYCAP; to check if a specific ioctl is
244supported, the V4L2 core now returns ENOIOCTLCMD if a driver doesn't provide 191supported, the V4L2 core now returns ENOTTY if a driver doesn't provide
245support for an ioctl.</para> 192support for an ioctl.</para>
246 193
247 <para>Other features can be queried 194 <para>Other features can be queried
248by calling the respective ioctl, for example &VIDIOC-ENUMINPUT; 195by calling the respective ioctl, for example &VIDIOC-ENUMINPUT;
249to learn about the number, types and names of video connectors on the 196to learn about the number, types and names of video connectors on the
250device. Although abstraction is a major objective of this API, the 197device. Although abstraction is a major objective of this API, the
251ioctl also allows driver specific applications to reliable identify 198&VIDIOC-QUERYCAP; ioctl also allows driver specific applications to reliably identify
252the driver.</para> 199the driver.</para>
253 200
254 <para>All V4L2 drivers must support 201 <para>All V4L2 drivers must support
@@ -278,9 +225,7 @@ Applications requiring a different priority will usually call
278the &VIDIOC-QUERYCAP; ioctl.</para> 225the &VIDIOC-QUERYCAP; ioctl.</para>
279 226
280 <para>Ioctls changing driver properties, such as &VIDIOC-S-INPUT;, 227 <para>Ioctls changing driver properties, such as &VIDIOC-S-INPUT;,
281return an &EBUSY; after another application obtained higher priority. 228return an &EBUSY; after another application obtained higher priority.</para>
282An event mechanism to notify applications about asynchronous property
283changes has been proposed but not added yet.</para>
284 </section> 229 </section>
285 230
286 <section id="video"> 231 <section id="video">
@@ -288,9 +233,9 @@ changes has been proposed but not added yet.</para>
288 233
289 <para>Video inputs and outputs are physical connectors of a 234 <para>Video inputs and outputs are physical connectors of a
290device. These can be for example RF connectors (antenna/cable), CVBS 235device. These can be for example RF connectors (antenna/cable), CVBS
291a.k.a. Composite Video, S-Video or RGB connectors. Only video and VBI 236a.k.a. Composite Video, S-Video or RGB connectors. Video and VBI
292capture devices have inputs, output devices have outputs, at least one 237capture devices have inputs. Video and VBI output devices have outputs,
293each. Radio devices have no video inputs or outputs.</para> 238at least one each. Radio devices have no video inputs or outputs.</para>
294 239
295 <para>To learn about the number and attributes of the 240 <para>To learn about the number and attributes of the
296available inputs and outputs applications can enumerate them with the 241available inputs and outputs applications can enumerate them with the
@@ -299,30 +244,13 @@ available inputs and outputs applications can enumerate them with the
299ioctl also contains signal status information applicable when the 244ioctl also contains signal status information applicable when the
300current video input is queried.</para> 245current video input is queried.</para>
301 246
302 <para>The &VIDIOC-G-INPUT; and &VIDIOC-G-OUTPUT; ioctl return the 247 <para>The &VIDIOC-G-INPUT; and &VIDIOC-G-OUTPUT; ioctls return the
303index of the current video input or output. To select a different 248index of the current video input or output. To select a different
304input or output applications call the &VIDIOC-S-INPUT; and 249input or output applications call the &VIDIOC-S-INPUT; and
305&VIDIOC-S-OUTPUT; ioctl. Drivers must implement all the input ioctls 250&VIDIOC-S-OUTPUT; ioctls. Drivers must implement all the input ioctls
306when the device has one or more inputs, all the output ioctls when the 251when the device has one or more inputs, all the output ioctls when the
307device has one or more outputs.</para> 252device has one or more outputs.</para>
308 253
309 <!--
310 <figure id=io-tree>
311 <title>Input and output enumeration is the root of most device properties.</title>
312 <mediaobject>
313 <imageobject>
314 <imagedata fileref="links.pdf" format="ps" />
315 </imageobject>
316 <imageobject>
317 <imagedata fileref="links.gif" format="gif" />
318 </imageobject>
319 <textobject>
320 <phrase>Links between various device property structures.</phrase>
321 </textobject>
322 </mediaobject>
323 </figure>
324 -->
325
326 <example> 254 <example>
327 <title>Information about the current video input</title> 255 <title>Information about the current video input</title>
328 256
@@ -330,20 +258,20 @@ device has one or more outputs.</para>
330&v4l2-input; input; 258&v4l2-input; input;
331int index; 259int index;
332 260
333if (-1 == ioctl (fd, &VIDIOC-G-INPUT;, &amp;index)) { 261if (-1 == ioctl(fd, &VIDIOC-G-INPUT;, &amp;index)) {
334 perror ("VIDIOC_G_INPUT"); 262 perror("VIDIOC_G_INPUT");
335 exit (EXIT_FAILURE); 263 exit(EXIT_FAILURE);
336} 264}
337 265
338memset (&amp;input, 0, sizeof (input)); 266memset(&amp;input, 0, sizeof(input));
339input.index = index; 267input.index = index;
340 268
341if (-1 == ioctl (fd, &VIDIOC-ENUMINPUT;, &amp;input)) { 269if (-1 == ioctl(fd, &VIDIOC-ENUMINPUT;, &amp;input)) {
342 perror ("VIDIOC_ENUMINPUT"); 270 perror("VIDIOC_ENUMINPUT");
343 exit (EXIT_FAILURE); 271 exit(EXIT_FAILURE);
344} 272}
345 273
346printf ("Current input: %s\n", input.name); 274printf("Current input: %s\n", input.name);
347 </programlisting> 275 </programlisting>
348 </example> 276 </example>
349 277
@@ -355,9 +283,9 @@ int index;
355 283
356index = 0; 284index = 0;
357 285
358if (-1 == ioctl (fd, &VIDIOC-S-INPUT;, &amp;index)) { 286if (-1 == ioctl(fd, &VIDIOC-S-INPUT;, &amp;index)) {
359 perror ("VIDIOC_S_INPUT"); 287 perror("VIDIOC_S_INPUT");
360 exit (EXIT_FAILURE); 288 exit(EXIT_FAILURE);
361} 289}
362 </programlisting> 290 </programlisting>
363 </example> 291 </example>
@@ -397,7 +325,7 @@ available inputs and outputs applications can enumerate them with the
397also contains signal status information applicable when the current 325also contains signal status information applicable when the current
398audio input is queried.</para> 326audio input is queried.</para>
399 327
400 <para>The &VIDIOC-G-AUDIO; and &VIDIOC-G-AUDOUT; ioctl report 328 <para>The &VIDIOC-G-AUDIO; and &VIDIOC-G-AUDOUT; ioctls report
401the current audio input and output, respectively. Note that, unlike 329the current audio input and output, respectively. Note that, unlike
402&VIDIOC-G-INPUT; and &VIDIOC-G-OUTPUT; these ioctls return a structure 330&VIDIOC-G-INPUT; and &VIDIOC-G-OUTPUT; these ioctls return a structure
403as <constant>VIDIOC_ENUMAUDIO</constant> and 331as <constant>VIDIOC_ENUMAUDIO</constant> and
@@ -408,11 +336,11 @@ applications call the &VIDIOC-S-AUDIO; ioctl. To select an audio
408output (which presently has no changeable properties) applications 336output (which presently has no changeable properties) applications
409call the &VIDIOC-S-AUDOUT; ioctl.</para> 337call the &VIDIOC-S-AUDOUT; ioctl.</para>
410 338
411 <para>Drivers must implement all input ioctls when the device 339 <para>Drivers must implement all audio input ioctls when the device
412has one or more inputs, all output ioctls when the device has one 340has multiple selectable audio inputs, all audio output ioctls when the
413or more outputs. When the device has any audio inputs or outputs the 341device has multiple selectable audio outputs. When the device has any
414driver must set the <constant>V4L2_CAP_AUDIO</constant> flag in the 342audio inputs or outputs the driver must set the <constant>V4L2_CAP_AUDIO</constant>
415&v4l2-capability; returned by the &VIDIOC-QUERYCAP; ioctl.</para> 343flag in the &v4l2-capability; returned by the &VIDIOC-QUERYCAP; ioctl.</para>
416 344
417 <example> 345 <example>
418 <title>Information about the current audio input</title> 346 <title>Information about the current audio input</title>
@@ -420,14 +348,14 @@ driver must set the <constant>V4L2_CAP_AUDIO</constant> flag in the
420 <programlisting> 348 <programlisting>
421&v4l2-audio; audio; 349&v4l2-audio; audio;
422 350
423memset (&amp;audio, 0, sizeof (audio)); 351memset(&amp;audio, 0, sizeof(audio));
424 352
425if (-1 == ioctl (fd, &VIDIOC-G-AUDIO;, &amp;audio)) { 353if (-1 == ioctl(fd, &VIDIOC-G-AUDIO;, &amp;audio)) {
426 perror ("VIDIOC_G_AUDIO"); 354 perror("VIDIOC_G_AUDIO");
427 exit (EXIT_FAILURE); 355 exit(EXIT_FAILURE);
428} 356}
429 357
430printf ("Current input: %s\n", audio.name); 358printf("Current input: %s\n", audio.name);
431 </programlisting> 359 </programlisting>
432 </example> 360 </example>
433 361
@@ -437,13 +365,13 @@ printf ("Current input: %s\n", audio.name);
437 <programlisting> 365 <programlisting>
438&v4l2-audio; audio; 366&v4l2-audio; audio;
439 367
440memset (&amp;audio, 0, sizeof (audio)); /* clear audio.mode, audio.reserved */ 368memset(&amp;audio, 0, sizeof(audio)); /* clear audio.mode, audio.reserved */
441 369
442audio.index = 0; 370audio.index = 0;
443 371
444if (-1 == ioctl (fd, &VIDIOC-S-AUDIO;, &amp;audio)) { 372if (-1 == ioctl(fd, &VIDIOC-S-AUDIO;, &amp;audio)) {
445 perror ("VIDIOC_S_AUDIO"); 373 perror("VIDIOC_S_AUDIO");
446 exit (EXIT_FAILURE); 374 exit(EXIT_FAILURE);
447} 375}
448 </programlisting> 376 </programlisting>
449 </example> 377 </example>
@@ -468,7 +396,7 @@ the tuner.</para>
468video inputs.</para> 396video inputs.</para>
469 397
470 <para>To query and change tuner properties applications use the 398 <para>To query and change tuner properties applications use the
471&VIDIOC-G-TUNER; and &VIDIOC-S-TUNER; ioctl, respectively. The 399&VIDIOC-G-TUNER; and &VIDIOC-S-TUNER; ioctls, respectively. The
472&v4l2-tuner; returned by <constant>VIDIOC_G_TUNER</constant> also 400&v4l2-tuner; returned by <constant>VIDIOC_G_TUNER</constant> also
473contains signal status information applicable when the tuner of the 401contains signal status information applicable when the tuner of the
474current video or radio input is queried. Note that 402current video or radio input is queried. Note that
@@ -533,7 +461,7 @@ standards or variations of standards. Each video input and output may
533support another set of standards. This set is reported by the 461support another set of standards. This set is reported by the
534<structfield>std</structfield> field of &v4l2-input; and 462<structfield>std</structfield> field of &v4l2-input; and
535&v4l2-output; returned by the &VIDIOC-ENUMINPUT; and 463&v4l2-output; returned by the &VIDIOC-ENUMINPUT; and
536&VIDIOC-ENUMOUTPUT; ioctl, respectively.</para> 464&VIDIOC-ENUMOUTPUT; ioctls, respectively.</para>
537 465
538 <para>V4L2 defines one bit for each analog video standard 466 <para>V4L2 defines one bit for each analog video standard
539currently in use worldwide, and sets aside bits for driver defined 467currently in use worldwide, and sets aside bits for driver defined
@@ -564,28 +492,10 @@ automatically.</para>
564 <para>To query and select the standard used by the current video 492 <para>To query and select the standard used by the current video
565input or output applications call the &VIDIOC-G-STD; and 493input or output applications call the &VIDIOC-G-STD; and
566&VIDIOC-S-STD; ioctl, respectively. The <emphasis>received</emphasis> 494&VIDIOC-S-STD; ioctl, respectively. The <emphasis>received</emphasis>
567standard can be sensed with the &VIDIOC-QUERYSTD; ioctl. Note that the parameter of all these ioctls is a pointer to a &v4l2-std-id; type (a standard set), <emphasis>not</emphasis> an index into the standard enumeration.<footnote> 495standard can be sensed with the &VIDIOC-QUERYSTD; ioctl. Note that the
568 <para>An alternative to the current scheme is to use pointers 496parameter of all these ioctls is a pointer to a &v4l2-std-id; type
569to indices as arguments of <constant>VIDIOC_G_STD</constant> and 497(a standard set), <emphasis>not</emphasis> an index into the standard
570<constant>VIDIOC_S_STD</constant>, the &v4l2-input; and 498enumeration. Drivers must implement all video standard ioctls
571&v4l2-output; <structfield>std</structfield> field would be a set of
572indices like <structfield>audioset</structfield>.</para>
573 <para>Indices are consistent with the rest of the API
574and identify the standard unambiguously. In the present scheme of
575things an enumerated standard is looked up by &v4l2-std-id;. Now the
576standards supported by the inputs of a device can overlap. Just
577assume the tuner and composite input in the example above both
578exist on a device. An enumeration of "PAL-B/G", "PAL-H/I" suggests
579a choice which does not exist. We cannot merge or omit sets, because
580applications would be unable to find the standards reported by
581<constant>VIDIOC_G_STD</constant>. That leaves separate enumerations
582for each input. Also selecting a standard by &v4l2-std-id; can be
583ambiguous. Advantage of this method is that applications need not
584identify the standard indirectly, after enumerating.</para><para>So in
585summary, the lookup itself is unavoidable. The difference is only
586whether the lookup is necessary to find an enumerated standard or to
587switch to a standard by &v4l2-std-id;.</para>
588 </footnote> Drivers must implement all video standard ioctls
589when the device has one or more video inputs or outputs.</para> 499when the device has one or more video inputs or outputs.</para>
590 500
591 <para>Special rules apply to devices such as USB cameras where the notion of video 501 <para>Special rules apply to devices such as USB cameras where the notion of video
@@ -604,17 +514,10 @@ to zero and the <constant>VIDIOC_G_STD</constant>,
604<constant>VIDIOC_S_STD</constant>, 514<constant>VIDIOC_S_STD</constant>,
605<constant>VIDIOC_QUERYSTD</constant> and 515<constant>VIDIOC_QUERYSTD</constant> and
606<constant>VIDIOC_ENUMSTD</constant> ioctls shall return the 516<constant>VIDIOC_ENUMSTD</constant> ioctls shall return the
607&ENOTTY;.<footnote> 517&ENOTTY; or the &EINVAL;.</para>
608 <para>See <xref linkend="buffer" /> for a rationale.</para>
609 <para>Applications can make use of the <xref linkend="input-capabilities" /> and 518 <para>Applications can make use of the <xref linkend="input-capabilities" /> and
610<xref linkend="output-capabilities"/> flags to determine whether the video standard ioctls 519<xref linkend="output-capabilities"/> flags to determine whether the video standard ioctls
611are available for the device.</para> 520can be used with the given input or output.</para>
612
613 <para>See <xref linkend="buffer" /> for a rationale. Probably
614even USB cameras follow some well known video standard. It might have
615been better to explicitly indicate elsewhere if a device cannot live
616up to normal expectations, instead of this exception.</para>
617 </footnote></para>
618 521
619 <example> 522 <example>
620 <title>Information about the current video standard</title> 523 <title>Information about the current video standard</title>
@@ -623,22 +526,22 @@ up to normal expectations, instead of this exception.</para>
623&v4l2-std-id; std_id; 526&v4l2-std-id; std_id;
624&v4l2-standard; standard; 527&v4l2-standard; standard;
625 528
626if (-1 == ioctl (fd, &VIDIOC-G-STD;, &amp;std_id)) { 529if (-1 == ioctl(fd, &VIDIOC-G-STD;, &amp;std_id)) {
627 /* Note when VIDIOC_ENUMSTD always returns ENOTTY this 530 /* Note when VIDIOC_ENUMSTD always returns ENOTTY this
628 is no video device or it falls under the USB exception, 531 is no video device or it falls under the USB exception,
629 and VIDIOC_G_STD returning ENOTTY is no error. */ 532 and VIDIOC_G_STD returning ENOTTY is no error. */
630 533
631 perror ("VIDIOC_G_STD"); 534 perror("VIDIOC_G_STD");
632 exit (EXIT_FAILURE); 535 exit(EXIT_FAILURE);
633} 536}
634 537
635memset (&amp;standard, 0, sizeof (standard)); 538memset(&amp;standard, 0, sizeof(standard));
636standard.index = 0; 539standard.index = 0;
637 540
638while (0 == ioctl (fd, &VIDIOC-ENUMSTD;, &amp;standard)) { 541while (0 == ioctl(fd, &VIDIOC-ENUMSTD;, &amp;standard)) {
639 if (standard.id &amp; std_id) { 542 if (standard.id &amp; std_id) {
640 printf ("Current video standard: %s\n", standard.name); 543 printf("Current video standard: %s\n", standard.name);
641 exit (EXIT_SUCCESS); 544 exit(EXIT_SUCCESS);
642 } 545 }
643 546
644 standard.index++; 547 standard.index++;
@@ -648,8 +551,8 @@ while (0 == ioctl (fd, &VIDIOC-ENUMSTD;, &amp;standard)) {
648 empty unless this device falls under the USB exception. */ 551 empty unless this device falls under the USB exception. */
649 552
650if (errno == EINVAL || standard.index == 0) { 553if (errno == EINVAL || standard.index == 0) {
651 perror ("VIDIOC_ENUMSTD"); 554 perror("VIDIOC_ENUMSTD");
652 exit (EXIT_FAILURE); 555 exit(EXIT_FAILURE);
653} 556}
654 </programlisting> 557 </programlisting>
655 </example> 558 </example>
@@ -662,26 +565,26 @@ input</title>
662&v4l2-input; input; 565&v4l2-input; input;
663&v4l2-standard; standard; 566&v4l2-standard; standard;
664 567
665memset (&amp;input, 0, sizeof (input)); 568memset(&amp;input, 0, sizeof(input));
666 569
667if (-1 == ioctl (fd, &VIDIOC-G-INPUT;, &amp;input.index)) { 570if (-1 == ioctl(fd, &VIDIOC-G-INPUT;, &amp;input.index)) {
668 perror ("VIDIOC_G_INPUT"); 571 perror("VIDIOC_G_INPUT");
669 exit (EXIT_FAILURE); 572 exit(EXIT_FAILURE);
670} 573}
671 574
672if (-1 == ioctl (fd, &VIDIOC-ENUMINPUT;, &amp;input)) { 575if (-1 == ioctl(fd, &VIDIOC-ENUMINPUT;, &amp;input)) {
673 perror ("VIDIOC_ENUM_INPUT"); 576 perror("VIDIOC_ENUM_INPUT");
674 exit (EXIT_FAILURE); 577 exit(EXIT_FAILURE);
675} 578}
676 579
677printf ("Current input %s supports:\n", input.name); 580printf("Current input %s supports:\n", input.name);
678 581
679memset (&amp;standard, 0, sizeof (standard)); 582memset(&amp;standard, 0, sizeof(standard));
680standard.index = 0; 583standard.index = 0;
681 584
682while (0 == ioctl (fd, &VIDIOC-ENUMSTD;, &amp;standard)) { 585while (0 == ioctl(fd, &VIDIOC-ENUMSTD;, &amp;standard)) {
683 if (standard.id &amp; input.std) 586 if (standard.id &amp; input.std)
684 printf ("%s\n", standard.name); 587 printf("%s\n", standard.name);
685 588
686 standard.index++; 589 standard.index++;
687} 590}
@@ -690,8 +593,8 @@ while (0 == ioctl (fd, &VIDIOC-ENUMSTD;, &amp;standard)) {
690 empty unless this device falls under the USB exception. */ 593 empty unless this device falls under the USB exception. */
691 594
692if (errno != EINVAL || standard.index == 0) { 595if (errno != EINVAL || standard.index == 0) {
693 perror ("VIDIOC_ENUMSTD"); 596 perror("VIDIOC_ENUMSTD");
694 exit (EXIT_FAILURE); 597 exit(EXIT_FAILURE);
695} 598}
696 </programlisting> 599 </programlisting>
697 </example> 600 </example>
@@ -703,21 +606,21 @@ if (errno != EINVAL || standard.index == 0) {
703&v4l2-input; input; 606&v4l2-input; input;
704&v4l2-std-id; std_id; 607&v4l2-std-id; std_id;
705 608
706memset (&amp;input, 0, sizeof (input)); 609memset(&amp;input, 0, sizeof(input));
707 610
708if (-1 == ioctl (fd, &VIDIOC-G-INPUT;, &amp;input.index)) { 611if (-1 == ioctl(fd, &VIDIOC-G-INPUT;, &amp;input.index)) {
709 perror ("VIDIOC_G_INPUT"); 612 perror("VIDIOC_G_INPUT");
710 exit (EXIT_FAILURE); 613 exit(EXIT_FAILURE);
711} 614}
712 615
713if (-1 == ioctl (fd, &VIDIOC-ENUMINPUT;, &amp;input)) { 616if (-1 == ioctl(fd, &VIDIOC-ENUMINPUT;, &amp;input)) {
714 perror ("VIDIOC_ENUM_INPUT"); 617 perror("VIDIOC_ENUM_INPUT");
715 exit (EXIT_FAILURE); 618 exit(EXIT_FAILURE);
716} 619}
717 620
718if (0 == (input.std &amp; V4L2_STD_PAL_BG)) { 621if (0 == (input.std &amp; V4L2_STD_PAL_BG)) {
719 fprintf (stderr, "Oops. B/G PAL is not supported.\n"); 622 fprintf(stderr, "Oops. B/G PAL is not supported.\n");
720 exit (EXIT_FAILURE); 623 exit(EXIT_FAILURE);
721} 624}
722 625
723/* Note this is also supposed to work when only B 626/* Note this is also supposed to work when only B
@@ -725,9 +628,9 @@ if (0 == (input.std &amp; V4L2_STD_PAL_BG)) {
725 628
726std_id = V4L2_STD_PAL_BG; 629std_id = V4L2_STD_PAL_BG;
727 630
728if (-1 == ioctl (fd, &VIDIOC-S-STD;, &amp;std_id)) { 631if (-1 == ioctl(fd, &VIDIOC-S-STD;, &amp;std_id)) {
729 perror ("VIDIOC_S_STD"); 632 perror("VIDIOC_S_STD");
730 exit (EXIT_FAILURE); 633 exit(EXIT_FAILURE);
731} 634}
732 </programlisting> 635 </programlisting>
733 </example> 636 </example>
@@ -740,26 +643,25 @@ corresponding video timings. Today there are many more different hardware interf
740such as High Definition TV interfaces (HDMI), VGA, DVI connectors etc., that carry 643such as High Definition TV interfaces (HDMI), VGA, DVI connectors etc., that carry
741video signals and there is a need to extend the API to select the video timings 644video signals and there is a need to extend the API to select the video timings
742for these interfaces. Since it is not possible to extend the &v4l2-std-id; due to 645for these interfaces. Since it is not possible to extend the &v4l2-std-id; due to
743the limited bits available, a new set of IOCTLs was added to set/get video timings at 646the limited bits available, a new set of ioctls was added to set/get video timings at
744the input and output: </para><itemizedlist> 647the input and output.</para>
745 <listitem> 648
746 <para>DV Timings: This will allow applications to define detailed 649 <para>These ioctls deal with the detailed digital video timings that define
747video timings for the interface. This includes parameters such as width, height, 650each video format. This includes parameters such as the active video width and height,
748polarities, frontporch, backporch etc. The <filename>linux/v4l2-dv-timings.h</filename> 651signal polarities, frontporches, backporches, sync widths etc. The <filename>linux/v4l2-dv-timings.h</filename>
749header can be used to get the timings of the formats in the <xref linkend="cea861" /> and 652header can be used to get the timings of the formats in the <xref linkend="cea861" /> and
750<xref linkend="vesadmt" /> standards. 653<xref linkend="vesadmt" /> standards.
751 </para> 654 </para>
752 </listitem> 655
753 </itemizedlist> 656 <para>To enumerate and query the attributes of the DV timings supported by a device
754 <para>To enumerate and query the attributes of the DV timings supported by a device,
755 applications use the &VIDIOC-ENUM-DV-TIMINGS; and &VIDIOC-DV-TIMINGS-CAP; ioctls. 657 applications use the &VIDIOC-ENUM-DV-TIMINGS; and &VIDIOC-DV-TIMINGS-CAP; ioctls.
756 To set DV timings for the device, applications use the 658 To set DV timings for the device applications use the
757&VIDIOC-S-DV-TIMINGS; ioctl and to get current DV timings they use the 659&VIDIOC-S-DV-TIMINGS; ioctl and to get current DV timings they use the
758&VIDIOC-G-DV-TIMINGS; ioctl. To detect the DV timings as seen by the video receiver applications 660&VIDIOC-G-DV-TIMINGS; ioctl. To detect the DV timings as seen by the video receiver applications
759use the &VIDIOC-QUERY-DV-TIMINGS; ioctl.</para> 661use the &VIDIOC-QUERY-DV-TIMINGS; ioctl.</para>
760 <para>Applications can make use of the <xref linkend="input-capabilities" /> and 662 <para>Applications can make use of the <xref linkend="input-capabilities" /> and
761<xref linkend="output-capabilities"/> flags to decide what ioctls are available to set the 663<xref linkend="output-capabilities"/> flags to determine whether the digital video ioctls
762video timings for the device.</para> 664can be used with the given input or output.</para>
763 </section> 665 </section>
764 666
765 &sub-controls; 667 &sub-controls;
diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml
index 86c6dd2f6b8a..eee6f0f4aa43 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2535,6 +2535,16 @@ fields changed from _s32 to _u32.
2535 </orderedlist> 2535 </orderedlist>
2536 </section> 2536 </section>
2537 2537
2538 <section>
2539 <title>V4L2 in Linux 3.15</title>
2540 <orderedlist>
2541 <listitem>
2542 <para>Added Software Defined Radio (SDR) Interface.
2543 </para>
2544 </listitem>
2545 </orderedlist>
2546 </section>
2547
2538 <section id="other"> 2548 <section id="other">
2539 <title>Relation of V4L2 to other Linux multimedia APIs</title> 2549 <title>Relation of V4L2 to other Linux multimedia APIs</title>
2540 2550
@@ -2651,6 +2661,9 @@ ioctls.</para>
2651 <listitem> 2661 <listitem>
2652 <para>Exporting DMABUF files using &VIDIOC-EXPBUF; ioctl.</para> 2662 <para>Exporting DMABUF files using &VIDIOC-EXPBUF; ioctl.</para>
2653 </listitem> 2663 </listitem>
2664 <listitem>
2665 <para>Software Defined Radio (SDR) Interface, <xref linkend="sdr" />.</para>
2666 </listitem>
2654 </itemizedlist> 2667 </itemizedlist>
2655 </section> 2668 </section>
2656 2669
diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index a5a3188e5af7..47198eef75a4 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -2258,6 +2258,26 @@ Applicable to the MPEG1, MPEG2, MPEG4 encoders.</entry>
2258VBV buffer control.</entry> 2258VBV buffer control.</entry>
2259 </row> 2259 </row>
2260 2260
2261 <row><entry></entry></row>
2262 <row id="v4l2-mpeg-video-hor-search-range">
2263 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE</constant>&nbsp;</entry>
2264 <entry>integer</entry>
2265 </row>
2266 <row><entry spanname="descr">Horizontal search range defines maximum horizontal search area in pixels
2267to search and match for the present Macroblock (MB) in the reference picture. This V4L2 control macro is used to set
2268horizontal search range for motion estimation module in video encoder.</entry>
2269 </row>
2270
2271 <row><entry></entry></row>
2272 <row id="v4l2-mpeg-video-vert-search-range">
2273 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE</constant>&nbsp;</entry>
2274 <entry>integer</entry>
2275 </row>
2276 <row><entry spanname="descr">Vertical search range defines maximum vertical search area in pixels
2277to search and match for the present Macroblock (MB) in the reference picture. This V4L2 control macro is used to set
2278vertical search range for motion estimation module in video encoder.</entry>
2279 </row>
2280
2261 <row><entry></entry></row> 2281 <row><entry></entry></row>
2262 <row> 2282 <row>
2263 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE</constant>&nbsp;</entry> 2283 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE</constant>&nbsp;</entry>
@@ -4370,6 +4390,24 @@ interface and may change in the future.</para>
4370 <entry>The flash controller has detected a short or open 4390 <entry>The flash controller has detected a short or open
4371 circuit condition on the indicator LED.</entry> 4391 circuit condition on the indicator LED.</entry>
4372 </row> 4392 </row>
4393 <row>
4394 <entry><constant>V4L2_FLASH_FAULT_UNDER_VOLTAGE</constant></entry>
4395 <entry>Flash controller voltage to the flash LED
4396 has been below the minimum limit specific to the flash
4397 controller.</entry>
4398 </row>
4399 <row>
4400 <entry><constant>V4L2_FLASH_FAULT_INPUT_VOLTAGE</constant></entry>
4401 <entry>The input voltage of the flash controller is below
4402 the limit under which strobing the flash at full current
4403 will not be possible.The condition persists until this flag
4404 is no longer set.</entry>
4405 </row>
4406 <row>
4407 <entry><constant>V4L2_FLASH_FAULT_LED_OVER_TEMPERATURE</constant></entry>
4408 <entry>The temperature of the LED has exceeded its
4409 allowed upper limit.</entry>
4410 </row>
4373 </tbody> 4411 </tbody>
4374 </entrytbl> 4412 </entrytbl>
4375 </row> 4413 </row>
@@ -4971,4 +5009,142 @@ defines possible values for de-emphasis. Here they are:</entry>
4971 </table> 5009 </table>
4972 5010
4973 </section> 5011 </section>
5012
5013 <section id="rf-tuner-controls">
5014 <title>RF Tuner Control Reference</title>
5015
5016 <para>
5017The RF Tuner (RF_TUNER) class includes controls for common features of devices
5018having RF tuner.
5019 </para>
5020 <para>
5021In this context, RF tuner is radio receiver circuit between antenna and
5022demodulator. It receives radio frequency (RF) from the antenna and converts that
5023received signal to lower intermediate frequency (IF) or baseband frequency (BB).
5024Tuners that could do baseband output are often called Zero-IF tuners. Older
5025tuners were typically simple PLL tuners inside a metal box, whilst newer ones
5026are highly integrated chips without a metal box "silicon tuners". These controls
5027are mostly applicable for new feature rich silicon tuners, just because older
5028tuners does not have much adjustable features.
5029 </para>
5030 <para>
5031For more information about RF tuners see
5032<ulink url="http://en.wikipedia.org/wiki/Tuner_%28radio%29">Tuner (radio)</ulink>
5033and
5034<ulink url="http://en.wikipedia.org/wiki/RF_front_end">RF front end</ulink>
5035from Wikipedia.
5036 </para>
5037
5038 <table pgwide="1" frame="none" id="rf-tuner-control-id">
5039 <title>RF_TUNER Control IDs</title>
5040
5041 <tgroup cols="4">
5042 <colspec colname="c1" colwidth="1*" />
5043 <colspec colname="c2" colwidth="6*" />
5044 <colspec colname="c3" colwidth="2*" />
5045 <colspec colname="c4" colwidth="6*" />
5046 <spanspec namest="c1" nameend="c2" spanname="id" />
5047 <spanspec namest="c2" nameend="c4" spanname="descr" />
5048 <thead>
5049 <row>
5050 <entry spanname="id" align="left">ID</entry>
5051 <entry align="left">Type</entry>
5052 </row>
5053 <row rowsep="1">
5054 <entry spanname="descr" align="left">Description</entry>
5055 </row>
5056 </thead>
5057 <tbody valign="top">
5058 <row><entry></entry></row>
5059 <row>
5060 <entry spanname="id"><constant>V4L2_CID_RF_TUNER_CLASS</constant>&nbsp;</entry>
5061 <entry>class</entry>
5062 </row><row><entry spanname="descr">The RF_TUNER class
5063descriptor. Calling &VIDIOC-QUERYCTRL; for this control will return a
5064description of this control class.</entry>
5065 </row>
5066 <row>
5067 <entry spanname="id"><constant>V4L2_CID_RF_TUNER_BANDWIDTH_AUTO</constant>&nbsp;</entry>
5068 <entry>boolean</entry>
5069 </row>
5070 <row>
5071 <entry spanname="descr">Enables/disables tuner radio channel
5072bandwidth configuration. In automatic mode bandwidth configuration is performed
5073by the driver.</entry>
5074 </row>
5075 <row>
5076 <entry spanname="id"><constant>V4L2_CID_RF_TUNER_BANDWIDTH</constant>&nbsp;</entry>
5077 <entry>integer</entry>
5078 </row>
5079 <row>
5080 <entry spanname="descr">Filter(s) on tuner signal path are used to
5081filter signal according to receiving party needs. Driver configures filters to
5082fulfill desired bandwidth requirement. Used when V4L2_CID_RF_TUNER_BANDWIDTH_AUTO is not
5083set. Unit is in Hz. The range and step are driver-specific.</entry>
5084 </row>
5085 <row>
5086 <entry spanname="id"><constant>V4L2_CID_RF_TUNER_LNA_GAIN_AUTO</constant>&nbsp;</entry>
5087 <entry>boolean</entry>
5088 </row>
5089 <row>
5090 <entry spanname="descr">Enables/disables LNA automatic gain control (AGC)</entry>
5091 </row>
5092 <row>
5093 <entry spanname="id"><constant>V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO</constant>&nbsp;</entry>
5094 <entry>boolean</entry>
5095 </row>
5096 <row>
5097 <entry spanname="descr">Enables/disables mixer automatic gain control (AGC)</entry>
5098 </row>
5099 <row>
5100 <entry spanname="id"><constant>V4L2_CID_RF_TUNER_IF_GAIN_AUTO</constant>&nbsp;</entry>
5101 <entry>boolean</entry>
5102 </row>
5103 <row>
5104 <entry spanname="descr">Enables/disables IF automatic gain control (AGC)</entry>
5105 </row>
5106 <row>
5107 <entry spanname="id"><constant>V4L2_CID_RF_TUNER_LNA_GAIN</constant>&nbsp;</entry>
5108 <entry>integer</entry>
5109 </row>
5110 <row>
5111 <entry spanname="descr">LNA (low noise amplifier) gain is first
5112gain stage on the RF tuner signal path. It is located very close to tuner
5113antenna input. Used when <constant>V4L2_CID_RF_TUNER_LNA_GAIN_AUTO</constant> is not set.
5114The range and step are driver-specific.</entry>
5115 </row>
5116 <row>
5117 <entry spanname="id"><constant>V4L2_CID_RF_TUNER_MIXER_GAIN</constant>&nbsp;</entry>
5118 <entry>integer</entry>
5119 </row>
5120 <row>
5121 <entry spanname="descr">Mixer gain is second gain stage on the RF
5122tuner signal path. It is located inside mixer block, where RF signal is
5123down-converted by the mixer. Used when <constant>V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO</constant>
5124is not set. The range and step are driver-specific.</entry>
5125 </row>
5126 <row>
5127 <entry spanname="id"><constant>V4L2_CID_RF_TUNER_IF_GAIN</constant>&nbsp;</entry>
5128 <entry>integer</entry>
5129 </row>
5130 <row>
5131 <entry spanname="descr">IF gain is last gain stage on the RF tuner
5132signal path. It is located on output of RF tuner. It controls signal level of
5133intermediate frequency output or baseband output. Used when
5134<constant>V4L2_CID_RF_TUNER_IF_GAIN_AUTO</constant> is not set. The range and step are
5135driver-specific.</entry>
5136 </row>
5137 <row>
5138 <entry spanname="id"><constant>V4L2_CID_RF_TUNER_PLL_LOCK</constant>&nbsp;</entry>
5139 <entry>boolean</entry>
5140 </row>
5141 <row>
5142 <entry spanname="descr">Is synthesizer PLL locked? RF tuner is
5143receiving given frequency when that control is set. This is a read-only control.
5144</entry>
5145 </row>
5146 </tbody>
5147 </tgroup>
5148 </table>
5149 </section>
4974</section> 5150</section>
diff --git a/Documentation/DocBook/media/v4l/dev-osd.xml b/Documentation/DocBook/media/v4l/dev-osd.xml
index dd91d6134e8c..54853329140b 100644
--- a/Documentation/DocBook/media/v4l/dev-osd.xml
+++ b/Documentation/DocBook/media/v4l/dev-osd.xml
@@ -56,18 +56,18 @@ framebuffer device.</para>
56unsigned int i; 56unsigned int i;
57int fb_fd; 57int fb_fd;
58 58
59if (-1 == ioctl (fd, VIDIOC_G_FBUF, &amp;fbuf)) { 59if (-1 == ioctl(fd, VIDIOC_G_FBUF, &amp;fbuf)) {
60 perror ("VIDIOC_G_FBUF"); 60 perror("VIDIOC_G_FBUF");
61 exit (EXIT_FAILURE); 61 exit(EXIT_FAILURE);
62} 62}
63 63
64for (i = 0; i &gt; 30; ++i) { 64for (i = 0; i &lt; 30; i++) {
65 char dev_name[16]; 65 char dev_name[16];
66 struct fb_fix_screeninfo si; 66 struct fb_fix_screeninfo si;
67 67
68 snprintf (dev_name, sizeof (dev_name), "/dev/fb%u", i); 68 snprintf(dev_name, sizeof(dev_name), "/dev/fb%u", i);
69 69
70 fb_fd = open (dev_name, O_RDWR); 70 fb_fd = open(dev_name, O_RDWR);
71 if (-1 == fb_fd) { 71 if (-1 == fb_fd) {
72 switch (errno) { 72 switch (errno) {
73 case ENOENT: /* no such file */ 73 case ENOENT: /* no such file */
@@ -75,19 +75,19 @@ for (i = 0; i &gt; 30; ++i) {
75 continue; 75 continue;
76 76
77 default: 77 default:
78 perror ("open"); 78 perror("open");
79 exit (EXIT_FAILURE); 79 exit(EXIT_FAILURE);
80 } 80 }
81 } 81 }
82 82
83 if (0 == ioctl (fb_fd, FBIOGET_FSCREENINFO, &amp;si)) { 83 if (0 == ioctl(fb_fd, FBIOGET_FSCREENINFO, &amp;si)) {
84 if (si.smem_start == (unsigned long) fbuf.base) 84 if (si.smem_start == (unsigned long)fbuf.base)
85 break; 85 break;
86 } else { 86 } else {
87 /* Apparently not a framebuffer device. */ 87 /* Apparently not a framebuffer device. */
88 } 88 }
89 89
90 close (fb_fd); 90 close(fb_fd);
91 fb_fd = -1; 91 fb_fd = -1;
92} 92}
93 93
diff --git a/Documentation/DocBook/media/v4l/dev-sdr.xml b/Documentation/DocBook/media/v4l/dev-sdr.xml
new file mode 100644
index 000000000000..dc14804f5436
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/dev-sdr.xml
@@ -0,0 +1,110 @@
1 <title>Software Defined Radio Interface (SDR)</title>
2
3 <note>
4 <title>Experimental</title>
5 <para>This is an <link linkend="experimental"> experimental </link>
6 interface and may change in the future.</para>
7 </note>
8
9 <para>
10SDR is an abbreviation of Software Defined Radio, the radio device
11which uses application software for modulation or demodulation. This interface
12is intended for controlling and data streaming of such devices.
13 </para>
14
15 <para>
16SDR devices are accessed through character device special files named
17<filename>/dev/swradio0</filename> to <filename>/dev/swradio255</filename>
18with major number 81 and dynamically allocated minor numbers 0 to 255.
19 </para>
20
21 <section>
22 <title>Querying Capabilities</title>
23
24 <para>
25Devices supporting the SDR receiver interface set the
26<constant>V4L2_CAP_SDR_CAPTURE</constant> and
27<constant>V4L2_CAP_TUNER</constant> flag in the
28<structfield>capabilities</structfield> field of &v4l2-capability;
29returned by the &VIDIOC-QUERYCAP; ioctl. That flag means the device has an
30Analog to Digital Converter (ADC), which is a mandatory element for the SDR receiver.
31At least one of the read/write, streaming or asynchronous I/O methods must
32be supported.
33 </para>
34 </section>
35
36 <section>
37 <title>Supplemental Functions</title>
38
39 <para>
40SDR devices can support <link linkend="control">controls</link>, and must
41support the <link linkend="tuner">tuner</link> ioctls. Tuner ioctls are used
42for setting the ADC sampling rate (sampling frequency) and the possible RF tuner
43frequency.
44 </para>
45
46 <para>
47The <constant>V4L2_TUNER_ADC</constant> tuner type is used for ADC tuners, and
48the <constant>V4L2_TUNER_RF</constant> tuner type is used for RF tuners. The
49tuner index of the RF tuner (if any) must always follow the ADC tuner index.
50Normally the ADC tuner is #0 and the RF tuner is #1.
51 </para>
52
53 <para>
54The &VIDIOC-S-HW-FREQ-SEEK; ioctl is not supported.
55 </para>
56 </section>
57
58 <section>
59 <title>Data Format Negotiation</title>
60
61 <para>
62The SDR capture device uses the <link linkend="format">format</link> ioctls to
63select the capture format. Both the sampling resolution and the data streaming
64format are bound to that selectable format. In addition to the basic
65<link linkend="format">format</link> ioctls, the &VIDIOC-ENUM-FMT; ioctl
66must be supported as well.
67 </para>
68
69 <para>
70To use the <link linkend="format">format</link> ioctls applications set the
71<structfield>type</structfield> field of a &v4l2-format; to
72<constant>V4L2_BUF_TYPE_SDR_CAPTURE</constant> and use the &v4l2-sdr-format;
73<structfield>sdr</structfield> member of the <structfield>fmt</structfield>
74union as needed per the desired operation.
75Currently only the <structfield>pixelformat</structfield> field of
76&v4l2-sdr-format; is used. The content of that field is the V4L2 fourcc code
77of the data format.
78 </para>
79
80 <table pgwide="1" frame="none" id="v4l2-sdr-format">
81 <title>struct <structname>v4l2_sdr_format</structname></title>
82 <tgroup cols="3">
83 &cs-str;
84 <tbody valign="top">
85 <row>
86 <entry>__u32</entry>
87 <entry><structfield>pixelformat</structfield></entry>
88 <entry>
89The data format or type of compression, set by the application. This is a
90little endian <link linkend="v4l2-fourcc">four character code</link>.
91V4L2 defines SDR formats in <xref linkend="sdr-formats" />.
92 </entry>
93 </row>
94 <row>
95 <entry>__u8</entry>
96 <entry><structfield>reserved[28]</structfield></entry>
97 <entry>This array is reserved for future extensions.
98Drivers and applications must set it to zero.</entry>
99 </row>
100 </tbody>
101 </tgroup>
102 </table>
103
104 <para>
105An SDR device may support <link linkend="rw">read/write</link>
106and/or streaming (<link linkend="mmap">memory mapping</link>
107or <link linkend="userp">user pointer</link>) I/O.
108 </para>
109
110 </section>
diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
index 2c4c068dde83..97a69bf6f3eb 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -339,8 +339,8 @@ returns immediately with an &EAGAIN; when no buffer is available. The
339queues as a side effect. Since there is no notion of doing anything 339queues as a side effect. Since there is no notion of doing anything
340"now" on a multitasking system, if an application needs to synchronize 340"now" on a multitasking system, if an application needs to synchronize
341with another event it should examine the &v4l2-buffer; 341with another event it should examine the &v4l2-buffer;
342<structfield>timestamp</structfield> of captured buffers, or set the 342<structfield>timestamp</structfield> of captured or outputted buffers.
343field before enqueuing buffers for output.</para> 343</para>
344 344
345 <para>Drivers implementing memory mapping I/O must 345 <para>Drivers implementing memory mapping I/O must
346support the <constant>VIDIOC_REQBUFS</constant>, 346support the <constant>VIDIOC_REQBUFS</constant>,
@@ -457,7 +457,7 @@ queues and unlocks all buffers as a side effect. Since there is no
457notion of doing anything "now" on a multitasking system, if an 457notion of doing anything "now" on a multitasking system, if an
458application needs to synchronize with another event it should examine 458application needs to synchronize with another event it should examine
459the &v4l2-buffer; <structfield>timestamp</structfield> of captured 459the &v4l2-buffer; <structfield>timestamp</structfield> of captured
460buffers, or set the field before enqueuing buffers for output.</para> 460or outputted buffers.</para>
461 461
462 <para>Drivers implementing user pointer I/O must 462 <para>Drivers implementing user pointer I/O must
463support the <constant>VIDIOC_REQBUFS</constant>, 463support the <constant>VIDIOC_REQBUFS</constant>,
@@ -620,8 +620,7 @@ returns immediately with an &EAGAIN; when no buffer is available. The
620unlocks all buffers as a side effect. Since there is no notion of doing 620unlocks all buffers as a side effect. Since there is no notion of doing
621anything "now" on a multitasking system, if an application needs to synchronize 621anything "now" on a multitasking system, if an application needs to synchronize
622with another event it should examine the &v4l2-buffer; 622with another event it should examine the &v4l2-buffer;
623<structfield>timestamp</structfield> of captured buffers, or set the field 623<structfield>timestamp</structfield> of captured or outputted buffers.</para>
624before enqueuing buffers for output.</para>
625 624
626 <para>Drivers implementing DMABUF importing I/O must support the 625 <para>Drivers implementing DMABUF importing I/O must support the
627<constant>VIDIOC_REQBUFS</constant>, <constant>VIDIOC_QBUF</constant>, 626<constant>VIDIOC_REQBUFS</constant>, <constant>VIDIOC_QBUF</constant>,
@@ -654,38 +653,19 @@ plane, are stored in struct <structname>v4l2_plane</structname> instead.
654In that case, struct <structname>v4l2_buffer</structname> contains an array of 653In that case, struct <structname>v4l2_buffer</structname> contains an array of
655plane structures.</para> 654plane structures.</para>
656 655
657 <para>Nominally timestamps refer to the first data byte transmitted. 656 <para>Dequeued video buffers come with timestamps. The driver
658In practice however the wide range of hardware covered by the V4L2 API 657 decides at which part of the frame and with which clock the
659limits timestamp accuracy. Often an interrupt routine will 658 timestamp is taken. Please see flags in the masks
660sample the system clock shortly after the field or frame was stored 659 <constant>V4L2_BUF_FLAG_TIMESTAMP_MASK</constant> and
661completely in memory. So applications must expect a constant 660 <constant>V4L2_BUF_FLAG_TSTAMP_SRC_MASK</constant> in <xref
662difference up to one field or frame period plus a small (few scan 661 linkend="buffer-flags" />. These flags are always valid and constant
663lines) random error. The delay and error can be much 662 across all buffers during the whole video stream. Changes in these
664larger due to compression or transmission over an external bus when 663 flags may take place as a side effect of &VIDIOC-S-INPUT; or
665the frames are not properly stamped by the sender. This is frequently 664 &VIDIOC-S-OUTPUT; however. The
666the case with USB cameras. Here timestamps refer to the instant the 665 <constant>V4L2_BUF_FLAG_TIMESTAMP_COPY</constant> timestamp type
667field or frame was received by the driver, not the capture time. These 666 which is used by e.g. on mem-to-mem devices is an exception to the
668devices identify by not enumerating any video standards, see <xref 667 rule: the timestamp source flags are copied from the OUTPUT video
669linkend="standard" />.</para> 668 buffer to the CAPTURE video buffer.</para>
670
671 <para>Similar limitations apply to output timestamps. Typically
672the video hardware locks to a clock controlling the video timing, the
673horizontal and vertical synchronization pulses. At some point in the
674line sequence, possibly the vertical blanking, an interrupt routine
675samples the system clock, compares against the timestamp and programs
676the hardware to repeat the previous field or frame, or to display the
677buffer contents.</para>
678
679 <para>Apart of limitations of the video device and natural
680inaccuracies of all clocks, it should be noted system time itself is
681not perfectly stable. It can be affected by power saving cycles,
682warped to insert leap seconds, or even turned back or forth by the
683system administrator affecting long term measurements. <footnote>
684 <para>Since no other Linux multimedia
685API supports unadjusted time it would be foolish to introduce here. We
686must use a universally supported clock to synchronize different media,
687hence time of day.</para>
688 </footnote></para>
689 669
690 <table frame="none" pgwide="1" id="v4l2-buffer"> 670 <table frame="none" pgwide="1" id="v4l2-buffer">
691 <title>struct <structname>v4l2_buffer</structname></title> 671 <title>struct <structname>v4l2_buffer</structname></title>
@@ -696,10 +676,11 @@ hence time of day.</para>
696 <entry>__u32</entry> 676 <entry>__u32</entry>
697 <entry><structfield>index</structfield></entry> 677 <entry><structfield>index</structfield></entry>
698 <entry></entry> 678 <entry></entry>
699 <entry>Number of the buffer, set by the application. This 679 <entry>Number of the buffer, set by the application except
700field is only used for <link linkend="mmap">memory mapping</link> I/O 680when calling &VIDIOC-DQBUF;, then it is set by the driver.
701and can range from zero to the number of buffers allocated 681This field can range from zero to the number of buffers allocated
702with the &VIDIOC-REQBUFS; ioctl (&v4l2-requestbuffers; <structfield>count</structfield>) minus one.</entry> 682with the &VIDIOC-REQBUFS; ioctl (&v4l2-requestbuffers; <structfield>count</structfield>),
683plus any buffers allocated with &VIDIOC-CREATE-BUFS; minus one.</entry>
703 </row> 684 </row>
704 <row> 685 <row>
705 <entry>__u32</entry> 686 <entry>__u32</entry>
@@ -718,7 +699,7 @@ linkend="v4l2-buf-type" /></entry>
718buffer. It depends on the negotiated data format and may change with 699buffer. It depends on the negotiated data format and may change with
719each buffer for compressed variable size data like JPEG images. 700each buffer for compressed variable size data like JPEG images.
720Drivers must set this field when <structfield>type</structfield> 701Drivers must set this field when <structfield>type</structfield>
721refers to an input stream, applications when an output stream.</entry> 702refers to an input stream, applications when it refers to an output stream.</entry>
722 </row> 703 </row>
723 <row> 704 <row>
724 <entry>__u32</entry> 705 <entry>__u32</entry>
@@ -735,7 +716,7 @@ linkend="buffer-flags" />.</entry>
735buffer, see <xref linkend="v4l2-field" />. This field is not used when 716buffer, see <xref linkend="v4l2-field" />. This field is not used when
736the buffer contains VBI data. Drivers must set it when 717the buffer contains VBI data. Drivers must set it when
737<structfield>type</structfield> refers to an input stream, 718<structfield>type</structfield> refers to an input stream,
738applications when an output stream.</entry> 719applications when it refers to an output stream.</entry>
739 </row> 720 </row>
740 <row> 721 <row>
741 <entry>struct timeval</entry> 722 <entry>struct timeval</entry>
@@ -745,15 +726,13 @@ applications when an output stream.</entry>
745 byte was captured, as returned by the 726 byte was captured, as returned by the
746 <function>clock_gettime()</function> function for the relevant 727 <function>clock_gettime()</function> function for the relevant
747 clock id; see <constant>V4L2_BUF_FLAG_TIMESTAMP_*</constant> in 728 clock id; see <constant>V4L2_BUF_FLAG_TIMESTAMP_*</constant> in
748 <xref linkend="buffer-flags" />. For output streams the data 729 <xref linkend="buffer-flags" />. For output streams the driver
749 will not be displayed before this time, secondary to the nominal 730 stores the time at which the last data byte was actually sent out
750 frame rate determined by the current video standard in enqueued 731 in the <structfield>timestamp</structfield> field. This permits
751 order. Applications can for example zero this field to display
752 frames as soon as possible. The driver stores the time at which
753 the first data byte was actually sent out in the
754 <structfield>timestamp</structfield> field. This permits
755 applications to monitor the drift between the video and system 732 applications to monitor the drift between the video and system
756 clock.</para></entry> 733 clock. For output streams that use <constant>V4L2_BUF_FLAG_TIMESTAMP_COPY</constant>
734 the application has to fill in the timestamp which will be copied
735 by the driver to the capture stream.</para></entry>
757 </row> 736 </row>
758 <row> 737 <row>
759 <entry>&v4l2-timecode;</entry> 738 <entry>&v4l2-timecode;</entry>
@@ -846,7 +825,8 @@ is the file descriptor associated with a DMABUF buffer.</entry>
846 <entry><structfield>length</structfield></entry> 825 <entry><structfield>length</structfield></entry>
847 <entry></entry> 826 <entry></entry>
848 <entry>Size of the buffer (not the payload) in bytes for the 827 <entry>Size of the buffer (not the payload) in bytes for the
849 single-planar API. For the multi-planar API the application sets 828 single-planar API. This is set by the driver based on the calls to
829 &VIDIOC-REQBUFS; and/or &VIDIOC-CREATE-BUFS;. For the multi-planar API the application sets
850 this to the number of elements in the <structfield>planes</structfield> 830 this to the number of elements in the <structfield>planes</structfield>
851 array. The driver will fill in the actual number of valid elements in 831 array. The driver will fill in the actual number of valid elements in
852 that array. 832 that array.
@@ -880,13 +860,15 @@ should set this to 0.</entry>
880 <entry><structfield>bytesused</structfield></entry> 860 <entry><structfield>bytesused</structfield></entry>
881 <entry></entry> 861 <entry></entry>
882 <entry>The number of bytes occupied by data in the plane 862 <entry>The number of bytes occupied by data in the plane
883 (its payload).</entry> 863 (its payload). Drivers must set this field when <structfield>type</structfield>
864 refers to an input stream, applications when it refers to an output stream.</entry>
884 </row> 865 </row>
885 <row> 866 <row>
886 <entry>__u32</entry> 867 <entry>__u32</entry>
887 <entry><structfield>length</structfield></entry> 868 <entry><structfield>length</structfield></entry>
888 <entry></entry> 869 <entry></entry>
889 <entry>Size in bytes of the plane (not its payload).</entry> 870 <entry>Size in bytes of the plane (not its payload). This is set by the driver
871 based on the calls to &VIDIOC-REQBUFS; and/or &VIDIOC-CREATE-BUFS;.</entry>
890 </row> 872 </row>
891 <row> 873 <row>
892 <entry>union</entry> 874 <entry>union</entry>
@@ -925,7 +907,9 @@ should set this to 0.</entry>
925 <entry>__u32</entry> 907 <entry>__u32</entry>
926 <entry><structfield>data_offset</structfield></entry> 908 <entry><structfield>data_offset</structfield></entry>
927 <entry></entry> 909 <entry></entry>
928 <entry>Offset in bytes to video data in the plane, if applicable. 910 <entry>Offset in bytes to video data in the plane.
911 Drivers must set this field when <structfield>type</structfield>
912 refers to an input stream, applications when it refers to an output stream.
929 </entry> 913 </entry>
930 </row> 914 </row>
931 <row> 915 <row>
@@ -1005,6 +989,12 @@ should set this to 0.</entry>
1005 <entry>Buffer for video output overlay (OSD), see <xref 989 <entry>Buffer for video output overlay (OSD), see <xref
1006 linkend="osd" />.</entry> 990 linkend="osd" />.</entry>
1007 </row> 991 </row>
992 <row>
993 <entry><constant>V4L2_BUF_TYPE_SDR_CAPTURE</constant></entry>
994 <entry>11</entry>
995 <entry>Buffer for Software Defined Radio (SDR), see <xref
996 linkend="sdr" />.</entry>
997 </row>
1008 </tbody> 998 </tbody>
1009 </tgroup> 999 </tgroup>
1010 </table> 1000 </table>
@@ -1016,7 +1006,7 @@ should set this to 0.</entry>
1016 <tbody valign="top"> 1006 <tbody valign="top">
1017 <row> 1007 <row>
1018 <entry><constant>V4L2_BUF_FLAG_MAPPED</constant></entry> 1008 <entry><constant>V4L2_BUF_FLAG_MAPPED</constant></entry>
1019 <entry>0x0001</entry> 1009 <entry>0x00000001</entry>
1020 <entry>The buffer resides in device memory and has been mapped 1010 <entry>The buffer resides in device memory and has been mapped
1021into the application's address space, see <xref linkend="mmap" /> for details. 1011into the application's address space, see <xref linkend="mmap" /> for details.
1022Drivers set or clear this flag when the 1012Drivers set or clear this flag when the
@@ -1026,7 +1016,7 @@ Drivers set or clear this flag when the
1026 </row> 1016 </row>
1027 <row> 1017 <row>
1028 <entry><constant>V4L2_BUF_FLAG_QUEUED</constant></entry> 1018 <entry><constant>V4L2_BUF_FLAG_QUEUED</constant></entry>
1029 <entry>0x0002</entry> 1019 <entry>0x00000002</entry>
1030 <entry>Internally drivers maintain two buffer queues, an 1020 <entry>Internally drivers maintain two buffer queues, an
1031incoming and outgoing queue. When this flag is set, the buffer is 1021incoming and outgoing queue. When this flag is set, the buffer is
1032currently on the incoming queue. It automatically moves to the 1022currently on the incoming queue. It automatically moves to the
@@ -1039,7 +1029,7 @@ cleared.</entry>
1039 </row> 1029 </row>
1040 <row> 1030 <row>
1041 <entry><constant>V4L2_BUF_FLAG_DONE</constant></entry> 1031 <entry><constant>V4L2_BUF_FLAG_DONE</constant></entry>
1042 <entry>0x0004</entry> 1032 <entry>0x00000004</entry>
1043 <entry>When this flag is set, the buffer is currently on 1033 <entry>When this flag is set, the buffer is currently on
1044the outgoing queue, ready to be dequeued from the driver. Drivers set 1034the outgoing queue, ready to be dequeued from the driver. Drivers set
1045or clear this flag when the <constant>VIDIOC_QUERYBUF</constant> ioctl 1035or clear this flag when the <constant>VIDIOC_QUERYBUF</constant> ioctl
@@ -1049,11 +1039,11 @@ buffer cannot be on both queues at the same time, the
1049<constant>V4L2_BUF_FLAG_QUEUED</constant> and 1039<constant>V4L2_BUF_FLAG_QUEUED</constant> and
1050<constant>V4L2_BUF_FLAG_DONE</constant> flag are mutually exclusive. 1040<constant>V4L2_BUF_FLAG_DONE</constant> flag are mutually exclusive.
1051They can be both cleared however, then the buffer is in "dequeued" 1041They can be both cleared however, then the buffer is in "dequeued"
1052state, in the application domain to say so.</entry> 1042state, in the application domain so to say.</entry>
1053 </row> 1043 </row>
1054 <row> 1044 <row>
1055 <entry><constant>V4L2_BUF_FLAG_ERROR</constant></entry> 1045 <entry><constant>V4L2_BUF_FLAG_ERROR</constant></entry>
1056 <entry>0x0040</entry> 1046 <entry>0x00000040</entry>
1057 <entry>When this flag is set, the buffer has been dequeued 1047 <entry>When this flag is set, the buffer has been dequeued
1058 successfully, although the data might have been corrupted. 1048 successfully, although the data might have been corrupted.
1059 This is recoverable, streaming may continue as normal and 1049 This is recoverable, streaming may continue as normal and
@@ -1063,35 +1053,43 @@ state, in the application domain to say so.</entry>
1063 </row> 1053 </row>
1064 <row> 1054 <row>
1065 <entry><constant>V4L2_BUF_FLAG_KEYFRAME</constant></entry> 1055 <entry><constant>V4L2_BUF_FLAG_KEYFRAME</constant></entry>
1066 <entry>0x0008</entry> 1056 <entry>0x00000008</entry>
1067 <entry>Drivers set or clear this flag when calling the 1057 <entry>Drivers set or clear this flag when calling the
1068<constant>VIDIOC_DQBUF</constant> ioctl. It may be set by video 1058<constant>VIDIOC_DQBUF</constant> ioctl. It may be set by video
1069capture devices when the buffer contains a compressed image which is a 1059capture devices when the buffer contains a compressed image which is a
1070key frame (or field), &ie; can be decompressed on its own.</entry> 1060key frame (or field), &ie; can be decompressed on its own. Also know as
1061an I-frame. Applications can set this bit when <structfield>type</structfield>
1062refers to an output stream.</entry>
1071 </row> 1063 </row>
1072 <row> 1064 <row>
1073 <entry><constant>V4L2_BUF_FLAG_PFRAME</constant></entry> 1065 <entry><constant>V4L2_BUF_FLAG_PFRAME</constant></entry>
1074 <entry>0x0010</entry> 1066 <entry>0x00000010</entry>
1075 <entry>Similar to <constant>V4L2_BUF_FLAG_KEYFRAME</constant> 1067 <entry>Similar to <constant>V4L2_BUF_FLAG_KEYFRAME</constant>
1076this flags predicted frames or fields which contain only differences to a 1068this flags predicted frames or fields which contain only differences to a
1077previous key frame.</entry> 1069previous key frame. Applications can set this bit when <structfield>type</structfield>
1070refers to an output stream.</entry>
1078 </row> 1071 </row>
1079 <row> 1072 <row>
1080 <entry><constant>V4L2_BUF_FLAG_BFRAME</constant></entry> 1073 <entry><constant>V4L2_BUF_FLAG_BFRAME</constant></entry>
1081 <entry>0x0020</entry> 1074 <entry>0x00000020</entry>
1082 <entry>Similar to <constant>V4L2_BUF_FLAG_PFRAME</constant> 1075 <entry>Similar to <constant>V4L2_BUF_FLAG_KEYFRAME</constant>
1083 this is a bidirectional predicted frame or field. [ooc tbd]</entry> 1076this flags a bi-directional predicted frame or field which contains only
1077the differences between the current frame and both the preceding and following
1078key frames to specify its content. Applications can set this bit when
1079<structfield>type</structfield> refers to an output stream.</entry>
1084 </row> 1080 </row>
1085 <row> 1081 <row>
1086 <entry><constant>V4L2_BUF_FLAG_TIMECODE</constant></entry> 1082 <entry><constant>V4L2_BUF_FLAG_TIMECODE</constant></entry>
1087 <entry>0x0100</entry> 1083 <entry>0x00000100</entry>
1088 <entry>The <structfield>timecode</structfield> field is valid. 1084 <entry>The <structfield>timecode</structfield> field is valid.
1089Drivers set or clear this flag when the <constant>VIDIOC_DQBUF</constant> 1085Drivers set or clear this flag when the <constant>VIDIOC_DQBUF</constant>
1090ioctl is called.</entry> 1086ioctl is called. Applications can set this bit and the corresponding
1087<structfield>timecode</structfield> structure when <structfield>type</structfield>
1088refers to an output stream.</entry>
1091 </row> 1089 </row>
1092 <row> 1090 <row>
1093 <entry><constant>V4L2_BUF_FLAG_PREPARED</constant></entry> 1091 <entry><constant>V4L2_BUF_FLAG_PREPARED</constant></entry>
1094 <entry>0x0400</entry> 1092 <entry>0x00000400</entry>
1095 <entry>The buffer has been prepared for I/O and can be queued by the 1093 <entry>The buffer has been prepared for I/O and can be queued by the
1096application. Drivers set or clear this flag when the 1094application. Drivers set or clear this flag when the
1097<link linkend="vidioc-querybuf">VIDIOC_QUERYBUF</link>, <link 1095<link linkend="vidioc-querybuf">VIDIOC_QUERYBUF</link>, <link
@@ -1101,7 +1099,7 @@ application. Drivers set or clear this flag when the
1101 </row> 1099 </row>
1102 <row> 1100 <row>
1103 <entry><constant>V4L2_BUF_FLAG_NO_CACHE_INVALIDATE</constant></entry> 1101 <entry><constant>V4L2_BUF_FLAG_NO_CACHE_INVALIDATE</constant></entry>
1104 <entry>0x0800</entry> 1102 <entry>0x00000800</entry>
1105 <entry>Caches do not have to be invalidated for this buffer. 1103 <entry>Caches do not have to be invalidated for this buffer.
1106Typically applications shall use this flag if the data captured in the buffer 1104Typically applications shall use this flag if the data captured in the buffer
1107is not going to be touched by the CPU, instead the buffer will, probably, be 1105is not going to be touched by the CPU, instead the buffer will, probably, be
@@ -1110,7 +1108,7 @@ passed on to a DMA-capable hardware unit for further processing or output.
1110 </row> 1108 </row>
1111 <row> 1109 <row>
1112 <entry><constant>V4L2_BUF_FLAG_NO_CACHE_CLEAN</constant></entry> 1110 <entry><constant>V4L2_BUF_FLAG_NO_CACHE_CLEAN</constant></entry>
1113 <entry>0x1000</entry> 1111 <entry>0x00001000</entry>
1114 <entry>Caches do not have to be cleaned for this buffer. 1112 <entry>Caches do not have to be cleaned for this buffer.
1115Typically applications shall use this flag for output buffers if the data 1113Typically applications shall use this flag for output buffers if the data
1116in this buffer has not been created by the CPU but by some DMA-capable unit, 1114in this buffer has not been created by the CPU but by some DMA-capable unit,
@@ -1118,7 +1116,7 @@ in which case caches have not been used.</entry>
1118 </row> 1116 </row>
1119 <row> 1117 <row>
1120 <entry><constant>V4L2_BUF_FLAG_TIMESTAMP_MASK</constant></entry> 1118 <entry><constant>V4L2_BUF_FLAG_TIMESTAMP_MASK</constant></entry>
1121 <entry>0xe000</entry> 1119 <entry>0x0000e000</entry>
1122 <entry>Mask for timestamp types below. To test the 1120 <entry>Mask for timestamp types below. To test the
1123 timestamp type, mask out bits not belonging to timestamp 1121 timestamp type, mask out bits not belonging to timestamp
1124 type by performing a logical and operation with buffer 1122 type by performing a logical and operation with buffer
@@ -1126,7 +1124,7 @@ in which case caches have not been used.</entry>
1126 </row> 1124 </row>
1127 <row> 1125 <row>
1128 <entry><constant>V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN</constant></entry> 1126 <entry><constant>V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN</constant></entry>
1129 <entry>0x0000</entry> 1127 <entry>0x00000000</entry>
1130 <entry>Unknown timestamp type. This type is used by 1128 <entry>Unknown timestamp type. This type is used by
1131 drivers before Linux 3.9 and may be either monotonic (see 1129 drivers before Linux 3.9 and may be either monotonic (see
1132 below) or realtime (wall clock). Monotonic clock has been 1130 below) or realtime (wall clock). Monotonic clock has been
@@ -1139,7 +1137,7 @@ in which case caches have not been used.</entry>
1139 </row> 1137 </row>
1140 <row> 1138 <row>
1141 <entry><constant>V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC</constant></entry> 1139 <entry><constant>V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC</constant></entry>
1142 <entry>0x2000</entry> 1140 <entry>0x00002000</entry>
1143 <entry>The buffer timestamp has been taken from the 1141 <entry>The buffer timestamp has been taken from the
1144 <constant>CLOCK_MONOTONIC</constant> clock. To access the 1142 <constant>CLOCK_MONOTONIC</constant> clock. To access the
1145 same clock outside V4L2, use 1143 same clock outside V4L2, use
@@ -1147,10 +1145,42 @@ in which case caches have not been used.</entry>
1147 </row> 1145 </row>
1148 <row> 1146 <row>
1149 <entry><constant>V4L2_BUF_FLAG_TIMESTAMP_COPY</constant></entry> 1147 <entry><constant>V4L2_BUF_FLAG_TIMESTAMP_COPY</constant></entry>
1150 <entry>0x4000</entry> 1148 <entry>0x00004000</entry>
1151 <entry>The CAPTURE buffer timestamp has been taken from the 1149 <entry>The CAPTURE buffer timestamp has been taken from the
1152 corresponding OUTPUT buffer. This flag applies only to mem2mem devices.</entry> 1150 corresponding OUTPUT buffer. This flag applies only to mem2mem devices.</entry>
1153 </row> 1151 </row>
1152 <row>
1153 <entry><constant>V4L2_BUF_FLAG_TSTAMP_SRC_MASK</constant></entry>
1154 <entry>0x00070000</entry>
1155 <entry>Mask for timestamp sources below. The timestamp source
1156 defines the point of time the timestamp is taken in relation to
1157 the frame. Logical 'and' operation between the
1158 <structfield>flags</structfield> field and
1159 <constant>V4L2_BUF_FLAG_TSTAMP_SRC_MASK</constant> produces the
1160 value of the timestamp source. Applications must set the timestamp
1161 source when <structfield>type</structfield> refers to an output stream
1162 and <constant>V4L2_BUF_FLAG_TIMESTAMP_COPY</constant> is set.</entry>
1163 </row>
1164 <row>
1165 <entry><constant>V4L2_BUF_FLAG_TSTAMP_SRC_EOF</constant></entry>
1166 <entry>0x00000000</entry>
1167 <entry>End Of Frame. The buffer timestamp has been taken
1168 when the last pixel of the frame has been received or the
1169 last pixel of the frame has been transmitted. In practice,
1170 software generated timestamps will typically be read from
1171 the clock a small amount of time after the last pixel has
1172 been received or transmitten, depending on the system and
1173 other activity in it.</entry>
1174 </row>
1175 <row>
1176 <entry><constant>V4L2_BUF_FLAG_TSTAMP_SRC_SOE</constant></entry>
1177 <entry>0x00010000</entry>
1178 <entry>Start Of Exposure. The buffer timestamp has been
1179 taken when the exposure of the frame has begun. This is
1180 only valid for the
1181 <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant> buffer
1182 type.</entry>
1183 </row>
1154 </tbody> 1184 </tbody>
1155 </tgroup> 1185 </tgroup>
1156 </table> 1186 </table>
@@ -1440,10 +1470,9 @@ or application, depending on data direction, must set &v4l2-buffer;
1440<constant>V4L2_FIELD_BOTTOM</constant>. Any two successive fields pair 1470<constant>V4L2_FIELD_BOTTOM</constant>. Any two successive fields pair
1441to build a frame. If fields are successive, without any dropped fields 1471to build a frame. If fields are successive, without any dropped fields
1442between them (fields can drop individually), can be determined from 1472between them (fields can drop individually), can be determined from
1443the &v4l2-buffer; <structfield>sequence</structfield> field. Image 1473the &v4l2-buffer; <structfield>sequence</structfield> field. This format
1444sizes refer to the frame, not fields. This format cannot be selected 1474cannot be selected when using the read/write I/O method since there
1445when using the read/write I/O method.<!-- Where it's indistinguishable 1475is no way to communicate if a field was a top or bottom field.</entry>
1446from V4L2_FIELD_SEQ_*. --></entry>
1447 </row> 1476 </row>
1448 <row> 1477 <row>
1449 <entry><constant>V4L2_FIELD_INTERLACED_TB</constant></entry> 1478 <entry><constant>V4L2_FIELD_INTERLACED_TB</constant></entry>
diff --git a/Documentation/DocBook/media/v4l/pixfmt-nv16m.xml b/Documentation/DocBook/media/v4l/pixfmt-nv16m.xml
index c51d5a4cda09..fb2b5e35d665 100644
--- a/Documentation/DocBook/media/v4l/pixfmt-nv16m.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt-nv16m.xml
@@ -12,18 +12,17 @@
12 <refsect1> 12 <refsect1>
13 <title>Description</title> 13 <title>Description</title>
14 14
15 <para>This is a multi-planar, two-plane version of the YUV 4:2:0 format. 15 <para>This is a multi-planar, two-plane version of the YUV 4:2:2 format.
16The three components are separated into two sub-images or planes. 16The three components are separated into two sub-images or planes.
17<constant>V4L2_PIX_FMT_NV16M</constant> differs from <constant>V4L2_PIX_FMT_NV16 17<constant>V4L2_PIX_FMT_NV16M</constant> differs from <constant>V4L2_PIX_FMT_NV16
18</constant> in that the two planes are non-contiguous in memory, i.e. the chroma 18</constant> in that the two planes are non-contiguous in memory, i.e. the chroma
19plane does not necessarily immediately follows the luma plane. 19plane does not necessarily immediately follow the luma plane.
20The luminance data occupies the first plane. The Y plane has one byte per pixel. 20The luminance data occupies the first plane. The Y plane has one byte per pixel.
21In the second plane there is chrominance data with alternating chroma samples. 21In the second plane there is chrominance data with alternating chroma samples.
22The CbCr plane is the same width and height, in bytes, as the Y plane. 22The CbCr plane is the same width and height, in bytes, as the Y plane.
23Each CbCr pair belongs to four pixels. For example, 23Each CbCr pair belongs to two pixels. For example,
24Cb<subscript>0</subscript>/Cr<subscript>0</subscript> belongs to 24Cb<subscript>0</subscript>/Cr<subscript>0</subscript> belongs to
25Y'<subscript>00</subscript>, Y'<subscript>01</subscript>, 25Y'<subscript>00</subscript>, Y'<subscript>01</subscript>.
26Y'<subscript>10</subscript>, Y'<subscript>11</subscript>.
27<constant>V4L2_PIX_FMT_NV61M</constant> is the same as <constant>V4L2_PIX_FMT_NV16M</constant> 26<constant>V4L2_PIX_FMT_NV61M</constant> is the same as <constant>V4L2_PIX_FMT_NV16M</constant>
28except the Cb and Cr bytes are swapped, the CrCb plane starts with a Cr byte.</para> 27except the Cb and Cr bytes are swapped, the CrCb plane starts with a Cr byte.</para>
29 28
diff --git a/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml b/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
index 166c8d65e4f7..e1c4f8b4c0b3 100644
--- a/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
@@ -121,14 +121,14 @@ colorspace <constant>V4L2_COLORSPACE_SRGB</constant>.</para>
121 <entry><constant>V4L2_PIX_FMT_RGB332</constant></entry> 121 <entry><constant>V4L2_PIX_FMT_RGB332</constant></entry>
122 <entry>'RGB1'</entry> 122 <entry>'RGB1'</entry>
123 <entry></entry> 123 <entry></entry>
124 <entry>b<subscript>1</subscript></entry>
125 <entry>b<subscript>0</subscript></entry>
126 <entry>g<subscript>2</subscript></entry>
127 <entry>g<subscript>1</subscript></entry>
128 <entry>g<subscript>0</subscript></entry>
129 <entry>r<subscript>2</subscript></entry> 124 <entry>r<subscript>2</subscript></entry>
130 <entry>r<subscript>1</subscript></entry> 125 <entry>r<subscript>1</subscript></entry>
131 <entry>r<subscript>0</subscript></entry> 126 <entry>r<subscript>0</subscript></entry>
127 <entry>g<subscript>2</subscript></entry>
128 <entry>g<subscript>1</subscript></entry>
129 <entry>g<subscript>0</subscript></entry>
130 <entry>b<subscript>1</subscript></entry>
131 <entry>b<subscript>0</subscript></entry>
132 </row> 132 </row>
133 <row id="V4L2-PIX-FMT-RGB444"> 133 <row id="V4L2-PIX-FMT-RGB444">
134 <entry><constant>V4L2_PIX_FMT_RGB444</constant></entry> 134 <entry><constant>V4L2_PIX_FMT_RGB444</constant></entry>
@@ -159,18 +159,18 @@ colorspace <constant>V4L2_COLORSPACE_SRGB</constant>.</para>
159 <entry>g<subscript>2</subscript></entry> 159 <entry>g<subscript>2</subscript></entry>
160 <entry>g<subscript>1</subscript></entry> 160 <entry>g<subscript>1</subscript></entry>
161 <entry>g<subscript>0</subscript></entry> 161 <entry>g<subscript>0</subscript></entry>
162 <entry>r<subscript>4</subscript></entry>
163 <entry>r<subscript>3</subscript></entry>
164 <entry>r<subscript>2</subscript></entry>
165 <entry>r<subscript>1</subscript></entry>
166 <entry>r<subscript>0</subscript></entry>
167 <entry></entry>
168 <entry>a</entry>
169 <entry>b<subscript>4</subscript></entry> 162 <entry>b<subscript>4</subscript></entry>
170 <entry>b<subscript>3</subscript></entry> 163 <entry>b<subscript>3</subscript></entry>
171 <entry>b<subscript>2</subscript></entry> 164 <entry>b<subscript>2</subscript></entry>
172 <entry>b<subscript>1</subscript></entry> 165 <entry>b<subscript>1</subscript></entry>
173 <entry>b<subscript>0</subscript></entry> 166 <entry>b<subscript>0</subscript></entry>
167 <entry></entry>
168 <entry>a</entry>
169 <entry>r<subscript>4</subscript></entry>
170 <entry>r<subscript>3</subscript></entry>
171 <entry>r<subscript>2</subscript></entry>
172 <entry>r<subscript>1</subscript></entry>
173 <entry>r<subscript>0</subscript></entry>
174 <entry>g<subscript>4</subscript></entry> 174 <entry>g<subscript>4</subscript></entry>
175 <entry>g<subscript>3</subscript></entry> 175 <entry>g<subscript>3</subscript></entry>
176 </row> 176 </row>
@@ -181,17 +181,17 @@ colorspace <constant>V4L2_COLORSPACE_SRGB</constant>.</para>
181 <entry>g<subscript>2</subscript></entry> 181 <entry>g<subscript>2</subscript></entry>
182 <entry>g<subscript>1</subscript></entry> 182 <entry>g<subscript>1</subscript></entry>
183 <entry>g<subscript>0</subscript></entry> 183 <entry>g<subscript>0</subscript></entry>
184 <entry>r<subscript>4</subscript></entry>
185 <entry>r<subscript>3</subscript></entry>
186 <entry>r<subscript>2</subscript></entry>
187 <entry>r<subscript>1</subscript></entry>
188 <entry>r<subscript>0</subscript></entry>
189 <entry></entry>
190 <entry>b<subscript>4</subscript></entry> 184 <entry>b<subscript>4</subscript></entry>
191 <entry>b<subscript>3</subscript></entry> 185 <entry>b<subscript>3</subscript></entry>
192 <entry>b<subscript>2</subscript></entry> 186 <entry>b<subscript>2</subscript></entry>
193 <entry>b<subscript>1</subscript></entry> 187 <entry>b<subscript>1</subscript></entry>
194 <entry>b<subscript>0</subscript></entry> 188 <entry>b<subscript>0</subscript></entry>
189 <entry></entry>
190 <entry>r<subscript>4</subscript></entry>
191 <entry>r<subscript>3</subscript></entry>
192 <entry>r<subscript>2</subscript></entry>
193 <entry>r<subscript>1</subscript></entry>
194 <entry>r<subscript>0</subscript></entry>
195 <entry>g<subscript>5</subscript></entry> 195 <entry>g<subscript>5</subscript></entry>
196 <entry>g<subscript>4</subscript></entry> 196 <entry>g<subscript>4</subscript></entry>
197 <entry>g<subscript>3</subscript></entry> 197 <entry>g<subscript>3</subscript></entry>
@@ -201,32 +201,32 @@ colorspace <constant>V4L2_COLORSPACE_SRGB</constant>.</para>
201 <entry>'RGBQ'</entry> 201 <entry>'RGBQ'</entry>
202 <entry></entry> 202 <entry></entry>
203 <entry>a</entry> 203 <entry>a</entry>
204 <entry>b<subscript>4</subscript></entry>
205 <entry>b<subscript>3</subscript></entry>
206 <entry>b<subscript>2</subscript></entry>
207 <entry>b<subscript>1</subscript></entry>
208 <entry>b<subscript>0</subscript></entry>
209 <entry>g<subscript>4</subscript></entry>
210 <entry>g<subscript>3</subscript></entry>
211 <entry></entry>
212 <entry>g<subscript>2</subscript></entry>
213 <entry>g<subscript>1</subscript></entry>
214 <entry>g<subscript>0</subscript></entry>
215 <entry>r<subscript>4</subscript></entry> 204 <entry>r<subscript>4</subscript></entry>
216 <entry>r<subscript>3</subscript></entry> 205 <entry>r<subscript>3</subscript></entry>
217 <entry>r<subscript>2</subscript></entry> 206 <entry>r<subscript>2</subscript></entry>
218 <entry>r<subscript>1</subscript></entry> 207 <entry>r<subscript>1</subscript></entry>
219 <entry>r<subscript>0</subscript></entry> 208 <entry>r<subscript>0</subscript></entry>
220 </row> 209 <entry>g<subscript>4</subscript></entry>
221 <row id="V4L2-PIX-FMT-RGB565X"> 210 <entry>g<subscript>3</subscript></entry>
222 <entry><constant>V4L2_PIX_FMT_RGB565X</constant></entry>
223 <entry>'RGBR'</entry>
224 <entry></entry> 211 <entry></entry>
212 <entry>g<subscript>2</subscript></entry>
213 <entry>g<subscript>1</subscript></entry>
214 <entry>g<subscript>0</subscript></entry>
225 <entry>b<subscript>4</subscript></entry> 215 <entry>b<subscript>4</subscript></entry>
226 <entry>b<subscript>3</subscript></entry> 216 <entry>b<subscript>3</subscript></entry>
227 <entry>b<subscript>2</subscript></entry> 217 <entry>b<subscript>2</subscript></entry>
228 <entry>b<subscript>1</subscript></entry> 218 <entry>b<subscript>1</subscript></entry>
229 <entry>b<subscript>0</subscript></entry> 219 <entry>b<subscript>0</subscript></entry>
220 </row>
221 <row id="V4L2-PIX-FMT-RGB565X">
222 <entry><constant>V4L2_PIX_FMT_RGB565X</constant></entry>
223 <entry>'RGBR'</entry>
224 <entry></entry>
225 <entry>r<subscript>4</subscript></entry>
226 <entry>r<subscript>3</subscript></entry>
227 <entry>r<subscript>2</subscript></entry>
228 <entry>r<subscript>1</subscript></entry>
229 <entry>r<subscript>0</subscript></entry>
230 <entry>g<subscript>5</subscript></entry> 230 <entry>g<subscript>5</subscript></entry>
231 <entry>g<subscript>4</subscript></entry> 231 <entry>g<subscript>4</subscript></entry>
232 <entry>g<subscript>3</subscript></entry> 232 <entry>g<subscript>3</subscript></entry>
@@ -234,11 +234,11 @@ colorspace <constant>V4L2_COLORSPACE_SRGB</constant>.</para>
234 <entry>g<subscript>2</subscript></entry> 234 <entry>g<subscript>2</subscript></entry>
235 <entry>g<subscript>1</subscript></entry> 235 <entry>g<subscript>1</subscript></entry>
236 <entry>g<subscript>0</subscript></entry> 236 <entry>g<subscript>0</subscript></entry>
237 <entry>r<subscript>4</subscript></entry> 237 <entry>b<subscript>4</subscript></entry>
238 <entry>r<subscript>3</subscript></entry> 238 <entry>b<subscript>3</subscript></entry>
239 <entry>r<subscript>2</subscript></entry> 239 <entry>b<subscript>2</subscript></entry>
240 <entry>r<subscript>1</subscript></entry> 240 <entry>b<subscript>1</subscript></entry>
241 <entry>r<subscript>0</subscript></entry> 241 <entry>b<subscript>0</subscript></entry>
242 </row> 242 </row>
243 <row id="V4L2-PIX-FMT-BGR666"> 243 <row id="V4L2-PIX-FMT-BGR666">
244 <entry><constant>V4L2_PIX_FMT_BGR666</constant></entry> 244 <entry><constant>V4L2_PIX_FMT_BGR666</constant></entry>
@@ -385,6 +385,15 @@ colorspace <constant>V4L2_COLORSPACE_SRGB</constant>.</para>
385 <entry><constant>V4L2_PIX_FMT_RGB32</constant></entry> 385 <entry><constant>V4L2_PIX_FMT_RGB32</constant></entry>
386 <entry>'RGB4'</entry> 386 <entry>'RGB4'</entry>
387 <entry></entry> 387 <entry></entry>
388 <entry>a<subscript>7</subscript></entry>
389 <entry>a<subscript>6</subscript></entry>
390 <entry>a<subscript>5</subscript></entry>
391 <entry>a<subscript>4</subscript></entry>
392 <entry>a<subscript>3</subscript></entry>
393 <entry>a<subscript>2</subscript></entry>
394 <entry>a<subscript>1</subscript></entry>
395 <entry>a<subscript>0</subscript></entry>
396 <entry></entry>
388 <entry>r<subscript>7</subscript></entry> 397 <entry>r<subscript>7</subscript></entry>
389 <entry>r<subscript>6</subscript></entry> 398 <entry>r<subscript>6</subscript></entry>
390 <entry>r<subscript>5</subscript></entry> 399 <entry>r<subscript>5</subscript></entry>
@@ -411,25 +420,16 @@ colorspace <constant>V4L2_COLORSPACE_SRGB</constant>.</para>
411 <entry>b<subscript>2</subscript></entry> 420 <entry>b<subscript>2</subscript></entry>
412 <entry>b<subscript>1</subscript></entry> 421 <entry>b<subscript>1</subscript></entry>
413 <entry>b<subscript>0</subscript></entry> 422 <entry>b<subscript>0</subscript></entry>
414 <entry></entry>
415 <entry>a<subscript>7</subscript></entry>
416 <entry>a<subscript>6</subscript></entry>
417 <entry>a<subscript>5</subscript></entry>
418 <entry>a<subscript>4</subscript></entry>
419 <entry>a<subscript>3</subscript></entry>
420 <entry>a<subscript>2</subscript></entry>
421 <entry>a<subscript>1</subscript></entry>
422 <entry>a<subscript>0</subscript></entry>
423 </row> 423 </row>
424 </tbody> 424 </tbody>
425 </tgroup> 425 </tgroup>
426 </table> 426 </table>
427 427
428 <para>Bit 7 is the most significant bit. The value of a = alpha 428 <para>Bit 7 is the most significant bit. The value of the a = alpha
429bits is undefined when reading from the driver, ignored when writing 429bits is undefined when reading from the driver, ignored when writing
430to the driver, except when alpha blending has been negotiated for a 430to the driver, except when alpha blending has been negotiated for a
431<link linkend="overlay">Video Overlay</link> or <link linkend="osd"> 431<link linkend="overlay">Video Overlay</link> or <link linkend="osd">
432Video Output Overlay</link> or when alpha component has been configured 432Video Output Overlay</link> or when the alpha component has been configured
433for a <link linkend="capture">Video Capture</link> by means of <link 433for a <link linkend="capture">Video Capture</link> by means of <link
434linkend="v4l2-alpha-component"> <constant>V4L2_CID_ALPHA_COMPONENT 434linkend="v4l2-alpha-component"> <constant>V4L2_CID_ALPHA_COMPONENT
435</constant> </link> control.</para> 435</constant> </link> control.</para>
@@ -512,421 +512,6 @@ image</title>
512 </formalpara> 512 </formalpara>
513 </example> 513 </example>
514 514
515 <important>
516 <para>Drivers may interpret these formats differently.</para>
517 </important>
518
519 <para>Some RGB formats above are uncommon and were probably
520defined in error. Drivers may interpret them as in <xref
521 linkend="rgb-formats-corrected" />.</para>
522
523 <table pgwide="1" frame="none" id="rgb-formats-corrected">
524 <title>Packed RGB Image Formats (corrected)</title>
525 <tgroup cols="37" align="center">
526 <colspec colname="id" align="left" />
527 <colspec colname="fourcc" />
528 <colspec colname="bit" />
529
530 <colspec colnum="4" colname="b07" align="center" />
531 <colspec colnum="5" colname="b06" align="center" />
532 <colspec colnum="6" colname="b05" align="center" />
533 <colspec colnum="7" colname="b04" align="center" />
534 <colspec colnum="8" colname="b03" align="center" />
535 <colspec colnum="9" colname="b02" align="center" />
536 <colspec colnum="10" colname="b01" align="center" />
537 <colspec colnum="11" colname="b00" align="center" />
538
539 <colspec colnum="13" colname="b17" align="center" />
540 <colspec colnum="14" colname="b16" align="center" />
541 <colspec colnum="15" colname="b15" align="center" />
542 <colspec colnum="16" colname="b14" align="center" />
543 <colspec colnum="17" colname="b13" align="center" />
544 <colspec colnum="18" colname="b12" align="center" />
545 <colspec colnum="19" colname="b11" align="center" />
546 <colspec colnum="20" colname="b10" align="center" />
547
548 <colspec colnum="22" colname="b27" align="center" />
549 <colspec colnum="23" colname="b26" align="center" />
550 <colspec colnum="24" colname="b25" align="center" />
551 <colspec colnum="25" colname="b24" align="center" />
552 <colspec colnum="26" colname="b23" align="center" />
553 <colspec colnum="27" colname="b22" align="center" />
554 <colspec colnum="28" colname="b21" align="center" />
555 <colspec colnum="29" colname="b20" align="center" />
556
557 <colspec colnum="31" colname="b37" align="center" />
558 <colspec colnum="32" colname="b36" align="center" />
559 <colspec colnum="33" colname="b35" align="center" />
560 <colspec colnum="34" colname="b34" align="center" />
561 <colspec colnum="35" colname="b33" align="center" />
562 <colspec colnum="36" colname="b32" align="center" />
563 <colspec colnum="37" colname="b31" align="center" />
564 <colspec colnum="38" colname="b30" align="center" />
565
566 <spanspec namest="b07" nameend="b00" spanname="b0" />
567 <spanspec namest="b17" nameend="b10" spanname="b1" />
568 <spanspec namest="b27" nameend="b20" spanname="b2" />
569 <spanspec namest="b37" nameend="b30" spanname="b3" />
570 <thead>
571 <row>
572 <entry>Identifier</entry>
573 <entry>Code</entry>
574 <entry>&nbsp;</entry>
575 <entry spanname="b0">Byte&nbsp;0 in memory</entry>
576 <entry spanname="b1">Byte&nbsp;1</entry>
577 <entry spanname="b2">Byte&nbsp;2</entry>
578 <entry spanname="b3">Byte&nbsp;3</entry>
579 </row>
580 <row>
581 <entry>&nbsp;</entry>
582 <entry>&nbsp;</entry>
583 <entry>Bit</entry>
584 <entry>7</entry>
585 <entry>6</entry>
586 <entry>5</entry>
587 <entry>4</entry>
588 <entry>3</entry>
589 <entry>2</entry>
590 <entry>1</entry>
591 <entry>0</entry>
592 <entry>&nbsp;</entry>
593 <entry>7</entry>
594 <entry>6</entry>
595 <entry>5</entry>
596 <entry>4</entry>
597 <entry>3</entry>
598 <entry>2</entry>
599 <entry>1</entry>
600 <entry>0</entry>
601 <entry>&nbsp;</entry>
602 <entry>7</entry>
603 <entry>6</entry>
604 <entry>5</entry>
605 <entry>4</entry>
606 <entry>3</entry>
607 <entry>2</entry>
608 <entry>1</entry>
609 <entry>0</entry>
610 <entry>&nbsp;</entry>
611 <entry>7</entry>
612 <entry>6</entry>
613 <entry>5</entry>
614 <entry>4</entry>
615 <entry>3</entry>
616 <entry>2</entry>
617 <entry>1</entry>
618 <entry>0</entry>
619 </row>
620 </thead>
621 <tbody valign="top">
622 <row><!-- id="V4L2-PIX-FMT-RGB332" -->
623 <entry><constant>V4L2_PIX_FMT_RGB332</constant></entry>
624 <entry>'RGB1'</entry>
625 <entry></entry>
626 <entry>r<subscript>2</subscript></entry>
627 <entry>r<subscript>1</subscript></entry>
628 <entry>r<subscript>0</subscript></entry>
629 <entry>g<subscript>2</subscript></entry>
630 <entry>g<subscript>1</subscript></entry>
631 <entry>g<subscript>0</subscript></entry>
632 <entry>b<subscript>1</subscript></entry>
633 <entry>b<subscript>0</subscript></entry>
634 </row>
635 <row><!-- id="V4L2-PIX-FMT-RGB444" -->
636 <entry><constant>V4L2_PIX_FMT_RGB444</constant></entry>
637 <entry>'R444'</entry>
638 <entry></entry>
639 <entry>g<subscript>3</subscript></entry>
640 <entry>g<subscript>2</subscript></entry>
641 <entry>g<subscript>1</subscript></entry>
642 <entry>g<subscript>0</subscript></entry>
643 <entry>b<subscript>3</subscript></entry>
644 <entry>b<subscript>2</subscript></entry>
645 <entry>b<subscript>1</subscript></entry>
646 <entry>b<subscript>0</subscript></entry>
647 <entry></entry>
648 <entry>a<subscript>3</subscript></entry>
649 <entry>a<subscript>2</subscript></entry>
650 <entry>a<subscript>1</subscript></entry>
651 <entry>a<subscript>0</subscript></entry>
652 <entry>r<subscript>3</subscript></entry>
653 <entry>r<subscript>2</subscript></entry>
654 <entry>r<subscript>1</subscript></entry>
655 <entry>r<subscript>0</subscript></entry>
656 </row>
657 <row><!-- id="V4L2-PIX-FMT-RGB555" -->
658 <entry><constant>V4L2_PIX_FMT_RGB555</constant></entry>
659 <entry>'RGBO'</entry>
660 <entry></entry>
661 <entry>g<subscript>2</subscript></entry>
662 <entry>g<subscript>1</subscript></entry>
663 <entry>g<subscript>0</subscript></entry>
664 <entry>b<subscript>4</subscript></entry>
665 <entry>b<subscript>3</subscript></entry>
666 <entry>b<subscript>2</subscript></entry>
667 <entry>b<subscript>1</subscript></entry>
668 <entry>b<subscript>0</subscript></entry>
669 <entry></entry>
670 <entry>a</entry>
671 <entry>r<subscript>4</subscript></entry>
672 <entry>r<subscript>3</subscript></entry>
673 <entry>r<subscript>2</subscript></entry>
674 <entry>r<subscript>1</subscript></entry>
675 <entry>r<subscript>0</subscript></entry>
676 <entry>g<subscript>4</subscript></entry>
677 <entry>g<subscript>3</subscript></entry>
678 </row>
679 <row><!-- id="V4L2-PIX-FMT-RGB565" -->
680 <entry><constant>V4L2_PIX_FMT_RGB565</constant></entry>
681 <entry>'RGBP'</entry>
682 <entry></entry>
683 <entry>g<subscript>2</subscript></entry>
684 <entry>g<subscript>1</subscript></entry>
685 <entry>g<subscript>0</subscript></entry>
686 <entry>b<subscript>4</subscript></entry>
687 <entry>b<subscript>3</subscript></entry>
688 <entry>b<subscript>2</subscript></entry>
689 <entry>b<subscript>1</subscript></entry>
690 <entry>b<subscript>0</subscript></entry>
691 <entry></entry>
692 <entry>r<subscript>4</subscript></entry>
693 <entry>r<subscript>3</subscript></entry>
694 <entry>r<subscript>2</subscript></entry>
695 <entry>r<subscript>1</subscript></entry>
696 <entry>r<subscript>0</subscript></entry>
697 <entry>g<subscript>5</subscript></entry>
698 <entry>g<subscript>4</subscript></entry>
699 <entry>g<subscript>3</subscript></entry>
700 </row>
701 <row><!-- id="V4L2-PIX-FMT-RGB555X" -->
702 <entry><constant>V4L2_PIX_FMT_RGB555X</constant></entry>
703 <entry>'RGBQ'</entry>
704 <entry></entry>
705 <entry>a</entry>
706 <entry>r<subscript>4</subscript></entry>
707 <entry>r<subscript>3</subscript></entry>
708 <entry>r<subscript>2</subscript></entry>
709 <entry>r<subscript>1</subscript></entry>
710 <entry>r<subscript>0</subscript></entry>
711 <entry>g<subscript>4</subscript></entry>
712 <entry>g<subscript>3</subscript></entry>
713 <entry></entry>
714 <entry>g<subscript>2</subscript></entry>
715 <entry>g<subscript>1</subscript></entry>
716 <entry>g<subscript>0</subscript></entry>
717 <entry>b<subscript>4</subscript></entry>
718 <entry>b<subscript>3</subscript></entry>
719 <entry>b<subscript>2</subscript></entry>
720 <entry>b<subscript>1</subscript></entry>
721 <entry>b<subscript>0</subscript></entry>
722 </row>
723 <row><!-- id="V4L2-PIX-FMT-RGB565X" -->
724 <entry><constant>V4L2_PIX_FMT_RGB565X</constant></entry>
725 <entry>'RGBR'</entry>
726 <entry></entry>
727 <entry>r<subscript>4</subscript></entry>
728 <entry>r<subscript>3</subscript></entry>
729 <entry>r<subscript>2</subscript></entry>
730 <entry>r<subscript>1</subscript></entry>
731 <entry>r<subscript>0</subscript></entry>
732 <entry>g<subscript>5</subscript></entry>
733 <entry>g<subscript>4</subscript></entry>
734 <entry>g<subscript>3</subscript></entry>
735 <entry></entry>
736 <entry>g<subscript>2</subscript></entry>
737 <entry>g<subscript>1</subscript></entry>
738 <entry>g<subscript>0</subscript></entry>
739 <entry>b<subscript>4</subscript></entry>
740 <entry>b<subscript>3</subscript></entry>
741 <entry>b<subscript>2</subscript></entry>
742 <entry>b<subscript>1</subscript></entry>
743 <entry>b<subscript>0</subscript></entry>
744 </row>
745 <row><!-- id="V4L2-PIX-FMT-BGR666" -->
746 <entry><constant>V4L2_PIX_FMT_BGR666</constant></entry>
747 <entry>'BGRH'</entry>
748 <entry></entry>
749 <entry>b<subscript>5</subscript></entry>
750 <entry>b<subscript>4</subscript></entry>
751 <entry>b<subscript>3</subscript></entry>
752 <entry>b<subscript>2</subscript></entry>
753 <entry>b<subscript>1</subscript></entry>
754 <entry>b<subscript>0</subscript></entry>
755 <entry>g<subscript>5</subscript></entry>
756 <entry>g<subscript>4</subscript></entry>
757 <entry></entry>
758 <entry>g<subscript>3</subscript></entry>
759 <entry>g<subscript>2</subscript></entry>
760 <entry>g<subscript>1</subscript></entry>
761 <entry>g<subscript>0</subscript></entry>
762 <entry>r<subscript>5</subscript></entry>
763 <entry>r<subscript>4</subscript></entry>
764 <entry>r<subscript>3</subscript></entry>
765 <entry>r<subscript>2</subscript></entry>
766 <entry></entry>
767 <entry>r<subscript>1</subscript></entry>
768 <entry>r<subscript>0</subscript></entry>
769 <entry></entry>
770 <entry></entry>
771 <entry></entry>
772 <entry></entry>
773 <entry></entry>
774 <entry></entry>
775 <entry></entry>
776 <entry></entry>
777 <entry></entry>
778 <entry></entry>
779 <entry></entry>
780 <entry></entry>
781 <entry></entry>
782 <entry></entry>
783 </row>
784 <row><!-- id="V4L2-PIX-FMT-BGR24" -->
785 <entry><constant>V4L2_PIX_FMT_BGR24</constant></entry>
786 <entry>'BGR3'</entry>
787 <entry></entry>
788 <entry>b<subscript>7</subscript></entry>
789 <entry>b<subscript>6</subscript></entry>
790 <entry>b<subscript>5</subscript></entry>
791 <entry>b<subscript>4</subscript></entry>
792 <entry>b<subscript>3</subscript></entry>
793 <entry>b<subscript>2</subscript></entry>
794 <entry>b<subscript>1</subscript></entry>
795 <entry>b<subscript>0</subscript></entry>
796 <entry></entry>
797 <entry>g<subscript>7</subscript></entry>
798 <entry>g<subscript>6</subscript></entry>
799 <entry>g<subscript>5</subscript></entry>
800 <entry>g<subscript>4</subscript></entry>
801 <entry>g<subscript>3</subscript></entry>
802 <entry>g<subscript>2</subscript></entry>
803 <entry>g<subscript>1</subscript></entry>
804 <entry>g<subscript>0</subscript></entry>
805 <entry></entry>
806 <entry>r<subscript>7</subscript></entry>
807 <entry>r<subscript>6</subscript></entry>
808 <entry>r<subscript>5</subscript></entry>
809 <entry>r<subscript>4</subscript></entry>
810 <entry>r<subscript>3</subscript></entry>
811 <entry>r<subscript>2</subscript></entry>
812 <entry>r<subscript>1</subscript></entry>
813 <entry>r<subscript>0</subscript></entry>
814 </row>
815 <row><!-- id="V4L2-PIX-FMT-RGB24" -->
816 <entry><constant>V4L2_PIX_FMT_RGB24</constant></entry>
817 <entry>'RGB3'</entry>
818 <entry></entry>
819 <entry>r<subscript>7</subscript></entry>
820 <entry>r<subscript>6</subscript></entry>
821 <entry>r<subscript>5</subscript></entry>
822 <entry>r<subscript>4</subscript></entry>
823 <entry>r<subscript>3</subscript></entry>
824 <entry>r<subscript>2</subscript></entry>
825 <entry>r<subscript>1</subscript></entry>
826 <entry>r<subscript>0</subscript></entry>
827 <entry></entry>
828 <entry>g<subscript>7</subscript></entry>
829 <entry>g<subscript>6</subscript></entry>
830 <entry>g<subscript>5</subscript></entry>
831 <entry>g<subscript>4</subscript></entry>
832 <entry>g<subscript>3</subscript></entry>
833 <entry>g<subscript>2</subscript></entry>
834 <entry>g<subscript>1</subscript></entry>
835 <entry>g<subscript>0</subscript></entry>
836 <entry></entry>
837 <entry>b<subscript>7</subscript></entry>
838 <entry>b<subscript>6</subscript></entry>
839 <entry>b<subscript>5</subscript></entry>
840 <entry>b<subscript>4</subscript></entry>
841 <entry>b<subscript>3</subscript></entry>
842 <entry>b<subscript>2</subscript></entry>
843 <entry>b<subscript>1</subscript></entry>
844 <entry>b<subscript>0</subscript></entry>
845 </row>
846 <row><!-- id="V4L2-PIX-FMT-BGR32" -->
847 <entry><constant>V4L2_PIX_FMT_BGR32</constant></entry>
848 <entry>'BGR4'</entry>
849 <entry></entry>
850 <entry>b<subscript>7</subscript></entry>
851 <entry>b<subscript>6</subscript></entry>
852 <entry>b<subscript>5</subscript></entry>
853 <entry>b<subscript>4</subscript></entry>
854 <entry>b<subscript>3</subscript></entry>
855 <entry>b<subscript>2</subscript></entry>
856 <entry>b<subscript>1</subscript></entry>
857 <entry>b<subscript>0</subscript></entry>
858 <entry></entry>
859 <entry>g<subscript>7</subscript></entry>
860 <entry>g<subscript>6</subscript></entry>
861 <entry>g<subscript>5</subscript></entry>
862 <entry>g<subscript>4</subscript></entry>
863 <entry>g<subscript>3</subscript></entry>
864 <entry>g<subscript>2</subscript></entry>
865 <entry>g<subscript>1</subscript></entry>
866 <entry>g<subscript>0</subscript></entry>
867 <entry></entry>
868 <entry>r<subscript>7</subscript></entry>
869 <entry>r<subscript>6</subscript></entry>
870 <entry>r<subscript>5</subscript></entry>
871 <entry>r<subscript>4</subscript></entry>
872 <entry>r<subscript>3</subscript></entry>
873 <entry>r<subscript>2</subscript></entry>
874 <entry>r<subscript>1</subscript></entry>
875 <entry>r<subscript>0</subscript></entry>
876 <entry></entry>
877 <entry>a<subscript>7</subscript></entry>
878 <entry>a<subscript>6</subscript></entry>
879 <entry>a<subscript>5</subscript></entry>
880 <entry>a<subscript>4</subscript></entry>
881 <entry>a<subscript>3</subscript></entry>
882 <entry>a<subscript>2</subscript></entry>
883 <entry>a<subscript>1</subscript></entry>
884 <entry>a<subscript>0</subscript></entry>
885 </row>
886 <row><!-- id="V4L2-PIX-FMT-RGB32" -->
887 <entry><constant>V4L2_PIX_FMT_RGB32</constant></entry>
888 <entry>'RGB4'</entry>
889 <entry></entry>
890 <entry>a<subscript>7</subscript></entry>
891 <entry>a<subscript>6</subscript></entry>
892 <entry>a<subscript>5</subscript></entry>
893 <entry>a<subscript>4</subscript></entry>
894 <entry>a<subscript>3</subscript></entry>
895 <entry>a<subscript>2</subscript></entry>
896 <entry>a<subscript>1</subscript></entry>
897 <entry>a<subscript>0</subscript></entry>
898 <entry></entry>
899 <entry>r<subscript>7</subscript></entry>
900 <entry>r<subscript>6</subscript></entry>
901 <entry>r<subscript>5</subscript></entry>
902 <entry>r<subscript>4</subscript></entry>
903 <entry>r<subscript>3</subscript></entry>
904 <entry>r<subscript>2</subscript></entry>
905 <entry>r<subscript>1</subscript></entry>
906 <entry>r<subscript>0</subscript></entry>
907 <entry></entry>
908 <entry>g<subscript>7</subscript></entry>
909 <entry>g<subscript>6</subscript></entry>
910 <entry>g<subscript>5</subscript></entry>
911 <entry>g<subscript>4</subscript></entry>
912 <entry>g<subscript>3</subscript></entry>
913 <entry>g<subscript>2</subscript></entry>
914 <entry>g<subscript>1</subscript></entry>
915 <entry>g<subscript>0</subscript></entry>
916 <entry></entry>
917 <entry>b<subscript>7</subscript></entry>
918 <entry>b<subscript>6</subscript></entry>
919 <entry>b<subscript>5</subscript></entry>
920 <entry>b<subscript>4</subscript></entry>
921 <entry>b<subscript>3</subscript></entry>
922 <entry>b<subscript>2</subscript></entry>
923 <entry>b<subscript>1</subscript></entry>
924 <entry>b<subscript>0</subscript></entry>
925 </row>
926 </tbody>
927 </tgroup>
928 </table>
929
930 <para>A test utility to determine which RGB formats a driver 515 <para>A test utility to determine which RGB formats a driver
931actually supports is available from the LinuxTV v4l-dvb repository. 516actually supports is available from the LinuxTV v4l-dvb repository.
932See &v4l-dvb; for access instructions.</para> 517See &v4l-dvb; for access instructions.</para>
diff --git a/Documentation/DocBook/media/v4l/pixfmt-sdr-cu08.xml b/Documentation/DocBook/media/v4l/pixfmt-sdr-cu08.xml
new file mode 100644
index 000000000000..2d80104c178b
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/pixfmt-sdr-cu08.xml
@@ -0,0 +1,44 @@
1<refentry id="V4L2-SDR-FMT-CU08">
2 <refmeta>
3 <refentrytitle>V4L2_SDR_FMT_CU8 ('CU08')</refentrytitle>
4 &manvol;
5 </refmeta>
6 <refnamediv>
7 <refname>
8 <constant>V4L2_SDR_FMT_CU8</constant>
9 </refname>
10 <refpurpose>Complex unsigned 8-bit IQ sample</refpurpose>
11 </refnamediv>
12 <refsect1>
13 <title>Description</title>
14 <para>
15This format contains sequence of complex number samples. Each complex number
16consist two parts, called In-phase and Quadrature (IQ). Both I and Q are
17represented as a 8 bit unsigned number. I value comes first and Q value after
18that.
19 </para>
20 <example>
21 <title><constant>V4L2_SDR_FMT_CU8</constant> 1 sample</title>
22 <formalpara>
23 <title>Byte Order.</title>
24 <para>Each cell is one byte.
25 <informaltable frame="none">
26 <tgroup cols="2" align="center">
27 <colspec align="left" colwidth="2*" />
28 <tbody valign="top">
29 <row>
30 <entry>start&nbsp;+&nbsp;0:</entry>
31 <entry>I'<subscript>0</subscript></entry>
32 </row>
33 <row>
34 <entry>start&nbsp;+&nbsp;1:</entry>
35 <entry>Q'<subscript>0</subscript></entry>
36 </row>
37 </tbody>
38 </tgroup>
39 </informaltable>
40 </para>
41 </formalpara>
42 </example>
43 </refsect1>
44</refentry>
diff --git a/Documentation/DocBook/media/v4l/pixfmt-sdr-cu16le.xml b/Documentation/DocBook/media/v4l/pixfmt-sdr-cu16le.xml
new file mode 100644
index 000000000000..26288ffa9071
--- /dev/null
+++ b/Documentation/DocBook/media/v4l/pixfmt-sdr-cu16le.xml
@@ -0,0 +1,46 @@
1<refentry id="V4L2-SDR-FMT-CU16LE">
2 <refmeta>
3 <refentrytitle>V4L2_SDR_FMT_CU16LE ('CU16')</refentrytitle>
4 &manvol;
5 </refmeta>
6 <refnamediv>
7 <refname>
8 <constant>V4L2_SDR_FMT_CU16LE</constant>
9 </refname>
10 <refpurpose>Complex unsigned 16-bit little endian IQ sample</refpurpose>
11 </refnamediv>
12 <refsect1>
13 <title>Description</title>
14 <para>
15This format contains sequence of complex number samples. Each complex number
16consist two parts, called In-phase and Quadrature (IQ). Both I and Q are
17represented as a 16 bit unsigned little endian number. I value comes first
18and Q value after that.
19 </para>
20 <example>
21 <title><constant>V4L2_SDR_FMT_CU16LE</constant> 1 sample</title>
22 <formalpara>
23 <title>Byte Order.</title>
24 <para>Each cell is one byte.
25 <informaltable frame="none">
26 <tgroup cols="3" align="center">
27 <colspec align="left" colwidth="2*" />
28 <tbody valign="top">
29 <row>
30 <entry>start&nbsp;+&nbsp;0:</entry>
31 <entry>I'<subscript>0[7:0]</subscript></entry>
32 <entry>I'<subscript>0[15:8]</subscript></entry>
33 </row>
34 <row>
35 <entry>start&nbsp;+&nbsp;2:</entry>
36 <entry>Q'<subscript>0[7:0]</subscript></entry>
37 <entry>Q'<subscript>0[15:8]</subscript></entry>
38 </row>
39 </tbody>
40 </tgroup>
41 </informaltable>
42 </para>
43 </formalpara>
44 </example>
45 </refsect1>
46</refentry>
diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml b/Documentation/DocBook/media/v4l/pixfmt.xml
index 72d72bd67d0a..ea514d6075c5 100644
--- a/Documentation/DocBook/media/v4l/pixfmt.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt.xml
@@ -25,7 +25,12 @@ capturing and output, for overlay frame buffer formats see also
25 <row> 25 <row>
26 <entry>__u32</entry> 26 <entry>__u32</entry>
27 <entry><structfield>height</structfield></entry> 27 <entry><structfield>height</structfield></entry>
28 <entry>Image height in pixels.</entry> 28 <entry>Image height in pixels. If <structfield>field</structfield> is
29 one of <constant>V4L2_FIELD_TOP</constant>, <constant>V4L2_FIELD_BOTTOM</constant>
30 or <constant>V4L2_FIELD_ALTERNATE</constant> then height refers to the
31 number of lines in the field, otherwise it refers to the number of
32 lines in the frame (which is twice the field height for interlaced
33 formats).</entry>
29 </row> 34 </row>
30 <row> 35 <row>
31 <entry spanname="hspan">Applications set these fields to 36 <entry spanname="hspan">Applications set these fields to
@@ -54,7 +59,7 @@ linkend="reserved-formats" /></entry>
54can request to capture or output only the top or bottom field, or both 59can request to capture or output only the top or bottom field, or both
55fields interlaced or sequentially stored in one buffer or alternating 60fields interlaced or sequentially stored in one buffer or alternating
56in separate buffers. Drivers return the actual field order selected. 61in separate buffers. Drivers return the actual field order selected.
57For details see <xref linkend="field-order" />.</entry> 62For more details on fields see <xref linkend="field-order" />.</entry>
58 </row> 63 </row>
59 <row> 64 <row>
60 <entry>__u32</entry> 65 <entry>__u32</entry>
@@ -81,7 +86,10 @@ plane and is divided by the same factor as the
81example the Cb and Cr planes of a YUV 4:2:0 image have half as many 86example the Cb and Cr planes of a YUV 4:2:0 image have half as many
82padding bytes following each line as the Y plane. To avoid ambiguities 87padding bytes following each line as the Y plane. To avoid ambiguities
83drivers must return a <structfield>bytesperline</structfield> value 88drivers must return a <structfield>bytesperline</structfield> value
84rounded up to a multiple of the scale factor.</para></entry> 89rounded up to a multiple of the scale factor.</para>
90<para>For compressed formats the <structfield>bytesperline</structfield>
91value makes no sense. Applications and drivers must set this to 0 in
92that case.</para></entry>
85 </row> 93 </row>
86 <row> 94 <row>
87 <entry>__u32</entry> 95 <entry>__u32</entry>
@@ -97,7 +105,8 @@ hold an image.</entry>
97 <entry>&v4l2-colorspace;</entry> 105 <entry>&v4l2-colorspace;</entry>
98 <entry><structfield>colorspace</structfield></entry> 106 <entry><structfield>colorspace</structfield></entry>
99 <entry>This information supplements the 107 <entry>This information supplements the
100<structfield>pixelformat</structfield> and must be set by the driver, 108<structfield>pixelformat</structfield> and must be set by the driver for
109capture streams and by the application for output streams,
101see <xref linkend="colorspaces" />.</entry> 110see <xref linkend="colorspaces" />.</entry>
102 </row> 111 </row>
103 <row> 112 <row>
@@ -135,7 +144,7 @@ set this field to zero.</entry>
135 <entry>__u16</entry> 144 <entry>__u16</entry>
136 <entry><structfield>bytesperline</structfield></entry> 145 <entry><structfield>bytesperline</structfield></entry>
137 <entry>Distance in bytes between the leftmost pixels in two adjacent 146 <entry>Distance in bytes between the leftmost pixels in two adjacent
138 lines.</entry> 147 lines. See &v4l2-pix-format;.</entry>
139 </row> 148 </row>
140 <row> 149 <row>
141 <entry>__u16</entry> 150 <entry>__u16</entry>
@@ -154,12 +163,12 @@ set this field to zero.</entry>
154 <row> 163 <row>
155 <entry>__u32</entry> 164 <entry>__u32</entry>
156 <entry><structfield>width</structfield></entry> 165 <entry><structfield>width</structfield></entry>
157 <entry>Image width in pixels.</entry> 166 <entry>Image width in pixels. See &v4l2-pix-format;.</entry>
158 </row> 167 </row>
159 <row> 168 <row>
160 <entry>__u32</entry> 169 <entry>__u32</entry>
161 <entry><structfield>height</structfield></entry> 170 <entry><structfield>height</structfield></entry>
162 <entry>Image height in pixels.</entry> 171 <entry>Image height in pixels. See &v4l2-pix-format;.</entry>
163 </row> 172 </row>
164 <row> 173 <row>
165 <entry>__u32</entry> 174 <entry>__u32</entry>
@@ -811,6 +820,17 @@ extended control <constant>V4L2_CID_MPEG_STREAM_TYPE</constant>, see
811 </table> 820 </table>
812 </section> 821 </section>
813 822
823 <section id="sdr-formats">
824 <title>SDR Formats</title>
825
826 <para>These formats are used for <link linkend="sdr">SDR Capture</link>
827interface only.</para>
828
829 &sub-sdr-cu08;
830 &sub-sdr-cu16le;
831
832 </section>
833
814 <section id="pixfmt-reserved"> 834 <section id="pixfmt-reserved">
815 <title>Reserved Format Identifiers</title> 835 <title>Reserved Format Identifiers</title>
816 836
diff --git a/Documentation/DocBook/media/v4l/remote_controllers.xml b/Documentation/DocBook/media/v4l/remote_controllers.xml
index 160e464d44b7..5124a6c4daa8 100644
--- a/Documentation/DocBook/media/v4l/remote_controllers.xml
+++ b/Documentation/DocBook/media/v4l/remote_controllers.xml
@@ -1,10 +1,152 @@
1<partinfo>
2<authorgroup>
3<author>
4<firstname>Mauro</firstname>
5<surname>Chehab</surname>
6<othername role="mi">Carvalho</othername>
7<affiliation><address><email>m.chehab@samsung.com</email></address></affiliation>
8<contrib>Initial version.</contrib>
9</author>
10</authorgroup>
11<copyright>
12 <year>2009-2014</year>
13 <holder>Mauro Carvalho Chehab</holder>
14</copyright>
15
16<revhistory>
17<!-- Put document revisions here, newest first. -->
18<revision>
19<revnumber>3.15</revnumber>
20<date>2014-02-06</date>
21<authorinitials>mcc</authorinitials>
22<revremark>Added the interface description and the RC sysfs class description.</revremark>
23</revision>
24<revision>
25<revnumber>1.0</revnumber>
26<date>2009-09-06</date>
27<authorinitials>mcc</authorinitials>
28<revremark>Initial revision</revremark>
29</revision>
30</revhistory>
31</partinfo>
32
33 <title>Remote Controller API</title>
34 <chapter id="remote_controllers">
35
1<title>Remote Controllers</title> 36<title>Remote Controllers</title>
37
2<section id="Remote_controllers_Intro"> 38<section id="Remote_controllers_Intro">
3<title>Introduction</title> 39<title>Introduction</title>
4 40
5<para>Currently, most analog and digital devices have a Infrared input for remote controllers. Each 41<para>Currently, most analog and digital devices have a Infrared input for remote controllers. Each
6manufacturer has their own type of control. It is not rare for the same manufacturer to ship different 42manufacturer has their own type of control. It is not rare for the same manufacturer to ship different
7types of controls, depending on the device.</para> 43types of controls, depending on the device.</para>
44<para>A Remote Controller interface is mapped as a normal evdev/input interface, just like a keyboard or a mouse.
45So, it uses all ioctls already defined for any other input devices.</para>
46<para>However, remove controllers are more flexible than a normal input device, as the IR
47receiver (and/or transmitter) can be used in conjunction with a wide variety of different IR remotes.</para>
48<para>In order to allow flexibility, the Remote Controller subsystem allows controlling the
49RC-specific attributes via <link linkend="remote_controllers_sysfs_nodes">the sysfs class nodes</link>.</para>
50</section>
51
52<section id="remote_controllers_sysfs_nodes">
53<title>Remote Controller's sysfs nodes</title>
54<para>As defined at <constant>Documentation/ABI/testing/sysfs-class-rc</constant>, those are the sysfs nodes that control the Remote Controllers:</para>
55
56<section id="sys_class_rc">
57<title>/sys/class/rc/</title>
58<para>The <constant>/sys/class/rc/</constant> class sub-directory belongs to the Remote Controller
59core and provides a sysfs interface for configuring infrared remote controller receivers.
60</para>
61
62</section>
63<section id="sys_class_rc_rcN">
64<title>/sys/class/rc/rcN/</title>
65<para>A <constant>/sys/class/rc/rcN</constant> directory is created for each remote
66 control receiver device where N is the number of the receiver.</para>
67
68</section>
69<section id="sys_class_rc_rcN_protocols">
70<title>/sys/class/rc/rcN/protocols</title>
71<para>Reading this file returns a list of available protocols, something like:</para>
72<para><constant>rc5 [rc6] nec jvc [sony]</constant></para>
73<para>Enabled protocols are shown in [] brackets.</para>
74<para>Writing "+proto" will add a protocol to the list of enabled protocols.</para>
75<para>Writing "-proto" will remove a protocol from the list of enabled protocols.</para>
76<para>Writing "proto" will enable only "proto".</para>
77<para>Writing "none" will disable all protocols.</para>
78<para>Write fails with EINVAL if an invalid protocol combination or unknown protocol name is used.</para>
79
80</section>
81<section id="sys_class_rc_rcN_filter">
82<title>/sys/class/rc/rcN/filter</title>
83<para>Sets the scancode filter expected value.</para>
84<para>Use in combination with <constant>/sys/class/rc/rcN/filter_mask</constant> to set the
85expected value of the bits set in the filter mask.
86If the hardware supports it then scancodes which do not match
87the filter will be ignored. Otherwise the write will fail with
88an error.</para>
89<para>This value may be reset to 0 if the current protocol is altered.</para>
90
91</section>
92<section id="sys_class_rc_rcN_filter_mask">
93<title>/sys/class/rc/rcN/filter_mask</title>
94<para>Sets the scancode filter mask of bits to compare.
95Use in combination with <constant>/sys/class/rc/rcN/filter</constant> to set the bits
96of the scancode which should be compared against the expected
97value. A value of 0 disables the filter to allow all valid
98scancodes to be processed.</para>
99<para>If the hardware supports it then scancodes which do not match
100the filter will be ignored. Otherwise the write will fail with
101an error.</para>
102<para>This value may be reset to 0 if the current protocol is altered.</para>
103
104</section>
105<section id="sys_class_rc_rcN_wakeup_protocols">
106<title>/sys/class/rc/rcN/wakeup_protocols</title>
107<para>Reading this file returns a list of available protocols to use for the
108wakeup filter, something like:</para>
109<para><constant>rc5 rc6 nec jvc [sony]</constant></para>
110<para>The enabled wakeup protocol is shown in [] brackets.</para>
111<para>Writing "+proto" will add a protocol to the list of enabled wakeup
112protocols.</para>
113<para>Writing "-proto" will remove a protocol from the list of enabled wakeup
114protocols.</para>
115<para>Writing "proto" will use "proto" for wakeup events.</para>
116<para>Writing "none" will disable wakeup.</para>
117<para>Write fails with EINVAL if an invalid protocol combination or unknown
118protocol name is used, or if wakeup is not supported by the hardware.</para>
119
120</section>
121<section id="sys_class_rc_rcN_wakeup_filter">
122<title>/sys/class/rc/rcN/wakeup_filter</title>
123<para>Sets the scancode wakeup filter expected value.
124Use in combination with <constant>/sys/class/rc/rcN/wakeup_filter_mask</constant> to
125set the expected value of the bits set in the wakeup filter mask
126to trigger a system wake event.</para>
127<para>If the hardware supports it and wakeup_filter_mask is not 0 then
128scancodes which match the filter will wake the system from e.g.
129suspend to RAM or power off.
130Otherwise the write will fail with an error.</para>
131<para>This value may be reset to 0 if the wakeup protocol is altered.</para>
132
133</section>
134<section id="sys_class_rc_rcN_wakeup_filter_mask">
135<title>/sys/class/rc/rcN/wakeup_filter_mask</title>
136<para>Sets the scancode wakeup filter mask of bits to compare.
137Use in combination with <constant>/sys/class/rc/rcN/wakeup_filter</constant> to set
138the bits of the scancode which should be compared against the
139expected value to trigger a system wake event.</para>
140<para>If the hardware supports it and wakeup_filter_mask is not 0 then
141scancodes which match the filter will wake the system from e.g.
142suspend to RAM or power off.
143Otherwise the write will fail with an error.</para>
144<para>This value may be reset to 0 if the wakeup protocol is altered.</para>
145</section>
146</section>
147
148<section id="Remote_controllers_tables">
149<title>Remote controller tables</title>
8<para>Unfortunately, for several years, there was no effort to create uniform IR keycodes for 150<para>Unfortunately, for several years, there was no effort to create uniform IR keycodes for
9different devices. This caused the same IR keyname to be mapped completely differently on 151different devices. This caused the same IR keyname to be mapped completely differently on
10different IR devices. This resulted that the same IR keyname to be mapped completely different on 152different IR devices. This resulted that the same IR keyname to be mapped completely different on
@@ -175,3 +317,4 @@ keymapping.</para>
175</section> 317</section>
176 318
177&sub-lirc_device_interface; 319&sub-lirc_device_interface;
320</chapter>
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml
index 74b7f27af71a..b445161b912c 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -70,7 +70,7 @@ MPEG stream embedded, sliced VBI data format in this specification.
70Remote Controller chapter.</contrib> 70Remote Controller chapter.</contrib>
71 <affiliation> 71 <affiliation>
72 <address> 72 <address>
73 <email>mchehab@redhat.com</email> 73 <email>m.chehab@samsung.com</email>
74 </address> 74 </address>
75 </affiliation> 75 </affiliation>
76 </author> 76 </author>
@@ -107,6 +107,16 @@ Remote Controller chapter.</contrib>
107 </address> 107 </address>
108 </affiliation> 108 </affiliation>
109 </author> 109 </author>
110 <author>
111 <firstname>Antti</firstname>
112 <surname>Palosaari</surname>
113 <contrib>SDR API.</contrib>
114 <affiliation>
115 <address>
116 <email>crope@iki.fi</email>
117 </address>
118 </affiliation>
119 </author>
110 </authorgroup> 120 </authorgroup>
111 121
112 <copyright> 122 <copyright>
@@ -125,6 +135,7 @@ Remote Controller chapter.</contrib>
125 <year>2011</year> 135 <year>2011</year>
126 <year>2012</year> 136 <year>2012</year>
127 <year>2013</year> 137 <year>2013</year>
138 <year>2014</year>
128 <holder>Bill Dirks, Michael H. Schimek, Hans Verkuil, Martin 139 <holder>Bill Dirks, Michael H. Schimek, Hans Verkuil, Martin
129Rubli, Andy Walls, Muralidharan Karicheri, Mauro Carvalho Chehab, 140Rubli, Andy Walls, Muralidharan Karicheri, Mauro Carvalho Chehab,
130 Pawel Osciak</holder> 141 Pawel Osciak</holder>
@@ -141,6 +152,16 @@ structs, ioctls) must be noted in more detail in the history chapter
141applications. --> 152applications. -->
142 153
143 <revision> 154 <revision>
155 <revnumber>3.15</revnumber>
156 <date>2014-02-03</date>
157 <authorinitials>hv, ap</authorinitials>
158 <revremark>Update several sections of "Common API Elements": "Opening and Closing Devices"
159"Querying Capabilities", "Application Priority", "Video Inputs and Outputs", "Audio Inputs and Outputs"
160"Tuners and Modulators", "Video Standards" and "Digital Video (DV) Timings". Added SDR API.
161 </revremark>
162 </revision>
163
164 <revision>
144 <revnumber>3.14</revnumber> 165 <revnumber>3.14</revnumber>
145 <date>2013-11-25</date> 166 <date>2013-11-25</date>
146 <authorinitials>rr</authorinitials> 167 <authorinitials>rr</authorinitials>
@@ -537,6 +558,7 @@ and discussions on the V4L mailing list.</revremark>
537 <section id="ttx"> &sub-dev-teletext; </section> 558 <section id="ttx"> &sub-dev-teletext; </section>
538 <section id="radio"> &sub-dev-radio; </section> 559 <section id="radio"> &sub-dev-radio; </section>
539 <section id="rds"> &sub-dev-rds; </section> 560 <section id="rds"> &sub-dev-rds; </section>
561 <section id="sdr"> &sub-dev-sdr; </section>
540 <section id="event"> &sub-dev-event; </section> 562 <section id="event"> &sub-dev-event; </section>
541 <section id="subdev"> &sub-dev-subdev; </section> 563 <section id="subdev"> &sub-dev-subdev; </section>
542 </chapter> 564 </chapter>
@@ -585,6 +607,7 @@ and discussions on the V4L mailing list.</revremark>
585 &sub-g-crop; 607 &sub-g-crop;
586 &sub-g-ctrl; 608 &sub-g-ctrl;
587 &sub-g-dv-timings; 609 &sub-g-dv-timings;
610 &sub-g-edid;
588 &sub-g-enc-index; 611 &sub-g-enc-index;
589 &sub-g-ext-ctrls; 612 &sub-g-ext-ctrls;
590 &sub-g-fbuf; 613 &sub-g-fbuf;
@@ -616,7 +639,6 @@ and discussions on the V4L mailing list.</revremark>
616 &sub-subdev-enum-frame-size; 639 &sub-subdev-enum-frame-size;
617 &sub-subdev-enum-mbus-code; 640 &sub-subdev-enum-mbus-code;
618 &sub-subdev-g-crop; 641 &sub-subdev-g-crop;
619 &sub-subdev-g-edid;
620 &sub-subdev-g-fmt; 642 &sub-subdev-g-fmt;
621 &sub-subdev-g-frame-interval; 643 &sub-subdev-g-frame-interval;
622 &sub-subdev-g-selection; 644 &sub-subdev-g-selection;
diff --git a/Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml b/Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml
index 6541ba0175ed..4e8ea65f7282 100644
--- a/Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-enum-freq-bands.xml
@@ -100,7 +100,7 @@ See <xref linkend="v4l2-tuner-type" /></entry>
100 <entry><structfield>capability</structfield></entry> 100 <entry><structfield>capability</structfield></entry>
101 <entry spanname="hspan">The tuner/modulator capability flags for 101 <entry spanname="hspan">The tuner/modulator capability flags for
102this frequency band, see <xref linkend="tuner-capability" />. The <constant>V4L2_TUNER_CAP_LOW</constant> 102this frequency band, see <xref linkend="tuner-capability" />. The <constant>V4L2_TUNER_CAP_LOW</constant>
103capability must be the same for all frequency bands of the selected tuner/modulator. 103or <constant>V4L2_TUNER_CAP_1HZ</constant> capability must be the same for all frequency bands of the selected tuner/modulator.
104So either all bands have that capability set, or none of them have that capability.</entry> 104So either all bands have that capability set, or none of them have that capability.</entry>
105 </row> 105 </row>
106 <row> 106 <row>
@@ -109,7 +109,8 @@ So either all bands have that capability set, or none of them have that capabili
109 <entry spanname="hspan">The lowest tunable frequency in 109 <entry spanname="hspan">The lowest tunable frequency in
110units of 62.5 kHz, or if the <structfield>capability</structfield> 110units of 62.5 kHz, or if the <structfield>capability</structfield>
111flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 111flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
112Hz, for this frequency band.</entry> 112Hz, for this frequency band. A 1 Hz unit is used when the <structfield>capability</structfield> flag
113<constant>V4L2_TUNER_CAP_1HZ</constant> is set.</entry>
113 </row> 114 </row>
114 <row> 115 <row>
115 <entry>__u32</entry> 116 <entry>__u32</entry>
@@ -117,7 +118,8 @@ Hz, for this frequency band.</entry>
117 <entry spanname="hspan">The highest tunable frequency in 118 <entry spanname="hspan">The highest tunable frequency in
118units of 62.5 kHz, or if the <structfield>capability</structfield> 119units of 62.5 kHz, or if the <structfield>capability</structfield>
119flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 120flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
120Hz, for this frequency band.</entry> 121Hz, for this frequency band. A 1 Hz unit is used when the <structfield>capability</structfield> flag
122<constant>V4L2_TUNER_CAP_1HZ</constant> is set.</entry>
121 </row> 123 </row>
122 <row> 124 <row>
123 <entry>__u32</entry> 125 <entry>__u32</entry>
diff --git a/Documentation/DocBook/media/v4l/vidioc-subdev-g-edid.xml b/Documentation/DocBook/media/v4l/vidioc-g-edid.xml
index bbd18f0e6ede..ce4563b87131 100644
--- a/Documentation/DocBook/media/v4l/vidioc-subdev-g-edid.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-edid.xml
@@ -1,12 +1,12 @@
1<refentry id="vidioc-subdev-g-edid"> 1<refentry id="vidioc-g-edid">
2 <refmeta> 2 <refmeta>
3 <refentrytitle>ioctl VIDIOC_SUBDEV_G_EDID, VIDIOC_SUBDEV_S_EDID</refentrytitle> 3 <refentrytitle>ioctl VIDIOC_G_EDID, VIDIOC_S_EDID</refentrytitle>
4 &manvol; 4 &manvol;
5 </refmeta> 5 </refmeta>
6 6
7 <refnamediv> 7 <refnamediv>
8 <refname>VIDIOC_SUBDEV_G_EDID</refname> 8 <refname>VIDIOC_G_EDID</refname>
9 <refname>VIDIOC_SUBDEV_S_EDID</refname> 9 <refname>VIDIOC_S_EDID</refname>
10 <refpurpose>Get or set the EDID of a video receiver/transmitter</refpurpose> 10 <refpurpose>Get or set the EDID of a video receiver/transmitter</refpurpose>
11 </refnamediv> 11 </refnamediv>
12 12
@@ -16,7 +16,7 @@
16 <funcdef>int <function>ioctl</function></funcdef> 16 <funcdef>int <function>ioctl</function></funcdef>
17 <paramdef>int <parameter>fd</parameter></paramdef> 17 <paramdef>int <parameter>fd</parameter></paramdef>
18 <paramdef>int <parameter>request</parameter></paramdef> 18 <paramdef>int <parameter>request</parameter></paramdef>
19 <paramdef>struct v4l2_subdev_edid *<parameter>argp</parameter></paramdef> 19 <paramdef>struct v4l2_edid *<parameter>argp</parameter></paramdef>
20 </funcprototype> 20 </funcprototype>
21 </funcsynopsis> 21 </funcsynopsis>
22 <funcsynopsis> 22 <funcsynopsis>
@@ -24,7 +24,7 @@
24 <funcdef>int <function>ioctl</function></funcdef> 24 <funcdef>int <function>ioctl</function></funcdef>
25 <paramdef>int <parameter>fd</parameter></paramdef> 25 <paramdef>int <parameter>fd</parameter></paramdef>
26 <paramdef>int <parameter>request</parameter></paramdef> 26 <paramdef>int <parameter>request</parameter></paramdef>
27 <paramdef>const struct v4l2_subdev_edid *<parameter>argp</parameter></paramdef> 27 <paramdef>const struct v4l2_edid *<parameter>argp</parameter></paramdef>
28 </funcprototype> 28 </funcprototype>
29 </funcsynopsis> 29 </funcsynopsis>
30 </refsynopsisdiv> 30 </refsynopsisdiv>
@@ -42,7 +42,7 @@
42 <varlistentry> 42 <varlistentry>
43 <term><parameter>request</parameter></term> 43 <term><parameter>request</parameter></term>
44 <listitem> 44 <listitem>
45 <para>VIDIOC_SUBDEV_G_EDID, VIDIOC_SUBDEV_S_EDID</para> 45 <para>VIDIOC_G_EDID, VIDIOC_S_EDID</para>
46 </listitem> 46 </listitem>
47 </varlistentry> 47 </varlistentry>
48 <varlistentry> 48 <varlistentry>
@@ -56,12 +56,20 @@
56 56
57 <refsect1> 57 <refsect1>
58 <title>Description</title> 58 <title>Description</title>
59 <para>These ioctls can be used to get or set an EDID associated with an input pad 59 <para>These ioctls can be used to get or set an EDID associated with an input
60 from a receiver or an output pad of a transmitter subdevice.</para> 60 from a receiver or an output of a transmitter device. They can be
61 used with subdevice nodes (/dev/v4l-subdevX) or with video nodes (/dev/videoX).</para>
62
63 <para>When used with video nodes the <structfield>pad</structfield> field represents the
64 input (for video capture devices) or output (for video output devices) index as
65 is returned by &VIDIOC-ENUMINPUT; and &VIDIOC-ENUMOUTPUT; respectively. When used
66 with subdevice nodes the <structfield>pad</structfield> field represents the
67 input or output pad of the subdevice. If there is no EDID support for the given
68 <structfield>pad</structfield> value, then the &EINVAL; will be returned.</para>
61 69
62 <para>To get the EDID data the application has to fill in the <structfield>pad</structfield>, 70 <para>To get the EDID data the application has to fill in the <structfield>pad</structfield>,
63 <structfield>start_block</structfield>, <structfield>blocks</structfield> and <structfield>edid</structfield> 71 <structfield>start_block</structfield>, <structfield>blocks</structfield> and <structfield>edid</structfield>
64 fields and call <constant>VIDIOC_SUBDEV_G_EDID</constant>. The current EDID from block 72 fields and call <constant>VIDIOC_G_EDID</constant>. The current EDID from block
65 <structfield>start_block</structfield> and of size <structfield>blocks</structfield> 73 <structfield>start_block</structfield> and of size <structfield>blocks</structfield>
66 will be placed in the memory <structfield>edid</structfield> points to. The <structfield>edid</structfield> 74 will be placed in the memory <structfield>edid</structfield> points to. The <structfield>edid</structfield>
67 pointer must point to memory at least <structfield>blocks</structfield>&nbsp;*&nbsp;128 bytes 75 pointer must point to memory at least <structfield>blocks</structfield>&nbsp;*&nbsp;128 bytes
@@ -91,15 +99,17 @@
91 data in some way. In any case, the end result is the same: the EDID is no longer available. 99 data in some way. In any case, the end result is the same: the EDID is no longer available.
92 </para> 100 </para>
93 101
94 <table pgwide="1" frame="none" id="v4l2-subdev-edid"> 102 <table pgwide="1" frame="none" id="v4l2-edid">
95 <title>struct <structname>v4l2_subdev_edid</structname></title> 103 <title>struct <structname>v4l2_edid</structname></title>
96 <tgroup cols="3"> 104 <tgroup cols="3">
97 &cs-str; 105 &cs-str;
98 <tbody valign="top"> 106 <tbody valign="top">
99 <row> 107 <row>
100 <entry>__u32</entry> 108 <entry>__u32</entry>
101 <entry><structfield>pad</structfield></entry> 109 <entry><structfield>pad</structfield></entry>
102 <entry>Pad for which to get/set the EDID blocks.</entry> 110 <entry>Pad for which to get/set the EDID blocks. When used with a video device
111 node the pad represents the input or output index as returned by
112 &VIDIOC-ENUMINPUT; and &VIDIOC-ENUMOUTPUT; respectively.</entry>
103 </row> 113 </row>
104 <row> 114 <row>
105 <entry>__u32</entry> 115 <entry>__u32</entry>
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
index b3bb9575b2e0..e9f6735c0823 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml
@@ -327,7 +327,12 @@ These controls are described in <xref
327These controls are described in <xref 327These controls are described in <xref
328 linkend="fm-rx-controls" />.</entry> 328 linkend="fm-rx-controls" />.</entry>
329 </row> 329 </row>
330 330 <row>
331 <entry><constant>V4L2_CTRL_CLASS_RF_TUNER</constant></entry>
332 <entry>0xa20000</entry>
333 <entry>The class containing RF tuner controls.
334These controls are described in <xref linkend="rf-tuner-controls" />.</entry>
335 </row>
331 </tbody> 336 </tbody>
332 </tgroup> 337 </tgroup>
333 </table> 338 </table>
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml b/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
index ee8f56e1bac0..4fe19a7a9a31 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-fmt.xml
@@ -172,6 +172,13 @@ capture and output devices.</entry>
172 </row> 172 </row>
173 <row> 173 <row>
174 <entry></entry> 174 <entry></entry>
175 <entry>&v4l2-sdr-format;</entry>
176 <entry><structfield>sdr</structfield></entry>
177 <entry>Definition of a data format, see
178<xref linkend="pixfmt" />, used by SDR capture devices.</entry>
179 </row>
180 <row>
181 <entry></entry>
175 <entry>__u8</entry> 182 <entry>__u8</entry>
176 <entry><structfield>raw_data</structfield>[200]</entry> 183 <entry><structfield>raw_data</structfield>[200]</entry>
177 <entry>Place holder for future extensions.</entry> 184 <entry>Place holder for future extensions.</entry>
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-frequency.xml b/Documentation/DocBook/media/v4l/vidioc-g-frequency.xml
index c7a1c462e724..d1034fb61d15 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-frequency.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-frequency.xml
@@ -109,9 +109,10 @@ See <xref linkend="v4l2-tuner-type" /></entry>
109 <entry>__u32</entry> 109 <entry>__u32</entry>
110 <entry><structfield>frequency</structfield></entry> 110 <entry><structfield>frequency</structfield></entry>
111 <entry>Tuning frequency in units of 62.5 kHz, or if the 111 <entry>Tuning frequency in units of 62.5 kHz, or if the
112&v4l2-tuner; or &v4l2-modulator; <structfield>capabilities</structfield> flag 112&v4l2-tuner; or &v4l2-modulator; <structfield>capability</structfield> flag
113<constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 113<constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
114Hz.</entry> 114Hz. A 1 Hz unit is used when the <structfield>capability</structfield> flag
115<constant>V4L2_TUNER_CAP_1HZ</constant> is set.</entry>
115 </row> 116 </row>
116 <row> 117 <row>
117 <entry>__u32</entry> 118 <entry>__u32</entry>
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-modulator.xml b/Documentation/DocBook/media/v4l/vidioc-g-modulator.xml
index 7f4ac7e41fa8..7068b599a00d 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-modulator.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-modulator.xml
@@ -113,7 +113,8 @@ change for example with the current video standard.</entry>
113 <entry>The lowest tunable frequency in units of 62.5 113 <entry>The lowest tunable frequency in units of 62.5
114KHz, or if the <structfield>capability</structfield> flag 114KHz, or if the <structfield>capability</structfield> flag
115<constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 115<constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
116Hz.</entry> 116Hz, or if the <structfield>capability</structfield> flag
117<constant>V4L2_TUNER_CAP_1HZ</constant> is set, in units of 1 Hz.</entry>
117 </row> 118 </row>
118 <row> 119 <row>
119 <entry>__u32</entry> 120 <entry>__u32</entry>
@@ -121,7 +122,8 @@ Hz.</entry>
121 <entry>The highest tunable frequency in units of 62.5 122 <entry>The highest tunable frequency in units of 62.5
122KHz, or if the <structfield>capability</structfield> flag 123KHz, or if the <structfield>capability</structfield> flag
123<constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 124<constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
124Hz.</entry> 125Hz, or if the <structfield>capability</structfield> flag
126<constant>V4L2_TUNER_CAP_1HZ</constant> is set, in units of 1 Hz.</entry>
125 </row> 127 </row>
126 <row> 128 <row>
127 <entry>__u32</entry> 129 <entry>__u32</entry>
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml b/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml
index 6cc82010c736..b0d865933da6 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml
@@ -134,7 +134,9 @@ the structure refers to a radio tuner the
134 <entry spanname="hspan">The lowest tunable frequency in 134 <entry spanname="hspan">The lowest tunable frequency in
135units of 62.5 kHz, or if the <structfield>capability</structfield> 135units of 62.5 kHz, or if the <structfield>capability</structfield>
136flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 136flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
137Hz. If multiple frequency bands are supported, then 137Hz, or if the <structfield>capability</structfield> flag
138<constant>V4L2_TUNER_CAP_1HZ</constant> is set, in units of 1 Hz.
139If multiple frequency bands are supported, then
138<structfield>rangelow</structfield> is the lowest frequency 140<structfield>rangelow</structfield> is the lowest frequency
139of all the frequency bands.</entry> 141of all the frequency bands.</entry>
140 </row> 142 </row>
@@ -144,7 +146,9 @@ of all the frequency bands.</entry>
144 <entry spanname="hspan">The highest tunable frequency in 146 <entry spanname="hspan">The highest tunable frequency in
145units of 62.5 kHz, or if the <structfield>capability</structfield> 147units of 62.5 kHz, or if the <structfield>capability</structfield>
146flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5 148flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
147Hz. If multiple frequency bands are supported, then 149Hz, or if the <structfield>capability</structfield> flag
150<constant>V4L2_TUNER_CAP_1HZ</constant> is set, in units of 1 Hz.
151If multiple frequency bands are supported, then
148<structfield>rangehigh</structfield> is the highest frequency 152<structfield>rangehigh</structfield> is the highest frequency
149of all the frequency bands.</entry> 153of all the frequency bands.</entry>
150 </row> 154 </row>
@@ -270,7 +274,7 @@ applications must set the array to zero.</entry>
270 <entry><constant>V4L2_TUNER_CAP_LOW</constant></entry> 274 <entry><constant>V4L2_TUNER_CAP_LOW</constant></entry>
271 <entry>0x0001</entry> 275 <entry>0x0001</entry>
272 <entry>When set, tuning frequencies are expressed in units of 276 <entry>When set, tuning frequencies are expressed in units of
27362.5&nbsp;Hz, otherwise in units of 62.5&nbsp;kHz.</entry> 27762.5 Hz instead of 62.5 kHz.</entry>
274 </row> 278 </row>
275 <row> 279 <row>
276 <entry><constant>V4L2_TUNER_CAP_NORM</constant></entry> 280 <entry><constant>V4L2_TUNER_CAP_NORM</constant></entry>
@@ -360,6 +364,11 @@ radio tuners.</entry>
360 <entry>The range to search when using the hardware seek functionality 364 <entry>The range to search when using the hardware seek functionality
361 is programmable, see &VIDIOC-S-HW-FREQ-SEEK; for details.</entry> 365 is programmable, see &VIDIOC-S-HW-FREQ-SEEK; for details.</entry>
362 </row> 366 </row>
367 <row>
368 <entry><constant>V4L2_TUNER_CAP_1HZ</constant></entry>
369 <entry>0x1000</entry>
370 <entry>When set, tuning frequencies are expressed in units of 1 Hz instead of 62.5 kHz.</entry>
371 </row>
363 </tbody> 372 </tbody>
364 </tgroup> 373 </tgroup>
365 </table> 374 </table>
diff --git a/Documentation/DocBook/media/v4l/vidioc-querycap.xml b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
index d5a3c97b206a..370d49d6fb64 100644
--- a/Documentation/DocBook/media/v4l/vidioc-querycap.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-querycap.xml
@@ -296,6 +296,12 @@ modulator programming see
296<xref linkend="tuner" />.</entry> 296<xref linkend="tuner" />.</entry>
297 </row> 297 </row>
298 <row> 298 <row>
299 <entry><constant>V4L2_CAP_SDR_CAPTURE</constant></entry>
300 <entry>0x00100000</entry>
301 <entry>The device supports the
302<link linkend="sdr">SDR Capture</link> interface.</entry>
303 </row>
304 <row>
299 <entry><constant>V4L2_CAP_READWRITE</constant></entry> 305 <entry><constant>V4L2_CAP_READWRITE</constant></entry>
300 <entry>0x01000000</entry> 306 <entry>0x01000000</entry>
301 <entry>The device supports the <link 307 <entry>The device supports the <link
diff --git a/Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml b/Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml
index 5b379e752194..a5fc4c4880f3 100644
--- a/Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml
@@ -121,7 +121,9 @@ field and the &v4l2-tuner; <structfield>index</structfield> field.</entry>
121 <entry>If non-zero, the lowest tunable frequency of the band to 121 <entry>If non-zero, the lowest tunable frequency of the band to
122search in units of 62.5 kHz, or if the &v4l2-tuner; 122search in units of 62.5 kHz, or if the &v4l2-tuner;
123<structfield>capability</structfield> field has the 123<structfield>capability</structfield> field has the
124<constant>V4L2_TUNER_CAP_LOW</constant> flag set, in units of 62.5 Hz. 124<constant>V4L2_TUNER_CAP_LOW</constant> flag set, in units of 62.5 Hz or if the &v4l2-tuner;
125<structfield>capability</structfield> field has the
126<constant>V4L2_TUNER_CAP_1HZ</constant> flag set, in units of 1 Hz.
125If <structfield>rangelow</structfield> is zero a reasonable default value 127If <structfield>rangelow</structfield> is zero a reasonable default value
126is used.</entry> 128is used.</entry>
127 </row> 129 </row>
@@ -131,7 +133,9 @@ is used.</entry>
131 <entry>If non-zero, the highest tunable frequency of the band to 133 <entry>If non-zero, the highest tunable frequency of the band to
132search in units of 62.5 kHz, or if the &v4l2-tuner; 134search in units of 62.5 kHz, or if the &v4l2-tuner;
133<structfield>capability</structfield> field has the 135<structfield>capability</structfield> field has the
134<constant>V4L2_TUNER_CAP_LOW</constant> flag set, in units of 62.5 Hz. 136<constant>V4L2_TUNER_CAP_LOW</constant> flag set, in units of 62.5 Hz or if the &v4l2-tuner;
137<structfield>capability</structfield> field has the
138<constant>V4L2_TUNER_CAP_1HZ</constant> flag set, in units of 1 Hz.
135If <structfield>rangehigh</structfield> is zero a reasonable default value 139If <structfield>rangehigh</structfield> is zero a reasonable default value
136is used.</entry> 140is used.</entry>
137 </row> 141 </row>
diff --git a/Documentation/DocBook/media/v4l/vidioc-streamon.xml b/Documentation/DocBook/media/v4l/vidioc-streamon.xml
index 65dff55079d7..df2c63d07bac 100644
--- a/Documentation/DocBook/media/v4l/vidioc-streamon.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-streamon.xml
@@ -52,16 +52,24 @@
52 <para>The <constant>VIDIOC_STREAMON</constant> and 52 <para>The <constant>VIDIOC_STREAMON</constant> and
53<constant>VIDIOC_STREAMOFF</constant> ioctl start and stop the capture 53<constant>VIDIOC_STREAMOFF</constant> ioctl start and stop the capture
54or output process during streaming (<link linkend="mmap">memory 54or output process during streaming (<link linkend="mmap">memory
55mapping</link> or <link linkend="userp">user pointer</link>) I/O.</para> 55mapping</link>, <link linkend="userp">user pointer</link> or
56<link linkend="dmabuf">DMABUF</link>) I/O.</para>
56 57
57 <para>Specifically the capture hardware is disabled and no input 58 <para>Capture hardware is disabled and no input
58buffers are filled (if there are any empty buffers in the incoming 59buffers are filled (if there are any empty buffers in the incoming
59queue) until <constant>VIDIOC_STREAMON</constant> has been called. 60queue) until <constant>VIDIOC_STREAMON</constant> has been called.
60Accordingly the output hardware is disabled, no video signal is 61Output hardware is disabled and no video signal is
61produced until <constant>VIDIOC_STREAMON</constant> has been called. 62produced until <constant>VIDIOC_STREAMON</constant> has been called.
62The ioctl will succeed when at least one output buffer is in the 63The ioctl will succeed when at least one output buffer is in the
63incoming queue.</para> 64incoming queue.</para>
64 65
66 <para>Memory-to-memory devices will not start until
67<constant>VIDIOC_STREAMON</constant> has been called for both the capture
68and output stream types.</para>
69
70 <para>If <constant>VIDIOC_STREAMON</constant> fails then any already
71queued buffers will remain queued.</para>
72
65 <para>The <constant>VIDIOC_STREAMOFF</constant> ioctl, apart of 73 <para>The <constant>VIDIOC_STREAMOFF</constant> ioctl, apart of
66aborting or finishing any DMA in progress, unlocks any user pointer 74aborting or finishing any DMA in progress, unlocks any user pointer
67buffers locked in physical memory, and it removes all buffers from the 75buffers locked in physical memory, and it removes all buffers from the
@@ -70,14 +78,22 @@ dequeued yet will be lost, likewise all images enqueued for output but
70not transmitted yet. I/O returns to the same state as after calling 78not transmitted yet. I/O returns to the same state as after calling
71&VIDIOC-REQBUFS; and can be restarted accordingly.</para> 79&VIDIOC-REQBUFS; and can be restarted accordingly.</para>
72 80
81 <para>If buffers have been queued with &VIDIOC-QBUF; and
82<constant>VIDIOC_STREAMOFF</constant> is called without ever having
83called <constant>VIDIOC_STREAMON</constant>, then those queued buffers
84will also be removed from the incoming queue and all are returned to the
85same state as after calling &VIDIOC-REQBUFS; and can be restarted
86accordingly.</para>
87
73 <para>Both ioctls take a pointer to an integer, the desired buffer or 88 <para>Both ioctls take a pointer to an integer, the desired buffer or
74stream type. This is the same as &v4l2-requestbuffers; 89stream type. This is the same as &v4l2-requestbuffers;
75<structfield>type</structfield>.</para> 90<structfield>type</structfield>.</para>
76 91
77 <para>If <constant>VIDIOC_STREAMON</constant> is called when streaming 92 <para>If <constant>VIDIOC_STREAMON</constant> is called when streaming
78is already in progress, or if <constant>VIDIOC_STREAMOFF</constant> is called 93is already in progress, or if <constant>VIDIOC_STREAMOFF</constant> is called
79when streaming is already stopped, then the ioctl does nothing and 0 is 94when streaming is already stopped, then 0 is returned. Nothing happens in the
80returned.</para> 95case of <constant>VIDIOC_STREAMON</constant>, but <constant>VIDIOC_STREAMOFF</constant>
96will return queued buffers to their starting state as mentioned above.</para>
81 97
82 <para>Note that applications can be preempted for unknown periods right 98 <para>Note that applications can be preempted for unknown periods right
83before or after the <constant>VIDIOC_STREAMON</constant> or 99before or after the <constant>VIDIOC_STREAMON</constant> or
@@ -93,7 +109,7 @@ synchronize with other events.</para>
93 <varlistentry> 109 <varlistentry>
94 <term><errorcode>EINVAL</errorcode></term> 110 <term><errorcode>EINVAL</errorcode></term>
95 <listitem> 111 <listitem>
96 <para>The buffer<structfield>type</structfield> is not supported, 112 <para>The buffer <structfield>type</structfield> is not supported,
97 or no buffers have been allocated (memory mapping) or enqueued 113 or no buffers have been allocated (memory mapping) or enqueued
98 (output) yet.</para> 114 (output) yet.</para>
99 </listitem> 115 </listitem>
diff --git a/Documentation/DocBook/media_api.tmpl b/Documentation/DocBook/media_api.tmpl
index ab56f89c8642..4decb46bfa76 100644
--- a/Documentation/DocBook/media_api.tmpl
+++ b/Documentation/DocBook/media_api.tmpl
@@ -34,22 +34,20 @@
34 34
35<book id="media_api"> 35<book id="media_api">
36<bookinfo> 36<bookinfo>
37<title>LINUX MEDIA INFRASTRUCTURE API</title> 37 <title>LINUX MEDIA INFRASTRUCTURE API</title>
38 38
39<copyright> 39 <copyright>
40 <year>2009-2012</year> 40 <year>2009-2014</year>
41 <holder>LinuxTV Developers</holder> 41 <holder>LinuxTV Developers</holder>
42</copyright> 42 </copyright>
43 43
44<legalnotice> 44 <legalnotice>
45 45 <para>Permission is granted to copy, distribute and/or modify
46<para>Permission is granted to copy, distribute and/or modify 46 this document under the terms of the GNU Free Documentation License,
47this document under the terms of the GNU Free Documentation License, 47 Version 1.1 or any later version published by the Free Software
48Version 1.1 or any later version published by the Free Software 48 Foundation. A copy of the license is included in the chapter entitled
49Foundation. A copy of the license is included in the chapter entitled 49 "GNU Free Documentation License"</para>
50"GNU Free Documentation License"</para> 50 </legalnotice>
51</legalnotice>
52
53</bookinfo> 51</bookinfo>
54 52
55<toc></toc> <!-- autogenerated --> 53<toc></toc> <!-- autogenerated -->
@@ -60,10 +58,11 @@ Foundation. A copy of the license is included in the chapter entitled
60 <para>This document covers the Linux Kernel to Userspace API's used by 58 <para>This document covers the Linux Kernel to Userspace API's used by
61 video and radio streaming devices, including video cameras, 59 video and radio streaming devices, including video cameras,
62 analog and digital TV receiver cards, AM/FM receiver cards, 60 analog and digital TV receiver cards, AM/FM receiver cards,
63 streaming capture devices.</para> 61 streaming capture and output devices, codec devices and remote
62 controllers.</para>
64 <para>It is divided into four parts.</para> 63 <para>It is divided into four parts.</para>
65 <para>The first part covers radio, capture, 64 <para>The first part covers radio, video capture and output,
66 cameras and analog TV devices.</para> 65 cameras, analog TV devices and codecs.</para>
67 <para>The second part covers the 66 <para>The second part covers the
68 API used for digital TV and Internet reception via one of the 67 API used for digital TV and Internet reception via one of the
69 several digital tv standards. While it is called as DVB API, 68 several digital tv standards. While it is called as DVB API,
@@ -75,55 +74,14 @@ Foundation. A copy of the license is included in the chapter entitled
75 <para>For additional information and for the latest development code, 74 <para>For additional information and for the latest development code,
76 see: <ulink url="http://linuxtv.org">http://linuxtv.org</ulink>.</para> 75 see: <ulink url="http://linuxtv.org">http://linuxtv.org</ulink>.</para>
77 <para>For discussing improvements, reporting troubles, sending new drivers, etc, please mail to: <ulink url="http://vger.kernel.org/vger-lists.html#linux-media">Linux Media Mailing List (LMML).</ulink>.</para> 76 <para>For discussing improvements, reporting troubles, sending new drivers, etc, please mail to: <ulink url="http://vger.kernel.org/vger-lists.html#linux-media">Linux Media Mailing List (LMML).</ulink>.</para>
78
79</preface> 77</preface>
80 78
81<part id="v4l2spec"> 79<part id="v4l2spec">&sub-v4l2;</part>
82&sub-v4l2; 80<part id="dvbapi">&sub-dvbapi;</part>
83</part> 81<part id="remotes">&sub-remote_controllers;</part>
84<part id="dvbapi"> 82<part id="media_common">&sub-media-controller;</part>
85&sub-dvbapi;
86</part>
87<part id="v4ldvb_common">
88<partinfo>
89<authorgroup>
90<author>
91<firstname>Mauro</firstname>
92<surname>Chehab</surname>
93<othername role="mi">Carvalho</othername>
94<affiliation><address><email>mchehab@redhat.com</email></address></affiliation>
95<contrib>Initial version.</contrib>
96</author>
97</authorgroup>
98<copyright>
99 <year>2009-2012</year>
100 <holder>Mauro Carvalho Chehab</holder>
101</copyright>
102
103<revhistory>
104<!-- Put document revisions here, newest first. -->
105<revision>
106<revnumber>1.0.0</revnumber>
107<date>2009-09-06</date>
108<authorinitials>mcc</authorinitials>
109<revremark>Initial revision</revremark>
110</revision>
111</revhistory>
112</partinfo>
113
114<title>Remote Controller API</title>
115<chapter id="remote_controllers">
116&sub-remote_controllers;
117</chapter>
118</part>
119<part id="media_common">
120&sub-media-controller;
121</part>
122
123<chapter id="gen_errors">
124&sub-gen-errors;
125</chapter>
126 83
84<chapter id="gen_errors">&sub-gen-errors;</chapter>
127 85
128&sub-fdl-appendix; 86&sub-fdl-appendix;
129 87
diff --git a/Documentation/devices.txt b/Documentation/devices.txt
index d154147d0015..87b4c5e82d39 100644
--- a/Documentation/devices.txt
+++ b/Documentation/devices.txt
@@ -1494,10 +1494,17 @@ Your cooperation is appreciated.
1494 64 = /dev/radio0 Radio device 1494 64 = /dev/radio0 Radio device
1495 ... 1495 ...
1496 127 = /dev/radio63 Radio device 1496 127 = /dev/radio63 Radio device
1497 128 = /dev/swradio0 Software Defined Radio device
1498 ...
1499 191 = /dev/swradio63 Software Defined Radio device
1497 224 = /dev/vbi0 Vertical blank interrupt 1500 224 = /dev/vbi0 Vertical blank interrupt
1498 ... 1501 ...
1499 255 = /dev/vbi31 Vertical blank interrupt 1502 255 = /dev/vbi31 Vertical blank interrupt
1500 1503
1504 Minor numbers are allocated dynamically unless
1505 CONFIG_VIDEO_FIXED_MINOR_RANGES (default n)
1506 configuration option is set.
1507
1501 81 block I2O hard disk 1508 81 block I2O hard disk
1502 0 = /dev/i2o/hdq 17th I2O hard disk, whole disk 1509 0 = /dev/i2o/hdq 17th I2O hard disk, whole disk
1503 16 = /dev/i2o/hdr 18th I2O hard disk, whole disk 1510 16 = /dev/i2o/hdr 18th I2O hard disk, whole disk
diff --git a/Documentation/devicetree/bindings/media/img-ir-rev1.txt b/Documentation/devicetree/bindings/media/img-ir-rev1.txt
new file mode 100644
index 000000000000..5434ce61b925
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/img-ir-rev1.txt
@@ -0,0 +1,34 @@
1* ImgTec Infrared (IR) decoder version 1
2
3This binding is for Imagination Technologies' Infrared decoder block,
4specifically major revision 1.
5
6Required properties:
7- compatible: Should be "img,ir-rev1"
8- reg: Physical base address of the controller and length of
9 memory mapped region.
10- interrupts: The interrupt specifier to the cpu.
11
12Optional properties:
13- clocks: List of clock specifiers as described in standard
14 clock bindings.
15 Up to 3 clocks may be specified in the following order:
16 1st: Core clock (defaults to 32.768KHz if omitted).
17 2nd: System side (fast) clock.
18 3rd: Power modulation clock.
19- clock-names: List of clock names corresponding to the clocks
20 specified in the clocks property.
21 Accepted clock names are:
22 "core": Core clock.
23 "sys": System clock.
24 "mod": Power modulation clock.
25
26Example:
27
28 ir@02006200 {
29 compatible = "img,ir-rev1";
30 reg = <0x02006200 0x100>;
31 interrupts = <29 4>;
32 clocks = <&clk_32khz>;
33 clock-names = "core";
34 };
diff --git a/Documentation/dvb/get_dvb_firmware b/Documentation/dvb/get_dvb_firmware
index 5d5ee4c13fa6..d91b8be80b66 100755
--- a/Documentation/dvb/get_dvb_firmware
+++ b/Documentation/dvb/get_dvb_firmware
@@ -28,8 +28,8 @@ use IO::Handle;
28 "opera1", "cx231xx", "cx18", "cx23885", "pvrusb2", "mpc718", 28 "opera1", "cx231xx", "cx18", "cx23885", "pvrusb2", "mpc718",
29 "af9015", "ngene", "az6027", "lme2510_lg", "lme2510c_s7395", 29 "af9015", "ngene", "az6027", "lme2510_lg", "lme2510c_s7395",
30 "lme2510c_s7395_old", "drxk", "drxk_terratec_h5", 30 "lme2510c_s7395_old", "drxk", "drxk_terratec_h5",
31 "drxk_hauppauge_hvr930c", "tda10071", "it9135", "it9137", 31 "drxk_hauppauge_hvr930c", "tda10071", "it9135", "drxk_pctv",
32 "drxk_pctv", "drxk_terratec_htc_stick", "sms1xxx_hcw"); 32 "drxk_terratec_htc_stick", "sms1xxx_hcw");
33 33
34# Check args 34# Check args
35syntax() if (scalar(@ARGV) != 1); 35syntax() if (scalar(@ARGV) != 1);
@@ -727,24 +727,6 @@ sub it9135 {
727 "$fwfile1 $fwfile2" 727 "$fwfile1 $fwfile2"
728} 728}
729 729
730sub it9137 {
731 my $url = "http://kworld.server261.com/kworld/CD/ITE_TiVme/V1.00/";
732 my $zipfile = "Driver_V10.323.1.0412.100412.zip";
733 my $hash = "79b597dc648698ed6820845c0c9d0d37";
734 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0);
735 my $drvfile = "Driver_V10.323.1.0412.100412/Data/x86/IT9135BDA.sys";
736 my $fwfile = "dvb-usb-it9137-01.fw";
737
738 checkstandard();
739
740 wgetfile($zipfile, $url . $zipfile);
741 verify($zipfile, $hash);
742 unzip($zipfile, $tmpdir);
743 extract("$tmpdir/$drvfile", 69632, 5731, "$fwfile");
744
745 "$fwfile"
746}
747
748sub tda10071 { 730sub tda10071 {
749 my $sourcefile = "PCTV_460e_reference.zip"; 731 my $sourcefile = "PCTV_460e_reference.zip";
750 my $url = "ftp://ftp.pctvsystems.com/TV/driver/PCTV%2070e%2080e%20100e%20320e%20330e%20800e/"; 732 my $url = "ftp://ftp.pctvsystems.com/TV/driver/PCTV%2070e%2080e%20100e%20320e%20330e%20800e/";
diff --git a/Documentation/dvb/it9137.txt b/Documentation/dvb/it9137.txt
deleted file mode 100644
index 9e6726eead90..000000000000
--- a/Documentation/dvb/it9137.txt
+++ /dev/null
@@ -1,9 +0,0 @@
1To extract firmware for Kworld UB499-2T (id 1b80:e409) you need to copy the
2following file(s) to this directory.
3
4IT9135BDA.sys Dated Mon 22 Mar 2010 02:20:08 GMT
5
6extract using dd
7dd if=IT9135BDA.sys ibs=1 skip=69632 count=5731 of=dvb-usb-it9137-01.fw
8
9copy to default firmware location.
diff --git a/Documentation/edac.txt b/Documentation/edac.txt
index 56c7e936430f..cb4c2cefd45a 100644
--- a/Documentation/edac.txt
+++ b/Documentation/edac.txt
@@ -6,7 +6,7 @@ Written by Doug Thompson <dougthompson@xmission.com>
67 Dec 2005 67 Dec 2005
717 Jul 2007 Updated 717 Jul 2007 Updated
8 8
9(c) Mauro Carvalho Chehab <mchehab@redhat.com> 9(c) Mauro Carvalho Chehab
1005 Aug 2009 Nehalem interface 1005 Aug 2009 Nehalem interface
11 11
12EDAC is maintained and written by: 12EDAC is maintained and written by:
diff --git a/Documentation/video4linux/CARDLIST.bttv b/Documentation/video4linux/CARDLIST.bttv
index f14475011fea..2f6e93597ce0 100644
--- a/Documentation/video4linux/CARDLIST.bttv
+++ b/Documentation/video4linux/CARDLIST.bttv
@@ -163,3 +163,4 @@
163162 -> Adlink MPG24 163162 -> Adlink MPG24
164163 -> Bt848 Capture 14MHz 164163 -> Bt848 Capture 14MHz
165164 -> CyberVision CV06 (SV) 165164 -> CyberVision CV06 (SV)
166165 -> Kworld V-Stream Xpert TV PVR878
diff --git a/Documentation/video4linux/CARDLIST.cx23885 b/Documentation/video4linux/CARDLIST.cx23885
index 9f056d512e35..fc009d0ee7d6 100644
--- a/Documentation/video4linux/CARDLIST.cx23885
+++ b/Documentation/video4linux/CARDLIST.cx23885
@@ -31,10 +31,13 @@
31 30 -> NetUP Dual DVB-T/C-CI RF [1b55:e2e4] 31 30 -> NetUP Dual DVB-T/C-CI RF [1b55:e2e4]
32 31 -> Leadtek Winfast PxDVR3200 H XC4000 [107d:6f39] 32 31 -> Leadtek Winfast PxDVR3200 H XC4000 [107d:6f39]
33 32 -> MPX-885 33 32 -> MPX-885
34 33 -> Mygica X8507 [14f1:8502] 34 33 -> Mygica X8502/X8507 ISDB-T [14f1:8502]
35 34 -> TerraTec Cinergy T PCIe Dual [153b:117e] 35 34 -> TerraTec Cinergy T PCIe Dual [153b:117e]
36 35 -> TeVii S471 [d471:9022] 36 35 -> TeVii S471 [d471:9022]
37 36 -> Hauppauge WinTV-HVR1255 [0070:2259] 37 36 -> Hauppauge WinTV-HVR1255 [0070:2259]
38 37 -> Prof Revolution DVB-S2 8000 [8000:3034] 38 37 -> Prof Revolution DVB-S2 8000 [8000:3034]
39 38 -> Hauppauge WinTV-HVR4400 [0070:c108,0070:c138,0070:c12a,0070:c1f8] 39 38 -> Hauppauge WinTV-HVR4400 [0070:c108,0070:c138,0070:c12a,0070:c1f8]
40 39 -> AVerTV Hybrid Express Slim HC81R [1461:d939] 40 39 -> AVerTV Hybrid Express Slim HC81R [1461:d939]
41 40 -> TurboSight TBS 6981 [6981:8888]
42 41 -> TurboSight TBS 6980 [6980:8888]
43 42 -> Leadtek Winfast PxPVR2200 [107d:6f21]
diff --git a/Documentation/video4linux/CARDLIST.em28xx b/Documentation/video4linux/CARDLIST.em28xx
index e81864405102..e085b1243b45 100644
--- a/Documentation/video4linux/CARDLIST.em28xx
+++ b/Documentation/video4linux/CARDLIST.em28xx
@@ -57,6 +57,7 @@
57 56 -> Pinnacle Hybrid Pro (330e) (em2882) [2304:0226] 57 56 -> Pinnacle Hybrid Pro (330e) (em2882) [2304:0226]
58 57 -> Kworld PlusTV HD Hybrid 330 (em2883) [eb1a:a316] 58 57 -> Kworld PlusTV HD Hybrid 330 (em2883) [eb1a:a316]
59 58 -> Compro VideoMate ForYou/Stereo (em2820/em2840) [185b:2041] 59 58 -> Compro VideoMate ForYou/Stereo (em2820/em2840) [185b:2041]
60 59 -> Pinnacle PCTV HD Mini (em2874) [2304:023f]
60 60 -> Hauppauge WinTV HVR 850 (em2883) [2040:651f] 61 60 -> Hauppauge WinTV HVR 850 (em2883) [2040:651f]
61 61 -> Pixelview PlayTV Box 4 USB 2.0 (em2820/em2840) 62 61 -> Pixelview PlayTV Box 4 USB 2.0 (em2820/em2840)
62 62 -> Gadmei TVR200 (em2820/em2840) 63 62 -> Gadmei TVR200 (em2820/em2840)
@@ -86,3 +87,8 @@
86 86 -> PCTV QuatroStick nano (520e) (em2884) [2013:0251] 87 86 -> PCTV QuatroStick nano (520e) (em2884) [2013:0251]
87 87 -> Terratec Cinergy HTC USB XS (em2884) [0ccd:008e,0ccd:00ac] 88 87 -> Terratec Cinergy HTC USB XS (em2884) [0ccd:008e,0ccd:00ac]
88 88 -> C3 Tech Digital Duo HDTV/SDTV USB (em2884) [1b80:e755] 89 88 -> C3 Tech Digital Duo HDTV/SDTV USB (em2884) [1b80:e755]
90 89 -> Delock 61959 (em2874) [1b80:e1cc]
91 90 -> KWorld USB ATSC TV Stick UB435-Q V2 (em2874) [1b80:e346]
92 91 -> SpeedLink Vicious And Devine Laplace webcam (em2765) [1ae7:9003,1ae7:9004]
93 92 -> PCTV DVB-S2 Stick (461e) (em28178)
94 93 -> KWorld USB ATSC TV Stick UB435-Q V3 (em2874) [1b80:e34c]
diff --git a/Documentation/video4linux/gspca.txt b/Documentation/video4linux/gspca.txt
index 1e6b6531bbcc..d2ba80bb7af5 100644
--- a/Documentation/video4linux/gspca.txt
+++ b/Documentation/video4linux/gspca.txt
@@ -55,6 +55,7 @@ zc3xx 0458:700f Genius VideoCam Web V2
55sonixj 0458:7025 Genius Eye 311Q 55sonixj 0458:7025 Genius Eye 311Q
56sn9c20x 0458:7029 Genius Look 320s 56sn9c20x 0458:7029 Genius Look 320s
57sonixj 0458:702e Genius Slim 310 NB 57sonixj 0458:702e Genius Slim 310 NB
58sn9c20x 0458:7045 Genius Look 1320 V2
58sn9c20x 0458:704a Genius Slim 1320 59sn9c20x 0458:704a Genius Slim 1320
59sn9c20x 0458:704c Genius i-Look 1321 60sn9c20x 0458:704c Genius i-Look 1321
60sn9c20x 045e:00f4 LifeCam VX-6000 (SN9C20x + OV9650) 61sn9c20x 045e:00f4 LifeCam VX-6000 (SN9C20x + OV9650)
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
index 6c4866b49eb5..667a43361706 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -34,6 +34,10 @@ So this framework sets up the basic building blocks that all drivers
34need and this same framework should make it much easier to refactor 34need and this same framework should make it much easier to refactor
35common code into utility functions shared by all drivers. 35common code into utility functions shared by all drivers.
36 36
37A good example to look at as a reference is the v4l2-pci-skeleton.c
38source that is available in this directory. It is a skeleton driver for
39a PCI capture card, and demonstrates how to use the V4L2 driver
40framework. It can be used as a template for real PCI video capture driver.
37 41
38Structure of a driver 42Structure of a driver
39--------------------- 43---------------------
@@ -768,6 +772,7 @@ types exist:
768VFL_TYPE_GRABBER: videoX for video input/output devices 772VFL_TYPE_GRABBER: videoX for video input/output devices
769VFL_TYPE_VBI: vbiX for vertical blank data (i.e. closed captions, teletext) 773VFL_TYPE_VBI: vbiX for vertical blank data (i.e. closed captions, teletext)
770VFL_TYPE_RADIO: radioX for radio tuners 774VFL_TYPE_RADIO: radioX for radio tuners
775VFL_TYPE_SDR: swradioX for Software Defined Radio tuners
771 776
772The last argument gives you a certain amount of control over the device 777The last argument gives you a certain amount of control over the device
773device node number used (i.e. the X in videoX). Normally you will pass -1 778device node number used (i.e. the X in videoX). Normally you will pass -1
diff --git a/Documentation/video4linux/v4l2-pci-skeleton.c b/Documentation/video4linux/v4l2-pci-skeleton.c
new file mode 100644
index 000000000000..3a1c0d2dafce
--- /dev/null
+++ b/Documentation/video4linux/v4l2-pci-skeleton.c
@@ -0,0 +1,913 @@
1/*
2 * This is a V4L2 PCI Skeleton Driver. It gives an initial skeleton source
3 * for use with other PCI drivers.
4 *
5 * This skeleton PCI driver assumes that the card has an S-Video connector as
6 * input 0 and an HDMI connector as input 1.
7 *
8 * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
9 *
10 * This program is free software; you may redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2 of the License.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24#include <linux/types.h>
25#include <linux/kernel.h>
26#include <linux/module.h>
27#include <linux/init.h>
28#include <linux/kmod.h>
29#include <linux/mutex.h>
30#include <linux/pci.h>
31#include <linux/interrupt.h>
32#include <linux/videodev2.h>
33#include <linux/v4l2-dv-timings.h>
34#include <media/v4l2-device.h>
35#include <media/v4l2-dev.h>
36#include <media/v4l2-ioctl.h>
37#include <media/v4l2-dv-timings.h>
38#include <media/v4l2-ctrls.h>
39#include <media/v4l2-event.h>
40#include <media/videobuf2-dma-contig.h>
41
42MODULE_DESCRIPTION("V4L2 PCI Skeleton Driver");
43MODULE_AUTHOR("Hans Verkuil");
44MODULE_LICENSE("GPL v2");
45MODULE_DEVICE_TABLE(pci, skeleton_pci_tbl);
46
47/**
48 * struct skeleton - All internal data for one instance of device
49 * @pdev: PCI device
50 * @v4l2_dev: top-level v4l2 device struct
51 * @vdev: video node structure
52 * @ctrl_handler: control handler structure
53 * @lock: ioctl serialization mutex
54 * @std: current SDTV standard
55 * @timings: current HDTV timings
56 * @format: current pix format
57 * @input: current video input (0 = SDTV, 1 = HDTV)
58 * @queue: vb2 video capture queue
59 * @alloc_ctx: vb2 contiguous DMA context
60 * @qlock: spinlock controlling access to buf_list and sequence
61 * @buf_list: list of buffers queued for DMA
62 * @sequence: frame sequence counter
63 */
64struct skeleton {
65 struct pci_dev *pdev;
66 struct v4l2_device v4l2_dev;
67 struct video_device vdev;
68 struct v4l2_ctrl_handler ctrl_handler;
69 struct mutex lock;
70 v4l2_std_id std;
71 struct v4l2_dv_timings timings;
72 struct v4l2_pix_format format;
73 unsigned input;
74
75 struct vb2_queue queue;
76 struct vb2_alloc_ctx *alloc_ctx;
77
78 spinlock_t qlock;
79 struct list_head buf_list;
80 unsigned int sequence;
81};
82
83struct skel_buffer {
84 struct vb2_buffer vb;
85 struct list_head list;
86};
87
88static inline struct skel_buffer *to_skel_buffer(struct vb2_buffer *vb2)
89{
90 return container_of(vb2, struct skel_buffer, vb);
91}
92
93static const struct pci_device_id skeleton_pci_tbl[] = {
94 /* { PCI_DEVICE(PCI_VENDOR_ID_, PCI_DEVICE_ID_) }, */
95 { 0, }
96};
97
98/*
99 * HDTV: this structure has the capabilities of the HDTV receiver.
100 * It is used to constrain the huge list of possible formats based
101 * upon the hardware capabilities.
102 */
103static const struct v4l2_dv_timings_cap skel_timings_cap = {
104 .type = V4L2_DV_BT_656_1120,
105 /* keep this initialization for compatibility with GCC < 4.4.6 */
106 .reserved = { 0 },
107 V4L2_INIT_BT_TIMINGS(
108 720, 1920, /* min/max width */
109 480, 1080, /* min/max height */
110 27000000, 74250000, /* min/max pixelclock*/
111 V4L2_DV_BT_STD_CEA861, /* Supported standards */
112 /* capabilities */
113 V4L2_DV_BT_CAP_INTERLACED | V4L2_DV_BT_CAP_PROGRESSIVE
114 )
115};
116
117/*
118 * Supported SDTV standards. This does the same job as skel_timings_cap, but
119 * for standard TV formats.
120 */
121#define SKEL_TVNORMS V4L2_STD_ALL
122
123/*
124 * Interrupt handler: typically interrupts happen after a new frame has been
125 * captured. It is the job of the handler to remove the new frame from the
126 * internal list and give it back to the vb2 framework, updating the sequence
127 * counter and timestamp at the same time.
128 */
129static irqreturn_t skeleton_irq(int irq, void *dev_id)
130{
131#ifdef TODO
132 struct skeleton *skel = dev_id;
133
134 /* handle interrupt */
135
136 /* Once a new frame has been captured, mark it as done like this: */
137 if (captured_new_frame) {
138 ...
139 spin_lock(&skel->qlock);
140 list_del(&new_buf->list);
141 spin_unlock(&skel->qlock);
142 new_buf->vb.v4l2_buf.sequence = skel->sequence++;
143 v4l2_get_timestamp(&new_buf->vb.v4l2_buf.timestamp);
144 vb2_buffer_done(&new_buf->vb, VB2_BUF_STATE_DONE);
145 }
146#endif
147 return IRQ_HANDLED;
148}
149
150/*
151 * Setup the constraints of the queue: besides setting the number of planes
152 * per buffer and the size and allocation context of each plane, it also
153 * checks if sufficient buffers have been allocated. Usually 3 is a good
154 * minimum number: many DMA engines need a minimum of 2 buffers in the
155 * queue and you need to have another available for userspace processing.
156 */
157static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
158 unsigned int *nbuffers, unsigned int *nplanes,
159 unsigned int sizes[], void *alloc_ctxs[])
160{
161 struct skeleton *skel = vb2_get_drv_priv(vq);
162
163 if (vq->num_buffers + *nbuffers < 3)
164 *nbuffers = 3 - vq->num_buffers;
165
166 if (fmt && fmt->fmt.pix.sizeimage < skel->format.sizeimage)
167 return -EINVAL;
168 *nplanes = 1;
169 sizes[0] = fmt ? fmt->fmt.pix.sizeimage : skel->format.sizeimage;
170 alloc_ctxs[0] = skel->alloc_ctx;
171 return 0;
172}
173
174/*
175 * Prepare the buffer for queueing to the DMA engine: check and set the
176 * payload size and fill in the field. Note: if the format's field is
177 * V4L2_FIELD_ALTERNATE, then vb->v4l2_buf.field should be set in the
178 * interrupt handler since that's usually where you know if the TOP or
179 * BOTTOM field has been captured.
180 */
181static int buffer_prepare(struct vb2_buffer *vb)
182{
183 struct skeleton *skel = vb2_get_drv_priv(vb->vb2_queue);
184 unsigned long size = skel->format.sizeimage;
185
186 if (vb2_plane_size(vb, 0) < size) {
187 dev_err(&skel->pdev->dev, "buffer too small (%lu < %lu)\n",
188 vb2_plane_size(vb, 0), size);
189 return -EINVAL;
190 }
191
192 vb2_set_plane_payload(vb, 0, size);
193 vb->v4l2_buf.field = skel->format.field;
194 return 0;
195}
196
197/*
198 * Queue this buffer to the DMA engine.
199 */
200static void buffer_queue(struct vb2_buffer *vb)
201{
202 struct skeleton *skel = vb2_get_drv_priv(vb->vb2_queue);
203 struct skel_buffer *buf = to_skel_buffer(vb);
204 unsigned long flags;
205
206 spin_lock_irqsave(&skel->qlock, flags);
207 list_add_tail(&buf->list, &skel->buf_list);
208
209 /* TODO: Update any DMA pointers if necessary */
210
211 spin_unlock_irqrestore(&skel->qlock, flags);
212}
213
214static void return_all_buffers(struct skeleton *skel,
215 enum vb2_buffer_state state)
216{
217 struct skel_buffer *buf, *node;
218 unsigned long flags;
219
220 spin_lock_irqsave(&skel->qlock, flags);
221 list_for_each_entry_safe(buf, node, &skel->buf_list, list) {
222 vb2_buffer_done(&buf->vb, state);
223 list_del(&buf->list);
224 }
225 spin_unlock_irqrestore(&skel->qlock, flags);
226}
227
228/*
229 * Start streaming. First check if the minimum number of buffers have been
230 * queued. If not, then return -ENOBUFS and the vb2 framework will call
231 * this function again the next time a buffer has been queued until enough
232 * buffers are available to actually start the DMA engine.
233 */
234static int start_streaming(struct vb2_queue *vq, unsigned int count)
235{
236 struct skeleton *skel = vb2_get_drv_priv(vq);
237 int ret = 0;
238
239 skel->sequence = 0;
240
241 /* TODO: start DMA */
242
243 if (ret) {
244 /*
245 * In case of an error, return all active buffers to the
246 * QUEUED state
247 */
248 return_all_buffers(skel, VB2_BUF_STATE_QUEUED);
249 }
250 return ret;
251}
252
253/*
254 * Stop the DMA engine. Any remaining buffers in the DMA queue are dequeued
255 * and passed on to the vb2 framework marked as STATE_ERROR.
256 */
257static int stop_streaming(struct vb2_queue *vq)
258{
259 struct skeleton *skel = vb2_get_drv_priv(vq);
260
261 /* TODO: stop DMA */
262
263 /* Release all active buffers */
264 return_all_buffers(skel, VB2_BUF_STATE_ERROR);
265 return 0;
266}
267
268/*
269 * The vb2 queue ops. Note that since q->lock is set we can use the standard
270 * vb2_ops_wait_prepare/finish helper functions. If q->lock would be NULL,
271 * then this driver would have to provide these ops.
272 */
273static struct vb2_ops skel_qops = {
274 .queue_setup = queue_setup,
275 .buf_prepare = buffer_prepare,
276 .buf_queue = buffer_queue,
277 .start_streaming = start_streaming,
278 .stop_streaming = stop_streaming,
279 .wait_prepare = vb2_ops_wait_prepare,
280 .wait_finish = vb2_ops_wait_finish,
281};
282
283/*
284 * Required ioctl querycap. Note that the version field is prefilled with
285 * the version of the kernel.
286 */
287static int skeleton_querycap(struct file *file, void *priv,
288 struct v4l2_capability *cap)
289{
290 struct skeleton *skel = video_drvdata(file);
291
292 strlcpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
293 strlcpy(cap->card, "V4L2 PCI Skeleton", sizeof(cap->card));
294 snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
295 pci_name(skel->pdev));
296 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
297 V4L2_CAP_STREAMING;
298 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
299 return 0;
300}
301
302/*
303 * Helper function to check and correct struct v4l2_pix_format. It's used
304 * not only in VIDIOC_TRY/S_FMT, but also elsewhere if changes to the SDTV
305 * standard, HDTV timings or the video input would require updating the
306 * current format.
307 */
308static void skeleton_fill_pix_format(struct skeleton *skel,
309 struct v4l2_pix_format *pix)
310{
311 pix->pixelformat = V4L2_PIX_FMT_YUYV;
312 if (skel->input == 0) {
313 /* S-Video input */
314 pix->width = 720;
315 pix->height = (skel->std & V4L2_STD_525_60) ? 480 : 576;
316 pix->field = V4L2_FIELD_INTERLACED;
317 pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
318 } else {
319 /* HDMI input */
320 pix->width = skel->timings.bt.width;
321 pix->height = skel->timings.bt.height;
322 if (skel->timings.bt.interlaced)
323 pix->field = V4L2_FIELD_INTERLACED;
324 else
325 pix->field = V4L2_FIELD_NONE;
326 pix->colorspace = V4L2_COLORSPACE_REC709;
327 }
328
329 /*
330 * The YUYV format is four bytes for every two pixels, so bytesperline
331 * is width * 2.
332 */
333 pix->bytesperline = pix->width * 2;
334 pix->sizeimage = pix->bytesperline * pix->height;
335 pix->priv = 0;
336}
337
338static int skeleton_try_fmt_vid_cap(struct file *file, void *priv,
339 struct v4l2_format *f)
340{
341 struct skeleton *skel = video_drvdata(file);
342 struct v4l2_pix_format *pix = &f->fmt.pix;
343
344 /*
345 * Due to historical reasons providing try_fmt with an unsupported
346 * pixelformat will return -EINVAL for video receivers. Webcam drivers,
347 * however, will silently correct the pixelformat. Some video capture
348 * applications rely on this behavior...
349 */
350 if (pix->pixelformat != V4L2_PIX_FMT_YUYV)
351 return -EINVAL;
352 skeleton_fill_pix_format(skel, pix);
353 return 0;
354}
355
356static int skeleton_s_fmt_vid_cap(struct file *file, void *priv,
357 struct v4l2_format *f)
358{
359 struct skeleton *skel = video_drvdata(file);
360 int ret;
361
362 ret = skeleton_try_fmt_vid_cap(file, priv, f);
363 if (ret)
364 return ret;
365
366 /*
367 * It is not allowed to change the format while buffers for use with
368 * streaming have already been allocated.
369 */
370 if (vb2_is_busy(&skel->queue))
371 return -EBUSY;
372
373 /* TODO: change format */
374 skel->format = f->fmt.pix;
375 return 0;
376}
377
378static int skeleton_g_fmt_vid_cap(struct file *file, void *priv,
379 struct v4l2_format *f)
380{
381 struct skeleton *skel = video_drvdata(file);
382
383 f->fmt.pix = skel->format;
384 return 0;
385}
386
387static int skeleton_enum_fmt_vid_cap(struct file *file, void *priv,
388 struct v4l2_fmtdesc *f)
389{
390 if (f->index != 0)
391 return -EINVAL;
392
393 strlcpy(f->description, "4:2:2, packed, YUYV", sizeof(f->description));
394 f->pixelformat = V4L2_PIX_FMT_YUYV;
395 f->flags = 0;
396 return 0;
397}
398
399static int skeleton_s_std(struct file *file, void *priv, v4l2_std_id std)
400{
401 struct skeleton *skel = video_drvdata(file);
402
403 /* S_STD is not supported on the HDMI input */
404 if (skel->input)
405 return -ENODATA;
406
407 /*
408 * No change, so just return. Some applications call S_STD again after
409 * the buffers for streaming have been set up, so we have to allow for
410 * this behavior.
411 */
412 if (std == skel->std)
413 return 0;
414
415 /*
416 * Changing the standard implies a format change, which is not allowed
417 * while buffers for use with streaming have already been allocated.
418 */
419 if (vb2_is_busy(&skel->queue))
420 return -EBUSY;
421
422 /* TODO: handle changing std */
423
424 skel->std = std;
425
426 /* Update the internal format */
427 skeleton_fill_pix_format(skel, &skel->format);
428 return 0;
429}
430
431static int skeleton_g_std(struct file *file, void *priv, v4l2_std_id *std)
432{
433 struct skeleton *skel = video_drvdata(file);
434
435 /* G_STD is not supported on the HDMI input */
436 if (skel->input)
437 return -ENODATA;
438
439 *std = skel->std;
440 return 0;
441}
442
443/*
444 * Query the current standard as seen by the hardware. This function shall
445 * never actually change the standard, it just detects and reports.
446 * The framework will initially set *std to tvnorms (i.e. the set of
447 * supported standards by this input), and this function should just AND
448 * this value. If there is no signal, then *std should be set to 0.
449 */
450static int skeleton_querystd(struct file *file, void *priv, v4l2_std_id *std)
451{
452 struct skeleton *skel = video_drvdata(file);
453
454 /* QUERY_STD is not supported on the HDMI input */
455 if (skel->input)
456 return -ENODATA;
457
458#ifdef TODO
459 /*
460 * Query currently seen standard. Initial value of *std is
461 * V4L2_STD_ALL. This function should look something like this:
462 */
463 get_signal_info();
464 if (no_signal) {
465 *std = 0;
466 return 0;
467 }
468 /* Use signal information to reduce the number of possible standards */
469 if (signal_has_525_lines)
470 *std &= V4L2_STD_525_60;
471 else
472 *std &= V4L2_STD_625_50;
473#endif
474 return 0;
475}
476
477static int skeleton_s_dv_timings(struct file *file, void *_fh,
478 struct v4l2_dv_timings *timings)
479{
480 struct skeleton *skel = video_drvdata(file);
481
482 /* S_DV_TIMINGS is not supported on the S-Video input */
483 if (skel->input == 0)
484 return -ENODATA;
485
486 /* Quick sanity check */
487 if (!v4l2_valid_dv_timings(timings, &skel_timings_cap, NULL, NULL))
488 return -EINVAL;
489
490 /* Check if the timings are part of the CEA-861 timings. */
491 if (!v4l2_find_dv_timings_cap(timings, &skel_timings_cap,
492 0, NULL, NULL))
493 return -EINVAL;
494
495 /* Return 0 if the new timings are the same as the current timings. */
496 if (v4l2_match_dv_timings(timings, &skel->timings, 0))
497 return 0;
498
499 /*
500 * Changing the timings implies a format change, which is not allowed
501 * while buffers for use with streaming have already been allocated.
502 */
503 if (vb2_is_busy(&skel->queue))
504 return -EBUSY;
505
506 /* TODO: Configure new timings */
507
508 /* Save timings */
509 skel->timings = *timings;
510
511 /* Update the internal format */
512 skeleton_fill_pix_format(skel, &skel->format);
513 return 0;
514}
515
516static int skeleton_g_dv_timings(struct file *file, void *_fh,
517 struct v4l2_dv_timings *timings)
518{
519 struct skeleton *skel = video_drvdata(file);
520
521 /* G_DV_TIMINGS is not supported on the S-Video input */
522 if (skel->input == 0)
523 return -ENODATA;
524
525 *timings = skel->timings;
526 return 0;
527}
528
529static int skeleton_enum_dv_timings(struct file *file, void *_fh,
530 struct v4l2_enum_dv_timings *timings)
531{
532 struct skeleton *skel = video_drvdata(file);
533
534 /* ENUM_DV_TIMINGS is not supported on the S-Video input */
535 if (skel->input == 0)
536 return -ENODATA;
537
538 return v4l2_enum_dv_timings_cap(timings, &skel_timings_cap,
539 NULL, NULL);
540}
541
542/*
543 * Query the current timings as seen by the hardware. This function shall
544 * never actually change the timings, it just detects and reports.
545 * If no signal is detected, then return -ENOLINK. If the hardware cannot
546 * lock to the signal, then return -ENOLCK. If the signal is out of range
547 * of the capabilities of the system (e.g., it is possible that the receiver
548 * can lock but that the DMA engine it is connected to cannot handle
549 * pixelclocks above a certain frequency), then -ERANGE is returned.
550 */
551static int skeleton_query_dv_timings(struct file *file, void *_fh,
552 struct v4l2_dv_timings *timings)
553{
554 struct skeleton *skel = video_drvdata(file);
555
556 /* QUERY_DV_TIMINGS is not supported on the S-Video input */
557 if (skel->input == 0)
558 return -ENODATA;
559
560#ifdef TODO
561 /*
562 * Query currently seen timings. This function should look
563 * something like this:
564 */
565 detect_timings();
566 if (no_signal)
567 return -ENOLINK;
568 if (cannot_lock_to_signal)
569 return -ENOLCK;
570 if (signal_out_of_range_of_capabilities)
571 return -ERANGE;
572
573 /* Useful for debugging */
574 v4l2_print_dv_timings(skel->v4l2_dev.name, "query_dv_timings:",
575 timings, true);
576#endif
577 return 0;
578}
579
580static int skeleton_dv_timings_cap(struct file *file, void *fh,
581 struct v4l2_dv_timings_cap *cap)
582{
583 struct skeleton *skel = video_drvdata(file);
584
585 /* DV_TIMINGS_CAP is not supported on the S-Video input */
586 if (skel->input == 0)
587 return -ENODATA;
588 *cap = skel_timings_cap;
589 return 0;
590}
591
592static int skeleton_enum_input(struct file *file, void *priv,
593 struct v4l2_input *i)
594{
595 if (i->index > 1)
596 return -EINVAL;
597
598 i->type = V4L2_INPUT_TYPE_CAMERA;
599 if (i->index == 0) {
600 i->std = SKEL_TVNORMS;
601 strlcpy(i->name, "S-Video", sizeof(i->name));
602 i->capabilities = V4L2_IN_CAP_STD;
603 } else {
604 i->std = 0;
605 strlcpy(i->name, "HDMI", sizeof(i->name));
606 i->capabilities = V4L2_IN_CAP_DV_TIMINGS;
607 }
608 return 0;
609}
610
611static int skeleton_s_input(struct file *file, void *priv, unsigned int i)
612{
613 struct skeleton *skel = video_drvdata(file);
614
615 if (i > 1)
616 return -EINVAL;
617
618 /*
619 * Changing the input implies a format change, which is not allowed
620 * while buffers for use with streaming have already been allocated.
621 */
622 if (vb2_is_busy(&skel->queue))
623 return -EBUSY;
624
625 skel->input = i;
626 /*
627 * Update tvnorms. The tvnorms value is used by the core to implement
628 * VIDIOC_ENUMSTD so it has to be correct. If tvnorms == 0, then
629 * ENUMSTD will return -ENODATA.
630 */
631 skel->vdev.tvnorms = i ? 0 : SKEL_TVNORMS;
632
633 /* Update the internal format */
634 skeleton_fill_pix_format(skel, &skel->format);
635 return 0;
636}
637
638static int skeleton_g_input(struct file *file, void *priv, unsigned int *i)
639{
640 struct skeleton *skel = video_drvdata(file);
641
642 *i = skel->input;
643 return 0;
644}
645
646/* The control handler. */
647static int skeleton_s_ctrl(struct v4l2_ctrl *ctrl)
648{
649 /*struct skeleton *skel =
650 container_of(ctrl->handler, struct skeleton, ctrl_handler);*/
651
652 switch (ctrl->id) {
653 case V4L2_CID_BRIGHTNESS:
654 /* TODO: set brightness to ctrl->val */
655 break;
656 case V4L2_CID_CONTRAST:
657 /* TODO: set contrast to ctrl->val */
658 break;
659 case V4L2_CID_SATURATION:
660 /* TODO: set saturation to ctrl->val */
661 break;
662 case V4L2_CID_HUE:
663 /* TODO: set hue to ctrl->val */
664 break;
665 default:
666 return -EINVAL;
667 }
668 return 0;
669}
670
671/* ------------------------------------------------------------------
672 File operations for the device
673 ------------------------------------------------------------------*/
674
675static const struct v4l2_ctrl_ops skel_ctrl_ops = {
676 .s_ctrl = skeleton_s_ctrl,
677};
678
679/*
680 * The set of all supported ioctls. Note that all the streaming ioctls
681 * use the vb2 helper functions that take care of all the locking and
682 * that also do ownership tracking (i.e. only the filehandle that requested
683 * the buffers can call the streaming ioctls, all other filehandles will
684 * receive -EBUSY if they attempt to call the same streaming ioctls).
685 *
686 * The last three ioctls also use standard helper functions: these implement
687 * standard behavior for drivers with controls.
688 */
689static const struct v4l2_ioctl_ops skel_ioctl_ops = {
690 .vidioc_querycap = skeleton_querycap,
691 .vidioc_try_fmt_vid_cap = skeleton_try_fmt_vid_cap,
692 .vidioc_s_fmt_vid_cap = skeleton_s_fmt_vid_cap,
693 .vidioc_g_fmt_vid_cap = skeleton_g_fmt_vid_cap,
694 .vidioc_enum_fmt_vid_cap = skeleton_enum_fmt_vid_cap,
695
696 .vidioc_g_std = skeleton_g_std,
697 .vidioc_s_std = skeleton_s_std,
698 .vidioc_querystd = skeleton_querystd,
699
700 .vidioc_s_dv_timings = skeleton_s_dv_timings,
701 .vidioc_g_dv_timings = skeleton_g_dv_timings,
702 .vidioc_enum_dv_timings = skeleton_enum_dv_timings,
703 .vidioc_query_dv_timings = skeleton_query_dv_timings,
704 .vidioc_dv_timings_cap = skeleton_dv_timings_cap,
705
706 .vidioc_enum_input = skeleton_enum_input,
707 .vidioc_g_input = skeleton_g_input,
708 .vidioc_s_input = skeleton_s_input,
709
710 .vidioc_reqbufs = vb2_ioctl_reqbufs,
711 .vidioc_create_bufs = vb2_ioctl_create_bufs,
712 .vidioc_querybuf = vb2_ioctl_querybuf,
713 .vidioc_qbuf = vb2_ioctl_qbuf,
714 .vidioc_dqbuf = vb2_ioctl_dqbuf,
715 .vidioc_expbuf = vb2_ioctl_expbuf,
716 .vidioc_streamon = vb2_ioctl_streamon,
717 .vidioc_streamoff = vb2_ioctl_streamoff,
718
719 .vidioc_log_status = v4l2_ctrl_log_status,
720 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
721 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
722};
723
724/*
725 * The set of file operations. Note that all these ops are standard core
726 * helper functions.
727 */
728static const struct v4l2_file_operations skel_fops = {
729 .owner = THIS_MODULE,
730 .open = v4l2_fh_open,
731 .release = vb2_fop_release,
732 .unlocked_ioctl = video_ioctl2,
733 .read = vb2_fop_read,
734 .mmap = vb2_fop_mmap,
735 .poll = vb2_fop_poll,
736};
737
738/*
739 * The initial setup of this device instance. Note that the initial state of
740 * the driver should be complete. So the initial format, standard, timings
741 * and video input should all be initialized to some reasonable value.
742 */
743static int skeleton_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
744{
745 /* The initial timings are chosen to be 720p60. */
746 static const struct v4l2_dv_timings timings_def =
747 V4L2_DV_BT_CEA_1280X720P60;
748 struct skeleton *skel;
749 struct video_device *vdev;
750 struct v4l2_ctrl_handler *hdl;
751 struct vb2_queue *q;
752 int ret;
753
754 /* Enable PCI */
755 ret = pci_enable_device(pdev);
756 if (ret)
757 return ret;
758 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
759 if (ret) {
760 dev_err(&pdev->dev, "no suitable DMA available.\n");
761 goto disable_pci;
762 }
763
764 /* Allocate a new instance */
765 skel = devm_kzalloc(&pdev->dev, sizeof(struct skeleton), GFP_KERNEL);
766 if (!skel)
767 return -ENOMEM;
768
769 /* Allocate the interrupt */
770 ret = devm_request_irq(&pdev->dev, pdev->irq,
771 skeleton_irq, 0, KBUILD_MODNAME, skel);
772 if (ret) {
773 dev_err(&pdev->dev, "request_irq failed\n");
774 goto disable_pci;
775 }
776 skel->pdev = pdev;
777
778 /* Fill in the initial format-related settings */
779 skel->timings = timings_def;
780 skel->std = V4L2_STD_625_50;
781 skeleton_fill_pix_format(skel, &skel->format);
782
783 /* Initialize the top-level structure */
784 ret = v4l2_device_register(&pdev->dev, &skel->v4l2_dev);
785 if (ret)
786 goto disable_pci;
787
788 mutex_init(&skel->lock);
789
790 /* Add the controls */
791 hdl = &skel->ctrl_handler;
792 v4l2_ctrl_handler_init(hdl, 4);
793 v4l2_ctrl_new_std(hdl, &skel_ctrl_ops,
794 V4L2_CID_BRIGHTNESS, 0, 255, 1, 127);
795 v4l2_ctrl_new_std(hdl, &skel_ctrl_ops,
796 V4L2_CID_CONTRAST, 0, 255, 1, 16);
797 v4l2_ctrl_new_std(hdl, &skel_ctrl_ops,
798 V4L2_CID_SATURATION, 0, 255, 1, 127);
799 v4l2_ctrl_new_std(hdl, &skel_ctrl_ops,
800 V4L2_CID_HUE, -128, 127, 1, 0);
801 if (hdl->error) {
802 ret = hdl->error;
803 goto free_hdl;
804 }
805 skel->v4l2_dev.ctrl_handler = hdl;
806
807 /* Initialize the vb2 queue */
808 q = &skel->queue;
809 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
810 q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
811 q->drv_priv = skel;
812 q->buf_struct_size = sizeof(struct skel_buffer);
813 q->ops = &skel_qops;
814 q->mem_ops = &vb2_dma_contig_memops;
815 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
816 /*
817 * Assume that this DMA engine needs to have at least two buffers
818 * available before it can be started. The start_streaming() op
819 * won't be called until at least this many buffers are queued up.
820 */
821 q->min_buffers_needed = 2;
822 /*
823 * The serialization lock for the streaming ioctls. This is the same
824 * as the main serialization lock, but if some of the non-streaming
825 * ioctls could take a long time to execute, then you might want to
826 * have a different lock here to prevent VIDIOC_DQBUF from being
827 * blocked while waiting for another action to finish. This is
828 * generally not needed for PCI devices, but USB devices usually do
829 * want a separate lock here.
830 */
831 q->lock = &skel->lock;
832 /*
833 * Since this driver can only do 32-bit DMA we must make sure that
834 * the vb2 core will allocate the buffers in 32-bit DMA memory.
835 */
836 q->gfp_flags = GFP_DMA32;
837 ret = vb2_queue_init(q);
838 if (ret)
839 goto free_hdl;
840
841 skel->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
842 if (IS_ERR(skel->alloc_ctx)) {
843 dev_err(&pdev->dev, "Can't allocate buffer context");
844 ret = PTR_ERR(skel->alloc_ctx);
845 goto free_hdl;
846 }
847 INIT_LIST_HEAD(&skel->buf_list);
848 spin_lock_init(&skel->qlock);
849
850 /* Initialize the video_device structure */
851 vdev = &skel->vdev;
852 strlcpy(vdev->name, KBUILD_MODNAME, sizeof(vdev->name));
853 /*
854 * There is nothing to clean up, so release is set to an empty release
855 * function. The release callback must be non-NULL.
856 */
857 vdev->release = video_device_release_empty;
858 vdev->fops = &skel_fops,
859 vdev->ioctl_ops = &skel_ioctl_ops,
860 /*
861 * The main serialization lock. All ioctls are serialized by this
862 * lock. Exception: if q->lock is set, then the streaming ioctls
863 * are serialized by that separate lock.
864 */
865 vdev->lock = &skel->lock;
866 vdev->queue = q;
867 vdev->v4l2_dev = &skel->v4l2_dev;
868 /* Supported SDTV standards, if any */
869 vdev->tvnorms = SKEL_TVNORMS;
870 /* If this bit is set, then the v4l2 core will provide the support
871 * for the VIDIOC_G/S_PRIORITY ioctls. This flag will eventually
872 * go away once all drivers have been converted to use struct v4l2_fh.
873 */
874 set_bit(V4L2_FL_USE_FH_PRIO, &vdev->flags);
875 video_set_drvdata(vdev, skel);
876
877 ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
878 if (ret)
879 goto free_ctx;
880
881 dev_info(&pdev->dev, "V4L2 PCI Skeleton Driver loaded\n");
882 return 0;
883
884free_ctx:
885 vb2_dma_contig_cleanup_ctx(skel->alloc_ctx);
886free_hdl:
887 v4l2_ctrl_handler_free(&skel->ctrl_handler);
888 v4l2_device_unregister(&skel->v4l2_dev);
889disable_pci:
890 pci_disable_device(pdev);
891 return ret;
892}
893
894static void skeleton_remove(struct pci_dev *pdev)
895{
896 struct v4l2_device *v4l2_dev = pci_get_drvdata(pdev);
897 struct skeleton *skel = container_of(v4l2_dev, struct skeleton, v4l2_dev);
898
899 video_unregister_device(&skel->vdev);
900 v4l2_ctrl_handler_free(&skel->ctrl_handler);
901 vb2_dma_contig_cleanup_ctx(skel->alloc_ctx);
902 v4l2_device_unregister(&skel->v4l2_dev);
903 pci_disable_device(skel->pdev);
904}
905
906static struct pci_driver skeleton_driver = {
907 .name = KBUILD_MODNAME,
908 .probe = skeleton_probe,
909 .remove = skeleton_remove,
910 .id_table = skeleton_pci_tbl,
911};
912
913module_pci_driver(skeleton_driver);
diff --git a/MAINTAINERS b/MAINTAINERS
index 9eeeddfa19a0..8774f7974d69 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4860,22 +4860,6 @@ F: Documentation/hwmon/it87
4860F: drivers/hwmon/it87.c 4860F: drivers/hwmon/it87.c
4861 4861
4862IT913X MEDIA DRIVER 4862IT913X MEDIA DRIVER
4863M: Malcolm Priestley <tvboxspy@gmail.com>
4864L: linux-media@vger.kernel.org
4865W: http://linuxtv.org/
4866Q: http://patchwork.linuxtv.org/project/linux-media/list/
4867S: Maintained
4868F: drivers/media/usb/dvb-usb-v2/it913x*
4869
4870IT913X FE MEDIA DRIVER
4871M: Malcolm Priestley <tvboxspy@gmail.com>
4872L: linux-media@vger.kernel.org
4873W: http://linuxtv.org/
4874Q: http://patchwork.linuxtv.org/project/linux-media/list/
4875S: Maintained
4876F: drivers/media/dvb-frontends/it913x-fe*
4877
4878IT913X MEDIA DRIVER
4879M: Antti Palosaari <crope@iki.fi> 4863M: Antti Palosaari <crope@iki.fi>
4880L: linux-media@vger.kernel.org 4864L: linux-media@vger.kernel.org
4881W: http://linuxtv.org/ 4865W: http://linuxtv.org/
@@ -5855,6 +5839,26 @@ L: platform-driver-x86@vger.kernel.org
5855S: Supported 5839S: Supported
5856F: drivers/platform/x86/msi-wmi.c 5840F: drivers/platform/x86/msi-wmi.c
5857 5841
5842MSI001 MEDIA DRIVER
5843M: Antti Palosaari <crope@iki.fi>
5844L: linux-media@vger.kernel.org
5845W: http://linuxtv.org/
5846W: http://palosaari.fi/linux/
5847Q: http://patchwork.linuxtv.org/project/linux-media/list/
5848T: git git://linuxtv.org/anttip/media_tree.git
5849S: Maintained
5850F: drivers/staging/media/msi3101/msi001*
5851
5852MSI3101 MEDIA DRIVER
5853M: Antti Palosaari <crope@iki.fi>
5854L: linux-media@vger.kernel.org
5855W: http://linuxtv.org/
5856W: http://palosaari.fi/linux/
5857Q: http://patchwork.linuxtv.org/project/linux-media/list/
5858T: git git://linuxtv.org/anttip/media_tree.git
5859S: Maintained
5860F: drivers/staging/media/msi3101/sdr-msi3101*
5861
5858MT9M032 APTINA SENSOR DRIVER 5862MT9M032 APTINA SENSOR DRIVER
5859M: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 5863M: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
5860L: linux-media@vger.kernel.org 5864L: linux-media@vger.kernel.org
@@ -7422,6 +7426,16 @@ T: git git://linuxtv.org/anttip/media_tree.git
7422S: Maintained 7426S: Maintained
7423F: drivers/media/dvb-frontends/rtl2832* 7427F: drivers/media/dvb-frontends/rtl2832*
7424 7428
7429RTL2832_SDR MEDIA DRIVER
7430M: Antti Palosaari <crope@iki.fi>
7431L: linux-media@vger.kernel.org
7432W: http://linuxtv.org/
7433W: http://palosaari.fi/linux/
7434Q: http://patchwork.linuxtv.org/project/linux-media/list/
7435T: git git://linuxtv.org/anttip/media_tree.git
7436S: Maintained
7437F: drivers/staging/media/rtl2832u_sdr/rtl2832_sdr*
7438
7425RTL8180 WIRELESS DRIVER 7439RTL8180 WIRELESS DRIVER
7426M: "John W. Linville" <linville@tuxdriver.com> 7440M: "John W. Linville" <linville@tuxdriver.com>
7427L: linux-wireless@vger.kernel.org 7441L: linux-wireless@vger.kernel.org
@@ -7954,15 +7968,13 @@ F: drivers/media/usb/siano/
7954F: drivers/media/mmc/siano/ 7968F: drivers/media/mmc/siano/
7955 7969
7956SH_VEU V4L2 MEM2MEM DRIVER 7970SH_VEU V4L2 MEM2MEM DRIVER
7957M: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
7958L: linux-media@vger.kernel.org 7971L: linux-media@vger.kernel.org
7959S: Maintained 7972S: Orphan
7960F: drivers/media/platform/sh_veu.c 7973F: drivers/media/platform/sh_veu.c
7961 7974
7962SH_VOU V4L2 OUTPUT DRIVER 7975SH_VOU V4L2 OUTPUT DRIVER
7963M: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
7964L: linux-media@vger.kernel.org 7976L: linux-media@vger.kernel.org
7965S: Odd Fixes 7977S: Orphan
7966F: drivers/media/platform/sh_vou.c 7978F: drivers/media/platform/sh_vou.c
7967F: include/media/sh_vou.h 7979F: include/media/sh_vou.h
7968 7980
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index 8dd0ec858cf1..018353d88b96 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -16,6 +16,8 @@
16 * 16 *
17 */ 17 */
18 18
19#include <linux/clk-provider.h>
20#include <linux/clkdev.h>
19#include <linux/kernel.h> 21#include <linux/kernel.h>
20#include <linux/init.h> 22#include <linux/init.h>
21#include <linux/platform_device.h> 23#include <linux/platform_device.h>
@@ -542,8 +544,22 @@ static struct isp_platform_data cm_t35_isp_pdata = {
542 .subdevs = cm_t35_isp_subdevs, 544 .subdevs = cm_t35_isp_subdevs,
543}; 545};
544 546
547static struct regulator_consumer_supply cm_t35_camera_supplies[] = {
548 REGULATOR_SUPPLY("vaa", "3-005d"),
549 REGULATOR_SUPPLY("vdd", "3-005d"),
550};
551
545static void __init cm_t35_init_camera(void) 552static void __init cm_t35_init_camera(void)
546{ 553{
554 struct clk *clk;
555
556 clk = clk_register_fixed_rate(NULL, "mt9t001-clkin", NULL, CLK_IS_ROOT,
557 48000000);
558 clk_register_clkdev(clk, NULL, "3-005d");
559
560 regulator_register_fixed(2, cm_t35_camera_supplies,
561 ARRAY_SIZE(cm_t35_camera_supplies));
562
547 if (omap3_init_camera(&cm_t35_isp_pdata) < 0) 563 if (omap3_init_camera(&cm_t35_isp_pdata) < 0)
548 pr_warn("CM-T3x: Failed registering camera device!\n"); 564 pr_warn("CM-T3x: Failed registering camera device!\n");
549} 565}
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index b335c6ab5efe..01fae8289cf0 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Written Doug Thompson <norsk5@xmission.com> www.softwarebitmaker.com 8 * Written Doug Thompson <norsk5@xmission.com> www.softwarebitmaker.com
9 * 9 *
10 * (c) 2012-2013 - Mauro Carvalho Chehab <mchehab@redhat.com> 10 * (c) 2012-2013 - Mauro Carvalho Chehab
11 * The entire API were re-written, and ported to use struct device 11 * The entire API were re-written, and ported to use struct device
12 * 12 *
13 */ 13 */
diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c
index d5a98a45c062..8399b4e16fe0 100644
--- a/drivers/edac/ghes_edac.c
+++ b/drivers/edac/ghes_edac.c
@@ -4,7 +4,7 @@
4 * This file may be distributed under the terms of the GNU General Public 4 * This file may be distributed under the terms of the GNU General Public
5 * License version 2. 5 * License version 2.
6 * 6 *
7 * Copyright (c) 2013 by Mauro Carvalho Chehab <mchehab@redhat.com> 7 * Copyright (c) 2013 by Mauro Carvalho Chehab
8 * 8 *
9 * Red Hat Inc. http://www.redhat.com 9 * Red Hat Inc. http://www.redhat.com
10 */ 10 */
diff --git a/drivers/edac/i5400_edac.c b/drivers/edac/i5400_edac.c
index 5381e98d9c0c..6ef6ad1ba16e 100644
--- a/drivers/edac/i5400_edac.c
+++ b/drivers/edac/i5400_edac.c
@@ -6,7 +6,7 @@
6 * 6 *
7 * Copyright (c) 2008 by: 7 * Copyright (c) 2008 by:
8 * Ben Woodard <woodard@redhat.com> 8 * Ben Woodard <woodard@redhat.com>
9 * Mauro Carvalho Chehab <mchehab@redhat.com> 9 * Mauro Carvalho Chehab
10 * 10 *
11 * Red Hat Inc. http://www.redhat.com 11 * Red Hat Inc. http://www.redhat.com
12 * 12 *
@@ -1469,7 +1469,7 @@ module_exit(i5400_exit);
1469 1469
1470MODULE_LICENSE("GPL"); 1470MODULE_LICENSE("GPL");
1471MODULE_AUTHOR("Ben Woodard <woodard@redhat.com>"); 1471MODULE_AUTHOR("Ben Woodard <woodard@redhat.com>");
1472MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 1472MODULE_AUTHOR("Mauro Carvalho Chehab");
1473MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)"); 1473MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)");
1474MODULE_DESCRIPTION("MC Driver for Intel I5400 memory controllers - " 1474MODULE_DESCRIPTION("MC Driver for Intel I5400 memory controllers - "
1475 I5400_REVISION); 1475 I5400_REVISION);
diff --git a/drivers/edac/i7300_edac.c b/drivers/edac/i7300_edac.c
index 57e96a3350f0..dcac982fdc7a 100644
--- a/drivers/edac/i7300_edac.c
+++ b/drivers/edac/i7300_edac.c
@@ -5,7 +5,7 @@
5 * GNU General Public License version 2 only. 5 * GNU General Public License version 2 only.
6 * 6 *
7 * Copyright (c) 2010 by: 7 * Copyright (c) 2010 by:
8 * Mauro Carvalho Chehab <mchehab@redhat.com> 8 * Mauro Carvalho Chehab
9 * 9 *
10 * Red Hat Inc. http://www.redhat.com 10 * Red Hat Inc. http://www.redhat.com
11 * 11 *
@@ -1209,7 +1209,7 @@ module_init(i7300_init);
1209module_exit(i7300_exit); 1209module_exit(i7300_exit);
1210 1210
1211MODULE_LICENSE("GPL"); 1211MODULE_LICENSE("GPL");
1212MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 1212MODULE_AUTHOR("Mauro Carvalho Chehab");
1213MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)"); 1213MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)");
1214MODULE_DESCRIPTION("MC Driver for Intel I7300 memory controllers - " 1214MODULE_DESCRIPTION("MC Driver for Intel I7300 memory controllers - "
1215 I7300_REVISION); 1215 I7300_REVISION);
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 8bc83b99974b..9cd0b301f81b 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -9,7 +9,7 @@
9 * GNU General Public License version 2 only. 9 * GNU General Public License version 2 only.
10 * 10 *
11 * Copyright (c) 2009-2010 by: 11 * Copyright (c) 2009-2010 by:
12 * Mauro Carvalho Chehab <mchehab@redhat.com> 12 * Mauro Carvalho Chehab
13 * 13 *
14 * Red Hat Inc. http://www.redhat.com 14 * Red Hat Inc. http://www.redhat.com
15 * 15 *
@@ -2457,7 +2457,7 @@ module_init(i7core_init);
2457module_exit(i7core_exit); 2457module_exit(i7core_exit);
2458 2458
2459MODULE_LICENSE("GPL"); 2459MODULE_LICENSE("GPL");
2460MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 2460MODULE_AUTHOR("Mauro Carvalho Chehab");
2461MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)"); 2461MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)");
2462MODULE_DESCRIPTION("MC Driver for Intel i7 Core memory controllers - " 2462MODULE_DESCRIPTION("MC Driver for Intel i7 Core memory controllers - "
2463 I7CORE_REVISION); 2463 I7CORE_REVISION);
diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index c460ba5d65a8..deea0dc9999b 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -7,7 +7,7 @@
7 * GNU General Public License version 2 only. 7 * GNU General Public License version 2 only.
8 * 8 *
9 * Copyright (c) 2011 by: 9 * Copyright (c) 2011 by:
10 * Mauro Carvalho Chehab <mchehab@redhat.com> 10 * Mauro Carvalho Chehab
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
@@ -2183,7 +2183,7 @@ module_param(edac_op_state, int, 0444);
2183MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); 2183MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI");
2184 2184
2185MODULE_LICENSE("GPL"); 2185MODULE_LICENSE("GPL");
2186MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 2186MODULE_AUTHOR("Mauro Carvalho Chehab");
2187MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)"); 2187MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)");
2188MODULE_DESCRIPTION("MC Driver for Intel Sandy Bridge and Ivy Bridge memory controllers - " 2188MODULE_DESCRIPTION("MC Driver for Intel Sandy Bridge and Ivy Bridge memory controllers - "
2189 SBRIDGE_REVISION); 2189 SBRIDGE_REVISION);
diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
index 59d5eb1e742c..cf1a9f1c1217 100644
--- a/drivers/hid/hid-picolcd_cir.c
+++ b/drivers/hid/hid-picolcd_cir.c
@@ -114,7 +114,7 @@ int picolcd_init_cir(struct picolcd_data *data, struct hid_report *report)
114 114
115 rdev->priv = data; 115 rdev->priv = data;
116 rdev->driver_type = RC_DRIVER_IR_RAW; 116 rdev->driver_type = RC_DRIVER_IR_RAW;
117 rdev->allowed_protos = RC_BIT_ALL; 117 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
118 rdev->open = picolcd_cir_open; 118 rdev->open = picolcd_cir_open;
119 rdev->close = picolcd_cir_close; 119 rdev->close = picolcd_cir_close;
120 rdev->input_name = data->hdev->name; 120 rdev->input_name = data->hdev->name;
diff --git a/drivers/media/common/siano/smsdvb-debugfs.c b/drivers/media/common/siano/smsdvb-debugfs.c
index 0bb4430535f9..2408d7e9451e 100644
--- a/drivers/media/common/siano/smsdvb-debugfs.c
+++ b/drivers/media/common/siano/smsdvb-debugfs.c
@@ -1,6 +1,6 @@
1/*********************************************************************** 1/***********************************************************************
2 * 2 *
3 * Copyright(c) 2013 Mauro Carvalho Chehab <mchehab@redhat.com> 3 * Copyright(c) 2013 Mauro Carvalho Chehab
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/common/siano/smsir.c b/drivers/media/common/siano/smsir.c
index b8c5cad78537..6d7c0c858bd0 100644
--- a/drivers/media/common/siano/smsir.c
+++ b/drivers/media/common/siano/smsir.c
@@ -88,7 +88,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
88 88
89 dev->priv = coredev; 89 dev->priv = coredev;
90 dev->driver_type = RC_DRIVER_IR_RAW; 90 dev->driver_type = RC_DRIVER_IR_RAW;
91 dev->allowed_protos = RC_BIT_ALL; 91 rc_set_allowed_protocols(dev, RC_BIT_ALL);
92 dev->map_name = sms_get_board(board_id)->rc_codes; 92 dev->map_name = sms_get_board(board_id)->rc_codes;
93 dev->driver_name = MODULE_NAME; 93 dev->driver_name = MODULE_NAME;
94 94
diff --git a/drivers/media/dvb-core/dvb-usb-ids.h b/drivers/media/dvb-core/dvb-usb-ids.h
index f19a2ccd1e4b..1bdc0e7e8b79 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -257,6 +257,7 @@
257#define USB_PID_TERRATEC_T5 0x10a1 257#define USB_PID_TERRATEC_T5 0x10a1
258#define USB_PID_NOXON_DAB_STICK 0x00b3 258#define USB_PID_NOXON_DAB_STICK 0x00b3
259#define USB_PID_NOXON_DAB_STICK_REV2 0x00e0 259#define USB_PID_NOXON_DAB_STICK_REV2 0x00e0
260#define USB_PID_NOXON_DAB_STICK_REV3 0x00b4
260#define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e 261#define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e
261#define USB_PID_PINNACLE_PCTV2000E 0x022c 262#define USB_PID_PINNACLE_PCTV2000E 0x022c
262#define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228 263#define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index 1f925e856974..6ce435ac866f 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -1279,7 +1279,7 @@ static int dtv_property_process_get(struct dvb_frontend *fe,
1279 switch(tvp->cmd) { 1279 switch(tvp->cmd) {
1280 case DTV_ENUM_DELSYS: 1280 case DTV_ENUM_DELSYS:
1281 ncaps = 0; 1281 ncaps = 0;
1282 while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) { 1282 while (ncaps < MAX_DELSYS && fe->ops.delsys[ncaps]) {
1283 tvp->u.buffer.data[ncaps] = fe->ops.delsys[ncaps]; 1283 tvp->u.buffer.data[ncaps] = fe->ops.delsys[ncaps];
1284 ncaps++; 1284 ncaps++;
1285 } 1285 }
@@ -1596,7 +1596,7 @@ static int dvbv5_set_delivery_system(struct dvb_frontend *fe,
1596 * supported 1596 * supported
1597 */ 1597 */
1598 ncaps = 0; 1598 ncaps = 0;
1599 while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) { 1599 while (ncaps < MAX_DELSYS && fe->ops.delsys[ncaps]) {
1600 if (fe->ops.delsys[ncaps] == desired_system) { 1600 if (fe->ops.delsys[ncaps] == desired_system) {
1601 c->delivery_system = desired_system; 1601 c->delivery_system = desired_system;
1602 dev_dbg(fe->dvb->device, 1602 dev_dbg(fe->dvb->device,
@@ -1628,7 +1628,7 @@ static int dvbv5_set_delivery_system(struct dvb_frontend *fe,
1628 * of the desired system 1628 * of the desired system
1629 */ 1629 */
1630 ncaps = 0; 1630 ncaps = 0;
1631 while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) { 1631 while (ncaps < MAX_DELSYS && fe->ops.delsys[ncaps]) {
1632 if (dvbv3_type(fe->ops.delsys[ncaps]) == type) 1632 if (dvbv3_type(fe->ops.delsys[ncaps]) == type)
1633 delsys = fe->ops.delsys[ncaps]; 1633 delsys = fe->ops.delsys[ncaps];
1634 ncaps++; 1634 ncaps++;
@@ -1703,7 +1703,7 @@ static int dvbv3_set_delivery_system(struct dvb_frontend *fe)
1703 * DVBv3 standard 1703 * DVBv3 standard
1704 */ 1704 */
1705 ncaps = 0; 1705 ncaps = 0;
1706 while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) { 1706 while (ncaps < MAX_DELSYS && fe->ops.delsys[ncaps]) {
1707 if (dvbv3_type(fe->ops.delsys[ncaps]) != DVBV3_UNKNOWN) { 1707 if (dvbv3_type(fe->ops.delsys[ncaps]) != DVBV3_UNKNOWN) {
1708 delsys = fe->ops.delsys[ncaps]; 1708 delsys = fe->ops.delsys[ncaps];
1709 break; 1709 break;
@@ -1882,6 +1882,8 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
1882 c->lna = tvp->u.data; 1882 c->lna = tvp->u.data;
1883 if (fe->ops.set_lna) 1883 if (fe->ops.set_lna)
1884 r = fe->ops.set_lna(fe); 1884 r = fe->ops.set_lna(fe);
1885 if (r < 0)
1886 c->lna = LNA_AUTO;
1885 break; 1887 break;
1886 1888
1887 default: 1889 default:
diff --git a/drivers/media/dvb-frontends/Kconfig b/drivers/media/dvb-frontends/Kconfig
index dd12a1ebda82..025fc5496bfc 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -441,7 +441,7 @@ config DVB_RTL2830
441 441
442config DVB_RTL2832 442config DVB_RTL2832
443 tristate "Realtek RTL2832 DVB-T" 443 tristate "Realtek RTL2832 DVB-T"
444 depends on DVB_CORE && I2C 444 depends on DVB_CORE && I2C && I2C_MUX
445 default m if !MEDIA_SUBDRV_AUTOSELECT 445 default m if !MEDIA_SUBDRV_AUTOSELECT
446 help 446 help
447 Say Y when you want to support this frontend. 447 Say Y when you want to support this frontend.
@@ -650,6 +650,8 @@ config DVB_TUNER_DIB0090
650comment "SEC control devices for DVB-S" 650comment "SEC control devices for DVB-S"
651 depends on DVB_CORE 651 depends on DVB_CORE
652 652
653source "drivers/media/dvb-frontends/drx39xyj/Kconfig"
654
653config DVB_LNBP21 655config DVB_LNBP21
654 tristate "LNBP21/LNBH24 SEC controllers" 656 tristate "LNBP21/LNBH24 SEC controllers"
655 depends on DVB_CORE && I2C 657 depends on DVB_CORE && I2C
@@ -733,14 +735,6 @@ config DVB_IX2505V
733 help 735 help
734 A DVB-S tuner module. Say Y when you want to support this frontend. 736 A DVB-S tuner module. Say Y when you want to support this frontend.
735 737
736config DVB_IT913X_FE
737 tristate "it913x frontend and it9137 tuner"
738 depends on DVB_CORE && I2C
739 default m if !MEDIA_SUBDRV_AUTOSELECT
740 help
741 A DVB-T tuner module.
742 Say Y when you want to support this frontend.
743
744config DVB_M88RS2000 738config DVB_M88RS2000
745 tristate "M88RS2000 DVB-S demodulator and tuner" 739 tristate "M88RS2000 DVB-S demodulator and tuner"
746 depends on DVB_CORE && I2C 740 depends on DVB_CORE && I2C
diff --git a/drivers/media/dvb-frontends/Makefile b/drivers/media/dvb-frontends/Makefile
index 0c75a6aafb9d..282aba2fe8db 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -92,13 +92,13 @@ obj-$(CONFIG_DVB_HD29L2) += hd29l2.o
92obj-$(CONFIG_DVB_DS3000) += ds3000.o 92obj-$(CONFIG_DVB_DS3000) += ds3000.o
93obj-$(CONFIG_DVB_TS2020) += ts2020.o 93obj-$(CONFIG_DVB_TS2020) += ts2020.o
94obj-$(CONFIG_DVB_MB86A16) += mb86a16.o 94obj-$(CONFIG_DVB_MB86A16) += mb86a16.o
95obj-$(CONFIG_DVB_DRX39XYJ) += drx39xyj/
95obj-$(CONFIG_DVB_MB86A20S) += mb86a20s.o 96obj-$(CONFIG_DVB_MB86A20S) += mb86a20s.o
96obj-$(CONFIG_DVB_IX2505V) += ix2505v.o 97obj-$(CONFIG_DVB_IX2505V) += ix2505v.o
97obj-$(CONFIG_DVB_STV0367) += stv0367.o 98obj-$(CONFIG_DVB_STV0367) += stv0367.o
98obj-$(CONFIG_DVB_CXD2820R) += cxd2820r.o 99obj-$(CONFIG_DVB_CXD2820R) += cxd2820r.o
99obj-$(CONFIG_DVB_DRXK) += drxk.o 100obj-$(CONFIG_DVB_DRXK) += drxk.o
100obj-$(CONFIG_DVB_TDA18271C2DD) += tda18271c2dd.o 101obj-$(CONFIG_DVB_TDA18271C2DD) += tda18271c2dd.o
101obj-$(CONFIG_DVB_IT913X_FE) += it913x-fe.o
102obj-$(CONFIG_DVB_A8293) += a8293.o 102obj-$(CONFIG_DVB_A8293) += a8293.o
103obj-$(CONFIG_DVB_TDA10071) += tda10071.o 103obj-$(CONFIG_DVB_TDA10071) += tda10071.o
104obj-$(CONFIG_DVB_RTL2830) += rtl2830.o 104obj-$(CONFIG_DVB_RTL2830) += rtl2830.o
diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c
index 65728c25ea05..be4bec2a9640 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -989,10 +989,62 @@ err:
989 return ret; 989 return ret;
990} 990}
991 991
992static int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
993{
994 struct af9033_state *state = fe->demodulator_priv;
995 int ret;
996
997 dev_dbg(&state->i2c->dev, "%s: onoff=%d\n", __func__, onoff);
998
999 ret = af9033_wr_reg_mask(state, 0x80f993, onoff, 0x01);
1000 if (ret < 0)
1001 goto err;
1002
1003 return 0;
1004
1005err:
1006 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
1007
1008 return ret;
1009}
1010
1011static int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid, int onoff)
1012{
1013 struct af9033_state *state = fe->demodulator_priv;
1014 int ret;
1015 u8 wbuf[2] = {(pid >> 0) & 0xff, (pid >> 8) & 0xff};
1016
1017 dev_dbg(&state->i2c->dev, "%s: index=%d pid=%04x onoff=%d\n",
1018 __func__, index, pid, onoff);
1019
1020 if (pid > 0x1fff)
1021 return 0;
1022
1023 ret = af9033_wr_regs(state, 0x80f996, wbuf, 2);
1024 if (ret < 0)
1025 goto err;
1026
1027 ret = af9033_wr_reg(state, 0x80f994, onoff);
1028 if (ret < 0)
1029 goto err;
1030
1031 ret = af9033_wr_reg(state, 0x80f995, index);
1032 if (ret < 0)
1033 goto err;
1034
1035 return 0;
1036
1037err:
1038 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret);
1039
1040 return ret;
1041}
1042
992static struct dvb_frontend_ops af9033_ops; 1043static struct dvb_frontend_ops af9033_ops;
993 1044
994struct dvb_frontend *af9033_attach(const struct af9033_config *config, 1045struct dvb_frontend *af9033_attach(const struct af9033_config *config,
995 struct i2c_adapter *i2c) 1046 struct i2c_adapter *i2c,
1047 struct af9033_ops *ops)
996{ 1048{
997 int ret; 1049 int ret;
998 struct af9033_state *state; 1050 struct af9033_state *state;
@@ -1067,6 +1119,11 @@ struct dvb_frontend *af9033_attach(const struct af9033_config *config,
1067 memcpy(&state->fe.ops, &af9033_ops, sizeof(struct dvb_frontend_ops)); 1119 memcpy(&state->fe.ops, &af9033_ops, sizeof(struct dvb_frontend_ops));
1068 state->fe.demodulator_priv = state; 1120 state->fe.demodulator_priv = state;
1069 1121
1122 if (ops) {
1123 ops->pid_filter = af9033_pid_filter;
1124 ops->pid_filter_ctrl = af9033_pid_filter_ctrl;
1125 }
1126
1070 return &state->fe; 1127 return &state->fe;
1071 1128
1072err: 1129err:
diff --git a/drivers/media/dvb-frontends/af9033.h b/drivers/media/dvb-frontends/af9033.h
index c286e8f1ec02..539f4db678b8 100644
--- a/drivers/media/dvb-frontends/af9033.h
+++ b/drivers/media/dvb-frontends/af9033.h
@@ -78,16 +78,42 @@ struct af9033_config {
78}; 78};
79 79
80 80
81struct af9033_ops {
82 int (*pid_filter_ctrl)(struct dvb_frontend *fe, int onoff);
83 int (*pid_filter)(struct dvb_frontend *fe, int index, u16 pid,
84 int onoff);
85};
86
87
81#if IS_ENABLED(CONFIG_DVB_AF9033) 88#if IS_ENABLED(CONFIG_DVB_AF9033)
82extern struct dvb_frontend *af9033_attach(const struct af9033_config *config, 89extern
83 struct i2c_adapter *i2c); 90struct dvb_frontend *af9033_attach(const struct af9033_config *config,
91 struct i2c_adapter *i2c,
92 struct af9033_ops *ops);
93
84#else 94#else
85static inline struct dvb_frontend *af9033_attach( 95static inline
86 const struct af9033_config *config, struct i2c_adapter *i2c) 96struct dvb_frontend *af9033_attach(const struct af9033_config *config,
97 struct i2c_adapter *i2c,
98 struct af9033_ops *ops)
87{ 99{
88 pr_warn("%s: driver disabled by Kconfig\n", __func__); 100 pr_warn("%s: driver disabled by Kconfig\n", __func__);
89 return NULL; 101 return NULL;
90} 102}
103
104static inline int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
105{
106 pr_warn("%s: driver disabled by Kconfig\n", __func__);
107 return -ENODEV;
108}
109
110static inline int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid,
111 int onoff)
112{
113 pr_warn("%s: driver disabled by Kconfig\n", __func__);
114 return -ENODEV;
115}
116
91#endif 117#endif
92 118
93#endif /* AF9033_H */ 119#endif /* AF9033_H */
diff --git a/drivers/media/dvb-frontends/drx39xyj/Kconfig b/drivers/media/dvb-frontends/drx39xyj/Kconfig
new file mode 100644
index 000000000000..15628eb5cf0c
--- /dev/null
+++ b/drivers/media/dvb-frontends/drx39xyj/Kconfig
@@ -0,0 +1,7 @@
1config DVB_DRX39XYJ
2 tristate "Micronas DRX-J demodulator"
3 depends on DVB_CORE && I2C
4 default m if DVB_FE_CUSTOMISE
5 help
6 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
7 to support this frontend.
diff --git a/drivers/media/dvb-frontends/drx39xyj/Makefile b/drivers/media/dvb-frontends/drx39xyj/Makefile
new file mode 100644
index 000000000000..672e07774955
--- /dev/null
+++ b/drivers/media/dvb-frontends/drx39xyj/Makefile
@@ -0,0 +1,6 @@
1drx39xyj-objs := drxj.o
2
3obj-$(CONFIG_DVB_DRX39XYJ) += drx39xyj.o
4
5ccflags-y += -I$(srctree)/drivers/media/dvb-core/
6ccflags-y += -I$(srctree)/drivers/media/tuners/
diff --git a/drivers/media/dvb-frontends/drx39xyj/bsp_i2c.h b/drivers/media/dvb-frontends/drx39xyj/bsp_i2c.h
new file mode 100644
index 000000000000..5b5421f70388
--- /dev/null
+++ b/drivers/media/dvb-frontends/drx39xyj/bsp_i2c.h
@@ -0,0 +1,139 @@
1/*
2 I2C API, implementation depends on board specifics
3
4 Copyright (c), 2004-2005,2007-2010 Trident Microsystems, Inc.
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10 * Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
15 * Neither the name of Trident Microsystems nor Hauppauge Computer Works
16 nor the names of its contributors may be used to endorse or promote
17 products derived from this software without specific prior written
18 permission.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32 This module encapsulates I2C access.In some applications several devices
33 share one I2C bus. If these devices have the same I2C address some kind
34 off "switch" must be implemented to ensure error free communication with
35 one device. In case such a "switch" is used, the device ID can be used
36 to implement control over this "switch".
37*/
38
39#ifndef __BSPI2C_H__
40#define __BSPI2C_H__
41
42#include "bsp_types.h"
43
44/*
45 * This structure contains the I2C address, the device ID and a user_data pointer.
46 * The user_data pointer can be used for application specific purposes.
47 */
48struct i2c_device_addr {
49 u16 i2c_addr; /* The I2C address of the device. */
50 u16 i2c_dev_id; /* The device identifier. */
51 void *user_data; /* User data pointer */
52};
53
54
55/**
56* \def IS_I2C_10BIT( addr )
57* \brief Determine if I2C address 'addr' is a 10 bits address or not.
58* \param addr The I2C address.
59* \return int.
60* \retval 0 if address is not a 10 bits I2C address.
61* \retval 1 if address is a 10 bits I2C address.
62*/
63#define IS_I2C_10BIT(addr) \
64 (((addr) & 0xF8) == 0xF0)
65
66/*------------------------------------------------------------------------------
67Exported FUNCTIONS
68------------------------------------------------------------------------------*/
69
70/**
71* \fn drxbsp_i2c_init()
72* \brief Initialize I2C communication module.
73* \return drx_status_t Return status.
74* \retval 0 Initialization successful.
75* \retval -EIO Initialization failed.
76*/
77 drx_status_t drxbsp_i2c_init(void);
78
79/**
80* \fn drxbsp_i2c_term()
81* \brief Terminate I2C communication module.
82* \return drx_status_t Return status.
83* \retval 0 Termination successful.
84* \retval -EIO Termination failed.
85*/
86 drx_status_t drxbsp_i2c_term(void);
87
88/**
89* \fn drx_status_t drxbsp_i2c_write_read( struct i2c_device_addr *w_dev_addr,
90* u16 w_count,
91* u8 *wData,
92* struct i2c_device_addr *r_dev_addr,
93* u16 r_count,
94* u8 *r_data)
95* \brief Read and/or write count bytes from I2C bus, store them in data[].
96* \param w_dev_addr The device i2c address and the device ID to write to
97* \param w_count The number of bytes to write
98* \param wData The array to write the data to
99* \param r_dev_addr The device i2c address and the device ID to read from
100* \param r_count The number of bytes to read
101* \param r_data The array to read the data from
102* \return drx_status_t Return status.
103* \retval 0 Succes.
104* \retval -EIO Failure.
105* \retval -EINVAL Parameter 'wcount' is not zero but parameter
106* 'wdata' contains NULL.
107* Idem for 'rcount' and 'rdata'.
108* Both w_dev_addr and r_dev_addr are NULL.
109*
110* This function must implement an atomic write and/or read action on the I2C bus
111* No other process may use the I2C bus when this function is executing.
112* The critical section of this function runs from and including the I2C
113* write, up to and including the I2C read action.
114*
115* The device ID can be useful if several devices share an I2C address.
116* It can be used to control a "switch" on the I2C bus to the correct device.
117*/
118 drx_status_t drxbsp_i2c_write_read(struct i2c_device_addr *w_dev_addr,
119 u16 w_count,
120 u8 *w_data,
121 struct i2c_device_addr *r_dev_addr,
122 u16 r_count, u8 *r_data);
123
124/**
125* \fn drxbsp_i2c_error_text()
126* \brief Returns a human readable error.
127* Counter part of numerical drx_i2c_error_g.
128*
129* \return char* Pointer to human readable error text.
130*/
131 char *drxbsp_i2c_error_text(void);
132
133/**
134* \var drx_i2c_error_g;
135* \brief I2C specific error codes, platform dependent.
136*/
137 extern int drx_i2c_error_g;
138
139#endif /* __BSPI2C_H__ */
diff --git a/drivers/media/dvb-frontends/drx39xyj/drx39xxj.h b/drivers/media/dvb-frontends/drx39xyj/drx39xxj.h
new file mode 100644
index 000000000000..cfd0b96b6939
--- /dev/null
+++ b/drivers/media/dvb-frontends/drx39xyj/drx39xxj.h
@@ -0,0 +1,45 @@
1/*
2 * Driver for Micronas DRX39xx family (drx3933j)
3 *
4 * Written by Devin Heitmueller <devin.heitmueller@kernellabs.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 *
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */
21
22#ifndef DRX39XXJ_H
23#define DRX39XXJ_H
24
25#include <linux/dvb/frontend.h>
26#include "dvb_frontend.h"
27#include "drx_driver.h"
28
29struct drx39xxj_state {
30 struct i2c_adapter *i2c;
31 struct drx_demod_instance *demod;
32 struct dvb_frontend frontend;
33 unsigned int i2c_gate_open:1;
34 const struct firmware *fw;
35};
36
37#if IS_ENABLED(CONFIG_DVB_DRX39XYJ)
38struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c);
39#else
40static inline struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c) {
41 return NULL;
42};
43#endif
44
45#endif /* DVB_DUMMY_FE_H */
diff --git a/drivers/media/dvb-frontends/drx39xyj/drx_dap_fasi.h b/drivers/media/dvb-frontends/drx39xyj/drx_dap_fasi.h
new file mode 100644
index 000000000000..354ec07eae87
--- /dev/null
+++ b/drivers/media/dvb-frontends/drx39xyj/drx_dap_fasi.h
@@ -0,0 +1,256 @@
1/*
2 Copyright (c), 2004-2005,2007-2010 Trident Microsystems, Inc.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
13 * Neither the name of Trident Microsystems nor Hauppauge Computer Works
14 nor the names of its contributors may be used to endorse or promote
15 products derived from this software without specific prior written
16 permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 POSSIBILITY OF SUCH DAMAGE.
29*/
30
31/*******************************************************************************
32* FILENAME: $Id: drx_dap_fasi.h,v 1.5 2009/07/07 14:21:40 justin Exp $
33*
34* DESCRIPTION:
35* Part of DRX driver.
36* Data access protocol: Fast Access Sequential Interface (fasi)
37* Fast access, because of short addressing format (16 instead of 32 bits addr)
38* Sequential, because of I2C.
39*
40* USAGE:
41* Include.
42*
43* NOTES:
44*
45*
46*******************************************************************************/
47
48/*-------- compilation control switches --------------------------------------*/
49
50#ifndef __DRX_DAP_FASI_H__
51#define __DRX_DAP_FASI_H__
52
53/*-------- Required includes -------------------------------------------------*/
54
55#include "drx_driver.h"
56
57/*-------- Defines, configuring the API --------------------------------------*/
58
59/********************************************
60* Allowed address formats
61********************************************/
62
63/*
64* Comments about short/long addressing format:
65*
66* The DAP FASI offers long address format (4 bytes) and short address format
67* (2 bytes). The DAP can operate in 3 modes:
68* (1) only short
69* (2) only long
70* (3) both long and short but short preferred and long only when necesarry
71*
72* These modes must be selected compile time via compile switches.
73* Compile switch settings for the diffrent modes:
74* (1) DRXDAPFASI_LONG_ADDR_ALLOWED=0, DRXDAPFASI_SHORT_ADDR_ALLOWED=1
75* (2) DRXDAPFASI_LONG_ADDR_ALLOWED=1, DRXDAPFASI_SHORT_ADDR_ALLOWED=0
76* (3) DRXDAPFASI_LONG_ADDR_ALLOWED=1, DRXDAPFASI_SHORT_ADDR_ALLOWED=1
77*
78* The default setting will be (3) both long and short.
79* The default setting will need no compile switches.
80* The default setting must be overridden if compile switches are already
81* defined.
82*
83*/
84
85/* set default */
86#if !defined(DRXDAPFASI_LONG_ADDR_ALLOWED)
87#define DRXDAPFASI_LONG_ADDR_ALLOWED 1
88#endif
89
90/* set default */
91#if !defined(DRXDAPFASI_SHORT_ADDR_ALLOWED)
92#define DRXDAPFASI_SHORT_ADDR_ALLOWED 1
93#endif
94
95/* check */
96#if ((DRXDAPFASI_LONG_ADDR_ALLOWED == 0) && \
97 (DRXDAPFASI_SHORT_ADDR_ALLOWED == 0))
98#error At least one of short- or long-addressing format must be allowed.
99*; /* illegal statement to force compiler error */
100#endif
101
102/********************************************
103* Single/master multi master setting
104********************************************/
105/*
106* Comments about SINGLE MASTER/MULTI MASTER modes:
107*
108* Consider the two sides:1) the master and 2)the slave.
109*
110* Master:
111* Single/multimaster operation set via DRXDAP_SINGLE_MASTER compile switch
112* + single master mode means no use of repeated starts
113* + multi master mode means use of repeated starts
114* Default is single master.
115* Default can be overriden by setting the compile switch DRXDAP_SINGLE_MASTER.
116*
117* Slave:
118* Single/multi master selected via the flags in the FASI protocol.
119* + single master means remember memory address between i2c packets
120* + multimaster means flush memory address between i2c packets
121* Default is single master, DAP FASI changes multi-master setting silently
122* into single master setting. This cannot be overrriden.
123*
124*/
125/* set default */
126#ifndef DRXDAP_SINGLE_MASTER
127#define DRXDAP_SINGLE_MASTER 0
128#endif
129
130/********************************************
131* Chunk/mode checking
132********************************************/
133/*
134* Comments about DRXDAP_MAX_WCHUNKSIZE in single or multi master mode and
135* in combination with short and long addressing format. All text below
136* assumes long addressing format. The table also includes information
137* for short ADDRessing format.
138*
139* In single master mode, data can be written by sending the register address
140* first, then two or four bytes of data in the next packet.
141* Because the device address plus a register address equals five bytes,
142* the mimimum chunk size must be five.
143* If ten-bit I2C device addresses are used, the minimum chunk size must be six,
144* because the I2C device address will then occupy two bytes when writing.
145*
146* Data in single master mode is transferred as follows:
147* <S> <devW> a0 a1 a2 a3 <P>
148* <S> <devW> d0 d1 [d2 d3] <P>
149* ..
150* or
151* ..
152* <S> <devW> a0 a1 a2 a3 <P>
153* <S> <devR> --- <P>
154*
155* In multi-master mode, the data must immediately follow the address (an I2C
156* stop resets the internal address), and hence the minimum chunk size is
157* 1 <I2C address> + 4 (register address) + 2 (data to send) = 7 bytes (8 if
158* 10-bit I2C device addresses are used).
159*
160* The 7-bit or 10-bit i2c address parameters is a runtime parameter.
161* The other parameters can be limited via compile time switches.
162*
163*-------------------------------------------------------------------------------
164*
165* Minimum chunk size table (in bytes):
166*
167* +----------------+----------------+
168* | 7b i2c addr | 10b i2c addr |
169* +----------------+----------------+
170* | single | multi | single | multi |
171* ------+--------+-------+--------+-------+
172* short | 3 | 5 | 4 | 6 |
173* long | 5 | 7 | 6 | 8 |
174* ------+--------+-------+--------+-------+
175*
176*/
177
178/* set default */
179#if !defined(DRXDAP_MAX_WCHUNKSIZE)
180#define DRXDAP_MAX_WCHUNKSIZE 254
181#endif
182
183/* check */
184#if ((DRXDAPFASI_LONG_ADDR_ALLOWED == 0) && (DRXDAPFASI_SHORT_ADDR_ALLOWED == 1))
185#if DRXDAP_SINGLE_MASTER
186#define DRXDAP_MAX_WCHUNKSIZE_MIN 3
187#else
188#define DRXDAP_MAX_WCHUNKSIZE_MIN 5
189#endif
190#else
191#if DRXDAP_SINGLE_MASTER
192#define DRXDAP_MAX_WCHUNKSIZE_MIN 5
193#else
194#define DRXDAP_MAX_WCHUNKSIZE_MIN 7
195#endif
196#endif
197
198#if DRXDAP_MAX_WCHUNKSIZE < DRXDAP_MAX_WCHUNKSIZE_MIN
199#if ((DRXDAPFASI_LONG_ADDR_ALLOWED == 0) && (DRXDAPFASI_SHORT_ADDR_ALLOWED == 1))
200#if DRXDAP_SINGLE_MASTER
201#error DRXDAP_MAX_WCHUNKSIZE must be at least 3 in single master mode
202*; /* illegal statement to force compiler error */
203#else
204#error DRXDAP_MAX_WCHUNKSIZE must be at least 5 in multi master mode
205*; /* illegal statement to force compiler error */
206#endif
207#else
208#if DRXDAP_SINGLE_MASTER
209#error DRXDAP_MAX_WCHUNKSIZE must be at least 5 in single master mode
210*; /* illegal statement to force compiler error */
211#else
212#error DRXDAP_MAX_WCHUNKSIZE must be at least 7 in multi master mode
213*; /* illegal statement to force compiler error */
214#endif
215#endif
216#endif
217
218/* set default */
219#if !defined(DRXDAP_MAX_RCHUNKSIZE)
220#define DRXDAP_MAX_RCHUNKSIZE 254
221#endif
222
223/* check */
224#if DRXDAP_MAX_RCHUNKSIZE < 2
225#error DRXDAP_MAX_RCHUNKSIZE must be at least 2
226*; /* illegal statement to force compiler error */
227#endif
228
229/* check */
230#if DRXDAP_MAX_RCHUNKSIZE & 1
231#error DRXDAP_MAX_RCHUNKSIZE must be even
232*; /* illegal statement to force compiler error */
233#endif
234
235/*-------- Public API functions ----------------------------------------------*/
236
237extern struct drx_access_func drx_dap_fasi_funct_g;
238
239#define DRXDAP_FASI_RMW 0x10000000
240#define DRXDAP_FASI_BROADCAST 0x20000000
241#define DRXDAP_FASI_CLEARCRC 0x80000000
242#define DRXDAP_FASI_SINGLE_MASTER 0xC0000000
243#define DRXDAP_FASI_MULTI_MASTER 0x40000000
244#define DRXDAP_FASI_SMM_SWITCH 0x40000000 /* single/multi master switch */
245#define DRXDAP_FASI_MODEFLAGS 0xC0000000
246#define DRXDAP_FASI_FLAGS 0xF0000000
247
248#define DRXDAP_FASI_ADDR2BLOCK(addr) (((addr)>>22)&0x3F)
249#define DRXDAP_FASI_ADDR2BANK(addr) (((addr)>>16)&0x3F)
250#define DRXDAP_FASI_ADDR2OFFSET(addr) ((addr)&0x7FFF)
251
252#define DRXDAP_FASI_SHORT_FORMAT(addr) (((addr) & 0xFC30FF80) == 0)
253#define DRXDAP_FASI_LONG_FORMAT(addr) (((addr) & 0xFC30FF80) != 0)
254#define DRXDAP_FASI_OFFSET_TOO_LARGE(addr) (((addr) & 0x00008000) != 0)
255
256#endif /* __DRX_DAP_FASI_H__ */
diff --git a/drivers/media/dvb-frontends/drx39xyj/drx_driver.h b/drivers/media/dvb-frontends/drx39xyj/drx_driver.h
new file mode 100644
index 000000000000..9076bf21cc8a
--- /dev/null
+++ b/drivers/media/dvb-frontends/drx39xyj/drx_driver.h
@@ -0,0 +1,2343 @@
1/*
2 Copyright (c), 2004-2005,2007-2010 Trident Microsystems, Inc.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
13 * Neither the name of Trident Microsystems nor Hauppauge Computer Works
14 nor the names of its contributors may be used to endorse or promote
15 products derived from this software without specific prior written
16 permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 POSSIBILITY OF SUCH DAMAGE.
29*/
30
31#ifndef __DRXDRIVER_H__
32#define __DRXDRIVER_H__
33
34#include <linux/kernel.h>
35#include <linux/errno.h>
36#include <linux/firmware.h>
37#include <linux/i2c.h>
38
39/*
40 * This structure contains the I2C address, the device ID and a user_data pointer.
41 * The user_data pointer can be used for application specific purposes.
42 */
43struct i2c_device_addr {
44 u16 i2c_addr; /* The I2C address of the device. */
45 u16 i2c_dev_id; /* The device identifier. */
46 void *user_data; /* User data pointer */
47};
48
49/**
50* \def IS_I2C_10BIT( addr )
51* \brief Determine if I2C address 'addr' is a 10 bits address or not.
52* \param addr The I2C address.
53* \return int.
54* \retval 0 if address is not a 10 bits I2C address.
55* \retval 1 if address is a 10 bits I2C address.
56*/
57#define IS_I2C_10BIT(addr) \
58 (((addr) & 0xF8) == 0xF0)
59
60/*------------------------------------------------------------------------------
61Exported FUNCTIONS
62------------------------------------------------------------------------------*/
63
64/**
65* \fn drxbsp_i2c_init()
66* \brief Initialize I2C communication module.
67* \return int Return status.
68* \retval 0 Initialization successful.
69* \retval -EIO Initialization failed.
70*/
71int drxbsp_i2c_init(void);
72
73/**
74* \fn drxbsp_i2c_term()
75* \brief Terminate I2C communication module.
76* \return int Return status.
77* \retval 0 Termination successful.
78* \retval -EIO Termination failed.
79*/
80int drxbsp_i2c_term(void);
81
82/**
83* \fn int drxbsp_i2c_write_read( struct i2c_device_addr *w_dev_addr,
84* u16 w_count,
85* u8 * wData,
86* struct i2c_device_addr *r_dev_addr,
87* u16 r_count,
88* u8 * r_data)
89* \brief Read and/or write count bytes from I2C bus, store them in data[].
90* \param w_dev_addr The device i2c address and the device ID to write to
91* \param w_count The number of bytes to write
92* \param wData The array to write the data to
93* \param r_dev_addr The device i2c address and the device ID to read from
94* \param r_count The number of bytes to read
95* \param r_data The array to read the data from
96* \return int Return status.
97* \retval 0 Succes.
98* \retval -EIO Failure.
99* \retval -EINVAL Parameter 'wcount' is not zero but parameter
100* 'wdata' contains NULL.
101* Idem for 'rcount' and 'rdata'.
102* Both w_dev_addr and r_dev_addr are NULL.
103*
104* This function must implement an atomic write and/or read action on the I2C bus
105* No other process may use the I2C bus when this function is executing.
106* The critical section of this function runs from and including the I2C
107* write, up to and including the I2C read action.
108*
109* The device ID can be useful if several devices share an I2C address.
110* It can be used to control a "switch" on the I2C bus to the correct device.
111*/
112int drxbsp_i2c_write_read(struct i2c_device_addr *w_dev_addr,
113 u16 w_count,
114 u8 *wData,
115 struct i2c_device_addr *r_dev_addr,
116 u16 r_count, u8 *r_data);
117
118/**
119* \fn drxbsp_i2c_error_text()
120* \brief Returns a human readable error.
121* Counter part of numerical drx_i2c_error_g.
122*
123* \return char* Pointer to human readable error text.
124*/
125char *drxbsp_i2c_error_text(void);
126
127/**
128* \var drx_i2c_error_g;
129* \brief I2C specific error codes, platform dependent.
130*/
131extern int drx_i2c_error_g;
132
133#define TUNER_MODE_SUB0 0x0001 /* for sub-mode (e.g. RF-AGC setting) */
134#define TUNER_MODE_SUB1 0x0002 /* for sub-mode (e.g. RF-AGC setting) */
135#define TUNER_MODE_SUB2 0x0004 /* for sub-mode (e.g. RF-AGC setting) */
136#define TUNER_MODE_SUB3 0x0008 /* for sub-mode (e.g. RF-AGC setting) */
137#define TUNER_MODE_SUB4 0x0010 /* for sub-mode (e.g. RF-AGC setting) */
138#define TUNER_MODE_SUB5 0x0020 /* for sub-mode (e.g. RF-AGC setting) */
139#define TUNER_MODE_SUB6 0x0040 /* for sub-mode (e.g. RF-AGC setting) */
140#define TUNER_MODE_SUB7 0x0080 /* for sub-mode (e.g. RF-AGC setting) */
141
142#define TUNER_MODE_DIGITAL 0x0100 /* for digital channel (e.g. DVB-T) */
143#define TUNER_MODE_ANALOG 0x0200 /* for analog channel (e.g. PAL) */
144#define TUNER_MODE_SWITCH 0x0400 /* during channel switch & scanning */
145#define TUNER_MODE_LOCK 0x0800 /* after tuner has locked */
146#define TUNER_MODE_6MHZ 0x1000 /* for 6MHz bandwidth channels */
147#define TUNER_MODE_7MHZ 0x2000 /* for 7MHz bandwidth channels */
148#define TUNER_MODE_8MHZ 0x4000 /* for 8MHz bandwidth channels */
149
150#define TUNER_MODE_SUB_MAX 8
151#define TUNER_MODE_SUBALL (TUNER_MODE_SUB0 | TUNER_MODE_SUB1 | \
152 TUNER_MODE_SUB2 | TUNER_MODE_SUB3 | \
153 TUNER_MODE_SUB4 | TUNER_MODE_SUB5 | \
154 TUNER_MODE_SUB6 | TUNER_MODE_SUB7)
155
156
157enum tuner_lock_status {
158 TUNER_LOCKED,
159 TUNER_NOT_LOCKED
160};
161
162struct tuner_common {
163 char *name; /* Tuner brand & type name */
164 s32 min_freq_rf; /* Lowest RF input frequency, in kHz */
165 s32 max_freq_rf; /* Highest RF input frequency, in kHz */
166
167 u8 sub_mode; /* Index to sub-mode in use */
168 char ***sub_mode_descriptions; /* Pointer to description of sub-modes */
169 u8 sub_modes; /* Number of available sub-modes */
170
171 /* The following fields will be either 0, NULL or false and do not need
172 initialisation */
173 void *self_check; /* gives proof of initialization */
174 bool programmed; /* only valid if self_check is OK */
175 s32 r_ffrequency; /* only valid if programmed */
176 s32 i_ffrequency; /* only valid if programmed */
177
178 void *my_user_data; /* pointer to associated demod instance */
179 u16 my_capabilities; /* value for storing application flags */
180};
181
182struct tuner_instance;
183
184typedef int(*tuner_open_func_t) (struct tuner_instance *tuner);
185typedef int(*tuner_close_func_t) (struct tuner_instance *tuner);
186
187typedef int(*tuner_set_frequency_func_t) (struct tuner_instance *tuner,
188 u32 mode,
189 s32
190 frequency);
191
192typedef int(*tuner_get_frequency_func_t) (struct tuner_instance *tuner,
193 u32 mode,
194 s32 *
195 r_ffrequency,
196 s32 *
197 i_ffrequency);
198
199typedef int(*tuner_lock_status_func_t) (struct tuner_instance *tuner,
200 enum tuner_lock_status *
201 lock_stat);
202
203typedef int(*tune_ri2c_write_read_func_t) (struct tuner_instance *tuner,
204 struct i2c_device_addr *
205 w_dev_addr, u16 w_count,
206 u8 *wData,
207 struct i2c_device_addr *
208 r_dev_addr, u16 r_count,
209 u8 *r_data);
210
211struct tuner_ops {
212 tuner_open_func_t open_func;
213 tuner_close_func_t close_func;
214 tuner_set_frequency_func_t set_frequency_func;
215 tuner_get_frequency_func_t get_frequency_func;
216 tuner_lock_status_func_t lock_status_func;
217 tune_ri2c_write_read_func_t i2c_write_read_func;
218
219};
220
221struct tuner_instance {
222 struct i2c_device_addr my_i2c_dev_addr;
223 struct tuner_common *my_common_attr;
224 void *my_ext_attr;
225 struct tuner_ops *my_funct;
226};
227
228int drxbsp_tuner_set_frequency(struct tuner_instance *tuner,
229 u32 mode,
230 s32 frequency);
231
232int drxbsp_tuner_get_frequency(struct tuner_instance *tuner,
233 u32 mode,
234 s32 *r_ffrequency,
235 s32 *i_ffrequency);
236
237int drxbsp_tuner_default_i2c_write_read(struct tuner_instance *tuner,
238 struct i2c_device_addr *w_dev_addr,
239 u16 w_count,
240 u8 *wData,
241 struct i2c_device_addr *r_dev_addr,
242 u16 r_count, u8 *r_data);
243
244/**************
245*
246* This section configures the DRX Data Access Protocols (DAPs).
247*
248**************/
249
250/**
251* \def DRXDAP_SINGLE_MASTER
252* \brief Enable I2C single or I2C multimaster mode on host.
253*
254* Set to 1 to enable single master mode
255* Set to 0 to enable multi master mode
256*
257* The actual DAP implementation may be restricted to only one of the modes.
258* A compiler warning or error will be generated if the DAP implementation
259* overides or cannot handle the mode defined below.
260*
261*/
262#ifndef DRXDAP_SINGLE_MASTER
263#define DRXDAP_SINGLE_MASTER 1
264#endif
265
266/**
267* \def DRXDAP_MAX_WCHUNKSIZE
268* \brief Defines maximum chunksize of an i2c write action by host.
269*
270* This indicates the maximum size of data the I2C device driver is able to
271* write at a time. This includes I2C device address and register addressing.
272*
273* This maximum size may be restricted by the actual DAP implementation.
274* A compiler warning or error will be generated if the DAP implementation
275* overides or cannot handle the chunksize defined below.
276*
277* Beware that the DAP uses DRXDAP_MAX_WCHUNKSIZE to create a temporary data
278* buffer. Do not undefine or choose too large, unless your system is able to
279* handle a stack buffer of that size.
280*
281*/
282#ifndef DRXDAP_MAX_WCHUNKSIZE
283#define DRXDAP_MAX_WCHUNKSIZE 60
284#endif
285
286/**
287* \def DRXDAP_MAX_RCHUNKSIZE
288* \brief Defines maximum chunksize of an i2c read action by host.
289*
290* This indicates the maximum size of data the I2C device driver is able to read
291* at a time. Minimum value is 2. Also, the read chunk size must be even.
292*
293* This maximum size may be restricted by the actual DAP implementation.
294* A compiler warning or error will be generated if the DAP implementation
295* overides or cannot handle the chunksize defined below.
296*
297*/
298#ifndef DRXDAP_MAX_RCHUNKSIZE
299#define DRXDAP_MAX_RCHUNKSIZE 60
300#endif
301
302/**************
303*
304* This section describes drxdriver defines.
305*
306**************/
307
308/**
309* \def DRX_UNKNOWN
310* \brief Generic UNKNOWN value for DRX enumerated types.
311*
312* Used to indicate that the parameter value is unknown or not yet initalized.
313*/
314#ifndef DRX_UNKNOWN
315#define DRX_UNKNOWN (254)
316#endif
317
318/**
319* \def DRX_AUTO
320* \brief Generic AUTO value for DRX enumerated types.
321*
322* Used to instruct the driver to automatically determine the value of the
323* parameter.
324*/
325#ifndef DRX_AUTO
326#define DRX_AUTO (255)
327#endif
328
329/**************
330*
331* This section describes flag definitions for the device capbilities.
332*
333**************/
334
335/**
336* \brief LNA capability flag
337*
338* Device has a Low Noise Amplifier
339*
340*/
341#define DRX_CAPABILITY_HAS_LNA (1UL << 0)
342/**
343* \brief OOB-RX capability flag
344*
345* Device has OOB-RX
346*
347*/
348#define DRX_CAPABILITY_HAS_OOBRX (1UL << 1)
349/**
350* \brief ATV capability flag
351*
352* Device has ATV
353*
354*/
355#define DRX_CAPABILITY_HAS_ATV (1UL << 2)
356/**
357* \brief DVB-T capability flag
358*
359* Device has DVB-T
360*
361*/
362#define DRX_CAPABILITY_HAS_DVBT (1UL << 3)
363/**
364* \brief ITU-B capability flag
365*
366* Device has ITU-B
367*
368*/
369#define DRX_CAPABILITY_HAS_ITUB (1UL << 4)
370/**
371* \brief Audio capability flag
372*
373* Device has Audio
374*
375*/
376#define DRX_CAPABILITY_HAS_AUD (1UL << 5)
377/**
378* \brief SAW switch capability flag
379*
380* Device has SAW switch
381*
382*/
383#define DRX_CAPABILITY_HAS_SAWSW (1UL << 6)
384/**
385* \brief GPIO1 capability flag
386*
387* Device has GPIO1
388*
389*/
390#define DRX_CAPABILITY_HAS_GPIO1 (1UL << 7)
391/**
392* \brief GPIO2 capability flag
393*
394* Device has GPIO2
395*
396*/
397#define DRX_CAPABILITY_HAS_GPIO2 (1UL << 8)
398/**
399* \brief IRQN capability flag
400*
401* Device has IRQN
402*
403*/
404#define DRX_CAPABILITY_HAS_IRQN (1UL << 9)
405/**
406* \brief 8VSB capability flag
407*
408* Device has 8VSB
409*
410*/
411#define DRX_CAPABILITY_HAS_8VSB (1UL << 10)
412/**
413* \brief SMA-TX capability flag
414*
415* Device has SMATX
416*
417*/
418#define DRX_CAPABILITY_HAS_SMATX (1UL << 11)
419/**
420* \brief SMA-RX capability flag
421*
422* Device has SMARX
423*
424*/
425#define DRX_CAPABILITY_HAS_SMARX (1UL << 12)
426/**
427* \brief ITU-A/C capability flag
428*
429* Device has ITU-A/C
430*
431*/
432#define DRX_CAPABILITY_HAS_ITUAC (1UL << 13)
433
434/*-------------------------------------------------------------------------
435MACROS
436-------------------------------------------------------------------------*/
437/* Macros to stringify the version number */
438#define DRX_VERSIONSTRING(MAJOR, MINOR, PATCH) \
439 DRX_VERSIONSTRING_HELP(MAJOR)"." \
440 DRX_VERSIONSTRING_HELP(MINOR)"." \
441 DRX_VERSIONSTRING_HELP(PATCH)
442#define DRX_VERSIONSTRING_HELP(NUM) #NUM
443
444/**
445* \brief Macro to create byte array elements from 16 bit integers.
446* This macro is used to create byte arrays for block writes.
447* Block writes speed up I2C traffic between host and demod.
448* The macro takes care of the required byte order in a 16 bits word.
449* x->lowbyte(x), highbyte(x)
450*/
451#define DRX_16TO8(x) ((u8) (((u16)x) & 0xFF)), \
452 ((u8)((((u16)x)>>8)&0xFF))
453
454/**
455* \brief Macro to sign extend signed 9 bit value to signed 16 bit value
456*/
457#define DRX_S9TOS16(x) ((((u16)x)&0x100) ? ((s16)((u16)(x)|0xFF00)) : (x))
458
459/**
460* \brief Macro to sign extend signed 9 bit value to signed 16 bit value
461*/
462#define DRX_S24TODRXFREQ(x) ((((u32) x) & 0x00800000UL) ? \
463 ((s32) \
464 (((u32) x) | 0xFF000000)) : \
465 ((s32) x))
466
467/**
468* \brief Macro to convert 16 bit register value to a s32
469*/
470#define DRX_U16TODRXFREQ(x) ((x & 0x8000) ? \
471 ((s32) \
472 (((u32) x) | 0xFFFF0000)) : \
473 ((s32) x))
474
475/*-------------------------------------------------------------------------
476ENUM
477-------------------------------------------------------------------------*/
478
479/**
480* \enum enum drx_standard
481* \brief Modulation standards.
482*/
483enum drx_standard {
484 DRX_STANDARD_DVBT = 0, /**< Terrestrial DVB-T. */
485 DRX_STANDARD_8VSB, /**< Terrestrial 8VSB. */
486 DRX_STANDARD_NTSC, /**< Terrestrial\Cable analog NTSC. */
487 DRX_STANDARD_PAL_SECAM_BG,
488 /**< Terrestrial analog PAL/SECAM B/G */
489 DRX_STANDARD_PAL_SECAM_DK,
490 /**< Terrestrial analog PAL/SECAM D/K */
491 DRX_STANDARD_PAL_SECAM_I,
492 /**< Terrestrial analog PAL/SECAM I */
493 DRX_STANDARD_PAL_SECAM_L,
494 /**< Terrestrial analog PAL/SECAM L
495 with negative modulation */
496 DRX_STANDARD_PAL_SECAM_LP,
497 /**< Terrestrial analog PAL/SECAM L
498 with positive modulation */
499 DRX_STANDARD_ITU_A, /**< Cable ITU ANNEX A. */
500 DRX_STANDARD_ITU_B, /**< Cable ITU ANNEX B. */
501 DRX_STANDARD_ITU_C, /**< Cable ITU ANNEX C. */
502 DRX_STANDARD_ITU_D, /**< Cable ITU ANNEX D. */
503 DRX_STANDARD_FM, /**< Terrestrial\Cable FM radio */
504 DRX_STANDARD_DTMB, /**< Terrestrial DTMB standard (China)*/
505 DRX_STANDARD_UNKNOWN = DRX_UNKNOWN,
506 /**< Standard unknown. */
507 DRX_STANDARD_AUTO = DRX_AUTO
508 /**< Autodetect standard. */
509};
510
511/**
512* \enum enum drx_standard
513* \brief Modulation sub-standards.
514*/
515enum drx_substandard {
516 DRX_SUBSTANDARD_MAIN = 0, /**< Main subvariant of standard */
517 DRX_SUBSTANDARD_ATV_BG_SCANDINAVIA,
518 DRX_SUBSTANDARD_ATV_DK_POLAND,
519 DRX_SUBSTANDARD_ATV_DK_CHINA,
520 DRX_SUBSTANDARD_UNKNOWN = DRX_UNKNOWN,
521 /**< Sub-standard unknown. */
522 DRX_SUBSTANDARD_AUTO = DRX_AUTO
523 /**< Auto (default) sub-standard */
524};
525
526/**
527* \enum enum drx_bandwidth
528* \brief Channel bandwidth or channel spacing.
529*/
530enum drx_bandwidth {
531 DRX_BANDWIDTH_8MHZ = 0, /**< Bandwidth 8 MHz. */
532 DRX_BANDWIDTH_7MHZ, /**< Bandwidth 7 MHz. */
533 DRX_BANDWIDTH_6MHZ, /**< Bandwidth 6 MHz. */
534 DRX_BANDWIDTH_UNKNOWN = DRX_UNKNOWN,
535 /**< Bandwidth unknown. */
536 DRX_BANDWIDTH_AUTO = DRX_AUTO
537 /**< Auto Set Bandwidth */
538};
539
540/**
541* \enum enum drx_mirror
542* \brief Indicate if channel spectrum is mirrored or not.
543*/
544enum drx_mirror {
545 DRX_MIRROR_NO = 0, /**< Spectrum is not mirrored. */
546 DRX_MIRROR_YES, /**< Spectrum is mirrored. */
547 DRX_MIRROR_UNKNOWN = DRX_UNKNOWN,
548 /**< Unknown if spectrum is mirrored. */
549 DRX_MIRROR_AUTO = DRX_AUTO
550 /**< Autodetect if spectrum is mirrored. */
551};
552
553/**
554* \enum enum drx_modulation
555* \brief Constellation type of the channel.
556*/
557enum drx_modulation {
558 DRX_CONSTELLATION_BPSK = 0, /**< Modulation is BPSK. */
559 DRX_CONSTELLATION_QPSK, /**< Constellation is QPSK. */
560 DRX_CONSTELLATION_PSK8, /**< Constellation is PSK8. */
561 DRX_CONSTELLATION_QAM16, /**< Constellation is QAM16. */
562 DRX_CONSTELLATION_QAM32, /**< Constellation is QAM32. */
563 DRX_CONSTELLATION_QAM64, /**< Constellation is QAM64. */
564 DRX_CONSTELLATION_QAM128, /**< Constellation is QAM128. */
565 DRX_CONSTELLATION_QAM256, /**< Constellation is QAM256. */
566 DRX_CONSTELLATION_QAM512, /**< Constellation is QAM512. */
567 DRX_CONSTELLATION_QAM1024, /**< Constellation is QAM1024. */
568 DRX_CONSTELLATION_QPSK_NR, /**< Constellation is QPSK_NR */
569 DRX_CONSTELLATION_UNKNOWN = DRX_UNKNOWN,
570 /**< Constellation unknown. */
571 DRX_CONSTELLATION_AUTO = DRX_AUTO
572 /**< Autodetect constellation. */
573};
574
575/**
576* \enum enum drx_hierarchy
577* \brief Hierarchy of the channel.
578*/
579enum drx_hierarchy {
580 DRX_HIERARCHY_NONE = 0, /**< None hierarchical channel. */
581 DRX_HIERARCHY_ALPHA1, /**< Hierarchical channel, alpha=1. */
582 DRX_HIERARCHY_ALPHA2, /**< Hierarchical channel, alpha=2. */
583 DRX_HIERARCHY_ALPHA4, /**< Hierarchical channel, alpha=4. */
584 DRX_HIERARCHY_UNKNOWN = DRX_UNKNOWN,
585 /**< Hierarchy unknown. */
586 DRX_HIERARCHY_AUTO = DRX_AUTO
587 /**< Autodetect hierarchy. */
588};
589
590/**
591* \enum enum drx_priority
592* \brief Channel priority in case of hierarchical transmission.
593*/
594enum drx_priority {
595 DRX_PRIORITY_LOW = 0, /**< Low priority channel. */
596 DRX_PRIORITY_HIGH, /**< High priority channel. */
597 DRX_PRIORITY_UNKNOWN = DRX_UNKNOWN
598 /**< Priority unknown. */
599};
600
601/**
602* \enum enum drx_coderate
603* \brief Channel priority in case of hierarchical transmission.
604*/
605enum drx_coderate {
606 DRX_CODERATE_1DIV2 = 0, /**< Code rate 1/2nd. */
607 DRX_CODERATE_2DIV3, /**< Code rate 2/3nd. */
608 DRX_CODERATE_3DIV4, /**< Code rate 3/4nd. */
609 DRX_CODERATE_5DIV6, /**< Code rate 5/6nd. */
610 DRX_CODERATE_7DIV8, /**< Code rate 7/8nd. */
611 DRX_CODERATE_UNKNOWN = DRX_UNKNOWN,
612 /**< Code rate unknown. */
613 DRX_CODERATE_AUTO = DRX_AUTO
614 /**< Autodetect code rate. */
615};
616
617/**
618* \enum enum drx_guard
619* \brief Guard interval of a channel.
620*/
621enum drx_guard {
622 DRX_GUARD_1DIV32 = 0, /**< Guard interval 1/32nd. */
623 DRX_GUARD_1DIV16, /**< Guard interval 1/16th. */
624 DRX_GUARD_1DIV8, /**< Guard interval 1/8th. */
625 DRX_GUARD_1DIV4, /**< Guard interval 1/4th. */
626 DRX_GUARD_UNKNOWN = DRX_UNKNOWN,
627 /**< Guard interval unknown. */
628 DRX_GUARD_AUTO = DRX_AUTO
629 /**< Autodetect guard interval. */
630};
631
632/**
633* \enum enum drx_fft_mode
634* \brief FFT mode.
635*/
636enum drx_fft_mode {
637 DRX_FFTMODE_2K = 0, /**< 2K FFT mode. */
638 DRX_FFTMODE_4K, /**< 4K FFT mode. */
639 DRX_FFTMODE_8K, /**< 8K FFT mode. */
640 DRX_FFTMODE_UNKNOWN = DRX_UNKNOWN,
641 /**< FFT mode unknown. */
642 DRX_FFTMODE_AUTO = DRX_AUTO
643 /**< Autodetect FFT mode. */
644};
645
646/**
647* \enum enum drx_classification
648* \brief Channel classification.
649*/
650enum drx_classification {
651 DRX_CLASSIFICATION_GAUSS = 0, /**< Gaussion noise. */
652 DRX_CLASSIFICATION_HVY_GAUSS, /**< Heavy Gaussion noise. */
653 DRX_CLASSIFICATION_COCHANNEL, /**< Co-channel. */
654 DRX_CLASSIFICATION_STATIC, /**< Static echo. */
655 DRX_CLASSIFICATION_MOVING, /**< Moving echo. */
656 DRX_CLASSIFICATION_ZERODB, /**< Zero dB echo. */
657 DRX_CLASSIFICATION_UNKNOWN = DRX_UNKNOWN,
658 /**< Unknown classification */
659 DRX_CLASSIFICATION_AUTO = DRX_AUTO
660 /**< Autodetect classification. */
661};
662
663/**
664* /enum enum drx_interleave_mode
665* /brief Interleave modes
666*/
667enum drx_interleave_mode {
668 DRX_INTERLEAVEMODE_I128_J1 = 0,
669 DRX_INTERLEAVEMODE_I128_J1_V2,
670 DRX_INTERLEAVEMODE_I128_J2,
671 DRX_INTERLEAVEMODE_I64_J2,
672 DRX_INTERLEAVEMODE_I128_J3,
673 DRX_INTERLEAVEMODE_I32_J4,
674 DRX_INTERLEAVEMODE_I128_J4,
675 DRX_INTERLEAVEMODE_I16_J8,
676 DRX_INTERLEAVEMODE_I128_J5,
677 DRX_INTERLEAVEMODE_I8_J16,
678 DRX_INTERLEAVEMODE_I128_J6,
679 DRX_INTERLEAVEMODE_RESERVED_11,
680 DRX_INTERLEAVEMODE_I128_J7,
681 DRX_INTERLEAVEMODE_RESERVED_13,
682 DRX_INTERLEAVEMODE_I128_J8,
683 DRX_INTERLEAVEMODE_RESERVED_15,
684 DRX_INTERLEAVEMODE_I12_J17,
685 DRX_INTERLEAVEMODE_I5_J4,
686 DRX_INTERLEAVEMODE_B52_M240,
687 DRX_INTERLEAVEMODE_B52_M720,
688 DRX_INTERLEAVEMODE_B52_M48,
689 DRX_INTERLEAVEMODE_B52_M0,
690 DRX_INTERLEAVEMODE_UNKNOWN = DRX_UNKNOWN,
691 /**< Unknown interleave mode */
692 DRX_INTERLEAVEMODE_AUTO = DRX_AUTO
693 /**< Autodetect interleave mode */
694};
695
696/**
697* \enum enum drx_carrier_mode
698* \brief Channel Carrier Mode.
699*/
700enum drx_carrier_mode {
701 DRX_CARRIER_MULTI = 0, /**< Multi carrier mode */
702 DRX_CARRIER_SINGLE, /**< Single carrier mode */
703 DRX_CARRIER_UNKNOWN = DRX_UNKNOWN,
704 /**< Carrier mode unknown. */
705 DRX_CARRIER_AUTO = DRX_AUTO /**< Autodetect carrier mode */
706};
707
708/**
709* \enum enum drx_frame_mode
710* \brief Channel Frame Mode.
711*/
712enum drx_frame_mode {
713 DRX_FRAMEMODE_420 = 0, /**< 420 with variable PN */
714 DRX_FRAMEMODE_595, /**< 595 */
715 DRX_FRAMEMODE_945, /**< 945 with variable PN */
716 DRX_FRAMEMODE_420_FIXED_PN,
717 /**< 420 with fixed PN */
718 DRX_FRAMEMODE_945_FIXED_PN,
719 /**< 945 with fixed PN */
720 DRX_FRAMEMODE_UNKNOWN = DRX_UNKNOWN,
721 /**< Frame mode unknown. */
722 DRX_FRAMEMODE_AUTO = DRX_AUTO
723 /**< Autodetect frame mode */
724};
725
726/**
727* \enum enum drx_tps_frame
728* \brief Frame number in current super-frame.
729*/
730enum drx_tps_frame {
731 DRX_TPS_FRAME1 = 0, /**< TPS frame 1. */
732 DRX_TPS_FRAME2, /**< TPS frame 2. */
733 DRX_TPS_FRAME3, /**< TPS frame 3. */
734 DRX_TPS_FRAME4, /**< TPS frame 4. */
735 DRX_TPS_FRAME_UNKNOWN = DRX_UNKNOWN
736 /**< TPS frame unknown. */
737};
738
739/**
740* \enum enum drx_ldpc
741* \brief TPS LDPC .
742*/
743enum drx_ldpc {
744 DRX_LDPC_0_4 = 0, /**< LDPC 0.4 */
745 DRX_LDPC_0_6, /**< LDPC 0.6 */
746 DRX_LDPC_0_8, /**< LDPC 0.8 */
747 DRX_LDPC_UNKNOWN = DRX_UNKNOWN,
748 /**< LDPC unknown. */
749 DRX_LDPC_AUTO = DRX_AUTO /**< Autodetect LDPC */
750};
751
752/**
753* \enum enum drx_pilot_mode
754* \brief Pilot modes in DTMB.
755*/
756enum drx_pilot_mode {
757 DRX_PILOT_ON = 0, /**< Pilot On */
758 DRX_PILOT_OFF, /**< Pilot Off */
759 DRX_PILOT_UNKNOWN = DRX_UNKNOWN,
760 /**< Pilot unknown. */
761 DRX_PILOT_AUTO = DRX_AUTO /**< Autodetect Pilot */
762};
763
764/**
765 * enum drxu_code_action - indicate if firmware has to be uploaded or verified.
766 * @UCODE_UPLOAD: Upload the microcode image to device
767 * @UCODE_VERIFY: Compare microcode image with code on device
768 */
769enum drxu_code_action {
770 UCODE_UPLOAD,
771 UCODE_VERIFY
772};
773
774/**
775* \enum enum drx_lock_status * \brief Used to reflect current lock status of demodulator.
776*
777* The generic lock states have device dependent semantics.
778
779 DRX_NEVER_LOCK = 0,
780 **< Device will never lock on this signal *
781 DRX_NOT_LOCKED,
782 **< Device has no lock at all *
783 DRX_LOCK_STATE_1,
784 **< Generic lock state *
785 DRX_LOCK_STATE_2,
786 **< Generic lock state *
787 DRX_LOCK_STATE_3,
788 **< Generic lock state *
789 DRX_LOCK_STATE_4,
790 **< Generic lock state *
791 DRX_LOCK_STATE_5,
792 **< Generic lock state *
793 DRX_LOCK_STATE_6,
794 **< Generic lock state *
795 DRX_LOCK_STATE_7,
796 **< Generic lock state *
797 DRX_LOCK_STATE_8,
798 **< Generic lock state *
799 DRX_LOCK_STATE_9,
800 **< Generic lock state *
801 DRX_LOCKED **< Device is in lock *
802*/
803
804enum drx_lock_status {
805 DRX_NEVER_LOCK = 0,
806 DRX_NOT_LOCKED,
807 DRX_LOCK_STATE_1,
808 DRX_LOCK_STATE_2,
809 DRX_LOCK_STATE_3,
810 DRX_LOCK_STATE_4,
811 DRX_LOCK_STATE_5,
812 DRX_LOCK_STATE_6,
813 DRX_LOCK_STATE_7,
814 DRX_LOCK_STATE_8,
815 DRX_LOCK_STATE_9,
816 DRX_LOCKED
817};
818
819/**
820* \enum enum drx_uio* \brief Used to address a User IO (UIO).
821*/
822enum drx_uio {
823 DRX_UIO1,
824 DRX_UIO2,
825 DRX_UIO3,
826 DRX_UIO4,
827 DRX_UIO5,
828 DRX_UIO6,
829 DRX_UIO7,
830 DRX_UIO8,
831 DRX_UIO9,
832 DRX_UIO10,
833 DRX_UIO11,
834 DRX_UIO12,
835 DRX_UIO13,
836 DRX_UIO14,
837 DRX_UIO15,
838 DRX_UIO16,
839 DRX_UIO17,
840 DRX_UIO18,
841 DRX_UIO19,
842 DRX_UIO20,
843 DRX_UIO21,
844 DRX_UIO22,
845 DRX_UIO23,
846 DRX_UIO24,
847 DRX_UIO25,
848 DRX_UIO26,
849 DRX_UIO27,
850 DRX_UIO28,
851 DRX_UIO29,
852 DRX_UIO30,
853 DRX_UIO31,
854 DRX_UIO32,
855 DRX_UIO_MAX = DRX_UIO32
856};
857
858/**
859* \enum enum drxuio_mode * \brief Used to configure the modus oprandi of a UIO.
860*
861* DRX_UIO_MODE_FIRMWARE is an old uio mode.
862* It is replaced by the modes DRX_UIO_MODE_FIRMWARE0 .. DRX_UIO_MODE_FIRMWARE9.
863* To be backward compatible DRX_UIO_MODE_FIRMWARE is equivalent to
864* DRX_UIO_MODE_FIRMWARE0.
865*/
866enum drxuio_mode {
867 DRX_UIO_MODE_DISABLE = 0x01,
868 /**< not used, pin is configured as input */
869 DRX_UIO_MODE_READWRITE = 0x02,
870 /**< used for read/write by application */
871 DRX_UIO_MODE_FIRMWARE = 0x04,
872 /**< controlled by firmware, function 0 */
873 DRX_UIO_MODE_FIRMWARE0 = DRX_UIO_MODE_FIRMWARE,
874 /**< same as above */
875 DRX_UIO_MODE_FIRMWARE1 = 0x08,
876 /**< controlled by firmware, function 1 */
877 DRX_UIO_MODE_FIRMWARE2 = 0x10,
878 /**< controlled by firmware, function 2 */
879 DRX_UIO_MODE_FIRMWARE3 = 0x20,
880 /**< controlled by firmware, function 3 */
881 DRX_UIO_MODE_FIRMWARE4 = 0x40,
882 /**< controlled by firmware, function 4 */
883 DRX_UIO_MODE_FIRMWARE5 = 0x80
884 /**< controlled by firmware, function 5 */
885};
886
887/**
888* \enum enum drxoob_downstream_standard * \brief Used to select OOB standard.
889*
890* Based on ANSI 55-1 and 55-2
891*/
892enum drxoob_downstream_standard {
893 DRX_OOB_MODE_A = 0,
894 /**< ANSI 55-1 */
895 DRX_OOB_MODE_B_GRADE_A,
896 /**< ANSI 55-2 A */
897 DRX_OOB_MODE_B_GRADE_B
898 /**< ANSI 55-2 B */
899};
900
901/*-------------------------------------------------------------------------
902STRUCTS
903-------------------------------------------------------------------------*/
904
905/*============================================================================*/
906/*============================================================================*/
907/*== CTRL CFG related data structures ========================================*/
908/*============================================================================*/
909/*============================================================================*/
910
911#ifndef DRX_CFG_BASE
912#define DRX_CFG_BASE 0
913#endif
914
915#define DRX_CFG_MPEG_OUTPUT (DRX_CFG_BASE + 0) /* MPEG TS output */
916#define DRX_CFG_PKTERR (DRX_CFG_BASE + 1) /* Packet Error */
917#define DRX_CFG_SYMCLK_OFFS (DRX_CFG_BASE + 2) /* Symbol Clk Offset */
918#define DRX_CFG_SMA (DRX_CFG_BASE + 3) /* Smart Antenna */
919#define DRX_CFG_PINSAFE (DRX_CFG_BASE + 4) /* Pin safe mode */
920#define DRX_CFG_SUBSTANDARD (DRX_CFG_BASE + 5) /* substandard */
921#define DRX_CFG_AUD_VOLUME (DRX_CFG_BASE + 6) /* volume */
922#define DRX_CFG_AUD_RDS (DRX_CFG_BASE + 7) /* rds */
923#define DRX_CFG_AUD_AUTOSOUND (DRX_CFG_BASE + 8) /* ASS & ASC */
924#define DRX_CFG_AUD_ASS_THRES (DRX_CFG_BASE + 9) /* ASS Thresholds */
925#define DRX_CFG_AUD_DEVIATION (DRX_CFG_BASE + 10) /* Deviation */
926#define DRX_CFG_AUD_PRESCALE (DRX_CFG_BASE + 11) /* Prescale */
927#define DRX_CFG_AUD_MIXER (DRX_CFG_BASE + 12) /* Mixer */
928#define DRX_CFG_AUD_AVSYNC (DRX_CFG_BASE + 13) /* AVSync */
929#define DRX_CFG_AUD_CARRIER (DRX_CFG_BASE + 14) /* Audio carriers */
930#define DRX_CFG_I2S_OUTPUT (DRX_CFG_BASE + 15) /* I2S output */
931#define DRX_CFG_ATV_STANDARD (DRX_CFG_BASE + 16) /* ATV standard */
932#define DRX_CFG_SQI_SPEED (DRX_CFG_BASE + 17) /* SQI speed */
933#define DRX_CTRL_CFG_MAX (DRX_CFG_BASE + 18) /* never to be used */
934
935#define DRX_CFG_PINS_SAFE_MODE DRX_CFG_PINSAFE
936/*============================================================================*/
937/*============================================================================*/
938/*== CTRL related data structures ============================================*/
939/*============================================================================*/
940/*============================================================================*/
941
942/**
943 * struct drxu_code_info Parameters for microcode upload and verfiy.
944 *
945 * @mc_file: microcode file name
946 *
947 * Used by DRX_CTRL_LOAD_UCODE and DRX_CTRL_VERIFY_UCODE
948 */
949struct drxu_code_info {
950 char *mc_file;
951};
952
953/**
954* \struct drx_mc_version_rec_t
955* \brief Microcode version record
956* Version numbers are stored in BCD format, as usual:
957* o major number = bits 31-20 (first three nibbles of MSW)
958* o minor number = bits 19-16 (fourth nibble of MSW)
959* o patch number = bits 15-0 (remaining nibbles in LSW)
960*
961* The device type indicates for which the device is meant. It is based on the
962* JTAG ID, using everything except the bond ID and the metal fix.
963*
964* Special values:
965* - mc_dev_type == 0 => any device allowed
966* - mc_base_version == 0.0.0 => full microcode (mc_version is the version)
967* - mc_base_version != 0.0.0 => patch microcode, the base microcode version
968* (mc_version is the version)
969*/
970#define AUX_VER_RECORD 0x8000
971
972struct drx_mc_version_rec {
973 u16 aux_type; /* type of aux data - 0x8000 for version record */
974 u32 mc_dev_type; /* device type, based on JTAG ID */
975 u32 mc_version; /* version of microcode */
976 u32 mc_base_version; /* in case of patch: the original microcode version */
977};
978
979/*========================================*/
980
981/**
982* \struct drx_filter_info_t
983* \brief Parameters for loading filter coefficients
984*
985* Used by DRX_CTRL_LOAD_FILTER
986*/
987struct drx_filter_info {
988 u8 *data_re;
989 /**< pointer to coefficients for RE */
990 u8 *data_im;
991 /**< pointer to coefficients for IM */
992 u16 size_re;
993 /**< size of coefficients for RE */
994 u16 size_im;
995 /**< size of coefficients for IM */
996};
997
998/*========================================*/
999
1000/**
1001* \struct struct drx_channel * \brief The set of parameters describing a single channel.
1002*
1003* Used by DRX_CTRL_SET_CHANNEL and DRX_CTRL_GET_CHANNEL.
1004* Only certain fields need to be used for a specfic standard.
1005*
1006*/
1007struct drx_channel {
1008 s32 frequency;
1009 /**< frequency in kHz */
1010 enum drx_bandwidth bandwidth;
1011 /**< bandwidth */
1012 enum drx_mirror mirror; /**< mirrored or not on RF */
1013 enum drx_modulation constellation;
1014 /**< constellation */
1015 enum drx_hierarchy hierarchy;
1016 /**< hierarchy */
1017 enum drx_priority priority; /**< priority */
1018 enum drx_coderate coderate; /**< coderate */
1019 enum drx_guard guard; /**< guard interval */
1020 enum drx_fft_mode fftmode; /**< fftmode */
1021 enum drx_classification classification;
1022 /**< classification */
1023 u32 symbolrate;
1024 /**< symbolrate in symbols/sec */
1025 enum drx_interleave_mode interleavemode;
1026 /**< interleaveMode QAM */
1027 enum drx_ldpc ldpc; /**< ldpc */
1028 enum drx_carrier_mode carrier; /**< carrier */
1029 enum drx_frame_mode framemode;
1030 /**< frame mode */
1031 enum drx_pilot_mode pilot; /**< pilot mode */
1032};
1033
1034/*========================================*/
1035
1036enum drx_cfg_sqi_speed {
1037 DRX_SQI_SPEED_FAST = 0,
1038 DRX_SQI_SPEED_MEDIUM,
1039 DRX_SQI_SPEED_SLOW,
1040 DRX_SQI_SPEED_UNKNOWN = DRX_UNKNOWN
1041};
1042
1043/*========================================*/
1044
1045/**
1046* \struct struct drx_complex * A complex number.
1047*
1048* Used by DRX_CTRL_CONSTEL.
1049*/
1050struct drx_complex {
1051 s16 im;
1052 /**< Imaginary part. */
1053 s16 re;
1054 /**< Real part. */
1055};
1056
1057/*========================================*/
1058
1059/**
1060* \struct struct drx_frequency_plan * Array element of a frequency plan.
1061*
1062* Used by DRX_CTRL_SCAN_INIT.
1063*/
1064struct drx_frequency_plan {
1065 s32 first;
1066 /**< First centre frequency in this band */
1067 s32 last;
1068 /**< Last centre frequency in this band */
1069 s32 step;
1070 /**< Stepping frequency in this band */
1071 enum drx_bandwidth bandwidth;
1072 /**< Bandwidth within this frequency band */
1073 u16 ch_number;
1074 /**< First channel number in this band, or first
1075 index in ch_names */
1076 char **ch_names;
1077 /**< Optional list of channel names in this
1078 band */
1079};
1080
1081/*========================================*/
1082
1083/**
1084* \struct struct drx_scan_param * Parameters for channel scan.
1085*
1086* Used by DRX_CTRL_SCAN_INIT.
1087*/
1088struct drx_scan_param {
1089 struct drx_frequency_plan *frequency_plan;
1090 /**< Frequency plan (array)*/
1091 u16 frequency_plan_size; /**< Number of bands */
1092 u32 num_tries; /**< Max channels tried */
1093 s32 skip; /**< Minimum frequency step to take
1094 after a channel is found */
1095 void *ext_params; /**< Standard specific params */
1096};
1097
1098/*========================================*/
1099
1100/**
1101* \brief Scan commands.
1102* Used by scanning algorithms.
1103*/
1104enum drx_scan_command {
1105 DRX_SCAN_COMMAND_INIT = 0,/**< Initialize scanning */
1106 DRX_SCAN_COMMAND_NEXT, /**< Next scan */
1107 DRX_SCAN_COMMAND_STOP /**< Stop scanning */
1108};
1109
1110/*========================================*/
1111
1112/**
1113* \brief Inner scan function prototype.
1114*/
1115typedef int(*drx_scan_func_t) (void *scan_context,
1116 enum drx_scan_command scan_command,
1117 struct drx_channel *scan_channel,
1118 bool *get_next_channel);
1119
1120/*========================================*/
1121
1122/**
1123* \struct struct drxtps_info * TPS information, DVB-T specific.
1124*
1125* Used by DRX_CTRL_TPS_INFO.
1126*/
1127 struct drxtps_info {
1128 enum drx_fft_mode fftmode; /**< Fft mode */
1129 enum drx_guard guard; /**< Guard interval */
1130 enum drx_modulation constellation;
1131 /**< Constellation */
1132 enum drx_hierarchy hierarchy;
1133 /**< Hierarchy */
1134 enum drx_coderate high_coderate;
1135 /**< High code rate */
1136 enum drx_coderate low_coderate;
1137 /**< Low cod rate */
1138 enum drx_tps_frame frame; /**< Tps frame */
1139 u8 length; /**< Length */
1140 u16 cell_id; /**< Cell id */
1141 };
1142
1143/*========================================*/
1144
1145/**
1146* \brief Power mode of device.
1147*
1148* Used by DRX_CTRL_SET_POWER_MODE.
1149*/
1150 enum drx_power_mode {
1151 DRX_POWER_UP = 0,
1152 /**< Generic , Power Up Mode */
1153 DRX_POWER_MODE_1,
1154 /**< Device specific , Power Up Mode */
1155 DRX_POWER_MODE_2,
1156 /**< Device specific , Power Up Mode */
1157 DRX_POWER_MODE_3,
1158 /**< Device specific , Power Up Mode */
1159 DRX_POWER_MODE_4,
1160 /**< Device specific , Power Up Mode */
1161 DRX_POWER_MODE_5,
1162 /**< Device specific , Power Up Mode */
1163 DRX_POWER_MODE_6,
1164 /**< Device specific , Power Up Mode */
1165 DRX_POWER_MODE_7,
1166 /**< Device specific , Power Up Mode */
1167 DRX_POWER_MODE_8,
1168 /**< Device specific , Power Up Mode */
1169
1170 DRX_POWER_MODE_9,
1171 /**< Device specific , Power Down Mode */
1172 DRX_POWER_MODE_10,
1173 /**< Device specific , Power Down Mode */
1174 DRX_POWER_MODE_11,
1175 /**< Device specific , Power Down Mode */
1176 DRX_POWER_MODE_12,
1177 /**< Device specific , Power Down Mode */
1178 DRX_POWER_MODE_13,
1179 /**< Device specific , Power Down Mode */
1180 DRX_POWER_MODE_14,
1181 /**< Device specific , Power Down Mode */
1182 DRX_POWER_MODE_15,
1183 /**< Device specific , Power Down Mode */
1184 DRX_POWER_MODE_16,
1185 /**< Device specific , Power Down Mode */
1186 DRX_POWER_DOWN = 255
1187 /**< Generic , Power Down Mode */
1188 };
1189
1190/*========================================*/
1191
1192/**
1193* \enum enum drx_module * \brief Software module identification.
1194*
1195* Used by DRX_CTRL_VERSION.
1196*/
1197 enum drx_module {
1198 DRX_MODULE_DEVICE,
1199 DRX_MODULE_MICROCODE,
1200 DRX_MODULE_DRIVERCORE,
1201 DRX_MODULE_DEVICEDRIVER,
1202 DRX_MODULE_DAP,
1203 DRX_MODULE_BSP_I2C,
1204 DRX_MODULE_BSP_TUNER,
1205 DRX_MODULE_BSP_HOST,
1206 DRX_MODULE_UNKNOWN
1207 };
1208
1209/**
1210* \enum struct drx_version * \brief Version information of one software module.
1211*
1212* Used by DRX_CTRL_VERSION.
1213*/
1214 struct drx_version {
1215 enum drx_module module_type;
1216 /**< Type identifier of the module */
1217 char *module_name;
1218 /**< Name or description of module */
1219 u16 v_major; /**< Major version number */
1220 u16 v_minor; /**< Minor version number */
1221 u16 v_patch; /**< Patch version number */
1222 char *v_string; /**< Version as text string */
1223 };
1224
1225/**
1226* \enum struct drx_version_list * \brief List element of NULL terminated, linked list for version information.
1227*
1228* Used by DRX_CTRL_VERSION.
1229*/
1230struct drx_version_list {
1231 struct drx_version *version;/**< Version information */
1232 struct drx_version_list *next;
1233 /**< Next list element */
1234};
1235
1236/*========================================*/
1237
1238/**
1239* \brief Parameters needed to confiugure a UIO.
1240*
1241* Used by DRX_CTRL_UIO_CFG.
1242*/
1243 struct drxuio_cfg {
1244 enum drx_uio uio;
1245 /**< UIO identifier */
1246 enum drxuio_mode mode;
1247 /**< UIO operational mode */
1248 };
1249
1250/*========================================*/
1251
1252/**
1253* \brief Parameters needed to read from or write to a UIO.
1254*
1255* Used by DRX_CTRL_UIO_READ and DRX_CTRL_UIO_WRITE.
1256*/
1257 struct drxuio_data {
1258 enum drx_uio uio;
1259 /**< UIO identifier */
1260 bool value;
1261 /**< UIO value (true=1, false=0) */
1262 };
1263
1264/*========================================*/
1265
1266/**
1267* \brief Parameters needed to configure OOB.
1268*
1269* Used by DRX_CTRL_SET_OOB.
1270*/
1271 struct drxoob {
1272 s32 frequency; /**< Frequency in kHz */
1273 enum drxoob_downstream_standard standard;
1274 /**< OOB standard */
1275 bool spectrum_inverted; /**< If true, then spectrum
1276 is inverted */
1277 };
1278
1279/*========================================*/
1280
1281/**
1282* \brief Metrics from OOB.
1283*
1284* Used by DRX_CTRL_GET_OOB.
1285*/
1286 struct drxoob_status {
1287 s32 frequency; /**< Frequency in Khz */
1288 enum drx_lock_status lock; /**< Lock status */
1289 u32 mer; /**< MER */
1290 s32 symbol_rate_offset; /**< Symbolrate offset in ppm */
1291 };
1292
1293/*========================================*/
1294
1295/**
1296* \brief Device dependent configuration data.
1297*
1298* Used by DRX_CTRL_SET_CFG and DRX_CTRL_GET_CFG.
1299* A sort of nested drx_ctrl() functionality for device specific controls.
1300*/
1301 struct drx_cfg {
1302 u32 cfg_type;
1303 /**< Function identifier */
1304 void *cfg_data;
1305 /**< Function data */
1306 };
1307
1308/*========================================*/
1309
1310/**
1311* /struct DRXMpegStartWidth_t
1312* MStart width [nr MCLK cycles] for serial MPEG output.
1313*/
1314
1315 enum drxmpeg_str_width {
1316 DRX_MPEG_STR_WIDTH_1,
1317 DRX_MPEG_STR_WIDTH_8
1318 };
1319
1320/* CTRL CFG MPEG ouput */
1321/**
1322* \struct struct drx_cfg_mpeg_output * \brief Configuartion parameters for MPEG output control.
1323*
1324* Used by DRX_CFG_MPEG_OUTPUT, in combination with DRX_CTRL_SET_CFG and
1325* DRX_CTRL_GET_CFG.
1326*/
1327
1328 struct drx_cfg_mpeg_output {
1329 bool enable_mpeg_output;/**< If true, enable MPEG output */
1330 bool insert_rs_byte; /**< If true, insert RS byte */
1331 bool enable_parallel; /**< If true, parallel out otherwise
1332 serial */
1333 bool invert_data; /**< If true, invert DATA signals */
1334 bool invert_err; /**< If true, invert ERR signal */
1335 bool invert_str; /**< If true, invert STR signals */
1336 bool invert_val; /**< If true, invert VAL signals */
1337 bool invert_clk; /**< If true, invert CLK signals */
1338 bool static_clk; /**< If true, static MPEG clockrate
1339 will be used, otherwise clockrate
1340 will adapt to the bitrate of the
1341 TS */
1342 u32 bitrate; /**< Maximum bitrate in b/s in case
1343 static clockrate is selected */
1344 enum drxmpeg_str_width width_str;
1345 /**< MPEG start width */
1346 };
1347
1348
1349/*========================================*/
1350
1351/**
1352* \struct struct drxi2c_data * \brief Data for I2C via 2nd or 3rd or etc I2C port.
1353*
1354* Used by DRX_CTRL_I2C_READWRITE.
1355* If port_nr is equal to primairy port_nr BSPI2C will be used.
1356*
1357*/
1358 struct drxi2c_data {
1359 u16 port_nr; /**< I2C port number */
1360 struct i2c_device_addr *w_dev_addr;
1361 /**< Write device address */
1362 u16 w_count; /**< Size of write data in bytes */
1363 u8 *wData; /**< Pointer to write data */
1364 struct i2c_device_addr *r_dev_addr;
1365 /**< Read device address */
1366 u16 r_count; /**< Size of data to read in bytes */
1367 u8 *r_data; /**< Pointer to read buffer */
1368 };
1369
1370/*========================================*/
1371
1372/**
1373* \enum enum drx_aud_standard * \brief Audio standard identifier.
1374*
1375* Used by DRX_CTRL_SET_AUD.
1376*/
1377 enum drx_aud_standard {
1378 DRX_AUD_STANDARD_BTSC, /**< set BTSC standard (USA) */
1379 DRX_AUD_STANDARD_A2, /**< set A2-Korea FM Stereo */
1380 DRX_AUD_STANDARD_EIAJ, /**< set to Japanese FM Stereo */
1381 DRX_AUD_STANDARD_FM_STEREO,/**< set to FM-Stereo Radio */
1382 DRX_AUD_STANDARD_M_MONO, /**< for 4.5 MHz mono detected */
1383 DRX_AUD_STANDARD_D_K_MONO, /**< for 6.5 MHz mono detected */
1384 DRX_AUD_STANDARD_BG_FM, /**< set BG_FM standard */
1385 DRX_AUD_STANDARD_D_K1, /**< set D_K1 standard */
1386 DRX_AUD_STANDARD_D_K2, /**< set D_K2 standard */
1387 DRX_AUD_STANDARD_D_K3, /**< set D_K3 standard */
1388 DRX_AUD_STANDARD_BG_NICAM_FM,
1389 /**< set BG_NICAM_FM standard */
1390 DRX_AUD_STANDARD_L_NICAM_AM,
1391 /**< set L_NICAM_AM standard */
1392 DRX_AUD_STANDARD_I_NICAM_FM,
1393 /**< set I_NICAM_FM standard */
1394 DRX_AUD_STANDARD_D_K_NICAM_FM,
1395 /**< set D_K_NICAM_FM standard */
1396 DRX_AUD_STANDARD_NOT_READY,/**< used to detect audio standard */
1397 DRX_AUD_STANDARD_AUTO = DRX_AUTO,
1398 /**< Automatic Standard Detection */
1399 DRX_AUD_STANDARD_UNKNOWN = DRX_UNKNOWN
1400 /**< used as auto and for readback */
1401 };
1402
1403/* CTRL_AUD_GET_STATUS - struct drx_aud_status */
1404/**
1405* \enum enum drx_aud_nicam_status * \brief Status of NICAM carrier.
1406*/
1407 enum drx_aud_nicam_status {
1408 DRX_AUD_NICAM_DETECTED = 0,
1409 /**< NICAM carrier detected */
1410 DRX_AUD_NICAM_NOT_DETECTED,
1411 /**< NICAM carrier not detected */
1412 DRX_AUD_NICAM_BAD /**< NICAM carrier bad quality */
1413 };
1414
1415/**
1416* \struct struct drx_aud_status * \brief Audio status characteristics.
1417*/
1418 struct drx_aud_status {
1419 bool stereo; /**< stereo detection */
1420 bool carrier_a; /**< carrier A detected */
1421 bool carrier_b; /**< carrier B detected */
1422 bool sap; /**< sap / bilingual detection */
1423 bool rds; /**< RDS data array present */
1424 enum drx_aud_nicam_status nicam_status;
1425 /**< status of NICAM carrier */
1426 s8 fm_ident; /**< FM Identification value */
1427 };
1428
1429/* CTRL_AUD_READ_RDS - DRXRDSdata_t */
1430
1431/**
1432* \struct DRXRDSdata_t
1433* \brief Raw RDS data array.
1434*/
1435 struct drx_cfg_aud_rds {
1436 bool valid; /**< RDS data validation */
1437 u16 data[18]; /**< data from one RDS data array */
1438 };
1439
1440/* DRX_CFG_AUD_VOLUME - struct drx_cfg_aud_volume - set/get */
1441/**
1442* \enum DRXAudAVCDecayTime_t
1443* \brief Automatic volume control configuration.
1444*/
1445 enum drx_aud_avc_mode {
1446 DRX_AUD_AVC_OFF, /**< Automatic volume control off */
1447 DRX_AUD_AVC_DECAYTIME_8S, /**< level volume in 8 seconds */
1448 DRX_AUD_AVC_DECAYTIME_4S, /**< level volume in 4 seconds */
1449 DRX_AUD_AVC_DECAYTIME_2S, /**< level volume in 2 seconds */
1450 DRX_AUD_AVC_DECAYTIME_20MS/**< level volume in 20 millisec */
1451 };
1452
1453/**
1454* /enum DRXAudMaxAVCGain_t
1455* /brief Automatic volume control max gain in audio baseband.
1456*/
1457 enum drx_aud_avc_max_gain {
1458 DRX_AUD_AVC_MAX_GAIN_0DB, /**< maximum AVC gain 0 dB */
1459 DRX_AUD_AVC_MAX_GAIN_6DB, /**< maximum AVC gain 6 dB */
1460 DRX_AUD_AVC_MAX_GAIN_12DB /**< maximum AVC gain 12 dB */
1461 };
1462
1463/**
1464* /enum DRXAudMaxAVCAtten_t
1465* /brief Automatic volume control max attenuation in audio baseband.
1466*/
1467 enum drx_aud_avc_max_atten {
1468 DRX_AUD_AVC_MAX_ATTEN_12DB,
1469 /**< maximum AVC attenuation 12 dB */
1470 DRX_AUD_AVC_MAX_ATTEN_18DB,
1471 /**< maximum AVC attenuation 18 dB */
1472 DRX_AUD_AVC_MAX_ATTEN_24DB/**< maximum AVC attenuation 24 dB */
1473 };
1474/**
1475* \struct struct drx_cfg_aud_volume * \brief Audio volume configuration.
1476*/
1477 struct drx_cfg_aud_volume {
1478 bool mute; /**< mute overrides volume setting */
1479 s16 volume; /**< volume, range -114 to 12 dB */
1480 enum drx_aud_avc_mode avc_mode; /**< AVC auto volume control mode */
1481 u16 avc_ref_level; /**< AVC reference level */
1482 enum drx_aud_avc_max_gain avc_max_gain;
1483 /**< AVC max gain selection */
1484 enum drx_aud_avc_max_atten avc_max_atten;
1485 /**< AVC max attenuation selection */
1486 s16 strength_left; /**< quasi-peak, left speaker */
1487 s16 strength_right; /**< quasi-peak, right speaker */
1488 };
1489
1490/* DRX_CFG_I2S_OUTPUT - struct drx_cfg_i2s_output - set/get */
1491/**
1492* \enum enum drxi2s_mode * \brief I2S output mode.
1493*/
1494 enum drxi2s_mode {
1495 DRX_I2S_MODE_MASTER, /**< I2S is in master mode */
1496 DRX_I2S_MODE_SLAVE /**< I2S is in slave mode */
1497 };
1498
1499/**
1500* \enum enum drxi2s_word_length * \brief Width of I2S data.
1501*/
1502 enum drxi2s_word_length {
1503 DRX_I2S_WORDLENGTH_32 = 0,/**< I2S data is 32 bit wide */
1504 DRX_I2S_WORDLENGTH_16 = 1 /**< I2S data is 16 bit wide */
1505 };
1506
1507/**
1508* \enum enum drxi2s_format * \brief Data wordstrobe alignment for I2S.
1509*/
1510 enum drxi2s_format {
1511 DRX_I2S_FORMAT_WS_WITH_DATA,
1512 /**< I2S data and wordstrobe are aligned */
1513 DRX_I2S_FORMAT_WS_ADVANCED
1514 /**< I2S data one cycle after wordstrobe */
1515 };
1516
1517/**
1518* \enum enum drxi2s_polarity * \brief Polarity of I2S data.
1519*/
1520 enum drxi2s_polarity {
1521 DRX_I2S_POLARITY_RIGHT,/**< wordstrobe - right high, left low */
1522 DRX_I2S_POLARITY_LEFT /**< wordstrobe - right low, left high */
1523 };
1524
1525/**
1526* \struct struct drx_cfg_i2s_output * \brief I2S output configuration.
1527*/
1528 struct drx_cfg_i2s_output {
1529 bool output_enable; /**< I2S output enable */
1530 u32 frequency; /**< range from 8000-48000 Hz */
1531 enum drxi2s_mode mode; /**< I2S mode, master or slave */
1532 enum drxi2s_word_length word_length;
1533 /**< I2S wordlength, 16 or 32 bits */
1534 enum drxi2s_polarity polarity;/**< I2S wordstrobe polarity */
1535 enum drxi2s_format format; /**< I2S wordstrobe delay to data */
1536 };
1537
1538/* ------------------------------expert interface-----------------------------*/
1539/**
1540* /enum enum drx_aud_fm_deemphasis * setting for FM-Deemphasis in audio demodulator.
1541*
1542*/
1543 enum drx_aud_fm_deemphasis {
1544 DRX_AUD_FM_DEEMPH_50US,
1545 DRX_AUD_FM_DEEMPH_75US,
1546 DRX_AUD_FM_DEEMPH_OFF
1547 };
1548
1549/**
1550* /enum DRXAudDeviation_t
1551* setting for deviation mode in audio demodulator.
1552*
1553*/
1554 enum drx_cfg_aud_deviation {
1555 DRX_AUD_DEVIATION_NORMAL,
1556 DRX_AUD_DEVIATION_HIGH
1557 };
1558
1559/**
1560* /enum enum drx_no_carrier_option * setting for carrier, mute/noise.
1561*
1562*/
1563 enum drx_no_carrier_option {
1564 DRX_NO_CARRIER_MUTE,
1565 DRX_NO_CARRIER_NOISE
1566 };
1567
1568/**
1569* \enum DRXAudAutoSound_t
1570* \brief Automatic Sound
1571*/
1572 enum drx_cfg_aud_auto_sound {
1573 DRX_AUD_AUTO_SOUND_OFF = 0,
1574 DRX_AUD_AUTO_SOUND_SELECT_ON_CHANGE_ON,
1575 DRX_AUD_AUTO_SOUND_SELECT_ON_CHANGE_OFF
1576 };
1577
1578/**
1579* \enum DRXAudASSThres_t
1580* \brief Automatic Sound Select Thresholds
1581*/
1582 struct drx_cfg_aud_ass_thres {
1583 u16 a2; /* A2 Threshold for ASS configuration */
1584 u16 btsc; /* BTSC Threshold for ASS configuration */
1585 u16 nicam; /* Nicam Threshold for ASS configuration */
1586 };
1587
1588/**
1589* \struct struct drx_aud_carrier * \brief Carrier detection related parameters
1590*/
1591 struct drx_aud_carrier {
1592 u16 thres; /* carrier detetcion threshold for primary carrier (A) */
1593 enum drx_no_carrier_option opt; /* Mute or noise at no carrier detection (A) */
1594 s32 shift; /* DC level of incoming signal (A) */
1595 s32 dco; /* frequency adjustment (A) */
1596 };
1597
1598/**
1599* \struct struct drx_cfg_aud_carriers * \brief combining carrier A & B to one struct
1600*/
1601 struct drx_cfg_aud_carriers {
1602 struct drx_aud_carrier a;
1603 struct drx_aud_carrier b;
1604 };
1605
1606/**
1607* /enum enum drx_aud_i2s_src * Selection of audio source
1608*/
1609 enum drx_aud_i2s_src {
1610 DRX_AUD_SRC_MONO,
1611 DRX_AUD_SRC_STEREO_OR_AB,
1612 DRX_AUD_SRC_STEREO_OR_A,
1613 DRX_AUD_SRC_STEREO_OR_B};
1614
1615/**
1616* \enum enum drx_aud_i2s_matrix * \brief Used for selecting I2S output.
1617*/
1618 enum drx_aud_i2s_matrix {
1619 DRX_AUD_I2S_MATRIX_A_MONO,
1620 /**< A sound only, stereo or mono */
1621 DRX_AUD_I2S_MATRIX_B_MONO,
1622 /**< B sound only, stereo or mono */
1623 DRX_AUD_I2S_MATRIX_STEREO,
1624 /**< A+B sound, transparant */
1625 DRX_AUD_I2S_MATRIX_MONO /**< A+B mixed to mono sum, (L+R)/2 */};
1626
1627/**
1628* /enum enum drx_aud_fm_matrix * setting for FM-Matrix in audio demodulator.
1629*
1630*/
1631 enum drx_aud_fm_matrix {
1632 DRX_AUD_FM_MATRIX_NO_MATRIX,
1633 DRX_AUD_FM_MATRIX_GERMAN,
1634 DRX_AUD_FM_MATRIX_KOREAN,
1635 DRX_AUD_FM_MATRIX_SOUND_A,
1636 DRX_AUD_FM_MATRIX_SOUND_B};
1637
1638/**
1639* \struct DRXAudMatrices_t
1640* \brief Mixer settings
1641*/
1642struct drx_cfg_aud_mixer {
1643 enum drx_aud_i2s_src source_i2s;
1644 enum drx_aud_i2s_matrix matrix_i2s;
1645 enum drx_aud_fm_matrix matrix_fm;
1646};
1647
1648/**
1649* \enum DRXI2SVidSync_t
1650* \brief Audio/video synchronization, interacts with I2S mode.
1651* AUTO_1 and AUTO_2 are for automatic video standard detection with preference
1652* for NTSC or Monochrome, because the frequencies are too close (59.94 & 60 Hz)
1653*/
1654 enum drx_cfg_aud_av_sync {
1655 DRX_AUD_AVSYNC_OFF,/**< audio/video synchronization is off */
1656 DRX_AUD_AVSYNC_NTSC,
1657 /**< it is an NTSC system */
1658 DRX_AUD_AVSYNC_MONOCHROME,
1659 /**< it is a MONOCHROME system */
1660 DRX_AUD_AVSYNC_PAL_SECAM
1661 /**< it is a PAL/SECAM system */};
1662
1663/**
1664* \struct struct drx_cfg_aud_prescale * \brief Prescalers
1665*/
1666struct drx_cfg_aud_prescale {
1667 u16 fm_deviation;
1668 s16 nicam_gain;
1669};
1670
1671/**
1672* \struct struct drx_aud_beep * \brief Beep
1673*/
1674struct drx_aud_beep {
1675 s16 volume; /* dB */
1676 u16 frequency; /* Hz */
1677 bool mute;
1678};
1679
1680/**
1681* \enum enum drx_aud_btsc_detect * \brief BTSC detetcion mode
1682*/
1683 enum drx_aud_btsc_detect {
1684 DRX_BTSC_STEREO,
1685 DRX_BTSC_MONO_AND_SAP};
1686
1687/**
1688* \struct struct drx_aud_data * \brief Audio data structure
1689*/
1690struct drx_aud_data {
1691 /* audio storage */
1692 bool audio_is_active;
1693 enum drx_aud_standard audio_standard;
1694 struct drx_cfg_i2s_output i2sdata;
1695 struct drx_cfg_aud_volume volume;
1696 enum drx_cfg_aud_auto_sound auto_sound;
1697 struct drx_cfg_aud_ass_thres ass_thresholds;
1698 struct drx_cfg_aud_carriers carriers;
1699 struct drx_cfg_aud_mixer mixer;
1700 enum drx_cfg_aud_deviation deviation;
1701 enum drx_cfg_aud_av_sync av_sync;
1702 struct drx_cfg_aud_prescale prescale;
1703 enum drx_aud_fm_deemphasis deemph;
1704 enum drx_aud_btsc_detect btsc_detect;
1705 /* rds */
1706 u16 rds_data_counter;
1707 bool rds_data_present;
1708};
1709
1710/**
1711* \enum enum drx_qam_lock_range * \brief QAM lock range mode
1712*/
1713 enum drx_qam_lock_range {
1714 DRX_QAM_LOCKRANGE_NORMAL,
1715 DRX_QAM_LOCKRANGE_EXTENDED};
1716
1717/*============================================================================*/
1718/*============================================================================*/
1719/*== Data access structures ==================================================*/
1720/*============================================================================*/
1721/*============================================================================*/
1722
1723/* Address on device */
1724 typedef u32 dr_xaddr_t, *pdr_xaddr_t;
1725
1726/* Protocol specific flags */
1727 typedef u32 dr_xflags_t, *pdr_xflags_t;
1728
1729/* Write block of data to device */
1730 typedef int(*drx_write_block_func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
1731 u32 addr, /* address of register/memory */
1732 u16 datasize, /* size of data in bytes */
1733 u8 *data, /* data to send */
1734 u32 flags);
1735
1736/* Read block of data from device */
1737 typedef int(*drx_read_block_func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
1738 u32 addr, /* address of register/memory */
1739 u16 datasize, /* size of data in bytes */
1740 u8 *data, /* receive buffer */
1741 u32 flags);
1742
1743/* Write 8-bits value to device */
1744 typedef int(*drx_write_reg8func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
1745 u32 addr, /* address of register/memory */
1746 u8 data, /* data to send */
1747 u32 flags);
1748
1749/* Read 8-bits value to device */
1750 typedef int(*drx_read_reg8func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
1751 u32 addr, /* address of register/memory */
1752 u8 *data, /* receive buffer */
1753 u32 flags);
1754
1755/* Read modify write 8-bits value to device */
1756 typedef int(*drx_read_modify_write_reg8func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
1757 u32 waddr, /* write address of register */
1758 u32 raddr, /* read address of register */
1759 u8 wdata, /* data to write */
1760 u8 *rdata); /* data to read */
1761
1762/* Write 16-bits value to device */
1763 typedef int(*drx_write_reg16func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
1764 u32 addr, /* address of register/memory */
1765 u16 data, /* data to send */
1766 u32 flags);
1767
1768/* Read 16-bits value to device */
1769 typedef int(*drx_read_reg16func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
1770 u32 addr, /* address of register/memory */
1771 u16 *data, /* receive buffer */
1772 u32 flags);
1773
1774/* Read modify write 16-bits value to device */
1775 typedef int(*drx_read_modify_write_reg16func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
1776 u32 waddr, /* write address of register */
1777 u32 raddr, /* read address of register */
1778 u16 wdata, /* data to write */
1779 u16 *rdata); /* data to read */
1780
1781/* Write 32-bits value to device */
1782 typedef int(*drx_write_reg32func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
1783 u32 addr, /* address of register/memory */
1784 u32 data, /* data to send */
1785 u32 flags);
1786
1787/* Read 32-bits value to device */
1788 typedef int(*drx_read_reg32func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
1789 u32 addr, /* address of register/memory */
1790 u32 *data, /* receive buffer */
1791 u32 flags);
1792
1793/* Read modify write 32-bits value to device */
1794 typedef int(*drx_read_modify_write_reg32func_t) (struct i2c_device_addr *dev_addr, /* address of I2C device */
1795 u32 waddr, /* write address of register */
1796 u32 raddr, /* read address of register */
1797 u32 wdata, /* data to write */
1798 u32 *rdata); /* data to read */
1799
1800/**
1801* \struct struct drx_access_func * \brief Interface to an access protocol.
1802*/
1803struct drx_access_func {
1804 drx_write_block_func_t write_block_func;
1805 drx_read_block_func_t read_block_func;
1806 drx_write_reg8func_t write_reg8func;
1807 drx_read_reg8func_t read_reg8func;
1808 drx_read_modify_write_reg8func_t read_modify_write_reg8func;
1809 drx_write_reg16func_t write_reg16func;
1810 drx_read_reg16func_t read_reg16func;
1811 drx_read_modify_write_reg16func_t read_modify_write_reg16func;
1812 drx_write_reg32func_t write_reg32func;
1813 drx_read_reg32func_t read_reg32func;
1814 drx_read_modify_write_reg32func_t read_modify_write_reg32func;
1815};
1816
1817/* Register address and data for register dump function */
1818struct drx_reg_dump {
1819 u32 address;
1820 u32 data;
1821};
1822
1823/*============================================================================*/
1824/*============================================================================*/
1825/*== Demod instance data structures ==========================================*/
1826/*============================================================================*/
1827/*============================================================================*/
1828
1829/**
1830* \struct struct drx_common_attr * \brief Set of common attributes, shared by all DRX devices.
1831*/
1832 struct drx_common_attr {
1833 /* Microcode (firmware) attributes */
1834 char *microcode_file; /**< microcode filename */
1835 bool verify_microcode;
1836 /**< Use microcode verify or not. */
1837 struct drx_mc_version_rec mcversion;
1838 /**< Version record of microcode from file */
1839
1840 /* Clocks and tuner attributes */
1841 s32 intermediate_freq;
1842 /**< IF,if tuner instance not used. (kHz)*/
1843 s32 sys_clock_freq;
1844 /**< Systemclock frequency. (kHz) */
1845 s32 osc_clock_freq;
1846 /**< Oscillator clock frequency. (kHz) */
1847 s16 osc_clock_deviation;
1848 /**< Oscillator clock deviation. (ppm) */
1849 bool mirror_freq_spect;
1850 /**< Mirror IF frequency spectrum or not.*/
1851
1852 /* Initial MPEG output attributes */
1853 struct drx_cfg_mpeg_output mpeg_cfg;
1854 /**< MPEG configuration */
1855
1856 bool is_opened; /**< if true instance is already opened. */
1857
1858 /* Channel scan */
1859 struct drx_scan_param *scan_param;
1860 /**< scan parameters */
1861 u16 scan_freq_plan_index;
1862 /**< next index in freq plan */
1863 s32 scan_next_frequency;
1864 /**< next freq to scan */
1865 bool scan_ready; /**< scan ready flag */
1866 u32 scan_max_channels;/**< number of channels in freqplan */
1867 u32 scan_channels_scanned;
1868 /**< number of channels scanned */
1869 /* Channel scan - inner loop: demod related */
1870 drx_scan_func_t scan_function;
1871 /**< function to check channel */
1872 /* Channel scan - inner loop: SYSObj related */
1873 void *scan_context; /**< Context Pointer of SYSObj */
1874 /* Channel scan - parameters for default DTV scan function in core driver */
1875 u16 scan_demod_lock_timeout;
1876 /**< millisecs to wait for lock */
1877 enum drx_lock_status scan_desired_lock;
1878 /**< lock requirement for channel found */
1879 /* scan_active can be used by SetChannel to decide how to program the tuner,
1880 fast or slow (but stable). Usually fast during scan. */
1881 bool scan_active; /**< true when scan routines are active */
1882
1883 /* Power management */
1884 enum drx_power_mode current_power_mode;
1885 /**< current power management mode */
1886
1887 /* Tuner */
1888 u8 tuner_port_nr; /**< nr of I2C port to wich tuner is */
1889 s32 tuner_min_freq_rf;
1890 /**< minimum RF input frequency, in kHz */
1891 s32 tuner_max_freq_rf;
1892 /**< maximum RF input frequency, in kHz */
1893 bool tuner_rf_agc_pol; /**< if true invert RF AGC polarity */
1894 bool tuner_if_agc_pol; /**< if true invert IF AGC polarity */
1895 bool tuner_slow_mode; /**< if true invert IF AGC polarity */
1896
1897 struct drx_channel current_channel;
1898 /**< current channel parameters */
1899 enum drx_standard current_standard;
1900 /**< current standard selection */
1901 enum drx_standard prev_standard;
1902 /**< previous standard selection */
1903 enum drx_standard di_cache_standard;
1904 /**< standard in DI cache if available */
1905 bool use_bootloader; /**< use bootloader in open */
1906 u32 capabilities; /**< capabilities flags */
1907 u32 product_id; /**< product ID inc. metal fix number */};
1908
1909/*
1910* Generic functions for DRX devices.
1911*/
1912
1913struct drx_demod_instance;
1914
1915/**
1916* \struct struct drx_demod_instance * \brief Top structure of demodulator instance.
1917*/
1918struct drx_demod_instance {
1919 /**< data access protocol functions */
1920 struct i2c_device_addr *my_i2c_dev_addr;
1921 /**< i2c address and device identifier */
1922 struct drx_common_attr *my_common_attr;
1923 /**< common DRX attributes */
1924 void *my_ext_attr; /**< device specific attributes */
1925 /* generic demodulator data */
1926
1927 struct i2c_adapter *i2c;
1928 const struct firmware *firmware;
1929};
1930
1931/*-------------------------------------------------------------------------
1932MACROS
1933Conversion from enum values to human readable form.
1934-------------------------------------------------------------------------*/
1935
1936/* standard */
1937
1938#define DRX_STR_STANDARD(x) ( \
1939 (x == DRX_STANDARD_DVBT) ? "DVB-T" : \
1940 (x == DRX_STANDARD_8VSB) ? "8VSB" : \
1941 (x == DRX_STANDARD_NTSC) ? "NTSC" : \
1942 (x == DRX_STANDARD_PAL_SECAM_BG) ? "PAL/SECAM B/G" : \
1943 (x == DRX_STANDARD_PAL_SECAM_DK) ? "PAL/SECAM D/K" : \
1944 (x == DRX_STANDARD_PAL_SECAM_I) ? "PAL/SECAM I" : \
1945 (x == DRX_STANDARD_PAL_SECAM_L) ? "PAL/SECAM L" : \
1946 (x == DRX_STANDARD_PAL_SECAM_LP) ? "PAL/SECAM LP" : \
1947 (x == DRX_STANDARD_ITU_A) ? "ITU-A" : \
1948 (x == DRX_STANDARD_ITU_B) ? "ITU-B" : \
1949 (x == DRX_STANDARD_ITU_C) ? "ITU-C" : \
1950 (x == DRX_STANDARD_ITU_D) ? "ITU-D" : \
1951 (x == DRX_STANDARD_FM) ? "FM" : \
1952 (x == DRX_STANDARD_DTMB) ? "DTMB" : \
1953 (x == DRX_STANDARD_AUTO) ? "Auto" : \
1954 (x == DRX_STANDARD_UNKNOWN) ? "Unknown" : \
1955 "(Invalid)")
1956
1957/* channel */
1958
1959#define DRX_STR_BANDWIDTH(x) ( \
1960 (x == DRX_BANDWIDTH_8MHZ) ? "8 MHz" : \
1961 (x == DRX_BANDWIDTH_7MHZ) ? "7 MHz" : \
1962 (x == DRX_BANDWIDTH_6MHZ) ? "6 MHz" : \
1963 (x == DRX_BANDWIDTH_AUTO) ? "Auto" : \
1964 (x == DRX_BANDWIDTH_UNKNOWN) ? "Unknown" : \
1965 "(Invalid)")
1966#define DRX_STR_FFTMODE(x) ( \
1967 (x == DRX_FFTMODE_2K) ? "2k" : \
1968 (x == DRX_FFTMODE_4K) ? "4k" : \
1969 (x == DRX_FFTMODE_8K) ? "8k" : \
1970 (x == DRX_FFTMODE_AUTO) ? "Auto" : \
1971 (x == DRX_FFTMODE_UNKNOWN) ? "Unknown" : \
1972 "(Invalid)")
1973#define DRX_STR_GUARD(x) ( \
1974 (x == DRX_GUARD_1DIV32) ? "1/32nd" : \
1975 (x == DRX_GUARD_1DIV16) ? "1/16th" : \
1976 (x == DRX_GUARD_1DIV8) ? "1/8th" : \
1977 (x == DRX_GUARD_1DIV4) ? "1/4th" : \
1978 (x == DRX_GUARD_AUTO) ? "Auto" : \
1979 (x == DRX_GUARD_UNKNOWN) ? "Unknown" : \
1980 "(Invalid)")
1981#define DRX_STR_CONSTELLATION(x) ( \
1982 (x == DRX_CONSTELLATION_BPSK) ? "BPSK" : \
1983 (x == DRX_CONSTELLATION_QPSK) ? "QPSK" : \
1984 (x == DRX_CONSTELLATION_PSK8) ? "PSK8" : \
1985 (x == DRX_CONSTELLATION_QAM16) ? "QAM16" : \
1986 (x == DRX_CONSTELLATION_QAM32) ? "QAM32" : \
1987 (x == DRX_CONSTELLATION_QAM64) ? "QAM64" : \
1988 (x == DRX_CONSTELLATION_QAM128) ? "QAM128" : \
1989 (x == DRX_CONSTELLATION_QAM256) ? "QAM256" : \
1990 (x == DRX_CONSTELLATION_QAM512) ? "QAM512" : \
1991 (x == DRX_CONSTELLATION_QAM1024) ? "QAM1024" : \
1992 (x == DRX_CONSTELLATION_QPSK_NR) ? "QPSK_NR" : \
1993 (x == DRX_CONSTELLATION_AUTO) ? "Auto" : \
1994 (x == DRX_CONSTELLATION_UNKNOWN) ? "Unknown" : \
1995 "(Invalid)")
1996#define DRX_STR_CODERATE(x) ( \
1997 (x == DRX_CODERATE_1DIV2) ? "1/2nd" : \
1998 (x == DRX_CODERATE_2DIV3) ? "2/3rd" : \
1999 (x == DRX_CODERATE_3DIV4) ? "3/4th" : \
2000 (x == DRX_CODERATE_5DIV6) ? "5/6th" : \
2001 (x == DRX_CODERATE_7DIV8) ? "7/8th" : \
2002 (x == DRX_CODERATE_AUTO) ? "Auto" : \
2003 (x == DRX_CODERATE_UNKNOWN) ? "Unknown" : \
2004 "(Invalid)")
2005#define DRX_STR_HIERARCHY(x) ( \
2006 (x == DRX_HIERARCHY_NONE) ? "None" : \
2007 (x == DRX_HIERARCHY_ALPHA1) ? "Alpha=1" : \
2008 (x == DRX_HIERARCHY_ALPHA2) ? "Alpha=2" : \
2009 (x == DRX_HIERARCHY_ALPHA4) ? "Alpha=4" : \
2010 (x == DRX_HIERARCHY_AUTO) ? "Auto" : \
2011 (x == DRX_HIERARCHY_UNKNOWN) ? "Unknown" : \
2012 "(Invalid)")
2013#define DRX_STR_PRIORITY(x) ( \
2014 (x == DRX_PRIORITY_LOW) ? "Low" : \
2015 (x == DRX_PRIORITY_HIGH) ? "High" : \
2016 (x == DRX_PRIORITY_UNKNOWN) ? "Unknown" : \
2017 "(Invalid)")
2018#define DRX_STR_MIRROR(x) ( \
2019 (x == DRX_MIRROR_NO) ? "Normal" : \
2020 (x == DRX_MIRROR_YES) ? "Mirrored" : \
2021 (x == DRX_MIRROR_AUTO) ? "Auto" : \
2022 (x == DRX_MIRROR_UNKNOWN) ? "Unknown" : \
2023 "(Invalid)")
2024#define DRX_STR_CLASSIFICATION(x) ( \
2025 (x == DRX_CLASSIFICATION_GAUSS) ? "Gaussion" : \
2026 (x == DRX_CLASSIFICATION_HVY_GAUSS) ? "Heavy Gaussion" : \
2027 (x == DRX_CLASSIFICATION_COCHANNEL) ? "Co-channel" : \
2028 (x == DRX_CLASSIFICATION_STATIC) ? "Static echo" : \
2029 (x == DRX_CLASSIFICATION_MOVING) ? "Moving echo" : \
2030 (x == DRX_CLASSIFICATION_ZERODB) ? "Zero dB echo" : \
2031 (x == DRX_CLASSIFICATION_UNKNOWN) ? "Unknown" : \
2032 (x == DRX_CLASSIFICATION_AUTO) ? "Auto" : \
2033 "(Invalid)")
2034
2035#define DRX_STR_INTERLEAVEMODE(x) ( \
2036 (x == DRX_INTERLEAVEMODE_I128_J1) ? "I128_J1" : \
2037 (x == DRX_INTERLEAVEMODE_I128_J1_V2) ? "I128_J1_V2" : \
2038 (x == DRX_INTERLEAVEMODE_I128_J2) ? "I128_J2" : \
2039 (x == DRX_INTERLEAVEMODE_I64_J2) ? "I64_J2" : \
2040 (x == DRX_INTERLEAVEMODE_I128_J3) ? "I128_J3" : \
2041 (x == DRX_INTERLEAVEMODE_I32_J4) ? "I32_J4" : \
2042 (x == DRX_INTERLEAVEMODE_I128_J4) ? "I128_J4" : \
2043 (x == DRX_INTERLEAVEMODE_I16_J8) ? "I16_J8" : \
2044 (x == DRX_INTERLEAVEMODE_I128_J5) ? "I128_J5" : \
2045 (x == DRX_INTERLEAVEMODE_I8_J16) ? "I8_J16" : \
2046 (x == DRX_INTERLEAVEMODE_I128_J6) ? "I128_J6" : \
2047 (x == DRX_INTERLEAVEMODE_RESERVED_11) ? "Reserved 11" : \
2048 (x == DRX_INTERLEAVEMODE_I128_J7) ? "I128_J7" : \
2049 (x == DRX_INTERLEAVEMODE_RESERVED_13) ? "Reserved 13" : \
2050 (x == DRX_INTERLEAVEMODE_I128_J8) ? "I128_J8" : \
2051 (x == DRX_INTERLEAVEMODE_RESERVED_15) ? "Reserved 15" : \
2052 (x == DRX_INTERLEAVEMODE_I12_J17) ? "I12_J17" : \
2053 (x == DRX_INTERLEAVEMODE_I5_J4) ? "I5_J4" : \
2054 (x == DRX_INTERLEAVEMODE_B52_M240) ? "B52_M240" : \
2055 (x == DRX_INTERLEAVEMODE_B52_M720) ? "B52_M720" : \
2056 (x == DRX_INTERLEAVEMODE_B52_M48) ? "B52_M48" : \
2057 (x == DRX_INTERLEAVEMODE_B52_M0) ? "B52_M0" : \
2058 (x == DRX_INTERLEAVEMODE_UNKNOWN) ? "Unknown" : \
2059 (x == DRX_INTERLEAVEMODE_AUTO) ? "Auto" : \
2060 "(Invalid)")
2061
2062#define DRX_STR_LDPC(x) ( \
2063 (x == DRX_LDPC_0_4) ? "0.4" : \
2064 (x == DRX_LDPC_0_6) ? "0.6" : \
2065 (x == DRX_LDPC_0_8) ? "0.8" : \
2066 (x == DRX_LDPC_AUTO) ? "Auto" : \
2067 (x == DRX_LDPC_UNKNOWN) ? "Unknown" : \
2068 "(Invalid)")
2069
2070#define DRX_STR_CARRIER(x) ( \
2071 (x == DRX_CARRIER_MULTI) ? "Multi" : \
2072 (x == DRX_CARRIER_SINGLE) ? "Single" : \
2073 (x == DRX_CARRIER_AUTO) ? "Auto" : \
2074 (x == DRX_CARRIER_UNKNOWN) ? "Unknown" : \
2075 "(Invalid)")
2076
2077#define DRX_STR_FRAMEMODE(x) ( \
2078 (x == DRX_FRAMEMODE_420) ? "420" : \
2079 (x == DRX_FRAMEMODE_595) ? "595" : \
2080 (x == DRX_FRAMEMODE_945) ? "945" : \
2081 (x == DRX_FRAMEMODE_420_FIXED_PN) ? "420 with fixed PN" : \
2082 (x == DRX_FRAMEMODE_945_FIXED_PN) ? "945 with fixed PN" : \
2083 (x == DRX_FRAMEMODE_AUTO) ? "Auto" : \
2084 (x == DRX_FRAMEMODE_UNKNOWN) ? "Unknown" : \
2085 "(Invalid)")
2086
2087#define DRX_STR_PILOT(x) ( \
2088 (x == DRX_PILOT_ON) ? "On" : \
2089 (x == DRX_PILOT_OFF) ? "Off" : \
2090 (x == DRX_PILOT_AUTO) ? "Auto" : \
2091 (x == DRX_PILOT_UNKNOWN) ? "Unknown" : \
2092 "(Invalid)")
2093/* TPS */
2094
2095#define DRX_STR_TPS_FRAME(x) ( \
2096 (x == DRX_TPS_FRAME1) ? "Frame1" : \
2097 (x == DRX_TPS_FRAME2) ? "Frame2" : \
2098 (x == DRX_TPS_FRAME3) ? "Frame3" : \
2099 (x == DRX_TPS_FRAME4) ? "Frame4" : \
2100 (x == DRX_TPS_FRAME_UNKNOWN) ? "Unknown" : \
2101 "(Invalid)")
2102
2103/* lock status */
2104
2105#define DRX_STR_LOCKSTATUS(x) ( \
2106 (x == DRX_NEVER_LOCK) ? "Never" : \
2107 (x == DRX_NOT_LOCKED) ? "No" : \
2108 (x == DRX_LOCKED) ? "Locked" : \
2109 (x == DRX_LOCK_STATE_1) ? "Lock state 1" : \
2110 (x == DRX_LOCK_STATE_2) ? "Lock state 2" : \
2111 (x == DRX_LOCK_STATE_3) ? "Lock state 3" : \
2112 (x == DRX_LOCK_STATE_4) ? "Lock state 4" : \
2113 (x == DRX_LOCK_STATE_5) ? "Lock state 5" : \
2114 (x == DRX_LOCK_STATE_6) ? "Lock state 6" : \
2115 (x == DRX_LOCK_STATE_7) ? "Lock state 7" : \
2116 (x == DRX_LOCK_STATE_8) ? "Lock state 8" : \
2117 (x == DRX_LOCK_STATE_9) ? "Lock state 9" : \
2118 "(Invalid)")
2119
2120/* version information , modules */
2121#define DRX_STR_MODULE(x) ( \
2122 (x == DRX_MODULE_DEVICE) ? "Device" : \
2123 (x == DRX_MODULE_MICROCODE) ? "Microcode" : \
2124 (x == DRX_MODULE_DRIVERCORE) ? "CoreDriver" : \
2125 (x == DRX_MODULE_DEVICEDRIVER) ? "DeviceDriver" : \
2126 (x == DRX_MODULE_BSP_I2C) ? "BSP I2C" : \
2127 (x == DRX_MODULE_BSP_TUNER) ? "BSP Tuner" : \
2128 (x == DRX_MODULE_BSP_HOST) ? "BSP Host" : \
2129 (x == DRX_MODULE_DAP) ? "Data Access Protocol" : \
2130 (x == DRX_MODULE_UNKNOWN) ? "Unknown" : \
2131 "(Invalid)")
2132
2133#define DRX_STR_POWER_MODE(x) ( \
2134 (x == DRX_POWER_UP) ? "DRX_POWER_UP " : \
2135 (x == DRX_POWER_MODE_1) ? "DRX_POWER_MODE_1" : \
2136 (x == DRX_POWER_MODE_2) ? "DRX_POWER_MODE_2" : \
2137 (x == DRX_POWER_MODE_3) ? "DRX_POWER_MODE_3" : \
2138 (x == DRX_POWER_MODE_4) ? "DRX_POWER_MODE_4" : \
2139 (x == DRX_POWER_MODE_5) ? "DRX_POWER_MODE_5" : \
2140 (x == DRX_POWER_MODE_6) ? "DRX_POWER_MODE_6" : \
2141 (x == DRX_POWER_MODE_7) ? "DRX_POWER_MODE_7" : \
2142 (x == DRX_POWER_MODE_8) ? "DRX_POWER_MODE_8" : \
2143 (x == DRX_POWER_MODE_9) ? "DRX_POWER_MODE_9" : \
2144 (x == DRX_POWER_MODE_10) ? "DRX_POWER_MODE_10" : \
2145 (x == DRX_POWER_MODE_11) ? "DRX_POWER_MODE_11" : \
2146 (x == DRX_POWER_MODE_12) ? "DRX_POWER_MODE_12" : \
2147 (x == DRX_POWER_MODE_13) ? "DRX_POWER_MODE_13" : \
2148 (x == DRX_POWER_MODE_14) ? "DRX_POWER_MODE_14" : \
2149 (x == DRX_POWER_MODE_15) ? "DRX_POWER_MODE_15" : \
2150 (x == DRX_POWER_MODE_16) ? "DRX_POWER_MODE_16" : \
2151 (x == DRX_POWER_DOWN) ? "DRX_POWER_DOWN " : \
2152 "(Invalid)")
2153
2154#define DRX_STR_OOB_STANDARD(x) ( \
2155 (x == DRX_OOB_MODE_A) ? "ANSI 55-1 " : \
2156 (x == DRX_OOB_MODE_B_GRADE_A) ? "ANSI 55-2 A" : \
2157 (x == DRX_OOB_MODE_B_GRADE_B) ? "ANSI 55-2 B" : \
2158 "(Invalid)")
2159
2160#define DRX_STR_AUD_STANDARD(x) ( \
2161 (x == DRX_AUD_STANDARD_BTSC) ? "BTSC" : \
2162 (x == DRX_AUD_STANDARD_A2) ? "A2" : \
2163 (x == DRX_AUD_STANDARD_EIAJ) ? "EIAJ" : \
2164 (x == DRX_AUD_STANDARD_FM_STEREO) ? "FM Stereo" : \
2165 (x == DRX_AUD_STANDARD_AUTO) ? "Auto" : \
2166 (x == DRX_AUD_STANDARD_M_MONO) ? "M-Standard Mono" : \
2167 (x == DRX_AUD_STANDARD_D_K_MONO) ? "D/K Mono FM" : \
2168 (x == DRX_AUD_STANDARD_BG_FM) ? "B/G-Dual Carrier FM (A2)" : \
2169 (x == DRX_AUD_STANDARD_D_K1) ? "D/K1-Dual Carrier FM" : \
2170 (x == DRX_AUD_STANDARD_D_K2) ? "D/K2-Dual Carrier FM" : \
2171 (x == DRX_AUD_STANDARD_D_K3) ? "D/K3-Dual Carrier FM" : \
2172 (x == DRX_AUD_STANDARD_BG_NICAM_FM) ? "B/G-NICAM-FM" : \
2173 (x == DRX_AUD_STANDARD_L_NICAM_AM) ? "L-NICAM-AM" : \
2174 (x == DRX_AUD_STANDARD_I_NICAM_FM) ? "I-NICAM-FM" : \
2175 (x == DRX_AUD_STANDARD_D_K_NICAM_FM) ? "D/K-NICAM-FM" : \
2176 (x == DRX_AUD_STANDARD_UNKNOWN) ? "Unknown" : \
2177 "(Invalid)")
2178#define DRX_STR_AUD_STEREO(x) ( \
2179 (x == true) ? "Stereo" : \
2180 (x == false) ? "Mono" : \
2181 "(Invalid)")
2182
2183#define DRX_STR_AUD_SAP(x) ( \
2184 (x == true) ? "Present" : \
2185 (x == false) ? "Not present" : \
2186 "(Invalid)")
2187
2188#define DRX_STR_AUD_CARRIER(x) ( \
2189 (x == true) ? "Present" : \
2190 (x == false) ? "Not present" : \
2191 "(Invalid)")
2192
2193#define DRX_STR_AUD_RDS(x) ( \
2194 (x == true) ? "Available" : \
2195 (x == false) ? "Not Available" : \
2196 "(Invalid)")
2197
2198#define DRX_STR_AUD_NICAM_STATUS(x) ( \
2199 (x == DRX_AUD_NICAM_DETECTED) ? "Detected" : \
2200 (x == DRX_AUD_NICAM_NOT_DETECTED) ? "Not detected" : \
2201 (x == DRX_AUD_NICAM_BAD) ? "Bad" : \
2202 "(Invalid)")
2203
2204#define DRX_STR_RDS_VALID(x) ( \
2205 (x == true) ? "Valid" : \
2206 (x == false) ? "Not Valid" : \
2207 "(Invalid)")
2208
2209/*-------------------------------------------------------------------------
2210Access macros
2211-------------------------------------------------------------------------*/
2212
2213/**
2214* \brief Create a compilable reference to the microcode attribute
2215* \param d pointer to demod instance
2216*
2217* Used as main reference to an attribute field.
2218* Used by both macro implementation and function implementation.
2219* These macros are defined to avoid duplication of code in macro and function
2220* definitions that handle access of demod common or extended attributes.
2221*
2222*/
2223
2224#define DRX_ATTR_MCRECORD(d) ((d)->my_common_attr->mcversion)
2225#define DRX_ATTR_MIRRORFREQSPECT(d) ((d)->my_common_attr->mirror_freq_spect)
2226#define DRX_ATTR_CURRENTPOWERMODE(d)((d)->my_common_attr->current_power_mode)
2227#define DRX_ATTR_ISOPENED(d) ((d)->my_common_attr->is_opened)
2228#define DRX_ATTR_USEBOOTLOADER(d) ((d)->my_common_attr->use_bootloader)
2229#define DRX_ATTR_CURRENTSTANDARD(d) ((d)->my_common_attr->current_standard)
2230#define DRX_ATTR_PREVSTANDARD(d) ((d)->my_common_attr->prev_standard)
2231#define DRX_ATTR_CACHESTANDARD(d) ((d)->my_common_attr->di_cache_standard)
2232#define DRX_ATTR_CURRENTCHANNEL(d) ((d)->my_common_attr->current_channel)
2233#define DRX_ATTR_MICROCODE(d) ((d)->my_common_attr->microcode)
2234#define DRX_ATTR_VERIFYMICROCODE(d) ((d)->my_common_attr->verify_microcode)
2235#define DRX_ATTR_CAPABILITIES(d) ((d)->my_common_attr->capabilities)
2236#define DRX_ATTR_PRODUCTID(d) ((d)->my_common_attr->product_id)
2237#define DRX_ATTR_INTERMEDIATEFREQ(d) ((d)->my_common_attr->intermediate_freq)
2238#define DRX_ATTR_SYSCLOCKFREQ(d) ((d)->my_common_attr->sys_clock_freq)
2239#define DRX_ATTR_TUNERRFAGCPOL(d) ((d)->my_common_attr->tuner_rf_agc_pol)
2240#define DRX_ATTR_TUNERIFAGCPOL(d) ((d)->my_common_attr->tuner_if_agc_pol)
2241#define DRX_ATTR_TUNERSLOWMODE(d) ((d)->my_common_attr->tuner_slow_mode)
2242#define DRX_ATTR_TUNERSPORTNR(d) ((d)->my_common_attr->tuner_port_nr)
2243#define DRX_ATTR_I2CADDR(d) ((d)->my_i2c_dev_addr->i2c_addr)
2244#define DRX_ATTR_I2CDEVID(d) ((d)->my_i2c_dev_addr->i2c_dev_id)
2245#define DRX_ISMCVERTYPE(x) ((x) == AUX_VER_RECORD)
2246
2247/**************************/
2248
2249/* Macros with device-specific handling are converted to CFG functions */
2250
2251#define DRX_ACCESSMACRO_SET(demod, value, cfg_name, data_type) \
2252 do { \
2253 struct drx_cfg config; \
2254 data_type cfg_data; \
2255 config.cfg_type = cfg_name; \
2256 config.cfg_data = &cfg_data; \
2257 cfg_data = value; \
2258 drx_ctrl(demod, DRX_CTRL_SET_CFG, &config); \
2259 } while (0)
2260
2261#define DRX_ACCESSMACRO_GET(demod, value, cfg_name, data_type, error_value) \
2262 do { \
2263 int cfg_status; \
2264 struct drx_cfg config; \
2265 data_type cfg_data; \
2266 config.cfg_type = cfg_name; \
2267 config.cfg_data = &cfg_data; \
2268 cfg_status = drx_ctrl(demod, DRX_CTRL_GET_CFG, &config); \
2269 if (cfg_status == 0) { \
2270 value = cfg_data; \
2271 } else { \
2272 value = (data_type)error_value; \
2273 } \
2274 } while (0)
2275
2276/* Configuration functions for usage by Access (XS) Macros */
2277
2278#ifndef DRX_XS_CFG_BASE
2279#define DRX_XS_CFG_BASE (500)
2280#endif
2281
2282#define DRX_XS_CFG_PRESET (DRX_XS_CFG_BASE + 0)
2283#define DRX_XS_CFG_AUD_BTSC_DETECT (DRX_XS_CFG_BASE + 1)
2284#define DRX_XS_CFG_QAM_LOCKRANGE (DRX_XS_CFG_BASE + 2)
2285
2286/* Access Macros with device-specific handling */
2287
2288#define DRX_SET_PRESET(d, x) \
2289 DRX_ACCESSMACRO_SET((d), (x), DRX_XS_CFG_PRESET, char*)
2290#define DRX_GET_PRESET(d, x) \
2291 DRX_ACCESSMACRO_GET((d), (x), DRX_XS_CFG_PRESET, char*, "ERROR")
2292
2293#define DRX_SET_AUD_BTSC_DETECT(d, x) DRX_ACCESSMACRO_SET((d), (x), \
2294 DRX_XS_CFG_AUD_BTSC_DETECT, enum drx_aud_btsc_detect)
2295#define DRX_GET_AUD_BTSC_DETECT(d, x) DRX_ACCESSMACRO_GET((d), (x), \
2296 DRX_XS_CFG_AUD_BTSC_DETECT, enum drx_aud_btsc_detect, DRX_UNKNOWN)
2297
2298#define DRX_SET_QAM_LOCKRANGE(d, x) DRX_ACCESSMACRO_SET((d), (x), \
2299 DRX_XS_CFG_QAM_LOCKRANGE, enum drx_qam_lock_range)
2300#define DRX_GET_QAM_LOCKRANGE(d, x) DRX_ACCESSMACRO_GET((d), (x), \
2301 DRX_XS_CFG_QAM_LOCKRANGE, enum drx_qam_lock_range, DRX_UNKNOWN)
2302
2303/**
2304* \brief Macro to check if std is an ATV standard
2305* \retval true std is an ATV standard
2306* \retval false std is an ATV standard
2307*/
2308#define DRX_ISATVSTD(std) (((std) == DRX_STANDARD_PAL_SECAM_BG) || \
2309 ((std) == DRX_STANDARD_PAL_SECAM_DK) || \
2310 ((std) == DRX_STANDARD_PAL_SECAM_I) || \
2311 ((std) == DRX_STANDARD_PAL_SECAM_L) || \
2312 ((std) == DRX_STANDARD_PAL_SECAM_LP) || \
2313 ((std) == DRX_STANDARD_NTSC) || \
2314 ((std) == DRX_STANDARD_FM))
2315
2316/**
2317* \brief Macro to check if std is an QAM standard
2318* \retval true std is an QAM standards
2319* \retval false std is an QAM standards
2320*/
2321#define DRX_ISQAMSTD(std) (((std) == DRX_STANDARD_ITU_A) || \
2322 ((std) == DRX_STANDARD_ITU_B) || \
2323 ((std) == DRX_STANDARD_ITU_C) || \
2324 ((std) == DRX_STANDARD_ITU_D))
2325
2326/**
2327* \brief Macro to check if std is VSB standard
2328* \retval true std is VSB standard
2329* \retval false std is not VSB standard
2330*/
2331#define DRX_ISVSBSTD(std) ((std) == DRX_STANDARD_8VSB)
2332
2333/**
2334* \brief Macro to check if std is DVBT standard
2335* \retval true std is DVBT standard
2336* \retval false std is not DVBT standard
2337*/
2338#define DRX_ISDVBTSTD(std) ((std) == DRX_STANDARD_DVBT)
2339
2340/*-------------------------------------------------------------------------
2341THE END
2342-------------------------------------------------------------------------*/
2343#endif /* __DRXDRIVER_H__ */
diff --git a/drivers/media/dvb-frontends/drx39xyj/drx_driver_version.h b/drivers/media/dvb-frontends/drx39xyj/drx_driver_version.h
new file mode 100644
index 000000000000..ff05a4ffb190
--- /dev/null
+++ b/drivers/media/dvb-frontends/drx39xyj/drx_driver_version.h
@@ -0,0 +1,72 @@
1/*
2 *******************************************************************************
3 * WARNING - THIS FILE HAS BEEN GENERATED - DO NOT CHANGE
4 *
5 * Filename: drx_driver_version.h
6 * Generated on: Mon Jan 18 12:09:23 2010
7 * Generated by: IDF:x 1.3.0
8 * Generated from: ../../../device/drxj/version
9 * Output start: [entry point]
10 *
11 * filename last modified re-use
12 *
13 Copyright (c), 2004-2005,2007-2010 Trident Microsystems, Inc.
14 All rights reserved.
15
16 Redistribution and use in source and binary forms, with or without
17 modification, are permitted provided that the following conditions are met:
18
19 * Redistributions of source code must retain the above copyright notice,
20 this list of conditions and the following disclaimer.
21 * Redistributions in binary form must reproduce the above copyright notice,
22 this list of conditions and the following disclaimer in the documentation
23 and/or other materials provided with the distribution.
24 * Neither the name of Trident Microsystems nor Hauppauge Computer Works
25 nor the names of its contributors may be used to endorse or promote
26 products derived from this software without specific prior written
27 permission.
28
29 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
33 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 POSSIBILITY OF SUCH DAMAGE.
40*/
41
42/* -----------------------------------------------------
43 * version.idf Mon Jan 18 11:56:10 2010 -
44 *
45 */
46
47#ifndef __DRX_DRIVER_VERSION__H__
48#define __DRX_DRIVER_VERSION__H__ INCLUDED
49
50#ifdef _REGISTERTABLE_
51#include <registertable.h>
52 extern register_table_t drx_driver_version[];
53 extern register_table_info_t drx_driver_version_info[];
54#endif /* _REGISTERTABLE_ */
55
56/*
57 *==============================================================================
58 * VERSION
59 * version@/var/cvs/projects/drxj.cvsroot/hostcode/drxdriver/device/drxj
60 *==============================================================================
61 */
62
63#define VERSION__A 0x0
64#define VERSION_MAJOR 1
65#define VERSION_MINOR 0
66#define VERSION_PATCH 56
67
68#endif /* __DRX_DRIVER_VERSION__H__ */
69/*
70 * End of file (drx_driver_version.h)
71 *******************************************************************************
72 */
diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
new file mode 100644
index 000000000000..9482954fd453
--- /dev/null
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -0,0 +1,12400 @@
1/*
2 Copyright (c), 2004-2005,2007-2010 Trident Microsystems, Inc.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
13 * Neither the name of Trident Microsystems nor Hauppauge Computer Works
14 nor the names of its contributors may be used to endorse or promote
15 products derived from this software without specific prior written
16 permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 POSSIBILITY OF SUCH DAMAGE.
29
30 DRXJ specific implementation of DRX driver
31 authors: Dragan Savic, Milos Nikolic, Mihajlo Katona, Tao Ding, Paul Janssen
32
33 The Linux DVB Driver for Micronas DRX39xx family (drx3933j) was
34 written by Devin Heitmueller <devin.heitmueller@kernellabs.com>
35
36 This program is free software; you can redistribute it and/or modify
37 it under the terms of the GNU General Public License as published by
38 the Free Software Foundation; either version 2 of the License, or
39 (at your option) any later version.
40
41 This program is distributed in the hope that it will be useful,
42 but WITHOUT ANY WARRANTY; without even the implied warranty of
43 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44
45 GNU General Public License for more details.
46
47 You should have received a copy of the GNU General Public License
48 along with this program; if not, write to the Free Software
49 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
50*/
51
52/*-----------------------------------------------------------------------------
53INCLUDE FILES
54----------------------------------------------------------------------------*/
55
56#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
57
58#include <linux/module.h>
59#include <linux/init.h>
60#include <linux/string.h>
61#include <linux/slab.h>
62#include <asm/div64.h>
63
64#include "dvb_frontend.h"
65#include "drx39xxj.h"
66
67#include "drxj.h"
68#include "drxj_map.h"
69
70/*============================================================================*/
71/*=== DEFINES ================================================================*/
72/*============================================================================*/
73
74#define DRX39XX_MAIN_FIRMWARE "dvb-fe-drxj-mc-1.0.8.fw"
75
76/**
77* \brief Maximum u32 value.
78*/
79#ifndef MAX_U32
80#define MAX_U32 ((u32) (0xFFFFFFFFL))
81#endif
82
83/* Customer configurable hardware settings, etc */
84#ifndef MPEG_SERIAL_OUTPUT_PIN_DRIVE_STRENGTH
85#define MPEG_SERIAL_OUTPUT_PIN_DRIVE_STRENGTH 0x02
86#endif
87
88#ifndef MPEG_PARALLEL_OUTPUT_PIN_DRIVE_STRENGTH
89#define MPEG_PARALLEL_OUTPUT_PIN_DRIVE_STRENGTH 0x02
90#endif
91
92#ifndef MPEG_OUTPUT_CLK_DRIVE_STRENGTH
93#define MPEG_OUTPUT_CLK_DRIVE_STRENGTH 0x06
94#endif
95
96#ifndef OOB_CRX_DRIVE_STRENGTH
97#define OOB_CRX_DRIVE_STRENGTH 0x02
98#endif
99
100#ifndef OOB_DRX_DRIVE_STRENGTH
101#define OOB_DRX_DRIVE_STRENGTH 0x02
102#endif
103/**** START DJCOMBO patches to DRXJ registermap constants *********************/
104/**** registermap 200706071303 from drxj **************************************/
105#define ATV_TOP_CR_AMP_TH_FM 0x0
106#define ATV_TOP_CR_AMP_TH_L 0xA
107#define ATV_TOP_CR_AMP_TH_LP 0xA
108#define ATV_TOP_CR_AMP_TH_BG 0x8
109#define ATV_TOP_CR_AMP_TH_DK 0x8
110#define ATV_TOP_CR_AMP_TH_I 0x8
111#define ATV_TOP_CR_CONT_CR_D_MN 0x18
112#define ATV_TOP_CR_CONT_CR_D_FM 0x0
113#define ATV_TOP_CR_CONT_CR_D_L 0x20
114#define ATV_TOP_CR_CONT_CR_D_LP 0x20
115#define ATV_TOP_CR_CONT_CR_D_BG 0x18
116#define ATV_TOP_CR_CONT_CR_D_DK 0x18
117#define ATV_TOP_CR_CONT_CR_D_I 0x18
118#define ATV_TOP_CR_CONT_CR_I_MN 0x80
119#define ATV_TOP_CR_CONT_CR_I_FM 0x0
120#define ATV_TOP_CR_CONT_CR_I_L 0x80
121#define ATV_TOP_CR_CONT_CR_I_LP 0x80
122#define ATV_TOP_CR_CONT_CR_I_BG 0x80
123#define ATV_TOP_CR_CONT_CR_I_DK 0x80
124#define ATV_TOP_CR_CONT_CR_I_I 0x80
125#define ATV_TOP_CR_CONT_CR_P_MN 0x4
126#define ATV_TOP_CR_CONT_CR_P_FM 0x0
127#define ATV_TOP_CR_CONT_CR_P_L 0x4
128#define ATV_TOP_CR_CONT_CR_P_LP 0x4
129#define ATV_TOP_CR_CONT_CR_P_BG 0x4
130#define ATV_TOP_CR_CONT_CR_P_DK 0x4
131#define ATV_TOP_CR_CONT_CR_P_I 0x4
132#define ATV_TOP_CR_OVM_TH_MN 0xA0
133#define ATV_TOP_CR_OVM_TH_FM 0x0
134#define ATV_TOP_CR_OVM_TH_L 0xA0
135#define ATV_TOP_CR_OVM_TH_LP 0xA0
136#define ATV_TOP_CR_OVM_TH_BG 0xA0
137#define ATV_TOP_CR_OVM_TH_DK 0xA0
138#define ATV_TOP_CR_OVM_TH_I 0xA0
139#define ATV_TOP_EQU0_EQU_C0_FM 0x0
140#define ATV_TOP_EQU0_EQU_C0_L 0x3
141#define ATV_TOP_EQU0_EQU_C0_LP 0x3
142#define ATV_TOP_EQU0_EQU_C0_BG 0x7
143#define ATV_TOP_EQU0_EQU_C0_DK 0x0
144#define ATV_TOP_EQU0_EQU_C0_I 0x3
145#define ATV_TOP_EQU1_EQU_C1_FM 0x0
146#define ATV_TOP_EQU1_EQU_C1_L 0x1F6
147#define ATV_TOP_EQU1_EQU_C1_LP 0x1F6
148#define ATV_TOP_EQU1_EQU_C1_BG 0x197
149#define ATV_TOP_EQU1_EQU_C1_DK 0x198
150#define ATV_TOP_EQU1_EQU_C1_I 0x1F6
151#define ATV_TOP_EQU2_EQU_C2_FM 0x0
152#define ATV_TOP_EQU2_EQU_C2_L 0x28
153#define ATV_TOP_EQU2_EQU_C2_LP 0x28
154#define ATV_TOP_EQU2_EQU_C2_BG 0xC5
155#define ATV_TOP_EQU2_EQU_C2_DK 0xB0
156#define ATV_TOP_EQU2_EQU_C2_I 0x28
157#define ATV_TOP_EQU3_EQU_C3_FM 0x0
158#define ATV_TOP_EQU3_EQU_C3_L 0x192
159#define ATV_TOP_EQU3_EQU_C3_LP 0x192
160#define ATV_TOP_EQU3_EQU_C3_BG 0x12E
161#define ATV_TOP_EQU3_EQU_C3_DK 0x18E
162#define ATV_TOP_EQU3_EQU_C3_I 0x192
163#define ATV_TOP_STD_MODE_MN 0x0
164#define ATV_TOP_STD_MODE_FM 0x1
165#define ATV_TOP_STD_MODE_L 0x0
166#define ATV_TOP_STD_MODE_LP 0x0
167#define ATV_TOP_STD_MODE_BG 0x0
168#define ATV_TOP_STD_MODE_DK 0x0
169#define ATV_TOP_STD_MODE_I 0x0
170#define ATV_TOP_STD_VID_POL_MN 0x0
171#define ATV_TOP_STD_VID_POL_FM 0x0
172#define ATV_TOP_STD_VID_POL_L 0x2
173#define ATV_TOP_STD_VID_POL_LP 0x2
174#define ATV_TOP_STD_VID_POL_BG 0x0
175#define ATV_TOP_STD_VID_POL_DK 0x0
176#define ATV_TOP_STD_VID_POL_I 0x0
177#define ATV_TOP_VID_AMP_MN 0x380
178#define ATV_TOP_VID_AMP_FM 0x0
179#define ATV_TOP_VID_AMP_L 0xF50
180#define ATV_TOP_VID_AMP_LP 0xF50
181#define ATV_TOP_VID_AMP_BG 0x380
182#define ATV_TOP_VID_AMP_DK 0x394
183#define ATV_TOP_VID_AMP_I 0x3D8
184#define IQM_CF_OUT_ENA_OFDM__M 0x4
185#define IQM_FS_ADJ_SEL_B_QAM 0x1
186#define IQM_FS_ADJ_SEL_B_OFF 0x0
187#define IQM_FS_ADJ_SEL_B_VSB 0x2
188#define IQM_RC_ADJ_SEL_B_OFF 0x0
189#define IQM_RC_ADJ_SEL_B_QAM 0x1
190#define IQM_RC_ADJ_SEL_B_VSB 0x2
191/**** END DJCOMBO patches to DRXJ registermap *********************************/
192
193#include "drx_driver_version.h"
194
195/* #define DRX_DEBUG */
196#ifdef DRX_DEBUG
197#include <stdio.h>
198#endif
199
200/*-----------------------------------------------------------------------------
201ENUMS
202----------------------------------------------------------------------------*/
203
204/*-----------------------------------------------------------------------------
205DEFINES
206----------------------------------------------------------------------------*/
207#ifndef DRXJ_WAKE_UP_KEY
208#define DRXJ_WAKE_UP_KEY (demod->my_i2c_dev_addr->i2c_addr)
209#endif
210
211/**
212* \def DRXJ_DEF_I2C_ADDR
213* \brief Default I2C addres of a demodulator instance.
214*/
215#define DRXJ_DEF_I2C_ADDR (0x52)
216
217/**
218* \def DRXJ_DEF_DEMOD_DEV_ID
219* \brief Default device identifier of a demodultor instance.
220*/
221#define DRXJ_DEF_DEMOD_DEV_ID (1)
222
223/**
224* \def DRXJ_SCAN_TIMEOUT
225* \brief Timeout value for waiting on demod lock during channel scan (millisec).
226*/
227#define DRXJ_SCAN_TIMEOUT 1000
228
229/**
230* \def HI_I2C_DELAY
231* \brief HI timing delay for I2C timing (in nano seconds)
232*
233* Used to compute HI_CFG_DIV
234*/
235#define HI_I2C_DELAY 42
236
237/**
238* \def HI_I2C_BRIDGE_DELAY
239* \brief HI timing delay for I2C timing (in nano seconds)
240*
241* Used to compute HI_CFG_BDL
242*/
243#define HI_I2C_BRIDGE_DELAY 750
244
245/**
246* \brief Time Window for MER and SER Measurement in Units of Segment duration.
247*/
248#define VSB_TOP_MEASUREMENT_PERIOD 64
249#define SYMBOLS_PER_SEGMENT 832
250
251/**
252* \brief bit rate and segment rate constants used for SER and BER.
253*/
254/* values taken from the QAM microcode */
255#define DRXJ_QAM_SL_SIG_POWER_QAM_UNKNOWN 0
256#define DRXJ_QAM_SL_SIG_POWER_QPSK 32768
257#define DRXJ_QAM_SL_SIG_POWER_QAM8 24576
258#define DRXJ_QAM_SL_SIG_POWER_QAM16 40960
259#define DRXJ_QAM_SL_SIG_POWER_QAM32 20480
260#define DRXJ_QAM_SL_SIG_POWER_QAM64 43008
261#define DRXJ_QAM_SL_SIG_POWER_QAM128 20992
262#define DRXJ_QAM_SL_SIG_POWER_QAM256 43520
263/**
264* \brief Min supported symbolrates.
265*/
266#ifndef DRXJ_QAM_SYMBOLRATE_MIN
267#define DRXJ_QAM_SYMBOLRATE_MIN (520000)
268#endif
269
270/**
271* \brief Max supported symbolrates.
272*/
273#ifndef DRXJ_QAM_SYMBOLRATE_MAX
274#define DRXJ_QAM_SYMBOLRATE_MAX (7233000)
275#endif
276
277/**
278* \def DRXJ_QAM_MAX_WAITTIME
279* \brief Maximal wait time for QAM auto constellation in ms
280*/
281#ifndef DRXJ_QAM_MAX_WAITTIME
282#define DRXJ_QAM_MAX_WAITTIME 900
283#endif
284
285#ifndef DRXJ_QAM_FEC_LOCK_WAITTIME
286#define DRXJ_QAM_FEC_LOCK_WAITTIME 150
287#endif
288
289#ifndef DRXJ_QAM_DEMOD_LOCK_EXT_WAITTIME
290#define DRXJ_QAM_DEMOD_LOCK_EXT_WAITTIME 200
291#endif
292
293/**
294* \def SCU status and results
295* \brief SCU
296*/
297#define DRX_SCU_READY 0
298#define DRXJ_MAX_WAITTIME 100 /* ms */
299#define FEC_RS_MEASUREMENT_PERIOD 12894 /* 1 sec */
300#define FEC_RS_MEASUREMENT_PRESCALE 1 /* n sec */
301
302/**
303* \def DRX_AUD_MAX_DEVIATION
304* \brief Needed for calculation of prescale feature in AUD
305*/
306#ifndef DRXJ_AUD_MAX_FM_DEVIATION
307#define DRXJ_AUD_MAX_FM_DEVIATION 100 /* kHz */
308#endif
309
310/**
311* \brief Needed for calculation of NICAM prescale feature in AUD
312*/
313#ifndef DRXJ_AUD_MAX_NICAM_PRESCALE
314#define DRXJ_AUD_MAX_NICAM_PRESCALE (9) /* dB */
315#endif
316
317/**
318* \brief Needed for calculation of NICAM prescale feature in AUD
319*/
320#ifndef DRXJ_AUD_MAX_WAITTIME
321#define DRXJ_AUD_MAX_WAITTIME 250 /* ms */
322#endif
323
324/* ATV config changed flags */
325#define DRXJ_ATV_CHANGED_COEF (0x00000001UL)
326#define DRXJ_ATV_CHANGED_PEAK_FLT (0x00000008UL)
327#define DRXJ_ATV_CHANGED_NOISE_FLT (0x00000010UL)
328#define DRXJ_ATV_CHANGED_OUTPUT (0x00000020UL)
329#define DRXJ_ATV_CHANGED_SIF_ATT (0x00000040UL)
330
331/* UIO define */
332#define DRX_UIO_MODE_FIRMWARE_SMA DRX_UIO_MODE_FIRMWARE0
333#define DRX_UIO_MODE_FIRMWARE_SAW DRX_UIO_MODE_FIRMWARE1
334
335/*
336 * MICROCODE RELATED DEFINES
337 */
338
339/* Magic word for checking correct Endianess of microcode data */
340#define DRX_UCODE_MAGIC_WORD ((((u16)'H')<<8)+((u16)'L'))
341
342/* CRC flag in ucode header, flags field. */
343#define DRX_UCODE_CRC_FLAG (0x0001)
344
345/*
346 * Maximum size of buffer used to verify the microcode.
347 * Must be an even number
348 */
349#define DRX_UCODE_MAX_BUF_SIZE (DRXDAP_MAX_RCHUNKSIZE)
350
351#if DRX_UCODE_MAX_BUF_SIZE & 1
352#error DRX_UCODE_MAX_BUF_SIZE must be an even number
353#endif
354
355/*
356 * Power mode macros
357 */
358
359#define DRX_ISPOWERDOWNMODE(mode) ((mode == DRX_POWER_MODE_9) || \
360 (mode == DRX_POWER_MODE_10) || \
361 (mode == DRX_POWER_MODE_11) || \
362 (mode == DRX_POWER_MODE_12) || \
363 (mode == DRX_POWER_MODE_13) || \
364 (mode == DRX_POWER_MODE_14) || \
365 (mode == DRX_POWER_MODE_15) || \
366 (mode == DRX_POWER_MODE_16) || \
367 (mode == DRX_POWER_DOWN))
368
369/* Pin safe mode macro */
370#define DRXJ_PIN_SAFE_MODE 0x0000
371/*============================================================================*/
372/*=== GLOBAL VARIABLEs =======================================================*/
373/*============================================================================*/
374/**
375*/
376
377/**
378* \brief Temporary register definitions.
379* (register definitions that are not yet available in register master)
380*/
381
382/******************************************************************************/
383/* Audio block 0x103 is write only. To avoid shadowing in driver accessing */
384/* RAM adresses directly. This must be READ ONLY to avoid problems. */
385/* Writing to the interface adresses is more than only writing the RAM */
386/* locations */
387/******************************************************************************/
388/**
389* \brief RAM location of MODUS registers
390*/
391#define AUD_DEM_RAM_MODUS_HI__A 0x10204A3
392#define AUD_DEM_RAM_MODUS_HI__M 0xF000
393
394#define AUD_DEM_RAM_MODUS_LO__A 0x10204A4
395#define AUD_DEM_RAM_MODUS_LO__M 0x0FFF
396
397/**
398* \brief RAM location of I2S config registers
399*/
400#define AUD_DEM_RAM_I2S_CONFIG1__A 0x10204B1
401#define AUD_DEM_RAM_I2S_CONFIG2__A 0x10204B2
402
403/**
404* \brief RAM location of DCO config registers
405*/
406#define AUD_DEM_RAM_DCO_B_HI__A 0x1020461
407#define AUD_DEM_RAM_DCO_B_LO__A 0x1020462
408#define AUD_DEM_RAM_DCO_A_HI__A 0x1020463
409#define AUD_DEM_RAM_DCO_A_LO__A 0x1020464
410
411/**
412* \brief RAM location of Threshold registers
413*/
414#define AUD_DEM_RAM_NICAM_THRSHLD__A 0x102045A
415#define AUD_DEM_RAM_A2_THRSHLD__A 0x10204BB
416#define AUD_DEM_RAM_BTSC_THRSHLD__A 0x10204A6
417
418/**
419* \brief RAM location of Carrier Threshold registers
420*/
421#define AUD_DEM_RAM_CM_A_THRSHLD__A 0x10204AF
422#define AUD_DEM_RAM_CM_B_THRSHLD__A 0x10204B0
423
424/**
425* \brief FM Matrix register fix
426*/
427#ifdef AUD_DEM_WR_FM_MATRIX__A
428#undef AUD_DEM_WR_FM_MATRIX__A
429#endif
430#define AUD_DEM_WR_FM_MATRIX__A 0x105006F
431
432/*============================================================================*/
433/**
434* \brief Defines required for audio
435*/
436#define AUD_VOLUME_ZERO_DB 115
437#define AUD_VOLUME_DB_MIN -60
438#define AUD_VOLUME_DB_MAX 12
439#define AUD_CARRIER_STRENGTH_QP_0DB 0x4000
440#define AUD_CARRIER_STRENGTH_QP_0DB_LOG10T100 421
441#define AUD_MAX_AVC_REF_LEVEL 15
442#define AUD_I2S_FREQUENCY_MAX 48000UL
443#define AUD_I2S_FREQUENCY_MIN 12000UL
444#define AUD_RDS_ARRAY_SIZE 18
445
446/**
447* \brief Needed for calculation of prescale feature in AUD
448*/
449#ifndef DRX_AUD_MAX_FM_DEVIATION
450#define DRX_AUD_MAX_FM_DEVIATION (100) /* kHz */
451#endif
452
453/**
454* \brief Needed for calculation of NICAM prescale feature in AUD
455*/
456#ifndef DRX_AUD_MAX_NICAM_PRESCALE
457#define DRX_AUD_MAX_NICAM_PRESCALE (9) /* dB */
458#endif
459
460/*============================================================================*/
461/* Values for I2S Master/Slave pin configurations */
462#define SIO_PDR_I2S_CL_CFG_MODE__MASTER 0x0004
463#define SIO_PDR_I2S_CL_CFG_DRIVE__MASTER 0x0008
464#define SIO_PDR_I2S_CL_CFG_MODE__SLAVE 0x0004
465#define SIO_PDR_I2S_CL_CFG_DRIVE__SLAVE 0x0000
466
467#define SIO_PDR_I2S_DA_CFG_MODE__MASTER 0x0003
468#define SIO_PDR_I2S_DA_CFG_DRIVE__MASTER 0x0008
469#define SIO_PDR_I2S_DA_CFG_MODE__SLAVE 0x0003
470#define SIO_PDR_I2S_DA_CFG_DRIVE__SLAVE 0x0008
471
472#define SIO_PDR_I2S_WS_CFG_MODE__MASTER 0x0004
473#define SIO_PDR_I2S_WS_CFG_DRIVE__MASTER 0x0008
474#define SIO_PDR_I2S_WS_CFG_MODE__SLAVE 0x0004
475#define SIO_PDR_I2S_WS_CFG_DRIVE__SLAVE 0x0000
476
477/*============================================================================*/
478/*=== REGISTER ACCESS MACROS =================================================*/
479/*============================================================================*/
480
481/**
482* This macro is used to create byte arrays for block writes.
483* Block writes speed up I2C traffic between host and demod.
484* The macro takes care of the required byte order in a 16 bits word.
485* x -> lowbyte(x), highbyte(x)
486*/
487#define DRXJ_16TO8(x) ((u8) (((u16)x) & 0xFF)), \
488 ((u8)((((u16)x)>>8)&0xFF))
489/**
490* This macro is used to convert byte array to 16 bit register value for block read.
491* Block read speed up I2C traffic between host and demod.
492* The macro takes care of the required byte order in a 16 bits word.
493*/
494#define DRXJ_8TO16(x) ((u16) (x[0] | (x[1] << 8)))
495
496/*============================================================================*/
497/*=== MISC DEFINES ===========================================================*/
498/*============================================================================*/
499
500/*============================================================================*/
501/*=== HI COMMAND RELATED DEFINES =============================================*/
502/*============================================================================*/
503
504/**
505* \brief General maximum number of retries for ucode command interfaces
506*/
507#define DRXJ_MAX_RETRIES (100)
508
509/*============================================================================*/
510/*=== STANDARD RELATED MACROS ================================================*/
511/*============================================================================*/
512
513#define DRXJ_ISATVSTD(std) ((std == DRX_STANDARD_PAL_SECAM_BG) || \
514 (std == DRX_STANDARD_PAL_SECAM_DK) || \
515 (std == DRX_STANDARD_PAL_SECAM_I) || \
516 (std == DRX_STANDARD_PAL_SECAM_L) || \
517 (std == DRX_STANDARD_PAL_SECAM_LP) || \
518 (std == DRX_STANDARD_NTSC) || \
519 (std == DRX_STANDARD_FM))
520
521#define DRXJ_ISQAMSTD(std) ((std == DRX_STANDARD_ITU_A) || \
522 (std == DRX_STANDARD_ITU_B) || \
523 (std == DRX_STANDARD_ITU_C) || \
524 (std == DRX_STANDARD_ITU_D))
525
526/*-----------------------------------------------------------------------------
527GLOBAL VARIABLES
528----------------------------------------------------------------------------*/
529/*
530 * DRXJ DAP structures
531 */
532
533static int drxdap_fasi_read_block(struct i2c_device_addr *dev_addr,
534 u32 addr,
535 u16 datasize,
536 u8 *data, u32 flags);
537
538
539static int drxj_dap_read_modify_write_reg16(struct i2c_device_addr *dev_addr,
540 u32 waddr,
541 u32 raddr,
542 u16 wdata, u16 *rdata);
543
544static int drxj_dap_read_reg16(struct i2c_device_addr *dev_addr,
545 u32 addr,
546 u16 *data, u32 flags);
547
548static int drxdap_fasi_read_reg32(struct i2c_device_addr *dev_addr,
549 u32 addr,
550 u32 *data, u32 flags);
551
552static int drxdap_fasi_write_block(struct i2c_device_addr *dev_addr,
553 u32 addr,
554 u16 datasize,
555 u8 *data, u32 flags);
556
557static int drxj_dap_write_reg16(struct i2c_device_addr *dev_addr,
558 u32 addr,
559 u16 data, u32 flags);
560
561static int drxdap_fasi_write_reg32(struct i2c_device_addr *dev_addr,
562 u32 addr,
563 u32 data, u32 flags);
564
565static struct drxj_data drxj_data_g = {
566 false, /* has_lna : true if LNA (aka PGA) present */
567 false, /* has_oob : true if OOB supported */
568 false, /* has_ntsc: true if NTSC supported */
569 false, /* has_btsc: true if BTSC supported */
570 false, /* has_smatx: true if SMA_TX pin is available */
571 false, /* has_smarx: true if SMA_RX pin is available */
572 false, /* has_gpio : true if GPIO pin is available */
573 false, /* has_irqn : true if IRQN pin is available */
574 0, /* mfx A1/A2/A... */
575
576 /* tuner settings */
577 false, /* tuner mirrors RF signal */
578 /* standard/channel settings */
579 DRX_STANDARD_UNKNOWN, /* current standard */
580 DRX_CONSTELLATION_AUTO, /* constellation */
581 0, /* frequency in KHz */
582 DRX_BANDWIDTH_UNKNOWN, /* curr_bandwidth */
583 DRX_MIRROR_NO, /* mirror */
584
585 /* signal quality information: */
586 /* default values taken from the QAM Programming guide */
587 /* fec_bits_desired should not be less than 4000000 */
588 4000000, /* fec_bits_desired */
589 5, /* fec_vd_plen */
590 4, /* qam_vd_prescale */
591 0xFFFF, /* qamVDPeriod */
592 204 * 8, /* fec_rs_plen annex A */
593 1, /* fec_rs_prescale */
594 FEC_RS_MEASUREMENT_PERIOD, /* fec_rs_period */
595 true, /* reset_pkt_err_acc */
596 0, /* pkt_err_acc_start */
597
598 /* HI configuration */
599 0, /* hi_cfg_timing_div */
600 0, /* hi_cfg_bridge_delay */
601 0, /* hi_cfg_wake_up_key */
602 0, /* hi_cfg_ctrl */
603 0, /* HICfgTimeout */
604 /* UIO configuartion */
605 DRX_UIO_MODE_DISABLE, /* uio_sma_rx_mode */
606 DRX_UIO_MODE_DISABLE, /* uio_sma_tx_mode */
607 DRX_UIO_MODE_DISABLE, /* uioASELMode */
608 DRX_UIO_MODE_DISABLE, /* uio_irqn_mode */
609 /* FS setting */
610 0UL, /* iqm_fs_rate_ofs */
611 false, /* pos_image */
612 /* RC setting */
613 0UL, /* iqm_rc_rate_ofs */
614 /* AUD information */
615/* false, * flagSetAUDdone */
616/* false, * detectedRDS */
617/* true, * flagASDRequest */
618/* false, * flagHDevClear */
619/* false, * flagHDevSet */
620/* (u16) 0xFFF, * rdsLastCount */
621
622 /* ATV configuartion */
623 0UL, /* flags cfg changes */
624 /* shadow of ATV_TOP_EQU0__A */
625 {-5,
626 ATV_TOP_EQU0_EQU_C0_FM,
627 ATV_TOP_EQU0_EQU_C0_L,
628 ATV_TOP_EQU0_EQU_C0_LP,
629 ATV_TOP_EQU0_EQU_C0_BG,
630 ATV_TOP_EQU0_EQU_C0_DK,
631 ATV_TOP_EQU0_EQU_C0_I},
632 /* shadow of ATV_TOP_EQU1__A */
633 {-50,
634 ATV_TOP_EQU1_EQU_C1_FM,
635 ATV_TOP_EQU1_EQU_C1_L,
636 ATV_TOP_EQU1_EQU_C1_LP,
637 ATV_TOP_EQU1_EQU_C1_BG,
638 ATV_TOP_EQU1_EQU_C1_DK,
639 ATV_TOP_EQU1_EQU_C1_I},
640 /* shadow of ATV_TOP_EQU2__A */
641 {210,
642 ATV_TOP_EQU2_EQU_C2_FM,
643 ATV_TOP_EQU2_EQU_C2_L,
644 ATV_TOP_EQU2_EQU_C2_LP,
645 ATV_TOP_EQU2_EQU_C2_BG,
646 ATV_TOP_EQU2_EQU_C2_DK,
647 ATV_TOP_EQU2_EQU_C2_I},
648 /* shadow of ATV_TOP_EQU3__A */
649 {-160,
650 ATV_TOP_EQU3_EQU_C3_FM,
651 ATV_TOP_EQU3_EQU_C3_L,
652 ATV_TOP_EQU3_EQU_C3_LP,
653 ATV_TOP_EQU3_EQU_C3_BG,
654 ATV_TOP_EQU3_EQU_C3_DK,
655 ATV_TOP_EQU3_EQU_C3_I},
656 false, /* flag: true=bypass */
657 ATV_TOP_VID_PEAK__PRE, /* shadow of ATV_TOP_VID_PEAK__A */
658 ATV_TOP_NOISE_TH__PRE, /* shadow of ATV_TOP_NOISE_TH__A */
659 true, /* flag CVBS ouput enable */
660 false, /* flag SIF ouput enable */
661 DRXJ_SIF_ATTENUATION_0DB, /* current SIF att setting */
662 { /* qam_rf_agc_cfg */
663 DRX_STANDARD_ITU_B, /* standard */
664 DRX_AGC_CTRL_AUTO, /* ctrl_mode */
665 0, /* output_level */
666 0, /* min_output_level */
667 0xFFFF, /* max_output_level */
668 0x0000, /* speed */
669 0x0000, /* top */
670 0x0000 /* c.o.c. */
671 },
672 { /* qam_if_agc_cfg */
673 DRX_STANDARD_ITU_B, /* standard */
674 DRX_AGC_CTRL_AUTO, /* ctrl_mode */
675 0, /* output_level */
676 0, /* min_output_level */
677 0xFFFF, /* max_output_level */
678 0x0000, /* speed */
679 0x0000, /* top (don't care) */
680 0x0000 /* c.o.c. (don't care) */
681 },
682 { /* vsb_rf_agc_cfg */
683 DRX_STANDARD_8VSB, /* standard */
684 DRX_AGC_CTRL_AUTO, /* ctrl_mode */
685 0, /* output_level */
686 0, /* min_output_level */
687 0xFFFF, /* max_output_level */
688 0x0000, /* speed */
689 0x0000, /* top (don't care) */
690 0x0000 /* c.o.c. (don't care) */
691 },
692 { /* vsb_if_agc_cfg */
693 DRX_STANDARD_8VSB, /* standard */
694 DRX_AGC_CTRL_AUTO, /* ctrl_mode */
695 0, /* output_level */
696 0, /* min_output_level */
697 0xFFFF, /* max_output_level */
698 0x0000, /* speed */
699 0x0000, /* top (don't care) */
700 0x0000 /* c.o.c. (don't care) */
701 },
702 0, /* qam_pga_cfg */
703 0, /* vsb_pga_cfg */
704 { /* qam_pre_saw_cfg */
705 DRX_STANDARD_ITU_B, /* standard */
706 0, /* reference */
707 false /* use_pre_saw */
708 },
709 { /* vsb_pre_saw_cfg */
710 DRX_STANDARD_8VSB, /* standard */
711 0, /* reference */
712 false /* use_pre_saw */
713 },
714
715 /* Version information */
716#ifndef _CH_
717 {
718 "01234567890", /* human readable version microcode */
719 "01234567890" /* human readable version device specific code */
720 },
721 {
722 { /* struct drx_version for microcode */
723 DRX_MODULE_UNKNOWN,
724 (char *)(NULL),
725 0,
726 0,
727 0,
728 (char *)(NULL)
729 },
730 { /* struct drx_version for device specific code */
731 DRX_MODULE_UNKNOWN,
732 (char *)(NULL),
733 0,
734 0,
735 0,
736 (char *)(NULL)
737 }
738 },
739 {
740 { /* struct drx_version_list for microcode */
741 (struct drx_version *) (NULL),
742 (struct drx_version_list *) (NULL)
743 },
744 { /* struct drx_version_list for device specific code */
745 (struct drx_version *) (NULL),
746 (struct drx_version_list *) (NULL)
747 }
748 },
749#endif
750 false, /* smart_ant_inverted */
751 /* Tracking filter setting for OOB */
752 {
753 12000,
754 9300,
755 6600,
756 5280,
757 3700,
758 3000,
759 2000,
760 0},
761 false, /* oob_power_on */
762 0, /* mpeg_ts_static_bitrate */
763 false, /* disable_te_ihandling */
764 false, /* bit_reverse_mpeg_outout */
765 DRXJ_MPEGOUTPUT_CLOCK_RATE_AUTO, /* mpeg_output_clock_rate */
766 DRXJ_MPEG_START_WIDTH_1CLKCYC, /* mpeg_start_width */
767
768 /* Pre SAW & Agc configuration for ATV */
769 {
770 DRX_STANDARD_NTSC, /* standard */
771 7, /* reference */
772 true /* use_pre_saw */
773 },
774 { /* ATV RF-AGC */
775 DRX_STANDARD_NTSC, /* standard */
776 DRX_AGC_CTRL_AUTO, /* ctrl_mode */
777 0, /* output_level */
778 0, /* min_output_level (d.c.) */
779 0, /* max_output_level (d.c.) */
780 3, /* speed */
781 9500, /* top */
782 4000 /* cut-off current */
783 },
784 { /* ATV IF-AGC */
785 DRX_STANDARD_NTSC, /* standard */
786 DRX_AGC_CTRL_AUTO, /* ctrl_mode */
787 0, /* output_level */
788 0, /* min_output_level (d.c.) */
789 0, /* max_output_level (d.c.) */
790 3, /* speed */
791 2400, /* top */
792 0 /* c.o.c. (d.c.) */
793 },
794 140, /* ATV PGA config */
795 0, /* curr_symbol_rate */
796
797 false, /* pdr_safe_mode */
798 SIO_PDR_GPIO_CFG__PRE, /* pdr_safe_restore_val_gpio */
799 SIO_PDR_VSYNC_CFG__PRE, /* pdr_safe_restore_val_v_sync */
800 SIO_PDR_SMA_RX_CFG__PRE, /* pdr_safe_restore_val_sma_rx */
801 SIO_PDR_SMA_TX_CFG__PRE, /* pdr_safe_restore_val_sma_tx */
802
803 4, /* oob_pre_saw */
804 DRXJ_OOB_LO_POW_MINUS10DB, /* oob_lo_pow */
805 {
806 false /* aud_data, only first member */
807 },
808};
809
810/**
811* \var drxj_default_addr_g
812* \brief Default I2C address and device identifier.
813*/
814static struct i2c_device_addr drxj_default_addr_g = {
815 DRXJ_DEF_I2C_ADDR, /* i2c address */
816 DRXJ_DEF_DEMOD_DEV_ID /* device id */
817};
818
819/**
820* \var drxj_default_comm_attr_g
821* \brief Default common attributes of a drxj demodulator instance.
822*/
823static struct drx_common_attr drxj_default_comm_attr_g = {
824 NULL, /* ucode file */
825 true, /* ucode verify switch */
826 {0}, /* version record */
827
828 44000, /* IF in kHz in case no tuner instance is used */
829 (151875 - 0), /* system clock frequency in kHz */
830 0, /* oscillator frequency kHz */
831 0, /* oscillator deviation in ppm, signed */
832 false, /* If true mirror frequency spectrum */
833 {
834 /* MPEG output configuration */
835 true, /* If true, enable MPEG ouput */
836 false, /* If true, insert RS byte */
837 false, /* If true, parallel out otherwise serial */
838 false, /* If true, invert DATA signals */
839 false, /* If true, invert ERR signal */
840 false, /* If true, invert STR signals */
841 false, /* If true, invert VAL signals */
842 false, /* If true, invert CLK signals */
843 true, /* If true, static MPEG clockrate will
844 be used, otherwise clockrate will
845 adapt to the bitrate of the TS */
846 19392658UL, /* Maximum bitrate in b/s in case
847 static clockrate is selected */
848 DRX_MPEG_STR_WIDTH_1 /* MPEG Start width in clock cycles */
849 },
850 /* Initilisations below can be ommited, they require no user input and
851 are initialy 0, NULL or false. The compiler will initialize them to these
852 values when ommited. */
853 false, /* is_opened */
854
855 /* SCAN */
856 NULL, /* no scan params yet */
857 0, /* current scan index */
858 0, /* next scan frequency */
859 false, /* scan ready flag */
860 0, /* max channels to scan */
861 0, /* nr of channels scanned */
862 NULL, /* default scan function */
863 NULL, /* default context pointer */
864 0, /* millisec to wait for demod lock */
865 DRXJ_DEMOD_LOCK, /* desired lock */
866 false,
867
868 /* Power management */
869 DRX_POWER_UP,
870
871 /* Tuner */
872 1, /* nr of I2C port to wich tuner is */
873 0L, /* minimum RF input frequency, in kHz */
874 0L, /* maximum RF input frequency, in kHz */
875 false, /* Rf Agc Polarity */
876 false, /* If Agc Polarity */
877 false, /* tuner slow mode */
878
879 { /* current channel (all 0) */
880 0UL /* channel.frequency */
881 },
882 DRX_STANDARD_UNKNOWN, /* current standard */
883 DRX_STANDARD_UNKNOWN, /* previous standard */
884 DRX_STANDARD_UNKNOWN, /* di_cache_standard */
885 false, /* use_bootloader */
886 0UL, /* capabilities */
887 0 /* mfx */
888};
889
890/**
891* \var drxj_default_demod_g
892* \brief Default drxj demodulator instance.
893*/
894static struct drx_demod_instance drxj_default_demod_g = {
895 &drxj_default_addr_g, /* i2c address & device id */
896 &drxj_default_comm_attr_g, /* demod common attributes */
897 &drxj_data_g /* demod device specific attributes */
898};
899
900/**
901* \brief Default audio data structure for DRK demodulator instance.
902*
903* This structure is DRXK specific.
904*
905*/
906static struct drx_aud_data drxj_default_aud_data_g = {
907 false, /* audio_is_active */
908 DRX_AUD_STANDARD_AUTO, /* audio_standard */
909
910 /* i2sdata */
911 {
912 false, /* output_enable */
913 48000, /* frequency */
914 DRX_I2S_MODE_MASTER, /* mode */
915 DRX_I2S_WORDLENGTH_32, /* word_length */
916 DRX_I2S_POLARITY_RIGHT, /* polarity */
917 DRX_I2S_FORMAT_WS_WITH_DATA /* format */
918 },
919 /* volume */
920 {
921 true, /* mute; */
922 0, /* volume */
923 DRX_AUD_AVC_OFF, /* avc_mode */
924 0, /* avc_ref_level */
925 DRX_AUD_AVC_MAX_GAIN_12DB, /* avc_max_gain */
926 DRX_AUD_AVC_MAX_ATTEN_24DB, /* avc_max_atten */
927 0, /* strength_left */
928 0 /* strength_right */
929 },
930 DRX_AUD_AUTO_SOUND_SELECT_ON_CHANGE_ON, /* auto_sound */
931 /* ass_thresholds */
932 {
933 440, /* A2 */
934 12, /* BTSC */
935 700, /* NICAM */
936 },
937 /* carrier */
938 {
939 /* a */
940 {
941 42, /* thres */
942 DRX_NO_CARRIER_NOISE, /* opt */
943 0, /* shift */
944 0 /* dco */
945 },
946 /* b */
947 {
948 42, /* thres */
949 DRX_NO_CARRIER_MUTE, /* opt */
950 0, /* shift */
951 0 /* dco */
952 },
953
954 },
955 /* mixer */
956 {
957 DRX_AUD_SRC_STEREO_OR_A, /* source_i2s */
958 DRX_AUD_I2S_MATRIX_STEREO, /* matrix_i2s */
959 DRX_AUD_FM_MATRIX_SOUND_A /* matrix_fm */
960 },
961 DRX_AUD_DEVIATION_NORMAL, /* deviation */
962 DRX_AUD_AVSYNC_OFF, /* av_sync */
963
964 /* prescale */
965 {
966 DRX_AUD_MAX_FM_DEVIATION, /* fm_deviation */
967 DRX_AUD_MAX_NICAM_PRESCALE /* nicam_gain */
968 },
969 DRX_AUD_FM_DEEMPH_75US, /* deemph */
970 DRX_BTSC_STEREO, /* btsc_detect */
971 0, /* rds_data_counter */
972 false /* rds_data_present */
973};
974
975/*-----------------------------------------------------------------------------
976STRUCTURES
977----------------------------------------------------------------------------*/
978struct drxjeq_stat {
979 u16 eq_mse;
980 u8 eq_mode;
981 u8 eq_ctrl;
982 u8 eq_stat;
983};
984
985/* HI command */
986struct drxj_hi_cmd {
987 u16 cmd;
988 u16 param1;
989 u16 param2;
990 u16 param3;
991 u16 param4;
992 u16 param5;
993 u16 param6;
994};
995
996/*============================================================================*/
997/*=== MICROCODE RELATED STRUCTURES ===========================================*/
998/*============================================================================*/
999
1000/**
1001 * struct drxu_code_block_hdr - Structure of the microcode block headers
1002 *
1003 * @addr: Destination address of the data in this block
1004 * @size: Size of the block data following this header counted in
1005 * 16 bits words
1006 * @CRC: CRC value of the data block, only valid if CRC flag is
1007 * set.
1008 */
1009struct drxu_code_block_hdr {
1010 u32 addr;
1011 u16 size;
1012 u16 flags;
1013 u16 CRC;
1014};
1015
1016/*-----------------------------------------------------------------------------
1017FUNCTIONS
1018----------------------------------------------------------------------------*/
1019/* Some prototypes */
1020static int
1021hi_command(struct i2c_device_addr *dev_addr,
1022 const struct drxj_hi_cmd *cmd, u16 *result);
1023
1024static int
1025ctrl_lock_status(struct drx_demod_instance *demod, enum drx_lock_status *lock_stat);
1026
1027static int
1028ctrl_power_mode(struct drx_demod_instance *demod, enum drx_power_mode *mode);
1029
1030static int power_down_aud(struct drx_demod_instance *demod);
1031
1032static int
1033ctrl_set_cfg_pre_saw(struct drx_demod_instance *demod, struct drxj_cfg_pre_saw *pre_saw);
1034
1035static int
1036ctrl_set_cfg_afe_gain(struct drx_demod_instance *demod, struct drxj_cfg_afe_gain *afe_gain);
1037
1038/*============================================================================*/
1039/*============================================================================*/
1040/*== HELPER FUNCTIONS ==*/
1041/*============================================================================*/
1042/*============================================================================*/
1043
1044
1045/*============================================================================*/
1046
1047/*
1048* \fn u32 frac28(u32 N, u32 D)
1049* \brief Compute: (1<<28)*N/D
1050* \param N 32 bits
1051* \param D 32 bits
1052* \return (1<<28)*N/D
1053* This function is used to avoid floating-point calculations as they may
1054* not be present on the target platform.
1055
1056* frac28 performs an unsigned 28/28 bits division to 32-bit fixed point
1057* fraction used for setting the Frequency Shifter registers.
1058* N and D can hold numbers up to width: 28-bits.
1059* The 4 bits integer part and the 28 bits fractional part are calculated.
1060
1061* Usage condition: ((1<<28)*n)/d < ((1<<32)-1) => (n/d) < 15.999
1062
1063* N: 0...(1<<28)-1 = 268435454
1064* D: 0...(1<<28)-1
1065* Q: 0...(1<<32)-1
1066*/
1067static u32 frac28(u32 N, u32 D)
1068{
1069 int i = 0;
1070 u32 Q1 = 0;
1071 u32 R0 = 0;
1072
1073 R0 = (N % D) << 4; /* 32-28 == 4 shifts possible at max */
1074 Q1 = N / D; /* integer part, only the 4 least significant bits
1075 will be visible in the result */
1076
1077 /* division using radix 16, 7 nibbles in the result */
1078 for (i = 0; i < 7; i++) {
1079 Q1 = (Q1 << 4) | R0 / D;
1080 R0 = (R0 % D) << 4;
1081 }
1082 /* rounding */
1083 if ((R0 >> 3) >= D)
1084 Q1++;
1085
1086 return Q1;
1087}
1088
1089/**
1090* \fn u32 log1_times100( u32 x)
1091* \brief Compute: 100*log10(x)
1092* \param x 32 bits
1093* \return 100*log10(x)
1094*
1095* 100*log10(x)
1096* = 100*(log2(x)/log2(10)))
1097* = (100*(2^15)*log2(x))/((2^15)*log2(10))
1098* = ((200*(2^15)*log2(x))/((2^15)*log2(10)))/2
1099* = ((200*(2^15)*(log2(x/y)+log2(y)))/((2^15)*log2(10)))/2
1100* = ((200*(2^15)*log2(x/y))+(200*(2^15)*log2(y)))/((2^15)*log2(10)))/2
1101*
1102* where y = 2^k and 1<= (x/y) < 2
1103*/
1104
1105static u32 log1_times100(u32 x)
1106{
1107 static const u8 scale = 15;
1108 static const u8 index_width = 5;
1109 /*
1110 log2lut[n] = (1<<scale) * 200 * log2( 1.0 + ( (1.0/(1<<INDEXWIDTH)) * n ))
1111 0 <= n < ((1<<INDEXWIDTH)+1)
1112 */
1113
1114 static const u32 log2lut[] = {
1115 0, /* 0.000000 */
1116 290941, /* 290941.300628 */
1117 573196, /* 573196.476418 */
1118 847269, /* 847269.179851 */
1119 1113620, /* 1113620.489452 */
1120 1372674, /* 1372673.576986 */
1121 1624818, /* 1624817.752104 */
1122 1870412, /* 1870411.981536 */
1123 2109788, /* 2109787.962654 */
1124 2343253, /* 2343252.817465 */
1125 2571091, /* 2571091.461923 */
1126 2793569, /* 2793568.696416 */
1127 3010931, /* 3010931.055901 */
1128 3223408, /* 3223408.452106 */
1129 3431216, /* 3431215.635215 */
1130 3634553, /* 3634553.498355 */
1131 3833610, /* 3833610.244726 */
1132 4028562, /* 4028562.434393 */
1133 4219576, /* 4219575.925308 */
1134 4406807, /* 4406806.721144 */
1135 4590402, /* 4590401.736809 */
1136 4770499, /* 4770499.491025 */
1137 4947231, /* 4947230.734179 */
1138 5120719, /* 5120719.018555 */
1139 5291081, /* 5291081.217197 */
1140 5458428, /* 5458427.996830 */
1141 5622864, /* 5622864.249668 */
1142 5784489, /* 5784489.488298 */
1143 5943398, /* 5943398.207380 */
1144 6099680, /* 6099680.215452 */
1145 6253421, /* 6253420.939751 */
1146 6404702, /* 6404701.706649 */
1147 6553600, /* 6553600.000000 */
1148 };
1149
1150 u8 i = 0;
1151 u32 y = 0;
1152 u32 d = 0;
1153 u32 k = 0;
1154 u32 r = 0;
1155
1156 if (x == 0)
1157 return 0;
1158
1159 /* Scale x (normalize) */
1160 /* computing y in log(x/y) = log(x) - log(y) */
1161 if ((x & (((u32) (-1)) << (scale + 1))) == 0) {
1162 for (k = scale; k > 0; k--) {
1163 if (x & (((u32) 1) << scale))
1164 break;
1165 x <<= 1;
1166 }
1167 } else {
1168 for (k = scale; k < 31; k++) {
1169 if ((x & (((u32) (-1)) << (scale + 1))) == 0)
1170 break;
1171 x >>= 1;
1172 }
1173 }
1174 /*
1175 Now x has binary point between bit[scale] and bit[scale-1]
1176 and 1.0 <= x < 2.0 */
1177
1178 /* correction for divison: log(x) = log(x/y)+log(y) */
1179 y = k * ((((u32) 1) << scale) * 200);
1180
1181 /* remove integer part */
1182 x &= ((((u32) 1) << scale) - 1);
1183 /* get index */
1184 i = (u8) (x >> (scale - index_width));
1185 /* compute delta (x-a) */
1186 d = x & ((((u32) 1) << (scale - index_width)) - 1);
1187 /* compute log, multiplication ( d* (.. )) must be within range ! */
1188 y += log2lut[i] +
1189 ((d * (log2lut[i + 1] - log2lut[i])) >> (scale - index_width));
1190 /* Conver to log10() */
1191 y /= 108853; /* (log2(10) << scale) */
1192 r = (y >> 1);
1193 /* rounding */
1194 if (y & ((u32)1))
1195 r++;
1196
1197 return r;
1198
1199}
1200
1201/**
1202* \fn u32 frac_times1e6( u16 N, u32 D)
1203* \brief Compute: (N/D) * 1000000.
1204* \param N nominator 16-bits.
1205* \param D denominator 32-bits.
1206* \return u32
1207* \retval ((N/D) * 1000000), 32 bits
1208*
1209* No check on D=0!
1210*/
1211static u32 frac_times1e6(u32 N, u32 D)
1212{
1213 u32 remainder = 0;
1214 u32 frac = 0;
1215
1216 /*
1217 frac = (N * 1000000) / D
1218 To let it fit in a 32 bits computation:
1219 frac = (N * (1000000 >> 4)) / (D >> 4)
1220 This would result in a problem in case D < 16 (div by 0).
1221 So we do it more elaborate as shown below.
1222 */
1223 frac = (((u32) N) * (1000000 >> 4)) / D;
1224 frac <<= 4;
1225 remainder = (((u32) N) * (1000000 >> 4)) % D;
1226 remainder <<= 4;
1227 frac += remainder / D;
1228 remainder = remainder % D;
1229 if ((remainder * 2) > D)
1230 frac++;
1231
1232 return frac;
1233}
1234
1235/*============================================================================*/
1236
1237
1238/**
1239* \brief Values for NICAM prescaler gain. Computed from dB to integer
1240* and rounded. For calc used formula: 16*10^(prescaleGain[dB]/20).
1241*
1242*/
1243static const u16 nicam_presc_table_val[43] = {
1244 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4,
1245 5, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16,
1246 18, 20, 23, 25, 28, 32, 36, 40, 45,
1247 51, 57, 64, 71, 80, 90, 101, 113, 127
1248};
1249
1250/*============================================================================*/
1251/*== END HELPER FUNCTIONS ==*/
1252/*============================================================================*/
1253
1254/*============================================================================*/
1255/*============================================================================*/
1256/*== DRXJ DAP FUNCTIONS ==*/
1257/*============================================================================*/
1258/*============================================================================*/
1259
1260/*
1261 This layer takes care of some device specific register access protocols:
1262 -conversion to short address format
1263 -access to audio block
1264 This layer is placed between the drx_dap_fasi and the rest of the drxj
1265 specific implementation. This layer can use address map knowledge whereas
1266 dap_fasi may not use memory map knowledge.
1267
1268 * For audio currently only 16 bits read and write register access is
1269 supported. More is not needed. RMW and 32 or 8 bit access on audio
1270 registers will have undefined behaviour. Flags (RMW, CRC reset, broadcast
1271 single/multi master) will be ignored.
1272
1273 TODO: check ignoring single/multimaster is ok for AUD access ?
1274*/
1275
1276#define DRXJ_ISAUDWRITE(addr) (((((addr)>>16)&1) == 1) ? true : false)
1277#define DRXJ_DAP_AUDTRIF_TIMEOUT 80 /* millisec */
1278/*============================================================================*/
1279
1280/**
1281* \fn bool is_handled_by_aud_tr_if( u32 addr )
1282* \brief Check if this address is handled by the audio token ring interface.
1283* \param addr
1284* \return bool
1285* \retval true Yes, handled by audio token ring interface
1286* \retval false No, not handled by audio token ring interface
1287*
1288*/
1289static
1290bool is_handled_by_aud_tr_if(u32 addr)
1291{
1292 bool retval = false;
1293
1294 if ((DRXDAP_FASI_ADDR2BLOCK(addr) == 4) &&
1295 (DRXDAP_FASI_ADDR2BANK(addr) > 1) &&
1296 (DRXDAP_FASI_ADDR2BANK(addr) < 6)) {
1297 retval = true;
1298 }
1299
1300 return retval;
1301}
1302
1303/*============================================================================*/
1304
1305int drxbsp_i2c_write_read(struct i2c_device_addr *w_dev_addr,
1306 u16 w_count,
1307 u8 *wData,
1308 struct i2c_device_addr *r_dev_addr,
1309 u16 r_count, u8 *r_data)
1310{
1311 struct drx39xxj_state *state;
1312 struct i2c_msg msg[2];
1313 unsigned int num_msgs;
1314
1315 if (w_dev_addr == NULL) {
1316 /* Read only */
1317 state = r_dev_addr->user_data;
1318 msg[0].addr = r_dev_addr->i2c_addr >> 1;
1319 msg[0].flags = I2C_M_RD;
1320 msg[0].buf = r_data;
1321 msg[0].len = r_count;
1322 num_msgs = 1;
1323 } else if (r_dev_addr == NULL) {
1324 /* Write only */
1325 state = w_dev_addr->user_data;
1326 msg[0].addr = w_dev_addr->i2c_addr >> 1;
1327 msg[0].flags = 0;
1328 msg[0].buf = wData;
1329 msg[0].len = w_count;
1330 num_msgs = 1;
1331 } else {
1332 /* Both write and read */
1333 state = w_dev_addr->user_data;
1334 msg[0].addr = w_dev_addr->i2c_addr >> 1;
1335 msg[0].flags = 0;
1336 msg[0].buf = wData;
1337 msg[0].len = w_count;
1338 msg[1].addr = r_dev_addr->i2c_addr >> 1;
1339 msg[1].flags = I2C_M_RD;
1340 msg[1].buf = r_data;
1341 msg[1].len = r_count;
1342 num_msgs = 2;
1343 }
1344
1345 if (state->i2c == NULL) {
1346 pr_err("i2c was zero, aborting\n");
1347 return 0;
1348 }
1349 if (i2c_transfer(state->i2c, msg, num_msgs) != num_msgs) {
1350 pr_warn("drx3933: I2C write/read failed\n");
1351 return -EREMOTEIO;
1352 }
1353
1354#ifdef DJH_DEBUG
1355 if (w_dev_addr == NULL || r_dev_addr == NULL)
1356 return 0;
1357
1358 state = w_dev_addr->user_data;
1359
1360 if (state->i2c == NULL)
1361 return 0;
1362
1363 msg[0].addr = w_dev_addr->i2c_addr;
1364 msg[0].flags = 0;
1365 msg[0].buf = wData;
1366 msg[0].len = w_count;
1367 msg[1].addr = r_dev_addr->i2c_addr;
1368 msg[1].flags = I2C_M_RD;
1369 msg[1].buf = r_data;
1370 msg[1].len = r_count;
1371 num_msgs = 2;
1372
1373 pr_debug("drx3933 i2c operation addr=%x i2c=%p, wc=%x rc=%x\n",
1374 w_dev_addr->i2c_addr, state->i2c, w_count, r_count);
1375
1376 if (i2c_transfer(state->i2c, msg, 2) != 2) {
1377 pr_warn("drx3933: I2C write/read failed\n");
1378 return -EREMOTEIO;
1379 }
1380#endif
1381 return 0;
1382}
1383
1384/*============================================================================*/
1385
1386/******************************
1387*
1388* int drxdap_fasi_read_block (
1389* struct i2c_device_addr *dev_addr, -- address of I2C device
1390* u32 addr, -- address of chip register/memory
1391* u16 datasize, -- number of bytes to read
1392* u8 *data, -- data to receive
1393* u32 flags) -- special device flags
1394*
1395* Read block data from chip address. Because the chip is word oriented,
1396* the number of bytes to read must be even.
1397*
1398* Make sure that the buffer to receive the data is large enough.
1399*
1400* Although this function expects an even number of bytes, it is still byte
1401* oriented, and the data read back is NOT translated to the endianness of
1402* the target platform.
1403*
1404* Output:
1405* - 0 if reading was successful
1406* in that case: data read is in *data.
1407* - -EIO if anything went wrong
1408*
1409******************************/
1410
1411static int drxdap_fasi_read_block(struct i2c_device_addr *dev_addr,
1412 u32 addr,
1413 u16 datasize,
1414 u8 *data, u32 flags)
1415{
1416 u8 buf[4];
1417 u16 bufx;
1418 int rc;
1419 u16 overhead_size = 0;
1420
1421 /* Check parameters ******************************************************* */
1422 if (dev_addr == NULL)
1423 return -EINVAL;
1424
1425 overhead_size = (IS_I2C_10BIT(dev_addr->i2c_addr) ? 2 : 1) +
1426 (DRXDAP_FASI_LONG_FORMAT(addr) ? 4 : 2);
1427
1428 if ((DRXDAP_FASI_OFFSET_TOO_LARGE(addr)) ||
1429 ((!(DRXDAPFASI_LONG_ADDR_ALLOWED)) &&
1430 DRXDAP_FASI_LONG_FORMAT(addr)) ||
1431 (overhead_size > (DRXDAP_MAX_WCHUNKSIZE)) ||
1432 ((datasize != 0) && (data == NULL)) || ((datasize & 1) == 1)) {
1433 return -EINVAL;
1434 }
1435
1436 /* ReadModifyWrite & mode flag bits are not allowed */
1437 flags &= (~DRXDAP_FASI_RMW & ~DRXDAP_FASI_MODEFLAGS);
1438#if DRXDAP_SINGLE_MASTER
1439 flags |= DRXDAP_FASI_SINGLE_MASTER;
1440#endif
1441
1442 /* Read block from I2C **************************************************** */
1443 do {
1444 u16 todo = (datasize < DRXDAP_MAX_RCHUNKSIZE ?
1445 datasize : DRXDAP_MAX_RCHUNKSIZE);
1446
1447 bufx = 0;
1448
1449 addr &= ~DRXDAP_FASI_FLAGS;
1450 addr |= flags;
1451
1452#if ((DRXDAPFASI_LONG_ADDR_ALLOWED == 1) && (DRXDAPFASI_SHORT_ADDR_ALLOWED == 1))
1453 /* short format address preferred but long format otherwise */
1454 if (DRXDAP_FASI_LONG_FORMAT(addr)) {
1455#endif
1456#if (DRXDAPFASI_LONG_ADDR_ALLOWED == 1)
1457 buf[bufx++] = (u8) (((addr << 1) & 0xFF) | 0x01);
1458 buf[bufx++] = (u8) ((addr >> 16) & 0xFF);
1459 buf[bufx++] = (u8) ((addr >> 24) & 0xFF);
1460 buf[bufx++] = (u8) ((addr >> 7) & 0xFF);
1461#endif
1462#if ((DRXDAPFASI_LONG_ADDR_ALLOWED == 1) && (DRXDAPFASI_SHORT_ADDR_ALLOWED == 1))
1463 } else {
1464#endif
1465#if (DRXDAPFASI_SHORT_ADDR_ALLOWED == 1)
1466 buf[bufx++] = (u8) ((addr << 1) & 0xFF);
1467 buf[bufx++] =
1468 (u8) (((addr >> 16) & 0x0F) |
1469 ((addr >> 18) & 0xF0));
1470#endif
1471#if ((DRXDAPFASI_LONG_ADDR_ALLOWED == 1) && (DRXDAPFASI_SHORT_ADDR_ALLOWED == 1))
1472 }
1473#endif
1474
1475#if DRXDAP_SINGLE_MASTER
1476 /*
1477 * In single master mode, split the read and write actions.
1478 * No special action is needed for write chunks here.
1479 */
1480 rc = drxbsp_i2c_write_read(dev_addr, bufx, buf,
1481 NULL, 0, NULL);
1482 if (rc == 0)
1483 rc = drxbsp_i2c_write_read(NULL, 0, NULL, dev_addr, todo, data);
1484#else
1485 /* In multi master mode, do everything in one RW action */
1486 rc = drxbsp_i2c_write_read(dev_addr, bufx, buf, dev_addr, todo,
1487 data);
1488#endif
1489 data += todo;
1490 addr += (todo >> 1);
1491 datasize -= todo;
1492 } while (datasize && rc == 0);
1493
1494 return rc;
1495}
1496
1497
1498/******************************
1499*
1500* int drxdap_fasi_read_reg16 (
1501* struct i2c_device_addr *dev_addr, -- address of I2C device
1502* u32 addr, -- address of chip register/memory
1503* u16 *data, -- data to receive
1504* u32 flags) -- special device flags
1505*
1506* Read one 16-bit register or memory location. The data received back is
1507* converted back to the target platform's endianness.
1508*
1509* Output:
1510* - 0 if reading was successful
1511* in that case: read data is at *data
1512* - -EIO if anything went wrong
1513*
1514******************************/
1515
1516static int drxdap_fasi_read_reg16(struct i2c_device_addr *dev_addr,
1517 u32 addr,
1518 u16 *data, u32 flags)
1519{
1520 u8 buf[sizeof(*data)];
1521 int rc;
1522
1523 if (!data)
1524 return -EINVAL;
1525
1526 rc = drxdap_fasi_read_block(dev_addr, addr, sizeof(*data), buf, flags);
1527 *data = buf[0] + (((u16) buf[1]) << 8);
1528 return rc;
1529}
1530
1531/******************************
1532*
1533* int drxdap_fasi_read_reg32 (
1534* struct i2c_device_addr *dev_addr, -- address of I2C device
1535* u32 addr, -- address of chip register/memory
1536* u32 *data, -- data to receive
1537* u32 flags) -- special device flags
1538*
1539* Read one 32-bit register or memory location. The data received back is
1540* converted back to the target platform's endianness.
1541*
1542* Output:
1543* - 0 if reading was successful
1544* in that case: read data is at *data
1545* - -EIO if anything went wrong
1546*
1547******************************/
1548
1549static int drxdap_fasi_read_reg32(struct i2c_device_addr *dev_addr,
1550 u32 addr,
1551 u32 *data, u32 flags)
1552{
1553 u8 buf[sizeof(*data)];
1554 int rc;
1555
1556 if (!data)
1557 return -EINVAL;
1558
1559 rc = drxdap_fasi_read_block(dev_addr, addr, sizeof(*data), buf, flags);
1560 *data = (((u32) buf[0]) << 0) +
1561 (((u32) buf[1]) << 8) +
1562 (((u32) buf[2]) << 16) + (((u32) buf[3]) << 24);
1563 return rc;
1564}
1565
1566/******************************
1567*
1568* int drxdap_fasi_write_block (
1569* struct i2c_device_addr *dev_addr, -- address of I2C device
1570* u32 addr, -- address of chip register/memory
1571* u16 datasize, -- number of bytes to read
1572* u8 *data, -- data to receive
1573* u32 flags) -- special device flags
1574*
1575* Write block data to chip address. Because the chip is word oriented,
1576* the number of bytes to write must be even.
1577*
1578* Although this function expects an even number of bytes, it is still byte
1579* oriented, and the data being written is NOT translated from the endianness of
1580* the target platform.
1581*
1582* Output:
1583* - 0 if writing was successful
1584* - -EIO if anything went wrong
1585*
1586******************************/
1587
1588static int drxdap_fasi_write_block(struct i2c_device_addr *dev_addr,
1589 u32 addr,
1590 u16 datasize,
1591 u8 *data, u32 flags)
1592{
1593 u8 buf[DRXDAP_MAX_WCHUNKSIZE];
1594 int st = -EIO;
1595 int first_err = 0;
1596 u16 overhead_size = 0;
1597 u16 block_size = 0;
1598
1599 /* Check parameters ******************************************************* */
1600 if (dev_addr == NULL)
1601 return -EINVAL;
1602
1603 overhead_size = (IS_I2C_10BIT(dev_addr->i2c_addr) ? 2 : 1) +
1604 (DRXDAP_FASI_LONG_FORMAT(addr) ? 4 : 2);
1605
1606 if ((DRXDAP_FASI_OFFSET_TOO_LARGE(addr)) ||
1607 ((!(DRXDAPFASI_LONG_ADDR_ALLOWED)) &&
1608 DRXDAP_FASI_LONG_FORMAT(addr)) ||
1609 (overhead_size > (DRXDAP_MAX_WCHUNKSIZE)) ||
1610 ((datasize != 0) && (data == NULL)) || ((datasize & 1) == 1))
1611 return -EINVAL;
1612
1613 flags &= DRXDAP_FASI_FLAGS;
1614 flags &= ~DRXDAP_FASI_MODEFLAGS;
1615#if DRXDAP_SINGLE_MASTER
1616 flags |= DRXDAP_FASI_SINGLE_MASTER;
1617#endif
1618
1619 /* Write block to I2C ***************************************************** */
1620 block_size = ((DRXDAP_MAX_WCHUNKSIZE) - overhead_size) & ~1;
1621 do {
1622 u16 todo = 0;
1623 u16 bufx = 0;
1624
1625 /* Buffer device address */
1626 addr &= ~DRXDAP_FASI_FLAGS;
1627 addr |= flags;
1628#if (((DRXDAPFASI_LONG_ADDR_ALLOWED) == 1) && ((DRXDAPFASI_SHORT_ADDR_ALLOWED) == 1))
1629 /* short format address preferred but long format otherwise */
1630 if (DRXDAP_FASI_LONG_FORMAT(addr)) {
1631#endif
1632#if ((DRXDAPFASI_LONG_ADDR_ALLOWED) == 1)
1633 buf[bufx++] = (u8) (((addr << 1) & 0xFF) | 0x01);
1634 buf[bufx++] = (u8) ((addr >> 16) & 0xFF);
1635 buf[bufx++] = (u8) ((addr >> 24) & 0xFF);
1636 buf[bufx++] = (u8) ((addr >> 7) & 0xFF);
1637#endif
1638#if (((DRXDAPFASI_LONG_ADDR_ALLOWED) == 1) && ((DRXDAPFASI_SHORT_ADDR_ALLOWED) == 1))
1639 } else {
1640#endif
1641#if ((DRXDAPFASI_SHORT_ADDR_ALLOWED) == 1)
1642 buf[bufx++] = (u8) ((addr << 1) & 0xFF);
1643 buf[bufx++] =
1644 (u8) (((addr >> 16) & 0x0F) |
1645 ((addr >> 18) & 0xF0));
1646#endif
1647#if (((DRXDAPFASI_LONG_ADDR_ALLOWED) == 1) && ((DRXDAPFASI_SHORT_ADDR_ALLOWED) == 1))
1648 }
1649#endif
1650
1651 /*
1652 In single master mode block_size can be 0. In such a case this I2C
1653 sequense will be visible: (1) write address {i2c addr,
1654 4 bytes chip address} (2) write data {i2c addr, 4 bytes data }
1655 (3) write address (4) write data etc...
1656 Addres must be rewriten because HI is reset after data transport and
1657 expects an address.
1658 */
1659 todo = (block_size < datasize ? block_size : datasize);
1660 if (todo == 0) {
1661 u16 overhead_size_i2c_addr = 0;
1662 u16 data_block_size = 0;
1663
1664 overhead_size_i2c_addr =
1665 (IS_I2C_10BIT(dev_addr->i2c_addr) ? 2 : 1);
1666 data_block_size =
1667 (DRXDAP_MAX_WCHUNKSIZE - overhead_size_i2c_addr) & ~1;
1668
1669 /* write device address */
1670 st = drxbsp_i2c_write_read(dev_addr,
1671 (u16) (bufx),
1672 buf,
1673 (struct i2c_device_addr *)(NULL),
1674 0, (u8 *)(NULL));
1675
1676 if ((st != 0) && (first_err == 0)) {
1677 /* at the end, return the first error encountered */
1678 first_err = st;
1679 }
1680 bufx = 0;
1681 todo =
1682 (data_block_size <
1683 datasize ? data_block_size : datasize);
1684 }
1685 memcpy(&buf[bufx], data, todo);
1686 /* write (address if can do and) data */
1687 st = drxbsp_i2c_write_read(dev_addr,
1688 (u16) (bufx + todo),
1689 buf,
1690 (struct i2c_device_addr *)(NULL),
1691 0, (u8 *)(NULL));
1692
1693 if ((st != 0) && (first_err == 0)) {
1694 /* at the end, return the first error encountered */
1695 first_err = st;
1696 }
1697 datasize -= todo;
1698 data += todo;
1699 addr += (todo >> 1);
1700 } while (datasize);
1701
1702 return first_err;
1703}
1704
1705/******************************
1706*
1707* int drxdap_fasi_write_reg16 (
1708* struct i2c_device_addr *dev_addr, -- address of I2C device
1709* u32 addr, -- address of chip register/memory
1710* u16 data, -- data to send
1711* u32 flags) -- special device flags
1712*
1713* Write one 16-bit register or memory location. The data being written is
1714* converted from the target platform's endianness to little endian.
1715*
1716* Output:
1717* - 0 if writing was successful
1718* - -EIO if anything went wrong
1719*
1720******************************/
1721
1722static int drxdap_fasi_write_reg16(struct i2c_device_addr *dev_addr,
1723 u32 addr,
1724 u16 data, u32 flags)
1725{
1726 u8 buf[sizeof(data)];
1727
1728 buf[0] = (u8) ((data >> 0) & 0xFF);
1729 buf[1] = (u8) ((data >> 8) & 0xFF);
1730
1731 return drxdap_fasi_write_block(dev_addr, addr, sizeof(data), buf, flags);
1732}
1733
1734/******************************
1735*
1736* int drxdap_fasi_read_modify_write_reg16 (
1737* struct i2c_device_addr *dev_addr, -- address of I2C device
1738* u32 waddr, -- address of chip register/memory
1739* u32 raddr, -- chip address to read back from
1740* u16 wdata, -- data to send
1741* u16 *rdata) -- data to receive back
1742*
1743* Write 16-bit data, then read back the original contents of that location.
1744* Requires long addressing format to be allowed.
1745*
1746* Before sending data, the data is converted to little endian. The
1747* data received back is converted back to the target platform's endianness.
1748*
1749* WARNING: This function is only guaranteed to work if there is one
1750* master on the I2C bus.
1751*
1752* Output:
1753* - 0 if reading was successful
1754* in that case: read back data is at *rdata
1755* - -EIO if anything went wrong
1756*
1757******************************/
1758
1759static int drxdap_fasi_read_modify_write_reg16(struct i2c_device_addr *dev_addr,
1760 u32 waddr,
1761 u32 raddr,
1762 u16 wdata, u16 *rdata)
1763{
1764 int rc = -EIO;
1765
1766#if (DRXDAPFASI_LONG_ADDR_ALLOWED == 1)
1767 if (rdata == NULL)
1768 return -EINVAL;
1769
1770 rc = drxdap_fasi_write_reg16(dev_addr, waddr, wdata, DRXDAP_FASI_RMW);
1771 if (rc == 0)
1772 rc = drxdap_fasi_read_reg16(dev_addr, raddr, rdata, 0);
1773#endif
1774
1775 return rc;
1776}
1777
1778/******************************
1779*
1780* int drxdap_fasi_write_reg32 (
1781* struct i2c_device_addr *dev_addr, -- address of I2C device
1782* u32 addr, -- address of chip register/memory
1783* u32 data, -- data to send
1784* u32 flags) -- special device flags
1785*
1786* Write one 32-bit register or memory location. The data being written is
1787* converted from the target platform's endianness to little endian.
1788*
1789* Output:
1790* - 0 if writing was successful
1791* - -EIO if anything went wrong
1792*
1793******************************/
1794
1795static int drxdap_fasi_write_reg32(struct i2c_device_addr *dev_addr,
1796 u32 addr,
1797 u32 data, u32 flags)
1798{
1799 u8 buf[sizeof(data)];
1800
1801 buf[0] = (u8) ((data >> 0) & 0xFF);
1802 buf[1] = (u8) ((data >> 8) & 0xFF);
1803 buf[2] = (u8) ((data >> 16) & 0xFF);
1804 buf[3] = (u8) ((data >> 24) & 0xFF);
1805
1806 return drxdap_fasi_write_block(dev_addr, addr, sizeof(data), buf, flags);
1807}
1808
1809/*============================================================================*/
1810
1811/**
1812* \fn int drxj_dap_rm_write_reg16short
1813* \brief Read modify write 16 bits audio register using short format only.
1814* \param dev_addr
1815* \param waddr Address to write to
1816* \param raddr Address to read from (usually SIO_HI_RA_RAM_S0_RMWBUF__A)
1817* \param wdata Data to write
1818* \param rdata Buffer for data to read
1819* \return int
1820* \retval 0 Succes
1821* \retval -EIO Timeout, I2C error, illegal bank
1822*
1823* 16 bits register read modify write access using short addressing format only.
1824* Requires knowledge of the registermap, thus device dependent.
1825* Using DAP FASI directly to avoid endless recursion of RMWs to audio registers.
1826*
1827*/
1828
1829/* TODO correct define should be #if ( DRXDAPFASI_SHORT_ADDR_ALLOWED==1 )
1830 See comments drxj_dap_read_modify_write_reg16 */
1831#if (DRXDAPFASI_LONG_ADDR_ALLOWED == 0)
1832static int drxj_dap_rm_write_reg16short(struct i2c_device_addr *dev_addr,
1833 u32 waddr,
1834 u32 raddr,
1835 u16 wdata, u16 *rdata)
1836{
1837 int rc;
1838
1839 if (rdata == NULL)
1840 return -EINVAL;
1841
1842 /* Set RMW flag */
1843 rc = drxdap_fasi_write_reg16(dev_addr,
1844 SIO_HI_RA_RAM_S0_FLG_ACC__A,
1845 SIO_HI_RA_RAM_S0_FLG_ACC_S0_RWM__M,
1846 0x0000);
1847 if (rc == 0) {
1848 /* Write new data: triggers RMW */
1849 rc = drxdap_fasi_write_reg16(dev_addr, waddr, wdata,
1850 0x0000);
1851 }
1852 if (rc == 0) {
1853 /* Read old data */
1854 rc = drxdap_fasi_read_reg16(dev_addr, raddr, rdata,
1855 0x0000);
1856 }
1857 if (rc == 0) {
1858 /* Reset RMW flag */
1859 rc = drxdap_fasi_write_reg16(dev_addr,
1860 SIO_HI_RA_RAM_S0_FLG_ACC__A,
1861 0, 0x0000);
1862 }
1863
1864 return rc;
1865}
1866#endif
1867
1868/*============================================================================*/
1869
1870static int drxj_dap_read_modify_write_reg16(struct i2c_device_addr *dev_addr,
1871 u32 waddr,
1872 u32 raddr,
1873 u16 wdata, u16 *rdata)
1874{
1875 /* TODO: correct short/long addressing format decision,
1876 now long format has higher prio then short because short also
1877 needs virt bnks (not impl yet) for certain audio registers */
1878#if (DRXDAPFASI_LONG_ADDR_ALLOWED == 1)
1879 return drxdap_fasi_read_modify_write_reg16(dev_addr,
1880 waddr,
1881 raddr, wdata, rdata);
1882#else
1883 return drxj_dap_rm_write_reg16short(dev_addr, waddr, raddr, wdata, rdata);
1884#endif
1885}
1886
1887
1888/*============================================================================*/
1889
1890/**
1891* \fn int drxj_dap_read_aud_reg16
1892* \brief Read 16 bits audio register
1893* \param dev_addr
1894* \param addr
1895* \param data
1896* \return int
1897* \retval 0 Succes
1898* \retval -EIO Timeout, I2C error, illegal bank
1899*
1900* 16 bits register read access via audio token ring interface.
1901*
1902*/
1903static int drxj_dap_read_aud_reg16(struct i2c_device_addr *dev_addr,
1904 u32 addr, u16 *data)
1905{
1906 u32 start_timer = 0;
1907 u32 current_timer = 0;
1908 u32 delta_timer = 0;
1909 u16 tr_status = 0;
1910 int stat = -EIO;
1911
1912 /* No read possible for bank 3, return with error */
1913 if (DRXDAP_FASI_ADDR2BANK(addr) == 3) {
1914 stat = -EINVAL;
1915 } else {
1916 const u32 write_bit = ((dr_xaddr_t) 1) << 16;
1917
1918 /* Force reset write bit */
1919 addr &= (~write_bit);
1920
1921 /* Set up read */
1922 start_timer = jiffies_to_msecs(jiffies);
1923 do {
1924 /* RMW to aud TR IF until request is granted or timeout */
1925 stat = drxj_dap_read_modify_write_reg16(dev_addr,
1926 addr,
1927 SIO_HI_RA_RAM_S0_RMWBUF__A,
1928 0x0000, &tr_status);
1929
1930 if (stat != 0)
1931 break;
1932
1933 current_timer = jiffies_to_msecs(jiffies);
1934 delta_timer = current_timer - start_timer;
1935 if (delta_timer > DRXJ_DAP_AUDTRIF_TIMEOUT) {
1936 stat = -EIO;
1937 break;
1938 }
1939
1940 } while (((tr_status & AUD_TOP_TR_CTR_FIFO_LOCK__M) ==
1941 AUD_TOP_TR_CTR_FIFO_LOCK_LOCKED) ||
1942 ((tr_status & AUD_TOP_TR_CTR_FIFO_FULL__M) ==
1943 AUD_TOP_TR_CTR_FIFO_FULL_FULL));
1944 } /* if ( DRXDAP_FASI_ADDR2BANK(addr)!=3 ) */
1945
1946 /* Wait for read ready status or timeout */
1947 if (stat == 0) {
1948 start_timer = jiffies_to_msecs(jiffies);
1949
1950 while ((tr_status & AUD_TOP_TR_CTR_FIFO_RD_RDY__M) !=
1951 AUD_TOP_TR_CTR_FIFO_RD_RDY_READY) {
1952 stat = drxj_dap_read_reg16(dev_addr,
1953 AUD_TOP_TR_CTR__A,
1954 &tr_status, 0x0000);
1955 if (stat != 0)
1956 break;
1957
1958 current_timer = jiffies_to_msecs(jiffies);
1959 delta_timer = current_timer - start_timer;
1960 if (delta_timer > DRXJ_DAP_AUDTRIF_TIMEOUT) {
1961 stat = -EIO;
1962 break;
1963 }
1964 } /* while ( ... ) */
1965 }
1966
1967 /* Read value */
1968 if (stat == 0)
1969 stat = drxj_dap_read_modify_write_reg16(dev_addr,
1970 AUD_TOP_TR_RD_REG__A,
1971 SIO_HI_RA_RAM_S0_RMWBUF__A,
1972 0x0000, data);
1973 return stat;
1974}
1975
1976/*============================================================================*/
1977
1978static int drxj_dap_read_reg16(struct i2c_device_addr *dev_addr,
1979 u32 addr,
1980 u16 *data, u32 flags)
1981{
1982 int stat = -EIO;
1983
1984 /* Check param */
1985 if ((dev_addr == NULL) || (data == NULL))
1986 return -EINVAL;
1987
1988 if (is_handled_by_aud_tr_if(addr))
1989 stat = drxj_dap_read_aud_reg16(dev_addr, addr, data);
1990 else
1991 stat = drxdap_fasi_read_reg16(dev_addr, addr, data, flags);
1992
1993 return stat;
1994}
1995/*============================================================================*/
1996
1997/**
1998* \fn int drxj_dap_write_aud_reg16
1999* \brief Write 16 bits audio register
2000* \param dev_addr
2001* \param addr
2002* \param data
2003* \return int
2004* \retval 0 Succes
2005* \retval -EIO Timeout, I2C error, illegal bank
2006*
2007* 16 bits register write access via audio token ring interface.
2008*
2009*/
2010static int drxj_dap_write_aud_reg16(struct i2c_device_addr *dev_addr,
2011 u32 addr, u16 data)
2012{
2013 int stat = -EIO;
2014
2015 /* No write possible for bank 2, return with error */
2016 if (DRXDAP_FASI_ADDR2BANK(addr) == 2) {
2017 stat = -EINVAL;
2018 } else {
2019 u32 start_timer = 0;
2020 u32 current_timer = 0;
2021 u32 delta_timer = 0;
2022 u16 tr_status = 0;
2023 const u32 write_bit = ((dr_xaddr_t) 1) << 16;
2024
2025 /* Force write bit */
2026 addr |= write_bit;
2027 start_timer = jiffies_to_msecs(jiffies);
2028 do {
2029 /* RMW to aud TR IF until request is granted or timeout */
2030 stat = drxj_dap_read_modify_write_reg16(dev_addr,
2031 addr,
2032 SIO_HI_RA_RAM_S0_RMWBUF__A,
2033 data, &tr_status);
2034 if (stat != 0)
2035 break;
2036
2037 current_timer = jiffies_to_msecs(jiffies);
2038 delta_timer = current_timer - start_timer;
2039 if (delta_timer > DRXJ_DAP_AUDTRIF_TIMEOUT) {
2040 stat = -EIO;
2041 break;
2042 }
2043
2044 } while (((tr_status & AUD_TOP_TR_CTR_FIFO_LOCK__M) ==
2045 AUD_TOP_TR_CTR_FIFO_LOCK_LOCKED) ||
2046 ((tr_status & AUD_TOP_TR_CTR_FIFO_FULL__M) ==
2047 AUD_TOP_TR_CTR_FIFO_FULL_FULL));
2048
2049 } /* if ( DRXDAP_FASI_ADDR2BANK(addr)!=2 ) */
2050
2051 return stat;
2052}
2053
2054/*============================================================================*/
2055
2056static int drxj_dap_write_reg16(struct i2c_device_addr *dev_addr,
2057 u32 addr,
2058 u16 data, u32 flags)
2059{
2060 int stat = -EIO;
2061
2062 /* Check param */
2063 if (dev_addr == NULL)
2064 return -EINVAL;
2065
2066 if (is_handled_by_aud_tr_if(addr))
2067 stat = drxj_dap_write_aud_reg16(dev_addr, addr, data);
2068 else
2069 stat = drxdap_fasi_write_reg16(dev_addr,
2070 addr, data, flags);
2071
2072 return stat;
2073}
2074
2075/*============================================================================*/
2076
2077/* Free data ram in SIO HI */
2078#define SIO_HI_RA_RAM_USR_BEGIN__A 0x420040
2079#define SIO_HI_RA_RAM_USR_END__A 0x420060
2080
2081#define DRXJ_HI_ATOMIC_BUF_START (SIO_HI_RA_RAM_USR_BEGIN__A)
2082#define DRXJ_HI_ATOMIC_BUF_END (SIO_HI_RA_RAM_USR_BEGIN__A + 7)
2083#define DRXJ_HI_ATOMIC_READ SIO_HI_RA_RAM_PAR_3_ACP_RW_READ
2084#define DRXJ_HI_ATOMIC_WRITE SIO_HI_RA_RAM_PAR_3_ACP_RW_WRITE
2085
2086/**
2087* \fn int drxj_dap_atomic_read_write_block()
2088* \brief Basic access routine for atomic read or write access
2089* \param dev_addr pointer to i2c dev address
2090* \param addr destination/source address
2091* \param datasize size of data buffer in bytes
2092* \param data pointer to data buffer
2093* \return int
2094* \retval 0 Succes
2095* \retval -EIO Timeout, I2C error, illegal bank
2096*
2097*/
2098static
2099int drxj_dap_atomic_read_write_block(struct i2c_device_addr *dev_addr,
2100 u32 addr,
2101 u16 datasize,
2102 u8 *data, bool read_flag)
2103{
2104 struct drxj_hi_cmd hi_cmd;
2105 int rc;
2106 u16 word;
2107 u16 dummy = 0;
2108 u16 i = 0;
2109
2110 /* Parameter check */
2111 if (!data || !dev_addr || ((datasize % 2)) || ((datasize / 2) > 8))
2112 return -EINVAL;
2113
2114 /* Set up HI parameters to read or write n bytes */
2115 hi_cmd.cmd = SIO_HI_RA_RAM_CMD_ATOMIC_COPY;
2116 hi_cmd.param1 =
2117 (u16) ((DRXDAP_FASI_ADDR2BLOCK(DRXJ_HI_ATOMIC_BUF_START) << 6) +
2118 DRXDAP_FASI_ADDR2BANK(DRXJ_HI_ATOMIC_BUF_START));
2119 hi_cmd.param2 =
2120 (u16) DRXDAP_FASI_ADDR2OFFSET(DRXJ_HI_ATOMIC_BUF_START);
2121 hi_cmd.param3 = (u16) ((datasize / 2) - 1);
2122 if (!read_flag)
2123 hi_cmd.param3 |= DRXJ_HI_ATOMIC_WRITE;
2124 else
2125 hi_cmd.param3 |= DRXJ_HI_ATOMIC_READ;
2126 hi_cmd.param4 = (u16) ((DRXDAP_FASI_ADDR2BLOCK(addr) << 6) +
2127 DRXDAP_FASI_ADDR2BANK(addr));
2128 hi_cmd.param5 = (u16) DRXDAP_FASI_ADDR2OFFSET(addr);
2129
2130 if (!read_flag) {
2131 /* write data to buffer */
2132 for (i = 0; i < (datasize / 2); i++) {
2133
2134 word = ((u16) data[2 * i]);
2135 word += (((u16) data[(2 * i) + 1]) << 8);
2136 drxj_dap_write_reg16(dev_addr,
2137 (DRXJ_HI_ATOMIC_BUF_START + i),
2138 word, 0);
2139 }
2140 }
2141
2142 rc = hi_command(dev_addr, &hi_cmd, &dummy);
2143 if (rc != 0) {
2144 pr_err("error %d\n", rc);
2145 goto rw_error;
2146 }
2147
2148 if (read_flag) {
2149 /* read data from buffer */
2150 for (i = 0; i < (datasize / 2); i++) {
2151 drxj_dap_read_reg16(dev_addr,
2152 (DRXJ_HI_ATOMIC_BUF_START + i),
2153 &word, 0);
2154 data[2 * i] = (u8) (word & 0xFF);
2155 data[(2 * i) + 1] = (u8) (word >> 8);
2156 }
2157 }
2158
2159 return 0;
2160
2161rw_error:
2162 return -EIO;
2163
2164}
2165
2166/*============================================================================*/
2167
2168/**
2169* \fn int drxj_dap_atomic_read_reg32()
2170* \brief Atomic read of 32 bits words
2171*/
2172static
2173int drxj_dap_atomic_read_reg32(struct i2c_device_addr *dev_addr,
2174 u32 addr,
2175 u32 *data, u32 flags)
2176{
2177 u8 buf[sizeof(*data)];
2178 int rc = -EIO;
2179 u32 word = 0;
2180
2181 if (!data)
2182 return -EINVAL;
2183
2184 rc = drxj_dap_atomic_read_write_block(dev_addr, addr,
2185 sizeof(*data), buf, true);
2186
2187 if (rc < 0)
2188 return 0;
2189
2190 word = (u32) buf[3];
2191 word <<= 8;
2192 word |= (u32) buf[2];
2193 word <<= 8;
2194 word |= (u32) buf[1];
2195 word <<= 8;
2196 word |= (u32) buf[0];
2197
2198 *data = word;
2199
2200 return rc;
2201}
2202
2203/*============================================================================*/
2204
2205/*============================================================================*/
2206/*== END DRXJ DAP FUNCTIONS ==*/
2207/*============================================================================*/
2208
2209/*============================================================================*/
2210/*============================================================================*/
2211/*== HOST INTERFACE FUNCTIONS ==*/
2212/*============================================================================*/
2213/*============================================================================*/
2214
2215/**
2216* \fn int hi_cfg_command()
2217* \brief Configure HI with settings stored in the demod structure.
2218* \param demod Demodulator.
2219* \return int.
2220*
2221* This routine was created because to much orthogonal settings have
2222* been put into one HI API function (configure). Especially the I2C bridge
2223* enable/disable should not need re-configuration of the HI.
2224*
2225*/
2226static int hi_cfg_command(const struct drx_demod_instance *demod)
2227{
2228 struct drxj_data *ext_attr = (struct drxj_data *) (NULL);
2229 struct drxj_hi_cmd hi_cmd;
2230 u16 result = 0;
2231 int rc;
2232
2233 ext_attr = (struct drxj_data *) demod->my_ext_attr;
2234
2235 hi_cmd.cmd = SIO_HI_RA_RAM_CMD_CONFIG;
2236 hi_cmd.param1 = SIO_HI_RA_RAM_PAR_1_PAR1_SEC_KEY;
2237 hi_cmd.param2 = ext_attr->hi_cfg_timing_div;
2238 hi_cmd.param3 = ext_attr->hi_cfg_bridge_delay;
2239 hi_cmd.param4 = ext_attr->hi_cfg_wake_up_key;
2240 hi_cmd.param5 = ext_attr->hi_cfg_ctrl;
2241 hi_cmd.param6 = ext_attr->hi_cfg_transmit;
2242
2243 rc = hi_command(demod->my_i2c_dev_addr, &hi_cmd, &result);
2244 if (rc != 0) {
2245 pr_err("error %d\n", rc);
2246 goto rw_error;
2247 }
2248
2249 /* Reset power down flag (set one call only) */
2250 ext_attr->hi_cfg_ctrl &= (~(SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ));
2251
2252 return 0;
2253
2254rw_error:
2255 return -EIO;
2256}
2257
2258/**
2259* \fn int hi_command()
2260* \brief Configure HI with settings stored in the demod structure.
2261* \param dev_addr I2C address.
2262* \param cmd HI command.
2263* \param result HI command result.
2264* \return int.
2265*
2266* Sends command to HI
2267*
2268*/
2269static int
2270hi_command(struct i2c_device_addr *dev_addr, const struct drxj_hi_cmd *cmd, u16 *result)
2271{
2272 u16 wait_cmd = 0;
2273 u16 nr_retries = 0;
2274 bool powerdown_cmd = false;
2275 int rc;
2276
2277 /* Write parameters */
2278 switch (cmd->cmd) {
2279
2280 case SIO_HI_RA_RAM_CMD_CONFIG:
2281 case SIO_HI_RA_RAM_CMD_ATOMIC_COPY:
2282 rc = drxj_dap_write_reg16(dev_addr, SIO_HI_RA_RAM_PAR_6__A, cmd->param6, 0);
2283 if (rc != 0) {
2284 pr_err("error %d\n", rc);
2285 goto rw_error;
2286 }
2287 rc = drxj_dap_write_reg16(dev_addr, SIO_HI_RA_RAM_PAR_5__A, cmd->param5, 0);
2288 if (rc != 0) {
2289 pr_err("error %d\n", rc);
2290 goto rw_error;
2291 }
2292 rc = drxj_dap_write_reg16(dev_addr, SIO_HI_RA_RAM_PAR_4__A, cmd->param4, 0);
2293 if (rc != 0) {
2294 pr_err("error %d\n", rc);
2295 goto rw_error;
2296 }
2297 rc = drxj_dap_write_reg16(dev_addr, SIO_HI_RA_RAM_PAR_3__A, cmd->param3, 0);
2298 if (rc != 0) {
2299 pr_err("error %d\n", rc);
2300 goto rw_error;
2301 }
2302 /* fallthrough */
2303 case SIO_HI_RA_RAM_CMD_BRDCTRL:
2304 rc = drxj_dap_write_reg16(dev_addr, SIO_HI_RA_RAM_PAR_2__A, cmd->param2, 0);
2305 if (rc != 0) {
2306 pr_err("error %d\n", rc);
2307 goto rw_error;
2308 }
2309 rc = drxj_dap_write_reg16(dev_addr, SIO_HI_RA_RAM_PAR_1__A, cmd->param1, 0);
2310 if (rc != 0) {
2311 pr_err("error %d\n", rc);
2312 goto rw_error;
2313 }
2314 /* fallthrough */
2315 case SIO_HI_RA_RAM_CMD_NULL:
2316 /* No parameters */
2317 break;
2318
2319 default:
2320 return -EINVAL;
2321 break;
2322 }
2323
2324 /* Write command */
2325 rc = drxj_dap_write_reg16(dev_addr, SIO_HI_RA_RAM_CMD__A, cmd->cmd, 0);
2326 if (rc != 0) {
2327 pr_err("error %d\n", rc);
2328 goto rw_error;
2329 }
2330
2331 if ((cmd->cmd) == SIO_HI_RA_RAM_CMD_RESET)
2332 msleep(1);
2333
2334 /* Detect power down to ommit reading result */
2335 powerdown_cmd = (bool) ((cmd->cmd == SIO_HI_RA_RAM_CMD_CONFIG) &&
2336 (((cmd->
2337 param5) & SIO_HI_RA_RAM_PAR_5_CFG_SLEEP__M)
2338 == SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ));
2339 if (!powerdown_cmd) {
2340 /* Wait until command rdy */
2341 do {
2342 nr_retries++;
2343 if (nr_retries > DRXJ_MAX_RETRIES) {
2344 pr_err("timeout\n");
2345 goto rw_error;
2346 }
2347
2348 rc = drxj_dap_read_reg16(dev_addr, SIO_HI_RA_RAM_CMD__A, &wait_cmd, 0);
2349 if (rc != 0) {
2350 pr_err("error %d\n", rc);
2351 goto rw_error;
2352 }
2353 } while (wait_cmd != 0);
2354
2355 /* Read result */
2356 rc = drxj_dap_read_reg16(dev_addr, SIO_HI_RA_RAM_RES__A, result, 0);
2357 if (rc != 0) {
2358 pr_err("error %d\n", rc);
2359 goto rw_error;
2360 }
2361
2362 }
2363 /* if ( powerdown_cmd == true ) */
2364 return 0;
2365rw_error:
2366 return -EIO;
2367}
2368
2369/**
2370* \fn int init_hi( const struct drx_demod_instance *demod )
2371* \brief Initialise and configurate HI.
2372* \param demod pointer to demod data.
2373* \return int Return status.
2374* \retval 0 Success.
2375* \retval -EIO Failure.
2376*
2377* Needs to know Psys (System Clock period) and Posc (Osc Clock period)
2378* Need to store configuration in driver because of the way I2C
2379* bridging is controlled.
2380*
2381*/
2382static int init_hi(const struct drx_demod_instance *demod)
2383{
2384 struct drxj_data *ext_attr = (struct drxj_data *) (NULL);
2385 struct drx_common_attr *common_attr = (struct drx_common_attr *) (NULL);
2386 struct i2c_device_addr *dev_addr = (struct i2c_device_addr *)(NULL);
2387 int rc;
2388
2389 ext_attr = (struct drxj_data *) demod->my_ext_attr;
2390 common_attr = (struct drx_common_attr *) demod->my_common_attr;
2391 dev_addr = demod->my_i2c_dev_addr;
2392
2393 /* PATCH for bug 5003, HI ucode v3.1.0 */
2394 rc = drxj_dap_write_reg16(dev_addr, 0x4301D7, 0x801, 0);
2395 if (rc != 0) {
2396 pr_err("error %d\n", rc);
2397 goto rw_error;
2398 }
2399
2400 /* Timing div, 250ns/Psys */
2401 /* Timing div, = ( delay (nano seconds) * sysclk (kHz) )/ 1000 */
2402 ext_attr->hi_cfg_timing_div =
2403 (u16) ((common_attr->sys_clock_freq / 1000) * HI_I2C_DELAY) / 1000;
2404 /* Clipping */
2405 if ((ext_attr->hi_cfg_timing_div) > SIO_HI_RA_RAM_PAR_2_CFG_DIV__M)
2406 ext_attr->hi_cfg_timing_div = SIO_HI_RA_RAM_PAR_2_CFG_DIV__M;
2407 /* Bridge delay, uses oscilator clock */
2408 /* Delay = ( delay (nano seconds) * oscclk (kHz) )/ 1000 */
2409 /* SDA brdige delay */
2410 ext_attr->hi_cfg_bridge_delay =
2411 (u16) ((common_attr->osc_clock_freq / 1000) * HI_I2C_BRIDGE_DELAY) /
2412 1000;
2413 /* Clipping */
2414 if ((ext_attr->hi_cfg_bridge_delay) > SIO_HI_RA_RAM_PAR_3_CFG_DBL_SDA__M)
2415 ext_attr->hi_cfg_bridge_delay = SIO_HI_RA_RAM_PAR_3_CFG_DBL_SDA__M;
2416 /* SCL bridge delay, same as SDA for now */
2417 ext_attr->hi_cfg_bridge_delay += ((ext_attr->hi_cfg_bridge_delay) <<
2418 SIO_HI_RA_RAM_PAR_3_CFG_DBL_SCL__B);
2419 /* Wakeup key, setting the read flag (as suggest in the documentation) does
2420 not always result into a working solution (barebones worked VI2C failed).
2421 Not setting the bit works in all cases . */
2422 ext_attr->hi_cfg_wake_up_key = DRXJ_WAKE_UP_KEY;
2423 /* port/bridge/power down ctrl */
2424 ext_attr->hi_cfg_ctrl = (SIO_HI_RA_RAM_PAR_5_CFG_SLV0_SLAVE);
2425 /* transit mode time out delay and watch dog divider */
2426 ext_attr->hi_cfg_transmit = SIO_HI_RA_RAM_PAR_6__PRE;
2427
2428 rc = hi_cfg_command(demod);
2429 if (rc != 0) {
2430 pr_err("error %d\n", rc);
2431 goto rw_error;
2432 }
2433
2434 return 0;
2435
2436rw_error:
2437 return -EIO;
2438}
2439
2440/*============================================================================*/
2441/*== END HOST INTERFACE FUNCTIONS ==*/
2442/*============================================================================*/
2443
2444/*============================================================================*/
2445/*============================================================================*/
2446/*== AUXILIARY FUNCTIONS ==*/
2447/*============================================================================*/
2448/*============================================================================*/
2449
2450/**
2451* \fn int get_device_capabilities()
2452* \brief Get and store device capabilities.
2453* \param demod Pointer to demodulator instance.
2454* \return int.
2455* \return 0 Success
2456* \retval -EIO Failure
2457*
2458* Depending on pulldowns on MDx pins the following internals are set:
2459* * common_attr->osc_clock_freq
2460* * ext_attr->has_lna
2461* * ext_attr->has_ntsc
2462* * ext_attr->has_btsc
2463* * ext_attr->has_oob
2464*
2465*/
2466static int get_device_capabilities(struct drx_demod_instance *demod)
2467{
2468 struct drx_common_attr *common_attr = (struct drx_common_attr *) (NULL);
2469 struct drxj_data *ext_attr = (struct drxj_data *) NULL;
2470 struct i2c_device_addr *dev_addr = (struct i2c_device_addr *)(NULL);
2471 u16 sio_pdr_ohw_cfg = 0;
2472 u32 sio_top_jtagid_lo = 0;
2473 u16 bid = 0;
2474 int rc;
2475
2476 common_attr = (struct drx_common_attr *) demod->my_common_attr;
2477 ext_attr = (struct drxj_data *) demod->my_ext_attr;
2478 dev_addr = demod->my_i2c_dev_addr;
2479
2480 rc = drxj_dap_write_reg16(dev_addr, SIO_TOP_COMM_KEY__A, SIO_TOP_COMM_KEY_KEY, 0);
2481 if (rc != 0) {
2482 pr_err("error %d\n", rc);
2483 goto rw_error;
2484 }
2485 rc = drxj_dap_read_reg16(dev_addr, SIO_PDR_OHW_CFG__A, &sio_pdr_ohw_cfg, 0);
2486 if (rc != 0) {
2487 pr_err("error %d\n", rc);
2488 goto rw_error;
2489 }
2490 rc = drxj_dap_write_reg16(dev_addr, SIO_TOP_COMM_KEY__A, SIO_TOP_COMM_KEY__PRE, 0);
2491 if (rc != 0) {
2492 pr_err("error %d\n", rc);
2493 goto rw_error;
2494 }
2495
2496 switch ((sio_pdr_ohw_cfg & SIO_PDR_OHW_CFG_FREF_SEL__M)) {
2497 case 0:
2498 /* ignore (bypass ?) */
2499 break;
2500 case 1:
2501 /* 27 MHz */
2502 common_attr->osc_clock_freq = 27000;
2503 break;
2504 case 2:
2505 /* 20.25 MHz */
2506 common_attr->osc_clock_freq = 20250;
2507 break;
2508 case 3:
2509 /* 4 MHz */
2510 common_attr->osc_clock_freq = 4000;
2511 break;
2512 default:
2513 return -EIO;
2514 }
2515
2516 /*
2517 Determine device capabilities
2518 Based on pinning v47
2519 */
2520 rc = drxdap_fasi_read_reg32(dev_addr, SIO_TOP_JTAGID_LO__A, &sio_top_jtagid_lo, 0);
2521 if (rc != 0) {
2522 pr_err("error %d\n", rc);
2523 goto rw_error;
2524 }
2525 ext_attr->mfx = (u8) ((sio_top_jtagid_lo >> 29) & 0xF);
2526
2527 switch ((sio_top_jtagid_lo >> 12) & 0xFF) {
2528 case 0x31:
2529 rc = drxj_dap_write_reg16(dev_addr, SIO_TOP_COMM_KEY__A, SIO_TOP_COMM_KEY_KEY, 0);
2530 if (rc != 0) {
2531 pr_err("error %d\n", rc);
2532 goto rw_error;
2533 }
2534 rc = drxj_dap_read_reg16(dev_addr, SIO_PDR_UIO_IN_HI__A, &bid, 0);
2535 if (rc != 0) {
2536 pr_err("error %d\n", rc);
2537 goto rw_error;
2538 }
2539 bid = (bid >> 10) & 0xf;
2540 rc = drxj_dap_write_reg16(dev_addr, SIO_TOP_COMM_KEY__A, SIO_TOP_COMM_KEY__PRE, 0);
2541 if (rc != 0) {
2542 pr_err("error %d\n", rc);
2543 goto rw_error;
2544 }
2545
2546 ext_attr->has_lna = true;
2547 ext_attr->has_ntsc = false;
2548 ext_attr->has_btsc = false;
2549 ext_attr->has_oob = false;
2550 ext_attr->has_smatx = true;
2551 ext_attr->has_smarx = false;
2552 ext_attr->has_gpio = false;
2553 ext_attr->has_irqn = false;
2554 break;
2555 case 0x33:
2556 ext_attr->has_lna = false;
2557 ext_attr->has_ntsc = false;
2558 ext_attr->has_btsc = false;
2559 ext_attr->has_oob = false;
2560 ext_attr->has_smatx = true;
2561 ext_attr->has_smarx = false;
2562 ext_attr->has_gpio = false;
2563 ext_attr->has_irqn = false;
2564 break;
2565 case 0x45:
2566 ext_attr->has_lna = true;
2567 ext_attr->has_ntsc = true;
2568 ext_attr->has_btsc = false;
2569 ext_attr->has_oob = false;
2570 ext_attr->has_smatx = true;
2571 ext_attr->has_smarx = true;
2572 ext_attr->has_gpio = true;
2573 ext_attr->has_irqn = false;
2574 break;
2575 case 0x46:
2576 ext_attr->has_lna = false;
2577 ext_attr->has_ntsc = true;
2578 ext_attr->has_btsc = false;
2579 ext_attr->has_oob = false;
2580 ext_attr->has_smatx = true;
2581 ext_attr->has_smarx = true;
2582 ext_attr->has_gpio = true;
2583 ext_attr->has_irqn = false;
2584 break;
2585 case 0x41:
2586 ext_attr->has_lna = true;
2587 ext_attr->has_ntsc = true;
2588 ext_attr->has_btsc = true;
2589 ext_attr->has_oob = false;
2590 ext_attr->has_smatx = true;
2591 ext_attr->has_smarx = true;
2592 ext_attr->has_gpio = true;
2593 ext_attr->has_irqn = false;
2594 break;
2595 case 0x43:
2596 ext_attr->has_lna = false;
2597 ext_attr->has_ntsc = true;
2598 ext_attr->has_btsc = true;
2599 ext_attr->has_oob = false;
2600 ext_attr->has_smatx = true;
2601 ext_attr->has_smarx = true;
2602 ext_attr->has_gpio = true;
2603 ext_attr->has_irqn = false;
2604 break;
2605 case 0x32:
2606 ext_attr->has_lna = true;
2607 ext_attr->has_ntsc = false;
2608 ext_attr->has_btsc = false;
2609 ext_attr->has_oob = true;
2610 ext_attr->has_smatx = true;
2611 ext_attr->has_smarx = true;
2612 ext_attr->has_gpio = true;
2613 ext_attr->has_irqn = true;
2614 break;
2615 case 0x34:
2616 ext_attr->has_lna = false;
2617 ext_attr->has_ntsc = true;
2618 ext_attr->has_btsc = true;
2619 ext_attr->has_oob = true;
2620 ext_attr->has_smatx = true;
2621 ext_attr->has_smarx = true;
2622 ext_attr->has_gpio = true;
2623 ext_attr->has_irqn = true;
2624 break;
2625 case 0x42:
2626 ext_attr->has_lna = true;
2627 ext_attr->has_ntsc = true;
2628 ext_attr->has_btsc = true;
2629 ext_attr->has_oob = true;
2630 ext_attr->has_smatx = true;
2631 ext_attr->has_smarx = true;
2632 ext_attr->has_gpio = true;
2633 ext_attr->has_irqn = true;
2634 break;
2635 case 0x44:
2636 ext_attr->has_lna = false;
2637 ext_attr->has_ntsc = true;
2638 ext_attr->has_btsc = true;
2639 ext_attr->has_oob = true;
2640 ext_attr->has_smatx = true;
2641 ext_attr->has_smarx = true;
2642 ext_attr->has_gpio = true;
2643 ext_attr->has_irqn = true;
2644 break;
2645 default:
2646 /* Unknown device variant */
2647 return -EIO;
2648 break;
2649 }
2650
2651 return 0;
2652rw_error:
2653 return -EIO;
2654}
2655
2656/**
2657* \fn int power_up_device()
2658* \brief Power up device.
2659* \param demod Pointer to demodulator instance.
2660* \return int.
2661* \return 0 Success
2662* \retval -EIO Failure, I2C or max retries reached
2663*
2664*/
2665
2666#ifndef DRXJ_MAX_RETRIES_POWERUP
2667#define DRXJ_MAX_RETRIES_POWERUP 10
2668#endif
2669
2670static int power_up_device(struct drx_demod_instance *demod)
2671{
2672 struct i2c_device_addr *dev_addr = (struct i2c_device_addr *)(NULL);
2673 u8 data = 0;
2674 u16 retry_count = 0;
2675 struct i2c_device_addr wake_up_addr;
2676
2677 dev_addr = demod->my_i2c_dev_addr;
2678 wake_up_addr.i2c_addr = DRXJ_WAKE_UP_KEY;
2679 wake_up_addr.i2c_dev_id = dev_addr->i2c_dev_id;
2680 wake_up_addr.user_data = dev_addr->user_data;
2681 /*
2682 * I2C access may fail in this case: no ack
2683 * dummy write must be used to wake uop device, dummy read must be used to
2684 * reset HI state machine (avoiding actual writes)
2685 */
2686 do {
2687 data = 0;
2688 drxbsp_i2c_write_read(&wake_up_addr, 1, &data,
2689 (struct i2c_device_addr *)(NULL), 0,
2690 (u8 *)(NULL));
2691 msleep(10);
2692 retry_count++;
2693 } while ((drxbsp_i2c_write_read
2694 ((struct i2c_device_addr *) (NULL), 0, (u8 *)(NULL), dev_addr, 1,
2695 &data)
2696 != 0) && (retry_count < DRXJ_MAX_RETRIES_POWERUP));
2697
2698 /* Need some recovery time .... */
2699 msleep(10);
2700
2701 if (retry_count == DRXJ_MAX_RETRIES_POWERUP)
2702 return -EIO;
2703
2704 return 0;
2705}
2706
2707/*----------------------------------------------------------------------------*/
2708/* MPEG Output Configuration Functions - begin */
2709/*----------------------------------------------------------------------------*/
2710/**
2711* \fn int ctrl_set_cfg_mpeg_output()
2712* \brief Set MPEG output configuration of the device.
2713* \param devmod Pointer to demodulator instance.
2714* \param cfg_data Pointer to mpeg output configuaration.
2715* \return int.
2716*
2717* Configure MPEG output parameters.
2718*
2719*/
2720static int
2721ctrl_set_cfg_mpeg_output(struct drx_demod_instance *demod, struct drx_cfg_mpeg_output *cfg_data)
2722{
2723 struct i2c_device_addr *dev_addr = (struct i2c_device_addr *)(NULL);
2724 struct drxj_data *ext_attr = (struct drxj_data *) (NULL);
2725 struct drx_common_attr *common_attr = (struct drx_common_attr *) (NULL);
2726 int rc;
2727 u16 fec_oc_reg_mode = 0;
2728 u16 fec_oc_reg_ipr_mode = 0;
2729 u16 fec_oc_reg_ipr_invert = 0;
2730 u32 max_bit_rate = 0;
2731 u32 rcn_rate = 0;
2732 u32 nr_bits = 0;
2733 u16 sio_pdr_md_cfg = 0;
2734 /* data mask for the output data byte */
2735 u16 invert_data_mask =
2736 FEC_OC_IPR_INVERT_MD7__M | FEC_OC_IPR_INVERT_MD6__M |
2737 FEC_OC_IPR_INVERT_MD5__M | FEC_OC_IPR_INVERT_MD4__M |
2738 FEC_OC_IPR_INVERT_MD3__M | FEC_OC_IPR_INVERT_MD2__M |
2739 FEC_OC_IPR_INVERT_MD1__M | FEC_OC_IPR_INVERT_MD0__M;
2740
2741 /* check arguments */
2742 if ((demod == NULL) || (cfg_data == NULL))
2743 return -EINVAL;
2744
2745 dev_addr = demod->my_i2c_dev_addr;
2746 ext_attr = (struct drxj_data *) demod->my_ext_attr;
2747 common_attr = (struct drx_common_attr *) demod->my_common_attr;
2748
2749 if (cfg_data->enable_mpeg_output == true) {
2750 /* quick and dirty patch to set MPEG incase current std is not
2751 producing MPEG */
2752 switch (ext_attr->standard) {
2753 case DRX_STANDARD_8VSB:
2754 case DRX_STANDARD_ITU_A:
2755 case DRX_STANDARD_ITU_B:
2756 case DRX_STANDARD_ITU_C:
2757 break;
2758 default:
2759 return 0;
2760 }
2761
2762 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_OCR_INVERT__A, 0, 0);
2763 if (rc != 0) {
2764 pr_err("error %d\n", rc);
2765 goto rw_error;
2766 }
2767 switch (ext_attr->standard) {
2768 case DRX_STANDARD_8VSB:
2769 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_FCT_USAGE__A, 7, 0);
2770 if (rc != 0) {
2771 pr_err("error %d\n", rc);
2772 goto rw_error;
2773 } /* 2048 bytes fifo ram */
2774 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_TMD_CTL_UPD_RATE__A, 10, 0);
2775 if (rc != 0) {
2776 pr_err("error %d\n", rc);
2777 goto rw_error;
2778 }
2779 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_TMD_INT_UPD_RATE__A, 10, 0);
2780 if (rc != 0) {
2781 pr_err("error %d\n", rc);
2782 goto rw_error;
2783 }
2784 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_AVR_PARM_A__A, 5, 0);
2785 if (rc != 0) {
2786 pr_err("error %d\n", rc);
2787 goto rw_error;
2788 }
2789 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_AVR_PARM_B__A, 7, 0);
2790 if (rc != 0) {
2791 pr_err("error %d\n", rc);
2792 goto rw_error;
2793 }
2794 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_RCN_GAIN__A, 10, 0);
2795 if (rc != 0) {
2796 pr_err("error %d\n", rc);
2797 goto rw_error;
2798 }
2799 /* Low Water Mark for synchronization */
2800 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_SNC_LWM__A, 3, 0);
2801 if (rc != 0) {
2802 pr_err("error %d\n", rc);
2803 goto rw_error;
2804 }
2805 /* High Water Mark for synchronization */
2806 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_SNC_HWM__A, 5, 0);
2807 if (rc != 0) {
2808 pr_err("error %d\n", rc);
2809 goto rw_error;
2810 }
2811 break;
2812 case DRX_STANDARD_ITU_A:
2813 case DRX_STANDARD_ITU_C:
2814 switch (ext_attr->constellation) {
2815 case DRX_CONSTELLATION_QAM256:
2816 nr_bits = 8;
2817 break;
2818 case DRX_CONSTELLATION_QAM128:
2819 nr_bits = 7;
2820 break;
2821 case DRX_CONSTELLATION_QAM64:
2822 nr_bits = 6;
2823 break;
2824 case DRX_CONSTELLATION_QAM32:
2825 nr_bits = 5;
2826 break;
2827 case DRX_CONSTELLATION_QAM16:
2828 nr_bits = 4;
2829 break;
2830 default:
2831 return -EIO;
2832 } /* ext_attr->constellation */
2833 /* max_bit_rate = symbol_rate * nr_bits * coef */
2834 /* coef = 188/204 */
2835 max_bit_rate =
2836 (ext_attr->curr_symbol_rate / 8) * nr_bits * 188;
2837 /* pass through b/c Annex A/c need following settings */
2838 case DRX_STANDARD_ITU_B:
2839 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_FCT_USAGE__A, FEC_OC_FCT_USAGE__PRE, 0);
2840 if (rc != 0) {
2841 pr_err("error %d\n", rc);
2842 goto rw_error;
2843 }
2844 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_TMD_CTL_UPD_RATE__A, FEC_OC_TMD_CTL_UPD_RATE__PRE, 0);
2845 if (rc != 0) {
2846 pr_err("error %d\n", rc);
2847 goto rw_error;
2848 }
2849 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_TMD_INT_UPD_RATE__A, 5, 0);
2850 if (rc != 0) {
2851 pr_err("error %d\n", rc);
2852 goto rw_error;
2853 }
2854 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_AVR_PARM_A__A, FEC_OC_AVR_PARM_A__PRE, 0);
2855 if (rc != 0) {
2856 pr_err("error %d\n", rc);
2857 goto rw_error;
2858 }
2859 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_AVR_PARM_B__A, FEC_OC_AVR_PARM_B__PRE, 0);
2860 if (rc != 0) {
2861 pr_err("error %d\n", rc);
2862 goto rw_error;
2863 }
2864 if (cfg_data->static_clk == true) {
2865 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_RCN_GAIN__A, 0xD, 0);
2866 if (rc != 0) {
2867 pr_err("error %d\n", rc);
2868 goto rw_error;
2869 }
2870 } else {
2871 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_RCN_GAIN__A, FEC_OC_RCN_GAIN__PRE, 0);
2872 if (rc != 0) {
2873 pr_err("error %d\n", rc);
2874 goto rw_error;
2875 }
2876 }
2877 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_SNC_LWM__A, 2, 0);
2878 if (rc != 0) {
2879 pr_err("error %d\n", rc);
2880 goto rw_error;
2881 }
2882 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_SNC_HWM__A, 12, 0);
2883 if (rc != 0) {
2884 pr_err("error %d\n", rc);
2885 goto rw_error;
2886 }
2887 break;
2888 default:
2889 break;
2890 } /* swtich (standard) */
2891
2892 /* Check insertion of the Reed-Solomon parity bytes */
2893 rc = drxj_dap_read_reg16(dev_addr, FEC_OC_MODE__A, &fec_oc_reg_mode, 0);
2894 if (rc != 0) {
2895 pr_err("error %d\n", rc);
2896 goto rw_error;
2897 }
2898 rc = drxj_dap_read_reg16(dev_addr, FEC_OC_IPR_MODE__A, &fec_oc_reg_ipr_mode, 0);
2899 if (rc != 0) {
2900 pr_err("error %d\n", rc);
2901 goto rw_error;
2902 }
2903 if (cfg_data->insert_rs_byte == true) {
2904 /* enable parity symbol forward */
2905 fec_oc_reg_mode |= FEC_OC_MODE_PARITY__M;
2906 /* MVAL disable during parity bytes */
2907 fec_oc_reg_ipr_mode |= FEC_OC_IPR_MODE_MVAL_DIS_PAR__M;
2908 switch (ext_attr->standard) {
2909 case DRX_STANDARD_8VSB:
2910 rcn_rate = 0x004854D3;
2911 break;
2912 case DRX_STANDARD_ITU_B:
2913 fec_oc_reg_mode |= FEC_OC_MODE_TRANSPARENT__M;
2914 switch (ext_attr->constellation) {
2915 case DRX_CONSTELLATION_QAM256:
2916 rcn_rate = 0x008945E7;
2917 break;
2918 case DRX_CONSTELLATION_QAM64:
2919 rcn_rate = 0x005F64D4;
2920 break;
2921 default:
2922 return -EIO;
2923 }
2924 break;
2925 case DRX_STANDARD_ITU_A:
2926 case DRX_STANDARD_ITU_C:
2927 /* insert_rs_byte = true -> coef = 188/188 -> 1, RS bits are in MPEG output */
2928 rcn_rate =
2929 (frac28
2930 (max_bit_rate,
2931 (u32) (common_attr->sys_clock_freq / 8))) /
2932 188;
2933 break;
2934 default:
2935 return -EIO;
2936 } /* ext_attr->standard */
2937 } else { /* insert_rs_byte == false */
2938
2939 /* disable parity symbol forward */
2940 fec_oc_reg_mode &= (~FEC_OC_MODE_PARITY__M);
2941 /* MVAL enable during parity bytes */
2942 fec_oc_reg_ipr_mode &= (~FEC_OC_IPR_MODE_MVAL_DIS_PAR__M);
2943 switch (ext_attr->standard) {
2944 case DRX_STANDARD_8VSB:
2945 rcn_rate = 0x0041605C;
2946 break;
2947 case DRX_STANDARD_ITU_B:
2948 fec_oc_reg_mode &= (~FEC_OC_MODE_TRANSPARENT__M);
2949 switch (ext_attr->constellation) {
2950 case DRX_CONSTELLATION_QAM256:
2951 rcn_rate = 0x0082D6A0;
2952 break;
2953 case DRX_CONSTELLATION_QAM64:
2954 rcn_rate = 0x005AEC1A;
2955 break;
2956 default:
2957 return -EIO;
2958 }
2959 break;
2960 case DRX_STANDARD_ITU_A:
2961 case DRX_STANDARD_ITU_C:
2962 /* insert_rs_byte = false -> coef = 188/204, RS bits not in MPEG output */
2963 rcn_rate =
2964 (frac28
2965 (max_bit_rate,
2966 (u32) (common_attr->sys_clock_freq / 8))) /
2967 204;
2968 break;
2969 default:
2970 return -EIO;
2971 } /* ext_attr->standard */
2972 }
2973
2974 if (cfg_data->enable_parallel == true) { /* MPEG data output is paralel -> clear ipr_mode[0] */
2975 fec_oc_reg_ipr_mode &= (~(FEC_OC_IPR_MODE_SERIAL__M));
2976 } else { /* MPEG data output is serial -> set ipr_mode[0] */
2977 fec_oc_reg_ipr_mode |= FEC_OC_IPR_MODE_SERIAL__M;
2978 }
2979
2980 /* Control slective inversion of output bits */
2981 if (cfg_data->invert_data == true)
2982 fec_oc_reg_ipr_invert |= invert_data_mask;
2983 else
2984 fec_oc_reg_ipr_invert &= (~(invert_data_mask));
2985
2986 if (cfg_data->invert_err == true)
2987 fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MERR__M;
2988 else
2989 fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MERR__M));
2990
2991 if (cfg_data->invert_str == true)
2992 fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MSTRT__M;
2993 else
2994 fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MSTRT__M));
2995
2996 if (cfg_data->invert_val == true)
2997 fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MVAL__M;
2998 else
2999 fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MVAL__M));
3000
3001 if (cfg_data->invert_clk == true)
3002 fec_oc_reg_ipr_invert |= FEC_OC_IPR_INVERT_MCLK__M;
3003 else
3004 fec_oc_reg_ipr_invert &= (~(FEC_OC_IPR_INVERT_MCLK__M));
3005
3006
3007 if (cfg_data->static_clk == true) { /* Static mode */
3008 u32 dto_rate = 0;
3009 u32 bit_rate = 0;
3010 u16 fec_oc_dto_burst_len = 0;
3011 u16 fec_oc_dto_period = 0;
3012
3013 fec_oc_dto_burst_len = FEC_OC_DTO_BURST_LEN__PRE;
3014
3015 switch (ext_attr->standard) {
3016 case DRX_STANDARD_8VSB:
3017 fec_oc_dto_period = 4;
3018 if (cfg_data->insert_rs_byte == true)
3019 fec_oc_dto_burst_len = 208;
3020 break;
3021 case DRX_STANDARD_ITU_A:
3022 {
3023 u32 symbol_rate_th = 6400000;
3024 if (cfg_data->insert_rs_byte == true) {
3025 fec_oc_dto_burst_len = 204;
3026 symbol_rate_th = 5900000;
3027 }
3028 if (ext_attr->curr_symbol_rate >=
3029 symbol_rate_th) {
3030 fec_oc_dto_period = 0;
3031 } else {
3032 fec_oc_dto_period = 1;
3033 }
3034 }
3035 break;
3036 case DRX_STANDARD_ITU_B:
3037 fec_oc_dto_period = 1;
3038 if (cfg_data->insert_rs_byte == true)
3039 fec_oc_dto_burst_len = 128;
3040 break;
3041 case DRX_STANDARD_ITU_C:
3042 fec_oc_dto_period = 1;
3043 if (cfg_data->insert_rs_byte == true)
3044 fec_oc_dto_burst_len = 204;
3045 break;
3046 default:
3047 return -EIO;
3048 }
3049 bit_rate =
3050 common_attr->sys_clock_freq * 1000 / (fec_oc_dto_period +
3051 2);
3052 dto_rate =
3053 frac28(bit_rate, common_attr->sys_clock_freq * 1000);
3054 dto_rate >>= 3;
3055 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_DTO_RATE_HI__A, (u16)((dto_rate >> 16) & FEC_OC_DTO_RATE_HI__M), 0);
3056 if (rc != 0) {
3057 pr_err("error %d\n", rc);
3058 goto rw_error;
3059 }
3060 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_DTO_RATE_LO__A, (u16)(dto_rate & FEC_OC_DTO_RATE_LO_RATE_LO__M), 0);
3061 if (rc != 0) {
3062 pr_err("error %d\n", rc);
3063 goto rw_error;
3064 }
3065 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_DTO_MODE__A, FEC_OC_DTO_MODE_DYNAMIC__M | FEC_OC_DTO_MODE_OFFSET_ENABLE__M, 0);
3066 if (rc != 0) {
3067 pr_err("error %d\n", rc);
3068 goto rw_error;
3069 }
3070 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_FCT_MODE__A, FEC_OC_FCT_MODE_RAT_ENA__M | FEC_OC_FCT_MODE_VIRT_ENA__M, 0);
3071 if (rc != 0) {
3072 pr_err("error %d\n", rc);
3073 goto rw_error;
3074 }
3075 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_DTO_BURST_LEN__A, fec_oc_dto_burst_len, 0);
3076 if (rc != 0) {
3077 pr_err("error %d\n", rc);
3078 goto rw_error;
3079 }
3080 if (ext_attr->mpeg_output_clock_rate != DRXJ_MPEGOUTPUT_CLOCK_RATE_AUTO)
3081 fec_oc_dto_period = ext_attr->mpeg_output_clock_rate - 1;
3082 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_DTO_PERIOD__A, fec_oc_dto_period, 0);
3083 if (rc != 0) {
3084 pr_err("error %d\n", rc);
3085 goto rw_error;
3086 }
3087 } else { /* Dynamic mode */
3088
3089 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_DTO_MODE__A, FEC_OC_DTO_MODE_DYNAMIC__M, 0);
3090 if (rc != 0) {
3091 pr_err("error %d\n", rc);
3092 goto rw_error;
3093 }
3094 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_FCT_MODE__A, 0, 0);
3095 if (rc != 0) {
3096 pr_err("error %d\n", rc);
3097 goto rw_error;
3098 }
3099 }
3100
3101 rc = drxdap_fasi_write_reg32(dev_addr, FEC_OC_RCN_CTL_RATE_LO__A, rcn_rate, 0);
3102 if (rc != 0) {
3103 pr_err("error %d\n", rc);
3104 goto rw_error;
3105 }
3106
3107 /* Write appropriate registers with requested configuration */
3108 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_MODE__A, fec_oc_reg_mode, 0);
3109 if (rc != 0) {
3110 pr_err("error %d\n", rc);
3111 goto rw_error;
3112 }
3113 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_IPR_MODE__A, fec_oc_reg_ipr_mode, 0);
3114 if (rc != 0) {
3115 pr_err("error %d\n", rc);
3116 goto rw_error;
3117 }
3118 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_IPR_INVERT__A, fec_oc_reg_ipr_invert, 0);
3119 if (rc != 0) {
3120 pr_err("error %d\n", rc);
3121 goto rw_error;
3122 }
3123
3124 /* enabling for both parallel and serial now */
3125 /* Write magic word to enable pdr reg write */
3126 rc = drxj_dap_write_reg16(dev_addr, SIO_TOP_COMM_KEY__A, 0xFABA, 0);
3127 if (rc != 0) {
3128 pr_err("error %d\n", rc);
3129 goto rw_error;
3130 }
3131 /* Set MPEG TS pads to outputmode */
3132 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MSTRT_CFG__A, 0x0013, 0);
3133 if (rc != 0) {
3134 pr_err("error %d\n", rc);
3135 goto rw_error;
3136 }
3137 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MERR_CFG__A, 0x0013, 0);
3138 if (rc != 0) {
3139 pr_err("error %d\n", rc);
3140 goto rw_error;
3141 }
3142 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MCLK_CFG__A, MPEG_OUTPUT_CLK_DRIVE_STRENGTH << SIO_PDR_MCLK_CFG_DRIVE__B | 0x03 << SIO_PDR_MCLK_CFG_MODE__B, 0);
3143 if (rc != 0) {
3144 pr_err("error %d\n", rc);
3145 goto rw_error;
3146 }
3147 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MVAL_CFG__A, 0x0013, 0);
3148 if (rc != 0) {
3149 pr_err("error %d\n", rc);
3150 goto rw_error;
3151 }
3152 sio_pdr_md_cfg =
3153 MPEG_SERIAL_OUTPUT_PIN_DRIVE_STRENGTH <<
3154 SIO_PDR_MD0_CFG_DRIVE__B | 0x03 << SIO_PDR_MD0_CFG_MODE__B;
3155 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD0_CFG__A, sio_pdr_md_cfg, 0);
3156 if (rc != 0) {
3157 pr_err("error %d\n", rc);
3158 goto rw_error;
3159 }
3160 if (cfg_data->enable_parallel == true) { /* MPEG data output is paralel -> set MD1 to MD7 to output mode */
3161 sio_pdr_md_cfg =
3162 MPEG_PARALLEL_OUTPUT_PIN_DRIVE_STRENGTH <<
3163 SIO_PDR_MD0_CFG_DRIVE__B | 0x03 <<
3164 SIO_PDR_MD0_CFG_MODE__B;
3165 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD0_CFG__A, sio_pdr_md_cfg, 0);
3166 if (rc != 0) {
3167 pr_err("error %d\n", rc);
3168 goto rw_error;
3169 }
3170 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD1_CFG__A, sio_pdr_md_cfg, 0);
3171 if (rc != 0) {
3172 pr_err("error %d\n", rc);
3173 goto rw_error;
3174 }
3175 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD2_CFG__A, sio_pdr_md_cfg, 0);
3176 if (rc != 0) {
3177 pr_err("error %d\n", rc);
3178 goto rw_error;
3179 }
3180 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD3_CFG__A, sio_pdr_md_cfg, 0);
3181 if (rc != 0) {
3182 pr_err("error %d\n", rc);
3183 goto rw_error;
3184 }
3185 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD4_CFG__A, sio_pdr_md_cfg, 0);
3186 if (rc != 0) {
3187 pr_err("error %d\n", rc);
3188 goto rw_error;
3189 }
3190 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD5_CFG__A, sio_pdr_md_cfg, 0);
3191 if (rc != 0) {
3192 pr_err("error %d\n", rc);
3193 goto rw_error;
3194 }
3195 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD6_CFG__A, sio_pdr_md_cfg, 0);
3196 if (rc != 0) {
3197 pr_err("error %d\n", rc);
3198 goto rw_error;
3199 }
3200 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD7_CFG__A, sio_pdr_md_cfg, 0);
3201 if (rc != 0) {
3202 pr_err("error %d\n", rc);
3203 goto rw_error;
3204 }
3205 } else { /* MPEG data output is serial -> set MD1 to MD7 to tri-state */
3206 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD1_CFG__A, 0x0000, 0);
3207 if (rc != 0) {
3208 pr_err("error %d\n", rc);
3209 goto rw_error;
3210 }
3211 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD2_CFG__A, 0x0000, 0);
3212 if (rc != 0) {
3213 pr_err("error %d\n", rc);
3214 goto rw_error;
3215 }
3216 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD3_CFG__A, 0x0000, 0);
3217 if (rc != 0) {
3218 pr_err("error %d\n", rc);
3219 goto rw_error;
3220 }
3221 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD4_CFG__A, 0x0000, 0);
3222 if (rc != 0) {
3223 pr_err("error %d\n", rc);
3224 goto rw_error;
3225 }
3226 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD5_CFG__A, 0x0000, 0);
3227 if (rc != 0) {
3228 pr_err("error %d\n", rc);
3229 goto rw_error;
3230 }
3231 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD6_CFG__A, 0x0000, 0);
3232 if (rc != 0) {
3233 pr_err("error %d\n", rc);
3234 goto rw_error;
3235 }
3236 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD7_CFG__A, 0x0000, 0);
3237 if (rc != 0) {
3238 pr_err("error %d\n", rc);
3239 goto rw_error;
3240 }
3241 }
3242 /* Enable Monitor Bus output over MPEG pads and ctl input */
3243 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MON_CFG__A, 0x0000, 0);
3244 if (rc != 0) {
3245 pr_err("error %d\n", rc);
3246 goto rw_error;
3247 }
3248 /* Write nomagic word to enable pdr reg write */
3249 rc = drxj_dap_write_reg16(dev_addr, SIO_TOP_COMM_KEY__A, 0x0000, 0);
3250 if (rc != 0) {
3251 pr_err("error %d\n", rc);
3252 goto rw_error;
3253 }
3254 } else {
3255 /* Write magic word to enable pdr reg write */
3256 rc = drxj_dap_write_reg16(dev_addr, SIO_TOP_COMM_KEY__A, 0xFABA, 0);
3257 if (rc != 0) {
3258 pr_err("error %d\n", rc);
3259 goto rw_error;
3260 }
3261 /* Set MPEG TS pads to inputmode */
3262 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MSTRT_CFG__A, 0x0000, 0);
3263 if (rc != 0) {
3264 pr_err("error %d\n", rc);
3265 goto rw_error;
3266 }
3267 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MERR_CFG__A, 0x0000, 0);
3268 if (rc != 0) {
3269 pr_err("error %d\n", rc);
3270 goto rw_error;
3271 }
3272 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MCLK_CFG__A, 0x0000, 0);
3273 if (rc != 0) {
3274 pr_err("error %d\n", rc);
3275 goto rw_error;
3276 }
3277 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MVAL_CFG__A, 0x0000, 0);
3278 if (rc != 0) {
3279 pr_err("error %d\n", rc);
3280 goto rw_error;
3281 }
3282 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD0_CFG__A, 0x0000, 0);
3283 if (rc != 0) {
3284 pr_err("error %d\n", rc);
3285 goto rw_error;
3286 }
3287 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD1_CFG__A, 0x0000, 0);
3288 if (rc != 0) {
3289 pr_err("error %d\n", rc);
3290 goto rw_error;
3291 }
3292 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD2_CFG__A, 0x0000, 0);
3293 if (rc != 0) {
3294 pr_err("error %d\n", rc);
3295 goto rw_error;
3296 }
3297 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD3_CFG__A, 0x0000, 0);
3298 if (rc != 0) {
3299 pr_err("error %d\n", rc);
3300 goto rw_error;
3301 }
3302 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD4_CFG__A, 0x0000, 0);
3303 if (rc != 0) {
3304 pr_err("error %d\n", rc);
3305 goto rw_error;
3306 }
3307 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD5_CFG__A, 0x0000, 0);
3308 if (rc != 0) {
3309 pr_err("error %d\n", rc);
3310 goto rw_error;
3311 }
3312 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD6_CFG__A, 0x0000, 0);
3313 if (rc != 0) {
3314 pr_err("error %d\n", rc);
3315 goto rw_error;
3316 }
3317 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MD7_CFG__A, 0x0000, 0);
3318 if (rc != 0) {
3319 pr_err("error %d\n", rc);
3320 goto rw_error;
3321 }
3322 /* Enable Monitor Bus output over MPEG pads and ctl input */
3323 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_MON_CFG__A, 0x0000, 0);
3324 if (rc != 0) {
3325 pr_err("error %d\n", rc);
3326 goto rw_error;
3327 }
3328 /* Write nomagic word to enable pdr reg write */
3329 rc = drxj_dap_write_reg16(dev_addr, SIO_TOP_COMM_KEY__A, 0x0000, 0);
3330 if (rc != 0) {
3331 pr_err("error %d\n", rc);
3332 goto rw_error;
3333 }
3334 }
3335
3336 /* save values for restore after re-acquire */
3337 common_attr->mpeg_cfg.enable_mpeg_output = cfg_data->enable_mpeg_output;
3338
3339 return 0;
3340rw_error:
3341 return -EIO;
3342}
3343
3344/*----------------------------------------------------------------------------*/
3345
3346
3347/*----------------------------------------------------------------------------*/
3348/* MPEG Output Configuration Functions - end */
3349/*----------------------------------------------------------------------------*/
3350
3351/*----------------------------------------------------------------------------*/
3352/* miscellaneous configuartions - begin */
3353/*----------------------------------------------------------------------------*/
3354
3355/**
3356* \fn int set_mpegtei_handling()
3357* \brief Activate MPEG TEI handling settings.
3358* \param devmod Pointer to demodulator instance.
3359* \return int.
3360*
3361* This routine should be called during a set channel of QAM/VSB
3362*
3363*/
3364static int set_mpegtei_handling(struct drx_demod_instance *demod)
3365{
3366 struct drxj_data *ext_attr = (struct drxj_data *) (NULL);
3367 struct i2c_device_addr *dev_addr = (struct i2c_device_addr *)(NULL);
3368 int rc;
3369 u16 fec_oc_dpr_mode = 0;
3370 u16 fec_oc_snc_mode = 0;
3371 u16 fec_oc_ems_mode = 0;
3372
3373 dev_addr = demod->my_i2c_dev_addr;
3374 ext_attr = (struct drxj_data *) demod->my_ext_attr;
3375
3376 rc = drxj_dap_read_reg16(dev_addr, FEC_OC_DPR_MODE__A, &fec_oc_dpr_mode, 0);
3377 if (rc != 0) {
3378 pr_err("error %d\n", rc);
3379 goto rw_error;
3380 }
3381 rc = drxj_dap_read_reg16(dev_addr, FEC_OC_SNC_MODE__A, &fec_oc_snc_mode, 0);
3382 if (rc != 0) {
3383 pr_err("error %d\n", rc);
3384 goto rw_error;
3385 }
3386 rc = drxj_dap_read_reg16(dev_addr, FEC_OC_EMS_MODE__A, &fec_oc_ems_mode, 0);
3387 if (rc != 0) {
3388 pr_err("error %d\n", rc);
3389 goto rw_error;
3390 }
3391
3392 /* reset to default, allow TEI bit to be changed */
3393 fec_oc_dpr_mode &= (~FEC_OC_DPR_MODE_ERR_DISABLE__M);
3394 fec_oc_snc_mode &= (~(FEC_OC_SNC_MODE_ERROR_CTL__M |
3395 FEC_OC_SNC_MODE_CORR_DISABLE__M));
3396 fec_oc_ems_mode &= (~FEC_OC_EMS_MODE_MODE__M);
3397
3398 if (ext_attr->disable_te_ihandling) {
3399 /* do not change TEI bit */
3400 fec_oc_dpr_mode |= FEC_OC_DPR_MODE_ERR_DISABLE__M;
3401 fec_oc_snc_mode |= FEC_OC_SNC_MODE_CORR_DISABLE__M |
3402 ((0x2) << (FEC_OC_SNC_MODE_ERROR_CTL__B));
3403 fec_oc_ems_mode |= ((0x01) << (FEC_OC_EMS_MODE_MODE__B));
3404 }
3405
3406 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_DPR_MODE__A, fec_oc_dpr_mode, 0);
3407 if (rc != 0) {
3408 pr_err("error %d\n", rc);
3409 goto rw_error;
3410 }
3411 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_SNC_MODE__A, fec_oc_snc_mode, 0);
3412 if (rc != 0) {
3413 pr_err("error %d\n", rc);
3414 goto rw_error;
3415 }
3416 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_EMS_MODE__A, fec_oc_ems_mode, 0);
3417 if (rc != 0) {
3418 pr_err("error %d\n", rc);
3419 goto rw_error;
3420 }
3421
3422 return 0;
3423rw_error:
3424 return -EIO;
3425}
3426
3427/*----------------------------------------------------------------------------*/
3428/**
3429* \fn int bit_reverse_mpeg_output()
3430* \brief Set MPEG output bit-endian settings.
3431* \param devmod Pointer to demodulator instance.
3432* \return int.
3433*
3434* This routine should be called during a set channel of QAM/VSB
3435*
3436*/
3437static int bit_reverse_mpeg_output(struct drx_demod_instance *demod)
3438{
3439 struct drxj_data *ext_attr = (struct drxj_data *) (NULL);
3440 struct i2c_device_addr *dev_addr = (struct i2c_device_addr *)(NULL);
3441 int rc;
3442 u16 fec_oc_ipr_mode = 0;
3443
3444 dev_addr = demod->my_i2c_dev_addr;
3445 ext_attr = (struct drxj_data *) demod->my_ext_attr;
3446
3447 rc = drxj_dap_read_reg16(dev_addr, FEC_OC_IPR_MODE__A, &fec_oc_ipr_mode, 0);
3448 if (rc != 0) {
3449 pr_err("error %d\n", rc);
3450 goto rw_error;
3451 }
3452
3453 /* reset to default (normal bit order) */
3454 fec_oc_ipr_mode &= (~FEC_OC_IPR_MODE_REVERSE_ORDER__M);
3455
3456 if (ext_attr->bit_reverse_mpeg_outout)
3457 fec_oc_ipr_mode |= FEC_OC_IPR_MODE_REVERSE_ORDER__M;
3458
3459 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_IPR_MODE__A, fec_oc_ipr_mode, 0);
3460 if (rc != 0) {
3461 pr_err("error %d\n", rc);
3462 goto rw_error;
3463 }
3464
3465 return 0;
3466rw_error:
3467 return -EIO;
3468}
3469
3470/*----------------------------------------------------------------------------*/
3471/**
3472* \fn int set_mpeg_start_width()
3473* \brief Set MPEG start width.
3474* \param devmod Pointer to demodulator instance.
3475* \return int.
3476*
3477* This routine should be called during a set channel of QAM/VSB
3478*
3479*/
3480static int set_mpeg_start_width(struct drx_demod_instance *demod)
3481{
3482 struct drxj_data *ext_attr = (struct drxj_data *) (NULL);
3483 struct i2c_device_addr *dev_addr = (struct i2c_device_addr *)(NULL);
3484 struct drx_common_attr *common_attr = (struct drx_common_attr *) NULL;
3485 int rc;
3486 u16 fec_oc_comm_mb = 0;
3487
3488 dev_addr = demod->my_i2c_dev_addr;
3489 ext_attr = (struct drxj_data *) demod->my_ext_attr;
3490 common_attr = demod->my_common_attr;
3491
3492 if ((common_attr->mpeg_cfg.static_clk == true)
3493 && (common_attr->mpeg_cfg.enable_parallel == false)) {
3494 rc = drxj_dap_read_reg16(dev_addr, FEC_OC_COMM_MB__A, &fec_oc_comm_mb, 0);
3495 if (rc != 0) {
3496 pr_err("error %d\n", rc);
3497 goto rw_error;
3498 }
3499 fec_oc_comm_mb &= ~FEC_OC_COMM_MB_CTL_ON;
3500 if (ext_attr->mpeg_start_width == DRXJ_MPEG_START_WIDTH_8CLKCYC)
3501 fec_oc_comm_mb |= FEC_OC_COMM_MB_CTL_ON;
3502 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_COMM_MB__A, fec_oc_comm_mb, 0);
3503 if (rc != 0) {
3504 pr_err("error %d\n", rc);
3505 goto rw_error;
3506 }
3507 }
3508
3509 return 0;
3510rw_error:
3511 return -EIO;
3512}
3513
3514/*----------------------------------------------------------------------------*/
3515/* miscellaneous configuartions - end */
3516/*----------------------------------------------------------------------------*/
3517
3518/*----------------------------------------------------------------------------*/
3519/* UIO Configuration Functions - begin */
3520/*----------------------------------------------------------------------------*/
3521/**
3522* \fn int ctrl_set_uio_cfg()
3523* \brief Configure modus oprandi UIO.
3524* \param demod Pointer to demodulator instance.
3525* \param uio_cfg Pointer to a configuration setting for a certain UIO.
3526* \return int.
3527*/
3528static int ctrl_set_uio_cfg(struct drx_demod_instance *demod, struct drxuio_cfg *uio_cfg)
3529{
3530 struct drxj_data *ext_attr = (struct drxj_data *) (NULL);
3531 int rc;
3532
3533 if ((uio_cfg == NULL) || (demod == NULL))
3534 return -EINVAL;
3535
3536 ext_attr = (struct drxj_data *) demod->my_ext_attr;
3537
3538 /* Write magic word to enable pdr reg write */
3539 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_TOP_COMM_KEY__A, SIO_TOP_COMM_KEY_KEY, 0);
3540 if (rc != 0) {
3541 pr_err("error %d\n", rc);
3542 goto rw_error;
3543 }
3544 switch (uio_cfg->uio) {
3545 /*====================================================================*/
3546 case DRX_UIO1:
3547 /* DRX_UIO1: SMA_TX UIO-1 */
3548 if (!ext_attr->has_smatx)
3549 return -EIO;
3550 switch (uio_cfg->mode) {
3551 case DRX_UIO_MODE_FIRMWARE_SMA: /* falltrough */
3552 case DRX_UIO_MODE_FIRMWARE_SAW: /* falltrough */
3553 case DRX_UIO_MODE_READWRITE:
3554 ext_attr->uio_sma_tx_mode = uio_cfg->mode;
3555 break;
3556 case DRX_UIO_MODE_DISABLE:
3557 ext_attr->uio_sma_tx_mode = uio_cfg->mode;
3558 /* pad configuration register is set 0 - input mode */
3559 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_SMA_TX_CFG__A, 0, 0);
3560 if (rc != 0) {
3561 pr_err("error %d\n", rc);
3562 goto rw_error;
3563 }
3564 break;
3565 default:
3566 return -EINVAL;
3567 } /* switch ( uio_cfg->mode ) */
3568 break;
3569 /*====================================================================*/
3570 case DRX_UIO2:
3571 /* DRX_UIO2: SMA_RX UIO-2 */
3572 if (!ext_attr->has_smarx)
3573 return -EIO;
3574 switch (uio_cfg->mode) {
3575 case DRX_UIO_MODE_FIRMWARE0: /* falltrough */
3576 case DRX_UIO_MODE_READWRITE:
3577 ext_attr->uio_sma_rx_mode = uio_cfg->mode;
3578 break;
3579 case DRX_UIO_MODE_DISABLE:
3580 ext_attr->uio_sma_rx_mode = uio_cfg->mode;
3581 /* pad configuration register is set 0 - input mode */
3582 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_SMA_RX_CFG__A, 0, 0);
3583 if (rc != 0) {
3584 pr_err("error %d\n", rc);
3585 goto rw_error;
3586 }
3587 break;
3588 default:
3589 return -EINVAL;
3590 break;
3591 } /* switch ( uio_cfg->mode ) */
3592 break;
3593 /*====================================================================*/
3594 case DRX_UIO3:
3595 /* DRX_UIO3: GPIO UIO-3 */
3596 if (!ext_attr->has_gpio)
3597 return -EIO;
3598 switch (uio_cfg->mode) {
3599 case DRX_UIO_MODE_FIRMWARE0: /* falltrough */
3600 case DRX_UIO_MODE_READWRITE:
3601 ext_attr->uio_gpio_mode = uio_cfg->mode;
3602 break;
3603 case DRX_UIO_MODE_DISABLE:
3604 ext_attr->uio_gpio_mode = uio_cfg->mode;
3605 /* pad configuration register is set 0 - input mode */
3606 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_GPIO_CFG__A, 0, 0);
3607 if (rc != 0) {
3608 pr_err("error %d\n", rc);
3609 goto rw_error;
3610 }
3611 break;
3612 default:
3613 return -EINVAL;
3614 break;
3615 } /* switch ( uio_cfg->mode ) */
3616 break;
3617 /*====================================================================*/
3618 case DRX_UIO4:
3619 /* DRX_UIO4: IRQN UIO-4 */
3620 if (!ext_attr->has_irqn)
3621 return -EIO;
3622 switch (uio_cfg->mode) {
3623 case DRX_UIO_MODE_READWRITE:
3624 ext_attr->uio_irqn_mode = uio_cfg->mode;
3625 break;
3626 case DRX_UIO_MODE_DISABLE:
3627 /* pad configuration register is set 0 - input mode */
3628 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_IRQN_CFG__A, 0, 0);
3629 if (rc != 0) {
3630 pr_err("error %d\n", rc);
3631 goto rw_error;
3632 }
3633 ext_attr->uio_irqn_mode = uio_cfg->mode;
3634 break;
3635 case DRX_UIO_MODE_FIRMWARE0: /* falltrough */
3636 default:
3637 return -EINVAL;
3638 break;
3639 } /* switch ( uio_cfg->mode ) */
3640 break;
3641 /*====================================================================*/
3642 default:
3643 return -EINVAL;
3644 } /* switch ( uio_cfg->uio ) */
3645
3646 /* Write magic word to disable pdr reg write */
3647 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_TOP_COMM_KEY__A, 0x0000, 0);
3648 if (rc != 0) {
3649 pr_err("error %d\n", rc);
3650 goto rw_error;
3651 }
3652
3653 return 0;
3654rw_error:
3655 return -EIO;
3656}
3657
3658/**
3659* \fn int ctrl_uio_write()
3660* \brief Write to a UIO.
3661* \param demod Pointer to demodulator instance.
3662* \param uio_data Pointer to data container for a certain UIO.
3663* \return int.
3664*/
3665static int
3666ctrl_uio_write(struct drx_demod_instance *demod, struct drxuio_data *uio_data)
3667{
3668 struct drxj_data *ext_attr = (struct drxj_data *) (NULL);
3669 int rc;
3670 u16 pin_cfg_value = 0;
3671 u16 value = 0;
3672
3673 if ((uio_data == NULL) || (demod == NULL))
3674 return -EINVAL;
3675
3676 ext_attr = (struct drxj_data *) demod->my_ext_attr;
3677
3678 /* Write magic word to enable pdr reg write */
3679 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_TOP_COMM_KEY__A, SIO_TOP_COMM_KEY_KEY, 0);
3680 if (rc != 0) {
3681 pr_err("error %d\n", rc);
3682 goto rw_error;
3683 }
3684 switch (uio_data->uio) {
3685 /*====================================================================*/
3686 case DRX_UIO1:
3687 /* DRX_UIO1: SMA_TX UIO-1 */
3688 if (!ext_attr->has_smatx)
3689 return -EIO;
3690 if ((ext_attr->uio_sma_tx_mode != DRX_UIO_MODE_READWRITE)
3691 && (ext_attr->uio_sma_tx_mode != DRX_UIO_MODE_FIRMWARE_SAW)) {
3692 return -EIO;
3693 }
3694 pin_cfg_value = 0;
3695 /* io_pad_cfg register (8 bit reg.) MSB bit is 1 (default value) */
3696 pin_cfg_value |= 0x0113;
3697 /* io_pad_cfg_mode output mode is drive always */
3698 /* io_pad_cfg_drive is set to power 2 (23 mA) */
3699
3700 /* write to io pad configuration register - output mode */
3701 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_SMA_TX_CFG__A, pin_cfg_value, 0);
3702 if (rc != 0) {
3703 pr_err("error %d\n", rc);
3704 goto rw_error;
3705 }
3706
3707 /* use corresponding bit in io data output registar */
3708 rc = drxj_dap_read_reg16(demod->my_i2c_dev_addr, SIO_PDR_UIO_OUT_LO__A, &value, 0);
3709 if (rc != 0) {
3710 pr_err("error %d\n", rc);
3711 goto rw_error;
3712 }
3713 if (!uio_data->value)
3714 value &= 0x7FFF; /* write zero to 15th bit - 1st UIO */
3715 else
3716 value |= 0x8000; /* write one to 15th bit - 1st UIO */
3717
3718 /* write back to io data output register */
3719 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_UIO_OUT_LO__A, value, 0);
3720 if (rc != 0) {
3721 pr_err("error %d\n", rc);
3722 goto rw_error;
3723 }
3724 break;
3725 /*======================================================================*/
3726 case DRX_UIO2:
3727 /* DRX_UIO2: SMA_RX UIO-2 */
3728 if (!ext_attr->has_smarx)
3729 return -EIO;
3730 if (ext_attr->uio_sma_rx_mode != DRX_UIO_MODE_READWRITE)
3731 return -EIO;
3732
3733 pin_cfg_value = 0;
3734 /* io_pad_cfg register (8 bit reg.) MSB bit is 1 (default value) */
3735 pin_cfg_value |= 0x0113;
3736 /* io_pad_cfg_mode output mode is drive always */
3737 /* io_pad_cfg_drive is set to power 2 (23 mA) */
3738
3739 /* write to io pad configuration register - output mode */
3740 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_SMA_RX_CFG__A, pin_cfg_value, 0);
3741 if (rc != 0) {
3742 pr_err("error %d\n", rc);
3743 goto rw_error;
3744 }
3745
3746 /* use corresponding bit in io data output registar */
3747 rc = drxj_dap_read_reg16(demod->my_i2c_dev_addr, SIO_PDR_UIO_OUT_LO__A, &value, 0);
3748 if (rc != 0) {
3749 pr_err("error %d\n", rc);
3750 goto rw_error;
3751 }
3752 if (!uio_data->value)
3753 value &= 0xBFFF; /* write zero to 14th bit - 2nd UIO */
3754 else
3755 value |= 0x4000; /* write one to 14th bit - 2nd UIO */
3756
3757 /* write back to io data output register */
3758 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_UIO_OUT_LO__A, value, 0);
3759 if (rc != 0) {
3760 pr_err("error %d\n", rc);
3761 goto rw_error;
3762 }
3763 break;
3764 /*====================================================================*/
3765 case DRX_UIO3:
3766 /* DRX_UIO3: ASEL UIO-3 */
3767 if (!ext_attr->has_gpio)
3768 return -EIO;
3769 if (ext_attr->uio_gpio_mode != DRX_UIO_MODE_READWRITE)
3770 return -EIO;
3771
3772 pin_cfg_value = 0;
3773 /* io_pad_cfg register (8 bit reg.) MSB bit is 1 (default value) */
3774 pin_cfg_value |= 0x0113;
3775 /* io_pad_cfg_mode output mode is drive always */
3776 /* io_pad_cfg_drive is set to power 2 (23 mA) */
3777
3778 /* write to io pad configuration register - output mode */
3779 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_GPIO_CFG__A, pin_cfg_value, 0);
3780 if (rc != 0) {
3781 pr_err("error %d\n", rc);
3782 goto rw_error;
3783 }
3784
3785 /* use corresponding bit in io data output registar */
3786 rc = drxj_dap_read_reg16(demod->my_i2c_dev_addr, SIO_PDR_UIO_OUT_HI__A, &value, 0);
3787 if (rc != 0) {
3788 pr_err("error %d\n", rc);
3789 goto rw_error;
3790 }
3791 if (!uio_data->value)
3792 value &= 0xFFFB; /* write zero to 2nd bit - 3rd UIO */
3793 else
3794 value |= 0x0004; /* write one to 2nd bit - 3rd UIO */
3795
3796 /* write back to io data output register */
3797 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_UIO_OUT_HI__A, value, 0);
3798 if (rc != 0) {
3799 pr_err("error %d\n", rc);
3800 goto rw_error;
3801 }
3802 break;
3803 /*=====================================================================*/
3804 case DRX_UIO4:
3805 /* DRX_UIO4: IRQN UIO-4 */
3806 if (!ext_attr->has_irqn)
3807 return -EIO;
3808
3809 if (ext_attr->uio_irqn_mode != DRX_UIO_MODE_READWRITE)
3810 return -EIO;
3811
3812 pin_cfg_value = 0;
3813 /* io_pad_cfg register (8 bit reg.) MSB bit is 1 (default value) */
3814 pin_cfg_value |= 0x0113;
3815 /* io_pad_cfg_mode output mode is drive always */
3816 /* io_pad_cfg_drive is set to power 2 (23 mA) */
3817
3818 /* write to io pad configuration register - output mode */
3819 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_IRQN_CFG__A, pin_cfg_value, 0);
3820 if (rc != 0) {
3821 pr_err("error %d\n", rc);
3822 goto rw_error;
3823 }
3824
3825 /* use corresponding bit in io data output registar */
3826 rc = drxj_dap_read_reg16(demod->my_i2c_dev_addr, SIO_PDR_UIO_OUT_LO__A, &value, 0);
3827 if (rc != 0) {
3828 pr_err("error %d\n", rc);
3829 goto rw_error;
3830 }
3831 if (uio_data->value == false)
3832 value &= 0xEFFF; /* write zero to 12th bit - 4th UIO */
3833 else
3834 value |= 0x1000; /* write one to 12th bit - 4th UIO */
3835
3836 /* write back to io data output register */
3837 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_UIO_OUT_LO__A, value, 0);
3838 if (rc != 0) {
3839 pr_err("error %d\n", rc);
3840 goto rw_error;
3841 }
3842 break;
3843 /*=====================================================================*/
3844 default:
3845 return -EINVAL;
3846 } /* switch ( uio_data->uio ) */
3847
3848 /* Write magic word to disable pdr reg write */
3849 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_TOP_COMM_KEY__A, 0x0000, 0);
3850 if (rc != 0) {
3851 pr_err("error %d\n", rc);
3852 goto rw_error;
3853 }
3854
3855 return 0;
3856rw_error:
3857 return -EIO;
3858}
3859
3860/*---------------------------------------------------------------------------*/
3861/* UIO Configuration Functions - end */
3862/*---------------------------------------------------------------------------*/
3863
3864/*----------------------------------------------------------------------------*/
3865/* I2C Bridge Functions - begin */
3866/*----------------------------------------------------------------------------*/
3867/**
3868* \fn int ctrl_i2c_bridge()
3869* \brief Open or close the I2C switch to tuner.
3870* \param demod Pointer to demodulator instance.
3871* \param bridge_closed Pointer to bool indication if bridge is closed not.
3872* \return int.
3873
3874*/
3875static int
3876ctrl_i2c_bridge(struct drx_demod_instance *demod, bool *bridge_closed)
3877{
3878 struct drxj_hi_cmd hi_cmd;
3879 u16 result = 0;
3880
3881 /* check arguments */
3882 if (bridge_closed == NULL)
3883 return -EINVAL;
3884
3885 hi_cmd.cmd = SIO_HI_RA_RAM_CMD_BRDCTRL;
3886 hi_cmd.param1 = SIO_HI_RA_RAM_PAR_1_PAR1_SEC_KEY;
3887 if (*bridge_closed)
3888 hi_cmd.param2 = SIO_HI_RA_RAM_PAR_2_BRD_CFG_CLOSED;
3889 else
3890 hi_cmd.param2 = SIO_HI_RA_RAM_PAR_2_BRD_CFG_OPEN;
3891
3892 return hi_command(demod->my_i2c_dev_addr, &hi_cmd, &result);
3893}
3894
3895/*----------------------------------------------------------------------------*/
3896/* I2C Bridge Functions - end */
3897/*----------------------------------------------------------------------------*/
3898
3899/*----------------------------------------------------------------------------*/
3900/* Smart antenna Functions - begin */
3901/*----------------------------------------------------------------------------*/
3902/**
3903* \fn int smart_ant_init()
3904* \brief Initialize Smart Antenna.
3905* \param pointer to struct drx_demod_instance.
3906* \return int.
3907*
3908*/
3909static int smart_ant_init(struct drx_demod_instance *demod)
3910{
3911 struct drxj_data *ext_attr = NULL;
3912 struct i2c_device_addr *dev_addr = NULL;
3913 struct drxuio_cfg uio_cfg = { DRX_UIO1, DRX_UIO_MODE_FIRMWARE_SMA };
3914 int rc;
3915 u16 data = 0;
3916
3917 dev_addr = demod->my_i2c_dev_addr;
3918 ext_attr = (struct drxj_data *) demod->my_ext_attr;
3919
3920 /* Write magic word to enable pdr reg write */
3921 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_TOP_COMM_KEY__A, SIO_TOP_COMM_KEY_KEY, 0);
3922 if (rc != 0) {
3923 pr_err("error %d\n", rc);
3924 goto rw_error;
3925 }
3926 /* init smart antenna */
3927 rc = drxj_dap_read_reg16(dev_addr, SIO_SA_TX_COMMAND__A, &data, 0);
3928 if (rc != 0) {
3929 pr_err("error %d\n", rc);
3930 goto rw_error;
3931 }
3932 if (ext_attr->smart_ant_inverted) {
3933 rc = drxj_dap_write_reg16(dev_addr, SIO_SA_TX_COMMAND__A, (data | SIO_SA_TX_COMMAND_TX_INVERT__M) | SIO_SA_TX_COMMAND_TX_ENABLE__M, 0);
3934 if (rc != 0) {
3935 pr_err("error %d\n", rc);
3936 goto rw_error;
3937 }
3938 } else {
3939 rc = drxj_dap_write_reg16(dev_addr, SIO_SA_TX_COMMAND__A, (data & (~SIO_SA_TX_COMMAND_TX_INVERT__M)) | SIO_SA_TX_COMMAND_TX_ENABLE__M, 0);
3940 if (rc != 0) {
3941 pr_err("error %d\n", rc);
3942 goto rw_error;
3943 }
3944 }
3945
3946 /* config SMA_TX pin to smart antenna mode */
3947 rc = ctrl_set_uio_cfg(demod, &uio_cfg);
3948 if (rc != 0) {
3949 pr_err("error %d\n", rc);
3950 goto rw_error;
3951 }
3952 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_SMA_TX_CFG__A, 0x13, 0);
3953 if (rc != 0) {
3954 pr_err("error %d\n", rc);
3955 goto rw_error;
3956 }
3957 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_PDR_SMA_TX_GPIO_FNC__A, 0x03, 0);
3958 if (rc != 0) {
3959 pr_err("error %d\n", rc);
3960 goto rw_error;
3961 }
3962
3963 /* Write magic word to disable pdr reg write */
3964 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, SIO_TOP_COMM_KEY__A, 0x0000, 0);
3965 if (rc != 0) {
3966 pr_err("error %d\n", rc);
3967 goto rw_error;
3968 }
3969
3970 return 0;
3971rw_error:
3972 return -EIO;
3973}
3974
3975static int scu_command(struct i2c_device_addr *dev_addr, struct drxjscu_cmd *cmd)
3976{
3977 int rc;
3978 u16 cur_cmd = 0;
3979 unsigned long timeout;
3980
3981 /* Check param */
3982 if (cmd == NULL)
3983 return -EINVAL;
3984
3985 /* Wait until SCU command interface is ready to receive command */
3986 rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_COMMAND__A, &cur_cmd, 0);
3987 if (rc != 0) {
3988 pr_err("error %d\n", rc);
3989 goto rw_error;
3990 }
3991 if (cur_cmd != DRX_SCU_READY)
3992 return -EIO;
3993
3994 switch (cmd->parameter_len) {
3995 case 5:
3996 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_PARAM_4__A, *(cmd->parameter + 4), 0);
3997 if (rc != 0) {
3998 pr_err("error %d\n", rc);
3999 goto rw_error;
4000 } /* fallthrough */
4001 case 4:
4002 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_PARAM_3__A, *(cmd->parameter + 3), 0);
4003 if (rc != 0) {
4004 pr_err("error %d\n", rc);
4005 goto rw_error;
4006 } /* fallthrough */
4007 case 3:
4008 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_PARAM_2__A, *(cmd->parameter + 2), 0);
4009 if (rc != 0) {
4010 pr_err("error %d\n", rc);
4011 goto rw_error;
4012 } /* fallthrough */
4013 case 2:
4014 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_PARAM_1__A, *(cmd->parameter + 1), 0);
4015 if (rc != 0) {
4016 pr_err("error %d\n", rc);
4017 goto rw_error;
4018 } /* fallthrough */
4019 case 1:
4020 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_PARAM_0__A, *(cmd->parameter + 0), 0);
4021 if (rc != 0) {
4022 pr_err("error %d\n", rc);
4023 goto rw_error;
4024 } /* fallthrough */
4025 case 0:
4026 /* do nothing */
4027 break;
4028 default:
4029 /* this number of parameters is not supported */
4030 return -EIO;
4031 }
4032 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_COMMAND__A, cmd->command, 0);
4033 if (rc != 0) {
4034 pr_err("error %d\n", rc);
4035 goto rw_error;
4036 }
4037
4038 /* Wait until SCU has processed command */
4039 timeout = jiffies + msecs_to_jiffies(DRXJ_MAX_WAITTIME);
4040 while (time_is_after_jiffies(timeout)) {
4041 rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_COMMAND__A, &cur_cmd, 0);
4042 if (rc != 0) {
4043 pr_err("error %d\n", rc);
4044 goto rw_error;
4045 }
4046 if (cur_cmd == DRX_SCU_READY)
4047 break;
4048 usleep_range(1000, 2000);
4049 }
4050
4051 if (cur_cmd != DRX_SCU_READY)
4052 return -EIO;
4053
4054 /* read results */
4055 if ((cmd->result_len > 0) && (cmd->result != NULL)) {
4056 s16 err;
4057
4058 switch (cmd->result_len) {
4059 case 4:
4060 rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_PARAM_3__A, cmd->result + 3, 0);
4061 if (rc != 0) {
4062 pr_err("error %d\n", rc);
4063 goto rw_error;
4064 } /* fallthrough */
4065 case 3:
4066 rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_PARAM_2__A, cmd->result + 2, 0);
4067 if (rc != 0) {
4068 pr_err("error %d\n", rc);
4069 goto rw_error;
4070 } /* fallthrough */
4071 case 2:
4072 rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_PARAM_1__A, cmd->result + 1, 0);
4073 if (rc != 0) {
4074 pr_err("error %d\n", rc);
4075 goto rw_error;
4076 } /* fallthrough */
4077 case 1:
4078 rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_PARAM_0__A, cmd->result + 0, 0);
4079 if (rc != 0) {
4080 pr_err("error %d\n", rc);
4081 goto rw_error;
4082 } /* fallthrough */
4083 case 0:
4084 /* do nothing */
4085 break;
4086 default:
4087 /* this number of parameters is not supported */
4088 return -EIO;
4089 }
4090
4091 /* Check if an error was reported by SCU */
4092 err = cmd->result[0];
4093
4094 /* check a few fixed error codes */
4095 if ((err == (s16) SCU_RAM_PARAM_0_RESULT_UNKSTD)
4096 || (err == (s16) SCU_RAM_PARAM_0_RESULT_UNKCMD)
4097 || (err == (s16) SCU_RAM_PARAM_0_RESULT_INVPAR)
4098 || (err == (s16) SCU_RAM_PARAM_0_RESULT_SIZE)
4099 ) {
4100 return -EINVAL;
4101 }
4102 /* here it is assumed that negative means error, and positive no error */
4103 else if (err < 0)
4104 return -EIO;
4105 else
4106 return 0;
4107 }
4108
4109 return 0;
4110
4111rw_error:
4112 return -EIO;
4113}
4114
4115/**
4116* \fn int DRXJ_DAP_SCUAtomicReadWriteBlock()
4117* \brief Basic access routine for SCU atomic read or write access
4118* \param dev_addr pointer to i2c dev address
4119* \param addr destination/source address
4120* \param datasize size of data buffer in bytes
4121* \param data pointer to data buffer
4122* \return int
4123* \retval 0 Succes
4124* \retval -EIO Timeout, I2C error, illegal bank
4125*
4126*/
4127#define ADDR_AT_SCU_SPACE(x) ((x - 0x82E000) * 2)
4128static
4129int drxj_dap_scu_atomic_read_write_block(struct i2c_device_addr *dev_addr, u32 addr, u16 datasize, /* max 30 bytes because the limit of SCU parameter */
4130 u8 *data, bool read_flag)
4131{
4132 struct drxjscu_cmd scu_cmd;
4133 int rc;
4134 u16 set_param_parameters[15];
4135 u16 cmd_result[15];
4136
4137 /* Parameter check */
4138 if (!data || !dev_addr || (datasize % 2) || ((datasize / 2) > 16))
4139 return -EINVAL;
4140
4141 set_param_parameters[1] = (u16) ADDR_AT_SCU_SPACE(addr);
4142 if (read_flag) { /* read */
4143 set_param_parameters[0] = ((~(0x0080)) & datasize);
4144 scu_cmd.parameter_len = 2;
4145 scu_cmd.result_len = datasize / 2 + 2;
4146 } else {
4147 int i = 0;
4148
4149 set_param_parameters[0] = 0x0080 | datasize;
4150 for (i = 0; i < (datasize / 2); i++) {
4151 set_param_parameters[i + 2] =
4152 (data[2 * i] | (data[(2 * i) + 1] << 8));
4153 }
4154 scu_cmd.parameter_len = datasize / 2 + 2;
4155 scu_cmd.result_len = 1;
4156 }
4157
4158 scu_cmd.command =
4159 SCU_RAM_COMMAND_STANDARD_TOP |
4160 SCU_RAM_COMMAND_CMD_AUX_SCU_ATOMIC_ACCESS;
4161 scu_cmd.result = cmd_result;
4162 scu_cmd.parameter = set_param_parameters;
4163 rc = scu_command(dev_addr, &scu_cmd);
4164 if (rc != 0) {
4165 pr_err("error %d\n", rc);
4166 goto rw_error;
4167 }
4168
4169 if (read_flag) {
4170 int i = 0;
4171 /* read data from buffer */
4172 for (i = 0; i < (datasize / 2); i++) {
4173 data[2 * i] = (u8) (scu_cmd.result[i + 2] & 0xFF);
4174 data[(2 * i) + 1] = (u8) (scu_cmd.result[i + 2] >> 8);
4175 }
4176 }
4177
4178 return 0;
4179
4180rw_error:
4181 return -EIO;
4182
4183}
4184
4185/*============================================================================*/
4186
4187/**
4188* \fn int DRXJ_DAP_AtomicReadReg16()
4189* \brief Atomic read of 16 bits words
4190*/
4191static
4192int drxj_dap_scu_atomic_read_reg16(struct i2c_device_addr *dev_addr,
4193 u32 addr,
4194 u16 *data, u32 flags)
4195{
4196 u8 buf[2];
4197 int rc = -EIO;
4198 u16 word = 0;
4199
4200 if (!data)
4201 return -EINVAL;
4202
4203 rc = drxj_dap_scu_atomic_read_write_block(dev_addr, addr, 2, buf, true);
4204 if (rc < 0)
4205 return rc;
4206
4207 word = (u16) (buf[0] + (buf[1] << 8));
4208
4209 *data = word;
4210
4211 return rc;
4212}
4213
4214/*============================================================================*/
4215/**
4216* \fn int drxj_dap_scu_atomic_write_reg16()
4217* \brief Atomic read of 16 bits words
4218*/
4219static
4220int drxj_dap_scu_atomic_write_reg16(struct i2c_device_addr *dev_addr,
4221 u32 addr,
4222 u16 data, u32 flags)
4223{
4224 u8 buf[2];
4225 int rc = -EIO;
4226
4227 buf[0] = (u8) (data & 0xff);
4228 buf[1] = (u8) ((data >> 8) & 0xff);
4229
4230 rc = drxj_dap_scu_atomic_read_write_block(dev_addr, addr, 2, buf, false);
4231
4232 return rc;
4233}
4234
4235/* -------------------------------------------------------------------------- */
4236/**
4237* \brief Measure result of ADC synchronisation
4238* \param demod demod instance
4239* \param count (returned) count
4240* \return int.
4241* \retval 0 Success
4242* \retval -EIO Failure: I2C error
4243*
4244*/
4245static int adc_sync_measurement(struct drx_demod_instance *demod, u16 *count)
4246{
4247 struct i2c_device_addr *dev_addr = NULL;
4248 int rc;
4249 u16 data = 0;
4250
4251 dev_addr = demod->my_i2c_dev_addr;
4252
4253 /* Start measurement */
4254 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_COMM_EXEC__A, IQM_AF_COMM_EXEC_ACTIVE, 0);
4255 if (rc != 0) {
4256 pr_err("error %d\n", rc);
4257 goto rw_error;
4258 }
4259 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_START_LOCK__A, 1, 0);
4260 if (rc != 0) {
4261 pr_err("error %d\n", rc);
4262 goto rw_error;
4263 }
4264
4265 /* Wait at least 3*128*(1/sysclk) <<< 1 millisec */
4266 msleep(1);
4267
4268 *count = 0;
4269 rc = drxj_dap_read_reg16(dev_addr, IQM_AF_PHASE0__A, &data, 0);
4270 if (rc != 0) {
4271 pr_err("error %d\n", rc);
4272 goto rw_error;
4273 }
4274 if (data == 127)
4275 *count = *count + 1;
4276 rc = drxj_dap_read_reg16(dev_addr, IQM_AF_PHASE1__A, &data, 0);
4277 if (rc != 0) {
4278 pr_err("error %d\n", rc);
4279 goto rw_error;
4280 }
4281 if (data == 127)
4282 *count = *count + 1;
4283 rc = drxj_dap_read_reg16(dev_addr, IQM_AF_PHASE2__A, &data, 0);
4284 if (rc != 0) {
4285 pr_err("error %d\n", rc);
4286 goto rw_error;
4287 }
4288 if (data == 127)
4289 *count = *count + 1;
4290
4291 return 0;
4292rw_error:
4293 return -EIO;
4294}
4295
4296/**
4297* \brief Synchronize analog and digital clock domains
4298* \param demod demod instance
4299* \return int.
4300* \retval 0 Success
4301* \retval -EIO Failure: I2C error or failure to synchronize
4302*
4303* An IQM reset will also reset the results of this synchronization.
4304* After an IQM reset this routine needs to be called again.
4305*
4306*/
4307
4308static int adc_synchronization(struct drx_demod_instance *demod)
4309{
4310 struct i2c_device_addr *dev_addr = NULL;
4311 int rc;
4312 u16 count = 0;
4313
4314 dev_addr = demod->my_i2c_dev_addr;
4315
4316 rc = adc_sync_measurement(demod, &count);
4317 if (rc != 0) {
4318 pr_err("error %d\n", rc);
4319 goto rw_error;
4320 }
4321
4322 if (count == 1) {
4323 /* Try sampling on a diffrent edge */
4324 u16 clk_neg = 0;
4325
4326 rc = drxj_dap_read_reg16(dev_addr, IQM_AF_CLKNEG__A, &clk_neg, 0);
4327 if (rc != 0) {
4328 pr_err("error %d\n", rc);
4329 goto rw_error;
4330 }
4331
4332 clk_neg ^= IQM_AF_CLKNEG_CLKNEGDATA__M;
4333 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_CLKNEG__A, clk_neg, 0);
4334 if (rc != 0) {
4335 pr_err("error %d\n", rc);
4336 goto rw_error;
4337 }
4338
4339 rc = adc_sync_measurement(demod, &count);
4340 if (rc != 0) {
4341 pr_err("error %d\n", rc);
4342 goto rw_error;
4343 }
4344 }
4345
4346 /* TODO: implement fallback scenarios */
4347 if (count < 2)
4348 return -EIO;
4349
4350 return 0;
4351rw_error:
4352 return -EIO;
4353}
4354
4355/*============================================================================*/
4356/*== END AUXILIARY FUNCTIONS ==*/
4357/*============================================================================*/
4358
4359/*============================================================================*/
4360/*============================================================================*/
4361/*== 8VSB & QAM COMMON DATAPATH FUNCTIONS ==*/
4362/*============================================================================*/
4363/*============================================================================*/
4364/**
4365* \fn int init_agc ()
4366* \brief Initialize AGC for all standards.
4367* \param demod instance of demodulator.
4368* \param channel pointer to channel data.
4369* \return int.
4370*/
4371static int init_agc(struct drx_demod_instance *demod)
4372{
4373 struct i2c_device_addr *dev_addr = NULL;
4374 struct drx_common_attr *common_attr = NULL;
4375 struct drxj_data *ext_attr = NULL;
4376 struct drxj_cfg_agc *p_agc_rf_settings = NULL;
4377 struct drxj_cfg_agc *p_agc_if_settings = NULL;
4378 int rc;
4379 u16 ingain_tgt_max = 0;
4380 u16 clp_dir_to = 0;
4381 u16 sns_sum_max = 0;
4382 u16 clp_sum_max = 0;
4383 u16 sns_dir_to = 0;
4384 u16 ki_innergain_min = 0;
4385 u16 agc_ki = 0;
4386 u16 ki_max = 0;
4387 u16 if_iaccu_hi_tgt_min = 0;
4388 u16 data = 0;
4389 u16 agc_ki_dgain = 0;
4390 u16 ki_min = 0;
4391 u16 clp_ctrl_mode = 0;
4392 u16 agc_rf = 0;
4393 u16 agc_if = 0;
4394
4395 dev_addr = demod->my_i2c_dev_addr;
4396 common_attr = (struct drx_common_attr *) demod->my_common_attr;
4397 ext_attr = (struct drxj_data *) demod->my_ext_attr;
4398
4399 switch (ext_attr->standard) {
4400 case DRX_STANDARD_8VSB:
4401 clp_sum_max = 1023;
4402 clp_dir_to = (u16) (-9);
4403 sns_sum_max = 1023;
4404 sns_dir_to = (u16) (-9);
4405 ki_innergain_min = (u16) (-32768);
4406 ki_max = 0x032C;
4407 agc_ki_dgain = 0xC;
4408 if_iaccu_hi_tgt_min = 2047;
4409 ki_min = 0x0117;
4410 ingain_tgt_max = 16383;
4411 clp_ctrl_mode = 0;
4412 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_KI_MINGAIN__A, 0x7fff, 0);
4413 if (rc != 0) {
4414 pr_err("error %d\n", rc);
4415 goto rw_error;
4416 }
4417 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_KI_MAXGAIN__A, 0x0, 0);
4418 if (rc != 0) {
4419 pr_err("error %d\n", rc);
4420 goto rw_error;
4421 }
4422 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_CLP_SUM__A, 0, 0);
4423 if (rc != 0) {
4424 pr_err("error %d\n", rc);
4425 goto rw_error;
4426 }
4427 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_CLP_CYCCNT__A, 0, 0);
4428 if (rc != 0) {
4429 pr_err("error %d\n", rc);
4430 goto rw_error;
4431 }
4432 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_CLP_DIR_WD__A, 0, 0);
4433 if (rc != 0) {
4434 pr_err("error %d\n", rc);
4435 goto rw_error;
4436 }
4437 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_CLP_DIR_STP__A, 1, 0);
4438 if (rc != 0) {
4439 pr_err("error %d\n", rc);
4440 goto rw_error;
4441 }
4442 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_SNS_SUM__A, 0, 0);
4443 if (rc != 0) {
4444 pr_err("error %d\n", rc);
4445 goto rw_error;
4446 }
4447 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_SNS_CYCCNT__A, 0, 0);
4448 if (rc != 0) {
4449 pr_err("error %d\n", rc);
4450 goto rw_error;
4451 }
4452 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_SNS_DIR_WD__A, 0, 0);
4453 if (rc != 0) {
4454 pr_err("error %d\n", rc);
4455 goto rw_error;
4456 }
4457 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_SNS_DIR_STP__A, 1, 0);
4458 if (rc != 0) {
4459 pr_err("error %d\n", rc);
4460 goto rw_error;
4461 }
4462 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_INGAIN__A, 1024, 0);
4463 if (rc != 0) {
4464 pr_err("error %d\n", rc);
4465 goto rw_error;
4466 }
4467 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_VSB_AGC_POW_TGT__A, 22600, 0);
4468 if (rc != 0) {
4469 pr_err("error %d\n", rc);
4470 goto rw_error;
4471 }
4472 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_INGAIN_TGT__A, 13200, 0);
4473 if (rc != 0) {
4474 pr_err("error %d\n", rc);
4475 goto rw_error;
4476 }
4477 p_agc_if_settings = &(ext_attr->vsb_if_agc_cfg);
4478 p_agc_rf_settings = &(ext_attr->vsb_rf_agc_cfg);
4479 break;
4480#ifndef DRXJ_VSB_ONLY
4481 case DRX_STANDARD_ITU_A:
4482 case DRX_STANDARD_ITU_C:
4483 case DRX_STANDARD_ITU_B:
4484 ingain_tgt_max = 5119;
4485 clp_sum_max = 1023;
4486 clp_dir_to = (u16) (-5);
4487 sns_sum_max = 127;
4488 sns_dir_to = (u16) (-3);
4489 ki_innergain_min = 0;
4490 ki_max = 0x0657;
4491 if_iaccu_hi_tgt_min = 2047;
4492 agc_ki_dgain = 0x7;
4493 ki_min = 0x0117;
4494 clp_ctrl_mode = 0;
4495 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_KI_MINGAIN__A, 0x7fff, 0);
4496 if (rc != 0) {
4497 pr_err("error %d\n", rc);
4498 goto rw_error;
4499 }
4500 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_KI_MAXGAIN__A, 0x0, 0);
4501 if (rc != 0) {
4502 pr_err("error %d\n", rc);
4503 goto rw_error;
4504 }
4505 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_CLP_SUM__A, 0, 0);
4506 if (rc != 0) {
4507 pr_err("error %d\n", rc);
4508 goto rw_error;
4509 }
4510 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_CLP_CYCCNT__A, 0, 0);
4511 if (rc != 0) {
4512 pr_err("error %d\n", rc);
4513 goto rw_error;
4514 }
4515 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_CLP_DIR_WD__A, 0, 0);
4516 if (rc != 0) {
4517 pr_err("error %d\n", rc);
4518 goto rw_error;
4519 }
4520 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_CLP_DIR_STP__A, 1, 0);
4521 if (rc != 0) {
4522 pr_err("error %d\n", rc);
4523 goto rw_error;
4524 }
4525 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_SNS_SUM__A, 0, 0);
4526 if (rc != 0) {
4527 pr_err("error %d\n", rc);
4528 goto rw_error;
4529 }
4530 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_SNS_CYCCNT__A, 0, 0);
4531 if (rc != 0) {
4532 pr_err("error %d\n", rc);
4533 goto rw_error;
4534 }
4535 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_SNS_DIR_WD__A, 0, 0);
4536 if (rc != 0) {
4537 pr_err("error %d\n", rc);
4538 goto rw_error;
4539 }
4540 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_SNS_DIR_STP__A, 1, 0);
4541 if (rc != 0) {
4542 pr_err("error %d\n", rc);
4543 goto rw_error;
4544 }
4545 p_agc_if_settings = &(ext_attr->qam_if_agc_cfg);
4546 p_agc_rf_settings = &(ext_attr->qam_rf_agc_cfg);
4547 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_INGAIN_TGT__A, p_agc_if_settings->top, 0);
4548 if (rc != 0) {
4549 pr_err("error %d\n", rc);
4550 goto rw_error;
4551 }
4552
4553 rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_AGC_KI__A, &agc_ki, 0);
4554 if (rc != 0) {
4555 pr_err("error %d\n", rc);
4556 goto rw_error;
4557 }
4558 agc_ki &= 0xf000;
4559 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_KI__A, agc_ki, 0);
4560 if (rc != 0) {
4561 pr_err("error %d\n", rc);
4562 goto rw_error;
4563 }
4564 break;
4565#endif
4566 default:
4567 return -EINVAL;
4568 }
4569
4570 /* for new AGC interface */
4571 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_INGAIN_TGT_MIN__A, p_agc_if_settings->top, 0);
4572 if (rc != 0) {
4573 pr_err("error %d\n", rc);
4574 goto rw_error;
4575 }
4576 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_INGAIN__A, p_agc_if_settings->top, 0);
4577 if (rc != 0) {
4578 pr_err("error %d\n", rc);
4579 goto rw_error;
4580 } /* Gain fed from inner to outer AGC */
4581 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_INGAIN_TGT_MAX__A, ingain_tgt_max, 0);
4582 if (rc != 0) {
4583 pr_err("error %d\n", rc);
4584 goto rw_error;
4585 }
4586 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_IF_IACCU_HI_TGT_MIN__A, if_iaccu_hi_tgt_min, 0);
4587 if (rc != 0) {
4588 pr_err("error %d\n", rc);
4589 goto rw_error;
4590 }
4591 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_IF_IACCU_HI__A, 0, 0);
4592 if (rc != 0) {
4593 pr_err("error %d\n", rc);
4594 goto rw_error;
4595 } /* set to p_agc_settings->top before */
4596 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_IF_IACCU_LO__A, 0, 0);
4597 if (rc != 0) {
4598 pr_err("error %d\n", rc);
4599 goto rw_error;
4600 }
4601 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_RF_IACCU_HI__A, 0, 0);
4602 if (rc != 0) {
4603 pr_err("error %d\n", rc);
4604 goto rw_error;
4605 }
4606 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_RF_IACCU_LO__A, 0, 0);
4607 if (rc != 0) {
4608 pr_err("error %d\n", rc);
4609 goto rw_error;
4610 }
4611 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_RF_MAX__A, 32767, 0);
4612 if (rc != 0) {
4613 pr_err("error %d\n", rc);
4614 goto rw_error;
4615 }
4616 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_CLP_SUM_MAX__A, clp_sum_max, 0);
4617 if (rc != 0) {
4618 pr_err("error %d\n", rc);
4619 goto rw_error;
4620 }
4621 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_SNS_SUM_MAX__A, sns_sum_max, 0);
4622 if (rc != 0) {
4623 pr_err("error %d\n", rc);
4624 goto rw_error;
4625 }
4626 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_KI_INNERGAIN_MIN__A, ki_innergain_min, 0);
4627 if (rc != 0) {
4628 pr_err("error %d\n", rc);
4629 goto rw_error;
4630 }
4631 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_FAST_SNS_CTRL_DELAY__A, 50, 0);
4632 if (rc != 0) {
4633 pr_err("error %d\n", rc);
4634 goto rw_error;
4635 }
4636 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_KI_CYCLEN__A, 500, 0);
4637 if (rc != 0) {
4638 pr_err("error %d\n", rc);
4639 goto rw_error;
4640 }
4641 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_SNS_CYCLEN__A, 500, 0);
4642 if (rc != 0) {
4643 pr_err("error %d\n", rc);
4644 goto rw_error;
4645 }
4646 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_KI_MAXMINGAIN_TH__A, 20, 0);
4647 if (rc != 0) {
4648 pr_err("error %d\n", rc);
4649 goto rw_error;
4650 }
4651 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_KI_MIN__A, ki_min, 0);
4652 if (rc != 0) {
4653 pr_err("error %d\n", rc);
4654 goto rw_error;
4655 }
4656 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_KI_MAX__A, ki_max, 0);
4657 if (rc != 0) {
4658 pr_err("error %d\n", rc);
4659 goto rw_error;
4660 }
4661 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_KI_RED__A, 0, 0);
4662 if (rc != 0) {
4663 pr_err("error %d\n", rc);
4664 goto rw_error;
4665 }
4666 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_CLP_SUM_MIN__A, 8, 0);
4667 if (rc != 0) {
4668 pr_err("error %d\n", rc);
4669 goto rw_error;
4670 }
4671 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_CLP_CYCLEN__A, 500, 0);
4672 if (rc != 0) {
4673 pr_err("error %d\n", rc);
4674 goto rw_error;
4675 }
4676 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_CLP_DIR_TO__A, clp_dir_to, 0);
4677 if (rc != 0) {
4678 pr_err("error %d\n", rc);
4679 goto rw_error;
4680 }
4681 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_SNS_SUM_MIN__A, 8, 0);
4682 if (rc != 0) {
4683 pr_err("error %d\n", rc);
4684 goto rw_error;
4685 }
4686 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_SNS_DIR_TO__A, sns_dir_to, 0);
4687 if (rc != 0) {
4688 pr_err("error %d\n", rc);
4689 goto rw_error;
4690 }
4691 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A, 50, 0);
4692 if (rc != 0) {
4693 pr_err("error %d\n", rc);
4694 goto rw_error;
4695 }
4696 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_CLP_CTRL_MODE__A, clp_ctrl_mode, 0);
4697 if (rc != 0) {
4698 pr_err("error %d\n", rc);
4699 goto rw_error;
4700 }
4701
4702 agc_rf = 0x800 + p_agc_rf_settings->cut_off_current;
4703 if (common_attr->tuner_rf_agc_pol == true)
4704 agc_rf = 0x87ff - agc_rf;
4705
4706 agc_if = 0x800;
4707 if (common_attr->tuner_if_agc_pol == true)
4708 agc_rf = 0x87ff - agc_rf;
4709
4710 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_AGC_RF__A, agc_rf, 0);
4711 if (rc != 0) {
4712 pr_err("error %d\n", rc);
4713 goto rw_error;
4714 }
4715 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_AGC_IF__A, agc_if, 0);
4716 if (rc != 0) {
4717 pr_err("error %d\n", rc);
4718 goto rw_error;
4719 }
4720
4721 /* Set/restore Ki DGAIN factor */
4722 rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_AGC_KI__A, &data, 0);
4723 if (rc != 0) {
4724 pr_err("error %d\n", rc);
4725 goto rw_error;
4726 }
4727 data &= ~SCU_RAM_AGC_KI_DGAIN__M;
4728 data |= (agc_ki_dgain << SCU_RAM_AGC_KI_DGAIN__B);
4729 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_AGC_KI__A, data, 0);
4730 if (rc != 0) {
4731 pr_err("error %d\n", rc);
4732 goto rw_error;
4733 }
4734
4735 return 0;
4736rw_error:
4737 return -EIO;
4738}
4739
4740/**
4741* \fn int set_frequency ()
4742* \brief Set frequency shift.
4743* \param demod instance of demodulator.
4744* \param channel pointer to channel data.
4745* \param tuner_freq_offset residual frequency from tuner.
4746* \return int.
4747*/
4748static int
4749set_frequency(struct drx_demod_instance *demod,
4750 struct drx_channel *channel, s32 tuner_freq_offset)
4751{
4752 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
4753 struct drxj_data *ext_attr = demod->my_ext_attr;
4754 int rc;
4755 s32 sampling_frequency = 0;
4756 s32 frequency_shift = 0;
4757 s32 if_freq_actual = 0;
4758 s32 rf_freq_residual = -1 * tuner_freq_offset;
4759 s32 adc_freq = 0;
4760 s32 intermediate_freq = 0;
4761 u32 iqm_fs_rate_ofs = 0;
4762 bool adc_flip = true;
4763 bool select_pos_image = false;
4764 bool rf_mirror;
4765 bool tuner_mirror;
4766 bool image_to_select = true;
4767 s32 fm_frequency_shift = 0;
4768
4769 rf_mirror = (ext_attr->mirror == DRX_MIRROR_YES) ? true : false;
4770 tuner_mirror = demod->my_common_attr->mirror_freq_spect ? false : true;
4771 /*
4772 Program frequency shifter
4773 No need to account for mirroring on RF
4774 */
4775 switch (ext_attr->standard) {
4776 case DRX_STANDARD_ITU_A: /* fallthrough */
4777 case DRX_STANDARD_ITU_C: /* fallthrough */
4778 case DRX_STANDARD_PAL_SECAM_LP: /* fallthrough */
4779 case DRX_STANDARD_8VSB:
4780 select_pos_image = true;
4781 break;
4782 case DRX_STANDARD_FM:
4783 /* After IQM FS sound carrier must appear at 4 Mhz in spect.
4784 Sound carrier is already 3Mhz above centre frequency due
4785 to tuner setting so now add an extra shift of 1MHz... */
4786 fm_frequency_shift = 1000;
4787 case DRX_STANDARD_ITU_B: /* fallthrough */
4788 case DRX_STANDARD_NTSC: /* fallthrough */
4789 case DRX_STANDARD_PAL_SECAM_BG: /* fallthrough */
4790 case DRX_STANDARD_PAL_SECAM_DK: /* fallthrough */
4791 case DRX_STANDARD_PAL_SECAM_I: /* fallthrough */
4792 case DRX_STANDARD_PAL_SECAM_L:
4793 select_pos_image = false;
4794 break;
4795 default:
4796 return -EINVAL;
4797 }
4798 intermediate_freq = demod->my_common_attr->intermediate_freq;
4799 sampling_frequency = demod->my_common_attr->sys_clock_freq / 3;
4800 if (tuner_mirror)
4801 if_freq_actual = intermediate_freq + rf_freq_residual + fm_frequency_shift;
4802 else
4803 if_freq_actual = intermediate_freq - rf_freq_residual - fm_frequency_shift;
4804 if (if_freq_actual > sampling_frequency / 2) {
4805 /* adc mirrors */
4806 adc_freq = sampling_frequency - if_freq_actual;
4807 adc_flip = true;
4808 } else {
4809 /* adc doesn't mirror */
4810 adc_freq = if_freq_actual;
4811 adc_flip = false;
4812 }
4813
4814 frequency_shift = adc_freq;
4815 image_to_select =
4816 (bool) (rf_mirror ^ tuner_mirror ^ adc_flip ^ select_pos_image);
4817 iqm_fs_rate_ofs = frac28(frequency_shift, sampling_frequency);
4818
4819 if (image_to_select)
4820 iqm_fs_rate_ofs = ~iqm_fs_rate_ofs + 1;
4821
4822 /* Program frequency shifter with tuner offset compensation */
4823 /* frequency_shift += tuner_freq_offset; TODO */
4824 rc = drxdap_fasi_write_reg32(dev_addr, IQM_FS_RATE_OFS_LO__A, iqm_fs_rate_ofs, 0);
4825 if (rc != 0) {
4826 pr_err("error %d\n", rc);
4827 goto rw_error;
4828 }
4829 ext_attr->iqm_fs_rate_ofs = iqm_fs_rate_ofs;
4830 ext_attr->pos_image = (bool) (rf_mirror ^ tuner_mirror ^ select_pos_image);
4831
4832 return 0;
4833rw_error:
4834 return -EIO;
4835}
4836
4837/**
4838* \fn int get_acc_pkt_err()
4839* \brief Retrieve signal strength for VSB and QAM.
4840* \param demod Pointer to demod instance
4841* \param packet_err Pointer to packet error
4842* \return int.
4843* \retval 0 sig_strength contains valid data.
4844* \retval -EINVAL sig_strength is NULL.
4845* \retval -EIO Erroneous data, sig_strength contains invalid data.
4846*/
4847#ifdef DRXJ_SIGNAL_ACCUM_ERR
4848static int get_acc_pkt_err(struct drx_demod_instance *demod, u16 *packet_err)
4849{
4850 int rc;
4851 static u16 pkt_err;
4852 static u16 last_pkt_err;
4853 u16 data = 0;
4854 struct drxj_data *ext_attr = NULL;
4855 struct i2c_device_addr *dev_addr = NULL;
4856
4857 ext_attr = (struct drxj_data *) demod->my_ext_attr;
4858 dev_addr = demod->my_i2c_dev_addr;
4859
4860 rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A, &data, 0);
4861 if (rc != 0) {
4862 pr_err("error %d\n", rc);
4863 goto rw_error;
4864 }
4865 if (ext_attr->reset_pkt_err_acc) {
4866 last_pkt_err = data;
4867 pkt_err = 0;
4868 ext_attr->reset_pkt_err_acc = false;
4869 }
4870
4871 if (data < last_pkt_err) {
4872 pkt_err += 0xffff - last_pkt_err;
4873 pkt_err += data;
4874 } else {
4875 pkt_err += (data - last_pkt_err);
4876 }
4877 *packet_err = pkt_err;
4878 last_pkt_err = data;
4879
4880 return 0;
4881rw_error:
4882 return -EIO;
4883}
4884#endif
4885
4886
4887/*============================================================================*/
4888
4889/**
4890* \fn int set_agc_rf ()
4891* \brief Configure RF AGC
4892* \param demod instance of demodulator.
4893* \param agc_settings AGC configuration structure
4894* \return int.
4895*/
4896static int
4897set_agc_rf(struct drx_demod_instance *demod, struct drxj_cfg_agc *agc_settings, bool atomic)
4898{
4899 struct i2c_device_addr *dev_addr = NULL;
4900 struct drxj_data *ext_attr = NULL;
4901 struct drxj_cfg_agc *p_agc_settings = NULL;
4902 struct drx_common_attr *common_attr = NULL;
4903 int rc;
4904 drx_write_reg16func_t scu_wr16 = NULL;
4905 drx_read_reg16func_t scu_rr16 = NULL;
4906
4907 common_attr = (struct drx_common_attr *) demod->my_common_attr;
4908 dev_addr = demod->my_i2c_dev_addr;
4909 ext_attr = (struct drxj_data *) demod->my_ext_attr;
4910
4911 if (atomic) {
4912 scu_rr16 = drxj_dap_scu_atomic_read_reg16;
4913 scu_wr16 = drxj_dap_scu_atomic_write_reg16;
4914 } else {
4915 scu_rr16 = drxj_dap_read_reg16;
4916 scu_wr16 = drxj_dap_write_reg16;
4917 }
4918
4919 /* Configure AGC only if standard is currently active */
4920 if ((ext_attr->standard == agc_settings->standard) ||
4921 (DRXJ_ISQAMSTD(ext_attr->standard) &&
4922 DRXJ_ISQAMSTD(agc_settings->standard)) ||
4923 (DRXJ_ISATVSTD(ext_attr->standard) &&
4924 DRXJ_ISATVSTD(agc_settings->standard))) {
4925 u16 data = 0;
4926
4927 switch (agc_settings->ctrl_mode) {
4928 case DRX_AGC_CTRL_AUTO:
4929
4930 /* Enable RF AGC DAC */
4931 rc = drxj_dap_read_reg16(dev_addr, IQM_AF_STDBY__A, &data, 0);
4932 if (rc != 0) {
4933 pr_err("error %d\n", rc);
4934 goto rw_error;
4935 }
4936 data |= IQM_AF_STDBY_STDBY_TAGC_RF_A2_ACTIVE;
4937 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_STDBY__A, data, 0);
4938 if (rc != 0) {
4939 pr_err("error %d\n", rc);
4940 goto rw_error;
4941 }
4942
4943 /* Enable SCU RF AGC loop */
4944 rc = (*scu_rr16)(dev_addr, SCU_RAM_AGC_KI__A, &data, 0);
4945 if (rc != 0) {
4946 pr_err("error %d\n", rc);
4947 goto rw_error;
4948 }
4949 data &= ~SCU_RAM_AGC_KI_RF__M;
4950 if (ext_attr->standard == DRX_STANDARD_8VSB)
4951 data |= (2 << SCU_RAM_AGC_KI_RF__B);
4952 else if (DRXJ_ISQAMSTD(ext_attr->standard))
4953 data |= (5 << SCU_RAM_AGC_KI_RF__B);
4954 else
4955 data |= (4 << SCU_RAM_AGC_KI_RF__B);
4956
4957 if (common_attr->tuner_rf_agc_pol)
4958 data |= SCU_RAM_AGC_KI_INV_RF_POL__M;
4959 else
4960 data &= ~SCU_RAM_AGC_KI_INV_RF_POL__M;
4961 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_KI__A, data, 0);
4962 if (rc != 0) {
4963 pr_err("error %d\n", rc);
4964 goto rw_error;
4965 }
4966
4967 /* Set speed ( using complementary reduction value ) */
4968 rc = (*scu_rr16)(dev_addr, SCU_RAM_AGC_KI_RED__A, &data, 0);
4969 if (rc != 0) {
4970 pr_err("error %d\n", rc);
4971 goto rw_error;
4972 }
4973 data &= ~SCU_RAM_AGC_KI_RED_RAGC_RED__M;
4974 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_KI_RED__A, (~(agc_settings->speed << SCU_RAM_AGC_KI_RED_RAGC_RED__B) & SCU_RAM_AGC_KI_RED_RAGC_RED__M) | data, 0);
4975 if (rc != 0) {
4976 pr_err("error %d\n", rc);
4977 goto rw_error;
4978 }
4979
4980 if (agc_settings->standard == DRX_STANDARD_8VSB)
4981 p_agc_settings = &(ext_attr->vsb_if_agc_cfg);
4982 else if (DRXJ_ISQAMSTD(agc_settings->standard))
4983 p_agc_settings = &(ext_attr->qam_if_agc_cfg);
4984 else if (DRXJ_ISATVSTD(agc_settings->standard))
4985 p_agc_settings = &(ext_attr->atv_if_agc_cfg);
4986 else
4987 return -EINVAL;
4988
4989 /* Set TOP, only if IF-AGC is in AUTO mode */
4990 if (p_agc_settings->ctrl_mode == DRX_AGC_CTRL_AUTO) {
4991 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, agc_settings->top, 0);
4992 if (rc != 0) {
4993 pr_err("error %d\n", rc);
4994 goto rw_error;
4995 }
4996 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_IF_IACCU_HI_TGT__A, agc_settings->top, 0);
4997 if (rc != 0) {
4998 pr_err("error %d\n", rc);
4999 goto rw_error;
5000 }
5001 }
5002
5003 /* Cut-Off current */
5004 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_RF_IACCU_HI_CO__A, agc_settings->cut_off_current, 0);
5005 if (rc != 0) {
5006 pr_err("error %d\n", rc);
5007 goto rw_error;
5008 }
5009 break;
5010 case DRX_AGC_CTRL_USER:
5011
5012 /* Enable RF AGC DAC */
5013 rc = drxj_dap_read_reg16(dev_addr, IQM_AF_STDBY__A, &data, 0);
5014 if (rc != 0) {
5015 pr_err("error %d\n", rc);
5016 goto rw_error;
5017 }
5018 data |= IQM_AF_STDBY_STDBY_TAGC_RF_A2_ACTIVE;
5019 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_STDBY__A, data, 0);
5020 if (rc != 0) {
5021 pr_err("error %d\n", rc);
5022 goto rw_error;
5023 }
5024
5025 /* Disable SCU RF AGC loop */
5026 rc = (*scu_rr16)(dev_addr, SCU_RAM_AGC_KI__A, &data, 0);
5027 if (rc != 0) {
5028 pr_err("error %d\n", rc);
5029 goto rw_error;
5030 }
5031 data &= ~SCU_RAM_AGC_KI_RF__M;
5032 if (common_attr->tuner_rf_agc_pol)
5033 data |= SCU_RAM_AGC_KI_INV_RF_POL__M;
5034 else
5035 data &= ~SCU_RAM_AGC_KI_INV_RF_POL__M;
5036 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_KI__A, data, 0);
5037 if (rc != 0) {
5038 pr_err("error %d\n", rc);
5039 goto rw_error;
5040 }
5041
5042 /* Write value to output pin */
5043 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_RF_IACCU_HI__A, agc_settings->output_level, 0);
5044 if (rc != 0) {
5045 pr_err("error %d\n", rc);
5046 goto rw_error;
5047 }
5048 break;
5049 case DRX_AGC_CTRL_OFF:
5050
5051 /* Disable RF AGC DAC */
5052 rc = drxj_dap_read_reg16(dev_addr, IQM_AF_STDBY__A, &data, 0);
5053 if (rc != 0) {
5054 pr_err("error %d\n", rc);
5055 goto rw_error;
5056 }
5057 data &= (~IQM_AF_STDBY_STDBY_TAGC_RF_A2_ACTIVE);
5058 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_STDBY__A, data, 0);
5059 if (rc != 0) {
5060 pr_err("error %d\n", rc);
5061 goto rw_error;
5062 }
5063
5064 /* Disable SCU RF AGC loop */
5065 rc = (*scu_rr16)(dev_addr, SCU_RAM_AGC_KI__A, &data, 0);
5066 if (rc != 0) {
5067 pr_err("error %d\n", rc);
5068 goto rw_error;
5069 }
5070 data &= ~SCU_RAM_AGC_KI_RF__M;
5071 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_KI__A, data, 0);
5072 if (rc != 0) {
5073 pr_err("error %d\n", rc);
5074 goto rw_error;
5075 }
5076 break;
5077 default:
5078 return -EINVAL;
5079 } /* switch ( agcsettings->ctrl_mode ) */
5080 }
5081
5082 /* Store rf agc settings */
5083 switch (agc_settings->standard) {
5084 case DRX_STANDARD_8VSB:
5085 ext_attr->vsb_rf_agc_cfg = *agc_settings;
5086 break;
5087#ifndef DRXJ_VSB_ONLY
5088 case DRX_STANDARD_ITU_A:
5089 case DRX_STANDARD_ITU_B:
5090 case DRX_STANDARD_ITU_C:
5091 ext_attr->qam_rf_agc_cfg = *agc_settings;
5092 break;
5093#endif
5094 default:
5095 return -EIO;
5096 }
5097
5098 return 0;
5099rw_error:
5100 return -EIO;
5101}
5102
5103/**
5104* \fn int set_agc_if ()
5105* \brief Configure If AGC
5106* \param demod instance of demodulator.
5107* \param agc_settings AGC configuration structure
5108* \return int.
5109*/
5110static int
5111set_agc_if(struct drx_demod_instance *demod, struct drxj_cfg_agc *agc_settings, bool atomic)
5112{
5113 struct i2c_device_addr *dev_addr = NULL;
5114 struct drxj_data *ext_attr = NULL;
5115 struct drxj_cfg_agc *p_agc_settings = NULL;
5116 struct drx_common_attr *common_attr = NULL;
5117 drx_write_reg16func_t scu_wr16 = NULL;
5118 drx_read_reg16func_t scu_rr16 = NULL;
5119 int rc;
5120
5121 common_attr = (struct drx_common_attr *) demod->my_common_attr;
5122 dev_addr = demod->my_i2c_dev_addr;
5123 ext_attr = (struct drxj_data *) demod->my_ext_attr;
5124
5125 if (atomic) {
5126 scu_rr16 = drxj_dap_scu_atomic_read_reg16;
5127 scu_wr16 = drxj_dap_scu_atomic_write_reg16;
5128 } else {
5129 scu_rr16 = drxj_dap_read_reg16;
5130 scu_wr16 = drxj_dap_write_reg16;
5131 }
5132
5133 /* Configure AGC only if standard is currently active */
5134 if ((ext_attr->standard == agc_settings->standard) ||
5135 (DRXJ_ISQAMSTD(ext_attr->standard) &&
5136 DRXJ_ISQAMSTD(agc_settings->standard)) ||
5137 (DRXJ_ISATVSTD(ext_attr->standard) &&
5138 DRXJ_ISATVSTD(agc_settings->standard))) {
5139 u16 data = 0;
5140
5141 switch (agc_settings->ctrl_mode) {
5142 case DRX_AGC_CTRL_AUTO:
5143 /* Enable IF AGC DAC */
5144 rc = drxj_dap_read_reg16(dev_addr, IQM_AF_STDBY__A, &data, 0);
5145 if (rc != 0) {
5146 pr_err("error %d\n", rc);
5147 goto rw_error;
5148 }
5149 data |= IQM_AF_STDBY_STDBY_TAGC_IF_A2_ACTIVE;
5150 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_STDBY__A, data, 0);
5151 if (rc != 0) {
5152 pr_err("error %d\n", rc);
5153 goto rw_error;
5154 }
5155
5156 /* Enable SCU IF AGC loop */
5157 rc = (*scu_rr16)(dev_addr, SCU_RAM_AGC_KI__A, &data, 0);
5158 if (rc != 0) {
5159 pr_err("error %d\n", rc);
5160 goto rw_error;
5161 }
5162 data &= ~SCU_RAM_AGC_KI_IF_AGC_DISABLE__M;
5163 data &= ~SCU_RAM_AGC_KI_IF__M;
5164 if (ext_attr->standard == DRX_STANDARD_8VSB)
5165 data |= (3 << SCU_RAM_AGC_KI_IF__B);
5166 else if (DRXJ_ISQAMSTD(ext_attr->standard))
5167 data |= (6 << SCU_RAM_AGC_KI_IF__B);
5168 else
5169 data |= (5 << SCU_RAM_AGC_KI_IF__B);
5170
5171 if (common_attr->tuner_if_agc_pol)
5172 data |= SCU_RAM_AGC_KI_INV_IF_POL__M;
5173 else
5174 data &= ~SCU_RAM_AGC_KI_INV_IF_POL__M;
5175 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_KI__A, data, 0);
5176 if (rc != 0) {
5177 pr_err("error %d\n", rc);
5178 goto rw_error;
5179 }
5180
5181 /* Set speed (using complementary reduction value) */
5182 rc = (*scu_rr16)(dev_addr, SCU_RAM_AGC_KI_RED__A, &data, 0);
5183 if (rc != 0) {
5184 pr_err("error %d\n", rc);
5185 goto rw_error;
5186 }
5187 data &= ~SCU_RAM_AGC_KI_RED_IAGC_RED__M;
5188 rc = (*scu_wr16) (dev_addr, SCU_RAM_AGC_KI_RED__A, (~(agc_settings->speed << SCU_RAM_AGC_KI_RED_IAGC_RED__B) & SCU_RAM_AGC_KI_RED_IAGC_RED__M) | data, 0);
5189 if (rc != 0) {
5190 pr_err("error %d\n", rc);
5191 goto rw_error;
5192 }
5193
5194 if (agc_settings->standard == DRX_STANDARD_8VSB)
5195 p_agc_settings = &(ext_attr->vsb_rf_agc_cfg);
5196 else if (DRXJ_ISQAMSTD(agc_settings->standard))
5197 p_agc_settings = &(ext_attr->qam_rf_agc_cfg);
5198 else if (DRXJ_ISATVSTD(agc_settings->standard))
5199 p_agc_settings = &(ext_attr->atv_rf_agc_cfg);
5200 else
5201 return -EINVAL;
5202
5203 /* Restore TOP */
5204 if (p_agc_settings->ctrl_mode == DRX_AGC_CTRL_AUTO) {
5205 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, p_agc_settings->top, 0);
5206 if (rc != 0) {
5207 pr_err("error %d\n", rc);
5208 goto rw_error;
5209 }
5210 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_IF_IACCU_HI_TGT__A, p_agc_settings->top, 0);
5211 if (rc != 0) {
5212 pr_err("error %d\n", rc);
5213 goto rw_error;
5214 }
5215 } else {
5216 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, 0, 0);
5217 if (rc != 0) {
5218 pr_err("error %d\n", rc);
5219 goto rw_error;
5220 }
5221 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_IF_IACCU_HI_TGT__A, 0, 0);
5222 if (rc != 0) {
5223 pr_err("error %d\n", rc);
5224 goto rw_error;
5225 }
5226 }
5227 break;
5228
5229 case DRX_AGC_CTRL_USER:
5230
5231 /* Enable IF AGC DAC */
5232 rc = drxj_dap_read_reg16(dev_addr, IQM_AF_STDBY__A, &data, 0);
5233 if (rc != 0) {
5234 pr_err("error %d\n", rc);
5235 goto rw_error;
5236 }
5237 data |= IQM_AF_STDBY_STDBY_TAGC_IF_A2_ACTIVE;
5238 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_STDBY__A, data, 0);
5239 if (rc != 0) {
5240 pr_err("error %d\n", rc);
5241 goto rw_error;
5242 }
5243
5244 /* Disable SCU IF AGC loop */
5245 rc = (*scu_rr16)(dev_addr, SCU_RAM_AGC_KI__A, &data, 0);
5246 if (rc != 0) {
5247 pr_err("error %d\n", rc);
5248 goto rw_error;
5249 }
5250 data &= ~SCU_RAM_AGC_KI_IF_AGC_DISABLE__M;
5251 data |= SCU_RAM_AGC_KI_IF_AGC_DISABLE__M;
5252 if (common_attr->tuner_if_agc_pol)
5253 data |= SCU_RAM_AGC_KI_INV_IF_POL__M;
5254 else
5255 data &= ~SCU_RAM_AGC_KI_INV_IF_POL__M;
5256 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_KI__A, data, 0);
5257 if (rc != 0) {
5258 pr_err("error %d\n", rc);
5259 goto rw_error;
5260 }
5261
5262 /* Write value to output pin */
5263 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A, agc_settings->output_level, 0);
5264 if (rc != 0) {
5265 pr_err("error %d\n", rc);
5266 goto rw_error;
5267 }
5268 break;
5269
5270 case DRX_AGC_CTRL_OFF:
5271
5272 /* Disable If AGC DAC */
5273 rc = drxj_dap_read_reg16(dev_addr, IQM_AF_STDBY__A, &data, 0);
5274 if (rc != 0) {
5275 pr_err("error %d\n", rc);
5276 goto rw_error;
5277 }
5278 data &= (~IQM_AF_STDBY_STDBY_TAGC_IF_A2_ACTIVE);
5279 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_STDBY__A, data, 0);
5280 if (rc != 0) {
5281 pr_err("error %d\n", rc);
5282 goto rw_error;
5283 }
5284
5285 /* Disable SCU IF AGC loop */
5286 rc = (*scu_rr16)(dev_addr, SCU_RAM_AGC_KI__A, &data, 0);
5287 if (rc != 0) {
5288 pr_err("error %d\n", rc);
5289 goto rw_error;
5290 }
5291 data &= ~SCU_RAM_AGC_KI_IF_AGC_DISABLE__M;
5292 data |= SCU_RAM_AGC_KI_IF_AGC_DISABLE__M;
5293 rc = (*scu_wr16)(dev_addr, SCU_RAM_AGC_KI__A, data, 0);
5294 if (rc != 0) {
5295 pr_err("error %d\n", rc);
5296 goto rw_error;
5297 }
5298 break;
5299 default:
5300 return -EINVAL;
5301 } /* switch ( agcsettings->ctrl_mode ) */
5302
5303 /* always set the top to support configurations without if-loop */
5304 rc = (*scu_wr16) (dev_addr, SCU_RAM_AGC_INGAIN_TGT_MIN__A, agc_settings->top, 0);
5305 if (rc != 0) {
5306 pr_err("error %d\n", rc);
5307 goto rw_error;
5308 }
5309 }
5310
5311 /* Store if agc settings */
5312 switch (agc_settings->standard) {
5313 case DRX_STANDARD_8VSB:
5314 ext_attr->vsb_if_agc_cfg = *agc_settings;
5315 break;
5316#ifndef DRXJ_VSB_ONLY
5317 case DRX_STANDARD_ITU_A:
5318 case DRX_STANDARD_ITU_B:
5319 case DRX_STANDARD_ITU_C:
5320 ext_attr->qam_if_agc_cfg = *agc_settings;
5321 break;
5322#endif
5323 default:
5324 return -EIO;
5325 }
5326
5327 return 0;
5328rw_error:
5329 return -EIO;
5330}
5331
5332/**
5333* \fn int set_iqm_af ()
5334* \brief Configure IQM AF registers
5335* \param demod instance of demodulator.
5336* \param active
5337* \return int.
5338*/
5339static int set_iqm_af(struct drx_demod_instance *demod, bool active)
5340{
5341 u16 data = 0;
5342 struct i2c_device_addr *dev_addr = NULL;
5343 int rc;
5344
5345 dev_addr = demod->my_i2c_dev_addr;
5346
5347 /* Configure IQM */
5348 rc = drxj_dap_read_reg16(dev_addr, IQM_AF_STDBY__A, &data, 0);
5349 if (rc != 0) {
5350 pr_err("error %d\n", rc);
5351 goto rw_error;
5352 }
5353 if (!active)
5354 data &= ((~IQM_AF_STDBY_STDBY_ADC_A2_ACTIVE) & (~IQM_AF_STDBY_STDBY_AMP_A2_ACTIVE) & (~IQM_AF_STDBY_STDBY_PD_A2_ACTIVE) & (~IQM_AF_STDBY_STDBY_TAGC_IF_A2_ACTIVE) & (~IQM_AF_STDBY_STDBY_TAGC_RF_A2_ACTIVE));
5355 else
5356 data |= (IQM_AF_STDBY_STDBY_ADC_A2_ACTIVE | IQM_AF_STDBY_STDBY_AMP_A2_ACTIVE | IQM_AF_STDBY_STDBY_PD_A2_ACTIVE | IQM_AF_STDBY_STDBY_TAGC_IF_A2_ACTIVE | IQM_AF_STDBY_STDBY_TAGC_RF_A2_ACTIVE);
5357 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_STDBY__A, data, 0);
5358 if (rc != 0) {
5359 pr_err("error %d\n", rc);
5360 goto rw_error;
5361 }
5362
5363 return 0;
5364rw_error:
5365 return -EIO;
5366}
5367
5368/*============================================================================*/
5369/*== END 8VSB & QAM COMMON DATAPATH FUNCTIONS ==*/
5370/*============================================================================*/
5371
5372/*============================================================================*/
5373/*============================================================================*/
5374/*== 8VSB DATAPATH FUNCTIONS ==*/
5375/*============================================================================*/
5376/*============================================================================*/
5377
5378/**
5379* \fn int power_down_vsb ()
5380* \brief Powr down QAM related blocks.
5381* \param demod instance of demodulator.
5382* \param channel pointer to channel data.
5383* \return int.
5384*/
5385static int power_down_vsb(struct drx_demod_instance *demod, bool primary)
5386{
5387 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
5388 struct drxjscu_cmd cmd_scu = { /* command */ 0,
5389 /* parameter_len */ 0,
5390 /* result_len */ 0,
5391 /* *parameter */ NULL,
5392 /* *result */ NULL
5393 };
5394 struct drx_cfg_mpeg_output cfg_mpeg_output;
5395 int rc;
5396 u16 cmd_result = 0;
5397
5398 /*
5399 STOP demodulator
5400 reset of FEC and VSB HW
5401 */
5402 cmd_scu.command = SCU_RAM_COMMAND_STANDARD_VSB |
5403 SCU_RAM_COMMAND_CMD_DEMOD_STOP;
5404 cmd_scu.parameter_len = 0;
5405 cmd_scu.result_len = 1;
5406 cmd_scu.parameter = NULL;
5407 cmd_scu.result = &cmd_result;
5408 rc = scu_command(dev_addr, &cmd_scu);
5409 if (rc != 0) {
5410 pr_err("error %d\n", rc);
5411 goto rw_error;
5412 }
5413
5414 /* stop all comm_exec */
5415 rc = drxj_dap_write_reg16(dev_addr, FEC_COMM_EXEC__A, FEC_COMM_EXEC_STOP, 0);
5416 if (rc != 0) {
5417 pr_err("error %d\n", rc);
5418 goto rw_error;
5419 }
5420 rc = drxj_dap_write_reg16(dev_addr, VSB_COMM_EXEC__A, VSB_COMM_EXEC_STOP, 0);
5421 if (rc != 0) {
5422 pr_err("error %d\n", rc);
5423 goto rw_error;
5424 }
5425 if (primary) {
5426 rc = drxj_dap_write_reg16(dev_addr, IQM_COMM_EXEC__A, IQM_COMM_EXEC_STOP, 0);
5427 if (rc != 0) {
5428 pr_err("error %d\n", rc);
5429 goto rw_error;
5430 }
5431 rc = set_iqm_af(demod, false);
5432 if (rc != 0) {
5433 pr_err("error %d\n", rc);
5434 goto rw_error;
5435 }
5436 } else {
5437 rc = drxj_dap_write_reg16(dev_addr, IQM_FS_COMM_EXEC__A, IQM_FS_COMM_EXEC_STOP, 0);
5438 if (rc != 0) {
5439 pr_err("error %d\n", rc);
5440 goto rw_error;
5441 }
5442 rc = drxj_dap_write_reg16(dev_addr, IQM_FD_COMM_EXEC__A, IQM_FD_COMM_EXEC_STOP, 0);
5443 if (rc != 0) {
5444 pr_err("error %d\n", rc);
5445 goto rw_error;
5446 }
5447 rc = drxj_dap_write_reg16(dev_addr, IQM_RC_COMM_EXEC__A, IQM_RC_COMM_EXEC_STOP, 0);
5448 if (rc != 0) {
5449 pr_err("error %d\n", rc);
5450 goto rw_error;
5451 }
5452 rc = drxj_dap_write_reg16(dev_addr, IQM_RT_COMM_EXEC__A, IQM_RT_COMM_EXEC_STOP, 0);
5453 if (rc != 0) {
5454 pr_err("error %d\n", rc);
5455 goto rw_error;
5456 }
5457 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_COMM_EXEC__A, IQM_CF_COMM_EXEC_STOP, 0);
5458 if (rc != 0) {
5459 pr_err("error %d\n", rc);
5460 goto rw_error;
5461 }
5462 }
5463
5464 cfg_mpeg_output.enable_mpeg_output = false;
5465 rc = ctrl_set_cfg_mpeg_output(demod, &cfg_mpeg_output);
5466 if (rc != 0) {
5467 pr_err("error %d\n", rc);
5468 goto rw_error;
5469 }
5470
5471 return 0;
5472rw_error:
5473 return -EIO;
5474}
5475
5476/**
5477* \fn int set_vsb_leak_n_gain ()
5478* \brief Set ATSC demod.
5479* \param demod instance of demodulator.
5480* \return int.
5481*/
5482static int set_vsb_leak_n_gain(struct drx_demod_instance *demod)
5483{
5484 struct i2c_device_addr *dev_addr = NULL;
5485 int rc;
5486
5487 const u8 vsb_ffe_leak_gain_ram0[] = {
5488 DRXJ_16TO8(0x8), /* FFETRAINLKRATIO1 */
5489 DRXJ_16TO8(0x8), /* FFETRAINLKRATIO2 */
5490 DRXJ_16TO8(0x8), /* FFETRAINLKRATIO3 */
5491 DRXJ_16TO8(0xf), /* FFETRAINLKRATIO4 */
5492 DRXJ_16TO8(0xf), /* FFETRAINLKRATIO5 */
5493 DRXJ_16TO8(0xf), /* FFETRAINLKRATIO6 */
5494 DRXJ_16TO8(0xf), /* FFETRAINLKRATIO7 */
5495 DRXJ_16TO8(0xf), /* FFETRAINLKRATIO8 */
5496 DRXJ_16TO8(0xf), /* FFETRAINLKRATIO9 */
5497 DRXJ_16TO8(0x8), /* FFETRAINLKRATIO10 */
5498 DRXJ_16TO8(0x8), /* FFETRAINLKRATIO11 */
5499 DRXJ_16TO8(0x8), /* FFETRAINLKRATIO12 */
5500 DRXJ_16TO8(0x10), /* FFERCA1TRAINLKRATIO1 */
5501 DRXJ_16TO8(0x10), /* FFERCA1TRAINLKRATIO2 */
5502 DRXJ_16TO8(0x10), /* FFERCA1TRAINLKRATIO3 */
5503 DRXJ_16TO8(0x20), /* FFERCA1TRAINLKRATIO4 */
5504 DRXJ_16TO8(0x20), /* FFERCA1TRAINLKRATIO5 */
5505 DRXJ_16TO8(0x20), /* FFERCA1TRAINLKRATIO6 */
5506 DRXJ_16TO8(0x20), /* FFERCA1TRAINLKRATIO7 */
5507 DRXJ_16TO8(0x20), /* FFERCA1TRAINLKRATIO8 */
5508 DRXJ_16TO8(0x20), /* FFERCA1TRAINLKRATIO9 */
5509 DRXJ_16TO8(0x10), /* FFERCA1TRAINLKRATIO10 */
5510 DRXJ_16TO8(0x10), /* FFERCA1TRAINLKRATIO11 */
5511 DRXJ_16TO8(0x10), /* FFERCA1TRAINLKRATIO12 */
5512 DRXJ_16TO8(0x10), /* FFERCA1DATALKRATIO1 */
5513 DRXJ_16TO8(0x10), /* FFERCA1DATALKRATIO2 */
5514 DRXJ_16TO8(0x10), /* FFERCA1DATALKRATIO3 */
5515 DRXJ_16TO8(0x20), /* FFERCA1DATALKRATIO4 */
5516 DRXJ_16TO8(0x20), /* FFERCA1DATALKRATIO5 */
5517 DRXJ_16TO8(0x20), /* FFERCA1DATALKRATIO6 */
5518 DRXJ_16TO8(0x20), /* FFERCA1DATALKRATIO7 */
5519 DRXJ_16TO8(0x20), /* FFERCA1DATALKRATIO8 */
5520 DRXJ_16TO8(0x20), /* FFERCA1DATALKRATIO9 */
5521 DRXJ_16TO8(0x10), /* FFERCA1DATALKRATIO10 */
5522 DRXJ_16TO8(0x10), /* FFERCA1DATALKRATIO11 */
5523 DRXJ_16TO8(0x10), /* FFERCA1DATALKRATIO12 */
5524 DRXJ_16TO8(0x10), /* FFERCA2TRAINLKRATIO1 */
5525 DRXJ_16TO8(0x10), /* FFERCA2TRAINLKRATIO2 */
5526 DRXJ_16TO8(0x10), /* FFERCA2TRAINLKRATIO3 */
5527 DRXJ_16TO8(0x20), /* FFERCA2TRAINLKRATIO4 */
5528 DRXJ_16TO8(0x20), /* FFERCA2TRAINLKRATIO5 */
5529 DRXJ_16TO8(0x20), /* FFERCA2TRAINLKRATIO6 */
5530 DRXJ_16TO8(0x20), /* FFERCA2TRAINLKRATIO7 */
5531 DRXJ_16TO8(0x20), /* FFERCA2TRAINLKRATIO8 */
5532 DRXJ_16TO8(0x20), /* FFERCA2TRAINLKRATIO9 */
5533 DRXJ_16TO8(0x10), /* FFERCA2TRAINLKRATIO10 */
5534 DRXJ_16TO8(0x10), /* FFERCA2TRAINLKRATIO11 */
5535 DRXJ_16TO8(0x10), /* FFERCA2TRAINLKRATIO12 */
5536 DRXJ_16TO8(0x10), /* FFERCA2DATALKRATIO1 */
5537 DRXJ_16TO8(0x10), /* FFERCA2DATALKRATIO2 */
5538 DRXJ_16TO8(0x10), /* FFERCA2DATALKRATIO3 */
5539 DRXJ_16TO8(0x20), /* FFERCA2DATALKRATIO4 */
5540 DRXJ_16TO8(0x20), /* FFERCA2DATALKRATIO5 */
5541 DRXJ_16TO8(0x20), /* FFERCA2DATALKRATIO6 */
5542 DRXJ_16TO8(0x20), /* FFERCA2DATALKRATIO7 */
5543 DRXJ_16TO8(0x20), /* FFERCA2DATALKRATIO8 */
5544 DRXJ_16TO8(0x20), /* FFERCA2DATALKRATIO9 */
5545 DRXJ_16TO8(0x10), /* FFERCA2DATALKRATIO10 */
5546 DRXJ_16TO8(0x10), /* FFERCA2DATALKRATIO11 */
5547 DRXJ_16TO8(0x10), /* FFERCA2DATALKRATIO12 */
5548 DRXJ_16TO8(0x07), /* FFEDDM1TRAINLKRATIO1 */
5549 DRXJ_16TO8(0x07), /* FFEDDM1TRAINLKRATIO2 */
5550 DRXJ_16TO8(0x07), /* FFEDDM1TRAINLKRATIO3 */
5551 DRXJ_16TO8(0x0e), /* FFEDDM1TRAINLKRATIO4 */
5552 DRXJ_16TO8(0x0e), /* FFEDDM1TRAINLKRATIO5 */
5553 DRXJ_16TO8(0x0e), /* FFEDDM1TRAINLKRATIO6 */
5554 DRXJ_16TO8(0x0e), /* FFEDDM1TRAINLKRATIO7 */
5555 DRXJ_16TO8(0x0e), /* FFEDDM1TRAINLKRATIO8 */
5556 DRXJ_16TO8(0x0e), /* FFEDDM1TRAINLKRATIO9 */
5557 DRXJ_16TO8(0x07), /* FFEDDM1TRAINLKRATIO10 */
5558 DRXJ_16TO8(0x07), /* FFEDDM1TRAINLKRATIO11 */
5559 DRXJ_16TO8(0x07), /* FFEDDM1TRAINLKRATIO12 */
5560 DRXJ_16TO8(0x07), /* FFEDDM1DATALKRATIO1 */
5561 DRXJ_16TO8(0x07), /* FFEDDM1DATALKRATIO2 */
5562 DRXJ_16TO8(0x07), /* FFEDDM1DATALKRATIO3 */
5563 DRXJ_16TO8(0x0e), /* FFEDDM1DATALKRATIO4 */
5564 DRXJ_16TO8(0x0e), /* FFEDDM1DATALKRATIO5 */
5565 DRXJ_16TO8(0x0e), /* FFEDDM1DATALKRATIO6 */
5566 DRXJ_16TO8(0x0e), /* FFEDDM1DATALKRATIO7 */
5567 DRXJ_16TO8(0x0e), /* FFEDDM1DATALKRATIO8 */
5568 DRXJ_16TO8(0x0e), /* FFEDDM1DATALKRATIO9 */
5569 DRXJ_16TO8(0x07), /* FFEDDM1DATALKRATIO10 */
5570 DRXJ_16TO8(0x07), /* FFEDDM1DATALKRATIO11 */
5571 DRXJ_16TO8(0x07), /* FFEDDM1DATALKRATIO12 */
5572 DRXJ_16TO8(0x06), /* FFEDDM2TRAINLKRATIO1 */
5573 DRXJ_16TO8(0x06), /* FFEDDM2TRAINLKRATIO2 */
5574 DRXJ_16TO8(0x06), /* FFEDDM2TRAINLKRATIO3 */
5575 DRXJ_16TO8(0x0c), /* FFEDDM2TRAINLKRATIO4 */
5576 DRXJ_16TO8(0x0c), /* FFEDDM2TRAINLKRATIO5 */
5577 DRXJ_16TO8(0x0c), /* FFEDDM2TRAINLKRATIO6 */
5578 DRXJ_16TO8(0x0c), /* FFEDDM2TRAINLKRATIO7 */
5579 DRXJ_16TO8(0x0c), /* FFEDDM2TRAINLKRATIO8 */
5580 DRXJ_16TO8(0x0c), /* FFEDDM2TRAINLKRATIO9 */
5581 DRXJ_16TO8(0x06), /* FFEDDM2TRAINLKRATIO10 */
5582 DRXJ_16TO8(0x06), /* FFEDDM2TRAINLKRATIO11 */
5583 DRXJ_16TO8(0x06), /* FFEDDM2TRAINLKRATIO12 */
5584 DRXJ_16TO8(0x06), /* FFEDDM2DATALKRATIO1 */
5585 DRXJ_16TO8(0x06), /* FFEDDM2DATALKRATIO2 */
5586 DRXJ_16TO8(0x06), /* FFEDDM2DATALKRATIO3 */
5587 DRXJ_16TO8(0x0c), /* FFEDDM2DATALKRATIO4 */
5588 DRXJ_16TO8(0x0c), /* FFEDDM2DATALKRATIO5 */
5589 DRXJ_16TO8(0x0c), /* FFEDDM2DATALKRATIO6 */
5590 DRXJ_16TO8(0x0c), /* FFEDDM2DATALKRATIO7 */
5591 DRXJ_16TO8(0x0c), /* FFEDDM2DATALKRATIO8 */
5592 DRXJ_16TO8(0x0c), /* FFEDDM2DATALKRATIO9 */
5593 DRXJ_16TO8(0x06), /* FFEDDM2DATALKRATIO10 */
5594 DRXJ_16TO8(0x06), /* FFEDDM2DATALKRATIO11 */
5595 DRXJ_16TO8(0x06), /* FFEDDM2DATALKRATIO12 */
5596 DRXJ_16TO8(0x2020), /* FIRTRAINGAIN1 */
5597 DRXJ_16TO8(0x2020), /* FIRTRAINGAIN2 */
5598 DRXJ_16TO8(0x2020), /* FIRTRAINGAIN3 */
5599 DRXJ_16TO8(0x4040), /* FIRTRAINGAIN4 */
5600 DRXJ_16TO8(0x4040), /* FIRTRAINGAIN5 */
5601 DRXJ_16TO8(0x4040), /* FIRTRAINGAIN6 */
5602 DRXJ_16TO8(0x4040), /* FIRTRAINGAIN7 */
5603 DRXJ_16TO8(0x4040), /* FIRTRAINGAIN8 */
5604 DRXJ_16TO8(0x4040), /* FIRTRAINGAIN9 */
5605 DRXJ_16TO8(0x2020), /* FIRTRAINGAIN10 */
5606 DRXJ_16TO8(0x2020), /* FIRTRAINGAIN11 */
5607 DRXJ_16TO8(0x2020), /* FIRTRAINGAIN12 */
5608 DRXJ_16TO8(0x0808), /* FIRRCA1GAIN1 */
5609 DRXJ_16TO8(0x0808), /* FIRRCA1GAIN2 */
5610 DRXJ_16TO8(0x0808), /* FIRRCA1GAIN3 */
5611 DRXJ_16TO8(0x1010), /* FIRRCA1GAIN4 */
5612 DRXJ_16TO8(0x1010), /* FIRRCA1GAIN5 */
5613 DRXJ_16TO8(0x1010), /* FIRRCA1GAIN6 */
5614 DRXJ_16TO8(0x1010), /* FIRRCA1GAIN7 */
5615 DRXJ_16TO8(0x1010) /* FIRRCA1GAIN8 */
5616 };
5617
5618 const u8 vsb_ffe_leak_gain_ram1[] = {
5619 DRXJ_16TO8(0x1010), /* FIRRCA1GAIN9 */
5620 DRXJ_16TO8(0x0808), /* FIRRCA1GAIN10 */
5621 DRXJ_16TO8(0x0808), /* FIRRCA1GAIN11 */
5622 DRXJ_16TO8(0x0808), /* FIRRCA1GAIN12 */
5623 DRXJ_16TO8(0x0808), /* FIRRCA2GAIN1 */
5624 DRXJ_16TO8(0x0808), /* FIRRCA2GAIN2 */
5625 DRXJ_16TO8(0x0808), /* FIRRCA2GAIN3 */
5626 DRXJ_16TO8(0x1010), /* FIRRCA2GAIN4 */
5627 DRXJ_16TO8(0x1010), /* FIRRCA2GAIN5 */
5628 DRXJ_16TO8(0x1010), /* FIRRCA2GAIN6 */
5629 DRXJ_16TO8(0x1010), /* FIRRCA2GAIN7 */
5630 DRXJ_16TO8(0x1010), /* FIRRCA2GAIN8 */
5631 DRXJ_16TO8(0x1010), /* FIRRCA2GAIN9 */
5632 DRXJ_16TO8(0x0808), /* FIRRCA2GAIN10 */
5633 DRXJ_16TO8(0x0808), /* FIRRCA2GAIN11 */
5634 DRXJ_16TO8(0x0808), /* FIRRCA2GAIN12 */
5635 DRXJ_16TO8(0x0303), /* FIRDDM1GAIN1 */
5636 DRXJ_16TO8(0x0303), /* FIRDDM1GAIN2 */
5637 DRXJ_16TO8(0x0303), /* FIRDDM1GAIN3 */
5638 DRXJ_16TO8(0x0606), /* FIRDDM1GAIN4 */
5639 DRXJ_16TO8(0x0606), /* FIRDDM1GAIN5 */
5640 DRXJ_16TO8(0x0606), /* FIRDDM1GAIN6 */
5641 DRXJ_16TO8(0x0606), /* FIRDDM1GAIN7 */
5642 DRXJ_16TO8(0x0606), /* FIRDDM1GAIN8 */
5643 DRXJ_16TO8(0x0606), /* FIRDDM1GAIN9 */
5644 DRXJ_16TO8(0x0303), /* FIRDDM1GAIN10 */
5645 DRXJ_16TO8(0x0303), /* FIRDDM1GAIN11 */
5646 DRXJ_16TO8(0x0303), /* FIRDDM1GAIN12 */
5647 DRXJ_16TO8(0x0303), /* FIRDDM2GAIN1 */
5648 DRXJ_16TO8(0x0303), /* FIRDDM2GAIN2 */
5649 DRXJ_16TO8(0x0303), /* FIRDDM2GAIN3 */
5650 DRXJ_16TO8(0x0505), /* FIRDDM2GAIN4 */
5651 DRXJ_16TO8(0x0505), /* FIRDDM2GAIN5 */
5652 DRXJ_16TO8(0x0505), /* FIRDDM2GAIN6 */
5653 DRXJ_16TO8(0x0505), /* FIRDDM2GAIN7 */
5654 DRXJ_16TO8(0x0505), /* FIRDDM2GAIN8 */
5655 DRXJ_16TO8(0x0505), /* FIRDDM2GAIN9 */
5656 DRXJ_16TO8(0x0303), /* FIRDDM2GAIN10 */
5657 DRXJ_16TO8(0x0303), /* FIRDDM2GAIN11 */
5658 DRXJ_16TO8(0x0303), /* FIRDDM2GAIN12 */
5659 DRXJ_16TO8(0x001f), /* DFETRAINLKRATIO */
5660 DRXJ_16TO8(0x01ff), /* DFERCA1TRAINLKRATIO */
5661 DRXJ_16TO8(0x01ff), /* DFERCA1DATALKRATIO */
5662 DRXJ_16TO8(0x004f), /* DFERCA2TRAINLKRATIO */
5663 DRXJ_16TO8(0x004f), /* DFERCA2DATALKRATIO */
5664 DRXJ_16TO8(0x01ff), /* DFEDDM1TRAINLKRATIO */
5665 DRXJ_16TO8(0x01ff), /* DFEDDM1DATALKRATIO */
5666 DRXJ_16TO8(0x0352), /* DFEDDM2TRAINLKRATIO */
5667 DRXJ_16TO8(0x0352), /* DFEDDM2DATALKRATIO */
5668 DRXJ_16TO8(0x0000), /* DFETRAINGAIN */
5669 DRXJ_16TO8(0x2020), /* DFERCA1GAIN */
5670 DRXJ_16TO8(0x1010), /* DFERCA2GAIN */
5671 DRXJ_16TO8(0x1818), /* DFEDDM1GAIN */
5672 DRXJ_16TO8(0x1212) /* DFEDDM2GAIN */
5673 };
5674
5675 dev_addr = demod->my_i2c_dev_addr;
5676 rc = drxdap_fasi_write_block(dev_addr, VSB_SYSCTRL_RAM0_FFETRAINLKRATIO1__A, sizeof(vsb_ffe_leak_gain_ram0), ((u8 *)vsb_ffe_leak_gain_ram0), 0);
5677 if (rc != 0) {
5678 pr_err("error %d\n", rc);
5679 goto rw_error;
5680 }
5681 rc = drxdap_fasi_write_block(dev_addr, VSB_SYSCTRL_RAM1_FIRRCA1GAIN9__A, sizeof(vsb_ffe_leak_gain_ram1), ((u8 *)vsb_ffe_leak_gain_ram1), 0);
5682 if (rc != 0) {
5683 pr_err("error %d\n", rc);
5684 goto rw_error;
5685 }
5686
5687 return 0;
5688rw_error:
5689 return -EIO;
5690}
5691
5692/**
5693* \fn int set_vsb()
5694* \brief Set 8VSB demod.
5695* \param demod instance of demodulator.
5696* \return int.
5697*
5698*/
5699static int set_vsb(struct drx_demod_instance *demod)
5700{
5701 struct i2c_device_addr *dev_addr = NULL;
5702 int rc;
5703 struct drx_common_attr *common_attr = NULL;
5704 struct drxjscu_cmd cmd_scu;
5705 struct drxj_data *ext_attr = NULL;
5706 u16 cmd_result = 0;
5707 u16 cmd_param = 0;
5708 const u8 vsb_taps_re[] = {
5709 DRXJ_16TO8(-2), /* re0 */
5710 DRXJ_16TO8(4), /* re1 */
5711 DRXJ_16TO8(1), /* re2 */
5712 DRXJ_16TO8(-4), /* re3 */
5713 DRXJ_16TO8(1), /* re4 */
5714 DRXJ_16TO8(4), /* re5 */
5715 DRXJ_16TO8(-3), /* re6 */
5716 DRXJ_16TO8(-3), /* re7 */
5717 DRXJ_16TO8(6), /* re8 */
5718 DRXJ_16TO8(1), /* re9 */
5719 DRXJ_16TO8(-9), /* re10 */
5720 DRXJ_16TO8(3), /* re11 */
5721 DRXJ_16TO8(12), /* re12 */
5722 DRXJ_16TO8(-9), /* re13 */
5723 DRXJ_16TO8(-15), /* re14 */
5724 DRXJ_16TO8(17), /* re15 */
5725 DRXJ_16TO8(19), /* re16 */
5726 DRXJ_16TO8(-29), /* re17 */
5727 DRXJ_16TO8(-22), /* re18 */
5728 DRXJ_16TO8(45), /* re19 */
5729 DRXJ_16TO8(25), /* re20 */
5730 DRXJ_16TO8(-70), /* re21 */
5731 DRXJ_16TO8(-28), /* re22 */
5732 DRXJ_16TO8(111), /* re23 */
5733 DRXJ_16TO8(30), /* re24 */
5734 DRXJ_16TO8(-201), /* re25 */
5735 DRXJ_16TO8(-31), /* re26 */
5736 DRXJ_16TO8(629) /* re27 */
5737 };
5738
5739 dev_addr = demod->my_i2c_dev_addr;
5740 common_attr = (struct drx_common_attr *) demod->my_common_attr;
5741 ext_attr = (struct drxj_data *) demod->my_ext_attr;
5742
5743 /* stop all comm_exec */
5744 rc = drxj_dap_write_reg16(dev_addr, FEC_COMM_EXEC__A, FEC_COMM_EXEC_STOP, 0);
5745 if (rc != 0) {
5746 pr_err("error %d\n", rc);
5747 goto rw_error;
5748 }
5749 rc = drxj_dap_write_reg16(dev_addr, VSB_COMM_EXEC__A, VSB_COMM_EXEC_STOP, 0);
5750 if (rc != 0) {
5751 pr_err("error %d\n", rc);
5752 goto rw_error;
5753 }
5754 rc = drxj_dap_write_reg16(dev_addr, IQM_FS_COMM_EXEC__A, IQM_FS_COMM_EXEC_STOP, 0);
5755 if (rc != 0) {
5756 pr_err("error %d\n", rc);
5757 goto rw_error;
5758 }
5759 rc = drxj_dap_write_reg16(dev_addr, IQM_FD_COMM_EXEC__A, IQM_FD_COMM_EXEC_STOP, 0);
5760 if (rc != 0) {
5761 pr_err("error %d\n", rc);
5762 goto rw_error;
5763 }
5764 rc = drxj_dap_write_reg16(dev_addr, IQM_RC_COMM_EXEC__A, IQM_RC_COMM_EXEC_STOP, 0);
5765 if (rc != 0) {
5766 pr_err("error %d\n", rc);
5767 goto rw_error;
5768 }
5769 rc = drxj_dap_write_reg16(dev_addr, IQM_RT_COMM_EXEC__A, IQM_RT_COMM_EXEC_STOP, 0);
5770 if (rc != 0) {
5771 pr_err("error %d\n", rc);
5772 goto rw_error;
5773 }
5774 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_COMM_EXEC__A, IQM_CF_COMM_EXEC_STOP, 0);
5775 if (rc != 0) {
5776 pr_err("error %d\n", rc);
5777 goto rw_error;
5778 }
5779
5780 /* reset demodulator */
5781 cmd_scu.command = SCU_RAM_COMMAND_STANDARD_VSB
5782 | SCU_RAM_COMMAND_CMD_DEMOD_RESET;
5783 cmd_scu.parameter_len = 0;
5784 cmd_scu.result_len = 1;
5785 cmd_scu.parameter = NULL;
5786 cmd_scu.result = &cmd_result;
5787 rc = scu_command(dev_addr, &cmd_scu);
5788 if (rc != 0) {
5789 pr_err("error %d\n", rc);
5790 goto rw_error;
5791 }
5792
5793 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_DCF_BYPASS__A, 1, 0);
5794 if (rc != 0) {
5795 pr_err("error %d\n", rc);
5796 goto rw_error;
5797 }
5798 rc = drxj_dap_write_reg16(dev_addr, IQM_FS_ADJ_SEL__A, IQM_FS_ADJ_SEL_B_VSB, 0);
5799 if (rc != 0) {
5800 pr_err("error %d\n", rc);
5801 goto rw_error;
5802 }
5803 rc = drxj_dap_write_reg16(dev_addr, IQM_RC_ADJ_SEL__A, IQM_RC_ADJ_SEL_B_VSB, 0);
5804 if (rc != 0) {
5805 pr_err("error %d\n", rc);
5806 goto rw_error;
5807 }
5808 ext_attr->iqm_rc_rate_ofs = 0x00AD0D79;
5809 rc = drxdap_fasi_write_reg32(dev_addr, IQM_RC_RATE_OFS_LO__A, ext_attr->iqm_rc_rate_ofs, 0);
5810 if (rc != 0) {
5811 pr_err("error %d\n", rc);
5812 goto rw_error;
5813 }
5814 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_CFAGC_GAINSHIFT__A, 4, 0);
5815 if (rc != 0) {
5816 pr_err("error %d\n", rc);
5817 goto rw_error;
5818 }
5819 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_CYGN1TRK__A, 1, 0);
5820 if (rc != 0) {
5821 pr_err("error %d\n", rc);
5822 goto rw_error;
5823 }
5824
5825 rc = drxj_dap_write_reg16(dev_addr, IQM_RC_CROUT_ENA__A, 1, 0);
5826 if (rc != 0) {
5827 pr_err("error %d\n", rc);
5828 goto rw_error;
5829 }
5830 rc = drxj_dap_write_reg16(dev_addr, IQM_RC_STRETCH__A, 28, 0);
5831 if (rc != 0) {
5832 pr_err("error %d\n", rc);
5833 goto rw_error;
5834 }
5835 rc = drxj_dap_write_reg16(dev_addr, IQM_RT_ACTIVE__A, 0, 0);
5836 if (rc != 0) {
5837 pr_err("error %d\n", rc);
5838 goto rw_error;
5839 }
5840 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_SYMMETRIC__A, 0, 0);
5841 if (rc != 0) {
5842 pr_err("error %d\n", rc);
5843 goto rw_error;
5844 }
5845 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_MIDTAP__A, 3, 0);
5846 if (rc != 0) {
5847 pr_err("error %d\n", rc);
5848 goto rw_error;
5849 }
5850 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_OUT_ENA__A, IQM_CF_OUT_ENA_VSB__M, 0);
5851 if (rc != 0) {
5852 pr_err("error %d\n", rc);
5853 goto rw_error;
5854 }
5855 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_SCALE__A, 1393, 0);
5856 if (rc != 0) {
5857 pr_err("error %d\n", rc);
5858 goto rw_error;
5859 }
5860 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_SCALE_SH__A, 0, 0);
5861 if (rc != 0) {
5862 pr_err("error %d\n", rc);
5863 goto rw_error;
5864 }
5865 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_POW_MEAS_LEN__A, 1, 0);
5866 if (rc != 0) {
5867 pr_err("error %d\n", rc);
5868 goto rw_error;
5869 }
5870
5871 rc = drxdap_fasi_write_block(dev_addr, IQM_CF_TAP_RE0__A, sizeof(vsb_taps_re), ((u8 *)vsb_taps_re), 0);
5872 if (rc != 0) {
5873 pr_err("error %d\n", rc);
5874 goto rw_error;
5875 }
5876 rc = drxdap_fasi_write_block(dev_addr, IQM_CF_TAP_IM0__A, sizeof(vsb_taps_re), ((u8 *)vsb_taps_re), 0);
5877 if (rc != 0) {
5878 pr_err("error %d\n", rc);
5879 goto rw_error;
5880 }
5881
5882 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_BNTHRESH__A, 330, 0);
5883 if (rc != 0) {
5884 pr_err("error %d\n", rc);
5885 goto rw_error;
5886 } /* set higher threshold */
5887 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_CLPLASTNUM__A, 90, 0);
5888 if (rc != 0) {
5889 pr_err("error %d\n", rc);
5890 goto rw_error;
5891 } /* burst detection on */
5892 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_SNRTH_RCA1__A, 0x0042, 0);
5893 if (rc != 0) {
5894 pr_err("error %d\n", rc);
5895 goto rw_error;
5896 } /* drop thresholds by 1 dB */
5897 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_SNRTH_RCA2__A, 0x0053, 0);
5898 if (rc != 0) {
5899 pr_err("error %d\n", rc);
5900 goto rw_error;
5901 } /* drop thresholds by 2 dB */
5902 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_EQCTRL__A, 0x1, 0);
5903 if (rc != 0) {
5904 pr_err("error %d\n", rc);
5905 goto rw_error;
5906 } /* cma on */
5907 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_GPIO__A, 0, 0);
5908 if (rc != 0) {
5909 pr_err("error %d\n", rc);
5910 goto rw_error;
5911 } /* GPIO */
5912
5913 /* Initialize the FEC Subsystem */
5914 rc = drxj_dap_write_reg16(dev_addr, FEC_TOP_ANNEX__A, FEC_TOP_ANNEX_D, 0);
5915 if (rc != 0) {
5916 pr_err("error %d\n", rc);
5917 goto rw_error;
5918 }
5919 {
5920 u16 fec_oc_snc_mode = 0;
5921 rc = drxj_dap_read_reg16(dev_addr, FEC_OC_SNC_MODE__A, &fec_oc_snc_mode, 0);
5922 if (rc != 0) {
5923 pr_err("error %d\n", rc);
5924 goto rw_error;
5925 }
5926 /* output data even when not locked */
5927 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_SNC_MODE__A, fec_oc_snc_mode | FEC_OC_SNC_MODE_UNLOCK_ENABLE__M, 0);
5928 if (rc != 0) {
5929 pr_err("error %d\n", rc);
5930 goto rw_error;
5931 }
5932 }
5933
5934 /* set clip */
5935 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_CLP_LEN__A, 0, 0);
5936 if (rc != 0) {
5937 pr_err("error %d\n", rc);
5938 goto rw_error;
5939 }
5940 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_CLP_TH__A, 470, 0);
5941 if (rc != 0) {
5942 pr_err("error %d\n", rc);
5943 goto rw_error;
5944 }
5945 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_SNS_LEN__A, 0, 0);
5946 if (rc != 0) {
5947 pr_err("error %d\n", rc);
5948 goto rw_error;
5949 }
5950 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_SNRTH_PT__A, 0xD4, 0);
5951 if (rc != 0) {
5952 pr_err("error %d\n", rc);
5953 goto rw_error;
5954 }
5955 /* no transparent, no A&C framing; parity is set in mpegoutput */
5956 {
5957 u16 fec_oc_reg_mode = 0;
5958 rc = drxj_dap_read_reg16(dev_addr, FEC_OC_MODE__A, &fec_oc_reg_mode, 0);
5959 if (rc != 0) {
5960 pr_err("error %d\n", rc);
5961 goto rw_error;
5962 }
5963 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_MODE__A, fec_oc_reg_mode & (~(FEC_OC_MODE_TRANSPARENT__M | FEC_OC_MODE_CLEAR__M | FEC_OC_MODE_RETAIN_FRAMING__M)), 0);
5964 if (rc != 0) {
5965 pr_err("error %d\n", rc);
5966 goto rw_error;
5967 }
5968 }
5969
5970 rc = drxj_dap_write_reg16(dev_addr, FEC_DI_TIMEOUT_LO__A, 0, 0);
5971 if (rc != 0) {
5972 pr_err("error %d\n", rc);
5973 goto rw_error;
5974 } /* timeout counter for restarting */
5975 rc = drxj_dap_write_reg16(dev_addr, FEC_DI_TIMEOUT_HI__A, 3, 0);
5976 if (rc != 0) {
5977 pr_err("error %d\n", rc);
5978 goto rw_error;
5979 }
5980 rc = drxj_dap_write_reg16(dev_addr, FEC_RS_MODE__A, 0, 0);
5981 if (rc != 0) {
5982 pr_err("error %d\n", rc);
5983 goto rw_error;
5984 } /* bypass disabled */
5985 /* initialize RS packet error measurement parameters */
5986 rc = drxj_dap_write_reg16(dev_addr, FEC_RS_MEASUREMENT_PERIOD__A, FEC_RS_MEASUREMENT_PERIOD, 0);
5987 if (rc != 0) {
5988 pr_err("error %d\n", rc);
5989 goto rw_error;
5990 }
5991 rc = drxj_dap_write_reg16(dev_addr, FEC_RS_MEASUREMENT_PRESCALE__A, FEC_RS_MEASUREMENT_PRESCALE, 0);
5992 if (rc != 0) {
5993 pr_err("error %d\n", rc);
5994 goto rw_error;
5995 }
5996
5997 /* init measurement period of MER/SER */
5998 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_MEASUREMENT_PERIOD__A, VSB_TOP_MEASUREMENT_PERIOD, 0);
5999 if (rc != 0) {
6000 pr_err("error %d\n", rc);
6001 goto rw_error;
6002 }
6003 rc = drxdap_fasi_write_reg32(dev_addr, SCU_RAM_FEC_ACCUM_CW_CORRECTED_LO__A, 0, 0);
6004 if (rc != 0) {
6005 pr_err("error %d\n", rc);
6006 goto rw_error;
6007 }
6008 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_FEC_MEAS_COUNT__A, 0, 0);
6009 if (rc != 0) {
6010 pr_err("error %d\n", rc);
6011 goto rw_error;
6012 }
6013 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A, 0, 0);
6014 if (rc != 0) {
6015 pr_err("error %d\n", rc);
6016 goto rw_error;
6017 }
6018
6019 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_CKGN1TRK__A, 128, 0);
6020 if (rc != 0) {
6021 pr_err("error %d\n", rc);
6022 goto rw_error;
6023 }
6024 /* B-Input to ADC, PGA+filter in standby */
6025 if (!ext_attr->has_lna) {
6026 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_AMUX__A, 0x02, 0);
6027 if (rc != 0) {
6028 pr_err("error %d\n", rc);
6029 goto rw_error;
6030 }
6031 }
6032
6033 /* turn on IQMAF. It has to be in front of setAgc**() */
6034 rc = set_iqm_af(demod, true);
6035 if (rc != 0) {
6036 pr_err("error %d\n", rc);
6037 goto rw_error;
6038 }
6039 rc = adc_synchronization(demod);
6040 if (rc != 0) {
6041 pr_err("error %d\n", rc);
6042 goto rw_error;
6043 }
6044
6045 rc = init_agc(demod);
6046 if (rc != 0) {
6047 pr_err("error %d\n", rc);
6048 goto rw_error;
6049 }
6050 rc = set_agc_if(demod, &(ext_attr->vsb_if_agc_cfg), false);
6051 if (rc != 0) {
6052 pr_err("error %d\n", rc);
6053 goto rw_error;
6054 }
6055 rc = set_agc_rf(demod, &(ext_attr->vsb_rf_agc_cfg), false);
6056 if (rc != 0) {
6057 pr_err("error %d\n", rc);
6058 goto rw_error;
6059 }
6060 {
6061 /* TODO fix this, store a struct drxj_cfg_afe_gain structure in struct drxj_data instead
6062 of only the gain */
6063 struct drxj_cfg_afe_gain vsb_pga_cfg = { DRX_STANDARD_8VSB, 0 };
6064
6065 vsb_pga_cfg.gain = ext_attr->vsb_pga_cfg;
6066 rc = ctrl_set_cfg_afe_gain(demod, &vsb_pga_cfg);
6067 if (rc != 0) {
6068 pr_err("error %d\n", rc);
6069 goto rw_error;
6070 }
6071 }
6072 rc = ctrl_set_cfg_pre_saw(demod, &(ext_attr->vsb_pre_saw_cfg));
6073 if (rc != 0) {
6074 pr_err("error %d\n", rc);
6075 goto rw_error;
6076 }
6077
6078 /* Mpeg output has to be in front of FEC active */
6079 rc = set_mpegtei_handling(demod);
6080 if (rc != 0) {
6081 pr_err("error %d\n", rc);
6082 goto rw_error;
6083 }
6084 rc = bit_reverse_mpeg_output(demod);
6085 if (rc != 0) {
6086 pr_err("error %d\n", rc);
6087 goto rw_error;
6088 }
6089 rc = set_mpeg_start_width(demod);
6090 if (rc != 0) {
6091 pr_err("error %d\n", rc);
6092 goto rw_error;
6093 }
6094 {
6095 /* TODO: move to set_standard after hardware reset value problem is solved */
6096 /* Configure initial MPEG output */
6097 struct drx_cfg_mpeg_output cfg_mpeg_output;
6098
6099 memcpy(&cfg_mpeg_output, &common_attr->mpeg_cfg, sizeof(cfg_mpeg_output));
6100 cfg_mpeg_output.enable_mpeg_output = true;
6101
6102 rc = ctrl_set_cfg_mpeg_output(demod, &cfg_mpeg_output);
6103 if (rc != 0) {
6104 pr_err("error %d\n", rc);
6105 goto rw_error;
6106 }
6107 }
6108
6109 /* TBD: what parameters should be set */
6110 cmd_param = 0x00; /* Default mode AGC on, etc */
6111 cmd_scu.command = SCU_RAM_COMMAND_STANDARD_VSB
6112 | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM;
6113 cmd_scu.parameter_len = 1;
6114 cmd_scu.result_len = 1;
6115 cmd_scu.parameter = &cmd_param;
6116 cmd_scu.result = &cmd_result;
6117 rc = scu_command(dev_addr, &cmd_scu);
6118 if (rc != 0) {
6119 pr_err("error %d\n", rc);
6120 goto rw_error;
6121 }
6122
6123 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_BEAGC_GAINSHIFT__A, 0x0004, 0);
6124 if (rc != 0) {
6125 pr_err("error %d\n", rc);
6126 goto rw_error;
6127 }
6128 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_SNRTH_PT__A, 0x00D2, 0);
6129 if (rc != 0) {
6130 pr_err("error %d\n", rc);
6131 goto rw_error;
6132 }
6133 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_SYSSMTRNCTRL__A, VSB_TOP_SYSSMTRNCTRL__PRE | VSB_TOP_SYSSMTRNCTRL_NCOTIMEOUTCNTEN__M, 0);
6134 if (rc != 0) {
6135 pr_err("error %d\n", rc);
6136 goto rw_error;
6137 }
6138 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_BEDETCTRL__A, 0x142, 0);
6139 if (rc != 0) {
6140 pr_err("error %d\n", rc);
6141 goto rw_error;
6142 }
6143 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_LBAGCREFLVL__A, 640, 0);
6144 if (rc != 0) {
6145 pr_err("error %d\n", rc);
6146 goto rw_error;
6147 }
6148 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_CYGN1ACQ__A, 4, 0);
6149 if (rc != 0) {
6150 pr_err("error %d\n", rc);
6151 goto rw_error;
6152 }
6153 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_CYGN1TRK__A, 2, 0);
6154 if (rc != 0) {
6155 pr_err("error %d\n", rc);
6156 goto rw_error;
6157 }
6158 rc = drxj_dap_write_reg16(dev_addr, VSB_TOP_CYGN2TRK__A, 3, 0);
6159 if (rc != 0) {
6160 pr_err("error %d\n", rc);
6161 goto rw_error;
6162 }
6163
6164 /* start demodulator */
6165 cmd_scu.command = SCU_RAM_COMMAND_STANDARD_VSB
6166 | SCU_RAM_COMMAND_CMD_DEMOD_START;
6167 cmd_scu.parameter_len = 0;
6168 cmd_scu.result_len = 1;
6169 cmd_scu.parameter = NULL;
6170 cmd_scu.result = &cmd_result;
6171 rc = scu_command(dev_addr, &cmd_scu);
6172 if (rc != 0) {
6173 pr_err("error %d\n", rc);
6174 goto rw_error;
6175 }
6176
6177 rc = drxj_dap_write_reg16(dev_addr, IQM_COMM_EXEC__A, IQM_COMM_EXEC_ACTIVE, 0);
6178 if (rc != 0) {
6179 pr_err("error %d\n", rc);
6180 goto rw_error;
6181 }
6182 rc = drxj_dap_write_reg16(dev_addr, VSB_COMM_EXEC__A, VSB_COMM_EXEC_ACTIVE, 0);
6183 if (rc != 0) {
6184 pr_err("error %d\n", rc);
6185 goto rw_error;
6186 }
6187 rc = drxj_dap_write_reg16(dev_addr, FEC_COMM_EXEC__A, FEC_COMM_EXEC_ACTIVE, 0);
6188 if (rc != 0) {
6189 pr_err("error %d\n", rc);
6190 goto rw_error;
6191 }
6192
6193 return 0;
6194rw_error:
6195 return -EIO;
6196}
6197
6198/**
6199* \fn static short get_vsb_post_rs_pck_err(struct i2c_device_addr *dev_addr, u16 *PckErrs)
6200* \brief Get the values of packet error in 8VSB mode
6201* \return Error code
6202*/
6203static int get_vsb_post_rs_pck_err(struct i2c_device_addr *dev_addr,
6204 u32 *pck_errs, u32 *pck_count)
6205{
6206 int rc;
6207 u16 data = 0;
6208 u16 period = 0;
6209 u16 prescale = 0;
6210 u16 packet_errors_mant = 0;
6211 u16 packet_errors_exp = 0;
6212
6213 rc = drxj_dap_read_reg16(dev_addr, FEC_RS_NR_FAILURES__A, &data, 0);
6214 if (rc != 0) {
6215 pr_err("error %d\n", rc);
6216 goto rw_error;
6217 }
6218 packet_errors_mant = data & FEC_RS_NR_FAILURES_FIXED_MANT__M;
6219 packet_errors_exp = (data & FEC_RS_NR_FAILURES_EXP__M)
6220 >> FEC_RS_NR_FAILURES_EXP__B;
6221 period = FEC_RS_MEASUREMENT_PERIOD;
6222 prescale = FEC_RS_MEASUREMENT_PRESCALE;
6223 /* packet error rate = (error packet number) per second */
6224 /* 77.3 us is time for per packet */
6225 if (period * prescale == 0) {
6226 pr_err("error: period and/or prescale is zero!\n");
6227 return -EIO;
6228 }
6229 *pck_errs = packet_errors_mant * (1 << packet_errors_exp);
6230 *pck_count = period * prescale * 77;
6231
6232 return 0;
6233rw_error:
6234 return -EIO;
6235}
6236
6237/**
6238* \fn static short GetVSBBer(struct i2c_device_addr *dev_addr, u32 *ber)
6239* \brief Get the values of ber in VSB mode
6240* \return Error code
6241*/
6242static int get_vs_bpost_viterbi_ber(struct i2c_device_addr *dev_addr,
6243 u32 *ber, u32 *cnt)
6244{
6245 int rc;
6246 u16 data = 0;
6247 u16 period = 0;
6248 u16 prescale = 0;
6249 u16 bit_errors_mant = 0;
6250 u16 bit_errors_exp = 0;
6251
6252 rc = drxj_dap_read_reg16(dev_addr, FEC_RS_NR_BIT_ERRORS__A, &data, 0);
6253 if (rc != 0) {
6254 pr_err("error %d\n", rc);
6255 goto rw_error;
6256 }
6257 period = FEC_RS_MEASUREMENT_PERIOD;
6258 prescale = FEC_RS_MEASUREMENT_PRESCALE;
6259
6260 bit_errors_mant = data & FEC_RS_NR_BIT_ERRORS_FIXED_MANT__M;
6261 bit_errors_exp = (data & FEC_RS_NR_BIT_ERRORS_EXP__M)
6262 >> FEC_RS_NR_BIT_ERRORS_EXP__B;
6263
6264 *cnt = period * prescale * 207 * ((bit_errors_exp > 2) ? 1 : 8);
6265
6266 if (((bit_errors_mant << bit_errors_exp) >> 3) > 68700)
6267 *ber = (*cnt) * 26570;
6268 else {
6269 if (period * prescale == 0) {
6270 pr_err("error: period and/or prescale is zero!\n");
6271 return -EIO;
6272 }
6273 *ber = bit_errors_mant << ((bit_errors_exp > 2) ?
6274 (bit_errors_exp - 3) : bit_errors_exp);
6275 }
6276
6277 return 0;
6278rw_error:
6279 return -EIO;
6280}
6281
6282/**
6283* \fn static short get_vs_bpre_viterbi_ber(struct i2c_device_addr *dev_addr, u32 *ber)
6284* \brief Get the values of ber in VSB mode
6285* \return Error code
6286*/
6287static int get_vs_bpre_viterbi_ber(struct i2c_device_addr *dev_addr,
6288 u32 *ber, u32 *cnt)
6289{
6290 u16 data = 0;
6291 int rc;
6292
6293 rc = drxj_dap_read_reg16(dev_addr, VSB_TOP_NR_SYM_ERRS__A, &data, 0);
6294 if (rc != 0) {
6295 pr_err("error %d\n", rc);
6296 return -EIO;
6297 }
6298 *ber = data;
6299 *cnt = VSB_TOP_MEASUREMENT_PERIOD * SYMBOLS_PER_SEGMENT;
6300
6301 return 0;
6302}
6303
6304/**
6305* \fn static int get_vsbmer(struct i2c_device_addr *dev_addr, u16 *mer)
6306* \brief Get the values of MER
6307* \return Error code
6308*/
6309static int get_vsbmer(struct i2c_device_addr *dev_addr, u16 *mer)
6310{
6311 int rc;
6312 u16 data_hi = 0;
6313
6314 rc = drxj_dap_read_reg16(dev_addr, VSB_TOP_ERR_ENERGY_H__A, &data_hi, 0);
6315 if (rc != 0) {
6316 pr_err("error %d\n", rc);
6317 goto rw_error;
6318 }
6319 *mer =
6320 (u16) (log1_times100(21504) - log1_times100((data_hi << 6) / 52));
6321
6322 return 0;
6323rw_error:
6324 return -EIO;
6325}
6326
6327
6328/*============================================================================*/
6329/*== END 8VSB DATAPATH FUNCTIONS ==*/
6330/*============================================================================*/
6331
6332/*============================================================================*/
6333/*============================================================================*/
6334/*== QAM DATAPATH FUNCTIONS ==*/
6335/*============================================================================*/
6336/*============================================================================*/
6337
6338/**
6339* \fn int power_down_qam ()
6340* \brief Powr down QAM related blocks.
6341* \param demod instance of demodulator.
6342* \param channel pointer to channel data.
6343* \return int.
6344*/
6345static int power_down_qam(struct drx_demod_instance *demod, bool primary)
6346{
6347 struct drxjscu_cmd cmd_scu = { /* command */ 0,
6348 /* parameter_len */ 0,
6349 /* result_len */ 0,
6350 /* *parameter */ NULL,
6351 /* *result */ NULL
6352 };
6353 int rc;
6354 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
6355 struct drx_cfg_mpeg_output cfg_mpeg_output;
6356 struct drx_common_attr *common_attr = demod->my_common_attr;
6357 u16 cmd_result = 0;
6358
6359 /*
6360 STOP demodulator
6361 resets IQM, QAM and FEC HW blocks
6362 */
6363 /* stop all comm_exec */
6364 rc = drxj_dap_write_reg16(dev_addr, FEC_COMM_EXEC__A, FEC_COMM_EXEC_STOP, 0);
6365 if (rc != 0) {
6366 pr_err("error %d\n", rc);
6367 goto rw_error;
6368 }
6369 rc = drxj_dap_write_reg16(dev_addr, QAM_COMM_EXEC__A, QAM_COMM_EXEC_STOP, 0);
6370 if (rc != 0) {
6371 pr_err("error %d\n", rc);
6372 goto rw_error;
6373 }
6374
6375 cmd_scu.command = SCU_RAM_COMMAND_STANDARD_QAM |
6376 SCU_RAM_COMMAND_CMD_DEMOD_STOP;
6377 cmd_scu.parameter_len = 0;
6378 cmd_scu.result_len = 1;
6379 cmd_scu.parameter = NULL;
6380 cmd_scu.result = &cmd_result;
6381 rc = scu_command(dev_addr, &cmd_scu);
6382 if (rc != 0) {
6383 pr_err("error %d\n", rc);
6384 goto rw_error;
6385 }
6386
6387 if (primary) {
6388 rc = drxj_dap_write_reg16(dev_addr, IQM_COMM_EXEC__A, IQM_COMM_EXEC_STOP, 0);
6389 if (rc != 0) {
6390 pr_err("error %d\n", rc);
6391 goto rw_error;
6392 }
6393 rc = set_iqm_af(demod, false);
6394 if (rc != 0) {
6395 pr_err("error %d\n", rc);
6396 goto rw_error;
6397 }
6398 } else {
6399 rc = drxj_dap_write_reg16(dev_addr, IQM_FS_COMM_EXEC__A, IQM_FS_COMM_EXEC_STOP, 0);
6400 if (rc != 0) {
6401 pr_err("error %d\n", rc);
6402 goto rw_error;
6403 }
6404 rc = drxj_dap_write_reg16(dev_addr, IQM_FD_COMM_EXEC__A, IQM_FD_COMM_EXEC_STOP, 0);
6405 if (rc != 0) {
6406 pr_err("error %d\n", rc);
6407 goto rw_error;
6408 }
6409 rc = drxj_dap_write_reg16(dev_addr, IQM_RC_COMM_EXEC__A, IQM_RC_COMM_EXEC_STOP, 0);
6410 if (rc != 0) {
6411 pr_err("error %d\n", rc);
6412 goto rw_error;
6413 }
6414 rc = drxj_dap_write_reg16(dev_addr, IQM_RT_COMM_EXEC__A, IQM_RT_COMM_EXEC_STOP, 0);
6415 if (rc != 0) {
6416 pr_err("error %d\n", rc);
6417 goto rw_error;
6418 }
6419 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_COMM_EXEC__A, IQM_CF_COMM_EXEC_STOP, 0);
6420 if (rc != 0) {
6421 pr_err("error %d\n", rc);
6422 goto rw_error;
6423 }
6424 }
6425
6426 memcpy(&cfg_mpeg_output, &common_attr->mpeg_cfg, sizeof(cfg_mpeg_output));
6427 cfg_mpeg_output.enable_mpeg_output = false;
6428
6429 rc = ctrl_set_cfg_mpeg_output(demod, &cfg_mpeg_output);
6430 if (rc != 0) {
6431 pr_err("error %d\n", rc);
6432 goto rw_error;
6433 }
6434
6435 return 0;
6436rw_error:
6437 return -EIO;
6438}
6439
6440/*============================================================================*/
6441
6442/**
6443* \fn int set_qam_measurement ()
6444* \brief Setup of the QAM Measuremnt intervals for signal quality
6445* \param demod instance of demod.
6446* \param constellation current constellation.
6447* \return int.
6448*
6449* NOTE:
6450* Take into account that for certain settings the errorcounters can overflow.
6451* The implementation does not check this.
6452*
6453* TODO: overriding the ext_attr->fec_bits_desired by constellation dependent
6454* constants to get a measurement period of approx. 1 sec. Remove fec_bits_desired
6455* field ?
6456*
6457*/
6458#ifndef DRXJ_VSB_ONLY
6459static int
6460set_qam_measurement(struct drx_demod_instance *demod,
6461 enum drx_modulation constellation, u32 symbol_rate)
6462{
6463 struct i2c_device_addr *dev_addr = NULL; /* device address for I2C writes */
6464 struct drxj_data *ext_attr = NULL; /* Global data container for DRXJ specif data */
6465 int rc;
6466 u32 fec_bits_desired = 0; /* BER accounting period */
6467 u16 fec_rs_plen = 0; /* defines RS BER measurement period */
6468 u16 fec_rs_prescale = 0; /* ReedSolomon Measurement Prescale */
6469 u32 fec_rs_period = 0; /* Value for corresponding I2C register */
6470 u32 fec_rs_bit_cnt = 0; /* Actual precise amount of bits */
6471 u32 fec_oc_snc_fail_period = 0; /* Value for corresponding I2C register */
6472 u32 qam_vd_period = 0; /* Value for corresponding I2C register */
6473 u32 qam_vd_bit_cnt = 0; /* Actual precise amount of bits */
6474 u16 fec_vd_plen = 0; /* no of trellis symbols: VD SER measur period */
6475 u16 qam_vd_prescale = 0; /* Viterbi Measurement Prescale */
6476
6477 dev_addr = demod->my_i2c_dev_addr;
6478 ext_attr = (struct drxj_data *) demod->my_ext_attr;
6479
6480 fec_bits_desired = ext_attr->fec_bits_desired;
6481 fec_rs_prescale = ext_attr->fec_rs_prescale;
6482
6483 switch (constellation) {
6484 case DRX_CONSTELLATION_QAM16:
6485 fec_bits_desired = 4 * symbol_rate;
6486 break;
6487 case DRX_CONSTELLATION_QAM32:
6488 fec_bits_desired = 5 * symbol_rate;
6489 break;
6490 case DRX_CONSTELLATION_QAM64:
6491 fec_bits_desired = 6 * symbol_rate;
6492 break;
6493 case DRX_CONSTELLATION_QAM128:
6494 fec_bits_desired = 7 * symbol_rate;
6495 break;
6496 case DRX_CONSTELLATION_QAM256:
6497 fec_bits_desired = 8 * symbol_rate;
6498 break;
6499 default:
6500 return -EINVAL;
6501 }
6502
6503 /* Parameters for Reed-Solomon Decoder */
6504 /* fecrs_period = (int)ceil(FEC_BITS_DESIRED/(fecrs_prescale*plen)) */
6505 /* rs_bit_cnt = fecrs_period*fecrs_prescale*plen */
6506 /* result is within 32 bit arithmetic -> */
6507 /* no need for mult or frac functions */
6508
6509 /* TODO: use constant instead of calculation and remove the fec_rs_plen in ext_attr */
6510 switch (ext_attr->standard) {
6511 case DRX_STANDARD_ITU_A:
6512 case DRX_STANDARD_ITU_C:
6513 fec_rs_plen = 204 * 8;
6514 break;
6515 case DRX_STANDARD_ITU_B:
6516 fec_rs_plen = 128 * 7;
6517 break;
6518 default:
6519 return -EINVAL;
6520 }
6521
6522 ext_attr->fec_rs_plen = fec_rs_plen; /* for getSigQual */
6523 fec_rs_bit_cnt = fec_rs_prescale * fec_rs_plen; /* temp storage */
6524 if (fec_rs_bit_cnt == 0) {
6525 pr_err("error: fec_rs_bit_cnt is zero!\n");
6526 return -EIO;
6527 }
6528 fec_rs_period = fec_bits_desired / fec_rs_bit_cnt + 1; /* ceil */
6529 if (ext_attr->standard != DRX_STANDARD_ITU_B)
6530 fec_oc_snc_fail_period = fec_rs_period;
6531
6532 /* limit to max 16 bit value (I2C register width) if needed */
6533 if (fec_rs_period > 0xFFFF)
6534 fec_rs_period = 0xFFFF;
6535
6536 /* write corresponding registers */
6537 switch (ext_attr->standard) {
6538 case DRX_STANDARD_ITU_A:
6539 case DRX_STANDARD_ITU_C:
6540 break;
6541 case DRX_STANDARD_ITU_B:
6542 switch (constellation) {
6543 case DRX_CONSTELLATION_QAM64:
6544 fec_rs_period = 31581;
6545 fec_oc_snc_fail_period = 17932;
6546 break;
6547 case DRX_CONSTELLATION_QAM256:
6548 fec_rs_period = 45446;
6549 fec_oc_snc_fail_period = 25805;
6550 break;
6551 default:
6552 return -EINVAL;
6553 }
6554 break;
6555 default:
6556 return -EINVAL;
6557 }
6558
6559 rc = drxj_dap_write_reg16(dev_addr, FEC_OC_SNC_FAIL_PERIOD__A, (u16)fec_oc_snc_fail_period, 0);
6560 if (rc != 0) {
6561 pr_err("error %d\n", rc);
6562 goto rw_error;
6563 }
6564 rc = drxj_dap_write_reg16(dev_addr, FEC_RS_MEASUREMENT_PERIOD__A, (u16)fec_rs_period, 0);
6565 if (rc != 0) {
6566 pr_err("error %d\n", rc);
6567 goto rw_error;
6568 }
6569 rc = drxj_dap_write_reg16(dev_addr, FEC_RS_MEASUREMENT_PRESCALE__A, fec_rs_prescale, 0);
6570 if (rc != 0) {
6571 pr_err("error %d\n", rc);
6572 goto rw_error;
6573 }
6574 ext_attr->fec_rs_period = (u16) fec_rs_period;
6575 ext_attr->fec_rs_prescale = fec_rs_prescale;
6576 rc = drxdap_fasi_write_reg32(dev_addr, SCU_RAM_FEC_ACCUM_CW_CORRECTED_LO__A, 0, 0);
6577 if (rc != 0) {
6578 pr_err("error %d\n", rc);
6579 goto rw_error;
6580 }
6581 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_FEC_MEAS_COUNT__A, 0, 0);
6582 if (rc != 0) {
6583 pr_err("error %d\n", rc);
6584 goto rw_error;
6585 }
6586 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A, 0, 0);
6587 if (rc != 0) {
6588 pr_err("error %d\n", rc);
6589 goto rw_error;
6590 }
6591
6592 if (ext_attr->standard == DRX_STANDARD_ITU_B) {
6593 /* Parameters for Viterbi Decoder */
6594 /* qamvd_period = (int)ceil(FEC_BITS_DESIRED/ */
6595 /* (qamvd_prescale*plen*(qam_constellation+1))) */
6596 /* vd_bit_cnt = qamvd_period*qamvd_prescale*plen */
6597 /* result is within 32 bit arithmetic -> */
6598 /* no need for mult or frac functions */
6599
6600 /* a(8 bit) * b(8 bit) = 16 bit result => mult32 not needed */
6601 fec_vd_plen = ext_attr->fec_vd_plen;
6602 qam_vd_prescale = ext_attr->qam_vd_prescale;
6603 qam_vd_bit_cnt = qam_vd_prescale * fec_vd_plen; /* temp storage */
6604
6605 switch (constellation) {
6606 case DRX_CONSTELLATION_QAM64:
6607 /* a(16 bit) * b(4 bit) = 20 bit result => mult32 not needed */
6608 qam_vd_period =
6609 qam_vd_bit_cnt * (QAM_TOP_CONSTELLATION_QAM64 + 1)
6610 * (QAM_TOP_CONSTELLATION_QAM64 + 1);
6611 break;
6612 case DRX_CONSTELLATION_QAM256:
6613 /* a(16 bit) * b(5 bit) = 21 bit result => mult32 not needed */
6614 qam_vd_period =
6615 qam_vd_bit_cnt * (QAM_TOP_CONSTELLATION_QAM256 + 1)
6616 * (QAM_TOP_CONSTELLATION_QAM256 + 1);
6617 break;
6618 default:
6619 return -EINVAL;
6620 }
6621 if (qam_vd_period == 0) {
6622 pr_err("error: qam_vd_period is zero!\n");
6623 return -EIO;
6624 }
6625 qam_vd_period = fec_bits_desired / qam_vd_period;
6626 /* limit to max 16 bit value (I2C register width) if needed */
6627 if (qam_vd_period > 0xFFFF)
6628 qam_vd_period = 0xFFFF;
6629
6630 /* a(16 bit) * b(16 bit) = 32 bit result => mult32 not needed */
6631 qam_vd_bit_cnt *= qam_vd_period;
6632
6633 rc = drxj_dap_write_reg16(dev_addr, QAM_VD_MEASUREMENT_PERIOD__A, (u16)qam_vd_period, 0);
6634 if (rc != 0) {
6635 pr_err("error %d\n", rc);
6636 goto rw_error;
6637 }
6638 rc = drxj_dap_write_reg16(dev_addr, QAM_VD_MEASUREMENT_PRESCALE__A, qam_vd_prescale, 0);
6639 if (rc != 0) {
6640 pr_err("error %d\n", rc);
6641 goto rw_error;
6642 }
6643 ext_attr->qam_vd_period = (u16) qam_vd_period;
6644 ext_attr->qam_vd_prescale = qam_vd_prescale;
6645 }
6646
6647 return 0;
6648rw_error:
6649 return -EIO;
6650}
6651
6652/*============================================================================*/
6653
6654/**
6655* \fn int set_qam16 ()
6656* \brief QAM16 specific setup
6657* \param demod instance of demod.
6658* \return int.
6659*/
6660static int set_qam16(struct drx_demod_instance *demod)
6661{
6662 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
6663 int rc;
6664 const u8 qam_dq_qual_fun[] = {
6665 DRXJ_16TO8(2), /* fun0 */
6666 DRXJ_16TO8(2), /* fun1 */
6667 DRXJ_16TO8(2), /* fun2 */
6668 DRXJ_16TO8(2), /* fun3 */
6669 DRXJ_16TO8(3), /* fun4 */
6670 DRXJ_16TO8(3), /* fun5 */
6671 };
6672 const u8 qam_eq_cma_rad[] = {
6673 DRXJ_16TO8(13517), /* RAD0 */
6674 DRXJ_16TO8(13517), /* RAD1 */
6675 DRXJ_16TO8(13517), /* RAD2 */
6676 DRXJ_16TO8(13517), /* RAD3 */
6677 DRXJ_16TO8(13517), /* RAD4 */
6678 DRXJ_16TO8(13517), /* RAD5 */
6679 };
6680
6681 rc = drxdap_fasi_write_block(dev_addr, QAM_DQ_QUAL_FUN0__A, sizeof(qam_dq_qual_fun), ((u8 *)qam_dq_qual_fun), 0);
6682 if (rc != 0) {
6683 pr_err("error %d\n", rc);
6684 goto rw_error;
6685 }
6686 rc = drxdap_fasi_write_block(dev_addr, SCU_RAM_QAM_EQ_CMA_RAD0__A, sizeof(qam_eq_cma_rad), ((u8 *)qam_eq_cma_rad), 0);
6687 if (rc != 0) {
6688 pr_err("error %d\n", rc);
6689 goto rw_error;
6690 }
6691
6692 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RTH__A, 140, 0);
6693 if (rc != 0) {
6694 pr_err("error %d\n", rc);
6695 goto rw_error;
6696 }
6697 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_FTH__A, 50, 0);
6698 if (rc != 0) {
6699 pr_err("error %d\n", rc);
6700 goto rw_error;
6701 }
6702 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_PTH__A, 120, 0);
6703 if (rc != 0) {
6704 pr_err("error %d\n", rc);
6705 goto rw_error;
6706 }
6707 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_QTH__A, 230, 0);
6708 if (rc != 0) {
6709 pr_err("error %d\n", rc);
6710 goto rw_error;
6711 }
6712 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_CTH__A, 95, 0);
6713 if (rc != 0) {
6714 pr_err("error %d\n", rc);
6715 goto rw_error;
6716 }
6717 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_MTH__A, 105, 0);
6718 if (rc != 0) {
6719 pr_err("error %d\n", rc);
6720 goto rw_error;
6721 }
6722
6723 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RATE_LIM__A, 40, 0);
6724 if (rc != 0) {
6725 pr_err("error %d\n", rc);
6726 goto rw_error;
6727 }
6728 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_FREQ_LIM__A, 56, 0);
6729 if (rc != 0) {
6730 pr_err("error %d\n", rc);
6731 goto rw_error;
6732 }
6733 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_COUNT_LIM__A, 3, 0);
6734 if (rc != 0) {
6735 pr_err("error %d\n", rc);
6736 goto rw_error;
6737 }
6738
6739 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A, 16, 0);
6740 if (rc != 0) {
6741 pr_err("error %d\n", rc);
6742 goto rw_error;
6743 }
6744 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A, 220, 0);
6745 if (rc != 0) {
6746 pr_err("error %d\n", rc);
6747 goto rw_error;
6748 }
6749 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A, 25, 0);
6750 if (rc != 0) {
6751 pr_err("error %d\n", rc);
6752 goto rw_error;
6753 }
6754 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A, 6, 0);
6755 if (rc != 0) {
6756 pr_err("error %d\n", rc);
6757 goto rw_error;
6758 }
6759 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A, (u16)(-24), 0);
6760 if (rc != 0) {
6761 pr_err("error %d\n", rc);
6762 goto rw_error;
6763 }
6764 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A, (u16)(-65), 0);
6765 if (rc != 0) {
6766 pr_err("error %d\n", rc);
6767 goto rw_error;
6768 }
6769 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A, (u16)(-127), 0);
6770 if (rc != 0) {
6771 pr_err("error %d\n", rc);
6772 goto rw_error;
6773 }
6774
6775 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CA_FINE__A, 15, 0);
6776 if (rc != 0) {
6777 pr_err("error %d\n", rc);
6778 goto rw_error;
6779 }
6780 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CA_COARSE__A, 40, 0);
6781 if (rc != 0) {
6782 pr_err("error %d\n", rc);
6783 goto rw_error;
6784 }
6785 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_FINE__A, 2, 0);
6786 if (rc != 0) {
6787 pr_err("error %d\n", rc);
6788 goto rw_error;
6789 }
6790 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_MEDIUM__A, 20, 0);
6791 if (rc != 0) {
6792 pr_err("error %d\n", rc);
6793 goto rw_error;
6794 }
6795 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_COARSE__A, 255, 0);
6796 if (rc != 0) {
6797 pr_err("error %d\n", rc);
6798 goto rw_error;
6799 }
6800 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_FINE__A, 2, 0);
6801 if (rc != 0) {
6802 pr_err("error %d\n", rc);
6803 goto rw_error;
6804 }
6805 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_MEDIUM__A, 10, 0);
6806 if (rc != 0) {
6807 pr_err("error %d\n", rc);
6808 goto rw_error;
6809 }
6810 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_COARSE__A, 50, 0);
6811 if (rc != 0) {
6812 pr_err("error %d\n", rc);
6813 goto rw_error;
6814 }
6815 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_FINE__A, 12, 0);
6816 if (rc != 0) {
6817 pr_err("error %d\n", rc);
6818 goto rw_error;
6819 }
6820 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_MEDIUM__A, 24, 0);
6821 if (rc != 0) {
6822 pr_err("error %d\n", rc);
6823 goto rw_error;
6824 }
6825 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_COARSE__A, 24, 0);
6826 if (rc != 0) {
6827 pr_err("error %d\n", rc);
6828 goto rw_error;
6829 }
6830 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_FINE__A, 12, 0);
6831 if (rc != 0) {
6832 pr_err("error %d\n", rc);
6833 goto rw_error;
6834 }
6835 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_MEDIUM__A, 16, 0);
6836 if (rc != 0) {
6837 pr_err("error %d\n", rc);
6838 goto rw_error;
6839 }
6840 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_COARSE__A, 16, 0);
6841 if (rc != 0) {
6842 pr_err("error %d\n", rc);
6843 goto rw_error;
6844 }
6845 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_FINE__A, 16, 0);
6846 if (rc != 0) {
6847 pr_err("error %d\n", rc);
6848 goto rw_error;
6849 }
6850 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_MEDIUM__A, 32, 0);
6851 if (rc != 0) {
6852 pr_err("error %d\n", rc);
6853 goto rw_error;
6854 }
6855 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_COARSE__A, 240, 0);
6856 if (rc != 0) {
6857 pr_err("error %d\n", rc);
6858 goto rw_error;
6859 }
6860 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_FINE__A, 5, 0);
6861 if (rc != 0) {
6862 pr_err("error %d\n", rc);
6863 goto rw_error;
6864 }
6865 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_MEDIUM__A, 15, 0);
6866 if (rc != 0) {
6867 pr_err("error %d\n", rc);
6868 goto rw_error;
6869 }
6870 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_COARSE__A, 32, 0);
6871 if (rc != 0) {
6872 pr_err("error %d\n", rc);
6873 goto rw_error;
6874 }
6875
6876 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_SL_SIG_POWER__A, 40960, 0);
6877 if (rc != 0) {
6878 pr_err("error %d\n", rc);
6879 goto rw_error;
6880 }
6881
6882 return 0;
6883rw_error:
6884 return -EIO;
6885}
6886
6887/*============================================================================*/
6888
6889/**
6890* \fn int set_qam32 ()
6891* \brief QAM32 specific setup
6892* \param demod instance of demod.
6893* \return int.
6894*/
6895static int set_qam32(struct drx_demod_instance *demod)
6896{
6897 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
6898 int rc;
6899 const u8 qam_dq_qual_fun[] = {
6900 DRXJ_16TO8(3), /* fun0 */
6901 DRXJ_16TO8(3), /* fun1 */
6902 DRXJ_16TO8(3), /* fun2 */
6903 DRXJ_16TO8(3), /* fun3 */
6904 DRXJ_16TO8(4), /* fun4 */
6905 DRXJ_16TO8(4), /* fun5 */
6906 };
6907 const u8 qam_eq_cma_rad[] = {
6908 DRXJ_16TO8(6707), /* RAD0 */
6909 DRXJ_16TO8(6707), /* RAD1 */
6910 DRXJ_16TO8(6707), /* RAD2 */
6911 DRXJ_16TO8(6707), /* RAD3 */
6912 DRXJ_16TO8(6707), /* RAD4 */
6913 DRXJ_16TO8(6707), /* RAD5 */
6914 };
6915
6916 rc = drxdap_fasi_write_block(dev_addr, QAM_DQ_QUAL_FUN0__A, sizeof(qam_dq_qual_fun), ((u8 *)qam_dq_qual_fun), 0);
6917 if (rc != 0) {
6918 pr_err("error %d\n", rc);
6919 goto rw_error;
6920 }
6921 rc = drxdap_fasi_write_block(dev_addr, SCU_RAM_QAM_EQ_CMA_RAD0__A, sizeof(qam_eq_cma_rad), ((u8 *)qam_eq_cma_rad), 0);
6922 if (rc != 0) {
6923 pr_err("error %d\n", rc);
6924 goto rw_error;
6925 }
6926
6927 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RTH__A, 90, 0);
6928 if (rc != 0) {
6929 pr_err("error %d\n", rc);
6930 goto rw_error;
6931 }
6932 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_FTH__A, 50, 0);
6933 if (rc != 0) {
6934 pr_err("error %d\n", rc);
6935 goto rw_error;
6936 }
6937 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_PTH__A, 100, 0);
6938 if (rc != 0) {
6939 pr_err("error %d\n", rc);
6940 goto rw_error;
6941 }
6942 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_QTH__A, 170, 0);
6943 if (rc != 0) {
6944 pr_err("error %d\n", rc);
6945 goto rw_error;
6946 }
6947 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_CTH__A, 80, 0);
6948 if (rc != 0) {
6949 pr_err("error %d\n", rc);
6950 goto rw_error;
6951 }
6952 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_MTH__A, 100, 0);
6953 if (rc != 0) {
6954 pr_err("error %d\n", rc);
6955 goto rw_error;
6956 }
6957
6958 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RATE_LIM__A, 40, 0);
6959 if (rc != 0) {
6960 pr_err("error %d\n", rc);
6961 goto rw_error;
6962 }
6963 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_FREQ_LIM__A, 56, 0);
6964 if (rc != 0) {
6965 pr_err("error %d\n", rc);
6966 goto rw_error;
6967 }
6968 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_COUNT_LIM__A, 3, 0);
6969 if (rc != 0) {
6970 pr_err("error %d\n", rc);
6971 goto rw_error;
6972 }
6973
6974 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A, 12, 0);
6975 if (rc != 0) {
6976 pr_err("error %d\n", rc);
6977 goto rw_error;
6978 }
6979 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A, 140, 0);
6980 if (rc != 0) {
6981 pr_err("error %d\n", rc);
6982 goto rw_error;
6983 }
6984 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A, (u16)(-8), 0);
6985 if (rc != 0) {
6986 pr_err("error %d\n", rc);
6987 goto rw_error;
6988 }
6989 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A, (u16)(-16), 0);
6990 if (rc != 0) {
6991 pr_err("error %d\n", rc);
6992 goto rw_error;
6993 }
6994 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A, (u16)(-26), 0);
6995 if (rc != 0) {
6996 pr_err("error %d\n", rc);
6997 goto rw_error;
6998 }
6999 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A, (u16)(-56), 0);
7000 if (rc != 0) {
7001 pr_err("error %d\n", rc);
7002 goto rw_error;
7003 }
7004 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A, (u16)(-86), 0);
7005 if (rc != 0) {
7006 pr_err("error %d\n", rc);
7007 goto rw_error;
7008 }
7009
7010 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CA_FINE__A, 15, 0);
7011 if (rc != 0) {
7012 pr_err("error %d\n", rc);
7013 goto rw_error;
7014 }
7015 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CA_COARSE__A, 40, 0);
7016 if (rc != 0) {
7017 pr_err("error %d\n", rc);
7018 goto rw_error;
7019 }
7020 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_FINE__A, 2, 0);
7021 if (rc != 0) {
7022 pr_err("error %d\n", rc);
7023 goto rw_error;
7024 }
7025 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_MEDIUM__A, 20, 0);
7026 if (rc != 0) {
7027 pr_err("error %d\n", rc);
7028 goto rw_error;
7029 }
7030 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_COARSE__A, 255, 0);
7031 if (rc != 0) {
7032 pr_err("error %d\n", rc);
7033 goto rw_error;
7034 }
7035 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_FINE__A, 2, 0);
7036 if (rc != 0) {
7037 pr_err("error %d\n", rc);
7038 goto rw_error;
7039 }
7040 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_MEDIUM__A, 10, 0);
7041 if (rc != 0) {
7042 pr_err("error %d\n", rc);
7043 goto rw_error;
7044 }
7045 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_COARSE__A, 50, 0);
7046 if (rc != 0) {
7047 pr_err("error %d\n", rc);
7048 goto rw_error;
7049 }
7050 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_FINE__A, 12, 0);
7051 if (rc != 0) {
7052 pr_err("error %d\n", rc);
7053 goto rw_error;
7054 }
7055 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_MEDIUM__A, 24, 0);
7056 if (rc != 0) {
7057 pr_err("error %d\n", rc);
7058 goto rw_error;
7059 }
7060 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_COARSE__A, 24, 0);
7061 if (rc != 0) {
7062 pr_err("error %d\n", rc);
7063 goto rw_error;
7064 }
7065 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_FINE__A, 12, 0);
7066 if (rc != 0) {
7067 pr_err("error %d\n", rc);
7068 goto rw_error;
7069 }
7070 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_MEDIUM__A, 16, 0);
7071 if (rc != 0) {
7072 pr_err("error %d\n", rc);
7073 goto rw_error;
7074 }
7075 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_COARSE__A, 16, 0);
7076 if (rc != 0) {
7077 pr_err("error %d\n", rc);
7078 goto rw_error;
7079 }
7080 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_FINE__A, 16, 0);
7081 if (rc != 0) {
7082 pr_err("error %d\n", rc);
7083 goto rw_error;
7084 }
7085 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_MEDIUM__A, 32, 0);
7086 if (rc != 0) {
7087 pr_err("error %d\n", rc);
7088 goto rw_error;
7089 }
7090 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_COARSE__A, 176, 0);
7091 if (rc != 0) {
7092 pr_err("error %d\n", rc);
7093 goto rw_error;
7094 }
7095 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_FINE__A, 5, 0);
7096 if (rc != 0) {
7097 pr_err("error %d\n", rc);
7098 goto rw_error;
7099 }
7100 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_MEDIUM__A, 15, 0);
7101 if (rc != 0) {
7102 pr_err("error %d\n", rc);
7103 goto rw_error;
7104 }
7105 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_COARSE__A, 8, 0);
7106 if (rc != 0) {
7107 pr_err("error %d\n", rc);
7108 goto rw_error;
7109 }
7110
7111 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_SL_SIG_POWER__A, 20480, 0);
7112 if (rc != 0) {
7113 pr_err("error %d\n", rc);
7114 goto rw_error;
7115 }
7116
7117 return 0;
7118rw_error:
7119 return -EIO;
7120}
7121
7122/*============================================================================*/
7123
7124/**
7125* \fn int set_qam64 ()
7126* \brief QAM64 specific setup
7127* \param demod instance of demod.
7128* \return int.
7129*/
7130static int set_qam64(struct drx_demod_instance *demod)
7131{
7132 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
7133 int rc;
7134 const u8 qam_dq_qual_fun[] = { /* this is hw reset value. no necessary to re-write */
7135 DRXJ_16TO8(4), /* fun0 */
7136 DRXJ_16TO8(4), /* fun1 */
7137 DRXJ_16TO8(4), /* fun2 */
7138 DRXJ_16TO8(4), /* fun3 */
7139 DRXJ_16TO8(6), /* fun4 */
7140 DRXJ_16TO8(6), /* fun5 */
7141 };
7142 const u8 qam_eq_cma_rad[] = {
7143 DRXJ_16TO8(13336), /* RAD0 */
7144 DRXJ_16TO8(12618), /* RAD1 */
7145 DRXJ_16TO8(11988), /* RAD2 */
7146 DRXJ_16TO8(13809), /* RAD3 */
7147 DRXJ_16TO8(13809), /* RAD4 */
7148 DRXJ_16TO8(15609), /* RAD5 */
7149 };
7150
7151 rc = drxdap_fasi_write_block(dev_addr, QAM_DQ_QUAL_FUN0__A, sizeof(qam_dq_qual_fun), ((u8 *)qam_dq_qual_fun), 0);
7152 if (rc != 0) {
7153 pr_err("error %d\n", rc);
7154 goto rw_error;
7155 }
7156 rc = drxdap_fasi_write_block(dev_addr, SCU_RAM_QAM_EQ_CMA_RAD0__A, sizeof(qam_eq_cma_rad), ((u8 *)qam_eq_cma_rad), 0);
7157 if (rc != 0) {
7158 pr_err("error %d\n", rc);
7159 goto rw_error;
7160 }
7161
7162 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RTH__A, 105, 0);
7163 if (rc != 0) {
7164 pr_err("error %d\n", rc);
7165 goto rw_error;
7166 }
7167 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_FTH__A, 60, 0);
7168 if (rc != 0) {
7169 pr_err("error %d\n", rc);
7170 goto rw_error;
7171 }
7172 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_PTH__A, 100, 0);
7173 if (rc != 0) {
7174 pr_err("error %d\n", rc);
7175 goto rw_error;
7176 }
7177 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_QTH__A, 195, 0);
7178 if (rc != 0) {
7179 pr_err("error %d\n", rc);
7180 goto rw_error;
7181 }
7182 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_CTH__A, 80, 0);
7183 if (rc != 0) {
7184 pr_err("error %d\n", rc);
7185 goto rw_error;
7186 }
7187 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_MTH__A, 84, 0);
7188 if (rc != 0) {
7189 pr_err("error %d\n", rc);
7190 goto rw_error;
7191 }
7192
7193 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RATE_LIM__A, 40, 0);
7194 if (rc != 0) {
7195 pr_err("error %d\n", rc);
7196 goto rw_error;
7197 }
7198 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_FREQ_LIM__A, 32, 0);
7199 if (rc != 0) {
7200 pr_err("error %d\n", rc);
7201 goto rw_error;
7202 }
7203 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_COUNT_LIM__A, 3, 0);
7204 if (rc != 0) {
7205 pr_err("error %d\n", rc);
7206 goto rw_error;
7207 }
7208
7209 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A, 12, 0);
7210 if (rc != 0) {
7211 pr_err("error %d\n", rc);
7212 goto rw_error;
7213 }
7214 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A, 141, 0);
7215 if (rc != 0) {
7216 pr_err("error %d\n", rc);
7217 goto rw_error;
7218 }
7219 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A, 7, 0);
7220 if (rc != 0) {
7221 pr_err("error %d\n", rc);
7222 goto rw_error;
7223 }
7224 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A, 0, 0);
7225 if (rc != 0) {
7226 pr_err("error %d\n", rc);
7227 goto rw_error;
7228 }
7229 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A, (u16)(-15), 0);
7230 if (rc != 0) {
7231 pr_err("error %d\n", rc);
7232 goto rw_error;
7233 }
7234 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A, (u16)(-45), 0);
7235 if (rc != 0) {
7236 pr_err("error %d\n", rc);
7237 goto rw_error;
7238 }
7239 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A, (u16)(-80), 0);
7240 if (rc != 0) {
7241 pr_err("error %d\n", rc);
7242 goto rw_error;
7243 }
7244
7245 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CA_FINE__A, 15, 0);
7246 if (rc != 0) {
7247 pr_err("error %d\n", rc);
7248 goto rw_error;
7249 }
7250 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CA_COARSE__A, 40, 0);
7251 if (rc != 0) {
7252 pr_err("error %d\n", rc);
7253 goto rw_error;
7254 }
7255 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_FINE__A, 2, 0);
7256 if (rc != 0) {
7257 pr_err("error %d\n", rc);
7258 goto rw_error;
7259 }
7260 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_MEDIUM__A, 30, 0);
7261 if (rc != 0) {
7262 pr_err("error %d\n", rc);
7263 goto rw_error;
7264 }
7265 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_COARSE__A, 255, 0);
7266 if (rc != 0) {
7267 pr_err("error %d\n", rc);
7268 goto rw_error;
7269 }
7270 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_FINE__A, 2, 0);
7271 if (rc != 0) {
7272 pr_err("error %d\n", rc);
7273 goto rw_error;
7274 }
7275 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_MEDIUM__A, 15, 0);
7276 if (rc != 0) {
7277 pr_err("error %d\n", rc);
7278 goto rw_error;
7279 }
7280 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_COARSE__A, 80, 0);
7281 if (rc != 0) {
7282 pr_err("error %d\n", rc);
7283 goto rw_error;
7284 }
7285 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_FINE__A, 12, 0);
7286 if (rc != 0) {
7287 pr_err("error %d\n", rc);
7288 goto rw_error;
7289 }
7290 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_MEDIUM__A, 24, 0);
7291 if (rc != 0) {
7292 pr_err("error %d\n", rc);
7293 goto rw_error;
7294 }
7295 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_COARSE__A, 24, 0);
7296 if (rc != 0) {
7297 pr_err("error %d\n", rc);
7298 goto rw_error;
7299 }
7300 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_FINE__A, 12, 0);
7301 if (rc != 0) {
7302 pr_err("error %d\n", rc);
7303 goto rw_error;
7304 }
7305 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_MEDIUM__A, 16, 0);
7306 if (rc != 0) {
7307 pr_err("error %d\n", rc);
7308 goto rw_error;
7309 }
7310 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_COARSE__A, 16, 0);
7311 if (rc != 0) {
7312 pr_err("error %d\n", rc);
7313 goto rw_error;
7314 }
7315 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_FINE__A, 16, 0);
7316 if (rc != 0) {
7317 pr_err("error %d\n", rc);
7318 goto rw_error;
7319 }
7320 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_MEDIUM__A, 48, 0);
7321 if (rc != 0) {
7322 pr_err("error %d\n", rc);
7323 goto rw_error;
7324 }
7325 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_COARSE__A, 160, 0);
7326 if (rc != 0) {
7327 pr_err("error %d\n", rc);
7328 goto rw_error;
7329 }
7330 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_FINE__A, 5, 0);
7331 if (rc != 0) {
7332 pr_err("error %d\n", rc);
7333 goto rw_error;
7334 }
7335 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_MEDIUM__A, 15, 0);
7336 if (rc != 0) {
7337 pr_err("error %d\n", rc);
7338 goto rw_error;
7339 }
7340 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_COARSE__A, 32, 0);
7341 if (rc != 0) {
7342 pr_err("error %d\n", rc);
7343 goto rw_error;
7344 }
7345
7346 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_SL_SIG_POWER__A, 43008, 0);
7347 if (rc != 0) {
7348 pr_err("error %d\n", rc);
7349 goto rw_error;
7350 }
7351
7352 return 0;
7353rw_error:
7354 return -EIO;
7355}
7356
7357/*============================================================================*/
7358
7359/**
7360* \fn int set_qam128 ()
7361* \brief QAM128 specific setup
7362* \param demod: instance of demod.
7363* \return int.
7364*/
7365static int set_qam128(struct drx_demod_instance *demod)
7366{
7367 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
7368 int rc;
7369 const u8 qam_dq_qual_fun[] = {
7370 DRXJ_16TO8(6), /* fun0 */
7371 DRXJ_16TO8(6), /* fun1 */
7372 DRXJ_16TO8(6), /* fun2 */
7373 DRXJ_16TO8(6), /* fun3 */
7374 DRXJ_16TO8(9), /* fun4 */
7375 DRXJ_16TO8(9), /* fun5 */
7376 };
7377 const u8 qam_eq_cma_rad[] = {
7378 DRXJ_16TO8(6164), /* RAD0 */
7379 DRXJ_16TO8(6598), /* RAD1 */
7380 DRXJ_16TO8(6394), /* RAD2 */
7381 DRXJ_16TO8(6409), /* RAD3 */
7382 DRXJ_16TO8(6656), /* RAD4 */
7383 DRXJ_16TO8(7238), /* RAD5 */
7384 };
7385
7386 rc = drxdap_fasi_write_block(dev_addr, QAM_DQ_QUAL_FUN0__A, sizeof(qam_dq_qual_fun), ((u8 *)qam_dq_qual_fun), 0);
7387 if (rc != 0) {
7388 pr_err("error %d\n", rc);
7389 goto rw_error;
7390 }
7391 rc = drxdap_fasi_write_block(dev_addr, SCU_RAM_QAM_EQ_CMA_RAD0__A, sizeof(qam_eq_cma_rad), ((u8 *)qam_eq_cma_rad), 0);
7392 if (rc != 0) {
7393 pr_err("error %d\n", rc);
7394 goto rw_error;
7395 }
7396
7397 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RTH__A, 50, 0);
7398 if (rc != 0) {
7399 pr_err("error %d\n", rc);
7400 goto rw_error;
7401 }
7402 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_FTH__A, 60, 0);
7403 if (rc != 0) {
7404 pr_err("error %d\n", rc);
7405 goto rw_error;
7406 }
7407 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_PTH__A, 100, 0);
7408 if (rc != 0) {
7409 pr_err("error %d\n", rc);
7410 goto rw_error;
7411 }
7412 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_QTH__A, 140, 0);
7413 if (rc != 0) {
7414 pr_err("error %d\n", rc);
7415 goto rw_error;
7416 }
7417 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_CTH__A, 80, 0);
7418 if (rc != 0) {
7419 pr_err("error %d\n", rc);
7420 goto rw_error;
7421 }
7422 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_MTH__A, 100, 0);
7423 if (rc != 0) {
7424 pr_err("error %d\n", rc);
7425 goto rw_error;
7426 }
7427
7428 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RATE_LIM__A, 40, 0);
7429 if (rc != 0) {
7430 pr_err("error %d\n", rc);
7431 goto rw_error;
7432 }
7433 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_FREQ_LIM__A, 32, 0);
7434 if (rc != 0) {
7435 pr_err("error %d\n", rc);
7436 goto rw_error;
7437 }
7438 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_COUNT_LIM__A, 3, 0);
7439 if (rc != 0) {
7440 pr_err("error %d\n", rc);
7441 goto rw_error;
7442 }
7443
7444 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A, 8, 0);
7445 if (rc != 0) {
7446 pr_err("error %d\n", rc);
7447 goto rw_error;
7448 }
7449 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A, 65, 0);
7450 if (rc != 0) {
7451 pr_err("error %d\n", rc);
7452 goto rw_error;
7453 }
7454 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A, 5, 0);
7455 if (rc != 0) {
7456 pr_err("error %d\n", rc);
7457 goto rw_error;
7458 }
7459 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A, 3, 0);
7460 if (rc != 0) {
7461 pr_err("error %d\n", rc);
7462 goto rw_error;
7463 }
7464 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A, (u16)(-1), 0);
7465 if (rc != 0) {
7466 pr_err("error %d\n", rc);
7467 goto rw_error;
7468 }
7469 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A, 12, 0);
7470 if (rc != 0) {
7471 pr_err("error %d\n", rc);
7472 goto rw_error;
7473 }
7474 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A, (u16)(-23), 0);
7475 if (rc != 0) {
7476 pr_err("error %d\n", rc);
7477 goto rw_error;
7478 }
7479
7480 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CA_FINE__A, 15, 0);
7481 if (rc != 0) {
7482 pr_err("error %d\n", rc);
7483 goto rw_error;
7484 }
7485 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CA_COARSE__A, 40, 0);
7486 if (rc != 0) {
7487 pr_err("error %d\n", rc);
7488 goto rw_error;
7489 }
7490 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_FINE__A, 2, 0);
7491 if (rc != 0) {
7492 pr_err("error %d\n", rc);
7493 goto rw_error;
7494 }
7495 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_MEDIUM__A, 40, 0);
7496 if (rc != 0) {
7497 pr_err("error %d\n", rc);
7498 goto rw_error;
7499 }
7500 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_COARSE__A, 255, 0);
7501 if (rc != 0) {
7502 pr_err("error %d\n", rc);
7503 goto rw_error;
7504 }
7505 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_FINE__A, 2, 0);
7506 if (rc != 0) {
7507 pr_err("error %d\n", rc);
7508 goto rw_error;
7509 }
7510 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_MEDIUM__A, 20, 0);
7511 if (rc != 0) {
7512 pr_err("error %d\n", rc);
7513 goto rw_error;
7514 }
7515 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_COARSE__A, 80, 0);
7516 if (rc != 0) {
7517 pr_err("error %d\n", rc);
7518 goto rw_error;
7519 }
7520 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_FINE__A, 12, 0);
7521 if (rc != 0) {
7522 pr_err("error %d\n", rc);
7523 goto rw_error;
7524 }
7525 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_MEDIUM__A, 24, 0);
7526 if (rc != 0) {
7527 pr_err("error %d\n", rc);
7528 goto rw_error;
7529 }
7530 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_COARSE__A, 24, 0);
7531 if (rc != 0) {
7532 pr_err("error %d\n", rc);
7533 goto rw_error;
7534 }
7535 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_FINE__A, 12, 0);
7536 if (rc != 0) {
7537 pr_err("error %d\n", rc);
7538 goto rw_error;
7539 }
7540 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_MEDIUM__A, 16, 0);
7541 if (rc != 0) {
7542 pr_err("error %d\n", rc);
7543 goto rw_error;
7544 }
7545 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_COARSE__A, 16, 0);
7546 if (rc != 0) {
7547 pr_err("error %d\n", rc);
7548 goto rw_error;
7549 }
7550 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_FINE__A, 16, 0);
7551 if (rc != 0) {
7552 pr_err("error %d\n", rc);
7553 goto rw_error;
7554 }
7555 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_MEDIUM__A, 32, 0);
7556 if (rc != 0) {
7557 pr_err("error %d\n", rc);
7558 goto rw_error;
7559 }
7560 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_COARSE__A, 144, 0);
7561 if (rc != 0) {
7562 pr_err("error %d\n", rc);
7563 goto rw_error;
7564 }
7565 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_FINE__A, 5, 0);
7566 if (rc != 0) {
7567 pr_err("error %d\n", rc);
7568 goto rw_error;
7569 }
7570 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_MEDIUM__A, 15, 0);
7571 if (rc != 0) {
7572 pr_err("error %d\n", rc);
7573 goto rw_error;
7574 }
7575 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_COARSE__A, 16, 0);
7576 if (rc != 0) {
7577 pr_err("error %d\n", rc);
7578 goto rw_error;
7579 }
7580
7581 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_SL_SIG_POWER__A, 20992, 0);
7582 if (rc != 0) {
7583 pr_err("error %d\n", rc);
7584 goto rw_error;
7585 }
7586
7587 return 0;
7588rw_error:
7589 return -EIO;
7590}
7591
7592/*============================================================================*/
7593
7594/**
7595* \fn int set_qam256 ()
7596* \brief QAM256 specific setup
7597* \param demod: instance of demod.
7598* \return int.
7599*/
7600static int set_qam256(struct drx_demod_instance *demod)
7601{
7602 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
7603 int rc;
7604 const u8 qam_dq_qual_fun[] = {
7605 DRXJ_16TO8(8), /* fun0 */
7606 DRXJ_16TO8(8), /* fun1 */
7607 DRXJ_16TO8(8), /* fun2 */
7608 DRXJ_16TO8(8), /* fun3 */
7609 DRXJ_16TO8(12), /* fun4 */
7610 DRXJ_16TO8(12), /* fun5 */
7611 };
7612 const u8 qam_eq_cma_rad[] = {
7613 DRXJ_16TO8(12345), /* RAD0 */
7614 DRXJ_16TO8(12345), /* RAD1 */
7615 DRXJ_16TO8(13626), /* RAD2 */
7616 DRXJ_16TO8(12931), /* RAD3 */
7617 DRXJ_16TO8(14719), /* RAD4 */
7618 DRXJ_16TO8(15356), /* RAD5 */
7619 };
7620
7621 rc = drxdap_fasi_write_block(dev_addr, QAM_DQ_QUAL_FUN0__A, sizeof(qam_dq_qual_fun), ((u8 *)qam_dq_qual_fun), 0);
7622 if (rc != 0) {
7623 pr_err("error %d\n", rc);
7624 goto rw_error;
7625 }
7626 rc = drxdap_fasi_write_block(dev_addr, SCU_RAM_QAM_EQ_CMA_RAD0__A, sizeof(qam_eq_cma_rad), ((u8 *)qam_eq_cma_rad), 0);
7627 if (rc != 0) {
7628 pr_err("error %d\n", rc);
7629 goto rw_error;
7630 }
7631
7632 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RTH__A, 50, 0);
7633 if (rc != 0) {
7634 pr_err("error %d\n", rc);
7635 goto rw_error;
7636 }
7637 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_FTH__A, 60, 0);
7638 if (rc != 0) {
7639 pr_err("error %d\n", rc);
7640 goto rw_error;
7641 }
7642 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_PTH__A, 100, 0);
7643 if (rc != 0) {
7644 pr_err("error %d\n", rc);
7645 goto rw_error;
7646 }
7647 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_QTH__A, 150, 0);
7648 if (rc != 0) {
7649 pr_err("error %d\n", rc);
7650 goto rw_error;
7651 }
7652 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_CTH__A, 80, 0);
7653 if (rc != 0) {
7654 pr_err("error %d\n", rc);
7655 goto rw_error;
7656 }
7657 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_MTH__A, 110, 0);
7658 if (rc != 0) {
7659 pr_err("error %d\n", rc);
7660 goto rw_error;
7661 }
7662
7663 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RATE_LIM__A, 40, 0);
7664 if (rc != 0) {
7665 pr_err("error %d\n", rc);
7666 goto rw_error;
7667 }
7668 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_FREQ_LIM__A, 16, 0);
7669 if (rc != 0) {
7670 pr_err("error %d\n", rc);
7671 goto rw_error;
7672 }
7673 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_COUNT_LIM__A, 3, 0);
7674 if (rc != 0) {
7675 pr_err("error %d\n", rc);
7676 goto rw_error;
7677 }
7678
7679 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A, 8, 0);
7680 if (rc != 0) {
7681 pr_err("error %d\n", rc);
7682 goto rw_error;
7683 }
7684 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A, 74, 0);
7685 if (rc != 0) {
7686 pr_err("error %d\n", rc);
7687 goto rw_error;
7688 }
7689 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A, 18, 0);
7690 if (rc != 0) {
7691 pr_err("error %d\n", rc);
7692 goto rw_error;
7693 }
7694 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A, 13, 0);
7695 if (rc != 0) {
7696 pr_err("error %d\n", rc);
7697 goto rw_error;
7698 }
7699 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A, 7, 0);
7700 if (rc != 0) {
7701 pr_err("error %d\n", rc);
7702 goto rw_error;
7703 }
7704 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A, 0, 0);
7705 if (rc != 0) {
7706 pr_err("error %d\n", rc);
7707 goto rw_error;
7708 }
7709 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A, (u16)(-8), 0);
7710 if (rc != 0) {
7711 pr_err("error %d\n", rc);
7712 goto rw_error;
7713 }
7714
7715 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CA_FINE__A, 15, 0);
7716 if (rc != 0) {
7717 pr_err("error %d\n", rc);
7718 goto rw_error;
7719 }
7720 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CA_COARSE__A, 40, 0);
7721 if (rc != 0) {
7722 pr_err("error %d\n", rc);
7723 goto rw_error;
7724 }
7725 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_FINE__A, 2, 0);
7726 if (rc != 0) {
7727 pr_err("error %d\n", rc);
7728 goto rw_error;
7729 }
7730 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_MEDIUM__A, 50, 0);
7731 if (rc != 0) {
7732 pr_err("error %d\n", rc);
7733 goto rw_error;
7734 }
7735 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CP_COARSE__A, 255, 0);
7736 if (rc != 0) {
7737 pr_err("error %d\n", rc);
7738 goto rw_error;
7739 }
7740 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_FINE__A, 2, 0);
7741 if (rc != 0) {
7742 pr_err("error %d\n", rc);
7743 goto rw_error;
7744 }
7745 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_MEDIUM__A, 25, 0);
7746 if (rc != 0) {
7747 pr_err("error %d\n", rc);
7748 goto rw_error;
7749 }
7750 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CI_COARSE__A, 80, 0);
7751 if (rc != 0) {
7752 pr_err("error %d\n", rc);
7753 goto rw_error;
7754 }
7755 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_FINE__A, 12, 0);
7756 if (rc != 0) {
7757 pr_err("error %d\n", rc);
7758 goto rw_error;
7759 }
7760 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_MEDIUM__A, 24, 0);
7761 if (rc != 0) {
7762 pr_err("error %d\n", rc);
7763 goto rw_error;
7764 }
7765 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EP_COARSE__A, 24, 0);
7766 if (rc != 0) {
7767 pr_err("error %d\n", rc);
7768 goto rw_error;
7769 }
7770 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_FINE__A, 12, 0);
7771 if (rc != 0) {
7772 pr_err("error %d\n", rc);
7773 goto rw_error;
7774 }
7775 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_MEDIUM__A, 16, 0);
7776 if (rc != 0) {
7777 pr_err("error %d\n", rc);
7778 goto rw_error;
7779 }
7780 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_EI_COARSE__A, 16, 0);
7781 if (rc != 0) {
7782 pr_err("error %d\n", rc);
7783 goto rw_error;
7784 }
7785 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_FINE__A, 16, 0);
7786 if (rc != 0) {
7787 pr_err("error %d\n", rc);
7788 goto rw_error;
7789 }
7790 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_MEDIUM__A, 48, 0);
7791 if (rc != 0) {
7792 pr_err("error %d\n", rc);
7793 goto rw_error;
7794 }
7795 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF_COARSE__A, 80, 0);
7796 if (rc != 0) {
7797 pr_err("error %d\n", rc);
7798 goto rw_error;
7799 }
7800 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_FINE__A, 5, 0);
7801 if (rc != 0) {
7802 pr_err("error %d\n", rc);
7803 goto rw_error;
7804 }
7805 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_MEDIUM__A, 15, 0);
7806 if (rc != 0) {
7807 pr_err("error %d\n", rc);
7808 goto rw_error;
7809 }
7810 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_LC_CF1_COARSE__A, 16, 0);
7811 if (rc != 0) {
7812 pr_err("error %d\n", rc);
7813 goto rw_error;
7814 }
7815
7816 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_SL_SIG_POWER__A, 43520, 0);
7817 if (rc != 0) {
7818 pr_err("error %d\n", rc);
7819 goto rw_error;
7820 }
7821
7822 return 0;
7823rw_error:
7824 return -EIO;
7825}
7826
7827/*============================================================================*/
7828#define QAM_SET_OP_ALL 0x1
7829#define QAM_SET_OP_CONSTELLATION 0x2
7830#define QAM_SET_OP_SPECTRUM 0X4
7831
7832/**
7833* \fn int set_qam ()
7834* \brief Set QAM demod.
7835* \param demod: instance of demod.
7836* \param channel: pointer to channel data.
7837* \return int.
7838*/
7839static int
7840set_qam(struct drx_demod_instance *demod,
7841 struct drx_channel *channel, s32 tuner_freq_offset, u32 op)
7842{
7843 struct i2c_device_addr *dev_addr = NULL;
7844 struct drxj_data *ext_attr = NULL;
7845 struct drx_common_attr *common_attr = NULL;
7846 int rc;
7847 u32 adc_frequency = 0;
7848 u32 iqm_rc_rate = 0;
7849 u16 cmd_result = 0;
7850 u16 lc_symbol_freq = 0;
7851 u16 iqm_rc_stretch = 0;
7852 u16 set_env_parameters = 0;
7853 u16 set_param_parameters[2] = { 0 };
7854 struct drxjscu_cmd cmd_scu = { /* command */ 0,
7855 /* parameter_len */ 0,
7856 /* result_len */ 0,
7857 /* parameter */ NULL,
7858 /* result */ NULL
7859 };
7860 const u8 qam_a_taps[] = {
7861 DRXJ_16TO8(-1), /* re0 */
7862 DRXJ_16TO8(1), /* re1 */
7863 DRXJ_16TO8(1), /* re2 */
7864 DRXJ_16TO8(-1), /* re3 */
7865 DRXJ_16TO8(-1), /* re4 */
7866 DRXJ_16TO8(2), /* re5 */
7867 DRXJ_16TO8(1), /* re6 */
7868 DRXJ_16TO8(-2), /* re7 */
7869 DRXJ_16TO8(0), /* re8 */
7870 DRXJ_16TO8(3), /* re9 */
7871 DRXJ_16TO8(-1), /* re10 */
7872 DRXJ_16TO8(-3), /* re11 */
7873 DRXJ_16TO8(4), /* re12 */
7874 DRXJ_16TO8(1), /* re13 */
7875 DRXJ_16TO8(-8), /* re14 */
7876 DRXJ_16TO8(4), /* re15 */
7877 DRXJ_16TO8(13), /* re16 */
7878 DRXJ_16TO8(-13), /* re17 */
7879 DRXJ_16TO8(-19), /* re18 */
7880 DRXJ_16TO8(28), /* re19 */
7881 DRXJ_16TO8(25), /* re20 */
7882 DRXJ_16TO8(-53), /* re21 */
7883 DRXJ_16TO8(-31), /* re22 */
7884 DRXJ_16TO8(96), /* re23 */
7885 DRXJ_16TO8(37), /* re24 */
7886 DRXJ_16TO8(-190), /* re25 */
7887 DRXJ_16TO8(-40), /* re26 */
7888 DRXJ_16TO8(619) /* re27 */
7889 };
7890 const u8 qam_b64_taps[] = {
7891 DRXJ_16TO8(0), /* re0 */
7892 DRXJ_16TO8(-2), /* re1 */
7893 DRXJ_16TO8(1), /* re2 */
7894 DRXJ_16TO8(2), /* re3 */
7895 DRXJ_16TO8(-2), /* re4 */
7896 DRXJ_16TO8(0), /* re5 */
7897 DRXJ_16TO8(4), /* re6 */
7898 DRXJ_16TO8(-2), /* re7 */
7899 DRXJ_16TO8(-4), /* re8 */
7900 DRXJ_16TO8(4), /* re9 */
7901 DRXJ_16TO8(3), /* re10 */
7902 DRXJ_16TO8(-6), /* re11 */
7903 DRXJ_16TO8(0), /* re12 */
7904 DRXJ_16TO8(6), /* re13 */
7905 DRXJ_16TO8(-5), /* re14 */
7906 DRXJ_16TO8(-3), /* re15 */
7907 DRXJ_16TO8(11), /* re16 */
7908 DRXJ_16TO8(-4), /* re17 */
7909 DRXJ_16TO8(-19), /* re18 */
7910 DRXJ_16TO8(19), /* re19 */
7911 DRXJ_16TO8(28), /* re20 */
7912 DRXJ_16TO8(-45), /* re21 */
7913 DRXJ_16TO8(-36), /* re22 */
7914 DRXJ_16TO8(90), /* re23 */
7915 DRXJ_16TO8(42), /* re24 */
7916 DRXJ_16TO8(-185), /* re25 */
7917 DRXJ_16TO8(-46), /* re26 */
7918 DRXJ_16TO8(614) /* re27 */
7919 };
7920 const u8 qam_b256_taps[] = {
7921 DRXJ_16TO8(-2), /* re0 */
7922 DRXJ_16TO8(4), /* re1 */
7923 DRXJ_16TO8(1), /* re2 */
7924 DRXJ_16TO8(-4), /* re3 */
7925 DRXJ_16TO8(0), /* re4 */
7926 DRXJ_16TO8(4), /* re5 */
7927 DRXJ_16TO8(-2), /* re6 */
7928 DRXJ_16TO8(-4), /* re7 */
7929 DRXJ_16TO8(5), /* re8 */
7930 DRXJ_16TO8(2), /* re9 */
7931 DRXJ_16TO8(-8), /* re10 */
7932 DRXJ_16TO8(2), /* re11 */
7933 DRXJ_16TO8(11), /* re12 */
7934 DRXJ_16TO8(-8), /* re13 */
7935 DRXJ_16TO8(-15), /* re14 */
7936 DRXJ_16TO8(16), /* re15 */
7937 DRXJ_16TO8(19), /* re16 */
7938 DRXJ_16TO8(-27), /* re17 */
7939 DRXJ_16TO8(-22), /* re18 */
7940 DRXJ_16TO8(44), /* re19 */
7941 DRXJ_16TO8(26), /* re20 */
7942 DRXJ_16TO8(-69), /* re21 */
7943 DRXJ_16TO8(-28), /* re22 */
7944 DRXJ_16TO8(110), /* re23 */
7945 DRXJ_16TO8(31), /* re24 */
7946 DRXJ_16TO8(-201), /* re25 */
7947 DRXJ_16TO8(-32), /* re26 */
7948 DRXJ_16TO8(628) /* re27 */
7949 };
7950 const u8 qam_c_taps[] = {
7951 DRXJ_16TO8(-3), /* re0 */
7952 DRXJ_16TO8(3), /* re1 */
7953 DRXJ_16TO8(2), /* re2 */
7954 DRXJ_16TO8(-4), /* re3 */
7955 DRXJ_16TO8(0), /* re4 */
7956 DRXJ_16TO8(4), /* re5 */
7957 DRXJ_16TO8(-1), /* re6 */
7958 DRXJ_16TO8(-4), /* re7 */
7959 DRXJ_16TO8(3), /* re8 */
7960 DRXJ_16TO8(3), /* re9 */
7961 DRXJ_16TO8(-5), /* re10 */
7962 DRXJ_16TO8(0), /* re11 */
7963 DRXJ_16TO8(9), /* re12 */
7964 DRXJ_16TO8(-4), /* re13 */
7965 DRXJ_16TO8(-12), /* re14 */
7966 DRXJ_16TO8(10), /* re15 */
7967 DRXJ_16TO8(16), /* re16 */
7968 DRXJ_16TO8(-21), /* re17 */
7969 DRXJ_16TO8(-20), /* re18 */
7970 DRXJ_16TO8(37), /* re19 */
7971 DRXJ_16TO8(25), /* re20 */
7972 DRXJ_16TO8(-62), /* re21 */
7973 DRXJ_16TO8(-28), /* re22 */
7974 DRXJ_16TO8(105), /* re23 */
7975 DRXJ_16TO8(31), /* re24 */
7976 DRXJ_16TO8(-197), /* re25 */
7977 DRXJ_16TO8(-33), /* re26 */
7978 DRXJ_16TO8(626) /* re27 */
7979 };
7980
7981 dev_addr = demod->my_i2c_dev_addr;
7982 ext_attr = (struct drxj_data *) demod->my_ext_attr;
7983 common_attr = (struct drx_common_attr *) demod->my_common_attr;
7984
7985 if ((op & QAM_SET_OP_ALL) || (op & QAM_SET_OP_CONSTELLATION)) {
7986 if (ext_attr->standard == DRX_STANDARD_ITU_B) {
7987 switch (channel->constellation) {
7988 case DRX_CONSTELLATION_QAM256:
7989 iqm_rc_rate = 0x00AE3562;
7990 lc_symbol_freq =
7991 QAM_LC_SYMBOL_FREQ_FREQ_QAM_B_256;
7992 channel->symbolrate = 5360537;
7993 iqm_rc_stretch = IQM_RC_STRETCH_QAM_B_256;
7994 break;
7995 case DRX_CONSTELLATION_QAM64:
7996 iqm_rc_rate = 0x00C05A0E;
7997 lc_symbol_freq = 409;
7998 channel->symbolrate = 5056941;
7999 iqm_rc_stretch = IQM_RC_STRETCH_QAM_B_64;
8000 break;
8001 default:
8002 return -EINVAL;
8003 }
8004 } else {
8005 adc_frequency = (common_attr->sys_clock_freq * 1000) / 3;
8006 if (channel->symbolrate == 0) {
8007 pr_err("error: channel symbolrate is zero!\n");
8008 return -EIO;
8009 }
8010 iqm_rc_rate =
8011 (adc_frequency / channel->symbolrate) * (1 << 21) +
8012 (frac28
8013 ((adc_frequency % channel->symbolrate),
8014 channel->symbolrate) >> 7) - (1 << 23);
8015 lc_symbol_freq =
8016 (u16) (frac28
8017 (channel->symbolrate +
8018 (adc_frequency >> 13),
8019 adc_frequency) >> 16);
8020 if (lc_symbol_freq > 511)
8021 lc_symbol_freq = 511;
8022
8023 iqm_rc_stretch = 21;
8024 }
8025
8026 if (ext_attr->standard == DRX_STANDARD_ITU_A) {
8027 set_env_parameters = QAM_TOP_ANNEX_A; /* annex */
8028 set_param_parameters[0] = channel->constellation; /* constellation */
8029 set_param_parameters[1] = DRX_INTERLEAVEMODE_I12_J17; /* interleave mode */
8030 } else if (ext_attr->standard == DRX_STANDARD_ITU_B) {
8031 set_env_parameters = QAM_TOP_ANNEX_B; /* annex */
8032 set_param_parameters[0] = channel->constellation; /* constellation */
8033 set_param_parameters[1] = channel->interleavemode; /* interleave mode */
8034 } else if (ext_attr->standard == DRX_STANDARD_ITU_C) {
8035 set_env_parameters = QAM_TOP_ANNEX_C; /* annex */
8036 set_param_parameters[0] = channel->constellation; /* constellation */
8037 set_param_parameters[1] = DRX_INTERLEAVEMODE_I12_J17; /* interleave mode */
8038 } else {
8039 return -EINVAL;
8040 }
8041 }
8042
8043 if (op & QAM_SET_OP_ALL) {
8044 /*
8045 STEP 1: reset demodulator
8046 resets IQM, QAM and FEC HW blocks
8047 resets SCU variables
8048 */
8049 /* stop all comm_exec */
8050 rc = drxj_dap_write_reg16(dev_addr, FEC_COMM_EXEC__A, FEC_COMM_EXEC_STOP, 0);
8051 if (rc != 0) {
8052 pr_err("error %d\n", rc);
8053 goto rw_error;
8054 }
8055 rc = drxj_dap_write_reg16(dev_addr, QAM_COMM_EXEC__A, QAM_COMM_EXEC_STOP, 0);
8056 if (rc != 0) {
8057 pr_err("error %d\n", rc);
8058 goto rw_error;
8059 }
8060 rc = drxj_dap_write_reg16(dev_addr, IQM_FS_COMM_EXEC__A, IQM_FS_COMM_EXEC_STOP, 0);
8061 if (rc != 0) {
8062 pr_err("error %d\n", rc);
8063 goto rw_error;
8064 }
8065 rc = drxj_dap_write_reg16(dev_addr, IQM_FD_COMM_EXEC__A, IQM_FD_COMM_EXEC_STOP, 0);
8066 if (rc != 0) {
8067 pr_err("error %d\n", rc);
8068 goto rw_error;
8069 }
8070 rc = drxj_dap_write_reg16(dev_addr, IQM_RC_COMM_EXEC__A, IQM_RC_COMM_EXEC_STOP, 0);
8071 if (rc != 0) {
8072 pr_err("error %d\n", rc);
8073 goto rw_error;
8074 }
8075 rc = drxj_dap_write_reg16(dev_addr, IQM_RT_COMM_EXEC__A, IQM_RT_COMM_EXEC_STOP, 0);
8076 if (rc != 0) {
8077 pr_err("error %d\n", rc);
8078 goto rw_error;
8079 }
8080 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_COMM_EXEC__A, IQM_CF_COMM_EXEC_STOP, 0);
8081 if (rc != 0) {
8082 pr_err("error %d\n", rc);
8083 goto rw_error;
8084 }
8085
8086 cmd_scu.command = SCU_RAM_COMMAND_STANDARD_QAM |
8087 SCU_RAM_COMMAND_CMD_DEMOD_RESET;
8088 cmd_scu.parameter_len = 0;
8089 cmd_scu.result_len = 1;
8090 cmd_scu.parameter = NULL;
8091 cmd_scu.result = &cmd_result;
8092 rc = scu_command(dev_addr, &cmd_scu);
8093 if (rc != 0) {
8094 pr_err("error %d\n", rc);
8095 goto rw_error;
8096 }
8097 }
8098
8099 if ((op & QAM_SET_OP_ALL) || (op & QAM_SET_OP_CONSTELLATION)) {
8100 /*
8101 STEP 2: configure demodulator
8102 -set env
8103 -set params (resets IQM,QAM,FEC HW; initializes some SCU variables )
8104 */
8105 cmd_scu.command = SCU_RAM_COMMAND_STANDARD_QAM |
8106 SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV;
8107 cmd_scu.parameter_len = 1;
8108 cmd_scu.result_len = 1;
8109 cmd_scu.parameter = &set_env_parameters;
8110 cmd_scu.result = &cmd_result;
8111 rc = scu_command(dev_addr, &cmd_scu);
8112 if (rc != 0) {
8113 pr_err("error %d\n", rc);
8114 goto rw_error;
8115 }
8116
8117 cmd_scu.command = SCU_RAM_COMMAND_STANDARD_QAM |
8118 SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM;
8119 cmd_scu.parameter_len = 2;
8120 cmd_scu.result_len = 1;
8121 cmd_scu.parameter = set_param_parameters;
8122 cmd_scu.result = &cmd_result;
8123 rc = scu_command(dev_addr, &cmd_scu);
8124 if (rc != 0) {
8125 pr_err("error %d\n", rc);
8126 goto rw_error;
8127 }
8128 /* set symbol rate */
8129 rc = drxdap_fasi_write_reg32(dev_addr, IQM_RC_RATE_OFS_LO__A, iqm_rc_rate, 0);
8130 if (rc != 0) {
8131 pr_err("error %d\n", rc);
8132 goto rw_error;
8133 }
8134 ext_attr->iqm_rc_rate_ofs = iqm_rc_rate;
8135 rc = set_qam_measurement(demod, channel->constellation, channel->symbolrate);
8136 if (rc != 0) {
8137 pr_err("error %d\n", rc);
8138 goto rw_error;
8139 }
8140 }
8141 /* STEP 3: enable the system in a mode where the ADC provides valid signal
8142 setup constellation independent registers */
8143 /* from qam_cmd.py script (qam_driver_b) */
8144 /* TODO: remove re-writes of HW reset values */
8145 if ((op & QAM_SET_OP_ALL) || (op & QAM_SET_OP_SPECTRUM)) {
8146 rc = set_frequency(demod, channel, tuner_freq_offset);
8147 if (rc != 0) {
8148 pr_err("error %d\n", rc);
8149 goto rw_error;
8150 }
8151 }
8152
8153 if ((op & QAM_SET_OP_ALL) || (op & QAM_SET_OP_CONSTELLATION)) {
8154
8155 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_SYMBOL_FREQ__A, lc_symbol_freq, 0);
8156 if (rc != 0) {
8157 pr_err("error %d\n", rc);
8158 goto rw_error;
8159 }
8160 rc = drxj_dap_write_reg16(dev_addr, IQM_RC_STRETCH__A, iqm_rc_stretch, 0);
8161 if (rc != 0) {
8162 pr_err("error %d\n", rc);
8163 goto rw_error;
8164 }
8165 }
8166
8167 if (op & QAM_SET_OP_ALL) {
8168 if (!ext_attr->has_lna) {
8169 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_AMUX__A, 0x02, 0);
8170 if (rc != 0) {
8171 pr_err("error %d\n", rc);
8172 goto rw_error;
8173 }
8174 }
8175 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_SYMMETRIC__A, 0, 0);
8176 if (rc != 0) {
8177 pr_err("error %d\n", rc);
8178 goto rw_error;
8179 }
8180 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_MIDTAP__A, 3, 0);
8181 if (rc != 0) {
8182 pr_err("error %d\n", rc);
8183 goto rw_error;
8184 }
8185 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_OUT_ENA__A, IQM_CF_OUT_ENA_QAM__M, 0);
8186 if (rc != 0) {
8187 pr_err("error %d\n", rc);
8188 goto rw_error;
8189 }
8190
8191 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_WR_RSV_0__A, 0x5f, 0);
8192 if (rc != 0) {
8193 pr_err("error %d\n", rc);
8194 goto rw_error;
8195 } /* scu temporary shut down agc */
8196
8197 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_SYNC_SEL__A, 3, 0);
8198 if (rc != 0) {
8199 pr_err("error %d\n", rc);
8200 goto rw_error;
8201 }
8202 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_CLP_LEN__A, 0, 0);
8203 if (rc != 0) {
8204 pr_err("error %d\n", rc);
8205 goto rw_error;
8206 }
8207 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_CLP_TH__A, 448, 0);
8208 if (rc != 0) {
8209 pr_err("error %d\n", rc);
8210 goto rw_error;
8211 }
8212 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_SNS_LEN__A, 0, 0);
8213 if (rc != 0) {
8214 pr_err("error %d\n", rc);
8215 goto rw_error;
8216 }
8217 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_PDREF__A, 4, 0);
8218 if (rc != 0) {
8219 pr_err("error %d\n", rc);
8220 goto rw_error;
8221 }
8222 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_STDBY__A, 0x10, 0);
8223 if (rc != 0) {
8224 pr_err("error %d\n", rc);
8225 goto rw_error;
8226 }
8227 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_PGA_GAIN__A, 11, 0);
8228 if (rc != 0) {
8229 pr_err("error %d\n", rc);
8230 goto rw_error;
8231 }
8232
8233 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_POW_MEAS_LEN__A, 1, 0);
8234 if (rc != 0) {
8235 pr_err("error %d\n", rc);
8236 goto rw_error;
8237 }
8238 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_SCALE_SH__A, IQM_CF_SCALE_SH__PRE, 0);
8239 if (rc != 0) {
8240 pr_err("error %d\n", rc);
8241 goto rw_error;
8242 } /*! reset default val ! */
8243
8244 rc = drxj_dap_write_reg16(dev_addr, QAM_SY_TIMEOUT__A, QAM_SY_TIMEOUT__PRE, 0);
8245 if (rc != 0) {
8246 pr_err("error %d\n", rc);
8247 goto rw_error;
8248 } /*! reset default val ! */
8249 if (ext_attr->standard == DRX_STANDARD_ITU_B) {
8250 rc = drxj_dap_write_reg16(dev_addr, QAM_SY_SYNC_LWM__A, QAM_SY_SYNC_LWM__PRE, 0);
8251 if (rc != 0) {
8252 pr_err("error %d\n", rc);
8253 goto rw_error;
8254 } /*! reset default val ! */
8255 rc = drxj_dap_write_reg16(dev_addr, QAM_SY_SYNC_AWM__A, QAM_SY_SYNC_AWM__PRE, 0);
8256 if (rc != 0) {
8257 pr_err("error %d\n", rc);
8258 goto rw_error;
8259 } /*! reset default val ! */
8260 rc = drxj_dap_write_reg16(dev_addr, QAM_SY_SYNC_HWM__A, QAM_SY_SYNC_HWM__PRE, 0);
8261 if (rc != 0) {
8262 pr_err("error %d\n", rc);
8263 goto rw_error;
8264 } /*! reset default val ! */
8265 } else {
8266 switch (channel->constellation) {
8267 case DRX_CONSTELLATION_QAM16:
8268 case DRX_CONSTELLATION_QAM64:
8269 case DRX_CONSTELLATION_QAM256:
8270 rc = drxj_dap_write_reg16(dev_addr, QAM_SY_SYNC_LWM__A, 0x03, 0);
8271 if (rc != 0) {
8272 pr_err("error %d\n", rc);
8273 goto rw_error;
8274 }
8275 rc = drxj_dap_write_reg16(dev_addr, QAM_SY_SYNC_AWM__A, 0x04, 0);
8276 if (rc != 0) {
8277 pr_err("error %d\n", rc);
8278 goto rw_error;
8279 }
8280 rc = drxj_dap_write_reg16(dev_addr, QAM_SY_SYNC_HWM__A, QAM_SY_SYNC_HWM__PRE, 0);
8281 if (rc != 0) {
8282 pr_err("error %d\n", rc);
8283 goto rw_error;
8284 } /*! reset default val ! */
8285 break;
8286 case DRX_CONSTELLATION_QAM32:
8287 case DRX_CONSTELLATION_QAM128:
8288 rc = drxj_dap_write_reg16(dev_addr, QAM_SY_SYNC_LWM__A, 0x03, 0);
8289 if (rc != 0) {
8290 pr_err("error %d\n", rc);
8291 goto rw_error;
8292 }
8293 rc = drxj_dap_write_reg16(dev_addr, QAM_SY_SYNC_AWM__A, 0x05, 0);
8294 if (rc != 0) {
8295 pr_err("error %d\n", rc);
8296 goto rw_error;
8297 }
8298 rc = drxj_dap_write_reg16(dev_addr, QAM_SY_SYNC_HWM__A, 0x06, 0);
8299 if (rc != 0) {
8300 pr_err("error %d\n", rc);
8301 goto rw_error;
8302 }
8303 break;
8304 default:
8305 return -EIO;
8306 } /* switch */
8307 }
8308
8309 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_MODE__A, QAM_LC_MODE__PRE, 0);
8310 if (rc != 0) {
8311 pr_err("error %d\n", rc);
8312 goto rw_error;
8313 } /*! reset default val ! */
8314 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_RATE_LIMIT__A, 3, 0);
8315 if (rc != 0) {
8316 pr_err("error %d\n", rc);
8317 goto rw_error;
8318 }
8319 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_LPF_FACTORP__A, 4, 0);
8320 if (rc != 0) {
8321 pr_err("error %d\n", rc);
8322 goto rw_error;
8323 }
8324 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_LPF_FACTORI__A, 4, 0);
8325 if (rc != 0) {
8326 pr_err("error %d\n", rc);
8327 goto rw_error;
8328 }
8329 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_MODE__A, 7, 0);
8330 if (rc != 0) {
8331 pr_err("error %d\n", rc);
8332 goto rw_error;
8333 }
8334 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB0__A, 1, 0);
8335 if (rc != 0) {
8336 pr_err("error %d\n", rc);
8337 goto rw_error;
8338 }
8339 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB1__A, 1, 0);
8340 if (rc != 0) {
8341 pr_err("error %d\n", rc);
8342 goto rw_error;
8343 }
8344 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB2__A, 1, 0);
8345 if (rc != 0) {
8346 pr_err("error %d\n", rc);
8347 goto rw_error;
8348 }
8349 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB3__A, 1, 0);
8350 if (rc != 0) {
8351 pr_err("error %d\n", rc);
8352 goto rw_error;
8353 }
8354 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB4__A, 2, 0);
8355 if (rc != 0) {
8356 pr_err("error %d\n", rc);
8357 goto rw_error;
8358 }
8359 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB5__A, 2, 0);
8360 if (rc != 0) {
8361 pr_err("error %d\n", rc);
8362 goto rw_error;
8363 }
8364 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB6__A, 2, 0);
8365 if (rc != 0) {
8366 pr_err("error %d\n", rc);
8367 goto rw_error;
8368 }
8369 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB8__A, 2, 0);
8370 if (rc != 0) {
8371 pr_err("error %d\n", rc);
8372 goto rw_error;
8373 }
8374 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB9__A, 2, 0);
8375 if (rc != 0) {
8376 pr_err("error %d\n", rc);
8377 goto rw_error;
8378 }
8379 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB10__A, 2, 0);
8380 if (rc != 0) {
8381 pr_err("error %d\n", rc);
8382 goto rw_error;
8383 }
8384 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB12__A, 2, 0);
8385 if (rc != 0) {
8386 pr_err("error %d\n", rc);
8387 goto rw_error;
8388 }
8389 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB15__A, 3, 0);
8390 if (rc != 0) {
8391 pr_err("error %d\n", rc);
8392 goto rw_error;
8393 }
8394 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB16__A, 3, 0);
8395 if (rc != 0) {
8396 pr_err("error %d\n", rc);
8397 goto rw_error;
8398 }
8399 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB20__A, 4, 0);
8400 if (rc != 0) {
8401 pr_err("error %d\n", rc);
8402 goto rw_error;
8403 }
8404 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_QUAL_TAB25__A, 4, 0);
8405 if (rc != 0) {
8406 pr_err("error %d\n", rc);
8407 goto rw_error;
8408 }
8409
8410 rc = drxj_dap_write_reg16(dev_addr, IQM_FS_ADJ_SEL__A, 1, 0);
8411 if (rc != 0) {
8412 pr_err("error %d\n", rc);
8413 goto rw_error;
8414 }
8415 rc = drxj_dap_write_reg16(dev_addr, IQM_RC_ADJ_SEL__A, 1, 0);
8416 if (rc != 0) {
8417 pr_err("error %d\n", rc);
8418 goto rw_error;
8419 }
8420 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_ADJ_SEL__A, 1, 0);
8421 if (rc != 0) {
8422 pr_err("error %d\n", rc);
8423 goto rw_error;
8424 }
8425 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_POW_MEAS_LEN__A, 0, 0);
8426 if (rc != 0) {
8427 pr_err("error %d\n", rc);
8428 goto rw_error;
8429 }
8430 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_GPIO__A, 0, 0);
8431 if (rc != 0) {
8432 pr_err("error %d\n", rc);
8433 goto rw_error;
8434 }
8435
8436 /* No more resets of the IQM, current standard correctly set =>
8437 now AGCs can be configured. */
8438 /* turn on IQMAF. It has to be in front of setAgc**() */
8439 rc = set_iqm_af(demod, true);
8440 if (rc != 0) {
8441 pr_err("error %d\n", rc);
8442 goto rw_error;
8443 }
8444 rc = adc_synchronization(demod);
8445 if (rc != 0) {
8446 pr_err("error %d\n", rc);
8447 goto rw_error;
8448 }
8449
8450 rc = init_agc(demod);
8451 if (rc != 0) {
8452 pr_err("error %d\n", rc);
8453 goto rw_error;
8454 }
8455 rc = set_agc_if(demod, &(ext_attr->qam_if_agc_cfg), false);
8456 if (rc != 0) {
8457 pr_err("error %d\n", rc);
8458 goto rw_error;
8459 }
8460 rc = set_agc_rf(demod, &(ext_attr->qam_rf_agc_cfg), false);
8461 if (rc != 0) {
8462 pr_err("error %d\n", rc);
8463 goto rw_error;
8464 }
8465 {
8466 /* TODO fix this, store a struct drxj_cfg_afe_gain structure in struct drxj_data instead
8467 of only the gain */
8468 struct drxj_cfg_afe_gain qam_pga_cfg = { DRX_STANDARD_ITU_B, 0 };
8469
8470 qam_pga_cfg.gain = ext_attr->qam_pga_cfg;
8471 rc = ctrl_set_cfg_afe_gain(demod, &qam_pga_cfg);
8472 if (rc != 0) {
8473 pr_err("error %d\n", rc);
8474 goto rw_error;
8475 }
8476 }
8477 rc = ctrl_set_cfg_pre_saw(demod, &(ext_attr->qam_pre_saw_cfg));
8478 if (rc != 0) {
8479 pr_err("error %d\n", rc);
8480 goto rw_error;
8481 }
8482 }
8483
8484 if ((op & QAM_SET_OP_ALL) || (op & QAM_SET_OP_CONSTELLATION)) {
8485 if (ext_attr->standard == DRX_STANDARD_ITU_A) {
8486 rc = drxdap_fasi_write_block(dev_addr, IQM_CF_TAP_RE0__A, sizeof(qam_a_taps), ((u8 *)qam_a_taps), 0);
8487 if (rc != 0) {
8488 pr_err("error %d\n", rc);
8489 goto rw_error;
8490 }
8491 rc = drxdap_fasi_write_block(dev_addr, IQM_CF_TAP_IM0__A, sizeof(qam_a_taps), ((u8 *)qam_a_taps), 0);
8492 if (rc != 0) {
8493 pr_err("error %d\n", rc);
8494 goto rw_error;
8495 }
8496 } else if (ext_attr->standard == DRX_STANDARD_ITU_B) {
8497 switch (channel->constellation) {
8498 case DRX_CONSTELLATION_QAM64:
8499 rc = drxdap_fasi_write_block(dev_addr, IQM_CF_TAP_RE0__A, sizeof(qam_b64_taps), ((u8 *)qam_b64_taps), 0);
8500 if (rc != 0) {
8501 pr_err("error %d\n", rc);
8502 goto rw_error;
8503 }
8504 rc = drxdap_fasi_write_block(dev_addr, IQM_CF_TAP_IM0__A, sizeof(qam_b64_taps), ((u8 *)qam_b64_taps), 0);
8505 if (rc != 0) {
8506 pr_err("error %d\n", rc);
8507 goto rw_error;
8508 }
8509 break;
8510 case DRX_CONSTELLATION_QAM256:
8511 rc = drxdap_fasi_write_block(dev_addr, IQM_CF_TAP_RE0__A, sizeof(qam_b256_taps), ((u8 *)qam_b256_taps), 0);
8512 if (rc != 0) {
8513 pr_err("error %d\n", rc);
8514 goto rw_error;
8515 }
8516 rc = drxdap_fasi_write_block(dev_addr, IQM_CF_TAP_IM0__A, sizeof(qam_b256_taps), ((u8 *)qam_b256_taps), 0);
8517 if (rc != 0) {
8518 pr_err("error %d\n", rc);
8519 goto rw_error;
8520 }
8521 break;
8522 default:
8523 return -EIO;
8524 }
8525 } else if (ext_attr->standard == DRX_STANDARD_ITU_C) {
8526 rc = drxdap_fasi_write_block(dev_addr, IQM_CF_TAP_RE0__A, sizeof(qam_c_taps), ((u8 *)qam_c_taps), 0);
8527 if (rc != 0) {
8528 pr_err("error %d\n", rc);
8529 goto rw_error;
8530 }
8531 rc = drxdap_fasi_write_block(dev_addr, IQM_CF_TAP_IM0__A, sizeof(qam_c_taps), ((u8 *)qam_c_taps), 0);
8532 if (rc != 0) {
8533 pr_err("error %d\n", rc);
8534 goto rw_error;
8535 }
8536 }
8537
8538 /* SETP 4: constellation specific setup */
8539 switch (channel->constellation) {
8540 case DRX_CONSTELLATION_QAM16:
8541 rc = set_qam16(demod);
8542 if (rc != 0) {
8543 pr_err("error %d\n", rc);
8544 goto rw_error;
8545 }
8546 break;
8547 case DRX_CONSTELLATION_QAM32:
8548 rc = set_qam32(demod);
8549 if (rc != 0) {
8550 pr_err("error %d\n", rc);
8551 goto rw_error;
8552 }
8553 break;
8554 case DRX_CONSTELLATION_QAM64:
8555 rc = set_qam64(demod);
8556 if (rc != 0) {
8557 pr_err("error %d\n", rc);
8558 goto rw_error;
8559 }
8560 break;
8561 case DRX_CONSTELLATION_QAM128:
8562 rc = set_qam128(demod);
8563 if (rc != 0) {
8564 pr_err("error %d\n", rc);
8565 goto rw_error;
8566 }
8567 break;
8568 case DRX_CONSTELLATION_QAM256:
8569 rc = set_qam256(demod);
8570 if (rc != 0) {
8571 pr_err("error %d\n", rc);
8572 goto rw_error;
8573 }
8574 break;
8575 default:
8576 return -EIO;
8577 } /* switch */
8578 }
8579
8580 if ((op & QAM_SET_OP_ALL)) {
8581 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_SCALE_SH__A, 0, 0);
8582 if (rc != 0) {
8583 pr_err("error %d\n", rc);
8584 goto rw_error;
8585 }
8586
8587 /* Mpeg output has to be in front of FEC active */
8588 rc = set_mpegtei_handling(demod);
8589 if (rc != 0) {
8590 pr_err("error %d\n", rc);
8591 goto rw_error;
8592 }
8593 rc = bit_reverse_mpeg_output(demod);
8594 if (rc != 0) {
8595 pr_err("error %d\n", rc);
8596 goto rw_error;
8597 }
8598 rc = set_mpeg_start_width(demod);
8599 if (rc != 0) {
8600 pr_err("error %d\n", rc);
8601 goto rw_error;
8602 }
8603 {
8604 /* TODO: move to set_standard after hardware reset value problem is solved */
8605 /* Configure initial MPEG output */
8606 struct drx_cfg_mpeg_output cfg_mpeg_output;
8607
8608 memcpy(&cfg_mpeg_output, &common_attr->mpeg_cfg, sizeof(cfg_mpeg_output));
8609 cfg_mpeg_output.enable_mpeg_output = true;
8610
8611 rc = ctrl_set_cfg_mpeg_output(demod, &cfg_mpeg_output);
8612 if (rc != 0) {
8613 pr_err("error %d\n", rc);
8614 goto rw_error;
8615 }
8616 }
8617 }
8618
8619 if ((op & QAM_SET_OP_ALL) || (op & QAM_SET_OP_CONSTELLATION)) {
8620
8621 /* STEP 5: start QAM demodulator (starts FEC, QAM and IQM HW) */
8622 cmd_scu.command = SCU_RAM_COMMAND_STANDARD_QAM |
8623 SCU_RAM_COMMAND_CMD_DEMOD_START;
8624 cmd_scu.parameter_len = 0;
8625 cmd_scu.result_len = 1;
8626 cmd_scu.parameter = NULL;
8627 cmd_scu.result = &cmd_result;
8628 rc = scu_command(dev_addr, &cmd_scu);
8629 if (rc != 0) {
8630 pr_err("error %d\n", rc);
8631 goto rw_error;
8632 }
8633 }
8634
8635 rc = drxj_dap_write_reg16(dev_addr, IQM_COMM_EXEC__A, IQM_COMM_EXEC_ACTIVE, 0);
8636 if (rc != 0) {
8637 pr_err("error %d\n", rc);
8638 goto rw_error;
8639 }
8640 rc = drxj_dap_write_reg16(dev_addr, QAM_COMM_EXEC__A, QAM_COMM_EXEC_ACTIVE, 0);
8641 if (rc != 0) {
8642 pr_err("error %d\n", rc);
8643 goto rw_error;
8644 }
8645 rc = drxj_dap_write_reg16(dev_addr, FEC_COMM_EXEC__A, FEC_COMM_EXEC_ACTIVE, 0);
8646 if (rc != 0) {
8647 pr_err("error %d\n", rc);
8648 goto rw_error;
8649 }
8650
8651 return 0;
8652rw_error:
8653 return -EIO;
8654}
8655
8656/*============================================================================*/
8657static int ctrl_get_qam_sig_quality(struct drx_demod_instance *demod);
8658
8659static int qam_flip_spec(struct drx_demod_instance *demod, struct drx_channel *channel)
8660{
8661 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
8662 struct drxj_data *ext_attr = demod->my_ext_attr;
8663 int rc;
8664 u32 iqm_fs_rate_ofs = 0;
8665 u32 iqm_fs_rate_lo = 0;
8666 u16 qam_ctl_ena = 0;
8667 u16 data = 0;
8668 u16 equ_mode = 0;
8669 u16 fsm_state = 0;
8670 int i = 0;
8671 int ofsofs = 0;
8672
8673 /* Silence the controlling of lc, equ, and the acquisition state machine */
8674 rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_QAM_CTL_ENA__A, &qam_ctl_ena, 0);
8675 if (rc != 0) {
8676 pr_err("error %d\n", rc);
8677 goto rw_error;
8678 }
8679 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_CTL_ENA__A, qam_ctl_ena & ~(SCU_RAM_QAM_CTL_ENA_ACQ__M | SCU_RAM_QAM_CTL_ENA_EQU__M | SCU_RAM_QAM_CTL_ENA_LC__M), 0);
8680 if (rc != 0) {
8681 pr_err("error %d\n", rc);
8682 goto rw_error;
8683 }
8684
8685 /* freeze the frequency control loop */
8686 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_CF__A, 0, 0);
8687 if (rc != 0) {
8688 pr_err("error %d\n", rc);
8689 goto rw_error;
8690 }
8691 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_CF1__A, 0, 0);
8692 if (rc != 0) {
8693 pr_err("error %d\n", rc);
8694 goto rw_error;
8695 }
8696
8697 rc = drxj_dap_atomic_read_reg32(dev_addr, IQM_FS_RATE_OFS_LO__A, &iqm_fs_rate_ofs, 0);
8698 if (rc != 0) {
8699 pr_err("error %d\n", rc);
8700 goto rw_error;
8701 }
8702 rc = drxj_dap_atomic_read_reg32(dev_addr, IQM_FS_RATE_LO__A, &iqm_fs_rate_lo, 0);
8703 if (rc != 0) {
8704 pr_err("error %d\n", rc);
8705 goto rw_error;
8706 }
8707 ofsofs = iqm_fs_rate_lo - iqm_fs_rate_ofs;
8708 iqm_fs_rate_ofs = ~iqm_fs_rate_ofs + 1;
8709 iqm_fs_rate_ofs -= 2 * ofsofs;
8710
8711 /* freeze dq/fq updating */
8712 rc = drxj_dap_read_reg16(dev_addr, QAM_DQ_MODE__A, &data, 0);
8713 if (rc != 0) {
8714 pr_err("error %d\n", rc);
8715 goto rw_error;
8716 }
8717 data = (data & 0xfff9);
8718 rc = drxj_dap_write_reg16(dev_addr, QAM_DQ_MODE__A, data, 0);
8719 if (rc != 0) {
8720 pr_err("error %d\n", rc);
8721 goto rw_error;
8722 }
8723 rc = drxj_dap_write_reg16(dev_addr, QAM_FQ_MODE__A, data, 0);
8724 if (rc != 0) {
8725 pr_err("error %d\n", rc);
8726 goto rw_error;
8727 }
8728
8729 /* lc_cp / _ci / _ca */
8730 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_CI__A, 0, 0);
8731 if (rc != 0) {
8732 pr_err("error %d\n", rc);
8733 goto rw_error;
8734 }
8735 rc = drxj_dap_write_reg16(dev_addr, QAM_LC_EP__A, 0, 0);
8736 if (rc != 0) {
8737 pr_err("error %d\n", rc);
8738 goto rw_error;
8739 }
8740 rc = drxj_dap_write_reg16(dev_addr, QAM_FQ_LA_FACTOR__A, 0, 0);
8741 if (rc != 0) {
8742 pr_err("error %d\n", rc);
8743 goto rw_error;
8744 }
8745
8746 /* flip the spec */
8747 rc = drxdap_fasi_write_reg32(dev_addr, IQM_FS_RATE_OFS_LO__A, iqm_fs_rate_ofs, 0);
8748 if (rc != 0) {
8749 pr_err("error %d\n", rc);
8750 goto rw_error;
8751 }
8752 ext_attr->iqm_fs_rate_ofs = iqm_fs_rate_ofs;
8753 ext_attr->pos_image = (ext_attr->pos_image) ? false : true;
8754
8755 /* freeze dq/fq updating */
8756 rc = drxj_dap_read_reg16(dev_addr, QAM_DQ_MODE__A, &data, 0);
8757 if (rc != 0) {
8758 pr_err("error %d\n", rc);
8759 goto rw_error;
8760 }
8761 equ_mode = data;
8762 data = (data & 0xfff9);
8763 rc = drxj_dap_write_reg16(dev_addr, QAM_DQ_MODE__A, data, 0);
8764 if (rc != 0) {
8765 pr_err("error %d\n", rc);
8766 goto rw_error;
8767 }
8768 rc = drxj_dap_write_reg16(dev_addr, QAM_FQ_MODE__A, data, 0);
8769 if (rc != 0) {
8770 pr_err("error %d\n", rc);
8771 goto rw_error;
8772 }
8773
8774 for (i = 0; i < 28; i++) {
8775 rc = drxj_dap_read_reg16(dev_addr, QAM_DQ_TAP_IM_EL0__A + (2 * i), &data, 0);
8776 if (rc != 0) {
8777 pr_err("error %d\n", rc);
8778 goto rw_error;
8779 }
8780 rc = drxj_dap_write_reg16(dev_addr, QAM_DQ_TAP_IM_EL0__A + (2 * i), -data, 0);
8781 if (rc != 0) {
8782 pr_err("error %d\n", rc);
8783 goto rw_error;
8784 }
8785 }
8786
8787 for (i = 0; i < 24; i++) {
8788 rc = drxj_dap_read_reg16(dev_addr, QAM_FQ_TAP_IM_EL0__A + (2 * i), &data, 0);
8789 if (rc != 0) {
8790 pr_err("error %d\n", rc);
8791 goto rw_error;
8792 }
8793 rc = drxj_dap_write_reg16(dev_addr, QAM_FQ_TAP_IM_EL0__A + (2 * i), -data, 0);
8794 if (rc != 0) {
8795 pr_err("error %d\n", rc);
8796 goto rw_error;
8797 }
8798 }
8799
8800 data = equ_mode;
8801 rc = drxj_dap_write_reg16(dev_addr, QAM_DQ_MODE__A, data, 0);
8802 if (rc != 0) {
8803 pr_err("error %d\n", rc);
8804 goto rw_error;
8805 }
8806 rc = drxj_dap_write_reg16(dev_addr, QAM_FQ_MODE__A, data, 0);
8807 if (rc != 0) {
8808 pr_err("error %d\n", rc);
8809 goto rw_error;
8810 }
8811
8812 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_FSM_STATE_TGT__A, 4, 0);
8813 if (rc != 0) {
8814 pr_err("error %d\n", rc);
8815 goto rw_error;
8816 }
8817
8818 i = 0;
8819 while ((fsm_state != 4) && (i++ < 100)) {
8820 rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_QAM_FSM_STATE__A, &fsm_state, 0);
8821 if (rc != 0) {
8822 pr_err("error %d\n", rc);
8823 goto rw_error;
8824 }
8825 }
8826 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_QAM_CTL_ENA__A, (qam_ctl_ena | 0x0016), 0);
8827 if (rc != 0) {
8828 pr_err("error %d\n", rc);
8829 goto rw_error;
8830 }
8831
8832 return 0;
8833rw_error:
8834 return -EIO;
8835
8836}
8837
8838#define NO_LOCK 0x0
8839#define DEMOD_LOCKED 0x1
8840#define SYNC_FLIPPED 0x2
8841#define SPEC_MIRRORED 0x4
8842/**
8843* \fn int qam64auto ()
8844* \brief auto do sync pattern switching and mirroring.
8845* \param demod: instance of demod.
8846* \param channel: pointer to channel data.
8847* \param tuner_freq_offset: tuner frequency offset.
8848* \param lock_status: pointer to lock status.
8849* \return int.
8850*/
8851static int
8852qam64auto(struct drx_demod_instance *demod,
8853 struct drx_channel *channel,
8854 s32 tuner_freq_offset, enum drx_lock_status *lock_status)
8855{
8856 struct drxj_data *ext_attr = demod->my_ext_attr;
8857 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
8858 struct drx39xxj_state *state = dev_addr->user_data;
8859 struct dtv_frontend_properties *p = &state->frontend.dtv_property_cache;
8860 int rc;
8861 u32 lck_state = NO_LOCK;
8862 u32 start_time = 0;
8863 u32 d_locked_time = 0;
8864 u32 timeout_ofs = 0;
8865 u16 data = 0;
8866
8867 /* external attributes for storing aquired channel constellation */
8868 *lock_status = DRX_NOT_LOCKED;
8869 start_time = jiffies_to_msecs(jiffies);
8870 lck_state = NO_LOCK;
8871 do {
8872 rc = ctrl_lock_status(demod, lock_status);
8873 if (rc != 0) {
8874 pr_err("error %d\n", rc);
8875 goto rw_error;
8876 }
8877
8878 switch (lck_state) {
8879 case NO_LOCK:
8880 if (*lock_status == DRXJ_DEMOD_LOCK) {
8881 rc = ctrl_get_qam_sig_quality(demod);
8882 if (rc != 0) {
8883 pr_err("error %d\n", rc);
8884 goto rw_error;
8885 }
8886 if (p->cnr.stat[0].svalue > 20800) {
8887 lck_state = DEMOD_LOCKED;
8888 /* some delay to see if fec_lock possible TODO find the right value */
8889 timeout_ofs += DRXJ_QAM_DEMOD_LOCK_EXT_WAITTIME; /* see something, waiting longer */
8890 d_locked_time = jiffies_to_msecs(jiffies);
8891 }
8892 }
8893 break;
8894 case DEMOD_LOCKED:
8895 if ((*lock_status == DRXJ_DEMOD_LOCK) && /* still demod_lock in 150ms */
8896 ((jiffies_to_msecs(jiffies) - d_locked_time) >
8897 DRXJ_QAM_FEC_LOCK_WAITTIME)) {
8898 rc = drxj_dap_read_reg16(demod->my_i2c_dev_addr, QAM_SY_TIMEOUT__A, &data, 0);
8899 if (rc != 0) {
8900 pr_err("error %d\n", rc);
8901 goto rw_error;
8902 }
8903 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, QAM_SY_TIMEOUT__A, data | 0x1, 0);
8904 if (rc != 0) {
8905 pr_err("error %d\n", rc);
8906 goto rw_error;
8907 }
8908 lck_state = SYNC_FLIPPED;
8909 msleep(10);
8910 }
8911 break;
8912 case SYNC_FLIPPED:
8913 if (*lock_status == DRXJ_DEMOD_LOCK) {
8914 if (channel->mirror == DRX_MIRROR_AUTO) {
8915 /* flip sync pattern back */
8916 rc = drxj_dap_read_reg16(demod->my_i2c_dev_addr, QAM_SY_TIMEOUT__A, &data, 0);
8917 if (rc != 0) {
8918 pr_err("error %d\n", rc);
8919 goto rw_error;
8920 }
8921 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, QAM_SY_TIMEOUT__A, data & 0xFFFE, 0);
8922 if (rc != 0) {
8923 pr_err("error %d\n", rc);
8924 goto rw_error;
8925 }
8926 /* flip spectrum */
8927 ext_attr->mirror = DRX_MIRROR_YES;
8928 rc = qam_flip_spec(demod, channel);
8929 if (rc != 0) {
8930 pr_err("error %d\n", rc);
8931 goto rw_error;
8932 }
8933 lck_state = SPEC_MIRRORED;
8934 /* reset timer TODO: still need 500ms? */
8935 start_time = d_locked_time =
8936 jiffies_to_msecs(jiffies);
8937 timeout_ofs = 0;
8938 } else { /* no need to wait lock */
8939
8940 start_time =
8941 jiffies_to_msecs(jiffies) -
8942 DRXJ_QAM_MAX_WAITTIME - timeout_ofs;
8943 }
8944 }
8945 break;
8946 case SPEC_MIRRORED:
8947 if ((*lock_status == DRXJ_DEMOD_LOCK) && /* still demod_lock in 150ms */
8948 ((jiffies_to_msecs(jiffies) - d_locked_time) >
8949 DRXJ_QAM_FEC_LOCK_WAITTIME)) {
8950 rc = ctrl_get_qam_sig_quality(demod);
8951 if (rc != 0) {
8952 pr_err("error %d\n", rc);
8953 goto rw_error;
8954 }
8955 if (p->cnr.stat[0].svalue > 20800) {
8956 rc = drxj_dap_read_reg16(demod->my_i2c_dev_addr, QAM_SY_TIMEOUT__A, &data, 0);
8957 if (rc != 0) {
8958 pr_err("error %d\n", rc);
8959 goto rw_error;
8960 }
8961 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr, QAM_SY_TIMEOUT__A, data | 0x1, 0);
8962 if (rc != 0) {
8963 pr_err("error %d\n", rc);
8964 goto rw_error;
8965 }
8966 /* no need to wait lock */
8967 start_time =
8968 jiffies_to_msecs(jiffies) -
8969 DRXJ_QAM_MAX_WAITTIME - timeout_ofs;
8970 }
8971 }
8972 break;
8973 default:
8974 break;
8975 }
8976 msleep(10);
8977 } while
8978 ((*lock_status != DRX_LOCKED) &&
8979 (*lock_status != DRX_NEVER_LOCK) &&
8980 ((jiffies_to_msecs(jiffies) - start_time) <
8981 (DRXJ_QAM_MAX_WAITTIME + timeout_ofs))
8982 );
8983 /* Returning control to apllication ... */
8984
8985 return 0;
8986rw_error:
8987 return -EIO;
8988}
8989
8990/**
8991* \fn int qam256auto ()
8992* \brief auto do sync pattern switching and mirroring.
8993* \param demod: instance of demod.
8994* \param channel: pointer to channel data.
8995* \param tuner_freq_offset: tuner frequency offset.
8996* \param lock_status: pointer to lock status.
8997* \return int.
8998*/
8999static int
9000qam256auto(struct drx_demod_instance *demod,
9001 struct drx_channel *channel,
9002 s32 tuner_freq_offset, enum drx_lock_status *lock_status)
9003{
9004 struct drxj_data *ext_attr = demod->my_ext_attr;
9005 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
9006 struct drx39xxj_state *state = dev_addr->user_data;
9007 struct dtv_frontend_properties *p = &state->frontend.dtv_property_cache;
9008 int rc;
9009 u32 lck_state = NO_LOCK;
9010 u32 start_time = 0;
9011 u32 d_locked_time = 0;
9012 u32 timeout_ofs = DRXJ_QAM_DEMOD_LOCK_EXT_WAITTIME;
9013
9014 /* external attributes for storing aquired channel constellation */
9015 *lock_status = DRX_NOT_LOCKED;
9016 start_time = jiffies_to_msecs(jiffies);
9017 lck_state = NO_LOCK;
9018 do {
9019 rc = ctrl_lock_status(demod, lock_status);
9020 if (rc != 0) {
9021 pr_err("error %d\n", rc);
9022 goto rw_error;
9023 }
9024 switch (lck_state) {
9025 case NO_LOCK:
9026 if (*lock_status == DRXJ_DEMOD_LOCK) {
9027 rc = ctrl_get_qam_sig_quality(demod);
9028 if (rc != 0) {
9029 pr_err("error %d\n", rc);
9030 goto rw_error;
9031 }
9032 if (p->cnr.stat[0].svalue > 26800) {
9033 lck_state = DEMOD_LOCKED;
9034 timeout_ofs += DRXJ_QAM_DEMOD_LOCK_EXT_WAITTIME; /* see something, wait longer */
9035 d_locked_time = jiffies_to_msecs(jiffies);
9036 }
9037 }
9038 break;
9039 case DEMOD_LOCKED:
9040 if (*lock_status == DRXJ_DEMOD_LOCK) {
9041 if ((channel->mirror == DRX_MIRROR_AUTO) &&
9042 ((jiffies_to_msecs(jiffies) - d_locked_time) >
9043 DRXJ_QAM_FEC_LOCK_WAITTIME)) {
9044 ext_attr->mirror = DRX_MIRROR_YES;
9045 rc = qam_flip_spec(demod, channel);
9046 if (rc != 0) {
9047 pr_err("error %d\n", rc);
9048 goto rw_error;
9049 }
9050 lck_state = SPEC_MIRRORED;
9051 /* reset timer TODO: still need 300ms? */
9052 start_time = jiffies_to_msecs(jiffies);
9053 timeout_ofs = -DRXJ_QAM_MAX_WAITTIME / 2;
9054 }
9055 }
9056 break;
9057 case SPEC_MIRRORED:
9058 break;
9059 default:
9060 break;
9061 }
9062 msleep(10);
9063 } while
9064 ((*lock_status < DRX_LOCKED) &&
9065 (*lock_status != DRX_NEVER_LOCK) &&
9066 ((jiffies_to_msecs(jiffies) - start_time) <
9067 (DRXJ_QAM_MAX_WAITTIME + timeout_ofs)));
9068
9069 return 0;
9070rw_error:
9071 return -EIO;
9072}
9073
9074/**
9075* \fn int set_qam_channel ()
9076* \brief Set QAM channel according to the requested constellation.
9077* \param demod: instance of demod.
9078* \param channel: pointer to channel data.
9079* \return int.
9080*/
9081static int
9082set_qam_channel(struct drx_demod_instance *demod,
9083 struct drx_channel *channel, s32 tuner_freq_offset)
9084{
9085 struct drxj_data *ext_attr = NULL;
9086 int rc;
9087 enum drx_lock_status lock_status = DRX_NOT_LOCKED;
9088 bool auto_flag = false;
9089
9090 /* external attributes for storing aquired channel constellation */
9091 ext_attr = (struct drxj_data *) demod->my_ext_attr;
9092
9093 /* set QAM channel constellation */
9094 switch (channel->constellation) {
9095 case DRX_CONSTELLATION_QAM16:
9096 case DRX_CONSTELLATION_QAM32:
9097 case DRX_CONSTELLATION_QAM128:
9098 return -EINVAL;
9099 case DRX_CONSTELLATION_QAM64:
9100 case DRX_CONSTELLATION_QAM256:
9101 if (ext_attr->standard != DRX_STANDARD_ITU_B)
9102 return -EINVAL;
9103
9104 ext_attr->constellation = channel->constellation;
9105 if (channel->mirror == DRX_MIRROR_AUTO)
9106 ext_attr->mirror = DRX_MIRROR_NO;
9107 else
9108 ext_attr->mirror = channel->mirror;
9109
9110 rc = set_qam(demod, channel, tuner_freq_offset, QAM_SET_OP_ALL);
9111 if (rc != 0) {
9112 pr_err("error %d\n", rc);
9113 goto rw_error;
9114 }
9115
9116 if (channel->constellation == DRX_CONSTELLATION_QAM64)
9117 rc = qam64auto(demod, channel, tuner_freq_offset,
9118 &lock_status);
9119 else
9120 rc = qam256auto(demod, channel, tuner_freq_offset,
9121 &lock_status);
9122 if (rc != 0) {
9123 pr_err("error %d\n", rc);
9124 goto rw_error;
9125 }
9126 break;
9127 case DRX_CONSTELLATION_AUTO: /* for channel scan */
9128 if (ext_attr->standard == DRX_STANDARD_ITU_B) {
9129 u16 qam_ctl_ena = 0;
9130
9131 auto_flag = true;
9132
9133 /* try to lock default QAM constellation: QAM256 */
9134 channel->constellation = DRX_CONSTELLATION_QAM256;
9135 ext_attr->constellation = DRX_CONSTELLATION_QAM256;
9136 if (channel->mirror == DRX_MIRROR_AUTO)
9137 ext_attr->mirror = DRX_MIRROR_NO;
9138 else
9139 ext_attr->mirror = channel->mirror;
9140 rc = set_qam(demod, channel, tuner_freq_offset,
9141 QAM_SET_OP_ALL);
9142 if (rc != 0) {
9143 pr_err("error %d\n", rc);
9144 goto rw_error;
9145 }
9146 rc = qam256auto(demod, channel, tuner_freq_offset,
9147 &lock_status);
9148 if (rc != 0) {
9149 pr_err("error %d\n", rc);
9150 goto rw_error;
9151 }
9152
9153 if (lock_status >= DRX_LOCKED) {
9154 channel->constellation = DRX_CONSTELLATION_AUTO;
9155 break;
9156 }
9157
9158 /* QAM254 not locked. Try QAM64 constellation */
9159 channel->constellation = DRX_CONSTELLATION_QAM64;
9160 ext_attr->constellation = DRX_CONSTELLATION_QAM64;
9161 if (channel->mirror == DRX_MIRROR_AUTO)
9162 ext_attr->mirror = DRX_MIRROR_NO;
9163 else
9164 ext_attr->mirror = channel->mirror;
9165
9166 rc = drxj_dap_read_reg16(demod->my_i2c_dev_addr,
9167 SCU_RAM_QAM_CTL_ENA__A,
9168 &qam_ctl_ena, 0);
9169 if (rc != 0) {
9170 pr_err("error %d\n", rc);
9171 goto rw_error;
9172 }
9173 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr,
9174 SCU_RAM_QAM_CTL_ENA__A,
9175 qam_ctl_ena & ~SCU_RAM_QAM_CTL_ENA_ACQ__M, 0);
9176 if (rc != 0) {
9177 pr_err("error %d\n", rc);
9178 goto rw_error;
9179 }
9180 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr,
9181 SCU_RAM_QAM_FSM_STATE_TGT__A,
9182 0x2, 0);
9183 if (rc != 0) {
9184 pr_err("error %d\n", rc);
9185 goto rw_error;
9186 } /* force to rate hunting */
9187
9188 rc = set_qam(demod, channel, tuner_freq_offset,
9189 QAM_SET_OP_CONSTELLATION);
9190 if (rc != 0) {
9191 pr_err("error %d\n", rc);
9192 goto rw_error;
9193 }
9194 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr,
9195 SCU_RAM_QAM_CTL_ENA__A,
9196 qam_ctl_ena, 0);
9197 if (rc != 0) {
9198 pr_err("error %d\n", rc);
9199 goto rw_error;
9200 }
9201
9202 rc = qam64auto(demod, channel, tuner_freq_offset,
9203 &lock_status);
9204 if (rc != 0) {
9205 pr_err("error %d\n", rc);
9206 goto rw_error;
9207 }
9208
9209 channel->constellation = DRX_CONSTELLATION_AUTO;
9210 } else if (ext_attr->standard == DRX_STANDARD_ITU_C) {
9211 u16 qam_ctl_ena = 0;
9212
9213 channel->constellation = DRX_CONSTELLATION_QAM64;
9214 ext_attr->constellation = DRX_CONSTELLATION_QAM64;
9215 auto_flag = true;
9216
9217 if (channel->mirror == DRX_MIRROR_AUTO)
9218 ext_attr->mirror = DRX_MIRROR_NO;
9219 else
9220 ext_attr->mirror = channel->mirror;
9221 rc = drxj_dap_read_reg16(demod->my_i2c_dev_addr,
9222 SCU_RAM_QAM_CTL_ENA__A,
9223 &qam_ctl_ena, 0);
9224 if (rc != 0) {
9225 pr_err("error %d\n", rc);
9226 goto rw_error;
9227 }
9228 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr,
9229 SCU_RAM_QAM_CTL_ENA__A,
9230 qam_ctl_ena & ~SCU_RAM_QAM_CTL_ENA_ACQ__M, 0);
9231 if (rc != 0) {
9232 pr_err("error %d\n", rc);
9233 goto rw_error;
9234 }
9235 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr,
9236 SCU_RAM_QAM_FSM_STATE_TGT__A,
9237 0x2, 0);
9238 if (rc != 0) {
9239 pr_err("error %d\n", rc);
9240 goto rw_error;
9241 } /* force to rate hunting */
9242
9243 rc = set_qam(demod, channel, tuner_freq_offset,
9244 QAM_SET_OP_CONSTELLATION);
9245 if (rc != 0) {
9246 pr_err("error %d\n", rc);
9247 goto rw_error;
9248 }
9249 rc = drxj_dap_write_reg16(demod->my_i2c_dev_addr,
9250 SCU_RAM_QAM_CTL_ENA__A,
9251 qam_ctl_ena, 0);
9252 if (rc != 0) {
9253 pr_err("error %d\n", rc);
9254 goto rw_error;
9255 }
9256 rc = qam64auto(demod, channel, tuner_freq_offset,
9257 &lock_status);
9258 if (rc != 0) {
9259 pr_err("error %d\n", rc);
9260 goto rw_error;
9261 }
9262 channel->constellation = DRX_CONSTELLATION_AUTO;
9263 } else {
9264 return -EINVAL;
9265 }
9266 break;
9267 default:
9268 return -EINVAL;
9269 }
9270
9271 return 0;
9272rw_error:
9273 /* restore starting value */
9274 if (auto_flag)
9275 channel->constellation = DRX_CONSTELLATION_AUTO;
9276 return -EIO;
9277}
9278
9279/*============================================================================*/
9280
9281/**
9282* \fn static short get_qamrs_err_count(struct i2c_device_addr *dev_addr)
9283* \brief Get RS error count in QAM mode (used for post RS BER calculation)
9284* \return Error code
9285*
9286* precondition: measurement period & measurement prescale must be set
9287*
9288*/
9289static int
9290get_qamrs_err_count(struct i2c_device_addr *dev_addr,
9291 struct drxjrs_errors *rs_errors)
9292{
9293 int rc;
9294 u16 nr_bit_errors = 0,
9295 nr_symbol_errors = 0,
9296 nr_packet_errors = 0, nr_failures = 0, nr_snc_par_fail_count = 0;
9297
9298 /* check arguments */
9299 if (dev_addr == NULL)
9300 return -EINVAL;
9301
9302 /* all reported errors are received in the */
9303 /* most recently finished measurment period */
9304 /* no of pre RS bit errors */
9305 rc = drxj_dap_read_reg16(dev_addr, FEC_RS_NR_BIT_ERRORS__A, &nr_bit_errors, 0);
9306 if (rc != 0) {
9307 pr_err("error %d\n", rc);
9308 goto rw_error;
9309 }
9310 /* no of symbol errors */
9311 rc = drxj_dap_read_reg16(dev_addr, FEC_RS_NR_SYMBOL_ERRORS__A, &nr_symbol_errors, 0);
9312 if (rc != 0) {
9313 pr_err("error %d\n", rc);
9314 goto rw_error;
9315 }
9316 /* no of packet errors */
9317 rc = drxj_dap_read_reg16(dev_addr, FEC_RS_NR_PACKET_ERRORS__A, &nr_packet_errors, 0);
9318 if (rc != 0) {
9319 pr_err("error %d\n", rc);
9320 goto rw_error;
9321 }
9322 /* no of failures to decode */
9323 rc = drxj_dap_read_reg16(dev_addr, FEC_RS_NR_FAILURES__A, &nr_failures, 0);
9324 if (rc != 0) {
9325 pr_err("error %d\n", rc);
9326 goto rw_error;
9327 }
9328 /* no of post RS bit erros */
9329 rc = drxj_dap_read_reg16(dev_addr, FEC_OC_SNC_FAIL_COUNT__A, &nr_snc_par_fail_count, 0);
9330 if (rc != 0) {
9331 pr_err("error %d\n", rc);
9332 goto rw_error;
9333 }
9334 /* TODO: NOTE */
9335 /* These register values are fetched in non-atomic fashion */
9336 /* It is possible that the read values contain unrelated information */
9337
9338 rs_errors->nr_bit_errors = nr_bit_errors & FEC_RS_NR_BIT_ERRORS__M;
9339 rs_errors->nr_symbol_errors = nr_symbol_errors & FEC_RS_NR_SYMBOL_ERRORS__M;
9340 rs_errors->nr_packet_errors = nr_packet_errors & FEC_RS_NR_PACKET_ERRORS__M;
9341 rs_errors->nr_failures = nr_failures & FEC_RS_NR_FAILURES__M;
9342 rs_errors->nr_snc_par_fail_count =
9343 nr_snc_par_fail_count & FEC_OC_SNC_FAIL_COUNT__M;
9344
9345 return 0;
9346rw_error:
9347 return -EIO;
9348}
9349
9350/*============================================================================*/
9351
9352/**
9353 * \fn int get_sig_strength()
9354 * \brief Retrieve signal strength for VSB and QAM.
9355 * \param demod Pointer to demod instance
9356 * \param u16-t Pointer to signal strength data; range 0, .. , 100.
9357 * \return int.
9358 * \retval 0 sig_strength contains valid data.
9359 * \retval -EINVAL sig_strength is NULL.
9360 * \retval -EIO Erroneous data, sig_strength contains invalid data.
9361 */
9362#define DRXJ_AGC_TOP 0x2800
9363#define DRXJ_AGC_SNS 0x1600
9364#define DRXJ_RFAGC_MAX 0x3fff
9365#define DRXJ_RFAGC_MIN 0x800
9366
9367static int get_sig_strength(struct drx_demod_instance *demod, u16 *sig_strength)
9368{
9369 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
9370 int rc;
9371 u16 rf_gain = 0;
9372 u16 if_gain = 0;
9373 u16 if_agc_sns = 0;
9374 u16 if_agc_top = 0;
9375 u16 rf_agc_max = 0;
9376 u16 rf_agc_min = 0;
9377
9378 rc = drxj_dap_read_reg16(dev_addr, IQM_AF_AGC_IF__A, &if_gain, 0);
9379 if (rc != 0) {
9380 pr_err("error %d\n", rc);
9381 goto rw_error;
9382 }
9383 if_gain &= IQM_AF_AGC_IF__M;
9384 rc = drxj_dap_read_reg16(dev_addr, IQM_AF_AGC_RF__A, &rf_gain, 0);
9385 if (rc != 0) {
9386 pr_err("error %d\n", rc);
9387 goto rw_error;
9388 }
9389 rf_gain &= IQM_AF_AGC_RF__M;
9390
9391 if_agc_sns = DRXJ_AGC_SNS;
9392 if_agc_top = DRXJ_AGC_TOP;
9393 rf_agc_max = DRXJ_RFAGC_MAX;
9394 rf_agc_min = DRXJ_RFAGC_MIN;
9395
9396 if (if_gain > if_agc_top) {
9397 if (rf_gain > rf_agc_max)
9398 *sig_strength = 100;
9399 else if (rf_gain > rf_agc_min) {
9400 if (rf_agc_max == rf_agc_min) {
9401 pr_err("error: rf_agc_max == rf_agc_min\n");
9402 return -EIO;
9403 }
9404 *sig_strength =
9405 75 + 25 * (rf_gain - rf_agc_min) / (rf_agc_max -
9406 rf_agc_min);
9407 } else
9408 *sig_strength = 75;
9409 } else if (if_gain > if_agc_sns) {
9410 if (if_agc_top == if_agc_sns) {
9411 pr_err("error: if_agc_top == if_agc_sns\n");
9412 return -EIO;
9413 }
9414 *sig_strength =
9415 20 + 55 * (if_gain - if_agc_sns) / (if_agc_top - if_agc_sns);
9416 } else {
9417 if (!if_agc_sns) {
9418 pr_err("error: if_agc_sns is zero!\n");
9419 return -EIO;
9420 }
9421 *sig_strength = (20 * if_gain / if_agc_sns);
9422 }
9423
9424 if (*sig_strength <= 7)
9425 *sig_strength = 0;
9426
9427 return 0;
9428 rw_error:
9429 return -EIO;
9430}
9431
9432/**
9433* \fn int ctrl_get_qam_sig_quality()
9434* \brief Retreive QAM signal quality from device.
9435* \param devmod Pointer to demodulator instance.
9436* \param sig_quality Pointer to signal quality data.
9437* \return int.
9438* \retval 0 sig_quality contains valid data.
9439* \retval -EINVAL sig_quality is NULL.
9440* \retval -EIO Erroneous data, sig_quality contains invalid data.
9441
9442* Pre-condition: Device must be started and in lock.
9443*/
9444static int
9445ctrl_get_qam_sig_quality(struct drx_demod_instance *demod)
9446{
9447 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
9448 struct drxj_data *ext_attr = demod->my_ext_attr;
9449 struct drx39xxj_state *state = dev_addr->user_data;
9450 struct dtv_frontend_properties *p = &state->frontend.dtv_property_cache;
9451 struct drxjrs_errors measuredrs_errors = { 0, 0, 0, 0, 0 };
9452 enum drx_modulation constellation = ext_attr->constellation;
9453 int rc;
9454
9455 u32 pre_bit_err_rs = 0; /* pre RedSolomon Bit Error Rate */
9456 u32 post_bit_err_rs = 0; /* post RedSolomon Bit Error Rate */
9457 u32 pkt_errs = 0; /* no of packet errors in RS */
9458 u16 qam_sl_err_power = 0; /* accumulated error between raw and sliced symbols */
9459 u16 qsym_err_vd = 0; /* quadrature symbol errors in QAM_VD */
9460 u16 fec_oc_period = 0; /* SNC sync failure measurement period */
9461 u16 fec_rs_prescale = 0; /* ReedSolomon Measurement Prescale */
9462 u16 fec_rs_period = 0; /* Value for corresponding I2C register */
9463 /* calculation constants */
9464 u32 rs_bit_cnt = 0; /* RedSolomon Bit Count */
9465 u32 qam_sl_sig_power = 0; /* used for MER, depends of QAM constellation */
9466 /* intermediate results */
9467 u32 e = 0; /* exponent value used for QAM BER/SER */
9468 u32 m = 0; /* mantisa value used for QAM BER/SER */
9469 u32 ber_cnt = 0; /* BER count */
9470 /* signal quality info */
9471 u32 qam_sl_mer = 0; /* QAM MER */
9472 u32 qam_pre_rs_ber = 0; /* Pre RedSolomon BER */
9473 u32 qam_post_rs_ber = 0; /* Post RedSolomon BER */
9474 u32 qam_vd_ser = 0; /* ViterbiDecoder SER */
9475 u16 qam_vd_prescale = 0; /* Viterbi Measurement Prescale */
9476 u16 qam_vd_period = 0; /* Viterbi Measurement period */
9477 u32 vd_bit_cnt = 0; /* ViterbiDecoder Bit Count */
9478
9479 p->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
9480
9481 /* read the physical registers */
9482 /* Get the RS error data */
9483 rc = get_qamrs_err_count(dev_addr, &measuredrs_errors);
9484 if (rc != 0) {
9485 pr_err("error %d\n", rc);
9486 goto rw_error;
9487 }
9488 /* get the register value needed for MER */
9489 rc = drxj_dap_read_reg16(dev_addr, QAM_SL_ERR_POWER__A, &qam_sl_err_power, 0);
9490 if (rc != 0) {
9491 pr_err("error %d\n", rc);
9492 goto rw_error;
9493 }
9494 /* get the register value needed for post RS BER */
9495 rc = drxj_dap_read_reg16(dev_addr, FEC_OC_SNC_FAIL_PERIOD__A, &fec_oc_period, 0);
9496 if (rc != 0) {
9497 pr_err("error %d\n", rc);
9498 goto rw_error;
9499 }
9500
9501 /* get constants needed for signal quality calculation */
9502 fec_rs_period = ext_attr->fec_rs_period;
9503 fec_rs_prescale = ext_attr->fec_rs_prescale;
9504 rs_bit_cnt = fec_rs_period * fec_rs_prescale * ext_attr->fec_rs_plen;
9505 qam_vd_period = ext_attr->qam_vd_period;
9506 qam_vd_prescale = ext_attr->qam_vd_prescale;
9507 vd_bit_cnt = qam_vd_period * qam_vd_prescale * ext_attr->fec_vd_plen;
9508
9509 /* DRXJ_QAM_SL_SIG_POWER_QAMxxx * 4 */
9510 switch (constellation) {
9511 case DRX_CONSTELLATION_QAM16:
9512 qam_sl_sig_power = DRXJ_QAM_SL_SIG_POWER_QAM16 << 2;
9513 break;
9514 case DRX_CONSTELLATION_QAM32:
9515 qam_sl_sig_power = DRXJ_QAM_SL_SIG_POWER_QAM32 << 2;
9516 break;
9517 case DRX_CONSTELLATION_QAM64:
9518 qam_sl_sig_power = DRXJ_QAM_SL_SIG_POWER_QAM64 << 2;
9519 break;
9520 case DRX_CONSTELLATION_QAM128:
9521 qam_sl_sig_power = DRXJ_QAM_SL_SIG_POWER_QAM128 << 2;
9522 break;
9523 case DRX_CONSTELLATION_QAM256:
9524 qam_sl_sig_power = DRXJ_QAM_SL_SIG_POWER_QAM256 << 2;
9525 break;
9526 default:
9527 return -EIO;
9528 }
9529
9530 /* ------------------------------ */
9531 /* MER Calculation */
9532 /* ------------------------------ */
9533 /* MER is good if it is above 27.5 for QAM256 or 21.5 for QAM64 */
9534
9535 /* 10.0*log10(qam_sl_sig_power * 4.0 / qam_sl_err_power); */
9536 if (qam_sl_err_power == 0)
9537 qam_sl_mer = 0;
9538 else
9539 qam_sl_mer = log1_times100(qam_sl_sig_power) - log1_times100((u32)qam_sl_err_power);
9540
9541 /* ----------------------------------------- */
9542 /* Pre Viterbi Symbol Error Rate Calculation */
9543 /* ----------------------------------------- */
9544 /* pre viterbi SER is good if it is bellow 0.025 */
9545
9546 /* get the register value */
9547 /* no of quadrature symbol errors */
9548 rc = drxj_dap_read_reg16(dev_addr, QAM_VD_NR_QSYM_ERRORS__A, &qsym_err_vd, 0);
9549 if (rc != 0) {
9550 pr_err("error %d\n", rc);
9551 goto rw_error;
9552 }
9553 /* Extract the Exponent and the Mantisa */
9554 /* of number of quadrature symbol errors */
9555 e = (qsym_err_vd & QAM_VD_NR_QSYM_ERRORS_EXP__M) >>
9556 QAM_VD_NR_QSYM_ERRORS_EXP__B;
9557 m = (qsym_err_vd & QAM_VD_NR_SYMBOL_ERRORS_FIXED_MANT__M) >>
9558 QAM_VD_NR_SYMBOL_ERRORS_FIXED_MANT__B;
9559
9560 if ((m << e) >> 3 > 549752)
9561 qam_vd_ser = 500000 * vd_bit_cnt * ((e > 2) ? 1 : 8) / 8;
9562 else
9563 qam_vd_ser = m << ((e > 2) ? (e - 3) : e);
9564
9565 /* --------------------------------------- */
9566 /* pre and post RedSolomon BER Calculation */
9567 /* --------------------------------------- */
9568 /* pre RS BER is good if it is below 3.5e-4 */
9569
9570 /* get the register values */
9571 pre_bit_err_rs = (u32) measuredrs_errors.nr_bit_errors;
9572 pkt_errs = post_bit_err_rs = (u32) measuredrs_errors.nr_snc_par_fail_count;
9573
9574 /* Extract the Exponent and the Mantisa of the */
9575 /* pre Reed-Solomon bit error count */
9576 e = (pre_bit_err_rs & FEC_RS_NR_BIT_ERRORS_EXP__M) >>
9577 FEC_RS_NR_BIT_ERRORS_EXP__B;
9578 m = (pre_bit_err_rs & FEC_RS_NR_BIT_ERRORS_FIXED_MANT__M) >>
9579 FEC_RS_NR_BIT_ERRORS_FIXED_MANT__B;
9580
9581 ber_cnt = m << e;
9582
9583 /*qam_pre_rs_ber = frac_times1e6( ber_cnt, rs_bit_cnt ); */
9584 if (m > (rs_bit_cnt >> (e + 1)) || (rs_bit_cnt >> e) == 0)
9585 qam_pre_rs_ber = 500000 * rs_bit_cnt >> e;
9586 else
9587 qam_pre_rs_ber = ber_cnt;
9588
9589 /* post RS BER = 1000000* (11.17 * FEC_OC_SNC_FAIL_COUNT__A) / */
9590 /* (1504.0 * FEC_OC_SNC_FAIL_PERIOD__A) */
9591 /*
9592 => c = (1000000*100*11.17)/1504 =
9593 post RS BER = (( c* FEC_OC_SNC_FAIL_COUNT__A) /
9594 (100 * FEC_OC_SNC_FAIL_PERIOD__A)
9595 *100 and /100 is for more precision.
9596 => (20 bits * 12 bits) /(16 bits * 7 bits) => safe in 32 bits computation
9597
9598 Precision errors still possible.
9599 */
9600 e = post_bit_err_rs * 742686;
9601 m = fec_oc_period * 100;
9602 if (fec_oc_period == 0)
9603 qam_post_rs_ber = 0xFFFFFFFF;
9604 else
9605 qam_post_rs_ber = e / m;
9606
9607 /* fill signal quality data structure */
9608 p->pre_bit_count.stat[0].scale = FE_SCALE_COUNTER;
9609 p->post_bit_count.stat[0].scale = FE_SCALE_COUNTER;
9610 p->pre_bit_error.stat[0].scale = FE_SCALE_COUNTER;
9611 p->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
9612 p->block_error.stat[0].scale = FE_SCALE_COUNTER;
9613 p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
9614
9615 p->cnr.stat[0].svalue = ((u16) qam_sl_mer) * 100;
9616 if (ext_attr->standard == DRX_STANDARD_ITU_B) {
9617 p->pre_bit_error.stat[0].uvalue += qam_vd_ser;
9618 p->pre_bit_count.stat[0].uvalue += vd_bit_cnt * ((e > 2) ? 1 : 8) / 8;
9619 } else {
9620 p->pre_bit_error.stat[0].uvalue += qam_pre_rs_ber;
9621 p->pre_bit_count.stat[0].uvalue += rs_bit_cnt >> e;
9622 }
9623
9624 p->post_bit_error.stat[0].uvalue += qam_post_rs_ber;
9625 p->post_bit_count.stat[0].uvalue += rs_bit_cnt >> e;
9626
9627 p->block_error.stat[0].uvalue += pkt_errs;
9628
9629#ifdef DRXJ_SIGNAL_ACCUM_ERR
9630 rc = get_acc_pkt_err(demod, &sig_quality->packet_error);
9631 if (rc != 0) {
9632 pr_err("error %d\n", rc);
9633 goto rw_error;
9634 }
9635#endif
9636
9637 return 0;
9638rw_error:
9639 p->pre_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
9640 p->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
9641 p->pre_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
9642 p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
9643 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
9644 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
9645
9646 return -EIO;
9647}
9648
9649#endif /* #ifndef DRXJ_VSB_ONLY */
9650
9651/*============================================================================*/
9652/*== END QAM DATAPATH FUNCTIONS ==*/
9653/*============================================================================*/
9654
9655/*============================================================================*/
9656/*============================================================================*/
9657/*== ATV DATAPATH FUNCTIONS ==*/
9658/*============================================================================*/
9659/*============================================================================*/
9660
9661/*
9662 Implementation notes.
9663
9664 NTSC/FM AGCs
9665
9666 Four AGCs are used for NTSC:
9667 (1) RF (used to attenuate the input signal in case of to much power)
9668 (2) IF (used to attenuate the input signal in case of to much power)
9669 (3) Video AGC (used to amplify the output signal in case input to low)
9670 (4) SIF AGC (used to amplify the output signal in case input to low)
9671
9672 Video AGC is coupled to RF and IF. SIF AGC is not coupled. It is assumed
9673 that the coupling between Video AGC and the RF and IF AGCs also works in
9674 favor of the SIF AGC.
9675
9676 Three AGCs are used for FM:
9677 (1) RF (used to attenuate the input signal in case of to much power)
9678 (2) IF (used to attenuate the input signal in case of to much power)
9679 (3) SIF AGC (used to amplify the output signal in case input to low)
9680
9681 The SIF AGC is now coupled to the RF/IF AGCs.
9682 The SIF AGC is needed for both SIF ouput and the internal SIF signal to
9683 the AUD block.
9684
9685 RF and IF AGCs DACs are part of AFE, Video and SIF AGC DACs are part of
9686 the ATV block. The AGC control algorithms are all implemented in
9687 microcode.
9688
9689 ATV SETTINGS
9690
9691 (Shadow settings will not be used for now, they will be implemented
9692 later on because of the schedule)
9693
9694 Several HW/SCU "settings" can be used for ATV. The standard selection
9695 will reset most of these settings. To avoid that the end user apllication
9696 has to perform these settings each time the ATV or FM standards is
9697 selected the driver will shadow these settings. This enables the end user
9698 to perform the settings only once after a drx_open(). The driver must
9699 write the shadow settings to HW/SCU incase:
9700 ( setstandard FM/ATV) ||
9701 ( settings have changed && FM/ATV standard is active)
9702 The shadow settings will be stored in the device specific data container.
9703 A set of flags will be defined to flag changes in shadow settings.
9704 A routine will be implemented to write all changed shadow settings to
9705 HW/SCU.
9706
9707 The "settings" will consist of: AGC settings, filter settings etc.
9708
9709 Disadvantage of use of shadow settings:
9710 Direct changes in HW/SCU registers will not be reflected in the
9711 shadow settings and these changes will be overwritten during a next
9712 update. This can happen during evaluation. This will not be a problem
9713 for normal customer usage.
9714*/
9715/* -------------------------------------------------------------------------- */
9716
9717/**
9718* \fn int power_down_atv ()
9719* \brief Power down ATV.
9720* \param demod instance of demodulator
9721* \param standard either NTSC or FM (sub strandard for ATV )
9722* \return int.
9723*
9724* Stops and thus resets ATV and IQM block
9725* SIF and CVBS ADC are powered down
9726* Calls audio power down
9727*/
9728static int
9729power_down_atv(struct drx_demod_instance *demod, enum drx_standard standard, bool primary)
9730{
9731 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
9732 struct drxjscu_cmd cmd_scu = { /* command */ 0,
9733 /* parameter_len */ 0,
9734 /* result_len */ 0,
9735 /* *parameter */ NULL,
9736 /* *result */ NULL
9737 };
9738 int rc;
9739 u16 cmd_result = 0;
9740
9741 /* ATV NTSC */
9742
9743 /* Stop ATV SCU (will reset ATV and IQM hardware */
9744 cmd_scu.command = SCU_RAM_COMMAND_STANDARD_ATV |
9745 SCU_RAM_COMMAND_CMD_DEMOD_STOP;
9746 cmd_scu.parameter_len = 0;
9747 cmd_scu.result_len = 1;
9748 cmd_scu.parameter = NULL;
9749 cmd_scu.result = &cmd_result;
9750 rc = scu_command(dev_addr, &cmd_scu);
9751 if (rc != 0) {
9752 pr_err("error %d\n", rc);
9753 goto rw_error;
9754 }
9755 /* Disable ATV outputs (ATV reset enables CVBS, undo this) */
9756 rc = drxj_dap_write_reg16(dev_addr, ATV_TOP_STDBY__A, (ATV_TOP_STDBY_SIF_STDBY_STANDBY & (~ATV_TOP_STDBY_CVBS_STDBY_A2_ACTIVE)), 0);
9757 if (rc != 0) {
9758 pr_err("error %d\n", rc);
9759 goto rw_error;
9760 }
9761
9762 rc = drxj_dap_write_reg16(dev_addr, ATV_COMM_EXEC__A, ATV_COMM_EXEC_STOP, 0);
9763 if (rc != 0) {
9764 pr_err("error %d\n", rc);
9765 goto rw_error;
9766 }
9767 if (primary) {
9768 rc = drxj_dap_write_reg16(dev_addr, IQM_COMM_EXEC__A, IQM_COMM_EXEC_STOP, 0);
9769 if (rc != 0) {
9770 pr_err("error %d\n", rc);
9771 goto rw_error;
9772 }
9773 rc = set_iqm_af(demod, false);
9774 if (rc != 0) {
9775 pr_err("error %d\n", rc);
9776 goto rw_error;
9777 }
9778 } else {
9779 rc = drxj_dap_write_reg16(dev_addr, IQM_FS_COMM_EXEC__A, IQM_FS_COMM_EXEC_STOP, 0);
9780 if (rc != 0) {
9781 pr_err("error %d\n", rc);
9782 goto rw_error;
9783 }
9784 rc = drxj_dap_write_reg16(dev_addr, IQM_FD_COMM_EXEC__A, IQM_FD_COMM_EXEC_STOP, 0);
9785 if (rc != 0) {
9786 pr_err("error %d\n", rc);
9787 goto rw_error;
9788 }
9789 rc = drxj_dap_write_reg16(dev_addr, IQM_RC_COMM_EXEC__A, IQM_RC_COMM_EXEC_STOP, 0);
9790 if (rc != 0) {
9791 pr_err("error %d\n", rc);
9792 goto rw_error;
9793 }
9794 rc = drxj_dap_write_reg16(dev_addr, IQM_RT_COMM_EXEC__A, IQM_RT_COMM_EXEC_STOP, 0);
9795 if (rc != 0) {
9796 pr_err("error %d\n", rc);
9797 goto rw_error;
9798 }
9799 rc = drxj_dap_write_reg16(dev_addr, IQM_CF_COMM_EXEC__A, IQM_CF_COMM_EXEC_STOP, 0);
9800 if (rc != 0) {
9801 pr_err("error %d\n", rc);
9802 goto rw_error;
9803 }
9804 }
9805 rc = power_down_aud(demod);
9806 if (rc != 0) {
9807 pr_err("error %d\n", rc);
9808 goto rw_error;
9809 }
9810
9811 return 0;
9812rw_error:
9813 return -EIO;
9814}
9815
9816/*============================================================================*/
9817
9818/**
9819* \brief Power up AUD.
9820* \param demod instance of demodulator
9821* \return int.
9822*
9823*/
9824static int power_down_aud(struct drx_demod_instance *demod)
9825{
9826 struct i2c_device_addr *dev_addr = NULL;
9827 struct drxj_data *ext_attr = NULL;
9828 int rc;
9829
9830 dev_addr = (struct i2c_device_addr *)demod->my_i2c_dev_addr;
9831 ext_attr = (struct drxj_data *) demod->my_ext_attr;
9832
9833 rc = drxj_dap_write_reg16(dev_addr, AUD_COMM_EXEC__A, AUD_COMM_EXEC_STOP, 0);
9834 if (rc != 0) {
9835 pr_err("error %d\n", rc);
9836 goto rw_error;
9837 }
9838
9839 ext_attr->aud_data.audio_is_active = false;
9840
9841 return 0;
9842rw_error:
9843 return -EIO;
9844}
9845
9846/**
9847* \fn int set_orx_nsu_aox()
9848* \brief Configure OrxNsuAox for OOB
9849* \param demod instance of demodulator.
9850* \param active
9851* \return int.
9852*/
9853static int set_orx_nsu_aox(struct drx_demod_instance *demod, bool active)
9854{
9855 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
9856 int rc;
9857 u16 data = 0;
9858
9859 /* Configure NSU_AOX */
9860 rc = drxj_dap_read_reg16(dev_addr, ORX_NSU_AOX_STDBY_W__A, &data, 0);
9861 if (rc != 0) {
9862 pr_err("error %d\n", rc);
9863 goto rw_error;
9864 }
9865 if (!active)
9866 data &= ((~ORX_NSU_AOX_STDBY_W_STDBYADC_A2_ON) & (~ORX_NSU_AOX_STDBY_W_STDBYAMP_A2_ON) & (~ORX_NSU_AOX_STDBY_W_STDBYBIAS_A2_ON) & (~ORX_NSU_AOX_STDBY_W_STDBYPLL_A2_ON) & (~ORX_NSU_AOX_STDBY_W_STDBYPD_A2_ON) & (~ORX_NSU_AOX_STDBY_W_STDBYTAGC_IF_A2_ON) & (~ORX_NSU_AOX_STDBY_W_STDBYTAGC_RF_A2_ON) & (~ORX_NSU_AOX_STDBY_W_STDBYFLT_A2_ON));
9867 else
9868 data |= (ORX_NSU_AOX_STDBY_W_STDBYADC_A2_ON | ORX_NSU_AOX_STDBY_W_STDBYAMP_A2_ON | ORX_NSU_AOX_STDBY_W_STDBYBIAS_A2_ON | ORX_NSU_AOX_STDBY_W_STDBYPLL_A2_ON | ORX_NSU_AOX_STDBY_W_STDBYPD_A2_ON | ORX_NSU_AOX_STDBY_W_STDBYTAGC_IF_A2_ON | ORX_NSU_AOX_STDBY_W_STDBYTAGC_RF_A2_ON | ORX_NSU_AOX_STDBY_W_STDBYFLT_A2_ON);
9869 rc = drxj_dap_write_reg16(dev_addr, ORX_NSU_AOX_STDBY_W__A, data, 0);
9870 if (rc != 0) {
9871 pr_err("error %d\n", rc);
9872 goto rw_error;
9873 }
9874
9875 return 0;
9876rw_error:
9877 return -EIO;
9878}
9879
9880/**
9881* \fn int ctrl_set_oob()
9882* \brief Set OOB channel to be used.
9883* \param demod instance of demodulator
9884* \param oob_param OOB parameters for channel setting.
9885* \frequency should be in KHz
9886* \return int.
9887*
9888* Accepts only. Returns error otherwise.
9889* Demapper value is written after scu_command START
9890* because START command causes COMM_EXEC transition
9891* from 0 to 1 which causes all registers to be
9892* overwritten with initial value
9893*
9894*/
9895
9896/* Nyquist filter impulse response */
9897#define IMPULSE_COSINE_ALPHA_0_3 {-3, -4, -1, 6, 10, 7, -5, -20, -25, -10, 29, 79, 123, 140} /*sqrt raised-cosine filter with alpha=0.3 */
9898#define IMPULSE_COSINE_ALPHA_0_5 { 2, 0, -2, -2, 2, 5, 2, -10, -20, -14, 20, 74, 125, 145} /*sqrt raised-cosine filter with alpha=0.5 */
9899#define IMPULSE_COSINE_ALPHA_RO_0_5 { 0, 0, 1, 2, 3, 0, -7, -15, -16, 0, 34, 77, 114, 128} /*full raised-cosine filter with alpha=0.5 (receiver only) */
9900
9901/* Coefficients for the nyquist fitler (total: 27 taps) */
9902#define NYQFILTERLEN 27
9903
9904static int ctrl_set_oob(struct drx_demod_instance *demod, struct drxoob *oob_param)
9905{
9906 int rc;
9907 s32 freq = 0; /* KHz */
9908 struct i2c_device_addr *dev_addr = NULL;
9909 struct drxj_data *ext_attr = NULL;
9910 u16 i = 0;
9911 bool mirror_freq_spect_oob = false;
9912 u16 trk_filter_value = 0;
9913 struct drxjscu_cmd scu_cmd;
9914 u16 set_param_parameters[3];
9915 u16 cmd_result[2] = { 0, 0 };
9916 s16 nyquist_coeffs[4][(NYQFILTERLEN + 1) / 2] = {
9917 IMPULSE_COSINE_ALPHA_0_3, /* Target Mode 0 */
9918 IMPULSE_COSINE_ALPHA_0_3, /* Target Mode 1 */
9919 IMPULSE_COSINE_ALPHA_0_5, /* Target Mode 2 */
9920 IMPULSE_COSINE_ALPHA_RO_0_5 /* Target Mode 3 */
9921 };
9922 u8 mode_val[4] = { 2, 2, 0, 1 };
9923 u8 pfi_coeffs[4][6] = {
9924 {DRXJ_16TO8(-92), DRXJ_16TO8(-108), DRXJ_16TO8(100)}, /* TARGET_MODE = 0: PFI_A = -23/32; PFI_B = -54/32; PFI_C = 25/32; fg = 0.5 MHz (Att=26dB) */
9925 {DRXJ_16TO8(-64), DRXJ_16TO8(-80), DRXJ_16TO8(80)}, /* TARGET_MODE = 1: PFI_A = -16/32; PFI_B = -40/32; PFI_C = 20/32; fg = 1.0 MHz (Att=28dB) */
9926 {DRXJ_16TO8(-80), DRXJ_16TO8(-98), DRXJ_16TO8(92)}, /* TARGET_MODE = 2, 3: PFI_A = -20/32; PFI_B = -49/32; PFI_C = 23/32; fg = 0.8 MHz (Att=25dB) */
9927 {DRXJ_16TO8(-80), DRXJ_16TO8(-98), DRXJ_16TO8(92)} /* TARGET_MODE = 2, 3: PFI_A = -20/32; PFI_B = -49/32; PFI_C = 23/32; fg = 0.8 MHz (Att=25dB) */
9928 };
9929 u16 mode_index;
9930
9931 dev_addr = demod->my_i2c_dev_addr;
9932 ext_attr = (struct drxj_data *) demod->my_ext_attr;
9933 mirror_freq_spect_oob = ext_attr->mirror_freq_spect_oob;
9934
9935 /* Check parameters */
9936 if (oob_param == NULL) {
9937 /* power off oob module */
9938 scu_cmd.command = SCU_RAM_COMMAND_STANDARD_OOB
9939 | SCU_RAM_COMMAND_CMD_DEMOD_STOP;
9940 scu_cmd.parameter_len = 0;
9941 scu_cmd.result_len = 1;
9942 scu_cmd.result = cmd_result;
9943 rc = scu_command(dev_addr, &scu_cmd);
9944 if (rc != 0) {
9945 pr_err("error %d\n", rc);
9946 goto rw_error;
9947 }
9948 rc = set_orx_nsu_aox(demod, false);
9949 if (rc != 0) {
9950 pr_err("error %d\n", rc);
9951 goto rw_error;
9952 }
9953 rc = drxj_dap_write_reg16(dev_addr, ORX_COMM_EXEC__A, ORX_COMM_EXEC_STOP, 0);
9954 if (rc != 0) {
9955 pr_err("error %d\n", rc);
9956 goto rw_error;
9957 }
9958
9959 ext_attr->oob_power_on = false;
9960 return 0;
9961 }
9962
9963 freq = oob_param->frequency;
9964 if ((freq < 70000) || (freq > 130000))
9965 return -EIO;
9966 freq = (freq - 50000) / 50;
9967
9968 {
9969 u16 index = 0;
9970 u16 remainder = 0;
9971 u16 *trk_filtercfg = ext_attr->oob_trk_filter_cfg;
9972
9973 index = (u16) ((freq - 400) / 200);
9974 remainder = (u16) ((freq - 400) % 200);
9975 trk_filter_value =
9976 trk_filtercfg[index] - (trk_filtercfg[index] -
9977 trk_filtercfg[index +
9978 1]) / 10 * remainder /
9979 20;
9980 }
9981
9982 /*********/
9983 /* Stop */
9984 /*********/
9985 rc = drxj_dap_write_reg16(dev_addr, ORX_COMM_EXEC__A, ORX_COMM_EXEC_STOP, 0);
9986 if (rc != 0) {
9987 pr_err("error %d\n", rc);
9988 goto rw_error;
9989 }
9990 scu_cmd.command = SCU_RAM_COMMAND_STANDARD_OOB
9991 | SCU_RAM_COMMAND_CMD_DEMOD_STOP;
9992 scu_cmd.parameter_len = 0;
9993 scu_cmd.result_len = 1;
9994 scu_cmd.result = cmd_result;
9995 rc = scu_command(dev_addr, &scu_cmd);
9996 if (rc != 0) {
9997 pr_err("error %d\n", rc);
9998 goto rw_error;
9999 }
10000 /*********/
10001 /* Reset */
10002 /*********/
10003 scu_cmd.command = SCU_RAM_COMMAND_STANDARD_OOB
10004 | SCU_RAM_COMMAND_CMD_DEMOD_RESET;
10005 scu_cmd.parameter_len = 0;
10006 scu_cmd.result_len = 1;
10007 scu_cmd.result = cmd_result;
10008 rc = scu_command(dev_addr, &scu_cmd);
10009 if (rc != 0) {
10010 pr_err("error %d\n", rc);
10011 goto rw_error;
10012 }
10013 /***********/
10014 /* SET_ENV */
10015 /***********/
10016 /* set frequency, spectrum inversion and data rate */
10017 scu_cmd.command = SCU_RAM_COMMAND_STANDARD_OOB
10018 | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV;
10019 scu_cmd.parameter_len = 3;
10020 /* 1-data rate;2-frequency */
10021 switch (oob_param->standard) {
10022 case DRX_OOB_MODE_A:
10023 if (
10024 /* signal is transmitted inverted */
10025 ((oob_param->spectrum_inverted == true) &&
10026 /* and tuner is not mirroring the signal */
10027 (!mirror_freq_spect_oob)) |
10028 /* or */
10029 /* signal is transmitted noninverted */
10030 ((oob_param->spectrum_inverted == false) &&
10031 /* and tuner is mirroring the signal */
10032 (mirror_freq_spect_oob))
10033 )
10034 set_param_parameters[0] =
10035 SCU_RAM_ORX_RF_RX_DATA_RATE_2048KBPS_INVSPEC;
10036 else
10037 set_param_parameters[0] =
10038 SCU_RAM_ORX_RF_RX_DATA_RATE_2048KBPS_REGSPEC;
10039 break;
10040 case DRX_OOB_MODE_B_GRADE_A:
10041 if (
10042 /* signal is transmitted inverted */
10043 ((oob_param->spectrum_inverted == true) &&
10044 /* and tuner is not mirroring the signal */
10045 (!mirror_freq_spect_oob)) |
10046 /* or */
10047 /* signal is transmitted noninverted */
10048 ((oob_param->spectrum_inverted == false) &&
10049 /* and tuner is mirroring the signal */
10050 (mirror_freq_spect_oob))
10051 )
10052 set_param_parameters[0] =
10053 SCU_RAM_ORX_RF_RX_DATA_RATE_1544KBPS_INVSPEC;
10054 else
10055 set_param_parameters[0] =
10056 SCU_RAM_ORX_RF_RX_DATA_RATE_1544KBPS_REGSPEC;
10057 break;
10058 case DRX_OOB_MODE_B_GRADE_B:
10059 default:
10060 if (
10061 /* signal is transmitted inverted */
10062 ((oob_param->spectrum_inverted == true) &&
10063 /* and tuner is not mirroring the signal */
10064 (!mirror_freq_spect_oob)) |
10065 /* or */
10066 /* signal is transmitted noninverted */
10067 ((oob_param->spectrum_inverted == false) &&
10068 /* and tuner is mirroring the signal */
10069 (mirror_freq_spect_oob))
10070 )
10071 set_param_parameters[0] =
10072 SCU_RAM_ORX_RF_RX_DATA_RATE_3088KBPS_INVSPEC;
10073 else
10074 set_param_parameters[0] =
10075 SCU_RAM_ORX_RF_RX_DATA_RATE_3088KBPS_REGSPEC;
10076 break;
10077 }
10078 set_param_parameters[1] = (u16) (freq & 0xFFFF);
10079 set_param_parameters[2] = trk_filter_value;
10080 scu_cmd.parameter = set_param_parameters;
10081 scu_cmd.result_len = 1;
10082 scu_cmd.result = cmd_result;
10083 mode_index = mode_val[(set_param_parameters[0] & 0xC0) >> 6];
10084 rc = scu_command(dev_addr, &scu_cmd);
10085 if (rc != 0) {
10086 pr_err("error %d\n", rc);
10087 goto rw_error;
10088 }
10089
10090 rc = drxj_dap_write_reg16(dev_addr, SIO_TOP_COMM_KEY__A, 0xFABA, 0);
10091 if (rc != 0) {
10092 pr_err("error %d\n", rc);
10093 goto rw_error;
10094 } /* Write magic word to enable pdr reg write */
10095 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_OOB_CRX_CFG__A, OOB_CRX_DRIVE_STRENGTH << SIO_PDR_OOB_CRX_CFG_DRIVE__B | 0x03 << SIO_PDR_OOB_CRX_CFG_MODE__B, 0);
10096 if (rc != 0) {
10097 pr_err("error %d\n", rc);
10098 goto rw_error;
10099 }
10100 rc = drxj_dap_write_reg16(dev_addr, SIO_PDR_OOB_DRX_CFG__A, OOB_DRX_DRIVE_STRENGTH << SIO_PDR_OOB_DRX_CFG_DRIVE__B | 0x03 << SIO_PDR_OOB_DRX_CFG_MODE__B, 0);
10101 if (rc != 0) {
10102 pr_err("error %d\n", rc);
10103 goto rw_error;
10104 }
10105 rc = drxj_dap_write_reg16(dev_addr, SIO_TOP_COMM_KEY__A, 0x0000, 0);
10106 if (rc != 0) {
10107 pr_err("error %d\n", rc);
10108 goto rw_error;
10109 } /* Write magic word to disable pdr reg write */
10110
10111 rc = drxj_dap_write_reg16(dev_addr, ORX_TOP_COMM_KEY__A, 0, 0);
10112 if (rc != 0) {
10113 pr_err("error %d\n", rc);
10114 goto rw_error;
10115 }
10116 rc = drxj_dap_write_reg16(dev_addr, ORX_FWP_AAG_LEN_W__A, 16000, 0);
10117 if (rc != 0) {
10118 pr_err("error %d\n", rc);
10119 goto rw_error;
10120 }
10121 rc = drxj_dap_write_reg16(dev_addr, ORX_FWP_AAG_THR_W__A, 40, 0);
10122 if (rc != 0) {
10123 pr_err("error %d\n", rc);
10124 goto rw_error;
10125 }
10126
10127 /* ddc */
10128 rc = drxj_dap_write_reg16(dev_addr, ORX_DDC_OFO_SET_W__A, ORX_DDC_OFO_SET_W__PRE, 0);
10129 if (rc != 0) {
10130 pr_err("error %d\n", rc);
10131 goto rw_error;
10132 }
10133
10134 /* nsu */
10135 rc = drxj_dap_write_reg16(dev_addr, ORX_NSU_AOX_LOPOW_W__A, ext_attr->oob_lo_pow, 0);
10136 if (rc != 0) {
10137 pr_err("error %d\n", rc);
10138 goto rw_error;
10139 }
10140
10141 /* initialization for target mode */
10142 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_TARGET_MODE__A, SCU_RAM_ORX_TARGET_MODE_2048KBPS_SQRT, 0);
10143 if (rc != 0) {
10144 pr_err("error %d\n", rc);
10145 goto rw_error;
10146 }
10147 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_FREQ_GAIN_CORR__A, SCU_RAM_ORX_FREQ_GAIN_CORR_2048KBPS, 0);
10148 if (rc != 0) {
10149 pr_err("error %d\n", rc);
10150 goto rw_error;
10151 }
10152
10153 /* Reset bits for timing and freq. recovery */
10154 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_RST_CPH__A, 0x0001, 0);
10155 if (rc != 0) {
10156 pr_err("error %d\n", rc);
10157 goto rw_error;
10158 }
10159 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_RST_CTI__A, 0x0002, 0);
10160 if (rc != 0) {
10161 pr_err("error %d\n", rc);
10162 goto rw_error;
10163 }
10164 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_RST_KRN__A, 0x0004, 0);
10165 if (rc != 0) {
10166 pr_err("error %d\n", rc);
10167 goto rw_error;
10168 }
10169 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_RST_KRP__A, 0x0008, 0);
10170 if (rc != 0) {
10171 pr_err("error %d\n", rc);
10172 goto rw_error;
10173 }
10174
10175 /* AGN_LOCK = {2048>>3, -2048, 8, -8, 0, 1}; */
10176 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_AGN_LOCK_TH__A, 2048 >> 3, 0);
10177 if (rc != 0) {
10178 pr_err("error %d\n", rc);
10179 goto rw_error;
10180 }
10181 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_AGN_LOCK_TOTH__A, (u16)(-2048), 0);
10182 if (rc != 0) {
10183 pr_err("error %d\n", rc);
10184 goto rw_error;
10185 }
10186 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_AGN_ONLOCK_TTH__A, 8, 0);
10187 if (rc != 0) {
10188 pr_err("error %d\n", rc);
10189 goto rw_error;
10190 }
10191 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_AGN_UNLOCK_TTH__A, (u16)(-8), 0);
10192 if (rc != 0) {
10193 pr_err("error %d\n", rc);
10194 goto rw_error;
10195 }
10196 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_AGN_LOCK_MASK__A, 1, 0);
10197 if (rc != 0) {
10198 pr_err("error %d\n", rc);
10199 goto rw_error;
10200 }
10201
10202 /* DGN_LOCK = {10, -2048, 8, -8, 0, 1<<1}; */
10203 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_DGN_LOCK_TH__A, 10, 0);
10204 if (rc != 0) {
10205 pr_err("error %d\n", rc);
10206 goto rw_error;
10207 }
10208 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_DGN_LOCK_TOTH__A, (u16)(-2048), 0);
10209 if (rc != 0) {
10210 pr_err("error %d\n", rc);
10211 goto rw_error;
10212 }
10213 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_DGN_ONLOCK_TTH__A, 8, 0);
10214 if (rc != 0) {
10215 pr_err("error %d\n", rc);
10216 goto rw_error;
10217 }
10218 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_DGN_UNLOCK_TTH__A, (u16)(-8), 0);
10219 if (rc != 0) {
10220 pr_err("error %d\n", rc);
10221 goto rw_error;
10222 }
10223 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_DGN_LOCK_MASK__A, 1 << 1, 0);
10224 if (rc != 0) {
10225 pr_err("error %d\n", rc);
10226 goto rw_error;
10227 }
10228
10229 /* FRQ_LOCK = {15,-2048, 8, -8, 0, 1<<2}; */
10230 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_FRQ_LOCK_TH__A, 17, 0);
10231 if (rc != 0) {
10232 pr_err("error %d\n", rc);
10233 goto rw_error;
10234 }
10235 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_FRQ_LOCK_TOTH__A, (u16)(-2048), 0);
10236 if (rc != 0) {
10237 pr_err("error %d\n", rc);
10238 goto rw_error;
10239 }
10240 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_FRQ_ONLOCK_TTH__A, 8, 0);
10241 if (rc != 0) {
10242 pr_err("error %d\n", rc);
10243 goto rw_error;
10244 }
10245 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_FRQ_UNLOCK_TTH__A, (u16)(-8), 0);
10246 if (rc != 0) {
10247 pr_err("error %d\n", rc);
10248 goto rw_error;
10249 }
10250 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_FRQ_LOCK_MASK__A, 1 << 2, 0);
10251 if (rc != 0) {
10252 pr_err("error %d\n", rc);
10253 goto rw_error;
10254 }
10255
10256 /* PHA_LOCK = {5000, -2048, 8, -8, 0, 1<<3}; */
10257 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_PHA_LOCK_TH__A, 3000, 0);
10258 if (rc != 0) {
10259 pr_err("error %d\n", rc);
10260 goto rw_error;
10261 }
10262 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_PHA_LOCK_TOTH__A, (u16)(-2048), 0);
10263 if (rc != 0) {
10264 pr_err("error %d\n", rc);
10265 goto rw_error;
10266 }
10267 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_PHA_ONLOCK_TTH__A, 8, 0);
10268 if (rc != 0) {
10269 pr_err("error %d\n", rc);
10270 goto rw_error;
10271 }
10272 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_PHA_UNLOCK_TTH__A, (u16)(-8), 0);
10273 if (rc != 0) {
10274 pr_err("error %d\n", rc);
10275 goto rw_error;
10276 }
10277 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_PHA_LOCK_MASK__A, 1 << 3, 0);
10278 if (rc != 0) {
10279 pr_err("error %d\n", rc);
10280 goto rw_error;
10281 }
10282
10283 /* TIM_LOCK = {300, -2048, 8, -8, 0, 1<<4}; */
10284 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_TIM_LOCK_TH__A, 400, 0);
10285 if (rc != 0) {
10286 pr_err("error %d\n", rc);
10287 goto rw_error;
10288 }
10289 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_TIM_LOCK_TOTH__A, (u16)(-2048), 0);
10290 if (rc != 0) {
10291 pr_err("error %d\n", rc);
10292 goto rw_error;
10293 }
10294 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_TIM_ONLOCK_TTH__A, 8, 0);
10295 if (rc != 0) {
10296 pr_err("error %d\n", rc);
10297 goto rw_error;
10298 }
10299 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_TIM_UNLOCK_TTH__A, (u16)(-8), 0);
10300 if (rc != 0) {
10301 pr_err("error %d\n", rc);
10302 goto rw_error;
10303 }
10304 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_TIM_LOCK_MASK__A, 1 << 4, 0);
10305 if (rc != 0) {
10306 pr_err("error %d\n", rc);
10307 goto rw_error;
10308 }
10309
10310 /* EQU_LOCK = {20, -2048, 8, -8, 0, 1<<5}; */
10311 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_EQU_LOCK_TH__A, 20, 0);
10312 if (rc != 0) {
10313 pr_err("error %d\n", rc);
10314 goto rw_error;
10315 }
10316 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_EQU_LOCK_TOTH__A, (u16)(-2048), 0);
10317 if (rc != 0) {
10318 pr_err("error %d\n", rc);
10319 goto rw_error;
10320 }
10321 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_EQU_ONLOCK_TTH__A, 4, 0);
10322 if (rc != 0) {
10323 pr_err("error %d\n", rc);
10324 goto rw_error;
10325 }
10326 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_EQU_UNLOCK_TTH__A, (u16)(-4), 0);
10327 if (rc != 0) {
10328 pr_err("error %d\n", rc);
10329 goto rw_error;
10330 }
10331 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_ORX_EQU_LOCK_MASK__A, 1 << 5, 0);
10332 if (rc != 0) {
10333 pr_err("error %d\n", rc);
10334 goto rw_error;
10335 }
10336
10337 /* PRE-Filter coefficients (PFI) */
10338 rc = drxdap_fasi_write_block(dev_addr, ORX_FWP_PFI_A_W__A, sizeof(pfi_coeffs[mode_index]), ((u8 *)pfi_coeffs[mode_index]), 0);
10339 if (rc != 0) {
10340 pr_err("error %d\n", rc);
10341 goto rw_error;
10342 }
10343 rc = drxj_dap_write_reg16(dev_addr, ORX_TOP_MDE_W__A, mode_index, 0);
10344 if (rc != 0) {
10345 pr_err("error %d\n", rc);
10346 goto rw_error;
10347 }
10348
10349 /* NYQUIST-Filter coefficients (NYQ) */
10350 for (i = 0; i < (NYQFILTERLEN + 1) / 2; i++) {
10351 rc = drxj_dap_write_reg16(dev_addr, ORX_FWP_NYQ_ADR_W__A, i, 0);
10352 if (rc != 0) {
10353 pr_err("error %d\n", rc);
10354 goto rw_error;
10355 }
10356 rc = drxj_dap_write_reg16(dev_addr, ORX_FWP_NYQ_COF_RW__A, nyquist_coeffs[mode_index][i], 0);
10357 if (rc != 0) {
10358 pr_err("error %d\n", rc);
10359 goto rw_error;
10360 }
10361 }
10362 rc = drxj_dap_write_reg16(dev_addr, ORX_FWP_NYQ_ADR_W__A, 31, 0);
10363 if (rc != 0) {
10364 pr_err("error %d\n", rc);
10365 goto rw_error;
10366 }
10367 rc = drxj_dap_write_reg16(dev_addr, ORX_COMM_EXEC__A, ORX_COMM_EXEC_ACTIVE, 0);
10368 if (rc != 0) {
10369 pr_err("error %d\n", rc);
10370 goto rw_error;
10371 }
10372 /*********/
10373 /* Start */
10374 /*********/
10375 scu_cmd.command = SCU_RAM_COMMAND_STANDARD_OOB
10376 | SCU_RAM_COMMAND_CMD_DEMOD_START;
10377 scu_cmd.parameter_len = 0;
10378 scu_cmd.result_len = 1;
10379 scu_cmd.result = cmd_result;
10380 rc = scu_command(dev_addr, &scu_cmd);
10381 if (rc != 0) {
10382 pr_err("error %d\n", rc);
10383 goto rw_error;
10384 }
10385
10386 rc = set_orx_nsu_aox(demod, true);
10387 if (rc != 0) {
10388 pr_err("error %d\n", rc);
10389 goto rw_error;
10390 }
10391 rc = drxj_dap_write_reg16(dev_addr, ORX_NSU_AOX_STHR_W__A, ext_attr->oob_pre_saw, 0);
10392 if (rc != 0) {
10393 pr_err("error %d\n", rc);
10394 goto rw_error;
10395 }
10396
10397 ext_attr->oob_power_on = true;
10398
10399 return 0;
10400rw_error:
10401 return -EIO;
10402}
10403
10404/*============================================================================*/
10405/*== END OOB DATAPATH FUNCTIONS ==*/
10406/*============================================================================*/
10407
10408/*=============================================================================
10409 ===== MC command related functions ==========================================
10410 ===========================================================================*/
10411
10412/*=============================================================================
10413 ===== ctrl_set_channel() ==========================================================
10414 ===========================================================================*/
10415/**
10416* \fn int ctrl_set_channel()
10417* \brief Select a new transmission channel.
10418* \param demod instance of demod.
10419* \param channel Pointer to channel data.
10420* \return int.
10421*
10422* In case the tuner module is not used and in case of NTSC/FM the pogrammer
10423* must tune the tuner to the centre frequency of the NTSC/FM channel.
10424*
10425*/
10426static int
10427ctrl_set_channel(struct drx_demod_instance *demod, struct drx_channel *channel)
10428{
10429 int rc;
10430 s32 tuner_freq_offset = 0;
10431 struct drxj_data *ext_attr = NULL;
10432 struct i2c_device_addr *dev_addr = NULL;
10433 enum drx_standard standard = DRX_STANDARD_UNKNOWN;
10434#ifndef DRXJ_VSB_ONLY
10435 u32 min_symbol_rate = 0;
10436 u32 max_symbol_rate = 0;
10437 int bandwidth_temp = 0;
10438 int bandwidth = 0;
10439#endif
10440 /*== check arguments ======================================================*/
10441 if ((demod == NULL) || (channel == NULL))
10442 return -EINVAL;
10443
10444 dev_addr = demod->my_i2c_dev_addr;
10445 ext_attr = (struct drxj_data *) demod->my_ext_attr;
10446 standard = ext_attr->standard;
10447
10448 /* check valid standards */
10449 switch (standard) {
10450 case DRX_STANDARD_8VSB:
10451#ifndef DRXJ_VSB_ONLY
10452 case DRX_STANDARD_ITU_A:
10453 case DRX_STANDARD_ITU_B:
10454 case DRX_STANDARD_ITU_C:
10455#endif /* DRXJ_VSB_ONLY */
10456 break;
10457 case DRX_STANDARD_UNKNOWN:
10458 default:
10459 return -EINVAL;
10460 }
10461
10462 /* check bandwidth QAM annex B, NTSC and 8VSB */
10463 if ((standard == DRX_STANDARD_ITU_B) ||
10464 (standard == DRX_STANDARD_8VSB) ||
10465 (standard == DRX_STANDARD_NTSC)) {
10466 switch (channel->bandwidth) {
10467 case DRX_BANDWIDTH_6MHZ:
10468 case DRX_BANDWIDTH_UNKNOWN: /* fall through */
10469 channel->bandwidth = DRX_BANDWIDTH_6MHZ;
10470 break;
10471 case DRX_BANDWIDTH_8MHZ: /* fall through */
10472 case DRX_BANDWIDTH_7MHZ: /* fall through */
10473 default:
10474 return -EINVAL;
10475 }
10476 }
10477
10478 /* For QAM annex A and annex C:
10479 -check symbolrate and constellation
10480 -derive bandwidth from symbolrate (input bandwidth is ignored)
10481 */
10482#ifndef DRXJ_VSB_ONLY
10483 if ((standard == DRX_STANDARD_ITU_A) ||
10484 (standard == DRX_STANDARD_ITU_C)) {
10485 struct drxuio_cfg uio_cfg = { DRX_UIO1, DRX_UIO_MODE_FIRMWARE_SAW };
10486 int bw_rolloff_factor = 0;
10487
10488 bw_rolloff_factor = (standard == DRX_STANDARD_ITU_A) ? 115 : 113;
10489 min_symbol_rate = DRXJ_QAM_SYMBOLRATE_MIN;
10490 max_symbol_rate = DRXJ_QAM_SYMBOLRATE_MAX;
10491 /* config SMA_TX pin to SAW switch mode */
10492 rc = ctrl_set_uio_cfg(demod, &uio_cfg);
10493 if (rc != 0) {
10494 pr_err("error %d\n", rc);
10495 goto rw_error;
10496 }
10497
10498 if (channel->symbolrate < min_symbol_rate ||
10499 channel->symbolrate > max_symbol_rate) {
10500 return -EINVAL;
10501 }
10502
10503 switch (channel->constellation) {
10504 case DRX_CONSTELLATION_QAM16: /* fall through */
10505 case DRX_CONSTELLATION_QAM32: /* fall through */
10506 case DRX_CONSTELLATION_QAM64: /* fall through */
10507 case DRX_CONSTELLATION_QAM128: /* fall through */
10508 case DRX_CONSTELLATION_QAM256:
10509 bandwidth_temp = channel->symbolrate * bw_rolloff_factor;
10510 bandwidth = bandwidth_temp / 100;
10511
10512 if ((bandwidth_temp % 100) >= 50)
10513 bandwidth++;
10514
10515 if (bandwidth <= 6100000) {
10516 channel->bandwidth = DRX_BANDWIDTH_6MHZ;
10517 } else if ((bandwidth > 6100000)
10518 && (bandwidth <= 7100000)) {
10519 channel->bandwidth = DRX_BANDWIDTH_7MHZ;
10520 } else if (bandwidth > 7100000) {
10521 channel->bandwidth = DRX_BANDWIDTH_8MHZ;
10522 }
10523 break;
10524 default:
10525 return -EINVAL;
10526 }
10527 }
10528
10529 /* For QAM annex B:
10530 -check constellation
10531 */
10532 if (standard == DRX_STANDARD_ITU_B) {
10533 switch (channel->constellation) {
10534 case DRX_CONSTELLATION_AUTO:
10535 case DRX_CONSTELLATION_QAM256:
10536 case DRX_CONSTELLATION_QAM64:
10537 break;
10538 default:
10539 return -EINVAL;
10540 }
10541
10542 switch (channel->interleavemode) {
10543 case DRX_INTERLEAVEMODE_I128_J1:
10544 case DRX_INTERLEAVEMODE_I128_J1_V2:
10545 case DRX_INTERLEAVEMODE_I128_J2:
10546 case DRX_INTERLEAVEMODE_I64_J2:
10547 case DRX_INTERLEAVEMODE_I128_J3:
10548 case DRX_INTERLEAVEMODE_I32_J4:
10549 case DRX_INTERLEAVEMODE_I128_J4:
10550 case DRX_INTERLEAVEMODE_I16_J8:
10551 case DRX_INTERLEAVEMODE_I128_J5:
10552 case DRX_INTERLEAVEMODE_I8_J16:
10553 case DRX_INTERLEAVEMODE_I128_J6:
10554 case DRX_INTERLEAVEMODE_I128_J7:
10555 case DRX_INTERLEAVEMODE_I128_J8:
10556 case DRX_INTERLEAVEMODE_I12_J17:
10557 case DRX_INTERLEAVEMODE_I5_J4:
10558 case DRX_INTERLEAVEMODE_B52_M240:
10559 case DRX_INTERLEAVEMODE_B52_M720:
10560 case DRX_INTERLEAVEMODE_UNKNOWN:
10561 case DRX_INTERLEAVEMODE_AUTO:
10562 break;
10563 default:
10564 return -EINVAL;
10565 }
10566 }
10567
10568 if ((ext_attr->uio_sma_tx_mode) == DRX_UIO_MODE_FIRMWARE_SAW) {
10569 /* SAW SW, user UIO is used for switchable SAW */
10570 struct drxuio_data uio1 = { DRX_UIO1, false };
10571
10572 switch (channel->bandwidth) {
10573 case DRX_BANDWIDTH_8MHZ:
10574 uio1.value = true;
10575 break;
10576 case DRX_BANDWIDTH_7MHZ:
10577 uio1.value = false;
10578 break;
10579 case DRX_BANDWIDTH_6MHZ:
10580 uio1.value = false;
10581 break;
10582 case DRX_BANDWIDTH_UNKNOWN:
10583 default:
10584 return -EINVAL;
10585 }
10586
10587 rc = ctrl_uio_write(demod, &uio1);
10588 if (rc != 0) {
10589 pr_err("error %d\n", rc);
10590 goto rw_error;
10591 }
10592 }
10593#endif /* DRXJ_VSB_ONLY */
10594 rc = drxj_dap_write_reg16(dev_addr, SCU_COMM_EXEC__A, SCU_COMM_EXEC_ACTIVE, 0);
10595 if (rc != 0) {
10596 pr_err("error %d\n", rc);
10597 goto rw_error;
10598 }
10599
10600 tuner_freq_offset = 0;
10601
10602 /*== Setup demod for specific standard ====================================*/
10603 switch (standard) {
10604 case DRX_STANDARD_8VSB:
10605 if (channel->mirror == DRX_MIRROR_AUTO)
10606 ext_attr->mirror = DRX_MIRROR_NO;
10607 else
10608 ext_attr->mirror = channel->mirror;
10609 rc = set_vsb(demod);
10610 if (rc != 0) {
10611 pr_err("error %d\n", rc);
10612 goto rw_error;
10613 }
10614 rc = set_frequency(demod, channel, tuner_freq_offset);
10615 if (rc != 0) {
10616 pr_err("error %d\n", rc);
10617 goto rw_error;
10618 }
10619 break;
10620#ifndef DRXJ_VSB_ONLY
10621 case DRX_STANDARD_ITU_A: /* fallthrough */
10622 case DRX_STANDARD_ITU_B: /* fallthrough */
10623 case DRX_STANDARD_ITU_C:
10624 rc = set_qam_channel(demod, channel, tuner_freq_offset);
10625 if (rc != 0) {
10626 pr_err("error %d\n", rc);
10627 goto rw_error;
10628 }
10629 break;
10630#endif
10631 case DRX_STANDARD_UNKNOWN:
10632 default:
10633 return -EIO;
10634 }
10635
10636 /* flag the packet error counter reset */
10637 ext_attr->reset_pkt_err_acc = true;
10638
10639 return 0;
10640rw_error:
10641 return -EIO;
10642}
10643
10644/*=============================================================================
10645 ===== SigQuality() ==========================================================
10646 ===========================================================================*/
10647
10648/**
10649* \fn int ctrl_sig_quality()
10650* \brief Retreive signal quality form device.
10651* \param devmod Pointer to demodulator instance.
10652* \param sig_quality Pointer to signal quality data.
10653* \return int.
10654* \retval 0 sig_quality contains valid data.
10655* \retval -EINVAL sig_quality is NULL.
10656* \retval -EIO Erroneous data, sig_quality contains invalid data.
10657
10658*/
10659static int
10660ctrl_sig_quality(struct drx_demod_instance *demod,
10661 enum drx_lock_status lock_status)
10662{
10663 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
10664 struct drxj_data *ext_attr = demod->my_ext_attr;
10665 struct drx39xxj_state *state = dev_addr->user_data;
10666 struct dtv_frontend_properties *p = &state->frontend.dtv_property_cache;
10667 enum drx_standard standard = ext_attr->standard;
10668 int rc;
10669 u32 ber, cnt, err, pkt;
10670 u16 mer, strength;
10671
10672 rc = get_sig_strength(demod, &strength);
10673 if (rc < 0) {
10674 pr_err("error getting signal strength %d\n", rc);
10675 p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
10676 } else {
10677 p->strength.stat[0].scale = FE_SCALE_RELATIVE;
10678 p->strength.stat[0].uvalue = 65535UL * strength/ 100;
10679 }
10680
10681 switch (standard) {
10682 case DRX_STANDARD_8VSB:
10683#ifdef DRXJ_SIGNAL_ACCUM_ERR
10684 rc = get_acc_pkt_err(demod, &pkt);
10685 if (rc != 0) {
10686 pr_err("error %d\n", rc);
10687 goto rw_error;
10688 }
10689#endif
10690 if (lock_status != DRXJ_DEMOD_LOCK && lock_status != DRX_LOCKED) {
10691 p->pre_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
10692 p->pre_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
10693 p->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
10694 p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
10695 p->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
10696 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
10697 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
10698 } else {
10699 rc = get_vsb_post_rs_pck_err(dev_addr, &err, &pkt);
10700 if (rc != 0) {
10701 pr_err("error %d getting UCB\n", rc);
10702 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
10703 } else {
10704 p->block_error.stat[0].scale = FE_SCALE_COUNTER;
10705 p->block_error.stat[0].uvalue += err;
10706 p->block_count.stat[0].scale = FE_SCALE_COUNTER;
10707 p->block_count.stat[0].uvalue += pkt;
10708 }
10709
10710 /* PostViterbi is compute in steps of 10^(-6) */
10711 rc = get_vs_bpre_viterbi_ber(dev_addr, &ber, &cnt);
10712 if (rc != 0) {
10713 pr_err("error %d getting pre-ber\n", rc);
10714 p->pre_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
10715 } else {
10716 p->pre_bit_error.stat[0].scale = FE_SCALE_COUNTER;
10717 p->pre_bit_error.stat[0].uvalue += ber;
10718 p->pre_bit_count.stat[0].scale = FE_SCALE_COUNTER;
10719 p->pre_bit_count.stat[0].uvalue += cnt;
10720 }
10721
10722 rc = get_vs_bpost_viterbi_ber(dev_addr, &ber, &cnt);
10723 if (rc != 0) {
10724 pr_err("error %d getting post-ber\n", rc);
10725 p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
10726 } else {
10727 p->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
10728 p->post_bit_error.stat[0].uvalue += ber;
10729 p->post_bit_count.stat[0].scale = FE_SCALE_COUNTER;
10730 p->post_bit_count.stat[0].uvalue += cnt;
10731 }
10732 rc = get_vsbmer(dev_addr, &mer);
10733 if (rc != 0) {
10734 pr_err("error %d getting MER\n", rc);
10735 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
10736 } else {
10737 p->cnr.stat[0].svalue = mer * 100;
10738 p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
10739 }
10740 }
10741 break;
10742#ifndef DRXJ_VSB_ONLY
10743 case DRX_STANDARD_ITU_A:
10744 case DRX_STANDARD_ITU_B:
10745 case DRX_STANDARD_ITU_C:
10746 rc = ctrl_get_qam_sig_quality(demod);
10747 if (rc != 0) {
10748 pr_err("error %d\n", rc);
10749 goto rw_error;
10750 }
10751 break;
10752#endif
10753 default:
10754 return -EIO;
10755 }
10756
10757 return 0;
10758rw_error:
10759 return -EIO;
10760}
10761
10762/*============================================================================*/
10763
10764/**
10765* \fn int ctrl_lock_status()
10766* \brief Retreive lock status .
10767* \param dev_addr Pointer to demodulator device address.
10768* \param lock_stat Pointer to lock status structure.
10769* \return int.
10770*
10771*/
10772static int
10773ctrl_lock_status(struct drx_demod_instance *demod, enum drx_lock_status *lock_stat)
10774{
10775 enum drx_standard standard = DRX_STANDARD_UNKNOWN;
10776 struct drxj_data *ext_attr = NULL;
10777 struct i2c_device_addr *dev_addr = NULL;
10778 struct drxjscu_cmd cmd_scu = { /* command */ 0,
10779 /* parameter_len */ 0,
10780 /* result_len */ 0,
10781 /* *parameter */ NULL,
10782 /* *result */ NULL
10783 };
10784 int rc;
10785 u16 cmd_result[2] = { 0, 0 };
10786 u16 demod_lock = SCU_RAM_PARAM_1_RES_DEMOD_GET_LOCK_DEMOD_LOCKED;
10787
10788 /* check arguments */
10789 if ((demod == NULL) || (lock_stat == NULL))
10790 return -EINVAL;
10791
10792 dev_addr = demod->my_i2c_dev_addr;
10793 ext_attr = (struct drxj_data *) demod->my_ext_attr;
10794 standard = ext_attr->standard;
10795
10796 *lock_stat = DRX_NOT_LOCKED;
10797
10798 /* define the SCU command code */
10799 switch (standard) {
10800 case DRX_STANDARD_8VSB:
10801 cmd_scu.command = SCU_RAM_COMMAND_STANDARD_VSB |
10802 SCU_RAM_COMMAND_CMD_DEMOD_GET_LOCK;
10803 demod_lock |= 0x6;
10804 break;
10805#ifndef DRXJ_VSB_ONLY
10806 case DRX_STANDARD_ITU_A:
10807 case DRX_STANDARD_ITU_B:
10808 case DRX_STANDARD_ITU_C:
10809 cmd_scu.command = SCU_RAM_COMMAND_STANDARD_QAM |
10810 SCU_RAM_COMMAND_CMD_DEMOD_GET_LOCK;
10811 break;
10812#endif
10813 case DRX_STANDARD_UNKNOWN: /* fallthrough */
10814 default:
10815 return -EIO;
10816 }
10817
10818 /* define the SCU command paramters and execute the command */
10819 cmd_scu.parameter_len = 0;
10820 cmd_scu.result_len = 2;
10821 cmd_scu.parameter = NULL;
10822 cmd_scu.result = cmd_result;
10823 rc = scu_command(dev_addr, &cmd_scu);
10824 if (rc != 0) {
10825 pr_err("error %d\n", rc);
10826 goto rw_error;
10827 }
10828
10829 /* set the lock status */
10830 if (cmd_scu.result[1] < demod_lock) {
10831 /* 0x0000 NOT LOCKED */
10832 *lock_stat = DRX_NOT_LOCKED;
10833 } else if (cmd_scu.result[1] < SCU_RAM_PARAM_1_RES_DEMOD_GET_LOCK_LOCKED) {
10834 *lock_stat = DRXJ_DEMOD_LOCK;
10835 } else if (cmd_scu.result[1] <
10836 SCU_RAM_PARAM_1_RES_DEMOD_GET_LOCK_NEVER_LOCK) {
10837 /* 0x8000 DEMOD + FEC LOCKED (system lock) */
10838 *lock_stat = DRX_LOCKED;
10839 } else {
10840 /* 0xC000 NEVER LOCKED */
10841 /* (system will never be able to lock to the signal) */
10842 *lock_stat = DRX_NEVER_LOCK;
10843 }
10844
10845 return 0;
10846rw_error:
10847 return -EIO;
10848}
10849
10850/*============================================================================*/
10851
10852/**
10853* \fn int ctrl_set_standard()
10854* \brief Set modulation standard to be used.
10855* \param standard Modulation standard.
10856* \return int.
10857*
10858* Setup stuff for the desired demodulation standard.
10859* Disable and power down the previous selected demodulation standard
10860*
10861*/
10862static int
10863ctrl_set_standard(struct drx_demod_instance *demod, enum drx_standard *standard)
10864{
10865 struct drxj_data *ext_attr = NULL;
10866 int rc;
10867 enum drx_standard prev_standard;
10868
10869 /* check arguments */
10870 if ((standard == NULL) || (demod == NULL))
10871 return -EINVAL;
10872
10873 ext_attr = (struct drxj_data *) demod->my_ext_attr;
10874 prev_standard = ext_attr->standard;
10875
10876 /*
10877 Stop and power down previous standard
10878 */
10879 switch (prev_standard) {
10880#ifndef DRXJ_VSB_ONLY
10881 case DRX_STANDARD_ITU_A: /* fallthrough */
10882 case DRX_STANDARD_ITU_B: /* fallthrough */
10883 case DRX_STANDARD_ITU_C:
10884 rc = power_down_qam(demod, false);
10885 if (rc != 0) {
10886 pr_err("error %d\n", rc);
10887 goto rw_error;
10888 }
10889 break;
10890#endif
10891 case DRX_STANDARD_8VSB:
10892 rc = power_down_vsb(demod, false);
10893 if (rc != 0) {
10894 pr_err("error %d\n", rc);
10895 goto rw_error;
10896 }
10897 break;
10898 case DRX_STANDARD_UNKNOWN:
10899 /* Do nothing */
10900 break;
10901 case DRX_STANDARD_AUTO: /* fallthrough */
10902 default:
10903 return -EINVAL;
10904 }
10905
10906 /*
10907 Initialize channel independent registers
10908 Power up new standard
10909 */
10910 ext_attr->standard = *standard;
10911
10912 switch (*standard) {
10913#ifndef DRXJ_VSB_ONLY
10914 case DRX_STANDARD_ITU_A: /* fallthrough */
10915 case DRX_STANDARD_ITU_B: /* fallthrough */
10916 case DRX_STANDARD_ITU_C:
10917 do {
10918 u16 dummy;
10919 rc = drxj_dap_read_reg16(demod->my_i2c_dev_addr, SCU_RAM_VERSION_HI__A, &dummy, 0);
10920 if (rc != 0) {
10921 pr_err("error %d\n", rc);
10922 goto rw_error;
10923 }
10924 } while (0);
10925 break;
10926#endif
10927 case DRX_STANDARD_8VSB:
10928 rc = set_vsb_leak_n_gain(demod);
10929 if (rc != 0) {
10930 pr_err("error %d\n", rc);
10931 goto rw_error;
10932 }
10933 break;
10934 default:
10935 ext_attr->standard = DRX_STANDARD_UNKNOWN;
10936 return -EINVAL;
10937 break;
10938 }
10939
10940 return 0;
10941rw_error:
10942 /* Don't know what the standard is now ... try again */
10943 ext_attr->standard = DRX_STANDARD_UNKNOWN;
10944 return -EIO;
10945}
10946
10947/*============================================================================*/
10948
10949static void drxj_reset_mode(struct drxj_data *ext_attr)
10950{
10951 /* Initialize default AFE configuartion for QAM */
10952 if (ext_attr->has_lna) {
10953 /* IF AGC off, PGA active */
10954#ifndef DRXJ_VSB_ONLY
10955 ext_attr->qam_if_agc_cfg.standard = DRX_STANDARD_ITU_B;
10956 ext_attr->qam_if_agc_cfg.ctrl_mode = DRX_AGC_CTRL_OFF;
10957 ext_attr->qam_pga_cfg = 140 + (11 * 13);
10958#endif
10959 ext_attr->vsb_if_agc_cfg.standard = DRX_STANDARD_8VSB;
10960 ext_attr->vsb_if_agc_cfg.ctrl_mode = DRX_AGC_CTRL_OFF;
10961 ext_attr->vsb_pga_cfg = 140 + (11 * 13);
10962 } else {
10963 /* IF AGC on, PGA not active */
10964#ifndef DRXJ_VSB_ONLY
10965 ext_attr->qam_if_agc_cfg.standard = DRX_STANDARD_ITU_B;
10966 ext_attr->qam_if_agc_cfg.ctrl_mode = DRX_AGC_CTRL_AUTO;
10967 ext_attr->qam_if_agc_cfg.min_output_level = 0;
10968 ext_attr->qam_if_agc_cfg.max_output_level = 0x7FFF;
10969 ext_attr->qam_if_agc_cfg.speed = 3;
10970 ext_attr->qam_if_agc_cfg.top = 1297;
10971 ext_attr->qam_pga_cfg = 140;
10972#endif
10973 ext_attr->vsb_if_agc_cfg.standard = DRX_STANDARD_8VSB;
10974 ext_attr->vsb_if_agc_cfg.ctrl_mode = DRX_AGC_CTRL_AUTO;
10975 ext_attr->vsb_if_agc_cfg.min_output_level = 0;
10976 ext_attr->vsb_if_agc_cfg.max_output_level = 0x7FFF;
10977 ext_attr->vsb_if_agc_cfg.speed = 3;
10978 ext_attr->vsb_if_agc_cfg.top = 1024;
10979 ext_attr->vsb_pga_cfg = 140;
10980 }
10981 /* TODO: remove min_output_level and max_output_level for both QAM and VSB after */
10982 /* mc has not used them */
10983#ifndef DRXJ_VSB_ONLY
10984 ext_attr->qam_rf_agc_cfg.standard = DRX_STANDARD_ITU_B;
10985 ext_attr->qam_rf_agc_cfg.ctrl_mode = DRX_AGC_CTRL_AUTO;
10986 ext_attr->qam_rf_agc_cfg.min_output_level = 0;
10987 ext_attr->qam_rf_agc_cfg.max_output_level = 0x7FFF;
10988 ext_attr->qam_rf_agc_cfg.speed = 3;
10989 ext_attr->qam_rf_agc_cfg.top = 9500;
10990 ext_attr->qam_rf_agc_cfg.cut_off_current = 4000;
10991 ext_attr->qam_pre_saw_cfg.standard = DRX_STANDARD_ITU_B;
10992 ext_attr->qam_pre_saw_cfg.reference = 0x07;
10993 ext_attr->qam_pre_saw_cfg.use_pre_saw = true;
10994#endif
10995 /* Initialize default AFE configuartion for VSB */
10996 ext_attr->vsb_rf_agc_cfg.standard = DRX_STANDARD_8VSB;
10997 ext_attr->vsb_rf_agc_cfg.ctrl_mode = DRX_AGC_CTRL_AUTO;
10998 ext_attr->vsb_rf_agc_cfg.min_output_level = 0;
10999 ext_attr->vsb_rf_agc_cfg.max_output_level = 0x7FFF;
11000 ext_attr->vsb_rf_agc_cfg.speed = 3;
11001 ext_attr->vsb_rf_agc_cfg.top = 9500;
11002 ext_attr->vsb_rf_agc_cfg.cut_off_current = 4000;
11003 ext_attr->vsb_pre_saw_cfg.standard = DRX_STANDARD_8VSB;
11004 ext_attr->vsb_pre_saw_cfg.reference = 0x07;
11005 ext_attr->vsb_pre_saw_cfg.use_pre_saw = true;
11006}
11007
11008/**
11009* \fn int ctrl_power_mode()
11010* \brief Set the power mode of the device to the specified power mode
11011* \param demod Pointer to demodulator instance.
11012* \param mode Pointer to new power mode.
11013* \return int.
11014* \retval 0 Success
11015* \retval -EIO I2C error or other failure
11016* \retval -EINVAL Invalid mode argument.
11017*
11018*
11019*/
11020static int
11021ctrl_power_mode(struct drx_demod_instance *demod, enum drx_power_mode *mode)
11022{
11023 struct drx_common_attr *common_attr = (struct drx_common_attr *) NULL;
11024 struct drxj_data *ext_attr = (struct drxj_data *) NULL;
11025 struct i2c_device_addr *dev_addr = (struct i2c_device_addr *)NULL;
11026 int rc;
11027 u16 sio_cc_pwd_mode = 0;
11028
11029 common_attr = (struct drx_common_attr *) demod->my_common_attr;
11030 ext_attr = (struct drxj_data *) demod->my_ext_attr;
11031 dev_addr = demod->my_i2c_dev_addr;
11032
11033 /* Check arguments */
11034 if (mode == NULL)
11035 return -EINVAL;
11036
11037 /* If already in requested power mode, do nothing */
11038 if (common_attr->current_power_mode == *mode)
11039 return 0;
11040
11041 switch (*mode) {
11042 case DRX_POWER_UP:
11043 case DRXJ_POWER_DOWN_MAIN_PATH:
11044 sio_cc_pwd_mode = SIO_CC_PWD_MODE_LEVEL_NONE;
11045 break;
11046 case DRXJ_POWER_DOWN_CORE:
11047 sio_cc_pwd_mode = SIO_CC_PWD_MODE_LEVEL_CLOCK;
11048 break;
11049 case DRXJ_POWER_DOWN_PLL:
11050 sio_cc_pwd_mode = SIO_CC_PWD_MODE_LEVEL_PLL;
11051 break;
11052 case DRX_POWER_DOWN:
11053 sio_cc_pwd_mode = SIO_CC_PWD_MODE_LEVEL_OSC;
11054 break;
11055 default:
11056 /* Unknow sleep mode */
11057 return -EINVAL;
11058 break;
11059 }
11060
11061 /* Check if device needs to be powered up */
11062 if ((common_attr->current_power_mode != DRX_POWER_UP)) {
11063 rc = power_up_device(demod);
11064 if (rc != 0) {
11065 pr_err("error %d\n", rc);
11066 goto rw_error;
11067 }
11068 }
11069
11070 if ((*mode == DRX_POWER_UP)) {
11071 /* Restore analog & pin configuartion */
11072
11073 /* Initialize default AFE configuartion for VSB */
11074 drxj_reset_mode(ext_attr);
11075 } else {
11076 /* Power down to requested mode */
11077 /* Backup some register settings */
11078 /* Set pins with possible pull-ups connected to them in input mode */
11079 /* Analog power down */
11080 /* ADC power down */
11081 /* Power down device */
11082 /* stop all comm_exec */
11083 /*
11084 Stop and power down previous standard
11085 */
11086
11087 switch (ext_attr->standard) {
11088 case DRX_STANDARD_ITU_A:
11089 case DRX_STANDARD_ITU_B:
11090 case DRX_STANDARD_ITU_C:
11091 rc = power_down_qam(demod, true);
11092 if (rc != 0) {
11093 pr_err("error %d\n", rc);
11094 goto rw_error;
11095 }
11096 break;
11097 case DRX_STANDARD_8VSB:
11098 rc = power_down_vsb(demod, true);
11099 if (rc != 0) {
11100 pr_err("error %d\n", rc);
11101 goto rw_error;
11102 }
11103 break;
11104 case DRX_STANDARD_PAL_SECAM_BG: /* fallthrough */
11105 case DRX_STANDARD_PAL_SECAM_DK: /* fallthrough */
11106 case DRX_STANDARD_PAL_SECAM_I: /* fallthrough */
11107 case DRX_STANDARD_PAL_SECAM_L: /* fallthrough */
11108 case DRX_STANDARD_PAL_SECAM_LP: /* fallthrough */
11109 case DRX_STANDARD_NTSC: /* fallthrough */
11110 case DRX_STANDARD_FM:
11111 rc = power_down_atv(demod, ext_attr->standard, true);
11112 if (rc != 0) {
11113 pr_err("error %d\n", rc);
11114 goto rw_error;
11115 }
11116 break;
11117 case DRX_STANDARD_UNKNOWN:
11118 /* Do nothing */
11119 break;
11120 case DRX_STANDARD_AUTO: /* fallthrough */
11121 default:
11122 return -EIO;
11123 }
11124 ext_attr->standard = DRX_STANDARD_UNKNOWN;
11125 }
11126
11127 if (*mode != DRXJ_POWER_DOWN_MAIN_PATH) {
11128 rc = drxj_dap_write_reg16(dev_addr, SIO_CC_PWD_MODE__A, sio_cc_pwd_mode, 0);
11129 if (rc != 0) {
11130 pr_err("error %d\n", rc);
11131 goto rw_error;
11132 }
11133 rc = drxj_dap_write_reg16(dev_addr, SIO_CC_UPDATE__A, SIO_CC_UPDATE_KEY, 0);
11134 if (rc != 0) {
11135 pr_err("error %d\n", rc);
11136 goto rw_error;
11137 }
11138
11139 if ((*mode != DRX_POWER_UP)) {
11140 /* Initialize HI, wakeup key especially before put IC to sleep */
11141 rc = init_hi(demod);
11142 if (rc != 0) {
11143 pr_err("error %d\n", rc);
11144 goto rw_error;
11145 }
11146
11147 ext_attr->hi_cfg_ctrl |= SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ;
11148 rc = hi_cfg_command(demod);
11149 if (rc != 0) {
11150 pr_err("error %d\n", rc);
11151 goto rw_error;
11152 }
11153 }
11154 }
11155
11156 common_attr->current_power_mode = *mode;
11157
11158 return 0;
11159rw_error:
11160 return rc;
11161}
11162
11163/*============================================================================*/
11164/*== CTRL Set/Get Config related functions ===================================*/
11165/*============================================================================*/
11166
11167/**
11168* \fn int ctrl_set_cfg_pre_saw()
11169* \brief Set Pre-saw reference.
11170* \param demod demod instance
11171* \param u16 *
11172* \return int.
11173*
11174* Check arguments
11175* Dispatch handling to standard specific function.
11176*
11177*/
11178static int
11179ctrl_set_cfg_pre_saw(struct drx_demod_instance *demod, struct drxj_cfg_pre_saw *pre_saw)
11180{
11181 struct i2c_device_addr *dev_addr = NULL;
11182 struct drxj_data *ext_attr = NULL;
11183 int rc;
11184
11185 dev_addr = demod->my_i2c_dev_addr;
11186 ext_attr = (struct drxj_data *) demod->my_ext_attr;
11187
11188 /* check arguments */
11189 if ((pre_saw == NULL) || (pre_saw->reference > IQM_AF_PDREF__M)
11190 ) {
11191 return -EINVAL;
11192 }
11193
11194 /* Only if standard is currently active */
11195 if ((ext_attr->standard == pre_saw->standard) ||
11196 (DRXJ_ISQAMSTD(ext_attr->standard) &&
11197 DRXJ_ISQAMSTD(pre_saw->standard)) ||
11198 (DRXJ_ISATVSTD(ext_attr->standard) &&
11199 DRXJ_ISATVSTD(pre_saw->standard))) {
11200 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_PDREF__A, pre_saw->reference, 0);
11201 if (rc != 0) {
11202 pr_err("error %d\n", rc);
11203 goto rw_error;
11204 }
11205 }
11206
11207 /* Store pre-saw settings */
11208 switch (pre_saw->standard) {
11209 case DRX_STANDARD_8VSB:
11210 ext_attr->vsb_pre_saw_cfg = *pre_saw;
11211 break;
11212#ifndef DRXJ_VSB_ONLY
11213 case DRX_STANDARD_ITU_A: /* fallthrough */
11214 case DRX_STANDARD_ITU_B: /* fallthrough */
11215 case DRX_STANDARD_ITU_C:
11216 ext_attr->qam_pre_saw_cfg = *pre_saw;
11217 break;
11218#endif
11219 default:
11220 return -EINVAL;
11221 }
11222
11223 return 0;
11224rw_error:
11225 return -EIO;
11226}
11227
11228/*============================================================================*/
11229
11230/**
11231* \fn int ctrl_set_cfg_afe_gain()
11232* \brief Set AFE Gain.
11233* \param demod demod instance
11234* \param u16 *
11235* \return int.
11236*
11237* Check arguments
11238* Dispatch handling to standard specific function.
11239*
11240*/
11241static int
11242ctrl_set_cfg_afe_gain(struct drx_demod_instance *demod, struct drxj_cfg_afe_gain *afe_gain)
11243{
11244 struct i2c_device_addr *dev_addr = NULL;
11245 struct drxj_data *ext_attr = NULL;
11246 int rc;
11247 u8 gain = 0;
11248
11249 /* check arguments */
11250 if (afe_gain == NULL)
11251 return -EINVAL;
11252
11253 dev_addr = demod->my_i2c_dev_addr;
11254 ext_attr = (struct drxj_data *) demod->my_ext_attr;
11255
11256 switch (afe_gain->standard) {
11257 case DRX_STANDARD_8VSB: /* fallthrough */
11258#ifndef DRXJ_VSB_ONLY
11259 case DRX_STANDARD_ITU_A: /* fallthrough */
11260 case DRX_STANDARD_ITU_B: /* fallthrough */
11261 case DRX_STANDARD_ITU_C:
11262#endif
11263 /* Do nothing */
11264 break;
11265 default:
11266 return -EINVAL;
11267 }
11268
11269 /* TODO PGA gain is also written by microcode (at least by QAM and VSB)
11270 So I (PJ) think interface requires choice between auto, user mode */
11271
11272 if (afe_gain->gain >= 329)
11273 gain = 15;
11274 else if (afe_gain->gain <= 147)
11275 gain = 0;
11276 else
11277 gain = (afe_gain->gain - 140 + 6) / 13;
11278
11279 /* Only if standard is currently active */
11280 if (ext_attr->standard == afe_gain->standard) {
11281 rc = drxj_dap_write_reg16(dev_addr, IQM_AF_PGA_GAIN__A, gain, 0);
11282 if (rc != 0) {
11283 pr_err("error %d\n", rc);
11284 goto rw_error;
11285 }
11286 }
11287
11288 /* Store AFE Gain settings */
11289 switch (afe_gain->standard) {
11290 case DRX_STANDARD_8VSB:
11291 ext_attr->vsb_pga_cfg = gain * 13 + 140;
11292 break;
11293#ifndef DRXJ_VSB_ONLY
11294 case DRX_STANDARD_ITU_A: /* fallthrough */
11295 case DRX_STANDARD_ITU_B: /* fallthrough */
11296 case DRX_STANDARD_ITU_C:
11297 ext_attr->qam_pga_cfg = gain * 13 + 140;
11298 break;
11299#endif
11300 default:
11301 return -EIO;
11302 }
11303
11304 return 0;
11305rw_error:
11306 return -EIO;
11307}
11308
11309/*============================================================================*/
11310
11311
11312/*=============================================================================
11313===== EXPORTED FUNCTIONS ====================================================*/
11314
11315static int drx_ctrl_u_code(struct drx_demod_instance *demod,
11316 struct drxu_code_info *mc_info,
11317 enum drxu_code_action action);
11318
11319/**
11320* \fn drxj_open()
11321* \brief Open the demod instance, configure device, configure drxdriver
11322* \return Status_t Return status.
11323*
11324* drxj_open() can be called with a NULL ucode image => no ucode upload.
11325* This means that drxj_open() must NOT contain SCU commands or, in general,
11326* rely on SCU or AUD ucode to be present.
11327*
11328*/
11329
11330static int drxj_open(struct drx_demod_instance *demod)
11331{
11332 struct i2c_device_addr *dev_addr = NULL;
11333 struct drxj_data *ext_attr = NULL;
11334 struct drx_common_attr *common_attr = NULL;
11335 u32 driver_version = 0;
11336 struct drxu_code_info ucode_info;
11337 struct drx_cfg_mpeg_output cfg_mpeg_output;
11338 int rc;
11339 enum drx_power_mode power_mode = DRX_POWER_UP;
11340
11341 if ((demod == NULL) ||
11342 (demod->my_common_attr == NULL) ||
11343 (demod->my_ext_attr == NULL) ||
11344 (demod->my_i2c_dev_addr == NULL) ||
11345 (demod->my_common_attr->is_opened)) {
11346 return -EINVAL;
11347 }
11348
11349 /* Check arguments */
11350 if (demod->my_ext_attr == NULL)
11351 return -EINVAL;
11352
11353 dev_addr = demod->my_i2c_dev_addr;
11354 ext_attr = (struct drxj_data *) demod->my_ext_attr;
11355 common_attr = (struct drx_common_attr *) demod->my_common_attr;
11356
11357 rc = ctrl_power_mode(demod, &power_mode);
11358 if (rc != 0) {
11359 pr_err("error %d\n", rc);
11360 goto rw_error;
11361 }
11362 if (power_mode != DRX_POWER_UP) {
11363 rc = -EINVAL;
11364 pr_err("failed to powerup device\n");
11365 goto rw_error;
11366 }
11367
11368 /* has to be in front of setIqmAf and setOrxNsuAox */
11369 rc = get_device_capabilities(demod);
11370 if (rc != 0) {
11371 pr_err("error %d\n", rc);
11372 goto rw_error;
11373 }
11374
11375 /*
11376 * Soft reset of sys- and osc-clockdomain
11377 *
11378 * HACK: On windows, it writes a 0x07 here, instead of just 0x03.
11379 * As we didn't load the firmware here yet, we should do the same.
11380 * Btw, this is coherent with DRX-K, where we send reset codes
11381 * for modulation (OFTM, in DRX-k), SYS and OSC clock domains.
11382 */
11383 rc = drxj_dap_write_reg16(dev_addr, SIO_CC_SOFT_RST__A, (0x04 | SIO_CC_SOFT_RST_SYS__M | SIO_CC_SOFT_RST_OSC__M), 0);
11384 if (rc != 0) {
11385 pr_err("error %d\n", rc);
11386 goto rw_error;
11387 }
11388 rc = drxj_dap_write_reg16(dev_addr, SIO_CC_UPDATE__A, SIO_CC_UPDATE_KEY, 0);
11389 if (rc != 0) {
11390 pr_err("error %d\n", rc);
11391 goto rw_error;
11392 }
11393 msleep(1);
11394
11395 /* TODO first make sure that everything keeps working before enabling this */
11396 /* PowerDownAnalogBlocks() */
11397 rc = drxj_dap_write_reg16(dev_addr, ATV_TOP_STDBY__A, (~ATV_TOP_STDBY_CVBS_STDBY_A2_ACTIVE) | ATV_TOP_STDBY_SIF_STDBY_STANDBY, 0);
11398 if (rc != 0) {
11399 pr_err("error %d\n", rc);
11400 goto rw_error;
11401 }
11402
11403 rc = set_iqm_af(demod, false);
11404 if (rc != 0) {
11405 pr_err("error %d\n", rc);
11406 goto rw_error;
11407 }
11408 rc = set_orx_nsu_aox(demod, false);
11409 if (rc != 0) {
11410 pr_err("error %d\n", rc);
11411 goto rw_error;
11412 }
11413
11414 rc = init_hi(demod);
11415 if (rc != 0) {
11416 pr_err("error %d\n", rc);
11417 goto rw_error;
11418 }
11419
11420 /* disable mpegoutput pins */
11421 memcpy(&cfg_mpeg_output, &common_attr->mpeg_cfg, sizeof(cfg_mpeg_output));
11422 cfg_mpeg_output.enable_mpeg_output = false;
11423
11424 rc = ctrl_set_cfg_mpeg_output(demod, &cfg_mpeg_output);
11425 if (rc != 0) {
11426 pr_err("error %d\n", rc);
11427 goto rw_error;
11428 }
11429 /* Stop AUD Inform SetAudio it will need to do all setting */
11430 rc = power_down_aud(demod);
11431 if (rc != 0) {
11432 pr_err("error %d\n", rc);
11433 goto rw_error;
11434 }
11435 /* Stop SCU */
11436 rc = drxj_dap_write_reg16(dev_addr, SCU_COMM_EXEC__A, SCU_COMM_EXEC_STOP, 0);
11437 if (rc != 0) {
11438 pr_err("error %d\n", rc);
11439 goto rw_error;
11440 }
11441
11442 /* Upload microcode */
11443 if (common_attr->microcode_file != NULL) {
11444 /* Dirty trick to use common ucode upload & verify,
11445 pretend device is already open */
11446 common_attr->is_opened = true;
11447 ucode_info.mc_file = common_attr->microcode_file;
11448
11449 if (DRX_ISPOWERDOWNMODE(demod->my_common_attr->current_power_mode)) {
11450 pr_err("Should powerup before loading the firmware.");
11451 return -EINVAL;
11452 }
11453
11454 rc = drx_ctrl_u_code(demod, &ucode_info, UCODE_UPLOAD);
11455 if (rc != 0) {
11456 pr_err("error %d while uploading the firmware\n", rc);
11457 goto rw_error;
11458 }
11459 if (common_attr->verify_microcode == true) {
11460 rc = drx_ctrl_u_code(demod, &ucode_info, UCODE_VERIFY);
11461 if (rc != 0) {
11462 pr_err("error %d while verifying the firmware\n",
11463 rc);
11464 goto rw_error;
11465 }
11466 }
11467 common_attr->is_opened = false;
11468 }
11469
11470 /* Run SCU for a little while to initialize microcode version numbers */
11471 rc = drxj_dap_write_reg16(dev_addr, SCU_COMM_EXEC__A, SCU_COMM_EXEC_ACTIVE, 0);
11472 if (rc != 0) {
11473 pr_err("error %d\n", rc);
11474 goto rw_error;
11475 }
11476
11477 /* Initialize scan timeout */
11478 common_attr->scan_demod_lock_timeout = DRXJ_SCAN_TIMEOUT;
11479 common_attr->scan_desired_lock = DRX_LOCKED;
11480
11481 drxj_reset_mode(ext_attr);
11482 ext_attr->standard = DRX_STANDARD_UNKNOWN;
11483
11484 rc = smart_ant_init(demod);
11485 if (rc != 0) {
11486 pr_err("error %d\n", rc);
11487 goto rw_error;
11488 }
11489
11490 /* Stamp driver version number in SCU data RAM in BCD code
11491 Done to enable field application engineers to retreive drxdriver version
11492 via I2C from SCU RAM
11493 */
11494 driver_version = (VERSION_MAJOR / 100) % 10;
11495 driver_version <<= 4;
11496 driver_version += (VERSION_MAJOR / 10) % 10;
11497 driver_version <<= 4;
11498 driver_version += (VERSION_MAJOR % 10);
11499 driver_version <<= 4;
11500 driver_version += (VERSION_MINOR % 10);
11501 driver_version <<= 4;
11502 driver_version += (VERSION_PATCH / 1000) % 10;
11503 driver_version <<= 4;
11504 driver_version += (VERSION_PATCH / 100) % 10;
11505 driver_version <<= 4;
11506 driver_version += (VERSION_PATCH / 10) % 10;
11507 driver_version <<= 4;
11508 driver_version += (VERSION_PATCH % 10);
11509 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_DRIVER_VER_HI__A, (u16)(driver_version >> 16), 0);
11510 if (rc != 0) {
11511 pr_err("error %d\n", rc);
11512 goto rw_error;
11513 }
11514 rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_DRIVER_VER_LO__A, (u16)(driver_version & 0xFFFF), 0);
11515 if (rc != 0) {
11516 pr_err("error %d\n", rc);
11517 goto rw_error;
11518 }
11519
11520 rc = ctrl_set_oob(demod, NULL);
11521 if (rc != 0) {
11522 pr_err("error %d\n", rc);
11523 goto rw_error;
11524 }
11525
11526 /* refresh the audio data structure with default */
11527 ext_attr->aud_data = drxj_default_aud_data_g;
11528
11529 demod->my_common_attr->is_opened = true;
11530 return 0;
11531rw_error:
11532 common_attr->is_opened = false;
11533 return -EIO;
11534}
11535
11536/*============================================================================*/
11537/**
11538* \fn drxj_close()
11539* \brief Close the demod instance, power down the device
11540* \return Status_t Return status.
11541*
11542*/
11543static int drxj_close(struct drx_demod_instance *demod)
11544{
11545 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
11546 int rc;
11547 enum drx_power_mode power_mode = DRX_POWER_UP;
11548
11549 if ((demod->my_common_attr == NULL) ||
11550 (demod->my_ext_attr == NULL) ||
11551 (demod->my_i2c_dev_addr == NULL) ||
11552 (!demod->my_common_attr->is_opened)) {
11553 return -EINVAL;
11554 }
11555
11556 /* power up */
11557 rc = ctrl_power_mode(demod, &power_mode);
11558 if (rc != 0) {
11559 pr_err("error %d\n", rc);
11560 goto rw_error;
11561 }
11562
11563 rc = drxj_dap_write_reg16(dev_addr, SCU_COMM_EXEC__A, SCU_COMM_EXEC_ACTIVE, 0);
11564 if (rc != 0) {
11565 pr_err("error %d\n", rc);
11566 goto rw_error;
11567 }
11568 power_mode = DRX_POWER_DOWN;
11569 rc = ctrl_power_mode(demod, &power_mode);
11570 if (rc != 0) {
11571 pr_err("error %d\n", rc);
11572 goto rw_error;
11573 }
11574
11575 DRX_ATTR_ISOPENED(demod) = false;
11576
11577 return 0;
11578rw_error:
11579 DRX_ATTR_ISOPENED(demod) = false;
11580
11581 return -EIO;
11582}
11583
11584/*
11585 * Microcode related functions
11586 */
11587
11588/**
11589 * drx_u_code_compute_crc - Compute CRC of block of microcode data.
11590 * @block_data: Pointer to microcode data.
11591 * @nr_words: Size of microcode block (number of 16 bits words).
11592 *
11593 * returns The computed CRC residue.
11594 */
11595static u16 drx_u_code_compute_crc(u8 *block_data, u16 nr_words)
11596{
11597 u16 i = 0;
11598 u16 j = 0;
11599 u32 crc_word = 0;
11600 u32 carry = 0;
11601
11602 while (i < nr_words) {
11603 crc_word |= (u32)be16_to_cpu(*(u32 *)(block_data));
11604 for (j = 0; j < 16; j++) {
11605 crc_word <<= 1;
11606 if (carry != 0)
11607 crc_word ^= 0x80050000UL;
11608 carry = crc_word & 0x80000000UL;
11609 }
11610 i++;
11611 block_data += (sizeof(u16));
11612 }
11613 return (u16)(crc_word >> 16);
11614}
11615
11616/**
11617 * drx_check_firmware - checks if the loaded firmware is valid
11618 *
11619 * @demod: demod structure
11620 * @mc_data: pointer to the start of the firmware
11621 * @size: firmware size
11622 */
11623static int drx_check_firmware(struct drx_demod_instance *demod, u8 *mc_data,
11624 unsigned size)
11625{
11626 struct drxu_code_block_hdr block_hdr;
11627 int i;
11628 unsigned count = 2 * sizeof(u16);
11629 u32 mc_dev_type, mc_version, mc_base_version;
11630 u16 mc_nr_of_blks = be16_to_cpu(*(u32 *)(mc_data + sizeof(u16)));
11631
11632 /*
11633 * Scan microcode blocks first for version info
11634 * and firmware check
11635 */
11636
11637 /* Clear version block */
11638 DRX_ATTR_MCRECORD(demod).aux_type = 0;
11639 DRX_ATTR_MCRECORD(demod).mc_dev_type = 0;
11640 DRX_ATTR_MCRECORD(demod).mc_version = 0;
11641 DRX_ATTR_MCRECORD(demod).mc_base_version = 0;
11642
11643 for (i = 0; i < mc_nr_of_blks; i++) {
11644 if (count + 3 * sizeof(u16) + sizeof(u32) > size)
11645 goto eof;
11646
11647 /* Process block header */
11648 block_hdr.addr = be32_to_cpu(*(u32 *)(mc_data + count));
11649 count += sizeof(u32);
11650 block_hdr.size = be16_to_cpu(*(u32 *)(mc_data + count));
11651 count += sizeof(u16);
11652 block_hdr.flags = be16_to_cpu(*(u32 *)(mc_data + count));
11653 count += sizeof(u16);
11654 block_hdr.CRC = be16_to_cpu(*(u32 *)(mc_data + count));
11655 count += sizeof(u16);
11656
11657 pr_debug("%u: addr %u, size %u, flags 0x%04x, CRC 0x%04x\n",
11658 count, block_hdr.addr, block_hdr.size, block_hdr.flags,
11659 block_hdr.CRC);
11660
11661 if (block_hdr.flags & 0x8) {
11662 u8 *auxblk = ((void *)mc_data) + block_hdr.addr;
11663 u16 auxtype;
11664
11665 if (block_hdr.addr + sizeof(u16) > size)
11666 goto eof;
11667
11668 auxtype = be16_to_cpu(*(u32 *)(auxblk));
11669
11670 /* Aux block. Check type */
11671 if (DRX_ISMCVERTYPE(auxtype)) {
11672 if (block_hdr.addr + 2 * sizeof(u16) + 2 * sizeof (u32) > size)
11673 goto eof;
11674
11675 auxblk += sizeof(u16);
11676 mc_dev_type = be32_to_cpu(*(u32 *)(auxblk));
11677 auxblk += sizeof(u32);
11678 mc_version = be32_to_cpu(*(u32 *)(auxblk));
11679 auxblk += sizeof(u32);
11680 mc_base_version = be32_to_cpu(*(u32 *)(auxblk));
11681
11682 DRX_ATTR_MCRECORD(demod).aux_type = auxtype;
11683 DRX_ATTR_MCRECORD(demod).mc_dev_type = mc_dev_type;
11684 DRX_ATTR_MCRECORD(demod).mc_version = mc_version;
11685 DRX_ATTR_MCRECORD(demod).mc_base_version = mc_base_version;
11686
11687 pr_info("Firmware dev %x, ver %x, base ver %x\n",
11688 mc_dev_type, mc_version, mc_base_version);
11689
11690 }
11691 } else if (count + block_hdr.size * sizeof(u16) > size)
11692 goto eof;
11693
11694 count += block_hdr.size * sizeof(u16);
11695 }
11696 return 0;
11697eof:
11698 pr_err("Firmware is truncated at pos %u/%u\n", count, size);
11699 return -EINVAL;
11700}
11701
11702/**
11703 * drx_ctrl_u_code - Handle microcode upload or verify.
11704 * @dev_addr: Address of device.
11705 * @mc_info: Pointer to information about microcode data.
11706 * @action: Either UCODE_UPLOAD or UCODE_VERIFY
11707 *
11708 * This function returns:
11709 * 0:
11710 * - In case of UCODE_UPLOAD: code is successfully uploaded.
11711 * - In case of UCODE_VERIFY: image on device is equal to
11712 * image provided to this control function.
11713 * -EIO:
11714 * - In case of UCODE_UPLOAD: I2C error.
11715 * - In case of UCODE_VERIFY: I2C error or image on device
11716 * is not equal to image provided to this control function.
11717 * -EINVAL:
11718 * - Invalid arguments.
11719 * - Provided image is corrupt
11720 */
11721static int drx_ctrl_u_code(struct drx_demod_instance *demod,
11722 struct drxu_code_info *mc_info,
11723 enum drxu_code_action action)
11724{
11725 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
11726 int rc;
11727 u16 i = 0;
11728 u16 mc_nr_of_blks = 0;
11729 u16 mc_magic_word = 0;
11730 const u8 *mc_data_init = NULL;
11731 u8 *mc_data = NULL;
11732 unsigned size;
11733 char *mc_file;
11734
11735 /* Check arguments */
11736 if (!mc_info || !mc_info->mc_file)
11737 return -EINVAL;
11738
11739 mc_file = mc_info->mc_file;
11740
11741 if (!demod->firmware) {
11742 const struct firmware *fw = NULL;
11743
11744 rc = request_firmware(&fw, mc_file, demod->i2c->dev.parent);
11745 if (rc < 0) {
11746 pr_err("Couldn't read firmware %s\n", mc_file);
11747 return rc;
11748 }
11749 demod->firmware = fw;
11750
11751 if (demod->firmware->size < 2 * sizeof(u16)) {
11752 rc = -EINVAL;
11753 pr_err("Firmware is too short!\n");
11754 goto release;
11755 }
11756
11757 pr_info("Firmware %s, size %zu\n",
11758 mc_file, demod->firmware->size);
11759 }
11760
11761 mc_data_init = demod->firmware->data;
11762 size = demod->firmware->size;
11763
11764 mc_data = (void *)mc_data_init;
11765 /* Check data */
11766 mc_magic_word = be16_to_cpu(*(u32 *)(mc_data));
11767 mc_data += sizeof(u16);
11768 mc_nr_of_blks = be16_to_cpu(*(u32 *)(mc_data));
11769 mc_data += sizeof(u16);
11770
11771 if ((mc_magic_word != DRX_UCODE_MAGIC_WORD) || (mc_nr_of_blks == 0)) {
11772 rc = -EINVAL;
11773 pr_err("Firmware magic word doesn't match\n");
11774 goto release;
11775 }
11776
11777 if (action == UCODE_UPLOAD) {
11778 rc = drx_check_firmware(demod, (u8 *)mc_data_init, size);
11779 if (rc)
11780 goto release;
11781 pr_info("Uploading firmware %s\n", mc_file);
11782 } else {
11783 pr_info("Verifying if firmware upload was ok.\n");
11784 }
11785
11786 /* Process microcode blocks */
11787 for (i = 0; i < mc_nr_of_blks; i++) {
11788 struct drxu_code_block_hdr block_hdr;
11789 u16 mc_block_nr_bytes = 0;
11790
11791 /* Process block header */
11792 block_hdr.addr = be32_to_cpu(*(u32 *)(mc_data));
11793 mc_data += sizeof(u32);
11794 block_hdr.size = be16_to_cpu(*(u32 *)(mc_data));
11795 mc_data += sizeof(u16);
11796 block_hdr.flags = be16_to_cpu(*(u32 *)(mc_data));
11797 mc_data += sizeof(u16);
11798 block_hdr.CRC = be16_to_cpu(*(u32 *)(mc_data));
11799 mc_data += sizeof(u16);
11800
11801 pr_debug("%u: addr %u, size %u, flags 0x%04x, CRC 0x%04x\n",
11802 (unsigned)(mc_data - mc_data_init), block_hdr.addr,
11803 block_hdr.size, block_hdr.flags, block_hdr.CRC);
11804
11805 /* Check block header on:
11806 - data larger than 64Kb
11807 - if CRC enabled check CRC
11808 */
11809 if ((block_hdr.size > 0x7FFF) ||
11810 (((block_hdr.flags & DRX_UCODE_CRC_FLAG) != 0) &&
11811 (block_hdr.CRC != drx_u_code_compute_crc(mc_data, block_hdr.size)))
11812 ) {
11813 /* Wrong data ! */
11814 rc = -EINVAL;
11815 pr_err("firmware CRC is wrong\n");
11816 goto release;
11817 }
11818
11819 if (!block_hdr.size)
11820 continue;
11821
11822 mc_block_nr_bytes = block_hdr.size * ((u16) sizeof(u16));
11823
11824 /* Perform the desired action */
11825 switch (action) {
11826 case UCODE_UPLOAD: /* Upload microcode */
11827 if (drxdap_fasi_write_block(dev_addr,
11828 block_hdr.addr,
11829 mc_block_nr_bytes,
11830 mc_data, 0x0000)) {
11831 rc = -EIO;
11832 pr_err("error writing firmware at pos %u\n",
11833 (unsigned)(mc_data - mc_data_init));
11834 goto release;
11835 }
11836 break;
11837 case UCODE_VERIFY: { /* Verify uploaded microcode */
11838 int result = 0;
11839 u8 mc_data_buffer[DRX_UCODE_MAX_BUF_SIZE];
11840 u32 bytes_to_comp = 0;
11841 u32 bytes_left = mc_block_nr_bytes;
11842 u32 curr_addr = block_hdr.addr;
11843 u8 *curr_ptr = mc_data;
11844
11845 while (bytes_left != 0) {
11846 if (bytes_left > DRX_UCODE_MAX_BUF_SIZE)
11847 bytes_to_comp = DRX_UCODE_MAX_BUF_SIZE;
11848 else
11849 bytes_to_comp = bytes_left;
11850
11851 if (drxdap_fasi_read_block(dev_addr,
11852 curr_addr,
11853 (u16)bytes_to_comp,
11854 (u8 *)mc_data_buffer,
11855 0x0000)) {
11856 pr_err("error reading firmware at pos %u\n",
11857 (unsigned)(mc_data - mc_data_init));
11858 return -EIO;
11859 }
11860
11861 result = memcmp(curr_ptr, mc_data_buffer,
11862 bytes_to_comp);
11863
11864 if (result) {
11865 pr_err("error verifying firmware at pos %u\n",
11866 (unsigned)(mc_data - mc_data_init));
11867 return -EIO;
11868 }
11869
11870 curr_addr += ((dr_xaddr_t)(bytes_to_comp / 2));
11871 curr_ptr =&(curr_ptr[bytes_to_comp]);
11872 bytes_left -=((u32) bytes_to_comp);
11873 }
11874 break;
11875 }
11876 default:
11877 return -EINVAL;
11878 break;
11879
11880 }
11881 mc_data += mc_block_nr_bytes;
11882 }
11883
11884 return 0;
11885
11886release:
11887 release_firmware(demod->firmware);
11888 demod->firmware = NULL;
11889
11890 return rc;
11891}
11892
11893/*
11894 * The Linux DVB Driver for Micronas DRX39xx family (drx3933j)
11895 *
11896 * Written by Devin Heitmueller <devin.heitmueller@kernellabs.com>
11897 */
11898
11899static int drx39xxj_set_powerstate(struct dvb_frontend *fe, int enable)
11900{
11901 struct drx39xxj_state *state = fe->demodulator_priv;
11902 struct drx_demod_instance *demod = state->demod;
11903 int result;
11904 enum drx_power_mode power_mode;
11905
11906 if (enable)
11907 power_mode = DRX_POWER_UP;
11908 else
11909 power_mode = DRX_POWER_DOWN;
11910
11911 result = ctrl_power_mode(demod, &power_mode);
11912 if (result != 0) {
11913 pr_err("Power state change failed\n");
11914 return 0;
11915 }
11916
11917 return 0;
11918}
11919
11920static int drx39xxj_read_status(struct dvb_frontend *fe, fe_status_t *status)
11921{
11922 struct drx39xxj_state *state = fe->demodulator_priv;
11923 struct drx_demod_instance *demod = state->demod;
11924 int result;
11925 enum drx_lock_status lock_status;
11926
11927 *status = 0;
11928
11929 result = ctrl_lock_status(demod, &lock_status);
11930 if (result != 0) {
11931 pr_err("drx39xxj: could not get lock status!\n");
11932 *status = 0;
11933 }
11934
11935 switch (lock_status) {
11936 case DRX_NEVER_LOCK:
11937 *status = 0;
11938 pr_err("drx says NEVER_LOCK\n");
11939 break;
11940 case DRX_NOT_LOCKED:
11941 *status = 0;
11942 break;
11943 case DRX_LOCK_STATE_1:
11944 case DRX_LOCK_STATE_2:
11945 case DRX_LOCK_STATE_3:
11946 case DRX_LOCK_STATE_4:
11947 case DRX_LOCK_STATE_5:
11948 case DRX_LOCK_STATE_6:
11949 case DRX_LOCK_STATE_7:
11950 case DRX_LOCK_STATE_8:
11951 case DRX_LOCK_STATE_9:
11952 *status = FE_HAS_SIGNAL
11953 | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC;
11954 break;
11955 case DRX_LOCKED:
11956 *status = FE_HAS_SIGNAL
11957 | FE_HAS_CARRIER
11958 | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
11959 break;
11960 default:
11961 pr_err("Lock state unknown %d\n", lock_status);
11962 }
11963 ctrl_sig_quality(demod, lock_status);
11964
11965 return 0;
11966}
11967
11968static int drx39xxj_read_ber(struct dvb_frontend *fe, u32 *ber)
11969{
11970 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
11971
11972 if (p->pre_bit_error.stat[0].scale == FE_SCALE_NOT_AVAILABLE) {
11973 *ber = 0;
11974 return 0;
11975 }
11976
11977 if (!p->pre_bit_count.stat[0].uvalue) {
11978 if (!p->pre_bit_error.stat[0].uvalue)
11979 *ber = 0;
11980 else
11981 *ber = 1000000;
11982 } else {
11983 *ber = frac_times1e6(p->pre_bit_error.stat[0].uvalue,
11984 p->pre_bit_count.stat[0].uvalue);
11985 }
11986 return 0;
11987}
11988
11989static int drx39xxj_read_signal_strength(struct dvb_frontend *fe,
11990 u16 *strength)
11991{
11992 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
11993
11994 if (p->strength.stat[0].scale == FE_SCALE_NOT_AVAILABLE) {
11995 *strength = 0;
11996 return 0;
11997 }
11998
11999 *strength = p->strength.stat[0].uvalue;
12000 return 0;
12001}
12002
12003static int drx39xxj_read_snr(struct dvb_frontend *fe, u16 *snr)
12004{
12005 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
12006 u64 tmp64;
12007
12008 if (p->cnr.stat[0].scale == FE_SCALE_NOT_AVAILABLE) {
12009 *snr = 0;
12010 return 0;
12011 }
12012
12013 tmp64 = p->cnr.stat[0].svalue;
12014 do_div(tmp64, 10);
12015 *snr = tmp64;
12016 return 0;
12017}
12018
12019static int drx39xxj_read_ucblocks(struct dvb_frontend *fe, u32 *ucb)
12020{
12021 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
12022
12023 if (p->block_error.stat[0].scale == FE_SCALE_NOT_AVAILABLE) {
12024 *ucb = 0;
12025 return 0;
12026 }
12027
12028 *ucb = p->block_error.stat[0].uvalue;
12029 return 0;
12030}
12031
12032static int drx39xxj_set_frontend(struct dvb_frontend *fe)
12033{
12034#ifdef DJH_DEBUG
12035 int i;
12036#endif
12037 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
12038 struct drx39xxj_state *state = fe->demodulator_priv;
12039 struct drx_demod_instance *demod = state->demod;
12040 enum drx_standard standard = DRX_STANDARD_8VSB;
12041 struct drx_channel channel;
12042 int result;
12043 struct drxuio_data uio_data;
12044 static const struct drx_channel def_channel = {
12045 /* frequency */ 0,
12046 /* bandwidth */ DRX_BANDWIDTH_6MHZ,
12047 /* mirror */ DRX_MIRROR_NO,
12048 /* constellation */ DRX_CONSTELLATION_AUTO,
12049 /* hierarchy */ DRX_HIERARCHY_UNKNOWN,
12050 /* priority */ DRX_PRIORITY_UNKNOWN,
12051 /* coderate */ DRX_CODERATE_UNKNOWN,
12052 /* guard */ DRX_GUARD_UNKNOWN,
12053 /* fftmode */ DRX_FFTMODE_UNKNOWN,
12054 /* classification */ DRX_CLASSIFICATION_AUTO,
12055 /* symbolrate */ 5057000,
12056 /* interleavemode */ DRX_INTERLEAVEMODE_UNKNOWN,
12057 /* ldpc */ DRX_LDPC_UNKNOWN,
12058 /* carrier */ DRX_CARRIER_UNKNOWN,
12059 /* frame mode */ DRX_FRAMEMODE_UNKNOWN
12060 };
12061 u32 constellation = DRX_CONSTELLATION_AUTO;
12062
12063 /* Bring the demod out of sleep */
12064 drx39xxj_set_powerstate(fe, 1);
12065
12066 if (fe->ops.tuner_ops.set_params) {
12067 u32 int_freq;
12068
12069 if (fe->ops.i2c_gate_ctrl)
12070 fe->ops.i2c_gate_ctrl(fe, 1);
12071
12072 /* Set tuner to desired frequency and standard */
12073 fe->ops.tuner_ops.set_params(fe);
12074
12075 /* Use the tuner's IF */
12076 if (fe->ops.tuner_ops.get_if_frequency) {
12077 fe->ops.tuner_ops.get_if_frequency(fe, &int_freq);
12078 demod->my_common_attr->intermediate_freq = int_freq / 1000;
12079 }
12080
12081 if (fe->ops.i2c_gate_ctrl)
12082 fe->ops.i2c_gate_ctrl(fe, 0);
12083 }
12084
12085 switch (p->delivery_system) {
12086 case SYS_ATSC:
12087 standard = DRX_STANDARD_8VSB;
12088 break;
12089 case SYS_DVBC_ANNEX_B:
12090 standard = DRX_STANDARD_ITU_B;
12091
12092 switch (p->modulation) {
12093 case QAM_64:
12094 constellation = DRX_CONSTELLATION_QAM64;
12095 break;
12096 case QAM_256:
12097 constellation = DRX_CONSTELLATION_QAM256;
12098 break;
12099 default:
12100 constellation = DRX_CONSTELLATION_AUTO;
12101 break;
12102 }
12103 break;
12104 default:
12105 return -EINVAL;
12106 }
12107 /* Set the standard (will be powered up if necessary */
12108 result = ctrl_set_standard(demod, &standard);
12109 if (result != 0) {
12110 pr_err("Failed to set standard! result=%02x\n",
12111 result);
12112 return -EINVAL;
12113 }
12114
12115 /* set channel parameters */
12116 channel = def_channel;
12117 channel.frequency = p->frequency / 1000;
12118 channel.bandwidth = DRX_BANDWIDTH_6MHZ;
12119 channel.constellation = constellation;
12120
12121 /* program channel */
12122 result = ctrl_set_channel(demod, &channel);
12123 if (result != 0) {
12124 pr_err("Failed to set channel!\n");
12125 return -EINVAL;
12126 }
12127 /* Just for giggles, let's shut off the LNA again.... */
12128 uio_data.uio = DRX_UIO1;
12129 uio_data.value = false;
12130 result = ctrl_uio_write(demod, &uio_data);
12131 if (result != 0) {
12132 pr_err("Failed to disable LNA!\n");
12133 return 0;
12134 }
12135
12136 /* After set_frontend, except for strength, stats aren't available */
12137 p->strength.stat[0].scale = FE_SCALE_RELATIVE;
12138
12139 return 0;
12140}
12141
12142static int drx39xxj_sleep(struct dvb_frontend *fe)
12143{
12144 /* power-down the demodulator */
12145 return drx39xxj_set_powerstate(fe, 0);
12146}
12147
12148static int drx39xxj_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
12149{
12150 struct drx39xxj_state *state = fe->demodulator_priv;
12151 struct drx_demod_instance *demod = state->demod;
12152 bool i2c_gate_state;
12153 int result;
12154
12155#ifdef DJH_DEBUG
12156 pr_debug("i2c gate call: enable=%d state=%d\n", enable,
12157 state->i2c_gate_open);
12158#endif
12159
12160 if (enable)
12161 i2c_gate_state = true;
12162 else
12163 i2c_gate_state = false;
12164
12165 if (state->i2c_gate_open == enable) {
12166 /* We're already in the desired state */
12167 return 0;
12168 }
12169
12170 result = ctrl_i2c_bridge(demod, &i2c_gate_state);
12171 if (result != 0) {
12172 pr_err("drx39xxj: could not open i2c gate [%d]\n",
12173 result);
12174 dump_stack();
12175 } else {
12176 state->i2c_gate_open = enable;
12177 }
12178 return 0;
12179}
12180
12181static int drx39xxj_init(struct dvb_frontend *fe)
12182{
12183 /* Bring the demod out of sleep */
12184 drx39xxj_set_powerstate(fe, 1);
12185
12186 return 0;
12187}
12188
12189static int drx39xxj_set_lna(struct dvb_frontend *fe)
12190{
12191 int result;
12192 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
12193 struct drx39xxj_state *state = fe->demodulator_priv;
12194 struct drx_demod_instance *demod = state->demod;
12195 struct drxj_data *ext_attr = demod->my_ext_attr;
12196 struct drxuio_cfg uio_cfg;
12197 struct drxuio_data uio_data;
12198
12199 if (c->lna) {
12200 if (!ext_attr->has_lna) {
12201 pr_err("LNA is not supported on this device!\n");
12202 return -EINVAL;
12203
12204 }
12205 }
12206
12207 /* Turn off the LNA */
12208 uio_cfg.uio = DRX_UIO1;
12209 uio_cfg.mode = DRX_UIO_MODE_READWRITE;
12210 /* Configure user-I/O #3: enable read/write */
12211 result = ctrl_set_uio_cfg(demod, &uio_cfg);
12212 if (result) {
12213 pr_err("Failed to setup LNA GPIO!\n");
12214 return result;
12215 }
12216
12217 uio_data.uio = DRX_UIO1;
12218 uio_data.value = c->lna;
12219 result = ctrl_uio_write(demod, &uio_data);
12220 if (result != 0) {
12221 pr_err("Failed to %sable LNA!\n",
12222 c->lna ? "en" : "dis");
12223 return result;
12224 }
12225
12226 return 0;
12227}
12228
12229static int drx39xxj_get_tune_settings(struct dvb_frontend *fe,
12230 struct dvb_frontend_tune_settings *tune)
12231{
12232 tune->min_delay_ms = 1000;
12233 return 0;
12234}
12235
12236static void drx39xxj_release(struct dvb_frontend *fe)
12237{
12238 struct drx39xxj_state *state = fe->demodulator_priv;
12239 struct drx_demod_instance *demod = state->demod;
12240
12241 drxj_close(demod);
12242
12243 kfree(demod->my_ext_attr);
12244 kfree(demod->my_common_attr);
12245 kfree(demod->my_i2c_dev_addr);
12246 if (demod->firmware)
12247 release_firmware(demod->firmware);
12248 kfree(demod);
12249 kfree(state);
12250}
12251
12252static struct dvb_frontend_ops drx39xxj_ops;
12253
12254struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c)
12255{
12256 struct drx39xxj_state *state = NULL;
12257 struct i2c_device_addr *demod_addr = NULL;
12258 struct drx_common_attr *demod_comm_attr = NULL;
12259 struct drxj_data *demod_ext_attr = NULL;
12260 struct drx_demod_instance *demod = NULL;
12261 struct dtv_frontend_properties *p;
12262 struct drxuio_cfg uio_cfg;
12263 struct drxuio_data uio_data;
12264 int result;
12265
12266 /* allocate memory for the internal state */
12267 state = kzalloc(sizeof(struct drx39xxj_state), GFP_KERNEL);
12268 if (state == NULL)
12269 goto error;
12270
12271 demod = kmalloc(sizeof(struct drx_demod_instance), GFP_KERNEL);
12272 if (demod == NULL)
12273 goto error;
12274
12275 demod_addr = kmalloc(sizeof(struct i2c_device_addr), GFP_KERNEL);
12276 if (demod_addr == NULL)
12277 goto error;
12278 memcpy(demod_addr, &drxj_default_addr_g,
12279 sizeof(struct i2c_device_addr));
12280
12281 demod_comm_attr = kmalloc(sizeof(struct drx_common_attr), GFP_KERNEL);
12282 if (demod_comm_attr == NULL)
12283 goto error;
12284 memcpy(demod_comm_attr, &drxj_default_comm_attr_g,
12285 sizeof(struct drx_common_attr));
12286
12287 demod_ext_attr = kmalloc(sizeof(struct drxj_data), GFP_KERNEL);
12288 if (demod_ext_attr == NULL)
12289 goto error;
12290 memcpy(demod_ext_attr, &drxj_data_g, sizeof(struct drxj_data));
12291
12292 /* setup the state */
12293 state->i2c = i2c;
12294 state->demod = demod;
12295
12296 /* setup the demod data */
12297 memcpy(demod, &drxj_default_demod_g, sizeof(struct drx_demod_instance));
12298
12299 demod->my_i2c_dev_addr = demod_addr;
12300 demod->my_common_attr = demod_comm_attr;
12301 demod->my_i2c_dev_addr->user_data = state;
12302 demod->my_common_attr->microcode_file = DRX39XX_MAIN_FIRMWARE;
12303 demod->my_common_attr->verify_microcode = true;
12304 demod->my_common_attr->intermediate_freq = 5000;
12305 demod->my_common_attr->current_power_mode = DRX_POWER_DOWN;
12306 demod->my_ext_attr = demod_ext_attr;
12307 ((struct drxj_data *)demod_ext_attr)->uio_sma_tx_mode = DRX_UIO_MODE_READWRITE;
12308 demod->i2c = i2c;
12309
12310 result = drxj_open(demod);
12311 if (result != 0) {
12312 pr_err("DRX open failed! Aborting\n");
12313 goto error;
12314 }
12315
12316 /* Turn off the LNA */
12317 uio_cfg.uio = DRX_UIO1;
12318 uio_cfg.mode = DRX_UIO_MODE_READWRITE;
12319 /* Configure user-I/O #3: enable read/write */
12320 result = ctrl_set_uio_cfg(demod, &uio_cfg);
12321 if (result) {
12322 pr_err("Failed to setup LNA GPIO!\n");
12323 goto error;
12324 }
12325
12326 uio_data.uio = DRX_UIO1;
12327 uio_data.value = false;
12328 result = ctrl_uio_write(demod, &uio_data);
12329 if (result != 0) {
12330 pr_err("Failed to disable LNA!\n");
12331 goto error;
12332 }
12333
12334 /* create dvb_frontend */
12335 memcpy(&state->frontend.ops, &drx39xxj_ops,
12336 sizeof(struct dvb_frontend_ops));
12337
12338 state->frontend.demodulator_priv = state;
12339
12340 /* Initialize stats - needed for DVBv5 stats to work */
12341 p = &state->frontend.dtv_property_cache;
12342 p->strength.len = 1;
12343 p->pre_bit_count.len = 1;
12344 p->pre_bit_error.len = 1;
12345 p->post_bit_count.len = 1;
12346 p->post_bit_error.len = 1;
12347 p->block_count.len = 1;
12348 p->block_error.len = 1;
12349 p->cnr.len = 1;
12350
12351 p->strength.stat[0].scale = FE_SCALE_RELATIVE;
12352 p->pre_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
12353 p->pre_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
12354 p->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
12355 p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
12356 p->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
12357 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
12358 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
12359
12360 return &state->frontend;
12361
12362error:
12363 kfree(demod_ext_attr);
12364 kfree(demod_comm_attr);
12365 kfree(demod_addr);
12366 kfree(demod);
12367 kfree(state);
12368
12369 return NULL;
12370}
12371EXPORT_SYMBOL(drx39xxj_attach);
12372
12373static struct dvb_frontend_ops drx39xxj_ops = {
12374 .delsys = { SYS_ATSC, SYS_DVBC_ANNEX_B },
12375 .info = {
12376 .name = "Micronas DRX39xxj family Frontend",
12377 .frequency_stepsize = 62500,
12378 .frequency_min = 51000000,
12379 .frequency_max = 858000000,
12380 .caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB
12381 },
12382
12383 .init = drx39xxj_init,
12384 .i2c_gate_ctrl = drx39xxj_i2c_gate_ctrl,
12385 .sleep = drx39xxj_sleep,
12386 .set_frontend = drx39xxj_set_frontend,
12387 .get_tune_settings = drx39xxj_get_tune_settings,
12388 .read_status = drx39xxj_read_status,
12389 .read_ber = drx39xxj_read_ber,
12390 .read_signal_strength = drx39xxj_read_signal_strength,
12391 .read_snr = drx39xxj_read_snr,
12392 .read_ucblocks = drx39xxj_read_ucblocks,
12393 .release = drx39xxj_release,
12394 .set_lna = drx39xxj_set_lna,
12395};
12396
12397MODULE_DESCRIPTION("Micronas DRX39xxj Frontend");
12398MODULE_AUTHOR("Devin Heitmueller");
12399MODULE_LICENSE("GPL");
12400MODULE_FIRMWARE(DRX39XX_MAIN_FIRMWARE);
diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.h b/drivers/media/dvb-frontends/drx39xyj/drxj.h
new file mode 100644
index 000000000000..55ad535197d2
--- /dev/null
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.h
@@ -0,0 +1,650 @@
1
2/*
3 Copyright (c), 2004-2005,2007-2010 Trident Microsystems, Inc.
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8
9 * Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following disclaimer in the documentation
13 and/or other materials provided with the distribution.
14 * Neither the name of Trident Microsystems nor Hauppauge Computer Works
15 nor the names of its contributors may be used to endorse or promote
16 products derived from this software without specific prior written
17 permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 POSSIBILITY OF SUCH DAMAGE.
30
31 DRXJ specific header file
32
33 Authors: Dragan Savic, Milos Nikolic, Mihajlo Katona, Tao Ding, Paul Janssen
34*/
35
36#ifndef __DRXJ_H__
37#define __DRXJ_H__
38/*-------------------------------------------------------------------------
39INCLUDES
40-------------------------------------------------------------------------*/
41
42#include "drx_driver.h"
43#include "drx_dap_fasi.h"
44
45/* Check DRX-J specific dap condition */
46/* Multi master mode and short addr format only will not work.
47 RMW, CRC reset, broadcast and switching back to single master mode
48 cannot be done with short addr only in multi master mode. */
49#if ((DRXDAP_SINGLE_MASTER == 0) && (DRXDAPFASI_LONG_ADDR_ALLOWED == 0))
50#error "Multi master mode and short addressing only is an illegal combination"
51 *; /* Generate a fatal compiler error to make sure it stops here,
52 this is necesarry because not all compilers stop after a #error. */
53#endif
54
55/*-------------------------------------------------------------------------
56TYPEDEFS
57-------------------------------------------------------------------------*/
58/*============================================================================*/
59/*============================================================================*/
60/*== code support ============================================================*/
61/*============================================================================*/
62/*============================================================================*/
63
64/*============================================================================*/
65/*============================================================================*/
66/*== SCU cmd if =============================================================*/
67/*============================================================================*/
68/*============================================================================*/
69
70 struct drxjscu_cmd {
71 u16 command;
72 /**< Command number */
73 u16 parameter_len;
74 /**< Data length in byte */
75 u16 result_len;
76 /**< result length in byte */
77 u16 *parameter;
78 /**< General purpous param */
79 u16 *result;
80 /**< General purpous param */};
81
82/*============================================================================*/
83/*============================================================================*/
84/*== CTRL CFG related data structures ========================================*/
85/*============================================================================*/
86/*============================================================================*/
87
88/* extra intermediate lock state for VSB,QAM,NTSC */
89#define DRXJ_DEMOD_LOCK (DRX_LOCK_STATE_1)
90
91/* OOB lock states */
92#define DRXJ_OOB_AGC_LOCK (DRX_LOCK_STATE_1) /* analog gain control lock */
93#define DRXJ_OOB_SYNC_LOCK (DRX_LOCK_STATE_2) /* digital gain control lock */
94
95/* Intermediate powermodes for DRXJ */
96#define DRXJ_POWER_DOWN_MAIN_PATH DRX_POWER_MODE_8
97#define DRXJ_POWER_DOWN_CORE DRX_POWER_MODE_9
98#define DRXJ_POWER_DOWN_PLL DRX_POWER_MODE_10
99
100/* supstition for GPIO FNC mux */
101#define APP_O (0x0000)
102
103/*#define DRX_CTRL_BASE (0x0000)*/
104
105#define DRXJ_CTRL_CFG_BASE (0x1000)
106 enum drxj_cfg_type {
107 DRXJ_CFG_AGC_RF = DRXJ_CTRL_CFG_BASE,
108 DRXJ_CFG_AGC_IF,
109 DRXJ_CFG_AGC_INTERNAL,
110 DRXJ_CFG_PRE_SAW,
111 DRXJ_CFG_AFE_GAIN,
112 DRXJ_CFG_SYMBOL_CLK_OFFSET,
113 DRXJ_CFG_ACCUM_CR_RS_CW_ERR,
114 DRXJ_CFG_FEC_MERS_SEQ_COUNT,
115 DRXJ_CFG_OOB_MISC,
116 DRXJ_CFG_SMART_ANT,
117 DRXJ_CFG_OOB_PRE_SAW,
118 DRXJ_CFG_VSB_MISC,
119 DRXJ_CFG_RESET_PACKET_ERR,
120
121 /* ATV (FM) */
122 DRXJ_CFG_ATV_OUTPUT, /* also for FM (SIF control) but not likely */
123 DRXJ_CFG_ATV_MISC,
124 DRXJ_CFG_ATV_EQU_COEF,
125 DRXJ_CFG_ATV_AGC_STATUS, /* also for FM ( IF,RF, audioAGC ) */
126
127 DRXJ_CFG_MPEG_OUTPUT_MISC,
128 DRXJ_CFG_HW_CFG,
129 DRXJ_CFG_OOB_LO_POW,
130
131 DRXJ_CFG_MAX /* dummy, never to be used */};
132
133/**
134* /struct enum drxj_cfg_smart_ant_io * smart antenna i/o.
135*/
136enum drxj_cfg_smart_ant_io {
137 DRXJ_SMT_ANT_OUTPUT = 0,
138 DRXJ_SMT_ANT_INPUT
139};
140
141/**
142* /struct struct drxj_cfg_smart_ant * Set smart antenna.
143*/
144 struct drxj_cfg_smart_ant {
145 enum drxj_cfg_smart_ant_io io;
146 u16 ctrl_data;
147 };
148
149/**
150* /struct DRXJAGCSTATUS_t
151* AGC status information from the DRXJ-IQM-AF.
152*/
153struct drxj_agc_status {
154 u16 IFAGC;
155 u16 RFAGC;
156 u16 digital_agc;
157};
158
159/* DRXJ_CFG_AGC_RF, DRXJ_CFG_AGC_IF */
160
161/**
162* /struct enum drxj_agc_ctrl_mode * Available AGCs modes in the DRXJ.
163*/
164 enum drxj_agc_ctrl_mode {
165 DRX_AGC_CTRL_AUTO = 0,
166 DRX_AGC_CTRL_USER,
167 DRX_AGC_CTRL_OFF};
168
169/**
170* /struct struct drxj_cfg_agc * Generic interface for all AGCs present on the DRXJ.
171*/
172 struct drxj_cfg_agc {
173 enum drx_standard standard; /* standard for which these settings apply */
174 enum drxj_agc_ctrl_mode ctrl_mode; /* off, user, auto */
175 u16 output_level; /* range dependent on AGC */
176 u16 min_output_level; /* range dependent on AGC */
177 u16 max_output_level; /* range dependent on AGC */
178 u16 speed; /* range dependent on AGC */
179 u16 top; /* rf-agc take over point */
180 u16 cut_off_current; /* rf-agc is accelerated if output current
181 is below cut-off current */};
182
183/* DRXJ_CFG_PRE_SAW */
184
185/**
186* /struct struct drxj_cfg_pre_saw * Interface to configure pre SAW sense.
187*/
188 struct drxj_cfg_pre_saw {
189 enum drx_standard standard; /* standard to which these settings apply */
190 u16 reference; /* pre SAW reference value, range 0 .. 31 */
191 bool use_pre_saw; /* true algorithms must use pre SAW sense */};
192
193/* DRXJ_CFG_AFE_GAIN */
194
195/**
196* /struct struct drxj_cfg_afe_gain * Interface to configure gain of AFE (LNA + PGA).
197*/
198 struct drxj_cfg_afe_gain {
199 enum drx_standard standard; /* standard to which these settings apply */
200 u16 gain; /* gain in 0.1 dB steps, DRXJ range 140 .. 335 */};
201
202/**
203* /struct drxjrs_errors
204* Available failure information in DRXJ_FEC_RS.
205*
206* Container for errors that are received in the most recently finished measurment period
207*
208*/
209 struct drxjrs_errors {
210 u16 nr_bit_errors;
211 /**< no of pre RS bit errors */
212 u16 nr_symbol_errors;
213 /**< no of pre RS symbol errors */
214 u16 nr_packet_errors;
215 /**< no of pre RS packet errors */
216 u16 nr_failures;
217 /**< no of post RS failures to decode */
218 u16 nr_snc_par_fail_count;
219 /**< no of post RS bit erros */
220 };
221
222/**
223* /struct struct drxj_cfg_vsb_misc * symbol error rate
224*/
225 struct drxj_cfg_vsb_misc {
226 u32 symb_error;
227 /**< symbol error rate sps */};
228
229/**
230* /enum enum drxj_mpeg_output_clock_rate * Mpeg output clock rate.
231*
232*/
233 enum drxj_mpeg_start_width {
234 DRXJ_MPEG_START_WIDTH_1CLKCYC,
235 DRXJ_MPEG_START_WIDTH_8CLKCYC};
236
237/**
238* /enum enum drxj_mpeg_output_clock_rate * Mpeg output clock rate.
239*
240*/
241 enum drxj_mpeg_output_clock_rate {
242 DRXJ_MPEGOUTPUT_CLOCK_RATE_AUTO,
243 DRXJ_MPEGOUTPUT_CLOCK_RATE_75973K,
244 DRXJ_MPEGOUTPUT_CLOCK_RATE_50625K,
245 DRXJ_MPEGOUTPUT_CLOCK_RATE_37968K,
246 DRXJ_MPEGOUTPUT_CLOCK_RATE_30375K,
247 DRXJ_MPEGOUTPUT_CLOCK_RATE_25313K,
248 DRXJ_MPEGOUTPUT_CLOCK_RATE_21696K};
249
250/**
251* /struct DRXJCfgMisc_t
252* Change TEI bit of MPEG output
253* reverse MPEG output bit order
254* set MPEG output clock rate
255*/
256 struct drxj_cfg_mpeg_output_misc {
257 bool disable_tei_handling; /**< if true pass (not change) TEI bit */
258 bool bit_reverse_mpeg_outout; /**< if true, parallel: msb on MD0; serial: lsb out first */
259 enum drxj_mpeg_output_clock_rate mpeg_output_clock_rate;
260 /**< set MPEG output clock rate that overwirtes the derived one from symbol rate */
261 enum drxj_mpeg_start_width mpeg_start_width; /**< set MPEG output start width */};
262
263/**
264* /enum enum drxj_xtal_freq * Supported external crystal reference frequency.
265*/
266 enum drxj_xtal_freq {
267 DRXJ_XTAL_FREQ_RSVD,
268 DRXJ_XTAL_FREQ_27MHZ,
269 DRXJ_XTAL_FREQ_20P25MHZ,
270 DRXJ_XTAL_FREQ_4MHZ};
271
272/**
273* /enum enum drxj_xtal_freq * Supported external crystal reference frequency.
274*/
275 enum drxji2c_speed {
276 DRXJ_I2C_SPEED_400KBPS,
277 DRXJ_I2C_SPEED_100KBPS};
278
279/**
280* /struct struct drxj_cfg_hw_cfg * Get hw configuration, such as crystal reference frequency, I2C speed, etc...
281*/
282 struct drxj_cfg_hw_cfg {
283 enum drxj_xtal_freq xtal_freq;
284 /**< crystal reference frequency */
285 enum drxji2c_speed i2c_speed;
286 /**< 100 or 400 kbps */};
287
288/*
289 * DRXJ_CFG_ATV_MISC
290 */
291 struct drxj_cfg_atv_misc {
292 s16 peak_filter; /* -8 .. 15 */
293 u16 noise_filter; /* 0 .. 15 */};
294
295/*
296 * struct drxj_cfg_oob_misc */
297#define DRXJ_OOB_STATE_RESET 0x0
298#define DRXJ_OOB_STATE_AGN_HUNT 0x1
299#define DRXJ_OOB_STATE_DGN_HUNT 0x2
300#define DRXJ_OOB_STATE_AGC_HUNT 0x3
301#define DRXJ_OOB_STATE_FRQ_HUNT 0x4
302#define DRXJ_OOB_STATE_PHA_HUNT 0x8
303#define DRXJ_OOB_STATE_TIM_HUNT 0x10
304#define DRXJ_OOB_STATE_EQU_HUNT 0x20
305#define DRXJ_OOB_STATE_EQT_HUNT 0x30
306#define DRXJ_OOB_STATE_SYNC 0x40
307
308struct drxj_cfg_oob_misc {
309 struct drxj_agc_status agc;
310 bool eq_lock;
311 bool sym_timing_lock;
312 bool phase_lock;
313 bool freq_lock;
314 bool dig_gain_lock;
315 bool ana_gain_lock;
316 u8 state;
317};
318
319/*
320 * Index of in array of coef
321 */
322 enum drxj_cfg_oob_lo_power {
323 DRXJ_OOB_LO_POW_MINUS0DB = 0,
324 DRXJ_OOB_LO_POW_MINUS5DB,
325 DRXJ_OOB_LO_POW_MINUS10DB,
326 DRXJ_OOB_LO_POW_MINUS15DB,
327 DRXJ_OOB_LO_POW_MAX};
328
329/*
330 * DRXJ_CFG_ATV_EQU_COEF
331 */
332 struct drxj_cfg_atv_equ_coef {
333 s16 coef0; /* -256 .. 255 */
334 s16 coef1; /* -256 .. 255 */
335 s16 coef2; /* -256 .. 255 */
336 s16 coef3; /* -256 .. 255 */};
337
338/*
339 * Index of in array of coef
340 */
341 enum drxj_coef_array_index {
342 DRXJ_COEF_IDX_MN = 0,
343 DRXJ_COEF_IDX_FM,
344 DRXJ_COEF_IDX_L,
345 DRXJ_COEF_IDX_LP,
346 DRXJ_COEF_IDX_BG,
347 DRXJ_COEF_IDX_DK,
348 DRXJ_COEF_IDX_I,
349 DRXJ_COEF_IDX_MAX};
350
351/*
352 * DRXJ_CFG_ATV_OUTPUT
353 */
354
355/**
356* /enum DRXJAttenuation_t
357* Attenuation setting for SIF AGC.
358*
359*/
360 enum drxjsif_attenuation {
361 DRXJ_SIF_ATTENUATION_0DB,
362 DRXJ_SIF_ATTENUATION_3DB,
363 DRXJ_SIF_ATTENUATION_6DB,
364 DRXJ_SIF_ATTENUATION_9DB};
365
366/**
367* /struct struct drxj_cfg_atv_output * SIF attenuation setting.
368*
369*/
370struct drxj_cfg_atv_output {
371 bool enable_cvbs_output; /* true= enabled */
372 bool enable_sif_output; /* true= enabled */
373 enum drxjsif_attenuation sif_attenuation;
374};
375
376/*
377 DRXJ_CFG_ATV_AGC_STATUS (get only)
378*/
379/* TODO : AFE interface not yet finished, subject to change */
380 struct drxj_cfg_atv_agc_status {
381 u16 rf_agc_gain; /* 0 .. 877 uA */
382 u16 if_agc_gain; /* 0 .. 877 uA */
383 s16 video_agc_gain; /* -75 .. 1972 in 0.1 dB steps */
384 s16 audio_agc_gain; /* -4 .. 1020 in 0.1 dB steps */
385 u16 rf_agc_loop_gain; /* 0 .. 7 */
386 u16 if_agc_loop_gain; /* 0 .. 7 */
387 u16 video_agc_loop_gain; /* 0 .. 7 */};
388
389/*============================================================================*/
390/*============================================================================*/
391/*== CTRL related data structures ============================================*/
392/*============================================================================*/
393/*============================================================================*/
394
395/* NONE */
396
397/*============================================================================*/
398/*============================================================================*/
399
400/*========================================*/
401/**
402* /struct struct drxj_data * DRXJ specific attributes.
403*
404* Global data container for DRXJ specific data.
405*
406*/
407 struct drxj_data {
408 /* device capabilties (determined during drx_open()) */
409 bool has_lna; /**< true if LNA (aka PGA) present */
410 bool has_oob; /**< true if OOB supported */
411 bool has_ntsc; /**< true if NTSC supported */
412 bool has_btsc; /**< true if BTSC supported */
413 bool has_smatx; /**< true if mat_tx is available */
414 bool has_smarx; /**< true if mat_rx is available */
415 bool has_gpio; /**< true if GPIO is available */
416 bool has_irqn; /**< true if IRQN is available */
417 /* A1/A2/A... */
418 u8 mfx; /**< metal fix */
419
420 /* tuner settings */
421 bool mirror_freq_spect_oob;/**< tuner inversion (true = tuner mirrors the signal */
422
423 /* standard/channel settings */
424 enum drx_standard standard; /**< current standard information */
425 enum drx_modulation constellation;
426 /**< current constellation */
427 s32 frequency; /**< center signal frequency in KHz */
428 enum drx_bandwidth curr_bandwidth;
429 /**< current channel bandwidth */
430 enum drx_mirror mirror; /**< current channel mirror */
431
432 /* signal quality information */
433 u32 fec_bits_desired; /**< BER accounting period */
434 u16 fec_vd_plen; /**< no of trellis symbols: VD SER measurement period */
435 u16 qam_vd_prescale; /**< Viterbi Measurement Prescale */
436 u16 qam_vd_period; /**< Viterbi Measurement period */
437 u16 fec_rs_plen; /**< defines RS BER measurement period */
438 u16 fec_rs_prescale; /**< ReedSolomon Measurement Prescale */
439 u16 fec_rs_period; /**< ReedSolomon Measurement period */
440 bool reset_pkt_err_acc; /**< Set a flag to reset accumulated packet error */
441 u16 pkt_err_acc_start; /**< Set a flag to reset accumulated packet error */
442
443 /* HI configuration */
444 u16 hi_cfg_timing_div; /**< HI Configure() parameter 2 */
445 u16 hi_cfg_bridge_delay; /**< HI Configure() parameter 3 */
446 u16 hi_cfg_wake_up_key; /**< HI Configure() parameter 4 */
447 u16 hi_cfg_ctrl; /**< HI Configure() parameter 5 */
448 u16 hi_cfg_transmit; /**< HI Configure() parameter 6 */
449
450 /* UIO configuartion */
451 enum drxuio_mode uio_sma_rx_mode;/**< current mode of SmaRx pin */
452 enum drxuio_mode uio_sma_tx_mode;/**< current mode of SmaTx pin */
453 enum drxuio_mode uio_gpio_mode; /**< current mode of ASEL pin */
454 enum drxuio_mode uio_irqn_mode; /**< current mode of IRQN pin */
455
456 /* IQM fs frequecy shift and inversion */
457 u32 iqm_fs_rate_ofs; /**< frequency shifter setting after setchannel */
458 bool pos_image; /**< Ture: positive image */
459 /* IQM RC frequecy shift */
460 u32 iqm_rc_rate_ofs; /**< frequency shifter setting after setchannel */
461
462 /* ATV configuartion */
463 u32 atv_cfg_changed_flags; /**< flag: flags cfg changes */
464 s16 atv_top_equ0[DRXJ_COEF_IDX_MAX]; /**< shadow of ATV_TOP_EQU0__A */
465 s16 atv_top_equ1[DRXJ_COEF_IDX_MAX]; /**< shadow of ATV_TOP_EQU1__A */
466 s16 atv_top_equ2[DRXJ_COEF_IDX_MAX]; /**< shadow of ATV_TOP_EQU2__A */
467 s16 atv_top_equ3[DRXJ_COEF_IDX_MAX]; /**< shadow of ATV_TOP_EQU3__A */
468 bool phase_correction_bypass;/**< flag: true=bypass */
469 s16 atv_top_vid_peak; /**< shadow of ATV_TOP_VID_PEAK__A */
470 u16 atv_top_noise_th; /**< shadow of ATV_TOP_NOISE_TH__A */
471 bool enable_cvbs_output; /**< flag CVBS ouput enable */
472 bool enable_sif_output; /**< flag SIF ouput enable */
473 enum drxjsif_attenuation sif_attenuation;
474 /**< current SIF att setting */
475 /* Agc configuration for QAM and VSB */
476 struct drxj_cfg_agc qam_rf_agc_cfg; /**< qam RF AGC config */
477 struct drxj_cfg_agc qam_if_agc_cfg; /**< qam IF AGC config */
478 struct drxj_cfg_agc vsb_rf_agc_cfg; /**< vsb RF AGC config */
479 struct drxj_cfg_agc vsb_if_agc_cfg; /**< vsb IF AGC config */
480
481 /* PGA gain configuration for QAM and VSB */
482 u16 qam_pga_cfg; /**< qam PGA config */
483 u16 vsb_pga_cfg; /**< vsb PGA config */
484
485 /* Pre SAW configuration for QAM and VSB */
486 struct drxj_cfg_pre_saw qam_pre_saw_cfg;
487 /**< qam pre SAW config */
488 struct drxj_cfg_pre_saw vsb_pre_saw_cfg;
489 /**< qam pre SAW config */
490
491 /* Version information */
492 char v_text[2][12]; /**< allocated text versions */
493 struct drx_version v_version[2]; /**< allocated versions structs */
494 struct drx_version_list v_list_elements[2];
495 /**< allocated version list */
496
497 /* smart antenna configuration */
498 bool smart_ant_inverted;
499
500 /* Tracking filter setting for OOB */
501 u16 oob_trk_filter_cfg[8];
502 bool oob_power_on;
503
504 /* MPEG static bitrate setting */
505 u32 mpeg_ts_static_bitrate; /**< bitrate static MPEG output */
506 bool disable_te_ihandling; /**< MPEG TS TEI handling */
507 bool bit_reverse_mpeg_outout;/**< MPEG output bit order */
508 enum drxj_mpeg_output_clock_rate mpeg_output_clock_rate;
509 /**< MPEG output clock rate */
510 enum drxj_mpeg_start_width mpeg_start_width;
511 /**< MPEG Start width */
512
513 /* Pre SAW & Agc configuration for ATV */
514 struct drxj_cfg_pre_saw atv_pre_saw_cfg;
515 /**< atv pre SAW config */
516 struct drxj_cfg_agc atv_rf_agc_cfg; /**< atv RF AGC config */
517 struct drxj_cfg_agc atv_if_agc_cfg; /**< atv IF AGC config */
518 u16 atv_pga_cfg; /**< atv pga config */
519
520 u32 curr_symbol_rate;
521
522 /* pin-safe mode */
523 bool pdr_safe_mode; /**< PDR safe mode activated */
524 u16 pdr_safe_restore_val_gpio;
525 u16 pdr_safe_restore_val_v_sync;
526 u16 pdr_safe_restore_val_sma_rx;
527 u16 pdr_safe_restore_val_sma_tx;
528
529 /* OOB pre-saw value */
530 u16 oob_pre_saw;
531 enum drxj_cfg_oob_lo_power oob_lo_pow;
532
533 struct drx_aud_data aud_data;
534 /**< audio storage */};
535
536/*-------------------------------------------------------------------------
537Access MACROS
538-------------------------------------------------------------------------*/
539/**
540* \brief Compilable references to attributes
541* \param d pointer to demod instance
542*
543* Used as main reference to an attribute field.
544* Can be used by both macro implementation and function implementation.
545* These macros are defined to avoid duplication of code in macro and function
546* definitions that handle access of demod common or extended attributes.
547*
548*/
549
550#define DRXJ_ATTR_BTSC_DETECT(d) \
551 (((struct drxj_data *)(d)->my_ext_attr)->aud_data.btsc_detect)
552
553/*-------------------------------------------------------------------------
554DEFINES
555-------------------------------------------------------------------------*/
556
557/**
558* \def DRXJ_NTSC_CARRIER_FREQ_OFFSET
559* \brief Offset from picture carrier to centre frequency in kHz, in RF domain
560*
561* For NTSC standard.
562* NTSC channels are listed by their picture carrier frequency (Fpc).
563* The function DRX_CTRL_SET_CHANNEL requires the centre frequency as input.
564* In case the tuner module is not used the DRX-J requires that the tuner is
565* tuned to the centre frequency of the channel:
566*
567* Fcentre = Fpc + DRXJ_NTSC_CARRIER_FREQ_OFFSET
568*
569*/
570#define DRXJ_NTSC_CARRIER_FREQ_OFFSET ((s32)(1750))
571
572/**
573* \def DRXJ_PAL_SECAM_BG_CARRIER_FREQ_OFFSET
574* \brief Offset from picture carrier to centre frequency in kHz, in RF domain
575*
576* For PAL/SECAM - BG standard. This define is needed in case the tuner module
577* is NOT used. PAL/SECAM channels are listed by their picture carrier frequency (Fpc).
578* The DRX-J requires that the tuner is tuned to:
579* Fpc + DRXJ_PAL_SECAM_BG_CARRIER_FREQ_OFFSET
580*
581* In case the tuner module is used the drxdriver takes care of this.
582* In case the tuner module is NOT used the application programmer must take
583* care of this.
584*
585*/
586#define DRXJ_PAL_SECAM_BG_CARRIER_FREQ_OFFSET ((s32)(2375))
587
588/**
589* \def DRXJ_PAL_SECAM_DKIL_CARRIER_FREQ_OFFSET
590* \brief Offset from picture carrier to centre frequency in kHz, in RF domain
591*
592* For PAL/SECAM - DK, I, L standards. This define is needed in case the tuner module
593* is NOT used. PAL/SECAM channels are listed by their picture carrier frequency (Fpc).
594* The DRX-J requires that the tuner is tuned to:
595* Fpc + DRXJ_PAL_SECAM_DKIL_CARRIER_FREQ_OFFSET
596*
597* In case the tuner module is used the drxdriver takes care of this.
598* In case the tuner module is NOT used the application programmer must take
599* care of this.
600*
601*/
602#define DRXJ_PAL_SECAM_DKIL_CARRIER_FREQ_OFFSET ((s32)(2775))
603
604/**
605* \def DRXJ_PAL_SECAM_LP_CARRIER_FREQ_OFFSET
606* \brief Offset from picture carrier to centre frequency in kHz, in RF domain
607*
608* For PAL/SECAM - LP standard. This define is needed in case the tuner module
609* is NOT used. PAL/SECAM channels are listed by their picture carrier frequency (Fpc).
610* The DRX-J requires that the tuner is tuned to:
611* Fpc + DRXJ_PAL_SECAM_LP_CARRIER_FREQ_OFFSET
612*
613* In case the tuner module is used the drxdriver takes care of this.
614* In case the tuner module is NOT used the application programmer must take
615* care of this.
616*/
617#define DRXJ_PAL_SECAM_LP_CARRIER_FREQ_OFFSET ((s32)(-3255))
618
619/**
620* \def DRXJ_FM_CARRIER_FREQ_OFFSET
621* \brief Offset from sound carrier to centre frequency in kHz, in RF domain
622*
623* For FM standard.
624* FM channels are listed by their sound carrier frequency (Fsc).
625* The function DRX_CTRL_SET_CHANNEL requires the Ffm frequency (see below) as
626* input.
627* In case the tuner module is not used the DRX-J requires that the tuner is
628* tuned to the Ffm frequency of the channel.
629*
630* Ffm = Fsc + DRXJ_FM_CARRIER_FREQ_OFFSET
631*
632*/
633#define DRXJ_FM_CARRIER_FREQ_OFFSET ((s32)(-3000))
634
635/* Revision types -------------------------------------------------------*/
636
637#define DRXJ_TYPE_ID (0x3946000DUL)
638
639/* Macros ---------------------------------------------------------------*/
640
641/* Convert OOB lock status to string */
642#define DRXJ_STR_OOB_LOCKSTATUS(x) ( \
643 (x == DRX_NEVER_LOCK) ? "Never" : \
644 (x == DRX_NOT_LOCKED) ? "No" : \
645 (x == DRX_LOCKED) ? "Locked" : \
646 (x == DRX_LOCK_STATE_1) ? "AGC lock" : \
647 (x == DRX_LOCK_STATE_2) ? "sync lock" : \
648 "(Invalid)")
649
650#endif /* __DRXJ_H__ */
diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj_map.h b/drivers/media/dvb-frontends/drx39xyj/drxj_map.h
new file mode 100644
index 000000000000..0bbd4ae1f524
--- /dev/null
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj_map.h
@@ -0,0 +1,15055 @@
1/*
2 Copyright (c), 2004-2005,2007-2010 Trident Microsystems, Inc.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
13 * Neither the name of Trident Microsystems nor Hauppauge Computer Works
14 nor the names of its contributors may be used to endorse or promote
15 products derived from this software without specific prior written
16 permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 POSSIBILITY OF SUCH DAMAGE.
29*/
30
31/*
32 ***********************************************************************************************************************
33 * WARNING - THIS FILE HAS BEEN GENERATED - DO NOT CHANGE
34 *
35 * Filename: drxj_map.h
36 * Generated on: Mon Jan 18 12:09:24 2010
37 * Generated by: IDF:x 1.3.0
38 * Generated from: reg_map
39 * Output start: [entry point]
40 *
41 * filename last modified re-use
42 * -----------------------------------------------------
43 * reg_map.1.tmp Mon Jan 18 12:09:24 2010 -
44 *
45 */
46
47#ifndef __DRXJ_MAP__H__
48#define __DRXJ_MAP__H__ INCLUDED
49
50#ifdef _REGISTERTABLE_
51#include <registertable.h>
52 extern register_table_t drxj_map[];
53 extern register_table_info_t drxj_map_info[];
54#endif
55
56#define ATV_COMM_EXEC__A 0xC00000
57#define ATV_COMM_EXEC__W 2
58#define ATV_COMM_EXEC__M 0x3
59#define ATV_COMM_EXEC__PRE 0x0
60#define ATV_COMM_EXEC_STOP 0x0
61#define ATV_COMM_EXEC_ACTIVE 0x1
62#define ATV_COMM_EXEC_HOLD 0x2
63
64#define ATV_COMM_STATE__A 0xC00001
65#define ATV_COMM_STATE__W 16
66#define ATV_COMM_STATE__M 0xFFFF
67#define ATV_COMM_STATE__PRE 0x0
68#define ATV_COMM_MB__A 0xC00002
69#define ATV_COMM_MB__W 16
70#define ATV_COMM_MB__M 0xFFFF
71#define ATV_COMM_MB__PRE 0x0
72#define ATV_COMM_INT_REQ__A 0xC00003
73#define ATV_COMM_INT_REQ__W 16
74#define ATV_COMM_INT_REQ__M 0xFFFF
75#define ATV_COMM_INT_REQ__PRE 0x0
76#define ATV_COMM_INT_REQ_COMM_INT_REQ__B 0
77#define ATV_COMM_INT_REQ_COMM_INT_REQ__W 1
78#define ATV_COMM_INT_REQ_COMM_INT_REQ__M 0x1
79#define ATV_COMM_INT_REQ_COMM_INT_REQ__PRE 0x0
80
81#define ATV_COMM_INT_STA__A 0xC00005
82#define ATV_COMM_INT_STA__W 16
83#define ATV_COMM_INT_STA__M 0xFFFF
84#define ATV_COMM_INT_STA__PRE 0x0
85#define ATV_COMM_INT_MSK__A 0xC00006
86#define ATV_COMM_INT_MSK__W 16
87#define ATV_COMM_INT_MSK__M 0xFFFF
88#define ATV_COMM_INT_MSK__PRE 0x0
89#define ATV_COMM_INT_STM__A 0xC00007
90#define ATV_COMM_INT_STM__W 16
91#define ATV_COMM_INT_STM__M 0xFFFF
92#define ATV_COMM_INT_STM__PRE 0x0
93
94#define ATV_COMM_KEY__A 0xC0000F
95#define ATV_COMM_KEY__W 16
96#define ATV_COMM_KEY__M 0xFFFF
97#define ATV_COMM_KEY__PRE 0x0
98#define ATV_COMM_KEY_KEY 0xFABA
99#define ATV_COMM_KEY_MIN 0x0
100#define ATV_COMM_KEY_MAX 0xFFFF
101
102#define ATV_TOP_COMM_EXEC__A 0xC10000
103#define ATV_TOP_COMM_EXEC__W 2
104#define ATV_TOP_COMM_EXEC__M 0x3
105#define ATV_TOP_COMM_EXEC__PRE 0x0
106#define ATV_TOP_COMM_EXEC_STOP 0x0
107#define ATV_TOP_COMM_EXEC_ACTIVE 0x1
108#define ATV_TOP_COMM_EXEC_HOLD 0x2
109
110#define ATV_TOP_COMM_STATE__A 0xC10001
111#define ATV_TOP_COMM_STATE__W 16
112#define ATV_TOP_COMM_STATE__M 0xFFFF
113#define ATV_TOP_COMM_STATE__PRE 0x0
114#define ATV_TOP_COMM_STATE_STATE__B 0
115#define ATV_TOP_COMM_STATE_STATE__W 16
116#define ATV_TOP_COMM_STATE_STATE__M 0xFFFF
117#define ATV_TOP_COMM_STATE_STATE__PRE 0x0
118
119#define ATV_TOP_COMM_MB__A 0xC10002
120#define ATV_TOP_COMM_MB__W 16
121#define ATV_TOP_COMM_MB__M 0xFFFF
122#define ATV_TOP_COMM_MB__PRE 0x0
123#define ATV_TOP_COMM_MB_CTL__B 0
124#define ATV_TOP_COMM_MB_CTL__W 1
125#define ATV_TOP_COMM_MB_CTL__M 0x1
126#define ATV_TOP_COMM_MB_CTL__PRE 0x0
127#define ATV_TOP_COMM_MB_OBS__B 1
128#define ATV_TOP_COMM_MB_OBS__W 1
129#define ATV_TOP_COMM_MB_OBS__M 0x2
130#define ATV_TOP_COMM_MB_OBS__PRE 0x0
131
132#define ATV_TOP_COMM_MB_MUX_CTRL__B 2
133#define ATV_TOP_COMM_MB_MUX_CTRL__W 4
134#define ATV_TOP_COMM_MB_MUX_CTRL__M 0x3C
135#define ATV_TOP_COMM_MB_MUX_CTRL__PRE 0x0
136#define ATV_TOP_COMM_MB_MUX_CTRL_PEAK_S 0x0
137#define ATV_TOP_COMM_MB_MUX_CTRL_VID_GAIN 0x4
138#define ATV_TOP_COMM_MB_MUX_CTRL_CORR_O 0x8
139#define ATV_TOP_COMM_MB_MUX_CTRL_CR_ROT_O 0xC
140#define ATV_TOP_COMM_MB_MUX_CTRL_CR_IIR_IQ 0x10
141#define ATV_TOP_COMM_MB_MUX_CTRL_VIDEO_O 0x14
142#define ATV_TOP_COMM_MB_MUX_CTRL_SIF_O 0x18
143#define ATV_TOP_COMM_MB_MUX_CTRL_SIF2025_O 0x1C
144#define ATV_TOP_COMM_MB_MUX_CTRL_POST_S 0x20
145
146#define ATV_TOP_COMM_MB_MUX_OBS__B 6
147#define ATV_TOP_COMM_MB_MUX_OBS__W 4
148#define ATV_TOP_COMM_MB_MUX_OBS__M 0x3C0
149#define ATV_TOP_COMM_MB_MUX_OBS__PRE 0x0
150#define ATV_TOP_COMM_MB_MUX_OBS_PEAK_S 0x0
151#define ATV_TOP_COMM_MB_MUX_OBS_VID_GAIN 0x40
152#define ATV_TOP_COMM_MB_MUX_OBS_CORR_O 0x80
153#define ATV_TOP_COMM_MB_MUX_OBS_CR_ROT_O 0xC0
154#define ATV_TOP_COMM_MB_MUX_OBS_CR_IIR_IQ 0x100
155#define ATV_TOP_COMM_MB_MUX_OBS_VIDEO_O 0x140
156#define ATV_TOP_COMM_MB_MUX_OBS_SIF_O 0x180
157#define ATV_TOP_COMM_MB_MUX_OBS_SIF2025_O 0x1C0
158#define ATV_TOP_COMM_MB_MUX_OBS_POST_S 0x200
159
160#define ATV_TOP_COMM_INT_REQ__A 0xC10003
161#define ATV_TOP_COMM_INT_REQ__W 16
162#define ATV_TOP_COMM_INT_REQ__M 0xFFFF
163#define ATV_TOP_COMM_INT_REQ__PRE 0x0
164#define ATV_TOP_COMM_INT_STA__A 0xC10005
165#define ATV_TOP_COMM_INT_STA__W 16
166#define ATV_TOP_COMM_INT_STA__M 0xFFFF
167#define ATV_TOP_COMM_INT_STA__PRE 0x0
168
169#define ATV_TOP_COMM_INT_STA_FAGC_STA__B 0
170#define ATV_TOP_COMM_INT_STA_FAGC_STA__W 1
171#define ATV_TOP_COMM_INT_STA_FAGC_STA__M 0x1
172#define ATV_TOP_COMM_INT_STA_FAGC_STA__PRE 0x0
173
174#define ATV_TOP_COMM_INT_STA_OVM_STA__B 1
175#define ATV_TOP_COMM_INT_STA_OVM_STA__W 1
176#define ATV_TOP_COMM_INT_STA_OVM_STA__M 0x2
177#define ATV_TOP_COMM_INT_STA_OVM_STA__PRE 0x0
178
179#define ATV_TOP_COMM_INT_STA_AMPTH_STA__B 2
180#define ATV_TOP_COMM_INT_STA_AMPTH_STA__W 1
181#define ATV_TOP_COMM_INT_STA_AMPTH_STA__M 0x4
182#define ATV_TOP_COMM_INT_STA_AMPTH_STA__PRE 0x0
183
184#define ATV_TOP_COMM_INT_MSK__A 0xC10006
185#define ATV_TOP_COMM_INT_MSK__W 16
186#define ATV_TOP_COMM_INT_MSK__M 0xFFFF
187#define ATV_TOP_COMM_INT_MSK__PRE 0x0
188
189#define ATV_TOP_COMM_INT_MSK_FAGC_MSK__B 0
190#define ATV_TOP_COMM_INT_MSK_FAGC_MSK__W 1
191#define ATV_TOP_COMM_INT_MSK_FAGC_MSK__M 0x1
192#define ATV_TOP_COMM_INT_MSK_FAGC_MSK__PRE 0x0
193
194#define ATV_TOP_COMM_INT_MSK_OVM_MSK__B 1
195#define ATV_TOP_COMM_INT_MSK_OVM_MSK__W 1
196#define ATV_TOP_COMM_INT_MSK_OVM_MSK__M 0x2
197#define ATV_TOP_COMM_INT_MSK_OVM_MSK__PRE 0x0
198
199#define ATV_TOP_COMM_INT_MSK_AMPTH_MSK__B 2
200#define ATV_TOP_COMM_INT_MSK_AMPTH_MSK__W 1
201#define ATV_TOP_COMM_INT_MSK_AMPTH_MSK__M 0x4
202#define ATV_TOP_COMM_INT_MSK_AMPTH_MSK__PRE 0x0
203
204#define ATV_TOP_COMM_INT_STM__A 0xC10007
205#define ATV_TOP_COMM_INT_STM__W 16
206#define ATV_TOP_COMM_INT_STM__M 0xFFFF
207#define ATV_TOP_COMM_INT_STM__PRE 0x0
208
209#define ATV_TOP_COMM_INT_STM_FAGC_STM__B 0
210#define ATV_TOP_COMM_INT_STM_FAGC_STM__W 1
211#define ATV_TOP_COMM_INT_STM_FAGC_STM__M 0x1
212#define ATV_TOP_COMM_INT_STM_FAGC_STM__PRE 0x0
213
214#define ATV_TOP_COMM_INT_STM_OVM_STM__B 1
215#define ATV_TOP_COMM_INT_STM_OVM_STM__W 1
216#define ATV_TOP_COMM_INT_STM_OVM_STM__M 0x2
217#define ATV_TOP_COMM_INT_STM_OVM_STM__PRE 0x0
218
219#define ATV_TOP_COMM_INT_STM_AMPTH_STM__B 2
220#define ATV_TOP_COMM_INT_STM_AMPTH_STM__W 1
221#define ATV_TOP_COMM_INT_STM_AMPTH_STM__M 0x4
222#define ATV_TOP_COMM_INT_STM_AMPTH_STM__PRE 0x0
223
224#define ATV_TOP_COMM_KEY__A 0xC1000F
225#define ATV_TOP_COMM_KEY__W 16
226#define ATV_TOP_COMM_KEY__M 0xFFFF
227#define ATV_TOP_COMM_KEY__PRE 0x0
228
229#define ATV_TOP_COMM_KEY_KEY__B 0
230#define ATV_TOP_COMM_KEY_KEY__W 16
231#define ATV_TOP_COMM_KEY_KEY__M 0xFFFF
232#define ATV_TOP_COMM_KEY_KEY__PRE 0x0
233#define ATV_TOP_COMM_KEY_KEY_KEY 0xFABA
234#define ATV_TOP_COMM_KEY_KEY_MIN 0x0
235#define ATV_TOP_COMM_KEY_KEY_MAX 0xFFFF
236
237#define ATV_TOP_CR_AMP_TH__A 0xC10010
238#define ATV_TOP_CR_AMP_TH__W 8
239#define ATV_TOP_CR_AMP_TH__M 0xFF
240#define ATV_TOP_CR_AMP_TH__PRE 0x8
241#define ATV_TOP_CR_AMP_TH_MN 0x8
242
243#define ATV_TOP_CR_CONT__A 0xC10011
244#define ATV_TOP_CR_CONT__W 9
245#define ATV_TOP_CR_CONT__M 0x1FF
246#define ATV_TOP_CR_CONT__PRE 0x9C
247
248#define ATV_TOP_CR_CONT_CR_P__B 0
249#define ATV_TOP_CR_CONT_CR_P__W 3
250#define ATV_TOP_CR_CONT_CR_P__M 0x7
251#define ATV_TOP_CR_CONT_CR_P__PRE 0x4
252#define ATV_TOP_CR_CONT_CR_P_MN 0x4
253#define ATV_TOP_CR_CONT_CR_P_FM 0x0
254
255#define ATV_TOP_CR_CONT_CR_D__B 3
256#define ATV_TOP_CR_CONT_CR_D__W 3
257#define ATV_TOP_CR_CONT_CR_D__M 0x38
258#define ATV_TOP_CR_CONT_CR_D__PRE 0x18
259#define ATV_TOP_CR_CONT_CR_D_MN 0x18
260#define ATV_TOP_CR_CONT_CR_D_FM 0x0
261
262#define ATV_TOP_CR_CONT_CR_I__B 6
263#define ATV_TOP_CR_CONT_CR_I__W 3
264#define ATV_TOP_CR_CONT_CR_I__M 0x1C0
265#define ATV_TOP_CR_CONT_CR_I__PRE 0x80
266#define ATV_TOP_CR_CONT_CR_I_MN 0x80
267#define ATV_TOP_CR_CONT_CR_I_FM 0x0
268
269#define ATV_TOP_CR_OVM_TH__A 0xC10012
270#define ATV_TOP_CR_OVM_TH__W 8
271#define ATV_TOP_CR_OVM_TH__M 0xFF
272#define ATV_TOP_CR_OVM_TH__PRE 0xA0
273#define ATV_TOP_CR_OVM_TH_MN 0xA0
274#define ATV_TOP_CR_OVM_TH_FM 0x0
275
276#define ATV_TOP_NOISE_TH__A 0xC10013
277#define ATV_TOP_NOISE_TH__W 4
278#define ATV_TOP_NOISE_TH__M 0xF
279#define ATV_TOP_NOISE_TH__PRE 0x8
280#define ATV_TOP_NOISE_TH_MN 0x8
281
282#define ATV_TOP_EQU0__A 0xC10014
283#define ATV_TOP_EQU0__W 9
284#define ATV_TOP_EQU0__M 0x1FF
285#define ATV_TOP_EQU0__PRE 0x1FB
286
287#define ATV_TOP_EQU0_EQU_C0__B 0
288#define ATV_TOP_EQU0_EQU_C0__W 9
289#define ATV_TOP_EQU0_EQU_C0__M 0x1FF
290#define ATV_TOP_EQU0_EQU_C0__PRE 0x1FB
291#define ATV_TOP_EQU0_EQU_C0_MN 0xFB
292
293#define ATV_TOP_EQU1__A 0xC10015
294#define ATV_TOP_EQU1__W 9
295#define ATV_TOP_EQU1__M 0x1FF
296#define ATV_TOP_EQU1__PRE 0x1CE
297
298#define ATV_TOP_EQU1_EQU_C1__B 0
299#define ATV_TOP_EQU1_EQU_C1__W 9
300#define ATV_TOP_EQU1_EQU_C1__M 0x1FF
301#define ATV_TOP_EQU1_EQU_C1__PRE 0x1CE
302#define ATV_TOP_EQU1_EQU_C1_MN 0xCE
303
304#define ATV_TOP_EQU2__A 0xC10016
305#define ATV_TOP_EQU2__W 9
306#define ATV_TOP_EQU2__M 0x1FF
307#define ATV_TOP_EQU2__PRE 0xD2
308
309#define ATV_TOP_EQU2_EQU_C2__B 0
310#define ATV_TOP_EQU2_EQU_C2__W 9
311#define ATV_TOP_EQU2_EQU_C2__M 0x1FF
312#define ATV_TOP_EQU2_EQU_C2__PRE 0xD2
313#define ATV_TOP_EQU2_EQU_C2_MN 0xD2
314
315#define ATV_TOP_EQU3__A 0xC10017
316#define ATV_TOP_EQU3__W 9
317#define ATV_TOP_EQU3__M 0x1FF
318#define ATV_TOP_EQU3__PRE 0x160
319
320#define ATV_TOP_EQU3_EQU_C3__B 0
321#define ATV_TOP_EQU3_EQU_C3__W 9
322#define ATV_TOP_EQU3_EQU_C3__M 0x1FF
323#define ATV_TOP_EQU3_EQU_C3__PRE 0x160
324#define ATV_TOP_EQU3_EQU_C3_MN 0x60
325
326#define ATV_TOP_ROT_MODE__A 0xC10018
327#define ATV_TOP_ROT_MODE__W 1
328#define ATV_TOP_ROT_MODE__M 0x1
329#define ATV_TOP_ROT_MODE__PRE 0x0
330#define ATV_TOP_ROT_MODE_AMPTH_DEPEND 0x0
331#define ATV_TOP_ROT_MODE_ALWAYS 0x1
332
333#define ATV_TOP_MOD_CONTROL__A 0xC10019
334#define ATV_TOP_MOD_CONTROL__W 12
335#define ATV_TOP_MOD_CONTROL__M 0xFFF
336#define ATV_TOP_MOD_CONTROL__PRE 0x5B1
337
338#define ATV_TOP_MOD_CONTROL_MOD_IR__B 0
339#define ATV_TOP_MOD_CONTROL_MOD_IR__W 3
340#define ATV_TOP_MOD_CONTROL_MOD_IR__M 0x7
341#define ATV_TOP_MOD_CONTROL_MOD_IR__PRE 0x1
342#define ATV_TOP_MOD_CONTROL_MOD_IR_MN 0x1
343#define ATV_TOP_MOD_CONTROL_MOD_IR_FM 0x0
344
345#define ATV_TOP_MOD_CONTROL_MOD_IF__B 3
346#define ATV_TOP_MOD_CONTROL_MOD_IF__W 4
347#define ATV_TOP_MOD_CONTROL_MOD_IF__M 0x78
348#define ATV_TOP_MOD_CONTROL_MOD_IF__PRE 0x30
349#define ATV_TOP_MOD_CONTROL_MOD_IF_MN 0x30
350#define ATV_TOP_MOD_CONTROL_MOD_IF_FM 0x0
351
352#define ATV_TOP_MOD_CONTROL_MOD_MODE__B 7
353#define ATV_TOP_MOD_CONTROL_MOD_MODE__W 1
354#define ATV_TOP_MOD_CONTROL_MOD_MODE__M 0x80
355#define ATV_TOP_MOD_CONTROL_MOD_MODE__PRE 0x80
356#define ATV_TOP_MOD_CONTROL_MOD_MODE_RISE 0x0
357#define ATV_TOP_MOD_CONTROL_MOD_MODE_RISE_FALL 0x80
358
359#define ATV_TOP_MOD_CONTROL_MOD_TH__B 8
360#define ATV_TOP_MOD_CONTROL_MOD_TH__W 4
361#define ATV_TOP_MOD_CONTROL_MOD_TH__M 0xF00
362#define ATV_TOP_MOD_CONTROL_MOD_TH__PRE 0x500
363#define ATV_TOP_MOD_CONTROL_MOD_TH_MN 0x500
364#define ATV_TOP_MOD_CONTROL_MOD_TH_FM 0x0
365
366#define ATV_TOP_STD__A 0xC1001A
367#define ATV_TOP_STD__W 2
368#define ATV_TOP_STD__M 0x3
369#define ATV_TOP_STD__PRE 0x0
370
371#define ATV_TOP_STD_MODE__B 0
372#define ATV_TOP_STD_MODE__W 1
373#define ATV_TOP_STD_MODE__M 0x1
374#define ATV_TOP_STD_MODE__PRE 0x0
375#define ATV_TOP_STD_MODE_MN 0x0
376#define ATV_TOP_STD_MODE_FM 0x1
377
378#define ATV_TOP_STD_VID_POL__B 1
379#define ATV_TOP_STD_VID_POL__W 1
380#define ATV_TOP_STD_VID_POL__M 0x2
381#define ATV_TOP_STD_VID_POL__PRE 0x0
382#define ATV_TOP_STD_VID_POL_NEG 0x0
383#define ATV_TOP_STD_VID_POL_POS 0x2
384
385#define ATV_TOP_VID_AMP__A 0xC1001B
386#define ATV_TOP_VID_AMP__W 12
387#define ATV_TOP_VID_AMP__M 0xFFF
388#define ATV_TOP_VID_AMP__PRE 0x380
389#define ATV_TOP_VID_AMP_MN 0x380
390#define ATV_TOP_VID_AMP_FM 0x0
391
392#define ATV_TOP_VID_PEAK__A 0xC1001C
393#define ATV_TOP_VID_PEAK__W 5
394#define ATV_TOP_VID_PEAK__M 0x1F
395#define ATV_TOP_VID_PEAK__PRE 0x1
396
397#define ATV_TOP_FAGC_TH__A 0xC1001D
398#define ATV_TOP_FAGC_TH__W 11
399#define ATV_TOP_FAGC_TH__M 0x7FF
400#define ATV_TOP_FAGC_TH__PRE 0x2B2
401#define ATV_TOP_FAGC_TH_MN 0x2B2
402
403#define ATV_TOP_SYNC_SLICE__A 0xC1001E
404#define ATV_TOP_SYNC_SLICE__W 11
405#define ATV_TOP_SYNC_SLICE__M 0x7FF
406#define ATV_TOP_SYNC_SLICE__PRE 0x243
407#define ATV_TOP_SYNC_SLICE_MN 0x243
408
409#define ATV_TOP_SIF_GAIN__A 0xC1001F
410#define ATV_TOP_SIF_GAIN__W 11
411#define ATV_TOP_SIF_GAIN__M 0x7FF
412#define ATV_TOP_SIF_GAIN__PRE 0x0
413
414#define ATV_TOP_SIF_TP__A 0xC10020
415#define ATV_TOP_SIF_TP__W 6
416#define ATV_TOP_SIF_TP__M 0x3F
417#define ATV_TOP_SIF_TP__PRE 0x0
418
419#define ATV_TOP_MOD_ACCU__A 0xC10021
420#define ATV_TOP_MOD_ACCU__W 10
421#define ATV_TOP_MOD_ACCU__M 0x3FF
422#define ATV_TOP_MOD_ACCU__PRE 0x0
423
424#define ATV_TOP_CR_FREQ__A 0xC10022
425#define ATV_TOP_CR_FREQ__W 8
426#define ATV_TOP_CR_FREQ__M 0xFF
427#define ATV_TOP_CR_FREQ__PRE 0x0
428
429#define ATV_TOP_CR_PHAD__A 0xC10023
430#define ATV_TOP_CR_PHAD__W 12
431#define ATV_TOP_CR_PHAD__M 0xFFF
432#define ATV_TOP_CR_PHAD__PRE 0x0
433
434#define ATV_TOP_AF_SIF_ATT__A 0xC10024
435#define ATV_TOP_AF_SIF_ATT__W 2
436#define ATV_TOP_AF_SIF_ATT__M 0x3
437#define ATV_TOP_AF_SIF_ATT__PRE 0x0
438#define ATV_TOP_AF_SIF_ATT_0DB 0x0
439#define ATV_TOP_AF_SIF_ATT_M3DB 0x1
440#define ATV_TOP_AF_SIF_ATT_M6DB 0x2
441#define ATV_TOP_AF_SIF_ATT_M9DB 0x3
442
443#define ATV_TOP_STDBY__A 0xC10025
444#define ATV_TOP_STDBY__W 2
445#define ATV_TOP_STDBY__M 0x3
446#define ATV_TOP_STDBY__PRE 0x1
447
448#define ATV_TOP_STDBY_SIF_STDBY__B 0
449#define ATV_TOP_STDBY_SIF_STDBY__W 1
450#define ATV_TOP_STDBY_SIF_STDBY__M 0x1
451#define ATV_TOP_STDBY_SIF_STDBY__PRE 0x1
452#define ATV_TOP_STDBY_SIF_STDBY_ACTIVE 0x0
453#define ATV_TOP_STDBY_SIF_STDBY_STANDBY 0x1
454
455#define ATV_TOP_STDBY_CVBS_STDBY__B 1
456#define ATV_TOP_STDBY_CVBS_STDBY__W 1
457#define ATV_TOP_STDBY_CVBS_STDBY__M 0x2
458#define ATV_TOP_STDBY_CVBS_STDBY__PRE 0x0
459#define ATV_TOP_STDBY_CVBS_STDBY_A1_ACTIVE 0x0
460#define ATV_TOP_STDBY_CVBS_STDBY_A1_STANDBY 0x2
461#define ATV_TOP_STDBY_CVBS_STDBY_A2_ACTIVE 0x2
462#define ATV_TOP_STDBY_CVBS_STDBY_A2_STANDBY 0x0
463
464#define ATV_TOP_OVERRIDE_SFR__A 0xC10026
465#define ATV_TOP_OVERRIDE_SFR__W 1
466#define ATV_TOP_OVERRIDE_SFR__M 0x1
467#define ATV_TOP_OVERRIDE_SFR__PRE 0x0
468#define ATV_TOP_OVERRIDE_SFR_ACTIVE 0x0
469#define ATV_TOP_OVERRIDE_SFR_OVERRIDE 0x1
470
471#define ATV_TOP_SFR_VID_GAIN__A 0xC10027
472#define ATV_TOP_SFR_VID_GAIN__W 16
473#define ATV_TOP_SFR_VID_GAIN__M 0xFFFF
474#define ATV_TOP_SFR_VID_GAIN__PRE 0x0
475
476#define ATV_TOP_SFR_AGC_RES__A 0xC10028
477#define ATV_TOP_SFR_AGC_RES__W 5
478#define ATV_TOP_SFR_AGC_RES__M 0x1F
479#define ATV_TOP_SFR_AGC_RES__PRE 0x0
480
481#define ATV_TOP_OVM_COMP__A 0xC10029
482#define ATV_TOP_OVM_COMP__W 12
483#define ATV_TOP_OVM_COMP__M 0xFFF
484#define ATV_TOP_OVM_COMP__PRE 0x0
485#define ATV_TOP_OUT_CONF__A 0xC1002A
486#define ATV_TOP_OUT_CONF__W 5
487#define ATV_TOP_OUT_CONF__M 0x1F
488#define ATV_TOP_OUT_CONF__PRE 0x0
489
490#define ATV_TOP_OUT_CONF_CVBS_DAC_SIGN__B 0
491#define ATV_TOP_OUT_CONF_CVBS_DAC_SIGN__W 1
492#define ATV_TOP_OUT_CONF_CVBS_DAC_SIGN__M 0x1
493#define ATV_TOP_OUT_CONF_CVBS_DAC_SIGN__PRE 0x0
494#define ATV_TOP_OUT_CONF_CVBS_DAC_SIGN_UNSIGNED 0x0
495#define ATV_TOP_OUT_CONF_CVBS_DAC_SIGN_SIGNED 0x1
496
497#define ATV_TOP_OUT_CONF_SIF_DAC_SIGN__B 1
498#define ATV_TOP_OUT_CONF_SIF_DAC_SIGN__W 1
499#define ATV_TOP_OUT_CONF_SIF_DAC_SIGN__M 0x2
500#define ATV_TOP_OUT_CONF_SIF_DAC_SIGN__PRE 0x0
501#define ATV_TOP_OUT_CONF_SIF_DAC_SIGN_UNSIGNED 0x0
502#define ATV_TOP_OUT_CONF_SIF_DAC_SIGN_SIGNED 0x2
503
504#define ATV_TOP_OUT_CONF_SIF20_SIGN__B 2
505#define ATV_TOP_OUT_CONF_SIF20_SIGN__W 1
506#define ATV_TOP_OUT_CONF_SIF20_SIGN__M 0x4
507#define ATV_TOP_OUT_CONF_SIF20_SIGN__PRE 0x0
508#define ATV_TOP_OUT_CONF_SIF20_SIGN_UNSIGNED 0x0
509#define ATV_TOP_OUT_CONF_SIF20_SIGN_SIGNED 0x4
510
511#define ATV_TOP_OUT_CONF_CVBS_DAC_BR__B 3
512#define ATV_TOP_OUT_CONF_CVBS_DAC_BR__W 1
513#define ATV_TOP_OUT_CONF_CVBS_DAC_BR__M 0x8
514#define ATV_TOP_OUT_CONF_CVBS_DAC_BR__PRE 0x0
515#define ATV_TOP_OUT_CONF_CVBS_DAC_BR_NORMAL 0x0
516#define ATV_TOP_OUT_CONF_CVBS_DAC_BR_BITREVERSED 0x8
517
518#define ATV_TOP_OUT_CONF_SIF_DAC_BR__B 4
519#define ATV_TOP_OUT_CONF_SIF_DAC_BR__W 1
520#define ATV_TOP_OUT_CONF_SIF_DAC_BR__M 0x10
521#define ATV_TOP_OUT_CONF_SIF_DAC_BR__PRE 0x0
522#define ATV_TOP_OUT_CONF_SIF_DAC_BR_NORMAL 0x0
523#define ATV_TOP_OUT_CONF_SIF_DAC_BR_BITREVERSED 0x10
524
525#define ATV_AFT_COMM_EXEC__A 0xFF0000
526#define ATV_AFT_COMM_EXEC__W 2
527#define ATV_AFT_COMM_EXEC__M 0x3
528#define ATV_AFT_COMM_EXEC__PRE 0x0
529#define ATV_AFT_COMM_EXEC_STOP 0x0
530#define ATV_AFT_COMM_EXEC_ACTIVE 0x1
531#define ATV_AFT_COMM_EXEC_HOLD 0x2
532
533#define ATV_AFT_TST__A 0xFF0010
534#define ATV_AFT_TST__W 4
535#define ATV_AFT_TST__M 0xF
536#define ATV_AFT_TST__PRE 0x0
537
538#define AUD_COMM_EXEC__A 0x1000000
539#define AUD_COMM_EXEC__W 2
540#define AUD_COMM_EXEC__M 0x3
541#define AUD_COMM_EXEC__PRE 0x0
542#define AUD_COMM_EXEC_STOP 0x0
543#define AUD_COMM_EXEC_ACTIVE 0x1
544
545#define AUD_COMM_MB__A 0x1000002
546#define AUD_COMM_MB__W 16
547#define AUD_COMM_MB__M 0xFFFF
548#define AUD_COMM_MB__PRE 0x0
549
550#define AUD_TOP_COMM_EXEC__A 0x1010000
551#define AUD_TOP_COMM_EXEC__W 2
552#define AUD_TOP_COMM_EXEC__M 0x3
553#define AUD_TOP_COMM_EXEC__PRE 0x0
554#define AUD_TOP_COMM_EXEC_STOP 0x0
555#define AUD_TOP_COMM_EXEC_ACTIVE 0x1
556
557#define AUD_TOP_COMM_MB__A 0x1010002
558#define AUD_TOP_COMM_MB__W 16
559#define AUD_TOP_COMM_MB__M 0xFFFF
560#define AUD_TOP_COMM_MB__PRE 0x0
561
562#define AUD_TOP_COMM_MB_CTL__B 0
563#define AUD_TOP_COMM_MB_CTL__W 1
564#define AUD_TOP_COMM_MB_CTL__M 0x1
565#define AUD_TOP_COMM_MB_CTL__PRE 0x0
566#define AUD_TOP_COMM_MB_CTL_CTR_OFF 0x0
567#define AUD_TOP_COMM_MB_CTL_CTR_ON 0x1
568
569#define AUD_TOP_COMM_MB_OBS__B 1
570#define AUD_TOP_COMM_MB_OBS__W 1
571#define AUD_TOP_COMM_MB_OBS__M 0x2
572#define AUD_TOP_COMM_MB_OBS__PRE 0x0
573#define AUD_TOP_COMM_MB_OBS_OBS_OFF 0x0
574#define AUD_TOP_COMM_MB_OBS_OBS_ON 0x2
575
576#define AUD_TOP_COMM_MB_MUX_CTRL__B 2
577#define AUD_TOP_COMM_MB_MUX_CTRL__W 4
578#define AUD_TOP_COMM_MB_MUX_CTRL__M 0x3C
579#define AUD_TOP_COMM_MB_MUX_CTRL__PRE 0x0
580#define AUD_TOP_COMM_MB_MUX_CTRL_DEMOD_TBO 0x0
581#define AUD_TOP_COMM_MB_MUX_CTRL_XDFP_IRQS 0x4
582#define AUD_TOP_COMM_MB_MUX_CTRL_OBSERVEPC 0x8
583#define AUD_TOP_COMM_MB_MUX_CTRL_SAOUT 0xC
584#define AUD_TOP_COMM_MB_MUX_CTRL_XDFP_SCHEQ 0x10
585
586#define AUD_TOP_COMM_MB_MUX_OBS__B 6
587#define AUD_TOP_COMM_MB_MUX_OBS__W 4
588#define AUD_TOP_COMM_MB_MUX_OBS__M 0x3C0
589#define AUD_TOP_COMM_MB_MUX_OBS__PRE 0x0
590#define AUD_TOP_COMM_MB_MUX_OBS_DEMOD_TBO 0x0
591#define AUD_TOP_COMM_MB_MUX_OBS_XDFP_IRQS 0x40
592#define AUD_TOP_COMM_MB_MUX_OBS_OBSERVEPC 0x80
593#define AUD_TOP_COMM_MB_MUX_OBS_SAOUT 0xC0
594#define AUD_TOP_COMM_MB_MUX_OBS_XDFP_SCHEQ 0x100
595
596#define AUD_TOP_TR_MDE__A 0x1010010
597#define AUD_TOP_TR_MDE__W 5
598#define AUD_TOP_TR_MDE__M 0x1F
599#define AUD_TOP_TR_MDE__PRE 0x18
600
601#define AUD_TOP_TR_MDE_FIFO_SIZE__B 0
602#define AUD_TOP_TR_MDE_FIFO_SIZE__W 4
603#define AUD_TOP_TR_MDE_FIFO_SIZE__M 0xF
604#define AUD_TOP_TR_MDE_FIFO_SIZE__PRE 0x8
605
606#define AUD_TOP_TR_MDE_RD_LOCK__B 4
607#define AUD_TOP_TR_MDE_RD_LOCK__W 1
608#define AUD_TOP_TR_MDE_RD_LOCK__M 0x10
609#define AUD_TOP_TR_MDE_RD_LOCK__PRE 0x10
610#define AUD_TOP_TR_MDE_RD_LOCK_NORMAL 0x0
611#define AUD_TOP_TR_MDE_RD_LOCK_LOCK 0x10
612
613#define AUD_TOP_TR_CTR__A 0x1010011
614#define AUD_TOP_TR_CTR__W 4
615#define AUD_TOP_TR_CTR__M 0xF
616#define AUD_TOP_TR_CTR__PRE 0x0
617
618#define AUD_TOP_TR_CTR_FIFO_RD_RDY__B 0
619#define AUD_TOP_TR_CTR_FIFO_RD_RDY__W 1
620#define AUD_TOP_TR_CTR_FIFO_RD_RDY__M 0x1
621#define AUD_TOP_TR_CTR_FIFO_RD_RDY__PRE 0x0
622#define AUD_TOP_TR_CTR_FIFO_RD_RDY_NOT_READY 0x0
623#define AUD_TOP_TR_CTR_FIFO_RD_RDY_READY 0x1
624
625#define AUD_TOP_TR_CTR_FIFO_EMPTY__B 1
626#define AUD_TOP_TR_CTR_FIFO_EMPTY__W 1
627#define AUD_TOP_TR_CTR_FIFO_EMPTY__M 0x2
628#define AUD_TOP_TR_CTR_FIFO_EMPTY__PRE 0x0
629#define AUD_TOP_TR_CTR_FIFO_EMPTY_NOT_EMPTY 0x0
630#define AUD_TOP_TR_CTR_FIFO_EMPTY_EMPTY 0x2
631
632#define AUD_TOP_TR_CTR_FIFO_LOCK__B 2
633#define AUD_TOP_TR_CTR_FIFO_LOCK__W 1
634#define AUD_TOP_TR_CTR_FIFO_LOCK__M 0x4
635#define AUD_TOP_TR_CTR_FIFO_LOCK__PRE 0x0
636#define AUD_TOP_TR_CTR_FIFO_LOCK_UNLOCKED 0x0
637#define AUD_TOP_TR_CTR_FIFO_LOCK_LOCKED 0x4
638
639#define AUD_TOP_TR_CTR_FIFO_FULL__B 3
640#define AUD_TOP_TR_CTR_FIFO_FULL__W 1
641#define AUD_TOP_TR_CTR_FIFO_FULL__M 0x8
642#define AUD_TOP_TR_CTR_FIFO_FULL__PRE 0x0
643#define AUD_TOP_TR_CTR_FIFO_FULL_EMPTY 0x0
644#define AUD_TOP_TR_CTR_FIFO_FULL_FULL 0x8
645
646#define AUD_TOP_TR_RD_REG__A 0x1010012
647#define AUD_TOP_TR_RD_REG__W 16
648#define AUD_TOP_TR_RD_REG__M 0xFFFF
649#define AUD_TOP_TR_RD_REG__PRE 0x0
650
651#define AUD_TOP_TR_RD_REG_RESULT__B 0
652#define AUD_TOP_TR_RD_REG_RESULT__W 16
653#define AUD_TOP_TR_RD_REG_RESULT__M 0xFFFF
654#define AUD_TOP_TR_RD_REG_RESULT__PRE 0x0
655
656#define AUD_TOP_TR_TIMER__A 0x1010013
657#define AUD_TOP_TR_TIMER__W 16
658#define AUD_TOP_TR_TIMER__M 0xFFFF
659#define AUD_TOP_TR_TIMER__PRE 0x0
660
661#define AUD_TOP_TR_TIMER_CYCLES__B 0
662#define AUD_TOP_TR_TIMER_CYCLES__W 16
663#define AUD_TOP_TR_TIMER_CYCLES__M 0xFFFF
664#define AUD_TOP_TR_TIMER_CYCLES__PRE 0x0
665
666#define AUD_TOP_DEMOD_TBO_SEL__A 0x1010014
667#define AUD_TOP_DEMOD_TBO_SEL__W 5
668#define AUD_TOP_DEMOD_TBO_SEL__M 0x1F
669#define AUD_TOP_DEMOD_TBO_SEL__PRE 0x0
670
671#define AUD_DEM_WR_MODUS__A 0x1030030
672#define AUD_DEM_WR_MODUS__W 16
673#define AUD_DEM_WR_MODUS__M 0xFFFF
674#define AUD_DEM_WR_MODUS__PRE 0x0
675
676#define AUD_DEM_WR_MODUS_MOD_ASS__B 0
677#define AUD_DEM_WR_MODUS_MOD_ASS__W 1
678#define AUD_DEM_WR_MODUS_MOD_ASS__M 0x1
679#define AUD_DEM_WR_MODUS_MOD_ASS__PRE 0x0
680#define AUD_DEM_WR_MODUS_MOD_ASS_OFF 0x0
681#define AUD_DEM_WR_MODUS_MOD_ASS_ON 0x1
682
683#define AUD_DEM_WR_MODUS_MOD_STATINTERR__B 1
684#define AUD_DEM_WR_MODUS_MOD_STATINTERR__W 1
685#define AUD_DEM_WR_MODUS_MOD_STATINTERR__M 0x2
686#define AUD_DEM_WR_MODUS_MOD_STATINTERR__PRE 0x0
687#define AUD_DEM_WR_MODUS_MOD_STATINTERR_DISABLE 0x0
688#define AUD_DEM_WR_MODUS_MOD_STATINTERR_ENABLE 0x2
689
690#define AUD_DEM_WR_MODUS_MOD_DIS_STD_CHG__B 2
691#define AUD_DEM_WR_MODUS_MOD_DIS_STD_CHG__W 1
692#define AUD_DEM_WR_MODUS_MOD_DIS_STD_CHG__M 0x4
693#define AUD_DEM_WR_MODUS_MOD_DIS_STD_CHG__PRE 0x0
694#define AUD_DEM_WR_MODUS_MOD_DIS_STD_CHG_ENABLED 0x0
695#define AUD_DEM_WR_MODUS_MOD_DIS_STD_CHG_DISABLED 0x4
696
697#define AUD_DEM_WR_MODUS_MOD_HDEV_A__B 8
698#define AUD_DEM_WR_MODUS_MOD_HDEV_A__W 1
699#define AUD_DEM_WR_MODUS_MOD_HDEV_A__M 0x100
700#define AUD_DEM_WR_MODUS_MOD_HDEV_A__PRE 0x0
701#define AUD_DEM_WR_MODUS_MOD_HDEV_A_NORMAL 0x0
702#define AUD_DEM_WR_MODUS_MOD_HDEV_A_HIGH_DEVIATION 0x100
703
704#define AUD_DEM_WR_MODUS_MOD_CM_A__B 9
705#define AUD_DEM_WR_MODUS_MOD_CM_A__W 1
706#define AUD_DEM_WR_MODUS_MOD_CM_A__M 0x200
707#define AUD_DEM_WR_MODUS_MOD_CM_A__PRE 0x0
708#define AUD_DEM_WR_MODUS_MOD_CM_A_MUTE 0x0
709#define AUD_DEM_WR_MODUS_MOD_CM_A_NOISE 0x200
710
711#define AUD_DEM_WR_MODUS_MOD_CM_B__B 10
712#define AUD_DEM_WR_MODUS_MOD_CM_B__W 1
713#define AUD_DEM_WR_MODUS_MOD_CM_B__M 0x400
714#define AUD_DEM_WR_MODUS_MOD_CM_B__PRE 0x0
715#define AUD_DEM_WR_MODUS_MOD_CM_B_MUTE 0x0
716#define AUD_DEM_WR_MODUS_MOD_CM_B_NOISE 0x400
717
718#define AUD_DEM_WR_MODUS_MOD_FMRADIO__B 11
719#define AUD_DEM_WR_MODUS_MOD_FMRADIO__W 1
720#define AUD_DEM_WR_MODUS_MOD_FMRADIO__M 0x800
721#define AUD_DEM_WR_MODUS_MOD_FMRADIO__PRE 0x0
722#define AUD_DEM_WR_MODUS_MOD_FMRADIO_US_75U 0x0
723#define AUD_DEM_WR_MODUS_MOD_FMRADIO_EU_50U 0x800
724
725#define AUD_DEM_WR_MODUS_MOD_6_5MHZ__B 12
726#define AUD_DEM_WR_MODUS_MOD_6_5MHZ__W 1
727#define AUD_DEM_WR_MODUS_MOD_6_5MHZ__M 0x1000
728#define AUD_DEM_WR_MODUS_MOD_6_5MHZ__PRE 0x0
729#define AUD_DEM_WR_MODUS_MOD_6_5MHZ_SECAM 0x0
730#define AUD_DEM_WR_MODUS_MOD_6_5MHZ_D_K 0x1000
731
732#define AUD_DEM_WR_MODUS_MOD_4_5MHZ__B 13
733#define AUD_DEM_WR_MODUS_MOD_4_5MHZ__W 2
734#define AUD_DEM_WR_MODUS_MOD_4_5MHZ__M 0x6000
735#define AUD_DEM_WR_MODUS_MOD_4_5MHZ__PRE 0x0
736#define AUD_DEM_WR_MODUS_MOD_4_5MHZ_M_KOREA 0x0
737#define AUD_DEM_WR_MODUS_MOD_4_5MHZ_M_BTSC 0x2000
738#define AUD_DEM_WR_MODUS_MOD_4_5MHZ_M_EIAJ 0x4000
739#define AUD_DEM_WR_MODUS_MOD_4_5MHZ_CHROMA 0x6000
740
741#define AUD_DEM_WR_MODUS_MOD_BTSC__B 15
742#define AUD_DEM_WR_MODUS_MOD_BTSC__W 1
743#define AUD_DEM_WR_MODUS_MOD_BTSC__M 0x8000
744#define AUD_DEM_WR_MODUS_MOD_BTSC__PRE 0x0
745#define AUD_DEM_WR_MODUS_MOD_BTSC_BTSC_STEREO 0x0
746#define AUD_DEM_WR_MODUS_MOD_BTSC_BTSC_SAP 0x8000
747
748#define AUD_DEM_WR_STANDARD_SEL__A 0x1030020
749#define AUD_DEM_WR_STANDARD_SEL__W 16
750#define AUD_DEM_WR_STANDARD_SEL__M 0xFFFF
751#define AUD_DEM_WR_STANDARD_SEL__PRE 0x0
752
753#define AUD_DEM_WR_STANDARD_SEL_STD_SEL__B 0
754#define AUD_DEM_WR_STANDARD_SEL_STD_SEL__W 12
755#define AUD_DEM_WR_STANDARD_SEL_STD_SEL__M 0xFFF
756#define AUD_DEM_WR_STANDARD_SEL_STD_SEL__PRE 0x0
757#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_AUTO 0x1
758#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_M_KOREA 0x2
759#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_BG_FM 0x3
760#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_D_K1 0x4
761#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_D_K2 0x5
762#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_D_K3 0x7
763#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_BG_NICAM_FM 0x8
764#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_L_NICAM_AM 0x9
765#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_I_NICAM_FM 0xA
766#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_D_K_NICAM_FM 0xB
767#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_BTSC_STEREO 0x20
768#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_BTSC_SAP 0x21
769#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_EIA_J 0x30
770#define AUD_DEM_WR_STANDARD_SEL_STD_SEL_FM_RADIO 0x40
771
772#define AUD_DEM_RD_STANDARD_RES__A 0x102007E
773#define AUD_DEM_RD_STANDARD_RES__W 16
774#define AUD_DEM_RD_STANDARD_RES__M 0xFFFF
775#define AUD_DEM_RD_STANDARD_RES__PRE 0x0
776
777#define AUD_DEM_RD_STANDARD_RES_STD_RESULT__B 0
778#define AUD_DEM_RD_STANDARD_RES_STD_RESULT__W 16
779#define AUD_DEM_RD_STANDARD_RES_STD_RESULT__M 0xFFFF
780#define AUD_DEM_RD_STANDARD_RES_STD_RESULT__PRE 0x0
781#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_NO_SOUND_STANDARD 0x0
782#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_NTSC_M_DUAL_CARRIER_FM 0x2
783#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_B_G_DUAL_CARRIER_FM 0x3
784#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_D_K1_DUAL_CARRIER_FM 0x4
785#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_D_K2_DUAL_CARRIER_FM 0x5
786#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_D_K3_DUAL_CARRIER_FM 0x7
787#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_B_G_NICAM_FM 0x8
788#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_L_NICAM_AM 0x9
789#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_I_NICAM_FM 0xA
790#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_D_K_NICAM_FM 0xB
791#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_BTSC_STEREO 0x20
792#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_BTSC_MONO_SAP 0x21
793#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_NTSC_EIA_J 0x30
794#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_FM_RADIO 0x40
795#define AUD_DEM_RD_STANDARD_RES_STD_RESULT_DETECTION_STILL_ACTIVE 0x7FF
796
797#define AUD_DEM_RD_STATUS__A 0x1020200
798#define AUD_DEM_RD_STATUS__W 16
799#define AUD_DEM_RD_STATUS__M 0xFFFF
800#define AUD_DEM_RD_STATUS__PRE 0x0
801
802#define AUD_DEM_RD_STATUS_STAT_NEW_RDS__B 0
803#define AUD_DEM_RD_STATUS_STAT_NEW_RDS__W 1
804#define AUD_DEM_RD_STATUS_STAT_NEW_RDS__M 0x1
805#define AUD_DEM_RD_STATUS_STAT_NEW_RDS__PRE 0x0
806#define AUD_DEM_RD_STATUS_STAT_NEW_RDS_NO_RDS_DATA 0x0
807#define AUD_DEM_RD_STATUS_STAT_NEW_RDS_NEW_RDS_DATA 0x1
808
809#define AUD_DEM_RD_STATUS_STAT_CARR_A__B 1
810#define AUD_DEM_RD_STATUS_STAT_CARR_A__W 1
811#define AUD_DEM_RD_STATUS_STAT_CARR_A__M 0x2
812#define AUD_DEM_RD_STATUS_STAT_CARR_A__PRE 0x0
813#define AUD_DEM_RD_STATUS_STAT_CARR_A_DETECTED 0x0
814#define AUD_DEM_RD_STATUS_STAT_CARR_A_NOT_DETECTED 0x2
815
816#define AUD_DEM_RD_STATUS_STAT_CARR_B__B 2
817#define AUD_DEM_RD_STATUS_STAT_CARR_B__W 1
818#define AUD_DEM_RD_STATUS_STAT_CARR_B__M 0x4
819#define AUD_DEM_RD_STATUS_STAT_CARR_B__PRE 0x0
820#define AUD_DEM_RD_STATUS_STAT_CARR_B_DETECTED 0x0
821#define AUD_DEM_RD_STATUS_STAT_CARR_B_NOT_DETECTED 0x4
822
823#define AUD_DEM_RD_STATUS_STAT_NICAM__B 5
824#define AUD_DEM_RD_STATUS_STAT_NICAM__W 1
825#define AUD_DEM_RD_STATUS_STAT_NICAM__M 0x20
826#define AUD_DEM_RD_STATUS_STAT_NICAM__PRE 0x0
827#define AUD_DEM_RD_STATUS_STAT_NICAM_NO_NICAM 0x0
828#define AUD_DEM_RD_STATUS_STAT_NICAM_NICAM_DETECTED 0x20
829
830#define AUD_DEM_RD_STATUS_STAT_STEREO__B 6
831#define AUD_DEM_RD_STATUS_STAT_STEREO__W 1
832#define AUD_DEM_RD_STATUS_STAT_STEREO__M 0x40
833#define AUD_DEM_RD_STATUS_STAT_STEREO__PRE 0x0
834#define AUD_DEM_RD_STATUS_STAT_STEREO_NO_STEREO 0x0
835#define AUD_DEM_RD_STATUS_STAT_STEREO_STEREO 0x40
836
837#define AUD_DEM_RD_STATUS_STAT_INDEP_MONO__B 7
838#define AUD_DEM_RD_STATUS_STAT_INDEP_MONO__W 1
839#define AUD_DEM_RD_STATUS_STAT_INDEP_MONO__M 0x80
840#define AUD_DEM_RD_STATUS_STAT_INDEP_MONO__PRE 0x0
841#define AUD_DEM_RD_STATUS_STAT_INDEP_MONO_DEPENDENT_FM_MONO_PROGRAM 0x0
842#define AUD_DEM_RD_STATUS_STAT_INDEP_MONO_INDEPENDENT_FM_MONO_PROGRAM 0x80
843
844#define AUD_DEM_RD_STATUS_STAT_BIL_OR_SAP__B 8
845#define AUD_DEM_RD_STATUS_STAT_BIL_OR_SAP__W 1
846#define AUD_DEM_RD_STATUS_STAT_BIL_OR_SAP__M 0x100
847#define AUD_DEM_RD_STATUS_STAT_BIL_OR_SAP__PRE 0x0
848#define AUD_DEM_RD_STATUS_STAT_BIL_OR_SAP_NO_SAP 0x0
849#define AUD_DEM_RD_STATUS_STAT_BIL_OR_SAP_SAP 0x100
850
851#define AUD_DEM_RD_STATUS_BAD_NICAM__B 9
852#define AUD_DEM_RD_STATUS_BAD_NICAM__W 1
853#define AUD_DEM_RD_STATUS_BAD_NICAM__M 0x200
854#define AUD_DEM_RD_STATUS_BAD_NICAM__PRE 0x0
855#define AUD_DEM_RD_STATUS_BAD_NICAM_OK 0x0
856#define AUD_DEM_RD_STATUS_BAD_NICAM_BAD 0x200
857
858#define AUD_DEM_RD_RDS_ARRAY_CNT__A 0x102020F
859#define AUD_DEM_RD_RDS_ARRAY_CNT__W 12
860#define AUD_DEM_RD_RDS_ARRAY_CNT__M 0xFFF
861#define AUD_DEM_RD_RDS_ARRAY_CNT__PRE 0x0
862
863#define AUD_DEM_RD_RDS_ARRAY_CNT_RDS_ARRAY_CT__B 0
864#define AUD_DEM_RD_RDS_ARRAY_CNT_RDS_ARRAY_CT__W 12
865#define AUD_DEM_RD_RDS_ARRAY_CNT_RDS_ARRAY_CT__M 0xFFF
866#define AUD_DEM_RD_RDS_ARRAY_CNT_RDS_ARRAY_CT__PRE 0x0
867#define AUD_DEM_RD_RDS_ARRAY_CNT_RDS_ARRAY_CT_RDS_DATA_NOT_VALID 0xFFF
868
869#define AUD_DEM_RD_RDS_DATA__A 0x1020210
870#define AUD_DEM_RD_RDS_DATA__W 12
871#define AUD_DEM_RD_RDS_DATA__M 0xFFF
872#define AUD_DEM_RD_RDS_DATA__PRE 0x0
873
874#define AUD_DSP_WR_FM_PRESC__A 0x105000E
875#define AUD_DSP_WR_FM_PRESC__W 16
876#define AUD_DSP_WR_FM_PRESC__M 0xFFFF
877#define AUD_DSP_WR_FM_PRESC__PRE 0x0
878
879#define AUD_DSP_WR_FM_PRESC_FM_AM_PRESC__B 8
880#define AUD_DSP_WR_FM_PRESC_FM_AM_PRESC__W 8
881#define AUD_DSP_WR_FM_PRESC_FM_AM_PRESC__M 0xFF00
882#define AUD_DSP_WR_FM_PRESC_FM_AM_PRESC__PRE 0x0
883#define AUD_DSP_WR_FM_PRESC_FM_AM_PRESC_28_KHZ_FM_DEVIATION 0x7F00
884#define AUD_DSP_WR_FM_PRESC_FM_AM_PRESC_50_KHZ_FM_DEVIATION 0x4800
885#define AUD_DSP_WR_FM_PRESC_FM_AM_PRESC_75_KHZ_FM_DEVIATION 0x3000
886#define AUD_DSP_WR_FM_PRESC_FM_AM_PRESC_100_KHZ_FM_DEVIATION 0x2400
887#define AUD_DSP_WR_FM_PRESC_FM_AM_PRESC_150_KHZ_FM_DEVIATION 0x1800
888#define AUD_DSP_WR_FM_PRESC_FM_AM_PRESC_180_KHZ_FM_DEVIATION 0x1300
889#define AUD_DSP_WR_FM_PRESC_FM_AM_PRESC_380_KHZ_FM_DEVIATION 0x900
890
891#define AUD_DSP_WR_NICAM_PRESC__A 0x1050010
892#define AUD_DSP_WR_NICAM_PRESC__W 16
893#define AUD_DSP_WR_NICAM_PRESC__M 0xFFFF
894#define AUD_DSP_WR_NICAM_PRESC__PRE 0x0
895#define AUD_DSP_WR_VOLUME__A 0x1050000
896#define AUD_DSP_WR_VOLUME__W 16
897#define AUD_DSP_WR_VOLUME__M 0xFFFF
898#define AUD_DSP_WR_VOLUME__PRE 0x0
899
900#define AUD_DSP_WR_VOLUME_VOL_MAIN__B 8
901#define AUD_DSP_WR_VOLUME_VOL_MAIN__W 8
902#define AUD_DSP_WR_VOLUME_VOL_MAIN__M 0xFF00
903#define AUD_DSP_WR_VOLUME_VOL_MAIN__PRE 0x0
904
905#define AUD_DSP_WR_SRC_I2S_MATR__A 0x1050038
906#define AUD_DSP_WR_SRC_I2S_MATR__W 16
907#define AUD_DSP_WR_SRC_I2S_MATR__M 0xFFFF
908#define AUD_DSP_WR_SRC_I2S_MATR__PRE 0x0
909
910#define AUD_DSP_WR_SRC_I2S_MATR_SRC_I2S__B 8
911#define AUD_DSP_WR_SRC_I2S_MATR_SRC_I2S__W 8
912#define AUD_DSP_WR_SRC_I2S_MATR_SRC_I2S__M 0xFF00
913#define AUD_DSP_WR_SRC_I2S_MATR_SRC_I2S__PRE 0x0
914#define AUD_DSP_WR_SRC_I2S_MATR_SRC_I2S_MONO 0x0
915#define AUD_DSP_WR_SRC_I2S_MATR_SRC_I2S_STEREO_AB 0x100
916#define AUD_DSP_WR_SRC_I2S_MATR_SRC_I2S_STEREO_A 0x300
917#define AUD_DSP_WR_SRC_I2S_MATR_SRC_I2S_STEREO_B 0x400
918
919#define AUD_DSP_WR_SRC_I2S_MATR_MAT_I2S__B 0
920#define AUD_DSP_WR_SRC_I2S_MATR_MAT_I2S__W 8
921#define AUD_DSP_WR_SRC_I2S_MATR_MAT_I2S__M 0xFF
922#define AUD_DSP_WR_SRC_I2S_MATR_MAT_I2S__PRE 0x0
923#define AUD_DSP_WR_SRC_I2S_MATR_MAT_I2S_SOUND_A 0x0
924#define AUD_DSP_WR_SRC_I2S_MATR_MAT_I2S_SOUND_B 0x10
925#define AUD_DSP_WR_SRC_I2S_MATR_MAT_I2S_STEREO 0x20
926#define AUD_DSP_WR_SRC_I2S_MATR_MAT_I2S_MONO 0x30
927
928#define AUD_DSP_WR_AVC__A 0x1050029
929#define AUD_DSP_WR_AVC__W 16
930#define AUD_DSP_WR_AVC__M 0xFFFF
931#define AUD_DSP_WR_AVC__PRE 0x0
932
933#define AUD_DSP_WR_AVC_AVC_ON__B 14
934#define AUD_DSP_WR_AVC_AVC_ON__W 2
935#define AUD_DSP_WR_AVC_AVC_ON__M 0xC000
936#define AUD_DSP_WR_AVC_AVC_ON__PRE 0x0
937#define AUD_DSP_WR_AVC_AVC_ON_OFF 0x0
938#define AUD_DSP_WR_AVC_AVC_ON_ON 0xC000
939
940#define AUD_DSP_WR_AVC_AVC_DECAY__B 8
941#define AUD_DSP_WR_AVC_AVC_DECAY__W 4
942#define AUD_DSP_WR_AVC_AVC_DECAY__M 0xF00
943#define AUD_DSP_WR_AVC_AVC_DECAY__PRE 0x0
944#define AUD_DSP_WR_AVC_AVC_DECAY_8_SEC 0x800
945#define AUD_DSP_WR_AVC_AVC_DECAY_4_SEC 0x400
946#define AUD_DSP_WR_AVC_AVC_DECAY_2_SEC 0x200
947#define AUD_DSP_WR_AVC_AVC_DECAY_20_MSEC 0x100
948
949#define AUD_DSP_WR_AVC_AVC_REF_LEV__B 4
950#define AUD_DSP_WR_AVC_AVC_REF_LEV__W 4
951#define AUD_DSP_WR_AVC_AVC_REF_LEV__M 0xF0
952#define AUD_DSP_WR_AVC_AVC_REF_LEV__PRE 0x0
953
954#define AUD_DSP_WR_AVC_AVC_MAX_ATT__B 2
955#define AUD_DSP_WR_AVC_AVC_MAX_ATT__W 2
956#define AUD_DSP_WR_AVC_AVC_MAX_ATT__M 0xC
957#define AUD_DSP_WR_AVC_AVC_MAX_ATT__PRE 0x0
958#define AUD_DSP_WR_AVC_AVC_MAX_ATT_24DB 0x0
959#define AUD_DSP_WR_AVC_AVC_MAX_ATT_18DB 0x4
960#define AUD_DSP_WR_AVC_AVC_MAX_ATT_12DB 0x8
961
962#define AUD_DSP_WR_AVC_AVC_MAX_GAIN__B 0
963#define AUD_DSP_WR_AVC_AVC_MAX_GAIN__W 2
964#define AUD_DSP_WR_AVC_AVC_MAX_GAIN__M 0x3
965#define AUD_DSP_WR_AVC_AVC_MAX_GAIN__PRE 0x0
966#define AUD_DSP_WR_AVC_AVC_MAX_GAIN_6DB 0x0
967#define AUD_DSP_WR_AVC_AVC_MAX_GAIN_12DB 0x1
968#define AUD_DSP_WR_AVC_AVC_MAX_GAIN_0DB 0x3
969
970#define AUD_DSP_WR_QPEAK__A 0x105000C
971#define AUD_DSP_WR_QPEAK__W 16
972#define AUD_DSP_WR_QPEAK__M 0xFFFF
973#define AUD_DSP_WR_QPEAK__PRE 0x0
974
975#define AUD_DSP_WR_QPEAK_SRC_QP__B 8
976#define AUD_DSP_WR_QPEAK_SRC_QP__W 8
977#define AUD_DSP_WR_QPEAK_SRC_QP__M 0xFF00
978#define AUD_DSP_WR_QPEAK_SRC_QP__PRE 0x0
979#define AUD_DSP_WR_QPEAK_SRC_QP_MONO 0x0
980#define AUD_DSP_WR_QPEAK_SRC_QP_STEREO_AB 0x100
981#define AUD_DSP_WR_QPEAK_SRC_QP_STEREO_A 0x300
982#define AUD_DSP_WR_QPEAK_SRC_QP_STEREO_B 0x400
983
984#define AUD_DSP_WR_QPEAK_MAT_QP__B 0
985#define AUD_DSP_WR_QPEAK_MAT_QP__W 8
986#define AUD_DSP_WR_QPEAK_MAT_QP__M 0xFF
987#define AUD_DSP_WR_QPEAK_MAT_QP__PRE 0x0
988#define AUD_DSP_WR_QPEAK_MAT_QP_SOUND_A 0x0
989#define AUD_DSP_WR_QPEAK_MAT_QP_SOUND_B 0x10
990#define AUD_DSP_WR_QPEAK_MAT_QP_STEREO 0x20
991#define AUD_DSP_WR_QPEAK_MAT_QP_MONO 0x30
992
993#define AUD_DSP_RD_QPEAK_L__A 0x1040019
994#define AUD_DSP_RD_QPEAK_L__W 16
995#define AUD_DSP_RD_QPEAK_L__M 0xFFFF
996#define AUD_DSP_RD_QPEAK_L__PRE 0x0
997
998#define AUD_DSP_RD_QPEAK_R__A 0x104001A
999#define AUD_DSP_RD_QPEAK_R__W 16
1000#define AUD_DSP_RD_QPEAK_R__M 0xFFFF
1001#define AUD_DSP_RD_QPEAK_R__PRE 0x0
1002
1003#define AUD_DSP_WR_BEEPER__A 0x1050014
1004#define AUD_DSP_WR_BEEPER__W 16
1005#define AUD_DSP_WR_BEEPER__M 0xFFFF
1006#define AUD_DSP_WR_BEEPER__PRE 0x0
1007
1008#define AUD_DSP_WR_BEEPER_BEEP_VOLUME__B 8
1009#define AUD_DSP_WR_BEEPER_BEEP_VOLUME__W 7
1010#define AUD_DSP_WR_BEEPER_BEEP_VOLUME__M 0x7F00
1011#define AUD_DSP_WR_BEEPER_BEEP_VOLUME__PRE 0x0
1012
1013#define AUD_DSP_WR_BEEPER_BEEP_FREQUENCY__B 0
1014#define AUD_DSP_WR_BEEPER_BEEP_FREQUENCY__W 7
1015#define AUD_DSP_WR_BEEPER_BEEP_FREQUENCY__M 0x7F
1016#define AUD_DSP_WR_BEEPER_BEEP_FREQUENCY__PRE 0x0
1017
1018#define AUD_DEM_WR_I2S_CONFIG2__A 0x1030050
1019#define AUD_DEM_WR_I2S_CONFIG2__W 16
1020#define AUD_DEM_WR_I2S_CONFIG2__M 0xFFFF
1021#define AUD_DEM_WR_I2S_CONFIG2__PRE 0x0
1022
1023#define AUD_DEM_WR_I2S_CONFIG2_I2S_CL_POL__B 6
1024#define AUD_DEM_WR_I2S_CONFIG2_I2S_CL_POL__W 1
1025#define AUD_DEM_WR_I2S_CONFIG2_I2S_CL_POL__M 0x40
1026#define AUD_DEM_WR_I2S_CONFIG2_I2S_CL_POL__PRE 0x0
1027#define AUD_DEM_WR_I2S_CONFIG2_I2S_CL_POL_NORMAL 0x0
1028#define AUD_DEM_WR_I2S_CONFIG2_I2S_CL_POL_INVERTED 0x40
1029
1030#define AUD_DEM_WR_I2S_CONFIG2_I2S_ENABLE__B 4
1031#define AUD_DEM_WR_I2S_CONFIG2_I2S_ENABLE__W 1
1032#define AUD_DEM_WR_I2S_CONFIG2_I2S_ENABLE__M 0x10
1033#define AUD_DEM_WR_I2S_CONFIG2_I2S_ENABLE__PRE 0x0
1034#define AUD_DEM_WR_I2S_CONFIG2_I2S_ENABLE_DISABLE 0x0
1035#define AUD_DEM_WR_I2S_CONFIG2_I2S_ENABLE_ENABLE 0x10
1036
1037#define AUD_DEM_WR_I2S_CONFIG2_I2S_SLV_MST__B 3
1038#define AUD_DEM_WR_I2S_CONFIG2_I2S_SLV_MST__W 1
1039#define AUD_DEM_WR_I2S_CONFIG2_I2S_SLV_MST__M 0x8
1040#define AUD_DEM_WR_I2S_CONFIG2_I2S_SLV_MST__PRE 0x0
1041#define AUD_DEM_WR_I2S_CONFIG2_I2S_SLV_MST_MASTER 0x0
1042#define AUD_DEM_WR_I2S_CONFIG2_I2S_SLV_MST_SLAVE 0x8
1043
1044#define AUD_DEM_WR_I2S_CONFIG2_I2S_WS_POL__B 2
1045#define AUD_DEM_WR_I2S_CONFIG2_I2S_WS_POL__W 1
1046#define AUD_DEM_WR_I2S_CONFIG2_I2S_WS_POL__M 0x4
1047#define AUD_DEM_WR_I2S_CONFIG2_I2S_WS_POL__PRE 0x0
1048#define AUD_DEM_WR_I2S_CONFIG2_I2S_WS_POL_LEFT_LOW 0x0
1049#define AUD_DEM_WR_I2S_CONFIG2_I2S_WS_POL_LEFT_HIGH 0x4
1050
1051#define AUD_DEM_WR_I2S_CONFIG2_I2S_WS_MODE__B 1
1052#define AUD_DEM_WR_I2S_CONFIG2_I2S_WS_MODE__W 1
1053#define AUD_DEM_WR_I2S_CONFIG2_I2S_WS_MODE__M 0x2
1054#define AUD_DEM_WR_I2S_CONFIG2_I2S_WS_MODE__PRE 0x0
1055#define AUD_DEM_WR_I2S_CONFIG2_I2S_WS_MODE_NO_DELAY 0x0
1056#define AUD_DEM_WR_I2S_CONFIG2_I2S_WS_MODE_DELAY 0x2
1057
1058#define AUD_DEM_WR_I2S_CONFIG2_I2S_WORD_LEN__B 0
1059#define AUD_DEM_WR_I2S_CONFIG2_I2S_WORD_LEN__W 1
1060#define AUD_DEM_WR_I2S_CONFIG2_I2S_WORD_LEN__M 0x1
1061#define AUD_DEM_WR_I2S_CONFIG2_I2S_WORD_LEN__PRE 0x0
1062#define AUD_DEM_WR_I2S_CONFIG2_I2S_WORD_LEN_BIT_32 0x0
1063#define AUD_DEM_WR_I2S_CONFIG2_I2S_WORD_LEN_BIT_16 0x1
1064
1065#define AUD_DSP_WR_I2S_OUT_FS__A 0x105002A
1066#define AUD_DSP_WR_I2S_OUT_FS__W 16
1067#define AUD_DSP_WR_I2S_OUT_FS__M 0xFFFF
1068#define AUD_DSP_WR_I2S_OUT_FS__PRE 0x0
1069
1070#define AUD_DSP_WR_I2S_OUT_FS_FS_OUT__B 0
1071#define AUD_DSP_WR_I2S_OUT_FS_FS_OUT__W 16
1072#define AUD_DSP_WR_I2S_OUT_FS_FS_OUT__M 0xFFFF
1073#define AUD_DSP_WR_I2S_OUT_FS_FS_OUT__PRE 0x0
1074
1075#define AUD_DSP_WR_AV_SYNC__A 0x105002B
1076#define AUD_DSP_WR_AV_SYNC__W 16
1077#define AUD_DSP_WR_AV_SYNC__M 0xFFFF
1078#define AUD_DSP_WR_AV_SYNC__PRE 0x0
1079
1080#define AUD_DSP_WR_AV_SYNC_AV_ON__B 15
1081#define AUD_DSP_WR_AV_SYNC_AV_ON__W 1
1082#define AUD_DSP_WR_AV_SYNC_AV_ON__M 0x8000
1083#define AUD_DSP_WR_AV_SYNC_AV_ON__PRE 0x0
1084#define AUD_DSP_WR_AV_SYNC_AV_ON_DISABLE 0x0
1085#define AUD_DSP_WR_AV_SYNC_AV_ON_ENABLE 0x8000
1086
1087#define AUD_DSP_WR_AV_SYNC_AV_AUTO_FREQ__B 14
1088#define AUD_DSP_WR_AV_SYNC_AV_AUTO_FREQ__W 1
1089#define AUD_DSP_WR_AV_SYNC_AV_AUTO_FREQ__M 0x4000
1090#define AUD_DSP_WR_AV_SYNC_AV_AUTO_FREQ__PRE 0x0
1091#define AUD_DSP_WR_AV_SYNC_AV_AUTO_FREQ_MONOCHROME 0x0
1092#define AUD_DSP_WR_AV_SYNC_AV_AUTO_FREQ_NTSC 0x4000
1093
1094#define AUD_DSP_WR_AV_SYNC_AV_STD_SEL__B 0
1095#define AUD_DSP_WR_AV_SYNC_AV_STD_SEL__W 2
1096#define AUD_DSP_WR_AV_SYNC_AV_STD_SEL__M 0x3
1097#define AUD_DSP_WR_AV_SYNC_AV_STD_SEL__PRE 0x0
1098#define AUD_DSP_WR_AV_SYNC_AV_STD_SEL_AUTO 0x0
1099#define AUD_DSP_WR_AV_SYNC_AV_STD_SEL_PAL_SECAM 0x1
1100#define AUD_DSP_WR_AV_SYNC_AV_STD_SEL_NTSC 0x2
1101#define AUD_DSP_WR_AV_SYNC_AV_STD_SEL_MONOCHROME 0x3
1102
1103#define AUD_DSP_RD_STATUS2__A 0x104007B
1104#define AUD_DSP_RD_STATUS2__W 16
1105#define AUD_DSP_RD_STATUS2__M 0xFFFF
1106#define AUD_DSP_RD_STATUS2__PRE 0x0
1107
1108#define AUD_DSP_RD_STATUS2_AV_ACTIVE__B 15
1109#define AUD_DSP_RD_STATUS2_AV_ACTIVE__W 1
1110#define AUD_DSP_RD_STATUS2_AV_ACTIVE__M 0x8000
1111#define AUD_DSP_RD_STATUS2_AV_ACTIVE__PRE 0x0
1112#define AUD_DSP_RD_STATUS2_AV_ACTIVE_NO_SYNC 0x0
1113#define AUD_DSP_RD_STATUS2_AV_ACTIVE_SYNC_ACTIVE 0x8000
1114
1115#define AUD_DSP_RD_XDFP_FW__A 0x104001D
1116#define AUD_DSP_RD_XDFP_FW__W 16
1117#define AUD_DSP_RD_XDFP_FW__M 0xFFFF
1118#define AUD_DSP_RD_XDFP_FW__PRE 0x344
1119
1120#define AUD_DSP_RD_XDFP_FW_DSP_FW_REV__B 0
1121#define AUD_DSP_RD_XDFP_FW_DSP_FW_REV__W 16
1122#define AUD_DSP_RD_XDFP_FW_DSP_FW_REV__M 0xFFFF
1123#define AUD_DSP_RD_XDFP_FW_DSP_FW_REV__PRE 0x344
1124
1125#define AUD_DSP_RD_XFP_FW__A 0x10404B8
1126#define AUD_DSP_RD_XFP_FW__W 16
1127#define AUD_DSP_RD_XFP_FW__M 0xFFFF
1128#define AUD_DSP_RD_XFP_FW__PRE 0x42
1129
1130#define AUD_DSP_RD_XFP_FW_FP_FW_REV__B 0
1131#define AUD_DSP_RD_XFP_FW_FP_FW_REV__W 16
1132#define AUD_DSP_RD_XFP_FW_FP_FW_REV__M 0xFFFF
1133#define AUD_DSP_RD_XFP_FW_FP_FW_REV__PRE 0x42
1134
1135#define AUD_DEM_WR_DCO_B_HI__A 0x103009B
1136#define AUD_DEM_WR_DCO_B_HI__W 16
1137#define AUD_DEM_WR_DCO_B_HI__M 0xFFFF
1138#define AUD_DEM_WR_DCO_B_HI__PRE 0x0
1139
1140#define AUD_DEM_WR_DCO_B_LO__A 0x1030093
1141#define AUD_DEM_WR_DCO_B_LO__W 16
1142#define AUD_DEM_WR_DCO_B_LO__M 0xFFFF
1143#define AUD_DEM_WR_DCO_B_LO__PRE 0x0
1144
1145#define AUD_DEM_WR_DCO_A_HI__A 0x10300AB
1146#define AUD_DEM_WR_DCO_A_HI__W 16
1147#define AUD_DEM_WR_DCO_A_HI__M 0xFFFF
1148#define AUD_DEM_WR_DCO_A_HI__PRE 0x0
1149
1150#define AUD_DEM_WR_DCO_A_LO__A 0x10300A3
1151#define AUD_DEM_WR_DCO_A_LO__W 16
1152#define AUD_DEM_WR_DCO_A_LO__M 0xFFFF
1153#define AUD_DEM_WR_DCO_A_LO__PRE 0x0
1154#define AUD_DEM_WR_NICAM_THRSHLD__A 0x1030021
1155#define AUD_DEM_WR_NICAM_THRSHLD__W 16
1156#define AUD_DEM_WR_NICAM_THRSHLD__M 0xFFFF
1157#define AUD_DEM_WR_NICAM_THRSHLD__PRE 0x2BC
1158
1159#define AUD_DEM_WR_NICAM_THRSHLD_NICAM_THLD__B 0
1160#define AUD_DEM_WR_NICAM_THRSHLD_NICAM_THLD__W 12
1161#define AUD_DEM_WR_NICAM_THRSHLD_NICAM_THLD__M 0xFFF
1162#define AUD_DEM_WR_NICAM_THRSHLD_NICAM_THLD__PRE 0x2BC
1163
1164#define AUD_DEM_WR_A2_THRSHLD__A 0x1030022
1165#define AUD_DEM_WR_A2_THRSHLD__W 16
1166#define AUD_DEM_WR_A2_THRSHLD__M 0xFFFF
1167#define AUD_DEM_WR_A2_THRSHLD__PRE 0x190
1168
1169#define AUD_DEM_WR_A2_THRSHLD_A2_THLD__B 0
1170#define AUD_DEM_WR_A2_THRSHLD_A2_THLD__W 12
1171#define AUD_DEM_WR_A2_THRSHLD_A2_THLD__M 0xFFF
1172#define AUD_DEM_WR_A2_THRSHLD_A2_THLD__PRE 0x190
1173
1174#define AUD_DEM_WR_BTSC_THRSHLD__A 0x1030023
1175#define AUD_DEM_WR_BTSC_THRSHLD__W 16
1176#define AUD_DEM_WR_BTSC_THRSHLD__M 0xFFFF
1177#define AUD_DEM_WR_BTSC_THRSHLD__PRE 0xC
1178
1179#define AUD_DEM_WR_BTSC_THRSHLD_BTSC_THLD__B 0
1180#define AUD_DEM_WR_BTSC_THRSHLD_BTSC_THLD__W 12
1181#define AUD_DEM_WR_BTSC_THRSHLD_BTSC_THLD__M 0xFFF
1182#define AUD_DEM_WR_BTSC_THRSHLD_BTSC_THLD__PRE 0xC
1183
1184#define AUD_DEM_WR_CM_A_THRSHLD__A 0x1030024
1185#define AUD_DEM_WR_CM_A_THRSHLD__W 16
1186#define AUD_DEM_WR_CM_A_THRSHLD__M 0xFFFF
1187#define AUD_DEM_WR_CM_A_THRSHLD__PRE 0x2A
1188
1189#define AUD_DEM_WR_CM_A_THRSHLD_CM_A_THLD__B 0
1190#define AUD_DEM_WR_CM_A_THRSHLD_CM_A_THLD__W 12
1191#define AUD_DEM_WR_CM_A_THRSHLD_CM_A_THLD__M 0xFFF
1192#define AUD_DEM_WR_CM_A_THRSHLD_CM_A_THLD__PRE 0x2A
1193
1194#define AUD_DEM_WR_CM_B_THRSHLD__A 0x1030025
1195#define AUD_DEM_WR_CM_B_THRSHLD__W 16
1196#define AUD_DEM_WR_CM_B_THRSHLD__M 0xFFFF
1197#define AUD_DEM_WR_CM_B_THRSHLD__PRE 0x2A
1198
1199#define AUD_DEM_WR_CM_B_THRSHLD_CM_B_THLD__B 0
1200#define AUD_DEM_WR_CM_B_THRSHLD_CM_B_THLD__W 12
1201#define AUD_DEM_WR_CM_B_THRSHLD_CM_B_THLD__M 0xFFF
1202#define AUD_DEM_WR_CM_B_THRSHLD_CM_B_THLD__PRE 0x2A
1203
1204#define AUD_DEM_RD_NIC_C_AD_BITS__A 0x1020023
1205#define AUD_DEM_RD_NIC_C_AD_BITS__W 16
1206#define AUD_DEM_RD_NIC_C_AD_BITS__M 0xFFFF
1207#define AUD_DEM_RD_NIC_C_AD_BITS__PRE 0x0
1208
1209#define AUD_DEM_RD_NIC_C_AD_BITS_NICAM_SYNC__B 0
1210#define AUD_DEM_RD_NIC_C_AD_BITS_NICAM_SYNC__W 1
1211#define AUD_DEM_RD_NIC_C_AD_BITS_NICAM_SYNC__M 0x1
1212#define AUD_DEM_RD_NIC_C_AD_BITS_NICAM_SYNC__PRE 0x0
1213#define AUD_DEM_RD_NIC_C_AD_BITS_NICAM_SYNC_NOT_SYNCED 0x0
1214#define AUD_DEM_RD_NIC_C_AD_BITS_NICAM_SYNC_SYNCED 0x1
1215
1216#define AUD_DEM_RD_NIC_C_AD_BITS_C__B 1
1217#define AUD_DEM_RD_NIC_C_AD_BITS_C__W 4
1218#define AUD_DEM_RD_NIC_C_AD_BITS_C__M 0x1E
1219#define AUD_DEM_RD_NIC_C_AD_BITS_C__PRE 0x0
1220
1221#define AUD_DEM_RD_NIC_C_AD_BITS_ADD_BIT_LO__B 5
1222#define AUD_DEM_RD_NIC_C_AD_BITS_ADD_BIT_LO__W 3
1223#define AUD_DEM_RD_NIC_C_AD_BITS_ADD_BIT_LO__M 0xE0
1224#define AUD_DEM_RD_NIC_C_AD_BITS_ADD_BIT_LO__PRE 0x0
1225
1226#define AUD_DEM_RD_NIC_ADD_BITS_HI__A 0x1020038
1227#define AUD_DEM_RD_NIC_ADD_BITS_HI__W 16
1228#define AUD_DEM_RD_NIC_ADD_BITS_HI__M 0xFFFF
1229#define AUD_DEM_RD_NIC_ADD_BITS_HI__PRE 0x0
1230
1231#define AUD_DEM_RD_NIC_ADD_BITS_HI_ADD_BIT_HI__B 0
1232#define AUD_DEM_RD_NIC_ADD_BITS_HI_ADD_BIT_HI__W 8
1233#define AUD_DEM_RD_NIC_ADD_BITS_HI_ADD_BIT_HI__M 0xFF
1234#define AUD_DEM_RD_NIC_ADD_BITS_HI_ADD_BIT_HI__PRE 0x0
1235
1236#define AUD_DEM_RD_NIC_CIB__A 0x1020038
1237#define AUD_DEM_RD_NIC_CIB__W 16
1238#define AUD_DEM_RD_NIC_CIB__M 0xFFFF
1239#define AUD_DEM_RD_NIC_CIB__PRE 0x0
1240
1241#define AUD_DEM_RD_NIC_CIB_CIB2__B 0
1242#define AUD_DEM_RD_NIC_CIB_CIB2__W 1
1243#define AUD_DEM_RD_NIC_CIB_CIB2__M 0x1
1244#define AUD_DEM_RD_NIC_CIB_CIB2__PRE 0x0
1245
1246#define AUD_DEM_RD_NIC_CIB_CIB1__B 1
1247#define AUD_DEM_RD_NIC_CIB_CIB1__W 1
1248#define AUD_DEM_RD_NIC_CIB_CIB1__M 0x2
1249#define AUD_DEM_RD_NIC_CIB_CIB1__PRE 0x0
1250
1251#define AUD_DEM_RD_NIC_ERROR_RATE__A 0x1020057
1252#define AUD_DEM_RD_NIC_ERROR_RATE__W 16
1253#define AUD_DEM_RD_NIC_ERROR_RATE__M 0xFFFF
1254#define AUD_DEM_RD_NIC_ERROR_RATE__PRE 0x0
1255
1256#define AUD_DEM_RD_NIC_ERROR_RATE_ERROR_RATE__B 0
1257#define AUD_DEM_RD_NIC_ERROR_RATE_ERROR_RATE__W 12
1258#define AUD_DEM_RD_NIC_ERROR_RATE_ERROR_RATE__M 0xFFF
1259#define AUD_DEM_RD_NIC_ERROR_RATE_ERROR_RATE__PRE 0x0
1260
1261#define AUD_DEM_WR_FM_DEEMPH__A 0x103000F
1262#define AUD_DEM_WR_FM_DEEMPH__W 16
1263#define AUD_DEM_WR_FM_DEEMPH__M 0xFFFF
1264#define AUD_DEM_WR_FM_DEEMPH__PRE 0x0
1265#define AUD_DEM_WR_FM_DEEMPH_50US 0x0
1266#define AUD_DEM_WR_FM_DEEMPH_75US 0x1
1267#define AUD_DEM_WR_FM_DEEMPH_OFF 0x3F
1268
1269#define AUD_DEM_WR_FM_MATRIX__A 0x103006F
1270#define AUD_DEM_WR_FM_MATRIX__W 16
1271#define AUD_DEM_WR_FM_MATRIX__M 0xFFFF
1272#define AUD_DEM_WR_FM_MATRIX__PRE 0x0
1273#define AUD_DEM_WR_FM_MATRIX_NO_MATRIX 0x0
1274#define AUD_DEM_WR_FM_MATRIX_GERMAN_MATRIX 0x1
1275#define AUD_DEM_WR_FM_MATRIX_KOREAN_MATRIX 0x2
1276#define AUD_DEM_WR_FM_MATRIX_SOUND_A 0x3
1277#define AUD_DEM_WR_FM_MATRIX_SOUND_B 0x4
1278
1279#define AUD_DSP_RD_FM_IDENT_VALUE__A 0x1040018
1280#define AUD_DSP_RD_FM_IDENT_VALUE__W 16
1281#define AUD_DSP_RD_FM_IDENT_VALUE__M 0xFFFF
1282#define AUD_DSP_RD_FM_IDENT_VALUE__PRE 0x0
1283
1284#define AUD_DSP_RD_FM_IDENT_VALUE_FM_IDENT__B 8
1285#define AUD_DSP_RD_FM_IDENT_VALUE_FM_IDENT__W 8
1286#define AUD_DSP_RD_FM_IDENT_VALUE_FM_IDENT__M 0xFF00
1287#define AUD_DSP_RD_FM_IDENT_VALUE_FM_IDENT__PRE 0x0
1288
1289#define AUD_DSP_RD_FM_DC_LEVEL_A__A 0x104001B
1290#define AUD_DSP_RD_FM_DC_LEVEL_A__W 16
1291#define AUD_DSP_RD_FM_DC_LEVEL_A__M 0xFFFF
1292#define AUD_DSP_RD_FM_DC_LEVEL_A__PRE 0x0
1293
1294#define AUD_DSP_RD_FM_DC_LEVEL_A_FM_DC_LEV_A__B 0
1295#define AUD_DSP_RD_FM_DC_LEVEL_A_FM_DC_LEV_A__W 16
1296#define AUD_DSP_RD_FM_DC_LEVEL_A_FM_DC_LEV_A__M 0xFFFF
1297#define AUD_DSP_RD_FM_DC_LEVEL_A_FM_DC_LEV_A__PRE 0x0
1298
1299#define AUD_DSP_RD_FM_DC_LEVEL_B__A 0x104001C
1300#define AUD_DSP_RD_FM_DC_LEVEL_B__W 16
1301#define AUD_DSP_RD_FM_DC_LEVEL_B__M 0xFFFF
1302#define AUD_DSP_RD_FM_DC_LEVEL_B__PRE 0x0
1303
1304#define AUD_DSP_RD_FM_DC_LEVEL_B_FM_DC_LEV_B__B 0
1305#define AUD_DSP_RD_FM_DC_LEVEL_B_FM_DC_LEV_B__W 16
1306#define AUD_DSP_RD_FM_DC_LEVEL_B_FM_DC_LEV_B__M 0xFFFF
1307#define AUD_DSP_RD_FM_DC_LEVEL_B_FM_DC_LEV_B__PRE 0x0
1308
1309#define AUD_DEM_WR_FM_DC_NOTCH_SW__A 0x1030017
1310#define AUD_DEM_WR_FM_DC_NOTCH_SW__W 16
1311#define AUD_DEM_WR_FM_DC_NOTCH_SW__M 0xFFFF
1312#define AUD_DEM_WR_FM_DC_NOTCH_SW__PRE 0x0
1313
1314#define AUD_DEM_WR_FM_DC_NOTCH_SW_FM_DC_NO_SW__B 0
1315#define AUD_DEM_WR_FM_DC_NOTCH_SW_FM_DC_NO_SW__W 16
1316#define AUD_DEM_WR_FM_DC_NOTCH_SW_FM_DC_NO_SW__M 0xFFFF
1317#define AUD_DEM_WR_FM_DC_NOTCH_SW_FM_DC_NO_SW__PRE 0x0
1318#define AUD_DEM_WR_FM_DC_NOTCH_SW_FM_DC_NO_SW_ON 0x0
1319#define AUD_DEM_WR_FM_DC_NOTCH_SW_FM_DC_NO_SW_OFF 0x3F
1320
1321#define AUD_DSP_WR_SYNC_OUT__A 0x1050026
1322#define AUD_DSP_WR_SYNC_OUT__W 16
1323#define AUD_DSP_WR_SYNC_OUT__M 0xFFFF
1324#define AUD_DSP_WR_SYNC_OUT__PRE 0x0
1325#define AUD_DSP_WR_SYNC_OUT_OFF 0x0
1326#define AUD_DSP_WR_SYNC_OUT_SYNCHRONOUS 0x1
1327
1328#define AUD_XFP_DRAM_1K__A 0x1060000
1329#define AUD_XFP_DRAM_1K__W 16
1330#define AUD_XFP_DRAM_1K__M 0xFFFF
1331#define AUD_XFP_DRAM_1K__PRE 0x0
1332#define AUD_XFP_DRAM_1K_D__B 0
1333#define AUD_XFP_DRAM_1K_D__W 16
1334#define AUD_XFP_DRAM_1K_D__M 0xFFFF
1335#define AUD_XFP_DRAM_1K_D__PRE 0x0
1336
1337#define AUD_XFP_PRAM_4K__A 0x1070000
1338#define AUD_XFP_PRAM_4K__W 16
1339#define AUD_XFP_PRAM_4K__M 0xFFFF
1340#define AUD_XFP_PRAM_4K__PRE 0x0
1341#define AUD_XFP_PRAM_4K_D__B 0
1342#define AUD_XFP_PRAM_4K_D__W 16
1343#define AUD_XFP_PRAM_4K_D__M 0xFFFF
1344#define AUD_XFP_PRAM_4K_D__PRE 0x0
1345
1346#define AUD_XDFP_DRAM_1K__A 0x1080000
1347#define AUD_XDFP_DRAM_1K__W 16
1348#define AUD_XDFP_DRAM_1K__M 0xFFFF
1349#define AUD_XDFP_DRAM_1K__PRE 0x0
1350#define AUD_XDFP_DRAM_1K_D__B 0
1351#define AUD_XDFP_DRAM_1K_D__W 16
1352#define AUD_XDFP_DRAM_1K_D__M 0xFFFF
1353#define AUD_XDFP_DRAM_1K_D__PRE 0x0
1354
1355#define AUD_XDFP_PRAM_4K__A 0x1090000
1356#define AUD_XDFP_PRAM_4K__W 16
1357#define AUD_XDFP_PRAM_4K__M 0xFFFF
1358#define AUD_XDFP_PRAM_4K__PRE 0x0
1359#define AUD_XDFP_PRAM_4K_D__B 0
1360#define AUD_XDFP_PRAM_4K_D__W 16
1361#define AUD_XDFP_PRAM_4K_D__M 0xFFFF
1362#define AUD_XDFP_PRAM_4K_D__PRE 0x0
1363
1364#define FEC_COMM_EXEC__A 0x2400000
1365#define FEC_COMM_EXEC__W 2
1366#define FEC_COMM_EXEC__M 0x3
1367#define FEC_COMM_EXEC__PRE 0x0
1368#define FEC_COMM_EXEC_STOP 0x0
1369#define FEC_COMM_EXEC_ACTIVE 0x1
1370#define FEC_COMM_EXEC_HOLD 0x2
1371
1372#define FEC_COMM_MB__A 0x2400002
1373#define FEC_COMM_MB__W 16
1374#define FEC_COMM_MB__M 0xFFFF
1375#define FEC_COMM_MB__PRE 0x0
1376#define FEC_COMM_INT_REQ__A 0x2400003
1377#define FEC_COMM_INT_REQ__W 16
1378#define FEC_COMM_INT_REQ__M 0xFFFF
1379#define FEC_COMM_INT_REQ__PRE 0x0
1380#define FEC_COMM_INT_REQ_OC_REQ__B 0
1381#define FEC_COMM_INT_REQ_OC_REQ__W 1
1382#define FEC_COMM_INT_REQ_OC_REQ__M 0x1
1383#define FEC_COMM_INT_REQ_OC_REQ__PRE 0x0
1384#define FEC_COMM_INT_REQ_RS_REQ__B 1
1385#define FEC_COMM_INT_REQ_RS_REQ__W 1
1386#define FEC_COMM_INT_REQ_RS_REQ__M 0x2
1387#define FEC_COMM_INT_REQ_RS_REQ__PRE 0x0
1388#define FEC_COMM_INT_REQ_DI_REQ__B 2
1389#define FEC_COMM_INT_REQ_DI_REQ__W 1
1390#define FEC_COMM_INT_REQ_DI_REQ__M 0x4
1391#define FEC_COMM_INT_REQ_DI_REQ__PRE 0x0
1392
1393#define FEC_COMM_INT_STA__A 0x2400005
1394#define FEC_COMM_INT_STA__W 16
1395#define FEC_COMM_INT_STA__M 0xFFFF
1396#define FEC_COMM_INT_STA__PRE 0x0
1397#define FEC_COMM_INT_MSK__A 0x2400006
1398#define FEC_COMM_INT_MSK__W 16
1399#define FEC_COMM_INT_MSK__M 0xFFFF
1400#define FEC_COMM_INT_MSK__PRE 0x0
1401#define FEC_COMM_INT_STM__A 0x2400007
1402#define FEC_COMM_INT_STM__W 16
1403#define FEC_COMM_INT_STM__M 0xFFFF
1404#define FEC_COMM_INT_STM__PRE 0x0
1405
1406#define FEC_TOP_COMM_EXEC__A 0x2410000
1407#define FEC_TOP_COMM_EXEC__W 2
1408#define FEC_TOP_COMM_EXEC__M 0x3
1409#define FEC_TOP_COMM_EXEC__PRE 0x0
1410#define FEC_TOP_COMM_EXEC_STOP 0x0
1411#define FEC_TOP_COMM_EXEC_ACTIVE 0x1
1412#define FEC_TOP_COMM_EXEC_HOLD 0x2
1413
1414#define FEC_TOP_ANNEX__A 0x2410010
1415#define FEC_TOP_ANNEX__W 2
1416#define FEC_TOP_ANNEX__M 0x3
1417#define FEC_TOP_ANNEX__PRE 0x0
1418#define FEC_TOP_ANNEX_A 0x0
1419#define FEC_TOP_ANNEX_B 0x1
1420#define FEC_TOP_ANNEX_C 0x2
1421#define FEC_TOP_ANNEX_D 0x3
1422
1423#define FEC_DI_COMM_EXEC__A 0x2420000
1424#define FEC_DI_COMM_EXEC__W 2
1425#define FEC_DI_COMM_EXEC__M 0x3
1426#define FEC_DI_COMM_EXEC__PRE 0x0
1427#define FEC_DI_COMM_EXEC_STOP 0x0
1428#define FEC_DI_COMM_EXEC_ACTIVE 0x1
1429#define FEC_DI_COMM_EXEC_HOLD 0x2
1430
1431#define FEC_DI_COMM_MB__A 0x2420002
1432#define FEC_DI_COMM_MB__W 2
1433#define FEC_DI_COMM_MB__M 0x3
1434#define FEC_DI_COMM_MB__PRE 0x0
1435#define FEC_DI_COMM_MB_CTL__B 0
1436#define FEC_DI_COMM_MB_CTL__W 1
1437#define FEC_DI_COMM_MB_CTL__M 0x1
1438#define FEC_DI_COMM_MB_CTL__PRE 0x0
1439#define FEC_DI_COMM_MB_CTL_OFF 0x0
1440#define FEC_DI_COMM_MB_CTL_ON 0x1
1441#define FEC_DI_COMM_MB_OBS__B 1
1442#define FEC_DI_COMM_MB_OBS__W 1
1443#define FEC_DI_COMM_MB_OBS__M 0x2
1444#define FEC_DI_COMM_MB_OBS__PRE 0x0
1445#define FEC_DI_COMM_MB_OBS_OFF 0x0
1446#define FEC_DI_COMM_MB_OBS_ON 0x2
1447
1448#define FEC_DI_COMM_INT_REQ__A 0x2420003
1449#define FEC_DI_COMM_INT_REQ__W 1
1450#define FEC_DI_COMM_INT_REQ__M 0x1
1451#define FEC_DI_COMM_INT_REQ__PRE 0x0
1452#define FEC_DI_COMM_INT_STA__A 0x2420005
1453#define FEC_DI_COMM_INT_STA__W 2
1454#define FEC_DI_COMM_INT_STA__M 0x3
1455#define FEC_DI_COMM_INT_STA__PRE 0x0
1456
1457#define FEC_DI_COMM_INT_STA_STAT_INT__B 0
1458#define FEC_DI_COMM_INT_STA_STAT_INT__W 1
1459#define FEC_DI_COMM_INT_STA_STAT_INT__M 0x1
1460#define FEC_DI_COMM_INT_STA_STAT_INT__PRE 0x0
1461
1462#define FEC_DI_COMM_INT_STA_TIMEOUT_INT__B 1
1463#define FEC_DI_COMM_INT_STA_TIMEOUT_INT__W 1
1464#define FEC_DI_COMM_INT_STA_TIMEOUT_INT__M 0x2
1465#define FEC_DI_COMM_INT_STA_TIMEOUT_INT__PRE 0x0
1466
1467#define FEC_DI_COMM_INT_MSK__A 0x2420006
1468#define FEC_DI_COMM_INT_MSK__W 2
1469#define FEC_DI_COMM_INT_MSK__M 0x3
1470#define FEC_DI_COMM_INT_MSK__PRE 0x0
1471#define FEC_DI_COMM_INT_MSK_STAT_INT__B 0
1472#define FEC_DI_COMM_INT_MSK_STAT_INT__W 1
1473#define FEC_DI_COMM_INT_MSK_STAT_INT__M 0x1
1474#define FEC_DI_COMM_INT_MSK_STAT_INT__PRE 0x0
1475#define FEC_DI_COMM_INT_MSK_TIMEOUT_INT__B 1
1476#define FEC_DI_COMM_INT_MSK_TIMEOUT_INT__W 1
1477#define FEC_DI_COMM_INT_MSK_TIMEOUT_INT__M 0x2
1478#define FEC_DI_COMM_INT_MSK_TIMEOUT_INT__PRE 0x0
1479
1480#define FEC_DI_COMM_INT_STM__A 0x2420007
1481#define FEC_DI_COMM_INT_STM__W 2
1482#define FEC_DI_COMM_INT_STM__M 0x3
1483#define FEC_DI_COMM_INT_STM__PRE 0x0
1484#define FEC_DI_COMM_INT_STM_STAT_INT__B 0
1485#define FEC_DI_COMM_INT_STM_STAT_INT__W 1
1486#define FEC_DI_COMM_INT_STM_STAT_INT__M 0x1
1487#define FEC_DI_COMM_INT_STM_STAT_INT__PRE 0x0
1488#define FEC_DI_COMM_INT_STM_TIMEOUT_INT__B 1
1489#define FEC_DI_COMM_INT_STM_TIMEOUT_INT__W 1
1490#define FEC_DI_COMM_INT_STM_TIMEOUT_INT__M 0x2
1491#define FEC_DI_COMM_INT_STM_TIMEOUT_INT__PRE 0x0
1492
1493#define FEC_DI_STATUS__A 0x2420010
1494#define FEC_DI_STATUS__W 1
1495#define FEC_DI_STATUS__M 0x1
1496#define FEC_DI_STATUS__PRE 0x0
1497#define FEC_DI_MODE__A 0x2420011
1498#define FEC_DI_MODE__W 3
1499#define FEC_DI_MODE__M 0x7
1500#define FEC_DI_MODE__PRE 0x0
1501
1502#define FEC_DI_MODE_NO_SYNC__B 0
1503#define FEC_DI_MODE_NO_SYNC__W 1
1504#define FEC_DI_MODE_NO_SYNC__M 0x1
1505#define FEC_DI_MODE_NO_SYNC__PRE 0x0
1506
1507#define FEC_DI_MODE_IGNORE_LOST_SYNC__B 1
1508#define FEC_DI_MODE_IGNORE_LOST_SYNC__W 1
1509#define FEC_DI_MODE_IGNORE_LOST_SYNC__M 0x2
1510#define FEC_DI_MODE_IGNORE_LOST_SYNC__PRE 0x0
1511
1512#define FEC_DI_MODE_IGNORE_TIMEOUT__B 2
1513#define FEC_DI_MODE_IGNORE_TIMEOUT__W 1
1514#define FEC_DI_MODE_IGNORE_TIMEOUT__M 0x4
1515#define FEC_DI_MODE_IGNORE_TIMEOUT__PRE 0x0
1516
1517#define FEC_DI_CONTROL_WORD__A 0x2420012
1518#define FEC_DI_CONTROL_WORD__W 4
1519#define FEC_DI_CONTROL_WORD__M 0xF
1520#define FEC_DI_CONTROL_WORD__PRE 0x0
1521
1522#define FEC_DI_RESTART__A 0x2420013
1523#define FEC_DI_RESTART__W 1
1524#define FEC_DI_RESTART__M 0x1
1525#define FEC_DI_RESTART__PRE 0x0
1526
1527#define FEC_DI_TIMEOUT_LO__A 0x2420014
1528#define FEC_DI_TIMEOUT_LO__W 16
1529#define FEC_DI_TIMEOUT_LO__M 0xFFFF
1530#define FEC_DI_TIMEOUT_LO__PRE 0x0
1531
1532#define FEC_DI_TIMEOUT_HI__A 0x2420015
1533#define FEC_DI_TIMEOUT_HI__W 8
1534#define FEC_DI_TIMEOUT_HI__M 0xFF
1535#define FEC_DI_TIMEOUT_HI__PRE 0xA
1536
1537#define FEC_RS_COMM_EXEC__A 0x2430000
1538#define FEC_RS_COMM_EXEC__W 2
1539#define FEC_RS_COMM_EXEC__M 0x3
1540#define FEC_RS_COMM_EXEC__PRE 0x0
1541#define FEC_RS_COMM_EXEC_STOP 0x0
1542#define FEC_RS_COMM_EXEC_ACTIVE 0x1
1543#define FEC_RS_COMM_EXEC_HOLD 0x2
1544
1545#define FEC_RS_COMM_MB__A 0x2430002
1546#define FEC_RS_COMM_MB__W 2
1547#define FEC_RS_COMM_MB__M 0x3
1548#define FEC_RS_COMM_MB__PRE 0x0
1549#define FEC_RS_COMM_MB_CTL__B 0
1550#define FEC_RS_COMM_MB_CTL__W 1
1551#define FEC_RS_COMM_MB_CTL__M 0x1
1552#define FEC_RS_COMM_MB_CTL__PRE 0x0
1553#define FEC_RS_COMM_MB_CTL_OFF 0x0
1554#define FEC_RS_COMM_MB_CTL_ON 0x1
1555#define FEC_RS_COMM_MB_OBS__B 1
1556#define FEC_RS_COMM_MB_OBS__W 1
1557#define FEC_RS_COMM_MB_OBS__M 0x2
1558#define FEC_RS_COMM_MB_OBS__PRE 0x0
1559#define FEC_RS_COMM_MB_OBS_OFF 0x0
1560#define FEC_RS_COMM_MB_OBS_ON 0x2
1561
1562#define FEC_RS_COMM_INT_REQ__A 0x2430003
1563#define FEC_RS_COMM_INT_REQ__W 1
1564#define FEC_RS_COMM_INT_REQ__M 0x1
1565#define FEC_RS_COMM_INT_REQ__PRE 0x0
1566#define FEC_RS_COMM_INT_STA__A 0x2430005
1567#define FEC_RS_COMM_INT_STA__W 2
1568#define FEC_RS_COMM_INT_STA__M 0x3
1569#define FEC_RS_COMM_INT_STA__PRE 0x0
1570
1571#define FEC_RS_COMM_INT_STA_FAILURE_INT__B 0
1572#define FEC_RS_COMM_INT_STA_FAILURE_INT__W 1
1573#define FEC_RS_COMM_INT_STA_FAILURE_INT__M 0x1
1574#define FEC_RS_COMM_INT_STA_FAILURE_INT__PRE 0x0
1575
1576#define FEC_RS_COMM_INT_STA_MEASUREMENT_INT__B 1
1577#define FEC_RS_COMM_INT_STA_MEASUREMENT_INT__W 1
1578#define FEC_RS_COMM_INT_STA_MEASUREMENT_INT__M 0x2
1579#define FEC_RS_COMM_INT_STA_MEASUREMENT_INT__PRE 0x0
1580
1581#define FEC_RS_COMM_INT_MSK__A 0x2430006
1582#define FEC_RS_COMM_INT_MSK__W 2
1583#define FEC_RS_COMM_INT_MSK__M 0x3
1584#define FEC_RS_COMM_INT_MSK__PRE 0x0
1585#define FEC_RS_COMM_INT_MSK_FAILURE_MSK__B 0
1586#define FEC_RS_COMM_INT_MSK_FAILURE_MSK__W 1
1587#define FEC_RS_COMM_INT_MSK_FAILURE_MSK__M 0x1
1588#define FEC_RS_COMM_INT_MSK_FAILURE_MSK__PRE 0x0
1589#define FEC_RS_COMM_INT_MSK_MEASUREMENT_MSK__B 1
1590#define FEC_RS_COMM_INT_MSK_MEASUREMENT_MSK__W 1
1591#define FEC_RS_COMM_INT_MSK_MEASUREMENT_MSK__M 0x2
1592#define FEC_RS_COMM_INT_MSK_MEASUREMENT_MSK__PRE 0x0
1593
1594#define FEC_RS_COMM_INT_STM__A 0x2430007
1595#define FEC_RS_COMM_INT_STM__W 2
1596#define FEC_RS_COMM_INT_STM__M 0x3
1597#define FEC_RS_COMM_INT_STM__PRE 0x0
1598#define FEC_RS_COMM_INT_STM_FAILURE_MSK__B 0
1599#define FEC_RS_COMM_INT_STM_FAILURE_MSK__W 1
1600#define FEC_RS_COMM_INT_STM_FAILURE_MSK__M 0x1
1601#define FEC_RS_COMM_INT_STM_FAILURE_MSK__PRE 0x0
1602#define FEC_RS_COMM_INT_STM_MEASUREMENT_MSK__B 1
1603#define FEC_RS_COMM_INT_STM_MEASUREMENT_MSK__W 1
1604#define FEC_RS_COMM_INT_STM_MEASUREMENT_MSK__M 0x2
1605#define FEC_RS_COMM_INT_STM_MEASUREMENT_MSK__PRE 0x0
1606
1607#define FEC_RS_STATUS__A 0x2430010
1608#define FEC_RS_STATUS__W 1
1609#define FEC_RS_STATUS__M 0x1
1610#define FEC_RS_STATUS__PRE 0x0
1611#define FEC_RS_MODE__A 0x2430011
1612#define FEC_RS_MODE__W 1
1613#define FEC_RS_MODE__M 0x1
1614#define FEC_RS_MODE__PRE 0x0
1615
1616#define FEC_RS_MODE_BYPASS__B 0
1617#define FEC_RS_MODE_BYPASS__W 1
1618#define FEC_RS_MODE_BYPASS__M 0x1
1619#define FEC_RS_MODE_BYPASS__PRE 0x0
1620
1621#define FEC_RS_MEASUREMENT_PERIOD__A 0x2430012
1622#define FEC_RS_MEASUREMENT_PERIOD__W 16
1623#define FEC_RS_MEASUREMENT_PERIOD__M 0xFFFF
1624#define FEC_RS_MEASUREMENT_PERIOD__PRE 0x1171
1625
1626#define FEC_RS_MEASUREMENT_PERIOD_PERIOD__B 0
1627#define FEC_RS_MEASUREMENT_PERIOD_PERIOD__W 16
1628#define FEC_RS_MEASUREMENT_PERIOD_PERIOD__M 0xFFFF
1629#define FEC_RS_MEASUREMENT_PERIOD_PERIOD__PRE 0x1171
1630
1631#define FEC_RS_MEASUREMENT_PRESCALE__A 0x2430013
1632#define FEC_RS_MEASUREMENT_PRESCALE__W 16
1633#define FEC_RS_MEASUREMENT_PRESCALE__M 0xFFFF
1634#define FEC_RS_MEASUREMENT_PRESCALE__PRE 0x1
1635
1636#define FEC_RS_MEASUREMENT_PRESCALE_PRESCALE__B 0
1637#define FEC_RS_MEASUREMENT_PRESCALE_PRESCALE__W 16
1638#define FEC_RS_MEASUREMENT_PRESCALE_PRESCALE__M 0xFFFF
1639#define FEC_RS_MEASUREMENT_PRESCALE_PRESCALE__PRE 0x1
1640
1641#define FEC_RS_NR_BIT_ERRORS__A 0x2430014
1642#define FEC_RS_NR_BIT_ERRORS__W 16
1643#define FEC_RS_NR_BIT_ERRORS__M 0xFFFF
1644#define FEC_RS_NR_BIT_ERRORS__PRE 0xFFFF
1645
1646#define FEC_RS_NR_BIT_ERRORS_FIXED_MANT__B 0
1647#define FEC_RS_NR_BIT_ERRORS_FIXED_MANT__W 12
1648#define FEC_RS_NR_BIT_ERRORS_FIXED_MANT__M 0xFFF
1649#define FEC_RS_NR_BIT_ERRORS_FIXED_MANT__PRE 0xFFF
1650
1651#define FEC_RS_NR_BIT_ERRORS_EXP__B 12
1652#define FEC_RS_NR_BIT_ERRORS_EXP__W 4
1653#define FEC_RS_NR_BIT_ERRORS_EXP__M 0xF000
1654#define FEC_RS_NR_BIT_ERRORS_EXP__PRE 0xF000
1655
1656#define FEC_RS_NR_SYMBOL_ERRORS__A 0x2430015
1657#define FEC_RS_NR_SYMBOL_ERRORS__W 16
1658#define FEC_RS_NR_SYMBOL_ERRORS__M 0xFFFF
1659#define FEC_RS_NR_SYMBOL_ERRORS__PRE 0xFFFF
1660
1661#define FEC_RS_NR_SYMBOL_ERRORS_FIXED_MANT__B 0
1662#define FEC_RS_NR_SYMBOL_ERRORS_FIXED_MANT__W 12
1663#define FEC_RS_NR_SYMBOL_ERRORS_FIXED_MANT__M 0xFFF
1664#define FEC_RS_NR_SYMBOL_ERRORS_FIXED_MANT__PRE 0xFFF
1665
1666#define FEC_RS_NR_SYMBOL_ERRORS_EXP__B 12
1667#define FEC_RS_NR_SYMBOL_ERRORS_EXP__W 4
1668#define FEC_RS_NR_SYMBOL_ERRORS_EXP__M 0xF000
1669#define FEC_RS_NR_SYMBOL_ERRORS_EXP__PRE 0xF000
1670
1671#define FEC_RS_NR_PACKET_ERRORS__A 0x2430016
1672#define FEC_RS_NR_PACKET_ERRORS__W 16
1673#define FEC_RS_NR_PACKET_ERRORS__M 0xFFFF
1674#define FEC_RS_NR_PACKET_ERRORS__PRE 0xFFFF
1675
1676#define FEC_RS_NR_PACKET_ERRORS_FIXED_MANT__B 0
1677#define FEC_RS_NR_PACKET_ERRORS_FIXED_MANT__W 12
1678#define FEC_RS_NR_PACKET_ERRORS_FIXED_MANT__M 0xFFF
1679#define FEC_RS_NR_PACKET_ERRORS_FIXED_MANT__PRE 0xFFF
1680
1681#define FEC_RS_NR_PACKET_ERRORS_EXP__B 12
1682#define FEC_RS_NR_PACKET_ERRORS_EXP__W 4
1683#define FEC_RS_NR_PACKET_ERRORS_EXP__M 0xF000
1684#define FEC_RS_NR_PACKET_ERRORS_EXP__PRE 0xF000
1685
1686#define FEC_RS_NR_FAILURES__A 0x2430017
1687#define FEC_RS_NR_FAILURES__W 16
1688#define FEC_RS_NR_FAILURES__M 0xFFFF
1689#define FEC_RS_NR_FAILURES__PRE 0x0
1690
1691#define FEC_RS_NR_FAILURES_FIXED_MANT__B 0
1692#define FEC_RS_NR_FAILURES_FIXED_MANT__W 12
1693#define FEC_RS_NR_FAILURES_FIXED_MANT__M 0xFFF
1694#define FEC_RS_NR_FAILURES_FIXED_MANT__PRE 0x0
1695
1696#define FEC_RS_NR_FAILURES_EXP__B 12
1697#define FEC_RS_NR_FAILURES_EXP__W 4
1698#define FEC_RS_NR_FAILURES_EXP__M 0xF000
1699#define FEC_RS_NR_FAILURES_EXP__PRE 0x0
1700
1701#define FEC_OC_COMM_EXEC__A 0x2440000
1702#define FEC_OC_COMM_EXEC__W 2
1703#define FEC_OC_COMM_EXEC__M 0x3
1704#define FEC_OC_COMM_EXEC__PRE 0x0
1705#define FEC_OC_COMM_EXEC_STOP 0x0
1706#define FEC_OC_COMM_EXEC_ACTIVE 0x1
1707#define FEC_OC_COMM_EXEC_HOLD 0x2
1708
1709#define FEC_OC_COMM_MB__A 0x2440002
1710#define FEC_OC_COMM_MB__W 2
1711#define FEC_OC_COMM_MB__M 0x3
1712#define FEC_OC_COMM_MB__PRE 0x0
1713#define FEC_OC_COMM_MB_CTL__B 0
1714#define FEC_OC_COMM_MB_CTL__W 1
1715#define FEC_OC_COMM_MB_CTL__M 0x1
1716#define FEC_OC_COMM_MB_CTL__PRE 0x0
1717#define FEC_OC_COMM_MB_CTL_OFF 0x0
1718#define FEC_OC_COMM_MB_CTL_ON 0x1
1719#define FEC_OC_COMM_MB_OBS__B 1
1720#define FEC_OC_COMM_MB_OBS__W 1
1721#define FEC_OC_COMM_MB_OBS__M 0x2
1722#define FEC_OC_COMM_MB_OBS__PRE 0x0
1723#define FEC_OC_COMM_MB_OBS_OFF 0x0
1724#define FEC_OC_COMM_MB_OBS_ON 0x2
1725
1726#define FEC_OC_COMM_INT_REQ__A 0x2440003
1727#define FEC_OC_COMM_INT_REQ__W 1
1728#define FEC_OC_COMM_INT_REQ__M 0x1
1729#define FEC_OC_COMM_INT_REQ__PRE 0x0
1730#define FEC_OC_COMM_INT_STA__A 0x2440005
1731#define FEC_OC_COMM_INT_STA__W 8
1732#define FEC_OC_COMM_INT_STA__M 0xFF
1733#define FEC_OC_COMM_INT_STA__PRE 0x0
1734
1735#define FEC_OC_COMM_INT_STA_DPR_LOCK_INT__B 0
1736#define FEC_OC_COMM_INT_STA_DPR_LOCK_INT__W 1
1737#define FEC_OC_COMM_INT_STA_DPR_LOCK_INT__M 0x1
1738#define FEC_OC_COMM_INT_STA_DPR_LOCK_INT__PRE 0x0
1739
1740#define FEC_OC_COMM_INT_STA_SNC_LOCK_INT__B 1
1741#define FEC_OC_COMM_INT_STA_SNC_LOCK_INT__W 1
1742#define FEC_OC_COMM_INT_STA_SNC_LOCK_INT__M 0x2
1743#define FEC_OC_COMM_INT_STA_SNC_LOCK_INT__PRE 0x0
1744
1745#define FEC_OC_COMM_INT_STA_SNC_LOST_INT__B 2
1746#define FEC_OC_COMM_INT_STA_SNC_LOST_INT__W 1
1747#define FEC_OC_COMM_INT_STA_SNC_LOST_INT__M 0x4
1748#define FEC_OC_COMM_INT_STA_SNC_LOST_INT__PRE 0x0
1749
1750#define FEC_OC_COMM_INT_STA_SNC_PAR_INT__B 3
1751#define FEC_OC_COMM_INT_STA_SNC_PAR_INT__W 1
1752#define FEC_OC_COMM_INT_STA_SNC_PAR_INT__M 0x8
1753#define FEC_OC_COMM_INT_STA_SNC_PAR_INT__PRE 0x0
1754
1755#define FEC_OC_COMM_INT_STA_FIFO_FULL_INT__B 4
1756#define FEC_OC_COMM_INT_STA_FIFO_FULL_INT__W 1
1757#define FEC_OC_COMM_INT_STA_FIFO_FULL_INT__M 0x10
1758#define FEC_OC_COMM_INT_STA_FIFO_FULL_INT__PRE 0x0
1759
1760#define FEC_OC_COMM_INT_STA_FIFO_EMPTY_INT__B 5
1761#define FEC_OC_COMM_INT_STA_FIFO_EMPTY_INT__W 1
1762#define FEC_OC_COMM_INT_STA_FIFO_EMPTY_INT__M 0x20
1763#define FEC_OC_COMM_INT_STA_FIFO_EMPTY_INT__PRE 0x0
1764
1765#define FEC_OC_COMM_INT_STA_OCR_ACQ_INT__B 6
1766#define FEC_OC_COMM_INT_STA_OCR_ACQ_INT__W 1
1767#define FEC_OC_COMM_INT_STA_OCR_ACQ_INT__M 0x40
1768#define FEC_OC_COMM_INT_STA_OCR_ACQ_INT__PRE 0x0
1769
1770#define FEC_OC_COMM_INT_STA_STAT_CHG_INT__B 7
1771#define FEC_OC_COMM_INT_STA_STAT_CHG_INT__W 1
1772#define FEC_OC_COMM_INT_STA_STAT_CHG_INT__M 0x80
1773#define FEC_OC_COMM_INT_STA_STAT_CHG_INT__PRE 0x0
1774
1775#define FEC_OC_COMM_INT_MSK__A 0x2440006
1776#define FEC_OC_COMM_INT_MSK__W 8
1777#define FEC_OC_COMM_INT_MSK__M 0xFF
1778#define FEC_OC_COMM_INT_MSK__PRE 0x0
1779#define FEC_OC_COMM_INT_MSK_DPR_LOCK_MSK__B 0
1780#define FEC_OC_COMM_INT_MSK_DPR_LOCK_MSK__W 1
1781#define FEC_OC_COMM_INT_MSK_DPR_LOCK_MSK__M 0x1
1782#define FEC_OC_COMM_INT_MSK_DPR_LOCK_MSK__PRE 0x0
1783#define FEC_OC_COMM_INT_MSK_SNC_LOCK_MSK__B 1
1784#define FEC_OC_COMM_INT_MSK_SNC_LOCK_MSK__W 1
1785#define FEC_OC_COMM_INT_MSK_SNC_LOCK_MSK__M 0x2
1786#define FEC_OC_COMM_INT_MSK_SNC_LOCK_MSK__PRE 0x0
1787#define FEC_OC_COMM_INT_MSK_SNC_LOST_MSK__B 2
1788#define FEC_OC_COMM_INT_MSK_SNC_LOST_MSK__W 1
1789#define FEC_OC_COMM_INT_MSK_SNC_LOST_MSK__M 0x4
1790#define FEC_OC_COMM_INT_MSK_SNC_LOST_MSK__PRE 0x0
1791#define FEC_OC_COMM_INT_MSK_SNC_PAR_MSK__B 3
1792#define FEC_OC_COMM_INT_MSK_SNC_PAR_MSK__W 1
1793#define FEC_OC_COMM_INT_MSK_SNC_PAR_MSK__M 0x8
1794#define FEC_OC_COMM_INT_MSK_SNC_PAR_MSK__PRE 0x0
1795#define FEC_OC_COMM_INT_MSK_FIFO_FULL_MSK__B 4
1796#define FEC_OC_COMM_INT_MSK_FIFO_FULL_MSK__W 1
1797#define FEC_OC_COMM_INT_MSK_FIFO_FULL_MSK__M 0x10
1798#define FEC_OC_COMM_INT_MSK_FIFO_FULL_MSK__PRE 0x0
1799#define FEC_OC_COMM_INT_MSK_FIFO_EMPTY_MSK__B 5
1800#define FEC_OC_COMM_INT_MSK_FIFO_EMPTY_MSK__W 1
1801#define FEC_OC_COMM_INT_MSK_FIFO_EMPTY_MSK__M 0x20
1802#define FEC_OC_COMM_INT_MSK_FIFO_EMPTY_MSK__PRE 0x0
1803#define FEC_OC_COMM_INT_MSK_OCR_ACQ_MSK__B 6
1804#define FEC_OC_COMM_INT_MSK_OCR_ACQ_MSK__W 1
1805#define FEC_OC_COMM_INT_MSK_OCR_ACQ_MSK__M 0x40
1806#define FEC_OC_COMM_INT_MSK_OCR_ACQ_MSK__PRE 0x0
1807#define FEC_OC_COMM_INT_MSK_STAT_CHG_MSK__B 7
1808#define FEC_OC_COMM_INT_MSK_STAT_CHG_MSK__W 1
1809#define FEC_OC_COMM_INT_MSK_STAT_CHG_MSK__M 0x80
1810#define FEC_OC_COMM_INT_MSK_STAT_CHG_MSK__PRE 0x0
1811
1812#define FEC_OC_COMM_INT_STM__A 0x2440007
1813#define FEC_OC_COMM_INT_STM__W 8
1814#define FEC_OC_COMM_INT_STM__M 0xFF
1815#define FEC_OC_COMM_INT_STM__PRE 0x0
1816#define FEC_OC_COMM_INT_STM_DPR_LOCK_MSK__B 0
1817#define FEC_OC_COMM_INT_STM_DPR_LOCK_MSK__W 1
1818#define FEC_OC_COMM_INT_STM_DPR_LOCK_MSK__M 0x1
1819#define FEC_OC_COMM_INT_STM_DPR_LOCK_MSK__PRE 0x0
1820#define FEC_OC_COMM_INT_STM_SNC_LOCK_MSK__B 1
1821#define FEC_OC_COMM_INT_STM_SNC_LOCK_MSK__W 1
1822#define FEC_OC_COMM_INT_STM_SNC_LOCK_MSK__M 0x2
1823#define FEC_OC_COMM_INT_STM_SNC_LOCK_MSK__PRE 0x0
1824#define FEC_OC_COMM_INT_STM_SNC_LOST_MSK__B 2
1825#define FEC_OC_COMM_INT_STM_SNC_LOST_MSK__W 1
1826#define FEC_OC_COMM_INT_STM_SNC_LOST_MSK__M 0x4
1827#define FEC_OC_COMM_INT_STM_SNC_LOST_MSK__PRE 0x0
1828#define FEC_OC_COMM_INT_STM_SNC_PAR_MSK__B 3
1829#define FEC_OC_COMM_INT_STM_SNC_PAR_MSK__W 1
1830#define FEC_OC_COMM_INT_STM_SNC_PAR_MSK__M 0x8
1831#define FEC_OC_COMM_INT_STM_SNC_PAR_MSK__PRE 0x0
1832#define FEC_OC_COMM_INT_STM_FIFO_FULL_MSK__B 4
1833#define FEC_OC_COMM_INT_STM_FIFO_FULL_MSK__W 1
1834#define FEC_OC_COMM_INT_STM_FIFO_FULL_MSK__M 0x10
1835#define FEC_OC_COMM_INT_STM_FIFO_FULL_MSK__PRE 0x0
1836#define FEC_OC_COMM_INT_STM_FIFO_EMPTY_MSK__B 5
1837#define FEC_OC_COMM_INT_STM_FIFO_EMPTY_MSK__W 1
1838#define FEC_OC_COMM_INT_STM_FIFO_EMPTY_MSK__M 0x20
1839#define FEC_OC_COMM_INT_STM_FIFO_EMPTY_MSK__PRE 0x0
1840#define FEC_OC_COMM_INT_STM_OCR_ACQ_MSK__B 6
1841#define FEC_OC_COMM_INT_STM_OCR_ACQ_MSK__W 1
1842#define FEC_OC_COMM_INT_STM_OCR_ACQ_MSK__M 0x40
1843#define FEC_OC_COMM_INT_STM_OCR_ACQ_MSK__PRE 0x0
1844#define FEC_OC_COMM_INT_STM_STAT_CHG_MSK__B 7
1845#define FEC_OC_COMM_INT_STM_STAT_CHG_MSK__W 1
1846#define FEC_OC_COMM_INT_STM_STAT_CHG_MSK__M 0x80
1847#define FEC_OC_COMM_INT_STM_STAT_CHG_MSK__PRE 0x0
1848
1849#define FEC_OC_STATUS__A 0x2440010
1850#define FEC_OC_STATUS__W 5
1851#define FEC_OC_STATUS__M 0x1F
1852#define FEC_OC_STATUS__PRE 0x0
1853
1854#define FEC_OC_STATUS_DPR_STATUS__B 0
1855#define FEC_OC_STATUS_DPR_STATUS__W 1
1856#define FEC_OC_STATUS_DPR_STATUS__M 0x1
1857#define FEC_OC_STATUS_DPR_STATUS__PRE 0x0
1858
1859#define FEC_OC_STATUS_SNC_STATUS__B 1
1860#define FEC_OC_STATUS_SNC_STATUS__W 2
1861#define FEC_OC_STATUS_SNC_STATUS__M 0x6
1862#define FEC_OC_STATUS_SNC_STATUS__PRE 0x0
1863
1864#define FEC_OC_STATUS_FIFO_FULL__B 3
1865#define FEC_OC_STATUS_FIFO_FULL__W 1
1866#define FEC_OC_STATUS_FIFO_FULL__M 0x8
1867#define FEC_OC_STATUS_FIFO_FULL__PRE 0x0
1868
1869#define FEC_OC_STATUS_FIFO_EMPTY__B 4
1870#define FEC_OC_STATUS_FIFO_EMPTY__W 1
1871#define FEC_OC_STATUS_FIFO_EMPTY__M 0x10
1872#define FEC_OC_STATUS_FIFO_EMPTY__PRE 0x0
1873
1874#define FEC_OC_MODE__A 0x2440011
1875#define FEC_OC_MODE__W 4
1876#define FEC_OC_MODE__M 0xF
1877#define FEC_OC_MODE__PRE 0x0
1878
1879#define FEC_OC_MODE_PARITY__B 0
1880#define FEC_OC_MODE_PARITY__W 1
1881#define FEC_OC_MODE_PARITY__M 0x1
1882#define FEC_OC_MODE_PARITY__PRE 0x0
1883
1884#define FEC_OC_MODE_TRANSPARENT__B 1
1885#define FEC_OC_MODE_TRANSPARENT__W 1
1886#define FEC_OC_MODE_TRANSPARENT__M 0x2
1887#define FEC_OC_MODE_TRANSPARENT__PRE 0x0
1888
1889#define FEC_OC_MODE_CLEAR__B 2
1890#define FEC_OC_MODE_CLEAR__W 1
1891#define FEC_OC_MODE_CLEAR__M 0x4
1892#define FEC_OC_MODE_CLEAR__PRE 0x0
1893
1894#define FEC_OC_MODE_RETAIN_FRAMING__B 3
1895#define FEC_OC_MODE_RETAIN_FRAMING__W 1
1896#define FEC_OC_MODE_RETAIN_FRAMING__M 0x8
1897#define FEC_OC_MODE_RETAIN_FRAMING__PRE 0x0
1898
1899#define FEC_OC_DPR_MODE__A 0x2440012
1900#define FEC_OC_DPR_MODE__W 2
1901#define FEC_OC_DPR_MODE__M 0x3
1902#define FEC_OC_DPR_MODE__PRE 0x0
1903
1904#define FEC_OC_DPR_MODE_ERR_DISABLE__B 0
1905#define FEC_OC_DPR_MODE_ERR_DISABLE__W 1
1906#define FEC_OC_DPR_MODE_ERR_DISABLE__M 0x1
1907#define FEC_OC_DPR_MODE_ERR_DISABLE__PRE 0x0
1908
1909#define FEC_OC_DPR_MODE_NOSYNC_ENABLE__B 1
1910#define FEC_OC_DPR_MODE_NOSYNC_ENABLE__W 1
1911#define FEC_OC_DPR_MODE_NOSYNC_ENABLE__M 0x2
1912#define FEC_OC_DPR_MODE_NOSYNC_ENABLE__PRE 0x0
1913
1914#define FEC_OC_DPR_UNLOCK__A 0x2440013
1915#define FEC_OC_DPR_UNLOCK__W 1
1916#define FEC_OC_DPR_UNLOCK__M 0x1
1917#define FEC_OC_DPR_UNLOCK__PRE 0x0
1918#define FEC_OC_DTO_MODE__A 0x2440014
1919#define FEC_OC_DTO_MODE__W 3
1920#define FEC_OC_DTO_MODE__M 0x7
1921#define FEC_OC_DTO_MODE__PRE 0x0
1922
1923#define FEC_OC_DTO_MODE_DYNAMIC__B 0
1924#define FEC_OC_DTO_MODE_DYNAMIC__W 1
1925#define FEC_OC_DTO_MODE_DYNAMIC__M 0x1
1926#define FEC_OC_DTO_MODE_DYNAMIC__PRE 0x0
1927
1928#define FEC_OC_DTO_MODE_DUTY_CYCLE__B 1
1929#define FEC_OC_DTO_MODE_DUTY_CYCLE__W 1
1930#define FEC_OC_DTO_MODE_DUTY_CYCLE__M 0x2
1931#define FEC_OC_DTO_MODE_DUTY_CYCLE__PRE 0x0
1932
1933#define FEC_OC_DTO_MODE_OFFSET_ENABLE__B 2
1934#define FEC_OC_DTO_MODE_OFFSET_ENABLE__W 1
1935#define FEC_OC_DTO_MODE_OFFSET_ENABLE__M 0x4
1936#define FEC_OC_DTO_MODE_OFFSET_ENABLE__PRE 0x0
1937
1938#define FEC_OC_DTO_PERIOD__A 0x2440015
1939#define FEC_OC_DTO_PERIOD__W 8
1940#define FEC_OC_DTO_PERIOD__M 0xFF
1941#define FEC_OC_DTO_PERIOD__PRE 0x0
1942#define FEC_OC_DTO_RATE_LO__A 0x2440016
1943#define FEC_OC_DTO_RATE_LO__W 16
1944#define FEC_OC_DTO_RATE_LO__M 0xFFFF
1945#define FEC_OC_DTO_RATE_LO__PRE 0x0
1946
1947#define FEC_OC_DTO_RATE_LO_RATE_LO__B 0
1948#define FEC_OC_DTO_RATE_LO_RATE_LO__W 16
1949#define FEC_OC_DTO_RATE_LO_RATE_LO__M 0xFFFF
1950#define FEC_OC_DTO_RATE_LO_RATE_LO__PRE 0x0
1951
1952#define FEC_OC_DTO_RATE_HI__A 0x2440017
1953#define FEC_OC_DTO_RATE_HI__W 10
1954#define FEC_OC_DTO_RATE_HI__M 0x3FF
1955#define FEC_OC_DTO_RATE_HI__PRE 0xC0
1956
1957#define FEC_OC_DTO_RATE_HI_RATE_HI__B 0
1958#define FEC_OC_DTO_RATE_HI_RATE_HI__W 10
1959#define FEC_OC_DTO_RATE_HI_RATE_HI__M 0x3FF
1960#define FEC_OC_DTO_RATE_HI_RATE_HI__PRE 0xC0
1961
1962#define FEC_OC_DTO_BURST_LEN__A 0x2440018
1963#define FEC_OC_DTO_BURST_LEN__W 8
1964#define FEC_OC_DTO_BURST_LEN__M 0xFF
1965#define FEC_OC_DTO_BURST_LEN__PRE 0xBC
1966
1967#define FEC_OC_DTO_BURST_LEN_BURST_LEN__B 0
1968#define FEC_OC_DTO_BURST_LEN_BURST_LEN__W 8
1969#define FEC_OC_DTO_BURST_LEN_BURST_LEN__M 0xFF
1970#define FEC_OC_DTO_BURST_LEN_BURST_LEN__PRE 0xBC
1971
1972#define FEC_OC_FCT_MODE__A 0x244001A
1973#define FEC_OC_FCT_MODE__W 2
1974#define FEC_OC_FCT_MODE__M 0x3
1975#define FEC_OC_FCT_MODE__PRE 0x0
1976
1977#define FEC_OC_FCT_MODE_RAT_ENA__B 0
1978#define FEC_OC_FCT_MODE_RAT_ENA__W 1
1979#define FEC_OC_FCT_MODE_RAT_ENA__M 0x1
1980#define FEC_OC_FCT_MODE_RAT_ENA__PRE 0x0
1981
1982#define FEC_OC_FCT_MODE_VIRT_ENA__B 1
1983#define FEC_OC_FCT_MODE_VIRT_ENA__W 1
1984#define FEC_OC_FCT_MODE_VIRT_ENA__M 0x2
1985#define FEC_OC_FCT_MODE_VIRT_ENA__PRE 0x0
1986
1987#define FEC_OC_FCT_USAGE__A 0x244001B
1988#define FEC_OC_FCT_USAGE__W 3
1989#define FEC_OC_FCT_USAGE__M 0x7
1990#define FEC_OC_FCT_USAGE__PRE 0x2
1991
1992#define FEC_OC_FCT_USAGE_USAGE__B 0
1993#define FEC_OC_FCT_USAGE_USAGE__W 3
1994#define FEC_OC_FCT_USAGE_USAGE__M 0x7
1995#define FEC_OC_FCT_USAGE_USAGE__PRE 0x2
1996
1997#define FEC_OC_FCT_OCCUPATION__A 0x244001C
1998#define FEC_OC_FCT_OCCUPATION__W 12
1999#define FEC_OC_FCT_OCCUPATION__M 0xFFF
2000#define FEC_OC_FCT_OCCUPATION__PRE 0x0
2001
2002#define FEC_OC_FCT_OCCUPATION_OCCUPATION__B 0
2003#define FEC_OC_FCT_OCCUPATION_OCCUPATION__W 12
2004#define FEC_OC_FCT_OCCUPATION_OCCUPATION__M 0xFFF
2005#define FEC_OC_FCT_OCCUPATION_OCCUPATION__PRE 0x0
2006
2007#define FEC_OC_TMD_MODE__A 0x244001E
2008#define FEC_OC_TMD_MODE__W 3
2009#define FEC_OC_TMD_MODE__M 0x7
2010#define FEC_OC_TMD_MODE__PRE 0x4
2011
2012#define FEC_OC_TMD_MODE_MODE__B 0
2013#define FEC_OC_TMD_MODE_MODE__W 3
2014#define FEC_OC_TMD_MODE_MODE__M 0x7
2015#define FEC_OC_TMD_MODE_MODE__PRE 0x4
2016
2017#define FEC_OC_TMD_COUNT__A 0x244001F
2018#define FEC_OC_TMD_COUNT__W 10
2019#define FEC_OC_TMD_COUNT__M 0x3FF
2020#define FEC_OC_TMD_COUNT__PRE 0x1F4
2021
2022#define FEC_OC_TMD_COUNT_COUNT__B 0
2023#define FEC_OC_TMD_COUNT_COUNT__W 10
2024#define FEC_OC_TMD_COUNT_COUNT__M 0x3FF
2025#define FEC_OC_TMD_COUNT_COUNT__PRE 0x1F4
2026
2027#define FEC_OC_TMD_HI_MARGIN__A 0x2440020
2028#define FEC_OC_TMD_HI_MARGIN__W 11
2029#define FEC_OC_TMD_HI_MARGIN__M 0x7FF
2030#define FEC_OC_TMD_HI_MARGIN__PRE 0x200
2031
2032#define FEC_OC_TMD_HI_MARGIN_HI_MARGIN__B 0
2033#define FEC_OC_TMD_HI_MARGIN_HI_MARGIN__W 11
2034#define FEC_OC_TMD_HI_MARGIN_HI_MARGIN__M 0x7FF
2035#define FEC_OC_TMD_HI_MARGIN_HI_MARGIN__PRE 0x200
2036
2037#define FEC_OC_TMD_LO_MARGIN__A 0x2440021
2038#define FEC_OC_TMD_LO_MARGIN__W 11
2039#define FEC_OC_TMD_LO_MARGIN__M 0x7FF
2040#define FEC_OC_TMD_LO_MARGIN__PRE 0x100
2041
2042#define FEC_OC_TMD_LO_MARGIN_LO_MARGIN__B 0
2043#define FEC_OC_TMD_LO_MARGIN_LO_MARGIN__W 11
2044#define FEC_OC_TMD_LO_MARGIN_LO_MARGIN__M 0x7FF
2045#define FEC_OC_TMD_LO_MARGIN_LO_MARGIN__PRE 0x100
2046
2047#define FEC_OC_TMD_CTL_UPD_RATE__A 0x2440022
2048#define FEC_OC_TMD_CTL_UPD_RATE__W 4
2049#define FEC_OC_TMD_CTL_UPD_RATE__M 0xF
2050#define FEC_OC_TMD_CTL_UPD_RATE__PRE 0x1
2051
2052#define FEC_OC_TMD_CTL_UPD_RATE_RATE__B 0
2053#define FEC_OC_TMD_CTL_UPD_RATE_RATE__W 4
2054#define FEC_OC_TMD_CTL_UPD_RATE_RATE__M 0xF
2055#define FEC_OC_TMD_CTL_UPD_RATE_RATE__PRE 0x1
2056
2057#define FEC_OC_TMD_INT_UPD_RATE__A 0x2440023
2058#define FEC_OC_TMD_INT_UPD_RATE__W 4
2059#define FEC_OC_TMD_INT_UPD_RATE__M 0xF
2060#define FEC_OC_TMD_INT_UPD_RATE__PRE 0x4
2061
2062#define FEC_OC_TMD_INT_UPD_RATE_RATE__B 0
2063#define FEC_OC_TMD_INT_UPD_RATE_RATE__W 4
2064#define FEC_OC_TMD_INT_UPD_RATE_RATE__M 0xF
2065#define FEC_OC_TMD_INT_UPD_RATE_RATE__PRE 0x4
2066
2067#define FEC_OC_AVR_PARM_A__A 0x2440026
2068#define FEC_OC_AVR_PARM_A__W 4
2069#define FEC_OC_AVR_PARM_A__M 0xF
2070#define FEC_OC_AVR_PARM_A__PRE 0x6
2071
2072#define FEC_OC_AVR_PARM_A_PARM__B 0
2073#define FEC_OC_AVR_PARM_A_PARM__W 4
2074#define FEC_OC_AVR_PARM_A_PARM__M 0xF
2075#define FEC_OC_AVR_PARM_A_PARM__PRE 0x6
2076
2077#define FEC_OC_AVR_PARM_B__A 0x2440027
2078#define FEC_OC_AVR_PARM_B__W 4
2079#define FEC_OC_AVR_PARM_B__M 0xF
2080#define FEC_OC_AVR_PARM_B__PRE 0x4
2081
2082#define FEC_OC_AVR_PARM_B_PARM__B 0
2083#define FEC_OC_AVR_PARM_B_PARM__W 4
2084#define FEC_OC_AVR_PARM_B_PARM__M 0xF
2085#define FEC_OC_AVR_PARM_B_PARM__PRE 0x4
2086
2087#define FEC_OC_AVR_AVG_LO__A 0x2440028
2088#define FEC_OC_AVR_AVG_LO__W 16
2089#define FEC_OC_AVR_AVG_LO__M 0xFFFF
2090#define FEC_OC_AVR_AVG_LO__PRE 0x0
2091
2092#define FEC_OC_AVR_AVG_LO_AVG_LO__B 0
2093#define FEC_OC_AVR_AVG_LO_AVG_LO__W 16
2094#define FEC_OC_AVR_AVG_LO_AVG_LO__M 0xFFFF
2095#define FEC_OC_AVR_AVG_LO_AVG_LO__PRE 0x0
2096
2097#define FEC_OC_AVR_AVG_HI__A 0x2440029
2098#define FEC_OC_AVR_AVG_HI__W 6
2099#define FEC_OC_AVR_AVG_HI__M 0x3F
2100#define FEC_OC_AVR_AVG_HI__PRE 0x0
2101
2102#define FEC_OC_AVR_AVG_HI_AVG_HI__B 0
2103#define FEC_OC_AVR_AVG_HI_AVG_HI__W 6
2104#define FEC_OC_AVR_AVG_HI_AVG_HI__M 0x3F
2105#define FEC_OC_AVR_AVG_HI_AVG_HI__PRE 0x0
2106
2107#define FEC_OC_RCN_MODE__A 0x244002C
2108#define FEC_OC_RCN_MODE__W 5
2109#define FEC_OC_RCN_MODE__M 0x1F
2110#define FEC_OC_RCN_MODE__PRE 0x1F
2111
2112#define FEC_OC_RCN_MODE_MODE__B 0
2113#define FEC_OC_RCN_MODE_MODE__W 5
2114#define FEC_OC_RCN_MODE_MODE__M 0x1F
2115#define FEC_OC_RCN_MODE_MODE__PRE 0x1F
2116
2117#define FEC_OC_RCN_OCC_SETTLE__A 0x244002D
2118#define FEC_OC_RCN_OCC_SETTLE__W 11
2119#define FEC_OC_RCN_OCC_SETTLE__M 0x7FF
2120#define FEC_OC_RCN_OCC_SETTLE__PRE 0x180
2121
2122#define FEC_OC_RCN_OCC_SETTLE_LEVEL__B 0
2123#define FEC_OC_RCN_OCC_SETTLE_LEVEL__W 11
2124#define FEC_OC_RCN_OCC_SETTLE_LEVEL__M 0x7FF
2125#define FEC_OC_RCN_OCC_SETTLE_LEVEL__PRE 0x180
2126
2127#define FEC_OC_RCN_GAIN__A 0x244002E
2128#define FEC_OC_RCN_GAIN__W 4
2129#define FEC_OC_RCN_GAIN__M 0xF
2130#define FEC_OC_RCN_GAIN__PRE 0xC
2131
2132#define FEC_OC_RCN_GAIN_GAIN__B 0
2133#define FEC_OC_RCN_GAIN_GAIN__W 4
2134#define FEC_OC_RCN_GAIN_GAIN__M 0xF
2135#define FEC_OC_RCN_GAIN_GAIN__PRE 0xC
2136
2137#define FEC_OC_RCN_CTL_RATE_LO__A 0x2440030
2138#define FEC_OC_RCN_CTL_RATE_LO__W 16
2139#define FEC_OC_RCN_CTL_RATE_LO__M 0xFFFF
2140#define FEC_OC_RCN_CTL_RATE_LO__PRE 0x0
2141
2142#define FEC_OC_RCN_CTL_RATE_LO_CTL_LO__B 0
2143#define FEC_OC_RCN_CTL_RATE_LO_CTL_LO__W 16
2144#define FEC_OC_RCN_CTL_RATE_LO_CTL_LO__M 0xFFFF
2145#define FEC_OC_RCN_CTL_RATE_LO_CTL_LO__PRE 0x0
2146
2147#define FEC_OC_RCN_CTL_RATE_HI__A 0x2440031
2148#define FEC_OC_RCN_CTL_RATE_HI__W 8
2149#define FEC_OC_RCN_CTL_RATE_HI__M 0xFF
2150#define FEC_OC_RCN_CTL_RATE_HI__PRE 0xC0
2151
2152#define FEC_OC_RCN_CTL_RATE_HI_CTL_HI__B 0
2153#define FEC_OC_RCN_CTL_RATE_HI_CTL_HI__W 8
2154#define FEC_OC_RCN_CTL_RATE_HI_CTL_HI__M 0xFF
2155#define FEC_OC_RCN_CTL_RATE_HI_CTL_HI__PRE 0xC0
2156
2157#define FEC_OC_RCN_CTL_STEP_LO__A 0x2440032
2158#define FEC_OC_RCN_CTL_STEP_LO__W 16
2159#define FEC_OC_RCN_CTL_STEP_LO__M 0xFFFF
2160#define FEC_OC_RCN_CTL_STEP_LO__PRE 0x0
2161
2162#define FEC_OC_RCN_CTL_STEP_LO_CTL_LO__B 0
2163#define FEC_OC_RCN_CTL_STEP_LO_CTL_LO__W 16
2164#define FEC_OC_RCN_CTL_STEP_LO_CTL_LO__M 0xFFFF
2165#define FEC_OC_RCN_CTL_STEP_LO_CTL_LO__PRE 0x0
2166
2167#define FEC_OC_RCN_CTL_STEP_HI__A 0x2440033
2168#define FEC_OC_RCN_CTL_STEP_HI__W 8
2169#define FEC_OC_RCN_CTL_STEP_HI__M 0xFF
2170#define FEC_OC_RCN_CTL_STEP_HI__PRE 0x8
2171
2172#define FEC_OC_RCN_CTL_STEP_HI_CTL_HI__B 0
2173#define FEC_OC_RCN_CTL_STEP_HI_CTL_HI__W 8
2174#define FEC_OC_RCN_CTL_STEP_HI_CTL_HI__M 0xFF
2175#define FEC_OC_RCN_CTL_STEP_HI_CTL_HI__PRE 0x8
2176
2177#define FEC_OC_RCN_DTO_OFS_LO__A 0x2440034
2178#define FEC_OC_RCN_DTO_OFS_LO__W 16
2179#define FEC_OC_RCN_DTO_OFS_LO__M 0xFFFF
2180#define FEC_OC_RCN_DTO_OFS_LO__PRE 0x0
2181
2182#define FEC_OC_RCN_DTO_OFS_LO_OFS_LO__B 0
2183#define FEC_OC_RCN_DTO_OFS_LO_OFS_LO__W 16
2184#define FEC_OC_RCN_DTO_OFS_LO_OFS_LO__M 0xFFFF
2185#define FEC_OC_RCN_DTO_OFS_LO_OFS_LO__PRE 0x0
2186
2187#define FEC_OC_RCN_DTO_OFS_HI__A 0x2440035
2188#define FEC_OC_RCN_DTO_OFS_HI__W 8
2189#define FEC_OC_RCN_DTO_OFS_HI__M 0xFF
2190#define FEC_OC_RCN_DTO_OFS_HI__PRE 0x0
2191
2192#define FEC_OC_RCN_DTO_OFS_HI_OFS_HI__B 0
2193#define FEC_OC_RCN_DTO_OFS_HI_OFS_HI__W 8
2194#define FEC_OC_RCN_DTO_OFS_HI_OFS_HI__M 0xFF
2195#define FEC_OC_RCN_DTO_OFS_HI_OFS_HI__PRE 0x0
2196
2197#define FEC_OC_RCN_DTO_RATE_LO__A 0x2440036
2198#define FEC_OC_RCN_DTO_RATE_LO__W 16
2199#define FEC_OC_RCN_DTO_RATE_LO__M 0xFFFF
2200#define FEC_OC_RCN_DTO_RATE_LO__PRE 0x0
2201
2202#define FEC_OC_RCN_DTO_RATE_LO_OFS_LO__B 0
2203#define FEC_OC_RCN_DTO_RATE_LO_OFS_LO__W 16
2204#define FEC_OC_RCN_DTO_RATE_LO_OFS_LO__M 0xFFFF
2205#define FEC_OC_RCN_DTO_RATE_LO_OFS_LO__PRE 0x0
2206
2207#define FEC_OC_RCN_DTO_RATE_HI__A 0x2440037
2208#define FEC_OC_RCN_DTO_RATE_HI__W 8
2209#define FEC_OC_RCN_DTO_RATE_HI__M 0xFF
2210#define FEC_OC_RCN_DTO_RATE_HI__PRE 0x0
2211
2212#define FEC_OC_RCN_DTO_RATE_HI_OFS_HI__B 0
2213#define FEC_OC_RCN_DTO_RATE_HI_OFS_HI__W 8
2214#define FEC_OC_RCN_DTO_RATE_HI_OFS_HI__M 0xFF
2215#define FEC_OC_RCN_DTO_RATE_HI_OFS_HI__PRE 0x0
2216
2217#define FEC_OC_RCN_RATE_CLIP_LO__A 0x2440038
2218#define FEC_OC_RCN_RATE_CLIP_LO__W 16
2219#define FEC_OC_RCN_RATE_CLIP_LO__M 0xFFFF
2220#define FEC_OC_RCN_RATE_CLIP_LO__PRE 0x0
2221
2222#define FEC_OC_RCN_RATE_CLIP_LO_CLIP_LO__B 0
2223#define FEC_OC_RCN_RATE_CLIP_LO_CLIP_LO__W 16
2224#define FEC_OC_RCN_RATE_CLIP_LO_CLIP_LO__M 0xFFFF
2225#define FEC_OC_RCN_RATE_CLIP_LO_CLIP_LO__PRE 0x0
2226
2227#define FEC_OC_RCN_RATE_CLIP_HI__A 0x2440039
2228#define FEC_OC_RCN_RATE_CLIP_HI__W 8
2229#define FEC_OC_RCN_RATE_CLIP_HI__M 0xFF
2230#define FEC_OC_RCN_RATE_CLIP_HI__PRE 0xF0
2231
2232#define FEC_OC_RCN_RATE_CLIP_HI_CLIP_HI__B 0
2233#define FEC_OC_RCN_RATE_CLIP_HI_CLIP_HI__W 8
2234#define FEC_OC_RCN_RATE_CLIP_HI_CLIP_HI__M 0xFF
2235#define FEC_OC_RCN_RATE_CLIP_HI_CLIP_HI__PRE 0xF0
2236
2237#define FEC_OC_RCN_DYN_RATE_LO__A 0x244003A
2238#define FEC_OC_RCN_DYN_RATE_LO__W 16
2239#define FEC_OC_RCN_DYN_RATE_LO__M 0xFFFF
2240#define FEC_OC_RCN_DYN_RATE_LO__PRE 0x0
2241
2242#define FEC_OC_RCN_DYN_RATE_LO_RATE_LO__B 0
2243#define FEC_OC_RCN_DYN_RATE_LO_RATE_LO__W 16
2244#define FEC_OC_RCN_DYN_RATE_LO_RATE_LO__M 0xFFFF
2245#define FEC_OC_RCN_DYN_RATE_LO_RATE_LO__PRE 0x0
2246
2247#define FEC_OC_RCN_DYN_RATE_HI__A 0x244003B
2248#define FEC_OC_RCN_DYN_RATE_HI__W 8
2249#define FEC_OC_RCN_DYN_RATE_HI__M 0xFF
2250#define FEC_OC_RCN_DYN_RATE_HI__PRE 0x0
2251
2252#define FEC_OC_RCN_DYN_RATE_HI_RATE_HI__B 0
2253#define FEC_OC_RCN_DYN_RATE_HI_RATE_HI__W 8
2254#define FEC_OC_RCN_DYN_RATE_HI_RATE_HI__M 0xFF
2255#define FEC_OC_RCN_DYN_RATE_HI_RATE_HI__PRE 0x0
2256
2257#define FEC_OC_SNC_MODE__A 0x2440040
2258#define FEC_OC_SNC_MODE__W 4
2259#define FEC_OC_SNC_MODE__M 0xF
2260#define FEC_OC_SNC_MODE__PRE 0x0
2261
2262#define FEC_OC_SNC_MODE_UNLOCK_ENABLE__B 0
2263#define FEC_OC_SNC_MODE_UNLOCK_ENABLE__W 1
2264#define FEC_OC_SNC_MODE_UNLOCK_ENABLE__M 0x1
2265#define FEC_OC_SNC_MODE_UNLOCK_ENABLE__PRE 0x0
2266
2267#define FEC_OC_SNC_MODE_ERROR_CTL__B 1
2268#define FEC_OC_SNC_MODE_ERROR_CTL__W 2
2269#define FEC_OC_SNC_MODE_ERROR_CTL__M 0x6
2270#define FEC_OC_SNC_MODE_ERROR_CTL__PRE 0x0
2271
2272#define FEC_OC_SNC_MODE_CORR_DISABLE__B 3
2273#define FEC_OC_SNC_MODE_CORR_DISABLE__W 1
2274#define FEC_OC_SNC_MODE_CORR_DISABLE__M 0x8
2275#define FEC_OC_SNC_MODE_CORR_DISABLE__PRE 0x0
2276
2277#define FEC_OC_SNC_LWM__A 0x2440041
2278#define FEC_OC_SNC_LWM__W 4
2279#define FEC_OC_SNC_LWM__M 0xF
2280#define FEC_OC_SNC_LWM__PRE 0x3
2281
2282#define FEC_OC_SNC_LWM_MARK__B 0
2283#define FEC_OC_SNC_LWM_MARK__W 4
2284#define FEC_OC_SNC_LWM_MARK__M 0xF
2285#define FEC_OC_SNC_LWM_MARK__PRE 0x3
2286
2287#define FEC_OC_SNC_HWM__A 0x2440042
2288#define FEC_OC_SNC_HWM__W 4
2289#define FEC_OC_SNC_HWM__M 0xF
2290#define FEC_OC_SNC_HWM__PRE 0x5
2291
2292#define FEC_OC_SNC_HWM_MARK__B 0
2293#define FEC_OC_SNC_HWM_MARK__W 4
2294#define FEC_OC_SNC_HWM_MARK__M 0xF
2295#define FEC_OC_SNC_HWM_MARK__PRE 0x5
2296
2297#define FEC_OC_SNC_UNLOCK__A 0x2440043
2298#define FEC_OC_SNC_UNLOCK__W 1
2299#define FEC_OC_SNC_UNLOCK__M 0x1
2300#define FEC_OC_SNC_UNLOCK__PRE 0x0
2301
2302#define FEC_OC_SNC_UNLOCK_RESTART__B 0
2303#define FEC_OC_SNC_UNLOCK_RESTART__W 1
2304#define FEC_OC_SNC_UNLOCK_RESTART__M 0x1
2305#define FEC_OC_SNC_UNLOCK_RESTART__PRE 0x0
2306
2307#define FEC_OC_SNC_LOCK_COUNT__A 0x2440044
2308#define FEC_OC_SNC_LOCK_COUNT__W 12
2309#define FEC_OC_SNC_LOCK_COUNT__M 0xFFF
2310#define FEC_OC_SNC_LOCK_COUNT__PRE 0x0
2311
2312#define FEC_OC_SNC_LOCK_COUNT_COUNT__B 0
2313#define FEC_OC_SNC_LOCK_COUNT_COUNT__W 12
2314#define FEC_OC_SNC_LOCK_COUNT_COUNT__M 0xFFF
2315#define FEC_OC_SNC_LOCK_COUNT_COUNT__PRE 0x0
2316
2317#define FEC_OC_SNC_FAIL_COUNT__A 0x2440045
2318#define FEC_OC_SNC_FAIL_COUNT__W 12
2319#define FEC_OC_SNC_FAIL_COUNT__M 0xFFF
2320#define FEC_OC_SNC_FAIL_COUNT__PRE 0x0
2321
2322#define FEC_OC_SNC_FAIL_COUNT_COUNT__B 0
2323#define FEC_OC_SNC_FAIL_COUNT_COUNT__W 12
2324#define FEC_OC_SNC_FAIL_COUNT_COUNT__M 0xFFF
2325#define FEC_OC_SNC_FAIL_COUNT_COUNT__PRE 0x0
2326
2327#define FEC_OC_SNC_FAIL_PERIOD__A 0x2440046
2328#define FEC_OC_SNC_FAIL_PERIOD__W 16
2329#define FEC_OC_SNC_FAIL_PERIOD__M 0xFFFF
2330#define FEC_OC_SNC_FAIL_PERIOD__PRE 0x1171
2331
2332#define FEC_OC_SNC_FAIL_PERIOD_PERIOD__B 0
2333#define FEC_OC_SNC_FAIL_PERIOD_PERIOD__W 16
2334#define FEC_OC_SNC_FAIL_PERIOD_PERIOD__M 0xFFFF
2335#define FEC_OC_SNC_FAIL_PERIOD_PERIOD__PRE 0x1171
2336
2337#define FEC_OC_EMS_MODE__A 0x2440047
2338#define FEC_OC_EMS_MODE__W 2
2339#define FEC_OC_EMS_MODE__M 0x3
2340#define FEC_OC_EMS_MODE__PRE 0x0
2341
2342#define FEC_OC_EMS_MODE_MODE__B 0
2343#define FEC_OC_EMS_MODE_MODE__W 2
2344#define FEC_OC_EMS_MODE_MODE__M 0x3
2345#define FEC_OC_EMS_MODE_MODE__PRE 0x0
2346
2347#define FEC_OC_IPR_MODE__A 0x2440048
2348#define FEC_OC_IPR_MODE__W 12
2349#define FEC_OC_IPR_MODE__M 0xFFF
2350#define FEC_OC_IPR_MODE__PRE 0x0
2351
2352#define FEC_OC_IPR_MODE_SERIAL__B 0
2353#define FEC_OC_IPR_MODE_SERIAL__W 1
2354#define FEC_OC_IPR_MODE_SERIAL__M 0x1
2355#define FEC_OC_IPR_MODE_SERIAL__PRE 0x0
2356
2357#define FEC_OC_IPR_MODE_REVERSE_ORDER__B 1
2358#define FEC_OC_IPR_MODE_REVERSE_ORDER__W 1
2359#define FEC_OC_IPR_MODE_REVERSE_ORDER__M 0x2
2360#define FEC_OC_IPR_MODE_REVERSE_ORDER__PRE 0x0
2361
2362#define FEC_OC_IPR_MODE_MCLK_DIS_DAT_ABS__B 2
2363#define FEC_OC_IPR_MODE_MCLK_DIS_DAT_ABS__W 1
2364#define FEC_OC_IPR_MODE_MCLK_DIS_DAT_ABS__M 0x4
2365#define FEC_OC_IPR_MODE_MCLK_DIS_DAT_ABS__PRE 0x0
2366
2367#define FEC_OC_IPR_MODE_MCLK_DIS_PAR__B 3
2368#define FEC_OC_IPR_MODE_MCLK_DIS_PAR__W 1
2369#define FEC_OC_IPR_MODE_MCLK_DIS_PAR__M 0x8
2370#define FEC_OC_IPR_MODE_MCLK_DIS_PAR__PRE 0x0
2371
2372#define FEC_OC_IPR_MODE_MVAL_DIS_PAR__B 4
2373#define FEC_OC_IPR_MODE_MVAL_DIS_PAR__W 1
2374#define FEC_OC_IPR_MODE_MVAL_DIS_PAR__M 0x10
2375#define FEC_OC_IPR_MODE_MVAL_DIS_PAR__PRE 0x0
2376
2377#define FEC_OC_IPR_MODE_MERR_DIS_PAR__B 5
2378#define FEC_OC_IPR_MODE_MERR_DIS_PAR__W 1
2379#define FEC_OC_IPR_MODE_MERR_DIS_PAR__M 0x20
2380#define FEC_OC_IPR_MODE_MERR_DIS_PAR__PRE 0x0
2381
2382#define FEC_OC_IPR_MODE_MD_DIS_PAR__B 6
2383#define FEC_OC_IPR_MODE_MD_DIS_PAR__W 1
2384#define FEC_OC_IPR_MODE_MD_DIS_PAR__M 0x40
2385#define FEC_OC_IPR_MODE_MD_DIS_PAR__PRE 0x0
2386
2387#define FEC_OC_IPR_MODE_MCLK_DIS_ERR__B 7
2388#define FEC_OC_IPR_MODE_MCLK_DIS_ERR__W 1
2389#define FEC_OC_IPR_MODE_MCLK_DIS_ERR__M 0x80
2390#define FEC_OC_IPR_MODE_MCLK_DIS_ERR__PRE 0x0
2391
2392#define FEC_OC_IPR_MODE_MVAL_DIS_ERR__B 8
2393#define FEC_OC_IPR_MODE_MVAL_DIS_ERR__W 1
2394#define FEC_OC_IPR_MODE_MVAL_DIS_ERR__M 0x100
2395#define FEC_OC_IPR_MODE_MVAL_DIS_ERR__PRE 0x0
2396
2397#define FEC_OC_IPR_MODE_MERR_DIS_ERR__B 9
2398#define FEC_OC_IPR_MODE_MERR_DIS_ERR__W 1
2399#define FEC_OC_IPR_MODE_MERR_DIS_ERR__M 0x200
2400#define FEC_OC_IPR_MODE_MERR_DIS_ERR__PRE 0x0
2401
2402#define FEC_OC_IPR_MODE_MD_DIS_ERR__B 10
2403#define FEC_OC_IPR_MODE_MD_DIS_ERR__W 1
2404#define FEC_OC_IPR_MODE_MD_DIS_ERR__M 0x400
2405#define FEC_OC_IPR_MODE_MD_DIS_ERR__PRE 0x0
2406
2407#define FEC_OC_IPR_MODE_MSTRT_DIS_ERR__B 11
2408#define FEC_OC_IPR_MODE_MSTRT_DIS_ERR__W 1
2409#define FEC_OC_IPR_MODE_MSTRT_DIS_ERR__M 0x800
2410#define FEC_OC_IPR_MODE_MSTRT_DIS_ERR__PRE 0x0
2411
2412#define FEC_OC_IPR_INVERT__A 0x2440049
2413#define FEC_OC_IPR_INVERT__W 12
2414#define FEC_OC_IPR_INVERT__M 0xFFF
2415#define FEC_OC_IPR_INVERT__PRE 0x0
2416
2417#define FEC_OC_IPR_INVERT_MD0__B 0
2418#define FEC_OC_IPR_INVERT_MD0__W 1
2419#define FEC_OC_IPR_INVERT_MD0__M 0x1
2420#define FEC_OC_IPR_INVERT_MD0__PRE 0x0
2421
2422#define FEC_OC_IPR_INVERT_MD1__B 1
2423#define FEC_OC_IPR_INVERT_MD1__W 1
2424#define FEC_OC_IPR_INVERT_MD1__M 0x2
2425#define FEC_OC_IPR_INVERT_MD1__PRE 0x0
2426
2427#define FEC_OC_IPR_INVERT_MD2__B 2
2428#define FEC_OC_IPR_INVERT_MD2__W 1
2429#define FEC_OC_IPR_INVERT_MD2__M 0x4
2430#define FEC_OC_IPR_INVERT_MD2__PRE 0x0
2431
2432#define FEC_OC_IPR_INVERT_MD3__B 3
2433#define FEC_OC_IPR_INVERT_MD3__W 1
2434#define FEC_OC_IPR_INVERT_MD3__M 0x8
2435#define FEC_OC_IPR_INVERT_MD3__PRE 0x0
2436
2437#define FEC_OC_IPR_INVERT_MD4__B 4
2438#define FEC_OC_IPR_INVERT_MD4__W 1
2439#define FEC_OC_IPR_INVERT_MD4__M 0x10
2440#define FEC_OC_IPR_INVERT_MD4__PRE 0x0
2441
2442#define FEC_OC_IPR_INVERT_MD5__B 5
2443#define FEC_OC_IPR_INVERT_MD5__W 1
2444#define FEC_OC_IPR_INVERT_MD5__M 0x20
2445#define FEC_OC_IPR_INVERT_MD5__PRE 0x0
2446
2447#define FEC_OC_IPR_INVERT_MD6__B 6
2448#define FEC_OC_IPR_INVERT_MD6__W 1
2449#define FEC_OC_IPR_INVERT_MD6__M 0x40
2450#define FEC_OC_IPR_INVERT_MD6__PRE 0x0
2451
2452#define FEC_OC_IPR_INVERT_MD7__B 7
2453#define FEC_OC_IPR_INVERT_MD7__W 1
2454#define FEC_OC_IPR_INVERT_MD7__M 0x80
2455#define FEC_OC_IPR_INVERT_MD7__PRE 0x0
2456
2457#define FEC_OC_IPR_INVERT_MERR__B 8
2458#define FEC_OC_IPR_INVERT_MERR__W 1
2459#define FEC_OC_IPR_INVERT_MERR__M 0x100
2460#define FEC_OC_IPR_INVERT_MERR__PRE 0x0
2461
2462#define FEC_OC_IPR_INVERT_MSTRT__B 9
2463#define FEC_OC_IPR_INVERT_MSTRT__W 1
2464#define FEC_OC_IPR_INVERT_MSTRT__M 0x200
2465#define FEC_OC_IPR_INVERT_MSTRT__PRE 0x0
2466
2467#define FEC_OC_IPR_INVERT_MVAL__B 10
2468#define FEC_OC_IPR_INVERT_MVAL__W 1
2469#define FEC_OC_IPR_INVERT_MVAL__M 0x400
2470#define FEC_OC_IPR_INVERT_MVAL__PRE 0x0
2471
2472#define FEC_OC_IPR_INVERT_MCLK__B 11
2473#define FEC_OC_IPR_INVERT_MCLK__W 1
2474#define FEC_OC_IPR_INVERT_MCLK__M 0x800
2475#define FEC_OC_IPR_INVERT_MCLK__PRE 0x0
2476
2477#define FEC_OC_OCR_MODE__A 0x2440050
2478#define FEC_OC_OCR_MODE__W 4
2479#define FEC_OC_OCR_MODE__M 0xF
2480#define FEC_OC_OCR_MODE__PRE 0x0
2481
2482#define FEC_OC_OCR_MODE_MB_SELECT__B 0
2483#define FEC_OC_OCR_MODE_MB_SELECT__W 1
2484#define FEC_OC_OCR_MODE_MB_SELECT__M 0x1
2485#define FEC_OC_OCR_MODE_MB_SELECT__PRE 0x0
2486
2487#define FEC_OC_OCR_MODE_GRAB_ENABLE__B 1
2488#define FEC_OC_OCR_MODE_GRAB_ENABLE__W 1
2489#define FEC_OC_OCR_MODE_GRAB_ENABLE__M 0x2
2490#define FEC_OC_OCR_MODE_GRAB_ENABLE__PRE 0x0
2491
2492#define FEC_OC_OCR_MODE_GRAB_SELECT__B 2
2493#define FEC_OC_OCR_MODE_GRAB_SELECT__W 1
2494#define FEC_OC_OCR_MODE_GRAB_SELECT__M 0x4
2495#define FEC_OC_OCR_MODE_GRAB_SELECT__PRE 0x0
2496
2497#define FEC_OC_OCR_MODE_GRAB_COUNTED__B 3
2498#define FEC_OC_OCR_MODE_GRAB_COUNTED__W 1
2499#define FEC_OC_OCR_MODE_GRAB_COUNTED__M 0x8
2500#define FEC_OC_OCR_MODE_GRAB_COUNTED__PRE 0x0
2501
2502#define FEC_OC_OCR_RATE__A 0x2440051
2503#define FEC_OC_OCR_RATE__W 4
2504#define FEC_OC_OCR_RATE__M 0xF
2505#define FEC_OC_OCR_RATE__PRE 0x0
2506
2507#define FEC_OC_OCR_RATE_RATE__B 0
2508#define FEC_OC_OCR_RATE_RATE__W 4
2509#define FEC_OC_OCR_RATE_RATE__M 0xF
2510#define FEC_OC_OCR_RATE_RATE__PRE 0x0
2511
2512#define FEC_OC_OCR_INVERT__A 0x2440052
2513#define FEC_OC_OCR_INVERT__W 12
2514#define FEC_OC_OCR_INVERT__M 0xFFF
2515#define FEC_OC_OCR_INVERT__PRE 0x800
2516
2517#define FEC_OC_OCR_INVERT_INVERT__B 0
2518#define FEC_OC_OCR_INVERT_INVERT__W 12
2519#define FEC_OC_OCR_INVERT_INVERT__M 0xFFF
2520#define FEC_OC_OCR_INVERT_INVERT__PRE 0x800
2521
2522#define FEC_OC_OCR_GRAB_COUNT__A 0x2440053
2523#define FEC_OC_OCR_GRAB_COUNT__W 16
2524#define FEC_OC_OCR_GRAB_COUNT__M 0xFFFF
2525#define FEC_OC_OCR_GRAB_COUNT__PRE 0x0
2526
2527#define FEC_OC_OCR_GRAB_COUNT_COUNT__B 0
2528#define FEC_OC_OCR_GRAB_COUNT_COUNT__W 16
2529#define FEC_OC_OCR_GRAB_COUNT_COUNT__M 0xFFFF
2530#define FEC_OC_OCR_GRAB_COUNT_COUNT__PRE 0x0
2531
2532#define FEC_OC_OCR_GRAB_SYNC__A 0x2440054
2533#define FEC_OC_OCR_GRAB_SYNC__W 8
2534#define FEC_OC_OCR_GRAB_SYNC__M 0xFF
2535#define FEC_OC_OCR_GRAB_SYNC__PRE 0x0
2536
2537#define FEC_OC_OCR_GRAB_SYNC_BYTE_SEL__B 0
2538#define FEC_OC_OCR_GRAB_SYNC_BYTE_SEL__W 3
2539#define FEC_OC_OCR_GRAB_SYNC_BYTE_SEL__M 0x7
2540#define FEC_OC_OCR_GRAB_SYNC_BYTE_SEL__PRE 0x0
2541
2542#define FEC_OC_OCR_GRAB_SYNC_BIT_SEL__B 3
2543#define FEC_OC_OCR_GRAB_SYNC_BIT_SEL__W 4
2544#define FEC_OC_OCR_GRAB_SYNC_BIT_SEL__M 0x78
2545#define FEC_OC_OCR_GRAB_SYNC_BIT_SEL__PRE 0x0
2546
2547#define FEC_OC_OCR_GRAB_SYNC_VALUE_SEL__B 7
2548#define FEC_OC_OCR_GRAB_SYNC_VALUE_SEL__W 1
2549#define FEC_OC_OCR_GRAB_SYNC_VALUE_SEL__M 0x80
2550#define FEC_OC_OCR_GRAB_SYNC_VALUE_SEL__PRE 0x0
2551
2552#define FEC_OC_OCR_GRAB_RD0__A 0x2440055
2553#define FEC_OC_OCR_GRAB_RD0__W 10
2554#define FEC_OC_OCR_GRAB_RD0__M 0x3FF
2555#define FEC_OC_OCR_GRAB_RD0__PRE 0x0
2556
2557#define FEC_OC_OCR_GRAB_RD0_DATA__B 0
2558#define FEC_OC_OCR_GRAB_RD0_DATA__W 10
2559#define FEC_OC_OCR_GRAB_RD0_DATA__M 0x3FF
2560#define FEC_OC_OCR_GRAB_RD0_DATA__PRE 0x0
2561
2562#define FEC_OC_OCR_GRAB_RD1__A 0x2440056
2563#define FEC_OC_OCR_GRAB_RD1__W 10
2564#define FEC_OC_OCR_GRAB_RD1__M 0x3FF
2565#define FEC_OC_OCR_GRAB_RD1__PRE 0x0
2566
2567#define FEC_OC_OCR_GRAB_RD1_DATA__B 0
2568#define FEC_OC_OCR_GRAB_RD1_DATA__W 10
2569#define FEC_OC_OCR_GRAB_RD1_DATA__M 0x3FF
2570#define FEC_OC_OCR_GRAB_RD1_DATA__PRE 0x0
2571
2572#define FEC_OC_OCR_GRAB_RD2__A 0x2440057
2573#define FEC_OC_OCR_GRAB_RD2__W 10
2574#define FEC_OC_OCR_GRAB_RD2__M 0x3FF
2575#define FEC_OC_OCR_GRAB_RD2__PRE 0x0
2576
2577#define FEC_OC_OCR_GRAB_RD2_DATA__B 0
2578#define FEC_OC_OCR_GRAB_RD2_DATA__W 10
2579#define FEC_OC_OCR_GRAB_RD2_DATA__M 0x3FF
2580#define FEC_OC_OCR_GRAB_RD2_DATA__PRE 0x0
2581
2582#define FEC_OC_OCR_GRAB_RD3__A 0x2440058
2583#define FEC_OC_OCR_GRAB_RD3__W 10
2584#define FEC_OC_OCR_GRAB_RD3__M 0x3FF
2585#define FEC_OC_OCR_GRAB_RD3__PRE 0x0
2586
2587#define FEC_OC_OCR_GRAB_RD3_DATA__B 0
2588#define FEC_OC_OCR_GRAB_RD3_DATA__W 10
2589#define FEC_OC_OCR_GRAB_RD3_DATA__M 0x3FF
2590#define FEC_OC_OCR_GRAB_RD3_DATA__PRE 0x0
2591
2592#define FEC_OC_OCR_GRAB_RD4__A 0x2440059
2593#define FEC_OC_OCR_GRAB_RD4__W 10
2594#define FEC_OC_OCR_GRAB_RD4__M 0x3FF
2595#define FEC_OC_OCR_GRAB_RD4__PRE 0x0
2596
2597#define FEC_OC_OCR_GRAB_RD4_DATA__B 0
2598#define FEC_OC_OCR_GRAB_RD4_DATA__W 10
2599#define FEC_OC_OCR_GRAB_RD4_DATA__M 0x3FF
2600#define FEC_OC_OCR_GRAB_RD4_DATA__PRE 0x0
2601
2602#define FEC_OC_OCR_GRAB_RD5__A 0x244005A
2603#define FEC_OC_OCR_GRAB_RD5__W 10
2604#define FEC_OC_OCR_GRAB_RD5__M 0x3FF
2605#define FEC_OC_OCR_GRAB_RD5__PRE 0x0
2606
2607#define FEC_OC_OCR_GRAB_RD5_DATA__B 0
2608#define FEC_OC_OCR_GRAB_RD5_DATA__W 10
2609#define FEC_OC_OCR_GRAB_RD5_DATA__M 0x3FF
2610#define FEC_OC_OCR_GRAB_RD5_DATA__PRE 0x0
2611
2612#define FEC_DI_RAM__A 0x2450000
2613
2614#define FEC_RS_RAM__A 0x2460000
2615
2616#define FEC_OC_RAM__A 0x2470000
2617
2618#define IQM_COMM_EXEC__A 0x1800000
2619#define IQM_COMM_EXEC__W 2
2620#define IQM_COMM_EXEC__M 0x3
2621#define IQM_COMM_EXEC__PRE 0x0
2622#define IQM_COMM_EXEC_STOP 0x0
2623#define IQM_COMM_EXEC_ACTIVE 0x1
2624#define IQM_COMM_EXEC_HOLD 0x2
2625
2626#define IQM_COMM_MB__A 0x1800002
2627#define IQM_COMM_MB__W 16
2628#define IQM_COMM_MB__M 0xFFFF
2629#define IQM_COMM_MB__PRE 0x0
2630#define IQM_COMM_INT_REQ__A 0x1800003
2631#define IQM_COMM_INT_REQ__W 2
2632#define IQM_COMM_INT_REQ__M 0x3
2633#define IQM_COMM_INT_REQ__PRE 0x0
2634
2635#define IQM_COMM_INT_REQ_AF_REQ__B 0
2636#define IQM_COMM_INT_REQ_AF_REQ__W 1
2637#define IQM_COMM_INT_REQ_AF_REQ__M 0x1
2638#define IQM_COMM_INT_REQ_AF_REQ__PRE 0x0
2639
2640#define IQM_COMM_INT_REQ_CF_REQ__B 1
2641#define IQM_COMM_INT_REQ_CF_REQ__W 1
2642#define IQM_COMM_INT_REQ_CF_REQ__M 0x2
2643#define IQM_COMM_INT_REQ_CF_REQ__PRE 0x0
2644
2645#define IQM_COMM_INT_STA__A 0x1800005
2646#define IQM_COMM_INT_STA__W 16
2647#define IQM_COMM_INT_STA__M 0xFFFF
2648#define IQM_COMM_INT_STA__PRE 0x0
2649#define IQM_COMM_INT_MSK__A 0x1800006
2650#define IQM_COMM_INT_MSK__W 16
2651#define IQM_COMM_INT_MSK__M 0xFFFF
2652#define IQM_COMM_INT_MSK__PRE 0x0
2653#define IQM_COMM_INT_STM__A 0x1800007
2654#define IQM_COMM_INT_STM__W 16
2655#define IQM_COMM_INT_STM__M 0xFFFF
2656#define IQM_COMM_INT_STM__PRE 0x0
2657
2658#define IQM_FS_COMM_EXEC__A 0x1820000
2659#define IQM_FS_COMM_EXEC__W 2
2660#define IQM_FS_COMM_EXEC__M 0x3
2661#define IQM_FS_COMM_EXEC__PRE 0x0
2662#define IQM_FS_COMM_EXEC_STOP 0x0
2663#define IQM_FS_COMM_EXEC_ACTIVE 0x1
2664#define IQM_FS_COMM_EXEC_HOLD 0x2
2665
2666#define IQM_FS_COMM_MB__A 0x1820002
2667#define IQM_FS_COMM_MB__W 2
2668#define IQM_FS_COMM_MB__M 0x3
2669#define IQM_FS_COMM_MB__PRE 0x0
2670#define IQM_FS_COMM_MB_CTL__B 0
2671#define IQM_FS_COMM_MB_CTL__W 1
2672#define IQM_FS_COMM_MB_CTL__M 0x1
2673#define IQM_FS_COMM_MB_CTL__PRE 0x0
2674#define IQM_FS_COMM_MB_CTL_CTL_OFF 0x0
2675#define IQM_FS_COMM_MB_CTL_CTL_ON 0x1
2676#define IQM_FS_COMM_MB_OBS__B 1
2677#define IQM_FS_COMM_MB_OBS__W 1
2678#define IQM_FS_COMM_MB_OBS__M 0x2
2679#define IQM_FS_COMM_MB_OBS__PRE 0x0
2680#define IQM_FS_COMM_MB_OBS_OBS_OFF 0x0
2681#define IQM_FS_COMM_MB_OBS_OBS_ON 0x2
2682
2683#define IQM_FS_RATE_OFS_LO__A 0x1820010
2684#define IQM_FS_RATE_OFS_LO__W 16
2685#define IQM_FS_RATE_OFS_LO__M 0xFFFF
2686#define IQM_FS_RATE_OFS_LO__PRE 0x0
2687#define IQM_FS_RATE_OFS_HI__A 0x1820011
2688#define IQM_FS_RATE_OFS_HI__W 12
2689#define IQM_FS_RATE_OFS_HI__M 0xFFF
2690#define IQM_FS_RATE_OFS_HI__PRE 0x0
2691#define IQM_FS_RATE_LO__A 0x1820012
2692#define IQM_FS_RATE_LO__W 16
2693#define IQM_FS_RATE_LO__M 0xFFFF
2694#define IQM_FS_RATE_LO__PRE 0x0
2695#define IQM_FS_RATE_HI__A 0x1820013
2696#define IQM_FS_RATE_HI__W 12
2697#define IQM_FS_RATE_HI__M 0xFFF
2698#define IQM_FS_RATE_HI__PRE 0x0
2699
2700#define IQM_FS_ADJ_SEL__A 0x1820014
2701#define IQM_FS_ADJ_SEL__W 2
2702#define IQM_FS_ADJ_SEL__M 0x3
2703#define IQM_FS_ADJ_SEL__PRE 0x0
2704#define IQM_FS_ADJ_SEL_OFF 0x0
2705#define IQM_FS_ADJ_SEL_QAM 0x1
2706#define IQM_FS_ADJ_SEL_VSB 0x2
2707
2708#define IQM_FD_COMM_EXEC__A 0x1830000
2709#define IQM_FD_COMM_EXEC__W 2
2710#define IQM_FD_COMM_EXEC__M 0x3
2711#define IQM_FD_COMM_EXEC__PRE 0x0
2712#define IQM_FD_COMM_EXEC_STOP 0x0
2713#define IQM_FD_COMM_EXEC_ACTIVE 0x1
2714#define IQM_FD_COMM_EXEC_HOLD 0x2
2715
2716#define IQM_FD_COMM_MB__A 0x1830002
2717#define IQM_FD_COMM_MB__W 2
2718#define IQM_FD_COMM_MB__M 0x3
2719#define IQM_FD_COMM_MB__PRE 0x0
2720#define IQM_FD_COMM_MB_CTL__B 0
2721#define IQM_FD_COMM_MB_CTL__W 1
2722#define IQM_FD_COMM_MB_CTL__M 0x1
2723#define IQM_FD_COMM_MB_CTL__PRE 0x0
2724#define IQM_FD_COMM_MB_CTL_CTL_OFF 0x0
2725#define IQM_FD_COMM_MB_CTL_CTL_ON 0x1
2726#define IQM_FD_COMM_MB_OBS__B 1
2727#define IQM_FD_COMM_MB_OBS__W 1
2728#define IQM_FD_COMM_MB_OBS__M 0x2
2729#define IQM_FD_COMM_MB_OBS__PRE 0x0
2730#define IQM_FD_COMM_MB_OBS_OBS_OFF 0x0
2731#define IQM_FD_COMM_MB_OBS_OBS_ON 0x2
2732
2733#define IQM_RC_COMM_EXEC__A 0x1840000
2734#define IQM_RC_COMM_EXEC__W 2
2735#define IQM_RC_COMM_EXEC__M 0x3
2736#define IQM_RC_COMM_EXEC__PRE 0x0
2737#define IQM_RC_COMM_EXEC_STOP 0x0
2738#define IQM_RC_COMM_EXEC_ACTIVE 0x1
2739#define IQM_RC_COMM_EXEC_HOLD 0x2
2740
2741#define IQM_RC_COMM_MB__A 0x1840002
2742#define IQM_RC_COMM_MB__W 2
2743#define IQM_RC_COMM_MB__M 0x3
2744#define IQM_RC_COMM_MB__PRE 0x0
2745#define IQM_RC_COMM_MB_CTL__B 0
2746#define IQM_RC_COMM_MB_CTL__W 1
2747#define IQM_RC_COMM_MB_CTL__M 0x1
2748#define IQM_RC_COMM_MB_CTL__PRE 0x0
2749#define IQM_RC_COMM_MB_CTL_CTL_OFF 0x0
2750#define IQM_RC_COMM_MB_CTL_CTL_ON 0x1
2751#define IQM_RC_COMM_MB_OBS__B 1
2752#define IQM_RC_COMM_MB_OBS__W 1
2753#define IQM_RC_COMM_MB_OBS__M 0x2
2754#define IQM_RC_COMM_MB_OBS__PRE 0x0
2755#define IQM_RC_COMM_MB_OBS_OBS_OFF 0x0
2756#define IQM_RC_COMM_MB_OBS_OBS_ON 0x2
2757
2758#define IQM_RC_RATE_OFS_LO__A 0x1840010
2759#define IQM_RC_RATE_OFS_LO__W 16
2760#define IQM_RC_RATE_OFS_LO__M 0xFFFF
2761#define IQM_RC_RATE_OFS_LO__PRE 0x0
2762#define IQM_RC_RATE_OFS_HI__A 0x1840011
2763#define IQM_RC_RATE_OFS_HI__W 8
2764#define IQM_RC_RATE_OFS_HI__M 0xFF
2765#define IQM_RC_RATE_OFS_HI__PRE 0x0
2766#define IQM_RC_RATE_LO__A 0x1840012
2767#define IQM_RC_RATE_LO__W 16
2768#define IQM_RC_RATE_LO__M 0xFFFF
2769#define IQM_RC_RATE_LO__PRE 0x0
2770#define IQM_RC_RATE_HI__A 0x1840013
2771#define IQM_RC_RATE_HI__W 8
2772#define IQM_RC_RATE_HI__M 0xFF
2773#define IQM_RC_RATE_HI__PRE 0x0
2774
2775#define IQM_RC_ADJ_SEL__A 0x1840014
2776#define IQM_RC_ADJ_SEL__W 2
2777#define IQM_RC_ADJ_SEL__M 0x3
2778#define IQM_RC_ADJ_SEL__PRE 0x0
2779#define IQM_RC_ADJ_SEL_OFF 0x0
2780#define IQM_RC_ADJ_SEL_QAM 0x1
2781#define IQM_RC_ADJ_SEL_VSB 0x2
2782
2783#define IQM_RC_CROUT_ENA__A 0x1840015
2784#define IQM_RC_CROUT_ENA__W 1
2785#define IQM_RC_CROUT_ENA__M 0x1
2786#define IQM_RC_CROUT_ENA__PRE 0x0
2787
2788#define IQM_RC_CROUT_ENA_ENA__B 0
2789#define IQM_RC_CROUT_ENA_ENA__W 1
2790#define IQM_RC_CROUT_ENA_ENA__M 0x1
2791#define IQM_RC_CROUT_ENA_ENA__PRE 0x0
2792
2793#define IQM_RC_STRETCH__A 0x1840016
2794#define IQM_RC_STRETCH__W 5
2795#define IQM_RC_STRETCH__M 0x1F
2796#define IQM_RC_STRETCH__PRE 0x0
2797#define IQM_RC_STRETCH_QAM_B_64 0x1E
2798#define IQM_RC_STRETCH_QAM_B_256 0x1C
2799#define IQM_RC_STRETCH_ATV 0xF
2800
2801#define IQM_RT_COMM_EXEC__A 0x1850000
2802#define IQM_RT_COMM_EXEC__W 2
2803#define IQM_RT_COMM_EXEC__M 0x3
2804#define IQM_RT_COMM_EXEC__PRE 0x0
2805#define IQM_RT_COMM_EXEC_STOP 0x0
2806#define IQM_RT_COMM_EXEC_ACTIVE 0x1
2807#define IQM_RT_COMM_EXEC_HOLD 0x2
2808
2809#define IQM_RT_COMM_MB__A 0x1850002
2810#define IQM_RT_COMM_MB__W 2
2811#define IQM_RT_COMM_MB__M 0x3
2812#define IQM_RT_COMM_MB__PRE 0x0
2813#define IQM_RT_COMM_MB_CTL__B 0
2814#define IQM_RT_COMM_MB_CTL__W 1
2815#define IQM_RT_COMM_MB_CTL__M 0x1
2816#define IQM_RT_COMM_MB_CTL__PRE 0x0
2817#define IQM_RT_COMM_MB_CTL_CTL_OFF 0x0
2818#define IQM_RT_COMM_MB_CTL_CTL_ON 0x1
2819#define IQM_RT_COMM_MB_OBS__B 1
2820#define IQM_RT_COMM_MB_OBS__W 1
2821#define IQM_RT_COMM_MB_OBS__M 0x2
2822#define IQM_RT_COMM_MB_OBS__PRE 0x0
2823#define IQM_RT_COMM_MB_OBS_OBS_OFF 0x0
2824#define IQM_RT_COMM_MB_OBS_OBS_ON 0x2
2825
2826#define IQM_RT_ACTIVE__A 0x1850010
2827#define IQM_RT_ACTIVE__W 2
2828#define IQM_RT_ACTIVE__M 0x3
2829#define IQM_RT_ACTIVE__PRE 0x0
2830
2831#define IQM_RT_ACTIVE_ACTIVE_RT__B 0
2832#define IQM_RT_ACTIVE_ACTIVE_RT__W 1
2833#define IQM_RT_ACTIVE_ACTIVE_RT__M 0x1
2834#define IQM_RT_ACTIVE_ACTIVE_RT__PRE 0x0
2835#define IQM_RT_ACTIVE_ACTIVE_RT_ATV_FCR_OFF 0x0
2836#define IQM_RT_ACTIVE_ACTIVE_RT_ATV_FCR_ON 0x1
2837
2838#define IQM_RT_ACTIVE_ACTIVE_CR__B 1
2839#define IQM_RT_ACTIVE_ACTIVE_CR__W 1
2840#define IQM_RT_ACTIVE_ACTIVE_CR__M 0x2
2841#define IQM_RT_ACTIVE_ACTIVE_CR__PRE 0x0
2842#define IQM_RT_ACTIVE_ACTIVE_CR_ATV_CR_OFF 0x0
2843#define IQM_RT_ACTIVE_ACTIVE_CR_ATV_CR_ON 0x2
2844
2845#define IQM_RT_LO_INCR__A 0x1850011
2846#define IQM_RT_LO_INCR__W 12
2847#define IQM_RT_LO_INCR__M 0xFFF
2848#define IQM_RT_LO_INCR__PRE 0x588
2849#define IQM_RT_LO_INCR_FM 0x0
2850#define IQM_RT_LO_INCR_MN 0x588
2851
2852#define IQM_RT_ROT_BP__A 0x1850012
2853#define IQM_RT_ROT_BP__W 2
2854#define IQM_RT_ROT_BP__M 0x3
2855#define IQM_RT_ROT_BP__PRE 0x0
2856
2857#define IQM_RT_ROT_BP_ROT_OFF__B 0
2858#define IQM_RT_ROT_BP_ROT_OFF__W 1
2859#define IQM_RT_ROT_BP_ROT_OFF__M 0x1
2860#define IQM_RT_ROT_BP_ROT_OFF__PRE 0x0
2861#define IQM_RT_ROT_BP_ROT_OFF_ACTIVE 0x0
2862#define IQM_RT_ROT_BP_ROT_OFF_OFF 0x1
2863
2864#define IQM_RT_ROT_BP_ROT_BPF__B 1
2865#define IQM_RT_ROT_BP_ROT_BPF__W 1
2866#define IQM_RT_ROT_BP_ROT_BPF__M 0x2
2867#define IQM_RT_ROT_BP_ROT_BPF__PRE 0x0
2868
2869#define IQM_RT_LP_BP__A 0x1850013
2870#define IQM_RT_LP_BP__W 1
2871#define IQM_RT_LP_BP__M 0x1
2872#define IQM_RT_LP_BP__PRE 0x0
2873
2874#define IQM_RT_DELAY__A 0x1850014
2875#define IQM_RT_DELAY__W 7
2876#define IQM_RT_DELAY__M 0x7F
2877#define IQM_RT_DELAY__PRE 0x45
2878
2879#define IQM_CF_COMM_EXEC__A 0x1860000
2880#define IQM_CF_COMM_EXEC__W 2
2881#define IQM_CF_COMM_EXEC__M 0x3
2882#define IQM_CF_COMM_EXEC__PRE 0x0
2883#define IQM_CF_COMM_EXEC_STOP 0x0
2884#define IQM_CF_COMM_EXEC_ACTIVE 0x1
2885#define IQM_CF_COMM_EXEC_HOLD 0x2
2886
2887#define IQM_CF_COMM_MB__A 0x1860002
2888#define IQM_CF_COMM_MB__W 2
2889#define IQM_CF_COMM_MB__M 0x3
2890#define IQM_CF_COMM_MB__PRE 0x0
2891#define IQM_CF_COMM_MB_CTL__B 0
2892#define IQM_CF_COMM_MB_CTL__W 1
2893#define IQM_CF_COMM_MB_CTL__M 0x1
2894#define IQM_CF_COMM_MB_CTL__PRE 0x0
2895#define IQM_CF_COMM_MB_CTL_CTL_OFF 0x0
2896#define IQM_CF_COMM_MB_CTL_CTL_ON 0x1
2897#define IQM_CF_COMM_MB_OBS__B 1
2898#define IQM_CF_COMM_MB_OBS__W 1
2899#define IQM_CF_COMM_MB_OBS__M 0x2
2900#define IQM_CF_COMM_MB_OBS__PRE 0x0
2901#define IQM_CF_COMM_MB_OBS_OBS_OFF 0x0
2902#define IQM_CF_COMM_MB_OBS_OBS_ON 0x2
2903
2904#define IQM_CF_COMM_INT_REQ__A 0x1860003
2905#define IQM_CF_COMM_INT_REQ__W 1
2906#define IQM_CF_COMM_INT_REQ__M 0x1
2907#define IQM_CF_COMM_INT_REQ__PRE 0x0
2908#define IQM_CF_COMM_INT_STA__A 0x1860005
2909#define IQM_CF_COMM_INT_STA__W 1
2910#define IQM_CF_COMM_INT_STA__M 0x1
2911#define IQM_CF_COMM_INT_STA__PRE 0x0
2912#define IQM_CF_COMM_INT_STA_PM__B 0
2913#define IQM_CF_COMM_INT_STA_PM__W 1
2914#define IQM_CF_COMM_INT_STA_PM__M 0x1
2915#define IQM_CF_COMM_INT_STA_PM__PRE 0x0
2916
2917#define IQM_CF_COMM_INT_MSK__A 0x1860006
2918#define IQM_CF_COMM_INT_MSK__W 1
2919#define IQM_CF_COMM_INT_MSK__M 0x1
2920#define IQM_CF_COMM_INT_MSK__PRE 0x0
2921#define IQM_CF_COMM_INT_MSK_PM__B 0
2922#define IQM_CF_COMM_INT_MSK_PM__W 1
2923#define IQM_CF_COMM_INT_MSK_PM__M 0x1
2924#define IQM_CF_COMM_INT_MSK_PM__PRE 0x0
2925
2926#define IQM_CF_COMM_INT_STM__A 0x1860007
2927#define IQM_CF_COMM_INT_STM__W 1
2928#define IQM_CF_COMM_INT_STM__M 0x1
2929#define IQM_CF_COMM_INT_STM__PRE 0x0
2930#define IQM_CF_COMM_INT_STM_PM__B 0
2931#define IQM_CF_COMM_INT_STM_PM__W 1
2932#define IQM_CF_COMM_INT_STM_PM__M 0x1
2933#define IQM_CF_COMM_INT_STM_PM__PRE 0x0
2934
2935#define IQM_CF_SYMMETRIC__A 0x1860010
2936#define IQM_CF_SYMMETRIC__W 2
2937#define IQM_CF_SYMMETRIC__M 0x3
2938#define IQM_CF_SYMMETRIC__PRE 0x0
2939
2940#define IQM_CF_SYMMETRIC_RE__B 0
2941#define IQM_CF_SYMMETRIC_RE__W 1
2942#define IQM_CF_SYMMETRIC_RE__M 0x1
2943#define IQM_CF_SYMMETRIC_RE__PRE 0x0
2944
2945#define IQM_CF_SYMMETRIC_IM__B 1
2946#define IQM_CF_SYMMETRIC_IM__W 1
2947#define IQM_CF_SYMMETRIC_IM__M 0x2
2948#define IQM_CF_SYMMETRIC_IM__PRE 0x0
2949
2950#define IQM_CF_MIDTAP__A 0x1860011
2951#define IQM_CF_MIDTAP__W 2
2952#define IQM_CF_MIDTAP__M 0x3
2953#define IQM_CF_MIDTAP__PRE 0x3
2954
2955#define IQM_CF_MIDTAP_RE__B 0
2956#define IQM_CF_MIDTAP_RE__W 1
2957#define IQM_CF_MIDTAP_RE__M 0x1
2958#define IQM_CF_MIDTAP_RE__PRE 0x1
2959
2960#define IQM_CF_MIDTAP_IM__B 1
2961#define IQM_CF_MIDTAP_IM__W 1
2962#define IQM_CF_MIDTAP_IM__M 0x2
2963#define IQM_CF_MIDTAP_IM__PRE 0x2
2964
2965#define IQM_CF_OUT_ENA__A 0x1860012
2966#define IQM_CF_OUT_ENA__W 3
2967#define IQM_CF_OUT_ENA__M 0x7
2968#define IQM_CF_OUT_ENA__PRE 0x0
2969
2970#define IQM_CF_OUT_ENA_ATV__B 0
2971#define IQM_CF_OUT_ENA_ATV__W 1
2972#define IQM_CF_OUT_ENA_ATV__M 0x1
2973#define IQM_CF_OUT_ENA_ATV__PRE 0x0
2974
2975#define IQM_CF_OUT_ENA_QAM__B 1
2976#define IQM_CF_OUT_ENA_QAM__W 1
2977#define IQM_CF_OUT_ENA_QAM__M 0x2
2978#define IQM_CF_OUT_ENA_QAM__PRE 0x0
2979
2980#define IQM_CF_OUT_ENA_VSB__B 2
2981#define IQM_CF_OUT_ENA_VSB__W 1
2982#define IQM_CF_OUT_ENA_VSB__M 0x4
2983#define IQM_CF_OUT_ENA_VSB__PRE 0x0
2984
2985#define IQM_CF_ADJ_SEL__A 0x1860013
2986#define IQM_CF_ADJ_SEL__W 2
2987#define IQM_CF_ADJ_SEL__M 0x3
2988#define IQM_CF_ADJ_SEL__PRE 0x0
2989#define IQM_CF_SCALE__A 0x1860014
2990#define IQM_CF_SCALE__W 14
2991#define IQM_CF_SCALE__M 0x3FFF
2992#define IQM_CF_SCALE__PRE 0x400
2993
2994#define IQM_CF_SCALE_SH__A 0x1860015
2995#define IQM_CF_SCALE_SH__W 2
2996#define IQM_CF_SCALE_SH__M 0x3
2997#define IQM_CF_SCALE_SH__PRE 0x0
2998
2999#define IQM_CF_AMP__A 0x1860016
3000#define IQM_CF_AMP__W 14
3001#define IQM_CF_AMP__M 0x3FFF
3002#define IQM_CF_AMP__PRE 0x0
3003
3004#define IQM_CF_POW_MEAS_LEN__A 0x1860017
3005#define IQM_CF_POW_MEAS_LEN__W 3
3006#define IQM_CF_POW_MEAS_LEN__M 0x7
3007#define IQM_CF_POW_MEAS_LEN__PRE 0x2
3008#define IQM_CF_POW_MEAS_LEN_QAM_B_64 0x1
3009#define IQM_CF_POW_MEAS_LEN_QAM_B_256 0x1
3010
3011#define IQM_CF_POW__A 0x1860018
3012#define IQM_CF_POW__W 16
3013#define IQM_CF_POW__M 0xFFFF
3014#define IQM_CF_POW__PRE 0x2
3015#define IQM_CF_TAP_RE0__A 0x1860020
3016#define IQM_CF_TAP_RE0__W 7
3017#define IQM_CF_TAP_RE0__M 0x7F
3018#define IQM_CF_TAP_RE0__PRE 0x2
3019#define IQM_CF_TAP_RE1__A 0x1860021
3020#define IQM_CF_TAP_RE1__W 7
3021#define IQM_CF_TAP_RE1__M 0x7F
3022#define IQM_CF_TAP_RE1__PRE 0x2
3023#define IQM_CF_TAP_RE2__A 0x1860022
3024#define IQM_CF_TAP_RE2__W 7
3025#define IQM_CF_TAP_RE2__M 0x7F
3026#define IQM_CF_TAP_RE2__PRE 0x2
3027#define IQM_CF_TAP_RE3__A 0x1860023
3028#define IQM_CF_TAP_RE3__W 7
3029#define IQM_CF_TAP_RE3__M 0x7F
3030#define IQM_CF_TAP_RE3__PRE 0x2
3031#define IQM_CF_TAP_RE4__A 0x1860024
3032#define IQM_CF_TAP_RE4__W 7
3033#define IQM_CF_TAP_RE4__M 0x7F
3034#define IQM_CF_TAP_RE4__PRE 0x2
3035#define IQM_CF_TAP_RE5__A 0x1860025
3036#define IQM_CF_TAP_RE5__W 7
3037#define IQM_CF_TAP_RE5__M 0x7F
3038#define IQM_CF_TAP_RE5__PRE 0x2
3039#define IQM_CF_TAP_RE6__A 0x1860026
3040#define IQM_CF_TAP_RE6__W 7
3041#define IQM_CF_TAP_RE6__M 0x7F
3042#define IQM_CF_TAP_RE6__PRE 0x2
3043#define IQM_CF_TAP_RE7__A 0x1860027
3044#define IQM_CF_TAP_RE7__W 9
3045#define IQM_CF_TAP_RE7__M 0x1FF
3046#define IQM_CF_TAP_RE7__PRE 0x2
3047#define IQM_CF_TAP_RE8__A 0x1860028
3048#define IQM_CF_TAP_RE8__W 9
3049#define IQM_CF_TAP_RE8__M 0x1FF
3050#define IQM_CF_TAP_RE8__PRE 0x2
3051#define IQM_CF_TAP_RE9__A 0x1860029
3052#define IQM_CF_TAP_RE9__W 9
3053#define IQM_CF_TAP_RE9__M 0x1FF
3054#define IQM_CF_TAP_RE9__PRE 0x2
3055#define IQM_CF_TAP_RE10__A 0x186002A
3056#define IQM_CF_TAP_RE10__W 9
3057#define IQM_CF_TAP_RE10__M 0x1FF
3058#define IQM_CF_TAP_RE10__PRE 0x2
3059#define IQM_CF_TAP_RE11__A 0x186002B
3060#define IQM_CF_TAP_RE11__W 9
3061#define IQM_CF_TAP_RE11__M 0x1FF
3062#define IQM_CF_TAP_RE11__PRE 0x2
3063#define IQM_CF_TAP_RE12__A 0x186002C
3064#define IQM_CF_TAP_RE12__W 9
3065#define IQM_CF_TAP_RE12__M 0x1FF
3066#define IQM_CF_TAP_RE12__PRE 0x2
3067#define IQM_CF_TAP_RE13__A 0x186002D
3068#define IQM_CF_TAP_RE13__W 9
3069#define IQM_CF_TAP_RE13__M 0x1FF
3070#define IQM_CF_TAP_RE13__PRE 0x2
3071#define IQM_CF_TAP_RE14__A 0x186002E
3072#define IQM_CF_TAP_RE14__W 9
3073#define IQM_CF_TAP_RE14__M 0x1FF
3074#define IQM_CF_TAP_RE14__PRE 0x2
3075#define IQM_CF_TAP_RE15__A 0x186002F
3076#define IQM_CF_TAP_RE15__W 9
3077#define IQM_CF_TAP_RE15__M 0x1FF
3078#define IQM_CF_TAP_RE15__PRE 0x2
3079#define IQM_CF_TAP_RE16__A 0x1860030
3080#define IQM_CF_TAP_RE16__W 9
3081#define IQM_CF_TAP_RE16__M 0x1FF
3082#define IQM_CF_TAP_RE16__PRE 0x2
3083#define IQM_CF_TAP_RE17__A 0x1860031
3084#define IQM_CF_TAP_RE17__W 9
3085#define IQM_CF_TAP_RE17__M 0x1FF
3086#define IQM_CF_TAP_RE17__PRE 0x2
3087#define IQM_CF_TAP_RE18__A 0x1860032
3088#define IQM_CF_TAP_RE18__W 9
3089#define IQM_CF_TAP_RE18__M 0x1FF
3090#define IQM_CF_TAP_RE18__PRE 0x2
3091#define IQM_CF_TAP_RE19__A 0x1860033
3092#define IQM_CF_TAP_RE19__W 9
3093#define IQM_CF_TAP_RE19__M 0x1FF
3094#define IQM_CF_TAP_RE19__PRE 0x2
3095#define IQM_CF_TAP_RE20__A 0x1860034
3096#define IQM_CF_TAP_RE20__W 9
3097#define IQM_CF_TAP_RE20__M 0x1FF
3098#define IQM_CF_TAP_RE20__PRE 0x2
3099#define IQM_CF_TAP_RE21__A 0x1860035
3100#define IQM_CF_TAP_RE21__W 11
3101#define IQM_CF_TAP_RE21__M 0x7FF
3102#define IQM_CF_TAP_RE21__PRE 0x2
3103#define IQM_CF_TAP_RE22__A 0x1860036
3104#define IQM_CF_TAP_RE22__W 11
3105#define IQM_CF_TAP_RE22__M 0x7FF
3106#define IQM_CF_TAP_RE22__PRE 0x2
3107#define IQM_CF_TAP_RE23__A 0x1860037
3108#define IQM_CF_TAP_RE23__W 11
3109#define IQM_CF_TAP_RE23__M 0x7FF
3110#define IQM_CF_TAP_RE23__PRE 0x2
3111#define IQM_CF_TAP_RE24__A 0x1860038
3112#define IQM_CF_TAP_RE24__W 11
3113#define IQM_CF_TAP_RE24__M 0x7FF
3114#define IQM_CF_TAP_RE24__PRE 0x2
3115#define IQM_CF_TAP_RE25__A 0x1860039
3116#define IQM_CF_TAP_RE25__W 11
3117#define IQM_CF_TAP_RE25__M 0x7FF
3118#define IQM_CF_TAP_RE25__PRE 0x2
3119#define IQM_CF_TAP_RE26__A 0x186003A
3120#define IQM_CF_TAP_RE26__W 11
3121#define IQM_CF_TAP_RE26__M 0x7FF
3122#define IQM_CF_TAP_RE26__PRE 0x2
3123#define IQM_CF_TAP_RE27__A 0x186003B
3124#define IQM_CF_TAP_RE27__W 11
3125#define IQM_CF_TAP_RE27__M 0x7FF
3126#define IQM_CF_TAP_RE27__PRE 0x2
3127#define IQM_CF_TAP_IM0__A 0x1860040
3128#define IQM_CF_TAP_IM0__W 7
3129#define IQM_CF_TAP_IM0__M 0x7F
3130#define IQM_CF_TAP_IM0__PRE 0x2
3131#define IQM_CF_TAP_IM1__A 0x1860041
3132#define IQM_CF_TAP_IM1__W 7
3133#define IQM_CF_TAP_IM1__M 0x7F
3134#define IQM_CF_TAP_IM1__PRE 0x2
3135#define IQM_CF_TAP_IM2__A 0x1860042
3136#define IQM_CF_TAP_IM2__W 7
3137#define IQM_CF_TAP_IM2__M 0x7F
3138#define IQM_CF_TAP_IM2__PRE 0x2
3139#define IQM_CF_TAP_IM3__A 0x1860043
3140#define IQM_CF_TAP_IM3__W 7
3141#define IQM_CF_TAP_IM3__M 0x7F
3142#define IQM_CF_TAP_IM3__PRE 0x2
3143#define IQM_CF_TAP_IM4__A 0x1860044
3144#define IQM_CF_TAP_IM4__W 7
3145#define IQM_CF_TAP_IM4__M 0x7F
3146#define IQM_CF_TAP_IM4__PRE 0x2
3147#define IQM_CF_TAP_IM5__A 0x1860045
3148#define IQM_CF_TAP_IM5__W 7
3149#define IQM_CF_TAP_IM5__M 0x7F
3150#define IQM_CF_TAP_IM5__PRE 0x2
3151#define IQM_CF_TAP_IM6__A 0x1860046
3152#define IQM_CF_TAP_IM6__W 7
3153#define IQM_CF_TAP_IM6__M 0x7F
3154#define IQM_CF_TAP_IM6__PRE 0x2
3155#define IQM_CF_TAP_IM7__A 0x1860047
3156#define IQM_CF_TAP_IM7__W 9
3157#define IQM_CF_TAP_IM7__M 0x1FF
3158#define IQM_CF_TAP_IM7__PRE 0x2
3159#define IQM_CF_TAP_IM8__A 0x1860048
3160#define IQM_CF_TAP_IM8__W 9
3161#define IQM_CF_TAP_IM8__M 0x1FF
3162#define IQM_CF_TAP_IM8__PRE 0x2
3163#define IQM_CF_TAP_IM9__A 0x1860049
3164#define IQM_CF_TAP_IM9__W 9
3165#define IQM_CF_TAP_IM9__M 0x1FF
3166#define IQM_CF_TAP_IM9__PRE 0x2
3167#define IQM_CF_TAP_IM10__A 0x186004A
3168#define IQM_CF_TAP_IM10__W 9
3169#define IQM_CF_TAP_IM10__M 0x1FF
3170#define IQM_CF_TAP_IM10__PRE 0x2
3171#define IQM_CF_TAP_IM11__A 0x186004B
3172#define IQM_CF_TAP_IM11__W 9
3173#define IQM_CF_TAP_IM11__M 0x1FF
3174#define IQM_CF_TAP_IM11__PRE 0x2
3175#define IQM_CF_TAP_IM12__A 0x186004C
3176#define IQM_CF_TAP_IM12__W 9
3177#define IQM_CF_TAP_IM12__M 0x1FF
3178#define IQM_CF_TAP_IM12__PRE 0x2
3179#define IQM_CF_TAP_IM13__A 0x186004D
3180#define IQM_CF_TAP_IM13__W 9
3181#define IQM_CF_TAP_IM13__M 0x1FF
3182#define IQM_CF_TAP_IM13__PRE 0x2
3183#define IQM_CF_TAP_IM14__A 0x186004E
3184#define IQM_CF_TAP_IM14__W 9
3185#define IQM_CF_TAP_IM14__M 0x1FF
3186#define IQM_CF_TAP_IM14__PRE 0x2
3187#define IQM_CF_TAP_IM15__A 0x186004F
3188#define IQM_CF_TAP_IM15__W 9
3189#define IQM_CF_TAP_IM15__M 0x1FF
3190#define IQM_CF_TAP_IM15__PRE 0x2
3191#define IQM_CF_TAP_IM16__A 0x1860050
3192#define IQM_CF_TAP_IM16__W 9
3193#define IQM_CF_TAP_IM16__M 0x1FF
3194#define IQM_CF_TAP_IM16__PRE 0x2
3195#define IQM_CF_TAP_IM17__A 0x1860051
3196#define IQM_CF_TAP_IM17__W 9
3197#define IQM_CF_TAP_IM17__M 0x1FF
3198#define IQM_CF_TAP_IM17__PRE 0x2
3199#define IQM_CF_TAP_IM18__A 0x1860052
3200#define IQM_CF_TAP_IM18__W 9
3201#define IQM_CF_TAP_IM18__M 0x1FF
3202#define IQM_CF_TAP_IM18__PRE 0x2
3203#define IQM_CF_TAP_IM19__A 0x1860053
3204#define IQM_CF_TAP_IM19__W 9
3205#define IQM_CF_TAP_IM19__M 0x1FF
3206#define IQM_CF_TAP_IM19__PRE 0x2
3207#define IQM_CF_TAP_IM20__A 0x1860054
3208#define IQM_CF_TAP_IM20__W 9
3209#define IQM_CF_TAP_IM20__M 0x1FF
3210#define IQM_CF_TAP_IM20__PRE 0x2
3211#define IQM_CF_TAP_IM21__A 0x1860055
3212#define IQM_CF_TAP_IM21__W 11
3213#define IQM_CF_TAP_IM21__M 0x7FF
3214#define IQM_CF_TAP_IM21__PRE 0x2
3215#define IQM_CF_TAP_IM22__A 0x1860056
3216#define IQM_CF_TAP_IM22__W 11
3217#define IQM_CF_TAP_IM22__M 0x7FF
3218#define IQM_CF_TAP_IM22__PRE 0x2
3219#define IQM_CF_TAP_IM23__A 0x1860057
3220#define IQM_CF_TAP_IM23__W 11
3221#define IQM_CF_TAP_IM23__M 0x7FF
3222#define IQM_CF_TAP_IM23__PRE 0x2
3223#define IQM_CF_TAP_IM24__A 0x1860058
3224#define IQM_CF_TAP_IM24__W 11
3225#define IQM_CF_TAP_IM24__M 0x7FF
3226#define IQM_CF_TAP_IM24__PRE 0x2
3227#define IQM_CF_TAP_IM25__A 0x1860059
3228#define IQM_CF_TAP_IM25__W 11
3229#define IQM_CF_TAP_IM25__M 0x7FF
3230#define IQM_CF_TAP_IM25__PRE 0x2
3231#define IQM_CF_TAP_IM26__A 0x186005A
3232#define IQM_CF_TAP_IM26__W 11
3233#define IQM_CF_TAP_IM26__M 0x7FF
3234#define IQM_CF_TAP_IM26__PRE 0x2
3235#define IQM_CF_TAP_IM27__A 0x186005B
3236#define IQM_CF_TAP_IM27__W 11
3237#define IQM_CF_TAP_IM27__M 0x7FF
3238#define IQM_CF_TAP_IM27__PRE 0x2
3239
3240#define IQM_AF_COMM_EXEC__A 0x1870000
3241#define IQM_AF_COMM_EXEC__W 2
3242#define IQM_AF_COMM_EXEC__M 0x3
3243#define IQM_AF_COMM_EXEC__PRE 0x0
3244#define IQM_AF_COMM_EXEC_STOP 0x0
3245#define IQM_AF_COMM_EXEC_ACTIVE 0x1
3246#define IQM_AF_COMM_EXEC_HOLD 0x2
3247
3248#define IQM_AF_COMM_MB__A 0x1870002
3249#define IQM_AF_COMM_MB__W 8
3250#define IQM_AF_COMM_MB__M 0xFF
3251#define IQM_AF_COMM_MB__PRE 0x0
3252#define IQM_AF_COMM_MB_CTL__B 0
3253#define IQM_AF_COMM_MB_CTL__W 1
3254#define IQM_AF_COMM_MB_CTL__M 0x1
3255#define IQM_AF_COMM_MB_CTL__PRE 0x0
3256#define IQM_AF_COMM_MB_CTL_CTL_OFF 0x0
3257#define IQM_AF_COMM_MB_CTL_CTL_ON 0x1
3258#define IQM_AF_COMM_MB_OBS__B 1
3259#define IQM_AF_COMM_MB_OBS__W 1
3260#define IQM_AF_COMM_MB_OBS__M 0x2
3261#define IQM_AF_COMM_MB_OBS__PRE 0x0
3262#define IQM_AF_COMM_MB_OBS_OBS_OFF 0x0
3263#define IQM_AF_COMM_MB_OBS_OBS_ON 0x2
3264#define IQM_AF_COMM_MB_MUX_CTRL__B 2
3265#define IQM_AF_COMM_MB_MUX_CTRL__W 3
3266#define IQM_AF_COMM_MB_MUX_CTRL__M 0x1C
3267#define IQM_AF_COMM_MB_MUX_CTRL__PRE 0x0
3268#define IQM_AF_COMM_MB_MUX_CTRL_AF_DATA_INPUT 0x0
3269#define IQM_AF_COMM_MB_MUX_CTRL_SENSE_INPUT 0x4
3270#define IQM_AF_COMM_MB_MUX_CTRL_AF_DATA_OUTPUT 0x8
3271#define IQM_AF_COMM_MB_MUX_CTRL_IF_AGC_OUTPUT 0xC
3272#define IQM_AF_COMM_MB_MUX_CTRL_RF_AGC_OUTPUT 0x10
3273#define IQM_AF_COMM_MB_MUX_OBS__B 5
3274#define IQM_AF_COMM_MB_MUX_OBS__W 3
3275#define IQM_AF_COMM_MB_MUX_OBS__M 0xE0
3276#define IQM_AF_COMM_MB_MUX_OBS__PRE 0x0
3277#define IQM_AF_COMM_MB_MUX_OBS_AF_DATA_INPUT 0x0
3278#define IQM_AF_COMM_MB_MUX_OBS_SENSE_INPUT 0x20
3279#define IQM_AF_COMM_MB_MUX_OBS_AF_DATA_OUTPUT 0x40
3280#define IQM_AF_COMM_MB_MUX_OBS_IF_AGC_OUTPUT 0x60
3281#define IQM_AF_COMM_MB_MUX_OBS_RF_AGC_OUTPUT 0x80
3282
3283#define IQM_AF_COMM_INT_REQ__A 0x1870003
3284#define IQM_AF_COMM_INT_REQ__W 1
3285#define IQM_AF_COMM_INT_REQ__M 0x1
3286#define IQM_AF_COMM_INT_REQ__PRE 0x0
3287#define IQM_AF_COMM_INT_STA__A 0x1870005
3288#define IQM_AF_COMM_INT_STA__W 2
3289#define IQM_AF_COMM_INT_STA__M 0x3
3290#define IQM_AF_COMM_INT_STA__PRE 0x0
3291#define IQM_AF_COMM_INT_STA_CLP_INT_STA__B 0
3292#define IQM_AF_COMM_INT_STA_CLP_INT_STA__W 1
3293#define IQM_AF_COMM_INT_STA_CLP_INT_STA__M 0x1
3294#define IQM_AF_COMM_INT_STA_CLP_INT_STA__PRE 0x0
3295#define IQM_AF_COMM_INT_STA_SNS_INT_STA__B 1
3296#define IQM_AF_COMM_INT_STA_SNS_INT_STA__W 1
3297#define IQM_AF_COMM_INT_STA_SNS_INT_STA__M 0x2
3298#define IQM_AF_COMM_INT_STA_SNS_INT_STA__PRE 0x0
3299
3300#define IQM_AF_COMM_INT_MSK__A 0x1870006
3301#define IQM_AF_COMM_INT_MSK__W 2
3302#define IQM_AF_COMM_INT_MSK__M 0x3
3303#define IQM_AF_COMM_INT_MSK__PRE 0x0
3304#define IQM_AF_COMM_INT_MSK_CLP_INT_MSK__B 0
3305#define IQM_AF_COMM_INT_MSK_CLP_INT_MSK__W 1
3306#define IQM_AF_COMM_INT_MSK_CLP_INT_MSK__M 0x1
3307#define IQM_AF_COMM_INT_MSK_CLP_INT_MSK__PRE 0x0
3308#define IQM_AF_COMM_INT_MSK_SNS_INT_MSK__B 1
3309#define IQM_AF_COMM_INT_MSK_SNS_INT_MSK__W 1
3310#define IQM_AF_COMM_INT_MSK_SNS_INT_MSK__M 0x2
3311#define IQM_AF_COMM_INT_MSK_SNS_INT_MSK__PRE 0x0
3312
3313#define IQM_AF_COMM_INT_STM__A 0x1870007
3314#define IQM_AF_COMM_INT_STM__W 2
3315#define IQM_AF_COMM_INT_STM__M 0x3
3316#define IQM_AF_COMM_INT_STM__PRE 0x0
3317#define IQM_AF_COMM_INT_STM_CLP_INT_STA__B 0
3318#define IQM_AF_COMM_INT_STM_CLP_INT_STA__W 1
3319#define IQM_AF_COMM_INT_STM_CLP_INT_STA__M 0x1
3320#define IQM_AF_COMM_INT_STM_CLP_INT_STA__PRE 0x0
3321#define IQM_AF_COMM_INT_STM_SNS_INT_STA__B 1
3322#define IQM_AF_COMM_INT_STM_SNS_INT_STA__W 1
3323#define IQM_AF_COMM_INT_STM_SNS_INT_STA__M 0x2
3324#define IQM_AF_COMM_INT_STM_SNS_INT_STA__PRE 0x0
3325
3326#define IQM_AF_FDB_SEL__A 0x1870010
3327#define IQM_AF_FDB_SEL__W 1
3328#define IQM_AF_FDB_SEL__M 0x1
3329#define IQM_AF_FDB_SEL__PRE 0x0
3330
3331#define IQM_AF_INVEXT__A 0x1870011
3332#define IQM_AF_INVEXT__W 1
3333#define IQM_AF_INVEXT__M 0x1
3334#define IQM_AF_INVEXT__PRE 0x0
3335#define IQM_AF_CLKNEG__A 0x1870012
3336#define IQM_AF_CLKNEG__W 2
3337#define IQM_AF_CLKNEG__M 0x3
3338#define IQM_AF_CLKNEG__PRE 0x0
3339
3340#define IQM_AF_CLKNEG_CLKNEGPEAK__B 0
3341#define IQM_AF_CLKNEG_CLKNEGPEAK__W 1
3342#define IQM_AF_CLKNEG_CLKNEGPEAK__M 0x1
3343#define IQM_AF_CLKNEG_CLKNEGPEAK__PRE 0x0
3344#define IQM_AF_CLKNEG_CLKNEGPEAK_CLK_ADC_PEAK_POS 0x0
3345#define IQM_AF_CLKNEG_CLKNEGPEAK_CLK_ADC_PEAK_NEG 0x1
3346
3347#define IQM_AF_CLKNEG_CLKNEGDATA__B 1
3348#define IQM_AF_CLKNEG_CLKNEGDATA__W 1
3349#define IQM_AF_CLKNEG_CLKNEGDATA__M 0x2
3350#define IQM_AF_CLKNEG_CLKNEGDATA__PRE 0x0
3351#define IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_POS 0x0
3352#define IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_NEG 0x2
3353
3354#define IQM_AF_MON_IN_MUX__A 0x1870013
3355#define IQM_AF_MON_IN_MUX__W 2
3356#define IQM_AF_MON_IN_MUX__M 0x3
3357#define IQM_AF_MON_IN_MUX__PRE 0x0
3358
3359#define IQM_AF_MON_IN5__A 0x1870014
3360#define IQM_AF_MON_IN5__W 10
3361#define IQM_AF_MON_IN5__M 0x3FF
3362#define IQM_AF_MON_IN5__PRE 0x0
3363
3364#define IQM_AF_MON_IN4__A 0x1870015
3365#define IQM_AF_MON_IN4__W 10
3366#define IQM_AF_MON_IN4__M 0x3FF
3367#define IQM_AF_MON_IN4__PRE 0x0
3368
3369#define IQM_AF_MON_IN3__A 0x1870016
3370#define IQM_AF_MON_IN3__W 10
3371#define IQM_AF_MON_IN3__M 0x3FF
3372#define IQM_AF_MON_IN3__PRE 0x0
3373
3374#define IQM_AF_MON_IN2__A 0x1870017
3375#define IQM_AF_MON_IN2__W 10
3376#define IQM_AF_MON_IN2__M 0x3FF
3377#define IQM_AF_MON_IN2__PRE 0x0
3378
3379#define IQM_AF_MON_IN1__A 0x1870018
3380#define IQM_AF_MON_IN1__W 10
3381#define IQM_AF_MON_IN1__M 0x3FF
3382#define IQM_AF_MON_IN1__PRE 0x0
3383
3384#define IQM_AF_MON_IN0__A 0x1870019
3385#define IQM_AF_MON_IN0__W 10
3386#define IQM_AF_MON_IN0__M 0x3FF
3387#define IQM_AF_MON_IN0__PRE 0x0
3388
3389#define IQM_AF_MON_IN_VAL__A 0x187001A
3390#define IQM_AF_MON_IN_VAL__W 1
3391#define IQM_AF_MON_IN_VAL__M 0x1
3392#define IQM_AF_MON_IN_VAL__PRE 0x0
3393
3394#define IQM_AF_START_LOCK__A 0x187001B
3395#define IQM_AF_START_LOCK__W 1
3396#define IQM_AF_START_LOCK__M 0x1
3397#define IQM_AF_START_LOCK__PRE 0x0
3398
3399#define IQM_AF_PHASE0__A 0x187001C
3400#define IQM_AF_PHASE0__W 7
3401#define IQM_AF_PHASE0__M 0x7F
3402#define IQM_AF_PHASE0__PRE 0x0
3403
3404#define IQM_AF_PHASE1__A 0x187001D
3405#define IQM_AF_PHASE1__W 7
3406#define IQM_AF_PHASE1__M 0x7F
3407#define IQM_AF_PHASE1__PRE 0x0
3408
3409#define IQM_AF_PHASE2__A 0x187001E
3410#define IQM_AF_PHASE2__W 7
3411#define IQM_AF_PHASE2__M 0x7F
3412#define IQM_AF_PHASE2__PRE 0x0
3413
3414#define IQM_AF_SCU_PHASE__A 0x187001F
3415#define IQM_AF_SCU_PHASE__W 2
3416#define IQM_AF_SCU_PHASE__M 0x3
3417#define IQM_AF_SCU_PHASE__PRE 0x0
3418
3419#define IQM_AF_SYNC_SEL__A 0x1870020
3420#define IQM_AF_SYNC_SEL__W 2
3421#define IQM_AF_SYNC_SEL__M 0x3
3422#define IQM_AF_SYNC_SEL__PRE 0x0
3423#define IQM_AF_ADC_CONF__A 0x1870021
3424#define IQM_AF_ADC_CONF__W 4
3425#define IQM_AF_ADC_CONF__M 0xF
3426#define IQM_AF_ADC_CONF__PRE 0x0
3427
3428#define IQM_AF_ADC_CONF_ADC_SIGN__B 0
3429#define IQM_AF_ADC_CONF_ADC_SIGN__W 1
3430#define IQM_AF_ADC_CONF_ADC_SIGN__M 0x1
3431#define IQM_AF_ADC_CONF_ADC_SIGN__PRE 0x0
3432#define IQM_AF_ADC_CONF_ADC_SIGN_ADC_SIGNED 0x0
3433#define IQM_AF_ADC_CONF_ADC_SIGN_ADC_UNSIGNED 0x1
3434
3435#define IQM_AF_ADC_CONF_BITREVERSE_ADC__B 1
3436#define IQM_AF_ADC_CONF_BITREVERSE_ADC__W 1
3437#define IQM_AF_ADC_CONF_BITREVERSE_ADC__M 0x2
3438#define IQM_AF_ADC_CONF_BITREVERSE_ADC__PRE 0x0
3439#define IQM_AF_ADC_CONF_BITREVERSE_ADC_ADC_NORMAL 0x0
3440#define IQM_AF_ADC_CONF_BITREVERSE_ADC_ADC_BITREVERSED 0x2
3441
3442#define IQM_AF_ADC_CONF_BITREVERSE_NSSI__B 2
3443#define IQM_AF_ADC_CONF_BITREVERSE_NSSI__W 1
3444#define IQM_AF_ADC_CONF_BITREVERSE_NSSI__M 0x4
3445#define IQM_AF_ADC_CONF_BITREVERSE_NSSI__PRE 0x0
3446#define IQM_AF_ADC_CONF_BITREVERSE_NSSI_IFAGC_DAC_NORMAL 0x0
3447#define IQM_AF_ADC_CONF_BITREVERSE_NSSI_IFAGC_DAC_BITREVERSED 0x4
3448
3449#define IQM_AF_ADC_CONF_BITREVERSE_NSSR__B 3
3450#define IQM_AF_ADC_CONF_BITREVERSE_NSSR__W 1
3451#define IQM_AF_ADC_CONF_BITREVERSE_NSSR__M 0x8
3452#define IQM_AF_ADC_CONF_BITREVERSE_NSSR__PRE 0x0
3453#define IQM_AF_ADC_CONF_BITREVERSE_NSSR_RFAGC_DAC_NORMAL 0x0
3454#define IQM_AF_ADC_CONF_BITREVERSE_NSSR_RFAGC_DAC_BITREVERSED 0x8
3455
3456#define IQM_AF_CLP_CLIP__A 0x1870022
3457#define IQM_AF_CLP_CLIP__W 16
3458#define IQM_AF_CLP_CLIP__M 0xFFFF
3459#define IQM_AF_CLP_CLIP__PRE 0x0
3460
3461#define IQM_AF_CLP_LEN__A 0x1870023
3462#define IQM_AF_CLP_LEN__W 16
3463#define IQM_AF_CLP_LEN__M 0xFFFF
3464#define IQM_AF_CLP_LEN__PRE 0x0
3465#define IQM_AF_CLP_LEN_QAM_B_64 0x400
3466#define IQM_AF_CLP_LEN_QAM_B_256 0x400
3467#define IQM_AF_CLP_LEN_ATV 0x0
3468
3469#define IQM_AF_CLP_TH__A 0x1870024
3470#define IQM_AF_CLP_TH__W 9
3471#define IQM_AF_CLP_TH__M 0x1FF
3472#define IQM_AF_CLP_TH__PRE 0x0
3473#define IQM_AF_CLP_TH_QAM_B_64 0x80
3474#define IQM_AF_CLP_TH_QAM_B_256 0x80
3475#define IQM_AF_CLP_TH_ATV 0x1C0
3476
3477#define IQM_AF_DCF_BYPASS__A 0x1870025
3478#define IQM_AF_DCF_BYPASS__W 1
3479#define IQM_AF_DCF_BYPASS__M 0x1
3480#define IQM_AF_DCF_BYPASS__PRE 0x0
3481#define IQM_AF_DCF_BYPASS_ACTIVE 0x0
3482#define IQM_AF_DCF_BYPASS_BYPASS 0x1
3483
3484#define IQM_AF_SNS_LEN__A 0x1870026
3485#define IQM_AF_SNS_LEN__W 16
3486#define IQM_AF_SNS_LEN__M 0xFFFF
3487#define IQM_AF_SNS_LEN__PRE 0x0
3488#define IQM_AF_SNS_LEN_QAM_B_64 0x400
3489#define IQM_AF_SNS_LEN_QAM_B_256 0x400
3490#define IQM_AF_SNS_LEN_ATV 0x0
3491
3492#define IQM_AF_SNS_SENSE__A 0x1870027
3493#define IQM_AF_SNS_SENSE__W 16
3494#define IQM_AF_SNS_SENSE__M 0xFFFF
3495#define IQM_AF_SNS_SENSE__PRE 0x0
3496
3497#define IQM_AF_AGC_IF__A 0x1870028
3498#define IQM_AF_AGC_IF__W 15
3499#define IQM_AF_AGC_IF__M 0x7FFF
3500#define IQM_AF_AGC_IF__PRE 0x0
3501
3502#define IQM_AF_AGC_RF__A 0x1870029
3503#define IQM_AF_AGC_RF__W 15
3504#define IQM_AF_AGC_RF__M 0x7FFF
3505#define IQM_AF_AGC_RF__PRE 0x0
3506
3507#define IQM_AF_PGA_GAIN__A 0x187002A
3508#define IQM_AF_PGA_GAIN__W 4
3509#define IQM_AF_PGA_GAIN__M 0xF
3510#define IQM_AF_PGA_GAIN__PRE 0x0
3511
3512#define IQM_AF_PDREF__A 0x187002B
3513#define IQM_AF_PDREF__W 5
3514#define IQM_AF_PDREF__M 0x1F
3515#define IQM_AF_PDREF__PRE 0x0
3516#define IQM_AF_PDREF_QAM_B_64 0xF
3517#define IQM_AF_PDREF_QAM_B_256 0xF
3518#define IQM_AF_PDREF_ATV 0xF
3519
3520#define IQM_AF_STDBY__A 0x187002C
3521#define IQM_AF_STDBY__W 6
3522#define IQM_AF_STDBY__M 0x3F
3523#define IQM_AF_STDBY__PRE 0x0
3524
3525#define IQM_AF_STDBY_STDBY_BIAS__B 0
3526#define IQM_AF_STDBY_STDBY_BIAS__W 1
3527#define IQM_AF_STDBY_STDBY_BIAS__M 0x1
3528#define IQM_AF_STDBY_STDBY_BIAS__PRE 0x0
3529#define IQM_AF_STDBY_STDBY_BIAS_ACTIVE 0x0
3530#define IQM_AF_STDBY_STDBY_BIAS_STANDBY 0x1
3531
3532#define IQM_AF_STDBY_STDBY_ADC__B 1
3533#define IQM_AF_STDBY_STDBY_ADC__W 1
3534#define IQM_AF_STDBY_STDBY_ADC__M 0x2
3535#define IQM_AF_STDBY_STDBY_ADC__PRE 0x0
3536#define IQM_AF_STDBY_STDBY_ADC_A1_ACTIVE 0x0
3537#define IQM_AF_STDBY_STDBY_ADC_A1_STANDBY 0x2
3538#define IQM_AF_STDBY_STDBY_ADC_A2_ACTIVE 0x2
3539#define IQM_AF_STDBY_STDBY_ADC_A2_STANDBY 0x0
3540
3541#define IQM_AF_STDBY_STDBY_AMP__B 2
3542#define IQM_AF_STDBY_STDBY_AMP__W 1
3543#define IQM_AF_STDBY_STDBY_AMP__M 0x4
3544#define IQM_AF_STDBY_STDBY_AMP__PRE 0x0
3545#define IQM_AF_STDBY_STDBY_AMP_A1_ACTIVE 0x0
3546#define IQM_AF_STDBY_STDBY_AMP_A1_STANDBY 0x4
3547#define IQM_AF_STDBY_STDBY_AMP_A2_ACTIVE 0x4
3548#define IQM_AF_STDBY_STDBY_AMP_A2_STANDBY 0x0
3549
3550#define IQM_AF_STDBY_STDBY_PD__B 3
3551#define IQM_AF_STDBY_STDBY_PD__W 1
3552#define IQM_AF_STDBY_STDBY_PD__M 0x8
3553#define IQM_AF_STDBY_STDBY_PD__PRE 0x0
3554#define IQM_AF_STDBY_STDBY_PD_A1_ACTIVE 0x0
3555#define IQM_AF_STDBY_STDBY_PD_A1_STANDBY 0x8
3556#define IQM_AF_STDBY_STDBY_PD_A2_ACTIVE 0x8
3557#define IQM_AF_STDBY_STDBY_PD_A2_STANDBY 0x0
3558
3559#define IQM_AF_STDBY_STDBY_TAGC_IF__B 4
3560#define IQM_AF_STDBY_STDBY_TAGC_IF__W 1
3561#define IQM_AF_STDBY_STDBY_TAGC_IF__M 0x10
3562#define IQM_AF_STDBY_STDBY_TAGC_IF__PRE 0x0
3563#define IQM_AF_STDBY_STDBY_TAGC_IF_A1_ACTIVE 0x0
3564#define IQM_AF_STDBY_STDBY_TAGC_IF_A1_STANDBY 0x10
3565#define IQM_AF_STDBY_STDBY_TAGC_IF_A2_ACTIVE 0x10
3566#define IQM_AF_STDBY_STDBY_TAGC_IF_A2_STANDBY 0x0
3567
3568#define IQM_AF_STDBY_STDBY_TAGC_RF__B 5
3569#define IQM_AF_STDBY_STDBY_TAGC_RF__W 1
3570#define IQM_AF_STDBY_STDBY_TAGC_RF__M 0x20
3571#define IQM_AF_STDBY_STDBY_TAGC_RF__PRE 0x0
3572#define IQM_AF_STDBY_STDBY_TAGC_RF_A1_ACTIVE 0x0
3573#define IQM_AF_STDBY_STDBY_TAGC_RF_A1_STANDBY 0x20
3574#define IQM_AF_STDBY_STDBY_TAGC_RF_A2_ACTIVE 0x20
3575#define IQM_AF_STDBY_STDBY_TAGC_RF_A2_STANDBY 0x0
3576
3577#define IQM_AF_AMUX__A 0x187002D
3578#define IQM_AF_AMUX__W 2
3579#define IQM_AF_AMUX__M 0x3
3580#define IQM_AF_AMUX__PRE 0x0
3581
3582#define IQM_AF_TST_AFEMAIN__A 0x187002E
3583#define IQM_AF_TST_AFEMAIN__W 8
3584#define IQM_AF_TST_AFEMAIN__M 0xFF
3585#define IQM_AF_TST_AFEMAIN__PRE 0x0
3586
3587#define IQM_RT_RAM__A 0x1880000
3588
3589#define IQM_RT_RAM_DLY__B 0
3590#define IQM_RT_RAM_DLY__W 13
3591#define IQM_RT_RAM_DLY__M 0x1FFF
3592#define IQM_RT_RAM_DLY__PRE 0x0
3593
3594#define ORX_COMM_EXEC__A 0x2000000
3595#define ORX_COMM_EXEC__W 2
3596#define ORX_COMM_EXEC__M 0x3
3597#define ORX_COMM_EXEC__PRE 0x0
3598#define ORX_COMM_EXEC_STOP 0x0
3599#define ORX_COMM_EXEC_ACTIVE 0x1
3600#define ORX_COMM_EXEC_HOLD 0x2
3601
3602#define ORX_COMM_STATE__A 0x2000001
3603#define ORX_COMM_STATE__W 16
3604#define ORX_COMM_STATE__M 0xFFFF
3605#define ORX_COMM_STATE__PRE 0x0
3606#define ORX_COMM_MB__A 0x2000002
3607#define ORX_COMM_MB__W 16
3608#define ORX_COMM_MB__M 0xFFFF
3609#define ORX_COMM_MB__PRE 0x0
3610#define ORX_COMM_INT_REQ__A 0x2000003
3611#define ORX_COMM_INT_REQ__W 16
3612#define ORX_COMM_INT_REQ__M 0xFFFF
3613#define ORX_COMM_INT_REQ__PRE 0x0
3614#define ORX_COMM_INT_REQ_EQU_REQ__B 0
3615#define ORX_COMM_INT_REQ_EQU_REQ__W 1
3616#define ORX_COMM_INT_REQ_EQU_REQ__M 0x1
3617#define ORX_COMM_INT_REQ_EQU_REQ__PRE 0x0
3618#define ORX_COMM_INT_REQ_DDC_REQ__B 1
3619#define ORX_COMM_INT_REQ_DDC_REQ__W 1
3620#define ORX_COMM_INT_REQ_DDC_REQ__M 0x2
3621#define ORX_COMM_INT_REQ_DDC_REQ__PRE 0x0
3622#define ORX_COMM_INT_REQ_FWP_REQ__B 2
3623#define ORX_COMM_INT_REQ_FWP_REQ__W 1
3624#define ORX_COMM_INT_REQ_FWP_REQ__M 0x4
3625#define ORX_COMM_INT_REQ_FWP_REQ__PRE 0x0
3626#define ORX_COMM_INT_REQ_CON_REQ__B 3
3627#define ORX_COMM_INT_REQ_CON_REQ__W 1
3628#define ORX_COMM_INT_REQ_CON_REQ__M 0x8
3629#define ORX_COMM_INT_REQ_CON_REQ__PRE 0x0
3630#define ORX_COMM_INT_REQ_NSU_REQ__B 4
3631#define ORX_COMM_INT_REQ_NSU_REQ__W 1
3632#define ORX_COMM_INT_REQ_NSU_REQ__M 0x10
3633#define ORX_COMM_INT_REQ_NSU_REQ__PRE 0x0
3634
3635#define ORX_COMM_INT_STA__A 0x2000005
3636#define ORX_COMM_INT_STA__W 16
3637#define ORX_COMM_INT_STA__M 0xFFFF
3638#define ORX_COMM_INT_STA__PRE 0x0
3639#define ORX_COMM_INT_MSK__A 0x2000006
3640#define ORX_COMM_INT_MSK__W 16
3641#define ORX_COMM_INT_MSK__M 0xFFFF
3642#define ORX_COMM_INT_MSK__PRE 0x0
3643#define ORX_COMM_INT_STM__A 0x2000007
3644#define ORX_COMM_INT_STM__W 16
3645#define ORX_COMM_INT_STM__M 0xFFFF
3646#define ORX_COMM_INT_STM__PRE 0x0
3647
3648#define ORX_TOP_COMM_EXEC__A 0x2010000
3649#define ORX_TOP_COMM_EXEC__W 2
3650#define ORX_TOP_COMM_EXEC__M 0x3
3651#define ORX_TOP_COMM_EXEC__PRE 0x0
3652#define ORX_TOP_COMM_EXEC_STOP 0x0
3653#define ORX_TOP_COMM_EXEC_ACTIVE 0x1
3654#define ORX_TOP_COMM_EXEC_HOLD 0x2
3655
3656#define ORX_TOP_COMM_KEY__A 0x201000F
3657#define ORX_TOP_COMM_KEY__W 16
3658#define ORX_TOP_COMM_KEY__M 0xFFFF
3659#define ORX_TOP_COMM_KEY__PRE 0x0
3660#define ORX_TOP_COMM_KEY_KEY 0xFABA
3661
3662#define ORX_TOP_MDE_W__A 0x2010010
3663#define ORX_TOP_MDE_W__W 2
3664#define ORX_TOP_MDE_W__M 0x3
3665#define ORX_TOP_MDE_W__PRE 0x2
3666#define ORX_TOP_MDE_W_RATE_1544KBPS 0x0
3667#define ORX_TOP_MDE_W_RATE_3088KBPS 0x1
3668#define ORX_TOP_MDE_W_RATE_2048KBPS_SQRT 0x2
3669#define ORX_TOP_MDE_W_RATE_2048KBPS_RO 0x3
3670
3671#define ORX_TOP_AIF_CTRL_W__A 0x2010011
3672#define ORX_TOP_AIF_CTRL_W__W 3
3673#define ORX_TOP_AIF_CTRL_W__M 0x7
3674#define ORX_TOP_AIF_CTRL_W__PRE 0x0
3675#define ORX_TOP_AIF_CTRL_W_NEG_CLK_EDGE__B 0
3676#define ORX_TOP_AIF_CTRL_W_NEG_CLK_EDGE__W 1
3677#define ORX_TOP_AIF_CTRL_W_NEG_CLK_EDGE__M 0x1
3678#define ORX_TOP_AIF_CTRL_W_NEG_CLK_EDGE__PRE 0x0
3679#define ORX_TOP_AIF_CTRL_W_NEG_CLK_EDGE_ADC_SAMPL_ON_POS_CLK_EDGE 0x0
3680#define ORX_TOP_AIF_CTRL_W_NEG_CLK_EDGE_ADC_SAMPL_ON_NEG_CLK_EDGE 0x1
3681#define ORX_TOP_AIF_CTRL_W_BIT_REVERSE__B 1
3682#define ORX_TOP_AIF_CTRL_W_BIT_REVERSE__W 1
3683#define ORX_TOP_AIF_CTRL_W_BIT_REVERSE__M 0x2
3684#define ORX_TOP_AIF_CTRL_W_BIT_REVERSE__PRE 0x0
3685#define ORX_TOP_AIF_CTRL_W_BIT_REVERSE_REGULAR_BIT_ORDER_ADC 0x0
3686#define ORX_TOP_AIF_CTRL_W_BIT_REVERSE_REVERSAL_BIT_ORDER_ADC 0x2
3687#define ORX_TOP_AIF_CTRL_W_INV_MSB__B 2
3688#define ORX_TOP_AIF_CTRL_W_INV_MSB__W 1
3689#define ORX_TOP_AIF_CTRL_W_INV_MSB__M 0x4
3690#define ORX_TOP_AIF_CTRL_W_INV_MSB__PRE 0x0
3691#define ORX_TOP_AIF_CTRL_W_INV_MSB_NO_MSB_INVERSION_ADC 0x0
3692#define ORX_TOP_AIF_CTRL_W_INV_MSB_MSB_INVERSION_ADC 0x4
3693
3694#define ORX_FWP_COMM_EXEC__A 0x2020000
3695#define ORX_FWP_COMM_EXEC__W 2
3696#define ORX_FWP_COMM_EXEC__M 0x3
3697#define ORX_FWP_COMM_EXEC__PRE 0x0
3698#define ORX_FWP_COMM_EXEC_STOP 0x0
3699#define ORX_FWP_COMM_EXEC_ACTIVE 0x1
3700#define ORX_FWP_COMM_EXEC_HOLD 0x2
3701
3702#define ORX_FWP_COMM_MB__A 0x2020002
3703#define ORX_FWP_COMM_MB__W 8
3704#define ORX_FWP_COMM_MB__M 0xFF
3705#define ORX_FWP_COMM_MB__PRE 0x0
3706#define ORX_FWP_COMM_MB_CTL__B 0
3707#define ORX_FWP_COMM_MB_CTL__W 1
3708#define ORX_FWP_COMM_MB_CTL__M 0x1
3709#define ORX_FWP_COMM_MB_CTL__PRE 0x0
3710#define ORX_FWP_COMM_MB_CTL_OFF 0x0
3711#define ORX_FWP_COMM_MB_CTL_ON 0x1
3712#define ORX_FWP_COMM_MB_OBS__B 1
3713#define ORX_FWP_COMM_MB_OBS__W 1
3714#define ORX_FWP_COMM_MB_OBS__M 0x2
3715#define ORX_FWP_COMM_MB_OBS__PRE 0x0
3716#define ORX_FWP_COMM_MB_OBS_OFF 0x0
3717#define ORX_FWP_COMM_MB_OBS_ON 0x2
3718
3719#define ORX_FWP_COMM_MB_CTL_MUX__B 2
3720#define ORX_FWP_COMM_MB_CTL_MUX__W 3
3721#define ORX_FWP_COMM_MB_CTL_MUX__M 0x1C
3722#define ORX_FWP_COMM_MB_CTL_MUX__PRE 0x0
3723
3724#define ORX_FWP_COMM_MB_OBS_MUX__B 5
3725#define ORX_FWP_COMM_MB_OBS_MUX__W 3
3726#define ORX_FWP_COMM_MB_OBS_MUX__M 0xE0
3727#define ORX_FWP_COMM_MB_OBS_MUX__PRE 0x0
3728
3729#define ORX_FWP_AAG_LEN_W__A 0x2020010
3730#define ORX_FWP_AAG_LEN_W__W 16
3731#define ORX_FWP_AAG_LEN_W__M 0xFFFF
3732#define ORX_FWP_AAG_LEN_W__PRE 0x800
3733
3734#define ORX_FWP_AAG_THR_W__A 0x2020011
3735#define ORX_FWP_AAG_THR_W__W 8
3736#define ORX_FWP_AAG_THR_W__M 0xFF
3737#define ORX_FWP_AAG_THR_W__PRE 0x50
3738
3739#define ORX_FWP_AAG_THR_CNT_R__A 0x2020012
3740#define ORX_FWP_AAG_THR_CNT_R__W 16
3741#define ORX_FWP_AAG_THR_CNT_R__M 0xFFFF
3742#define ORX_FWP_AAG_THR_CNT_R__PRE 0x0
3743
3744#define ORX_FWP_AAG_SNS_CNT_R__A 0x2020013
3745#define ORX_FWP_AAG_SNS_CNT_R__W 16
3746#define ORX_FWP_AAG_SNS_CNT_R__M 0xFFFF
3747#define ORX_FWP_AAG_SNS_CNT_R__PRE 0x0
3748
3749#define ORX_FWP_PFI_A_W__A 0x2020014
3750#define ORX_FWP_PFI_A_W__W 8
3751#define ORX_FWP_PFI_A_W__M 0xFF
3752#define ORX_FWP_PFI_A_W__PRE 0xB0
3753#define ORX_FWP_PFI_A_W_RATE_2048KBPS 0xB0
3754#define ORX_FWP_PFI_A_W_RATE_1544KBPS 0xA4
3755#define ORX_FWP_PFI_A_W_RATE_3088KBPS 0xC0
3756
3757#define ORX_FWP_PFI_B_W__A 0x2020015
3758#define ORX_FWP_PFI_B_W__W 8
3759#define ORX_FWP_PFI_B_W__M 0xFF
3760#define ORX_FWP_PFI_B_W__PRE 0x9E
3761#define ORX_FWP_PFI_B_W_RATE_2048KBPS 0x9E
3762#define ORX_FWP_PFI_B_W_RATE_1544KBPS 0x94
3763#define ORX_FWP_PFI_B_W_RATE_3088KBPS 0xB0
3764
3765#define ORX_FWP_PFI_C_W__A 0x2020016
3766#define ORX_FWP_PFI_C_W__W 8
3767#define ORX_FWP_PFI_C_W__M 0xFF
3768#define ORX_FWP_PFI_C_W__PRE 0x5C
3769#define ORX_FWP_PFI_C_W_RATE_2048KBPS 0x5C
3770#define ORX_FWP_PFI_C_W_RATE_1544KBPS 0x64
3771#define ORX_FWP_PFI_C_W_RATE_3088KBPS 0x50
3772
3773#define ORX_FWP_KR1_AMP_R__A 0x2020017
3774#define ORX_FWP_KR1_AMP_R__W 9
3775#define ORX_FWP_KR1_AMP_R__M 0x1FF
3776#define ORX_FWP_KR1_AMP_R__PRE 0x0
3777
3778#define ORX_FWP_KR1_LDT_W__A 0x2020018
3779#define ORX_FWP_KR1_LDT_W__W 3
3780#define ORX_FWP_KR1_LDT_W__M 0x7
3781#define ORX_FWP_KR1_LDT_W__PRE 0x2
3782#define ORX_FWP_SRC_DGN_W__A 0x2020019
3783#define ORX_FWP_SRC_DGN_W__W 16
3784#define ORX_FWP_SRC_DGN_W__M 0xFFFF
3785#define ORX_FWP_SRC_DGN_W__PRE 0x1FF
3786
3787#define ORX_FWP_SRC_DGN_W_MANT__B 0
3788#define ORX_FWP_SRC_DGN_W_MANT__W 9
3789#define ORX_FWP_SRC_DGN_W_MANT__M 0x1FF
3790#define ORX_FWP_SRC_DGN_W_MANT__PRE 0x1FF
3791
3792#define ORX_FWP_SRC_DGN_W_EXP__B 12
3793#define ORX_FWP_SRC_DGN_W_EXP__W 4
3794#define ORX_FWP_SRC_DGN_W_EXP__M 0xF000
3795#define ORX_FWP_SRC_DGN_W_EXP__PRE 0x0
3796
3797#define ORX_FWP_NYQ_ADR_W__A 0x202001A
3798#define ORX_FWP_NYQ_ADR_W__W 5
3799#define ORX_FWP_NYQ_ADR_W__M 0x1F
3800#define ORX_FWP_NYQ_ADR_W__PRE 0x1F
3801
3802#define ORX_FWP_NYQ_COF_RW__A 0x202001B
3803#define ORX_FWP_NYQ_COF_RW__W 10
3804#define ORX_FWP_NYQ_COF_RW__M 0x3FF
3805#define ORX_FWP_NYQ_COF_RW__PRE 0x0
3806
3807#define ORX_FWP_IQM_FRQ_W__A 0x202001C
3808#define ORX_FWP_IQM_FRQ_W__W 16
3809#define ORX_FWP_IQM_FRQ_W__M 0xFFFF
3810#define ORX_FWP_IQM_FRQ_W__PRE 0x4301
3811
3812#define ORX_EQU_COMM_EXEC__A 0x2030000
3813#define ORX_EQU_COMM_EXEC__W 2
3814#define ORX_EQU_COMM_EXEC__M 0x3
3815#define ORX_EQU_COMM_EXEC__PRE 0x0
3816#define ORX_EQU_COMM_EXEC_STOP 0x0
3817#define ORX_EQU_COMM_EXEC_ACTIVE 0x1
3818#define ORX_EQU_COMM_EXEC_HOLD 0x2
3819
3820#define ORX_EQU_COMM_MB__A 0x2030002
3821#define ORX_EQU_COMM_MB__W 8
3822#define ORX_EQU_COMM_MB__M 0xFF
3823#define ORX_EQU_COMM_MB__PRE 0x0
3824#define ORX_EQU_COMM_MB_CTL__B 0
3825#define ORX_EQU_COMM_MB_CTL__W 1
3826#define ORX_EQU_COMM_MB_CTL__M 0x1
3827#define ORX_EQU_COMM_MB_CTL__PRE 0x0
3828#define ORX_EQU_COMM_MB_CTL_OFF 0x0
3829#define ORX_EQU_COMM_MB_CTL_ON 0x1
3830#define ORX_EQU_COMM_MB_OBS__B 1
3831#define ORX_EQU_COMM_MB_OBS__W 1
3832#define ORX_EQU_COMM_MB_OBS__M 0x2
3833#define ORX_EQU_COMM_MB_OBS__PRE 0x0
3834#define ORX_EQU_COMM_MB_OBS_OFF 0x0
3835#define ORX_EQU_COMM_MB_OBS_ON 0x2
3836
3837#define ORX_EQU_COMM_MB_CTL_MUX__B 2
3838#define ORX_EQU_COMM_MB_CTL_MUX__W 3
3839#define ORX_EQU_COMM_MB_CTL_MUX__M 0x1C
3840#define ORX_EQU_COMM_MB_CTL_MUX__PRE 0x0
3841
3842#define ORX_EQU_COMM_MB_OBS_MUX__B 5
3843#define ORX_EQU_COMM_MB_OBS_MUX__W 3
3844#define ORX_EQU_COMM_MB_OBS_MUX__M 0xE0
3845#define ORX_EQU_COMM_MB_OBS_MUX__PRE 0x0
3846
3847#define ORX_EQU_COMM_INT_REQ__A 0x2030003
3848#define ORX_EQU_COMM_INT_REQ__W 1
3849#define ORX_EQU_COMM_INT_REQ__M 0x1
3850#define ORX_EQU_COMM_INT_REQ__PRE 0x0
3851#define ORX_EQU_COMM_INT_STA__A 0x2030005
3852#define ORX_EQU_COMM_INT_STA__W 2
3853#define ORX_EQU_COMM_INT_STA__M 0x3
3854#define ORX_EQU_COMM_INT_STA__PRE 0x0
3855
3856#define ORX_EQU_COMM_INT_STA_FFF_READ__B 0
3857#define ORX_EQU_COMM_INT_STA_FFF_READ__W 1
3858#define ORX_EQU_COMM_INT_STA_FFF_READ__M 0x1
3859#define ORX_EQU_COMM_INT_STA_FFF_READ__PRE 0x0
3860
3861#define ORX_EQU_COMM_INT_STA_FBF_READ__B 1
3862#define ORX_EQU_COMM_INT_STA_FBF_READ__W 1
3863#define ORX_EQU_COMM_INT_STA_FBF_READ__M 0x2
3864#define ORX_EQU_COMM_INT_STA_FBF_READ__PRE 0x0
3865
3866#define ORX_EQU_COMM_INT_MSK__A 0x2030006
3867#define ORX_EQU_COMM_INT_MSK__W 2
3868#define ORX_EQU_COMM_INT_MSK__M 0x3
3869#define ORX_EQU_COMM_INT_MSK__PRE 0x0
3870#define ORX_EQU_COMM_INT_MSK_FFF_READ__B 0
3871#define ORX_EQU_COMM_INT_MSK_FFF_READ__W 1
3872#define ORX_EQU_COMM_INT_MSK_FFF_READ__M 0x1
3873#define ORX_EQU_COMM_INT_MSK_FFF_READ__PRE 0x0
3874#define ORX_EQU_COMM_INT_MSK_FBF_READ__B 1
3875#define ORX_EQU_COMM_INT_MSK_FBF_READ__W 1
3876#define ORX_EQU_COMM_INT_MSK_FBF_READ__M 0x2
3877#define ORX_EQU_COMM_INT_MSK_FBF_READ__PRE 0x0
3878
3879#define ORX_EQU_COMM_INT_STM__A 0x2030007
3880#define ORX_EQU_COMM_INT_STM__W 2
3881#define ORX_EQU_COMM_INT_STM__M 0x3
3882#define ORX_EQU_COMM_INT_STM__PRE 0x0
3883#define ORX_EQU_COMM_INT_STM_FFF_READ__B 0
3884#define ORX_EQU_COMM_INT_STM_FFF_READ__W 1
3885#define ORX_EQU_COMM_INT_STM_FFF_READ__M 0x1
3886#define ORX_EQU_COMM_INT_STM_FFF_READ__PRE 0x0
3887#define ORX_EQU_COMM_INT_STM_FBF_READ__B 1
3888#define ORX_EQU_COMM_INT_STM_FBF_READ__W 1
3889#define ORX_EQU_COMM_INT_STM_FBF_READ__M 0x2
3890#define ORX_EQU_COMM_INT_STM_FBF_READ__PRE 0x0
3891
3892#define ORX_EQU_FFF_SCL_W__A 0x2030010
3893#define ORX_EQU_FFF_SCL_W__W 1
3894#define ORX_EQU_FFF_SCL_W__M 0x1
3895#define ORX_EQU_FFF_SCL_W__PRE 0x0
3896#define ORX_EQU_FFF_SCL_W_SCALE_GAIN_1 0x0
3897#define ORX_EQU_FFF_SCL_W_SCALE_GAIN_2 0x1
3898
3899#define ORX_EQU_FFF_UPD_W__A 0x2030011
3900#define ORX_EQU_FFF_UPD_W__W 1
3901#define ORX_EQU_FFF_UPD_W__M 0x1
3902#define ORX_EQU_FFF_UPD_W__PRE 0x0
3903#define ORX_EQU_FFF_UPD_W_NO_UPDATE 0x0
3904#define ORX_EQU_FFF_UPD_W_LMS_UPDATE 0x1
3905
3906#define ORX_EQU_FFF_STP_W__A 0x2030012
3907#define ORX_EQU_FFF_STP_W__W 3
3908#define ORX_EQU_FFF_STP_W__M 0x7
3909#define ORX_EQU_FFF_STP_W__PRE 0x2
3910
3911#define ORX_EQU_FFF_LEA_W__A 0x2030013
3912#define ORX_EQU_FFF_LEA_W__W 4
3913#define ORX_EQU_FFF_LEA_W__M 0xF
3914#define ORX_EQU_FFF_LEA_W__PRE 0x4
3915
3916#define ORX_EQU_FFF_RWT_W__A 0x2030014
3917#define ORX_EQU_FFF_RWT_W__W 2
3918#define ORX_EQU_FFF_RWT_W__M 0x3
3919#define ORX_EQU_FFF_RWT_W__PRE 0x0
3920
3921#define ORX_EQU_FFF_C0RE_RW__A 0x2030015
3922#define ORX_EQU_FFF_C0RE_RW__W 12
3923#define ORX_EQU_FFF_C0RE_RW__M 0xFFF
3924#define ORX_EQU_FFF_C0RE_RW__PRE 0x0
3925
3926#define ORX_EQU_FFF_C0IM_RW__A 0x2030016
3927#define ORX_EQU_FFF_C0IM_RW__W 12
3928#define ORX_EQU_FFF_C0IM_RW__M 0xFFF
3929#define ORX_EQU_FFF_C0IM_RW__PRE 0x0
3930
3931#define ORX_EQU_FFF_C1RE_RW__A 0x2030017
3932#define ORX_EQU_FFF_C1RE_RW__W 12
3933#define ORX_EQU_FFF_C1RE_RW__M 0xFFF
3934#define ORX_EQU_FFF_C1RE_RW__PRE 0x0
3935
3936#define ORX_EQU_FFF_C1IM_RW__A 0x2030018
3937#define ORX_EQU_FFF_C1IM_RW__W 12
3938#define ORX_EQU_FFF_C1IM_RW__M 0xFFF
3939#define ORX_EQU_FFF_C1IM_RW__PRE 0x0
3940
3941#define ORX_EQU_FFF_C2RE_RW__A 0x2030019
3942#define ORX_EQU_FFF_C2RE_RW__W 12
3943#define ORX_EQU_FFF_C2RE_RW__M 0xFFF
3944#define ORX_EQU_FFF_C2RE_RW__PRE 0x0
3945
3946#define ORX_EQU_FFF_C2IM_RW__A 0x203001A
3947#define ORX_EQU_FFF_C2IM_RW__W 12
3948#define ORX_EQU_FFF_C2IM_RW__M 0xFFF
3949#define ORX_EQU_FFF_C2IM_RW__PRE 0x0
3950
3951#define ORX_EQU_FFF_C3RE_RW__A 0x203001B
3952#define ORX_EQU_FFF_C3RE_RW__W 12
3953#define ORX_EQU_FFF_C3RE_RW__M 0xFFF
3954#define ORX_EQU_FFF_C3RE_RW__PRE 0x0
3955
3956#define ORX_EQU_FFF_C3IM_RW__A 0x203001C
3957#define ORX_EQU_FFF_C3IM_RW__W 12
3958#define ORX_EQU_FFF_C3IM_RW__M 0xFFF
3959#define ORX_EQU_FFF_C3IM_RW__PRE 0x0
3960
3961#define ORX_EQU_FFF_C4RE_RW__A 0x203001D
3962#define ORX_EQU_FFF_C4RE_RW__W 12
3963#define ORX_EQU_FFF_C4RE_RW__M 0xFFF
3964#define ORX_EQU_FFF_C4RE_RW__PRE 0x400
3965
3966#define ORX_EQU_FFF_C4IM_RW__A 0x203001E
3967#define ORX_EQU_FFF_C4IM_RW__W 12
3968#define ORX_EQU_FFF_C4IM_RW__M 0xFFF
3969#define ORX_EQU_FFF_C4IM_RW__PRE 0x0
3970
3971#define ORX_EQU_FFF_C5RE_RW__A 0x203001F
3972#define ORX_EQU_FFF_C5RE_RW__W 12
3973#define ORX_EQU_FFF_C5RE_RW__M 0xFFF
3974#define ORX_EQU_FFF_C5RE_RW__PRE 0x0
3975
3976#define ORX_EQU_FFF_C5IM_RW__A 0x2030020
3977#define ORX_EQU_FFF_C5IM_RW__W 12
3978#define ORX_EQU_FFF_C5IM_RW__M 0xFFF
3979#define ORX_EQU_FFF_C5IM_RW__PRE 0x0
3980
3981#define ORX_EQU_FFF_C6RE_RW__A 0x2030021
3982#define ORX_EQU_FFF_C6RE_RW__W 12
3983#define ORX_EQU_FFF_C6RE_RW__M 0xFFF
3984#define ORX_EQU_FFF_C6RE_RW__PRE 0x0
3985
3986#define ORX_EQU_FFF_C6IM_RW__A 0x2030022
3987#define ORX_EQU_FFF_C6IM_RW__W 12
3988#define ORX_EQU_FFF_C6IM_RW__M 0xFFF
3989#define ORX_EQU_FFF_C6IM_RW__PRE 0x0
3990
3991#define ORX_EQU_FFF_C7RE_RW__A 0x2030023
3992#define ORX_EQU_FFF_C7RE_RW__W 12
3993#define ORX_EQU_FFF_C7RE_RW__M 0xFFF
3994#define ORX_EQU_FFF_C7RE_RW__PRE 0x0
3995
3996#define ORX_EQU_FFF_C7IM_RW__A 0x2030024
3997#define ORX_EQU_FFF_C7IM_RW__W 12
3998#define ORX_EQU_FFF_C7IM_RW__M 0xFFF
3999#define ORX_EQU_FFF_C7IM_RW__PRE 0x0
4000
4001#define ORX_EQU_FFF_C8RE_RW__A 0x2030025
4002#define ORX_EQU_FFF_C8RE_RW__W 12
4003#define ORX_EQU_FFF_C8RE_RW__M 0xFFF
4004#define ORX_EQU_FFF_C8RE_RW__PRE 0x0
4005
4006#define ORX_EQU_FFF_C8IM_RW__A 0x2030026
4007#define ORX_EQU_FFF_C8IM_RW__W 12
4008#define ORX_EQU_FFF_C8IM_RW__M 0xFFF
4009#define ORX_EQU_FFF_C8IM_RW__PRE 0x0
4010
4011#define ORX_EQU_FFF_C9RE_RW__A 0x2030027
4012#define ORX_EQU_FFF_C9RE_RW__W 12
4013#define ORX_EQU_FFF_C9RE_RW__M 0xFFF
4014#define ORX_EQU_FFF_C9RE_RW__PRE 0x0
4015
4016#define ORX_EQU_FFF_C9IM_RW__A 0x2030028
4017#define ORX_EQU_FFF_C9IM_RW__W 12
4018#define ORX_EQU_FFF_C9IM_RW__M 0xFFF
4019#define ORX_EQU_FFF_C9IM_RW__PRE 0x0
4020
4021#define ORX_EQU_FFF_C10RE_RW__A 0x2030029
4022#define ORX_EQU_FFF_C10RE_RW__W 12
4023#define ORX_EQU_FFF_C10RE_RW__M 0xFFF
4024#define ORX_EQU_FFF_C10RE_RW__PRE 0x0
4025
4026#define ORX_EQU_FFF_C10IM_RW__A 0x203002A
4027#define ORX_EQU_FFF_C10IM_RW__W 12
4028#define ORX_EQU_FFF_C10IM_RW__M 0xFFF
4029#define ORX_EQU_FFF_C10IM_RW__PRE 0x0
4030
4031#define ORX_EQU_MXB_SEL_W__A 0x203002B
4032#define ORX_EQU_MXB_SEL_W__W 1
4033#define ORX_EQU_MXB_SEL_W__M 0x1
4034#define ORX_EQU_MXB_SEL_W__PRE 0x0
4035#define ORX_EQU_MXB_SEL_W_UNDECIDED_SYMBOLS 0x0
4036#define ORX_EQU_MXB_SEL_W_DECIDED_SYMBOLS 0x1
4037
4038#define ORX_EQU_FBF_UPD_W__A 0x203002C
4039#define ORX_EQU_FBF_UPD_W__W 1
4040#define ORX_EQU_FBF_UPD_W__M 0x1
4041#define ORX_EQU_FBF_UPD_W__PRE 0x0
4042#define ORX_EQU_FBF_UPD_W_NO_UPDATE 0x0
4043#define ORX_EQU_FBF_UPD_W_LMS_UPDATE 0x1
4044
4045#define ORX_EQU_FBF_STP_W__A 0x203002D
4046#define ORX_EQU_FBF_STP_W__W 3
4047#define ORX_EQU_FBF_STP_W__M 0x7
4048#define ORX_EQU_FBF_STP_W__PRE 0x2
4049
4050#define ORX_EQU_FBF_LEA_W__A 0x203002E
4051#define ORX_EQU_FBF_LEA_W__W 4
4052#define ORX_EQU_FBF_LEA_W__M 0xF
4053#define ORX_EQU_FBF_LEA_W__PRE 0x4
4054
4055#define ORX_EQU_FBF_RWT_W__A 0x203002F
4056#define ORX_EQU_FBF_RWT_W__W 2
4057#define ORX_EQU_FBF_RWT_W__M 0x3
4058#define ORX_EQU_FBF_RWT_W__PRE 0x0
4059
4060#define ORX_EQU_FBF_C0RE_RW__A 0x2030030
4061#define ORX_EQU_FBF_C0RE_RW__W 12
4062#define ORX_EQU_FBF_C0RE_RW__M 0xFFF
4063#define ORX_EQU_FBF_C0RE_RW__PRE 0x0
4064
4065#define ORX_EQU_FBF_C0IM_RW__A 0x2030031
4066#define ORX_EQU_FBF_C0IM_RW__W 12
4067#define ORX_EQU_FBF_C0IM_RW__M 0xFFF
4068#define ORX_EQU_FBF_C0IM_RW__PRE 0x0
4069
4070#define ORX_EQU_FBF_C1RE_RW__A 0x2030032
4071#define ORX_EQU_FBF_C1RE_RW__W 12
4072#define ORX_EQU_FBF_C1RE_RW__M 0xFFF
4073#define ORX_EQU_FBF_C1RE_RW__PRE 0x0
4074
4075#define ORX_EQU_FBF_C1IM_RW__A 0x2030033
4076#define ORX_EQU_FBF_C1IM_RW__W 12
4077#define ORX_EQU_FBF_C1IM_RW__M 0xFFF
4078#define ORX_EQU_FBF_C1IM_RW__PRE 0x0
4079
4080#define ORX_EQU_FBF_C2RE_RW__A 0x2030034
4081#define ORX_EQU_FBF_C2RE_RW__W 12
4082#define ORX_EQU_FBF_C2RE_RW__M 0xFFF
4083#define ORX_EQU_FBF_C2RE_RW__PRE 0x0
4084
4085#define ORX_EQU_FBF_C2IM_RW__A 0x2030035
4086#define ORX_EQU_FBF_C2IM_RW__W 12
4087#define ORX_EQU_FBF_C2IM_RW__M 0xFFF
4088#define ORX_EQU_FBF_C2IM_RW__PRE 0x0
4089
4090#define ORX_EQU_FBF_C3RE_RW__A 0x2030036
4091#define ORX_EQU_FBF_C3RE_RW__W 12
4092#define ORX_EQU_FBF_C3RE_RW__M 0xFFF
4093#define ORX_EQU_FBF_C3RE_RW__PRE 0x0
4094
4095#define ORX_EQU_FBF_C3IM_RW__A 0x2030037
4096#define ORX_EQU_FBF_C3IM_RW__W 12
4097#define ORX_EQU_FBF_C3IM_RW__M 0xFFF
4098#define ORX_EQU_FBF_C3IM_RW__PRE 0x0
4099
4100#define ORX_EQU_FBF_C4RE_RW__A 0x2030038
4101#define ORX_EQU_FBF_C4RE_RW__W 12
4102#define ORX_EQU_FBF_C4RE_RW__M 0xFFF
4103#define ORX_EQU_FBF_C4RE_RW__PRE 0x0
4104
4105#define ORX_EQU_FBF_C4IM_RW__A 0x2030039
4106#define ORX_EQU_FBF_C4IM_RW__W 12
4107#define ORX_EQU_FBF_C4IM_RW__M 0xFFF
4108#define ORX_EQU_FBF_C4IM_RW__PRE 0x0
4109
4110#define ORX_EQU_FBF_C5RE_RW__A 0x203003A
4111#define ORX_EQU_FBF_C5RE_RW__W 12
4112#define ORX_EQU_FBF_C5RE_RW__M 0xFFF
4113#define ORX_EQU_FBF_C5RE_RW__PRE 0x0
4114
4115#define ORX_EQU_FBF_C5IM_RW__A 0x203003B
4116#define ORX_EQU_FBF_C5IM_RW__W 12
4117#define ORX_EQU_FBF_C5IM_RW__M 0xFFF
4118#define ORX_EQU_FBF_C5IM_RW__PRE 0x0
4119
4120#define ORX_EQU_ERR_SEL_W__A 0x203003C
4121#define ORX_EQU_ERR_SEL_W__W 1
4122#define ORX_EQU_ERR_SEL_W__M 0x1
4123#define ORX_EQU_ERR_SEL_W__PRE 0x0
4124#define ORX_EQU_ERR_SEL_W_CMA_ERROR 0x0
4125#define ORX_EQU_ERR_SEL_W_DDA_ERROR 0x1
4126
4127#define ORX_EQU_ERR_TIS_W__A 0x203003D
4128#define ORX_EQU_ERR_TIS_W__W 1
4129#define ORX_EQU_ERR_TIS_W__M 0x1
4130#define ORX_EQU_ERR_TIS_W__PRE 0x0
4131#define ORX_EQU_ERR_TIS_W_CMA_SIGNALS 0x0
4132#define ORX_EQU_ERR_TIS_W_DDA_SIGNALS 0x1
4133
4134#define ORX_EQU_ERR_EDI_R__A 0x203003E
4135#define ORX_EQU_ERR_EDI_R__W 5
4136#define ORX_EQU_ERR_EDI_R__M 0x1F
4137#define ORX_EQU_ERR_EDI_R__PRE 0xF
4138
4139#define ORX_EQU_ERR_EDQ_R__A 0x203003F
4140#define ORX_EQU_ERR_EDQ_R__W 5
4141#define ORX_EQU_ERR_EDQ_R__M 0x1F
4142#define ORX_EQU_ERR_EDQ_R__PRE 0xF
4143
4144#define ORX_EQU_ERR_ECI_R__A 0x2030040
4145#define ORX_EQU_ERR_ECI_R__W 5
4146#define ORX_EQU_ERR_ECI_R__M 0x1F
4147#define ORX_EQU_ERR_ECI_R__PRE 0xF
4148
4149#define ORX_EQU_ERR_ECQ_R__A 0x2030041
4150#define ORX_EQU_ERR_ECQ_R__W 5
4151#define ORX_EQU_ERR_ECQ_R__M 0x1F
4152#define ORX_EQU_ERR_ECQ_R__PRE 0xF
4153
4154#define ORX_EQU_MER_MER_R__A 0x2030042
4155#define ORX_EQU_MER_MER_R__W 6
4156#define ORX_EQU_MER_MER_R__M 0x3F
4157#define ORX_EQU_MER_MER_R__PRE 0x3F
4158
4159#define ORX_EQU_MER_LDT_W__A 0x2030043
4160#define ORX_EQU_MER_LDT_W__W 3
4161#define ORX_EQU_MER_LDT_W__M 0x7
4162#define ORX_EQU_MER_LDT_W__PRE 0x4
4163
4164#define ORX_EQU_SYN_LEN_W__A 0x2030044
4165#define ORX_EQU_SYN_LEN_W__W 16
4166#define ORX_EQU_SYN_LEN_W__M 0xFFFF
4167#define ORX_EQU_SYN_LEN_W__PRE 0x0
4168
4169#define ORX_DDC_COMM_EXEC__A 0x2040000
4170#define ORX_DDC_COMM_EXEC__W 2
4171#define ORX_DDC_COMM_EXEC__M 0x3
4172#define ORX_DDC_COMM_EXEC__PRE 0x0
4173#define ORX_DDC_COMM_EXEC_STOP 0x0
4174#define ORX_DDC_COMM_EXEC_ACTIVE 0x1
4175#define ORX_DDC_COMM_EXEC_HOLD 0x2
4176
4177#define ORX_DDC_COMM_MB__A 0x2040002
4178#define ORX_DDC_COMM_MB__W 6
4179#define ORX_DDC_COMM_MB__M 0x3F
4180#define ORX_DDC_COMM_MB__PRE 0x0
4181#define ORX_DDC_COMM_MB_CTL__B 0
4182#define ORX_DDC_COMM_MB_CTL__W 1
4183#define ORX_DDC_COMM_MB_CTL__M 0x1
4184#define ORX_DDC_COMM_MB_CTL__PRE 0x0
4185#define ORX_DDC_COMM_MB_CTL_OFF 0x0
4186#define ORX_DDC_COMM_MB_CTL_ON 0x1
4187#define ORX_DDC_COMM_MB_OBS__B 1
4188#define ORX_DDC_COMM_MB_OBS__W 1
4189#define ORX_DDC_COMM_MB_OBS__M 0x2
4190#define ORX_DDC_COMM_MB_OBS__PRE 0x0
4191#define ORX_DDC_COMM_MB_OBS_OFF 0x0
4192#define ORX_DDC_COMM_MB_OBS_ON 0x2
4193
4194#define ORX_DDC_COMM_MB_CTL_MUX__B 2
4195#define ORX_DDC_COMM_MB_CTL_MUX__W 2
4196#define ORX_DDC_COMM_MB_CTL_MUX__M 0xC
4197#define ORX_DDC_COMM_MB_CTL_MUX__PRE 0x0
4198
4199#define ORX_DDC_COMM_MB_OBS_MUX__B 4
4200#define ORX_DDC_COMM_MB_OBS_MUX__W 2
4201#define ORX_DDC_COMM_MB_OBS_MUX__M 0x30
4202#define ORX_DDC_COMM_MB_OBS_MUX__PRE 0x0
4203
4204#define ORX_DDC_COMM_INT_REQ__A 0x2040003
4205#define ORX_DDC_COMM_INT_REQ__W 1
4206#define ORX_DDC_COMM_INT_REQ__M 0x1
4207#define ORX_DDC_COMM_INT_REQ__PRE 0x0
4208#define ORX_DDC_COMM_INT_STA__A 0x2040005
4209#define ORX_DDC_COMM_INT_STA__W 1
4210#define ORX_DDC_COMM_INT_STA__M 0x1
4211#define ORX_DDC_COMM_INT_STA__PRE 0x0
4212#define ORX_DDC_COMM_INT_MSK__A 0x2040006
4213#define ORX_DDC_COMM_INT_MSK__W 1
4214#define ORX_DDC_COMM_INT_MSK__M 0x1
4215#define ORX_DDC_COMM_INT_MSK__PRE 0x0
4216#define ORX_DDC_COMM_INT_STM__A 0x2040007
4217#define ORX_DDC_COMM_INT_STM__W 1
4218#define ORX_DDC_COMM_INT_STM__M 0x1
4219#define ORX_DDC_COMM_INT_STM__PRE 0x0
4220#define ORX_DDC_DEC_MAP_W__A 0x2040010
4221#define ORX_DDC_DEC_MAP_W__W 9
4222#define ORX_DDC_DEC_MAP_W__M 0x1FF
4223#define ORX_DDC_DEC_MAP_W__PRE 0x178
4224
4225#define ORX_DDC_DEC_MAP_W_QUADR0__B 0
4226#define ORX_DDC_DEC_MAP_W_QUADR0__W 2
4227#define ORX_DDC_DEC_MAP_W_QUADR0__M 0x3
4228#define ORX_DDC_DEC_MAP_W_QUADR0__PRE 0x0
4229#define ORX_DDC_DEC_MAP_W_QUADR0_ROTATE_DEFAULT 0x0
4230#define ORX_DDC_DEC_MAP_W_QUADR0_ROTATE_ALTERNATE 0x0
4231
4232#define ORX_DDC_DEC_MAP_W_QUADR1__B 2
4233#define ORX_DDC_DEC_MAP_W_QUADR1__W 2
4234#define ORX_DDC_DEC_MAP_W_QUADR1__M 0xC
4235#define ORX_DDC_DEC_MAP_W_QUADR1__PRE 0x8
4236#define ORX_DDC_DEC_MAP_W_QUADR1_ROTATE_DEFAULT 0x8
4237#define ORX_DDC_DEC_MAP_W_QUADR1_ROTATE_ALTERNATE 0x4
4238
4239#define ORX_DDC_DEC_MAP_W_QUADR2__B 4
4240#define ORX_DDC_DEC_MAP_W_QUADR2__W 2
4241#define ORX_DDC_DEC_MAP_W_QUADR2__M 0x30
4242#define ORX_DDC_DEC_MAP_W_QUADR2__PRE 0x30
4243#define ORX_DDC_DEC_MAP_W_QUADR2_ROTATE_DEFAULT 0x30
4244#define ORX_DDC_DEC_MAP_W_QUADR2_ROTATE_ALTERNATE 0x30
4245
4246#define ORX_DDC_DEC_MAP_W_QUADR3__B 6
4247#define ORX_DDC_DEC_MAP_W_QUADR3__W 2
4248#define ORX_DDC_DEC_MAP_W_QUADR3__M 0xC0
4249#define ORX_DDC_DEC_MAP_W_QUADR3__PRE 0x40
4250#define ORX_DDC_DEC_MAP_W_QUADR3_ROTATE_DEFAULT 0x40
4251#define ORX_DDC_DEC_MAP_W_QUADR3_ROTATE_ALTERNATE 0x80
4252#define ORX_DDC_DEC_MAP_W_DIFF_DECOD__B 8
4253#define ORX_DDC_DEC_MAP_W_DIFF_DECOD__W 1
4254#define ORX_DDC_DEC_MAP_W_DIFF_DECOD__M 0x100
4255#define ORX_DDC_DEC_MAP_W_DIFF_DECOD__PRE 0x100
4256#define ORX_DDC_DEC_MAP_W_DIFF_DECOD_COHERENT_DECODING 0x0
4257#define ORX_DDC_DEC_MAP_W_DIFF_DECOD_DIFF_DECODING 0x100
4258
4259#define ORX_DDC_OFO_SET_W__A 0x2040011
4260#define ORX_DDC_OFO_SET_W__W 16
4261#define ORX_DDC_OFO_SET_W__M 0xFFFF
4262#define ORX_DDC_OFO_SET_W__PRE 0x1402
4263
4264#define ORX_DDC_OFO_SET_W_PHASE__B 0
4265#define ORX_DDC_OFO_SET_W_PHASE__W 7
4266#define ORX_DDC_OFO_SET_W_PHASE__M 0x7F
4267#define ORX_DDC_OFO_SET_W_PHASE__PRE 0x2
4268
4269#define ORX_DDC_OFO_SET_W_CRXHITIME__B 7
4270#define ORX_DDC_OFO_SET_W_CRXHITIME__W 7
4271#define ORX_DDC_OFO_SET_W_CRXHITIME__M 0x3F80
4272#define ORX_DDC_OFO_SET_W_CRXHITIME__PRE 0x1400
4273
4274#define ORX_DDC_OFO_SET_W_CRXINV__B 14
4275#define ORX_DDC_OFO_SET_W_CRXINV__W 1
4276#define ORX_DDC_OFO_SET_W_CRXINV__M 0x4000
4277#define ORX_DDC_OFO_SET_W_CRXINV__PRE 0x0
4278
4279#define ORX_DDC_OFO_SET_W_DISABLE__B 15
4280#define ORX_DDC_OFO_SET_W_DISABLE__W 1
4281#define ORX_DDC_OFO_SET_W_DISABLE__M 0x8000
4282#define ORX_DDC_OFO_SET_W_DISABLE__PRE 0x0
4283
4284#define ORX_CON_COMM_EXEC__A 0x2050000
4285#define ORX_CON_COMM_EXEC__W 2
4286#define ORX_CON_COMM_EXEC__M 0x3
4287#define ORX_CON_COMM_EXEC__PRE 0x0
4288#define ORX_CON_COMM_EXEC_STOP 0x0
4289#define ORX_CON_COMM_EXEC_ACTIVE 0x1
4290#define ORX_CON_COMM_EXEC_HOLD 0x2
4291
4292#define ORX_CON_LDT_W__A 0x2050010
4293#define ORX_CON_LDT_W__W 3
4294#define ORX_CON_LDT_W__M 0x7
4295#define ORX_CON_LDT_W__PRE 0x3
4296
4297#define ORX_CON_LDT_W_CON_LDT_W__B 0
4298#define ORX_CON_LDT_W_CON_LDT_W__W 3
4299#define ORX_CON_LDT_W_CON_LDT_W__M 0x7
4300#define ORX_CON_LDT_W_CON_LDT_W__PRE 0x3
4301
4302#define ORX_CON_RST_W__A 0x2050011
4303#define ORX_CON_RST_W__W 4
4304#define ORX_CON_RST_W__M 0xF
4305#define ORX_CON_RST_W__PRE 0x0
4306
4307#define ORX_CON_RST_W_CPH__B 0
4308#define ORX_CON_RST_W_CPH__W 1
4309#define ORX_CON_RST_W_CPH__M 0x1
4310#define ORX_CON_RST_W_CPH__PRE 0x0
4311
4312#define ORX_CON_RST_W_CTI__B 1
4313#define ORX_CON_RST_W_CTI__W 1
4314#define ORX_CON_RST_W_CTI__M 0x2
4315#define ORX_CON_RST_W_CTI__PRE 0x0
4316
4317#define ORX_CON_RST_W_KRN__B 2
4318#define ORX_CON_RST_W_KRN__W 1
4319#define ORX_CON_RST_W_KRN__M 0x4
4320#define ORX_CON_RST_W_KRN__PRE 0x0
4321
4322#define ORX_CON_RST_W_KRP__B 3
4323#define ORX_CON_RST_W_KRP__W 1
4324#define ORX_CON_RST_W_KRP__M 0x8
4325#define ORX_CON_RST_W_KRP__PRE 0x0
4326
4327#define ORX_CON_CPH_PHI_R__A 0x2050012
4328#define ORX_CON_CPH_PHI_R__W 16
4329#define ORX_CON_CPH_PHI_R__M 0xFFFF
4330#define ORX_CON_CPH_PHI_R__PRE 0x0
4331
4332#define ORX_CON_CPH_FRQ_R__A 0x2050013
4333#define ORX_CON_CPH_FRQ_R__W 16
4334#define ORX_CON_CPH_FRQ_R__M 0xFFFF
4335#define ORX_CON_CPH_FRQ_R__PRE 0x0
4336
4337#define ORX_CON_CPH_AMP_R__A 0x2050014
4338#define ORX_CON_CPH_AMP_R__W 16
4339#define ORX_CON_CPH_AMP_R__M 0xFFFF
4340#define ORX_CON_CPH_AMP_R__PRE 0x0
4341
4342#define ORX_CON_CPH_KDF_W__A 0x2050015
4343#define ORX_CON_CPH_KDF_W__W 4
4344#define ORX_CON_CPH_KDF_W__M 0xF
4345#define ORX_CON_CPH_KDF_W__PRE 0x0
4346
4347#define ORX_CON_CPH_KPF_W__A 0x2050016
4348#define ORX_CON_CPH_KPF_W__W 4
4349#define ORX_CON_CPH_KPF_W__M 0xF
4350#define ORX_CON_CPH_KPF_W__PRE 0x0
4351
4352#define ORX_CON_CPH_KIF_W__A 0x2050017
4353#define ORX_CON_CPH_KIF_W__W 4
4354#define ORX_CON_CPH_KIF_W__M 0xF
4355#define ORX_CON_CPH_KIF_W__PRE 0x0
4356#define ORX_CON_CPH_APT_W__A 0x2050018
4357#define ORX_CON_CPH_APT_W__W 16
4358#define ORX_CON_CPH_APT_W__M 0xFFFF
4359#define ORX_CON_CPH_APT_W__PRE 0x804
4360
4361#define ORX_CON_CPH_APT_W_PTH__B 0
4362#define ORX_CON_CPH_APT_W_PTH__W 8
4363#define ORX_CON_CPH_APT_W_PTH__M 0xFF
4364#define ORX_CON_CPH_APT_W_PTH__PRE 0x4
4365
4366#define ORX_CON_CPH_APT_W_ATH__B 8
4367#define ORX_CON_CPH_APT_W_ATH__W 8
4368#define ORX_CON_CPH_APT_W_ATH__M 0xFF00
4369#define ORX_CON_CPH_APT_W_ATH__PRE 0x800
4370
4371#define ORX_CON_CPH_WLC_W__A 0x2050019
4372#define ORX_CON_CPH_WLC_W__W 8
4373#define ORX_CON_CPH_WLC_W__M 0xFF
4374#define ORX_CON_CPH_WLC_W__PRE 0x81
4375
4376#define ORX_CON_CPH_WLC_W_LATC__B 0
4377#define ORX_CON_CPH_WLC_W_LATC__W 4
4378#define ORX_CON_CPH_WLC_W_LATC__M 0xF
4379#define ORX_CON_CPH_WLC_W_LATC__PRE 0x1
4380
4381#define ORX_CON_CPH_WLC_W_WLIM__B 4
4382#define ORX_CON_CPH_WLC_W_WLIM__W 4
4383#define ORX_CON_CPH_WLC_W_WLIM__M 0xF0
4384#define ORX_CON_CPH_WLC_W_WLIM__PRE 0x80
4385
4386#define ORX_CON_CPH_DLY_W__A 0x205001A
4387#define ORX_CON_CPH_DLY_W__W 3
4388#define ORX_CON_CPH_DLY_W__M 0x7
4389#define ORX_CON_CPH_DLY_W__PRE 0x4
4390
4391#define ORX_CON_CPH_TCL_W__A 0x205001B
4392#define ORX_CON_CPH_TCL_W__W 3
4393#define ORX_CON_CPH_TCL_W__M 0x7
4394#define ORX_CON_CPH_TCL_W__PRE 0x3
4395
4396#define ORX_CON_KRP_AMP_R__A 0x205001C
4397#define ORX_CON_KRP_AMP_R__W 9
4398#define ORX_CON_KRP_AMP_R__M 0x1FF
4399#define ORX_CON_KRP_AMP_R__PRE 0x0
4400
4401#define ORX_CON_KRN_AMP_R__A 0x205001D
4402#define ORX_CON_KRN_AMP_R__W 9
4403#define ORX_CON_KRN_AMP_R__M 0x1FF
4404#define ORX_CON_KRN_AMP_R__PRE 0x0
4405
4406#define ORX_CON_CTI_DTI_R__A 0x205001E
4407#define ORX_CON_CTI_DTI_R__W 16
4408#define ORX_CON_CTI_DTI_R__M 0xFFFF
4409#define ORX_CON_CTI_DTI_R__PRE 0x0
4410
4411#define ORX_CON_CTI_KDT_W__A 0x205001F
4412#define ORX_CON_CTI_KDT_W__W 4
4413#define ORX_CON_CTI_KDT_W__M 0xF
4414#define ORX_CON_CTI_KDT_W__PRE 0x4
4415
4416#define ORX_CON_CTI_KPT_W__A 0x2050020
4417#define ORX_CON_CTI_KPT_W__W 4
4418#define ORX_CON_CTI_KPT_W__M 0xF
4419#define ORX_CON_CTI_KPT_W__PRE 0x3
4420
4421#define ORX_CON_CTI_KIT_W__A 0x2050021
4422#define ORX_CON_CTI_KIT_W__W 4
4423#define ORX_CON_CTI_KIT_W__M 0xF
4424#define ORX_CON_CTI_KIT_W__PRE 0xB
4425
4426#define ORX_CON_CTI_TAT_W__A 0x2050022
4427#define ORX_CON_CTI_TAT_W__W 4
4428#define ORX_CON_CTI_TAT_W__M 0xF
4429#define ORX_CON_CTI_TAT_W__PRE 0x3
4430
4431#define ORX_NSU_COMM_EXEC__A 0x2060000
4432#define ORX_NSU_COMM_EXEC__W 2
4433#define ORX_NSU_COMM_EXEC__M 0x3
4434#define ORX_NSU_COMM_EXEC__PRE 0x0
4435#define ORX_NSU_COMM_EXEC_STOP 0x0
4436#define ORX_NSU_COMM_EXEC_ACTIVE 0x1
4437#define ORX_NSU_COMM_EXEC_HOLD 0x2
4438
4439#define ORX_NSU_AOX_STDBY_W__A 0x2060010
4440#define ORX_NSU_AOX_STDBY_W__W 8
4441#define ORX_NSU_AOX_STDBY_W__M 0xFF
4442#define ORX_NSU_AOX_STDBY_W__PRE 0x0
4443
4444#define ORX_NSU_AOX_STDBY_W_STDBYADC__B 0
4445#define ORX_NSU_AOX_STDBY_W_STDBYADC__W 1
4446#define ORX_NSU_AOX_STDBY_W_STDBYADC__M 0x1
4447#define ORX_NSU_AOX_STDBY_W_STDBYADC__PRE 0x0
4448#define ORX_NSU_AOX_STDBY_W_STDBYADC_A1_ON 0x0
4449#define ORX_NSU_AOX_STDBY_W_STDBYADC_A1_OFF 0x1
4450#define ORX_NSU_AOX_STDBY_W_STDBYADC_A2_OFF 0x0
4451#define ORX_NSU_AOX_STDBY_W_STDBYADC_A2_ON 0x1
4452
4453#define ORX_NSU_AOX_STDBY_W_STDBYAMP__B 1
4454#define ORX_NSU_AOX_STDBY_W_STDBYAMP__W 1
4455#define ORX_NSU_AOX_STDBY_W_STDBYAMP__M 0x2
4456#define ORX_NSU_AOX_STDBY_W_STDBYAMP__PRE 0x0
4457#define ORX_NSU_AOX_STDBY_W_STDBYAMP_A1_ON 0x0
4458#define ORX_NSU_AOX_STDBY_W_STDBYAMP_A1_OFF 0x2
4459#define ORX_NSU_AOX_STDBY_W_STDBYAMP_A2_OFF 0x0
4460#define ORX_NSU_AOX_STDBY_W_STDBYAMP_A2_ON 0x2
4461
4462#define ORX_NSU_AOX_STDBY_W_STDBYBIAS__B 2
4463#define ORX_NSU_AOX_STDBY_W_STDBYBIAS__W 1
4464#define ORX_NSU_AOX_STDBY_W_STDBYBIAS__M 0x4
4465#define ORX_NSU_AOX_STDBY_W_STDBYBIAS__PRE 0x0
4466#define ORX_NSU_AOX_STDBY_W_STDBYBIAS_A1_ON 0x0
4467#define ORX_NSU_AOX_STDBY_W_STDBYBIAS_A1_OFF 0x4
4468#define ORX_NSU_AOX_STDBY_W_STDBYBIAS_A2_OFF 0x0
4469#define ORX_NSU_AOX_STDBY_W_STDBYBIAS_A2_ON 0x4
4470
4471#define ORX_NSU_AOX_STDBY_W_STDBYPLL__B 3
4472#define ORX_NSU_AOX_STDBY_W_STDBYPLL__W 1
4473#define ORX_NSU_AOX_STDBY_W_STDBYPLL__M 0x8
4474#define ORX_NSU_AOX_STDBY_W_STDBYPLL__PRE 0x0
4475#define ORX_NSU_AOX_STDBY_W_STDBYPLL_A1_ON 0x0
4476#define ORX_NSU_AOX_STDBY_W_STDBYPLL_A1_OFF 0x8
4477#define ORX_NSU_AOX_STDBY_W_STDBYPLL_A2_OFF 0x0
4478#define ORX_NSU_AOX_STDBY_W_STDBYPLL_A2_ON 0x8
4479
4480#define ORX_NSU_AOX_STDBY_W_STDBYPD__B 4
4481#define ORX_NSU_AOX_STDBY_W_STDBYPD__W 1
4482#define ORX_NSU_AOX_STDBY_W_STDBYPD__M 0x10
4483#define ORX_NSU_AOX_STDBY_W_STDBYPD__PRE 0x0
4484#define ORX_NSU_AOX_STDBY_W_STDBYPD_A1_ON 0x0
4485#define ORX_NSU_AOX_STDBY_W_STDBYPD_A1_OFF 0x10
4486#define ORX_NSU_AOX_STDBY_W_STDBYPD_A2_OFF 0x0
4487#define ORX_NSU_AOX_STDBY_W_STDBYPD_A2_ON 0x10
4488
4489#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_IF__B 5
4490#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_IF__W 1
4491#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_IF__M 0x20
4492#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_IF__PRE 0x0
4493#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_IF_A1_ON 0x0
4494#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_IF_A1_OFF 0x20
4495#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_IF_A2_OFF 0x0
4496#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_IF_A2_ON 0x20
4497
4498#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_RF__B 6
4499#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_RF__W 1
4500#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_RF__M 0x40
4501#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_RF__PRE 0x0
4502#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_RF_A1_ON 0x0
4503#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_RF_A1_OFF 0x40
4504#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_RF_A2_OFF 0x0
4505#define ORX_NSU_AOX_STDBY_W_STDBYTAGC_RF_A2_ON 0x40
4506
4507#define ORX_NSU_AOX_STDBY_W_STDBYFLT__B 7
4508#define ORX_NSU_AOX_STDBY_W_STDBYFLT__W 1
4509#define ORX_NSU_AOX_STDBY_W_STDBYFLT__M 0x80
4510#define ORX_NSU_AOX_STDBY_W_STDBYFLT__PRE 0x0
4511#define ORX_NSU_AOX_STDBY_W_STDBYFLT_A1_ON 0x0
4512#define ORX_NSU_AOX_STDBY_W_STDBYFLT_A1_OFF 0x80
4513#define ORX_NSU_AOX_STDBY_W_STDBYFLT_A2_OFF 0x0
4514#define ORX_NSU_AOX_STDBY_W_STDBYFLT_A2_ON 0x80
4515
4516#define ORX_NSU_AOX_LOFRQ_W__A 0x2060011
4517#define ORX_NSU_AOX_LOFRQ_W__W 16
4518#define ORX_NSU_AOX_LOFRQ_W__M 0xFFFF
4519#define ORX_NSU_AOX_LOFRQ_W__PRE 0x0
4520#define ORX_NSU_AOX_LOMDE_W__A 0x2060012
4521#define ORX_NSU_AOX_LOMDE_W__W 16
4522#define ORX_NSU_AOX_LOMDE_W__M 0xFFFF
4523#define ORX_NSU_AOX_LOMDE_W__PRE 0x0
4524
4525#define ORX_NSU_AOX_LOMDE_W_AOX_LOFRQ_EXT__B 0
4526#define ORX_NSU_AOX_LOMDE_W_AOX_LOFRQ_EXT__W 8
4527#define ORX_NSU_AOX_LOMDE_W_AOX_LOFRQ_EXT__M 0xFF
4528#define ORX_NSU_AOX_LOMDE_W_AOX_LOFRQ_EXT__PRE 0x0
4529
4530#define ORX_NSU_AOX_LOMDE_W_RESET_VCO__B 13
4531#define ORX_NSU_AOX_LOMDE_W_RESET_VCO__W 1
4532#define ORX_NSU_AOX_LOMDE_W_RESET_VCO__M 0x2000
4533#define ORX_NSU_AOX_LOMDE_W_RESET_VCO__PRE 0x0
4534
4535#define ORX_NSU_AOX_LOMDE_W_PLL_DIV__B 14
4536#define ORX_NSU_AOX_LOMDE_W_PLL_DIV__W 2
4537#define ORX_NSU_AOX_LOMDE_W_PLL_DIV__M 0xC000
4538#define ORX_NSU_AOX_LOMDE_W_PLL_DIV__PRE 0x0
4539
4540#define ORX_NSU_AOX_LOPOW_W__A 0x2060013
4541#define ORX_NSU_AOX_LOPOW_W__W 2
4542#define ORX_NSU_AOX_LOPOW_W__M 0x3
4543#define ORX_NSU_AOX_LOPOW_W__PRE 0x0
4544#define ORX_NSU_AOX_LOPOW_W_POWER_MINUS0DB 0x0
4545#define ORX_NSU_AOX_LOPOW_W_POWER_MINUS5DB 0x1
4546#define ORX_NSU_AOX_LOPOW_W_POWER_MINUS10DB 0x2
4547#define ORX_NSU_AOX_LOPOW_W_POWER_MINUS15DB 0x3
4548
4549#define ORX_NSU_AOX_STHR_W__A 0x2060014
4550#define ORX_NSU_AOX_STHR_W__W 5
4551#define ORX_NSU_AOX_STHR_W__M 0x1F
4552#define ORX_NSU_AOX_STHR_W__PRE 0x0
4553
4554#define ORX_NSU_TUN_RFGAIN_W__A 0x2060015
4555#define ORX_NSU_TUN_RFGAIN_W__W 15
4556#define ORX_NSU_TUN_RFGAIN_W__M 0x7FFF
4557#define ORX_NSU_TUN_RFGAIN_W__PRE 0x0
4558
4559#define ORX_NSU_TUN_IFGAIN_W__A 0x2060016
4560#define ORX_NSU_TUN_IFGAIN_W__W 15
4561#define ORX_NSU_TUN_IFGAIN_W__M 0x7FFF
4562#define ORX_NSU_TUN_IFGAIN_W__PRE 0x0
4563
4564#define ORX_NSU_TUN_BPF_W__A 0x2060017
4565#define ORX_NSU_TUN_BPF_W__W 15
4566#define ORX_NSU_TUN_BPF_W__M 0x7FFF
4567#define ORX_NSU_TUN_BPF_W__PRE 0x1F9
4568#define ORX_NSU_NSS_BITSWAP_W__A 0x2060018
4569#define ORX_NSU_NSS_BITSWAP_W__W 3
4570#define ORX_NSU_NSS_BITSWAP_W__M 0x7
4571#define ORX_NSU_NSS_BITSWAP_W__PRE 0x0
4572
4573#define ORX_NSU_NSS_BITSWAP_W_BITSWAP_NS0_RF__B 0
4574#define ORX_NSU_NSS_BITSWAP_W_BITSWAP_NS0_RF__W 1
4575#define ORX_NSU_NSS_BITSWAP_W_BITSWAP_NS0_RF__M 0x1
4576#define ORX_NSU_NSS_BITSWAP_W_BITSWAP_NS0_RF__PRE 0x0
4577
4578#define ORX_NSU_NSS_BITSWAP_W_BITSWAP_NS1_IF__B 1
4579#define ORX_NSU_NSS_BITSWAP_W_BITSWAP_NS1_IF__W 1
4580#define ORX_NSU_NSS_BITSWAP_W_BITSWAP_NS1_IF__M 0x2
4581#define ORX_NSU_NSS_BITSWAP_W_BITSWAP_NS1_IF__PRE 0x0
4582
4583#define ORX_NSU_NSS_BITSWAP_W_BITSWAP_NS2_BP__B 2
4584#define ORX_NSU_NSS_BITSWAP_W_BITSWAP_NS2_BP__W 1
4585#define ORX_NSU_NSS_BITSWAP_W_BITSWAP_NS2_BP__M 0x4
4586#define ORX_NSU_NSS_BITSWAP_W_BITSWAP_NS2_BP__PRE 0x0
4587
4588#define ORX_TST_COMM_EXEC__A 0x23F0000
4589#define ORX_TST_COMM_EXEC__W 2
4590#define ORX_TST_COMM_EXEC__M 0x3
4591#define ORX_TST_COMM_EXEC__PRE 0x0
4592#define ORX_TST_COMM_EXEC_STOP 0x0
4593#define ORX_TST_COMM_EXEC_ACTIVE 0x1
4594#define ORX_TST_COMM_EXEC_HOLD 0x2
4595
4596#define ORX_TST_AOX_TST_W__A 0x23F0010
4597#define ORX_TST_AOX_TST_W__W 8
4598#define ORX_TST_AOX_TST_W__M 0xFF
4599#define ORX_TST_AOX_TST_W__PRE 0x0
4600
4601#define QAM_COMM_EXEC__A 0x1400000
4602#define QAM_COMM_EXEC__W 2
4603#define QAM_COMM_EXEC__M 0x3
4604#define QAM_COMM_EXEC__PRE 0x0
4605#define QAM_COMM_EXEC_STOP 0x0
4606#define QAM_COMM_EXEC_ACTIVE 0x1
4607#define QAM_COMM_EXEC_HOLD 0x2
4608
4609#define QAM_COMM_MB__A 0x1400002
4610#define QAM_COMM_MB__W 16
4611#define QAM_COMM_MB__M 0xFFFF
4612#define QAM_COMM_MB__PRE 0x0
4613#define QAM_COMM_INT_REQ__A 0x1400003
4614#define QAM_COMM_INT_REQ__W 16
4615#define QAM_COMM_INT_REQ__M 0xFFFF
4616#define QAM_COMM_INT_REQ__PRE 0x0
4617
4618#define QAM_COMM_INT_REQ_SL_REQ__B 0
4619#define QAM_COMM_INT_REQ_SL_REQ__W 1
4620#define QAM_COMM_INT_REQ_SL_REQ__M 0x1
4621#define QAM_COMM_INT_REQ_SL_REQ__PRE 0x0
4622
4623#define QAM_COMM_INT_REQ_LC_REQ__B 1
4624#define QAM_COMM_INT_REQ_LC_REQ__W 1
4625#define QAM_COMM_INT_REQ_LC_REQ__M 0x2
4626#define QAM_COMM_INT_REQ_LC_REQ__PRE 0x0
4627
4628#define QAM_COMM_INT_REQ_VD_REQ__B 2
4629#define QAM_COMM_INT_REQ_VD_REQ__W 1
4630#define QAM_COMM_INT_REQ_VD_REQ__M 0x4
4631#define QAM_COMM_INT_REQ_VD_REQ__PRE 0x0
4632
4633#define QAM_COMM_INT_REQ_SY_REQ__B 3
4634#define QAM_COMM_INT_REQ_SY_REQ__W 1
4635#define QAM_COMM_INT_REQ_SY_REQ__M 0x8
4636#define QAM_COMM_INT_REQ_SY_REQ__PRE 0x0
4637
4638#define QAM_COMM_INT_STA__A 0x1400005
4639#define QAM_COMM_INT_STA__W 16
4640#define QAM_COMM_INT_STA__M 0xFFFF
4641#define QAM_COMM_INT_STA__PRE 0x0
4642#define QAM_COMM_INT_MSK__A 0x1400006
4643#define QAM_COMM_INT_MSK__W 16
4644#define QAM_COMM_INT_MSK__M 0xFFFF
4645#define QAM_COMM_INT_MSK__PRE 0x0
4646#define QAM_COMM_INT_STM__A 0x1400007
4647#define QAM_COMM_INT_STM__W 16
4648#define QAM_COMM_INT_STM__M 0xFFFF
4649#define QAM_COMM_INT_STM__PRE 0x0
4650
4651#define QAM_TOP_COMM_EXEC__A 0x1410000
4652#define QAM_TOP_COMM_EXEC__W 2
4653#define QAM_TOP_COMM_EXEC__M 0x3
4654#define QAM_TOP_COMM_EXEC__PRE 0x0
4655#define QAM_TOP_COMM_EXEC_STOP 0x0
4656#define QAM_TOP_COMM_EXEC_ACTIVE 0x1
4657#define QAM_TOP_COMM_EXEC_HOLD 0x2
4658
4659#define QAM_TOP_ANNEX__A 0x1410010
4660#define QAM_TOP_ANNEX__W 2
4661#define QAM_TOP_ANNEX__M 0x3
4662#define QAM_TOP_ANNEX__PRE 0x1
4663#define QAM_TOP_ANNEX_A 0x0
4664#define QAM_TOP_ANNEX_B 0x1
4665#define QAM_TOP_ANNEX_C 0x2
4666#define QAM_TOP_ANNEX_D 0x3
4667
4668#define QAM_TOP_CONSTELLATION__A 0x1410011
4669#define QAM_TOP_CONSTELLATION__W 3
4670#define QAM_TOP_CONSTELLATION__M 0x7
4671#define QAM_TOP_CONSTELLATION__PRE 0x5
4672#define QAM_TOP_CONSTELLATION_NONE 0x0
4673#define QAM_TOP_CONSTELLATION_QPSK 0x1
4674#define QAM_TOP_CONSTELLATION_QAM8 0x2
4675#define QAM_TOP_CONSTELLATION_QAM16 0x3
4676#define QAM_TOP_CONSTELLATION_QAM32 0x4
4677#define QAM_TOP_CONSTELLATION_QAM64 0x5
4678#define QAM_TOP_CONSTELLATION_QAM128 0x6
4679#define QAM_TOP_CONSTELLATION_QAM256 0x7
4680
4681#define QAM_FQ_COMM_EXEC__A 0x1420000
4682#define QAM_FQ_COMM_EXEC__W 2
4683#define QAM_FQ_COMM_EXEC__M 0x3
4684#define QAM_FQ_COMM_EXEC__PRE 0x0
4685#define QAM_FQ_COMM_EXEC_STOP 0x0
4686#define QAM_FQ_COMM_EXEC_ACTIVE 0x1
4687#define QAM_FQ_COMM_EXEC_HOLD 0x2
4688
4689#define QAM_FQ_MODE__A 0x1420010
4690#define QAM_FQ_MODE__W 3
4691#define QAM_FQ_MODE__M 0x7
4692#define QAM_FQ_MODE__PRE 0x0
4693
4694#define QAM_FQ_MODE_TAPRESET__B 0
4695#define QAM_FQ_MODE_TAPRESET__W 1
4696#define QAM_FQ_MODE_TAPRESET__M 0x1
4697#define QAM_FQ_MODE_TAPRESET__PRE 0x0
4698#define QAM_FQ_MODE_TAPRESET_RST 0x1
4699
4700#define QAM_FQ_MODE_TAPLMS__B 1
4701#define QAM_FQ_MODE_TAPLMS__W 1
4702#define QAM_FQ_MODE_TAPLMS__M 0x2
4703#define QAM_FQ_MODE_TAPLMS__PRE 0x0
4704#define QAM_FQ_MODE_TAPLMS_UPD 0x2
4705
4706#define QAM_FQ_MODE_TAPDRAIN__B 2
4707#define QAM_FQ_MODE_TAPDRAIN__W 1
4708#define QAM_FQ_MODE_TAPDRAIN__M 0x4
4709#define QAM_FQ_MODE_TAPDRAIN__PRE 0x0
4710#define QAM_FQ_MODE_TAPDRAIN_DRAIN 0x4
4711
4712#define QAM_FQ_MU_FACTOR__A 0x1420011
4713#define QAM_FQ_MU_FACTOR__W 3
4714#define QAM_FQ_MU_FACTOR__M 0x7
4715#define QAM_FQ_MU_FACTOR__PRE 0x0
4716
4717#define QAM_FQ_LA_FACTOR__A 0x1420012
4718#define QAM_FQ_LA_FACTOR__W 4
4719#define QAM_FQ_LA_FACTOR__M 0xF
4720#define QAM_FQ_LA_FACTOR__PRE 0xC
4721#define QAM_FQ_CENTTAP_IDX__A 0x1420016
4722#define QAM_FQ_CENTTAP_IDX__W 5
4723#define QAM_FQ_CENTTAP_IDX__M 0x1F
4724#define QAM_FQ_CENTTAP_IDX__PRE 0x13
4725
4726#define QAM_FQ_CENTTAP_IDX_IDX__B 0
4727#define QAM_FQ_CENTTAP_IDX_IDX__W 5
4728#define QAM_FQ_CENTTAP_IDX_IDX__M 0x1F
4729#define QAM_FQ_CENTTAP_IDX_IDX__PRE 0x13
4730
4731#define QAM_FQ_CENTTAP_VALUE__A 0x1420017
4732#define QAM_FQ_CENTTAP_VALUE__W 12
4733#define QAM_FQ_CENTTAP_VALUE__M 0xFFF
4734#define QAM_FQ_CENTTAP_VALUE__PRE 0x600
4735
4736#define QAM_FQ_CENTTAP_VALUE_TAP__B 0
4737#define QAM_FQ_CENTTAP_VALUE_TAP__W 12
4738#define QAM_FQ_CENTTAP_VALUE_TAP__M 0xFFF
4739#define QAM_FQ_CENTTAP_VALUE_TAP__PRE 0x600
4740
4741#define QAM_FQ_TAP_RE_EL0__A 0x1420020
4742#define QAM_FQ_TAP_RE_EL0__W 12
4743#define QAM_FQ_TAP_RE_EL0__M 0xFFF
4744#define QAM_FQ_TAP_RE_EL0__PRE 0x2
4745
4746#define QAM_FQ_TAP_RE_EL0_TAP__B 0
4747#define QAM_FQ_TAP_RE_EL0_TAP__W 12
4748#define QAM_FQ_TAP_RE_EL0_TAP__M 0xFFF
4749#define QAM_FQ_TAP_RE_EL0_TAP__PRE 0x2
4750
4751#define QAM_FQ_TAP_IM_EL0__A 0x1420021
4752#define QAM_FQ_TAP_IM_EL0__W 12
4753#define QAM_FQ_TAP_IM_EL0__M 0xFFF
4754#define QAM_FQ_TAP_IM_EL0__PRE 0x2
4755
4756#define QAM_FQ_TAP_IM_EL0_TAP__B 0
4757#define QAM_FQ_TAP_IM_EL0_TAP__W 12
4758#define QAM_FQ_TAP_IM_EL0_TAP__M 0xFFF
4759#define QAM_FQ_TAP_IM_EL0_TAP__PRE 0x2
4760
4761#define QAM_FQ_TAP_RE_EL1__A 0x1420022
4762#define QAM_FQ_TAP_RE_EL1__W 12
4763#define QAM_FQ_TAP_RE_EL1__M 0xFFF
4764#define QAM_FQ_TAP_RE_EL1__PRE 0x2
4765
4766#define QAM_FQ_TAP_RE_EL1_TAP__B 0
4767#define QAM_FQ_TAP_RE_EL1_TAP__W 12
4768#define QAM_FQ_TAP_RE_EL1_TAP__M 0xFFF
4769#define QAM_FQ_TAP_RE_EL1_TAP__PRE 0x2
4770
4771#define QAM_FQ_TAP_IM_EL1__A 0x1420023
4772#define QAM_FQ_TAP_IM_EL1__W 12
4773#define QAM_FQ_TAP_IM_EL1__M 0xFFF
4774#define QAM_FQ_TAP_IM_EL1__PRE 0x2
4775
4776#define QAM_FQ_TAP_IM_EL1_TAP__B 0
4777#define QAM_FQ_TAP_IM_EL1_TAP__W 12
4778#define QAM_FQ_TAP_IM_EL1_TAP__M 0xFFF
4779#define QAM_FQ_TAP_IM_EL1_TAP__PRE 0x2
4780
4781#define QAM_FQ_TAP_RE_EL2__A 0x1420024
4782#define QAM_FQ_TAP_RE_EL2__W 12
4783#define QAM_FQ_TAP_RE_EL2__M 0xFFF
4784#define QAM_FQ_TAP_RE_EL2__PRE 0x2
4785
4786#define QAM_FQ_TAP_RE_EL2_TAP__B 0
4787#define QAM_FQ_TAP_RE_EL2_TAP__W 12
4788#define QAM_FQ_TAP_RE_EL2_TAP__M 0xFFF
4789#define QAM_FQ_TAP_RE_EL2_TAP__PRE 0x2
4790
4791#define QAM_FQ_TAP_IM_EL2__A 0x1420025
4792#define QAM_FQ_TAP_IM_EL2__W 12
4793#define QAM_FQ_TAP_IM_EL2__M 0xFFF
4794#define QAM_FQ_TAP_IM_EL2__PRE 0x2
4795
4796#define QAM_FQ_TAP_IM_EL2_TAP__B 0
4797#define QAM_FQ_TAP_IM_EL2_TAP__W 12
4798#define QAM_FQ_TAP_IM_EL2_TAP__M 0xFFF
4799#define QAM_FQ_TAP_IM_EL2_TAP__PRE 0x2
4800
4801#define QAM_FQ_TAP_RE_EL3__A 0x1420026
4802#define QAM_FQ_TAP_RE_EL3__W 12
4803#define QAM_FQ_TAP_RE_EL3__M 0xFFF
4804#define QAM_FQ_TAP_RE_EL3__PRE 0x2
4805
4806#define QAM_FQ_TAP_RE_EL3_TAP__B 0
4807#define QAM_FQ_TAP_RE_EL3_TAP__W 12
4808#define QAM_FQ_TAP_RE_EL3_TAP__M 0xFFF
4809#define QAM_FQ_TAP_RE_EL3_TAP__PRE 0x2
4810
4811#define QAM_FQ_TAP_IM_EL3__A 0x1420027
4812#define QAM_FQ_TAP_IM_EL3__W 12
4813#define QAM_FQ_TAP_IM_EL3__M 0xFFF
4814#define QAM_FQ_TAP_IM_EL3__PRE 0x2
4815
4816#define QAM_FQ_TAP_IM_EL3_TAP__B 0
4817#define QAM_FQ_TAP_IM_EL3_TAP__W 12
4818#define QAM_FQ_TAP_IM_EL3_TAP__M 0xFFF
4819#define QAM_FQ_TAP_IM_EL3_TAP__PRE 0x2
4820
4821#define QAM_FQ_TAP_RE_EL4__A 0x1420028
4822#define QAM_FQ_TAP_RE_EL4__W 12
4823#define QAM_FQ_TAP_RE_EL4__M 0xFFF
4824#define QAM_FQ_TAP_RE_EL4__PRE 0x2
4825
4826#define QAM_FQ_TAP_RE_EL4_TAP__B 0
4827#define QAM_FQ_TAP_RE_EL4_TAP__W 12
4828#define QAM_FQ_TAP_RE_EL4_TAP__M 0xFFF
4829#define QAM_FQ_TAP_RE_EL4_TAP__PRE 0x2
4830
4831#define QAM_FQ_TAP_IM_EL4__A 0x1420029
4832#define QAM_FQ_TAP_IM_EL4__W 12
4833#define QAM_FQ_TAP_IM_EL4__M 0xFFF
4834#define QAM_FQ_TAP_IM_EL4__PRE 0x2
4835
4836#define QAM_FQ_TAP_IM_EL4_TAP__B 0
4837#define QAM_FQ_TAP_IM_EL4_TAP__W 12
4838#define QAM_FQ_TAP_IM_EL4_TAP__M 0xFFF
4839#define QAM_FQ_TAP_IM_EL4_TAP__PRE 0x2
4840
4841#define QAM_FQ_TAP_RE_EL5__A 0x142002A
4842#define QAM_FQ_TAP_RE_EL5__W 12
4843#define QAM_FQ_TAP_RE_EL5__M 0xFFF
4844#define QAM_FQ_TAP_RE_EL5__PRE 0x2
4845
4846#define QAM_FQ_TAP_RE_EL5_TAP__B 0
4847#define QAM_FQ_TAP_RE_EL5_TAP__W 12
4848#define QAM_FQ_TAP_RE_EL5_TAP__M 0xFFF
4849#define QAM_FQ_TAP_RE_EL5_TAP__PRE 0x2
4850
4851#define QAM_FQ_TAP_IM_EL5__A 0x142002B
4852#define QAM_FQ_TAP_IM_EL5__W 12
4853#define QAM_FQ_TAP_IM_EL5__M 0xFFF
4854#define QAM_FQ_TAP_IM_EL5__PRE 0x2
4855
4856#define QAM_FQ_TAP_IM_EL5_TAP__B 0
4857#define QAM_FQ_TAP_IM_EL5_TAP__W 12
4858#define QAM_FQ_TAP_IM_EL5_TAP__M 0xFFF
4859#define QAM_FQ_TAP_IM_EL5_TAP__PRE 0x2
4860
4861#define QAM_FQ_TAP_RE_EL6__A 0x142002C
4862#define QAM_FQ_TAP_RE_EL6__W 12
4863#define QAM_FQ_TAP_RE_EL6__M 0xFFF
4864#define QAM_FQ_TAP_RE_EL6__PRE 0x2
4865
4866#define QAM_FQ_TAP_RE_EL6_TAP__B 0
4867#define QAM_FQ_TAP_RE_EL6_TAP__W 12
4868#define QAM_FQ_TAP_RE_EL6_TAP__M 0xFFF
4869#define QAM_FQ_TAP_RE_EL6_TAP__PRE 0x2
4870
4871#define QAM_FQ_TAP_IM_EL6__A 0x142002D
4872#define QAM_FQ_TAP_IM_EL6__W 12
4873#define QAM_FQ_TAP_IM_EL6__M 0xFFF
4874#define QAM_FQ_TAP_IM_EL6__PRE 0x2
4875
4876#define QAM_FQ_TAP_IM_EL6_TAP__B 0
4877#define QAM_FQ_TAP_IM_EL6_TAP__W 12
4878#define QAM_FQ_TAP_IM_EL6_TAP__M 0xFFF
4879#define QAM_FQ_TAP_IM_EL6_TAP__PRE 0x2
4880
4881#define QAM_FQ_TAP_RE_EL7__A 0x142002E
4882#define QAM_FQ_TAP_RE_EL7__W 12
4883#define QAM_FQ_TAP_RE_EL7__M 0xFFF
4884#define QAM_FQ_TAP_RE_EL7__PRE 0x2
4885
4886#define QAM_FQ_TAP_RE_EL7_TAP__B 0
4887#define QAM_FQ_TAP_RE_EL7_TAP__W 12
4888#define QAM_FQ_TAP_RE_EL7_TAP__M 0xFFF
4889#define QAM_FQ_TAP_RE_EL7_TAP__PRE 0x2
4890
4891#define QAM_FQ_TAP_IM_EL7__A 0x142002F
4892#define QAM_FQ_TAP_IM_EL7__W 12
4893#define QAM_FQ_TAP_IM_EL7__M 0xFFF
4894#define QAM_FQ_TAP_IM_EL7__PRE 0x2
4895
4896#define QAM_FQ_TAP_IM_EL7_TAP__B 0
4897#define QAM_FQ_TAP_IM_EL7_TAP__W 12
4898#define QAM_FQ_TAP_IM_EL7_TAP__M 0xFFF
4899#define QAM_FQ_TAP_IM_EL7_TAP__PRE 0x2
4900
4901#define QAM_FQ_TAP_RE_EL8__A 0x1420030
4902#define QAM_FQ_TAP_RE_EL8__W 12
4903#define QAM_FQ_TAP_RE_EL8__M 0xFFF
4904#define QAM_FQ_TAP_RE_EL8__PRE 0x2
4905
4906#define QAM_FQ_TAP_RE_EL8_TAP__B 0
4907#define QAM_FQ_TAP_RE_EL8_TAP__W 12
4908#define QAM_FQ_TAP_RE_EL8_TAP__M 0xFFF
4909#define QAM_FQ_TAP_RE_EL8_TAP__PRE 0x2
4910
4911#define QAM_FQ_TAP_IM_EL8__A 0x1420031
4912#define QAM_FQ_TAP_IM_EL8__W 12
4913#define QAM_FQ_TAP_IM_EL8__M 0xFFF
4914#define QAM_FQ_TAP_IM_EL8__PRE 0x2
4915
4916#define QAM_FQ_TAP_IM_EL8_TAP__B 0
4917#define QAM_FQ_TAP_IM_EL8_TAP__W 12
4918#define QAM_FQ_TAP_IM_EL8_TAP__M 0xFFF
4919#define QAM_FQ_TAP_IM_EL8_TAP__PRE 0x2
4920
4921#define QAM_FQ_TAP_RE_EL9__A 0x1420032
4922#define QAM_FQ_TAP_RE_EL9__W 12
4923#define QAM_FQ_TAP_RE_EL9__M 0xFFF
4924#define QAM_FQ_TAP_RE_EL9__PRE 0x2
4925
4926#define QAM_FQ_TAP_RE_EL9_TAP__B 0
4927#define QAM_FQ_TAP_RE_EL9_TAP__W 12
4928#define QAM_FQ_TAP_RE_EL9_TAP__M 0xFFF
4929#define QAM_FQ_TAP_RE_EL9_TAP__PRE 0x2
4930
4931#define QAM_FQ_TAP_IM_EL9__A 0x1420033
4932#define QAM_FQ_TAP_IM_EL9__W 12
4933#define QAM_FQ_TAP_IM_EL9__M 0xFFF
4934#define QAM_FQ_TAP_IM_EL9__PRE 0x2
4935
4936#define QAM_FQ_TAP_IM_EL9_TAP__B 0
4937#define QAM_FQ_TAP_IM_EL9_TAP__W 12
4938#define QAM_FQ_TAP_IM_EL9_TAP__M 0xFFF
4939#define QAM_FQ_TAP_IM_EL9_TAP__PRE 0x2
4940
4941#define QAM_FQ_TAP_RE_EL10__A 0x1420034
4942#define QAM_FQ_TAP_RE_EL10__W 12
4943#define QAM_FQ_TAP_RE_EL10__M 0xFFF
4944#define QAM_FQ_TAP_RE_EL10__PRE 0x2
4945
4946#define QAM_FQ_TAP_RE_EL10_TAP__B 0
4947#define QAM_FQ_TAP_RE_EL10_TAP__W 12
4948#define QAM_FQ_TAP_RE_EL10_TAP__M 0xFFF
4949#define QAM_FQ_TAP_RE_EL10_TAP__PRE 0x2
4950
4951#define QAM_FQ_TAP_IM_EL10__A 0x1420035
4952#define QAM_FQ_TAP_IM_EL10__W 12
4953#define QAM_FQ_TAP_IM_EL10__M 0xFFF
4954#define QAM_FQ_TAP_IM_EL10__PRE 0x2
4955
4956#define QAM_FQ_TAP_IM_EL10_TAP__B 0
4957#define QAM_FQ_TAP_IM_EL10_TAP__W 12
4958#define QAM_FQ_TAP_IM_EL10_TAP__M 0xFFF
4959#define QAM_FQ_TAP_IM_EL10_TAP__PRE 0x2
4960
4961#define QAM_FQ_TAP_RE_EL11__A 0x1420036
4962#define QAM_FQ_TAP_RE_EL11__W 12
4963#define QAM_FQ_TAP_RE_EL11__M 0xFFF
4964#define QAM_FQ_TAP_RE_EL11__PRE 0x2
4965
4966#define QAM_FQ_TAP_RE_EL11_TAP__B 0
4967#define QAM_FQ_TAP_RE_EL11_TAP__W 12
4968#define QAM_FQ_TAP_RE_EL11_TAP__M 0xFFF
4969#define QAM_FQ_TAP_RE_EL11_TAP__PRE 0x2
4970
4971#define QAM_FQ_TAP_IM_EL11__A 0x1420037
4972#define QAM_FQ_TAP_IM_EL11__W 12
4973#define QAM_FQ_TAP_IM_EL11__M 0xFFF
4974#define QAM_FQ_TAP_IM_EL11__PRE 0x2
4975
4976#define QAM_FQ_TAP_IM_EL11_TAP__B 0
4977#define QAM_FQ_TAP_IM_EL11_TAP__W 12
4978#define QAM_FQ_TAP_IM_EL11_TAP__M 0xFFF
4979#define QAM_FQ_TAP_IM_EL11_TAP__PRE 0x2
4980
4981#define QAM_FQ_TAP_RE_EL12__A 0x1420038
4982#define QAM_FQ_TAP_RE_EL12__W 12
4983#define QAM_FQ_TAP_RE_EL12__M 0xFFF
4984#define QAM_FQ_TAP_RE_EL12__PRE 0x2
4985
4986#define QAM_FQ_TAP_RE_EL12_TAP__B 0
4987#define QAM_FQ_TAP_RE_EL12_TAP__W 12
4988#define QAM_FQ_TAP_RE_EL12_TAP__M 0xFFF
4989#define QAM_FQ_TAP_RE_EL12_TAP__PRE 0x2
4990
4991#define QAM_FQ_TAP_IM_EL12__A 0x1420039
4992#define QAM_FQ_TAP_IM_EL12__W 12
4993#define QAM_FQ_TAP_IM_EL12__M 0xFFF
4994#define QAM_FQ_TAP_IM_EL12__PRE 0x2
4995
4996#define QAM_FQ_TAP_IM_EL12_TAP__B 0
4997#define QAM_FQ_TAP_IM_EL12_TAP__W 12
4998#define QAM_FQ_TAP_IM_EL12_TAP__M 0xFFF
4999#define QAM_FQ_TAP_IM_EL12_TAP__PRE 0x2
5000
5001#define QAM_FQ_TAP_RE_EL13__A 0x142003A
5002#define QAM_FQ_TAP_RE_EL13__W 12
5003#define QAM_FQ_TAP_RE_EL13__M 0xFFF
5004#define QAM_FQ_TAP_RE_EL13__PRE 0x2
5005
5006#define QAM_FQ_TAP_RE_EL13_TAP__B 0
5007#define QAM_FQ_TAP_RE_EL13_TAP__W 12
5008#define QAM_FQ_TAP_RE_EL13_TAP__M 0xFFF
5009#define QAM_FQ_TAP_RE_EL13_TAP__PRE 0x2
5010
5011#define QAM_FQ_TAP_IM_EL13__A 0x142003B
5012#define QAM_FQ_TAP_IM_EL13__W 12
5013#define QAM_FQ_TAP_IM_EL13__M 0xFFF
5014#define QAM_FQ_TAP_IM_EL13__PRE 0x2
5015
5016#define QAM_FQ_TAP_IM_EL13_TAP__B 0
5017#define QAM_FQ_TAP_IM_EL13_TAP__W 12
5018#define QAM_FQ_TAP_IM_EL13_TAP__M 0xFFF
5019#define QAM_FQ_TAP_IM_EL13_TAP__PRE 0x2
5020
5021#define QAM_FQ_TAP_RE_EL14__A 0x142003C
5022#define QAM_FQ_TAP_RE_EL14__W 12
5023#define QAM_FQ_TAP_RE_EL14__M 0xFFF
5024#define QAM_FQ_TAP_RE_EL14__PRE 0x2
5025
5026#define QAM_FQ_TAP_RE_EL14_TAP__B 0
5027#define QAM_FQ_TAP_RE_EL14_TAP__W 12
5028#define QAM_FQ_TAP_RE_EL14_TAP__M 0xFFF
5029#define QAM_FQ_TAP_RE_EL14_TAP__PRE 0x2
5030
5031#define QAM_FQ_TAP_IM_EL14__A 0x142003D
5032#define QAM_FQ_TAP_IM_EL14__W 12
5033#define QAM_FQ_TAP_IM_EL14__M 0xFFF
5034#define QAM_FQ_TAP_IM_EL14__PRE 0x2
5035
5036#define QAM_FQ_TAP_IM_EL14_TAP__B 0
5037#define QAM_FQ_TAP_IM_EL14_TAP__W 12
5038#define QAM_FQ_TAP_IM_EL14_TAP__M 0xFFF
5039#define QAM_FQ_TAP_IM_EL14_TAP__PRE 0x2
5040
5041#define QAM_FQ_TAP_RE_EL15__A 0x142003E
5042#define QAM_FQ_TAP_RE_EL15__W 12
5043#define QAM_FQ_TAP_RE_EL15__M 0xFFF
5044#define QAM_FQ_TAP_RE_EL15__PRE 0x2
5045
5046#define QAM_FQ_TAP_RE_EL15_TAP__B 0
5047#define QAM_FQ_TAP_RE_EL15_TAP__W 12
5048#define QAM_FQ_TAP_RE_EL15_TAP__M 0xFFF
5049#define QAM_FQ_TAP_RE_EL15_TAP__PRE 0x2
5050
5051#define QAM_FQ_TAP_IM_EL15__A 0x142003F
5052#define QAM_FQ_TAP_IM_EL15__W 12
5053#define QAM_FQ_TAP_IM_EL15__M 0xFFF
5054#define QAM_FQ_TAP_IM_EL15__PRE 0x2
5055
5056#define QAM_FQ_TAP_IM_EL15_TAP__B 0
5057#define QAM_FQ_TAP_IM_EL15_TAP__W 12
5058#define QAM_FQ_TAP_IM_EL15_TAP__M 0xFFF
5059#define QAM_FQ_TAP_IM_EL15_TAP__PRE 0x2
5060
5061#define QAM_FQ_TAP_RE_EL16__A 0x1420040
5062#define QAM_FQ_TAP_RE_EL16__W 12
5063#define QAM_FQ_TAP_RE_EL16__M 0xFFF
5064#define QAM_FQ_TAP_RE_EL16__PRE 0x2
5065
5066#define QAM_FQ_TAP_RE_EL16_TAP__B 0
5067#define QAM_FQ_TAP_RE_EL16_TAP__W 12
5068#define QAM_FQ_TAP_RE_EL16_TAP__M 0xFFF
5069#define QAM_FQ_TAP_RE_EL16_TAP__PRE 0x2
5070
5071#define QAM_FQ_TAP_IM_EL16__A 0x1420041
5072#define QAM_FQ_TAP_IM_EL16__W 12
5073#define QAM_FQ_TAP_IM_EL16__M 0xFFF
5074#define QAM_FQ_TAP_IM_EL16__PRE 0x2
5075
5076#define QAM_FQ_TAP_IM_EL16_TAP__B 0
5077#define QAM_FQ_TAP_IM_EL16_TAP__W 12
5078#define QAM_FQ_TAP_IM_EL16_TAP__M 0xFFF
5079#define QAM_FQ_TAP_IM_EL16_TAP__PRE 0x2
5080
5081#define QAM_FQ_TAP_RE_EL17__A 0x1420042
5082#define QAM_FQ_TAP_RE_EL17__W 12
5083#define QAM_FQ_TAP_RE_EL17__M 0xFFF
5084#define QAM_FQ_TAP_RE_EL17__PRE 0x2
5085
5086#define QAM_FQ_TAP_RE_EL17_TAP__B 0
5087#define QAM_FQ_TAP_RE_EL17_TAP__W 12
5088#define QAM_FQ_TAP_RE_EL17_TAP__M 0xFFF
5089#define QAM_FQ_TAP_RE_EL17_TAP__PRE 0x2
5090
5091#define QAM_FQ_TAP_IM_EL17__A 0x1420043
5092#define QAM_FQ_TAP_IM_EL17__W 12
5093#define QAM_FQ_TAP_IM_EL17__M 0xFFF
5094#define QAM_FQ_TAP_IM_EL17__PRE 0x2
5095
5096#define QAM_FQ_TAP_IM_EL17_TAP__B 0
5097#define QAM_FQ_TAP_IM_EL17_TAP__W 12
5098#define QAM_FQ_TAP_IM_EL17_TAP__M 0xFFF
5099#define QAM_FQ_TAP_IM_EL17_TAP__PRE 0x2
5100
5101#define QAM_FQ_TAP_RE_EL18__A 0x1420044
5102#define QAM_FQ_TAP_RE_EL18__W 12
5103#define QAM_FQ_TAP_RE_EL18__M 0xFFF
5104#define QAM_FQ_TAP_RE_EL18__PRE 0x2
5105
5106#define QAM_FQ_TAP_RE_EL18_TAP__B 0
5107#define QAM_FQ_TAP_RE_EL18_TAP__W 12
5108#define QAM_FQ_TAP_RE_EL18_TAP__M 0xFFF
5109#define QAM_FQ_TAP_RE_EL18_TAP__PRE 0x2
5110
5111#define QAM_FQ_TAP_IM_EL18__A 0x1420045
5112#define QAM_FQ_TAP_IM_EL18__W 12
5113#define QAM_FQ_TAP_IM_EL18__M 0xFFF
5114#define QAM_FQ_TAP_IM_EL18__PRE 0x2
5115
5116#define QAM_FQ_TAP_IM_EL18_TAP__B 0
5117#define QAM_FQ_TAP_IM_EL18_TAP__W 12
5118#define QAM_FQ_TAP_IM_EL18_TAP__M 0xFFF
5119#define QAM_FQ_TAP_IM_EL18_TAP__PRE 0x2
5120
5121#define QAM_FQ_TAP_RE_EL19__A 0x1420046
5122#define QAM_FQ_TAP_RE_EL19__W 12
5123#define QAM_FQ_TAP_RE_EL19__M 0xFFF
5124#define QAM_FQ_TAP_RE_EL19__PRE 0x600
5125
5126#define QAM_FQ_TAP_RE_EL19_TAP__B 0
5127#define QAM_FQ_TAP_RE_EL19_TAP__W 12
5128#define QAM_FQ_TAP_RE_EL19_TAP__M 0xFFF
5129#define QAM_FQ_TAP_RE_EL19_TAP__PRE 0x600
5130
5131#define QAM_FQ_TAP_IM_EL19__A 0x1420047
5132#define QAM_FQ_TAP_IM_EL19__W 12
5133#define QAM_FQ_TAP_IM_EL19__M 0xFFF
5134#define QAM_FQ_TAP_IM_EL19__PRE 0x2
5135
5136#define QAM_FQ_TAP_IM_EL19_TAP__B 0
5137#define QAM_FQ_TAP_IM_EL19_TAP__W 12
5138#define QAM_FQ_TAP_IM_EL19_TAP__M 0xFFF
5139#define QAM_FQ_TAP_IM_EL19_TAP__PRE 0x2
5140
5141#define QAM_FQ_TAP_RE_EL20__A 0x1420048
5142#define QAM_FQ_TAP_RE_EL20__W 12
5143#define QAM_FQ_TAP_RE_EL20__M 0xFFF
5144#define QAM_FQ_TAP_RE_EL20__PRE 0x2
5145
5146#define QAM_FQ_TAP_RE_EL20_TAP__B 0
5147#define QAM_FQ_TAP_RE_EL20_TAP__W 12
5148#define QAM_FQ_TAP_RE_EL20_TAP__M 0xFFF
5149#define QAM_FQ_TAP_RE_EL20_TAP__PRE 0x2
5150
5151#define QAM_FQ_TAP_IM_EL20__A 0x1420049
5152#define QAM_FQ_TAP_IM_EL20__W 12
5153#define QAM_FQ_TAP_IM_EL20__M 0xFFF
5154#define QAM_FQ_TAP_IM_EL20__PRE 0x2
5155
5156#define QAM_FQ_TAP_IM_EL20_TAP__B 0
5157#define QAM_FQ_TAP_IM_EL20_TAP__W 12
5158#define QAM_FQ_TAP_IM_EL20_TAP__M 0xFFF
5159#define QAM_FQ_TAP_IM_EL20_TAP__PRE 0x2
5160
5161#define QAM_FQ_TAP_RE_EL21__A 0x142004A
5162#define QAM_FQ_TAP_RE_EL21__W 12
5163#define QAM_FQ_TAP_RE_EL21__M 0xFFF
5164#define QAM_FQ_TAP_RE_EL21__PRE 0x2
5165
5166#define QAM_FQ_TAP_RE_EL21_TAP__B 0
5167#define QAM_FQ_TAP_RE_EL21_TAP__W 12
5168#define QAM_FQ_TAP_RE_EL21_TAP__M 0xFFF
5169#define QAM_FQ_TAP_RE_EL21_TAP__PRE 0x2
5170
5171#define QAM_FQ_TAP_IM_EL21__A 0x142004B
5172#define QAM_FQ_TAP_IM_EL21__W 12
5173#define QAM_FQ_TAP_IM_EL21__M 0xFFF
5174#define QAM_FQ_TAP_IM_EL21__PRE 0x2
5175
5176#define QAM_FQ_TAP_IM_EL21_TAP__B 0
5177#define QAM_FQ_TAP_IM_EL21_TAP__W 12
5178#define QAM_FQ_TAP_IM_EL21_TAP__M 0xFFF
5179#define QAM_FQ_TAP_IM_EL21_TAP__PRE 0x2
5180
5181#define QAM_FQ_TAP_RE_EL22__A 0x142004C
5182#define QAM_FQ_TAP_RE_EL22__W 12
5183#define QAM_FQ_TAP_RE_EL22__M 0xFFF
5184#define QAM_FQ_TAP_RE_EL22__PRE 0x2
5185
5186#define QAM_FQ_TAP_RE_EL22_TAP__B 0
5187#define QAM_FQ_TAP_RE_EL22_TAP__W 12
5188#define QAM_FQ_TAP_RE_EL22_TAP__M 0xFFF
5189#define QAM_FQ_TAP_RE_EL22_TAP__PRE 0x2
5190
5191#define QAM_FQ_TAP_IM_EL22__A 0x142004D
5192#define QAM_FQ_TAP_IM_EL22__W 12
5193#define QAM_FQ_TAP_IM_EL22__M 0xFFF
5194#define QAM_FQ_TAP_IM_EL22__PRE 0x2
5195
5196#define QAM_FQ_TAP_IM_EL22_TAP__B 0
5197#define QAM_FQ_TAP_IM_EL22_TAP__W 12
5198#define QAM_FQ_TAP_IM_EL22_TAP__M 0xFFF
5199#define QAM_FQ_TAP_IM_EL22_TAP__PRE 0x2
5200
5201#define QAM_FQ_TAP_RE_EL23__A 0x142004E
5202#define QAM_FQ_TAP_RE_EL23__W 12
5203#define QAM_FQ_TAP_RE_EL23__M 0xFFF
5204#define QAM_FQ_TAP_RE_EL23__PRE 0x2
5205
5206#define QAM_FQ_TAP_RE_EL23_TAP__B 0
5207#define QAM_FQ_TAP_RE_EL23_TAP__W 12
5208#define QAM_FQ_TAP_RE_EL23_TAP__M 0xFFF
5209#define QAM_FQ_TAP_RE_EL23_TAP__PRE 0x2
5210
5211#define QAM_FQ_TAP_IM_EL23__A 0x142004F
5212#define QAM_FQ_TAP_IM_EL23__W 12
5213#define QAM_FQ_TAP_IM_EL23__M 0xFFF
5214#define QAM_FQ_TAP_IM_EL23__PRE 0x2
5215
5216#define QAM_FQ_TAP_IM_EL23_TAP__B 0
5217#define QAM_FQ_TAP_IM_EL23_TAP__W 12
5218#define QAM_FQ_TAP_IM_EL23_TAP__M 0xFFF
5219#define QAM_FQ_TAP_IM_EL23_TAP__PRE 0x2
5220
5221#define QAM_SL_COMM_EXEC__A 0x1430000
5222#define QAM_SL_COMM_EXEC__W 2
5223#define QAM_SL_COMM_EXEC__M 0x3
5224#define QAM_SL_COMM_EXEC__PRE 0x0
5225#define QAM_SL_COMM_EXEC_STOP 0x0
5226#define QAM_SL_COMM_EXEC_ACTIVE 0x1
5227#define QAM_SL_COMM_EXEC_HOLD 0x2
5228
5229#define QAM_SL_COMM_MB__A 0x1430002
5230#define QAM_SL_COMM_MB__W 4
5231#define QAM_SL_COMM_MB__M 0xF
5232#define QAM_SL_COMM_MB__PRE 0x0
5233#define QAM_SL_COMM_MB_CTL__B 0
5234#define QAM_SL_COMM_MB_CTL__W 1
5235#define QAM_SL_COMM_MB_CTL__M 0x1
5236#define QAM_SL_COMM_MB_CTL__PRE 0x0
5237#define QAM_SL_COMM_MB_CTL_OFF 0x0
5238#define QAM_SL_COMM_MB_CTL_ON 0x1
5239#define QAM_SL_COMM_MB_OBS__B 1
5240#define QAM_SL_COMM_MB_OBS__W 1
5241#define QAM_SL_COMM_MB_OBS__M 0x2
5242#define QAM_SL_COMM_MB_OBS__PRE 0x0
5243#define QAM_SL_COMM_MB_OBS_OFF 0x0
5244#define QAM_SL_COMM_MB_OBS_ON 0x2
5245#define QAM_SL_COMM_MB_MUX_OBS__B 2
5246#define QAM_SL_COMM_MB_MUX_OBS__W 2
5247#define QAM_SL_COMM_MB_MUX_OBS__M 0xC
5248#define QAM_SL_COMM_MB_MUX_OBS__PRE 0x0
5249#define QAM_SL_COMM_MB_MUX_OBS_CONST_CORR 0x0
5250#define QAM_SL_COMM_MB_MUX_OBS_CONST2LC_O 0x4
5251#define QAM_SL_COMM_MB_MUX_OBS_CONST2DQ_O 0x8
5252#define QAM_SL_COMM_MB_MUX_OBS_VDEC_O 0xC
5253
5254#define QAM_SL_COMM_INT_REQ__A 0x1430003
5255#define QAM_SL_COMM_INT_REQ__W 1
5256#define QAM_SL_COMM_INT_REQ__M 0x1
5257#define QAM_SL_COMM_INT_REQ__PRE 0x0
5258#define QAM_SL_COMM_INT_STA__A 0x1430005
5259#define QAM_SL_COMM_INT_STA__W 2
5260#define QAM_SL_COMM_INT_STA__M 0x3
5261#define QAM_SL_COMM_INT_STA__PRE 0x0
5262
5263#define QAM_SL_COMM_INT_STA_MED_ERR_INT__B 0
5264#define QAM_SL_COMM_INT_STA_MED_ERR_INT__W 1
5265#define QAM_SL_COMM_INT_STA_MED_ERR_INT__M 0x1
5266#define QAM_SL_COMM_INT_STA_MED_ERR_INT__PRE 0x0
5267
5268#define QAM_SL_COMM_INT_STA_MER_INT__B 1
5269#define QAM_SL_COMM_INT_STA_MER_INT__W 1
5270#define QAM_SL_COMM_INT_STA_MER_INT__M 0x2
5271#define QAM_SL_COMM_INT_STA_MER_INT__PRE 0x0
5272
5273#define QAM_SL_COMM_INT_MSK__A 0x1430006
5274#define QAM_SL_COMM_INT_MSK__W 2
5275#define QAM_SL_COMM_INT_MSK__M 0x3
5276#define QAM_SL_COMM_INT_MSK__PRE 0x0
5277#define QAM_SL_COMM_INT_MSK_MED_ERR_MSK__B 0
5278#define QAM_SL_COMM_INT_MSK_MED_ERR_MSK__W 1
5279#define QAM_SL_COMM_INT_MSK_MED_ERR_MSK__M 0x1
5280#define QAM_SL_COMM_INT_MSK_MED_ERR_MSK__PRE 0x0
5281#define QAM_SL_COMM_INT_MSK_MER_MSK__B 1
5282#define QAM_SL_COMM_INT_MSK_MER_MSK__W 1
5283#define QAM_SL_COMM_INT_MSK_MER_MSK__M 0x2
5284#define QAM_SL_COMM_INT_MSK_MER_MSK__PRE 0x0
5285
5286#define QAM_SL_COMM_INT_STM__A 0x1430007
5287#define QAM_SL_COMM_INT_STM__W 2
5288#define QAM_SL_COMM_INT_STM__M 0x3
5289#define QAM_SL_COMM_INT_STM__PRE 0x0
5290#define QAM_SL_COMM_INT_STM_MED_ERR_STM__B 0
5291#define QAM_SL_COMM_INT_STM_MED_ERR_STM__W 1
5292#define QAM_SL_COMM_INT_STM_MED_ERR_STM__M 0x1
5293#define QAM_SL_COMM_INT_STM_MED_ERR_STM__PRE 0x0
5294#define QAM_SL_COMM_INT_STM_MER_STM__B 1
5295#define QAM_SL_COMM_INT_STM_MER_STM__W 1
5296#define QAM_SL_COMM_INT_STM_MER_STM__M 0x2
5297#define QAM_SL_COMM_INT_STM_MER_STM__PRE 0x0
5298
5299#define QAM_SL_MODE__A 0x1430010
5300#define QAM_SL_MODE__W 11
5301#define QAM_SL_MODE__M 0x7FF
5302#define QAM_SL_MODE__PRE 0x0
5303
5304#define QAM_SL_MODE_SLICER4LC__B 0
5305#define QAM_SL_MODE_SLICER4LC__W 2
5306#define QAM_SL_MODE_SLICER4LC__M 0x3
5307#define QAM_SL_MODE_SLICER4LC__PRE 0x0
5308#define QAM_SL_MODE_SLICER4LC_RECT 0x0
5309#define QAM_SL_MODE_SLICER4LC_ONET 0x1
5310#define QAM_SL_MODE_SLICER4LC_RAD 0x2
5311
5312#define QAM_SL_MODE_SLICER4DQ__B 2
5313#define QAM_SL_MODE_SLICER4DQ__W 2
5314#define QAM_SL_MODE_SLICER4DQ__M 0xC
5315#define QAM_SL_MODE_SLICER4DQ__PRE 0x0
5316#define QAM_SL_MODE_SLICER4DQ_RECT 0x0
5317#define QAM_SL_MODE_SLICER4DQ_ONET 0x4
5318#define QAM_SL_MODE_SLICER4DQ_RAD 0x8
5319
5320#define QAM_SL_MODE_SLICER4VD__B 4
5321#define QAM_SL_MODE_SLICER4VD__W 2
5322#define QAM_SL_MODE_SLICER4VD__M 0x30
5323#define QAM_SL_MODE_SLICER4VD__PRE 0x0
5324#define QAM_SL_MODE_SLICER4VD_RECT 0x0
5325#define QAM_SL_MODE_SLICER4VD_ONET 0x10
5326#define QAM_SL_MODE_SLICER4VD_RAD 0x20
5327
5328#define QAM_SL_MODE_ROT_DIS__B 6
5329#define QAM_SL_MODE_ROT_DIS__W 1
5330#define QAM_SL_MODE_ROT_DIS__M 0x40
5331#define QAM_SL_MODE_ROT_DIS__PRE 0x0
5332
5333#define QAM_SL_MODE_DQROT_DIS__B 7
5334#define QAM_SL_MODE_DQROT_DIS__W 1
5335#define QAM_SL_MODE_DQROT_DIS__M 0x80
5336#define QAM_SL_MODE_DQROT_DIS__PRE 0x0
5337
5338#define QAM_SL_MODE_DFE_DIS__B 8
5339#define QAM_SL_MODE_DFE_DIS__W 1
5340#define QAM_SL_MODE_DFE_DIS__M 0x100
5341#define QAM_SL_MODE_DFE_DIS__PRE 0x0
5342
5343#define QAM_SL_MODE_RADIUS_MIX__B 9
5344#define QAM_SL_MODE_RADIUS_MIX__W 1
5345#define QAM_SL_MODE_RADIUS_MIX__M 0x200
5346#define QAM_SL_MODE_RADIUS_MIX__PRE 0x0
5347
5348#define QAM_SL_MODE_TILT_COMP__B 10
5349#define QAM_SL_MODE_TILT_COMP__W 1
5350#define QAM_SL_MODE_TILT_COMP__M 0x400
5351#define QAM_SL_MODE_TILT_COMP__PRE 0x0
5352
5353#define QAM_SL_K_FACTOR__A 0x1430011
5354#define QAM_SL_K_FACTOR__W 4
5355#define QAM_SL_K_FACTOR__M 0xF
5356#define QAM_SL_K_FACTOR__PRE 0x0
5357#define QAM_SL_MEDIAN__A 0x1430012
5358#define QAM_SL_MEDIAN__W 14
5359#define QAM_SL_MEDIAN__M 0x3FFF
5360#define QAM_SL_MEDIAN__PRE 0x0
5361
5362#define QAM_SL_MEDIAN_LENGTH__B 0
5363#define QAM_SL_MEDIAN_LENGTH__W 2
5364#define QAM_SL_MEDIAN_LENGTH__M 0x3
5365#define QAM_SL_MEDIAN_LENGTH__PRE 0x0
5366
5367#define QAM_SL_MEDIAN_CORRECT__B 2
5368#define QAM_SL_MEDIAN_CORRECT__W 4
5369#define QAM_SL_MEDIAN_CORRECT__M 0x3C
5370#define QAM_SL_MEDIAN_CORRECT__PRE 0x0
5371
5372#define QAM_SL_MEDIAN_TOLERANCE__B 6
5373#define QAM_SL_MEDIAN_TOLERANCE__W 7
5374#define QAM_SL_MEDIAN_TOLERANCE__M 0x1FC0
5375#define QAM_SL_MEDIAN_TOLERANCE__PRE 0x0
5376
5377#define QAM_SL_MEDIAN_FAST__B 13
5378#define QAM_SL_MEDIAN_FAST__W 1
5379#define QAM_SL_MEDIAN_FAST__M 0x2000
5380#define QAM_SL_MEDIAN_FAST__PRE 0x0
5381
5382#define QAM_SL_ALPHA__A 0x1430013
5383#define QAM_SL_ALPHA__W 3
5384#define QAM_SL_ALPHA__M 0x7
5385#define QAM_SL_ALPHA__PRE 0x0
5386
5387#define QAM_SL_PHASELIMIT__A 0x1430014
5388#define QAM_SL_PHASELIMIT__W 9
5389#define QAM_SL_PHASELIMIT__M 0x1FF
5390#define QAM_SL_PHASELIMIT__PRE 0x0
5391#define QAM_SL_MTA_LENGTH__A 0x1430015
5392#define QAM_SL_MTA_LENGTH__W 2
5393#define QAM_SL_MTA_LENGTH__M 0x3
5394#define QAM_SL_MTA_LENGTH__PRE 0x1
5395
5396#define QAM_SL_MTA_LENGTH_LENGTH__B 0
5397#define QAM_SL_MTA_LENGTH_LENGTH__W 2
5398#define QAM_SL_MTA_LENGTH_LENGTH__M 0x3
5399#define QAM_SL_MTA_LENGTH_LENGTH__PRE 0x1
5400
5401#define QAM_SL_MEDIAN_ERROR__A 0x1430016
5402#define QAM_SL_MEDIAN_ERROR__W 10
5403#define QAM_SL_MEDIAN_ERROR__M 0x3FF
5404#define QAM_SL_MEDIAN_ERROR__PRE 0x0
5405
5406#define QAM_SL_MEDIAN_ERROR_MEDIAN_ERR__B 0
5407#define QAM_SL_MEDIAN_ERROR_MEDIAN_ERR__W 10
5408#define QAM_SL_MEDIAN_ERROR_MEDIAN_ERR__M 0x3FF
5409#define QAM_SL_MEDIAN_ERROR_MEDIAN_ERR__PRE 0x0
5410
5411#define QAM_SL_ERR_POWER__A 0x1430017
5412#define QAM_SL_ERR_POWER__W 16
5413#define QAM_SL_ERR_POWER__M 0xFFFF
5414#define QAM_SL_ERR_POWER__PRE 0x0
5415
5416#define QAM_DQ_COMM_EXEC__A 0x1440000
5417#define QAM_DQ_COMM_EXEC__W 2
5418#define QAM_DQ_COMM_EXEC__M 0x3
5419#define QAM_DQ_COMM_EXEC__PRE 0x0
5420#define QAM_DQ_COMM_EXEC_STOP 0x0
5421#define QAM_DQ_COMM_EXEC_ACTIVE 0x1
5422#define QAM_DQ_COMM_EXEC_HOLD 0x2
5423
5424#define QAM_DQ_MODE__A 0x1440010
5425#define QAM_DQ_MODE__W 5
5426#define QAM_DQ_MODE__M 0x1F
5427#define QAM_DQ_MODE__PRE 0x0
5428
5429#define QAM_DQ_MODE_TAPRESET__B 0
5430#define QAM_DQ_MODE_TAPRESET__W 1
5431#define QAM_DQ_MODE_TAPRESET__M 0x1
5432#define QAM_DQ_MODE_TAPRESET__PRE 0x0
5433#define QAM_DQ_MODE_TAPRESET_RST 0x1
5434
5435#define QAM_DQ_MODE_TAPLMS__B 1
5436#define QAM_DQ_MODE_TAPLMS__W 1
5437#define QAM_DQ_MODE_TAPLMS__M 0x2
5438#define QAM_DQ_MODE_TAPLMS__PRE 0x0
5439#define QAM_DQ_MODE_TAPLMS_UPD 0x2
5440
5441#define QAM_DQ_MODE_TAPDRAIN__B 2
5442#define QAM_DQ_MODE_TAPDRAIN__W 1
5443#define QAM_DQ_MODE_TAPDRAIN__M 0x4
5444#define QAM_DQ_MODE_TAPDRAIN__PRE 0x0
5445#define QAM_DQ_MODE_TAPDRAIN_DRAIN 0x4
5446
5447#define QAM_DQ_MODE_FB__B 3
5448#define QAM_DQ_MODE_FB__W 2
5449#define QAM_DQ_MODE_FB__M 0x18
5450#define QAM_DQ_MODE_FB__PRE 0x0
5451#define QAM_DQ_MODE_FB_CMA 0x0
5452#define QAM_DQ_MODE_FB_RADIUS 0x8
5453#define QAM_DQ_MODE_FB_DFB 0x10
5454#define QAM_DQ_MODE_FB_TRELLIS 0x18
5455
5456#define QAM_DQ_MU_FACTOR__A 0x1440011
5457#define QAM_DQ_MU_FACTOR__W 3
5458#define QAM_DQ_MU_FACTOR__M 0x7
5459#define QAM_DQ_MU_FACTOR__PRE 0x0
5460
5461#define QAM_DQ_LA_FACTOR__A 0x1440012
5462#define QAM_DQ_LA_FACTOR__W 4
5463#define QAM_DQ_LA_FACTOR__M 0xF
5464#define QAM_DQ_LA_FACTOR__PRE 0xC
5465
5466#define QAM_DQ_CMA_RATIO__A 0x1440013
5467#define QAM_DQ_CMA_RATIO__W 14
5468#define QAM_DQ_CMA_RATIO__M 0x3FFF
5469#define QAM_DQ_CMA_RATIO__PRE 0x3CF9
5470#define QAM_DQ_CMA_RATIO_QPSK 0x2000
5471#define QAM_DQ_CMA_RATIO_QAM16 0x34CD
5472#define QAM_DQ_CMA_RATIO_QAM64 0x3A00
5473#define QAM_DQ_CMA_RATIO_QAM256 0x3B4D
5474#define QAM_DQ_CMA_RATIO_QAM1024 0x3BA0
5475
5476#define QAM_DQ_QUAL_RADSEL__A 0x1440014
5477#define QAM_DQ_QUAL_RADSEL__W 3
5478#define QAM_DQ_QUAL_RADSEL__M 0x7
5479#define QAM_DQ_QUAL_RADSEL__PRE 0x0
5480
5481#define QAM_DQ_QUAL_RADSEL_BIT__B 0
5482#define QAM_DQ_QUAL_RADSEL_BIT__W 3
5483#define QAM_DQ_QUAL_RADSEL_BIT__M 0x7
5484#define QAM_DQ_QUAL_RADSEL_BIT__PRE 0x0
5485#define QAM_DQ_QUAL_RADSEL_BIT_PURE_RADIUS 0x0
5486#define QAM_DQ_QUAL_RADSEL_BIT_PURE_CMA 0x6
5487
5488#define QAM_DQ_QUAL_ENA__A 0x1440015
5489#define QAM_DQ_QUAL_ENA__W 1
5490#define QAM_DQ_QUAL_ENA__M 0x1
5491#define QAM_DQ_QUAL_ENA__PRE 0x0
5492
5493#define QAM_DQ_QUAL_ENA_ENA__B 0
5494#define QAM_DQ_QUAL_ENA_ENA__W 1
5495#define QAM_DQ_QUAL_ENA_ENA__M 0x1
5496#define QAM_DQ_QUAL_ENA_ENA__PRE 0x0
5497#define QAM_DQ_QUAL_ENA_ENA_QUAL_WEIGHTING 0x1
5498
5499#define QAM_DQ_QUAL_FUN0__A 0x1440018
5500#define QAM_DQ_QUAL_FUN0__W 6
5501#define QAM_DQ_QUAL_FUN0__M 0x3F
5502#define QAM_DQ_QUAL_FUN0__PRE 0x4
5503
5504#define QAM_DQ_QUAL_FUN0_BIT__B 0
5505#define QAM_DQ_QUAL_FUN0_BIT__W 6
5506#define QAM_DQ_QUAL_FUN0_BIT__M 0x3F
5507#define QAM_DQ_QUAL_FUN0_BIT__PRE 0x4
5508
5509#define QAM_DQ_QUAL_FUN1__A 0x1440019
5510#define QAM_DQ_QUAL_FUN1__W 6
5511#define QAM_DQ_QUAL_FUN1__M 0x3F
5512#define QAM_DQ_QUAL_FUN1__PRE 0x4
5513
5514#define QAM_DQ_QUAL_FUN1_BIT__B 0
5515#define QAM_DQ_QUAL_FUN1_BIT__W 6
5516#define QAM_DQ_QUAL_FUN1_BIT__M 0x3F
5517#define QAM_DQ_QUAL_FUN1_BIT__PRE 0x4
5518
5519#define QAM_DQ_QUAL_FUN2__A 0x144001A
5520#define QAM_DQ_QUAL_FUN2__W 6
5521#define QAM_DQ_QUAL_FUN2__M 0x3F
5522#define QAM_DQ_QUAL_FUN2__PRE 0x4
5523
5524#define QAM_DQ_QUAL_FUN2_BIT__B 0
5525#define QAM_DQ_QUAL_FUN2_BIT__W 6
5526#define QAM_DQ_QUAL_FUN2_BIT__M 0x3F
5527#define QAM_DQ_QUAL_FUN2_BIT__PRE 0x4
5528
5529#define QAM_DQ_QUAL_FUN3__A 0x144001B
5530#define QAM_DQ_QUAL_FUN3__W 6
5531#define QAM_DQ_QUAL_FUN3__M 0x3F
5532#define QAM_DQ_QUAL_FUN3__PRE 0x4
5533
5534#define QAM_DQ_QUAL_FUN3_BIT__B 0
5535#define QAM_DQ_QUAL_FUN3_BIT__W 6
5536#define QAM_DQ_QUAL_FUN3_BIT__M 0x3F
5537#define QAM_DQ_QUAL_FUN3_BIT__PRE 0x4
5538
5539#define QAM_DQ_QUAL_FUN4__A 0x144001C
5540#define QAM_DQ_QUAL_FUN4__W 6
5541#define QAM_DQ_QUAL_FUN4__M 0x3F
5542#define QAM_DQ_QUAL_FUN4__PRE 0x6
5543
5544#define QAM_DQ_QUAL_FUN4_BIT__B 0
5545#define QAM_DQ_QUAL_FUN4_BIT__W 6
5546#define QAM_DQ_QUAL_FUN4_BIT__M 0x3F
5547#define QAM_DQ_QUAL_FUN4_BIT__PRE 0x6
5548
5549#define QAM_DQ_QUAL_FUN5__A 0x144001D
5550#define QAM_DQ_QUAL_FUN5__W 6
5551#define QAM_DQ_QUAL_FUN5__M 0x3F
5552#define QAM_DQ_QUAL_FUN5__PRE 0x6
5553
5554#define QAM_DQ_QUAL_FUN5_BIT__B 0
5555#define QAM_DQ_QUAL_FUN5_BIT__W 6
5556#define QAM_DQ_QUAL_FUN5_BIT__M 0x3F
5557#define QAM_DQ_QUAL_FUN5_BIT__PRE 0x6
5558
5559#define QAM_DQ_RAW_LIM__A 0x144001E
5560#define QAM_DQ_RAW_LIM__W 5
5561#define QAM_DQ_RAW_LIM__M 0x1F
5562#define QAM_DQ_RAW_LIM__PRE 0x1F
5563
5564#define QAM_DQ_RAW_LIM_BIT__B 0
5565#define QAM_DQ_RAW_LIM_BIT__W 5
5566#define QAM_DQ_RAW_LIM_BIT__M 0x1F
5567#define QAM_DQ_RAW_LIM_BIT__PRE 0x1F
5568
5569#define QAM_DQ_TAP_RE_EL0__A 0x1440020
5570#define QAM_DQ_TAP_RE_EL0__W 12
5571#define QAM_DQ_TAP_RE_EL0__M 0xFFF
5572#define QAM_DQ_TAP_RE_EL0__PRE 0x2
5573
5574#define QAM_DQ_TAP_RE_EL0_TAP__B 0
5575#define QAM_DQ_TAP_RE_EL0_TAP__W 12
5576#define QAM_DQ_TAP_RE_EL0_TAP__M 0xFFF
5577#define QAM_DQ_TAP_RE_EL0_TAP__PRE 0x2
5578
5579#define QAM_DQ_TAP_IM_EL0__A 0x1440021
5580#define QAM_DQ_TAP_IM_EL0__W 12
5581#define QAM_DQ_TAP_IM_EL0__M 0xFFF
5582#define QAM_DQ_TAP_IM_EL0__PRE 0x2
5583
5584#define QAM_DQ_TAP_IM_EL0_TAP__B 0
5585#define QAM_DQ_TAP_IM_EL0_TAP__W 12
5586#define QAM_DQ_TAP_IM_EL0_TAP__M 0xFFF
5587#define QAM_DQ_TAP_IM_EL0_TAP__PRE 0x2
5588
5589#define QAM_DQ_TAP_RE_EL1__A 0x1440022
5590#define QAM_DQ_TAP_RE_EL1__W 12
5591#define QAM_DQ_TAP_RE_EL1__M 0xFFF
5592#define QAM_DQ_TAP_RE_EL1__PRE 0x2
5593
5594#define QAM_DQ_TAP_RE_EL1_TAP__B 0
5595#define QAM_DQ_TAP_RE_EL1_TAP__W 12
5596#define QAM_DQ_TAP_RE_EL1_TAP__M 0xFFF
5597#define QAM_DQ_TAP_RE_EL1_TAP__PRE 0x2
5598
5599#define QAM_DQ_TAP_IM_EL1__A 0x1440023
5600#define QAM_DQ_TAP_IM_EL1__W 12
5601#define QAM_DQ_TAP_IM_EL1__M 0xFFF
5602#define QAM_DQ_TAP_IM_EL1__PRE 0x2
5603
5604#define QAM_DQ_TAP_IM_EL1_TAP__B 0
5605#define QAM_DQ_TAP_IM_EL1_TAP__W 12
5606#define QAM_DQ_TAP_IM_EL1_TAP__M 0xFFF
5607#define QAM_DQ_TAP_IM_EL1_TAP__PRE 0x2
5608
5609#define QAM_DQ_TAP_RE_EL2__A 0x1440024
5610#define QAM_DQ_TAP_RE_EL2__W 12
5611#define QAM_DQ_TAP_RE_EL2__M 0xFFF
5612#define QAM_DQ_TAP_RE_EL2__PRE 0x2
5613
5614#define QAM_DQ_TAP_RE_EL2_TAP__B 0
5615#define QAM_DQ_TAP_RE_EL2_TAP__W 12
5616#define QAM_DQ_TAP_RE_EL2_TAP__M 0xFFF
5617#define QAM_DQ_TAP_RE_EL2_TAP__PRE 0x2
5618
5619#define QAM_DQ_TAP_IM_EL2__A 0x1440025
5620#define QAM_DQ_TAP_IM_EL2__W 12
5621#define QAM_DQ_TAP_IM_EL2__M 0xFFF
5622#define QAM_DQ_TAP_IM_EL2__PRE 0x2
5623
5624#define QAM_DQ_TAP_IM_EL2_TAP__B 0
5625#define QAM_DQ_TAP_IM_EL2_TAP__W 12
5626#define QAM_DQ_TAP_IM_EL2_TAP__M 0xFFF
5627#define QAM_DQ_TAP_IM_EL2_TAP__PRE 0x2
5628
5629#define QAM_DQ_TAP_RE_EL3__A 0x1440026
5630#define QAM_DQ_TAP_RE_EL3__W 12
5631#define QAM_DQ_TAP_RE_EL3__M 0xFFF
5632#define QAM_DQ_TAP_RE_EL3__PRE 0x2
5633
5634#define QAM_DQ_TAP_RE_EL3_TAP__B 0
5635#define QAM_DQ_TAP_RE_EL3_TAP__W 12
5636#define QAM_DQ_TAP_RE_EL3_TAP__M 0xFFF
5637#define QAM_DQ_TAP_RE_EL3_TAP__PRE 0x2
5638
5639#define QAM_DQ_TAP_IM_EL3__A 0x1440027
5640#define QAM_DQ_TAP_IM_EL3__W 12
5641#define QAM_DQ_TAP_IM_EL3__M 0xFFF
5642#define QAM_DQ_TAP_IM_EL3__PRE 0x2
5643
5644#define QAM_DQ_TAP_IM_EL3_TAP__B 0
5645#define QAM_DQ_TAP_IM_EL3_TAP__W 12
5646#define QAM_DQ_TAP_IM_EL3_TAP__M 0xFFF
5647#define QAM_DQ_TAP_IM_EL3_TAP__PRE 0x2
5648
5649#define QAM_DQ_TAP_RE_EL4__A 0x1440028
5650#define QAM_DQ_TAP_RE_EL4__W 12
5651#define QAM_DQ_TAP_RE_EL4__M 0xFFF
5652#define QAM_DQ_TAP_RE_EL4__PRE 0x2
5653
5654#define QAM_DQ_TAP_RE_EL4_TAP__B 0
5655#define QAM_DQ_TAP_RE_EL4_TAP__W 12
5656#define QAM_DQ_TAP_RE_EL4_TAP__M 0xFFF
5657#define QAM_DQ_TAP_RE_EL4_TAP__PRE 0x2
5658
5659#define QAM_DQ_TAP_IM_EL4__A 0x1440029
5660#define QAM_DQ_TAP_IM_EL4__W 12
5661#define QAM_DQ_TAP_IM_EL4__M 0xFFF
5662#define QAM_DQ_TAP_IM_EL4__PRE 0x2
5663
5664#define QAM_DQ_TAP_IM_EL4_TAP__B 0
5665#define QAM_DQ_TAP_IM_EL4_TAP__W 12
5666#define QAM_DQ_TAP_IM_EL4_TAP__M 0xFFF
5667#define QAM_DQ_TAP_IM_EL4_TAP__PRE 0x2
5668
5669#define QAM_DQ_TAP_RE_EL5__A 0x144002A
5670#define QAM_DQ_TAP_RE_EL5__W 12
5671#define QAM_DQ_TAP_RE_EL5__M 0xFFF
5672#define QAM_DQ_TAP_RE_EL5__PRE 0x2
5673
5674#define QAM_DQ_TAP_RE_EL5_TAP__B 0
5675#define QAM_DQ_TAP_RE_EL5_TAP__W 12
5676#define QAM_DQ_TAP_RE_EL5_TAP__M 0xFFF
5677#define QAM_DQ_TAP_RE_EL5_TAP__PRE 0x2
5678
5679#define QAM_DQ_TAP_IM_EL5__A 0x144002B
5680#define QAM_DQ_TAP_IM_EL5__W 12
5681#define QAM_DQ_TAP_IM_EL5__M 0xFFF
5682#define QAM_DQ_TAP_IM_EL5__PRE 0x2
5683
5684#define QAM_DQ_TAP_IM_EL5_TAP__B 0
5685#define QAM_DQ_TAP_IM_EL5_TAP__W 12
5686#define QAM_DQ_TAP_IM_EL5_TAP__M 0xFFF
5687#define QAM_DQ_TAP_IM_EL5_TAP__PRE 0x2
5688
5689#define QAM_DQ_TAP_RE_EL6__A 0x144002C
5690#define QAM_DQ_TAP_RE_EL6__W 12
5691#define QAM_DQ_TAP_RE_EL6__M 0xFFF
5692#define QAM_DQ_TAP_RE_EL6__PRE 0x2
5693
5694#define QAM_DQ_TAP_RE_EL6_TAP__B 0
5695#define QAM_DQ_TAP_RE_EL6_TAP__W 12
5696#define QAM_DQ_TAP_RE_EL6_TAP__M 0xFFF
5697#define QAM_DQ_TAP_RE_EL6_TAP__PRE 0x2
5698
5699#define QAM_DQ_TAP_IM_EL6__A 0x144002D
5700#define QAM_DQ_TAP_IM_EL6__W 12
5701#define QAM_DQ_TAP_IM_EL6__M 0xFFF
5702#define QAM_DQ_TAP_IM_EL6__PRE 0x2
5703
5704#define QAM_DQ_TAP_IM_EL6_TAP__B 0
5705#define QAM_DQ_TAP_IM_EL6_TAP__W 12
5706#define QAM_DQ_TAP_IM_EL6_TAP__M 0xFFF
5707#define QAM_DQ_TAP_IM_EL6_TAP__PRE 0x2
5708
5709#define QAM_DQ_TAP_RE_EL7__A 0x144002E
5710#define QAM_DQ_TAP_RE_EL7__W 12
5711#define QAM_DQ_TAP_RE_EL7__M 0xFFF
5712#define QAM_DQ_TAP_RE_EL7__PRE 0x2
5713
5714#define QAM_DQ_TAP_RE_EL7_TAP__B 0
5715#define QAM_DQ_TAP_RE_EL7_TAP__W 12
5716#define QAM_DQ_TAP_RE_EL7_TAP__M 0xFFF
5717#define QAM_DQ_TAP_RE_EL7_TAP__PRE 0x2
5718
5719#define QAM_DQ_TAP_IM_EL7__A 0x144002F
5720#define QAM_DQ_TAP_IM_EL7__W 12
5721#define QAM_DQ_TAP_IM_EL7__M 0xFFF
5722#define QAM_DQ_TAP_IM_EL7__PRE 0x2
5723
5724#define QAM_DQ_TAP_IM_EL7_TAP__B 0
5725#define QAM_DQ_TAP_IM_EL7_TAP__W 12
5726#define QAM_DQ_TAP_IM_EL7_TAP__M 0xFFF
5727#define QAM_DQ_TAP_IM_EL7_TAP__PRE 0x2
5728
5729#define QAM_DQ_TAP_RE_EL8__A 0x1440030
5730#define QAM_DQ_TAP_RE_EL8__W 12
5731#define QAM_DQ_TAP_RE_EL8__M 0xFFF
5732#define QAM_DQ_TAP_RE_EL8__PRE 0x2
5733
5734#define QAM_DQ_TAP_RE_EL8_TAP__B 0
5735#define QAM_DQ_TAP_RE_EL8_TAP__W 12
5736#define QAM_DQ_TAP_RE_EL8_TAP__M 0xFFF
5737#define QAM_DQ_TAP_RE_EL8_TAP__PRE 0x2
5738
5739#define QAM_DQ_TAP_IM_EL8__A 0x1440031
5740#define QAM_DQ_TAP_IM_EL8__W 12
5741#define QAM_DQ_TAP_IM_EL8__M 0xFFF
5742#define QAM_DQ_TAP_IM_EL8__PRE 0x2
5743
5744#define QAM_DQ_TAP_IM_EL8_TAP__B 0
5745#define QAM_DQ_TAP_IM_EL8_TAP__W 12
5746#define QAM_DQ_TAP_IM_EL8_TAP__M 0xFFF
5747#define QAM_DQ_TAP_IM_EL8_TAP__PRE 0x2
5748
5749#define QAM_DQ_TAP_RE_EL9__A 0x1440032
5750#define QAM_DQ_TAP_RE_EL9__W 12
5751#define QAM_DQ_TAP_RE_EL9__M 0xFFF
5752#define QAM_DQ_TAP_RE_EL9__PRE 0x2
5753
5754#define QAM_DQ_TAP_RE_EL9_TAP__B 0
5755#define QAM_DQ_TAP_RE_EL9_TAP__W 12
5756#define QAM_DQ_TAP_RE_EL9_TAP__M 0xFFF
5757#define QAM_DQ_TAP_RE_EL9_TAP__PRE 0x2
5758
5759#define QAM_DQ_TAP_IM_EL9__A 0x1440033
5760#define QAM_DQ_TAP_IM_EL9__W 12
5761#define QAM_DQ_TAP_IM_EL9__M 0xFFF
5762#define QAM_DQ_TAP_IM_EL9__PRE 0x2
5763
5764#define QAM_DQ_TAP_IM_EL9_TAP__B 0
5765#define QAM_DQ_TAP_IM_EL9_TAP__W 12
5766#define QAM_DQ_TAP_IM_EL9_TAP__M 0xFFF
5767#define QAM_DQ_TAP_IM_EL9_TAP__PRE 0x2
5768
5769#define QAM_DQ_TAP_RE_EL10__A 0x1440034
5770#define QAM_DQ_TAP_RE_EL10__W 12
5771#define QAM_DQ_TAP_RE_EL10__M 0xFFF
5772#define QAM_DQ_TAP_RE_EL10__PRE 0x2
5773
5774#define QAM_DQ_TAP_RE_EL10_TAP__B 0
5775#define QAM_DQ_TAP_RE_EL10_TAP__W 12
5776#define QAM_DQ_TAP_RE_EL10_TAP__M 0xFFF
5777#define QAM_DQ_TAP_RE_EL10_TAP__PRE 0x2
5778
5779#define QAM_DQ_TAP_IM_EL10__A 0x1440035
5780#define QAM_DQ_TAP_IM_EL10__W 12
5781#define QAM_DQ_TAP_IM_EL10__M 0xFFF
5782#define QAM_DQ_TAP_IM_EL10__PRE 0x2
5783
5784#define QAM_DQ_TAP_IM_EL10_TAP__B 0
5785#define QAM_DQ_TAP_IM_EL10_TAP__W 12
5786#define QAM_DQ_TAP_IM_EL10_TAP__M 0xFFF
5787#define QAM_DQ_TAP_IM_EL10_TAP__PRE 0x2
5788
5789#define QAM_DQ_TAP_RE_EL11__A 0x1440036
5790#define QAM_DQ_TAP_RE_EL11__W 12
5791#define QAM_DQ_TAP_RE_EL11__M 0xFFF
5792#define QAM_DQ_TAP_RE_EL11__PRE 0x2
5793
5794#define QAM_DQ_TAP_RE_EL11_TAP__B 0
5795#define QAM_DQ_TAP_RE_EL11_TAP__W 12
5796#define QAM_DQ_TAP_RE_EL11_TAP__M 0xFFF
5797#define QAM_DQ_TAP_RE_EL11_TAP__PRE 0x2
5798
5799#define QAM_DQ_TAP_IM_EL11__A 0x1440037
5800#define QAM_DQ_TAP_IM_EL11__W 12
5801#define QAM_DQ_TAP_IM_EL11__M 0xFFF
5802#define QAM_DQ_TAP_IM_EL11__PRE 0x2
5803
5804#define QAM_DQ_TAP_IM_EL11_TAP__B 0
5805#define QAM_DQ_TAP_IM_EL11_TAP__W 12
5806#define QAM_DQ_TAP_IM_EL11_TAP__M 0xFFF
5807#define QAM_DQ_TAP_IM_EL11_TAP__PRE 0x2
5808
5809#define QAM_DQ_TAP_RE_EL12__A 0x1440038
5810#define QAM_DQ_TAP_RE_EL12__W 12
5811#define QAM_DQ_TAP_RE_EL12__M 0xFFF
5812#define QAM_DQ_TAP_RE_EL12__PRE 0x2
5813
5814#define QAM_DQ_TAP_RE_EL12_TAP__B 0
5815#define QAM_DQ_TAP_RE_EL12_TAP__W 12
5816#define QAM_DQ_TAP_RE_EL12_TAP__M 0xFFF
5817#define QAM_DQ_TAP_RE_EL12_TAP__PRE 0x2
5818
5819#define QAM_DQ_TAP_IM_EL12__A 0x1440039
5820#define QAM_DQ_TAP_IM_EL12__W 12
5821#define QAM_DQ_TAP_IM_EL12__M 0xFFF
5822#define QAM_DQ_TAP_IM_EL12__PRE 0x2
5823
5824#define QAM_DQ_TAP_IM_EL12_TAP__B 0
5825#define QAM_DQ_TAP_IM_EL12_TAP__W 12
5826#define QAM_DQ_TAP_IM_EL12_TAP__M 0xFFF
5827#define QAM_DQ_TAP_IM_EL12_TAP__PRE 0x2
5828
5829#define QAM_DQ_TAP_RE_EL13__A 0x144003A
5830#define QAM_DQ_TAP_RE_EL13__W 12
5831#define QAM_DQ_TAP_RE_EL13__M 0xFFF
5832#define QAM_DQ_TAP_RE_EL13__PRE 0x2
5833
5834#define QAM_DQ_TAP_RE_EL13_TAP__B 0
5835#define QAM_DQ_TAP_RE_EL13_TAP__W 12
5836#define QAM_DQ_TAP_RE_EL13_TAP__M 0xFFF
5837#define QAM_DQ_TAP_RE_EL13_TAP__PRE 0x2
5838
5839#define QAM_DQ_TAP_IM_EL13__A 0x144003B
5840#define QAM_DQ_TAP_IM_EL13__W 12
5841#define QAM_DQ_TAP_IM_EL13__M 0xFFF
5842#define QAM_DQ_TAP_IM_EL13__PRE 0x2
5843
5844#define QAM_DQ_TAP_IM_EL13_TAP__B 0
5845#define QAM_DQ_TAP_IM_EL13_TAP__W 12
5846#define QAM_DQ_TAP_IM_EL13_TAP__M 0xFFF
5847#define QAM_DQ_TAP_IM_EL13_TAP__PRE 0x2
5848
5849#define QAM_DQ_TAP_RE_EL14__A 0x144003C
5850#define QAM_DQ_TAP_RE_EL14__W 12
5851#define QAM_DQ_TAP_RE_EL14__M 0xFFF
5852#define QAM_DQ_TAP_RE_EL14__PRE 0x2
5853
5854#define QAM_DQ_TAP_RE_EL14_TAP__B 0
5855#define QAM_DQ_TAP_RE_EL14_TAP__W 12
5856#define QAM_DQ_TAP_RE_EL14_TAP__M 0xFFF
5857#define QAM_DQ_TAP_RE_EL14_TAP__PRE 0x2
5858
5859#define QAM_DQ_TAP_IM_EL14__A 0x144003D
5860#define QAM_DQ_TAP_IM_EL14__W 12
5861#define QAM_DQ_TAP_IM_EL14__M 0xFFF
5862#define QAM_DQ_TAP_IM_EL14__PRE 0x2
5863
5864#define QAM_DQ_TAP_IM_EL14_TAP__B 0
5865#define QAM_DQ_TAP_IM_EL14_TAP__W 12
5866#define QAM_DQ_TAP_IM_EL14_TAP__M 0xFFF
5867#define QAM_DQ_TAP_IM_EL14_TAP__PRE 0x2
5868
5869#define QAM_DQ_TAP_RE_EL15__A 0x144003E
5870#define QAM_DQ_TAP_RE_EL15__W 12
5871#define QAM_DQ_TAP_RE_EL15__M 0xFFF
5872#define QAM_DQ_TAP_RE_EL15__PRE 0x2
5873
5874#define QAM_DQ_TAP_RE_EL15_TAP__B 0
5875#define QAM_DQ_TAP_RE_EL15_TAP__W 12
5876#define QAM_DQ_TAP_RE_EL15_TAP__M 0xFFF
5877#define QAM_DQ_TAP_RE_EL15_TAP__PRE 0x2
5878
5879#define QAM_DQ_TAP_IM_EL15__A 0x144003F
5880#define QAM_DQ_TAP_IM_EL15__W 12
5881#define QAM_DQ_TAP_IM_EL15__M 0xFFF
5882#define QAM_DQ_TAP_IM_EL15__PRE 0x2
5883
5884#define QAM_DQ_TAP_IM_EL15_TAP__B 0
5885#define QAM_DQ_TAP_IM_EL15_TAP__W 12
5886#define QAM_DQ_TAP_IM_EL15_TAP__M 0xFFF
5887#define QAM_DQ_TAP_IM_EL15_TAP__PRE 0x2
5888
5889#define QAM_DQ_TAP_RE_EL16__A 0x1440040
5890#define QAM_DQ_TAP_RE_EL16__W 12
5891#define QAM_DQ_TAP_RE_EL16__M 0xFFF
5892#define QAM_DQ_TAP_RE_EL16__PRE 0x2
5893
5894#define QAM_DQ_TAP_RE_EL16_TAP__B 0
5895#define QAM_DQ_TAP_RE_EL16_TAP__W 12
5896#define QAM_DQ_TAP_RE_EL16_TAP__M 0xFFF
5897#define QAM_DQ_TAP_RE_EL16_TAP__PRE 0x2
5898
5899#define QAM_DQ_TAP_IM_EL16__A 0x1440041
5900#define QAM_DQ_TAP_IM_EL16__W 12
5901#define QAM_DQ_TAP_IM_EL16__M 0xFFF
5902#define QAM_DQ_TAP_IM_EL16__PRE 0x2
5903
5904#define QAM_DQ_TAP_IM_EL16_TAP__B 0
5905#define QAM_DQ_TAP_IM_EL16_TAP__W 12
5906#define QAM_DQ_TAP_IM_EL16_TAP__M 0xFFF
5907#define QAM_DQ_TAP_IM_EL16_TAP__PRE 0x2
5908
5909#define QAM_DQ_TAP_RE_EL17__A 0x1440042
5910#define QAM_DQ_TAP_RE_EL17__W 12
5911#define QAM_DQ_TAP_RE_EL17__M 0xFFF
5912#define QAM_DQ_TAP_RE_EL17__PRE 0x2
5913
5914#define QAM_DQ_TAP_RE_EL17_TAP__B 0
5915#define QAM_DQ_TAP_RE_EL17_TAP__W 12
5916#define QAM_DQ_TAP_RE_EL17_TAP__M 0xFFF
5917#define QAM_DQ_TAP_RE_EL17_TAP__PRE 0x2
5918
5919#define QAM_DQ_TAP_IM_EL17__A 0x1440043
5920#define QAM_DQ_TAP_IM_EL17__W 12
5921#define QAM_DQ_TAP_IM_EL17__M 0xFFF
5922#define QAM_DQ_TAP_IM_EL17__PRE 0x2
5923
5924#define QAM_DQ_TAP_IM_EL17_TAP__B 0
5925#define QAM_DQ_TAP_IM_EL17_TAP__W 12
5926#define QAM_DQ_TAP_IM_EL17_TAP__M 0xFFF
5927#define QAM_DQ_TAP_IM_EL17_TAP__PRE 0x2
5928
5929#define QAM_DQ_TAP_RE_EL18__A 0x1440044
5930#define QAM_DQ_TAP_RE_EL18__W 12
5931#define QAM_DQ_TAP_RE_EL18__M 0xFFF
5932#define QAM_DQ_TAP_RE_EL18__PRE 0x2
5933
5934#define QAM_DQ_TAP_RE_EL18_TAP__B 0
5935#define QAM_DQ_TAP_RE_EL18_TAP__W 12
5936#define QAM_DQ_TAP_RE_EL18_TAP__M 0xFFF
5937#define QAM_DQ_TAP_RE_EL18_TAP__PRE 0x2
5938
5939#define QAM_DQ_TAP_IM_EL18__A 0x1440045
5940#define QAM_DQ_TAP_IM_EL18__W 12
5941#define QAM_DQ_TAP_IM_EL18__M 0xFFF
5942#define QAM_DQ_TAP_IM_EL18__PRE 0x2
5943
5944#define QAM_DQ_TAP_IM_EL18_TAP__B 0
5945#define QAM_DQ_TAP_IM_EL18_TAP__W 12
5946#define QAM_DQ_TAP_IM_EL18_TAP__M 0xFFF
5947#define QAM_DQ_TAP_IM_EL18_TAP__PRE 0x2
5948
5949#define QAM_DQ_TAP_RE_EL19__A 0x1440046
5950#define QAM_DQ_TAP_RE_EL19__W 12
5951#define QAM_DQ_TAP_RE_EL19__M 0xFFF
5952#define QAM_DQ_TAP_RE_EL19__PRE 0x2
5953
5954#define QAM_DQ_TAP_RE_EL19_TAP__B 0
5955#define QAM_DQ_TAP_RE_EL19_TAP__W 12
5956#define QAM_DQ_TAP_RE_EL19_TAP__M 0xFFF
5957#define QAM_DQ_TAP_RE_EL19_TAP__PRE 0x2
5958
5959#define QAM_DQ_TAP_IM_EL19__A 0x1440047
5960#define QAM_DQ_TAP_IM_EL19__W 12
5961#define QAM_DQ_TAP_IM_EL19__M 0xFFF
5962#define QAM_DQ_TAP_IM_EL19__PRE 0x2
5963
5964#define QAM_DQ_TAP_IM_EL19_TAP__B 0
5965#define QAM_DQ_TAP_IM_EL19_TAP__W 12
5966#define QAM_DQ_TAP_IM_EL19_TAP__M 0xFFF
5967#define QAM_DQ_TAP_IM_EL19_TAP__PRE 0x2
5968
5969#define QAM_DQ_TAP_RE_EL20__A 0x1440048
5970#define QAM_DQ_TAP_RE_EL20__W 12
5971#define QAM_DQ_TAP_RE_EL20__M 0xFFF
5972#define QAM_DQ_TAP_RE_EL20__PRE 0x2
5973
5974#define QAM_DQ_TAP_RE_EL20_TAP__B 0
5975#define QAM_DQ_TAP_RE_EL20_TAP__W 12
5976#define QAM_DQ_TAP_RE_EL20_TAP__M 0xFFF
5977#define QAM_DQ_TAP_RE_EL20_TAP__PRE 0x2
5978
5979#define QAM_DQ_TAP_IM_EL20__A 0x1440049
5980#define QAM_DQ_TAP_IM_EL20__W 12
5981#define QAM_DQ_TAP_IM_EL20__M 0xFFF
5982#define QAM_DQ_TAP_IM_EL20__PRE 0x2
5983
5984#define QAM_DQ_TAP_IM_EL20_TAP__B 0
5985#define QAM_DQ_TAP_IM_EL20_TAP__W 12
5986#define QAM_DQ_TAP_IM_EL20_TAP__M 0xFFF
5987#define QAM_DQ_TAP_IM_EL20_TAP__PRE 0x2
5988
5989#define QAM_DQ_TAP_RE_EL21__A 0x144004A
5990#define QAM_DQ_TAP_RE_EL21__W 12
5991#define QAM_DQ_TAP_RE_EL21__M 0xFFF
5992#define QAM_DQ_TAP_RE_EL21__PRE 0x2
5993
5994#define QAM_DQ_TAP_RE_EL21_TAP__B 0
5995#define QAM_DQ_TAP_RE_EL21_TAP__W 12
5996#define QAM_DQ_TAP_RE_EL21_TAP__M 0xFFF
5997#define QAM_DQ_TAP_RE_EL21_TAP__PRE 0x2
5998
5999#define QAM_DQ_TAP_IM_EL21__A 0x144004B
6000#define QAM_DQ_TAP_IM_EL21__W 12
6001#define QAM_DQ_TAP_IM_EL21__M 0xFFF
6002#define QAM_DQ_TAP_IM_EL21__PRE 0x2
6003
6004#define QAM_DQ_TAP_IM_EL21_TAP__B 0
6005#define QAM_DQ_TAP_IM_EL21_TAP__W 12
6006#define QAM_DQ_TAP_IM_EL21_TAP__M 0xFFF
6007#define QAM_DQ_TAP_IM_EL21_TAP__PRE 0x2
6008
6009#define QAM_DQ_TAP_RE_EL22__A 0x144004C
6010#define QAM_DQ_TAP_RE_EL22__W 12
6011#define QAM_DQ_TAP_RE_EL22__M 0xFFF
6012#define QAM_DQ_TAP_RE_EL22__PRE 0x2
6013
6014#define QAM_DQ_TAP_RE_EL22_TAP__B 0
6015#define QAM_DQ_TAP_RE_EL22_TAP__W 12
6016#define QAM_DQ_TAP_RE_EL22_TAP__M 0xFFF
6017#define QAM_DQ_TAP_RE_EL22_TAP__PRE 0x2
6018
6019#define QAM_DQ_TAP_IM_EL22__A 0x144004D
6020#define QAM_DQ_TAP_IM_EL22__W 12
6021#define QAM_DQ_TAP_IM_EL22__M 0xFFF
6022#define QAM_DQ_TAP_IM_EL22__PRE 0x2
6023
6024#define QAM_DQ_TAP_IM_EL22_TAP__B 0
6025#define QAM_DQ_TAP_IM_EL22_TAP__W 12
6026#define QAM_DQ_TAP_IM_EL22_TAP__M 0xFFF
6027#define QAM_DQ_TAP_IM_EL22_TAP__PRE 0x2
6028
6029#define QAM_DQ_TAP_RE_EL23__A 0x144004E
6030#define QAM_DQ_TAP_RE_EL23__W 12
6031#define QAM_DQ_TAP_RE_EL23__M 0xFFF
6032#define QAM_DQ_TAP_RE_EL23__PRE 0x2
6033
6034#define QAM_DQ_TAP_RE_EL23_TAP__B 0
6035#define QAM_DQ_TAP_RE_EL23_TAP__W 12
6036#define QAM_DQ_TAP_RE_EL23_TAP__M 0xFFF
6037#define QAM_DQ_TAP_RE_EL23_TAP__PRE 0x2
6038
6039#define QAM_DQ_TAP_IM_EL23__A 0x144004F
6040#define QAM_DQ_TAP_IM_EL23__W 12
6041#define QAM_DQ_TAP_IM_EL23__M 0xFFF
6042#define QAM_DQ_TAP_IM_EL23__PRE 0x2
6043
6044#define QAM_DQ_TAP_IM_EL23_TAP__B 0
6045#define QAM_DQ_TAP_IM_EL23_TAP__W 12
6046#define QAM_DQ_TAP_IM_EL23_TAP__M 0xFFF
6047#define QAM_DQ_TAP_IM_EL23_TAP__PRE 0x2
6048
6049#define QAM_DQ_TAP_RE_EL24__A 0x1440050
6050#define QAM_DQ_TAP_RE_EL24__W 12
6051#define QAM_DQ_TAP_RE_EL24__M 0xFFF
6052#define QAM_DQ_TAP_RE_EL24__PRE 0x2
6053
6054#define QAM_DQ_TAP_RE_EL24_TAP__B 0
6055#define QAM_DQ_TAP_RE_EL24_TAP__W 12
6056#define QAM_DQ_TAP_RE_EL24_TAP__M 0xFFF
6057#define QAM_DQ_TAP_RE_EL24_TAP__PRE 0x2
6058
6059#define QAM_DQ_TAP_IM_EL24__A 0x1440051
6060#define QAM_DQ_TAP_IM_EL24__W 12
6061#define QAM_DQ_TAP_IM_EL24__M 0xFFF
6062#define QAM_DQ_TAP_IM_EL24__PRE 0x2
6063
6064#define QAM_DQ_TAP_IM_EL24_TAP__B 0
6065#define QAM_DQ_TAP_IM_EL24_TAP__W 12
6066#define QAM_DQ_TAP_IM_EL24_TAP__M 0xFFF
6067#define QAM_DQ_TAP_IM_EL24_TAP__PRE 0x2
6068
6069#define QAM_DQ_TAP_RE_EL25__A 0x1440052
6070#define QAM_DQ_TAP_RE_EL25__W 12
6071#define QAM_DQ_TAP_RE_EL25__M 0xFFF
6072#define QAM_DQ_TAP_RE_EL25__PRE 0x2
6073
6074#define QAM_DQ_TAP_RE_EL25_TAP__B 0
6075#define QAM_DQ_TAP_RE_EL25_TAP__W 12
6076#define QAM_DQ_TAP_RE_EL25_TAP__M 0xFFF
6077#define QAM_DQ_TAP_RE_EL25_TAP__PRE 0x2
6078
6079#define QAM_DQ_TAP_IM_EL25__A 0x1440053
6080#define QAM_DQ_TAP_IM_EL25__W 12
6081#define QAM_DQ_TAP_IM_EL25__M 0xFFF
6082#define QAM_DQ_TAP_IM_EL25__PRE 0x2
6083
6084#define QAM_DQ_TAP_IM_EL25_TAP__B 0
6085#define QAM_DQ_TAP_IM_EL25_TAP__W 12
6086#define QAM_DQ_TAP_IM_EL25_TAP__M 0xFFF
6087#define QAM_DQ_TAP_IM_EL25_TAP__PRE 0x2
6088
6089#define QAM_DQ_TAP_RE_EL26__A 0x1440054
6090#define QAM_DQ_TAP_RE_EL26__W 12
6091#define QAM_DQ_TAP_RE_EL26__M 0xFFF
6092#define QAM_DQ_TAP_RE_EL26__PRE 0x2
6093
6094#define QAM_DQ_TAP_RE_EL26_TAP__B 0
6095#define QAM_DQ_TAP_RE_EL26_TAP__W 12
6096#define QAM_DQ_TAP_RE_EL26_TAP__M 0xFFF
6097#define QAM_DQ_TAP_RE_EL26_TAP__PRE 0x2
6098
6099#define QAM_DQ_TAP_IM_EL26__A 0x1440055
6100#define QAM_DQ_TAP_IM_EL26__W 12
6101#define QAM_DQ_TAP_IM_EL26__M 0xFFF
6102#define QAM_DQ_TAP_IM_EL26__PRE 0x2
6103
6104#define QAM_DQ_TAP_IM_EL26_TAP__B 0
6105#define QAM_DQ_TAP_IM_EL26_TAP__W 12
6106#define QAM_DQ_TAP_IM_EL26_TAP__M 0xFFF
6107#define QAM_DQ_TAP_IM_EL26_TAP__PRE 0x2
6108
6109#define QAM_DQ_TAP_RE_EL27__A 0x1440056
6110#define QAM_DQ_TAP_RE_EL27__W 12
6111#define QAM_DQ_TAP_RE_EL27__M 0xFFF
6112#define QAM_DQ_TAP_RE_EL27__PRE 0x2
6113
6114#define QAM_DQ_TAP_RE_EL27_TAP__B 0
6115#define QAM_DQ_TAP_RE_EL27_TAP__W 12
6116#define QAM_DQ_TAP_RE_EL27_TAP__M 0xFFF
6117#define QAM_DQ_TAP_RE_EL27_TAP__PRE 0x2
6118
6119#define QAM_DQ_TAP_IM_EL27__A 0x1440057
6120#define QAM_DQ_TAP_IM_EL27__W 12
6121#define QAM_DQ_TAP_IM_EL27__M 0xFFF
6122#define QAM_DQ_TAP_IM_EL27__PRE 0x2
6123
6124#define QAM_DQ_TAP_IM_EL27_TAP__B 0
6125#define QAM_DQ_TAP_IM_EL27_TAP__W 12
6126#define QAM_DQ_TAP_IM_EL27_TAP__M 0xFFF
6127#define QAM_DQ_TAP_IM_EL27_TAP__PRE 0x2
6128
6129#define QAM_LC_COMM_EXEC__A 0x1450000
6130#define QAM_LC_COMM_EXEC__W 2
6131#define QAM_LC_COMM_EXEC__M 0x3
6132#define QAM_LC_COMM_EXEC__PRE 0x0
6133#define QAM_LC_COMM_EXEC_STOP 0x0
6134#define QAM_LC_COMM_EXEC_ACTIVE 0x1
6135#define QAM_LC_COMM_EXEC_HOLD 0x2
6136
6137#define QAM_LC_COMM_MB__A 0x1450002
6138#define QAM_LC_COMM_MB__W 2
6139#define QAM_LC_COMM_MB__M 0x3
6140#define QAM_LC_COMM_MB__PRE 0x0
6141#define QAM_LC_COMM_MB_CTL__B 0
6142#define QAM_LC_COMM_MB_CTL__W 1
6143#define QAM_LC_COMM_MB_CTL__M 0x1
6144#define QAM_LC_COMM_MB_CTL__PRE 0x0
6145#define QAM_LC_COMM_MB_CTL_OFF 0x0
6146#define QAM_LC_COMM_MB_CTL_ON 0x1
6147#define QAM_LC_COMM_MB_OBS__B 1
6148#define QAM_LC_COMM_MB_OBS__W 1
6149#define QAM_LC_COMM_MB_OBS__M 0x2
6150#define QAM_LC_COMM_MB_OBS__PRE 0x0
6151#define QAM_LC_COMM_MB_OBS_OFF 0x0
6152#define QAM_LC_COMM_MB_OBS_ON 0x2
6153
6154#define QAM_LC_COMM_INT_REQ__A 0x1450003
6155#define QAM_LC_COMM_INT_REQ__W 1
6156#define QAM_LC_COMM_INT_REQ__M 0x1
6157#define QAM_LC_COMM_INT_REQ__PRE 0x0
6158#define QAM_LC_COMM_INT_STA__A 0x1450005
6159#define QAM_LC_COMM_INT_STA__W 3
6160#define QAM_LC_COMM_INT_STA__M 0x7
6161#define QAM_LC_COMM_INT_STA__PRE 0x0
6162
6163#define QAM_LC_COMM_INT_STA_READY__B 0
6164#define QAM_LC_COMM_INT_STA_READY__W 1
6165#define QAM_LC_COMM_INT_STA_READY__M 0x1
6166#define QAM_LC_COMM_INT_STA_READY__PRE 0x0
6167
6168#define QAM_LC_COMM_INT_STA_OVERFLOW__B 1
6169#define QAM_LC_COMM_INT_STA_OVERFLOW__W 1
6170#define QAM_LC_COMM_INT_STA_OVERFLOW__M 0x2
6171#define QAM_LC_COMM_INT_STA_OVERFLOW__PRE 0x0
6172
6173#define QAM_LC_COMM_INT_STA_FREQ_WRAP__B 2
6174#define QAM_LC_COMM_INT_STA_FREQ_WRAP__W 1
6175#define QAM_LC_COMM_INT_STA_FREQ_WRAP__M 0x4
6176#define QAM_LC_COMM_INT_STA_FREQ_WRAP__PRE 0x0
6177
6178#define QAM_LC_COMM_INT_MSK__A 0x1450006
6179#define QAM_LC_COMM_INT_MSK__W 3
6180#define QAM_LC_COMM_INT_MSK__M 0x7
6181#define QAM_LC_COMM_INT_MSK__PRE 0x0
6182#define QAM_LC_COMM_INT_MSK_READY__B 0
6183#define QAM_LC_COMM_INT_MSK_READY__W 1
6184#define QAM_LC_COMM_INT_MSK_READY__M 0x1
6185#define QAM_LC_COMM_INT_MSK_READY__PRE 0x0
6186#define QAM_LC_COMM_INT_MSK_OVERFLOW__B 1
6187#define QAM_LC_COMM_INT_MSK_OVERFLOW__W 1
6188#define QAM_LC_COMM_INT_MSK_OVERFLOW__M 0x2
6189#define QAM_LC_COMM_INT_MSK_OVERFLOW__PRE 0x0
6190#define QAM_LC_COMM_INT_MSK_FREQ_WRAP__B 2
6191#define QAM_LC_COMM_INT_MSK_FREQ_WRAP__W 1
6192#define QAM_LC_COMM_INT_MSK_FREQ_WRAP__M 0x4
6193#define QAM_LC_COMM_INT_MSK_FREQ_WRAP__PRE 0x0
6194
6195#define QAM_LC_COMM_INT_STM__A 0x1450007
6196#define QAM_LC_COMM_INT_STM__W 3
6197#define QAM_LC_COMM_INT_STM__M 0x7
6198#define QAM_LC_COMM_INT_STM__PRE 0x0
6199#define QAM_LC_COMM_INT_STM_READY__B 0
6200#define QAM_LC_COMM_INT_STM_READY__W 1
6201#define QAM_LC_COMM_INT_STM_READY__M 0x1
6202#define QAM_LC_COMM_INT_STM_READY__PRE 0x0
6203#define QAM_LC_COMM_INT_STM_OVERFLOW__B 1
6204#define QAM_LC_COMM_INT_STM_OVERFLOW__W 1
6205#define QAM_LC_COMM_INT_STM_OVERFLOW__M 0x2
6206#define QAM_LC_COMM_INT_STM_OVERFLOW__PRE 0x0
6207#define QAM_LC_COMM_INT_STM_FREQ_WRAP__B 2
6208#define QAM_LC_COMM_INT_STM_FREQ_WRAP__W 1
6209#define QAM_LC_COMM_INT_STM_FREQ_WRAP__M 0x4
6210#define QAM_LC_COMM_INT_STM_FREQ_WRAP__PRE 0x0
6211
6212#define QAM_LC_MODE__A 0x1450010
6213#define QAM_LC_MODE__W 3
6214#define QAM_LC_MODE__M 0x7
6215#define QAM_LC_MODE__PRE 0x7
6216
6217#define QAM_LC_MODE_ENABLE_A__B 0
6218#define QAM_LC_MODE_ENABLE_A__W 1
6219#define QAM_LC_MODE_ENABLE_A__M 0x1
6220#define QAM_LC_MODE_ENABLE_A__PRE 0x1
6221
6222#define QAM_LC_MODE_ENABLE_F__B 1
6223#define QAM_LC_MODE_ENABLE_F__W 1
6224#define QAM_LC_MODE_ENABLE_F__M 0x2
6225#define QAM_LC_MODE_ENABLE_F__PRE 0x2
6226
6227#define QAM_LC_MODE_ENABLE_R__B 2
6228#define QAM_LC_MODE_ENABLE_R__W 1
6229#define QAM_LC_MODE_ENABLE_R__M 0x4
6230#define QAM_LC_MODE_ENABLE_R__PRE 0x4
6231
6232#define QAM_LC_CA__A 0x1450011
6233#define QAM_LC_CA__W 6
6234#define QAM_LC_CA__M 0x3F
6235#define QAM_LC_CA__PRE 0x28
6236
6237#define QAM_LC_CA_COEF__B 0
6238#define QAM_LC_CA_COEF__W 6
6239#define QAM_LC_CA_COEF__M 0x3F
6240#define QAM_LC_CA_COEF__PRE 0x28
6241
6242#define QAM_LC_CF__A 0x1450012
6243#define QAM_LC_CF__W 8
6244#define QAM_LC_CF__M 0xFF
6245#define QAM_LC_CF__PRE 0x8C
6246
6247#define QAM_LC_CF_COEF__B 0
6248#define QAM_LC_CF_COEF__W 8
6249#define QAM_LC_CF_COEF__M 0xFF
6250#define QAM_LC_CF_COEF__PRE 0x8C
6251
6252#define QAM_LC_CF1__A 0x1450013
6253#define QAM_LC_CF1__W 8
6254#define QAM_LC_CF1__M 0xFF
6255#define QAM_LC_CF1__PRE 0x1E
6256
6257#define QAM_LC_CF1_COEF__B 0
6258#define QAM_LC_CF1_COEF__W 8
6259#define QAM_LC_CF1_COEF__M 0xFF
6260#define QAM_LC_CF1_COEF__PRE 0x1E
6261
6262#define QAM_LC_CP__A 0x1450014
6263#define QAM_LC_CP__W 8
6264#define QAM_LC_CP__M 0xFF
6265#define QAM_LC_CP__PRE 0x78
6266
6267#define QAM_LC_CP_COEF__B 0
6268#define QAM_LC_CP_COEF__W 8
6269#define QAM_LC_CP_COEF__M 0xFF
6270#define QAM_LC_CP_COEF__PRE 0x78
6271
6272#define QAM_LC_CI__A 0x1450015
6273#define QAM_LC_CI__W 8
6274#define QAM_LC_CI__M 0xFF
6275#define QAM_LC_CI__PRE 0x46
6276
6277#define QAM_LC_CI_COEF__B 0
6278#define QAM_LC_CI_COEF__W 8
6279#define QAM_LC_CI_COEF__M 0xFF
6280#define QAM_LC_CI_COEF__PRE 0x46
6281
6282#define QAM_LC_EP__A 0x1450016
6283#define QAM_LC_EP__W 6
6284#define QAM_LC_EP__M 0x3F
6285#define QAM_LC_EP__PRE 0x0
6286
6287#define QAM_LC_EP_COEF__B 0
6288#define QAM_LC_EP_COEF__W 6
6289#define QAM_LC_EP_COEF__M 0x3F
6290#define QAM_LC_EP_COEF__PRE 0x0
6291
6292#define QAM_LC_EI__A 0x1450017
6293#define QAM_LC_EI__W 6
6294#define QAM_LC_EI__M 0x3F
6295#define QAM_LC_EI__PRE 0x0
6296
6297#define QAM_LC_EI_COEF__B 0
6298#define QAM_LC_EI_COEF__W 6
6299#define QAM_LC_EI_COEF__M 0x3F
6300#define QAM_LC_EI_COEF__PRE 0x0
6301
6302#define QAM_LC_QUAL_TAB0__A 0x1450018
6303#define QAM_LC_QUAL_TAB0__W 5
6304#define QAM_LC_QUAL_TAB0__M 0x1F
6305#define QAM_LC_QUAL_TAB0__PRE 0x1
6306
6307#define QAM_LC_QUAL_TAB0_VALUE__B 0
6308#define QAM_LC_QUAL_TAB0_VALUE__W 5
6309#define QAM_LC_QUAL_TAB0_VALUE__M 0x1F
6310#define QAM_LC_QUAL_TAB0_VALUE__PRE 0x1
6311
6312#define QAM_LC_QUAL_TAB1__A 0x1450019
6313#define QAM_LC_QUAL_TAB1__W 5
6314#define QAM_LC_QUAL_TAB1__M 0x1F
6315#define QAM_LC_QUAL_TAB1__PRE 0x1
6316
6317#define QAM_LC_QUAL_TAB1_VALUE__B 0
6318#define QAM_LC_QUAL_TAB1_VALUE__W 5
6319#define QAM_LC_QUAL_TAB1_VALUE__M 0x1F
6320#define QAM_LC_QUAL_TAB1_VALUE__PRE 0x1
6321
6322#define QAM_LC_QUAL_TAB2__A 0x145001A
6323#define QAM_LC_QUAL_TAB2__W 5
6324#define QAM_LC_QUAL_TAB2__M 0x1F
6325#define QAM_LC_QUAL_TAB2__PRE 0x1
6326
6327#define QAM_LC_QUAL_TAB2_VALUE__B 0
6328#define QAM_LC_QUAL_TAB2_VALUE__W 5
6329#define QAM_LC_QUAL_TAB2_VALUE__M 0x1F
6330#define QAM_LC_QUAL_TAB2_VALUE__PRE 0x1
6331
6332#define QAM_LC_QUAL_TAB3__A 0x145001B
6333#define QAM_LC_QUAL_TAB3__W 5
6334#define QAM_LC_QUAL_TAB3__M 0x1F
6335#define QAM_LC_QUAL_TAB3__PRE 0x1
6336
6337#define QAM_LC_QUAL_TAB3_VALUE__B 0
6338#define QAM_LC_QUAL_TAB3_VALUE__W 5
6339#define QAM_LC_QUAL_TAB3_VALUE__M 0x1F
6340#define QAM_LC_QUAL_TAB3_VALUE__PRE 0x1
6341
6342#define QAM_LC_QUAL_TAB4__A 0x145001C
6343#define QAM_LC_QUAL_TAB4__W 5
6344#define QAM_LC_QUAL_TAB4__M 0x1F
6345#define QAM_LC_QUAL_TAB4__PRE 0x1
6346
6347#define QAM_LC_QUAL_TAB4_VALUE__B 0
6348#define QAM_LC_QUAL_TAB4_VALUE__W 5
6349#define QAM_LC_QUAL_TAB4_VALUE__M 0x1F
6350#define QAM_LC_QUAL_TAB4_VALUE__PRE 0x1
6351
6352#define QAM_LC_QUAL_TAB5__A 0x145001D
6353#define QAM_LC_QUAL_TAB5__W 5
6354#define QAM_LC_QUAL_TAB5__M 0x1F
6355#define QAM_LC_QUAL_TAB5__PRE 0x1
6356
6357#define QAM_LC_QUAL_TAB5_VALUE__B 0
6358#define QAM_LC_QUAL_TAB5_VALUE__W 5
6359#define QAM_LC_QUAL_TAB5_VALUE__M 0x1F
6360#define QAM_LC_QUAL_TAB5_VALUE__PRE 0x1
6361
6362#define QAM_LC_QUAL_TAB6__A 0x145001E
6363#define QAM_LC_QUAL_TAB6__W 5
6364#define QAM_LC_QUAL_TAB6__M 0x1F
6365#define QAM_LC_QUAL_TAB6__PRE 0x1
6366
6367#define QAM_LC_QUAL_TAB6_VALUE__B 0
6368#define QAM_LC_QUAL_TAB6_VALUE__W 5
6369#define QAM_LC_QUAL_TAB6_VALUE__M 0x1F
6370#define QAM_LC_QUAL_TAB6_VALUE__PRE 0x1
6371
6372#define QAM_LC_QUAL_TAB8__A 0x145001F
6373#define QAM_LC_QUAL_TAB8__W 5
6374#define QAM_LC_QUAL_TAB8__M 0x1F
6375#define QAM_LC_QUAL_TAB8__PRE 0x1
6376
6377#define QAM_LC_QUAL_TAB8_VALUE__B 0
6378#define QAM_LC_QUAL_TAB8_VALUE__W 5
6379#define QAM_LC_QUAL_TAB8_VALUE__M 0x1F
6380#define QAM_LC_QUAL_TAB8_VALUE__PRE 0x1
6381
6382#define QAM_LC_QUAL_TAB9__A 0x1450020
6383#define QAM_LC_QUAL_TAB9__W 5
6384#define QAM_LC_QUAL_TAB9__M 0x1F
6385#define QAM_LC_QUAL_TAB9__PRE 0x1
6386
6387#define QAM_LC_QUAL_TAB9_VALUE__B 0
6388#define QAM_LC_QUAL_TAB9_VALUE__W 5
6389#define QAM_LC_QUAL_TAB9_VALUE__M 0x1F
6390#define QAM_LC_QUAL_TAB9_VALUE__PRE 0x1
6391
6392#define QAM_LC_QUAL_TAB10__A 0x1450021
6393#define QAM_LC_QUAL_TAB10__W 5
6394#define QAM_LC_QUAL_TAB10__M 0x1F
6395#define QAM_LC_QUAL_TAB10__PRE 0x1
6396
6397#define QAM_LC_QUAL_TAB10_VALUE__B 0
6398#define QAM_LC_QUAL_TAB10_VALUE__W 5
6399#define QAM_LC_QUAL_TAB10_VALUE__M 0x1F
6400#define QAM_LC_QUAL_TAB10_VALUE__PRE 0x1
6401
6402#define QAM_LC_QUAL_TAB12__A 0x1450022
6403#define QAM_LC_QUAL_TAB12__W 5
6404#define QAM_LC_QUAL_TAB12__M 0x1F
6405#define QAM_LC_QUAL_TAB12__PRE 0x1
6406
6407#define QAM_LC_QUAL_TAB12_VALUE__B 0
6408#define QAM_LC_QUAL_TAB12_VALUE__W 5
6409#define QAM_LC_QUAL_TAB12_VALUE__M 0x1F
6410#define QAM_LC_QUAL_TAB12_VALUE__PRE 0x1
6411
6412#define QAM_LC_QUAL_TAB15__A 0x1450023
6413#define QAM_LC_QUAL_TAB15__W 5
6414#define QAM_LC_QUAL_TAB15__M 0x1F
6415#define QAM_LC_QUAL_TAB15__PRE 0x1
6416
6417#define QAM_LC_QUAL_TAB15_VALUE__B 0
6418#define QAM_LC_QUAL_TAB15_VALUE__W 5
6419#define QAM_LC_QUAL_TAB15_VALUE__M 0x1F
6420#define QAM_LC_QUAL_TAB15_VALUE__PRE 0x1
6421
6422#define QAM_LC_QUAL_TAB16__A 0x1450024
6423#define QAM_LC_QUAL_TAB16__W 5
6424#define QAM_LC_QUAL_TAB16__M 0x1F
6425#define QAM_LC_QUAL_TAB16__PRE 0x1
6426
6427#define QAM_LC_QUAL_TAB16_VALUE__B 0
6428#define QAM_LC_QUAL_TAB16_VALUE__W 5
6429#define QAM_LC_QUAL_TAB16_VALUE__M 0x1F
6430#define QAM_LC_QUAL_TAB16_VALUE__PRE 0x1
6431
6432#define QAM_LC_QUAL_TAB20__A 0x1450025
6433#define QAM_LC_QUAL_TAB20__W 5
6434#define QAM_LC_QUAL_TAB20__M 0x1F
6435#define QAM_LC_QUAL_TAB20__PRE 0x1
6436
6437#define QAM_LC_QUAL_TAB20_VALUE__B 0
6438#define QAM_LC_QUAL_TAB20_VALUE__W 5
6439#define QAM_LC_QUAL_TAB20_VALUE__M 0x1F
6440#define QAM_LC_QUAL_TAB20_VALUE__PRE 0x1
6441
6442#define QAM_LC_QUAL_TAB25__A 0x1450026
6443#define QAM_LC_QUAL_TAB25__W 5
6444#define QAM_LC_QUAL_TAB25__M 0x1F
6445#define QAM_LC_QUAL_TAB25__PRE 0x1
6446
6447#define QAM_LC_QUAL_TAB25_VALUE__B 0
6448#define QAM_LC_QUAL_TAB25_VALUE__W 5
6449#define QAM_LC_QUAL_TAB25_VALUE__M 0x1F
6450#define QAM_LC_QUAL_TAB25_VALUE__PRE 0x1
6451
6452#define QAM_LC_EQ_TIMING__A 0x1450027
6453#define QAM_LC_EQ_TIMING__W 10
6454#define QAM_LC_EQ_TIMING__M 0x3FF
6455#define QAM_LC_EQ_TIMING__PRE 0x0
6456
6457#define QAM_LC_EQ_TIMING_OFFS__B 0
6458#define QAM_LC_EQ_TIMING_OFFS__W 10
6459#define QAM_LC_EQ_TIMING_OFFS__M 0x3FF
6460#define QAM_LC_EQ_TIMING_OFFS__PRE 0x0
6461
6462#define QAM_LC_LPF_FACTORP__A 0x1450028
6463#define QAM_LC_LPF_FACTORP__W 3
6464#define QAM_LC_LPF_FACTORP__M 0x7
6465#define QAM_LC_LPF_FACTORP__PRE 0x3
6466
6467#define QAM_LC_LPF_FACTORP_FACTOR__B 0
6468#define QAM_LC_LPF_FACTORP_FACTOR__W 3
6469#define QAM_LC_LPF_FACTORP_FACTOR__M 0x7
6470#define QAM_LC_LPF_FACTORP_FACTOR__PRE 0x3
6471
6472#define QAM_LC_LPF_FACTORI__A 0x1450029
6473#define QAM_LC_LPF_FACTORI__W 3
6474#define QAM_LC_LPF_FACTORI__M 0x7
6475#define QAM_LC_LPF_FACTORI__PRE 0x3
6476
6477#define QAM_LC_LPF_FACTORI_FACTOR__B 0
6478#define QAM_LC_LPF_FACTORI_FACTOR__W 3
6479#define QAM_LC_LPF_FACTORI_FACTOR__M 0x7
6480#define QAM_LC_LPF_FACTORI_FACTOR__PRE 0x3
6481
6482#define QAM_LC_RATE_LIMIT__A 0x145002A
6483#define QAM_LC_RATE_LIMIT__W 2
6484#define QAM_LC_RATE_LIMIT__M 0x3
6485#define QAM_LC_RATE_LIMIT__PRE 0x3
6486
6487#define QAM_LC_RATE_LIMIT_LIMIT__B 0
6488#define QAM_LC_RATE_LIMIT_LIMIT__W 2
6489#define QAM_LC_RATE_LIMIT_LIMIT__M 0x3
6490#define QAM_LC_RATE_LIMIT_LIMIT__PRE 0x3
6491
6492#define QAM_LC_SYMBOL_FREQ__A 0x145002B
6493#define QAM_LC_SYMBOL_FREQ__W 10
6494#define QAM_LC_SYMBOL_FREQ__M 0x3FF
6495#define QAM_LC_SYMBOL_FREQ__PRE 0x199
6496
6497#define QAM_LC_SYMBOL_FREQ_FREQ__B 0
6498#define QAM_LC_SYMBOL_FREQ_FREQ__W 10
6499#define QAM_LC_SYMBOL_FREQ_FREQ__M 0x3FF
6500#define QAM_LC_SYMBOL_FREQ_FREQ__PRE 0x199
6501#define QAM_LC_SYMBOL_FREQ_FREQ_QAM_B_64 0x197
6502#define QAM_LC_SYMBOL_FREQ_FREQ_QAM_B_256 0x1B2
6503
6504#define QAM_LC_MTA_LENGTH__A 0x145002C
6505#define QAM_LC_MTA_LENGTH__W 2
6506#define QAM_LC_MTA_LENGTH__M 0x3
6507#define QAM_LC_MTA_LENGTH__PRE 0x2
6508
6509#define QAM_LC_MTA_LENGTH_LENGTH__B 0
6510#define QAM_LC_MTA_LENGTH_LENGTH__W 2
6511#define QAM_LC_MTA_LENGTH_LENGTH__M 0x3
6512#define QAM_LC_MTA_LENGTH_LENGTH__PRE 0x2
6513
6514#define QAM_LC_AMP_ACCU__A 0x145002D
6515#define QAM_LC_AMP_ACCU__W 14
6516#define QAM_LC_AMP_ACCU__M 0x3FFF
6517#define QAM_LC_AMP_ACCU__PRE 0x600
6518
6519#define QAM_LC_AMP_ACCU_ACCU__B 0
6520#define QAM_LC_AMP_ACCU_ACCU__W 14
6521#define QAM_LC_AMP_ACCU_ACCU__M 0x3FFF
6522#define QAM_LC_AMP_ACCU_ACCU__PRE 0x600
6523
6524#define QAM_LC_FREQ_ACCU__A 0x145002E
6525#define QAM_LC_FREQ_ACCU__W 10
6526#define QAM_LC_FREQ_ACCU__M 0x3FF
6527#define QAM_LC_FREQ_ACCU__PRE 0x0
6528
6529#define QAM_LC_FREQ_ACCU_ACCU__B 0
6530#define QAM_LC_FREQ_ACCU_ACCU__W 10
6531#define QAM_LC_FREQ_ACCU_ACCU__M 0x3FF
6532#define QAM_LC_FREQ_ACCU_ACCU__PRE 0x0
6533
6534#define QAM_LC_RATE_ACCU__A 0x145002F
6535#define QAM_LC_RATE_ACCU__W 10
6536#define QAM_LC_RATE_ACCU__M 0x3FF
6537#define QAM_LC_RATE_ACCU__PRE 0x0
6538
6539#define QAM_LC_RATE_ACCU_ACCU__B 0
6540#define QAM_LC_RATE_ACCU_ACCU__W 10
6541#define QAM_LC_RATE_ACCU_ACCU__M 0x3FF
6542#define QAM_LC_RATE_ACCU_ACCU__PRE 0x0
6543
6544#define QAM_LC_AMPLITUDE__A 0x1450030
6545#define QAM_LC_AMPLITUDE__W 10
6546#define QAM_LC_AMPLITUDE__M 0x3FF
6547#define QAM_LC_AMPLITUDE__PRE 0x0
6548
6549#define QAM_LC_AMPLITUDE_SIZE__B 0
6550#define QAM_LC_AMPLITUDE_SIZE__W 10
6551#define QAM_LC_AMPLITUDE_SIZE__M 0x3FF
6552#define QAM_LC_AMPLITUDE_SIZE__PRE 0x0
6553
6554#define QAM_LC_RAD_ERROR__A 0x1450031
6555#define QAM_LC_RAD_ERROR__W 10
6556#define QAM_LC_RAD_ERROR__M 0x3FF
6557#define QAM_LC_RAD_ERROR__PRE 0x0
6558
6559#define QAM_LC_RAD_ERROR_SIZE__B 0
6560#define QAM_LC_RAD_ERROR_SIZE__W 10
6561#define QAM_LC_RAD_ERROR_SIZE__M 0x3FF
6562#define QAM_LC_RAD_ERROR_SIZE__PRE 0x0
6563
6564#define QAM_LC_FREQ_OFFS__A 0x1450032
6565#define QAM_LC_FREQ_OFFS__W 10
6566#define QAM_LC_FREQ_OFFS__M 0x3FF
6567#define QAM_LC_FREQ_OFFS__PRE 0x0
6568
6569#define QAM_LC_FREQ_OFFS_OFFS__B 0
6570#define QAM_LC_FREQ_OFFS_OFFS__W 10
6571#define QAM_LC_FREQ_OFFS_OFFS__M 0x3FF
6572#define QAM_LC_FREQ_OFFS_OFFS__PRE 0x0
6573
6574#define QAM_LC_PHASE_ERROR__A 0x1450033
6575#define QAM_LC_PHASE_ERROR__W 10
6576#define QAM_LC_PHASE_ERROR__M 0x3FF
6577#define QAM_LC_PHASE_ERROR__PRE 0x0
6578
6579#define QAM_LC_PHASE_ERROR_SIZE__B 0
6580#define QAM_LC_PHASE_ERROR_SIZE__W 10
6581#define QAM_LC_PHASE_ERROR_SIZE__M 0x3FF
6582#define QAM_LC_PHASE_ERROR_SIZE__PRE 0x0
6583
6584#define QAM_VD_COMM_EXEC__A 0x1460000
6585#define QAM_VD_COMM_EXEC__W 2
6586#define QAM_VD_COMM_EXEC__M 0x3
6587#define QAM_VD_COMM_EXEC__PRE 0x0
6588#define QAM_VD_COMM_EXEC_STOP 0x0
6589#define QAM_VD_COMM_EXEC_ACTIVE 0x1
6590#define QAM_VD_COMM_EXEC_HOLD 0x2
6591
6592#define QAM_VD_COMM_MB__A 0x1460002
6593#define QAM_VD_COMM_MB__W 2
6594#define QAM_VD_COMM_MB__M 0x3
6595#define QAM_VD_COMM_MB__PRE 0x0
6596#define QAM_VD_COMM_MB_CTL__B 0
6597#define QAM_VD_COMM_MB_CTL__W 1
6598#define QAM_VD_COMM_MB_CTL__M 0x1
6599#define QAM_VD_COMM_MB_CTL__PRE 0x0
6600#define QAM_VD_COMM_MB_CTL_OFF 0x0
6601#define QAM_VD_COMM_MB_CTL_ON 0x1
6602#define QAM_VD_COMM_MB_OBS__B 1
6603#define QAM_VD_COMM_MB_OBS__W 1
6604#define QAM_VD_COMM_MB_OBS__M 0x2
6605#define QAM_VD_COMM_MB_OBS__PRE 0x0
6606#define QAM_VD_COMM_MB_OBS_OFF 0x0
6607#define QAM_VD_COMM_MB_OBS_ON 0x2
6608
6609#define QAM_VD_COMM_INT_REQ__A 0x1460003
6610#define QAM_VD_COMM_INT_REQ__W 1
6611#define QAM_VD_COMM_INT_REQ__M 0x1
6612#define QAM_VD_COMM_INT_REQ__PRE 0x0
6613#define QAM_VD_COMM_INT_STA__A 0x1460005
6614#define QAM_VD_COMM_INT_STA__W 2
6615#define QAM_VD_COMM_INT_STA__M 0x3
6616#define QAM_VD_COMM_INT_STA__PRE 0x0
6617
6618#define QAM_VD_COMM_INT_STA_LOCK_INT__B 0
6619#define QAM_VD_COMM_INT_STA_LOCK_INT__W 1
6620#define QAM_VD_COMM_INT_STA_LOCK_INT__M 0x1
6621#define QAM_VD_COMM_INT_STA_LOCK_INT__PRE 0x0
6622
6623#define QAM_VD_COMM_INT_STA_PERIOD_INT__B 1
6624#define QAM_VD_COMM_INT_STA_PERIOD_INT__W 1
6625#define QAM_VD_COMM_INT_STA_PERIOD_INT__M 0x2
6626#define QAM_VD_COMM_INT_STA_PERIOD_INT__PRE 0x0
6627
6628#define QAM_VD_COMM_INT_MSK__A 0x1460006
6629#define QAM_VD_COMM_INT_MSK__W 2
6630#define QAM_VD_COMM_INT_MSK__M 0x3
6631#define QAM_VD_COMM_INT_MSK__PRE 0x0
6632#define QAM_VD_COMM_INT_MSK_LOCK_INT__B 0
6633#define QAM_VD_COMM_INT_MSK_LOCK_INT__W 1
6634#define QAM_VD_COMM_INT_MSK_LOCK_INT__M 0x1
6635#define QAM_VD_COMM_INT_MSK_LOCK_INT__PRE 0x0
6636#define QAM_VD_COMM_INT_MSK_PERIOD_INT__B 1
6637#define QAM_VD_COMM_INT_MSK_PERIOD_INT__W 1
6638#define QAM_VD_COMM_INT_MSK_PERIOD_INT__M 0x2
6639#define QAM_VD_COMM_INT_MSK_PERIOD_INT__PRE 0x0
6640
6641#define QAM_VD_COMM_INT_STM__A 0x1460007
6642#define QAM_VD_COMM_INT_STM__W 2
6643#define QAM_VD_COMM_INT_STM__M 0x3
6644#define QAM_VD_COMM_INT_STM__PRE 0x0
6645#define QAM_VD_COMM_INT_STM_LOCK_INT__B 0
6646#define QAM_VD_COMM_INT_STM_LOCK_INT__W 1
6647#define QAM_VD_COMM_INT_STM_LOCK_INT__M 0x1
6648#define QAM_VD_COMM_INT_STM_LOCK_INT__PRE 0x0
6649#define QAM_VD_COMM_INT_STM_PERIOD_INT__B 1
6650#define QAM_VD_COMM_INT_STM_PERIOD_INT__W 1
6651#define QAM_VD_COMM_INT_STM_PERIOD_INT__M 0x2
6652#define QAM_VD_COMM_INT_STM_PERIOD_INT__PRE 0x0
6653
6654#define QAM_VD_STATUS__A 0x1460010
6655#define QAM_VD_STATUS__W 1
6656#define QAM_VD_STATUS__M 0x1
6657#define QAM_VD_STATUS__PRE 0x0
6658
6659#define QAM_VD_STATUS_LOCK__B 0
6660#define QAM_VD_STATUS_LOCK__W 1
6661#define QAM_VD_STATUS_LOCK__M 0x1
6662#define QAM_VD_STATUS_LOCK__PRE 0x0
6663
6664#define QAM_VD_UNLOCK_CONTROL__A 0x1460011
6665#define QAM_VD_UNLOCK_CONTROL__W 1
6666#define QAM_VD_UNLOCK_CONTROL__M 0x1
6667#define QAM_VD_UNLOCK_CONTROL__PRE 0x0
6668
6669#define QAM_VD_UNLOCK_CONTROL_UNLOCK_CTRL__B 0
6670#define QAM_VD_UNLOCK_CONTROL_UNLOCK_CTRL__W 1
6671#define QAM_VD_UNLOCK_CONTROL_UNLOCK_CTRL__M 0x1
6672#define QAM_VD_UNLOCK_CONTROL_UNLOCK_CTRL__PRE 0x0
6673
6674#define QAM_VD_MIN_VOTING_ROUNDS__A 0x1460012
6675#define QAM_VD_MIN_VOTING_ROUNDS__W 6
6676#define QAM_VD_MIN_VOTING_ROUNDS__M 0x3F
6677#define QAM_VD_MIN_VOTING_ROUNDS__PRE 0x10
6678
6679#define QAM_VD_MIN_VOTING_ROUNDS_ROUNDS__B 0
6680#define QAM_VD_MIN_VOTING_ROUNDS_ROUNDS__W 6
6681#define QAM_VD_MIN_VOTING_ROUNDS_ROUNDS__M 0x3F
6682#define QAM_VD_MIN_VOTING_ROUNDS_ROUNDS__PRE 0x10
6683
6684#define QAM_VD_MAX_VOTING_ROUNDS__A 0x1460013
6685#define QAM_VD_MAX_VOTING_ROUNDS__W 6
6686#define QAM_VD_MAX_VOTING_ROUNDS__M 0x3F
6687#define QAM_VD_MAX_VOTING_ROUNDS__PRE 0x10
6688
6689#define QAM_VD_MAX_VOTING_ROUNDS_ROUNDS__B 0
6690#define QAM_VD_MAX_VOTING_ROUNDS_ROUNDS__W 6
6691#define QAM_VD_MAX_VOTING_ROUNDS_ROUNDS__M 0x3F
6692#define QAM_VD_MAX_VOTING_ROUNDS_ROUNDS__PRE 0x10
6693
6694#define QAM_VD_TRACEBACK_DEPTH__A 0x1460014
6695#define QAM_VD_TRACEBACK_DEPTH__W 5
6696#define QAM_VD_TRACEBACK_DEPTH__M 0x1F
6697#define QAM_VD_TRACEBACK_DEPTH__PRE 0x10
6698
6699#define QAM_VD_TRACEBACK_DEPTH_LENGTH__B 0
6700#define QAM_VD_TRACEBACK_DEPTH_LENGTH__W 5
6701#define QAM_VD_TRACEBACK_DEPTH_LENGTH__M 0x1F
6702#define QAM_VD_TRACEBACK_DEPTH_LENGTH__PRE 0x10
6703
6704#define QAM_VD_UNLOCK__A 0x1460015
6705#define QAM_VD_UNLOCK__W 1
6706#define QAM_VD_UNLOCK__M 0x1
6707#define QAM_VD_UNLOCK__PRE 0x0
6708#define QAM_VD_MEASUREMENT_PERIOD__A 0x1460016
6709#define QAM_VD_MEASUREMENT_PERIOD__W 16
6710#define QAM_VD_MEASUREMENT_PERIOD__M 0xFFFF
6711#define QAM_VD_MEASUREMENT_PERIOD__PRE 0x8236
6712
6713#define QAM_VD_MEASUREMENT_PERIOD_PERIOD__B 0
6714#define QAM_VD_MEASUREMENT_PERIOD_PERIOD__W 16
6715#define QAM_VD_MEASUREMENT_PERIOD_PERIOD__M 0xFFFF
6716#define QAM_VD_MEASUREMENT_PERIOD_PERIOD__PRE 0x8236
6717
6718#define QAM_VD_MEASUREMENT_PRESCALE__A 0x1460017
6719#define QAM_VD_MEASUREMENT_PRESCALE__W 16
6720#define QAM_VD_MEASUREMENT_PRESCALE__M 0xFFFF
6721#define QAM_VD_MEASUREMENT_PRESCALE__PRE 0x4
6722
6723#define QAM_VD_MEASUREMENT_PRESCALE_PRESCALE__B 0
6724#define QAM_VD_MEASUREMENT_PRESCALE_PRESCALE__W 16
6725#define QAM_VD_MEASUREMENT_PRESCALE_PRESCALE__M 0xFFFF
6726#define QAM_VD_MEASUREMENT_PRESCALE_PRESCALE__PRE 0x4
6727
6728#define QAM_VD_DELTA_PATH_METRIC__A 0x1460018
6729#define QAM_VD_DELTA_PATH_METRIC__W 16
6730#define QAM_VD_DELTA_PATH_METRIC__M 0xFFFF
6731#define QAM_VD_DELTA_PATH_METRIC__PRE 0xFFFF
6732
6733#define QAM_VD_DELTA_PATH_METRIC_FIXED_MANT__B 0
6734#define QAM_VD_DELTA_PATH_METRIC_FIXED_MANT__W 12
6735#define QAM_VD_DELTA_PATH_METRIC_FIXED_MANT__M 0xFFF
6736#define QAM_VD_DELTA_PATH_METRIC_FIXED_MANT__PRE 0xFFF
6737
6738#define QAM_VD_DELTA_PATH_METRIC_EXP__B 12
6739#define QAM_VD_DELTA_PATH_METRIC_EXP__W 4
6740#define QAM_VD_DELTA_PATH_METRIC_EXP__M 0xF000
6741#define QAM_VD_DELTA_PATH_METRIC_EXP__PRE 0xF000
6742
6743#define QAM_VD_NR_QSYM_ERRORS__A 0x1460019
6744#define QAM_VD_NR_QSYM_ERRORS__W 16
6745#define QAM_VD_NR_QSYM_ERRORS__M 0xFFFF
6746#define QAM_VD_NR_QSYM_ERRORS__PRE 0xFFFF
6747
6748#define QAM_VD_NR_QSYM_ERRORS_FIXED_MANT__B 0
6749#define QAM_VD_NR_QSYM_ERRORS_FIXED_MANT__W 12
6750#define QAM_VD_NR_QSYM_ERRORS_FIXED_MANT__M 0xFFF
6751#define QAM_VD_NR_QSYM_ERRORS_FIXED_MANT__PRE 0xFFF
6752
6753#define QAM_VD_NR_QSYM_ERRORS_EXP__B 12
6754#define QAM_VD_NR_QSYM_ERRORS_EXP__W 4
6755#define QAM_VD_NR_QSYM_ERRORS_EXP__M 0xF000
6756#define QAM_VD_NR_QSYM_ERRORS_EXP__PRE 0xF000
6757
6758#define QAM_VD_NR_SYMBOL_ERRORS__A 0x146001A
6759#define QAM_VD_NR_SYMBOL_ERRORS__W 16
6760#define QAM_VD_NR_SYMBOL_ERRORS__M 0xFFFF
6761#define QAM_VD_NR_SYMBOL_ERRORS__PRE 0xFFFF
6762
6763#define QAM_VD_NR_SYMBOL_ERRORS_FIXED_MANT__B 0
6764#define QAM_VD_NR_SYMBOL_ERRORS_FIXED_MANT__W 12
6765#define QAM_VD_NR_SYMBOL_ERRORS_FIXED_MANT__M 0xFFF
6766#define QAM_VD_NR_SYMBOL_ERRORS_FIXED_MANT__PRE 0xFFF
6767
6768#define QAM_VD_NR_SYMBOL_ERRORS_EXP__B 12
6769#define QAM_VD_NR_SYMBOL_ERRORS_EXP__W 4
6770#define QAM_VD_NR_SYMBOL_ERRORS_EXP__M 0xF000
6771#define QAM_VD_NR_SYMBOL_ERRORS_EXP__PRE 0xF000
6772
6773#define QAM_VD_RELOCK_COUNT__A 0x146001B
6774#define QAM_VD_RELOCK_COUNT__W 16
6775#define QAM_VD_RELOCK_COUNT__M 0xFFFF
6776#define QAM_VD_RELOCK_COUNT__PRE 0x0
6777
6778#define QAM_VD_RELOCK_COUNT_COUNT__B 0
6779#define QAM_VD_RELOCK_COUNT_COUNT__W 8
6780#define QAM_VD_RELOCK_COUNT_COUNT__M 0xFF
6781#define QAM_VD_RELOCK_COUNT_COUNT__PRE 0x0
6782
6783#define QAM_SY_COMM_EXEC__A 0x1470000
6784#define QAM_SY_COMM_EXEC__W 2
6785#define QAM_SY_COMM_EXEC__M 0x3
6786#define QAM_SY_COMM_EXEC__PRE 0x0
6787#define QAM_SY_COMM_EXEC_STOP 0x0
6788#define QAM_SY_COMM_EXEC_ACTIVE 0x1
6789#define QAM_SY_COMM_EXEC_HOLD 0x2
6790
6791#define QAM_SY_COMM_MB__A 0x1470002
6792#define QAM_SY_COMM_MB__W 2
6793#define QAM_SY_COMM_MB__M 0x3
6794#define QAM_SY_COMM_MB__PRE 0x0
6795#define QAM_SY_COMM_MB_CTL__B 0
6796#define QAM_SY_COMM_MB_CTL__W 1
6797#define QAM_SY_COMM_MB_CTL__M 0x1
6798#define QAM_SY_COMM_MB_CTL__PRE 0x0
6799#define QAM_SY_COMM_MB_CTL_OFF 0x0
6800#define QAM_SY_COMM_MB_CTL_ON 0x1
6801#define QAM_SY_COMM_MB_OBS__B 1
6802#define QAM_SY_COMM_MB_OBS__W 1
6803#define QAM_SY_COMM_MB_OBS__M 0x2
6804#define QAM_SY_COMM_MB_OBS__PRE 0x0
6805#define QAM_SY_COMM_MB_OBS_OFF 0x0
6806#define QAM_SY_COMM_MB_OBS_ON 0x2
6807
6808#define QAM_SY_COMM_INT_REQ__A 0x1470003
6809#define QAM_SY_COMM_INT_REQ__W 1
6810#define QAM_SY_COMM_INT_REQ__M 0x1
6811#define QAM_SY_COMM_INT_REQ__PRE 0x0
6812#define QAM_SY_COMM_INT_STA__A 0x1470005
6813#define QAM_SY_COMM_INT_STA__W 4
6814#define QAM_SY_COMM_INT_STA__M 0xF
6815#define QAM_SY_COMM_INT_STA__PRE 0x0
6816
6817#define QAM_SY_COMM_INT_STA_LOCK_INT__B 0
6818#define QAM_SY_COMM_INT_STA_LOCK_INT__W 1
6819#define QAM_SY_COMM_INT_STA_LOCK_INT__M 0x1
6820#define QAM_SY_COMM_INT_STA_LOCK_INT__PRE 0x0
6821
6822#define QAM_SY_COMM_INT_STA_UNLOCK_INT__B 1
6823#define QAM_SY_COMM_INT_STA_UNLOCK_INT__W 1
6824#define QAM_SY_COMM_INT_STA_UNLOCK_INT__M 0x2
6825#define QAM_SY_COMM_INT_STA_UNLOCK_INT__PRE 0x0
6826
6827#define QAM_SY_COMM_INT_STA_TIMEOUT_INT__B 2
6828#define QAM_SY_COMM_INT_STA_TIMEOUT_INT__W 1
6829#define QAM_SY_COMM_INT_STA_TIMEOUT_INT__M 0x4
6830#define QAM_SY_COMM_INT_STA_TIMEOUT_INT__PRE 0x0
6831
6832#define QAM_SY_COMM_INT_STA_CTL_WORD_INT__B 3
6833#define QAM_SY_COMM_INT_STA_CTL_WORD_INT__W 1
6834#define QAM_SY_COMM_INT_STA_CTL_WORD_INT__M 0x8
6835#define QAM_SY_COMM_INT_STA_CTL_WORD_INT__PRE 0x0
6836
6837#define QAM_SY_COMM_INT_MSK__A 0x1470006
6838#define QAM_SY_COMM_INT_MSK__W 4
6839#define QAM_SY_COMM_INT_MSK__M 0xF
6840#define QAM_SY_COMM_INT_MSK__PRE 0x0
6841#define QAM_SY_COMM_INT_MSK_LOCK_MSK__B 0
6842#define QAM_SY_COMM_INT_MSK_LOCK_MSK__W 1
6843#define QAM_SY_COMM_INT_MSK_LOCK_MSK__M 0x1
6844#define QAM_SY_COMM_INT_MSK_LOCK_MSK__PRE 0x0
6845#define QAM_SY_COMM_INT_MSK_UNLOCK_MSK__B 1
6846#define QAM_SY_COMM_INT_MSK_UNLOCK_MSK__W 1
6847#define QAM_SY_COMM_INT_MSK_UNLOCK_MSK__M 0x2
6848#define QAM_SY_COMM_INT_MSK_UNLOCK_MSK__PRE 0x0
6849#define QAM_SY_COMM_INT_MSK_TIMEOUT_MSK__B 2
6850#define QAM_SY_COMM_INT_MSK_TIMEOUT_MSK__W 1
6851#define QAM_SY_COMM_INT_MSK_TIMEOUT_MSK__M 0x4
6852#define QAM_SY_COMM_INT_MSK_TIMEOUT_MSK__PRE 0x0
6853#define QAM_SY_COMM_INT_MSK_CTL_WORD_MSK__B 3
6854#define QAM_SY_COMM_INT_MSK_CTL_WORD_MSK__W 1
6855#define QAM_SY_COMM_INT_MSK_CTL_WORD_MSK__M 0x8
6856#define QAM_SY_COMM_INT_MSK_CTL_WORD_MSK__PRE 0x0
6857
6858#define QAM_SY_COMM_INT_STM__A 0x1470007
6859#define QAM_SY_COMM_INT_STM__W 4
6860#define QAM_SY_COMM_INT_STM__M 0xF
6861#define QAM_SY_COMM_INT_STM__PRE 0x0
6862#define QAM_SY_COMM_INT_STM_LOCK_MSK__B 0
6863#define QAM_SY_COMM_INT_STM_LOCK_MSK__W 1
6864#define QAM_SY_COMM_INT_STM_LOCK_MSK__M 0x1
6865#define QAM_SY_COMM_INT_STM_LOCK_MSK__PRE 0x0
6866#define QAM_SY_COMM_INT_STM_UNLOCK_MSK__B 1
6867#define QAM_SY_COMM_INT_STM_UNLOCK_MSK__W 1
6868#define QAM_SY_COMM_INT_STM_UNLOCK_MSK__M 0x2
6869#define QAM_SY_COMM_INT_STM_UNLOCK_MSK__PRE 0x0
6870#define QAM_SY_COMM_INT_STM_TIMEOUT_MSK__B 2
6871#define QAM_SY_COMM_INT_STM_TIMEOUT_MSK__W 1
6872#define QAM_SY_COMM_INT_STM_TIMEOUT_MSK__M 0x4
6873#define QAM_SY_COMM_INT_STM_TIMEOUT_MSK__PRE 0x0
6874#define QAM_SY_COMM_INT_STM_CTL_WORD_MSK__B 3
6875#define QAM_SY_COMM_INT_STM_CTL_WORD_MSK__W 1
6876#define QAM_SY_COMM_INT_STM_CTL_WORD_MSK__M 0x8
6877#define QAM_SY_COMM_INT_STM_CTL_WORD_MSK__PRE 0x0
6878
6879#define QAM_SY_STATUS__A 0x1470010
6880#define QAM_SY_STATUS__W 2
6881#define QAM_SY_STATUS__M 0x3
6882#define QAM_SY_STATUS__PRE 0x0
6883
6884#define QAM_SY_STATUS_SYNC_STATE__B 0
6885#define QAM_SY_STATUS_SYNC_STATE__W 2
6886#define QAM_SY_STATUS_SYNC_STATE__M 0x3
6887#define QAM_SY_STATUS_SYNC_STATE__PRE 0x0
6888
6889#define QAM_SY_TIMEOUT__A 0x1470011
6890#define QAM_SY_TIMEOUT__W 16
6891#define QAM_SY_TIMEOUT__M 0xFFFF
6892#define QAM_SY_TIMEOUT__PRE 0x3A98
6893
6894#define QAM_SY_SYNC_LWM__A 0x1470012
6895#define QAM_SY_SYNC_LWM__W 4
6896#define QAM_SY_SYNC_LWM__M 0xF
6897#define QAM_SY_SYNC_LWM__PRE 0x2
6898
6899#define QAM_SY_SYNC_AWM__A 0x1470013
6900#define QAM_SY_SYNC_AWM__W 4
6901#define QAM_SY_SYNC_AWM__M 0xF
6902#define QAM_SY_SYNC_AWM__PRE 0x3
6903
6904#define QAM_SY_SYNC_HWM__A 0x1470014
6905#define QAM_SY_SYNC_HWM__W 4
6906#define QAM_SY_SYNC_HWM__M 0xF
6907#define QAM_SY_SYNC_HWM__PRE 0x5
6908
6909#define QAM_SY_UNLOCK__A 0x1470015
6910#define QAM_SY_UNLOCK__W 1
6911#define QAM_SY_UNLOCK__M 0x1
6912#define QAM_SY_UNLOCK__PRE 0x0
6913#define QAM_SY_CONTROL_WORD__A 0x1470016
6914#define QAM_SY_CONTROL_WORD__W 4
6915#define QAM_SY_CONTROL_WORD__M 0xF
6916#define QAM_SY_CONTROL_WORD__PRE 0x0
6917
6918#define QAM_SY_CONTROL_WORD_CTRL_WORD__B 0
6919#define QAM_SY_CONTROL_WORD_CTRL_WORD__W 4
6920#define QAM_SY_CONTROL_WORD_CTRL_WORD__M 0xF
6921#define QAM_SY_CONTROL_WORD_CTRL_WORD__PRE 0x0
6922
6923#define QAM_VD_ISS_RAM__A 0x1480000
6924
6925#define QAM_VD_QSS_RAM__A 0x1490000
6926
6927#define QAM_VD_SYM_RAM__A 0x14A0000
6928
6929#define SCU_COMM_EXEC__A 0x800000
6930#define SCU_COMM_EXEC__W 2
6931#define SCU_COMM_EXEC__M 0x3
6932#define SCU_COMM_EXEC__PRE 0x0
6933#define SCU_COMM_EXEC_STOP 0x0
6934#define SCU_COMM_EXEC_ACTIVE 0x1
6935#define SCU_COMM_EXEC_HOLD 0x2
6936
6937#define SCU_COMM_STATE__A 0x800001
6938#define SCU_COMM_STATE__W 16
6939#define SCU_COMM_STATE__M 0xFFFF
6940#define SCU_COMM_STATE__PRE 0x0
6941
6942#define SCU_COMM_STATE_COMM_STATE__B 0
6943#define SCU_COMM_STATE_COMM_STATE__W 16
6944#define SCU_COMM_STATE_COMM_STATE__M 0xFFFF
6945#define SCU_COMM_STATE_COMM_STATE__PRE 0x0
6946
6947#define SCU_TOP_COMM_EXEC__A 0x810000
6948#define SCU_TOP_COMM_EXEC__W 2
6949#define SCU_TOP_COMM_EXEC__M 0x3
6950#define SCU_TOP_COMM_EXEC__PRE 0x0
6951#define SCU_TOP_COMM_EXEC_STOP 0x0
6952#define SCU_TOP_COMM_EXEC_ACTIVE 0x1
6953#define SCU_TOP_COMM_EXEC_HOLD 0x2
6954
6955#define SCU_TOP_COMM_STATE__A 0x810001
6956#define SCU_TOP_COMM_STATE__W 16
6957#define SCU_TOP_COMM_STATE__M 0xFFFF
6958#define SCU_TOP_COMM_STATE__PRE 0x0
6959#define SCU_TOP_MWAIT_CTR__A 0x810010
6960#define SCU_TOP_MWAIT_CTR__W 2
6961#define SCU_TOP_MWAIT_CTR__M 0x3
6962#define SCU_TOP_MWAIT_CTR__PRE 0x0
6963
6964#define SCU_TOP_MWAIT_CTR_MWAIT_SEL__B 0
6965#define SCU_TOP_MWAIT_CTR_MWAIT_SEL__W 1
6966#define SCU_TOP_MWAIT_CTR_MWAIT_SEL__M 0x1
6967#define SCU_TOP_MWAIT_CTR_MWAIT_SEL__PRE 0x0
6968#define SCU_TOP_MWAIT_CTR_MWAIT_SEL_TR_MW_OFF 0x0
6969#define SCU_TOP_MWAIT_CTR_MWAIT_SEL_TR_MW_ON 0x1
6970
6971#define SCU_TOP_MWAIT_CTR_READY_DIS__B 1
6972#define SCU_TOP_MWAIT_CTR_READY_DIS__W 1
6973#define SCU_TOP_MWAIT_CTR_READY_DIS__M 0x2
6974#define SCU_TOP_MWAIT_CTR_READY_DIS__PRE 0x0
6975#define SCU_TOP_MWAIT_CTR_READY_DIS_NMI_ON 0x0
6976#define SCU_TOP_MWAIT_CTR_READY_DIS_NMI_OFF 0x2
6977
6978#define SCU_LOW_RAM__A 0x820000
6979
6980#define SCU_LOW_RAM_LOW__B 0
6981#define SCU_LOW_RAM_LOW__W 16
6982#define SCU_LOW_RAM_LOW__M 0xFFFF
6983#define SCU_LOW_RAM_LOW__PRE 0x0
6984
6985#define SCU_HIGH_RAM__A 0x830000
6986
6987#define SCU_HIGH_RAM_HIGH__B 0
6988#define SCU_HIGH_RAM_HIGH__W 16
6989#define SCU_HIGH_RAM_HIGH__M 0xFFFF
6990#define SCU_HIGH_RAM_HIGH__PRE 0x0
6991
6992#define SCU_RAM_AGC_RF_MAX__A 0x831E96
6993#define SCU_RAM_AGC_RF_MAX__W 15
6994#define SCU_RAM_AGC_RF_MAX__M 0x7FFF
6995#define SCU_RAM_AGC_RF_MAX__PRE 0x0
6996
6997#define SCU_RAM_AGC_FAST_SNS_CTRL_DELAY__A 0x831E97
6998#define SCU_RAM_AGC_FAST_SNS_CTRL_DELAY__W 16
6999#define SCU_RAM_AGC_FAST_SNS_CTRL_DELAY__M 0xFFFF
7000#define SCU_RAM_AGC_FAST_SNS_CTRL_DELAY__PRE 0x0
7001
7002#define SCU_RAM_AGC_KI_CYCCNT__A 0x831E98
7003#define SCU_RAM_AGC_KI_CYCCNT__W 16
7004#define SCU_RAM_AGC_KI_CYCCNT__M 0xFFFF
7005#define SCU_RAM_AGC_KI_CYCCNT__PRE 0x0
7006
7007#define SCU_RAM_AGC_KI_CYCLEN__A 0x831E99
7008#define SCU_RAM_AGC_KI_CYCLEN__W 16
7009#define SCU_RAM_AGC_KI_CYCLEN__M 0xFFFF
7010#define SCU_RAM_AGC_KI_CYCLEN__PRE 0x0
7011
7012#define SCU_RAM_AGC_SNS_CYCLEN__A 0x831E9A
7013#define SCU_RAM_AGC_SNS_CYCLEN__W 16
7014#define SCU_RAM_AGC_SNS_CYCLEN__M 0xFFFF
7015#define SCU_RAM_AGC_SNS_CYCLEN__PRE 0x0
7016
7017#define SCU_RAM_AGC_RF_SNS_DEV_MAX__A 0x831E9B
7018#define SCU_RAM_AGC_RF_SNS_DEV_MAX__W 16
7019#define SCU_RAM_AGC_RF_SNS_DEV_MAX__M 0xFFFF
7020#define SCU_RAM_AGC_RF_SNS_DEV_MAX__PRE 0x0
7021
7022#define SCU_RAM_AGC_RF_SNS_DEV_MIN__A 0x831E9C
7023#define SCU_RAM_AGC_RF_SNS_DEV_MIN__W 16
7024#define SCU_RAM_AGC_RF_SNS_DEV_MIN__M 0xFFFF
7025#define SCU_RAM_AGC_RF_SNS_DEV_MIN__PRE 0x0
7026#define SCU_RAM_AGC_KI__A 0x831E9D
7027#define SCU_RAM_AGC_KI__W 15
7028#define SCU_RAM_AGC_KI__M 0x7FFF
7029#define SCU_RAM_AGC_KI__PRE 0x0
7030
7031#define SCU_RAM_AGC_KI_DGAIN__B 0
7032#define SCU_RAM_AGC_KI_DGAIN__W 4
7033#define SCU_RAM_AGC_KI_DGAIN__M 0xF
7034#define SCU_RAM_AGC_KI_DGAIN__PRE 0x0
7035
7036#define SCU_RAM_AGC_KI_RF__B 4
7037#define SCU_RAM_AGC_KI_RF__W 4
7038#define SCU_RAM_AGC_KI_RF__M 0xF0
7039#define SCU_RAM_AGC_KI_RF__PRE 0x0
7040
7041#define SCU_RAM_AGC_KI_IF__B 8
7042#define SCU_RAM_AGC_KI_IF__W 4
7043#define SCU_RAM_AGC_KI_IF__M 0xF00
7044#define SCU_RAM_AGC_KI_IF__PRE 0x0
7045
7046#define SCU_RAM_AGC_KI_IF_AGC_DISABLE__B 12
7047#define SCU_RAM_AGC_KI_IF_AGC_DISABLE__W 1
7048#define SCU_RAM_AGC_KI_IF_AGC_DISABLE__M 0x1000
7049#define SCU_RAM_AGC_KI_IF_AGC_DISABLE__PRE 0x0
7050
7051#define SCU_RAM_AGC_KI_INV_IF_POL__B 13
7052#define SCU_RAM_AGC_KI_INV_IF_POL__W 1
7053#define SCU_RAM_AGC_KI_INV_IF_POL__M 0x2000
7054#define SCU_RAM_AGC_KI_INV_IF_POL__PRE 0x0
7055
7056#define SCU_RAM_AGC_KI_INV_RF_POL__B 14
7057#define SCU_RAM_AGC_KI_INV_RF_POL__W 1
7058#define SCU_RAM_AGC_KI_INV_RF_POL__M 0x4000
7059#define SCU_RAM_AGC_KI_INV_RF_POL__PRE 0x0
7060
7061#define SCU_RAM_AGC_KI_RED__A 0x831E9E
7062#define SCU_RAM_AGC_KI_RED__W 6
7063#define SCU_RAM_AGC_KI_RED__M 0x3F
7064#define SCU_RAM_AGC_KI_RED__PRE 0x0
7065
7066#define SCU_RAM_AGC_KI_RED_INNER_RED__B 0
7067#define SCU_RAM_AGC_KI_RED_INNER_RED__W 2
7068#define SCU_RAM_AGC_KI_RED_INNER_RED__M 0x3
7069#define SCU_RAM_AGC_KI_RED_INNER_RED__PRE 0x0
7070
7071#define SCU_RAM_AGC_KI_RED_RAGC_RED__B 2
7072#define SCU_RAM_AGC_KI_RED_RAGC_RED__W 2
7073#define SCU_RAM_AGC_KI_RED_RAGC_RED__M 0xC
7074#define SCU_RAM_AGC_KI_RED_RAGC_RED__PRE 0x0
7075
7076#define SCU_RAM_AGC_KI_RED_IAGC_RED__B 4
7077#define SCU_RAM_AGC_KI_RED_IAGC_RED__W 2
7078#define SCU_RAM_AGC_KI_RED_IAGC_RED__M 0x30
7079#define SCU_RAM_AGC_KI_RED_IAGC_RED__PRE 0x0
7080
7081#define SCU_RAM_AGC_KI_INNERGAIN_MIN__A 0x831E9F
7082#define SCU_RAM_AGC_KI_INNERGAIN_MIN__W 16
7083#define SCU_RAM_AGC_KI_INNERGAIN_MIN__M 0xFFFF
7084#define SCU_RAM_AGC_KI_INNERGAIN_MIN__PRE 0x0
7085
7086#define SCU_RAM_AGC_KI_MINGAIN__A 0x831EA0
7087#define SCU_RAM_AGC_KI_MINGAIN__W 16
7088#define SCU_RAM_AGC_KI_MINGAIN__M 0xFFFF
7089#define SCU_RAM_AGC_KI_MINGAIN__PRE 0x0
7090
7091#define SCU_RAM_AGC_KI_MAXGAIN__A 0x831EA1
7092#define SCU_RAM_AGC_KI_MAXGAIN__W 16
7093#define SCU_RAM_AGC_KI_MAXGAIN__M 0xFFFF
7094#define SCU_RAM_AGC_KI_MAXGAIN__PRE 0x0
7095
7096#define SCU_RAM_AGC_KI_MAXMINGAIN_TH__A 0x831EA2
7097#define SCU_RAM_AGC_KI_MAXMINGAIN_TH__W 16
7098#define SCU_RAM_AGC_KI_MAXMINGAIN_TH__M 0xFFFF
7099#define SCU_RAM_AGC_KI_MAXMINGAIN_TH__PRE 0x0
7100#define SCU_RAM_AGC_KI_MIN__A 0x831EA3
7101#define SCU_RAM_AGC_KI_MIN__W 12
7102#define SCU_RAM_AGC_KI_MIN__M 0xFFF
7103#define SCU_RAM_AGC_KI_MIN__PRE 0x0
7104
7105#define SCU_RAM_AGC_KI_MIN_DGAIN__B 0
7106#define SCU_RAM_AGC_KI_MIN_DGAIN__W 4
7107#define SCU_RAM_AGC_KI_MIN_DGAIN__M 0xF
7108#define SCU_RAM_AGC_KI_MIN_DGAIN__PRE 0x0
7109
7110#define SCU_RAM_AGC_KI_MIN_RF__B 4
7111#define SCU_RAM_AGC_KI_MIN_RF__W 4
7112#define SCU_RAM_AGC_KI_MIN_RF__M 0xF0
7113#define SCU_RAM_AGC_KI_MIN_RF__PRE 0x0
7114
7115#define SCU_RAM_AGC_KI_MIN_IF__B 8
7116#define SCU_RAM_AGC_KI_MIN_IF__W 4
7117#define SCU_RAM_AGC_KI_MIN_IF__M 0xF00
7118#define SCU_RAM_AGC_KI_MIN_IF__PRE 0x0
7119
7120#define SCU_RAM_AGC_KI_MAX__A 0x831EA4
7121#define SCU_RAM_AGC_KI_MAX__W 12
7122#define SCU_RAM_AGC_KI_MAX__M 0xFFF
7123#define SCU_RAM_AGC_KI_MAX__PRE 0x0
7124
7125#define SCU_RAM_AGC_KI_MAX_DGAIN__B 0
7126#define SCU_RAM_AGC_KI_MAX_DGAIN__W 4
7127#define SCU_RAM_AGC_KI_MAX_DGAIN__M 0xF
7128#define SCU_RAM_AGC_KI_MAX_DGAIN__PRE 0x0
7129
7130#define SCU_RAM_AGC_KI_MAX_RF__B 4
7131#define SCU_RAM_AGC_KI_MAX_RF__W 4
7132#define SCU_RAM_AGC_KI_MAX_RF__M 0xF0
7133#define SCU_RAM_AGC_KI_MAX_RF__PRE 0x0
7134
7135#define SCU_RAM_AGC_KI_MAX_IF__B 8
7136#define SCU_RAM_AGC_KI_MAX_IF__W 4
7137#define SCU_RAM_AGC_KI_MAX_IF__M 0xF00
7138#define SCU_RAM_AGC_KI_MAX_IF__PRE 0x0
7139
7140#define SCU_RAM_AGC_CLP_SUM__A 0x831EA5
7141#define SCU_RAM_AGC_CLP_SUM__W 16
7142#define SCU_RAM_AGC_CLP_SUM__M 0xFFFF
7143#define SCU_RAM_AGC_CLP_SUM__PRE 0x0
7144
7145#define SCU_RAM_AGC_CLP_SUM_MIN__A 0x831EA6
7146#define SCU_RAM_AGC_CLP_SUM_MIN__W 16
7147#define SCU_RAM_AGC_CLP_SUM_MIN__M 0xFFFF
7148#define SCU_RAM_AGC_CLP_SUM_MIN__PRE 0x0
7149
7150#define SCU_RAM_AGC_CLP_SUM_MAX__A 0x831EA7
7151#define SCU_RAM_AGC_CLP_SUM_MAX__W 16
7152#define SCU_RAM_AGC_CLP_SUM_MAX__M 0xFFFF
7153#define SCU_RAM_AGC_CLP_SUM_MAX__PRE 0x0
7154
7155#define SCU_RAM_AGC_CLP_CYCLEN__A 0x831EA8
7156#define SCU_RAM_AGC_CLP_CYCLEN__W 16
7157#define SCU_RAM_AGC_CLP_CYCLEN__M 0xFFFF
7158#define SCU_RAM_AGC_CLP_CYCLEN__PRE 0x0
7159
7160#define SCU_RAM_AGC_CLP_CYCCNT__A 0x831EA9
7161#define SCU_RAM_AGC_CLP_CYCCNT__W 16
7162#define SCU_RAM_AGC_CLP_CYCCNT__M 0xFFFF
7163#define SCU_RAM_AGC_CLP_CYCCNT__PRE 0x0
7164
7165#define SCU_RAM_AGC_CLP_DIR_TO__A 0x831EAA
7166#define SCU_RAM_AGC_CLP_DIR_TO__W 8
7167#define SCU_RAM_AGC_CLP_DIR_TO__M 0xFF
7168#define SCU_RAM_AGC_CLP_DIR_TO__PRE 0x0
7169
7170#define SCU_RAM_AGC_CLP_DIR_WD__A 0x831EAB
7171#define SCU_RAM_AGC_CLP_DIR_WD__W 8
7172#define SCU_RAM_AGC_CLP_DIR_WD__M 0xFF
7173#define SCU_RAM_AGC_CLP_DIR_WD__PRE 0x0
7174
7175#define SCU_RAM_AGC_CLP_DIR_STP__A 0x831EAC
7176#define SCU_RAM_AGC_CLP_DIR_STP__W 16
7177#define SCU_RAM_AGC_CLP_DIR_STP__M 0xFFFF
7178#define SCU_RAM_AGC_CLP_DIR_STP__PRE 0x0
7179
7180#define SCU_RAM_AGC_SNS_SUM__A 0x831EAD
7181#define SCU_RAM_AGC_SNS_SUM__W 16
7182#define SCU_RAM_AGC_SNS_SUM__M 0xFFFF
7183#define SCU_RAM_AGC_SNS_SUM__PRE 0x0
7184
7185#define SCU_RAM_AGC_SNS_SUM_MIN__A 0x831EAE
7186#define SCU_RAM_AGC_SNS_SUM_MIN__W 16
7187#define SCU_RAM_AGC_SNS_SUM_MIN__M 0xFFFF
7188#define SCU_RAM_AGC_SNS_SUM_MIN__PRE 0x0
7189
7190#define SCU_RAM_AGC_SNS_SUM_MAX__A 0x831EAF
7191#define SCU_RAM_AGC_SNS_SUM_MAX__W 16
7192#define SCU_RAM_AGC_SNS_SUM_MAX__M 0xFFFF
7193#define SCU_RAM_AGC_SNS_SUM_MAX__PRE 0x0
7194
7195#define SCU_RAM_AGC_SNS_CYCCNT__A 0x831EB0
7196#define SCU_RAM_AGC_SNS_CYCCNT__W 16
7197#define SCU_RAM_AGC_SNS_CYCCNT__M 0xFFFF
7198#define SCU_RAM_AGC_SNS_CYCCNT__PRE 0x0
7199
7200#define SCU_RAM_AGC_SNS_DIR_TO__A 0x831EB1
7201#define SCU_RAM_AGC_SNS_DIR_TO__W 8
7202#define SCU_RAM_AGC_SNS_DIR_TO__M 0xFF
7203#define SCU_RAM_AGC_SNS_DIR_TO__PRE 0x0
7204
7205#define SCU_RAM_AGC_SNS_DIR_WD__A 0x831EB2
7206#define SCU_RAM_AGC_SNS_DIR_WD__W 8
7207#define SCU_RAM_AGC_SNS_DIR_WD__M 0xFF
7208#define SCU_RAM_AGC_SNS_DIR_WD__PRE 0x0
7209
7210#define SCU_RAM_AGC_SNS_DIR_STP__A 0x831EB3
7211#define SCU_RAM_AGC_SNS_DIR_STP__W 16
7212#define SCU_RAM_AGC_SNS_DIR_STP__M 0xFFFF
7213#define SCU_RAM_AGC_SNS_DIR_STP__PRE 0x0
7214
7215#define SCU_RAM_AGC_INGAIN__A 0x831EB4
7216#define SCU_RAM_AGC_INGAIN__W 16
7217#define SCU_RAM_AGC_INGAIN__M 0xFFFF
7218#define SCU_RAM_AGC_INGAIN__PRE 0x0
7219
7220#define SCU_RAM_AGC_INGAIN_TGT__A 0x831EB5
7221#define SCU_RAM_AGC_INGAIN_TGT__W 15
7222#define SCU_RAM_AGC_INGAIN_TGT__M 0x7FFF
7223#define SCU_RAM_AGC_INGAIN_TGT__PRE 0x0
7224
7225#define SCU_RAM_AGC_INGAIN_TGT_MIN__A 0x831EB6
7226#define SCU_RAM_AGC_INGAIN_TGT_MIN__W 15
7227#define SCU_RAM_AGC_INGAIN_TGT_MIN__M 0x7FFF
7228#define SCU_RAM_AGC_INGAIN_TGT_MIN__PRE 0x0
7229
7230#define SCU_RAM_AGC_INGAIN_TGT_MAX__A 0x831EB7
7231#define SCU_RAM_AGC_INGAIN_TGT_MAX__W 15
7232#define SCU_RAM_AGC_INGAIN_TGT_MAX__M 0x7FFF
7233#define SCU_RAM_AGC_INGAIN_TGT_MAX__PRE 0x0
7234
7235#define SCU_RAM_AGC_IF_IACCU_HI__A 0x831EB8
7236#define SCU_RAM_AGC_IF_IACCU_HI__W 16
7237#define SCU_RAM_AGC_IF_IACCU_HI__M 0xFFFF
7238#define SCU_RAM_AGC_IF_IACCU_HI__PRE 0x0
7239
7240#define SCU_RAM_AGC_IF_IACCU_LO__A 0x831EB9
7241#define SCU_RAM_AGC_IF_IACCU_LO__W 8
7242#define SCU_RAM_AGC_IF_IACCU_LO__M 0xFF
7243#define SCU_RAM_AGC_IF_IACCU_LO__PRE 0x0
7244
7245#define SCU_RAM_AGC_IF_IACCU_HI_TGT__A 0x831EBA
7246#define SCU_RAM_AGC_IF_IACCU_HI_TGT__W 15
7247#define SCU_RAM_AGC_IF_IACCU_HI_TGT__M 0x7FFF
7248#define SCU_RAM_AGC_IF_IACCU_HI_TGT__PRE 0x0
7249
7250#define SCU_RAM_AGC_IF_IACCU_HI_TGT_MIN__A 0x831EBB
7251#define SCU_RAM_AGC_IF_IACCU_HI_TGT_MIN__W 15
7252#define SCU_RAM_AGC_IF_IACCU_HI_TGT_MIN__M 0x7FFF
7253#define SCU_RAM_AGC_IF_IACCU_HI_TGT_MIN__PRE 0x0
7254
7255#define SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A 0x831EBC
7256#define SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__W 15
7257#define SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__M 0x7FFF
7258#define SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__PRE 0x0
7259
7260#define SCU_RAM_AGC_RF_IACCU_HI__A 0x831EBD
7261#define SCU_RAM_AGC_RF_IACCU_HI__W 16
7262#define SCU_RAM_AGC_RF_IACCU_HI__M 0xFFFF
7263#define SCU_RAM_AGC_RF_IACCU_HI__PRE 0x0
7264
7265#define SCU_RAM_AGC_RF_IACCU_LO__A 0x831EBE
7266#define SCU_RAM_AGC_RF_IACCU_LO__W 8
7267#define SCU_RAM_AGC_RF_IACCU_LO__M 0xFF
7268#define SCU_RAM_AGC_RF_IACCU_LO__PRE 0x0
7269
7270#define SCU_RAM_AGC_RF_IACCU_HI_CO__A 0x831EBF
7271#define SCU_RAM_AGC_RF_IACCU_HI_CO__W 16
7272#define SCU_RAM_AGC_RF_IACCU_HI_CO__M 0xFFFF
7273#define SCU_RAM_AGC_RF_IACCU_HI_CO__PRE 0x0
7274
7275#define SCU_RAM_SP__A 0x831EC0
7276#define SCU_RAM_SP__W 16
7277#define SCU_RAM_SP__M 0xFFFF
7278#define SCU_RAM_SP__PRE 0x0
7279
7280#define SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A 0x831EC1
7281#define SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__W 16
7282#define SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__M 0xFFFF
7283#define SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__PRE 0x0
7284
7285#define SCU_RAM_AGC_KI_MIN_IFGAIN__A 0x831EC2
7286#define SCU_RAM_AGC_KI_MIN_IFGAIN__W 16
7287#define SCU_RAM_AGC_KI_MIN_IFGAIN__M 0xFFFF
7288#define SCU_RAM_AGC_KI_MIN_IFGAIN__PRE 0x0
7289
7290#define SCU_RAM_AGC_KI_MAX_IFGAIN__A 0x831EC3
7291#define SCU_RAM_AGC_KI_MAX_IFGAIN__W 16
7292#define SCU_RAM_AGC_KI_MAX_IFGAIN__M 0xFFFF
7293#define SCU_RAM_AGC_KI_MAX_IFGAIN__PRE 0x0
7294
7295#define SCU_RAM_FEC_MEAS_COUNT__A 0x831EC4
7296#define SCU_RAM_FEC_MEAS_COUNT__W 16
7297#define SCU_RAM_FEC_MEAS_COUNT__M 0xFFFF
7298#define SCU_RAM_FEC_MEAS_COUNT__PRE 0x0
7299
7300#define SCU_RAM_FEC_ACCUM_CW_CORRECTED_LO__A 0x831EC5
7301#define SCU_RAM_FEC_ACCUM_CW_CORRECTED_LO__W 16
7302#define SCU_RAM_FEC_ACCUM_CW_CORRECTED_LO__M 0xFFFF
7303#define SCU_RAM_FEC_ACCUM_CW_CORRECTED_LO__PRE 0x0
7304
7305#define SCU_RAM_FEC_ACCUM_CW_CORRECTED_HI__A 0x831EC6
7306#define SCU_RAM_FEC_ACCUM_CW_CORRECTED_HI__W 16
7307#define SCU_RAM_FEC_ACCUM_CW_CORRECTED_HI__M 0xFFFF
7308#define SCU_RAM_FEC_ACCUM_CW_CORRECTED_HI__PRE 0x0
7309#define SCU_RAM_GPIO__A 0x831EC7
7310#define SCU_RAM_GPIO__W 1
7311#define SCU_RAM_GPIO__M 0x1
7312#define SCU_RAM_GPIO__PRE 0x0
7313
7314#define SCU_RAM_GPIO_HW_LOCK_IND__B 0
7315#define SCU_RAM_GPIO_HW_LOCK_IND__W 1
7316#define SCU_RAM_GPIO_HW_LOCK_IND__M 0x1
7317#define SCU_RAM_GPIO_HW_LOCK_IND__PRE 0x0
7318#define SCU_RAM_GPIO_HW_LOCK_IND_DISABLE 0x0
7319#define SCU_RAM_GPIO_HW_LOCK_IND_ENABLE 0x1
7320
7321#define SCU_RAM_AGC_CLP_CTRL_MODE__A 0x831EC8
7322#define SCU_RAM_AGC_CLP_CTRL_MODE__W 8
7323#define SCU_RAM_AGC_CLP_CTRL_MODE__M 0xFF
7324#define SCU_RAM_AGC_CLP_CTRL_MODE__PRE 0x0
7325
7326#define SCU_RAM_AGC_CLP_CTRL_MODE_NARROW_POW__B 0
7327#define SCU_RAM_AGC_CLP_CTRL_MODE_NARROW_POW__W 1
7328#define SCU_RAM_AGC_CLP_CTRL_MODE_NARROW_POW__M 0x1
7329#define SCU_RAM_AGC_CLP_CTRL_MODE_NARROW_POW__PRE 0x0
7330#define SCU_RAM_AGC_CLP_CTRL_MODE_NARROW_POW_false 0x0
7331#define SCU_RAM_AGC_CLP_CTRL_MODE_NARROW_POW_true 0x1
7332
7333#define SCU_RAM_AGC_CLP_CTRL_MODE_FAST_CLP_BP__B 1
7334#define SCU_RAM_AGC_CLP_CTRL_MODE_FAST_CLP_BP__W 1
7335#define SCU_RAM_AGC_CLP_CTRL_MODE_FAST_CLP_BP__M 0x2
7336#define SCU_RAM_AGC_CLP_CTRL_MODE_FAST_CLP_BP__PRE 0x0
7337#define SCU_RAM_AGC_CLP_CTRL_MODE_FAST_CLP_BP_FCC_ENABLE 0x0
7338#define SCU_RAM_AGC_CLP_CTRL_MODE_FAST_CLP_BP_FCC_DISABLE 0x2
7339
7340#define SCU_RAM_AGC_CLP_CTRL_MODE_FAST_CLP_DEC__B 2
7341#define SCU_RAM_AGC_CLP_CTRL_MODE_FAST_CLP_DEC__W 1
7342#define SCU_RAM_AGC_CLP_CTRL_MODE_FAST_CLP_DEC__M 0x4
7343#define SCU_RAM_AGC_CLP_CTRL_MODE_FAST_CLP_DEC__PRE 0x0
7344#define SCU_RAM_AGC_CLP_CTRL_MODE_FAST_CLP_DEC_DEC_DISABLE 0x0
7345#define SCU_RAM_AGC_CLP_CTRL_MODE_FAST_CLP_DEC_DEC_ENABLE 0x4
7346
7347#define SCU_RAM_AGC_KI_MIN_RFGAIN__A 0x831EC9
7348#define SCU_RAM_AGC_KI_MIN_RFGAIN__W 16
7349#define SCU_RAM_AGC_KI_MIN_RFGAIN__M 0xFFFF
7350#define SCU_RAM_AGC_KI_MIN_RFGAIN__PRE 0x0
7351
7352#define SCU_RAM_AGC_KI_MAX_RFGAIN__A 0x831ECA
7353#define SCU_RAM_AGC_KI_MAX_RFGAIN__W 16
7354#define SCU_RAM_AGC_KI_MAX_RFGAIN__M 0xFFFF
7355#define SCU_RAM_AGC_KI_MAX_RFGAIN__PRE 0x0
7356
7357#define SCU_RAM_FEC_ACCUM_PKT_FAILURES__A 0x831ECB
7358#define SCU_RAM_FEC_ACCUM_PKT_FAILURES__W 16
7359#define SCU_RAM_FEC_ACCUM_PKT_FAILURES__M 0xFFFF
7360#define SCU_RAM_FEC_ACCUM_PKT_FAILURES__PRE 0x0
7361
7362#define SCU_RAM_INHIBIT_1__A 0x831ECC
7363#define SCU_RAM_INHIBIT_1__W 16
7364#define SCU_RAM_INHIBIT_1__M 0xFFFF
7365#define SCU_RAM_INHIBIT_1__PRE 0x0
7366
7367#define SCU_RAM_HTOL_BUF_0__A 0x831ECD
7368#define SCU_RAM_HTOL_BUF_0__W 16
7369#define SCU_RAM_HTOL_BUF_0__M 0xFFFF
7370#define SCU_RAM_HTOL_BUF_0__PRE 0x0
7371
7372#define SCU_RAM_HTOL_BUF_1__A 0x831ECE
7373#define SCU_RAM_HTOL_BUF_1__W 16
7374#define SCU_RAM_HTOL_BUF_1__M 0xFFFF
7375#define SCU_RAM_HTOL_BUF_1__PRE 0x0
7376
7377#define SCU_RAM_INHIBIT_2__A 0x831ECF
7378#define SCU_RAM_INHIBIT_2__W 16
7379#define SCU_RAM_INHIBIT_2__M 0xFFFF
7380#define SCU_RAM_INHIBIT_2__PRE 0x0
7381
7382#define SCU_RAM_TR_SHORT_BUF_0__A 0x831ED0
7383#define SCU_RAM_TR_SHORT_BUF_0__W 16
7384#define SCU_RAM_TR_SHORT_BUF_0__M 0xFFFF
7385#define SCU_RAM_TR_SHORT_BUF_0__PRE 0x0
7386
7387#define SCU_RAM_TR_SHORT_BUF_1__A 0x831ED1
7388#define SCU_RAM_TR_SHORT_BUF_1__W 16
7389#define SCU_RAM_TR_SHORT_BUF_1__M 0xFFFF
7390#define SCU_RAM_TR_SHORT_BUF_1__PRE 0x0
7391
7392#define SCU_RAM_TR_LONG_BUF_0__A 0x831ED2
7393#define SCU_RAM_TR_LONG_BUF_0__W 16
7394#define SCU_RAM_TR_LONG_BUF_0__M 0xFFFF
7395#define SCU_RAM_TR_LONG_BUF_0__PRE 0x0
7396
7397#define SCU_RAM_TR_LONG_BUF_1__A 0x831ED3
7398#define SCU_RAM_TR_LONG_BUF_1__W 16
7399#define SCU_RAM_TR_LONG_BUF_1__M 0xFFFF
7400#define SCU_RAM_TR_LONG_BUF_1__PRE 0x0
7401
7402#define SCU_RAM_TR_LONG_BUF_2__A 0x831ED4
7403#define SCU_RAM_TR_LONG_BUF_2__W 16
7404#define SCU_RAM_TR_LONG_BUF_2__M 0xFFFF
7405#define SCU_RAM_TR_LONG_BUF_2__PRE 0x0
7406
7407#define SCU_RAM_TR_LONG_BUF_3__A 0x831ED5
7408#define SCU_RAM_TR_LONG_BUF_3__W 16
7409#define SCU_RAM_TR_LONG_BUF_3__M 0xFFFF
7410#define SCU_RAM_TR_LONG_BUF_3__PRE 0x0
7411
7412#define SCU_RAM_TR_LONG_BUF_4__A 0x831ED6
7413#define SCU_RAM_TR_LONG_BUF_4__W 16
7414#define SCU_RAM_TR_LONG_BUF_4__M 0xFFFF
7415#define SCU_RAM_TR_LONG_BUF_4__PRE 0x0
7416
7417#define SCU_RAM_TR_LONG_BUF_5__A 0x831ED7
7418#define SCU_RAM_TR_LONG_BUF_5__W 16
7419#define SCU_RAM_TR_LONG_BUF_5__M 0xFFFF
7420#define SCU_RAM_TR_LONG_BUF_5__PRE 0x0
7421
7422#define SCU_RAM_TR_LONG_BUF_6__A 0x831ED8
7423#define SCU_RAM_TR_LONG_BUF_6__W 16
7424#define SCU_RAM_TR_LONG_BUF_6__M 0xFFFF
7425#define SCU_RAM_TR_LONG_BUF_6__PRE 0x0
7426
7427#define SCU_RAM_TR_LONG_BUF_7__A 0x831ED9
7428#define SCU_RAM_TR_LONG_BUF_7__W 16
7429#define SCU_RAM_TR_LONG_BUF_7__M 0xFFFF
7430#define SCU_RAM_TR_LONG_BUF_7__PRE 0x0
7431
7432#define SCU_RAM_TR_LONG_BUF_8__A 0x831EDA
7433#define SCU_RAM_TR_LONG_BUF_8__W 16
7434#define SCU_RAM_TR_LONG_BUF_8__M 0xFFFF
7435#define SCU_RAM_TR_LONG_BUF_8__PRE 0x0
7436
7437#define SCU_RAM_TR_LONG_BUF_9__A 0x831EDB
7438#define SCU_RAM_TR_LONG_BUF_9__W 16
7439#define SCU_RAM_TR_LONG_BUF_9__M 0xFFFF
7440#define SCU_RAM_TR_LONG_BUF_9__PRE 0x0
7441
7442#define SCU_RAM_TR_LONG_BUF_10__A 0x831EDC
7443#define SCU_RAM_TR_LONG_BUF_10__W 16
7444#define SCU_RAM_TR_LONG_BUF_10__M 0xFFFF
7445#define SCU_RAM_TR_LONG_BUF_10__PRE 0x0
7446
7447#define SCU_RAM_TR_LONG_BUF_11__A 0x831EDD
7448#define SCU_RAM_TR_LONG_BUF_11__W 16
7449#define SCU_RAM_TR_LONG_BUF_11__M 0xFFFF
7450#define SCU_RAM_TR_LONG_BUF_11__PRE 0x0
7451
7452#define SCU_RAM_TR_LONG_BUF_12__A 0x831EDE
7453#define SCU_RAM_TR_LONG_BUF_12__W 16
7454#define SCU_RAM_TR_LONG_BUF_12__M 0xFFFF
7455#define SCU_RAM_TR_LONG_BUF_12__PRE 0x0
7456
7457#define SCU_RAM_TR_LONG_BUF_13__A 0x831EDF
7458#define SCU_RAM_TR_LONG_BUF_13__W 16
7459#define SCU_RAM_TR_LONG_BUF_13__M 0xFFFF
7460#define SCU_RAM_TR_LONG_BUF_13__PRE 0x0
7461
7462#define SCU_RAM_TR_LONG_BUF_14__A 0x831EE0
7463#define SCU_RAM_TR_LONG_BUF_14__W 16
7464#define SCU_RAM_TR_LONG_BUF_14__M 0xFFFF
7465#define SCU_RAM_TR_LONG_BUF_14__PRE 0x0
7466
7467#define SCU_RAM_TR_LONG_BUF_15__A 0x831EE1
7468#define SCU_RAM_TR_LONG_BUF_15__W 16
7469#define SCU_RAM_TR_LONG_BUF_15__M 0xFFFF
7470#define SCU_RAM_TR_LONG_BUF_15__PRE 0x0
7471
7472#define SCU_RAM_TR_LONG_BUF_16__A 0x831EE2
7473#define SCU_RAM_TR_LONG_BUF_16__W 16
7474#define SCU_RAM_TR_LONG_BUF_16__M 0xFFFF
7475#define SCU_RAM_TR_LONG_BUF_16__PRE 0x0
7476
7477#define SCU_RAM_TR_LONG_BUF_17__A 0x831EE3
7478#define SCU_RAM_TR_LONG_BUF_17__W 16
7479#define SCU_RAM_TR_LONG_BUF_17__M 0xFFFF
7480#define SCU_RAM_TR_LONG_BUF_17__PRE 0x0
7481
7482#define SCU_RAM_TR_LONG_BUF_18__A 0x831EE4
7483#define SCU_RAM_TR_LONG_BUF_18__W 16
7484#define SCU_RAM_TR_LONG_BUF_18__M 0xFFFF
7485#define SCU_RAM_TR_LONG_BUF_18__PRE 0x0
7486
7487#define SCU_RAM_TR_LONG_BUF_19__A 0x831EE5
7488#define SCU_RAM_TR_LONG_BUF_19__W 16
7489#define SCU_RAM_TR_LONG_BUF_19__M 0xFFFF
7490#define SCU_RAM_TR_LONG_BUF_19__PRE 0x0
7491
7492#define SCU_RAM_TR_LONG_BUF_20__A 0x831EE6
7493#define SCU_RAM_TR_LONG_BUF_20__W 16
7494#define SCU_RAM_TR_LONG_BUF_20__M 0xFFFF
7495#define SCU_RAM_TR_LONG_BUF_20__PRE 0x0
7496
7497#define SCU_RAM_TR_LONG_BUF_21__A 0x831EE7
7498#define SCU_RAM_TR_LONG_BUF_21__W 16
7499#define SCU_RAM_TR_LONG_BUF_21__M 0xFFFF
7500#define SCU_RAM_TR_LONG_BUF_21__PRE 0x0
7501
7502#define SCU_RAM_TR_LONG_BUF_22__A 0x831EE8
7503#define SCU_RAM_TR_LONG_BUF_22__W 16
7504#define SCU_RAM_TR_LONG_BUF_22__M 0xFFFF
7505#define SCU_RAM_TR_LONG_BUF_22__PRE 0x0
7506
7507#define SCU_RAM_TR_LONG_BUF_23__A 0x831EE9
7508#define SCU_RAM_TR_LONG_BUF_23__W 16
7509#define SCU_RAM_TR_LONG_BUF_23__M 0xFFFF
7510#define SCU_RAM_TR_LONG_BUF_23__PRE 0x0
7511
7512#define SCU_RAM_TR_LONG_BUF_24__A 0x831EEA
7513#define SCU_RAM_TR_LONG_BUF_24__W 16
7514#define SCU_RAM_TR_LONG_BUF_24__M 0xFFFF
7515#define SCU_RAM_TR_LONG_BUF_24__PRE 0x0
7516
7517#define SCU_RAM_TR_LONG_BUF_25__A 0x831EEB
7518#define SCU_RAM_TR_LONG_BUF_25__W 16
7519#define SCU_RAM_TR_LONG_BUF_25__M 0xFFFF
7520#define SCU_RAM_TR_LONG_BUF_25__PRE 0x0
7521
7522#define SCU_RAM_TR_LONG_BUF_26__A 0x831EEC
7523#define SCU_RAM_TR_LONG_BUF_26__W 16
7524#define SCU_RAM_TR_LONG_BUF_26__M 0xFFFF
7525#define SCU_RAM_TR_LONG_BUF_26__PRE 0x0
7526
7527#define SCU_RAM_TR_LONG_BUF_27__A 0x831EED
7528#define SCU_RAM_TR_LONG_BUF_27__W 16
7529#define SCU_RAM_TR_LONG_BUF_27__M 0xFFFF
7530#define SCU_RAM_TR_LONG_BUF_27__PRE 0x0
7531
7532#define SCU_RAM_TR_LONG_BUF_28__A 0x831EEE
7533#define SCU_RAM_TR_LONG_BUF_28__W 16
7534#define SCU_RAM_TR_LONG_BUF_28__M 0xFFFF
7535#define SCU_RAM_TR_LONG_BUF_28__PRE 0x0
7536
7537#define SCU_RAM_TR_LONG_BUF_29__A 0x831EEF
7538#define SCU_RAM_TR_LONG_BUF_29__W 16
7539#define SCU_RAM_TR_LONG_BUF_29__M 0xFFFF
7540#define SCU_RAM_TR_LONG_BUF_29__PRE 0x0
7541
7542#define SCU_RAM_TR_LONG_BUF_30__A 0x831EF0
7543#define SCU_RAM_TR_LONG_BUF_30__W 16
7544#define SCU_RAM_TR_LONG_BUF_30__M 0xFFFF
7545#define SCU_RAM_TR_LONG_BUF_30__PRE 0x0
7546
7547#define SCU_RAM_TR_LONG_BUF_31__A 0x831EF1
7548#define SCU_RAM_TR_LONG_BUF_31__W 16
7549#define SCU_RAM_TR_LONG_BUF_31__M 0xFFFF
7550#define SCU_RAM_TR_LONG_BUF_31__PRE 0x0
7551#define SCU_RAM_ATV_AMS_MAX__A 0x831EF2
7552#define SCU_RAM_ATV_AMS_MAX__W 11
7553#define SCU_RAM_ATV_AMS_MAX__M 0x7FF
7554#define SCU_RAM_ATV_AMS_MAX__PRE 0x0
7555
7556#define SCU_RAM_ATV_AMS_MAX_AMS_MAX__B 0
7557#define SCU_RAM_ATV_AMS_MAX_AMS_MAX__W 11
7558#define SCU_RAM_ATV_AMS_MAX_AMS_MAX__M 0x7FF
7559#define SCU_RAM_ATV_AMS_MAX_AMS_MAX__PRE 0x0
7560
7561#define SCU_RAM_ATV_AMS_MIN__A 0x831EF3
7562#define SCU_RAM_ATV_AMS_MIN__W 11
7563#define SCU_RAM_ATV_AMS_MIN__M 0x7FF
7564#define SCU_RAM_ATV_AMS_MIN__PRE 0x0
7565
7566#define SCU_RAM_ATV_AMS_MIN_AMS_MIN__B 0
7567#define SCU_RAM_ATV_AMS_MIN_AMS_MIN__W 11
7568#define SCU_RAM_ATV_AMS_MIN_AMS_MIN__M 0x7FF
7569#define SCU_RAM_ATV_AMS_MIN_AMS_MIN__PRE 0x0
7570
7571#define SCU_RAM_ATV_FIELD_CNT__A 0x831EF4
7572#define SCU_RAM_ATV_FIELD_CNT__W 9
7573#define SCU_RAM_ATV_FIELD_CNT__M 0x1FF
7574#define SCU_RAM_ATV_FIELD_CNT__PRE 0x0
7575
7576#define SCU_RAM_ATV_FIELD_CNT_FIELD_CNT__B 0
7577#define SCU_RAM_ATV_FIELD_CNT_FIELD_CNT__W 9
7578#define SCU_RAM_ATV_FIELD_CNT_FIELD_CNT__M 0x1FF
7579#define SCU_RAM_ATV_FIELD_CNT_FIELD_CNT__PRE 0x0
7580
7581#define SCU_RAM_ATV_AAGC_FAST__A 0x831EF5
7582#define SCU_RAM_ATV_AAGC_FAST__W 1
7583#define SCU_RAM_ATV_AAGC_FAST__M 0x1
7584#define SCU_RAM_ATV_AAGC_FAST__PRE 0x0
7585
7586#define SCU_RAM_ATV_AAGC_FAST_AAGC_FAST__B 0
7587#define SCU_RAM_ATV_AAGC_FAST_AAGC_FAST__W 1
7588#define SCU_RAM_ATV_AAGC_FAST_AAGC_FAST__M 0x1
7589#define SCU_RAM_ATV_AAGC_FAST_AAGC_FAST__PRE 0x0
7590#define SCU_RAM_ATV_AAGC_FAST_AAGC_FAST_OFF 0x0
7591#define SCU_RAM_ATV_AAGC_FAST_AAGC_FAST_ON 0x1
7592
7593#define SCU_RAM_ATV_AAGC_LP2__A 0x831EF6
7594#define SCU_RAM_ATV_AAGC_LP2__W 16
7595#define SCU_RAM_ATV_AAGC_LP2__M 0xFFFF
7596#define SCU_RAM_ATV_AAGC_LP2__PRE 0x0
7597
7598#define SCU_RAM_ATV_AAGC_LP2_AAGC_LP2__B 0
7599#define SCU_RAM_ATV_AAGC_LP2_AAGC_LP2__W 16
7600#define SCU_RAM_ATV_AAGC_LP2_AAGC_LP2__M 0xFFFF
7601#define SCU_RAM_ATV_AAGC_LP2_AAGC_LP2__PRE 0x0
7602
7603#define SCU_RAM_ATV_BP_LVL__A 0x831EF7
7604#define SCU_RAM_ATV_BP_LVL__W 11
7605#define SCU_RAM_ATV_BP_LVL__M 0x7FF
7606#define SCU_RAM_ATV_BP_LVL__PRE 0x0
7607
7608#define SCU_RAM_ATV_BP_LVL_BP_LVL__B 0
7609#define SCU_RAM_ATV_BP_LVL_BP_LVL__W 11
7610#define SCU_RAM_ATV_BP_LVL_BP_LVL__M 0x7FF
7611#define SCU_RAM_ATV_BP_LVL_BP_LVL__PRE 0x0
7612
7613#define SCU_RAM_ATV_BP_RELY__A 0x831EF8
7614#define SCU_RAM_ATV_BP_RELY__W 8
7615#define SCU_RAM_ATV_BP_RELY__M 0xFF
7616#define SCU_RAM_ATV_BP_RELY__PRE 0x0
7617
7618#define SCU_RAM_ATV_BP_RELY_BP_RELY__B 0
7619#define SCU_RAM_ATV_BP_RELY_BP_RELY__W 8
7620#define SCU_RAM_ATV_BP_RELY_BP_RELY__M 0xFF
7621#define SCU_RAM_ATV_BP_RELY_BP_RELY__PRE 0x0
7622
7623#define SCU_RAM_ATV_BP_MTA__A 0x831EF9
7624#define SCU_RAM_ATV_BP_MTA__W 14
7625#define SCU_RAM_ATV_BP_MTA__M 0x3FFF
7626#define SCU_RAM_ATV_BP_MTA__PRE 0x0
7627
7628#define SCU_RAM_ATV_BP_MTA_BP_MTA__B 0
7629#define SCU_RAM_ATV_BP_MTA_BP_MTA__W 14
7630#define SCU_RAM_ATV_BP_MTA_BP_MTA__M 0x3FFF
7631#define SCU_RAM_ATV_BP_MTA_BP_MTA__PRE 0x0
7632
7633#define SCU_RAM_ATV_BP_REF__A 0x831EFA
7634#define SCU_RAM_ATV_BP_REF__W 11
7635#define SCU_RAM_ATV_BP_REF__M 0x7FF
7636#define SCU_RAM_ATV_BP_REF__PRE 0x0
7637
7638#define SCU_RAM_ATV_BP_REF_BP_REF__B 0
7639#define SCU_RAM_ATV_BP_REF_BP_REF__W 11
7640#define SCU_RAM_ATV_BP_REF_BP_REF__M 0x7FF
7641#define SCU_RAM_ATV_BP_REF_BP_REF__PRE 0x0
7642
7643#define SCU_RAM_ATV_BP_REF_MIN__A 0x831EFB
7644#define SCU_RAM_ATV_BP_REF_MIN__W 11
7645#define SCU_RAM_ATV_BP_REF_MIN__M 0x7FF
7646#define SCU_RAM_ATV_BP_REF_MIN__PRE 0x0
7647
7648#define SCU_RAM_ATV_BP_REF_MIN_BP_REF_MIN__B 0
7649#define SCU_RAM_ATV_BP_REF_MIN_BP_REF_MIN__W 11
7650#define SCU_RAM_ATV_BP_REF_MIN_BP_REF_MIN__M 0x7FF
7651#define SCU_RAM_ATV_BP_REF_MIN_BP_REF_MIN__PRE 0x0
7652
7653#define SCU_RAM_ATV_BP_REF_MAX__A 0x831EFC
7654#define SCU_RAM_ATV_BP_REF_MAX__W 11
7655#define SCU_RAM_ATV_BP_REF_MAX__M 0x7FF
7656#define SCU_RAM_ATV_BP_REF_MAX__PRE 0x0
7657
7658#define SCU_RAM_ATV_BP_REF_MAX_BP_REF_MAX__B 0
7659#define SCU_RAM_ATV_BP_REF_MAX_BP_REF_MAX__W 11
7660#define SCU_RAM_ATV_BP_REF_MAX_BP_REF_MAX__M 0x7FF
7661#define SCU_RAM_ATV_BP_REF_MAX_BP_REF_MAX__PRE 0x0
7662
7663#define SCU_RAM_ATV_BP_CNT__A 0x831EFD
7664#define SCU_RAM_ATV_BP_CNT__W 8
7665#define SCU_RAM_ATV_BP_CNT__M 0xFF
7666#define SCU_RAM_ATV_BP_CNT__PRE 0x0
7667
7668#define SCU_RAM_ATV_BP_CNT_BP_CNT__B 0
7669#define SCU_RAM_ATV_BP_CNT_BP_CNT__W 8
7670#define SCU_RAM_ATV_BP_CNT_BP_CNT__M 0xFF
7671#define SCU_RAM_ATV_BP_CNT_BP_CNT__PRE 0x0
7672
7673#define SCU_RAM_ATV_BP_XD_CNT__A 0x831EFE
7674#define SCU_RAM_ATV_BP_XD_CNT__W 12
7675#define SCU_RAM_ATV_BP_XD_CNT__M 0xFFF
7676#define SCU_RAM_ATV_BP_XD_CNT__PRE 0x0
7677
7678#define SCU_RAM_ATV_BP_XD_CNT_BP_XD_CNT__B 0
7679#define SCU_RAM_ATV_BP_XD_CNT_BP_XD_CNT__W 12
7680#define SCU_RAM_ATV_BP_XD_CNT_BP_XD_CNT__M 0xFFF
7681#define SCU_RAM_ATV_BP_XD_CNT_BP_XD_CNT__PRE 0x0
7682
7683#define SCU_RAM_ATV_PAGC_KI_MIN__A 0x831EFF
7684#define SCU_RAM_ATV_PAGC_KI_MIN__W 12
7685#define SCU_RAM_ATV_PAGC_KI_MIN__M 0xFFF
7686#define SCU_RAM_ATV_PAGC_KI_MIN__PRE 0x0
7687
7688#define SCU_RAM_ATV_PAGC_KI_MIN_PAGC_KI_MIN__B 0
7689#define SCU_RAM_ATV_PAGC_KI_MIN_PAGC_KI_MIN__W 12
7690#define SCU_RAM_ATV_PAGC_KI_MIN_PAGC_KI_MIN__M 0xFFF
7691#define SCU_RAM_ATV_PAGC_KI_MIN_PAGC_KI_MIN__PRE 0x0
7692
7693#define SCU_RAM_ATV_BPC_KI_MIN__A 0x831F00
7694#define SCU_RAM_ATV_BPC_KI_MIN__W 12
7695#define SCU_RAM_ATV_BPC_KI_MIN__M 0xFFF
7696#define SCU_RAM_ATV_BPC_KI_MIN__PRE 0x0
7697
7698#define SCU_RAM_ATV_BPC_KI_MIN_BPC_KI_MIN__B 0
7699#define SCU_RAM_ATV_BPC_KI_MIN_BPC_KI_MIN__W 12
7700#define SCU_RAM_ATV_BPC_KI_MIN_BPC_KI_MIN__M 0xFFF
7701#define SCU_RAM_ATV_BPC_KI_MIN_BPC_KI_MIN__PRE 0x0
7702
7703#define SCU_RAM_ORX_RF_RX_FREQUENCY_VALUE__A 0x831F01
7704#define SCU_RAM_ORX_RF_RX_FREQUENCY_VALUE__W 16
7705#define SCU_RAM_ORX_RF_RX_FREQUENCY_VALUE__M 0xFFFF
7706#define SCU_RAM_ORX_RF_RX_FREQUENCY_VALUE__PRE 0x0
7707
7708#define SCU_RAM_ORX_RF_RX_DATA_RATE__A 0x831F02
7709#define SCU_RAM_ORX_RF_RX_DATA_RATE__W 8
7710#define SCU_RAM_ORX_RF_RX_DATA_RATE__M 0xFF
7711#define SCU_RAM_ORX_RF_RX_DATA_RATE__PRE 0x0
7712#define SCU_RAM_ORX_RF_RX_DATA_RATE_2048KBPS_REGSPEC 0x0
7713#define SCU_RAM_ORX_RF_RX_DATA_RATE_2048KBPS_INVSPEC 0x1
7714#define SCU_RAM_ORX_RF_RX_DATA_RATE_2048KBPS_REGSPEC_ALT 0x40
7715#define SCU_RAM_ORX_RF_RX_DATA_RATE_2048KBPS_INVSPEC_ALT 0x41
7716#define SCU_RAM_ORX_RF_RX_DATA_RATE_1544KBPS_REGSPEC 0x80
7717#define SCU_RAM_ORX_RF_RX_DATA_RATE_1544KBPS_INVSPEC 0x81
7718#define SCU_RAM_ORX_RF_RX_DATA_RATE_3088KBPS_REGSPEC 0xC0
7719#define SCU_RAM_ORX_RF_RX_DATA_RATE_3088KBPS_INVSPEC 0xC1
7720
7721#define SCU_RAM_ORX_SCU_STATE__A 0x831F03
7722#define SCU_RAM_ORX_SCU_STATE__W 8
7723#define SCU_RAM_ORX_SCU_STATE__M 0xFF
7724#define SCU_RAM_ORX_SCU_STATE__PRE 0x0
7725#define SCU_RAM_ORX_SCU_STATE_RESET 0x0
7726#define SCU_RAM_ORX_SCU_STATE_AGN_HUNT 0x1
7727#define SCU_RAM_ORX_SCU_STATE_DGN_HUNT 0x2
7728#define SCU_RAM_ORX_SCU_STATE_AGC_HUNT 0x3
7729#define SCU_RAM_ORX_SCU_STATE_FRQ_HUNT 0x4
7730#define SCU_RAM_ORX_SCU_STATE_PHA_HUNT 0x8
7731#define SCU_RAM_ORX_SCU_STATE_TIM_HUNT 0x10
7732#define SCU_RAM_ORX_SCU_STATE_EQU_HUNT 0x20
7733#define SCU_RAM_ORX_SCU_STATE_EQT_HUNT 0x30
7734#define SCU_RAM_ORX_SCU_STATE_SYNC 0x40
7735
7736#define SCU_RAM_ORX_SCU_LOCK__A 0x831F04
7737#define SCU_RAM_ORX_SCU_LOCK__W 16
7738#define SCU_RAM_ORX_SCU_LOCK__M 0xFFFF
7739#define SCU_RAM_ORX_SCU_LOCK__PRE 0x0
7740
7741#define SCU_RAM_ORX_TARGET_MODE__A 0x831F05
7742#define SCU_RAM_ORX_TARGET_MODE__W 2
7743#define SCU_RAM_ORX_TARGET_MODE__M 0x3
7744#define SCU_RAM_ORX_TARGET_MODE__PRE 0x0
7745#define SCU_RAM_ORX_TARGET_MODE_1544KBPS 0x0
7746#define SCU_RAM_ORX_TARGET_MODE_3088KBPS 0x1
7747#define SCU_RAM_ORX_TARGET_MODE_2048KBPS_SQRT 0x2
7748#define SCU_RAM_ORX_TARGET_MODE_2048KBPS_RO 0x3
7749
7750#define SCU_RAM_ORX_MER_MIN_DB__A 0x831F06
7751#define SCU_RAM_ORX_MER_MIN_DB__W 8
7752#define SCU_RAM_ORX_MER_MIN_DB__M 0xFF
7753#define SCU_RAM_ORX_MER_MIN_DB__PRE 0x0
7754
7755#define SCU_RAM_ORX_RF_GAIN__A 0x831F07
7756#define SCU_RAM_ORX_RF_GAIN__W 16
7757#define SCU_RAM_ORX_RF_GAIN__M 0xFFFF
7758#define SCU_RAM_ORX_RF_GAIN__PRE 0x0
7759
7760#define SCU_RAM_ORX_RF_GAIN_MIN__A 0x831F08
7761#define SCU_RAM_ORX_RF_GAIN_MIN__W 16
7762#define SCU_RAM_ORX_RF_GAIN_MIN__M 0xFFFF
7763#define SCU_RAM_ORX_RF_GAIN_MIN__PRE 0x0
7764
7765#define SCU_RAM_ORX_RF_GAIN_MAX__A 0x831F09
7766#define SCU_RAM_ORX_RF_GAIN_MAX__W 16
7767#define SCU_RAM_ORX_RF_GAIN_MAX__M 0xFFFF
7768#define SCU_RAM_ORX_RF_GAIN_MAX__PRE 0x0
7769
7770#define SCU_RAM_ORX_IF_GAIN__A 0x831F0A
7771#define SCU_RAM_ORX_IF_GAIN__W 16
7772#define SCU_RAM_ORX_IF_GAIN__M 0xFFFF
7773#define SCU_RAM_ORX_IF_GAIN__PRE 0x0
7774
7775#define SCU_RAM_ORX_IF_GAIN_MIN__A 0x831F0B
7776#define SCU_RAM_ORX_IF_GAIN_MIN__W 16
7777#define SCU_RAM_ORX_IF_GAIN_MIN__M 0xFFFF
7778#define SCU_RAM_ORX_IF_GAIN_MIN__PRE 0x0
7779
7780#define SCU_RAM_ORX_IF_GAIN_MAX__A 0x831F0C
7781#define SCU_RAM_ORX_IF_GAIN_MAX__W 16
7782#define SCU_RAM_ORX_IF_GAIN_MAX__M 0xFFFF
7783#define SCU_RAM_ORX_IF_GAIN_MAX__PRE 0x0
7784
7785#define SCU_RAM_ORX_AGN_HEADR__A 0x831F0D
7786#define SCU_RAM_ORX_AGN_HEADR__W 16
7787#define SCU_RAM_ORX_AGN_HEADR__M 0xFFFF
7788#define SCU_RAM_ORX_AGN_HEADR__PRE 0x0
7789
7790#define SCU_RAM_ORX_AGN_HEADR_STP__A 0x831F0E
7791#define SCU_RAM_ORX_AGN_HEADR_STP__W 8
7792#define SCU_RAM_ORX_AGN_HEADR_STP__M 0xFF
7793#define SCU_RAM_ORX_AGN_HEADR_STP__PRE 0x0
7794
7795#define SCU_RAM_ORX_AGN_KI__A 0x831F0F
7796#define SCU_RAM_ORX_AGN_KI__W 8
7797#define SCU_RAM_ORX_AGN_KI__M 0xFF
7798#define SCU_RAM_ORX_AGN_KI__PRE 0x0
7799
7800#define SCU_RAM_ORX_AGN_LOCK_TH__A 0x831F10
7801#define SCU_RAM_ORX_AGN_LOCK_TH__W 16
7802#define SCU_RAM_ORX_AGN_LOCK_TH__M 0xFFFF
7803#define SCU_RAM_ORX_AGN_LOCK_TH__PRE 0x0
7804
7805#define SCU_RAM_ORX_AGN_LOCK_WD__A 0x831F11
7806#define SCU_RAM_ORX_AGN_LOCK_WD__W 16
7807#define SCU_RAM_ORX_AGN_LOCK_WD__M 0xFFFF
7808#define SCU_RAM_ORX_AGN_LOCK_WD__PRE 0x0
7809
7810#define SCU_RAM_ORX_AGN_ONLOCK_TTH__A 0x831F12
7811#define SCU_RAM_ORX_AGN_ONLOCK_TTH__W 16
7812#define SCU_RAM_ORX_AGN_ONLOCK_TTH__M 0xFFFF
7813#define SCU_RAM_ORX_AGN_ONLOCK_TTH__PRE 0x0
7814
7815#define SCU_RAM_ORX_AGN_UNLOCK_TTH__A 0x831F13
7816#define SCU_RAM_ORX_AGN_UNLOCK_TTH__W 16
7817#define SCU_RAM_ORX_AGN_UNLOCK_TTH__M 0xFFFF
7818#define SCU_RAM_ORX_AGN_UNLOCK_TTH__PRE 0x0
7819
7820#define SCU_RAM_ORX_AGN_LOCK_TOTH__A 0x831F14
7821#define SCU_RAM_ORX_AGN_LOCK_TOTH__W 16
7822#define SCU_RAM_ORX_AGN_LOCK_TOTH__M 0xFFFF
7823#define SCU_RAM_ORX_AGN_LOCK_TOTH__PRE 0x0
7824
7825#define SCU_RAM_ORX_AGN_LOCK_MASK__A 0x831F15
7826#define SCU_RAM_ORX_AGN_LOCK_MASK__W 8
7827#define SCU_RAM_ORX_AGN_LOCK_MASK__M 0xFF
7828#define SCU_RAM_ORX_AGN_LOCK_MASK__PRE 0x0
7829
7830#define SCU_RAM_ORX_DGN__A 0x831F16
7831#define SCU_RAM_ORX_DGN__W 16
7832#define SCU_RAM_ORX_DGN__M 0xFFFF
7833#define SCU_RAM_ORX_DGN__PRE 0x0
7834
7835#define SCU_RAM_ORX_DGN_MIN__A 0x831F17
7836#define SCU_RAM_ORX_DGN_MIN__W 16
7837#define SCU_RAM_ORX_DGN_MIN__M 0xFFFF
7838#define SCU_RAM_ORX_DGN_MIN__PRE 0x0
7839
7840#define SCU_RAM_ORX_DGN_MAX__A 0x831F18
7841#define SCU_RAM_ORX_DGN_MAX__W 16
7842#define SCU_RAM_ORX_DGN_MAX__M 0xFFFF
7843#define SCU_RAM_ORX_DGN_MAX__PRE 0x0
7844
7845#define SCU_RAM_ORX_DGN_AMP__A 0x831F19
7846#define SCU_RAM_ORX_DGN_AMP__W 16
7847#define SCU_RAM_ORX_DGN_AMP__M 0xFFFF
7848#define SCU_RAM_ORX_DGN_AMP__PRE 0x0
7849
7850#define SCU_RAM_ORX_DGN_AMPTARGET__A 0x831F1A
7851#define SCU_RAM_ORX_DGN_AMPTARGET__W 16
7852#define SCU_RAM_ORX_DGN_AMPTARGET__M 0xFFFF
7853#define SCU_RAM_ORX_DGN_AMPTARGET__PRE 0x0
7854
7855#define SCU_RAM_ORX_DGN_KI__A 0x831F1B
7856#define SCU_RAM_ORX_DGN_KI__W 8
7857#define SCU_RAM_ORX_DGN_KI__M 0xFF
7858#define SCU_RAM_ORX_DGN_KI__PRE 0x0
7859
7860#define SCU_RAM_ORX_DGN_LOCK_TH__A 0x831F1C
7861#define SCU_RAM_ORX_DGN_LOCK_TH__W 16
7862#define SCU_RAM_ORX_DGN_LOCK_TH__M 0xFFFF
7863#define SCU_RAM_ORX_DGN_LOCK_TH__PRE 0x0
7864
7865#define SCU_RAM_ORX_DGN_LOCK_WD__A 0x831F1D
7866#define SCU_RAM_ORX_DGN_LOCK_WD__W 16
7867#define SCU_RAM_ORX_DGN_LOCK_WD__M 0xFFFF
7868#define SCU_RAM_ORX_DGN_LOCK_WD__PRE 0x0
7869
7870#define SCU_RAM_ORX_DGN_ONLOCK_TTH__A 0x831F1E
7871#define SCU_RAM_ORX_DGN_ONLOCK_TTH__W 16
7872#define SCU_RAM_ORX_DGN_ONLOCK_TTH__M 0xFFFF
7873#define SCU_RAM_ORX_DGN_ONLOCK_TTH__PRE 0x0
7874
7875#define SCU_RAM_ORX_DGN_UNLOCK_TTH__A 0x831F1F
7876#define SCU_RAM_ORX_DGN_UNLOCK_TTH__W 16
7877#define SCU_RAM_ORX_DGN_UNLOCK_TTH__M 0xFFFF
7878#define SCU_RAM_ORX_DGN_UNLOCK_TTH__PRE 0x0
7879
7880#define SCU_RAM_ORX_DGN_LOCK_TOTH__A 0x831F20
7881#define SCU_RAM_ORX_DGN_LOCK_TOTH__W 16
7882#define SCU_RAM_ORX_DGN_LOCK_TOTH__M 0xFFFF
7883#define SCU_RAM_ORX_DGN_LOCK_TOTH__PRE 0x0
7884
7885#define SCU_RAM_ORX_DGN_LOCK_MASK__A 0x831F21
7886#define SCU_RAM_ORX_DGN_LOCK_MASK__W 8
7887#define SCU_RAM_ORX_DGN_LOCK_MASK__M 0xFF
7888#define SCU_RAM_ORX_DGN_LOCK_MASK__PRE 0x0
7889
7890#define SCU_RAM_ORX_FREQ_GAIN_CORR__A 0x831F22
7891#define SCU_RAM_ORX_FREQ_GAIN_CORR__W 8
7892#define SCU_RAM_ORX_FREQ_GAIN_CORR__M 0xFF
7893#define SCU_RAM_ORX_FREQ_GAIN_CORR__PRE 0x0
7894#define SCU_RAM_ORX_FREQ_GAIN_CORR_1544KBPS 0x60
7895#define SCU_RAM_ORX_FREQ_GAIN_CORR_2048KBPS 0x80
7896#define SCU_RAM_ORX_FREQ_GAIN_CORR_3088KBPS 0xC0
7897
7898#define SCU_RAM_ORX_FRQ_OFFSET__A 0x831F23
7899#define SCU_RAM_ORX_FRQ_OFFSET__W 16
7900#define SCU_RAM_ORX_FRQ_OFFSET__M 0xFFFF
7901#define SCU_RAM_ORX_FRQ_OFFSET__PRE 0x0
7902
7903#define SCU_RAM_ORX_FRQ_OFFSET_MAX__A 0x831F24
7904#define SCU_RAM_ORX_FRQ_OFFSET_MAX__W 15
7905#define SCU_RAM_ORX_FRQ_OFFSET_MAX__M 0x7FFF
7906#define SCU_RAM_ORX_FRQ_OFFSET_MAX__PRE 0x0
7907
7908#define SCU_RAM_ORX_FRQ_KI__A 0x831F25
7909#define SCU_RAM_ORX_FRQ_KI__W 8
7910#define SCU_RAM_ORX_FRQ_KI__M 0xFF
7911#define SCU_RAM_ORX_FRQ_KI__PRE 0x0
7912
7913#define SCU_RAM_ORX_FRQ_DIFF__A 0x831F26
7914#define SCU_RAM_ORX_FRQ_DIFF__W 16
7915#define SCU_RAM_ORX_FRQ_DIFF__M 0xFFFF
7916#define SCU_RAM_ORX_FRQ_DIFF__PRE 0x0
7917
7918#define SCU_RAM_ORX_FRQ_LOCK_TH__A 0x831F27
7919#define SCU_RAM_ORX_FRQ_LOCK_TH__W 16
7920#define SCU_RAM_ORX_FRQ_LOCK_TH__M 0xFFFF
7921#define SCU_RAM_ORX_FRQ_LOCK_TH__PRE 0x0
7922
7923#define SCU_RAM_ORX_FRQ_LOCK_WD__A 0x831F28
7924#define SCU_RAM_ORX_FRQ_LOCK_WD__W 16
7925#define SCU_RAM_ORX_FRQ_LOCK_WD__M 0xFFFF
7926#define SCU_RAM_ORX_FRQ_LOCK_WD__PRE 0x0
7927
7928#define SCU_RAM_ORX_FRQ_ONLOCK_TTH__A 0x831F29
7929#define SCU_RAM_ORX_FRQ_ONLOCK_TTH__W 16
7930#define SCU_RAM_ORX_FRQ_ONLOCK_TTH__M 0xFFFF
7931#define SCU_RAM_ORX_FRQ_ONLOCK_TTH__PRE 0x0
7932
7933#define SCU_RAM_ORX_FRQ_UNLOCK_TTH__A 0x831F2A
7934#define SCU_RAM_ORX_FRQ_UNLOCK_TTH__W 16
7935#define SCU_RAM_ORX_FRQ_UNLOCK_TTH__M 0xFFFF
7936#define SCU_RAM_ORX_FRQ_UNLOCK_TTH__PRE 0x0
7937
7938#define SCU_RAM_ORX_FRQ_LOCK_TOTH__A 0x831F2B
7939#define SCU_RAM_ORX_FRQ_LOCK_TOTH__W 16
7940#define SCU_RAM_ORX_FRQ_LOCK_TOTH__M 0xFFFF
7941#define SCU_RAM_ORX_FRQ_LOCK_TOTH__PRE 0x0
7942
7943#define SCU_RAM_ORX_FRQ_LOCK_MASK__A 0x831F2C
7944#define SCU_RAM_ORX_FRQ_LOCK_MASK__W 8
7945#define SCU_RAM_ORX_FRQ_LOCK_MASK__M 0xFF
7946#define SCU_RAM_ORX_FRQ_LOCK_MASK__PRE 0x0
7947
7948#define SCU_RAM_ORX_PHA_DIFF__A 0x831F2D
7949#define SCU_RAM_ORX_PHA_DIFF__W 16
7950#define SCU_RAM_ORX_PHA_DIFF__M 0xFFFF
7951#define SCU_RAM_ORX_PHA_DIFF__PRE 0x0
7952
7953#define SCU_RAM_ORX_PHA_LOCK_TH__A 0x831F2E
7954#define SCU_RAM_ORX_PHA_LOCK_TH__W 16
7955#define SCU_RAM_ORX_PHA_LOCK_TH__M 0xFFFF
7956#define SCU_RAM_ORX_PHA_LOCK_TH__PRE 0x0
7957
7958#define SCU_RAM_ORX_PHA_LOCK_WD__A 0x831F2F
7959#define SCU_RAM_ORX_PHA_LOCK_WD__W 16
7960#define SCU_RAM_ORX_PHA_LOCK_WD__M 0xFFFF
7961#define SCU_RAM_ORX_PHA_LOCK_WD__PRE 0x0
7962
7963#define SCU_RAM_ORX_PHA_ONLOCK_TTH__A 0x831F30
7964#define SCU_RAM_ORX_PHA_ONLOCK_TTH__W 16
7965#define SCU_RAM_ORX_PHA_ONLOCK_TTH__M 0xFFFF
7966#define SCU_RAM_ORX_PHA_ONLOCK_TTH__PRE 0x0
7967
7968#define SCU_RAM_ORX_PHA_UNLOCK_TTH__A 0x831F31
7969#define SCU_RAM_ORX_PHA_UNLOCK_TTH__W 16
7970#define SCU_RAM_ORX_PHA_UNLOCK_TTH__M 0xFFFF
7971#define SCU_RAM_ORX_PHA_UNLOCK_TTH__PRE 0x0
7972
7973#define SCU_RAM_ORX_PHA_LOCK_TOTH__A 0x831F32
7974#define SCU_RAM_ORX_PHA_LOCK_TOTH__W 16
7975#define SCU_RAM_ORX_PHA_LOCK_TOTH__M 0xFFFF
7976#define SCU_RAM_ORX_PHA_LOCK_TOTH__PRE 0x0
7977
7978#define SCU_RAM_ORX_PHA_LOCK_MASK__A 0x831F33
7979#define SCU_RAM_ORX_PHA_LOCK_MASK__W 8
7980#define SCU_RAM_ORX_PHA_LOCK_MASK__M 0xFF
7981#define SCU_RAM_ORX_PHA_LOCK_MASK__PRE 0x0
7982
7983#define SCU_RAM_ORX_TIM_OFFSET__A 0x831F34
7984#define SCU_RAM_ORX_TIM_OFFSET__W 16
7985#define SCU_RAM_ORX_TIM_OFFSET__M 0xFFFF
7986#define SCU_RAM_ORX_TIM_OFFSET__PRE 0x0
7987
7988#define SCU_RAM_ORX_TIM_DIFF__A 0x831F35
7989#define SCU_RAM_ORX_TIM_DIFF__W 16
7990#define SCU_RAM_ORX_TIM_DIFF__M 0xFFFF
7991#define SCU_RAM_ORX_TIM_DIFF__PRE 0x0
7992
7993#define SCU_RAM_ORX_TIM_LOCK_TH__A 0x831F36
7994#define SCU_RAM_ORX_TIM_LOCK_TH__W 16
7995#define SCU_RAM_ORX_TIM_LOCK_TH__M 0xFFFF
7996#define SCU_RAM_ORX_TIM_LOCK_TH__PRE 0x0
7997
7998#define SCU_RAM_ORX_TIM_LOCK_WD__A 0x831F37
7999#define SCU_RAM_ORX_TIM_LOCK_WD__W 16
8000#define SCU_RAM_ORX_TIM_LOCK_WD__M 0xFFFF
8001#define SCU_RAM_ORX_TIM_LOCK_WD__PRE 0x0
8002
8003#define SCU_RAM_ORX_TIM_ONLOCK_TTH__A 0x831F38
8004#define SCU_RAM_ORX_TIM_ONLOCK_TTH__W 16
8005#define SCU_RAM_ORX_TIM_ONLOCK_TTH__M 0xFFFF
8006#define SCU_RAM_ORX_TIM_ONLOCK_TTH__PRE 0x0
8007
8008#define SCU_RAM_ORX_TIM_UNLOCK_TTH__A 0x831F39
8009#define SCU_RAM_ORX_TIM_UNLOCK_TTH__W 16
8010#define SCU_RAM_ORX_TIM_UNLOCK_TTH__M 0xFFFF
8011#define SCU_RAM_ORX_TIM_UNLOCK_TTH__PRE 0x0
8012
8013#define SCU_RAM_ORX_TIM_LOCK_TOTH__A 0x831F3A
8014#define SCU_RAM_ORX_TIM_LOCK_TOTH__W 16
8015#define SCU_RAM_ORX_TIM_LOCK_TOTH__M 0xFFFF
8016#define SCU_RAM_ORX_TIM_LOCK_TOTH__PRE 0x0
8017
8018#define SCU_RAM_ORX_TIM_LOCK_MASK__A 0x831F3B
8019#define SCU_RAM_ORX_TIM_LOCK_MASK__W 8
8020#define SCU_RAM_ORX_TIM_LOCK_MASK__M 0xFF
8021#define SCU_RAM_ORX_TIM_LOCK_MASK__PRE 0x0
8022
8023#define SCU_RAM_ORX_EQU_DIFF__A 0x831F3C
8024#define SCU_RAM_ORX_EQU_DIFF__W 16
8025#define SCU_RAM_ORX_EQU_DIFF__M 0xFFFF
8026#define SCU_RAM_ORX_EQU_DIFF__PRE 0x0
8027
8028#define SCU_RAM_ORX_EQU_LOCK_TH__A 0x831F3D
8029#define SCU_RAM_ORX_EQU_LOCK_TH__W 16
8030#define SCU_RAM_ORX_EQU_LOCK_TH__M 0xFFFF
8031#define SCU_RAM_ORX_EQU_LOCK_TH__PRE 0x0
8032
8033#define SCU_RAM_ORX_EQU_LOCK_WD__A 0x831F3E
8034#define SCU_RAM_ORX_EQU_LOCK_WD__W 16
8035#define SCU_RAM_ORX_EQU_LOCK_WD__M 0xFFFF
8036#define SCU_RAM_ORX_EQU_LOCK_WD__PRE 0x0
8037
8038#define SCU_RAM_ORX_EQU_ONLOCK_TTH__A 0x831F3F
8039#define SCU_RAM_ORX_EQU_ONLOCK_TTH__W 16
8040#define SCU_RAM_ORX_EQU_ONLOCK_TTH__M 0xFFFF
8041#define SCU_RAM_ORX_EQU_ONLOCK_TTH__PRE 0x0
8042
8043#define SCU_RAM_ORX_EQU_UNLOCK_TTH__A 0x831F40
8044#define SCU_RAM_ORX_EQU_UNLOCK_TTH__W 16
8045#define SCU_RAM_ORX_EQU_UNLOCK_TTH__M 0xFFFF
8046#define SCU_RAM_ORX_EQU_UNLOCK_TTH__PRE 0x0
8047
8048#define SCU_RAM_ORX_EQU_LOCK_TOTH__A 0x831F41
8049#define SCU_RAM_ORX_EQU_LOCK_TOTH__W 16
8050#define SCU_RAM_ORX_EQU_LOCK_TOTH__M 0xFFFF
8051#define SCU_RAM_ORX_EQU_LOCK_TOTH__PRE 0x0
8052
8053#define SCU_RAM_ORX_EQU_LOCK_MASK__A 0x831F42
8054#define SCU_RAM_ORX_EQU_LOCK_MASK__W 8
8055#define SCU_RAM_ORX_EQU_LOCK_MASK__M 0xFF
8056#define SCU_RAM_ORX_EQU_LOCK_MASK__PRE 0x0
8057
8058#define SCU_RAM_ORX_FLT_FRQ__A 0x831F43
8059#define SCU_RAM_ORX_FLT_FRQ__W 16
8060#define SCU_RAM_ORX_FLT_FRQ__M 0xFFFF
8061#define SCU_RAM_ORX_FLT_FRQ__PRE 0x0
8062#define SCU_RAM_ORX_RST_CPH__A 0x831F44
8063#define SCU_RAM_ORX_RST_CPH__W 4
8064#define SCU_RAM_ORX_RST_CPH__M 0xF
8065#define SCU_RAM_ORX_RST_CPH__PRE 0x0
8066
8067#define SCU_RAM_ORX_RST_CPH_RST_CPH__B 0
8068#define SCU_RAM_ORX_RST_CPH_RST_CPH__W 4
8069#define SCU_RAM_ORX_RST_CPH_RST_CPH__M 0xF
8070#define SCU_RAM_ORX_RST_CPH_RST_CPH__PRE 0x0
8071
8072#define SCU_RAM_ORX_RST_CTI__A 0x831F45
8073#define SCU_RAM_ORX_RST_CTI__W 4
8074#define SCU_RAM_ORX_RST_CTI__M 0xF
8075#define SCU_RAM_ORX_RST_CTI__PRE 0x0
8076
8077#define SCU_RAM_ORX_RST_CTI_RST_CTI__B 0
8078#define SCU_RAM_ORX_RST_CTI_RST_CTI__W 4
8079#define SCU_RAM_ORX_RST_CTI_RST_CTI__M 0xF
8080#define SCU_RAM_ORX_RST_CTI_RST_CTI__PRE 0x0
8081
8082#define SCU_RAM_ORX_RST_KRN__A 0x831F46
8083#define SCU_RAM_ORX_RST_KRN__W 4
8084#define SCU_RAM_ORX_RST_KRN__M 0xF
8085#define SCU_RAM_ORX_RST_KRN__PRE 0x0
8086
8087#define SCU_RAM_ORX_RST_KRN_RST_KRN__B 0
8088#define SCU_RAM_ORX_RST_KRN_RST_KRN__W 4
8089#define SCU_RAM_ORX_RST_KRN_RST_KRN__M 0xF
8090#define SCU_RAM_ORX_RST_KRN_RST_KRN__PRE 0x0
8091
8092#define SCU_RAM_ORX_RST_KRP__A 0x831F47
8093#define SCU_RAM_ORX_RST_KRP__W 4
8094#define SCU_RAM_ORX_RST_KRP__M 0xF
8095#define SCU_RAM_ORX_RST_KRP__PRE 0x0
8096
8097#define SCU_RAM_ORX_RST_KRP_RST_KRP__B 0
8098#define SCU_RAM_ORX_RST_KRP_RST_KRP__W 4
8099#define SCU_RAM_ORX_RST_KRP_RST_KRP__M 0xF
8100#define SCU_RAM_ORX_RST_KRP_RST_KRP__PRE 0x0
8101
8102#define SCU_RAM_ATV_STANDARD__A 0x831F48
8103#define SCU_RAM_ATV_STANDARD__W 12
8104#define SCU_RAM_ATV_STANDARD__M 0xFFF
8105#define SCU_RAM_ATV_STANDARD__PRE 0x0
8106
8107#define SCU_RAM_ATV_STANDARD_STANDARD__B 0
8108#define SCU_RAM_ATV_STANDARD_STANDARD__W 12
8109#define SCU_RAM_ATV_STANDARD_STANDARD__M 0xFFF
8110#define SCU_RAM_ATV_STANDARD_STANDARD__PRE 0x0
8111#define SCU_RAM_ATV_STANDARD_STANDARD_MN 0x2
8112#define SCU_RAM_ATV_STANDARD_STANDARD_B 0x103
8113#define SCU_RAM_ATV_STANDARD_STANDARD_G 0x3
8114#define SCU_RAM_ATV_STANDARD_STANDARD_DK 0x4
8115#define SCU_RAM_ATV_STANDARD_STANDARD_L 0x9
8116#define SCU_RAM_ATV_STANDARD_STANDARD_LP 0x109
8117#define SCU_RAM_ATV_STANDARD_STANDARD_I 0xA
8118#define SCU_RAM_ATV_STANDARD_STANDARD_FM 0x40
8119
8120#define SCU_RAM_ATV_DETECT__A 0x831F49
8121#define SCU_RAM_ATV_DETECT__W 1
8122#define SCU_RAM_ATV_DETECT__M 0x1
8123#define SCU_RAM_ATV_DETECT__PRE 0x0
8124
8125#define SCU_RAM_ATV_DETECT_DETECT__B 0
8126#define SCU_RAM_ATV_DETECT_DETECT__W 1
8127#define SCU_RAM_ATV_DETECT_DETECT__M 0x1
8128#define SCU_RAM_ATV_DETECT_DETECT__PRE 0x0
8129#define SCU_RAM_ATV_DETECT_DETECT_false 0x0
8130#define SCU_RAM_ATV_DETECT_DETECT_true 0x1
8131
8132#define SCU_RAM_ATV_DETECT_TH__A 0x831F4A
8133#define SCU_RAM_ATV_DETECT_TH__W 8
8134#define SCU_RAM_ATV_DETECT_TH__M 0xFF
8135#define SCU_RAM_ATV_DETECT_TH__PRE 0x0
8136
8137#define SCU_RAM_ATV_DETECT_TH_DETECT_TH__B 0
8138#define SCU_RAM_ATV_DETECT_TH_DETECT_TH__W 8
8139#define SCU_RAM_ATV_DETECT_TH_DETECT_TH__M 0xFF
8140#define SCU_RAM_ATV_DETECT_TH_DETECT_TH__PRE 0x0
8141
8142#define SCU_RAM_ATV_LOCK__A 0x831F4B
8143#define SCU_RAM_ATV_LOCK__W 2
8144#define SCU_RAM_ATV_LOCK__M 0x3
8145#define SCU_RAM_ATV_LOCK__PRE 0x0
8146
8147#define SCU_RAM_ATV_LOCK_CR_LOCK_BIT__B 0
8148#define SCU_RAM_ATV_LOCK_CR_LOCK_BIT__W 1
8149#define SCU_RAM_ATV_LOCK_CR_LOCK_BIT__M 0x1
8150#define SCU_RAM_ATV_LOCK_CR_LOCK_BIT__PRE 0x0
8151#define SCU_RAM_ATV_LOCK_CR_LOCK_BIT_NO_LOCK 0x0
8152#define SCU_RAM_ATV_LOCK_CR_LOCK_BIT_LOCK 0x1
8153
8154#define SCU_RAM_ATV_LOCK_SYNC_FLAG__B 1
8155#define SCU_RAM_ATV_LOCK_SYNC_FLAG__W 1
8156#define SCU_RAM_ATV_LOCK_SYNC_FLAG__M 0x2
8157#define SCU_RAM_ATV_LOCK_SYNC_FLAG__PRE 0x0
8158#define SCU_RAM_ATV_LOCK_SYNC_FLAG_NO_SYNC 0x0
8159#define SCU_RAM_ATV_LOCK_SYNC_FLAG_SYNC 0x2
8160
8161#define SCU_RAM_ATV_CR_LOCK__A 0x831F4C
8162#define SCU_RAM_ATV_CR_LOCK__W 11
8163#define SCU_RAM_ATV_CR_LOCK__M 0x7FF
8164#define SCU_RAM_ATV_CR_LOCK__PRE 0x0
8165
8166#define SCU_RAM_ATV_CR_LOCK_CR_LOCK__B 0
8167#define SCU_RAM_ATV_CR_LOCK_CR_LOCK__W 11
8168#define SCU_RAM_ATV_CR_LOCK_CR_LOCK__M 0x7FF
8169#define SCU_RAM_ATV_CR_LOCK_CR_LOCK__PRE 0x0
8170
8171#define SCU_RAM_ATV_AGC_MODE__A 0x831F4D
8172#define SCU_RAM_ATV_AGC_MODE__W 8
8173#define SCU_RAM_ATV_AGC_MODE__M 0xFF
8174#define SCU_RAM_ATV_AGC_MODE__PRE 0x0
8175
8176#define SCU_RAM_ATV_AGC_MODE_VAGC_VEL__B 2
8177#define SCU_RAM_ATV_AGC_MODE_VAGC_VEL__W 1
8178#define SCU_RAM_ATV_AGC_MODE_VAGC_VEL__M 0x4
8179#define SCU_RAM_ATV_AGC_MODE_VAGC_VEL__PRE 0x0
8180#define SCU_RAM_ATV_AGC_MODE_VAGC_VEL_AGC_FAST 0x0
8181#define SCU_RAM_ATV_AGC_MODE_VAGC_VEL_AGC_SLOW 0x4
8182
8183#define SCU_RAM_ATV_AGC_MODE_BP_EN__B 3
8184#define SCU_RAM_ATV_AGC_MODE_BP_EN__W 1
8185#define SCU_RAM_ATV_AGC_MODE_BP_EN__M 0x8
8186#define SCU_RAM_ATV_AGC_MODE_BP_EN__PRE 0x0
8187#define SCU_RAM_ATV_AGC_MODE_BP_EN_BPC_DISABLE 0x0
8188#define SCU_RAM_ATV_AGC_MODE_BP_EN_BPC_ENABLE 0x8
8189
8190#define SCU_RAM_ATV_AGC_MODE_SIF_STD__B 4
8191#define SCU_RAM_ATV_AGC_MODE_SIF_STD__W 2
8192#define SCU_RAM_ATV_AGC_MODE_SIF_STD__M 0x30
8193#define SCU_RAM_ATV_AGC_MODE_SIF_STD__PRE 0x0
8194#define SCU_RAM_ATV_AGC_MODE_SIF_STD_SIF_AGC_OFF 0x0
8195#define SCU_RAM_ATV_AGC_MODE_SIF_STD_SIF_AGC_FM 0x10
8196#define SCU_RAM_ATV_AGC_MODE_SIF_STD_SIF_AGC_AM 0x20
8197
8198#define SCU_RAM_ATV_AGC_MODE_FAST_VAGC_EN__B 6
8199#define SCU_RAM_ATV_AGC_MODE_FAST_VAGC_EN__W 1
8200#define SCU_RAM_ATV_AGC_MODE_FAST_VAGC_EN__M 0x40
8201#define SCU_RAM_ATV_AGC_MODE_FAST_VAGC_EN__PRE 0x0
8202#define SCU_RAM_ATV_AGC_MODE_FAST_VAGC_EN_FAGC_DISABLE 0x0
8203#define SCU_RAM_ATV_AGC_MODE_FAST_VAGC_EN_FAGC_ENABLE 0x40
8204
8205#define SCU_RAM_ATV_AGC_MODE_MOD_WA_BP__B 7
8206#define SCU_RAM_ATV_AGC_MODE_MOD_WA_BP__W 1
8207#define SCU_RAM_ATV_AGC_MODE_MOD_WA_BP__M 0x80
8208#define SCU_RAM_ATV_AGC_MODE_MOD_WA_BP__PRE 0x0
8209#define SCU_RAM_ATV_AGC_MODE_MOD_WA_BP_MWA_ENABLE 0x0
8210#define SCU_RAM_ATV_AGC_MODE_MOD_WA_BP_MWA_DISABLE 0x80
8211
8212#define SCU_RAM_ATV_RSV_01__A 0x831F4E
8213#define SCU_RAM_ATV_RSV_01__W 16
8214#define SCU_RAM_ATV_RSV_01__M 0xFFFF
8215#define SCU_RAM_ATV_RSV_01__PRE 0x0
8216
8217#define SCU_RAM_ATV_RSV_02__A 0x831F4F
8218#define SCU_RAM_ATV_RSV_02__W 16
8219#define SCU_RAM_ATV_RSV_02__M 0xFFFF
8220#define SCU_RAM_ATV_RSV_02__PRE 0x0
8221
8222#define SCU_RAM_ATV_RSV_03__A 0x831F50
8223#define SCU_RAM_ATV_RSV_03__W 16
8224#define SCU_RAM_ATV_RSV_03__M 0xFFFF
8225#define SCU_RAM_ATV_RSV_03__PRE 0x0
8226
8227#define SCU_RAM_ATV_RSV_04__A 0x831F51
8228#define SCU_RAM_ATV_RSV_04__W 16
8229#define SCU_RAM_ATV_RSV_04__M 0xFFFF
8230#define SCU_RAM_ATV_RSV_04__PRE 0x0
8231#define SCU_RAM_ATV_FAGC_TH_RED__A 0x831F52
8232#define SCU_RAM_ATV_FAGC_TH_RED__W 8
8233#define SCU_RAM_ATV_FAGC_TH_RED__M 0xFF
8234#define SCU_RAM_ATV_FAGC_TH_RED__PRE 0x0
8235
8236#define SCU_RAM_ATV_FAGC_TH_RED_FAGC_TH_RED__B 0
8237#define SCU_RAM_ATV_FAGC_TH_RED_FAGC_TH_RED__W 8
8238#define SCU_RAM_ATV_FAGC_TH_RED_FAGC_TH_RED__M 0xFF
8239#define SCU_RAM_ATV_FAGC_TH_RED_FAGC_TH_RED__PRE 0x0
8240
8241#define SCU_RAM_ATV_AMS_MAX_REF__A 0x831F53
8242#define SCU_RAM_ATV_AMS_MAX_REF__W 11
8243#define SCU_RAM_ATV_AMS_MAX_REF__M 0x7FF
8244#define SCU_RAM_ATV_AMS_MAX_REF__PRE 0x0
8245
8246#define SCU_RAM_ATV_AMS_MAX_REF_AMS_MAX_REF__B 0
8247#define SCU_RAM_ATV_AMS_MAX_REF_AMS_MAX_REF__W 11
8248#define SCU_RAM_ATV_AMS_MAX_REF_AMS_MAX_REF__M 0x7FF
8249#define SCU_RAM_ATV_AMS_MAX_REF_AMS_MAX_REF__PRE 0x0
8250#define SCU_RAM_ATV_AMS_MAX_REF_AMS_MAX_REF_BG_MN 0x2BC
8251#define SCU_RAM_ATV_AMS_MAX_REF_AMS_MAX_REF_DK 0x2D0
8252#define SCU_RAM_ATV_AMS_MAX_REF_AMS_MAX_REF_I 0x314
8253#define SCU_RAM_ATV_AMS_MAX_REF_AMS_MAX_REF_LLP 0x28A
8254
8255#define SCU_RAM_ATV_ACT_AMX__A 0x831F54
8256#define SCU_RAM_ATV_ACT_AMX__W 11
8257#define SCU_RAM_ATV_ACT_AMX__M 0x7FF
8258#define SCU_RAM_ATV_ACT_AMX__PRE 0x0
8259
8260#define SCU_RAM_ATV_ACT_AMX_ACT_AMX__B 0
8261#define SCU_RAM_ATV_ACT_AMX_ACT_AMX__W 11
8262#define SCU_RAM_ATV_ACT_AMX_ACT_AMX__M 0x7FF
8263#define SCU_RAM_ATV_ACT_AMX_ACT_AMX__PRE 0x0
8264
8265#define SCU_RAM_ATV_ACT_AMI__A 0x831F55
8266#define SCU_RAM_ATV_ACT_AMI__W 11
8267#define SCU_RAM_ATV_ACT_AMI__M 0x7FF
8268#define SCU_RAM_ATV_ACT_AMI__PRE 0x0
8269
8270#define SCU_RAM_ATV_ACT_AMI_ACT_AMI__B 0
8271#define SCU_RAM_ATV_ACT_AMI_ACT_AMI__W 11
8272#define SCU_RAM_ATV_ACT_AMI_ACT_AMI__M 0x7FF
8273#define SCU_RAM_ATV_ACT_AMI_ACT_AMI__PRE 0x0
8274
8275#define SCU_RAM_ATV_RSV_05__A 0x831F56
8276#define SCU_RAM_ATV_RSV_05__W 16
8277#define SCU_RAM_ATV_RSV_05__M 0xFFFF
8278#define SCU_RAM_ATV_RSV_05__PRE 0x0
8279
8280#define SCU_RAM_ATV_RSV_06__A 0x831F57
8281#define SCU_RAM_ATV_RSV_06__W 16
8282#define SCU_RAM_ATV_RSV_06__M 0xFFFF
8283#define SCU_RAM_ATV_RSV_06__PRE 0x0
8284
8285#define SCU_RAM_ATV_RSV_07__A 0x831F58
8286#define SCU_RAM_ATV_RSV_07__W 16
8287#define SCU_RAM_ATV_RSV_07__M 0xFFFF
8288#define SCU_RAM_ATV_RSV_07__PRE 0x0
8289
8290#define SCU_RAM_ATV_RSV_08__A 0x831F59
8291#define SCU_RAM_ATV_RSV_08__W 16
8292#define SCU_RAM_ATV_RSV_08__M 0xFFFF
8293#define SCU_RAM_ATV_RSV_08__PRE 0x0
8294
8295#define SCU_RAM_ATV_RSV_09__A 0x831F5A
8296#define SCU_RAM_ATV_RSV_09__W 16
8297#define SCU_RAM_ATV_RSV_09__M 0xFFFF
8298#define SCU_RAM_ATV_RSV_09__PRE 0x0
8299
8300#define SCU_RAM_ATV_RSV_10__A 0x831F5B
8301#define SCU_RAM_ATV_RSV_10__W 16
8302#define SCU_RAM_ATV_RSV_10__M 0xFFFF
8303#define SCU_RAM_ATV_RSV_10__PRE 0x0
8304
8305#define SCU_RAM_ATV_RSV_11__A 0x831F5C
8306#define SCU_RAM_ATV_RSV_11__W 16
8307#define SCU_RAM_ATV_RSV_11__M 0xFFFF
8308#define SCU_RAM_ATV_RSV_11__PRE 0x0
8309
8310#define SCU_RAM_ATV_RSV_12__A 0x831F5D
8311#define SCU_RAM_ATV_RSV_12__W 16
8312#define SCU_RAM_ATV_RSV_12__M 0xFFFF
8313#define SCU_RAM_ATV_RSV_12__PRE 0x0
8314#define SCU_RAM_ATV_VID_GAIN_HI__A 0x831F5E
8315#define SCU_RAM_ATV_VID_GAIN_HI__W 16
8316#define SCU_RAM_ATV_VID_GAIN_HI__M 0xFFFF
8317#define SCU_RAM_ATV_VID_GAIN_HI__PRE 0x0
8318
8319#define SCU_RAM_ATV_VID_GAIN_HI_VID_GAIN_HI__B 0
8320#define SCU_RAM_ATV_VID_GAIN_HI_VID_GAIN_HI__W 16
8321#define SCU_RAM_ATV_VID_GAIN_HI_VID_GAIN_HI__M 0xFFFF
8322#define SCU_RAM_ATV_VID_GAIN_HI_VID_GAIN_HI__PRE 0x0
8323
8324#define SCU_RAM_ATV_VID_GAIN_LO__A 0x831F5F
8325#define SCU_RAM_ATV_VID_GAIN_LO__W 8
8326#define SCU_RAM_ATV_VID_GAIN_LO__M 0xFF
8327#define SCU_RAM_ATV_VID_GAIN_LO__PRE 0x0
8328
8329#define SCU_RAM_ATV_VID_GAIN_LO_VID_GAIN_LO__B 0
8330#define SCU_RAM_ATV_VID_GAIN_LO_VID_GAIN_LO__W 8
8331#define SCU_RAM_ATV_VID_GAIN_LO_VID_GAIN_LO__M 0xFF
8332#define SCU_RAM_ATV_VID_GAIN_LO_VID_GAIN_LO__PRE 0x0
8333
8334#define SCU_RAM_ATV_RSV_13__A 0x831F60
8335#define SCU_RAM_ATV_RSV_13__W 16
8336#define SCU_RAM_ATV_RSV_13__M 0xFFFF
8337#define SCU_RAM_ATV_RSV_13__PRE 0x0
8338
8339#define SCU_RAM_ATV_RSV_14__A 0x831F61
8340#define SCU_RAM_ATV_RSV_14__W 16
8341#define SCU_RAM_ATV_RSV_14__M 0xFFFF
8342#define SCU_RAM_ATV_RSV_14__PRE 0x0
8343
8344#define SCU_RAM_ATV_RSV_15__A 0x831F62
8345#define SCU_RAM_ATV_RSV_15__W 16
8346#define SCU_RAM_ATV_RSV_15__M 0xFFFF
8347#define SCU_RAM_ATV_RSV_15__PRE 0x0
8348
8349#define SCU_RAM_ATV_RSV_16__A 0x831F63
8350#define SCU_RAM_ATV_RSV_16__W 16
8351#define SCU_RAM_ATV_RSV_16__M 0xFFFF
8352#define SCU_RAM_ATV_RSV_16__PRE 0x0
8353#define SCU_RAM_ATV_AAGC_CNT__A 0x831F64
8354#define SCU_RAM_ATV_AAGC_CNT__W 8
8355#define SCU_RAM_ATV_AAGC_CNT__M 0xFF
8356#define SCU_RAM_ATV_AAGC_CNT__PRE 0x0
8357
8358#define SCU_RAM_ATV_AAGC_CNT_AAGC_CNT__B 0
8359#define SCU_RAM_ATV_AAGC_CNT_AAGC_CNT__W 8
8360#define SCU_RAM_ATV_AAGC_CNT_AAGC_CNT__M 0xFF
8361#define SCU_RAM_ATV_AAGC_CNT_AAGC_CNT__PRE 0x0
8362
8363#define SCU_RAM_ATV_SIF_GAIN__A 0x831F65
8364#define SCU_RAM_ATV_SIF_GAIN__W 11
8365#define SCU_RAM_ATV_SIF_GAIN__M 0x7FF
8366#define SCU_RAM_ATV_SIF_GAIN__PRE 0x0
8367
8368#define SCU_RAM_ATV_SIF_GAIN_SIF_GAIN__B 0
8369#define SCU_RAM_ATV_SIF_GAIN_SIF_GAIN__W 11
8370#define SCU_RAM_ATV_SIF_GAIN_SIF_GAIN__M 0x7FF
8371#define SCU_RAM_ATV_SIF_GAIN_SIF_GAIN__PRE 0x0
8372
8373#define SCU_RAM_ATV_RSV_17__A 0x831F66
8374#define SCU_RAM_ATV_RSV_17__W 16
8375#define SCU_RAM_ATV_RSV_17__M 0xFFFF
8376#define SCU_RAM_ATV_RSV_17__PRE 0x0
8377
8378#define SCU_RAM_ATV_RSV_18__A 0x831F67
8379#define SCU_RAM_ATV_RSV_18__W 16
8380#define SCU_RAM_ATV_RSV_18__M 0xFFFF
8381#define SCU_RAM_ATV_RSV_18__PRE 0x0
8382
8383#define SCU_RAM_ATV_RATE_OFS__A 0x831F68
8384#define SCU_RAM_ATV_RATE_OFS__W 12
8385#define SCU_RAM_ATV_RATE_OFS__M 0xFFF
8386#define SCU_RAM_ATV_RATE_OFS__PRE 0x0
8387
8388#define SCU_RAM_ATV_LO_INCR__A 0x831F69
8389#define SCU_RAM_ATV_LO_INCR__W 12
8390#define SCU_RAM_ATV_LO_INCR__M 0xFFF
8391#define SCU_RAM_ATV_LO_INCR__PRE 0x0
8392
8393#define SCU_RAM_ATV_IIR_CRIT__A 0x831F6A
8394#define SCU_RAM_ATV_IIR_CRIT__W 12
8395#define SCU_RAM_ATV_IIR_CRIT__M 0xFFF
8396#define SCU_RAM_ATV_IIR_CRIT__PRE 0x0
8397
8398#define SCU_RAM_ATV_DEF_RATE_OFS__A 0x831F6B
8399#define SCU_RAM_ATV_DEF_RATE_OFS__W 12
8400#define SCU_RAM_ATV_DEF_RATE_OFS__M 0xFFF
8401#define SCU_RAM_ATV_DEF_RATE_OFS__PRE 0x0
8402
8403#define SCU_RAM_ATV_DEF_LO_INCR__A 0x831F6C
8404#define SCU_RAM_ATV_DEF_LO_INCR__W 12
8405#define SCU_RAM_ATV_DEF_LO_INCR__M 0xFFF
8406#define SCU_RAM_ATV_DEF_LO_INCR__PRE 0x0
8407
8408#define SCU_RAM_ATV_ENABLE_IIR_WA__A 0x831F6D
8409#define SCU_RAM_ATV_ENABLE_IIR_WA__W 1
8410#define SCU_RAM_ATV_ENABLE_IIR_WA__M 0x1
8411#define SCU_RAM_ATV_ENABLE_IIR_WA__PRE 0x0
8412
8413#define SCU_RAM_ATV_MOD_CONTROL__A 0x831F6E
8414#define SCU_RAM_ATV_MOD_CONTROL__W 12
8415#define SCU_RAM_ATV_MOD_CONTROL__M 0xFFF
8416#define SCU_RAM_ATV_MOD_CONTROL__PRE 0x0
8417
8418#define SCU_RAM_ATV_PAGC_KI_MAX__A 0x831F6F
8419#define SCU_RAM_ATV_PAGC_KI_MAX__W 12
8420#define SCU_RAM_ATV_PAGC_KI_MAX__M 0xFFF
8421#define SCU_RAM_ATV_PAGC_KI_MAX__PRE 0x0
8422
8423#define SCU_RAM_ATV_BPC_KI_MAX__A 0x831F70
8424#define SCU_RAM_ATV_BPC_KI_MAX__W 12
8425#define SCU_RAM_ATV_BPC_KI_MAX__M 0xFFF
8426#define SCU_RAM_ATV_BPC_KI_MAX__PRE 0x0
8427
8428#define SCU_RAM_ATV_NAGC_KI_MAX__A 0x831F71
8429#define SCU_RAM_ATV_NAGC_KI_MAX__W 12
8430#define SCU_RAM_ATV_NAGC_KI_MAX__M 0xFFF
8431#define SCU_RAM_ATV_NAGC_KI_MAX__PRE 0x0
8432#define SCU_RAM_ATV_NAGC_KI_MIN__A 0x831F72
8433#define SCU_RAM_ATV_NAGC_KI_MIN__W 12
8434#define SCU_RAM_ATV_NAGC_KI_MIN__M 0xFFF
8435#define SCU_RAM_ATV_NAGC_KI_MIN__PRE 0x0
8436
8437#define SCU_RAM_ATV_NAGC_KI_MIN_NAGC_KI_MIN__B 0
8438#define SCU_RAM_ATV_NAGC_KI_MIN_NAGC_KI_MIN__W 12
8439#define SCU_RAM_ATV_NAGC_KI_MIN_NAGC_KI_MIN__M 0xFFF
8440#define SCU_RAM_ATV_NAGC_KI_MIN_NAGC_KI_MIN__PRE 0x0
8441
8442#define SCU_RAM_ATV_KI_CHANGE_TH__A 0x831F73
8443#define SCU_RAM_ATV_KI_CHANGE_TH__W 8
8444#define SCU_RAM_ATV_KI_CHANGE_TH__M 0xFF
8445#define SCU_RAM_ATV_KI_CHANGE_TH__PRE 0x0
8446
8447#define SCU_RAM_ATV_KI_CHANGE_TH_KI_CHANGE_TH__B 0
8448#define SCU_RAM_ATV_KI_CHANGE_TH_KI_CHANGE_TH__W 8
8449#define SCU_RAM_ATV_KI_CHANGE_TH_KI_CHANGE_TH__M 0xFF
8450#define SCU_RAM_ATV_KI_CHANGE_TH_KI_CHANGE_TH__PRE 0x0
8451#define SCU_RAM_ATV_KI_CHANGE_TH_KI_CHANGE_TH_NEG_MOD 0x14
8452#define SCU_RAM_ATV_KI_CHANGE_TH_KI_CHANGE_TH_POS_MOD 0x28
8453
8454#define SCU_RAM_QAM_PARAM_ANNEX__A 0x831F74
8455#define SCU_RAM_QAM_PARAM_ANNEX__W 2
8456#define SCU_RAM_QAM_PARAM_ANNEX__M 0x3
8457#define SCU_RAM_QAM_PARAM_ANNEX__PRE 0x0
8458
8459#define SCU_RAM_QAM_PARAM_ANNEX_BIT__B 0
8460#define SCU_RAM_QAM_PARAM_ANNEX_BIT__W 2
8461#define SCU_RAM_QAM_PARAM_ANNEX_BIT__M 0x3
8462#define SCU_RAM_QAM_PARAM_ANNEX_BIT__PRE 0x0
8463#define SCU_RAM_QAM_PARAM_ANNEX_BIT_ANNEX_A 0x0
8464#define SCU_RAM_QAM_PARAM_ANNEX_BIT_ANNEX_B 0x1
8465#define SCU_RAM_QAM_PARAM_ANNEX_BIT_ANNEX_C 0x2
8466#define SCU_RAM_QAM_PARAM_ANNEX_BIT_ANNEX_D 0x3
8467
8468#define SCU_RAM_QAM_PARAM_CONSTELLATION__A 0x831F75
8469#define SCU_RAM_QAM_PARAM_CONSTELLATION__W 3
8470#define SCU_RAM_QAM_PARAM_CONSTELLATION__M 0x7
8471#define SCU_RAM_QAM_PARAM_CONSTELLATION__PRE 0x0
8472
8473#define SCU_RAM_QAM_PARAM_CONSTELLATION_BIT__B 0
8474#define SCU_RAM_QAM_PARAM_CONSTELLATION_BIT__W 3
8475#define SCU_RAM_QAM_PARAM_CONSTELLATION_BIT__M 0x7
8476#define SCU_RAM_QAM_PARAM_CONSTELLATION_BIT__PRE 0x0
8477#define SCU_RAM_QAM_PARAM_CONSTELLATION_BIT_UNKNOWN 0x0
8478#define SCU_RAM_QAM_PARAM_CONSTELLATION_BIT_QAM_16 0x3
8479#define SCU_RAM_QAM_PARAM_CONSTELLATION_BIT_QAM_32 0x4
8480#define SCU_RAM_QAM_PARAM_CONSTELLATION_BIT_QAM_64 0x5
8481#define SCU_RAM_QAM_PARAM_CONSTELLATION_BIT_QAM_128 0x6
8482#define SCU_RAM_QAM_PARAM_CONSTELLATION_BIT_QAM_256 0x7
8483
8484#define SCU_RAM_QAM_PARAM_INTERLEAVE__A 0x831F76
8485#define SCU_RAM_QAM_PARAM_INTERLEAVE__W 8
8486#define SCU_RAM_QAM_PARAM_INTERLEAVE__M 0xFF
8487#define SCU_RAM_QAM_PARAM_INTERLEAVE__PRE 0x0
8488
8489#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT__B 0
8490#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT__W 8
8491#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT__M 0xFF
8492#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT__PRE 0x0
8493#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I128_J1 0x0
8494#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I128_J1_V2 0x1
8495#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I128_J2 0x2
8496#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I64_J2 0x3
8497#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I128_J3 0x4
8498#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I32_J4 0x5
8499#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I128_J4 0x6
8500#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I16_J8 0x7
8501#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I128_J5 0x8
8502#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I8_J16 0x9
8503#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I128_J6 0xA
8504#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I128_J7 0xC
8505#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I128_J8 0xE
8506#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I12_J17 0x10
8507#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_I5_J4 0x11
8508#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_UNKNOWN 0xFE
8509#define SCU_RAM_QAM_PARAM_INTERLEAVE_BIT_AUTO 0xFF
8510
8511#define SCU_RAM_QAM_PARAM_SYM_RCRATE_HI__A 0x831F77
8512#define SCU_RAM_QAM_PARAM_SYM_RCRATE_HI__W 16
8513#define SCU_RAM_QAM_PARAM_SYM_RCRATE_HI__M 0xFFFF
8514#define SCU_RAM_QAM_PARAM_SYM_RCRATE_HI__PRE 0x0
8515
8516#define SCU_RAM_QAM_PARAM_SYM_RCRATE_HI_BIT__B 0
8517#define SCU_RAM_QAM_PARAM_SYM_RCRATE_HI_BIT__W 16
8518#define SCU_RAM_QAM_PARAM_SYM_RCRATE_HI_BIT__M 0xFFFF
8519#define SCU_RAM_QAM_PARAM_SYM_RCRATE_HI_BIT__PRE 0x0
8520
8521#define SCU_RAM_QAM_PARAM_SYM_RCRATE_LO__A 0x831F78
8522#define SCU_RAM_QAM_PARAM_SYM_RCRATE_LO__W 16
8523#define SCU_RAM_QAM_PARAM_SYM_RCRATE_LO__M 0xFFFF
8524#define SCU_RAM_QAM_PARAM_SYM_RCRATE_LO__PRE 0x0
8525
8526#define SCU_RAM_QAM_PARAM_SYM_RCRATE_LO_BIT__B 0
8527#define SCU_RAM_QAM_PARAM_SYM_RCRATE_LO_BIT__W 16
8528#define SCU_RAM_QAM_PARAM_SYM_RCRATE_LO_BIT__M 0xFFFF
8529#define SCU_RAM_QAM_PARAM_SYM_RCRATE_LO_BIT__PRE 0x0
8530
8531#define SCU_RAM_QAM_EQ_CENTERTAP__A 0x831F79
8532#define SCU_RAM_QAM_EQ_CENTERTAP__W 16
8533#define SCU_RAM_QAM_EQ_CENTERTAP__M 0xFFFF
8534#define SCU_RAM_QAM_EQ_CENTERTAP__PRE 0x0
8535
8536#define SCU_RAM_QAM_EQ_CENTERTAP_BIT__B 0
8537#define SCU_RAM_QAM_EQ_CENTERTAP_BIT__W 8
8538#define SCU_RAM_QAM_EQ_CENTERTAP_BIT__M 0xFF
8539#define SCU_RAM_QAM_EQ_CENTERTAP_BIT__PRE 0x0
8540
8541#define SCU_RAM_QAM_WR_RSV_0__A 0x831F7A
8542#define SCU_RAM_QAM_WR_RSV_0__W 16
8543#define SCU_RAM_QAM_WR_RSV_0__M 0xFFFF
8544#define SCU_RAM_QAM_WR_RSV_0__PRE 0x0
8545
8546#define SCU_RAM_QAM_WR_RSV_0_BIT__B 0
8547#define SCU_RAM_QAM_WR_RSV_0_BIT__W 16
8548#define SCU_RAM_QAM_WR_RSV_0_BIT__M 0xFFFF
8549#define SCU_RAM_QAM_WR_RSV_0_BIT__PRE 0x0
8550
8551#define SCU_RAM_QAM_PARAM_ALT_RCRATE_HI__A 0x831F7B
8552#define SCU_RAM_QAM_PARAM_ALT_RCRATE_HI__W 16
8553#define SCU_RAM_QAM_PARAM_ALT_RCRATE_HI__M 0xFFFF
8554#define SCU_RAM_QAM_PARAM_ALT_RCRATE_HI__PRE 0x0
8555
8556#define SCU_RAM_QAM_PARAM_ALT_RCRATE_HI_BIT__B 0
8557#define SCU_RAM_QAM_PARAM_ALT_RCRATE_HI_BIT__W 16
8558#define SCU_RAM_QAM_PARAM_ALT_RCRATE_HI_BIT__M 0xFFFF
8559#define SCU_RAM_QAM_PARAM_ALT_RCRATE_HI_BIT__PRE 0x0
8560
8561#define SCU_RAM_QAM_PARAM_ALT_RCRATE_LO__A 0x831F7C
8562#define SCU_RAM_QAM_PARAM_ALT_RCRATE_LO__W 16
8563#define SCU_RAM_QAM_PARAM_ALT_RCRATE_LO__M 0xFFFF
8564#define SCU_RAM_QAM_PARAM_ALT_RCRATE_LO__PRE 0x0
8565
8566#define SCU_RAM_QAM_PARAM_ALT_RCRATE_LO_BIT__B 0
8567#define SCU_RAM_QAM_PARAM_ALT_RCRATE_LO_BIT__W 16
8568#define SCU_RAM_QAM_PARAM_ALT_RCRATE_LO_BIT__M 0xFFFF
8569#define SCU_RAM_QAM_PARAM_ALT_RCRATE_LO_BIT__PRE 0x0
8570
8571#define SCU_RAM_QAM_WR_RSV_5__A 0x831F7D
8572#define SCU_RAM_QAM_WR_RSV_5__W 16
8573#define SCU_RAM_QAM_WR_RSV_5__M 0xFFFF
8574#define SCU_RAM_QAM_WR_RSV_5__PRE 0x0
8575
8576#define SCU_RAM_QAM_WR_RSV_5_BIT__B 0
8577#define SCU_RAM_QAM_WR_RSV_5_BIT__W 16
8578#define SCU_RAM_QAM_WR_RSV_5_BIT__M 0xFFFF
8579#define SCU_RAM_QAM_WR_RSV_5_BIT__PRE 0x0
8580
8581#define SCU_RAM_QAM_WR_RSV_6__A 0x831F7E
8582#define SCU_RAM_QAM_WR_RSV_6__W 16
8583#define SCU_RAM_QAM_WR_RSV_6__M 0xFFFF
8584#define SCU_RAM_QAM_WR_RSV_6__PRE 0x0
8585
8586#define SCU_RAM_QAM_WR_RSV_6_BIT__B 0
8587#define SCU_RAM_QAM_WR_RSV_6_BIT__W 16
8588#define SCU_RAM_QAM_WR_RSV_6_BIT__M 0xFFFF
8589#define SCU_RAM_QAM_WR_RSV_6_BIT__PRE 0x0
8590
8591#define SCU_RAM_QAM_WR_RSV_7__A 0x831F7F
8592#define SCU_RAM_QAM_WR_RSV_7__W 16
8593#define SCU_RAM_QAM_WR_RSV_7__M 0xFFFF
8594#define SCU_RAM_QAM_WR_RSV_7__PRE 0x0
8595
8596#define SCU_RAM_QAM_WR_RSV_7_BIT__B 0
8597#define SCU_RAM_QAM_WR_RSV_7_BIT__W 16
8598#define SCU_RAM_QAM_WR_RSV_7_BIT__M 0xFFFF
8599#define SCU_RAM_QAM_WR_RSV_7_BIT__PRE 0x0
8600
8601#define SCU_RAM_QAM_WR_RSV_8__A 0x831F80
8602#define SCU_RAM_QAM_WR_RSV_8__W 16
8603#define SCU_RAM_QAM_WR_RSV_8__M 0xFFFF
8604#define SCU_RAM_QAM_WR_RSV_8__PRE 0x0
8605
8606#define SCU_RAM_QAM_WR_RSV_8_BIT__B 0
8607#define SCU_RAM_QAM_WR_RSV_8_BIT__W 16
8608#define SCU_RAM_QAM_WR_RSV_8_BIT__M 0xFFFF
8609#define SCU_RAM_QAM_WR_RSV_8_BIT__PRE 0x0
8610
8611#define SCU_RAM_QAM_WR_RSV_9__A 0x831F81
8612#define SCU_RAM_QAM_WR_RSV_9__W 16
8613#define SCU_RAM_QAM_WR_RSV_9__M 0xFFFF
8614#define SCU_RAM_QAM_WR_RSV_9__PRE 0x0
8615
8616#define SCU_RAM_QAM_WR_RSV_9_BIT__B 0
8617#define SCU_RAM_QAM_WR_RSV_9_BIT__W 16
8618#define SCU_RAM_QAM_WR_RSV_9_BIT__M 0xFFFF
8619#define SCU_RAM_QAM_WR_RSV_9_BIT__PRE 0x0
8620
8621#define SCU_RAM_QAM_WR_RSV_10__A 0x831F82
8622#define SCU_RAM_QAM_WR_RSV_10__W 16
8623#define SCU_RAM_QAM_WR_RSV_10__M 0xFFFF
8624#define SCU_RAM_QAM_WR_RSV_10__PRE 0x0
8625
8626#define SCU_RAM_QAM_WR_RSV_10_BIT__B 0
8627#define SCU_RAM_QAM_WR_RSV_10_BIT__W 16
8628#define SCU_RAM_QAM_WR_RSV_10_BIT__M 0xFFFF
8629#define SCU_RAM_QAM_WR_RSV_10_BIT__PRE 0x0
8630
8631#define SCU_RAM_QAM_FSM_FMHUM_TO__A 0x831F83
8632#define SCU_RAM_QAM_FSM_FMHUM_TO__W 16
8633#define SCU_RAM_QAM_FSM_FMHUM_TO__M 0xFFFF
8634#define SCU_RAM_QAM_FSM_FMHUM_TO__PRE 0x0
8635
8636#define SCU_RAM_QAM_FSM_FMHUM_TO_BIT__B 0
8637#define SCU_RAM_QAM_FSM_FMHUM_TO_BIT__W 16
8638#define SCU_RAM_QAM_FSM_FMHUM_TO_BIT__M 0xFFFF
8639#define SCU_RAM_QAM_FSM_FMHUM_TO_BIT__PRE 0x0
8640#define SCU_RAM_QAM_FSM_FMHUM_TO_BIT_NO_FMHUM_TO 0x0
8641
8642#define SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A 0x831F84
8643#define SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__W 16
8644#define SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__M 0xFFFF
8645#define SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__PRE 0x0
8646
8647#define SCU_RAM_QAM_FSM_MEDIAN_AV_MULT_BIT__B 0
8648#define SCU_RAM_QAM_FSM_MEDIAN_AV_MULT_BIT__W 16
8649#define SCU_RAM_QAM_FSM_MEDIAN_AV_MULT_BIT__M 0xFFFF
8650#define SCU_RAM_QAM_FSM_MEDIAN_AV_MULT_BIT__PRE 0x0
8651
8652#define SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A 0x831F85
8653#define SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__W 16
8654#define SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__M 0xFFFF
8655#define SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__PRE 0x0
8656
8657#define SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT_BIT__B 0
8658#define SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT_BIT__W 16
8659#define SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT_BIT__M 0xFFFF
8660#define SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT_BIT__PRE 0x0
8661
8662#define SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A 0x831F86
8663#define SCU_RAM_QAM_FSM_LCAVG_OFFSET1__W 16
8664#define SCU_RAM_QAM_FSM_LCAVG_OFFSET1__M 0xFFFF
8665#define SCU_RAM_QAM_FSM_LCAVG_OFFSET1__PRE 0x0
8666
8667#define SCU_RAM_QAM_FSM_LCAVG_OFFSET1_BIT__B 0
8668#define SCU_RAM_QAM_FSM_LCAVG_OFFSET1_BIT__W 16
8669#define SCU_RAM_QAM_FSM_LCAVG_OFFSET1_BIT__M 0xFFFF
8670#define SCU_RAM_QAM_FSM_LCAVG_OFFSET1_BIT__PRE 0x0
8671
8672#define SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A 0x831F87
8673#define SCU_RAM_QAM_FSM_LCAVG_OFFSET2__W 16
8674#define SCU_RAM_QAM_FSM_LCAVG_OFFSET2__M 0xFFFF
8675#define SCU_RAM_QAM_FSM_LCAVG_OFFSET2__PRE 0x0
8676
8677#define SCU_RAM_QAM_FSM_LCAVG_OFFSET2_BIT__B 0
8678#define SCU_RAM_QAM_FSM_LCAVG_OFFSET2_BIT__W 16
8679#define SCU_RAM_QAM_FSM_LCAVG_OFFSET2_BIT__M 0xFFFF
8680#define SCU_RAM_QAM_FSM_LCAVG_OFFSET2_BIT__PRE 0x0
8681
8682#define SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A 0x831F88
8683#define SCU_RAM_QAM_FSM_LCAVG_OFFSET3__W 16
8684#define SCU_RAM_QAM_FSM_LCAVG_OFFSET3__M 0xFFFF
8685#define SCU_RAM_QAM_FSM_LCAVG_OFFSET3__PRE 0x0
8686
8687#define SCU_RAM_QAM_FSM_LCAVG_OFFSET3_BIT__B 0
8688#define SCU_RAM_QAM_FSM_LCAVG_OFFSET3_BIT__W 16
8689#define SCU_RAM_QAM_FSM_LCAVG_OFFSET3_BIT__M 0xFFFF
8690#define SCU_RAM_QAM_FSM_LCAVG_OFFSET3_BIT__PRE 0x0
8691
8692#define SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A 0x831F89
8693#define SCU_RAM_QAM_FSM_LCAVG_OFFSET4__W 16
8694#define SCU_RAM_QAM_FSM_LCAVG_OFFSET4__M 0xFFFF
8695#define SCU_RAM_QAM_FSM_LCAVG_OFFSET4__PRE 0x0
8696
8697#define SCU_RAM_QAM_FSM_LCAVG_OFFSET4_BIT__B 0
8698#define SCU_RAM_QAM_FSM_LCAVG_OFFSET4_BIT__W 16
8699#define SCU_RAM_QAM_FSM_LCAVG_OFFSET4_BIT__M 0xFFFF
8700#define SCU_RAM_QAM_FSM_LCAVG_OFFSET4_BIT__PRE 0x0
8701
8702#define SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A 0x831F8A
8703#define SCU_RAM_QAM_FSM_LCAVG_OFFSET5__W 16
8704#define SCU_RAM_QAM_FSM_LCAVG_OFFSET5__M 0xFFFF
8705#define SCU_RAM_QAM_FSM_LCAVG_OFFSET5__PRE 0x0
8706
8707#define SCU_RAM_QAM_FSM_LCAVG_OFFSET5_BIT__B 0
8708#define SCU_RAM_QAM_FSM_LCAVG_OFFSET5_BIT__W 16
8709#define SCU_RAM_QAM_FSM_LCAVG_OFFSET5_BIT__M 0xFFFF
8710#define SCU_RAM_QAM_FSM_LCAVG_OFFSET5_BIT__PRE 0x0
8711
8712#define SCU_RAM_QAM_FSM_STATE_TGT__A 0x831F8B
8713#define SCU_RAM_QAM_FSM_STATE_TGT__W 4
8714#define SCU_RAM_QAM_FSM_STATE_TGT__M 0xF
8715#define SCU_RAM_QAM_FSM_STATE_TGT__PRE 0x0
8716
8717#define SCU_RAM_QAM_FSM_STATE_TGT_BIT__B 0
8718#define SCU_RAM_QAM_FSM_STATE_TGT_BIT__W 4
8719#define SCU_RAM_QAM_FSM_STATE_TGT_BIT__M 0xF
8720#define SCU_RAM_QAM_FSM_STATE_TGT_BIT__PRE 0x0
8721#define SCU_RAM_QAM_FSM_STATE_TGT_BIT_HUNTING_AMP 0x0
8722#define SCU_RAM_QAM_FSM_STATE_TGT_BIT_HUNTING_RATE 0x1
8723#define SCU_RAM_QAM_FSM_STATE_TGT_BIT_HUNTING_FREQ 0x2
8724#define SCU_RAM_QAM_FSM_STATE_TGT_BIT_HUNTING_UPRIGHT 0x3
8725#define SCU_RAM_QAM_FSM_STATE_TGT_BIT_HUNTING_PHASE 0x4
8726#define SCU_RAM_QAM_FSM_STATE_TGT_BIT_TRACKING_PHNOISE 0x5
8727#define SCU_RAM_QAM_FSM_STATE_TGT_BIT_TRACKING 0x6
8728#define SCU_RAM_QAM_FSM_STATE_TGT_BIT_TRACKING_BURST 0x7
8729
8730#define SCU_RAM_QAM_FSM_LOCK_OVERRIDE__A 0x831F8C
8731#define SCU_RAM_QAM_FSM_LOCK_OVERRIDE__W 9
8732#define SCU_RAM_QAM_FSM_LOCK_OVERRIDE__M 0x1FF
8733#define SCU_RAM_QAM_FSM_LOCK_OVERRIDE__PRE 0x0
8734
8735#define SCU_RAM_QAM_FSM_LOCK_OVERRIDE_LCK_AMP__B 0
8736#define SCU_RAM_QAM_FSM_LOCK_OVERRIDE_LCK_AMP__W 1
8737#define SCU_RAM_QAM_FSM_LOCK_OVERRIDE_LCK_AMP__M 0x1
8738#define SCU_RAM_QAM_FSM_LOCK_OVERRIDE_LCK_AMP__PRE 0x0
8739
8740#define SCU_RAM_QAM_FSM_ATH__A 0x831F8D
8741#define SCU_RAM_QAM_FSM_ATH__W 16
8742#define SCU_RAM_QAM_FSM_ATH__M 0xFFFF
8743#define SCU_RAM_QAM_FSM_ATH__PRE 0x0
8744
8745#define SCU_RAM_QAM_FSM_ATH_BIT__B 0
8746#define SCU_RAM_QAM_FSM_ATH_BIT__W 16
8747#define SCU_RAM_QAM_FSM_ATH_BIT__M 0xFFFF
8748#define SCU_RAM_QAM_FSM_ATH_BIT__PRE 0x0
8749
8750#define SCU_RAM_QAM_FSM_RTH__A 0x831F8E
8751#define SCU_RAM_QAM_FSM_RTH__W 16
8752#define SCU_RAM_QAM_FSM_RTH__M 0xFFFF
8753#define SCU_RAM_QAM_FSM_RTH__PRE 0x0
8754
8755#define SCU_RAM_QAM_FSM_RTH_BIT__B 0
8756#define SCU_RAM_QAM_FSM_RTH_BIT__W 16
8757#define SCU_RAM_QAM_FSM_RTH_BIT__M 0xFFFF
8758#define SCU_RAM_QAM_FSM_RTH_BIT__PRE 0x0
8759#define SCU_RAM_QAM_FSM_RTH_BIT_QAM_16 0x8C
8760#define SCU_RAM_QAM_FSM_RTH_BIT_QAM_32 0x50
8761#define SCU_RAM_QAM_FSM_RTH_BIT_QAM_64 0x4E
8762#define SCU_RAM_QAM_FSM_RTH_BIT_QAM_128 0x32
8763#define SCU_RAM_QAM_FSM_RTH_BIT_QAM_256 0x2D
8764
8765#define SCU_RAM_QAM_FSM_FTH__A 0x831F8F
8766#define SCU_RAM_QAM_FSM_FTH__W 16
8767#define SCU_RAM_QAM_FSM_FTH__M 0xFFFF
8768#define SCU_RAM_QAM_FSM_FTH__PRE 0x0
8769
8770#define SCU_RAM_QAM_FSM_FTH_BIT__B 0
8771#define SCU_RAM_QAM_FSM_FTH_BIT__W 16
8772#define SCU_RAM_QAM_FSM_FTH_BIT__M 0xFFFF
8773#define SCU_RAM_QAM_FSM_FTH_BIT__PRE 0x0
8774#define SCU_RAM_QAM_FSM_FTH_BIT_QAM_16 0x32
8775#define SCU_RAM_QAM_FSM_FTH_BIT_QAM_32 0x1E
8776#define SCU_RAM_QAM_FSM_FTH_BIT_QAM_64 0x1E
8777#define SCU_RAM_QAM_FSM_FTH_BIT_QAM_128 0x14
8778#define SCU_RAM_QAM_FSM_FTH_BIT_QAM_256 0x14
8779
8780#define SCU_RAM_QAM_FSM_PTH__A 0x831F90
8781#define SCU_RAM_QAM_FSM_PTH__W 16
8782#define SCU_RAM_QAM_FSM_PTH__M 0xFFFF
8783#define SCU_RAM_QAM_FSM_PTH__PRE 0x0
8784
8785#define SCU_RAM_QAM_FSM_PTH_BIT__B 0
8786#define SCU_RAM_QAM_FSM_PTH_BIT__W 16
8787#define SCU_RAM_QAM_FSM_PTH_BIT__M 0xFFFF
8788#define SCU_RAM_QAM_FSM_PTH_BIT__PRE 0x0
8789#define SCU_RAM_QAM_FSM_PTH_BIT_QAM_16 0xC8
8790#define SCU_RAM_QAM_FSM_PTH_BIT_QAM_32 0x96
8791#define SCU_RAM_QAM_FSM_PTH_BIT_QAM_64 0x8C
8792#define SCU_RAM_QAM_FSM_PTH_BIT_QAM_128 0x64
8793#define SCU_RAM_QAM_FSM_PTH_BIT_QAM_256 0x64
8794
8795#define SCU_RAM_QAM_FSM_MTH__A 0x831F91
8796#define SCU_RAM_QAM_FSM_MTH__W 16
8797#define SCU_RAM_QAM_FSM_MTH__M 0xFFFF
8798#define SCU_RAM_QAM_FSM_MTH__PRE 0x0
8799
8800#define SCU_RAM_QAM_FSM_MTH_BIT__B 0
8801#define SCU_RAM_QAM_FSM_MTH_BIT__W 16
8802#define SCU_RAM_QAM_FSM_MTH_BIT__M 0xFFFF
8803#define SCU_RAM_QAM_FSM_MTH_BIT__PRE 0x0
8804#define SCU_RAM_QAM_FSM_MTH_BIT_QAM_16 0x5A
8805#define SCU_RAM_QAM_FSM_MTH_BIT_QAM_32 0x50
8806#define SCU_RAM_QAM_FSM_MTH_BIT_QAM_64 0x46
8807#define SCU_RAM_QAM_FSM_MTH_BIT_QAM_128 0x3C
8808#define SCU_RAM_QAM_FSM_MTH_BIT_QAM_256 0x50
8809
8810#define SCU_RAM_QAM_FSM_CTH__A 0x831F92
8811#define SCU_RAM_QAM_FSM_CTH__W 16
8812#define SCU_RAM_QAM_FSM_CTH__M 0xFFFF
8813#define SCU_RAM_QAM_FSM_CTH__PRE 0x0
8814
8815#define SCU_RAM_QAM_FSM_CTH_BIT__B 0
8816#define SCU_RAM_QAM_FSM_CTH_BIT__W 16
8817#define SCU_RAM_QAM_FSM_CTH_BIT__M 0xFFFF
8818#define SCU_RAM_QAM_FSM_CTH_BIT__PRE 0x0
8819#define SCU_RAM_QAM_FSM_CTH_BIT_QAM_16 0xA0
8820#define SCU_RAM_QAM_FSM_CTH_BIT_QAM_32 0x8C
8821#define SCU_RAM_QAM_FSM_CTH_BIT_QAM_64 0x8C
8822#define SCU_RAM_QAM_FSM_CTH_BIT_QAM_128 0x8C
8823#define SCU_RAM_QAM_FSM_CTH_BIT_QAM_256 0x8C
8824
8825#define SCU_RAM_QAM_FSM_QTH__A 0x831F93
8826#define SCU_RAM_QAM_FSM_QTH__W 16
8827#define SCU_RAM_QAM_FSM_QTH__M 0xFFFF
8828#define SCU_RAM_QAM_FSM_QTH__PRE 0x0
8829
8830#define SCU_RAM_QAM_FSM_QTH_BIT__B 0
8831#define SCU_RAM_QAM_FSM_QTH_BIT__W 16
8832#define SCU_RAM_QAM_FSM_QTH_BIT__M 0xFFFF
8833#define SCU_RAM_QAM_FSM_QTH_BIT__PRE 0x0
8834#define SCU_RAM_QAM_FSM_QTH_BIT_QAM_16 0xE6
8835#define SCU_RAM_QAM_FSM_QTH_BIT_QAM_32 0xAA
8836#define SCU_RAM_QAM_FSM_QTH_BIT_QAM_64 0xC3
8837#define SCU_RAM_QAM_FSM_QTH_BIT_QAM_128 0x8C
8838#define SCU_RAM_QAM_FSM_QTH_BIT_QAM_256 0x96
8839
8840#define SCU_RAM_QAM_FSM_RATE_LIM__A 0x831F94
8841#define SCU_RAM_QAM_FSM_RATE_LIM__W 16
8842#define SCU_RAM_QAM_FSM_RATE_LIM__M 0xFFFF
8843#define SCU_RAM_QAM_FSM_RATE_LIM__PRE 0x0
8844
8845#define SCU_RAM_QAM_FSM_RATE_LIM_BIT__B 0
8846#define SCU_RAM_QAM_FSM_RATE_LIM_BIT__W 16
8847#define SCU_RAM_QAM_FSM_RATE_LIM_BIT__M 0xFFFF
8848#define SCU_RAM_QAM_FSM_RATE_LIM_BIT__PRE 0x0
8849#define SCU_RAM_QAM_FSM_RATE_LIM_BIT_QAM_16 0x46
8850#define SCU_RAM_QAM_FSM_RATE_LIM_BIT_QAM_32 0x46
8851#define SCU_RAM_QAM_FSM_RATE_LIM_BIT_QAM_64 0x46
8852#define SCU_RAM_QAM_FSM_RATE_LIM_BIT_QAM_128 0x46
8853#define SCU_RAM_QAM_FSM_RATE_LIM_BIT_QAM_256 0x46
8854
8855#define SCU_RAM_QAM_FSM_FREQ_LIM__A 0x831F95
8856#define SCU_RAM_QAM_FSM_FREQ_LIM__W 16
8857#define SCU_RAM_QAM_FSM_FREQ_LIM__M 0xFFFF
8858#define SCU_RAM_QAM_FSM_FREQ_LIM__PRE 0x0
8859
8860#define SCU_RAM_QAM_FSM_FREQ_LIM_BIT__B 0
8861#define SCU_RAM_QAM_FSM_FREQ_LIM_BIT__W 16
8862#define SCU_RAM_QAM_FSM_FREQ_LIM_BIT__M 0xFFFF
8863#define SCU_RAM_QAM_FSM_FREQ_LIM_BIT__PRE 0x0
8864#define SCU_RAM_QAM_FSM_FREQ_LIM_BIT_QAM_16 0x1E
8865#define SCU_RAM_QAM_FSM_FREQ_LIM_BIT_QAM_32 0x14
8866#define SCU_RAM_QAM_FSM_FREQ_LIM_BIT_QAM_64 0x28
8867#define SCU_RAM_QAM_FSM_FREQ_LIM_BIT_QAM_128 0x8
8868#define SCU_RAM_QAM_FSM_FREQ_LIM_BIT_QAM_256 0x28
8869
8870#define SCU_RAM_QAM_FSM_COUNT_LIM__A 0x831F96
8871#define SCU_RAM_QAM_FSM_COUNT_LIM__W 16
8872#define SCU_RAM_QAM_FSM_COUNT_LIM__M 0xFFFF
8873#define SCU_RAM_QAM_FSM_COUNT_LIM__PRE 0x0
8874
8875#define SCU_RAM_QAM_FSM_COUNT_LIM_BIT__B 0
8876#define SCU_RAM_QAM_FSM_COUNT_LIM_BIT__W 16
8877#define SCU_RAM_QAM_FSM_COUNT_LIM_BIT__M 0xFFFF
8878#define SCU_RAM_QAM_FSM_COUNT_LIM_BIT__PRE 0x0
8879#define SCU_RAM_QAM_FSM_COUNT_LIM_BIT_QAM_16 0x4
8880#define SCU_RAM_QAM_FSM_COUNT_LIM_BIT_QAM_32 0x6
8881#define SCU_RAM_QAM_FSM_COUNT_LIM_BIT_QAM_64 0x6
8882#define SCU_RAM_QAM_FSM_COUNT_LIM_BIT_QAM_128 0x7
8883#define SCU_RAM_QAM_FSM_COUNT_LIM_BIT_QAM_256 0x6
8884
8885#define SCU_RAM_QAM_LC_CA_COARSE__A 0x831F97
8886#define SCU_RAM_QAM_LC_CA_COARSE__W 16
8887#define SCU_RAM_QAM_LC_CA_COARSE__M 0xFFFF
8888#define SCU_RAM_QAM_LC_CA_COARSE__PRE 0x0
8889
8890#define SCU_RAM_QAM_LC_CA_COARSE_BIT__B 0
8891#define SCU_RAM_QAM_LC_CA_COARSE_BIT__W 8
8892#define SCU_RAM_QAM_LC_CA_COARSE_BIT__M 0xFF
8893#define SCU_RAM_QAM_LC_CA_COARSE_BIT__PRE 0x0
8894
8895#define SCU_RAM_QAM_LC_CA_MEDIUM__A 0x831F98
8896#define SCU_RAM_QAM_LC_CA_MEDIUM__W 16
8897#define SCU_RAM_QAM_LC_CA_MEDIUM__M 0xFFFF
8898#define SCU_RAM_QAM_LC_CA_MEDIUM__PRE 0x0
8899
8900#define SCU_RAM_QAM_LC_CA_MEDIUM_BIT__B 0
8901#define SCU_RAM_QAM_LC_CA_MEDIUM_BIT__W 8
8902#define SCU_RAM_QAM_LC_CA_MEDIUM_BIT__M 0xFF
8903#define SCU_RAM_QAM_LC_CA_MEDIUM_BIT__PRE 0x0
8904
8905#define SCU_RAM_QAM_LC_CA_FINE__A 0x831F99
8906#define SCU_RAM_QAM_LC_CA_FINE__W 16
8907#define SCU_RAM_QAM_LC_CA_FINE__M 0xFFFF
8908#define SCU_RAM_QAM_LC_CA_FINE__PRE 0x0
8909
8910#define SCU_RAM_QAM_LC_CA_FINE_BIT__B 0
8911#define SCU_RAM_QAM_LC_CA_FINE_BIT__W 8
8912#define SCU_RAM_QAM_LC_CA_FINE_BIT__M 0xFF
8913#define SCU_RAM_QAM_LC_CA_FINE_BIT__PRE 0x0
8914
8915#define SCU_RAM_QAM_LC_CP_COARSE__A 0x831F9A
8916#define SCU_RAM_QAM_LC_CP_COARSE__W 16
8917#define SCU_RAM_QAM_LC_CP_COARSE__M 0xFFFF
8918#define SCU_RAM_QAM_LC_CP_COARSE__PRE 0x0
8919
8920#define SCU_RAM_QAM_LC_CP_COARSE_BIT__B 0
8921#define SCU_RAM_QAM_LC_CP_COARSE_BIT__W 8
8922#define SCU_RAM_QAM_LC_CP_COARSE_BIT__M 0xFF
8923#define SCU_RAM_QAM_LC_CP_COARSE_BIT__PRE 0x0
8924
8925#define SCU_RAM_QAM_LC_CP_MEDIUM__A 0x831F9B
8926#define SCU_RAM_QAM_LC_CP_MEDIUM__W 16
8927#define SCU_RAM_QAM_LC_CP_MEDIUM__M 0xFFFF
8928#define SCU_RAM_QAM_LC_CP_MEDIUM__PRE 0x0
8929
8930#define SCU_RAM_QAM_LC_CP_MEDIUM_BIT__B 0
8931#define SCU_RAM_QAM_LC_CP_MEDIUM_BIT__W 8
8932#define SCU_RAM_QAM_LC_CP_MEDIUM_BIT__M 0xFF
8933#define SCU_RAM_QAM_LC_CP_MEDIUM_BIT__PRE 0x0
8934
8935#define SCU_RAM_QAM_LC_CP_FINE__A 0x831F9C
8936#define SCU_RAM_QAM_LC_CP_FINE__W 16
8937#define SCU_RAM_QAM_LC_CP_FINE__M 0xFFFF
8938#define SCU_RAM_QAM_LC_CP_FINE__PRE 0x0
8939
8940#define SCU_RAM_QAM_LC_CP_FINE_BIT__B 0
8941#define SCU_RAM_QAM_LC_CP_FINE_BIT__W 8
8942#define SCU_RAM_QAM_LC_CP_FINE_BIT__M 0xFF
8943#define SCU_RAM_QAM_LC_CP_FINE_BIT__PRE 0x0
8944
8945#define SCU_RAM_QAM_LC_CI_COARSE__A 0x831F9D
8946#define SCU_RAM_QAM_LC_CI_COARSE__W 16
8947#define SCU_RAM_QAM_LC_CI_COARSE__M 0xFFFF
8948#define SCU_RAM_QAM_LC_CI_COARSE__PRE 0x0
8949
8950#define SCU_RAM_QAM_LC_CI_COARSE_BIT__B 0
8951#define SCU_RAM_QAM_LC_CI_COARSE_BIT__W 8
8952#define SCU_RAM_QAM_LC_CI_COARSE_BIT__M 0xFF
8953#define SCU_RAM_QAM_LC_CI_COARSE_BIT__PRE 0x0
8954
8955#define SCU_RAM_QAM_LC_CI_MEDIUM__A 0x831F9E
8956#define SCU_RAM_QAM_LC_CI_MEDIUM__W 16
8957#define SCU_RAM_QAM_LC_CI_MEDIUM__M 0xFFFF
8958#define SCU_RAM_QAM_LC_CI_MEDIUM__PRE 0x0
8959
8960#define SCU_RAM_QAM_LC_CI_MEDIUM_BIT__B 0
8961#define SCU_RAM_QAM_LC_CI_MEDIUM_BIT__W 8
8962#define SCU_RAM_QAM_LC_CI_MEDIUM_BIT__M 0xFF
8963#define SCU_RAM_QAM_LC_CI_MEDIUM_BIT__PRE 0x0
8964
8965#define SCU_RAM_QAM_LC_CI_FINE__A 0x831F9F
8966#define SCU_RAM_QAM_LC_CI_FINE__W 16
8967#define SCU_RAM_QAM_LC_CI_FINE__M 0xFFFF
8968#define SCU_RAM_QAM_LC_CI_FINE__PRE 0x0
8969
8970#define SCU_RAM_QAM_LC_CI_FINE_BIT__B 0
8971#define SCU_RAM_QAM_LC_CI_FINE_BIT__W 8
8972#define SCU_RAM_QAM_LC_CI_FINE_BIT__M 0xFF
8973#define SCU_RAM_QAM_LC_CI_FINE_BIT__PRE 0x0
8974
8975#define SCU_RAM_QAM_LC_EP_COARSE__A 0x831FA0
8976#define SCU_RAM_QAM_LC_EP_COARSE__W 16
8977#define SCU_RAM_QAM_LC_EP_COARSE__M 0xFFFF
8978#define SCU_RAM_QAM_LC_EP_COARSE__PRE 0x0
8979
8980#define SCU_RAM_QAM_LC_EP_COARSE_BIT__B 0
8981#define SCU_RAM_QAM_LC_EP_COARSE_BIT__W 8
8982#define SCU_RAM_QAM_LC_EP_COARSE_BIT__M 0xFF
8983#define SCU_RAM_QAM_LC_EP_COARSE_BIT__PRE 0x0
8984
8985#define SCU_RAM_QAM_LC_EP_MEDIUM__A 0x831FA1
8986#define SCU_RAM_QAM_LC_EP_MEDIUM__W 16
8987#define SCU_RAM_QAM_LC_EP_MEDIUM__M 0xFFFF
8988#define SCU_RAM_QAM_LC_EP_MEDIUM__PRE 0x0
8989
8990#define SCU_RAM_QAM_LC_EP_MEDIUM_BIT__B 0
8991#define SCU_RAM_QAM_LC_EP_MEDIUM_BIT__W 8
8992#define SCU_RAM_QAM_LC_EP_MEDIUM_BIT__M 0xFF
8993#define SCU_RAM_QAM_LC_EP_MEDIUM_BIT__PRE 0x0
8994
8995#define SCU_RAM_QAM_LC_EP_FINE__A 0x831FA2
8996#define SCU_RAM_QAM_LC_EP_FINE__W 16
8997#define SCU_RAM_QAM_LC_EP_FINE__M 0xFFFF
8998#define SCU_RAM_QAM_LC_EP_FINE__PRE 0x0
8999
9000#define SCU_RAM_QAM_LC_EP_FINE_BIT__B 0
9001#define SCU_RAM_QAM_LC_EP_FINE_BIT__W 8
9002#define SCU_RAM_QAM_LC_EP_FINE_BIT__M 0xFF
9003#define SCU_RAM_QAM_LC_EP_FINE_BIT__PRE 0x0
9004
9005#define SCU_RAM_QAM_LC_EI_COARSE__A 0x831FA3
9006#define SCU_RAM_QAM_LC_EI_COARSE__W 16
9007#define SCU_RAM_QAM_LC_EI_COARSE__M 0xFFFF
9008#define SCU_RAM_QAM_LC_EI_COARSE__PRE 0x0
9009
9010#define SCU_RAM_QAM_LC_EI_COARSE_BIT__B 0
9011#define SCU_RAM_QAM_LC_EI_COARSE_BIT__W 8
9012#define SCU_RAM_QAM_LC_EI_COARSE_BIT__M 0xFF
9013#define SCU_RAM_QAM_LC_EI_COARSE_BIT__PRE 0x0
9014
9015#define SCU_RAM_QAM_LC_EI_MEDIUM__A 0x831FA4
9016#define SCU_RAM_QAM_LC_EI_MEDIUM__W 16
9017#define SCU_RAM_QAM_LC_EI_MEDIUM__M 0xFFFF
9018#define SCU_RAM_QAM_LC_EI_MEDIUM__PRE 0x0
9019
9020#define SCU_RAM_QAM_LC_EI_MEDIUM_BIT__B 0
9021#define SCU_RAM_QAM_LC_EI_MEDIUM_BIT__W 8
9022#define SCU_RAM_QAM_LC_EI_MEDIUM_BIT__M 0xFF
9023#define SCU_RAM_QAM_LC_EI_MEDIUM_BIT__PRE 0x0
9024
9025#define SCU_RAM_QAM_LC_EI_FINE__A 0x831FA5
9026#define SCU_RAM_QAM_LC_EI_FINE__W 16
9027#define SCU_RAM_QAM_LC_EI_FINE__M 0xFFFF
9028#define SCU_RAM_QAM_LC_EI_FINE__PRE 0x0
9029
9030#define SCU_RAM_QAM_LC_EI_FINE_BIT__B 0
9031#define SCU_RAM_QAM_LC_EI_FINE_BIT__W 8
9032#define SCU_RAM_QAM_LC_EI_FINE_BIT__M 0xFF
9033#define SCU_RAM_QAM_LC_EI_FINE_BIT__PRE 0x0
9034
9035#define SCU_RAM_QAM_LC_CF_COARSE__A 0x831FA6
9036#define SCU_RAM_QAM_LC_CF_COARSE__W 16
9037#define SCU_RAM_QAM_LC_CF_COARSE__M 0xFFFF
9038#define SCU_RAM_QAM_LC_CF_COARSE__PRE 0x0
9039
9040#define SCU_RAM_QAM_LC_CF_COARSE_BIT__B 0
9041#define SCU_RAM_QAM_LC_CF_COARSE_BIT__W 8
9042#define SCU_RAM_QAM_LC_CF_COARSE_BIT__M 0xFF
9043#define SCU_RAM_QAM_LC_CF_COARSE_BIT__PRE 0x0
9044
9045#define SCU_RAM_QAM_LC_CF_MEDIUM__A 0x831FA7
9046#define SCU_RAM_QAM_LC_CF_MEDIUM__W 16
9047#define SCU_RAM_QAM_LC_CF_MEDIUM__M 0xFFFF
9048#define SCU_RAM_QAM_LC_CF_MEDIUM__PRE 0x0
9049
9050#define SCU_RAM_QAM_LC_CF_MEDIUM_BIT__B 0
9051#define SCU_RAM_QAM_LC_CF_MEDIUM_BIT__W 8
9052#define SCU_RAM_QAM_LC_CF_MEDIUM_BIT__M 0xFF
9053#define SCU_RAM_QAM_LC_CF_MEDIUM_BIT__PRE 0x0
9054
9055#define SCU_RAM_QAM_LC_CF_FINE__A 0x831FA8
9056#define SCU_RAM_QAM_LC_CF_FINE__W 16
9057#define SCU_RAM_QAM_LC_CF_FINE__M 0xFFFF
9058#define SCU_RAM_QAM_LC_CF_FINE__PRE 0x0
9059
9060#define SCU_RAM_QAM_LC_CF_FINE_BIT__B 0
9061#define SCU_RAM_QAM_LC_CF_FINE_BIT__W 8
9062#define SCU_RAM_QAM_LC_CF_FINE_BIT__M 0xFF
9063#define SCU_RAM_QAM_LC_CF_FINE_BIT__PRE 0x0
9064
9065#define SCU_RAM_QAM_LC_CF1_COARSE__A 0x831FA9
9066#define SCU_RAM_QAM_LC_CF1_COARSE__W 16
9067#define SCU_RAM_QAM_LC_CF1_COARSE__M 0xFFFF
9068#define SCU_RAM_QAM_LC_CF1_COARSE__PRE 0x0
9069
9070#define SCU_RAM_QAM_LC_CF1_COARSE_BIT__B 0
9071#define SCU_RAM_QAM_LC_CF1_COARSE_BIT__W 8
9072#define SCU_RAM_QAM_LC_CF1_COARSE_BIT__M 0xFF
9073#define SCU_RAM_QAM_LC_CF1_COARSE_BIT__PRE 0x0
9074
9075#define SCU_RAM_QAM_LC_CF1_MEDIUM__A 0x831FAA
9076#define SCU_RAM_QAM_LC_CF1_MEDIUM__W 16
9077#define SCU_RAM_QAM_LC_CF1_MEDIUM__M 0xFFFF
9078#define SCU_RAM_QAM_LC_CF1_MEDIUM__PRE 0x0
9079
9080#define SCU_RAM_QAM_LC_CF1_MEDIUM_BIT__B 0
9081#define SCU_RAM_QAM_LC_CF1_MEDIUM_BIT__W 8
9082#define SCU_RAM_QAM_LC_CF1_MEDIUM_BIT__M 0xFF
9083#define SCU_RAM_QAM_LC_CF1_MEDIUM_BIT__PRE 0x0
9084
9085#define SCU_RAM_QAM_LC_CF1_FINE__A 0x831FAB
9086#define SCU_RAM_QAM_LC_CF1_FINE__W 16
9087#define SCU_RAM_QAM_LC_CF1_FINE__M 0xFFFF
9088#define SCU_RAM_QAM_LC_CF1_FINE__PRE 0x0
9089
9090#define SCU_RAM_QAM_LC_CF1_FINE_BIT__B 0
9091#define SCU_RAM_QAM_LC_CF1_FINE_BIT__W 8
9092#define SCU_RAM_QAM_LC_CF1_FINE_BIT__M 0xFF
9093#define SCU_RAM_QAM_LC_CF1_FINE_BIT__PRE 0x0
9094
9095#define SCU_RAM_QAM_SL_SIG_POWER__A 0x831FAC
9096#define SCU_RAM_QAM_SL_SIG_POWER__W 16
9097#define SCU_RAM_QAM_SL_SIG_POWER__M 0xFFFF
9098#define SCU_RAM_QAM_SL_SIG_POWER__PRE 0x0
9099
9100#define SCU_RAM_QAM_SL_SIG_POWER_BIT__B 0
9101#define SCU_RAM_QAM_SL_SIG_POWER_BIT__W 16
9102#define SCU_RAM_QAM_SL_SIG_POWER_BIT__M 0xFFFF
9103#define SCU_RAM_QAM_SL_SIG_POWER_BIT__PRE 0x0
9104
9105#define SCU_RAM_QAM_EQ_CMA_RAD0__A 0x831FAD
9106#define SCU_RAM_QAM_EQ_CMA_RAD0__W 14
9107#define SCU_RAM_QAM_EQ_CMA_RAD0__M 0x3FFF
9108#define SCU_RAM_QAM_EQ_CMA_RAD0__PRE 0x0
9109
9110#define SCU_RAM_QAM_EQ_CMA_RAD0_BIT__B 0
9111#define SCU_RAM_QAM_EQ_CMA_RAD0_BIT__W 14
9112#define SCU_RAM_QAM_EQ_CMA_RAD0_BIT__M 0x3FFF
9113#define SCU_RAM_QAM_EQ_CMA_RAD0_BIT__PRE 0x0
9114#define SCU_RAM_QAM_EQ_CMA_RAD0_BIT_QAM_16 0x34CD
9115#define SCU_RAM_QAM_EQ_CMA_RAD0_BIT_QAM_32 0x1A33
9116#define SCU_RAM_QAM_EQ_CMA_RAD0_BIT_QAM_64 0x3418
9117#define SCU_RAM_QAM_EQ_CMA_RAD0_BIT_QAM_128 0x1814
9118#define SCU_RAM_QAM_EQ_CMA_RAD0_BIT_QAM_256 0x2CEE
9119
9120#define SCU_RAM_QAM_EQ_CMA_RAD1__A 0x831FAE
9121#define SCU_RAM_QAM_EQ_CMA_RAD1__W 14
9122#define SCU_RAM_QAM_EQ_CMA_RAD1__M 0x3FFF
9123#define SCU_RAM_QAM_EQ_CMA_RAD1__PRE 0x0
9124
9125#define SCU_RAM_QAM_EQ_CMA_RAD1_BIT__B 0
9126#define SCU_RAM_QAM_EQ_CMA_RAD1_BIT__W 14
9127#define SCU_RAM_QAM_EQ_CMA_RAD1_BIT__M 0x3FFF
9128#define SCU_RAM_QAM_EQ_CMA_RAD1_BIT__PRE 0x0
9129#define SCU_RAM_QAM_EQ_CMA_RAD1_BIT_QAM_16 0x34CD
9130#define SCU_RAM_QAM_EQ_CMA_RAD1_BIT_QAM_32 0x1A33
9131#define SCU_RAM_QAM_EQ_CMA_RAD1_BIT_QAM_64 0x314A
9132#define SCU_RAM_QAM_EQ_CMA_RAD1_BIT_QAM_128 0x19C6
9133#define SCU_RAM_QAM_EQ_CMA_RAD1_BIT_QAM_256 0x2F34
9134
9135#define SCU_RAM_QAM_EQ_CMA_RAD2__A 0x831FAF
9136#define SCU_RAM_QAM_EQ_CMA_RAD2__W 14
9137#define SCU_RAM_QAM_EQ_CMA_RAD2__M 0x3FFF
9138#define SCU_RAM_QAM_EQ_CMA_RAD2__PRE 0x0
9139
9140#define SCU_RAM_QAM_EQ_CMA_RAD2_BIT__B 0
9141#define SCU_RAM_QAM_EQ_CMA_RAD2_BIT__W 14
9142#define SCU_RAM_QAM_EQ_CMA_RAD2_BIT__M 0x3FFF
9143#define SCU_RAM_QAM_EQ_CMA_RAD2_BIT__PRE 0x0
9144#define SCU_RAM_QAM_EQ_CMA_RAD2_BIT_QAM_16 0x34CD
9145#define SCU_RAM_QAM_EQ_CMA_RAD2_BIT_QAM_32 0x1A33
9146#define SCU_RAM_QAM_EQ_CMA_RAD2_BIT_QAM_64 0x2ED4
9147#define SCU_RAM_QAM_EQ_CMA_RAD2_BIT_QAM_128 0x18FA
9148#define SCU_RAM_QAM_EQ_CMA_RAD2_BIT_QAM_256 0x30FF
9149
9150#define SCU_RAM_QAM_EQ_CMA_RAD3__A 0x831FB0
9151#define SCU_RAM_QAM_EQ_CMA_RAD3__W 14
9152#define SCU_RAM_QAM_EQ_CMA_RAD3__M 0x3FFF
9153#define SCU_RAM_QAM_EQ_CMA_RAD3__PRE 0x0
9154
9155#define SCU_RAM_QAM_EQ_CMA_RAD3_BIT__B 0
9156#define SCU_RAM_QAM_EQ_CMA_RAD3_BIT__W 14
9157#define SCU_RAM_QAM_EQ_CMA_RAD3_BIT__M 0x3FFF
9158#define SCU_RAM_QAM_EQ_CMA_RAD3_BIT__PRE 0x0
9159#define SCU_RAM_QAM_EQ_CMA_RAD3_BIT_QAM_16 0x34CD
9160#define SCU_RAM_QAM_EQ_CMA_RAD3_BIT_QAM_32 0x1A33
9161#define SCU_RAM_QAM_EQ_CMA_RAD3_BIT_QAM_64 0x35F1
9162#define SCU_RAM_QAM_EQ_CMA_RAD3_BIT_QAM_128 0x1909
9163#define SCU_RAM_QAM_EQ_CMA_RAD3_BIT_QAM_256 0x3283
9164
9165#define SCU_RAM_QAM_EQ_CMA_RAD4__A 0x831FB1
9166#define SCU_RAM_QAM_EQ_CMA_RAD4__W 14
9167#define SCU_RAM_QAM_EQ_CMA_RAD4__M 0x3FFF
9168#define SCU_RAM_QAM_EQ_CMA_RAD4__PRE 0x0
9169
9170#define SCU_RAM_QAM_EQ_CMA_RAD4_BIT__B 0
9171#define SCU_RAM_QAM_EQ_CMA_RAD4_BIT__W 14
9172#define SCU_RAM_QAM_EQ_CMA_RAD4_BIT__M 0x3FFF
9173#define SCU_RAM_QAM_EQ_CMA_RAD4_BIT__PRE 0x0
9174#define SCU_RAM_QAM_EQ_CMA_RAD4_BIT_QAM_16 0x34CD
9175#define SCU_RAM_QAM_EQ_CMA_RAD4_BIT_QAM_32 0x1A33
9176#define SCU_RAM_QAM_EQ_CMA_RAD4_BIT_QAM_64 0x35F1
9177#define SCU_RAM_QAM_EQ_CMA_RAD4_BIT_QAM_128 0x1A00
9178#define SCU_RAM_QAM_EQ_CMA_RAD4_BIT_QAM_256 0x353D
9179
9180#define SCU_RAM_QAM_EQ_CMA_RAD5__A 0x831FB2
9181#define SCU_RAM_QAM_EQ_CMA_RAD5__W 14
9182#define SCU_RAM_QAM_EQ_CMA_RAD5__M 0x3FFF
9183#define SCU_RAM_QAM_EQ_CMA_RAD5__PRE 0x0
9184
9185#define SCU_RAM_QAM_EQ_CMA_RAD5_BIT__B 0
9186#define SCU_RAM_QAM_EQ_CMA_RAD5_BIT__W 14
9187#define SCU_RAM_QAM_EQ_CMA_RAD5_BIT__M 0x3FFF
9188#define SCU_RAM_QAM_EQ_CMA_RAD5_BIT__PRE 0x0
9189#define SCU_RAM_QAM_EQ_CMA_RAD5_BIT_QAM_16 0x34CD
9190#define SCU_RAM_QAM_EQ_CMA_RAD5_BIT_QAM_32 0x1A33
9191#define SCU_RAM_QAM_EQ_CMA_RAD5_BIT_QAM_64 0x3CF9
9192#define SCU_RAM_QAM_EQ_CMA_RAD5_BIT_QAM_128 0x1C46
9193#define SCU_RAM_QAM_EQ_CMA_RAD5_BIT_QAM_256 0x3C19
9194
9195#define SCU_RAM_QAM_CTL_ENA__A 0x831FB3
9196#define SCU_RAM_QAM_CTL_ENA__W 16
9197#define SCU_RAM_QAM_CTL_ENA__M 0xFFFF
9198#define SCU_RAM_QAM_CTL_ENA__PRE 0x0
9199
9200#define SCU_RAM_QAM_CTL_ENA_AMP__B 0
9201#define SCU_RAM_QAM_CTL_ENA_AMP__W 1
9202#define SCU_RAM_QAM_CTL_ENA_AMP__M 0x1
9203#define SCU_RAM_QAM_CTL_ENA_AMP__PRE 0x0
9204
9205#define SCU_RAM_QAM_CTL_ENA_ACQ__B 1
9206#define SCU_RAM_QAM_CTL_ENA_ACQ__W 1
9207#define SCU_RAM_QAM_CTL_ENA_ACQ__M 0x2
9208#define SCU_RAM_QAM_CTL_ENA_ACQ__PRE 0x0
9209
9210#define SCU_RAM_QAM_CTL_ENA_EQU__B 2
9211#define SCU_RAM_QAM_CTL_ENA_EQU__W 1
9212#define SCU_RAM_QAM_CTL_ENA_EQU__M 0x4
9213#define SCU_RAM_QAM_CTL_ENA_EQU__PRE 0x0
9214
9215#define SCU_RAM_QAM_CTL_ENA_SLC__B 3
9216#define SCU_RAM_QAM_CTL_ENA_SLC__W 1
9217#define SCU_RAM_QAM_CTL_ENA_SLC__M 0x8
9218#define SCU_RAM_QAM_CTL_ENA_SLC__PRE 0x0
9219
9220#define SCU_RAM_QAM_CTL_ENA_LC__B 4
9221#define SCU_RAM_QAM_CTL_ENA_LC__W 1
9222#define SCU_RAM_QAM_CTL_ENA_LC__M 0x10
9223#define SCU_RAM_QAM_CTL_ENA_LC__PRE 0x0
9224
9225#define SCU_RAM_QAM_CTL_ENA_AGC__B 5
9226#define SCU_RAM_QAM_CTL_ENA_AGC__W 1
9227#define SCU_RAM_QAM_CTL_ENA_AGC__M 0x20
9228#define SCU_RAM_QAM_CTL_ENA_AGC__PRE 0x0
9229
9230#define SCU_RAM_QAM_CTL_ENA_FEC__B 6
9231#define SCU_RAM_QAM_CTL_ENA_FEC__W 1
9232#define SCU_RAM_QAM_CTL_ENA_FEC__M 0x40
9233#define SCU_RAM_QAM_CTL_ENA_FEC__PRE 0x0
9234
9235#define SCU_RAM_QAM_CTL_ENA_AXIS__B 7
9236#define SCU_RAM_QAM_CTL_ENA_AXIS__W 1
9237#define SCU_RAM_QAM_CTL_ENA_AXIS__M 0x80
9238#define SCU_RAM_QAM_CTL_ENA_AXIS__PRE 0x0
9239
9240#define SCU_RAM_QAM_CTL_ENA_FMHUM__B 8
9241#define SCU_RAM_QAM_CTL_ENA_FMHUM__W 1
9242#define SCU_RAM_QAM_CTL_ENA_FMHUM__M 0x100
9243#define SCU_RAM_QAM_CTL_ENA_FMHUM__PRE 0x0
9244
9245#define SCU_RAM_QAM_CTL_ENA_EQTIME__B 9
9246#define SCU_RAM_QAM_CTL_ENA_EQTIME__W 1
9247#define SCU_RAM_QAM_CTL_ENA_EQTIME__M 0x200
9248#define SCU_RAM_QAM_CTL_ENA_EQTIME__PRE 0x0
9249
9250#define SCU_RAM_QAM_CTL_ENA_EXTLCK__B 10
9251#define SCU_RAM_QAM_CTL_ENA_EXTLCK__W 1
9252#define SCU_RAM_QAM_CTL_ENA_EXTLCK__M 0x400
9253#define SCU_RAM_QAM_CTL_ENA_EXTLCK__PRE 0x0
9254
9255#define SCU_RAM_QAM_WR_RSV_1__A 0x831FB4
9256#define SCU_RAM_QAM_WR_RSV_1__W 16
9257#define SCU_RAM_QAM_WR_RSV_1__M 0xFFFF
9258#define SCU_RAM_QAM_WR_RSV_1__PRE 0x0
9259
9260#define SCU_RAM_QAM_WR_RSV_1_BIT__B 0
9261#define SCU_RAM_QAM_WR_RSV_1_BIT__W 16
9262#define SCU_RAM_QAM_WR_RSV_1_BIT__M 0xFFFF
9263#define SCU_RAM_QAM_WR_RSV_1_BIT__PRE 0x0
9264
9265#define SCU_RAM_QAM_WR_RSV_2__A 0x831FB5
9266#define SCU_RAM_QAM_WR_RSV_2__W 16
9267#define SCU_RAM_QAM_WR_RSV_2__M 0xFFFF
9268#define SCU_RAM_QAM_WR_RSV_2__PRE 0x0
9269
9270#define SCU_RAM_QAM_WR_RSV_2_BIT__B 0
9271#define SCU_RAM_QAM_WR_RSV_2_BIT__W 16
9272#define SCU_RAM_QAM_WR_RSV_2_BIT__M 0xFFFF
9273#define SCU_RAM_QAM_WR_RSV_2_BIT__PRE 0x0
9274
9275#define SCU_RAM_QAM_WR_RSV_3__A 0x831FB6
9276#define SCU_RAM_QAM_WR_RSV_3__W 16
9277#define SCU_RAM_QAM_WR_RSV_3__M 0xFFFF
9278#define SCU_RAM_QAM_WR_RSV_3__PRE 0x0
9279
9280#define SCU_RAM_QAM_WR_RSV_3_BIT__B 0
9281#define SCU_RAM_QAM_WR_RSV_3_BIT__W 16
9282#define SCU_RAM_QAM_WR_RSV_3_BIT__M 0xFFFF
9283#define SCU_RAM_QAM_WR_RSV_3_BIT__PRE 0x0
9284
9285#define SCU_RAM_QAM_ACTIVE_CONSTELLATION__A 0x831FB7
9286#define SCU_RAM_QAM_ACTIVE_CONSTELLATION__W 3
9287#define SCU_RAM_QAM_ACTIVE_CONSTELLATION__M 0x7
9288#define SCU_RAM_QAM_ACTIVE_CONSTELLATION__PRE 0x0
9289
9290#define SCU_RAM_QAM_ACTIVE_CONSTELLATION_BIT__B 0
9291#define SCU_RAM_QAM_ACTIVE_CONSTELLATION_BIT__W 3
9292#define SCU_RAM_QAM_ACTIVE_CONSTELLATION_BIT__M 0x7
9293#define SCU_RAM_QAM_ACTIVE_CONSTELLATION_BIT__PRE 0x0
9294#define SCU_RAM_QAM_ACTIVE_CONSTELLATION_BIT_UNKNOWN 0x0
9295#define SCU_RAM_QAM_ACTIVE_CONSTELLATION_BIT_QAM_16 0x3
9296#define SCU_RAM_QAM_ACTIVE_CONSTELLATION_BIT_QAM_32 0x4
9297#define SCU_RAM_QAM_ACTIVE_CONSTELLATION_BIT_QAM_64 0x5
9298#define SCU_RAM_QAM_ACTIVE_CONSTELLATION_BIT_QAM_128 0x6
9299#define SCU_RAM_QAM_ACTIVE_CONSTELLATION_BIT_QAM_256 0x7
9300
9301#define SCU_RAM_QAM_ACTIVE_INTERLEAVE__A 0x831FB8
9302#define SCU_RAM_QAM_ACTIVE_INTERLEAVE__W 8
9303#define SCU_RAM_QAM_ACTIVE_INTERLEAVE__M 0xFF
9304#define SCU_RAM_QAM_ACTIVE_INTERLEAVE__PRE 0x0
9305
9306#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT__B 0
9307#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT__W 8
9308#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT__M 0xFF
9309#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT__PRE 0x0
9310#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I128_J1 0x0
9311#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I128_J1_V2 0x1
9312#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I128_J2 0x2
9313#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I64_J2 0x3
9314#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I128_J3 0x4
9315#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I32_J4 0x5
9316#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I128_J4 0x6
9317#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I16_J8 0x7
9318#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I128_J5 0x8
9319#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I8_J16 0x9
9320#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I128_J6 0xA
9321#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I128_J7 0xC
9322#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I128_J8 0xE
9323#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I12_J17 0x10
9324#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_I5_J4 0x11
9325#define SCU_RAM_QAM_ACTIVE_INTERLEAVE_BIT_UNKNOWN 0xFE
9326
9327#define SCU_RAM_QAM_RD_RSV_4__A 0x831FB9
9328#define SCU_RAM_QAM_RD_RSV_4__W 16
9329#define SCU_RAM_QAM_RD_RSV_4__M 0xFFFF
9330#define SCU_RAM_QAM_RD_RSV_4__PRE 0x0
9331
9332#define SCU_RAM_QAM_RD_RSV_4_BIT__B 0
9333#define SCU_RAM_QAM_RD_RSV_4_BIT__W 16
9334#define SCU_RAM_QAM_RD_RSV_4_BIT__M 0xFFFF
9335#define SCU_RAM_QAM_RD_RSV_4_BIT__PRE 0x0
9336
9337#define SCU_RAM_QAM_LOCKED__A 0x831FBA
9338#define SCU_RAM_QAM_LOCKED__W 16
9339#define SCU_RAM_QAM_LOCKED__M 0xFFFF
9340#define SCU_RAM_QAM_LOCKED__PRE 0x0
9341
9342#define SCU_RAM_QAM_LOCKED_INTLEVEL__B 0
9343#define SCU_RAM_QAM_LOCKED_INTLEVEL__W 8
9344#define SCU_RAM_QAM_LOCKED_INTLEVEL__M 0xFF
9345#define SCU_RAM_QAM_LOCKED_INTLEVEL__PRE 0x0
9346#define SCU_RAM_QAM_LOCKED_INTLEVEL_NOT_LOCKED 0x0
9347#define SCU_RAM_QAM_LOCKED_INTLEVEL_AMP_OK 0x1
9348#define SCU_RAM_QAM_LOCKED_INTLEVEL_RATE_OK 0x2
9349#define SCU_RAM_QAM_LOCKED_INTLEVEL_FREQ_OK 0x3
9350#define SCU_RAM_QAM_LOCKED_INTLEVEL_UPRIGHT_OK 0x4
9351#define SCU_RAM_QAM_LOCKED_INTLEVEL_PHNOISE_OK 0x5
9352#define SCU_RAM_QAM_LOCKED_INTLEVEL_TRACK_OK 0x6
9353#define SCU_RAM_QAM_LOCKED_INTLEVEL_IMPNOISE_OK 0x7
9354
9355#define SCU_RAM_QAM_LOCKED_LOCKED__B 8
9356#define SCU_RAM_QAM_LOCKED_LOCKED__W 8
9357#define SCU_RAM_QAM_LOCKED_LOCKED__M 0xFF00
9358#define SCU_RAM_QAM_LOCKED_LOCKED__PRE 0x0
9359#define SCU_RAM_QAM_LOCKED_LOCKED_NOT_LOCKED 0x0
9360#define SCU_RAM_QAM_LOCKED_LOCKED_DEMOD_LOCKED 0x4000
9361#define SCU_RAM_QAM_LOCKED_LOCKED_LOCKED 0x8000
9362#define SCU_RAM_QAM_LOCKED_LOCKED_NEVER_LOCK 0xC000
9363
9364#define SCU_RAM_QAM_EVENTS_OCC_HI__A 0x831FBB
9365#define SCU_RAM_QAM_EVENTS_OCC_HI__W 16
9366#define SCU_RAM_QAM_EVENTS_OCC_HI__M 0xFFFF
9367#define SCU_RAM_QAM_EVENTS_OCC_HI__PRE 0x0
9368
9369#define SCU_RAM_QAM_EVENTS_OCC_HI_PREBER__B 0
9370#define SCU_RAM_QAM_EVENTS_OCC_HI_PREBER__W 1
9371#define SCU_RAM_QAM_EVENTS_OCC_HI_PREBER__M 0x1
9372#define SCU_RAM_QAM_EVENTS_OCC_HI_PREBER__PRE 0x0
9373
9374#define SCU_RAM_QAM_EVENTS_OCC_HI_PACKET_FAIL__B 1
9375#define SCU_RAM_QAM_EVENTS_OCC_HI_PACKET_FAIL__W 1
9376#define SCU_RAM_QAM_EVENTS_OCC_HI_PACKET_FAIL__M 0x2
9377#define SCU_RAM_QAM_EVENTS_OCC_HI_PACKET_FAIL__PRE 0x0
9378
9379#define SCU_RAM_QAM_EVENTS_OCC_HI_PRBS__B 2
9380#define SCU_RAM_QAM_EVENTS_OCC_HI_PRBS__W 1
9381#define SCU_RAM_QAM_EVENTS_OCC_HI_PRBS__M 0x4
9382#define SCU_RAM_QAM_EVENTS_OCC_HI_PRBS__PRE 0x0
9383
9384#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_LOCK_IN__B 3
9385#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_LOCK_IN__W 1
9386#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_LOCK_IN__M 0x8
9387#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_LOCK_IN__PRE 0x0
9388
9389#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_LOCK_OUT__B 4
9390#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_LOCK_OUT__W 1
9391#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_LOCK_OUT__M 0x10
9392#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_LOCK_OUT__PRE 0x0
9393
9394#define SCU_RAM_QAM_EVENTS_OCC_HI_POSTBER__B 5
9395#define SCU_RAM_QAM_EVENTS_OCC_HI_POSTBER__W 1
9396#define SCU_RAM_QAM_EVENTS_OCC_HI_POSTBER__M 0x20
9397#define SCU_RAM_QAM_EVENTS_OCC_HI_POSTBER__PRE 0x0
9398
9399#define SCU_RAM_QAM_EVENTS_OCC_HI_FIFO_FULL__B 6
9400#define SCU_RAM_QAM_EVENTS_OCC_HI_FIFO_FULL__W 1
9401#define SCU_RAM_QAM_EVENTS_OCC_HI_FIFO_FULL__M 0x40
9402#define SCU_RAM_QAM_EVENTS_OCC_HI_FIFO_FULL__PRE 0x0
9403
9404#define SCU_RAM_QAM_EVENTS_OCC_HI_FIFO_EMPTY__B 7
9405#define SCU_RAM_QAM_EVENTS_OCC_HI_FIFO_EMPTY__W 1
9406#define SCU_RAM_QAM_EVENTS_OCC_HI_FIFO_EMPTY__M 0x80
9407#define SCU_RAM_QAM_EVENTS_OCC_HI_FIFO_EMPTY__PRE 0x0
9408
9409#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_GRAB__B 8
9410#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_GRAB__W 1
9411#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_GRAB__M 0x100
9412#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_GRAB__PRE 0x0
9413
9414#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_CHANGE__B 9
9415#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_CHANGE__W 1
9416#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_CHANGE__M 0x200
9417#define SCU_RAM_QAM_EVENTS_OCC_HI_OC_CHANGE__PRE 0x0
9418
9419#define SCU_RAM_QAM_EVENTS_OCC_HI_LCK_CHG__B 10
9420#define SCU_RAM_QAM_EVENTS_OCC_HI_LCK_CHG__W 1
9421#define SCU_RAM_QAM_EVENTS_OCC_HI_LCK_CHG__M 0x400
9422#define SCU_RAM_QAM_EVENTS_OCC_HI_LCK_CHG__PRE 0x0
9423
9424#define SCU_RAM_QAM_EVENTS_OCC_HI_FSM_CHG__B 11
9425#define SCU_RAM_QAM_EVENTS_OCC_HI_FSM_CHG__W 1
9426#define SCU_RAM_QAM_EVENTS_OCC_HI_FSM_CHG__M 0x800
9427#define SCU_RAM_QAM_EVENTS_OCC_HI_FSM_CHG__PRE 0x0
9428
9429#define SCU_RAM_QAM_EVENTS_OCC_HI_RSV__B 12
9430#define SCU_RAM_QAM_EVENTS_OCC_HI_RSV__W 4
9431#define SCU_RAM_QAM_EVENTS_OCC_HI_RSV__M 0xF000
9432#define SCU_RAM_QAM_EVENTS_OCC_HI_RSV__PRE 0x0
9433
9434#define SCU_RAM_QAM_EVENTS_OCC_LO__A 0x831FBC
9435#define SCU_RAM_QAM_EVENTS_OCC_LO__W 16
9436#define SCU_RAM_QAM_EVENTS_OCC_LO__M 0xFFFF
9437#define SCU_RAM_QAM_EVENTS_OCC_LO__PRE 0x0
9438
9439#define SCU_RAM_QAM_EVENTS_OCC_LO_TIMER__B 0
9440#define SCU_RAM_QAM_EVENTS_OCC_LO_TIMER__W 1
9441#define SCU_RAM_QAM_EVENTS_OCC_LO_TIMER__M 0x1
9442#define SCU_RAM_QAM_EVENTS_OCC_LO_TIMER__PRE 0x0
9443
9444#define SCU_RAM_QAM_EVENTS_OCC_LO_CLIP__B 1
9445#define SCU_RAM_QAM_EVENTS_OCC_LO_CLIP__W 1
9446#define SCU_RAM_QAM_EVENTS_OCC_LO_CLIP__M 0x2
9447#define SCU_RAM_QAM_EVENTS_OCC_LO_CLIP__PRE 0x0
9448
9449#define SCU_RAM_QAM_EVENTS_OCC_LO_SENSE__B 2
9450#define SCU_RAM_QAM_EVENTS_OCC_LO_SENSE__W 1
9451#define SCU_RAM_QAM_EVENTS_OCC_LO_SENSE__M 0x4
9452#define SCU_RAM_QAM_EVENTS_OCC_LO_SENSE__PRE 0x0
9453
9454#define SCU_RAM_QAM_EVENTS_OCC_LO_POWER__B 3
9455#define SCU_RAM_QAM_EVENTS_OCC_LO_POWER__W 1
9456#define SCU_RAM_QAM_EVENTS_OCC_LO_POWER__M 0x8
9457#define SCU_RAM_QAM_EVENTS_OCC_LO_POWER__PRE 0x0
9458
9459#define SCU_RAM_QAM_EVENTS_OCC_LO_MEDIAN__B 4
9460#define SCU_RAM_QAM_EVENTS_OCC_LO_MEDIAN__W 1
9461#define SCU_RAM_QAM_EVENTS_OCC_LO_MEDIAN__M 0x10
9462#define SCU_RAM_QAM_EVENTS_OCC_LO_MEDIAN__PRE 0x0
9463
9464#define SCU_RAM_QAM_EVENTS_OCC_LO_MER__B 5
9465#define SCU_RAM_QAM_EVENTS_OCC_LO_MER__W 1
9466#define SCU_RAM_QAM_EVENTS_OCC_LO_MER__M 0x20
9467#define SCU_RAM_QAM_EVENTS_OCC_LO_MER__PRE 0x0
9468
9469#define SCU_RAM_QAM_EVENTS_OCC_LO_LOOP__B 6
9470#define SCU_RAM_QAM_EVENTS_OCC_LO_LOOP__W 1
9471#define SCU_RAM_QAM_EVENTS_OCC_LO_LOOP__M 0x40
9472#define SCU_RAM_QAM_EVENTS_OCC_LO_LOOP__PRE 0x0
9473
9474#define SCU_RAM_QAM_EVENTS_OCC_LO_FREQWRAP__B 7
9475#define SCU_RAM_QAM_EVENTS_OCC_LO_FREQWRAP__W 1
9476#define SCU_RAM_QAM_EVENTS_OCC_LO_FREQWRAP__M 0x80
9477#define SCU_RAM_QAM_EVENTS_OCC_LO_FREQWRAP__PRE 0x0
9478
9479#define SCU_RAM_QAM_EVENTS_OCC_LO_SER__B 8
9480#define SCU_RAM_QAM_EVENTS_OCC_LO_SER__W 1
9481#define SCU_RAM_QAM_EVENTS_OCC_LO_SER__M 0x100
9482#define SCU_RAM_QAM_EVENTS_OCC_LO_SER__PRE 0x0
9483
9484#define SCU_RAM_QAM_EVENTS_OCC_LO_VD_LOCK_IN__B 9
9485#define SCU_RAM_QAM_EVENTS_OCC_LO_VD_LOCK_IN__W 1
9486#define SCU_RAM_QAM_EVENTS_OCC_LO_VD_LOCK_IN__M 0x200
9487#define SCU_RAM_QAM_EVENTS_OCC_LO_VD_LOCK_IN__PRE 0x0
9488
9489#define SCU_RAM_QAM_EVENTS_OCC_LO_SY_LOCK_IN__B 10
9490#define SCU_RAM_QAM_EVENTS_OCC_LO_SY_LOCK_IN__W 1
9491#define SCU_RAM_QAM_EVENTS_OCC_LO_SY_LOCK_IN__M 0x400
9492#define SCU_RAM_QAM_EVENTS_OCC_LO_SY_LOCK_IN__PRE 0x0
9493
9494#define SCU_RAM_QAM_EVENTS_OCC_LO_SY_LOCK_OUT__B 11
9495#define SCU_RAM_QAM_EVENTS_OCC_LO_SY_LOCK_OUT__W 1
9496#define SCU_RAM_QAM_EVENTS_OCC_LO_SY_LOCK_OUT__M 0x800
9497#define SCU_RAM_QAM_EVENTS_OCC_LO_SY_LOCK_OUT__PRE 0x0
9498
9499#define SCU_RAM_QAM_EVENTS_OCC_LO_SY_TIME_OUT__B 12
9500#define SCU_RAM_QAM_EVENTS_OCC_LO_SY_TIME_OUT__W 1
9501#define SCU_RAM_QAM_EVENTS_OCC_LO_SY_TIME_OUT__M 0x1000
9502#define SCU_RAM_QAM_EVENTS_OCC_LO_SY_TIME_OUT__PRE 0x0
9503
9504#define SCU_RAM_QAM_EVENTS_OCC_LO_SYNCWORD__B 13
9505#define SCU_RAM_QAM_EVENTS_OCC_LO_SYNCWORD__W 1
9506#define SCU_RAM_QAM_EVENTS_OCC_LO_SYNCWORD__M 0x2000
9507#define SCU_RAM_QAM_EVENTS_OCC_LO_SYNCWORD__PRE 0x0
9508
9509#define SCU_RAM_QAM_EVENTS_OCC_LO_DI_LOCK_IN__B 14
9510#define SCU_RAM_QAM_EVENTS_OCC_LO_DI_LOCK_IN__W 1
9511#define SCU_RAM_QAM_EVENTS_OCC_LO_DI_LOCK_IN__M 0x4000
9512#define SCU_RAM_QAM_EVENTS_OCC_LO_DI_LOCK_IN__PRE 0x0
9513
9514#define SCU_RAM_QAM_EVENTS_OCC_LO_DI_LOCK_OUT__B 15
9515#define SCU_RAM_QAM_EVENTS_OCC_LO_DI_LOCK_OUT__W 1
9516#define SCU_RAM_QAM_EVENTS_OCC_LO_DI_LOCK_OUT__M 0x8000
9517#define SCU_RAM_QAM_EVENTS_OCC_LO_DI_LOCK_OUT__PRE 0x0
9518
9519#define SCU_RAM_QAM_EVENTS_SCHED_HI__A 0x831FBD
9520#define SCU_RAM_QAM_EVENTS_SCHED_HI__W 16
9521#define SCU_RAM_QAM_EVENTS_SCHED_HI__M 0xFFFF
9522#define SCU_RAM_QAM_EVENTS_SCHED_HI__PRE 0x0
9523
9524#define SCU_RAM_QAM_EVENTS_SCHED_HI_BIT__B 0
9525#define SCU_RAM_QAM_EVENTS_SCHED_HI_BIT__W 16
9526#define SCU_RAM_QAM_EVENTS_SCHED_HI_BIT__M 0xFFFF
9527#define SCU_RAM_QAM_EVENTS_SCHED_HI_BIT__PRE 0x0
9528
9529#define SCU_RAM_QAM_EVENTS_SCHED_LO__A 0x831FBE
9530#define SCU_RAM_QAM_EVENTS_SCHED_LO__W 16
9531#define SCU_RAM_QAM_EVENTS_SCHED_LO__M 0xFFFF
9532#define SCU_RAM_QAM_EVENTS_SCHED_LO__PRE 0x0
9533
9534#define SCU_RAM_QAM_EVENTS_SCHED_LO_BIT__B 0
9535#define SCU_RAM_QAM_EVENTS_SCHED_LO_BIT__W 16
9536#define SCU_RAM_QAM_EVENTS_SCHED_LO_BIT__M 0xFFFF
9537#define SCU_RAM_QAM_EVENTS_SCHED_LO_BIT__PRE 0x0
9538
9539#define SCU_RAM_QAM_TASKLETS_SCHED__A 0x831FBF
9540#define SCU_RAM_QAM_TASKLETS_SCHED__W 16
9541#define SCU_RAM_QAM_TASKLETS_SCHED__M 0xFFFF
9542#define SCU_RAM_QAM_TASKLETS_SCHED__PRE 0x0
9543
9544#define SCU_RAM_QAM_TASKLETS_SCHED_BIT__B 0
9545#define SCU_RAM_QAM_TASKLETS_SCHED_BIT__W 16
9546#define SCU_RAM_QAM_TASKLETS_SCHED_BIT__M 0xFFFF
9547#define SCU_RAM_QAM_TASKLETS_SCHED_BIT__PRE 0x0
9548
9549#define SCU_RAM_QAM_TASKLETS_RUN__A 0x831FC0
9550#define SCU_RAM_QAM_TASKLETS_RUN__W 16
9551#define SCU_RAM_QAM_TASKLETS_RUN__M 0xFFFF
9552#define SCU_RAM_QAM_TASKLETS_RUN__PRE 0x0
9553
9554#define SCU_RAM_QAM_TASKLETS_RUN_BIT__B 0
9555#define SCU_RAM_QAM_TASKLETS_RUN_BIT__W 16
9556#define SCU_RAM_QAM_TASKLETS_RUN_BIT__M 0xFFFF
9557#define SCU_RAM_QAM_TASKLETS_RUN_BIT__PRE 0x0
9558
9559#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_HI__A 0x831FC1
9560#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_HI__W 16
9561#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_HI__M 0xFFFF
9562#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_HI__PRE 0x0
9563
9564#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_HI_BIT__B 0
9565#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_HI_BIT__W 16
9566#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_HI_BIT__M 0xFFFF
9567#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_HI_BIT__PRE 0x0
9568
9569#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_LO__A 0x831FC2
9570#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_LO__W 16
9571#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_LO__M 0xFFFF
9572#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_LO__PRE 0x0
9573
9574#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_LO_BIT__B 0
9575#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_LO_BIT__W 16
9576#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_LO_BIT__M 0xFFFF
9577#define SCU_RAM_QAM_ACTIVE_SYM_RCRATE_LO_BIT__PRE 0x0
9578
9579#define SCU_RAM_QAM_RD_RSV_5__A 0x831FC3
9580#define SCU_RAM_QAM_RD_RSV_5__W 16
9581#define SCU_RAM_QAM_RD_RSV_5__M 0xFFFF
9582#define SCU_RAM_QAM_RD_RSV_5__PRE 0x0
9583
9584#define SCU_RAM_QAM_RD_RSV_5_BIT__B 0
9585#define SCU_RAM_QAM_RD_RSV_5_BIT__W 16
9586#define SCU_RAM_QAM_RD_RSV_5_BIT__M 0xFFFF
9587#define SCU_RAM_QAM_RD_RSV_5_BIT__PRE 0x0
9588
9589#define SCU_RAM_QAM_RD_RSV_6__A 0x831FC4
9590#define SCU_RAM_QAM_RD_RSV_6__W 16
9591#define SCU_RAM_QAM_RD_RSV_6__M 0xFFFF
9592#define SCU_RAM_QAM_RD_RSV_6__PRE 0x0
9593
9594#define SCU_RAM_QAM_RD_RSV_6_BIT__B 0
9595#define SCU_RAM_QAM_RD_RSV_6_BIT__W 16
9596#define SCU_RAM_QAM_RD_RSV_6_BIT__M 0xFFFF
9597#define SCU_RAM_QAM_RD_RSV_6_BIT__PRE 0x0
9598
9599#define SCU_RAM_QAM_RD_RSV_7__A 0x831FC5
9600#define SCU_RAM_QAM_RD_RSV_7__W 16
9601#define SCU_RAM_QAM_RD_RSV_7__M 0xFFFF
9602#define SCU_RAM_QAM_RD_RSV_7__PRE 0x0
9603
9604#define SCU_RAM_QAM_RD_RSV_7_BIT__B 0
9605#define SCU_RAM_QAM_RD_RSV_7_BIT__W 16
9606#define SCU_RAM_QAM_RD_RSV_7_BIT__M 0xFFFF
9607#define SCU_RAM_QAM_RD_RSV_7_BIT__PRE 0x0
9608
9609#define SCU_RAM_QAM_RD_RSV_8__A 0x831FC6
9610#define SCU_RAM_QAM_RD_RSV_8__W 16
9611#define SCU_RAM_QAM_RD_RSV_8__M 0xFFFF
9612#define SCU_RAM_QAM_RD_RSV_8__PRE 0x0
9613
9614#define SCU_RAM_QAM_RD_RSV_8_BIT__B 0
9615#define SCU_RAM_QAM_RD_RSV_8_BIT__W 16
9616#define SCU_RAM_QAM_RD_RSV_8_BIT__M 0xFFFF
9617#define SCU_RAM_QAM_RD_RSV_8_BIT__PRE 0x0
9618
9619#define SCU_RAM_QAM_RD_RSV_9__A 0x831FC7
9620#define SCU_RAM_QAM_RD_RSV_9__W 16
9621#define SCU_RAM_QAM_RD_RSV_9__M 0xFFFF
9622#define SCU_RAM_QAM_RD_RSV_9__PRE 0x0
9623
9624#define SCU_RAM_QAM_RD_RSV_9_BIT__B 0
9625#define SCU_RAM_QAM_RD_RSV_9_BIT__W 16
9626#define SCU_RAM_QAM_RD_RSV_9_BIT__M 0xFFFF
9627#define SCU_RAM_QAM_RD_RSV_9_BIT__PRE 0x0
9628
9629#define SCU_RAM_QAM_RD_RSV_10__A 0x831FC8
9630#define SCU_RAM_QAM_RD_RSV_10__W 16
9631#define SCU_RAM_QAM_RD_RSV_10__M 0xFFFF
9632#define SCU_RAM_QAM_RD_RSV_10__PRE 0x0
9633
9634#define SCU_RAM_QAM_RD_RSV_10_BIT__B 0
9635#define SCU_RAM_QAM_RD_RSV_10_BIT__W 16
9636#define SCU_RAM_QAM_RD_RSV_10_BIT__M 0xFFFF
9637#define SCU_RAM_QAM_RD_RSV_10_BIT__PRE 0x0
9638
9639#define SCU_RAM_QAM_AGC_TPOW_OFFS__A 0x831FC9
9640#define SCU_RAM_QAM_AGC_TPOW_OFFS__W 16
9641#define SCU_RAM_QAM_AGC_TPOW_OFFS__M 0xFFFF
9642#define SCU_RAM_QAM_AGC_TPOW_OFFS__PRE 0x0
9643
9644#define SCU_RAM_QAM_AGC_TPOW_OFFS_BIT__B 0
9645#define SCU_RAM_QAM_AGC_TPOW_OFFS_BIT__W 16
9646#define SCU_RAM_QAM_AGC_TPOW_OFFS_BIT__M 0xFFFF
9647#define SCU_RAM_QAM_AGC_TPOW_OFFS_BIT__PRE 0x0
9648
9649#define SCU_RAM_QAM_FSM_STATE__A 0x831FCA
9650#define SCU_RAM_QAM_FSM_STATE__W 4
9651#define SCU_RAM_QAM_FSM_STATE__M 0xF
9652#define SCU_RAM_QAM_FSM_STATE__PRE 0x0
9653
9654#define SCU_RAM_QAM_FSM_STATE_BIT__B 0
9655#define SCU_RAM_QAM_FSM_STATE_BIT__W 4
9656#define SCU_RAM_QAM_FSM_STATE_BIT__M 0xF
9657#define SCU_RAM_QAM_FSM_STATE_BIT__PRE 0x0
9658#define SCU_RAM_QAM_FSM_STATE_BIT_HUNTING_AMP 0x0
9659#define SCU_RAM_QAM_FSM_STATE_BIT_HUNTING_RATE 0x1
9660#define SCU_RAM_QAM_FSM_STATE_BIT_HUNTING_FREQ 0x2
9661#define SCU_RAM_QAM_FSM_STATE_BIT_HUNTING_UPRIGHT 0x3
9662#define SCU_RAM_QAM_FSM_STATE_BIT_HUNTING_PHASE 0x4
9663#define SCU_RAM_QAM_FSM_STATE_BIT_TRACKING_PHNOISE 0x5
9664#define SCU_RAM_QAM_FSM_STATE_BIT_TRACKING 0x6
9665#define SCU_RAM_QAM_FSM_STATE_BIT_TRACKING_BURST 0x7
9666
9667#define SCU_RAM_QAM_FSM_STATE_NEW__A 0x831FCB
9668#define SCU_RAM_QAM_FSM_STATE_NEW__W 4
9669#define SCU_RAM_QAM_FSM_STATE_NEW__M 0xF
9670#define SCU_RAM_QAM_FSM_STATE_NEW__PRE 0x0
9671
9672#define SCU_RAM_QAM_FSM_STATE_NEW_BIT__B 0
9673#define SCU_RAM_QAM_FSM_STATE_NEW_BIT__W 4
9674#define SCU_RAM_QAM_FSM_STATE_NEW_BIT__M 0xF
9675#define SCU_RAM_QAM_FSM_STATE_NEW_BIT__PRE 0x0
9676#define SCU_RAM_QAM_FSM_STATE_NEW_BIT_HUNTING_AMP 0x0
9677#define SCU_RAM_QAM_FSM_STATE_NEW_BIT_HUNTING_RATE 0x1
9678#define SCU_RAM_QAM_FSM_STATE_NEW_BIT_HUNTING_FREQ 0x2
9679#define SCU_RAM_QAM_FSM_STATE_NEW_BIT_HUNTING_UPRIGHT 0x3
9680#define SCU_RAM_QAM_FSM_STATE_NEW_BIT_HUNTING_PHASE 0x4
9681#define SCU_RAM_QAM_FSM_STATE_NEW_BIT_TRACKING_PHNOISE 0x5
9682#define SCU_RAM_QAM_FSM_STATE_NEW_BIT_TRACKING 0x6
9683#define SCU_RAM_QAM_FSM_STATE_NEW_BIT_TRACKING_BURST 0x7
9684
9685#define SCU_RAM_QAM_FSM_LOCK_FLAGS__A 0x831FCC
9686#define SCU_RAM_QAM_FSM_LOCK_FLAGS__W 9
9687#define SCU_RAM_QAM_FSM_LOCK_FLAGS__M 0x1FF
9688#define SCU_RAM_QAM_FSM_LOCK_FLAGS__PRE 0x0
9689
9690#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_AMP__B 0
9691#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_AMP__W 1
9692#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_AMP__M 0x1
9693#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_AMP__PRE 0x0
9694
9695#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_RATEVAR__B 1
9696#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_RATEVAR__W 1
9697#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_RATEVAR__M 0x2
9698#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_RATEVAR__PRE 0x0
9699
9700#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_RADIUS__B 2
9701#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_RADIUS__W 1
9702#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_RADIUS__M 0x4
9703#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_RADIUS__PRE 0x0
9704
9705#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_FREQ__B 3
9706#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_FREQ__W 1
9707#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_FREQ__M 0x8
9708#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_FREQ__PRE 0x0
9709
9710#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_FREQVAR__B 4
9711#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_FREQVAR__W 1
9712#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_FREQVAR__M 0x10
9713#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_FREQVAR__PRE 0x0
9714
9715#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_CPHASE__B 5
9716#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_CPHASE__W 1
9717#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_CPHASE__M 0x20
9718#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_CPHASE__PRE 0x0
9719
9720#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_UPRIGHT__B 6
9721#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_UPRIGHT__W 1
9722#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_UPRIGHT__M 0x40
9723#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_UPRIGHT__PRE 0x0
9724
9725#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_PHASE__B 7
9726#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_PHASE__W 1
9727#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_PHASE__M 0x80
9728#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_PHASE__PRE 0x0
9729
9730#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_MEDIAN__B 8
9731#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_MEDIAN__W 1
9732#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_MEDIAN__M 0x100
9733#define SCU_RAM_QAM_FSM_LOCK_FLAGS_LCK_MEDIAN__PRE 0x0
9734
9735#define SCU_RAM_QAM_FSM_RATE_VARIATION__A 0x831FCD
9736#define SCU_RAM_QAM_FSM_RATE_VARIATION__W 16
9737#define SCU_RAM_QAM_FSM_RATE_VARIATION__M 0xFFFF
9738#define SCU_RAM_QAM_FSM_RATE_VARIATION__PRE 0x0
9739
9740#define SCU_RAM_QAM_FSM_RATE_VARIATION_BIT__B 0
9741#define SCU_RAM_QAM_FSM_RATE_VARIATION_BIT__W 16
9742#define SCU_RAM_QAM_FSM_RATE_VARIATION_BIT__M 0xFFFF
9743#define SCU_RAM_QAM_FSM_RATE_VARIATION_BIT__PRE 0x0
9744
9745#define SCU_RAM_QAM_FSM_FREQ_VARIATION__A 0x831FCE
9746#define SCU_RAM_QAM_FSM_FREQ_VARIATION__W 16
9747#define SCU_RAM_QAM_FSM_FREQ_VARIATION__M 0xFFFF
9748#define SCU_RAM_QAM_FSM_FREQ_VARIATION__PRE 0x0
9749
9750#define SCU_RAM_QAM_FSM_FREQ_VARIATION_BIT__B 0
9751#define SCU_RAM_QAM_FSM_FREQ_VARIATION_BIT__W 16
9752#define SCU_RAM_QAM_FSM_FREQ_VARIATION_BIT__M 0xFFFF
9753#define SCU_RAM_QAM_FSM_FREQ_VARIATION_BIT__PRE 0x0
9754
9755#define SCU_RAM_QAM_ERR_STATE__A 0x831FCF
9756#define SCU_RAM_QAM_ERR_STATE__W 4
9757#define SCU_RAM_QAM_ERR_STATE__M 0xF
9758#define SCU_RAM_QAM_ERR_STATE__PRE 0x0
9759
9760#define SCU_RAM_QAM_ERR_STATE_BIT__B 0
9761#define SCU_RAM_QAM_ERR_STATE_BIT__W 4
9762#define SCU_RAM_QAM_ERR_STATE_BIT__M 0xF
9763#define SCU_RAM_QAM_ERR_STATE_BIT__PRE 0x0
9764#define SCU_RAM_QAM_ERR_STATE_BIT_HUNTING_AMP 0x0
9765#define SCU_RAM_QAM_ERR_STATE_BIT_HUNTING_RATE 0x1
9766#define SCU_RAM_QAM_ERR_STATE_BIT_HUNTING_FREQ 0x2
9767#define SCU_RAM_QAM_ERR_STATE_BIT_HUNTING_UPRIGHT 0x3
9768#define SCU_RAM_QAM_ERR_STATE_BIT_HUNTING_PHASE 0x4
9769#define SCU_RAM_QAM_ERR_STATE_BIT_TRACKING_PHNOISE 0x5
9770#define SCU_RAM_QAM_ERR_STATE_BIT_TRACKING 0x6
9771#define SCU_RAM_QAM_ERR_STATE_BIT_TRACKING_BURST 0x7
9772
9773#define SCU_RAM_QAM_ERR_LOCK_FLAGS__A 0x831FD0
9774#define SCU_RAM_QAM_ERR_LOCK_FLAGS__W 9
9775#define SCU_RAM_QAM_ERR_LOCK_FLAGS__M 0x1FF
9776#define SCU_RAM_QAM_ERR_LOCK_FLAGS__PRE 0x0
9777
9778#define SCU_RAM_QAM_ERR_LOCK_FLAGS_LCK_AMP__B 0
9779#define SCU_RAM_QAM_ERR_LOCK_FLAGS_LCK_AMP__W 1
9780#define SCU_RAM_QAM_ERR_LOCK_FLAGS_LCK_AMP__M 0x1
9781#define SCU_RAM_QAM_ERR_LOCK_FLAGS_LCK_AMP__PRE 0x0
9782
9783#define SCU_RAM_QAM_EQ_LOCK__A 0x831FD1
9784#define SCU_RAM_QAM_EQ_LOCK__W 1
9785#define SCU_RAM_QAM_EQ_LOCK__M 0x1
9786#define SCU_RAM_QAM_EQ_LOCK__PRE 0x0
9787
9788#define SCU_RAM_QAM_EQ_LOCK_BIT__B 0
9789#define SCU_RAM_QAM_EQ_LOCK_BIT__W 1
9790#define SCU_RAM_QAM_EQ_LOCK_BIT__M 0x1
9791#define SCU_RAM_QAM_EQ_LOCK_BIT__PRE 0x0
9792
9793#define SCU_RAM_QAM_EQ_STATE__A 0x831FD2
9794#define SCU_RAM_QAM_EQ_STATE__W 16
9795#define SCU_RAM_QAM_EQ_STATE__M 0xFFFF
9796#define SCU_RAM_QAM_EQ_STATE__PRE 0x0
9797
9798#define SCU_RAM_QAM_EQ_STATE_BIT__B 0
9799#define SCU_RAM_QAM_EQ_STATE_BIT__W 16
9800#define SCU_RAM_QAM_EQ_STATE_BIT__M 0xFFFF
9801#define SCU_RAM_QAM_EQ_STATE_BIT__PRE 0x0
9802
9803#define SCU_RAM_QAM_RD_RSV_0__A 0x831FD3
9804#define SCU_RAM_QAM_RD_RSV_0__W 16
9805#define SCU_RAM_QAM_RD_RSV_0__M 0xFFFF
9806#define SCU_RAM_QAM_RD_RSV_0__PRE 0x0
9807
9808#define SCU_RAM_QAM_RD_RSV_0_BIT__B 0
9809#define SCU_RAM_QAM_RD_RSV_0_BIT__W 16
9810#define SCU_RAM_QAM_RD_RSV_0_BIT__M 0xFFFF
9811#define SCU_RAM_QAM_RD_RSV_0_BIT__PRE 0x0
9812
9813#define SCU_RAM_QAM_RD_RSV_1__A 0x831FD4
9814#define SCU_RAM_QAM_RD_RSV_1__W 16
9815#define SCU_RAM_QAM_RD_RSV_1__M 0xFFFF
9816#define SCU_RAM_QAM_RD_RSV_1__PRE 0x0
9817
9818#define SCU_RAM_QAM_RD_RSV_1_BIT__B 0
9819#define SCU_RAM_QAM_RD_RSV_1_BIT__W 16
9820#define SCU_RAM_QAM_RD_RSV_1_BIT__M 0xFFFF
9821#define SCU_RAM_QAM_RD_RSV_1_BIT__PRE 0x0
9822
9823#define SCU_RAM_QAM_RD_RSV_2__A 0x831FD5
9824#define SCU_RAM_QAM_RD_RSV_2__W 16
9825#define SCU_RAM_QAM_RD_RSV_2__M 0xFFFF
9826#define SCU_RAM_QAM_RD_RSV_2__PRE 0x0
9827
9828#define SCU_RAM_QAM_RD_RSV_2_BIT__B 0
9829#define SCU_RAM_QAM_RD_RSV_2_BIT__W 16
9830#define SCU_RAM_QAM_RD_RSV_2_BIT__M 0xFFFF
9831#define SCU_RAM_QAM_RD_RSV_2_BIT__PRE 0x0
9832
9833#define SCU_RAM_QAM_RD_RSV_3__A 0x831FD6
9834#define SCU_RAM_QAM_RD_RSV_3__W 16
9835#define SCU_RAM_QAM_RD_RSV_3__M 0xFFFF
9836#define SCU_RAM_QAM_RD_RSV_3__PRE 0x0
9837
9838#define SCU_RAM_QAM_RD_RSV_3_BIT__B 0
9839#define SCU_RAM_QAM_RD_RSV_3_BIT__W 16
9840#define SCU_RAM_QAM_RD_RSV_3_BIT__M 0xFFFF
9841#define SCU_RAM_QAM_RD_RSV_3_BIT__PRE 0x0
9842
9843#define SCU_RAM_VSB_CTL_MODE__A 0x831FD7
9844#define SCU_RAM_VSB_CTL_MODE__W 2
9845#define SCU_RAM_VSB_CTL_MODE__M 0x3
9846#define SCU_RAM_VSB_CTL_MODE__PRE 0x0
9847
9848#define SCU_RAM_VSB_CTL_MODE_VSB_CTL_MODE_AGC__B 0
9849#define SCU_RAM_VSB_CTL_MODE_VSB_CTL_MODE_AGC__W 1
9850#define SCU_RAM_VSB_CTL_MODE_VSB_CTL_MODE_AGC__M 0x1
9851#define SCU_RAM_VSB_CTL_MODE_VSB_CTL_MODE_AGC__PRE 0x0
9852#define SCU_RAM_VSB_CTL_MODE_VSB_CTL_MODE_AGC_OFF 0x0
9853#define SCU_RAM_VSB_CTL_MODE_VSB_CTL_MODE_AGC_ON 0x1
9854
9855#define SCU_RAM_VSB_CTL_MODE_VSB_CTL_MODE_MON__B 1
9856#define SCU_RAM_VSB_CTL_MODE_VSB_CTL_MODE_MON__W 1
9857#define SCU_RAM_VSB_CTL_MODE_VSB_CTL_MODE_MON__M 0x2
9858#define SCU_RAM_VSB_CTL_MODE_VSB_CTL_MODE_MON__PRE 0x0
9859#define SCU_RAM_VSB_CTL_MODE_VSB_CTL_MODE_MON_OFF 0x0
9860#define SCU_RAM_VSB_CTL_MODE_VSB_CTL_MODE_MON_ON 0x2
9861
9862#define SCU_RAM_VSB_NOTCH_THRESHOLD__A 0x831FD8
9863#define SCU_RAM_VSB_NOTCH_THRESHOLD__W 16
9864#define SCU_RAM_VSB_NOTCH_THRESHOLD__M 0xFFFF
9865#define SCU_RAM_VSB_NOTCH_THRESHOLD__PRE 0x0
9866
9867#define SCU_RAM_VSB_RSV_0__A 0x831FD9
9868#define SCU_RAM_VSB_RSV_0__W 16
9869#define SCU_RAM_VSB_RSV_0__M 0xFFFF
9870#define SCU_RAM_VSB_RSV_0__PRE 0x0
9871
9872#define SCU_RAM_VSB_RSV_1__A 0x831FDA
9873#define SCU_RAM_VSB_RSV_1__W 16
9874#define SCU_RAM_VSB_RSV_1__M 0xFFFF
9875#define SCU_RAM_VSB_RSV_1__PRE 0x0
9876
9877#define SCU_RAM_VSB_RSV_2__A 0x831FDB
9878#define SCU_RAM_VSB_RSV_2__W 16
9879#define SCU_RAM_VSB_RSV_2__M 0xFFFF
9880#define SCU_RAM_VSB_RSV_2__PRE 0x0
9881
9882#define SCU_RAM_VSB_RSV_3__A 0x831FDC
9883#define SCU_RAM_VSB_RSV_3__W 16
9884#define SCU_RAM_VSB_RSV_3__M 0xFFFF
9885#define SCU_RAM_VSB_RSV_3__PRE 0x0
9886
9887#define SCU_RAM_VSB_RSV_4__A 0x831FDD
9888#define SCU_RAM_VSB_RSV_4__W 16
9889#define SCU_RAM_VSB_RSV_4__M 0xFFFF
9890#define SCU_RAM_VSB_RSV_4__PRE 0x0
9891
9892#define SCU_RAM_VSB_RSV_5__A 0x831FDE
9893#define SCU_RAM_VSB_RSV_5__W 16
9894#define SCU_RAM_VSB_RSV_5__M 0xFFFF
9895#define SCU_RAM_VSB_RSV_5__PRE 0x0
9896
9897#define SCU_RAM_VSB_RSV_6__A 0x831FDF
9898#define SCU_RAM_VSB_RSV_6__W 16
9899#define SCU_RAM_VSB_RSV_6__M 0xFFFF
9900#define SCU_RAM_VSB_RSV_6__PRE 0x0
9901
9902#define SCU_RAM_VSB_RSV_7__A 0x831FE0
9903#define SCU_RAM_VSB_RSV_7__W 16
9904#define SCU_RAM_VSB_RSV_7__M 0xFFFF
9905#define SCU_RAM_VSB_RSV_7__PRE 0x0
9906
9907#define SCU_RAM_VSB_RSV_8__A 0x831FE1
9908#define SCU_RAM_VSB_RSV_8__W 16
9909#define SCU_RAM_VSB_RSV_8__M 0xFFFF
9910#define SCU_RAM_VSB_RSV_8__PRE 0x0
9911
9912#define SCU_RAM_VSB_RSV_9__A 0x831FE2
9913#define SCU_RAM_VSB_RSV_9__W 16
9914#define SCU_RAM_VSB_RSV_9__M 0xFFFF
9915#define SCU_RAM_VSB_RSV_9__PRE 0x0
9916
9917#define SCU_RAM_VSB_RSV_10__A 0x831FE3
9918#define SCU_RAM_VSB_RSV_10__W 16
9919#define SCU_RAM_VSB_RSV_10__M 0xFFFF
9920#define SCU_RAM_VSB_RSV_10__PRE 0x0
9921
9922#define SCU_RAM_VSB_RSV_11__A 0x831FE4
9923#define SCU_RAM_VSB_RSV_11__W 16
9924#define SCU_RAM_VSB_RSV_11__M 0xFFFF
9925#define SCU_RAM_VSB_RSV_11__PRE 0x0
9926
9927#define SCU_RAM_VSB_RSV_12__A 0x831FE5
9928#define SCU_RAM_VSB_RSV_12__W 16
9929#define SCU_RAM_VSB_RSV_12__M 0xFFFF
9930#define SCU_RAM_VSB_RSV_12__PRE 0x0
9931
9932#define SCU_RAM_VSB_RSV_13__A 0x831FE6
9933#define SCU_RAM_VSB_RSV_13__W 16
9934#define SCU_RAM_VSB_RSV_13__M 0xFFFF
9935#define SCU_RAM_VSB_RSV_13__PRE 0x0
9936
9937#define SCU_RAM_VSB_AGC_POW_TGT__A 0x831FE7
9938#define SCU_RAM_VSB_AGC_POW_TGT__W 15
9939#define SCU_RAM_VSB_AGC_POW_TGT__M 0x7FFF
9940#define SCU_RAM_VSB_AGC_POW_TGT__PRE 0x0
9941
9942#define SCU_RAM_VSB_OUTER_LOOP_CYCLE__A 0x831FE8
9943#define SCU_RAM_VSB_OUTER_LOOP_CYCLE__W 8
9944#define SCU_RAM_VSB_OUTER_LOOP_CYCLE__M 0xFF
9945#define SCU_RAM_VSB_OUTER_LOOP_CYCLE__PRE 0x0
9946
9947#define SCU_RAM_VSB_FIELD_NUMBER__A 0x831FE9
9948#define SCU_RAM_VSB_FIELD_NUMBER__W 9
9949#define SCU_RAM_VSB_FIELD_NUMBER__M 0x1FF
9950#define SCU_RAM_VSB_FIELD_NUMBER__PRE 0x0
9951
9952#define SCU_RAM_VSB_SEGMENT_NUMBER__A 0x831FEA
9953#define SCU_RAM_VSB_SEGMENT_NUMBER__W 10
9954#define SCU_RAM_VSB_SEGMENT_NUMBER__M 0x3FF
9955#define SCU_RAM_VSB_SEGMENT_NUMBER__PRE 0x0
9956
9957#define SCU_RAM_DRIVER_VER_HI__A 0x831FEB
9958#define SCU_RAM_DRIVER_VER_HI__W 16
9959#define SCU_RAM_DRIVER_VER_HI__M 0xFFFF
9960#define SCU_RAM_DRIVER_VER_HI__PRE 0x0
9961
9962#define SCU_RAM_DRIVER_VER_LO__A 0x831FEC
9963#define SCU_RAM_DRIVER_VER_LO__W 16
9964#define SCU_RAM_DRIVER_VER_LO__M 0xFFFF
9965#define SCU_RAM_DRIVER_VER_LO__PRE 0x0
9966
9967#define SCU_RAM_PARAM_15__A 0x831FED
9968#define SCU_RAM_PARAM_15__W 16
9969#define SCU_RAM_PARAM_15__M 0xFFFF
9970#define SCU_RAM_PARAM_15__PRE 0x0
9971
9972#define SCU_RAM_PARAM_14__A 0x831FEE
9973#define SCU_RAM_PARAM_14__W 16
9974#define SCU_RAM_PARAM_14__M 0xFFFF
9975#define SCU_RAM_PARAM_14__PRE 0x0
9976
9977#define SCU_RAM_PARAM_13__A 0x831FEF
9978#define SCU_RAM_PARAM_13__W 16
9979#define SCU_RAM_PARAM_13__M 0xFFFF
9980#define SCU_RAM_PARAM_13__PRE 0x0
9981
9982#define SCU_RAM_PARAM_12__A 0x831FF0
9983#define SCU_RAM_PARAM_12__W 16
9984#define SCU_RAM_PARAM_12__M 0xFFFF
9985#define SCU_RAM_PARAM_12__PRE 0x0
9986
9987#define SCU_RAM_PARAM_11__A 0x831FF1
9988#define SCU_RAM_PARAM_11__W 16
9989#define SCU_RAM_PARAM_11__M 0xFFFF
9990#define SCU_RAM_PARAM_11__PRE 0x0
9991
9992#define SCU_RAM_PARAM_10__A 0x831FF2
9993#define SCU_RAM_PARAM_10__W 16
9994#define SCU_RAM_PARAM_10__M 0xFFFF
9995#define SCU_RAM_PARAM_10__PRE 0x0
9996
9997#define SCU_RAM_PARAM_9__A 0x831FF3
9998#define SCU_RAM_PARAM_9__W 16
9999#define SCU_RAM_PARAM_9__M 0xFFFF
10000#define SCU_RAM_PARAM_9__PRE 0x0
10001
10002#define SCU_RAM_PARAM_8__A 0x831FF4
10003#define SCU_RAM_PARAM_8__W 16
10004#define SCU_RAM_PARAM_8__M 0xFFFF
10005#define SCU_RAM_PARAM_8__PRE 0x0
10006
10007#define SCU_RAM_PARAM_7__A 0x831FF5
10008#define SCU_RAM_PARAM_7__W 16
10009#define SCU_RAM_PARAM_7__M 0xFFFF
10010#define SCU_RAM_PARAM_7__PRE 0x0
10011
10012#define SCU_RAM_PARAM_6__A 0x831FF6
10013#define SCU_RAM_PARAM_6__W 16
10014#define SCU_RAM_PARAM_6__M 0xFFFF
10015#define SCU_RAM_PARAM_6__PRE 0x0
10016
10017#define SCU_RAM_PARAM_5__A 0x831FF7
10018#define SCU_RAM_PARAM_5__W 16
10019#define SCU_RAM_PARAM_5__M 0xFFFF
10020#define SCU_RAM_PARAM_5__PRE 0x0
10021
10022#define SCU_RAM_PARAM_4__A 0x831FF8
10023#define SCU_RAM_PARAM_4__W 16
10024#define SCU_RAM_PARAM_4__M 0xFFFF
10025#define SCU_RAM_PARAM_4__PRE 0x0
10026
10027#define SCU_RAM_PARAM_3__A 0x831FF9
10028#define SCU_RAM_PARAM_3__W 16
10029#define SCU_RAM_PARAM_3__M 0xFFFF
10030#define SCU_RAM_PARAM_3__PRE 0x0
10031
10032#define SCU_RAM_PARAM_2__A 0x831FFA
10033#define SCU_RAM_PARAM_2__W 16
10034#define SCU_RAM_PARAM_2__M 0xFFFF
10035#define SCU_RAM_PARAM_2__PRE 0x0
10036
10037#define SCU_RAM_PARAM_1__A 0x831FFB
10038#define SCU_RAM_PARAM_1__W 16
10039#define SCU_RAM_PARAM_1__M 0xFFFF
10040#define SCU_RAM_PARAM_1__PRE 0x0
10041#define SCU_RAM_PARAM_1_RES_DEMOD_GET_LOCK_NOT_LOCKED 0x0
10042#define SCU_RAM_PARAM_1_RES_DEMOD_GET_LOCK_DEMOD_LOCKED 0x4000
10043#define SCU_RAM_PARAM_1_RES_DEMOD_GET_LOCK_LOCKED 0x8000
10044#define SCU_RAM_PARAM_1_RES_DEMOD_GET_LOCK_NEVER_LOCK 0xC000
10045
10046#define SCU_RAM_PARAM_0__A 0x831FFC
10047#define SCU_RAM_PARAM_0__W 16
10048#define SCU_RAM_PARAM_0__M 0xFFFF
10049#define SCU_RAM_PARAM_0__PRE 0x0
10050#define SCU_RAM_PARAM_0_ATV_DEMOD_SETENV_MN_STANDARD 0x2
10051#define SCU_RAM_PARAM_0_ATV_DEMOD_SETENV_B_STANDARD 0x103
10052#define SCU_RAM_PARAM_0_ATV_DEMOD_SETENV_G_STANDARD 0x3
10053#define SCU_RAM_PARAM_0_ATV_DEMOD_SETENV_DK_STANDARD 0x4
10054#define SCU_RAM_PARAM_0_ATV_DEMOD_SETENV_L_STANDARD 0x9
10055#define SCU_RAM_PARAM_0_ATV_DEMOD_SETENV_LP_STANDARD 0x109
10056#define SCU_RAM_PARAM_0_ATV_DEMOD_SETENV_I_STANDARD 0xA
10057#define SCU_RAM_PARAM_0_ATV_DEMOD_SETENV_FM_STANDARD 0x40
10058#define SCU_RAM_PARAM_0_QAM_DEMOD_SETENV_ANNEX_A 0x0
10059#define SCU_RAM_PARAM_0_QAM_DEMOD_SETENV_ANNEX_B 0x1
10060#define SCU_RAM_PARAM_0_QAM_DEMOD_SETENV_ANNEX_C 0x2
10061#define SCU_RAM_PARAM_0_QAM_DEMOD_SETENV_ANNEX_D 0x3
10062#define SCU_RAM_PARAM_0_RESULT_OK 0x0
10063#define SCU_RAM_PARAM_0_RESULT_UNKCMD 0xFFFF
10064#define SCU_RAM_PARAM_0_RESULT_UNKSTD 0xFFFE
10065#define SCU_RAM_PARAM_0_RESULT_INVPAR 0xFFFD
10066#define SCU_RAM_PARAM_0_RESULT_SIZE 0xFFFC
10067
10068#define SCU_RAM_COMMAND__A 0x831FFD
10069#define SCU_RAM_COMMAND__W 16
10070#define SCU_RAM_COMMAND__M 0xFFFF
10071#define SCU_RAM_COMMAND__PRE 0x0
10072#define SCU_RAM_COMMAND_CMD_DEMOD_RESET 0x1
10073#define SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV 0x2
10074#define SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM 0x3
10075#define SCU_RAM_COMMAND_CMD_DEMOD_START 0x4
10076#define SCU_RAM_COMMAND_CMD_DEMOD_GET_LOCK 0x5
10077#define SCU_RAM_COMMAND_CMD_DEMOD_GET_PARAM 0x6
10078#define SCU_RAM_COMMAND_CMD_DEMOD_HOLD 0x7
10079#define SCU_RAM_COMMAND_CMD_DEMOD_RESUME 0x8
10080#define SCU_RAM_COMMAND_CMD_DEMOD_STOP 0x9
10081#define SCU_RAM_COMMAND_CMD_STD_QAM_IRQ_ACTIVATE 0x80
10082#define SCU_RAM_COMMAND_CMD_STD_QAM_IRQ_INACTIVATE 0x81
10083#define SCU_RAM_COMMAND_CMD_STD_QAM_IRQ_SIGNAL 0x82
10084#define SCU_RAM_COMMAND_CMD_STD_QAM_IRQ_MONITOR 0x83
10085#define SCU_RAM_COMMAND_CMD_STD_QAM_TSK_ENABLE 0x84
10086#define SCU_RAM_COMMAND_CMD_STD_QAM_FSM_SET_STATE 0x85
10087#define SCU_RAM_COMMAND_CMD_DEBUG_GET_IRQ_REGS 0x80
10088#define SCU_RAM_COMMAND_CMD_DEBUG_HTOL 0x81
10089#define SCU_RAM_COMMAND_CMD_DEBUG_GET_STACK_POINTER 0x82
10090#define SCU_RAM_COMMAND_CMD_DEBUG_START_STACK_CHECK 0x83
10091#define SCU_RAM_COMMAND_CMD_DEBUG_STOP_STACK_CHECK 0x84
10092#define SCU_RAM_COMMAND_CMD_ADMIN_NOP 0xFF
10093#define SCU_RAM_COMMAND_CMD_ADMIN_GET_VERSION 0xFE
10094#define SCU_RAM_COMMAND_CMD_ADMIN_GET_JTAG_VERSION 0xFD
10095#define SCU_RAM_COMMAND_CMD_AUX_SCU_ATOMIC_ACCESS 0xC0
10096
10097#define SCU_RAM_COMMAND_STANDARD__B 8
10098#define SCU_RAM_COMMAND_STANDARD__W 8
10099#define SCU_RAM_COMMAND_STANDARD__M 0xFF00
10100#define SCU_RAM_COMMAND_STANDARD__PRE 0x0
10101#define SCU_RAM_COMMAND_STANDARD_ATV 0x100
10102#define SCU_RAM_COMMAND_STANDARD_QAM 0x200
10103#define SCU_RAM_COMMAND_STANDARD_VSB 0x300
10104#define SCU_RAM_COMMAND_STANDARD_OFDM 0x400
10105#define SCU_RAM_COMMAND_STANDARD_OOB 0x8000
10106#define SCU_RAM_COMMAND_STANDARD_TOP 0xFF00
10107
10108#define SCU_RAM_VERSION_HI__A 0x831FFE
10109#define SCU_RAM_VERSION_HI__W 16
10110#define SCU_RAM_VERSION_HI__M 0xFFFF
10111#define SCU_RAM_VERSION_HI__PRE 0x0
10112
10113#define SCU_RAM_VERSION_HI_VER_MAJOR_N3__B 12
10114#define SCU_RAM_VERSION_HI_VER_MAJOR_N3__W 4
10115#define SCU_RAM_VERSION_HI_VER_MAJOR_N3__M 0xF000
10116#define SCU_RAM_VERSION_HI_VER_MAJOR_N3__PRE 0x0
10117
10118#define SCU_RAM_VERSION_HI_VER_MAJOR_N2__B 8
10119#define SCU_RAM_VERSION_HI_VER_MAJOR_N2__W 4
10120#define SCU_RAM_VERSION_HI_VER_MAJOR_N2__M 0xF00
10121#define SCU_RAM_VERSION_HI_VER_MAJOR_N2__PRE 0x0
10122
10123#define SCU_RAM_VERSION_HI_VER_MAJOR_N1__B 4
10124#define SCU_RAM_VERSION_HI_VER_MAJOR_N1__W 4
10125#define SCU_RAM_VERSION_HI_VER_MAJOR_N1__M 0xF0
10126#define SCU_RAM_VERSION_HI_VER_MAJOR_N1__PRE 0x0
10127
10128#define SCU_RAM_VERSION_HI_VER_MINOR_N1__B 0
10129#define SCU_RAM_VERSION_HI_VER_MINOR_N1__W 4
10130#define SCU_RAM_VERSION_HI_VER_MINOR_N1__M 0xF
10131#define SCU_RAM_VERSION_HI_VER_MINOR_N1__PRE 0x0
10132
10133#define SCU_RAM_VERSION_LO__A 0x831FFF
10134#define SCU_RAM_VERSION_LO__W 16
10135#define SCU_RAM_VERSION_LO__M 0xFFFF
10136#define SCU_RAM_VERSION_LO__PRE 0x0
10137
10138#define SCU_RAM_VERSION_LO_VER_PATCH_N4__B 12
10139#define SCU_RAM_VERSION_LO_VER_PATCH_N4__W 4
10140#define SCU_RAM_VERSION_LO_VER_PATCH_N4__M 0xF000
10141#define SCU_RAM_VERSION_LO_VER_PATCH_N4__PRE 0x0
10142
10143#define SCU_RAM_VERSION_LO_VER_PATCH_N3__B 8
10144#define SCU_RAM_VERSION_LO_VER_PATCH_N3__W 4
10145#define SCU_RAM_VERSION_LO_VER_PATCH_N3__M 0xF00
10146#define SCU_RAM_VERSION_LO_VER_PATCH_N3__PRE 0x0
10147
10148#define SCU_RAM_VERSION_LO_VER_PATCH_N2__B 4
10149#define SCU_RAM_VERSION_LO_VER_PATCH_N2__W 4
10150#define SCU_RAM_VERSION_LO_VER_PATCH_N2__M 0xF0
10151#define SCU_RAM_VERSION_LO_VER_PATCH_N2__PRE 0x0
10152
10153#define SCU_RAM_VERSION_LO_VER_PATCH_N1__B 0
10154#define SCU_RAM_VERSION_LO_VER_PATCH_N1__W 4
10155#define SCU_RAM_VERSION_LO_VER_PATCH_N1__M 0xF
10156#define SCU_RAM_VERSION_LO_VER_PATCH_N1__PRE 0x0
10157
10158#define SIO_COMM_EXEC__A 0x400000
10159#define SIO_COMM_EXEC__W 2
10160#define SIO_COMM_EXEC__M 0x3
10161#define SIO_COMM_EXEC__PRE 0x0
10162#define SIO_COMM_EXEC_STOP 0x0
10163#define SIO_COMM_EXEC_ACTIVE 0x1
10164#define SIO_COMM_EXEC_HOLD 0x2
10165
10166#define SIO_COMM_STATE__A 0x400001
10167#define SIO_COMM_STATE__W 16
10168#define SIO_COMM_STATE__M 0xFFFF
10169#define SIO_COMM_STATE__PRE 0x0
10170#define SIO_COMM_MB__A 0x400002
10171#define SIO_COMM_MB__W 16
10172#define SIO_COMM_MB__M 0xFFFF
10173#define SIO_COMM_MB__PRE 0x0
10174#define SIO_COMM_INT_REQ__A 0x400003
10175#define SIO_COMM_INT_REQ__W 16
10176#define SIO_COMM_INT_REQ__M 0xFFFF
10177#define SIO_COMM_INT_REQ__PRE 0x0
10178
10179#define SIO_COMM_INT_REQ_HI_REQ__B 0
10180#define SIO_COMM_INT_REQ_HI_REQ__W 1
10181#define SIO_COMM_INT_REQ_HI_REQ__M 0x1
10182#define SIO_COMM_INT_REQ_HI_REQ__PRE 0x0
10183
10184#define SIO_COMM_INT_REQ_SA_REQ__B 1
10185#define SIO_COMM_INT_REQ_SA_REQ__W 1
10186#define SIO_COMM_INT_REQ_SA_REQ__M 0x2
10187#define SIO_COMM_INT_REQ_SA_REQ__PRE 0x0
10188
10189#define SIO_COMM_INT_STA__A 0x400005
10190#define SIO_COMM_INT_STA__W 16
10191#define SIO_COMM_INT_STA__M 0xFFFF
10192#define SIO_COMM_INT_STA__PRE 0x0
10193#define SIO_COMM_INT_MSK__A 0x400006
10194#define SIO_COMM_INT_MSK__W 16
10195#define SIO_COMM_INT_MSK__M 0xFFFF
10196#define SIO_COMM_INT_MSK__PRE 0x0
10197#define SIO_COMM_INT_STM__A 0x400007
10198#define SIO_COMM_INT_STM__W 16
10199#define SIO_COMM_INT_STM__M 0xFFFF
10200#define SIO_COMM_INT_STM__PRE 0x0
10201
10202#define SIO_TOP_COMM_EXEC__A 0x410000
10203#define SIO_TOP_COMM_EXEC__W 2
10204#define SIO_TOP_COMM_EXEC__M 0x3
10205#define SIO_TOP_COMM_EXEC__PRE 0x0
10206#define SIO_TOP_COMM_EXEC_STOP 0x0
10207#define SIO_TOP_COMM_EXEC_ACTIVE 0x1
10208#define SIO_TOP_COMM_EXEC_HOLD 0x2
10209
10210#define SIO_TOP_COMM_KEY__A 0x41000F
10211#define SIO_TOP_COMM_KEY__W 16
10212#define SIO_TOP_COMM_KEY__M 0xFFFF
10213#define SIO_TOP_COMM_KEY__PRE 0x0
10214#define SIO_TOP_COMM_KEY_KEY 0xFABA
10215
10216#define SIO_TOP_JTAGID_LO__A 0x410012
10217#define SIO_TOP_JTAGID_LO__W 16
10218#define SIO_TOP_JTAGID_LO__M 0xFFFF
10219#define SIO_TOP_JTAGID_LO__PRE 0x0
10220
10221#define SIO_TOP_JTAGID_HI__A 0x410013
10222#define SIO_TOP_JTAGID_HI__W 16
10223#define SIO_TOP_JTAGID_HI__M 0xFFFF
10224#define SIO_TOP_JTAGID_HI__PRE 0x0
10225
10226#define SIO_HI_RA_RAM_S0_FLG_SMM__A 0x420010
10227#define SIO_HI_RA_RAM_S0_FLG_SMM__W 1
10228#define SIO_HI_RA_RAM_S0_FLG_SMM__M 0x1
10229#define SIO_HI_RA_RAM_S0_FLG_SMM__PRE 0x0
10230
10231#define SIO_HI_RA_RAM_S0_DEV_ID__A 0x420011
10232#define SIO_HI_RA_RAM_S0_DEV_ID__W 7
10233#define SIO_HI_RA_RAM_S0_DEV_ID__M 0x7F
10234#define SIO_HI_RA_RAM_S0_DEV_ID__PRE 0x52
10235
10236#define SIO_HI_RA_RAM_S0_FLG_CRC__A 0x420012
10237#define SIO_HI_RA_RAM_S0_FLG_CRC__W 1
10238#define SIO_HI_RA_RAM_S0_FLG_CRC__M 0x1
10239#define SIO_HI_RA_RAM_S0_FLG_CRC__PRE 0x0
10240#define SIO_HI_RA_RAM_S0_FLG_ACC__A 0x420013
10241#define SIO_HI_RA_RAM_S0_FLG_ACC__W 4
10242#define SIO_HI_RA_RAM_S0_FLG_ACC__M 0xF
10243#define SIO_HI_RA_RAM_S0_FLG_ACC__PRE 0x0
10244
10245#define SIO_HI_RA_RAM_S0_FLG_ACC_S0_RWM__B 0
10246#define SIO_HI_RA_RAM_S0_FLG_ACC_S0_RWM__W 2
10247#define SIO_HI_RA_RAM_S0_FLG_ACC_S0_RWM__M 0x3
10248#define SIO_HI_RA_RAM_S0_FLG_ACC_S0_RWM__PRE 0x0
10249
10250#define SIO_HI_RA_RAM_S0_FLG_ACC_S0_SLV_BRC__B 2
10251#define SIO_HI_RA_RAM_S0_FLG_ACC_S0_SLV_BRC__W 1
10252#define SIO_HI_RA_RAM_S0_FLG_ACC_S0_SLV_BRC__M 0x4
10253#define SIO_HI_RA_RAM_S0_FLG_ACC_S0_SLV_BRC__PRE 0x0
10254
10255#define SIO_HI_RA_RAM_S0_FLG_ACC_S0_SLV_SWP__B 3
10256#define SIO_HI_RA_RAM_S0_FLG_ACC_S0_SLV_SWP__W 1
10257#define SIO_HI_RA_RAM_S0_FLG_ACC_S0_SLV_SWP__M 0x8
10258#define SIO_HI_RA_RAM_S0_FLG_ACC_S0_SLV_SWP__PRE 0x0
10259
10260#define SIO_HI_RA_RAM_S0_STATE__A 0x420014
10261#define SIO_HI_RA_RAM_S0_STATE__W 1
10262#define SIO_HI_RA_RAM_S0_STATE__M 0x1
10263#define SIO_HI_RA_RAM_S0_STATE__PRE 0x0
10264
10265#define SIO_HI_RA_RAM_S0_STATE_S0_SLV_STA__B 0
10266#define SIO_HI_RA_RAM_S0_STATE_S0_SLV_STA__W 1
10267#define SIO_HI_RA_RAM_S0_STATE_S0_SLV_STA__M 0x1
10268#define SIO_HI_RA_RAM_S0_STATE_S0_SLV_STA__PRE 0x0
10269
10270#define SIO_HI_RA_RAM_S0_BLK_BNK__A 0x420015
10271#define SIO_HI_RA_RAM_S0_BLK_BNK__W 12
10272#define SIO_HI_RA_RAM_S0_BLK_BNK__M 0xFFF
10273#define SIO_HI_RA_RAM_S0_BLK_BNK__PRE 0x82
10274
10275#define SIO_HI_RA_RAM_S0_BLK_BNK_S0_SLV_BNK__B 0
10276#define SIO_HI_RA_RAM_S0_BLK_BNK_S0_SLV_BNK__W 6
10277#define SIO_HI_RA_RAM_S0_BLK_BNK_S0_SLV_BNK__M 0x3F
10278#define SIO_HI_RA_RAM_S0_BLK_BNK_S0_SLV_BNK__PRE 0x2
10279
10280#define SIO_HI_RA_RAM_S0_BLK_BNK_S0_SLV_BLK__B 6
10281#define SIO_HI_RA_RAM_S0_BLK_BNK_S0_SLV_BLK__W 6
10282#define SIO_HI_RA_RAM_S0_BLK_BNK_S0_SLV_BLK__M 0xFC0
10283#define SIO_HI_RA_RAM_S0_BLK_BNK_S0_SLV_BLK__PRE 0x80
10284
10285#define SIO_HI_RA_RAM_S0_ADDR__A 0x420016
10286#define SIO_HI_RA_RAM_S0_ADDR__W 16
10287#define SIO_HI_RA_RAM_S0_ADDR__M 0xFFFF
10288#define SIO_HI_RA_RAM_S0_ADDR__PRE 0x0
10289
10290#define SIO_HI_RA_RAM_S0_ADDR_S0_SLV_ADDR__B 0
10291#define SIO_HI_RA_RAM_S0_ADDR_S0_SLV_ADDR__W 16
10292#define SIO_HI_RA_RAM_S0_ADDR_S0_SLV_ADDR__M 0xFFFF
10293#define SIO_HI_RA_RAM_S0_ADDR_S0_SLV_ADDR__PRE 0x0
10294
10295#define SIO_HI_RA_RAM_S0_CRC__A 0x420017
10296#define SIO_HI_RA_RAM_S0_CRC__W 16
10297#define SIO_HI_RA_RAM_S0_CRC__M 0xFFFF
10298#define SIO_HI_RA_RAM_S0_CRC__PRE 0x0
10299
10300#define SIO_HI_RA_RAM_S0_BUFFER__A 0x420018
10301#define SIO_HI_RA_RAM_S0_BUFFER__W 16
10302#define SIO_HI_RA_RAM_S0_BUFFER__M 0xFFFF
10303#define SIO_HI_RA_RAM_S0_BUFFER__PRE 0x0
10304
10305#define SIO_HI_RA_RAM_S0_RMWBUF__A 0x420019
10306#define SIO_HI_RA_RAM_S0_RMWBUF__W 16
10307#define SIO_HI_RA_RAM_S0_RMWBUF__M 0xFFFF
10308#define SIO_HI_RA_RAM_S0_RMWBUF__PRE 0x0
10309
10310#define SIO_HI_RA_RAM_S0_FLG_VB__A 0x42001A
10311#define SIO_HI_RA_RAM_S0_FLG_VB__W 1
10312#define SIO_HI_RA_RAM_S0_FLG_VB__M 0x1
10313#define SIO_HI_RA_RAM_S0_FLG_VB__PRE 0x0
10314
10315#define SIO_HI_RA_RAM_S0_TEMP0__A 0x42001B
10316#define SIO_HI_RA_RAM_S0_TEMP0__W 16
10317#define SIO_HI_RA_RAM_S0_TEMP0__M 0xFFFF
10318#define SIO_HI_RA_RAM_S0_TEMP0__PRE 0x0
10319
10320#define SIO_HI_RA_RAM_S0_TEMP1__A 0x42001C
10321#define SIO_HI_RA_RAM_S0_TEMP1__W 16
10322#define SIO_HI_RA_RAM_S0_TEMP1__M 0xFFFF
10323#define SIO_HI_RA_RAM_S0_TEMP1__PRE 0x0
10324
10325#define SIO_HI_RA_RAM_S0_OFFSET__A 0x42001D
10326#define SIO_HI_RA_RAM_S0_OFFSET__W 16
10327#define SIO_HI_RA_RAM_S0_OFFSET__M 0xFFFF
10328#define SIO_HI_RA_RAM_S0_OFFSET__PRE 0x0
10329
10330#define SIO_HI_RA_RAM_S1_FLG_SMM__A 0x420020
10331#define SIO_HI_RA_RAM_S1_FLG_SMM__W 1
10332#define SIO_HI_RA_RAM_S1_FLG_SMM__M 0x1
10333#define SIO_HI_RA_RAM_S1_FLG_SMM__PRE 0x0
10334
10335#define SIO_HI_RA_RAM_S1_DEV_ID__A 0x420021
10336#define SIO_HI_RA_RAM_S1_DEV_ID__W 7
10337#define SIO_HI_RA_RAM_S1_DEV_ID__M 0x7F
10338#define SIO_HI_RA_RAM_S1_DEV_ID__PRE 0x52
10339
10340#define SIO_HI_RA_RAM_S1_FLG_CRC__A 0x420022
10341#define SIO_HI_RA_RAM_S1_FLG_CRC__W 1
10342#define SIO_HI_RA_RAM_S1_FLG_CRC__M 0x1
10343#define SIO_HI_RA_RAM_S1_FLG_CRC__PRE 0x0
10344#define SIO_HI_RA_RAM_S1_FLG_ACC__A 0x420023
10345#define SIO_HI_RA_RAM_S1_FLG_ACC__W 4
10346#define SIO_HI_RA_RAM_S1_FLG_ACC__M 0xF
10347#define SIO_HI_RA_RAM_S1_FLG_ACC__PRE 0x0
10348
10349#define SIO_HI_RA_RAM_S1_FLG_ACC_S1_RWM__B 0
10350#define SIO_HI_RA_RAM_S1_FLG_ACC_S1_RWM__W 2
10351#define SIO_HI_RA_RAM_S1_FLG_ACC_S1_RWM__M 0x3
10352#define SIO_HI_RA_RAM_S1_FLG_ACC_S1_RWM__PRE 0x0
10353
10354#define SIO_HI_RA_RAM_S1_FLG_ACC_S1_SLV_BRC__B 2
10355#define SIO_HI_RA_RAM_S1_FLG_ACC_S1_SLV_BRC__W 1
10356#define SIO_HI_RA_RAM_S1_FLG_ACC_S1_SLV_BRC__M 0x4
10357#define SIO_HI_RA_RAM_S1_FLG_ACC_S1_SLV_BRC__PRE 0x0
10358
10359#define SIO_HI_RA_RAM_S1_FLG_ACC_S1_SLV_SWP__B 3
10360#define SIO_HI_RA_RAM_S1_FLG_ACC_S1_SLV_SWP__W 1
10361#define SIO_HI_RA_RAM_S1_FLG_ACC_S1_SLV_SWP__M 0x8
10362#define SIO_HI_RA_RAM_S1_FLG_ACC_S1_SLV_SWP__PRE 0x0
10363
10364#define SIO_HI_RA_RAM_S1_STATE__A 0x420024
10365#define SIO_HI_RA_RAM_S1_STATE__W 1
10366#define SIO_HI_RA_RAM_S1_STATE__M 0x1
10367#define SIO_HI_RA_RAM_S1_STATE__PRE 0x0
10368
10369#define SIO_HI_RA_RAM_S1_STATE_S1_SLV_STA__B 0
10370#define SIO_HI_RA_RAM_S1_STATE_S1_SLV_STA__W 1
10371#define SIO_HI_RA_RAM_S1_STATE_S1_SLV_STA__M 0x1
10372#define SIO_HI_RA_RAM_S1_STATE_S1_SLV_STA__PRE 0x0
10373
10374#define SIO_HI_RA_RAM_S1_BLK_BNK__A 0x420025
10375#define SIO_HI_RA_RAM_S1_BLK_BNK__W 12
10376#define SIO_HI_RA_RAM_S1_BLK_BNK__M 0xFFF
10377#define SIO_HI_RA_RAM_S1_BLK_BNK__PRE 0x82
10378
10379#define SIO_HI_RA_RAM_S1_BLK_BNK_S1_SLV_BNK__B 0
10380#define SIO_HI_RA_RAM_S1_BLK_BNK_S1_SLV_BNK__W 6
10381#define SIO_HI_RA_RAM_S1_BLK_BNK_S1_SLV_BNK__M 0x3F
10382#define SIO_HI_RA_RAM_S1_BLK_BNK_S1_SLV_BNK__PRE 0x2
10383
10384#define SIO_HI_RA_RAM_S1_BLK_BNK_S1_SLV_BLK__B 6
10385#define SIO_HI_RA_RAM_S1_BLK_BNK_S1_SLV_BLK__W 6
10386#define SIO_HI_RA_RAM_S1_BLK_BNK_S1_SLV_BLK__M 0xFC0
10387#define SIO_HI_RA_RAM_S1_BLK_BNK_S1_SLV_BLK__PRE 0x80
10388
10389#define SIO_HI_RA_RAM_S1_ADDR__A 0x420026
10390#define SIO_HI_RA_RAM_S1_ADDR__W 16
10391#define SIO_HI_RA_RAM_S1_ADDR__M 0xFFFF
10392#define SIO_HI_RA_RAM_S1_ADDR__PRE 0x0
10393
10394#define SIO_HI_RA_RAM_S1_ADDR_S1_SLV_ADDR__B 0
10395#define SIO_HI_RA_RAM_S1_ADDR_S1_SLV_ADDR__W 16
10396#define SIO_HI_RA_RAM_S1_ADDR_S1_SLV_ADDR__M 0xFFFF
10397#define SIO_HI_RA_RAM_S1_ADDR_S1_SLV_ADDR__PRE 0x0
10398
10399#define SIO_HI_RA_RAM_S1_CRC__A 0x420027
10400#define SIO_HI_RA_RAM_S1_CRC__W 16
10401#define SIO_HI_RA_RAM_S1_CRC__M 0xFFFF
10402#define SIO_HI_RA_RAM_S1_CRC__PRE 0x0
10403
10404#define SIO_HI_RA_RAM_S1_BUFFER__A 0x420028
10405#define SIO_HI_RA_RAM_S1_BUFFER__W 16
10406#define SIO_HI_RA_RAM_S1_BUFFER__M 0xFFFF
10407#define SIO_HI_RA_RAM_S1_BUFFER__PRE 0x0
10408
10409#define SIO_HI_RA_RAM_S1_RMWBUF__A 0x420029
10410#define SIO_HI_RA_RAM_S1_RMWBUF__W 16
10411#define SIO_HI_RA_RAM_S1_RMWBUF__M 0xFFFF
10412#define SIO_HI_RA_RAM_S1_RMWBUF__PRE 0x0
10413
10414#define SIO_HI_RA_RAM_S1_FLG_VB__A 0x42002A
10415#define SIO_HI_RA_RAM_S1_FLG_VB__W 1
10416#define SIO_HI_RA_RAM_S1_FLG_VB__M 0x1
10417#define SIO_HI_RA_RAM_S1_FLG_VB__PRE 0x0
10418
10419#define SIO_HI_RA_RAM_S1_TEMP0__A 0x42002B
10420#define SIO_HI_RA_RAM_S1_TEMP0__W 16
10421#define SIO_HI_RA_RAM_S1_TEMP0__M 0xFFFF
10422#define SIO_HI_RA_RAM_S1_TEMP0__PRE 0x0
10423
10424#define SIO_HI_RA_RAM_S1_TEMP1__A 0x42002C
10425#define SIO_HI_RA_RAM_S1_TEMP1__W 16
10426#define SIO_HI_RA_RAM_S1_TEMP1__M 0xFFFF
10427#define SIO_HI_RA_RAM_S1_TEMP1__PRE 0x0
10428
10429#define SIO_HI_RA_RAM_S1_OFFSET__A 0x42002D
10430#define SIO_HI_RA_RAM_S1_OFFSET__W 16
10431#define SIO_HI_RA_RAM_S1_OFFSET__M 0xFFFF
10432#define SIO_HI_RA_RAM_S1_OFFSET__PRE 0x0
10433#define SIO_HI_RA_RAM_SEMA__A 0x420030
10434#define SIO_HI_RA_RAM_SEMA__W 1
10435#define SIO_HI_RA_RAM_SEMA__M 0x1
10436#define SIO_HI_RA_RAM_SEMA__PRE 0x0
10437#define SIO_HI_RA_RAM_SEMA_FREE 0x0
10438#define SIO_HI_RA_RAM_SEMA_BUSY 0x1
10439
10440#define SIO_HI_RA_RAM_RES__A 0x420031
10441#define SIO_HI_RA_RAM_RES__W 3
10442#define SIO_HI_RA_RAM_RES__M 0x7
10443#define SIO_HI_RA_RAM_RES__PRE 0x0
10444#define SIO_HI_RA_RAM_RES_OK 0x0
10445#define SIO_HI_RA_RAM_RES_ERROR 0x1
10446#define SIO_HI_RA_RAM_RES_I2C_START_FOUND 0x1
10447#define SIO_HI_RA_RAM_RES_I2C_STOP_FOUND 0x2
10448#define SIO_HI_RA_RAM_RES_I2C_ARB_LOST 0x3
10449#define SIO_HI_RA_RAM_RES_I2C_ERROR 0x4
10450
10451#define SIO_HI_RA_RAM_CMD__A 0x420032
10452#define SIO_HI_RA_RAM_CMD__W 4
10453#define SIO_HI_RA_RAM_CMD__M 0xF
10454#define SIO_HI_RA_RAM_CMD__PRE 0x0
10455#define SIO_HI_RA_RAM_CMD_NULL 0x0
10456#define SIO_HI_RA_RAM_CMD_UIO 0x1
10457#define SIO_HI_RA_RAM_CMD_RESET 0x2
10458#define SIO_HI_RA_RAM_CMD_CONFIG 0x3
10459#define SIO_HI_RA_RAM_CMD_INTERNAL_TRANSFER 0x4
10460#define SIO_HI_RA_RAM_CMD_I2C_TRANSMIT 0x5
10461#define SIO_HI_RA_RAM_CMD_EXEC 0x6
10462#define SIO_HI_RA_RAM_CMD_BRDCTRL 0x7
10463#define SIO_HI_RA_RAM_CMD_ATOMIC_COPY 0x8
10464
10465#define SIO_HI_RA_RAM_PAR_1__A 0x420033
10466#define SIO_HI_RA_RAM_PAR_1__W 16
10467#define SIO_HI_RA_RAM_PAR_1__M 0xFFFF
10468#define SIO_HI_RA_RAM_PAR_1__PRE 0x0
10469#define SIO_HI_RA_RAM_PAR_1_PAR1__B 0
10470#define SIO_HI_RA_RAM_PAR_1_PAR1__W 16
10471#define SIO_HI_RA_RAM_PAR_1_PAR1__M 0xFFFF
10472#define SIO_HI_RA_RAM_PAR_1_PAR1__PRE 0x0
10473#define SIO_HI_RA_RAM_PAR_1_PAR1_SEC_KEY 0x3945
10474
10475#define SIO_HI_RA_RAM_PAR_1_ITX_SRC_BNK__B 0
10476#define SIO_HI_RA_RAM_PAR_1_ITX_SRC_BNK__W 6
10477#define SIO_HI_RA_RAM_PAR_1_ITX_SRC_BNK__M 0x3F
10478#define SIO_HI_RA_RAM_PAR_1_ITX_SRC_BNK__PRE 0x0
10479
10480#define SIO_HI_RA_RAM_PAR_1_ITX_SRC_BLK__B 6
10481#define SIO_HI_RA_RAM_PAR_1_ITX_SRC_BLK__W 6
10482#define SIO_HI_RA_RAM_PAR_1_ITX_SRC_BLK__M 0xFC0
10483#define SIO_HI_RA_RAM_PAR_1_ITX_SRC_BLK__PRE 0x0
10484
10485#define SIO_HI_RA_RAM_PAR_1_I2CTX_PORT__B 0
10486#define SIO_HI_RA_RAM_PAR_1_I2CTX_PORT__W 1
10487#define SIO_HI_RA_RAM_PAR_1_I2CTX_PORT__M 0x1
10488#define SIO_HI_RA_RAM_PAR_1_I2CTX_PORT__PRE 0x0
10489
10490#define SIO_HI_RA_RAM_PAR_1_I2CTX_TOE__B 1
10491#define SIO_HI_RA_RAM_PAR_1_I2CTX_TOE__W 1
10492#define SIO_HI_RA_RAM_PAR_1_I2CTX_TOE__M 0x2
10493#define SIO_HI_RA_RAM_PAR_1_I2CTX_TOE__PRE 0x0
10494#define SIO_HI_RA_RAM_PAR_1_I2CTX_TOE_DISABLE 0x0
10495#define SIO_HI_RA_RAM_PAR_1_I2CTX_TOE_ENABLE 0x2
10496
10497#define SIO_HI_RA_RAM_PAR_1_EXEC_FUNC__B 0
10498#define SIO_HI_RA_RAM_PAR_1_EXEC_FUNC__W 10
10499#define SIO_HI_RA_RAM_PAR_1_EXEC_FUNC__M 0x3FF
10500#define SIO_HI_RA_RAM_PAR_1_EXEC_FUNC__PRE 0x0
10501
10502#define SIO_HI_RA_RAM_PAR_1_ACP_INT_BNK__B 0
10503#define SIO_HI_RA_RAM_PAR_1_ACP_INT_BNK__W 6
10504#define SIO_HI_RA_RAM_PAR_1_ACP_INT_BNK__M 0x3F
10505#define SIO_HI_RA_RAM_PAR_1_ACP_INT_BNK__PRE 0x0
10506
10507#define SIO_HI_RA_RAM_PAR_1_ACP_INT_BLK__B 6
10508#define SIO_HI_RA_RAM_PAR_1_ACP_INT_BLK__W 6
10509#define SIO_HI_RA_RAM_PAR_1_ACP_INT_BLK__M 0xFC0
10510#define SIO_HI_RA_RAM_PAR_1_ACP_INT_BLK__PRE 0x0
10511
10512#define SIO_HI_RA_RAM_PAR_2__A 0x420034
10513#define SIO_HI_RA_RAM_PAR_2__W 16
10514#define SIO_HI_RA_RAM_PAR_2__M 0xFFFF
10515#define SIO_HI_RA_RAM_PAR_2__PRE 0x0
10516#define SIO_HI_RA_RAM_PAR_2_PAR2__B 0
10517#define SIO_HI_RA_RAM_PAR_2_PAR2__W 16
10518#define SIO_HI_RA_RAM_PAR_2_PAR2__M 0xFFFF
10519#define SIO_HI_RA_RAM_PAR_2_PAR2__PRE 0x0
10520
10521#define SIO_HI_RA_RAM_PAR_2_CFG_DIV__B 0
10522#define SIO_HI_RA_RAM_PAR_2_CFG_DIV__W 7
10523#define SIO_HI_RA_RAM_PAR_2_CFG_DIV__M 0x7F
10524#define SIO_HI_RA_RAM_PAR_2_CFG_DIV__PRE 0x25
10525
10526#define SIO_HI_RA_RAM_PAR_2_ITX_SRC_OFF__B 0
10527#define SIO_HI_RA_RAM_PAR_2_ITX_SRC_OFF__W 16
10528#define SIO_HI_RA_RAM_PAR_2_ITX_SRC_OFF__M 0xFFFF
10529#define SIO_HI_RA_RAM_PAR_2_ITX_SRC_OFF__PRE 0x0
10530
10531#define SIO_HI_RA_RAM_PAR_2_I2CTX_BUF__B 0
10532#define SIO_HI_RA_RAM_PAR_2_I2CTX_BUF__W 16
10533#define SIO_HI_RA_RAM_PAR_2_I2CTX_BUF__M 0xFFFF
10534#define SIO_HI_RA_RAM_PAR_2_I2CTX_BUF__PRE 0x0
10535
10536#define SIO_HI_RA_RAM_PAR_2_BRD_CFG__B 2
10537#define SIO_HI_RA_RAM_PAR_2_BRD_CFG__W 1
10538#define SIO_HI_RA_RAM_PAR_2_BRD_CFG__M 0x4
10539#define SIO_HI_RA_RAM_PAR_2_BRD_CFG__PRE 0x0
10540#define SIO_HI_RA_RAM_PAR_2_BRD_CFG_OPEN 0x0
10541#define SIO_HI_RA_RAM_PAR_2_BRD_CFG_CLOSED 0x4
10542
10543#define SIO_HI_RA_RAM_PAR_2_ACP_INT_OFF__B 0
10544#define SIO_HI_RA_RAM_PAR_2_ACP_INT_OFF__W 16
10545#define SIO_HI_RA_RAM_PAR_2_ACP_INT_OFF__M 0xFFFF
10546#define SIO_HI_RA_RAM_PAR_2_ACP_INT_OFF__PRE 0x0
10547
10548#define SIO_HI_RA_RAM_PAR_3__A 0x420035
10549#define SIO_HI_RA_RAM_PAR_3__W 16
10550#define SIO_HI_RA_RAM_PAR_3__M 0xFFFF
10551#define SIO_HI_RA_RAM_PAR_3__PRE 0x0
10552#define SIO_HI_RA_RAM_PAR_3_PAR3__B 0
10553#define SIO_HI_RA_RAM_PAR_3_PAR3__W 16
10554#define SIO_HI_RA_RAM_PAR_3_PAR3__M 0xFFFF
10555#define SIO_HI_RA_RAM_PAR_3_PAR3__PRE 0x0
10556
10557#define SIO_HI_RA_RAM_PAR_3_CFG_DBL_SDA__B 0
10558#define SIO_HI_RA_RAM_PAR_3_CFG_DBL_SDA__W 7
10559#define SIO_HI_RA_RAM_PAR_3_CFG_DBL_SDA__M 0x7F
10560#define SIO_HI_RA_RAM_PAR_3_CFG_DBL_SDA__PRE 0x3F
10561
10562#define SIO_HI_RA_RAM_PAR_3_CFG_DBL_SCL__B 7
10563#define SIO_HI_RA_RAM_PAR_3_CFG_DBL_SCL__W 7
10564#define SIO_HI_RA_RAM_PAR_3_CFG_DBL_SCL__M 0x3F80
10565#define SIO_HI_RA_RAM_PAR_3_CFG_DBL_SCL__PRE 0x1F80
10566
10567#define SIO_HI_RA_RAM_PAR_3_ITX_LEN__B 0
10568#define SIO_HI_RA_RAM_PAR_3_ITX_LEN__W 16
10569#define SIO_HI_RA_RAM_PAR_3_ITX_LEN__M 0xFFFF
10570#define SIO_HI_RA_RAM_PAR_3_ITX_LEN__PRE 0x0
10571
10572#define SIO_HI_RA_RAM_PAR_3_ACP_LEN__B 0
10573#define SIO_HI_RA_RAM_PAR_3_ACP_LEN__W 3
10574#define SIO_HI_RA_RAM_PAR_3_ACP_LEN__M 0x7
10575#define SIO_HI_RA_RAM_PAR_3_ACP_LEN__PRE 0x0
10576
10577#define SIO_HI_RA_RAM_PAR_3_ACP_RW__B 3
10578#define SIO_HI_RA_RAM_PAR_3_ACP_RW__W 1
10579#define SIO_HI_RA_RAM_PAR_3_ACP_RW__M 0x8
10580#define SIO_HI_RA_RAM_PAR_3_ACP_RW__PRE 0x0
10581#define SIO_HI_RA_RAM_PAR_3_ACP_RW_READ 0x0
10582#define SIO_HI_RA_RAM_PAR_3_ACP_RW_WRITE 0x8
10583
10584#define SIO_HI_RA_RAM_PAR_4__A 0x420036
10585#define SIO_HI_RA_RAM_PAR_4__W 16
10586#define SIO_HI_RA_RAM_PAR_4__M 0xFFFF
10587#define SIO_HI_RA_RAM_PAR_4__PRE 0x0
10588#define SIO_HI_RA_RAM_PAR_4_PAR4__B 0
10589#define SIO_HI_RA_RAM_PAR_4_PAR4__W 16
10590#define SIO_HI_RA_RAM_PAR_4_PAR4__M 0xFFFF
10591#define SIO_HI_RA_RAM_PAR_4_PAR4__PRE 0x0
10592
10593#define SIO_HI_RA_RAM_PAR_4_CFG_WUP__B 0
10594#define SIO_HI_RA_RAM_PAR_4_CFG_WUP__W 8
10595#define SIO_HI_RA_RAM_PAR_4_CFG_WUP__M 0xFF
10596#define SIO_HI_RA_RAM_PAR_4_CFG_WUP__PRE 0xC1
10597
10598#define SIO_HI_RA_RAM_PAR_4_ITX_DST_BNK__B 0
10599#define SIO_HI_RA_RAM_PAR_4_ITX_DST_BNK__W 6
10600#define SIO_HI_RA_RAM_PAR_4_ITX_DST_BNK__M 0x3F
10601#define SIO_HI_RA_RAM_PAR_4_ITX_DST_BNK__PRE 0x0
10602
10603#define SIO_HI_RA_RAM_PAR_4_ITX_DST_BLK__B 6
10604#define SIO_HI_RA_RAM_PAR_4_ITX_DST_BLK__W 6
10605#define SIO_HI_RA_RAM_PAR_4_ITX_DST_BLK__M 0xFC0
10606#define SIO_HI_RA_RAM_PAR_4_ITX_DST_BLK__PRE 0x0
10607
10608#define SIO_HI_RA_RAM_PAR_4_ACP_EXT_BNK__B 0
10609#define SIO_HI_RA_RAM_PAR_4_ACP_EXT_BNK__W 6
10610#define SIO_HI_RA_RAM_PAR_4_ACP_EXT_BNK__M 0x3F
10611#define SIO_HI_RA_RAM_PAR_4_ACP_EXT_BNK__PRE 0x0
10612
10613#define SIO_HI_RA_RAM_PAR_4_ACP_EXT_BLK__B 6
10614#define SIO_HI_RA_RAM_PAR_4_ACP_EXT_BLK__W 6
10615#define SIO_HI_RA_RAM_PAR_4_ACP_EXT_BLK__M 0xFC0
10616#define SIO_HI_RA_RAM_PAR_4_ACP_EXT_BLK__PRE 0x0
10617
10618#define SIO_HI_RA_RAM_PAR_5__A 0x420037
10619#define SIO_HI_RA_RAM_PAR_5__W 16
10620#define SIO_HI_RA_RAM_PAR_5__M 0xFFFF
10621#define SIO_HI_RA_RAM_PAR_5__PRE 0x0
10622#define SIO_HI_RA_RAM_PAR_5_PAR5__B 0
10623#define SIO_HI_RA_RAM_PAR_5_PAR5__W 16
10624#define SIO_HI_RA_RAM_PAR_5_PAR5__M 0xFFFF
10625#define SIO_HI_RA_RAM_PAR_5_PAR5__PRE 0x0
10626
10627#define SIO_HI_RA_RAM_PAR_5_CFG_SLV0__B 0
10628#define SIO_HI_RA_RAM_PAR_5_CFG_SLV0__W 1
10629#define SIO_HI_RA_RAM_PAR_5_CFG_SLV0__M 0x1
10630#define SIO_HI_RA_RAM_PAR_5_CFG_SLV0__PRE 0x0
10631#define SIO_HI_RA_RAM_PAR_5_CFG_SLV0_NO_SLAVE 0x0
10632#define SIO_HI_RA_RAM_PAR_5_CFG_SLV0_SLAVE 0x1
10633
10634#define SIO_HI_RA_RAM_PAR_5_CFG_SLV1__B 1
10635#define SIO_HI_RA_RAM_PAR_5_CFG_SLV1__W 1
10636#define SIO_HI_RA_RAM_PAR_5_CFG_SLV1__M 0x2
10637#define SIO_HI_RA_RAM_PAR_5_CFG_SLV1__PRE 0x0
10638#define SIO_HI_RA_RAM_PAR_5_CFG_SLV1_NO_SLAVE 0x0
10639#define SIO_HI_RA_RAM_PAR_5_CFG_SLV1_SLAVE 0x2
10640
10641#define SIO_HI_RA_RAM_PAR_5_CFG_SLEEP__B 3
10642#define SIO_HI_RA_RAM_PAR_5_CFG_SLEEP__W 1
10643#define SIO_HI_RA_RAM_PAR_5_CFG_SLEEP__M 0x8
10644#define SIO_HI_RA_RAM_PAR_5_CFG_SLEEP__PRE 0x0
10645#define SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_AWAKE 0x0
10646#define SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ 0x8
10647
10648#define SIO_HI_RA_RAM_PAR_5_CFG_BDGST__B 5
10649#define SIO_HI_RA_RAM_PAR_5_CFG_BDGST__W 1
10650#define SIO_HI_RA_RAM_PAR_5_CFG_BDGST__M 0x20
10651#define SIO_HI_RA_RAM_PAR_5_CFG_BDGST__PRE 0x0
10652#define SIO_HI_RA_RAM_PAR_5_CFG_BDGST_DISABLE 0x0
10653#define SIO_HI_RA_RAM_PAR_5_CFG_BDGST_ENABLE 0x20
10654
10655#define SIO_HI_RA_RAM_PAR_5_ITX_DST_OFF__B 0
10656#define SIO_HI_RA_RAM_PAR_5_ITX_DST_OFF__W 16
10657#define SIO_HI_RA_RAM_PAR_5_ITX_DST_OFF__M 0xFFFF
10658#define SIO_HI_RA_RAM_PAR_5_ITX_DST_OFF__PRE 0x0
10659
10660#define SIO_HI_RA_RAM_PAR_5_ACP_EXT_OFF__B 0
10661#define SIO_HI_RA_RAM_PAR_5_ACP_EXT_OFF__W 16
10662#define SIO_HI_RA_RAM_PAR_5_ACP_EXT_OFF__M 0xFFFF
10663#define SIO_HI_RA_RAM_PAR_5_ACP_EXT_OFF__PRE 0x0
10664
10665#define SIO_HI_RA_RAM_PAR_6__A 0x420038
10666#define SIO_HI_RA_RAM_PAR_6__W 16
10667#define SIO_HI_RA_RAM_PAR_6__M 0xFFFF
10668#define SIO_HI_RA_RAM_PAR_6__PRE 0x95FF
10669#define SIO_HI_RA_RAM_PAR_6_PAR6__B 0
10670#define SIO_HI_RA_RAM_PAR_6_PAR6__W 16
10671#define SIO_HI_RA_RAM_PAR_6_PAR6__M 0xFFFF
10672#define SIO_HI_RA_RAM_PAR_6_PAR6__PRE 0x0
10673
10674#define SIO_HI_RA_RAM_PAR_6_CFG_TOD__B 0
10675#define SIO_HI_RA_RAM_PAR_6_CFG_TOD__W 8
10676#define SIO_HI_RA_RAM_PAR_6_CFG_TOD__M 0xFF
10677#define SIO_HI_RA_RAM_PAR_6_CFG_TOD__PRE 0xFF
10678
10679#define SIO_HI_RA_RAM_PAR_6_CFG_WDD__B 8
10680#define SIO_HI_RA_RAM_PAR_6_CFG_WDD__W 8
10681#define SIO_HI_RA_RAM_PAR_6_CFG_WDD__M 0xFF00
10682#define SIO_HI_RA_RAM_PAR_6_CFG_WDD__PRE 0x9500
10683
10684#define SIO_HI_RA_RAM_AB_TEMP__A 0x42006E
10685#define SIO_HI_RA_RAM_AB_TEMP__W 16
10686#define SIO_HI_RA_RAM_AB_TEMP__M 0xFFFF
10687#define SIO_HI_RA_RAM_AB_TEMP__PRE 0x0
10688
10689#define SIO_HI_RA_RAM_I2C_CTL__A 0x42006F
10690#define SIO_HI_RA_RAM_I2C_CTL__W 16
10691#define SIO_HI_RA_RAM_I2C_CTL__M 0xFFFF
10692#define SIO_HI_RA_RAM_I2C_CTL__PRE 0x0
10693
10694#define SIO_HI_RA_RAM_VB_ENTRY0__A 0x420070
10695#define SIO_HI_RA_RAM_VB_ENTRY0__W 16
10696#define SIO_HI_RA_RAM_VB_ENTRY0__M 0xFFFF
10697#define SIO_HI_RA_RAM_VB_ENTRY0__PRE 0x0
10698
10699#define SIO_HI_RA_RAM_VB_ENTRY0_HI_MAP_BNK__B 0
10700#define SIO_HI_RA_RAM_VB_ENTRY0_HI_MAP_BNK__W 4
10701#define SIO_HI_RA_RAM_VB_ENTRY0_HI_MAP_BNK__M 0xF
10702#define SIO_HI_RA_RAM_VB_ENTRY0_HI_MAP_BNK__PRE 0x0
10703
10704#define SIO_HI_RA_RAM_VB_ENTRY0_HI_MAP_BLK__B 4
10705#define SIO_HI_RA_RAM_VB_ENTRY0_HI_MAP_BLK__W 4
10706#define SIO_HI_RA_RAM_VB_ENTRY0_HI_MAP_BLK__M 0xF0
10707#define SIO_HI_RA_RAM_VB_ENTRY0_HI_MAP_BLK__PRE 0x0
10708
10709#define SIO_HI_RA_RAM_VB_ENTRY0_HI_VIRT_BNK__B 8
10710#define SIO_HI_RA_RAM_VB_ENTRY0_HI_VIRT_BNK__W 4
10711#define SIO_HI_RA_RAM_VB_ENTRY0_HI_VIRT_BNK__M 0xF00
10712#define SIO_HI_RA_RAM_VB_ENTRY0_HI_VIRT_BNK__PRE 0x0
10713
10714#define SIO_HI_RA_RAM_VB_ENTRY0_HI_VIRT_BLK__B 12
10715#define SIO_HI_RA_RAM_VB_ENTRY0_HI_VIRT_BLK__W 4
10716#define SIO_HI_RA_RAM_VB_ENTRY0_HI_VIRT_BLK__M 0xF000
10717#define SIO_HI_RA_RAM_VB_ENTRY0_HI_VIRT_BLK__PRE 0x0
10718
10719#define SIO_HI_RA_RAM_VB_OFFSET0__A 0x420071
10720#define SIO_HI_RA_RAM_VB_OFFSET0__W 16
10721#define SIO_HI_RA_RAM_VB_OFFSET0__M 0xFFFF
10722#define SIO_HI_RA_RAM_VB_OFFSET0__PRE 0x0
10723
10724#define SIO_HI_RA_RAM_VB_OFFSET0_HI_MAP_OFF0__B 0
10725#define SIO_HI_RA_RAM_VB_OFFSET0_HI_MAP_OFF0__W 16
10726#define SIO_HI_RA_RAM_VB_OFFSET0_HI_MAP_OFF0__M 0xFFFF
10727#define SIO_HI_RA_RAM_VB_OFFSET0_HI_MAP_OFF0__PRE 0x0
10728
10729#define SIO_HI_RA_RAM_VB_ENTRY1__A 0x420072
10730#define SIO_HI_RA_RAM_VB_ENTRY1__W 16
10731#define SIO_HI_RA_RAM_VB_ENTRY1__M 0xFFFF
10732#define SIO_HI_RA_RAM_VB_ENTRY1__PRE 0x0
10733#define SIO_HI_RA_RAM_VB_OFFSET1__A 0x420073
10734#define SIO_HI_RA_RAM_VB_OFFSET1__W 16
10735#define SIO_HI_RA_RAM_VB_OFFSET1__M 0xFFFF
10736#define SIO_HI_RA_RAM_VB_OFFSET1__PRE 0x0
10737
10738#define SIO_HI_RA_RAM_VB_OFFSET1_HI_MAP_OFF__B 0
10739#define SIO_HI_RA_RAM_VB_OFFSET1_HI_MAP_OFF__W 16
10740#define SIO_HI_RA_RAM_VB_OFFSET1_HI_MAP_OFF__M 0xFFFF
10741#define SIO_HI_RA_RAM_VB_OFFSET1_HI_MAP_OFF__PRE 0x0
10742
10743#define SIO_HI_RA_RAM_VB_ENTRY2__A 0x420074
10744#define SIO_HI_RA_RAM_VB_ENTRY2__W 16
10745#define SIO_HI_RA_RAM_VB_ENTRY2__M 0xFFFF
10746#define SIO_HI_RA_RAM_VB_ENTRY2__PRE 0x0
10747#define SIO_HI_RA_RAM_VB_OFFSET2__A 0x420075
10748#define SIO_HI_RA_RAM_VB_OFFSET2__W 16
10749#define SIO_HI_RA_RAM_VB_OFFSET2__M 0xFFFF
10750#define SIO_HI_RA_RAM_VB_OFFSET2__PRE 0x0
10751
10752#define SIO_HI_RA_RAM_VB_OFFSET2_HI_MAP_OFF__B 0
10753#define SIO_HI_RA_RAM_VB_OFFSET2_HI_MAP_OFF__W 16
10754#define SIO_HI_RA_RAM_VB_OFFSET2_HI_MAP_OFF__M 0xFFFF
10755#define SIO_HI_RA_RAM_VB_OFFSET2_HI_MAP_OFF__PRE 0x0
10756
10757#define SIO_HI_RA_RAM_VB_ENTRY3__A 0x420076
10758#define SIO_HI_RA_RAM_VB_ENTRY3__W 16
10759#define SIO_HI_RA_RAM_VB_ENTRY3__M 0xFFFF
10760#define SIO_HI_RA_RAM_VB_ENTRY3__PRE 0x0
10761#define SIO_HI_RA_RAM_VB_OFFSET3__A 0x420077
10762#define SIO_HI_RA_RAM_VB_OFFSET3__W 16
10763#define SIO_HI_RA_RAM_VB_OFFSET3__M 0xFFFF
10764#define SIO_HI_RA_RAM_VB_OFFSET3__PRE 0x0
10765
10766#define SIO_HI_RA_RAM_VB_OFFSET3_HI_MAP_OFF__B 0
10767#define SIO_HI_RA_RAM_VB_OFFSET3_HI_MAP_OFF__W 16
10768#define SIO_HI_RA_RAM_VB_OFFSET3_HI_MAP_OFF__M 0xFFFF
10769#define SIO_HI_RA_RAM_VB_OFFSET3_HI_MAP_OFF__PRE 0x0
10770
10771#define SIO_HI_RA_RAM_VB_ENTRY4__A 0x420078
10772#define SIO_HI_RA_RAM_VB_ENTRY4__W 16
10773#define SIO_HI_RA_RAM_VB_ENTRY4__M 0xFFFF
10774#define SIO_HI_RA_RAM_VB_ENTRY4__PRE 0x0
10775#define SIO_HI_RA_RAM_VB_OFFSET4__A 0x420079
10776#define SIO_HI_RA_RAM_VB_OFFSET4__W 16
10777#define SIO_HI_RA_RAM_VB_OFFSET4__M 0xFFFF
10778#define SIO_HI_RA_RAM_VB_OFFSET4__PRE 0x0
10779
10780#define SIO_HI_RA_RAM_VB_OFFSET4_HI_MAP_OFF__B 0
10781#define SIO_HI_RA_RAM_VB_OFFSET4_HI_MAP_OFF__W 16
10782#define SIO_HI_RA_RAM_VB_OFFSET4_HI_MAP_OFF__M 0xFFFF
10783#define SIO_HI_RA_RAM_VB_OFFSET4_HI_MAP_OFF__PRE 0x0
10784
10785#define SIO_HI_RA_RAM_VB_ENTRY5__A 0x42007A
10786#define SIO_HI_RA_RAM_VB_ENTRY5__W 16
10787#define SIO_HI_RA_RAM_VB_ENTRY5__M 0xFFFF
10788#define SIO_HI_RA_RAM_VB_ENTRY5__PRE 0x0
10789#define SIO_HI_RA_RAM_VB_OFFSET5__A 0x42007B
10790#define SIO_HI_RA_RAM_VB_OFFSET5__W 16
10791#define SIO_HI_RA_RAM_VB_OFFSET5__M 0xFFFF
10792#define SIO_HI_RA_RAM_VB_OFFSET5__PRE 0x0
10793
10794#define SIO_HI_RA_RAM_VB_OFFSET5_HI_MAP_OFF__B 0
10795#define SIO_HI_RA_RAM_VB_OFFSET5_HI_MAP_OFF__W 16
10796#define SIO_HI_RA_RAM_VB_OFFSET5_HI_MAP_OFF__M 0xFFFF
10797#define SIO_HI_RA_RAM_VB_OFFSET5_HI_MAP_OFF__PRE 0x0
10798
10799#define SIO_HI_RA_RAM_VB_ENTRY6__A 0x42007C
10800#define SIO_HI_RA_RAM_VB_ENTRY6__W 16
10801#define SIO_HI_RA_RAM_VB_ENTRY6__M 0xFFFF
10802#define SIO_HI_RA_RAM_VB_ENTRY6__PRE 0x0
10803#define SIO_HI_RA_RAM_VB_OFFSET6__A 0x42007D
10804#define SIO_HI_RA_RAM_VB_OFFSET6__W 16
10805#define SIO_HI_RA_RAM_VB_OFFSET6__M 0xFFFF
10806#define SIO_HI_RA_RAM_VB_OFFSET6__PRE 0x0
10807
10808#define SIO_HI_RA_RAM_VB_OFFSET6_HI_MAP_OFF__B 0
10809#define SIO_HI_RA_RAM_VB_OFFSET6_HI_MAP_OFF__W 16
10810#define SIO_HI_RA_RAM_VB_OFFSET6_HI_MAP_OFF__M 0xFFFF
10811#define SIO_HI_RA_RAM_VB_OFFSET6_HI_MAP_OFF__PRE 0x0
10812
10813#define SIO_HI_RA_RAM_VB_ENTRY7__A 0x42007E
10814#define SIO_HI_RA_RAM_VB_ENTRY7__W 16
10815#define SIO_HI_RA_RAM_VB_ENTRY7__M 0xFFFF
10816#define SIO_HI_RA_RAM_VB_ENTRY7__PRE 0x0
10817#define SIO_HI_RA_RAM_VB_OFFSET7__A 0x42007F
10818#define SIO_HI_RA_RAM_VB_OFFSET7__W 16
10819#define SIO_HI_RA_RAM_VB_OFFSET7__M 0xFFFF
10820#define SIO_HI_RA_RAM_VB_OFFSET7__PRE 0x0
10821
10822#define SIO_HI_RA_RAM_VB_OFFSET7_HI_MAP_OFF__B 0
10823#define SIO_HI_RA_RAM_VB_OFFSET7_HI_MAP_OFF__W 16
10824#define SIO_HI_RA_RAM_VB_OFFSET7_HI_MAP_OFF__M 0xFFFF
10825#define SIO_HI_RA_RAM_VB_OFFSET7_HI_MAP_OFF__PRE 0x0
10826
10827#define SIO_HI_IF_RAM_TRP_BPT_0__A 0x430000
10828#define SIO_HI_IF_RAM_TRP_BPT_0__W 12
10829#define SIO_HI_IF_RAM_TRP_BPT_0__M 0xFFF
10830#define SIO_HI_IF_RAM_TRP_BPT_0__PRE 0x0
10831#define SIO_HI_IF_RAM_TRP_BPT_1__A 0x430001
10832#define SIO_HI_IF_RAM_TRP_BPT_1__W 12
10833#define SIO_HI_IF_RAM_TRP_BPT_1__M 0xFFF
10834#define SIO_HI_IF_RAM_TRP_BPT_1__PRE 0x0
10835#define SIO_HI_IF_RAM_TRP_STK_0__A 0x430002
10836#define SIO_HI_IF_RAM_TRP_STK_0__W 12
10837#define SIO_HI_IF_RAM_TRP_STK_0__M 0xFFF
10838#define SIO_HI_IF_RAM_TRP_STK_0__PRE 0x0
10839#define SIO_HI_IF_RAM_TRP_STK_1__A 0x430003
10840#define SIO_HI_IF_RAM_TRP_STK_1__W 12
10841#define SIO_HI_IF_RAM_TRP_STK_1__M 0xFFF
10842#define SIO_HI_IF_RAM_TRP_STK_1__PRE 0x0
10843#define SIO_HI_IF_RAM_FUN_BASE__A 0x430300
10844#define SIO_HI_IF_RAM_FUN_BASE__W 12
10845#define SIO_HI_IF_RAM_FUN_BASE__M 0xFFF
10846#define SIO_HI_IF_RAM_FUN_BASE__PRE 0x0
10847
10848#define SIO_HI_IF_COMM_EXEC__A 0x440000
10849#define SIO_HI_IF_COMM_EXEC__W 2
10850#define SIO_HI_IF_COMM_EXEC__M 0x3
10851#define SIO_HI_IF_COMM_EXEC__PRE 0x0
10852#define SIO_HI_IF_COMM_EXEC_STOP 0x0
10853#define SIO_HI_IF_COMM_EXEC_ACTIVE 0x1
10854#define SIO_HI_IF_COMM_EXEC_HOLD 0x2
10855#define SIO_HI_IF_COMM_EXEC_STEP 0x3
10856
10857#define SIO_HI_IF_COMM_STATE__A 0x440001
10858#define SIO_HI_IF_COMM_STATE__W 10
10859#define SIO_HI_IF_COMM_STATE__M 0x3FF
10860#define SIO_HI_IF_COMM_STATE__PRE 0x0
10861#define SIO_HI_IF_COMM_INT_REQ__A 0x440003
10862#define SIO_HI_IF_COMM_INT_REQ__W 1
10863#define SIO_HI_IF_COMM_INT_REQ__M 0x1
10864#define SIO_HI_IF_COMM_INT_REQ__PRE 0x0
10865#define SIO_HI_IF_COMM_INT_STA__A 0x440005
10866#define SIO_HI_IF_COMM_INT_STA__W 1
10867#define SIO_HI_IF_COMM_INT_STA__M 0x1
10868#define SIO_HI_IF_COMM_INT_STA__PRE 0x0
10869#define SIO_HI_IF_COMM_INT_STA_STAT__B 0
10870#define SIO_HI_IF_COMM_INT_STA_STAT__W 1
10871#define SIO_HI_IF_COMM_INT_STA_STAT__M 0x1
10872#define SIO_HI_IF_COMM_INT_STA_STAT__PRE 0x0
10873
10874#define SIO_HI_IF_COMM_INT_MSK__A 0x440006
10875#define SIO_HI_IF_COMM_INT_MSK__W 1
10876#define SIO_HI_IF_COMM_INT_MSK__M 0x1
10877#define SIO_HI_IF_COMM_INT_MSK__PRE 0x0
10878#define SIO_HI_IF_COMM_INT_MSK_STAT__B 0
10879#define SIO_HI_IF_COMM_INT_MSK_STAT__W 1
10880#define SIO_HI_IF_COMM_INT_MSK_STAT__M 0x1
10881#define SIO_HI_IF_COMM_INT_MSK_STAT__PRE 0x0
10882
10883#define SIO_HI_IF_COMM_INT_STM__A 0x440007
10884#define SIO_HI_IF_COMM_INT_STM__W 1
10885#define SIO_HI_IF_COMM_INT_STM__M 0x1
10886#define SIO_HI_IF_COMM_INT_STM__PRE 0x0
10887#define SIO_HI_IF_COMM_INT_STM_STAT__B 0
10888#define SIO_HI_IF_COMM_INT_STM_STAT__W 1
10889#define SIO_HI_IF_COMM_INT_STM_STAT__M 0x1
10890#define SIO_HI_IF_COMM_INT_STM_STAT__PRE 0x0
10891
10892#define SIO_HI_IF_STK_0__A 0x440010
10893#define SIO_HI_IF_STK_0__W 10
10894#define SIO_HI_IF_STK_0__M 0x3FF
10895#define SIO_HI_IF_STK_0__PRE 0x2
10896
10897#define SIO_HI_IF_STK_0_ADDR__B 0
10898#define SIO_HI_IF_STK_0_ADDR__W 10
10899#define SIO_HI_IF_STK_0_ADDR__M 0x3FF
10900#define SIO_HI_IF_STK_0_ADDR__PRE 0x2
10901
10902#define SIO_HI_IF_STK_1__A 0x440011
10903#define SIO_HI_IF_STK_1__W 10
10904#define SIO_HI_IF_STK_1__M 0x3FF
10905#define SIO_HI_IF_STK_1__PRE 0x2
10906#define SIO_HI_IF_STK_1_ADDR__B 0
10907#define SIO_HI_IF_STK_1_ADDR__W 10
10908#define SIO_HI_IF_STK_1_ADDR__M 0x3FF
10909#define SIO_HI_IF_STK_1_ADDR__PRE 0x2
10910
10911#define SIO_HI_IF_STK_2__A 0x440012
10912#define SIO_HI_IF_STK_2__W 10
10913#define SIO_HI_IF_STK_2__M 0x3FF
10914#define SIO_HI_IF_STK_2__PRE 0x2
10915#define SIO_HI_IF_STK_2_ADDR__B 0
10916#define SIO_HI_IF_STK_2_ADDR__W 10
10917#define SIO_HI_IF_STK_2_ADDR__M 0x3FF
10918#define SIO_HI_IF_STK_2_ADDR__PRE 0x2
10919
10920#define SIO_HI_IF_STK_3__A 0x440013
10921#define SIO_HI_IF_STK_3__W 10
10922#define SIO_HI_IF_STK_3__M 0x3FF
10923#define SIO_HI_IF_STK_3__PRE 0x2
10924
10925#define SIO_HI_IF_STK_3_ADDR__B 0
10926#define SIO_HI_IF_STK_3_ADDR__W 10
10927#define SIO_HI_IF_STK_3_ADDR__M 0x3FF
10928#define SIO_HI_IF_STK_3_ADDR__PRE 0x2
10929
10930#define SIO_HI_IF_BPT_IDX__A 0x44001F
10931#define SIO_HI_IF_BPT_IDX__W 1
10932#define SIO_HI_IF_BPT_IDX__M 0x1
10933#define SIO_HI_IF_BPT_IDX__PRE 0x0
10934
10935#define SIO_HI_IF_BPT_IDX_ADDR__B 0
10936#define SIO_HI_IF_BPT_IDX_ADDR__W 1
10937#define SIO_HI_IF_BPT_IDX_ADDR__M 0x1
10938#define SIO_HI_IF_BPT_IDX_ADDR__PRE 0x0
10939
10940#define SIO_HI_IF_BPT__A 0x440020
10941#define SIO_HI_IF_BPT__W 10
10942#define SIO_HI_IF_BPT__M 0x3FF
10943#define SIO_HI_IF_BPT__PRE 0x2
10944
10945#define SIO_HI_IF_BPT_ADDR__B 0
10946#define SIO_HI_IF_BPT_ADDR__W 10
10947#define SIO_HI_IF_BPT_ADDR__M 0x3FF
10948#define SIO_HI_IF_BPT_ADDR__PRE 0x2
10949
10950#define SIO_CC_COMM_EXEC__A 0x450000
10951#define SIO_CC_COMM_EXEC__W 2
10952#define SIO_CC_COMM_EXEC__M 0x3
10953#define SIO_CC_COMM_EXEC__PRE 0x0
10954#define SIO_CC_COMM_EXEC_STOP 0x0
10955#define SIO_CC_COMM_EXEC_ACTIVE 0x1
10956#define SIO_CC_COMM_EXEC_HOLD 0x2
10957
10958#define SIO_CC_PLL_MODE__A 0x450010
10959#define SIO_CC_PLL_MODE__W 6
10960#define SIO_CC_PLL_MODE__M 0x3F
10961#define SIO_CC_PLL_MODE__PRE 0x0
10962
10963#define SIO_CC_PLL_MODE_FREF_SEL__B 0
10964#define SIO_CC_PLL_MODE_FREF_SEL__W 2
10965#define SIO_CC_PLL_MODE_FREF_SEL__M 0x3
10966#define SIO_CC_PLL_MODE_FREF_SEL__PRE 0x0
10967#define SIO_CC_PLL_MODE_FREF_SEL_OHW 0x0
10968#define SIO_CC_PLL_MODE_FREF_SEL_27_00 0x1
10969#define SIO_CC_PLL_MODE_FREF_SEL_20_25 0x2
10970#define SIO_CC_PLL_MODE_FREF_SEL_4_00 0x3
10971
10972#define SIO_CC_PLL_MODE_LOCKSEL__B 2
10973#define SIO_CC_PLL_MODE_LOCKSEL__W 2
10974#define SIO_CC_PLL_MODE_LOCKSEL__M 0xC
10975#define SIO_CC_PLL_MODE_LOCKSEL__PRE 0x0
10976
10977#define SIO_CC_PLL_MODE_BYPASS__B 4
10978#define SIO_CC_PLL_MODE_BYPASS__W 2
10979#define SIO_CC_PLL_MODE_BYPASS__M 0x30
10980#define SIO_CC_PLL_MODE_BYPASS__PRE 0x0
10981#define SIO_CC_PLL_MODE_BYPASS_OHW 0x0
10982#define SIO_CC_PLL_MODE_BYPASS_OFF 0x10
10983#define SIO_CC_PLL_MODE_BYPASS_ON 0x20
10984
10985#define SIO_CC_PLL_TEST__A 0x450011
10986#define SIO_CC_PLL_TEST__W 8
10987#define SIO_CC_PLL_TEST__M 0xFF
10988#define SIO_CC_PLL_TEST__PRE 0x0
10989
10990#define SIO_CC_PLL_LOCK__A 0x450012
10991#define SIO_CC_PLL_LOCK__W 1
10992#define SIO_CC_PLL_LOCK__M 0x1
10993#define SIO_CC_PLL_LOCK__PRE 0x0
10994#define SIO_CC_CLK_MODE__A 0x450014
10995#define SIO_CC_CLK_MODE__W 5
10996#define SIO_CC_CLK_MODE__M 0x1F
10997#define SIO_CC_CLK_MODE__PRE 0x0
10998
10999#define SIO_CC_CLK_MODE_DELAY__B 0
11000#define SIO_CC_CLK_MODE_DELAY__W 4
11001#define SIO_CC_CLK_MODE_DELAY__M 0xF
11002#define SIO_CC_CLK_MODE_DELAY__PRE 0x0
11003
11004#define SIO_CC_CLK_MODE_INVERT__B 4
11005#define SIO_CC_CLK_MODE_INVERT__W 1
11006#define SIO_CC_CLK_MODE_INVERT__M 0x10
11007#define SIO_CC_CLK_MODE_INVERT__PRE 0x0
11008
11009#define SIO_CC_PWD_MODE__A 0x450015
11010#define SIO_CC_PWD_MODE__W 3
11011#define SIO_CC_PWD_MODE__M 0x7
11012#define SIO_CC_PWD_MODE__PRE 0x0
11013
11014#define SIO_CC_PWD_MODE_LEVEL__B 0
11015#define SIO_CC_PWD_MODE_LEVEL__W 2
11016#define SIO_CC_PWD_MODE_LEVEL__M 0x3
11017#define SIO_CC_PWD_MODE_LEVEL__PRE 0x0
11018#define SIO_CC_PWD_MODE_LEVEL_NONE 0x0
11019#define SIO_CC_PWD_MODE_LEVEL_CLOCK 0x1
11020#define SIO_CC_PWD_MODE_LEVEL_PLL 0x2
11021#define SIO_CC_PWD_MODE_LEVEL_OSC 0x3
11022
11023#define SIO_CC_PWD_MODE_USE_LOCK__B 2
11024#define SIO_CC_PWD_MODE_USE_LOCK__W 1
11025#define SIO_CC_PWD_MODE_USE_LOCK__M 0x4
11026#define SIO_CC_PWD_MODE_USE_LOCK__PRE 0x0
11027
11028#define SIO_CC_SOFT_RST__A 0x450016
11029#define SIO_CC_SOFT_RST__W 2
11030#define SIO_CC_SOFT_RST__M 0x3
11031#define SIO_CC_SOFT_RST__PRE 0x0
11032
11033#define SIO_CC_SOFT_RST_SYS__B 0
11034#define SIO_CC_SOFT_RST_SYS__W 1
11035#define SIO_CC_SOFT_RST_SYS__M 0x1
11036#define SIO_CC_SOFT_RST_SYS__PRE 0x0
11037
11038#define SIO_CC_SOFT_RST_OSC__B 1
11039#define SIO_CC_SOFT_RST_OSC__W 1
11040#define SIO_CC_SOFT_RST_OSC__M 0x2
11041#define SIO_CC_SOFT_RST_OSC__PRE 0x0
11042
11043#define SIO_CC_UPDATE__A 0x450017
11044#define SIO_CC_UPDATE__W 16
11045#define SIO_CC_UPDATE__M 0xFFFF
11046#define SIO_CC_UPDATE__PRE 0x0
11047#define SIO_CC_UPDATE_KEY 0xFABA
11048
11049#define SIO_SA_COMM_EXEC__A 0x460000
11050#define SIO_SA_COMM_EXEC__W 2
11051#define SIO_SA_COMM_EXEC__M 0x3
11052#define SIO_SA_COMM_EXEC__PRE 0x0
11053#define SIO_SA_COMM_EXEC_STOP 0x0
11054#define SIO_SA_COMM_EXEC_ACTIVE 0x1
11055#define SIO_SA_COMM_EXEC_HOLD 0x2
11056
11057#define SIO_SA_COMM_INT_REQ__A 0x460003
11058#define SIO_SA_COMM_INT_REQ__W 1
11059#define SIO_SA_COMM_INT_REQ__M 0x1
11060#define SIO_SA_COMM_INT_REQ__PRE 0x0
11061#define SIO_SA_COMM_INT_STA__A 0x460005
11062#define SIO_SA_COMM_INT_STA__W 4
11063#define SIO_SA_COMM_INT_STA__M 0xF
11064#define SIO_SA_COMM_INT_STA__PRE 0x0
11065
11066#define SIO_SA_COMM_INT_STA_TR_END_INT_STA__B 0
11067#define SIO_SA_COMM_INT_STA_TR_END_INT_STA__W 1
11068#define SIO_SA_COMM_INT_STA_TR_END_INT_STA__M 0x1
11069#define SIO_SA_COMM_INT_STA_TR_END_INT_STA__PRE 0x0
11070
11071#define SIO_SA_COMM_INT_STA_TR_BUFF_EMPTY_INT__B 1
11072#define SIO_SA_COMM_INT_STA_TR_BUFF_EMPTY_INT__W 1
11073#define SIO_SA_COMM_INT_STA_TR_BUFF_EMPTY_INT__M 0x2
11074#define SIO_SA_COMM_INT_STA_TR_BUFF_EMPTY_INT__PRE 0x0
11075
11076#define SIO_SA_COMM_INT_STA_RX_END_INT_STA__B 2
11077#define SIO_SA_COMM_INT_STA_RX_END_INT_STA__W 1
11078#define SIO_SA_COMM_INT_STA_RX_END_INT_STA__M 0x4
11079#define SIO_SA_COMM_INT_STA_RX_END_INT_STA__PRE 0x0
11080
11081#define SIO_SA_COMM_INT_STA_RX_BUFF_FULL_INT__B 3
11082#define SIO_SA_COMM_INT_STA_RX_BUFF_FULL_INT__W 1
11083#define SIO_SA_COMM_INT_STA_RX_BUFF_FULL_INT__M 0x8
11084#define SIO_SA_COMM_INT_STA_RX_BUFF_FULL_INT__PRE 0x0
11085
11086#define SIO_SA_COMM_INT_MSK__A 0x460006
11087#define SIO_SA_COMM_INT_MSK__W 4
11088#define SIO_SA_COMM_INT_MSK__M 0xF
11089#define SIO_SA_COMM_INT_MSK__PRE 0x0
11090
11091#define SIO_SA_COMM_INT_MSK_TR_END_INT_MASK__B 0
11092#define SIO_SA_COMM_INT_MSK_TR_END_INT_MASK__W 1
11093#define SIO_SA_COMM_INT_MSK_TR_END_INT_MASK__M 0x1
11094#define SIO_SA_COMM_INT_MSK_TR_END_INT_MASK__PRE 0x0
11095
11096#define SIO_SA_COMM_INT_MSK_TR_BUFF_EMPTY_MASK__B 1
11097#define SIO_SA_COMM_INT_MSK_TR_BUFF_EMPTY_MASK__W 1
11098#define SIO_SA_COMM_INT_MSK_TR_BUFF_EMPTY_MASK__M 0x2
11099#define SIO_SA_COMM_INT_MSK_TR_BUFF_EMPTY_MASK__PRE 0x0
11100
11101#define SIO_SA_COMM_INT_MSK_RX_END_INT_MASK__B 2
11102#define SIO_SA_COMM_INT_MSK_RX_END_INT_MASK__W 1
11103#define SIO_SA_COMM_INT_MSK_RX_END_INT_MASK__M 0x4
11104#define SIO_SA_COMM_INT_MSK_RX_END_INT_MASK__PRE 0x0
11105
11106#define SIO_SA_COMM_INT_MSK_RX_BUFF_FULL_MASK__B 3
11107#define SIO_SA_COMM_INT_MSK_RX_BUFF_FULL_MASK__W 1
11108#define SIO_SA_COMM_INT_MSK_RX_BUFF_FULL_MASK__M 0x8
11109#define SIO_SA_COMM_INT_MSK_RX_BUFF_FULL_MASK__PRE 0x0
11110
11111#define SIO_SA_COMM_INT_STM__A 0x460007
11112#define SIO_SA_COMM_INT_STM__W 4
11113#define SIO_SA_COMM_INT_STM__M 0xF
11114#define SIO_SA_COMM_INT_STM__PRE 0x0
11115
11116#define SIO_SA_COMM_INT_STM_TR_END_INT_MASK__B 0
11117#define SIO_SA_COMM_INT_STM_TR_END_INT_MASK__W 1
11118#define SIO_SA_COMM_INT_STM_TR_END_INT_MASK__M 0x1
11119#define SIO_SA_COMM_INT_STM_TR_END_INT_MASK__PRE 0x0
11120
11121#define SIO_SA_COMM_INT_STM_TR_BUFF_EMPTY_MASK__B 1
11122#define SIO_SA_COMM_INT_STM_TR_BUFF_EMPTY_MASK__W 1
11123#define SIO_SA_COMM_INT_STM_TR_BUFF_EMPTY_MASK__M 0x2
11124#define SIO_SA_COMM_INT_STM_TR_BUFF_EMPTY_MASK__PRE 0x0
11125
11126#define SIO_SA_COMM_INT_STM_RX_END_INT_MASK__B 2
11127#define SIO_SA_COMM_INT_STM_RX_END_INT_MASK__W 1
11128#define SIO_SA_COMM_INT_STM_RX_END_INT_MASK__M 0x4
11129#define SIO_SA_COMM_INT_STM_RX_END_INT_MASK__PRE 0x0
11130
11131#define SIO_SA_COMM_INT_STM_RX_BUFF_FULL_MASK__B 3
11132#define SIO_SA_COMM_INT_STM_RX_BUFF_FULL_MASK__W 1
11133#define SIO_SA_COMM_INT_STM_RX_BUFF_FULL_MASK__M 0x8
11134#define SIO_SA_COMM_INT_STM_RX_BUFF_FULL_MASK__PRE 0x0
11135
11136#define SIO_SA_PRESCALER__A 0x460010
11137#define SIO_SA_PRESCALER__W 13
11138#define SIO_SA_PRESCALER__M 0x1FFF
11139#define SIO_SA_PRESCALER__PRE 0x18B7
11140#define SIO_SA_TX_DATA0__A 0x460011
11141#define SIO_SA_TX_DATA0__W 16
11142#define SIO_SA_TX_DATA0__M 0xFFFF
11143#define SIO_SA_TX_DATA0__PRE 0x0
11144#define SIO_SA_TX_DATA1__A 0x460012
11145#define SIO_SA_TX_DATA1__W 16
11146#define SIO_SA_TX_DATA1__M 0xFFFF
11147#define SIO_SA_TX_DATA1__PRE 0x0
11148#define SIO_SA_TX_DATA2__A 0x460013
11149#define SIO_SA_TX_DATA2__W 16
11150#define SIO_SA_TX_DATA2__M 0xFFFF
11151#define SIO_SA_TX_DATA2__PRE 0x0
11152#define SIO_SA_TX_DATA3__A 0x460014
11153#define SIO_SA_TX_DATA3__W 16
11154#define SIO_SA_TX_DATA3__M 0xFFFF
11155#define SIO_SA_TX_DATA3__PRE 0x0
11156#define SIO_SA_TX_LENGTH__A 0x460015
11157#define SIO_SA_TX_LENGTH__W 6
11158#define SIO_SA_TX_LENGTH__M 0x3F
11159#define SIO_SA_TX_LENGTH__PRE 0x0
11160#define SIO_SA_TX_COMMAND__A 0x460016
11161#define SIO_SA_TX_COMMAND__W 2
11162#define SIO_SA_TX_COMMAND__M 0x3
11163#define SIO_SA_TX_COMMAND__PRE 0x3
11164
11165#define SIO_SA_TX_COMMAND_TX_INVERT__B 0
11166#define SIO_SA_TX_COMMAND_TX_INVERT__W 1
11167#define SIO_SA_TX_COMMAND_TX_INVERT__M 0x1
11168#define SIO_SA_TX_COMMAND_TX_INVERT__PRE 0x1
11169
11170#define SIO_SA_TX_COMMAND_TX_ENABLE__B 1
11171#define SIO_SA_TX_COMMAND_TX_ENABLE__W 1
11172#define SIO_SA_TX_COMMAND_TX_ENABLE__M 0x2
11173#define SIO_SA_TX_COMMAND_TX_ENABLE__PRE 0x2
11174
11175#define SIO_SA_TX_STATUS__A 0x460017
11176#define SIO_SA_TX_STATUS__W 2
11177#define SIO_SA_TX_STATUS__M 0x3
11178#define SIO_SA_TX_STATUS__PRE 0x0
11179
11180#define SIO_SA_TX_STATUS_BUSY__B 0
11181#define SIO_SA_TX_STATUS_BUSY__W 1
11182#define SIO_SA_TX_STATUS_BUSY__M 0x1
11183#define SIO_SA_TX_STATUS_BUSY__PRE 0x0
11184
11185#define SIO_SA_TX_STATUS_BUFF_FULL__B 1
11186#define SIO_SA_TX_STATUS_BUFF_FULL__W 1
11187#define SIO_SA_TX_STATUS_BUFF_FULL__M 0x2
11188#define SIO_SA_TX_STATUS_BUFF_FULL__PRE 0x0
11189
11190#define SIO_SA_RX_DATA0__A 0x460018
11191#define SIO_SA_RX_DATA0__W 16
11192#define SIO_SA_RX_DATA0__M 0xFFFF
11193#define SIO_SA_RX_DATA0__PRE 0x0
11194#define SIO_SA_RX_DATA1__A 0x460019
11195#define SIO_SA_RX_DATA1__W 16
11196#define SIO_SA_RX_DATA1__M 0xFFFF
11197#define SIO_SA_RX_DATA1__PRE 0x0
11198#define SIO_SA_RX_LENGTH__A 0x46001A
11199#define SIO_SA_RX_LENGTH__W 6
11200#define SIO_SA_RX_LENGTH__M 0x3F
11201#define SIO_SA_RX_LENGTH__PRE 0x0
11202#define SIO_SA_RX_COMMAND__A 0x46001B
11203#define SIO_SA_RX_COMMAND__W 1
11204#define SIO_SA_RX_COMMAND__M 0x1
11205#define SIO_SA_RX_COMMAND__PRE 0x1
11206
11207#define SIO_SA_RX_COMMAND_RX_INVERT__B 0
11208#define SIO_SA_RX_COMMAND_RX_INVERT__W 1
11209#define SIO_SA_RX_COMMAND_RX_INVERT__M 0x1
11210#define SIO_SA_RX_COMMAND_RX_INVERT__PRE 0x1
11211
11212#define SIO_SA_RX_STATUS__A 0x46001C
11213#define SIO_SA_RX_STATUS__W 2
11214#define SIO_SA_RX_STATUS__M 0x3
11215#define SIO_SA_RX_STATUS__PRE 0x0
11216
11217#define SIO_SA_RX_STATUS_BUSY__B 0
11218#define SIO_SA_RX_STATUS_BUSY__W 1
11219#define SIO_SA_RX_STATUS_BUSY__M 0x1
11220#define SIO_SA_RX_STATUS_BUSY__PRE 0x0
11221
11222#define SIO_SA_RX_STATUS_BUFF_FULL__B 1
11223#define SIO_SA_RX_STATUS_BUFF_FULL__W 1
11224#define SIO_SA_RX_STATUS_BUFF_FULL__M 0x2
11225#define SIO_SA_RX_STATUS_BUFF_FULL__PRE 0x0
11226
11227#define SIO_PDR_COMM_EXEC__A 0x7F0000
11228#define SIO_PDR_COMM_EXEC__W 2
11229#define SIO_PDR_COMM_EXEC__M 0x3
11230#define SIO_PDR_COMM_EXEC__PRE 0x0
11231#define SIO_PDR_COMM_EXEC_STOP 0x0
11232#define SIO_PDR_COMM_EXEC_ACTIVE 0x1
11233#define SIO_PDR_COMM_EXEC_HOLD 0x2
11234
11235#define SIO_PDR_MON_CFG__A 0x7F0010
11236#define SIO_PDR_MON_CFG__W 2
11237#define SIO_PDR_MON_CFG__M 0x3
11238#define SIO_PDR_MON_CFG__PRE 0x0
11239
11240#define SIO_PDR_MON_CFG_OSEL__B 0
11241#define SIO_PDR_MON_CFG_OSEL__W 1
11242#define SIO_PDR_MON_CFG_OSEL__M 0x1
11243#define SIO_PDR_MON_CFG_OSEL__PRE 0x0
11244
11245#define SIO_PDR_MON_CFG_IACT__B 1
11246#define SIO_PDR_MON_CFG_IACT__W 1
11247#define SIO_PDR_MON_CFG_IACT__M 0x2
11248#define SIO_PDR_MON_CFG_IACT__PRE 0x0
11249
11250#define SIO_PDR_FDB_CFG__A 0x7F0011
11251#define SIO_PDR_FDB_CFG__W 2
11252#define SIO_PDR_FDB_CFG__M 0x3
11253#define SIO_PDR_FDB_CFG__PRE 0x0
11254#define SIO_PDR_FDB_CFG_SEL__B 0
11255#define SIO_PDR_FDB_CFG_SEL__W 2
11256#define SIO_PDR_FDB_CFG_SEL__M 0x3
11257#define SIO_PDR_FDB_CFG_SEL__PRE 0x0
11258
11259#define SIO_PDR_SMA_RX_SEL__A 0x7F0012
11260#define SIO_PDR_SMA_RX_SEL__W 4
11261#define SIO_PDR_SMA_RX_SEL__M 0xF
11262#define SIO_PDR_SMA_RX_SEL__PRE 0x0
11263#define SIO_PDR_SMA_RX_SEL_SEL__B 0
11264#define SIO_PDR_SMA_RX_SEL_SEL__W 4
11265#define SIO_PDR_SMA_RX_SEL_SEL__M 0xF
11266#define SIO_PDR_SMA_RX_SEL_SEL__PRE 0x0
11267
11268#define SIO_PDR_SMA_TX_SILENT__A 0x7F0013
11269#define SIO_PDR_SMA_TX_SILENT__W 1
11270#define SIO_PDR_SMA_TX_SILENT__M 0x1
11271#define SIO_PDR_SMA_TX_SILENT__PRE 0x0
11272#define SIO_PDR_UIO_IN_LO__A 0x7F0014
11273#define SIO_PDR_UIO_IN_LO__W 16
11274#define SIO_PDR_UIO_IN_LO__M 0xFFFF
11275#define SIO_PDR_UIO_IN_LO__PRE 0x0
11276#define SIO_PDR_UIO_IN_LO_DATA__B 0
11277#define SIO_PDR_UIO_IN_LO_DATA__W 16
11278#define SIO_PDR_UIO_IN_LO_DATA__M 0xFFFF
11279#define SIO_PDR_UIO_IN_LO_DATA__PRE 0x0
11280
11281#define SIO_PDR_UIO_IN_HI__A 0x7F0015
11282#define SIO_PDR_UIO_IN_HI__W 14
11283#define SIO_PDR_UIO_IN_HI__M 0x3FFF
11284#define SIO_PDR_UIO_IN_HI__PRE 0x0
11285#define SIO_PDR_UIO_IN_HI_DATA__B 0
11286#define SIO_PDR_UIO_IN_HI_DATA__W 14
11287#define SIO_PDR_UIO_IN_HI_DATA__M 0x3FFF
11288#define SIO_PDR_UIO_IN_HI_DATA__PRE 0x0
11289
11290#define SIO_PDR_UIO_OUT_LO__A 0x7F0016
11291#define SIO_PDR_UIO_OUT_LO__W 16
11292#define SIO_PDR_UIO_OUT_LO__M 0xFFFF
11293#define SIO_PDR_UIO_OUT_LO__PRE 0x0
11294#define SIO_PDR_UIO_OUT_LO_DATA__B 0
11295#define SIO_PDR_UIO_OUT_LO_DATA__W 16
11296#define SIO_PDR_UIO_OUT_LO_DATA__M 0xFFFF
11297#define SIO_PDR_UIO_OUT_LO_DATA__PRE 0x0
11298
11299#define SIO_PDR_UIO_OUT_HI__A 0x7F0017
11300#define SIO_PDR_UIO_OUT_HI__W 14
11301#define SIO_PDR_UIO_OUT_HI__M 0x3FFF
11302#define SIO_PDR_UIO_OUT_HI__PRE 0x0
11303#define SIO_PDR_UIO_OUT_HI_DATA__B 0
11304#define SIO_PDR_UIO_OUT_HI_DATA__W 14
11305#define SIO_PDR_UIO_OUT_HI_DATA__M 0x3FFF
11306#define SIO_PDR_UIO_OUT_HI_DATA__PRE 0x0
11307
11308#define SIO_PDR_PWM1_MODE__A 0x7F0018
11309#define SIO_PDR_PWM1_MODE__W 2
11310#define SIO_PDR_PWM1_MODE__M 0x3
11311#define SIO_PDR_PWM1_MODE__PRE 0x0
11312#define SIO_PDR_PWM1_PRESCALE__A 0x7F0019
11313#define SIO_PDR_PWM1_PRESCALE__W 6
11314#define SIO_PDR_PWM1_PRESCALE__M 0x3F
11315#define SIO_PDR_PWM1_PRESCALE__PRE 0x0
11316#define SIO_PDR_PWM1_VALUE__A 0x7F001A
11317#define SIO_PDR_PWM1_VALUE__W 11
11318#define SIO_PDR_PWM1_VALUE__M 0x7FF
11319#define SIO_PDR_PWM1_VALUE__PRE 0x0
11320#define SIO_PDR_PWM2_MODE__A 0x7F001C
11321#define SIO_PDR_PWM2_MODE__W 2
11322#define SIO_PDR_PWM2_MODE__M 0x3
11323#define SIO_PDR_PWM2_MODE__PRE 0x0
11324#define SIO_PDR_PWM2_PRESCALE__A 0x7F001D
11325#define SIO_PDR_PWM2_PRESCALE__W 6
11326#define SIO_PDR_PWM2_PRESCALE__M 0x3F
11327#define SIO_PDR_PWM2_PRESCALE__PRE 0x0
11328#define SIO_PDR_PWM2_VALUE__A 0x7F001E
11329#define SIO_PDR_PWM2_VALUE__W 11
11330#define SIO_PDR_PWM2_VALUE__M 0x7FF
11331#define SIO_PDR_PWM2_VALUE__PRE 0x0
11332#define SIO_PDR_OHW_CFG__A 0x7F001F
11333#define SIO_PDR_OHW_CFG__W 7
11334#define SIO_PDR_OHW_CFG__M 0x7F
11335#define SIO_PDR_OHW_CFG__PRE 0x0
11336
11337#define SIO_PDR_OHW_CFG_FREF_SEL__B 0
11338#define SIO_PDR_OHW_CFG_FREF_SEL__W 2
11339#define SIO_PDR_OHW_CFG_FREF_SEL__M 0x3
11340#define SIO_PDR_OHW_CFG_FREF_SEL__PRE 0x0
11341
11342#define SIO_PDR_OHW_CFG_BYPASS__B 2
11343#define SIO_PDR_OHW_CFG_BYPASS__W 1
11344#define SIO_PDR_OHW_CFG_BYPASS__M 0x4
11345#define SIO_PDR_OHW_CFG_BYPASS__PRE 0x0
11346
11347#define SIO_PDR_OHW_CFG_ASEL__B 3
11348#define SIO_PDR_OHW_CFG_ASEL__W 3
11349#define SIO_PDR_OHW_CFG_ASEL__M 0x38
11350#define SIO_PDR_OHW_CFG_ASEL__PRE 0x0
11351
11352#define SIO_PDR_OHW_CFG_SPEED__B 6
11353#define SIO_PDR_OHW_CFG_SPEED__W 1
11354#define SIO_PDR_OHW_CFG_SPEED__M 0x40
11355#define SIO_PDR_OHW_CFG_SPEED__PRE 0x0
11356
11357#define SIO_PDR_I2S_WS_CFG__A 0x7F0020
11358#define SIO_PDR_I2S_WS_CFG__W 9
11359#define SIO_PDR_I2S_WS_CFG__M 0x1FF
11360#define SIO_PDR_I2S_WS_CFG__PRE 0x10
11361#define SIO_PDR_I2S_WS_CFG_MODE__B 0
11362#define SIO_PDR_I2S_WS_CFG_MODE__W 3
11363#define SIO_PDR_I2S_WS_CFG_MODE__M 0x7
11364#define SIO_PDR_I2S_WS_CFG_MODE__PRE 0x0
11365#define SIO_PDR_I2S_WS_CFG_DRIVE__B 3
11366#define SIO_PDR_I2S_WS_CFG_DRIVE__W 3
11367#define SIO_PDR_I2S_WS_CFG_DRIVE__M 0x38
11368#define SIO_PDR_I2S_WS_CFG_DRIVE__PRE 0x10
11369#define SIO_PDR_I2S_WS_CFG_KEEP__B 6
11370#define SIO_PDR_I2S_WS_CFG_KEEP__W 2
11371#define SIO_PDR_I2S_WS_CFG_KEEP__M 0xC0
11372#define SIO_PDR_I2S_WS_CFG_KEEP__PRE 0x0
11373#define SIO_PDR_I2S_WS_CFG_UIO__B 8
11374#define SIO_PDR_I2S_WS_CFG_UIO__W 1
11375#define SIO_PDR_I2S_WS_CFG_UIO__M 0x100
11376#define SIO_PDR_I2S_WS_CFG_UIO__PRE 0x0
11377
11378#define SIO_PDR_GPIO_CFG__A 0x7F0021
11379#define SIO_PDR_GPIO_CFG__W 9
11380#define SIO_PDR_GPIO_CFG__M 0x1FF
11381#define SIO_PDR_GPIO_CFG__PRE 0x10
11382#define SIO_PDR_GPIO_CFG_MODE__B 0
11383#define SIO_PDR_GPIO_CFG_MODE__W 3
11384#define SIO_PDR_GPIO_CFG_MODE__M 0x7
11385#define SIO_PDR_GPIO_CFG_MODE__PRE 0x0
11386#define SIO_PDR_GPIO_CFG_DRIVE__B 3
11387#define SIO_PDR_GPIO_CFG_DRIVE__W 3
11388#define SIO_PDR_GPIO_CFG_DRIVE__M 0x38
11389#define SIO_PDR_GPIO_CFG_DRIVE__PRE 0x10
11390#define SIO_PDR_GPIO_CFG_KEEP__B 6
11391#define SIO_PDR_GPIO_CFG_KEEP__W 2
11392#define SIO_PDR_GPIO_CFG_KEEP__M 0xC0
11393#define SIO_PDR_GPIO_CFG_KEEP__PRE 0x0
11394#define SIO_PDR_GPIO_CFG_UIO__B 8
11395#define SIO_PDR_GPIO_CFG_UIO__W 1
11396#define SIO_PDR_GPIO_CFG_UIO__M 0x100
11397#define SIO_PDR_GPIO_CFG_UIO__PRE 0x0
11398
11399#define SIO_PDR_IRQN_CFG__A 0x7F0022
11400#define SIO_PDR_IRQN_CFG__W 9
11401#define SIO_PDR_IRQN_CFG__M 0x1FF
11402#define SIO_PDR_IRQN_CFG__PRE 0x10
11403#define SIO_PDR_IRQN_CFG_MODE__B 0
11404#define SIO_PDR_IRQN_CFG_MODE__W 3
11405#define SIO_PDR_IRQN_CFG_MODE__M 0x7
11406#define SIO_PDR_IRQN_CFG_MODE__PRE 0x0
11407#define SIO_PDR_IRQN_CFG_DRIVE__B 3
11408#define SIO_PDR_IRQN_CFG_DRIVE__W 3
11409#define SIO_PDR_IRQN_CFG_DRIVE__M 0x38
11410#define SIO_PDR_IRQN_CFG_DRIVE__PRE 0x10
11411#define SIO_PDR_IRQN_CFG_KEEP__B 6
11412#define SIO_PDR_IRQN_CFG_KEEP__W 2
11413#define SIO_PDR_IRQN_CFG_KEEP__M 0xC0
11414#define SIO_PDR_IRQN_CFG_KEEP__PRE 0x0
11415#define SIO_PDR_IRQN_CFG_UIO__B 8
11416#define SIO_PDR_IRQN_CFG_UIO__W 1
11417#define SIO_PDR_IRQN_CFG_UIO__M 0x100
11418#define SIO_PDR_IRQN_CFG_UIO__PRE 0x0
11419
11420#define SIO_PDR_OOB_CRX_CFG__A 0x7F0023
11421#define SIO_PDR_OOB_CRX_CFG__W 9
11422#define SIO_PDR_OOB_CRX_CFG__M 0x1FF
11423#define SIO_PDR_OOB_CRX_CFG__PRE 0x10
11424#define SIO_PDR_OOB_CRX_CFG_MODE__B 0
11425#define SIO_PDR_OOB_CRX_CFG_MODE__W 3
11426#define SIO_PDR_OOB_CRX_CFG_MODE__M 0x7
11427#define SIO_PDR_OOB_CRX_CFG_MODE__PRE 0x0
11428#define SIO_PDR_OOB_CRX_CFG_DRIVE__B 3
11429#define SIO_PDR_OOB_CRX_CFG_DRIVE__W 3
11430#define SIO_PDR_OOB_CRX_CFG_DRIVE__M 0x38
11431#define SIO_PDR_OOB_CRX_CFG_DRIVE__PRE 0x10
11432#define SIO_PDR_OOB_CRX_CFG_KEEP__B 6
11433#define SIO_PDR_OOB_CRX_CFG_KEEP__W 2
11434#define SIO_PDR_OOB_CRX_CFG_KEEP__M 0xC0
11435#define SIO_PDR_OOB_CRX_CFG_KEEP__PRE 0x0
11436#define SIO_PDR_OOB_CRX_CFG_UIO__B 8
11437#define SIO_PDR_OOB_CRX_CFG_UIO__W 1
11438#define SIO_PDR_OOB_CRX_CFG_UIO__M 0x100
11439#define SIO_PDR_OOB_CRX_CFG_UIO__PRE 0x0
11440
11441#define SIO_PDR_OOB_DRX_CFG__A 0x7F0024
11442#define SIO_PDR_OOB_DRX_CFG__W 9
11443#define SIO_PDR_OOB_DRX_CFG__M 0x1FF
11444#define SIO_PDR_OOB_DRX_CFG__PRE 0x10
11445#define SIO_PDR_OOB_DRX_CFG_MODE__B 0
11446#define SIO_PDR_OOB_DRX_CFG_MODE__W 3
11447#define SIO_PDR_OOB_DRX_CFG_MODE__M 0x7
11448#define SIO_PDR_OOB_DRX_CFG_MODE__PRE 0x0
11449#define SIO_PDR_OOB_DRX_CFG_DRIVE__B 3
11450#define SIO_PDR_OOB_DRX_CFG_DRIVE__W 3
11451#define SIO_PDR_OOB_DRX_CFG_DRIVE__M 0x38
11452#define SIO_PDR_OOB_DRX_CFG_DRIVE__PRE 0x10
11453#define SIO_PDR_OOB_DRX_CFG_KEEP__B 6
11454#define SIO_PDR_OOB_DRX_CFG_KEEP__W 2
11455#define SIO_PDR_OOB_DRX_CFG_KEEP__M 0xC0
11456#define SIO_PDR_OOB_DRX_CFG_KEEP__PRE 0x0
11457#define SIO_PDR_OOB_DRX_CFG_UIO__B 8
11458#define SIO_PDR_OOB_DRX_CFG_UIO__W 1
11459#define SIO_PDR_OOB_DRX_CFG_UIO__M 0x100
11460#define SIO_PDR_OOB_DRX_CFG_UIO__PRE 0x0
11461
11462#define SIO_PDR_MSTRT_CFG__A 0x7F0025
11463#define SIO_PDR_MSTRT_CFG__W 9
11464#define SIO_PDR_MSTRT_CFG__M 0x1FF
11465#define SIO_PDR_MSTRT_CFG__PRE 0x50
11466#define SIO_PDR_MSTRT_CFG_MODE__B 0
11467#define SIO_PDR_MSTRT_CFG_MODE__W 3
11468#define SIO_PDR_MSTRT_CFG_MODE__M 0x7
11469#define SIO_PDR_MSTRT_CFG_MODE__PRE 0x0
11470#define SIO_PDR_MSTRT_CFG_DRIVE__B 3
11471#define SIO_PDR_MSTRT_CFG_DRIVE__W 3
11472#define SIO_PDR_MSTRT_CFG_DRIVE__M 0x38
11473#define SIO_PDR_MSTRT_CFG_DRIVE__PRE 0x10
11474#define SIO_PDR_MSTRT_CFG_KEEP__B 6
11475#define SIO_PDR_MSTRT_CFG_KEEP__W 2
11476#define SIO_PDR_MSTRT_CFG_KEEP__M 0xC0
11477#define SIO_PDR_MSTRT_CFG_KEEP__PRE 0x40
11478#define SIO_PDR_MSTRT_CFG_UIO__B 8
11479#define SIO_PDR_MSTRT_CFG_UIO__W 1
11480#define SIO_PDR_MSTRT_CFG_UIO__M 0x100
11481#define SIO_PDR_MSTRT_CFG_UIO__PRE 0x0
11482
11483#define SIO_PDR_MERR_CFG__A 0x7F0026
11484#define SIO_PDR_MERR_CFG__W 9
11485#define SIO_PDR_MERR_CFG__M 0x1FF
11486#define SIO_PDR_MERR_CFG__PRE 0x50
11487#define SIO_PDR_MERR_CFG_MODE__B 0
11488#define SIO_PDR_MERR_CFG_MODE__W 3
11489#define SIO_PDR_MERR_CFG_MODE__M 0x7
11490#define SIO_PDR_MERR_CFG_MODE__PRE 0x0
11491#define SIO_PDR_MERR_CFG_DRIVE__B 3
11492#define SIO_PDR_MERR_CFG_DRIVE__W 3
11493#define SIO_PDR_MERR_CFG_DRIVE__M 0x38
11494#define SIO_PDR_MERR_CFG_DRIVE__PRE 0x10
11495#define SIO_PDR_MERR_CFG_KEEP__B 6
11496#define SIO_PDR_MERR_CFG_KEEP__W 2
11497#define SIO_PDR_MERR_CFG_KEEP__M 0xC0
11498#define SIO_PDR_MERR_CFG_KEEP__PRE 0x40
11499#define SIO_PDR_MERR_CFG_UIO__B 8
11500#define SIO_PDR_MERR_CFG_UIO__W 1
11501#define SIO_PDR_MERR_CFG_UIO__M 0x100
11502#define SIO_PDR_MERR_CFG_UIO__PRE 0x0
11503
11504#define SIO_PDR_MCLK_CFG__A 0x7F0028
11505#define SIO_PDR_MCLK_CFG__W 9
11506#define SIO_PDR_MCLK_CFG__M 0x1FF
11507#define SIO_PDR_MCLK_CFG__PRE 0x50
11508#define SIO_PDR_MCLK_CFG_MODE__B 0
11509#define SIO_PDR_MCLK_CFG_MODE__W 3
11510#define SIO_PDR_MCLK_CFG_MODE__M 0x7
11511#define SIO_PDR_MCLK_CFG_MODE__PRE 0x0
11512#define SIO_PDR_MCLK_CFG_DRIVE__B 3
11513#define SIO_PDR_MCLK_CFG_DRIVE__W 3
11514#define SIO_PDR_MCLK_CFG_DRIVE__M 0x38
11515#define SIO_PDR_MCLK_CFG_DRIVE__PRE 0x10
11516#define SIO_PDR_MCLK_CFG_KEEP__B 6
11517#define SIO_PDR_MCLK_CFG_KEEP__W 2
11518#define SIO_PDR_MCLK_CFG_KEEP__M 0xC0
11519#define SIO_PDR_MCLK_CFG_KEEP__PRE 0x40
11520#define SIO_PDR_MCLK_CFG_UIO__B 8
11521#define SIO_PDR_MCLK_CFG_UIO__W 1
11522#define SIO_PDR_MCLK_CFG_UIO__M 0x100
11523#define SIO_PDR_MCLK_CFG_UIO__PRE 0x0
11524
11525#define SIO_PDR_MVAL_CFG__A 0x7F0029
11526#define SIO_PDR_MVAL_CFG__W 9
11527#define SIO_PDR_MVAL_CFG__M 0x1FF
11528#define SIO_PDR_MVAL_CFG__PRE 0x50
11529#define SIO_PDR_MVAL_CFG_MODE__B 0
11530#define SIO_PDR_MVAL_CFG_MODE__W 3
11531#define SIO_PDR_MVAL_CFG_MODE__M 0x7
11532#define SIO_PDR_MVAL_CFG_MODE__PRE 0x0
11533#define SIO_PDR_MVAL_CFG_DRIVE__B 3
11534#define SIO_PDR_MVAL_CFG_DRIVE__W 3
11535#define SIO_PDR_MVAL_CFG_DRIVE__M 0x38
11536#define SIO_PDR_MVAL_CFG_DRIVE__PRE 0x10
11537#define SIO_PDR_MVAL_CFG_KEEP__B 6
11538#define SIO_PDR_MVAL_CFG_KEEP__W 2
11539#define SIO_PDR_MVAL_CFG_KEEP__M 0xC0
11540#define SIO_PDR_MVAL_CFG_KEEP__PRE 0x40
11541#define SIO_PDR_MVAL_CFG_UIO__B 8
11542#define SIO_PDR_MVAL_CFG_UIO__W 1
11543#define SIO_PDR_MVAL_CFG_UIO__M 0x100
11544#define SIO_PDR_MVAL_CFG_UIO__PRE 0x0
11545
11546#define SIO_PDR_MD0_CFG__A 0x7F002A
11547#define SIO_PDR_MD0_CFG__W 9
11548#define SIO_PDR_MD0_CFG__M 0x1FF
11549#define SIO_PDR_MD0_CFG__PRE 0x50
11550#define SIO_PDR_MD0_CFG_MODE__B 0
11551#define SIO_PDR_MD0_CFG_MODE__W 3
11552#define SIO_PDR_MD0_CFG_MODE__M 0x7
11553#define SIO_PDR_MD0_CFG_MODE__PRE 0x0
11554#define SIO_PDR_MD0_CFG_DRIVE__B 3
11555#define SIO_PDR_MD0_CFG_DRIVE__W 3
11556#define SIO_PDR_MD0_CFG_DRIVE__M 0x38
11557#define SIO_PDR_MD0_CFG_DRIVE__PRE 0x10
11558#define SIO_PDR_MD0_CFG_KEEP__B 6
11559#define SIO_PDR_MD0_CFG_KEEP__W 2
11560#define SIO_PDR_MD0_CFG_KEEP__M 0xC0
11561#define SIO_PDR_MD0_CFG_KEEP__PRE 0x40
11562#define SIO_PDR_MD0_CFG_UIO__B 8
11563#define SIO_PDR_MD0_CFG_UIO__W 1
11564#define SIO_PDR_MD0_CFG_UIO__M 0x100
11565#define SIO_PDR_MD0_CFG_UIO__PRE 0x0
11566
11567#define SIO_PDR_MD1_CFG__A 0x7F002B
11568#define SIO_PDR_MD1_CFG__W 9
11569#define SIO_PDR_MD1_CFG__M 0x1FF
11570#define SIO_PDR_MD1_CFG__PRE 0x50
11571#define SIO_PDR_MD1_CFG_MODE__B 0
11572#define SIO_PDR_MD1_CFG_MODE__W 3
11573#define SIO_PDR_MD1_CFG_MODE__M 0x7
11574#define SIO_PDR_MD1_CFG_MODE__PRE 0x0
11575#define SIO_PDR_MD1_CFG_DRIVE__B 3
11576#define SIO_PDR_MD1_CFG_DRIVE__W 3
11577#define SIO_PDR_MD1_CFG_DRIVE__M 0x38
11578#define SIO_PDR_MD1_CFG_DRIVE__PRE 0x10
11579#define SIO_PDR_MD1_CFG_KEEP__B 6
11580#define SIO_PDR_MD1_CFG_KEEP__W 2
11581#define SIO_PDR_MD1_CFG_KEEP__M 0xC0
11582#define SIO_PDR_MD1_CFG_KEEP__PRE 0x40
11583#define SIO_PDR_MD1_CFG_UIO__B 8
11584#define SIO_PDR_MD1_CFG_UIO__W 1
11585#define SIO_PDR_MD1_CFG_UIO__M 0x100
11586#define SIO_PDR_MD1_CFG_UIO__PRE 0x0
11587
11588#define SIO_PDR_MD2_CFG__A 0x7F002C
11589#define SIO_PDR_MD2_CFG__W 9
11590#define SIO_PDR_MD2_CFG__M 0x1FF
11591#define SIO_PDR_MD2_CFG__PRE 0x50
11592#define SIO_PDR_MD2_CFG_MODE__B 0
11593#define SIO_PDR_MD2_CFG_MODE__W 3
11594#define SIO_PDR_MD2_CFG_MODE__M 0x7
11595#define SIO_PDR_MD2_CFG_MODE__PRE 0x0
11596#define SIO_PDR_MD2_CFG_DRIVE__B 3
11597#define SIO_PDR_MD2_CFG_DRIVE__W 3
11598#define SIO_PDR_MD2_CFG_DRIVE__M 0x38
11599#define SIO_PDR_MD2_CFG_DRIVE__PRE 0x10
11600#define SIO_PDR_MD2_CFG_KEEP__B 6
11601#define SIO_PDR_MD2_CFG_KEEP__W 2
11602#define SIO_PDR_MD2_CFG_KEEP__M 0xC0
11603#define SIO_PDR_MD2_CFG_KEEP__PRE 0x40
11604#define SIO_PDR_MD2_CFG_UIO__B 8
11605#define SIO_PDR_MD2_CFG_UIO__W 1
11606#define SIO_PDR_MD2_CFG_UIO__M 0x100
11607#define SIO_PDR_MD2_CFG_UIO__PRE 0x0
11608
11609#define SIO_PDR_MD3_CFG__A 0x7F002D
11610#define SIO_PDR_MD3_CFG__W 9
11611#define SIO_PDR_MD3_CFG__M 0x1FF
11612#define SIO_PDR_MD3_CFG__PRE 0x50
11613#define SIO_PDR_MD3_CFG_MODE__B 0
11614#define SIO_PDR_MD3_CFG_MODE__W 3
11615#define SIO_PDR_MD3_CFG_MODE__M 0x7
11616#define SIO_PDR_MD3_CFG_MODE__PRE 0x0
11617#define SIO_PDR_MD3_CFG_DRIVE__B 3
11618#define SIO_PDR_MD3_CFG_DRIVE__W 3
11619#define SIO_PDR_MD3_CFG_DRIVE__M 0x38
11620#define SIO_PDR_MD3_CFG_DRIVE__PRE 0x10
11621#define SIO_PDR_MD3_CFG_KEEP__B 6
11622#define SIO_PDR_MD3_CFG_KEEP__W 2
11623#define SIO_PDR_MD3_CFG_KEEP__M 0xC0
11624#define SIO_PDR_MD3_CFG_KEEP__PRE 0x40
11625#define SIO_PDR_MD3_CFG_UIO__B 8
11626#define SIO_PDR_MD3_CFG_UIO__W 1
11627#define SIO_PDR_MD3_CFG_UIO__M 0x100
11628#define SIO_PDR_MD3_CFG_UIO__PRE 0x0
11629
11630#define SIO_PDR_MD4_CFG__A 0x7F002F
11631#define SIO_PDR_MD4_CFG__W 9
11632#define SIO_PDR_MD4_CFG__M 0x1FF
11633#define SIO_PDR_MD4_CFG__PRE 0x50
11634#define SIO_PDR_MD4_CFG_MODE__B 0
11635#define SIO_PDR_MD4_CFG_MODE__W 3
11636#define SIO_PDR_MD4_CFG_MODE__M 0x7
11637#define SIO_PDR_MD4_CFG_MODE__PRE 0x0
11638#define SIO_PDR_MD4_CFG_DRIVE__B 3
11639#define SIO_PDR_MD4_CFG_DRIVE__W 3
11640#define SIO_PDR_MD4_CFG_DRIVE__M 0x38
11641#define SIO_PDR_MD4_CFG_DRIVE__PRE 0x10
11642#define SIO_PDR_MD4_CFG_KEEP__B 6
11643#define SIO_PDR_MD4_CFG_KEEP__W 2
11644#define SIO_PDR_MD4_CFG_KEEP__M 0xC0
11645#define SIO_PDR_MD4_CFG_KEEP__PRE 0x40
11646#define SIO_PDR_MD4_CFG_UIO__B 8
11647#define SIO_PDR_MD4_CFG_UIO__W 1
11648#define SIO_PDR_MD4_CFG_UIO__M 0x100
11649#define SIO_PDR_MD4_CFG_UIO__PRE 0x0
11650
11651#define SIO_PDR_MD5_CFG__A 0x7F0030
11652#define SIO_PDR_MD5_CFG__W 9
11653#define SIO_PDR_MD5_CFG__M 0x1FF
11654#define SIO_PDR_MD5_CFG__PRE 0x50
11655#define SIO_PDR_MD5_CFG_MODE__B 0
11656#define SIO_PDR_MD5_CFG_MODE__W 3
11657#define SIO_PDR_MD5_CFG_MODE__M 0x7
11658#define SIO_PDR_MD5_CFG_MODE__PRE 0x0
11659#define SIO_PDR_MD5_CFG_DRIVE__B 3
11660#define SIO_PDR_MD5_CFG_DRIVE__W 3
11661#define SIO_PDR_MD5_CFG_DRIVE__M 0x38
11662#define SIO_PDR_MD5_CFG_DRIVE__PRE 0x10
11663#define SIO_PDR_MD5_CFG_KEEP__B 6
11664#define SIO_PDR_MD5_CFG_KEEP__W 2
11665#define SIO_PDR_MD5_CFG_KEEP__M 0xC0
11666#define SIO_PDR_MD5_CFG_KEEP__PRE 0x40
11667#define SIO_PDR_MD5_CFG_UIO__B 8
11668#define SIO_PDR_MD5_CFG_UIO__W 1
11669#define SIO_PDR_MD5_CFG_UIO__M 0x100
11670#define SIO_PDR_MD5_CFG_UIO__PRE 0x0
11671
11672#define SIO_PDR_MD6_CFG__A 0x7F0031
11673#define SIO_PDR_MD6_CFG__W 9
11674#define SIO_PDR_MD6_CFG__M 0x1FF
11675#define SIO_PDR_MD6_CFG__PRE 0x50
11676#define SIO_PDR_MD6_CFG_MODE__B 0
11677#define SIO_PDR_MD6_CFG_MODE__W 3
11678#define SIO_PDR_MD6_CFG_MODE__M 0x7
11679#define SIO_PDR_MD6_CFG_MODE__PRE 0x0
11680#define SIO_PDR_MD6_CFG_DRIVE__B 3
11681#define SIO_PDR_MD6_CFG_DRIVE__W 3
11682#define SIO_PDR_MD6_CFG_DRIVE__M 0x38
11683#define SIO_PDR_MD6_CFG_DRIVE__PRE 0x10
11684#define SIO_PDR_MD6_CFG_KEEP__B 6
11685#define SIO_PDR_MD6_CFG_KEEP__W 2
11686#define SIO_PDR_MD6_CFG_KEEP__M 0xC0
11687#define SIO_PDR_MD6_CFG_KEEP__PRE 0x40
11688#define SIO_PDR_MD6_CFG_UIO__B 8
11689#define SIO_PDR_MD6_CFG_UIO__W 1
11690#define SIO_PDR_MD6_CFG_UIO__M 0x100
11691#define SIO_PDR_MD6_CFG_UIO__PRE 0x0
11692
11693#define SIO_PDR_MD7_CFG__A 0x7F0032
11694#define SIO_PDR_MD7_CFG__W 9
11695#define SIO_PDR_MD7_CFG__M 0x1FF
11696#define SIO_PDR_MD7_CFG__PRE 0x50
11697#define SIO_PDR_MD7_CFG_MODE__B 0
11698#define SIO_PDR_MD7_CFG_MODE__W 3
11699#define SIO_PDR_MD7_CFG_MODE__M 0x7
11700#define SIO_PDR_MD7_CFG_MODE__PRE 0x0
11701#define SIO_PDR_MD7_CFG_DRIVE__B 3
11702#define SIO_PDR_MD7_CFG_DRIVE__W 3
11703#define SIO_PDR_MD7_CFG_DRIVE__M 0x38
11704#define SIO_PDR_MD7_CFG_DRIVE__PRE 0x10
11705#define SIO_PDR_MD7_CFG_KEEP__B 6
11706#define SIO_PDR_MD7_CFG_KEEP__W 2
11707#define SIO_PDR_MD7_CFG_KEEP__M 0xC0
11708#define SIO_PDR_MD7_CFG_KEEP__PRE 0x40
11709#define SIO_PDR_MD7_CFG_UIO__B 8
11710#define SIO_PDR_MD7_CFG_UIO__W 1
11711#define SIO_PDR_MD7_CFG_UIO__M 0x100
11712#define SIO_PDR_MD7_CFG_UIO__PRE 0x0
11713
11714#define SIO_PDR_I2C_SCL1_CFG__A 0x7F0033
11715#define SIO_PDR_I2C_SCL1_CFG__W 9
11716#define SIO_PDR_I2C_SCL1_CFG__M 0x1FF
11717#define SIO_PDR_I2C_SCL1_CFG__PRE 0x11
11718#define SIO_PDR_I2C_SCL1_CFG_MODE__B 0
11719#define SIO_PDR_I2C_SCL1_CFG_MODE__W 3
11720#define SIO_PDR_I2C_SCL1_CFG_MODE__M 0x7
11721#define SIO_PDR_I2C_SCL1_CFG_MODE__PRE 0x1
11722#define SIO_PDR_I2C_SCL1_CFG_DRIVE__B 3
11723#define SIO_PDR_I2C_SCL1_CFG_DRIVE__W 3
11724#define SIO_PDR_I2C_SCL1_CFG_DRIVE__M 0x38
11725#define SIO_PDR_I2C_SCL1_CFG_DRIVE__PRE 0x10
11726#define SIO_PDR_I2C_SCL1_CFG_KEEP__B 6
11727#define SIO_PDR_I2C_SCL1_CFG_KEEP__W 2
11728#define SIO_PDR_I2C_SCL1_CFG_KEEP__M 0xC0
11729#define SIO_PDR_I2C_SCL1_CFG_KEEP__PRE 0x0
11730#define SIO_PDR_I2C_SCL1_CFG_UIO__B 8
11731#define SIO_PDR_I2C_SCL1_CFG_UIO__W 1
11732#define SIO_PDR_I2C_SCL1_CFG_UIO__M 0x100
11733#define SIO_PDR_I2C_SCL1_CFG_UIO__PRE 0x0
11734
11735#define SIO_PDR_I2C_SDA1_CFG__A 0x7F0034
11736#define SIO_PDR_I2C_SDA1_CFG__W 9
11737#define SIO_PDR_I2C_SDA1_CFG__M 0x1FF
11738#define SIO_PDR_I2C_SDA1_CFG__PRE 0x11
11739#define SIO_PDR_I2C_SDA1_CFG_MODE__B 0
11740#define SIO_PDR_I2C_SDA1_CFG_MODE__W 3
11741#define SIO_PDR_I2C_SDA1_CFG_MODE__M 0x7
11742#define SIO_PDR_I2C_SDA1_CFG_MODE__PRE 0x1
11743#define SIO_PDR_I2C_SDA1_CFG_DRIVE__B 3
11744#define SIO_PDR_I2C_SDA1_CFG_DRIVE__W 3
11745#define SIO_PDR_I2C_SDA1_CFG_DRIVE__M 0x38
11746#define SIO_PDR_I2C_SDA1_CFG_DRIVE__PRE 0x10
11747#define SIO_PDR_I2C_SDA1_CFG_KEEP__B 6
11748#define SIO_PDR_I2C_SDA1_CFG_KEEP__W 2
11749#define SIO_PDR_I2C_SDA1_CFG_KEEP__M 0xC0
11750#define SIO_PDR_I2C_SDA1_CFG_KEEP__PRE 0x0
11751#define SIO_PDR_I2C_SDA1_CFG_UIO__B 8
11752#define SIO_PDR_I2C_SDA1_CFG_UIO__W 1
11753#define SIO_PDR_I2C_SDA1_CFG_UIO__M 0x100
11754#define SIO_PDR_I2C_SDA1_CFG_UIO__PRE 0x0
11755
11756#define SIO_PDR_VSYNC_CFG__A 0x7F0036
11757#define SIO_PDR_VSYNC_CFG__W 9
11758#define SIO_PDR_VSYNC_CFG__M 0x1FF
11759#define SIO_PDR_VSYNC_CFG__PRE 0x10
11760#define SIO_PDR_VSYNC_CFG_MODE__B 0
11761#define SIO_PDR_VSYNC_CFG_MODE__W 3
11762#define SIO_PDR_VSYNC_CFG_MODE__M 0x7
11763#define SIO_PDR_VSYNC_CFG_MODE__PRE 0x0
11764#define SIO_PDR_VSYNC_CFG_DRIVE__B 3
11765#define SIO_PDR_VSYNC_CFG_DRIVE__W 3
11766#define SIO_PDR_VSYNC_CFG_DRIVE__M 0x38
11767#define SIO_PDR_VSYNC_CFG_DRIVE__PRE 0x10
11768#define SIO_PDR_VSYNC_CFG_KEEP__B 6
11769#define SIO_PDR_VSYNC_CFG_KEEP__W 2
11770#define SIO_PDR_VSYNC_CFG_KEEP__M 0xC0
11771#define SIO_PDR_VSYNC_CFG_KEEP__PRE 0x0
11772#define SIO_PDR_VSYNC_CFG_UIO__B 8
11773#define SIO_PDR_VSYNC_CFG_UIO__W 1
11774#define SIO_PDR_VSYNC_CFG_UIO__M 0x100
11775#define SIO_PDR_VSYNC_CFG_UIO__PRE 0x0
11776
11777#define SIO_PDR_SMA_RX_CFG__A 0x7F0037
11778#define SIO_PDR_SMA_RX_CFG__W 9
11779#define SIO_PDR_SMA_RX_CFG__M 0x1FF
11780#define SIO_PDR_SMA_RX_CFG__PRE 0x10
11781#define SIO_PDR_SMA_RX_CFG_MODE__B 0
11782#define SIO_PDR_SMA_RX_CFG_MODE__W 3
11783#define SIO_PDR_SMA_RX_CFG_MODE__M 0x7
11784#define SIO_PDR_SMA_RX_CFG_MODE__PRE 0x0
11785#define SIO_PDR_SMA_RX_CFG_DRIVE__B 3
11786#define SIO_PDR_SMA_RX_CFG_DRIVE__W 3
11787#define SIO_PDR_SMA_RX_CFG_DRIVE__M 0x38
11788#define SIO_PDR_SMA_RX_CFG_DRIVE__PRE 0x10
11789#define SIO_PDR_SMA_RX_CFG_KEEP__B 6
11790#define SIO_PDR_SMA_RX_CFG_KEEP__W 2
11791#define SIO_PDR_SMA_RX_CFG_KEEP__M 0xC0
11792#define SIO_PDR_SMA_RX_CFG_KEEP__PRE 0x0
11793#define SIO_PDR_SMA_RX_CFG_UIO__B 8
11794#define SIO_PDR_SMA_RX_CFG_UIO__W 1
11795#define SIO_PDR_SMA_RX_CFG_UIO__M 0x100
11796#define SIO_PDR_SMA_RX_CFG_UIO__PRE 0x0
11797
11798#define SIO_PDR_SMA_TX_CFG__A 0x7F0038
11799#define SIO_PDR_SMA_TX_CFG__W 9
11800#define SIO_PDR_SMA_TX_CFG__M 0x1FF
11801#define SIO_PDR_SMA_TX_CFG__PRE 0x90
11802#define SIO_PDR_SMA_TX_CFG_MODE__B 0
11803#define SIO_PDR_SMA_TX_CFG_MODE__W 3
11804#define SIO_PDR_SMA_TX_CFG_MODE__M 0x7
11805#define SIO_PDR_SMA_TX_CFG_MODE__PRE 0x0
11806#define SIO_PDR_SMA_TX_CFG_DRIVE__B 3
11807#define SIO_PDR_SMA_TX_CFG_DRIVE__W 3
11808#define SIO_PDR_SMA_TX_CFG_DRIVE__M 0x38
11809#define SIO_PDR_SMA_TX_CFG_DRIVE__PRE 0x10
11810#define SIO_PDR_SMA_TX_CFG_KEEP__B 6
11811#define SIO_PDR_SMA_TX_CFG_KEEP__W 2
11812#define SIO_PDR_SMA_TX_CFG_KEEP__M 0xC0
11813#define SIO_PDR_SMA_TX_CFG_KEEP__PRE 0x80
11814#define SIO_PDR_SMA_TX_CFG_UIO__B 8
11815#define SIO_PDR_SMA_TX_CFG_UIO__W 1
11816#define SIO_PDR_SMA_TX_CFG_UIO__M 0x100
11817#define SIO_PDR_SMA_TX_CFG_UIO__PRE 0x0
11818
11819#define SIO_PDR_I2C_SDA2_CFG__A 0x7F003F
11820#define SIO_PDR_I2C_SDA2_CFG__W 9
11821#define SIO_PDR_I2C_SDA2_CFG__M 0x1FF
11822#define SIO_PDR_I2C_SDA2_CFG__PRE 0x11
11823#define SIO_PDR_I2C_SDA2_CFG_MODE__B 0
11824#define SIO_PDR_I2C_SDA2_CFG_MODE__W 3
11825#define SIO_PDR_I2C_SDA2_CFG_MODE__M 0x7
11826#define SIO_PDR_I2C_SDA2_CFG_MODE__PRE 0x1
11827#define SIO_PDR_I2C_SDA2_CFG_DRIVE__B 3
11828#define SIO_PDR_I2C_SDA2_CFG_DRIVE__W 3
11829#define SIO_PDR_I2C_SDA2_CFG_DRIVE__M 0x38
11830#define SIO_PDR_I2C_SDA2_CFG_DRIVE__PRE 0x10
11831#define SIO_PDR_I2C_SDA2_CFG_KEEP__B 6
11832#define SIO_PDR_I2C_SDA2_CFG_KEEP__W 2
11833#define SIO_PDR_I2C_SDA2_CFG_KEEP__M 0xC0
11834#define SIO_PDR_I2C_SDA2_CFG_KEEP__PRE 0x0
11835#define SIO_PDR_I2C_SDA2_CFG_UIO__B 8
11836#define SIO_PDR_I2C_SDA2_CFG_UIO__W 1
11837#define SIO_PDR_I2C_SDA2_CFG_UIO__M 0x100
11838#define SIO_PDR_I2C_SDA2_CFG_UIO__PRE 0x0
11839
11840#define SIO_PDR_I2C_SCL2_CFG__A 0x7F0040
11841#define SIO_PDR_I2C_SCL2_CFG__W 9
11842#define SIO_PDR_I2C_SCL2_CFG__M 0x1FF
11843#define SIO_PDR_I2C_SCL2_CFG__PRE 0x11
11844#define SIO_PDR_I2C_SCL2_CFG_MODE__B 0
11845#define SIO_PDR_I2C_SCL2_CFG_MODE__W 3
11846#define SIO_PDR_I2C_SCL2_CFG_MODE__M 0x7
11847#define SIO_PDR_I2C_SCL2_CFG_MODE__PRE 0x1
11848#define SIO_PDR_I2C_SCL2_CFG_DRIVE__B 3
11849#define SIO_PDR_I2C_SCL2_CFG_DRIVE__W 3
11850#define SIO_PDR_I2C_SCL2_CFG_DRIVE__M 0x38
11851#define SIO_PDR_I2C_SCL2_CFG_DRIVE__PRE 0x10
11852#define SIO_PDR_I2C_SCL2_CFG_KEEP__B 6
11853#define SIO_PDR_I2C_SCL2_CFG_KEEP__W 2
11854#define SIO_PDR_I2C_SCL2_CFG_KEEP__M 0xC0
11855#define SIO_PDR_I2C_SCL2_CFG_KEEP__PRE 0x0
11856#define SIO_PDR_I2C_SCL2_CFG_UIO__B 8
11857#define SIO_PDR_I2C_SCL2_CFG_UIO__W 1
11858#define SIO_PDR_I2C_SCL2_CFG_UIO__M 0x100
11859#define SIO_PDR_I2C_SCL2_CFG_UIO__PRE 0x0
11860
11861#define SIO_PDR_I2S_CL_CFG__A 0x7F0041
11862#define SIO_PDR_I2S_CL_CFG__W 9
11863#define SIO_PDR_I2S_CL_CFG__M 0x1FF
11864#define SIO_PDR_I2S_CL_CFG__PRE 0x10
11865#define SIO_PDR_I2S_CL_CFG_MODE__B 0
11866#define SIO_PDR_I2S_CL_CFG_MODE__W 3
11867#define SIO_PDR_I2S_CL_CFG_MODE__M 0x7
11868#define SIO_PDR_I2S_CL_CFG_MODE__PRE 0x0
11869#define SIO_PDR_I2S_CL_CFG_DRIVE__B 3
11870#define SIO_PDR_I2S_CL_CFG_DRIVE__W 3
11871#define SIO_PDR_I2S_CL_CFG_DRIVE__M 0x38
11872#define SIO_PDR_I2S_CL_CFG_DRIVE__PRE 0x10
11873#define SIO_PDR_I2S_CL_CFG_KEEP__B 6
11874#define SIO_PDR_I2S_CL_CFG_KEEP__W 2
11875#define SIO_PDR_I2S_CL_CFG_KEEP__M 0xC0
11876#define SIO_PDR_I2S_CL_CFG_KEEP__PRE 0x0
11877#define SIO_PDR_I2S_CL_CFG_UIO__B 8
11878#define SIO_PDR_I2S_CL_CFG_UIO__W 1
11879#define SIO_PDR_I2S_CL_CFG_UIO__M 0x100
11880#define SIO_PDR_I2S_CL_CFG_UIO__PRE 0x0
11881
11882#define SIO_PDR_I2S_DA_CFG__A 0x7F0042
11883#define SIO_PDR_I2S_DA_CFG__W 9
11884#define SIO_PDR_I2S_DA_CFG__M 0x1FF
11885#define SIO_PDR_I2S_DA_CFG__PRE 0x10
11886#define SIO_PDR_I2S_DA_CFG_MODE__B 0
11887#define SIO_PDR_I2S_DA_CFG_MODE__W 3
11888#define SIO_PDR_I2S_DA_CFG_MODE__M 0x7
11889#define SIO_PDR_I2S_DA_CFG_MODE__PRE 0x0
11890#define SIO_PDR_I2S_DA_CFG_DRIVE__B 3
11891#define SIO_PDR_I2S_DA_CFG_DRIVE__W 3
11892#define SIO_PDR_I2S_DA_CFG_DRIVE__M 0x38
11893#define SIO_PDR_I2S_DA_CFG_DRIVE__PRE 0x10
11894#define SIO_PDR_I2S_DA_CFG_KEEP__B 6
11895#define SIO_PDR_I2S_DA_CFG_KEEP__W 2
11896#define SIO_PDR_I2S_DA_CFG_KEEP__M 0xC0
11897#define SIO_PDR_I2S_DA_CFG_KEEP__PRE 0x0
11898#define SIO_PDR_I2S_DA_CFG_UIO__B 8
11899#define SIO_PDR_I2S_DA_CFG_UIO__W 1
11900#define SIO_PDR_I2S_DA_CFG_UIO__M 0x100
11901#define SIO_PDR_I2S_DA_CFG_UIO__PRE 0x0
11902
11903#define SIO_PDR_GPIO_GPIO_FNC__A 0x7F0050
11904#define SIO_PDR_GPIO_GPIO_FNC__W 2
11905#define SIO_PDR_GPIO_GPIO_FNC__M 0x3
11906#define SIO_PDR_GPIO_GPIO_FNC__PRE 0x0
11907#define SIO_PDR_GPIO_GPIO_FNC_SEL__B 0
11908#define SIO_PDR_GPIO_GPIO_FNC_SEL__W 2
11909#define SIO_PDR_GPIO_GPIO_FNC_SEL__M 0x3
11910#define SIO_PDR_GPIO_GPIO_FNC_SEL__PRE 0x0
11911
11912#define SIO_PDR_IRQN_GPIO_FNC__A 0x7F0051
11913#define SIO_PDR_IRQN_GPIO_FNC__W 2
11914#define SIO_PDR_IRQN_GPIO_FNC__M 0x3
11915#define SIO_PDR_IRQN_GPIO_FNC__PRE 0x0
11916#define SIO_PDR_IRQN_GPIO_FNC_SEL__B 0
11917#define SIO_PDR_IRQN_GPIO_FNC_SEL__W 2
11918#define SIO_PDR_IRQN_GPIO_FNC_SEL__M 0x3
11919#define SIO_PDR_IRQN_GPIO_FNC_SEL__PRE 0x0
11920
11921#define SIO_PDR_MSTRT_GPIO_FNC__A 0x7F0052
11922#define SIO_PDR_MSTRT_GPIO_FNC__W 2
11923#define SIO_PDR_MSTRT_GPIO_FNC__M 0x3
11924#define SIO_PDR_MSTRT_GPIO_FNC__PRE 0x0
11925#define SIO_PDR_MSTRT_GPIO_FNC_SEL__B 0
11926#define SIO_PDR_MSTRT_GPIO_FNC_SEL__W 2
11927#define SIO_PDR_MSTRT_GPIO_FNC_SEL__M 0x3
11928#define SIO_PDR_MSTRT_GPIO_FNC_SEL__PRE 0x0
11929
11930#define SIO_PDR_MERR_GPIO_FNC__A 0x7F0053
11931#define SIO_PDR_MERR_GPIO_FNC__W 2
11932#define SIO_PDR_MERR_GPIO_FNC__M 0x3
11933#define SIO_PDR_MERR_GPIO_FNC__PRE 0x0
11934#define SIO_PDR_MERR_GPIO_FNC_SEL__B 0
11935#define SIO_PDR_MERR_GPIO_FNC_SEL__W 2
11936#define SIO_PDR_MERR_GPIO_FNC_SEL__M 0x3
11937#define SIO_PDR_MERR_GPIO_FNC_SEL__PRE 0x0
11938
11939#define SIO_PDR_MCLK_GPIO_FNC__A 0x7F0054
11940#define SIO_PDR_MCLK_GPIO_FNC__W 2
11941#define SIO_PDR_MCLK_GPIO_FNC__M 0x3
11942#define SIO_PDR_MCLK_GPIO_FNC__PRE 0x0
11943#define SIO_PDR_MCLK_GPIO_FNC_SEL__B 0
11944#define SIO_PDR_MCLK_GPIO_FNC_SEL__W 2
11945#define SIO_PDR_MCLK_GPIO_FNC_SEL__M 0x3
11946#define SIO_PDR_MCLK_GPIO_FNC_SEL__PRE 0x0
11947
11948#define SIO_PDR_MVAL_GPIO_FNC__A 0x7F0055
11949#define SIO_PDR_MVAL_GPIO_FNC__W 2
11950#define SIO_PDR_MVAL_GPIO_FNC__M 0x3
11951#define SIO_PDR_MVAL_GPIO_FNC__PRE 0x0
11952#define SIO_PDR_MVAL_GPIO_FNC_SEL__B 0
11953#define SIO_PDR_MVAL_GPIO_FNC_SEL__W 2
11954#define SIO_PDR_MVAL_GPIO_FNC_SEL__M 0x3
11955#define SIO_PDR_MVAL_GPIO_FNC_SEL__PRE 0x0
11956
11957#define SIO_PDR_MD0_GPIO_FNC__A 0x7F0056
11958#define SIO_PDR_MD0_GPIO_FNC__W 2
11959#define SIO_PDR_MD0_GPIO_FNC__M 0x3
11960#define SIO_PDR_MD0_GPIO_FNC__PRE 0x0
11961#define SIO_PDR_MD0_GPIO_FNC_SEL__B 0
11962#define SIO_PDR_MD0_GPIO_FNC_SEL__W 2
11963#define SIO_PDR_MD0_GPIO_FNC_SEL__M 0x3
11964#define SIO_PDR_MD0_GPIO_FNC_SEL__PRE 0x0
11965
11966#define SIO_PDR_MD1_GPIO_FNC__A 0x7F0057
11967#define SIO_PDR_MD1_GPIO_FNC__W 2
11968#define SIO_PDR_MD1_GPIO_FNC__M 0x3
11969#define SIO_PDR_MD1_GPIO_FNC__PRE 0x0
11970#define SIO_PDR_MD1_GPIO_FNC_SEL__B 0
11971#define SIO_PDR_MD1_GPIO_FNC_SEL__W 2
11972#define SIO_PDR_MD1_GPIO_FNC_SEL__M 0x3
11973#define SIO_PDR_MD1_GPIO_FNC_SEL__PRE 0x0
11974
11975#define SIO_PDR_MD2_GPIO_FNC__A 0x7F0058
11976#define SIO_PDR_MD2_GPIO_FNC__W 2
11977#define SIO_PDR_MD2_GPIO_FNC__M 0x3
11978#define SIO_PDR_MD2_GPIO_FNC__PRE 0x0
11979#define SIO_PDR_MD2_GPIO_FNC_SEL__B 0
11980#define SIO_PDR_MD2_GPIO_FNC_SEL__W 2
11981#define SIO_PDR_MD2_GPIO_FNC_SEL__M 0x3
11982#define SIO_PDR_MD2_GPIO_FNC_SEL__PRE 0x0
11983
11984#define SIO_PDR_MD3_GPIO_FNC__A 0x7F0059
11985#define SIO_PDR_MD3_GPIO_FNC__W 2
11986#define SIO_PDR_MD3_GPIO_FNC__M 0x3
11987#define SIO_PDR_MD3_GPIO_FNC__PRE 0x0
11988#define SIO_PDR_MD3_GPIO_FNC_SEL__B 0
11989#define SIO_PDR_MD3_GPIO_FNC_SEL__W 2
11990#define SIO_PDR_MD3_GPIO_FNC_SEL__M 0x3
11991#define SIO_PDR_MD3_GPIO_FNC_SEL__PRE 0x0
11992
11993#define SIO_PDR_MD4_GPIO_FNC__A 0x7F005A
11994#define SIO_PDR_MD4_GPIO_FNC__W 2
11995#define SIO_PDR_MD4_GPIO_FNC__M 0x3
11996#define SIO_PDR_MD4_GPIO_FNC__PRE 0x0
11997#define SIO_PDR_MD4_GPIO_FNC_SEL__B 0
11998#define SIO_PDR_MD4_GPIO_FNC_SEL__W 2
11999#define SIO_PDR_MD4_GPIO_FNC_SEL__M 0x3
12000#define SIO_PDR_MD4_GPIO_FNC_SEL__PRE 0x0
12001
12002#define SIO_PDR_MD5_GPIO_FNC__A 0x7F005B
12003#define SIO_PDR_MD5_GPIO_FNC__W 2
12004#define SIO_PDR_MD5_GPIO_FNC__M 0x3
12005#define SIO_PDR_MD5_GPIO_FNC__PRE 0x0
12006#define SIO_PDR_MD5_GPIO_FNC_SEL__B 0
12007#define SIO_PDR_MD5_GPIO_FNC_SEL__W 2
12008#define SIO_PDR_MD5_GPIO_FNC_SEL__M 0x3
12009#define SIO_PDR_MD5_GPIO_FNC_SEL__PRE 0x0
12010
12011#define SIO_PDR_MD6_GPIO_FNC__A 0x7F005C
12012#define SIO_PDR_MD6_GPIO_FNC__W 2
12013#define SIO_PDR_MD6_GPIO_FNC__M 0x3
12014#define SIO_PDR_MD6_GPIO_FNC__PRE 0x0
12015#define SIO_PDR_MD6_GPIO_FNC_SEL__B 0
12016#define SIO_PDR_MD6_GPIO_FNC_SEL__W 2
12017#define SIO_PDR_MD6_GPIO_FNC_SEL__M 0x3
12018#define SIO_PDR_MD6_GPIO_FNC_SEL__PRE 0x0
12019
12020#define SIO_PDR_MD7_GPIO_FNC__A 0x7F005D
12021#define SIO_PDR_MD7_GPIO_FNC__W 2
12022#define SIO_PDR_MD7_GPIO_FNC__M 0x3
12023#define SIO_PDR_MD7_GPIO_FNC__PRE 0x0
12024#define SIO_PDR_MD7_GPIO_FNC_SEL__B 0
12025#define SIO_PDR_MD7_GPIO_FNC_SEL__W 2
12026#define SIO_PDR_MD7_GPIO_FNC_SEL__M 0x3
12027#define SIO_PDR_MD7_GPIO_FNC_SEL__PRE 0x0
12028
12029#define SIO_PDR_SMA_RX_GPIO_FNC__A 0x7F005E
12030#define SIO_PDR_SMA_RX_GPIO_FNC__W 2
12031#define SIO_PDR_SMA_RX_GPIO_FNC__M 0x3
12032#define SIO_PDR_SMA_RX_GPIO_FNC__PRE 0x0
12033#define SIO_PDR_SMA_RX_GPIO_FNC_SEL__B 0
12034#define SIO_PDR_SMA_RX_GPIO_FNC_SEL__W 2
12035#define SIO_PDR_SMA_RX_GPIO_FNC_SEL__M 0x3
12036#define SIO_PDR_SMA_RX_GPIO_FNC_SEL__PRE 0x0
12037
12038#define SIO_PDR_SMA_TX_GPIO_FNC__A 0x7F005F
12039#define SIO_PDR_SMA_TX_GPIO_FNC__W 2
12040#define SIO_PDR_SMA_TX_GPIO_FNC__M 0x3
12041#define SIO_PDR_SMA_TX_GPIO_FNC__PRE 0x0
12042#define SIO_PDR_SMA_TX_GPIO_FNC_SEL__B 0
12043#define SIO_PDR_SMA_TX_GPIO_FNC_SEL__W 2
12044#define SIO_PDR_SMA_TX_GPIO_FNC_SEL__M 0x3
12045#define SIO_PDR_SMA_TX_GPIO_FNC_SEL__PRE 0x0
12046
12047#define VSB_COMM_EXEC__A 0x1C00000
12048#define VSB_COMM_EXEC__W 2
12049#define VSB_COMM_EXEC__M 0x3
12050#define VSB_COMM_EXEC__PRE 0x0
12051#define VSB_COMM_EXEC_STOP 0x0
12052#define VSB_COMM_EXEC_ACTIVE 0x1
12053#define VSB_COMM_EXEC_HOLD 0x2
12054
12055#define VSB_COMM_MB__A 0x1C00002
12056#define VSB_COMM_MB__W 16
12057#define VSB_COMM_MB__M 0xFFFF
12058#define VSB_COMM_MB__PRE 0x0
12059#define VSB_COMM_INT_REQ__A 0x1C00003
12060#define VSB_COMM_INT_REQ__W 1
12061#define VSB_COMM_INT_REQ__M 0x1
12062#define VSB_COMM_INT_REQ__PRE 0x0
12063
12064#define VSB_COMM_INT_REQ_TOP_INT_REQ__B 0
12065#define VSB_COMM_INT_REQ_TOP_INT_REQ__W 1
12066#define VSB_COMM_INT_REQ_TOP_INT_REQ__M 0x1
12067#define VSB_COMM_INT_REQ_TOP_INT_REQ__PRE 0x0
12068
12069#define VSB_COMM_INT_STA__A 0x1C00005
12070#define VSB_COMM_INT_STA__W 16
12071#define VSB_COMM_INT_STA__M 0xFFFF
12072#define VSB_COMM_INT_STA__PRE 0x0
12073
12074#define VSB_COMM_INT_MSK__A 0x1C00006
12075#define VSB_COMM_INT_MSK__W 16
12076#define VSB_COMM_INT_MSK__M 0xFFFF
12077#define VSB_COMM_INT_MSK__PRE 0x0
12078
12079#define VSB_COMM_INT_STM__A 0x1C00007
12080#define VSB_COMM_INT_STM__W 16
12081#define VSB_COMM_INT_STM__M 0xFFFF
12082#define VSB_COMM_INT_STM__PRE 0x0
12083
12084#define VSB_TOP_COMM_EXEC__A 0x1C10000
12085#define VSB_TOP_COMM_EXEC__W 2
12086#define VSB_TOP_COMM_EXEC__M 0x3
12087#define VSB_TOP_COMM_EXEC__PRE 0x0
12088#define VSB_TOP_COMM_EXEC_STOP 0x0
12089#define VSB_TOP_COMM_EXEC_ACTIVE 0x1
12090#define VSB_TOP_COMM_EXEC_HOLD 0x2
12091
12092#define VSB_TOP_COMM_MB__A 0x1C10002
12093#define VSB_TOP_COMM_MB__W 10
12094#define VSB_TOP_COMM_MB__M 0x3FF
12095#define VSB_TOP_COMM_MB__PRE 0x0
12096
12097#define VSB_TOP_COMM_MB_CTL__B 0
12098#define VSB_TOP_COMM_MB_CTL__W 1
12099#define VSB_TOP_COMM_MB_CTL__M 0x1
12100#define VSB_TOP_COMM_MB_CTL__PRE 0x0
12101#define VSB_TOP_COMM_MB_CTL_CTL_OFF 0x0
12102#define VSB_TOP_COMM_MB_CTL_CTL_ON 0x1
12103
12104#define VSB_TOP_COMM_MB_OBS__B 1
12105#define VSB_TOP_COMM_MB_OBS__W 1
12106#define VSB_TOP_COMM_MB_OBS__M 0x2
12107#define VSB_TOP_COMM_MB_OBS__PRE 0x0
12108#define VSB_TOP_COMM_MB_OBS_OBS_OFF 0x0
12109#define VSB_TOP_COMM_MB_OBS_OBS_ON 0x2
12110
12111#define VSB_TOP_COMM_MB_MUX_CTL__B 2
12112#define VSB_TOP_COMM_MB_MUX_CTL__W 4
12113#define VSB_TOP_COMM_MB_MUX_CTL__M 0x3C
12114#define VSB_TOP_COMM_MB_MUX_CTL__PRE 0x0
12115
12116#define VSB_TOP_COMM_MB_MUX_OBS__B 6
12117#define VSB_TOP_COMM_MB_MUX_OBS__W 4
12118#define VSB_TOP_COMM_MB_MUX_OBS__M 0x3C0
12119#define VSB_TOP_COMM_MB_MUX_OBS__PRE 0x0
12120#define VSB_TOP_COMM_MB_MUX_OBS_VSB_FEC 0x0
12121#define VSB_TOP_COMM_MB_MUX_OBS_VSB_IQM 0x40
12122#define VSB_TOP_COMM_MB_MUX_OBS_VSB_IQM_AMPLITUDE 0x80
12123#define VSB_TOP_COMM_MB_MUX_OBS_VSB_TCMEQ_1 0xC0
12124#define VSB_TOP_COMM_MB_MUX_OBS_VSB_TCMEQ_2 0x100
12125#define VSB_TOP_COMM_MB_MUX_OBS_VSB_FFE_1 0x140
12126#define VSB_TOP_COMM_MB_MUX_OBS_VSB_FFE_2 0x180
12127#define VSB_TOP_COMM_MB_MUX_OBS_VSB_DFE_1 0x1C0
12128#define VSB_TOP_COMM_MB_MUX_OBS_VSB_DFE_2 0x200
12129
12130#define VSB_TOP_COMM_INT_REQ__A 0x1C10003
12131#define VSB_TOP_COMM_INT_REQ__W 1
12132#define VSB_TOP_COMM_INT_REQ__M 0x1
12133#define VSB_TOP_COMM_INT_REQ__PRE 0x0
12134#define VSB_TOP_COMM_INT_STA__A 0x1C10005
12135#define VSB_TOP_COMM_INT_STA__W 6
12136#define VSB_TOP_COMM_INT_STA__M 0x3F
12137#define VSB_TOP_COMM_INT_STA__PRE 0x0
12138
12139#define VSB_TOP_COMM_INT_STA_FIELD_INT_STA__B 0
12140#define VSB_TOP_COMM_INT_STA_FIELD_INT_STA__W 1
12141#define VSB_TOP_COMM_INT_STA_FIELD_INT_STA__M 0x1
12142#define VSB_TOP_COMM_INT_STA_FIELD_INT_STA__PRE 0x0
12143
12144#define VSB_TOP_COMM_INT_STA_LOCK_STA__B 1
12145#define VSB_TOP_COMM_INT_STA_LOCK_STA__W 1
12146#define VSB_TOP_COMM_INT_STA_LOCK_STA__M 0x2
12147#define VSB_TOP_COMM_INT_STA_LOCK_STA__PRE 0x0
12148
12149#define VSB_TOP_COMM_INT_STA_UNLOCK_STA__B 2
12150#define VSB_TOP_COMM_INT_STA_UNLOCK_STA__W 1
12151#define VSB_TOP_COMM_INT_STA_UNLOCK_STA__M 0x4
12152#define VSB_TOP_COMM_INT_STA_UNLOCK_STA__PRE 0x0
12153
12154#define VSB_TOP_COMM_INT_STA_TAPREADER_STA__B 3
12155#define VSB_TOP_COMM_INT_STA_TAPREADER_STA__W 1
12156#define VSB_TOP_COMM_INT_STA_TAPREADER_STA__M 0x8
12157#define VSB_TOP_COMM_INT_STA_TAPREADER_STA__PRE 0x0
12158
12159#define VSB_TOP_COMM_INT_STA_SEGSYNCINTR_STA__B 4
12160#define VSB_TOP_COMM_INT_STA_SEGSYNCINTR_STA__W 1
12161#define VSB_TOP_COMM_INT_STA_SEGSYNCINTR_STA__M 0x10
12162#define VSB_TOP_COMM_INT_STA_SEGSYNCINTR_STA__PRE 0x0
12163
12164#define VSB_TOP_COMM_INT_STA_MERSER_STA__B 5
12165#define VSB_TOP_COMM_INT_STA_MERSER_STA__W 1
12166#define VSB_TOP_COMM_INT_STA_MERSER_STA__M 0x20
12167#define VSB_TOP_COMM_INT_STA_MERSER_STA__PRE 0x0
12168
12169#define VSB_TOP_COMM_INT_MSK__A 0x1C10006
12170#define VSB_TOP_COMM_INT_MSK__W 6
12171#define VSB_TOP_COMM_INT_MSK__M 0x3F
12172#define VSB_TOP_COMM_INT_MSK__PRE 0x0
12173
12174#define VSB_TOP_COMM_INT_MSK_FIELD_INT_MSK__B 0
12175#define VSB_TOP_COMM_INT_MSK_FIELD_INT_MSK__W 1
12176#define VSB_TOP_COMM_INT_MSK_FIELD_INT_MSK__M 0x1
12177#define VSB_TOP_COMM_INT_MSK_FIELD_INT_MSK__PRE 0x0
12178
12179#define VSB_TOP_COMM_INT_MSK_LOCK_MSK__B 1
12180#define VSB_TOP_COMM_INT_MSK_LOCK_MSK__W 1
12181#define VSB_TOP_COMM_INT_MSK_LOCK_MSK__M 0x2
12182#define VSB_TOP_COMM_INT_MSK_LOCK_MSK__PRE 0x0
12183
12184#define VSB_TOP_COMM_INT_MSK_UNLOCK_MSK__B 2
12185#define VSB_TOP_COMM_INT_MSK_UNLOCK_MSK__W 1
12186#define VSB_TOP_COMM_INT_MSK_UNLOCK_MSK__M 0x4
12187#define VSB_TOP_COMM_INT_MSK_UNLOCK_MSK__PRE 0x0
12188
12189#define VSB_TOP_COMM_INT_MSK_TAPREADER_MSK__B 3
12190#define VSB_TOP_COMM_INT_MSK_TAPREADER_MSK__W 1
12191#define VSB_TOP_COMM_INT_MSK_TAPREADER_MSK__M 0x8
12192#define VSB_TOP_COMM_INT_MSK_TAPREADER_MSK__PRE 0x0
12193
12194#define VSB_TOP_COMM_INT_MSK_SEGSYNCINTR_MSK__B 4
12195#define VSB_TOP_COMM_INT_MSK_SEGSYNCINTR_MSK__W 1
12196#define VSB_TOP_COMM_INT_MSK_SEGSYNCINTR_MSK__M 0x10
12197#define VSB_TOP_COMM_INT_MSK_SEGSYNCINTR_MSK__PRE 0x0
12198
12199#define VSB_TOP_COMM_INT_MSK_MERSER_MSK__B 5
12200#define VSB_TOP_COMM_INT_MSK_MERSER_MSK__W 1
12201#define VSB_TOP_COMM_INT_MSK_MERSER_MSK__M 0x20
12202#define VSB_TOP_COMM_INT_MSK_MERSER_MSK__PRE 0x0
12203
12204#define VSB_TOP_COMM_INT_STM__A 0x1C10007
12205#define VSB_TOP_COMM_INT_STM__W 6
12206#define VSB_TOP_COMM_INT_STM__M 0x3F
12207#define VSB_TOP_COMM_INT_STM__PRE 0x0
12208
12209#define VSB_TOP_COMM_INT_STM_FIELD_INT_STM__B 0
12210#define VSB_TOP_COMM_INT_STM_FIELD_INT_STM__W 1
12211#define VSB_TOP_COMM_INT_STM_FIELD_INT_STM__M 0x1
12212#define VSB_TOP_COMM_INT_STM_FIELD_INT_STM__PRE 0x0
12213
12214#define VSB_TOP_COMM_INT_STM_LOCK_STM__B 1
12215#define VSB_TOP_COMM_INT_STM_LOCK_STM__W 1
12216#define VSB_TOP_COMM_INT_STM_LOCK_STM__M 0x2
12217#define VSB_TOP_COMM_INT_STM_LOCK_STM__PRE 0x0
12218
12219#define VSB_TOP_COMM_INT_STM_UNLOCK_STM__B 2
12220#define VSB_TOP_COMM_INT_STM_UNLOCK_STM__W 1
12221#define VSB_TOP_COMM_INT_STM_UNLOCK_STM__M 0x4
12222#define VSB_TOP_COMM_INT_STM_UNLOCK_STM__PRE 0x0
12223
12224#define VSB_TOP_COMM_INT_STM_TAPREADER_STM__B 3
12225#define VSB_TOP_COMM_INT_STM_TAPREADER_STM__W 1
12226#define VSB_TOP_COMM_INT_STM_TAPREADER_STM__M 0x8
12227#define VSB_TOP_COMM_INT_STM_TAPREADER_STM__PRE 0x0
12228
12229#define VSB_TOP_COMM_INT_STM_SEGSYNCINTR_STM__B 4
12230#define VSB_TOP_COMM_INT_STM_SEGSYNCINTR_STM__W 1
12231#define VSB_TOP_COMM_INT_STM_SEGSYNCINTR_STM__M 0x10
12232#define VSB_TOP_COMM_INT_STM_SEGSYNCINTR_STM__PRE 0x0
12233
12234#define VSB_TOP_COMM_INT_STM_MERSER_STM__B 5
12235#define VSB_TOP_COMM_INT_STM_MERSER_STM__W 1
12236#define VSB_TOP_COMM_INT_STM_MERSER_STM__M 0x20
12237#define VSB_TOP_COMM_INT_STM_MERSER_STM__PRE 0x0
12238
12239#define VSB_TOP_CKGN1ACQ__A 0x1C10010
12240#define VSB_TOP_CKGN1ACQ__W 8
12241#define VSB_TOP_CKGN1ACQ__M 0xFF
12242#define VSB_TOP_CKGN1ACQ__PRE 0x4
12243
12244#define VSB_TOP_CKGN1TRK__A 0x1C10011
12245#define VSB_TOP_CKGN1TRK__W 8
12246#define VSB_TOP_CKGN1TRK__M 0xFF
12247#define VSB_TOP_CKGN1TRK__PRE 0x0
12248
12249#define VSB_TOP_CKGN2ACQ__A 0x1C10012
12250#define VSB_TOP_CKGN2ACQ__W 8
12251#define VSB_TOP_CKGN2ACQ__M 0xFF
12252#define VSB_TOP_CKGN2ACQ__PRE 0x2
12253
12254#define VSB_TOP_CKGN2TRK__A 0x1C10013
12255#define VSB_TOP_CKGN2TRK__W 8
12256#define VSB_TOP_CKGN2TRK__M 0xFF
12257#define VSB_TOP_CKGN2TRK__PRE 0x1
12258
12259#define VSB_TOP_CKGN3__A 0x1C10014
12260#define VSB_TOP_CKGN3__W 8
12261#define VSB_TOP_CKGN3__M 0xFF
12262#define VSB_TOP_CKGN3__PRE 0x5
12263
12264#define VSB_TOP_CYGN1ACQ__A 0x1C10015
12265#define VSB_TOP_CYGN1ACQ__W 8
12266#define VSB_TOP_CYGN1ACQ__M 0xFF
12267#define VSB_TOP_CYGN1ACQ__PRE 0x3
12268
12269#define VSB_TOP_CYGN1TRK__A 0x1C10016
12270#define VSB_TOP_CYGN1TRK__W 8
12271#define VSB_TOP_CYGN1TRK__M 0xFF
12272#define VSB_TOP_CYGN1TRK__PRE 0x0
12273
12274#define VSB_TOP_CYGN2ACQ__A 0x1C10017
12275#define VSB_TOP_CYGN2ACQ__W 8
12276#define VSB_TOP_CYGN2ACQ__M 0xFF
12277#define VSB_TOP_CYGN2ACQ__PRE 0x3
12278
12279#define VSB_TOP_CYGN2TRK__A 0x1C10018
12280#define VSB_TOP_CYGN2TRK__W 8
12281#define VSB_TOP_CYGN2TRK__M 0xFF
12282#define VSB_TOP_CYGN2TRK__PRE 0x2
12283
12284#define VSB_TOP_CYGN3__A 0x1C10019
12285#define VSB_TOP_CYGN3__W 8
12286#define VSB_TOP_CYGN3__M 0xFF
12287#define VSB_TOP_CYGN3__PRE 0x6
12288#define VSB_TOP_SYNCCTRLWORD__A 0x1C1001A
12289#define VSB_TOP_SYNCCTRLWORD__W 5
12290#define VSB_TOP_SYNCCTRLWORD__M 0x1F
12291#define VSB_TOP_SYNCCTRLWORD__PRE 0x0
12292
12293#define VSB_TOP_SYNCCTRLWORD_PRST__B 0
12294#define VSB_TOP_SYNCCTRLWORD_PRST__W 1
12295#define VSB_TOP_SYNCCTRLWORD_PRST__M 0x1
12296#define VSB_TOP_SYNCCTRLWORD_PRST__PRE 0x0
12297
12298#define VSB_TOP_SYNCCTRLWORD_DCFREEZ__B 1
12299#define VSB_TOP_SYNCCTRLWORD_DCFREEZ__W 1
12300#define VSB_TOP_SYNCCTRLWORD_DCFREEZ__M 0x2
12301#define VSB_TOP_SYNCCTRLWORD_DCFREEZ__PRE 0x0
12302
12303#define VSB_TOP_SYNCCTRLWORD_INVCNST__B 2
12304#define VSB_TOP_SYNCCTRLWORD_INVCNST__W 1
12305#define VSB_TOP_SYNCCTRLWORD_INVCNST__M 0x4
12306#define VSB_TOP_SYNCCTRLWORD_INVCNST__PRE 0x0
12307
12308#define VSB_TOP_SYNCCTRLWORD_CPUAGCRST__B 3
12309#define VSB_TOP_SYNCCTRLWORD_CPUAGCRST__W 1
12310#define VSB_TOP_SYNCCTRLWORD_CPUAGCRST__M 0x8
12311#define VSB_TOP_SYNCCTRLWORD_CPUAGCRST__PRE 0x0
12312
12313#define VSB_TOP_SYNCCTRLWORD_AGCIGNOREFS__B 4
12314#define VSB_TOP_SYNCCTRLWORD_AGCIGNOREFS__W 1
12315#define VSB_TOP_SYNCCTRLWORD_AGCIGNOREFS__M 0x10
12316#define VSB_TOP_SYNCCTRLWORD_AGCIGNOREFS__PRE 0x0
12317
12318#define VSB_TOP_MAINSMUP__A 0x1C1001B
12319#define VSB_TOP_MAINSMUP__W 8
12320#define VSB_TOP_MAINSMUP__M 0xFF
12321#define VSB_TOP_MAINSMUP__PRE 0xFF
12322
12323#define VSB_TOP_EQSMUP__A 0x1C1001C
12324#define VSB_TOP_EQSMUP__W 8
12325#define VSB_TOP_EQSMUP__M 0xFF
12326#define VSB_TOP_EQSMUP__PRE 0xFF
12327#define VSB_TOP_SYSMUXCTRL__A 0x1C1001D
12328#define VSB_TOP_SYSMUXCTRL__W 13
12329#define VSB_TOP_SYSMUXCTRL__M 0x1FFF
12330#define VSB_TOP_SYSMUXCTRL__PRE 0x0
12331
12332#define VSB_TOP_SYSMUXCTRL_CYLK_STATIC__B 0
12333#define VSB_TOP_SYSMUXCTRL_CYLK_STATIC__W 1
12334#define VSB_TOP_SYSMUXCTRL_CYLK_STATIC__M 0x1
12335#define VSB_TOP_SYSMUXCTRL_CYLK_STATIC__PRE 0x0
12336
12337#define VSB_TOP_SYSMUXCTRL_CYLK_SEL_STATIC__B 1
12338#define VSB_TOP_SYSMUXCTRL_CYLK_SEL_STATIC__W 1
12339#define VSB_TOP_SYSMUXCTRL_CYLK_SEL_STATIC__M 0x2
12340#define VSB_TOP_SYSMUXCTRL_CYLK_SEL_STATIC__PRE 0x0
12341
12342#define VSB_TOP_SYSMUXCTRL_CTCALDONE_STATIC__B 2
12343#define VSB_TOP_SYSMUXCTRL_CTCALDONE_STATIC__W 1
12344#define VSB_TOP_SYSMUXCTRL_CTCALDONE_STATIC__M 0x4
12345#define VSB_TOP_SYSMUXCTRL_CTCALDONE_STATIC__PRE 0x0
12346
12347#define VSB_TOP_SYSMUXCTRL_CTCALDONE_SEL_STATIC__B 3
12348#define VSB_TOP_SYSMUXCTRL_CTCALDONE_SEL_STATIC__W 1
12349#define VSB_TOP_SYSMUXCTRL_CTCALDONE_SEL_STATIC__M 0x8
12350#define VSB_TOP_SYSMUXCTRL_CTCALDONE_SEL_STATIC__PRE 0x0
12351
12352#define VSB_TOP_SYSMUXCTRL_FRAMELOCK_STATIC__B 4
12353#define VSB_TOP_SYSMUXCTRL_FRAMELOCK_STATIC__W 1
12354#define VSB_TOP_SYSMUXCTRL_FRAMELOCK_STATIC__M 0x10
12355#define VSB_TOP_SYSMUXCTRL_FRAMELOCK_STATIC__PRE 0x0
12356
12357#define VSB_TOP_SYSMUXCTRL_FRAMELOCK_SEL_STATIC__B 5
12358#define VSB_TOP_SYSMUXCTRL_FRAMELOCK_SEL_STATIC__W 1
12359#define VSB_TOP_SYSMUXCTRL_FRAMELOCK_SEL_STATIC__M 0x20
12360#define VSB_TOP_SYSMUXCTRL_FRAMELOCK_SEL_STATIC__PRE 0x0
12361
12362#define VSB_TOP_SYSMUXCTRL_FRAMESYNC_STATIC__B 6
12363#define VSB_TOP_SYSMUXCTRL_FRAMESYNC_STATIC__W 1
12364#define VSB_TOP_SYSMUXCTRL_FRAMESYNC_STATIC__M 0x40
12365#define VSB_TOP_SYSMUXCTRL_FRAMESYNC_STATIC__PRE 0x0
12366
12367#define VSB_TOP_SYSMUXCTRL_FRAMESYNC_SEL_STATIC__B 7
12368#define VSB_TOP_SYSMUXCTRL_FRAMESYNC_SEL_STATIC__W 1
12369#define VSB_TOP_SYSMUXCTRL_FRAMESYNC_SEL_STATIC__M 0x80
12370#define VSB_TOP_SYSMUXCTRL_FRAMESYNC_SEL_STATIC__PRE 0x0
12371
12372#define VSB_TOP_SYSMUXCTRL_SNROVTH_STATIC__B 8
12373#define VSB_TOP_SYSMUXCTRL_SNROVTH_STATIC__W 4
12374#define VSB_TOP_SYSMUXCTRL_SNROVTH_STATIC__M 0xF00
12375#define VSB_TOP_SYSMUXCTRL_SNROVTH_STATIC__PRE 0x0
12376
12377#define VSB_TOP_SYSMUXCTRL_SNROVTH_SEL_STATIC__B 12
12378#define VSB_TOP_SYSMUXCTRL_SNROVTH_SEL_STATIC__W 1
12379#define VSB_TOP_SYSMUXCTRL_SNROVTH_SEL_STATIC__M 0x1000
12380#define VSB_TOP_SYSMUXCTRL_SNROVTH_SEL_STATIC__PRE 0x0
12381
12382#define VSB_TOP_SNRTH_RCA1__A 0x1C1001E
12383#define VSB_TOP_SNRTH_RCA1__W 8
12384#define VSB_TOP_SNRTH_RCA1__M 0xFF
12385#define VSB_TOP_SNRTH_RCA1__PRE 0x53
12386
12387#define VSB_TOP_SNRTH_RCA1_DN__B 0
12388#define VSB_TOP_SNRTH_RCA1_DN__W 4
12389#define VSB_TOP_SNRTH_RCA1_DN__M 0xF
12390#define VSB_TOP_SNRTH_RCA1_DN__PRE 0x3
12391
12392#define VSB_TOP_SNRTH_RCA1_UP__B 4
12393#define VSB_TOP_SNRTH_RCA1_UP__W 4
12394#define VSB_TOP_SNRTH_RCA1_UP__M 0xF0
12395#define VSB_TOP_SNRTH_RCA1_UP__PRE 0x50
12396
12397#define VSB_TOP_SNRTH_RCA2__A 0x1C1001F
12398#define VSB_TOP_SNRTH_RCA2__W 8
12399#define VSB_TOP_SNRTH_RCA2__M 0xFF
12400#define VSB_TOP_SNRTH_RCA2__PRE 0x75
12401
12402#define VSB_TOP_SNRTH_RCA2_DN__B 0
12403#define VSB_TOP_SNRTH_RCA2_DN__W 4
12404#define VSB_TOP_SNRTH_RCA2_DN__M 0xF
12405#define VSB_TOP_SNRTH_RCA2_DN__PRE 0x5
12406
12407#define VSB_TOP_SNRTH_RCA2_UP__B 4
12408#define VSB_TOP_SNRTH_RCA2_UP__W 4
12409#define VSB_TOP_SNRTH_RCA2_UP__M 0xF0
12410#define VSB_TOP_SNRTH_RCA2_UP__PRE 0x70
12411
12412#define VSB_TOP_SNRTH_DDM1__A 0x1C10020
12413#define VSB_TOP_SNRTH_DDM1__W 8
12414#define VSB_TOP_SNRTH_DDM1__M 0xFF
12415#define VSB_TOP_SNRTH_DDM1__PRE 0xCA
12416
12417#define VSB_TOP_SNRTH_DDM1_DN__B 0
12418#define VSB_TOP_SNRTH_DDM1_DN__W 4
12419#define VSB_TOP_SNRTH_DDM1_DN__M 0xF
12420#define VSB_TOP_SNRTH_DDM1_DN__PRE 0xA
12421
12422#define VSB_TOP_SNRTH_DDM1_UP__B 4
12423#define VSB_TOP_SNRTH_DDM1_UP__W 4
12424#define VSB_TOP_SNRTH_DDM1_UP__M 0xF0
12425#define VSB_TOP_SNRTH_DDM1_UP__PRE 0xC0
12426
12427#define VSB_TOP_SNRTH_DDM2__A 0x1C10021
12428#define VSB_TOP_SNRTH_DDM2__W 8
12429#define VSB_TOP_SNRTH_DDM2__M 0xFF
12430#define VSB_TOP_SNRTH_DDM2__PRE 0xCA
12431
12432#define VSB_TOP_SNRTH_DDM2_DN__B 0
12433#define VSB_TOP_SNRTH_DDM2_DN__W 4
12434#define VSB_TOP_SNRTH_DDM2_DN__M 0xF
12435#define VSB_TOP_SNRTH_DDM2_DN__PRE 0xA
12436
12437#define VSB_TOP_SNRTH_DDM2_UP__B 4
12438#define VSB_TOP_SNRTH_DDM2_UP__W 4
12439#define VSB_TOP_SNRTH_DDM2_UP__M 0xF0
12440#define VSB_TOP_SNRTH_DDM2_UP__PRE 0xC0
12441
12442#define VSB_TOP_SNRTH_PT__A 0x1C10022
12443#define VSB_TOP_SNRTH_PT__W 8
12444#define VSB_TOP_SNRTH_PT__M 0xFF
12445#define VSB_TOP_SNRTH_PT__PRE 0xD8
12446
12447#define VSB_TOP_SNRTH_PT_DN__B 0
12448#define VSB_TOP_SNRTH_PT_DN__W 4
12449#define VSB_TOP_SNRTH_PT_DN__M 0xF
12450#define VSB_TOP_SNRTH_PT_DN__PRE 0x8
12451
12452#define VSB_TOP_SNRTH_PT_UP__B 4
12453#define VSB_TOP_SNRTH_PT_UP__W 4
12454#define VSB_TOP_SNRTH_PT_UP__M 0xF0
12455#define VSB_TOP_SNRTH_PT_UP__PRE 0xD0
12456
12457#define VSB_TOP_CYSMSTATES__A 0x1C10023
12458#define VSB_TOP_CYSMSTATES__W 8
12459#define VSB_TOP_CYSMSTATES__M 0xFF
12460#define VSB_TOP_CYSMSTATES__PRE 0x0
12461
12462#define VSB_TOP_CYSMSTATES_SYSST__B 0
12463#define VSB_TOP_CYSMSTATES_SYSST__W 4
12464#define VSB_TOP_CYSMSTATES_SYSST__M 0xF
12465#define VSB_TOP_CYSMSTATES_SYSST__PRE 0x0
12466
12467#define VSB_TOP_CYSMSTATES_EQST__B 4
12468#define VSB_TOP_CYSMSTATES_EQST__W 4
12469#define VSB_TOP_CYSMSTATES_EQST__M 0xF0
12470#define VSB_TOP_CYSMSTATES_EQST__PRE 0x0
12471
12472#define VSB_TOP_SMALL_NOTCH_CONTROL__A 0x1C10024
12473#define VSB_TOP_SMALL_NOTCH_CONTROL__W 8
12474#define VSB_TOP_SMALL_NOTCH_CONTROL__M 0xFF
12475#define VSB_TOP_SMALL_NOTCH_CONTROL__PRE 0x0
12476
12477#define VSB_TOP_SMALL_NOTCH_CONTROL_GO__B 0
12478#define VSB_TOP_SMALL_NOTCH_CONTROL_GO__W 1
12479#define VSB_TOP_SMALL_NOTCH_CONTROL_GO__M 0x1
12480#define VSB_TOP_SMALL_NOTCH_CONTROL_GO__PRE 0x0
12481
12482#define VSB_TOP_SMALL_NOTCH_CONTROL_BYPASS1__B 1
12483#define VSB_TOP_SMALL_NOTCH_CONTROL_BYPASS1__W 1
12484#define VSB_TOP_SMALL_NOTCH_CONTROL_BYPASS1__M 0x2
12485#define VSB_TOP_SMALL_NOTCH_CONTROL_BYPASS1__PRE 0x0
12486
12487#define VSB_TOP_SMALL_NOTCH_CONTROL_BYPASS2__B 2
12488#define VSB_TOP_SMALL_NOTCH_CONTROL_BYPASS2__W 1
12489#define VSB_TOP_SMALL_NOTCH_CONTROL_BYPASS2__M 0x4
12490#define VSB_TOP_SMALL_NOTCH_CONTROL_BYPASS2__PRE 0x0
12491
12492#define VSB_TOP_SMALL_NOTCH_CONTROL_SPARE__B 3
12493#define VSB_TOP_SMALL_NOTCH_CONTROL_SPARE__W 4
12494#define VSB_TOP_SMALL_NOTCH_CONTROL_SPARE__M 0x78
12495#define VSB_TOP_SMALL_NOTCH_CONTROL_SPARE__PRE 0x0
12496
12497#define VSB_TOP_SMALL_NOTCH_CONTROL_SOFT_RESET__B 7
12498#define VSB_TOP_SMALL_NOTCH_CONTROL_SOFT_RESET__W 1
12499#define VSB_TOP_SMALL_NOTCH_CONTROL_SOFT_RESET__M 0x80
12500#define VSB_TOP_SMALL_NOTCH_CONTROL_SOFT_RESET__PRE 0x0
12501
12502#define VSB_TOP_TAPREADCYC__A 0x1C10025
12503#define VSB_TOP_TAPREADCYC__W 9
12504#define VSB_TOP_TAPREADCYC__M 0x1FF
12505#define VSB_TOP_TAPREADCYC__PRE 0x1
12506
12507#define VSB_TOP_VALIDPKLVL__A 0x1C10026
12508#define VSB_TOP_VALIDPKLVL__W 13
12509#define VSB_TOP_VALIDPKLVL__M 0x1FFF
12510#define VSB_TOP_VALIDPKLVL__PRE 0x100
12511
12512#define VSB_TOP_CENTROID_FINE_DELAY__A 0x1C10027
12513#define VSB_TOP_CENTROID_FINE_DELAY__W 10
12514#define VSB_TOP_CENTROID_FINE_DELAY__M 0x3FF
12515#define VSB_TOP_CENTROID_FINE_DELAY__PRE 0xFF
12516
12517#define VSB_TOP_CENTROID_SMACH_DELAY__A 0x1C10028
12518#define VSB_TOP_CENTROID_SMACH_DELAY__W 10
12519#define VSB_TOP_CENTROID_SMACH_DELAY__M 0x3FF
12520#define VSB_TOP_CENTROID_SMACH_DELAY__PRE 0x1FF
12521
12522#define VSB_TOP_SNR__A 0x1C10029
12523#define VSB_TOP_SNR__W 14
12524#define VSB_TOP_SNR__M 0x3FFF
12525#define VSB_TOP_SNR__PRE 0x0
12526#define VSB_TOP_LOCKSTATUS__A 0x1C1002A
12527#define VSB_TOP_LOCKSTATUS__W 7
12528#define VSB_TOP_LOCKSTATUS__M 0x7F
12529#define VSB_TOP_LOCKSTATUS__PRE 0x0
12530
12531#define VSB_TOP_LOCKSTATUS_VSBMODE__B 0
12532#define VSB_TOP_LOCKSTATUS_VSBMODE__W 4
12533#define VSB_TOP_LOCKSTATUS_VSBMODE__M 0xF
12534#define VSB_TOP_LOCKSTATUS_VSBMODE__PRE 0x0
12535
12536#define VSB_TOP_LOCKSTATUS_FRMLOCK__B 4
12537#define VSB_TOP_LOCKSTATUS_FRMLOCK__W 1
12538#define VSB_TOP_LOCKSTATUS_FRMLOCK__M 0x10
12539#define VSB_TOP_LOCKSTATUS_FRMLOCK__PRE 0x0
12540
12541#define VSB_TOP_LOCKSTATUS_CYLOCK__B 5
12542#define VSB_TOP_LOCKSTATUS_CYLOCK__W 1
12543#define VSB_TOP_LOCKSTATUS_CYLOCK__M 0x20
12544#define VSB_TOP_LOCKSTATUS_CYLOCK__PRE 0x0
12545
12546#define VSB_TOP_LOCKSTATUS_DDMON__B 6
12547#define VSB_TOP_LOCKSTATUS_DDMON__W 1
12548#define VSB_TOP_LOCKSTATUS_DDMON__M 0x40
12549#define VSB_TOP_LOCKSTATUS_DDMON__PRE 0x0
12550
12551#define VSB_TOP_CTST__A 0x1C1002B
12552#define VSB_TOP_CTST__W 4
12553#define VSB_TOP_CTST__M 0xF
12554#define VSB_TOP_CTST__PRE 0x0
12555#define VSB_TOP_EQSMRSTCTRL__A 0x1C1002C
12556#define VSB_TOP_EQSMRSTCTRL__W 7
12557#define VSB_TOP_EQSMRSTCTRL__M 0x7F
12558#define VSB_TOP_EQSMRSTCTRL__PRE 0x0
12559
12560#define VSB_TOP_EQSMRSTCTRL_RCAON__B 0
12561#define VSB_TOP_EQSMRSTCTRL_RCAON__W 1
12562#define VSB_TOP_EQSMRSTCTRL_RCAON__M 0x1
12563#define VSB_TOP_EQSMRSTCTRL_RCAON__PRE 0x0
12564
12565#define VSB_TOP_EQSMRSTCTRL_DFEON__B 1
12566#define VSB_TOP_EQSMRSTCTRL_DFEON__W 1
12567#define VSB_TOP_EQSMRSTCTRL_DFEON__M 0x2
12568#define VSB_TOP_EQSMRSTCTRL_DFEON__PRE 0x0
12569
12570#define VSB_TOP_EQSMRSTCTRL_DDMEN1__B 2
12571#define VSB_TOP_EQSMRSTCTRL_DDMEN1__W 1
12572#define VSB_TOP_EQSMRSTCTRL_DDMEN1__M 0x4
12573#define VSB_TOP_EQSMRSTCTRL_DDMEN1__PRE 0x0
12574
12575#define VSB_TOP_EQSMRSTCTRL_DDMEN2__B 3
12576#define VSB_TOP_EQSMRSTCTRL_DDMEN2__W 1
12577#define VSB_TOP_EQSMRSTCTRL_DDMEN2__M 0x8
12578#define VSB_TOP_EQSMRSTCTRL_DDMEN2__PRE 0x0
12579
12580#define VSB_TOP_EQSMRSTCTRL_DIGIAGCON__B 4
12581#define VSB_TOP_EQSMRSTCTRL_DIGIAGCON__W 1
12582#define VSB_TOP_EQSMRSTCTRL_DIGIAGCON__M 0x10
12583#define VSB_TOP_EQSMRSTCTRL_DIGIAGCON__PRE 0x0
12584
12585#define VSB_TOP_EQSMRSTCTRL_PARAINITEN__B 5
12586#define VSB_TOP_EQSMRSTCTRL_PARAINITEN__W 1
12587#define VSB_TOP_EQSMRSTCTRL_PARAINITEN__M 0x20
12588#define VSB_TOP_EQSMRSTCTRL_PARAINITEN__PRE 0x0
12589
12590#define VSB_TOP_EQSMRSTCTRL_TIMEOUTFRMCNTEN__B 6
12591#define VSB_TOP_EQSMRSTCTRL_TIMEOUTFRMCNTEN__W 1
12592#define VSB_TOP_EQSMRSTCTRL_TIMEOUTFRMCNTEN__M 0x40
12593#define VSB_TOP_EQSMRSTCTRL_TIMEOUTFRMCNTEN__PRE 0x0
12594
12595#define VSB_TOP_EQSMTRNCTRL__A 0x1C1002D
12596#define VSB_TOP_EQSMTRNCTRL__W 7
12597#define VSB_TOP_EQSMTRNCTRL__M 0x7F
12598#define VSB_TOP_EQSMTRNCTRL__PRE 0x40
12599
12600#define VSB_TOP_EQSMTRNCTRL_RCAON__B 0
12601#define VSB_TOP_EQSMTRNCTRL_RCAON__W 1
12602#define VSB_TOP_EQSMTRNCTRL_RCAON__M 0x1
12603#define VSB_TOP_EQSMTRNCTRL_RCAON__PRE 0x0
12604
12605#define VSB_TOP_EQSMTRNCTRL_DFEON__B 1
12606#define VSB_TOP_EQSMTRNCTRL_DFEON__W 1
12607#define VSB_TOP_EQSMTRNCTRL_DFEON__M 0x2
12608#define VSB_TOP_EQSMTRNCTRL_DFEON__PRE 0x0
12609
12610#define VSB_TOP_EQSMTRNCTRL_DDMEN1__B 2
12611#define VSB_TOP_EQSMTRNCTRL_DDMEN1__W 1
12612#define VSB_TOP_EQSMTRNCTRL_DDMEN1__M 0x4
12613#define VSB_TOP_EQSMTRNCTRL_DDMEN1__PRE 0x0
12614
12615#define VSB_TOP_EQSMTRNCTRL_DDMEN2__B 3
12616#define VSB_TOP_EQSMTRNCTRL_DDMEN2__W 1
12617#define VSB_TOP_EQSMTRNCTRL_DDMEN2__M 0x8
12618#define VSB_TOP_EQSMTRNCTRL_DDMEN2__PRE 0x0
12619
12620#define VSB_TOP_EQSMTRNCTRL_DIGIAGCON__B 4
12621#define VSB_TOP_EQSMTRNCTRL_DIGIAGCON__W 1
12622#define VSB_TOP_EQSMTRNCTRL_DIGIAGCON__M 0x10
12623#define VSB_TOP_EQSMTRNCTRL_DIGIAGCON__PRE 0x0
12624
12625#define VSB_TOP_EQSMTRNCTRL_PARAINITEN__B 5
12626#define VSB_TOP_EQSMTRNCTRL_PARAINITEN__W 1
12627#define VSB_TOP_EQSMTRNCTRL_PARAINITEN__M 0x20
12628#define VSB_TOP_EQSMTRNCTRL_PARAINITEN__PRE 0x0
12629
12630#define VSB_TOP_EQSMTRNCTRL_TIMEOUTFRMCNTEN__B 6
12631#define VSB_TOP_EQSMTRNCTRL_TIMEOUTFRMCNTEN__W 1
12632#define VSB_TOP_EQSMTRNCTRL_TIMEOUTFRMCNTEN__M 0x40
12633#define VSB_TOP_EQSMTRNCTRL_TIMEOUTFRMCNTEN__PRE 0x40
12634
12635#define VSB_TOP_EQSMRCA1CTRL__A 0x1C1002E
12636#define VSB_TOP_EQSMRCA1CTRL__W 7
12637#define VSB_TOP_EQSMRCA1CTRL__M 0x7F
12638#define VSB_TOP_EQSMRCA1CTRL__PRE 0x1
12639
12640#define VSB_TOP_EQSMRCA1CTRL_RCAON__B 0
12641#define VSB_TOP_EQSMRCA1CTRL_RCAON__W 1
12642#define VSB_TOP_EQSMRCA1CTRL_RCAON__M 0x1
12643#define VSB_TOP_EQSMRCA1CTRL_RCAON__PRE 0x1
12644
12645#define VSB_TOP_EQSMRCA1CTRL_DFEON__B 1
12646#define VSB_TOP_EQSMRCA1CTRL_DFEON__W 1
12647#define VSB_TOP_EQSMRCA1CTRL_DFEON__M 0x2
12648#define VSB_TOP_EQSMRCA1CTRL_DFEON__PRE 0x0
12649
12650#define VSB_TOP_EQSMRCA1CTRL_DDMEN1__B 2
12651#define VSB_TOP_EQSMRCA1CTRL_DDMEN1__W 1
12652#define VSB_TOP_EQSMRCA1CTRL_DDMEN1__M 0x4
12653#define VSB_TOP_EQSMRCA1CTRL_DDMEN1__PRE 0x0
12654
12655#define VSB_TOP_EQSMRCA1CTRL_DDMEN2__B 3
12656#define VSB_TOP_EQSMRCA1CTRL_DDMEN2__W 1
12657#define VSB_TOP_EQSMRCA1CTRL_DDMEN2__M 0x8
12658#define VSB_TOP_EQSMRCA1CTRL_DDMEN2__PRE 0x0
12659
12660#define VSB_TOP_EQSMRCA1CTRL_DIGIAGCON__B 4
12661#define VSB_TOP_EQSMRCA1CTRL_DIGIAGCON__W 1
12662#define VSB_TOP_EQSMRCA1CTRL_DIGIAGCON__M 0x10
12663#define VSB_TOP_EQSMRCA1CTRL_DIGIAGCON__PRE 0x0
12664
12665#define VSB_TOP_EQSMRCA1CTRL_PARAINITEN__B 5
12666#define VSB_TOP_EQSMRCA1CTRL_PARAINITEN__W 1
12667#define VSB_TOP_EQSMRCA1CTRL_PARAINITEN__M 0x20
12668#define VSB_TOP_EQSMRCA1CTRL_PARAINITEN__PRE 0x0
12669
12670#define VSB_TOP_EQSMRCA1CTRL_TIMEOUTFRMCNTEN__B 6
12671#define VSB_TOP_EQSMRCA1CTRL_TIMEOUTFRMCNTEN__W 1
12672#define VSB_TOP_EQSMRCA1CTRL_TIMEOUTFRMCNTEN__M 0x40
12673#define VSB_TOP_EQSMRCA1CTRL_TIMEOUTFRMCNTEN__PRE 0x0
12674
12675#define VSB_TOP_EQSMRCA2CTRL__A 0x1C1002F
12676#define VSB_TOP_EQSMRCA2CTRL__W 7
12677#define VSB_TOP_EQSMRCA2CTRL__M 0x7F
12678#define VSB_TOP_EQSMRCA2CTRL__PRE 0x3
12679
12680#define VSB_TOP_EQSMRCA2CTRL_RCAON__B 0
12681#define VSB_TOP_EQSMRCA2CTRL_RCAON__W 1
12682#define VSB_TOP_EQSMRCA2CTRL_RCAON__M 0x1
12683#define VSB_TOP_EQSMRCA2CTRL_RCAON__PRE 0x1
12684
12685#define VSB_TOP_EQSMRCA2CTRL_DFEON__B 1
12686#define VSB_TOP_EQSMRCA2CTRL_DFEON__W 1
12687#define VSB_TOP_EQSMRCA2CTRL_DFEON__M 0x2
12688#define VSB_TOP_EQSMRCA2CTRL_DFEON__PRE 0x2
12689
12690#define VSB_TOP_EQSMRCA2CTRL_DDMEN1__B 2
12691#define VSB_TOP_EQSMRCA2CTRL_DDMEN1__W 1
12692#define VSB_TOP_EQSMRCA2CTRL_DDMEN1__M 0x4
12693#define VSB_TOP_EQSMRCA2CTRL_DDMEN1__PRE 0x0
12694
12695#define VSB_TOP_EQSMRCA2CTRL_DDMEN2__B 3
12696#define VSB_TOP_EQSMRCA2CTRL_DDMEN2__W 1
12697#define VSB_TOP_EQSMRCA2CTRL_DDMEN2__M 0x8
12698#define VSB_TOP_EQSMRCA2CTRL_DDMEN2__PRE 0x0
12699
12700#define VSB_TOP_EQSMRCA2CTRL_DIGIAGCON__B 4
12701#define VSB_TOP_EQSMRCA2CTRL_DIGIAGCON__W 1
12702#define VSB_TOP_EQSMRCA2CTRL_DIGIAGCON__M 0x10
12703#define VSB_TOP_EQSMRCA2CTRL_DIGIAGCON__PRE 0x0
12704
12705#define VSB_TOP_EQSMRCA2CTRL_PARAINITEN__B 5
12706#define VSB_TOP_EQSMRCA2CTRL_PARAINITEN__W 1
12707#define VSB_TOP_EQSMRCA2CTRL_PARAINITEN__M 0x20
12708#define VSB_TOP_EQSMRCA2CTRL_PARAINITEN__PRE 0x0
12709
12710#define VSB_TOP_EQSMRCA2CTRL_TIMEOUTFRMCNTEN__B 6
12711#define VSB_TOP_EQSMRCA2CTRL_TIMEOUTFRMCNTEN__W 1
12712#define VSB_TOP_EQSMRCA2CTRL_TIMEOUTFRMCNTEN__M 0x40
12713#define VSB_TOP_EQSMRCA2CTRL_TIMEOUTFRMCNTEN__PRE 0x0
12714
12715#define VSB_TOP_EQSMDDM1CTRL__A 0x1C10030
12716#define VSB_TOP_EQSMDDM1CTRL__W 7
12717#define VSB_TOP_EQSMDDM1CTRL__M 0x7F
12718#define VSB_TOP_EQSMDDM1CTRL__PRE 0x6
12719
12720#define VSB_TOP_EQSMDDM1CTRL_RCAON__B 0
12721#define VSB_TOP_EQSMDDM1CTRL_RCAON__W 1
12722#define VSB_TOP_EQSMDDM1CTRL_RCAON__M 0x1
12723#define VSB_TOP_EQSMDDM1CTRL_RCAON__PRE 0x0
12724
12725#define VSB_TOP_EQSMDDM1CTRL_DFEON__B 1
12726#define VSB_TOP_EQSMDDM1CTRL_DFEON__W 1
12727#define VSB_TOP_EQSMDDM1CTRL_DFEON__M 0x2
12728#define VSB_TOP_EQSMDDM1CTRL_DFEON__PRE 0x2
12729
12730#define VSB_TOP_EQSMDDM1CTRL_DDMEN1__B 2
12731#define VSB_TOP_EQSMDDM1CTRL_DDMEN1__W 1
12732#define VSB_TOP_EQSMDDM1CTRL_DDMEN1__M 0x4
12733#define VSB_TOP_EQSMDDM1CTRL_DDMEN1__PRE 0x4
12734
12735#define VSB_TOP_EQSMDDM1CTRL_DDMEN2__B 3
12736#define VSB_TOP_EQSMDDM1CTRL_DDMEN2__W 1
12737#define VSB_TOP_EQSMDDM1CTRL_DDMEN2__M 0x8
12738#define VSB_TOP_EQSMDDM1CTRL_DDMEN2__PRE 0x0
12739
12740#define VSB_TOP_EQSMDDM1CTRL_DIGIAGCON__B 4
12741#define VSB_TOP_EQSMDDM1CTRL_DIGIAGCON__W 1
12742#define VSB_TOP_EQSMDDM1CTRL_DIGIAGCON__M 0x10
12743#define VSB_TOP_EQSMDDM1CTRL_DIGIAGCON__PRE 0x0
12744
12745#define VSB_TOP_EQSMDDM1CTRL_PARAINITEN__B 5
12746#define VSB_TOP_EQSMDDM1CTRL_PARAINITEN__W 1
12747#define VSB_TOP_EQSMDDM1CTRL_PARAINITEN__M 0x20
12748#define VSB_TOP_EQSMDDM1CTRL_PARAINITEN__PRE 0x0
12749
12750#define VSB_TOP_EQSMDDM1CTRL_TIMEOUTFRMCNTEN__B 6
12751#define VSB_TOP_EQSMDDM1CTRL_TIMEOUTFRMCNTEN__W 1
12752#define VSB_TOP_EQSMDDM1CTRL_TIMEOUTFRMCNTEN__M 0x40
12753#define VSB_TOP_EQSMDDM1CTRL_TIMEOUTFRMCNTEN__PRE 0x0
12754
12755#define VSB_TOP_EQSMDDM2CTRL__A 0x1C10031
12756#define VSB_TOP_EQSMDDM2CTRL__W 7
12757#define VSB_TOP_EQSMDDM2CTRL__M 0x7F
12758#define VSB_TOP_EQSMDDM2CTRL__PRE 0x1E
12759
12760#define VSB_TOP_EQSMDDM2CTRL_RCAON__B 0
12761#define VSB_TOP_EQSMDDM2CTRL_RCAON__W 1
12762#define VSB_TOP_EQSMDDM2CTRL_RCAON__M 0x1
12763#define VSB_TOP_EQSMDDM2CTRL_RCAON__PRE 0x0
12764
12765#define VSB_TOP_EQSMDDM2CTRL_DFEON__B 1
12766#define VSB_TOP_EQSMDDM2CTRL_DFEON__W 1
12767#define VSB_TOP_EQSMDDM2CTRL_DFEON__M 0x2
12768#define VSB_TOP_EQSMDDM2CTRL_DFEON__PRE 0x2
12769
12770#define VSB_TOP_EQSMDDM2CTRL_DDMEN1__B 2
12771#define VSB_TOP_EQSMDDM2CTRL_DDMEN1__W 1
12772#define VSB_TOP_EQSMDDM2CTRL_DDMEN1__M 0x4
12773#define VSB_TOP_EQSMDDM2CTRL_DDMEN1__PRE 0x4
12774
12775#define VSB_TOP_EQSMDDM2CTRL_DDMEN2__B 3
12776#define VSB_TOP_EQSMDDM2CTRL_DDMEN2__W 1
12777#define VSB_TOP_EQSMDDM2CTRL_DDMEN2__M 0x8
12778#define VSB_TOP_EQSMDDM2CTRL_DDMEN2__PRE 0x8
12779
12780#define VSB_TOP_EQSMDDM2CTRL_DIGIAGCON__B 4
12781#define VSB_TOP_EQSMDDM2CTRL_DIGIAGCON__W 1
12782#define VSB_TOP_EQSMDDM2CTRL_DIGIAGCON__M 0x10
12783#define VSB_TOP_EQSMDDM2CTRL_DIGIAGCON__PRE 0x10
12784
12785#define VSB_TOP_EQSMDDM2CTRL_PARAINITEN__B 5
12786#define VSB_TOP_EQSMDDM2CTRL_PARAINITEN__W 1
12787#define VSB_TOP_EQSMDDM2CTRL_PARAINITEN__M 0x20
12788#define VSB_TOP_EQSMDDM2CTRL_PARAINITEN__PRE 0x0
12789
12790#define VSB_TOP_EQSMDDM2CTRL_TIMEOUTFRMCNTEN__B 6
12791#define VSB_TOP_EQSMDDM2CTRL_TIMEOUTFRMCNTEN__W 1
12792#define VSB_TOP_EQSMDDM2CTRL_TIMEOUTFRMCNTEN__M 0x40
12793#define VSB_TOP_EQSMDDM2CTRL_TIMEOUTFRMCNTEN__PRE 0x0
12794
12795#define VSB_TOP_SYSSMRSTCTRL__A 0x1C10032
12796#define VSB_TOP_SYSSMRSTCTRL__W 11
12797#define VSB_TOP_SYSSMRSTCTRL__M 0x7FF
12798#define VSB_TOP_SYSSMRSTCTRL__PRE 0x7F9
12799
12800#define VSB_TOP_SYSSMRSTCTRL_RSTCTCAL__B 0
12801#define VSB_TOP_SYSSMRSTCTRL_RSTCTCAL__W 1
12802#define VSB_TOP_SYSSMRSTCTRL_RSTCTCAL__M 0x1
12803#define VSB_TOP_SYSSMRSTCTRL_RSTCTCAL__PRE 0x1
12804
12805#define VSB_TOP_SYSSMRSTCTRL_CTCALEN__B 1
12806#define VSB_TOP_SYSSMRSTCTRL_CTCALEN__W 1
12807#define VSB_TOP_SYSSMRSTCTRL_CTCALEN__M 0x2
12808#define VSB_TOP_SYSSMRSTCTRL_CTCALEN__PRE 0x0
12809
12810#define VSB_TOP_SYSSMRSTCTRL_STARTTRN__B 2
12811#define VSB_TOP_SYSSMRSTCTRL_STARTTRN__W 1
12812#define VSB_TOP_SYSSMRSTCTRL_STARTTRN__M 0x4
12813#define VSB_TOP_SYSSMRSTCTRL_STARTTRN__PRE 0x0
12814
12815#define VSB_TOP_SYSSMRSTCTRL_RSTFRMSYNCDET__B 3
12816#define VSB_TOP_SYSSMRSTCTRL_RSTFRMSYNCDET__W 1
12817#define VSB_TOP_SYSSMRSTCTRL_RSTFRMSYNCDET__M 0x8
12818#define VSB_TOP_SYSSMRSTCTRL_RSTFRMSYNCDET__PRE 0x8
12819
12820#define VSB_TOP_SYSSMRSTCTRL_RSTCYDET__B 4
12821#define VSB_TOP_SYSSMRSTCTRL_RSTCYDET__W 1
12822#define VSB_TOP_SYSSMRSTCTRL_RSTCYDET__M 0x10
12823#define VSB_TOP_SYSSMRSTCTRL_RSTCYDET__PRE 0x10
12824
12825#define VSB_TOP_SYSSMRSTCTRL_RSTDCRMV__B 5
12826#define VSB_TOP_SYSSMRSTCTRL_RSTDCRMV__W 1
12827#define VSB_TOP_SYSSMRSTCTRL_RSTDCRMV__M 0x20
12828#define VSB_TOP_SYSSMRSTCTRL_RSTDCRMV__PRE 0x20
12829
12830#define VSB_TOP_SYSSMRSTCTRL_RSTEQSIG__B 6
12831#define VSB_TOP_SYSSMRSTCTRL_RSTEQSIG__W 1
12832#define VSB_TOP_SYSSMRSTCTRL_RSTEQSIG__M 0x40
12833#define VSB_TOP_SYSSMRSTCTRL_RSTEQSIG__PRE 0x40
12834
12835#define VSB_TOP_SYSSMRSTCTRL_CKFRZ__B 7
12836#define VSB_TOP_SYSSMRSTCTRL_CKFRZ__W 1
12837#define VSB_TOP_SYSSMRSTCTRL_CKFRZ__M 0x80
12838#define VSB_TOP_SYSSMRSTCTRL_CKFRZ__PRE 0x80
12839
12840#define VSB_TOP_SYSSMRSTCTRL_CKBWSW__B 8
12841#define VSB_TOP_SYSSMRSTCTRL_CKBWSW__W 1
12842#define VSB_TOP_SYSSMRSTCTRL_CKBWSW__M 0x100
12843#define VSB_TOP_SYSSMRSTCTRL_CKBWSW__PRE 0x100
12844
12845#define VSB_TOP_SYSSMRSTCTRL_NCOBWSW__B 9
12846#define VSB_TOP_SYSSMRSTCTRL_NCOBWSW__W 1
12847#define VSB_TOP_SYSSMRSTCTRL_NCOBWSW__M 0x200
12848#define VSB_TOP_SYSSMRSTCTRL_NCOBWSW__PRE 0x200
12849
12850#define VSB_TOP_SYSSMRSTCTRL_NCOTIMEOUTCNTEN__B 10
12851#define VSB_TOP_SYSSMRSTCTRL_NCOTIMEOUTCNTEN__W 1
12852#define VSB_TOP_SYSSMRSTCTRL_NCOTIMEOUTCNTEN__M 0x400
12853#define VSB_TOP_SYSSMRSTCTRL_NCOTIMEOUTCNTEN__PRE 0x400
12854
12855#define VSB_TOP_SYSSMCYCTRL__A 0x1C10033
12856#define VSB_TOP_SYSSMCYCTRL__W 11
12857#define VSB_TOP_SYSSMCYCTRL__M 0x7FF
12858#define VSB_TOP_SYSSMCYCTRL__PRE 0x4E9
12859
12860#define VSB_TOP_SYSSMCYCTRL_RSTCTCAL__B 0
12861#define VSB_TOP_SYSSMCYCTRL_RSTCTCAL__W 1
12862#define VSB_TOP_SYSSMCYCTRL_RSTCTCAL__M 0x1
12863#define VSB_TOP_SYSSMCYCTRL_RSTCTCAL__PRE 0x1
12864
12865#define VSB_TOP_SYSSMCYCTRL_CTCALEN__B 1
12866#define VSB_TOP_SYSSMCYCTRL_CTCALEN__W 1
12867#define VSB_TOP_SYSSMCYCTRL_CTCALEN__M 0x2
12868#define VSB_TOP_SYSSMCYCTRL_CTCALEN__PRE 0x0
12869
12870#define VSB_TOP_SYSSMCYCTRL_STARTTRN__B 2
12871#define VSB_TOP_SYSSMCYCTRL_STARTTRN__W 1
12872#define VSB_TOP_SYSSMCYCTRL_STARTTRN__M 0x4
12873#define VSB_TOP_SYSSMCYCTRL_STARTTRN__PRE 0x0
12874
12875#define VSB_TOP_SYSSMCYCTRL_RSTFRMSYNCDET__B 3
12876#define VSB_TOP_SYSSMCYCTRL_RSTFRMSYNCDET__W 1
12877#define VSB_TOP_SYSSMCYCTRL_RSTFRMSYNCDET__M 0x8
12878#define VSB_TOP_SYSSMCYCTRL_RSTFRMSYNCDET__PRE 0x8
12879
12880#define VSB_TOP_SYSSMCYCTRL_RSTCYDET__B 4
12881#define VSB_TOP_SYSSMCYCTRL_RSTCYDET__W 1
12882#define VSB_TOP_SYSSMCYCTRL_RSTCYDET__M 0x10
12883#define VSB_TOP_SYSSMCYCTRL_RSTCYDET__PRE 0x0
12884
12885#define VSB_TOP_SYSSMCYCTRL_RSTDCRMV__B 5
12886#define VSB_TOP_SYSSMCYCTRL_RSTDCRMV__W 1
12887#define VSB_TOP_SYSSMCYCTRL_RSTDCRMV__M 0x20
12888#define VSB_TOP_SYSSMCYCTRL_RSTDCRMV__PRE 0x20
12889
12890#define VSB_TOP_SYSSMCYCTRL_RSTEQSIG__B 6
12891#define VSB_TOP_SYSSMCYCTRL_RSTEQSIG__W 1
12892#define VSB_TOP_SYSSMCYCTRL_RSTEQSIG__M 0x40
12893#define VSB_TOP_SYSSMCYCTRL_RSTEQSIG__PRE 0x40
12894
12895#define VSB_TOP_SYSSMCYCTRL_CKFRZ__B 7
12896#define VSB_TOP_SYSSMCYCTRL_CKFRZ__W 1
12897#define VSB_TOP_SYSSMCYCTRL_CKFRZ__M 0x80
12898#define VSB_TOP_SYSSMCYCTRL_CKFRZ__PRE 0x80
12899
12900#define VSB_TOP_SYSSMCYCTRL_CKBWSW__B 8
12901#define VSB_TOP_SYSSMCYCTRL_CKBWSW__W 1
12902#define VSB_TOP_SYSSMCYCTRL_CKBWSW__M 0x100
12903#define VSB_TOP_SYSSMCYCTRL_CKBWSW__PRE 0x0
12904
12905#define VSB_TOP_SYSSMCYCTRL_NCOBWSW__B 9
12906#define VSB_TOP_SYSSMCYCTRL_NCOBWSW__W 1
12907#define VSB_TOP_SYSSMCYCTRL_NCOBWSW__M 0x200
12908#define VSB_TOP_SYSSMCYCTRL_NCOBWSW__PRE 0x0
12909
12910#define VSB_TOP_SYSSMCYCTRL_NCOTIMEOUTCNTEN__B 10
12911#define VSB_TOP_SYSSMCYCTRL_NCOTIMEOUTCNTEN__W 1
12912#define VSB_TOP_SYSSMCYCTRL_NCOTIMEOUTCNTEN__M 0x400
12913#define VSB_TOP_SYSSMCYCTRL_NCOTIMEOUTCNTEN__PRE 0x400
12914
12915#define VSB_TOP_SYSSMTRNCTRL__A 0x1C10034
12916#define VSB_TOP_SYSSMTRNCTRL__W 11
12917#define VSB_TOP_SYSSMTRNCTRL__M 0x7FF
12918#define VSB_TOP_SYSSMTRNCTRL__PRE 0x204
12919
12920#define VSB_TOP_SYSSMTRNCTRL_RSTCTCAL__B 0
12921#define VSB_TOP_SYSSMTRNCTRL_RSTCTCAL__W 1
12922#define VSB_TOP_SYSSMTRNCTRL_RSTCTCAL__M 0x1
12923#define VSB_TOP_SYSSMTRNCTRL_RSTCTCAL__PRE 0x0
12924
12925#define VSB_TOP_SYSSMTRNCTRL_CTCALEN__B 1
12926#define VSB_TOP_SYSSMTRNCTRL_CTCALEN__W 1
12927#define VSB_TOP_SYSSMTRNCTRL_CTCALEN__M 0x2
12928#define VSB_TOP_SYSSMTRNCTRL_CTCALEN__PRE 0x0
12929
12930#define VSB_TOP_SYSSMTRNCTRL_STARTTRN__B 2
12931#define VSB_TOP_SYSSMTRNCTRL_STARTTRN__W 1
12932#define VSB_TOP_SYSSMTRNCTRL_STARTTRN__M 0x4
12933#define VSB_TOP_SYSSMTRNCTRL_STARTTRN__PRE 0x4
12934
12935#define VSB_TOP_SYSSMTRNCTRL_RSTFRMSYNCDET__B 3
12936#define VSB_TOP_SYSSMTRNCTRL_RSTFRMSYNCDET__W 1
12937#define VSB_TOP_SYSSMTRNCTRL_RSTFRMSYNCDET__M 0x8
12938#define VSB_TOP_SYSSMTRNCTRL_RSTFRMSYNCDET__PRE 0x0
12939
12940#define VSB_TOP_SYSSMTRNCTRL_RSTCYDET__B 4
12941#define VSB_TOP_SYSSMTRNCTRL_RSTCYDET__W 1
12942#define VSB_TOP_SYSSMTRNCTRL_RSTCYDET__M 0x10
12943#define VSB_TOP_SYSSMTRNCTRL_RSTCYDET__PRE 0x0
12944
12945#define VSB_TOP_SYSSMTRNCTRL_RSTDCRMV__B 5
12946#define VSB_TOP_SYSSMTRNCTRL_RSTDCRMV__W 1
12947#define VSB_TOP_SYSSMTRNCTRL_RSTDCRMV__M 0x20
12948#define VSB_TOP_SYSSMTRNCTRL_RSTDCRMV__PRE 0x0
12949
12950#define VSB_TOP_SYSSMTRNCTRL_RSTEQSIG__B 6
12951#define VSB_TOP_SYSSMTRNCTRL_RSTEQSIG__W 1
12952#define VSB_TOP_SYSSMTRNCTRL_RSTEQSIG__M 0x40
12953#define VSB_TOP_SYSSMTRNCTRL_RSTEQSIG__PRE 0x0
12954
12955#define VSB_TOP_SYSSMTRNCTRL_CKFRZ__B 7
12956#define VSB_TOP_SYSSMTRNCTRL_CKFRZ__W 1
12957#define VSB_TOP_SYSSMTRNCTRL_CKFRZ__M 0x80
12958#define VSB_TOP_SYSSMTRNCTRL_CKFRZ__PRE 0x0
12959
12960#define VSB_TOP_SYSSMTRNCTRL_CKBWSW__B 8
12961#define VSB_TOP_SYSSMTRNCTRL_CKBWSW__W 1
12962#define VSB_TOP_SYSSMTRNCTRL_CKBWSW__M 0x100
12963#define VSB_TOP_SYSSMTRNCTRL_CKBWSW__PRE 0x0
12964
12965#define VSB_TOP_SYSSMTRNCTRL_NCOBWSW__B 9
12966#define VSB_TOP_SYSSMTRNCTRL_NCOBWSW__W 1
12967#define VSB_TOP_SYSSMTRNCTRL_NCOBWSW__M 0x200
12968#define VSB_TOP_SYSSMTRNCTRL_NCOBWSW__PRE 0x200
12969
12970#define VSB_TOP_SYSSMTRNCTRL_NCOTIMEOUTCNTEN__B 10
12971#define VSB_TOP_SYSSMTRNCTRL_NCOTIMEOUTCNTEN__W 1
12972#define VSB_TOP_SYSSMTRNCTRL_NCOTIMEOUTCNTEN__M 0x400
12973#define VSB_TOP_SYSSMTRNCTRL_NCOTIMEOUTCNTEN__PRE 0x0
12974
12975#define VSB_TOP_SYSSMEQCTRL__A 0x1C10035
12976#define VSB_TOP_SYSSMEQCTRL__W 11
12977#define VSB_TOP_SYSSMEQCTRL__M 0x7FF
12978#define VSB_TOP_SYSSMEQCTRL__PRE 0x304
12979
12980#define VSB_TOP_SYSSMEQCTRL_RSTCTCAL__B 0
12981#define VSB_TOP_SYSSMEQCTRL_RSTCTCAL__W 1
12982#define VSB_TOP_SYSSMEQCTRL_RSTCTCAL__M 0x1
12983#define VSB_TOP_SYSSMEQCTRL_RSTCTCAL__PRE 0x0
12984
12985#define VSB_TOP_SYSSMEQCTRL_CTCALEN__B 1
12986#define VSB_TOP_SYSSMEQCTRL_CTCALEN__W 1
12987#define VSB_TOP_SYSSMEQCTRL_CTCALEN__M 0x2
12988#define VSB_TOP_SYSSMEQCTRL_CTCALEN__PRE 0x0
12989
12990#define VSB_TOP_SYSSMEQCTRL_STARTTRN__B 2
12991#define VSB_TOP_SYSSMEQCTRL_STARTTRN__W 1
12992#define VSB_TOP_SYSSMEQCTRL_STARTTRN__M 0x4
12993#define VSB_TOP_SYSSMEQCTRL_STARTTRN__PRE 0x4
12994
12995#define VSB_TOP_SYSSMEQCTRL_RSTFRMSYNCDET__B 3
12996#define VSB_TOP_SYSSMEQCTRL_RSTFRMSYNCDET__W 1
12997#define VSB_TOP_SYSSMEQCTRL_RSTFRMSYNCDET__M 0x8
12998#define VSB_TOP_SYSSMEQCTRL_RSTFRMSYNCDET__PRE 0x0
12999
13000#define VSB_TOP_SYSSMEQCTRL_RSTCYDET__B 4
13001#define VSB_TOP_SYSSMEQCTRL_RSTCYDET__W 1
13002#define VSB_TOP_SYSSMEQCTRL_RSTCYDET__M 0x10
13003#define VSB_TOP_SYSSMEQCTRL_RSTCYDET__PRE 0x0
13004
13005#define VSB_TOP_SYSSMEQCTRL_RSTDCRMV__B 5
13006#define VSB_TOP_SYSSMEQCTRL_RSTDCRMV__W 1
13007#define VSB_TOP_SYSSMEQCTRL_RSTDCRMV__M 0x20
13008#define VSB_TOP_SYSSMEQCTRL_RSTDCRMV__PRE 0x0
13009
13010#define VSB_TOP_SYSSMEQCTRL_RSTEQSIG__B 6
13011#define VSB_TOP_SYSSMEQCTRL_RSTEQSIG__W 1
13012#define VSB_TOP_SYSSMEQCTRL_RSTEQSIG__M 0x40
13013#define VSB_TOP_SYSSMEQCTRL_RSTEQSIG__PRE 0x0
13014
13015#define VSB_TOP_SYSSMEQCTRL_CKFRZ__B 7
13016#define VSB_TOP_SYSSMEQCTRL_CKFRZ__W 1
13017#define VSB_TOP_SYSSMEQCTRL_CKFRZ__M 0x80
13018#define VSB_TOP_SYSSMEQCTRL_CKFRZ__PRE 0x0
13019
13020#define VSB_TOP_SYSSMEQCTRL_CKBWSW__B 8
13021#define VSB_TOP_SYSSMEQCTRL_CKBWSW__W 1
13022#define VSB_TOP_SYSSMEQCTRL_CKBWSW__M 0x100
13023#define VSB_TOP_SYSSMEQCTRL_CKBWSW__PRE 0x100
13024
13025#define VSB_TOP_SYSSMEQCTRL_NCOBWSW__B 9
13026#define VSB_TOP_SYSSMEQCTRL_NCOBWSW__W 1
13027#define VSB_TOP_SYSSMEQCTRL_NCOBWSW__M 0x200
13028#define VSB_TOP_SYSSMEQCTRL_NCOBWSW__PRE 0x200
13029
13030#define VSB_TOP_SYSSMEQCTRL_NCOTIMEOUTCNTEN__B 10
13031#define VSB_TOP_SYSSMEQCTRL_NCOTIMEOUTCNTEN__W 1
13032#define VSB_TOP_SYSSMEQCTRL_NCOTIMEOUTCNTEN__M 0x400
13033#define VSB_TOP_SYSSMEQCTRL_NCOTIMEOUTCNTEN__PRE 0x0
13034
13035#define VSB_TOP_SYSSMAGCCTRL__A 0x1C10036
13036#define VSB_TOP_SYSSMAGCCTRL__W 11
13037#define VSB_TOP_SYSSMAGCCTRL__M 0x7FF
13038#define VSB_TOP_SYSSMAGCCTRL__PRE 0xF9
13039
13040#define VSB_TOP_SYSSMAGCCTRL_RSTCTCAL__B 0
13041#define VSB_TOP_SYSSMAGCCTRL_RSTCTCAL__W 1
13042#define VSB_TOP_SYSSMAGCCTRL_RSTCTCAL__M 0x1
13043#define VSB_TOP_SYSSMAGCCTRL_RSTCTCAL__PRE 0x1
13044
13045#define VSB_TOP_SYSSMAGCCTRL_CTCALEN__B 1
13046#define VSB_TOP_SYSSMAGCCTRL_CTCALEN__W 1
13047#define VSB_TOP_SYSSMAGCCTRL_CTCALEN__M 0x2
13048#define VSB_TOP_SYSSMAGCCTRL_CTCALEN__PRE 0x0
13049
13050#define VSB_TOP_SYSSMAGCCTRL_STARTTRN__B 2
13051#define VSB_TOP_SYSSMAGCCTRL_STARTTRN__W 1
13052#define VSB_TOP_SYSSMAGCCTRL_STARTTRN__M 0x4
13053#define VSB_TOP_SYSSMAGCCTRL_STARTTRN__PRE 0x0
13054
13055#define VSB_TOP_SYSSMAGCCTRL_RSTFRMSYNCDET__B 3
13056#define VSB_TOP_SYSSMAGCCTRL_RSTFRMSYNCDET__W 1
13057#define VSB_TOP_SYSSMAGCCTRL_RSTFRMSYNCDET__M 0x8
13058#define VSB_TOP_SYSSMAGCCTRL_RSTFRMSYNCDET__PRE 0x8
13059
13060#define VSB_TOP_SYSSMAGCCTRL_RSTCYDET__B 4
13061#define VSB_TOP_SYSSMAGCCTRL_RSTCYDET__W 1
13062#define VSB_TOP_SYSSMAGCCTRL_RSTCYDET__M 0x10
13063#define VSB_TOP_SYSSMAGCCTRL_RSTCYDET__PRE 0x10
13064
13065#define VSB_TOP_SYSSMAGCCTRL_RSTDCRMV__B 5
13066#define VSB_TOP_SYSSMAGCCTRL_RSTDCRMV__W 1
13067#define VSB_TOP_SYSSMAGCCTRL_RSTDCRMV__M 0x20
13068#define VSB_TOP_SYSSMAGCCTRL_RSTDCRMV__PRE 0x20
13069
13070#define VSB_TOP_SYSSMAGCCTRL_RSTEQSIG__B 6
13071#define VSB_TOP_SYSSMAGCCTRL_RSTEQSIG__W 1
13072#define VSB_TOP_SYSSMAGCCTRL_RSTEQSIG__M 0x40
13073#define VSB_TOP_SYSSMAGCCTRL_RSTEQSIG__PRE 0x40
13074
13075#define VSB_TOP_SYSSMAGCCTRL_CKFRZ__B 7
13076#define VSB_TOP_SYSSMAGCCTRL_CKFRZ__W 1
13077#define VSB_TOP_SYSSMAGCCTRL_CKFRZ__M 0x80
13078#define VSB_TOP_SYSSMAGCCTRL_CKFRZ__PRE 0x80
13079
13080#define VSB_TOP_SYSSMAGCCTRL_CKBWSW__B 8
13081#define VSB_TOP_SYSSMAGCCTRL_CKBWSW__W 1
13082#define VSB_TOP_SYSSMAGCCTRL_CKBWSW__M 0x100
13083#define VSB_TOP_SYSSMAGCCTRL_CKBWSW__PRE 0x0
13084
13085#define VSB_TOP_SYSSMAGCCTRL_NCOBWSW__B 9
13086#define VSB_TOP_SYSSMAGCCTRL_NCOBWSW__W 1
13087#define VSB_TOP_SYSSMAGCCTRL_NCOBWSW__M 0x200
13088#define VSB_TOP_SYSSMAGCCTRL_NCOBWSW__PRE 0x0
13089
13090#define VSB_TOP_SYSSMAGCCTRL_NCOTIMEOUTCNTEN__B 10
13091#define VSB_TOP_SYSSMAGCCTRL_NCOTIMEOUTCNTEN__W 1
13092#define VSB_TOP_SYSSMAGCCTRL_NCOTIMEOUTCNTEN__M 0x400
13093#define VSB_TOP_SYSSMAGCCTRL_NCOTIMEOUTCNTEN__PRE 0x0
13094
13095#define VSB_TOP_SYSSMCTCTRL__A 0x1C10037
13096#define VSB_TOP_SYSSMCTCTRL__W 11
13097#define VSB_TOP_SYSSMCTCTRL__M 0x7FF
13098#define VSB_TOP_SYSSMCTCTRL__PRE 0x4A
13099
13100#define VSB_TOP_SYSSMCTCTRL_RSTCTCAL__B 0
13101#define VSB_TOP_SYSSMCTCTRL_RSTCTCAL__W 1
13102#define VSB_TOP_SYSSMCTCTRL_RSTCTCAL__M 0x1
13103#define VSB_TOP_SYSSMCTCTRL_RSTCTCAL__PRE 0x0
13104
13105#define VSB_TOP_SYSSMCTCTRL_CTCALEN__B 1
13106#define VSB_TOP_SYSSMCTCTRL_CTCALEN__W 1
13107#define VSB_TOP_SYSSMCTCTRL_CTCALEN__M 0x2
13108#define VSB_TOP_SYSSMCTCTRL_CTCALEN__PRE 0x2
13109
13110#define VSB_TOP_SYSSMCTCTRL_STARTTRN__B 2
13111#define VSB_TOP_SYSSMCTCTRL_STARTTRN__W 1
13112#define VSB_TOP_SYSSMCTCTRL_STARTTRN__M 0x4
13113#define VSB_TOP_SYSSMCTCTRL_STARTTRN__PRE 0x0
13114
13115#define VSB_TOP_SYSSMCTCTRL_RSTFRMSYNCDET__B 3
13116#define VSB_TOP_SYSSMCTCTRL_RSTFRMSYNCDET__W 1
13117#define VSB_TOP_SYSSMCTCTRL_RSTFRMSYNCDET__M 0x8
13118#define VSB_TOP_SYSSMCTCTRL_RSTFRMSYNCDET__PRE 0x8
13119
13120#define VSB_TOP_SYSSMCTCTRL_RSTCYDET__B 4
13121#define VSB_TOP_SYSSMCTCTRL_RSTCYDET__W 1
13122#define VSB_TOP_SYSSMCTCTRL_RSTCYDET__M 0x10
13123#define VSB_TOP_SYSSMCTCTRL_RSTCYDET__PRE 0x0
13124
13125#define VSB_TOP_SYSSMCTCTRL_RSTDCRMV__B 5
13126#define VSB_TOP_SYSSMCTCTRL_RSTDCRMV__W 1
13127#define VSB_TOP_SYSSMCTCTRL_RSTDCRMV__M 0x20
13128#define VSB_TOP_SYSSMCTCTRL_RSTDCRMV__PRE 0x0
13129
13130#define VSB_TOP_SYSSMCTCTRL_RSTEQSIG__B 6
13131#define VSB_TOP_SYSSMCTCTRL_RSTEQSIG__W 1
13132#define VSB_TOP_SYSSMCTCTRL_RSTEQSIG__M 0x40
13133#define VSB_TOP_SYSSMCTCTRL_RSTEQSIG__PRE 0x40
13134
13135#define VSB_TOP_SYSSMCTCTRL_CKFRZ__B 7
13136#define VSB_TOP_SYSSMCTCTRL_CKFRZ__W 1
13137#define VSB_TOP_SYSSMCTCTRL_CKFRZ__M 0x80
13138#define VSB_TOP_SYSSMCTCTRL_CKFRZ__PRE 0x0
13139
13140#define VSB_TOP_SYSSMCTCTRL_CKBWSW__B 8
13141#define VSB_TOP_SYSSMCTCTRL_CKBWSW__W 1
13142#define VSB_TOP_SYSSMCTCTRL_CKBWSW__M 0x100
13143#define VSB_TOP_SYSSMCTCTRL_CKBWSW__PRE 0x0
13144
13145#define VSB_TOP_SYSSMCTCTRL_NCOBWSW__B 9
13146#define VSB_TOP_SYSSMCTCTRL_NCOBWSW__W 1
13147#define VSB_TOP_SYSSMCTCTRL_NCOBWSW__M 0x200
13148#define VSB_TOP_SYSSMCTCTRL_NCOBWSW__PRE 0x0
13149
13150#define VSB_TOP_SYSSMCTCTRL_NCOTIMEOUTCNTEN__B 10
13151#define VSB_TOP_SYSSMCTCTRL_NCOTIMEOUTCNTEN__W 1
13152#define VSB_TOP_SYSSMCTCTRL_NCOTIMEOUTCNTEN__M 0x400
13153#define VSB_TOP_SYSSMCTCTRL_NCOTIMEOUTCNTEN__PRE 0x0
13154
13155#define VSB_TOP_EQCTRL__A 0x1C10038
13156#define VSB_TOP_EQCTRL__W 10
13157#define VSB_TOP_EQCTRL__M 0x3FF
13158#define VSB_TOP_EQCTRL__PRE 0x6
13159
13160#define VSB_TOP_EQCTRL_STASSIGNEN__B 0
13161#define VSB_TOP_EQCTRL_STASSIGNEN__W 1
13162#define VSB_TOP_EQCTRL_STASSIGNEN__M 0x1
13163#define VSB_TOP_EQCTRL_STASSIGNEN__PRE 0x0
13164
13165#define VSB_TOP_EQCTRL_ORCANCMAEN__B 1
13166#define VSB_TOP_EQCTRL_ORCANCMAEN__W 1
13167#define VSB_TOP_EQCTRL_ORCANCMAEN__M 0x2
13168#define VSB_TOP_EQCTRL_ORCANCMAEN__PRE 0x2
13169
13170#define VSB_TOP_EQCTRL_ODAGCGO__B 2
13171#define VSB_TOP_EQCTRL_ODAGCGO__W 1
13172#define VSB_TOP_EQCTRL_ODAGCGO__M 0x4
13173#define VSB_TOP_EQCTRL_ODAGCGO__PRE 0x4
13174
13175#define VSB_TOP_EQCTRL_OPTGAIN__B 3
13176#define VSB_TOP_EQCTRL_OPTGAIN__W 3
13177#define VSB_TOP_EQCTRL_OPTGAIN__M 0x38
13178#define VSB_TOP_EQCTRL_OPTGAIN__PRE 0x0
13179
13180#define VSB_TOP_EQCTRL_TAPRAMWRTEN__B 6
13181#define VSB_TOP_EQCTRL_TAPRAMWRTEN__W 1
13182#define VSB_TOP_EQCTRL_TAPRAMWRTEN__M 0x40
13183#define VSB_TOP_EQCTRL_TAPRAMWRTEN__PRE 0x0
13184
13185#define VSB_TOP_EQCTRL_CMAGAIN__B 7
13186#define VSB_TOP_EQCTRL_CMAGAIN__W 3
13187#define VSB_TOP_EQCTRL_CMAGAIN__M 0x380
13188#define VSB_TOP_EQCTRL_CMAGAIN__PRE 0x0
13189
13190#define VSB_TOP_PREEQAGCCTRL__A 0x1C10039
13191#define VSB_TOP_PREEQAGCCTRL__W 5
13192#define VSB_TOP_PREEQAGCCTRL__M 0x1F
13193#define VSB_TOP_PREEQAGCCTRL__PRE 0x10
13194
13195#define VSB_TOP_PREEQAGCCTRL_PREEQAGCBWSEL__B 0
13196#define VSB_TOP_PREEQAGCCTRL_PREEQAGCBWSEL__W 4
13197#define VSB_TOP_PREEQAGCCTRL_PREEQAGCBWSEL__M 0xF
13198#define VSB_TOP_PREEQAGCCTRL_PREEQAGCBWSEL__PRE 0x0
13199
13200#define VSB_TOP_PREEQAGCCTRL_PREEQAGCFRZ__B 4
13201#define VSB_TOP_PREEQAGCCTRL_PREEQAGCFRZ__W 1
13202#define VSB_TOP_PREEQAGCCTRL_PREEQAGCFRZ__M 0x10
13203#define VSB_TOP_PREEQAGCCTRL_PREEQAGCFRZ__PRE 0x10
13204
13205#define VSB_TOP_PREEQAGCPWRREFLVLHI__A 0x1C1003A
13206#define VSB_TOP_PREEQAGCPWRREFLVLHI__W 8
13207#define VSB_TOP_PREEQAGCPWRREFLVLHI__M 0xFF
13208#define VSB_TOP_PREEQAGCPWRREFLVLHI__PRE 0x0
13209
13210#define VSB_TOP_PREEQAGCPWRREFLVLLO__A 0x1C1003B
13211#define VSB_TOP_PREEQAGCPWRREFLVLLO__W 16
13212#define VSB_TOP_PREEQAGCPWRREFLVLLO__M 0xFFFF
13213#define VSB_TOP_PREEQAGCPWRREFLVLLO__PRE 0x1D66
13214
13215#define VSB_TOP_CORINGSEL__A 0x1C1003C
13216#define VSB_TOP_CORINGSEL__W 8
13217#define VSB_TOP_CORINGSEL__M 0xFF
13218#define VSB_TOP_CORINGSEL__PRE 0x3
13219#define VSB_TOP_BEDETCTRL__A 0x1C1003D
13220#define VSB_TOP_BEDETCTRL__W 9
13221#define VSB_TOP_BEDETCTRL__M 0x1FF
13222#define VSB_TOP_BEDETCTRL__PRE 0x145
13223
13224#define VSB_TOP_BEDETCTRL_MIXRATIO__B 0
13225#define VSB_TOP_BEDETCTRL_MIXRATIO__W 3
13226#define VSB_TOP_BEDETCTRL_MIXRATIO__M 0x7
13227#define VSB_TOP_BEDETCTRL_MIXRATIO__PRE 0x5
13228
13229#define VSB_TOP_BEDETCTRL_CYOFFSEL__B 3
13230#define VSB_TOP_BEDETCTRL_CYOFFSEL__W 1
13231#define VSB_TOP_BEDETCTRL_CYOFFSEL__M 0x8
13232#define VSB_TOP_BEDETCTRL_CYOFFSEL__PRE 0x0
13233
13234#define VSB_TOP_BEDETCTRL_DATAOFFSEL__B 4
13235#define VSB_TOP_BEDETCTRL_DATAOFFSEL__W 1
13236#define VSB_TOP_BEDETCTRL_DATAOFFSEL__M 0x10
13237#define VSB_TOP_BEDETCTRL_DATAOFFSEL__PRE 0x0
13238
13239#define VSB_TOP_BEDETCTRL_BYPASS_DSQ__B 5
13240#define VSB_TOP_BEDETCTRL_BYPASS_DSQ__W 1
13241#define VSB_TOP_BEDETCTRL_BYPASS_DSQ__M 0x20
13242#define VSB_TOP_BEDETCTRL_BYPASS_DSQ__PRE 0x0
13243
13244#define VSB_TOP_BEDETCTRL_BYPASS_PSQ__B 6
13245#define VSB_TOP_BEDETCTRL_BYPASS_PSQ__W 1
13246#define VSB_TOP_BEDETCTRL_BYPASS_PSQ__M 0x40
13247#define VSB_TOP_BEDETCTRL_BYPASS_PSQ__PRE 0x40
13248
13249#define VSB_TOP_BEDETCTRL_BYPASS_CSQ__B 7
13250#define VSB_TOP_BEDETCTRL_BYPASS_CSQ__W 1
13251#define VSB_TOP_BEDETCTRL_BYPASS_CSQ__M 0x80
13252#define VSB_TOP_BEDETCTRL_BYPASS_CSQ__PRE 0x0
13253
13254#define VSB_TOP_BEDETCTRL_BYPASS_DMP__B 8
13255#define VSB_TOP_BEDETCTRL_BYPASS_DMP__W 1
13256#define VSB_TOP_BEDETCTRL_BYPASS_DMP__M 0x100
13257#define VSB_TOP_BEDETCTRL_BYPASS_DMP__PRE 0x100
13258
13259#define VSB_TOP_LBAGCREFLVL__A 0x1C1003E
13260#define VSB_TOP_LBAGCREFLVL__W 12
13261#define VSB_TOP_LBAGCREFLVL__M 0xFFF
13262#define VSB_TOP_LBAGCREFLVL__PRE 0x200
13263
13264#define VSB_TOP_UBAGCREFLVL__A 0x1C1003F
13265#define VSB_TOP_UBAGCREFLVL__W 12
13266#define VSB_TOP_UBAGCREFLVL__M 0xFFF
13267#define VSB_TOP_UBAGCREFLVL__PRE 0x400
13268
13269#define VSB_TOP_NOTCH1_BIN_NUM__A 0x1C10040
13270#define VSB_TOP_NOTCH1_BIN_NUM__W 11
13271#define VSB_TOP_NOTCH1_BIN_NUM__M 0x7FF
13272#define VSB_TOP_NOTCH1_BIN_NUM__PRE 0xB2
13273
13274#define VSB_TOP_NOTCH2_BIN_NUM__A 0x1C10041
13275#define VSB_TOP_NOTCH2_BIN_NUM__W 11
13276#define VSB_TOP_NOTCH2_BIN_NUM__M 0x7FF
13277#define VSB_TOP_NOTCH2_BIN_NUM__PRE 0x40B
13278
13279#define VSB_TOP_NOTCH_START_BIN_NUM__A 0x1C10042
13280#define VSB_TOP_NOTCH_START_BIN_NUM__W 11
13281#define VSB_TOP_NOTCH_START_BIN_NUM__M 0x7FF
13282#define VSB_TOP_NOTCH_START_BIN_NUM__PRE 0x7C0
13283
13284#define VSB_TOP_NOTCH_STOP_BIN_NUM__A 0x1C10043
13285#define VSB_TOP_NOTCH_STOP_BIN_NUM__W 11
13286#define VSB_TOP_NOTCH_STOP_BIN_NUM__M 0x7FF
13287#define VSB_TOP_NOTCH_STOP_BIN_NUM__PRE 0x43F
13288
13289#define VSB_TOP_NOTCH_TEST_DURATION__A 0x1C10044
13290#define VSB_TOP_NOTCH_TEST_DURATION__W 11
13291#define VSB_TOP_NOTCH_TEST_DURATION__M 0x7FF
13292#define VSB_TOP_NOTCH_TEST_DURATION__PRE 0x7FF
13293
13294#define VSB_TOP_RESULT_LARGE_PEAK_BIN__A 0x1C10045
13295#define VSB_TOP_RESULT_LARGE_PEAK_BIN__W 11
13296#define VSB_TOP_RESULT_LARGE_PEAK_BIN__M 0x7FF
13297#define VSB_TOP_RESULT_LARGE_PEAK_BIN__PRE 0x0
13298
13299#define VSB_TOP_RESULT_LARGE_PEAK_VALUE__A 0x1C10046
13300#define VSB_TOP_RESULT_LARGE_PEAK_VALUE__W 16
13301#define VSB_TOP_RESULT_LARGE_PEAK_VALUE__M 0xFFFF
13302#define VSB_TOP_RESULT_LARGE_PEAK_VALUE__PRE 0x0
13303
13304#define VSB_TOP_RESULT_SMALL_PEAK_BIN__A 0x1C10047
13305#define VSB_TOP_RESULT_SMALL_PEAK_BIN__W 11
13306#define VSB_TOP_RESULT_SMALL_PEAK_BIN__M 0x7FF
13307#define VSB_TOP_RESULT_SMALL_PEAK_BIN__PRE 0x0
13308
13309#define VSB_TOP_RESULT_SMALL_PEAK_VALUE__A 0x1C10048
13310#define VSB_TOP_RESULT_SMALL_PEAK_VALUE__W 16
13311#define VSB_TOP_RESULT_SMALL_PEAK_VALUE__M 0xFFFF
13312#define VSB_TOP_RESULT_SMALL_PEAK_VALUE__PRE 0x0
13313
13314#define VSB_TOP_NOTCH_SWEEP_RUNNING__A 0x1C10049
13315#define VSB_TOP_NOTCH_SWEEP_RUNNING__W 1
13316#define VSB_TOP_NOTCH_SWEEP_RUNNING__M 0x1
13317#define VSB_TOP_NOTCH_SWEEP_RUNNING__PRE 0x0
13318
13319#define VSB_TOP_PREEQDAGCRATIO__A 0x1C1004A
13320#define VSB_TOP_PREEQDAGCRATIO__W 13
13321#define VSB_TOP_PREEQDAGCRATIO__M 0x1FFF
13322#define VSB_TOP_PREEQDAGCRATIO__PRE 0x0
13323#define VSB_TOP_AGC_TRUNCCTRL__A 0x1C1004B
13324#define VSB_TOP_AGC_TRUNCCTRL__W 4
13325#define VSB_TOP_AGC_TRUNCCTRL__M 0xF
13326#define VSB_TOP_AGC_TRUNCCTRL__PRE 0xF
13327
13328#define VSB_TOP_AGC_TRUNCCTRL_TRUNC_LSB__B 0
13329#define VSB_TOP_AGC_TRUNCCTRL_TRUNC_LSB__W 2
13330#define VSB_TOP_AGC_TRUNCCTRL_TRUNC_LSB__M 0x3
13331#define VSB_TOP_AGC_TRUNCCTRL_TRUNC_LSB__PRE 0x3
13332
13333#define VSB_TOP_AGC_TRUNCCTRL_TRUNC_12N__B 2
13334#define VSB_TOP_AGC_TRUNCCTRL_TRUNC_12N__W 1
13335#define VSB_TOP_AGC_TRUNCCTRL_TRUNC_12N__M 0x4
13336#define VSB_TOP_AGC_TRUNCCTRL_TRUNC_12N__PRE 0x4
13337
13338#define VSB_TOP_AGC_TRUNCCTRL_TRUNC_EN__B 3
13339#define VSB_TOP_AGC_TRUNCCTRL_TRUNC_EN__W 1
13340#define VSB_TOP_AGC_TRUNCCTRL_TRUNC_EN__M 0x8
13341#define VSB_TOP_AGC_TRUNCCTRL_TRUNC_EN__PRE 0x8
13342
13343#define VSB_TOP_BEAGC_DEADZONEINIT__A 0x1C1004C
13344#define VSB_TOP_BEAGC_DEADZONEINIT__W 8
13345#define VSB_TOP_BEAGC_DEADZONEINIT__M 0xFF
13346#define VSB_TOP_BEAGC_DEADZONEINIT__PRE 0x50
13347
13348#define VSB_TOP_BEAGC_REFLEVEL__A 0x1C1004D
13349#define VSB_TOP_BEAGC_REFLEVEL__W 9
13350#define VSB_TOP_BEAGC_REFLEVEL__M 0x1FF
13351#define VSB_TOP_BEAGC_REFLEVEL__PRE 0xAE
13352
13353#define VSB_TOP_BEAGC_GAINSHIFT__A 0x1C1004E
13354#define VSB_TOP_BEAGC_GAINSHIFT__W 3
13355#define VSB_TOP_BEAGC_GAINSHIFT__M 0x7
13356#define VSB_TOP_BEAGC_GAINSHIFT__PRE 0x3
13357
13358#define VSB_TOP_BEAGC_REGINIT__A 0x1C1004F
13359#define VSB_TOP_BEAGC_REGINIT__W 15
13360#define VSB_TOP_BEAGC_REGINIT__M 0x7FFF
13361#define VSB_TOP_BEAGC_REGINIT__PRE 0x40
13362
13363#define VSB_TOP_BEAGC_REGINIT_BEAGC_RST__B 14
13364#define VSB_TOP_BEAGC_REGINIT_BEAGC_RST__W 1
13365#define VSB_TOP_BEAGC_REGINIT_BEAGC_RST__M 0x4000
13366#define VSB_TOP_BEAGC_REGINIT_BEAGC_RST__PRE 0x0
13367
13368#define VSB_TOP_BEAGC_SCALE__A 0x1C10050
13369#define VSB_TOP_BEAGC_SCALE__W 14
13370#define VSB_TOP_BEAGC_SCALE__M 0x3FFF
13371#define VSB_TOP_BEAGC_SCALE__PRE 0x0
13372
13373#define VSB_TOP_CFAGC_DEADZONEINIT__A 0x1C10051
13374#define VSB_TOP_CFAGC_DEADZONEINIT__W 8
13375#define VSB_TOP_CFAGC_DEADZONEINIT__M 0xFF
13376#define VSB_TOP_CFAGC_DEADZONEINIT__PRE 0x50
13377
13378#define VSB_TOP_CFAGC_REFLEVEL__A 0x1C10052
13379#define VSB_TOP_CFAGC_REFLEVEL__W 9
13380#define VSB_TOP_CFAGC_REFLEVEL__M 0x1FF
13381#define VSB_TOP_CFAGC_REFLEVEL__PRE 0xAE
13382
13383#define VSB_TOP_CFAGC_GAINSHIFT__A 0x1C10053
13384#define VSB_TOP_CFAGC_GAINSHIFT__W 3
13385#define VSB_TOP_CFAGC_GAINSHIFT__M 0x7
13386#define VSB_TOP_CFAGC_GAINSHIFT__PRE 0x3
13387
13388#define VSB_TOP_CFAGC_REGINIT__A 0x1C10054
13389#define VSB_TOP_CFAGC_REGINIT__W 15
13390#define VSB_TOP_CFAGC_REGINIT__M 0x7FFF
13391#define VSB_TOP_CFAGC_REGINIT__PRE 0x80
13392
13393#define VSB_TOP_CFAGC_REGINIT_CFAGC_RST__B 14
13394#define VSB_TOP_CFAGC_REGINIT_CFAGC_RST__W 1
13395#define VSB_TOP_CFAGC_REGINIT_CFAGC_RST__M 0x4000
13396#define VSB_TOP_CFAGC_REGINIT_CFAGC_RST__PRE 0x0
13397
13398#define VSB_TOP_CFAGC_SCALE__A 0x1C10055
13399#define VSB_TOP_CFAGC_SCALE__W 14
13400#define VSB_TOP_CFAGC_SCALE__M 0x3FFF
13401#define VSB_TOP_CFAGC_SCALE__PRE 0x0
13402
13403#define VSB_TOP_CKTRKONCTL__A 0x1C10056
13404#define VSB_TOP_CKTRKONCTL__W 2
13405#define VSB_TOP_CKTRKONCTL__M 0x3
13406#define VSB_TOP_CKTRKONCTL__PRE 0x0
13407
13408#define VSB_TOP_CYTRKONCTL__A 0x1C10057
13409#define VSB_TOP_CYTRKONCTL__W 2
13410#define VSB_TOP_CYTRKONCTL__M 0x3
13411#define VSB_TOP_CYTRKONCTL__PRE 0x0
13412
13413#define VSB_TOP_PTONCTL__A 0x1C10058
13414#define VSB_TOP_PTONCTL__W 2
13415#define VSB_TOP_PTONCTL__M 0x3
13416#define VSB_TOP_PTONCTL__PRE 0x0
13417
13418#define VSB_TOP_NOTCH_SCALE_1__A 0x1C10059
13419#define VSB_TOP_NOTCH_SCALE_1__W 8
13420#define VSB_TOP_NOTCH_SCALE_1__M 0xFF
13421#define VSB_TOP_NOTCH_SCALE_1__PRE 0xA
13422
13423#define VSB_TOP_NOTCH_SCALE_2__A 0x1C1005A
13424#define VSB_TOP_NOTCH_SCALE_2__W 8
13425#define VSB_TOP_NOTCH_SCALE_2__M 0xFF
13426#define VSB_TOP_NOTCH_SCALE_2__PRE 0xA
13427
13428#define VSB_TOP_FIRSTLARGFFETAP__A 0x1C1005B
13429#define VSB_TOP_FIRSTLARGFFETAP__W 12
13430#define VSB_TOP_FIRSTLARGFFETAP__M 0xFFF
13431#define VSB_TOP_FIRSTLARGFFETAP__PRE 0x0
13432
13433#define VSB_TOP_FIRSTLARGFFETAPADDR__A 0x1C1005C
13434#define VSB_TOP_FIRSTLARGFFETAPADDR__W 11
13435#define VSB_TOP_FIRSTLARGFFETAPADDR__M 0x7FF
13436#define VSB_TOP_FIRSTLARGFFETAPADDR__PRE 0x0
13437
13438#define VSB_TOP_SECONDLARGFFETAP__A 0x1C1005D
13439#define VSB_TOP_SECONDLARGFFETAP__W 12
13440#define VSB_TOP_SECONDLARGFFETAP__M 0xFFF
13441#define VSB_TOP_SECONDLARGFFETAP__PRE 0x0
13442
13443#define VSB_TOP_SECONDLARGFFETAPADDR__A 0x1C1005E
13444#define VSB_TOP_SECONDLARGFFETAPADDR__W 11
13445#define VSB_TOP_SECONDLARGFFETAPADDR__M 0x7FF
13446#define VSB_TOP_SECONDLARGFFETAPADDR__PRE 0x0
13447
13448#define VSB_TOP_FIRSTLARGDFETAP__A 0x1C1005F
13449#define VSB_TOP_FIRSTLARGDFETAP__W 12
13450#define VSB_TOP_FIRSTLARGDFETAP__M 0xFFF
13451#define VSB_TOP_FIRSTLARGDFETAP__PRE 0x0
13452
13453#define VSB_TOP_FIRSTLARGDFETAPADDR__A 0x1C10060
13454#define VSB_TOP_FIRSTLARGDFETAPADDR__W 11
13455#define VSB_TOP_FIRSTLARGDFETAPADDR__M 0x7FF
13456#define VSB_TOP_FIRSTLARGDFETAPADDR__PRE 0x0
13457
13458#define VSB_TOP_SECONDLARGDFETAP__A 0x1C10061
13459#define VSB_TOP_SECONDLARGDFETAP__W 12
13460#define VSB_TOP_SECONDLARGDFETAP__M 0xFFF
13461#define VSB_TOP_SECONDLARGDFETAP__PRE 0x0
13462
13463#define VSB_TOP_SECONDLARGDFETAPADDR__A 0x1C10062
13464#define VSB_TOP_SECONDLARGDFETAPADDR__W 11
13465#define VSB_TOP_SECONDLARGDFETAPADDR__M 0x7FF
13466#define VSB_TOP_SECONDLARGDFETAPADDR__PRE 0x0
13467
13468#define VSB_TOP_PARAOWDBUS__A 0x1C10063
13469#define VSB_TOP_PARAOWDBUS__W 12
13470#define VSB_TOP_PARAOWDBUS__M 0xFFF
13471#define VSB_TOP_PARAOWDBUS__PRE 0x0
13472#define VSB_TOP_PARAOWCTRL__A 0x1C10064
13473#define VSB_TOP_PARAOWCTRL__W 7
13474#define VSB_TOP_PARAOWCTRL__M 0x7F
13475#define VSB_TOP_PARAOWCTRL__PRE 0x0
13476
13477#define VSB_TOP_PARAOWCTRL_PARAOWABUS__B 0
13478#define VSB_TOP_PARAOWCTRL_PARAOWABUS__W 6
13479#define VSB_TOP_PARAOWCTRL_PARAOWABUS__M 0x3F
13480#define VSB_TOP_PARAOWCTRL_PARAOWABUS__PRE 0x0
13481
13482#define VSB_TOP_PARAOWCTRL_PARAOWEN__B 6
13483#define VSB_TOP_PARAOWCTRL_PARAOWEN__W 1
13484#define VSB_TOP_PARAOWCTRL_PARAOWEN__M 0x40
13485#define VSB_TOP_PARAOWCTRL_PARAOWEN__PRE 0x0
13486
13487#define VSB_TOP_CURRENTSEGLOCAT__A 0x1C10065
13488#define VSB_TOP_CURRENTSEGLOCAT__W 10
13489#define VSB_TOP_CURRENTSEGLOCAT__M 0x3FF
13490#define VSB_TOP_CURRENTSEGLOCAT__PRE 0x0
13491
13492#define VSB_TOP_MEASUREMENT_PERIOD__A 0x1C10066
13493#define VSB_TOP_MEASUREMENT_PERIOD__W 16
13494#define VSB_TOP_MEASUREMENT_PERIOD__M 0xFFFF
13495#define VSB_TOP_MEASUREMENT_PERIOD__PRE 0x0
13496
13497#define VSB_TOP_NR_SYM_ERRS__A 0x1C10067
13498#define VSB_TOP_NR_SYM_ERRS__W 16
13499#define VSB_TOP_NR_SYM_ERRS__M 0xFFFF
13500#define VSB_TOP_NR_SYM_ERRS__PRE 0xFFFF
13501
13502#define VSB_TOP_ERR_ENERGY_L__A 0x1C10068
13503#define VSB_TOP_ERR_ENERGY_L__W 16
13504#define VSB_TOP_ERR_ENERGY_L__M 0xFFFF
13505#define VSB_TOP_ERR_ENERGY_L__PRE 0xFFFF
13506
13507#define VSB_TOP_ERR_ENERGY_H__A 0x1C10069
13508#define VSB_TOP_ERR_ENERGY_H__W 16
13509#define VSB_TOP_ERR_ENERGY_H__M 0xFFFF
13510#define VSB_TOP_ERR_ENERGY_H__PRE 0xFFFF
13511
13512#define VSB_TOP_SLICER_SEL_8LEV__A 0x1C1006A
13513#define VSB_TOP_SLICER_SEL_8LEV__W 1
13514#define VSB_TOP_SLICER_SEL_8LEV__M 0x1
13515#define VSB_TOP_SLICER_SEL_8LEV__PRE 0x1
13516
13517#define VSB_TOP_BNFIELD__A 0x1C1006B
13518#define VSB_TOP_BNFIELD__W 3
13519#define VSB_TOP_BNFIELD__M 0x7
13520#define VSB_TOP_BNFIELD__PRE 0x3
13521
13522#define VSB_TOP_CLPLASTNUM__A 0x1C1006C
13523#define VSB_TOP_CLPLASTNUM__W 8
13524#define VSB_TOP_CLPLASTNUM__M 0xFF
13525#define VSB_TOP_CLPLASTNUM__PRE 0x0
13526
13527#define VSB_TOP_BNSQERR__A 0x1C1006D
13528#define VSB_TOP_BNSQERR__W 16
13529#define VSB_TOP_BNSQERR__M 0xFFFF
13530#define VSB_TOP_BNSQERR__PRE 0x1AD
13531
13532#define VSB_TOP_BNTHRESH__A 0x1C1006E
13533#define VSB_TOP_BNTHRESH__W 9
13534#define VSB_TOP_BNTHRESH__M 0x1FF
13535#define VSB_TOP_BNTHRESH__PRE 0x120
13536
13537#define VSB_TOP_BNCLPNUM__A 0x1C1006F
13538#define VSB_TOP_BNCLPNUM__W 16
13539#define VSB_TOP_BNCLPNUM__M 0xFFFF
13540#define VSB_TOP_BNCLPNUM__PRE 0x0
13541#define VSB_TOP_PHASELOCKCTRL__A 0x1C10070
13542#define VSB_TOP_PHASELOCKCTRL__W 7
13543#define VSB_TOP_PHASELOCKCTRL__M 0x7F
13544#define VSB_TOP_PHASELOCKCTRL__PRE 0x0
13545
13546#define VSB_TOP_PHASELOCKCTRL_DFORCEPOLARITY__B 0
13547#define VSB_TOP_PHASELOCKCTRL_DFORCEPOLARITY__W 1
13548#define VSB_TOP_PHASELOCKCTRL_DFORCEPOLARITY__M 0x1
13549#define VSB_TOP_PHASELOCKCTRL_DFORCEPOLARITY__PRE 0x0
13550
13551#define VSB_TOP_PHASELOCKCTRL_DFORCEPLL__B 1
13552#define VSB_TOP_PHASELOCKCTRL_DFORCEPLL__W 1
13553#define VSB_TOP_PHASELOCKCTRL_DFORCEPLL__M 0x2
13554#define VSB_TOP_PHASELOCKCTRL_DFORCEPLL__PRE 0x0
13555
13556#define VSB_TOP_PHASELOCKCTRL_PFORCEPOLARITY__B 2
13557#define VSB_TOP_PHASELOCKCTRL_PFORCEPOLARITY__W 1
13558#define VSB_TOP_PHASELOCKCTRL_PFORCEPOLARITY__M 0x4
13559#define VSB_TOP_PHASELOCKCTRL_PFORCEPOLARITY__PRE 0x0
13560
13561#define VSB_TOP_PHASELOCKCTRL_PFORCEPLL__B 3
13562#define VSB_TOP_PHASELOCKCTRL_PFORCEPLL__W 1
13563#define VSB_TOP_PHASELOCKCTRL_PFORCEPLL__M 0x8
13564#define VSB_TOP_PHASELOCKCTRL_PFORCEPLL__PRE 0x0
13565
13566#define VSB_TOP_PHASELOCKCTRL_CFORCEPOLARITY__B 4
13567#define VSB_TOP_PHASELOCKCTRL_CFORCEPOLARITY__W 1
13568#define VSB_TOP_PHASELOCKCTRL_CFORCEPOLARITY__M 0x10
13569#define VSB_TOP_PHASELOCKCTRL_CFORCEPOLARITY__PRE 0x0
13570
13571#define VSB_TOP_PHASELOCKCTRL_CFORCEPLL__B 5
13572#define VSB_TOP_PHASELOCKCTRL_CFORCEPLL__W 1
13573#define VSB_TOP_PHASELOCKCTRL_CFORCEPLL__M 0x20
13574#define VSB_TOP_PHASELOCKCTRL_CFORCEPLL__PRE 0x0
13575
13576#define VSB_TOP_PHASELOCKCTRL_IQSWITCH__B 6
13577#define VSB_TOP_PHASELOCKCTRL_IQSWITCH__W 1
13578#define VSB_TOP_PHASELOCKCTRL_IQSWITCH__M 0x40
13579#define VSB_TOP_PHASELOCKCTRL_IQSWITCH__PRE 0x0
13580
13581#define VSB_TOP_DLOCKACCUM__A 0x1C10071
13582#define VSB_TOP_DLOCKACCUM__W 16
13583#define VSB_TOP_DLOCKACCUM__M 0xFFFF
13584#define VSB_TOP_DLOCKACCUM__PRE 0x0
13585
13586#define VSB_TOP_PLOCKACCUM__A 0x1C10072
13587#define VSB_TOP_PLOCKACCUM__W 16
13588#define VSB_TOP_PLOCKACCUM__M 0xFFFF
13589#define VSB_TOP_PLOCKACCUM__PRE 0x0
13590
13591#define VSB_TOP_CLOCKACCUM__A 0x1C10073
13592#define VSB_TOP_CLOCKACCUM__W 16
13593#define VSB_TOP_CLOCKACCUM__M 0xFFFF
13594#define VSB_TOP_CLOCKACCUM__PRE 0x0
13595
13596#define VSB_TOP_DCRMVACUMI__A 0x1C10074
13597#define VSB_TOP_DCRMVACUMI__W 10
13598#define VSB_TOP_DCRMVACUMI__M 0x3FF
13599#define VSB_TOP_DCRMVACUMI__PRE 0x0
13600
13601#define VSB_TOP_DCRMVACUMQ__A 0x1C10075
13602#define VSB_TOP_DCRMVACUMQ__W 10
13603#define VSB_TOP_DCRMVACUMQ__M 0x3FF
13604#define VSB_TOP_DCRMVACUMQ__PRE 0x0
13605
13606#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO1__A 0x1C20000
13607#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO1__W 12
13608#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO1__M 0xFFF
13609#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO1__PRE 0x0
13610
13611#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO2__A 0x1C20001
13612#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO2__W 12
13613#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO2__M 0xFFF
13614#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO2__PRE 0x0
13615
13616#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO3__A 0x1C20002
13617#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO3__W 12
13618#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO3__M 0xFFF
13619#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO3__PRE 0x0
13620
13621#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO4__A 0x1C20003
13622#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO4__W 12
13623#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO4__M 0xFFF
13624#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO4__PRE 0x0
13625
13626#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO5__A 0x1C20004
13627#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO5__W 12
13628#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO5__M 0xFFF
13629#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO5__PRE 0x0
13630
13631#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO6__A 0x1C20005
13632#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO6__W 12
13633#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO6__M 0xFFF
13634#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO6__PRE 0x0
13635
13636#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO7__A 0x1C20006
13637#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO7__W 12
13638#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO7__M 0xFFF
13639#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO7__PRE 0x0
13640
13641#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO8__A 0x1C20007
13642#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO8__W 12
13643#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO8__M 0xFFF
13644#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO8__PRE 0x0
13645
13646#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO9__A 0x1C20008
13647#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO9__W 12
13648#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO9__M 0xFFF
13649#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO9__PRE 0x0
13650
13651#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO10__A 0x1C20009
13652#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO10__W 12
13653#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO10__M 0xFFF
13654#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO10__PRE 0x0
13655
13656#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO11__A 0x1C2000A
13657#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO11__W 12
13658#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO11__M 0xFFF
13659#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO11__PRE 0x0
13660
13661#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO12__A 0x1C2000B
13662#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO12__W 12
13663#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO12__M 0xFFF
13664#define VSB_SYSCTRL_RAM0_FFETRAINLKRATIO12__PRE 0x0
13665
13666#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO1__A 0x1C2000C
13667#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO1__W 12
13668#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO1__M 0xFFF
13669#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO1__PRE 0x0
13670
13671#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO2__A 0x1C2000D
13672#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO2__W 12
13673#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO2__M 0xFFF
13674#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO2__PRE 0x0
13675
13676#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO3__A 0x1C2000E
13677#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO3__W 12
13678#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO3__M 0xFFF
13679#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO3__PRE 0x0
13680
13681#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO4__A 0x1C2000F
13682#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO4__W 12
13683#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO4__M 0xFFF
13684#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO4__PRE 0x0
13685
13686#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO5__A 0x1C20010
13687#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO5__W 12
13688#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO5__M 0xFFF
13689#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO5__PRE 0x0
13690
13691#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO6__A 0x1C20011
13692#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO6__W 12
13693#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO6__M 0xFFF
13694#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO6__PRE 0x0
13695
13696#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO7__A 0x1C20012
13697#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO7__W 12
13698#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO7__M 0xFFF
13699#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO7__PRE 0x0
13700
13701#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO8__A 0x1C20013
13702#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO8__W 12
13703#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO8__M 0xFFF
13704#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO8__PRE 0x0
13705
13706#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO9__A 0x1C20014
13707#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO9__W 12
13708#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO9__M 0xFFF
13709#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO9__PRE 0x0
13710
13711#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO10__A 0x1C20015
13712#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO10__W 12
13713#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO10__M 0xFFF
13714#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO10__PRE 0x0
13715
13716#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO11__A 0x1C20016
13717#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO11__W 12
13718#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO11__M 0xFFF
13719#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO11__PRE 0x0
13720
13721#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO12__A 0x1C20017
13722#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO12__W 12
13723#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO12__M 0xFFF
13724#define VSB_SYSCTRL_RAM0_FFERCA1TRAINLKRATIO12__PRE 0x0
13725
13726#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO1__A 0x1C20018
13727#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO1__W 12
13728#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO1__M 0xFFF
13729#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO1__PRE 0x0
13730
13731#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO2__A 0x1C20019
13732#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO2__W 12
13733#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO2__M 0xFFF
13734#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO2__PRE 0x0
13735
13736#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO3__A 0x1C2001A
13737#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO3__W 12
13738#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO3__M 0xFFF
13739#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO3__PRE 0x0
13740
13741#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO4__A 0x1C2001B
13742#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO4__W 12
13743#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO4__M 0xFFF
13744#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO4__PRE 0x0
13745
13746#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO5__A 0x1C2001C
13747#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO5__W 12
13748#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO5__M 0xFFF
13749#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO5__PRE 0x0
13750
13751#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO6__A 0x1C2001D
13752#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO6__W 12
13753#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO6__M 0xFFF
13754#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO6__PRE 0x0
13755
13756#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO7__A 0x1C2001E
13757#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO7__W 12
13758#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO7__M 0xFFF
13759#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO7__PRE 0x0
13760
13761#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO8__A 0x1C2001F
13762#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO8__W 12
13763#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO8__M 0xFFF
13764#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO8__PRE 0x0
13765
13766#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO9__A 0x1C20020
13767#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO9__W 12
13768#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO9__M 0xFFF
13769#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO9__PRE 0x0
13770
13771#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO10__A 0x1C20021
13772#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO10__W 12
13773#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO10__M 0xFFF
13774#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO10__PRE 0x0
13775
13776#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO11__A 0x1C20022
13777#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO11__W 12
13778#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO11__M 0xFFF
13779#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO11__PRE 0x0
13780
13781#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO12__A 0x1C20023
13782#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO12__W 12
13783#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO12__M 0xFFF
13784#define VSB_SYSCTRL_RAM0_FFERCA1DATALKRATIO12__PRE 0x0
13785
13786#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO1__A 0x1C20024
13787#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO1__W 12
13788#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO1__M 0xFFF
13789#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO1__PRE 0x0
13790
13791#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO2__A 0x1C20025
13792#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO2__W 12
13793#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO2__M 0xFFF
13794#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO2__PRE 0x0
13795
13796#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO3__A 0x1C20026
13797#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO3__W 12
13798#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO3__M 0xFFF
13799#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO3__PRE 0x0
13800
13801#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO4__A 0x1C20027
13802#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO4__W 12
13803#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO4__M 0xFFF
13804#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO4__PRE 0x0
13805
13806#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO5__A 0x1C20028
13807#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO5__W 12
13808#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO5__M 0xFFF
13809#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO5__PRE 0x0
13810
13811#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO6__A 0x1C20029
13812#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO6__W 12
13813#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO6__M 0xFFF
13814#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO6__PRE 0x0
13815
13816#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO7__A 0x1C2002A
13817#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO7__W 12
13818#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO7__M 0xFFF
13819#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO7__PRE 0x0
13820
13821#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO8__A 0x1C2002B
13822#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO8__W 12
13823#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO8__M 0xFFF
13824#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO8__PRE 0x0
13825
13826#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO9__A 0x1C2002C
13827#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO9__W 12
13828#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO9__M 0xFFF
13829#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO9__PRE 0x0
13830
13831#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO10__A 0x1C2002D
13832#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO10__W 12
13833#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO10__M 0xFFF
13834#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO10__PRE 0x0
13835
13836#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO11__A 0x1C2002E
13837#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO11__W 12
13838#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO11__M 0xFFF
13839#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO11__PRE 0x0
13840
13841#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO12__A 0x1C2002F
13842#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO12__W 12
13843#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO12__M 0xFFF
13844#define VSB_SYSCTRL_RAM0_FFERCA2TRAINLKRATIO12__PRE 0x0
13845
13846#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO1__A 0x1C20030
13847#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO1__W 12
13848#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO1__M 0xFFF
13849#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO1__PRE 0x0
13850
13851#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO2__A 0x1C20031
13852#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO2__W 12
13853#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO2__M 0xFFF
13854#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO2__PRE 0x0
13855
13856#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO3__A 0x1C20032
13857#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO3__W 12
13858#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO3__M 0xFFF
13859#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO3__PRE 0x0
13860
13861#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO4__A 0x1C20033
13862#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO4__W 12
13863#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO4__M 0xFFF
13864#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO4__PRE 0x0
13865
13866#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO5__A 0x1C20034
13867#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO5__W 12
13868#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO5__M 0xFFF
13869#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO5__PRE 0x0
13870
13871#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO6__A 0x1C20035
13872#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO6__W 12
13873#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO6__M 0xFFF
13874#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO6__PRE 0x0
13875
13876#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO7__A 0x1C20036
13877#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO7__W 12
13878#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO7__M 0xFFF
13879#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO7__PRE 0x0
13880
13881#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO8__A 0x1C20037
13882#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO8__W 12
13883#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO8__M 0xFFF
13884#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO8__PRE 0x0
13885
13886#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO9__A 0x1C20038
13887#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO9__W 12
13888#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO9__M 0xFFF
13889#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO9__PRE 0x0
13890
13891#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO10__A 0x1C20039
13892#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO10__W 12
13893#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO10__M 0xFFF
13894#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO10__PRE 0x0
13895
13896#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO11__A 0x1C2003A
13897#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO11__W 12
13898#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO11__M 0xFFF
13899#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO11__PRE 0x0
13900
13901#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO12__A 0x1C2003B
13902#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO12__W 12
13903#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO12__M 0xFFF
13904#define VSB_SYSCTRL_RAM0_FFERCA2DATALKRATIO12__PRE 0x0
13905
13906#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO1__A 0x1C2003C
13907#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO1__W 12
13908#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO1__M 0xFFF
13909#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO1__PRE 0x0
13910
13911#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO2__A 0x1C2003D
13912#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO2__W 12
13913#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO2__M 0xFFF
13914#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO2__PRE 0x0
13915
13916#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO3__A 0x1C2003E
13917#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO3__W 12
13918#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO3__M 0xFFF
13919#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO3__PRE 0x0
13920
13921#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO4__A 0x1C2003F
13922#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO4__W 12
13923#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO4__M 0xFFF
13924#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO4__PRE 0x0
13925
13926#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO5__A 0x1C20040
13927#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO5__W 12
13928#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO5__M 0xFFF
13929#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO5__PRE 0x0
13930
13931#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO6__A 0x1C20041
13932#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO6__W 12
13933#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO6__M 0xFFF
13934#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO6__PRE 0x0
13935
13936#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO7__A 0x1C20042
13937#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO7__W 12
13938#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO7__M 0xFFF
13939#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO7__PRE 0x0
13940
13941#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO8__A 0x1C20043
13942#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO8__W 12
13943#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO8__M 0xFFF
13944#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO8__PRE 0x0
13945
13946#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO9__A 0x1C20044
13947#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO9__W 12
13948#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO9__M 0xFFF
13949#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO9__PRE 0x0
13950
13951#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO10__A 0x1C20045
13952#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO10__W 12
13953#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO10__M 0xFFF
13954#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO10__PRE 0x0
13955
13956#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO11__A 0x1C20046
13957#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO11__W 12
13958#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO11__M 0xFFF
13959#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO11__PRE 0x0
13960
13961#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO12__A 0x1C20047
13962#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO12__W 12
13963#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO12__M 0xFFF
13964#define VSB_SYSCTRL_RAM0_FFEDDM1TRAINLKRATIO12__PRE 0x0
13965
13966#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO1__A 0x1C20048
13967#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO1__W 12
13968#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO1__M 0xFFF
13969#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO1__PRE 0x0
13970
13971#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO2__A 0x1C20049
13972#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO2__W 12
13973#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO2__M 0xFFF
13974#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO2__PRE 0x0
13975
13976#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO3__A 0x1C2004A
13977#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO3__W 12
13978#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO3__M 0xFFF
13979#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO3__PRE 0x0
13980
13981#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO4__A 0x1C2004B
13982#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO4__W 12
13983#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO4__M 0xFFF
13984#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO4__PRE 0x0
13985
13986#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO5__A 0x1C2004C
13987#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO5__W 12
13988#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO5__M 0xFFF
13989#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO5__PRE 0x0
13990
13991#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO6__A 0x1C2004D
13992#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO6__W 12
13993#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO6__M 0xFFF
13994#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO6__PRE 0x0
13995
13996#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO7__A 0x1C2004E
13997#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO7__W 12
13998#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO7__M 0xFFF
13999#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO7__PRE 0x0
14000
14001#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO8__A 0x1C2004F
14002#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO8__W 12
14003#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO8__M 0xFFF
14004#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO8__PRE 0x0
14005
14006#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO9__A 0x1C20050
14007#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO9__W 12
14008#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO9__M 0xFFF
14009#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO9__PRE 0x0
14010
14011#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO10__A 0x1C20051
14012#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO10__W 12
14013#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO10__M 0xFFF
14014#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO10__PRE 0x0
14015
14016#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO11__A 0x1C20052
14017#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO11__W 12
14018#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO11__M 0xFFF
14019#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO11__PRE 0x0
14020
14021#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO12__A 0x1C20053
14022#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO12__W 12
14023#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO12__M 0xFFF
14024#define VSB_SYSCTRL_RAM0_FFEDDM1DATALKRATIO12__PRE 0x0
14025
14026#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO1__A 0x1C20054
14027#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO1__W 12
14028#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO1__M 0xFFF
14029#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO1__PRE 0x0
14030
14031#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO2__A 0x1C20055
14032#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO2__W 12
14033#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO2__M 0xFFF
14034#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO2__PRE 0x0
14035
14036#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO3__A 0x1C20056
14037#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO3__W 12
14038#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO3__M 0xFFF
14039#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO3__PRE 0x0
14040
14041#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO4__A 0x1C20057
14042#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO4__W 12
14043#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO4__M 0xFFF
14044#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO4__PRE 0x0
14045
14046#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO5__A 0x1C20058
14047#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO5__W 12
14048#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO5__M 0xFFF
14049#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO5__PRE 0x0
14050
14051#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO6__A 0x1C20059
14052#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO6__W 12
14053#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO6__M 0xFFF
14054#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO6__PRE 0x0
14055
14056#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO7__A 0x1C2005A
14057#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO7__W 12
14058#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO7__M 0xFFF
14059#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO7__PRE 0x0
14060
14061#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO8__A 0x1C2005B
14062#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO8__W 12
14063#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO8__M 0xFFF
14064#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO8__PRE 0x0
14065
14066#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO9__A 0x1C2005C
14067#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO9__W 12
14068#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO9__M 0xFFF
14069#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO9__PRE 0x0
14070
14071#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO10__A 0x1C2005D
14072#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO10__W 12
14073#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO10__M 0xFFF
14074#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO10__PRE 0x0
14075
14076#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO11__A 0x1C2005E
14077#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO11__W 12
14078#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO11__M 0xFFF
14079#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO11__PRE 0x0
14080
14081#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO12__A 0x1C2005F
14082#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO12__W 12
14083#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO12__M 0xFFF
14084#define VSB_SYSCTRL_RAM0_FFEDDM2TRAINLKRATIO12__PRE 0x0
14085
14086#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO1__A 0x1C20060
14087#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO1__W 12
14088#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO1__M 0xFFF
14089#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO1__PRE 0x0
14090
14091#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO2__A 0x1C20061
14092#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO2__W 12
14093#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO2__M 0xFFF
14094#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO2__PRE 0x0
14095
14096#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO3__A 0x1C20062
14097#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO3__W 12
14098#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO3__M 0xFFF
14099#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO3__PRE 0x0
14100
14101#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO4__A 0x1C20063
14102#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO4__W 12
14103#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO4__M 0xFFF
14104#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO4__PRE 0x0
14105
14106#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO5__A 0x1C20064
14107#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO5__W 12
14108#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO5__M 0xFFF
14109#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO5__PRE 0x0
14110
14111#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO6__A 0x1C20065
14112#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO6__W 12
14113#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO6__M 0xFFF
14114#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO6__PRE 0x0
14115
14116#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO7__A 0x1C20066
14117#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO7__W 12
14118#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO7__M 0xFFF
14119#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO7__PRE 0x0
14120
14121#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO8__A 0x1C20067
14122#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO8__W 12
14123#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO8__M 0xFFF
14124#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO8__PRE 0x0
14125
14126#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO9__A 0x1C20068
14127#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO9__W 12
14128#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO9__M 0xFFF
14129#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO9__PRE 0x0
14130
14131#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO10__A 0x1C20069
14132#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO10__W 12
14133#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO10__M 0xFFF
14134#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO10__PRE 0x0
14135
14136#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO11__A 0x1C2006A
14137#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO11__W 12
14138#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO11__M 0xFFF
14139#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO11__PRE 0x0
14140
14141#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO12__A 0x1C2006B
14142#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO12__W 12
14143#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO12__M 0xFFF
14144#define VSB_SYSCTRL_RAM0_FFEDDM2DATALKRATIO12__PRE 0x0
14145
14146#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN1__A 0x1C2006C
14147#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN1__W 7
14148#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN1__M 0x7F
14149#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN1__PRE 0x0
14150
14151#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN2__A 0x1C2006D
14152#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN2__W 7
14153#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN2__M 0x7F
14154#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN2__PRE 0x0
14155
14156#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN3__A 0x1C2006E
14157#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN3__W 7
14158#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN3__M 0x7F
14159#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN3__PRE 0x0
14160
14161#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN4__A 0x1C2006F
14162#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN4__W 7
14163#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN4__M 0x7F
14164#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN4__PRE 0x0
14165
14166#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN5__A 0x1C20070
14167#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN5__W 7
14168#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN5__M 0x7F
14169#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN5__PRE 0x0
14170
14171#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN6__A 0x1C20071
14172#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN6__W 7
14173#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN6__M 0x7F
14174#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN6__PRE 0x0
14175
14176#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN7__A 0x1C20072
14177#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN7__W 7
14178#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN7__M 0x7F
14179#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN7__PRE 0x0
14180
14181#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN8__A 0x1C20073
14182#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN8__W 7
14183#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN8__M 0x7F
14184#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN8__PRE 0x0
14185
14186#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN9__A 0x1C20074
14187#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN9__W 7
14188#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN9__M 0x7F
14189#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN9__PRE 0x0
14190
14191#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN10__A 0x1C20075
14192#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN10__W 7
14193#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN10__M 0x7F
14194#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN10__PRE 0x0
14195
14196#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN11__A 0x1C20076
14197#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN11__W 7
14198#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN11__M 0x7F
14199#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN11__PRE 0x0
14200
14201#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN12__A 0x1C20077
14202#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN12__W 7
14203#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN12__M 0x7F
14204#define VSB_SYSCTRL_RAM0_FIRTRAINGAIN12__PRE 0x0
14205#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN1__A 0x1C20078
14206#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN1__W 15
14207#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN1__M 0x7FFF
14208#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN1__PRE 0x0
14209
14210#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN1_FIRRCA1TRAINGAIN1__B 0
14211#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN1_FIRRCA1TRAINGAIN1__W 7
14212#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN1_FIRRCA1TRAINGAIN1__M 0x7F
14213#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN1_FIRRCA1TRAINGAIN1__PRE 0x0
14214
14215#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN1_FIRRCA1DATAGAIN1__B 8
14216#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN1_FIRRCA1DATAGAIN1__W 7
14217#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN1_FIRRCA1DATAGAIN1__M 0x7F00
14218#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN1_FIRRCA1DATAGAIN1__PRE 0x0
14219
14220#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN2__A 0x1C20079
14221#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN2__W 15
14222#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN2__M 0x7FFF
14223#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN2__PRE 0x0
14224
14225#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN2_FIRRCA1TRAINGAIN2__B 0
14226#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN2_FIRRCA1TRAINGAIN2__W 7
14227#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN2_FIRRCA1TRAINGAIN2__M 0x7F
14228#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN2_FIRRCA1TRAINGAIN2__PRE 0x0
14229
14230#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN2_FIRRCA1DATAGAIN2__B 8
14231#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN2_FIRRCA1DATAGAIN2__W 7
14232#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN2_FIRRCA1DATAGAIN2__M 0x7F00
14233#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN2_FIRRCA1DATAGAIN2__PRE 0x0
14234
14235#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN3__A 0x1C2007A
14236#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN3__W 15
14237#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN3__M 0x7FFF
14238#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN3__PRE 0x0
14239
14240#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN3_FIRRCA1TRAINGAIN3__B 0
14241#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN3_FIRRCA1TRAINGAIN3__W 7
14242#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN3_FIRRCA1TRAINGAIN3__M 0x7F
14243#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN3_FIRRCA1TRAINGAIN3__PRE 0x0
14244
14245#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN3_FIRRCA1DATAGAIN3__B 8
14246#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN3_FIRRCA1DATAGAIN3__W 7
14247#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN3_FIRRCA1DATAGAIN3__M 0x7F00
14248#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN3_FIRRCA1DATAGAIN3__PRE 0x0
14249
14250#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN4__A 0x1C2007B
14251#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN4__W 15
14252#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN4__M 0x7FFF
14253#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN4__PRE 0x0
14254
14255#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN4_FIRRCA1TRAINGAIN4__B 0
14256#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN4_FIRRCA1TRAINGAIN4__W 7
14257#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN4_FIRRCA1TRAINGAIN4__M 0x7F
14258#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN4_FIRRCA1TRAINGAIN4__PRE 0x0
14259
14260#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN4_FIRRCA1DATAGAIN4__B 8
14261#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN4_FIRRCA1DATAGAIN4__W 7
14262#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN4_FIRRCA1DATAGAIN4__M 0x7F00
14263#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN4_FIRRCA1DATAGAIN4__PRE 0x0
14264
14265#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN5__A 0x1C2007C
14266#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN5__W 15
14267#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN5__M 0x7FFF
14268#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN5__PRE 0x0
14269
14270#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN5_FIRRCA1TRAINGAIN5__B 0
14271#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN5_FIRRCA1TRAINGAIN5__W 7
14272#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN5_FIRRCA1TRAINGAIN5__M 0x7F
14273#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN5_FIRRCA1TRAINGAIN5__PRE 0x0
14274
14275#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN5_FIRRCA1DATAGAIN5__B 8
14276#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN5_FIRRCA1DATAGAIN5__W 7
14277#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN5_FIRRCA1DATAGAIN5__M 0x7F00
14278#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN5_FIRRCA1DATAGAIN5__PRE 0x0
14279
14280#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN6__A 0x1C2007D
14281#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN6__W 15
14282#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN6__M 0x7FFF
14283#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN6__PRE 0x0
14284
14285#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN6_FIRRCA1TRAINGAIN6__B 0
14286#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN6_FIRRCA1TRAINGAIN6__W 7
14287#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN6_FIRRCA1TRAINGAIN6__M 0x7F
14288#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN6_FIRRCA1TRAINGAIN6__PRE 0x0
14289
14290#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN6_FIRRCA1DATAGAIN6__B 8
14291#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN6_FIRRCA1DATAGAIN6__W 7
14292#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN6_FIRRCA1DATAGAIN6__M 0x7F00
14293#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN6_FIRRCA1DATAGAIN6__PRE 0x0
14294
14295#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN7__A 0x1C2007E
14296#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN7__W 15
14297#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN7__M 0x7FFF
14298#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN7__PRE 0x0
14299
14300#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN7_FIRRCA1TRAINGAIN7__B 0
14301#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN7_FIRRCA1TRAINGAIN7__W 7
14302#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN7_FIRRCA1TRAINGAIN7__M 0x7F
14303#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN7_FIRRCA1TRAINGAIN7__PRE 0x0
14304
14305#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN7_FIRRCA1DATAGAIN7__B 8
14306#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN7_FIRRCA1DATAGAIN7__W 7
14307#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN7_FIRRCA1DATAGAIN7__M 0x7F00
14308#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN7_FIRRCA1DATAGAIN7__PRE 0x0
14309
14310#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN8__A 0x1C2007F
14311#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN8__W 15
14312#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN8__M 0x7FFF
14313#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN8__PRE 0x0
14314
14315#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN8_FIRRCA1TRAINGAIN8__B 0
14316#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN8_FIRRCA1TRAINGAIN8__W 7
14317#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN8_FIRRCA1TRAINGAIN8__M 0x7F
14318#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN8_FIRRCA1TRAINGAIN8__PRE 0x0
14319
14320#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN8_FIRRCA1DATAGAIN8__B 8
14321#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN8_FIRRCA1DATAGAIN8__W 7
14322#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN8_FIRRCA1DATAGAIN8__M 0x7F00
14323#define VSB_SYSCTRL_RAM0_FIRRCA1GAIN8_FIRRCA1DATAGAIN8__PRE 0x0
14324
14325#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN9__A 0x1C30000
14326#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN9__W 15
14327#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN9__M 0x7FFF
14328#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN9__PRE 0x0
14329
14330#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN9_FIRRCA1TRAINGAIN9__B 0
14331#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN9_FIRRCA1TRAINGAIN9__W 7
14332#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN9_FIRRCA1TRAINGAIN9__M 0x7F
14333#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN9_FIRRCA1TRAINGAIN9__PRE 0x0
14334
14335#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN9_FIRRCA1DATAGAIN9__B 8
14336#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN9_FIRRCA1DATAGAIN9__W 7
14337#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN9_FIRRCA1DATAGAIN9__M 0x7F00
14338#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN9_FIRRCA1DATAGAIN9__PRE 0x0
14339
14340#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN10__A 0x1C30001
14341#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN10__W 15
14342#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN10__M 0x7FFF
14343#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN10__PRE 0x0
14344
14345#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN10_FIRRCA1TRAINGAIN10__B 0
14346#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN10_FIRRCA1TRAINGAIN10__W 7
14347#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN10_FIRRCA1TRAINGAIN10__M 0x7F
14348#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN10_FIRRCA1TRAINGAIN10__PRE 0x0
14349
14350#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN10_FIRRCA1DATAGAIN10__B 8
14351#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN10_FIRRCA1DATAGAIN10__W 7
14352#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN10_FIRRCA1DATAGAIN10__M 0x7F00
14353#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN10_FIRRCA1DATAGAIN10__PRE 0x0
14354
14355#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN11__A 0x1C30002
14356#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN11__W 15
14357#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN11__M 0x7FFF
14358#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN11__PRE 0x0
14359
14360#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN11_FIRRCA1TRAINGAIN11__B 0
14361#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN11_FIRRCA1TRAINGAIN11__W 7
14362#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN11_FIRRCA1TRAINGAIN11__M 0x7F
14363#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN11_FIRRCA1TRAINGAIN11__PRE 0x0
14364
14365#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN11_FIRRCA1DATAGAIN11__B 8
14366#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN11_FIRRCA1DATAGAIN11__W 7
14367#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN11_FIRRCA1DATAGAIN11__M 0x7F00
14368#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN11_FIRRCA1DATAGAIN11__PRE 0x0
14369
14370#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN12__A 0x1C30003
14371#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN12__W 15
14372#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN12__M 0x7FFF
14373#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN12__PRE 0x0
14374
14375#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN12_FIRRCA1TRAINGAIN12__B 0
14376#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN12_FIRRCA1TRAINGAIN12__W 7
14377#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN12_FIRRCA1TRAINGAIN12__M 0x7F
14378#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN12_FIRRCA1TRAINGAIN12__PRE 0x0
14379
14380#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN12_FIRRCA1DATAGAIN12__B 8
14381#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN12_FIRRCA1DATAGAIN12__W 7
14382#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN12_FIRRCA1DATAGAIN12__M 0x7F00
14383#define VSB_SYSCTRL_RAM1_FIRRCA1GAIN12_FIRRCA1DATAGAIN12__PRE 0x0
14384
14385#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN1__A 0x1C30004
14386#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN1__W 15
14387#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN1__M 0x7FFF
14388#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN1__PRE 0x0
14389
14390#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN1_FIRRCA2TRAINGAIN1__B 0
14391#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN1_FIRRCA2TRAINGAIN1__W 7
14392#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN1_FIRRCA2TRAINGAIN1__M 0x7F
14393#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN1_FIRRCA2TRAINGAIN1__PRE 0x0
14394
14395#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN1_FIRRCA2DATAGAIN1__B 8
14396#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN1_FIRRCA2DATAGAIN1__W 7
14397#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN1_FIRRCA2DATAGAIN1__M 0x7F00
14398#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN1_FIRRCA2DATAGAIN1__PRE 0x0
14399
14400#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN2__A 0x1C30005
14401#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN2__W 15
14402#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN2__M 0x7FFF
14403#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN2__PRE 0x0
14404
14405#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN2_FIRRCA2TRAINGAIN2__B 0
14406#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN2_FIRRCA2TRAINGAIN2__W 7
14407#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN2_FIRRCA2TRAINGAIN2__M 0x7F
14408#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN2_FIRRCA2TRAINGAIN2__PRE 0x0
14409
14410#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN2_FIRRCA2DATAGAIN2__B 8
14411#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN2_FIRRCA2DATAGAIN2__W 7
14412#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN2_FIRRCA2DATAGAIN2__M 0x7F00
14413#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN2_FIRRCA2DATAGAIN2__PRE 0x0
14414
14415#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN3__A 0x1C30006
14416#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN3__W 15
14417#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN3__M 0x7FFF
14418#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN3__PRE 0x0
14419
14420#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN3_FIRRCA2TRAINGAIN3__B 0
14421#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN3_FIRRCA2TRAINGAIN3__W 7
14422#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN3_FIRRCA2TRAINGAIN3__M 0x7F
14423#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN3_FIRRCA2TRAINGAIN3__PRE 0x0
14424
14425#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN3_FIRRCA2DATAGAIN3__B 8
14426#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN3_FIRRCA2DATAGAIN3__W 7
14427#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN3_FIRRCA2DATAGAIN3__M 0x7F00
14428#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN3_FIRRCA2DATAGAIN3__PRE 0x0
14429
14430#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN4__A 0x1C30007
14431#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN4__W 15
14432#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN4__M 0x7FFF
14433#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN4__PRE 0x0
14434
14435#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN4_FIRRCA2TRAINGAIN4__B 0
14436#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN4_FIRRCA2TRAINGAIN4__W 7
14437#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN4_FIRRCA2TRAINGAIN4__M 0x7F
14438#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN4_FIRRCA2TRAINGAIN4__PRE 0x0
14439
14440#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN4_FIRRCA2DATAGAIN4__B 8
14441#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN4_FIRRCA2DATAGAIN4__W 7
14442#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN4_FIRRCA2DATAGAIN4__M 0x7F00
14443#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN4_FIRRCA2DATAGAIN4__PRE 0x0
14444
14445#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN5__A 0x1C30008
14446#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN5__W 15
14447#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN5__M 0x7FFF
14448#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN5__PRE 0x0
14449
14450#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN5_FIRRCA2TRAINGAIN5__B 0
14451#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN5_FIRRCA2TRAINGAIN5__W 7
14452#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN5_FIRRCA2TRAINGAIN5__M 0x7F
14453#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN5_FIRRCA2TRAINGAIN5__PRE 0x0
14454
14455#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN5_FIRRCA2DATAGAIN5__B 8
14456#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN5_FIRRCA2DATAGAIN5__W 7
14457#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN5_FIRRCA2DATAGAIN5__M 0x7F00
14458#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN5_FIRRCA2DATAGAIN5__PRE 0x0
14459
14460#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN6__A 0x1C30009
14461#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN6__W 15
14462#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN6__M 0x7FFF
14463#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN6__PRE 0x0
14464
14465#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN6_FIRRCA2TRAINGAIN6__B 0
14466#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN6_FIRRCA2TRAINGAIN6__W 7
14467#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN6_FIRRCA2TRAINGAIN6__M 0x7F
14468#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN6_FIRRCA2TRAINGAIN6__PRE 0x0
14469
14470#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN6_FIRRCA2DATAGAIN6__B 8
14471#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN6_FIRRCA2DATAGAIN6__W 7
14472#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN6_FIRRCA2DATAGAIN6__M 0x7F00
14473#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN6_FIRRCA2DATAGAIN6__PRE 0x0
14474
14475#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN7__A 0x1C3000A
14476#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN7__W 15
14477#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN7__M 0x7FFF
14478#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN7__PRE 0x0
14479
14480#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN7_FIRRCA2TRAINGAIN7__B 0
14481#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN7_FIRRCA2TRAINGAIN7__W 7
14482#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN7_FIRRCA2TRAINGAIN7__M 0x7F
14483#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN7_FIRRCA2TRAINGAIN7__PRE 0x0
14484
14485#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN7_FIRRCA2DATAGAIN7__B 8
14486#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN7_FIRRCA2DATAGAIN7__W 7
14487#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN7_FIRRCA2DATAGAIN7__M 0x7F00
14488#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN7_FIRRCA2DATAGAIN7__PRE 0x0
14489
14490#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN8__A 0x1C3000B
14491#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN8__W 15
14492#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN8__M 0x7FFF
14493#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN8__PRE 0x0
14494
14495#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN8_FIRRCA2TRAINGAIN8__B 0
14496#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN8_FIRRCA2TRAINGAIN8__W 7
14497#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN8_FIRRCA2TRAINGAIN8__M 0x7F
14498#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN8_FIRRCA2TRAINGAIN8__PRE 0x0
14499
14500#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN8_FIRRCA2DATAGAIN8__B 8
14501#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN8_FIRRCA2DATAGAIN8__W 7
14502#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN8_FIRRCA2DATAGAIN8__M 0x7F00
14503#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN8_FIRRCA2DATAGAIN8__PRE 0x0
14504
14505#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN9__A 0x1C3000C
14506#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN9__W 15
14507#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN9__M 0x7FFF
14508#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN9__PRE 0x0
14509
14510#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN9_FIRRCA2TRAINGAIN9__B 0
14511#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN9_FIRRCA2TRAINGAIN9__W 7
14512#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN9_FIRRCA2TRAINGAIN9__M 0x7F
14513#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN9_FIRRCA2TRAINGAIN9__PRE 0x0
14514
14515#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN9_FIRRCA2DATAGAIN9__B 8
14516#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN9_FIRRCA2DATAGAIN9__W 7
14517#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN9_FIRRCA2DATAGAIN9__M 0x7F00
14518#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN9_FIRRCA2DATAGAIN9__PRE 0x0
14519
14520#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN10__A 0x1C3000D
14521#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN10__W 15
14522#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN10__M 0x7FFF
14523#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN10__PRE 0x0
14524
14525#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN10_FIRRCA2TRAINGAIN10__B 0
14526#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN10_FIRRCA2TRAINGAIN10__W 7
14527#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN10_FIRRCA2TRAINGAIN10__M 0x7F
14528#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN10_FIRRCA2TRAINGAIN10__PRE 0x0
14529
14530#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN10_FIRRCA2DATAGAIN10__B 8
14531#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN10_FIRRCA2DATAGAIN10__W 7
14532#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN10_FIRRCA2DATAGAIN10__M 0x7F00
14533#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN10_FIRRCA2DATAGAIN10__PRE 0x0
14534
14535#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN11__A 0x1C3000E
14536#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN11__W 15
14537#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN11__M 0x7FFF
14538#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN11__PRE 0x0
14539
14540#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN11_FIRRCA2TRAINGAIN11__B 0
14541#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN11_FIRRCA2TRAINGAIN11__W 7
14542#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN11_FIRRCA2TRAINGAIN11__M 0x7F
14543#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN11_FIRRCA2TRAINGAIN11__PRE 0x0
14544
14545#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN11_FIRRCA2DATAGAIN11__B 8
14546#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN11_FIRRCA2DATAGAIN11__W 7
14547#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN11_FIRRCA2DATAGAIN11__M 0x7F00
14548#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN11_FIRRCA2DATAGAIN11__PRE 0x0
14549
14550#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN12__A 0x1C3000F
14551#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN12__W 15
14552#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN12__M 0x7FFF
14553#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN12__PRE 0x0
14554
14555#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN12_FIRRCA2TRAINGAIN12__B 0
14556#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN12_FIRRCA2TRAINGAIN12__W 7
14557#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN12_FIRRCA2TRAINGAIN12__M 0x7F
14558#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN12_FIRRCA2TRAINGAIN12__PRE 0x0
14559
14560#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN12_FIRRCA2DATAGAIN12__B 8
14561#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN12_FIRRCA2DATAGAIN12__W 7
14562#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN12_FIRRCA2DATAGAIN12__M 0x7F00
14563#define VSB_SYSCTRL_RAM1_FIRRCA2GAIN12_FIRRCA2DATAGAIN12__PRE 0x0
14564
14565#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN1__A 0x1C30010
14566#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN1__W 15
14567#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN1__M 0x7FFF
14568#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN1__PRE 0x0
14569
14570#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN1_FIRDDM1TRAINGAIN1__B 0
14571#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN1_FIRDDM1TRAINGAIN1__W 7
14572#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN1_FIRDDM1TRAINGAIN1__M 0x7F
14573#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN1_FIRDDM1TRAINGAIN1__PRE 0x0
14574
14575#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN1_FIRDDM1DATAGAIN1__B 8
14576#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN1_FIRDDM1DATAGAIN1__W 7
14577#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN1_FIRDDM1DATAGAIN1__M 0x7F00
14578#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN1_FIRDDM1DATAGAIN1__PRE 0x0
14579
14580#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN2__A 0x1C30011
14581#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN2__W 15
14582#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN2__M 0x7FFF
14583#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN2__PRE 0x0
14584
14585#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN2_FIRDDM1TRAINGAIN2__B 0
14586#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN2_FIRDDM1TRAINGAIN2__W 7
14587#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN2_FIRDDM1TRAINGAIN2__M 0x7F
14588#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN2_FIRDDM1TRAINGAIN2__PRE 0x0
14589
14590#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN2_FIRDDM1DATAGAIN2__B 8
14591#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN2_FIRDDM1DATAGAIN2__W 7
14592#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN2_FIRDDM1DATAGAIN2__M 0x7F00
14593#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN2_FIRDDM1DATAGAIN2__PRE 0x0
14594
14595#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN3__A 0x1C30012
14596#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN3__W 15
14597#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN3__M 0x7FFF
14598#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN3__PRE 0x0
14599
14600#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN3_FIRDDM1TRAINGAIN3__B 0
14601#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN3_FIRDDM1TRAINGAIN3__W 7
14602#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN3_FIRDDM1TRAINGAIN3__M 0x7F
14603#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN3_FIRDDM1TRAINGAIN3__PRE 0x0
14604
14605#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN3_FIRDDM1DATAGAIN3__B 8
14606#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN3_FIRDDM1DATAGAIN3__W 7
14607#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN3_FIRDDM1DATAGAIN3__M 0x7F00
14608#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN3_FIRDDM1DATAGAIN3__PRE 0x0
14609
14610#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN4__A 0x1C30013
14611#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN4__W 15
14612#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN4__M 0x7FFF
14613#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN4__PRE 0x0
14614
14615#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN4_FIRDDM1TRAINGAIN4__B 0
14616#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN4_FIRDDM1TRAINGAIN4__W 7
14617#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN4_FIRDDM1TRAINGAIN4__M 0x7F
14618#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN4_FIRDDM1TRAINGAIN4__PRE 0x0
14619
14620#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN4_FIRDDM1DATAGAIN4__B 8
14621#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN4_FIRDDM1DATAGAIN4__W 7
14622#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN4_FIRDDM1DATAGAIN4__M 0x7F00
14623#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN4_FIRDDM1DATAGAIN4__PRE 0x0
14624
14625#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN5__A 0x1C30014
14626#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN5__W 15
14627#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN5__M 0x7FFF
14628#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN5__PRE 0x0
14629
14630#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN5_FIRDDM1TRAINGAIN5__B 0
14631#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN5_FIRDDM1TRAINGAIN5__W 7
14632#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN5_FIRDDM1TRAINGAIN5__M 0x7F
14633#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN5_FIRDDM1TRAINGAIN5__PRE 0x0
14634
14635#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN5_FIRDDM1DATAGAIN5__B 8
14636#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN5_FIRDDM1DATAGAIN5__W 7
14637#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN5_FIRDDM1DATAGAIN5__M 0x7F00
14638#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN5_FIRDDM1DATAGAIN5__PRE 0x0
14639
14640#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN6__A 0x1C30015
14641#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN6__W 15
14642#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN6__M 0x7FFF
14643#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN6__PRE 0x0
14644
14645#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN6_FIRDDM1TRAINGAIN6__B 0
14646#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN6_FIRDDM1TRAINGAIN6__W 7
14647#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN6_FIRDDM1TRAINGAIN6__M 0x7F
14648#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN6_FIRDDM1TRAINGAIN6__PRE 0x0
14649
14650#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN6_FIRDDM1DATAGAIN6__B 8
14651#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN6_FIRDDM1DATAGAIN6__W 7
14652#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN6_FIRDDM1DATAGAIN6__M 0x7F00
14653#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN6_FIRDDM1DATAGAIN6__PRE 0x0
14654
14655#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN7__A 0x1C30016
14656#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN7__W 15
14657#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN7__M 0x7FFF
14658#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN7__PRE 0x0
14659
14660#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN7_FIRDDM1TRAINGAIN7__B 0
14661#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN7_FIRDDM1TRAINGAIN7__W 7
14662#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN7_FIRDDM1TRAINGAIN7__M 0x7F
14663#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN7_FIRDDM1TRAINGAIN7__PRE 0x0
14664
14665#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN7_FIRDDM1DATAGAIN7__B 8
14666#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN7_FIRDDM1DATAGAIN7__W 7
14667#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN7_FIRDDM1DATAGAIN7__M 0x7F00
14668#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN7_FIRDDM1DATAGAIN7__PRE 0x0
14669
14670#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN8__A 0x1C30017
14671#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN8__W 15
14672#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN8__M 0x7FFF
14673#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN8__PRE 0x0
14674
14675#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN8_FIRDDM1TRAINGAIN8__B 0
14676#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN8_FIRDDM1TRAINGAIN8__W 7
14677#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN8_FIRDDM1TRAINGAIN8__M 0x7F
14678#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN8_FIRDDM1TRAINGAIN8__PRE 0x0
14679
14680#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN8_FIRDDM1DATAGAIN8__B 8
14681#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN8_FIRDDM1DATAGAIN8__W 7
14682#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN8_FIRDDM1DATAGAIN8__M 0x7F00
14683#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN8_FIRDDM1DATAGAIN8__PRE 0x0
14684
14685#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN9__A 0x1C30018
14686#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN9__W 15
14687#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN9__M 0x7FFF
14688#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN9__PRE 0x0
14689
14690#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN9_FIRDDM1TRAINGAIN9__B 0
14691#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN9_FIRDDM1TRAINGAIN9__W 7
14692#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN9_FIRDDM1TRAINGAIN9__M 0x7F
14693#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN9_FIRDDM1TRAINGAIN9__PRE 0x0
14694
14695#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN9_FIRDDM1DATAGAIN9__B 8
14696#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN9_FIRDDM1DATAGAIN9__W 7
14697#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN9_FIRDDM1DATAGAIN9__M 0x7F00
14698#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN9_FIRDDM1DATAGAIN9__PRE 0x0
14699
14700#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN10__A 0x1C30019
14701#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN10__W 15
14702#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN10__M 0x7FFF
14703#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN10__PRE 0x0
14704
14705#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN10_FIRDDM1TRAINGAIN10__B 0
14706#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN10_FIRDDM1TRAINGAIN10__W 7
14707#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN10_FIRDDM1TRAINGAIN10__M 0x7F
14708#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN10_FIRDDM1TRAINGAIN10__PRE 0x0
14709
14710#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN10_FIRDDM1DATAGAIN10__B 8
14711#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN10_FIRDDM1DATAGAIN10__W 7
14712#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN10_FIRDDM1DATAGAIN10__M 0x7F00
14713#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN10_FIRDDM1DATAGAIN10__PRE 0x0
14714
14715#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN11__A 0x1C3001A
14716#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN11__W 15
14717#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN11__M 0x7FFF
14718#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN11__PRE 0x0
14719
14720#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN11_FIRDDM1TRAINGAIN11__B 0
14721#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN11_FIRDDM1TRAINGAIN11__W 7
14722#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN11_FIRDDM1TRAINGAIN11__M 0x7F
14723#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN11_FIRDDM1TRAINGAIN11__PRE 0x0
14724
14725#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN11_FIRDDM1DATAGAIN11__B 8
14726#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN11_FIRDDM1DATAGAIN11__W 7
14727#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN11_FIRDDM1DATAGAIN11__M 0x7F00
14728#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN11_FIRDDM1DATAGAIN11__PRE 0x0
14729
14730#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN12__A 0x1C3001B
14731#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN12__W 15
14732#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN12__M 0x7FFF
14733#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN12__PRE 0x0
14734
14735#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN12_FIRDDM1TRAINGAIN12__B 0
14736#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN12_FIRDDM1TRAINGAIN12__W 7
14737#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN12_FIRDDM1TRAINGAIN12__M 0x7F
14738#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN12_FIRDDM1TRAINGAIN12__PRE 0x0
14739
14740#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN12_FIRDDM1DATAGAIN12__B 8
14741#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN12_FIRDDM1DATAGAIN12__W 7
14742#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN12_FIRDDM1DATAGAIN12__M 0x7F00
14743#define VSB_SYSCTRL_RAM1_FIRDDM1GAIN12_FIRDDM1DATAGAIN12__PRE 0x0
14744
14745#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN1__A 0x1C3001C
14746#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN1__W 15
14747#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN1__M 0x7FFF
14748#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN1__PRE 0x0
14749
14750#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN1_FIRDDM2TRAINGAIN1__B 0
14751#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN1_FIRDDM2TRAINGAIN1__W 7
14752#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN1_FIRDDM2TRAINGAIN1__M 0x7F
14753#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN1_FIRDDM2TRAINGAIN1__PRE 0x0
14754
14755#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN1_FIRDDM2DATAGAIN1__B 8
14756#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN1_FIRDDM2DATAGAIN1__W 7
14757#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN1_FIRDDM2DATAGAIN1__M 0x7F00
14758#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN1_FIRDDM2DATAGAIN1__PRE 0x0
14759
14760#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN2__A 0x1C3001D
14761#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN2__W 15
14762#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN2__M 0x7FFF
14763#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN2__PRE 0x0
14764
14765#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN2_FIRDDM2TRAINGAIN2__B 0
14766#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN2_FIRDDM2TRAINGAIN2__W 7
14767#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN2_FIRDDM2TRAINGAIN2__M 0x7F
14768#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN2_FIRDDM2TRAINGAIN2__PRE 0x0
14769
14770#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN2_FIRDDM2DATAGAIN2__B 8
14771#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN2_FIRDDM2DATAGAIN2__W 7
14772#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN2_FIRDDM2DATAGAIN2__M 0x7F00
14773#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN2_FIRDDM2DATAGAIN2__PRE 0x0
14774
14775#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN3__A 0x1C3001E
14776#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN3__W 15
14777#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN3__M 0x7FFF
14778#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN3__PRE 0x0
14779
14780#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN3_FIRDDM2TRAINGAIN3__B 0
14781#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN3_FIRDDM2TRAINGAIN3__W 7
14782#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN3_FIRDDM2TRAINGAIN3__M 0x7F
14783#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN3_FIRDDM2TRAINGAIN3__PRE 0x0
14784
14785#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN3_FIRDDM2DATAGAIN3__B 8
14786#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN3_FIRDDM2DATAGAIN3__W 7
14787#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN3_FIRDDM2DATAGAIN3__M 0x7F00
14788#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN3_FIRDDM2DATAGAIN3__PRE 0x0
14789
14790#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN4__A 0x1C3001F
14791#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN4__W 15
14792#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN4__M 0x7FFF
14793#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN4__PRE 0x0
14794
14795#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN4_FIRDDM2TRAINGAIN4__B 0
14796#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN4_FIRDDM2TRAINGAIN4__W 7
14797#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN4_FIRDDM2TRAINGAIN4__M 0x7F
14798#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN4_FIRDDM2TRAINGAIN4__PRE 0x0
14799
14800#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN4_FIRDDM2DATAGAIN4__B 8
14801#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN4_FIRDDM2DATAGAIN4__W 7
14802#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN4_FIRDDM2DATAGAIN4__M 0x7F00
14803#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN4_FIRDDM2DATAGAIN4__PRE 0x0
14804
14805#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN5__A 0x1C30020
14806#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN5__W 15
14807#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN5__M 0x7FFF
14808#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN5__PRE 0x0
14809
14810#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN5_FIRDDM2TRAINGAIN5__B 0
14811#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN5_FIRDDM2TRAINGAIN5__W 7
14812#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN5_FIRDDM2TRAINGAIN5__M 0x7F
14813#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN5_FIRDDM2TRAINGAIN5__PRE 0x0
14814
14815#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN5_FIRDDM2DATAGAIN5__B 8
14816#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN5_FIRDDM2DATAGAIN5__W 7
14817#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN5_FIRDDM2DATAGAIN5__M 0x7F00
14818#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN5_FIRDDM2DATAGAIN5__PRE 0x0
14819
14820#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN6__A 0x1C30021
14821#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN6__W 15
14822#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN6__M 0x7FFF
14823#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN6__PRE 0x0
14824
14825#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN6_FIRDDM2TRAINGAIN6__B 0
14826#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN6_FIRDDM2TRAINGAIN6__W 7
14827#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN6_FIRDDM2TRAINGAIN6__M 0x7F
14828#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN6_FIRDDM2TRAINGAIN6__PRE 0x0
14829
14830#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN6_FIRDDM2DATAGAIN6__B 8
14831#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN6_FIRDDM2DATAGAIN6__W 7
14832#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN6_FIRDDM2DATAGAIN6__M 0x7F00
14833#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN6_FIRDDM2DATAGAIN6__PRE 0x0
14834
14835#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN7__A 0x1C30022
14836#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN7__W 15
14837#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN7__M 0x7FFF
14838#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN7__PRE 0x0
14839
14840#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN7_FIRDDM2TRAINGAIN7__B 0
14841#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN7_FIRDDM2TRAINGAIN7__W 7
14842#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN7_FIRDDM2TRAINGAIN7__M 0x7F
14843#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN7_FIRDDM2TRAINGAIN7__PRE 0x0
14844
14845#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN7_FIRDDM2DATAGAIN7__B 8
14846#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN7_FIRDDM2DATAGAIN7__W 7
14847#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN7_FIRDDM2DATAGAIN7__M 0x7F00
14848#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN7_FIRDDM2DATAGAIN7__PRE 0x0
14849
14850#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN8__A 0x1C30023
14851#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN8__W 15
14852#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN8__M 0x7FFF
14853#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN8__PRE 0x0
14854
14855#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN8_FIRDDM2TRAINGAIN8__B 0
14856#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN8_FIRDDM2TRAINGAIN8__W 7
14857#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN8_FIRDDM2TRAINGAIN8__M 0x7F
14858#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN8_FIRDDM2TRAINGAIN8__PRE 0x0
14859
14860#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN8_FIRDDM2DATAGAIN8__B 8
14861#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN8_FIRDDM2DATAGAIN8__W 7
14862#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN8_FIRDDM2DATAGAIN8__M 0x7F00
14863#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN8_FIRDDM2DATAGAIN8__PRE 0x0
14864
14865#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN9__A 0x1C30024
14866#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN9__W 15
14867#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN9__M 0x7FFF
14868#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN9__PRE 0x0
14869
14870#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN9_FIRDDM2TRAINGAIN9__B 0
14871#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN9_FIRDDM2TRAINGAIN9__W 7
14872#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN9_FIRDDM2TRAINGAIN9__M 0x7F
14873#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN9_FIRDDM2TRAINGAIN9__PRE 0x0
14874
14875#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN9_FIRDDM2DATAGAIN9__B 8
14876#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN9_FIRDDM2DATAGAIN9__W 7
14877#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN9_FIRDDM2DATAGAIN9__M 0x7F00
14878#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN9_FIRDDM2DATAGAIN9__PRE 0x0
14879
14880#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN10__A 0x1C30025
14881#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN10__W 15
14882#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN10__M 0x7FFF
14883#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN10__PRE 0x0
14884
14885#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN10_FIRDDM2TRAINGAIN10__B 0
14886#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN10_FIRDDM2TRAINGAIN10__W 7
14887#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN10_FIRDDM2TRAINGAIN10__M 0x7F
14888#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN10_FIRDDM2TRAINGAIN10__PRE 0x0
14889
14890#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN10_FIRDDM2DATAGAIN10__B 8
14891#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN10_FIRDDM2DATAGAIN10__W 7
14892#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN10_FIRDDM2DATAGAIN10__M 0x7F00
14893#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN10_FIRDDM2DATAGAIN10__PRE 0x0
14894
14895#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN11__A 0x1C30026
14896#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN11__W 15
14897#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN11__M 0x7FFF
14898#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN11__PRE 0x0
14899
14900#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN11_FIRDDM2TRAINGAIN11__B 0
14901#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN11_FIRDDM2TRAINGAIN11__W 7
14902#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN11_FIRDDM2TRAINGAIN11__M 0x7F
14903#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN11_FIRDDM2TRAINGAIN11__PRE 0x0
14904
14905#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN11_FIRDDM2DATAGAIN11__B 8
14906#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN11_FIRDDM2DATAGAIN11__W 7
14907#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN11_FIRDDM2DATAGAIN11__M 0x7F00
14908#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN11_FIRDDM2DATAGAIN11__PRE 0x0
14909
14910#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN12__A 0x1C30027
14911#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN12__W 15
14912#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN12__M 0x7FFF
14913#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN12__PRE 0x0
14914
14915#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN12_FIRDDM2TRAINGAIN12__B 0
14916#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN12_FIRDDM2TRAINGAIN12__W 7
14917#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN12_FIRDDM2TRAINGAIN12__M 0x7F
14918#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN12_FIRDDM2TRAINGAIN12__PRE 0x0
14919
14920#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN12_FIRDDM2DATAGAIN12__B 8
14921#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN12_FIRDDM2DATAGAIN12__W 7
14922#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN12_FIRDDM2DATAGAIN12__M 0x7F00
14923#define VSB_SYSCTRL_RAM1_FIRDDM2GAIN12_FIRDDM2DATAGAIN12__PRE 0x0
14924
14925#define VSB_SYSCTRL_RAM1_DFETRAINLKRATIO__A 0x1C30028
14926#define VSB_SYSCTRL_RAM1_DFETRAINLKRATIO__W 12
14927#define VSB_SYSCTRL_RAM1_DFETRAINLKRATIO__M 0xFFF
14928#define VSB_SYSCTRL_RAM1_DFETRAINLKRATIO__PRE 0x0
14929
14930#define VSB_SYSCTRL_RAM1_DFERCA1TRAINLKRATIO__A 0x1C30029
14931#define VSB_SYSCTRL_RAM1_DFERCA1TRAINLKRATIO__W 12
14932#define VSB_SYSCTRL_RAM1_DFERCA1TRAINLKRATIO__M 0xFFF
14933#define VSB_SYSCTRL_RAM1_DFERCA1TRAINLKRATIO__PRE 0x0
14934
14935#define VSB_SYSCTRL_RAM1_DFERCA1DATALKRATIO__A 0x1C3002A
14936#define VSB_SYSCTRL_RAM1_DFERCA1DATALKRATIO__W 12
14937#define VSB_SYSCTRL_RAM1_DFERCA1DATALKRATIO__M 0xFFF
14938#define VSB_SYSCTRL_RAM1_DFERCA1DATALKRATIO__PRE 0x0
14939
14940#define VSB_SYSCTRL_RAM1_DFERCA2TRAINLKRATIO__A 0x1C3002B
14941#define VSB_SYSCTRL_RAM1_DFERCA2TRAINLKRATIO__W 12
14942#define VSB_SYSCTRL_RAM1_DFERCA2TRAINLKRATIO__M 0xFFF
14943#define VSB_SYSCTRL_RAM1_DFERCA2TRAINLKRATIO__PRE 0x0
14944
14945#define VSB_SYSCTRL_RAM1_DFERCA2DATALKRATIO__A 0x1C3002C
14946#define VSB_SYSCTRL_RAM1_DFERCA2DATALKRATIO__W 12
14947#define VSB_SYSCTRL_RAM1_DFERCA2DATALKRATIO__M 0xFFF
14948#define VSB_SYSCTRL_RAM1_DFERCA2DATALKRATIO__PRE 0x0
14949
14950#define VSB_SYSCTRL_RAM1_DFEDDM1TRAINLKRATIO__A 0x1C3002D
14951#define VSB_SYSCTRL_RAM1_DFEDDM1TRAINLKRATIO__W 12
14952#define VSB_SYSCTRL_RAM1_DFEDDM1TRAINLKRATIO__M 0xFFF
14953#define VSB_SYSCTRL_RAM1_DFEDDM1TRAINLKRATIO__PRE 0x0
14954
14955#define VSB_SYSCTRL_RAM1_DFEDDM1DATALKRATIO__A 0x1C3002E
14956#define VSB_SYSCTRL_RAM1_DFEDDM1DATALKRATIO__W 12
14957#define VSB_SYSCTRL_RAM1_DFEDDM1DATALKRATIO__M 0xFFF
14958#define VSB_SYSCTRL_RAM1_DFEDDM1DATALKRATIO__PRE 0x0
14959
14960#define VSB_SYSCTRL_RAM1_DFEDDM2TRAINLKRATIO__A 0x1C3002F
14961#define VSB_SYSCTRL_RAM1_DFEDDM2TRAINLKRATIO__W 12
14962#define VSB_SYSCTRL_RAM1_DFEDDM2TRAINLKRATIO__M 0xFFF
14963#define VSB_SYSCTRL_RAM1_DFEDDM2TRAINLKRATIO__PRE 0x0
14964
14965#define VSB_SYSCTRL_RAM1_DFEDDM2DATALKRATIO__A 0x1C30030
14966#define VSB_SYSCTRL_RAM1_DFEDDM2DATALKRATIO__W 12
14967#define VSB_SYSCTRL_RAM1_DFEDDM2DATALKRATIO__M 0xFFF
14968#define VSB_SYSCTRL_RAM1_DFEDDM2DATALKRATIO__PRE 0x0
14969
14970#define VSB_SYSCTRL_RAM1_DFETRAINGAIN__A 0x1C30031
14971#define VSB_SYSCTRL_RAM1_DFETRAINGAIN__W 7
14972#define VSB_SYSCTRL_RAM1_DFETRAINGAIN__M 0x7F
14973#define VSB_SYSCTRL_RAM1_DFETRAINGAIN__PRE 0x0
14974#define VSB_SYSCTRL_RAM1_DFERCA1GAIN__A 0x1C30032
14975#define VSB_SYSCTRL_RAM1_DFERCA1GAIN__W 15
14976#define VSB_SYSCTRL_RAM1_DFERCA1GAIN__M 0x7FFF
14977#define VSB_SYSCTRL_RAM1_DFERCA1GAIN__PRE 0x0
14978
14979#define VSB_SYSCTRL_RAM1_DFERCA1GAIN_DFERCA1TRAINGAIN__B 0
14980#define VSB_SYSCTRL_RAM1_DFERCA1GAIN_DFERCA1TRAINGAIN__W 7
14981#define VSB_SYSCTRL_RAM1_DFERCA1GAIN_DFERCA1TRAINGAIN__M 0x7F
14982#define VSB_SYSCTRL_RAM1_DFERCA1GAIN_DFERCA1TRAINGAIN__PRE 0x0
14983
14984#define VSB_SYSCTRL_RAM1_DFERCA1GAIN_DFERCA1DATAGAIN__B 8
14985#define VSB_SYSCTRL_RAM1_DFERCA1GAIN_DFERCA1DATAGAIN__W 7
14986#define VSB_SYSCTRL_RAM1_DFERCA1GAIN_DFERCA1DATAGAIN__M 0x7F00
14987#define VSB_SYSCTRL_RAM1_DFERCA1GAIN_DFERCA1DATAGAIN__PRE 0x0
14988
14989#define VSB_SYSCTRL_RAM1_DFERCA2GAIN__A 0x1C30033
14990#define VSB_SYSCTRL_RAM1_DFERCA2GAIN__W 15
14991#define VSB_SYSCTRL_RAM1_DFERCA2GAIN__M 0x7FFF
14992#define VSB_SYSCTRL_RAM1_DFERCA2GAIN__PRE 0x0
14993
14994#define VSB_SYSCTRL_RAM1_DFERCA2GAIN_DFERCA2TRAINGAIN__B 0
14995#define VSB_SYSCTRL_RAM1_DFERCA2GAIN_DFERCA2TRAINGAIN__W 7
14996#define VSB_SYSCTRL_RAM1_DFERCA2GAIN_DFERCA2TRAINGAIN__M 0x7F
14997#define VSB_SYSCTRL_RAM1_DFERCA2GAIN_DFERCA2TRAINGAIN__PRE 0x0
14998
14999#define VSB_SYSCTRL_RAM1_DFERCA2GAIN_DFERCA2DATAGAIN__B 8
15000#define VSB_SYSCTRL_RAM1_DFERCA2GAIN_DFERCA2DATAGAIN__W 7
15001#define VSB_SYSCTRL_RAM1_DFERCA2GAIN_DFERCA2DATAGAIN__M 0x7F00
15002#define VSB_SYSCTRL_RAM1_DFERCA2GAIN_DFERCA2DATAGAIN__PRE 0x0
15003
15004#define VSB_SYSCTRL_RAM1_DFEDDM1GAIN__A 0x1C30034
15005#define VSB_SYSCTRL_RAM1_DFEDDM1GAIN__W 15
15006#define VSB_SYSCTRL_RAM1_DFEDDM1GAIN__M 0x7FFF
15007#define VSB_SYSCTRL_RAM1_DFEDDM1GAIN__PRE 0x0
15008
15009#define VSB_SYSCTRL_RAM1_DFEDDM1GAIN_DFEDDM1TRAINGAIN__B 0
15010#define VSB_SYSCTRL_RAM1_DFEDDM1GAIN_DFEDDM1TRAINGAIN__W 7
15011#define VSB_SYSCTRL_RAM1_DFEDDM1GAIN_DFEDDM1TRAINGAIN__M 0x7F
15012#define VSB_SYSCTRL_RAM1_DFEDDM1GAIN_DFEDDM1TRAINGAIN__PRE 0x0
15013
15014#define VSB_SYSCTRL_RAM1_DFEDDM1GAIN_DFEDDM1DATAGAIN__B 8
15015#define VSB_SYSCTRL_RAM1_DFEDDM1GAIN_DFEDDM1DATAGAIN__W 7
15016#define VSB_SYSCTRL_RAM1_DFEDDM1GAIN_DFEDDM1DATAGAIN__M 0x7F00
15017#define VSB_SYSCTRL_RAM1_DFEDDM1GAIN_DFEDDM1DATAGAIN__PRE 0x0
15018
15019#define VSB_SYSCTRL_RAM1_DFEDDM2GAIN__A 0x1C30035
15020#define VSB_SYSCTRL_RAM1_DFEDDM2GAIN__W 15
15021#define VSB_SYSCTRL_RAM1_DFEDDM2GAIN__M 0x7FFF
15022#define VSB_SYSCTRL_RAM1_DFEDDM2GAIN__PRE 0x0
15023
15024#define VSB_SYSCTRL_RAM1_DFEDDM2GAIN_DFEDDM2TRAINGAIN__B 0
15025#define VSB_SYSCTRL_RAM1_DFEDDM2GAIN_DFEDDM2TRAINGAIN__W 7
15026#define VSB_SYSCTRL_RAM1_DFEDDM2GAIN_DFEDDM2TRAINGAIN__M 0x7F
15027#define VSB_SYSCTRL_RAM1_DFEDDM2GAIN_DFEDDM2TRAINGAIN__PRE 0x0
15028
15029#define VSB_SYSCTRL_RAM1_DFEDDM2GAIN_DFEDDM2DATAGAIN__B 8
15030#define VSB_SYSCTRL_RAM1_DFEDDM2GAIN_DFEDDM2DATAGAIN__W 7
15031#define VSB_SYSCTRL_RAM1_DFEDDM2GAIN_DFEDDM2DATAGAIN__M 0x7F00
15032#define VSB_SYSCTRL_RAM1_DFEDDM2GAIN_DFEDDM2DATAGAIN__PRE 0x0
15033
15034#define VSB_TCMEQ_RAM__A 0x1C40000
15035
15036#define VSB_TCMEQ_RAM_TCMEQ_RAM__B 0
15037#define VSB_TCMEQ_RAM_TCMEQ_RAM__W 16
15038#define VSB_TCMEQ_RAM_TCMEQ_RAM__M 0xFFFF
15039#define VSB_TCMEQ_RAM_TCMEQ_RAM__PRE 0x0
15040
15041#define VSB_FCPRE_RAM__A 0x1C50000
15042
15043#define VSB_FCPRE_RAM_FCPRE_RAM__B 0
15044#define VSB_FCPRE_RAM_FCPRE_RAM__W 16
15045#define VSB_FCPRE_RAM_FCPRE_RAM__M 0xFFFF
15046#define VSB_FCPRE_RAM_FCPRE_RAM__PRE 0x0
15047
15048#define VSB_EQTAP_RAM__A 0x1C60000
15049
15050#define VSB_EQTAP_RAM_EQTAP_RAM__B 0
15051#define VSB_EQTAP_RAM_EQTAP_RAM__W 12
15052#define VSB_EQTAP_RAM_EQTAP_RAM__M 0xFFF
15053#define VSB_EQTAP_RAM_EQTAP_RAM__PRE 0x0
15054
15055#endif
diff --git a/drivers/media/dvb-frontends/drxd_hard.c b/drivers/media/dvb-frontends/drxd_hard.c
index 959ae36403b8..5b87ece69414 100644
--- a/drivers/media/dvb-frontends/drxd_hard.c
+++ b/drivers/media/dvb-frontends/drxd_hard.c
@@ -2688,11 +2688,11 @@ static int DRXD_init(struct drxd_state *state, const u8 *fw, u32 fw_size)
2688 status = EnableAndResetMB(state); 2688 status = EnableAndResetMB(state);
2689 if (status < 0) 2689 if (status < 0)
2690 break; 2690 break;
2691 if (state->type_A) 2691 if (state->type_A) {
2692 status = ResetCEFR(state); 2692 status = ResetCEFR(state);
2693 if (status < 0) 2693 if (status < 0)
2694 break; 2694 break;
2695 2695 }
2696 if (fw) { 2696 if (fw) {
2697 status = DownloadMicrocode(state, fw, fw_size); 2697 status = DownloadMicrocode(state, fw, fw_size);
2698 if (status < 0) 2698 if (status < 0)
diff --git a/drivers/media/dvb-frontends/ds3000.c b/drivers/media/dvb-frontends/ds3000.c
index 1e344b033277..335daeff91b9 100644
--- a/drivers/media/dvb-frontends/ds3000.c
+++ b/drivers/media/dvb-frontends/ds3000.c
@@ -616,7 +616,7 @@ static int ds3000_read_snr(struct dvb_frontend *fe, u16 *snr)
616 snr_reading = dvbs2_noise_reading / tmp; 616 snr_reading = dvbs2_noise_reading / tmp;
617 if (snr_reading > 80) 617 if (snr_reading > 80)
618 snr_reading = 80; 618 snr_reading = 80;
619 *snr = -(dvbs2_snr_tab[snr_reading] / 1000); 619 *snr = -(dvbs2_snr_tab[snr_reading - 1] / 1000);
620 } 620 }
621 dprintk("%s: raw / cooked = 0x%02x / 0x%04x\n", __func__, 621 dprintk("%s: raw / cooked = 0x%02x / 0x%04x\n", __func__,
622 snr_reading, *snr); 622 snr_reading, *snr);
diff --git a/drivers/media/dvb-frontends/it913x-fe-priv.h b/drivers/media/dvb-frontends/it913x-fe-priv.h
deleted file mode 100644
index eb6fd8aebdb3..000000000000
--- a/drivers/media/dvb-frontends/it913x-fe-priv.h
+++ /dev/null
@@ -1,1051 +0,0 @@
1
2struct it913xset { u32 pro;
3 u32 address;
4 u8 reg[15];
5 u8 count;
6};
7
8struct adctable { u32 adcFrequency;
9 u32 bandwidth;
10 u32 coeff_1_2048;
11 u32 coeff_1_4096;
12 u32 coeff_1_8191;
13 u32 coeff_1_8192;
14 u32 coeff_1_8193;
15 u32 coeff_2_2k;
16 u32 coeff_2_4k;
17 u32 coeff_2_8k;
18 u16 bfsfcw_fftinx_ratio;
19 u16 fftinx_bfsfcw_ratio;
20};
21
22/* clock and coeff tables only table 3 is used with IT9137*/
23/* TODO other tables relate AF9035 may be removed */
24static struct adctable tab1[] = {
25 { 20156250, 6000000,
26 0x02b8ba6e, 0x015c5d37, 0x00ae340d, 0x00ae2e9b, 0x00ae292a,
27 0x015c5d37, 0x00ae2e9b, 0x0057174e, 0x02f1, 0x015c },
28 { 20156250, 7000000,
29 0x032cd980, 0x01966cc0, 0x00cb3cba, 0x00cb3660, 0x00cb3007,
30 0x01966cc0, 0x00cb3660, 0x00659b30, 0x0285, 0x0196 },
31 { 20156250, 8000000,
32 0x03a0f893, 0x01d07c49, 0x00e84567, 0x00e83e25, 0x00e836e3,
33 0x01d07c49, 0x00e83e25, 0x00741f12, 0x0234, 0x01d0 },
34 { 20156250, 5000000,
35 0x02449b5c, 0x01224dae, 0x00912b60, 0x009126d7, 0x0091224e,
36 0x01224dae, 0x009126d7, 0x0048936b, 0x0387, 0x0122 }
37};
38
39static struct adctable tab2[] = {
40 { 20187500, 6000000,
41 0x02b7a654, 0x015bd32a, 0x00adef04, 0x00ade995, 0x00ade426,
42 0x015bd32a, 0x00ade995, 0x0056f4ca, 0x02f2, 0x015c },
43 { 20187500, 7000000,
44 0x032b9761, 0x0195cbb1, 0x00caec30, 0x00cae5d8, 0x00cadf81,
45 0x0195cbb1, 0x00cae5d8, 0x006572ec, 0x0286, 0x0196 },
46 { 20187500, 8000000,
47 0x039f886f, 0x01cfc438, 0x00e7e95b, 0x00e7e21c, 0x00e7dadd,
48 0x01cfc438, 0x00e7e21c, 0x0073f10e, 0x0235, 0x01d0 },
49 { 20187500, 5000000,
50 0x0243b546, 0x0121daa3, 0x0090f1d9, 0x0090ed51, 0x0090e8ca,
51 0x0121daa3, 0x0090ed51, 0x004876a9, 0x0388, 0x0122 }
52
53};
54
55static struct adctable tab3[] = {
56 { 20250000, 6000000,
57 0x02b580ad, 0x015ac057, 0x00ad6597, 0x00ad602b, 0x00ad5ac1,
58 0x015ac057, 0x00ad602b, 0x0056b016, 0x02f4, 0x015b },
59 { 20250000, 7000000,
60 0x03291620, 0x01948b10, 0x00ca4bda, 0x00ca4588, 0x00ca3f36,
61 0x01948b10, 0x00ca4588, 0x006522c4, 0x0288, 0x0195 },
62 { 20250000, 8000000,
63 0x039cab92, 0x01ce55c9, 0x00e7321e, 0x00e72ae4, 0x00e723ab,
64 0x01ce55c9, 0x00e72ae4, 0x00739572, 0x0237, 0x01ce },
65 { 20250000, 5000000,
66 0x0241eb3b, 0x0120f59e, 0x00907f53, 0x00907acf, 0x0090764b,
67 0x0120f59e, 0x00907acf, 0x00483d67, 0x038b, 0x0121 }
68
69};
70
71static struct adctable tab4[] = {
72 { 20583333, 6000000,
73 0x02aa4598, 0x015522cc, 0x00aa96bb, 0x00aa9166, 0x00aa8c12,
74 0x015522cc, 0x00aa9166, 0x005548b3, 0x0300, 0x0155 },
75 { 20583333, 7000000,
76 0x031bfbdc, 0x018dfdee, 0x00c7052f, 0x00c6fef7, 0x00c6f8bf,
77 0x018dfdee, 0x00c6fef7, 0x00637f7b, 0x0293, 0x018e },
78 { 20583333, 8000000,
79 0x038db21f, 0x01c6d910, 0x00e373a3, 0x00e36c88, 0x00e3656d,
80 0x01c6d910, 0x00e36c88, 0x0071b644, 0x0240, 0x01c7 },
81 { 20583333, 5000000,
82 0x02388f54, 0x011c47aa, 0x008e2846, 0x008e23d5, 0x008e1f64,
83 0x011c47aa, 0x008e23d5, 0x004711ea, 0x039a, 0x011c }
84
85};
86
87static struct adctable tab5[] = {
88 { 20416667, 6000000,
89 0x02afd765, 0x0157ebb3, 0x00abfb39, 0x00abf5d9, 0x00abf07a,
90 0x0157ebb3, 0x00abf5d9, 0x0055faed, 0x02fa, 0x0158 },
91 { 20416667, 7000000,
92 0x03227b4b, 0x01913da6, 0x00c8a518, 0x00c89ed3, 0x00c8988e,
93 0x01913da6, 0x00c89ed3, 0x00644f69, 0x028d, 0x0191 },
94 { 20416667, 8000000,
95 0x03951f32, 0x01ca8f99, 0x00e54ef7, 0x00e547cc, 0x00e540a2,
96 0x01ca8f99, 0x00e547cc, 0x0072a3e6, 0x023c, 0x01cb },
97 { 20416667, 5000000,
98 0x023d337f, 0x011e99c0, 0x008f515a, 0x008f4ce0, 0x008f4865,
99 0x011e99c0, 0x008f4ce0, 0x0047a670, 0x0393, 0x011f }
100
101};
102
103static struct adctable tab6[] = {
104 { 20480000, 6000000,
105 0x02adb6db, 0x0156db6e, 0x00ab7312, 0x00ab6db7, 0x00ab685c,
106 0x0156db6e, 0x00ab6db7, 0x0055b6db, 0x02fd, 0x0157 },
107 { 20480000, 7000000,
108 0x03200000, 0x01900000, 0x00c80640, 0x00c80000, 0x00c7f9c0,
109 0x01900000, 0x00c80000, 0x00640000, 0x028f, 0x0190 },
110 { 20480000, 8000000,
111 0x03924925, 0x01c92492, 0x00e4996e, 0x00e49249, 0x00e48b25,
112 0x01c92492, 0x00e49249, 0x00724925, 0x023d, 0x01c9 },
113 { 20480000, 5000000,
114 0x023b6db7, 0x011db6db, 0x008edfe5, 0x008edb6e, 0x008ed6f7,
115 0x011db6db, 0x008edb6e, 0x00476db7, 0x0396, 0x011e }
116};
117
118static struct adctable tab7[] = {
119 { 20500000, 6000000,
120 0x02ad0b99, 0x015685cc, 0x00ab4840, 0x00ab42e6, 0x00ab3d8c,
121 0x015685cc, 0x00ab42e6, 0x0055a173, 0x02fd, 0x0157 },
122 { 20500000, 7000000,
123 0x031f3832, 0x018f9c19, 0x00c7d44b, 0x00c7ce0c, 0x00c7c7ce,
124 0x018f9c19, 0x00c7ce0c, 0x0063e706, 0x0290, 0x0190 },
125 { 20500000, 8000000,
126 0x039164cb, 0x01c8b266, 0x00e46056, 0x00e45933, 0x00e45210,
127 0x01c8b266, 0x00e45933, 0x00722c99, 0x023e, 0x01c9 },
128 { 20500000, 5000000,
129 0x023adeff, 0x011d6f80, 0x008ebc36, 0x008eb7c0, 0x008eb34a,
130 0x011d6f80, 0x008eb7c0, 0x00475be0, 0x0396, 0x011d }
131
132};
133
134static struct adctable tab8[] = {
135 { 20625000, 6000000,
136 0x02a8e4bd, 0x0154725e, 0x00aa3e81, 0x00aa392f, 0x00aa33de,
137 0x0154725e, 0x00aa392f, 0x00551c98, 0x0302, 0x0154 },
138 { 20625000, 7000000,
139 0x031a6032, 0x018d3019, 0x00c69e41, 0x00c6980c, 0x00c691d8,
140 0x018d3019, 0x00c6980c, 0x00634c06, 0x0294, 0x018d },
141 { 20625000, 8000000,
142 0x038bdba6, 0x01c5edd3, 0x00e2fe02, 0x00e2f6ea, 0x00e2efd2,
143 0x01c5edd3, 0x00e2f6ea, 0x00717b75, 0x0242, 0x01c6 },
144 { 20625000, 5000000,
145 0x02376948, 0x011bb4a4, 0x008ddec1, 0x008dda52, 0x008dd5e3,
146 0x011bb4a4, 0x008dda52, 0x0046ed29, 0x039c, 0x011c }
147
148};
149
150struct table {
151 u32 xtal;
152 struct adctable *table;
153};
154
155static struct table fe_clockTable[] = {
156 {12000000, tab3}, /* 12.00MHz */
157 {20480000, tab6}, /* 20.48MHz */
158 {36000000, tab3}, /* 36.00MHz */
159 {30000000, tab1}, /* 30.00MHz */
160 {26000000, tab4}, /* 26.00MHz */
161 {28000000, tab5}, /* 28.00MHz */
162 {32000000, tab7}, /* 32.00MHz */
163 {34000000, tab2}, /* 34.00MHz */
164 {24000000, tab1}, /* 24.00MHz */
165 {22000000, tab8}, /* 22.00MHz */
166};
167
168/* fe get */
169fe_code_rate_t fe_code[] = {
170 FEC_1_2,
171 FEC_2_3,
172 FEC_3_4,
173 FEC_5_6,
174 FEC_7_8,
175 FEC_NONE,
176};
177
178fe_guard_interval_t fe_gi[] = {
179 GUARD_INTERVAL_1_32,
180 GUARD_INTERVAL_1_16,
181 GUARD_INTERVAL_1_8,
182 GUARD_INTERVAL_1_4,
183};
184
185fe_hierarchy_t fe_hi[] = {
186 HIERARCHY_NONE,
187 HIERARCHY_1,
188 HIERARCHY_2,
189 HIERARCHY_4,
190};
191
192fe_transmit_mode_t fe_mode[] = {
193 TRANSMISSION_MODE_2K,
194 TRANSMISSION_MODE_8K,
195 TRANSMISSION_MODE_4K,
196};
197
198fe_modulation_t fe_con[] = {
199 QPSK,
200 QAM_16,
201 QAM_64,
202};
203
204enum {
205 PRIORITY_HIGH = 0, /* High-priority stream */
206 PRIORITY_LOW, /* Low-priority stream */
207};
208
209/* Standard demodulator functions */
210static struct it913xset set_solo_fe[] = {
211 {PRO_LINK, GPIOH5_EN, {0x01}, 0x01},
212 {PRO_LINK, GPIOH5_ON, {0x01}, 0x01},
213 {PRO_LINK, GPIOH5_O, {0x00}, 0x01},
214 {PRO_LINK, GPIOH5_O, {0x01}, 0x01},
215 {PRO_LINK, DVBT_INTEN, {0x04}, 0x01},
216 {PRO_LINK, DVBT_ENABLE, {0x05}, 0x01},
217 {PRO_DMOD, MP2IF_MPEG_PAR_MODE, {0x00}, 0x01},
218 {PRO_LINK, HOSTB_MPEG_SER_MODE, {0x00}, 0x01},
219 {PRO_LINK, HOSTB_MPEG_PAR_MODE, {0x00}, 0x01},
220 {PRO_DMOD, DCA_UPPER_CHIP, {0x00}, 0x01},
221 {PRO_LINK, HOSTB_DCA_UPPER, {0x00}, 0x01},
222 {PRO_DMOD, DCA_LOWER_CHIP, {0x00}, 0x01},
223 {PRO_LINK, HOSTB_DCA_LOWER, {0x00}, 0x01},
224 {PRO_DMOD, DCA_PLATCH, {0x00}, 0x01},
225 {PRO_DMOD, DCA_FPGA_LATCH, {0x00}, 0x01},
226 {PRO_DMOD, DCA_STAND_ALONE, {0x01}, 0x01},
227 {PRO_DMOD, DCA_ENABLE, {0x00}, 0x01},
228 {PRO_DMOD, MP2IF_MPEG_PAR_MODE, {0x00}, 0x01},
229 {PRO_DMOD, BFS_FCW, {0x00, 0x00, 0x00}, 0x03},
230 {0xff, 0x0000, {0x00}, 0x00}, /* Terminating Entry */
231};
232
233
234static struct it913xset init_1[] = {
235 {PRO_LINK, LOCK3_OUT, {0x01}, 0x01},
236 {PRO_LINK, PADMISCDRSR, {0x01}, 0x01},
237 {PRO_LINK, PADMISCDR2, {0x00}, 0x01},
238 {PRO_DMOD, 0xec57, {0x00, 0x00}, 0x02},
239 {PRO_LINK, PADMISCDR4, {0x00}, 0x01}, /* Power up */
240 {PRO_LINK, PADMISCDR8, {0x00}, 0x01},
241 {0xff, 0x0000, {0x00}, 0x00} /* Terminating Entry */
242};
243
244
245/* Version 1 types */
246static struct it913xset it9135_v1[] = {
247 {PRO_DMOD, 0x0051, {0x01}, 0x01},
248 {PRO_DMOD, 0x0070, {0x0a}, 0x01},
249 {PRO_DMOD, 0x007e, {0x04}, 0x01},
250 {PRO_DMOD, 0x0081, {0x0a}, 0x01},
251 {PRO_DMOD, 0x008a, {0x01}, 0x01},
252 {PRO_DMOD, 0x008e, {0x01}, 0x01},
253 {PRO_DMOD, 0x0092, {0x06}, 0x01},
254 {PRO_DMOD, 0x0099, {0x01}, 0x01},
255 {PRO_DMOD, 0x009f, {0xe1}, 0x01},
256 {PRO_DMOD, 0x00a0, {0xcf}, 0x01},
257 {PRO_DMOD, 0x00a3, {0x01}, 0x01},
258 {PRO_DMOD, 0x00a5, {0x01}, 0x01},
259 {PRO_DMOD, 0x00a6, {0x01}, 0x01},
260 {PRO_DMOD, 0x00a9, {0x00}, 0x01},
261 {PRO_DMOD, 0x00aa, {0x01}, 0x01},
262 {PRO_DMOD, 0x00b0, {0x01}, 0x01},
263 {PRO_DMOD, 0x00c2, {0x05}, 0x01},
264 {PRO_DMOD, 0x00c6, {0x19}, 0x01},
265 {PRO_DMOD, 0xf000, {0x0f}, 0x01},
266 {PRO_DMOD, 0xf016, {0x10}, 0x01},
267 {PRO_DMOD, 0xf017, {0x04}, 0x01},
268 {PRO_DMOD, 0xf018, {0x05}, 0x01},
269 {PRO_DMOD, 0xf019, {0x04}, 0x01},
270 {PRO_DMOD, 0xf01a, {0x05}, 0x01},
271 {PRO_DMOD, 0xf021, {0x03}, 0x01},
272 {PRO_DMOD, 0xf022, {0x0a}, 0x01},
273 {PRO_DMOD, 0xf023, {0x0a}, 0x01},
274 {PRO_DMOD, 0xf02b, {0x00}, 0x01},
275 {PRO_DMOD, 0xf02c, {0x01}, 0x01},
276 {PRO_DMOD, 0xf064, {0x03}, 0x01},
277 {PRO_DMOD, 0xf065, {0xf9}, 0x01},
278 {PRO_DMOD, 0xf066, {0x03}, 0x01},
279 {PRO_DMOD, 0xf067, {0x01}, 0x01},
280 {PRO_DMOD, 0xf06f, {0xe0}, 0x01},
281 {PRO_DMOD, 0xf070, {0x03}, 0x01},
282 {PRO_DMOD, 0xf072, {0x0f}, 0x01},
283 {PRO_DMOD, 0xf073, {0x03}, 0x01},
284 {PRO_DMOD, 0xf078, {0x00}, 0x01},
285 {PRO_DMOD, 0xf087, {0x00}, 0x01},
286 {PRO_DMOD, 0xf09b, {0x3f}, 0x01},
287 {PRO_DMOD, 0xf09c, {0x00}, 0x01},
288 {PRO_DMOD, 0xf09d, {0x20}, 0x01},
289 {PRO_DMOD, 0xf09e, {0x00}, 0x01},
290 {PRO_DMOD, 0xf09f, {0x0c}, 0x01},
291 {PRO_DMOD, 0xf0a0, {0x00}, 0x01},
292 {PRO_DMOD, 0xf130, {0x04}, 0x01},
293 {PRO_DMOD, 0xf132, {0x04}, 0x01},
294 {PRO_DMOD, 0xf144, {0x1a}, 0x01},
295 {PRO_DMOD, 0xf146, {0x00}, 0x01},
296 {PRO_DMOD, 0xf14a, {0x01}, 0x01},
297 {PRO_DMOD, 0xf14c, {0x00}, 0x01},
298 {PRO_DMOD, 0xf14d, {0x00}, 0x01},
299 {PRO_DMOD, 0xf14f, {0x04}, 0x01},
300 {PRO_DMOD, 0xf158, {0x7f}, 0x01},
301 {PRO_DMOD, 0xf15a, {0x00}, 0x01},
302 {PRO_DMOD, 0xf15b, {0x08}, 0x01},
303 {PRO_DMOD, 0xf15d, {0x03}, 0x01},
304 {PRO_DMOD, 0xf15e, {0x05}, 0x01},
305 {PRO_DMOD, 0xf163, {0x05}, 0x01},
306 {PRO_DMOD, 0xf166, {0x01}, 0x01},
307 {PRO_DMOD, 0xf167, {0x40}, 0x01},
308 {PRO_DMOD, 0xf168, {0x0f}, 0x01},
309 {PRO_DMOD, 0xf17a, {0x00}, 0x01},
310 {PRO_DMOD, 0xf17b, {0x00}, 0x01},
311 {PRO_DMOD, 0xf183, {0x01}, 0x01},
312 {PRO_DMOD, 0xf19d, {0x40}, 0x01},
313 {PRO_DMOD, 0xf1bc, {0x36}, 0x01},
314 {PRO_DMOD, 0xf1bd, {0x00}, 0x01},
315 {PRO_DMOD, 0xf1cb, {0xa0}, 0x01},
316 {PRO_DMOD, 0xf1cc, {0x01}, 0x01},
317 {PRO_DMOD, 0xf204, {0x10}, 0x01},
318 {PRO_DMOD, 0xf214, {0x00}, 0x01},
319 {PRO_DMOD, 0xf40e, {0x0a}, 0x01},
320 {PRO_DMOD, 0xf40f, {0x40}, 0x01},
321 {PRO_DMOD, 0xf410, {0x08}, 0x01},
322 {PRO_DMOD, 0xf55f, {0x0a}, 0x01},
323 {PRO_DMOD, 0xf561, {0x15}, 0x01},
324 {PRO_DMOD, 0xf562, {0x20}, 0x01},
325 {PRO_DMOD, 0xf5df, {0xfb}, 0x01},
326 {PRO_DMOD, 0xf5e0, {0x00}, 0x01},
327 {PRO_DMOD, 0xf5e3, {0x09}, 0x01},
328 {PRO_DMOD, 0xf5e4, {0x01}, 0x01},
329 {PRO_DMOD, 0xf5e5, {0x01}, 0x01},
330 {PRO_DMOD, 0xf5f8, {0x01}, 0x01},
331 {PRO_DMOD, 0xf5fd, {0x01}, 0x01},
332 {PRO_DMOD, 0xf600, {0x05}, 0x01},
333 {PRO_DMOD, 0xf601, {0x08}, 0x01},
334 {PRO_DMOD, 0xf602, {0x0b}, 0x01},
335 {PRO_DMOD, 0xf603, {0x0e}, 0x01},
336 {PRO_DMOD, 0xf604, {0x11}, 0x01},
337 {PRO_DMOD, 0xf605, {0x14}, 0x01},
338 {PRO_DMOD, 0xf606, {0x17}, 0x01},
339 {PRO_DMOD, 0xf607, {0x1f}, 0x01},
340 {PRO_DMOD, 0xf60e, {0x00}, 0x01},
341 {PRO_DMOD, 0xf60f, {0x04}, 0x01},
342 {PRO_DMOD, 0xf610, {0x32}, 0x01},
343 {PRO_DMOD, 0xf611, {0x10}, 0x01},
344 {PRO_DMOD, 0xf707, {0xfc}, 0x01},
345 {PRO_DMOD, 0xf708, {0x00}, 0x01},
346 {PRO_DMOD, 0xf709, {0x37}, 0x01},
347 {PRO_DMOD, 0xf70a, {0x00}, 0x01},
348 {PRO_DMOD, 0xf78b, {0x01}, 0x01},
349 {PRO_DMOD, 0xf80f, {0x40}, 0x01},
350 {PRO_DMOD, 0xf810, {0x54}, 0x01},
351 {PRO_DMOD, 0xf811, {0x5a}, 0x01},
352 {PRO_DMOD, 0xf905, {0x01}, 0x01},
353 {PRO_DMOD, 0xfb06, {0x03}, 0x01},
354 {PRO_DMOD, 0xfd8b, {0x00}, 0x01},
355 {0xff, 0x0000, {0x00}, 0x00} /* Terminating Entry */
356};
357
358static struct it913xset it9135_38[] = {
359 {PRO_DMOD, 0x0043, {0x00}, 0x01},
360 {PRO_DMOD, 0x0046, {0x38}, 0x01},
361 {PRO_DMOD, 0x0051, {0x01}, 0x01},
362 {PRO_DMOD, 0x005f, {0x00, 0x00}, 0x02},
363 {PRO_DMOD, 0x0068, {0x0a}, 0x01},
364 {PRO_DMOD, 0x0070, {0x0a, 0x05, 0x02}, 0x03},
365 {PRO_DMOD, 0x0075, {0x8c, 0x8c, 0x8c, 0xc8, 0x01}, 0x05},
366 {PRO_DMOD, 0x007e, {0x04, 0x00}, 0x02},
367 {PRO_DMOD, 0x0081, { 0x0a, 0x12, 0x02, 0x0a, 0x03, 0xc8, 0xb8,
368 0xd0, 0xc3, 0x01}, 0x0a},
369 {PRO_DMOD, 0x008e, {0x01}, 0x01},
370 {PRO_DMOD, 0x0092, {0x06, 0x00, 0x00, 0x00, 0x00}, 0x05},
371 {PRO_DMOD, 0x0099, {0x01}, 0x01},
372 {PRO_DMOD, 0x009b, {0x3c, 0x28}, 0x02},
373 {PRO_DMOD, 0x009f, {0xe1, 0xcf}, 0x02},
374 {PRO_DMOD, 0x00a3, {0x01, 0x5a, 0x01, 0x01}, 0x04},
375 {PRO_DMOD, 0x00a9, {0x00, 0x01}, 0x02},
376 {PRO_DMOD, 0x00b0, {0x01}, 0x01},
377 {PRO_DMOD, 0x00b3, {0x02, 0x32}, 0x02},
378 {PRO_DMOD, 0x00b6, {0x14}, 0x01},
379 {PRO_DMOD, 0x00c0, {0x11, 0x00, 0x05}, 0x03},
380 {PRO_DMOD, 0x00c4, {0x00}, 0x01},
381 {PRO_DMOD, 0x00c6, {0x19, 0x00}, 0x02},
382 {PRO_DMOD, 0x00cc, {0x2e, 0x51, 0x33}, 0x03},
383 {PRO_DMOD, 0x00f3, {0x05, 0x8c, 0x8c}, 0x03},
384 {PRO_DMOD, 0x00f8, {0x03, 0x06, 0x06}, 0x03},
385 {PRO_DMOD, 0x00fc, { 0x02, 0x02, 0x02, 0x09, 0x50, 0x7b, 0x77,
386 0x00, 0x02, 0xc8, 0x05, 0x7b}, 0x0c},
387 {PRO_DMOD, 0x0109, {0x02}, 0x01},
388 {PRO_DMOD, 0x0115, {0x0a, 0x03, 0x02, 0x80}, 0x04},
389 {PRO_DMOD, 0x011a, {0xc8, 0x7b, 0x8a, 0xa0}, 0x04},
390 {PRO_DMOD, 0x0122, {0x02, 0x18, 0xc3}, 0x03},
391 {PRO_DMOD, 0x0127, {0x00, 0x07}, 0x02},
392 {PRO_DMOD, 0x012a, {0x53, 0x51, 0x4e, 0x43}, 0x04},
393 {PRO_DMOD, 0x0137, {0x01, 0x00, 0x07, 0x00, 0x06}, 0x05},
394 {PRO_DMOD, 0x013d, {0x00, 0x01, 0x5b, 0xc8, 0x59}, 0x05},
395 {PRO_DMOD, 0xf000, {0x0f}, 0x01},
396 {PRO_DMOD, 0xf016, {0x10, 0x04, 0x05, 0x04, 0x05}, 0x05},
397 {PRO_DMOD, 0xf01f, {0x8c, 0x00, 0x03, 0x0a, 0x0a}, 0x05},
398 {PRO_DMOD, 0xf029, {0x8c, 0x00, 0x00, 0x01}, 0x04},
399 {PRO_DMOD, 0xf064, {0x03, 0xf9, 0x03, 0x01}, 0x04},
400 {PRO_DMOD, 0xf06f, {0xe0, 0x03}, 0x02},
401 {PRO_DMOD, 0xf072, {0x0f, 0x03}, 0x02},
402 {PRO_DMOD, 0xf077, {0x01, 0x00}, 0x02},
403 {PRO_DMOD, 0xf085, {0x00, 0x02, 0x00}, 0x03},
404 {PRO_DMOD, 0xf09b, {0x3f, 0x00, 0x20, 0x00, 0x0c, 0x00}, 0x06},
405 {PRO_DMOD, 0xf130, {0x04}, 0x01},
406 {PRO_DMOD, 0xf132, {0x04}, 0x01},
407 {PRO_DMOD, 0xf144, {0x1a}, 0x01},
408 {PRO_DMOD, 0xf146, {0x00}, 0x01},
409 {PRO_DMOD, 0xf14a, {0x01}, 0x01},
410 {PRO_DMOD, 0xf14c, {0x00, 0x00}, 0x02},
411 {PRO_DMOD, 0xf14f, {0x04}, 0x01},
412 {PRO_DMOD, 0xf158, {0x7f}, 0x01},
413 {PRO_DMOD, 0xf15a, {0x00, 0x08}, 0x02},
414 {PRO_DMOD, 0xf15d, {0x03, 0x05}, 0x02},
415 {PRO_DMOD, 0xf163, {0x05}, 0x01},
416 {PRO_DMOD, 0xf166, {0x01, 0x40, 0x0f}, 0x03},
417 {PRO_DMOD, 0xf17a, {0x00, 0x00}, 0x02},
418 {PRO_DMOD, 0xf183, {0x01}, 0x01},
419 {PRO_DMOD, 0xf19d, {0x40}, 0x01},
420 {PRO_DMOD, 0xf1bc, {0x36, 0x00}, 0x02},
421 {PRO_DMOD, 0xf1cb, {0xa0, 0x01}, 0x02},
422 {PRO_DMOD, 0xf204, {0x10}, 0x01},
423 {PRO_DMOD, 0xf214, {0x00}, 0x01},
424 {PRO_DMOD, 0xf24c, {0x88, 0x95, 0x9a, 0x90}, 0x04},
425 {PRO_DMOD, 0xf25a, {0x07, 0xe8, 0x03, 0xb0, 0x04}, 0x05},
426 {PRO_DMOD, 0xf270, {0x01, 0x02, 0x01, 0x02}, 0x04},
427 {PRO_DMOD, 0xf40e, {0x0a, 0x40, 0x08}, 0x03},
428 {PRO_DMOD, 0xf55f, {0x0a}, 0x01},
429 {PRO_DMOD, 0xf561, {0x15, 0x20}, 0x02},
430 {PRO_DMOD, 0xf5df, {0xfb, 0x00}, 0x02},
431 {PRO_DMOD, 0xf5e3, {0x09, 0x01, 0x01}, 0x03},
432 {PRO_DMOD, 0xf5f8, {0x01}, 0x01},
433 {PRO_DMOD, 0xf5fd, {0x01}, 0x01},
434 {PRO_DMOD, 0xf600, { 0x05, 0x08, 0x0b, 0x0e, 0x11, 0x14, 0x17,
435 0x1f}, 0x08},
436 {PRO_DMOD, 0xf60e, {0x00, 0x04, 0x32, 0x10}, 0x04},
437 {PRO_DMOD, 0xf707, {0xfc, 0x00, 0x37, 0x00}, 0x04},
438 {PRO_DMOD, 0xf78b, {0x01}, 0x01},
439 {PRO_DMOD, 0xf80f, {0x40, 0x54, 0x5a}, 0x03},
440 {PRO_DMOD, 0xf905, {0x01}, 0x01},
441 {PRO_DMOD, 0xfb06, {0x03}, 0x01},
442 {PRO_DMOD, 0xfd8b, {0x00}, 0x01},
443 {0xff, 0x0000, {0x00}, 0x00} /* Terminating Entry */
444};
445
446static struct it913xset it9135_51[] = {
447 {PRO_DMOD, 0x0043, {0x00}, 0x01},
448 {PRO_DMOD, 0x0046, {0x51}, 0x01},
449 {PRO_DMOD, 0x0051, {0x01}, 0x01},
450 {PRO_DMOD, 0x005f, {0x00, 0x00}, 0x02},
451 {PRO_DMOD, 0x0068, {0x0a}, 0x01},
452 {PRO_DMOD, 0x0070, {0x0a, 0x06, 0x02}, 0x03},
453 {PRO_DMOD, 0x0075, {0x8c, 0x8c, 0x8c, 0xc8, 0x01}, 0x05},
454 {PRO_DMOD, 0x007e, {0x04, 0x00}, 0x02},
455 {PRO_DMOD, 0x0081, { 0x0a, 0x12, 0x02, 0x0a, 0x03, 0xc0, 0x96,
456 0xcf, 0xc3, 0x01}, 0x0a},
457 {PRO_DMOD, 0x008e, {0x01}, 0x01},
458 {PRO_DMOD, 0x0092, {0x06, 0x00, 0x00, 0x00, 0x00}, 0x05},
459 {PRO_DMOD, 0x0099, {0x01}, 0x01},
460 {PRO_DMOD, 0x009b, {0x3c, 0x28}, 0x02},
461 {PRO_DMOD, 0x009f, {0xe1, 0xcf}, 0x02},
462 {PRO_DMOD, 0x00a3, {0x01, 0x5a, 0x01, 0x01}, 0x04},
463 {PRO_DMOD, 0x00a9, {0x00, 0x01}, 0x02},
464 {PRO_DMOD, 0x00b0, {0x01}, 0x01},
465 {PRO_DMOD, 0x00b3, {0x02, 0x3c}, 0x02},
466 {PRO_DMOD, 0x00b6, {0x14}, 0x01},
467 {PRO_DMOD, 0x00c0, {0x11, 0x00, 0x05}, 0x03},
468 {PRO_DMOD, 0x00c4, {0x00}, 0x01},
469 {PRO_DMOD, 0x00c6, {0x19, 0x00}, 0x02},
470 {PRO_DMOD, 0x00cc, {0x2e, 0x51, 0x33}, 0x03},
471 {PRO_DMOD, 0x00f3, {0x05, 0x8c, 0x8c}, 0x03},
472 {PRO_DMOD, 0x00f8, {0x03, 0x06, 0x06}, 0x03},
473 {PRO_DMOD, 0x00fc, { 0x03, 0x02, 0x02, 0x09, 0x50, 0x7a, 0x77,
474 0x01, 0x02, 0xb0, 0x02, 0x7a}, 0x0c},
475 {PRO_DMOD, 0x0109, {0x02}, 0x01},
476 {PRO_DMOD, 0x0115, {0x0a, 0x03, 0x02, 0x80}, 0x04},
477 {PRO_DMOD, 0x011a, {0xc0, 0x7a, 0xac, 0x8c}, 0x04},
478 {PRO_DMOD, 0x0122, {0x02, 0x70, 0xa4}, 0x03},
479 {PRO_DMOD, 0x0127, {0x00, 0x07}, 0x02},
480 {PRO_DMOD, 0x012a, {0x53, 0x51, 0x4e, 0x43}, 0x04},
481 {PRO_DMOD, 0x0137, {0x01, 0x00, 0x07, 0x00, 0x06}, 0x05},
482 {PRO_DMOD, 0x013d, {0x00, 0x01, 0x5b, 0xc0, 0x59}, 0x05},
483 {PRO_DMOD, 0xf000, {0x0f}, 0x01},
484 {PRO_DMOD, 0xf016, {0x10, 0x04, 0x05, 0x04, 0x05}, 0x05},
485 {PRO_DMOD, 0xf01f, {0x8c, 0x00, 0x03, 0x0a, 0x0a}, 0x05},
486 {PRO_DMOD, 0xf029, {0x8c, 0x00, 0x00, 0x01}, 0x04},
487 {PRO_DMOD, 0xf064, {0x03, 0xf9, 0x03, 0x01}, 0x04},
488 {PRO_DMOD, 0xf06f, {0xe0, 0x03}, 0x02},
489 {PRO_DMOD, 0xf072, {0x0f, 0x03}, 0x02},
490 {PRO_DMOD, 0xf077, {0x01, 0x00}, 0x02},
491 {PRO_DMOD, 0xf085, {0xc0, 0x01, 0x00}, 0x03},
492 {PRO_DMOD, 0xf09b, {0x3f, 0x00, 0x20, 0x00, 0x0c, 0x00}, 0x06},
493 {PRO_DMOD, 0xf130, {0x04}, 0x01},
494 {PRO_DMOD, 0xf132, {0x04}, 0x01},
495 {PRO_DMOD, 0xf144, {0x1a}, 0x01},
496 {PRO_DMOD, 0xf146, {0x00}, 0x01},
497 {PRO_DMOD, 0xf14a, {0x01}, 0x01},
498 {PRO_DMOD, 0xf14c, {0x00, 0x00}, 0x02},
499 {PRO_DMOD, 0xf14f, {0x04}, 0x01},
500 {PRO_DMOD, 0xf158, {0x7f}, 0x01},
501 {PRO_DMOD, 0xf15a, {0x00, 0x08}, 0x02},
502 {PRO_DMOD, 0xf15d, {0x03, 0x05}, 0x02},
503 {PRO_DMOD, 0xf163, {0x05}, 0x01},
504 {PRO_DMOD, 0xf166, {0x01, 0x40, 0x0f}, 0x03},
505 {PRO_DMOD, 0xf17a, {0x00, 0x00}, 0x02},
506 {PRO_DMOD, 0xf183, {0x01}, 0x01},
507 {PRO_DMOD, 0xf19d, {0x40}, 0x01},
508 {PRO_DMOD, 0xf1bc, {0x36, 0x00}, 0x02},
509 {PRO_DMOD, 0xf1cb, {0xa0, 0x01}, 0x02},
510 {PRO_DMOD, 0xf204, {0x10}, 0x01},
511 {PRO_DMOD, 0xf214, {0x00}, 0x01},
512 {PRO_DMOD, 0xf24c, {0x88, 0x95, 0x9a, 0x90}, 0x04},
513 {PRO_DMOD, 0xf25a, {0x07, 0xe8, 0x03, 0xb0, 0x04}, 0x05},
514 {PRO_DMOD, 0xf270, {0x01, 0x02, 0x01, 0x02}, 0x04},
515 {PRO_DMOD, 0xf40e, {0x0a, 0x40, 0x08}, 0x03},
516 {PRO_DMOD, 0xf55f, {0x0a}, 0x01},
517 {PRO_DMOD, 0xf561, {0x15, 0x20}, 0x02},
518 {PRO_DMOD, 0xf5df, {0xfb, 0x00}, 0x02},
519 {PRO_DMOD, 0xf5e3, {0x09, 0x01, 0x01}, 0x03},
520 {PRO_DMOD, 0xf5f8, {0x01}, 0x01},
521 {PRO_DMOD, 0xf5fd, {0x01}, 0x01},
522 {PRO_DMOD, 0xf600, { 0x05, 0x08, 0x0b, 0x0e, 0x11, 0x14, 0x17,
523 0x1f}, 0x08},
524 {PRO_DMOD, 0xf60e, {0x00, 0x04, 0x32, 0x10}, 0x04},
525 {PRO_DMOD, 0xf707, {0xfc, 0x00, 0x37, 0x00}, 0x04},
526 {PRO_DMOD, 0xf78b, {0x01}, 0x01},
527 {PRO_DMOD, 0xf80f, {0x40, 0x54, 0x5a}, 0x03},
528 {PRO_DMOD, 0xf905, {0x01}, 0x01},
529 {PRO_DMOD, 0xfb06, {0x03}, 0x01},
530 {PRO_DMOD, 0xfd8b, {0x00}, 0x01},
531 {0xff, 0x0000, {0x00}, 0x00} /* Terminating Entry */
532};
533
534static struct it913xset it9135_52[] = {
535 {PRO_DMOD, 0x0043, {0x00}, 0x01},
536 {PRO_DMOD, 0x0046, {0x52}, 0x01},
537 {PRO_DMOD, 0x0051, {0x01}, 0x01},
538 {PRO_DMOD, 0x005f, {0x00, 0x00}, 0x02},
539 {PRO_DMOD, 0x0068, {0x10}, 0x01},
540 {PRO_DMOD, 0x0070, {0x0a, 0x05, 0x02}, 0x03},
541 {PRO_DMOD, 0x0075, {0x8c, 0x8c, 0x8c, 0xa0, 0x01}, 0x05},
542 {PRO_DMOD, 0x007e, {0x04, 0x00}, 0x02},
543 {PRO_DMOD, 0x0081, { 0x0a, 0x12, 0x03, 0x0a, 0x03, 0xb3, 0x97,
544 0xc0, 0x9e, 0x01}, 0x0a},
545 {PRO_DMOD, 0x008e, {0x01}, 0x01},
546 {PRO_DMOD, 0x0092, {0x06, 0x00, 0x00, 0x00, 0x00}, 0x05},
547 {PRO_DMOD, 0x0099, {0x01}, 0x01},
548 {PRO_DMOD, 0x009b, {0x3c, 0x28}, 0x02},
549 {PRO_DMOD, 0x009f, {0xe1, 0xcf}, 0x02},
550 {PRO_DMOD, 0x00a3, {0x01, 0x5c, 0x01, 0x01}, 0x04},
551 {PRO_DMOD, 0x00a9, {0x00, 0x01}, 0x02},
552 {PRO_DMOD, 0x00b0, {0x01}, 0x01},
553 {PRO_DMOD, 0x00b3, {0x02, 0x3c}, 0x02},
554 {PRO_DMOD, 0x00b6, {0x14}, 0x01},
555 {PRO_DMOD, 0x00c0, {0x11, 0x00, 0x05}, 0x03},
556 {PRO_DMOD, 0x00c4, {0x00}, 0x01},
557 {PRO_DMOD, 0x00c6, {0x19, 0x00}, 0x02},
558 {PRO_DMOD, 0x00cc, {0x2e, 0x51, 0x33}, 0x03},
559 {PRO_DMOD, 0x00f3, {0x05, 0x91, 0x8c}, 0x03},
560 {PRO_DMOD, 0x00f8, {0x03, 0x06, 0x06}, 0x03},
561 {PRO_DMOD, 0x00fc, { 0x03, 0x02, 0x02, 0x09, 0x50, 0x74, 0x77,
562 0x02, 0x02, 0xae, 0x02, 0x6e}, 0x0c},
563 {PRO_DMOD, 0x0109, {0x02}, 0x01},
564 {PRO_DMOD, 0x0115, {0x0a, 0x03, 0x02, 0x80}, 0x04},
565 {PRO_DMOD, 0x011a, {0xcd, 0x62, 0xa4, 0x8c}, 0x04},
566 {PRO_DMOD, 0x0122, {0x03, 0x18, 0x9e}, 0x03},
567 {PRO_DMOD, 0x0127, {0x00, 0x07}, 0x02},
568 {PRO_DMOD, 0x012a, {0x53, 0x51, 0x4e, 0x43}, 0x04},
569 {PRO_DMOD, 0x0137, {0x00, 0x00, 0x07, 0x00, 0x06}, 0x05},
570 {PRO_DMOD, 0x013d, {0x00, 0x01, 0x5b, 0xb6, 0x59}, 0x05},
571 {PRO_DMOD, 0xf000, {0x0f}, 0x01},
572 {PRO_DMOD, 0xf016, {0x10, 0x04, 0x05, 0x04, 0x05}, 0x05},
573 {PRO_DMOD, 0xf01f, {0x8c, 0x00, 0x03, 0x0a, 0x0a}, 0x05},
574 {PRO_DMOD, 0xf029, {0x8c, 0x00, 0x00, 0x01}, 0x04},
575 {PRO_DMOD, 0xf064, {0x03, 0xf9, 0x03, 0x01}, 0x04},
576 {PRO_DMOD, 0xf06f, {0xe0, 0x03}, 0x02},
577 {PRO_DMOD, 0xf072, {0x0f, 0x03}, 0x02},
578 {PRO_DMOD, 0xf077, {0x01, 0x00}, 0x02},
579 {PRO_DMOD, 0xf085, {0xc0, 0x01, 0x00}, 0x03},
580 {PRO_DMOD, 0xf09b, {0x3f, 0x00, 0x20, 0x00, 0x0c, 0x00}, 0x06},
581 {PRO_DMOD, 0xf130, {0x04}, 0x01},
582 {PRO_DMOD, 0xf132, {0x04}, 0x01},
583 {PRO_DMOD, 0xf144, {0x1a}, 0x01},
584 {PRO_DMOD, 0xf146, {0x00}, 0x01},
585 {PRO_DMOD, 0xf14a, {0x01}, 0x01},
586 {PRO_DMOD, 0xf14c, {0x00, 0x00}, 0x02},
587 {PRO_DMOD, 0xf14f, {0x04}, 0x01},
588 {PRO_DMOD, 0xf158, {0x7f}, 0x01},
589 {PRO_DMOD, 0xf15a, {0x00, 0x08}, 0x02},
590 {PRO_DMOD, 0xf15d, {0x03, 0x05}, 0x02},
591 {PRO_DMOD, 0xf163, {0x05}, 0x01},
592 {PRO_DMOD, 0xf166, {0x01, 0x40, 0x0f}, 0x03},
593 {PRO_DMOD, 0xf17a, {0x00, 0x00}, 0x02},
594 {PRO_DMOD, 0xf183, {0x01}, 0x01},
595 {PRO_DMOD, 0xf19d, {0x40}, 0x01},
596 {PRO_DMOD, 0xf1bc, {0x36, 0x00}, 0x02},
597 {PRO_DMOD, 0xf1cb, {0xa0, 0x01}, 0x02},
598 {PRO_DMOD, 0xf204, {0x10}, 0x01},
599 {PRO_DMOD, 0xf214, {0x00}, 0x01},
600 {PRO_DMOD, 0xf24c, {0x88, 0x95, 0x9a, 0x90}, 0x04},
601 {PRO_DMOD, 0xf25a, {0x07, 0xe8, 0x03, 0xb0, 0x04}, 0x05},
602 {PRO_DMOD, 0xf270, {0x01, 0x02, 0x01, 0x02}, 0x04},
603 {PRO_DMOD, 0xf40e, {0x0a, 0x40, 0x08}, 0x03},
604 {PRO_DMOD, 0xf55f, {0x0a}, 0x01},
605 {PRO_DMOD, 0xf561, {0x15, 0x20}, 0x02},
606 {PRO_DMOD, 0xf5df, {0xfb, 0x00}, 0x02},
607 {PRO_DMOD, 0xf5e3, {0x09, 0x01, 0x01}, 0x03},
608 {PRO_DMOD, 0xf5f8, {0x01}, 0x01},
609 {PRO_DMOD, 0xf5fd, {0x01}, 0x01},
610 {PRO_DMOD, 0xf600, {0x05, 0x08, 0x0b, 0x0e, 0x11, 0x14, 0x17,
611 0x1f}, 0x08},
612 {PRO_DMOD, 0xf60e, {0x00, 0x04, 0x32, 0x10}, 0x04},
613 {PRO_DMOD, 0xf707, {0xfc, 0x00, 0x37, 0x00}, 0x04},
614 {PRO_DMOD, 0xf78b, {0x01}, 0x01},
615 {PRO_DMOD, 0xf80f, {0x40, 0x54, 0x5a}, 0x03},
616 {PRO_DMOD, 0xf905, {0x01}, 0x01},
617 {PRO_DMOD, 0xfb06, {0x03}, 0x01},
618 {PRO_DMOD, 0xfd8b, {0x00}, 0x01},
619 {0xff, 0x0000, {0x00}, 0x00} /* Terminating Entry */
620};
621
622/* Version 2 types */
623static struct it913xset it9135_v2[] = {
624 {PRO_DMOD, 0x0051, {0x01}, 0x01},
625 {PRO_DMOD, 0x0070, {0x0a}, 0x01},
626 {PRO_DMOD, 0x007e, {0x04}, 0x01},
627 {PRO_DMOD, 0x0081, {0x0a}, 0x01},
628 {PRO_DMOD, 0x008a, {0x01}, 0x01},
629 {PRO_DMOD, 0x008e, {0x01}, 0x01},
630 {PRO_DMOD, 0x0092, {0x06}, 0x01},
631 {PRO_DMOD, 0x0099, {0x01}, 0x01},
632 {PRO_DMOD, 0x009f, {0xe1}, 0x01},
633 {PRO_DMOD, 0x00a0, {0xcf}, 0x01},
634 {PRO_DMOD, 0x00a3, {0x01}, 0x01},
635 {PRO_DMOD, 0x00a5, {0x01}, 0x01},
636 {PRO_DMOD, 0x00a6, {0x01}, 0x01},
637 {PRO_DMOD, 0x00a9, {0x00}, 0x01},
638 {PRO_DMOD, 0x00aa, {0x01}, 0x01},
639 {PRO_DMOD, 0x00b0, {0x01}, 0x01},
640 {PRO_DMOD, 0x00c2, {0x05}, 0x01},
641 {PRO_DMOD, 0x00c6, {0x19}, 0x01},
642 {PRO_DMOD, 0xf000, {0x0f}, 0x01},
643 {PRO_DMOD, 0xf02b, {0x00}, 0x01},
644 {PRO_DMOD, 0xf064, {0x03}, 0x01},
645 {PRO_DMOD, 0xf065, {0xf9}, 0x01},
646 {PRO_DMOD, 0xf066, {0x03}, 0x01},
647 {PRO_DMOD, 0xf067, {0x01}, 0x01},
648 {PRO_DMOD, 0xf06f, {0xe0}, 0x01},
649 {PRO_DMOD, 0xf070, {0x03}, 0x01},
650 {PRO_DMOD, 0xf072, {0x0f}, 0x01},
651 {PRO_DMOD, 0xf073, {0x03}, 0x01},
652 {PRO_DMOD, 0xf078, {0x00}, 0x01},
653 {PRO_DMOD, 0xf087, {0x00}, 0x01},
654 {PRO_DMOD, 0xf09b, {0x3f}, 0x01},
655 {PRO_DMOD, 0xf09c, {0x00}, 0x01},
656 {PRO_DMOD, 0xf09d, {0x20}, 0x01},
657 {PRO_DMOD, 0xf09e, {0x00}, 0x01},
658 {PRO_DMOD, 0xf09f, {0x0c}, 0x01},
659 {PRO_DMOD, 0xf0a0, {0x00}, 0x01},
660 {PRO_DMOD, 0xf130, {0x04}, 0x01},
661 {PRO_DMOD, 0xf132, {0x04}, 0x01},
662 {PRO_DMOD, 0xf144, {0x1a}, 0x01},
663 {PRO_DMOD, 0xf146, {0x00}, 0x01},
664 {PRO_DMOD, 0xf14a, {0x01}, 0x01},
665 {PRO_DMOD, 0xf14c, {0x00}, 0x01},
666 {PRO_DMOD, 0xf14d, {0x00}, 0x01},
667 {PRO_DMOD, 0xf14f, {0x04}, 0x01},
668 {PRO_DMOD, 0xf158, {0x7f}, 0x01},
669 {PRO_DMOD, 0xf15a, {0x00}, 0x01},
670 {PRO_DMOD, 0xf15b, {0x08}, 0x01},
671 {PRO_DMOD, 0xf15d, {0x03}, 0x01},
672 {PRO_DMOD, 0xf15e, {0x05}, 0x01},
673 {PRO_DMOD, 0xf163, {0x05}, 0x01},
674 {PRO_DMOD, 0xf166, {0x01}, 0x01},
675 {PRO_DMOD, 0xf167, {0x40}, 0x01},
676 {PRO_DMOD, 0xf168, {0x0f}, 0x01},
677 {PRO_DMOD, 0xf17a, {0x00}, 0x01},
678 {PRO_DMOD, 0xf17b, {0x00}, 0x01},
679 {PRO_DMOD, 0xf183, {0x01}, 0x01},
680 {PRO_DMOD, 0xf19d, {0x40}, 0x01},
681 {PRO_DMOD, 0xf1bc, {0x36}, 0x01},
682 {PRO_DMOD, 0xf1bd, {0x00}, 0x01},
683 {PRO_DMOD, 0xf1cb, {0xa0}, 0x01},
684 {PRO_DMOD, 0xf1cc, {0x01}, 0x01},
685 {PRO_DMOD, 0xf204, {0x10}, 0x01},
686 {PRO_DMOD, 0xf214, {0x00}, 0x01},
687 {PRO_DMOD, 0xf40e, {0x0a}, 0x01},
688 {PRO_DMOD, 0xf40f, {0x40}, 0x01},
689 {PRO_DMOD, 0xf410, {0x08}, 0x01},
690 {PRO_DMOD, 0xf55f, {0x0a}, 0x01},
691 {PRO_DMOD, 0xf561, {0x15}, 0x01},
692 {PRO_DMOD, 0xf562, {0x20}, 0x01},
693 {PRO_DMOD, 0xf5e3, {0x09}, 0x01},
694 {PRO_DMOD, 0xf5e4, {0x01}, 0x01},
695 {PRO_DMOD, 0xf5e5, {0x01}, 0x01},
696 {PRO_DMOD, 0xf600, {0x05}, 0x01},
697 {PRO_DMOD, 0xf601, {0x08}, 0x01},
698 {PRO_DMOD, 0xf602, {0x0b}, 0x01},
699 {PRO_DMOD, 0xf603, {0x0e}, 0x01},
700 {PRO_DMOD, 0xf604, {0x11}, 0x01},
701 {PRO_DMOD, 0xf605, {0x14}, 0x01},
702 {PRO_DMOD, 0xf606, {0x17}, 0x01},
703 {PRO_DMOD, 0xf607, {0x1f}, 0x01},
704 {PRO_DMOD, 0xf60e, {0x00}, 0x01},
705 {PRO_DMOD, 0xf60f, {0x04}, 0x01},
706 {PRO_DMOD, 0xf610, {0x32}, 0x01},
707 {PRO_DMOD, 0xf611, {0x10}, 0x01},
708 {PRO_DMOD, 0xf707, {0xfc}, 0x01},
709 {PRO_DMOD, 0xf708, {0x00}, 0x01},
710 {PRO_DMOD, 0xf709, {0x37}, 0x01},
711 {PRO_DMOD, 0xf70a, {0x00}, 0x01},
712 {PRO_DMOD, 0xf78b, {0x01}, 0x01},
713 {PRO_DMOD, 0xf80f, {0x40}, 0x01},
714 {PRO_DMOD, 0xf810, {0x54}, 0x01},
715 {PRO_DMOD, 0xf811, {0x5a}, 0x01},
716 {PRO_DMOD, 0xf905, {0x01}, 0x01},
717 {PRO_DMOD, 0xfb06, {0x03}, 0x01},
718 {PRO_DMOD, 0xfd8b, {0x00}, 0x01},
719 {0xff, 0x0000, {0x00}, 0x00} /* Terminating Entry */
720};
721
722static struct it913xset it9135_60[] = {
723 {PRO_DMOD, 0x0043, {0x00}, 0x01},
724 {PRO_DMOD, 0x0046, {0x60}, 0x01},
725 {PRO_DMOD, 0x0051, {0x01}, 0x01},
726 {PRO_DMOD, 0x005f, {0x00, 0x00}, 0x02},
727 {PRO_DMOD, 0x0068, {0x0a}, 0x01},
728 {PRO_DMOD, 0x006a, {0x03}, 0x01},
729 {PRO_DMOD, 0x0070, {0x0a, 0x05, 0x02}, 0x03},
730 {PRO_DMOD, 0x0075, {0x8c, 0x8c, 0x8c, 0x8c, 0x01}, 0x05},
731 {PRO_DMOD, 0x007e, {0x04}, 0x01},
732 {PRO_DMOD, 0x0081, {0x0a, 0x12}, 0x02},
733 {PRO_DMOD, 0x0084, {0x0a, 0x33, 0xbe, 0xa0, 0xc6, 0xb6, 0x01}, 0x07},
734 {PRO_DMOD, 0x008e, {0x01}, 0x01},
735 {PRO_DMOD, 0x0092, {0x06, 0x00, 0x00, 0x00, 0x00}, 0x05},
736 {PRO_DMOD, 0x0099, {0x01}, 0x01},
737 {PRO_DMOD, 0x009b, {0x3c, 0x28}, 0x02},
738 {PRO_DMOD, 0x009f, {0xe1, 0xcf}, 0x02},
739 {PRO_DMOD, 0x00a3, {0x01, 0x5a, 0x01, 0x01}, 0x04},
740 {PRO_DMOD, 0x00a9, {0x00, 0x01}, 0x02},
741 {PRO_DMOD, 0x00b0, {0x01}, 0x01},
742 {PRO_DMOD, 0x00b3, {0x02, 0x3a}, 0x02},
743 {PRO_DMOD, 0x00b6, {0x14}, 0x01},
744 {PRO_DMOD, 0x00c0, {0x11, 0x00, 0x05, 0x01, 0x00}, 0x05},
745 {PRO_DMOD, 0x00c6, {0x19, 0x00}, 0x02},
746 {PRO_DMOD, 0x00cb, {0x32, 0x2c, 0x4f, 0x30}, 0x04},
747 {PRO_DMOD, 0x00f3, {0x05, 0xa0, 0x8c}, 0x03},
748 {PRO_DMOD, 0x00f8, {0x03, 0x06, 0x06}, 0x03},
749 {PRO_DMOD, 0x00fc, { 0x03, 0x03, 0x02, 0x0a, 0x50, 0x7b, 0x8c,
750 0x00, 0x02, 0xbe, 0x00}, 0x0b},
751 {PRO_DMOD, 0x0109, {0x02}, 0x01},
752 {PRO_DMOD, 0x0115, {0x0a, 0x03}, 0x02},
753 {PRO_DMOD, 0x011a, {0xbe}, 0x01},
754 {PRO_DMOD, 0x0124, {0xae}, 0x01},
755 {PRO_DMOD, 0x0127, {0x00}, 0x01},
756 {PRO_DMOD, 0x012a, {0x56, 0x50, 0x47, 0x42}, 0x04},
757 {PRO_DMOD, 0x0137, {0x00}, 0x01},
758 {PRO_DMOD, 0x013b, {0x08}, 0x01},
759 {PRO_DMOD, 0x013f, {0x5b}, 0x01},
760 {PRO_DMOD, 0x0141, { 0x59, 0xf9, 0x19, 0x19, 0x8c, 0x8c, 0x8c,
761 0x6e, 0x8c, 0x50, 0x8c, 0x8c, 0xac, 0xc6,
762 0x33}, 0x0f},
763 {PRO_DMOD, 0x0151, {0x28}, 0x01},
764 {PRO_DMOD, 0x0153, {0xbc}, 0x01},
765 {PRO_DMOD, 0x0178, {0x09}, 0x01},
766 {PRO_DMOD, 0x0181, {0x94, 0x6e}, 0x02},
767 {PRO_DMOD, 0x0185, {0x24}, 0x01},
768 {PRO_DMOD, 0x0187, {0x00, 0x00, 0xbe, 0x02, 0x80}, 0x05},
769 {PRO_DMOD, 0xed02, {0xff}, 0x01},
770 {PRO_DMOD, 0xee42, {0xff}, 0x01},
771 {PRO_DMOD, 0xee82, {0xff}, 0x01},
772 {PRO_DMOD, 0xf000, {0x0f}, 0x01},
773 {PRO_DMOD, 0xf01f, {0x8c, 0x00}, 0x02},
774 {PRO_DMOD, 0xf029, {0x8c, 0x00, 0x00}, 0x03},
775 {PRO_DMOD, 0xf064, {0x03, 0xf9, 0x03, 0x01}, 0x04},
776 {PRO_DMOD, 0xf06f, {0xe0, 0x03}, 0x02},
777 {PRO_DMOD, 0xf072, {0x0f, 0x03}, 0x02},
778 {PRO_DMOD, 0xf077, {0x01, 0x00}, 0x02},
779 {PRO_DMOD, 0xf087, {0x00}, 0x01},
780 {PRO_DMOD, 0xf09b, {0x3f, 0x00, 0x20, 0x00, 0x0c, 0x00}, 0x06},
781 {PRO_DMOD, 0xf130, {0x04}, 0x01},
782 {PRO_DMOD, 0xf132, {0x04}, 0x01},
783 {PRO_DMOD, 0xf144, {0x1a}, 0x01},
784 {PRO_DMOD, 0xf146, {0x00}, 0x01},
785 {PRO_DMOD, 0xf14a, {0x01}, 0x01},
786 {PRO_DMOD, 0xf14c, {0x00, 0x00}, 0x02},
787 {PRO_DMOD, 0xf14f, {0x04}, 0x01},
788 {PRO_DMOD, 0xf158, {0x7f}, 0x01},
789 {PRO_DMOD, 0xf15a, {0x00, 0x08}, 0x02},
790 {PRO_DMOD, 0xf15d, {0x03, 0x05}, 0x02},
791 {PRO_DMOD, 0xf163, {0x05}, 0x01},
792 {PRO_DMOD, 0xf166, {0x01, 0x40, 0x0f}, 0x03},
793 {PRO_DMOD, 0xf17a, {0x00, 0x00}, 0x02},
794 {PRO_DMOD, 0xf183, {0x01}, 0x01},
795 {PRO_DMOD, 0xf19d, {0x40}, 0x01},
796 {PRO_DMOD, 0xf1bc, {0x36, 0x00}, 0x02},
797 {PRO_DMOD, 0xf1cb, {0xa0, 0x01}, 0x02},
798 {PRO_DMOD, 0xf204, {0x10}, 0x01},
799 {PRO_DMOD, 0xf214, {0x00}, 0x01},
800 {PRO_DMOD, 0xf24c, {0x88, 0x95, 0x9a, 0x90}, 0x04},
801 {PRO_DMOD, 0xf25a, {0x07, 0xe8, 0x03, 0xb0, 0x04}, 0x05},
802 {PRO_DMOD, 0xf270, {0x01, 0x02, 0x01, 0x02}, 0x04},
803 {PRO_DMOD, 0xf40e, {0x0a, 0x40, 0x08}, 0x03},
804 {PRO_DMOD, 0xf55f, {0x0a}, 0x01},
805 {PRO_DMOD, 0xf561, {0x15, 0x20}, 0x02},
806 {PRO_DMOD, 0xf5e3, {0x09, 0x01, 0x01}, 0x03},
807 {PRO_DMOD, 0xf600, {0x05, 0x08, 0x0b, 0x0e, 0x11, 0x14, 0x17
808 , 0x1f}, 0x08},
809 {PRO_DMOD, 0xf60e, {0x00, 0x04, 0x32, 0x10}, 0x04},
810 {PRO_DMOD, 0xf707, {0xfc, 0x00, 0x37, 0x00}, 0x04},
811 {PRO_DMOD, 0xf78b, {0x01}, 0x01},
812 {PRO_DMOD, 0xf80f, {0x40, 0x54, 0x5a}, 0x03},
813 {PRO_DMOD, 0xf905, {0x01}, 0x01},
814 {PRO_DMOD, 0xfb06, {0x03}, 0x01},
815 {PRO_DMOD, 0xfd8b, {0x00}, 0x01},
816 {0xff, 0x0000, {0x00}, 0x00} /* Terminating Entry */
817};
818
819static struct it913xset it9135_61[] = {
820 {PRO_DMOD, 0x0043, {0x00}, 0x01},
821 {PRO_DMOD, 0x0046, {0x61}, 0x01},
822 {PRO_DMOD, 0x0051, {0x01}, 0x01},
823 {PRO_DMOD, 0x005f, {0x00, 0x00}, 0x02},
824 {PRO_DMOD, 0x0068, {0x06}, 0x01},
825 {PRO_DMOD, 0x006a, {0x03}, 0x01},
826 {PRO_DMOD, 0x0070, {0x0a, 0x05, 0x02}, 0x03},
827 {PRO_DMOD, 0x0075, {0x8c, 0x8c, 0x8c, 0x90, 0x01}, 0x05},
828 {PRO_DMOD, 0x007e, {0x04}, 0x01},
829 {PRO_DMOD, 0x0081, {0x0a, 0x12}, 0x02},
830 {PRO_DMOD, 0x0084, {0x0a, 0x33, 0xbc, 0x9c, 0xcc, 0xa8, 0x01}, 0x07},
831 {PRO_DMOD, 0x008e, {0x01}, 0x01},
832 {PRO_DMOD, 0x0092, {0x06, 0x00, 0x00, 0x00, 0x00}, 0x05},
833 {PRO_DMOD, 0x0099, {0x01}, 0x01},
834 {PRO_DMOD, 0x009b, {0x3c, 0x28}, 0x02},
835 {PRO_DMOD, 0x009f, {0xe1, 0xcf}, 0x02},
836 {PRO_DMOD, 0x00a3, {0x01, 0x5c, 0x01, 0x01}, 0x04},
837 {PRO_DMOD, 0x00a9, {0x00, 0x01}, 0x02},
838 {PRO_DMOD, 0x00b0, {0x01}, 0x01},
839 {PRO_DMOD, 0x00b3, {0x02, 0x3a}, 0x02},
840 {PRO_DMOD, 0x00b6, {0x14}, 0x01},
841 {PRO_DMOD, 0x00c0, {0x11, 0x00, 0x05, 0x01, 0x00}, 0x05},
842 {PRO_DMOD, 0x00c6, {0x19, 0x00}, 0x02},
843 {PRO_DMOD, 0x00cb, {0x32, 0x2c, 0x4f, 0x30}, 0x04},
844 {PRO_DMOD, 0x00f3, {0x05, 0xa0, 0x8c}, 0x03},
845 {PRO_DMOD, 0x00f8, {0x03, 0x06, 0x06}, 0x03},
846 {PRO_DMOD, 0x00fc, { 0x03, 0x03, 0x02, 0x08, 0x50, 0x7b, 0x8c,
847 0x01, 0x02, 0xc8, 0x00}, 0x0b},
848 {PRO_DMOD, 0x0109, {0x02}, 0x01},
849 {PRO_DMOD, 0x0115, {0x0a, 0x03}, 0x02},
850 {PRO_DMOD, 0x011a, {0xc6}, 0x01},
851 {PRO_DMOD, 0x0124, {0xa8}, 0x01},
852 {PRO_DMOD, 0x0127, {0x00}, 0x01},
853 {PRO_DMOD, 0x012a, {0x59, 0x50, 0x47, 0x42}, 0x04},
854 {PRO_DMOD, 0x0137, {0x00}, 0x01},
855 {PRO_DMOD, 0x013b, {0x05}, 0x01},
856 {PRO_DMOD, 0x013f, {0x5b}, 0x01},
857 {PRO_DMOD, 0x0141, { 0x59, 0xf9, 0x59, 0x59, 0x8c, 0x8c, 0x8c,
858 0x7b, 0x8c, 0x50, 0x8c, 0x8c, 0xa8, 0xc6,
859 0x33}, 0x0f},
860 {PRO_DMOD, 0x0151, {0x28}, 0x01},
861 {PRO_DMOD, 0x0153, {0xcc}, 0x01},
862 {PRO_DMOD, 0x0178, {0x09}, 0x01},
863 {PRO_DMOD, 0x0181, {0x9c, 0x76}, 0x02},
864 {PRO_DMOD, 0x0185, {0x28}, 0x01},
865 {PRO_DMOD, 0x0187, {0x01, 0x00, 0xaa, 0x02, 0x80}, 0x05},
866 {PRO_DMOD, 0xed02, {0xff}, 0x01},
867 {PRO_DMOD, 0xee42, {0xff}, 0x01},
868 {PRO_DMOD, 0xee82, {0xff}, 0x01},
869 {PRO_DMOD, 0xf000, {0x0f}, 0x01},
870 {PRO_DMOD, 0xf01f, {0x8c, 0x00}, 0x02},
871 {PRO_DMOD, 0xf029, {0x8c, 0x00, 0x00}, 0x03},
872 {PRO_DMOD, 0xf064, {0x03, 0xf9, 0x03, 0x01}, 0x04},
873 {PRO_DMOD, 0xf06f, {0xe0, 0x03}, 0x02},
874 {PRO_DMOD, 0xf072, {0x0f, 0x03}, 0x02},
875 {PRO_DMOD, 0xf077, {0x01, 0x00}, 0x02},
876 {PRO_DMOD, 0xf087, {0x00}, 0x01},
877 {PRO_DMOD, 0xf09b, {0x3f, 0x00, 0x20, 0x00, 0x0c, 0x00}, 0x06},
878 {PRO_DMOD, 0xf130, {0x04}, 0x01},
879 {PRO_DMOD, 0xf132, {0x04}, 0x01},
880 {PRO_DMOD, 0xf144, {0x1a}, 0x01},
881 {PRO_DMOD, 0xf146, {0x00}, 0x01},
882 {PRO_DMOD, 0xf14a, {0x01}, 0x01},
883 {PRO_DMOD, 0xf14c, {0x00, 0x00}, 0x02},
884 {PRO_DMOD, 0xf14f, {0x04}, 0x01},
885 {PRO_DMOD, 0xf158, {0x7f}, 0x01},
886 {PRO_DMOD, 0xf15a, {0x00, 0x08}, 0x02},
887 {PRO_DMOD, 0xf15d, {0x03, 0x05}, 0x02},
888 {PRO_DMOD, 0xf163, {0x05}, 0x01},
889 {PRO_DMOD, 0xf166, {0x01, 0x40, 0x0f}, 0x03},
890 {PRO_DMOD, 0xf17a, {0x00, 0x00}, 0x02},
891 {PRO_DMOD, 0xf183, {0x01}, 0x01},
892 {PRO_DMOD, 0xf19d, {0x40}, 0x01},
893 {PRO_DMOD, 0xf1bc, {0x36, 0x00}, 0x02},
894 {PRO_DMOD, 0xf1cb, {0xa0, 0x01}, 0x02},
895 {PRO_DMOD, 0xf204, {0x10}, 0x01},
896 {PRO_DMOD, 0xf214, {0x00}, 0x01},
897 {PRO_DMOD, 0xf24c, {0x88, 0x95, 0x9a, 0x90}, 0x04},
898 {PRO_DMOD, 0xf25a, {0x07, 0xe8, 0x03, 0xb0, 0x04}, 0x05},
899 {PRO_DMOD, 0xf270, {0x01, 0x02, 0x01, 0x02}, 0x04},
900 {PRO_DMOD, 0xf40e, {0x0a, 0x40, 0x08}, 0x03},
901 {PRO_DMOD, 0xf55f, {0x0a}, 0x01},
902 {PRO_DMOD, 0xf561, {0x15, 0x20}, 0x02},
903 {PRO_DMOD, 0xf5e3, {0x09, 0x01, 0x01}, 0x03},
904 {PRO_DMOD, 0xf600, { 0x05, 0x08, 0x0b, 0x0e, 0x11, 0x14, 0x17,
905 0x1f}, 0x08},
906 {PRO_DMOD, 0xf60e, {0x00, 0x04, 0x32, 0x10}, 0x04},
907 {PRO_DMOD, 0xf707, {0xfc, 0x00, 0x37, 0x00}, 0x04},
908 {PRO_DMOD, 0xf78b, {0x01}, 0x01},
909 {PRO_DMOD, 0xf80f, {0x40, 0x54, 0x5a}, 0x03},
910 {PRO_DMOD, 0xf905, {0x01}, 0x01},
911 {PRO_DMOD, 0xfb06, {0x03}, 0x01},
912 {PRO_DMOD, 0xfd8b, {0x00}, 0x01},
913 {0xff, 0x0000, {0x00}, 0x00} /* Terminating Entry */
914};
915
916static struct it913xset it9135_62[] = {
917 {PRO_DMOD, 0x0043, {0x00}, 0x01},
918 {PRO_DMOD, 0x0046, {0x62}, 0x01},
919 {PRO_DMOD, 0x0051, {0x01}, 0x01},
920 {PRO_DMOD, 0x005f, {0x00, 0x00}, 0x02},
921 {PRO_DMOD, 0x0068, {0x0a}, 0x01},
922 {PRO_DMOD, 0x006a, {0x03}, 0x01},
923 {PRO_DMOD, 0x0070, {0x0a, 0x05, 0x02}, 0x03},
924 {PRO_DMOD, 0x0075, {0x8c, 0x8c, 0x8c, 0x8c, 0x01}, 0x05},
925 {PRO_DMOD, 0x007e, {0x04}, 0x01},
926 {PRO_DMOD, 0x0081, {0x0a, 0x12}, 0x02},
927 {PRO_DMOD, 0x0084, { 0x0a, 0x33, 0xb8, 0x9c, 0xb2, 0xa6, 0x01},
928 0x07},
929 {PRO_DMOD, 0x008e, {0x01}, 0x01},
930 {PRO_DMOD, 0x0092, {0x06, 0x00, 0x00, 0x00, 0x00}, 0x05},
931 {PRO_DMOD, 0x0099, {0x01}, 0x01},
932 {PRO_DMOD, 0x009b, {0x3c, 0x28}, 0x02},
933 {PRO_DMOD, 0x009f, {0xe1, 0xcf}, 0x02},
934 {PRO_DMOD, 0x00a3, {0x01, 0x5a, 0x01, 0x01}, 0x04},
935 {PRO_DMOD, 0x00a9, {0x00, 0x01}, 0x02},
936 {PRO_DMOD, 0x00b0, {0x01}, 0x01},
937 {PRO_DMOD, 0x00b3, {0x02, 0x3a}, 0x02},
938 {PRO_DMOD, 0x00b6, {0x14}, 0x01},
939 {PRO_DMOD, 0x00c0, {0x11, 0x00, 0x05, 0x01, 0x00}, 0x05},
940 {PRO_DMOD, 0x00c6, {0x19, 0x00}, 0x02},
941 {PRO_DMOD, 0x00cb, {0x32, 0x2c, 0x4f, 0x30}, 0x04},
942 {PRO_DMOD, 0x00f3, {0x05, 0x8c, 0x8c}, 0x03},
943 {PRO_DMOD, 0x00f8, {0x03, 0x06, 0x06}, 0x03},
944 {PRO_DMOD, 0x00fc, { 0x02, 0x03, 0x02, 0x09, 0x50, 0x6e, 0x8c,
945 0x02, 0x02, 0xc2, 0x00}, 0x0b},
946 {PRO_DMOD, 0x0109, {0x02}, 0x01},
947 {PRO_DMOD, 0x0115, {0x0a, 0x03}, 0x02},
948 {PRO_DMOD, 0x011a, {0xb8}, 0x01},
949 {PRO_DMOD, 0x0124, {0xa8}, 0x01},
950 {PRO_DMOD, 0x0127, {0x00}, 0x01},
951 {PRO_DMOD, 0x012a, {0x53, 0x51, 0x4e, 0x43}, 0x04},
952 {PRO_DMOD, 0x0137, {0x00}, 0x01},
953 {PRO_DMOD, 0x013b, {0x05}, 0x01},
954 {PRO_DMOD, 0x013f, {0x5b}, 0x01},
955 {PRO_DMOD, 0x0141, { 0x59, 0xf9, 0x59, 0x19, 0x8c, 0x8c, 0x8c,
956 0x7b, 0x8c, 0x50, 0x70, 0x8c, 0x96, 0xd0,
957 0x33}, 0x0f},
958 {PRO_DMOD, 0x0151, {0x28}, 0x01},
959 {PRO_DMOD, 0x0153, {0xb2}, 0x01},
960 {PRO_DMOD, 0x0178, {0x09}, 0x01},
961 {PRO_DMOD, 0x0181, {0x9c, 0x6e}, 0x02},
962 {PRO_DMOD, 0x0185, {0x24}, 0x01},
963 {PRO_DMOD, 0x0187, {0x00, 0x00, 0xb8, 0x02, 0x80}, 0x05},
964 {PRO_DMOD, 0xed02, {0xff}, 0x01},
965 {PRO_DMOD, 0xee42, {0xff}, 0x01},
966 {PRO_DMOD, 0xee82, {0xff}, 0x01},
967 {PRO_DMOD, 0xf000, {0x0f}, 0x01},
968 {PRO_DMOD, 0xf01f, {0x8c, 0x00}, 0x02},
969 {PRO_DMOD, 0xf029, {0x8c, 0x00, 0x00}, 0x03},
970 {PRO_DMOD, 0xf064, {0x03, 0xf9, 0x03, 0x01}, 0x04},
971 {PRO_DMOD, 0xf06f, {0xe0, 0x03}, 0x02},
972 {PRO_DMOD, 0xf072, {0x0f, 0x03}, 0x02},
973 {PRO_DMOD, 0xf077, {0x01, 0x00}, 0x02},
974 {PRO_DMOD, 0xf087, {0x00}, 0x01},
975 {PRO_DMOD, 0xf09b, {0x3f, 0x00, 0x20, 0x00, 0x0c, 0x00}, 0x06},
976 {PRO_DMOD, 0xf130, {0x04}, 0x01},
977 {PRO_DMOD, 0xf132, {0x04}, 0x01},
978 {PRO_DMOD, 0xf144, {0x1a}, 0x01},
979 {PRO_DMOD, 0xf146, {0x00}, 0x01},
980 {PRO_DMOD, 0xf14a, {0x01}, 0x01},
981 {PRO_DMOD, 0xf14c, {0x00, 0x00}, 0x02},
982 {PRO_DMOD, 0xf14f, {0x04}, 0x01},
983 {PRO_DMOD, 0xf158, {0x7f}, 0x01},
984 {PRO_DMOD, 0xf15a, {0x00, 0x08}, 0x02},
985 {PRO_DMOD, 0xf15d, {0x03, 0x05}, 0x02},
986 {PRO_DMOD, 0xf163, {0x05}, 0x01},
987 {PRO_DMOD, 0xf166, {0x01, 0x40, 0x0f}, 0x03},
988 {PRO_DMOD, 0xf17a, {0x00, 0x00}, 0x02},
989 {PRO_DMOD, 0xf183, {0x01}, 0x01},
990 {PRO_DMOD, 0xf19d, {0x40}, 0x01},
991 {PRO_DMOD, 0xf1bc, {0x36, 0x00}, 0x02},
992 {PRO_DMOD, 0xf1cb, {0xa0, 0x01}, 0x02},
993 {PRO_DMOD, 0xf204, {0x10}, 0x01},
994 {PRO_DMOD, 0xf214, {0x00}, 0x01},
995 {PRO_DMOD, 0xf24c, {0x88, 0x95, 0x9a, 0x90}, 0x04},
996 {PRO_DMOD, 0xf25a, {0x07, 0xe8, 0x03, 0xb0, 0x04}, 0x05},
997 {PRO_DMOD, 0xf270, {0x01, 0x02, 0x01, 0x02}, 0x04},
998 {PRO_DMOD, 0xf40e, {0x0a, 0x40, 0x08}, 0x03},
999 {PRO_DMOD, 0xf55f, {0x0a}, 0x01},
1000 {PRO_DMOD, 0xf561, {0x15, 0x20}, 0x02},
1001 {PRO_DMOD, 0xf5e3, {0x09, 0x01, 0x01}, 0x03},
1002 {PRO_DMOD, 0xf600, { 0x05, 0x08, 0x0b, 0x0e, 0x11, 0x14, 0x17,
1003 0x1f}, 0x08},
1004 {PRO_DMOD, 0xf60e, {0x00, 0x04, 0x32, 0x10}, 0x04},
1005 {PRO_DMOD, 0xf707, {0xfc, 0x00, 0x37, 0x00}, 0x04},
1006 {PRO_DMOD, 0xf78b, {0x01}, 0x01},
1007 {PRO_DMOD, 0xf80f, {0x40, 0x54, 0x5a}, 0x03},
1008 {PRO_DMOD, 0xf905, {0x01}, 0x01},
1009 {PRO_DMOD, 0xfb06, {0x03}, 0x01},
1010 {PRO_DMOD, 0xfd8b, {0x00}, 0x01},
1011 {0xff, 0x0000, {0x00}, 0x00} /* Terminating Entry */
1012};
1013
1014/* Tuner setting scripts (still keeping it9137) */
1015static struct it913xset it9137_tuner_off[] = {
1016 {PRO_DMOD, 0xfba8, {0x01}, 0x01}, /* Tuner Clock Off */
1017 {PRO_DMOD, 0xec40, {0x00}, 0x01}, /* Power Down Tuner */
1018 {PRO_DMOD, 0xec02, {0x3f, 0x1f, 0x3f, 0x3f}, 0x04},
1019 {PRO_DMOD, 0xec06, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1020 0x00, 0x00, 0x00, 0x00}, 0x0c},
1021 {PRO_DMOD, 0xec12, {0x00, 0x00, 0x00, 0x00}, 0x04},
1022 {PRO_DMOD, 0xec17, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1023 0x00}, 0x09},
1024 {PRO_DMOD, 0xec22, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1025 0x00, 0x00}, 0x0a},
1026 {PRO_DMOD, 0xec20, {0x00}, 0x01},
1027 {PRO_DMOD, 0xec3f, {0x01}, 0x01},
1028 {0xff, 0x0000, {0x00}, 0x00}, /* Terminating Entry */
1029};
1030
1031static struct it913xset set_it9135_template[] = {
1032 {PRO_DMOD, 0xee06, {0x00}, 0x01},
1033 {PRO_DMOD, 0xec56, {0x00}, 0x01},
1034 {PRO_DMOD, 0xec4c, {0x00}, 0x01},
1035 {PRO_DMOD, 0xec4d, {0x00}, 0x01},
1036 {PRO_DMOD, 0xec4e, {0x00}, 0x01},
1037 {PRO_DMOD, 0x011e, {0x00}, 0x01}, /* Older Devices */
1038 {PRO_DMOD, 0x011f, {0x00}, 0x01},
1039 {0xff, 0x0000, {0x00}, 0x00}, /* Terminating Entry */
1040};
1041
1042static struct it913xset set_it9137_template[] = {
1043 {PRO_DMOD, 0xee06, {0x00}, 0x01},
1044 {PRO_DMOD, 0xec56, {0x00}, 0x01},
1045 {PRO_DMOD, 0xec4c, {0x00}, 0x01},
1046 {PRO_DMOD, 0xec4d, {0x00}, 0x01},
1047 {PRO_DMOD, 0xec4e, {0x00}, 0x01},
1048 {PRO_DMOD, 0xec4f, {0x00}, 0x01},
1049 {PRO_DMOD, 0xec50, {0x00}, 0x01},
1050 {0xff, 0x0000, {0x00}, 0x00}, /* Terminating Entry */
1051};
diff --git a/drivers/media/dvb-frontends/it913x-fe.c b/drivers/media/dvb-frontends/it913x-fe.c
deleted file mode 100644
index 6e1c6eb340b7..000000000000
--- a/drivers/media/dvb-frontends/it913x-fe.c
+++ /dev/null
@@ -1,1045 +0,0 @@
1/*
2 * Driver for it913x-fe Frontend
3 *
4 * with support for on chip it9137 integral tuner
5 *
6 * Copyright (C) 2011 Malcolm Priestley (tvboxspy@gmail.com)
7 * IT9137 Copyright (C) ITE Tech Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 *
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
23 */
24
25#include <linux/module.h>
26#include <linux/init.h>
27#include <linux/slab.h>
28#include <linux/types.h>
29
30#include "dvb_frontend.h"
31#include "it913x-fe.h"
32#include "it913x-fe-priv.h"
33
34static int it913x_debug;
35
36module_param_named(debug, it913x_debug, int, 0644);
37MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able)).");
38
39#define dprintk(level, args...) do { \
40 if (level & it913x_debug) \
41 printk(KERN_DEBUG "it913x-fe: " args); \
42} while (0)
43
44#define deb_info(args...) dprintk(0x01, args)
45#define debug_data_snipet(level, name, p) \
46 dprintk(level, name" (%02x%02x%02x%02x%02x%02x%02x%02x)", \
47 *p, *(p+1), *(p+2), *(p+3), *(p+4), \
48 *(p+5), *(p+6), *(p+7));
49#define info(format, arg...) \
50 printk(KERN_INFO "it913x-fe: " format "\n" , ## arg)
51
52struct it913x_fe_state {
53 struct dvb_frontend frontend;
54 struct i2c_adapter *i2c_adap;
55 struct ite_config *config;
56 u8 i2c_addr;
57 u32 frequency;
58 fe_modulation_t constellation;
59 fe_transmit_mode_t transmission_mode;
60 u8 priority;
61 u32 crystalFrequency;
62 u32 adcFrequency;
63 u8 tuner_type;
64 struct adctable *table;
65 fe_status_t it913x_status;
66 u16 tun_xtal;
67 u8 tun_fdiv;
68 u8 tun_clk_mode;
69 u32 tun_fn_min;
70 u32 ucblocks;
71};
72
73static int it913x_read_reg(struct it913x_fe_state *state,
74 u32 reg, u8 *data, u8 count)
75{
76 int ret;
77 u8 pro = PRO_DMOD; /* All reads from demodulator */
78 u8 b[4];
79 struct i2c_msg msg[2] = {
80 { .addr = state->i2c_addr + (pro << 1), .flags = 0,
81 .buf = b, .len = sizeof(b) },
82 { .addr = state->i2c_addr + (pro << 1), .flags = I2C_M_RD,
83 .buf = data, .len = count }
84 };
85 b[0] = (u8) reg >> 24;
86 b[1] = (u8)(reg >> 16) & 0xff;
87 b[2] = (u8)(reg >> 8) & 0xff;
88 b[3] = (u8) reg & 0xff;
89
90 ret = i2c_transfer(state->i2c_adap, msg, 2);
91
92 return ret;
93}
94
95static int it913x_read_reg_u8(struct it913x_fe_state *state, u32 reg)
96{
97 int ret;
98 u8 b[1];
99 ret = it913x_read_reg(state, reg, &b[0], sizeof(b));
100 return (ret < 0) ? -ENODEV : b[0];
101}
102
103static int it913x_write(struct it913x_fe_state *state,
104 u8 pro, u32 reg, u8 buf[], u8 count)
105{
106 u8 b[256];
107 struct i2c_msg msg[1] = {
108 { .addr = state->i2c_addr + (pro << 1), .flags = 0,
109 .buf = b, .len = count + 4 }
110 };
111 int ret;
112
113 b[0] = (u8) reg >> 24;
114 b[1] = (u8)(reg >> 16) & 0xff;
115 b[2] = (u8)(reg >> 8) & 0xff;
116 b[3] = (u8) reg & 0xff;
117 memcpy(&b[4], buf, count);
118
119 ret = i2c_transfer(state->i2c_adap, msg, 1);
120
121 if (ret < 0)
122 return -EIO;
123
124 return 0;
125}
126
127static int it913x_write_reg(struct it913x_fe_state *state,
128 u8 pro, u32 reg, u32 data)
129{
130 int ret;
131 u8 b[4];
132 u8 s;
133
134 b[0] = data >> 24;
135 b[1] = (data >> 16) & 0xff;
136 b[2] = (data >> 8) & 0xff;
137 b[3] = data & 0xff;
138 /* expand write as needed */
139 if (data < 0x100)
140 s = 3;
141 else if (data < 0x1000)
142 s = 2;
143 else if (data < 0x100000)
144 s = 1;
145 else
146 s = 0;
147
148 ret = it913x_write(state, pro, reg, &b[s], sizeof(b) - s);
149
150 return ret;
151}
152
153static int it913x_fe_script_loader(struct it913x_fe_state *state,
154 struct it913xset *loadscript)
155{
156 int ret, i;
157 if (loadscript == NULL)
158 return -EINVAL;
159
160 for (i = 0; i < 1000; ++i) {
161 if (loadscript[i].pro == 0xff)
162 break;
163 ret = it913x_write(state, loadscript[i].pro,
164 loadscript[i].address,
165 loadscript[i].reg, loadscript[i].count);
166 if (ret < 0)
167 return -ENODEV;
168 }
169 return 0;
170}
171
172static int it913x_init_tuner(struct it913x_fe_state *state)
173{
174 int ret, i, reg;
175 u8 val, nv_val;
176 u8 nv[] = {48, 32, 24, 16, 12, 8, 6, 4, 2};
177 u8 b[2];
178
179 reg = it913x_read_reg_u8(state, 0xec86);
180 switch (reg) {
181 case 0:
182 state->tun_clk_mode = reg;
183 state->tun_xtal = 2000;
184 state->tun_fdiv = 3;
185 val = 16;
186 break;
187 case -ENODEV:
188 return -ENODEV;
189 case 1:
190 default:
191 state->tun_clk_mode = reg;
192 state->tun_xtal = 640;
193 state->tun_fdiv = 1;
194 val = 6;
195 break;
196 }
197
198 reg = it913x_read_reg_u8(state, 0xed03);
199
200 if (reg < 0)
201 return -ENODEV;
202 else if (reg < ARRAY_SIZE(nv))
203 nv_val = nv[reg];
204 else
205 nv_val = 2;
206
207 for (i = 0; i < 50; i++) {
208 ret = it913x_read_reg(state, 0xed23, &b[0], sizeof(b));
209 reg = (b[1] << 8) + b[0];
210 if (reg > 0)
211 break;
212 if (ret < 0)
213 return -ENODEV;
214 udelay(2000);
215 }
216 state->tun_fn_min = state->tun_xtal * reg;
217 state->tun_fn_min /= (state->tun_fdiv * nv_val);
218 deb_info("Tuner fn_min %d", state->tun_fn_min);
219
220 if (state->config->chip_ver > 1)
221 msleep(50);
222 else {
223 for (i = 0; i < 50; i++) {
224 reg = it913x_read_reg_u8(state, 0xec82);
225 if (reg > 0)
226 break;
227 if (reg < 0)
228 return -ENODEV;
229 udelay(2000);
230 }
231 }
232
233 return it913x_write_reg(state, PRO_DMOD, 0xed81, val);
234}
235
236static int it9137_set_tuner(struct it913x_fe_state *state,
237 u32 bandwidth, u32 frequency_m)
238{
239 struct it913xset *set_tuner = set_it9137_template;
240 int ret, reg;
241 u32 frequency = frequency_m / 1000;
242 u32 freq, temp_f, tmp;
243 u16 iqik_m_cal;
244 u16 n_div;
245 u8 n;
246 u8 l_band;
247 u8 lna_band;
248 u8 bw;
249
250 if (state->config->firmware_ver == 1)
251 set_tuner = set_it9135_template;
252 else
253 set_tuner = set_it9137_template;
254
255 deb_info("Tuner Frequency %d Bandwidth %d", frequency, bandwidth);
256
257 if (frequency >= 51000 && frequency <= 440000) {
258 l_band = 0;
259 lna_band = 0;
260 } else if (frequency > 440000 && frequency <= 484000) {
261 l_band = 1;
262 lna_band = 1;
263 } else if (frequency > 484000 && frequency <= 533000) {
264 l_band = 1;
265 lna_band = 2;
266 } else if (frequency > 533000 && frequency <= 587000) {
267 l_band = 1;
268 lna_band = 3;
269 } else if (frequency > 587000 && frequency <= 645000) {
270 l_band = 1;
271 lna_band = 4;
272 } else if (frequency > 645000 && frequency <= 710000) {
273 l_band = 1;
274 lna_band = 5;
275 } else if (frequency > 710000 && frequency <= 782000) {
276 l_band = 1;
277 lna_band = 6;
278 } else if (frequency > 782000 && frequency <= 860000) {
279 l_band = 1;
280 lna_band = 7;
281 } else if (frequency > 1450000 && frequency <= 1492000) {
282 l_band = 1;
283 lna_band = 0;
284 } else if (frequency > 1660000 && frequency <= 1685000) {
285 l_band = 1;
286 lna_band = 1;
287 } else
288 return -EINVAL;
289 set_tuner[0].reg[0] = lna_band;
290
291 switch (bandwidth) {
292 case 5000000:
293 bw = 0;
294 break;
295 case 6000000:
296 bw = 2;
297 break;
298 case 7000000:
299 bw = 4;
300 break;
301 default:
302 case 8000000:
303 bw = 6;
304 break;
305 }
306
307 set_tuner[1].reg[0] = bw;
308 set_tuner[2].reg[0] = 0xa0 | (l_band << 3);
309
310 if (frequency > 53000 && frequency <= 74000) {
311 n_div = 48;
312 n = 0;
313 } else if (frequency > 74000 && frequency <= 111000) {
314 n_div = 32;
315 n = 1;
316 } else if (frequency > 111000 && frequency <= 148000) {
317 n_div = 24;
318 n = 2;
319 } else if (frequency > 148000 && frequency <= 222000) {
320 n_div = 16;
321 n = 3;
322 } else if (frequency > 222000 && frequency <= 296000) {
323 n_div = 12;
324 n = 4;
325 } else if (frequency > 296000 && frequency <= 445000) {
326 n_div = 8;
327 n = 5;
328 } else if (frequency > 445000 && frequency <= state->tun_fn_min) {
329 n_div = 6;
330 n = 6;
331 } else if (frequency > state->tun_fn_min && frequency <= 950000) {
332 n_div = 4;
333 n = 7;
334 } else if (frequency > 1450000 && frequency <= 1680000) {
335 n_div = 2;
336 n = 0;
337 } else
338 return -EINVAL;
339
340 reg = it913x_read_reg_u8(state, 0xed81);
341 iqik_m_cal = (u16)reg * n_div;
342
343 if (reg < 0x20) {
344 if (state->tun_clk_mode == 0)
345 iqik_m_cal = (iqik_m_cal * 9) >> 5;
346 else
347 iqik_m_cal >>= 1;
348 } else {
349 iqik_m_cal = 0x40 - iqik_m_cal;
350 if (state->tun_clk_mode == 0)
351 iqik_m_cal = ~((iqik_m_cal * 9) >> 5);
352 else
353 iqik_m_cal = ~(iqik_m_cal >> 1);
354 }
355
356 temp_f = frequency * (u32)n_div * (u32)state->tun_fdiv;
357 freq = temp_f / state->tun_xtal;
358 tmp = freq * state->tun_xtal;
359
360 if ((temp_f - tmp) >= (state->tun_xtal >> 1))
361 freq++;
362
363 freq += (u32) n << 13;
364 /* Frequency OMEGA_IQIK_M_CAL_MID*/
365 temp_f = freq + (u32)iqik_m_cal;
366
367 set_tuner[3].reg[0] = temp_f & 0xff;
368 set_tuner[4].reg[0] = (temp_f >> 8) & 0xff;
369
370 deb_info("High Frequency = %04x", temp_f);
371
372 /* Lower frequency */
373 set_tuner[5].reg[0] = freq & 0xff;
374 set_tuner[6].reg[0] = (freq >> 8) & 0xff;
375
376 deb_info("low Frequency = %04x", freq);
377
378 ret = it913x_fe_script_loader(state, set_tuner);
379
380 return (ret < 0) ? -ENODEV : 0;
381}
382
383static int it913x_fe_select_bw(struct it913x_fe_state *state,
384 u32 bandwidth, u32 adcFrequency)
385{
386 int ret, i;
387 u8 buffer[256];
388 u32 coeff[8];
389 u16 bfsfcw_fftinx_ratio;
390 u16 fftinx_bfsfcw_ratio;
391 u8 count;
392 u8 bw;
393 u8 adcmultiplier;
394
395 deb_info("Bandwidth %d Adc %d", bandwidth, adcFrequency);
396
397 switch (bandwidth) {
398 case 5000000:
399 bw = 3;
400 break;
401 case 6000000:
402 bw = 0;
403 break;
404 case 7000000:
405 bw = 1;
406 break;
407 default:
408 case 8000000:
409 bw = 2;
410 break;
411 }
412 ret = it913x_write_reg(state, PRO_DMOD, REG_BW, bw);
413
414 if (state->table == NULL)
415 return -EINVAL;
416
417 /* In write order */
418 coeff[0] = state->table[bw].coeff_1_2048;
419 coeff[1] = state->table[bw].coeff_2_2k;
420 coeff[2] = state->table[bw].coeff_1_8191;
421 coeff[3] = state->table[bw].coeff_1_8192;
422 coeff[4] = state->table[bw].coeff_1_8193;
423 coeff[5] = state->table[bw].coeff_2_8k;
424 coeff[6] = state->table[bw].coeff_1_4096;
425 coeff[7] = state->table[bw].coeff_2_4k;
426 bfsfcw_fftinx_ratio = state->table[bw].bfsfcw_fftinx_ratio;
427 fftinx_bfsfcw_ratio = state->table[bw].fftinx_bfsfcw_ratio;
428
429 /* ADC multiplier */
430 ret = it913x_read_reg_u8(state, ADC_X_2);
431 if (ret < 0)
432 return -EINVAL;
433
434 adcmultiplier = ret;
435
436 count = 0;
437
438 /* Build Buffer for COEFF Registers */
439 for (i = 0; i < 8; i++) {
440 if (adcmultiplier == 1)
441 coeff[i] /= 2;
442 buffer[count++] = (coeff[i] >> 24) & 0x3;
443 buffer[count++] = (coeff[i] >> 16) & 0xff;
444 buffer[count++] = (coeff[i] >> 8) & 0xff;
445 buffer[count++] = coeff[i] & 0xff;
446 }
447
448 /* bfsfcw_fftinx_ratio register 0x21-0x22 */
449 buffer[count++] = bfsfcw_fftinx_ratio & 0xff;
450 buffer[count++] = (bfsfcw_fftinx_ratio >> 8) & 0xff;
451 /* fftinx_bfsfcw_ratio register 0x23-0x24 */
452 buffer[count++] = fftinx_bfsfcw_ratio & 0xff;
453 buffer[count++] = (fftinx_bfsfcw_ratio >> 8) & 0xff;
454 /* start at COEFF_1_2048 and write through to fftinx_bfsfcw_ratio*/
455 ret = it913x_write(state, PRO_DMOD, COEFF_1_2048, buffer, count);
456
457 for (i = 0; i < 42; i += 8)
458 debug_data_snipet(0x1, "Buffer", &buffer[i]);
459
460 return ret;
461}
462
463
464
465static int it913x_fe_read_status(struct dvb_frontend *fe, fe_status_t *status)
466{
467 struct it913x_fe_state *state = fe->demodulator_priv;
468 int ret, i;
469 fe_status_t old_status = state->it913x_status;
470 *status = 0;
471
472 if (state->it913x_status == 0) {
473 ret = it913x_read_reg_u8(state, EMPTY_CHANNEL_STATUS);
474 if (ret == 0x1) {
475 *status |= FE_HAS_SIGNAL;
476 for (i = 0; i < 40; i++) {
477 ret = it913x_read_reg_u8(state, MP2IF_SYNC_LK);
478 if (ret == 0x1)
479 break;
480 msleep(25);
481 }
482 if (ret == 0x1)
483 *status |= FE_HAS_CARRIER
484 | FE_HAS_VITERBI
485 | FE_HAS_SYNC;
486 state->it913x_status = *status;
487 }
488 }
489
490 if (state->it913x_status & FE_HAS_SYNC) {
491 ret = it913x_read_reg_u8(state, TPSD_LOCK);
492 if (ret == 0x1)
493 *status |= FE_HAS_LOCK
494 | state->it913x_status;
495 else
496 state->it913x_status = 0;
497 if (old_status != state->it913x_status)
498 ret = it913x_write_reg(state, PRO_LINK, GPIOH3_O, ret);
499 }
500
501 return 0;
502}
503
504/* FEC values based on fe_code_rate_t non supported values 0*/
505int it913x_qpsk_pval[] = {0, -93, -91, -90, 0, -89, -88};
506int it913x_16qam_pval[] = {0, -87, -85, -84, 0, -83, -82};
507int it913x_64qam_pval[] = {0, -82, -80, -78, 0, -77, -76};
508
509static int it913x_get_signal_strength(struct dvb_frontend *fe)
510{
511 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
512 struct it913x_fe_state *state = fe->demodulator_priv;
513 u8 code_rate;
514 int ret, temp;
515 u8 lna_gain_os;
516
517 ret = it913x_read_reg_u8(state, VAR_P_INBAND);
518 if (ret < 0)
519 return ret;
520
521 /* VHF/UHF gain offset */
522 if (state->frequency < 300000000)
523 lna_gain_os = 7;
524 else
525 lna_gain_os = 14;
526
527 temp = (ret - 100) - lna_gain_os;
528
529 if (state->priority == PRIORITY_HIGH)
530 code_rate = p->code_rate_HP;
531 else
532 code_rate = p->code_rate_LP;
533
534 if (code_rate >= ARRAY_SIZE(it913x_qpsk_pval))
535 return -EINVAL;
536
537 deb_info("Reg VAR_P_INBAND:%d Calc Offset Value:%d", ret, temp);
538
539 /* Apply FEC offset values*/
540 switch (p->modulation) {
541 case QPSK:
542 temp -= it913x_qpsk_pval[code_rate];
543 break;
544 case QAM_16:
545 temp -= it913x_16qam_pval[code_rate];
546 break;
547 case QAM_64:
548 temp -= it913x_64qam_pval[code_rate];
549 break;
550 default:
551 return -EINVAL;
552 }
553
554 if (temp < -15)
555 ret = 0;
556 else if ((-15 <= temp) && (temp < 0))
557 ret = (2 * (temp + 15)) / 3;
558 else if ((0 <= temp) && (temp < 20))
559 ret = 4 * temp + 10;
560 else if ((20 <= temp) && (temp < 35))
561 ret = (2 * (temp - 20)) / 3 + 90;
562 else if (temp >= 35)
563 ret = 100;
564
565 deb_info("Signal Strength :%d", ret);
566
567 return ret;
568}
569
570static int it913x_fe_read_signal_strength(struct dvb_frontend *fe,
571 u16 *strength)
572{
573 struct it913x_fe_state *state = fe->demodulator_priv;
574 int ret = 0;
575 if (state->config->read_slevel) {
576 if (state->it913x_status & FE_HAS_SIGNAL)
577 ret = it913x_read_reg_u8(state, SIGNAL_LEVEL);
578 } else
579 ret = it913x_get_signal_strength(fe);
580
581 if (ret >= 0)
582 *strength = (u16)((u32)ret * 0xffff / 0x64);
583
584 return (ret < 0) ? -ENODEV : 0;
585}
586
587static int it913x_fe_read_snr(struct dvb_frontend *fe, u16 *snr)
588{
589 struct it913x_fe_state *state = fe->demodulator_priv;
590 int ret;
591 u8 reg[3];
592 u32 snr_val, snr_min, snr_max;
593 u32 temp;
594
595 ret = it913x_read_reg(state, 0x2c, reg, sizeof(reg));
596
597 snr_val = (u32)(reg[2] << 16) | (reg[1] << 8) | reg[0];
598
599 ret |= it913x_read_reg(state, 0xf78b, reg, 1);
600 if (reg[0])
601 snr_val /= reg[0];
602
603 if (state->transmission_mode == TRANSMISSION_MODE_2K)
604 snr_val *= 4;
605 else if (state->transmission_mode == TRANSMISSION_MODE_4K)
606 snr_val *= 2;
607
608 if (state->constellation == QPSK) {
609 snr_min = 0xb4711;
610 snr_max = 0x191451;
611 } else if (state->constellation == QAM_16) {
612 snr_min = 0x4f0d5;
613 snr_max = 0xc7925;
614 } else if (state->constellation == QAM_64) {
615 snr_min = 0x256d0;
616 snr_max = 0x626be;
617 } else
618 return -EINVAL;
619
620 if (snr_val < snr_min)
621 *snr = 0;
622 else if (snr_val < snr_max) {
623 temp = (snr_val - snr_min) >> 5;
624 temp *= 0xffff;
625 temp /= (snr_max - snr_min) >> 5;
626 *snr = (u16)temp;
627 } else
628 *snr = 0xffff;
629
630 return (ret < 0) ? -ENODEV : 0;
631}
632
633static int it913x_fe_read_ber(struct dvb_frontend *fe, u32 *ber)
634{
635 struct it913x_fe_state *state = fe->demodulator_priv;
636 u8 reg[5];
637 /* Read Aborted Packets and Pre-Viterbi error rate 5 bytes */
638 it913x_read_reg(state, RSD_ABORT_PKT_LSB, reg, sizeof(reg));
639 state->ucblocks += (u32)(reg[1] << 8) | reg[0];
640 *ber = (u32)(reg[4] << 16) | (reg[3] << 8) | reg[2];
641 return 0;
642}
643
644static int it913x_fe_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
645{
646 struct it913x_fe_state *state = fe->demodulator_priv;
647 int ret;
648 u8 reg[2];
649 /* Aborted Packets */
650 ret = it913x_read_reg(state, RSD_ABORT_PKT_LSB, reg, sizeof(reg));
651 state->ucblocks += (u32)(reg[1] << 8) | reg[0];
652 *ucblocks = state->ucblocks;
653 return ret;
654}
655
656static int it913x_fe_get_frontend(struct dvb_frontend *fe)
657{
658 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
659 struct it913x_fe_state *state = fe->demodulator_priv;
660 u8 reg[8];
661
662 it913x_read_reg(state, REG_TPSD_TX_MODE, reg, sizeof(reg));
663
664 if (reg[3] < 3)
665 p->modulation = fe_con[reg[3]];
666
667 if (reg[0] < 3)
668 p->transmission_mode = fe_mode[reg[0]];
669
670 if (reg[1] < 4)
671 p->guard_interval = fe_gi[reg[1]];
672
673 if (reg[2] < 4)
674 p->hierarchy = fe_hi[reg[2]];
675
676 state->priority = reg[5];
677
678 p->code_rate_HP = (reg[6] < 6) ? fe_code[reg[6]] : FEC_NONE;
679 p->code_rate_LP = (reg[7] < 6) ? fe_code[reg[7]] : FEC_NONE;
680
681 /* Update internal state to reflect the autodetected props */
682 state->constellation = p->modulation;
683 state->transmission_mode = p->transmission_mode;
684
685 return 0;
686}
687
688static int it913x_fe_set_frontend(struct dvb_frontend *fe)
689{
690 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
691 struct it913x_fe_state *state = fe->demodulator_priv;
692 int i;
693 u8 empty_ch, last_ch;
694
695 state->it913x_status = 0;
696
697 /* Set bw*/
698 it913x_fe_select_bw(state, p->bandwidth_hz,
699 state->adcFrequency);
700
701 /* Training Mode Off */
702 it913x_write_reg(state, PRO_LINK, TRAINING_MODE, 0x0);
703
704 /* Clear Empty Channel */
705 it913x_write_reg(state, PRO_DMOD, EMPTY_CHANNEL_STATUS, 0x0);
706
707 /* Clear bits */
708 it913x_write_reg(state, PRO_DMOD, MP2IF_SYNC_LK, 0x0);
709 /* LED on */
710 it913x_write_reg(state, PRO_LINK, GPIOH3_O, 0x1);
711 /* Select Band*/
712 if ((p->frequency >= 51000000) && (p->frequency <= 230000000))
713 i = 0;
714 else if ((p->frequency >= 350000000) && (p->frequency <= 900000000))
715 i = 1;
716 else if ((p->frequency >= 1450000000) && (p->frequency <= 1680000000))
717 i = 2;
718 else
719 return -EOPNOTSUPP;
720
721 it913x_write_reg(state, PRO_DMOD, FREE_BAND, i);
722
723 deb_info("Frontend Set Tuner Type %02x", state->tuner_type);
724 switch (state->tuner_type) {
725 case IT9135_38:
726 case IT9135_51:
727 case IT9135_52:
728 case IT9135_60:
729 case IT9135_61:
730 case IT9135_62:
731 it9137_set_tuner(state,
732 p->bandwidth_hz, p->frequency);
733 break;
734 default:
735 if (fe->ops.tuner_ops.set_params) {
736 fe->ops.tuner_ops.set_params(fe);
737 if (fe->ops.i2c_gate_ctrl)
738 fe->ops.i2c_gate_ctrl(fe, 0);
739 }
740 break;
741 }
742 /* LED off */
743 it913x_write_reg(state, PRO_LINK, GPIOH3_O, 0x0);
744 /* Trigger ofsm */
745 it913x_write_reg(state, PRO_DMOD, TRIGGER_OFSM, 0x0);
746 last_ch = 2;
747 for (i = 0; i < 40; ++i) {
748 empty_ch = it913x_read_reg_u8(state, EMPTY_CHANNEL_STATUS);
749 if (last_ch == 1 && empty_ch == 1)
750 break;
751 if (last_ch == 2 && empty_ch == 2)
752 return 0;
753 last_ch = empty_ch;
754 msleep(25);
755 }
756 for (i = 0; i < 40; ++i) {
757 if (it913x_read_reg_u8(state, D_TPSD_LOCK) == 1)
758 break;
759 msleep(25);
760 }
761
762 state->frequency = p->frequency;
763 return 0;
764}
765
766static int it913x_fe_suspend(struct it913x_fe_state *state)
767{
768 int ret, i;
769 u8 b;
770
771 ret = it913x_write_reg(state, PRO_DMOD, SUSPEND_FLAG, 0x1);
772
773 ret |= it913x_write_reg(state, PRO_DMOD, TRIGGER_OFSM, 0x0);
774
775 for (i = 0; i < 128; i++) {
776 ret = it913x_read_reg(state, SUSPEND_FLAG, &b, 1);
777 if (ret < 0)
778 return -ENODEV;
779 if (b == 0)
780 break;
781
782 }
783
784 ret |= it913x_write_reg(state, PRO_DMOD, AFE_MEM0, 0x8);
785 /* Turn LED off */
786 ret |= it913x_write_reg(state, PRO_LINK, GPIOH3_O, 0x0);
787
788 ret |= it913x_fe_script_loader(state, it9137_tuner_off);
789
790 return (ret < 0) ? -ENODEV : 0;
791}
792
793/* Power sequence */
794/* Power Up Tuner on -> Frontend suspend off -> Tuner clk on */
795/* Power Down Frontend suspend on -> Tuner clk off -> Tuner off */
796
797static int it913x_fe_sleep(struct dvb_frontend *fe)
798{
799 struct it913x_fe_state *state = fe->demodulator_priv;
800 return it913x_fe_suspend(state);
801}
802
803static u32 compute_div(u32 a, u32 b, u32 x)
804{
805 u32 res = 0;
806 u32 c = 0;
807 u32 i = 0;
808
809 if (a > b) {
810 c = a / b;
811 a = a - c * b;
812 }
813
814 for (i = 0; i < x; i++) {
815 if (a >= b) {
816 res += 1;
817 a -= b;
818 }
819 a <<= 1;
820 res <<= 1;
821 }
822
823 res = (c << x) + res;
824
825 return res;
826}
827
828static int it913x_fe_start(struct it913x_fe_state *state)
829{
830 struct it913xset *set_lna;
831 struct it913xset *set_mode;
832 int ret;
833 u8 adf = (state->config->adf & 0xf);
834 u32 adc, xtal;
835 u8 b[4];
836
837 if (state->config->chip_ver == 1)
838 ret = it913x_init_tuner(state);
839
840 info("ADF table value :%02x", adf);
841
842 if (adf < 10) {
843 state->crystalFrequency = fe_clockTable[adf].xtal ;
844 state->table = fe_clockTable[adf].table;
845 state->adcFrequency = state->table->adcFrequency;
846
847 adc = compute_div(state->adcFrequency, 1000000ul, 19ul);
848 xtal = compute_div(state->crystalFrequency, 1000000ul, 19ul);
849
850 } else
851 return -EINVAL;
852
853 /* Set LED indicator on GPIOH3 */
854 ret = it913x_write_reg(state, PRO_LINK, GPIOH3_EN, 0x1);
855 ret |= it913x_write_reg(state, PRO_LINK, GPIOH3_ON, 0x1);
856 ret |= it913x_write_reg(state, PRO_LINK, GPIOH3_O, 0x1);
857
858 ret |= it913x_write_reg(state, PRO_LINK, 0xf641, state->tuner_type);
859 ret |= it913x_write_reg(state, PRO_DMOD, 0xf5ca, 0x01);
860 ret |= it913x_write_reg(state, PRO_DMOD, 0xf715, 0x01);
861
862 b[0] = xtal & 0xff;
863 b[1] = (xtal >> 8) & 0xff;
864 b[2] = (xtal >> 16) & 0xff;
865 b[3] = (xtal >> 24);
866 ret |= it913x_write(state, PRO_DMOD, XTAL_CLK, b , 4);
867
868 b[0] = adc & 0xff;
869 b[1] = (adc >> 8) & 0xff;
870 b[2] = (adc >> 16) & 0xff;
871 ret |= it913x_write(state, PRO_DMOD, ADC_FREQ, b, 3);
872
873 if (state->config->adc_x2)
874 ret |= it913x_write_reg(state, PRO_DMOD, ADC_X_2, 0x01);
875 b[0] = 0;
876 b[1] = 0;
877 b[2] = 0;
878 ret |= it913x_write(state, PRO_DMOD, 0x0029, b, 3);
879
880 info("Crystal Frequency :%d Adc Frequency :%d ADC X2: %02x",
881 state->crystalFrequency, state->adcFrequency,
882 state->config->adc_x2);
883 deb_info("Xtal value :%04x Adc value :%04x", xtal, adc);
884
885 if (ret < 0)
886 return -ENODEV;
887
888 /* v1 or v2 tuner script */
889 if (state->config->chip_ver > 1)
890 ret = it913x_fe_script_loader(state, it9135_v2);
891 else
892 ret = it913x_fe_script_loader(state, it9135_v1);
893 if (ret < 0)
894 return ret;
895
896 /* LNA Scripts */
897 switch (state->tuner_type) {
898 case IT9135_51:
899 set_lna = it9135_51;
900 break;
901 case IT9135_52:
902 set_lna = it9135_52;
903 break;
904 case IT9135_60:
905 set_lna = it9135_60;
906 break;
907 case IT9135_61:
908 set_lna = it9135_61;
909 break;
910 case IT9135_62:
911 set_lna = it9135_62;
912 break;
913 case IT9135_38:
914 default:
915 set_lna = it9135_38;
916 }
917 info("Tuner LNA type :%02x", state->tuner_type);
918
919 ret = it913x_fe_script_loader(state, set_lna);
920 if (ret < 0)
921 return ret;
922
923 if (state->config->chip_ver == 2) {
924 ret = it913x_write_reg(state, PRO_DMOD, TRIGGER_OFSM, 0x1);
925 ret |= it913x_write_reg(state, PRO_LINK, PADODPU, 0x0);
926 ret |= it913x_write_reg(state, PRO_LINK, AGC_O_D, 0x0);
927 ret |= it913x_init_tuner(state);
928 }
929 if (ret < 0)
930 return -ENODEV;
931
932 /* Always solo frontend */
933 set_mode = set_solo_fe;
934 ret |= it913x_fe_script_loader(state, set_mode);
935
936 ret |= it913x_fe_suspend(state);
937 return (ret < 0) ? -ENODEV : 0;
938}
939
940static int it913x_fe_init(struct dvb_frontend *fe)
941{
942 struct it913x_fe_state *state = fe->demodulator_priv;
943 int ret = 0;
944 /* Power Up Tuner - common all versions */
945 ret = it913x_write_reg(state, PRO_DMOD, 0xec40, 0x1);
946
947 ret |= it913x_fe_script_loader(state, init_1);
948
949 ret |= it913x_write_reg(state, PRO_DMOD, AFE_MEM0, 0x0);
950
951 ret |= it913x_write_reg(state, PRO_DMOD, 0xfba8, 0x0);
952
953 return (ret < 0) ? -ENODEV : 0;
954}
955
956static void it913x_fe_release(struct dvb_frontend *fe)
957{
958 struct it913x_fe_state *state = fe->demodulator_priv;
959 kfree(state);
960}
961
962static struct dvb_frontend_ops it913x_fe_ofdm_ops;
963
964struct dvb_frontend *it913x_fe_attach(struct i2c_adapter *i2c_adap,
965 u8 i2c_addr, struct ite_config *config)
966{
967 struct it913x_fe_state *state = NULL;
968 int ret;
969
970 /* allocate memory for the internal state */
971 state = kzalloc(sizeof(struct it913x_fe_state), GFP_KERNEL);
972 if (state == NULL)
973 return NULL;
974 if (config == NULL)
975 goto error;
976
977 state->i2c_adap = i2c_adap;
978 state->i2c_addr = i2c_addr;
979 state->config = config;
980
981 switch (state->config->tuner_id_0) {
982 case IT9135_51:
983 case IT9135_52:
984 case IT9135_60:
985 case IT9135_61:
986 case IT9135_62:
987 state->tuner_type = state->config->tuner_id_0;
988 break;
989 default:
990 case IT9135_38:
991 state->tuner_type = IT9135_38;
992 }
993
994 ret = it913x_fe_start(state);
995 if (ret < 0)
996 goto error;
997
998
999 /* create dvb_frontend */
1000 memcpy(&state->frontend.ops, &it913x_fe_ofdm_ops,
1001 sizeof(struct dvb_frontend_ops));
1002 state->frontend.demodulator_priv = state;
1003
1004 return &state->frontend;
1005error:
1006 kfree(state);
1007 return NULL;
1008}
1009EXPORT_SYMBOL(it913x_fe_attach);
1010
1011static struct dvb_frontend_ops it913x_fe_ofdm_ops = {
1012 .delsys = { SYS_DVBT },
1013 .info = {
1014 .name = "it913x-fe DVB-T",
1015 .frequency_min = 51000000,
1016 .frequency_max = 1680000000,
1017 .frequency_stepsize = 62500,
1018 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
1019 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
1020 FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
1021 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
1022 FE_CAN_TRANSMISSION_MODE_AUTO |
1023 FE_CAN_GUARD_INTERVAL_AUTO |
1024 FE_CAN_HIERARCHY_AUTO,
1025 },
1026
1027 .release = it913x_fe_release,
1028
1029 .init = it913x_fe_init,
1030 .sleep = it913x_fe_sleep,
1031
1032 .set_frontend = it913x_fe_set_frontend,
1033 .get_frontend = it913x_fe_get_frontend,
1034
1035 .read_status = it913x_fe_read_status,
1036 .read_signal_strength = it913x_fe_read_signal_strength,
1037 .read_snr = it913x_fe_read_snr,
1038 .read_ber = it913x_fe_read_ber,
1039 .read_ucblocks = it913x_fe_read_ucblocks,
1040};
1041
1042MODULE_DESCRIPTION("it913x Frontend and it9137 tuner");
1043MODULE_AUTHOR("Malcolm Priestley tvboxspy@gmail.com");
1044MODULE_VERSION("1.15");
1045MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/it913x-fe.h b/drivers/media/dvb-frontends/it913x-fe.h
deleted file mode 100644
index df0ad4207343..000000000000
--- a/drivers/media/dvb-frontends/it913x-fe.h
+++ /dev/null
@@ -1,237 +0,0 @@
1/*
2 * Driver for it913x Frontend
3 *
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
19 */
20
21#ifndef IT913X_FE_H
22#define IT913X_FE_H
23
24#include <linux/kconfig.h>
25#include <linux/dvb/frontend.h>
26#include "dvb_frontend.h"
27
28struct ite_config {
29 u8 chip_ver;
30 u16 chip_type;
31 u32 firmware;
32 u8 firmware_ver;
33 u8 adc_x2;
34 u8 tuner_id_0;
35 u8 tuner_id_1;
36 u8 dual_mode;
37 u8 adf;
38 /* option to read SIGNAL_LEVEL */
39 u8 read_slevel;
40};
41
42#if IS_ENABLED(CONFIG_DVB_IT913X_FE)
43extern struct dvb_frontend *it913x_fe_attach(struct i2c_adapter *i2c_adap,
44 u8 i2c_addr, struct ite_config *config);
45#else
46static inline struct dvb_frontend *it913x_fe_attach(
47 struct i2c_adapter *i2c_adap,
48 u8 i2c_addr, struct ite_config *config)
49{
50 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
51 return NULL;
52}
53#endif /* CONFIG_IT913X_FE */
54#define I2C_BASE_ADDR 0x10
55#define DEV_0 0x0
56#define DEV_1 0x10
57#define PRO_LINK 0x0
58#define PRO_DMOD 0x1
59#define DEV_0_DMOD (PRO_DMOD << 0x7)
60#define DEV_1_DMOD (DEV_0_DMOD | DEV_1)
61#define CHIP2_I2C_ADDR 0x3a
62
63#define AFE_MEM0 0xfb24
64
65#define MP2_SW_RST 0xf99d
66#define MP2IF2_SW_RST 0xf9a4
67
68#define PADODPU 0xd827
69#define THIRDODPU 0xd828
70#define AGC_O_D 0xd829
71
72#define EP0_TX_EN 0xdd11
73#define EP0_TX_NAK 0xdd13
74#define EP4_TX_LEN_LSB 0xdd88
75#define EP4_TX_LEN_MSB 0xdd89
76#define EP4_MAX_PKT 0xdd0c
77#define EP5_TX_LEN_LSB 0xdd8a
78#define EP5_TX_LEN_MSB 0xdd8b
79#define EP5_MAX_PKT 0xdd0d
80
81#define IO_MUX_POWER_CLK 0xd800
82#define CLK_O_EN 0xd81a
83#define I2C_CLK 0xf103
84#define I2C_CLK_100 0x7
85#define I2C_CLK_400 0x1a
86
87#define D_TPSD_LOCK 0xf5a9
88#define MP2IF2_EN 0xf9a3
89#define MP2IF_SERIAL 0xf985
90#define TSIS_ENABLE 0xf9cd
91#define MP2IF2_HALF_PSB 0xf9a5
92#define MP2IF_STOP_EN 0xf9b5
93#define MPEG_FULL_SPEED 0xf990
94#define TOP_HOSTB_SER_MODE 0xd91c
95
96#define PID_RST 0xf992
97#define PID_EN 0xf993
98#define PID_INX_EN 0xf994
99#define PID_INX 0xf995
100#define PID_LSB 0xf996
101#define PID_MSB 0xf997
102
103#define MP2IF_MPEG_PAR_MODE 0xf986
104#define DCA_UPPER_CHIP 0xf731
105#define DCA_LOWER_CHIP 0xf732
106#define DCA_PLATCH 0xf730
107#define DCA_FPGA_LATCH 0xf778
108#define DCA_STAND_ALONE 0xf73c
109#define DCA_ENABLE 0xf776
110
111#define DVBT_INTEN 0xf41f
112#define DVBT_ENABLE 0xf41a
113#define HOSTB_DCA_LOWER 0xd91f
114#define HOSTB_MPEG_PAR_MODE 0xd91b
115#define HOSTB_MPEG_SER_MODE 0xd91c
116#define HOSTB_MPEG_SER_DO7 0xd91d
117#define HOSTB_DCA_UPPER 0xd91e
118#define PADMISCDR2 0xd830
119#define PADMISCDR4 0xd831
120#define PADMISCDR8 0xd832
121#define PADMISCDRSR 0xd833
122#define LOCK3_OUT 0xd8fd
123
124#define GPIOH1_O 0xd8af
125#define GPIOH1_EN 0xd8b0
126#define GPIOH1_ON 0xd8b1
127#define GPIOH3_O 0xd8b3
128#define GPIOH3_EN 0xd8b4
129#define GPIOH3_ON 0xd8b5
130#define GPIOH5_O 0xd8bb
131#define GPIOH5_EN 0xd8bc
132#define GPIOH5_ON 0xd8bd
133
134#define AFE_MEM0 0xfb24
135
136#define REG_TPSD_TX_MODE 0xf900
137#define REG_TPSD_GI 0xf901
138#define REG_TPSD_HIER 0xf902
139#define REG_TPSD_CONST 0xf903
140#define REG_BW 0xf904
141#define REG_PRIV 0xf905
142#define REG_TPSD_HP_CODE 0xf906
143#define REG_TPSD_LP_CODE 0xf907
144
145#define MP2IF_SYNC_LK 0xf999
146#define ADC_FREQ 0xf1cd
147
148#define TRIGGER_OFSM 0x0000
149/* COEFF Registers start at 0x0001 to 0x0020 */
150#define COEFF_1_2048 0x0001
151#define XTAL_CLK 0x0025
152#define BFS_FCW 0x0029
153
154/* Error Regs */
155#define RSD_ABORT_PKT_LSB 0x0032
156#define RSD_ABORT_PKT_MSB 0x0033
157#define RSD_BIT_ERR_0_7 0x0034
158#define RSD_BIT_ERR_8_15 0x0035
159#define RSD_BIT_ERR_23_16 0x0036
160#define RSD_BIT_COUNT_LSB 0x0037
161#define RSD_BIT_COUNT_MSB 0x0038
162
163#define TPSD_LOCK 0x003c
164#define TRAINING_MODE 0x0040
165#define ADC_X_2 0x0045
166#define TUNER_ID 0x0046
167#define EMPTY_CHANNEL_STATUS 0x0047
168#define SIGNAL_LEVEL 0x0048
169#define SIGNAL_QUALITY 0x0049
170#define EST_SIGNAL_LEVEL 0x004a
171#define FREE_BAND 0x004b
172#define SUSPEND_FLAG 0x004c
173#define VAR_P_INBAND 0x00f7
174
175/* Build in tuner types */
176#define IT9137 0x38
177#define IT9135_38 0x38
178#define IT9135_51 0x51
179#define IT9135_52 0x52
180#define IT9135_60 0x60
181#define IT9135_61 0x61
182#define IT9135_62 0x62
183
184enum {
185 CMD_DEMOD_READ = 0,
186 CMD_DEMOD_WRITE,
187 CMD_TUNER_READ,
188 CMD_TUNER_WRITE,
189 CMD_REG_EEPROM_READ,
190 CMD_REG_EEPROM_WRITE,
191 CMD_DATA_READ,
192 CMD_VAR_READ = 8,
193 CMD_VAR_WRITE,
194 CMD_PLATFORM_GET,
195 CMD_PLATFORM_SET,
196 CMD_IP_CACHE,
197 CMD_IP_ADD,
198 CMD_IP_REMOVE,
199 CMD_PID_ADD,
200 CMD_PID_REMOVE,
201 CMD_SIPSI_GET,
202 CMD_SIPSI_MPE_RESET,
203 CMD_H_PID_ADD = 0x15,
204 CMD_H_PID_REMOVE,
205 CMD_ABORT,
206 CMD_IR_GET,
207 CMD_IR_SET,
208 CMD_FW_DOWNLOAD = 0x21,
209 CMD_QUERYINFO,
210 CMD_BOOT,
211 CMD_FW_DOWNLOAD_BEGIN,
212 CMD_FW_DOWNLOAD_END,
213 CMD_RUN_CODE,
214 CMD_SCATTER_READ = 0x28,
215 CMD_SCATTER_WRITE,
216 CMD_GENERIC_READ,
217 CMD_GENERIC_WRITE
218};
219
220enum {
221 READ_LONG,
222 WRITE_LONG,
223 READ_SHORT,
224 WRITE_SHORT,
225 READ_DATA,
226 WRITE_DATA,
227 WRITE_CMD,
228};
229
230enum {
231 IT9135_AUTO = 0,
232 IT9137_FW,
233 IT9135_V1_FW,
234 IT9135_V2_FW,
235};
236
237#endif /* IT913X_FE_H */
diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index b8a7897e7bd8..2ef8ce13fb60 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -271,6 +271,13 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
271 ret = fe->ops.tuner_ops.get_frequency(fe, &tuner_frequency); 271 ret = fe->ops.tuner_ops.get_frequency(fe, &tuner_frequency);
272 if (ret) 272 if (ret)
273 goto err; 273 goto err;
274 } else {
275 /*
276 * Use nominal target frequency as tuner driver does not provide
277 * actual frequency used. Carrier offset calculation is not
278 * valid.
279 */
280 tuner_frequency = c->frequency;
274 } 281 }
275 282
276 /* reset */ 283 /* reset */
@@ -428,18 +435,10 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
428 goto err; 435 goto err;
429 436
430 switch (target_mclk) { 437 switch (target_mclk) {
431 case 72000:
432 u8tmp1 = 0x00; /* 0b00 */
433 u8tmp2 = 0x03; /* 0b11 */
434 break;
435 case 96000: 438 case 96000:
436 u8tmp1 = 0x02; /* 0b10 */ 439 u8tmp1 = 0x02; /* 0b10 */
437 u8tmp2 = 0x01; /* 0b01 */ 440 u8tmp2 = 0x01; /* 0b01 */
438 break; 441 break;
439 case 115200:
440 u8tmp1 = 0x01; /* 0b01 */
441 u8tmp2 = 0x01; /* 0b01 */
442 break;
443 case 144000: 442 case 144000:
444 u8tmp1 = 0x00; /* 0b00 */ 443 u8tmp1 = 0x00; /* 0b00 */
445 u8tmp2 = 0x01; /* 0b01 */ 444 u8tmp2 = 0x01; /* 0b01 */
@@ -448,10 +447,6 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
448 u8tmp1 = 0x03; /* 0b11 */ 447 u8tmp1 = 0x03; /* 0b11 */
449 u8tmp2 = 0x00; /* 0b00 */ 448 u8tmp2 = 0x00; /* 0b00 */
450 break; 449 break;
451 default:
452 dev_dbg(&priv->i2c->dev, "%s: invalid target_mclk\n", __func__);
453 ret = -EINVAL;
454 goto err;
455 } 450 }
456 451
457 ret = m88ds3103_wr_reg_mask(priv, 0x22, u8tmp1 << 6, 0xc0); 452 ret = m88ds3103_wr_reg_mask(priv, 0x22, u8tmp1 << 6, 0xc0);
@@ -711,9 +706,6 @@ static int m88ds3103_get_frontend(struct dvb_frontend *fe)
711 case 1: 706 case 1:
712 c->inversion = INVERSION_ON; 707 c->inversion = INVERSION_ON;
713 break; 708 break;
714 default:
715 dev_dbg(&priv->i2c->dev, "%s: invalid inversion\n",
716 __func__);
717 } 709 }
718 710
719 switch ((buf[1] >> 5) & 0x07) { 711 switch ((buf[1] >> 5) & 0x07) {
@@ -793,9 +785,6 @@ static int m88ds3103_get_frontend(struct dvb_frontend *fe)
793 case 1: 785 case 1:
794 c->pilot = PILOT_ON; 786 c->pilot = PILOT_ON;
795 break; 787 break;
796 default:
797 dev_dbg(&priv->i2c->dev, "%s: invalid pilot\n",
798 __func__);
799 } 788 }
800 789
801 switch ((buf[0] >> 6) & 0x07) { 790 switch ((buf[0] >> 6) & 0x07) {
@@ -823,9 +812,6 @@ static int m88ds3103_get_frontend(struct dvb_frontend *fe)
823 case 1: 812 case 1:
824 c->inversion = INVERSION_ON; 813 c->inversion = INVERSION_ON;
825 break; 814 break;
826 default:
827 dev_dbg(&priv->i2c->dev, "%s: invalid inversion\n",
828 __func__);
829 } 815 }
830 816
831 switch ((buf[2] >> 0) & 0x03) { 817 switch ((buf[2] >> 0) & 0x03) {
@@ -958,7 +944,7 @@ static int m88ds3103_set_tone(struct dvb_frontend *fe,
958 switch (fe_sec_tone_mode) { 944 switch (fe_sec_tone_mode) {
959 case SEC_TONE_ON: 945 case SEC_TONE_ON:
960 tone = 0; 946 tone = 0;
961 reg_a1_mask = 0x87; 947 reg_a1_mask = 0x47;
962 break; 948 break;
963 case SEC_TONE_OFF: 949 case SEC_TONE_OFF:
964 tone = 1; 950 tone = 1;
diff --git a/drivers/media/dvb-frontends/m88rs2000.c b/drivers/media/dvb-frontends/m88rs2000.c
index b2351466b0da..32cffca14d0b 100644
--- a/drivers/media/dvb-frontends/m88rs2000.c
+++ b/drivers/media/dvb-frontends/m88rs2000.c
@@ -715,6 +715,22 @@ static int m88rs2000_get_frontend(struct dvb_frontend *fe)
715 return 0; 715 return 0;
716} 716}
717 717
718static int m88rs2000_get_tune_settings(struct dvb_frontend *fe,
719 struct dvb_frontend_tune_settings *tune)
720{
721 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
722
723 if (c->symbol_rate > 3000000)
724 tune->min_delay_ms = 2000;
725 else
726 tune->min_delay_ms = 3000;
727
728 tune->step_size = c->symbol_rate / 16000;
729 tune->max_drift = c->symbol_rate / 2000;
730
731 return 0;
732}
733
718static int m88rs2000_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) 734static int m88rs2000_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
719{ 735{
720 struct m88rs2000_state *state = fe->demodulator_priv; 736 struct m88rs2000_state *state = fe->demodulator_priv;
@@ -746,7 +762,7 @@ static struct dvb_frontend_ops m88rs2000_ops = {
746 .symbol_rate_tolerance = 500, /* ppm */ 762 .symbol_rate_tolerance = 500, /* ppm */
747 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 763 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
748 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | 764 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
749 FE_CAN_QPSK | 765 FE_CAN_QPSK | FE_CAN_INVERSION_AUTO |
750 FE_CAN_FEC_AUTO 766 FE_CAN_FEC_AUTO
751 }, 767 },
752 768
@@ -766,6 +782,7 @@ static struct dvb_frontend_ops m88rs2000_ops = {
766 782
767 .set_frontend = m88rs2000_set_frontend, 783 .set_frontend = m88rs2000_set_frontend,
768 .get_frontend = m88rs2000_get_frontend, 784 .get_frontend = m88rs2000_get_frontend,
785 .get_tune_settings = m88rs2000_get_tune_settings,
769}; 786};
770 787
771struct dvb_frontend *m88rs2000_attach(const struct m88rs2000_config *config, 788struct dvb_frontend *m88rs2000_attach(const struct m88rs2000_config *config,
diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c
index 2c7217fb1415..2f458bb188c7 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Fujitu mb86a20s ISDB-T/ISDB-Tsb Module driver 2 * Fujitu mb86a20s ISDB-T/ISDB-Tsb Module driver
3 * 3 *
4 * Copyright (C) 2010-2013 Mauro Carvalho Chehab <mchehab@redhat.com> 4 * Copyright (C) 2010-2013 Mauro Carvalho Chehab
5 * Copyright (C) 2009-2010 Douglas Landgraf <dougsland@redhat.com> 5 * Copyright (C) 2009-2010 Douglas Landgraf <dougsland@redhat.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
@@ -2156,5 +2156,5 @@ static struct dvb_frontend_ops mb86a20s_ops = {
2156}; 2156};
2157 2157
2158MODULE_DESCRIPTION("DVB Frontend module for Fujitsu mb86A20s hardware"); 2158MODULE_DESCRIPTION("DVB Frontend module for Fujitsu mb86A20s hardware");
2159MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 2159MODULE_AUTHOR("Mauro Carvalho Chehab");
2160MODULE_LICENSE("GPL"); 2160MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/mb86a20s.h b/drivers/media/dvb-frontends/mb86a20s.h
index 6627a3976087..cbeb941fba7c 100644
--- a/drivers/media/dvb-frontends/mb86a20s.h
+++ b/drivers/media/dvb-frontends/mb86a20s.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Fujitsu mb86a20s driver 2 * Fujitsu mb86a20s driver
3 * 3 *
4 * Copyright (C) 2010 Mauro Carvalho Chehab <mchehab@redhat.com> 4 * Copyright (C) 2010 Mauro Carvalho Chehab
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/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index ff73da9365e3..fdbed35c87fa 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -24,11 +24,6 @@
24 24
25/* Max transfer size done by I2C transfer functions */ 25/* Max transfer size done by I2C transfer functions */
26#define MAX_XFER_SIZE 64 26#define MAX_XFER_SIZE 64
27
28int rtl2832_debug;
29module_param_named(debug, rtl2832_debug, int, 0644);
30MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
31
32#define REG_MASK(b) (BIT(b + 1) - 1) 27#define REG_MASK(b) (BIT(b + 1) - 1)
33 28
34static const struct rtl2832_reg_entry registers[] = { 29static const struct rtl2832_reg_entry registers[] = {
@@ -185,12 +180,13 @@ static int rtl2832_wr(struct rtl2832_priv *priv, u8 reg, u8 *val, int len)
185 buf[0] = reg; 180 buf[0] = reg;
186 memcpy(&buf[1], val, len); 181 memcpy(&buf[1], val, len);
187 182
188 ret = i2c_transfer(priv->i2c, msg, 1); 183 ret = i2c_transfer(priv->i2c_adapter, msg, 1);
189 if (ret == 1) { 184 if (ret == 1) {
190 ret = 0; 185 ret = 0;
191 } else { 186 } else {
192 dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%02x " \ 187 dev_warn(&priv->i2c->dev,
193 "len=%d\n", KBUILD_MODNAME, ret, reg, len); 188 "%s: i2c wr failed=%d reg=%02x len=%d\n",
189 KBUILD_MODNAME, ret, reg, len);
194 ret = -EREMOTEIO; 190 ret = -EREMOTEIO;
195 } 191 }
196 return ret; 192 return ret;
@@ -214,12 +210,13 @@ static int rtl2832_rd(struct rtl2832_priv *priv, u8 reg, u8 *val, int len)
214 } 210 }
215 }; 211 };
216 212
217 ret = i2c_transfer(priv->i2c, msg, 2); 213 ret = i2c_transfer(priv->i2c_adapter, msg, 2);
218 if (ret == 2) { 214 if (ret == 2) {
219 ret = 0; 215 ret = 0;
220 } else { 216 } else {
221 dev_warn(&priv->i2c->dev, "%s: i2c rd failed=%d reg=%02x " \ 217 dev_warn(&priv->i2c->dev,
222 "len=%d\n", KBUILD_MODNAME, ret, reg, len); 218 "%s: i2c rd failed=%d reg=%02x len=%d\n",
219 KBUILD_MODNAME, ret, reg, len);
223 ret = -EREMOTEIO; 220 ret = -EREMOTEIO;
224 } 221 }
225 return ret; 222 return ret;
@@ -417,7 +414,7 @@ static int rtl2832_set_if(struct dvb_frontend *fe, u32 if_freq)
417 414
418 ret = rtl2832_wr_demod_reg(priv, DVBT_PSET_IFFREQ, pset_iffreq); 415 ret = rtl2832_wr_demod_reg(priv, DVBT_PSET_IFFREQ, pset_iffreq);
419 416
420 return (ret); 417 return ret;
421} 418}
422 419
423static int rtl2832_init(struct dvb_frontend *fe) 420static int rtl2832_init(struct dvb_frontend *fe)
@@ -514,15 +511,10 @@ static int rtl2832_init(struct dvb_frontend *fe)
514 goto err; 511 goto err;
515 } 512 }
516 513
517 if (!fe->ops.tuner_ops.get_if_frequency) {
518 ret = rtl2832_set_if(fe, priv->cfg.if_dvbt);
519 if (ret)
520 goto err;
521 }
522
523 /* 514 /*
524 * r820t NIM code does a software reset here at the demod - 515 * r820t NIM code does a software reset here at the demod -
525 * may not be needed, as there's already a software reset at set_params() 516 * may not be needed, as there's already a software reset at
517 * set_params()
526 */ 518 */
527#if 1 519#if 1
528 /* soft reset */ 520 /* soft reset */
@@ -599,9 +591,9 @@ static int rtl2832_set_frontend(struct dvb_frontend *fe)
599 }; 591 };
600 592
601 593
602 dev_dbg(&priv->i2c->dev, "%s: frequency=%d bandwidth_hz=%d " \ 594 dev_dbg(&priv->i2c->dev,
603 "inversion=%d\n", __func__, c->frequency, 595 "%s: frequency=%d bandwidth_hz=%d inversion=%d\n",
604 c->bandwidth_hz, c->inversion); 596 __func__, c->frequency, c->bandwidth_hz, c->inversion);
605 597
606 /* program tuner */ 598 /* program tuner */
607 if (fe->ops.tuner_ops.set_params) 599 if (fe->ops.tuner_ops.set_params)
@@ -899,9 +891,149 @@ static void rtl2832_release(struct dvb_frontend *fe)
899 struct rtl2832_priv *priv = fe->demodulator_priv; 891 struct rtl2832_priv *priv = fe->demodulator_priv;
900 892
901 dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 893 dev_dbg(&priv->i2c->dev, "%s:\n", __func__);
894 cancel_delayed_work_sync(&priv->i2c_gate_work);
895 i2c_del_mux_adapter(priv->i2c_adapter_tuner);
896 i2c_del_mux_adapter(priv->i2c_adapter);
902 kfree(priv); 897 kfree(priv);
903} 898}
904 899
900/*
901 * Delay mechanism to avoid unneeded I2C gate open / close. Gate close is
902 * delayed here a little bit in order to see if there is sequence of I2C
903 * messages sent to same I2C bus.
904 * We must use unlocked version of __i2c_transfer() in order to avoid deadlock
905 * as lock is already taken by calling muxed i2c_transfer().
906 */
907static void rtl2832_i2c_gate_work(struct work_struct *work)
908{
909 struct rtl2832_priv *priv = container_of(work,
910 struct rtl2832_priv, i2c_gate_work.work);
911 struct i2c_adapter *adap = priv->i2c;
912 int ret;
913 u8 buf[2];
914 struct i2c_msg msg[1] = {
915 {
916 .addr = priv->cfg.i2c_addr,
917 .flags = 0,
918 .len = sizeof(buf),
919 .buf = buf,
920 }
921 };
922
923 /* select reg bank 1 */
924 buf[0] = 0x00;
925 buf[1] = 0x01;
926 ret = __i2c_transfer(adap, msg, 1);
927 if (ret != 1)
928 goto err;
929
930 priv->page = 1;
931
932 /* close I2C repeater gate */
933 buf[0] = 0x01;
934 buf[1] = 0x10;
935 ret = __i2c_transfer(adap, msg, 1);
936 if (ret != 1)
937 goto err;
938
939 priv->i2c_gate_state = 0;
940
941 return;
942err:
943 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
944
945 return;
946}
947
948static int rtl2832_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id)
949{
950 struct rtl2832_priv *priv = mux_priv;
951 int ret;
952 u8 buf[2], val;
953 struct i2c_msg msg[1] = {
954 {
955 .addr = priv->cfg.i2c_addr,
956 .flags = 0,
957 .len = sizeof(buf),
958 .buf = buf,
959 }
960 };
961 struct i2c_msg msg_rd[2] = {
962 {
963 .addr = priv->cfg.i2c_addr,
964 .flags = 0,
965 .len = 1,
966 .buf = "\x01",
967 }, {
968 .addr = priv->cfg.i2c_addr,
969 .flags = I2C_M_RD,
970 .len = 1,
971 .buf = &val,
972 }
973 };
974
975 /* terminate possible gate closing */
976 cancel_delayed_work_sync(&priv->i2c_gate_work);
977
978 if (priv->i2c_gate_state == chan_id)
979 return 0;
980
981 /* select reg bank 1 */
982 buf[0] = 0x00;
983 buf[1] = 0x01;
984 ret = __i2c_transfer(adap, msg, 1);
985 if (ret != 1)
986 goto err;
987
988 priv->page = 1;
989
990 /* we must read that register, otherwise there will be errors */
991 ret = __i2c_transfer(adap, msg_rd, 2);
992 if (ret != 2)
993 goto err;
994
995 /* open or close I2C repeater gate */
996 buf[0] = 0x01;
997 if (chan_id == 1)
998 buf[1] = 0x18; /* open */
999 else
1000 buf[1] = 0x10; /* close */
1001
1002 ret = __i2c_transfer(adap, msg, 1);
1003 if (ret != 1)
1004 goto err;
1005
1006 priv->i2c_gate_state = chan_id;
1007
1008 return 0;
1009err:
1010 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
1011
1012 return -EREMOTEIO;
1013}
1014
1015static int rtl2832_deselect(struct i2c_adapter *adap, void *mux_priv,
1016 u32 chan_id)
1017{
1018 struct rtl2832_priv *priv = mux_priv;
1019 schedule_delayed_work(&priv->i2c_gate_work, usecs_to_jiffies(100));
1020 return 0;
1021}
1022
1023struct i2c_adapter *rtl2832_get_i2c_adapter(struct dvb_frontend *fe)
1024{
1025 struct rtl2832_priv *priv = fe->demodulator_priv;
1026 return priv->i2c_adapter_tuner;
1027}
1028EXPORT_SYMBOL(rtl2832_get_i2c_adapter);
1029
1030struct i2c_adapter *rtl2832_get_private_i2c_adapter(struct dvb_frontend *fe)
1031{
1032 struct rtl2832_priv *priv = fe->demodulator_priv;
1033 return priv->i2c_adapter;
1034}
1035EXPORT_SYMBOL(rtl2832_get_private_i2c_adapter);
1036
905struct dvb_frontend *rtl2832_attach(const struct rtl2832_config *cfg, 1037struct dvb_frontend *rtl2832_attach(const struct rtl2832_config *cfg,
906 struct i2c_adapter *i2c) 1038 struct i2c_adapter *i2c)
907{ 1039{
@@ -920,12 +1052,25 @@ struct dvb_frontend *rtl2832_attach(const struct rtl2832_config *cfg,
920 priv->i2c = i2c; 1052 priv->i2c = i2c;
921 priv->tuner = cfg->tuner; 1053 priv->tuner = cfg->tuner;
922 memcpy(&priv->cfg, cfg, sizeof(struct rtl2832_config)); 1054 memcpy(&priv->cfg, cfg, sizeof(struct rtl2832_config));
1055 INIT_DELAYED_WORK(&priv->i2c_gate_work, rtl2832_i2c_gate_work);
1056
1057 /* create muxed i2c adapter for demod itself */
1058 priv->i2c_adapter = i2c_add_mux_adapter(i2c, &i2c->dev, priv, 0, 0, 0,
1059 rtl2832_select, NULL);
1060 if (priv->i2c_adapter == NULL)
1061 goto err;
923 1062
924 /* check if the demod is there */ 1063 /* check if the demod is there */
925 ret = rtl2832_rd_reg(priv, 0x00, 0x0, &tmp); 1064 ret = rtl2832_rd_reg(priv, 0x00, 0x0, &tmp);
926 if (ret) 1065 if (ret)
927 goto err; 1066 goto err;
928 1067
1068 /* create muxed i2c adapter for demod tuner bus */
1069 priv->i2c_adapter_tuner = i2c_add_mux_adapter(i2c, &i2c->dev, priv,
1070 0, 1, 0, rtl2832_select, rtl2832_deselect);
1071 if (priv->i2c_adapter_tuner == NULL)
1072 goto err;
1073
929 /* create dvb_frontend */ 1074 /* create dvb_frontend */
930 memcpy(&priv->fe.ops, &rtl2832_ops, sizeof(struct dvb_frontend_ops)); 1075 memcpy(&priv->fe.ops, &rtl2832_ops, sizeof(struct dvb_frontend_ops));
931 priv->fe.demodulator_priv = priv; 1076 priv->fe.demodulator_priv = priv;
@@ -936,6 +1081,8 @@ struct dvb_frontend *rtl2832_attach(const struct rtl2832_config *cfg,
936 return &priv->fe; 1081 return &priv->fe;
937err: 1082err:
938 dev_dbg(&i2c->dev, "%s: failed=%d\n", __func__, ret); 1083 dev_dbg(&i2c->dev, "%s: failed=%d\n", __func__, ret);
1084 if (priv && priv->i2c_adapter)
1085 i2c_del_mux_adapter(priv->i2c_adapter);
939 kfree(priv); 1086 kfree(priv);
940 return NULL; 1087 return NULL;
941} 1088}
diff --git a/drivers/media/dvb-frontends/rtl2832.h b/drivers/media/dvb-frontends/rtl2832.h
index 2cfbb6a97061..cb3b6b0775b8 100644
--- a/drivers/media/dvb-frontends/rtl2832.h
+++ b/drivers/media/dvb-frontends/rtl2832.h
@@ -38,13 +38,6 @@ struct rtl2832_config {
38 u32 xtal; 38 u32 xtal;
39 39
40 /* 40 /*
41 * IFs for all used modes.
42 * Hz
43 * 4570000, 4571429, 36000000, 36125000, 36166667, 44000000
44 */
45 u32 if_dvbt;
46
47 /*
48 * tuner 41 * tuner
49 * XXX: This must be keep sync with dvb_usb_rtl28xxu demod driver. 42 * XXX: This must be keep sync with dvb_usb_rtl28xxu demod driver.
50 */ 43 */
@@ -58,11 +51,21 @@ struct rtl2832_config {
58}; 51};
59 52
60#if IS_ENABLED(CONFIG_DVB_RTL2832) 53#if IS_ENABLED(CONFIG_DVB_RTL2832)
61extern struct dvb_frontend *rtl2832_attach( 54struct dvb_frontend *rtl2832_attach(
62 const struct rtl2832_config *cfg, 55 const struct rtl2832_config *cfg,
63 struct i2c_adapter *i2c 56 struct i2c_adapter *i2c
64); 57);
58
59extern struct i2c_adapter *rtl2832_get_i2c_adapter(
60 struct dvb_frontend *fe
61);
62
63extern struct i2c_adapter *rtl2832_get_private_i2c_adapter(
64 struct dvb_frontend *fe
65);
66
65#else 67#else
68
66static inline struct dvb_frontend *rtl2832_attach( 69static inline struct dvb_frontend *rtl2832_attach(
67 const struct rtl2832_config *config, 70 const struct rtl2832_config *config,
68 struct i2c_adapter *i2c 71 struct i2c_adapter *i2c
@@ -71,6 +74,21 @@ static inline struct dvb_frontend *rtl2832_attach(
71 pr_warn("%s: driver disabled by Kconfig\n", __func__); 74 pr_warn("%s: driver disabled by Kconfig\n", __func__);
72 return NULL; 75 return NULL;
73} 76}
77
78static inline struct i2c_adapter *rtl2832_get_i2c_adapter(
79 struct dvb_frontend *fe
80)
81{
82 return NULL;
83}
84
85static inline struct i2c_adapter *rtl2832_get_private_i2c_adapter(
86 struct dvb_frontend *fe
87)
88{
89 return NULL;
90}
91
74#endif 92#endif
75 93
76 94
diff --git a/drivers/media/dvb-frontends/rtl2832_priv.h b/drivers/media/dvb-frontends/rtl2832_priv.h
index b5f2b80092ee..ae469f032fe6 100644
--- a/drivers/media/dvb-frontends/rtl2832_priv.h
+++ b/drivers/media/dvb-frontends/rtl2832_priv.h
@@ -23,9 +23,12 @@
23 23
24#include "dvb_frontend.h" 24#include "dvb_frontend.h"
25#include "rtl2832.h" 25#include "rtl2832.h"
26#include <linux/i2c-mux.h>
26 27
27struct rtl2832_priv { 28struct rtl2832_priv {
28 struct i2c_adapter *i2c; 29 struct i2c_adapter *i2c;
30 struct i2c_adapter *i2c_adapter;
31 struct i2c_adapter *i2c_adapter_tuner;
29 struct dvb_frontend fe; 32 struct dvb_frontend fe;
30 struct rtl2832_config cfg; 33 struct rtl2832_config cfg;
31 34
@@ -34,6 +37,7 @@ struct rtl2832_priv {
34 37
35 u8 tuner; 38 u8 tuner;
36 u8 page; /* active register page */ 39 u8 page; /* active register page */
40 struct delayed_work i2c_gate_work;
37}; 41};
38 42
39struct rtl2832_reg_entry { 43struct rtl2832_reg_entry {
@@ -267,7 +271,7 @@ static const struct rtl2832_reg_value rtl2832_tuner_init_tua9001[] = {
267 {DVBT_OPT_ADC_IQ, 0x1}, 271 {DVBT_OPT_ADC_IQ, 0x1},
268 {DVBT_AD_AVI, 0x0}, 272 {DVBT_AD_AVI, 0x0},
269 {DVBT_AD_AVQ, 0x0}, 273 {DVBT_AD_AVQ, 0x0},
270 {DVBT_SPEC_INV, 0x0}, 274 {DVBT_SPEC_INV, 0x0},
271}; 275};
272 276
273static const struct rtl2832_reg_value rtl2832_tuner_init_fc0012[] = { 277static const struct rtl2832_reg_value rtl2832_tuner_init_fc0012[] = {
@@ -301,7 +305,7 @@ static const struct rtl2832_reg_value rtl2832_tuner_init_fc0012[] = {
301 {DVBT_GI_PGA_STATE, 0x0}, 305 {DVBT_GI_PGA_STATE, 0x0},
302 {DVBT_EN_AGC_PGA, 0x1}, 306 {DVBT_EN_AGC_PGA, 0x1},
303 {DVBT_IF_AGC_MAN, 0x0}, 307 {DVBT_IF_AGC_MAN, 0x0},
304 {DVBT_SPEC_INV, 0x0}, 308 {DVBT_SPEC_INV, 0x0},
305}; 309};
306 310
307static const struct rtl2832_reg_value rtl2832_tuner_init_e4000[] = { 311static const struct rtl2832_reg_value rtl2832_tuner_init_e4000[] = {
@@ -339,32 +343,32 @@ static const struct rtl2832_reg_value rtl2832_tuner_init_e4000[] = {
339 {DVBT_REG_MONSEL, 0x1}, 343 {DVBT_REG_MONSEL, 0x1},
340 {DVBT_REG_MON, 0x1}, 344 {DVBT_REG_MON, 0x1},
341 {DVBT_REG_4MSEL, 0x0}, 345 {DVBT_REG_4MSEL, 0x0},
342 {DVBT_SPEC_INV, 0x0}, 346 {DVBT_SPEC_INV, 0x0},
343}; 347};
344 348
345static const struct rtl2832_reg_value rtl2832_tuner_init_r820t[] = { 349static const struct rtl2832_reg_value rtl2832_tuner_init_r820t[] = {
346 {DVBT_DAGC_TRG_VAL, 0x39}, 350 {DVBT_DAGC_TRG_VAL, 0x39},
347 {DVBT_AGC_TARG_VAL_0, 0x0}, 351 {DVBT_AGC_TARG_VAL_0, 0x0},
348 {DVBT_AGC_TARG_VAL_8_1, 0x40}, 352 {DVBT_AGC_TARG_VAL_8_1, 0x40},
349 {DVBT_AAGC_LOOP_GAIN, 0x16}, 353 {DVBT_AAGC_LOOP_GAIN, 0x16},
350 {DVBT_LOOP_GAIN2_3_0, 0x8}, 354 {DVBT_LOOP_GAIN2_3_0, 0x8},
351 {DVBT_LOOP_GAIN2_4, 0x1}, 355 {DVBT_LOOP_GAIN2_4, 0x1},
352 {DVBT_LOOP_GAIN3, 0x18}, 356 {DVBT_LOOP_GAIN3, 0x18},
353 {DVBT_VTOP1, 0x35}, 357 {DVBT_VTOP1, 0x35},
354 {DVBT_VTOP2, 0x21}, 358 {DVBT_VTOP2, 0x21},
355 {DVBT_VTOP3, 0x21}, 359 {DVBT_VTOP3, 0x21},
356 {DVBT_KRF1, 0x0}, 360 {DVBT_KRF1, 0x0},
357 {DVBT_KRF2, 0x40}, 361 {DVBT_KRF2, 0x40},
358 {DVBT_KRF3, 0x10}, 362 {DVBT_KRF3, 0x10},
359 {DVBT_KRF4, 0x10}, 363 {DVBT_KRF4, 0x10},
360 {DVBT_IF_AGC_MIN, 0x80}, 364 {DVBT_IF_AGC_MIN, 0x80},
361 {DVBT_IF_AGC_MAX, 0x7f}, 365 {DVBT_IF_AGC_MAX, 0x7f},
362 {DVBT_RF_AGC_MIN, 0x80}, 366 {DVBT_RF_AGC_MIN, 0x80},
363 {DVBT_RF_AGC_MAX, 0x7f}, 367 {DVBT_RF_AGC_MAX, 0x7f},
364 {DVBT_POLAR_RF_AGC, 0x0}, 368 {DVBT_POLAR_RF_AGC, 0x0},
365 {DVBT_POLAR_IF_AGC, 0x0}, 369 {DVBT_POLAR_IF_AGC, 0x0},
366 {DVBT_AD7_SETTING, 0xe9f4}, 370 {DVBT_AD7_SETTING, 0xe9f4},
367 {DVBT_SPEC_INV, 0x1}, 371 {DVBT_SPEC_INV, 0x1},
368}; 372};
369 373
370#endif /* RTL2832_PRIV_H */ 374#endif /* RTL2832_PRIV_H */
diff --git a/drivers/media/dvb-frontends/s921.c b/drivers/media/dvb-frontends/s921.c
index a271ac3eaec0..69862e1fd9e9 100644
--- a/drivers/media/dvb-frontends/s921.c
+++ b/drivers/media/dvb-frontends/s921.c
@@ -2,7 +2,7 @@
2 * Sharp VA3A5JZ921 One Seg Broadcast Module driver 2 * Sharp VA3A5JZ921 One Seg Broadcast Module driver
3 * This device is labeled as just S. 921 at the top of the frontend can 3 * This device is labeled as just S. 921 at the top of the frontend can
4 * 4 *
5 * Copyright (C) 2009-2010 Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (C) 2009-2010 Mauro Carvalho Chehab
6 * Copyright (C) 2009-2010 Douglas Landgraf <dougsland@redhat.com> 6 * Copyright (C) 2009-2010 Douglas Landgraf <dougsland@redhat.com>
7 * 7 *
8 * Developed for Leadership SBTVD 1seg device sold in Brazil 8 * Developed for Leadership SBTVD 1seg device sold in Brazil
@@ -539,6 +539,6 @@ static struct dvb_frontend_ops s921_ops = {
539}; 539};
540 540
541MODULE_DESCRIPTION("DVB Frontend module for Sharp S921 hardware"); 541MODULE_DESCRIPTION("DVB Frontend module for Sharp S921 hardware");
542MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 542MODULE_AUTHOR("Mauro Carvalho Chehab");
543MODULE_AUTHOR("Douglas Landgraf <dougsland@redhat.com>"); 543MODULE_AUTHOR("Douglas Landgraf <dougsland@redhat.com>");
544MODULE_LICENSE("GPL"); 544MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/s921.h b/drivers/media/dvb-frontends/s921.h
index 8d5e2a6e187c..9b20c9e0eb88 100644
--- a/drivers/media/dvb-frontends/s921.h
+++ b/drivers/media/dvb-frontends/s921.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Sharp s921 driver 2 * Sharp s921 driver
3 * 3 *
4 * Copyright (C) 2009 Mauro Carvalho Chehab <mchehab@redhat.com> 4 * Copyright (C) 2009 Mauro Carvalho Chehab
5 * Copyright (C) 2009 Douglas Landgraf <dougsland@redhat.com> 5 * Copyright (C) 2009 Douglas Landgraf <dougsland@redhat.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
diff --git a/drivers/media/dvb-frontends/stb6100.c b/drivers/media/dvb-frontends/stb6100.c
index cea175d19890..4ef8a5c7003e 100644
--- a/drivers/media/dvb-frontends/stb6100.c
+++ b/drivers/media/dvb-frontends/stb6100.c
@@ -193,7 +193,7 @@ static int stb6100_write_reg_range(struct stb6100_state *state, u8 buf[], int st
193 .len = len + 1 193 .len = len + 1
194 }; 194 };
195 195
196 if (1 + len > sizeof(buf)) { 196 if (1 + len > sizeof(cmdbuf)) {
197 printk(KERN_WARNING 197 printk(KERN_WARNING
198 "%s: i2c wr: len=%d is too big!\n", 198 "%s: i2c wr: len=%d is too big!\n",
199 KBUILD_MODNAME, len); 199 KBUILD_MODNAME, len);
diff --git a/drivers/media/dvb-frontends/stv0900_sw.c b/drivers/media/dvb-frontends/stv0900_sw.c
index 0a40edfad739..4ce1d260b3eb 100644
--- a/drivers/media/dvb-frontends/stv0900_sw.c
+++ b/drivers/media/dvb-frontends/stv0900_sw.c
@@ -1081,7 +1081,7 @@ static int stv0900_wait_for_lock(struct stv0900_internal *intp,
1081 lock = stv0900_get_demod_lock(intp, demod, dmd_timeout); 1081 lock = stv0900_get_demod_lock(intp, demod, dmd_timeout);
1082 1082
1083 if (lock) 1083 if (lock)
1084 lock = lock && stv0900_get_fec_lock(intp, demod, fec_timeout); 1084 lock = stv0900_get_fec_lock(intp, demod, fec_timeout);
1085 1085
1086 if (lock) { 1086 if (lock) {
1087 lock = 0; 1087 lock = 0;
diff --git a/drivers/media/dvb-frontends/tda10071.c b/drivers/media/dvb-frontends/tda10071.c
index 8ad3a57cf640..522fe00f5eee 100644
--- a/drivers/media/dvb-frontends/tda10071.c
+++ b/drivers/media/dvb-frontends/tda10071.c
@@ -42,8 +42,8 @@ static int tda10071_wr_regs(struct tda10071_priv *priv, u8 reg, u8 *val,
42 42
43 if (1 + len > sizeof(buf)) { 43 if (1 + len > sizeof(buf)) {
44 dev_warn(&priv->i2c->dev, 44 dev_warn(&priv->i2c->dev,
45 "%s: i2c wr reg=%04x: len=%d is too big!\n", 45 "%s: i2c wr reg=%04x: len=%d is too big!\n",
46 KBUILD_MODNAME, reg, len); 46 KBUILD_MODNAME, reg, len);
47 return -EINVAL; 47 return -EINVAL;
48 } 48 }
49 49
@@ -54,8 +54,9 @@ static int tda10071_wr_regs(struct tda10071_priv *priv, u8 reg, u8 *val,
54 if (ret == 1) { 54 if (ret == 1) {
55 ret = 0; 55 ret = 0;
56 } else { 56 } else {
57 dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%02x " \ 57 dev_warn(&priv->i2c->dev,
58 "len=%d\n", KBUILD_MODNAME, ret, reg, len); 58 "%s: i2c wr failed=%d reg=%02x len=%d\n",
59 KBUILD_MODNAME, ret, reg, len);
59 ret = -EREMOTEIO; 60 ret = -EREMOTEIO;
60 } 61 }
61 return ret; 62 return ret;
@@ -83,8 +84,8 @@ static int tda10071_rd_regs(struct tda10071_priv *priv, u8 reg, u8 *val,
83 84
84 if (len > sizeof(buf)) { 85 if (len > sizeof(buf)) {
85 dev_warn(&priv->i2c->dev, 86 dev_warn(&priv->i2c->dev,
86 "%s: i2c wr reg=%04x: len=%d is too big!\n", 87 "%s: i2c wr reg=%04x: len=%d is too big!\n",
87 KBUILD_MODNAME, reg, len); 88 KBUILD_MODNAME, reg, len);
88 return -EINVAL; 89 return -EINVAL;
89 } 90 }
90 91
@@ -93,8 +94,9 @@ static int tda10071_rd_regs(struct tda10071_priv *priv, u8 reg, u8 *val,
93 memcpy(val, buf, len); 94 memcpy(val, buf, len);
94 ret = 0; 95 ret = 0;
95 } else { 96 } else {
96 dev_warn(&priv->i2c->dev, "%s: i2c rd failed=%d reg=%02x " \ 97 dev_warn(&priv->i2c->dev,
97 "len=%d\n", KBUILD_MODNAME, ret, reg, len); 98 "%s: i2c rd failed=%d reg=%02x len=%d\n",
99 KBUILD_MODNAME, ret, reg, len);
98 ret = -EREMOTEIO; 100 ret = -EREMOTEIO;
99 } 101 }
100 return ret; 102 return ret;
@@ -491,10 +493,9 @@ static int tda10071_read_status(struct dvb_frontend *fe, fe_status_t *status)
491 if (ret) 493 if (ret)
492 goto error; 494 goto error;
493 495
494 if (tmp & 0x01) /* tuner PLL */ 496 /* 0x39[0] tuner PLL */
495 *status |= FE_HAS_SIGNAL;
496 if (tmp & 0x02) /* demod PLL */ 497 if (tmp & 0x02) /* demod PLL */
497 *status |= FE_HAS_CARRIER; 498 *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER;
498 if (tmp & 0x04) /* viterbi or LDPC*/ 499 if (tmp & 0x04) /* viterbi or LDPC*/
499 *status |= FE_HAS_VITERBI; 500 *status |= FE_HAS_VITERBI;
500 if (tmp & 0x08) /* RS or BCH */ 501 if (tmp & 0x08) /* RS or BCH */
@@ -668,11 +669,11 @@ static int tda10071_set_frontend(struct dvb_frontend *fe)
668 int ret, i; 669 int ret, i;
669 u8 mode, rolloff, pilot, inversion, div; 670 u8 mode, rolloff, pilot, inversion, div;
670 671
671 dev_dbg(&priv->i2c->dev, "%s: delivery_system=%d modulation=%d " \ 672 dev_dbg(&priv->i2c->dev,
672 "frequency=%d symbol_rate=%d inversion=%d pilot=%d " \ 673 "%s: delivery_system=%d modulation=%d frequency=%d symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n",
673 "rolloff=%d\n", __func__, c->delivery_system, c->modulation, 674 __func__, c->delivery_system, c->modulation,
674 c->frequency, c->symbol_rate, c->inversion, c->pilot, 675 c->frequency, c->symbol_rate, c->inversion, c->pilot,
675 c->rolloff); 676 c->rolloff);
676 677
677 priv->delivery_system = SYS_UNDEFINED; 678 priv->delivery_system = SYS_UNDEFINED;
678 679
@@ -952,10 +953,8 @@ static int tda10071_init(struct dvb_frontend *fe)
952 /* request the firmware, this will block and timeout */ 953 /* request the firmware, this will block and timeout */
953 ret = request_firmware(&fw, fw_file, priv->i2c->dev.parent); 954 ret = request_firmware(&fw, fw_file, priv->i2c->dev.parent);
954 if (ret) { 955 if (ret) {
955 dev_err(&priv->i2c->dev, "%s: did not find the " \ 956 dev_err(&priv->i2c->dev,
956 "firmware file. (%s) Please see " \ 957 "%s: did not find the firmware file. (%s) Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)\n",
957 "linux/Documentation/dvb/ for more " \
958 "details on firmware-problems. (%d)\n",
959 KBUILD_MODNAME, fw_file, ret); 958 KBUILD_MODNAME, fw_file, ret);
960 goto error; 959 goto error;
961 } 960 }
@@ -985,11 +984,12 @@ static int tda10071_init(struct dvb_frontend *fe)
985 if (ret) 984 if (ret)
986 goto error_release_firmware; 985 goto error_release_firmware;
987 986
988 dev_info(&priv->i2c->dev, "%s: found a '%s' in cold state, " \ 987 dev_info(&priv->i2c->dev,
989 "will try to load a firmware\n", KBUILD_MODNAME, 988 "%s: found a '%s' in cold state, will try to load a firmware\n",
990 tda10071_ops.info.name); 989 KBUILD_MODNAME, tda10071_ops.info.name);
991 dev_info(&priv->i2c->dev, "%s: downloading firmware from " \ 990 dev_info(&priv->i2c->dev,
992 "file '%s'\n", KBUILD_MODNAME, fw_file); 991 "%s: downloading firmware from file '%s'\n",
992 KBUILD_MODNAME, fw_file);
993 993
994 /* do not download last byte */ 994 /* do not download last byte */
995 fw_size = fw->size - 1; 995 fw_size = fw->size - 1;
@@ -1003,11 +1003,10 @@ static int tda10071_init(struct dvb_frontend *fe)
1003 ret = tda10071_wr_regs(priv, 0xfa, 1003 ret = tda10071_wr_regs(priv, 0xfa,
1004 (u8 *) &fw->data[fw_size - remaining], len); 1004 (u8 *) &fw->data[fw_size - remaining], len);
1005 if (ret) { 1005 if (ret) {
1006 dev_err(&priv->i2c->dev, "%s: firmware " \ 1006 dev_err(&priv->i2c->dev,
1007 "download failed=%d\n", 1007 "%s: firmware download failed=%d\n",
1008 KBUILD_MODNAME, ret); 1008 KBUILD_MODNAME, ret);
1009 if (ret) 1009 goto error_release_firmware;
1010 goto error_release_firmware;
1011 } 1010 }
1012 } 1011 }
1013 release_firmware(fw); 1012 release_firmware(fw);
@@ -1069,12 +1068,17 @@ static int tda10071_init(struct dvb_frontend *fe)
1069 if (ret) 1068 if (ret)
1070 goto error; 1069 goto error;
1071 1070
1071 if (priv->cfg.tuner_i2c_addr)
1072 tmp = priv->cfg.tuner_i2c_addr;
1073 else
1074 tmp = 0x14;
1075
1072 cmd.args[0] = CMD_TUNER_INIT; 1076 cmd.args[0] = CMD_TUNER_INIT;
1073 cmd.args[1] = 0x00; 1077 cmd.args[1] = 0x00;
1074 cmd.args[2] = 0x00; 1078 cmd.args[2] = 0x00;
1075 cmd.args[3] = 0x00; 1079 cmd.args[3] = 0x00;
1076 cmd.args[4] = 0x00; 1080 cmd.args[4] = 0x00;
1077 cmd.args[5] = (priv->cfg.tuner_i2c_addr) ? priv->cfg.tuner_i2c_addr : 0x14; 1081 cmd.args[5] = tmp;
1078 cmd.args[6] = 0x00; 1082 cmd.args[6] = 0x00;
1079 cmd.args[7] = 0x03; 1083 cmd.args[7] = 0x03;
1080 cmd.args[8] = 0x02; 1084 cmd.args[8] = 0x02;
@@ -1214,14 +1218,14 @@ struct dvb_frontend *tda10071_attach(const struct tda10071_config *config,
1214 1218
1215 /* make sure demod i2c address is specified */ 1219 /* make sure demod i2c address is specified */
1216 if (!config->demod_i2c_addr) { 1220 if (!config->demod_i2c_addr) {
1217 dev_dbg(&i2c->dev, "%s: invalid demod i2c address!\n", __func__); 1221 dev_dbg(&i2c->dev, "%s: invalid demod i2c address\n", __func__);
1218 ret = -EINVAL; 1222 ret = -EINVAL;
1219 goto error; 1223 goto error;
1220 } 1224 }
1221 1225
1222 /* make sure tuner i2c address is specified */ 1226 /* make sure tuner i2c address is specified */
1223 if (!config->tuner_i2c_addr) { 1227 if (!config->tuner_i2c_addr) {
1224 dev_dbg(&i2c->dev, "%s: invalid tuner i2c address!\n", __func__); 1228 dev_dbg(&i2c->dev, "%s: invalid tuner i2c address\n", __func__);
1225 ret = -EINVAL; 1229 ret = -EINVAL;
1226 goto error; 1230 goto error;
1227 } 1231 }
diff --git a/drivers/media/dvb-frontends/tda10071.h b/drivers/media/dvb-frontends/tda10071.h
index f9542f68fe78..331b5a819383 100644
--- a/drivers/media/dvb-frontends/tda10071.h
+++ b/drivers/media/dvb-frontends/tda10071.h
@@ -79,7 +79,7 @@ extern struct dvb_frontend *tda10071_attach(
79static inline struct dvb_frontend *tda10071_attach( 79static inline struct dvb_frontend *tda10071_attach(
80 const struct tda10071_config *config, struct i2c_adapter *i2c) 80 const struct tda10071_config *config, struct i2c_adapter *i2c)
81{ 81{
82 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 82 dev_warn(&i2c->dev, "%s: driver disabled by Kconfig\n", __func__);
83 return NULL; 83 return NULL;
84} 84}
85#endif 85#endif
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 4aa9c5311cc5..c930be30eb7e 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -196,7 +196,7 @@ config VIDEO_ADV7183
196 196
197config VIDEO_ADV7604 197config VIDEO_ADV7604
198 tristate "Analog Devices ADV7604 decoder" 198 tristate "Analog Devices ADV7604 decoder"
199 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API 199 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && MEDIA_CONTROLLER
200 ---help--- 200 ---help---
201 Support for the Analog Devices ADV7604 video decoder. 201 Support for the Analog Devices ADV7604 video decoder.
202 202
@@ -208,7 +208,7 @@ config VIDEO_ADV7604
208 208
209config VIDEO_ADV7842 209config VIDEO_ADV7842
210 tristate "Analog Devices ADV7842 decoder" 210 tristate "Analog Devices ADV7842 decoder"
211 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API 211 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && MEDIA_CONTROLLER
212 ---help--- 212 ---help---
213 Support for the Analog Devices ADV7842 video decoder. 213 Support for the Analog Devices ADV7842 video decoder.
214 214
@@ -431,7 +431,7 @@ config VIDEO_ADV7393
431 431
432config VIDEO_ADV7511 432config VIDEO_ADV7511
433 tristate "Analog Devices ADV7511 encoder" 433 tristate "Analog Devices ADV7511 encoder"
434 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API 434 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && MEDIA_CONTROLLER
435 ---help--- 435 ---help---
436 Support for the Analog Devices ADV7511 video encoder. 436 Support for the Analog Devices ADV7511 video encoder.
437 437
@@ -629,6 +629,15 @@ config VIDEO_LM3560
629 This is a driver for the lm3560 dual flash controllers. It controls 629 This is a driver for the lm3560 dual flash controllers. It controls
630 flash, torch LEDs. 630 flash, torch LEDs.
631 631
632config VIDEO_LM3646
633 tristate "LM3646 dual flash driver support"
634 depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER
635 depends on MEDIA_CAMERA_SUPPORT
636 select REGMAP_I2C
637 ---help---
638 This is a driver for the lm3646 dual flash controllers. It controls
639 flash, torch LEDs.
640
632comment "Video improvement chips" 641comment "Video improvement chips"
633 642
634config VIDEO_UPD64031A 643config VIDEO_UPD64031A
@@ -659,6 +668,7 @@ comment "Audio/Video compression chips"
659config VIDEO_SAA6752HS 668config VIDEO_SAA6752HS
660 tristate "Philips SAA6752HS MPEG-2 Audio/Video Encoder" 669 tristate "Philips SAA6752HS MPEG-2 Audio/Video Encoder"
661 depends on VIDEO_V4L2 && I2C 670 depends on VIDEO_V4L2 && I2C
671 select CRC32
662 ---help--- 672 ---help---
663 Support for the Philips SAA6752HS MPEG-2 video and MPEG-audio/AC-3 673 Support for the Philips SAA6752HS MPEG-2 video and MPEG-audio/AC-3
664 audio encoder with multiplexer. 674 audio encoder with multiplexer.
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 48888ae876fb..01b6bfc0db5b 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -72,6 +72,7 @@ obj-$(CONFIG_VIDEO_S5C73M3) += s5c73m3/
72obj-$(CONFIG_VIDEO_ADP1653) += adp1653.o 72obj-$(CONFIG_VIDEO_ADP1653) += adp1653.o
73obj-$(CONFIG_VIDEO_AS3645A) += as3645a.o 73obj-$(CONFIG_VIDEO_AS3645A) += as3645a.o
74obj-$(CONFIG_VIDEO_LM3560) += lm3560.o 74obj-$(CONFIG_VIDEO_LM3560) += lm3560.o
75obj-$(CONFIG_VIDEO_LM3646) += lm3646.o
75obj-$(CONFIG_VIDEO_SMIAPP_PLL) += smiapp-pll.o 76obj-$(CONFIG_VIDEO_SMIAPP_PLL) += smiapp-pll.o
76obj-$(CONFIG_VIDEO_AK881X) += ak881x.o 77obj-$(CONFIG_VIDEO_AK881X) += ak881x.o
77obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o 78obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o
diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index 83225d6a0dd9..1b7ecfd88673 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -573,7 +573,7 @@ static const struct v4l2_subdev_core_ops ad9389b_core_ops = {
573 573
574/* ------------------------------ PAD OPS ------------------------------ */ 574/* ------------------------------ PAD OPS ------------------------------ */
575 575
576static int ad9389b_get_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid) 576static int ad9389b_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
577{ 577{
578 struct ad9389b_state *state = get_ad9389b_state(sd); 578 struct ad9389b_state *state = get_ad9389b_state(sd);
579 579
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index d7d99f1c69e4..5e638b159452 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -123,11 +123,11 @@
123struct adv7180_state { 123struct adv7180_state {
124 struct v4l2_ctrl_handler ctrl_hdl; 124 struct v4l2_ctrl_handler ctrl_hdl;
125 struct v4l2_subdev sd; 125 struct v4l2_subdev sd;
126 struct work_struct work;
127 struct mutex mutex; /* mutual excl. when accessing chip */ 126 struct mutex mutex; /* mutual excl. when accessing chip */
128 int irq; 127 int irq;
129 v4l2_std_id curr_norm; 128 v4l2_std_id curr_norm;
130 bool autodetect; 129 bool autodetect;
130 bool powered;
131 u8 input; 131 u8 input;
132}; 132};
133#define to_adv7180_sd(_ctrl) (&container_of(_ctrl->handler, \ 133#define to_adv7180_sd(_ctrl) (&container_of(_ctrl->handler, \
@@ -312,6 +312,37 @@ out:
312 return ret; 312 return ret;
313} 313}
314 314
315static int adv7180_set_power(struct adv7180_state *state,
316 struct i2c_client *client, bool on)
317{
318 u8 val;
319
320 if (on)
321 val = ADV7180_PWR_MAN_ON;
322 else
323 val = ADV7180_PWR_MAN_OFF;
324
325 return i2c_smbus_write_byte_data(client, ADV7180_PWR_MAN_REG, val);
326}
327
328static int adv7180_s_power(struct v4l2_subdev *sd, int on)
329{
330 struct adv7180_state *state = to_state(sd);
331 struct i2c_client *client = v4l2_get_subdevdata(sd);
332 int ret;
333
334 ret = mutex_lock_interruptible(&state->mutex);
335 if (ret)
336 return ret;
337
338 ret = adv7180_set_power(state, client, on);
339 if (ret == 0)
340 state->powered = on;
341
342 mutex_unlock(&state->mutex);
343 return ret;
344}
345
315static int adv7180_s_ctrl(struct v4l2_ctrl *ctrl) 346static int adv7180_s_ctrl(struct v4l2_ctrl *ctrl)
316{ 347{
317 struct v4l2_subdev *sd = to_adv7180_sd(ctrl); 348 struct v4l2_subdev *sd = to_adv7180_sd(ctrl);
@@ -442,6 +473,7 @@ static const struct v4l2_subdev_video_ops adv7180_video_ops = {
442 473
443static const struct v4l2_subdev_core_ops adv7180_core_ops = { 474static const struct v4l2_subdev_core_ops adv7180_core_ops = {
444 .s_std = adv7180_s_std, 475 .s_std = adv7180_s_std,
476 .s_power = adv7180_s_power,
445}; 477};
446 478
447static const struct v4l2_subdev_ops adv7180_ops = { 479static const struct v4l2_subdev_ops adv7180_ops = {
@@ -449,10 +481,9 @@ static const struct v4l2_subdev_ops adv7180_ops = {
449 .video = &adv7180_video_ops, 481 .video = &adv7180_video_ops,
450}; 482};
451 483
452static void adv7180_work(struct work_struct *work) 484static irqreturn_t adv7180_irq(int irq, void *devid)
453{ 485{
454 struct adv7180_state *state = container_of(work, struct adv7180_state, 486 struct adv7180_state *state = devid;
455 work);
456 struct i2c_client *client = v4l2_get_subdevdata(&state->sd); 487 struct i2c_client *client = v4l2_get_subdevdata(&state->sd);
457 u8 isr3; 488 u8 isr3;
458 489
@@ -468,17 +499,6 @@ static void adv7180_work(struct work_struct *work)
468 __adv7180_status(client, NULL, &state->curr_norm); 499 __adv7180_status(client, NULL, &state->curr_norm);
469 mutex_unlock(&state->mutex); 500 mutex_unlock(&state->mutex);
470 501
471 enable_irq(state->irq);
472}
473
474static irqreturn_t adv7180_irq(int irq, void *devid)
475{
476 struct adv7180_state *state = devid;
477
478 schedule_work(&state->work);
479
480 disable_irq_nosync(state->irq);
481
482 return IRQ_HANDLED; 502 return IRQ_HANDLED;
483} 503}
484 504
@@ -533,48 +553,52 @@ static int init_device(struct i2c_client *client, struct adv7180_state *state)
533 553
534 /* register for interrupts */ 554 /* register for interrupts */
535 if (state->irq > 0) { 555 if (state->irq > 0) {
536 ret = request_irq(state->irq, adv7180_irq, 0, KBUILD_MODNAME, 556 ret = request_threaded_irq(state->irq, NULL, adv7180_irq,
537 state); 557 IRQF_ONESHOT, KBUILD_MODNAME, state);
538 if (ret) 558 if (ret)
539 return ret; 559 return ret;
540 560
541 ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG, 561 ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG,
542 ADV7180_ADI_CTRL_IRQ_SPACE); 562 ADV7180_ADI_CTRL_IRQ_SPACE);
543 if (ret < 0) 563 if (ret < 0)
544 return ret; 564 goto err;
545 565
546 /* config the Interrupt pin to be active low */ 566 /* config the Interrupt pin to be active low */
547 ret = i2c_smbus_write_byte_data(client, ADV7180_ICONF1_ADI, 567 ret = i2c_smbus_write_byte_data(client, ADV7180_ICONF1_ADI,
548 ADV7180_ICONF1_ACTIVE_LOW | 568 ADV7180_ICONF1_ACTIVE_LOW |
549 ADV7180_ICONF1_PSYNC_ONLY); 569 ADV7180_ICONF1_PSYNC_ONLY);
550 if (ret < 0) 570 if (ret < 0)
551 return ret; 571 goto err;
552 572
553 ret = i2c_smbus_write_byte_data(client, ADV7180_IMR1_ADI, 0); 573 ret = i2c_smbus_write_byte_data(client, ADV7180_IMR1_ADI, 0);
554 if (ret < 0) 574 if (ret < 0)
555 return ret; 575 goto err;
556 576
557 ret = i2c_smbus_write_byte_data(client, ADV7180_IMR2_ADI, 0); 577 ret = i2c_smbus_write_byte_data(client, ADV7180_IMR2_ADI, 0);
558 if (ret < 0) 578 if (ret < 0)
559 return ret; 579 goto err;
560 580
561 /* enable AD change interrupts interrupts */ 581 /* enable AD change interrupts interrupts */
562 ret = i2c_smbus_write_byte_data(client, ADV7180_IMR3_ADI, 582 ret = i2c_smbus_write_byte_data(client, ADV7180_IMR3_ADI,
563 ADV7180_IRQ3_AD_CHANGE); 583 ADV7180_IRQ3_AD_CHANGE);
564 if (ret < 0) 584 if (ret < 0)
565 return ret; 585 goto err;
566 586
567 ret = i2c_smbus_write_byte_data(client, ADV7180_IMR4_ADI, 0); 587 ret = i2c_smbus_write_byte_data(client, ADV7180_IMR4_ADI, 0);
568 if (ret < 0) 588 if (ret < 0)
569 return ret; 589 goto err;
570 590
571 ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG, 591 ret = i2c_smbus_write_byte_data(client, ADV7180_ADI_CTRL_REG,
572 0); 592 0);
573 if (ret < 0) 593 if (ret < 0)
574 return ret; 594 goto err;
575 } 595 }
576 596
577 return 0; 597 return 0;
598
599err:
600 free_irq(state->irq, state);
601 return ret;
578} 602}
579 603
580static int adv7180_probe(struct i2c_client *client, 604static int adv7180_probe(struct i2c_client *client,
@@ -598,9 +622,9 @@ static int adv7180_probe(struct i2c_client *client,
598 } 622 }
599 623
600 state->irq = client->irq; 624 state->irq = client->irq;
601 INIT_WORK(&state->work, adv7180_work);
602 mutex_init(&state->mutex); 625 mutex_init(&state->mutex);
603 state->autodetect = true; 626 state->autodetect = true;
627 state->powered = true;
604 state->input = 0; 628 state->input = 0;
605 sd = &state->sd; 629 sd = &state->sd;
606 v4l2_i2c_subdev_init(sd, client, &adv7180_ops); 630 v4l2_i2c_subdev_init(sd, client, &adv7180_ops);
@@ -611,15 +635,21 @@ static int adv7180_probe(struct i2c_client *client,
611 ret = init_device(client, state); 635 ret = init_device(client, state);
612 if (ret) 636 if (ret)
613 goto err_free_ctrl; 637 goto err_free_ctrl;
638
639 ret = v4l2_async_register_subdev(sd);
640 if (ret)
641 goto err_free_irq;
642
614 return 0; 643 return 0;
615 644
645err_free_irq:
646 if (state->irq > 0)
647 free_irq(client->irq, state);
616err_free_ctrl: 648err_free_ctrl:
617 adv7180_exit_controls(state); 649 adv7180_exit_controls(state);
618err_unreg_subdev: 650err_unreg_subdev:
619 mutex_destroy(&state->mutex); 651 mutex_destroy(&state->mutex);
620 v4l2_device_unregister_subdev(sd);
621err: 652err:
622 printk(KERN_ERR KBUILD_MODNAME ": Failed to probe: %d\n", ret);
623 return ret; 653 return ret;
624} 654}
625 655
@@ -628,20 +658,14 @@ static int adv7180_remove(struct i2c_client *client)
628 struct v4l2_subdev *sd = i2c_get_clientdata(client); 658 struct v4l2_subdev *sd = i2c_get_clientdata(client);
629 struct adv7180_state *state = to_state(sd); 659 struct adv7180_state *state = to_state(sd);
630 660
631 if (state->irq > 0) { 661 v4l2_async_unregister_subdev(sd);
662
663 if (state->irq > 0)
632 free_irq(client->irq, state); 664 free_irq(client->irq, state);
633 if (cancel_work_sync(&state->work)) {
634 /*
635 * Work was pending, therefore we need to enable
636 * IRQ here to balance the disable_irq() done in the
637 * interrupt handler.
638 */
639 enable_irq(state->irq);
640 }
641 }
642 665
643 mutex_destroy(&state->mutex);
644 v4l2_device_unregister_subdev(sd); 666 v4l2_device_unregister_subdev(sd);
667 adv7180_exit_controls(state);
668 mutex_destroy(&state->mutex);
645 return 0; 669 return 0;
646} 670}
647 671
@@ -654,13 +678,10 @@ static const struct i2c_device_id adv7180_id[] = {
654static int adv7180_suspend(struct device *dev) 678static int adv7180_suspend(struct device *dev)
655{ 679{
656 struct i2c_client *client = to_i2c_client(dev); 680 struct i2c_client *client = to_i2c_client(dev);
657 int ret; 681 struct v4l2_subdev *sd = i2c_get_clientdata(client);
682 struct adv7180_state *state = to_state(sd);
658 683
659 ret = i2c_smbus_write_byte_data(client, ADV7180_PWR_MAN_REG, 684 return adv7180_set_power(state, client, false);
660 ADV7180_PWR_MAN_OFF);
661 if (ret < 0)
662 return ret;
663 return 0;
664} 685}
665 686
666static int adv7180_resume(struct device *dev) 687static int adv7180_resume(struct device *dev)
@@ -670,10 +691,11 @@ static int adv7180_resume(struct device *dev)
670 struct adv7180_state *state = to_state(sd); 691 struct adv7180_state *state = to_state(sd);
671 int ret; 692 int ret;
672 693
673 ret = i2c_smbus_write_byte_data(client, ADV7180_PWR_MAN_REG, 694 if (state->powered) {
674 ADV7180_PWR_MAN_ON); 695 ret = adv7180_set_power(state, client, true);
675 if (ret < 0) 696 if (ret)
676 return ret; 697 return ret;
698 }
677 ret = init_device(client, state); 699 ret = init_device(client, state);
678 if (ret < 0) 700 if (ret < 0)
679 return ret; 701 return ret;
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index ee618942cb8e..942ca4b99297 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -597,7 +597,7 @@ static int adv7511_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
597 return 0; 597 return 0;
598} 598}
599 599
600static int adv7511_get_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid) 600static int adv7511_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
601{ 601{
602 struct adv7511_state *state = get_adv7511_state(sd); 602 struct adv7511_state *state = get_adv7511_state(sd);
603 603
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 71c8570bd9ea..98cc5407f1b1 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1658,7 +1658,7 @@ static int adv7604_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
1658 return 0; 1658 return 0;
1659} 1659}
1660 1660
1661static int adv7604_get_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid) 1661static int adv7604_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
1662{ 1662{
1663 struct adv7604_state *state = to_state(sd); 1663 struct adv7604_state *state = to_state(sd);
1664 u8 *data = NULL; 1664 u8 *data = NULL;
@@ -1728,7 +1728,7 @@ static int get_edid_spa_location(const u8 *edid)
1728 return -1; 1728 return -1;
1729} 1729}
1730 1730
1731static int adv7604_set_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid) 1731static int adv7604_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
1732{ 1732{
1733 struct adv7604_state *state = to_state(sd); 1733 struct adv7604_state *state = to_state(sd);
1734 int spa_loc; 1734 int spa_loc;
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 9bbd6656fb8f..636ac08925f6 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -546,6 +546,14 @@ static void main_reset(struct v4l2_subdev *sd)
546 546
547/* ----------------------------------------------------------------------- */ 547/* ----------------------------------------------------------------------- */
548 548
549static inline bool is_analog_input(struct v4l2_subdev *sd)
550{
551 struct adv7842_state *state = to_state(sd);
552
553 return ((state->mode == ADV7842_MODE_RGB) ||
554 (state->mode == ADV7842_MODE_COMP));
555}
556
549static inline bool is_digital_input(struct v4l2_subdev *sd) 557static inline bool is_digital_input(struct v4l2_subdev *sd)
550{ 558{
551 struct adv7842_state *state = to_state(sd); 559 struct adv7842_state *state = to_state(sd);
@@ -1027,12 +1035,72 @@ static void configure_custom_video_timings(struct v4l2_subdev *sd,
1027 cp_write(sd, 0xac, (height & 0x0f) << 4); 1035 cp_write(sd, 0xac, (height & 0x0f) << 4);
1028} 1036}
1029 1037
1038static void adv7842_set_offset(struct v4l2_subdev *sd, bool auto_offset, u16 offset_a, u16 offset_b, u16 offset_c)
1039{
1040 struct adv7842_state *state = to_state(sd);
1041 u8 offset_buf[4];
1042
1043 if (auto_offset) {
1044 offset_a = 0x3ff;
1045 offset_b = 0x3ff;
1046 offset_c = 0x3ff;
1047 }
1048
1049 v4l2_dbg(2, debug, sd, "%s: %s offset: a = 0x%x, b = 0x%x, c = 0x%x\n",
1050 __func__, auto_offset ? "Auto" : "Manual",
1051 offset_a, offset_b, offset_c);
1052
1053 offset_buf[0]= (cp_read(sd, 0x77) & 0xc0) | ((offset_a & 0x3f0) >> 4);
1054 offset_buf[1] = ((offset_a & 0x00f) << 4) | ((offset_b & 0x3c0) >> 6);
1055 offset_buf[2] = ((offset_b & 0x03f) << 2) | ((offset_c & 0x300) >> 8);
1056 offset_buf[3] = offset_c & 0x0ff;
1057
1058 /* Registers must be written in this order with no i2c access in between */
1059 if (adv_smbus_write_i2c_block_data(state->i2c_cp, 0x77, 4, offset_buf))
1060 v4l2_err(sd, "%s: i2c error writing to CP reg 0x77, 0x78, 0x79, 0x7a\n", __func__);
1061}
1062
1063static void adv7842_set_gain(struct v4l2_subdev *sd, bool auto_gain, u16 gain_a, u16 gain_b, u16 gain_c)
1064{
1065 struct adv7842_state *state = to_state(sd);
1066 u8 gain_buf[4];
1067 u8 gain_man = 1;
1068 u8 agc_mode_man = 1;
1069
1070 if (auto_gain) {
1071 gain_man = 0;
1072 agc_mode_man = 0;
1073 gain_a = 0x100;
1074 gain_b = 0x100;
1075 gain_c = 0x100;
1076 }
1077
1078 v4l2_dbg(2, debug, sd, "%s: %s gain: a = 0x%x, b = 0x%x, c = 0x%x\n",
1079 __func__, auto_gain ? "Auto" : "Manual",
1080 gain_a, gain_b, gain_c);
1081
1082 gain_buf[0] = ((gain_man << 7) | (agc_mode_man << 6) | ((gain_a & 0x3f0) >> 4));
1083 gain_buf[1] = (((gain_a & 0x00f) << 4) | ((gain_b & 0x3c0) >> 6));
1084 gain_buf[2] = (((gain_b & 0x03f) << 2) | ((gain_c & 0x300) >> 8));
1085 gain_buf[3] = ((gain_c & 0x0ff));
1086
1087 /* Registers must be written in this order with no i2c access in between */
1088 if (adv_smbus_write_i2c_block_data(state->i2c_cp, 0x73, 4, gain_buf))
1089 v4l2_err(sd, "%s: i2c error writing to CP reg 0x73, 0x74, 0x75, 0x76\n", __func__);
1090}
1091
1030static void set_rgb_quantization_range(struct v4l2_subdev *sd) 1092static void set_rgb_quantization_range(struct v4l2_subdev *sd)
1031{ 1093{
1032 struct adv7842_state *state = to_state(sd); 1094 struct adv7842_state *state = to_state(sd);
1095 bool rgb_output = io_read(sd, 0x02) & 0x02;
1096 bool hdmi_signal = hdmi_read(sd, 0x05) & 0x80;
1097
1098 v4l2_dbg(2, debug, sd, "%s: RGB quantization range: %d, RGB out: %d, HDMI: %d\n",
1099 __func__, state->rgb_quantization_range,
1100 rgb_output, hdmi_signal);
1033 1101
1034 v4l2_dbg(2, debug, sd, "%s: rgb_quantization_range = %d\n", 1102 adv7842_set_gain(sd, true, 0x0, 0x0, 0x0);
1035 __func__, state->rgb_quantization_range); 1103 adv7842_set_offset(sd, true, 0x0, 0x0, 0x0);
1036 1104
1037 switch (state->rgb_quantization_range) { 1105 switch (state->rgb_quantization_range) {
1038 case V4L2_DV_RGB_RANGE_AUTO: 1106 case V4L2_DV_RGB_RANGE_AUTO:
@@ -1050,7 +1118,7 @@ static void set_rgb_quantization_range(struct v4l2_subdev *sd)
1050 break; 1118 break;
1051 } 1119 }
1052 1120
1053 if (hdmi_read(sd, 0x05) & 0x80) { 1121 if (hdmi_signal) {
1054 /* Receiving HDMI signal 1122 /* Receiving HDMI signal
1055 * Set automode */ 1123 * Set automode */
1056 io_write_and_or(sd, 0x02, 0x0f, 0xf0); 1124 io_write_and_or(sd, 0x02, 0x0f, 0xf0);
@@ -1066,24 +1134,45 @@ static void set_rgb_quantization_range(struct v4l2_subdev *sd)
1066 } else { 1134 } else {
1067 /* RGB full range (0-255) */ 1135 /* RGB full range (0-255) */
1068 io_write_and_or(sd, 0x02, 0x0f, 0x10); 1136 io_write_and_or(sd, 0x02, 0x0f, 0x10);
1137
1138 if (is_digital_input(sd) && rgb_output) {
1139 adv7842_set_offset(sd, false, 0x40, 0x40, 0x40);
1140 } else {
1141 adv7842_set_gain(sd, false, 0xe0, 0xe0, 0xe0);
1142 adv7842_set_offset(sd, false, 0x70, 0x70, 0x70);
1143 }
1069 } 1144 }
1070 break; 1145 break;
1071 case V4L2_DV_RGB_RANGE_LIMITED: 1146 case V4L2_DV_RGB_RANGE_LIMITED:
1072 if (state->mode == ADV7842_MODE_COMP) { 1147 if (state->mode == ADV7842_MODE_COMP) {
1073 /* YCrCb limited range (16-235) */ 1148 /* YCrCb limited range (16-235) */
1074 io_write_and_or(sd, 0x02, 0x0f, 0x20); 1149 io_write_and_or(sd, 0x02, 0x0f, 0x20);
1075 } else { 1150 break;
1076 /* RGB limited range (16-235) */
1077 io_write_and_or(sd, 0x02, 0x0f, 0x00);
1078 } 1151 }
1152
1153 /* RGB limited range (16-235) */
1154 io_write_and_or(sd, 0x02, 0x0f, 0x00);
1155
1079 break; 1156 break;
1080 case V4L2_DV_RGB_RANGE_FULL: 1157 case V4L2_DV_RGB_RANGE_FULL:
1081 if (state->mode == ADV7842_MODE_COMP) { 1158 if (state->mode == ADV7842_MODE_COMP) {
1082 /* YCrCb full range (0-255) */ 1159 /* YCrCb full range (0-255) */
1083 io_write_and_or(sd, 0x02, 0x0f, 0x60); 1160 io_write_and_or(sd, 0x02, 0x0f, 0x60);
1161 break;
1162 }
1163
1164 /* RGB full range (0-255) */
1165 io_write_and_or(sd, 0x02, 0x0f, 0x10);
1166
1167 if (is_analog_input(sd) || hdmi_signal)
1168 break;
1169
1170 /* Adjust gain/offset for DVI-D signals only */
1171 if (rgb_output) {
1172 adv7842_set_offset(sd, false, 0x40, 0x40, 0x40);
1084 } else { 1173 } else {
1085 /* RGB full range (0-255) */ 1174 adv7842_set_gain(sd, false, 0xe0, 0xe0, 0xe0);
1086 io_write_and_or(sd, 0x02, 0x0f, 0x10); 1175 adv7842_set_offset(sd, false, 0x70, 0x70, 0x70);
1087 } 1176 }
1088 break; 1177 break;
1089 } 1178 }
@@ -1360,12 +1449,11 @@ static int adv7842_query_dv_timings(struct v4l2_subdev *sd,
1360 1449
1361 bt->width = (hdmi_read(sd, 0x07) & 0x0f) * 256 + hdmi_read(sd, 0x08); 1450 bt->width = (hdmi_read(sd, 0x07) & 0x0f) * 256 + hdmi_read(sd, 0x08);
1362 bt->height = (hdmi_read(sd, 0x09) & 0x0f) * 256 + hdmi_read(sd, 0x0a); 1451 bt->height = (hdmi_read(sd, 0x09) & 0x0f) * 256 + hdmi_read(sd, 0x0a);
1363 freq = (hdmi_read(sd, 0x06) * 1000000) + 1452 freq = ((hdmi_read(sd, 0x51) << 1) + (hdmi_read(sd, 0x52) >> 7)) * 1000000;
1364 ((hdmi_read(sd, 0x3b) & 0x30) >> 4) * 250000; 1453 freq += ((hdmi_read(sd, 0x52) & 0x7f) * 7813);
1365
1366 if (is_hdmi(sd)) { 1454 if (is_hdmi(sd)) {
1367 /* adjust for deep color mode */ 1455 /* adjust for deep color mode */
1368 freq = freq * 8 / (((hdmi_read(sd, 0x0b) & 0xc0) >> 5) + 8); 1456 freq = freq * 8 / (((hdmi_read(sd, 0x0b) & 0xc0) >> 6) * 2 + 8);
1369 } 1457 }
1370 bt->pixelclock = freq; 1458 bt->pixelclock = freq;
1371 bt->hfrontporch = (hdmi_read(sd, 0x20) & 0x03) * 256 + 1459 bt->hfrontporch = (hdmi_read(sd, 0x20) & 0x03) * 256 +
@@ -1717,8 +1805,8 @@ static void select_input(struct v4l2_subdev *sd,
1717 * (rev. 2.5, June 2010)" p. 17. */ 1805 * (rev. 2.5, June 2010)" p. 17. */
1718 afe_write(sd, 0x12, 0xfb); /* ADC noise shaping filter controls */ 1806 afe_write(sd, 0x12, 0xfb); /* ADC noise shaping filter controls */
1719 afe_write(sd, 0x0c, 0x0d); /* CP core gain controls */ 1807 afe_write(sd, 0x0c, 0x0d); /* CP core gain controls */
1720 cp_write(sd, 0x3e, 0x80); /* CP core pre-gain control, 1808 cp_write(sd, 0x3e, 0x00); /* CP core pre-gain control */
1721 enable color control */ 1809
1722 /* CP coast control */ 1810 /* CP coast control */
1723 cp_write(sd, 0xc3, 0x33); /* Component mode */ 1811 cp_write(sd, 0xc3, 0x33); /* Component mode */
1724 1812
@@ -1926,7 +2014,7 @@ static int adv7842_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
1926 return 0; 2014 return 0;
1927} 2015}
1928 2016
1929static int adv7842_get_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid) 2017static int adv7842_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
1930{ 2018{
1931 struct adv7842_state *state = to_state(sd); 2019 struct adv7842_state *state = to_state(sd);
1932 u8 *data = NULL; 2020 u8 *data = NULL;
@@ -1966,7 +2054,7 @@ static int adv7842_get_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edi
1966 return 0; 2054 return 0;
1967} 2055}
1968 2056
1969static int adv7842_set_edid(struct v4l2_subdev *sd, struct v4l2_subdev_edid *e) 2057static int adv7842_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *e)
1970{ 2058{
1971 struct adv7842_state *state = to_state(sd); 2059 struct adv7842_state *state = to_state(sd);
1972 int err = 0; 2060 int err = 0;
@@ -2103,7 +2191,8 @@ static void print_avi_infoframe(struct v4l2_subdev *sd)
2103{ 2191{
2104 int i; 2192 int i;
2105 uint8_t buf[14]; 2193 uint8_t buf[14];
2106 uint8_t avi_inf_len; 2194 u8 avi_len;
2195 u8 avi_ver;
2107 struct avi_info_frame avi; 2196 struct avi_info_frame avi;
2108 2197
2109 if (!(hdmi_read(sd, 0x05) & 0x80)) { 2198 if (!(hdmi_read(sd, 0x05) & 0x80)) {
@@ -2116,18 +2205,20 @@ static void print_avi_infoframe(struct v4l2_subdev *sd)
2116 } 2205 }
2117 2206
2118 if (io_read(sd, 0x88) & 0x10) { 2207 if (io_read(sd, 0x88) & 0x10) {
2119 /* Note: the ADV7842 calculated incorrect checksums for InfoFrames 2208 v4l2_info(sd, "AVI infoframe checksum error has occurred earlier\n");
2120 with a length of 14 or 15. See the ADV7842 Register Settings 2209 io_write(sd, 0x8a, 0x10); /* clear AVI_INF_CKS_ERR_RAW */
2121 Recommendations document for more details. */ 2210 if (io_read(sd, 0x88) & 0x10) {
2122 v4l2_info(sd, "AVI infoframe checksum error\n"); 2211 v4l2_info(sd, "AVI infoframe checksum error still present\n");
2123 return; 2212 io_write(sd, 0x8a, 0x10); /* clear AVI_INF_CKS_ERR_RAW */
2213 }
2124 } 2214 }
2125 2215
2126 avi_inf_len = infoframe_read(sd, 0xe2); 2216 avi_len = infoframe_read(sd, 0xe2);
2217 avi_ver = infoframe_read(sd, 0xe1);
2127 v4l2_info(sd, "AVI infoframe version %d (%d byte)\n", 2218 v4l2_info(sd, "AVI infoframe version %d (%d byte)\n",
2128 infoframe_read(sd, 0xe1), avi_inf_len); 2219 avi_ver, avi_len);
2129 2220
2130 if (infoframe_read(sd, 0xe1) != 0x02) 2221 if (avi_ver != 0x02)
2131 return; 2222 return;
2132 2223
2133 for (i = 0; i < 14; i++) 2224 for (i = 0; i < 14; i++)
@@ -2602,9 +2693,15 @@ static int adv7842_core_init(struct v4l2_subdev *sd)
2602 /* disable I2C access to internal EDID ram from HDMI DDC ports */ 2693 /* disable I2C access to internal EDID ram from HDMI DDC ports */
2603 rep_write_and_or(sd, 0x77, 0xf3, 0x00); 2694 rep_write_and_or(sd, 0x77, 0xf3, 0x00);
2604 2695
2605 hdmi_write(sd, 0x69, 0xa3); /* HPA manual */ 2696 if (pdata->hpa_auto) {
2606 /* HPA disable on port A and B */ 2697 /* HPA auto, HPA 0.5s after Edid set and Cable detect */
2607 io_write_and_or(sd, 0x20, 0xcf, 0x00); 2698 hdmi_write(sd, 0x69, 0x5c);
2699 } else {
2700 /* HPA manual */
2701 hdmi_write(sd, 0x69, 0xa3);
2702 /* HPA disable on port A and B */
2703 io_write_and_or(sd, 0x20, 0xcf, 0x00);
2704 }
2608 2705
2609 /* LLC */ 2706 /* LLC */
2610 io_write(sd, 0x19, 0x80 | pdata->llc_dll_phase); 2707 io_write(sd, 0x19, 0x80 | pdata->llc_dll_phase);
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 99ee456700f4..c8fe1358ec9e 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -431,8 +431,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
431 * Initialize the other fields of rc_dev 431 * Initialize the other fields of rc_dev
432 */ 432 */
433 rc->map_name = ir->ir_codes; 433 rc->map_name = ir->ir_codes;
434 rc->allowed_protos = rc_type; 434 rc_set_allowed_protocols(rc, rc_type);
435 rc->enabled_protocols = rc_type; 435 rc_set_enabled_protocols(rc, rc_type);
436 if (!rc->driver_name) 436 if (!rc->driver_name)
437 rc->driver_name = MODULE_NAME; 437 rc->driver_name = MODULE_NAME;
438 438
diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index d98ca3aebe23..c23de593c17d 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -15,12 +15,6 @@
15 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. 17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA
23 *
24 */ 18 */
25 19
26#include <linux/delay.h> 20#include <linux/delay.h>
@@ -42,7 +36,7 @@
42#define REG_FLAG 0xd0 36#define REG_FLAG 0xd0
43#define REG_CONFIG1 0xe0 37#define REG_CONFIG1 0xe0
44 38
45/* Fault Mask */ 39/* fault mask */
46#define FAULT_TIMEOUT (1<<0) 40#define FAULT_TIMEOUT (1<<0)
47#define FAULT_OVERTEMP (1<<1) 41#define FAULT_OVERTEMP (1<<1)
48#define FAULT_SHORT_CIRCUIT (1<<2) 42#define FAULT_SHORT_CIRCUIT (1<<2)
@@ -53,7 +47,8 @@ enum led_enable {
53 MODE_FLASH = 0x3, 47 MODE_FLASH = 0x3,
54}; 48};
55 49
56/* struct lm3560_flash 50/**
51 * struct lm3560_flash
57 * 52 *
58 * @pdata: platform data 53 * @pdata: platform data
59 * @regmap: reg. map for i2c 54 * @regmap: reg. map for i2c
@@ -98,7 +93,7 @@ static int lm3560_mode_ctrl(struct lm3560_flash *flash)
98 return rval; 93 return rval;
99} 94}
100 95
101/* led1/2 enable/disable */ 96/* led1/2 enable/disable */
102static int lm3560_enable_ctrl(struct lm3560_flash *flash, 97static int lm3560_enable_ctrl(struct lm3560_flash *flash,
103 enum lm3560_led_id led_no, bool on) 98 enum lm3560_led_id led_no, bool on)
104{ 99{
@@ -168,7 +163,7 @@ static int lm3560_flash_brt_ctrl(struct lm3560_flash *flash,
168 return rval; 163 return rval;
169} 164}
170 165
171/* V4L2 controls */ 166/* v4l2 controls */
172static int lm3560_get_ctrl(struct v4l2_ctrl *ctrl, enum lm3560_led_id led_no) 167static int lm3560_get_ctrl(struct v4l2_ctrl *ctrl, enum lm3560_led_id led_no)
173{ 168{
174 struct lm3560_flash *flash = to_lm3560_flash(ctrl, led_no); 169 struct lm3560_flash *flash = to_lm3560_flash(ctrl, led_no);
@@ -297,6 +292,7 @@ static int lm3560_init_controls(struct lm3560_flash *flash,
297 const struct v4l2_ctrl_ops *ops = &lm3560_led_ctrl_ops[led_no]; 292 const struct v4l2_ctrl_ops *ops = &lm3560_led_ctrl_ops[led_no];
298 293
299 v4l2_ctrl_handler_init(hdl, 8); 294 v4l2_ctrl_handler_init(hdl, 8);
295
300 /* flash mode */ 296 /* flash mode */
301 v4l2_ctrl_new_std_menu(hdl, ops, V4L2_CID_FLASH_LED_MODE, 297 v4l2_ctrl_new_std_menu(hdl, ops, V4L2_CID_FLASH_LED_MODE,
302 V4L2_FLASH_LED_MODE_TORCH, ~0x7, 298 V4L2_FLASH_LED_MODE_TORCH, ~0x7,
@@ -309,6 +305,7 @@ static int lm3560_init_controls(struct lm3560_flash *flash,
309 305
310 /* flash strobe */ 306 /* flash strobe */
311 v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FLASH_STROBE, 0, 0, 0, 0); 307 v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FLASH_STROBE, 0, 0, 0, 0);
308
312 /* flash strobe stop */ 309 /* flash strobe stop */
313 v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FLASH_STROBE_STOP, 0, 0, 0, 0); 310 v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FLASH_STROBE_STOP, 0, 0, 0, 0);
314 311
@@ -395,7 +392,7 @@ static int lm3560_init_device(struct lm3560_flash *flash)
395 rval = lm3560_mode_ctrl(flash); 392 rval = lm3560_mode_ctrl(flash);
396 if (rval < 0) 393 if (rval < 0)
397 return rval; 394 return rval;
398 /* Reset faults */ 395 /* reset faults */
399 rval = regmap_read(flash->regmap, REG_FLAG, &reg_val); 396 rval = regmap_read(flash->regmap, REG_FLAG, &reg_val);
400 return rval; 397 return rval;
401} 398}
@@ -419,8 +416,7 @@ static int lm3560_probe(struct i2c_client *client,
419 416
420 /* if there is no platform data, use chip default value */ 417 /* if there is no platform data, use chip default value */
421 if (pdata == NULL) { 418 if (pdata == NULL) {
422 pdata = 419 pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
423 kzalloc(sizeof(struct lm3560_platform_data), GFP_KERNEL);
424 if (pdata == NULL) 420 if (pdata == NULL)
425 return -ENODEV; 421 return -ENODEV;
426 pdata->peak = LM3560_PEAK_3600mA; 422 pdata->peak = LM3560_PEAK_3600mA;
diff --git a/drivers/media/i2c/lm3646.c b/drivers/media/i2c/lm3646.c
new file mode 100644
index 000000000000..626fb4679c02
--- /dev/null
+++ b/drivers/media/i2c/lm3646.c
@@ -0,0 +1,414 @@
1/*
2 * drivers/media/i2c/lm3646.c
3 * General device driver for TI lm3646, Dual FLASH LED Driver
4 *
5 * Copyright (C) 2014 Texas Instruments
6 *
7 * Contact: Daniel Jeong <gshark.jeong@gmail.com>
8 * Ldd-Mlp <ldd-mlp@list.ti.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * version 2 as published by the Free Software Foundation.
13 */
14
15#include <linux/delay.h>
16#include <linux/i2c.h>
17#include <linux/module.h>
18#include <linux/slab.h>
19#include <linux/regmap.h>
20#include <linux/videodev2.h>
21#include <media/lm3646.h>
22#include <media/v4l2-ctrls.h>
23#include <media/v4l2-device.h>
24
25/* registers definitions */
26#define REG_ENABLE 0x01
27#define REG_TORCH_BR 0x05
28#define REG_FLASH_BR 0x05
29#define REG_FLASH_TOUT 0x04
30#define REG_FLAG 0x08
31#define REG_STROBE_SRC 0x06
32#define REG_LED1_FLASH_BR 0x06
33#define REG_LED1_TORCH_BR 0x07
34
35#define MASK_ENABLE 0x03
36#define MASK_TORCH_BR 0x70
37#define MASK_FLASH_BR 0x0F
38#define MASK_FLASH_TOUT 0x07
39#define MASK_FLAG 0xFF
40#define MASK_STROBE_SRC 0x80
41
42/* Fault Mask */
43#define FAULT_TIMEOUT (1<<0)
44#define FAULT_SHORT_CIRCUIT (1<<1)
45#define FAULT_UVLO (1<<2)
46#define FAULT_IVFM (1<<3)
47#define FAULT_OCP (1<<4)
48#define FAULT_OVERTEMP (1<<5)
49#define FAULT_NTC_TRIP (1<<6)
50#define FAULT_OVP (1<<7)
51
52enum led_mode {
53 MODE_SHDN = 0x0,
54 MODE_TORCH = 0x2,
55 MODE_FLASH = 0x3,
56};
57
58/*
59 * struct lm3646_flash
60 *
61 * @pdata: platform data
62 * @regmap: reg. map for i2c
63 * @lock: muxtex for serial access.
64 * @led_mode: V4L2 LED mode
65 * @ctrls_led: V4L2 contols
66 * @subdev_led: V4L2 subdev
67 * @mode_reg : mode register value
68 */
69struct lm3646_flash {
70 struct device *dev;
71 struct lm3646_platform_data *pdata;
72 struct regmap *regmap;
73
74 struct v4l2_ctrl_handler ctrls_led;
75 struct v4l2_subdev subdev_led;
76
77 u8 mode_reg;
78};
79
80#define to_lm3646_flash(_ctrl) \
81 container_of(_ctrl->handler, struct lm3646_flash, ctrls_led)
82
83/* enable mode control */
84static int lm3646_mode_ctrl(struct lm3646_flash *flash,
85 enum v4l2_flash_led_mode led_mode)
86{
87 switch (led_mode) {
88 case V4L2_FLASH_LED_MODE_NONE:
89 return regmap_write(flash->regmap,
90 REG_ENABLE, flash->mode_reg | MODE_SHDN);
91 case V4L2_FLASH_LED_MODE_TORCH:
92 return regmap_write(flash->regmap,
93 REG_ENABLE, flash->mode_reg | MODE_TORCH);
94 case V4L2_FLASH_LED_MODE_FLASH:
95 return regmap_write(flash->regmap,
96 REG_ENABLE, flash->mode_reg | MODE_FLASH);
97 }
98 return -EINVAL;
99}
100
101/* V4L2 controls */
102static int lm3646_get_ctrl(struct v4l2_ctrl *ctrl)
103{
104 struct lm3646_flash *flash = to_lm3646_flash(ctrl);
105 unsigned int reg_val;
106 int rval;
107
108 if (ctrl->id != V4L2_CID_FLASH_FAULT)
109 return -EINVAL;
110
111 rval = regmap_read(flash->regmap, REG_FLAG, &reg_val);
112 if (rval < 0)
113 return rval;
114
115 ctrl->val = 0;
116 if (reg_val & FAULT_TIMEOUT)
117 ctrl->val |= V4L2_FLASH_FAULT_TIMEOUT;
118 if (reg_val & FAULT_SHORT_CIRCUIT)
119 ctrl->val |= V4L2_FLASH_FAULT_SHORT_CIRCUIT;
120 if (reg_val & FAULT_UVLO)
121 ctrl->val |= V4L2_FLASH_FAULT_UNDER_VOLTAGE;
122 if (reg_val & FAULT_IVFM)
123 ctrl->val |= V4L2_FLASH_FAULT_INPUT_VOLTAGE;
124 if (reg_val & FAULT_OCP)
125 ctrl->val |= V4L2_FLASH_FAULT_OVER_CURRENT;
126 if (reg_val & FAULT_OVERTEMP)
127 ctrl->val |= V4L2_FLASH_FAULT_OVER_TEMPERATURE;
128 if (reg_val & FAULT_NTC_TRIP)
129 ctrl->val |= V4L2_FLASH_FAULT_LED_OVER_TEMPERATURE;
130 if (reg_val & FAULT_OVP)
131 ctrl->val |= V4L2_FLASH_FAULT_OVER_VOLTAGE;
132
133 return 0;
134}
135
136static int lm3646_set_ctrl(struct v4l2_ctrl *ctrl)
137{
138 struct lm3646_flash *flash = to_lm3646_flash(ctrl);
139 unsigned int reg_val;
140 int rval = -EINVAL;
141
142 switch (ctrl->id) {
143 case V4L2_CID_FLASH_LED_MODE:
144
145 if (ctrl->val != V4L2_FLASH_LED_MODE_FLASH)
146 return lm3646_mode_ctrl(flash, ctrl->val);
147 /* switch to SHDN mode before flash strobe on */
148 return lm3646_mode_ctrl(flash, V4L2_FLASH_LED_MODE_NONE);
149
150 case V4L2_CID_FLASH_STROBE_SOURCE:
151 return regmap_update_bits(flash->regmap,
152 REG_STROBE_SRC, MASK_STROBE_SRC,
153 (ctrl->val) << 7);
154
155 case V4L2_CID_FLASH_STROBE:
156
157 /* read and check current mode of chip to start flash */
158 rval = regmap_read(flash->regmap, REG_ENABLE, &reg_val);
159 if (rval < 0 || ((reg_val & MASK_ENABLE) != MODE_SHDN))
160 return rval;
161 /* flash on */
162 return lm3646_mode_ctrl(flash, V4L2_FLASH_LED_MODE_FLASH);
163
164 case V4L2_CID_FLASH_STROBE_STOP:
165
166 /*
167 * flash mode will be turned automatically
168 * from FLASH mode to SHDN mode after flash duration timeout
169 * read and check current mode of chip to stop flash
170 */
171 rval = regmap_read(flash->regmap, REG_ENABLE, &reg_val);
172 if (rval < 0)
173 return rval;
174 if ((reg_val & MASK_ENABLE) == MODE_FLASH)
175 return lm3646_mode_ctrl(flash,
176 V4L2_FLASH_LED_MODE_NONE);
177 return rval;
178
179 case V4L2_CID_FLASH_TIMEOUT:
180 return regmap_update_bits(flash->regmap,
181 REG_FLASH_TOUT, MASK_FLASH_TOUT,
182 LM3646_FLASH_TOUT_ms_TO_REG
183 (ctrl->val));
184
185 case V4L2_CID_FLASH_INTENSITY:
186 return regmap_update_bits(flash->regmap,
187 REG_FLASH_BR, MASK_FLASH_BR,
188 LM3646_TOTAL_FLASH_BRT_uA_TO_REG
189 (ctrl->val));
190
191 case V4L2_CID_FLASH_TORCH_INTENSITY:
192 return regmap_update_bits(flash->regmap,
193 REG_TORCH_BR, MASK_TORCH_BR,
194 LM3646_TOTAL_TORCH_BRT_uA_TO_REG
195 (ctrl->val) << 4);
196 }
197
198 return -EINVAL;
199}
200
201static const struct v4l2_ctrl_ops lm3646_led_ctrl_ops = {
202 .g_volatile_ctrl = lm3646_get_ctrl,
203 .s_ctrl = lm3646_set_ctrl,
204};
205
206static int lm3646_init_controls(struct lm3646_flash *flash)
207{
208 struct v4l2_ctrl *fault;
209 struct v4l2_ctrl_handler *hdl = &flash->ctrls_led;
210 const struct v4l2_ctrl_ops *ops = &lm3646_led_ctrl_ops;
211
212 v4l2_ctrl_handler_init(hdl, 8);
213 /* flash mode */
214 v4l2_ctrl_new_std_menu(hdl, ops, V4L2_CID_FLASH_LED_MODE,
215 V4L2_FLASH_LED_MODE_TORCH, ~0x7,
216 V4L2_FLASH_LED_MODE_NONE);
217
218 /* flash source */
219 v4l2_ctrl_new_std_menu(hdl, ops, V4L2_CID_FLASH_STROBE_SOURCE,
220 0x1, ~0x3, V4L2_FLASH_STROBE_SOURCE_SOFTWARE);
221
222 /* flash strobe */
223 v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FLASH_STROBE, 0, 0, 0, 0);
224 /* flash strobe stop */
225 v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FLASH_STROBE_STOP, 0, 0, 0, 0);
226
227 /* flash strobe timeout */
228 v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FLASH_TIMEOUT,
229 LM3646_FLASH_TOUT_MIN,
230 LM3646_FLASH_TOUT_MAX,
231 LM3646_FLASH_TOUT_STEP, flash->pdata->flash_timeout);
232
233 /* max flash current */
234 v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FLASH_INTENSITY,
235 LM3646_TOTAL_FLASH_BRT_MIN,
236 LM3646_TOTAL_FLASH_BRT_MAX,
237 LM3646_TOTAL_FLASH_BRT_STEP,
238 LM3646_TOTAL_FLASH_BRT_MAX);
239
240 /* max torch current */
241 v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FLASH_TORCH_INTENSITY,
242 LM3646_TOTAL_TORCH_BRT_MIN,
243 LM3646_TOTAL_TORCH_BRT_MAX,
244 LM3646_TOTAL_TORCH_BRT_STEP,
245 LM3646_TOTAL_TORCH_BRT_MAX);
246
247 /* fault */
248 fault = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FLASH_FAULT, 0,
249 V4L2_FLASH_FAULT_OVER_VOLTAGE
250 | V4L2_FLASH_FAULT_OVER_TEMPERATURE
251 | V4L2_FLASH_FAULT_SHORT_CIRCUIT
252 | V4L2_FLASH_FAULT_TIMEOUT, 0, 0);
253 if (fault != NULL)
254 fault->flags |= V4L2_CTRL_FLAG_VOLATILE;
255
256 if (hdl->error)
257 return hdl->error;
258
259 flash->subdev_led.ctrl_handler = hdl;
260 return 0;
261}
262
263/* initialize device */
264static const struct v4l2_subdev_ops lm3646_ops = {
265 .core = NULL,
266};
267
268static const struct regmap_config lm3646_regmap = {
269 .reg_bits = 8,
270 .val_bits = 8,
271 .max_register = 0xFF,
272};
273
274static int lm3646_subdev_init(struct lm3646_flash *flash)
275{
276 struct i2c_client *client = to_i2c_client(flash->dev);
277 int rval;
278
279 v4l2_i2c_subdev_init(&flash->subdev_led, client, &lm3646_ops);
280 flash->subdev_led.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
281 strcpy(flash->subdev_led.name, LM3646_NAME);
282 rval = lm3646_init_controls(flash);
283 if (rval)
284 goto err_out;
285 rval = media_entity_init(&flash->subdev_led.entity, 0, NULL, 0);
286 if (rval < 0)
287 goto err_out;
288 flash->subdev_led.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH;
289 return rval;
290
291err_out:
292 v4l2_ctrl_handler_free(&flash->ctrls_led);
293 return rval;
294}
295
296static int lm3646_init_device(struct lm3646_flash *flash)
297{
298 unsigned int reg_val;
299 int rval;
300
301 /* read the value of mode register to reduce redundant i2c accesses */
302 rval = regmap_read(flash->regmap, REG_ENABLE, &reg_val);
303 if (rval < 0)
304 return rval;
305 flash->mode_reg = reg_val & 0xfc;
306
307 /* output disable */
308 rval = lm3646_mode_ctrl(flash, V4L2_FLASH_LED_MODE_NONE);
309 if (rval < 0)
310 return rval;
311
312 /*
313 * LED1 flash current setting
314 * LED2 flash current = Total(Max) flash current - LED1 flash current
315 */
316 rval = regmap_update_bits(flash->regmap,
317 REG_LED1_FLASH_BR, 0x7F,
318 LM3646_LED1_FLASH_BRT_uA_TO_REG
319 (flash->pdata->led1_flash_brt));
320
321 if (rval < 0)
322 return rval;
323
324 /*
325 * LED1 torch current setting
326 * LED2 torch current = Total(Max) torch current - LED1 torch current
327 */
328 rval = regmap_update_bits(flash->regmap,
329 REG_LED1_TORCH_BR, 0x7F,
330 LM3646_LED1_TORCH_BRT_uA_TO_REG
331 (flash->pdata->led1_torch_brt));
332 if (rval < 0)
333 return rval;
334
335 /* Reset flag register */
336 return regmap_read(flash->regmap, REG_FLAG, &reg_val);
337}
338
339static int lm3646_probe(struct i2c_client *client,
340 const struct i2c_device_id *devid)
341{
342 struct lm3646_flash *flash;
343 struct lm3646_platform_data *pdata = dev_get_platdata(&client->dev);
344 int rval;
345
346 flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL);
347 if (flash == NULL)
348 return -ENOMEM;
349
350 flash->regmap = devm_regmap_init_i2c(client, &lm3646_regmap);
351 if (IS_ERR(flash->regmap))
352 return PTR_ERR(flash->regmap);
353
354 /* check device tree if there is no platform data */
355 if (pdata == NULL) {
356 pdata = devm_kzalloc(&client->dev,
357 sizeof(struct lm3646_platform_data),
358 GFP_KERNEL);
359 if (pdata == NULL)
360 return -ENOMEM;
361 /* use default data in case of no platform data */
362 pdata->flash_timeout = LM3646_FLASH_TOUT_MAX;
363 pdata->led1_torch_brt = LM3646_LED1_TORCH_BRT_MAX;
364 pdata->led1_flash_brt = LM3646_LED1_FLASH_BRT_MAX;
365 }
366 flash->pdata = pdata;
367 flash->dev = &client->dev;
368
369 rval = lm3646_subdev_init(flash);
370 if (rval < 0)
371 return rval;
372
373 rval = lm3646_init_device(flash);
374 if (rval < 0)
375 return rval;
376
377 i2c_set_clientdata(client, flash);
378
379 return 0;
380}
381
382static int lm3646_remove(struct i2c_client *client)
383{
384 struct lm3646_flash *flash = i2c_get_clientdata(client);
385
386 v4l2_device_unregister_subdev(&flash->subdev_led);
387 v4l2_ctrl_handler_free(&flash->ctrls_led);
388 media_entity_cleanup(&flash->subdev_led.entity);
389
390 return 0;
391}
392
393static const struct i2c_device_id lm3646_id_table[] = {
394 {LM3646_NAME, 0},
395 {}
396};
397
398MODULE_DEVICE_TABLE(i2c, lm3646_id_table);
399
400static struct i2c_driver lm3646_i2c_driver = {
401 .driver = {
402 .name = LM3646_NAME,
403 },
404 .probe = lm3646_probe,
405 .remove = lm3646_remove,
406 .id_table = lm3646_id_table,
407};
408
409module_i2c_driver(lm3646_i2c_driver);
410
411MODULE_AUTHOR("Daniel Jeong <gshark.jeong@gmail.com>");
412MODULE_AUTHOR("Ldd Mlp <ldd-mlp@list.ti.com>");
413MODULE_DESCRIPTION("Texas Instruments LM3646 Dual Flash LED driver");
414MODULE_LICENSE("GPL");
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 192c4aad05d6..33daace81297 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -78,6 +78,9 @@
78#define MT9P031_PLL_CONFIG_1 0x11 78#define MT9P031_PLL_CONFIG_1 0x11
79#define MT9P031_PLL_CONFIG_2 0x12 79#define MT9P031_PLL_CONFIG_2 0x12
80#define MT9P031_PIXEL_CLOCK_CONTROL 0x0a 80#define MT9P031_PIXEL_CLOCK_CONTROL 0x0a
81#define MT9P031_PIXEL_CLOCK_INVERT (1 << 15)
82#define MT9P031_PIXEL_CLOCK_SHIFT(n) ((n) << 8)
83#define MT9P031_PIXEL_CLOCK_DIVIDE(n) ((n) << 0)
81#define MT9P031_FRAME_RESTART 0x0b 84#define MT9P031_FRAME_RESTART 0x0b
82#define MT9P031_SHUTTER_DELAY 0x0c 85#define MT9P031_SHUTTER_DELAY 0x0c
83#define MT9P031_RST 0x0d 86#define MT9P031_RST 0x0d
@@ -130,6 +133,8 @@ struct mt9p031 {
130 133
131 enum mt9p031_model model; 134 enum mt9p031_model model;
132 struct aptina_pll pll; 135 struct aptina_pll pll;
136 unsigned int clk_div;
137 bool use_pll;
133 int reset; 138 int reset;
134 139
135 struct v4l2_ctrl_handler ctrls; 140 struct v4l2_ctrl_handler ctrls;
@@ -198,6 +203,11 @@ static int mt9p031_reset(struct mt9p031 *mt9p031)
198 if (ret < 0) 203 if (ret < 0)
199 return ret; 204 return ret;
200 205
206 ret = mt9p031_write(client, MT9P031_PIXEL_CLOCK_CONTROL,
207 MT9P031_PIXEL_CLOCK_DIVIDE(mt9p031->clk_div));
208 if (ret < 0)
209 return ret;
210
201 return mt9p031_set_output_control(mt9p031, MT9P031_OUTPUT_CONTROL_CEN, 211 return mt9p031_set_output_control(mt9p031, MT9P031_OUTPUT_CONTROL_CEN,
202 0); 212 0);
203} 213}
@@ -222,15 +232,34 @@ static int mt9p031_clk_setup(struct mt9p031 *mt9p031)
222 232
223 struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev); 233 struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
224 struct mt9p031_platform_data *pdata = mt9p031->pdata; 234 struct mt9p031_platform_data *pdata = mt9p031->pdata;
235 int ret;
225 236
226 mt9p031->clk = devm_clk_get(&client->dev, NULL); 237 mt9p031->clk = devm_clk_get(&client->dev, NULL);
227 if (IS_ERR(mt9p031->clk)) 238 if (IS_ERR(mt9p031->clk))
228 return PTR_ERR(mt9p031->clk); 239 return PTR_ERR(mt9p031->clk);
229 240
230 clk_set_rate(mt9p031->clk, pdata->ext_freq); 241 ret = clk_set_rate(mt9p031->clk, pdata->ext_freq);
242 if (ret < 0)
243 return ret;
244
245 /* If the external clock frequency is out of bounds for the PLL use the
246 * pixel clock divider only and disable the PLL.
247 */
248 if (pdata->ext_freq > limits.ext_clock_max) {
249 unsigned int div;
250
251 div = DIV_ROUND_UP(pdata->ext_freq, pdata->target_freq);
252 div = roundup_pow_of_two(div) / 2;
253
254 mt9p031->clk_div = max_t(unsigned int, div, 64);
255 mt9p031->use_pll = false;
256
257 return 0;
258 }
231 259
232 mt9p031->pll.ext_clock = pdata->ext_freq; 260 mt9p031->pll.ext_clock = pdata->ext_freq;
233 mt9p031->pll.pix_clock = pdata->target_freq; 261 mt9p031->pll.pix_clock = pdata->target_freq;
262 mt9p031->use_pll = true;
234 263
235 return aptina_pll_calculate(&client->dev, &limits, &mt9p031->pll); 264 return aptina_pll_calculate(&client->dev, &limits, &mt9p031->pll);
236} 265}
@@ -240,6 +269,9 @@ static int mt9p031_pll_enable(struct mt9p031 *mt9p031)
240 struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev); 269 struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
241 int ret; 270 int ret;
242 271
272 if (!mt9p031->use_pll)
273 return 0;
274
243 ret = mt9p031_write(client, MT9P031_PLL_CONTROL, 275 ret = mt9p031_write(client, MT9P031_PLL_CONTROL,
244 MT9P031_PLL_CONTROL_PWRON); 276 MT9P031_PLL_CONTROL_PWRON);
245 if (ret < 0) 277 if (ret < 0)
@@ -265,6 +297,9 @@ static inline int mt9p031_pll_disable(struct mt9p031 *mt9p031)
265{ 297{
266 struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev); 298 struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
267 299
300 if (!mt9p031->use_pll)
301 return 0;
302
268 return mt9p031_write(client, MT9P031_PLL_CONTROL, 303 return mt9p031_write(client, MT9P031_PLL_CONTROL,
269 MT9P031_PLL_CONTROL_PWROFF); 304 MT9P031_PLL_CONTROL_PWROFF);
270} 305}
@@ -285,9 +320,15 @@ static int mt9p031_power_on(struct mt9p031 *mt9p031)
285 if (ret < 0) 320 if (ret < 0)
286 return ret; 321 return ret;
287 322
288 /* Emable clock */ 323 /* Enable clock */
289 if (mt9p031->clk) 324 if (mt9p031->clk) {
290 clk_prepare_enable(mt9p031->clk); 325 ret = clk_prepare_enable(mt9p031->clk);
326 if (ret) {
327 regulator_bulk_disable(ARRAY_SIZE(mt9p031->regulators),
328 mt9p031->regulators);
329 return ret;
330 }
331 }
291 332
292 /* Now RESET_BAR must be high */ 333 /* Now RESET_BAR must be high */
293 if (gpio_is_valid(mt9p031->reset)) { 334 if (gpio_is_valid(mt9p031->reset)) {
diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index d41c70eaf838..422e068f5f1b 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.c
@@ -12,9 +12,11 @@
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14 14
15#include <linux/clk.h>
15#include <linux/i2c.h> 16#include <linux/i2c.h>
16#include <linux/module.h>
17#include <linux/log2.h> 17#include <linux/log2.h>
18#include <linux/module.h>
19#include <linux/regulator/consumer.h>
18#include <linux/slab.h> 20#include <linux/slab.h>
19#include <linux/videodev2.h> 21#include <linux/videodev2.h>
20#include <linux/v4l2-mediabus.h> 22#include <linux/v4l2-mediabus.h>
@@ -55,6 +57,7 @@
55#define MT9T001_OUTPUT_CONTROL_SYNC (1 << 0) 57#define MT9T001_OUTPUT_CONTROL_SYNC (1 << 0)
56#define MT9T001_OUTPUT_CONTROL_CHIP_ENABLE (1 << 1) 58#define MT9T001_OUTPUT_CONTROL_CHIP_ENABLE (1 << 1)
57#define MT9T001_OUTPUT_CONTROL_TEST_DATA (1 << 6) 59#define MT9T001_OUTPUT_CONTROL_TEST_DATA (1 << 6)
60#define MT9T001_OUTPUT_CONTROL_DEF 0x0002
58#define MT9T001_SHUTTER_WIDTH_HIGH 0x08 61#define MT9T001_SHUTTER_WIDTH_HIGH 0x08
59#define MT9T001_SHUTTER_WIDTH_LOW 0x09 62#define MT9T001_SHUTTER_WIDTH_LOW 0x09
60#define MT9T001_SHUTTER_WIDTH_MIN 1 63#define MT9T001_SHUTTER_WIDTH_MIN 1
@@ -116,6 +119,12 @@ struct mt9t001 {
116 struct v4l2_subdev subdev; 119 struct v4l2_subdev subdev;
117 struct media_pad pad; 120 struct media_pad pad;
118 121
122 struct clk *clk;
123 struct regulator_bulk_data regulators[2];
124
125 struct mutex power_lock; /* lock to protect power_count */
126 int power_count;
127
119 struct v4l2_mbus_framefmt format; 128 struct v4l2_mbus_framefmt format;
120 struct v4l2_rect crop; 129 struct v4l2_rect crop;
121 130
@@ -159,6 +168,77 @@ static int mt9t001_set_output_control(struct mt9t001 *mt9t001, u16 clear,
159 return 0; 168 return 0;
160} 169}
161 170
171static int mt9t001_reset(struct mt9t001 *mt9t001)
172{
173 struct i2c_client *client = v4l2_get_subdevdata(&mt9t001->subdev);
174 int ret;
175
176 /* Reset the chip and stop data read out */
177 ret = mt9t001_write(client, MT9T001_RESET, 1);
178 if (ret < 0)
179 return ret;
180
181 ret = mt9t001_write(client, MT9T001_RESET, 0);
182 if (ret < 0)
183 return ret;
184
185 mt9t001->output_control = MT9T001_OUTPUT_CONTROL_DEF;
186
187 return mt9t001_set_output_control(mt9t001,
188 MT9T001_OUTPUT_CONTROL_CHIP_ENABLE,
189 0);
190}
191
192static int mt9t001_power_on(struct mt9t001 *mt9t001)
193{
194 int ret;
195
196 /* Bring up the supplies */
197 ret = regulator_bulk_enable(ARRAY_SIZE(mt9t001->regulators),
198 mt9t001->regulators);
199 if (ret < 0)
200 return ret;
201
202 /* Enable clock */
203 ret = clk_prepare_enable(mt9t001->clk);
204 if (ret < 0)
205 regulator_bulk_disable(ARRAY_SIZE(mt9t001->regulators),
206 mt9t001->regulators);
207
208 return ret;
209}
210
211static void mt9t001_power_off(struct mt9t001 *mt9t001)
212{
213 regulator_bulk_disable(ARRAY_SIZE(mt9t001->regulators),
214 mt9t001->regulators);
215
216 clk_disable_unprepare(mt9t001->clk);
217}
218
219static int __mt9t001_set_power(struct mt9t001 *mt9t001, bool on)
220{
221 struct i2c_client *client = v4l2_get_subdevdata(&mt9t001->subdev);
222 int ret;
223
224 if (!on) {
225 mt9t001_power_off(mt9t001);
226 return 0;
227 }
228
229 ret = mt9t001_power_on(mt9t001);
230 if (ret < 0)
231 return ret;
232
233 ret = mt9t001_reset(mt9t001);
234 if (ret < 0) {
235 dev_err(&client->dev, "Failed to reset the camera\n");
236 return ret;
237 }
238
239 return v4l2_ctrl_handler_setup(&mt9t001->ctrls);
240}
241
162/* ----------------------------------------------------------------------------- 242/* -----------------------------------------------------------------------------
163 * V4L2 subdev video operations 243 * V4L2 subdev video operations
164 */ 244 */
@@ -195,6 +275,7 @@ static int mt9t001_s_stream(struct v4l2_subdev *subdev, int enable)
195{ 275{
196 const u16 mode = MT9T001_OUTPUT_CONTROL_CHIP_ENABLE; 276 const u16 mode = MT9T001_OUTPUT_CONTROL_CHIP_ENABLE;
197 struct i2c_client *client = v4l2_get_subdevdata(subdev); 277 struct i2c_client *client = v4l2_get_subdevdata(subdev);
278 struct mt9t001_platform_data *pdata = client->dev.platform_data;
198 struct mt9t001 *mt9t001 = to_mt9t001(subdev); 279 struct mt9t001 *mt9t001 = to_mt9t001(subdev);
199 struct v4l2_mbus_framefmt *format = &mt9t001->format; 280 struct v4l2_mbus_framefmt *format = &mt9t001->format;
200 struct v4l2_rect *crop = &mt9t001->crop; 281 struct v4l2_rect *crop = &mt9t001->crop;
@@ -205,6 +286,14 @@ static int mt9t001_s_stream(struct v4l2_subdev *subdev, int enable)
205 if (!enable) 286 if (!enable)
206 return mt9t001_set_output_control(mt9t001, mode, 0); 287 return mt9t001_set_output_control(mt9t001, mode, 0);
207 288
289 /* Configure the pixel clock polarity */
290 if (pdata->clk_pol) {
291 ret = mt9t001_write(client, MT9T001_PIXEL_CLOCK,
292 MT9T001_PIXEL_CLOCK_INVERT);
293 if (ret < 0)
294 return ret;
295 }
296
208 /* Configure the window size and row/column bin */ 297 /* Configure the window size and row/column bin */
209 hratio = DIV_ROUND_CLOSEST(crop->width, format->width); 298 hratio = DIV_ROUND_CLOSEST(crop->width, format->width);
210 vratio = DIV_ROUND_CLOSEST(crop->height, format->height); 299 vratio = DIV_ROUND_CLOSEST(crop->height, format->height);
@@ -630,9 +719,67 @@ static const struct v4l2_ctrl_config mt9t001_gains[] = {
630}; 719};
631 720
632/* ----------------------------------------------------------------------------- 721/* -----------------------------------------------------------------------------
722 * V4L2 subdev core operations
723 */
724
725static int mt9t001_set_power(struct v4l2_subdev *subdev, int on)
726{
727 struct mt9t001 *mt9t001 = to_mt9t001(subdev);
728 int ret = 0;
729
730 mutex_lock(&mt9t001->power_lock);
731
732 /* If the power count is modified from 0 to != 0 or from != 0 to 0,
733 * update the power state.
734 */
735 if (mt9t001->power_count == !on) {
736 ret = __mt9t001_set_power(mt9t001, !!on);
737 if (ret < 0)
738 goto out;
739 }
740
741 /* Update the power count. */
742 mt9t001->power_count += on ? 1 : -1;
743 WARN_ON(mt9t001->power_count < 0);
744
745out:
746 mutex_unlock(&mt9t001->power_lock);
747 return ret;
748}
749
750/* -----------------------------------------------------------------------------
633 * V4L2 subdev internal operations 751 * V4L2 subdev internal operations
634 */ 752 */
635 753
754static int mt9t001_registered(struct v4l2_subdev *subdev)
755{
756 struct i2c_client *client = v4l2_get_subdevdata(subdev);
757 struct mt9t001 *mt9t001 = to_mt9t001(subdev);
758 s32 data;
759 int ret;
760
761 ret = mt9t001_power_on(mt9t001);
762 if (ret < 0) {
763 dev_err(&client->dev, "MT9T001 power up failed\n");
764 return ret;
765 }
766
767 /* Read out the chip version register */
768 data = mt9t001_read(client, MT9T001_CHIP_VERSION);
769 mt9t001_power_off(mt9t001);
770
771 if (data != MT9T001_CHIP_ID) {
772 dev_err(&client->dev,
773 "MT9T001 not detected, wrong version 0x%04x\n", data);
774 return -ENODEV;
775 }
776
777 dev_info(&client->dev, "MT9T001 detected at address 0x%02x\n",
778 client->addr);
779
780 return 0;
781}
782
636static int mt9t001_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh) 783static int mt9t001_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
637{ 784{
638 struct v4l2_mbus_framefmt *format; 785 struct v4l2_mbus_framefmt *format;
@@ -651,9 +798,18 @@ static int mt9t001_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
651 format->field = V4L2_FIELD_NONE; 798 format->field = V4L2_FIELD_NONE;
652 format->colorspace = V4L2_COLORSPACE_SRGB; 799 format->colorspace = V4L2_COLORSPACE_SRGB;
653 800
654 return 0; 801 return mt9t001_set_power(subdev, 1);
802}
803
804static int mt9t001_close(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
805{
806 return mt9t001_set_power(subdev, 0);
655} 807}
656 808
809static struct v4l2_subdev_core_ops mt9t001_subdev_core_ops = {
810 .s_power = mt9t001_set_power,
811};
812
657static struct v4l2_subdev_video_ops mt9t001_subdev_video_ops = { 813static struct v4l2_subdev_video_ops mt9t001_subdev_video_ops = {
658 .s_stream = mt9t001_s_stream, 814 .s_stream = mt9t001_s_stream,
659}; 815};
@@ -668,58 +824,17 @@ static struct v4l2_subdev_pad_ops mt9t001_subdev_pad_ops = {
668}; 824};
669 825
670static struct v4l2_subdev_ops mt9t001_subdev_ops = { 826static struct v4l2_subdev_ops mt9t001_subdev_ops = {
827 .core = &mt9t001_subdev_core_ops,
671 .video = &mt9t001_subdev_video_ops, 828 .video = &mt9t001_subdev_video_ops,
672 .pad = &mt9t001_subdev_pad_ops, 829 .pad = &mt9t001_subdev_pad_ops,
673}; 830};
674 831
675static struct v4l2_subdev_internal_ops mt9t001_subdev_internal_ops = { 832static struct v4l2_subdev_internal_ops mt9t001_subdev_internal_ops = {
833 .registered = mt9t001_registered,
676 .open = mt9t001_open, 834 .open = mt9t001_open,
835 .close = mt9t001_close,
677}; 836};
678 837
679static int mt9t001_video_probe(struct i2c_client *client)
680{
681 struct mt9t001_platform_data *pdata = client->dev.platform_data;
682 s32 data;
683 int ret;
684
685 dev_info(&client->dev, "Probing MT9T001 at address 0x%02x\n",
686 client->addr);
687
688 /* Reset the chip and stop data read out */
689 ret = mt9t001_write(client, MT9T001_RESET, 1);
690 if (ret < 0)
691 return ret;
692
693 ret = mt9t001_write(client, MT9T001_RESET, 0);
694 if (ret < 0)
695 return ret;
696
697 ret = mt9t001_write(client, MT9T001_OUTPUT_CONTROL, 0);
698 if (ret < 0)
699 return ret;
700
701 /* Configure the pixel clock polarity */
702 if (pdata->clk_pol) {
703 ret = mt9t001_write(client, MT9T001_PIXEL_CLOCK,
704 MT9T001_PIXEL_CLOCK_INVERT);
705 if (ret < 0)
706 return ret;
707 }
708
709 /* Read and check the sensor version */
710 data = mt9t001_read(client, MT9T001_CHIP_VERSION);
711 if (data != MT9T001_CHIP_ID) {
712 dev_err(&client->dev, "MT9T001 not detected, wrong version "
713 "0x%04x\n", data);
714 return -ENODEV;
715 }
716
717 dev_info(&client->dev, "MT9T001 detected at address 0x%02x\n",
718 client->addr);
719
720 return ret;
721}
722
723static int mt9t001_probe(struct i2c_client *client, 838static int mt9t001_probe(struct i2c_client *client,
724 const struct i2c_device_id *did) 839 const struct i2c_device_id *did)
725{ 840{
@@ -740,14 +855,28 @@ static int mt9t001_probe(struct i2c_client *client,
740 return -EIO; 855 return -EIO;
741 } 856 }
742 857
743 ret = mt9t001_video_probe(client);
744 if (ret < 0)
745 return ret;
746
747 mt9t001 = devm_kzalloc(&client->dev, sizeof(*mt9t001), GFP_KERNEL); 858 mt9t001 = devm_kzalloc(&client->dev, sizeof(*mt9t001), GFP_KERNEL);
748 if (!mt9t001) 859 if (!mt9t001)
749 return -ENOMEM; 860 return -ENOMEM;
750 861
862 mutex_init(&mt9t001->power_lock);
863 mt9t001->output_control = MT9T001_OUTPUT_CONTROL_DEF;
864
865 mt9t001->regulators[0].supply = "vdd";
866 mt9t001->regulators[1].supply = "vaa";
867
868 ret = devm_regulator_bulk_get(&client->dev, 2, mt9t001->regulators);
869 if (ret < 0) {
870 dev_err(&client->dev, "Unable to get regulators\n");
871 return ret;
872 }
873
874 mt9t001->clk = devm_clk_get(&client->dev, NULL);
875 if (IS_ERR(mt9t001->clk)) {
876 dev_err(&client->dev, "Unable to get clock\n");
877 return PTR_ERR(mt9t001->clk);
878 }
879
751 v4l2_ctrl_handler_init(&mt9t001->ctrls, ARRAY_SIZE(mt9t001_ctrls) + 880 v4l2_ctrl_handler_init(&mt9t001->ctrls, ARRAY_SIZE(mt9t001_ctrls) +
752 ARRAY_SIZE(mt9t001_gains) + 4); 881 ARRAY_SIZE(mt9t001_gains) + 4);
753 882
diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c
index f74698cf14c9..47e475319a24 100644
--- a/drivers/media/i2c/mt9v011.c
+++ b/drivers/media/i2c/mt9v011.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * mt9v011 -Micron 1/4-Inch VGA Digital Image Sensor 2 * mt9v011 -Micron 1/4-Inch VGA Digital Image Sensor
3 * 3 *
4 * Copyright (c) 2009 Mauro Carvalho Chehab (mchehab@redhat.com) 4 * Copyright (c) 2009 Mauro Carvalho Chehab
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
@@ -16,7 +16,7 @@
16#include <media/mt9v011.h> 16#include <media/mt9v011.h>
17 17
18MODULE_DESCRIPTION("Micron mt9v011 sensor driver"); 18MODULE_DESCRIPTION("Micron mt9v011 sensor driver");
19MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 19MODULE_AUTHOR("Mauro Carvalho Chehab");
20MODULE_LICENSE("GPL"); 20MODULE_LICENSE("GPL");
21 21
22static int debug; 22static int debug;
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 36c504b78f2c..40172b8d8ea2 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -317,8 +317,14 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032)
317 struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev); 317 struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev);
318 int ret; 318 int ret;
319 319
320 clk_set_rate(mt9v032->clk, mt9v032->sysclk); 320 ret = clk_set_rate(mt9v032->clk, mt9v032->sysclk);
321 clk_prepare_enable(mt9v032->clk); 321 if (ret < 0)
322 return ret;
323
324 ret = clk_prepare_enable(mt9v032->clk);
325 if (ret)
326 return ret;
327
322 udelay(1); 328 udelay(1);
323 329
324 /* Reset the chip and stop data read out */ 330 /* Reset the chip and stop data read out */
diff --git a/drivers/media/i2c/sr030pc30.c b/drivers/media/i2c/sr030pc30.c
index ae9432637fcb..118f8ee88465 100644
--- a/drivers/media/i2c/sr030pc30.c
+++ b/drivers/media/i2c/sr030pc30.c
@@ -8,7 +8,7 @@
8 * and HeungJun Kim <riverful.kim@samsung.com>. 8 * and HeungJun Kim <riverful.kim@samsung.com>.
9 * 9 *
10 * Based on mt9v011 Micron Digital Image Sensor driver 10 * Based on mt9v011 Micron Digital Image Sensor driver
11 * Copyright (c) 2009 Mauro Carvalho Chehab (mchehab@redhat.com) 11 * Copyright (c) 2009 Mauro Carvalho Chehab
12 * 12 *
13 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by 14 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/i2c/ths8200.c b/drivers/media/i2c/ths8200.c
index 04139eec8c4e..f72561e79739 100644
--- a/drivers/media/i2c/ths8200.c
+++ b/drivers/media/i2c/ths8200.c
@@ -217,8 +217,8 @@ static void ths8200_core_init(struct v4l2_subdev *sd)
217 /* Disable embedded syncs on the output by setting 217 /* Disable embedded syncs on the output by setting
218 * the amplitude to zero for all channels. 218 * the amplitude to zero for all channels.
219 */ 219 */
220 ths8200_write(sd, THS8200_DTG1_Y_SYNC_MSB, 0x2a); 220 ths8200_write(sd, THS8200_DTG1_Y_SYNC_MSB, 0x00);
221 ths8200_write(sd, THS8200_DTG1_CBCR_SYNC_MSB, 0x2a); 221 ths8200_write(sd, THS8200_DTG1_CBCR_SYNC_MSB, 0x00);
222} 222}
223 223
224static void ths8200_setup(struct v4l2_subdev *sd, struct v4l2_bt_timings *bt) 224static void ths8200_setup(struct v4l2_subdev *sd, struct v4l2_bt_timings *bt)
@@ -318,15 +318,15 @@ static void ths8200_setup(struct v4l2_subdev *sd, struct v4l2_bt_timings *bt)
318 (htotal(bt) >> 8) & 0x1f); 318 (htotal(bt) >> 8) & 0x1f);
319 ths8200_write(sd, THS8200_DTG2_HLENGTH_HDLY_LSB, htotal(bt)); 319 ths8200_write(sd, THS8200_DTG2_HLENGTH_HDLY_LSB, htotal(bt));
320 320
321 /* v sync width transmitted */ 321 /* v sync width transmitted (must add 1 to get correct output) */
322 ths8200_write(sd, THS8200_DTG2_VLENGTH1_LSB, (bt->vsync) & 0xff); 322 ths8200_write(sd, THS8200_DTG2_VLENGTH1_LSB, (bt->vsync + 1) & 0xff);
323 ths8200_write_and_or(sd, THS8200_DTG2_VLENGTH1_MSB_VDLY1_MSB, 0x3f, 323 ths8200_write_and_or(sd, THS8200_DTG2_VLENGTH1_MSB_VDLY1_MSB, 0x3f,
324 ((bt->vsync) >> 2) & 0xc0); 324 ((bt->vsync + 1) >> 2) & 0xc0);
325 325
326 /* The pixel value v sync is asserted on */ 326 /* The pixel value v sync is asserted on (must add 1 to get correct output) */
327 ths8200_write_and_or(sd, THS8200_DTG2_VLENGTH1_MSB_VDLY1_MSB, 0xf8, 327 ths8200_write_and_or(sd, THS8200_DTG2_VLENGTH1_MSB_VDLY1_MSB, 0xf8,
328 (vtotal(bt)>>8) & 0x7); 328 ((vtotal(bt) + 1) >> 8) & 0x7);
329 ths8200_write(sd, THS8200_DTG2_VDLY1_LSB, vtotal(bt)); 329 ths8200_write(sd, THS8200_DTG2_VDLY1_LSB, vtotal(bt) + 1);
330 330
331 /* For progressive video vlength2 must be set to all 0 and vdly2 must 331 /* For progressive video vlength2 must be set to all 0 and vdly2 must
332 * be set to all 1. 332 * be set to all 1.
@@ -336,11 +336,11 @@ static void ths8200_setup(struct v4l2_subdev *sd, struct v4l2_bt_timings *bt)
336 ths8200_write(sd, THS8200_DTG2_VDLY2_LSB, 0xff); 336 ths8200_write(sd, THS8200_DTG2_VDLY2_LSB, 0xff);
337 337
338 /* Internal delay factors to synchronize the sync pulses and the data */ 338 /* Internal delay factors to synchronize the sync pulses and the data */
339 /* Experimental values delays (hor 4, ver 1) */ 339 /* Experimental values delays (hor 0, ver 0) */
340 ths8200_write(sd, THS8200_DTG2_HS_IN_DLY_MSB, (htotal(bt)>>8) & 0x1f); 340 ths8200_write(sd, THS8200_DTG2_HS_IN_DLY_MSB, 0);
341 ths8200_write(sd, THS8200_DTG2_HS_IN_DLY_LSB, (htotal(bt) - 4) & 0xff); 341 ths8200_write(sd, THS8200_DTG2_HS_IN_DLY_LSB, 0);
342 ths8200_write(sd, THS8200_DTG2_VS_IN_DLY_MSB, 0); 342 ths8200_write(sd, THS8200_DTG2_VS_IN_DLY_MSB, 0);
343 ths8200_write(sd, THS8200_DTG2_VS_IN_DLY_LSB, 1); 343 ths8200_write(sd, THS8200_DTG2_VS_IN_DLY_LSB, 0);
344 344
345 /* Polarity of received and transmitted sync signals */ 345 /* Polarity of received and transmitted sync signals */
346 if (bt->polarities & V4L2_DV_HSYNC_POS_POL) { 346 if (bt->polarities & V4L2_DV_HSYNC_POS_POL) {
@@ -356,7 +356,7 @@ static void ths8200_setup(struct v4l2_subdev *sd, struct v4l2_bt_timings *bt)
356 /* Timing of video input bus is derived from HS, VS, and FID dedicated 356 /* Timing of video input bus is derived from HS, VS, and FID dedicated
357 * inputs 357 * inputs
358 */ 358 */
359 ths8200_write(sd, THS8200_DTG2_CNTL, 0x47 | polarity); 359 ths8200_write(sd, THS8200_DTG2_CNTL, 0x44 | polarity);
360 360
361 /* leave reset */ 361 /* leave reset */
362 ths8200_s_stream(sd, true); 362 ths8200_s_stream(sd, true);
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 542d2528b3f9..4fd3688e1164 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -16,9 +16,9 @@
16 16
17#include "tvp5150_reg.h" 17#include "tvp5150_reg.h"
18 18
19#define TVP5150_H_MAX 720 19#define TVP5150_H_MAX 720U
20#define TVP5150_V_MAX_525_60 480 20#define TVP5150_V_MAX_525_60 480U
21#define TVP5150_V_MAX_OTHERS 576 21#define TVP5150_V_MAX_OTHERS 576U
22#define TVP5150_MAX_CROP_LEFT 511 22#define TVP5150_MAX_CROP_LEFT 511
23#define TVP5150_MAX_CROP_TOP 127 23#define TVP5150_MAX_CROP_TOP 127
24#define TVP5150_CROP_SHIFT 2 24#define TVP5150_CROP_SHIFT 2
@@ -29,7 +29,7 @@ MODULE_LICENSE("GPL");
29 29
30 30
31static int debug; 31static int debug;
32module_param(debug, int, 0); 32module_param(debug, int, 0644);
33MODULE_PARM_DESC(debug, "Debug level (0-2)"); 33MODULE_PARM_DESC(debug, "Debug level (0-2)");
34 34
35struct tvp5150 { 35struct tvp5150 {
diff --git a/drivers/media/parport/bw-qcam.c b/drivers/media/parport/bw-qcam.c
index d12bd33f39cb..8a0e84c7d495 100644
--- a/drivers/media/parport/bw-qcam.c
+++ b/drivers/media/parport/bw-qcam.c
@@ -667,13 +667,16 @@ static void buffer_queue(struct vb2_buffer *vb)
667 vb2_buffer_done(vb, VB2_BUF_STATE_DONE); 667 vb2_buffer_done(vb, VB2_BUF_STATE_DONE);
668} 668}
669 669
670static int buffer_finish(struct vb2_buffer *vb) 670static void buffer_finish(struct vb2_buffer *vb)
671{ 671{
672 struct qcam *qcam = vb2_get_drv_priv(vb->vb2_queue); 672 struct qcam *qcam = vb2_get_drv_priv(vb->vb2_queue);
673 void *vbuf = vb2_plane_vaddr(vb, 0); 673 void *vbuf = vb2_plane_vaddr(vb, 0);
674 int size = vb->vb2_queue->plane_sizes[0]; 674 int size = vb->vb2_queue->plane_sizes[0];
675 int len; 675 int len;
676 676
677 if (!vb2_is_streaming(vb->vb2_queue))
678 return;
679
677 mutex_lock(&qcam->lock); 680 mutex_lock(&qcam->lock);
678 parport_claim_or_block(qcam->pdev); 681 parport_claim_or_block(qcam->pdev);
679 682
@@ -691,7 +694,6 @@ static int buffer_finish(struct vb2_buffer *vb)
691 if (len != size) 694 if (len != size)
692 vb->state = VB2_BUF_STATE_ERROR; 695 vb->state = VB2_BUF_STATE_ERROR;
693 vb2_set_plane_payload(vb, 0, len); 696 vb2_set_plane_payload(vb, 0, len);
694 return 0;
695} 697}
696 698
697static struct vb2_ops qcam_video_qops = { 699static struct vb2_ops qcam_video_qops = {
@@ -965,7 +967,7 @@ static struct qcam *qcam_init(struct parport *port)
965 q->drv_priv = qcam; 967 q->drv_priv = qcam;
966 q->ops = &qcam_video_qops; 968 q->ops = &qcam_video_qops;
967 q->mem_ops = &vb2_vmalloc_memops; 969 q->mem_ops = &vb2_vmalloc_memops;
968 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 970 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
969 err = vb2_queue_init(q); 971 err = vb2_queue_init(q);
970 if (err < 0) { 972 if (err < 0) {
971 v4l2_err(v4l2_dev, "couldn't init vb2_queue for %s.\n", port->name); 973 v4l2_err(v4l2_dev, "couldn't init vb2_queue for %s.\n", port->name);
diff --git a/drivers/media/pci/bt8xx/bttv-cards.c b/drivers/media/pci/bt8xx/bttv-cards.c
index 6662b495b22c..d06963b3dcf3 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -2855,7 +2855,22 @@ struct tvcard bttv_tvcards[] = {
2855 .tuner_type = TUNER_ABSENT, 2855 .tuner_type = TUNER_ABSENT,
2856 .tuner_addr = ADDR_UNSET, 2856 .tuner_addr = ADDR_UNSET,
2857 }, 2857 },
2858 2858 [BTTV_BOARD_KWORLD_VSTREAM_XPERT] = {
2859 /* Pojar George <geoubuntu@gmail.com> */
2860 .name = "Kworld V-Stream Xpert TV PVR878",
2861 .video_inputs = 3,
2862 /* .audio_inputs= 1, */
2863 .svhs = 2,
2864 .gpiomask = 0x001c0007,
2865 .muxsel = MUXSEL(2, 3, 1, 1),
2866 .gpiomux = { 0, 1, 2, 2 },
2867 .gpiomute = 3,
2868 .pll = PLL_28,
2869 .tuner_type = TUNER_TENA_9533_DI,
2870 .tuner_addr = ADDR_UNSET,
2871 .has_remote = 1,
2872 .has_radio = 1,
2873 },
2859}; 2874};
2860 2875
2861static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards); 2876static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards);
diff --git a/drivers/media/pci/bt8xx/bttv-input.c b/drivers/media/pci/bt8xx/bttv-input.c
index f36821367d8d..5930bce16658 100644
--- a/drivers/media/pci/bt8xx/bttv-input.c
+++ b/drivers/media/pci/bt8xx/bttv-input.c
@@ -483,6 +483,7 @@ int bttv_input_init(struct bttv *btv)
483 case BTTV_BOARD_ASKEY_CPH03X: 483 case BTTV_BOARD_ASKEY_CPH03X:
484 case BTTV_BOARD_CONCEPTRONIC_CTVFMI2: 484 case BTTV_BOARD_CONCEPTRONIC_CTVFMI2:
485 case BTTV_BOARD_CONTVFMI: 485 case BTTV_BOARD_CONTVFMI:
486 case BTTV_BOARD_KWORLD_VSTREAM_XPERT:
486 ir_codes = RC_MAP_PIXELVIEW; 487 ir_codes = RC_MAP_PIXELVIEW;
487 ir->mask_keycode = 0x001F00; 488 ir->mask_keycode = 0x001F00;
488 ir->mask_keyup = 0x006000; 489 ir->mask_keyup = 0x006000;
diff --git a/drivers/media/pci/bt8xx/bttv.h b/drivers/media/pci/bt8xx/bttv.h
index df578efe03c9..bb5da349a46e 100644
--- a/drivers/media/pci/bt8xx/bttv.h
+++ b/drivers/media/pci/bt8xx/bttv.h
@@ -188,6 +188,7 @@
188#define BTTV_BOARD_ADLINK_MPG24 0xa2 188#define BTTV_BOARD_ADLINK_MPG24 0xa2
189#define BTTV_BOARD_BT848_CAP_14 0xa3 189#define BTTV_BOARD_BT848_CAP_14 0xa3
190#define BTTV_BOARD_CYBERVISION_CV06 0xa4 190#define BTTV_BOARD_CYBERVISION_CV06 0xa4
191#define BTTV_BOARD_KWORLD_VSTREAM_XPERT 0xa5
191 192
192/* more card-specific defines */ 193/* more card-specific defines */
193#define PT2254_L_CHANNEL 0x10 194#define PT2254_L_CHANNEL 0x10
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index 05492053b473..4be01b3bd4f5 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -473,6 +473,7 @@ static struct ds3000_config tevii_ds3000_config = {
473static struct ts2020_config tevii_ts2020_config = { 473static struct ts2020_config tevii_ts2020_config = {
474 .tuner_address = 0x60, 474 .tuner_address = 0x60,
475 .clk_out_div = 1, 475 .clk_out_div = 1,
476 .frequency_div = 1146000,
476}; 477};
477 478
478static struct cx24116_config dvbworld_cx24116_config = { 479static struct cx24116_config dvbworld_cx24116_config = {
diff --git a/drivers/media/pci/cx23885/cx23885-input.c b/drivers/media/pci/cx23885/cx23885-input.c
index 8a49e7c9eddd..097d0a0b5f57 100644
--- a/drivers/media/pci/cx23885/cx23885-input.c
+++ b/drivers/media/pci/cx23885/cx23885-input.c
@@ -346,7 +346,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
346 } 346 }
347 rc->dev.parent = &dev->pci->dev; 347 rc->dev.parent = &dev->pci->dev;
348 rc->driver_type = driver_type; 348 rc->driver_type = driver_type;
349 rc->allowed_protos = allowed_protos; 349 rc_set_allowed_protocols(rc, allowed_protos);
350 rc->priv = kernel_ir; 350 rc->priv = kernel_ir;
351 rc->open = cx23885_input_ir_open; 351 rc->open = cx23885_input_ir_open;
352 rc->close = cx23885_input_ir_close; 352 rc->close = cx23885_input_ir_close;
diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c
index f29e18c72f44..f991696a6c59 100644
--- a/drivers/media/pci/cx88/cx88-input.c
+++ b/drivers/media/pci/cx88/cx88-input.c
@@ -469,7 +469,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
469 dev->timeout = 10 * 1000 * 1000; /* 10 ms */ 469 dev->timeout = 10 * 1000 * 1000; /* 10 ms */
470 } else { 470 } else {
471 dev->driver_type = RC_DRIVER_SCANCODE; 471 dev->driver_type = RC_DRIVER_SCANCODE;
472 dev->allowed_protos = rc_type; 472 rc_set_allowed_protocols(dev, rc_type);
473 } 473 }
474 474
475 ir->core = core; 475 ir->core = core;
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
index 9375f30d9a81..fb52bda8d45f 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -876,10 +876,8 @@ static int dvb_input_attach(struct ddb_input *input)
876 return -ENODEV; 876 return -ENODEV;
877 if (tuner_attach_tda18271(input) < 0) 877 if (tuner_attach_tda18271(input) < 0)
878 return -ENODEV; 878 return -ENODEV;
879 if (input->fe) { 879 if (dvb_register_frontend(adap, input->fe) < 0)
880 if (dvb_register_frontend(adap, input->fe) < 0) 880 return -ENODEV;
881 return -ENODEV;
882 }
883 if (input->fe2) { 881 if (input->fe2) {
884 if (dvb_register_frontend(adap, input->fe2) < 0) 882 if (dvb_register_frontend(adap, input->fe2) < 0)
885 return -ENODEV; 883 return -ENODEV;
diff --git a/drivers/media/pci/saa7134/saa7134-cards.c b/drivers/media/pci/saa7134/saa7134-cards.c
index c9b2350e92c8..6e4bdb90aa92 100644
--- a/drivers/media/pci/saa7134/saa7134-cards.c
+++ b/drivers/media/pci/saa7134/saa7134-cards.c
@@ -8045,8 +8045,8 @@ int saa7134_board_init2(struct saa7134_dev *dev)
8045 break; 8045 break;
8046 } /* switch() */ 8046 } /* switch() */
8047 8047
8048 /* initialize tuner */ 8048 /* initialize tuner (don't do this when resuming) */
8049 if (TUNER_ABSENT != dev->tuner_type) { 8049 if (!dev->insuspend && TUNER_ABSENT != dev->tuner_type) {
8050 int has_demod = (dev->tda9887_conf & TDA9887_PRESENT); 8050 int has_demod = (dev->tda9887_conf & TDA9887_PRESENT);
8051 8051
8052 /* Note: radio tuner address is always filled in, 8052 /* Note: radio tuner address is always filled in,
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c
index e5cfb6cfa18d..bb11443ed63e 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -327,7 +327,7 @@ static void buffer_queue(struct vb2_buffer *vb)
327 } 327 }
328 spin_unlock(&vip->lock); 328 spin_unlock(&vip->lock);
329} 329}
330static int buffer_finish(struct vb2_buffer *vb) 330static void buffer_finish(struct vb2_buffer *vb)
331{ 331{
332 struct sta2x11_vip *vip = vb2_get_drv_priv(vb->vb2_queue); 332 struct sta2x11_vip *vip = vb2_get_drv_priv(vb->vb2_queue);
333 struct vip_buffer *vip_buf = to_vip_buffer(vb); 333 struct vip_buffer *vip_buf = to_vip_buffer(vb);
@@ -337,9 +337,8 @@ static int buffer_finish(struct vb2_buffer *vb)
337 list_del_init(&vip_buf->list); 337 list_del_init(&vip_buf->list);
338 spin_unlock(&vip->lock); 338 spin_unlock(&vip->lock);
339 339
340 vip_active_buf_next(vip); 340 if (vb2_is_streaming(vb->vb2_queue))
341 341 vip_active_buf_next(vip);
342 return 0;
343} 342}
344 343
345static int start_streaming(struct vb2_queue *vq, unsigned int count) 344static int start_streaming(struct vb2_queue *vq, unsigned int count)
diff --git a/drivers/media/pci/ttpci/av7110_hw.c b/drivers/media/pci/ttpci/av7110_hw.c
index 6299d5dadb82..300bd3c94738 100644
--- a/drivers/media/pci/ttpci/av7110_hw.c
+++ b/drivers/media/pci/ttpci/av7110_hw.c
@@ -501,7 +501,7 @@ int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...)
501 501
502// dprintk(4, "%p\n", av7110); 502// dprintk(4, "%p\n", av7110);
503 503
504 if (2 + num > sizeof(buf)) { 504 if (2 + num > ARRAY_SIZE(buf)) {
505 printk(KERN_WARNING 505 printk(KERN_WARNING
506 "%s: %s len=%d is too big!\n", 506 "%s: %s len=%d is too big!\n",
507 KBUILD_MODNAME, __func__, num); 507 KBUILD_MODNAME, __func__, num);
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index b2a4403940c5..c137abfa0c54 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -36,7 +36,7 @@ source "drivers/media/platform/blackfin/Kconfig"
36config VIDEO_SH_VOU 36config VIDEO_SH_VOU
37 tristate "SuperH VOU video output driver" 37 tristate "SuperH VOU video output driver"
38 depends on MEDIA_CAMERA_SUPPORT 38 depends on MEDIA_CAMERA_SUPPORT
39 depends on VIDEO_DEV && I2C 39 depends on VIDEO_DEV && I2C && HAS_DMA
40 depends on ARCH_SHMOBILE || COMPILE_TEST 40 depends on ARCH_SHMOBILE || COMPILE_TEST
41 select VIDEOBUF_DMA_CONTIG 41 select VIDEOBUF_DMA_CONTIG
42 help 42 help
diff --git a/drivers/media/platform/arv.c b/drivers/media/platform/arv.c
index e346d32d08ce..e9410e41ae0c 100644
--- a/drivers/media/platform/arv.c
+++ b/drivers/media/platform/arv.c
@@ -109,7 +109,7 @@ extern struct cpuinfo_m32r boot_cpu_data;
109struct ar { 109struct ar {
110 struct v4l2_device v4l2_dev; 110 struct v4l2_device v4l2_dev;
111 struct video_device vdev; 111 struct video_device vdev;
112 unsigned int start_capture; /* duaring capture in INT. mode. */ 112 int start_capture; /* duaring capture in INT. mode. */
113#if USE_INT 113#if USE_INT
114 unsigned char *line_buff; /* DMA line buffer */ 114 unsigned char *line_buff; /* DMA line buffer */
115#endif 115#endif
@@ -307,11 +307,11 @@ static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos)
307 /* 307 /*
308 * Okay, kick AR LSI to invoke an interrupt 308 * Okay, kick AR LSI to invoke an interrupt
309 */ 309 */
310 ar->start_capture = 0; 310 ar->start_capture = -1;
311 ar_outl(arvcr1 | ARVCR1_HIEN, ARVCR1); 311 ar_outl(arvcr1 | ARVCR1_HIEN, ARVCR1);
312 local_irq_restore(flags); 312 local_irq_restore(flags);
313 /* .... AR interrupts .... */ 313 /* .... AR interrupts .... */
314 interruptible_sleep_on(&ar->wait); 314 wait_event_interruptible(ar->wait, ar->start_capture == 0);
315 if (signal_pending(current)) { 315 if (signal_pending(current)) {
316 printk(KERN_ERR "arv: interrupted while get frame data.\n"); 316 printk(KERN_ERR "arv: interrupted while get frame data.\n");
317 ret = -EINTR; 317 ret = -EINTR;
diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c
index 281916591437..200bec91182e 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -997,7 +997,7 @@ static int bcap_probe(struct platform_device *pdev)
997 q->buf_struct_size = sizeof(struct bcap_buffer); 997 q->buf_struct_size = sizeof(struct bcap_buffer);
998 q->ops = &bcap_video_qops; 998 q->ops = &bcap_video_qops;
999 q->mem_ops = &vb2_dma_contig_memops; 999 q->mem_ops = &vb2_dma_contig_memops;
1000 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1000 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1001 1001
1002 ret = vb2_queue_init(q); 1002 ret = vb2_queue_init(q);
1003 if (ret) 1003 if (ret)
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index 61f3dbcc259f..3e5199ee5d25 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -2428,7 +2428,7 @@ static int coda_queue_init(void *priv, struct vb2_queue *src_vq,
2428 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 2428 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
2429 src_vq->ops = &coda_qops; 2429 src_vq->ops = &coda_qops;
2430 src_vq->mem_ops = &vb2_dma_contig_memops; 2430 src_vq->mem_ops = &vb2_dma_contig_memops;
2431 src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 2431 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
2432 2432
2433 ret = vb2_queue_init(src_vq); 2433 ret = vb2_queue_init(src_vq);
2434 if (ret) 2434 if (ret)
@@ -2440,7 +2440,7 @@ static int coda_queue_init(void *priv, struct vb2_queue *src_vq,
2440 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 2440 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
2441 dst_vq->ops = &coda_qops; 2441 dst_vq->ops = &coda_qops;
2442 dst_vq->mem_ops = &vb2_dma_contig_memops; 2442 dst_vq->mem_ops = &vb2_dma_contig_memops;
2443 dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 2443 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
2444 2444
2445 return vb2_queue_init(dst_vq); 2445 return vb2_queue_init(dst_vq);
2446} 2446}
@@ -2829,6 +2829,9 @@ static void coda_finish_encode(struct coda_ctx *ctx)
2829 } 2829 }
2830 2830
2831 dst_buf->v4l2_buf.timestamp = src_buf->v4l2_buf.timestamp; 2831 dst_buf->v4l2_buf.timestamp = src_buf->v4l2_buf.timestamp;
2832 dst_buf->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
2833 dst_buf->v4l2_buf.flags |=
2834 src_buf->v4l2_buf.flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
2832 dst_buf->v4l2_buf.timecode = src_buf->v4l2_buf.timecode; 2835 dst_buf->v4l2_buf.timecode = src_buf->v4l2_buf.timecode;
2833 2836
2834 v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE); 2837 v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index b02aba488826..b4f12d00be05 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -341,14 +341,8 @@ static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count)
341{ 341{
342 struct vpbe_fh *fh = vb2_get_drv_priv(vq); 342 struct vpbe_fh *fh = vb2_get_drv_priv(vq);
343 struct vpbe_layer *layer = fh->layer; 343 struct vpbe_layer *layer = fh->layer;
344 struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev;
345 int ret; 344 int ret;
346 345
347 /* If buffer queue is empty, return error */
348 if (list_empty(&layer->dma_queue)) {
349 v4l2_err(&vpbe_dev->v4l2_dev, "buffer queue is empty\n");
350 return -ENOBUFS;
351 }
352 /* Get the next frame from the buffer queue */ 346 /* Get the next frame from the buffer queue */
353 layer->next_frm = layer->cur_frm = list_entry(layer->dma_queue.next, 347 layer->next_frm = layer->cur_frm = list_entry(layer->dma_queue.next,
354 struct vpbe_disp_buffer, list); 348 struct vpbe_disp_buffer, list);
@@ -1415,7 +1409,8 @@ static int vpbe_display_reqbufs(struct file *file, void *priv,
1415 q->ops = &video_qops; 1409 q->ops = &video_qops;
1416 q->mem_ops = &vb2_dma_contig_memops; 1410 q->mem_ops = &vb2_dma_contig_memops;
1417 q->buf_struct_size = sizeof(struct vpbe_disp_buffer); 1411 q->buf_struct_size = sizeof(struct vpbe_disp_buffer);
1418 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1412 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1413 q->min_buffers_needed = 1;
1419 1414
1420 ret = vb2_queue_init(q); 1415 ret = vb2_queue_init(q);
1421 if (ret) { 1416 if (ret) {
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index 735ec47601a9..756da78bac23 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -272,13 +272,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
272 unsigned long flags; 272 unsigned long flags;
273 int ret; 273 int ret;
274 274
275 /* If buffer queue is empty, return error */
276 spin_lock_irqsave(&common->irqlock, flags); 275 spin_lock_irqsave(&common->irqlock, flags);
277 if (list_empty(&common->dma_queue)) {
278 spin_unlock_irqrestore(&common->irqlock, flags);
279 vpif_dbg(1, debug, "buffer queue is empty\n");
280 return -ENOBUFS;
281 }
282 276
283 /* Get the next frame from the buffer queue */ 277 /* Get the next frame from the buffer queue */
284 common->cur_frm = common->next_frm = list_entry(common->dma_queue.next, 278 common->cur_frm = common->next_frm = list_entry(common->dma_queue.next,
@@ -1023,7 +1017,8 @@ static int vpif_reqbufs(struct file *file, void *priv,
1023 q->ops = &video_qops; 1017 q->ops = &video_qops;
1024 q->mem_ops = &vb2_dma_contig_memops; 1018 q->mem_ops = &vb2_dma_contig_memops;
1025 q->buf_struct_size = sizeof(struct vpif_cap_buffer); 1019 q->buf_struct_size = sizeof(struct vpif_cap_buffer);
1026 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1020 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1021 q->min_buffers_needed = 1;
1027 1022
1028 ret = vb2_queue_init(q); 1023 ret = vb2_queue_init(q);
1029 if (ret) { 1024 if (ret) {
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index 9d115cdc6bdb..0ac841e35aa4 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -234,13 +234,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
234 unsigned long flags; 234 unsigned long flags;
235 int ret; 235 int ret;
236 236
237 /* If buffer queue is empty, return error */
238 spin_lock_irqsave(&common->irqlock, flags); 237 spin_lock_irqsave(&common->irqlock, flags);
239 if (list_empty(&common->dma_queue)) {
240 spin_unlock_irqrestore(&common->irqlock, flags);
241 vpif_err("buffer queue is empty\n");
242 return -ENOBUFS;
243 }
244 238
245 /* Get the next frame from the buffer queue */ 239 /* Get the next frame from the buffer queue */
246 common->next_frm = common->cur_frm = 240 common->next_frm = common->cur_frm =
@@ -983,7 +977,8 @@ static int vpif_reqbufs(struct file *file, void *priv,
983 q->ops = &video_qops; 977 q->ops = &video_qops;
984 q->mem_ops = &vb2_dma_contig_memops; 978 q->mem_ops = &vb2_dma_contig_memops;
985 q->buf_struct_size = sizeof(struct vpif_disp_buffer); 979 q->buf_struct_size = sizeof(struct vpif_disp_buffer);
986 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 980 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
981 q->min_buffers_needed = 1;
987 982
988 ret = vb2_queue_init(q); 983 ret = vb2_queue_init(q);
989 if (ret) { 984 if (ret) {
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 810c3e13970c..d0ea94f58d6f 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -88,8 +88,12 @@ void gsc_m2m_job_finish(struct gsc_ctx *ctx, int vb_state)
88 dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx); 88 dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
89 89
90 if (src_vb && dst_vb) { 90 if (src_vb && dst_vb) {
91 src_vb->v4l2_buf.timestamp = dst_vb->v4l2_buf.timestamp; 91 dst_vb->v4l2_buf.timestamp = src_vb->v4l2_buf.timestamp;
92 src_vb->v4l2_buf.timecode = dst_vb->v4l2_buf.timecode; 92 dst_vb->v4l2_buf.timecode = src_vb->v4l2_buf.timecode;
93 dst_vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
94 dst_vb->v4l2_buf.flags |=
95 src_vb->v4l2_buf.flags
96 & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
93 97
94 v4l2_m2m_buf_done(src_vb, vb_state); 98 v4l2_m2m_buf_done(src_vb, vb_state);
95 v4l2_m2m_buf_done(dst_vb, vb_state); 99 v4l2_m2m_buf_done(dst_vb, vb_state);
@@ -590,7 +594,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
590 src_vq->ops = &gsc_m2m_qops; 594 src_vq->ops = &gsc_m2m_qops;
591 src_vq->mem_ops = &vb2_dma_contig_memops; 595 src_vq->mem_ops = &vb2_dma_contig_memops;
592 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 596 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
593 src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 597 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
594 598
595 ret = vb2_queue_init(src_vq); 599 ret = vb2_queue_init(src_vq);
596 if (ret) 600 if (ret)
@@ -603,7 +607,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
603 dst_vq->ops = &gsc_m2m_qops; 607 dst_vq->ops = &gsc_m2m_qops;
604 dst_vq->mem_ops = &vb2_dma_contig_memops; 608 dst_vq->mem_ops = &vb2_dma_contig_memops;
605 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 609 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
606 dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 610 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
607 611
608 return vb2_queue_init(dst_vq); 612 return vb2_queue_init(dst_vq);
609} 613}
diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c
index 8a712ca91d11..92ae812abce2 100644
--- a/drivers/media/platform/exynos4-is/fimc-capture.c
+++ b/drivers/media/platform/exynos4-is/fimc-capture.c
@@ -1782,7 +1782,7 @@ static int fimc_register_capture_device(struct fimc_dev *fimc,
1782 q->ops = &fimc_capture_qops; 1782 q->ops = &fimc_capture_qops;
1783 q->mem_ops = &vb2_dma_contig_memops; 1783 q->mem_ops = &vb2_dma_contig_memops;
1784 q->buf_struct_size = sizeof(struct fimc_vid_buffer); 1784 q->buf_struct_size = sizeof(struct fimc_vid_buffer);
1785 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1785 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1786 q->lock = &fimc->lock; 1786 q->lock = &fimc->lock;
1787 1787
1788 ret = vb2_queue_init(q); 1788 ret = vb2_queue_init(q);
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index 779ec3cd259d..3ad660b55b6b 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -1313,7 +1313,7 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd)
1313 q->mem_ops = &vb2_dma_contig_memops; 1313 q->mem_ops = &vb2_dma_contig_memops;
1314 q->buf_struct_size = sizeof(struct flite_buffer); 1314 q->buf_struct_size = sizeof(struct flite_buffer);
1315 q->drv_priv = fimc; 1315 q->drv_priv = fimc;
1316 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1316 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1317 q->lock = &fimc->lock; 1317 q->lock = &fimc->lock;
1318 1318
1319 ret = vb2_queue_init(q); 1319 ret = vb2_queue_init(q);
diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c
index 9da95bd14820..36971d915b53 100644
--- a/drivers/media/platform/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/exynos4-is/fimc-m2m.c
@@ -134,6 +134,9 @@ static void fimc_device_run(void *priv)
134 goto dma_unlock; 134 goto dma_unlock;
135 135
136 dst_vb->v4l2_buf.timestamp = src_vb->v4l2_buf.timestamp; 136 dst_vb->v4l2_buf.timestamp = src_vb->v4l2_buf.timestamp;
137 dst_vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
138 dst_vb->v4l2_buf.flags |=
139 src_vb->v4l2_buf.flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
137 140
138 /* Reconfigure hardware if the context has changed. */ 141 /* Reconfigure hardware if the context has changed. */
139 if (fimc->m2m.ctx != ctx) { 142 if (fimc->m2m.ctx != ctx) {
@@ -557,7 +560,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
557 src_vq->ops = &fimc_qops; 560 src_vq->ops = &fimc_qops;
558 src_vq->mem_ops = &vb2_dma_contig_memops; 561 src_vq->mem_ops = &vb2_dma_contig_memops;
559 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 562 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
560 src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 563 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
561 src_vq->lock = &ctx->fimc_dev->lock; 564 src_vq->lock = &ctx->fimc_dev->lock;
562 565
563 ret = vb2_queue_init(src_vq); 566 ret = vb2_queue_init(src_vq);
@@ -570,7 +573,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
570 dst_vq->ops = &fimc_qops; 573 dst_vq->ops = &fimc_qops;
571 dst_vq->mem_ops = &vb2_dma_contig_memops; 574 dst_vq->mem_ops = &vb2_dma_contig_memops;
572 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 575 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
573 dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 576 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
574 dst_vq->lock = &ctx->fimc_dev->lock; 577 dst_vq->lock = &ctx->fimc_dev->lock;
575 578
576 return vb2_queue_init(dst_vq); 579 return vb2_queue_init(dst_vq);
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
index 6bb86b581a34..c21d14fd61db 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -207,8 +207,11 @@ static void dma_callback(void *data)
207 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx); 207 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
208 dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx); 208 dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
209 209
210 src_vb->v4l2_buf.timestamp = dst_vb->v4l2_buf.timestamp; 210 dst_vb->v4l2_buf.timestamp = src_vb->v4l2_buf.timestamp;
211 src_vb->v4l2_buf.timecode = dst_vb->v4l2_buf.timecode; 211 dst_vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
212 dst_vb->v4l2_buf.flags |=
213 src_vb->v4l2_buf.flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
214 dst_vb->v4l2_buf.timecode = src_vb->v4l2_buf.timecode;
212 215
213 v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE); 216 v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE);
214 v4l2_m2m_buf_done(dst_vb, VB2_BUF_STATE_DONE); 217 v4l2_m2m_buf_done(dst_vb, VB2_BUF_STATE_DONE);
@@ -868,7 +871,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
868 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 871 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
869 src_vq->ops = &deinterlace_qops; 872 src_vq->ops = &deinterlace_qops;
870 src_vq->mem_ops = &vb2_dma_contig_memops; 873 src_vq->mem_ops = &vb2_dma_contig_memops;
871 src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 874 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
872 q_data[V4L2_M2M_SRC].fmt = &formats[0]; 875 q_data[V4L2_M2M_SRC].fmt = &formats[0];
873 q_data[V4L2_M2M_SRC].width = 640; 876 q_data[V4L2_M2M_SRC].width = 640;
874 q_data[V4L2_M2M_SRC].height = 480; 877 q_data[V4L2_M2M_SRC].height = 480;
@@ -885,7 +888,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
885 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 888 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
886 dst_vq->ops = &deinterlace_qops; 889 dst_vq->ops = &deinterlace_qops;
887 dst_vq->mem_ops = &vb2_dma_contig_memops; 890 dst_vq->mem_ops = &vb2_dma_contig_memops;
888 dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 891 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
889 q_data[V4L2_M2M_DST].fmt = &formats[0]; 892 q_data[V4L2_M2M_DST].fmt = &formats[0];
890 q_data[V4L2_M2M_DST].width = 640; 893 q_data[V4L2_M2M_DST].width = 640;
891 q_data[V4L2_M2M_DST].height = 480; 894 q_data[V4L2_M2M_DST].height = 480;
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 32fab30a9105..8b34c485be79 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1238,7 +1238,7 @@ static int mcam_vb_sg_buf_prepare(struct vb2_buffer *vb)
1238 return 0; 1238 return 0;
1239} 1239}
1240 1240
1241static int mcam_vb_sg_buf_finish(struct vb2_buffer *vb) 1241static void mcam_vb_sg_buf_finish(struct vb2_buffer *vb)
1242{ 1242{
1243 struct mcam_camera *cam = vb2_get_drv_priv(vb->vb2_queue); 1243 struct mcam_camera *cam = vb2_get_drv_priv(vb->vb2_queue);
1244 struct sg_table *sg_table = vb2_dma_sg_plane_desc(vb, 0); 1244 struct sg_table *sg_table = vb2_dma_sg_plane_desc(vb, 0);
@@ -1246,7 +1246,6 @@ static int mcam_vb_sg_buf_finish(struct vb2_buffer *vb)
1246 if (sg_table) 1246 if (sg_table)
1247 dma_unmap_sg(cam->dev, sg_table->sgl, 1247 dma_unmap_sg(cam->dev, sg_table->sgl,
1248 sg_table->nents, DMA_FROM_DEVICE); 1248 sg_table->nents, DMA_FROM_DEVICE);
1249 return 0;
1250} 1249}
1251 1250
1252static void mcam_vb_sg_buf_cleanup(struct vb2_buffer *vb) 1251static void mcam_vb_sg_buf_cleanup(struct vb2_buffer *vb)
diff --git a/drivers/media/platform/mem2mem_testdev.c b/drivers/media/platform/mem2mem_testdev.c
index 08e24379b794..4f3096b17066 100644
--- a/drivers/media/platform/mem2mem_testdev.c
+++ b/drivers/media/platform/mem2mem_testdev.c
@@ -60,9 +60,7 @@ MODULE_PARM_DESC(debug, "activates debug info");
60#define MEM2MEM_VID_MEM_LIMIT (16 * 1024 * 1024) 60#define MEM2MEM_VID_MEM_LIMIT (16 * 1024 * 1024)
61 61
62/* Default transaction time in msec */ 62/* Default transaction time in msec */
63#define MEM2MEM_DEF_TRANSTIME 1000 63#define MEM2MEM_DEF_TRANSTIME 40
64/* Default number of buffers per transaction */
65#define MEM2MEM_DEF_TRANSLEN 1
66#define MEM2MEM_COLOR_STEP (0xff >> 4) 64#define MEM2MEM_COLOR_STEP (0xff >> 4)
67#define MEM2MEM_NUM_TILES 8 65#define MEM2MEM_NUM_TILES 8
68 66
@@ -114,6 +112,7 @@ struct m2mtest_q_data {
114 unsigned int width; 112 unsigned int width;
115 unsigned int height; 113 unsigned int height;
116 unsigned int sizeimage; 114 unsigned int sizeimage;
115 unsigned int sequence;
117 struct m2mtest_fmt *fmt; 116 struct m2mtest_fmt *fmt;
118}; 117};
119 118
@@ -236,9 +235,21 @@ static int device_process(struct m2mtest_ctx *ctx,
236 bytes_left = bytesperline - tile_w * MEM2MEM_NUM_TILES; 235 bytes_left = bytesperline - tile_w * MEM2MEM_NUM_TILES;
237 w = 0; 236 w = 0;
238 237
238 out_vb->v4l2_buf.sequence = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE)->sequence++;
239 in_vb->v4l2_buf.sequence = q_data->sequence++;
239 memcpy(&out_vb->v4l2_buf.timestamp, 240 memcpy(&out_vb->v4l2_buf.timestamp,
240 &in_vb->v4l2_buf.timestamp, 241 &in_vb->v4l2_buf.timestamp,
241 sizeof(struct timeval)); 242 sizeof(struct timeval));
243 if (in_vb->v4l2_buf.flags & V4L2_BUF_FLAG_TIMECODE)
244 memcpy(&out_vb->v4l2_buf.timecode, &in_vb->v4l2_buf.timecode,
245 sizeof(struct v4l2_timecode));
246 out_vb->v4l2_buf.field = in_vb->v4l2_buf.field;
247 out_vb->v4l2_buf.flags = in_vb->v4l2_buf.flags &
248 (V4L2_BUF_FLAG_TIMECODE |
249 V4L2_BUF_FLAG_KEYFRAME |
250 V4L2_BUF_FLAG_PFRAME |
251 V4L2_BUF_FLAG_BFRAME |
252 V4L2_BUF_FLAG_TSTAMP_SRC_MASK);
242 253
243 switch (ctx->mode) { 254 switch (ctx->mode) {
244 case MEM2MEM_HFLIP | MEM2MEM_VFLIP: 255 case MEM2MEM_HFLIP | MEM2MEM_VFLIP:
@@ -505,19 +516,8 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
505 516
506static int vidioc_try_fmt(struct v4l2_format *f, struct m2mtest_fmt *fmt) 517static int vidioc_try_fmt(struct v4l2_format *f, struct m2mtest_fmt *fmt)
507{ 518{
508 enum v4l2_field field;
509
510 field = f->fmt.pix.field;
511
512 if (field == V4L2_FIELD_ANY)
513 field = V4L2_FIELD_NONE;
514 else if (V4L2_FIELD_NONE != field)
515 return -EINVAL;
516
517 /* V4L2 specification suggests the driver corrects the format struct 519 /* V4L2 specification suggests the driver corrects the format struct
518 * if any of the dimensions is unsupported */ 520 * if any of the dimensions is unsupported */
519 f->fmt.pix.field = field;
520
521 if (f->fmt.pix.height < MIN_H) 521 if (f->fmt.pix.height < MIN_H)
522 f->fmt.pix.height = MIN_H; 522 f->fmt.pix.height = MIN_H;
523 else if (f->fmt.pix.height > MAX_H) 523 else if (f->fmt.pix.height > MAX_H)
@@ -531,6 +531,8 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct m2mtest_fmt *fmt)
531 f->fmt.pix.width &= ~DIM_ALIGN_MASK; 531 f->fmt.pix.width &= ~DIM_ALIGN_MASK;
532 f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3; 532 f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3;
533 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 533 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
534 f->fmt.pix.field = V4L2_FIELD_NONE;
535 f->fmt.pix.priv = 0;
534 536
535 return 0; 537 return 0;
536} 538}
@@ -542,7 +544,11 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
542 struct m2mtest_ctx *ctx = file2ctx(file); 544 struct m2mtest_ctx *ctx = file2ctx(file);
543 545
544 fmt = find_format(f); 546 fmt = find_format(f);
545 if (!fmt || !(fmt->types & MEM2MEM_CAPTURE)) { 547 if (!fmt) {
548 f->fmt.pix.pixelformat = formats[0].fourcc;
549 fmt = find_format(f);
550 }
551 if (!(fmt->types & MEM2MEM_CAPTURE)) {
546 v4l2_err(&ctx->dev->v4l2_dev, 552 v4l2_err(&ctx->dev->v4l2_dev,
547 "Fourcc format (0x%08x) invalid.\n", 553 "Fourcc format (0x%08x) invalid.\n",
548 f->fmt.pix.pixelformat); 554 f->fmt.pix.pixelformat);
@@ -560,7 +566,11 @@ static int vidioc_try_fmt_vid_out(struct file *file, void *priv,
560 struct m2mtest_ctx *ctx = file2ctx(file); 566 struct m2mtest_ctx *ctx = file2ctx(file);
561 567
562 fmt = find_format(f); 568 fmt = find_format(f);
563 if (!fmt || !(fmt->types & MEM2MEM_OUTPUT)) { 569 if (!fmt) {
570 f->fmt.pix.pixelformat = formats[0].fourcc;
571 fmt = find_format(f);
572 }
573 if (!(fmt->types & MEM2MEM_OUTPUT)) {
564 v4l2_err(&ctx->dev->v4l2_dev, 574 v4l2_err(&ctx->dev->v4l2_dev,
565 "Fourcc format (0x%08x) invalid.\n", 575 "Fourcc format (0x%08x) invalid.\n",
566 f->fmt.pix.pixelformat); 576 f->fmt.pix.pixelformat);
@@ -740,6 +750,15 @@ static int m2mtest_buf_prepare(struct vb2_buffer *vb)
740 dprintk(ctx->dev, "type: %d\n", vb->vb2_queue->type); 750 dprintk(ctx->dev, "type: %d\n", vb->vb2_queue->type);
741 751
742 q_data = get_q_data(ctx, vb->vb2_queue->type); 752 q_data = get_q_data(ctx, vb->vb2_queue->type);
753 if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) {
754 if (vb->v4l2_buf.field == V4L2_FIELD_ANY)
755 vb->v4l2_buf.field = V4L2_FIELD_NONE;
756 if (vb->v4l2_buf.field != V4L2_FIELD_NONE) {
757 dprintk(ctx->dev, "%s field isn't supported\n",
758 __func__);
759 return -EINVAL;
760 }
761 }
743 762
744 if (vb2_plane_size(vb, 0) < q_data->sizeimage) { 763 if (vb2_plane_size(vb, 0) < q_data->sizeimage) {
745 dprintk(ctx->dev, "%s data will not fit into plane (%lu < %lu)\n", 764 dprintk(ctx->dev, "%s data will not fit into plane (%lu < %lu)\n",
@@ -755,13 +774,45 @@ static int m2mtest_buf_prepare(struct vb2_buffer *vb)
755static void m2mtest_buf_queue(struct vb2_buffer *vb) 774static void m2mtest_buf_queue(struct vb2_buffer *vb)
756{ 775{
757 struct m2mtest_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); 776 struct m2mtest_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
777
758 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb); 778 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb);
759} 779}
760 780
781static int m2mtest_start_streaming(struct vb2_queue *q, unsigned count)
782{
783 struct m2mtest_ctx *ctx = vb2_get_drv_priv(q);
784 struct m2mtest_q_data *q_data = get_q_data(ctx, q->type);
785
786 q_data->sequence = 0;
787 return 0;
788}
789
790static int m2mtest_stop_streaming(struct vb2_queue *q)
791{
792 struct m2mtest_ctx *ctx = vb2_get_drv_priv(q);
793 struct vb2_buffer *vb;
794 unsigned long flags;
795
796 for (;;) {
797 if (V4L2_TYPE_IS_OUTPUT(q->type))
798 vb = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
799 else
800 vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
801 if (vb == NULL)
802 return 0;
803 spin_lock_irqsave(&ctx->dev->irqlock, flags);
804 v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR);
805 spin_unlock_irqrestore(&ctx->dev->irqlock, flags);
806 }
807 return 0;
808}
809
761static struct vb2_ops m2mtest_qops = { 810static struct vb2_ops m2mtest_qops = {
762 .queue_setup = m2mtest_queue_setup, 811 .queue_setup = m2mtest_queue_setup,
763 .buf_prepare = m2mtest_buf_prepare, 812 .buf_prepare = m2mtest_buf_prepare,
764 .buf_queue = m2mtest_buf_queue, 813 .buf_queue = m2mtest_buf_queue,
814 .start_streaming = m2mtest_start_streaming,
815 .stop_streaming = m2mtest_stop_streaming,
765 .wait_prepare = vb2_ops_wait_prepare, 816 .wait_prepare = vb2_ops_wait_prepare,
766 .wait_finish = vb2_ops_wait_finish, 817 .wait_finish = vb2_ops_wait_finish,
767}; 818};
@@ -772,12 +823,12 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds
772 int ret; 823 int ret;
773 824
774 src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; 825 src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
775 src_vq->io_modes = VB2_MMAP | VB2_DMABUF; 826 src_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
776 src_vq->drv_priv = ctx; 827 src_vq->drv_priv = ctx;
777 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 828 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
778 src_vq->ops = &m2mtest_qops; 829 src_vq->ops = &m2mtest_qops;
779 src_vq->mem_ops = &vb2_vmalloc_memops; 830 src_vq->mem_ops = &vb2_vmalloc_memops;
780 src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 831 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
781 src_vq->lock = &ctx->dev->dev_mutex; 832 src_vq->lock = &ctx->dev->dev_mutex;
782 833
783 ret = vb2_queue_init(src_vq); 834 ret = vb2_queue_init(src_vq);
@@ -785,12 +836,12 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *ds
785 return ret; 836 return ret;
786 837
787 dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 838 dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
788 dst_vq->io_modes = VB2_MMAP | VB2_DMABUF; 839 dst_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
789 dst_vq->drv_priv = ctx; 840 dst_vq->drv_priv = ctx;
790 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 841 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
791 dst_vq->ops = &m2mtest_qops; 842 dst_vq->ops = &m2mtest_qops;
792 dst_vq->mem_ops = &vb2_vmalloc_memops; 843 dst_vq->mem_ops = &vb2_vmalloc_memops;
793 dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 844 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
794 dst_vq->lock = &ctx->dev->dev_mutex; 845 dst_vq->lock = &ctx->dev->dev_mutex;
795 846
796 return vb2_queue_init(dst_vq); 847 return vb2_queue_init(dst_vq);
@@ -801,10 +852,10 @@ static const struct v4l2_ctrl_config m2mtest_ctrl_trans_time_msec = {
801 .id = V4L2_CID_TRANS_TIME_MSEC, 852 .id = V4L2_CID_TRANS_TIME_MSEC,
802 .name = "Transaction Time (msec)", 853 .name = "Transaction Time (msec)",
803 .type = V4L2_CTRL_TYPE_INTEGER, 854 .type = V4L2_CTRL_TYPE_INTEGER,
804 .def = 1001, 855 .def = MEM2MEM_DEF_TRANSTIME,
805 .min = 1, 856 .min = 1,
806 .max = 10001, 857 .max = 10001,
807 .step = 100, 858 .step = 1,
808}; 859};
809 860
810static const struct v4l2_ctrl_config m2mtest_ctrl_trans_num_bufs = { 861static const struct v4l2_ctrl_config m2mtest_ctrl_trans_num_bufs = {
diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
index c690435853bd..0b7480e82142 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -377,8 +377,13 @@ static irqreturn_t emmaprp_irq(int irq_emma, void *data)
377 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx); 377 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
378 dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx); 378 dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
379 379
380 src_vb->v4l2_buf.timestamp = dst_vb->v4l2_buf.timestamp; 380 dst_vb->v4l2_buf.timestamp = src_vb->v4l2_buf.timestamp;
381 src_vb->v4l2_buf.timecode = dst_vb->v4l2_buf.timecode; 381 dst_vb->v4l2_buf.flags &=
382 ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
383 dst_vb->v4l2_buf.flags |=
384 src_vb->v4l2_buf.flags
385 & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
386 dst_vb->v4l2_buf.timecode = src_vb->v4l2_buf.timecode;
382 387
383 spin_lock_irqsave(&pcdev->irqlock, flags); 388 spin_lock_irqsave(&pcdev->irqlock, flags);
384 v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE); 389 v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE);
@@ -766,7 +771,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
766 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 771 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
767 src_vq->ops = &emmaprp_qops; 772 src_vq->ops = &emmaprp_qops;
768 src_vq->mem_ops = &vb2_dma_contig_memops; 773 src_vq->mem_ops = &vb2_dma_contig_memops;
769 src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 774 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
770 775
771 ret = vb2_queue_init(src_vq); 776 ret = vb2_queue_init(src_vq);
772 if (ret) 777 if (ret)
@@ -778,7 +783,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
778 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 783 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
779 dst_vq->ops = &emmaprp_qops; 784 dst_vq->ops = &emmaprp_qops;
780 dst_vq->mem_ops = &vb2_dma_contig_memops; 785 dst_vq->mem_ops = &vb2_dma_contig_memops;
781 dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 786 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
782 787
783 return vb2_queue_init(dst_vq); 788 return vb2_queue_init(dst_vq);
784} 789}
diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
index dfd0a21a0658..9a726eacb29b 100644
--- a/drivers/media/platform/omap/omap_vout.c
+++ b/drivers/media/platform/omap/omap_vout.c
@@ -601,6 +601,7 @@ static void omap_vout_isr(void *arg, unsigned int irqstatus)
601 switch (cur_display->type) { 601 switch (cur_display->type) {
602 case OMAP_DISPLAY_TYPE_DSI: 602 case OMAP_DISPLAY_TYPE_DSI:
603 case OMAP_DISPLAY_TYPE_DPI: 603 case OMAP_DISPLAY_TYPE_DPI:
604 case OMAP_DISPLAY_TYPE_DVI:
604 if (mgr_id == OMAP_DSS_CHANNEL_LCD) 605 if (mgr_id == OMAP_DSS_CHANNEL_LCD)
605 irq = DISPC_IRQ_VSYNC; 606 irq = DISPC_IRQ_VSYNC;
606 else if (mgr_id == OMAP_DSS_CHANNEL_LCD2) 607 else if (mgr_id == OMAP_DSS_CHANNEL_LCD2)
diff --git a/drivers/media/platform/omap/omap_vout_vrfb.c b/drivers/media/platform/omap/omap_vout_vrfb.c
index cf1c437a8687..62e7e5783ce8 100644
--- a/drivers/media/platform/omap/omap_vout_vrfb.c
+++ b/drivers/media/platform/omap/omap_vout_vrfb.c
@@ -270,7 +270,8 @@ int omap_vout_prepare_vrfb(struct omap_vout_device *vout,
270 omap_dma_set_global_params(DMA_DEFAULT_ARB_RATE, 0x20, 0); 270 omap_dma_set_global_params(DMA_DEFAULT_ARB_RATE, 0x20, 0);
271 271
272 omap_start_dma(tx->dma_ch); 272 omap_start_dma(tx->dma_ch);
273 interruptible_sleep_on_timeout(&tx->wait, VRFB_TX_TIMEOUT); 273 wait_event_interruptible_timeout(tx->wait, tx->tx_status == 1,
274 VRFB_TX_TIMEOUT);
274 275
275 if (tx->tx_status == 0) { 276 if (tx->tx_status == 0) {
276 omap_stop_dma(tx->dma_ch); 277 omap_stop_dma(tx->dma_ch);
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 5807185262fe..06a0df434249 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -391,7 +391,7 @@ static void isp_disable_interrupts(struct isp_device *isp)
391 * @isp: OMAP3 ISP device 391 * @isp: OMAP3 ISP device
392 * @idle: Consider idle state. 392 * @idle: Consider idle state.
393 * 393 *
394 * Set the power settings for the ISP and SBL bus and cConfigure the HS/VS 394 * Set the power settings for the ISP and SBL bus and configure the HS/VS
395 * interrupt source. 395 * interrupt source.
396 * 396 *
397 * We need to configure the HS/VS interrupt source before interrupts get 397 * We need to configure the HS/VS interrupt source before interrupts get
@@ -588,9 +588,6 @@ static void isp_isr_sbl(struct isp_device *isp)
588 * @_isp: Pointer to the OMAP3 ISP device 588 * @_isp: Pointer to the OMAP3 ISP device
589 * 589 *
590 * Handles the corresponding callback if plugged in. 590 * Handles the corresponding callback if plugged in.
591 *
592 * Returns IRQ_HANDLED when IRQ was correctly handled, or IRQ_NONE when the
593 * IRQ wasn't handled.
594 */ 591 */
595static irqreturn_t isp_isr(int irq, void *_isp) 592static irqreturn_t isp_isr(int irq, void *_isp)
596{ 593{
@@ -1420,7 +1417,7 @@ int omap3isp_module_sync_idle(struct media_entity *me, wait_queue_head_t *wait,
1420} 1417}
1421 1418
1422/* 1419/*
1423 * omap3isp_module_sync_is_stopped - Helper to verify if module was stopping 1420 * omap3isp_module_sync_is_stopping - Helper to verify if module was stopping
1424 * @wait: ISP submodule's wait queue for streamoff/interrupt synchronization 1421 * @wait: ISP submodule's wait queue for streamoff/interrupt synchronization
1425 * @stopping: flag which tells module wants to stop 1422 * @stopping: flag which tells module wants to stop
1426 * 1423 *
diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h
index 081f5ec5a663..6d5e69711907 100644
--- a/drivers/media/platform/omap3isp/isp.h
+++ b/drivers/media/platform/omap3isp/isp.h
@@ -265,7 +265,7 @@ void omap3isp_unregister_entities(struct platform_device *pdev);
265 265
266/* 266/*
267 * isp_reg_readl - Read value of an OMAP3 ISP register 267 * isp_reg_readl - Read value of an OMAP3 ISP register
268 * @dev: Device pointer specific to the OMAP3 ISP. 268 * @isp: Device pointer specific to the OMAP3 ISP.
269 * @isp_mmio_range: Range to which the register offset refers to. 269 * @isp_mmio_range: Range to which the register offset refers to.
270 * @reg_offset: Register offset to read from. 270 * @reg_offset: Register offset to read from.
271 * 271 *
@@ -280,7 +280,7 @@ u32 isp_reg_readl(struct isp_device *isp, enum isp_mem_resources isp_mmio_range,
280 280
281/* 281/*
282 * isp_reg_writel - Write value to an OMAP3 ISP register 282 * isp_reg_writel - Write value to an OMAP3 ISP register
283 * @dev: Device pointer specific to the OMAP3 ISP. 283 * @isp: Device pointer specific to the OMAP3 ISP.
284 * @reg_value: 32 bit value to write to the register. 284 * @reg_value: 32 bit value to write to the register.
285 * @isp_mmio_range: Range to which the register offset refers to. 285 * @isp_mmio_range: Range to which the register offset refers to.
286 * @reg_offset: Register offset to write into. 286 * @reg_offset: Register offset to write into.
@@ -293,8 +293,8 @@ void isp_reg_writel(struct isp_device *isp, u32 reg_value,
293} 293}
294 294
295/* 295/*
296 * isp_reg_and - Clear individual bits in an OMAP3 ISP register 296 * isp_reg_clr - Clear individual bits in an OMAP3 ISP register
297 * @dev: Device pointer specific to the OMAP3 ISP. 297 * @isp: Device pointer specific to the OMAP3 ISP.
298 * @mmio_range: Range to which the register offset refers to. 298 * @mmio_range: Range to which the register offset refers to.
299 * @reg: Register offset to work on. 299 * @reg: Register offset to work on.
300 * @clr_bits: 32 bit value which would be cleared in the register. 300 * @clr_bits: 32 bit value which would be cleared in the register.
@@ -310,7 +310,7 @@ void isp_reg_clr(struct isp_device *isp, enum isp_mem_resources mmio_range,
310 310
311/* 311/*
312 * isp_reg_set - Set individual bits in an OMAP3 ISP register 312 * isp_reg_set - Set individual bits in an OMAP3 ISP register
313 * @dev: Device pointer specific to the OMAP3 ISP. 313 * @isp: Device pointer specific to the OMAP3 ISP.
314 * @mmio_range: Range to which the register offset refers to. 314 * @mmio_range: Range to which the register offset refers to.
315 * @reg: Register offset to work on. 315 * @reg: Register offset to work on.
316 * @set_bits: 32 bit value which would be set in the register. 316 * @set_bits: 32 bit value which would be set in the register.
@@ -326,7 +326,7 @@ void isp_reg_set(struct isp_device *isp, enum isp_mem_resources mmio_range,
326 326
327/* 327/*
328 * isp_reg_clr_set - Clear and set invidial bits in an OMAP3 ISP register 328 * isp_reg_clr_set - Clear and set invidial bits in an OMAP3 ISP register
329 * @dev: Device pointer specific to the OMAP3 ISP. 329 * @isp: Device pointer specific to the OMAP3 ISP.
330 * @mmio_range: Range to which the register offset refers to. 330 * @mmio_range: Range to which the register offset refers to.
331 * @reg: Register offset to work on. 331 * @reg: Register offset to work on.
332 * @clr_bits: 32 bit value which would be cleared in the register. 332 * @clr_bits: 32 bit value which would be cleared in the register.
diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c
index 5db2c88b9ad8..4d920c800ff5 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -293,7 +293,7 @@ static int __ccdc_lsc_enable(struct isp_ccdc_device *ccdc, int enable)
293 isp_reg_clr(isp, OMAP3_ISP_IOMEM_CCDC, 293 isp_reg_clr(isp, OMAP3_ISP_IOMEM_CCDC,
294 ISPCCDC_LSC_CONFIG, ISPCCDC_LSC_ENABLE); 294 ISPCCDC_LSC_CONFIG, ISPCCDC_LSC_ENABLE);
295 ccdc->lsc.state = LSC_STATE_STOPPED; 295 ccdc->lsc.state = LSC_STATE_STOPPED;
296 dev_warn(to_device(ccdc), "LSC prefecth timeout\n"); 296 dev_warn(to_device(ccdc), "LSC prefetch timeout\n");
297 return -ETIMEDOUT; 297 return -ETIMEDOUT;
298 } 298 }
299 ccdc->lsc.state = LSC_STATE_RUNNING; 299 ccdc->lsc.state = LSC_STATE_RUNNING;
@@ -674,7 +674,7 @@ static void ccdc_config_imgattr(struct isp_ccdc_device *ccdc, u32 colptn)
674/* 674/*
675 * ccdc_config - Set CCDC configuration from userspace 675 * ccdc_config - Set CCDC configuration from userspace
676 * @ccdc: Pointer to ISP CCDC device. 676 * @ccdc: Pointer to ISP CCDC device.
677 * @userspace_add: Structure containing CCDC configuration sent from userspace. 677 * @ccdc_struct: Structure containing CCDC configuration sent from userspace.
678 * 678 *
679 * Returns 0 if successful, -EINVAL if the pointer to the configuration 679 * Returns 0 if successful, -EINVAL if the pointer to the configuration
680 * structure is null, or the copy_from_user function fails to copy user space 680 * structure is null, or the copy_from_user function fails to copy user space
@@ -793,7 +793,7 @@ static void ccdc_apply_controls(struct isp_ccdc_device *ccdc)
793 793
794/* 794/*
795 * omap3isp_ccdc_restore_context - Restore values of the CCDC module registers 795 * omap3isp_ccdc_restore_context - Restore values of the CCDC module registers
796 * @dev: Pointer to ISP device 796 * @isp: Pointer to ISP device
797 */ 797 */
798void omap3isp_ccdc_restore_context(struct isp_device *isp) 798void omap3isp_ccdc_restore_context(struct isp_device *isp)
799{ 799{
@@ -2525,7 +2525,7 @@ error_video:
2525 2525
2526/* 2526/*
2527 * omap3isp_ccdc_init - CCDC module initialization. 2527 * omap3isp_ccdc_init - CCDC module initialization.
2528 * @dev: Device pointer specific to the OMAP3 ISP. 2528 * @isp: Device pointer specific to the OMAP3 ISP.
2529 * 2529 *
2530 * TODO: Get the initialisation values from platform data. 2530 * TODO: Get the initialisation values from platform data.
2531 * 2531 *
@@ -2564,7 +2564,7 @@ int omap3isp_ccdc_init(struct isp_device *isp)
2564 2564
2565/* 2565/*
2566 * omap3isp_ccdc_cleanup - CCDC module cleanup. 2566 * omap3isp_ccdc_cleanup - CCDC module cleanup.
2567 * @dev: Device pointer specific to the OMAP3 ISP. 2567 * @isp: Device pointer specific to the OMAP3 ISP.
2568 */ 2568 */
2569void omap3isp_ccdc_cleanup(struct isp_device *isp) 2569void omap3isp_ccdc_cleanup(struct isp_device *isp)
2570{ 2570{
diff --git a/drivers/media/platform/omap3isp/ispccdc.h b/drivers/media/platform/omap3isp/ispccdc.h
index a5da9e19edbf..9d24e4107864 100644
--- a/drivers/media/platform/omap3isp/ispccdc.h
+++ b/drivers/media/platform/omap3isp/ispccdc.h
@@ -63,12 +63,6 @@ struct ispccdc_lsc_config_req {
63 63
64/* 64/*
65 * ispccdc_lsc - CCDC LSC parameters 65 * ispccdc_lsc - CCDC LSC parameters
66 * @update_config: Set when user changes config
67 * @request_enable: Whether LSC is requested to be enabled
68 * @config: LSC config set by user
69 * @update_table: Set when user provides a new LSC table to table_new
70 * @table_new: LSC table set by user, ISP address
71 * @table_inuse: LSC table currently in use, ISP address
72 */ 66 */
73struct ispccdc_lsc { 67struct ispccdc_lsc {
74 enum ispccdc_lsc_state state; 68 enum ispccdc_lsc_state state;
diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c
index e84fe0543e47..b30b67d22a58 100644
--- a/drivers/media/platform/omap3isp/ispccp2.c
+++ b/drivers/media/platform/omap3isp/ispccp2.c
@@ -211,7 +211,7 @@ static void ccp2_mem_enable(struct isp_ccp2_device *ccp2, u8 enable)
211/* 211/*
212 * ccp2_phyif_config - Initialize CCP2 phy interface config 212 * ccp2_phyif_config - Initialize CCP2 phy interface config
213 * @ccp2: Pointer to ISP CCP2 device 213 * @ccp2: Pointer to ISP CCP2 device
214 * @config: CCP2 platform data 214 * @pdata: CCP2 platform data
215 * 215 *
216 * Configure the CCP2 physical interface module from platform data. 216 * Configure the CCP2 physical interface module from platform data.
217 * 217 *
@@ -518,7 +518,7 @@ static void ccp2_mem_configure(struct isp_ccp2_device *ccp2,
518 ISPCCP2_LCM_IRQSTATUS_EOF_IRQ, 518 ISPCCP2_LCM_IRQSTATUS_EOF_IRQ,
519 OMAP3_ISP_IOMEM_CCP2, ISPCCP2_LCM_IRQSTATUS); 519 OMAP3_ISP_IOMEM_CCP2, ISPCCP2_LCM_IRQSTATUS);
520 520
521 /* Enable LCM interupts */ 521 /* Enable LCM interrupts */
522 isp_reg_set(isp, OMAP3_ISP_IOMEM_CCP2, ISPCCP2_LCM_IRQENABLE, 522 isp_reg_set(isp, OMAP3_ISP_IOMEM_CCP2, ISPCCP2_LCM_IRQENABLE,
523 ISPCCP2_LCM_IRQSTATUS_EOF_IRQ | 523 ISPCCP2_LCM_IRQSTATUS_EOF_IRQ |
524 ISPCCP2_LCM_IRQSTATUS_OCPERROR_IRQ); 524 ISPCCP2_LCM_IRQSTATUS_OCPERROR_IRQ);
@@ -1096,7 +1096,7 @@ static int ccp2_init_entities(struct isp_ccp2_device *ccp2)
1096 * implementation we use a fixed 32 bytes alignment regardless of the 1096 * implementation we use a fixed 32 bytes alignment regardless of the
1097 * input format and width. If strict 128 bits alignment support is 1097 * input format and width. If strict 128 bits alignment support is
1098 * required ispvideo will need to be made aware of this special dual 1098 * required ispvideo will need to be made aware of this special dual
1099 * alignement requirements. 1099 * alignment requirements.
1100 */ 1100 */
1101 ccp2->video_in.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; 1101 ccp2->video_in.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
1102 ccp2->video_in.bpl_alignment = 32; 1102 ccp2->video_in.bpl_alignment = 32;
diff --git a/drivers/media/platform/omap3isp/isphist.c b/drivers/media/platform/omap3isp/isphist.c
index e070c24048ef..06a5f8164eaa 100644
--- a/drivers/media/platform/omap3isp/isphist.c
+++ b/drivers/media/platform/omap3isp/isphist.c
@@ -299,7 +299,7 @@ static u32 hist_get_buf_size(struct omap3isp_hist_config *conf)
299 299
300/* 300/*
301 * hist_validate_params - Helper function to check user given params. 301 * hist_validate_params - Helper function to check user given params.
302 * @user_cfg: Pointer to user configuration structure. 302 * @new_conf: Pointer to user configuration structure.
303 * 303 *
304 * Returns 0 on success configuration. 304 * Returns 0 on success configuration.
305 */ 305 */
@@ -351,7 +351,7 @@ static int hist_validate_params(struct ispstat *hist, void *new_conf)
351 351
352 buf_size = hist_get_buf_size(user_cfg); 352 buf_size = hist_get_buf_size(user_cfg);
353 if (buf_size > user_cfg->buf_size) 353 if (buf_size > user_cfg->buf_size)
354 /* User's buf_size request wasn't enoght */ 354 /* User's buf_size request wasn't enough */
355 user_cfg->buf_size = buf_size; 355 user_cfg->buf_size = buf_size;
356 else if (user_cfg->buf_size > OMAP3ISP_HIST_MAX_BUF_SIZE) 356 else if (user_cfg->buf_size > OMAP3ISP_HIST_MAX_BUF_SIZE)
357 user_cfg->buf_size = OMAP3ISP_HIST_MAX_BUF_SIZE; 357 user_cfg->buf_size = OMAP3ISP_HIST_MAX_BUF_SIZE;
diff --git a/drivers/media/platform/omap3isp/isppreview.c b/drivers/media/platform/omap3isp/isppreview.c
index 1c776c1186f1..395b2b068c75 100644
--- a/drivers/media/platform/omap3isp/isppreview.c
+++ b/drivers/media/platform/omap3isp/isppreview.c
@@ -122,7 +122,7 @@ static struct omap3isp_prev_csc flr_prev_csc = {
122#define PREV_MAX_OUT_WIDTH_REV_15 4096 122#define PREV_MAX_OUT_WIDTH_REV_15 4096
123 123
124/* 124/*
125 * Coeficient Tables for the submodules in Preview. 125 * Coefficient Tables for the submodules in Preview.
126 * Array is initialised with the values from.the tables text file. 126 * Array is initialised with the values from.the tables text file.
127 */ 127 */
128 128
@@ -971,7 +971,8 @@ static void preview_setup_hw(struct isp_prev_device *prev, u32 update,
971 971
972/* 972/*
973 * preview_config_ycpos - Configure byte layout of YUV image. 973 * preview_config_ycpos - Configure byte layout of YUV image.
974 * @mode: Indicates the required byte layout. 974 * @prev: pointer to previewer private structure
975 * @pixelcode: pixel code
975 */ 976 */
976static void 977static void
977preview_config_ycpos(struct isp_prev_device *prev, 978preview_config_ycpos(struct isp_prev_device *prev,
@@ -1079,6 +1080,7 @@ static void preview_config_input_format(struct isp_prev_device *prev,
1079 */ 1080 */
1080static void preview_config_input_size(struct isp_prev_device *prev, u32 active) 1081static void preview_config_input_size(struct isp_prev_device *prev, u32 active)
1081{ 1082{
1083 const struct v4l2_mbus_framefmt *format = &prev->formats[PREV_PAD_SINK];
1082 struct isp_device *isp = to_isp_device(prev); 1084 struct isp_device *isp = to_isp_device(prev);
1083 unsigned int sph = prev->crop.left; 1085 unsigned int sph = prev->crop.left;
1084 unsigned int eph = prev->crop.left + prev->crop.width - 1; 1086 unsigned int eph = prev->crop.left + prev->crop.width - 1;
@@ -1086,6 +1088,14 @@ static void preview_config_input_size(struct isp_prev_device *prev, u32 active)
1086 unsigned int elv = prev->crop.top + prev->crop.height - 1; 1088 unsigned int elv = prev->crop.top + prev->crop.height - 1;
1087 u32 features; 1089 u32 features;
1088 1090
1091 if (format->code != V4L2_MBUS_FMT_Y8_1X8 &&
1092 format->code != V4L2_MBUS_FMT_Y10_1X10) {
1093 sph -= 2;
1094 eph += 2;
1095 slv -= 2;
1096 elv += 2;
1097 }
1098
1089 features = (prev->params.params[0].features & active) 1099 features = (prev->params.params[0].features & active)
1090 | (prev->params.params[1].features & ~active); 1100 | (prev->params.params[1].features & ~active);
1091 1101
@@ -1363,8 +1373,8 @@ static void preview_init_params(struct isp_prev_device *prev)
1363} 1373}
1364 1374
1365/* 1375/*
1366 * preview_max_out_width - Handle previewer hardware ouput limitations 1376 * preview_max_out_width - Handle previewer hardware output limitations
1367 * @isp_revision : ISP revision 1377 * @prev: pointer to previewer private structure
1368 * returns maximum width output for current isp revision 1378 * returns maximum width output for current isp revision
1369 */ 1379 */
1370static unsigned int preview_max_out_width(struct isp_prev_device *prev) 1380static unsigned int preview_max_out_width(struct isp_prev_device *prev)
@@ -1610,7 +1620,7 @@ static const struct v4l2_ctrl_ops preview_ctrl_ops = {
1610 1620
1611/* 1621/*
1612 * preview_ioctl - Handle preview module private ioctl's 1622 * preview_ioctl - Handle preview module private ioctl's
1613 * @prev: pointer to preview context structure 1623 * @sd: pointer to v4l2 subdev structure
1614 * @cmd: configuration command 1624 * @cmd: configuration command
1615 * @arg: configuration argument 1625 * @arg: configuration argument
1616 * return -EINVAL or zero on success 1626 * return -EINVAL or zero on success
@@ -2341,7 +2351,7 @@ error_video_in:
2341 2351
2342/* 2352/*
2343 * omap3isp_preview_init - Previewer initialization. 2353 * omap3isp_preview_init - Previewer initialization.
2344 * @dev : Pointer to ISP device 2354 * @isp : Pointer to ISP device
2345 * return -ENOMEM or zero on success 2355 * return -ENOMEM or zero on success
2346 */ 2356 */
2347int omap3isp_preview_init(struct isp_device *isp) 2357int omap3isp_preview_init(struct isp_device *isp)
diff --git a/drivers/media/platform/omap3isp/ispqueue.c b/drivers/media/platform/omap3isp/ispqueue.c
index 5f0f8fab1d17..a5e65858e799 100644
--- a/drivers/media/platform/omap3isp/ispqueue.c
+++ b/drivers/media/platform/omap3isp/ispqueue.c
@@ -597,7 +597,7 @@ static int isp_video_buffer_wait(struct isp_video_buffer *buf, int nonblocking)
597 * isp_video_queue_free - Free video buffers memory 597 * isp_video_queue_free - Free video buffers memory
598 * 598 *
599 * Buffers can only be freed if the queue isn't streaming and if no buffer is 599 * Buffers can only be freed if the queue isn't streaming and if no buffer is
600 * mapped to userspace. Return -EBUSY if those conditions aren't statisfied. 600 * mapped to userspace. Return -EBUSY if those conditions aren't satisfied.
601 * 601 *
602 * This function must be called with the queue lock held. 602 * This function must be called with the queue lock held.
603 */ 603 */
diff --git a/drivers/media/platform/omap3isp/ispresizer.c b/drivers/media/platform/omap3isp/ispresizer.c
index 0d36b8bc9f98..86369df81d74 100644
--- a/drivers/media/platform/omap3isp/ispresizer.c
+++ b/drivers/media/platform/omap3isp/ispresizer.c
@@ -206,7 +206,7 @@ static void resizer_set_bilinear(struct isp_res_device *res,
206/* 206/*
207 * resizer_set_ycpos - Luminance and chrominance order 207 * resizer_set_ycpos - Luminance and chrominance order
208 * @res: Device context. 208 * @res: Device context.
209 * @order: order type. 209 * @pixelcode: pixel code.
210 */ 210 */
211static void resizer_set_ycpos(struct isp_res_device *res, 211static void resizer_set_ycpos(struct isp_res_device *res,
212 enum v4l2_mbus_pixelcode pixelcode) 212 enum v4l2_mbus_pixelcode pixelcode)
@@ -918,8 +918,8 @@ static void resizer_calc_ratios(struct isp_res_device *res,
918/* 918/*
919 * resizer_set_crop_params - Setup hardware with cropping parameters 919 * resizer_set_crop_params - Setup hardware with cropping parameters
920 * @res : resizer private structure 920 * @res : resizer private structure
921 * @crop_rect : current crop rectangle 921 * @input : format on sink pad
922 * @ratio : resizer ratios 922 * @output : format on source pad
923 * return none 923 * return none
924 */ 924 */
925static void resizer_set_crop_params(struct isp_res_device *res, 925static void resizer_set_crop_params(struct isp_res_device *res,
diff --git a/drivers/media/platform/omap3isp/ispresizer.h b/drivers/media/platform/omap3isp/ispresizer.h
index 70c1c0e1bbdf..9b01e9047c15 100644
--- a/drivers/media/platform/omap3isp/ispresizer.h
+++ b/drivers/media/platform/omap3isp/ispresizer.h
@@ -30,12 +30,12 @@
30#include <linux/types.h> 30#include <linux/types.h>
31 31
32/* 32/*
33 * Constants for filter coefficents count 33 * Constants for filter coefficients count
34 */ 34 */
35#define COEFF_CNT 32 35#define COEFF_CNT 32
36 36
37/* 37/*
38 * struct isprsz_coef - Structure for resizer filter coeffcients. 38 * struct isprsz_coef - Structure for resizer filter coefficients.
39 * @h_filter_coef_4tap: Horizontal filter coefficients for 8-phase/4-tap 39 * @h_filter_coef_4tap: Horizontal filter coefficients for 8-phase/4-tap
40 * mode (.5x-4x) 40 * mode (.5x-4x)
41 * @v_filter_coef_4tap: Vertical filter coefficients for 8-phase/4-tap 41 * @v_filter_coef_4tap: Vertical filter coefficients for 8-phase/4-tap
diff --git a/drivers/media/platform/omap3isp/ispstat.c b/drivers/media/platform/omap3isp/ispstat.c
index a75407c3a726..5707f85c4cc4 100644
--- a/drivers/media/platform/omap3isp/ispstat.c
+++ b/drivers/media/platform/omap3isp/ispstat.c
@@ -144,7 +144,7 @@ static int isp_stat_buf_check_magic(struct ispstat *stat,
144 for (w = buf->virt_addr + buf_size, end = w + MAGIC_SIZE; 144 for (w = buf->virt_addr + buf_size, end = w + MAGIC_SIZE;
145 w < end; w++) { 145 w < end; w++) {
146 if (unlikely(*w != MAGIC_NUM)) { 146 if (unlikely(*w != MAGIC_NUM)) {
147 dev_dbg(stat->isp->dev, "%s: endding magic check does " 147 dev_dbg(stat->isp->dev, "%s: ending magic check does "
148 "not match.\n", stat->subdev.name); 148 "not match.\n", stat->subdev.name);
149 return -EINVAL; 149 return -EINVAL;
150 } 150 }
@@ -841,7 +841,7 @@ int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable)
841 if (enable) { 841 if (enable) {
842 /* 842 /*
843 * Only set enable PCR bit if the module was previously 843 * Only set enable PCR bit if the module was previously
844 * enabled through ioct. 844 * enabled through ioctl.
845 */ 845 */
846 isp_stat_try_enable(stat); 846 isp_stat_try_enable(stat);
847 } else { 847 } else {
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index 856fdf554035..85b4036ba5e4 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -333,7 +333,7 @@ isp_video_check_format(struct isp_video *video, struct isp_video_fh *vfh)
333 333
334/* 334/*
335 * ispmmu_vmap - Wrapper for Virtual memory mapping of a scatter gather list 335 * ispmmu_vmap - Wrapper for Virtual memory mapping of a scatter gather list
336 * @dev: Device pointer specific to the OMAP3 ISP. 336 * @isp: Device pointer specific to the OMAP3 ISP.
337 * @sglist: Pointer to source Scatter gather list to allocate. 337 * @sglist: Pointer to source Scatter gather list to allocate.
338 * @sglen: Number of elements of the scatter-gatter list. 338 * @sglen: Number of elements of the scatter-gatter list.
339 * 339 *
@@ -363,7 +363,7 @@ ispmmu_vmap(struct isp_device *isp, const struct scatterlist *sglist, int sglen)
363 363
364/* 364/*
365 * ispmmu_vunmap - Unmap a device address from the ISP MMU 365 * ispmmu_vunmap - Unmap a device address from the ISP MMU
366 * @dev: Device pointer specific to the OMAP3 ISP. 366 * @isp: Device pointer specific to the OMAP3 ISP.
367 * @da: Device address generated from a ispmmu_vmap call. 367 * @da: Device address generated from a ispmmu_vmap call.
368 */ 368 */
369static void ispmmu_vunmap(struct isp_device *isp, dma_addr_t da) 369static void ispmmu_vunmap(struct isp_device *isp, dma_addr_t da)
@@ -886,7 +886,11 @@ static int isp_video_check_external_subdevs(struct isp_video *video,
886 struct v4l2_ext_controls ctrls; 886 struct v4l2_ext_controls ctrls;
887 struct v4l2_ext_control ctrl; 887 struct v4l2_ext_control ctrl;
888 unsigned int i; 888 unsigned int i;
889 int ret = 0; 889 int ret;
890
891 /* Memory-to-memory pipelines have no external subdev. */
892 if (pipe->input != NULL)
893 return 0;
890 894
891 for (i = 0; i < ARRAY_SIZE(ents); i++) { 895 for (i = 0; i < ARRAY_SIZE(ents); i++) {
892 /* Is the entity part of the pipeline? */ 896 /* Is the entity part of the pipeline? */
@@ -905,7 +909,7 @@ static int isp_video_check_external_subdevs(struct isp_video *video,
905 909
906 if (!source) { 910 if (!source) {
907 dev_warn(isp->dev, "can't find source, failing now\n"); 911 dev_warn(isp->dev, "can't find source, failing now\n");
908 return ret; 912 return -EINVAL;
909 } 913 }
910 914
911 if (media_entity_type(source) != MEDIA_ENT_T_V4L2_SUBDEV) 915 if (media_entity_type(source) != MEDIA_ENT_T_V4L2_SUBDEV)
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
index 40b298ab87f1..4e4d1631e042 100644
--- a/drivers/media/platform/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -1160,7 +1160,7 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx)
1160 q->mem_ops = &vb2_dma_contig_memops; 1160 q->mem_ops = &vb2_dma_contig_memops;
1161 q->buf_struct_size = sizeof(struct camif_buffer); 1161 q->buf_struct_size = sizeof(struct camif_buffer);
1162 q->drv_priv = vp; 1162 q->drv_priv = vp;
1163 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1163 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1164 1164
1165 ret = vb2_queue_init(q); 1165 ret = vb2_queue_init(q);
1166 if (ret) 1166 if (ret)
@@ -1592,26 +1592,27 @@ int s3c_camif_create_subdev(struct camif_dev *camif)
1592 ARRAY_SIZE(s3c_camif_test_pattern_menu) - 1, 0, 0, 1592 ARRAY_SIZE(s3c_camif_test_pattern_menu) - 1, 0, 0,
1593 s3c_camif_test_pattern_menu); 1593 s3c_camif_test_pattern_menu);
1594 1594
1595 camif->ctrl_colorfx = v4l2_ctrl_new_std_menu(handler, 1595 if (camif->variant->has_img_effect) {
1596 camif->ctrl_colorfx = v4l2_ctrl_new_std_menu(handler,
1596 &s3c_camif_subdev_ctrl_ops, 1597 &s3c_camif_subdev_ctrl_ops,
1597 V4L2_CID_COLORFX, V4L2_COLORFX_SET_CBCR, 1598 V4L2_CID_COLORFX, V4L2_COLORFX_SET_CBCR,
1598 ~0x981f, V4L2_COLORFX_NONE); 1599 ~0x981f, V4L2_COLORFX_NONE);
1599 1600
1600 camif->ctrl_colorfx_cbcr = v4l2_ctrl_new_std(handler, 1601 camif->ctrl_colorfx_cbcr = v4l2_ctrl_new_std(handler,
1601 &s3c_camif_subdev_ctrl_ops, 1602 &s3c_camif_subdev_ctrl_ops,
1602 V4L2_CID_COLORFX_CBCR, 0, 0xffff, 1, 0); 1603 V4L2_CID_COLORFX_CBCR, 0, 0xffff, 1, 0);
1604 }
1605
1603 if (handler->error) { 1606 if (handler->error) {
1604 v4l2_ctrl_handler_free(handler); 1607 v4l2_ctrl_handler_free(handler);
1605 media_entity_cleanup(&sd->entity); 1608 media_entity_cleanup(&sd->entity);
1606 return handler->error; 1609 return handler->error;
1607 } 1610 }
1608 1611
1609 v4l2_ctrl_auto_cluster(2, &camif->ctrl_colorfx, 1612 if (camif->variant->has_img_effect)
1613 v4l2_ctrl_auto_cluster(2, &camif->ctrl_colorfx,
1610 V4L2_COLORFX_SET_CBCR, false); 1614 V4L2_COLORFX_SET_CBCR, false);
1611 if (!camif->variant->has_img_effect) { 1615
1612 camif->ctrl_colorfx->flags |= V4L2_CTRL_FLAG_DISABLED;
1613 camif->ctrl_colorfx_cbcr->flags |= V4L2_CTRL_FLAG_DISABLED;
1614 }
1615 sd->ctrl_handler = handler; 1616 sd->ctrl_handler = handler;
1616 v4l2_set_subdevdata(sd, camif); 1617 v4l2_set_subdevdata(sd, camif);
1617 1618
diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
index 0fcf7d75e841..357af1ebaeda 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -157,7 +157,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
157 src_vq->ops = &g2d_qops; 157 src_vq->ops = &g2d_qops;
158 src_vq->mem_ops = &vb2_dma_contig_memops; 158 src_vq->mem_ops = &vb2_dma_contig_memops;
159 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 159 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
160 src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 160 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
161 src_vq->lock = &ctx->dev->mutex; 161 src_vq->lock = &ctx->dev->mutex;
162 162
163 ret = vb2_queue_init(src_vq); 163 ret = vb2_queue_init(src_vq);
@@ -170,7 +170,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
170 dst_vq->ops = &g2d_qops; 170 dst_vq->ops = &g2d_qops;
171 dst_vq->mem_ops = &vb2_dma_contig_memops; 171 dst_vq->mem_ops = &vb2_dma_contig_memops;
172 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 172 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
173 dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 173 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
174 dst_vq->lock = &ctx->dev->mutex; 174 dst_vq->lock = &ctx->dev->mutex;
175 175
176 return vb2_queue_init(dst_vq); 176 return vb2_queue_init(dst_vq);
@@ -560,6 +560,9 @@ static irqreturn_t g2d_isr(int irq, void *prv)
560 560
561 dst->v4l2_buf.timecode = src->v4l2_buf.timecode; 561 dst->v4l2_buf.timecode = src->v4l2_buf.timecode;
562 dst->v4l2_buf.timestamp = src->v4l2_buf.timestamp; 562 dst->v4l2_buf.timestamp = src->v4l2_buf.timestamp;
563 dst->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
564 dst->v4l2_buf.flags |=
565 src->v4l2_buf.flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
563 566
564 v4l2_m2m_buf_done(src, VB2_BUF_STATE_DONE); 567 v4l2_m2m_buf_done(src, VB2_BUF_STATE_DONE);
565 v4l2_m2m_buf_done(dst, VB2_BUF_STATE_DONE); 568 v4l2_m2m_buf_done(dst, VB2_BUF_STATE_DONE);
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index 7d68d0b9966a..8a18972012f7 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -1701,7 +1701,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
1701 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 1701 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
1702 src_vq->ops = &s5p_jpeg_qops; 1702 src_vq->ops = &s5p_jpeg_qops;
1703 src_vq->mem_ops = &vb2_dma_contig_memops; 1703 src_vq->mem_ops = &vb2_dma_contig_memops;
1704 src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 1704 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
1705 src_vq->lock = &ctx->jpeg->lock; 1705 src_vq->lock = &ctx->jpeg->lock;
1706 1706
1707 ret = vb2_queue_init(src_vq); 1707 ret = vb2_queue_init(src_vq);
@@ -1714,7 +1714,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
1714 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 1714 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
1715 dst_vq->ops = &s5p_jpeg_qops; 1715 dst_vq->ops = &s5p_jpeg_qops;
1716 dst_vq->mem_ops = &vb2_dma_contig_memops; 1716 dst_vq->mem_ops = &vb2_dma_contig_memops;
1717 dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 1717 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
1718 dst_vq->lock = &ctx->jpeg->lock; 1718 dst_vq->lock = &ctx->jpeg->lock;
1719 1719
1720 return vb2_queue_init(dst_vq); 1720 return vb2_queue_init(dst_vq);
@@ -1766,6 +1766,9 @@ static irqreturn_t s5p_jpeg_irq(int irq, void *dev_id)
1766 1766
1767 dst_buf->v4l2_buf.timecode = src_buf->v4l2_buf.timecode; 1767 dst_buf->v4l2_buf.timecode = src_buf->v4l2_buf.timecode;
1768 dst_buf->v4l2_buf.timestamp = src_buf->v4l2_buf.timestamp; 1768 dst_buf->v4l2_buf.timestamp = src_buf->v4l2_buf.timestamp;
1769 dst_buf->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1770 dst_buf->v4l2_buf.flags |=
1771 src_buf->v4l2_buf.flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1769 1772
1770 v4l2_m2m_buf_done(src_buf, state); 1773 v4l2_m2m_buf_done(src_buf, state);
1771 if (curr_ctx->mode == S5P_JPEG_ENCODE) 1774 if (curr_ctx->mode == S5P_JPEG_ENCODE)
diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
index 2398cdf61341..8d0b686d9adb 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc-v6.h
@@ -229,6 +229,7 @@
229#define S5P_FIMV_E_PADDING_CTRL_V6 0xf7a4 229#define S5P_FIMV_E_PADDING_CTRL_V6 0xf7a4
230#define S5P_FIMV_E_MV_HOR_RANGE_V6 0xf7ac 230#define S5P_FIMV_E_MV_HOR_RANGE_V6 0xf7ac
231#define S5P_FIMV_E_MV_VER_RANGE_V6 0xf7b0 231#define S5P_FIMV_E_MV_VER_RANGE_V6 0xf7b0
232#define S5P_FIMV_E_MV_RANGE_V6_MASK 0x3fff
232 233
233#define S5P_FIMV_E_VBV_BUFFER_SIZE_V6 0xf84c 234#define S5P_FIMV_E_VBV_BUFFER_SIZE_V6 0xf84c
234#define S5P_FIMV_E_VBV_INIT_DELAY_V6 0xf850 235#define S5P_FIMV_E_VBV_INIT_DELAY_V6 0xf850
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index e2aac592d29f..89356ae90238 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -232,6 +232,11 @@ static void s5p_mfc_handle_frame_copy_time(struct s5p_mfc_ctx *ctx)
232 src_buf->b->v4l2_buf.timecode; 232 src_buf->b->v4l2_buf.timecode;
233 dst_buf->b->v4l2_buf.timestamp = 233 dst_buf->b->v4l2_buf.timestamp =
234 src_buf->b->v4l2_buf.timestamp; 234 src_buf->b->v4l2_buf.timestamp;
235 dst_buf->b->v4l2_buf.flags &=
236 ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
237 dst_buf->b->v4l2_buf.flags |=
238 src_buf->b->v4l2_buf.flags
239 & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
235 switch (frame_type) { 240 switch (frame_type) {
236 case S5P_FIMV_DECODE_FRAME_I_FRAME: 241 case S5P_FIMV_DECODE_FRAME_I_FRAME:
237 dst_buf->b->v4l2_buf.flags |= 242 dst_buf->b->v4l2_buf.flags |=
@@ -794,7 +799,7 @@ static int s5p_mfc_open(struct file *file)
794 goto err_queue_init; 799 goto err_queue_init;
795 } 800 }
796 q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops; 801 q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops;
797 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 802 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
798 ret = vb2_queue_init(q); 803 ret = vb2_queue_init(q);
799 if (ret) { 804 if (ret) {
800 mfc_err("Failed to initialize videobuf2 queue(capture)\n"); 805 mfc_err("Failed to initialize videobuf2 queue(capture)\n");
@@ -816,7 +821,7 @@ static int s5p_mfc_open(struct file *file)
816 goto err_queue_init; 821 goto err_queue_init;
817 } 822 }
818 q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops; 823 q->mem_ops = (struct vb2_mem_ops *)&vb2_dma_contig_memops;
819 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 824 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
820 ret = vb2_queue_init(q); 825 ret = vb2_queue_init(q);
821 if (ret) { 826 if (ret) {
822 mfc_err("Failed to initialize videobuf2 queue(output)\n"); 827 mfc_err("Failed to initialize videobuf2 queue(output)\n");
@@ -1147,9 +1152,9 @@ static int s5p_mfc_probe(struct platform_device *pdev)
1147 ret = -ENOMEM; 1152 ret = -ENOMEM;
1148 goto err_dec_alloc; 1153 goto err_dec_alloc;
1149 } 1154 }
1150 vfd->fops = &s5p_mfc_fops, 1155 vfd->fops = &s5p_mfc_fops;
1151 vfd->ioctl_ops = get_dec_v4l2_ioctl_ops(); 1156 vfd->ioctl_ops = get_dec_v4l2_ioctl_ops();
1152 vfd->release = video_device_release, 1157 vfd->release = video_device_release;
1153 vfd->lock = &dev->mfc_mutex; 1158 vfd->lock = &dev->mfc_mutex;
1154 vfd->v4l2_dev = &dev->v4l2_dev; 1159 vfd->v4l2_dev = &dev->v4l2_dev;
1155 vfd->vfl_dir = VFL_DIR_M2M; 1160 vfd->vfl_dir = VFL_DIR_M2M;
@@ -1172,9 +1177,9 @@ static int s5p_mfc_probe(struct platform_device *pdev)
1172 ret = -ENOMEM; 1177 ret = -ENOMEM;
1173 goto err_enc_alloc; 1178 goto err_enc_alloc;
1174 } 1179 }
1175 vfd->fops = &s5p_mfc_fops, 1180 vfd->fops = &s5p_mfc_fops;
1176 vfd->ioctl_ops = get_enc_v4l2_ioctl_ops(); 1181 vfd->ioctl_ops = get_enc_v4l2_ioctl_ops();
1177 vfd->release = video_device_release, 1182 vfd->release = video_device_release;
1178 vfd->lock = &dev->mfc_mutex; 1183 vfd->lock = &dev->mfc_mutex;
1179 vfd->v4l2_dev = &dev->v4l2_dev; 1184 vfd->v4l2_dev = &dev->v4l2_dev;
1180 vfd->vfl_dir = VFL_DIR_M2M; 1185 vfd->vfl_dir = VFL_DIR_M2M;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index f723f1f2f578..5c28cc3e699b 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -426,6 +426,8 @@ struct s5p_mfc_vp8_enc_params {
426struct s5p_mfc_enc_params { 426struct s5p_mfc_enc_params {
427 u16 width; 427 u16 width;
428 u16 height; 428 u16 height;
429 u32 mv_h_range;
430 u32 mv_v_range;
429 431
430 u16 gop_size; 432 u16 gop_size;
431 enum v4l2_mpeg_video_multi_slice_mode slice_mode; 433 enum v4l2_mpeg_video_multi_slice_mode slice_mode;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index 2475a3c9a0a6..ee05f2dd439b 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -44,8 +44,6 @@ int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev)
44 return -ENOMEM; 44 return -ENOMEM;
45 } 45 }
46 46
47 dev->bank1 = dev->bank1;
48
49 if (HAS_PORTNUM(dev) && IS_TWOPORT(dev)) { 47 if (HAS_PORTNUM(dev) && IS_TWOPORT(dev)) {
50 bank2_virt = dma_alloc_coherent(dev->mem_dev_r, 1 << MFC_BASE_ALIGN_ORDER, 48 bank2_virt = dma_alloc_coherent(dev->mem_dev_r, 1 << MFC_BASE_ALIGN_ORDER,
51 &bank2_dma_addr, GFP_KERNEL); 49 &bank2_dma_addr, GFP_KERNEL);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 91b6e020ddf3..df83cd157bab 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -208,6 +208,24 @@ static struct mfc_control controls[] = {
208 .default_value = 0, 208 .default_value = 0,
209 }, 209 },
210 { 210 {
211 .id = V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE,
212 .type = V4L2_CTRL_TYPE_INTEGER,
213 .name = "Horizontal MV Search Range",
214 .minimum = 16,
215 .maximum = 128,
216 .step = 16,
217 .default_value = 32,
218 },
219 {
220 .id = V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE,
221 .type = V4L2_CTRL_TYPE_INTEGER,
222 .name = "Vertical MV Search Range",
223 .minimum = 16,
224 .maximum = 128,
225 .step = 16,
226 .default_value = 32,
227 },
228 {
211 .id = V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE, 229 .id = V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE,
212 .type = V4L2_CTRL_TYPE_INTEGER, 230 .type = V4L2_CTRL_TYPE_INTEGER,
213 .minimum = 0, 231 .minimum = 0,
@@ -1417,6 +1435,12 @@ static int s5p_mfc_enc_s_ctrl(struct v4l2_ctrl *ctrl)
1417 case V4L2_CID_MPEG_VIDEO_VBV_SIZE: 1435 case V4L2_CID_MPEG_VIDEO_VBV_SIZE:
1418 p->vbv_size = ctrl->val; 1436 p->vbv_size = ctrl->val;
1419 break; 1437 break;
1438 case V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE:
1439 p->mv_h_range = ctrl->val;
1440 break;
1441 case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE:
1442 p->mv_v_range = ctrl->val;
1443 break;
1420 case V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE: 1444 case V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE:
1421 p->codec.h264.cpb_size = ctrl->val; 1445 p->codec.h264.cpb_size = ctrl->val;
1422 break; 1446 break;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index f6ff2dbf3a1d..f64621ae9b5a 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -727,14 +727,10 @@ static int s5p_mfc_set_enc_params(struct s5p_mfc_ctx *ctx)
727 WRITEL(reg, S5P_FIMV_E_RC_CONFIG_V6); 727 WRITEL(reg, S5P_FIMV_E_RC_CONFIG_V6);
728 728
729 /* setting for MV range [16, 256] */ 729 /* setting for MV range [16, 256] */
730 reg = 0; 730 reg = (p->mv_h_range & S5P_FIMV_E_MV_RANGE_V6_MASK);
731 reg &= ~(0x3FFF);
732 reg = 256;
733 WRITEL(reg, S5P_FIMV_E_MV_HOR_RANGE_V6); 731 WRITEL(reg, S5P_FIMV_E_MV_HOR_RANGE_V6);
734 732
735 reg = 0; 733 reg = (p->mv_v_range & S5P_FIMV_E_MV_RANGE_V6_MASK);
736 reg &= ~(0x3FFF);
737 reg = 256;
738 WRITEL(reg, S5P_FIMV_E_MV_VER_RANGE_V6); 734 WRITEL(reg, S5P_FIMV_E_MV_VER_RANGE_V6);
739 735
740 WRITEL(0x0, S5P_FIMV_E_FRAME_INSERTION_V6); 736 WRITEL(0x0, S5P_FIMV_E_FRAME_INSERTION_V6);
diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
index c5059ba0d733..a1ce55fd30f3 100644
--- a/drivers/media/platform/s5p-tv/mixer_video.c
+++ b/drivers/media/platform/s5p-tv/mixer_video.c
@@ -946,11 +946,6 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
946 946
947 mxr_dbg(mdev, "%s\n", __func__); 947 mxr_dbg(mdev, "%s\n", __func__);
948 948
949 if (count == 0) {
950 mxr_dbg(mdev, "no output buffers queued\n");
951 return -ENOBUFS;
952 }
953
954 /* block any changes in output configuration */ 949 /* block any changes in output configuration */
955 mxr_output_get(mdev); 950 mxr_output_get(mdev);
956 951
@@ -1124,6 +1119,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
1124 .drv_priv = layer, 1119 .drv_priv = layer,
1125 .buf_struct_size = sizeof(struct mxr_buffer), 1120 .buf_struct_size = sizeof(struct mxr_buffer),
1126 .ops = &mxr_video_qops, 1121 .ops = &mxr_video_qops,
1122 .min_buffers_needed = 1,
1127 .mem_ops = &vb2_dma_contig_memops, 1123 .mem_ops = &vb2_dma_contig_memops,
1128 }; 1124 };
1129 1125
diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c
index 4835173d7f80..f0b6c900034d 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -472,7 +472,7 @@ static int isi_camera_init_videobuf(struct vb2_queue *q,
472 q->buf_struct_size = sizeof(struct frame_buffer); 472 q->buf_struct_size = sizeof(struct frame_buffer);
473 q->ops = &isi_video_qops; 473 q->ops = &isi_video_qops;
474 q->mem_ops = &vb2_dma_contig_memops; 474 q->mem_ops = &vb2_dma_contig_memops;
475 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 475 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
476 476
477 return vb2_queue_init(q); 477 return vb2_queue_init(q);
478} 478}
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c
index d73abca9c6ee..3e844803bdca 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -794,7 +794,7 @@ static int mx2_camera_init_videobuf(struct vb2_queue *q,
794 q->ops = &mx2_videobuf_ops; 794 q->ops = &mx2_videobuf_ops;
795 q->mem_ops = &vb2_dma_contig_memops; 795 q->mem_ops = &vb2_dma_contig_memops;
796 q->buf_struct_size = sizeof(struct mx2_buffer); 796 q->buf_struct_size = sizeof(struct mx2_buffer);
797 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 797 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
798 798
799 return vb2_queue_init(q); 799 return vb2_queue_init(q);
800} 800}
diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c
index f975b7008692..9ed81ac6881c 100644
--- a/drivers/media/platform/soc_camera/mx3_camera.c
+++ b/drivers/media/platform/soc_camera/mx3_camera.c
@@ -453,7 +453,7 @@ static int mx3_camera_init_videobuf(struct vb2_queue *q,
453 q->ops = &mx3_videobuf_ops; 453 q->ops = &mx3_videobuf_ops;
454 q->mem_ops = &vb2_dma_contig_memops; 454 q->mem_ops = &vb2_dma_contig_memops;
455 q->buf_struct_size = sizeof(struct mx3_camera_buffer); 455 q->buf_struct_size = sizeof(struct mx3_camera_buffer);
456 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 456 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
457 457
458 return vb2_queue_init(q); 458 return vb2_queue_init(q);
459} 459}
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index 3b1c05a72d00..704eee766487 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -68,6 +68,8 @@
68#define VNMC_YCAL (1 << 19) 68#define VNMC_YCAL (1 << 19)
69#define VNMC_INF_YUV8_BT656 (0 << 16) 69#define VNMC_INF_YUV8_BT656 (0 << 16)
70#define VNMC_INF_YUV8_BT601 (1 << 16) 70#define VNMC_INF_YUV8_BT601 (1 << 16)
71#define VNMC_INF_YUV10_BT656 (2 << 16)
72#define VNMC_INF_YUV10_BT601 (3 << 16)
71#define VNMC_INF_YUV16 (5 << 16) 73#define VNMC_INF_YUV16 (5 << 16)
72#define VNMC_VUP (1 << 10) 74#define VNMC_VUP (1 << 10)
73#define VNMC_IM_ODD (0 << 3) 75#define VNMC_IM_ODD (0 << 3)
@@ -275,6 +277,12 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
275 /* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */ 277 /* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
276 vnmc |= priv->pdata->flags & RCAR_VIN_BT656 ? 278 vnmc |= priv->pdata->flags & RCAR_VIN_BT656 ?
277 VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601; 279 VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
280 break;
281 case V4L2_MBUS_FMT_YUYV10_2X10:
282 /* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
283 vnmc |= priv->pdata->flags & RCAR_VIN_BT656 ?
284 VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
285 break;
278 default: 286 default:
279 break; 287 break;
280 } 288 }
@@ -1003,6 +1011,7 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx,
1003 switch (code) { 1011 switch (code) {
1004 case V4L2_MBUS_FMT_YUYV8_1X16: 1012 case V4L2_MBUS_FMT_YUYV8_1X16:
1005 case V4L2_MBUS_FMT_YUYV8_2X8: 1013 case V4L2_MBUS_FMT_YUYV8_2X8:
1014 case V4L2_MBUS_FMT_YUYV10_2X10:
1006 if (cam->extra_fmt) 1015 if (cam->extra_fmt)
1007 break; 1016 break;
1008 1017
@@ -1360,7 +1369,7 @@ static int rcar_vin_init_videobuf2(struct vb2_queue *vq,
1360 vq->ops = &rcar_vin_vb2_ops; 1369 vq->ops = &rcar_vin_vb2_ops;
1361 vq->mem_ops = &vb2_dma_contig_memops; 1370 vq->mem_ops = &vb2_dma_contig_memops;
1362 vq->buf_struct_size = sizeof(struct rcar_vin_buffer); 1371 vq->buf_struct_size = sizeof(struct rcar_vin_buffer);
1363 vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1372 vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1364 1373
1365 return vb2_queue_init(vq); 1374 return vb2_queue_init(vq);
1366} 1375}
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 150bd4df413c..3e75a469cd49 100644
--- a/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
+++ b/drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
@@ -1665,7 +1665,7 @@ static int sh_mobile_ceu_init_videobuf(struct vb2_queue *q,
1665 q->ops = &sh_mobile_ceu_videobuf_ops; 1665 q->ops = &sh_mobile_ceu_videobuf_ops;
1666 q->mem_ops = &vb2_dma_contig_memops; 1666 q->mem_ops = &vb2_dma_contig_memops;
1667 q->buf_struct_size = sizeof(struct sh_mobile_ceu_buffer); 1667 q->buf_struct_size = sizeof(struct sh_mobile_ceu_buffer);
1668 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1668 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1669 1669
1670 return vb2_queue_init(q); 1670 return vb2_queue_init(q);
1671} 1671}
diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
index 1296c5386231..7a77a5b7a075 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -1278,6 +1278,8 @@ static irqreturn_t vpe_irq(int irq_vpe, void *data)
1278 d_buf = &d_vb->v4l2_buf; 1278 d_buf = &d_vb->v4l2_buf;
1279 1279
1280 d_buf->timestamp = s_buf->timestamp; 1280 d_buf->timestamp = s_buf->timestamp;
1281 d_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1282 d_buf->flags |= s_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1281 if (s_buf->flags & V4L2_BUF_FLAG_TIMECODE) { 1283 if (s_buf->flags & V4L2_BUF_FLAG_TIMECODE) {
1282 d_buf->flags |= V4L2_BUF_FLAG_TIMECODE; 1284 d_buf->flags |= V4L2_BUF_FLAG_TIMECODE;
1283 d_buf->timecode = s_buf->timecode; 1285 d_buf->timecode = s_buf->timecode;
@@ -1770,7 +1772,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
1770 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 1772 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
1771 src_vq->ops = &vpe_qops; 1773 src_vq->ops = &vpe_qops;
1772 src_vq->mem_ops = &vb2_dma_contig_memops; 1774 src_vq->mem_ops = &vb2_dma_contig_memops;
1773 src_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 1775 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
1774 1776
1775 ret = vb2_queue_init(src_vq); 1777 ret = vb2_queue_init(src_vq);
1776 if (ret) 1778 if (ret)
@@ -1783,7 +1785,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
1783 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); 1785 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
1784 dst_vq->ops = &vpe_qops; 1786 dst_vq->ops = &vpe_qops;
1785 dst_vq->mem_ops = &vb2_dma_contig_memops; 1787 dst_vq->mem_ops = &vb2_dma_contig_memops;
1786 dst_vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 1788 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
1787 1789
1788 return vb2_queue_init(dst_vq); 1790 return vb2_queue_init(dst_vq);
1789} 1791}
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index 2d4e73b45c5e..3890f4f42a78 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -70,10 +70,6 @@ static unsigned debug;
70module_param(debug, uint, 0644); 70module_param(debug, uint, 0644);
71MODULE_PARM_DESC(debug, "activates debug info"); 71MODULE_PARM_DESC(debug, "activates debug info");
72 72
73static unsigned int vid_limit = 16;
74module_param(vid_limit, uint, 0644);
75MODULE_PARM_DESC(vid_limit, "capture memory limit in megabytes");
76
77/* Global font descriptor */ 73/* Global font descriptor */
78static const u8 *font8x16; 74static const u8 *font8x16;
79 75
@@ -191,7 +187,6 @@ struct vivi_buffer {
191 /* common v4l buffer stuff -- must be first */ 187 /* common v4l buffer stuff -- must be first */
192 struct vb2_buffer vb; 188 struct vb2_buffer vb;
193 struct list_head list; 189 struct list_head list;
194 const struct vivi_fmt *fmt;
195}; 190};
196 191
197struct vivi_dmaqueue { 192struct vivi_dmaqueue {
@@ -254,7 +249,7 @@ struct vivi_dev {
254 struct v4l2_fract timeperframe; 249 struct v4l2_fract timeperframe;
255 unsigned int width, height; 250 unsigned int width, height;
256 struct vb2_queue vb_vidq; 251 struct vb2_queue vb_vidq;
257 unsigned int field_count; 252 unsigned int seq_count;
258 253
259 u8 bars[9][3]; 254 u8 bars[9][3];
260 u8 line[MAX_WIDTH * 8] __attribute__((__aligned__(4))); 255 u8 line[MAX_WIDTH * 8] __attribute__((__aligned__(4)));
@@ -675,8 +670,7 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf)
675 dev->mv_count += 2; 670 dev->mv_count += 2;
676 671
677 buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED; 672 buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED;
678 dev->field_count++; 673 buf->vb.v4l2_buf.sequence = dev->seq_count++;
679 buf->vb.v4l2_buf.sequence = dev->field_count >> 1;
680 v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp); 674 v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp);
681} 675}
682 676
@@ -818,19 +812,15 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
818 struct vivi_dev *dev = vb2_get_drv_priv(vq); 812 struct vivi_dev *dev = vb2_get_drv_priv(vq);
819 unsigned long size; 813 unsigned long size;
820 814
821 if (fmt) 815 size = dev->width * dev->height * dev->pixelsize;
816 if (fmt) {
817 if (fmt->fmt.pix.sizeimage < size)
818 return -EINVAL;
822 size = fmt->fmt.pix.sizeimage; 819 size = fmt->fmt.pix.sizeimage;
823 else 820 /* check against insane over 8K resolution buffers */
824 size = dev->width * dev->height * dev->pixelsize; 821 if (size > 7680 * 4320 * dev->pixelsize)
825 822 return -EINVAL;
826 if (size == 0) 823 }
827 return -EINVAL;
828
829 if (0 == *nbuffers)
830 *nbuffers = 32;
831
832 while (size * *nbuffers > vid_limit * 1024 * 1024)
833 (*nbuffers)--;
834 824
835 *nplanes = 1; 825 *nplanes = 1;
836 826
@@ -876,8 +866,6 @@ static int buffer_prepare(struct vb2_buffer *vb)
876 866
877 vb2_set_plane_payload(&buf->vb, 0, size); 867 vb2_set_plane_payload(&buf->vb, 0, size);
878 868
879 buf->fmt = dev->fmt;
880
881 precalculate_bars(dev); 869 precalculate_bars(dev);
882 precalculate_line(dev); 870 precalculate_line(dev);
883 871
@@ -901,8 +889,20 @@ static void buffer_queue(struct vb2_buffer *vb)
901static int start_streaming(struct vb2_queue *vq, unsigned int count) 889static int start_streaming(struct vb2_queue *vq, unsigned int count)
902{ 890{
903 struct vivi_dev *dev = vb2_get_drv_priv(vq); 891 struct vivi_dev *dev = vb2_get_drv_priv(vq);
892 int err;
893
904 dprintk(dev, 1, "%s\n", __func__); 894 dprintk(dev, 1, "%s\n", __func__);
905 return vivi_start_generating(dev); 895 dev->seq_count = 0;
896 err = vivi_start_generating(dev);
897 if (err) {
898 struct vivi_buffer *buf, *tmp;
899
900 list_for_each_entry_safe(buf, tmp, &dev->vidq.active, list) {
901 list_del(&buf->list);
902 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_QUEUED);
903 }
904 }
905 return err;
906} 906}
907 907
908/* abort streaming and wait for last buffer */ 908/* abort streaming and wait for last buffer */
@@ -1121,7 +1121,11 @@ static int vidioc_enum_frameintervals(struct file *file, void *priv,
1121 if (!fmt) 1121 if (!fmt)
1122 return -EINVAL; 1122 return -EINVAL;
1123 1123
1124 /* regarding width & height - we support any */ 1124 /* check for valid width/height */
1125 if (fival->width < 48 || fival->width > MAX_WIDTH || (fival->width & 3))
1126 return -EINVAL;
1127 if (fival->height < 32 || fival->height > MAX_HEIGHT)
1128 return -EINVAL;
1125 1129
1126 fival->type = V4L2_FRMIVAL_TYPE_CONTINUOUS; 1130 fival->type = V4L2_FRMIVAL_TYPE_CONTINUOUS;
1127 1131
@@ -1439,7 +1443,7 @@ static int __init vivi_create_instance(int inst)
1439 q->buf_struct_size = sizeof(struct vivi_buffer); 1443 q->buf_struct_size = sizeof(struct vivi_buffer);
1440 q->ops = &vivi_video_qops; 1444 q->ops = &vivi_video_qops;
1441 q->mem_ops = &vb2_vmalloc_memops; 1445 q->mem_ops = &vb2_vmalloc_memops;
1442 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1446 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1443 1447
1444 ret = vb2_queue_init(q); 1448 ret = vb2_queue_init(q);
1445 if (ret) 1449 if (ret)
diff --git a/drivers/media/platform/vsp1/vsp1.h b/drivers/media/platform/vsp1/vsp1.h
index 94d1b02680c5..0313210c6e9e 100644
--- a/drivers/media/platform/vsp1/vsp1.h
+++ b/drivers/media/platform/vsp1/vsp1.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1.h -- R-Car VSP1 Driver 2 * vsp1.h -- R-Car VSP1 Driver
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c
index 0df0a994e575..2f74f0e0ddf5 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1_drv.c -- R-Car VSP1 Driver 2 * vsp1_drv.c -- R-Car VSP1 Driver
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
diff --git a/drivers/media/platform/vsp1/vsp1_entity.c b/drivers/media/platform/vsp1/vsp1_entity.c
index 0226e47df6d9..3fc9e4266caf 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.c
+++ b/drivers/media/platform/vsp1/vsp1_entity.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1_entity.c -- R-Car VSP1 Base Entity 2 * vsp1_entity.c -- R-Car VSP1 Base Entity
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
diff --git a/drivers/media/platform/vsp1/vsp1_entity.h b/drivers/media/platform/vsp1/vsp1_entity.h
index e152798d7f38..f6fd6988aeb0 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.h
+++ b/drivers/media/platform/vsp1/vsp1_entity.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1_entity.h -- R-Car VSP1 Base Entity 2 * vsp1_entity.h -- R-Car VSP1 Base Entity
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
diff --git a/drivers/media/platform/vsp1/vsp1_lif.c b/drivers/media/platform/vsp1/vsp1_lif.c
index 74a32e69ef10..135a78957014 100644
--- a/drivers/media/platform/vsp1/vsp1_lif.c
+++ b/drivers/media/platform/vsp1/vsp1_lif.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1_lif.c -- R-Car VSP1 LCD Controller Interface 2 * vsp1_lif.c -- R-Car VSP1 LCD Controller Interface
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
diff --git a/drivers/media/platform/vsp1/vsp1_lif.h b/drivers/media/platform/vsp1/vsp1_lif.h
index 89b93af56fdc..7b35879028de 100644
--- a/drivers/media/platform/vsp1/vsp1_lif.h
+++ b/drivers/media/platform/vsp1/vsp1_lif.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1_lif.h -- R-Car VSP1 LCD Controller Interface 2 * vsp1_lif.h -- R-Car VSP1 LCD Controller Interface
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c
index bce2be5466b9..2b04d0f95c62 100644
--- a/drivers/media/platform/vsp1/vsp1_rpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rpf.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1_rpf.c -- R-Car VSP1 Read Pixel Formatter 2 * vsp1_rpf.c -- R-Car VSP1 Read Pixel Formatter
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.c b/drivers/media/platform/vsp1/vsp1_rwpf.c
index 782f770daee5..ec3dab6a9b9b 100644
--- a/drivers/media/platform/vsp1/vsp1_rwpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rwpf.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1_rwpf.c -- R-Car VSP1 Read and Write Pixel Formatters 2 * vsp1_rwpf.c -- R-Car VSP1 Read and Write Pixel Formatters
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
diff --git a/drivers/media/platform/vsp1/vsp1_rwpf.h b/drivers/media/platform/vsp1/vsp1_rwpf.h
index 6cbdb547470b..5c5ee81bbeae 100644
--- a/drivers/media/platform/vsp1/vsp1_rwpf.h
+++ b/drivers/media/platform/vsp1/vsp1_rwpf.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1_rwpf.h -- R-Car VSP1 Read and Write Pixel Formatters 2 * vsp1_rwpf.h -- R-Car VSP1 Read and Write Pixel Formatters
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
diff --git a/drivers/media/platform/vsp1/vsp1_uds.c b/drivers/media/platform/vsp1/vsp1_uds.c
index 0e50b37f060d..622342ac7770 100644
--- a/drivers/media/platform/vsp1/vsp1_uds.c
+++ b/drivers/media/platform/vsp1/vsp1_uds.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1_uds.c -- R-Car VSP1 Up and Down Scaler 2 * vsp1_uds.c -- R-Car VSP1 Up and Down Scaler
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
diff --git a/drivers/media/platform/vsp1/vsp1_uds.h b/drivers/media/platform/vsp1/vsp1_uds.h
index 972a285abdb9..479d12df1180 100644
--- a/drivers/media/platform/vsp1/vsp1_uds.h
+++ b/drivers/media/platform/vsp1/vsp1_uds.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1_uds.h -- R-Car VSP1 Up and Down Scaler 2 * vsp1_uds.h -- R-Car VSP1 Up and Down Scaler
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index b4687a834f85..b48f135ffc01 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1_video.c -- R-Car VSP1 Video Node 2 * vsp1_video.c -- R-Car VSP1 Video Node
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
@@ -1051,7 +1051,7 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf)
1051 video->queue.buf_struct_size = sizeof(struct vsp1_video_buffer); 1051 video->queue.buf_struct_size = sizeof(struct vsp1_video_buffer);
1052 video->queue.ops = &vsp1_video_queue_qops; 1052 video->queue.ops = &vsp1_video_queue_qops;
1053 video->queue.mem_ops = &vb2_dma_contig_memops; 1053 video->queue.mem_ops = &vb2_dma_contig_memops;
1054 video->queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; 1054 video->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
1055 ret = vb2_queue_init(&video->queue); 1055 ret = vb2_queue_init(&video->queue);
1056 if (ret < 0) { 1056 if (ret < 0) {
1057 dev_err(video->vsp1->dev, "failed to initialize vb2 queue\n"); 1057 dev_err(video->vsp1->dev, "failed to initialize vb2 queue\n");
diff --git a/drivers/media/platform/vsp1/vsp1_video.h b/drivers/media/platform/vsp1/vsp1_video.h
index d8612a378345..53e4b3745940 100644
--- a/drivers/media/platform/vsp1/vsp1_video.h
+++ b/drivers/media/platform/vsp1/vsp1_video.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1_video.h -- R-Car VSP1 Video Node 2 * vsp1_video.h -- R-Car VSP1 Video Node
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c b/drivers/media/platform/vsp1/vsp1_wpf.c
index 7baed81ff005..11a61c601da0 100644
--- a/drivers/media/platform/vsp1/vsp1_wpf.c
+++ b/drivers/media/platform/vsp1/vsp1_wpf.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * vsp1_wpf.c -- R-Car VSP1 Write Pixel Formatter 2 * vsp1_wpf.c -- R-Car VSP1 Write Pixel Formatter
3 * 3 *
4 * Copyright (C) 2013 Renesas Corporation 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 * 5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 * 7 *
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index 545c04cf7226..d719e59e2179 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -270,6 +270,16 @@ reset_rds:
270 outb(inb(dev->io + 1) & 0x7f, dev->io + 1); 270 outb(inb(dev->io + 1) & 0x7f, dev->io + 1);
271} 271}
272 272
273static bool cadet_has_rds_data(struct cadet *dev)
274{
275 bool result;
276
277 mutex_lock(&dev->lock);
278 result = dev->rdsin != dev->rdsout;
279 mutex_unlock(&dev->lock);
280 return result;
281}
282
273 283
274static void cadet_handler(unsigned long data) 284static void cadet_handler(unsigned long data)
275{ 285{
@@ -279,13 +289,12 @@ static void cadet_handler(unsigned long data)
279 if (mutex_trylock(&dev->lock)) { 289 if (mutex_trylock(&dev->lock)) {
280 outb(0x3, dev->io); /* Select RDS Decoder Control */ 290 outb(0x3, dev->io); /* Select RDS Decoder Control */
281 if ((inb(dev->io + 1) & 0x20) != 0) 291 if ((inb(dev->io + 1) & 0x20) != 0)
282 printk(KERN_CRIT "cadet: RDS fifo overflow\n"); 292 pr_err("cadet: RDS fifo overflow\n");
283 outb(0x80, dev->io); /* Select RDS fifo */ 293 outb(0x80, dev->io); /* Select RDS fifo */
294
284 while ((inb(dev->io) & 0x80) != 0) { 295 while ((inb(dev->io) & 0x80) != 0) {
285 dev->rdsbuf[dev->rdsin] = inb(dev->io + 1); 296 dev->rdsbuf[dev->rdsin] = inb(dev->io + 1);
286 if (dev->rdsin + 1 == dev->rdsout) 297 if (dev->rdsin + 1 != dev->rdsout)
287 printk(KERN_WARNING "cadet: RDS buffer overflow\n");
288 else
289 dev->rdsin++; 298 dev->rdsin++;
290 } 299 }
291 mutex_unlock(&dev->lock); 300 mutex_unlock(&dev->lock);
@@ -294,7 +303,7 @@ static void cadet_handler(unsigned long data)
294 /* 303 /*
295 * Service pending read 304 * Service pending read
296 */ 305 */
297 if (dev->rdsin != dev->rdsout) 306 if (cadet_has_rds_data(dev))
298 wake_up_interruptible(&dev->read_queue); 307 wake_up_interruptible(&dev->read_queue);
299 308
300 /* 309 /*
@@ -327,22 +336,21 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
327 mutex_lock(&dev->lock); 336 mutex_lock(&dev->lock);
328 if (dev->rdsstat == 0) 337 if (dev->rdsstat == 0)
329 cadet_start_rds(dev); 338 cadet_start_rds(dev);
330 if (dev->rdsin == dev->rdsout) { 339 mutex_unlock(&dev->lock);
331 if (file->f_flags & O_NONBLOCK) { 340
332 i = -EWOULDBLOCK; 341 if (!cadet_has_rds_data(dev) && (file->f_flags & O_NONBLOCK))
333 goto unlock; 342 return -EWOULDBLOCK;
334 } 343 i = wait_event_interruptible(dev->read_queue, cadet_has_rds_data(dev));
335 mutex_unlock(&dev->lock); 344 if (i)
336 interruptible_sleep_on(&dev->read_queue); 345 return i;
337 mutex_lock(&dev->lock); 346
338 } 347 mutex_lock(&dev->lock);
339 while (i < count && dev->rdsin != dev->rdsout) 348 while (i < count && dev->rdsin != dev->rdsout)
340 readbuf[i++] = dev->rdsbuf[dev->rdsout++]; 349 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
350 mutex_unlock(&dev->lock);
341 351
342 if (i && copy_to_user(data, readbuf, i)) 352 if (i && copy_to_user(data, readbuf, i))
343 i = -EFAULT; 353 return -EFAULT;
344unlock:
345 mutex_unlock(&dev->lock);
346 return i; 354 return i;
347} 355}
348 356
@@ -352,7 +360,7 @@ static int vidioc_querycap(struct file *file, void *priv,
352{ 360{
353 strlcpy(v->driver, "ADS Cadet", sizeof(v->driver)); 361 strlcpy(v->driver, "ADS Cadet", sizeof(v->driver));
354 strlcpy(v->card, "ADS Cadet", sizeof(v->card)); 362 strlcpy(v->card, "ADS Cadet", sizeof(v->card));
355 strlcpy(v->bus_info, "ISA", sizeof(v->bus_info)); 363 strlcpy(v->bus_info, "ISA:radio-cadet", sizeof(v->bus_info));
356 v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO | 364 v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO |
357 V4L2_CAP_READWRITE | V4L2_CAP_RDS_CAPTURE; 365 V4L2_CAP_READWRITE | V4L2_CAP_RDS_CAPTURE;
358 v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS; 366 v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS;
@@ -491,7 +499,7 @@ static unsigned int cadet_poll(struct file *file, struct poll_table_struct *wait
491 cadet_start_rds(dev); 499 cadet_start_rds(dev);
492 mutex_unlock(&dev->lock); 500 mutex_unlock(&dev->lock);
493 } 501 }
494 if (dev->rdsin != dev->rdsout) 502 if (cadet_has_rds_data(dev))
495 res |= POLLIN | POLLRDNORM; 503 res |= POLLIN | POLLRDNORM;
496 return res; 504 return res;
497} 505}
diff --git a/drivers/media/radio/radio-keene.c b/drivers/media/radio/radio-keene.c
index fa3964022b96..3d127825eceb 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -416,22 +416,5 @@ static struct usb_driver usb_keene_driver = {
416 .reset_resume = usb_keene_resume, 416 .reset_resume = usb_keene_resume,
417}; 417};
418 418
419static int __init keene_init(void) 419module_usb_driver(usb_keene_driver);
420{
421 int retval = usb_register(&usb_keene_driver);
422
423 if (retval)
424 pr_err(KBUILD_MODNAME
425 ": usb_register failed. Error number %d\n", retval);
426
427 return retval;
428}
429
430static void __exit keene_exit(void)
431{
432 usb_deregister(&usb_keene_driver);
433}
434
435module_init(keene_init);
436module_exit(keene_exit);
437 420
diff --git a/drivers/media/radio/si4713/Kconfig b/drivers/media/radio/si4713/Kconfig
index a7c3ba85d12b..9c8b887cff75 100644
--- a/drivers/media/radio/si4713/Kconfig
+++ b/drivers/media/radio/si4713/Kconfig
@@ -1,7 +1,7 @@
1config USB_SI4713 1config USB_SI4713
2 tristate "Silicon Labs Si4713 FM Radio Transmitter support with USB" 2 tristate "Silicon Labs Si4713 FM Radio Transmitter support with USB"
3 depends on USB && RADIO_SI4713 3 depends on USB && I2C && RADIO_SI4713
4 select SI4713 4 select I2C_SI4713
5 ---help--- 5 ---help---
6 This is a driver for USB devices with the Silicon Labs SI4713 6 This is a driver for USB devices with the Silicon Labs SI4713
7 chip. Currently these devices are known to work. 7 chip. Currently these devices are known to work.
@@ -16,7 +16,7 @@ config USB_SI4713
16config PLATFORM_SI4713 16config PLATFORM_SI4713
17 tristate "Silicon Labs Si4713 FM Radio Transmitter support with I2C" 17 tristate "Silicon Labs Si4713 FM Radio Transmitter support with I2C"
18 depends on I2C && RADIO_SI4713 18 depends on I2C && RADIO_SI4713
19 select SI4713 19 select I2C_SI4713
20 ---help--- 20 ---help---
21 This is a driver for I2C devices with the Silicon Labs SI4713 21 This is a driver for I2C devices with the Silicon Labs SI4713
22 chip. 22 chip.
diff --git a/drivers/media/radio/si4713/radio-usb-si4713.c b/drivers/media/radio/si4713/radio-usb-si4713.c
index 779855b74bcd..86502b2786d0 100644
--- a/drivers/media/radio/si4713/radio-usb-si4713.c
+++ b/drivers/media/radio/si4713/radio-usb-si4713.c
@@ -223,7 +223,7 @@ struct si4713_start_seq_table {
223 * (0x03): Get serial number of the board (Response : CB000-00-00) 223 * (0x03): Get serial number of the board (Response : CB000-00-00)
224 * (0x06, 0x03, 0x03, 0x08, 0x01, 0x0f) : Get Component revision 224 * (0x06, 0x03, 0x03, 0x08, 0x01, 0x0f) : Get Component revision
225 */ 225 */
226static struct si4713_start_seq_table start_seq[] = { 226static const struct si4713_start_seq_table start_seq[] = {
227 227
228 { 1, { 0x03 } }, 228 { 1, { 0x03 } },
229 { 2, { 0x32, 0x7f } }, 229 { 2, { 0x32, 0x7f } },
@@ -261,7 +261,7 @@ static int si4713_start_seq(struct si4713_usb_device *radio)
261 261
262 for (i = 0; i < ARRAY_SIZE(start_seq); i++) { 262 for (i = 0; i < ARRAY_SIZE(start_seq); i++) {
263 int len = start_seq[i].len; 263 int len = start_seq[i].len;
264 u8 *payload = start_seq[i].payload; 264 const u8 *payload = start_seq[i].payload;
265 265
266 memcpy(radio->buffer + 1, payload, len); 266 memcpy(radio->buffer + 1, payload, len);
267 memset(radio->buffer + len + 1, 0, BUFFER_LENGTH - 1 - len); 267 memset(radio->buffer + len + 1, 0, BUFFER_LENGTH - 1 - len);
diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 904f11367c29..8fbd377e6311 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -106,6 +106,15 @@ config IR_SANYO_DECODER
106 uses the Sanyo protocol (Sanyo, Aiwa, Chinon remotes), 106 uses the Sanyo protocol (Sanyo, Aiwa, Chinon remotes),
107 and you need software decoding support. 107 and you need software decoding support.
108 108
109config IR_SHARP_DECODER
110 tristate "Enable IR raw decoder for the Sharp protocol"
111 depends on RC_CORE
112 default y
113
114 ---help---
115 Enable this option if you have an infrared remote control which
116 uses the Sharp protocol, and you need software decoding support.
117
109config IR_MCE_KBD_DECODER 118config IR_MCE_KBD_DECODER
110 tristate "Enable IR raw decoder for the MCE keyboard/mouse protocol" 119 tristate "Enable IR raw decoder for the MCE keyboard/mouse protocol"
111 depends on RC_CORE 120 depends on RC_CORE
@@ -300,6 +309,8 @@ config IR_RX51
300 The driver uses omap DM timers for generating the carrier 309 The driver uses omap DM timers for generating the carrier
301 wave and pulses. 310 wave and pulses.
302 311
312source "drivers/media/rc/img-ir/Kconfig"
313
303config RC_LOOPBACK 314config RC_LOOPBACK
304 tristate "Remote Control Loopback Driver" 315 tristate "Remote Control Loopback Driver"
305 depends on RC_CORE 316 depends on RC_CORE
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index f4eb32c0a455..f8b54ff46601 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_IR_JVC_DECODER) += ir-jvc-decoder.o
11obj-$(CONFIG_IR_SONY_DECODER) += ir-sony-decoder.o 11obj-$(CONFIG_IR_SONY_DECODER) += ir-sony-decoder.o
12obj-$(CONFIG_IR_RC5_SZ_DECODER) += ir-rc5-sz-decoder.o 12obj-$(CONFIG_IR_RC5_SZ_DECODER) += ir-rc5-sz-decoder.o
13obj-$(CONFIG_IR_SANYO_DECODER) += ir-sanyo-decoder.o 13obj-$(CONFIG_IR_SANYO_DECODER) += ir-sanyo-decoder.o
14obj-$(CONFIG_IR_SHARP_DECODER) += ir-sharp-decoder.o
14obj-$(CONFIG_IR_MCE_KBD_DECODER) += ir-mce_kbd-decoder.o 15obj-$(CONFIG_IR_MCE_KBD_DECODER) += ir-mce_kbd-decoder.o
15obj-$(CONFIG_IR_LIRC_CODEC) += ir-lirc-codec.o 16obj-$(CONFIG_IR_LIRC_CODEC) += ir-lirc-codec.o
16 17
@@ -31,3 +32,4 @@ obj-$(CONFIG_IR_GPIO_CIR) += gpio-ir-recv.o
31obj-$(CONFIG_IR_IGUANA) += iguanair.o 32obj-$(CONFIG_IR_IGUANA) += iguanair.o
32obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o 33obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o
33obj-$(CONFIG_RC_ST) += st_rc.o 34obj-$(CONFIG_RC_ST) += st_rc.o
35obj-$(CONFIG_IR_IMG) += img-ir/
diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
index 4d6a63fe6c5e..2df7c5516013 100644
--- a/drivers/media/rc/ati_remote.c
+++ b/drivers/media/rc/ati_remote.c
@@ -784,7 +784,7 @@ static void ati_remote_rc_init(struct ati_remote *ati_remote)
784 784
785 rdev->priv = ati_remote; 785 rdev->priv = ati_remote;
786 rdev->driver_type = RC_DRIVER_SCANCODE; 786 rdev->driver_type = RC_DRIVER_SCANCODE;
787 rdev->allowed_protos = RC_BIT_OTHER; 787 rc_set_allowed_protocols(rdev, RC_BIT_OTHER);
788 rdev->driver_name = "ati_remote"; 788 rdev->driver_name = "ati_remote";
789 789
790 rdev->open = ati_remote_rc_open; 790 rdev->open = ati_remote_rc_open;
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index c1444f84717d..fc9d23f2ed3f 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -1059,7 +1059,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1059 learning_mode_force = false; 1059 learning_mode_force = false;
1060 1060
1061 rdev->driver_type = RC_DRIVER_IR_RAW; 1061 rdev->driver_type = RC_DRIVER_IR_RAW;
1062 rdev->allowed_protos = RC_BIT_ALL; 1062 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
1063 rdev->priv = dev; 1063 rdev->priv = dev;
1064 rdev->open = ene_open; 1064 rdev->open = ene_open;
1065 rdev->close = ene_close; 1065 rdev->close = ene_close;
diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c
index d6fa441655d2..46b66e59438f 100644
--- a/drivers/media/rc/fintek-cir.c
+++ b/drivers/media/rc/fintek-cir.c
@@ -541,7 +541,7 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
541 /* Set up the rc device */ 541 /* Set up the rc device */
542 rdev->priv = fintek; 542 rdev->priv = fintek;
543 rdev->driver_type = RC_DRIVER_IR_RAW; 543 rdev->driver_type = RC_DRIVER_IR_RAW;
544 rdev->allowed_protos = RC_BIT_ALL; 544 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
545 rdev->open = fintek_open; 545 rdev->open = fintek_open;
546 rdev->close = fintek_close; 546 rdev->close = fintek_close;
547 rdev->input_name = FINTEK_DESCRIPTION; 547 rdev->input_name = FINTEK_DESCRIPTION;
diff --git a/drivers/media/rc/gpio-ir-recv.c b/drivers/media/rc/gpio-ir-recv.c
index 80c611c2e8c2..29b5f89813b4 100644
--- a/drivers/media/rc/gpio-ir-recv.c
+++ b/drivers/media/rc/gpio-ir-recv.c
@@ -145,9 +145,9 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
145 rcdev->dev.parent = &pdev->dev; 145 rcdev->dev.parent = &pdev->dev;
146 rcdev->driver_name = GPIO_IR_DRIVER_NAME; 146 rcdev->driver_name = GPIO_IR_DRIVER_NAME;
147 if (pdata->allowed_protos) 147 if (pdata->allowed_protos)
148 rcdev->allowed_protos = pdata->allowed_protos; 148 rc_set_allowed_protocols(rcdev, pdata->allowed_protos);
149 else 149 else
150 rcdev->allowed_protos = RC_BIT_ALL; 150 rc_set_allowed_protocols(rcdev, RC_BIT_ALL);
151 rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY; 151 rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY;
152 152
153 gpio_dev->rcdev = rcdev; 153 gpio_dev->rcdev = rcdev;
diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index fdae05c4f377..627ddfd61980 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -286,10 +286,10 @@ static int iguanair_receiver(struct iguanair *ir, bool enable)
286} 286}
287 287
288/* 288/*
289 * The iguana ir creates the carrier by busy spinning after each pulse or 289 * The iguanair creates the carrier by busy spinning after each half period.
290 * space. This is counted in CPU cycles, with the CPU running at 24MHz. It is 290 * This is counted in CPU cycles, with the CPU running at 24MHz. It is
291 * broken down into 7-cycles and 4-cyles delays, with a preference for 291 * broken down into 7-cycles and 4-cyles delays, with a preference for
292 * 4-cycle delays. 292 * 4-cycle delays, minus the overhead of the loop itself (cycle_overhead).
293 */ 293 */
294static int iguanair_set_tx_carrier(struct rc_dev *dev, uint32_t carrier) 294static int iguanair_set_tx_carrier(struct rc_dev *dev, uint32_t carrier)
295{ 295{
@@ -316,7 +316,14 @@ static int iguanair_set_tx_carrier(struct rc_dev *dev, uint32_t carrier)
316 sevens = (4 - cycles) & 3; 316 sevens = (4 - cycles) & 3;
317 fours = (cycles - sevens * 7) / 4; 317 fours = (cycles - sevens * 7) / 4;
318 318
319 /* magic happens here */ 319 /*
320 * The firmware interprets these values as a relative offset
321 * for a branch. Immediately following the branches, there
322 * 4 instructions of 7 cycles (2 bytes each) and 110
323 * instructions of 4 cycles (1 byte each). A relative branch
324 * of 0 will execute all of them, branch further for less
325 * cycle burning.
326 */
320 ir->packet->busy7 = (4 - sevens) * 2; 327 ir->packet->busy7 = (4 - sevens) * 2;
321 ir->packet->busy4 = 110 - fours; 328 ir->packet->busy4 = 110 - fours;
322 } 329 }
@@ -357,20 +364,14 @@ static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count)
357 rc = -EINVAL; 364 rc = -EINVAL;
358 goto out; 365 goto out;
359 } 366 }
360 while (periods > 127) { 367 while (periods) {
361 ir->packet->payload[size++] = 127 | space; 368 unsigned p = min(periods, 127u);
362 periods -= 127; 369 ir->packet->payload[size++] = p | space;
370 periods -= p;
363 } 371 }
364
365 ir->packet->payload[size++] = periods | space;
366 space ^= 0x80; 372 space ^= 0x80;
367 } 373 }
368 374
369 if (count == 0) {
370 rc = -EINVAL;
371 goto out;
372 }
373
374 ir->packet->header.start = 0; 375 ir->packet->header.start = 0;
375 ir->packet->header.direction = DIR_OUT; 376 ir->packet->header.direction = DIR_OUT;
376 ir->packet->header.cmd = CMD_SEND; 377 ir->packet->header.cmd = CMD_SEND;
@@ -494,7 +495,7 @@ static int iguanair_probe(struct usb_interface *intf,
494 usb_to_input_id(ir->udev, &rc->input_id); 495 usb_to_input_id(ir->udev, &rc->input_id);
495 rc->dev.parent = &intf->dev; 496 rc->dev.parent = &intf->dev;
496 rc->driver_type = RC_DRIVER_IR_RAW; 497 rc->driver_type = RC_DRIVER_IR_RAW;
497 rc->allowed_protos = RC_BIT_ALL; 498 rc_set_allowed_protocols(rc, RC_BIT_ALL);
498 rc->priv = ir; 499 rc->priv = ir;
499 rc->open = iguanair_open; 500 rc->open = iguanair_open;
500 rc->close = iguanair_close; 501 rc->close = iguanair_close;
diff --git a/drivers/media/rc/img-ir/Kconfig b/drivers/media/rc/img-ir/Kconfig
new file mode 100644
index 000000000000..03ba9fc170fb
--- /dev/null
+++ b/drivers/media/rc/img-ir/Kconfig
@@ -0,0 +1,61 @@
1config IR_IMG
2 tristate "ImgTec IR Decoder"
3 depends on RC_CORE
4 select IR_IMG_HW if !IR_IMG_RAW
5 help
6 Say Y or M here if you want to use the ImgTec infrared decoder
7 functionality found in SoCs such as TZ1090.
8
9config IR_IMG_RAW
10 bool "Raw decoder"
11 depends on IR_IMG
12 help
13 Say Y here to enable the raw mode driver which passes raw IR signal
14 changes to the IR raw decoders for software decoding. This is much
15 less reliable (due to lack of timestamps) and consumes more
16 processing power than using hardware decode, but can be useful for
17 testing, debug, and to make more protocols available.
18
19config IR_IMG_HW
20 bool "Hardware decoder"
21 depends on IR_IMG
22 help
23 Say Y here to enable the hardware decode driver which decodes the IR
24 signals in hardware. This is more reliable, consumes less processing
25 power since only a single interrupt is received for each scancode,
26 and allows an IR scancode to be used as a wake event.
27
28config IR_IMG_NEC
29 bool "NEC protocol support"
30 depends on IR_IMG_HW
31 help
32 Say Y here to enable support for the NEC, extended NEC, and 32-bit
33 NEC protocols in the ImgTec infrared decoder block.
34
35config IR_IMG_JVC
36 bool "JVC protocol support"
37 depends on IR_IMG_HW
38 help
39 Say Y here to enable support for the JVC protocol in the ImgTec
40 infrared decoder block.
41
42config IR_IMG_SONY
43 bool "Sony protocol support"
44 depends on IR_IMG_HW
45 help
46 Say Y here to enable support for the Sony protocol in the ImgTec
47 infrared decoder block.
48
49config IR_IMG_SHARP
50 bool "Sharp protocol support"
51 depends on IR_IMG_HW
52 help
53 Say Y here to enable support for the Sharp protocol in the ImgTec
54 infrared decoder block.
55
56config IR_IMG_SANYO
57 bool "Sanyo protocol support"
58 depends on IR_IMG_HW
59 help
60 Say Y here to enable support for the Sanyo protocol (used by Sanyo,
61 Aiwa, Chinon remotes) in the ImgTec infrared decoder block.
diff --git a/drivers/media/rc/img-ir/Makefile b/drivers/media/rc/img-ir/Makefile
new file mode 100644
index 000000000000..92a459d99509
--- /dev/null
+++ b/drivers/media/rc/img-ir/Makefile
@@ -0,0 +1,11 @@
1img-ir-y := img-ir-core.o
2img-ir-$(CONFIG_IR_IMG_RAW) += img-ir-raw.o
3img-ir-$(CONFIG_IR_IMG_HW) += img-ir-hw.o
4img-ir-$(CONFIG_IR_IMG_NEC) += img-ir-nec.o
5img-ir-$(CONFIG_IR_IMG_JVC) += img-ir-jvc.o
6img-ir-$(CONFIG_IR_IMG_SONY) += img-ir-sony.o
7img-ir-$(CONFIG_IR_IMG_SHARP) += img-ir-sharp.o
8img-ir-$(CONFIG_IR_IMG_SANYO) += img-ir-sanyo.o
9img-ir-objs := $(img-ir-y)
10
11obj-$(CONFIG_IR_IMG) += img-ir.o
diff --git a/drivers/media/rc/img-ir/img-ir-core.c b/drivers/media/rc/img-ir/img-ir-core.c
new file mode 100644
index 000000000000..6b7834834fb8
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-core.c
@@ -0,0 +1,176 @@
1/*
2 * ImgTec IR Decoder found in PowerDown Controller.
3 *
4 * Copyright 2010-2014 Imagination Technologies Ltd.
5 *
6 * This contains core img-ir code for setting up the driver. The two interfaces
7 * (raw and hardware decode) are handled separately.
8 */
9
10#include <linux/clk.h>
11#include <linux/init.h>
12#include <linux/interrupt.h>
13#include <linux/io.h>
14#include <linux/module.h>
15#include <linux/platform_device.h>
16#include <linux/slab.h>
17#include <linux/spinlock.h>
18#include "img-ir.h"
19
20static irqreturn_t img_ir_isr(int irq, void *dev_id)
21{
22 struct img_ir_priv *priv = dev_id;
23 u32 irq_status;
24
25 spin_lock(&priv->lock);
26 /* we have to clear irqs before reading */
27 irq_status = img_ir_read(priv, IMG_IR_IRQ_STATUS);
28 img_ir_write(priv, IMG_IR_IRQ_CLEAR, irq_status);
29
30 /* don't handle valid data irqs if we're only interested in matches */
31 irq_status &= img_ir_read(priv, IMG_IR_IRQ_ENABLE);
32
33 /* hand off edge interrupts to raw decode handler */
34 if (irq_status & IMG_IR_IRQ_EDGE && img_ir_raw_enabled(&priv->raw))
35 img_ir_isr_raw(priv, irq_status);
36
37 /* hand off hardware match interrupts to hardware decode handler */
38 if (irq_status & (IMG_IR_IRQ_DATA_MATCH |
39 IMG_IR_IRQ_DATA_VALID |
40 IMG_IR_IRQ_DATA2_VALID) &&
41 img_ir_hw_enabled(&priv->hw))
42 img_ir_isr_hw(priv, irq_status);
43
44 spin_unlock(&priv->lock);
45 return IRQ_HANDLED;
46}
47
48static void img_ir_setup(struct img_ir_priv *priv)
49{
50 /* start off with interrupts disabled */
51 img_ir_write(priv, IMG_IR_IRQ_ENABLE, 0);
52
53 img_ir_setup_raw(priv);
54 img_ir_setup_hw(priv);
55
56 if (!IS_ERR(priv->clk))
57 clk_prepare_enable(priv->clk);
58}
59
60static void img_ir_ident(struct img_ir_priv *priv)
61{
62 u32 core_rev = img_ir_read(priv, IMG_IR_CORE_REV);
63
64 dev_info(priv->dev,
65 "IMG IR Decoder (%d.%d.%d.%d) probed successfully\n",
66 (core_rev & IMG_IR_DESIGNER) >> IMG_IR_DESIGNER_SHIFT,
67 (core_rev & IMG_IR_MAJOR_REV) >> IMG_IR_MAJOR_REV_SHIFT,
68 (core_rev & IMG_IR_MINOR_REV) >> IMG_IR_MINOR_REV_SHIFT,
69 (core_rev & IMG_IR_MAINT_REV) >> IMG_IR_MAINT_REV_SHIFT);
70 dev_info(priv->dev, "Modes:%s%s\n",
71 img_ir_hw_enabled(&priv->hw) ? " hardware" : "",
72 img_ir_raw_enabled(&priv->raw) ? " raw" : "");
73}
74
75static int img_ir_probe(struct platform_device *pdev)
76{
77 struct img_ir_priv *priv;
78 struct resource *res_regs;
79 int irq, error, error2;
80
81 /* Get resources from platform device */
82 irq = platform_get_irq(pdev, 0);
83 if (irq < 0) {
84 dev_err(&pdev->dev, "cannot find IRQ resource\n");
85 return irq;
86 }
87
88 /* Private driver data */
89 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
90 if (!priv) {
91 dev_err(&pdev->dev, "cannot allocate device data\n");
92 return -ENOMEM;
93 }
94 platform_set_drvdata(pdev, priv);
95 priv->dev = &pdev->dev;
96 spin_lock_init(&priv->lock);
97
98 /* Ioremap the registers */
99 res_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
100 priv->reg_base = devm_ioremap_resource(&pdev->dev, res_regs);
101 if (IS_ERR(priv->reg_base))
102 return PTR_ERR(priv->reg_base);
103
104 /* Get core clock */
105 priv->clk = devm_clk_get(&pdev->dev, "core");
106 if (IS_ERR(priv->clk))
107 dev_warn(&pdev->dev, "cannot get core clock resource\n");
108 /*
109 * The driver doesn't need to know about the system ("sys") or power
110 * modulation ("mod") clocks yet
111 */
112
113 /* Set up raw & hw decoder */
114 error = img_ir_probe_raw(priv);
115 error2 = img_ir_probe_hw(priv);
116 if (error && error2)
117 return (error == -ENODEV) ? error2 : error;
118
119 /* Get the IRQ */
120 priv->irq = irq;
121 error = request_irq(priv->irq, img_ir_isr, 0, "img-ir", priv);
122 if (error) {
123 dev_err(&pdev->dev, "cannot register IRQ %u\n",
124 priv->irq);
125 error = -EIO;
126 goto err_irq;
127 }
128
129 img_ir_ident(priv);
130 img_ir_setup(priv);
131
132 return 0;
133
134err_irq:
135 img_ir_remove_hw(priv);
136 img_ir_remove_raw(priv);
137 return error;
138}
139
140static int img_ir_remove(struct platform_device *pdev)
141{
142 struct img_ir_priv *priv = platform_get_drvdata(pdev);
143
144 free_irq(priv->irq, img_ir_isr);
145 img_ir_remove_hw(priv);
146 img_ir_remove_raw(priv);
147
148 if (!IS_ERR(priv->clk))
149 clk_disable_unprepare(priv->clk);
150 return 0;
151}
152
153static SIMPLE_DEV_PM_OPS(img_ir_pmops, img_ir_suspend, img_ir_resume);
154
155static const struct of_device_id img_ir_match[] = {
156 { .compatible = "img,ir-rev1" },
157 {}
158};
159MODULE_DEVICE_TABLE(of, img_ir_match);
160
161static struct platform_driver img_ir_driver = {
162 .driver = {
163 .name = "img-ir",
164 .owner = THIS_MODULE,
165 .of_match_table = img_ir_match,
166 .pm = &img_ir_pmops,
167 },
168 .probe = img_ir_probe,
169 .remove = img_ir_remove,
170};
171
172module_platform_driver(img_ir_driver);
173
174MODULE_AUTHOR("Imagination Technologies Ltd.");
175MODULE_DESCRIPTION("ImgTec IR");
176MODULE_LICENSE("GPL");
diff --git a/drivers/media/rc/img-ir/img-ir-hw.c b/drivers/media/rc/img-ir/img-ir-hw.c
new file mode 100644
index 000000000000..579a52b3edce
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -0,0 +1,1053 @@
1/*
2 * ImgTec IR Hardware Decoder found in PowerDown Controller.
3 *
4 * Copyright 2010-2014 Imagination Technologies Ltd.
5 *
6 * This ties into the input subsystem using the RC-core. Protocol support is
7 * provided in separate modules which provide the parameters and scancode
8 * translation functions to set up the hardware decoder and interpret the
9 * resulting input.
10 */
11
12#include <linux/bitops.h>
13#include <linux/clk.h>
14#include <linux/interrupt.h>
15#include <linux/spinlock.h>
16#include <linux/timer.h>
17#include <media/rc-core.h>
18#include "img-ir.h"
19
20/* Decoders lock (only modified to preprocess them) */
21static DEFINE_SPINLOCK(img_ir_decoders_lock);
22
23extern struct img_ir_decoder img_ir_nec;
24extern struct img_ir_decoder img_ir_jvc;
25extern struct img_ir_decoder img_ir_sony;
26extern struct img_ir_decoder img_ir_sharp;
27extern struct img_ir_decoder img_ir_sanyo;
28
29static bool img_ir_decoders_preprocessed;
30static struct img_ir_decoder *img_ir_decoders[] = {
31#ifdef CONFIG_IR_IMG_NEC
32 &img_ir_nec,
33#endif
34#ifdef CONFIG_IR_IMG_JVC
35 &img_ir_jvc,
36#endif
37#ifdef CONFIG_IR_IMG_SONY
38 &img_ir_sony,
39#endif
40#ifdef CONFIG_IR_IMG_SHARP
41 &img_ir_sharp,
42#endif
43#ifdef CONFIG_IR_IMG_SANYO
44 &img_ir_sanyo,
45#endif
46 NULL
47};
48
49#define IMG_IR_F_FILTER BIT(RC_FILTER_NORMAL) /* enable filtering */
50#define IMG_IR_F_WAKE BIT(RC_FILTER_WAKEUP) /* enable waking */
51
52/* code type quirks */
53
54#define IMG_IR_QUIRK_CODE_BROKEN 0x1 /* Decode is broken */
55#define IMG_IR_QUIRK_CODE_LEN_INCR 0x2 /* Bit length needs increment */
56
57/* functions for preprocessing timings, ensuring max is set */
58
59static void img_ir_timing_preprocess(struct img_ir_timing_range *range,
60 unsigned int unit)
61{
62 if (range->max < range->min)
63 range->max = range->min;
64 if (unit) {
65 /* multiply by unit and convert to microseconds */
66 range->min = (range->min*unit)/1000;
67 range->max = (range->max*unit + 999)/1000; /* round up */
68 }
69}
70
71static void img_ir_symbol_timing_preprocess(struct img_ir_symbol_timing *timing,
72 unsigned int unit)
73{
74 img_ir_timing_preprocess(&timing->pulse, unit);
75 img_ir_timing_preprocess(&timing->space, unit);
76}
77
78static void img_ir_timings_preprocess(struct img_ir_timings *timings,
79 unsigned int unit)
80{
81 img_ir_symbol_timing_preprocess(&timings->ldr, unit);
82 img_ir_symbol_timing_preprocess(&timings->s00, unit);
83 img_ir_symbol_timing_preprocess(&timings->s01, unit);
84 img_ir_symbol_timing_preprocess(&timings->s10, unit);
85 img_ir_symbol_timing_preprocess(&timings->s11, unit);
86 /* default s10 and s11 to s00 and s01 if no leader */
87 if (unit)
88 /* multiply by unit and convert to microseconds (round up) */
89 timings->ft.ft_min = (timings->ft.ft_min*unit + 999)/1000;
90}
91
92/* functions for filling empty fields with defaults */
93
94static void img_ir_timing_defaults(struct img_ir_timing_range *range,
95 struct img_ir_timing_range *defaults)
96{
97 if (!range->min)
98 range->min = defaults->min;
99 if (!range->max)
100 range->max = defaults->max;
101}
102
103static void img_ir_symbol_timing_defaults(struct img_ir_symbol_timing *timing,
104 struct img_ir_symbol_timing *defaults)
105{
106 img_ir_timing_defaults(&timing->pulse, &defaults->pulse);
107 img_ir_timing_defaults(&timing->space, &defaults->space);
108}
109
110static void img_ir_timings_defaults(struct img_ir_timings *timings,
111 struct img_ir_timings *defaults)
112{
113 img_ir_symbol_timing_defaults(&timings->ldr, &defaults->ldr);
114 img_ir_symbol_timing_defaults(&timings->s00, &defaults->s00);
115 img_ir_symbol_timing_defaults(&timings->s01, &defaults->s01);
116 img_ir_symbol_timing_defaults(&timings->s10, &defaults->s10);
117 img_ir_symbol_timing_defaults(&timings->s11, &defaults->s11);
118 if (!timings->ft.ft_min)
119 timings->ft.ft_min = defaults->ft.ft_min;
120}
121
122/* functions for converting timings to register values */
123
124/**
125 * img_ir_control() - Convert control struct to control register value.
126 * @control: Control data
127 *
128 * Returns: The control register value equivalent of @control.
129 */
130static u32 img_ir_control(const struct img_ir_control *control)
131{
132 u32 ctrl = control->code_type << IMG_IR_CODETYPE_SHIFT;
133 if (control->decoden)
134 ctrl |= IMG_IR_DECODEN;
135 if (control->hdrtog)
136 ctrl |= IMG_IR_HDRTOG;
137 if (control->ldrdec)
138 ctrl |= IMG_IR_LDRDEC;
139 if (control->decodinpol)
140 ctrl |= IMG_IR_DECODINPOL;
141 if (control->bitorien)
142 ctrl |= IMG_IR_BITORIEN;
143 if (control->d1validsel)
144 ctrl |= IMG_IR_D1VALIDSEL;
145 if (control->bitinv)
146 ctrl |= IMG_IR_BITINV;
147 if (control->decodend2)
148 ctrl |= IMG_IR_DECODEND2;
149 if (control->bitoriend2)
150 ctrl |= IMG_IR_BITORIEND2;
151 if (control->bitinvd2)
152 ctrl |= IMG_IR_BITINVD2;
153 return ctrl;
154}
155
156/**
157 * img_ir_timing_range_convert() - Convert microsecond range.
158 * @out: Output timing range in clock cycles with a shift.
159 * @in: Input timing range in microseconds.
160 * @tolerance: Tolerance as a fraction of 128 (roughly percent).
161 * @clock_hz: IR clock rate in Hz.
162 * @shift: Shift of output units.
163 *
164 * Converts min and max from microseconds to IR clock cycles, applies a
165 * tolerance, and shifts for the register, rounding in the right direction.
166 * Note that in and out can safely be the same object.
167 */
168static void img_ir_timing_range_convert(struct img_ir_timing_range *out,
169 const struct img_ir_timing_range *in,
170 unsigned int tolerance,
171 unsigned long clock_hz,
172 unsigned int shift)
173{
174 unsigned int min = in->min;
175 unsigned int max = in->max;
176 /* add a tolerance */
177 min = min - (min*tolerance >> 7);
178 max = max + (max*tolerance >> 7);
179 /* convert from microseconds into clock cycles */
180 min = min*clock_hz / 1000000;
181 max = (max*clock_hz + 999999) / 1000000; /* round up */
182 /* apply shift and copy to output */
183 out->min = min >> shift;
184 out->max = (max + ((1 << shift) - 1)) >> shift; /* round up */
185}
186
187/**
188 * img_ir_symbol_timing() - Convert symbol timing struct to register value.
189 * @timing: Symbol timing data
190 * @tolerance: Timing tolerance where 0-128 represents 0-100%
191 * @clock_hz: Frequency of source clock in Hz
192 * @pd_shift: Shift to apply to symbol period
193 * @w_shift: Shift to apply to symbol width
194 *
195 * Returns: Symbol timing register value based on arguments.
196 */
197static u32 img_ir_symbol_timing(const struct img_ir_symbol_timing *timing,
198 unsigned int tolerance,
199 unsigned long clock_hz,
200 unsigned int pd_shift,
201 unsigned int w_shift)
202{
203 struct img_ir_timing_range hw_pulse, hw_period;
204 /* we calculate period in hw_period, then convert in place */
205 hw_period.min = timing->pulse.min + timing->space.min;
206 hw_period.max = timing->pulse.max + timing->space.max;
207 img_ir_timing_range_convert(&hw_period, &hw_period,
208 tolerance, clock_hz, pd_shift);
209 img_ir_timing_range_convert(&hw_pulse, &timing->pulse,
210 tolerance, clock_hz, w_shift);
211 /* construct register value */
212 return (hw_period.max << IMG_IR_PD_MAX_SHIFT) |
213 (hw_period.min << IMG_IR_PD_MIN_SHIFT) |
214 (hw_pulse.max << IMG_IR_W_MAX_SHIFT) |
215 (hw_pulse.min << IMG_IR_W_MIN_SHIFT);
216}
217
218/**
219 * img_ir_free_timing() - Convert free time timing struct to register value.
220 * @timing: Free symbol timing data
221 * @clock_hz: Source clock frequency in Hz
222 *
223 * Returns: Free symbol timing register value.
224 */
225static u32 img_ir_free_timing(const struct img_ir_free_timing *timing,
226 unsigned long clock_hz)
227{
228 unsigned int minlen, maxlen, ft_min;
229 /* minlen is only 5 bits, and round minlen to multiple of 2 */
230 if (timing->minlen < 30)
231 minlen = timing->minlen & -2;
232 else
233 minlen = 30;
234 /* maxlen has maximum value of 48, and round maxlen to multiple of 2 */
235 if (timing->maxlen < 48)
236 maxlen = (timing->maxlen + 1) & -2;
237 else
238 maxlen = 48;
239 /* convert and shift ft_min, rounding upwards */
240 ft_min = (timing->ft_min*clock_hz + 999999) / 1000000;
241 ft_min = (ft_min + 7) >> 3;
242 /* construct register value */
243 return (maxlen << IMG_IR_MAXLEN_SHIFT) |
244 (minlen << IMG_IR_MINLEN_SHIFT) |
245 (ft_min << IMG_IR_FT_MIN_SHIFT);
246}
247
248/**
249 * img_ir_free_timing_dynamic() - Update free time register value.
250 * @st_ft: Static free time register value from img_ir_free_timing.
251 * @filter: Current filter which may additionally restrict min/max len.
252 *
253 * Returns: Updated free time register value based on the current filter.
254 */
255static u32 img_ir_free_timing_dynamic(u32 st_ft, struct img_ir_filter *filter)
256{
257 unsigned int minlen, maxlen, newminlen, newmaxlen;
258
259 /* round minlen, maxlen to multiple of 2 */
260 newminlen = filter->minlen & -2;
261 newmaxlen = (filter->maxlen + 1) & -2;
262 /* extract min/max len from register */
263 minlen = (st_ft & IMG_IR_MINLEN) >> IMG_IR_MINLEN_SHIFT;
264 maxlen = (st_ft & IMG_IR_MAXLEN) >> IMG_IR_MAXLEN_SHIFT;
265 /* if the new values are more restrictive, update the register value */
266 if (newminlen > minlen) {
267 st_ft &= ~IMG_IR_MINLEN;
268 st_ft |= newminlen << IMG_IR_MINLEN_SHIFT;
269 }
270 if (newmaxlen < maxlen) {
271 st_ft &= ~IMG_IR_MAXLEN;
272 st_ft |= newmaxlen << IMG_IR_MAXLEN_SHIFT;
273 }
274 return st_ft;
275}
276
277/**
278 * img_ir_timings_convert() - Convert timings to register values
279 * @regs: Output timing register values
280 * @timings: Input timing data
281 * @tolerance: Timing tolerance where 0-128 represents 0-100%
282 * @clock_hz: Source clock frequency in Hz
283 */
284static void img_ir_timings_convert(struct img_ir_timing_regvals *regs,
285 const struct img_ir_timings *timings,
286 unsigned int tolerance,
287 unsigned int clock_hz)
288{
289 /* leader symbol timings are divided by 16 */
290 regs->ldr = img_ir_symbol_timing(&timings->ldr, tolerance, clock_hz,
291 4, 4);
292 /* other symbol timings, pd fields only are divided by 2 */
293 regs->s00 = img_ir_symbol_timing(&timings->s00, tolerance, clock_hz,
294 1, 0);
295 regs->s01 = img_ir_symbol_timing(&timings->s01, tolerance, clock_hz,
296 1, 0);
297 regs->s10 = img_ir_symbol_timing(&timings->s10, tolerance, clock_hz,
298 1, 0);
299 regs->s11 = img_ir_symbol_timing(&timings->s11, tolerance, clock_hz,
300 1, 0);
301 regs->ft = img_ir_free_timing(&timings->ft, clock_hz);
302}
303
304/**
305 * img_ir_decoder_preprocess() - Preprocess timings in decoder.
306 * @decoder: Decoder to be preprocessed.
307 *
308 * Ensures that the symbol timing ranges are valid with respect to ordering, and
309 * does some fixed conversion on them.
310 */
311static void img_ir_decoder_preprocess(struct img_ir_decoder *decoder)
312{
313 /* default tolerance */
314 if (!decoder->tolerance)
315 decoder->tolerance = 10; /* percent */
316 /* and convert tolerance to fraction out of 128 */
317 decoder->tolerance = decoder->tolerance * 128 / 100;
318
319 /* fill in implicit fields */
320 img_ir_timings_preprocess(&decoder->timings, decoder->unit);
321
322 /* do the same for repeat timings if applicable */
323 if (decoder->repeat) {
324 img_ir_timings_preprocess(&decoder->rtimings, decoder->unit);
325 img_ir_timings_defaults(&decoder->rtimings, &decoder->timings);
326 }
327}
328
329/**
330 * img_ir_decoder_convert() - Generate internal timings in decoder.
331 * @decoder: Decoder to be converted to internal timings.
332 * @timings: Timing register values.
333 * @clock_hz: IR clock rate in Hz.
334 *
335 * Fills out the repeat timings and timing register values for a specific clock
336 * rate.
337 */
338static void img_ir_decoder_convert(const struct img_ir_decoder *decoder,
339 struct img_ir_reg_timings *reg_timings,
340 unsigned int clock_hz)
341{
342 /* calculate control value */
343 reg_timings->ctrl = img_ir_control(&decoder->control);
344
345 /* fill in implicit fields and calculate register values */
346 img_ir_timings_convert(&reg_timings->timings, &decoder->timings,
347 decoder->tolerance, clock_hz);
348
349 /* do the same for repeat timings if applicable */
350 if (decoder->repeat)
351 img_ir_timings_convert(&reg_timings->rtimings,
352 &decoder->rtimings, decoder->tolerance,
353 clock_hz);
354}
355
356/**
357 * img_ir_write_timings() - Write timings to the hardware now
358 * @priv: IR private data
359 * @regs: Timing register values to write
360 * @type: RC filter type (RC_FILTER_*)
361 *
362 * Write timing register values @regs to the hardware, taking into account the
363 * current filter which may impose restrictions on the length of the expected
364 * data.
365 */
366static void img_ir_write_timings(struct img_ir_priv *priv,
367 struct img_ir_timing_regvals *regs,
368 enum rc_filter_type type)
369{
370 struct img_ir_priv_hw *hw = &priv->hw;
371
372 /* filter may be more restrictive to minlen, maxlen */
373 u32 ft = regs->ft;
374 if (hw->flags & BIT(type))
375 ft = img_ir_free_timing_dynamic(regs->ft, &hw->filters[type]);
376 /* write to registers */
377 img_ir_write(priv, IMG_IR_LEAD_SYMB_TIMING, regs->ldr);
378 img_ir_write(priv, IMG_IR_S00_SYMB_TIMING, regs->s00);
379 img_ir_write(priv, IMG_IR_S01_SYMB_TIMING, regs->s01);
380 img_ir_write(priv, IMG_IR_S10_SYMB_TIMING, regs->s10);
381 img_ir_write(priv, IMG_IR_S11_SYMB_TIMING, regs->s11);
382 img_ir_write(priv, IMG_IR_FREE_SYMB_TIMING, ft);
383 dev_dbg(priv->dev, "timings: ldr=%#x, s=[%#x, %#x, %#x, %#x], ft=%#x\n",
384 regs->ldr, regs->s00, regs->s01, regs->s10, regs->s11, ft);
385}
386
387static void img_ir_write_filter(struct img_ir_priv *priv,
388 struct img_ir_filter *filter)
389{
390 if (filter) {
391 dev_dbg(priv->dev, "IR filter=%016llx & %016llx\n",
392 (unsigned long long)filter->data,
393 (unsigned long long)filter->mask);
394 img_ir_write(priv, IMG_IR_IRQ_MSG_DATA_LW, (u32)filter->data);
395 img_ir_write(priv, IMG_IR_IRQ_MSG_DATA_UP, (u32)(filter->data
396 >> 32));
397 img_ir_write(priv, IMG_IR_IRQ_MSG_MASK_LW, (u32)filter->mask);
398 img_ir_write(priv, IMG_IR_IRQ_MSG_MASK_UP, (u32)(filter->mask
399 >> 32));
400 } else {
401 dev_dbg(priv->dev, "IR clearing filter\n");
402 img_ir_write(priv, IMG_IR_IRQ_MSG_MASK_LW, 0);
403 img_ir_write(priv, IMG_IR_IRQ_MSG_MASK_UP, 0);
404 }
405}
406
407/* caller must have lock */
408static void _img_ir_set_filter(struct img_ir_priv *priv,
409 struct img_ir_filter *filter)
410{
411 struct img_ir_priv_hw *hw = &priv->hw;
412 u32 irq_en, irq_on;
413
414 irq_en = img_ir_read(priv, IMG_IR_IRQ_ENABLE);
415 if (filter) {
416 /* Only use the match interrupt */
417 hw->filters[RC_FILTER_NORMAL] = *filter;
418 hw->flags |= IMG_IR_F_FILTER;
419 irq_on = IMG_IR_IRQ_DATA_MATCH;
420 irq_en &= ~(IMG_IR_IRQ_DATA_VALID | IMG_IR_IRQ_DATA2_VALID);
421 } else {
422 /* Only use the valid interrupt */
423 hw->flags &= ~IMG_IR_F_FILTER;
424 irq_en &= ~IMG_IR_IRQ_DATA_MATCH;
425 irq_on = IMG_IR_IRQ_DATA_VALID | IMG_IR_IRQ_DATA2_VALID;
426 }
427 irq_en |= irq_on;
428
429 img_ir_write_filter(priv, filter);
430 /* clear any interrupts we're enabling so we don't handle old ones */
431 img_ir_write(priv, IMG_IR_IRQ_CLEAR, irq_on);
432 img_ir_write(priv, IMG_IR_IRQ_ENABLE, irq_en);
433}
434
435/* caller must have lock */
436static void _img_ir_set_wake_filter(struct img_ir_priv *priv,
437 struct img_ir_filter *filter)
438{
439 struct img_ir_priv_hw *hw = &priv->hw;
440 if (filter) {
441 /* Enable wake, and copy filter for later */
442 hw->filters[RC_FILTER_WAKEUP] = *filter;
443 hw->flags |= IMG_IR_F_WAKE;
444 } else {
445 /* Disable wake */
446 hw->flags &= ~IMG_IR_F_WAKE;
447 }
448}
449
450/* Callback for setting scancode filter */
451static int img_ir_set_filter(struct rc_dev *dev, enum rc_filter_type type,
452 struct rc_scancode_filter *sc_filter)
453{
454 struct img_ir_priv *priv = dev->priv;
455 struct img_ir_priv_hw *hw = &priv->hw;
456 struct img_ir_filter filter, *filter_ptr = &filter;
457 int ret = 0;
458
459 dev_dbg(priv->dev, "IR scancode %sfilter=%08x & %08x\n",
460 type == RC_FILTER_WAKEUP ? "wake " : "",
461 sc_filter->data,
462 sc_filter->mask);
463
464 spin_lock_irq(&priv->lock);
465
466 /* filtering can always be disabled */
467 if (!sc_filter->mask) {
468 filter_ptr = NULL;
469 goto set_unlock;
470 }
471
472 /* current decoder must support scancode filtering */
473 if (!hw->decoder || !hw->decoder->filter) {
474 ret = -EINVAL;
475 goto unlock;
476 }
477
478 /* convert scancode filter to raw filter */
479 filter.minlen = 0;
480 filter.maxlen = ~0;
481 ret = hw->decoder->filter(sc_filter, &filter, hw->enabled_protocols);
482 if (ret)
483 goto unlock;
484 dev_dbg(priv->dev, "IR raw %sfilter=%016llx & %016llx\n",
485 type == RC_FILTER_WAKEUP ? "wake " : "",
486 (unsigned long long)filter.data,
487 (unsigned long long)filter.mask);
488
489set_unlock:
490 /* apply raw filters */
491 switch (type) {
492 case RC_FILTER_NORMAL:
493 _img_ir_set_filter(priv, filter_ptr);
494 break;
495 case RC_FILTER_WAKEUP:
496 _img_ir_set_wake_filter(priv, filter_ptr);
497 break;
498 default:
499 ret = -EINVAL;
500 }
501
502unlock:
503 spin_unlock_irq(&priv->lock);
504 return ret;
505}
506
507/**
508 * img_ir_set_decoder() - Set the current decoder.
509 * @priv: IR private data.
510 * @decoder: Decoder to use with immediate effect.
511 * @proto: Protocol bitmap (or 0 to use decoder->type).
512 */
513static void img_ir_set_decoder(struct img_ir_priv *priv,
514 const struct img_ir_decoder *decoder,
515 u64 proto)
516{
517 struct img_ir_priv_hw *hw = &priv->hw;
518 struct rc_dev *rdev = hw->rdev;
519 u32 ir_status, irq_en;
520 spin_lock_irq(&priv->lock);
521
522 /* switch off and disable interrupts */
523 img_ir_write(priv, IMG_IR_CONTROL, 0);
524 irq_en = img_ir_read(priv, IMG_IR_IRQ_ENABLE);
525 img_ir_write(priv, IMG_IR_IRQ_ENABLE, irq_en & IMG_IR_IRQ_EDGE);
526 img_ir_write(priv, IMG_IR_IRQ_CLEAR, IMG_IR_IRQ_ALL & ~IMG_IR_IRQ_EDGE);
527
528 /* ack any data already detected */
529 ir_status = img_ir_read(priv, IMG_IR_STATUS);
530 if (ir_status & (IMG_IR_RXDVAL | IMG_IR_RXDVALD2)) {
531 ir_status &= ~(IMG_IR_RXDVAL | IMG_IR_RXDVALD2);
532 img_ir_write(priv, IMG_IR_STATUS, ir_status);
533 img_ir_read(priv, IMG_IR_DATA_LW);
534 img_ir_read(priv, IMG_IR_DATA_UP);
535 }
536
537 /* stop the end timer and switch back to normal mode */
538 del_timer_sync(&hw->end_timer);
539 hw->mode = IMG_IR_M_NORMAL;
540
541 /* clear the wakeup scancode filter */
542 rdev->scancode_filters[RC_FILTER_WAKEUP].data = 0;
543 rdev->scancode_filters[RC_FILTER_WAKEUP].mask = 0;
544
545 /* clear raw filters */
546 _img_ir_set_filter(priv, NULL);
547 _img_ir_set_wake_filter(priv, NULL);
548
549 /* clear the enabled protocols */
550 hw->enabled_protocols = 0;
551
552 /* switch decoder */
553 hw->decoder = decoder;
554 if (!decoder)
555 goto unlock;
556
557 /* set the enabled protocols */
558 if (!proto)
559 proto = decoder->type;
560 hw->enabled_protocols = proto;
561
562 /* write the new timings */
563 img_ir_decoder_convert(decoder, &hw->reg_timings, hw->clk_hz);
564 img_ir_write_timings(priv, &hw->reg_timings.timings, RC_FILTER_NORMAL);
565
566 /* set up and enable */
567 img_ir_write(priv, IMG_IR_CONTROL, hw->reg_timings.ctrl);
568
569
570unlock:
571 spin_unlock_irq(&priv->lock);
572}
573
574/**
575 * img_ir_decoder_compatable() - Find whether a decoder will work with a device.
576 * @priv: IR private data.
577 * @dec: Decoder to check.
578 *
579 * Returns: true if @dec is compatible with the device @priv refers to.
580 */
581static bool img_ir_decoder_compatible(struct img_ir_priv *priv,
582 const struct img_ir_decoder *dec)
583{
584 unsigned int ct;
585
586 /* don't accept decoders using code types which aren't supported */
587 ct = dec->control.code_type;
588 if (priv->hw.ct_quirks[ct] & IMG_IR_QUIRK_CODE_BROKEN)
589 return false;
590
591 return true;
592}
593
594/**
595 * img_ir_allowed_protos() - Get allowed protocols from global decoder list.
596 * @priv: IR private data.
597 *
598 * Returns: Mask of protocols supported by the device @priv refers to.
599 */
600static u64 img_ir_allowed_protos(struct img_ir_priv *priv)
601{
602 u64 protos = 0;
603 struct img_ir_decoder **decp;
604
605 for (decp = img_ir_decoders; *decp; ++decp) {
606 const struct img_ir_decoder *dec = *decp;
607 if (img_ir_decoder_compatible(priv, dec))
608 protos |= dec->type;
609 }
610 return protos;
611}
612
613/* Callback for changing protocol using sysfs */
614static int img_ir_change_protocol(struct rc_dev *dev, u64 *ir_type)
615{
616 struct img_ir_priv *priv = dev->priv;
617 struct img_ir_priv_hw *hw = &priv->hw;
618 struct rc_dev *rdev = hw->rdev;
619 struct img_ir_decoder **decp;
620 u64 wakeup_protocols;
621
622 if (!*ir_type) {
623 /* disable all protocols */
624 img_ir_set_decoder(priv, NULL, 0);
625 goto success;
626 }
627 for (decp = img_ir_decoders; *decp; ++decp) {
628 const struct img_ir_decoder *dec = *decp;
629 if (!img_ir_decoder_compatible(priv, dec))
630 continue;
631 if (*ir_type & dec->type) {
632 *ir_type &= dec->type;
633 img_ir_set_decoder(priv, dec, *ir_type);
634 goto success;
635 }
636 }
637 return -EINVAL;
638
639success:
640 /*
641 * Only allow matching wakeup protocols for now, and only if filtering
642 * is supported.
643 */
644 wakeup_protocols = *ir_type;
645 if (!hw->decoder || !hw->decoder->filter)
646 wakeup_protocols = 0;
647 rc_set_allowed_wakeup_protocols(rdev, wakeup_protocols);
648 rc_set_enabled_wakeup_protocols(rdev, wakeup_protocols);
649 return 0;
650}
651
652/* Changes ir-core protocol device attribute */
653static void img_ir_set_protocol(struct img_ir_priv *priv, u64 proto)
654{
655 struct rc_dev *rdev = priv->hw.rdev;
656
657 spin_lock_irq(&rdev->rc_map.lock);
658 rdev->rc_map.rc_type = __ffs64(proto);
659 spin_unlock_irq(&rdev->rc_map.lock);
660
661 mutex_lock(&rdev->lock);
662 rc_set_enabled_protocols(rdev, proto);
663 rc_set_allowed_wakeup_protocols(rdev, proto);
664 rc_set_enabled_wakeup_protocols(rdev, proto);
665 mutex_unlock(&rdev->lock);
666}
667
668/* Set up IR decoders */
669static void img_ir_init_decoders(void)
670{
671 struct img_ir_decoder **decp;
672
673 spin_lock(&img_ir_decoders_lock);
674 if (!img_ir_decoders_preprocessed) {
675 for (decp = img_ir_decoders; *decp; ++decp)
676 img_ir_decoder_preprocess(*decp);
677 img_ir_decoders_preprocessed = true;
678 }
679 spin_unlock(&img_ir_decoders_lock);
680}
681
682#ifdef CONFIG_PM_SLEEP
683/**
684 * img_ir_enable_wake() - Switch to wake mode.
685 * @priv: IR private data.
686 *
687 * Returns: non-zero if the IR can wake the system.
688 */
689static int img_ir_enable_wake(struct img_ir_priv *priv)
690{
691 struct img_ir_priv_hw *hw = &priv->hw;
692 int ret = 0;
693
694 spin_lock_irq(&priv->lock);
695 if (hw->flags & IMG_IR_F_WAKE) {
696 /* interrupt only on a match */
697 hw->suspend_irqen = img_ir_read(priv, IMG_IR_IRQ_ENABLE);
698 img_ir_write(priv, IMG_IR_IRQ_ENABLE, IMG_IR_IRQ_DATA_MATCH);
699 img_ir_write_filter(priv, &hw->filters[RC_FILTER_WAKEUP]);
700 img_ir_write_timings(priv, &hw->reg_timings.timings,
701 RC_FILTER_WAKEUP);
702 hw->mode = IMG_IR_M_WAKE;
703 ret = 1;
704 }
705 spin_unlock_irq(&priv->lock);
706 return ret;
707}
708
709/**
710 * img_ir_disable_wake() - Switch out of wake mode.
711 * @priv: IR private data
712 *
713 * Returns: 1 if the hardware should be allowed to wake from a sleep state.
714 * 0 otherwise.
715 */
716static int img_ir_disable_wake(struct img_ir_priv *priv)
717{
718 struct img_ir_priv_hw *hw = &priv->hw;
719 int ret = 0;
720
721 spin_lock_irq(&priv->lock);
722 if (hw->flags & IMG_IR_F_WAKE) {
723 /* restore normal filtering */
724 if (hw->flags & IMG_IR_F_FILTER) {
725 img_ir_write(priv, IMG_IR_IRQ_ENABLE,
726 (hw->suspend_irqen & IMG_IR_IRQ_EDGE) |
727 IMG_IR_IRQ_DATA_MATCH);
728 img_ir_write_filter(priv,
729 &hw->filters[RC_FILTER_NORMAL]);
730 } else {
731 img_ir_write(priv, IMG_IR_IRQ_ENABLE,
732 (hw->suspend_irqen & IMG_IR_IRQ_EDGE) |
733 IMG_IR_IRQ_DATA_VALID |
734 IMG_IR_IRQ_DATA2_VALID);
735 img_ir_write_filter(priv, NULL);
736 }
737 img_ir_write_timings(priv, &hw->reg_timings.timings,
738 RC_FILTER_NORMAL);
739 hw->mode = IMG_IR_M_NORMAL;
740 ret = 1;
741 }
742 spin_unlock_irq(&priv->lock);
743 return ret;
744}
745#endif /* CONFIG_PM_SLEEP */
746
747/* lock must be held */
748static void img_ir_begin_repeat(struct img_ir_priv *priv)
749{
750 struct img_ir_priv_hw *hw = &priv->hw;
751 if (hw->mode == IMG_IR_M_NORMAL) {
752 /* switch to repeat timings */
753 img_ir_write(priv, IMG_IR_CONTROL, 0);
754 hw->mode = IMG_IR_M_REPEATING;
755 img_ir_write_timings(priv, &hw->reg_timings.rtimings,
756 RC_FILTER_NORMAL);
757 img_ir_write(priv, IMG_IR_CONTROL, hw->reg_timings.ctrl);
758 }
759}
760
761/* lock must be held */
762static void img_ir_end_repeat(struct img_ir_priv *priv)
763{
764 struct img_ir_priv_hw *hw = &priv->hw;
765 if (hw->mode == IMG_IR_M_REPEATING) {
766 /* switch to normal timings */
767 img_ir_write(priv, IMG_IR_CONTROL, 0);
768 hw->mode = IMG_IR_M_NORMAL;
769 img_ir_write_timings(priv, &hw->reg_timings.timings,
770 RC_FILTER_NORMAL);
771 img_ir_write(priv, IMG_IR_CONTROL, hw->reg_timings.ctrl);
772 }
773}
774
775/* lock must be held */
776static void img_ir_handle_data(struct img_ir_priv *priv, u32 len, u64 raw)
777{
778 struct img_ir_priv_hw *hw = &priv->hw;
779 const struct img_ir_decoder *dec = hw->decoder;
780 int ret = IMG_IR_SCANCODE;
781 int scancode;
782 if (dec->scancode)
783 ret = dec->scancode(len, raw, &scancode, hw->enabled_protocols);
784 else if (len >= 32)
785 scancode = (u32)raw;
786 else if (len < 32)
787 scancode = (u32)raw & ((1 << len)-1);
788 dev_dbg(priv->dev, "data (%u bits) = %#llx\n",
789 len, (unsigned long long)raw);
790 if (ret == IMG_IR_SCANCODE) {
791 dev_dbg(priv->dev, "decoded scan code %#x\n", scancode);
792 rc_keydown(hw->rdev, scancode, 0);
793 img_ir_end_repeat(priv);
794 } else if (ret == IMG_IR_REPEATCODE) {
795 if (hw->mode == IMG_IR_M_REPEATING) {
796 dev_dbg(priv->dev, "decoded repeat code\n");
797 rc_repeat(hw->rdev);
798 } else {
799 dev_dbg(priv->dev, "decoded unexpected repeat code, ignoring\n");
800 }
801 } else {
802 dev_dbg(priv->dev, "decode failed (%d)\n", ret);
803 return;
804 }
805
806
807 if (dec->repeat) {
808 unsigned long interval;
809
810 img_ir_begin_repeat(priv);
811
812 /* update timer, but allowing for 1/8th tolerance */
813 interval = dec->repeat + (dec->repeat >> 3);
814 mod_timer(&hw->end_timer,
815 jiffies + msecs_to_jiffies(interval));
816 }
817}
818
819/* timer function to end waiting for repeat. */
820static void img_ir_end_timer(unsigned long arg)
821{
822 struct img_ir_priv *priv = (struct img_ir_priv *)arg;
823
824 spin_lock_irq(&priv->lock);
825 img_ir_end_repeat(priv);
826 spin_unlock_irq(&priv->lock);
827}
828
829#ifdef CONFIG_COMMON_CLK
830static void img_ir_change_frequency(struct img_ir_priv *priv,
831 struct clk_notifier_data *change)
832{
833 struct img_ir_priv_hw *hw = &priv->hw;
834
835 dev_dbg(priv->dev, "clk changed %lu HZ -> %lu HZ\n",
836 change->old_rate, change->new_rate);
837
838 spin_lock_irq(&priv->lock);
839 if (hw->clk_hz == change->new_rate)
840 goto unlock;
841 hw->clk_hz = change->new_rate;
842 /* refresh current timings */
843 if (hw->decoder) {
844 img_ir_decoder_convert(hw->decoder, &hw->reg_timings,
845 hw->clk_hz);
846 switch (hw->mode) {
847 case IMG_IR_M_NORMAL:
848 img_ir_write_timings(priv, &hw->reg_timings.timings,
849 RC_FILTER_NORMAL);
850 break;
851 case IMG_IR_M_REPEATING:
852 img_ir_write_timings(priv, &hw->reg_timings.rtimings,
853 RC_FILTER_NORMAL);
854 break;
855#ifdef CONFIG_PM_SLEEP
856 case IMG_IR_M_WAKE:
857 img_ir_write_timings(priv, &hw->reg_timings.timings,
858 RC_FILTER_WAKEUP);
859 break;
860#endif
861 }
862 }
863unlock:
864 spin_unlock_irq(&priv->lock);
865}
866
867static int img_ir_clk_notify(struct notifier_block *self, unsigned long action,
868 void *data)
869{
870 struct img_ir_priv *priv = container_of(self, struct img_ir_priv,
871 hw.clk_nb);
872 switch (action) {
873 case POST_RATE_CHANGE:
874 img_ir_change_frequency(priv, data);
875 break;
876 default:
877 break;
878 }
879 return NOTIFY_OK;
880}
881#endif /* CONFIG_COMMON_CLK */
882
883/* called with priv->lock held */
884void img_ir_isr_hw(struct img_ir_priv *priv, u32 irq_status)
885{
886 struct img_ir_priv_hw *hw = &priv->hw;
887 u32 ir_status, len, lw, up;
888 unsigned int ct;
889
890 /* use the current decoder */
891 if (!hw->decoder)
892 return;
893
894 ir_status = img_ir_read(priv, IMG_IR_STATUS);
895 if (!(ir_status & (IMG_IR_RXDVAL | IMG_IR_RXDVALD2)))
896 return;
897 ir_status &= ~(IMG_IR_RXDVAL | IMG_IR_RXDVALD2);
898 img_ir_write(priv, IMG_IR_STATUS, ir_status);
899
900 len = (ir_status & IMG_IR_RXDLEN) >> IMG_IR_RXDLEN_SHIFT;
901 /* some versions report wrong length for certain code types */
902 ct = hw->decoder->control.code_type;
903 if (hw->ct_quirks[ct] & IMG_IR_QUIRK_CODE_LEN_INCR)
904 ++len;
905
906 lw = img_ir_read(priv, IMG_IR_DATA_LW);
907 up = img_ir_read(priv, IMG_IR_DATA_UP);
908 img_ir_handle_data(priv, len, (u64)up << 32 | lw);
909}
910
911void img_ir_setup_hw(struct img_ir_priv *priv)
912{
913 struct img_ir_decoder **decp;
914
915 if (!priv->hw.rdev)
916 return;
917
918 /* Use the first available decoder (or disable stuff if NULL) */
919 for (decp = img_ir_decoders; *decp; ++decp) {
920 const struct img_ir_decoder *dec = *decp;
921 if (img_ir_decoder_compatible(priv, dec)) {
922 img_ir_set_protocol(priv, dec->type);
923 img_ir_set_decoder(priv, dec, 0);
924 return;
925 }
926 }
927 img_ir_set_decoder(priv, NULL, 0);
928}
929
930/**
931 * img_ir_probe_hw_caps() - Probe capabilities of the hardware.
932 * @priv: IR private data.
933 */
934static void img_ir_probe_hw_caps(struct img_ir_priv *priv)
935{
936 struct img_ir_priv_hw *hw = &priv->hw;
937 /*
938 * When a version of the block becomes available without these quirks,
939 * they'll have to depend on the core revision.
940 */
941 hw->ct_quirks[IMG_IR_CODETYPE_PULSELEN]
942 |= IMG_IR_QUIRK_CODE_LEN_INCR;
943 hw->ct_quirks[IMG_IR_CODETYPE_BIPHASE]
944 |= IMG_IR_QUIRK_CODE_BROKEN;
945 hw->ct_quirks[IMG_IR_CODETYPE_2BITPULSEPOS]
946 |= IMG_IR_QUIRK_CODE_BROKEN;
947}
948
949int img_ir_probe_hw(struct img_ir_priv *priv)
950{
951 struct img_ir_priv_hw *hw = &priv->hw;
952 struct rc_dev *rdev;
953 int error;
954
955 /* Ensure hardware decoders have been preprocessed */
956 img_ir_init_decoders();
957
958 /* Probe hardware capabilities */
959 img_ir_probe_hw_caps(priv);
960
961 /* Set up the end timer */
962 setup_timer(&hw->end_timer, img_ir_end_timer, (unsigned long)priv);
963
964 /* Register a clock notifier */
965 if (!IS_ERR(priv->clk)) {
966 hw->clk_hz = clk_get_rate(priv->clk);
967#ifdef CONFIG_COMMON_CLK
968 hw->clk_nb.notifier_call = img_ir_clk_notify;
969 error = clk_notifier_register(priv->clk, &hw->clk_nb);
970 if (error)
971 dev_warn(priv->dev,
972 "failed to register clock notifier\n");
973#endif
974 } else {
975 hw->clk_hz = 32768;
976 }
977
978 /* Allocate hardware decoder */
979 hw->rdev = rdev = rc_allocate_device();
980 if (!rdev) {
981 dev_err(priv->dev, "cannot allocate input device\n");
982 error = -ENOMEM;
983 goto err_alloc_rc;
984 }
985 rdev->priv = priv;
986 rdev->map_name = RC_MAP_EMPTY;
987 rc_set_allowed_protocols(rdev, img_ir_allowed_protos(priv));
988 rdev->input_name = "IMG Infrared Decoder";
989 rdev->s_filter = img_ir_set_filter;
990
991 /* Register hardware decoder */
992 error = rc_register_device(rdev);
993 if (error) {
994 dev_err(priv->dev, "failed to register IR input device\n");
995 goto err_register_rc;
996 }
997
998 /*
999 * Set this after rc_register_device as no protocols have been
1000 * registered yet.
1001 */
1002 rdev->change_protocol = img_ir_change_protocol;
1003
1004 device_init_wakeup(priv->dev, 1);
1005
1006 return 0;
1007
1008err_register_rc:
1009 img_ir_set_decoder(priv, NULL, 0);
1010 hw->rdev = NULL;
1011 rc_free_device(rdev);
1012err_alloc_rc:
1013#ifdef CONFIG_COMMON_CLK
1014 if (!IS_ERR(priv->clk))
1015 clk_notifier_unregister(priv->clk, &hw->clk_nb);
1016#endif
1017 return error;
1018}
1019
1020void img_ir_remove_hw(struct img_ir_priv *priv)
1021{
1022 struct img_ir_priv_hw *hw = &priv->hw;
1023 struct rc_dev *rdev = hw->rdev;
1024 if (!rdev)
1025 return;
1026 img_ir_set_decoder(priv, NULL, 0);
1027 hw->rdev = NULL;
1028 rc_unregister_device(rdev);
1029#ifdef CONFIG_COMMON_CLK
1030 if (!IS_ERR(priv->clk))
1031 clk_notifier_unregister(priv->clk, &hw->clk_nb);
1032#endif
1033}
1034
1035#ifdef CONFIG_PM_SLEEP
1036int img_ir_suspend(struct device *dev)
1037{
1038 struct img_ir_priv *priv = dev_get_drvdata(dev);
1039
1040 if (device_may_wakeup(dev) && img_ir_enable_wake(priv))
1041 enable_irq_wake(priv->irq);
1042 return 0;
1043}
1044
1045int img_ir_resume(struct device *dev)
1046{
1047 struct img_ir_priv *priv = dev_get_drvdata(dev);
1048
1049 if (device_may_wakeup(dev) && img_ir_disable_wake(priv))
1050 disable_irq_wake(priv->irq);
1051 return 0;
1052}
1053#endif /* CONFIG_PM_SLEEP */
diff --git a/drivers/media/rc/img-ir/img-ir-hw.h b/drivers/media/rc/img-ir/img-ir-hw.h
new file mode 100644
index 000000000000..6c9a94a81190
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-hw.h
@@ -0,0 +1,269 @@
1/*
2 * ImgTec IR Hardware Decoder found in PowerDown Controller.
3 *
4 * Copyright 2010-2014 Imagination Technologies Ltd.
5 */
6
7#ifndef _IMG_IR_HW_H_
8#define _IMG_IR_HW_H_
9
10#include <linux/kernel.h>
11#include <media/rc-core.h>
12
13/* constants */
14
15#define IMG_IR_CODETYPE_PULSELEN 0x0 /* Sony */
16#define IMG_IR_CODETYPE_PULSEDIST 0x1 /* NEC, Toshiba, Micom, Sharp */
17#define IMG_IR_CODETYPE_BIPHASE 0x2 /* RC-5/6 */
18#define IMG_IR_CODETYPE_2BITPULSEPOS 0x3 /* RC-MM */
19
20
21/* Timing information */
22
23/**
24 * struct img_ir_control - Decoder control settings
25 * @decoden: Primary decoder enable
26 * @code_type: Decode type (see IMG_IR_CODETYPE_*)
27 * @hdrtog: Detect header toggle symbol after leader symbol
28 * @ldrdec: Don't discard leader if maximum width reached
29 * @decodinpol: Decoder input polarity (1=active high)
30 * @bitorien: Bit orientation (1=MSB first)
31 * @d1validsel: Decoder 2 takes over if it detects valid data
32 * @bitinv: Bit inversion switch (1=don't invert)
33 * @decodend2: Secondary decoder enable (no leader symbol)
34 * @bitoriend2: Bit orientation (1=MSB first)
35 * @bitinvd2: Secondary decoder bit inversion switch (1=don't invert)
36 */
37struct img_ir_control {
38 unsigned decoden:1;
39 unsigned code_type:2;
40 unsigned hdrtog:1;
41 unsigned ldrdec:1;
42 unsigned decodinpol:1;
43 unsigned bitorien:1;
44 unsigned d1validsel:1;
45 unsigned bitinv:1;
46 unsigned decodend2:1;
47 unsigned bitoriend2:1;
48 unsigned bitinvd2:1;
49};
50
51/**
52 * struct img_ir_timing_range - range of timing values
53 * @min: Minimum timing value
54 * @max: Maximum timing value (if < @min, this will be set to @min during
55 * preprocessing step, so it is normally not explicitly initialised
56 * and is taken care of by the tolerance)
57 */
58struct img_ir_timing_range {
59 u16 min;
60 u16 max;
61};
62
63/**
64 * struct img_ir_symbol_timing - timing data for a symbol
65 * @pulse: Timing range for the length of the pulse in this symbol
66 * @space: Timing range for the length of the space in this symbol
67 */
68struct img_ir_symbol_timing {
69 struct img_ir_timing_range pulse;
70 struct img_ir_timing_range space;
71};
72
73/**
74 * struct img_ir_free_timing - timing data for free time symbol
75 * @minlen: Minimum number of bits of data
76 * @maxlen: Maximum number of bits of data
77 * @ft_min: Minimum free time after message
78 */
79struct img_ir_free_timing {
80 /* measured in bits */
81 u8 minlen;
82 u8 maxlen;
83 u16 ft_min;
84};
85
86/**
87 * struct img_ir_timings - Timing values.
88 * @ldr: Leader symbol timing data
89 * @s00: Zero symbol timing data for primary decoder
90 * @s01: One symbol timing data for primary decoder
91 * @s10: Zero symbol timing data for secondary (no leader symbol) decoder
92 * @s11: One symbol timing data for secondary (no leader symbol) decoder
93 * @ft: Free time symbol timing data
94 */
95struct img_ir_timings {
96 struct img_ir_symbol_timing ldr, s00, s01, s10, s11;
97 struct img_ir_free_timing ft;
98};
99
100/**
101 * struct img_ir_filter - Filter IR events.
102 * @data: Data to match.
103 * @mask: Mask of bits to compare.
104 * @minlen: Additional minimum number of bits.
105 * @maxlen: Additional maximum number of bits.
106 */
107struct img_ir_filter {
108 u64 data;
109 u64 mask;
110 u8 minlen;
111 u8 maxlen;
112};
113
114/**
115 * struct img_ir_timing_regvals - Calculated timing register values.
116 * @ldr: Leader symbol timing register value
117 * @s00: Zero symbol timing register value for primary decoder
118 * @s01: One symbol timing register value for primary decoder
119 * @s10: Zero symbol timing register value for secondary decoder
120 * @s11: One symbol timing register value for secondary decoder
121 * @ft: Free time symbol timing register value
122 */
123struct img_ir_timing_regvals {
124 u32 ldr, s00, s01, s10, s11, ft;
125};
126
127#define IMG_IR_SCANCODE 0 /* new scancode */
128#define IMG_IR_REPEATCODE 1 /* repeat the previous code */
129
130/**
131 * struct img_ir_decoder - Decoder settings for an IR protocol.
132 * @type: Protocol types bitmap.
133 * @tolerance: Timing tolerance as a percentage (default 10%).
134 * @unit: Unit of timings in nanoseconds (default 1 us).
135 * @timings: Primary timings
136 * @rtimings: Additional override timings while waiting for repeats.
137 * @repeat: Maximum repeat interval (always in milliseconds).
138 * @control: Control flags.
139 *
140 * @scancode: Pointer to function to convert the IR data into a scancode (it
141 * must be safe to execute in interrupt context).
142 * Returns IMG_IR_SCANCODE to emit new scancode.
143 * Returns IMG_IR_REPEATCODE to repeat previous code.
144 * Returns -errno (e.g. -EINVAL) on error.
145 * @filter: Pointer to function to convert scancode filter to raw hardware
146 * filter. The minlen and maxlen fields will have been initialised
147 * to the maximum range.
148 */
149struct img_ir_decoder {
150 /* core description */
151 u64 type;
152 unsigned int tolerance;
153 unsigned int unit;
154 struct img_ir_timings timings;
155 struct img_ir_timings rtimings;
156 unsigned int repeat;
157 struct img_ir_control control;
158
159 /* scancode logic */
160 int (*scancode)(int len, u64 raw, int *scancode, u64 protocols);
161 int (*filter)(const struct rc_scancode_filter *in,
162 struct img_ir_filter *out, u64 protocols);
163};
164
165/**
166 * struct img_ir_reg_timings - Reg values for decoder timings at clock rate.
167 * @ctrl: Processed control register value.
168 * @timings: Processed primary timings.
169 * @rtimings: Processed repeat timings.
170 */
171struct img_ir_reg_timings {
172 u32 ctrl;
173 struct img_ir_timing_regvals timings;
174 struct img_ir_timing_regvals rtimings;
175};
176
177int img_ir_register_decoder(struct img_ir_decoder *dec);
178void img_ir_unregister_decoder(struct img_ir_decoder *dec);
179
180struct img_ir_priv;
181
182#ifdef CONFIG_IR_IMG_HW
183
184enum img_ir_mode {
185 IMG_IR_M_NORMAL,
186 IMG_IR_M_REPEATING,
187#ifdef CONFIG_PM_SLEEP
188 IMG_IR_M_WAKE,
189#endif
190};
191
192/**
193 * struct img_ir_priv_hw - Private driver data for hardware decoder.
194 * @ct_quirks: Quirk bits for each code type.
195 * @rdev: Remote control device
196 * @clk_nb: Notifier block for clock notify events.
197 * @end_timer: Timer until repeat timeout.
198 * @decoder: Current decoder settings.
199 * @enabled_protocols: Currently enabled protocols.
200 * @clk_hz: Current core clock rate in Hz.
201 * @reg_timings: Timing reg values for decoder at clock rate.
202 * @flags: IMG_IR_F_*.
203 * @filters: HW filters (derived from scancode filters).
204 * @mode: Current decode mode.
205 * @suspend_irqen: Saved IRQ enable mask over suspend.
206 */
207struct img_ir_priv_hw {
208 unsigned int ct_quirks[4];
209 struct rc_dev *rdev;
210 struct notifier_block clk_nb;
211 struct timer_list end_timer;
212 const struct img_ir_decoder *decoder;
213 u64 enabled_protocols;
214 unsigned long clk_hz;
215 struct img_ir_reg_timings reg_timings;
216 unsigned int flags;
217 struct img_ir_filter filters[RC_FILTER_MAX];
218
219 enum img_ir_mode mode;
220 u32 suspend_irqen;
221};
222
223static inline bool img_ir_hw_enabled(struct img_ir_priv_hw *hw)
224{
225 return hw->rdev;
226};
227
228void img_ir_isr_hw(struct img_ir_priv *priv, u32 irq_status);
229void img_ir_setup_hw(struct img_ir_priv *priv);
230int img_ir_probe_hw(struct img_ir_priv *priv);
231void img_ir_remove_hw(struct img_ir_priv *priv);
232
233#ifdef CONFIG_PM_SLEEP
234int img_ir_suspend(struct device *dev);
235int img_ir_resume(struct device *dev);
236#else
237#define img_ir_suspend NULL
238#define img_ir_resume NULL
239#endif
240
241#else
242
243struct img_ir_priv_hw {
244};
245
246static inline bool img_ir_hw_enabled(struct img_ir_priv_hw *hw)
247{
248 return false;
249};
250static inline void img_ir_isr_hw(struct img_ir_priv *priv, u32 irq_status)
251{
252}
253static inline void img_ir_setup_hw(struct img_ir_priv *priv)
254{
255}
256static inline int img_ir_probe_hw(struct img_ir_priv *priv)
257{
258 return -ENODEV;
259}
260static inline void img_ir_remove_hw(struct img_ir_priv *priv)
261{
262}
263
264#define img_ir_suspend NULL
265#define img_ir_resume NULL
266
267#endif /* CONFIG_IR_IMG_HW */
268
269#endif /* _IMG_IR_HW_H_ */
diff --git a/drivers/media/rc/img-ir/img-ir-jvc.c b/drivers/media/rc/img-ir/img-ir-jvc.c
new file mode 100644
index 000000000000..10209d200efb
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-jvc.c
@@ -0,0 +1,81 @@
1/*
2 * ImgTec IR Decoder setup for JVC protocol.
3 *
4 * Copyright 2012-2014 Imagination Technologies Ltd.
5 */
6
7#include "img-ir-hw.h"
8
9/* Convert JVC data to a scancode */
10static int img_ir_jvc_scancode(int len, u64 raw, int *scancode, u64 protocols)
11{
12 unsigned int cust, data;
13
14 if (len != 16)
15 return -EINVAL;
16
17 cust = (raw >> 0) & 0xff;
18 data = (raw >> 8) & 0xff;
19
20 *scancode = cust << 8 | data;
21 return IMG_IR_SCANCODE;
22}
23
24/* Convert JVC scancode to JVC data filter */
25static int img_ir_jvc_filter(const struct rc_scancode_filter *in,
26 struct img_ir_filter *out, u64 protocols)
27{
28 unsigned int cust, data;
29 unsigned int cust_m, data_m;
30
31 cust = (in->data >> 8) & 0xff;
32 cust_m = (in->mask >> 8) & 0xff;
33 data = (in->data >> 0) & 0xff;
34 data_m = (in->mask >> 0) & 0xff;
35
36 out->data = cust | data << 8;
37 out->mask = cust_m | data_m << 8;
38
39 return 0;
40}
41
42/*
43 * JVC decoder
44 * See also http://www.sbprojects.com/knowledge/ir/jvc.php
45 * http://support.jvc.com/consumer/support/documents/RemoteCodes.pdf
46 */
47struct img_ir_decoder img_ir_jvc = {
48 .type = RC_BIT_JVC,
49 .control = {
50 .decoden = 1,
51 .code_type = IMG_IR_CODETYPE_PULSEDIST,
52 },
53 /* main timings */
54 .unit = 527500, /* 527.5 us */
55 .timings = {
56 /* leader symbol */
57 .ldr = {
58 .pulse = { 16 /* 8.44 ms */ },
59 .space = { 8 /* 4.22 ms */ },
60 },
61 /* 0 symbol */
62 .s00 = {
63 .pulse = { 1 /* 527.5 us +-60 us */ },
64 .space = { 1 /* 527.5 us */ },
65 },
66 /* 1 symbol */
67 .s01 = {
68 .pulse = { 1 /* 527.5 us +-60 us */ },
69 .space = { 3 /* 1.5825 ms +-40 us */ },
70 },
71 /* free time */
72 .ft = {
73 .minlen = 16,
74 .maxlen = 16,
75 .ft_min = 10, /* 5.275 ms */
76 },
77 },
78 /* scancode logic */
79 .scancode = img_ir_jvc_scancode,
80 .filter = img_ir_jvc_filter,
81};
diff --git a/drivers/media/rc/img-ir/img-ir-nec.c b/drivers/media/rc/img-ir/img-ir-nec.c
new file mode 100644
index 000000000000..e7a731bc3a9b
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-nec.c
@@ -0,0 +1,148 @@
1/*
2 * ImgTec IR Decoder setup for NEC protocol.
3 *
4 * Copyright 2010-2014 Imagination Technologies Ltd.
5 */
6
7#include "img-ir-hw.h"
8
9/* Convert NEC data to a scancode */
10static int img_ir_nec_scancode(int len, u64 raw, int *scancode, u64 protocols)
11{
12 unsigned int addr, addr_inv, data, data_inv;
13 /* a repeat code has no data */
14 if (!len)
15 return IMG_IR_REPEATCODE;
16 if (len != 32)
17 return -EINVAL;
18 /* raw encoding: ddDDaaAA */
19 addr = (raw >> 0) & 0xff;
20 addr_inv = (raw >> 8) & 0xff;
21 data = (raw >> 16) & 0xff;
22 data_inv = (raw >> 24) & 0xff;
23 if ((data_inv ^ data) != 0xff) {
24 /* 32-bit NEC (used by Apple and TiVo remotes) */
25 /* scan encoding: aaAAddDD */
26 *scancode = addr_inv << 24 |
27 addr << 16 |
28 data_inv << 8 |
29 data;
30 } else if ((addr_inv ^ addr) != 0xff) {
31 /* Extended NEC */
32 /* scan encoding: AAaaDD */
33 *scancode = addr << 16 |
34 addr_inv << 8 |
35 data;
36 } else {
37 /* Normal NEC */
38 /* scan encoding: AADD */
39 *scancode = addr << 8 |
40 data;
41 }
42 return IMG_IR_SCANCODE;
43}
44
45/* Convert NEC scancode to NEC data filter */
46static int img_ir_nec_filter(const struct rc_scancode_filter *in,
47 struct img_ir_filter *out, u64 protocols)
48{
49 unsigned int addr, addr_inv, data, data_inv;
50 unsigned int addr_m, addr_inv_m, data_m, data_inv_m;
51
52 data = in->data & 0xff;
53 data_m = in->mask & 0xff;
54
55 if ((in->data | in->mask) & 0xff000000) {
56 /* 32-bit NEC (used by Apple and TiVo remotes) */
57 /* scan encoding: aaAAddDD */
58 addr_inv = (in->data >> 24) & 0xff;
59 addr_inv_m = (in->mask >> 24) & 0xff;
60 addr = (in->data >> 16) & 0xff;
61 addr_m = (in->mask >> 16) & 0xff;
62 data_inv = (in->data >> 8) & 0xff;
63 data_inv_m = (in->mask >> 8) & 0xff;
64 } else if ((in->data | in->mask) & 0x00ff0000) {
65 /* Extended NEC */
66 /* scan encoding AAaaDD */
67 addr = (in->data >> 16) & 0xff;
68 addr_m = (in->mask >> 16) & 0xff;
69 addr_inv = (in->data >> 8) & 0xff;
70 addr_inv_m = (in->mask >> 8) & 0xff;
71 data_inv = data ^ 0xff;
72 data_inv_m = data_m;
73 } else {
74 /* Normal NEC */
75 /* scan encoding: AADD */
76 addr = (in->data >> 8) & 0xff;
77 addr_m = (in->mask >> 8) & 0xff;
78 addr_inv = addr ^ 0xff;
79 addr_inv_m = addr_m;
80 data_inv = data ^ 0xff;
81 data_inv_m = data_m;
82 }
83
84 /* raw encoding: ddDDaaAA */
85 out->data = data_inv << 24 |
86 data << 16 |
87 addr_inv << 8 |
88 addr;
89 out->mask = data_inv_m << 24 |
90 data_m << 16 |
91 addr_inv_m << 8 |
92 addr_m;
93 return 0;
94}
95
96/*
97 * NEC decoder
98 * See also http://www.sbprojects.com/knowledge/ir/nec.php
99 * http://wiki.altium.com/display/ADOH/NEC+Infrared+Transmission+Protocol
100 */
101struct img_ir_decoder img_ir_nec = {
102 .type = RC_BIT_NEC,
103 .control = {
104 .decoden = 1,
105 .code_type = IMG_IR_CODETYPE_PULSEDIST,
106 },
107 /* main timings */
108 .unit = 562500, /* 562.5 us */
109 .timings = {
110 /* leader symbol */
111 .ldr = {
112 .pulse = { 16 /* 9ms */ },
113 .space = { 8 /* 4.5ms */ },
114 },
115 /* 0 symbol */
116 .s00 = {
117 .pulse = { 1 /* 562.5 us */ },
118 .space = { 1 /* 562.5 us */ },
119 },
120 /* 1 symbol */
121 .s01 = {
122 .pulse = { 1 /* 562.5 us */ },
123 .space = { 3 /* 1687.5 us */ },
124 },
125 /* free time */
126 .ft = {
127 .minlen = 32,
128 .maxlen = 32,
129 .ft_min = 10, /* 5.625 ms */
130 },
131 },
132 /* repeat codes */
133 .repeat = 108, /* 108 ms */
134 .rtimings = {
135 /* leader symbol */
136 .ldr = {
137 .space = { 4 /* 2.25 ms */ },
138 },
139 /* free time */
140 .ft = {
141 .minlen = 0, /* repeat code has no data */
142 .maxlen = 0,
143 },
144 },
145 /* scancode logic */
146 .scancode = img_ir_nec_scancode,
147 .filter = img_ir_nec_filter,
148};
diff --git a/drivers/media/rc/img-ir/img-ir-raw.c b/drivers/media/rc/img-ir/img-ir-raw.c
new file mode 100644
index 000000000000..cfb01d9e571a
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-raw.c
@@ -0,0 +1,151 @@
1/*
2 * ImgTec IR Raw Decoder found in PowerDown Controller.
3 *
4 * Copyright 2010-2014 Imagination Technologies Ltd.
5 *
6 * This ties into the input subsystem using the RC-core in raw mode. Raw IR
7 * signal edges are reported and decoded by generic software decoders.
8 */
9
10#include <linux/spinlock.h>
11#include <media/rc-core.h>
12#include "img-ir.h"
13
14#define ECHO_TIMEOUT_MS 150 /* ms between echos */
15
16/* must be called with priv->lock held */
17static void img_ir_refresh_raw(struct img_ir_priv *priv, u32 irq_status)
18{
19 struct img_ir_priv_raw *raw = &priv->raw;
20 struct rc_dev *rc_dev = priv->raw.rdev;
21 int multiple;
22 u32 ir_status;
23
24 /* find whether both rise and fall was detected */
25 multiple = ((irq_status & IMG_IR_IRQ_EDGE) == IMG_IR_IRQ_EDGE);
26 /*
27 * If so, we need to see if the level has actually changed.
28 * If it's just noise that we didn't have time to process,
29 * there's no point reporting it.
30 */
31 ir_status = img_ir_read(priv, IMG_IR_STATUS) & IMG_IR_IRRXD;
32 if (multiple && ir_status == raw->last_status)
33 return;
34 raw->last_status = ir_status;
35
36 /* report the edge to the IR raw decoders */
37 if (ir_status) /* low */
38 ir_raw_event_store_edge(rc_dev, IR_SPACE);
39 else /* high */
40 ir_raw_event_store_edge(rc_dev, IR_PULSE);
41 ir_raw_event_handle(rc_dev);
42}
43
44/* called with priv->lock held */
45void img_ir_isr_raw(struct img_ir_priv *priv, u32 irq_status)
46{
47 struct img_ir_priv_raw *raw = &priv->raw;
48
49 /* check not removing */
50 if (!raw->rdev)
51 return;
52
53 img_ir_refresh_raw(priv, irq_status);
54
55 /* start / push back the echo timer */
56 mod_timer(&raw->timer, jiffies + msecs_to_jiffies(ECHO_TIMEOUT_MS));
57}
58
59/*
60 * Echo timer callback function.
61 * The raw decoders expect to get a final sample even if there are no edges, in
62 * order to be assured of the final space. If there are no edges for a certain
63 * time we use this timer to emit a final sample to satisfy them.
64 */
65static void img_ir_echo_timer(unsigned long arg)
66{
67 struct img_ir_priv *priv = (struct img_ir_priv *)arg;
68
69 spin_lock_irq(&priv->lock);
70
71 /* check not removing */
72 if (priv->raw.rdev)
73 /*
74 * It's safe to pass irq_status=0 since it's only used to check
75 * for double edges.
76 */
77 img_ir_refresh_raw(priv, 0);
78
79 spin_unlock_irq(&priv->lock);
80}
81
82void img_ir_setup_raw(struct img_ir_priv *priv)
83{
84 u32 irq_en;
85
86 if (!priv->raw.rdev)
87 return;
88
89 /* clear and enable edge interrupts */
90 spin_lock_irq(&priv->lock);
91 irq_en = img_ir_read(priv, IMG_IR_IRQ_ENABLE);
92 irq_en |= IMG_IR_IRQ_EDGE;
93 img_ir_write(priv, IMG_IR_IRQ_CLEAR, IMG_IR_IRQ_EDGE);
94 img_ir_write(priv, IMG_IR_IRQ_ENABLE, irq_en);
95 spin_unlock_irq(&priv->lock);
96}
97
98int img_ir_probe_raw(struct img_ir_priv *priv)
99{
100 struct img_ir_priv_raw *raw = &priv->raw;
101 struct rc_dev *rdev;
102 int error;
103
104 /* Set up the echo timer */
105 setup_timer(&raw->timer, img_ir_echo_timer, (unsigned long)priv);
106
107 /* Allocate raw decoder */
108 raw->rdev = rdev = rc_allocate_device();
109 if (!rdev) {
110 dev_err(priv->dev, "cannot allocate raw input device\n");
111 return -ENOMEM;
112 }
113 rdev->priv = priv;
114 rdev->map_name = RC_MAP_EMPTY;
115 rdev->input_name = "IMG Infrared Decoder Raw";
116 rdev->driver_type = RC_DRIVER_IR_RAW;
117
118 /* Register raw decoder */
119 error = rc_register_device(rdev);
120 if (error) {
121 dev_err(priv->dev, "failed to register raw IR input device\n");
122 rc_free_device(rdev);
123 raw->rdev = NULL;
124 return error;
125 }
126
127 return 0;
128}
129
130void img_ir_remove_raw(struct img_ir_priv *priv)
131{
132 struct img_ir_priv_raw *raw = &priv->raw;
133 struct rc_dev *rdev = raw->rdev;
134 u32 irq_en;
135
136 if (!rdev)
137 return;
138
139 /* switch off and disable raw (edge) interrupts */
140 spin_lock_irq(&priv->lock);
141 raw->rdev = NULL;
142 irq_en = img_ir_read(priv, IMG_IR_IRQ_ENABLE);
143 irq_en &= ~IMG_IR_IRQ_EDGE;
144 img_ir_write(priv, IMG_IR_IRQ_ENABLE, irq_en);
145 img_ir_write(priv, IMG_IR_IRQ_CLEAR, IMG_IR_IRQ_EDGE);
146 spin_unlock_irq(&priv->lock);
147
148 rc_unregister_device(rdev);
149
150 del_timer_sync(&raw->timer);
151}
diff --git a/drivers/media/rc/img-ir/img-ir-raw.h b/drivers/media/rc/img-ir/img-ir-raw.h
new file mode 100644
index 000000000000..9802ffd51b9a
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-raw.h
@@ -0,0 +1,60 @@
1/*
2 * ImgTec IR Raw Decoder found in PowerDown Controller.
3 *
4 * Copyright 2010-2014 Imagination Technologies Ltd.
5 */
6
7#ifndef _IMG_IR_RAW_H_
8#define _IMG_IR_RAW_H_
9
10struct img_ir_priv;
11
12#ifdef CONFIG_IR_IMG_RAW
13
14/**
15 * struct img_ir_priv_raw - Private driver data for raw decoder.
16 * @rdev: Raw remote control device
17 * @timer: Timer to echo samples to keep soft decoders happy.
18 * @last_status: Last raw status bits.
19 */
20struct img_ir_priv_raw {
21 struct rc_dev *rdev;
22 struct timer_list timer;
23 u32 last_status;
24};
25
26static inline bool img_ir_raw_enabled(struct img_ir_priv_raw *raw)
27{
28 return raw->rdev;
29};
30
31void img_ir_isr_raw(struct img_ir_priv *priv, u32 irq_status);
32void img_ir_setup_raw(struct img_ir_priv *priv);
33int img_ir_probe_raw(struct img_ir_priv *priv);
34void img_ir_remove_raw(struct img_ir_priv *priv);
35
36#else
37
38struct img_ir_priv_raw {
39};
40static inline bool img_ir_raw_enabled(struct img_ir_priv_raw *raw)
41{
42 return false;
43};
44static inline void img_ir_isr_raw(struct img_ir_priv *priv, u32 irq_status)
45{
46}
47static inline void img_ir_setup_raw(struct img_ir_priv *priv)
48{
49}
50static inline int img_ir_probe_raw(struct img_ir_priv *priv)
51{
52 return -ENODEV;
53}
54static inline void img_ir_remove_raw(struct img_ir_priv *priv)
55{
56}
57
58#endif /* CONFIG_IR_IMG_RAW */
59
60#endif /* _IMG_IR_RAW_H_ */
diff --git a/drivers/media/rc/img-ir/img-ir-sanyo.c b/drivers/media/rc/img-ir/img-ir-sanyo.c
new file mode 100644
index 000000000000..c2c763e08a41
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-sanyo.c
@@ -0,0 +1,122 @@
1/*
2 * ImgTec IR Decoder setup for Sanyo protocol.
3 *
4 * Copyright 2012-2014 Imagination Technologies Ltd.
5 *
6 * From ir-sanyo-decoder.c:
7 *
8 * This protocol uses the NEC protocol timings. However, data is formatted as:
9 * 13 bits Custom Code
10 * 13 bits NOT(Custom Code)
11 * 8 bits Key data
12 * 8 bits NOT(Key data)
13 *
14 * According with LIRC, this protocol is used on Sanyo, Aiwa and Chinon
15 * Information for this protocol is available at the Sanyo LC7461 datasheet.
16 */
17
18#include "img-ir-hw.h"
19
20/* Convert Sanyo data to a scancode */
21static int img_ir_sanyo_scancode(int len, u64 raw, int *scancode, u64 protocols)
22{
23 unsigned int addr, addr_inv, data, data_inv;
24 /* a repeat code has no data */
25 if (!len)
26 return IMG_IR_REPEATCODE;
27 if (len != 42)
28 return -EINVAL;
29 addr = (raw >> 0) & 0x1fff;
30 addr_inv = (raw >> 13) & 0x1fff;
31 data = (raw >> 26) & 0xff;
32 data_inv = (raw >> 34) & 0xff;
33 /* Validate data */
34 if ((data_inv ^ data) != 0xff)
35 return -EINVAL;
36 /* Validate address */
37 if ((addr_inv ^ addr) != 0x1fff)
38 return -EINVAL;
39
40 /* Normal Sanyo */
41 *scancode = addr << 8 | data;
42 return IMG_IR_SCANCODE;
43}
44
45/* Convert Sanyo scancode to Sanyo data filter */
46static int img_ir_sanyo_filter(const struct rc_scancode_filter *in,
47 struct img_ir_filter *out, u64 protocols)
48{
49 unsigned int addr, addr_inv, data, data_inv;
50 unsigned int addr_m, data_m;
51
52 data = in->data & 0xff;
53 data_m = in->mask & 0xff;
54 data_inv = data ^ 0xff;
55
56 if (in->data & 0xff700000)
57 return -EINVAL;
58
59 addr = (in->data >> 8) & 0x1fff;
60 addr_m = (in->mask >> 8) & 0x1fff;
61 addr_inv = addr ^ 0x1fff;
62
63 out->data = (u64)data_inv << 34 |
64 (u64)data << 26 |
65 addr_inv << 13 |
66 addr;
67 out->mask = (u64)data_m << 34 |
68 (u64)data_m << 26 |
69 addr_m << 13 |
70 addr_m;
71 return 0;
72}
73
74/* Sanyo decoder */
75struct img_ir_decoder img_ir_sanyo = {
76 .type = RC_BIT_SANYO,
77 .control = {
78 .decoden = 1,
79 .code_type = IMG_IR_CODETYPE_PULSEDIST,
80 },
81 /* main timings */
82 .unit = 562500, /* 562.5 us */
83 .timings = {
84 /* leader symbol */
85 .ldr = {
86 .pulse = { 16 /* 9ms */ },
87 .space = { 8 /* 4.5ms */ },
88 },
89 /* 0 symbol */
90 .s00 = {
91 .pulse = { 1 /* 562.5 us */ },
92 .space = { 1 /* 562.5 us */ },
93 },
94 /* 1 symbol */
95 .s01 = {
96 .pulse = { 1 /* 562.5 us */ },
97 .space = { 3 /* 1687.5 us */ },
98 },
99 /* free time */
100 .ft = {
101 .minlen = 42,
102 .maxlen = 42,
103 .ft_min = 10, /* 5.625 ms */
104 },
105 },
106 /* repeat codes */
107 .repeat = 108, /* 108 ms */
108 .rtimings = {
109 /* leader symbol */
110 .ldr = {
111 .space = { 4 /* 2.25 ms */ },
112 },
113 /* free time */
114 .ft = {
115 .minlen = 0, /* repeat code has no data */
116 .maxlen = 0,
117 },
118 },
119 /* scancode logic */
120 .scancode = img_ir_sanyo_scancode,
121 .filter = img_ir_sanyo_filter,
122};
diff --git a/drivers/media/rc/img-ir/img-ir-sharp.c b/drivers/media/rc/img-ir/img-ir-sharp.c
new file mode 100644
index 000000000000..3397cc5a6794
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-sharp.c
@@ -0,0 +1,99 @@
1/*
2 * ImgTec IR Decoder setup for Sharp protocol.
3 *
4 * Copyright 2012-2014 Imagination Technologies Ltd.
5 */
6
7#include "img-ir-hw.h"
8
9/* Convert Sharp data to a scancode */
10static int img_ir_sharp_scancode(int len, u64 raw, int *scancode, u64 protocols)
11{
12 unsigned int addr, cmd, exp, chk;
13
14 if (len != 15)
15 return -EINVAL;
16
17 addr = (raw >> 0) & 0x1f;
18 cmd = (raw >> 5) & 0xff;
19 exp = (raw >> 13) & 0x1;
20 chk = (raw >> 14) & 0x1;
21
22 /* validate data */
23 if (!exp)
24 return -EINVAL;
25 if (chk)
26 /* probably the second half of the message */
27 return -EINVAL;
28
29 *scancode = addr << 8 | cmd;
30 return IMG_IR_SCANCODE;
31}
32
33/* Convert Sharp scancode to Sharp data filter */
34static int img_ir_sharp_filter(const struct rc_scancode_filter *in,
35 struct img_ir_filter *out, u64 protocols)
36{
37 unsigned int addr, cmd, exp = 0, chk = 0;
38 unsigned int addr_m, cmd_m, exp_m = 0, chk_m = 0;
39
40 addr = (in->data >> 8) & 0x1f;
41 addr_m = (in->mask >> 8) & 0x1f;
42 cmd = (in->data >> 0) & 0xff;
43 cmd_m = (in->mask >> 0) & 0xff;
44 if (cmd_m) {
45 /* if filtering commands, we can only match the first part */
46 exp = 1;
47 exp_m = 1;
48 chk = 0;
49 chk_m = 1;
50 }
51
52 out->data = addr |
53 cmd << 5 |
54 exp << 13 |
55 chk << 14;
56 out->mask = addr_m |
57 cmd_m << 5 |
58 exp_m << 13 |
59 chk_m << 14;
60
61 return 0;
62}
63
64/*
65 * Sharp decoder
66 * See also http://www.sbprojects.com/knowledge/ir/sharp.php
67 */
68struct img_ir_decoder img_ir_sharp = {
69 .type = RC_BIT_SHARP,
70 .control = {
71 .decoden = 0,
72 .decodend2 = 1,
73 .code_type = IMG_IR_CODETYPE_PULSEDIST,
74 .d1validsel = 1,
75 },
76 /* main timings */
77 .tolerance = 20, /* 20% */
78 .timings = {
79 /* 0 symbol */
80 .s10 = {
81 .pulse = { 320 /* 320 us */ },
82 .space = { 680 /* 1 ms period */ },
83 },
84 /* 1 symbol */
85 .s11 = {
86 .pulse = { 320 /* 320 us */ },
87 .space = { 1680 /* 2 ms period */ },
88 },
89 /* free time */
90 .ft = {
91 .minlen = 15,
92 .maxlen = 15,
93 .ft_min = 5000, /* 5 ms */
94 },
95 },
96 /* scancode logic */
97 .scancode = img_ir_sharp_scancode,
98 .filter = img_ir_sharp_filter,
99};
diff --git a/drivers/media/rc/img-ir/img-ir-sony.c b/drivers/media/rc/img-ir/img-ir-sony.c
new file mode 100644
index 000000000000..993409a51a71
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir-sony.c
@@ -0,0 +1,145 @@
1/*
2 * ImgTec IR Decoder setup for Sony (SIRC) protocol.
3 *
4 * Copyright 2012-2014 Imagination Technologies Ltd.
5 */
6
7#include "img-ir-hw.h"
8
9/* Convert Sony data to a scancode */
10static int img_ir_sony_scancode(int len, u64 raw, int *scancode, u64 protocols)
11{
12 unsigned int dev, subdev, func;
13
14 switch (len) {
15 case 12:
16 if (!(protocols & RC_BIT_SONY12))
17 return -EINVAL;
18 func = raw & 0x7f; /* first 7 bits */
19 raw >>= 7;
20 dev = raw & 0x1f; /* next 5 bits */
21 subdev = 0;
22 break;
23 case 15:
24 if (!(protocols & RC_BIT_SONY15))
25 return -EINVAL;
26 func = raw & 0x7f; /* first 7 bits */
27 raw >>= 7;
28 dev = raw & 0xff; /* next 8 bits */
29 subdev = 0;
30 break;
31 case 20:
32 if (!(protocols & RC_BIT_SONY20))
33 return -EINVAL;
34 func = raw & 0x7f; /* first 7 bits */
35 raw >>= 7;
36 dev = raw & 0x1f; /* next 5 bits */
37 raw >>= 5;
38 subdev = raw & 0xff; /* next 8 bits */
39 break;
40 default:
41 return -EINVAL;
42 }
43 *scancode = dev << 16 | subdev << 8 | func;
44 return IMG_IR_SCANCODE;
45}
46
47/* Convert NEC scancode to NEC data filter */
48static int img_ir_sony_filter(const struct rc_scancode_filter *in,
49 struct img_ir_filter *out, u64 protocols)
50{
51 unsigned int dev, subdev, func;
52 unsigned int dev_m, subdev_m, func_m;
53 unsigned int len = 0;
54
55 dev = (in->data >> 16) & 0xff;
56 dev_m = (in->mask >> 16) & 0xff;
57 subdev = (in->data >> 8) & 0xff;
58 subdev_m = (in->mask >> 8) & 0xff;
59 func = (in->data >> 0) & 0x7f;
60 func_m = (in->mask >> 0) & 0x7f;
61
62 if (subdev & subdev_m) {
63 /* can't encode subdev and higher device bits */
64 if (dev & dev_m & 0xe0)
65 return -EINVAL;
66 /* subdevice (extended) bits only in 20 bit encoding */
67 if (!(protocols & RC_BIT_SONY20))
68 return -EINVAL;
69 len = 20;
70 dev_m &= 0x1f;
71 } else if (dev & dev_m & 0xe0) {
72 /* upper device bits only in 15 bit encoding */
73 if (!(protocols & RC_BIT_SONY15))
74 return -EINVAL;
75 len = 15;
76 subdev_m = 0;
77 } else {
78 /*
79 * The hardware mask cannot distinguish high device bits and low
80 * extended bits, so logically AND those bits of the masks
81 * together.
82 */
83 subdev_m &= (dev_m >> 5) | 0xf8;
84 dev_m &= 0x1f;
85 }
86
87 /* ensure there aren't any bits straying between fields */
88 dev &= dev_m;
89 subdev &= subdev_m;
90
91 /* write the hardware filter */
92 out->data = func |
93 dev << 7 |
94 subdev << 15;
95 out->mask = func_m |
96 dev_m << 7 |
97 subdev_m << 15;
98
99 if (len) {
100 out->minlen = len;
101 out->maxlen = len;
102 }
103 return 0;
104}
105
106/*
107 * Sony SIRC decoder
108 * See also http://www.sbprojects.com/knowledge/ir/sirc.php
109 * http://picprojects.org.uk/projects/sirc/sonysirc.pdf
110 */
111struct img_ir_decoder img_ir_sony = {
112 .type = RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20,
113 .control = {
114 .decoden = 1,
115 .code_type = IMG_IR_CODETYPE_PULSELEN,
116 },
117 /* main timings */
118 .unit = 600000, /* 600 us */
119 .timings = {
120 /* leader symbol */
121 .ldr = {
122 .pulse = { 4 /* 2.4 ms */ },
123 .space = { 1 /* 600 us */ },
124 },
125 /* 0 symbol */
126 .s00 = {
127 .pulse = { 1 /* 600 us */ },
128 .space = { 1 /* 600 us */ },
129 },
130 /* 1 symbol */
131 .s01 = {
132 .pulse = { 2 /* 1.2 ms */ },
133 .space = { 1 /* 600 us */ },
134 },
135 /* free time */
136 .ft = {
137 .minlen = 12,
138 .maxlen = 20,
139 .ft_min = 10, /* 6 ms */
140 },
141 },
142 /* scancode logic */
143 .scancode = img_ir_sony_scancode,
144 .filter = img_ir_sony_filter,
145};
diff --git a/drivers/media/rc/img-ir/img-ir.h b/drivers/media/rc/img-ir/img-ir.h
new file mode 100644
index 000000000000..afb189394af9
--- /dev/null
+++ b/drivers/media/rc/img-ir/img-ir.h
@@ -0,0 +1,166 @@
1/*
2 * ImgTec IR Decoder found in PowerDown Controller.
3 *
4 * Copyright 2010-2014 Imagination Technologies Ltd.
5 */
6
7#ifndef _IMG_IR_H_
8#define _IMG_IR_H_
9
10#include <linux/io.h>
11#include <linux/spinlock.h>
12
13#include "img-ir-raw.h"
14#include "img-ir-hw.h"
15
16/* registers */
17
18/* relative to the start of the IR block of registers */
19#define IMG_IR_CONTROL 0x00
20#define IMG_IR_STATUS 0x04
21#define IMG_IR_DATA_LW 0x08
22#define IMG_IR_DATA_UP 0x0c
23#define IMG_IR_LEAD_SYMB_TIMING 0x10
24#define IMG_IR_S00_SYMB_TIMING 0x14
25#define IMG_IR_S01_SYMB_TIMING 0x18
26#define IMG_IR_S10_SYMB_TIMING 0x1c
27#define IMG_IR_S11_SYMB_TIMING 0x20
28#define IMG_IR_FREE_SYMB_TIMING 0x24
29#define IMG_IR_POW_MOD_PARAMS 0x28
30#define IMG_IR_POW_MOD_ENABLE 0x2c
31#define IMG_IR_IRQ_MSG_DATA_LW 0x30
32#define IMG_IR_IRQ_MSG_DATA_UP 0x34
33#define IMG_IR_IRQ_MSG_MASK_LW 0x38
34#define IMG_IR_IRQ_MSG_MASK_UP 0x3c
35#define IMG_IR_IRQ_ENABLE 0x40
36#define IMG_IR_IRQ_STATUS 0x44
37#define IMG_IR_IRQ_CLEAR 0x48
38#define IMG_IR_IRCORE_ID 0xf0
39#define IMG_IR_CORE_REV 0xf4
40#define IMG_IR_CORE_DES1 0xf8
41#define IMG_IR_CORE_DES2 0xfc
42
43
44/* field masks */
45
46/* IMG_IR_CONTROL */
47#define IMG_IR_DECODEN 0x40000000
48#define IMG_IR_CODETYPE 0x30000000
49#define IMG_IR_CODETYPE_SHIFT 28
50#define IMG_IR_HDRTOG 0x08000000
51#define IMG_IR_LDRDEC 0x04000000
52#define IMG_IR_DECODINPOL 0x02000000 /* active high */
53#define IMG_IR_BITORIEN 0x01000000 /* MSB first */
54#define IMG_IR_D1VALIDSEL 0x00008000
55#define IMG_IR_BITINV 0x00000040 /* don't invert */
56#define IMG_IR_DECODEND2 0x00000010
57#define IMG_IR_BITORIEND2 0x00000002 /* MSB first */
58#define IMG_IR_BITINVD2 0x00000001 /* don't invert */
59
60/* IMG_IR_STATUS */
61#define IMG_IR_RXDVALD2 0x00001000
62#define IMG_IR_IRRXD 0x00000400
63#define IMG_IR_TOGSTATE 0x00000200
64#define IMG_IR_RXDVAL 0x00000040
65#define IMG_IR_RXDLEN 0x0000003f
66#define IMG_IR_RXDLEN_SHIFT 0
67
68/* IMG_IR_LEAD_SYMB_TIMING, IMG_IR_Sxx_SYMB_TIMING */
69#define IMG_IR_PD_MAX 0xff000000
70#define IMG_IR_PD_MAX_SHIFT 24
71#define IMG_IR_PD_MIN 0x00ff0000
72#define IMG_IR_PD_MIN_SHIFT 16
73#define IMG_IR_W_MAX 0x0000ff00
74#define IMG_IR_W_MAX_SHIFT 8
75#define IMG_IR_W_MIN 0x000000ff
76#define IMG_IR_W_MIN_SHIFT 0
77
78/* IMG_IR_FREE_SYMB_TIMING */
79#define IMG_IR_MAXLEN 0x0007e000
80#define IMG_IR_MAXLEN_SHIFT 13
81#define IMG_IR_MINLEN 0x00001f00
82#define IMG_IR_MINLEN_SHIFT 8
83#define IMG_IR_FT_MIN 0x000000ff
84#define IMG_IR_FT_MIN_SHIFT 0
85
86/* IMG_IR_POW_MOD_PARAMS */
87#define IMG_IR_PERIOD_LEN 0x3f000000
88#define IMG_IR_PERIOD_LEN_SHIFT 24
89#define IMG_IR_PERIOD_DUTY 0x003f0000
90#define IMG_IR_PERIOD_DUTY_SHIFT 16
91#define IMG_IR_STABLE_STOP 0x00003f00
92#define IMG_IR_STABLE_STOP_SHIFT 8
93#define IMG_IR_STABLE_START 0x0000003f
94#define IMG_IR_STABLE_START_SHIFT 0
95
96/* IMG_IR_POW_MOD_ENABLE */
97#define IMG_IR_POWER_OUT_EN 0x00000002
98#define IMG_IR_POWER_MOD_EN 0x00000001
99
100/* IMG_IR_IRQ_ENABLE, IMG_IR_IRQ_STATUS, IMG_IR_IRQ_CLEAR */
101#define IMG_IR_IRQ_DEC2_ERR 0x00000080
102#define IMG_IR_IRQ_DEC_ERR 0x00000040
103#define IMG_IR_IRQ_ACT_LEVEL 0x00000020
104#define IMG_IR_IRQ_FALL_EDGE 0x00000010
105#define IMG_IR_IRQ_RISE_EDGE 0x00000008
106#define IMG_IR_IRQ_DATA_MATCH 0x00000004
107#define IMG_IR_IRQ_DATA2_VALID 0x00000002
108#define IMG_IR_IRQ_DATA_VALID 0x00000001
109#define IMG_IR_IRQ_ALL 0x000000ff
110#define IMG_IR_IRQ_EDGE (IMG_IR_IRQ_FALL_EDGE | IMG_IR_IRQ_RISE_EDGE)
111
112/* IMG_IR_CORE_ID */
113#define IMG_IR_CORE_ID 0x00ff0000
114#define IMG_IR_CORE_ID_SHIFT 16
115#define IMG_IR_CORE_CONFIG 0x0000ffff
116#define IMG_IR_CORE_CONFIG_SHIFT 0
117
118/* IMG_IR_CORE_REV */
119#define IMG_IR_DESIGNER 0xff000000
120#define IMG_IR_DESIGNER_SHIFT 24
121#define IMG_IR_MAJOR_REV 0x00ff0000
122#define IMG_IR_MAJOR_REV_SHIFT 16
123#define IMG_IR_MINOR_REV 0x0000ff00
124#define IMG_IR_MINOR_REV_SHIFT 8
125#define IMG_IR_MAINT_REV 0x000000ff
126#define IMG_IR_MAINT_REV_SHIFT 0
127
128struct device;
129struct clk;
130
131/**
132 * struct img_ir_priv - Private driver data.
133 * @dev: Platform device.
134 * @irq: IRQ number.
135 * @clk: Input clock.
136 * @reg_base: Iomem base address of IR register block.
137 * @lock: Protects IR registers and variables in this struct.
138 * @raw: Driver data for raw decoder.
139 * @hw: Driver data for hardware decoder.
140 */
141struct img_ir_priv {
142 struct device *dev;
143 int irq;
144 struct clk *clk;
145 void __iomem *reg_base;
146 spinlock_t lock;
147
148 struct img_ir_priv_raw raw;
149 struct img_ir_priv_hw hw;
150};
151
152/* Hardware access */
153
154static inline void img_ir_write(struct img_ir_priv *priv,
155 unsigned int reg_offs, unsigned int data)
156{
157 iowrite32(data, priv->reg_base + reg_offs);
158}
159
160static inline unsigned int img_ir_read(struct img_ir_priv *priv,
161 unsigned int reg_offs)
162{
163 return ioread32(priv->reg_base + reg_offs);
164}
165
166#endif /* _IMG_IR_H_ */
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 822b9f47ca72..6f24e77b1488 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -1017,7 +1017,7 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 *rc_type)
1017 unsigned char ir_proto_packet[] = { 1017 unsigned char ir_proto_packet[] = {
1018 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 }; 1018 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 };
1019 1019
1020 if (*rc_type && !(*rc_type & rc->allowed_protos)) 1020 if (*rc_type && !rc_protocols_allowed(rc, *rc_type))
1021 dev_warn(dev, "Looks like you're trying to use an IR protocol " 1021 dev_warn(dev, "Looks like you're trying to use an IR protocol "
1022 "this device does not support\n"); 1022 "this device does not support\n");
1023 1023
@@ -1867,7 +1867,8 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1867 1867
1868 rdev->priv = ictx; 1868 rdev->priv = ictx;
1869 rdev->driver_type = RC_DRIVER_SCANCODE; 1869 rdev->driver_type = RC_DRIVER_SCANCODE;
1870 rdev->allowed_protos = RC_BIT_OTHER | RC_BIT_RC6_MCE; /* iMON PAD or MCE */ 1870 /* iMON PAD or MCE */
1871 rc_set_allowed_protocols(rdev, RC_BIT_OTHER | RC_BIT_RC6_MCE);
1871 rdev->change_protocol = imon_ir_change_protocol; 1872 rdev->change_protocol = imon_ir_change_protocol;
1872 rdev->driver_name = MOD_NAME; 1873 rdev->driver_name = MOD_NAME;
1873 1874
@@ -1880,7 +1881,7 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1880 1881
1881 if (ictx->product == 0xffdc) { 1882 if (ictx->product == 0xffdc) {
1882 imon_get_ffdc_type(ictx); 1883 imon_get_ffdc_type(ictx);
1883 rdev->allowed_protos = ictx->rc_type; 1884 rc_set_allowed_protocols(rdev, ictx->rc_type);
1884 } 1885 }
1885 1886
1886 imon_set_display_type(ictx); 1887 imon_set_display_type(ictx);
diff --git a/drivers/media/rc/ir-jvc-decoder.c b/drivers/media/rc/ir-jvc-decoder.c
index 3948138ca870..4ea62a1dcfda 100644
--- a/drivers/media/rc/ir-jvc-decoder.c
+++ b/drivers/media/rc/ir-jvc-decoder.c
@@ -47,7 +47,7 @@ static int ir_jvc_decode(struct rc_dev *dev, struct ir_raw_event ev)
47{ 47{
48 struct jvc_dec *data = &dev->raw->jvc; 48 struct jvc_dec *data = &dev->raw->jvc;
49 49
50 if (!(dev->enabled_protocols & RC_BIT_JVC)) 50 if (!rc_protocols_enabled(dev, RC_BIT_JVC))
51 return 0; 51 return 0;
52 52
53 if (!is_timing_event(ev)) { 53 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index ed2c8a1ed8ca..d731da6c414d 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -35,7 +35,7 @@ static int ir_lirc_decode(struct rc_dev *dev, struct ir_raw_event ev)
35 struct lirc_codec *lirc = &dev->raw->lirc; 35 struct lirc_codec *lirc = &dev->raw->lirc;
36 int sample; 36 int sample;
37 37
38 if (!(dev->enabled_protocols & RC_BIT_LIRC)) 38 if (!rc_protocols_enabled(dev, RC_BIT_LIRC))
39 return 0; 39 return 0;
40 40
41 if (!dev->raw->lirc.drv || !dev->raw->lirc.drv->rbuf) 41 if (!dev->raw->lirc.drv || !dev->raw->lirc.drv->rbuf)
diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c
index 9f3c9b59f30c..0c55f794c8cf 100644
--- a/drivers/media/rc/ir-mce_kbd-decoder.c
+++ b/drivers/media/rc/ir-mce_kbd-decoder.c
@@ -216,7 +216,7 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev)
216 u32 scancode; 216 u32 scancode;
217 unsigned long delay; 217 unsigned long delay;
218 218
219 if (!(dev->enabled_protocols & RC_BIT_MCE_KBD)) 219 if (!rc_protocols_enabled(dev, RC_BIT_MCE_KBD))
220 return 0; 220 return 0;
221 221
222 if (!is_timing_event(ev)) { 222 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c
index 9a9009411439..9de1791d2494 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -1,6 +1,6 @@
1/* ir-nec-decoder.c - handle NEC IR Pulse/Space protocol 1/* ir-nec-decoder.c - handle NEC IR Pulse/Space protocol
2 * 2 *
3 * Copyright (C) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 3 * Copyright (C) 2010 by Mauro Carvalho Chehab
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -52,7 +52,7 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
52 u8 address, not_address, command, not_command; 52 u8 address, not_address, command, not_command;
53 bool send_32bits = false; 53 bool send_32bits = false;
54 54
55 if (!(dev->enabled_protocols & RC_BIT_NEC)) 55 if (!rc_protocols_enabled(dev, RC_BIT_NEC))
56 return 0; 56 return 0;
57 57
58 if (!is_timing_event(ev)) { 58 if (!is_timing_event(ev)) {
@@ -172,7 +172,10 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
172 if (send_32bits) { 172 if (send_32bits) {
173 /* NEC transport, but modified protocol, used by at 173 /* NEC transport, but modified protocol, used by at
174 * least Apple and TiVo remotes */ 174 * least Apple and TiVo remotes */
175 scancode = data->bits; 175 scancode = not_address << 24 |
176 address << 16 |
177 not_command << 8 |
178 command;
176 IR_dprintk(1, "NEC (modified) scancode 0x%08x\n", scancode); 179 IR_dprintk(1, "NEC (modified) scancode 0x%08x\n", scancode);
177 } else if ((address ^ not_address) != 0xff) { 180 } else if ((address ^ not_address) != 0xff) {
178 /* Extended NEC */ 181 /* Extended NEC */
@@ -222,6 +225,6 @@ module_init(ir_nec_decode_init);
222module_exit(ir_nec_decode_exit); 225module_exit(ir_nec_decode_exit);
223 226
224MODULE_LICENSE("GPL"); 227MODULE_LICENSE("GPL");
225MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 228MODULE_AUTHOR("Mauro Carvalho Chehab");
226MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)"); 229MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)");
227MODULE_DESCRIPTION("NEC IR protocol decoder"); 230MODULE_DESCRIPTION("NEC IR protocol decoder");
diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index 5c42750c7b71..763c9d131d0f 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -1,6 +1,6 @@
1/* ir-raw.c - handle IR pulse/space events 1/* ir-raw.c - handle IR pulse/space events
2 * 2 *
3 * Copyright (C) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 3 * Copyright (C) 2010 by Mauro Carvalho Chehab
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -256,7 +256,7 @@ int ir_raw_event_register(struct rc_dev *dev)
256 return -ENOMEM; 256 return -ENOMEM;
257 257
258 dev->raw->dev = dev; 258 dev->raw->dev = dev;
259 dev->enabled_protocols = ~0; 259 rc_set_enabled_protocols(dev, ~0);
260 rc = kfifo_alloc(&dev->raw->kfifo, 260 rc = kfifo_alloc(&dev->raw->kfifo,
261 sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE, 261 sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE,
262 GFP_KERNEL); 262 GFP_KERNEL);
@@ -352,6 +352,7 @@ void ir_raw_init(void)
352 load_jvc_decode(); 352 load_jvc_decode();
353 load_sony_decode(); 353 load_sony_decode();
354 load_sanyo_decode(); 354 load_sanyo_decode();
355 load_sharp_decode();
355 load_mce_kbd_decode(); 356 load_mce_kbd_decode();
356 load_lirc_codec(); 357 load_lirc_codec();
357 358
diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c
index 4e53a319c5d8..4295d9b250c8 100644
--- a/drivers/media/rc/ir-rc5-decoder.c
+++ b/drivers/media/rc/ir-rc5-decoder.c
@@ -1,6 +1,6 @@
1/* ir-rc5-decoder.c - handle RC5(x) IR Pulse/Space protocol 1/* ir-rc5-decoder.c - handle RC5(x) IR Pulse/Space protocol
2 * 2 *
3 * Copyright (C) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 3 * Copyright (C) 2010 by Mauro Carvalho Chehab
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -52,7 +52,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
52 u8 toggle; 52 u8 toggle;
53 u32 scancode; 53 u32 scancode;
54 54
55 if (!(dev->enabled_protocols & (RC_BIT_RC5 | RC_BIT_RC5X))) 55 if (!rc_protocols_enabled(dev, RC_BIT_RC5 | RC_BIT_RC5X))
56 return 0; 56 return 0;
57 57
58 if (!is_timing_event(ev)) { 58 if (!is_timing_event(ev)) {
@@ -128,7 +128,7 @@ again:
128 if (data->wanted_bits == RC5X_NBITS) { 128 if (data->wanted_bits == RC5X_NBITS) {
129 /* RC5X */ 129 /* RC5X */
130 u8 xdata, command, system; 130 u8 xdata, command, system;
131 if (!(dev->enabled_protocols & RC_BIT_RC5X)) { 131 if (!rc_protocols_enabled(dev, RC_BIT_RC5X)) {
132 data->state = STATE_INACTIVE; 132 data->state = STATE_INACTIVE;
133 return 0; 133 return 0;
134 } 134 }
@@ -145,7 +145,7 @@ again:
145 } else { 145 } else {
146 /* RC5 */ 146 /* RC5 */
147 u8 command, system; 147 u8 command, system;
148 if (!(dev->enabled_protocols & RC_BIT_RC5)) { 148 if (!rc_protocols_enabled(dev, RC_BIT_RC5)) {
149 data->state = STATE_INACTIVE; 149 data->state = STATE_INACTIVE;
150 return 0; 150 return 0;
151 } 151 }
@@ -193,6 +193,6 @@ module_init(ir_rc5_decode_init);
193module_exit(ir_rc5_decode_exit); 193module_exit(ir_rc5_decode_exit);
194 194
195MODULE_LICENSE("GPL"); 195MODULE_LICENSE("GPL");
196MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 196MODULE_AUTHOR("Mauro Carvalho Chehab");
197MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)"); 197MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)");
198MODULE_DESCRIPTION("RC5(x) IR protocol decoder"); 198MODULE_DESCRIPTION("RC5(x) IR protocol decoder");
diff --git a/drivers/media/rc/ir-rc5-sz-decoder.c b/drivers/media/rc/ir-rc5-sz-decoder.c
index 865fe84fd854..dc18b7434db8 100644
--- a/drivers/media/rc/ir-rc5-sz-decoder.c
+++ b/drivers/media/rc/ir-rc5-sz-decoder.c
@@ -1,6 +1,6 @@
1/* ir-rc5-sz-decoder.c - handle RC5 Streamzap IR Pulse/Space protocol 1/* ir-rc5-sz-decoder.c - handle RC5 Streamzap IR Pulse/Space protocol
2 * 2 *
3 * Copyright (C) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 3 * Copyright (C) 2010 by Mauro Carvalho Chehab
4 * Copyright (C) 2010 by Jarod Wilson <jarod@redhat.com> 4 * Copyright (C) 2010 by Jarod Wilson <jarod@redhat.com>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
@@ -48,7 +48,7 @@ static int ir_rc5_sz_decode(struct rc_dev *dev, struct ir_raw_event ev)
48 u8 toggle, command, system; 48 u8 toggle, command, system;
49 u32 scancode; 49 u32 scancode;
50 50
51 if (!(dev->enabled_protocols & RC_BIT_RC5_SZ)) 51 if (!rc_protocols_enabled(dev, RC_BIT_RC5_SZ))
52 return 0; 52 return 0;
53 53
54 if (!is_timing_event(ev)) { 54 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-rc6-decoder.c b/drivers/media/rc/ir-rc6-decoder.c
index 7cba7d33a3fa..cfbd64e3999c 100644
--- a/drivers/media/rc/ir-rc6-decoder.c
+++ b/drivers/media/rc/ir-rc6-decoder.c
@@ -89,9 +89,9 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev)
89 u32 scancode; 89 u32 scancode;
90 u8 toggle; 90 u8 toggle;
91 91
92 if (!(dev->enabled_protocols & 92 if (!rc_protocols_enabled(dev, RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 |
93 (RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | 93 RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 |
94 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE))) 94 RC_BIT_RC6_MCE))
95 return 0; 95 return 0;
96 96
97 if (!is_timing_event(ev)) { 97 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/ir-sanyo-decoder.c b/drivers/media/rc/ir-sanyo-decoder.c
index 0a06205b5677..eb715f04dc27 100644
--- a/drivers/media/rc/ir-sanyo-decoder.c
+++ b/drivers/media/rc/ir-sanyo-decoder.c
@@ -1,6 +1,6 @@
1/* ir-sanyo-decoder.c - handle SANYO IR Pulse/Space protocol 1/* ir-sanyo-decoder.c - handle SANYO IR Pulse/Space protocol
2 * 2 *
3 * Copyright (C) 2011 by Mauro Carvalho Chehab <mchehab@redhat.com> 3 * Copyright (C) 2011 by Mauro Carvalho Chehab
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -58,7 +58,7 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev)
58 u32 scancode; 58 u32 scancode;
59 u8 address, command, not_command; 59 u8 address, command, not_command;
60 60
61 if (!(dev->enabled_protocols & RC_BIT_SANYO)) 61 if (!rc_protocols_enabled(dev, RC_BIT_SANYO))
62 return 0; 62 return 0;
63 63
64 if (!is_timing_event(ev)) { 64 if (!is_timing_event(ev)) {
@@ -200,6 +200,6 @@ module_init(ir_sanyo_decode_init);
200module_exit(ir_sanyo_decode_exit); 200module_exit(ir_sanyo_decode_exit);
201 201
202MODULE_LICENSE("GPL"); 202MODULE_LICENSE("GPL");
203MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 203MODULE_AUTHOR("Mauro Carvalho Chehab");
204MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)"); 204MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)");
205MODULE_DESCRIPTION("SANYO IR protocol decoder"); 205MODULE_DESCRIPTION("SANYO IR protocol decoder");
diff --git a/drivers/media/rc/ir-sharp-decoder.c b/drivers/media/rc/ir-sharp-decoder.c
new file mode 100644
index 000000000000..66d20394ceaa
--- /dev/null
+++ b/drivers/media/rc/ir-sharp-decoder.c
@@ -0,0 +1,200 @@
1/* ir-sharp-decoder.c - handle Sharp IR Pulse/Space protocol
2 *
3 * Copyright (C) 2013-2014 Imagination Technologies Ltd.
4 *
5 * Based on NEC decoder:
6 * Copyright (C) 2010 by Mauro Carvalho Chehab
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 version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#include <linux/bitrev.h>
19#include <linux/module.h>
20#include "rc-core-priv.h"
21
22#define SHARP_NBITS 15
23#define SHARP_UNIT 40000 /* ns */
24#define SHARP_BIT_PULSE (8 * SHARP_UNIT) /* 320us */
25#define SHARP_BIT_0_PERIOD (25 * SHARP_UNIT) /* 1ms (680us space) */
26#define SHARP_BIT_1_PERIOD (50 * SHARP_UNIT) /* 2ms (1680ms space) */
27#define SHARP_ECHO_SPACE (1000 * SHARP_UNIT) /* 40 ms */
28#define SHARP_TRAILER_SPACE (125 * SHARP_UNIT) /* 5 ms (even longer) */
29
30enum sharp_state {
31 STATE_INACTIVE,
32 STATE_BIT_PULSE,
33 STATE_BIT_SPACE,
34 STATE_TRAILER_PULSE,
35 STATE_ECHO_SPACE,
36 STATE_TRAILER_SPACE,
37};
38
39/**
40 * ir_sharp_decode() - Decode one Sharp pulse or space
41 * @dev: the struct rc_dev descriptor of the device
42 * @duration: the struct ir_raw_event descriptor of the pulse/space
43 *
44 * This function returns -EINVAL if the pulse violates the state machine
45 */
46static int ir_sharp_decode(struct rc_dev *dev, struct ir_raw_event ev)
47{
48 struct sharp_dec *data = &dev->raw->sharp;
49 u32 msg, echo, address, command, scancode;
50
51 if (!rc_protocols_enabled(dev, RC_BIT_SHARP))
52 return 0;
53
54 if (!is_timing_event(ev)) {
55 if (ev.reset)
56 data->state = STATE_INACTIVE;
57 return 0;
58 }
59
60 IR_dprintk(2, "Sharp decode started at state %d (%uus %s)\n",
61 data->state, TO_US(ev.duration), TO_STR(ev.pulse));
62
63 switch (data->state) {
64
65 case STATE_INACTIVE:
66 if (!ev.pulse)
67 break;
68
69 if (!eq_margin(ev.duration, SHARP_BIT_PULSE,
70 SHARP_BIT_PULSE / 2))
71 break;
72
73 data->count = 0;
74 data->pulse_len = ev.duration;
75 data->state = STATE_BIT_SPACE;
76 return 0;
77
78 case STATE_BIT_PULSE:
79 if (!ev.pulse)
80 break;
81
82 if (!eq_margin(ev.duration, SHARP_BIT_PULSE,
83 SHARP_BIT_PULSE / 2))
84 break;
85
86 data->pulse_len = ev.duration;
87 data->state = STATE_BIT_SPACE;
88 return 0;
89
90 case STATE_BIT_SPACE:
91 if (ev.pulse)
92 break;
93
94 data->bits <<= 1;
95 if (eq_margin(data->pulse_len + ev.duration, SHARP_BIT_1_PERIOD,
96 SHARP_BIT_PULSE * 2))
97 data->bits |= 1;
98 else if (!eq_margin(data->pulse_len + ev.duration,
99 SHARP_BIT_0_PERIOD, SHARP_BIT_PULSE * 2))
100 break;
101 data->count++;
102
103 if (data->count == SHARP_NBITS ||
104 data->count == SHARP_NBITS * 2)
105 data->state = STATE_TRAILER_PULSE;
106 else
107 data->state = STATE_BIT_PULSE;
108
109 return 0;
110
111 case STATE_TRAILER_PULSE:
112 if (!ev.pulse)
113 break;
114
115 if (!eq_margin(ev.duration, SHARP_BIT_PULSE,
116 SHARP_BIT_PULSE / 2))
117 break;
118
119 if (data->count == SHARP_NBITS) {
120 /* exp,chk bits should be 1,0 */
121 if ((data->bits & 0x3) != 0x2)
122 break;
123 data->state = STATE_ECHO_SPACE;
124 } else {
125 data->state = STATE_TRAILER_SPACE;
126 }
127 return 0;
128
129 case STATE_ECHO_SPACE:
130 if (ev.pulse)
131 break;
132
133 if (!eq_margin(ev.duration, SHARP_ECHO_SPACE,
134 SHARP_ECHO_SPACE / 4))
135 break;
136
137 data->state = STATE_BIT_PULSE;
138
139 return 0;
140
141 case STATE_TRAILER_SPACE:
142 if (ev.pulse)
143 break;
144
145 if (!geq_margin(ev.duration, SHARP_TRAILER_SPACE,
146 SHARP_BIT_PULSE / 2))
147 break;
148
149 /* Validate - command, ext, chk should be inverted in 2nd */
150 msg = (data->bits >> 15) & 0x7fff;
151 echo = data->bits & 0x7fff;
152 if ((msg ^ echo) != 0x3ff) {
153 IR_dprintk(1,
154 "Sharp checksum error: received 0x%04x, 0x%04x\n",
155 msg, echo);
156 break;
157 }
158
159 address = bitrev8((msg >> 7) & 0xf8);
160 command = bitrev8((msg >> 2) & 0xff);
161
162 scancode = address << 8 | command;
163 IR_dprintk(1, "Sharp scancode 0x%04x\n", scancode);
164
165 rc_keydown(dev, scancode, 0);
166 data->state = STATE_INACTIVE;
167 return 0;
168 }
169
170 IR_dprintk(1, "Sharp decode failed at count %d state %d (%uus %s)\n",
171 data->count, data->state, TO_US(ev.duration),
172 TO_STR(ev.pulse));
173 data->state = STATE_INACTIVE;
174 return -EINVAL;
175}
176
177static struct ir_raw_handler sharp_handler = {
178 .protocols = RC_BIT_SHARP,
179 .decode = ir_sharp_decode,
180};
181
182static int __init ir_sharp_decode_init(void)
183{
184 ir_raw_handler_register(&sharp_handler);
185
186 pr_info("IR Sharp protocol handler initialized\n");
187 return 0;
188}
189
190static void __exit ir_sharp_decode_exit(void)
191{
192 ir_raw_handler_unregister(&sharp_handler);
193}
194
195module_init(ir_sharp_decode_init);
196module_exit(ir_sharp_decode_exit);
197
198MODULE_LICENSE("GPL");
199MODULE_AUTHOR("James Hogan <james.hogan@imgtec.com>");
200MODULE_DESCRIPTION("Sharp IR protocol decoder");
diff --git a/drivers/media/rc/ir-sony-decoder.c b/drivers/media/rc/ir-sony-decoder.c
index 29ab9c2db060..599c19a73360 100644
--- a/drivers/media/rc/ir-sony-decoder.c
+++ b/drivers/media/rc/ir-sony-decoder.c
@@ -45,8 +45,8 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
45 u32 scancode; 45 u32 scancode;
46 u8 device, subdevice, function; 46 u8 device, subdevice, function;
47 47
48 if (!(dev->enabled_protocols & 48 if (!rc_protocols_enabled(dev, RC_BIT_SONY12 | RC_BIT_SONY15 |
49 (RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20))) 49 RC_BIT_SONY20))
50 return 0; 50 return 0;
51 51
52 if (!is_timing_event(ev)) { 52 if (!is_timing_event(ev)) {
@@ -124,7 +124,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
124 124
125 switch (data->count) { 125 switch (data->count) {
126 case 12: 126 case 12:
127 if (!(dev->enabled_protocols & RC_BIT_SONY12)) { 127 if (!rc_protocols_enabled(dev, RC_BIT_SONY12)) {
128 data->state = STATE_INACTIVE; 128 data->state = STATE_INACTIVE;
129 return 0; 129 return 0;
130 } 130 }
@@ -133,7 +133,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
133 function = bitrev8((data->bits >> 4) & 0xFE); 133 function = bitrev8((data->bits >> 4) & 0xFE);
134 break; 134 break;
135 case 15: 135 case 15:
136 if (!(dev->enabled_protocols & RC_BIT_SONY15)) { 136 if (!rc_protocols_enabled(dev, RC_BIT_SONY15)) {
137 data->state = STATE_INACTIVE; 137 data->state = STATE_INACTIVE;
138 return 0; 138 return 0;
139 } 139 }
@@ -142,7 +142,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
142 function = bitrev8((data->bits >> 7) & 0xFE); 142 function = bitrev8((data->bits >> 7) & 0xFE);
143 break; 143 break;
144 case 20: 144 case 20:
145 if (!(dev->enabled_protocols & RC_BIT_SONY20)) { 145 if (!rc_protocols_enabled(dev, RC_BIT_SONY20)) {
146 data->state = STATE_INACTIVE; 146 data->state = STATE_INACTIVE;
147 return 0; 147 return 0;
148 } 148 }
diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
index 63b42252166a..ab24cc6d3655 100644
--- a/drivers/media/rc/ite-cir.c
+++ b/drivers/media/rc/ite-cir.c
@@ -1563,7 +1563,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
1563 /* set up ir-core props */ 1563 /* set up ir-core props */
1564 rdev->priv = itdev; 1564 rdev->priv = itdev;
1565 rdev->driver_type = RC_DRIVER_IR_RAW; 1565 rdev->driver_type = RC_DRIVER_IR_RAW;
1566 rdev->allowed_protos = RC_BIT_ALL; 1566 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
1567 rdev->open = ite_open; 1567 rdev->open = ite_open;
1568 rdev->close = ite_close; 1568 rdev->close = ite_close;
1569 rdev->s_idle = ite_s_idle; 1569 rdev->s_idle = ite_s_idle;
diff --git a/drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c b/drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c
index b0e42df7ff82..01d901fbfc8b 100644
--- a/drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c
+++ b/drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -87,4 +87,4 @@ module_init(init_rc_map_adstech_dvb_t_pci)
87module_exit(exit_rc_map_adstech_dvb_t_pci) 87module_exit(exit_rc_map_adstech_dvb_t_pci)
88 88
89MODULE_LICENSE("GPL"); 89MODULE_LICENSE("GPL");
90MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 90MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-apac-viewcomp.c b/drivers/media/rc/keymaps/rc-apac-viewcomp.c
index 8c92ff95f94d..bf9efa007e1c 100644
--- a/drivers/media/rc/keymaps/rc-apac-viewcomp.c
+++ b/drivers/media/rc/keymaps/rc-apac-viewcomp.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -78,4 +78,4 @@ module_init(init_rc_map_apac_viewcomp)
78module_exit(exit_rc_map_apac_viewcomp) 78module_exit(exit_rc_map_apac_viewcomp)
79 79
80MODULE_LICENSE("GPL"); 80MODULE_LICENSE("GPL");
81MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 81MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-asus-pc39.c b/drivers/media/rc/keymaps/rc-asus-pc39.c
index 2caf2117759b..9e674ba5dd4f 100644
--- a/drivers/media/rc/keymaps/rc-asus-pc39.c
+++ b/drivers/media/rc/keymaps/rc-asus-pc39.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -89,4 +89,4 @@ module_init(init_rc_map_asus_pc39)
89module_exit(exit_rc_map_asus_pc39) 89module_exit(exit_rc_map_asus_pc39)
90 90
91MODULE_LICENSE("GPL"); 91MODULE_LICENSE("GPL");
92MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 92MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-asus-ps3-100.c b/drivers/media/rc/keymaps/rc-asus-ps3-100.c
index ba76609c5936..e45de35f528f 100644
--- a/drivers/media/rc/keymaps/rc-asus-ps3-100.c
+++ b/drivers/media/rc/keymaps/rc-asus-ps3-100.c
@@ -1,6 +1,6 @@
1/* asus-ps3-100.h - Keytable for asus_ps3_100 Remote Controller 1/* asus-ps3-100.h - Keytable for asus_ps3_100 Remote Controller
2 * 2 *
3 * Copyright (c) 2012 by Mauro Carvalho Chehab <mchehab@redhat.com> 3 * Copyright (c) 2012 by Mauro Carvalho Chehab
4 * 4 *
5 * Based on a previous patch from Remi Schwartz <remi.schwartz@gmail.com> 5 * Based on a previous patch from Remi Schwartz <remi.schwartz@gmail.com>
6 * 6 *
@@ -88,4 +88,4 @@ module_init(init_rc_map_asus_ps3_100)
88module_exit(exit_rc_map_asus_ps3_100) 88module_exit(exit_rc_map_asus_ps3_100)
89 89
90MODULE_LICENSE("GPL"); 90MODULE_LICENSE("GPL");
91MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 91MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-ati-tv-wonder-hd-600.c b/drivers/media/rc/keymaps/rc-ati-tv-wonder-hd-600.c
index 2031224a2027..91392d4cfd6d 100644
--- a/drivers/media/rc/keymaps/rc-ati-tv-wonder-hd-600.c
+++ b/drivers/media/rc/keymaps/rc-ati-tv-wonder-hd-600.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -67,4 +67,4 @@ module_init(init_rc_map_ati_tv_wonder_hd_600)
67module_exit(exit_rc_map_ati_tv_wonder_hd_600) 67module_exit(exit_rc_map_ati_tv_wonder_hd_600)
68 68
69MODULE_LICENSE("GPL"); 69MODULE_LICENSE("GPL");
70MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 70MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-avermedia-a16d.c b/drivers/media/rc/keymaps/rc-avermedia-a16d.c
index 894939ac17f2..ff30a71d623e 100644
--- a/drivers/media/rc/keymaps/rc-avermedia-a16d.c
+++ b/drivers/media/rc/keymaps/rc-avermedia-a16d.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -73,4 +73,4 @@ module_init(init_rc_map_avermedia_a16d)
73module_exit(exit_rc_map_avermedia_a16d) 73module_exit(exit_rc_map_avermedia_a16d)
74 74
75MODULE_LICENSE("GPL"); 75MODULE_LICENSE("GPL");
76MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 76MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-avermedia-cardbus.c b/drivers/media/rc/keymaps/rc-avermedia-cardbus.c
index d2aaf5b9e39f..d7471a6de9b4 100644
--- a/drivers/media/rc/keymaps/rc-avermedia-cardbus.c
+++ b/drivers/media/rc/keymaps/rc-avermedia-cardbus.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -95,4 +95,4 @@ module_init(init_rc_map_avermedia_cardbus)
95module_exit(exit_rc_map_avermedia_cardbus) 95module_exit(exit_rc_map_avermedia_cardbus)
96 96
97MODULE_LICENSE("GPL"); 97MODULE_LICENSE("GPL");
98MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 98MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-avermedia-dvbt.c b/drivers/media/rc/keymaps/rc-avermedia-dvbt.c
index dc2baf062398..e2417d6331fe 100644
--- a/drivers/media/rc/keymaps/rc-avermedia-dvbt.c
+++ b/drivers/media/rc/keymaps/rc-avermedia-dvbt.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -76,4 +76,4 @@ module_init(init_rc_map_avermedia_dvbt)
76module_exit(exit_rc_map_avermedia_dvbt) 76module_exit(exit_rc_map_avermedia_dvbt)
77 77
78MODULE_LICENSE("GPL"); 78MODULE_LICENSE("GPL");
79MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 79MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-avermedia-m135a.c b/drivers/media/rc/keymaps/rc-avermedia-m135a.c
index 04269d31fa19..843598a5f1b5 100644
--- a/drivers/media/rc/keymaps/rc-avermedia-m135a.c
+++ b/drivers/media/rc/keymaps/rc-avermedia-m135a.c
@@ -1,6 +1,6 @@
1/* avermedia-m135a.c - Keytable for Avermedia M135A Remote Controllers 1/* avermedia-m135a.c - Keytable for Avermedia M135A Remote Controllers
2 * 2 *
3 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 3 * Copyright (c) 2010 by Mauro Carvalho Chehab
4 * Copyright (c) 2010 by Herton Ronaldo Krzesinski <herton@mandriva.com.br> 4 * Copyright (c) 2010 by Herton Ronaldo Krzesinski <herton@mandriva.com.br>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
@@ -145,4 +145,4 @@ module_init(init_rc_map_avermedia_m135a)
145module_exit(exit_rc_map_avermedia_m135a) 145module_exit(exit_rc_map_avermedia_m135a)
146 146
147MODULE_LICENSE("GPL"); 147MODULE_LICENSE("GPL");
148MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 148MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-avermedia-m733a-rm-k6.c b/drivers/media/rc/keymaps/rc-avermedia-m733a-rm-k6.c
index e83b1a1939bf..b24e7481ac21 100644
--- a/drivers/media/rc/keymaps/rc-avermedia-m733a-rm-k6.c
+++ b/drivers/media/rc/keymaps/rc-avermedia-m733a-rm-k6.c
@@ -93,4 +93,4 @@ module_init(init_rc_map_avermedia_m733a_rm_k6)
93module_exit(exit_rc_map_avermedia_m733a_rm_k6) 93module_exit(exit_rc_map_avermedia_m733a_rm_k6)
94 94
95MODULE_LICENSE("GPL"); 95MODULE_LICENSE("GPL");
96MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 96MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-avermedia.c b/drivers/media/rc/keymaps/rc-avermedia.c
index c6063dfcd507..3f68fbecc188 100644
--- a/drivers/media/rc/keymaps/rc-avermedia.c
+++ b/drivers/media/rc/keymaps/rc-avermedia.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -84,4 +84,4 @@ module_init(init_rc_map_avermedia)
84module_exit(exit_rc_map_avermedia) 84module_exit(exit_rc_map_avermedia)
85 85
86MODULE_LICENSE("GPL"); 86MODULE_LICENSE("GPL");
87MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 87MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-avertv-303.c b/drivers/media/rc/keymaps/rc-avertv-303.c
index 14f78451e64e..c35bc5b835c4 100644
--- a/drivers/media/rc/keymaps/rc-avertv-303.c
+++ b/drivers/media/rc/keymaps/rc-avertv-303.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -83,4 +83,4 @@ module_init(init_rc_map_avertv_303)
83module_exit(exit_rc_map_avertv_303) 83module_exit(exit_rc_map_avertv_303)
84 84
85MODULE_LICENSE("GPL"); 85MODULE_LICENSE("GPL");
86MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 86MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-behold-columbus.c b/drivers/media/rc/keymaps/rc-behold-columbus.c
index 086b4b1f19e1..1fc344e9daa7 100644
--- a/drivers/media/rc/keymaps/rc-behold-columbus.c
+++ b/drivers/media/rc/keymaps/rc-behold-columbus.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -106,4 +106,4 @@ module_init(init_rc_map_behold_columbus)
106module_exit(exit_rc_map_behold_columbus) 106module_exit(exit_rc_map_behold_columbus)
107 107
108MODULE_LICENSE("GPL"); 108MODULE_LICENSE("GPL");
109MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 109MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-behold.c b/drivers/media/rc/keymaps/rc-behold.c
index 0877e3480941..d6519f8ac95a 100644
--- a/drivers/media/rc/keymaps/rc-behold.c
+++ b/drivers/media/rc/keymaps/rc-behold.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -139,4 +139,4 @@ module_init(init_rc_map_behold)
139module_exit(exit_rc_map_behold) 139module_exit(exit_rc_map_behold)
140 140
141MODULE_LICENSE("GPL"); 141MODULE_LICENSE("GPL");
142MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 142MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-budget-ci-old.c b/drivers/media/rc/keymaps/rc-budget-ci-old.c
index 8311e092c098..b196a5f436a3 100644
--- a/drivers/media/rc/keymaps/rc-budget-ci-old.c
+++ b/drivers/media/rc/keymaps/rc-budget-ci-old.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -91,4 +91,4 @@ module_init(init_rc_map_budget_ci_old)
91module_exit(exit_rc_map_budget_ci_old) 91module_exit(exit_rc_map_budget_ci_old)
92 92
93MODULE_LICENSE("GPL"); 93MODULE_LICENSE("GPL");
94MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 94MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-cinergy-1400.c b/drivers/media/rc/keymaps/rc-cinergy-1400.c
index 0c87fbaf99ab..a099c080bf8c 100644
--- a/drivers/media/rc/keymaps/rc-cinergy-1400.c
+++ b/drivers/media/rc/keymaps/rc-cinergy-1400.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -82,4 +82,4 @@ module_init(init_rc_map_cinergy_1400)
82module_exit(exit_rc_map_cinergy_1400) 82module_exit(exit_rc_map_cinergy_1400)
83 83
84MODULE_LICENSE("GPL"); 84MODULE_LICENSE("GPL");
85MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 85MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-cinergy.c b/drivers/media/rc/keymaps/rc-cinergy.c
index 309e9e3fb6f3..b0f4328bdd6f 100644
--- a/drivers/media/rc/keymaps/rc-cinergy.c
+++ b/drivers/media/rc/keymaps/rc-cinergy.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -76,4 +76,4 @@ module_init(init_rc_map_cinergy)
76module_exit(exit_rc_map_cinergy) 76module_exit(exit_rc_map_cinergy)
77 77
78MODULE_LICENSE("GPL"); 78MODULE_LICENSE("GPL");
79MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 79MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-dib0700-nec.c b/drivers/media/rc/keymaps/rc-dib0700-nec.c
index 492a05ade7e1..a0fa543c9f9e 100644
--- a/drivers/media/rc/keymaps/rc-dib0700-nec.c
+++ b/drivers/media/rc/keymaps/rc-dib0700-nec.c
@@ -1,6 +1,6 @@
1/* rc-dvb0700-big.c - Keytable for devices in dvb0700 1/* rc-dvb0700-big.c - Keytable for devices in dvb0700
2 * 2 *
3 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 3 * Copyright (c) 2010 by Mauro Carvalho Chehab
4 * 4 *
5 * TODO: This table is a real mess, as it merges RC codes from several 5 * TODO: This table is a real mess, as it merges RC codes from several
6 * devices into a big table. It also has both RC-5 and NEC codes inside. 6 * devices into a big table. It also has both RC-5 and NEC codes inside.
@@ -122,4 +122,4 @@ module_init(init_rc_map)
122module_exit(exit_rc_map) 122module_exit(exit_rc_map)
123 123
124MODULE_LICENSE("GPL"); 124MODULE_LICENSE("GPL");
125MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 125MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-dib0700-rc5.c b/drivers/media/rc/keymaps/rc-dib0700-rc5.c
index 454ea596a7ee..907941145eb7 100644
--- a/drivers/media/rc/keymaps/rc-dib0700-rc5.c
+++ b/drivers/media/rc/keymaps/rc-dib0700-rc5.c
@@ -1,6 +1,6 @@
1/* rc-dvb0700-big.c - Keytable for devices in dvb0700 1/* rc-dvb0700-big.c - Keytable for devices in dvb0700
2 * 2 *
3 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 3 * Copyright (c) 2010 by Mauro Carvalho Chehab
4 * 4 *
5 * TODO: This table is a real mess, as it merges RC codes from several 5 * TODO: This table is a real mess, as it merges RC codes from several
6 * devices into a big table. It also has both RC-5 and NEC codes inside. 6 * devices into a big table. It also has both RC-5 and NEC codes inside.
@@ -233,4 +233,4 @@ module_init(init_rc_map)
233module_exit(exit_rc_map) 233module_exit(exit_rc_map)
234 234
235MODULE_LICENSE("GPL"); 235MODULE_LICENSE("GPL");
236MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 236MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-dm1105-nec.c b/drivers/media/rc/keymaps/rc-dm1105-nec.c
index 67fc9fb0c007..46e7ae414cc8 100644
--- a/drivers/media/rc/keymaps/rc-dm1105-nec.c
+++ b/drivers/media/rc/keymaps/rc-dm1105-nec.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -74,4 +74,4 @@ module_init(init_rc_map_dm1105_nec)
74module_exit(exit_rc_map_dm1105_nec) 74module_exit(exit_rc_map_dm1105_nec)
75 75
76MODULE_LICENSE("GPL"); 76MODULE_LICENSE("GPL");
77MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 77MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-dntv-live-dvb-t.c b/drivers/media/rc/keymaps/rc-dntv-live-dvb-t.c
index 91ea91de9179..d2826b46fea2 100644
--- a/drivers/media/rc/keymaps/rc-dntv-live-dvb-t.c
+++ b/drivers/media/rc/keymaps/rc-dntv-live-dvb-t.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -76,4 +76,4 @@ module_init(init_rc_map_dntv_live_dvb_t)
76module_exit(exit_rc_map_dntv_live_dvb_t) 76module_exit(exit_rc_map_dntv_live_dvb_t)
77 77
78MODULE_LICENSE("GPL"); 78MODULE_LICENSE("GPL");
79MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 79MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-dntv-live-dvbt-pro.c b/drivers/media/rc/keymaps/rc-dntv-live-dvbt-pro.c
index fd680d4d3eb6..0d74769467b5 100644
--- a/drivers/media/rc/keymaps/rc-dntv-live-dvbt-pro.c
+++ b/drivers/media/rc/keymaps/rc-dntv-live-dvbt-pro.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -95,4 +95,4 @@ module_init(init_rc_map_dntv_live_dvbt_pro)
95module_exit(exit_rc_map_dntv_live_dvbt_pro) 95module_exit(exit_rc_map_dntv_live_dvbt_pro)
96 96
97MODULE_LICENSE("GPL"); 97MODULE_LICENSE("GPL");
98MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 98MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-em-terratec.c b/drivers/media/rc/keymaps/rc-em-terratec.c
index d1fcd64c0f90..7f1e06be175b 100644
--- a/drivers/media/rc/keymaps/rc-em-terratec.c
+++ b/drivers/media/rc/keymaps/rc-em-terratec.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -67,4 +67,4 @@ module_init(init_rc_map_em_terratec)
67module_exit(exit_rc_map_em_terratec) 67module_exit(exit_rc_map_em_terratec)
68 68
69MODULE_LICENSE("GPL"); 69MODULE_LICENSE("GPL");
70MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 70MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-encore-enltv-fm53.c b/drivers/media/rc/keymaps/rc-encore-enltv-fm53.c
index 2fe45e41fe49..4fc3904daf06 100644
--- a/drivers/media/rc/keymaps/rc-encore-enltv-fm53.c
+++ b/drivers/media/rc/keymaps/rc-encore-enltv-fm53.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -79,4 +79,4 @@ module_init(init_rc_map_encore_enltv_fm53)
79module_exit(exit_rc_map_encore_enltv_fm53) 79module_exit(exit_rc_map_encore_enltv_fm53)
80 80
81MODULE_LICENSE("GPL"); 81MODULE_LICENSE("GPL");
82MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 82MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-encore-enltv.c b/drivers/media/rc/keymaps/rc-encore-enltv.c
index 223de75a6d1c..f1914e23d203 100644
--- a/drivers/media/rc/keymaps/rc-encore-enltv.c
+++ b/drivers/media/rc/keymaps/rc-encore-enltv.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -110,4 +110,4 @@ module_init(init_rc_map_encore_enltv)
110module_exit(exit_rc_map_encore_enltv) 110module_exit(exit_rc_map_encore_enltv)
111 111
112MODULE_LICENSE("GPL"); 112MODULE_LICENSE("GPL");
113MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 113MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-encore-enltv2.c b/drivers/media/rc/keymaps/rc-encore-enltv2.c
index 669cbff22b7e..9c6c55240d18 100644
--- a/drivers/media/rc/keymaps/rc-encore-enltv2.c
+++ b/drivers/media/rc/keymaps/rc-encore-enltv2.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -88,4 +88,4 @@ module_init(init_rc_map_encore_enltv2)
88module_exit(exit_rc_map_encore_enltv2) 88module_exit(exit_rc_map_encore_enltv2)
89 89
90MODULE_LICENSE("GPL"); 90MODULE_LICENSE("GPL");
91MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 91MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-evga-indtube.c b/drivers/media/rc/keymaps/rc-evga-indtube.c
index 2c647fc25916..2370d2a3deb6 100644
--- a/drivers/media/rc/keymaps/rc-evga-indtube.c
+++ b/drivers/media/rc/keymaps/rc-evga-indtube.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -59,4 +59,4 @@ module_init(init_rc_map_evga_indtube)
59module_exit(exit_rc_map_evga_indtube) 59module_exit(exit_rc_map_evga_indtube)
60 60
61MODULE_LICENSE("GPL"); 61MODULE_LICENSE("GPL");
62MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 62MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-eztv.c b/drivers/media/rc/keymaps/rc-eztv.c
index 76921445c1d9..b5c96ed84376 100644
--- a/drivers/media/rc/keymaps/rc-eztv.c
+++ b/drivers/media/rc/keymaps/rc-eztv.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -94,4 +94,4 @@ module_init(init_rc_map_eztv)
94module_exit(exit_rc_map_eztv) 94module_exit(exit_rc_map_eztv)
95 95
96MODULE_LICENSE("GPL"); 96MODULE_LICENSE("GPL");
97MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 97MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-flydvb.c b/drivers/media/rc/keymaps/rc-flydvb.c
index 3a6bba311b08..25cb89fac03c 100644
--- a/drivers/media/rc/keymaps/rc-flydvb.c
+++ b/drivers/media/rc/keymaps/rc-flydvb.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -75,4 +75,4 @@ module_init(init_rc_map_flydvb)
75module_exit(exit_rc_map_flydvb) 75module_exit(exit_rc_map_flydvb)
76 76
77MODULE_LICENSE("GPL"); 77MODULE_LICENSE("GPL");
78MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 78MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-flyvideo.c b/drivers/media/rc/keymaps/rc-flyvideo.c
index bf9da584643b..e71377dd0534 100644
--- a/drivers/media/rc/keymaps/rc-flyvideo.c
+++ b/drivers/media/rc/keymaps/rc-flyvideo.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -68,4 +68,4 @@ module_init(init_rc_map_flyvideo)
68module_exit(exit_rc_map_flyvideo) 68module_exit(exit_rc_map_flyvideo)
69 69
70MODULE_LICENSE("GPL"); 70MODULE_LICENSE("GPL");
71MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 71MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-fusionhdtv-mce.c b/drivers/media/rc/keymaps/rc-fusionhdtv-mce.c
index 2f0970fe7832..cf0608dc83d5 100644
--- a/drivers/media/rc/keymaps/rc-fusionhdtv-mce.c
+++ b/drivers/media/rc/keymaps/rc-fusionhdtv-mce.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -96,4 +96,4 @@ module_init(init_rc_map_fusionhdtv_mce)
96module_exit(exit_rc_map_fusionhdtv_mce) 96module_exit(exit_rc_map_fusionhdtv_mce)
97 97
98MODULE_LICENSE("GPL"); 98MODULE_LICENSE("GPL");
99MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 99MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-gadmei-rm008z.c b/drivers/media/rc/keymaps/rc-gadmei-rm008z.c
index 0e98ec467c34..03575bdb2eca 100644
--- a/drivers/media/rc/keymaps/rc-gadmei-rm008z.c
+++ b/drivers/media/rc/keymaps/rc-gadmei-rm008z.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -79,4 +79,4 @@ module_init(init_rc_map_gadmei_rm008z)
79module_exit(exit_rc_map_gadmei_rm008z) 79module_exit(exit_rc_map_gadmei_rm008z)
80 80
81MODULE_LICENSE("GPL"); 81MODULE_LICENSE("GPL");
82MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 82MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c b/drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c
index a2e2faa1d1b3..b2ab13b0dcb1 100644
--- a/drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c
+++ b/drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -82,4 +82,4 @@ module_init(init_rc_map_genius_tvgo_a11mce)
82module_exit(exit_rc_map_genius_tvgo_a11mce) 82module_exit(exit_rc_map_genius_tvgo_a11mce)
83 83
84MODULE_LICENSE("GPL"); 84MODULE_LICENSE("GPL");
85MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 85MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-gotview7135.c b/drivers/media/rc/keymaps/rc-gotview7135.c
index 864614e19314..229a36ac7f0a 100644
--- a/drivers/media/rc/keymaps/rc-gotview7135.c
+++ b/drivers/media/rc/keymaps/rc-gotview7135.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -77,4 +77,4 @@ module_init(init_rc_map_gotview7135)
77module_exit(exit_rc_map_gotview7135) 77module_exit(exit_rc_map_gotview7135)
78 78
79MODULE_LICENSE("GPL"); 79MODULE_LICENSE("GPL");
80MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 80MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-hauppauge.c b/drivers/media/rc/keymaps/rc-hauppauge.c
index 929bbbc16393..36d57f7c532b 100644
--- a/drivers/media/rc/keymaps/rc-hauppauge.c
+++ b/drivers/media/rc/keymaps/rc-hauppauge.c
@@ -8,7 +8,7 @@
8 * - Hauppauge Black; 8 * - Hauppauge Black;
9 * - DSR-0112 remote bundled with Haupauge MiniStick. 9 * - DSR-0112 remote bundled with Haupauge MiniStick.
10 * 10 *
11 * Copyright (c) 2010-2011 by Mauro Carvalho Chehab <mchehab@redhat.com> 11 * Copyright (c) 2010-2011 by Mauro Carvalho Chehab
12 * 12 *
13 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by 14 * it under the terms of the GNU General Public License as published by
@@ -290,4 +290,4 @@ module_init(init_rc_map_rc5_hauppauge_new)
290module_exit(exit_rc_map_rc5_hauppauge_new) 290module_exit(exit_rc_map_rc5_hauppauge_new)
291 291
292MODULE_LICENSE("GPL"); 292MODULE_LICENSE("GPL");
293MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 293MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-iodata-bctv7e.c b/drivers/media/rc/keymaps/rc-iodata-bctv7e.c
index 34540dfc3df5..9ee154cb0c6b 100644
--- a/drivers/media/rc/keymaps/rc-iodata-bctv7e.c
+++ b/drivers/media/rc/keymaps/rc-iodata-bctv7e.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -86,4 +86,4 @@ module_init(init_rc_map_iodata_bctv7e)
86module_exit(exit_rc_map_iodata_bctv7e) 86module_exit(exit_rc_map_iodata_bctv7e)
87 87
88MODULE_LICENSE("GPL"); 88MODULE_LICENSE("GPL");
89MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 89MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-kaiomy.c b/drivers/media/rc/keymaps/rc-kaiomy.c
index 4264a787c150..60803a732c08 100644
--- a/drivers/media/rc/keymaps/rc-kaiomy.c
+++ b/drivers/media/rc/keymaps/rc-kaiomy.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -85,4 +85,4 @@ module_init(init_rc_map_kaiomy)
85module_exit(exit_rc_map_kaiomy) 85module_exit(exit_rc_map_kaiomy)
86 86
87MODULE_LICENSE("GPL"); 87MODULE_LICENSE("GPL");
88MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 88MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-kworld-315u.c b/drivers/media/rc/keymaps/rc-kworld-315u.c
index e48cd267dda6..ba087eed1ed9 100644
--- a/drivers/media/rc/keymaps/rc-kworld-315u.c
+++ b/drivers/media/rc/keymaps/rc-kworld-315u.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -81,4 +81,4 @@ module_init(init_rc_map_kworld_315u)
81module_exit(exit_rc_map_kworld_315u) 81module_exit(exit_rc_map_kworld_315u)
82 82
83MODULE_LICENSE("GPL"); 83MODULE_LICENSE("GPL");
84MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 84MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-kworld-pc150u.c b/drivers/media/rc/keymaps/rc-kworld-pc150u.c
index 233bb5ee087f..b92e571f4def 100644
--- a/drivers/media/rc/keymaps/rc-kworld-pc150u.c
+++ b/drivers/media/rc/keymaps/rc-kworld-pc150u.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (c) 2010 by Kyle Strickland 5 * Copyright (c) 2010 by Kyle Strickland
6 * (based on kworld-plus-tv-analog.c by 6 * (based on kworld-plus-tv-analog.c by
7 * Mauro Carvalho Chehab <mchehab@redhat.com>) 7 * Mauro Carvalho Chehab)
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/rc/keymaps/rc-kworld-plus-tv-analog.c b/drivers/media/rc/keymaps/rc-kworld-plus-tv-analog.c
index 32998d6b787d..edc868564f99 100644
--- a/drivers/media/rc/keymaps/rc-kworld-plus-tv-analog.c
+++ b/drivers/media/rc/keymaps/rc-kworld-plus-tv-analog.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -97,4 +97,4 @@ module_init(init_rc_map_kworld_plus_tv_analog)
97module_exit(exit_rc_map_kworld_plus_tv_analog) 97module_exit(exit_rc_map_kworld_plus_tv_analog)
98 98
99MODULE_LICENSE("GPL"); 99MODULE_LICENSE("GPL");
100MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 100MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-manli.c b/drivers/media/rc/keymaps/rc-manli.c
index e7038bb71bf6..92424ef2aaa6 100644
--- a/drivers/media/rc/keymaps/rc-manli.c
+++ b/drivers/media/rc/keymaps/rc-manli.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -132,4 +132,4 @@ module_init(init_rc_map_manli)
132module_exit(exit_rc_map_manli) 132module_exit(exit_rc_map_manli)
133 133
134MODULE_LICENSE("GPL"); 134MODULE_LICENSE("GPL");
135MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 135MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c b/drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c
index c393d8a50bca..fd7a55c56167 100644
--- a/drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c
+++ b/drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -121,4 +121,4 @@ module_init(init_rc_map_msi_tvanywhere_plus)
121module_exit(exit_rc_map_msi_tvanywhere_plus) 121module_exit(exit_rc_map_msi_tvanywhere_plus)
122 122
123MODULE_LICENSE("GPL"); 123MODULE_LICENSE("GPL");
124MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 124MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-msi-tvanywhere.c b/drivers/media/rc/keymaps/rc-msi-tvanywhere.c
index a7003d3a3c8a..4233a8d4d63e 100644
--- a/drivers/media/rc/keymaps/rc-msi-tvanywhere.c
+++ b/drivers/media/rc/keymaps/rc-msi-tvanywhere.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -67,4 +67,4 @@ module_init(init_rc_map_msi_tvanywhere)
67module_exit(exit_rc_map_msi_tvanywhere) 67module_exit(exit_rc_map_msi_tvanywhere)
68 68
69MODULE_LICENSE("GPL"); 69MODULE_LICENSE("GPL");
70MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 70MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-nebula.c b/drivers/media/rc/keymaps/rc-nebula.c
index 3f0ddd7afd30..8ec881adb7cf 100644
--- a/drivers/media/rc/keymaps/rc-nebula.c
+++ b/drivers/media/rc/keymaps/rc-nebula.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -94,4 +94,4 @@ module_init(init_rc_map_nebula)
94module_exit(exit_rc_map_nebula) 94module_exit(exit_rc_map_nebula)
95 95
96MODULE_LICENSE("GPL"); 96MODULE_LICENSE("GPL");
97MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 97MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c b/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
index 8d4dae2e2ece..292bbad35d21 100644
--- a/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
+++ b/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
14#include <linux/module.h> 14#include <linux/module.h>
15 15
16/* Terratec Cinergy Hybrid T USB XS FM 16/* Terratec Cinergy Hybrid T USB XS FM
17 Mauro Carvalho Chehab <mchehab@redhat.com> 17 Mauro Carvalho Chehab
18 */ 18 */
19 19
20static struct rc_map_table nec_terratec_cinergy_xs[] = { 20static struct rc_map_table nec_terratec_cinergy_xs[] = {
@@ -155,4 +155,4 @@ module_init(init_rc_map_nec_terratec_cinergy_xs)
155module_exit(exit_rc_map_nec_terratec_cinergy_xs) 155module_exit(exit_rc_map_nec_terratec_cinergy_xs)
156 156
157MODULE_LICENSE("GPL"); 157MODULE_LICENSE("GPL");
158MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 158MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-norwood.c b/drivers/media/rc/keymaps/rc-norwood.c
index 9e65f07157ab..ca1b82a2c54f 100644
--- a/drivers/media/rc/keymaps/rc-norwood.c
+++ b/drivers/media/rc/keymaps/rc-norwood.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -83,4 +83,4 @@ module_init(init_rc_map_norwood)
83module_exit(exit_rc_map_norwood) 83module_exit(exit_rc_map_norwood)
84 84
85MODULE_LICENSE("GPL"); 85MODULE_LICENSE("GPL");
86MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 86MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-npgtech.c b/drivers/media/rc/keymaps/rc-npgtech.c
index 65d0cfc3c33b..1fb946024512 100644
--- a/drivers/media/rc/keymaps/rc-npgtech.c
+++ b/drivers/media/rc/keymaps/rc-npgtech.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -78,4 +78,4 @@ module_init(init_rc_map_npgtech)
78module_exit(exit_rc_map_npgtech) 78module_exit(exit_rc_map_npgtech)
79 79
80MODULE_LICENSE("GPL"); 80MODULE_LICENSE("GPL");
81MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 81MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-pctv-sedna.c b/drivers/media/rc/keymaps/rc-pctv-sedna.c
index bf2cbdfe2e32..5ef01ab3fd50 100644
--- a/drivers/media/rc/keymaps/rc-pctv-sedna.c
+++ b/drivers/media/rc/keymaps/rc-pctv-sedna.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -78,4 +78,4 @@ module_init(init_rc_map_pctv_sedna)
78module_exit(exit_rc_map_pctv_sedna) 78module_exit(exit_rc_map_pctv_sedna)
79 79
80MODULE_LICENSE("GPL"); 80MODULE_LICENSE("GPL");
81MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 81MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-pinnacle-color.c b/drivers/media/rc/keymaps/rc-pinnacle-color.c
index b46cd8fe6438..a218b471a4ca 100644
--- a/drivers/media/rc/keymaps/rc-pinnacle-color.c
+++ b/drivers/media/rc/keymaps/rc-pinnacle-color.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -92,4 +92,4 @@ module_init(init_rc_map_pinnacle_color)
92module_exit(exit_rc_map_pinnacle_color) 92module_exit(exit_rc_map_pinnacle_color)
93 93
94MODULE_LICENSE("GPL"); 94MODULE_LICENSE("GPL");
95MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 95MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-pinnacle-grey.c b/drivers/media/rc/keymaps/rc-pinnacle-grey.c
index d525df9ad868..4a3f467a47a2 100644
--- a/drivers/media/rc/keymaps/rc-pinnacle-grey.c
+++ b/drivers/media/rc/keymaps/rc-pinnacle-grey.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -87,4 +87,4 @@ module_init(init_rc_map_pinnacle_grey)
87module_exit(exit_rc_map_pinnacle_grey) 87module_exit(exit_rc_map_pinnacle_grey)
88 88
89MODULE_LICENSE("GPL"); 89MODULE_LICENSE("GPL");
90MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 90MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c b/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c
index a4603d035374..e89cc10b68bf 100644
--- a/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c
+++ b/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -68,4 +68,4 @@ module_init(init_rc_map_pinnacle_pctv_hd)
68module_exit(exit_rc_map_pinnacle_pctv_hd) 68module_exit(exit_rc_map_pinnacle_pctv_hd)
69 69
70MODULE_LICENSE("GPL"); 70MODULE_LICENSE("GPL");
71MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 71MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-pixelview-002t.c b/drivers/media/rc/keymaps/rc-pixelview-002t.c
index 33eb64333c6f..d967c3816fdc 100644
--- a/drivers/media/rc/keymaps/rc-pixelview-002t.c
+++ b/drivers/media/rc/keymaps/rc-pixelview-002t.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -75,4 +75,4 @@ module_init(init_rc_map_pixelview)
75module_exit(exit_rc_map_pixelview) 75module_exit(exit_rc_map_pixelview)
76 76
77MODULE_LICENSE("GPL"); 77MODULE_LICENSE("GPL");
78MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 78MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-pixelview-mk12.c b/drivers/media/rc/keymaps/rc-pixelview-mk12.c
index 21f4dd25c2ec..224d0efaa6e5 100644
--- a/drivers/media/rc/keymaps/rc-pixelview-mk12.c
+++ b/drivers/media/rc/keymaps/rc-pixelview-mk12.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -81,4 +81,4 @@ module_init(init_rc_map_pixelview)
81module_exit(exit_rc_map_pixelview) 81module_exit(exit_rc_map_pixelview)
82 82
83MODULE_LICENSE("GPL"); 83MODULE_LICENSE("GPL");
84MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 84MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-pixelview-new.c b/drivers/media/rc/keymaps/rc-pixelview-new.c
index f944ad2cac2b..781d788d6b6d 100644
--- a/drivers/media/rc/keymaps/rc-pixelview-new.c
+++ b/drivers/media/rc/keymaps/rc-pixelview-new.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -81,4 +81,4 @@ module_init(init_rc_map_pixelview_new)
81module_exit(exit_rc_map_pixelview_new) 81module_exit(exit_rc_map_pixelview_new)
82 82
83MODULE_LICENSE("GPL"); 83MODULE_LICENSE("GPL");
84MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 84MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-pixelview.c b/drivers/media/rc/keymaps/rc-pixelview.c
index a6020eea7b95..39e6feaa35a3 100644
--- a/drivers/media/rc/keymaps/rc-pixelview.c
+++ b/drivers/media/rc/keymaps/rc-pixelview.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -80,4 +80,4 @@ module_init(init_rc_map_pixelview)
80module_exit(exit_rc_map_pixelview) 80module_exit(exit_rc_map_pixelview)
81 81
82MODULE_LICENSE("GPL"); 82MODULE_LICENSE("GPL");
83MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 83MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-powercolor-real-angel.c b/drivers/media/rc/keymaps/rc-powercolor-real-angel.c
index e74c571a5e44..e96fa3ab9f4b 100644
--- a/drivers/media/rc/keymaps/rc-powercolor-real-angel.c
+++ b/drivers/media/rc/keymaps/rc-powercolor-real-angel.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -79,4 +79,4 @@ module_init(init_rc_map_powercolor_real_angel)
79module_exit(exit_rc_map_powercolor_real_angel) 79module_exit(exit_rc_map_powercolor_real_angel)
80 80
81MODULE_LICENSE("GPL"); 81MODULE_LICENSE("GPL");
82MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 82MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-proteus-2309.c b/drivers/media/rc/keymaps/rc-proteus-2309.c
index adee8035ce96..eef626ee02df 100644
--- a/drivers/media/rc/keymaps/rc-proteus-2309.c
+++ b/drivers/media/rc/keymaps/rc-proteus-2309.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -67,4 +67,4 @@ module_init(init_rc_map_proteus_2309)
67module_exit(exit_rc_map_proteus_2309) 67module_exit(exit_rc_map_proteus_2309)
68 68
69MODULE_LICENSE("GPL"); 69MODULE_LICENSE("GPL");
70MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 70MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-purpletv.c b/drivers/media/rc/keymaps/rc-purpletv.c
index 722597a20e4a..cec6fe466829 100644
--- a/drivers/media/rc/keymaps/rc-purpletv.c
+++ b/drivers/media/rc/keymaps/rc-purpletv.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -79,4 +79,4 @@ module_init(init_rc_map_purpletv)
79module_exit(exit_rc_map_purpletv) 79module_exit(exit_rc_map_purpletv)
80 80
81MODULE_LICENSE("GPL"); 81MODULE_LICENSE("GPL");
82MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 82MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-pv951.c b/drivers/media/rc/keymaps/rc-pv951.c
index 0105d63c07a9..5ac89ce8c053 100644
--- a/drivers/media/rc/keymaps/rc-pv951.c
+++ b/drivers/media/rc/keymaps/rc-pv951.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -76,4 +76,4 @@ module_init(init_rc_map_pv951)
76module_exit(exit_rc_map_pv951) 76module_exit(exit_rc_map_pv951)
77 77
78MODULE_LICENSE("GPL"); 78MODULE_LICENSE("GPL");
79MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 79MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-real-audio-220-32-keys.c b/drivers/media/rc/keymaps/rc-real-audio-220-32-keys.c
index 073694d50f49..9f778bd091db 100644
--- a/drivers/media/rc/keymaps/rc-real-audio-220-32-keys.c
+++ b/drivers/media/rc/keymaps/rc-real-audio-220-32-keys.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -76,4 +76,4 @@ module_init(init_rc_map_real_audio_220_32_keys)
76module_exit(exit_rc_map_real_audio_220_32_keys) 76module_exit(exit_rc_map_real_audio_220_32_keys)
77 77
78MODULE_LICENSE("GPL"); 78MODULE_LICENSE("GPL");
79MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 79MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-tbs-nec.c b/drivers/media/rc/keymaps/rc-tbs-nec.c
index 5039be782bc5..24ce2a252502 100644
--- a/drivers/media/rc/keymaps/rc-tbs-nec.c
+++ b/drivers/media/rc/keymaps/rc-tbs-nec.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -73,4 +73,4 @@ module_init(init_rc_map_tbs_nec)
73module_exit(exit_rc_map_tbs_nec) 73module_exit(exit_rc_map_tbs_nec)
74 74
75MODULE_LICENSE("GPL"); 75MODULE_LICENSE("GPL");
76MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 76MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c b/drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c
index 53629fb0151f..97eb83ab5a35 100644
--- a/drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c
+++ b/drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -90,4 +90,4 @@ module_init(init_rc_map_terratec_cinergy_xs)
90module_exit(exit_rc_map_terratec_cinergy_xs) 90module_exit(exit_rc_map_terratec_cinergy_xs)
91 91
92MODULE_LICENSE("GPL"); 92MODULE_LICENSE("GPL");
93MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 93MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-tevii-nec.c b/drivers/media/rc/keymaps/rc-tevii-nec.c
index f2c3b75d8580..38e0c0875596 100644
--- a/drivers/media/rc/keymaps/rc-tevii-nec.c
+++ b/drivers/media/rc/keymaps/rc-tevii-nec.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -86,4 +86,4 @@ module_init(init_rc_map_tevii_nec)
86module_exit(exit_rc_map_tevii_nec) 86module_exit(exit_rc_map_tevii_nec)
87 87
88MODULE_LICENSE("GPL"); 88MODULE_LICENSE("GPL");
89MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 89MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-tivo.c b/drivers/media/rc/keymaps/rc-tivo.c
index 454e06295692..5cc1b456e329 100644
--- a/drivers/media/rc/keymaps/rc-tivo.c
+++ b/drivers/media/rc/keymaps/rc-tivo.c
@@ -15,62 +15,62 @@
15 * Initial mapping is for the TiVo remote included in the Nero LiquidTV bundle, 15 * Initial mapping is for the TiVo remote included in the Nero LiquidTV bundle,
16 * which also ships with a TiVo-branded IR transceiver, supported by the mceusb 16 * which also ships with a TiVo-branded IR transceiver, supported by the mceusb
17 * driver. Note that the remote uses an NEC-ish protocol, but instead of having 17 * driver. Note that the remote uses an NEC-ish protocol, but instead of having
18 * a command/not_command pair, it has a vendor ID of 0xa10c, but some keys, the 18 * a command/not_command pair, it has a vendor ID of 0x3085, but some keys, the
19 * NEC extended checksums do pass, so the table presently has the intended 19 * NEC extended checksums do pass, so the table presently has the intended
20 * values and the checksum-passed versions for those keys. 20 * values and the checksum-passed versions for those keys.
21 */ 21 */
22static struct rc_map_table tivo[] = { 22static struct rc_map_table tivo[] = {
23 { 0xa10c900f, KEY_MEDIA }, /* TiVo Button */ 23 { 0x3085f009, KEY_MEDIA }, /* TiVo Button */
24 { 0xa10c0807, KEY_POWER2 }, /* TV Power */ 24 { 0x3085e010, KEY_POWER2 }, /* TV Power */
25 { 0xa10c8807, KEY_TV }, /* Live TV/Swap */ 25 { 0x3085e011, KEY_TV }, /* Live TV/Swap */
26 { 0xa10c2c03, KEY_VIDEO_NEXT }, /* TV Input */ 26 { 0x3085c034, KEY_VIDEO_NEXT }, /* TV Input */
27 { 0xa10cc807, KEY_INFO }, 27 { 0x3085e013, KEY_INFO },
28 { 0xa10cfa05, KEY_CYCLEWINDOWS }, /* Window */ 28 { 0x3085a05f, KEY_CYCLEWINDOWS }, /* Window */
29 { 0x0085305f, KEY_CYCLEWINDOWS }, 29 { 0x0085305f, KEY_CYCLEWINDOWS },
30 { 0xa10c6c03, KEY_EPG }, /* Guide */ 30 { 0x3085c036, KEY_EPG }, /* Guide */
31 31
32 { 0xa10c2807, KEY_UP }, 32 { 0x3085e014, KEY_UP },
33 { 0xa10c6807, KEY_DOWN }, 33 { 0x3085e016, KEY_DOWN },
34 { 0xa10ce807, KEY_LEFT }, 34 { 0x3085e017, KEY_LEFT },
35 { 0xa10ca807, KEY_RIGHT }, 35 { 0x3085e015, KEY_RIGHT },
36 36
37 { 0xa10c1807, KEY_SCROLLDOWN }, /* Red Thumbs Down */ 37 { 0x3085e018, KEY_SCROLLDOWN }, /* Red Thumbs Down */
38 { 0xa10c9807, KEY_SELECT }, 38 { 0x3085e019, KEY_SELECT },
39 { 0xa10c5807, KEY_SCROLLUP }, /* Green Thumbs Up */ 39 { 0x3085e01a, KEY_SCROLLUP }, /* Green Thumbs Up */
40 40
41 { 0xa10c3807, KEY_VOLUMEUP }, 41 { 0x3085e01c, KEY_VOLUMEUP },
42 { 0xa10cb807, KEY_VOLUMEDOWN }, 42 { 0x3085e01d, KEY_VOLUMEDOWN },
43 { 0xa10cd807, KEY_MUTE }, 43 { 0x3085e01b, KEY_MUTE },
44 { 0xa10c040b, KEY_RECORD }, 44 { 0x3085d020, KEY_RECORD },
45 { 0xa10c7807, KEY_CHANNELUP }, 45 { 0x3085e01e, KEY_CHANNELUP },
46 { 0xa10cf807, KEY_CHANNELDOWN }, 46 { 0x3085e01f, KEY_CHANNELDOWN },
47 { 0x0085301f, KEY_CHANNELDOWN }, 47 { 0x0085301f, KEY_CHANNELDOWN },
48 48
49 { 0xa10c840b, KEY_PLAY }, 49 { 0x3085d021, KEY_PLAY },
50 { 0xa10cc40b, KEY_PAUSE }, 50 { 0x3085d023, KEY_PAUSE },
51 { 0xa10ca40b, KEY_SLOW }, 51 { 0x3085d025, KEY_SLOW },
52 { 0xa10c440b, KEY_REWIND }, 52 { 0x3085d022, KEY_REWIND },
53 { 0xa10c240b, KEY_FASTFORWARD }, 53 { 0x3085d024, KEY_FASTFORWARD },
54 { 0xa10c640b, KEY_PREVIOUS }, 54 { 0x3085d026, KEY_PREVIOUS },
55 { 0xa10ce40b, KEY_NEXT }, /* ->| */ 55 { 0x3085d027, KEY_NEXT }, /* ->| */
56 56
57 { 0xa10c220d, KEY_ZOOM }, /* Aspect */ 57 { 0x3085b044, KEY_ZOOM }, /* Aspect */
58 { 0xa10c120d, KEY_STOP }, 58 { 0x3085b048, KEY_STOP },
59 { 0xa10c520d, KEY_DVD }, /* DVD Menu */ 59 { 0x3085b04a, KEY_DVD }, /* DVD Menu */
60 60
61 { 0xa10c140b, KEY_NUMERIC_1 }, 61 { 0x3085d028, KEY_NUMERIC_1 },
62 { 0xa10c940b, KEY_NUMERIC_2 }, 62 { 0x3085d029, KEY_NUMERIC_2 },
63 { 0xa10c540b, KEY_NUMERIC_3 }, 63 { 0x3085d02a, KEY_NUMERIC_3 },
64 { 0xa10cd40b, KEY_NUMERIC_4 }, 64 { 0x3085d02b, KEY_NUMERIC_4 },
65 { 0xa10c340b, KEY_NUMERIC_5 }, 65 { 0x3085d02c, KEY_NUMERIC_5 },
66 { 0xa10cb40b, KEY_NUMERIC_6 }, 66 { 0x3085d02d, KEY_NUMERIC_6 },
67 { 0xa10c740b, KEY_NUMERIC_7 }, 67 { 0x3085d02e, KEY_NUMERIC_7 },
68 { 0xa10cf40b, KEY_NUMERIC_8 }, 68 { 0x3085d02f, KEY_NUMERIC_8 },
69 { 0x0085302f, KEY_NUMERIC_8 }, 69 { 0x0085302f, KEY_NUMERIC_8 },
70 { 0xa10c0c03, KEY_NUMERIC_9 }, 70 { 0x3085c030, KEY_NUMERIC_9 },
71 { 0xa10c8c03, KEY_NUMERIC_0 }, 71 { 0x3085c031, KEY_NUMERIC_0 },
72 { 0xa10ccc03, KEY_ENTER }, 72 { 0x3085c033, KEY_ENTER },
73 { 0xa10c4c03, KEY_CLEAR }, 73 { 0x3085c032, KEY_CLEAR },
74}; 74};
75 75
76static struct rc_map_list tivo_map = { 76static struct rc_map_list tivo_map = {
diff --git a/drivers/media/rc/keymaps/rc-tt-1500.c b/drivers/media/rc/keymaps/rc-tt-1500.c
index 80217ffc91db..c766d3b2b6b0 100644
--- a/drivers/media/rc/keymaps/rc-tt-1500.c
+++ b/drivers/media/rc/keymaps/rc-tt-1500.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -80,4 +80,4 @@ module_init(init_rc_map_tt_1500)
80module_exit(exit_rc_map_tt_1500) 80module_exit(exit_rc_map_tt_1500)
81 81
82MODULE_LICENSE("GPL"); 82MODULE_LICENSE("GPL");
83MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 83MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-videomate-s350.c b/drivers/media/rc/keymaps/rc-videomate-s350.c
index 8bfc3e8d909d..8a354775a2d8 100644
--- a/drivers/media/rc/keymaps/rc-videomate-s350.c
+++ b/drivers/media/rc/keymaps/rc-videomate-s350.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -83,4 +83,4 @@ module_init(init_rc_map_videomate_s350)
83module_exit(exit_rc_map_videomate_s350) 83module_exit(exit_rc_map_videomate_s350)
84 84
85MODULE_LICENSE("GPL"); 85MODULE_LICENSE("GPL");
86MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 86MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-videomate-tv-pvr.c b/drivers/media/rc/keymaps/rc-videomate-tv-pvr.c
index 390ce9431b35..eb0cda7766c4 100644
--- a/drivers/media/rc/keymaps/rc-videomate-tv-pvr.c
+++ b/drivers/media/rc/keymaps/rc-videomate-tv-pvr.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -85,4 +85,4 @@ module_init(init_rc_map_videomate_tv_pvr)
85module_exit(exit_rc_map_videomate_tv_pvr) 85module_exit(exit_rc_map_videomate_tv_pvr)
86 86
87MODULE_LICENSE("GPL"); 87MODULE_LICENSE("GPL");
88MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 88MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c b/drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c
index 2852bf705064..c1dd598e828e 100644
--- a/drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c
+++ b/drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -80,4 +80,4 @@ module_init(init_rc_map_winfast_usbii_deluxe)
80module_exit(exit_rc_map_winfast_usbii_deluxe) 80module_exit(exit_rc_map_winfast_usbii_deluxe)
81 81
82MODULE_LICENSE("GPL"); 82MODULE_LICENSE("GPL");
83MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 83MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/keymaps/rc-winfast.c b/drivers/media/rc/keymaps/rc-winfast.c
index 2df1cba23600..8a779da1e973 100644
--- a/drivers/media/rc/keymaps/rc-winfast.c
+++ b/drivers/media/rc/keymaps/rc-winfast.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * keymap imported from ir-keymaps.c 3 * keymap imported from ir-keymaps.c
4 * 4 *
5 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 5 * Copyright (c) 2010 by Mauro Carvalho Chehab
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
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -100,4 +100,4 @@ module_init(init_rc_map_winfast)
100module_exit(exit_rc_map_winfast) 100module_exit(exit_rc_map_winfast)
101 101
102MODULE_LICENSE("GPL"); 102MODULE_LICENSE("GPL");
103MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 103MODULE_AUTHOR("Mauro Carvalho Chehab");
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index a25bb1581e46..5d8f3d40d820 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -84,7 +84,7 @@
84#define MCE_PORT_IR 0x4 /* (0x4 << 5) | MCE_CMD = 0x9f */ 84#define MCE_PORT_IR 0x4 /* (0x4 << 5) | MCE_CMD = 0x9f */
85#define MCE_PORT_SYS 0x7 /* (0x7 << 5) | MCE_CMD = 0xff */ 85#define MCE_PORT_SYS 0x7 /* (0x7 << 5) | MCE_CMD = 0xff */
86#define MCE_PORT_SER 0x6 /* 0xc0 thru 0xdf flush & 0x1f bytes */ 86#define MCE_PORT_SER 0x6 /* 0xc0 thru 0xdf flush & 0x1f bytes */
87#define MCE_PORT_MASK 0xe0 /* Mask out command bits */ 87#define MCE_PORT_MASK 0xe0 /* Mask out command bits */
88 88
89/* Command port headers */ 89/* Command port headers */
90#define MCE_CMD_PORT_IR 0x9f /* IR-related cmd/rsp */ 90#define MCE_CMD_PORT_IR 0x9f /* IR-related cmd/rsp */
@@ -153,19 +153,6 @@
153#define MCE_COMMAND_IRDATA 0x80 153#define MCE_COMMAND_IRDATA 0x80
154#define MCE_PACKET_LENGTH_MASK 0x1f /* Packet length mask */ 154#define MCE_PACKET_LENGTH_MASK 0x1f /* Packet length mask */
155 155
156/* module parameters */
157#ifdef CONFIG_USB_DEBUG
158static bool debug = 1;
159#else
160static bool debug;
161#endif
162
163#define mce_dbg(dev, fmt, ...) \
164 do { \
165 if (debug) \
166 dev_info(dev, fmt, ## __VA_ARGS__); \
167 } while (0)
168
169/* general constants */ 156/* general constants */
170#define SEND_FLAG_IN_PROGRESS 1 157#define SEND_FLAG_IN_PROGRESS 1
171#define SEND_FLAG_COMPLETE 2 158#define SEND_FLAG_COMPLETE 2
@@ -541,16 +528,13 @@ static int mceusb_cmd_datasize(u8 cmd, u8 subcmd)
541static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf, 528static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
542 int offset, int len, bool out) 529 int offset, int len, bool out)
543{ 530{
544 char codes[USB_BUFLEN * 3 + 1]; 531#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
545 char inout[9]; 532 char *inout;
546 u8 cmd, subcmd, data1, data2, data3, data4; 533 u8 cmd, subcmd, data1, data2, data3, data4;
547 struct device *dev = ir->dev; 534 struct device *dev = ir->dev;
548 int i, start, skip = 0; 535 int start, skip = 0;
549 u32 carrier, period; 536 u32 carrier, period;
550 537
551 if (!debug)
552 return;
553
554 /* skip meaningless 0xb1 0x60 header bytes on orig receiver */ 538 /* skip meaningless 0xb1 0x60 header bytes on orig receiver */
555 if (ir->flags.microsoft_gen1 && !out && !offset) 539 if (ir->flags.microsoft_gen1 && !out && !offset)
556 skip = 2; 540 skip = 2;
@@ -558,16 +542,10 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
558 if (len <= skip) 542 if (len <= skip)
559 return; 543 return;
560 544
561 for (i = 0; i < len && i < USB_BUFLEN; i++) 545 dev_dbg(dev, "%cx data: %*ph (length=%d)",
562 snprintf(codes + i * 3, 4, "%02x ", buf[i + offset] & 0xff); 546 (out ? 't' : 'r'), min(len, USB_BUFLEN), buf, len);
563
564 dev_info(dev, "%sx data: %s(length=%d)\n",
565 (out ? "t" : "r"), codes, len);
566 547
567 if (out) 548 inout = out ? "Request" : "Got";
568 strcpy(inout, "Request\0");
569 else
570 strcpy(inout, "Got\0");
571 549
572 start = offset + skip; 550 start = offset + skip;
573 cmd = buf[start] & 0xff; 551 cmd = buf[start] & 0xff;
@@ -583,50 +561,50 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
583 break; 561 break;
584 if ((subcmd == MCE_CMD_PORT_SYS) && 562 if ((subcmd == MCE_CMD_PORT_SYS) &&
585 (data1 == MCE_CMD_RESUME)) 563 (data1 == MCE_CMD_RESUME))
586 dev_info(dev, "Device resume requested\n"); 564 dev_dbg(dev, "Device resume requested");
587 else 565 else
588 dev_info(dev, "Unknown command 0x%02x 0x%02x\n", 566 dev_dbg(dev, "Unknown command 0x%02x 0x%02x",
589 cmd, subcmd); 567 cmd, subcmd);
590 break; 568 break;
591 case MCE_CMD_PORT_SYS: 569 case MCE_CMD_PORT_SYS:
592 switch (subcmd) { 570 switch (subcmd) {
593 case MCE_RSP_EQEMVER: 571 case MCE_RSP_EQEMVER:
594 if (!out) 572 if (!out)
595 dev_info(dev, "Emulator interface version %x\n", 573 dev_dbg(dev, "Emulator interface version %x",
596 data1); 574 data1);
597 break; 575 break;
598 case MCE_CMD_G_REVISION: 576 case MCE_CMD_G_REVISION:
599 if (len == 2) 577 if (len == 2)
600 dev_info(dev, "Get hw/sw rev?\n"); 578 dev_dbg(dev, "Get hw/sw rev?");
601 else 579 else
602 dev_info(dev, "hw/sw rev 0x%02x 0x%02x " 580 dev_dbg(dev, "hw/sw rev 0x%02x 0x%02x 0x%02x 0x%02x",
603 "0x%02x 0x%02x\n", data1, data2, 581 data1, data2,
604 buf[start + 4], buf[start + 5]); 582 buf[start + 4], buf[start + 5]);
605 break; 583 break;
606 case MCE_CMD_RESUME: 584 case MCE_CMD_RESUME:
607 dev_info(dev, "Device resume requested\n"); 585 dev_dbg(dev, "Device resume requested");
608 break; 586 break;
609 case MCE_RSP_CMD_ILLEGAL: 587 case MCE_RSP_CMD_ILLEGAL:
610 dev_info(dev, "Illegal PORT_SYS command\n"); 588 dev_dbg(dev, "Illegal PORT_SYS command");
611 break; 589 break;
612 case MCE_RSP_EQWAKEVERSION: 590 case MCE_RSP_EQWAKEVERSION:
613 if (!out) 591 if (!out)
614 dev_info(dev, "Wake version, proto: 0x%02x, " 592 dev_dbg(dev, "Wake version, proto: 0x%02x, "
615 "payload: 0x%02x, address: 0x%02x, " 593 "payload: 0x%02x, address: 0x%02x, "
616 "version: 0x%02x\n", 594 "version: 0x%02x",
617 data1, data2, data3, data4); 595 data1, data2, data3, data4);
618 break; 596 break;
619 case MCE_RSP_GETPORTSTATUS: 597 case MCE_RSP_GETPORTSTATUS:
620 if (!out) 598 if (!out)
621 /* We use data1 + 1 here, to match hw labels */ 599 /* We use data1 + 1 here, to match hw labels */
622 dev_info(dev, "TX port %d: blaster is%s connected\n", 600 dev_dbg(dev, "TX port %d: blaster is%s connected",
623 data1 + 1, data4 ? " not" : ""); 601 data1 + 1, data4 ? " not" : "");
624 break; 602 break;
625 case MCE_CMD_FLASHLED: 603 case MCE_CMD_FLASHLED:
626 dev_info(dev, "Attempting to flash LED\n"); 604 dev_dbg(dev, "Attempting to flash LED");
627 break; 605 break;
628 default: 606 default:
629 dev_info(dev, "Unknown command 0x%02x 0x%02x\n", 607 dev_dbg(dev, "Unknown command 0x%02x 0x%02x",
630 cmd, subcmd); 608 cmd, subcmd);
631 break; 609 break;
632 } 610 }
@@ -634,13 +612,13 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
634 case MCE_CMD_PORT_IR: 612 case MCE_CMD_PORT_IR:
635 switch (subcmd) { 613 switch (subcmd) {
636 case MCE_CMD_SIG_END: 614 case MCE_CMD_SIG_END:
637 dev_info(dev, "End of signal\n"); 615 dev_dbg(dev, "End of signal");
638 break; 616 break;
639 case MCE_CMD_PING: 617 case MCE_CMD_PING:
640 dev_info(dev, "Ping\n"); 618 dev_dbg(dev, "Ping");
641 break; 619 break;
642 case MCE_CMD_UNKNOWN: 620 case MCE_CMD_UNKNOWN:
643 dev_info(dev, "Resp to 9f 05 of 0x%02x 0x%02x\n", 621 dev_dbg(dev, "Resp to 9f 05 of 0x%02x 0x%02x",
644 data1, data2); 622 data1, data2);
645 break; 623 break;
646 case MCE_RSP_EQIRCFS: 624 case MCE_RSP_EQIRCFS:
@@ -649,51 +627,51 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
649 if (!period) 627 if (!period)
650 break; 628 break;
651 carrier = (1000 * 1000) / period; 629 carrier = (1000 * 1000) / period;
652 dev_info(dev, "%s carrier of %u Hz (period %uus)\n", 630 dev_dbg(dev, "%s carrier of %u Hz (period %uus)",
653 inout, carrier, period); 631 inout, carrier, period);
654 break; 632 break;
655 case MCE_CMD_GETIRCFS: 633 case MCE_CMD_GETIRCFS:
656 dev_info(dev, "Get carrier mode and freq\n"); 634 dev_dbg(dev, "Get carrier mode and freq");
657 break; 635 break;
658 case MCE_RSP_EQIRTXPORTS: 636 case MCE_RSP_EQIRTXPORTS:
659 dev_info(dev, "%s transmit blaster mask of 0x%02x\n", 637 dev_dbg(dev, "%s transmit blaster mask of 0x%02x",
660 inout, data1); 638 inout, data1);
661 break; 639 break;
662 case MCE_RSP_EQIRTIMEOUT: 640 case MCE_RSP_EQIRTIMEOUT:
663 /* value is in units of 50us, so x*50/1000 ms */ 641 /* value is in units of 50us, so x*50/1000 ms */
664 period = ((data1 << 8) | data2) * MCE_TIME_UNIT / 1000; 642 period = ((data1 << 8) | data2) * MCE_TIME_UNIT / 1000;
665 dev_info(dev, "%s receive timeout of %d ms\n", 643 dev_dbg(dev, "%s receive timeout of %d ms",
666 inout, period); 644 inout, period);
667 break; 645 break;
668 case MCE_CMD_GETIRTIMEOUT: 646 case MCE_CMD_GETIRTIMEOUT:
669 dev_info(dev, "Get receive timeout\n"); 647 dev_dbg(dev, "Get receive timeout");
670 break; 648 break;
671 case MCE_CMD_GETIRTXPORTS: 649 case MCE_CMD_GETIRTXPORTS:
672 dev_info(dev, "Get transmit blaster mask\n"); 650 dev_dbg(dev, "Get transmit blaster mask");
673 break; 651 break;
674 case MCE_RSP_EQIRRXPORTEN: 652 case MCE_RSP_EQIRRXPORTEN:
675 dev_info(dev, "%s %s-range receive sensor in use\n", 653 dev_dbg(dev, "%s %s-range receive sensor in use",
676 inout, data1 == 0x02 ? "short" : "long"); 654 inout, data1 == 0x02 ? "short" : "long");
677 break; 655 break;
678 case MCE_CMD_GETIRRXPORTEN: 656 case MCE_CMD_GETIRRXPORTEN:
679 /* aka MCE_RSP_EQIRRXCFCNT */ 657 /* aka MCE_RSP_EQIRRXCFCNT */
680 if (out) 658 if (out)
681 dev_info(dev, "Get receive sensor\n"); 659 dev_dbg(dev, "Get receive sensor");
682 else if (ir->learning_enabled) 660 else if (ir->learning_enabled)
683 dev_info(dev, "RX pulse count: %d\n", 661 dev_dbg(dev, "RX pulse count: %d",
684 ((data1 << 8) | data2)); 662 ((data1 << 8) | data2));
685 break; 663 break;
686 case MCE_RSP_EQIRNUMPORTS: 664 case MCE_RSP_EQIRNUMPORTS:
687 if (out) 665 if (out)
688 break; 666 break;
689 dev_info(dev, "Num TX ports: %x, num RX ports: %x\n", 667 dev_dbg(dev, "Num TX ports: %x, num RX ports: %x",
690 data1, data2); 668 data1, data2);
691 break; 669 break;
692 case MCE_RSP_CMD_ILLEGAL: 670 case MCE_RSP_CMD_ILLEGAL:
693 dev_info(dev, "Illegal PORT_IR command\n"); 671 dev_dbg(dev, "Illegal PORT_IR command");
694 break; 672 break;
695 default: 673 default:
696 dev_info(dev, "Unknown command 0x%02x 0x%02x\n", 674 dev_dbg(dev, "Unknown command 0x%02x 0x%02x",
697 cmd, subcmd); 675 cmd, subcmd);
698 break; 676 break;
699 } 677 }
@@ -703,10 +681,11 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
703 } 681 }
704 682
705 if (cmd == MCE_IRDATA_TRAILER) 683 if (cmd == MCE_IRDATA_TRAILER)
706 dev_info(dev, "End of raw IR data\n"); 684 dev_dbg(dev, "End of raw IR data");
707 else if ((cmd != MCE_CMD_PORT_IR) && 685 else if ((cmd != MCE_CMD_PORT_IR) &&
708 ((cmd & MCE_PORT_MASK) == MCE_COMMAND_IRDATA)) 686 ((cmd & MCE_PORT_MASK) == MCE_COMMAND_IRDATA))
709 dev_info(dev, "Raw IR data, %d pulse/space samples\n", ir->rem); 687 dev_dbg(dev, "Raw IR data, %d pulse/space samples", ir->rem);
688#endif
710} 689}
711 690
712static void mce_async_callback(struct urb *urb) 691static void mce_async_callback(struct urb *urb)
@@ -718,10 +697,25 @@ static void mce_async_callback(struct urb *urb)
718 return; 697 return;
719 698
720 ir = urb->context; 699 ir = urb->context;
721 if (ir) { 700
701 switch (urb->status) {
702 /* success */
703 case 0:
722 len = urb->actual_length; 704 len = urb->actual_length;
723 705
724 mceusb_dev_printdata(ir, urb->transfer_buffer, 0, len, true); 706 mceusb_dev_printdata(ir, urb->transfer_buffer, 0, len, true);
707 break;
708
709 case -ECONNRESET:
710 case -ENOENT:
711 case -EILSEQ:
712 case -ESHUTDOWN:
713 break;
714
715 case -EPIPE:
716 default:
717 dev_err(ir->dev, "Error: request urb status = %d", urb->status);
718 break;
725 } 719 }
726 720
727 /* the transfer buffer and urb were allocated in mce_request_packet */ 721 /* the transfer buffer and urb were allocated in mce_request_packet */
@@ -770,17 +764,17 @@ static void mce_request_packet(struct mceusb_dev *ir, unsigned char *data,
770 return; 764 return;
771 } 765 }
772 766
773 mce_dbg(dev, "receive request called (size=%#x)\n", size); 767 dev_dbg(dev, "receive request called (size=%#x)", size);
774 768
775 async_urb->transfer_buffer_length = size; 769 async_urb->transfer_buffer_length = size;
776 async_urb->dev = ir->usbdev; 770 async_urb->dev = ir->usbdev;
777 771
778 res = usb_submit_urb(async_urb, GFP_ATOMIC); 772 res = usb_submit_urb(async_urb, GFP_ATOMIC);
779 if (res) { 773 if (res) {
780 mce_dbg(dev, "receive request FAILED! (res=%d)\n", res); 774 dev_err(dev, "receive request FAILED! (res=%d)", res);
781 return; 775 return;
782 } 776 }
783 mce_dbg(dev, "receive request complete (res=%d)\n", res); 777 dev_dbg(dev, "receive request complete (res=%d)", res);
784} 778}
785 779
786static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size) 780static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size)
@@ -895,8 +889,7 @@ static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier)
895 ir->carrier = carrier; 889 ir->carrier = carrier;
896 cmdbuf[2] = MCE_CMD_SIG_END; 890 cmdbuf[2] = MCE_CMD_SIG_END;
897 cmdbuf[3] = MCE_IRDATA_TRAILER; 891 cmdbuf[3] = MCE_IRDATA_TRAILER;
898 mce_dbg(ir->dev, "%s: disabling carrier " 892 dev_dbg(ir->dev, "disabling carrier modulation");
899 "modulation\n", __func__);
900 mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); 893 mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
901 return carrier; 894 return carrier;
902 } 895 }
@@ -907,8 +900,8 @@ static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier)
907 ir->carrier = carrier; 900 ir->carrier = carrier;
908 cmdbuf[2] = prescaler; 901 cmdbuf[2] = prescaler;
909 cmdbuf[3] = divisor; 902 cmdbuf[3] = divisor;
910 mce_dbg(ir->dev, "%s: requesting %u HZ " 903 dev_dbg(ir->dev, "requesting %u HZ carrier",
911 "carrier\n", __func__, carrier); 904 carrier);
912 905
913 /* Transmit new carrier to mce device */ 906 /* Transmit new carrier to mce device */
914 mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); 907 mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
@@ -998,7 +991,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
998 rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK) 991 rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK)
999 * US_TO_NS(MCE_TIME_UNIT); 992 * US_TO_NS(MCE_TIME_UNIT);
1000 993
1001 mce_dbg(ir->dev, "Storing %s with duration %d\n", 994 dev_dbg(ir->dev, "Storing %s with duration %d",
1002 rawir.pulse ? "pulse" : "space", 995 rawir.pulse ? "pulse" : "space",
1003 rawir.duration); 996 rawir.duration);
1004 997
@@ -1032,7 +1025,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
1032 ir->parser_state = CMD_HEADER; 1025 ir->parser_state = CMD_HEADER;
1033 } 1026 }
1034 if (event) { 1027 if (event) {
1035 mce_dbg(ir->dev, "processed IR data, calling ir_raw_event_handle\n"); 1028 dev_dbg(ir->dev, "processed IR data");
1036 ir_raw_event_handle(ir->rc); 1029 ir_raw_event_handle(ir->rc);
1037 } 1030 }
1038} 1031}
@@ -1055,7 +1048,7 @@ static void mceusb_dev_recv(struct urb *urb)
1055 1048
1056 if (ir->send_flags == RECV_FLAG_IN_PROGRESS) { 1049 if (ir->send_flags == RECV_FLAG_IN_PROGRESS) {
1057 ir->send_flags = SEND_FLAG_COMPLETE; 1050 ir->send_flags = SEND_FLAG_COMPLETE;
1058 mce_dbg(ir->dev, "setup answer received %d bytes\n", 1051 dev_dbg(ir->dev, "setup answer received %d bytes\n",
1059 buf_len); 1052 buf_len);
1060 } 1053 }
1061 1054
@@ -1067,13 +1060,14 @@ static void mceusb_dev_recv(struct urb *urb)
1067 1060
1068 case -ECONNRESET: 1061 case -ECONNRESET:
1069 case -ENOENT: 1062 case -ENOENT:
1063 case -EILSEQ:
1070 case -ESHUTDOWN: 1064 case -ESHUTDOWN:
1071 usb_unlink_urb(urb); 1065 usb_unlink_urb(urb);
1072 return; 1066 return;
1073 1067
1074 case -EPIPE: 1068 case -EPIPE:
1075 default: 1069 default:
1076 mce_dbg(ir->dev, "Error: urb status = %d\n", urb->status); 1070 dev_err(ir->dev, "Error: urb status = %d", urb->status);
1077 break; 1071 break;
1078 } 1072 }
1079 1073
@@ -1095,7 +1089,7 @@ static void mceusb_gen1_init(struct mceusb_dev *ir)
1095 1089
1096 data = kzalloc(USB_CTRL_MSG_SZ, GFP_KERNEL); 1090 data = kzalloc(USB_CTRL_MSG_SZ, GFP_KERNEL);
1097 if (!data) { 1091 if (!data) {
1098 dev_err(dev, "%s: memory allocation failed!\n", __func__); 1092 dev_err(dev, "%s: memory allocation failed!", __func__);
1099 return; 1093 return;
1100 } 1094 }
1101 1095
@@ -1106,28 +1100,28 @@ static void mceusb_gen1_init(struct mceusb_dev *ir)
1106 ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0), 1100 ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0),
1107 USB_REQ_SET_ADDRESS, USB_TYPE_VENDOR, 0, 0, 1101 USB_REQ_SET_ADDRESS, USB_TYPE_VENDOR, 0, 0,
1108 data, USB_CTRL_MSG_SZ, HZ * 3); 1102 data, USB_CTRL_MSG_SZ, HZ * 3);
1109 mce_dbg(dev, "%s - ret = %d\n", __func__, ret); 1103 dev_dbg(dev, "set address - ret = %d", ret);
1110 mce_dbg(dev, "%s - data[0] = %d, data[1] = %d\n", 1104 dev_dbg(dev, "set address - data[0] = %d, data[1] = %d",
1111 __func__, data[0], data[1]); 1105 data[0], data[1]);
1112 1106
1113 /* set feature: bit rate 38400 bps */ 1107 /* set feature: bit rate 38400 bps */
1114 ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0), 1108 ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
1115 USB_REQ_SET_FEATURE, USB_TYPE_VENDOR, 1109 USB_REQ_SET_FEATURE, USB_TYPE_VENDOR,
1116 0xc04e, 0x0000, NULL, 0, HZ * 3); 1110 0xc04e, 0x0000, NULL, 0, HZ * 3);
1117 1111
1118 mce_dbg(dev, "%s - ret = %d\n", __func__, ret); 1112 dev_dbg(dev, "set feature - ret = %d", ret);
1119 1113
1120 /* bRequest 4: set char length to 8 bits */ 1114 /* bRequest 4: set char length to 8 bits */
1121 ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0), 1115 ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
1122 4, USB_TYPE_VENDOR, 1116 4, USB_TYPE_VENDOR,
1123 0x0808, 0x0000, NULL, 0, HZ * 3); 1117 0x0808, 0x0000, NULL, 0, HZ * 3);
1124 mce_dbg(dev, "%s - retB = %d\n", __func__, ret); 1118 dev_dbg(dev, "set char length - retB = %d", ret);
1125 1119
1126 /* bRequest 2: set handshaking to use DTR/DSR */ 1120 /* bRequest 2: set handshaking to use DTR/DSR */
1127 ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0), 1121 ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
1128 2, USB_TYPE_VENDOR, 1122 2, USB_TYPE_VENDOR,
1129 0x0000, 0x0100, NULL, 0, HZ * 3); 1123 0x0000, 0x0100, NULL, 0, HZ * 3);
1130 mce_dbg(dev, "%s - retC = %d\n", __func__, ret); 1124 dev_dbg(dev, "set handshake - retC = %d", ret);
1131 1125
1132 /* device resume */ 1126 /* device resume */
1133 mce_async_out(ir, DEVICE_RESUME, sizeof(DEVICE_RESUME)); 1127 mce_async_out(ir, DEVICE_RESUME, sizeof(DEVICE_RESUME));
@@ -1198,7 +1192,7 @@ static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
1198 1192
1199 rc = rc_allocate_device(); 1193 rc = rc_allocate_device();
1200 if (!rc) { 1194 if (!rc) {
1201 dev_err(dev, "remote dev allocation failed\n"); 1195 dev_err(dev, "remote dev allocation failed");
1202 goto out; 1196 goto out;
1203 } 1197 }
1204 1198
@@ -1217,7 +1211,7 @@ static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
1217 rc->dev.parent = dev; 1211 rc->dev.parent = dev;
1218 rc->priv = ir; 1212 rc->priv = ir;
1219 rc->driver_type = RC_DRIVER_IR_RAW; 1213 rc->driver_type = RC_DRIVER_IR_RAW;
1220 rc->allowed_protos = RC_BIT_ALL; 1214 rc_set_allowed_protocols(rc, RC_BIT_ALL);
1221 rc->timeout = MS_TO_NS(100); 1215 rc->timeout = MS_TO_NS(100);
1222 if (!ir->flags.no_tx) { 1216 if (!ir->flags.no_tx) {
1223 rc->s_tx_mask = mceusb_set_tx_mask; 1217 rc->s_tx_mask = mceusb_set_tx_mask;
@@ -1230,7 +1224,7 @@ static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
1230 1224
1231 ret = rc_register_device(rc); 1225 ret = rc_register_device(rc);
1232 if (ret < 0) { 1226 if (ret < 0) {
1233 dev_err(dev, "remote dev registration failed\n"); 1227 dev_err(dev, "remote dev registration failed");
1234 goto out; 1228 goto out;
1235 } 1229 }
1236 1230
@@ -1258,7 +1252,7 @@ static int mceusb_dev_probe(struct usb_interface *intf,
1258 bool tx_mask_normal; 1252 bool tx_mask_normal;
1259 int ir_intfnum; 1253 int ir_intfnum;
1260 1254
1261 mce_dbg(&intf->dev, "%s called\n", __func__); 1255 dev_dbg(&intf->dev, "%s called", __func__);
1262 1256
1263 idesc = intf->cur_altsetting; 1257 idesc = intf->cur_altsetting;
1264 1258
@@ -1286,8 +1280,7 @@ static int mceusb_dev_probe(struct usb_interface *intf,
1286 ep_in = ep; 1280 ep_in = ep;
1287 ep_in->bmAttributes = USB_ENDPOINT_XFER_INT; 1281 ep_in->bmAttributes = USB_ENDPOINT_XFER_INT;
1288 ep_in->bInterval = 1; 1282 ep_in->bInterval = 1;
1289 mce_dbg(&intf->dev, "acceptable inbound endpoint " 1283 dev_dbg(&intf->dev, "acceptable inbound endpoint found");
1290 "found\n");
1291 } 1284 }
1292 1285
1293 if ((ep_out == NULL) 1286 if ((ep_out == NULL)
@@ -1301,12 +1294,11 @@ static int mceusb_dev_probe(struct usb_interface *intf,
1301 ep_out = ep; 1294 ep_out = ep;
1302 ep_out->bmAttributes = USB_ENDPOINT_XFER_INT; 1295 ep_out->bmAttributes = USB_ENDPOINT_XFER_INT;
1303 ep_out->bInterval = 1; 1296 ep_out->bInterval = 1;
1304 mce_dbg(&intf->dev, "acceptable outbound endpoint " 1297 dev_dbg(&intf->dev, "acceptable outbound endpoint found");
1305 "found\n");
1306 } 1298 }
1307 } 1299 }
1308 if (ep_in == NULL) { 1300 if (ep_in == NULL) {
1309 mce_dbg(&intf->dev, "inbound and/or endpoint not found\n"); 1301 dev_dbg(&intf->dev, "inbound and/or endpoint not found");
1310 return -ENODEV; 1302 return -ENODEV;
1311 } 1303 }
1312 1304
@@ -1357,7 +1349,7 @@ static int mceusb_dev_probe(struct usb_interface *intf,
1357 ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1349 ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1358 1350
1359 /* flush buffers on the device */ 1351 /* flush buffers on the device */
1360 mce_dbg(&intf->dev, "Flushing receive buffers\n"); 1352 dev_dbg(&intf->dev, "Flushing receive buffers\n");
1361 mce_flush_rx_buffer(ir, maxp); 1353 mce_flush_rx_buffer(ir, maxp);
1362 1354
1363 /* figure out which firmware/emulator version this hardware has */ 1355 /* figure out which firmware/emulator version this hardware has */
@@ -1382,10 +1374,9 @@ static int mceusb_dev_probe(struct usb_interface *intf,
1382 device_set_wakeup_capable(ir->dev, true); 1374 device_set_wakeup_capable(ir->dev, true);
1383 device_set_wakeup_enable(ir->dev, true); 1375 device_set_wakeup_enable(ir->dev, true);
1384 1376
1385 dev_info(&intf->dev, "Registered %s with mce emulator interface " 1377 dev_info(&intf->dev, "Registered %s with mce emulator interface version %x",
1386 "version %x\n", name, ir->emver); 1378 name, ir->emver);
1387 dev_info(&intf->dev, "%x tx ports (0x%x cabled) and " 1379 dev_info(&intf->dev, "%x tx ports (0x%x cabled) and %x rx sensors (0x%x active)",
1388 "%x rx sensors (0x%x active)\n",
1389 ir->num_txports, ir->txports_cabled, 1380 ir->num_txports, ir->txports_cabled,
1390 ir->num_rxports, ir->rxports_active); 1381 ir->num_rxports, ir->rxports_active);
1391 1382
@@ -1399,7 +1390,7 @@ urb_in_alloc_fail:
1399buf_in_alloc_fail: 1390buf_in_alloc_fail:
1400 kfree(ir); 1391 kfree(ir);
1401mem_alloc_fail: 1392mem_alloc_fail:
1402 dev_err(&intf->dev, "%s: device setup failed!\n", __func__); 1393 dev_err(&intf->dev, "%s: device setup failed!", __func__);
1403 1394
1404 return -ENOMEM; 1395 return -ENOMEM;
1405} 1396}
@@ -1427,7 +1418,7 @@ static void mceusb_dev_disconnect(struct usb_interface *intf)
1427static int mceusb_dev_suspend(struct usb_interface *intf, pm_message_t message) 1418static int mceusb_dev_suspend(struct usb_interface *intf, pm_message_t message)
1428{ 1419{
1429 struct mceusb_dev *ir = usb_get_intfdata(intf); 1420 struct mceusb_dev *ir = usb_get_intfdata(intf);
1430 dev_info(ir->dev, "suspend\n"); 1421 dev_info(ir->dev, "suspend");
1431 usb_kill_urb(ir->urb_in); 1422 usb_kill_urb(ir->urb_in);
1432 return 0; 1423 return 0;
1433} 1424}
@@ -1435,7 +1426,7 @@ static int mceusb_dev_suspend(struct usb_interface *intf, pm_message_t message)
1435static int mceusb_dev_resume(struct usb_interface *intf) 1426static int mceusb_dev_resume(struct usb_interface *intf)
1436{ 1427{
1437 struct mceusb_dev *ir = usb_get_intfdata(intf); 1428 struct mceusb_dev *ir = usb_get_intfdata(intf);
1438 dev_info(ir->dev, "resume\n"); 1429 dev_info(ir->dev, "resume");
1439 if (usb_submit_urb(ir->urb_in, GFP_ATOMIC)) 1430 if (usb_submit_urb(ir->urb_in, GFP_ATOMIC))
1440 return -EIO; 1431 return -EIO;
1441 return 0; 1432 return 0;
@@ -1457,6 +1448,3 @@ MODULE_DESCRIPTION(DRIVER_DESC);
1457MODULE_AUTHOR(DRIVER_AUTHOR); 1448MODULE_AUTHOR(DRIVER_AUTHOR);
1458MODULE_LICENSE("GPL"); 1449MODULE_LICENSE("GPL");
1459MODULE_DEVICE_TABLE(usb, mceusb_dev_table); 1450MODULE_DEVICE_TABLE(usb, mceusb_dev_table);
1460
1461module_param(debug, bool, S_IRUGO | S_IWUSR);
1462MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index 21ee0dc1b7ec..d244e1a83f43 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -330,9 +330,6 @@ static void nvt_cir_wake_ldev_init(struct nvt_dev *nvt)
330 /* Enable CIR Wake via PSOUT# (Pin60) */ 330 /* Enable CIR Wake via PSOUT# (Pin60) */
331 nvt_set_reg_bit(nvt, CIR_WAKE_ENABLE_BIT, CR_ACPI_CIR_WAKE); 331 nvt_set_reg_bit(nvt, CIR_WAKE_ENABLE_BIT, CR_ACPI_CIR_WAKE);
332 332
333 /* enable cir interrupt of mouse/keyboard IRQ event */
334 nvt_set_reg_bit(nvt, CIR_INTR_MOUSE_IRQ_BIT, CR_ACPI_IRQ_EVENTS);
335
336 /* enable pme interrupt of cir wakeup event */ 333 /* enable pme interrupt of cir wakeup event */
337 nvt_set_reg_bit(nvt, PME_INTR_CIR_PASS_BIT, CR_ACPI_IRQ_EVENTS2); 334 nvt_set_reg_bit(nvt, PME_INTR_CIR_PASS_BIT, CR_ACPI_IRQ_EVENTS2);
338 335
@@ -456,7 +453,6 @@ static void nvt_enable_wake(struct nvt_dev *nvt)
456 453
457 nvt_select_logical_dev(nvt, LOGICAL_DEV_ACPI); 454 nvt_select_logical_dev(nvt, LOGICAL_DEV_ACPI);
458 nvt_set_reg_bit(nvt, CIR_WAKE_ENABLE_BIT, CR_ACPI_CIR_WAKE); 455 nvt_set_reg_bit(nvt, CIR_WAKE_ENABLE_BIT, CR_ACPI_CIR_WAKE);
459 nvt_set_reg_bit(nvt, CIR_INTR_MOUSE_IRQ_BIT, CR_ACPI_IRQ_EVENTS);
460 nvt_set_reg_bit(nvt, PME_INTR_CIR_PASS_BIT, CR_ACPI_IRQ_EVENTS2); 456 nvt_set_reg_bit(nvt, PME_INTR_CIR_PASS_BIT, CR_ACPI_IRQ_EVENTS2);
461 457
462 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR_WAKE); 458 nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR_WAKE);
@@ -989,6 +985,12 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
989 goto exit_free_dev_rdev; 985 goto exit_free_dev_rdev;
990 986
991 ret = -ENODEV; 987 ret = -ENODEV;
988 /* activate pnp device */
989 if (pnp_activate_dev(pdev) < 0) {
990 dev_err(&pdev->dev, "Could not activate PNP device!\n");
991 goto exit_free_dev_rdev;
992 }
993
992 /* validate pnp resources */ 994 /* validate pnp resources */
993 if (!pnp_port_valid(pdev, 0) || 995 if (!pnp_port_valid(pdev, 0) ||
994 pnp_port_len(pdev, 0) < CIR_IOREG_LENGTH) { 996 pnp_port_len(pdev, 0) < CIR_IOREG_LENGTH) {
@@ -1042,7 +1044,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1042 /* Set up the rc device */ 1044 /* Set up the rc device */
1043 rdev->priv = nvt; 1045 rdev->priv = nvt;
1044 rdev->driver_type = RC_DRIVER_IR_RAW; 1046 rdev->driver_type = RC_DRIVER_IR_RAW;
1045 rdev->allowed_protos = RC_BIT_ALL; 1047 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
1046 rdev->open = nvt_open; 1048 rdev->open = nvt_open;
1047 rdev->close = nvt_close; 1049 rdev->close = nvt_close;
1048 rdev->tx_ir = nvt_tx_ir; 1050 rdev->tx_ir = nvt_tx_ir;
diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h
index 07e83108df0f..e1cf23c3875b 100644
--- a/drivers/media/rc/nuvoton-cir.h
+++ b/drivers/media/rc/nuvoton-cir.h
@@ -363,7 +363,6 @@ struct nvt_dev {
363#define LOGICAL_DEV_ENABLE 0x01 363#define LOGICAL_DEV_ENABLE 0x01
364 364
365#define CIR_WAKE_ENABLE_BIT 0x08 365#define CIR_WAKE_ENABLE_BIT 0x08
366#define CIR_INTR_MOUSE_IRQ_BIT 0x80
367#define PME_INTR_CIR_PASS_BIT 0x08 366#define PME_INTR_CIR_PASS_BIT 0x08
368 367
369/* w83677hg CIR pin config */ 368/* w83677hg CIR pin config */
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index 70a180bb0bd0..da536c93c978 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Remote Controller core raw events header 2 * Remote Controller core raw events header
3 * 3 *
4 * Copyright (C) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 4 * Copyright (C) 2010 by Mauro Carvalho Chehab
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
@@ -88,6 +88,12 @@ struct ir_raw_event_ctrl {
88 unsigned count; 88 unsigned count;
89 u64 bits; 89 u64 bits;
90 } sanyo; 90 } sanyo;
91 struct sharp_dec {
92 int state;
93 unsigned count;
94 u32 bits;
95 unsigned int pulse_len;
96 } sharp;
91 struct mce_kbd_dec { 97 struct mce_kbd_dec {
92 struct input_dev *idev; 98 struct input_dev *idev;
93 struct timer_list rx_timeout; 99 struct timer_list rx_timeout;
@@ -204,6 +210,13 @@ static inline void load_sony_decode(void) { }
204static inline void load_sanyo_decode(void) { } 210static inline void load_sanyo_decode(void) { }
205#endif 211#endif
206 212
213/* from ir-sharp-decoder.c */
214#ifdef CONFIG_IR_SHARP_DECODER_MODULE
215#define load_sharp_decode() request_module_nowait("ir-sharp-decoder")
216#else
217static inline void load_sharp_decode(void) { }
218#endif
219
207/* from ir-mce_kbd-decoder.c */ 220/* from ir-mce_kbd-decoder.c */
208#ifdef CONFIG_IR_MCE_KBD_DECODER_MODULE 221#ifdef CONFIG_IR_MCE_KBD_DECODER_MODULE
209#define load_mce_kbd_decode() request_module_nowait("ir-mce_kbd-decoder") 222#define load_mce_kbd_decode() request_module_nowait("ir-mce_kbd-decoder")
diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c
index 53d02827a472..0a88e0cf964f 100644
--- a/drivers/media/rc/rc-loopback.c
+++ b/drivers/media/rc/rc-loopback.c
@@ -195,7 +195,7 @@ static int __init loop_init(void)
195 rc->map_name = RC_MAP_EMPTY; 195 rc->map_name = RC_MAP_EMPTY;
196 rc->priv = &loopdev; 196 rc->priv = &loopdev;
197 rc->driver_type = RC_DRIVER_IR_RAW; 197 rc->driver_type = RC_DRIVER_IR_RAW;
198 rc->allowed_protos = RC_BIT_ALL; 198 rc_set_allowed_protocols(rc, RC_BIT_ALL);
199 rc->timeout = 100 * 1000 * 1000; /* 100 ms */ 199 rc->timeout = 100 * 1000 * 1000; /* 100 ms */
200 rc->min_timeout = 1; 200 rc->min_timeout = 1;
201 rc->max_timeout = UINT_MAX; 201 rc->max_timeout = UINT_MAX;
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 02e2f38c9c85..99697aae92ff 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -1,6 +1,6 @@
1/* rc-main.c - Remote Controller core module 1/* rc-main.c - Remote Controller core module
2 * 2 *
3 * Copyright (C) 2009-2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 3 * Copyright (C) 2009-2010 by Mauro Carvalho Chehab
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
24 24
25/* Bitmap to store allocated device numbers from 0 to IRRCV_NUM_DEVICES - 1 */ 25/* Bitmap to store allocated device numbers from 0 to IRRCV_NUM_DEVICES - 1 */
26#define IRRCV_NUM_DEVICES 256 26#define IRRCV_NUM_DEVICES 256
27DECLARE_BITMAP(ir_core_dev_number, IRRCV_NUM_DEVICES); 27static DECLARE_BITMAP(ir_core_dev_number, IRRCV_NUM_DEVICES);
28 28
29/* Sizes are in bytes, 256 bytes allows for 32 entries on x64 */ 29/* Sizes are in bytes, 256 bytes allows for 32 entries on x64 */
30#define IR_TAB_MIN_SIZE 256 30#define IR_TAB_MIN_SIZE 256
@@ -62,7 +62,7 @@ struct rc_map *rc_map_get(const char *name)
62 map = seek_rc_map(name); 62 map = seek_rc_map(name);
63#ifdef MODULE 63#ifdef MODULE
64 if (!map) { 64 if (!map) {
65 int rc = request_module(name); 65 int rc = request_module("%s", name);
66 if (rc < 0) { 66 if (rc < 0) {
67 printk(KERN_ERR "Couldn't load IR keymap %s\n", name); 67 printk(KERN_ERR "Couldn't load IR keymap %s\n", name);
68 return NULL; 68 return NULL;
@@ -633,6 +633,7 @@ EXPORT_SYMBOL_GPL(rc_repeat);
633static void ir_do_keydown(struct rc_dev *dev, int scancode, 633static void ir_do_keydown(struct rc_dev *dev, int scancode,
634 u32 keycode, u8 toggle) 634 u32 keycode, u8 toggle)
635{ 635{
636 struct rc_scancode_filter *filter;
636 bool new_event = !dev->keypressed || 637 bool new_event = !dev->keypressed ||
637 dev->last_scancode != scancode || 638 dev->last_scancode != scancode ||
638 dev->last_toggle != toggle; 639 dev->last_toggle != toggle;
@@ -640,6 +641,11 @@ static void ir_do_keydown(struct rc_dev *dev, int scancode,
640 if (new_event && dev->keypressed) 641 if (new_event && dev->keypressed)
641 ir_do_keyup(dev, false); 642 ir_do_keyup(dev, false);
642 643
644 /* Generic scancode filtering */
645 filter = &dev->scancode_filters[RC_FILTER_NORMAL];
646 if (filter->mask && ((scancode ^ filter->data) & filter->mask))
647 return;
648
643 input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode); 649 input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode);
644 650
645 if (new_event && keycode != KEY_RESERVED) { 651 if (new_event && keycode != KEY_RESERVED) {
@@ -653,9 +659,10 @@ static void ir_do_keydown(struct rc_dev *dev, int scancode,
653 "key 0x%04x, scancode 0x%04x\n", 659 "key 0x%04x, scancode 0x%04x\n",
654 dev->input_name, keycode, scancode); 660 dev->input_name, keycode, scancode);
655 input_report_key(dev->input_dev, keycode, 1); 661 input_report_key(dev->input_dev, keycode, 1);
662
663 led_trigger_event(led_feedback, LED_FULL);
656 } 664 }
657 665
658 led_trigger_event(led_feedback, LED_FULL);
659 input_sync(dev->input_dev); 666 input_sync(dev->input_dev);
660} 667}
661 668
@@ -790,18 +797,44 @@ static struct {
790 RC_BIT_SONY20, "sony" }, 797 RC_BIT_SONY20, "sony" },
791 { RC_BIT_RC5_SZ, "rc-5-sz" }, 798 { RC_BIT_RC5_SZ, "rc-5-sz" },
792 { RC_BIT_SANYO, "sanyo" }, 799 { RC_BIT_SANYO, "sanyo" },
800 { RC_BIT_SHARP, "sharp" },
793 { RC_BIT_MCE_KBD, "mce_kbd" }, 801 { RC_BIT_MCE_KBD, "mce_kbd" },
794 { RC_BIT_LIRC, "lirc" }, 802 { RC_BIT_LIRC, "lirc" },
795}; 803};
796 804
797/** 805/**
798 * show_protocols() - shows the current IR protocol(s) 806 * struct rc_filter_attribute - Device attribute relating to a filter type.
807 * @attr: Device attribute.
808 * @type: Filter type.
809 * @mask: false for filter value, true for filter mask.
810 */
811struct rc_filter_attribute {
812 struct device_attribute attr;
813 enum rc_filter_type type;
814 bool mask;
815};
816#define to_rc_filter_attr(a) container_of(a, struct rc_filter_attribute, attr)
817
818#define RC_PROTO_ATTR(_name, _mode, _show, _store, _type) \
819 struct rc_filter_attribute dev_attr_##_name = { \
820 .attr = __ATTR(_name, _mode, _show, _store), \
821 .type = (_type), \
822 }
823#define RC_FILTER_ATTR(_name, _mode, _show, _store, _type, _mask) \
824 struct rc_filter_attribute dev_attr_##_name = { \
825 .attr = __ATTR(_name, _mode, _show, _store), \
826 .type = (_type), \
827 .mask = (_mask), \
828 }
829
830/**
831 * show_protocols() - shows the current/wakeup IR protocol(s)
799 * @device: the device descriptor 832 * @device: the device descriptor
800 * @mattr: the device attribute struct (unused) 833 * @mattr: the device attribute struct (unused)
801 * @buf: a pointer to the output buffer 834 * @buf: a pointer to the output buffer
802 * 835 *
803 * This routine is a callback routine for input read the IR protocol type(s). 836 * This routine is a callback routine for input read the IR protocol type(s).
804 * it is trigged by reading /sys/class/rc/rc?/protocols. 837 * it is trigged by reading /sys/class/rc/rc?/[wakeup_]protocols.
805 * It returns the protocol names of supported protocols. 838 * It returns the protocol names of supported protocols.
806 * Enabled protocols are printed in brackets. 839 * Enabled protocols are printed in brackets.
807 * 840 *
@@ -812,6 +845,7 @@ static ssize_t show_protocols(struct device *device,
812 struct device_attribute *mattr, char *buf) 845 struct device_attribute *mattr, char *buf)
813{ 846{
814 struct rc_dev *dev = to_rc_dev(device); 847 struct rc_dev *dev = to_rc_dev(device);
848 struct rc_filter_attribute *fattr = to_rc_filter_attr(mattr);
815 u64 allowed, enabled; 849 u64 allowed, enabled;
816 char *tmp = buf; 850 char *tmp = buf;
817 int i; 851 int i;
@@ -822,9 +856,10 @@ static ssize_t show_protocols(struct device *device,
822 856
823 mutex_lock(&dev->lock); 857 mutex_lock(&dev->lock);
824 858
825 enabled = dev->enabled_protocols; 859 enabled = dev->enabled_protocols[fattr->type];
826 if (dev->driver_type == RC_DRIVER_SCANCODE) 860 if (dev->driver_type == RC_DRIVER_SCANCODE ||
827 allowed = dev->allowed_protos; 861 fattr->type == RC_FILTER_WAKEUP)
862 allowed = dev->allowed_protocols[fattr->type];
828 else if (dev->raw) 863 else if (dev->raw)
829 allowed = ir_raw_get_allowed_protocols(); 864 allowed = ir_raw_get_allowed_protocols();
830 else { 865 else {
@@ -856,14 +891,14 @@ static ssize_t show_protocols(struct device *device,
856} 891}
857 892
858/** 893/**
859 * store_protocols() - changes the current IR protocol(s) 894 * store_protocols() - changes the current/wakeup IR protocol(s)
860 * @device: the device descriptor 895 * @device: the device descriptor
861 * @mattr: the device attribute struct (unused) 896 * @mattr: the device attribute struct (unused)
862 * @buf: a pointer to the input buffer 897 * @buf: a pointer to the input buffer
863 * @len: length of the input buffer 898 * @len: length of the input buffer
864 * 899 *
865 * This routine is for changing the IR protocol type. 900 * This routine is for changing the IR protocol type.
866 * It is trigged by writing to /sys/class/rc/rc?/protocols. 901 * It is trigged by writing to /sys/class/rc/rc?/[wakeup_]protocols.
867 * Writing "+proto" will add a protocol to the list of enabled protocols. 902 * Writing "+proto" will add a protocol to the list of enabled protocols.
868 * Writing "-proto" will remove a protocol from the list of enabled protocols. 903 * Writing "-proto" will remove a protocol from the list of enabled protocols.
869 * Writing "proto" will enable only "proto". 904 * Writing "proto" will enable only "proto".
@@ -880,12 +915,15 @@ static ssize_t store_protocols(struct device *device,
880 size_t len) 915 size_t len)
881{ 916{
882 struct rc_dev *dev = to_rc_dev(device); 917 struct rc_dev *dev = to_rc_dev(device);
918 struct rc_filter_attribute *fattr = to_rc_filter_attr(mattr);
883 bool enable, disable; 919 bool enable, disable;
884 const char *tmp; 920 const char *tmp;
885 u64 type; 921 u64 old_type, type;
886 u64 mask; 922 u64 mask;
887 int rc, i, count = 0; 923 int rc, i, count = 0;
888 ssize_t ret; 924 ssize_t ret;
925 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type);
926 struct rc_scancode_filter local_filter, *filter;
889 927
890 /* Device is being removed */ 928 /* Device is being removed */
891 if (!dev) 929 if (!dev)
@@ -898,7 +936,8 @@ static ssize_t store_protocols(struct device *device,
898 ret = -EINVAL; 936 ret = -EINVAL;
899 goto out; 937 goto out;
900 } 938 }
901 type = dev->enabled_protocols; 939 old_type = dev->enabled_protocols[fattr->type];
940 type = old_type;
902 941
903 while ((tmp = strsep((char **) &data, " \n")) != NULL) { 942 while ((tmp = strsep((char **) &data, " \n")) != NULL) {
904 if (!*tmp) 943 if (!*tmp)
@@ -946,8 +985,10 @@ static ssize_t store_protocols(struct device *device,
946 goto out; 985 goto out;
947 } 986 }
948 987
949 if (dev->change_protocol) { 988 change_protocol = (fattr->type == RC_FILTER_NORMAL)
950 rc = dev->change_protocol(dev, &type); 989 ? dev->change_protocol : dev->change_wakeup_protocol;
990 if (change_protocol) {
991 rc = change_protocol(dev, &type);
951 if (rc < 0) { 992 if (rc < 0) {
952 IR_dprintk(1, "Error setting protocols to 0x%llx\n", 993 IR_dprintk(1, "Error setting protocols to 0x%llx\n",
953 (long long)type); 994 (long long)type);
@@ -956,10 +997,40 @@ static ssize_t store_protocols(struct device *device,
956 } 997 }
957 } 998 }
958 999
959 dev->enabled_protocols = type; 1000 dev->enabled_protocols[fattr->type] = type;
960 IR_dprintk(1, "Current protocol(s): 0x%llx\n", 1001 IR_dprintk(1, "Current protocol(s): 0x%llx\n",
961 (long long)type); 1002 (long long)type);
962 1003
1004 /*
1005 * If the protocol is changed the filter needs updating.
1006 * Try setting the same filter with the new protocol (if any).
1007 * Fall back to clearing the filter.
1008 */
1009 filter = &dev->scancode_filters[fattr->type];
1010 if (old_type != type && filter->mask) {
1011 local_filter = *filter;
1012 if (!type) {
1013 /* no protocol => clear filter */
1014 ret = -1;
1015 } else if (!dev->s_filter) {
1016 /* generic filtering => accept any filter */
1017 ret = 0;
1018 } else {
1019 /* hardware filtering => try setting, otherwise clear */
1020 ret = dev->s_filter(dev, fattr->type, &local_filter);
1021 }
1022 if (ret < 0) {
1023 /* clear the filter */
1024 local_filter.data = 0;
1025 local_filter.mask = 0;
1026 if (dev->s_filter)
1027 dev->s_filter(dev, fattr->type, &local_filter);
1028 }
1029
1030 /* commit the new filter */
1031 *filter = local_filter;
1032 }
1033
963 ret = len; 1034 ret = len;
964 1035
965out: 1036out:
@@ -967,6 +1038,115 @@ out:
967 return ret; 1038 return ret;
968} 1039}
969 1040
1041/**
1042 * show_filter() - shows the current scancode filter value or mask
1043 * @device: the device descriptor
1044 * @attr: the device attribute struct
1045 * @buf: a pointer to the output buffer
1046 *
1047 * This routine is a callback routine to read a scancode filter value or mask.
1048 * It is trigged by reading /sys/class/rc/rc?/[wakeup_]filter[_mask].
1049 * It prints the current scancode filter value or mask of the appropriate filter
1050 * type in hexadecimal into @buf and returns the size of the buffer.
1051 *
1052 * Bits of the filter value corresponding to set bits in the filter mask are
1053 * compared against input scancodes and non-matching scancodes are discarded.
1054 *
1055 * dev->lock is taken to guard against races between device registration,
1056 * store_filter and show_filter.
1057 */
1058static ssize_t show_filter(struct device *device,
1059 struct device_attribute *attr,
1060 char *buf)
1061{
1062 struct rc_dev *dev = to_rc_dev(device);
1063 struct rc_filter_attribute *fattr = to_rc_filter_attr(attr);
1064 u32 val;
1065
1066 /* Device is being removed */
1067 if (!dev)
1068 return -EINVAL;
1069
1070 mutex_lock(&dev->lock);
1071 if (fattr->mask)
1072 val = dev->scancode_filters[fattr->type].mask;
1073 else
1074 val = dev->scancode_filters[fattr->type].data;
1075 mutex_unlock(&dev->lock);
1076
1077 return sprintf(buf, "%#x\n", val);
1078}
1079
1080/**
1081 * store_filter() - changes the scancode filter value
1082 * @device: the device descriptor
1083 * @attr: the device attribute struct
1084 * @buf: a pointer to the input buffer
1085 * @len: length of the input buffer
1086 *
1087 * This routine is for changing a scancode filter value or mask.
1088 * It is trigged by writing to /sys/class/rc/rc?/[wakeup_]filter[_mask].
1089 * Returns -EINVAL if an invalid filter value for the current protocol was
1090 * specified or if scancode filtering is not supported by the driver, otherwise
1091 * returns @len.
1092 *
1093 * Bits of the filter value corresponding to set bits in the filter mask are
1094 * compared against input scancodes and non-matching scancodes are discarded.
1095 *
1096 * dev->lock is taken to guard against races between device registration,
1097 * store_filter and show_filter.
1098 */
1099static ssize_t store_filter(struct device *device,
1100 struct device_attribute *attr,
1101 const char *buf,
1102 size_t count)
1103{
1104 struct rc_dev *dev = to_rc_dev(device);
1105 struct rc_filter_attribute *fattr = to_rc_filter_attr(attr);
1106 struct rc_scancode_filter local_filter, *filter;
1107 int ret;
1108 unsigned long val;
1109
1110 /* Device is being removed */
1111 if (!dev)
1112 return -EINVAL;
1113
1114 ret = kstrtoul(buf, 0, &val);
1115 if (ret < 0)
1116 return ret;
1117
1118 /* Scancode filter not supported (but still accept 0) */
1119 if (!dev->s_filter && fattr->type != RC_FILTER_NORMAL)
1120 return val ? -EINVAL : count;
1121
1122 mutex_lock(&dev->lock);
1123
1124 /* Tell the driver about the new filter */
1125 filter = &dev->scancode_filters[fattr->type];
1126 local_filter = *filter;
1127 if (fattr->mask)
1128 local_filter.mask = val;
1129 else
1130 local_filter.data = val;
1131 if (!dev->enabled_protocols[fattr->type] && local_filter.mask) {
1132 /* refuse to set a filter unless a protocol is enabled */
1133 ret = -EINVAL;
1134 goto unlock;
1135 }
1136 if (dev->s_filter) {
1137 ret = dev->s_filter(dev, fattr->type, &local_filter);
1138 if (ret < 0)
1139 goto unlock;
1140 }
1141
1142 /* Success, commit the new filter */
1143 *filter = local_filter;
1144
1145unlock:
1146 mutex_unlock(&dev->lock);
1147 return (ret < 0) ? ret : count;
1148}
1149
970static void rc_dev_release(struct device *device) 1150static void rc_dev_release(struct device *device)
971{ 1151{
972} 1152}
@@ -996,11 +1176,26 @@ static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env)
996/* 1176/*
997 * Static device attribute struct with the sysfs attributes for IR's 1177 * Static device attribute struct with the sysfs attributes for IR's
998 */ 1178 */
999static DEVICE_ATTR(protocols, S_IRUGO | S_IWUSR, 1179static RC_PROTO_ATTR(protocols, S_IRUGO | S_IWUSR,
1000 show_protocols, store_protocols); 1180 show_protocols, store_protocols, RC_FILTER_NORMAL);
1181static RC_PROTO_ATTR(wakeup_protocols, S_IRUGO | S_IWUSR,
1182 show_protocols, store_protocols, RC_FILTER_WAKEUP);
1183static RC_FILTER_ATTR(filter, S_IRUGO|S_IWUSR,
1184 show_filter, store_filter, RC_FILTER_NORMAL, false);
1185static RC_FILTER_ATTR(filter_mask, S_IRUGO|S_IWUSR,
1186 show_filter, store_filter, RC_FILTER_NORMAL, true);
1187static RC_FILTER_ATTR(wakeup_filter, S_IRUGO|S_IWUSR,
1188 show_filter, store_filter, RC_FILTER_WAKEUP, false);
1189static RC_FILTER_ATTR(wakeup_filter_mask, S_IRUGO|S_IWUSR,
1190 show_filter, store_filter, RC_FILTER_WAKEUP, true);
1001 1191
1002static struct attribute *rc_dev_attrs[] = { 1192static struct attribute *rc_dev_attrs[] = {
1003 &dev_attr_protocols.attr, 1193 &dev_attr_protocols.attr.attr,
1194 &dev_attr_wakeup_protocols.attr.attr,
1195 &dev_attr_filter.attr.attr,
1196 &dev_attr_filter_mask.attr.attr,
1197 &dev_attr_wakeup_filter.attr.attr,
1198 &dev_attr_wakeup_filter_mask.attr.attr,
1004 NULL, 1199 NULL,
1005}; 1200};
1006 1201
@@ -1091,14 +1286,6 @@ int rc_register_device(struct rc_dev *dev)
1091 if (dev->close) 1286 if (dev->close)
1092 dev->input_dev->close = ir_close; 1287 dev->input_dev->close = ir_close;
1093 1288
1094 /*
1095 * Take the lock here, as the device sysfs node will appear
1096 * when device_add() is called, which may trigger an ir-keytable udev
1097 * rule, which will in turn call show_protocols and access
1098 * dev->enabled_protocols before it has been initialized.
1099 */
1100 mutex_lock(&dev->lock);
1101
1102 do { 1289 do {
1103 devno = find_first_zero_bit(ir_core_dev_number, 1290 devno = find_first_zero_bit(ir_core_dev_number,
1104 IRRCV_NUM_DEVICES); 1291 IRRCV_NUM_DEVICES);
@@ -1107,6 +1294,14 @@ int rc_register_device(struct rc_dev *dev)
1107 return -ENOMEM; 1294 return -ENOMEM;
1108 } while (test_and_set_bit(devno, ir_core_dev_number)); 1295 } while (test_and_set_bit(devno, ir_core_dev_number));
1109 1296
1297 /*
1298 * Take the lock here, as the device sysfs node will appear
1299 * when device_add() is called, which may trigger an ir-keytable udev
1300 * rule, which will in turn call show_protocols and access
1301 * dev->enabled_protocols before it has been initialized.
1302 */
1303 mutex_lock(&dev->lock);
1304
1110 dev->devno = devno; 1305 dev->devno = devno;
1111 dev_set_name(&dev->dev, "rc%ld", dev->devno); 1306 dev_set_name(&dev->dev, "rc%ld", dev->devno);
1112 dev_set_drvdata(&dev->dev, dev); 1307 dev_set_drvdata(&dev->dev, dev);
@@ -1172,7 +1367,7 @@ int rc_register_device(struct rc_dev *dev)
1172 rc = dev->change_protocol(dev, &rc_type); 1367 rc = dev->change_protocol(dev, &rc_type);
1173 if (rc < 0) 1368 if (rc < 0)
1174 goto out_raw; 1369 goto out_raw;
1175 dev->enabled_protocols = rc_type; 1370 dev->enabled_protocols[RC_FILTER_NORMAL] = rc_type;
1176 } 1371 }
1177 1372
1178 mutex_unlock(&dev->lock); 1373 mutex_unlock(&dev->lock);
@@ -1260,5 +1455,5 @@ int rc_core_debug; /* ir_debug level (0,1,2) */
1260EXPORT_SYMBOL_GPL(rc_core_debug); 1455EXPORT_SYMBOL_GPL(rc_core_debug);
1261module_param_named(debug, rc_core_debug, int, 0644); 1456module_param_named(debug, rc_core_debug, int, 0644);
1262 1457
1263MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 1458MODULE_AUTHOR("Mauro Carvalho Chehab");
1264MODULE_LICENSE("GPL"); 1459MODULE_LICENSE("GPL");
diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index a5d4f883d053..47cd373e2295 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -922,7 +922,7 @@ static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
922 rc->dev.parent = dev; 922 rc->dev.parent = dev;
923 rc->priv = rr3; 923 rc->priv = rr3;
924 rc->driver_type = RC_DRIVER_IR_RAW; 924 rc->driver_type = RC_DRIVER_IR_RAW;
925 rc->allowed_protos = RC_BIT_ALL; 925 rc_set_allowed_protocols(rc, RC_BIT_ALL);
926 rc->timeout = US_TO_NS(2750); 926 rc->timeout = US_TO_NS(2750);
927 rc->tx_ir = redrat3_transmit_ir; 927 rc->tx_ir = redrat3_transmit_ir;
928 rc->s_tx_carrier = redrat3_set_tx_carrier; 928 rc->s_tx_carrier = redrat3_set_tx_carrier;
diff --git a/drivers/media/rc/st_rc.c b/drivers/media/rc/st_rc.c
index 8f0cddb9e8f2..22e4c1f28ab4 100644
--- a/drivers/media/rc/st_rc.c
+++ b/drivers/media/rc/st_rc.c
@@ -287,7 +287,7 @@ static int st_rc_probe(struct platform_device *pdev)
287 st_rc_hardware_init(rc_dev); 287 st_rc_hardware_init(rc_dev);
288 288
289 rdev->driver_type = RC_DRIVER_IR_RAW; 289 rdev->driver_type = RC_DRIVER_IR_RAW;
290 rdev->allowed_protos = RC_BIT_ALL; 290 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
291 /* rx sampling rate is 10Mhz */ 291 /* rx sampling rate is 10Mhz */
292 rdev->rx_resolution = 100; 292 rdev->rx_resolution = 100;
293 rdev->timeout = US_TO_NS(MAX_SYMB_TIME); 293 rdev->timeout = US_TO_NS(MAX_SYMB_TIME);
diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
index d7b11e6a9982..f4e0bc3d382c 100644
--- a/drivers/media/rc/streamzap.c
+++ b/drivers/media/rc/streamzap.c
@@ -322,7 +322,7 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz)
322 rdev->dev.parent = dev; 322 rdev->dev.parent = dev;
323 rdev->priv = sz; 323 rdev->priv = sz;
324 rdev->driver_type = RC_DRIVER_IR_RAW; 324 rdev->driver_type = RC_DRIVER_IR_RAW;
325 rdev->allowed_protos = RC_BIT_ALL; 325 rc_set_allowed_protocols(rdev, RC_BIT_ALL);
326 rdev->driver_name = DRIVER_NAME; 326 rdev->driver_name = DRIVER_NAME;
327 rdev->map_name = RC_MAP_STREAMZAP; 327 rdev->map_name = RC_MAP_STREAMZAP;
328 328
diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c
index d8de2056a4f6..c5be38e2a2fe 100644
--- a/drivers/media/rc/ttusbir.c
+++ b/drivers/media/rc/ttusbir.c
@@ -318,7 +318,7 @@ static int ttusbir_probe(struct usb_interface *intf,
318 usb_to_input_id(tt->udev, &rc->input_id); 318 usb_to_input_id(tt->udev, &rc->input_id);
319 rc->dev.parent = &intf->dev; 319 rc->dev.parent = &intf->dev;
320 rc->driver_type = RC_DRIVER_IR_RAW; 320 rc->driver_type = RC_DRIVER_IR_RAW;
321 rc->allowed_protos = RC_BIT_ALL; 321 rc_set_allowed_protocols(rc, RC_BIT_ALL);
322 rc->priv = tt; 322 rc->priv = tt;
323 rc->driver_name = DRIVER_NAME; 323 rc->driver_name = DRIVER_NAME;
324 rc->map_name = RC_MAP_TT_1500; 324 rc->map_name = RC_MAP_TT_1500;
diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 904baf4eec28..a8b981f5ce2e 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -1082,7 +1082,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1082 data->dev->dev.parent = &device->dev; 1082 data->dev->dev.parent = &device->dev;
1083 data->dev->timeout = MS_TO_NS(100); 1083 data->dev->timeout = MS_TO_NS(100);
1084 data->dev->rx_resolution = US_TO_NS(2); 1084 data->dev->rx_resolution = US_TO_NS(2);
1085 data->dev->allowed_protos = RC_BIT_ALL; 1085 rc_set_allowed_protocols(data->dev, RC_BIT_ALL);
1086 1086
1087 err = rc_register_device(data->dev); 1087 err = rc_register_device(data->dev);
1088 if (err) 1088 if (err)
diff --git a/drivers/media/tuners/Kconfig b/drivers/media/tuners/Kconfig
index ba2e365296cf..a1284889cd15 100644
--- a/drivers/media/tuners/Kconfig
+++ b/drivers/media/tuners/Kconfig
@@ -204,6 +204,7 @@ config MEDIA_TUNER_TDA18212
204config MEDIA_TUNER_E4000 204config MEDIA_TUNER_E4000
205 tristate "Elonics E4000 silicon tuner" 205 tristate "Elonics E4000 silicon tuner"
206 depends on MEDIA_SUPPORT && I2C 206 depends on MEDIA_SUPPORT && I2C
207 select REGMAP_I2C
207 default m if !MEDIA_SUBDRV_AUTOSELECT 208 default m if !MEDIA_SUBDRV_AUTOSELECT
208 help 209 help
209 Elonics E4000 silicon tuner driver. 210 Elonics E4000 silicon tuner driver.
diff --git a/drivers/media/tuners/e4000.c b/drivers/media/tuners/e4000.c
index 40c1da707d15..90d93348f20c 100644
--- a/drivers/media/tuners/e4000.c
+++ b/drivers/media/tuners/e4000.c
@@ -21,220 +21,113 @@
21#include "e4000_priv.h" 21#include "e4000_priv.h"
22#include <linux/math64.h> 22#include <linux/math64.h>
23 23
24/* Max transfer size done by I2C transfer functions */
25#define MAX_XFER_SIZE 64
26
27/* write multiple registers */
28static int e4000_wr_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len)
29{
30 int ret;
31 u8 buf[MAX_XFER_SIZE];
32 struct i2c_msg msg[1] = {
33 {
34 .addr = priv->cfg->i2c_addr,
35 .flags = 0,
36 .len = 1 + len,
37 .buf = buf,
38 }
39 };
40
41 if (1 + len > sizeof(buf)) {
42 dev_warn(&priv->i2c->dev,
43 "%s: i2c wr reg=%04x: len=%d is too big!\n",
44 KBUILD_MODNAME, reg, len);
45 return -EINVAL;
46 }
47
48 buf[0] = reg;
49 memcpy(&buf[1], val, len);
50
51 ret = i2c_transfer(priv->i2c, msg, 1);
52 if (ret == 1) {
53 ret = 0;
54 } else {
55 dev_warn(&priv->i2c->dev,
56 "%s: i2c wr failed=%d reg=%02x len=%d\n",
57 KBUILD_MODNAME, ret, reg, len);
58 ret = -EREMOTEIO;
59 }
60 return ret;
61}
62
63/* read multiple registers */
64static int e4000_rd_regs(struct e4000_priv *priv, u8 reg, u8 *val, int len)
65{
66 int ret;
67 u8 buf[MAX_XFER_SIZE];
68 struct i2c_msg msg[2] = {
69 {
70 .addr = priv->cfg->i2c_addr,
71 .flags = 0,
72 .len = 1,
73 .buf = &reg,
74 }, {
75 .addr = priv->cfg->i2c_addr,
76 .flags = I2C_M_RD,
77 .len = len,
78 .buf = buf,
79 }
80 };
81
82 if (len > sizeof(buf)) {
83 dev_warn(&priv->i2c->dev,
84 "%s: i2c rd reg=%04x: len=%d is too big!\n",
85 KBUILD_MODNAME, reg, len);
86 return -EINVAL;
87 }
88
89 ret = i2c_transfer(priv->i2c, msg, 2);
90 if (ret == 2) {
91 memcpy(val, buf, len);
92 ret = 0;
93 } else {
94 dev_warn(&priv->i2c->dev,
95 "%s: i2c rd failed=%d reg=%02x len=%d\n",
96 KBUILD_MODNAME, ret, reg, len);
97 ret = -EREMOTEIO;
98 }
99
100 return ret;
101}
102
103/* write single register */
104static int e4000_wr_reg(struct e4000_priv *priv, u8 reg, u8 val)
105{
106 return e4000_wr_regs(priv, reg, &val, 1);
107}
108
109/* read single register */
110static int e4000_rd_reg(struct e4000_priv *priv, u8 reg, u8 *val)
111{
112 return e4000_rd_regs(priv, reg, val, 1);
113}
114
115static int e4000_init(struct dvb_frontend *fe) 24static int e4000_init(struct dvb_frontend *fe)
116{ 25{
117 struct e4000_priv *priv = fe->tuner_priv; 26 struct e4000 *s = fe->tuner_priv;
118 int ret; 27 int ret;
119 28
120 dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 29 dev_dbg(&s->client->dev, "%s:\n", __func__);
121
122 if (fe->ops.i2c_gate_ctrl)
123 fe->ops.i2c_gate_ctrl(fe, 1);
124 30
125 /* dummy I2C to ensure I2C wakes up */ 31 /* dummy I2C to ensure I2C wakes up */
126 ret = e4000_wr_reg(priv, 0x02, 0x40); 32 ret = regmap_write(s->regmap, 0x02, 0x40);
127 33
128 /* reset */ 34 /* reset */
129 ret = e4000_wr_reg(priv, 0x00, 0x01); 35 ret = regmap_write(s->regmap, 0x00, 0x01);
130 if (ret < 0) 36 if (ret)
131 goto err; 37 goto err;
132 38
133 /* disable output clock */ 39 /* disable output clock */
134 ret = e4000_wr_reg(priv, 0x06, 0x00); 40 ret = regmap_write(s->regmap, 0x06, 0x00);
135 if (ret < 0) 41 if (ret)
136 goto err; 42 goto err;
137 43
138 ret = e4000_wr_reg(priv, 0x7a, 0x96); 44 ret = regmap_write(s->regmap, 0x7a, 0x96);
139 if (ret < 0) 45 if (ret)
140 goto err; 46 goto err;
141 47
142 /* configure gains */ 48 /* configure gains */
143 ret = e4000_wr_regs(priv, 0x7e, "\x01\xfe", 2); 49 ret = regmap_bulk_write(s->regmap, 0x7e, "\x01\xfe", 2);
144 if (ret < 0) 50 if (ret)
145 goto err; 51 goto err;
146 52
147 ret = e4000_wr_reg(priv, 0x82, 0x00); 53 ret = regmap_write(s->regmap, 0x82, 0x00);
148 if (ret < 0) 54 if (ret)
149 goto err; 55 goto err;
150 56
151 ret = e4000_wr_reg(priv, 0x24, 0x05); 57 ret = regmap_write(s->regmap, 0x24, 0x05);
152 if (ret < 0) 58 if (ret)
153 goto err; 59 goto err;
154 60
155 ret = e4000_wr_regs(priv, 0x87, "\x20\x01", 2); 61 ret = regmap_bulk_write(s->regmap, 0x87, "\x20\x01", 2);
156 if (ret < 0) 62 if (ret)
157 goto err; 63 goto err;
158 64
159 ret = e4000_wr_regs(priv, 0x9f, "\x7f\x07", 2); 65 ret = regmap_bulk_write(s->regmap, 0x9f, "\x7f\x07", 2);
160 if (ret < 0) 66 if (ret)
161 goto err; 67 goto err;
162 68
163 /* DC offset control */ 69 /* DC offset control */
164 ret = e4000_wr_reg(priv, 0x2d, 0x1f); 70 ret = regmap_write(s->regmap, 0x2d, 0x1f);
165 if (ret < 0) 71 if (ret)
166 goto err; 72 goto err;
167 73
168 ret = e4000_wr_regs(priv, 0x70, "\x01\x01", 2); 74 ret = regmap_bulk_write(s->regmap, 0x70, "\x01\x01", 2);
169 if (ret < 0) 75 if (ret)
170 goto err; 76 goto err;
171 77
172 /* gain control */ 78 /* gain control */
173 ret = e4000_wr_reg(priv, 0x1a, 0x17); 79 ret = regmap_write(s->regmap, 0x1a, 0x17);
174 if (ret < 0) 80 if (ret)
175 goto err; 81 goto err;
176 82
177 ret = e4000_wr_reg(priv, 0x1f, 0x1a); 83 ret = regmap_write(s->regmap, 0x1f, 0x1a);
178 if (ret < 0) 84 if (ret)
179 goto err; 85 goto err;
180 86
181 if (fe->ops.i2c_gate_ctrl) 87 s->active = true;
182 fe->ops.i2c_gate_ctrl(fe, 0);
183
184 return 0;
185err: 88err:
186 if (fe->ops.i2c_gate_ctrl) 89 if (ret)
187 fe->ops.i2c_gate_ctrl(fe, 0); 90 dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
188 91
189 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
190 return ret; 92 return ret;
191} 93}
192 94
193static int e4000_sleep(struct dvb_frontend *fe) 95static int e4000_sleep(struct dvb_frontend *fe)
194{ 96{
195 struct e4000_priv *priv = fe->tuner_priv; 97 struct e4000 *s = fe->tuner_priv;
196 int ret; 98 int ret;
197 99
198 dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 100 dev_dbg(&s->client->dev, "%s:\n", __func__);
199 101
200 if (fe->ops.i2c_gate_ctrl) 102 s->active = false;
201 fe->ops.i2c_gate_ctrl(fe, 1);
202 103
203 ret = e4000_wr_reg(priv, 0x00, 0x00); 104 ret = regmap_write(s->regmap, 0x00, 0x00);
204 if (ret < 0) 105 if (ret)
205 goto err; 106 goto err;
206
207 if (fe->ops.i2c_gate_ctrl)
208 fe->ops.i2c_gate_ctrl(fe, 0);
209
210 return 0;
211err: 107err:
212 if (fe->ops.i2c_gate_ctrl) 108 if (ret)
213 fe->ops.i2c_gate_ctrl(fe, 0); 109 dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
214 110
215 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
216 return ret; 111 return ret;
217} 112}
218 113
219static int e4000_set_params(struct dvb_frontend *fe) 114static int e4000_set_params(struct dvb_frontend *fe)
220{ 115{
221 struct e4000_priv *priv = fe->tuner_priv; 116 struct e4000 *s = fe->tuner_priv;
222 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 117 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
223 int ret, i, sigma_delta; 118 int ret, i, sigma_delta;
224 unsigned int f_vco; 119 unsigned int pll_n, pll_f;
120 u64 f_vco;
225 u8 buf[5], i_data[4], q_data[4]; 121 u8 buf[5], i_data[4], q_data[4];
226 122
227 dev_dbg(&priv->i2c->dev, 123 dev_dbg(&s->client->dev,
228 "%s: delivery_system=%d frequency=%d bandwidth_hz=%d\n", 124 "%s: delivery_system=%d frequency=%u bandwidth_hz=%u\n",
229 __func__, c->delivery_system, c->frequency, 125 __func__, c->delivery_system, c->frequency,
230 c->bandwidth_hz); 126 c->bandwidth_hz);
231 127
232 if (fe->ops.i2c_gate_ctrl)
233 fe->ops.i2c_gate_ctrl(fe, 1);
234
235 /* gain control manual */ 128 /* gain control manual */
236 ret = e4000_wr_reg(priv, 0x1a, 0x00); 129 ret = regmap_write(s->regmap, 0x1a, 0x00);
237 if (ret < 0) 130 if (ret)
238 goto err; 131 goto err;
239 132
240 /* PLL */ 133 /* PLL */
@@ -248,23 +141,21 @@ static int e4000_set_params(struct dvb_frontend *fe)
248 goto err; 141 goto err;
249 } 142 }
250 143
251 /* 144 f_vco = 1ull * c->frequency * e4000_pll_lut[i].mul;
252 * Note: Currently f_vco overflows when c->frequency is 1 073 741 824 Hz 145 pll_n = div_u64_rem(f_vco, s->clock, &pll_f);
253 * or more. 146 sigma_delta = div_u64(0x10000ULL * pll_f, s->clock);
254 */ 147 buf[0] = pll_n;
255 f_vco = c->frequency * e4000_pll_lut[i].mul;
256 sigma_delta = div_u64(0x10000ULL * (f_vco % priv->cfg->clock), priv->cfg->clock);
257 buf[0] = f_vco / priv->cfg->clock;
258 buf[1] = (sigma_delta >> 0) & 0xff; 148 buf[1] = (sigma_delta >> 0) & 0xff;
259 buf[2] = (sigma_delta >> 8) & 0xff; 149 buf[2] = (sigma_delta >> 8) & 0xff;
260 buf[3] = 0x00; 150 buf[3] = 0x00;
261 buf[4] = e4000_pll_lut[i].div; 151 buf[4] = e4000_pll_lut[i].div;
262 152
263 dev_dbg(&priv->i2c->dev, "%s: f_vco=%u pll div=%d sigma_delta=%04x\n", 153 dev_dbg(&s->client->dev,
154 "%s: f_vco=%llu pll div=%d sigma_delta=%04x\n",
264 __func__, f_vco, buf[0], sigma_delta); 155 __func__, f_vco, buf[0], sigma_delta);
265 156
266 ret = e4000_wr_regs(priv, 0x09, buf, 5); 157 ret = regmap_bulk_write(s->regmap, 0x09, buf, 5);
267 if (ret < 0) 158 if (ret)
268 goto err; 159 goto err;
269 160
270 /* LNA filter (RF filter) */ 161 /* LNA filter (RF filter) */
@@ -278,8 +169,8 @@ static int e4000_set_params(struct dvb_frontend *fe)
278 goto err; 169 goto err;
279 } 170 }
280 171
281 ret = e4000_wr_reg(priv, 0x10, e400_lna_filter_lut[i].val); 172 ret = regmap_write(s->regmap, 0x10, e400_lna_filter_lut[i].val);
282 if (ret < 0) 173 if (ret)
283 goto err; 174 goto err;
284 175
285 /* IF filters */ 176 /* IF filters */
@@ -296,8 +187,8 @@ static int e4000_set_params(struct dvb_frontend *fe)
296 buf[0] = e4000_if_filter_lut[i].reg11_val; 187 buf[0] = e4000_if_filter_lut[i].reg11_val;
297 buf[1] = e4000_if_filter_lut[i].reg12_val; 188 buf[1] = e4000_if_filter_lut[i].reg12_val;
298 189
299 ret = e4000_wr_regs(priv, 0x11, buf, 2); 190 ret = regmap_bulk_write(s->regmap, 0x11, buf, 2);
300 if (ret < 0) 191 if (ret)
301 goto err; 192 goto err;
302 193
303 /* frequency band */ 194 /* frequency band */
@@ -311,34 +202,34 @@ static int e4000_set_params(struct dvb_frontend *fe)
311 goto err; 202 goto err;
312 } 203 }
313 204
314 ret = e4000_wr_reg(priv, 0x07, e4000_band_lut[i].reg07_val); 205 ret = regmap_write(s->regmap, 0x07, e4000_band_lut[i].reg07_val);
315 if (ret < 0) 206 if (ret)
316 goto err; 207 goto err;
317 208
318 ret = e4000_wr_reg(priv, 0x78, e4000_band_lut[i].reg78_val); 209 ret = regmap_write(s->regmap, 0x78, e4000_band_lut[i].reg78_val);
319 if (ret < 0) 210 if (ret)
320 goto err; 211 goto err;
321 212
322 /* DC offset */ 213 /* DC offset */
323 for (i = 0; i < 4; i++) { 214 for (i = 0; i < 4; i++) {
324 if (i == 0) 215 if (i == 0)
325 ret = e4000_wr_regs(priv, 0x15, "\x00\x7e\x24", 3); 216 ret = regmap_bulk_write(s->regmap, 0x15, "\x00\x7e\x24", 3);
326 else if (i == 1) 217 else if (i == 1)
327 ret = e4000_wr_regs(priv, 0x15, "\x00\x7f", 2); 218 ret = regmap_bulk_write(s->regmap, 0x15, "\x00\x7f", 2);
328 else if (i == 2) 219 else if (i == 2)
329 ret = e4000_wr_regs(priv, 0x15, "\x01", 1); 220 ret = regmap_bulk_write(s->regmap, 0x15, "\x01", 1);
330 else 221 else
331 ret = e4000_wr_regs(priv, 0x16, "\x7e", 1); 222 ret = regmap_bulk_write(s->regmap, 0x16, "\x7e", 1);
332 223
333 if (ret < 0) 224 if (ret)
334 goto err; 225 goto err;
335 226
336 ret = e4000_wr_reg(priv, 0x29, 0x01); 227 ret = regmap_write(s->regmap, 0x29, 0x01);
337 if (ret < 0) 228 if (ret)
338 goto err; 229 goto err;
339 230
340 ret = e4000_rd_regs(priv, 0x2a, buf, 3); 231 ret = regmap_bulk_read(s->regmap, 0x2a, buf, 3);
341 if (ret < 0) 232 if (ret)
342 goto err; 233 goto err;
343 234
344 i_data[i] = (((buf[2] >> 0) & 0x3) << 6) | (buf[0] & 0x3f); 235 i_data[i] = (((buf[2] >> 0) & 0x3) << 6) | (buf[0] & 0x3f);
@@ -348,53 +239,226 @@ static int e4000_set_params(struct dvb_frontend *fe)
348 swap(q_data[2], q_data[3]); 239 swap(q_data[2], q_data[3]);
349 swap(i_data[2], i_data[3]); 240 swap(i_data[2], i_data[3]);
350 241
351 ret = e4000_wr_regs(priv, 0x50, q_data, 4); 242 ret = regmap_bulk_write(s->regmap, 0x50, q_data, 4);
352 if (ret < 0) 243 if (ret)
353 goto err; 244 goto err;
354 245
355 ret = e4000_wr_regs(priv, 0x60, i_data, 4); 246 ret = regmap_bulk_write(s->regmap, 0x60, i_data, 4);
356 if (ret < 0) 247 if (ret)
357 goto err; 248 goto err;
358 249
359 /* gain control auto */ 250 /* gain control auto */
360 ret = e4000_wr_reg(priv, 0x1a, 0x17); 251 ret = regmap_write(s->regmap, 0x1a, 0x17);
361 if (ret < 0) 252 if (ret)
362 goto err; 253 goto err;
363
364 if (fe->ops.i2c_gate_ctrl)
365 fe->ops.i2c_gate_ctrl(fe, 0);
366
367 return 0;
368err: 254err:
369 if (fe->ops.i2c_gate_ctrl) 255 if (ret)
370 fe->ops.i2c_gate_ctrl(fe, 0); 256 dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
371 257
372 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
373 return ret; 258 return ret;
374} 259}
375 260
376static int e4000_get_if_frequency(struct dvb_frontend *fe, u32 *frequency) 261static int e4000_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
377{ 262{
378 struct e4000_priv *priv = fe->tuner_priv; 263 struct e4000 *s = fe->tuner_priv;
379 264
380 dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 265 dev_dbg(&s->client->dev, "%s:\n", __func__);
381 266
382 *frequency = 0; /* Zero-IF */ 267 *frequency = 0; /* Zero-IF */
383 268
384 return 0; 269 return 0;
385} 270}
386 271
387static int e4000_release(struct dvb_frontend *fe) 272#if IS_ENABLED(CONFIG_VIDEO_V4L2)
273static int e4000_set_lna_gain(struct dvb_frontend *fe)
388{ 274{
389 struct e4000_priv *priv = fe->tuner_priv; 275 struct e4000 *s = fe->tuner_priv;
276 int ret;
277 u8 u8tmp;
278
279 dev_dbg(&s->client->dev, "%s: lna auto=%d->%d val=%d->%d\n",
280 __func__, s->lna_gain_auto->cur.val,
281 s->lna_gain_auto->val, s->lna_gain->cur.val,
282 s->lna_gain->val);
283
284 if (s->lna_gain_auto->val && s->if_gain_auto->cur.val)
285 u8tmp = 0x17;
286 else if (s->lna_gain_auto->val)
287 u8tmp = 0x19;
288 else if (s->if_gain_auto->cur.val)
289 u8tmp = 0x16;
290 else
291 u8tmp = 0x10;
292
293 ret = regmap_write(s->regmap, 0x1a, u8tmp);
294 if (ret)
295 goto err;
296
297 if (s->lna_gain_auto->val == false) {
298 ret = regmap_write(s->regmap, 0x14, s->lna_gain->val);
299 if (ret)
300 goto err;
301 }
302err:
303 if (ret)
304 dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
390 305
391 dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 306 return ret;
307}
392 308
393 kfree(fe->tuner_priv); 309static int e4000_set_mixer_gain(struct dvb_frontend *fe)
310{
311 struct e4000 *s = fe->tuner_priv;
312 int ret;
313 u8 u8tmp;
394 314
395 return 0; 315 dev_dbg(&s->client->dev, "%s: mixer auto=%d->%d val=%d->%d\n",
316 __func__, s->mixer_gain_auto->cur.val,
317 s->mixer_gain_auto->val, s->mixer_gain->cur.val,
318 s->mixer_gain->val);
319
320 if (s->mixer_gain_auto->val)
321 u8tmp = 0x15;
322 else
323 u8tmp = 0x14;
324
325 ret = regmap_write(s->regmap, 0x20, u8tmp);
326 if (ret)
327 goto err;
328
329 if (s->mixer_gain_auto->val == false) {
330 ret = regmap_write(s->regmap, 0x15, s->mixer_gain->val);
331 if (ret)
332 goto err;
333 }
334err:
335 if (ret)
336 dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
337
338 return ret;
396} 339}
397 340
341static int e4000_set_if_gain(struct dvb_frontend *fe)
342{
343 struct e4000 *s = fe->tuner_priv;
344 int ret;
345 u8 buf[2];
346 u8 u8tmp;
347
348 dev_dbg(&s->client->dev, "%s: if auto=%d->%d val=%d->%d\n",
349 __func__, s->if_gain_auto->cur.val,
350 s->if_gain_auto->val, s->if_gain->cur.val,
351 s->if_gain->val);
352
353 if (s->if_gain_auto->val && s->lna_gain_auto->cur.val)
354 u8tmp = 0x17;
355 else if (s->lna_gain_auto->cur.val)
356 u8tmp = 0x19;
357 else if (s->if_gain_auto->val)
358 u8tmp = 0x16;
359 else
360 u8tmp = 0x10;
361
362 ret = regmap_write(s->regmap, 0x1a, u8tmp);
363 if (ret)
364 goto err;
365
366 if (s->if_gain_auto->val == false) {
367 buf[0] = e4000_if_gain_lut[s->if_gain->val].reg16_val;
368 buf[1] = e4000_if_gain_lut[s->if_gain->val].reg17_val;
369 ret = regmap_bulk_write(s->regmap, 0x16, buf, 2);
370 if (ret)
371 goto err;
372 }
373err:
374 if (ret)
375 dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
376
377 return ret;
378}
379
380static int e4000_pll_lock(struct dvb_frontend *fe)
381{
382 struct e4000 *s = fe->tuner_priv;
383 int ret;
384 unsigned int utmp;
385
386 ret = regmap_read(s->regmap, 0x07, &utmp);
387 if (ret)
388 goto err;
389
390 s->pll_lock->val = (utmp & 0x01);
391err:
392 if (ret)
393 dev_dbg(&s->client->dev, "%s: failed=%d\n", __func__, ret);
394
395 return ret;
396}
397
398static int e4000_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
399{
400 struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl);
401 int ret;
402
403 if (s->active == false)
404 return 0;
405
406 switch (ctrl->id) {
407 case V4L2_CID_RF_TUNER_PLL_LOCK:
408 ret = e4000_pll_lock(s->fe);
409 break;
410 default:
411 dev_dbg(&s->client->dev, "%s: unknown ctrl: id=%d name=%s\n",
412 __func__, ctrl->id, ctrl->name);
413 ret = -EINVAL;
414 }
415
416 return ret;
417}
418
419static int e4000_s_ctrl(struct v4l2_ctrl *ctrl)
420{
421 struct e4000 *s = container_of(ctrl->handler, struct e4000, hdl);
422 struct dvb_frontend *fe = s->fe;
423 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
424 int ret;
425
426 if (s->active == false)
427 return 0;
428
429 switch (ctrl->id) {
430 case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO:
431 case V4L2_CID_RF_TUNER_BANDWIDTH:
432 c->bandwidth_hz = s->bandwidth->val;
433 ret = e4000_set_params(s->fe);
434 break;
435 case V4L2_CID_RF_TUNER_LNA_GAIN_AUTO:
436 case V4L2_CID_RF_TUNER_LNA_GAIN:
437 ret = e4000_set_lna_gain(s->fe);
438 break;
439 case V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO:
440 case V4L2_CID_RF_TUNER_MIXER_GAIN:
441 ret = e4000_set_mixer_gain(s->fe);
442 break;
443 case V4L2_CID_RF_TUNER_IF_GAIN_AUTO:
444 case V4L2_CID_RF_TUNER_IF_GAIN:
445 ret = e4000_set_if_gain(s->fe);
446 break;
447 default:
448 dev_dbg(&s->client->dev, "%s: unknown ctrl: id=%d name=%s\n",
449 __func__, ctrl->id, ctrl->name);
450 ret = -EINVAL;
451 }
452
453 return ret;
454}
455
456static const struct v4l2_ctrl_ops e4000_ctrl_ops = {
457 .g_volatile_ctrl = e4000_g_volatile_ctrl,
458 .s_ctrl = e4000_s_ctrl,
459};
460#endif
461
398static const struct dvb_tuner_ops e4000_tuner_ops = { 462static const struct dvb_tuner_ops e4000_tuner_ops = {
399 .info = { 463 .info = {
400 .name = "Elonics E4000", 464 .name = "Elonics E4000",
@@ -402,8 +466,6 @@ static const struct dvb_tuner_ops e4000_tuner_ops = {
402 .frequency_max = 862000000, 466 .frequency_max = 862000000,
403 }, 467 },
404 468
405 .release = e4000_release,
406
407 .init = e4000_init, 469 .init = e4000_init,
408 .sleep = e4000_sleep, 470 .sleep = e4000_sleep,
409 .set_params = e4000_set_params, 471 .set_params = e4000_set_params,
@@ -411,62 +473,148 @@ static const struct dvb_tuner_ops e4000_tuner_ops = {
411 .get_if_frequency = e4000_get_if_frequency, 473 .get_if_frequency = e4000_get_if_frequency,
412}; 474};
413 475
414struct dvb_frontend *e4000_attach(struct dvb_frontend *fe, 476/*
415 struct i2c_adapter *i2c, const struct e4000_config *cfg) 477 * Use V4L2 subdev to carry V4L2 control handler, even we don't implement
478 * subdev itself, just to avoid reinventing the wheel.
479 */
480static int e4000_probe(struct i2c_client *client,
481 const struct i2c_device_id *id)
416{ 482{
417 struct e4000_priv *priv; 483 struct e4000_config *cfg = client->dev.platform_data;
484 struct dvb_frontend *fe = cfg->fe;
485 struct e4000 *s;
418 int ret; 486 int ret;
419 u8 chip_id; 487 unsigned int utmp;
420 488 static const struct regmap_config regmap_config = {
421 if (fe->ops.i2c_gate_ctrl) 489 .reg_bits = 8,
422 fe->ops.i2c_gate_ctrl(fe, 1); 490 .val_bits = 8,
491 .max_register = 0xff,
492 };
423 493
424 priv = kzalloc(sizeof(struct e4000_priv), GFP_KERNEL); 494 s = kzalloc(sizeof(struct e4000), GFP_KERNEL);
425 if (!priv) { 495 if (!s) {
426 ret = -ENOMEM; 496 ret = -ENOMEM;
427 dev_err(&i2c->dev, "%s: kzalloc() failed\n", KBUILD_MODNAME); 497 dev_err(&client->dev, "%s: kzalloc() failed\n", KBUILD_MODNAME);
428 goto err; 498 goto err;
429 } 499 }
430 500
431 priv->cfg = cfg; 501 s->clock = cfg->clock;
432 priv->i2c = i2c; 502 s->client = client;
503 s->fe = cfg->fe;
504 s->regmap = devm_regmap_init_i2c(client, &regmap_config);
505 if (IS_ERR(s->regmap)) {
506 ret = PTR_ERR(s->regmap);
507 goto err;
508 }
433 509
434 /* check if the tuner is there */ 510 /* check if the tuner is there */
435 ret = e4000_rd_reg(priv, 0x02, &chip_id); 511 ret = regmap_read(s->regmap, 0x02, &utmp);
436 if (ret < 0) 512 if (ret)
437 goto err; 513 goto err;
438 514
439 dev_dbg(&priv->i2c->dev, "%s: chip_id=%02x\n", __func__, chip_id); 515 dev_dbg(&s->client->dev, "%s: chip id=%02x\n", __func__, utmp);
440 516
441 if (chip_id != 0x40) 517 if (utmp != 0x40) {
518 ret = -ENODEV;
442 goto err; 519 goto err;
520 }
443 521
444 /* put sleep as chip seems to be in normal mode by default */ 522 /* put sleep as chip seems to be in normal mode by default */
445 ret = e4000_wr_reg(priv, 0x00, 0x00); 523 ret = regmap_write(s->regmap, 0x00, 0x00);
446 if (ret < 0) 524 if (ret)
447 goto err; 525 goto err;
448 526
449 dev_info(&priv->i2c->dev, 527#if IS_ENABLED(CONFIG_VIDEO_V4L2)
528 /* Register controls */
529 v4l2_ctrl_handler_init(&s->hdl, 9);
530 s->bandwidth_auto = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops,
531 V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1);
532 s->bandwidth = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops,
533 V4L2_CID_RF_TUNER_BANDWIDTH, 4300000, 11000000, 100000, 4300000);
534 v4l2_ctrl_auto_cluster(2, &s->bandwidth_auto, 0, false);
535 s->lna_gain_auto = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops,
536 V4L2_CID_RF_TUNER_LNA_GAIN_AUTO, 0, 1, 1, 1);
537 s->lna_gain = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops,
538 V4L2_CID_RF_TUNER_LNA_GAIN, 0, 15, 1, 10);
539 v4l2_ctrl_auto_cluster(2, &s->lna_gain_auto, 0, false);
540 s->mixer_gain_auto = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops,
541 V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO, 0, 1, 1, 1);
542 s->mixer_gain = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops,
543 V4L2_CID_RF_TUNER_MIXER_GAIN, 0, 1, 1, 1);
544 v4l2_ctrl_auto_cluster(2, &s->mixer_gain_auto, 0, false);
545 s->if_gain_auto = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops,
546 V4L2_CID_RF_TUNER_IF_GAIN_AUTO, 0, 1, 1, 1);
547 s->if_gain = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops,
548 V4L2_CID_RF_TUNER_IF_GAIN, 0, 54, 1, 0);
549 v4l2_ctrl_auto_cluster(2, &s->if_gain_auto, 0, false);
550 s->pll_lock = v4l2_ctrl_new_std(&s->hdl, &e4000_ctrl_ops,
551 V4L2_CID_RF_TUNER_PLL_LOCK, 0, 1, 1, 0);
552 if (s->hdl.error) {
553 ret = s->hdl.error;
554 dev_err(&s->client->dev, "Could not initialize controls\n");
555 v4l2_ctrl_handler_free(&s->hdl);
556 goto err;
557 }
558
559 s->sd.ctrl_handler = &s->hdl;
560#endif
561
562 dev_info(&s->client->dev,
450 "%s: Elonics E4000 successfully identified\n", 563 "%s: Elonics E4000 successfully identified\n",
451 KBUILD_MODNAME); 564 KBUILD_MODNAME);
452 565
453 fe->tuner_priv = priv; 566 fe->tuner_priv = s;
454 memcpy(&fe->ops.tuner_ops, &e4000_tuner_ops, 567 memcpy(&fe->ops.tuner_ops, &e4000_tuner_ops,
455 sizeof(struct dvb_tuner_ops)); 568 sizeof(struct dvb_tuner_ops));
456 569
457 if (fe->ops.i2c_gate_ctrl) 570 v4l2_set_subdevdata(&s->sd, client);
458 fe->ops.i2c_gate_ctrl(fe, 0); 571 i2c_set_clientdata(client, &s->sd);
459 572
460 return fe; 573 return 0;
461err: 574err:
462 if (fe->ops.i2c_gate_ctrl) 575 if (ret) {
463 fe->ops.i2c_gate_ctrl(fe, 0); 576 dev_dbg(&client->dev, "%s: failed=%d\n", __func__, ret);
577 kfree(s);
578 }
579
580 return ret;
581}
582
583static int e4000_remove(struct i2c_client *client)
584{
585 struct v4l2_subdev *sd = i2c_get_clientdata(client);
586 struct e4000 *s = container_of(sd, struct e4000, sd);
587 struct dvb_frontend *fe = s->fe;
588
589 dev_dbg(&client->dev, "%s:\n", __func__);
464 590
465 dev_dbg(&i2c->dev, "%s: failed=%d\n", __func__, ret); 591#if IS_ENABLED(CONFIG_VIDEO_V4L2)
466 kfree(priv); 592 v4l2_ctrl_handler_free(&s->hdl);
467 return NULL; 593#endif
594 memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops));
595 fe->tuner_priv = NULL;
596 kfree(s);
597
598 return 0;
468} 599}
469EXPORT_SYMBOL(e4000_attach); 600
601static const struct i2c_device_id e4000_id[] = {
602 {"e4000", 0},
603 {}
604};
605MODULE_DEVICE_TABLE(i2c, e4000_id);
606
607static struct i2c_driver e4000_driver = {
608 .driver = {
609 .owner = THIS_MODULE,
610 .name = "e4000",
611 },
612 .probe = e4000_probe,
613 .remove = e4000_remove,
614 .id_table = e4000_id,
615};
616
617module_i2c_driver(e4000_driver);
470 618
471MODULE_DESCRIPTION("Elonics E4000 silicon tuner driver"); 619MODULE_DESCRIPTION("Elonics E4000 silicon tuner driver");
472MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); 620MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
diff --git a/drivers/media/tuners/e4000.h b/drivers/media/tuners/e4000.h
index 25ee7c07abff..e74b8b2f2fc3 100644
--- a/drivers/media/tuners/e4000.h
+++ b/drivers/media/tuners/e4000.h
@@ -24,12 +24,15 @@
24#include <linux/kconfig.h> 24#include <linux/kconfig.h>
25#include "dvb_frontend.h" 25#include "dvb_frontend.h"
26 26
27/*
28 * I2C address
29 * 0x64, 0x65, 0x66, 0x67
30 */
27struct e4000_config { 31struct e4000_config {
28 /* 32 /*
29 * I2C address 33 * frontend
30 * 0x64, 0x65, 0x66, 0x67
31 */ 34 */
32 u8 i2c_addr; 35 struct dvb_frontend *fe;
33 36
34 /* 37 /*
35 * clock 38 * clock
@@ -37,16 +40,4 @@ struct e4000_config {
37 u32 clock; 40 u32 clock;
38}; 41};
39 42
40#if IS_ENABLED(CONFIG_MEDIA_TUNER_E4000)
41extern struct dvb_frontend *e4000_attach(struct dvb_frontend *fe,
42 struct i2c_adapter *i2c, const struct e4000_config *cfg);
43#else
44static inline struct dvb_frontend *e4000_attach(struct dvb_frontend *fe,
45 struct i2c_adapter *i2c, const struct e4000_config *cfg)
46{
47 dev_warn(&i2c->dev, "%s: driver disabled by Kconfig\n", __func__);
48 return NULL;
49}
50#endif
51
52#endif 43#endif
diff --git a/drivers/media/tuners/e4000_priv.h b/drivers/media/tuners/e4000_priv.h
index a3855053e78f..cb0070483e65 100644
--- a/drivers/media/tuners/e4000_priv.h
+++ b/drivers/media/tuners/e4000_priv.h
@@ -22,10 +22,29 @@
22#define E4000_PRIV_H 22#define E4000_PRIV_H
23 23
24#include "e4000.h" 24#include "e4000.h"
25#include <media/v4l2-ctrls.h>
26#include <media/v4l2-subdev.h>
27#include <linux/regmap.h>
25 28
26struct e4000_priv { 29struct e4000 {
27 const struct e4000_config *cfg; 30 struct i2c_client *client;
28 struct i2c_adapter *i2c; 31 struct regmap *regmap;
32 u32 clock;
33 struct dvb_frontend *fe;
34 struct v4l2_subdev sd;
35 bool active;
36
37 /* Controls */
38 struct v4l2_ctrl_handler hdl;
39 struct v4l2_ctrl *bandwidth_auto;
40 struct v4l2_ctrl *bandwidth;
41 struct v4l2_ctrl *lna_gain_auto;
42 struct v4l2_ctrl *lna_gain;
43 struct v4l2_ctrl *mixer_gain_auto;
44 struct v4l2_ctrl *mixer_gain;
45 struct v4l2_ctrl *if_gain_auto;
46 struct v4l2_ctrl *if_gain;
47 struct v4l2_ctrl *pll_lock;
29}; 48};
30 49
31struct e4000_pll { 50struct e4000_pll {
@@ -144,4 +163,67 @@ static const struct e4000_if_filter e4000_if_filter_lut[] = {
144 { 0xffffffff, 0x00, 0x20 }, 163 { 0xffffffff, 0x00, 0x20 },
145}; 164};
146 165
166struct e4000_if_gain {
167 u8 reg16_val;
168 u8 reg17_val;
169};
170
171static const struct e4000_if_gain e4000_if_gain_lut[] = {
172 {0x00, 0x00},
173 {0x20, 0x00},
174 {0x40, 0x00},
175 {0x02, 0x00},
176 {0x22, 0x00},
177 {0x42, 0x00},
178 {0x04, 0x00},
179 {0x24, 0x00},
180 {0x44, 0x00},
181 {0x01, 0x00},
182 {0x21, 0x00},
183 {0x41, 0x00},
184 {0x03, 0x00},
185 {0x23, 0x00},
186 {0x43, 0x00},
187 {0x05, 0x00},
188 {0x25, 0x00},
189 {0x45, 0x00},
190 {0x07, 0x00},
191 {0x27, 0x00},
192 {0x47, 0x00},
193 {0x0f, 0x00},
194 {0x2f, 0x00},
195 {0x4f, 0x00},
196 {0x17, 0x00},
197 {0x37, 0x00},
198 {0x57, 0x00},
199 {0x1f, 0x00},
200 {0x3f, 0x00},
201 {0x5f, 0x00},
202 {0x1f, 0x01},
203 {0x3f, 0x01},
204 {0x5f, 0x01},
205 {0x1f, 0x02},
206 {0x3f, 0x02},
207 {0x5f, 0x02},
208 {0x1f, 0x03},
209 {0x3f, 0x03},
210 {0x5f, 0x03},
211 {0x1f, 0x04},
212 {0x3f, 0x04},
213 {0x5f, 0x04},
214 {0x1f, 0x0c},
215 {0x3f, 0x0c},
216 {0x5f, 0x0c},
217 {0x1f, 0x14},
218 {0x3f, 0x14},
219 {0x5f, 0x14},
220 {0x1f, 0x1c},
221 {0x3f, 0x1c},
222 {0x5f, 0x1c},
223 {0x1f, 0x24},
224 {0x3f, 0x24},
225 {0x5f, 0x24},
226 {0x7f, 0x24},
227};
228
147#endif 229#endif
diff --git a/drivers/media/tuners/mt2063.c b/drivers/media/tuners/mt2063.c
index 20cca405bf45..f640dcf4a81d 100644
--- a/drivers/media/tuners/mt2063.c
+++ b/drivers/media/tuners/mt2063.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for mt2063 Micronas tuner 2 * Driver for mt2063 Micronas tuner
3 * 3 *
4 * Copyright (c) 2011 Mauro Carvalho Chehab <mchehab@redhat.com> 4 * Copyright (c) 2011 Mauro Carvalho Chehab
5 * 5 *
6 * This driver came from a driver originally written by: 6 * This driver came from a driver originally written by:
7 * Henry Wang <Henry.wang@AzureWave.com> 7 * Henry Wang <Henry.wang@AzureWave.com>
@@ -2298,6 +2298,6 @@ static int tuner_MT2063_ClearPowerMaskBits(struct dvb_frontend *fe)
2298} 2298}
2299#endif 2299#endif
2300 2300
2301MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 2301MODULE_AUTHOR("Mauro Carvalho Chehab");
2302MODULE_DESCRIPTION("MT2063 Silicon tuner"); 2302MODULE_DESCRIPTION("MT2063 Silicon tuner");
2303MODULE_LICENSE("GPL"); 2303MODULE_LICENSE("GPL");
diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index d9ee43fae62d..319adc4f0561 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Rafael Micro R820T driver 2 * Rafael Micro R820T driver
3 * 3 *
4 * Copyright (C) 2013 Mauro Carvalho Chehab <mchehab@redhat.com> 4 * Copyright (C) 2013 Mauro Carvalho Chehab
5 * 5 *
6 * This driver was written from scratch, based on an existing driver 6 * This driver was written from scratch, based on an existing driver
7 * that it is part of rtl-sdr git tree, released under GPLv2: 7 * that it is part of rtl-sdr git tree, released under GPLv2:
@@ -2351,5 +2351,5 @@ err_no_gate:
2351EXPORT_SYMBOL_GPL(r820t_attach); 2351EXPORT_SYMBOL_GPL(r820t_attach);
2352 2352
2353MODULE_DESCRIPTION("Rafael Micro r820t silicon tuner driver"); 2353MODULE_DESCRIPTION("Rafael Micro r820t silicon tuner driver");
2354MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 2354MODULE_AUTHOR("Mauro Carvalho Chehab");
2355MODULE_LICENSE("GPL"); 2355MODULE_LICENSE("GPL");
diff --git a/drivers/media/tuners/tda18212.c b/drivers/media/tuners/tda18212.c
index abe256e1f843..05a4ac9edb6b 100644
--- a/drivers/media/tuners/tda18212.c
+++ b/drivers/media/tuners/tda18212.c
@@ -150,6 +150,8 @@ static int tda18212_set_params(struct dvb_frontend *fe)
150 #define DVBT2_8 5 150 #define DVBT2_8 5
151 #define DVBC_6 6 151 #define DVBC_6 6
152 #define DVBC_8 7 152 #define DVBC_8 7
153 #define ATSC_VSB 8
154 #define ATSC_QAM 9
153 static const u8 bw_params[][3] = { 155 static const u8 bw_params[][3] = {
154 /* reg: 0f 13 23 */ 156 /* reg: 0f 13 23 */
155 [DVBT_6] = { 0xb3, 0x20, 0x03 }, 157 [DVBT_6] = { 0xb3, 0x20, 0x03 },
@@ -160,6 +162,8 @@ static int tda18212_set_params(struct dvb_frontend *fe)
160 [DVBT2_8] = { 0xbc, 0x22, 0x01 }, 162 [DVBT2_8] = { 0xbc, 0x22, 0x01 },
161 [DVBC_6] = { 0x92, 0x50, 0x03 }, 163 [DVBC_6] = { 0x92, 0x50, 0x03 },
162 [DVBC_8] = { 0x92, 0x53, 0x03 }, 164 [DVBC_8] = { 0x92, 0x53, 0x03 },
165 [ATSC_VSB] = { 0x7d, 0x20, 0x63 },
166 [ATSC_QAM] = { 0x7d, 0x20, 0x63 },
163 }; 167 };
164 168
165 dev_dbg(&priv->i2c->dev, 169 dev_dbg(&priv->i2c->dev,
@@ -171,6 +175,14 @@ static int tda18212_set_params(struct dvb_frontend *fe)
171 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ 175 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */
172 176
173 switch (c->delivery_system) { 177 switch (c->delivery_system) {
178 case SYS_ATSC:
179 if_khz = priv->cfg->if_atsc_vsb;
180 i = ATSC_VSB;
181 break;
182 case SYS_DVBC_ANNEX_B:
183 if_khz = priv->cfg->if_atsc_qam;
184 i = ATSC_QAM;
185 break;
174 case SYS_DVBT: 186 case SYS_DVBT:
175 switch (c->bandwidth_hz) { 187 switch (c->bandwidth_hz) {
176 case 6000000: 188 case 6000000:
diff --git a/drivers/media/tuners/tda18212.h b/drivers/media/tuners/tda18212.h
index 7e0d503baf05..c36b49e4b274 100644
--- a/drivers/media/tuners/tda18212.h
+++ b/drivers/media/tuners/tda18212.h
@@ -35,6 +35,8 @@ struct tda18212_config {
35 u16 if_dvbt2_7; 35 u16 if_dvbt2_7;
36 u16 if_dvbt2_8; 36 u16 if_dvbt2_8;
37 u16 if_dvbc; 37 u16 if_dvbc;
38 u16 if_atsc_vsb;
39 u16 if_atsc_qam;
38}; 40};
39 41
40#if IS_ENABLED(CONFIG_MEDIA_TUNER_TDA18212) 42#if IS_ENABLED(CONFIG_MEDIA_TUNER_TDA18212)
diff --git a/drivers/media/tuners/tuner-xc2028.c b/drivers/media/tuners/tuner-xc2028.c
index cca508d4aafb..76a816511f2f 100644
--- a/drivers/media/tuners/tuner-xc2028.c
+++ b/drivers/media/tuners/tuner-xc2028.c
@@ -1107,6 +1107,9 @@ static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */,
1107 offset += 200000; 1107 offset += 200000;
1108 } 1108 }
1109#endif 1109#endif
1110 default:
1111 tuner_err("Unsupported tuner type %d.\n", new_type);
1112 break;
1110 } 1113 }
1111 1114
1112 div = (freq - offset + DIV / 2) / DIV; 1115 div = (freq - offset + DIV / 2) / DIV;
diff --git a/drivers/media/usb/au0828/au0828-cards.c b/drivers/media/usb/au0828/au0828-cards.c
index dd32decb237d..7fdadf9bc90b 100644
--- a/drivers/media/usb/au0828/au0828-cards.c
+++ b/drivers/media/usb/au0828/au0828-cards.c
@@ -108,7 +108,7 @@ struct au0828_board au0828_boards[] = {
108 .name = "DViCO FusionHDTV USB", 108 .name = "DViCO FusionHDTV USB",
109 .tuner_type = UNSET, 109 .tuner_type = UNSET,
110 .tuner_addr = ADDR_UNSET, 110 .tuner_addr = ADDR_UNSET,
111 .i2c_clk_divider = AU0828_I2C_CLK_250KHZ, 111 .i2c_clk_divider = AU0828_I2C_CLK_20KHZ,
112 }, 112 },
113 [AU0828_BOARD_HAUPPAUGE_WOODBURY] = { 113 [AU0828_BOARD_HAUPPAUGE_WOODBURY] = {
114 .name = "Hauppauge Woodbury", 114 .name = "Hauppauge Woodbury",
@@ -270,18 +270,25 @@ void au0828_gpio_setup(struct au0828_dev *dev)
270 * 9 - XC5000 Tuner 270 * 9 - XC5000 Tuner
271 */ 271 */
272 272
273 /* Into reset */ 273 /* Set relevant GPIOs as outputs (leave the EEPROM W/P
274 as an input since we will never touch it and it has
275 a pullup) */
274 au0828_write(dev, REG_003, 0x02); 276 au0828_write(dev, REG_003, 0x02);
275 au0828_write(dev, REG_002, 0x80 | 0x20 | 0x10); 277 au0828_write(dev, REG_002, 0x80 | 0x20 | 0x10);
278
279 /* Into reset */
276 au0828_write(dev, REG_001, 0x0); 280 au0828_write(dev, REG_001, 0x0);
277 au0828_write(dev, REG_000, 0x0); 281 au0828_write(dev, REG_000, 0x0);
278 msleep(100); 282 msleep(50);
279 283
280 /* Out of reset (leave the cs5340 in reset until needed) */ 284 /* Bring power supply out of reset */
281 au0828_write(dev, REG_003, 0x02); 285 au0828_write(dev, REG_000, 0x80);
282 au0828_write(dev, REG_001, 0x02); 286 msleep(50);
283 au0828_write(dev, REG_002, 0x80 | 0x20 | 0x10); 287
284 au0828_write(dev, REG_000, 0x80 | 0x40 | 0x20); 288 /* Bring xc5000 and au8522 out of reset (leave the
289 cs5340 in reset until needed) */
290 au0828_write(dev, REG_001, 0x02); /* xc5000 */
291 au0828_write(dev, REG_000, 0x80 | 0x20); /* PS + au8522 */
285 292
286 msleep(250); 293 msleep(250);
287 break; 294 break;
diff --git a/drivers/media/usb/cx231xx/cx231xx-input.c b/drivers/media/usb/cx231xx/cx231xx-input.c
index 0f7b42446826..46d52fac8680 100644
--- a/drivers/media/usb/cx231xx/cx231xx-input.c
+++ b/drivers/media/usb/cx231xx/cx231xx-input.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * cx231xx IR glue driver 2 * cx231xx IR glue driver
3 * 3 *
4 * Copyright (C) 2010 Mauro Carvalho Chehab <mchehab@redhat.com> 4 * Copyright (C) 2010 Mauro Carvalho Chehab
5 * 5 *
6 * Polaris (cx231xx) has its support for IR's with a design close to MCE. 6 * Polaris (cx231xx) has its support for IR's with a design close to MCE.
7 * however, a few designs are using an external I2C chip for IR, instead 7 * however, a few designs are using an external I2C chip for IR, instead
diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig b/drivers/media/usb/dvb-usb-v2/Kconfig
index 2059d0c86ad3..037e519bbaa2 100644
--- a/drivers/media/usb/dvb-usb-v2/Kconfig
+++ b/drivers/media/usb/dvb-usb-v2/Kconfig
@@ -100,13 +100,6 @@ config DVB_USB_GL861
100 Say Y here to support the MSI Megasky 580 (55801) DVB-T USB2.0 100 Say Y here to support the MSI Megasky 580 (55801) DVB-T USB2.0
101 receiver with USB ID 0db0:5581. 101 receiver with USB ID 0db0:5581.
102 102
103config DVB_USB_IT913X
104 tristate "ITE IT913X DVB-T USB2.0 support"
105 depends on DVB_USB_V2
106 select DVB_IT913X_FE
107 help
108 Say Y here to support the ITE IT913X DVB-T USB2.0
109
110config DVB_USB_LME2510 103config DVB_USB_LME2510
111 tristate "LME DM04/QQBOX DVB-S USB2.0 support" 104 tristate "LME DM04/QQBOX DVB-S USB2.0 support"
112 depends on DVB_USB_V2 105 depends on DVB_USB_V2
@@ -133,7 +126,7 @@ config DVB_USB_MXL111SF
133 126
134config DVB_USB_RTL28XXU 127config DVB_USB_RTL28XXU
135 tristate "Realtek RTL28xxU DVB USB support" 128 tristate "Realtek RTL28xxU DVB USB support"
136 depends on DVB_USB_V2 129 depends on DVB_USB_V2 && I2C_MUX
137 select DVB_RTL2830 130 select DVB_RTL2830
138 select DVB_RTL2832 131 select DVB_RTL2832
139 select MEDIA_TUNER_QT1010 if MEDIA_SUBDRV_AUTOSELECT 132 select MEDIA_TUNER_QT1010 if MEDIA_SUBDRV_AUTOSELECT
diff --git a/drivers/media/usb/dvb-usb-v2/Makefile b/drivers/media/usb/dvb-usb-v2/Makefile
index 2c06714b9ef0..7407b8338ccf 100644
--- a/drivers/media/usb/dvb-usb-v2/Makefile
+++ b/drivers/media/usb/dvb-usb-v2/Makefile
@@ -22,9 +22,6 @@ obj-$(CONFIG_DVB_USB_CE6230) += dvb-usb-ce6230.o
22dvb-usb-ec168-objs := ec168.o 22dvb-usb-ec168-objs := ec168.o
23obj-$(CONFIG_DVB_USB_EC168) += dvb-usb-ec168.o 23obj-$(CONFIG_DVB_USB_EC168) += dvb-usb-ec168.o
24 24
25dvb-usb-it913x-objs := it913x.o
26obj-$(CONFIG_DVB_USB_IT913X) += dvb-usb-it913x.o
27
28dvb-usb-lmedm04-objs := lmedm04.o 25dvb-usb-lmedm04-objs := lmedm04.o
29obj-$(CONFIG_DVB_USB_LME2510) += dvb-usb-lmedm04.o 26obj-$(CONFIG_DVB_USB_LME2510) += dvb-usb-lmedm04.o
30 27
@@ -44,3 +41,4 @@ ccflags-y += -I$(srctree)/drivers/media/dvb-core
44ccflags-y += -I$(srctree)/drivers/media/dvb-frontends 41ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
45ccflags-y += -I$(srctree)/drivers/media/tuners 42ccflags-y += -I$(srctree)/drivers/media/tuners
46ccflags-y += -I$(srctree)/drivers/media/common 43ccflags-y += -I$(srctree)/drivers/media/common
44ccflags-y += -I$(srctree)/drivers/staging/media/rtl2832u_sdr
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 8ede8ea762e6..021e4d35e4d7 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -575,6 +575,10 @@ static int af9035_download_firmware(struct dvb_usb_device *d,
575 if (ret < 0) 575 if (ret < 0)
576 goto err; 576 goto err;
577 577
578 /* use default I2C address if eeprom has no address set */
579 if (!tmp)
580 tmp = 0x3a;
581
578 if (state->chip_type == 0x9135) { 582 if (state->chip_type == 0x9135) {
579 ret = af9035_wr_reg(d, 0x004bfb, tmp); 583 ret = af9035_wr_reg(d, 0x004bfb, tmp);
580 if (ret < 0) 584 if (ret < 0)
@@ -637,6 +641,7 @@ static int af9035_read_config(struct dvb_usb_device *d)
637 641
638 /* demod I2C "address" */ 642 /* demod I2C "address" */
639 state->af9033_config[0].i2c_addr = 0x38; 643 state->af9033_config[0].i2c_addr = 0x38;
644 state->af9033_config[1].i2c_addr = 0x3a;
640 state->af9033_config[0].adc_multiplier = AF9033_ADC_MULTIPLIER_2X; 645 state->af9033_config[0].adc_multiplier = AF9033_ADC_MULTIPLIER_2X;
641 state->af9033_config[1].adc_multiplier = AF9033_ADC_MULTIPLIER_2X; 646 state->af9033_config[1].adc_multiplier = AF9033_ADC_MULTIPLIER_2X;
642 state->af9033_config[0].ts_mode = AF9033_TS_MODE_USB; 647 state->af9033_config[0].ts_mode = AF9033_TS_MODE_USB;
@@ -684,7 +689,9 @@ static int af9035_read_config(struct dvb_usb_device *d)
684 if (ret < 0) 689 if (ret < 0)
685 goto err; 690 goto err;
686 691
687 state->af9033_config[1].i2c_addr = tmp; 692 if (tmp)
693 state->af9033_config[1].i2c_addr = tmp;
694
688 dev_dbg(&d->udev->dev, "%s: 2nd demod I2C addr=%02x\n", 695 dev_dbg(&d->udev->dev, "%s: 2nd demod I2C addr=%02x\n",
689 __func__, tmp); 696 __func__, tmp);
690 } 697 }
@@ -938,12 +945,7 @@ static int af9035_frontend_callback(void *adapter_priv, int component,
938static int af9035_get_adapter_count(struct dvb_usb_device *d) 945static int af9035_get_adapter_count(struct dvb_usb_device *d)
939{ 946{
940 struct state *state = d_to_priv(d); 947 struct state *state = d_to_priv(d);
941 948 return state->dual_mode + 1;
942 /* disable 2nd adapter as we don't have PID filters implemented */
943 if (d->udev->speed == USB_SPEED_FULL)
944 return 1;
945 else
946 return state->dual_mode + 1;
947} 949}
948 950
949static int af9035_frontend_attach(struct dvb_usb_adapter *adap) 951static int af9035_frontend_attach(struct dvb_usb_adapter *adap)
@@ -961,7 +963,7 @@ static int af9035_frontend_attach(struct dvb_usb_adapter *adap)
961 963
962 /* attach demodulator */ 964 /* attach demodulator */
963 adap->fe[0] = dvb_attach(af9033_attach, &state->af9033_config[adap->id], 965 adap->fe[0] = dvb_attach(af9033_attach, &state->af9033_config[adap->id],
964 &d->i2c_adap); 966 &d->i2c_adap, &state->ops);
965 if (adap->fe[0] == NULL) { 967 if (adap->fe[0] == NULL) {
966 ret = -ENODEV; 968 ret = -ENODEV;
967 goto err; 969 goto err;
@@ -1369,58 +1371,19 @@ static int af9035_get_stream_config(struct dvb_frontend *fe, u8 *ts_type,
1369 return 0; 1371 return 0;
1370} 1372}
1371 1373
1372/*
1373 * FIXME: PID filter is property of demodulator and should be moved to the
1374 * correct driver. Also we support only adapter #0 PID filter and will
1375 * disable adapter #1 if USB1.1 is used.
1376 */
1377static int af9035_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) 1374static int af9035_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
1378{ 1375{
1379 struct dvb_usb_device *d = adap_to_d(adap); 1376 struct state *state = adap_to_priv(adap);
1380 int ret;
1381
1382 dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff);
1383
1384 ret = af9035_wr_reg_mask(d, 0x80f993, onoff, 0x01);
1385 if (ret < 0)
1386 goto err;
1387
1388 return 0;
1389
1390err:
1391 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
1392 1377
1393 return ret; 1378 return state->ops.pid_filter_ctrl(adap->fe[0], onoff);
1394} 1379}
1395 1380
1396static int af9035_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, 1381static int af9035_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
1397 int onoff) 1382 int onoff)
1398{ 1383{
1399 struct dvb_usb_device *d = adap_to_d(adap); 1384 struct state *state = adap_to_priv(adap);
1400 int ret;
1401 u8 wbuf[2] = {(pid >> 0) & 0xff, (pid >> 8) & 0xff};
1402
1403 dev_dbg(&d->udev->dev, "%s: index=%d pid=%04x onoff=%d\n",
1404 __func__, index, pid, onoff);
1405
1406 ret = af9035_wr_regs(d, 0x80f996, wbuf, 2);
1407 if (ret < 0)
1408 goto err;
1409
1410 ret = af9035_wr_reg(d, 0x80f994, onoff);
1411 if (ret < 0)
1412 goto err;
1413
1414 ret = af9035_wr_reg(d, 0x80f995, index);
1415 if (ret < 0)
1416 goto err;
1417
1418 return 0;
1419
1420err:
1421 dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
1422 1385
1423 return ret; 1386 return state->ops.pid_filter(adap->fe[0], index, pid, onoff);
1424} 1387}
1425 1388
1426static int af9035_probe(struct usb_interface *intf, 1389static int af9035_probe(struct usb_interface *intf,
@@ -1494,6 +1457,13 @@ static const struct dvb_usb_device_properties af9035_props = {
1494 1457
1495 .stream = DVB_USB_STREAM_BULK(0x84, 6, 87 * 188), 1458 .stream = DVB_USB_STREAM_BULK(0x84, 6, 87 * 188),
1496 }, { 1459 }, {
1460 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
1461 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
1462
1463 .pid_filter_count = 32,
1464 .pid_filter_ctrl = af9035_pid_filter_ctrl,
1465 .pid_filter = af9035_pid_filter,
1466
1497 .stream = DVB_USB_STREAM_BULK(0x85, 6, 87 * 188), 1467 .stream = DVB_USB_STREAM_BULK(0x85, 6, 87 * 188),
1498 }, 1468 },
1499 }, 1469 },
@@ -1528,12 +1498,30 @@ static const struct usb_device_id af9035_id_table[] = {
1528 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00aa, 1498 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x00aa,
1529 &af9035_props, "TerraTec Cinergy T Stick (rev. 2)", NULL) }, 1499 &af9035_props, "TerraTec Cinergy T Stick (rev. 2)", NULL) },
1530 /* IT9135 devices */ 1500 /* IT9135 devices */
1531#if 0 1501 { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135,
1532 { DVB_USB_DEVICE(0x048d, 0x9135, 1502 &af9035_props, "ITE 9135 Generic", RC_MAP_IT913X_V1) },
1533 &af9035_props, "IT9135 reference design", NULL) }, 1503 { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135_9005,
1534 { DVB_USB_DEVICE(0x048d, 0x9006, 1504 &af9035_props, "ITE 9135(9005) Generic", RC_MAP_IT913X_V2) },
1535 &af9035_props, "IT9135 reference design", NULL) }, 1505 { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135_9006,
1536#endif 1506 &af9035_props, "ITE 9135(9006) Generic", RC_MAP_IT913X_V1) },
1507 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_1835,
1508 &af9035_props, "Avermedia A835B(1835)", RC_MAP_IT913X_V2) },
1509 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_2835,
1510 &af9035_props, "Avermedia A835B(2835)", RC_MAP_IT913X_V2) },
1511 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_3835,
1512 &af9035_props, "Avermedia A835B(3835)", RC_MAP_IT913X_V2) },
1513 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_4835,
1514 &af9035_props, "Avermedia A835B(4835)", RC_MAP_IT913X_V2) },
1515 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_H335,
1516 &af9035_props, "Avermedia H335", RC_MAP_IT913X_V2) },
1517 { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB499_2T_T09,
1518 &af9035_props, "Kworld UB499-2T T09", RC_MAP_IT913X_V1) },
1519 { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV22_IT9137,
1520 &af9035_props, "Sveon STV22 Dual DVB-T HDTV",
1521 RC_MAP_IT913X_V1) },
1522 { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CTVDIGDUAL_V2,
1523 &af9035_props, "Digital Dual TV Receiver CTVDIGDUAL_V2",
1524 RC_MAP_IT913X_V1) },
1537 /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */ 1525 /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
1538 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099, 1526 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099,
1539 &af9035_props, "TerraTec Cinergy T Stick Dual RC (rev. 2)", NULL) }, 1527 &af9035_props, "TerraTec Cinergy T Stick Dual RC (rev. 2)", NULL) },
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.h b/drivers/media/usb/dvb-usb-v2/af9035.h
index a1c68d829b8c..c21902fdd4c4 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.h
+++ b/drivers/media/usb/dvb-usb-v2/af9035.h
@@ -62,6 +62,8 @@ struct state {
62 u8 dual_mode:1; 62 u8 dual_mode:1;
63 u16 eeprom_addr; 63 u16 eeprom_addr;
64 struct af9033_config af9033_config[2]; 64 struct af9033_config af9033_config[2];
65
66 struct af9033_ops ops;
65}; 67};
66 68
67static const u32 clock_lut_af9035[] = { 69static const u32 clock_lut_af9035[] = {
diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index c1051c347744..c3c4b98733bf 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -7,7 +7,7 @@
7 * http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz 7 * http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz
8 * The original driver's license is GPL, as declared with MODULE_LICENSE() 8 * The original driver's license is GPL, as declared with MODULE_LICENSE()
9 * 9 *
10 * Copyright (c) 2010-2012 Mauro Carvalho Chehab <mchehab@redhat.com> 10 * Copyright (c) 2010-2012 Mauro Carvalho Chehab
11 * Driver modified by in order to work with upstream drxk driver, and 11 * Driver modified by in order to work with upstream drxk driver, and
12 * tons of bugs got fixed, and converted to use dvb-usb-v2. 12 * tons of bugs got fixed, and converted to use dvb-usb-v2.
13 * 13 *
@@ -975,7 +975,7 @@ static struct usb_driver az6007_usb_driver = {
975module_usb_driver(az6007_usb_driver); 975module_usb_driver(az6007_usb_driver);
976 976
977MODULE_AUTHOR("Henry Wang <Henry.wang@AzureWave.com>"); 977MODULE_AUTHOR("Henry Wang <Henry.wang@AzureWave.com>");
978MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 978MODULE_AUTHOR("Mauro Carvalho Chehab");
979MODULE_DESCRIPTION("Driver for AzureWave 6007 DVB-C/T USB2.0 and clones"); 979MODULE_DESCRIPTION("Driver for AzureWave 6007 DVB-C/T USB2.0 and clones");
980MODULE_VERSION("2.0"); 980MODULE_VERSION("2.0");
981MODULE_LICENSE("GPL"); 981MODULE_LICENSE("GPL");
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 8a054d66e708..de02db802ace 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -164,7 +164,7 @@ static int dvb_usbv2_remote_init(struct dvb_usb_device *d)
164 dev->driver_name = (char *) d->props->driver_name; 164 dev->driver_name = (char *) d->props->driver_name;
165 dev->map_name = d->rc.map_name; 165 dev->map_name = d->rc.map_name;
166 dev->driver_type = d->rc.driver_type; 166 dev->driver_type = d->rc.driver_type;
167 dev->allowed_protos = d->rc.allowed_protos; 167 rc_set_allowed_protocols(dev, d->rc.allowed_protos);
168 dev->change_protocol = d->rc.change_protocol; 168 dev->change_protocol = d->rc.change_protocol;
169 dev->priv = d; 169 dev->priv = d;
170 170
diff --git a/drivers/media/usb/dvb-usb-v2/it913x.c b/drivers/media/usb/dvb-usb-v2/it913x.c
deleted file mode 100644
index fe95a586dd5d..000000000000
--- a/drivers/media/usb/dvb-usb-v2/it913x.c
+++ /dev/null
@@ -1,828 +0,0 @@
1/*
2 * DVB USB compliant linux driver for ITE IT9135 and IT9137
3 *
4 * Copyright (C) 2011 Malcolm Priestley (tvboxspy@gmail.com)
5 * IT9135 (C) ITE Tech Inc.
6 * IT9137 (C) ITE Tech Inc.
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 Version 2, as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 *
22 * see Documentation/dvb/README.dvb-usb for more information
23 * see Documentation/dvb/it9137.txt for firmware information
24 *
25 */
26#define DVB_USB_LOG_PREFIX "it913x"
27
28#include <linux/usb.h>
29#include <linux/usb/input.h>
30#include <media/rc-core.h>
31
32#include "dvb_usb.h"
33#include "it913x-fe.h"
34
35/* debug */
36static int dvb_usb_it913x_debug;
37#define it_debug(var, level, args...) \
38 do { if ((var & level)) pr_debug(DVB_USB_LOG_PREFIX": " args); \
39} while (0)
40#define deb_info(level, args...) it_debug(dvb_usb_it913x_debug, level, args)
41#define info(args...) pr_info(DVB_USB_LOG_PREFIX": " args)
42
43module_param_named(debug, dvb_usb_it913x_debug, int, 0644);
44MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able)).");
45
46static int dvb_usb_it913x_firmware;
47module_param_named(firmware, dvb_usb_it913x_firmware, int, 0644);
48MODULE_PARM_DESC(firmware, "set firmware 0=auto "\
49 "1=IT9137 2=IT9135 V1 3=IT9135 V2");
50#define FW_IT9137 "dvb-usb-it9137-01.fw"
51#define FW_IT9135_V1 "dvb-usb-it9135-01.fw"
52#define FW_IT9135_V2 "dvb-usb-it9135-02.fw"
53
54DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
55
56struct it913x_state {
57 struct ite_config it913x_config;
58 u8 pid_filter_onoff;
59 bool proprietary_ir;
60 int cmd_counter;
61};
62
63static u16 check_sum(u8 *p, u8 len)
64{
65 u16 sum = 0;
66 u8 i = 1;
67 while (i < len)
68 sum += (i++ & 1) ? (*p++) << 8 : *p++;
69 return ~sum;
70}
71
72static int it913x_io(struct dvb_usb_device *d, u8 mode, u8 pro,
73 u8 cmd, u32 reg, u8 addr, u8 *data, u8 len)
74{
75 struct it913x_state *st = d->priv;
76 int ret = 0, i, buf_size = 1;
77 u8 *buff;
78 u8 rlen;
79 u16 chk_sum;
80
81 buff = kzalloc(256, GFP_KERNEL);
82 if (!buff) {
83 info("USB Buffer Failed");
84 return -ENOMEM;
85 }
86
87 buff[buf_size++] = pro;
88 buff[buf_size++] = cmd;
89 buff[buf_size++] = st->cmd_counter;
90
91 switch (mode) {
92 case READ_LONG:
93 case WRITE_LONG:
94 buff[buf_size++] = len;
95 buff[buf_size++] = 2;
96 buff[buf_size++] = (reg >> 24);
97 buff[buf_size++] = (reg >> 16) & 0xff;
98 buff[buf_size++] = (reg >> 8) & 0xff;
99 buff[buf_size++] = reg & 0xff;
100 break;
101 case READ_SHORT:
102 buff[buf_size++] = addr;
103 break;
104 case WRITE_SHORT:
105 buff[buf_size++] = len;
106 buff[buf_size++] = addr;
107 buff[buf_size++] = (reg >> 8) & 0xff;
108 buff[buf_size++] = reg & 0xff;
109 break;
110 case READ_DATA:
111 case WRITE_DATA:
112 break;
113 case WRITE_CMD:
114 mode = 7;
115 break;
116 default:
117 kfree(buff);
118 return -EINVAL;
119 }
120
121 if (mode & 1) {
122 for (i = 0; i < len ; i++)
123 buff[buf_size++] = data[i];
124 }
125 chk_sum = check_sum(&buff[1], buf_size);
126
127 buff[buf_size++] = chk_sum >> 8;
128 buff[0] = buf_size;
129 buff[buf_size++] = (chk_sum & 0xff);
130
131 ret = dvb_usbv2_generic_rw(d, buff, buf_size, buff, (mode & 1) ?
132 5 : len + 5);
133 if (ret < 0)
134 goto error;
135
136 rlen = (mode & 0x1) ? 0x1 : len;
137
138 if (mode & 1)
139 ret = buff[2];
140 else
141 memcpy(data, &buff[3], rlen);
142
143 st->cmd_counter++;
144
145error: kfree(buff);
146
147 return ret;
148}
149
150static int it913x_wr_reg(struct dvb_usb_device *d, u8 pro, u32 reg , u8 data)
151{
152 int ret;
153 u8 b[1];
154 b[0] = data;
155 ret = it913x_io(d, WRITE_LONG, pro,
156 CMD_DEMOD_WRITE, reg, 0, b, sizeof(b));
157
158 return ret;
159}
160
161static int it913x_read_reg(struct dvb_usb_device *d, u32 reg)
162{
163 int ret;
164 u8 data[1];
165
166 ret = it913x_io(d, READ_LONG, DEV_0,
167 CMD_DEMOD_READ, reg, 0, &data[0], sizeof(data));
168
169 return (ret < 0) ? ret : data[0];
170}
171
172static int it913x_query(struct dvb_usb_device *d, u8 pro)
173{
174 struct it913x_state *st = d->priv;
175 int ret, i;
176 u8 data[4];
177 u8 ver;
178
179 for (i = 0; i < 5; i++) {
180 ret = it913x_io(d, READ_LONG, pro, CMD_DEMOD_READ,
181 0x1222, 0, &data[0], 3);
182 ver = data[0];
183 if (ver > 0 && ver < 3)
184 break;
185 msleep(100);
186 }
187
188 if (ver < 1 || ver > 2) {
189 info("Failed to identify chip version applying 1");
190 st->it913x_config.chip_ver = 0x1;
191 st->it913x_config.chip_type = 0x9135;
192 return 0;
193 }
194
195 st->it913x_config.chip_ver = ver;
196 st->it913x_config.chip_type = (u16)(data[2] << 8) + data[1];
197
198 info("Chip Version=%02x Chip Type=%04x", st->it913x_config.chip_ver,
199 st->it913x_config.chip_type);
200
201 ret = it913x_io(d, READ_SHORT, pro,
202 CMD_QUERYINFO, 0, 0x1, &data[0], 4);
203
204 st->it913x_config.firmware = (data[0] << 24) | (data[1] << 16) |
205 (data[2] << 8) | data[3];
206
207 return ret;
208}
209
210static int it913x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
211{
212 struct dvb_usb_device *d = adap_to_d(adap);
213 struct it913x_state *st = adap_to_priv(adap);
214 int ret;
215 u8 pro = (adap->id == 0) ? DEV_0_DMOD : DEV_1_DMOD;
216
217 mutex_lock(&d->i2c_mutex);
218
219 deb_info(1, "PID_C (%02x)", onoff);
220
221 st->pid_filter_onoff = adap->pid_filtering;
222 ret = it913x_wr_reg(d, pro, PID_EN, st->pid_filter_onoff);
223
224 mutex_unlock(&d->i2c_mutex);
225 return ret;
226}
227
228static int it913x_pid_filter(struct dvb_usb_adapter *adap,
229 int index, u16 pid, int onoff)
230{
231 struct dvb_usb_device *d = adap_to_d(adap);
232 struct it913x_state *st = adap_to_priv(adap);
233 int ret;
234 u8 pro = (adap->id == 0) ? DEV_0_DMOD : DEV_1_DMOD;
235
236 mutex_lock(&d->i2c_mutex);
237
238 deb_info(1, "PID_F (%02x)", onoff);
239
240 ret = it913x_wr_reg(d, pro, PID_LSB, (u8)(pid & 0xff));
241
242 ret |= it913x_wr_reg(d, pro, PID_MSB, (u8)(pid >> 8));
243
244 ret |= it913x_wr_reg(d, pro, PID_INX_EN, (u8)onoff);
245
246 ret |= it913x_wr_reg(d, pro, PID_INX, (u8)(index & 0x1f));
247
248 if (d->udev->speed == USB_SPEED_HIGH && pid == 0x2000) {
249 ret |= it913x_wr_reg(d , pro, PID_EN, !onoff);
250 st->pid_filter_onoff = !onoff;
251 } else
252 st->pid_filter_onoff =
253 adap->pid_filtering;
254
255 mutex_unlock(&d->i2c_mutex);
256 return 0;
257}
258
259
260static int it913x_return_status(struct dvb_usb_device *d)
261{
262 struct it913x_state *st = d->priv;
263 int ret = it913x_query(d, DEV_0);
264 if (st->it913x_config.firmware > 0)
265 info("Firmware Version %d", st->it913x_config.firmware);
266
267 return ret;
268}
269
270static int it913x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
271 int num)
272{
273 struct dvb_usb_device *d = i2c_get_adapdata(adap);
274 static u8 data[256];
275 int ret;
276 u32 reg;
277 u8 pro;
278
279 mutex_lock(&d->i2c_mutex);
280
281 deb_info(2, "num of messages %d address %02x", num, msg[0].addr);
282
283 pro = (msg[0].addr & 0x2) ? DEV_0_DMOD : 0x0;
284 pro |= (msg[0].addr & 0x20) ? DEV_1 : DEV_0;
285 memcpy(data, msg[0].buf, msg[0].len);
286 reg = (data[0] << 24) + (data[1] << 16) +
287 (data[2] << 8) + data[3];
288 if (num == 2) {
289 ret = it913x_io(d, READ_LONG, pro,
290 CMD_DEMOD_READ, reg, 0, data, msg[1].len);
291 memcpy(msg[1].buf, data, msg[1].len);
292 } else
293 ret = it913x_io(d, WRITE_LONG, pro, CMD_DEMOD_WRITE,
294 reg, 0, &data[4], msg[0].len - 4);
295
296 mutex_unlock(&d->i2c_mutex);
297
298 return ret;
299}
300
301static u32 it913x_i2c_func(struct i2c_adapter *adapter)
302{
303 return I2C_FUNC_I2C;
304}
305
306static struct i2c_algorithm it913x_i2c_algo = {
307 .master_xfer = it913x_i2c_xfer,
308 .functionality = it913x_i2c_func,
309};
310
311/* Callbacks for DVB USB */
312#if IS_ENABLED(CONFIG_RC_CORE)
313static int it913x_rc_query(struct dvb_usb_device *d)
314{
315 u8 ibuf[4];
316 int ret;
317 u32 key;
318 /* Avoid conflict with frontends*/
319 mutex_lock(&d->i2c_mutex);
320
321 ret = it913x_io(d, READ_LONG, PRO_LINK, CMD_IR_GET,
322 0, 0, &ibuf[0], sizeof(ibuf));
323
324 if ((ibuf[2] + ibuf[3]) == 0xff) {
325 key = ibuf[2];
326 key += ibuf[0] << 16;
327 key += ibuf[1] << 8;
328 deb_info(1, "NEC Extended Key =%08x", key);
329 if (d->rc_dev != NULL)
330 rc_keydown(d->rc_dev, key, 0);
331 }
332
333 mutex_unlock(&d->i2c_mutex);
334
335 return ret;
336}
337
338static int it913x_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
339{
340 struct it913x_state *st = d->priv;
341
342 if (st->proprietary_ir == false) {
343 rc->map_name = NULL;
344 return 0;
345 }
346
347 rc->allowed_protos = RC_BIT_NEC;
348 rc->query = it913x_rc_query;
349 rc->interval = 250;
350
351 return 0;
352}
353#else
354 #define it913x_get_rc_config NULL
355#endif
356
357/* Firmware sets raw */
358static const char fw_it9135_v1[] = FW_IT9135_V1;
359static const char fw_it9135_v2[] = FW_IT9135_V2;
360static const char fw_it9137[] = FW_IT9137;
361
362static void ite_get_firmware_name(struct dvb_usb_device *d,
363 const char **name)
364{
365 struct it913x_state *st = d->priv;
366 int sw;
367 /* auto switch */
368 if (le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_KWORLD_2)
369 sw = IT9137_FW;
370 else if (st->it913x_config.chip_ver == 1)
371 sw = IT9135_V1_FW;
372 else
373 sw = IT9135_V2_FW;
374
375 /* force switch */
376 if (dvb_usb_it913x_firmware != IT9135_AUTO)
377 sw = dvb_usb_it913x_firmware;
378
379 switch (sw) {
380 case IT9135_V1_FW:
381 st->it913x_config.firmware_ver = 1;
382 st->it913x_config.adc_x2 = 1;
383 st->it913x_config.read_slevel = false;
384 *name = fw_it9135_v1;
385 break;
386 case IT9135_V2_FW:
387 st->it913x_config.firmware_ver = 1;
388 st->it913x_config.adc_x2 = 1;
389 st->it913x_config.read_slevel = false;
390 *name = fw_it9135_v2;
391 switch (st->it913x_config.tuner_id_0) {
392 case IT9135_61:
393 case IT9135_62:
394 break;
395 default:
396 info("Unknown tuner ID applying default 0x60");
397 case IT9135_60:
398 st->it913x_config.tuner_id_0 = IT9135_60;
399 }
400 break;
401 case IT9137_FW:
402 default:
403 st->it913x_config.firmware_ver = 0;
404 st->it913x_config.adc_x2 = 0;
405 st->it913x_config.read_slevel = true;
406 *name = fw_it9137;
407 }
408
409 return;
410}
411
412#define TS_MPEG_PKT_SIZE 188
413#define EP_LOW 21
414#define TS_BUFFER_SIZE_PID (EP_LOW*TS_MPEG_PKT_SIZE)
415#define EP_HIGH 348
416#define TS_BUFFER_SIZE_MAX (EP_HIGH*TS_MPEG_PKT_SIZE)
417
418static int it913x_get_stream_config(struct dvb_frontend *fe, u8 *ts_type,
419 struct usb_data_stream_properties *stream)
420{
421 struct dvb_usb_adapter *adap = fe_to_adap(fe);
422 if (adap->pid_filtering)
423 stream->u.bulk.buffersize = TS_BUFFER_SIZE_PID;
424 else
425 stream->u.bulk.buffersize = TS_BUFFER_SIZE_MAX;
426
427 return 0;
428}
429
430static int it913x_select_config(struct dvb_usb_device *d)
431{
432 struct it913x_state *st = d->priv;
433 int ret, reg;
434
435 ret = it913x_return_status(d);
436 if (ret < 0)
437 return ret;
438
439 if (st->it913x_config.chip_ver == 0x02
440 && st->it913x_config.chip_type == 0x9135)
441 reg = it913x_read_reg(d, 0x461d);
442 else
443 reg = it913x_read_reg(d, 0x461b);
444
445 if (reg < 0)
446 return reg;
447
448 if (reg == 0) {
449 st->it913x_config.dual_mode = 0;
450 st->it913x_config.tuner_id_0 = IT9135_38;
451 st->proprietary_ir = true;
452 } else {
453 /* TS mode */
454 reg = it913x_read_reg(d, 0x49c5);
455 if (reg < 0)
456 return reg;
457 st->it913x_config.dual_mode = reg;
458
459 /* IR mode type */
460 reg = it913x_read_reg(d, 0x49ac);
461 if (reg < 0)
462 return reg;
463 if (reg == 5) {
464 info("Remote propriety (raw) mode");
465 st->proprietary_ir = true;
466 } else if (reg == 1) {
467 info("Remote HID mode NOT SUPPORTED");
468 st->proprietary_ir = false;
469 }
470
471 /* Tuner_id */
472 reg = it913x_read_reg(d, 0x49d0);
473 if (reg < 0)
474 return reg;
475 st->it913x_config.tuner_id_0 = reg;
476 }
477
478 info("Dual mode=%x Tuner Type=%x", st->it913x_config.dual_mode,
479 st->it913x_config.tuner_id_0);
480
481 return ret;
482}
483
484static int it913x_streaming_ctrl(struct dvb_frontend *fe, int onoff)
485{
486 struct dvb_usb_adapter *adap = fe_to_adap(fe);
487 struct dvb_usb_device *d = adap_to_d(adap);
488 struct it913x_state *st = fe_to_priv(fe);
489 int ret = 0;
490 u8 pro = (adap->id == 0) ? DEV_0_DMOD : DEV_1_DMOD;
491
492 deb_info(1, "STM (%02x)", onoff);
493
494 if (!onoff) {
495 mutex_lock(&d->i2c_mutex);
496
497 ret = it913x_wr_reg(d, pro, PID_RST, 0x1);
498
499 mutex_unlock(&d->i2c_mutex);
500 st->pid_filter_onoff =
501 adap->pid_filtering;
502
503 }
504
505 return ret;
506}
507
508static int it913x_identify_state(struct dvb_usb_device *d, const char **name)
509{
510 struct it913x_state *st = d->priv;
511 int ret;
512 u8 reg;
513
514 /* Read and select config */
515 ret = it913x_select_config(d);
516 if (ret < 0)
517 return ret;
518
519 ite_get_firmware_name(d, name);
520
521 if (st->it913x_config.firmware > 0)
522 return WARM;
523
524 if (st->it913x_config.dual_mode) {
525 st->it913x_config.tuner_id_1 = it913x_read_reg(d, 0x49e0);
526 ret = it913x_wr_reg(d, DEV_0, GPIOH1_EN, 0x1);
527 ret |= it913x_wr_reg(d, DEV_0, GPIOH1_ON, 0x1);
528 ret |= it913x_wr_reg(d, DEV_0, GPIOH1_O, 0x1);
529 msleep(50);
530 ret |= it913x_wr_reg(d, DEV_0, GPIOH1_O, 0x0);
531 msleep(50);
532 reg = it913x_read_reg(d, GPIOH1_O);
533 if (reg == 0) {
534 ret |= it913x_wr_reg(d, DEV_0, GPIOH1_O, 0x1);
535 ret |= it913x_return_status(d);
536 if (ret != 0)
537 ret = it913x_wr_reg(d, DEV_0,
538 GPIOH1_O, 0x0);
539 }
540 }
541
542 reg = it913x_read_reg(d, IO_MUX_POWER_CLK);
543
544 if (st->it913x_config.dual_mode) {
545 ret |= it913x_wr_reg(d, DEV_0, 0x4bfb, CHIP2_I2C_ADDR);
546 if (st->it913x_config.firmware_ver == 1)
547 ret |= it913x_wr_reg(d, DEV_0, 0xcfff, 0x1);
548 else
549 ret |= it913x_wr_reg(d, DEV_0, CLK_O_EN, 0x1);
550 } else {
551 ret |= it913x_wr_reg(d, DEV_0, 0x4bfb, 0x0);
552 if (st->it913x_config.firmware_ver == 1)
553 ret |= it913x_wr_reg(d, DEV_0, 0xcfff, 0x0);
554 else
555 ret |= it913x_wr_reg(d, DEV_0, CLK_O_EN, 0x0);
556 }
557
558 ret |= it913x_wr_reg(d, DEV_0, I2C_CLK, I2C_CLK_100);
559
560 return (ret < 0) ? ret : COLD;
561}
562
563static int it913x_download_firmware(struct dvb_usb_device *d,
564 const struct firmware *fw)
565{
566 struct it913x_state *st = d->priv;
567 int ret = 0, i = 0, pos = 0;
568 u8 packet_size, min_pkt;
569 u8 *fw_data;
570
571 ret = it913x_wr_reg(d, DEV_0, I2C_CLK, I2C_CLK_100);
572
573 info("FRM Starting Firmware Download");
574
575 /* Multi firmware loader */
576 /* This uses scatter write firmware headers */
577 /* The firmware must start with 03 XX 00 */
578 /* and be the extact firmware length */
579
580 if (st->it913x_config.chip_ver == 2)
581 min_pkt = 0x11;
582 else
583 min_pkt = 0x19;
584
585 while (i <= fw->size) {
586 if (((fw->data[i] == 0x3) && (fw->data[i + 2] == 0x0))
587 || (i == fw->size)) {
588 packet_size = i - pos;
589 if ((packet_size > min_pkt) || (i == fw->size)) {
590 fw_data = (u8 *)(fw->data + pos);
591 pos += packet_size;
592 if (packet_size > 0) {
593 ret = it913x_io(d, WRITE_DATA,
594 DEV_0, CMD_SCATTER_WRITE, 0,
595 0, fw_data, packet_size);
596 if (ret < 0)
597 break;
598 }
599 udelay(1000);
600 }
601 }
602 i++;
603 }
604
605 if (ret < 0)
606 info("FRM Firmware Download Failed (%d)" , ret);
607 else
608 info("FRM Firmware Download Completed - Resetting Device");
609
610 msleep(30);
611
612 ret = it913x_io(d, WRITE_CMD, DEV_0, CMD_BOOT, 0, 0, NULL, 0);
613 if (ret < 0)
614 info("FRM Device not responding to reboot");
615
616 ret = it913x_return_status(d);
617 if (st->it913x_config.firmware == 0) {
618 info("FRM Failed to reboot device");
619 return -ENODEV;
620 }
621
622 msleep(30);
623
624 ret = it913x_wr_reg(d, DEV_0, I2C_CLK, I2C_CLK_400);
625
626 msleep(30);
627
628 /* Tuner function */
629 if (st->it913x_config.dual_mode)
630 ret |= it913x_wr_reg(d, DEV_0_DMOD , 0xec4c, 0xa0);
631 else
632 ret |= it913x_wr_reg(d, DEV_0_DMOD , 0xec4c, 0x68);
633
634 if ((st->it913x_config.chip_ver == 1) &&
635 (st->it913x_config.chip_type == 0x9135)) {
636 ret |= it913x_wr_reg(d, DEV_0, PADODPU, 0x0);
637 ret |= it913x_wr_reg(d, DEV_0, AGC_O_D, 0x0);
638 if (st->it913x_config.dual_mode) {
639 ret |= it913x_wr_reg(d, DEV_1, PADODPU, 0x0);
640 ret |= it913x_wr_reg(d, DEV_1, AGC_O_D, 0x0);
641 }
642 }
643
644 return (ret < 0) ? -ENODEV : 0;
645}
646
647static int it913x_name(struct dvb_usb_adapter *adap)
648{
649 struct dvb_usb_device *d = adap_to_d(adap);
650 const char *desc = d->name;
651 char *fe_name[] = {"_1", "_2", "_3", "_4"};
652 char *name = adap->fe[0]->ops.info.name;
653
654 strlcpy(name, desc, 128);
655 strlcat(name, fe_name[adap->id], 128);
656
657 return 0;
658}
659
660static int it913x_frontend_attach(struct dvb_usb_adapter *adap)
661{
662 struct dvb_usb_device *d = adap_to_d(adap);
663 struct it913x_state *st = d->priv;
664 int ret = 0;
665 u8 adap_addr = I2C_BASE_ADDR + (adap->id << 5);
666 u16 ep_size = (adap->pid_filtering) ? TS_BUFFER_SIZE_PID / 4 :
667 TS_BUFFER_SIZE_MAX / 4;
668 u8 pkt_size = 0x80;
669
670 if (d->udev->speed != USB_SPEED_HIGH)
671 pkt_size = 0x10;
672
673 st->it913x_config.adf = it913x_read_reg(d, IO_MUX_POWER_CLK);
674
675 adap->fe[0] = dvb_attach(it913x_fe_attach,
676 &d->i2c_adap, adap_addr, &st->it913x_config);
677
678 if (adap->id == 0 && adap->fe[0]) {
679 it913x_wr_reg(d, DEV_0_DMOD, MP2_SW_RST, 0x1);
680 it913x_wr_reg(d, DEV_0_DMOD, MP2IF2_SW_RST, 0x1);
681 it913x_wr_reg(d, DEV_0, EP0_TX_EN, 0x0f);
682 it913x_wr_reg(d, DEV_0, EP0_TX_NAK, 0x1b);
683 if (st->proprietary_ir == false) /* Enable endpoint 3 */
684 it913x_wr_reg(d, DEV_0, EP0_TX_EN, 0x3f);
685 else
686 it913x_wr_reg(d, DEV_0, EP0_TX_EN, 0x2f);
687 it913x_wr_reg(d, DEV_0, EP4_TX_LEN_LSB,
688 ep_size & 0xff);
689 it913x_wr_reg(d, DEV_0, EP4_TX_LEN_MSB, ep_size >> 8);
690 ret = it913x_wr_reg(d, DEV_0, EP4_MAX_PKT, pkt_size);
691 } else if (adap->id == 1 && adap->fe[0]) {
692 if (st->proprietary_ir == false)
693 it913x_wr_reg(d, DEV_0, EP0_TX_EN, 0x7f);
694 else
695 it913x_wr_reg(d, DEV_0, EP0_TX_EN, 0x6f);
696 it913x_wr_reg(d, DEV_0, EP5_TX_LEN_LSB,
697 ep_size & 0xff);
698 it913x_wr_reg(d, DEV_0, EP5_TX_LEN_MSB, ep_size >> 8);
699 it913x_wr_reg(d, DEV_0, EP5_MAX_PKT, pkt_size);
700 it913x_wr_reg(d, DEV_0_DMOD, MP2IF2_EN, 0x1);
701 it913x_wr_reg(d, DEV_1_DMOD, MP2IF_SERIAL, 0x1);
702 it913x_wr_reg(d, DEV_1, TOP_HOSTB_SER_MODE, 0x1);
703 it913x_wr_reg(d, DEV_0_DMOD, TSIS_ENABLE, 0x1);
704 it913x_wr_reg(d, DEV_0_DMOD, MP2_SW_RST, 0x0);
705 it913x_wr_reg(d, DEV_0_DMOD, MP2IF2_SW_RST, 0x0);
706 it913x_wr_reg(d, DEV_0_DMOD, MP2IF2_HALF_PSB, 0x0);
707 it913x_wr_reg(d, DEV_0_DMOD, MP2IF_STOP_EN, 0x1);
708 it913x_wr_reg(d, DEV_1_DMOD, MPEG_FULL_SPEED, 0x0);
709 ret = it913x_wr_reg(d, DEV_1_DMOD, MP2IF_STOP_EN, 0x0);
710 } else
711 return -ENODEV;
712
713 ret |= it913x_name(adap);
714
715 return ret;
716}
717
718/* DVB USB Driver */
719static int it913x_get_adapter_count(struct dvb_usb_device *d)
720{
721 struct it913x_state *st = d->priv;
722 if (st->it913x_config.dual_mode)
723 return 2;
724 return 1;
725}
726
727static struct dvb_usb_device_properties it913x_properties = {
728 .driver_name = KBUILD_MODNAME,
729 .owner = THIS_MODULE,
730 .bInterfaceNumber = 0,
731 .generic_bulk_ctrl_endpoint = 0x02,
732 .generic_bulk_ctrl_endpoint_response = 0x81,
733
734 .adapter_nr = adapter_nr,
735 .size_of_priv = sizeof(struct it913x_state),
736
737 .identify_state = it913x_identify_state,
738 .i2c_algo = &it913x_i2c_algo,
739
740 .download_firmware = it913x_download_firmware,
741
742 .frontend_attach = it913x_frontend_attach,
743 .get_rc_config = it913x_get_rc_config,
744 .get_stream_config = it913x_get_stream_config,
745 .get_adapter_count = it913x_get_adapter_count,
746 .streaming_ctrl = it913x_streaming_ctrl,
747
748
749 .adapter = {
750 {
751 .caps = DVB_USB_ADAP_HAS_PID_FILTER|
752 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
753 .pid_filter_count = 32,
754 .pid_filter = it913x_pid_filter,
755 .pid_filter_ctrl = it913x_pid_filter_ctrl,
756 .stream =
757 DVB_USB_STREAM_BULK(0x84, 10, TS_BUFFER_SIZE_MAX),
758 },
759 {
760 .caps = DVB_USB_ADAP_HAS_PID_FILTER|
761 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
762 .pid_filter_count = 32,
763 .pid_filter = it913x_pid_filter,
764 .pid_filter_ctrl = it913x_pid_filter_ctrl,
765 .stream =
766 DVB_USB_STREAM_BULK(0x85, 10, TS_BUFFER_SIZE_MAX),
767 }
768 }
769};
770
771static const struct usb_device_id it913x_id_table[] = {
772 { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_UB499_2T_T09,
773 &it913x_properties, "Kworld UB499-2T T09(IT9137)",
774 RC_MAP_IT913X_V1) },
775 { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135,
776 &it913x_properties, "ITE 9135 Generic",
777 RC_MAP_IT913X_V1) },
778 { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_SVEON_STV22_IT9137,
779 &it913x_properties, "Sveon STV22 Dual DVB-T HDTV(IT9137)",
780 RC_MAP_IT913X_V1) },
781 { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135_9005,
782 &it913x_properties, "ITE 9135(9005) Generic",
783 RC_MAP_IT913X_V2) },
784 { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135_9006,
785 &it913x_properties, "ITE 9135(9006) Generic",
786 RC_MAP_IT913X_V1) },
787 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_1835,
788 &it913x_properties, "Avermedia A835B(1835)",
789 RC_MAP_IT913X_V2) },
790 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_2835,
791 &it913x_properties, "Avermedia A835B(2835)",
792 RC_MAP_IT913X_V2) },
793 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_3835,
794 &it913x_properties, "Avermedia A835B(3835)",
795 RC_MAP_IT913X_V2) },
796 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_A835B_4835,
797 &it913x_properties, "Avermedia A835B(4835)",
798 RC_MAP_IT913X_V2) },
799 { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CTVDIGDUAL_V2,
800 &it913x_properties, "Digital Dual TV Receiver CTVDIGDUAL_V2",
801 RC_MAP_IT913X_V1) },
802 { DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_H335,
803 &it913x_properties, "Avermedia H335",
804 RC_MAP_IT913X_V2) },
805 {} /* Terminating entry */
806};
807
808MODULE_DEVICE_TABLE(usb, it913x_id_table);
809
810static struct usb_driver it913x_driver = {
811 .name = KBUILD_MODNAME,
812 .probe = dvb_usbv2_probe,
813 .disconnect = dvb_usbv2_disconnect,
814 .suspend = dvb_usbv2_suspend,
815 .resume = dvb_usbv2_resume,
816 .id_table = it913x_id_table,
817};
818
819module_usb_driver(it913x_driver);
820
821MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
822MODULE_DESCRIPTION("it913x USB 2 Driver");
823MODULE_VERSION("1.33");
824MODULE_LICENSE("GPL");
825MODULE_FIRMWARE(FW_IT9135_V1);
826MODULE_FIRMWARE(FW_IT9135_V2);
827MODULE_FIRMWARE(FW_IT9137);
828
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index fda5c64ba0e8..c83c16cece01 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -24,6 +24,7 @@
24 24
25#include "rtl2830.h" 25#include "rtl2830.h"
26#include "rtl2832.h" 26#include "rtl2832.h"
27#include "rtl2832_sdr.h"
27 28
28#include "qt1010.h" 29#include "qt1010.h"
29#include "mt2060.h" 30#include "mt2060.h"
@@ -35,6 +36,9 @@
35#include "tua9001.h" 36#include "tua9001.h"
36#include "r820t.h" 37#include "r820t.h"
37 38
39static int rtl28xxu_disable_rc;
40module_param_named(disable_rc, rtl28xxu_disable_rc, int, 0644);
41MODULE_PARM_DESC(disable_rc, "disable RTL2832U remote controller");
38DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 42DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
39 43
40static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) 44static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req)
@@ -513,7 +517,7 @@ err:
513 return ret; 517 return ret;
514} 518}
515 519
516static struct rtl2830_config rtl28xxu_rtl2830_mt2060_config = { 520static const struct rtl2830_config rtl28xxu_rtl2830_mt2060_config = {
517 .i2c_addr = 0x10, /* 0x20 */ 521 .i2c_addr = 0x10, /* 0x20 */
518 .xtal = 28800000, 522 .xtal = 28800000,
519 .ts_mode = 0, 523 .ts_mode = 0,
@@ -524,7 +528,7 @@ static struct rtl2830_config rtl28xxu_rtl2830_mt2060_config = {
524 528
525}; 529};
526 530
527static struct rtl2830_config rtl28xxu_rtl2830_qt1010_config = { 531static const struct rtl2830_config rtl28xxu_rtl2830_qt1010_config = {
528 .i2c_addr = 0x10, /* 0x20 */ 532 .i2c_addr = 0x10, /* 0x20 */
529 .xtal = 28800000, 533 .xtal = 28800000,
530 .ts_mode = 0, 534 .ts_mode = 0,
@@ -534,7 +538,7 @@ static struct rtl2830_config rtl28xxu_rtl2830_qt1010_config = {
534 .agc_targ_val = 0x2d, 538 .agc_targ_val = 0x2d,
535}; 539};
536 540
537static struct rtl2830_config rtl28xxu_rtl2830_mxl5005s_config = { 541static const struct rtl2830_config rtl28xxu_rtl2830_mxl5005s_config = {
538 .i2c_addr = 0x10, /* 0x20 */ 542 .i2c_addr = 0x10, /* 0x20 */
539 .xtal = 28800000, 543 .xtal = 28800000,
540 .ts_mode = 0, 544 .ts_mode = 0,
@@ -548,7 +552,7 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap)
548{ 552{
549 struct dvb_usb_device *d = adap_to_d(adap); 553 struct dvb_usb_device *d = adap_to_d(adap);
550 struct rtl28xxu_priv *priv = d_to_priv(d); 554 struct rtl28xxu_priv *priv = d_to_priv(d);
551 struct rtl2830_config *rtl2830_config; 555 const struct rtl2830_config *rtl2830_config;
552 int ret; 556 int ret;
553 557
554 dev_dbg(&d->udev->dev, "%s:\n", __func__); 558 dev_dbg(&d->udev->dev, "%s:\n", __func__);
@@ -583,33 +587,31 @@ err:
583 return ret; 587 return ret;
584} 588}
585 589
586static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = { 590static const struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = {
587 .i2c_addr = 0x10, /* 0x20 */ 591 .i2c_addr = 0x10, /* 0x20 */
588 .xtal = 28800000, 592 .xtal = 28800000,
589 .if_dvbt = 0,
590 .tuner = TUNER_RTL2832_FC0012 593 .tuner = TUNER_RTL2832_FC0012
591}; 594};
592 595
593static struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = { 596static const struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = {
594 .i2c_addr = 0x10, /* 0x20 */ 597 .i2c_addr = 0x10, /* 0x20 */
595 .xtal = 28800000, 598 .xtal = 28800000,
596 .if_dvbt = 0,
597 .tuner = TUNER_RTL2832_FC0013 599 .tuner = TUNER_RTL2832_FC0013
598}; 600};
599 601
600static struct rtl2832_config rtl28xxu_rtl2832_tua9001_config = { 602static const struct rtl2832_config rtl28xxu_rtl2832_tua9001_config = {
601 .i2c_addr = 0x10, /* 0x20 */ 603 .i2c_addr = 0x10, /* 0x20 */
602 .xtal = 28800000, 604 .xtal = 28800000,
603 .tuner = TUNER_RTL2832_TUA9001, 605 .tuner = TUNER_RTL2832_TUA9001,
604}; 606};
605 607
606static struct rtl2832_config rtl28xxu_rtl2832_e4000_config = { 608static const struct rtl2832_config rtl28xxu_rtl2832_e4000_config = {
607 .i2c_addr = 0x10, /* 0x20 */ 609 .i2c_addr = 0x10, /* 0x20 */
608 .xtal = 28800000, 610 .xtal = 28800000,
609 .tuner = TUNER_RTL2832_E4000, 611 .tuner = TUNER_RTL2832_E4000,
610}; 612};
611 613
612static struct rtl2832_config rtl28xxu_rtl2832_r820t_config = { 614static const struct rtl2832_config rtl28xxu_rtl2832_r820t_config = {
613 .i2c_addr = 0x10, 615 .i2c_addr = 0x10,
614 .xtal = 28800000, 616 .xtal = 28800000,
615 .tuner = TUNER_RTL2832_R820T, 617 .tuner = TUNER_RTL2832_R820T,
@@ -733,7 +735,7 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
733 int ret; 735 int ret;
734 struct dvb_usb_device *d = adap_to_d(adap); 736 struct dvb_usb_device *d = adap_to_d(adap);
735 struct rtl28xxu_priv *priv = d_to_priv(d); 737 struct rtl28xxu_priv *priv = d_to_priv(d);
736 struct rtl2832_config *rtl2832_config; 738 const struct rtl2832_config *rtl2832_config;
737 739
738 dev_dbg(&d->udev->dev, "%s:\n", __func__); 740 dev_dbg(&d->udev->dev, "%s:\n", __func__);
739 741
@@ -772,6 +774,9 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
772 goto err; 774 goto err;
773 } 775 }
774 776
777 /* RTL2832 I2C repeater */
778 priv->demod_i2c_adapter = rtl2832_get_i2c_adapter(adap->fe[0]);
779
775 /* set fe callback */ 780 /* set fe callback */
776 adap->fe[0]->callback = rtl2832u_frontend_callback; 781 adap->fe[0]->callback = rtl2832u_frontend_callback;
777 782
@@ -851,11 +856,6 @@ err:
851 return ret; 856 return ret;
852} 857}
853 858
854static const struct e4000_config rtl2832u_e4000_config = {
855 .i2c_addr = 0x64,
856 .clock = 28800000,
857};
858
859static const struct fc2580_config rtl2832u_fc2580_config = { 859static const struct fc2580_config rtl2832u_fc2580_config = {
860 .i2c_addr = 0x56, 860 .i2c_addr = 0x56,
861 .clock = 16384000, 861 .clock = 16384000,
@@ -889,10 +889,14 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
889 int ret; 889 int ret;
890 struct dvb_usb_device *d = adap_to_d(adap); 890 struct dvb_usb_device *d = adap_to_d(adap);
891 struct rtl28xxu_priv *priv = d_to_priv(d); 891 struct rtl28xxu_priv *priv = d_to_priv(d);
892 struct dvb_frontend *fe; 892 struct dvb_frontend *fe = NULL;
893 struct i2c_board_info info;
894 struct i2c_client *client;
893 895
894 dev_dbg(&d->udev->dev, "%s:\n", __func__); 896 dev_dbg(&d->udev->dev, "%s:\n", __func__);
895 897
898 memset(&info, 0, sizeof(struct i2c_board_info));
899
896 switch (priv->tuner) { 900 switch (priv->tuner) {
897 case TUNER_RTL2832_FC0012: 901 case TUNER_RTL2832_FC0012:
898 fe = dvb_attach(fc0012_attach, adap->fe[0], 902 fe = dvb_attach(fc0012_attach, adap->fe[0],
@@ -902,7 +906,10 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
902 * that to the tuner driver */ 906 * that to the tuner driver */
903 adap->fe[0]->ops.read_signal_strength = 907 adap->fe[0]->ops.read_signal_strength =
904 adap->fe[0]->ops.tuner_ops.get_rf_strength; 908 adap->fe[0]->ops.tuner_ops.get_rf_strength;
905 return 0; 909
910 /* attach SDR */
911 dvb_attach(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap,
912 &rtl28xxu_rtl2832_fc0012_config, NULL);
906 break; 913 break;
907 case TUNER_RTL2832_FC0013: 914 case TUNER_RTL2832_FC0013:
908 fe = dvb_attach(fc0013_attach, adap->fe[0], 915 fe = dvb_attach(fc0013_attach, adap->fe[0],
@@ -911,10 +918,43 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
911 /* fc0013 also supports signal strength reading */ 918 /* fc0013 also supports signal strength reading */
912 adap->fe[0]->ops.read_signal_strength = 919 adap->fe[0]->ops.read_signal_strength =
913 adap->fe[0]->ops.tuner_ops.get_rf_strength; 920 adap->fe[0]->ops.tuner_ops.get_rf_strength;
914 return 0; 921
915 case TUNER_RTL2832_E4000: 922 /* attach SDR */
916 fe = dvb_attach(e4000_attach, adap->fe[0], &d->i2c_adap, 923 dvb_attach(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap,
917 &rtl2832u_e4000_config); 924 &rtl28xxu_rtl2832_fc0013_config, NULL);
925 break;
926 case TUNER_RTL2832_E4000: {
927 struct v4l2_subdev *sd;
928 struct i2c_adapter *i2c_adap_internal =
929 rtl2832_get_private_i2c_adapter(adap->fe[0]);
930 struct e4000_config e4000_config = {
931 .fe = adap->fe[0],
932 .clock = 28800000,
933 };
934
935 strlcpy(info.type, "e4000", I2C_NAME_SIZE);
936 info.addr = 0x64;
937 info.platform_data = &e4000_config;
938
939 request_module(info.type);
940 client = i2c_new_device(priv->demod_i2c_adapter, &info);
941 if (client == NULL || client->dev.driver == NULL)
942 break;
943
944 if (!try_module_get(client->dev.driver->owner)) {
945 i2c_unregister_device(client);
946 break;
947 }
948
949 priv->client = client;
950 sd = i2c_get_clientdata(client);
951 i2c_set_adapdata(i2c_adap_internal, d);
952
953 /* attach SDR */
954 dvb_attach(rtl2832_sdr_attach, adap->fe[0],
955 i2c_adap_internal,
956 &rtl28xxu_rtl2832_e4000_config, sd);
957 }
918 break; 958 break;
919 case TUNER_RTL2832_FC2580: 959 case TUNER_RTL2832_FC2580:
920 fe = dvb_attach(fc2580_attach, adap->fe[0], &d->i2c_adap, 960 fe = dvb_attach(fc2580_attach, adap->fe[0], &d->i2c_adap,
@@ -940,6 +980,10 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
940 /* Use tuner to get the signal strength */ 980 /* Use tuner to get the signal strength */
941 adap->fe[0]->ops.read_signal_strength = 981 adap->fe[0]->ops.read_signal_strength =
942 adap->fe[0]->ops.tuner_ops.get_rf_strength; 982 adap->fe[0]->ops.tuner_ops.get_rf_strength;
983
984 /* attach SDR */
985 dvb_attach(rtl2832_sdr_attach, adap->fe[0], &d->i2c_adap,
986 &rtl28xxu_rtl2832_r820t_config, NULL);
943 break; 987 break;
944 case TUNER_RTL2832_R828D: 988 case TUNER_RTL2832_R828D:
945 /* power off mn88472 demod on GPIO0 */ 989 /* power off mn88472 demod on GPIO0 */
@@ -963,12 +1007,11 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
963 adap->fe[0]->ops.tuner_ops.get_rf_strength; 1007 adap->fe[0]->ops.tuner_ops.get_rf_strength;
964 break; 1008 break;
965 default: 1009 default:
966 fe = NULL;
967 dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME, 1010 dev_err(&d->udev->dev, "%s: unknown tuner=%d\n", KBUILD_MODNAME,
968 priv->tuner); 1011 priv->tuner);
969 } 1012 }
970 1013
971 if (fe == NULL) { 1014 if (fe == NULL && priv->client == NULL) {
972 ret = -ENODEV; 1015 ret = -ENODEV;
973 goto err; 1016 goto err;
974 } 1017 }
@@ -1013,6 +1056,22 @@ err:
1013 return ret; 1056 return ret;
1014} 1057}
1015 1058
1059static void rtl28xxu_exit(struct dvb_usb_device *d)
1060{
1061 struct rtl28xxu_priv *priv = d->priv;
1062 struct i2c_client *client = priv->client;
1063
1064 dev_dbg(&d->udev->dev, "%s:\n", __func__);
1065
1066 /* remove I2C tuner */
1067 if (client) {
1068 module_put(client->dev.driver->owner);
1069 i2c_unregister_device(client);
1070 }
1071
1072 return;
1073}
1074
1016static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff) 1075static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff)
1017{ 1076{
1018 int ret; 1077 int ret;
@@ -1322,6 +1381,10 @@ err:
1322static int rtl2832u_get_rc_config(struct dvb_usb_device *d, 1381static int rtl2832u_get_rc_config(struct dvb_usb_device *d,
1323 struct dvb_usb_rc *rc) 1382 struct dvb_usb_rc *rc)
1324{ 1383{
1384 /* disable IR interrupts in order to avoid SDR sample loss */
1385 if (rtl28xxu_disable_rc)
1386 return rtl28xx_wr_reg(d, IR_RX_IE, 0x00);
1387
1325 /* load empty to enable rc */ 1388 /* load empty to enable rc */
1326 if (!rc->map_name) 1389 if (!rc->map_name)
1327 rc->map_name = RC_MAP_EMPTY; 1390 rc->map_name = RC_MAP_EMPTY;
@@ -1371,6 +1434,7 @@ static const struct dvb_usb_device_properties rtl2832u_props = {
1371 .frontend_attach = rtl2832u_frontend_attach, 1434 .frontend_attach = rtl2832u_frontend_attach,
1372 .tuner_attach = rtl2832u_tuner_attach, 1435 .tuner_attach = rtl2832u_tuner_attach,
1373 .init = rtl28xxu_init, 1436 .init = rtl28xxu_init,
1437 .exit = rtl28xxu_exit,
1374 .get_rc_config = rtl2832u_get_rc_config, 1438 .get_rc_config = rtl2832u_get_rc_config,
1375 1439
1376 .num_adapters = 1, 1440 .num_adapters = 1,
@@ -1382,6 +1446,7 @@ static const struct dvb_usb_device_properties rtl2832u_props = {
1382}; 1446};
1383 1447
1384static const struct usb_device_id rtl28xxu_id_table[] = { 1448static const struct usb_device_id rtl28xxu_id_table[] = {
1449 /* RTL2831U devices: */
1385 { DVB_USB_DEVICE(USB_VID_REALTEK, USB_PID_REALTEK_RTL2831U, 1450 { DVB_USB_DEVICE(USB_VID_REALTEK, USB_PID_REALTEK_RTL2831U,
1386 &rtl2831u_props, "Realtek RTL2831U reference design", NULL) }, 1451 &rtl2831u_props, "Realtek RTL2831U reference design", NULL) },
1387 { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT, 1452 { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT,
@@ -1389,6 +1454,7 @@ static const struct usb_device_id rtl28xxu_id_table[] = {
1389 { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT_2, 1454 { DVB_USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT_2,
1390 &rtl2831u_props, "Freecom USB2.0 DVB-T", NULL) }, 1455 &rtl2831u_props, "Freecom USB2.0 DVB-T", NULL) },
1391 1456
1457 /* RTL2832U devices: */
1392 { DVB_USB_DEVICE(USB_VID_REALTEK, 0x2832, 1458 { DVB_USB_DEVICE(USB_VID_REALTEK, 0x2832,
1393 &rtl2832u_props, "Realtek RTL2832U reference design", NULL) }, 1459 &rtl2832u_props, "Realtek RTL2832U reference design", NULL) },
1394 { DVB_USB_DEVICE(USB_VID_REALTEK, 0x2838, 1460 { DVB_USB_DEVICE(USB_VID_REALTEK, 0x2838,
@@ -1401,6 +1467,8 @@ static const struct usb_device_id rtl28xxu_id_table[] = {
1401 &rtl2832u_props, "TerraTec NOXON DAB Stick", NULL) }, 1467 &rtl2832u_props, "TerraTec NOXON DAB Stick", NULL) },
1402 { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK_REV2, 1468 { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK_REV2,
1403 &rtl2832u_props, "TerraTec NOXON DAB Stick (rev 2)", NULL) }, 1469 &rtl2832u_props, "TerraTec NOXON DAB Stick (rev 2)", NULL) },
1470 { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK_REV3,
1471 &rtl2832u_props, "TerraTec NOXON DAB Stick (rev 3)", NULL) },
1404 { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_TREKSTOR_TERRES_2_0, 1472 { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_TREKSTOR_TERRES_2_0,
1405 &rtl2832u_props, "Trekstor DVB-T Stick Terres 2.0", NULL) }, 1473 &rtl2832u_props, "Trekstor DVB-T Stick Terres 2.0", NULL) },
1406 { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1101, 1474 { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1101,
@@ -1429,9 +1497,14 @@ static const struct usb_device_id rtl28xxu_id_table[] = {
1429 &rtl2832u_props, "Leadtek WinFast DTV Dongle mini", NULL) }, 1497 &rtl2832u_props, "Leadtek WinFast DTV Dongle mini", NULL) },
1430 { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_CPYTO_REDI_PC50A, 1498 { DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_CPYTO_REDI_PC50A,
1431 &rtl2832u_props, "Crypto ReDi PC 50 A", NULL) }, 1499 &rtl2832u_props, "Crypto ReDi PC 50 A", NULL) },
1500 { DVB_USB_DEVICE(USB_VID_KYE, 0x707f,
1501 &rtl2832u_props, "Genius TVGo DVB-T03", NULL) },
1432 1502
1503 /* RTL2832P devices: */
1433 { DVB_USB_DEVICE(USB_VID_HANFTEK, 0x0131, 1504 { DVB_USB_DEVICE(USB_VID_HANFTEK, 0x0131,
1434 &rtl2832u_props, "Astrometa DVB-T2", NULL) }, 1505 &rtl2832u_props, "Astrometa DVB-T2", NULL) },
1506 { DVB_USB_DEVICE(USB_VID_KYE, 0x707f,
1507 &rtl2832u_props, "Genius TVGo DVB-T03", NULL) },
1435 { } 1508 { }
1436}; 1509};
1437MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table); 1510MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table);
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h
index 2142bcb41b41..a26cab10f382 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h
@@ -55,7 +55,9 @@ struct rtl28xxu_priv {
55 u8 tuner; 55 u8 tuner;
56 char *tuner_name; 56 char *tuner_name;
57 u8 page; /* integrated demod active register page */ 57 u8 page; /* integrated demod active register page */
58 struct i2c_adapter *demod_i2c_adapter;
58 bool rc_active; 59 bool rc_active;
60 struct i2c_client *client;
59}; 61};
60 62
61enum rtl28xxu_chip_id { 63enum rtl28xxu_chip_id {
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-remote.c b/drivers/media/usb/dvb-usb/dvb-usb-remote.c
index 41bacff24960..4058aea9272f 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-remote.c
@@ -272,7 +272,7 @@ static int rc_core_dvb_usb_remote_init(struct dvb_usb_device *d)
272 dev->driver_name = d->props.rc.core.module_name; 272 dev->driver_name = d->props.rc.core.module_name;
273 dev->map_name = d->props.rc.core.rc_codes; 273 dev->map_name = d->props.rc.core.rc_codes;
274 dev->change_protocol = d->props.rc.core.change_protocol; 274 dev->change_protocol = d->props.rc.core.change_protocol;
275 dev->allowed_protos = d->props.rc.core.allowed_protos; 275 rc_set_allowed_protocols(dev, d->props.rc.core.allowed_protos);
276 dev->driver_type = d->props.rc.core.driver_type; 276 dev->driver_type = d->props.rc.core.driver_type;
277 usb_to_input_id(d->udev, &dev->input_id); 277 usb_to_input_id(d->udev, &dev->input_id);
278 dev->input_name = "IR-receiver inside an USB DVB receiver"; 278 dev->input_name = "IR-receiver inside an USB DVB receiver";
diff --git a/drivers/media/usb/em28xx/Kconfig b/drivers/media/usb/em28xx/Kconfig
index a1fccf3096de..d23a912096f7 100644
--- a/drivers/media/usb/em28xx/Kconfig
+++ b/drivers/media/usb/em28xx/Kconfig
@@ -53,8 +53,10 @@ config VIDEO_EM28XX_DVB
53 select DVB_MB86A20S if MEDIA_SUBDRV_AUTOSELECT 53 select DVB_MB86A20S if MEDIA_SUBDRV_AUTOSELECT
54 select MEDIA_TUNER_QT1010 if MEDIA_SUBDRV_AUTOSELECT 54 select MEDIA_TUNER_QT1010 if MEDIA_SUBDRV_AUTOSELECT
55 select MEDIA_TUNER_TDA18271 if MEDIA_SUBDRV_AUTOSELECT 55 select MEDIA_TUNER_TDA18271 if MEDIA_SUBDRV_AUTOSELECT
56 select MEDIA_TUNER_TDA18212 if MEDIA_SUBDRV_AUTOSELECT
56 select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT 57 select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT
57 select MEDIA_TUNER_M88TS2022 if MEDIA_SUBDRV_AUTOSELECT 58 select MEDIA_TUNER_M88TS2022 if MEDIA_SUBDRV_AUTOSELECT
59 select DVB_DRX39XYJ if MEDIA_SUBDRV_AUTOSELECT
58 ---help--- 60 ---help---
59 This adds support for DVB cards based on the 61 This adds support for DVB cards based on the
60 Empiatech em28xx chips. 62 Empiatech em28xx chips.
diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
index 1a28897af183..342490f44ed2 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -252,7 +252,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
252{ 252{
253 struct em28xx *dev = snd_pcm_substream_chip(substream); 253 struct em28xx *dev = snd_pcm_substream_chip(substream);
254 struct snd_pcm_runtime *runtime = substream->runtime; 254 struct snd_pcm_runtime *runtime = substream->runtime;
255 int ret = 0; 255 int nonblock, ret = 0;
256 256
257 if (!dev) { 257 if (!dev) {
258 em28xx_err("BUG: em28xx can't find device struct." 258 em28xx_err("BUG: em28xx can't find device struct."
@@ -265,45 +265,48 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
265 265
266 dprintk("opening device and trying to acquire exclusive lock\n"); 266 dprintk("opening device and trying to acquire exclusive lock\n");
267 267
268 nonblock = !!(substream->f_flags & O_NONBLOCK);
269 if (nonblock) {
270 if (!mutex_trylock(&dev->lock))
271 return -EAGAIN;
272 } else
273 mutex_lock(&dev->lock);
274
268 runtime->hw = snd_em28xx_hw_capture; 275 runtime->hw = snd_em28xx_hw_capture;
269 if ((dev->alt == 0 || dev->is_audio_only) && dev->adev.users == 0) { 276
270 int nonblock = !!(substream->f_flags & O_NONBLOCK); 277 if (dev->adev.users == 0) {
271 278 if (dev->alt == 0 || dev->is_audio_only) {
272 if (nonblock) { 279 if (dev->is_audio_only)
273 if (!mutex_trylock(&dev->lock)) 280 /* audio is on a separate interface */
274 return -EAGAIN; 281 dev->alt = 1;
275 } else 282 else
276 mutex_lock(&dev->lock); 283 /* audio is on the same interface as video */
277 if (dev->is_audio_only) 284 dev->alt = 7;
278 /* vendor audio is on a separate interface */ 285 /*
279 dev->alt = 1; 286 * FIXME: The intention seems to be to select
280 else 287 * the alt setting with the largest
281 /* vendor audio is on the same interface as video */ 288 * wMaxPacketSize for the video endpoint.
282 dev->alt = 7; 289 * At least dev->alt should be used instead, but
283 /* 290 * we should probably not touch it at all if it
284 * FIXME: The intention seems to be to select the alt 291 * is already >0, because wMaxPacketSize of the
285 * setting with the largest wMaxPacketSize for the video 292 * audio endpoints seems to be the same for all.
286 * endpoint. 293 */
287 * At least dev->alt should be used instead, but we 294 dprintk("changing alternate number on interface %d to %d\n",
288 * should probably not touch it at all if it is 295 dev->ifnum, dev->alt);
289 * already >0, because wMaxPacketSize of the audio 296 usb_set_interface(dev->udev, dev->ifnum, dev->alt);
290 * endpoints seems to be the same for all. 297 }
291 */
292
293 dprintk("changing alternate number on interface %d to %d\n",
294 dev->ifnum, dev->alt);
295 usb_set_interface(dev->udev, dev->ifnum, dev->alt);
296 298
297 /* Sets volume, mute, etc */ 299 /* Sets volume, mute, etc */
298 dev->mute = 0; 300 dev->mute = 0;
299 ret = em28xx_audio_analog_set(dev); 301 ret = em28xx_audio_analog_set(dev);
300 if (ret < 0) 302 if (ret < 0)
301 goto err; 303 goto err;
302
303 dev->adev.users++;
304 mutex_unlock(&dev->lock);
305 } 304 }
306 305
306 kref_get(&dev->ref);
307 dev->adev.users++;
308 mutex_unlock(&dev->lock);
309
307 /* Dynamically adjust the period size */ 310 /* Dynamically adjust the period size */
308 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); 311 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
309 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 312 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
@@ -341,6 +344,7 @@ static int snd_em28xx_pcm_close(struct snd_pcm_substream *substream)
341 substream->runtime->dma_area = NULL; 344 substream->runtime->dma_area = NULL;
342 } 345 }
343 mutex_unlock(&dev->lock); 346 mutex_unlock(&dev->lock);
347 kref_put(&dev->ref, em28xx_free_device);
344 348
345 return 0; 349 return 0;
346} 350}
@@ -895,6 +899,8 @@ static int em28xx_audio_init(struct em28xx *dev)
895 899
896 em28xx_info("Binding audio extension\n"); 900 em28xx_info("Binding audio extension\n");
897 901
902 kref_get(&dev->ref);
903
898 printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus " 904 printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus "
899 "Rechberger\n"); 905 "Rechberger\n");
900 printk(KERN_INFO 906 printk(KERN_INFO
@@ -966,7 +972,7 @@ static int em28xx_audio_fini(struct em28xx *dev)
966 if (dev == NULL) 972 if (dev == NULL)
967 return 0; 973 return 0;
968 974
969 if (dev->has_alsa_audio != 1) { 975 if (!dev->has_alsa_audio) {
970 /* This device does not support the extension (in this case 976 /* This device does not support the extension (in this case
971 the device is expecting the snd-usb-audio module or 977 the device is expecting the snd-usb-audio module or
972 doesn't have analog audio support at all) */ 978 doesn't have analog audio support at all) */
@@ -985,6 +991,35 @@ static int em28xx_audio_fini(struct em28xx *dev)
985 dev->adev.sndcard = NULL; 991 dev->adev.sndcard = NULL;
986 } 992 }
987 993
994 kref_put(&dev->ref, em28xx_free_device);
995 return 0;
996}
997
998static int em28xx_audio_suspend(struct em28xx *dev)
999{
1000 if (dev == NULL)
1001 return 0;
1002
1003 if (!dev->has_alsa_audio)
1004 return 0;
1005
1006 em28xx_info("Suspending audio extension");
1007 em28xx_deinit_isoc_audio(dev);
1008 atomic_set(&dev->stream_started, 0);
1009 return 0;
1010}
1011
1012static int em28xx_audio_resume(struct em28xx *dev)
1013{
1014 if (dev == NULL)
1015 return 0;
1016
1017 if (!dev->has_alsa_audio)
1018 return 0;
1019
1020 em28xx_info("Resuming audio extension");
1021 /* Nothing to do other than schedule_work() ?? */
1022 schedule_work(&dev->wq_trigger);
988 return 0; 1023 return 0;
989} 1024}
990 1025
@@ -993,6 +1028,8 @@ static struct em28xx_ops audio_ops = {
993 .name = "Em28xx Audio Extension", 1028 .name = "Em28xx Audio Extension",
994 .init = em28xx_audio_init, 1029 .init = em28xx_audio_init,
995 .fini = em28xx_audio_fini, 1030 .fini = em28xx_audio_fini,
1031 .suspend = em28xx_audio_suspend,
1032 .resume = em28xx_audio_resume,
996}; 1033};
997 1034
998static int __init em28xx_alsa_register(void) 1035static int __init em28xx_alsa_register(void)
@@ -1007,7 +1044,7 @@ static void __exit em28xx_alsa_unregister(void)
1007 1044
1008MODULE_LICENSE("GPL"); 1045MODULE_LICENSE("GPL");
1009MODULE_AUTHOR("Markus Rechberger <mrechberger@gmail.com>"); 1046MODULE_AUTHOR("Markus Rechberger <mrechberger@gmail.com>");
1010MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 1047MODULE_AUTHOR("Mauro Carvalho Chehab");
1011MODULE_DESCRIPTION(DRIVER_DESC " - audio interface"); 1048MODULE_DESCRIPTION(DRIVER_DESC " - audio interface");
1012MODULE_VERSION(EM28XX_VERSION); 1049MODULE_VERSION(EM28XX_VERSION);
1013 1050
diff --git a/drivers/media/usb/em28xx/em28xx-camera.c b/drivers/media/usb/em28xx/em28xx-camera.c
index c29f5c4e7b40..505e0505be04 100644
--- a/drivers/media/usb/em28xx/em28xx-camera.c
+++ b/drivers/media/usb/em28xx/em28xx-camera.c
@@ -120,7 +120,7 @@ static int em28xx_probe_sensor_micron(struct em28xx *dev)
120 reg = 0x00; 120 reg = 0x00;
121 ret = i2c_master_send(&client, &reg, 1); 121 ret = i2c_master_send(&client, &reg, 1);
122 if (ret < 0) { 122 if (ret < 0) {
123 if (ret != -ENODEV) 123 if (ret != -ENXIO)
124 em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n", 124 em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n",
125 client.addr << 1, ret); 125 client.addr << 1, ret);
126 continue; 126 continue;
@@ -218,7 +218,7 @@ static int em28xx_probe_sensor_omnivision(struct em28xx *dev)
218 reg = 0x1c; 218 reg = 0x1c;
219 ret = i2c_smbus_read_byte_data(&client, reg); 219 ret = i2c_smbus_read_byte_data(&client, reg);
220 if (ret < 0) { 220 if (ret < 0) {
221 if (ret != -ENODEV) 221 if (ret != -ENXIO)
222 em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n", 222 em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n",
223 client.addr << 1, ret); 223 client.addr << 1, ret);
224 continue; 224 continue;
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index 4d97a76cc3b0..50aa5a5317f2 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -66,7 +66,7 @@ MODULE_PARM_DESC(usb_xfer_mode,
66 66
67 67
68/* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS - 1 */ 68/* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS - 1 */
69DECLARE_BITMAP(em28xx_devused, EM28XX_MAXBOARDS); 69static DECLARE_BITMAP(em28xx_devused, EM28XX_MAXBOARDS);
70 70
71struct em28xx_hash_table { 71struct em28xx_hash_table {
72 unsigned long hash; 72 unsigned long hash;
@@ -189,6 +189,14 @@ static struct em28xx_reg_seq kworld_a340_digital[] = {
189 { -1, -1, -1, -1}, 189 { -1, -1, -1, -1},
190}; 190};
191 191
192static struct em28xx_reg_seq kworld_ub435q_v3_digital[] = {
193 {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 100},
194 {EM2874_R80_GPIO_P0_CTRL, 0xfe, 0xff, 100},
195 {EM2874_R80_GPIO_P0_CTRL, 0xbe, 0xff, 100},
196 {EM2874_R80_GPIO_P0_CTRL, 0xfe, 0xff, 100},
197 { -1, -1, -1, -1},
198};
199
192/* Pinnacle Hybrid Pro eb1a:2881 */ 200/* Pinnacle Hybrid Pro eb1a:2881 */
193static struct em28xx_reg_seq pinnacle_hybrid_pro_analog[] = { 201static struct em28xx_reg_seq pinnacle_hybrid_pro_analog[] = {
194 {EM2820_R08_GPIO_CTRL, 0xfd, ~EM_GPIO_4, 10}, 202 {EM2820_R08_GPIO_CTRL, 0xfd, ~EM_GPIO_4, 10},
@@ -214,6 +222,17 @@ static struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_digital[] = {
214 { -1, -1, -1, -1}, 222 { -1, -1, -1, -1},
215}; 223};
216 224
225/* PCTV HD Mini (80e) GPIOs
226 0-5: not used
227 6: demod reset, active low
228 7: LED on, active high */
229static struct em28xx_reg_seq em2874_pctv_80e_digital[] = {
230 {EM28XX_R06_I2C_CLK, 0x45, 0xff, 10}, /*400 KHz*/
231 {EM2874_R80_GPIO_P0_CTRL, 0x00, 0xff, 100},/*Demod reset*/
232 {EM2874_R80_GPIO_P0_CTRL, 0x40, 0xff, 10},
233 { -1, -1, -1, -1},
234};
235
217/* eb1a:2868 Reddo DVB-C USB TV Box 236/* eb1a:2868 Reddo DVB-C USB TV Box
218 GPIO4 - CU1216L NIM 237 GPIO4 - CU1216L NIM
219 Other GPIOs seems to be don't care. */ 238 Other GPIOs seems to be don't care. */
@@ -497,6 +516,27 @@ static struct em28xx_led speedlink_vad_laplace_leds[] = {
497 {-1, 0, 0, 0}, 516 {-1, 0, 0, 0},
498}; 517};
499 518
519static struct em28xx_led kworld_ub435q_v3_leds[] = {
520 {
521 .role = EM28XX_LED_DIGITAL_CAPTURING,
522 .gpio_reg = EM2874_R80_GPIO_P0_CTRL,
523 .gpio_mask = 0x80,
524 .inverted = 1,
525 },
526 {-1, 0, 0, 0},
527};
528
529static struct em28xx_led pctv_80e_leds[] = {
530 {
531 .role = EM28XX_LED_DIGITAL_CAPTURING,
532 .gpio_reg = EM2874_R80_GPIO_P0_CTRL,
533 .gpio_mask = 0x80,
534 .inverted = 0,
535 },
536 {-1, 0, 0, 0},
537};
538
539
500/* 540/*
501 * Board definitions 541 * Board definitions
502 */ 542 */
@@ -2128,6 +2168,29 @@ struct em28xx_board em28xx_boards[] = {
2128 .tuner_gpio = default_tuner_gpio, 2168 .tuner_gpio = default_tuner_gpio,
2129 .def_i2c_bus = 1, 2169 .def_i2c_bus = 1,
2130 }, 2170 },
2171 /*
2172 * 1b80:e34c KWorld USB ATSC TV Stick UB435-Q V3
2173 * Empia EM2874B + LG DT3305 + NXP TDA18271HDC2
2174 */
2175 [EM2874_BOARD_KWORLD_UB435Q_V3] = {
2176 .name = "KWorld USB ATSC TV Stick UB435-Q V3",
2177 .tuner_type = TUNER_ABSENT,
2178 .has_dvb = 1,
2179 .tuner_gpio = kworld_ub435q_v3_digital,
2180 .def_i2c_bus = 1,
2181 .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
2182 EM28XX_I2C_FREQ_100_KHZ,
2183 .leds = kworld_ub435q_v3_leds,
2184 },
2185 [EM2874_BOARD_PCTV_HD_MINI_80E] = {
2186 .name = "Pinnacle PCTV HD Mini",
2187 .tuner_type = TUNER_ABSENT,
2188 .has_dvb = 1,
2189 .dvb_gpio = em2874_pctv_80e_digital,
2190 .decoder = EM28XX_NODECODER,
2191 .ir_codes = RC_MAP_PINNACLE_PCTV_HD,
2192 .leds = pctv_80e_leds,
2193 },
2131 /* 1ae7:9003/9004 SpeedLink Vicious And Devine Laplace webcam 2194 /* 1ae7:9003/9004 SpeedLink Vicious And Devine Laplace webcam
2132 * Empia EM2765 + OmniVision OV2640 */ 2195 * Empia EM2765 + OmniVision OV2640 */
2133 [EM2765_BOARD_SPEEDLINK_VAD_LAPLACE] = { 2196 [EM2765_BOARD_SPEEDLINK_VAD_LAPLACE] = {
@@ -2290,6 +2353,8 @@ struct usb_device_id em28xx_id_table[] = {
2290 .driver_info = EM2882_BOARD_PINNACLE_HYBRID_PRO_330E }, 2353 .driver_info = EM2882_BOARD_PINNACLE_HYBRID_PRO_330E },
2291 { USB_DEVICE(0x2304, 0x0227), 2354 { USB_DEVICE(0x2304, 0x0227),
2292 .driver_info = EM2880_BOARD_PINNACLE_PCTV_HD_PRO }, 2355 .driver_info = EM2880_BOARD_PINNACLE_PCTV_HD_PRO },
2356 { USB_DEVICE(0x2304, 0x023f),
2357 .driver_info = EM2874_BOARD_PCTV_HD_MINI_80E },
2293 { USB_DEVICE(0x0413, 0x6023), 2358 { USB_DEVICE(0x0413, 0x6023),
2294 .driver_info = EM2800_BOARD_LEADTEK_WINFAST_USBII }, 2359 .driver_info = EM2800_BOARD_LEADTEK_WINFAST_USBII },
2295 { USB_DEVICE(0x093b, 0xa003), 2360 { USB_DEVICE(0x093b, 0xa003),
@@ -2304,6 +2369,8 @@ struct usb_device_id em28xx_id_table[] = {
2304 .driver_info = EM2870_BOARD_KWORLD_A340 }, 2369 .driver_info = EM2870_BOARD_KWORLD_A340 },
2305 { USB_DEVICE(0x1b80, 0xe346), 2370 { USB_DEVICE(0x1b80, 0xe346),
2306 .driver_info = EM2874_BOARD_KWORLD_UB435Q_V2 }, 2371 .driver_info = EM2874_BOARD_KWORLD_UB435Q_V2 },
2372 { USB_DEVICE(0x1b80, 0xe34c),
2373 .driver_info = EM2874_BOARD_KWORLD_UB435Q_V3 },
2307 { USB_DEVICE(0x2013, 0x024f), 2374 { USB_DEVICE(0x2013, 0x024f),
2308 .driver_info = EM28174_BOARD_PCTV_290E }, 2375 .driver_info = EM28174_BOARD_PCTV_290E },
2309 { USB_DEVICE(0x2013, 0x024c), 2376 { USB_DEVICE(0x2013, 0x024c),
@@ -2872,7 +2939,7 @@ static void flush_request_modules(struct em28xx *dev)
2872 * unregisters the v4l2,i2c and usb devices 2939 * unregisters the v4l2,i2c and usb devices
2873 * called when the device gets disconnected or at module unload 2940 * called when the device gets disconnected or at module unload
2874*/ 2941*/
2875void em28xx_release_resources(struct em28xx *dev) 2942static void em28xx_release_resources(struct em28xx *dev)
2876{ 2943{
2877 /*FIXME: I2C IR should be disconnected */ 2944 /*FIXME: I2C IR should be disconnected */
2878 2945
@@ -2889,7 +2956,27 @@ void em28xx_release_resources(struct em28xx *dev)
2889 2956
2890 mutex_unlock(&dev->lock); 2957 mutex_unlock(&dev->lock);
2891}; 2958};
2892EXPORT_SYMBOL_GPL(em28xx_release_resources); 2959
2960/**
2961 * em28xx_free_device() - Free em28xx device
2962 *
2963 * @ref: struct kref for em28xx device
2964 *
2965 * This is called when all extensions and em28xx core unregisters a device
2966 */
2967void em28xx_free_device(struct kref *ref)
2968{
2969 struct em28xx *dev = kref_to_dev(ref);
2970
2971 em28xx_info("Freeing device\n");
2972
2973 if (!dev->disconnected)
2974 em28xx_release_resources(dev);
2975
2976 kfree(dev->alt_max_pkt_size_isoc);
2977 kfree(dev);
2978}
2979EXPORT_SYMBOL_GPL(em28xx_free_device);
2893 2980
2894/* 2981/*
2895 * em28xx_init_dev() 2982 * em28xx_init_dev()
@@ -3331,8 +3418,8 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3331 if (has_video) { 3418 if (has_video) {
3332 if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk)) 3419 if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk))
3333 dev->analog_xfer_bulk = 1; 3420 dev->analog_xfer_bulk = 1;
3334 em28xx_info("analog set to %s mode.\n", 3421 em28xx_info("analog set to %s mode.\n",
3335 dev->analog_xfer_bulk ? "bulk" : "isoc"); 3422 dev->analog_xfer_bulk ? "bulk" : "isoc");
3336 } 3423 }
3337 if (has_dvb) { 3424 if (has_dvb) {
3338 if (!dev->dvb_ep_isoc || (try_bulk && dev->dvb_ep_bulk)) 3425 if (!dev->dvb_ep_isoc || (try_bulk && dev->dvb_ep_bulk))
@@ -3342,6 +3429,8 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3342 dev->dvb_xfer_bulk ? "bulk" : "isoc"); 3429 dev->dvb_xfer_bulk ? "bulk" : "isoc");
3343 } 3430 }
3344 3431
3432 kref_init(&dev->ref);
3433
3345 request_modules(dev); 3434 request_modules(dev);
3346 3435
3347 /* Should be the last thing to do, to avoid newer udev's to 3436 /* Should be the last thing to do, to avoid newer udev's to
@@ -3386,17 +3475,39 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
3386 em28xx_close_extension(dev); 3475 em28xx_close_extension(dev);
3387 3476
3388 em28xx_release_resources(dev); 3477 em28xx_release_resources(dev);
3478 kref_put(&dev->ref, em28xx_free_device);
3479}
3389 3480
3390 if (!dev->users) { 3481static int em28xx_usb_suspend(struct usb_interface *interface,
3391 kfree(dev->alt_max_pkt_size_isoc); 3482 pm_message_t message)
3392 kfree(dev); 3483{
3393 } 3484 struct em28xx *dev;
3485
3486 dev = usb_get_intfdata(interface);
3487 if (!dev)
3488 return 0;
3489 em28xx_suspend_extension(dev);
3490 return 0;
3491}
3492
3493static int em28xx_usb_resume(struct usb_interface *interface)
3494{
3495 struct em28xx *dev;
3496
3497 dev = usb_get_intfdata(interface);
3498 if (!dev)
3499 return 0;
3500 em28xx_resume_extension(dev);
3501 return 0;
3394} 3502}
3395 3503
3396static struct usb_driver em28xx_usb_driver = { 3504static struct usb_driver em28xx_usb_driver = {
3397 .name = "em28xx", 3505 .name = "em28xx",
3398 .probe = em28xx_usb_probe, 3506 .probe = em28xx_usb_probe,
3399 .disconnect = em28xx_usb_disconnect, 3507 .disconnect = em28xx_usb_disconnect,
3508 .suspend = em28xx_usb_suspend,
3509 .resume = em28xx_usb_resume,
3510 .reset_resume = em28xx_usb_resume,
3400 .id_table = em28xx_id_table, 3511 .id_table = em28xx_id_table,
3401}; 3512};
3402 3513
diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c
index 898fb9bd88a2..523d7e92bf47 100644
--- a/drivers/media/usb/em28xx/em28xx-core.c
+++ b/drivers/media/usb/em28xx/em28xx-core.c
@@ -619,6 +619,7 @@ EXPORT_SYMBOL_GPL(em28xx_find_led);
619int em28xx_capture_start(struct em28xx *dev, int start) 619int em28xx_capture_start(struct em28xx *dev, int start)
620{ 620{
621 int rc; 621 int rc;
622 const struct em28xx_led *led = NULL;
622 623
623 if (dev->chip_id == CHIP_ID_EM2874 || 624 if (dev->chip_id == CHIP_ID_EM2874 ||
624 dev->chip_id == CHIP_ID_EM2884 || 625 dev->chip_id == CHIP_ID_EM2884 ||
@@ -643,6 +644,8 @@ int em28xx_capture_start(struct em28xx *dev, int start)
643 644
644 /* Enable video capture */ 645 /* Enable video capture */
645 rc = em28xx_write_reg(dev, 0x48, 0x00); 646 rc = em28xx_write_reg(dev, 0x48, 0x00);
647 if (rc < 0)
648 return rc;
646 649
647 if (dev->mode == EM28XX_ANALOG_MODE) 650 if (dev->mode == EM28XX_ANALOG_MODE)
648 rc = em28xx_write_reg(dev, 651 rc = em28xx_write_reg(dev,
@@ -650,6 +653,8 @@ int em28xx_capture_start(struct em28xx *dev, int start)
650 else 653 else
651 rc = em28xx_write_reg(dev, 654 rc = em28xx_write_reg(dev,
652 EM28XX_R12_VINENABLE, 0x37); 655 EM28XX_R12_VINENABLE, 0x37);
656 if (rc < 0)
657 return rc;
653 658
654 msleep(6); 659 msleep(6);
655 } else { 660 } else {
@@ -658,19 +663,16 @@ int em28xx_capture_start(struct em28xx *dev, int start)
658 } 663 }
659 } 664 }
660 665
661 if (rc < 0) 666 if (dev->mode == EM28XX_ANALOG_MODE)
662 return rc;
663
664 /* Switch (explicitly controlled) analog capturing LED on/off */
665 if (dev->mode == EM28XX_ANALOG_MODE) {
666 const struct em28xx_led *led;
667 led = em28xx_find_led(dev, EM28XX_LED_ANALOG_CAPTURING); 667 led = em28xx_find_led(dev, EM28XX_LED_ANALOG_CAPTURING);
668 if (led) 668 else
669 em28xx_write_reg_bits(dev, led->gpio_reg, 669 led = em28xx_find_led(dev, EM28XX_LED_DIGITAL_CAPTURING);
670 (!start ^ led->inverted) ? 670
671 ~led->gpio_mask : led->gpio_mask, 671 if (led)
672 led->gpio_mask); 672 em28xx_write_reg_bits(dev, led->gpio_reg,
673 } 673 (!start ^ led->inverted) ?
674 ~led->gpio_mask : led->gpio_mask,
675 led->gpio_mask);
674 676
675 return rc; 677 return rc;
676} 678}
@@ -1106,3 +1108,31 @@ void em28xx_close_extension(struct em28xx *dev)
1106 list_del(&dev->devlist); 1108 list_del(&dev->devlist);
1107 mutex_unlock(&em28xx_devlist_mutex); 1109 mutex_unlock(&em28xx_devlist_mutex);
1108} 1110}
1111
1112int em28xx_suspend_extension(struct em28xx *dev)
1113{
1114 const struct em28xx_ops *ops = NULL;
1115
1116 em28xx_info("Suspending extensions");
1117 mutex_lock(&em28xx_devlist_mutex);
1118 list_for_each_entry(ops, &em28xx_extension_devlist, next) {
1119 if (ops->suspend)
1120 ops->suspend(dev);
1121 }
1122 mutex_unlock(&em28xx_devlist_mutex);
1123 return 0;
1124}
1125
1126int em28xx_resume_extension(struct em28xx *dev)
1127{
1128 const struct em28xx_ops *ops = NULL;
1129
1130 em28xx_info("Resuming extensions");
1131 mutex_lock(&em28xx_devlist_mutex);
1132 list_for_each_entry(ops, &em28xx_extension_devlist, next) {
1133 if (ops->resume)
1134 ops->resume(dev);
1135 }
1136 mutex_unlock(&em28xx_devlist_mutex);
1137 return 0;
1138}
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index a0a669e81362..f599b18ef7ca 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -41,6 +41,7 @@
41#include "mt352.h" 41#include "mt352.h"
42#include "mt352_priv.h" /* FIXME */ 42#include "mt352_priv.h" /* FIXME */
43#include "tda1002x.h" 43#include "tda1002x.h"
44#include "drx39xyj/drx39xxj.h"
44#include "tda18271.h" 45#include "tda18271.h"
45#include "s921.h" 46#include "s921.h"
46#include "drxd.h" 47#include "drxd.h"
@@ -48,6 +49,7 @@
48#include "tda18271c2dd.h" 49#include "tda18271c2dd.h"
49#include "drxk.h" 50#include "drxk.h"
50#include "tda10071.h" 51#include "tda10071.h"
52#include "tda18212.h"
51#include "a8293.h" 53#include "a8293.h"
52#include "qt1010.h" 54#include "qt1010.h"
53#include "mb86a20s.h" 55#include "mb86a20s.h"
@@ -161,6 +163,8 @@ static inline int em28xx_dvb_urb_data_copy(struct em28xx *dev, struct urb *urb)
161 if (urb->status != -EPROTO) 163 if (urb->status != -EPROTO)
162 continue; 164 continue;
163 } 165 }
166 if (!urb->actual_length)
167 continue;
164 dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer, 168 dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer,
165 urb->actual_length); 169 urb->actual_length);
166 } else { 170 } else {
@@ -170,6 +174,8 @@ static inline int em28xx_dvb_urb_data_copy(struct em28xx *dev, struct urb *urb)
170 if (urb->iso_frame_desc[i].status != -EPROTO) 174 if (urb->iso_frame_desc[i].status != -EPROTO)
171 continue; 175 continue;
172 } 176 }
177 if (!urb->iso_frame_desc[i].actual_length)
178 continue;
173 dvb_dmx_swfilter(&dev->dvb->demux, 179 dvb_dmx_swfilter(&dev->dvb->demux,
174 urb->transfer_buffer + 180 urb->transfer_buffer +
175 urb->iso_frame_desc[i].offset, 181 urb->iso_frame_desc[i].offset,
@@ -208,10 +214,10 @@ static int em28xx_start_streaming(struct em28xx_dvb *dvb)
208 if (rc < 0) 214 if (rc < 0)
209 return rc; 215 return rc;
210 216
211 dprintk(1, "Using %d buffers each with %d x %d bytes\n", 217 dprintk(1, "Using %d buffers each with %d x %d bytes, alternate %d\n",
212 EM28XX_DVB_NUM_BUFS, 218 EM28XX_DVB_NUM_BUFS,
213 packet_multiplier, 219 packet_multiplier,
214 dvb_max_packet_size); 220 dvb_max_packet_size, dvb_alt);
215 221
216 return em28xx_init_usb_xfer(dev, EM28XX_DIGITAL_MODE, 222 return em28xx_init_usb_xfer(dev, EM28XX_DIGITAL_MODE,
217 dev->dvb_xfer_bulk, 223 dev->dvb_xfer_bulk,
@@ -315,6 +321,18 @@ static struct lgdt3305_config em2874_lgdt3305_dev = {
315 .qam_if_khz = 4000, 321 .qam_if_khz = 4000,
316}; 322};
317 323
324static struct lgdt3305_config em2874_lgdt3305_nogate_dev = {
325 .i2c_addr = 0x0e,
326 .demod_chip = LGDT3305,
327 .spectral_inversion = 1,
328 .deny_i2c_rptr = 1,
329 .mpeg_mode = LGDT3305_MPEG_SERIAL,
330 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
331 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
332 .vsb_if_khz = 3600,
333 .qam_if_khz = 3600,
334};
335
318static struct s921_config sharp_isdbt = { 336static struct s921_config sharp_isdbt = {
319 .demod_address = 0x30 >> 1 337 .demod_address = 0x30 >> 1
320}; 338};
@@ -351,6 +369,12 @@ static struct tda18271_config kworld_ub435q_v2_config = {
351 .gate = TDA18271_GATE_DIGITAL, 369 .gate = TDA18271_GATE_DIGITAL,
352}; 370};
353 371
372static struct tda18212_config kworld_ub435q_v3_config = {
373 .i2c_address = 0x60,
374 .if_atsc_vsb = 3600,
375 .if_atsc_qam = 3600,
376};
377
354static struct zl10353_config em28xx_zl10353_xc3028_no_i2c_gate = { 378static struct zl10353_config em28xx_zl10353_xc3028_no_i2c_gate = {
355 .demod_address = (0x1e >> 1), 379 .demod_address = (0x1e >> 1),
356 .no_tuner = 1, 380 .no_tuner = 1,
@@ -693,7 +717,8 @@ static void pctv_520e_init(struct em28xx *dev)
693static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe) 717static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe)
694{ 718{
695 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 719 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
696 struct em28xx *dev = fe->dvb->priv; 720 struct em28xx_i2c_bus *i2c_bus = fe->dvb->priv;
721 struct em28xx *dev = i2c_bus->dev;
697#ifdef CONFIG_GPIOLIB 722#ifdef CONFIG_GPIOLIB
698 struct em28xx_dvb *dvb = dev->dvb; 723 struct em28xx_dvb *dvb = dev->dvb;
699 int ret; 724 int ret;
@@ -817,6 +842,20 @@ static const struct m88ds3103_config pctv_461e_m88ds3103_config = {
817 .agc = 0x99, 842 .agc = 0x99,
818}; 843};
819 844
845
846static struct tda18271_std_map drx_j_std_map = {
847 .atsc_6 = { .if_freq = 5000, .agc_mode = 3, .std = 0, .if_lvl = 1,
848 .rfagc_top = 0x37, },
849 .qam_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3, .if_lvl = 1,
850 .rfagc_top = 0x37, },
851};
852
853static struct tda18271_config pinnacle_80e_dvb_config = {
854 .std_map = &drx_j_std_map,
855 .gate = TDA18271_GATE_DIGITAL,
856 .role = TDA18271_MASTER,
857};
858
820/* ------------------------------------------------------------------ */ 859/* ------------------------------------------------------------------ */
821 860
822static int em28xx_attach_xc3028(u8 addr, struct em28xx *dev) 861static int em28xx_attach_xc3028(u8 addr, struct em28xx *dev)
@@ -1005,7 +1044,6 @@ static int em28xx_dvb_init(struct em28xx *dev)
1005 em28xx_info("Binding DVB extension\n"); 1044 em28xx_info("Binding DVB extension\n");
1006 1045
1007 dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL); 1046 dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL);
1008
1009 if (dvb == NULL) { 1047 if (dvb == NULL) {
1010 em28xx_info("em28xx_dvb: memory allocation failed\n"); 1048 em28xx_info("em28xx_dvb: memory allocation failed\n");
1011 return -ENOMEM; 1049 return -ENOMEM;
@@ -1370,10 +1408,40 @@ static int em28xx_dvb_init(struct em28xx *dev)
1370 goto out_free; 1408 goto out_free;
1371 } 1409 }
1372 break; 1410 break;
1411 case EM2874_BOARD_KWORLD_UB435Q_V3:
1412 dvb->fe[0] = dvb_attach(lgdt3305_attach,
1413 &em2874_lgdt3305_nogate_dev,
1414 &dev->i2c_adap[dev->def_i2c_bus]);
1415 if (!dvb->fe[0]) {
1416 result = -EINVAL;
1417 goto out_free;
1418 }
1419
1420 /* Attach the demodulator. */
1421 if (!dvb_attach(tda18212_attach, dvb->fe[0],
1422 &dev->i2c_adap[dev->def_i2c_bus],
1423 &kworld_ub435q_v3_config)) {
1424 result = -EINVAL;
1425 goto out_free;
1426 }
1427 break;
1428 case EM2874_BOARD_PCTV_HD_MINI_80E:
1429 dvb->fe[0] = dvb_attach(drx39xxj_attach, &dev->i2c_adap[dev->def_i2c_bus]);
1430 if (dvb->fe[0] != NULL) {
1431 dvb->fe[0] = dvb_attach(tda18271_attach, dvb->fe[0], 0x60,
1432 &dev->i2c_adap[dev->def_i2c_bus],
1433 &pinnacle_80e_dvb_config);
1434 if (!dvb->fe[0]) {
1435 result = -EINVAL;
1436 goto out_free;
1437 }
1438 }
1439 break;
1373 case EM28178_BOARD_PCTV_461E: 1440 case EM28178_BOARD_PCTV_461E:
1374 { 1441 {
1375 /* demod I2C adapter */ 1442 /* demod I2C adapter */
1376 struct i2c_adapter *i2c_adapter; 1443 struct i2c_adapter *i2c_adapter;
1444 struct i2c_client *client;
1377 struct i2c_board_info info; 1445 struct i2c_board_info info;
1378 struct m88ts2022_config m88ts2022_config = { 1446 struct m88ts2022_config m88ts2022_config = {
1379 .clock = 27000000, 1447 .clock = 27000000,
@@ -1396,7 +1464,19 @@ static int em28xx_dvb_init(struct em28xx *dev)
1396 info.addr = 0x60; 1464 info.addr = 0x60;
1397 info.platform_data = &m88ts2022_config; 1465 info.platform_data = &m88ts2022_config;
1398 request_module("m88ts2022"); 1466 request_module("m88ts2022");
1399 dvb->i2c_client_tuner = i2c_new_device(i2c_adapter, &info); 1467 client = i2c_new_device(i2c_adapter, &info);
1468 if (client == NULL || client->dev.driver == NULL) {
1469 dvb_frontend_detach(dvb->fe[0]);
1470 result = -ENODEV;
1471 goto out_free;
1472 }
1473
1474 if (!try_module_get(client->dev.driver->owner)) {
1475 i2c_unregister_device(client);
1476 dvb_frontend_detach(dvb->fe[0]);
1477 result = -ENODEV;
1478 goto out_free;
1479 }
1400 1480
1401 /* delegate signal strength measurement to tuner */ 1481 /* delegate signal strength measurement to tuner */
1402 dvb->fe[0]->ops.read_signal_strength = 1482 dvb->fe[0]->ops.read_signal_strength =
@@ -1406,10 +1486,14 @@ static int em28xx_dvb_init(struct em28xx *dev)
1406 if (!dvb_attach(a8293_attach, dvb->fe[0], 1486 if (!dvb_attach(a8293_attach, dvb->fe[0],
1407 &dev->i2c_adap[dev->def_i2c_bus], 1487 &dev->i2c_adap[dev->def_i2c_bus],
1408 &em28xx_a8293_config)) { 1488 &em28xx_a8293_config)) {
1489 module_put(client->dev.driver->owner);
1490 i2c_unregister_device(client);
1409 dvb_frontend_detach(dvb->fe[0]); 1491 dvb_frontend_detach(dvb->fe[0]);
1410 result = -ENODEV; 1492 result = -ENODEV;
1411 goto out_free; 1493 goto out_free;
1412 } 1494 }
1495
1496 dvb->i2c_client_tuner = client;
1413 } 1497 }
1414 break; 1498 break;
1415 default: 1499 default:
@@ -1437,6 +1521,9 @@ static int em28xx_dvb_init(struct em28xx *dev)
1437 dvb->adapter.mfe_shared = mfe_shared; 1521 dvb->adapter.mfe_shared = mfe_shared;
1438 1522
1439 em28xx_info("DVB extension successfully initialized\n"); 1523 em28xx_info("DVB extension successfully initialized\n");
1524
1525 kref_get(&dev->ref);
1526
1440ret: 1527ret:
1441 em28xx_set_mode(dev, EM28XX_SUSPEND); 1528 em28xx_set_mode(dev, EM28XX_SUSPEND);
1442 mutex_unlock(&dev->lock); 1529 mutex_unlock(&dev->lock);
@@ -1457,6 +1544,9 @@ static inline void prevent_sleep(struct dvb_frontend_ops *ops)
1457 1544
1458static int em28xx_dvb_fini(struct em28xx *dev) 1545static int em28xx_dvb_fini(struct em28xx *dev)
1459{ 1546{
1547 struct em28xx_dvb *dvb;
1548 struct i2c_client *client;
1549
1460 if (dev->is_audio_only) { 1550 if (dev->is_audio_only) {
1461 /* Shouldn't initialize IR for this interface */ 1551 /* Shouldn't initialize IR for this interface */
1462 return 0; 1552 return 0;
@@ -1467,23 +1557,96 @@ static int em28xx_dvb_fini(struct em28xx *dev)
1467 return 0; 1557 return 0;
1468 } 1558 }
1469 1559
1560 if (!dev->dvb)
1561 return 0;
1562
1470 em28xx_info("Closing DVB extension"); 1563 em28xx_info("Closing DVB extension");
1471 1564
1565 dvb = dev->dvb;
1566 client = dvb->i2c_client_tuner;
1567
1568 em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE);
1569
1570 if (dev->disconnected) {
1571 /* We cannot tell the device to sleep
1572 * once it has been unplugged. */
1573 if (dvb->fe[0])
1574 prevent_sleep(&dvb->fe[0]->ops);
1575 if (dvb->fe[1])
1576 prevent_sleep(&dvb->fe[1]->ops);
1577 }
1578
1579 /* remove I2C tuner */
1580 if (client) {
1581 module_put(client->dev.driver->owner);
1582 i2c_unregister_device(client);
1583 }
1584
1585 em28xx_unregister_dvb(dvb);
1586 kfree(dvb);
1587 dev->dvb = NULL;
1588 kref_put(&dev->ref, em28xx_free_device);
1589
1590 return 0;
1591}
1592
1593static int em28xx_dvb_suspend(struct em28xx *dev)
1594{
1595 int ret = 0;
1596
1597 if (dev->is_audio_only)
1598 return 0;
1599
1600 if (!dev->board.has_dvb)
1601 return 0;
1602
1603 em28xx_info("Suspending DVB extension");
1472 if (dev->dvb) { 1604 if (dev->dvb) {
1473 struct em28xx_dvb *dvb = dev->dvb; 1605 struct em28xx_dvb *dvb = dev->dvb;
1474 1606
1475 em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE); 1607 if (dvb->fe[0]) {
1608 ret = dvb_frontend_suspend(dvb->fe[0]);
1609 em28xx_info("fe0 suspend %d", ret);
1610 }
1611 if (dvb->fe[1]) {
1612 dvb_frontend_suspend(dvb->fe[1]);
1613 em28xx_info("fe1 suspend %d", ret);
1614 }
1615 }
1616
1617 return 0;
1618}
1619
1620static int em28xx_dvb_resume(struct em28xx *dev)
1621{
1622 int ret = 0;
1476 1623
1477 if (dev->disconnected) { 1624 if (dev->is_audio_only)
1478 /* We cannot tell the device to sleep 1625 return 0;
1479 * once it has been unplugged. */ 1626
1480 if (dvb->fe[0]) 1627 if (!dev->board.has_dvb)
1481 prevent_sleep(&dvb->fe[0]->ops); 1628 return 0;
1482 if (dvb->fe[1]) 1629
1483 prevent_sleep(&dvb->fe[1]->ops); 1630 em28xx_info("Resuming DVB extension");
1631 if (dev->dvb) {
1632 struct em28xx_dvb *dvb = dev->dvb;
1633 struct i2c_client *client = dvb->i2c_client_tuner;
1634
1635 if (dvb->fe[0]) {
1636 ret = dvb_frontend_resume(dvb->fe[0]);
1637 em28xx_info("fe0 resume %d", ret);
1638 }
1639
1640 if (dvb->fe[1]) {
1641 ret = dvb_frontend_resume(dvb->fe[1]);
1642 em28xx_info("fe1 resume %d", ret);
1643 }
1644 /* remove I2C tuner */
1645 if (client) {
1646 module_put(client->dev.driver->owner);
1647 i2c_unregister_device(client);
1484 } 1648 }
1485 1649
1486 i2c_release_client(dvb->i2c_client_tuner);
1487 em28xx_unregister_dvb(dvb); 1650 em28xx_unregister_dvb(dvb);
1488 kfree(dvb); 1651 kfree(dvb);
1489 dev->dvb = NULL; 1652 dev->dvb = NULL;
@@ -1497,6 +1660,8 @@ static struct em28xx_ops dvb_ops = {
1497 .name = "Em28xx dvb Extension", 1660 .name = "Em28xx dvb Extension",
1498 .init = em28xx_dvb_init, 1661 .init = em28xx_dvb_init,
1499 .fini = em28xx_dvb_fini, 1662 .fini = em28xx_dvb_fini,
1663 .suspend = em28xx_dvb_suspend,
1664 .resume = em28xx_dvb_resume,
1500}; 1665};
1501 1666
1502static int __init em28xx_dvb_register(void) 1667static int __init em28xx_dvb_register(void)
diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c
index 7e1724076ac4..ba6433c3a643 100644
--- a/drivers/media/usb/em28xx/em28xx-i2c.c
+++ b/drivers/media/usb/em28xx/em28xx-i2c.c
@@ -81,7 +81,7 @@ static int em2800_i2c_send_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len)
81 return len; 81 return len;
82 if (ret == 0x94 + len - 1) { 82 if (ret == 0x94 + len - 1) {
83 if (i2c_debug == 1) 83 if (i2c_debug == 1)
84 em28xx_warn("R05 returned 0x%02x: I2C timeout", 84 em28xx_warn("R05 returned 0x%02x: I2C ACK error\n",
85 ret); 85 ret);
86 return -ENXIO; 86 return -ENXIO;
87 } 87 }
@@ -128,7 +128,7 @@ static int em2800_i2c_recv_bytes(struct em28xx *dev, u8 addr, u8 *buf, u16 len)
128 break; 128 break;
129 if (ret == 0x94 + len - 1) { 129 if (ret == 0x94 + len - 1) {
130 if (i2c_debug == 1) 130 if (i2c_debug == 1)
131 em28xx_warn("R05 returned 0x%02x: I2C timeout", 131 em28xx_warn("R05 returned 0x%02x: I2C ACK error\n",
132 ret); 132 ret);
133 return -ENXIO; 133 return -ENXIO;
134 } 134 }
@@ -210,7 +210,7 @@ static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf,
210 return len; 210 return len;
211 if (ret == 0x10) { 211 if (ret == 0x10) {
212 if (i2c_debug == 1) 212 if (i2c_debug == 1)
213 em28xx_warn("I2C transfer timeout on writing to addr 0x%02x", 213 em28xx_warn("I2C ACK error on writing to addr 0x%02x\n",
214 addr); 214 addr);
215 return -ENXIO; 215 return -ENXIO;
216 } 216 }
@@ -226,10 +226,18 @@ static int em28xx_i2c_send_bytes(struct em28xx *dev, u16 addr, u8 *buf,
226 * (even with high payload) ... 226 * (even with high payload) ...
227 */ 227 */
228 } 228 }
229 if (i2c_debug) 229
230 em28xx_warn("write to i2c device at 0x%x timed out (status=%i)\n", 230 if (ret == 0x02 || ret == 0x04) {
231 addr, ret); 231 /* NOTE: these errors seem to be related to clock stretching */
232 return -ETIMEDOUT; 232 if (i2c_debug)
233 em28xx_warn("write to i2c device at 0x%x timed out (status=%i)\n",
234 addr, ret);
235 return -ETIMEDOUT;
236 }
237
238 em28xx_warn("write to i2c device at 0x%x failed with unknown error (status=%i)\n",
239 addr, ret);
240 return -EIO;
233} 241}
234 242
235/* 243/*
@@ -274,13 +282,22 @@ static int em28xx_i2c_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf, u16 len)
274 } 282 }
275 if (ret == 0x10) { 283 if (ret == 0x10) {
276 if (i2c_debug == 1) 284 if (i2c_debug == 1)
277 em28xx_warn("I2C transfer timeout on writing to addr 0x%02x", 285 em28xx_warn("I2C ACK error on writing to addr 0x%02x\n",
278 addr); 286 addr);
279 return -ENXIO; 287 return -ENXIO;
280 } 288 }
281 289
282 em28xx_warn("unknown i2c error (status=%i)\n", ret); 290 if (ret == 0x02 || ret == 0x04) {
283 return -ETIMEDOUT; 291 /* NOTE: these errors seem to be related to clock stretching */
292 if (i2c_debug)
293 em28xx_warn("write to i2c device at 0x%x timed out (status=%i)\n",
294 addr, ret);
295 return -ETIMEDOUT;
296 }
297
298 em28xx_warn("write to i2c device at 0x%x failed with unknown error (status=%i)\n",
299 addr, ret);
300 return -EIO;
284} 301}
285 302
286/* 303/*
@@ -337,7 +354,7 @@ static int em25xx_bus_B_send_bytes(struct em28xx *dev, u16 addr, u8 *buf,
337 return len; 354 return len;
338 else if (ret > 0) { 355 else if (ret > 0) {
339 if (i2c_debug == 1) 356 if (i2c_debug == 1)
340 em28xx_warn("Bus B R08 returned 0x%02x: I2C timeout", 357 em28xx_warn("Bus B R08 returned 0x%02x: I2C ACK error\n",
341 ret); 358 ret);
342 return -ENXIO; 359 return -ENXIO;
343 } 360 }
@@ -392,7 +409,7 @@ static int em25xx_bus_B_recv_bytes(struct em28xx *dev, u16 addr, u8 *buf,
392 return len; 409 return len;
393 else if (ret > 0) { 410 else if (ret > 0) {
394 if (i2c_debug == 1) 411 if (i2c_debug == 1)
395 em28xx_warn("Bus B R08 returned 0x%02x: I2C timeout", 412 em28xx_warn("Bus B R08 returned 0x%02x: I2C ACK error\n",
396 ret); 413 ret);
397 return -ENXIO; 414 return -ENXIO;
398 } 415 }
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
index 18f65d89d4bc..56ef49df4f8d 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -676,6 +676,8 @@ static int em28xx_ir_init(struct em28xx *dev)
676 return 0; 676 return 0;
677 } 677 }
678 678
679 kref_get(&dev->ref);
680
679 if (dev->board.buttons) 681 if (dev->board.buttons)
680 em28xx_init_buttons(dev); 682 em28xx_init_buttons(dev);
681 683
@@ -725,7 +727,7 @@ static int em28xx_ir_init(struct em28xx *dev)
725 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2: 727 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
726 rc->map_name = RC_MAP_HAUPPAUGE; 728 rc->map_name = RC_MAP_HAUPPAUGE;
727 ir->get_key_i2c = em28xx_get_key_em_haup; 729 ir->get_key_i2c = em28xx_get_key_em_haup;
728 rc->allowed_protos = RC_BIT_RC5; 730 rc_set_allowed_protocols(rc, RC_BIT_RC5);
729 break; 731 break;
730 case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE: 732 case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE:
731 rc->map_name = RC_MAP_WINFAST_USBII_DELUXE; 733 rc->map_name = RC_MAP_WINFAST_USBII_DELUXE;
@@ -741,7 +743,7 @@ static int em28xx_ir_init(struct em28xx *dev)
741 switch (dev->chip_id) { 743 switch (dev->chip_id) {
742 case CHIP_ID_EM2860: 744 case CHIP_ID_EM2860:
743 case CHIP_ID_EM2883: 745 case CHIP_ID_EM2883:
744 rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC; 746 rc_set_allowed_protocols(rc, RC_BIT_RC5 | RC_BIT_NEC);
745 ir->get_key = default_polling_getkey; 747 ir->get_key = default_polling_getkey;
746 break; 748 break;
747 case CHIP_ID_EM2884: 749 case CHIP_ID_EM2884:
@@ -749,8 +751,8 @@ static int em28xx_ir_init(struct em28xx *dev)
749 case CHIP_ID_EM28174: 751 case CHIP_ID_EM28174:
750 case CHIP_ID_EM28178: 752 case CHIP_ID_EM28178:
751 ir->get_key = em2874_polling_getkey; 753 ir->get_key = em2874_polling_getkey;
752 rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC | 754 rc_set_allowed_protocols(rc, RC_BIT_RC5 | RC_BIT_NEC |
753 RC_BIT_RC6_0; 755 RC_BIT_RC6_0);
754 break; 756 break;
755 default: 757 default:
756 err = -ENODEV; 758 err = -ENODEV;
@@ -816,7 +818,7 @@ static int em28xx_ir_fini(struct em28xx *dev)
816 818
817 /* skip detach on non attached boards */ 819 /* skip detach on non attached boards */
818 if (!ir) 820 if (!ir)
819 return 0; 821 goto ref_put;
820 822
821 if (ir->rc) 823 if (ir->rc)
822 rc_unregister_device(ir->rc); 824 rc_unregister_device(ir->rc);
@@ -824,6 +826,45 @@ static int em28xx_ir_fini(struct em28xx *dev)
824 /* done */ 826 /* done */
825 kfree(ir); 827 kfree(ir);
826 dev->ir = NULL; 828 dev->ir = NULL;
829
830ref_put:
831 kref_put(&dev->ref, em28xx_free_device);
832
833 return 0;
834}
835
836static int em28xx_ir_suspend(struct em28xx *dev)
837{
838 struct em28xx_IR *ir = dev->ir;
839
840 if (dev->is_audio_only)
841 return 0;
842
843 em28xx_info("Suspending input extension");
844 if (ir)
845 cancel_delayed_work_sync(&ir->work);
846 cancel_delayed_work_sync(&dev->buttons_query_work);
847 /* is canceling delayed work sufficient or does the rc event
848 kthread needs stopping? kthread is stopped in
849 ir_raw_event_unregister() */
850 return 0;
851}
852
853static int em28xx_ir_resume(struct em28xx *dev)
854{
855 struct em28xx_IR *ir = dev->ir;
856
857 if (dev->is_audio_only)
858 return 0;
859
860 em28xx_info("Resuming input extension");
861 /* if suspend calls ir_raw_event_unregister(), the should call
862 ir_raw_event_register() */
863 if (ir)
864 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling));
865 if (dev->num_button_polling_addresses)
866 schedule_delayed_work(&dev->buttons_query_work,
867 msecs_to_jiffies(dev->button_polling_interval));
827 return 0; 868 return 0;
828} 869}
829 870
@@ -832,6 +873,8 @@ static struct em28xx_ops rc_ops = {
832 .name = "Em28xx Input Extension", 873 .name = "Em28xx Input Extension",
833 .init = em28xx_ir_init, 874 .init = em28xx_ir_init,
834 .fini = em28xx_ir_fini, 875 .fini = em28xx_ir_fini,
876 .suspend = em28xx_ir_suspend,
877 .resume = em28xx_ir_resume,
835}; 878};
836 879
837static int __init em28xx_rc_register(void) 880static int __init em28xx_rc_register(void)
@@ -845,7 +888,7 @@ static void __exit em28xx_rc_unregister(void)
845} 888}
846 889
847MODULE_LICENSE("GPL"); 890MODULE_LICENSE("GPL");
848MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 891MODULE_AUTHOR("Mauro Carvalho Chehab");
849MODULE_DESCRIPTION(DRIVER_DESC " - input interface"); 892MODULE_DESCRIPTION(DRIVER_DESC " - input interface");
850MODULE_VERSION(EM28XX_VERSION); 893MODULE_VERSION(EM28XX_VERSION);
851 894
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index c3c928937dcd..0856e5d367b6 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1029,7 +1029,7 @@ static int em28xx_vb2_setup(struct em28xx *dev)
1029 q = &dev->vb_vidq; 1029 q = &dev->vb_vidq;
1030 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1030 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1031 q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR | VB2_DMABUF; 1031 q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
1032 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1032 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1033 q->drv_priv = dev; 1033 q->drv_priv = dev;
1034 q->buf_struct_size = sizeof(struct em28xx_buffer); 1034 q->buf_struct_size = sizeof(struct em28xx_buffer);
1035 q->ops = &em28xx_video_qops; 1035 q->ops = &em28xx_video_qops;
@@ -1043,7 +1043,7 @@ static int em28xx_vb2_setup(struct em28xx *dev)
1043 q = &dev->vb_vbiq; 1043 q = &dev->vb_vbiq;
1044 q->type = V4L2_BUF_TYPE_VBI_CAPTURE; 1044 q->type = V4L2_BUF_TYPE_VBI_CAPTURE;
1045 q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR; 1045 q->io_modes = VB2_READ | VB2_MMAP | VB2_USERPTR;
1046 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1046 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1047 q->drv_priv = dev; 1047 q->drv_priv = dev;
1048 q->buf_struct_size = sizeof(struct em28xx_buffer); 1048 q->buf_struct_size = sizeof(struct em28xx_buffer);
1049 q->ops = &em28xx_vbi_qops; 1049 q->ops = &em28xx_vbi_qops;
@@ -1837,7 +1837,6 @@ static int em28xx_v4l2_open(struct file *filp)
1837 video_device_node_name(vdev), v4l2_type_names[fh_type], 1837 video_device_node_name(vdev), v4l2_type_names[fh_type],
1838 dev->users); 1838 dev->users);
1839 1839
1840
1841 if (mutex_lock_interruptible(&dev->lock)) 1840 if (mutex_lock_interruptible(&dev->lock))
1842 return -ERESTARTSYS; 1841 return -ERESTARTSYS;
1843 fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL); 1842 fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL);
@@ -1869,6 +1868,7 @@ static int em28xx_v4l2_open(struct file *filp)
1869 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_radio); 1868 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_radio);
1870 } 1869 }
1871 1870
1871 kref_get(&dev->ref);
1872 dev->users++; 1872 dev->users++;
1873 1873
1874 mutex_unlock(&dev->lock); 1874 mutex_unlock(&dev->lock);
@@ -1918,18 +1918,43 @@ static int em28xx_v4l2_fini(struct em28xx *dev)
1918 video_unregister_device(dev->vdev); 1918 video_unregister_device(dev->vdev);
1919 } 1919 }
1920 1920
1921 v4l2_ctrl_handler_free(&dev->ctrl_handler);
1922 v4l2_device_unregister(&dev->v4l2_dev);
1923
1921 if (dev->clk) { 1924 if (dev->clk) {
1922 v4l2_clk_unregister_fixed(dev->clk); 1925 v4l2_clk_unregister_fixed(dev->clk);
1923 dev->clk = NULL; 1926 dev->clk = NULL;
1924 } 1927 }
1925 1928
1926 v4l2_ctrl_handler_free(&dev->ctrl_handler);
1927 v4l2_device_unregister(&dev->v4l2_dev);
1928
1929 if (dev->users)
1930 em28xx_warn("Device is open ! Memory deallocation is deferred on last close.\n");
1931 mutex_unlock(&dev->lock); 1929 mutex_unlock(&dev->lock);
1930 kref_put(&dev->ref, em28xx_free_device);
1931
1932 return 0;
1933}
1934
1935static int em28xx_v4l2_suspend(struct em28xx *dev)
1936{
1937 if (dev->is_audio_only)
1938 return 0;
1932 1939
1940 if (!dev->has_video)
1941 return 0;
1942
1943 em28xx_info("Suspending video extension");
1944 em28xx_stop_urbs(dev);
1945 return 0;
1946}
1947
1948static int em28xx_v4l2_resume(struct em28xx *dev)
1949{
1950 if (dev->is_audio_only)
1951 return 0;
1952
1953 if (!dev->has_video)
1954 return 0;
1955
1956 em28xx_info("Resuming video extension");
1957 /* what do we do here */
1933 return 0; 1958 return 0;
1934} 1959}
1935 1960
@@ -1950,11 +1975,9 @@ static int em28xx_v4l2_close(struct file *filp)
1950 mutex_lock(&dev->lock); 1975 mutex_lock(&dev->lock);
1951 1976
1952 if (dev->users == 1) { 1977 if (dev->users == 1) {
1953 /* free the remaining resources if device is disconnected */ 1978 /* No sense to try to write to the device */
1954 if (dev->disconnected) { 1979 if (dev->disconnected)
1955 kfree(dev->alt_max_pkt_size_isoc);
1956 goto exit; 1980 goto exit;
1957 }
1958 1981
1959 /* Save some power by putting tuner to sleep */ 1982 /* Save some power by putting tuner to sleep */
1960 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0); 1983 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0);
@@ -1975,6 +1998,8 @@ static int em28xx_v4l2_close(struct file *filp)
1975exit: 1998exit:
1976 dev->users--; 1999 dev->users--;
1977 mutex_unlock(&dev->lock); 2000 mutex_unlock(&dev->lock);
2001 kref_put(&dev->ref, em28xx_free_device);
2002
1978 return 0; 2003 return 0;
1979} 2004}
1980 2005
@@ -2273,7 +2298,8 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2273 } 2298 }
2274 2299
2275 em28xx_tuner_setup(dev); 2300 em28xx_tuner_setup(dev);
2276 em28xx_init_camera(dev); 2301 if (dev->em28xx_sensor != EM28XX_NOSENSOR)
2302 em28xx_init_camera(dev);
2277 2303
2278 /* Configure audio */ 2304 /* Configure audio */
2279 ret = em28xx_audio_setup(dev); 2305 ret = em28xx_audio_setup(dev);
@@ -2488,6 +2514,8 @@ static int em28xx_v4l2_init(struct em28xx *dev)
2488 2514
2489 em28xx_info("V4L2 extension successfully initialized\n"); 2515 em28xx_info("V4L2 extension successfully initialized\n");
2490 2516
2517 kref_get(&dev->ref);
2518
2491 mutex_unlock(&dev->lock); 2519 mutex_unlock(&dev->lock);
2492 return 0; 2520 return 0;
2493 2521
@@ -2504,6 +2532,8 @@ static struct em28xx_ops v4l2_ops = {
2504 .name = "Em28xx v4l2 Extension", 2532 .name = "Em28xx v4l2 Extension",
2505 .init = em28xx_v4l2_init, 2533 .init = em28xx_v4l2_init,
2506 .fini = em28xx_v4l2_fini, 2534 .fini = em28xx_v4l2_fini,
2535 .suspend = em28xx_v4l2_suspend,
2536 .resume = em28xx_v4l2_resume,
2507}; 2537};
2508 2538
2509static int __init em28xx_video_register(void) 2539static int __init em28xx_video_register(void)
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index 32d8a4bb7961..2051fc9fb932 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -32,6 +32,7 @@
32#include <linux/workqueue.h> 32#include <linux/workqueue.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/kref.h>
35#include <linux/videodev2.h> 36#include <linux/videodev2.h>
36 37
37#include <media/videobuf2-vmalloc.h> 38#include <media/videobuf2-vmalloc.h>
@@ -104,6 +105,7 @@
104#define EM2882_BOARD_PINNACLE_HYBRID_PRO_330E 56 105#define EM2882_BOARD_PINNACLE_HYBRID_PRO_330E 56
105#define EM2883_BOARD_KWORLD_HYBRID_330U 57 106#define EM2883_BOARD_KWORLD_HYBRID_330U 57
106#define EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU 58 107#define EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU 58
108#define EM2874_BOARD_PCTV_HD_MINI_80E 59
107#define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 60 109#define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 60
108#define EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2 61 110#define EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2 61
109#define EM2820_BOARD_GADMEI_TVR200 62 111#define EM2820_BOARD_GADMEI_TVR200 62
@@ -137,6 +139,7 @@
137#define EM2874_BOARD_KWORLD_UB435Q_V2 90 139#define EM2874_BOARD_KWORLD_UB435Q_V2 90
138#define EM2765_BOARD_SPEEDLINK_VAD_LAPLACE 91 140#define EM2765_BOARD_SPEEDLINK_VAD_LAPLACE 91
139#define EM28178_BOARD_PCTV_461E 92 141#define EM28178_BOARD_PCTV_461E 92
142#define EM2874_BOARD_KWORLD_UB435Q_V3 93
140 143
141/* Limits minimum and default number of buffers */ 144/* Limits minimum and default number of buffers */
142#define EM28XX_MIN_BUF 4 145#define EM28XX_MIN_BUF 4
@@ -399,6 +402,7 @@ enum em28xx_adecoder {
399 402
400enum em28xx_led_role { 403enum em28xx_led_role {
401 EM28XX_LED_ANALOG_CAPTURING = 0, 404 EM28XX_LED_ANALOG_CAPTURING = 0,
405 EM28XX_LED_DIGITAL_CAPTURING,
402 EM28XX_LED_ILLUMINATION, 406 EM28XX_LED_ILLUMINATION,
403 EM28XX_NUM_LED_ROLES, /* must be the last */ 407 EM28XX_NUM_LED_ROLES, /* must be the last */
404}; 408};
@@ -533,9 +537,10 @@ struct em28xx_i2c_bus {
533 enum em28xx_i2c_algo_type algo_type; 537 enum em28xx_i2c_algo_type algo_type;
534}; 538};
535 539
536
537/* main device struct */ 540/* main device struct */
538struct em28xx { 541struct em28xx {
542 struct kref ref;
543
539 /* generic device properties */ 544 /* generic device properties */
540 char name[30]; /* name (including minor) of the device */ 545 char name[30]; /* name (including minor) of the device */
541 int model; /* index in the device_data struct */ 546 int model; /* index in the device_data struct */
@@ -707,12 +712,16 @@ struct em28xx {
707 struct em28xx_dvb *dvb; 712 struct em28xx_dvb *dvb;
708}; 713};
709 714
715#define kref_to_dev(d) container_of(d, struct em28xx, ref)
716
710struct em28xx_ops { 717struct em28xx_ops {
711 struct list_head next; 718 struct list_head next;
712 char *name; 719 char *name;
713 int id; 720 int id;
714 int (*init)(struct em28xx *); 721 int (*init)(struct em28xx *);
715 int (*fini)(struct em28xx *); 722 int (*fini)(struct em28xx *);
723 int (*suspend)(struct em28xx *);
724 int (*resume)(struct em28xx *);
716}; 725};
717 726
718/* Provided by em28xx-i2c.c */ 727/* Provided by em28xx-i2c.c */
@@ -758,13 +767,15 @@ int em28xx_register_extension(struct em28xx_ops *dev);
758void em28xx_unregister_extension(struct em28xx_ops *dev); 767void em28xx_unregister_extension(struct em28xx_ops *dev);
759void em28xx_init_extension(struct em28xx *dev); 768void em28xx_init_extension(struct em28xx *dev);
760void em28xx_close_extension(struct em28xx *dev); 769void em28xx_close_extension(struct em28xx *dev);
770int em28xx_suspend_extension(struct em28xx *dev);
771int em28xx_resume_extension(struct em28xx *dev);
761 772
762/* Provided by em28xx-cards.c */ 773/* Provided by em28xx-cards.c */
763extern struct em28xx_board em28xx_boards[]; 774extern struct em28xx_board em28xx_boards[];
764extern struct usb_device_id em28xx_id_table[]; 775extern struct usb_device_id em28xx_id_table[];
765int em28xx_tuner_callback(void *ptr, int component, int command, int arg); 776int em28xx_tuner_callback(void *ptr, int component, int command, int arg);
766void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl); 777void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl);
767void em28xx_release_resources(struct em28xx *dev); 778void em28xx_free_device(struct kref *ref);
768 779
769/* Provided by em28xx-camera.c */ 780/* Provided by em28xx-camera.c */
770int em28xx_detect_sensor(struct em28xx *dev); 781int em28xx_detect_sensor(struct em28xx *dev);
diff --git a/drivers/media/usb/gspca/kinect.c b/drivers/media/usb/gspca/kinect.c
index 3773a8a745df..081f05162809 100644
--- a/drivers/media/usb/gspca/kinect.c
+++ b/drivers/media/usb/gspca/kinect.c
@@ -155,10 +155,11 @@ static int send_cmd(struct gspca_dev *gspca_dev, uint16_t cmd, void *cmdbuf,
155 do { 155 do {
156 actual_len = kinect_read(udev, ibuf, 0x200); 156 actual_len = kinect_read(udev, ibuf, 0x200);
157 } while (actual_len == 0); 157 } while (actual_len == 0);
158 PDEBUG(D_USBO, "Control reply: %d", res); 158 PDEBUG(D_USBO, "Control reply: %d", actual_len);
159 if (actual_len < sizeof(*rhdr)) { 159 if (actual_len < sizeof(*rhdr)) {
160 pr_err("send_cmd: Input control transfer failed (%d)\n", res); 160 pr_err("send_cmd: Input control transfer failed (%d)\n",
161 return res; 161 actual_len);
162 return actual_len < 0 ? actual_len : -EREMOTEIO;
162 } 163 }
163 actual_len -= sizeof(*rhdr); 164 actual_len -= sizeof(*rhdr);
164 165
diff --git a/drivers/media/usb/gspca/sn9c20x.c b/drivers/media/usb/gspca/sn9c20x.c
index 2a38621cf718..41a9a892f79c 100644
--- a/drivers/media/usb/gspca/sn9c20x.c
+++ b/drivers/media/usb/gspca/sn9c20x.c
@@ -2359,6 +2359,7 @@ static const struct usb_device_id device_table[] = {
2359 {USB_DEVICE(0x045e, 0x00f4), SN9C20X(OV9650, 0x30, 0)}, 2359 {USB_DEVICE(0x045e, 0x00f4), SN9C20X(OV9650, 0x30, 0)},
2360 {USB_DEVICE(0x145f, 0x013d), SN9C20X(OV7660, 0x21, 0)}, 2360 {USB_DEVICE(0x145f, 0x013d), SN9C20X(OV7660, 0x21, 0)},
2361 {USB_DEVICE(0x0458, 0x7029), SN9C20X(HV7131R, 0x11, 0)}, 2361 {USB_DEVICE(0x0458, 0x7029), SN9C20X(HV7131R, 0x11, 0)},
2362 {USB_DEVICE(0x0458, 0x7045), SN9C20X(MT9M112, 0x5d, LED_REVERSE)},
2362 {USB_DEVICE(0x0458, 0x704a), SN9C20X(MT9M112, 0x5d, 0)}, 2363 {USB_DEVICE(0x0458, 0x704a), SN9C20X(MT9M112, 0x5d, 0)},
2363 {USB_DEVICE(0x0458, 0x704c), SN9C20X(MT9M112, 0x5d, 0)}, 2364 {USB_DEVICE(0x0458, 0x704c), SN9C20X(MT9M112, 0x5d, 0)},
2364 {USB_DEVICE(0xa168, 0x0610), SN9C20X(HV7131R, 0x11, 0)}, 2365 {USB_DEVICE(0xa168, 0x0610), SN9C20X(HV7131R, 0x11, 0)},
diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c b/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c
index bf3e5c317a26..e60cbb3aa609 100644
--- a/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c
+++ b/drivers/media/usb/gspca/stv06xx/stv06xx_vv6410.c
@@ -178,7 +178,7 @@ static int vv6410_stop(struct sd *sd)
178 178
179 PDEBUG(D_STREAM, "Halting stream"); 179 PDEBUG(D_STREAM, "Halting stream");
180 180
181 return (err < 0) ? err : 0; 181 return 0;
182} 182}
183 183
184static int vv6410_dump(struct sd *sd) 184static int vv6410_dump(struct sd *sd)
diff --git a/drivers/media/usb/gspca/topro.c b/drivers/media/usb/gspca/topro.c
index 640c2fe760b3..5fcd1eec2004 100644
--- a/drivers/media/usb/gspca/topro.c
+++ b/drivers/media/usb/gspca/topro.c
@@ -4631,8 +4631,16 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
4631 } 4631 }
4632 data++; 4632 data++;
4633 len--; 4633 len--;
4634 if (len < 2) {
4635 gspca_dev->last_packet_type = DISCARD_PACKET;
4636 return;
4637 }
4634 if (*data == 0xff && data[1] == 0xd8) { 4638 if (*data == 0xff && data[1] == 0xd8) {
4635/*fixme: there may be information in the 4 high bits*/ 4639/*fixme: there may be information in the 4 high bits*/
4640 if (len < 7) {
4641 gspca_dev->last_packet_type = DISCARD_PACKET;
4642 return;
4643 }
4636 if ((data[6] & 0x0f) != sd->quality) 4644 if ((data[6] & 0x0f) != sd->quality)
4637 set_dqt(gspca_dev, data[6] & 0x0f); 4645 set_dqt(gspca_dev, data[6] & 0x0f);
4638 gspca_frame_add(gspca_dev, FIRST_PACKET, 4646 gspca_frame_add(gspca_dev, FIRST_PACKET,
@@ -4672,7 +4680,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
4672 gspca_dev->last_packet_type = DISCARD_PACKET; 4680 gspca_dev->last_packet_type = DISCARD_PACKET;
4673 break; 4681 break;
4674 case 0xcc: 4682 case 0xcc:
4675 if (data[1] != 0xff || data[2] != 0xd8) 4683 if (len >= 3 && (data[1] != 0xff || data[2] != 0xd8))
4676 gspca_frame_add(gspca_dev, INTER_PACKET, 4684 gspca_frame_add(gspca_dev, INTER_PACKET,
4677 data + 1, len - 1); 4685 data + 1, len - 1);
4678 else 4686 else
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index abf365ab025d..84a6720b1d00 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -614,17 +614,20 @@ static int buffer_prepare(struct vb2_buffer *vb)
614 return 0; 614 return 0;
615} 615}
616 616
617static int buffer_finish(struct vb2_buffer *vb) 617static void buffer_finish(struct vb2_buffer *vb)
618{ 618{
619 struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue); 619 struct pwc_device *pdev = vb2_get_drv_priv(vb->vb2_queue);
620 struct pwc_frame_buf *buf = container_of(vb, struct pwc_frame_buf, vb); 620 struct pwc_frame_buf *buf = container_of(vb, struct pwc_frame_buf, vb);
621 621
622 /* 622 if (vb->state == VB2_BUF_STATE_DONE) {
623 * Application has called dqbuf and is getting back a buffer we've 623 /*
624 * filled, take the pwc data we've stored in buf->data and decompress 624 * Application has called dqbuf and is getting back a buffer
625 * it into a usable format, storing the result in the vb2_buffer 625 * we've filled, take the pwc data we've stored in buf->data
626 */ 626 * and decompress it into a usable format, storing the result
627 return pwc_decompress(pdev, buf); 627 * in the vb2_buffer.
628 */
629 pwc_decompress(pdev, buf);
630 }
628} 631}
629 632
630static void buffer_cleanup(struct vb2_buffer *vb) 633static void buffer_cleanup(struct vb2_buffer *vb)
@@ -1001,7 +1004,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1001 pdev->vb_queue.buf_struct_size = sizeof(struct pwc_frame_buf); 1004 pdev->vb_queue.buf_struct_size = sizeof(struct pwc_frame_buf);
1002 pdev->vb_queue.ops = &pwc_vb_queue_ops; 1005 pdev->vb_queue.ops = &pwc_vb_queue_ops;
1003 pdev->vb_queue.mem_ops = &vb2_vmalloc_memops; 1006 pdev->vb_queue.mem_ops = &vb2_vmalloc_memops;
1004 pdev->vb_queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1007 pdev->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1005 rc = vb2_queue_init(&pdev->vb_queue); 1008 rc = vb2_queue_init(&pdev->vb_queue);
1006 if (rc < 0) { 1009 if (rc < 0) {
1007 PWC_ERROR("Oops, could not initialize vb2 queue.\n"); 1010 PWC_ERROR("Oops, could not initialize vb2 queue.\n");
diff --git a/drivers/media/usb/s2255/Kconfig b/drivers/media/usb/s2255/Kconfig
index 7e8ee1f864ab..8c3fceef9a09 100644
--- a/drivers/media/usb/s2255/Kconfig
+++ b/drivers/media/usb/s2255/Kconfig
@@ -1,7 +1,7 @@
1config USB_S2255 1config USB_S2255
2 tristate "USB Sensoray 2255 video capture device" 2 tristate "USB Sensoray 2255 video capture device"
3 depends on VIDEO_V4L2 3 depends on VIDEO_V4L2
4 select VIDEOBUF_VMALLOC 4 select VIDEOBUF2_VMALLOC
5 default n 5 default n
6 help 6 help
7 Say Y here if you want support for the Sensoray 2255 USB device. 7 Say Y here if you want support for the Sensoray 2255 USB device.
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 6bc9b8e19e20..1d4ba2b80490 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * s2255drv.c - a driver for the Sensoray 2255 USB video capture device 2 * s2255drv.c - a driver for the Sensoray 2255 USB video capture device
3 * 3 *
4 * Copyright (C) 2007-2013 by Sensoray Company Inc. 4 * Copyright (C) 2007-2014 by Sensoray Company Inc.
5 * Dean Anderson 5 * Dean Anderson
6 * 6 *
7 * Some video buffer code based on vivi driver: 7 * Some video buffer code based on vivi driver:
@@ -45,14 +45,14 @@
45#include <linux/mm.h> 45#include <linux/mm.h>
46#include <linux/vmalloc.h> 46#include <linux/vmalloc.h>
47#include <linux/usb.h> 47#include <linux/usb.h>
48#include <media/videobuf-vmalloc.h> 48#include <media/videobuf2-vmalloc.h>
49#include <media/v4l2-common.h> 49#include <media/v4l2-common.h>
50#include <media/v4l2-device.h> 50#include <media/v4l2-device.h>
51#include <media/v4l2-ioctl.h> 51#include <media/v4l2-ioctl.h>
52#include <media/v4l2-ctrls.h> 52#include <media/v4l2-ctrls.h>
53#include <media/v4l2-event.h> 53#include <media/v4l2-event.h>
54 54
55#define S2255_VERSION "1.23.1" 55#define S2255_VERSION "1.25.1"
56#define FIRMWARE_FILE_NAME "f2255usb.bin" 56#define FIRMWARE_FILE_NAME "f2255usb.bin"
57 57
58/* default JPEG quality */ 58/* default JPEG quality */
@@ -69,7 +69,7 @@
69#define S2255_DSP_BOOTTIME 800 69#define S2255_DSP_BOOTTIME 800
70/* maximum time to wait for firmware to load (ms) */ 70/* maximum time to wait for firmware to load (ms) */
71#define S2255_LOAD_TIMEOUT (5000 + S2255_DSP_BOOTTIME) 71#define S2255_LOAD_TIMEOUT (5000 + S2255_DSP_BOOTTIME)
72#define S2255_DEF_BUFS 16 72#define S2255_MIN_BUFS 2
73#define S2255_SETMODE_TIMEOUT 500 73#define S2255_SETMODE_TIMEOUT 500
74#define S2255_VIDSTATUS_TIMEOUT 350 74#define S2255_VIDSTATUS_TIMEOUT 350
75#define S2255_MARKER_FRAME cpu_to_le32(0x2255DA4AL) 75#define S2255_MARKER_FRAME cpu_to_le32(0x2255DA4AL)
@@ -178,11 +178,6 @@ struct s2255_bufferi {
178 DEF_FDEC, DEF_BRIGHT, DEF_CONTRAST, DEF_SATURATION, \ 178 DEF_FDEC, DEF_BRIGHT, DEF_CONTRAST, DEF_SATURATION, \
179 DEF_HUE, 0, DEF_USB_BLOCK, 0} 179 DEF_HUE, 0, DEF_USB_BLOCK, 0}
180 180
181struct s2255_dmaqueue {
182 struct list_head active;
183 struct s2255_dev *dev;
184};
185
186/* for firmware loading, fw_state */ 181/* for firmware loading, fw_state */
187#define S2255_FW_NOTLOADED 0 182#define S2255_FW_NOTLOADED 0
188#define S2255_FW_LOADED_DSPWAIT 1 183#define S2255_FW_LOADED_DSPWAIT 1
@@ -217,12 +212,14 @@ struct s2255_pipeinfo {
217struct s2255_fmt; /*forward declaration */ 212struct s2255_fmt; /*forward declaration */
218struct s2255_dev; 213struct s2255_dev;
219 214
220struct s2255_channel { 215/* 2255 video channel */
216struct s2255_vc {
217 struct s2255_dev *dev;
221 struct video_device vdev; 218 struct video_device vdev;
222 struct v4l2_ctrl_handler hdl; 219 struct v4l2_ctrl_handler hdl;
223 struct v4l2_ctrl *jpegqual_ctrl; 220 struct v4l2_ctrl *jpegqual_ctrl;
224 int resources; 221 int resources;
225 struct s2255_dmaqueue vidq; 222 struct list_head buf_list;
226 struct s2255_bufferi buffer; 223 struct s2255_bufferi buffer;
227 struct s2255_mode mode; 224 struct s2255_mode mode;
228 v4l2_std_id std; 225 v4l2_std_id std;
@@ -232,8 +229,6 @@ struct s2255_channel {
232 struct v4l2_captureparm cap_parm; 229 struct v4l2_captureparm cap_parm;
233 int cur_frame; 230 int cur_frame;
234 int last_frame; 231 int last_frame;
235
236 int b_acquire;
237 /* allocated image size */ 232 /* allocated image size */
238 unsigned long req_image_size; 233 unsigned long req_image_size;
239 /* received packet size */ 234 /* received packet size */
@@ -252,17 +247,22 @@ struct s2255_channel {
252 int vidstatus_ready; 247 int vidstatus_ready;
253 unsigned int width; 248 unsigned int width;
254 unsigned int height; 249 unsigned int height;
250 enum v4l2_field field;
255 const struct s2255_fmt *fmt; 251 const struct s2255_fmt *fmt;
256 int idx; /* channel number on device, 0-3 */ 252 int idx; /* channel number on device, 0-3 */
253 struct vb2_queue vb_vidq;
254 struct mutex vb_lock; /* streaming lock */
255 spinlock_t qlock;
257}; 256};
258 257
259 258
260struct s2255_dev { 259struct s2255_dev {
261 struct s2255_channel channel[MAX_CHANNELS]; 260 struct s2255_vc vc[MAX_CHANNELS];
262 struct v4l2_device v4l2_dev; 261 struct v4l2_device v4l2_dev;
263 atomic_t num_channels; 262 atomic_t num_channels;
264 int frames; 263 int frames;
265 struct mutex lock; /* channels[].vdev.lock */ 264 struct mutex lock; /* channels[].vdev.lock */
265 struct mutex cmdlock; /* protects cmdbuf */
266 struct usb_device *udev; 266 struct usb_device *udev;
267 struct usb_interface *interface; 267 struct usb_interface *interface;
268 u8 read_endpoint; 268 u8 read_endpoint;
@@ -272,10 +272,11 @@ struct s2255_dev {
272 u32 cc; /* current channel */ 272 u32 cc; /* current channel */
273 int frame_ready; 273 int frame_ready;
274 int chn_ready; 274 int chn_ready;
275 spinlock_t slock;
276 /* dsp firmware version (f2255usb.bin) */ 275 /* dsp firmware version (f2255usb.bin) */
277 int dsp_fw_ver; 276 int dsp_fw_ver;
278 u16 pid; /* product id */ 277 u16 pid; /* product id */
278#define S2255_CMDBUF_SIZE 512
279 __le32 *cmdbuf;
279}; 280};
280 281
281static inline struct s2255_dev *to_s2255_dev(struct v4l2_device *v4l2_dev) 282static inline struct s2255_dev *to_s2255_dev(struct v4l2_device *v4l2_dev)
@@ -292,19 +293,10 @@ struct s2255_fmt {
292/* buffer for one video frame */ 293/* buffer for one video frame */
293struct s2255_buffer { 294struct s2255_buffer {
294 /* common v4l buffer stuff -- must be first */ 295 /* common v4l buffer stuff -- must be first */
295 struct videobuf_buffer vb; 296 struct vb2_buffer vb;
296 const struct s2255_fmt *fmt; 297 struct list_head list;
297}; 298};
298 299
299struct s2255_fh {
300 /* this must be the first field in this struct */
301 struct v4l2_fh fh;
302 struct s2255_dev *dev;
303 struct videobuf_queue vb_vidq;
304 enum v4l2_buf_type type;
305 struct s2255_channel *channel;
306 int resources;
307};
308 300
309/* current cypress EEPROM firmware version */ 301/* current cypress EEPROM firmware version */
310#define S2255_CUR_USB_FWVER ((3 << 8) | 12) 302#define S2255_CUR_USB_FWVER ((3 << 8) | 12)
@@ -352,15 +344,14 @@ struct s2255_fh {
352static unsigned long G_chnmap[MAX_CHANNELS] = {3, 2, 1, 0}; 344static unsigned long G_chnmap[MAX_CHANNELS] = {3, 2, 1, 0};
353 345
354static int debug; 346static int debug;
355static int *s2255_debug = &debug;
356 347
357static int s2255_start_readpipe(struct s2255_dev *dev); 348static int s2255_start_readpipe(struct s2255_dev *dev);
358static void s2255_stop_readpipe(struct s2255_dev *dev); 349static void s2255_stop_readpipe(struct s2255_dev *dev);
359static int s2255_start_acquire(struct s2255_channel *channel); 350static int s2255_start_acquire(struct s2255_vc *vc);
360static int s2255_stop_acquire(struct s2255_channel *channel); 351static int s2255_stop_acquire(struct s2255_vc *vc);
361static void s2255_fillbuff(struct s2255_channel *chn, struct s2255_buffer *buf, 352static void s2255_fillbuff(struct s2255_vc *vc, struct s2255_buffer *buf,
362 int jpgsize); 353 int jpgsize);
363static int s2255_set_mode(struct s2255_channel *chan, struct s2255_mode *mode); 354static int s2255_set_mode(struct s2255_vc *vc, struct s2255_mode *mode);
364static int s2255_board_shutdown(struct s2255_dev *dev); 355static int s2255_board_shutdown(struct s2255_dev *dev);
365static void s2255_fwload_start(struct s2255_dev *dev, int reset); 356static void s2255_fwload_start(struct s2255_dev *dev, int reset);
366static void s2255_destroy(struct s2255_dev *dev); 357static void s2255_destroy(struct s2255_dev *dev);
@@ -373,19 +364,11 @@ static long s2255_vendor_req(struct s2255_dev *dev, unsigned char req,
373#define s2255_dev_err(dev, fmt, arg...) \ 364#define s2255_dev_err(dev, fmt, arg...) \
374 dev_err(dev, S2255_DRIVER_NAME " - " fmt, ##arg) 365 dev_err(dev, S2255_DRIVER_NAME " - " fmt, ##arg)
375 366
376#define dprintk(level, fmt, arg...) \ 367#define dprintk(dev, level, fmt, arg...) \
377 do { \ 368 v4l2_dbg(level, debug, &dev->v4l2_dev, fmt, ## arg)
378 if (*s2255_debug >= (level)) { \
379 printk(KERN_DEBUG S2255_DRIVER_NAME \
380 ": " fmt, ##arg); \
381 } \
382 } while (0)
383 369
384static struct usb_driver s2255_driver; 370static struct usb_driver s2255_driver;
385 371
386/* Declare static vars that will be used as parameters */
387static unsigned int vid_limit = 16; /* Video memory limit, in Mb */
388
389/* start video number */ 372/* start video number */
390static int video_nr = -1; /* /dev/videoN, -1 for autodetect */ 373static int video_nr = -1; /* /dev/videoN, -1 for autodetect */
391 374
@@ -394,8 +377,6 @@ static int jpeg_enable = 1;
394 377
395module_param(debug, int, 0644); 378module_param(debug, int, 0644);
396MODULE_PARM_DESC(debug, "Debug level(0-100) default 0"); 379MODULE_PARM_DESC(debug, "Debug level(0-100) default 0");
397module_param(vid_limit, int, 0644);
398MODULE_PARM_DESC(vid_limit, "video memory limit(Mb)");
399module_param(video_nr, int, 0644); 380module_param(video_nr, int, 0644);
400MODULE_PARM_DESC(video_nr, "start video minor(-1 default autodetect)"); 381MODULE_PARM_DESC(video_nr, "start video minor(-1 default autodetect)");
401module_param(jpeg_enable, int, 0644); 382module_param(jpeg_enable, int, 0644);
@@ -444,27 +425,27 @@ static const struct s2255_fmt formats[] = {
444 } 425 }
445}; 426};
446 427
447static int norm_maxw(struct s2255_channel *channel) 428static int norm_maxw(struct s2255_vc *vc)
448{ 429{
449 return (channel->std & V4L2_STD_525_60) ? 430 return (vc->std & V4L2_STD_525_60) ?
450 LINE_SZ_4CIFS_NTSC : LINE_SZ_4CIFS_PAL; 431 LINE_SZ_4CIFS_NTSC : LINE_SZ_4CIFS_PAL;
451} 432}
452 433
453static int norm_maxh(struct s2255_channel *channel) 434static int norm_maxh(struct s2255_vc *vc)
454{ 435{
455 return (channel->std & V4L2_STD_525_60) ? 436 return (vc->std & V4L2_STD_525_60) ?
456 (NUM_LINES_1CIFS_NTSC * 2) : (NUM_LINES_1CIFS_PAL * 2); 437 (NUM_LINES_1CIFS_NTSC * 2) : (NUM_LINES_1CIFS_PAL * 2);
457} 438}
458 439
459static int norm_minw(struct s2255_channel *channel) 440static int norm_minw(struct s2255_vc *vc)
460{ 441{
461 return (channel->std & V4L2_STD_525_60) ? 442 return (vc->std & V4L2_STD_525_60) ?
462 LINE_SZ_1CIFS_NTSC : LINE_SZ_1CIFS_PAL; 443 LINE_SZ_1CIFS_NTSC : LINE_SZ_1CIFS_PAL;
463} 444}
464 445
465static int norm_minh(struct s2255_channel *channel) 446static int norm_minh(struct s2255_vc *vc)
466{ 447{
467 return (channel->std & V4L2_STD_525_60) ? 448 return (vc->std & V4L2_STD_525_60) ?
468 (NUM_LINES_1CIFS_NTSC) : (NUM_LINES_1CIFS_PAL); 449 (NUM_LINES_1CIFS_NTSC) : (NUM_LINES_1CIFS_PAL);
469} 450}
470 451
@@ -498,7 +479,7 @@ static void planar422p_to_yuv_packed(const unsigned char *in,
498static void s2255_reset_dsppower(struct s2255_dev *dev) 479static void s2255_reset_dsppower(struct s2255_dev *dev)
499{ 480{
500 s2255_vendor_req(dev, 0x40, 0x0000, 0x0001, NULL, 0, 1); 481 s2255_vendor_req(dev, 0x40, 0x0000, 0x0001, NULL, 0, 1);
501 msleep(10); 482 msleep(20);
502 s2255_vendor_req(dev, 0x50, 0x0000, 0x0000, NULL, 0, 1); 483 s2255_vendor_req(dev, 0x50, 0x0000, 0x0000, NULL, 0, 1);
503 msleep(600); 484 msleep(600);
504 s2255_vendor_req(dev, 0x10, 0x0000, 0x0000, NULL, 0, 1); 485 s2255_vendor_req(dev, 0x10, 0x0000, 0x0000, NULL, 0, 1);
@@ -510,9 +491,8 @@ static void s2255_reset_dsppower(struct s2255_dev *dev)
510static void s2255_timer(unsigned long user_data) 491static void s2255_timer(unsigned long user_data)
511{ 492{
512 struct s2255_fw *data = (struct s2255_fw *)user_data; 493 struct s2255_fw *data = (struct s2255_fw *)user_data;
513 dprintk(100, "%s\n", __func__);
514 if (usb_submit_urb(data->fw_urb, GFP_ATOMIC) < 0) { 494 if (usb_submit_urb(data->fw_urb, GFP_ATOMIC) < 0) {
515 printk(KERN_ERR "s2255: can't submit urb\n"); 495 pr_err("s2255: can't submit urb\n");
516 atomic_set(&data->fw_state, S2255_FW_FAILED); 496 atomic_set(&data->fw_state, S2255_FW_FAILED);
517 /* wake up anything waiting for the firmware */ 497 /* wake up anything waiting for the firmware */
518 wake_up(&data->wait_fw); 498 wake_up(&data->wait_fw);
@@ -532,7 +512,6 @@ static void s2255_fwchunk_complete(struct urb *urb)
532 struct s2255_fw *data = urb->context; 512 struct s2255_fw *data = urb->context;
533 struct usb_device *udev = urb->dev; 513 struct usb_device *udev = urb->dev;
534 int len; 514 int len;
535 dprintk(100, "%s: udev %p urb %p", __func__, udev, urb);
536 if (urb->status) { 515 if (urb->status) {
537 dev_err(&udev->dev, "URB failed with status %d\n", urb->status); 516 dev_err(&udev->dev, "URB failed with status %d\n", urb->status);
538 atomic_set(&data->fw_state, S2255_FW_FAILED); 517 atomic_set(&data->fw_state, S2255_FW_FAILED);
@@ -559,9 +538,6 @@ static void s2255_fwchunk_complete(struct urb *urb)
559 if (len < CHUNK_SIZE) 538 if (len < CHUNK_SIZE)
560 memset(data->pfw_data, 0, CHUNK_SIZE); 539 memset(data->pfw_data, 0, CHUNK_SIZE);
561 540
562 dprintk(100, "completed len %d, loaded %d \n", len,
563 data->fw_loaded);
564
565 memcpy(data->pfw_data, 541 memcpy(data->pfw_data,
566 (char *) data->fw->data + data->fw_loaded, len); 542 (char *) data->fw->data + data->fw_loaded, len);
567 543
@@ -576,36 +552,32 @@ static void s2255_fwchunk_complete(struct urb *urb)
576 return; 552 return;
577 } 553 }
578 data->fw_loaded += len; 554 data->fw_loaded += len;
579 } else { 555 } else
580 atomic_set(&data->fw_state, S2255_FW_LOADED_DSPWAIT); 556 atomic_set(&data->fw_state, S2255_FW_LOADED_DSPWAIT);
581 dprintk(100, "%s: firmware upload complete\n", __func__);
582 }
583 return; 557 return;
584 558
585} 559}
586 560
587static int s2255_got_frame(struct s2255_channel *channel, int jpgsize) 561static int s2255_got_frame(struct s2255_vc *vc, int jpgsize)
588{ 562{
589 struct s2255_dmaqueue *dma_q = &channel->vidq;
590 struct s2255_buffer *buf; 563 struct s2255_buffer *buf;
591 struct s2255_dev *dev = to_s2255_dev(channel->vdev.v4l2_dev); 564 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
592 unsigned long flags = 0; 565 unsigned long flags = 0;
593 int rc = 0; 566 int rc = 0;
594 spin_lock_irqsave(&dev->slock, flags); 567 spin_lock_irqsave(&vc->qlock, flags);
595 if (list_empty(&dma_q->active)) { 568 if (list_empty(&vc->buf_list)) {
596 dprintk(1, "No active queue to serve\n"); 569 dprintk(dev, 1, "No active queue to serve\n");
597 rc = -1; 570 rc = -1;
598 goto unlock; 571 goto unlock;
599 } 572 }
600 buf = list_entry(dma_q->active.next, 573 buf = list_entry(vc->buf_list.next,
601 struct s2255_buffer, vb.queue); 574 struct s2255_buffer, list);
602 list_del(&buf->vb.queue); 575 list_del(&buf->list);
603 v4l2_get_timestamp(&buf->vb.ts); 576 v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp);
604 s2255_fillbuff(channel, buf, jpgsize); 577 s2255_fillbuff(vc, buf, jpgsize);
605 wake_up(&buf->vb.done); 578 dprintk(dev, 2, "%s: [buf] [%p]\n", __func__, buf);
606 dprintk(2, "%s: [buf/i] [%p/%d]\n", __func__, buf, buf->vb.i);
607unlock: 579unlock:
608 spin_unlock_irqrestore(&dev->slock, flags); 580 spin_unlock_irqrestore(&vc->qlock, flags);
609 return rc; 581 return rc;
610} 582}
611 583
@@ -615,9 +587,9 @@ static const struct s2255_fmt *format_by_fourcc(int fourcc)
615 for (i = 0; i < ARRAY_SIZE(formats); i++) { 587 for (i = 0; i < ARRAY_SIZE(formats); i++) {
616 if (-1 == formats[i].fourcc) 588 if (-1 == formats[i].fourcc)
617 continue; 589 continue;
618 if (!jpeg_enable && ((formats[i].fourcc == V4L2_PIX_FMT_JPEG) || 590 if (!jpeg_enable && ((formats[i].fourcc == V4L2_PIX_FMT_JPEG) ||
619 (formats[i].fourcc == V4L2_PIX_FMT_MJPEG))) 591 (formats[i].fourcc == V4L2_PIX_FMT_MJPEG)))
620 continue; 592 continue;
621 if (formats[i].fourcc == fourcc) 593 if (formats[i].fourcc == fourcc)
622 return formats + i; 594 return formats + i;
623 } 595 }
@@ -632,56 +604,56 @@ static const struct s2255_fmt *format_by_fourcc(int fourcc)
632 * http://v4l.videotechnology.com/ 604 * http://v4l.videotechnology.com/
633 * 605 *
634 */ 606 */
635static void s2255_fillbuff(struct s2255_channel *channel, 607static void s2255_fillbuff(struct s2255_vc *vc,
636 struct s2255_buffer *buf, int jpgsize) 608 struct s2255_buffer *buf, int jpgsize)
637{ 609{
638 int pos = 0; 610 int pos = 0;
639 const char *tmpbuf; 611 const char *tmpbuf;
640 char *vbuf = videobuf_to_vmalloc(&buf->vb); 612 char *vbuf = vb2_plane_vaddr(&buf->vb, 0);
641 unsigned long last_frame; 613 unsigned long last_frame;
614 struct s2255_dev *dev = vc->dev;
642 615
643 if (!vbuf) 616 if (!vbuf)
644 return; 617 return;
645 last_frame = channel->last_frame; 618 last_frame = vc->last_frame;
646 if (last_frame != -1) { 619 if (last_frame != -1) {
647 tmpbuf = 620 tmpbuf =
648 (const char *)channel->buffer.frame[last_frame].lpvbits; 621 (const char *)vc->buffer.frame[last_frame].lpvbits;
649 switch (buf->fmt->fourcc) { 622 switch (vc->fmt->fourcc) {
650 case V4L2_PIX_FMT_YUYV: 623 case V4L2_PIX_FMT_YUYV:
651 case V4L2_PIX_FMT_UYVY: 624 case V4L2_PIX_FMT_UYVY:
652 planar422p_to_yuv_packed((const unsigned char *)tmpbuf, 625 planar422p_to_yuv_packed((const unsigned char *)tmpbuf,
653 vbuf, buf->vb.width, 626 vbuf, vc->width,
654 buf->vb.height, 627 vc->height,
655 buf->fmt->fourcc); 628 vc->fmt->fourcc);
656 break; 629 break;
657 case V4L2_PIX_FMT_GREY: 630 case V4L2_PIX_FMT_GREY:
658 memcpy(vbuf, tmpbuf, buf->vb.width * buf->vb.height); 631 memcpy(vbuf, tmpbuf, vc->width * vc->height);
659 break; 632 break;
660 case V4L2_PIX_FMT_JPEG: 633 case V4L2_PIX_FMT_JPEG:
661 case V4L2_PIX_FMT_MJPEG: 634 case V4L2_PIX_FMT_MJPEG:
662 buf->vb.size = jpgsize; 635 buf->vb.v4l2_buf.length = jpgsize;
663 memcpy(vbuf, tmpbuf, buf->vb.size); 636 memcpy(vbuf, tmpbuf, jpgsize);
664 break; 637 break;
665 case V4L2_PIX_FMT_YUV422P: 638 case V4L2_PIX_FMT_YUV422P:
666 memcpy(vbuf, tmpbuf, 639 memcpy(vbuf, tmpbuf,
667 buf->vb.width * buf->vb.height * 2); 640 vc->width * vc->height * 2);
668 break; 641 break;
669 default: 642 default:
670 printk(KERN_DEBUG "s2255: unknown format?\n"); 643 pr_info("s2255: unknown format?\n");
671 } 644 }
672 channel->last_frame = -1; 645 vc->last_frame = -1;
673 } else { 646 } else {
674 printk(KERN_ERR "s2255: =======no frame\n"); 647 pr_err("s2255: =======no frame\n");
675 return; 648 return;
676
677 } 649 }
678 dprintk(2, "s2255fill at : Buffer 0x%08lx size= %d\n", 650 dprintk(dev, 2, "s2255fill at : Buffer 0x%08lx size= %d\n",
679 (unsigned long)vbuf, pos); 651 (unsigned long)vbuf, pos);
680 /* tell v4l buffer was filled */ 652 /* tell v4l buffer was filled */
681 653 buf->vb.v4l2_buf.field = vc->field;
682 buf->vb.field_count = channel->frame_count * 2; 654 buf->vb.v4l2_buf.sequence = vc->frame_count;
683 v4l2_get_timestamp(&buf->vb.ts); 655 v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp);
684 buf->vb.state = VIDEOBUF_DONE; 656 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE);
685} 657}
686 658
687 659
@@ -689,144 +661,82 @@ static void s2255_fillbuff(struct s2255_channel *channel,
689 Videobuf operations 661 Videobuf operations
690 ------------------------------------------------------------------*/ 662 ------------------------------------------------------------------*/
691 663
692static int buffer_setup(struct videobuf_queue *vq, unsigned int *count, 664static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
693 unsigned int *size) 665 unsigned int *nbuffers, unsigned int *nplanes,
666 unsigned int sizes[], void *alloc_ctxs[])
694{ 667{
695 struct s2255_fh *fh = vq->priv_data; 668 struct s2255_vc *vc = vb2_get_drv_priv(vq);
696 struct s2255_channel *channel = fh->channel; 669 if (*nbuffers < S2255_MIN_BUFS)
697 *size = channel->width * channel->height * (channel->fmt->depth >> 3); 670 *nbuffers = S2255_MIN_BUFS;
698 671 *nplanes = 1;
699 if (0 == *count) 672 sizes[0] = vc->width * vc->height * (vc->fmt->depth >> 3);
700 *count = S2255_DEF_BUFS;
701
702 if (*size * *count > vid_limit * 1024 * 1024)
703 *count = (vid_limit * 1024 * 1024) / *size;
704
705 return 0; 673 return 0;
706} 674}
707 675
708static void free_buffer(struct videobuf_queue *vq, struct s2255_buffer *buf) 676static int buffer_prepare(struct vb2_buffer *vb)
709{
710 dprintk(4, "%s\n", __func__);
711
712 videobuf_vmalloc_free(&buf->vb);
713 buf->vb.state = VIDEOBUF_NEEDS_INIT;
714}
715
716static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
717 enum v4l2_field field)
718{ 677{
719 struct s2255_fh *fh = vq->priv_data; 678 struct s2255_vc *vc = vb2_get_drv_priv(vb->vb2_queue);
720 struct s2255_channel *channel = fh->channel;
721 struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb); 679 struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb);
722 int rc; 680 int w = vc->width;
723 int w = channel->width; 681 int h = vc->height;
724 int h = channel->height; 682 unsigned long size;
725 dprintk(4, "%s, field=%d\n", __func__, field); 683
726 if (channel->fmt == NULL) 684 dprintk(vc->dev, 4, "%s\n", __func__);
685 if (vc->fmt == NULL)
727 return -EINVAL; 686 return -EINVAL;
728 687
729 if ((w < norm_minw(channel)) || 688 if ((w < norm_minw(vc)) ||
730 (w > norm_maxw(channel)) || 689 (w > norm_maxw(vc)) ||
731 (h < norm_minh(channel)) || 690 (h < norm_minh(vc)) ||
732 (h > norm_maxh(channel))) { 691 (h > norm_maxh(vc))) {
733 dprintk(4, "invalid buffer prepare\n"); 692 dprintk(vc->dev, 4, "invalid buffer prepare\n");
734 return -EINVAL; 693 return -EINVAL;
735 } 694 }
736 buf->vb.size = w * h * (channel->fmt->depth >> 3); 695 size = w * h * (vc->fmt->depth >> 3);
737 if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) { 696 if (vb2_plane_size(vb, 0) < size) {
738 dprintk(4, "invalid buffer prepare\n"); 697 dprintk(vc->dev, 4, "invalid buffer prepare\n");
739 return -EINVAL; 698 return -EINVAL;
740 } 699 }
741 700
742 buf->fmt = channel->fmt; 701 vb2_set_plane_payload(&buf->vb, 0, size);
743 buf->vb.width = w;
744 buf->vb.height = h;
745 buf->vb.field = field;
746
747 if (VIDEOBUF_NEEDS_INIT == buf->vb.state) {
748 rc = videobuf_iolock(vq, &buf->vb, NULL);
749 if (rc < 0)
750 goto fail;
751 }
752
753 buf->vb.state = VIDEOBUF_PREPARED;
754 return 0; 702 return 0;
755fail:
756 free_buffer(vq, buf);
757 return rc;
758} 703}
759 704
760static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) 705static void buffer_queue(struct vb2_buffer *vb)
761{ 706{
762 struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb); 707 struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb);
763 struct s2255_fh *fh = vq->priv_data; 708 struct s2255_vc *vc = vb2_get_drv_priv(vb->vb2_queue);
764 struct s2255_channel *channel = fh->channel; 709 unsigned long flags = 0;
765 struct s2255_dmaqueue *vidq = &channel->vidq; 710 dprintk(vc->dev, 1, "%s\n", __func__);
766 dprintk(1, "%s\n", __func__); 711 spin_lock_irqsave(&vc->qlock, flags);
767 buf->vb.state = VIDEOBUF_QUEUED; 712 list_add_tail(&buf->list, &vc->buf_list);
768 list_add_tail(&buf->vb.queue, &vidq->active); 713 spin_unlock_irqrestore(&vc->qlock, flags);
769} 714}
770 715
771static void buffer_release(struct videobuf_queue *vq, 716static int start_streaming(struct vb2_queue *vq, unsigned int count);
772 struct videobuf_buffer *vb) 717static int stop_streaming(struct vb2_queue *vq);
773{
774 struct s2255_buffer *buf = container_of(vb, struct s2255_buffer, vb);
775 struct s2255_fh *fh = vq->priv_data;
776 dprintk(4, "%s %d\n", __func__, fh->channel->idx);
777 free_buffer(vq, buf);
778}
779 718
780static struct videobuf_queue_ops s2255_video_qops = { 719static struct vb2_ops s2255_video_qops = {
781 .buf_setup = buffer_setup, 720 .queue_setup = queue_setup,
782 .buf_prepare = buffer_prepare, 721 .buf_prepare = buffer_prepare,
783 .buf_queue = buffer_queue, 722 .buf_queue = buffer_queue,
784 .buf_release = buffer_release, 723 .start_streaming = start_streaming,
724 .stop_streaming = stop_streaming,
725 .wait_prepare = vb2_ops_wait_prepare,
726 .wait_finish = vb2_ops_wait_finish,
785}; 727};
786 728
787
788static int res_get(struct s2255_fh *fh)
789{
790 struct s2255_channel *channel = fh->channel;
791 /* is it free? */
792 if (channel->resources)
793 return 0; /* no, someone else uses it */
794 /* it's free, grab it */
795 channel->resources = 1;
796 fh->resources = 1;
797 dprintk(1, "s2255: res: get\n");
798 return 1;
799}
800
801static int res_locked(struct s2255_fh *fh)
802{
803 return fh->channel->resources;
804}
805
806static int res_check(struct s2255_fh *fh)
807{
808 return fh->resources;
809}
810
811
812static void res_free(struct s2255_fh *fh)
813{
814 struct s2255_channel *channel = fh->channel;
815 channel->resources = 0;
816 fh->resources = 0;
817 dprintk(1, "res: put\n");
818}
819
820static int vidioc_querycap(struct file *file, void *priv, 729static int vidioc_querycap(struct file *file, void *priv,
821 struct v4l2_capability *cap) 730 struct v4l2_capability *cap)
822{ 731{
823 struct s2255_fh *fh = file->private_data; 732 struct s2255_vc *vc = video_drvdata(file);
824 struct s2255_dev *dev = fh->dev; 733 struct s2255_dev *dev = vc->dev;
825 734
826 strlcpy(cap->driver, "s2255", sizeof(cap->driver)); 735 strlcpy(cap->driver, "s2255", sizeof(cap->driver));
827 strlcpy(cap->card, "s2255", sizeof(cap->card)); 736 strlcpy(cap->card, "s2255", sizeof(cap->card));
828 usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); 737 usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info));
829 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; 738 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
739 V4L2_CAP_READWRITE;
830 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; 740 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
831 return 0; 741 return 0;
832} 742}
@@ -841,7 +751,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
841 if (!jpeg_enable && ((formats[index].fourcc == V4L2_PIX_FMT_JPEG) || 751 if (!jpeg_enable && ((formats[index].fourcc == V4L2_PIX_FMT_JPEG) ||
842 (formats[index].fourcc == V4L2_PIX_FMT_MJPEG))) 752 (formats[index].fourcc == V4L2_PIX_FMT_MJPEG)))
843 return -EINVAL; 753 return -EINVAL;
844 dprintk(4, "name %s\n", formats[index].name);
845 strlcpy(f->description, formats[index].name, sizeof(f->description)); 754 strlcpy(f->description, formats[index].name, sizeof(f->description));
846 f->pixelformat = formats[index].fourcc; 755 f->pixelformat = formats[index].fourcc;
847 return 0; 756 return 0;
@@ -850,19 +759,18 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
850static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, 759static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
851 struct v4l2_format *f) 760 struct v4l2_format *f)
852{ 761{
853 struct s2255_fh *fh = priv; 762 struct s2255_vc *vc = video_drvdata(file);
854 struct s2255_channel *channel = fh->channel; 763 int is_ntsc = vc->std & V4L2_STD_525_60;
855 int is_ntsc = channel->std & V4L2_STD_525_60;
856 764
857 f->fmt.pix.width = channel->width; 765 f->fmt.pix.width = vc->width;
858 f->fmt.pix.height = channel->height; 766 f->fmt.pix.height = vc->height;
859 if (f->fmt.pix.height >= 767 if (f->fmt.pix.height >=
860 (is_ntsc ? NUM_LINES_1CIFS_NTSC : NUM_LINES_1CIFS_PAL) * 2) 768 (is_ntsc ? NUM_LINES_1CIFS_NTSC : NUM_LINES_1CIFS_PAL) * 2)
861 f->fmt.pix.field = V4L2_FIELD_INTERLACED; 769 f->fmt.pix.field = V4L2_FIELD_INTERLACED;
862 else 770 else
863 f->fmt.pix.field = V4L2_FIELD_TOP; 771 f->fmt.pix.field = V4L2_FIELD_TOP;
864 f->fmt.pix.pixelformat = channel->fmt->fourcc; 772 f->fmt.pix.pixelformat = vc->fmt->fourcc;
865 f->fmt.pix.bytesperline = f->fmt.pix.width * (channel->fmt->depth >> 3); 773 f->fmt.pix.bytesperline = f->fmt.pix.width * (vc->fmt->depth >> 3);
866 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 774 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
867 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 775 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
868 f->fmt.pix.priv = 0; 776 f->fmt.pix.priv = 0;
@@ -874,9 +782,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
874{ 782{
875 const struct s2255_fmt *fmt; 783 const struct s2255_fmt *fmt;
876 enum v4l2_field field; 784 enum v4l2_field field;
877 struct s2255_fh *fh = priv; 785 struct s2255_vc *vc = video_drvdata(file);
878 struct s2255_channel *channel = fh->channel; 786 int is_ntsc = vc->std & V4L2_STD_525_60;
879 int is_ntsc = channel->std & V4L2_STD_525_60;
880 787
881 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 788 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
882 789
@@ -885,7 +792,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
885 792
886 field = f->fmt.pix.field; 793 field = f->fmt.pix.field;
887 794
888 dprintk(50, "%s NTSC: %d suggested width: %d, height: %d\n", 795 dprintk(vc->dev, 50, "%s NTSC: %d suggested width: %d, height: %d\n",
889 __func__, is_ntsc, f->fmt.pix.width, f->fmt.pix.height); 796 __func__, is_ntsc, f->fmt.pix.width, f->fmt.pix.height);
890 if (is_ntsc) { 797 if (is_ntsc) {
891 /* NTSC */ 798 /* NTSC */
@@ -927,7 +834,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
927 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 834 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
928 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 835 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
929 f->fmt.pix.priv = 0; 836 f->fmt.pix.priv = 0;
930 dprintk(50, "%s: set width %d height %d field %d\n", __func__, 837 dprintk(vc->dev, 50, "%s: set width %d height %d field %d\n", __func__,
931 f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); 838 f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field);
932 return 0; 839 return 0;
933} 840}
@@ -935,14 +842,13 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
935static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, 842static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
936 struct v4l2_format *f) 843 struct v4l2_format *f)
937{ 844{
938 struct s2255_fh *fh = priv; 845 struct s2255_vc *vc = video_drvdata(file);
939 struct s2255_channel *channel = fh->channel;
940 const struct s2255_fmt *fmt; 846 const struct s2255_fmt *fmt;
941 struct videobuf_queue *q = &fh->vb_vidq; 847 struct vb2_queue *q = &vc->vb_vidq;
942 struct s2255_mode mode; 848 struct s2255_mode mode;
943 int ret; 849 int ret;
944 850
945 ret = vidioc_try_fmt_vid_cap(file, fh, f); 851 ret = vidioc_try_fmt_vid_cap(file, vc, f);
946 852
947 if (ret < 0) 853 if (ret < 0)
948 return ret; 854 return ret;
@@ -952,28 +858,19 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
952 if (fmt == NULL) 858 if (fmt == NULL)
953 return -EINVAL; 859 return -EINVAL;
954 860
955 mutex_lock(&q->vb_lock); 861 if (vb2_is_busy(q)) {
956 862 dprintk(vc->dev, 1, "queue busy\n");
957 if (videobuf_queue_is_busy(&fh->vb_vidq)) { 863 return -EBUSY;
958 dprintk(1, "queue busy\n");
959 ret = -EBUSY;
960 goto out_s_fmt;
961 } 864 }
962 865
963 if (res_locked(fh)) { 866 mode = vc->mode;
964 dprintk(1, "%s: channel busy\n", __func__); 867 vc->fmt = fmt;
965 ret = -EBUSY; 868 vc->width = f->fmt.pix.width;
966 goto out_s_fmt; 869 vc->height = f->fmt.pix.height;
967 } 870 vc->field = f->fmt.pix.field;
968 mode = channel->mode; 871 if (vc->width > norm_minw(vc)) {
969 channel->fmt = fmt; 872 if (vc->height > norm_minh(vc)) {
970 channel->width = f->fmt.pix.width; 873 if (vc->cap_parm.capturemode &
971 channel->height = f->fmt.pix.height;
972 fh->vb_vidq.field = f->fmt.pix.field;
973 fh->type = f->type;
974 if (channel->width > norm_minw(channel)) {
975 if (channel->height > norm_minh(channel)) {
976 if (channel->cap_parm.capturemode &
977 V4L2_MODE_HIGHQUALITY) 874 V4L2_MODE_HIGHQUALITY)
978 mode.scale = SCALE_4CIFSI; 875 mode.scale = SCALE_4CIFSI;
979 else 876 else
@@ -985,7 +882,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
985 mode.scale = SCALE_1CIFS; 882 mode.scale = SCALE_1CIFS;
986 } 883 }
987 /* color mode */ 884 /* color mode */
988 switch (channel->fmt->fourcc) { 885 switch (vc->fmt->fourcc) {
989 case V4L2_PIX_FMT_GREY: 886 case V4L2_PIX_FMT_GREY:
990 mode.color &= ~MASK_COLOR; 887 mode.color &= ~MASK_COLOR;
991 mode.color |= COLOR_Y8; 888 mode.color |= COLOR_Y8;
@@ -994,7 +891,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
994 case V4L2_PIX_FMT_MJPEG: 891 case V4L2_PIX_FMT_MJPEG:
995 mode.color &= ~MASK_COLOR; 892 mode.color &= ~MASK_COLOR;
996 mode.color |= COLOR_JPG; 893 mode.color |= COLOR_JPG;
997 mode.color |= (channel->jpegqual << 8); 894 mode.color |= (vc->jpegqual << 8);
998 break; 895 break;
999 case V4L2_PIX_FMT_YUV422P: 896 case V4L2_PIX_FMT_YUV422P:
1000 mode.color &= ~MASK_COLOR; 897 mode.color &= ~MASK_COLOR;
@@ -1007,52 +904,17 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
1007 mode.color |= COLOR_YUVPK; 904 mode.color |= COLOR_YUVPK;
1008 break; 905 break;
1009 } 906 }
1010 if ((mode.color & MASK_COLOR) != (channel->mode.color & MASK_COLOR)) 907 if ((mode.color & MASK_COLOR) != (vc->mode.color & MASK_COLOR))
1011 mode.restart = 1; 908 mode.restart = 1;
1012 else if (mode.scale != channel->mode.scale) 909 else if (mode.scale != vc->mode.scale)
1013 mode.restart = 1; 910 mode.restart = 1;
1014 else if (mode.format != channel->mode.format) 911 else if (mode.format != vc->mode.format)
1015 mode.restart = 1; 912 mode.restart = 1;
1016 channel->mode = mode; 913 vc->mode = mode;
1017 (void) s2255_set_mode(channel, &mode); 914 (void) s2255_set_mode(vc, &mode);
1018 ret = 0; 915 return 0;
1019out_s_fmt:
1020 mutex_unlock(&q->vb_lock);
1021 return ret;
1022}
1023
1024static int vidioc_reqbufs(struct file *file, void *priv,
1025 struct v4l2_requestbuffers *p)
1026{
1027 int rc;
1028 struct s2255_fh *fh = priv;
1029 rc = videobuf_reqbufs(&fh->vb_vidq, p);
1030 return rc;
1031}
1032
1033static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *p)
1034{
1035 int rc;
1036 struct s2255_fh *fh = priv;
1037 rc = videobuf_querybuf(&fh->vb_vidq, p);
1038 return rc;
1039}
1040
1041static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p)
1042{
1043 int rc;
1044 struct s2255_fh *fh = priv;
1045 rc = videobuf_qbuf(&fh->vb_vidq, p);
1046 return rc;
1047} 916}
1048 917
1049static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
1050{
1051 int rc;
1052 struct s2255_fh *fh = priv;
1053 rc = videobuf_dqbuf(&fh->vb_vidq, p, file->f_flags & O_NONBLOCK);
1054 return rc;
1055}
1056 918
1057/* write to the configuration pipe, synchronously */ 919/* write to the configuration pipe, synchronously */
1058static int s2255_write_config(struct usb_device *udev, unsigned char *pbuf, 920static int s2255_write_config(struct usb_device *udev, unsigned char *pbuf,
@@ -1150,201 +1012,166 @@ static void s2255_print_cfg(struct s2255_dev *sdev, struct s2255_mode *mode)
1150 * When the restart parameter is set, we sleep for ONE frame to allow the 1012 * When the restart parameter is set, we sleep for ONE frame to allow the
1151 * DSP time to get the new frame 1013 * DSP time to get the new frame
1152 */ 1014 */
1153static int s2255_set_mode(struct s2255_channel *channel, 1015static int s2255_set_mode(struct s2255_vc *vc,
1154 struct s2255_mode *mode) 1016 struct s2255_mode *mode)
1155{ 1017{
1156 int res; 1018 int res;
1157 __le32 *buffer;
1158 unsigned long chn_rev; 1019 unsigned long chn_rev;
1159 struct s2255_dev *dev = to_s2255_dev(channel->vdev.v4l2_dev); 1020 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
1160 int i; 1021 int i;
1022 __le32 *buffer = dev->cmdbuf;
1161 1023
1162 chn_rev = G_chnmap[channel->idx]; 1024 mutex_lock(&dev->cmdlock);
1163 dprintk(3, "%s channel: %d\n", __func__, channel->idx); 1025 chn_rev = G_chnmap[vc->idx];
1026 dprintk(dev, 3, "%s channel: %d\n", __func__, vc->idx);
1164 /* if JPEG, set the quality */ 1027 /* if JPEG, set the quality */
1165 if ((mode->color & MASK_COLOR) == COLOR_JPG) { 1028 if ((mode->color & MASK_COLOR) == COLOR_JPG) {
1166 mode->color &= ~MASK_COLOR; 1029 mode->color &= ~MASK_COLOR;
1167 mode->color |= COLOR_JPG; 1030 mode->color |= COLOR_JPG;
1168 mode->color &= ~MASK_JPG_QUALITY; 1031 mode->color &= ~MASK_JPG_QUALITY;
1169 mode->color |= (channel->jpegqual << 8); 1032 mode->color |= (vc->jpegqual << 8);
1170 } 1033 }
1171 /* save the mode */ 1034 /* save the mode */
1172 channel->mode = *mode; 1035 vc->mode = *mode;
1173 channel->req_image_size = get_transfer_size(mode); 1036 vc->req_image_size = get_transfer_size(mode);
1174 dprintk(1, "%s: reqsize %ld\n", __func__, channel->req_image_size); 1037 dprintk(dev, 1, "%s: reqsize %ld\n", __func__, vc->req_image_size);
1175 buffer = kzalloc(512, GFP_KERNEL);
1176 if (buffer == NULL) {
1177 dev_err(&dev->udev->dev, "out of mem\n");
1178 return -ENOMEM;
1179 }
1180 /* set the mode */ 1038 /* set the mode */
1181 buffer[0] = IN_DATA_TOKEN; 1039 buffer[0] = IN_DATA_TOKEN;
1182 buffer[1] = (__le32) cpu_to_le32(chn_rev); 1040 buffer[1] = (__le32) cpu_to_le32(chn_rev);
1183 buffer[2] = CMD_SET_MODE; 1041 buffer[2] = CMD_SET_MODE;
1184 for (i = 0; i < sizeof(struct s2255_mode) / sizeof(u32); i++) 1042 for (i = 0; i < sizeof(struct s2255_mode) / sizeof(u32); i++)
1185 buffer[3 + i] = cpu_to_le32(((u32 *)&channel->mode)[i]); 1043 buffer[3 + i] = cpu_to_le32(((u32 *)&vc->mode)[i]);
1186 channel->setmode_ready = 0; 1044 vc->setmode_ready = 0;
1187 res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512); 1045 res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512);
1188 if (debug) 1046 if (debug)
1189 s2255_print_cfg(dev, mode); 1047 s2255_print_cfg(dev, mode);
1190 kfree(buffer);
1191 /* wait at least 3 frames before continuing */ 1048 /* wait at least 3 frames before continuing */
1192 if (mode->restart) { 1049 if (mode->restart) {
1193 wait_event_timeout(channel->wait_setmode, 1050 wait_event_timeout(vc->wait_setmode,
1194 (channel->setmode_ready != 0), 1051 (vc->setmode_ready != 0),
1195 msecs_to_jiffies(S2255_SETMODE_TIMEOUT)); 1052 msecs_to_jiffies(S2255_SETMODE_TIMEOUT));
1196 if (channel->setmode_ready != 1) { 1053 if (vc->setmode_ready != 1) {
1197 printk(KERN_DEBUG "s2255: no set mode response\n"); 1054 dprintk(dev, 0, "s2255: no set mode response\n");
1198 res = -EFAULT; 1055 res = -EFAULT;
1199 } 1056 }
1200 } 1057 }
1201 /* clear the restart flag */ 1058 /* clear the restart flag */
1202 channel->mode.restart = 0; 1059 vc->mode.restart = 0;
1203 dprintk(1, "%s chn %d, result: %d\n", __func__, channel->idx, res); 1060 dprintk(dev, 1, "%s chn %d, result: %d\n", __func__, vc->idx, res);
1061 mutex_unlock(&dev->cmdlock);
1204 return res; 1062 return res;
1205} 1063}
1206 1064
1207static int s2255_cmd_status(struct s2255_channel *channel, u32 *pstatus) 1065static int s2255_cmd_status(struct s2255_vc *vc, u32 *pstatus)
1208{ 1066{
1209 int res; 1067 int res;
1210 __le32 *buffer;
1211 u32 chn_rev; 1068 u32 chn_rev;
1212 struct s2255_dev *dev = to_s2255_dev(channel->vdev.v4l2_dev); 1069 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
1213 chn_rev = G_chnmap[channel->idx]; 1070 __le32 *buffer = dev->cmdbuf;
1214 dprintk(4, "%s chan %d\n", __func__, channel->idx); 1071
1215 buffer = kzalloc(512, GFP_KERNEL); 1072 mutex_lock(&dev->cmdlock);
1216 if (buffer == NULL) { 1073 chn_rev = G_chnmap[vc->idx];
1217 dev_err(&dev->udev->dev, "out of mem\n"); 1074 dprintk(dev, 4, "%s chan %d\n", __func__, vc->idx);
1218 return -ENOMEM;
1219 }
1220 /* form the get vid status command */ 1075 /* form the get vid status command */
1221 buffer[0] = IN_DATA_TOKEN; 1076 buffer[0] = IN_DATA_TOKEN;
1222 buffer[1] = (__le32) cpu_to_le32(chn_rev); 1077 buffer[1] = (__le32) cpu_to_le32(chn_rev);
1223 buffer[2] = CMD_STATUS; 1078 buffer[2] = CMD_STATUS;
1224 *pstatus = 0; 1079 *pstatus = 0;
1225 channel->vidstatus_ready = 0; 1080 vc->vidstatus_ready = 0;
1226 res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512); 1081 res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512);
1227 kfree(buffer); 1082 wait_event_timeout(vc->wait_vidstatus,
1228 wait_event_timeout(channel->wait_vidstatus, 1083 (vc->vidstatus_ready != 0),
1229 (channel->vidstatus_ready != 0),
1230 msecs_to_jiffies(S2255_VIDSTATUS_TIMEOUT)); 1084 msecs_to_jiffies(S2255_VIDSTATUS_TIMEOUT));
1231 if (channel->vidstatus_ready != 1) { 1085 if (vc->vidstatus_ready != 1) {
1232 printk(KERN_DEBUG "s2255: no vidstatus response\n"); 1086 dprintk(dev, 0, "s2255: no vidstatus response\n");
1233 res = -EFAULT; 1087 res = -EFAULT;
1234 } 1088 }
1235 *pstatus = channel->vidstatus; 1089 *pstatus = vc->vidstatus;
1236 dprintk(4, "%s, vid status %d\n", __func__, *pstatus); 1090 dprintk(dev, 4, "%s, vid status %d\n", __func__, *pstatus);
1091 mutex_unlock(&dev->cmdlock);
1237 return res; 1092 return res;
1238} 1093}
1239 1094
1240static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) 1095static int start_streaming(struct vb2_queue *vq, unsigned int count)
1241{ 1096{
1242 int res; 1097 struct s2255_vc *vc = vb2_get_drv_priv(vq);
1243 struct s2255_fh *fh = priv;
1244 struct s2255_dev *dev = fh->dev;
1245 struct s2255_channel *channel = fh->channel;
1246 int j; 1098 int j;
1247 dprintk(4, "%s\n", __func__);
1248 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1249 dev_err(&dev->udev->dev, "invalid fh type0\n");
1250 return -EINVAL;
1251 }
1252 if (i != fh->type) {
1253 dev_err(&dev->udev->dev, "invalid fh type1\n");
1254 return -EINVAL;
1255 }
1256 1099
1257 if (!res_get(fh)) { 1100 vc->last_frame = -1;
1258 s2255_dev_err(&dev->udev->dev, "stream busy\n"); 1101 vc->bad_payload = 0;
1259 return -EBUSY; 1102 vc->cur_frame = 0;
1260 } 1103 vc->frame_count = 0;
1261 channel->last_frame = -1;
1262 channel->bad_payload = 0;
1263 channel->cur_frame = 0;
1264 channel->frame_count = 0;
1265 for (j = 0; j < SYS_FRAMES; j++) { 1104 for (j = 0; j < SYS_FRAMES; j++) {
1266 channel->buffer.frame[j].ulState = S2255_READ_IDLE; 1105 vc->buffer.frame[j].ulState = S2255_READ_IDLE;
1267 channel->buffer.frame[j].cur_size = 0; 1106 vc->buffer.frame[j].cur_size = 0;
1268 } 1107 }
1269 res = videobuf_streamon(&fh->vb_vidq); 1108 return s2255_start_acquire(vc);
1270 if (res == 0) {
1271 s2255_start_acquire(channel);
1272 channel->b_acquire = 1;
1273 } else
1274 res_free(fh);
1275
1276 return res;
1277} 1109}
1278 1110
1279static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) 1111/* abort streaming and wait for last buffer */
1112static int stop_streaming(struct vb2_queue *vq)
1280{ 1113{
1281 struct s2255_fh *fh = priv; 1114 struct s2255_vc *vc = vb2_get_drv_priv(vq);
1282 dprintk(4, "%s\n, channel: %d", __func__, fh->channel->idx); 1115 struct s2255_buffer *buf, *node;
1283 if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1116 unsigned long flags;
1284 printk(KERN_ERR "invalid fh type0\n"); 1117 (void) s2255_stop_acquire(vc);
1285 return -EINVAL; 1118 spin_lock_irqsave(&vc->qlock, flags);
1119 list_for_each_entry_safe(buf, node, &vc->buf_list, list) {
1120 list_del(&buf->list);
1121 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
1122 dprintk(vc->dev, 2, "[%p/%d] done\n",
1123 buf, buf->vb.v4l2_buf.index);
1286 } 1124 }
1287 if (i != fh->type) { 1125 spin_unlock_irqrestore(&vc->qlock, flags);
1288 printk(KERN_ERR "invalid type i\n");
1289 return -EINVAL;
1290 }
1291 s2255_stop_acquire(fh->channel);
1292 videobuf_streamoff(&fh->vb_vidq);
1293 res_free(fh);
1294 return 0; 1126 return 0;
1295} 1127}
1296 1128
1297static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id i) 1129static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id i)
1298{ 1130{
1299 struct s2255_fh *fh = priv; 1131 struct s2255_vc *vc = video_drvdata(file);
1300 struct s2255_mode mode; 1132 struct s2255_mode mode;
1301 struct videobuf_queue *q = &fh->vb_vidq; 1133 struct vb2_queue *q = &vc->vb_vidq;
1302 struct s2255_channel *channel = fh->channel;
1303 int ret = 0;
1304 1134
1305 mutex_lock(&q->vb_lock); 1135 /*
1306 if (res_locked(fh)) { 1136 * Changing the standard implies a format change, which is not allowed
1307 dprintk(1, "can't change standard after started\n"); 1137 * while buffers for use with streaming have already been allocated.
1308 ret = -EBUSY; 1138 */
1309 goto out_s_std; 1139 if (vb2_is_busy(q))
1310 } 1140 return -EBUSY;
1311 mode = fh->channel->mode; 1141
1142 mode = vc->mode;
1312 if (i & V4L2_STD_525_60) { 1143 if (i & V4L2_STD_525_60) {
1313 dprintk(4, "%s 60 Hz\n", __func__); 1144 dprintk(vc->dev, 4, "%s 60 Hz\n", __func__);
1314 /* if changing format, reset frame decimation/intervals */ 1145 /* if changing format, reset frame decimation/intervals */
1315 if (mode.format != FORMAT_NTSC) { 1146 if (mode.format != FORMAT_NTSC) {
1316 mode.restart = 1; 1147 mode.restart = 1;
1317 mode.format = FORMAT_NTSC; 1148 mode.format = FORMAT_NTSC;
1318 mode.fdec = FDEC_1; 1149 mode.fdec = FDEC_1;
1319 channel->width = LINE_SZ_4CIFS_NTSC; 1150 vc->width = LINE_SZ_4CIFS_NTSC;
1320 channel->height = NUM_LINES_4CIFS_NTSC * 2; 1151 vc->height = NUM_LINES_4CIFS_NTSC * 2;
1321 } 1152 }
1322 } else if (i & V4L2_STD_625_50) { 1153 } else if (i & V4L2_STD_625_50) {
1323 dprintk(4, "%s 50 Hz\n", __func__); 1154 dprintk(vc->dev, 4, "%s 50 Hz\n", __func__);
1324 if (mode.format != FORMAT_PAL) { 1155 if (mode.format != FORMAT_PAL) {
1325 mode.restart = 1; 1156 mode.restart = 1;
1326 mode.format = FORMAT_PAL; 1157 mode.format = FORMAT_PAL;
1327 mode.fdec = FDEC_1; 1158 mode.fdec = FDEC_1;
1328 channel->width = LINE_SZ_4CIFS_PAL; 1159 vc->width = LINE_SZ_4CIFS_PAL;
1329 channel->height = NUM_LINES_4CIFS_PAL * 2; 1160 vc->height = NUM_LINES_4CIFS_PAL * 2;
1330 } 1161 }
1331 } else { 1162 } else
1332 ret = -EINVAL; 1163 return -EINVAL;
1333 goto out_s_std; 1164 vc->std = i;
1334 }
1335 fh->channel->std = i;
1336 if (mode.restart) 1165 if (mode.restart)
1337 s2255_set_mode(fh->channel, &mode); 1166 s2255_set_mode(vc, &mode);
1338out_s_std: 1167 return 0;
1339 mutex_unlock(&q->vb_lock);
1340 return ret;
1341} 1168}
1342 1169
1343static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *i) 1170static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *i)
1344{ 1171{
1345 struct s2255_fh *fh = priv; 1172 struct s2255_vc *vc = video_drvdata(file);
1346 1173
1347 *i = fh->channel->std; 1174 *i = vc->std;
1348 return 0; 1175 return 0;
1349} 1176}
1350 1177
@@ -1358,10 +1185,10 @@ static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *i)
1358static int vidioc_enum_input(struct file *file, void *priv, 1185static int vidioc_enum_input(struct file *file, void *priv,
1359 struct v4l2_input *inp) 1186 struct v4l2_input *inp)
1360{ 1187{
1361 struct s2255_fh *fh = priv; 1188 struct s2255_vc *vc = video_drvdata(file);
1362 struct s2255_dev *dev = fh->dev; 1189 struct s2255_dev *dev = vc->dev;
1363 struct s2255_channel *channel = fh->channel;
1364 u32 status = 0; 1190 u32 status = 0;
1191
1365 if (inp->index != 0) 1192 if (inp->index != 0)
1366 return -EINVAL; 1193 return -EINVAL;
1367 inp->type = V4L2_INPUT_TYPE_CAMERA; 1194 inp->type = V4L2_INPUT_TYPE_CAMERA;
@@ -1369,8 +1196,9 @@ static int vidioc_enum_input(struct file *file, void *priv,
1369 inp->status = 0; 1196 inp->status = 0;
1370 if (dev->dsp_fw_ver >= S2255_MIN_DSP_STATUS) { 1197 if (dev->dsp_fw_ver >= S2255_MIN_DSP_STATUS) {
1371 int rc; 1198 int rc;
1372 rc = s2255_cmd_status(fh->channel, &status); 1199 rc = s2255_cmd_status(vc, &status);
1373 dprintk(4, "s2255_cmd_status rc: %d status %x\n", rc, status); 1200 dprintk(dev, 4, "s2255_cmd_status rc: %d status %x\n",
1201 rc, status);
1374 if (rc == 0) 1202 if (rc == 0)
1375 inp->status = (status & 0x01) ? 0 1203 inp->status = (status & 0x01) ? 0
1376 : V4L2_IN_ST_NO_SIGNAL; 1204 : V4L2_IN_ST_NO_SIGNAL;
@@ -1381,7 +1209,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
1381 strlcpy(inp->name, "Composite", sizeof(inp->name)); 1209 strlcpy(inp->name, "Composite", sizeof(inp->name));
1382 break; 1210 break;
1383 case 0x2257: 1211 case 0x2257:
1384 strlcpy(inp->name, (channel->idx < 2) ? "Composite" : "S-Video", 1212 strlcpy(inp->name, (vc->idx < 2) ? "Composite" : "S-Video",
1385 sizeof(inp->name)); 1213 sizeof(inp->name));
1386 break; 1214 break;
1387 } 1215 }
@@ -1402,13 +1230,10 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
1402 1230
1403static int s2255_s_ctrl(struct v4l2_ctrl *ctrl) 1231static int s2255_s_ctrl(struct v4l2_ctrl *ctrl)
1404{ 1232{
1405 struct s2255_channel *channel = 1233 struct s2255_vc *vc =
1406 container_of(ctrl->handler, struct s2255_channel, hdl); 1234 container_of(ctrl->handler, struct s2255_vc, hdl);
1407 struct s2255_mode mode; 1235 struct s2255_mode mode;
1408 1236 mode = vc->mode;
1409 mode = channel->mode;
1410 dprintk(4, "%s\n", __func__);
1411
1412 /* update the mode to the corresponding value */ 1237 /* update the mode to the corresponding value */
1413 switch (ctrl->id) { 1238 switch (ctrl->id) {
1414 case V4L2_CID_BRIGHTNESS: 1239 case V4L2_CID_BRIGHTNESS:
@@ -1428,7 +1253,7 @@ static int s2255_s_ctrl(struct v4l2_ctrl *ctrl)
1428 mode.color |= !ctrl->val << 16; 1253 mode.color |= !ctrl->val << 16;
1429 break; 1254 break;
1430 case V4L2_CID_JPEG_COMPRESSION_QUALITY: 1255 case V4L2_CID_JPEG_COMPRESSION_QUALITY:
1431 channel->jpegqual = ctrl->val; 1256 vc->jpegqual = ctrl->val;
1432 return 0; 1257 return 0;
1433 default: 1258 default:
1434 return -EINVAL; 1259 return -EINVAL;
@@ -1438,48 +1263,48 @@ static int s2255_s_ctrl(struct v4l2_ctrl *ctrl)
1438 some V4L programs restart stream unnecessarily 1263 some V4L programs restart stream unnecessarily
1439 after a s_crtl. 1264 after a s_crtl.
1440 */ 1265 */
1441 s2255_set_mode(channel, &mode); 1266 s2255_set_mode(vc, &mode);
1442 return 0; 1267 return 0;
1443} 1268}
1444 1269
1445static int vidioc_g_jpegcomp(struct file *file, void *priv, 1270static int vidioc_g_jpegcomp(struct file *file, void *priv,
1446 struct v4l2_jpegcompression *jc) 1271 struct v4l2_jpegcompression *jc)
1447{ 1272{
1448 struct s2255_fh *fh = priv; 1273 struct s2255_vc *vc = video_drvdata(file);
1449 struct s2255_channel *channel = fh->channel;
1450 1274
1451 memset(jc, 0, sizeof(*jc)); 1275 memset(jc, 0, sizeof(*jc));
1452 jc->quality = channel->jpegqual; 1276 jc->quality = vc->jpegqual;
1453 dprintk(2, "%s: quality %d\n", __func__, jc->quality); 1277 dprintk(vc->dev, 2, "%s: quality %d\n", __func__, jc->quality);
1454 return 0; 1278 return 0;
1455} 1279}
1456 1280
1457static int vidioc_s_jpegcomp(struct file *file, void *priv, 1281static int vidioc_s_jpegcomp(struct file *file, void *priv,
1458 const struct v4l2_jpegcompression *jc) 1282 const struct v4l2_jpegcompression *jc)
1459{ 1283{
1460 struct s2255_fh *fh = priv; 1284 struct s2255_vc *vc = video_drvdata(file);
1461 struct s2255_channel *channel = fh->channel; 1285
1462 if (jc->quality < 0 || jc->quality > 100) 1286 if (jc->quality < 0 || jc->quality > 100)
1463 return -EINVAL; 1287 return -EINVAL;
1464 v4l2_ctrl_s_ctrl(channel->jpegqual_ctrl, jc->quality); 1288 v4l2_ctrl_s_ctrl(vc->jpegqual_ctrl, jc->quality);
1465 dprintk(2, "%s: quality %d\n", __func__, jc->quality); 1289 dprintk(vc->dev, 2, "%s: quality %d\n", __func__, jc->quality);
1466 return 0; 1290 return 0;
1467} 1291}
1468 1292
1469static int vidioc_g_parm(struct file *file, void *priv, 1293static int vidioc_g_parm(struct file *file, void *priv,
1470 struct v4l2_streamparm *sp) 1294 struct v4l2_streamparm *sp)
1471{ 1295{
1472 struct s2255_fh *fh = priv;
1473 __u32 def_num, def_dem; 1296 __u32 def_num, def_dem;
1474 struct s2255_channel *channel = fh->channel; 1297 struct s2255_vc *vc = video_drvdata(file);
1298
1475 if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1299 if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1476 return -EINVAL; 1300 return -EINVAL;
1477 sp->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; 1301 sp->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
1478 sp->parm.capture.capturemode = channel->cap_parm.capturemode; 1302 sp->parm.capture.capturemode = vc->cap_parm.capturemode;
1479 def_num = (channel->mode.format == FORMAT_NTSC) ? 1001 : 1000; 1303 sp->parm.capture.readbuffers = S2255_MIN_BUFS;
1480 def_dem = (channel->mode.format == FORMAT_NTSC) ? 30000 : 25000; 1304 def_num = (vc->mode.format == FORMAT_NTSC) ? 1001 : 1000;
1305 def_dem = (vc->mode.format == FORMAT_NTSC) ? 30000 : 25000;
1481 sp->parm.capture.timeperframe.denominator = def_dem; 1306 sp->parm.capture.timeperframe.denominator = def_dem;
1482 switch (channel->mode.fdec) { 1307 switch (vc->mode.fdec) {
1483 default: 1308 default:
1484 case FDEC_1: 1309 case FDEC_1:
1485 sp->parm.capture.timeperframe.numerator = def_num; 1310 sp->parm.capture.timeperframe.numerator = def_num;
@@ -1494,7 +1319,8 @@ static int vidioc_g_parm(struct file *file, void *priv,
1494 sp->parm.capture.timeperframe.numerator = def_num * 5; 1319 sp->parm.capture.timeperframe.numerator = def_num * 5;
1495 break; 1320 break;
1496 } 1321 }
1497 dprintk(4, "%s capture mode, %d timeperframe %d/%d\n", __func__, 1322 dprintk(vc->dev, 4, "%s capture mode, %d timeperframe %d/%d\n",
1323 __func__,
1498 sp->parm.capture.capturemode, 1324 sp->parm.capture.capturemode,
1499 sp->parm.capture.timeperframe.numerator, 1325 sp->parm.capture.timeperframe.numerator,
1500 sp->parm.capture.timeperframe.denominator); 1326 sp->parm.capture.timeperframe.denominator);
@@ -1504,17 +1330,16 @@ static int vidioc_g_parm(struct file *file, void *priv,
1504static int vidioc_s_parm(struct file *file, void *priv, 1330static int vidioc_s_parm(struct file *file, void *priv,
1505 struct v4l2_streamparm *sp) 1331 struct v4l2_streamparm *sp)
1506{ 1332{
1507 struct s2255_fh *fh = priv; 1333 struct s2255_vc *vc = video_drvdata(file);
1508 struct s2255_channel *channel = fh->channel;
1509 struct s2255_mode mode; 1334 struct s2255_mode mode;
1510 int fdec = FDEC_1; 1335 int fdec = FDEC_1;
1511 __u32 def_num, def_dem; 1336 __u32 def_num, def_dem;
1512 if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1337 if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1513 return -EINVAL; 1338 return -EINVAL;
1514 mode = channel->mode; 1339 mode = vc->mode;
1515 /* high quality capture mode requires a stream restart */ 1340 /* high quality capture mode requires a stream restart */
1516 if (channel->cap_parm.capturemode 1341 if ((vc->cap_parm.capturemode != sp->parm.capture.capturemode)
1517 != sp->parm.capture.capturemode && res_locked(fh)) 1342 && vb2_is_streaming(&vc->vb_vidq))
1518 return -EBUSY; 1343 return -EBUSY;
1519 def_num = (mode.format == FORMAT_NTSC) ? 1001 : 1000; 1344 def_num = (mode.format == FORMAT_NTSC) ? 1001 : 1000;
1520 def_dem = (mode.format == FORMAT_NTSC) ? 30000 : 25000; 1345 def_dem = (mode.format == FORMAT_NTSC) ? 30000 : 25000;
@@ -1534,8 +1359,9 @@ static int vidioc_s_parm(struct file *file, void *priv,
1534 } 1359 }
1535 mode.fdec = fdec; 1360 mode.fdec = fdec;
1536 sp->parm.capture.timeperframe.denominator = def_dem; 1361 sp->parm.capture.timeperframe.denominator = def_dem;
1537 s2255_set_mode(channel, &mode); 1362 sp->parm.capture.readbuffers = S2255_MIN_BUFS;
1538 dprintk(4, "%s capture mode, %d timeperframe %d/%d, fdec %d\n", 1363 s2255_set_mode(vc, &mode);
1364 dprintk(vc->dev, 4, "%s capture mode, %d timeperframe %d/%d, fdec %d\n",
1539 __func__, 1365 __func__,
1540 sp->parm.capture.capturemode, 1366 sp->parm.capture.capturemode,
1541 sp->parm.capture.timeperframe.numerator, 1367 sp->parm.capture.timeperframe.numerator,
@@ -1558,9 +1384,8 @@ static const struct v4l2_frmsize_discrete pal_sizes[] = {
1558static int vidioc_enum_framesizes(struct file *file, void *priv, 1384static int vidioc_enum_framesizes(struct file *file, void *priv,
1559 struct v4l2_frmsizeenum *fe) 1385 struct v4l2_frmsizeenum *fe)
1560{ 1386{
1561 struct s2255_fh *fh = priv; 1387 struct s2255_vc *vc = video_drvdata(file);
1562 struct s2255_channel *channel = fh->channel; 1388 int is_ntsc = vc->std & V4L2_STD_525_60;
1563 int is_ntsc = channel->std & V4L2_STD_525_60;
1564 const struct s2255_fmt *fmt; 1389 const struct s2255_fmt *fmt;
1565 1390
1566 if (fe->index >= NUM_SIZE_ENUMS) 1391 if (fe->index >= NUM_SIZE_ENUMS)
@@ -1577,11 +1402,10 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,
1577static int vidioc_enum_frameintervals(struct file *file, void *priv, 1402static int vidioc_enum_frameintervals(struct file *file, void *priv,
1578 struct v4l2_frmivalenum *fe) 1403 struct v4l2_frmivalenum *fe)
1579{ 1404{
1580 struct s2255_fh *fh = priv; 1405 struct s2255_vc *vc = video_drvdata(file);
1581 struct s2255_channel *channel = fh->channel;
1582 const struct s2255_fmt *fmt; 1406 const struct s2255_fmt *fmt;
1583 const struct v4l2_frmsize_discrete *sizes; 1407 const struct v4l2_frmsize_discrete *sizes;
1584 int is_ntsc = channel->std & V4L2_STD_525_60; 1408 int is_ntsc = vc->std & V4L2_STD_525_60;
1585#define NUM_FRAME_ENUMS 4 1409#define NUM_FRAME_ENUMS 4
1586 int frm_dec[NUM_FRAME_ENUMS] = {1, 2, 3, 5}; 1410 int frm_dec[NUM_FRAME_ENUMS] = {1, 2, 3, 5};
1587 int i; 1411 int i;
@@ -1604,21 +1428,24 @@ static int vidioc_enum_frameintervals(struct file *file, void *priv,
1604 fe->type = V4L2_FRMIVAL_TYPE_DISCRETE; 1428 fe->type = V4L2_FRMIVAL_TYPE_DISCRETE;
1605 fe->discrete.denominator = is_ntsc ? 30000 : 25000; 1429 fe->discrete.denominator = is_ntsc ? 30000 : 25000;
1606 fe->discrete.numerator = (is_ntsc ? 1001 : 1000) * frm_dec[fe->index]; 1430 fe->discrete.numerator = (is_ntsc ? 1001 : 1000) * frm_dec[fe->index];
1607 dprintk(4, "%s discrete %d/%d\n", __func__, fe->discrete.numerator, 1431 dprintk(vc->dev, 4, "%s discrete %d/%d\n", __func__,
1432 fe->discrete.numerator,
1608 fe->discrete.denominator); 1433 fe->discrete.denominator);
1609 return 0; 1434 return 0;
1610} 1435}
1611 1436
1612static int __s2255_open(struct file *file) 1437static int s2255_open(struct file *file)
1613{ 1438{
1614 struct video_device *vdev = video_devdata(file); 1439 struct s2255_vc *vc = video_drvdata(file);
1615 struct s2255_channel *channel = video_drvdata(file); 1440 struct s2255_dev *dev = vc->dev;
1616 struct s2255_dev *dev = to_s2255_dev(vdev->v4l2_dev);
1617 struct s2255_fh *fh;
1618 enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1619 int state; 1441 int state;
1620 dprintk(1, "s2255: open called (dev=%s)\n", 1442 int rc = 0;
1621 video_device_node_name(vdev)); 1443
1444 rc = v4l2_fh_open(file);
1445 if (rc != 0)
1446 return rc;
1447
1448 dprintk(dev, 1, "s2255: %s\n", __func__);
1622 state = atomic_read(&dev->fw_data->fw_state); 1449 state = atomic_read(&dev->fw_data->fw_state);
1623 switch (state) { 1450 switch (state) {
1624 case S2255_FW_DISCONNECTING: 1451 case S2255_FW_DISCONNECTING:
@@ -1640,7 +1467,7 @@ static int __s2255_open(struct file *file)
1640 case S2255_FW_LOADED_DSPWAIT: 1467 case S2255_FW_LOADED_DSPWAIT:
1641 /* give S2255_LOAD_TIMEOUT time for firmware to load in case 1468 /* give S2255_LOAD_TIMEOUT time for firmware to load in case
1642 driver loaded and then device immediately opened */ 1469 driver loaded and then device immediately opened */
1643 printk(KERN_INFO "%s waiting for firmware load\n", __func__); 1470 pr_info("%s waiting for firmware load\n", __func__);
1644 wait_event_timeout(dev->fw_data->wait_fw, 1471 wait_event_timeout(dev->fw_data->wait_fw,
1645 ((atomic_read(&dev->fw_data->fw_state) 1472 ((atomic_read(&dev->fw_data->fw_state)
1646 == S2255_FW_SUCCESS) || 1473 == S2255_FW_SUCCESS) ||
@@ -1659,16 +1486,15 @@ static int __s2255_open(struct file *file)
1659 case S2255_FW_SUCCESS: 1486 case S2255_FW_SUCCESS:
1660 break; 1487 break;
1661 case S2255_FW_FAILED: 1488 case S2255_FW_FAILED:
1662 printk(KERN_INFO "2255 firmware load failed.\n"); 1489 pr_info("2255 firmware load failed.\n");
1663 return -ENODEV; 1490 return -ENODEV;
1664 case S2255_FW_DISCONNECTING: 1491 case S2255_FW_DISCONNECTING:
1665 printk(KERN_INFO "%s: disconnecting\n", __func__); 1492 pr_info("%s: disconnecting\n", __func__);
1666 return -ENODEV; 1493 return -ENODEV;
1667 case S2255_FW_LOADED_DSPWAIT: 1494 case S2255_FW_LOADED_DSPWAIT:
1668 case S2255_FW_NOTLOADED: 1495 case S2255_FW_NOTLOADED:
1669 printk(KERN_INFO "%s: firmware not loaded yet" 1496 pr_info("%s: firmware not loaded, please retry\n",
1670 "please try again later\n", 1497 __func__);
1671 __func__);
1672 /* 1498 /*
1673 * Timeout on firmware load means device unusable. 1499 * Timeout on firmware load means device unusable.
1674 * Set firmware failure state. 1500 * Set firmware failure state.
@@ -1678,71 +1504,21 @@ static int __s2255_open(struct file *file)
1678 S2255_FW_FAILED); 1504 S2255_FW_FAILED);
1679 return -EAGAIN; 1505 return -EAGAIN;
1680 default: 1506 default:
1681 printk(KERN_INFO "%s: unknown state\n", __func__); 1507 pr_info("%s: unknown state\n", __func__);
1682 return -EFAULT; 1508 return -EFAULT;
1683 } 1509 }
1684 /* allocate + initialize per filehandle data */ 1510 if (!vc->configured) {
1685 fh = kzalloc(sizeof(*fh), GFP_KERNEL);
1686 if (NULL == fh)
1687 return -ENOMEM;
1688 v4l2_fh_init(&fh->fh, vdev);
1689 v4l2_fh_add(&fh->fh);
1690 file->private_data = &fh->fh;
1691 fh->dev = dev;
1692 fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1693 fh->channel = channel;
1694 if (!channel->configured) {
1695 /* configure channel to default state */ 1511 /* configure channel to default state */
1696 channel->fmt = &formats[0]; 1512 vc->fmt = &formats[0];
1697 s2255_set_mode(channel, &channel->mode); 1513 s2255_set_mode(vc, &vc->mode);
1698 channel->configured = 1; 1514 vc->configured = 1;
1699 } 1515 }
1700 dprintk(1, "%s: dev=%s type=%s\n", __func__,
1701 video_device_node_name(vdev), v4l2_type_names[type]);
1702 dprintk(2, "%s: fh=0x%08lx, dev=0x%08lx, vidq=0x%08lx\n", __func__,
1703 (unsigned long)fh, (unsigned long)dev,
1704 (unsigned long)&channel->vidq);
1705 dprintk(4, "%s: list_empty active=%d\n", __func__,
1706 list_empty(&channel->vidq.active));
1707 videobuf_queue_vmalloc_init(&fh->vb_vidq, &s2255_video_qops,
1708 NULL, &dev->slock,
1709 fh->type,
1710 V4L2_FIELD_INTERLACED,
1711 sizeof(struct s2255_buffer),
1712 fh, vdev->lock);
1713 return 0; 1516 return 0;
1714} 1517}
1715 1518
1716static int s2255_open(struct file *file)
1717{
1718 struct video_device *vdev = video_devdata(file);
1719 int ret;
1720
1721 if (mutex_lock_interruptible(vdev->lock))
1722 return -ERESTARTSYS;
1723 ret = __s2255_open(file);
1724 mutex_unlock(vdev->lock);
1725 return ret;
1726}
1727
1728static unsigned int s2255_poll(struct file *file,
1729 struct poll_table_struct *wait)
1730{
1731 struct s2255_fh *fh = file->private_data;
1732 struct s2255_dev *dev = fh->dev;
1733 int rc = v4l2_ctrl_poll(file, wait);
1734
1735 dprintk(100, "%s\n", __func__);
1736 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type)
1737 return POLLERR;
1738 mutex_lock(&dev->lock);
1739 rc |= videobuf_poll_stream(file, &fh->vb_vidq, wait);
1740 mutex_unlock(&dev->lock);
1741 return rc;
1742}
1743
1744static void s2255_destroy(struct s2255_dev *dev) 1519static void s2255_destroy(struct s2255_dev *dev)
1745{ 1520{
1521 dprintk(dev, 1, "%s", __func__);
1746 /* board shutdown stops the read pipe if it is running */ 1522 /* board shutdown stops the read pipe if it is running */
1747 s2255_board_shutdown(dev); 1523 s2255_board_shutdown(dev);
1748 /* make sure firmware still not trying to load */ 1524 /* make sure firmware still not trying to load */
@@ -1760,62 +1536,18 @@ static void s2255_destroy(struct s2255_dev *dev)
1760 mutex_destroy(&dev->lock); 1536 mutex_destroy(&dev->lock);
1761 usb_put_dev(dev->udev); 1537 usb_put_dev(dev->udev);
1762 v4l2_device_unregister(&dev->v4l2_dev); 1538 v4l2_device_unregister(&dev->v4l2_dev);
1763 dprintk(1, "%s", __func__); 1539 kfree(dev->cmdbuf);
1764 kfree(dev); 1540 kfree(dev);
1765} 1541}
1766 1542
1767static int s2255_release(struct file *file)
1768{
1769 struct s2255_fh *fh = file->private_data;
1770 struct s2255_dev *dev = fh->dev;
1771 struct video_device *vdev = video_devdata(file);
1772 struct s2255_channel *channel = fh->channel;
1773 if (!dev)
1774 return -ENODEV;
1775 mutex_lock(&dev->lock);
1776 /* turn off stream */
1777 if (res_check(fh)) {
1778 if (channel->b_acquire)
1779 s2255_stop_acquire(fh->channel);
1780 videobuf_streamoff(&fh->vb_vidq);
1781 res_free(fh);
1782 }
1783 videobuf_mmap_free(&fh->vb_vidq);
1784 mutex_unlock(&dev->lock);
1785 dprintk(1, "%s (dev=%s)\n", __func__, video_device_node_name(vdev));
1786 v4l2_fh_del(&fh->fh);
1787 v4l2_fh_exit(&fh->fh);
1788 kfree(fh);
1789 return 0;
1790}
1791
1792static int s2255_mmap_v4l(struct file *file, struct vm_area_struct *vma)
1793{
1794 struct s2255_fh *fh = file->private_data;
1795 struct s2255_dev *dev;
1796 int ret;
1797
1798 if (!fh)
1799 return -ENODEV;
1800 dev = fh->dev;
1801 dprintk(4, "%s, vma=0x%08lx\n", __func__, (unsigned long)vma);
1802 if (mutex_lock_interruptible(&dev->lock))
1803 return -ERESTARTSYS;
1804 ret = videobuf_mmap_mapper(&fh->vb_vidq, vma);
1805 mutex_unlock(&dev->lock);
1806 dprintk(4, "%s vma start=0x%08lx, size=%ld, ret=%d\n", __func__,
1807 (unsigned long)vma->vm_start,
1808 (unsigned long)vma->vm_end - (unsigned long)vma->vm_start, ret);
1809 return ret;
1810}
1811
1812static const struct v4l2_file_operations s2255_fops_v4l = { 1543static const struct v4l2_file_operations s2255_fops_v4l = {
1813 .owner = THIS_MODULE, 1544 .owner = THIS_MODULE,
1814 .open = s2255_open, 1545 .open = s2255_open,
1815 .release = s2255_release, 1546 .release = vb2_fop_release,
1816 .poll = s2255_poll, 1547 .poll = vb2_fop_poll,
1817 .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */ 1548 .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */
1818 .mmap = s2255_mmap_v4l, 1549 .mmap = vb2_fop_mmap,
1550 .read = vb2_fop_read,
1819}; 1551};
1820 1552
1821static const struct v4l2_ioctl_ops s2255_ioctl_ops = { 1553static const struct v4l2_ioctl_ops s2255_ioctl_ops = {
@@ -1824,17 +1556,17 @@ static const struct v4l2_ioctl_ops s2255_ioctl_ops = {
1824 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, 1556 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
1825 .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, 1557 .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap,
1826 .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, 1558 .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap,
1827 .vidioc_reqbufs = vidioc_reqbufs, 1559 .vidioc_reqbufs = vb2_ioctl_reqbufs,
1828 .vidioc_querybuf = vidioc_querybuf, 1560 .vidioc_querybuf = vb2_ioctl_querybuf,
1829 .vidioc_qbuf = vidioc_qbuf, 1561 .vidioc_qbuf = vb2_ioctl_qbuf,
1830 .vidioc_dqbuf = vidioc_dqbuf, 1562 .vidioc_dqbuf = vb2_ioctl_dqbuf,
1831 .vidioc_s_std = vidioc_s_std, 1563 .vidioc_s_std = vidioc_s_std,
1832 .vidioc_g_std = vidioc_g_std, 1564 .vidioc_g_std = vidioc_g_std,
1833 .vidioc_enum_input = vidioc_enum_input, 1565 .vidioc_enum_input = vidioc_enum_input,
1834 .vidioc_g_input = vidioc_g_input, 1566 .vidioc_g_input = vidioc_g_input,
1835 .vidioc_s_input = vidioc_s_input, 1567 .vidioc_s_input = vidioc_s_input,
1836 .vidioc_streamon = vidioc_streamon, 1568 .vidioc_streamon = vb2_ioctl_streamon,
1837 .vidioc_streamoff = vidioc_streamoff, 1569 .vidioc_streamoff = vb2_ioctl_streamoff,
1838 .vidioc_s_jpegcomp = vidioc_s_jpegcomp, 1570 .vidioc_s_jpegcomp = vidioc_s_jpegcomp,
1839 .vidioc_g_jpegcomp = vidioc_g_jpegcomp, 1571 .vidioc_g_jpegcomp = vidioc_g_jpegcomp,
1840 .vidioc_s_parm = vidioc_s_parm, 1572 .vidioc_s_parm = vidioc_s_parm,
@@ -1849,13 +1581,14 @@ static const struct v4l2_ioctl_ops s2255_ioctl_ops = {
1849static void s2255_video_device_release(struct video_device *vdev) 1581static void s2255_video_device_release(struct video_device *vdev)
1850{ 1582{
1851 struct s2255_dev *dev = to_s2255_dev(vdev->v4l2_dev); 1583 struct s2255_dev *dev = to_s2255_dev(vdev->v4l2_dev);
1852 struct s2255_channel *channel = 1584 struct s2255_vc *vc =
1853 container_of(vdev, struct s2255_channel, vdev); 1585 container_of(vdev, struct s2255_vc, vdev);
1854 1586
1855 v4l2_ctrl_handler_free(&channel->hdl); 1587 dprintk(dev, 4, "%s, chnls: %d\n", __func__,
1856 dprintk(4, "%s, chnls: %d\n", __func__,
1857 atomic_read(&dev->num_channels)); 1588 atomic_read(&dev->num_channels));
1858 1589
1590 v4l2_ctrl_handler_free(&vc->hdl);
1591
1859 if (atomic_dec_and_test(&dev->num_channels)) 1592 if (atomic_dec_and_test(&dev->num_channels))
1860 s2255_destroy(dev); 1593 s2255_destroy(dev);
1861 return; 1594 return;
@@ -1888,52 +1621,70 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1888 int ret; 1621 int ret;
1889 int i; 1622 int i;
1890 int cur_nr = video_nr; 1623 int cur_nr = video_nr;
1891 struct s2255_channel *channel; 1624 struct s2255_vc *vc;
1625 struct vb2_queue *q;
1626
1892 ret = v4l2_device_register(&dev->interface->dev, &dev->v4l2_dev); 1627 ret = v4l2_device_register(&dev->interface->dev, &dev->v4l2_dev);
1893 if (ret) 1628 if (ret)
1894 return ret; 1629 return ret;
1895 /* initialize all video 4 linux */ 1630 /* initialize all video 4 linux */
1896 /* register 4 video devices */ 1631 /* register 4 video devices */
1897 for (i = 0; i < MAX_CHANNELS; i++) { 1632 for (i = 0; i < MAX_CHANNELS; i++) {
1898 channel = &dev->channel[i]; 1633 vc = &dev->vc[i];
1899 INIT_LIST_HEAD(&channel->vidq.active); 1634 INIT_LIST_HEAD(&vc->buf_list);
1900 1635
1901 v4l2_ctrl_handler_init(&channel->hdl, 6); 1636 v4l2_ctrl_handler_init(&vc->hdl, 6);
1902 v4l2_ctrl_new_std(&channel->hdl, &s2255_ctrl_ops, 1637 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops,
1903 V4L2_CID_BRIGHTNESS, -127, 127, 1, DEF_BRIGHT); 1638 V4L2_CID_BRIGHTNESS, -127, 127, 1, DEF_BRIGHT);
1904 v4l2_ctrl_new_std(&channel->hdl, &s2255_ctrl_ops, 1639 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops,
1905 V4L2_CID_CONTRAST, 0, 255, 1, DEF_CONTRAST); 1640 V4L2_CID_CONTRAST, 0, 255, 1, DEF_CONTRAST);
1906 v4l2_ctrl_new_std(&channel->hdl, &s2255_ctrl_ops, 1641 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops,
1907 V4L2_CID_SATURATION, 0, 255, 1, DEF_SATURATION); 1642 V4L2_CID_SATURATION, 0, 255, 1, DEF_SATURATION);
1908 v4l2_ctrl_new_std(&channel->hdl, &s2255_ctrl_ops, 1643 v4l2_ctrl_new_std(&vc->hdl, &s2255_ctrl_ops,
1909 V4L2_CID_HUE, 0, 255, 1, DEF_HUE); 1644 V4L2_CID_HUE, 0, 255, 1, DEF_HUE);
1910 channel->jpegqual_ctrl = v4l2_ctrl_new_std(&channel->hdl, 1645 vc->jpegqual_ctrl = v4l2_ctrl_new_std(&vc->hdl,
1911 &s2255_ctrl_ops, 1646 &s2255_ctrl_ops,
1912 V4L2_CID_JPEG_COMPRESSION_QUALITY, 1647 V4L2_CID_JPEG_COMPRESSION_QUALITY,
1913 0, 100, 1, S2255_DEF_JPEG_QUAL); 1648 0, 100, 1, S2255_DEF_JPEG_QUAL);
1914 if (dev->dsp_fw_ver >= S2255_MIN_DSP_COLORFILTER && 1649 if (dev->dsp_fw_ver >= S2255_MIN_DSP_COLORFILTER &&
1915 (dev->pid != 0x2257 || channel->idx <= 1)) 1650 (dev->pid != 0x2257 || vc->idx <= 1))
1916 v4l2_ctrl_new_custom(&channel->hdl, &color_filter_ctrl, NULL); 1651 v4l2_ctrl_new_custom(&vc->hdl, &color_filter_ctrl,
1917 if (channel->hdl.error) { 1652 NULL);
1918 ret = channel->hdl.error; 1653 if (vc->hdl.error) {
1919 v4l2_ctrl_handler_free(&channel->hdl); 1654 ret = vc->hdl.error;
1655 v4l2_ctrl_handler_free(&vc->hdl);
1920 dev_err(&dev->udev->dev, "couldn't register control\n"); 1656 dev_err(&dev->udev->dev, "couldn't register control\n");
1921 break; 1657 break;
1922 } 1658 }
1923 channel->vidq.dev = dev; 1659 q = &vc->vb_vidq;
1924 /* register 4 video devices */ 1660 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1925 channel->vdev = template; 1661 q->io_modes = VB2_MMAP | VB2_READ | VB2_USERPTR;
1926 channel->vdev.ctrl_handler = &channel->hdl; 1662 q->drv_priv = vc;
1927 channel->vdev.lock = &dev->lock; 1663 q->lock = &vc->vb_lock;
1928 channel->vdev.v4l2_dev = &dev->v4l2_dev; 1664 q->buf_struct_size = sizeof(struct s2255_buffer);
1929 set_bit(V4L2_FL_USE_FH_PRIO, &channel->vdev.flags); 1665 q->mem_ops = &vb2_vmalloc_memops;
1930 video_set_drvdata(&channel->vdev, channel); 1666 q->ops = &s2255_video_qops;
1667 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1668 ret = vb2_queue_init(q);
1669 if (ret != 0) {
1670 dev_err(&dev->udev->dev,
1671 "%s vb2_queue_init 0x%x\n", __func__, ret);
1672 break;
1673 }
1674 /* register video devices */
1675 vc->vdev = template;
1676 vc->vdev.queue = q;
1677 vc->vdev.ctrl_handler = &vc->hdl;
1678 vc->vdev.lock = &dev->lock;
1679 vc->vdev.v4l2_dev = &dev->v4l2_dev;
1680 set_bit(V4L2_FL_USE_FH_PRIO, &vc->vdev.flags);
1681 video_set_drvdata(&vc->vdev, vc);
1931 if (video_nr == -1) 1682 if (video_nr == -1)
1932 ret = video_register_device(&channel->vdev, 1683 ret = video_register_device(&vc->vdev,
1933 VFL_TYPE_GRABBER, 1684 VFL_TYPE_GRABBER,
1934 video_nr); 1685 video_nr);
1935 else 1686 else
1936 ret = video_register_device(&channel->vdev, 1687 ret = video_register_device(&vc->vdev,
1937 VFL_TYPE_GRABBER, 1688 VFL_TYPE_GRABBER,
1938 cur_nr + i); 1689 cur_nr + i);
1939 1690
@@ -1944,18 +1695,18 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
1944 } 1695 }
1945 atomic_inc(&dev->num_channels); 1696 atomic_inc(&dev->num_channels);
1946 v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n", 1697 v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n",
1947 video_device_node_name(&channel->vdev)); 1698 video_device_node_name(&vc->vdev));
1948 1699
1949 } 1700 }
1950 printk(KERN_INFO "Sensoray 2255 V4L driver Revision: %s\n", 1701 pr_info("Sensoray 2255 V4L driver Revision: %s\n",
1951 S2255_VERSION); 1702 S2255_VERSION);
1952 /* if no channels registered, return error and probe will fail*/ 1703 /* if no channels registered, return error and probe will fail*/
1953 if (atomic_read(&dev->num_channels) == 0) { 1704 if (atomic_read(&dev->num_channels) == 0) {
1954 v4l2_device_unregister(&dev->v4l2_dev); 1705 v4l2_device_unregister(&dev->v4l2_dev);
1955 return ret; 1706 return ret;
1956 } 1707 }
1957 if (atomic_read(&dev->num_channels) != MAX_CHANNELS) 1708 if (atomic_read(&dev->num_channels) != MAX_CHANNELS)
1958 printk(KERN_WARNING "s2255: Not all channels available.\n"); 1709 pr_warn("s2255: Not all channels available.\n");
1959 return 0; 1710 return 0;
1960} 1711}
1961 1712
@@ -1981,11 +1732,11 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
1981 s32 idx = -1; 1732 s32 idx = -1;
1982 struct s2255_framei *frm; 1733 struct s2255_framei *frm;
1983 unsigned char *pdata; 1734 unsigned char *pdata;
1984 struct s2255_channel *channel; 1735 struct s2255_vc *vc;
1985 dprintk(100, "buffer to user\n"); 1736 dprintk(dev, 100, "buffer to user\n");
1986 channel = &dev->channel[dev->cc]; 1737 vc = &dev->vc[dev->cc];
1987 idx = channel->cur_frame; 1738 idx = vc->cur_frame;
1988 frm = &channel->buffer.frame[idx]; 1739 frm = &vc->buffer.frame[idx];
1989 if (frm->ulState == S2255_READ_IDLE) { 1740 if (frm->ulState == S2255_READ_IDLE) {
1990 int jj; 1741 int jj;
1991 unsigned int cc; 1742 unsigned int cc;
@@ -1997,28 +1748,27 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
1997 for (jj = 0; jj < (pipe_info->cur_transfer_size - 12); jj++) { 1748 for (jj = 0; jj < (pipe_info->cur_transfer_size - 12); jj++) {
1998 switch (*pdword) { 1749 switch (*pdword) {
1999 case S2255_MARKER_FRAME: 1750 case S2255_MARKER_FRAME:
2000 dprintk(4, "found frame marker at offset:" 1751 dprintk(dev, 4, "marker @ offset: %d [%x %x]\n",
2001 " %d [%x %x]\n", jj, pdata[0], 1752 jj, pdata[0], pdata[1]);
2002 pdata[1]);
2003 offset = jj + PREFIX_SIZE; 1753 offset = jj + PREFIX_SIZE;
2004 bframe = 1; 1754 bframe = 1;
2005 cc = le32_to_cpu(pdword[1]); 1755 cc = le32_to_cpu(pdword[1]);
2006 if (cc >= MAX_CHANNELS) { 1756 if (cc >= MAX_CHANNELS) {
2007 printk(KERN_ERR 1757 dprintk(dev, 0,
2008 "bad channel\n"); 1758 "bad channel\n");
2009 return -EINVAL; 1759 return -EINVAL;
2010 } 1760 }
2011 /* reverse it */ 1761 /* reverse it */
2012 dev->cc = G_chnmap[cc]; 1762 dev->cc = G_chnmap[cc];
2013 channel = &dev->channel[dev->cc]; 1763 vc = &dev->vc[dev->cc];
2014 payload = le32_to_cpu(pdword[3]); 1764 payload = le32_to_cpu(pdword[3]);
2015 if (payload > channel->req_image_size) { 1765 if (payload > vc->req_image_size) {
2016 channel->bad_payload++; 1766 vc->bad_payload++;
2017 /* discard the bad frame */ 1767 /* discard the bad frame */
2018 return -EINVAL; 1768 return -EINVAL;
2019 } 1769 }
2020 channel->pkt_size = payload; 1770 vc->pkt_size = payload;
2021 channel->jpg_size = le32_to_cpu(pdword[4]); 1771 vc->jpg_size = le32_to_cpu(pdword[4]);
2022 break; 1772 break;
2023 case S2255_MARKER_RESPONSE: 1773 case S2255_MARKER_RESPONSE:
2024 1774
@@ -2029,34 +1779,34 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2029 cc = G_chnmap[le32_to_cpu(pdword[1])]; 1779 cc = G_chnmap[le32_to_cpu(pdword[1])];
2030 if (cc >= MAX_CHANNELS) 1780 if (cc >= MAX_CHANNELS)
2031 break; 1781 break;
2032 channel = &dev->channel[cc]; 1782 vc = &dev->vc[cc];
2033 switch (pdword[2]) { 1783 switch (pdword[2]) {
2034 case S2255_RESPONSE_SETMODE: 1784 case S2255_RESPONSE_SETMODE:
2035 /* check if channel valid */ 1785 /* check if channel valid */
2036 /* set mode ready */ 1786 /* set mode ready */
2037 channel->setmode_ready = 1; 1787 vc->setmode_ready = 1;
2038 wake_up(&channel->wait_setmode); 1788 wake_up(&vc->wait_setmode);
2039 dprintk(5, "setmode ready %d\n", cc); 1789 dprintk(dev, 5, "setmode rdy %d\n", cc);
2040 break; 1790 break;
2041 case S2255_RESPONSE_FW: 1791 case S2255_RESPONSE_FW:
2042 dev->chn_ready |= (1 << cc); 1792 dev->chn_ready |= (1 << cc);
2043 if ((dev->chn_ready & 0x0f) != 0x0f) 1793 if ((dev->chn_ready & 0x0f) != 0x0f)
2044 break; 1794 break;
2045 /* all channels ready */ 1795 /* all channels ready */
2046 printk(KERN_INFO "s2255: fw loaded\n"); 1796 pr_info("s2255: fw loaded\n");
2047 atomic_set(&dev->fw_data->fw_state, 1797 atomic_set(&dev->fw_data->fw_state,
2048 S2255_FW_SUCCESS); 1798 S2255_FW_SUCCESS);
2049 wake_up(&dev->fw_data->wait_fw); 1799 wake_up(&dev->fw_data->wait_fw);
2050 break; 1800 break;
2051 case S2255_RESPONSE_STATUS: 1801 case S2255_RESPONSE_STATUS:
2052 channel->vidstatus = le32_to_cpu(pdword[3]); 1802 vc->vidstatus = le32_to_cpu(pdword[3]);
2053 channel->vidstatus_ready = 1; 1803 vc->vidstatus_ready = 1;
2054 wake_up(&channel->wait_vidstatus); 1804 wake_up(&vc->wait_vidstatus);
2055 dprintk(5, "got vidstatus %x chan %d\n", 1805 dprintk(dev, 5, "vstat %x chan %d\n",
2056 le32_to_cpu(pdword[3]), cc); 1806 le32_to_cpu(pdword[3]), cc);
2057 break; 1807 break;
2058 default: 1808 default:
2059 printk(KERN_INFO "s2255 unknown resp\n"); 1809 pr_info("s2255 unknown resp\n");
2060 } 1810 }
2061 default: 1811 default:
2062 pdata++; 1812 pdata++;
@@ -2068,11 +1818,11 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2068 if (!bframe) 1818 if (!bframe)
2069 return -EINVAL; 1819 return -EINVAL;
2070 } 1820 }
2071 channel = &dev->channel[dev->cc]; 1821 vc = &dev->vc[dev->cc];
2072 idx = channel->cur_frame; 1822 idx = vc->cur_frame;
2073 frm = &channel->buffer.frame[idx]; 1823 frm = &vc->buffer.frame[idx];
2074 /* search done. now find out if should be acquiring on this channel */ 1824 /* search done. now find out if should be acquiring on this channel */
2075 if (!channel->b_acquire) { 1825 if (!vb2_is_streaming(&vc->vb_vidq)) {
2076 /* we found a frame, but this channel is turned off */ 1826 /* we found a frame, but this channel is turned off */
2077 frm->ulState = S2255_READ_IDLE; 1827 frm->ulState = S2255_READ_IDLE;
2078 return -EINVAL; 1828 return -EINVAL;
@@ -2088,7 +1838,7 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2088 1838
2089 1839
2090 if (frm->lpvbits == NULL) { 1840 if (frm->lpvbits == NULL) {
2091 dprintk(1, "s2255 frame buffer == NULL.%p %p %d %d", 1841 dprintk(dev, 1, "s2255 frame buffer == NULL.%p %p %d %d",
2092 frm, dev, dev->cc, idx); 1842 frm, dev, dev->cc, idx);
2093 return -ENOMEM; 1843 return -ENOMEM;
2094 } 1844 }
@@ -2097,28 +1847,28 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info)
2097 1847
2098 copy_size = (pipe_info->cur_transfer_size - offset); 1848 copy_size = (pipe_info->cur_transfer_size - offset);
2099 1849
2100 size = channel->pkt_size - PREFIX_SIZE; 1850 size = vc->pkt_size - PREFIX_SIZE;
2101 1851
2102 /* sanity check on pdest */ 1852 /* sanity check on pdest */
2103 if ((copy_size + frm->cur_size) < channel->req_image_size) 1853 if ((copy_size + frm->cur_size) < vc->req_image_size)
2104 memcpy(pdest, psrc, copy_size); 1854 memcpy(pdest, psrc, copy_size);
2105 1855
2106 frm->cur_size += copy_size; 1856 frm->cur_size += copy_size;
2107 dprintk(4, "cur_size size %lu size %lu \n", frm->cur_size, size); 1857 dprintk(dev, 4, "cur_size: %lu, size: %lu\n", frm->cur_size, size);
2108 1858
2109 if (frm->cur_size >= size) { 1859 if (frm->cur_size >= size) {
2110 dprintk(2, "****************[%d]Buffer[%d]full*************\n", 1860 dprintk(dev, 2, "******[%d]Buffer[%d]full*******\n",
2111 dev->cc, idx); 1861 dev->cc, idx);
2112 channel->last_frame = channel->cur_frame; 1862 vc->last_frame = vc->cur_frame;
2113 channel->cur_frame++; 1863 vc->cur_frame++;
2114 /* end of system frame ring buffer, start at zero */ 1864 /* end of system frame ring buffer, start at zero */
2115 if ((channel->cur_frame == SYS_FRAMES) || 1865 if ((vc->cur_frame == SYS_FRAMES) ||
2116 (channel->cur_frame == channel->buffer.dwFrames)) 1866 (vc->cur_frame == vc->buffer.dwFrames))
2117 channel->cur_frame = 0; 1867 vc->cur_frame = 0;
2118 /* frame ready */ 1868 /* frame ready */
2119 if (channel->b_acquire) 1869 if (vb2_is_streaming(&vc->vb_vidq))
2120 s2255_got_frame(channel, channel->jpg_size); 1870 s2255_got_frame(vc, vc->jpg_size);
2121 channel->frame_count++; 1871 vc->frame_count++;
2122 frm->ulState = S2255_READ_IDLE; 1872 frm->ulState = S2255_READ_IDLE;
2123 frm->cur_size = 0; 1873 frm->cur_size = 0;
2124 1874
@@ -2131,7 +1881,7 @@ static void s2255_read_video_callback(struct s2255_dev *dev,
2131 struct s2255_pipeinfo *pipe_info) 1881 struct s2255_pipeinfo *pipe_info)
2132{ 1882{
2133 int res; 1883 int res;
2134 dprintk(50, "callback read video \n"); 1884 dprintk(dev, 50, "callback read video\n");
2135 1885
2136 if (dev->cc >= MAX_CHANNELS) { 1886 if (dev->cc >= MAX_CHANNELS) {
2137 dev->cc = 0; 1887 dev->cc = 0;
@@ -2141,9 +1891,9 @@ static void s2255_read_video_callback(struct s2255_dev *dev,
2141 /* otherwise copy to the system buffers */ 1891 /* otherwise copy to the system buffers */
2142 res = save_frame(dev, pipe_info); 1892 res = save_frame(dev, pipe_info);
2143 if (res != 0) 1893 if (res != 0)
2144 dprintk(4, "s2255: read callback failed\n"); 1894 dprintk(dev, 4, "s2255: read callback failed\n");
2145 1895
2146 dprintk(50, "callback read video done\n"); 1896 dprintk(dev, 50, "callback read video done\n");
2147 return; 1897 return;
2148} 1898}
2149 1899
@@ -2181,9 +1931,9 @@ static int s2255_get_fx2fw(struct s2255_dev *dev)
2181 ret = s2255_vendor_req(dev, S2255_VR_FW, 0, 0, transBuffer, 2, 1931 ret = s2255_vendor_req(dev, S2255_VR_FW, 0, 0, transBuffer, 2,
2182 S2255_VR_IN); 1932 S2255_VR_IN);
2183 if (ret < 0) 1933 if (ret < 0)
2184 dprintk(2, "get fw error: %x\n", ret); 1934 dprintk(dev, 2, "get fw error: %x\n", ret);
2185 fw = transBuffer[0] + (transBuffer[1] << 8); 1935 fw = transBuffer[0] + (transBuffer[1] << 8);
2186 dprintk(2, "Get FW %x %x\n", transBuffer[0], transBuffer[1]); 1936 dprintk(dev, 2, "Get FW %x %x\n", transBuffer[0], transBuffer[1]);
2187 return fw; 1937 return fw;
2188} 1938}
2189 1939
@@ -2191,12 +1941,11 @@ static int s2255_get_fx2fw(struct s2255_dev *dev)
2191 * Create the system ring buffer to copy frames into from the 1941 * Create the system ring buffer to copy frames into from the
2192 * usb read pipe. 1942 * usb read pipe.
2193 */ 1943 */
2194static int s2255_create_sys_buffers(struct s2255_channel *channel) 1944static int s2255_create_sys_buffers(struct s2255_vc *vc)
2195{ 1945{
2196 unsigned long i; 1946 unsigned long i;
2197 unsigned long reqsize; 1947 unsigned long reqsize;
2198 dprintk(1, "create sys buffers\n"); 1948 vc->buffer.dwFrames = SYS_FRAMES;
2199 channel->buffer.dwFrames = SYS_FRAMES;
2200 /* always allocate maximum size(PAL) for system buffers */ 1949 /* always allocate maximum size(PAL) for system buffers */
2201 reqsize = SYS_FRAMES_MAXSIZE; 1950 reqsize = SYS_FRAMES_MAXSIZE;
2202 1951
@@ -2205,40 +1954,33 @@ static int s2255_create_sys_buffers(struct s2255_channel *channel)
2205 1954
2206 for (i = 0; i < SYS_FRAMES; i++) { 1955 for (i = 0; i < SYS_FRAMES; i++) {
2207 /* allocate the frames */ 1956 /* allocate the frames */
2208 channel->buffer.frame[i].lpvbits = vmalloc(reqsize); 1957 vc->buffer.frame[i].lpvbits = vmalloc(reqsize);
2209 dprintk(1, "valloc %p chan %d, idx %lu, pdata %p\n", 1958 vc->buffer.frame[i].size = reqsize;
2210 &channel->buffer.frame[i], channel->idx, i, 1959 if (vc->buffer.frame[i].lpvbits == NULL) {
2211 channel->buffer.frame[i].lpvbits); 1960 pr_info("out of memory. using less frames\n");
2212 channel->buffer.frame[i].size = reqsize; 1961 vc->buffer.dwFrames = i;
2213 if (channel->buffer.frame[i].lpvbits == NULL) {
2214 printk(KERN_INFO "out of memory. using less frames\n");
2215 channel->buffer.dwFrames = i;
2216 break; 1962 break;
2217 } 1963 }
2218 } 1964 }
2219 1965
2220 /* make sure internal states are set */ 1966 /* make sure internal states are set */
2221 for (i = 0; i < SYS_FRAMES; i++) { 1967 for (i = 0; i < SYS_FRAMES; i++) {
2222 channel->buffer.frame[i].ulState = 0; 1968 vc->buffer.frame[i].ulState = 0;
2223 channel->buffer.frame[i].cur_size = 0; 1969 vc->buffer.frame[i].cur_size = 0;
2224 } 1970 }
2225 1971
2226 channel->cur_frame = 0; 1972 vc->cur_frame = 0;
2227 channel->last_frame = -1; 1973 vc->last_frame = -1;
2228 return 0; 1974 return 0;
2229} 1975}
2230 1976
2231static int s2255_release_sys_buffers(struct s2255_channel *channel) 1977static int s2255_release_sys_buffers(struct s2255_vc *vc)
2232{ 1978{
2233 unsigned long i; 1979 unsigned long i;
2234 dprintk(1, "release sys buffers\n");
2235 for (i = 0; i < SYS_FRAMES; i++) { 1980 for (i = 0; i < SYS_FRAMES; i++) {
2236 if (channel->buffer.frame[i].lpvbits) { 1981 if (vc->buffer.frame[i].lpvbits)
2237 dprintk(1, "vfree %p\n", 1982 vfree(vc->buffer.frame[i].lpvbits);
2238 channel->buffer.frame[i].lpvbits); 1983 vc->buffer.frame[i].lpvbits = NULL;
2239 vfree(channel->buffer.frame[i].lpvbits);
2240 }
2241 channel->buffer.frame[i].lpvbits = NULL;
2242 } 1984 }
2243 return 0; 1985 return 0;
2244} 1986}
@@ -2249,7 +1991,7 @@ static int s2255_board_init(struct s2255_dev *dev)
2249 int fw_ver; 1991 int fw_ver;
2250 int j; 1992 int j;
2251 struct s2255_pipeinfo *pipe = &dev->pipe; 1993 struct s2255_pipeinfo *pipe = &dev->pipe;
2252 dprintk(4, "board init: %p", dev); 1994 dprintk(dev, 4, "board init: %p", dev);
2253 memset(pipe, 0, sizeof(*pipe)); 1995 memset(pipe, 0, sizeof(*pipe));
2254 pipe->dev = dev; 1996 pipe->dev = dev;
2255 pipe->cur_transfer_size = S2255_USB_XFER_SIZE; 1997 pipe->cur_transfer_size = S2255_USB_XFER_SIZE;
@@ -2258,54 +2000,53 @@ static int s2255_board_init(struct s2255_dev *dev)
2258 pipe->transfer_buffer = kzalloc(pipe->max_transfer_size, 2000 pipe->transfer_buffer = kzalloc(pipe->max_transfer_size,
2259 GFP_KERNEL); 2001 GFP_KERNEL);
2260 if (pipe->transfer_buffer == NULL) { 2002 if (pipe->transfer_buffer == NULL) {
2261 dprintk(1, "out of memory!\n"); 2003 dprintk(dev, 1, "out of memory!\n");
2262 return -ENOMEM; 2004 return -ENOMEM;
2263 } 2005 }
2264 /* query the firmware */ 2006 /* query the firmware */
2265 fw_ver = s2255_get_fx2fw(dev); 2007 fw_ver = s2255_get_fx2fw(dev);
2266 2008
2267 printk(KERN_INFO "s2255: usb firmware version %d.%d\n", 2009 pr_info("s2255: usb firmware version %d.%d\n",
2268 (fw_ver >> 8) & 0xff, 2010 (fw_ver >> 8) & 0xff,
2269 fw_ver & 0xff); 2011 fw_ver & 0xff);
2270 2012
2271 if (fw_ver < S2255_CUR_USB_FWVER) 2013 if (fw_ver < S2255_CUR_USB_FWVER)
2272 printk(KERN_INFO "s2255: newer USB firmware available\n"); 2014 pr_info("s2255: newer USB firmware available\n");
2273 2015
2274 for (j = 0; j < MAX_CHANNELS; j++) { 2016 for (j = 0; j < MAX_CHANNELS; j++) {
2275 struct s2255_channel *channel = &dev->channel[j]; 2017 struct s2255_vc *vc = &dev->vc[j];
2276 channel->b_acquire = 0; 2018 vc->mode = mode_def;
2277 channel->mode = mode_def;
2278 if (dev->pid == 0x2257 && j > 1) 2019 if (dev->pid == 0x2257 && j > 1)
2279 channel->mode.color |= (1 << 16); 2020 vc->mode.color |= (1 << 16);
2280 channel->jpegqual = S2255_DEF_JPEG_QUAL; 2021 vc->jpegqual = S2255_DEF_JPEG_QUAL;
2281 channel->width = LINE_SZ_4CIFS_NTSC; 2022 vc->width = LINE_SZ_4CIFS_NTSC;
2282 channel->height = NUM_LINES_4CIFS_NTSC * 2; 2023 vc->height = NUM_LINES_4CIFS_NTSC * 2;
2283 channel->std = V4L2_STD_NTSC_M; 2024 vc->std = V4L2_STD_NTSC_M;
2284 channel->fmt = &formats[0]; 2025 vc->fmt = &formats[0];
2285 channel->mode.restart = 1; 2026 vc->mode.restart = 1;
2286 channel->req_image_size = get_transfer_size(&mode_def); 2027 vc->req_image_size = get_transfer_size(&mode_def);
2287 channel->frame_count = 0; 2028 vc->frame_count = 0;
2288 /* create the system buffers */ 2029 /* create the system buffers */
2289 s2255_create_sys_buffers(channel); 2030 s2255_create_sys_buffers(vc);
2290 } 2031 }
2291 /* start read pipe */ 2032 /* start read pipe */
2292 s2255_start_readpipe(dev); 2033 s2255_start_readpipe(dev);
2293 dprintk(1, "%s: success\n", __func__); 2034 dprintk(dev, 1, "%s: success\n", __func__);
2294 return 0; 2035 return 0;
2295} 2036}
2296 2037
2297static int s2255_board_shutdown(struct s2255_dev *dev) 2038static int s2255_board_shutdown(struct s2255_dev *dev)
2298{ 2039{
2299 u32 i; 2040 u32 i;
2300 dprintk(1, "%s: dev: %p", __func__, dev); 2041 dprintk(dev, 1, "%s: dev: %p", __func__, dev);
2301 2042
2302 for (i = 0; i < MAX_CHANNELS; i++) { 2043 for (i = 0; i < MAX_CHANNELS; i++) {
2303 if (dev->channel[i].b_acquire) 2044 if (vb2_is_streaming(&dev->vc[i].vb_vidq))
2304 s2255_stop_acquire(&dev->channel[i]); 2045 s2255_stop_acquire(&dev->vc[i]);
2305 } 2046 }
2306 s2255_stop_readpipe(dev); 2047 s2255_stop_readpipe(dev);
2307 for (i = 0; i < MAX_CHANNELS; i++) 2048 for (i = 0; i < MAX_CHANNELS; i++)
2308 s2255_release_sys_buffers(&dev->channel[i]); 2049 s2255_release_sys_buffers(&dev->vc[i]);
2309 /* release transfer buffer */ 2050 /* release transfer buffer */
2310 kfree(dev->pipe.transfer_buffer); 2051 kfree(dev->pipe.transfer_buffer);
2311 return 0; 2052 return 0;
@@ -2318,13 +2059,10 @@ static void read_pipe_completion(struct urb *purb)
2318 int status; 2059 int status;
2319 int pipe; 2060 int pipe;
2320 pipe_info = purb->context; 2061 pipe_info = purb->context;
2321 dprintk(100, "%s: urb:%p, status %d\n", __func__, purb,
2322 purb->status);
2323 if (pipe_info == NULL) { 2062 if (pipe_info == NULL) {
2324 dev_err(&purb->dev->dev, "no context!\n"); 2063 dev_err(&purb->dev->dev, "no context!\n");
2325 return; 2064 return;
2326 } 2065 }
2327
2328 dev = pipe_info->dev; 2066 dev = pipe_info->dev;
2329 if (dev == NULL) { 2067 if (dev == NULL) {
2330 dev_err(&purb->dev->dev, "no context!\n"); 2068 dev_err(&purb->dev->dev, "no context!\n");
@@ -2333,13 +2071,13 @@ static void read_pipe_completion(struct urb *purb)
2333 status = purb->status; 2071 status = purb->status;
2334 /* if shutting down, do not resubmit, exit immediately */ 2072 /* if shutting down, do not resubmit, exit immediately */
2335 if (status == -ESHUTDOWN) { 2073 if (status == -ESHUTDOWN) {
2336 dprintk(2, "%s: err shutdown\n", __func__); 2074 dprintk(dev, 2, "%s: err shutdown\n", __func__);
2337 pipe_info->err_count++; 2075 pipe_info->err_count++;
2338 return; 2076 return;
2339 } 2077 }
2340 2078
2341 if (pipe_info->state == 0) { 2079 if (pipe_info->state == 0) {
2342 dprintk(2, "%s: exiting USB pipe", __func__); 2080 dprintk(dev, 2, "%s: exiting USB pipe", __func__);
2343 return; 2081 return;
2344 } 2082 }
2345 2083
@@ -2347,7 +2085,7 @@ static void read_pipe_completion(struct urb *purb)
2347 s2255_read_video_callback(dev, pipe_info); 2085 s2255_read_video_callback(dev, pipe_info);
2348 else { 2086 else {
2349 pipe_info->err_count++; 2087 pipe_info->err_count++;
2350 dprintk(1, "%s: failed URB %d\n", __func__, status); 2088 dprintk(dev, 1, "%s: failed URB %d\n", __func__, status);
2351 } 2089 }
2352 2090
2353 pipe = usb_rcvbulkpipe(dev->udev, dev->read_endpoint); 2091 pipe = usb_rcvbulkpipe(dev->udev, dev->read_endpoint);
@@ -2359,11 +2097,10 @@ static void read_pipe_completion(struct urb *purb)
2359 read_pipe_completion, pipe_info); 2097 read_pipe_completion, pipe_info);
2360 2098
2361 if (pipe_info->state != 0) { 2099 if (pipe_info->state != 0) {
2362 if (usb_submit_urb(pipe_info->stream_urb, GFP_ATOMIC)) { 2100 if (usb_submit_urb(pipe_info->stream_urb, GFP_ATOMIC))
2363 dev_err(&dev->udev->dev, "error submitting urb\n"); 2101 dev_err(&dev->udev->dev, "error submitting urb\n");
2364 }
2365 } else { 2102 } else {
2366 dprintk(2, "%s :complete state 0\n", __func__); 2103 dprintk(dev, 2, "%s :complete state 0\n", __func__);
2367 } 2104 }
2368 return; 2105 return;
2369} 2106}
@@ -2374,7 +2111,7 @@ static int s2255_start_readpipe(struct s2255_dev *dev)
2374 int retval; 2111 int retval;
2375 struct s2255_pipeinfo *pipe_info = &dev->pipe; 2112 struct s2255_pipeinfo *pipe_info = &dev->pipe;
2376 pipe = usb_rcvbulkpipe(dev->udev, dev->read_endpoint); 2113 pipe = usb_rcvbulkpipe(dev->udev, dev->read_endpoint);
2377 dprintk(2, "%s: IN %d\n", __func__, dev->read_endpoint); 2114 dprintk(dev, 2, "%s: IN %d\n", __func__, dev->read_endpoint);
2378 pipe_info->state = 1; 2115 pipe_info->state = 1;
2379 pipe_info->err_count = 0; 2116 pipe_info->err_count = 0;
2380 pipe_info->stream_urb = usb_alloc_urb(0, GFP_KERNEL); 2117 pipe_info->stream_urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -2391,70 +2128,64 @@ static int s2255_start_readpipe(struct s2255_dev *dev)
2391 read_pipe_completion, pipe_info); 2128 read_pipe_completion, pipe_info);
2392 retval = usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL); 2129 retval = usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL);
2393 if (retval) { 2130 if (retval) {
2394 printk(KERN_ERR "s2255: start read pipe failed\n"); 2131 pr_err("s2255: start read pipe failed\n");
2395 return retval; 2132 return retval;
2396 } 2133 }
2397 return 0; 2134 return 0;
2398} 2135}
2399 2136
2400/* starts acquisition process */ 2137/* starts acquisition process */
2401static int s2255_start_acquire(struct s2255_channel *channel) 2138static int s2255_start_acquire(struct s2255_vc *vc)
2402{ 2139{
2403 unsigned char *buffer;
2404 int res; 2140 int res;
2405 unsigned long chn_rev; 2141 unsigned long chn_rev;
2406 int j; 2142 int j;
2407 struct s2255_dev *dev = to_s2255_dev(channel->vdev.v4l2_dev); 2143 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
2408 chn_rev = G_chnmap[channel->idx]; 2144 __le32 *buffer = dev->cmdbuf;
2409 buffer = kzalloc(512, GFP_KERNEL); 2145
2410 if (buffer == NULL) { 2146 mutex_lock(&dev->cmdlock);
2411 dev_err(&dev->udev->dev, "out of mem\n"); 2147 chn_rev = G_chnmap[vc->idx];
2412 return -ENOMEM; 2148 vc->last_frame = -1;
2413 } 2149 vc->bad_payload = 0;
2414 2150 vc->cur_frame = 0;
2415 channel->last_frame = -1;
2416 channel->bad_payload = 0;
2417 channel->cur_frame = 0;
2418 for (j = 0; j < SYS_FRAMES; j++) { 2151 for (j = 0; j < SYS_FRAMES; j++) {
2419 channel->buffer.frame[j].ulState = 0; 2152 vc->buffer.frame[j].ulState = 0;
2420 channel->buffer.frame[j].cur_size = 0; 2153 vc->buffer.frame[j].cur_size = 0;
2421 } 2154 }
2422 2155
2423 /* send the start command */ 2156 /* send the start command */
2424 *(__le32 *) buffer = IN_DATA_TOKEN; 2157 buffer[0] = IN_DATA_TOKEN;
2425 *((__le32 *) buffer + 1) = (__le32) cpu_to_le32(chn_rev); 2158 buffer[1] = (__le32) cpu_to_le32(chn_rev);
2426 *((__le32 *) buffer + 2) = CMD_START; 2159 buffer[2] = CMD_START;
2427 res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512); 2160 res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512);
2428 if (res != 0) 2161 if (res != 0)
2429 dev_err(&dev->udev->dev, "CMD_START error\n"); 2162 dev_err(&dev->udev->dev, "CMD_START error\n");
2430 2163
2431 dprintk(2, "start acquire exit[%d] %d \n", channel->idx, res); 2164 dprintk(dev, 2, "start acquire exit[%d] %d\n", vc->idx, res);
2432 kfree(buffer); 2165 mutex_unlock(&dev->cmdlock);
2433 return 0; 2166 return res;
2434} 2167}
2435 2168
2436static int s2255_stop_acquire(struct s2255_channel *channel) 2169static int s2255_stop_acquire(struct s2255_vc *vc)
2437{ 2170{
2438 unsigned char *buffer;
2439 int res; 2171 int res;
2440 unsigned long chn_rev; 2172 unsigned long chn_rev;
2441 struct s2255_dev *dev = to_s2255_dev(channel->vdev.v4l2_dev); 2173 struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev);
2442 chn_rev = G_chnmap[channel->idx]; 2174 __le32 *buffer = dev->cmdbuf;
2443 buffer = kzalloc(512, GFP_KERNEL); 2175
2444 if (buffer == NULL) { 2176 mutex_lock(&dev->cmdlock);
2445 dev_err(&dev->udev->dev, "out of mem\n"); 2177 chn_rev = G_chnmap[vc->idx];
2446 return -ENOMEM;
2447 }
2448 /* send the stop command */ 2178 /* send the stop command */
2449 *(__le32 *) buffer = IN_DATA_TOKEN; 2179 buffer[0] = IN_DATA_TOKEN;
2450 *((__le32 *) buffer + 1) = (__le32) cpu_to_le32(chn_rev); 2180 buffer[1] = (__le32) cpu_to_le32(chn_rev);
2451 *((__le32 *) buffer + 2) = CMD_STOP; 2181 buffer[2] = CMD_STOP;
2182
2452 res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512); 2183 res = s2255_write_config(dev->udev, (unsigned char *)buffer, 512);
2453 if (res != 0) 2184 if (res != 0)
2454 dev_err(&dev->udev->dev, "CMD_STOP error\n"); 2185 dev_err(&dev->udev->dev, "CMD_STOP error\n");
2455 kfree(buffer); 2186
2456 channel->b_acquire = 0; 2187 dprintk(dev, 4, "%s: chn %d, res %d\n", __func__, vc->idx, res);
2457 dprintk(4, "%s: chn %d, res %d\n", __func__, channel->idx, res); 2188 mutex_unlock(&dev->cmdlock);
2458 return res; 2189 return res;
2459} 2190}
2460 2191
@@ -2469,7 +2200,7 @@ static void s2255_stop_readpipe(struct s2255_dev *dev)
2469 usb_free_urb(pipe->stream_urb); 2200 usb_free_urb(pipe->stream_urb);
2470 pipe->stream_urb = NULL; 2201 pipe->stream_urb = NULL;
2471 } 2202 }
2472 dprintk(4, "%s", __func__); 2203 dprintk(dev, 4, "%s", __func__);
2473 return; 2204 return;
2474} 2205}
2475 2206
@@ -2501,19 +2232,27 @@ static int s2255_probe(struct usb_interface *interface,
2501 int retval = -ENOMEM; 2232 int retval = -ENOMEM;
2502 __le32 *pdata; 2233 __le32 *pdata;
2503 int fw_size; 2234 int fw_size;
2504 dprintk(2, "%s\n", __func__); 2235
2505 /* allocate memory for our device state and initialize it to zero */ 2236 /* allocate memory for our device state and initialize it to zero */
2506 dev = kzalloc(sizeof(struct s2255_dev), GFP_KERNEL); 2237 dev = kzalloc(sizeof(struct s2255_dev), GFP_KERNEL);
2507 if (dev == NULL) { 2238 if (dev == NULL) {
2508 s2255_dev_err(&interface->dev, "out of memory\n"); 2239 s2255_dev_err(&interface->dev, "out of memory\n");
2509 return -ENOMEM; 2240 return -ENOMEM;
2510 } 2241 }
2242
2243 dev->cmdbuf = kzalloc(S2255_CMDBUF_SIZE, GFP_KERNEL);
2244 if (dev->cmdbuf == NULL) {
2245 s2255_dev_err(&interface->dev, "out of memory\n");
2246 return -ENOMEM;
2247 }
2248
2511 atomic_set(&dev->num_channels, 0); 2249 atomic_set(&dev->num_channels, 0);
2512 dev->pid = le16_to_cpu(id->idProduct); 2250 dev->pid = le16_to_cpu(id->idProduct);
2513 dev->fw_data = kzalloc(sizeof(struct s2255_fw), GFP_KERNEL); 2251 dev->fw_data = kzalloc(sizeof(struct s2255_fw), GFP_KERNEL);
2514 if (!dev->fw_data) 2252 if (!dev->fw_data)
2515 goto errorFWDATA1; 2253 goto errorFWDATA1;
2516 mutex_init(&dev->lock); 2254 mutex_init(&dev->lock);
2255 mutex_init(&dev->cmdlock);
2517 /* grab usb_device and save it */ 2256 /* grab usb_device and save it */
2518 dev->udev = usb_get_dev(interface_to_usbdev(interface)); 2257 dev->udev = usb_get_dev(interface_to_usbdev(interface));
2519 if (dev->udev == NULL) { 2258 if (dev->udev == NULL) {
@@ -2521,12 +2260,13 @@ static int s2255_probe(struct usb_interface *interface,
2521 retval = -ENODEV; 2260 retval = -ENODEV;
2522 goto errorUDEV; 2261 goto errorUDEV;
2523 } 2262 }
2524 dprintk(1, "dev: %p, udev %p interface %p\n", dev, 2263 dev_dbg(&interface->dev, "dev: %p, udev %p interface %p\n",
2525 dev->udev, interface); 2264 dev, dev->udev, interface);
2526 dev->interface = interface; 2265 dev->interface = interface;
2527 /* set up the endpoint information */ 2266 /* set up the endpoint information */
2528 iface_desc = interface->cur_altsetting; 2267 iface_desc = interface->cur_altsetting;
2529 dprintk(1, "num endpoints %d\n", iface_desc->desc.bNumEndpoints); 2268 dev_dbg(&interface->dev, "num EP: %d\n",
2269 iface_desc->desc.bNumEndpoints);
2530 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 2270 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
2531 endpoint = &iface_desc->endpoint[i].desc; 2271 endpoint = &iface_desc->endpoint[i].desc;
2532 if (!dev->read_endpoint && usb_endpoint_is_bulk_in(endpoint)) { 2272 if (!dev->read_endpoint && usb_endpoint_is_bulk_in(endpoint)) {
@@ -2544,10 +2284,13 @@ static int s2255_probe(struct usb_interface *interface,
2544 dev->timer.data = (unsigned long)dev->fw_data; 2284 dev->timer.data = (unsigned long)dev->fw_data;
2545 init_waitqueue_head(&dev->fw_data->wait_fw); 2285 init_waitqueue_head(&dev->fw_data->wait_fw);
2546 for (i = 0; i < MAX_CHANNELS; i++) { 2286 for (i = 0; i < MAX_CHANNELS; i++) {
2547 struct s2255_channel *channel = &dev->channel[i]; 2287 struct s2255_vc *vc = &dev->vc[i];
2548 dev->channel[i].idx = i; 2288 vc->idx = i;
2549 init_waitqueue_head(&channel->wait_setmode); 2289 vc->dev = dev;
2550 init_waitqueue_head(&channel->wait_vidstatus); 2290 init_waitqueue_head(&vc->wait_setmode);
2291 init_waitqueue_head(&vc->wait_vidstatus);
2292 spin_lock_init(&vc->qlock);
2293 mutex_init(&vc->vb_lock);
2551 } 2294 }
2552 2295
2553 dev->fw_data->fw_urb = usb_alloc_urb(0, GFP_KERNEL); 2296 dev->fw_data->fw_urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -2564,7 +2307,7 @@ static int s2255_probe(struct usb_interface *interface,
2564 /* load the first chunk */ 2307 /* load the first chunk */
2565 if (request_firmware(&dev->fw_data->fw, 2308 if (request_firmware(&dev->fw_data->fw,
2566 FIRMWARE_FILE_NAME, &dev->udev->dev)) { 2309 FIRMWARE_FILE_NAME, &dev->udev->dev)) {
2567 printk(KERN_ERR "sensoray 2255 failed to get firmware\n"); 2310 dev_err(&interface->dev, "sensoray 2255 failed to get firmware\n");
2568 goto errorREQFW; 2311 goto errorREQFW;
2569 } 2312 }
2570 /* check the firmware is valid */ 2313 /* check the firmware is valid */
@@ -2572,28 +2315,27 @@ static int s2255_probe(struct usb_interface *interface,
2572 pdata = (__le32 *) &dev->fw_data->fw->data[fw_size - 8]; 2315 pdata = (__le32 *) &dev->fw_data->fw->data[fw_size - 8];
2573 2316
2574 if (*pdata != S2255_FW_MARKER) { 2317 if (*pdata != S2255_FW_MARKER) {
2575 printk(KERN_INFO "Firmware invalid.\n"); 2318 dev_err(&interface->dev, "Firmware invalid.\n");
2576 retval = -ENODEV; 2319 retval = -ENODEV;
2577 goto errorFWMARKER; 2320 goto errorFWMARKER;
2578 } else { 2321 } else {
2579 /* make sure firmware is the latest */ 2322 /* make sure firmware is the latest */
2580 __le32 *pRel; 2323 __le32 *pRel;
2581 pRel = (__le32 *) &dev->fw_data->fw->data[fw_size - 4]; 2324 pRel = (__le32 *) &dev->fw_data->fw->data[fw_size - 4];
2582 printk(KERN_INFO "s2255 dsp fw version %x\n", le32_to_cpu(*pRel)); 2325 pr_info("s2255 dsp fw version %x\n", le32_to_cpu(*pRel));
2583 dev->dsp_fw_ver = le32_to_cpu(*pRel); 2326 dev->dsp_fw_ver = le32_to_cpu(*pRel);
2584 if (dev->dsp_fw_ver < S2255_CUR_DSP_FWVER) 2327 if (dev->dsp_fw_ver < S2255_CUR_DSP_FWVER)
2585 printk(KERN_INFO "s2255: f2255usb.bin out of date.\n"); 2328 pr_info("s2255: f2255usb.bin out of date.\n");
2586 if (dev->pid == 0x2257 && 2329 if (dev->pid == 0x2257 &&
2587 dev->dsp_fw_ver < S2255_MIN_DSP_COLORFILTER) 2330 dev->dsp_fw_ver < S2255_MIN_DSP_COLORFILTER)
2588 printk(KERN_WARNING "s2255: 2257 requires firmware %d" 2331 pr_warn("2257 needs firmware %d or above.\n",
2589 " or above.\n", S2255_MIN_DSP_COLORFILTER); 2332 S2255_MIN_DSP_COLORFILTER);
2590 } 2333 }
2591 usb_reset_device(dev->udev); 2334 usb_reset_device(dev->udev);
2592 /* load 2255 board specific */ 2335 /* load 2255 board specific */
2593 retval = s2255_board_init(dev); 2336 retval = s2255_board_init(dev);
2594 if (retval) 2337 if (retval)
2595 goto errorBOARDINIT; 2338 goto errorBOARDINIT;
2596 spin_lock_init(&dev->slock);
2597 s2255_fwload_start(dev, 0); 2339 s2255_fwload_start(dev, 0);
2598 /* loads v4l specific */ 2340 /* loads v4l specific */
2599 retval = s2255_probe_v4l(dev); 2341 retval = s2255_probe_v4l(dev);
@@ -2617,8 +2359,9 @@ errorUDEV:
2617 kfree(dev->fw_data); 2359 kfree(dev->fw_data);
2618 mutex_destroy(&dev->lock); 2360 mutex_destroy(&dev->lock);
2619errorFWDATA1: 2361errorFWDATA1:
2362 kfree(dev->cmdbuf);
2620 kfree(dev); 2363 kfree(dev);
2621 printk(KERN_WARNING "Sensoray 2255 driver load failed: 0x%x\n", retval); 2364 pr_warn("Sensoray 2255 driver load failed: 0x%x\n", retval);
2622 return retval; 2365 return retval;
2623} 2366}
2624 2367
@@ -2635,15 +2378,15 @@ static void s2255_disconnect(struct usb_interface *interface)
2635 atomic_inc(&dev->num_channels); 2378 atomic_inc(&dev->num_channels);
2636 /* unregister each video device. */ 2379 /* unregister each video device. */
2637 for (i = 0; i < channels; i++) 2380 for (i = 0; i < channels; i++)
2638 video_unregister_device(&dev->channel[i].vdev); 2381 video_unregister_device(&dev->vc[i].vdev);
2639 /* wake up any of our timers */ 2382 /* wake up any of our timers */
2640 atomic_set(&dev->fw_data->fw_state, S2255_FW_DISCONNECTING); 2383 atomic_set(&dev->fw_data->fw_state, S2255_FW_DISCONNECTING);
2641 wake_up(&dev->fw_data->wait_fw); 2384 wake_up(&dev->fw_data->wait_fw);
2642 for (i = 0; i < MAX_CHANNELS; i++) { 2385 for (i = 0; i < MAX_CHANNELS; i++) {
2643 dev->channel[i].setmode_ready = 1; 2386 dev->vc[i].setmode_ready = 1;
2644 wake_up(&dev->channel[i].wait_setmode); 2387 wake_up(&dev->vc[i].wait_setmode);
2645 dev->channel[i].vidstatus_ready = 1; 2388 dev->vc[i].vidstatus_ready = 1;
2646 wake_up(&dev->channel[i].wait_vidstatus); 2389 wake_up(&dev->vc[i].wait_vidstatus);
2647 } 2390 }
2648 if (atomic_dec_and_test(&dev->num_channels)) 2391 if (atomic_dec_and_test(&dev->num_channels))
2649 s2255_destroy(dev); 2392 s2255_destroy(dev);
diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index 05bd91a60c09..1836a416d806 100644
--- a/drivers/media/usb/siano/smsusb.c
+++ b/drivers/media/usb/siano/smsusb.c
@@ -653,6 +653,8 @@ static const struct usb_device_id smsusb_id_table[] = {
653 .driver_info = SMS1XXX_BOARD_ZTE_DVB_DATA_CARD }, 653 .driver_info = SMS1XXX_BOARD_ZTE_DVB_DATA_CARD },
654 { USB_DEVICE(0x19D2, 0x0078), 654 { USB_DEVICE(0x19D2, 0x0078),
655 .driver_info = SMS1XXX_BOARD_ONDA_MDTV_DATA_CARD }, 655 .driver_info = SMS1XXX_BOARD_ONDA_MDTV_DATA_CARD },
656 { USB_DEVICE(0x3275, 0x0080),
657 .driver_info = SMS1XXX_BOARD_SIANO_RIO },
656 { } /* Terminating entry */ 658 { } /* Terminating entry */
657 }; 659 };
658 660
diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c b/drivers/media/usb/stk1160/stk1160-v4l.c
index c45c9881bb5f..37bc00f418f1 100644
--- a/drivers/media/usb/stk1160/stk1160-v4l.c
+++ b/drivers/media/usb/stk1160/stk1160-v4l.c
@@ -641,7 +641,7 @@ int stk1160_vb2_setup(struct stk1160 *dev)
641 q->buf_struct_size = sizeof(struct stk1160_buffer); 641 q->buf_struct_size = sizeof(struct stk1160_buffer);
642 q->ops = &stk1160_video_qops; 642 q->ops = &stk1160_video_qops;
643 q->mem_ops = &vb2_vmalloc_memops; 643 q->mem_ops = &vb2_vmalloc_memops;
644 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 644 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
645 645
646 rc = vb2_queue_init(q); 646 rc = vb2_queue_init(q);
647 if (rc < 0) 647 if (rc < 0)
diff --git a/drivers/media/usb/tm6000/tm6000-alsa.c b/drivers/media/usb/tm6000/tm6000-alsa.c
index 3239cd62e452..74e5697d8678 100644
--- a/drivers/media/usb/tm6000/tm6000-alsa.c
+++ b/drivers/media/usb/tm6000/tm6000-alsa.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * 2 *
3 * Support for audio capture for tm5600/6000/6010 3 * Support for audio capture for tm5600/6000/6010
4 * (c) 2007-2008 Mauro Carvalho Chehab <mchehab@redhat.com> 4 * (c) 2007-2008 Mauro Carvalho Chehab
5 * 5 *
6 * Based on cx88-alsa.c 6 * Based on cx88-alsa.c
7 * 7 *
@@ -56,7 +56,7 @@ MODULE_PARM_DESC(index, "Index value for tm6000x capture interface(s).");
56 ****************************************************************************/ 56 ****************************************************************************/
57 57
58MODULE_DESCRIPTION("ALSA driver module for tm5600/tm6000/tm6010 based TV cards"); 58MODULE_DESCRIPTION("ALSA driver module for tm5600/tm6000/tm6010 based TV cards");
59MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 59MODULE_AUTHOR("Mauro Carvalho Chehab");
60MODULE_LICENSE("GPL"); 60MODULE_LICENSE("GPL");
61MODULE_SUPPORTED_DEVICE("{{Trident,tm5600}," 61MODULE_SUPPORTED_DEVICE("{{Trident,tm5600},"
62 "{{Trident,tm6000}," 62 "{{Trident,tm6000},"
diff --git a/drivers/media/usb/tm6000/tm6000-dvb.c b/drivers/media/usb/tm6000/tm6000-dvb.c
index 9fc1e940a82b..095f5db1a790 100644
--- a/drivers/media/usb/tm6000/tm6000-dvb.c
+++ b/drivers/media/usb/tm6000/tm6000-dvb.c
@@ -32,7 +32,7 @@
32#include "xc5000.h" 32#include "xc5000.h"
33 33
34MODULE_DESCRIPTION("DVB driver extension module for tm5600/6000/6010 based TV cards"); 34MODULE_DESCRIPTION("DVB driver extension module for tm5600/6000/6010 based TV cards");
35MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 35MODULE_AUTHOR("Mauro Carvalho Chehab");
36MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
37 37
38MODULE_SUPPORTED_DEVICE("{{Trident, tm5600}," 38MODULE_SUPPORTED_DEVICE("{{Trident, tm5600},"
diff --git a/drivers/media/usb/tm6000/tm6000-input.c b/drivers/media/usb/tm6000/tm6000-input.c
index 8a6bbf1d80e1..d1af5438c168 100644
--- a/drivers/media/usb/tm6000/tm6000-input.c
+++ b/drivers/media/usb/tm6000/tm6000-input.c
@@ -422,7 +422,7 @@ int tm6000_ir_init(struct tm6000_core *dev)
422 ir->rc = rc; 422 ir->rc = rc;
423 423
424 /* input setup */ 424 /* input setup */
425 rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC; 425 rc_set_allowed_protocols(rc, RC_BIT_RC5 | RC_BIT_NEC);
426 /* Neded, in order to support NEC remotes with 24 or 32 bits */ 426 /* Neded, in order to support NEC remotes with 24 or 32 bits */
427 rc->scanmask = 0xffff; 427 rc->scanmask = 0xffff;
428 rc->priv = ir; 428 rc->priv = ir;
diff --git a/drivers/media/usb/tm6000/tm6000-stds.c b/drivers/media/usb/tm6000/tm6000-stds.c
index 5e28d6a2412f..93a4b2434b6e 100644
--- a/drivers/media/usb/tm6000/tm6000-stds.c
+++ b/drivers/media/usb/tm6000/tm6000-stds.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * tm6000-stds.c - driver for TM5600/TM6000/TM6010 USB video capture devices 2 * tm6000-stds.c - driver for TM5600/TM6000/TM6010 USB video capture devices
3 * 3 *
4 * Copyright (C) 2007 Mauro Carvalho Chehab <mchehab@redhat.com> 4 * Copyright (C) 2007 Mauro Carvalho Chehab
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/usb/usbtv/Makefile b/drivers/media/usb/usbtv/Makefile
index 28b872fa94e1..775316a88ea6 100644
--- a/drivers/media/usb/usbtv/Makefile
+++ b/drivers/media/usb/usbtv/Makefile
@@ -1 +1,4 @@
1usbtv-y := usbtv-core.o \
2 usbtv-video.o
3
1obj-$(CONFIG_VIDEO_USBTV) += usbtv.o 4obj-$(CONFIG_VIDEO_USBTV) += usbtv.o
diff --git a/drivers/media/usb/usbtv/usbtv-core.c b/drivers/media/usb/usbtv/usbtv-core.c
new file mode 100644
index 000000000000..2f87ddfa469f
--- /dev/null
+++ b/drivers/media/usb/usbtv/usbtv-core.c
@@ -0,0 +1,134 @@
1/*
2 * Fushicai USBTV007 Video Grabber Driver
3 *
4 * Product web site:
5 * http://www.fushicai.com/products_detail/&productId=d05449ee-b690-42f9-a661-aa7353894bed.html
6 *
7 * Following LWN articles were very useful in construction of this driver:
8 * Video4Linux2 API series: http://lwn.net/Articles/203924/
9 * videobuf2 API explanation: http://lwn.net/Articles/447435/
10 * Thanks go to Jonathan Corbet for providing this quality documentation.
11 * He is awesome.
12 *
13 * Copyright (c) 2013 Lubomir Rintel
14 * All rights reserved.
15 * No physical hardware was harmed running Windows during the
16 * reverse-engineering activity
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions, and the following disclaimer,
23 * without modification.
24 * 2. The name of the author may not be used to endorse or promote products
25 * derived from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL").
29 */
30
31#include "usbtv.h"
32
33int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size)
34{
35 int ret;
36 int pipe = usb_rcvctrlpipe(usbtv->udev, 0);
37 int i;
38
39 for (i = 0; i < size; i++) {
40 u16 index = regs[i][0];
41 u16 value = regs[i][1];
42
43 ret = usb_control_msg(usbtv->udev, pipe, USBTV_REQUEST_REG,
44 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
45 value, index, NULL, 0, 0);
46 if (ret < 0)
47 return ret;
48 }
49
50 return 0;
51}
52
53static int usbtv_probe(struct usb_interface *intf,
54 const struct usb_device_id *id)
55{
56 int ret;
57 int size;
58 struct device *dev = &intf->dev;
59 struct usbtv *usbtv;
60
61 /* Checks that the device is what we think it is. */
62 if (intf->num_altsetting != 2)
63 return -ENODEV;
64 if (intf->altsetting[1].desc.bNumEndpoints != 4)
65 return -ENODEV;
66
67 /* Packet size is split into 11 bits of base size and count of
68 * extra multiplies of it.*/
69 size = usb_endpoint_maxp(&intf->altsetting[1].endpoint[0].desc);
70 size = (size & 0x07ff) * (((size & 0x1800) >> 11) + 1);
71
72 /* Device structure */
73 usbtv = kzalloc(sizeof(struct usbtv), GFP_KERNEL);
74 if (usbtv == NULL)
75 return -ENOMEM;
76 usbtv->dev = dev;
77 usbtv->udev = usb_get_dev(interface_to_usbdev(intf));
78
79 usbtv->iso_size = size;
80
81 usb_set_intfdata(intf, usbtv);
82
83 ret = usbtv_video_init(usbtv);
84 if (ret < 0)
85 goto usbtv_video_fail;
86
87 /* for simplicity we exploit the v4l2_device reference counting */
88 v4l2_device_get(&usbtv->v4l2_dev);
89
90 dev_info(dev, "Fushicai USBTV007 Video Grabber\n");
91 return 0;
92
93usbtv_video_fail:
94 kfree(usbtv);
95
96 return ret;
97}
98
99static void usbtv_disconnect(struct usb_interface *intf)
100{
101 struct usbtv *usbtv = usb_get_intfdata(intf);
102 usb_set_intfdata(intf, NULL);
103
104 if (!usbtv)
105 return;
106
107 usbtv_video_free(usbtv);
108
109 usb_put_dev(usbtv->udev);
110 usbtv->udev = NULL;
111
112 /* the usbtv structure will be deallocated when v4l2 will be
113 done using it */
114 v4l2_device_put(&usbtv->v4l2_dev);
115}
116
117static struct usb_device_id usbtv_id_table[] = {
118 { USB_DEVICE(0x1b71, 0x3002) },
119 {}
120};
121MODULE_DEVICE_TABLE(usb, usbtv_id_table);
122
123MODULE_AUTHOR("Lubomir Rintel");
124MODULE_DESCRIPTION("Fushicai USBTV007 Video Grabber Driver");
125MODULE_LICENSE("Dual BSD/GPL");
126
127static struct usb_driver usbtv_usb_driver = {
128 .name = "usbtv",
129 .id_table = usbtv_id_table,
130 .probe = usbtv_probe,
131 .disconnect = usbtv_disconnect,
132};
133
134module_usb_driver(usbtv_usb_driver);
diff --git a/drivers/media/usb/usbtv/usbtv.c b/drivers/media/usb/usbtv/usbtv-video.c
index 6222a4ab1e00..20365bd69d05 100644
--- a/drivers/media/usb/usbtv/usbtv.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -28,45 +28,10 @@
28 * GNU General Public License ("GPL"). 28 * GNU General Public License ("GPL").
29 */ 29 */
30 30
31#include <linux/init.h>
32#include <linux/list.h>
33#include <linux/module.h>
34#include <linux/slab.h>
35#include <linux/usb.h>
36#include <linux/videodev2.h>
37
38#include <media/v4l2-device.h>
39#include <media/v4l2-ioctl.h> 31#include <media/v4l2-ioctl.h>
40#include <media/videobuf2-core.h> 32#include <media/videobuf2-core.h>
41#include <media/videobuf2-vmalloc.h> 33
42 34#include "usbtv.h"
43/* Hardware. */
44#define USBTV_VIDEO_ENDP 0x81
45#define USBTV_BASE 0xc000
46#define USBTV_REQUEST_REG 12
47
48/* Number of concurrent isochronous urbs submitted.
49 * Higher numbers was seen to overly saturate the USB bus. */
50#define USBTV_ISOC_TRANSFERS 16
51#define USBTV_ISOC_PACKETS 8
52
53#define USBTV_CHUNK_SIZE 256
54#define USBTV_CHUNK 240
55
56/* Chunk header. */
57#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \
58 == 0x88000000)
59#define USBTV_FRAME_ID(chunk) ((be32_to_cpu(chunk[0]) & 0x00ff0000) >> 16)
60#define USBTV_ODD(chunk) ((be32_to_cpu(chunk[0]) & 0x0000f000) >> 15)
61#define USBTV_CHUNK_NO(chunk) (be32_to_cpu(chunk[0]) & 0x00000fff)
62
63#define USBTV_TV_STD (V4L2_STD_525_60 | V4L2_STD_PAL)
64
65/* parameters for supported TV norms */
66struct usbtv_norm_params {
67 v4l2_std_id norm;
68 int cap_width, cap_height;
69};
70 35
71static struct usbtv_norm_params norm_params[] = { 36static struct usbtv_norm_params norm_params[] = {
72 { 37 {
@@ -81,43 +46,6 @@ static struct usbtv_norm_params norm_params[] = {
81 } 46 }
82}; 47};
83 48
84/* A single videobuf2 frame buffer. */
85struct usbtv_buf {
86 struct vb2_buffer vb;
87 struct list_head list;
88};
89
90/* Per-device structure. */
91struct usbtv {
92 struct device *dev;
93 struct usb_device *udev;
94 struct v4l2_device v4l2_dev;
95 struct video_device vdev;
96 struct vb2_queue vb2q;
97 struct mutex v4l2_lock;
98 struct mutex vb2q_lock;
99
100 /* List of videobuf2 buffers protected by a lock. */
101 spinlock_t buflock;
102 struct list_head bufs;
103
104 /* Number of currently processed frame, useful find
105 * out when a new one begins. */
106 u32 frame_id;
107 int chunks_done;
108
109 enum {
110 USBTV_COMPOSITE_INPUT,
111 USBTV_SVIDEO_INPUT,
112 } input;
113 v4l2_std_id norm;
114 int width, height;
115 int n_chunks;
116 int iso_size;
117 unsigned int sequence;
118 struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS];
119};
120
121static int usbtv_configure_for_norm(struct usbtv *usbtv, v4l2_std_id norm) 49static int usbtv_configure_for_norm(struct usbtv *usbtv, v4l2_std_id norm)
122{ 50{
123 int i, ret = 0; 51 int i, ret = 0;
@@ -142,26 +70,6 @@ static int usbtv_configure_for_norm(struct usbtv *usbtv, v4l2_std_id norm)
142 return ret; 70 return ret;
143} 71}
144 72
145static int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size)
146{
147 int ret;
148 int pipe = usb_rcvctrlpipe(usbtv->udev, 0);
149 int i;
150
151 for (i = 0; i < size; i++) {
152 u16 index = regs[i][0];
153 u16 value = regs[i][1];
154
155 ret = usb_control_msg(usbtv->udev, pipe, USBTV_REQUEST_REG,
156 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
157 value, index, NULL, 0, 0);
158 if (ret < 0)
159 return ret;
160 }
161
162 return 0;
163}
164
165static int usbtv_select_input(struct usbtv *usbtv, int input) 73static int usbtv_select_input(struct usbtv *usbtv, int input)
166{ 74{
167 int ret; 75 int ret;
@@ -560,12 +468,6 @@ start_fail:
560 return ret; 468 return ret;
561} 469}
562 470
563struct usb_device_id usbtv_id_table[] = {
564 { USB_DEVICE(0x1b71, 0x3002) },
565 {}
566};
567MODULE_DEVICE_TABLE(usb, usbtv_id_table);
568
569static int usbtv_querycap(struct file *file, void *priv, 471static int usbtv_querycap(struct file *file, void *priv,
570 struct v4l2_capability *cap) 472 struct v4l2_capability *cap)
571{ 473{
@@ -660,7 +562,7 @@ static int usbtv_s_input(struct file *file, void *priv, unsigned int i)
660 return usbtv_select_input(usbtv, i); 562 return usbtv_select_input(usbtv, i);
661} 563}
662 564
663struct v4l2_ioctl_ops usbtv_ioctl_ops = { 565static struct v4l2_ioctl_ops usbtv_ioctl_ops = {
664 .vidioc_querycap = usbtv_querycap, 566 .vidioc_querycap = usbtv_querycap,
665 .vidioc_enum_input = usbtv_enum_input, 567 .vidioc_enum_input = usbtv_enum_input,
666 .vidioc_enum_fmt_vid_cap = usbtv_enum_fmt_vid_cap, 568 .vidioc_enum_fmt_vid_cap = usbtv_enum_fmt_vid_cap,
@@ -682,7 +584,7 @@ struct v4l2_ioctl_ops usbtv_ioctl_ops = {
682 .vidioc_streamoff = vb2_ioctl_streamoff, 584 .vidioc_streamoff = vb2_ioctl_streamoff,
683}; 585};
684 586
685struct v4l2_file_operations usbtv_fops = { 587static struct v4l2_file_operations usbtv_fops = {
686 .owner = THIS_MODULE, 588 .owner = THIS_MODULE,
687 .unlocked_ioctl = video_ioctl2, 589 .unlocked_ioctl = video_ioctl2,
688 .mmap = vb2_fop_mmap, 590 .mmap = vb2_fop_mmap,
@@ -743,7 +645,7 @@ static int usbtv_stop_streaming(struct vb2_queue *vq)
743 return 0; 645 return 0;
744} 646}
745 647
746struct vb2_ops usbtv_vb2_ops = { 648static struct vb2_ops usbtv_vb2_ops = {
747 .queue_setup = usbtv_queue_setup, 649 .queue_setup = usbtv_queue_setup,
748 .buf_queue = usbtv_buf_queue, 650 .buf_queue = usbtv_buf_queue,
749 .start_streaming = usbtv_start_streaming, 651 .start_streaming = usbtv_start_streaming,
@@ -759,33 +661,9 @@ static void usbtv_release(struct v4l2_device *v4l2_dev)
759 kfree(usbtv); 661 kfree(usbtv);
760} 662}
761 663
762static int usbtv_probe(struct usb_interface *intf, 664int usbtv_video_init(struct usbtv *usbtv)
763 const struct usb_device_id *id)
764{ 665{
765 int ret; 666 int ret;
766 int size;
767 struct device *dev = &intf->dev;
768 struct usbtv *usbtv;
769
770 /* Checks that the device is what we think it is. */
771 if (intf->num_altsetting != 2)
772 return -ENODEV;
773 if (intf->altsetting[1].desc.bNumEndpoints != 4)
774 return -ENODEV;
775
776 /* Packet size is split into 11 bits of base size and count of
777 * extra multiplies of it.*/
778 size = usb_endpoint_maxp(&intf->altsetting[1].endpoint[0].desc);
779 size = (size & 0x07ff) * (((size & 0x1800) >> 11) + 1);
780
781 /* Device structure */
782 usbtv = kzalloc(sizeof(struct usbtv), GFP_KERNEL);
783 if (usbtv == NULL)
784 return -ENOMEM;
785 usbtv->dev = dev;
786 usbtv->udev = usb_get_dev(interface_to_usbdev(intf));
787
788 usbtv->iso_size = size;
789 667
790 (void)usbtv_configure_for_norm(usbtv, V4L2_STD_525_60); 668 (void)usbtv_configure_for_norm(usbtv, V4L2_STD_525_60);
791 669
@@ -801,24 +679,22 @@ static int usbtv_probe(struct usb_interface *intf,
801 usbtv->vb2q.buf_struct_size = sizeof(struct usbtv_buf); 679 usbtv->vb2q.buf_struct_size = sizeof(struct usbtv_buf);
802 usbtv->vb2q.ops = &usbtv_vb2_ops; 680 usbtv->vb2q.ops = &usbtv_vb2_ops;
803 usbtv->vb2q.mem_ops = &vb2_vmalloc_memops; 681 usbtv->vb2q.mem_ops = &vb2_vmalloc_memops;
804 usbtv->vb2q.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 682 usbtv->vb2q.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
805 usbtv->vb2q.lock = &usbtv->vb2q_lock; 683 usbtv->vb2q.lock = &usbtv->vb2q_lock;
806 ret = vb2_queue_init(&usbtv->vb2q); 684 ret = vb2_queue_init(&usbtv->vb2q);
807 if (ret < 0) { 685 if (ret < 0) {
808 dev_warn(dev, "Could not initialize videobuf2 queue\n"); 686 dev_warn(usbtv->dev, "Could not initialize videobuf2 queue\n");
809 goto usbtv_fail; 687 return ret;
810 } 688 }
811 689
812 /* v4l2 structure */ 690 /* v4l2 structure */
813 usbtv->v4l2_dev.release = usbtv_release; 691 usbtv->v4l2_dev.release = usbtv_release;
814 ret = v4l2_device_register(dev, &usbtv->v4l2_dev); 692 ret = v4l2_device_register(usbtv->dev, &usbtv->v4l2_dev);
815 if (ret < 0) { 693 if (ret < 0) {
816 dev_warn(dev, "Could not register v4l2 device\n"); 694 dev_warn(usbtv->dev, "Could not register v4l2 device\n");
817 goto v4l2_fail; 695 goto v4l2_fail;
818 } 696 }
819 697
820 usb_set_intfdata(intf, usbtv);
821
822 /* Video structure */ 698 /* Video structure */
823 strlcpy(usbtv->vdev.name, "usbtv", sizeof(usbtv->vdev.name)); 699 strlcpy(usbtv->vdev.name, "usbtv", sizeof(usbtv->vdev.name));
824 usbtv->vdev.v4l2_dev = &usbtv->v4l2_dev; 700 usbtv->vdev.v4l2_dev = &usbtv->v4l2_dev;
@@ -832,52 +708,31 @@ static int usbtv_probe(struct usb_interface *intf,
832 video_set_drvdata(&usbtv->vdev, usbtv); 708 video_set_drvdata(&usbtv->vdev, usbtv);
833 ret = video_register_device(&usbtv->vdev, VFL_TYPE_GRABBER, -1); 709 ret = video_register_device(&usbtv->vdev, VFL_TYPE_GRABBER, -1);
834 if (ret < 0) { 710 if (ret < 0) {
835 dev_warn(dev, "Could not register video device\n"); 711 dev_warn(usbtv->dev, "Could not register video device\n");
836 goto vdev_fail; 712 goto vdev_fail;
837 } 713 }
838 714
839 dev_info(dev, "Fushicai USBTV007 Video Grabber\n");
840 return 0; 715 return 0;
841 716
842vdev_fail: 717vdev_fail:
843 v4l2_device_unregister(&usbtv->v4l2_dev); 718 v4l2_device_unregister(&usbtv->v4l2_dev);
844v4l2_fail: 719v4l2_fail:
845 vb2_queue_release(&usbtv->vb2q); 720 vb2_queue_release(&usbtv->vb2q);
846usbtv_fail:
847 kfree(usbtv);
848 721
849 return ret; 722 return ret;
850} 723}
851 724
852static void usbtv_disconnect(struct usb_interface *intf) 725void usbtv_video_free(struct usbtv *usbtv)
853{ 726{
854 struct usbtv *usbtv = usb_get_intfdata(intf);
855
856 mutex_lock(&usbtv->vb2q_lock); 727 mutex_lock(&usbtv->vb2q_lock);
857 mutex_lock(&usbtv->v4l2_lock); 728 mutex_lock(&usbtv->v4l2_lock);
858 729
859 usbtv_stop(usbtv); 730 usbtv_stop(usbtv);
860 usb_set_intfdata(intf, NULL);
861 video_unregister_device(&usbtv->vdev); 731 video_unregister_device(&usbtv->vdev);
862 v4l2_device_disconnect(&usbtv->v4l2_dev); 732 v4l2_device_disconnect(&usbtv->v4l2_dev);
863 usb_put_dev(usbtv->udev);
864 usbtv->udev = NULL;
865 733
866 mutex_unlock(&usbtv->v4l2_lock); 734 mutex_unlock(&usbtv->v4l2_lock);
867 mutex_unlock(&usbtv->vb2q_lock); 735 mutex_unlock(&usbtv->vb2q_lock);
868 736
869 v4l2_device_put(&usbtv->v4l2_dev); 737 v4l2_device_put(&usbtv->v4l2_dev);
870} 738}
871
872MODULE_AUTHOR("Lubomir Rintel");
873MODULE_DESCRIPTION("Fushicai USBTV007 Video Grabber Driver");
874MODULE_LICENSE("Dual BSD/GPL");
875
876struct usb_driver usbtv_usb_driver = {
877 .name = "usbtv",
878 .id_table = usbtv_id_table,
879 .probe = usbtv_probe,
880 .disconnect = usbtv_disconnect,
881};
882
883module_usb_driver(usbtv_usb_driver);
diff --git a/drivers/media/usb/usbtv/usbtv.h b/drivers/media/usb/usbtv/usbtv.h
new file mode 100644
index 000000000000..cb1d388cc647
--- /dev/null
+++ b/drivers/media/usb/usbtv/usbtv.h
@@ -0,0 +1,99 @@
1/*
2 * Fushicai USBTV007 Video Grabber Driver
3 *
4 * Copyright (c) 2013 Lubomir Rintel
5 * All rights reserved.
6 * No physical hardware was harmed running Windows during the
7 * reverse-engineering activity
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions, and the following disclaimer,
14 * without modification.
15 * 2. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * Alternatively, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL").
20 */
21
22#include <linux/module.h>
23#include <linux/slab.h>
24#include <linux/usb.h>
25
26#include <media/v4l2-device.h>
27#include <media/videobuf2-vmalloc.h>
28
29/* Hardware. */
30#define USBTV_VIDEO_ENDP 0x81
31#define USBTV_BASE 0xc000
32#define USBTV_REQUEST_REG 12
33
34/* Number of concurrent isochronous urbs submitted.
35 * Higher numbers was seen to overly saturate the USB bus. */
36#define USBTV_ISOC_TRANSFERS 16
37#define USBTV_ISOC_PACKETS 8
38
39#define USBTV_CHUNK_SIZE 256
40#define USBTV_CHUNK 240
41
42/* Chunk header. */
43#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \
44 == 0x88000000)
45#define USBTV_FRAME_ID(chunk) ((be32_to_cpu(chunk[0]) & 0x00ff0000) >> 16)
46#define USBTV_ODD(chunk) ((be32_to_cpu(chunk[0]) & 0x0000f000) >> 15)
47#define USBTV_CHUNK_NO(chunk) (be32_to_cpu(chunk[0]) & 0x00000fff)
48
49#define USBTV_TV_STD (V4L2_STD_525_60 | V4L2_STD_PAL)
50
51/* parameters for supported TV norms */
52struct usbtv_norm_params {
53 v4l2_std_id norm;
54 int cap_width, cap_height;
55};
56
57/* A single videobuf2 frame buffer. */
58struct usbtv_buf {
59 struct vb2_buffer vb;
60 struct list_head list;
61};
62
63/* Per-device structure. */
64struct usbtv {
65 struct device *dev;
66 struct usb_device *udev;
67
68 /* video */
69 struct v4l2_device v4l2_dev;
70 struct video_device vdev;
71 struct vb2_queue vb2q;
72 struct mutex v4l2_lock;
73 struct mutex vb2q_lock;
74
75 /* List of videobuf2 buffers protected by a lock. */
76 spinlock_t buflock;
77 struct list_head bufs;
78
79 /* Number of currently processed frame, useful find
80 * out when a new one begins. */
81 u32 frame_id;
82 int chunks_done;
83
84 enum {
85 USBTV_COMPOSITE_INPUT,
86 USBTV_SVIDEO_INPUT,
87 } input;
88 v4l2_std_id norm;
89 int width, height;
90 int n_chunks;
91 int iso_size;
92 unsigned int sequence;
93 struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS];
94};
95
96int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size);
97
98int usbtv_video_init(struct usbtv *usbtv);
99void usbtv_video_free(struct usbtv *usbtv);
diff --git a/drivers/media/usb/usbvision/usbvision.h b/drivers/media/usb/usbvision/usbvision.h
index 8a25876d72c6..a0c73cf1517c 100644
--- a/drivers/media/usb/usbvision/usbvision.h
+++ b/drivers/media/usb/usbvision/usbvision.h
@@ -203,14 +203,6 @@ enum {
203 mr = LIMIT_RGB(mm_r); \ 203 mr = LIMIT_RGB(mm_r); \
204} 204}
205 205
206/* Debugging aid */
207#define USBVISION_SAY_AND_WAIT(what) { \
208 wait_queue_head_t wq; \
209 init_waitqueue_head(&wq); \
210 printk(KERN_INFO "Say: %s\n", what); \
211 interruptible_sleep_on_timeout(&wq, HZ * 3); \
212}
213
214/* 206/*
215 * This macro checks if usbvision is still operational. The 'usbvision' 207 * This macro checks if usbvision is still operational. The 'usbvision'
216 * pointer must be valid, usbvision->dev must be valid, we are not 208 * pointer must be valid, usbvision->dev must be valid, we are not
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index c3bb2502225b..ad47c5cb539a 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -108,11 +108,31 @@ static struct uvc_format_desc uvc_fmts[] = {
108 .fcc = V4L2_PIX_FMT_Y16, 108 .fcc = V4L2_PIX_FMT_Y16,
109 }, 109 },
110 { 110 {
111 .name = "RGB Bayer", 111 .name = "BGGR Bayer (BY8 )",
112 .guid = UVC_GUID_FORMAT_BY8, 112 .guid = UVC_GUID_FORMAT_BY8,
113 .fcc = V4L2_PIX_FMT_SBGGR8, 113 .fcc = V4L2_PIX_FMT_SBGGR8,
114 }, 114 },
115 { 115 {
116 .name = "BGGR Bayer (BA81)",
117 .guid = UVC_GUID_FORMAT_BA81,
118 .fcc = V4L2_PIX_FMT_SBGGR8,
119 },
120 {
121 .name = "GBRG Bayer (GBRG)",
122 .guid = UVC_GUID_FORMAT_GBRG,
123 .fcc = V4L2_PIX_FMT_SGBRG8,
124 },
125 {
126 .name = "GRBG Bayer (GRBG)",
127 .guid = UVC_GUID_FORMAT_GRBG,
128 .fcc = V4L2_PIX_FMT_SGRBG8,
129 },
130 {
131 .name = "RGGB Bayer (RGGB)",
132 .guid = UVC_GUID_FORMAT_RGGB,
133 .fcc = V4L2_PIX_FMT_SRGGB8,
134 },
135 {
116 .name = "RGB565", 136 .name = "RGB565",
117 .guid = UVC_GUID_FORMAT_RGBP, 137 .guid = UVC_GUID_FORMAT_RGBP,
118 .fcc = V4L2_PIX_FMT_RGB565, 138 .fcc = V4L2_PIX_FMT_RGB565,
@@ -925,7 +945,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
925 case UVC_VC_HEADER: 945 case UVC_VC_HEADER:
926 n = buflen >= 12 ? buffer[11] : 0; 946 n = buflen >= 12 ? buffer[11] : 0;
927 947
928 if (buflen < 12 || buflen < 12 + n) { 948 if (buflen < 12 + n) {
929 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " 949 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
930 "interface %d HEADER error\n", udev->devnum, 950 "interface %d HEADER error\n", udev->devnum,
931 alts->desc.bInterfaceNumber); 951 alts->desc.bInterfaceNumber);
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index cd962be860ca..6e92d2080255 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -48,12 +48,14 @@ static int uvc_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
48 struct uvc_streaming *stream = 48 struct uvc_streaming *stream =
49 container_of(queue, struct uvc_streaming, queue); 49 container_of(queue, struct uvc_streaming, queue);
50 50
51 if (*nbuffers > UVC_MAX_VIDEO_BUFFERS) 51 /* Make sure the image size is large enough. */
52 *nbuffers = UVC_MAX_VIDEO_BUFFERS; 52 if (fmt && fmt->fmt.pix.sizeimage < stream->ctrl.dwMaxVideoFrameSize)
53 return -EINVAL;
53 54
54 *nplanes = 1; 55 *nplanes = 1;
55 56
56 sizes[0] = stream->ctrl.dwMaxVideoFrameSize; 57 sizes[0] = fmt ? fmt->fmt.pix.sizeimage
58 : stream->ctrl.dwMaxVideoFrameSize;
57 59
58 return 0; 60 return 0;
59} 61}
@@ -104,15 +106,15 @@ static void uvc_buffer_queue(struct vb2_buffer *vb)
104 spin_unlock_irqrestore(&queue->irqlock, flags); 106 spin_unlock_irqrestore(&queue->irqlock, flags);
105} 107}
106 108
107static int uvc_buffer_finish(struct vb2_buffer *vb) 109static void uvc_buffer_finish(struct vb2_buffer *vb)
108{ 110{
109 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); 111 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);
110 struct uvc_streaming *stream = 112 struct uvc_streaming *stream =
111 container_of(queue, struct uvc_streaming, queue); 113 container_of(queue, struct uvc_streaming, queue);
112 struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf); 114 struct uvc_buffer *buf = container_of(vb, struct uvc_buffer, buf);
113 115
114 uvc_video_clock_update(stream, &vb->v4l2_buf, buf); 116 if (vb->state == VB2_BUF_STATE_DONE)
115 return 0; 117 uvc_video_clock_update(stream, &vb->v4l2_buf, buf);
116} 118}
117 119
118static void uvc_wait_prepare(struct vb2_queue *vq) 120static void uvc_wait_prepare(struct vb2_queue *vq)
@@ -149,7 +151,8 @@ int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
149 queue->queue.buf_struct_size = sizeof(struct uvc_buffer); 151 queue->queue.buf_struct_size = sizeof(struct uvc_buffer);
150 queue->queue.ops = &uvc_queue_qops; 152 queue->queue.ops = &uvc_queue_qops;
151 queue->queue.mem_ops = &vb2_vmalloc_memops; 153 queue->queue.mem_ops = &vb2_vmalloc_memops;
152 queue->queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 154 queue->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC
155 | V4L2_BUF_FLAG_TSTAMP_SRC_SOE;
153 ret = vb2_queue_init(&queue->queue); 156 ret = vb2_queue_init(&queue->queue);
154 if (ret) 157 if (ret)
155 return ret; 158 return ret;
@@ -196,6 +199,18 @@ int uvc_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf)
196 return ret; 199 return ret;
197} 200}
198 201
202int uvc_create_buffers(struct uvc_video_queue *queue,
203 struct v4l2_create_buffers *cb)
204{
205 int ret;
206
207 mutex_lock(&queue->mutex);
208 ret = vb2_create_bufs(&queue->queue, cb);
209 mutex_unlock(&queue->mutex);
210
211 return ret;
212}
213
199int uvc_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf) 214int uvc_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf)
200{ 215{
201 int ret; 216 int ret;
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 3afff92804d3..378ae02e593b 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -1000,6 +1000,17 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1000 return uvc_query_buffer(&stream->queue, buf); 1000 return uvc_query_buffer(&stream->queue, buf);
1001 } 1001 }
1002 1002
1003 case VIDIOC_CREATE_BUFS:
1004 {
1005 struct v4l2_create_buffers *cb = arg;
1006
1007 ret = uvc_acquire_privileges(handle);
1008 if (ret < 0)
1009 return ret;
1010
1011 return uvc_create_buffers(&stream->queue, cb);
1012 }
1013
1003 case VIDIOC_QBUF: 1014 case VIDIOC_QBUF:
1004 if (!uvc_has_privileges(handle)) 1015 if (!uvc_has_privileges(handle))
1005 return -EBUSY; 1016 return -EBUSY;
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 898c208889cd..8d52baf5952b 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1453,6 +1453,9 @@ static unsigned int uvc_endpoint_max_bpi(struct usb_device *dev,
1453 case USB_SPEED_HIGH: 1453 case USB_SPEED_HIGH:
1454 psize = usb_endpoint_maxp(&ep->desc); 1454 psize = usb_endpoint_maxp(&ep->desc);
1455 return (psize & 0x07ff) * (1 + ((psize >> 11) & 3)); 1455 return (psize & 0x07ff) * (1 + ((psize >> 11) & 3));
1456 case USB_SPEED_WIRELESS:
1457 psize = usb_endpoint_maxp(&ep->desc);
1458 return psize;
1456 default: 1459 default:
1457 psize = usb_endpoint_maxp(&ep->desc); 1460 psize = usb_endpoint_maxp(&ep->desc);
1458 return psize & 0x07ff; 1461 return psize & 0x07ff;
@@ -1847,7 +1850,25 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable)
1847 1850
1848 if (!enable) { 1851 if (!enable) {
1849 uvc_uninit_video(stream, 1); 1852 uvc_uninit_video(stream, 1);
1850 usb_set_interface(stream->dev->udev, stream->intfnum, 0); 1853 if (stream->intf->num_altsetting > 1) {
1854 usb_set_interface(stream->dev->udev,
1855 stream->intfnum, 0);
1856 } else {
1857 /* UVC doesn't specify how to inform a bulk-based device
1858 * when the video stream is stopped. Windows sends a
1859 * CLEAR_FEATURE(HALT) request to the video streaming
1860 * bulk endpoint, mimic the same behaviour.
1861 */
1862 unsigned int epnum = stream->header.bEndpointAddress
1863 & USB_ENDPOINT_NUMBER_MASK;
1864 unsigned int dir = stream->header.bEndpointAddress
1865 & USB_ENDPOINT_DIR_MASK;
1866 unsigned int pipe;
1867
1868 pipe = usb_sndbulkpipe(stream->dev->udev, epnum) | dir;
1869 usb_clear_halt(stream->dev->udev, pipe);
1870 }
1871
1851 uvc_queue_enable(&stream->queue, 0); 1872 uvc_queue_enable(&stream->queue, 0);
1852 uvc_video_clock_cleanup(stream); 1873 uvc_video_clock_cleanup(stream);
1853 return 0; 1874 return 0;
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 9e35982d099a..b1f69a6d4068 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -94,6 +94,18 @@
94#define UVC_GUID_FORMAT_BY8 \ 94#define UVC_GUID_FORMAT_BY8 \
95 { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \ 95 { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \
96 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 96 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
97#define UVC_GUID_FORMAT_BA81 \
98 { 'B', 'A', '8', '1', 0x00, 0x00, 0x10, 0x00, \
99 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
100#define UVC_GUID_FORMAT_GBRG \
101 { 'G', 'B', 'R', 'G', 0x00, 0x00, 0x10, 0x00, \
102 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
103#define UVC_GUID_FORMAT_GRBG \
104 { 'G', 'R', 'B', 'G', 0x00, 0x00, 0x10, 0x00, \
105 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
106#define UVC_GUID_FORMAT_RGGB \
107 { 'R', 'G', 'G', 'B', 0x00, 0x00, 0x10, 0x00, \
108 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
97#define UVC_GUID_FORMAT_RGBP \ 109#define UVC_GUID_FORMAT_RGBP \
98 { 'R', 'G', 'B', 'P', 0x00, 0x00, 0x10, 0x00, \ 110 { 'R', 'G', 'B', 'P', 0x00, 0x00, 0x10, 0x00, \
99 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 111 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
@@ -115,8 +127,6 @@
115#define UVC_URBS 5 127#define UVC_URBS 5
116/* Maximum number of packets per URB. */ 128/* Maximum number of packets per URB. */
117#define UVC_MAX_PACKETS 32 129#define UVC_MAX_PACKETS 32
118/* Maximum number of video buffers. */
119#define UVC_MAX_VIDEO_BUFFERS 32
120/* Maximum status buffer size in bytes of interrupt URB. */ 130/* Maximum status buffer size in bytes of interrupt URB. */
121#define UVC_MAX_STATUS_SIZE 16 131#define UVC_MAX_STATUS_SIZE 16
122 132
@@ -616,6 +626,8 @@ extern int uvc_alloc_buffers(struct uvc_video_queue *queue,
616extern void uvc_free_buffers(struct uvc_video_queue *queue); 626extern void uvc_free_buffers(struct uvc_video_queue *queue);
617extern int uvc_query_buffer(struct uvc_video_queue *queue, 627extern int uvc_query_buffer(struct uvc_video_queue *queue,
618 struct v4l2_buffer *v4l2_buf); 628 struct v4l2_buffer *v4l2_buf);
629extern int uvc_create_buffers(struct uvc_video_queue *queue,
630 struct v4l2_create_buffers *v4l2_cb);
619extern int uvc_queue_buffer(struct uvc_video_queue *queue, 631extern int uvc_queue_buffer(struct uvc_video_queue *queue,
620 struct v4l2_buffer *v4l2_buf); 632 struct v4l2_buffer *v4l2_buf);
621extern int uvc_dequeue_buffer(struct uvc_video_queue *queue, 633extern int uvc_dequeue_buffer(struct uvc_video_queue *queue,
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index 6191968db8fa..04b2daf567be 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -740,7 +740,7 @@ static int put_v4l2_event32(struct v4l2_event *kp, struct v4l2_event32 __user *u
740 return 0; 740 return 0;
741} 741}
742 742
743struct v4l2_subdev_edid32 { 743struct v4l2_edid32 {
744 __u32 pad; 744 __u32 pad;
745 __u32 start_block; 745 __u32 start_block;
746 __u32 blocks; 746 __u32 blocks;
@@ -748,11 +748,11 @@ struct v4l2_subdev_edid32 {
748 compat_caddr_t edid; 748 compat_caddr_t edid;
749}; 749};
750 750
751static int get_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subdev_edid32 __user *up) 751static int get_v4l2_edid32(struct v4l2_edid *kp, struct v4l2_edid32 __user *up)
752{ 752{
753 u32 tmp; 753 u32 tmp;
754 754
755 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_subdev_edid32)) || 755 if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_edid32)) ||
756 get_user(kp->pad, &up->pad) || 756 get_user(kp->pad, &up->pad) ||
757 get_user(kp->start_block, &up->start_block) || 757 get_user(kp->start_block, &up->start_block) ||
758 get_user(kp->blocks, &up->blocks) || 758 get_user(kp->blocks, &up->blocks) ||
@@ -763,11 +763,11 @@ static int get_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
763 return 0; 763 return 0;
764} 764}
765 765
766static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subdev_edid32 __user *up) 766static int put_v4l2_edid32(struct v4l2_edid *kp, struct v4l2_edid32 __user *up)
767{ 767{
768 u32 tmp = (u32)((unsigned long)kp->edid); 768 u32 tmp = (u32)((unsigned long)kp->edid);
769 769
770 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_subdev_edid32)) || 770 if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_edid32)) ||
771 put_user(kp->pad, &up->pad) || 771 put_user(kp->pad, &up->pad) ||
772 put_user(kp->start_block, &up->start_block) || 772 put_user(kp->start_block, &up->start_block) ||
773 put_user(kp->blocks, &up->blocks) || 773 put_user(kp->blocks, &up->blocks) ||
@@ -787,8 +787,8 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
787#define VIDIOC_DQBUF32 _IOWR('V', 17, struct v4l2_buffer32) 787#define VIDIOC_DQBUF32 _IOWR('V', 17, struct v4l2_buffer32)
788#define VIDIOC_ENUMSTD32 _IOWR('V', 25, struct v4l2_standard32) 788#define VIDIOC_ENUMSTD32 _IOWR('V', 25, struct v4l2_standard32)
789#define VIDIOC_ENUMINPUT32 _IOWR('V', 26, struct v4l2_input32) 789#define VIDIOC_ENUMINPUT32 _IOWR('V', 26, struct v4l2_input32)
790#define VIDIOC_SUBDEV_G_EDID32 _IOWR('V', 63, struct v4l2_subdev_edid32) 790#define VIDIOC_G_EDID32 _IOWR('V', 40, struct v4l2_edid32)
791#define VIDIOC_SUBDEV_S_EDID32 _IOWR('V', 64, struct v4l2_subdev_edid32) 791#define VIDIOC_S_EDID32 _IOWR('V', 41, struct v4l2_edid32)
792#define VIDIOC_TRY_FMT32 _IOWR('V', 64, struct v4l2_format32) 792#define VIDIOC_TRY_FMT32 _IOWR('V', 64, struct v4l2_format32)
793#define VIDIOC_G_EXT_CTRLS32 _IOWR('V', 71, struct v4l2_ext_controls32) 793#define VIDIOC_G_EXT_CTRLS32 _IOWR('V', 71, struct v4l2_ext_controls32)
794#define VIDIOC_S_EXT_CTRLS32 _IOWR('V', 72, struct v4l2_ext_controls32) 794#define VIDIOC_S_EXT_CTRLS32 _IOWR('V', 72, struct v4l2_ext_controls32)
@@ -816,7 +816,7 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
816 struct v4l2_ext_controls v2ecs; 816 struct v4l2_ext_controls v2ecs;
817 struct v4l2_event v2ev; 817 struct v4l2_event v2ev;
818 struct v4l2_create_buffers v2crt; 818 struct v4l2_create_buffers v2crt;
819 struct v4l2_subdev_edid v2edid; 819 struct v4l2_edid v2edid;
820 unsigned long vx; 820 unsigned long vx;
821 int vi; 821 int vi;
822 } karg; 822 } karg;
@@ -849,8 +849,8 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
849 case VIDIOC_S_OUTPUT32: cmd = VIDIOC_S_OUTPUT; break; 849 case VIDIOC_S_OUTPUT32: cmd = VIDIOC_S_OUTPUT; break;
850 case VIDIOC_CREATE_BUFS32: cmd = VIDIOC_CREATE_BUFS; break; 850 case VIDIOC_CREATE_BUFS32: cmd = VIDIOC_CREATE_BUFS; break;
851 case VIDIOC_PREPARE_BUF32: cmd = VIDIOC_PREPARE_BUF; break; 851 case VIDIOC_PREPARE_BUF32: cmd = VIDIOC_PREPARE_BUF; break;
852 case VIDIOC_SUBDEV_G_EDID32: cmd = VIDIOC_SUBDEV_G_EDID; break; 852 case VIDIOC_G_EDID32: cmd = VIDIOC_G_EDID; break;
853 case VIDIOC_SUBDEV_S_EDID32: cmd = VIDIOC_SUBDEV_S_EDID; break; 853 case VIDIOC_S_EDID32: cmd = VIDIOC_S_EDID; break;
854 } 854 }
855 855
856 switch (cmd) { 856 switch (cmd) {
@@ -868,9 +868,9 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
868 compatible_arg = 0; 868 compatible_arg = 0;
869 break; 869 break;
870 870
871 case VIDIOC_SUBDEV_G_EDID: 871 case VIDIOC_G_EDID:
872 case VIDIOC_SUBDEV_S_EDID: 872 case VIDIOC_S_EDID:
873 err = get_v4l2_subdev_edid32(&karg.v2edid, up); 873 err = get_v4l2_edid32(&karg.v2edid, up);
874 compatible_arg = 0; 874 compatible_arg = 0;
875 break; 875 break;
876 876
@@ -966,9 +966,9 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
966 err = put_v4l2_event32(&karg.v2ev, up); 966 err = put_v4l2_event32(&karg.v2ev, up);
967 break; 967 break;
968 968
969 case VIDIOC_SUBDEV_G_EDID: 969 case VIDIOC_G_EDID:
970 case VIDIOC_SUBDEV_S_EDID: 970 case VIDIOC_S_EDID:
971 err = put_v4l2_subdev_edid32(&karg.v2edid, up); 971 err = put_v4l2_edid32(&karg.v2edid, up);
972 break; 972 break;
973 973
974 case VIDIOC_G_FMT: 974 case VIDIOC_G_FMT:
@@ -1006,103 +1006,14 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
1006 if (!file->f_op->unlocked_ioctl) 1006 if (!file->f_op->unlocked_ioctl)
1007 return ret; 1007 return ret;
1008 1008
1009 switch (cmd) { 1009 if (_IOC_TYPE(cmd) == 'V' && _IOC_NR(cmd) < BASE_VIDIOC_PRIVATE)
1010 case VIDIOC_QUERYCAP:
1011 case VIDIOC_RESERVED:
1012 case VIDIOC_ENUM_FMT:
1013 case VIDIOC_G_FMT32:
1014 case VIDIOC_S_FMT32:
1015 case VIDIOC_REQBUFS:
1016 case VIDIOC_QUERYBUF32:
1017 case VIDIOC_G_FBUF32:
1018 case VIDIOC_S_FBUF32:
1019 case VIDIOC_OVERLAY32:
1020 case VIDIOC_QBUF32:
1021 case VIDIOC_EXPBUF:
1022 case VIDIOC_DQBUF32:
1023 case VIDIOC_STREAMON32:
1024 case VIDIOC_STREAMOFF32:
1025 case VIDIOC_G_PARM:
1026 case VIDIOC_S_PARM:
1027 case VIDIOC_G_STD:
1028 case VIDIOC_S_STD:
1029 case VIDIOC_ENUMSTD32:
1030 case VIDIOC_ENUMINPUT32:
1031 case VIDIOC_G_CTRL:
1032 case VIDIOC_S_CTRL:
1033 case VIDIOC_G_TUNER:
1034 case VIDIOC_S_TUNER:
1035 case VIDIOC_G_AUDIO:
1036 case VIDIOC_S_AUDIO:
1037 case VIDIOC_QUERYCTRL:
1038 case VIDIOC_QUERYMENU:
1039 case VIDIOC_G_INPUT32:
1040 case VIDIOC_S_INPUT32:
1041 case VIDIOC_G_OUTPUT32:
1042 case VIDIOC_S_OUTPUT32:
1043 case VIDIOC_ENUMOUTPUT:
1044 case VIDIOC_G_AUDOUT:
1045 case VIDIOC_S_AUDOUT:
1046 case VIDIOC_G_MODULATOR:
1047 case VIDIOC_S_MODULATOR:
1048 case VIDIOC_S_FREQUENCY:
1049 case VIDIOC_G_FREQUENCY:
1050 case VIDIOC_CROPCAP:
1051 case VIDIOC_G_CROP:
1052 case VIDIOC_S_CROP:
1053 case VIDIOC_G_SELECTION:
1054 case VIDIOC_S_SELECTION:
1055 case VIDIOC_G_JPEGCOMP:
1056 case VIDIOC_S_JPEGCOMP:
1057 case VIDIOC_QUERYSTD:
1058 case VIDIOC_TRY_FMT32:
1059 case VIDIOC_ENUMAUDIO:
1060 case VIDIOC_ENUMAUDOUT:
1061 case VIDIOC_G_PRIORITY:
1062 case VIDIOC_S_PRIORITY:
1063 case VIDIOC_G_SLICED_VBI_CAP:
1064 case VIDIOC_LOG_STATUS:
1065 case VIDIOC_G_EXT_CTRLS32:
1066 case VIDIOC_S_EXT_CTRLS32:
1067 case VIDIOC_TRY_EXT_CTRLS32:
1068 case VIDIOC_ENUM_FRAMESIZES:
1069 case VIDIOC_ENUM_FRAMEINTERVALS:
1070 case VIDIOC_G_ENC_INDEX:
1071 case VIDIOC_ENCODER_CMD:
1072 case VIDIOC_TRY_ENCODER_CMD:
1073 case VIDIOC_DECODER_CMD:
1074 case VIDIOC_TRY_DECODER_CMD:
1075 case VIDIOC_DBG_S_REGISTER:
1076 case VIDIOC_DBG_G_REGISTER:
1077 case VIDIOC_S_HW_FREQ_SEEK:
1078 case VIDIOC_S_DV_TIMINGS:
1079 case VIDIOC_G_DV_TIMINGS:
1080 case VIDIOC_DQEVENT:
1081 case VIDIOC_DQEVENT32:
1082 case VIDIOC_SUBSCRIBE_EVENT:
1083 case VIDIOC_UNSUBSCRIBE_EVENT:
1084 case VIDIOC_CREATE_BUFS32:
1085 case VIDIOC_PREPARE_BUF32:
1086 case VIDIOC_ENUM_DV_TIMINGS:
1087 case VIDIOC_QUERY_DV_TIMINGS:
1088 case VIDIOC_DV_TIMINGS_CAP:
1089 case VIDIOC_ENUM_FREQ_BANDS:
1090 case VIDIOC_SUBDEV_G_EDID32:
1091 case VIDIOC_SUBDEV_S_EDID32:
1092 ret = do_video_ioctl(file, cmd, arg); 1010 ret = do_video_ioctl(file, cmd, arg);
1093 break; 1011 else if (vdev->fops->compat_ioctl32)
1012 ret = vdev->fops->compat_ioctl32(file, cmd, arg);
1094 1013
1095 default: 1014 if (ret == -ENOIOCTLCMD)
1096 if (vdev->fops->compat_ioctl32) 1015 pr_warn("compat_ioctl32: unknown ioctl '%c', dir=%d, #%d (0x%08x)\n",
1097 ret = vdev->fops->compat_ioctl32(file, cmd, arg); 1016 _IOC_TYPE(cmd), _IOC_DIR(cmd), _IOC_NR(cmd), cmd);
1098
1099 if (ret == -ENOIOCTLCMD)
1100 printk(KERN_WARNING "compat_ioctl32: "
1101 "unknown ioctl '%c', dir=%d, #%d (0x%08x)\n",
1102 _IOC_TYPE(cmd), _IOC_DIR(cmd), _IOC_NR(cmd),
1103 cmd);
1104 break;
1105 }
1106 return ret; 1017 return ret;
1107} 1018}
1108EXPORT_SYMBOL_GPL(v4l2_compat_ioctl32); 1019EXPORT_SYMBOL_GPL(v4l2_compat_ioctl32);
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 6ff002bd5909..55c683254102 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -735,6 +735,8 @@ const char *v4l2_ctrl_get_name(u32 id)
735 case V4L2_CID_MPEG_VIDEO_DEC_PTS: return "Video Decoder PTS"; 735 case V4L2_CID_MPEG_VIDEO_DEC_PTS: return "Video Decoder PTS";
736 case V4L2_CID_MPEG_VIDEO_DEC_FRAME: return "Video Decoder Frame Count"; 736 case V4L2_CID_MPEG_VIDEO_DEC_FRAME: return "Video Decoder Frame Count";
737 case V4L2_CID_MPEG_VIDEO_VBV_DELAY: return "Initial Delay for VBV Control"; 737 case V4L2_CID_MPEG_VIDEO_VBV_DELAY: return "Initial Delay for VBV Control";
738 case V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE: return "Horizontal MV Search Range";
739 case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE: return "Vertical MV Search Range";
738 case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: return "Repeat Sequence Header"; 740 case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: return "Repeat Sequence Header";
739 741
740 /* VPX controls */ 742 /* VPX controls */
@@ -857,6 +859,17 @@ const char *v4l2_ctrl_get_name(u32 id)
857 case V4L2_CID_FM_RX_CLASS: return "FM Radio Receiver Controls"; 859 case V4L2_CID_FM_RX_CLASS: return "FM Radio Receiver Controls";
858 case V4L2_CID_TUNE_DEEMPHASIS: return "De-Emphasis"; 860 case V4L2_CID_TUNE_DEEMPHASIS: return "De-Emphasis";
859 case V4L2_CID_RDS_RECEPTION: return "RDS Reception"; 861 case V4L2_CID_RDS_RECEPTION: return "RDS Reception";
862
863 case V4L2_CID_RF_TUNER_CLASS: return "RF Tuner Controls";
864 case V4L2_CID_RF_TUNER_LNA_GAIN_AUTO: return "LNA Gain, Auto";
865 case V4L2_CID_RF_TUNER_LNA_GAIN: return "LNA Gain";
866 case V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO: return "Mixer Gain, Auto";
867 case V4L2_CID_RF_TUNER_MIXER_GAIN: return "Mixer Gain";
868 case V4L2_CID_RF_TUNER_IF_GAIN_AUTO: return "IF Gain, Auto";
869 case V4L2_CID_RF_TUNER_IF_GAIN: return "IF Gain";
870 case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO: return "Bandwidth, Auto";
871 case V4L2_CID_RF_TUNER_BANDWIDTH: return "Bandwidth";
872 case V4L2_CID_RF_TUNER_PLL_LOCK: return "PLL Lock";
860 default: 873 default:
861 return NULL; 874 return NULL;
862 } 875 }
@@ -906,10 +919,19 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
906 case V4L2_CID_WIDE_DYNAMIC_RANGE: 919 case V4L2_CID_WIDE_DYNAMIC_RANGE:
907 case V4L2_CID_IMAGE_STABILIZATION: 920 case V4L2_CID_IMAGE_STABILIZATION:
908 case V4L2_CID_RDS_RECEPTION: 921 case V4L2_CID_RDS_RECEPTION:
922 case V4L2_CID_RF_TUNER_LNA_GAIN_AUTO:
923 case V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO:
924 case V4L2_CID_RF_TUNER_IF_GAIN_AUTO:
925 case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO:
926 case V4L2_CID_RF_TUNER_PLL_LOCK:
909 *type = V4L2_CTRL_TYPE_BOOLEAN; 927 *type = V4L2_CTRL_TYPE_BOOLEAN;
910 *min = 0; 928 *min = 0;
911 *max = *step = 1; 929 *max = *step = 1;
912 break; 930 break;
931 case V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE:
932 case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE:
933 *type = V4L2_CTRL_TYPE_INTEGER;
934 break;
913 case V4L2_CID_PAN_RESET: 935 case V4L2_CID_PAN_RESET:
914 case V4L2_CID_TILT_RESET: 936 case V4L2_CID_TILT_RESET:
915 case V4L2_CID_FLASH_STROBE: 937 case V4L2_CID_FLASH_STROBE:
@@ -991,6 +1013,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
991 case V4L2_CID_IMAGE_PROC_CLASS: 1013 case V4L2_CID_IMAGE_PROC_CLASS:
992 case V4L2_CID_DV_CLASS: 1014 case V4L2_CID_DV_CLASS:
993 case V4L2_CID_FM_RX_CLASS: 1015 case V4L2_CID_FM_RX_CLASS:
1016 case V4L2_CID_RF_TUNER_CLASS:
994 *type = V4L2_CTRL_TYPE_CTRL_CLASS; 1017 *type = V4L2_CTRL_TYPE_CTRL_CLASS;
995 /* You can neither read not write these */ 1018 /* You can neither read not write these */
996 *flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY; 1019 *flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
@@ -1063,6 +1086,10 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
1063 case V4L2_CID_PILOT_TONE_FREQUENCY: 1086 case V4L2_CID_PILOT_TONE_FREQUENCY:
1064 case V4L2_CID_TUNE_POWER_LEVEL: 1087 case V4L2_CID_TUNE_POWER_LEVEL:
1065 case V4L2_CID_TUNE_ANTENNA_CAPACITOR: 1088 case V4L2_CID_TUNE_ANTENNA_CAPACITOR:
1089 case V4L2_CID_RF_TUNER_LNA_GAIN:
1090 case V4L2_CID_RF_TUNER_MIXER_GAIN:
1091 case V4L2_CID_RF_TUNER_IF_GAIN:
1092 case V4L2_CID_RF_TUNER_BANDWIDTH:
1066 *flags |= V4L2_CTRL_FLAG_SLIDER; 1093 *flags |= V4L2_CTRL_FLAG_SLIDER;
1067 break; 1094 break;
1068 case V4L2_CID_PAN_RELATIVE: 1095 case V4L2_CID_PAN_RELATIVE:
@@ -1081,6 +1108,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
1081 case V4L2_CID_DV_RX_POWER_PRESENT: 1108 case V4L2_CID_DV_RX_POWER_PRESENT:
1082 *flags |= V4L2_CTRL_FLAG_READ_ONLY; 1109 *flags |= V4L2_CTRL_FLAG_READ_ONLY;
1083 break; 1110 break;
1111 case V4L2_CID_RF_TUNER_PLL_LOCK:
1112 *flags |= V4L2_CTRL_FLAG_VOLATILE;
1113 break;
1084 } 1114 }
1085} 1115}
1086EXPORT_SYMBOL(v4l2_ctrl_fill); 1116EXPORT_SYMBOL(v4l2_ctrl_fill);
@@ -1921,7 +1951,8 @@ void v4l2_ctrl_cluster(unsigned ncontrols, struct v4l2_ctrl **controls)
1921 int i; 1951 int i;
1922 1952
1923 /* The first control is the master control and it must not be NULL */ 1953 /* The first control is the master control and it must not be NULL */
1924 BUG_ON(ncontrols == 0 || controls[0] == NULL); 1954 if (WARN_ON(ncontrols == 0 || controls[0] == NULL))
1955 return;
1925 1956
1926 for (i = 0; i < ncontrols; i++) { 1957 for (i = 0; i < ncontrols; i++) {
1927 if (controls[i]) { 1958 if (controls[i]) {
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 0a30dbf3d05c..634d863c05b4 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -554,6 +554,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
554 bool is_vid = vdev->vfl_type == VFL_TYPE_GRABBER; 554 bool is_vid = vdev->vfl_type == VFL_TYPE_GRABBER;
555 bool is_vbi = vdev->vfl_type == VFL_TYPE_VBI; 555 bool is_vbi = vdev->vfl_type == VFL_TYPE_VBI;
556 bool is_radio = vdev->vfl_type == VFL_TYPE_RADIO; 556 bool is_radio = vdev->vfl_type == VFL_TYPE_RADIO;
557 bool is_sdr = vdev->vfl_type == VFL_TYPE_SDR;
557 bool is_rx = vdev->vfl_dir != VFL_DIR_TX; 558 bool is_rx = vdev->vfl_dir != VFL_DIR_TX;
558 bool is_tx = vdev->vfl_dir != VFL_DIR_RX; 559 bool is_tx = vdev->vfl_dir != VFL_DIR_RX;
559 560
@@ -662,9 +663,20 @@ static void determine_valid_ioctls(struct video_device *vdev)
662 ops->vidioc_try_fmt_sliced_vbi_out))) 663 ops->vidioc_try_fmt_sliced_vbi_out)))
663 set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls); 664 set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
664 SET_VALID_IOCTL(ops, VIDIOC_G_SLICED_VBI_CAP, vidioc_g_sliced_vbi_cap); 665 SET_VALID_IOCTL(ops, VIDIOC_G_SLICED_VBI_CAP, vidioc_g_sliced_vbi_cap);
666 } else if (is_sdr) {
667 /* SDR specific ioctls */
668 if (ops->vidioc_enum_fmt_sdr_cap)
669 set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
670 if (ops->vidioc_g_fmt_sdr_cap)
671 set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
672 if (ops->vidioc_s_fmt_sdr_cap)
673 set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
674 if (ops->vidioc_try_fmt_sdr_cap)
675 set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
665 } 676 }
666 if (!is_radio) { 677
667 /* ioctls valid for video or vbi */ 678 if (is_vid || is_vbi || is_sdr) {
679 /* ioctls valid for video, vbi or sdr */
668 SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs); 680 SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs);
669 SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf); 681 SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf);
670 SET_VALID_IOCTL(ops, VIDIOC_QBUF, vidioc_qbuf); 682 SET_VALID_IOCTL(ops, VIDIOC_QBUF, vidioc_qbuf);
@@ -672,6 +684,10 @@ static void determine_valid_ioctls(struct video_device *vdev)
672 SET_VALID_IOCTL(ops, VIDIOC_DQBUF, vidioc_dqbuf); 684 SET_VALID_IOCTL(ops, VIDIOC_DQBUF, vidioc_dqbuf);
673 SET_VALID_IOCTL(ops, VIDIOC_CREATE_BUFS, vidioc_create_bufs); 685 SET_VALID_IOCTL(ops, VIDIOC_CREATE_BUFS, vidioc_create_bufs);
674 SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf); 686 SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf);
687 }
688
689 if (is_vid || is_vbi) {
690 /* ioctls valid for video or vbi */
675 if (ops->vidioc_s_std) 691 if (ops->vidioc_s_std)
676 set_bit(_IOC_NR(VIDIOC_ENUMSTD), valid_ioctls); 692 set_bit(_IOC_NR(VIDIOC_ENUMSTD), valid_ioctls);
677 SET_VALID_IOCTL(ops, VIDIOC_S_STD, vidioc_s_std); 693 SET_VALID_IOCTL(ops, VIDIOC_S_STD, vidioc_s_std);
@@ -685,6 +701,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
685 SET_VALID_IOCTL(ops, VIDIOC_G_AUDIO, vidioc_g_audio); 701 SET_VALID_IOCTL(ops, VIDIOC_G_AUDIO, vidioc_g_audio);
686 SET_VALID_IOCTL(ops, VIDIOC_S_AUDIO, vidioc_s_audio); 702 SET_VALID_IOCTL(ops, VIDIOC_S_AUDIO, vidioc_s_audio);
687 SET_VALID_IOCTL(ops, VIDIOC_QUERY_DV_TIMINGS, vidioc_query_dv_timings); 703 SET_VALID_IOCTL(ops, VIDIOC_QUERY_DV_TIMINGS, vidioc_query_dv_timings);
704 SET_VALID_IOCTL(ops, VIDIOC_S_EDID, vidioc_s_edid);
688 } 705 }
689 if (is_tx) { 706 if (is_tx) {
690 SET_VALID_IOCTL(ops, VIDIOC_ENUMOUTPUT, vidioc_enum_output); 707 SET_VALID_IOCTL(ops, VIDIOC_ENUMOUTPUT, vidioc_enum_output);
@@ -710,9 +727,10 @@ static void determine_valid_ioctls(struct video_device *vdev)
710 SET_VALID_IOCTL(ops, VIDIOC_G_DV_TIMINGS, vidioc_g_dv_timings); 727 SET_VALID_IOCTL(ops, VIDIOC_G_DV_TIMINGS, vidioc_g_dv_timings);
711 SET_VALID_IOCTL(ops, VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings); 728 SET_VALID_IOCTL(ops, VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings);
712 SET_VALID_IOCTL(ops, VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap); 729 SET_VALID_IOCTL(ops, VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap);
730 SET_VALID_IOCTL(ops, VIDIOC_G_EDID, vidioc_g_edid);
713 } 731 }
714 if (is_tx) { 732 if (is_tx && (is_radio || is_sdr)) {
715 /* transmitter only ioctls */ 733 /* radio transmitter only ioctls */
716 SET_VALID_IOCTL(ops, VIDIOC_G_MODULATOR, vidioc_g_modulator); 734 SET_VALID_IOCTL(ops, VIDIOC_G_MODULATOR, vidioc_g_modulator);
717 SET_VALID_IOCTL(ops, VIDIOC_S_MODULATOR, vidioc_s_modulator); 735 SET_VALID_IOCTL(ops, VIDIOC_S_MODULATOR, vidioc_s_modulator);
718 } 736 }
@@ -758,6 +776,8 @@ static void determine_valid_ioctls(struct video_device *vdev)
758 * %VFL_TYPE_RADIO - A radio card 776 * %VFL_TYPE_RADIO - A radio card
759 * 777 *
760 * %VFL_TYPE_SUBDEV - A subdevice 778 * %VFL_TYPE_SUBDEV - A subdevice
779 *
780 * %VFL_TYPE_SDR - Software Defined Radio
761 */ 781 */
762int __video_register_device(struct video_device *vdev, int type, int nr, 782int __video_register_device(struct video_device *vdev, int type, int nr,
763 int warn_if_nr_in_use, struct module *owner) 783 int warn_if_nr_in_use, struct module *owner)
@@ -797,6 +817,10 @@ int __video_register_device(struct video_device *vdev, int type, int nr,
797 case VFL_TYPE_SUBDEV: 817 case VFL_TYPE_SUBDEV:
798 name_base = "v4l-subdev"; 818 name_base = "v4l-subdev";
799 break; 819 break;
820 case VFL_TYPE_SDR:
821 /* Use device name 'swradio' because 'sdr' was already taken. */
822 name_base = "swradio";
823 break;
800 default: 824 default:
801 printk(KERN_ERR "%s called with unknown type: %d\n", 825 printk(KERN_ERR "%s called with unknown type: %d\n",
802 __func__, type); 826 __func__, type);
diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c
index f7902fe8a526..48b20dfcc4d0 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -26,6 +26,10 @@
26#include <linux/v4l2-dv-timings.h> 26#include <linux/v4l2-dv-timings.h>
27#include <media/v4l2-dv-timings.h> 27#include <media/v4l2-dv-timings.h>
28 28
29MODULE_AUTHOR("Hans Verkuil");
30MODULE_DESCRIPTION("V4L2 DV Timings Helper Functions");
31MODULE_LICENSE("GPL");
32
29const struct v4l2_dv_timings v4l2_dv_timings_presets[] = { 33const struct v4l2_dv_timings v4l2_dv_timings_presets[] = {
30 V4L2_DV_BT_CEA_640X480P59_94, 34 V4L2_DV_BT_CEA_640X480P59_94,
31 V4L2_DV_BT_CEA_720X480I59_94, 35 V4L2_DV_BT_CEA_720X480I59_94,
@@ -324,6 +328,10 @@ EXPORT_SYMBOL_GPL(v4l2_print_dv_timings);
324 * This function will attempt to detect if the given values correspond to a 328 * This function will attempt to detect if the given values correspond to a
325 * valid CVT format. If so, then it will return true, and fmt will be filled 329 * valid CVT format. If so, then it will return true, and fmt will be filled
326 * in with the found CVT timings. 330 * in with the found CVT timings.
331 *
332 * TODO: VESA defined a new version 2 of their reduced blanking
333 * formula. Support for that is currently missing in this CVT
334 * detection function.
327 */ 335 */
328bool v4l2_detect_cvt(unsigned frame_height, unsigned hfreq, unsigned vsync, 336bool v4l2_detect_cvt(unsigned frame_height, unsigned hfreq, unsigned vsync,
329 u32 polarities, struct v4l2_dv_timings *fmt) 337 u32 polarities, struct v4l2_dv_timings *fmt)
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 707aef705a47..d9113cc71c77 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -152,6 +152,7 @@ const char *v4l2_type_names[] = {
152 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "vid-out-overlay", 152 [V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY] = "vid-out-overlay",
153 [V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE] = "vid-cap-mplane", 153 [V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE] = "vid-cap-mplane",
154 [V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE] = "vid-out-mplane", 154 [V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE] = "vid-out-mplane",
155 [V4L2_BUF_TYPE_SDR_CAPTURE] = "sdr-cap",
155}; 156};
156EXPORT_SYMBOL(v4l2_type_names); 157EXPORT_SYMBOL(v4l2_type_names);
157 158
@@ -245,6 +246,7 @@ static void v4l_print_format(const void *arg, bool write_only)
245 const struct v4l2_vbi_format *vbi; 246 const struct v4l2_vbi_format *vbi;
246 const struct v4l2_sliced_vbi_format *sliced; 247 const struct v4l2_sliced_vbi_format *sliced;
247 const struct v4l2_window *win; 248 const struct v4l2_window *win;
249 const struct v4l2_sdr_format *sdr;
248 unsigned i; 250 unsigned i;
249 251
250 pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); 252 pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
@@ -318,6 +320,14 @@ static void v4l_print_format(const void *arg, bool write_only)
318 sliced->service_lines[0][i], 320 sliced->service_lines[0][i],
319 sliced->service_lines[1][i]); 321 sliced->service_lines[1][i]);
320 break; 322 break;
323 case V4L2_BUF_TYPE_SDR_CAPTURE:
324 sdr = &p->fmt.sdr;
325 pr_cont(", pixelformat=%c%c%c%c\n",
326 (sdr->pixelformat >> 0) & 0xff,
327 (sdr->pixelformat >> 8) & 0xff,
328 (sdr->pixelformat >> 16) & 0xff,
329 (sdr->pixelformat >> 24) & 0xff);
330 break;
321 } 331 }
322} 332}
323 333
@@ -834,6 +844,14 @@ static void v4l_print_freq_band(const void *arg, bool write_only)
834 p->rangehigh, p->modulation); 844 p->rangehigh, p->modulation);
835} 845}
836 846
847static void v4l_print_edid(const void *arg, bool write_only)
848{
849 const struct v4l2_edid *p = arg;
850
851 pr_cont("pad=%u, start_block=%u, blocks=%u\n",
852 p->pad, p->start_block, p->blocks);
853}
854
837static void v4l_print_u32(const void *arg, bool write_only) 855static void v4l_print_u32(const void *arg, bool write_only)
838{ 856{
839 pr_cont("value=%u\n", *(const u32 *)arg); 857 pr_cont("value=%u\n", *(const u32 *)arg);
@@ -881,6 +899,7 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)
881 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; 899 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
882 bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER; 900 bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER;
883 bool is_vbi = vfd->vfl_type == VFL_TYPE_VBI; 901 bool is_vbi = vfd->vfl_type == VFL_TYPE_VBI;
902 bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR;
884 bool is_rx = vfd->vfl_dir != VFL_DIR_TX; 903 bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
885 bool is_tx = vfd->vfl_dir != VFL_DIR_RX; 904 bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
886 905
@@ -930,6 +949,10 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)
930 if (is_vbi && is_tx && ops->vidioc_g_fmt_sliced_vbi_out) 949 if (is_vbi && is_tx && ops->vidioc_g_fmt_sliced_vbi_out)
931 return 0; 950 return 0;
932 break; 951 break;
952 case V4L2_BUF_TYPE_SDR_CAPTURE:
953 if (is_sdr && is_rx && ops->vidioc_g_fmt_sdr_cap)
954 return 0;
955 break;
933 default: 956 default:
934 break; 957 break;
935 } 958 }
@@ -1049,6 +1072,10 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
1049 if (unlikely(!is_tx || !ops->vidioc_enum_fmt_vid_out_mplane)) 1072 if (unlikely(!is_tx || !ops->vidioc_enum_fmt_vid_out_mplane))
1050 break; 1073 break;
1051 return ops->vidioc_enum_fmt_vid_out_mplane(file, fh, arg); 1074 return ops->vidioc_enum_fmt_vid_out_mplane(file, fh, arg);
1075 case V4L2_BUF_TYPE_SDR_CAPTURE:
1076 if (unlikely(!is_rx || !ops->vidioc_enum_fmt_sdr_cap))
1077 break;
1078 return ops->vidioc_enum_fmt_sdr_cap(file, fh, arg);
1052 } 1079 }
1053 return -EINVAL; 1080 return -EINVAL;
1054} 1081}
@@ -1059,6 +1086,7 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
1059 struct v4l2_format *p = arg; 1086 struct v4l2_format *p = arg;
1060 struct video_device *vfd = video_devdata(file); 1087 struct video_device *vfd = video_devdata(file);
1061 bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER; 1088 bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER;
1089 bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR;
1062 bool is_rx = vfd->vfl_dir != VFL_DIR_TX; 1090 bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
1063 bool is_tx = vfd->vfl_dir != VFL_DIR_RX; 1091 bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
1064 1092
@@ -1103,6 +1131,10 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
1103 if (unlikely(!is_tx || is_vid || !ops->vidioc_g_fmt_sliced_vbi_out)) 1131 if (unlikely(!is_tx || is_vid || !ops->vidioc_g_fmt_sliced_vbi_out))
1104 break; 1132 break;
1105 return ops->vidioc_g_fmt_sliced_vbi_out(file, fh, arg); 1133 return ops->vidioc_g_fmt_sliced_vbi_out(file, fh, arg);
1134 case V4L2_BUF_TYPE_SDR_CAPTURE:
1135 if (unlikely(!is_rx || !is_sdr || !ops->vidioc_g_fmt_sdr_cap))
1136 break;
1137 return ops->vidioc_g_fmt_sdr_cap(file, fh, arg);
1106 } 1138 }
1107 return -EINVAL; 1139 return -EINVAL;
1108} 1140}
@@ -1113,6 +1145,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
1113 struct v4l2_format *p = arg; 1145 struct v4l2_format *p = arg;
1114 struct video_device *vfd = video_devdata(file); 1146 struct video_device *vfd = video_devdata(file);
1115 bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER; 1147 bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER;
1148 bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR;
1116 bool is_rx = vfd->vfl_dir != VFL_DIR_TX; 1149 bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
1117 bool is_tx = vfd->vfl_dir != VFL_DIR_RX; 1150 bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
1118 1151
@@ -1167,6 +1200,11 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
1167 break; 1200 break;
1168 CLEAR_AFTER_FIELD(p, fmt.sliced); 1201 CLEAR_AFTER_FIELD(p, fmt.sliced);
1169 return ops->vidioc_s_fmt_sliced_vbi_out(file, fh, arg); 1202 return ops->vidioc_s_fmt_sliced_vbi_out(file, fh, arg);
1203 case V4L2_BUF_TYPE_SDR_CAPTURE:
1204 if (unlikely(!is_rx || !is_sdr || !ops->vidioc_s_fmt_sdr_cap))
1205 break;
1206 CLEAR_AFTER_FIELD(p, fmt.sdr);
1207 return ops->vidioc_s_fmt_sdr_cap(file, fh, arg);
1170 } 1208 }
1171 return -EINVAL; 1209 return -EINVAL;
1172} 1210}
@@ -1177,6 +1215,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
1177 struct v4l2_format *p = arg; 1215 struct v4l2_format *p = arg;
1178 struct video_device *vfd = video_devdata(file); 1216 struct video_device *vfd = video_devdata(file);
1179 bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER; 1217 bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER;
1218 bool is_sdr = vfd->vfl_type == VFL_TYPE_SDR;
1180 bool is_rx = vfd->vfl_dir != VFL_DIR_TX; 1219 bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
1181 bool is_tx = vfd->vfl_dir != VFL_DIR_RX; 1220 bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
1182 1221
@@ -1231,6 +1270,11 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
1231 break; 1270 break;
1232 CLEAR_AFTER_FIELD(p, fmt.sliced); 1271 CLEAR_AFTER_FIELD(p, fmt.sliced);
1233 return ops->vidioc_try_fmt_sliced_vbi_out(file, fh, arg); 1272 return ops->vidioc_try_fmt_sliced_vbi_out(file, fh, arg);
1273 case V4L2_BUF_TYPE_SDR_CAPTURE:
1274 if (unlikely(!is_rx || !is_sdr || !ops->vidioc_try_fmt_sdr_cap))
1275 break;
1276 CLEAR_AFTER_FIELD(p, fmt.sdr);
1277 return ops->vidioc_try_fmt_sdr_cap(file, fh, arg);
1234 } 1278 }
1235 return -EINVAL; 1279 return -EINVAL;
1236} 1280}
@@ -1291,8 +1335,11 @@ static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops,
1291 struct video_device *vfd = video_devdata(file); 1335 struct video_device *vfd = video_devdata(file);
1292 struct v4l2_frequency *p = arg; 1336 struct v4l2_frequency *p = arg;
1293 1337
1294 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? 1338 if (vfd->vfl_type == VFL_TYPE_SDR)
1295 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1339 p->type = V4L2_TUNER_ADC;
1340 else
1341 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
1342 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1296 return ops->vidioc_g_frequency(file, fh, p); 1343 return ops->vidioc_g_frequency(file, fh, p);
1297} 1344}
1298 1345
@@ -1303,10 +1350,15 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops,
1303 const struct v4l2_frequency *p = arg; 1350 const struct v4l2_frequency *p = arg;
1304 enum v4l2_tuner_type type; 1351 enum v4l2_tuner_type type;
1305 1352
1306 type = (vfd->vfl_type == VFL_TYPE_RADIO) ? 1353 if (vfd->vfl_type == VFL_TYPE_SDR) {
1307 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1354 if (p->type != V4L2_TUNER_ADC && p->type != V4L2_TUNER_RF)
1308 if (p->type != type) 1355 return -EINVAL;
1309 return -EINVAL; 1356 } else {
1357 type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
1358 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1359 if (type != p->type)
1360 return -EINVAL;
1361 }
1310 return ops->vidioc_s_frequency(file, fh, p); 1362 return ops->vidioc_s_frequency(file, fh, p);
1311} 1363}
1312 1364
@@ -1386,6 +1438,10 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops,
1386 struct v4l2_hw_freq_seek *p = arg; 1438 struct v4l2_hw_freq_seek *p = arg;
1387 enum v4l2_tuner_type type; 1439 enum v4l2_tuner_type type;
1388 1440
1441 /* s_hw_freq_seek is not supported for SDR for now */
1442 if (vfd->vfl_type == VFL_TYPE_SDR)
1443 return -EINVAL;
1444
1389 type = (vfd->vfl_type == VFL_TYPE_RADIO) ? 1445 type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
1390 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1446 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1391 if (p->type != type) 1447 if (p->type != type)
@@ -1885,11 +1941,16 @@ static int v4l_enum_freq_bands(const struct v4l2_ioctl_ops *ops,
1885 enum v4l2_tuner_type type; 1941 enum v4l2_tuner_type type;
1886 int err; 1942 int err;
1887 1943
1888 type = (vfd->vfl_type == VFL_TYPE_RADIO) ? 1944 if (vfd->vfl_type == VFL_TYPE_SDR) {
1889 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1945 if (p->type != V4L2_TUNER_ADC && p->type != V4L2_TUNER_RF)
1890 1946 return -EINVAL;
1891 if (type != p->type) 1947 type = p->type;
1892 return -EINVAL; 1948 } else {
1949 type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
1950 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1951 if (type != p->type)
1952 return -EINVAL;
1953 }
1893 if (ops->vidioc_enum_freq_bands) 1954 if (ops->vidioc_enum_freq_bands)
1894 return ops->vidioc_enum_freq_bands(file, fh, p); 1955 return ops->vidioc_enum_freq_bands(file, fh, p);
1895 if (is_valid_ioctl(vfd, VIDIOC_G_TUNER)) { 1956 if (is_valid_ioctl(vfd, VIDIOC_G_TUNER)) {
@@ -2009,6 +2070,8 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = {
2009 IOCTL_INFO_FNC(VIDIOC_QUERYMENU, v4l_querymenu, v4l_print_querymenu, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_querymenu, index)), 2070 IOCTL_INFO_FNC(VIDIOC_QUERYMENU, v4l_querymenu, v4l_print_querymenu, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_querymenu, index)),
2010 IOCTL_INFO_STD(VIDIOC_G_INPUT, vidioc_g_input, v4l_print_u32, 0), 2071 IOCTL_INFO_STD(VIDIOC_G_INPUT, vidioc_g_input, v4l_print_u32, 0),
2011 IOCTL_INFO_FNC(VIDIOC_S_INPUT, v4l_s_input, v4l_print_u32, INFO_FL_PRIO), 2072 IOCTL_INFO_FNC(VIDIOC_S_INPUT, v4l_s_input, v4l_print_u32, INFO_FL_PRIO),
2073 IOCTL_INFO_STD(VIDIOC_G_EDID, vidioc_g_edid, v4l_print_edid, INFO_FL_CLEAR(v4l2_edid, edid)),
2074 IOCTL_INFO_STD(VIDIOC_S_EDID, vidioc_s_edid, v4l_print_edid, INFO_FL_PRIO | INFO_FL_CLEAR(v4l2_edid, edid)),
2012 IOCTL_INFO_STD(VIDIOC_G_OUTPUT, vidioc_g_output, v4l_print_u32, 0), 2075 IOCTL_INFO_STD(VIDIOC_G_OUTPUT, vidioc_g_output, v4l_print_u32, 0),
2013 IOCTL_INFO_FNC(VIDIOC_S_OUTPUT, v4l_s_output, v4l_print_u32, INFO_FL_PRIO), 2076 IOCTL_INFO_FNC(VIDIOC_S_OUTPUT, v4l_s_output, v4l_print_u32, INFO_FL_PRIO),
2014 IOCTL_INFO_FNC(VIDIOC_ENUMOUTPUT, v4l_enumoutput, v4l_print_enumoutput, INFO_FL_CLEAR(v4l2_output, index)), 2077 IOCTL_INFO_FNC(VIDIOC_ENUMOUTPUT, v4l_enumoutput, v4l_print_enumoutput, INFO_FL_CLEAR(v4l2_output, index)),
@@ -2221,9 +2284,9 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
2221 break; 2284 break;
2222 } 2285 }
2223 2286
2224 case VIDIOC_SUBDEV_G_EDID: 2287 case VIDIOC_G_EDID:
2225 case VIDIOC_SUBDEV_S_EDID: { 2288 case VIDIOC_S_EDID: {
2226 struct v4l2_subdev_edid *edid = parg; 2289 struct v4l2_edid *edid = parg;
2227 2290
2228 if (edid->blocks) { 2291 if (edid->blocks) {
2229 if (edid->blocks > 256) { 2292 if (edid->blocks > 256) {
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 996c248dea42..aea84ac5688a 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -349,10 +349,10 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
349 sd, pad, set_selection, subdev_fh, sel); 349 sd, pad, set_selection, subdev_fh, sel);
350 } 350 }
351 351
352 case VIDIOC_SUBDEV_G_EDID: 352 case VIDIOC_G_EDID:
353 return v4l2_subdev_call(sd, pad, get_edid, arg); 353 return v4l2_subdev_call(sd, pad, get_edid, arg);
354 354
355 case VIDIOC_SUBDEV_S_EDID: 355 case VIDIOC_S_EDID:
356 return v4l2_subdev_call(sd, pad, set_edid, arg); 356 return v4l2_subdev_call(sd, pad, set_edid, arg);
357#endif 357#endif
358 default: 358 default:
@@ -368,6 +368,17 @@ static long subdev_ioctl(struct file *file, unsigned int cmd,
368 return video_usercopy(file, cmd, arg, subdev_do_ioctl); 368 return video_usercopy(file, cmd, arg, subdev_do_ioctl);
369} 369}
370 370
371#ifdef CONFIG_COMPAT
372static long subdev_compat_ioctl32(struct file *file, unsigned int cmd,
373 unsigned long arg)
374{
375 struct video_device *vdev = video_devdata(file);
376 struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
377
378 return v4l2_subdev_call(sd, core, compat_ioctl32, cmd, arg);
379}
380#endif
381
371static unsigned int subdev_poll(struct file *file, poll_table *wait) 382static unsigned int subdev_poll(struct file *file, poll_table *wait)
372{ 383{
373 struct video_device *vdev = video_devdata(file); 384 struct video_device *vdev = video_devdata(file);
@@ -389,6 +400,9 @@ const struct v4l2_file_operations v4l2_subdev_fops = {
389 .owner = THIS_MODULE, 400 .owner = THIS_MODULE,
390 .open = subdev_open, 401 .open = subdev_open,
391 .unlocked_ioctl = subdev_ioctl, 402 .unlocked_ioctl = subdev_ioctl,
403#ifdef CONFIG_COMPAT
404 .compat_ioctl32 = subdev_compat_ioctl32,
405#endif
392 .release = subdev_close, 406 .release = subdev_close,
393 .poll = subdev_poll, 407 .poll = subdev_poll,
394}; 408};
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index a127925c9d61..f9059bb73840 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -33,17 +33,74 @@ module_param(debug, int, 0644);
33 printk(KERN_DEBUG "vb2: " fmt, ## arg); \ 33 printk(KERN_DEBUG "vb2: " fmt, ## arg); \
34 } while (0) 34 } while (0)
35 35
36#define call_memop(q, op, args...) \ 36#ifdef CONFIG_VIDEO_ADV_DEBUG
37 (((q)->mem_ops->op) ? \ 37
38 ((q)->mem_ops->op(args)) : 0) 38/*
39 * If advanced debugging is on, then count how often each op is called,
40 * which can either be per-buffer or per-queue.
41 *
42 * If the op failed then the 'fail_' variant is called to decrease the
43 * counter. That makes it easy to check that the 'init' and 'cleanup'
44 * (and variations thereof) stay balanced.
45 */
46
47#define call_memop(vb, op, args...) \
48({ \
49 struct vb2_queue *_q = (vb)->vb2_queue; \
50 dprintk(2, "call_memop(%p, %d, %s)%s\n", \
51 _q, (vb)->v4l2_buf.index, #op, \
52 _q->mem_ops->op ? "" : " (nop)"); \
53 (vb)->cnt_mem_ ## op++; \
54 _q->mem_ops->op ? _q->mem_ops->op(args) : 0; \
55})
56#define fail_memop(vb, op) ((vb)->cnt_mem_ ## op--)
57
58#define call_qop(q, op, args...) \
59({ \
60 dprintk(2, "call_qop(%p, %s)%s\n", q, #op, \
61 (q)->ops->op ? "" : " (nop)"); \
62 (q)->cnt_ ## op++; \
63 (q)->ops->op ? (q)->ops->op(args) : 0; \
64})
65#define fail_qop(q, op) ((q)->cnt_ ## op--)
66
67#define call_vb_qop(vb, op, args...) \
68({ \
69 struct vb2_queue *_q = (vb)->vb2_queue; \
70 dprintk(2, "call_vb_qop(%p, %d, %s)%s\n", \
71 _q, (vb)->v4l2_buf.index, #op, \
72 _q->ops->op ? "" : " (nop)"); \
73 (vb)->cnt_ ## op++; \
74 _q->ops->op ? _q->ops->op(args) : 0; \
75})
76#define fail_vb_qop(vb, op) ((vb)->cnt_ ## op--)
77
78#else
79
80#define call_memop(vb, op, args...) \
81 ((vb)->vb2_queue->mem_ops->op ? (vb)->vb2_queue->mem_ops->op(args) : 0)
82#define fail_memop(vb, op)
39 83
40#define call_qop(q, op, args...) \ 84#define call_qop(q, op, args...) \
41 (((q)->ops->op) ? ((q)->ops->op(args)) : 0) 85 ((q)->ops->op ? (q)->ops->op(args) : 0)
86#define fail_qop(q, op)
42 87
88#define call_vb_qop(vb, op, args...) \
89 ((vb)->vb2_queue->ops->op ? (vb)->vb2_queue->ops->op(args) : 0)
90#define fail_vb_qop(vb, op)
91
92#endif
93
94/* Flags that are set by the vb2 core */
43#define V4L2_BUFFER_MASK_FLAGS (V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED | \ 95#define V4L2_BUFFER_MASK_FLAGS (V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED | \
44 V4L2_BUF_FLAG_DONE | V4L2_BUF_FLAG_ERROR | \ 96 V4L2_BUF_FLAG_DONE | V4L2_BUF_FLAG_ERROR | \
45 V4L2_BUF_FLAG_PREPARED | \ 97 V4L2_BUF_FLAG_PREPARED | \
46 V4L2_BUF_FLAG_TIMESTAMP_MASK) 98 V4L2_BUF_FLAG_TIMESTAMP_MASK)
99/* Output buffer flags that should be passed on to the driver */
100#define V4L2_BUFFER_OUT_FLAGS (V4L2_BUF_FLAG_PFRAME | V4L2_BUF_FLAG_BFRAME | \
101 V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_TIMECODE)
102
103static void __vb2_queue_cancel(struct vb2_queue *q);
47 104
48/** 105/**
49 * __vb2_buf_mem_alloc() - allocate video memory for the given buffer 106 * __vb2_buf_mem_alloc() - allocate video memory for the given buffer
@@ -61,7 +118,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
61 for (plane = 0; plane < vb->num_planes; ++plane) { 118 for (plane = 0; plane < vb->num_planes; ++plane) {
62 unsigned long size = PAGE_ALIGN(q->plane_sizes[plane]); 119 unsigned long size = PAGE_ALIGN(q->plane_sizes[plane]);
63 120
64 mem_priv = call_memop(q, alloc, q->alloc_ctx[plane], 121 mem_priv = call_memop(vb, alloc, q->alloc_ctx[plane],
65 size, q->gfp_flags); 122 size, q->gfp_flags);
66 if (IS_ERR_OR_NULL(mem_priv)) 123 if (IS_ERR_OR_NULL(mem_priv))
67 goto free; 124 goto free;
@@ -73,9 +130,10 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
73 130
74 return 0; 131 return 0;
75free: 132free:
133 fail_memop(vb, alloc);
76 /* Free already allocated memory if one of the allocations failed */ 134 /* Free already allocated memory if one of the allocations failed */
77 for (; plane > 0; --plane) { 135 for (; plane > 0; --plane) {
78 call_memop(q, put, vb->planes[plane - 1].mem_priv); 136 call_memop(vb, put, vb->planes[plane - 1].mem_priv);
79 vb->planes[plane - 1].mem_priv = NULL; 137 vb->planes[plane - 1].mem_priv = NULL;
80 } 138 }
81 139
@@ -87,11 +145,10 @@ free:
87 */ 145 */
88static void __vb2_buf_mem_free(struct vb2_buffer *vb) 146static void __vb2_buf_mem_free(struct vb2_buffer *vb)
89{ 147{
90 struct vb2_queue *q = vb->vb2_queue;
91 unsigned int plane; 148 unsigned int plane;
92 149
93 for (plane = 0; plane < vb->num_planes; ++plane) { 150 for (plane = 0; plane < vb->num_planes; ++plane) {
94 call_memop(q, put, vb->planes[plane].mem_priv); 151 call_memop(vb, put, vb->planes[plane].mem_priv);
95 vb->planes[plane].mem_priv = NULL; 152 vb->planes[plane].mem_priv = NULL;
96 dprintk(3, "Freed plane %d of buffer %d\n", plane, 153 dprintk(3, "Freed plane %d of buffer %d\n", plane,
97 vb->v4l2_buf.index); 154 vb->v4l2_buf.index);
@@ -104,12 +161,11 @@ static void __vb2_buf_mem_free(struct vb2_buffer *vb)
104 */ 161 */
105static void __vb2_buf_userptr_put(struct vb2_buffer *vb) 162static void __vb2_buf_userptr_put(struct vb2_buffer *vb)
106{ 163{
107 struct vb2_queue *q = vb->vb2_queue;
108 unsigned int plane; 164 unsigned int plane;
109 165
110 for (plane = 0; plane < vb->num_planes; ++plane) { 166 for (plane = 0; plane < vb->num_planes; ++plane) {
111 if (vb->planes[plane].mem_priv) 167 if (vb->planes[plane].mem_priv)
112 call_memop(q, put_userptr, vb->planes[plane].mem_priv); 168 call_memop(vb, put_userptr, vb->planes[plane].mem_priv);
113 vb->planes[plane].mem_priv = NULL; 169 vb->planes[plane].mem_priv = NULL;
114 } 170 }
115} 171}
@@ -118,15 +174,15 @@ static void __vb2_buf_userptr_put(struct vb2_buffer *vb)
118 * __vb2_plane_dmabuf_put() - release memory associated with 174 * __vb2_plane_dmabuf_put() - release memory associated with
119 * a DMABUF shared plane 175 * a DMABUF shared plane
120 */ 176 */
121static void __vb2_plane_dmabuf_put(struct vb2_queue *q, struct vb2_plane *p) 177static void __vb2_plane_dmabuf_put(struct vb2_buffer *vb, struct vb2_plane *p)
122{ 178{
123 if (!p->mem_priv) 179 if (!p->mem_priv)
124 return; 180 return;
125 181
126 if (p->dbuf_mapped) 182 if (p->dbuf_mapped)
127 call_memop(q, unmap_dmabuf, p->mem_priv); 183 call_memop(vb, unmap_dmabuf, p->mem_priv);
128 184
129 call_memop(q, detach_dmabuf, p->mem_priv); 185 call_memop(vb, detach_dmabuf, p->mem_priv);
130 dma_buf_put(p->dbuf); 186 dma_buf_put(p->dbuf);
131 memset(p, 0, sizeof(*p)); 187 memset(p, 0, sizeof(*p));
132} 188}
@@ -137,11 +193,10 @@ static void __vb2_plane_dmabuf_put(struct vb2_queue *q, struct vb2_plane *p)
137 */ 193 */
138static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb) 194static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb)
139{ 195{
140 struct vb2_queue *q = vb->vb2_queue;
141 unsigned int plane; 196 unsigned int plane;
142 197
143 for (plane = 0; plane < vb->num_planes; ++plane) 198 for (plane = 0; plane < vb->num_planes; ++plane)
144 __vb2_plane_dmabuf_put(q, &vb->planes[plane]); 199 __vb2_plane_dmabuf_put(vb, &vb->planes[plane]);
145} 200}
146 201
147/** 202/**
@@ -246,10 +301,11 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory,
246 * callback, if given. An error in initialization 301 * callback, if given. An error in initialization
247 * results in queue setup failure. 302 * results in queue setup failure.
248 */ 303 */
249 ret = call_qop(q, buf_init, vb); 304 ret = call_vb_qop(vb, buf_init, vb);
250 if (ret) { 305 if (ret) {
251 dprintk(1, "Buffer %d %p initialization" 306 dprintk(1, "Buffer %d %p initialization"
252 " failed\n", buffer, vb); 307 " failed\n", buffer, vb);
308 fail_vb_qop(vb, buf_init);
253 __vb2_buf_mem_free(vb); 309 __vb2_buf_mem_free(vb);
254 kfree(vb); 310 kfree(vb);
255 break; 311 break;
@@ -321,18 +377,79 @@ static int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
321 } 377 }
322 378
323 /* Call driver-provided cleanup function for each buffer, if provided */ 379 /* Call driver-provided cleanup function for each buffer, if provided */
324 if (q->ops->buf_cleanup) { 380 for (buffer = q->num_buffers - buffers; buffer < q->num_buffers;
325 for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; 381 ++buffer) {
326 ++buffer) { 382 struct vb2_buffer *vb = q->bufs[buffer];
327 if (NULL == q->bufs[buffer]) 383
328 continue; 384 if (vb && vb->planes[0].mem_priv)
329 q->ops->buf_cleanup(q->bufs[buffer]); 385 call_vb_qop(vb, buf_cleanup, vb);
330 }
331 } 386 }
332 387
333 /* Release video buffer memory */ 388 /* Release video buffer memory */
334 __vb2_free_mem(q, buffers); 389 __vb2_free_mem(q, buffers);
335 390
391#ifdef CONFIG_VIDEO_ADV_DEBUG
392 /*
393 * Check that all the calls were balances during the life-time of this
394 * queue. If not (or if the debug level is 1 or up), then dump the
395 * counters to the kernel log.
396 */
397 if (q->num_buffers) {
398 bool unbalanced = q->cnt_start_streaming != q->cnt_stop_streaming ||
399 q->cnt_wait_prepare != q->cnt_wait_finish;
400
401 if (unbalanced || debug) {
402 pr_info("vb2: counters for queue %p:%s\n", q,
403 unbalanced ? " UNBALANCED!" : "");
404 pr_info("vb2: setup: %u start_streaming: %u stop_streaming: %u\n",
405 q->cnt_queue_setup, q->cnt_start_streaming,
406 q->cnt_stop_streaming);
407 pr_info("vb2: wait_prepare: %u wait_finish: %u\n",
408 q->cnt_wait_prepare, q->cnt_wait_finish);
409 }
410 q->cnt_queue_setup = 0;
411 q->cnt_wait_prepare = 0;
412 q->cnt_wait_finish = 0;
413 q->cnt_start_streaming = 0;
414 q->cnt_stop_streaming = 0;
415 }
416 for (buffer = 0; buffer < q->num_buffers; ++buffer) {
417 struct vb2_buffer *vb = q->bufs[buffer];
418 bool unbalanced = vb->cnt_mem_alloc != vb->cnt_mem_put ||
419 vb->cnt_mem_prepare != vb->cnt_mem_finish ||
420 vb->cnt_mem_get_userptr != vb->cnt_mem_put_userptr ||
421 vb->cnt_mem_attach_dmabuf != vb->cnt_mem_detach_dmabuf ||
422 vb->cnt_mem_map_dmabuf != vb->cnt_mem_unmap_dmabuf ||
423 vb->cnt_buf_queue != vb->cnt_buf_done ||
424 vb->cnt_buf_prepare != vb->cnt_buf_finish ||
425 vb->cnt_buf_init != vb->cnt_buf_cleanup;
426
427 if (unbalanced || debug) {
428 pr_info("vb2: counters for queue %p, buffer %d:%s\n",
429 q, buffer, unbalanced ? " UNBALANCED!" : "");
430 pr_info("vb2: buf_init: %u buf_cleanup: %u buf_prepare: %u buf_finish: %u\n",
431 vb->cnt_buf_init, vb->cnt_buf_cleanup,
432 vb->cnt_buf_prepare, vb->cnt_buf_finish);
433 pr_info("vb2: buf_queue: %u buf_done: %u\n",
434 vb->cnt_buf_queue, vb->cnt_buf_done);
435 pr_info("vb2: alloc: %u put: %u prepare: %u finish: %u mmap: %u\n",
436 vb->cnt_mem_alloc, vb->cnt_mem_put,
437 vb->cnt_mem_prepare, vb->cnt_mem_finish,
438 vb->cnt_mem_mmap);
439 pr_info("vb2: get_userptr: %u put_userptr: %u\n",
440 vb->cnt_mem_get_userptr, vb->cnt_mem_put_userptr);
441 pr_info("vb2: attach_dmabuf: %u detach_dmabuf: %u map_dmabuf: %u unmap_dmabuf: %u\n",
442 vb->cnt_mem_attach_dmabuf, vb->cnt_mem_detach_dmabuf,
443 vb->cnt_mem_map_dmabuf, vb->cnt_mem_unmap_dmabuf);
444 pr_info("vb2: get_dmabuf: %u num_users: %u vaddr: %u cookie: %u\n",
445 vb->cnt_mem_get_dmabuf,
446 vb->cnt_mem_num_users,
447 vb->cnt_mem_vaddr,
448 vb->cnt_mem_cookie);
449 }
450 }
451#endif
452
336 /* Free videobuf buffers */ 453 /* Free videobuf buffers */
337 for (buffer = q->num_buffers - buffers; buffer < q->num_buffers; 454 for (buffer = q->num_buffers - buffers; buffer < q->num_buffers;
338 ++buffer) { 455 ++buffer) {
@@ -341,9 +458,10 @@ static int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
341 } 458 }
342 459
343 q->num_buffers -= buffers; 460 q->num_buffers -= buffers;
344 if (!q->num_buffers) 461 if (!q->num_buffers) {
345 q->memory = 0; 462 q->memory = 0;
346 INIT_LIST_HEAD(&q->queued_list); 463 INIT_LIST_HEAD(&q->queued_list);
464 }
347 return 0; 465 return 0;
348} 466}
349 467
@@ -424,7 +542,7 @@ static bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb)
424 * case anyway. If num_users() returns more than 1, 542 * case anyway. If num_users() returns more than 1,
425 * we are not the only user of the plane's memory. 543 * we are not the only user of the plane's memory.
426 */ 544 */
427 if (mem_priv && call_memop(q, num_users, mem_priv) > 1) 545 if (mem_priv && call_memop(vb, num_users, mem_priv) > 1)
428 return true; 546 return true;
429 } 547 }
430 return false; 548 return false;
@@ -484,7 +602,16 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
484 * Clear any buffer state related flags. 602 * Clear any buffer state related flags.
485 */ 603 */
486 b->flags &= ~V4L2_BUFFER_MASK_FLAGS; 604 b->flags &= ~V4L2_BUFFER_MASK_FLAGS;
487 b->flags |= q->timestamp_type; 605 b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK;
606 if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
607 V4L2_BUF_FLAG_TIMESTAMP_COPY) {
608 /*
609 * For non-COPY timestamps, drop timestamp source bits
610 * and obtain the timestamp source from the queue.
611 */
612 b->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
613 b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
614 }
488 615
489 switch (vb->state) { 616 switch (vb->state) {
490 case VB2_BUF_STATE_QUEUED: 617 case VB2_BUF_STATE_QUEUED:
@@ -677,6 +804,12 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
677 return -EBUSY; 804 return -EBUSY;
678 } 805 }
679 806
807 /*
808 * Call queue_cancel to clean up any buffers in the PREPARED or
809 * QUEUED state which is possible if buffers were prepared or
810 * queued without ever calling STREAMON.
811 */
812 __vb2_queue_cancel(q);
680 ret = __vb2_queue_free(q, q->num_buffers); 813 ret = __vb2_queue_free(q, q->num_buffers);
681 if (ret) 814 if (ret)
682 return ret; 815 return ret;
@@ -693,6 +826,7 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
693 * Make sure the requested values and current defaults are sane. 826 * Make sure the requested values and current defaults are sane.
694 */ 827 */
695 num_buffers = min_t(unsigned int, req->count, VIDEO_MAX_FRAME); 828 num_buffers = min_t(unsigned int, req->count, VIDEO_MAX_FRAME);
829 num_buffers = max_t(unsigned int, req->count, q->min_buffers_needed);
696 memset(q->plane_sizes, 0, sizeof(q->plane_sizes)); 830 memset(q->plane_sizes, 0, sizeof(q->plane_sizes));
697 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx)); 831 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx));
698 q->memory = req->memory; 832 q->memory = req->memory;
@@ -703,26 +837,35 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
703 */ 837 */
704 ret = call_qop(q, queue_setup, q, NULL, &num_buffers, &num_planes, 838 ret = call_qop(q, queue_setup, q, NULL, &num_buffers, &num_planes,
705 q->plane_sizes, q->alloc_ctx); 839 q->plane_sizes, q->alloc_ctx);
706 if (ret) 840 if (ret) {
841 fail_qop(q, queue_setup);
707 return ret; 842 return ret;
843 }
708 844
709 /* Finally, allocate buffers and video memory */ 845 /* Finally, allocate buffers and video memory */
710 ret = __vb2_queue_alloc(q, req->memory, num_buffers, num_planes); 846 allocated_buffers = __vb2_queue_alloc(q, req->memory, num_buffers, num_planes);
711 if (ret == 0) { 847 if (allocated_buffers == 0) {
712 dprintk(1, "Memory allocation failed\n"); 848 dprintk(1, "Memory allocation failed\n");
713 return -ENOMEM; 849 return -ENOMEM;
714 } 850 }
715 851
716 allocated_buffers = ret; 852 /*
853 * There is no point in continuing if we can't allocate the minimum
854 * number of buffers needed by this vb2_queue.
855 */
856 if (allocated_buffers < q->min_buffers_needed)
857 ret = -ENOMEM;
717 858
718 /* 859 /*
719 * Check if driver can handle the allocated number of buffers. 860 * Check if driver can handle the allocated number of buffers.
720 */ 861 */
721 if (allocated_buffers < num_buffers) { 862 if (!ret && allocated_buffers < num_buffers) {
722 num_buffers = allocated_buffers; 863 num_buffers = allocated_buffers;
723 864
724 ret = call_qop(q, queue_setup, q, NULL, &num_buffers, 865 ret = call_qop(q, queue_setup, q, NULL, &num_buffers,
725 &num_planes, q->plane_sizes, q->alloc_ctx); 866 &num_planes, q->plane_sizes, q->alloc_ctx);
867 if (ret)
868 fail_qop(q, queue_setup);
726 869
727 if (!ret && allocated_buffers < num_buffers) 870 if (!ret && allocated_buffers < num_buffers)
728 ret = -ENOMEM; 871 ret = -ENOMEM;
@@ -736,6 +879,10 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
736 q->num_buffers = allocated_buffers; 879 q->num_buffers = allocated_buffers;
737 880
738 if (ret < 0) { 881 if (ret < 0) {
882 /*
883 * Note: __vb2_queue_free() will subtract 'allocated_buffers'
884 * from q->num_buffers.
885 */
739 __vb2_queue_free(q, allocated_buffers); 886 __vb2_queue_free(q, allocated_buffers);
740 return ret; 887 return ret;
741 } 888 }
@@ -803,24 +950,24 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create
803 */ 950 */
804 ret = call_qop(q, queue_setup, q, &create->format, &num_buffers, 951 ret = call_qop(q, queue_setup, q, &create->format, &num_buffers,
805 &num_planes, q->plane_sizes, q->alloc_ctx); 952 &num_planes, q->plane_sizes, q->alloc_ctx);
806 if (ret) 953 if (ret) {
954 fail_qop(q, queue_setup);
807 return ret; 955 return ret;
956 }
808 957
809 /* Finally, allocate buffers and video memory */ 958 /* Finally, allocate buffers and video memory */
810 ret = __vb2_queue_alloc(q, create->memory, num_buffers, 959 allocated_buffers = __vb2_queue_alloc(q, create->memory, num_buffers,
811 num_planes); 960 num_planes);
812 if (ret == 0) { 961 if (allocated_buffers == 0) {
813 dprintk(1, "Memory allocation failed\n"); 962 dprintk(1, "Memory allocation failed\n");
814 return -ENOMEM; 963 return -ENOMEM;
815 } 964 }
816 965
817 allocated_buffers = ret;
818
819 /* 966 /*
820 * Check if driver can handle the so far allocated number of buffers. 967 * Check if driver can handle the so far allocated number of buffers.
821 */ 968 */
822 if (ret < num_buffers) { 969 if (allocated_buffers < num_buffers) {
823 num_buffers = ret; 970 num_buffers = allocated_buffers;
824 971
825 /* 972 /*
826 * q->num_buffers contains the total number of buffers, that the 973 * q->num_buffers contains the total number of buffers, that the
@@ -828,6 +975,8 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create
828 */ 975 */
829 ret = call_qop(q, queue_setup, q, &create->format, &num_buffers, 976 ret = call_qop(q, queue_setup, q, &create->format, &num_buffers,
830 &num_planes, q->plane_sizes, q->alloc_ctx); 977 &num_planes, q->plane_sizes, q->alloc_ctx);
978 if (ret)
979 fail_qop(q, queue_setup);
831 980
832 if (!ret && allocated_buffers < num_buffers) 981 if (!ret && allocated_buffers < num_buffers)
833 ret = -ENOMEM; 982 ret = -ENOMEM;
@@ -841,6 +990,10 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create
841 q->num_buffers += allocated_buffers; 990 q->num_buffers += allocated_buffers;
842 991
843 if (ret < 0) { 992 if (ret < 0) {
993 /*
994 * Note: __vb2_queue_free() will subtract 'allocated_buffers'
995 * from q->num_buffers.
996 */
844 __vb2_queue_free(q, allocated_buffers); 997 __vb2_queue_free(q, allocated_buffers);
845 return -ENOMEM; 998 return -ENOMEM;
846 } 999 }
@@ -882,12 +1035,10 @@ EXPORT_SYMBOL_GPL(vb2_create_bufs);
882 */ 1035 */
883void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no) 1036void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no)
884{ 1037{
885 struct vb2_queue *q = vb->vb2_queue;
886
887 if (plane_no > vb->num_planes || !vb->planes[plane_no].mem_priv) 1038 if (plane_no > vb->num_planes || !vb->planes[plane_no].mem_priv)
888 return NULL; 1039 return NULL;
889 1040
890 return call_memop(q, vaddr, vb->planes[plane_no].mem_priv); 1041 return call_memop(vb, vaddr, vb->planes[plane_no].mem_priv);
891 1042
892} 1043}
893EXPORT_SYMBOL_GPL(vb2_plane_vaddr); 1044EXPORT_SYMBOL_GPL(vb2_plane_vaddr);
@@ -905,12 +1056,10 @@ EXPORT_SYMBOL_GPL(vb2_plane_vaddr);
905 */ 1056 */
906void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no) 1057void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no)
907{ 1058{
908 struct vb2_queue *q = vb->vb2_queue;
909
910 if (plane_no > vb->num_planes || !vb->planes[plane_no].mem_priv) 1059 if (plane_no > vb->num_planes || !vb->planes[plane_no].mem_priv)
911 return NULL; 1060 return NULL;
912 1061
913 return call_memop(q, cookie, vb->planes[plane_no].mem_priv); 1062 return call_memop(vb, cookie, vb->planes[plane_no].mem_priv);
914} 1063}
915EXPORT_SYMBOL_GPL(vb2_plane_cookie); 1064EXPORT_SYMBOL_GPL(vb2_plane_cookie);
916 1065
@@ -918,13 +1067,20 @@ EXPORT_SYMBOL_GPL(vb2_plane_cookie);
918 * vb2_buffer_done() - inform videobuf that an operation on a buffer is finished 1067 * vb2_buffer_done() - inform videobuf that an operation on a buffer is finished
919 * @vb: vb2_buffer returned from the driver 1068 * @vb: vb2_buffer returned from the driver
920 * @state: either VB2_BUF_STATE_DONE if the operation finished successfully 1069 * @state: either VB2_BUF_STATE_DONE if the operation finished successfully
921 * or VB2_BUF_STATE_ERROR if the operation finished with an error 1070 * or VB2_BUF_STATE_ERROR if the operation finished with an error.
1071 * If start_streaming fails then it should return buffers with state
1072 * VB2_BUF_STATE_QUEUED to put them back into the queue.
922 * 1073 *
923 * This function should be called by the driver after a hardware operation on 1074 * This function should be called by the driver after a hardware operation on
924 * a buffer is finished and the buffer may be returned to userspace. The driver 1075 * a buffer is finished and the buffer may be returned to userspace. The driver
925 * cannot use this buffer anymore until it is queued back to it by videobuf 1076 * cannot use this buffer anymore until it is queued back to it by videobuf
926 * by the means of buf_queue callback. Only buffers previously queued to the 1077 * by the means of buf_queue callback. Only buffers previously queued to the
927 * driver by buf_queue can be passed to this function. 1078 * driver by buf_queue can be passed to this function.
1079 *
1080 * While streaming a buffer can only be returned in state DONE or ERROR.
1081 * The start_streaming op can also return them in case the DMA engine cannot
1082 * be started for some reason. In that case the buffers should be returned with
1083 * state QUEUED.
928 */ 1084 */
929void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) 1085void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
930{ 1086{
@@ -932,26 +1088,43 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
932 unsigned long flags; 1088 unsigned long flags;
933 unsigned int plane; 1089 unsigned int plane;
934 1090
935 if (vb->state != VB2_BUF_STATE_ACTIVE) 1091 if (WARN_ON(vb->state != VB2_BUF_STATE_ACTIVE))
936 return; 1092 return;
937 1093
938 if (state != VB2_BUF_STATE_DONE && state != VB2_BUF_STATE_ERROR) 1094 if (!q->start_streaming_called) {
939 return; 1095 if (WARN_ON(state != VB2_BUF_STATE_QUEUED))
1096 state = VB2_BUF_STATE_QUEUED;
1097 } else if (!WARN_ON(!q->start_streaming_called)) {
1098 if (WARN_ON(state != VB2_BUF_STATE_DONE &&
1099 state != VB2_BUF_STATE_ERROR))
1100 state = VB2_BUF_STATE_ERROR;
1101 }
940 1102
1103#ifdef CONFIG_VIDEO_ADV_DEBUG
1104 /*
1105 * Although this is not a callback, it still does have to balance
1106 * with the buf_queue op. So update this counter manually.
1107 */
1108 vb->cnt_buf_done++;
1109#endif
941 dprintk(4, "Done processing on buffer %d, state: %d\n", 1110 dprintk(4, "Done processing on buffer %d, state: %d\n",
942 vb->v4l2_buf.index, state); 1111 vb->v4l2_buf.index, state);
943 1112
944 /* sync buffers */ 1113 /* sync buffers */
945 for (plane = 0; plane < vb->num_planes; ++plane) 1114 for (plane = 0; plane < vb->num_planes; ++plane)
946 call_memop(q, finish, vb->planes[plane].mem_priv); 1115 call_memop(vb, finish, vb->planes[plane].mem_priv);
947 1116
948 /* Add the buffer to the done buffers list */ 1117 /* Add the buffer to the done buffers list */
949 spin_lock_irqsave(&q->done_lock, flags); 1118 spin_lock_irqsave(&q->done_lock, flags);
950 vb->state = state; 1119 vb->state = state;
951 list_add_tail(&vb->done_entry, &q->done_list); 1120 if (state != VB2_BUF_STATE_QUEUED)
952 atomic_dec(&q->queued_count); 1121 list_add_tail(&vb->done_entry, &q->done_list);
1122 atomic_dec(&q->owned_by_drv_count);
953 spin_unlock_irqrestore(&q->done_lock, flags); 1123 spin_unlock_irqrestore(&q->done_lock, flags);
954 1124
1125 if (state == VB2_BUF_STATE_QUEUED)
1126 return;
1127
955 /* Inform any processes that may be waiting for buffers */ 1128 /* Inform any processes that may be waiting for buffers */
956 wake_up(&q->done_wq); 1129 wake_up(&q->done_wq);
957} 1130}
@@ -1025,9 +1198,31 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b
1025 1198
1026 } 1199 }
1027 1200
1028 vb->v4l2_buf.field = b->field; 1201 /* Zero flags that the vb2 core handles */
1029 vb->v4l2_buf.timestamp = b->timestamp;
1030 vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS; 1202 vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS;
1203 if ((vb->vb2_queue->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) !=
1204 V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT(b->type)) {
1205 /*
1206 * Non-COPY timestamps and non-OUTPUT queues will get
1207 * their timestamp and timestamp source flags from the
1208 * queue.
1209 */
1210 vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1211 }
1212
1213 if (V4L2_TYPE_IS_OUTPUT(b->type)) {
1214 /*
1215 * For output buffers mask out the timecode flag:
1216 * this will be handled later in vb2_internal_qbuf().
1217 * The 'field' is valid metadata for this output buffer
1218 * and so that needs to be copied here.
1219 */
1220 vb->v4l2_buf.flags &= ~V4L2_BUF_FLAG_TIMECODE;
1221 vb->v4l2_buf.field = b->field;
1222 } else {
1223 /* Zero any output buffer flags as this is a capture buffer */
1224 vb->v4l2_buf.flags &= ~V4L2_BUFFER_OUT_FLAGS;
1225 }
1031} 1226}
1032 1227
1033/** 1228/**
@@ -1041,6 +1236,7 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b)
1041 unsigned int plane; 1236 unsigned int plane;
1042 int ret; 1237 int ret;
1043 int write = !V4L2_TYPE_IS_OUTPUT(q->type); 1238 int write = !V4L2_TYPE_IS_OUTPUT(q->type);
1239 bool reacquired = vb->planes[0].mem_priv == NULL;
1044 1240
1045 /* Copy relevant information provided by the userspace */ 1241 /* Copy relevant information provided by the userspace */
1046 __fill_vb2_buffer(vb, b, planes); 1242 __fill_vb2_buffer(vb, b, planes);
@@ -1066,20 +1262,25 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b)
1066 } 1262 }
1067 1263
1068 /* Release previously acquired memory if present */ 1264 /* Release previously acquired memory if present */
1069 if (vb->planes[plane].mem_priv) 1265 if (vb->planes[plane].mem_priv) {
1070 call_memop(q, put_userptr, vb->planes[plane].mem_priv); 1266 if (!reacquired) {
1267 reacquired = true;
1268 call_vb_qop(vb, buf_cleanup, vb);
1269 }
1270 call_memop(vb, put_userptr, vb->planes[plane].mem_priv);
1271 }
1071 1272
1072 vb->planes[plane].mem_priv = NULL; 1273 vb->planes[plane].mem_priv = NULL;
1073 vb->v4l2_planes[plane].m.userptr = 0; 1274 memset(&vb->v4l2_planes[plane], 0, sizeof(struct v4l2_plane));
1074 vb->v4l2_planes[plane].length = 0;
1075 1275
1076 /* Acquire each plane's memory */ 1276 /* Acquire each plane's memory */
1077 mem_priv = call_memop(q, get_userptr, q->alloc_ctx[plane], 1277 mem_priv = call_memop(vb, get_userptr, q->alloc_ctx[plane],
1078 planes[plane].m.userptr, 1278 planes[plane].m.userptr,
1079 planes[plane].length, write); 1279 planes[plane].length, write);
1080 if (IS_ERR_OR_NULL(mem_priv)) { 1280 if (IS_ERR_OR_NULL(mem_priv)) {
1081 dprintk(1, "qbuf: failed acquiring userspace " 1281 dprintk(1, "qbuf: failed acquiring userspace "
1082 "memory for plane %d\n", plane); 1282 "memory for plane %d\n", plane);
1283 fail_memop(vb, get_userptr);
1083 ret = mem_priv ? PTR_ERR(mem_priv) : -EINVAL; 1284 ret = mem_priv ? PTR_ERR(mem_priv) : -EINVAL;
1084 goto err; 1285 goto err;
1085 } 1286 }
@@ -1087,28 +1288,40 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b)
1087 } 1288 }
1088 1289
1089 /* 1290 /*
1090 * Call driver-specific initialization on the newly acquired buffer,
1091 * if provided.
1092 */
1093 ret = call_qop(q, buf_init, vb);
1094 if (ret) {
1095 dprintk(1, "qbuf: buffer initialization failed\n");
1096 goto err;
1097 }
1098
1099 /*
1100 * Now that everything is in order, copy relevant information 1291 * Now that everything is in order, copy relevant information
1101 * provided by userspace. 1292 * provided by userspace.
1102 */ 1293 */
1103 for (plane = 0; plane < vb->num_planes; ++plane) 1294 for (plane = 0; plane < vb->num_planes; ++plane)
1104 vb->v4l2_planes[plane] = planes[plane]; 1295 vb->v4l2_planes[plane] = planes[plane];
1105 1296
1297 if (reacquired) {
1298 /*
1299 * One or more planes changed, so we must call buf_init to do
1300 * the driver-specific initialization on the newly acquired
1301 * buffer, if provided.
1302 */
1303 ret = call_vb_qop(vb, buf_init, vb);
1304 if (ret) {
1305 dprintk(1, "qbuf: buffer initialization failed\n");
1306 fail_vb_qop(vb, buf_init);
1307 goto err;
1308 }
1309 }
1310
1311 ret = call_vb_qop(vb, buf_prepare, vb);
1312 if (ret) {
1313 dprintk(1, "qbuf: buffer preparation failed\n");
1314 fail_vb_qop(vb, buf_prepare);
1315 call_vb_qop(vb, buf_cleanup, vb);
1316 goto err;
1317 }
1318
1106 return 0; 1319 return 0;
1107err: 1320err:
1108 /* In case of errors, release planes that were already acquired */ 1321 /* In case of errors, release planes that were already acquired */
1109 for (plane = 0; plane < vb->num_planes; ++plane) { 1322 for (plane = 0; plane < vb->num_planes; ++plane) {
1110 if (vb->planes[plane].mem_priv) 1323 if (vb->planes[plane].mem_priv)
1111 call_memop(q, put_userptr, vb->planes[plane].mem_priv); 1324 call_memop(vb, put_userptr, vb->planes[plane].mem_priv);
1112 vb->planes[plane].mem_priv = NULL; 1325 vb->planes[plane].mem_priv = NULL;
1113 vb->v4l2_planes[plane].m.userptr = 0; 1326 vb->v4l2_planes[plane].m.userptr = 0;
1114 vb->v4l2_planes[plane].length = 0; 1327 vb->v4l2_planes[plane].length = 0;
@@ -1122,8 +1335,13 @@ err:
1122 */ 1335 */
1123static int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b) 1336static int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b)
1124{ 1337{
1338 int ret;
1339
1125 __fill_vb2_buffer(vb, b, vb->v4l2_planes); 1340 __fill_vb2_buffer(vb, b, vb->v4l2_planes);
1126 return 0; 1341 ret = call_vb_qop(vb, buf_prepare, vb);
1342 if (ret)
1343 fail_vb_qop(vb, buf_prepare);
1344 return ret;
1127} 1345}
1128 1346
1129/** 1347/**
@@ -1137,6 +1355,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b)
1137 unsigned int plane; 1355 unsigned int plane;
1138 int ret; 1356 int ret;
1139 int write = !V4L2_TYPE_IS_OUTPUT(q->type); 1357 int write = !V4L2_TYPE_IS_OUTPUT(q->type);
1358 bool reacquired = vb->planes[0].mem_priv == NULL;
1140 1359
1141 /* Copy relevant information provided by the userspace */ 1360 /* Copy relevant information provided by the userspace */
1142 __fill_vb2_buffer(vb, b, planes); 1361 __fill_vb2_buffer(vb, b, planes);
@@ -1172,15 +1391,21 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b)
1172 1391
1173 dprintk(1, "qbuf: buffer for plane %d changed\n", plane); 1392 dprintk(1, "qbuf: buffer for plane %d changed\n", plane);
1174 1393
1394 if (!reacquired) {
1395 reacquired = true;
1396 call_vb_qop(vb, buf_cleanup, vb);
1397 }
1398
1175 /* Release previously acquired memory if present */ 1399 /* Release previously acquired memory if present */
1176 __vb2_plane_dmabuf_put(q, &vb->planes[plane]); 1400 __vb2_plane_dmabuf_put(vb, &vb->planes[plane]);
1177 memset(&vb->v4l2_planes[plane], 0, sizeof(struct v4l2_plane)); 1401 memset(&vb->v4l2_planes[plane], 0, sizeof(struct v4l2_plane));
1178 1402
1179 /* Acquire each plane's memory */ 1403 /* Acquire each plane's memory */
1180 mem_priv = call_memop(q, attach_dmabuf, q->alloc_ctx[plane], 1404 mem_priv = call_memop(vb, attach_dmabuf, q->alloc_ctx[plane],
1181 dbuf, planes[plane].length, write); 1405 dbuf, planes[plane].length, write);
1182 if (IS_ERR(mem_priv)) { 1406 if (IS_ERR(mem_priv)) {
1183 dprintk(1, "qbuf: failed to attach dmabuf\n"); 1407 dprintk(1, "qbuf: failed to attach dmabuf\n");
1408 fail_memop(vb, attach_dmabuf);
1184 ret = PTR_ERR(mem_priv); 1409 ret = PTR_ERR(mem_priv);
1185 dma_buf_put(dbuf); 1410 dma_buf_put(dbuf);
1186 goto err; 1411 goto err;
@@ -1195,32 +1420,44 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b)
1195 * the buffer(s).. 1420 * the buffer(s)..
1196 */ 1421 */
1197 for (plane = 0; plane < vb->num_planes; ++plane) { 1422 for (plane = 0; plane < vb->num_planes; ++plane) {
1198 ret = call_memop(q, map_dmabuf, vb->planes[plane].mem_priv); 1423 ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv);
1199 if (ret) { 1424 if (ret) {
1200 dprintk(1, "qbuf: failed to map dmabuf for plane %d\n", 1425 dprintk(1, "qbuf: failed to map dmabuf for plane %d\n",
1201 plane); 1426 plane);
1427 fail_memop(vb, map_dmabuf);
1202 goto err; 1428 goto err;
1203 } 1429 }
1204 vb->planes[plane].dbuf_mapped = 1; 1430 vb->planes[plane].dbuf_mapped = 1;
1205 } 1431 }
1206 1432
1207 /* 1433 /*
1208 * Call driver-specific initialization on the newly acquired buffer,
1209 * if provided.
1210 */
1211 ret = call_qop(q, buf_init, vb);
1212 if (ret) {
1213 dprintk(1, "qbuf: buffer initialization failed\n");
1214 goto err;
1215 }
1216
1217 /*
1218 * Now that everything is in order, copy relevant information 1434 * Now that everything is in order, copy relevant information
1219 * provided by userspace. 1435 * provided by userspace.
1220 */ 1436 */
1221 for (plane = 0; plane < vb->num_planes; ++plane) 1437 for (plane = 0; plane < vb->num_planes; ++plane)
1222 vb->v4l2_planes[plane] = planes[plane]; 1438 vb->v4l2_planes[plane] = planes[plane];
1223 1439
1440 if (reacquired) {
1441 /*
1442 * Call driver-specific initialization on the newly acquired buffer,
1443 * if provided.
1444 */
1445 ret = call_vb_qop(vb, buf_init, vb);
1446 if (ret) {
1447 dprintk(1, "qbuf: buffer initialization failed\n");
1448 fail_vb_qop(vb, buf_init);
1449 goto err;
1450 }
1451 }
1452
1453 ret = call_vb_qop(vb, buf_prepare, vb);
1454 if (ret) {
1455 dprintk(1, "qbuf: buffer preparation failed\n");
1456 fail_vb_qop(vb, buf_prepare);
1457 call_vb_qop(vb, buf_cleanup, vb);
1458 goto err;
1459 }
1460
1224 return 0; 1461 return 0;
1225err: 1462err:
1226 /* In case of errors, release planes that were already acquired */ 1463 /* In case of errors, release planes that were already acquired */
@@ -1238,13 +1475,13 @@ static void __enqueue_in_driver(struct vb2_buffer *vb)
1238 unsigned int plane; 1475 unsigned int plane;
1239 1476
1240 vb->state = VB2_BUF_STATE_ACTIVE; 1477 vb->state = VB2_BUF_STATE_ACTIVE;
1241 atomic_inc(&q->queued_count); 1478 atomic_inc(&q->owned_by_drv_count);
1242 1479
1243 /* sync buffers */ 1480 /* sync buffers */
1244 for (plane = 0; plane < vb->num_planes; ++plane) 1481 for (plane = 0; plane < vb->num_planes; ++plane)
1245 call_memop(q, prepare, vb->planes[plane].mem_priv); 1482 call_memop(vb, prepare, vb->planes[plane].mem_priv);
1246 1483
1247 q->ops->buf_queue(vb); 1484 call_vb_qop(vb, buf_queue, vb);
1248} 1485}
1249 1486
1250static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b) 1487static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b)
@@ -1261,6 +1498,10 @@ static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b)
1261 } 1498 }
1262 1499
1263 vb->state = VB2_BUF_STATE_PREPARING; 1500 vb->state = VB2_BUF_STATE_PREPARING;
1501 vb->v4l2_buf.timestamp.tv_sec = 0;
1502 vb->v4l2_buf.timestamp.tv_usec = 0;
1503 vb->v4l2_buf.sequence = 0;
1504
1264 switch (q->memory) { 1505 switch (q->memory) {
1265 case V4L2_MEMORY_MMAP: 1506 case V4L2_MEMORY_MMAP:
1266 ret = __qbuf_mmap(vb, b); 1507 ret = __qbuf_mmap(vb, b);
@@ -1295,8 +1536,6 @@ static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b)
1295 ret = -EINVAL; 1536 ret = -EINVAL;
1296 } 1537 }
1297 1538
1298 if (!ret)
1299 ret = call_qop(q, buf_prepare, vb);
1300 if (ret) 1539 if (ret)
1301 dprintk(1, "qbuf: buffer preparation failed: %d\n", ret); 1540 dprintk(1, "qbuf: buffer preparation failed: %d\n", ret);
1302 vb->state = ret ? VB2_BUF_STATE_DEQUEUED : VB2_BUF_STATE_PREPARED; 1541 vb->state = ret ? VB2_BUF_STATE_DEQUEUED : VB2_BUF_STATE_PREPARED;
@@ -1382,32 +1621,49 @@ EXPORT_SYMBOL_GPL(vb2_prepare_buf);
1382 * vb2_start_streaming() - Attempt to start streaming. 1621 * vb2_start_streaming() - Attempt to start streaming.
1383 * @q: videobuf2 queue 1622 * @q: videobuf2 queue
1384 * 1623 *
1385 * If there are not enough buffers, then retry_start_streaming is set to 1624 * Attempt to start streaming. When this function is called there must be
1386 * 1 and 0 is returned. The next time a buffer is queued and 1625 * at least q->min_buffers_needed buffers queued up (i.e. the minimum
1387 * retry_start_streaming is 1, this function will be called again to 1626 * number of buffers required for the DMA engine to function). If the
1388 * retry starting the DMA engine. 1627 * @start_streaming op fails it is supposed to return all the driver-owned
1628 * buffers back to vb2 in state QUEUED. Check if that happened and if
1629 * not warn and reclaim them forcefully.
1389 */ 1630 */
1390static int vb2_start_streaming(struct vb2_queue *q) 1631static int vb2_start_streaming(struct vb2_queue *q)
1391{ 1632{
1633 struct vb2_buffer *vb;
1392 int ret; 1634 int ret;
1393 1635
1394 /* Tell the driver to start streaming */
1395 ret = call_qop(q, start_streaming, q, atomic_read(&q->queued_count));
1396
1397 /* 1636 /*
1398 * If there are not enough buffers queued to start streaming, then 1637 * If any buffers were queued before streamon,
1399 * the start_streaming operation will return -ENOBUFS and you have to 1638 * we can now pass them to driver for processing.
1400 * retry when the next buffer is queued.
1401 */ 1639 */
1402 if (ret == -ENOBUFS) { 1640 list_for_each_entry(vb, &q->queued_list, queued_entry)
1403 dprintk(1, "qbuf: not enough buffers, retry when more buffers are queued.\n"); 1641 __enqueue_in_driver(vb);
1404 q->retry_start_streaming = 1; 1642
1643 /* Tell the driver to start streaming */
1644 ret = call_qop(q, start_streaming, q,
1645 atomic_read(&q->owned_by_drv_count));
1646 q->start_streaming_called = ret == 0;
1647 if (!ret)
1405 return 0; 1648 return 0;
1649
1650 fail_qop(q, start_streaming);
1651 dprintk(1, "qbuf: driver refused to start streaming\n");
1652 if (WARN_ON(atomic_read(&q->owned_by_drv_count))) {
1653 unsigned i;
1654
1655 /*
1656 * Forcefully reclaim buffers if the driver did not
1657 * correctly return them to vb2.
1658 */
1659 for (i = 0; i < q->num_buffers; ++i) {
1660 vb = q->bufs[i];
1661 if (vb->state == VB2_BUF_STATE_ACTIVE)
1662 vb2_buffer_done(vb, VB2_BUF_STATE_QUEUED);
1663 }
1664 /* Must be zero now */
1665 WARN_ON(atomic_read(&q->owned_by_drv_count));
1406 } 1666 }
1407 if (ret)
1408 dprintk(1, "qbuf: driver refused to start streaming\n");
1409 else
1410 q->retry_start_streaming = 0;
1411 return ret; 1667 return ret;
1412} 1668}
1413 1669
@@ -1420,11 +1676,6 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
1420 return ret; 1676 return ret;
1421 1677
1422 vb = q->bufs[b->index]; 1678 vb = q->bufs[b->index];
1423 if (vb->state != VB2_BUF_STATE_DEQUEUED) {
1424 dprintk(1, "%s(): invalid buffer state %d\n", __func__,
1425 vb->state);
1426 return -EINVAL;
1427 }
1428 1679
1429 switch (vb->state) { 1680 switch (vb->state) {
1430 case VB2_BUF_STATE_DEQUEUED: 1681 case VB2_BUF_STATE_DEQUEUED:
@@ -1438,7 +1689,8 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
1438 dprintk(1, "qbuf: buffer still being prepared\n"); 1689 dprintk(1, "qbuf: buffer still being prepared\n");
1439 return -EINVAL; 1690 return -EINVAL;
1440 default: 1691 default:
1441 dprintk(1, "qbuf: buffer already in use\n"); 1692 dprintk(1, "%s(): invalid buffer state %d\n", __func__,
1693 vb->state);
1442 return -EINVAL; 1694 return -EINVAL;
1443 } 1695 }
1444 1696
@@ -1447,19 +1699,39 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
1447 * dequeued in dqbuf. 1699 * dequeued in dqbuf.
1448 */ 1700 */
1449 list_add_tail(&vb->queued_entry, &q->queued_list); 1701 list_add_tail(&vb->queued_entry, &q->queued_list);
1702 q->queued_count++;
1450 vb->state = VB2_BUF_STATE_QUEUED; 1703 vb->state = VB2_BUF_STATE_QUEUED;
1704 if (V4L2_TYPE_IS_OUTPUT(q->type)) {
1705 /*
1706 * For output buffers copy the timestamp if needed,
1707 * and the timecode field and flag if needed.
1708 */
1709 if ((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
1710 V4L2_BUF_FLAG_TIMESTAMP_COPY)
1711 vb->v4l2_buf.timestamp = b->timestamp;
1712 vb->v4l2_buf.flags |= b->flags & V4L2_BUF_FLAG_TIMECODE;
1713 if (b->flags & V4L2_BUF_FLAG_TIMECODE)
1714 vb->v4l2_buf.timecode = b->timecode;
1715 }
1451 1716
1452 /* 1717 /*
1453 * If already streaming, give the buffer to driver for processing. 1718 * If already streaming, give the buffer to driver for processing.
1454 * If not, the buffer will be given to driver on next streamon. 1719 * If not, the buffer will be given to driver on next streamon.
1455 */ 1720 */
1456 if (q->streaming) 1721 if (q->start_streaming_called)
1457 __enqueue_in_driver(vb); 1722 __enqueue_in_driver(vb);
1458 1723
1459 /* Fill buffer information for the userspace */ 1724 /* Fill buffer information for the userspace */
1460 __fill_v4l2_buffer(vb, b); 1725 __fill_v4l2_buffer(vb, b);
1461 1726
1462 if (q->retry_start_streaming) { 1727 /*
1728 * If streamon has been called, and we haven't yet called
1729 * start_streaming() since not enough buffers were queued, and
1730 * we now have reached the minimum number of queued buffers,
1731 * then we can finally call start_streaming().
1732 */
1733 if (q->streaming && !q->start_streaming_called &&
1734 q->queued_count >= q->min_buffers_needed) {
1463 ret = vb2_start_streaming(q); 1735 ret = vb2_start_streaming(q);
1464 if (ret) 1736 if (ret)
1465 return ret; 1737 return ret;
@@ -1614,8 +1886,8 @@ int vb2_wait_for_all_buffers(struct vb2_queue *q)
1614 return -EINVAL; 1886 return -EINVAL;
1615 } 1887 }
1616 1888
1617 if (!q->retry_start_streaming) 1889 if (q->start_streaming_called)
1618 wait_event(q->done_wq, !atomic_read(&q->queued_count)); 1890 wait_event(q->done_wq, !atomic_read(&q->owned_by_drv_count));
1619 return 0; 1891 return 0;
1620} 1892}
1621EXPORT_SYMBOL_GPL(vb2_wait_for_all_buffers); 1893EXPORT_SYMBOL_GPL(vb2_wait_for_all_buffers);
@@ -1639,7 +1911,7 @@ static void __vb2_dqbuf(struct vb2_buffer *vb)
1639 for (i = 0; i < vb->num_planes; ++i) { 1911 for (i = 0; i < vb->num_planes; ++i) {
1640 if (!vb->planes[i].dbuf_mapped) 1912 if (!vb->planes[i].dbuf_mapped)
1641 continue; 1913 continue;
1642 call_memop(q, unmap_dmabuf, vb->planes[i].mem_priv); 1914 call_memop(vb, unmap_dmabuf, vb->planes[i].mem_priv);
1643 vb->planes[i].dbuf_mapped = 0; 1915 vb->planes[i].dbuf_mapped = 0;
1644 } 1916 }
1645} 1917}
@@ -1657,12 +1929,6 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n
1657 if (ret < 0) 1929 if (ret < 0)
1658 return ret; 1930 return ret;
1659 1931
1660 ret = call_qop(q, buf_finish, vb);
1661 if (ret) {
1662 dprintk(1, "dqbuf: buffer finish failed\n");
1663 return ret;
1664 }
1665
1666 switch (vb->state) { 1932 switch (vb->state) {
1667 case VB2_BUF_STATE_DONE: 1933 case VB2_BUF_STATE_DONE:
1668 dprintk(3, "dqbuf: Returning done buffer\n"); 1934 dprintk(3, "dqbuf: Returning done buffer\n");
@@ -1675,10 +1941,13 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n
1675 return -EINVAL; 1941 return -EINVAL;
1676 } 1942 }
1677 1943
1944 call_vb_qop(vb, buf_finish, vb);
1945
1678 /* Fill buffer information for the userspace */ 1946 /* Fill buffer information for the userspace */
1679 __fill_v4l2_buffer(vb, b); 1947 __fill_v4l2_buffer(vb, b);
1680 /* Remove from videobuf queue */ 1948 /* Remove from videobuf queue */
1681 list_del(&vb->queued_entry); 1949 list_del(&vb->queued_entry);
1950 q->queued_count--;
1682 /* go back to dequeued state */ 1951 /* go back to dequeued state */
1683 __vb2_dqbuf(vb); 1952 __vb2_dqbuf(vb);
1684 1953
@@ -1729,18 +1998,23 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
1729{ 1998{
1730 unsigned int i; 1999 unsigned int i;
1731 2000
1732 if (q->retry_start_streaming) {
1733 q->retry_start_streaming = 0;
1734 q->streaming = 0;
1735 }
1736
1737 /* 2001 /*
1738 * Tell driver to stop all transactions and release all queued 2002 * Tell driver to stop all transactions and release all queued
1739 * buffers. 2003 * buffers.
1740 */ 2004 */
1741 if (q->streaming) 2005 if (q->start_streaming_called)
1742 call_qop(q, stop_streaming, q); 2006 call_qop(q, stop_streaming, q);
1743 q->streaming = 0; 2007 q->streaming = 0;
2008 q->start_streaming_called = 0;
2009 q->queued_count = 0;
2010
2011 if (WARN_ON(atomic_read(&q->owned_by_drv_count))) {
2012 for (i = 0; i < q->num_buffers; ++i)
2013 if (q->bufs[i]->state == VB2_BUF_STATE_ACTIVE)
2014 vb2_buffer_done(q->bufs[i], VB2_BUF_STATE_ERROR);
2015 /* Must be zero now */
2016 WARN_ON(atomic_read(&q->owned_by_drv_count));
2017 }
1744 2018
1745 /* 2019 /*
1746 * Remove all buffers from videobuf's list... 2020 * Remove all buffers from videobuf's list...
@@ -1751,19 +2025,31 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
1751 * has not already dequeued before initiating cancel. 2025 * has not already dequeued before initiating cancel.
1752 */ 2026 */
1753 INIT_LIST_HEAD(&q->done_list); 2027 INIT_LIST_HEAD(&q->done_list);
1754 atomic_set(&q->queued_count, 0); 2028 atomic_set(&q->owned_by_drv_count, 0);
1755 wake_up_all(&q->done_wq); 2029 wake_up_all(&q->done_wq);
1756 2030
1757 /* 2031 /*
1758 * Reinitialize all buffers for next use. 2032 * Reinitialize all buffers for next use.
2033 * Make sure to call buf_finish for any queued buffers. Normally
2034 * that's done in dqbuf, but that's not going to happen when we
2035 * cancel the whole queue. Note: this code belongs here, not in
2036 * __vb2_dqbuf() since in vb2_internal_dqbuf() there is a critical
2037 * call to __fill_v4l2_buffer() after buf_finish(). That order can't
2038 * be changed, so we can't move the buf_finish() to __vb2_dqbuf().
1759 */ 2039 */
1760 for (i = 0; i < q->num_buffers; ++i) 2040 for (i = 0; i < q->num_buffers; ++i) {
1761 __vb2_dqbuf(q->bufs[i]); 2041 struct vb2_buffer *vb = q->bufs[i];
2042
2043 if (vb->state != VB2_BUF_STATE_DEQUEUED) {
2044 vb->state = VB2_BUF_STATE_PREPARED;
2045 call_vb_qop(vb, buf_finish, vb);
2046 }
2047 __vb2_dqbuf(vb);
2048 }
1762} 2049}
1763 2050
1764static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type) 2051static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
1765{ 2052{
1766 struct vb2_buffer *vb;
1767 int ret; 2053 int ret;
1768 2054
1769 if (type != q->type) { 2055 if (type != q->type) {
@@ -1781,18 +2067,26 @@ static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
1781 return -EINVAL; 2067 return -EINVAL;
1782 } 2068 }
1783 2069
2070 if (!q->num_buffers) {
2071 dprintk(1, "streamon: no buffers have been allocated\n");
2072 return -EINVAL;
2073 }
2074 if (q->num_buffers < q->min_buffers_needed) {
2075 dprintk(1, "streamon: need at least %u allocated buffers\n",
2076 q->min_buffers_needed);
2077 return -EINVAL;
2078 }
2079
1784 /* 2080 /*
1785 * If any buffers were queued before streamon, 2081 * Tell driver to start streaming provided sufficient buffers
1786 * we can now pass them to driver for processing. 2082 * are available.
1787 */ 2083 */
1788 list_for_each_entry(vb, &q->queued_list, queued_entry) 2084 if (q->queued_count >= q->min_buffers_needed) {
1789 __enqueue_in_driver(vb); 2085 ret = vb2_start_streaming(q);
1790 2086 if (ret) {
1791 /* Tell driver to start streaming. */ 2087 __vb2_queue_cancel(q);
1792 ret = vb2_start_streaming(q); 2088 return ret;
1793 if (ret) { 2089 }
1794 __vb2_queue_cancel(q);
1795 return ret;
1796 } 2090 }
1797 2091
1798 q->streaming = 1; 2092 q->streaming = 1;
@@ -1831,14 +2125,14 @@ static int vb2_internal_streamoff(struct vb2_queue *q, enum v4l2_buf_type type)
1831 return -EINVAL; 2125 return -EINVAL;
1832 } 2126 }
1833 2127
1834 if (!q->streaming) {
1835 dprintk(3, "streamoff successful: not streaming\n");
1836 return 0;
1837 }
1838
1839 /* 2128 /*
1840 * Cancel will pause streaming and remove all buffers from the driver 2129 * Cancel will pause streaming and remove all buffers from the driver
1841 * and videobuf, effectively returning control over them to userspace. 2130 * and videobuf, effectively returning control over them to userspace.
2131 *
2132 * Note that we do this even if q->streaming == 0: if you prepare or
2133 * queue buffers, and then call streamoff without ever having called
2134 * streamon, you would still expect those buffers to be returned to
2135 * their normal dequeued state.
1842 */ 2136 */
1843 __vb2_queue_cancel(q); 2137 __vb2_queue_cancel(q);
1844 2138
@@ -1950,10 +2244,11 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb)
1950 2244
1951 vb_plane = &vb->planes[eb->plane]; 2245 vb_plane = &vb->planes[eb->plane];
1952 2246
1953 dbuf = call_memop(q, get_dmabuf, vb_plane->mem_priv, eb->flags & O_ACCMODE); 2247 dbuf = call_memop(vb, get_dmabuf, vb_plane->mem_priv, eb->flags & O_ACCMODE);
1954 if (IS_ERR_OR_NULL(dbuf)) { 2248 if (IS_ERR_OR_NULL(dbuf)) {
1955 dprintk(1, "Failed to export buffer %d, plane %d\n", 2249 dprintk(1, "Failed to export buffer %d, plane %d\n",
1956 eb->index, eb->plane); 2250 eb->index, eb->plane);
2251 fail_memop(vb, get_dmabuf);
1957 return -EINVAL; 2252 return -EINVAL;
1958 } 2253 }
1959 2254
@@ -2045,9 +2340,11 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
2045 return -EINVAL; 2340 return -EINVAL;
2046 } 2341 }
2047 2342
2048 ret = call_memop(q, mmap, vb->planes[plane].mem_priv, vma); 2343 ret = call_memop(vb, mmap, vb->planes[plane].mem_priv, vma);
2049 if (ret) 2344 if (ret) {
2345 fail_memop(vb, mmap);
2050 return ret; 2346 return ret;
2347 }
2051 2348
2052 dprintk(3, "Buffer %d, plane %d successfully mapped\n", buffer, plane); 2349 dprintk(3, "Buffer %d, plane %d successfully mapped\n", buffer, plane);
2053 return 0; 2350 return 0;
@@ -2200,11 +2497,14 @@ int vb2_queue_init(struct vb2_queue *q)
2200 WARN_ON(!q->io_modes) || 2497 WARN_ON(!q->io_modes) ||
2201 WARN_ON(!q->ops->queue_setup) || 2498 WARN_ON(!q->ops->queue_setup) ||
2202 WARN_ON(!q->ops->buf_queue) || 2499 WARN_ON(!q->ops->buf_queue) ||
2203 WARN_ON(q->timestamp_type & ~V4L2_BUF_FLAG_TIMESTAMP_MASK)) 2500 WARN_ON(q->timestamp_flags &
2501 ~(V4L2_BUF_FLAG_TIMESTAMP_MASK |
2502 V4L2_BUF_FLAG_TSTAMP_SRC_MASK)))
2204 return -EINVAL; 2503 return -EINVAL;
2205 2504
2206 /* Warn that the driver should choose an appropriate timestamp type */ 2505 /* Warn that the driver should choose an appropriate timestamp type */
2207 WARN_ON(q->timestamp_type == V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN); 2506 WARN_ON((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
2507 V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN);
2208 2508
2209 INIT_LIST_HEAD(&q->queued_list); 2509 INIT_LIST_HEAD(&q->queued_list);
2210 INIT_LIST_HEAD(&q->done_list); 2510 INIT_LIST_HEAD(&q->done_list);
@@ -2251,6 +2551,22 @@ struct vb2_fileio_buf {
2251/** 2551/**
2252 * struct vb2_fileio_data - queue context used by file io emulator 2552 * struct vb2_fileio_data - queue context used by file io emulator
2253 * 2553 *
2554 * @cur_index: the index of the buffer currently being read from or
2555 * written to. If equal to q->num_buffers then a new buffer
2556 * must be dequeued.
2557 * @initial_index: in the read() case all buffers are queued up immediately
2558 * in __vb2_init_fileio() and __vb2_perform_fileio() just cycles
2559 * buffers. However, in the write() case no buffers are initially
2560 * queued, instead whenever a buffer is full it is queued up by
2561 * __vb2_perform_fileio(). Only once all available buffers have
2562 * been queued up will __vb2_perform_fileio() start to dequeue
2563 * buffers. This means that initially __vb2_perform_fileio()
2564 * needs to know what buffer index to use when it is queuing up
2565 * the buffers for the first time. That initial index is stored
2566 * in this field. Once it is equal to q->num_buffers all
2567 * available buffers have been queued and __vb2_perform_fileio()
2568 * should start the normal dequeue/queue cycle.
2569 *
2254 * vb2 provides a compatibility layer and emulator of file io (read and 2570 * vb2 provides a compatibility layer and emulator of file io (read and
2255 * write) calls on top of streaming API. For proper operation it required 2571 * write) calls on top of streaming API. For proper operation it required
2256 * this structure to save the driver state between each call of the read 2572 * this structure to save the driver state between each call of the read
@@ -2260,7 +2576,8 @@ struct vb2_fileio_data {
2260 struct v4l2_requestbuffers req; 2576 struct v4l2_requestbuffers req;
2261 struct v4l2_buffer b; 2577 struct v4l2_buffer b;
2262 struct vb2_fileio_buf bufs[VIDEO_MAX_FRAME]; 2578 struct vb2_fileio_buf bufs[VIDEO_MAX_FRAME];
2263 unsigned int index; 2579 unsigned int cur_index;
2580 unsigned int initial_index;
2264 unsigned int q_count; 2581 unsigned int q_count;
2265 unsigned int dq_count; 2582 unsigned int dq_count;
2266 unsigned int flags; 2583 unsigned int flags;
@@ -2280,9 +2597,9 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
2280 /* 2597 /*
2281 * Sanity check 2598 * Sanity check
2282 */ 2599 */
2283 if ((read && !(q->io_modes & VB2_READ)) || 2600 if (WARN_ON((read && !(q->io_modes & VB2_READ)) ||
2284 (!read && !(q->io_modes & VB2_WRITE))) 2601 (!read && !(q->io_modes & VB2_WRITE))))
2285 BUG(); 2602 return -EINVAL;
2286 2603
2287 /* 2604 /*
2288 * Check if device supports mapping buffers to kernel virtual space. 2605 * Check if device supports mapping buffers to kernel virtual space.
@@ -2360,7 +2677,12 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
2360 goto err_reqbufs; 2677 goto err_reqbufs;
2361 fileio->bufs[i].queued = 1; 2678 fileio->bufs[i].queued = 1;
2362 } 2679 }
2363 fileio->index = q->num_buffers; 2680 /*
2681 * All buffers have been queued, so mark that by setting
2682 * initial_index to q->num_buffers
2683 */
2684 fileio->initial_index = q->num_buffers;
2685 fileio->cur_index = q->num_buffers;
2364 } 2686 }
2365 2687
2366 /* 2688 /*
@@ -2439,7 +2761,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
2439 /* 2761 /*
2440 * Check if we need to dequeue the buffer. 2762 * Check if we need to dequeue the buffer.
2441 */ 2763 */
2442 index = fileio->index; 2764 index = fileio->cur_index;
2443 if (index >= q->num_buffers) { 2765 if (index >= q->num_buffers) {
2444 /* 2766 /*
2445 * Call vb2_dqbuf to get buffer back. 2767 * Call vb2_dqbuf to get buffer back.
@@ -2453,7 +2775,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
2453 return ret; 2775 return ret;
2454 fileio->dq_count += 1; 2776 fileio->dq_count += 1;
2455 2777
2456 index = fileio->b.index; 2778 fileio->cur_index = index = fileio->b.index;
2457 buf = &fileio->bufs[index]; 2779 buf = &fileio->bufs[index];
2458 2780
2459 /* 2781 /*
@@ -2529,8 +2851,20 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_
2529 buf->queued = 1; 2851 buf->queued = 1;
2530 buf->size = vb2_plane_size(q->bufs[index], 0); 2852 buf->size = vb2_plane_size(q->bufs[index], 0);
2531 fileio->q_count += 1; 2853 fileio->q_count += 1;
2532 if (fileio->index < q->num_buffers) 2854 /*
2533 fileio->index++; 2855 * If we are queuing up buffers for the first time, then
2856 * increase initial_index by one.
2857 */
2858 if (fileio->initial_index < q->num_buffers)
2859 fileio->initial_index++;
2860 /*
2861 * The next buffer to use is either a buffer that's going to be
2862 * queued for the first time (initial_index < q->num_buffers)
2863 * or it is equal to q->num_buffers, meaning that the next
2864 * time we need to dequeue a buffer since we've now queued up
2865 * all the 'first time' buffers.
2866 */
2867 fileio->cur_index = fileio->initial_index;
2534 } 2868 }
2535 2869
2536 /* 2870 /*
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 4557a142c752..f72d19b7e5d2 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2196,64 +2196,65 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
2196 struct device_node *prev) 2196 struct device_node *prev)
2197{ 2197{
2198 struct device_node *endpoint; 2198 struct device_node *endpoint;
2199 struct device_node *port = NULL; 2199 struct device_node *port;
2200 2200
2201 if (!parent) 2201 if (!parent)
2202 return NULL; 2202 return NULL;
2203 2203
2204 /*
2205 * Start by locating the port node. If no previous endpoint is specified
2206 * search for the first port node, otherwise get the previous endpoint
2207 * parent port node.
2208 */
2204 if (!prev) { 2209 if (!prev) {
2205 struct device_node *node; 2210 struct device_node *node;
2206 /* 2211
2207 * It's the first call, we have to find a port subnode
2208 * within this node or within an optional 'ports' node.
2209 */
2210 node = of_get_child_by_name(parent, "ports"); 2212 node = of_get_child_by_name(parent, "ports");
2211 if (node) 2213 if (node)
2212 parent = node; 2214 parent = node;
2213 2215
2214 port = of_get_child_by_name(parent, "port"); 2216 port = of_get_child_by_name(parent, "port");
2215
2216 if (port) {
2217 /* Found a port, get an endpoint. */
2218 endpoint = of_get_next_child(port, NULL);
2219 of_node_put(port);
2220 } else {
2221 endpoint = NULL;
2222 }
2223
2224 if (!endpoint)
2225 pr_err("%s(): no endpoint nodes specified for %s\n",
2226 __func__, parent->full_name);
2227 of_node_put(node); 2217 of_node_put(node);
2228 2218
2229 return endpoint; 2219 if (!port) {
2230 } 2220 pr_err("%s(): no port node found in %s\n",
2231 2221 __func__, parent->full_name);
2232 port = of_get_parent(prev); 2222 return NULL;
2233 if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n", 2223 }
2234 __func__, prev->full_name)) 2224 } else {
2235 return NULL; 2225 port = of_get_parent(prev);
2226 if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n",
2227 __func__, prev->full_name))
2228 return NULL;
2236 2229
2237 /* Avoid dropping prev node refcount to 0. */ 2230 /*
2238 of_node_get(prev); 2231 * Avoid dropping prev node refcount to 0 when getting the next
2239 endpoint = of_get_next_child(port, prev); 2232 * child below.
2240 if (endpoint) { 2233 */
2241 of_node_put(port); 2234 of_node_get(prev);
2242 return endpoint;
2243 } 2235 }
2244 2236
2245 /* No more endpoints under this port, try the next one. */ 2237 while (1) {
2246 do { 2238 /*
2247 port = of_get_next_child(parent, port); 2239 * Now that we have a port node, get the next endpoint by
2248 if (!port) 2240 * getting the next child. If the previous endpoint is NULL this
2249 return NULL; 2241 * will return the first child.
2250 } while (of_node_cmp(port->name, "port")); 2242 */
2243 endpoint = of_get_next_child(port, prev);
2244 if (endpoint) {
2245 of_node_put(port);
2246 return endpoint;
2247 }
2251 2248
2252 /* Pick up the first endpoint in this port. */ 2249 /* No more endpoints under this port, try the next one. */
2253 endpoint = of_get_next_child(port, NULL); 2250 prev = NULL;
2254 of_node_put(port);
2255 2251
2256 return endpoint; 2252 do {
2253 port = of_get_next_child(parent, port);
2254 if (!port)
2255 return NULL;
2256 } while (of_node_cmp(port->name, "port"));
2257 }
2257} 2258}
2258EXPORT_SYMBOL(of_graph_get_next_endpoint); 2259EXPORT_SYMBOL(of_graph_get_next_endpoint);
2259 2260
diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig
index 22b0c9d6f046..a9f2e63a7c9c 100644
--- a/drivers/staging/media/Kconfig
+++ b/drivers/staging/media/Kconfig
@@ -41,6 +41,8 @@ source "drivers/staging/media/solo6x10/Kconfig"
41 41
42source "drivers/staging/media/omap4iss/Kconfig" 42source "drivers/staging/media/omap4iss/Kconfig"
43 43
44source "drivers/staging/media/rtl2832u_sdr/Kconfig"
45
44# Keep LIRC at the end, as it has sub-menus 46# Keep LIRC at the end, as it has sub-menus
45source "drivers/staging/media/lirc/Kconfig" 47source "drivers/staging/media/lirc/Kconfig"
46 48
diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index bedc62aaede6..8e2c5d272162 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -11,3 +11,5 @@ obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/
11obj-$(CONFIG_USB_SN9C102) += sn9c102/ 11obj-$(CONFIG_USB_SN9C102) += sn9c102/
12obj-$(CONFIG_VIDEO_OMAP2) += omap24xx/ 12obj-$(CONFIG_VIDEO_OMAP2) += omap24xx/
13obj-$(CONFIG_VIDEO_TCM825X) += omap24xx/ 13obj-$(CONFIG_VIDEO_TCM825X) += omap24xx/
14obj-$(CONFIG_DVB_RTL2832_SDR) += rtl2832u_sdr/
15
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
index 2d36b60bdbf1..b2daf5e63f88 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
@@ -267,7 +267,7 @@ int config_ipipe_hw(struct vpfe_ipipe_device *ipipe)
267 } 267 }
268 268
269 ipipe_mode = get_ipipe_mode(ipipe); 269 ipipe_mode = get_ipipe_mode(ipipe);
270 if (ipipe < 0) { 270 if (ipipe_mode < 0) {
271 pr_err("Failed to get ipipe mode"); 271 pr_err("Failed to get ipipe mode");
272 return -EINVAL; 272 return -EINVAL;
273 } 273 }
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
index d8ce20d2fbda..cda8388cbb89 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
@@ -298,7 +298,7 @@ static int vpfe_attach_irq(struct vpfe_device *vpfe_dev)
298{ 298{
299 int ret = 0; 299 int ret = 0;
300 300
301 ret = request_irq(vpfe_dev->ccdc_irq0, vpfe_isr, IRQF_DISABLED, 301 ret = request_irq(vpfe_dev->ccdc_irq0, vpfe_isr, 0,
302 "vpfe_capture0", vpfe_dev); 302 "vpfe_capture0", vpfe_dev);
303 if (ret < 0) { 303 if (ret < 0) {
304 v4l2_err(&vpfe_dev->v4l2_dev, 304 v4l2_err(&vpfe_dev->v4l2_dev,
@@ -306,7 +306,7 @@ static int vpfe_attach_irq(struct vpfe_device *vpfe_dev)
306 return ret; 306 return ret;
307 } 307 }
308 308
309 ret = request_irq(vpfe_dev->ccdc_irq1, vpfe_vdint1_isr, IRQF_DISABLED, 309 ret = request_irq(vpfe_dev->ccdc_irq1, vpfe_vdint1_isr, 0,
310 "vpfe_capture1", vpfe_dev); 310 "vpfe_capture1", vpfe_dev);
311 if (ret < 0) { 311 if (ret < 0) {
312 v4l2_err(&vpfe_dev->v4l2_dev, 312 v4l2_err(&vpfe_dev->v4l2_dev,
@@ -316,7 +316,7 @@ static int vpfe_attach_irq(struct vpfe_device *vpfe_dev)
316 } 316 }
317 317
318 ret = request_irq(vpfe_dev->imp_dma_irq, vpfe_imp_dma_isr, 318 ret = request_irq(vpfe_dev->imp_dma_irq, vpfe_imp_dma_isr,
319 IRQF_DISABLED, "Imp_Sdram_Irq", vpfe_dev); 319 0, "Imp_Sdram_Irq", vpfe_dev);
320 if (ret < 0) { 320 if (ret < 0) {
321 v4l2_err(&vpfe_dev->v4l2_dev, 321 v4l2_err(&vpfe_dev->v4l2_dev,
322 "Error: requesting IMP IRQ interrupt\n"); 322 "Error: requesting IMP IRQ interrupt\n");
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 1f3b0f9a8d10..8c101cbbee97 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -1201,8 +1201,6 @@ static int vpfe_start_streaming(struct vb2_queue *vq, unsigned int count)
1201 unsigned long addr; 1201 unsigned long addr;
1202 int ret; 1202 int ret;
1203 1203
1204 if (count == 0)
1205 return -ENOBUFS;
1206 ret = mutex_lock_interruptible(&video->lock); 1204 ret = mutex_lock_interruptible(&video->lock);
1207 if (ret) 1205 if (ret)
1208 goto streamoff; 1206 goto streamoff;
@@ -1327,6 +1325,7 @@ static int vpfe_reqbufs(struct file *file, void *priv,
1327 q->type = req_buf->type; 1325 q->type = req_buf->type;
1328 q->io_modes = VB2_MMAP | VB2_USERPTR; 1326 q->io_modes = VB2_MMAP | VB2_USERPTR;
1329 q->drv_priv = fh; 1327 q->drv_priv = fh;
1328 q->min_buffers_needed = 1;
1330 q->ops = &video_qops; 1329 q->ops = &video_qops;
1331 q->mem_ops = &vb2_dma_contig_memops; 1330 q->mem_ops = &vb2_dma_contig_memops;
1332 q->buf_struct_size = sizeof(struct vpfe_cap_buffer); 1331 q->buf_struct_size = sizeof(struct vpfe_cap_buffer);
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 97e7a9b48ac2..afbc2e519606 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -31,7 +31,6 @@
31 31
32#include "dt3155v4l.h" 32#include "dt3155v4l.h"
33 33
34#define DT3155_VENDOR_ID 0x8086
35#define DT3155_DEVICE_ID 0x1223 34#define DT3155_DEVICE_ID 0x1223
36 35
37/* DT3155_CHUNK_SIZE is 4M (2^22) 8 full size buffers */ 36/* DT3155_CHUNK_SIZE is 4M (2^22) 8 full size buffers */
@@ -391,7 +390,7 @@ dt3155_open(struct file *filp)
391 goto err_alloc_queue; 390 goto err_alloc_queue;
392 } 391 }
393 pd->q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 392 pd->q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
394 pd->q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 393 pd->q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
395 pd->q->io_modes = VB2_READ | VB2_MMAP; 394 pd->q->io_modes = VB2_READ | VB2_MMAP;
396 pd->q->ops = &q_ops; 395 pd->q->ops = &q_ops;
397 pd->q->mem_ops = &vb2_dma_contig_memops; 396 pd->q->mem_ops = &vb2_dma_contig_memops;
@@ -975,7 +974,7 @@ dt3155_remove(struct pci_dev *pdev)
975} 974}
976 975
977static const struct pci_device_id pci_ids[] = { 976static const struct pci_device_id pci_ids[] = {
978 { PCI_DEVICE(DT3155_VENDOR_ID, DT3155_DEVICE_ID) }, 977 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, DT3155_DEVICE_ID) },
979 { 0, /* zero marks the end */ }, 978 { 0, /* zero marks the end */ },
980}; 979};
981MODULE_DEVICE_TABLE(pci, pci_ids); 980MODULE_DEVICE_TABLE(pci, pci_ids);
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c b/drivers/staging/media/go7007/go7007-v4l2.c
index bdf414e19c8f..b397aa3c0f44 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -471,7 +471,7 @@ static int go7007_buf_prepare(struct vb2_buffer *vb)
471 return 0; 471 return 0;
472} 472}
473 473
474static int go7007_buf_finish(struct vb2_buffer *vb) 474static void go7007_buf_finish(struct vb2_buffer *vb)
475{ 475{
476 struct vb2_queue *vq = vb->vb2_queue; 476 struct vb2_queue *vq = vb->vb2_queue;
477 struct go7007 *go = vb2_get_drv_priv(vq); 477 struct go7007 *go = vb2_get_drv_priv(vq);
@@ -484,7 +484,6 @@ static int go7007_buf_finish(struct vb2_buffer *vb)
484 V4L2_BUF_FLAG_PFRAME); 484 V4L2_BUF_FLAG_PFRAME);
485 buf->flags |= frame_type_flag; 485 buf->flags |= frame_type_flag;
486 buf->field = V4L2_FIELD_NONE; 486 buf->field = V4L2_FIELD_NONE;
487 return 0;
488} 487}
489 488
490static int go7007_start_streaming(struct vb2_queue *q, unsigned int count) 489static int go7007_start_streaming(struct vb2_queue *q, unsigned int count)
@@ -995,7 +994,7 @@ int go7007_v4l2_init(struct go7007 *go)
995 go->vidq.mem_ops = &vb2_vmalloc_memops; 994 go->vidq.mem_ops = &vb2_vmalloc_memops;
996 go->vidq.drv_priv = go; 995 go->vidq.drv_priv = go;
997 go->vidq.buf_struct_size = sizeof(struct go7007_buffer); 996 go->vidq.buf_struct_size = sizeof(struct go7007_buffer);
998 go->vidq.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 997 go->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
999 go->vidq.lock = &go->queue_lock; 998 go->vidq.lock = &go->queue_lock;
1000 rv = vb2_queue_init(&go->vidq); 999 rv = vb2_queue_init(&go->vidq);
1001 if (rv) 1000 if (rv)
diff --git a/drivers/staging/media/msi3101/Kconfig b/drivers/staging/media/msi3101/Kconfig
index 0c349c8595e4..de0b3bba3873 100644
--- a/drivers/staging/media/msi3101/Kconfig
+++ b/drivers/staging/media/msi3101/Kconfig
@@ -1,5 +1,10 @@
1config USB_MSI3101 1config USB_MSI3101
2 tristate "Mirics MSi3101 SDR Dongle" 2 tristate "Mirics MSi3101 SDR Dongle"
3 depends on USB && VIDEO_DEV && VIDEO_V4L2 3 depends on USB && VIDEO_DEV && VIDEO_V4L2 && SPI
4 select VIDEOBUF2_CORE 4 select VIDEOBUF2_CORE
5 select VIDEOBUF2_VMALLOC 5 select VIDEOBUF2_VMALLOC
6 select MEDIA_TUNER_MSI001
7
8config MEDIA_TUNER_MSI001
9 tristate "Mirics MSi001"
10 depends on VIDEO_V4L2 && SPI
diff --git a/drivers/staging/media/msi3101/Makefile b/drivers/staging/media/msi3101/Makefile
index 3730654b0eb9..daf4f58d9a56 100644
--- a/drivers/staging/media/msi3101/Makefile
+++ b/drivers/staging/media/msi3101/Makefile
@@ -1 +1,2 @@
1obj-$(CONFIG_USB_MSI3101) += sdr-msi3101.o 1obj-$(CONFIG_USB_MSI3101) += sdr-msi3101.o
2obj-$(CONFIG_MEDIA_TUNER_MSI001) += msi001.o
diff --git a/drivers/staging/media/msi3101/msi001.c b/drivers/staging/media/msi3101/msi001.c
new file mode 100644
index 000000000000..ac43bae10102
--- /dev/null
+++ b/drivers/staging/media/msi3101/msi001.c
@@ -0,0 +1,500 @@
1/*
2 * Mirics MSi001 silicon tuner driver
3 *
4 * Copyright (C) 2013 Antti Palosaari <crope@iki.fi>
5 * Copyright (C) 2014 Antti Palosaari <crope@iki.fi>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#include <linux/module.h>
19#include <linux/gcd.h>
20#include <media/v4l2-device.h>
21#include <media/v4l2-ctrls.h>
22
23static const struct v4l2_frequency_band bands[] = {
24 {
25 .type = V4L2_TUNER_RF,
26 .index = 0,
27 .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
28 .rangelow = 49000000,
29 .rangehigh = 263000000,
30 }, {
31 .type = V4L2_TUNER_RF,
32 .index = 1,
33 .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
34 .rangelow = 390000000,
35 .rangehigh = 960000000,
36 },
37};
38
39struct msi001 {
40 struct spi_device *spi;
41 struct v4l2_subdev sd;
42
43 /* Controls */
44 struct v4l2_ctrl_handler hdl;
45 struct v4l2_ctrl *bandwidth_auto;
46 struct v4l2_ctrl *bandwidth;
47 struct v4l2_ctrl *lna_gain;
48 struct v4l2_ctrl *mixer_gain;
49 struct v4l2_ctrl *if_gain;
50
51 unsigned int f_tuner;
52};
53
54static inline struct msi001 *sd_to_msi001(struct v4l2_subdev *sd)
55{
56 return container_of(sd, struct msi001, sd);
57}
58
59static int msi001_wreg(struct msi001 *s, u32 data)
60{
61 /* Register format: 4 bits addr + 20 bits value */
62 return spi_write(s->spi, &data, 3);
63};
64
65static int msi001_set_gain(struct msi001 *s, int lna_gain, int mixer_gain,
66 int if_gain)
67{
68 int ret;
69 u32 reg;
70 dev_dbg(&s->spi->dev, "%s: lna=%d mixer=%d if=%d\n", __func__,
71 lna_gain, mixer_gain, if_gain);
72
73 reg = 1 << 0;
74 reg |= (59 - if_gain) << 4;
75 reg |= 0 << 10;
76 reg |= (1 - mixer_gain) << 12;
77 reg |= (1 - lna_gain) << 13;
78 reg |= 4 << 14;
79 reg |= 0 << 17;
80 ret = msi001_wreg(s, reg);
81 if (ret)
82 goto err;
83
84 return 0;
85err:
86 dev_dbg(&s->spi->dev, "%s: failed %d\n", __func__, ret);
87 return ret;
88};
89
90static int msi001_set_tuner(struct msi001 *s)
91{
92 int ret, i;
93 unsigned int n, m, thresh, frac, vco_step, tmp, f_if1;
94 u32 reg;
95 u64 f_vco, tmp64;
96 u8 mode, filter_mode, lo_div;
97 static const struct {
98 u32 rf;
99 u8 mode;
100 u8 lo_div;
101 } band_lut[] = {
102 { 50000000, 0xe1, 16}, /* AM_MODE2, antenna 2 */
103 {108000000, 0x42, 32}, /* VHF_MODE */
104 {330000000, 0x44, 16}, /* B3_MODE */
105 {960000000, 0x48, 4}, /* B45_MODE */
106 { ~0U, 0x50, 2}, /* BL_MODE */
107 };
108 static const struct {
109 u32 freq;
110 u8 filter_mode;
111 } if_freq_lut[] = {
112 { 0, 0x03}, /* Zero IF */
113 { 450000, 0x02}, /* 450 kHz IF */
114 {1620000, 0x01}, /* 1.62 MHz IF */
115 {2048000, 0x00}, /* 2.048 MHz IF */
116 };
117 static const struct {
118 u32 freq;
119 u8 val;
120 } bandwidth_lut[] = {
121 { 200000, 0x00}, /* 200 kHz */
122 { 300000, 0x01}, /* 300 kHz */
123 { 600000, 0x02}, /* 600 kHz */
124 {1536000, 0x03}, /* 1.536 MHz */
125 {5000000, 0x04}, /* 5 MHz */
126 {6000000, 0x05}, /* 6 MHz */
127 {7000000, 0x06}, /* 7 MHz */
128 {8000000, 0x07}, /* 8 MHz */
129 };
130
131 unsigned int f_rf = s->f_tuner;
132
133 /*
134 * bandwidth (Hz)
135 * 200000, 300000, 600000, 1536000, 5000000, 6000000, 7000000, 8000000
136 */
137 unsigned int bandwidth;
138
139 /*
140 * intermediate frequency (Hz)
141 * 0, 450000, 1620000, 2048000
142 */
143 unsigned int f_if = 0;
144 #define F_REF 24000000
145 #define R_REF 4
146 #define F_OUT_STEP 1
147
148 dev_dbg(&s->spi->dev,
149 "%s: f_rf=%d f_if=%d\n",
150 __func__, f_rf, f_if);
151
152 for (i = 0; i < ARRAY_SIZE(band_lut); i++) {
153 if (f_rf <= band_lut[i].rf) {
154 mode = band_lut[i].mode;
155 lo_div = band_lut[i].lo_div;
156 break;
157 }
158 }
159
160 if (i == ARRAY_SIZE(band_lut)) {
161 ret = -EINVAL;
162 goto err;
163 }
164
165 /* AM_MODE is upconverted */
166 if ((mode >> 0) & 0x1)
167 f_if1 = 5 * F_REF;
168 else
169 f_if1 = 0;
170
171 for (i = 0; i < ARRAY_SIZE(if_freq_lut); i++) {
172 if (f_if == if_freq_lut[i].freq) {
173 filter_mode = if_freq_lut[i].filter_mode;
174 break;
175 }
176 }
177
178 if (i == ARRAY_SIZE(if_freq_lut)) {
179 ret = -EINVAL;
180 goto err;
181 }
182
183 /* filters */
184 bandwidth = s->bandwidth->val;
185 bandwidth = clamp(bandwidth, 200000U, 8000000U);
186
187 for (i = 0; i < ARRAY_SIZE(bandwidth_lut); i++) {
188 if (bandwidth <= bandwidth_lut[i].freq) {
189 bandwidth = bandwidth_lut[i].val;
190 break;
191 }
192 }
193
194 if (i == ARRAY_SIZE(bandwidth_lut)) {
195 ret = -EINVAL;
196 goto err;
197 }
198
199 s->bandwidth->val = bandwidth_lut[i].freq;
200
201 dev_dbg(&s->spi->dev, "%s: bandwidth selected=%d\n",
202 __func__, bandwidth_lut[i].freq);
203
204 f_vco = (f_rf + f_if + f_if1) * lo_div;
205 tmp64 = f_vco;
206 m = do_div(tmp64, F_REF * R_REF);
207 n = (unsigned int) tmp64;
208
209 vco_step = F_OUT_STEP * lo_div;
210 thresh = (F_REF * R_REF) / vco_step;
211 frac = 1ul * thresh * m / (F_REF * R_REF);
212
213 /* Find out greatest common divisor and divide to smaller. */
214 tmp = gcd(thresh, frac);
215 thresh /= tmp;
216 frac /= tmp;
217
218 /* Force divide to reg max. Resolution will be reduced. */
219 tmp = DIV_ROUND_UP(thresh, 4095);
220 thresh = DIV_ROUND_CLOSEST(thresh, tmp);
221 frac = DIV_ROUND_CLOSEST(frac, tmp);
222
223 /* calc real RF set */
224 tmp = 1ul * F_REF * R_REF * n;
225 tmp += 1ul * F_REF * R_REF * frac / thresh;
226 tmp /= lo_div;
227
228 dev_dbg(&s->spi->dev,
229 "%s: rf=%u:%u n=%d thresh=%d frac=%d\n",
230 __func__, f_rf, tmp, n, thresh, frac);
231
232 ret = msi001_wreg(s, 0x00000e);
233 if (ret)
234 goto err;
235
236 ret = msi001_wreg(s, 0x000003);
237 if (ret)
238 goto err;
239
240 reg = 0 << 0;
241 reg |= mode << 4;
242 reg |= filter_mode << 12;
243 reg |= bandwidth << 14;
244 reg |= 0x02 << 17;
245 reg |= 0x00 << 20;
246 ret = msi001_wreg(s, reg);
247 if (ret)
248 goto err;
249
250 reg = 5 << 0;
251 reg |= thresh << 4;
252 reg |= 1 << 19;
253 reg |= 1 << 21;
254 ret = msi001_wreg(s, reg);
255 if (ret)
256 goto err;
257
258 reg = 2 << 0;
259 reg |= frac << 4;
260 reg |= n << 16;
261 ret = msi001_wreg(s, reg);
262 if (ret)
263 goto err;
264
265 ret = msi001_set_gain(s, s->lna_gain->cur.val, s->mixer_gain->cur.val,
266 s->if_gain->cur.val);
267 if (ret)
268 goto err;
269
270 reg = 6 << 0;
271 reg |= 63 << 4;
272 reg |= 4095 << 10;
273 ret = msi001_wreg(s, reg);
274 if (ret)
275 goto err;
276
277 return 0;
278err:
279 dev_dbg(&s->spi->dev, "%s: failed %d\n", __func__, ret);
280 return ret;
281};
282
283static int msi001_s_power(struct v4l2_subdev *sd, int on)
284{
285 struct msi001 *s = sd_to_msi001(sd);
286 int ret;
287 dev_dbg(&s->spi->dev, "%s: on=%d\n", __func__, on);
288
289 if (on)
290 ret = 0;
291 else
292 ret = msi001_wreg(s, 0x000000);
293
294 return ret;
295}
296
297static const struct v4l2_subdev_core_ops msi001_core_ops = {
298 .s_power = msi001_s_power,
299};
300
301static int msi001_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *v)
302{
303 struct msi001 *s = sd_to_msi001(sd);
304 dev_dbg(&s->spi->dev, "%s: index=%d\n", __func__, v->index);
305
306 strlcpy(v->name, "Mirics MSi001", sizeof(v->name));
307 v->type = V4L2_TUNER_RF;
308 v->capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS;
309 v->rangelow = 49000000;
310 v->rangehigh = 960000000;
311
312 return 0;
313}
314
315static int msi001_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *v)
316{
317 struct msi001 *s = sd_to_msi001(sd);
318 dev_dbg(&s->spi->dev, "%s: index=%d\n", __func__, v->index);
319 return 0;
320}
321
322static int msi001_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f)
323{
324 struct msi001 *s = sd_to_msi001(sd);
325 dev_dbg(&s->spi->dev, "%s: tuner=%d\n", __func__, f->tuner);
326 f->frequency = s->f_tuner;
327 return 0;
328}
329
330static int msi001_s_frequency(struct v4l2_subdev *sd,
331 const struct v4l2_frequency *f)
332{
333 struct msi001 *s = sd_to_msi001(sd);
334 unsigned int band;
335 dev_dbg(&s->spi->dev, "%s: tuner=%d type=%d frequency=%u\n",
336 __func__, f->tuner, f->type, f->frequency);
337
338 if (f->frequency < ((bands[0].rangehigh + bands[1].rangelow) / 2))
339 band = 0;
340 else
341 band = 1;
342 s->f_tuner = clamp_t(unsigned int, f->frequency,
343 bands[band].rangelow, bands[band].rangehigh);
344
345 return msi001_set_tuner(s);
346}
347
348static int msi001_enum_freq_bands(struct v4l2_subdev *sd,
349 struct v4l2_frequency_band *band)
350{
351 struct msi001 *s = sd_to_msi001(sd);
352 dev_dbg(&s->spi->dev, "%s: tuner=%d type=%d index=%d\n",
353 __func__, band->tuner, band->type, band->index);
354
355 if (band->index >= ARRAY_SIZE(bands))
356 return -EINVAL;
357
358 band->capability = bands[band->index].capability;
359 band->rangelow = bands[band->index].rangelow;
360 band->rangehigh = bands[band->index].rangehigh;
361
362 return 0;
363}
364
365static const struct v4l2_subdev_tuner_ops msi001_tuner_ops = {
366 .g_tuner = msi001_g_tuner,
367 .s_tuner = msi001_s_tuner,
368 .g_frequency = msi001_g_frequency,
369 .s_frequency = msi001_s_frequency,
370 .enum_freq_bands = msi001_enum_freq_bands,
371};
372
373static const struct v4l2_subdev_ops msi001_ops = {
374 .core = &msi001_core_ops,
375 .tuner = &msi001_tuner_ops,
376};
377
378static int msi001_s_ctrl(struct v4l2_ctrl *ctrl)
379{
380 struct msi001 *s = container_of(ctrl->handler, struct msi001, hdl);
381
382 int ret;
383 dev_dbg(&s->spi->dev,
384 "%s: id=%d name=%s val=%d min=%d max=%d step=%d\n",
385 __func__, ctrl->id, ctrl->name, ctrl->val,
386 ctrl->minimum, ctrl->maximum, ctrl->step);
387
388 switch (ctrl->id) {
389 case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO:
390 case V4L2_CID_RF_TUNER_BANDWIDTH:
391 ret = msi001_set_tuner(s);
392 break;
393 case V4L2_CID_RF_TUNER_LNA_GAIN:
394 ret = msi001_set_gain(s, s->lna_gain->val,
395 s->mixer_gain->cur.val, s->if_gain->cur.val);
396 break;
397 case V4L2_CID_RF_TUNER_MIXER_GAIN:
398 ret = msi001_set_gain(s, s->lna_gain->cur.val,
399 s->mixer_gain->val, s->if_gain->cur.val);
400 break;
401 case V4L2_CID_RF_TUNER_IF_GAIN:
402 ret = msi001_set_gain(s, s->lna_gain->cur.val,
403 s->mixer_gain->cur.val, s->if_gain->val);
404 break;
405 default:
406 dev_dbg(&s->spi->dev, "%s: unkown control %d\n",
407 __func__, ctrl->id);
408 ret = -EINVAL;
409 }
410
411 return ret;
412}
413
414static const struct v4l2_ctrl_ops msi001_ctrl_ops = {
415 .s_ctrl = msi001_s_ctrl,
416};
417
418static int msi001_probe(struct spi_device *spi)
419{
420 struct msi001 *s;
421 int ret;
422 dev_dbg(&spi->dev, "%s:\n", __func__);
423
424 s = kzalloc(sizeof(struct msi001), GFP_KERNEL);
425 if (s == NULL) {
426 ret = -ENOMEM;
427 dev_dbg(&spi->dev, "Could not allocate memory for msi001\n");
428 goto err_kfree;
429 }
430
431 s->spi = spi;
432 s->f_tuner = bands[0].rangelow;
433 v4l2_spi_subdev_init(&s->sd, spi, &msi001_ops);
434
435 /* Register controls */
436 v4l2_ctrl_handler_init(&s->hdl, 5);
437 s->bandwidth_auto = v4l2_ctrl_new_std(&s->hdl, &msi001_ctrl_ops,
438 V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1);
439 s->bandwidth = v4l2_ctrl_new_std(&s->hdl, &msi001_ctrl_ops,
440 V4L2_CID_RF_TUNER_BANDWIDTH, 200000, 8000000, 1, 200000);
441 v4l2_ctrl_auto_cluster(2, &s->bandwidth_auto, 0, false);
442 s->lna_gain = v4l2_ctrl_new_std(&s->hdl, &msi001_ctrl_ops,
443 V4L2_CID_RF_TUNER_LNA_GAIN, 0, 1, 1, 1);
444 s->mixer_gain = v4l2_ctrl_new_std(&s->hdl, &msi001_ctrl_ops,
445 V4L2_CID_RF_TUNER_MIXER_GAIN, 0, 1, 1, 1);
446 s->if_gain = v4l2_ctrl_new_std(&s->hdl, &msi001_ctrl_ops,
447 V4L2_CID_RF_TUNER_IF_GAIN, 0, 59, 1, 0);
448 if (s->hdl.error) {
449 ret = s->hdl.error;
450 dev_err(&s->spi->dev, "Could not initialize controls\n");
451 /* control init failed, free handler */
452 goto err_ctrl_handler_free;
453 }
454
455 s->sd.ctrl_handler = &s->hdl;
456 return 0;
457
458err_ctrl_handler_free:
459 v4l2_ctrl_handler_free(&s->hdl);
460err_kfree:
461 kfree(s);
462 return ret;
463}
464
465static int msi001_remove(struct spi_device *spi)
466{
467 struct v4l2_subdev *sd = spi_get_drvdata(spi);
468 struct msi001 *s = sd_to_msi001(sd);
469 dev_dbg(&spi->dev, "%s:\n", __func__);
470
471 /*
472 * Registered by v4l2_spi_new_subdev() from master driver, but we must
473 * unregister it from here. Weird.
474 */
475 v4l2_device_unregister_subdev(&s->sd);
476 v4l2_ctrl_handler_free(&s->hdl);
477 kfree(s);
478 return 0;
479}
480
481static const struct spi_device_id msi001_id[] = {
482 {"msi001", 0},
483 {}
484};
485MODULE_DEVICE_TABLE(spi, msi001_id);
486
487static struct spi_driver msi001_driver = {
488 .driver = {
489 .name = "msi001",
490 .owner = THIS_MODULE,
491 },
492 .probe = msi001_probe,
493 .remove = msi001_remove,
494 .id_table = msi001_id,
495};
496module_spi_driver(msi001_driver);
497
498MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
499MODULE_DESCRIPTION("Mirics MSi001");
500MODULE_LICENSE("GPL");
diff --git a/drivers/staging/media/msi3101/sdr-msi3101.c b/drivers/staging/media/msi3101/sdr-msi3101.c
index 5a0400fdb98c..260d1b736721 100644
--- a/drivers/staging/media/msi3101/sdr-msi3101.c
+++ b/drivers/staging/media/msi3101/sdr-msi3101.c
@@ -21,25 +21,10 @@
21 * (C) 1999-2004 Nemosoft Unv. 21 * (C) 1999-2004 Nemosoft Unv.
22 * (C) 2004-2006 Luc Saillard (luc@saillard.org) 22 * (C) 2004-2006 Luc Saillard (luc@saillard.org)
23 * (C) 2011 Hans de Goede <hdegoede@redhat.com> 23 * (C) 2011 Hans de Goede <hdegoede@redhat.com>
24 *
25 * Development tree of that driver will be on:
26 * http://git.linuxtv.org/anttip/media_tree.git/shortlog/refs/heads/mirics
27 *
28 * GNU Radio plugin "gr-kernel" for device usage will be on:
29 * http://git.linuxtv.org/anttip/gr-kernel.git
30 *
31 * TODO:
32 * Help is very highly welcome for these + all the others you could imagine:
33 * - split USB ADC interface and RF tuner to own drivers (msi2500 and msi001)
34 * - move controls to V4L2 API
35 * - use libv4l2 for stream format conversions
36 * - gr-kernel: switch to v4l2_mmap (current read eats a lot of cpu)
37 * - SDRSharp support
38 */ 24 */
39 25
40#include <linux/module.h> 26#include <linux/module.h>
41#include <linux/slab.h> 27#include <linux/slab.h>
42#include <linux/gcd.h>
43#include <asm/div64.h> 28#include <asm/div64.h>
44#include <media/v4l2-device.h> 29#include <media/v4l2-device.h>
45#include <media/v4l2-ioctl.h> 30#include <media/v4l2-ioctl.h>
@@ -47,317 +32,7 @@
47#include <media/v4l2-event.h> 32#include <media/v4l2-event.h>
48#include <linux/usb.h> 33#include <linux/usb.h>
49#include <media/videobuf2-vmalloc.h> 34#include <media/videobuf2-vmalloc.h>
50 35#include <linux/spi/spi.h>
51struct msi3101_gain {
52 u8 tot:7;
53 u8 baseband:6;
54 bool lna:1;
55 bool mixer:1;
56};
57
58/* 60 – 120 MHz band, lna 24dB, mixer 19dB */
59static const struct msi3101_gain msi3101_gain_lut_120[] = {
60 { 0, 0, 0, 0},
61 { 1, 1, 0, 0},
62 { 2, 2, 0, 0},
63 { 3, 3, 0, 0},
64 { 4, 4, 0, 0},
65 { 5, 5, 0, 0},
66 { 6, 6, 0, 0},
67 { 7, 7, 0, 0},
68 { 8, 8, 0, 0},
69 { 9, 9, 0, 0},
70 { 10, 10, 0, 0},
71 { 11, 11, 0, 0},
72 { 12, 12, 0, 0},
73 { 13, 13, 0, 0},
74 { 14, 14, 0, 0},
75 { 15, 15, 0, 0},
76 { 16, 16, 0, 0},
77 { 17, 17, 0, 0},
78 { 18, 18, 0, 0},
79 { 19, 19, 0, 0},
80 { 20, 20, 0, 0},
81 { 21, 21, 0, 0},
82 { 22, 22, 0, 0},
83 { 23, 23, 0, 0},
84 { 24, 24, 0, 0},
85 { 25, 25, 0, 0},
86 { 26, 26, 0, 0},
87 { 27, 27, 0, 0},
88 { 28, 28, 0, 0},
89 { 29, 5, 1, 0},
90 { 30, 6, 1, 0},
91 { 31, 7, 1, 0},
92 { 32, 8, 1, 0},
93 { 33, 9, 1, 0},
94 { 34, 10, 1, 0},
95 { 35, 11, 1, 0},
96 { 36, 12, 1, 0},
97 { 37, 13, 1, 0},
98 { 38, 14, 1, 0},
99 { 39, 15, 1, 0},
100 { 40, 16, 1, 0},
101 { 41, 17, 1, 0},
102 { 42, 18, 1, 0},
103 { 43, 19, 1, 0},
104 { 44, 20, 1, 0},
105 { 45, 21, 1, 0},
106 { 46, 22, 1, 0},
107 { 47, 23, 1, 0},
108 { 48, 24, 1, 0},
109 { 49, 25, 1, 0},
110 { 50, 26, 1, 0},
111 { 51, 27, 1, 0},
112 { 52, 28, 1, 0},
113 { 53, 29, 1, 0},
114 { 54, 30, 1, 0},
115 { 55, 31, 1, 0},
116 { 56, 32, 1, 0},
117 { 57, 33, 1, 0},
118 { 58, 34, 1, 0},
119 { 59, 35, 1, 0},
120 { 60, 36, 1, 0},
121 { 61, 37, 1, 0},
122 { 62, 38, 1, 0},
123 { 63, 39, 1, 0},
124 { 64, 40, 1, 0},
125 { 65, 41, 1, 0},
126 { 66, 42, 1, 0},
127 { 67, 43, 1, 0},
128 { 68, 44, 1, 0},
129 { 69, 45, 1, 0},
130 { 70, 46, 1, 0},
131 { 71, 47, 1, 0},
132 { 72, 48, 1, 0},
133 { 73, 49, 1, 0},
134 { 74, 50, 1, 0},
135 { 75, 51, 1, 0},
136 { 76, 52, 1, 0},
137 { 77, 53, 1, 0},
138 { 78, 54, 1, 0},
139 { 79, 55, 1, 0},
140 { 80, 56, 1, 0},
141 { 81, 57, 1, 0},
142 { 82, 58, 1, 0},
143 { 83, 40, 1, 1},
144 { 84, 41, 1, 1},
145 { 85, 42, 1, 1},
146 { 86, 43, 1, 1},
147 { 87, 44, 1, 1},
148 { 88, 45, 1, 1},
149 { 89, 46, 1, 1},
150 { 90, 47, 1, 1},
151 { 91, 48, 1, 1},
152 { 92, 49, 1, 1},
153 { 93, 50, 1, 1},
154 { 94, 51, 1, 1},
155 { 95, 52, 1, 1},
156 { 96, 53, 1, 1},
157 { 97, 54, 1, 1},
158 { 98, 55, 1, 1},
159 { 99, 56, 1, 1},
160 {100, 57, 1, 1},
161 {101, 58, 1, 1},
162 {102, 59, 1, 1},
163};
164
165/* 120 – 245 MHz band, lna 24dB, mixer 19dB */
166static const struct msi3101_gain msi3101_gain_lut_245[] = {
167 { 0, 0, 0, 0},
168 { 1, 1, 0, 0},
169 { 2, 2, 0, 0},
170 { 3, 3, 0, 0},
171 { 4, 4, 0, 0},
172 { 5, 5, 0, 0},
173 { 6, 6, 0, 0},
174 { 7, 7, 0, 0},
175 { 8, 8, 0, 0},
176 { 9, 9, 0, 0},
177 { 10, 10, 0, 0},
178 { 11, 11, 0, 0},
179 { 12, 12, 0, 0},
180 { 13, 13, 0, 0},
181 { 14, 14, 0, 0},
182 { 15, 15, 0, 0},
183 { 16, 16, 0, 0},
184 { 17, 17, 0, 0},
185 { 18, 18, 0, 0},
186 { 19, 19, 0, 0},
187 { 20, 20, 0, 0},
188 { 21, 21, 0, 0},
189 { 22, 22, 0, 0},
190 { 23, 23, 0, 0},
191 { 24, 24, 0, 0},
192 { 25, 25, 0, 0},
193 { 26, 26, 0, 0},
194 { 27, 27, 0, 0},
195 { 28, 28, 0, 0},
196 { 29, 5, 1, 0},
197 { 30, 6, 1, 0},
198 { 31, 7, 1, 0},
199 { 32, 8, 1, 0},
200 { 33, 9, 1, 0},
201 { 34, 10, 1, 0},
202 { 35, 11, 1, 0},
203 { 36, 12, 1, 0},
204 { 37, 13, 1, 0},
205 { 38, 14, 1, 0},
206 { 39, 15, 1, 0},
207 { 40, 16, 1, 0},
208 { 41, 17, 1, 0},
209 { 42, 18, 1, 0},
210 { 43, 19, 1, 0},
211 { 44, 20, 1, 0},
212 { 45, 21, 1, 0},
213 { 46, 22, 1, 0},
214 { 47, 23, 1, 0},
215 { 48, 24, 1, 0},
216 { 49, 25, 1, 0},
217 { 50, 26, 1, 0},
218 { 51, 27, 1, 0},
219 { 52, 28, 1, 0},
220 { 53, 29, 1, 0},
221 { 54, 30, 1, 0},
222 { 55, 31, 1, 0},
223 { 56, 32, 1, 0},
224 { 57, 33, 1, 0},
225 { 58, 34, 1, 0},
226 { 59, 35, 1, 0},
227 { 60, 36, 1, 0},
228 { 61, 37, 1, 0},
229 { 62, 38, 1, 0},
230 { 63, 39, 1, 0},
231 { 64, 40, 1, 0},
232 { 65, 41, 1, 0},
233 { 66, 42, 1, 0},
234 { 67, 43, 1, 0},
235 { 68, 44, 1, 0},
236 { 69, 45, 1, 0},
237 { 70, 46, 1, 0},
238 { 71, 47, 1, 0},
239 { 72, 48, 1, 0},
240 { 73, 49, 1, 0},
241 { 74, 50, 1, 0},
242 { 75, 51, 1, 0},
243 { 76, 52, 1, 0},
244 { 77, 53, 1, 0},
245 { 78, 54, 1, 0},
246 { 79, 55, 1, 0},
247 { 80, 56, 1, 0},
248 { 81, 57, 1, 0},
249 { 82, 58, 1, 0},
250 { 83, 40, 1, 1},
251 { 84, 41, 1, 1},
252 { 85, 42, 1, 1},
253 { 86, 43, 1, 1},
254 { 87, 44, 1, 1},
255 { 88, 45, 1, 1},
256 { 89, 46, 1, 1},
257 { 90, 47, 1, 1},
258 { 91, 48, 1, 1},
259 { 92, 49, 1, 1},
260 { 93, 50, 1, 1},
261 { 94, 51, 1, 1},
262 { 95, 52, 1, 1},
263 { 96, 53, 1, 1},
264 { 97, 54, 1, 1},
265 { 98, 55, 1, 1},
266 { 99, 56, 1, 1},
267 {100, 57, 1, 1},
268 {101, 58, 1, 1},
269 {102, 59, 1, 1},
270};
271
272/* 420 – 1000 MHz band, lna 7dB, mixer 19dB */
273static const struct msi3101_gain msi3101_gain_lut_1000[] = {
274 { 0, 0, 0, 0},
275 { 1, 1, 0, 0},
276 { 2, 2, 0, 0},
277 { 3, 3, 0, 0},
278 { 4, 4, 0, 0},
279 { 5, 5, 0, 0},
280 { 6, 6, 0, 0},
281 { 7, 7, 0, 0},
282 { 8, 8, 0, 0},
283 { 9, 9, 0, 0},
284 { 10, 10, 0, 0},
285 { 11, 11, 0, 0},
286 { 12, 5, 1, 0},
287 { 13, 6, 1, 0},
288 { 14, 7, 1, 0},
289 { 15, 8, 1, 0},
290 { 16, 9, 1, 0},
291 { 17, 10, 1, 0},
292 { 18, 11, 1, 0},
293 { 19, 12, 1, 0},
294 { 20, 13, 1, 0},
295 { 21, 14, 1, 0},
296 { 22, 15, 1, 0},
297 { 23, 16, 1, 0},
298 { 24, 17, 1, 0},
299 { 25, 18, 1, 0},
300 { 26, 19, 1, 0},
301 { 27, 20, 1, 0},
302 { 28, 21, 1, 0},
303 { 29, 22, 1, 0},
304 { 30, 23, 1, 0},
305 { 31, 24, 1, 0},
306 { 32, 25, 1, 0},
307 { 33, 26, 1, 0},
308 { 34, 27, 1, 0},
309 { 35, 28, 1, 0},
310 { 36, 29, 1, 0},
311 { 37, 30, 1, 0},
312 { 38, 31, 1, 0},
313 { 39, 32, 1, 0},
314 { 40, 33, 1, 0},
315 { 41, 34, 1, 0},
316 { 42, 35, 1, 0},
317 { 43, 36, 1, 0},
318 { 44, 37, 1, 0},
319 { 45, 38, 1, 0},
320 { 46, 39, 1, 0},
321 { 47, 40, 1, 0},
322 { 48, 41, 1, 0},
323 { 49, 42, 1, 0},
324 { 50, 43, 1, 0},
325 { 51, 44, 1, 0},
326 { 52, 45, 1, 0},
327 { 53, 46, 1, 0},
328 { 54, 47, 1, 0},
329 { 55, 48, 1, 0},
330 { 56, 49, 1, 0},
331 { 57, 50, 1, 0},
332 { 58, 51, 1, 0},
333 { 59, 52, 1, 0},
334 { 60, 53, 1, 0},
335 { 61, 54, 1, 0},
336 { 62, 55, 1, 0},
337 { 63, 56, 1, 0},
338 { 64, 57, 1, 0},
339 { 65, 58, 1, 0},
340 { 66, 40, 1, 1},
341 { 67, 41, 1, 1},
342 { 68, 42, 1, 1},
343 { 69, 43, 1, 1},
344 { 70, 44, 1, 1},
345 { 71, 45, 1, 1},
346 { 72, 46, 1, 1},
347 { 73, 47, 1, 1},
348 { 74, 48, 1, 1},
349 { 75, 49, 1, 1},
350 { 76, 50, 1, 1},
351 { 77, 51, 1, 1},
352 { 78, 52, 1, 1},
353 { 79, 53, 1, 1},
354 { 80, 54, 1, 1},
355 { 81, 55, 1, 1},
356 { 82, 56, 1, 1},
357 { 83, 57, 1, 1},
358 { 84, 58, 1, 1},
359 { 85, 59, 1, 1},
360};
361 36
362/* 37/*
363 * iConfiguration 0 38 * iConfiguration 0
@@ -377,13 +52,54 @@ static const struct msi3101_gain msi3101_gain_lut_1000[] = {
377#define MAX_ISOC_ERRORS 20 52#define MAX_ISOC_ERRORS 20
378 53
379/* TODO: These should be moved to V4L2 API */ 54/* TODO: These should be moved to V4L2 API */
380#define MSI3101_CID_SAMPLING_MODE ((V4L2_CID_USER_BASE | 0xf000) + 0) 55#define V4L2_PIX_FMT_SDR_S8 v4l2_fourcc('D', 'S', '0', '8') /* signed 8-bit */
381#define MSI3101_CID_SAMPLING_RATE ((V4L2_CID_USER_BASE | 0xf000) + 1) 56#define V4L2_PIX_FMT_SDR_S12 v4l2_fourcc('D', 'S', '1', '2') /* signed 12-bit */
382#define MSI3101_CID_SAMPLING_RESOLUTION ((V4L2_CID_USER_BASE | 0xf000) + 2) 57#define V4L2_PIX_FMT_SDR_S14 v4l2_fourcc('D', 'S', '1', '4') /* signed 14-bit */
383#define MSI3101_CID_TUNER_RF ((V4L2_CID_USER_BASE | 0xf000) + 10) 58#define V4L2_PIX_FMT_SDR_MSI2500_384 v4l2_fourcc('M', '3', '8', '4') /* Mirics MSi2500 format 384 */
384#define MSI3101_CID_TUNER_BW ((V4L2_CID_USER_BASE | 0xf000) + 11) 59
385#define MSI3101_CID_TUNER_IF ((V4L2_CID_USER_BASE | 0xf000) + 12) 60static const struct v4l2_frequency_band bands[] = {
386#define MSI3101_CID_TUNER_GAIN ((V4L2_CID_USER_BASE | 0xf000) + 13) 61 {
62 .tuner = 0,
63 .type = V4L2_TUNER_ADC,
64 .index = 0,
65 .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
66 .rangelow = 1200000,
67 .rangehigh = 15000000,
68 },
69};
70
71/* stream formats */
72struct msi3101_format {
73 char *name;
74 u32 pixelformat;
75};
76
77/* format descriptions for capture and preview */
78static struct msi3101_format formats[] = {
79 {
80 .name = "IQ U8",
81 .pixelformat = V4L2_SDR_FMT_CU8,
82 }, {
83 .name = "IQ U16LE",
84 .pixelformat = V4L2_SDR_FMT_CU16LE,
85#if 0
86 }, {
87 .name = "8-bit signed",
88 .pixelformat = V4L2_PIX_FMT_SDR_S8,
89 }, {
90 .name = "10+2-bit signed",
91 .pixelformat = V4L2_PIX_FMT_SDR_MSI2500_384,
92 }, {
93 .name = "12-bit signed",
94 .pixelformat = V4L2_PIX_FMT_SDR_S12,
95 }, {
96 .name = "14-bit signed",
97 .pixelformat = V4L2_PIX_FMT_SDR_S14,
98#endif
99 },
100};
101
102static const unsigned int NUM_FORMATS = ARRAY_SIZE(formats);
387 103
388/* intermediate buffers with raw data from the USB device */ 104/* intermediate buffers with raw data from the USB device */
389struct msi3101_frame_buf { 105struct msi3101_frame_buf {
@@ -394,6 +110,8 @@ struct msi3101_frame_buf {
394struct msi3101_state { 110struct msi3101_state {
395 struct video_device vdev; 111 struct video_device vdev;
396 struct v4l2_device v4l2_dev; 112 struct v4l2_device v4l2_dev;
113 struct v4l2_subdev *v4l2_subdev;
114 struct spi_master *master;
397 115
398 /* videobuf2 queue and queued buffers list */ 116 /* videobuf2 queue and queued buffers list */
399 struct vb2_queue vb_queue; 117 struct vb2_queue vb_queue;
@@ -407,24 +125,22 @@ struct msi3101_state {
407 /* Pointer to our usb_device, will be NULL after unplug */ 125 /* Pointer to our usb_device, will be NULL after unplug */
408 struct usb_device *udev; /* Both mutexes most be hold when setting! */ 126 struct usb_device *udev; /* Both mutexes most be hold when setting! */
409 127
128 unsigned int f_adc;
129 u32 pixelformat;
130
410 unsigned int isoc_errors; /* number of contiguous ISOC errors */ 131 unsigned int isoc_errors; /* number of contiguous ISOC errors */
411 unsigned int vb_full; /* vb is full and packets dropped */ 132 unsigned int vb_full; /* vb is full and packets dropped */
412 133
413 struct urb *urbs[MAX_ISO_BUFS]; 134 struct urb *urbs[MAX_ISO_BUFS];
414 int (*convert_stream)(struct msi3101_state *s, u32 *dst, u8 *src, 135 int (*convert_stream)(struct msi3101_state *s, u8 *dst, u8 *src,
415 unsigned int src_len); 136 unsigned int src_len);
416 137
417 /* Controls */ 138 /* Controls */
418 struct v4l2_ctrl_handler ctrl_handler; 139 struct v4l2_ctrl_handler hdl;
419 struct v4l2_ctrl *ctrl_sampling_rate;
420 struct v4l2_ctrl *ctrl_tuner_rf;
421 struct v4l2_ctrl *ctrl_tuner_bw;
422 struct v4l2_ctrl *ctrl_tuner_if;
423 struct v4l2_ctrl *ctrl_tuner_gain;
424 140
425 u32 next_sample; /* for track lost packets */ 141 u32 next_sample; /* for track lost packets */
426 u32 sample; /* for sample rate calc */ 142 u32 sample; /* for sample rate calc */
427 unsigned long jiffies; 143 unsigned long jiffies_next;
428 unsigned int sample_ctrl_bit[4]; 144 unsigned int sample_ctrl_bit[4];
429}; 145};
430 146
@@ -448,98 +164,79 @@ leave:
448 164
449/* 165/*
450 * +=========================================================================== 166 * +===========================================================================
451 * | 00-1023 | USB packet type '384' 167 * | 00-1023 | USB packet type '504'
452 * +=========================================================================== 168 * +===========================================================================
453 * | 00- 03 | sequence number of first sample in that USB packet 169 * | 00- 03 | sequence number of first sample in that USB packet
454 * +--------------------------------------------------------------------------- 170 * +---------------------------------------------------------------------------
455 * | 04- 15 | garbage 171 * | 04- 15 | garbage
456 * +--------------------------------------------------------------------------- 172 * +---------------------------------------------------------------------------
457 * | 16- 175 | samples 173 * | 16-1023 | samples
458 * +---------------------------------------------------------------------------
459 * | 176- 179 | control bits for previous samples
460 * +---------------------------------------------------------------------------
461 * | 180- 339 | samples
462 * +---------------------------------------------------------------------------
463 * | 340- 343 | control bits for previous samples
464 * +---------------------------------------------------------------------------
465 * | 344- 503 | samples
466 * +---------------------------------------------------------------------------
467 * | 504- 507 | control bits for previous samples
468 * +---------------------------------------------------------------------------
469 * | 508- 667 | samples
470 * +---------------------------------------------------------------------------
471 * | 668- 671 | control bits for previous samples
472 * +---------------------------------------------------------------------------
473 * | 672- 831 | samples
474 * +---------------------------------------------------------------------------
475 * | 832- 835 | control bits for previous samples
476 * +---------------------------------------------------------------------------
477 * | 836- 995 | samples
478 * +---------------------------------------------------------------------------
479 * | 996- 999 | control bits for previous samples
480 * +---------------------------------------------------------------------------
481 * | 1000-1023 | garbage
482 * +--------------------------------------------------------------------------- 174 * +---------------------------------------------------------------------------
483 * 175 * signed 8-bit sample
484 * Bytes 4 - 7 could have some meaning? 176 * 504 * 2 = 1008 samples
485 *
486 * Control bits for previous samples is 32-bit field, containing 16 x 2-bit
487 * numbers. This results one 2-bit number for 8 samples. It is likely used for
488 * for bit shifting sample by given bits, increasing actual sampling resolution.
489 * Number 2 (0b10) was never seen.
490 *
491 * 6 * 16 * 2 * 4 = 768 samples. 768 * 4 = 3072 bytes
492 */ 177 */
178static int msi3101_convert_stream_504(struct msi3101_state *s, u8 *dst,
179 u8 *src, unsigned int src_len)
180{
181 int i, i_max, dst_len = 0;
182 u32 sample_num[3];
493 183
494/* 184 /* There could be 1-3 1024 bytes URB frames */
495 * Integer to 32-bit IEEE floating point representation routine is taken 185 i_max = src_len / 1024;
496 * from Radeon R600 driver (drivers/gpu/drm/radeon/r600_blit_kms.c).
497 *
498 * TODO: Currently we do conversion here in Kernel, but in future that will
499 * be moved to the libv4l2 library as video format conversions are.
500 */
501#define I2F_FRAC_BITS 23
502#define I2F_MASK ((1 << I2F_FRAC_BITS) - 1)
503 186
504/* 187 for (i = 0; i < i_max; i++) {
505 * Converts signed 8-bit integer into 32-bit IEEE floating point 188 sample_num[i] = src[3] << 24 | src[2] << 16 | src[1] << 8 | src[0] << 0;
506 * representation. 189 if (i == 0 && s->next_sample != sample_num[0]) {
507 */ 190 dev_dbg_ratelimited(&s->udev->dev,
508static u32 msi3101_convert_sample_504(struct msi3101_state *s, u16 x) 191 "%d samples lost, %d %08x:%08x\n",
509{ 192 sample_num[0] - s->next_sample,
510 u32 msb, exponent, fraction, sign; 193 src_len, s->next_sample, sample_num[0]);
194 }
511 195
512 /* Zero is special */ 196 /*
513 if (!x) 197 * Dump all unknown 'garbage' data - maybe we will discover
514 return 0; 198 * someday if there is something rational...
199 */
200 dev_dbg_ratelimited(&s->udev->dev, "%*ph\n", 12, &src[4]);
515 201
516 /* Negative / positive value */ 202 /* 504 x I+Q samples */
517 if (x & (1 << 7)) { 203 src += 16;
518 x = -x; 204 memcpy(dst, src, 1008);
519 x &= 0x7f; /* result is 7 bit ... + sign */ 205 src += 1008;
520 sign = 1 << 31; 206 dst += 1008;
521 } else { 207 dst_len += 1008;
522 sign = 0 << 31;
523 } 208 }
524 209
525 /* Get location of the most significant bit */ 210 /* calculate samping rate and output it in 10 seconds intervals */
526 msb = __fls(x); 211 if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
212 unsigned long jiffies_now = jiffies;
213 unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
214 unsigned int samples = sample_num[i_max - 1] - s->sample;
215 s->jiffies_next = jiffies_now;
216 s->sample = sample_num[i_max - 1];
217 dev_dbg(&s->udev->dev,
218 "slen=%d samples=%u msecs=%lu sampling rate=%lu\n",
219 src_len, samples, msecs,
220 samples * 1000UL / msecs);
221 }
527 222
528 fraction = ror32(x, (msb - I2F_FRAC_BITS) & 0x1f) & I2F_MASK; 223 /* next sample (sample = sample + i * 504) */
529 exponent = (127 + msb) << I2F_FRAC_BITS; 224 s->next_sample = sample_num[i_max - 1] + 504;
530 225
531 return (fraction + exponent) | sign; 226 return dst_len;
532} 227}
533 228
534static int msi3101_convert_stream_504(struct msi3101_state *s, u32 *dst, 229static int msi3101_convert_stream_504_u8(struct msi3101_state *s, u8 *dst,
535 u8 *src, unsigned int src_len) 230 u8 *src, unsigned int src_len)
536{ 231{
537 int i, j, i_max, dst_len = 0; 232 int i, j, i_max, dst_len = 0;
538 u16 sample[2];
539 u32 sample_num[3]; 233 u32 sample_num[3];
234 s8 *s8src;
235 u8 *u8dst;
540 236
541 /* There could be 1-3 1024 bytes URB frames */ 237 /* There could be 1-3 1024 bytes URB frames */
542 i_max = src_len / 1024; 238 i_max = src_len / 1024;
239 u8dst = (u8 *) dst;
543 240
544 for (i = 0; i < i_max; i++) { 241 for (i = 0; i < i_max; i++) {
545 sample_num[i] = src[3] << 24 | src[2] << 16 | src[1] << 8 | src[0] << 0; 242 sample_num[i] = src[3] << 24 | src[2] << 16 | src[1] << 8 | src[0] << 0;
@@ -556,30 +253,28 @@ static int msi3101_convert_stream_504(struct msi3101_state *s, u32 *dst,
556 */ 253 */
557 dev_dbg_ratelimited(&s->udev->dev, "%*ph\n", 12, &src[4]); 254 dev_dbg_ratelimited(&s->udev->dev, "%*ph\n", 12, &src[4]);
558 255
256 /* 504 x I+Q samples */
559 src += 16; 257 src += 16;
560 for (j = 0; j < 1008; j += 2) {
561 sample[0] = src[j + 0];
562 sample[1] = src[j + 1];
563 258
564 *dst++ = msi3101_convert_sample_504(s, sample[0]); 259 s8src = (s8 *) src;
565 *dst++ = msi3101_convert_sample_504(s, sample[1]); 260 for (j = 0; j < 1008; j++)
566 } 261 *u8dst++ = *s8src++ + 128;
567 /* 504 x I+Q 32bit float samples */ 262
568 dst_len += 504 * 2 * 4;
569 src += 1008; 263 src += 1008;
264 dst += 1008;
265 dst_len += 1008;
570 } 266 }
571 267
572 /* calculate samping rate and output it in 10 seconds intervals */ 268 /* calculate samping rate and output it in 10 seconds intervals */
573 if ((s->jiffies + msecs_to_jiffies(10000)) <= jiffies) { 269 if (unlikely(time_is_before_jiffies(s->jiffies_next))) {
574 unsigned long jiffies_now = jiffies; 270#define MSECS 10000UL
575 unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies);
576 unsigned int samples = sample_num[i_max - 1] - s->sample; 271 unsigned int samples = sample_num[i_max - 1] - s->sample;
577 s->jiffies = jiffies_now; 272 s->jiffies_next = jiffies + msecs_to_jiffies(MSECS);
578 s->sample = sample_num[i_max - 1]; 273 s->sample = sample_num[i_max - 1];
579 dev_dbg(&s->udev->dev, 274 dev_dbg(&s->udev->dev,
580 "slen=%d samples=%u msecs=%lu sampling rate=%lu\n", 275 "slen=%d samples=%u msecs=%lu sampling rate=%lu\n",
581 src_len, samples, msecs, 276 src_len, samples, MSECS,
582 samples * 1000UL / msecs); 277 samples * 1000UL / MSECS);
583 } 278 }
584 279
585 /* next sample (sample = sample + i * 504) */ 280 /* next sample (sample = sample + i * 504) */
@@ -589,48 +284,53 @@ static int msi3101_convert_stream_504(struct msi3101_state *s, u32 *dst,
589} 284}
590 285
591/* 286/*
592 * Converts signed ~10+2-bit integer into 32-bit IEEE floating point 287 * +===========================================================================
593 * representation. 288 * | 00-1023 | USB packet type '384'
289 * +===========================================================================
290 * | 00- 03 | sequence number of first sample in that USB packet
291 * +---------------------------------------------------------------------------
292 * | 04- 15 | garbage
293 * +---------------------------------------------------------------------------
294 * | 16- 175 | samples
295 * +---------------------------------------------------------------------------
296 * | 176- 179 | control bits for previous samples
297 * +---------------------------------------------------------------------------
298 * | 180- 339 | samples
299 * +---------------------------------------------------------------------------
300 * | 340- 343 | control bits for previous samples
301 * +---------------------------------------------------------------------------
302 * | 344- 503 | samples
303 * +---------------------------------------------------------------------------
304 * | 504- 507 | control bits for previous samples
305 * +---------------------------------------------------------------------------
306 * | 508- 667 | samples
307 * +---------------------------------------------------------------------------
308 * | 668- 671 | control bits for previous samples
309 * +---------------------------------------------------------------------------
310 * | 672- 831 | samples
311 * +---------------------------------------------------------------------------
312 * | 832- 835 | control bits for previous samples
313 * +---------------------------------------------------------------------------
314 * | 836- 995 | samples
315 * +---------------------------------------------------------------------------
316 * | 996- 999 | control bits for previous samples
317 * +---------------------------------------------------------------------------
318 * | 1000-1023 | garbage
319 * +---------------------------------------------------------------------------
320 *
321 * Bytes 4 - 7 could have some meaning?
322 *
323 * Control bits for previous samples is 32-bit field, containing 16 x 2-bit
324 * numbers. This results one 2-bit number for 8 samples. It is likely used for
325 * for bit shifting sample by given bits, increasing actual sampling resolution.
326 * Number 2 (0b10) was never seen.
327 *
328 * 6 * 16 * 2 * 4 = 768 samples. 768 * 4 = 3072 bytes
594 */ 329 */
595static u32 msi3101_convert_sample_384(struct msi3101_state *s, u16 x, int shift) 330static int msi3101_convert_stream_384(struct msi3101_state *s, u8 *dst,
596{
597 u32 msb, exponent, fraction, sign;
598 s->sample_ctrl_bit[shift]++;
599
600 /* Zero is special */
601 if (!x)
602 return 0;
603
604 if (shift == 3)
605 shift = 2;
606
607 /* Convert 10-bit two's complement to 12-bit */
608 if (x & (1 << 9)) {
609 x |= ~0U << 10; /* set all the rest bits to one */
610 x <<= shift;
611 x = -x;
612 x &= 0x7ff; /* result is 11 bit ... + sign */
613 sign = 1 << 31;
614 } else {
615 x <<= shift;
616 sign = 0 << 31;
617 }
618
619 /* Get location of the most significant bit */
620 msb = __fls(x);
621
622 fraction = ror32(x, (msb - I2F_FRAC_BITS) & 0x1f) & I2F_MASK;
623 exponent = (127 + msb) << I2F_FRAC_BITS;
624
625 return (fraction + exponent) | sign;
626}
627
628static int msi3101_convert_stream_384(struct msi3101_state *s, u32 *dst,
629 u8 *src, unsigned int src_len) 331 u8 *src, unsigned int src_len)
630{ 332{
631 int i, j, k, l, i_max, dst_len = 0; 333 int i, i_max, dst_len = 0;
632 u16 sample[4];
633 u32 bits;
634 u32 sample_num[3]; 334 u32 sample_num[3];
635 335
636 /* There could be 1-3 1024 bytes URB frames */ 336 /* There could be 1-3 1024 bytes URB frames */
@@ -651,38 +351,20 @@ static int msi3101_convert_stream_384(struct msi3101_state *s, u32 *dst,
651 dev_dbg_ratelimited(&s->udev->dev, 351 dev_dbg_ratelimited(&s->udev->dev,
652 "%*ph %*ph\n", 12, &src[4], 24, &src[1000]); 352 "%*ph %*ph\n", 12, &src[4], 24, &src[1000]);
653 353
354 /* 384 x I+Q samples */
654 src += 16; 355 src += 16;
655 for (j = 0; j < 6; j++) { 356 memcpy(dst, src, 984);
656 bits = src[160 + 3] << 24 | src[160 + 2] << 16 | src[160 + 1] << 8 | src[160 + 0] << 0; 357 src += 984 + 24;
657 for (k = 0; k < 16; k++) { 358 dst += 984;
658 for (l = 0; l < 10; l += 5) { 359 dst_len += 984;
659 sample[0] = (src[l + 0] & 0xff) >> 0 | (src[l + 1] & 0x03) << 8;
660 sample[1] = (src[l + 1] & 0xfc) >> 2 | (src[l + 2] & 0x0f) << 6;
661 sample[2] = (src[l + 2] & 0xf0) >> 4 | (src[l + 3] & 0x3f) << 4;
662 sample[3] = (src[l + 3] & 0xc0) >> 6 | (src[l + 4] & 0xff) << 2;
663
664 *dst++ = msi3101_convert_sample_384(s, sample[0], (bits >> (2 * k)) & 0x3);
665 *dst++ = msi3101_convert_sample_384(s, sample[1], (bits >> (2 * k)) & 0x3);
666 *dst++ = msi3101_convert_sample_384(s, sample[2], (bits >> (2 * k)) & 0x3);
667 *dst++ = msi3101_convert_sample_384(s, sample[3], (bits >> (2 * k)) & 0x3);
668 }
669 src += 10;
670 }
671 dev_dbg_ratelimited(&s->udev->dev,
672 "sample control bits %08x\n", bits);
673 src += 4;
674 }
675 /* 384 x I+Q 32bit float samples */
676 dst_len += 384 * 2 * 4;
677 src += 24;
678 } 360 }
679 361
680 /* calculate samping rate and output it in 10 seconds intervals */ 362 /* calculate samping rate and output it in 10 seconds intervals */
681 if ((s->jiffies + msecs_to_jiffies(10000)) <= jiffies) { 363 if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
682 unsigned long jiffies_now = jiffies; 364 unsigned long jiffies_now = jiffies;
683 unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies); 365 unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
684 unsigned int samples = sample_num[i_max - 1] - s->sample; 366 unsigned int samples = sample_num[i_max - 1] - s->sample;
685 s->jiffies = jiffies_now; 367 s->jiffies_next = jiffies_now;
686 s->sample = sample_num[i_max - 1]; 368 s->sample = sample_num[i_max - 1];
687 dev_dbg(&s->udev->dev, 369 dev_dbg(&s->udev->dev,
688 "slen=%d samples=%u msecs=%lu sampling rate=%lu bits=%d.%d.%d.%d\n", 370 "slen=%d samples=%u msecs=%lu sampling rate=%lu bits=%d.%d.%d.%d\n",
@@ -699,40 +381,21 @@ static int msi3101_convert_stream_384(struct msi3101_state *s, u32 *dst,
699} 381}
700 382
701/* 383/*
702 * Converts signed 12-bit integer into 32-bit IEEE floating point 384 * +===========================================================================
703 * representation. 385 * | 00-1023 | USB packet type '336'
386 * +===========================================================================
387 * | 00- 03 | sequence number of first sample in that USB packet
388 * +---------------------------------------------------------------------------
389 * | 04- 15 | garbage
390 * +---------------------------------------------------------------------------
391 * | 16-1023 | samples
392 * +---------------------------------------------------------------------------
393 * signed 12-bit sample
704 */ 394 */
705static u32 msi3101_convert_sample_336(struct msi3101_state *s, u16 x) 395static int msi3101_convert_stream_336(struct msi3101_state *s, u8 *dst,
706{
707 u32 msb, exponent, fraction, sign;
708
709 /* Zero is special */
710 if (!x)
711 return 0;
712
713 /* Negative / positive value */
714 if (x & (1 << 11)) {
715 x = -x;
716 x &= 0x7ff; /* result is 11 bit ... + sign */
717 sign = 1 << 31;
718 } else {
719 sign = 0 << 31;
720 }
721
722 /* Get location of the most significant bit */
723 msb = __fls(x);
724
725 fraction = ror32(x, (msb - I2F_FRAC_BITS) & 0x1f) & I2F_MASK;
726 exponent = (127 + msb) << I2F_FRAC_BITS;
727
728 return (fraction + exponent) | sign;
729}
730
731static int msi3101_convert_stream_336(struct msi3101_state *s, u32 *dst,
732 u8 *src, unsigned int src_len) 396 u8 *src, unsigned int src_len)
733{ 397{
734 int i, j, i_max, dst_len = 0; 398 int i, i_max, dst_len = 0;
735 u16 sample[2];
736 u32 sample_num[3]; 399 u32 sample_num[3];
737 400
738 /* There could be 1-3 1024 bytes URB frames */ 401 /* There could be 1-3 1024 bytes URB frames */
@@ -753,25 +416,20 @@ static int msi3101_convert_stream_336(struct msi3101_state *s, u32 *dst,
753 */ 416 */
754 dev_dbg_ratelimited(&s->udev->dev, "%*ph\n", 12, &src[4]); 417 dev_dbg_ratelimited(&s->udev->dev, "%*ph\n", 12, &src[4]);
755 418
419 /* 336 x I+Q samples */
756 src += 16; 420 src += 16;
757 for (j = 0; j < 1008; j += 3) { 421 memcpy(dst, src, 1008);
758 sample[0] = (src[j + 0] & 0xff) >> 0 | (src[j + 1] & 0x0f) << 8;
759 sample[1] = (src[j + 1] & 0xf0) >> 4 | (src[j + 2] & 0xff) << 4;
760
761 *dst++ = msi3101_convert_sample_336(s, sample[0]);
762 *dst++ = msi3101_convert_sample_336(s, sample[1]);
763 }
764 /* 336 x I+Q 32bit float samples */
765 dst_len += 336 * 2 * 4;
766 src += 1008; 422 src += 1008;
423 dst += 1008;
424 dst_len += 1008;
767 } 425 }
768 426
769 /* calculate samping rate and output it in 10 seconds intervals */ 427 /* calculate samping rate and output it in 10 seconds intervals */
770 if ((s->jiffies + msecs_to_jiffies(10000)) <= jiffies) { 428 if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
771 unsigned long jiffies_now = jiffies; 429 unsigned long jiffies_now = jiffies;
772 unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies); 430 unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
773 unsigned int samples = sample_num[i_max - 1] - s->sample; 431 unsigned int samples = sample_num[i_max - 1] - s->sample;
774 s->jiffies = jiffies_now; 432 s->jiffies_next = jiffies_now;
775 s->sample = sample_num[i_max - 1]; 433 s->sample = sample_num[i_max - 1];
776 dev_dbg(&s->udev->dev, 434 dev_dbg(&s->udev->dev,
777 "slen=%d samples=%u msecs=%lu sampling rate=%lu\n", 435 "slen=%d samples=%u msecs=%lu sampling rate=%lu\n",
@@ -786,41 +444,75 @@ static int msi3101_convert_stream_336(struct msi3101_state *s, u32 *dst,
786} 444}
787 445
788/* 446/*
789 * Converts signed 14-bit integer into 32-bit IEEE floating point 447 * +===========================================================================
790 * representation. 448 * | 00-1023 | USB packet type '252'
449 * +===========================================================================
450 * | 00- 03 | sequence number of first sample in that USB packet
451 * +---------------------------------------------------------------------------
452 * | 04- 15 | garbage
453 * +---------------------------------------------------------------------------
454 * | 16-1023 | samples
455 * +---------------------------------------------------------------------------
456 * signed 14-bit sample
791 */ 457 */
792static u32 msi3101_convert_sample_252(struct msi3101_state *s, u16 x) 458static int msi3101_convert_stream_252(struct msi3101_state *s, u8 *dst,
459 u8 *src, unsigned int src_len)
793{ 460{
794 u32 msb, exponent, fraction, sign; 461 int i, i_max, dst_len = 0;
462 u32 sample_num[3];
795 463
796 /* Zero is special */ 464 /* There could be 1-3 1024 bytes URB frames */
797 if (!x) 465 i_max = src_len / 1024;
798 return 0;
799 466
800 /* Negative / positive value */ 467 for (i = 0; i < i_max; i++) {
801 if (x & (1 << 13)) { 468 sample_num[i] = src[3] << 24 | src[2] << 16 | src[1] << 8 | src[0] << 0;
802 x = -x; 469 if (i == 0 && s->next_sample != sample_num[0]) {
803 x &= 0x1fff; /* result is 13 bit ... + sign */ 470 dev_dbg_ratelimited(&s->udev->dev,
804 sign = 1 << 31; 471 "%d samples lost, %d %08x:%08x\n",
805 } else { 472 sample_num[0] - s->next_sample,
806 sign = 0 << 31; 473 src_len, s->next_sample, sample_num[0]);
474 }
475
476 /*
477 * Dump all unknown 'garbage' data - maybe we will discover
478 * someday if there is something rational...
479 */
480 dev_dbg_ratelimited(&s->udev->dev, "%*ph\n", 12, &src[4]);
481
482 /* 252 x I+Q samples */
483 src += 16;
484 memcpy(dst, src, 1008);
485 src += 1008;
486 dst += 1008;
487 dst_len += 1008;
807 } 488 }
808 489
809 /* Get location of the most significant bit */ 490 /* calculate samping rate and output it in 10 seconds intervals */
810 msb = __fls(x); 491 if ((s->jiffies_next + msecs_to_jiffies(10000)) <= jiffies) {
492 unsigned long jiffies_now = jiffies;
493 unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies_next);
494 unsigned int samples = sample_num[i_max - 1] - s->sample;
495 s->jiffies_next = jiffies_now;
496 s->sample = sample_num[i_max - 1];
497 dev_dbg(&s->udev->dev,
498 "slen=%d samples=%u msecs=%lu sampling rate=%lu\n",
499 src_len, samples, msecs,
500 samples * 1000UL / msecs);
501 }
811 502
812 fraction = ror32(x, (msb - I2F_FRAC_BITS) & 0x1f) & I2F_MASK; 503 /* next sample (sample = sample + i * 252) */
813 exponent = (127 + msb) << I2F_FRAC_BITS; 504 s->next_sample = sample_num[i_max - 1] + 252;
814 505
815 return (fraction + exponent) | sign; 506 return dst_len;
816} 507}
817 508
818static int msi3101_convert_stream_252(struct msi3101_state *s, u32 *dst, 509static int msi3101_convert_stream_252_u16(struct msi3101_state *s, u8 *dst,
819 u8 *src, unsigned int src_len) 510 u8 *src, unsigned int src_len)
820{ 511{
821 int i, j, i_max, dst_len = 0; 512 int i, j, i_max, dst_len = 0;
822 u16 sample[2];
823 u32 sample_num[3]; 513 u32 sample_num[3];
514 u16 *u16dst = (u16 *) dst;
515 struct {signed int x:14;} se;
824 516
825 /* There could be 1-3 1024 bytes URB frames */ 517 /* There could be 1-3 1024 bytes URB frames */
826 i_max = src_len / 1024; 518 i_max = src_len / 1024;
@@ -840,30 +532,44 @@ static int msi3101_convert_stream_252(struct msi3101_state *s, u32 *dst,
840 */ 532 */
841 dev_dbg_ratelimited(&s->udev->dev, "%*ph\n", 12, &src[4]); 533 dev_dbg_ratelimited(&s->udev->dev, "%*ph\n", 12, &src[4]);
842 534
535 /* 252 x I+Q samples */
843 src += 16; 536 src += 16;
537
844 for (j = 0; j < 1008; j += 4) { 538 for (j = 0; j < 1008; j += 4) {
845 sample[0] = src[j + 0] >> 0 | src[j + 1] << 8; 539 unsigned int usample[2];
846 sample[1] = src[j + 2] >> 0 | src[j + 3] << 8; 540 int ssample[2];
541
542 usample[0] = src[j + 0] >> 0 | src[j + 1] << 8;
543 usample[1] = src[j + 2] >> 0 | src[j + 3] << 8;
847 544
848 *dst++ = msi3101_convert_sample_252(s, sample[0]); 545 /* sign extension from 14-bit to signed int */
849 *dst++ = msi3101_convert_sample_252(s, sample[1]); 546 ssample[0] = se.x = usample[0];
547 ssample[1] = se.x = usample[1];
548
549 /* from signed to unsigned */
550 usample[0] = ssample[0] + 8192;
551 usample[1] = ssample[1] + 8192;
552
553 /* from 14-bit to 16-bit */
554 *u16dst++ = (usample[0] << 2) | (usample[0] >> 12);
555 *u16dst++ = (usample[1] << 2) | (usample[1] >> 12);
850 } 556 }
851 /* 252 x I+Q 32bit float samples */ 557
852 dst_len += 252 * 2 * 4;
853 src += 1008; 558 src += 1008;
559 dst += 1008;
560 dst_len += 1008;
854 } 561 }
855 562
856 /* calculate samping rate and output it in 10 seconds intervals */ 563 /* calculate samping rate and output it in 10 seconds intervals */
857 if ((s->jiffies + msecs_to_jiffies(10000)) <= jiffies) { 564 if (unlikely(time_is_before_jiffies(s->jiffies_next))) {
858 unsigned long jiffies_now = jiffies; 565#define MSECS 10000UL
859 unsigned long msecs = jiffies_to_msecs(jiffies_now) - jiffies_to_msecs(s->jiffies);
860 unsigned int samples = sample_num[i_max - 1] - s->sample; 566 unsigned int samples = sample_num[i_max - 1] - s->sample;
861 s->jiffies = jiffies_now; 567 s->jiffies_next = jiffies + msecs_to_jiffies(MSECS);
862 s->sample = sample_num[i_max - 1]; 568 s->sample = sample_num[i_max - 1];
863 dev_dbg(&s->udev->dev, 569 dev_dbg(&s->udev->dev,
864 "slen=%d samples=%u msecs=%lu sampling rate=%lu\n", 570 "slen=%d samples=%u msecs=%lu sampling rate=%lu\n",
865 src_len, samples, msecs, 571 src_len, samples, MSECS,
866 samples * 1000UL / msecs); 572 samples * 1000UL / MSECS);
867 } 573 }
868 574
869 /* next sample (sample = sample + i * 252) */ 575 /* next sample (sample = sample + i * 252) */
@@ -883,14 +589,14 @@ static void msi3101_isoc_handler(struct urb *urb)
883 unsigned char *iso_buf = NULL; 589 unsigned char *iso_buf = NULL;
884 struct msi3101_frame_buf *fbuf; 590 struct msi3101_frame_buf *fbuf;
885 591
886 if (urb->status == -ENOENT || urb->status == -ECONNRESET || 592 if (unlikely(urb->status == -ENOENT || urb->status == -ECONNRESET ||
887 urb->status == -ESHUTDOWN) { 593 urb->status == -ESHUTDOWN)) {
888 dev_dbg(&s->udev->dev, "URB (%p) unlinked %ssynchronuously\n", 594 dev_dbg(&s->udev->dev, "URB (%p) unlinked %ssynchronuously\n",
889 urb, urb->status == -ENOENT ? "" : "a"); 595 urb, urb->status == -ENOENT ? "" : "a");
890 return; 596 return;
891 } 597 }
892 598
893 if (urb->status != 0) { 599 if (unlikely(urb->status != 0)) {
894 dev_dbg(&s->udev->dev, 600 dev_dbg(&s->udev->dev,
895 "msi3101_isoc_handler() called with status %d\n", 601 "msi3101_isoc_handler() called with status %d\n",
896 urb->status); 602 urb->status);
@@ -910,28 +616,28 @@ static void msi3101_isoc_handler(struct urb *urb)
910 616
911 /* Check frame error */ 617 /* Check frame error */
912 fstatus = urb->iso_frame_desc[i].status; 618 fstatus = urb->iso_frame_desc[i].status;
913 if (fstatus) { 619 if (unlikely(fstatus)) {
914 dev_dbg_ratelimited(&s->udev->dev, 620 dev_dbg_ratelimited(&s->udev->dev,
915 "frame=%d/%d has error %d skipping\n", 621 "frame=%d/%d has error %d skipping\n",
916 i, urb->number_of_packets, fstatus); 622 i, urb->number_of_packets, fstatus);
917 goto skip; 623 continue;
918 } 624 }
919 625
920 /* Check if that frame contains data */ 626 /* Check if that frame contains data */
921 flen = urb->iso_frame_desc[i].actual_length; 627 flen = urb->iso_frame_desc[i].actual_length;
922 if (flen == 0) 628 if (unlikely(flen == 0))
923 goto skip; 629 continue;
924 630
925 iso_buf = urb->transfer_buffer + urb->iso_frame_desc[i].offset; 631 iso_buf = urb->transfer_buffer + urb->iso_frame_desc[i].offset;
926 632
927 /* Get free framebuffer */ 633 /* Get free framebuffer */
928 fbuf = msi3101_get_next_fill_buf(s); 634 fbuf = msi3101_get_next_fill_buf(s);
929 if (fbuf == NULL) { 635 if (unlikely(fbuf == NULL)) {
930 s->vb_full++; 636 s->vb_full++;
931 dev_dbg_ratelimited(&s->udev->dev, 637 dev_dbg_ratelimited(&s->udev->dev,
932 "videobuf is full, %d packets dropped\n", 638 "videobuf is full, %d packets dropped\n",
933 s->vb_full); 639 s->vb_full);
934 goto skip; 640 continue;
935 } 641 }
936 642
937 /* fill framebuffer */ 643 /* fill framebuffer */
@@ -939,13 +645,11 @@ static void msi3101_isoc_handler(struct urb *urb)
939 flen = s->convert_stream(s, ptr, iso_buf, flen); 645 flen = s->convert_stream(s, ptr, iso_buf, flen);
940 vb2_set_plane_payload(&fbuf->vb, 0, flen); 646 vb2_set_plane_payload(&fbuf->vb, 0, flen);
941 vb2_buffer_done(&fbuf->vb, VB2_BUF_STATE_DONE); 647 vb2_buffer_done(&fbuf->vb, VB2_BUF_STATE_DONE);
942skip:
943 ;
944 } 648 }
945 649
946handler_end: 650handler_end:
947 i = usb_submit_urb(urb, GFP_ATOMIC); 651 i = usb_submit_urb(urb, GFP_ATOMIC);
948 if (i != 0) 652 if (unlikely(i != 0))
949 dev_dbg(&s->udev->dev, 653 dev_dbg(&s->udev->dev,
950 "Error (%d) re-submitting urb in msi3101_isoc_handler\n", 654 "Error (%d) re-submitting urb in msi3101_isoc_handler\n",
951 i); 655 i);
@@ -1008,7 +712,7 @@ static int msi3101_isoc_init(struct msi3101_state *s)
1008 udev = s->udev; 712 udev = s->udev;
1009 713
1010 ret = usb_set_interface(s->udev, 0, 1); 714 ret = usb_set_interface(s->udev, 0, 1);
1011 if (ret < 0) 715 if (ret)
1012 return ret; 716 return ret;
1013 717
1014 /* Allocate and init Isochronuous urbs */ 718 /* Allocate and init Isochronuous urbs */
@@ -1094,9 +798,9 @@ static void msi3101_disconnect(struct usb_interface *intf)
1094 mutex_lock(&s->v4l2_lock); 798 mutex_lock(&s->v4l2_lock);
1095 /* No need to keep the urbs around after disconnection */ 799 /* No need to keep the urbs around after disconnection */
1096 s->udev = NULL; 800 s->udev = NULL;
1097
1098 v4l2_device_disconnect(&s->v4l2_dev); 801 v4l2_device_disconnect(&s->v4l2_dev);
1099 video_unregister_device(&s->vdev); 802 video_unregister_device(&s->vdev);
803 spi_unregister_master(s->master);
1100 mutex_unlock(&s->v4l2_lock); 804 mutex_unlock(&s->v4l2_lock);
1101 mutex_unlock(&s->vb_queue_lock); 805 mutex_unlock(&s->vb_queue_lock);
1102 806
@@ -1112,14 +816,12 @@ static int msi3101_querycap(struct file *file, void *fh,
1112 strlcpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver)); 816 strlcpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
1113 strlcpy(cap->card, s->vdev.name, sizeof(cap->card)); 817 strlcpy(cap->card, s->vdev.name, sizeof(cap->card));
1114 usb_make_path(s->udev, cap->bus_info, sizeof(cap->bus_info)); 818 usb_make_path(s->udev, cap->bus_info, sizeof(cap->bus_info));
1115 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | 819 cap->device_caps = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_STREAMING |
1116 V4L2_CAP_READWRITE; 820 V4L2_CAP_READWRITE | V4L2_CAP_TUNER;
1117 cap->device_caps = V4L2_CAP_TUNER;
1118 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; 821 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
1119 return 0; 822 return 0;
1120} 823}
1121 824
1122
1123/* Videobuf2 operations */ 825/* Videobuf2 operations */
1124static int msi3101_queue_setup(struct vb2_queue *vq, 826static int msi3101_queue_setup(struct vb2_queue *vq,
1125 const struct v4l2_format *fmt, unsigned int *nbuffers, 827 const struct v4l2_format *fmt, unsigned int *nbuffers,
@@ -1129,31 +831,20 @@ static int msi3101_queue_setup(struct vb2_queue *vq,
1129 dev_dbg(&s->udev->dev, "%s: *nbuffers=%d\n", __func__, *nbuffers); 831 dev_dbg(&s->udev->dev, "%s: *nbuffers=%d\n", __func__, *nbuffers);
1130 832
1131 /* Absolute min and max number of buffers available for mmap() */ 833 /* Absolute min and max number of buffers available for mmap() */
1132 *nbuffers = 32; 834 *nbuffers = clamp_t(unsigned int, *nbuffers, 8, 32);
1133 *nplanes = 1; 835 *nplanes = 1;
1134 /* 836 /*
1135 * 3, wMaxPacketSize 3x 1024 bytes 837 * 3, wMaxPacketSize 3x 1024 bytes
1136 * 504, max IQ sample pairs per 1024 frame 838 * 504, max IQ sample pairs per 1024 frame
1137 * 2, two samples, I and Q 839 * 2, two samples, I and Q
1138 * 4, 32-bit float 840 * 2, 16-bit is enough for single sample
1139 */ 841 */
1140 sizes[0] = PAGE_ALIGN(3 * 504 * 2 * 4); /* = 12096 */ 842 sizes[0] = PAGE_ALIGN(3 * 504 * 2 * 2);
1141 dev_dbg(&s->udev->dev, "%s: nbuffers=%d sizes[0]=%d\n", 843 dev_dbg(&s->udev->dev, "%s: nbuffers=%d sizes[0]=%d\n",
1142 __func__, *nbuffers, sizes[0]); 844 __func__, *nbuffers, sizes[0]);
1143 return 0; 845 return 0;
1144} 846}
1145 847
1146static int msi3101_buf_prepare(struct vb2_buffer *vb)
1147{
1148 struct msi3101_state *s = vb2_get_drv_priv(vb->vb2_queue);
1149
1150 /* Don't allow queing new buffers after device disconnection */
1151 if (!s->udev)
1152 return -ENODEV;
1153
1154 return 0;
1155}
1156
1157static void msi3101_buf_queue(struct vb2_buffer *vb) 848static void msi3101_buf_queue(struct vb2_buffer *vb)
1158{ 849{
1159 struct msi3101_state *s = vb2_get_drv_priv(vb->vb2_queue); 850 struct msi3101_state *s = vb2_get_drv_priv(vb->vb2_queue);
@@ -1162,7 +853,7 @@ static void msi3101_buf_queue(struct vb2_buffer *vb)
1162 unsigned long flags = 0; 853 unsigned long flags = 0;
1163 854
1164 /* Check the device has not disconnected between prep and queuing */ 855 /* Check the device has not disconnected between prep and queuing */
1165 if (!s->udev) { 856 if (unlikely(!s->udev)) {
1166 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); 857 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
1167 return; 858 return;
1168 } 859 }
@@ -1209,41 +900,63 @@ static int msi3101_ctrl_msg(struct msi3101_state *s, u8 cmd, u32 data)
1209 return ret; 900 return ret;
1210}; 901};
1211 902
1212static int msi3101_tuner_write(struct msi3101_state *s, u32 data)
1213{
1214 return msi3101_ctrl_msg(s, CMD_WREG, data << 8 | 0x09);
1215};
1216
1217#define F_REF 24000000 903#define F_REF 24000000
1218#define DIV_R_IN 2 904#define DIV_R_IN 2
1219static int msi3101_set_usb_adc(struct msi3101_state *s) 905static int msi3101_set_usb_adc(struct msi3101_state *s)
1220{ 906{
1221 int ret, div_n, div_m, div_r_out, f_sr, f_vco, fract; 907 int ret, div_n, div_m, div_r_out, f_sr, f_vco, fract;
1222 u32 reg3, reg4, reg7; 908 u32 reg3, reg4, reg7;
909 struct v4l2_ctrl *bandwidth_auto;
910 struct v4l2_ctrl *bandwidth;
1223 911
1224 f_sr = s->ctrl_sampling_rate->val64; 912 f_sr = s->f_adc;
913
914 /* set tuner, subdev, filters according to sampling rate */
915 bandwidth_auto = v4l2_ctrl_find(&s->hdl, V4L2_CID_RF_TUNER_BANDWIDTH_AUTO);
916 bandwidth = v4l2_ctrl_find(&s->hdl, V4L2_CID_RF_TUNER_BANDWIDTH);
917 if (v4l2_ctrl_g_ctrl(bandwidth_auto)) {
918 bandwidth = v4l2_ctrl_find(&s->hdl, V4L2_CID_RF_TUNER_BANDWIDTH);
919 v4l2_ctrl_s_ctrl(bandwidth, s->f_adc);
920 }
1225 921
1226 /* select stream format */ 922 /* select stream format */
1227 if (f_sr < 6000000) { 923 switch (s->pixelformat) {
1228 s->convert_stream = msi3101_convert_stream_252; 924 case V4L2_SDR_FMT_CU8:
925 s->convert_stream = msi3101_convert_stream_504_u8;
926 reg7 = 0x000c9407;
927 break;
928 case V4L2_SDR_FMT_CU16LE:
929 s->convert_stream = msi3101_convert_stream_252_u16;
1229 reg7 = 0x00009407; 930 reg7 = 0x00009407;
1230 } else if (f_sr < 8000000) { 931 break;
1231 s->convert_stream = msi3101_convert_stream_336; 932 case V4L2_PIX_FMT_SDR_S8:
1232 reg7 = 0x00008507; 933 s->convert_stream = msi3101_convert_stream_504;
1233 } else if (f_sr < 9000000) { 934 reg7 = 0x000c9407;
935 break;
936 case V4L2_PIX_FMT_SDR_MSI2500_384:
1234 s->convert_stream = msi3101_convert_stream_384; 937 s->convert_stream = msi3101_convert_stream_384;
1235 reg7 = 0x0000a507; 938 reg7 = 0x0000a507;
1236 } else { 939 break;
1237 s->convert_stream = msi3101_convert_stream_504; 940 case V4L2_PIX_FMT_SDR_S12:
941 s->convert_stream = msi3101_convert_stream_336;
942 reg7 = 0x00008507;
943 break;
944 case V4L2_PIX_FMT_SDR_S14:
945 s->convert_stream = msi3101_convert_stream_252;
946 reg7 = 0x00009407;
947 break;
948 default:
949 s->convert_stream = msi3101_convert_stream_504_u8;
1238 reg7 = 0x000c9407; 950 reg7 = 0x000c9407;
951 break;
1239 } 952 }
1240 953
1241 /* 954 /*
1242 * Synthesizer config is just a educated guess... 955 * Synthesizer config is just a educated guess...
1243 * 956 *
1244 * [7:0] 0x03, register address 957 * [7:0] 0x03, register address
1245 * [8] 1, always 958 * [8] 1, power control
1246 * [9] ? 959 * [9] ?, power control
1247 * [12:10] output divider 960 * [12:10] output divider
1248 * [13] 0 ? 961 * [13] 0 ?
1249 * [14] 0 ? 962 * [14] 0 ?
@@ -1334,224 +1047,6 @@ err:
1334 return ret; 1047 return ret;
1335}; 1048};
1336 1049
1337static int msi3101_set_tuner(struct msi3101_state *s)
1338{
1339 int ret, i, len;
1340 unsigned int n, m, thresh, frac, vco_step, tmp, f_if1;
1341 u32 reg;
1342 u64 f_vco, tmp64;
1343 u8 mode, filter_mode, lo_div;
1344 const struct msi3101_gain *gain_lut;
1345 static const struct {
1346 u32 rf;
1347 u8 mode;
1348 u8 lo_div;
1349 } band_lut[] = {
1350 { 50000000, 0xe1, 16}, /* AM_MODE2, antenna 2 */
1351 {108000000, 0x42, 32}, /* VHF_MODE */
1352 {330000000, 0x44, 16}, /* B3_MODE */
1353 {960000000, 0x48, 4}, /* B45_MODE */
1354 { ~0U, 0x50, 2}, /* BL_MODE */
1355 };
1356 static const struct {
1357 u32 freq;
1358 u8 filter_mode;
1359 } if_freq_lut[] = {
1360 { 0, 0x03}, /* Zero IF */
1361 { 450000, 0x02}, /* 450 kHz IF */
1362 {1620000, 0x01}, /* 1.62 MHz IF */
1363 {2048000, 0x00}, /* 2.048 MHz IF */
1364 };
1365 static const struct {
1366 u32 freq;
1367 u8 val;
1368 } bandwidth_lut[] = {
1369 { 200000, 0x00}, /* 200 kHz */
1370 { 300000, 0x01}, /* 300 kHz */
1371 { 600000, 0x02}, /* 600 kHz */
1372 {1536000, 0x03}, /* 1.536 MHz */
1373 {5000000, 0x04}, /* 5 MHz */
1374 {6000000, 0x05}, /* 6 MHz */
1375 {7000000, 0x06}, /* 7 MHz */
1376 {8000000, 0x07}, /* 8 MHz */
1377 };
1378
1379 unsigned int f_rf = s->ctrl_tuner_rf->val64;
1380
1381 /*
1382 * bandwidth (Hz)
1383 * 200000, 300000, 600000, 1536000, 5000000, 6000000, 7000000, 8000000
1384 */
1385 unsigned int bandwidth = s->ctrl_tuner_bw->val;
1386
1387 /*
1388 * intermediate frequency (Hz)
1389 * 0, 450000, 1620000, 2048000
1390 */
1391 unsigned int f_if = s->ctrl_tuner_if->val;
1392
1393 /*
1394 * gain reduction (dB)
1395 * 0 - 102 below 420 MHz
1396 * 0 - 85 above 420 MHz
1397 */
1398 int gain = s->ctrl_tuner_gain->val;
1399
1400 dev_dbg(&s->udev->dev,
1401 "%s: f_rf=%d bandwidth=%d f_if=%d gain=%d\n",
1402 __func__, f_rf, bandwidth, f_if, gain);
1403
1404 ret = -EINVAL;
1405
1406 for (i = 0; i < ARRAY_SIZE(band_lut); i++) {
1407 if (f_rf <= band_lut[i].rf) {
1408 mode = band_lut[i].mode;
1409 lo_div = band_lut[i].lo_div;
1410 break;
1411 }
1412 }
1413
1414 if (i == ARRAY_SIZE(band_lut))
1415 goto err;
1416
1417 /* AM_MODE is upconverted */
1418 if ((mode >> 0) & 0x1)
1419 f_if1 = 5 * F_REF;
1420 else
1421 f_if1 = 0;
1422
1423 for (i = 0; i < ARRAY_SIZE(if_freq_lut); i++) {
1424 if (f_if == if_freq_lut[i].freq) {
1425 filter_mode = if_freq_lut[i].filter_mode;
1426 break;
1427 }
1428 }
1429
1430 if (i == ARRAY_SIZE(if_freq_lut))
1431 goto err;
1432
1433 for (i = 0; i < ARRAY_SIZE(bandwidth_lut); i++) {
1434 if (bandwidth == bandwidth_lut[i].freq) {
1435 bandwidth = bandwidth_lut[i].val;
1436 break;
1437 }
1438 }
1439
1440 if (i == ARRAY_SIZE(bandwidth_lut))
1441 goto err;
1442
1443#define F_OUT_STEP 1
1444#define R_REF 4
1445 f_vco = (f_rf + f_if + f_if1) * lo_div;
1446
1447 tmp64 = f_vco;
1448 m = do_div(tmp64, F_REF * R_REF);
1449 n = (unsigned int) tmp64;
1450
1451 vco_step = F_OUT_STEP * lo_div;
1452 thresh = (F_REF * R_REF) / vco_step;
1453 frac = 1ul * thresh * m / (F_REF * R_REF);
1454
1455 /* Find out greatest common divisor and divide to smaller. */
1456 tmp = gcd(thresh, frac);
1457 thresh /= tmp;
1458 frac /= tmp;
1459
1460 /* Force divide to reg max. Resolution will be reduced. */
1461 tmp = DIV_ROUND_UP(thresh, 4095);
1462 thresh = DIV_ROUND_CLOSEST(thresh, tmp);
1463 frac = DIV_ROUND_CLOSEST(frac, tmp);
1464
1465 /* calc real RF set */
1466 tmp = 1ul * F_REF * R_REF * n;
1467 tmp += 1ul * F_REF * R_REF * frac / thresh;
1468 tmp /= lo_div;
1469
1470 dev_dbg(&s->udev->dev,
1471 "%s: rf=%u:%u n=%d thresh=%d frac=%d\n",
1472 __func__, f_rf, tmp, n, thresh, frac);
1473
1474 ret = msi3101_tuner_write(s, 0x00000e);
1475 if (ret)
1476 goto err;
1477
1478 ret = msi3101_tuner_write(s, 0x000003);
1479 if (ret)
1480 goto err;
1481
1482 reg = 0 << 0;
1483 reg |= mode << 4;
1484 reg |= filter_mode << 12;
1485 reg |= bandwidth << 14;
1486 reg |= 0x02 << 17;
1487 reg |= 0x00 << 20;
1488 ret = msi3101_tuner_write(s, reg);
1489 if (ret)
1490 goto err;
1491
1492 reg = 5 << 0;
1493 reg |= thresh << 4;
1494 reg |= 1 << 19;
1495 reg |= 1 << 21;
1496 ret = msi3101_tuner_write(s, reg);
1497 if (ret)
1498 goto err;
1499
1500 reg = 2 << 0;
1501 reg |= frac << 4;
1502 reg |= n << 16;
1503 ret = msi3101_tuner_write(s, reg);
1504 if (ret)
1505 goto err;
1506
1507 if (f_rf < 120000000) {
1508 gain_lut = msi3101_gain_lut_120;
1509 len = ARRAY_SIZE(msi3101_gain_lut_120);
1510 } else if (f_rf < 245000000) {
1511 gain_lut = msi3101_gain_lut_245;
1512 len = ARRAY_SIZE(msi3101_gain_lut_120);
1513 } else {
1514 gain_lut = msi3101_gain_lut_1000;
1515 len = ARRAY_SIZE(msi3101_gain_lut_1000);
1516 }
1517
1518 for (i = 0; i < len; i++) {
1519 if (gain_lut[i].tot >= gain)
1520 break;
1521 }
1522
1523 if (i == len)
1524 goto err;
1525
1526 dev_dbg(&s->udev->dev,
1527 "%s: gain tot=%d baseband=%d lna=%d mixer=%d\n",
1528 __func__, gain_lut[i].tot, gain_lut[i].baseband,
1529 gain_lut[i].lna, gain_lut[i].mixer);
1530
1531 reg = 1 << 0;
1532 reg |= gain_lut[i].baseband << 4;
1533 reg |= 0 << 10;
1534 reg |= gain_lut[i].mixer << 12;
1535 reg |= gain_lut[i].lna << 13;
1536 reg |= 4 << 14;
1537 reg |= 0 << 17;
1538 ret = msi3101_tuner_write(s, reg);
1539 if (ret)
1540 goto err;
1541
1542 reg = 6 << 0;
1543 reg |= 63 << 4;
1544 reg |= 4095 << 10;
1545 ret = msi3101_tuner_write(s, reg);
1546 if (ret)
1547 goto err;
1548
1549 return 0;
1550err:
1551 dev_dbg(&s->udev->dev, "%s: failed %d\n", __func__, ret);
1552 return ret;
1553};
1554
1555static int msi3101_start_streaming(struct vb2_queue *vq, unsigned int count) 1050static int msi3101_start_streaming(struct vb2_queue *vq, unsigned int count)
1556{ 1051{
1557 struct msi3101_state *s = vb2_get_drv_priv(vq); 1052 struct msi3101_state *s = vb2_get_drv_priv(vq);
@@ -1564,6 +1059,9 @@ static int msi3101_start_streaming(struct vb2_queue *vq, unsigned int count)
1564 if (mutex_lock_interruptible(&s->v4l2_lock)) 1059 if (mutex_lock_interruptible(&s->v4l2_lock))
1565 return -ERESTARTSYS; 1060 return -ERESTARTSYS;
1566 1061
1062 /* wake-up tuner */
1063 v4l2_subdev_call(s->v4l2_subdev, core, s_power, 1);
1064
1567 ret = msi3101_set_usb_adc(s); 1065 ret = msi3101_set_usb_adc(s);
1568 1066
1569 ret = msi3101_isoc_init(s); 1067 ret = msi3101_isoc_init(s);
@@ -1594,6 +1092,12 @@ static int msi3101_stop_streaming(struct vb2_queue *vq)
1594 msleep(20); 1092 msleep(20);
1595 msi3101_ctrl_msg(s, CMD_STOP_STREAMING, 0); 1093 msi3101_ctrl_msg(s, CMD_STOP_STREAMING, 0);
1596 1094
1095 /* sleep USB IF / ADC */
1096 msi3101_ctrl_msg(s, CMD_WREG, 0x01000003);
1097
1098 /* sleep tuner */
1099 v4l2_subdev_call(s->v4l2_subdev, core, s_power, 0);
1100
1597 mutex_unlock(&s->v4l2_lock); 1101 mutex_unlock(&s->v4l2_lock);
1598 1102
1599 return 0; 1103 return 0;
@@ -1601,7 +1105,6 @@ static int msi3101_stop_streaming(struct vb2_queue *vq)
1601 1105
1602static struct vb2_ops msi3101_vb2_ops = { 1106static struct vb2_ops msi3101_vb2_ops = {
1603 .queue_setup = msi3101_queue_setup, 1107 .queue_setup = msi3101_queue_setup,
1604 .buf_prepare = msi3101_buf_prepare,
1605 .buf_queue = msi3101_buf_queue, 1108 .buf_queue = msi3101_buf_queue,
1606 .start_streaming = msi3101_start_streaming, 1109 .start_streaming = msi3101_start_streaming,
1607 .stop_streaming = msi3101_stop_streaming, 1110 .stop_streaming = msi3101_stop_streaming,
@@ -1609,66 +1112,195 @@ static struct vb2_ops msi3101_vb2_ops = {
1609 .wait_finish = vb2_ops_wait_finish, 1112 .wait_finish = vb2_ops_wait_finish,
1610}; 1113};
1611 1114
1612static int msi3101_enum_input(struct file *file, void *fh, struct v4l2_input *i) 1115static int msi3101_enum_fmt_sdr_cap(struct file *file, void *priv,
1116 struct v4l2_fmtdesc *f)
1613{ 1117{
1614 if (i->index != 0) 1118 struct msi3101_state *s = video_drvdata(file);
1119 dev_dbg(&s->udev->dev, "%s: index=%d\n", __func__, f->index);
1120
1121 if (f->index >= NUM_FORMATS)
1615 return -EINVAL; 1122 return -EINVAL;
1616 1123
1617 strlcpy(i->name, "SDR data", sizeof(i->name)); 1124 strlcpy(f->description, formats[f->index].name, sizeof(f->description));
1618 i->type = V4L2_INPUT_TYPE_CAMERA; 1125 f->pixelformat = formats[f->index].pixelformat;
1126
1127 return 0;
1128}
1129
1130static int msi3101_g_fmt_sdr_cap(struct file *file, void *priv,
1131 struct v4l2_format *f)
1132{
1133 struct msi3101_state *s = video_drvdata(file);
1134 dev_dbg(&s->udev->dev, "%s: pixelformat fourcc %4.4s\n", __func__,
1135 (char *)&s->pixelformat);
1136
1137 memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
1138 f->fmt.sdr.pixelformat = s->pixelformat;
1619 1139
1620 return 0; 1140 return 0;
1621} 1141}
1622 1142
1623static int msi3101_g_input(struct file *file, void *fh, unsigned int *i) 1143static int msi3101_s_fmt_sdr_cap(struct file *file, void *priv,
1144 struct v4l2_format *f)
1624{ 1145{
1625 *i = 0; 1146 struct msi3101_state *s = video_drvdata(file);
1147 struct vb2_queue *q = &s->vb_queue;
1148 int i;
1149 dev_dbg(&s->udev->dev, "%s: pixelformat fourcc %4.4s\n", __func__,
1150 (char *)&f->fmt.sdr.pixelformat);
1151
1152 if (vb2_is_busy(q))
1153 return -EBUSY;
1154
1155 memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
1156 for (i = 0; i < NUM_FORMATS; i++) {
1157 if (formats[i].pixelformat == f->fmt.sdr.pixelformat) {
1158 s->pixelformat = f->fmt.sdr.pixelformat;
1159 return 0;
1160 }
1161 }
1162
1163 f->fmt.sdr.pixelformat = formats[0].pixelformat;
1164 s->pixelformat = formats[0].pixelformat;
1626 1165
1627 return 0; 1166 return 0;
1628} 1167}
1629 1168
1630static int msi3101_s_input(struct file *file, void *fh, unsigned int i) 1169static int msi3101_try_fmt_sdr_cap(struct file *file, void *priv,
1170 struct v4l2_format *f)
1631{ 1171{
1632 return i ? -EINVAL : 0; 1172 struct msi3101_state *s = video_drvdata(file);
1173 int i;
1174 dev_dbg(&s->udev->dev, "%s: pixelformat fourcc %4.4s\n", __func__,
1175 (char *)&f->fmt.sdr.pixelformat);
1176
1177 memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
1178 for (i = 0; i < NUM_FORMATS; i++) {
1179 if (formats[i].pixelformat == f->fmt.sdr.pixelformat)
1180 return 0;
1181 }
1182
1183 f->fmt.sdr.pixelformat = formats[0].pixelformat;
1184
1185 return 0;
1633} 1186}
1634 1187
1635static int vidioc_s_tuner(struct file *file, void *priv, 1188static int msi3101_s_tuner(struct file *file, void *priv,
1636 const struct v4l2_tuner *v) 1189 const struct v4l2_tuner *v)
1637{ 1190{
1638 struct msi3101_state *s = video_drvdata(file); 1191 struct msi3101_state *s = video_drvdata(file);
1639 dev_dbg(&s->udev->dev, "%s:\n", __func__); 1192 int ret;
1193 dev_dbg(&s->udev->dev, "%s: index=%d\n", __func__, v->index);
1640 1194
1641 return 0; 1195 if (v->index == 0)
1196 ret = 0;
1197 else if (v->index == 1)
1198 ret = v4l2_subdev_call(s->v4l2_subdev, tuner, s_tuner, v);
1199 else
1200 ret = -EINVAL;
1201
1202 return ret;
1642} 1203}
1643 1204
1644static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *v) 1205static int msi3101_g_tuner(struct file *file, void *priv, struct v4l2_tuner *v)
1645{ 1206{
1646 struct msi3101_state *s = video_drvdata(file); 1207 struct msi3101_state *s = video_drvdata(file);
1647 dev_dbg(&s->udev->dev, "%s:\n", __func__); 1208 int ret;
1209 dev_dbg(&s->udev->dev, "%s: index=%d\n", __func__, v->index);
1210
1211 if (v->index == 0) {
1212 strlcpy(v->name, "Mirics MSi2500", sizeof(v->name));
1213 v->type = V4L2_TUNER_ADC;
1214 v->capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS;
1215 v->rangelow = 1200000;
1216 v->rangehigh = 15000000;
1217 ret = 0;
1218 } else if (v->index == 1) {
1219 ret = v4l2_subdev_call(s->v4l2_subdev, tuner, g_tuner, v);
1220 } else {
1221 ret = -EINVAL;
1222 }
1648 1223
1649 strcpy(v->name, "SDR RX"); 1224 return ret;
1650 v->capability = V4L2_TUNER_CAP_LOW; 1225}
1651 1226
1652 return 0; 1227static int msi3101_g_frequency(struct file *file, void *priv,
1228 struct v4l2_frequency *f)
1229{
1230 struct msi3101_state *s = video_drvdata(file);
1231 int ret = 0;
1232 dev_dbg(&s->udev->dev, "%s: tuner=%d type=%d\n",
1233 __func__, f->tuner, f->type);
1234
1235 if (f->tuner == 0) {
1236 f->frequency = s->f_adc;
1237 ret = 0;
1238 } else if (f->tuner == 1) {
1239 f->type = V4L2_TUNER_RF;
1240 ret = v4l2_subdev_call(s->v4l2_subdev, tuner, g_frequency, f);
1241 } else {
1242 ret = -EINVAL;
1243 }
1244
1245 return ret;
1653} 1246}
1654 1247
1655static int vidioc_s_frequency(struct file *file, void *priv, 1248static int msi3101_s_frequency(struct file *file, void *priv,
1656 const struct v4l2_frequency *f) 1249 const struct v4l2_frequency *f)
1657{ 1250{
1658 struct msi3101_state *s = video_drvdata(file); 1251 struct msi3101_state *s = video_drvdata(file);
1659 dev_dbg(&s->udev->dev, "%s: frequency=%lu Hz (%u)\n", 1252 int ret;
1660 __func__, f->frequency * 625UL / 10UL, f->frequency); 1253 dev_dbg(&s->udev->dev, "%s: tuner=%d type=%d frequency=%u\n",
1254 __func__, f->tuner, f->type, f->frequency);
1255
1256 if (f->tuner == 0) {
1257 s->f_adc = clamp_t(unsigned int, f->frequency,
1258 bands[0].rangelow,
1259 bands[0].rangehigh);
1260 dev_dbg(&s->udev->dev, "%s: ADC frequency=%u Hz\n",
1261 __func__, s->f_adc);
1262 ret = msi3101_set_usb_adc(s);
1263 } else if (f->tuner == 1) {
1264 ret = v4l2_subdev_call(s->v4l2_subdev, tuner, s_frequency, f);
1265 } else {
1266 ret = -EINVAL;
1267 }
1661 1268
1662 return v4l2_ctrl_s_ctrl_int64(s->ctrl_tuner_rf, 1269 return ret;
1663 f->frequency * 625UL / 10UL); 1270}
1271
1272static int msi3101_enum_freq_bands(struct file *file, void *priv,
1273 struct v4l2_frequency_band *band)
1274{
1275 struct msi3101_state *s = video_drvdata(file);
1276 int ret;
1277 dev_dbg(&s->udev->dev, "%s: tuner=%d type=%d index=%d\n",
1278 __func__, band->tuner, band->type, band->index);
1279
1280 if (band->tuner == 0) {
1281 if (band->index >= ARRAY_SIZE(bands)) {
1282 ret = -EINVAL;
1283 } else {
1284 *band = bands[band->index];
1285 ret = 0;
1286 }
1287 } else if (band->tuner == 1) {
1288 ret = v4l2_subdev_call(s->v4l2_subdev, tuner,
1289 enum_freq_bands, band);
1290 } else {
1291 ret = -EINVAL;
1292 }
1293
1294 return ret;
1664} 1295}
1665 1296
1666static const struct v4l2_ioctl_ops msi3101_ioctl_ops = { 1297static const struct v4l2_ioctl_ops msi3101_ioctl_ops = {
1667 .vidioc_querycap = msi3101_querycap, 1298 .vidioc_querycap = msi3101_querycap,
1668 1299
1669 .vidioc_enum_input = msi3101_enum_input, 1300 .vidioc_enum_fmt_sdr_cap = msi3101_enum_fmt_sdr_cap,
1670 .vidioc_g_input = msi3101_g_input, 1301 .vidioc_g_fmt_sdr_cap = msi3101_g_fmt_sdr_cap,
1671 .vidioc_s_input = msi3101_s_input, 1302 .vidioc_s_fmt_sdr_cap = msi3101_s_fmt_sdr_cap,
1303 .vidioc_try_fmt_sdr_cap = msi3101_try_fmt_sdr_cap,
1672 1304
1673 .vidioc_reqbufs = vb2_ioctl_reqbufs, 1305 .vidioc_reqbufs = vb2_ioctl_reqbufs,
1674 .vidioc_create_bufs = vb2_ioctl_create_bufs, 1306 .vidioc_create_bufs = vb2_ioctl_create_bufs,
@@ -1680,9 +1312,12 @@ static const struct v4l2_ioctl_ops msi3101_ioctl_ops = {
1680 .vidioc_streamon = vb2_ioctl_streamon, 1312 .vidioc_streamon = vb2_ioctl_streamon,
1681 .vidioc_streamoff = vb2_ioctl_streamoff, 1313 .vidioc_streamoff = vb2_ioctl_streamoff,
1682 1314
1683 .vidioc_g_tuner = vidioc_g_tuner, 1315 .vidioc_g_tuner = msi3101_g_tuner,
1684 .vidioc_s_tuner = vidioc_s_tuner, 1316 .vidioc_s_tuner = msi3101_s_tuner,
1685 .vidioc_s_frequency = vidioc_s_frequency, 1317
1318 .vidioc_g_frequency = msi3101_g_frequency,
1319 .vidioc_s_frequency = msi3101_s_frequency,
1320 .vidioc_enum_freq_bands = msi3101_enum_freq_bands,
1686 1321
1687 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, 1322 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
1688 .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 1323 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
@@ -1706,129 +1341,52 @@ static struct video_device msi3101_template = {
1706 .ioctl_ops = &msi3101_ioctl_ops, 1341 .ioctl_ops = &msi3101_ioctl_ops,
1707}; 1342};
1708 1343
1709static int msi3101_s_ctrl(struct v4l2_ctrl *ctrl)
1710{
1711 struct msi3101_state *s =
1712 container_of(ctrl->handler, struct msi3101_state,
1713 ctrl_handler);
1714 int ret;
1715 dev_dbg(&s->udev->dev,
1716 "%s: id=%d name=%s val=%d min=%d max=%d step=%d\n",
1717 __func__, ctrl->id, ctrl->name, ctrl->val,
1718 ctrl->minimum, ctrl->maximum, ctrl->step);
1719
1720 switch (ctrl->id) {
1721 case MSI3101_CID_SAMPLING_MODE:
1722 case MSI3101_CID_SAMPLING_RATE:
1723 case MSI3101_CID_SAMPLING_RESOLUTION:
1724 ret = 0;
1725 break;
1726 case MSI3101_CID_TUNER_RF:
1727 case MSI3101_CID_TUNER_BW:
1728 case MSI3101_CID_TUNER_IF:
1729 case MSI3101_CID_TUNER_GAIN:
1730 ret = msi3101_set_tuner(s);
1731 break;
1732 default:
1733 ret = -EINVAL;
1734 }
1735
1736 return ret;
1737}
1738
1739static const struct v4l2_ctrl_ops msi3101_ctrl_ops = {
1740 .s_ctrl = msi3101_s_ctrl,
1741};
1742
1743static void msi3101_video_release(struct v4l2_device *v) 1344static void msi3101_video_release(struct v4l2_device *v)
1744{ 1345{
1745 struct msi3101_state *s = 1346 struct msi3101_state *s =
1746 container_of(v, struct msi3101_state, v4l2_dev); 1347 container_of(v, struct msi3101_state, v4l2_dev);
1747 1348
1748 v4l2_ctrl_handler_free(&s->ctrl_handler); 1349 v4l2_ctrl_handler_free(&s->hdl);
1749 v4l2_device_unregister(&s->v4l2_dev); 1350 v4l2_device_unregister(&s->v4l2_dev);
1750 kfree(s); 1351 kfree(s);
1751} 1352}
1752 1353
1354static int msi3101_transfer_one_message(struct spi_master *master,
1355 struct spi_message *m)
1356{
1357 struct msi3101_state *s = spi_master_get_devdata(master);
1358 struct spi_transfer *t;
1359 int ret = 0;
1360 u32 data;
1361
1362 list_for_each_entry(t, &m->transfers, transfer_list) {
1363 dev_dbg(&s->udev->dev, "%s: msg=%*ph\n",
1364 __func__, t->len, t->tx_buf);
1365 data = 0x09; /* reg 9 is SPI adapter */
1366 data |= ((u8 *)t->tx_buf)[0] << 8;
1367 data |= ((u8 *)t->tx_buf)[1] << 16;
1368 data |= ((u8 *)t->tx_buf)[2] << 24;
1369 ret = msi3101_ctrl_msg(s, CMD_WREG, data);
1370 }
1371
1372 m->status = ret;
1373 spi_finalize_current_message(master);
1374 return ret;
1375}
1376
1753static int msi3101_probe(struct usb_interface *intf, 1377static int msi3101_probe(struct usb_interface *intf,
1754 const struct usb_device_id *id) 1378 const struct usb_device_id *id)
1755{ 1379{
1756 struct usb_device *udev = interface_to_usbdev(intf); 1380 struct usb_device *udev = interface_to_usbdev(intf);
1757 struct msi3101_state *s = NULL; 1381 struct msi3101_state *s = NULL;
1382 struct v4l2_subdev *sd;
1383 struct spi_master *master;
1758 int ret; 1384 int ret;
1759 static const char * const ctrl_sampling_mode_qmenu_strings[] = { 1385 static struct spi_board_info board_info = {
1760 "Quadrature Sampling", 1386 .modalias = "msi001",
1761 NULL, 1387 .bus_num = 0,
1762 }; 1388 .chip_select = 0,
1763 static const struct v4l2_ctrl_config ctrl_sampling_mode = { 1389 .max_speed_hz = 12000000,
1764 .ops = &msi3101_ctrl_ops,
1765 .id = MSI3101_CID_SAMPLING_MODE,
1766 .type = V4L2_CTRL_TYPE_MENU,
1767 .flags = V4L2_CTRL_FLAG_INACTIVE,
1768 .name = "Sampling Mode",
1769 .qmenu = ctrl_sampling_mode_qmenu_strings,
1770 };
1771 static const struct v4l2_ctrl_config ctrl_sampling_rate = {
1772 .ops = &msi3101_ctrl_ops,
1773 .id = MSI3101_CID_SAMPLING_RATE,
1774 .type = V4L2_CTRL_TYPE_INTEGER64,
1775 .name = "Sampling Rate",
1776 .min = 500000,
1777 .max = 12000000,
1778 .def = 2048000,
1779 .step = 1,
1780 };
1781 static const struct v4l2_ctrl_config ctrl_sampling_resolution = {
1782 .ops = &msi3101_ctrl_ops,
1783 .id = MSI3101_CID_SAMPLING_RESOLUTION,
1784 .type = V4L2_CTRL_TYPE_INTEGER,
1785 .flags = V4L2_CTRL_FLAG_INACTIVE,
1786 .name = "Sampling Resolution",
1787 .min = 10,
1788 .max = 10,
1789 .def = 10,
1790 .step = 1,
1791 };
1792 static const struct v4l2_ctrl_config ctrl_tuner_rf = {
1793 .ops = &msi3101_ctrl_ops,
1794 .id = MSI3101_CID_TUNER_RF,
1795 .type = V4L2_CTRL_TYPE_INTEGER64,
1796 .name = "Tuner RF",
1797 .min = 40000000,
1798 .max = 2000000000,
1799 .def = 100000000,
1800 .step = 1,
1801 };
1802 static const struct v4l2_ctrl_config ctrl_tuner_bw = {
1803 .ops = &msi3101_ctrl_ops,
1804 .id = MSI3101_CID_TUNER_BW,
1805 .type = V4L2_CTRL_TYPE_INTEGER,
1806 .name = "Tuner BW",
1807 .min = 200000,
1808 .max = 8000000,
1809 .def = 600000,
1810 .step = 1,
1811 };
1812 static const struct v4l2_ctrl_config ctrl_tuner_if = {
1813 .ops = &msi3101_ctrl_ops,
1814 .id = MSI3101_CID_TUNER_IF,
1815 .type = V4L2_CTRL_TYPE_INTEGER,
1816 .flags = V4L2_CTRL_FLAG_INACTIVE,
1817 .name = "Tuner IF",
1818 .min = 0,
1819 .max = 2048000,
1820 .def = 0,
1821 .step = 1,
1822 };
1823 static const struct v4l2_ctrl_config ctrl_tuner_gain = {
1824 .ops = &msi3101_ctrl_ops,
1825 .id = MSI3101_CID_TUNER_GAIN,
1826 .type = V4L2_CTRL_TYPE_INTEGER,
1827 .name = "Tuner Gain",
1828 .min = 0,
1829 .max = 102,
1830 .def = 0,
1831 .step = 1,
1832 }; 1390 };
1833 1391
1834 s = kzalloc(sizeof(struct msi3101_state), GFP_KERNEL); 1392 s = kzalloc(sizeof(struct msi3101_state), GFP_KERNEL);
@@ -1841,19 +1399,20 @@ static int msi3101_probe(struct usb_interface *intf,
1841 mutex_init(&s->vb_queue_lock); 1399 mutex_init(&s->vb_queue_lock);
1842 spin_lock_init(&s->queued_bufs_lock); 1400 spin_lock_init(&s->queued_bufs_lock);
1843 INIT_LIST_HEAD(&s->queued_bufs); 1401 INIT_LIST_HEAD(&s->queued_bufs);
1844
1845 s->udev = udev; 1402 s->udev = udev;
1403 s->f_adc = bands[0].rangelow;
1404 s->pixelformat = V4L2_SDR_FMT_CU8;
1846 1405
1847 /* Init videobuf2 queue structure */ 1406 /* Init videobuf2 queue structure */
1848 s->vb_queue.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1407 s->vb_queue.type = V4L2_BUF_TYPE_SDR_CAPTURE;
1849 s->vb_queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ; 1408 s->vb_queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
1850 s->vb_queue.drv_priv = s; 1409 s->vb_queue.drv_priv = s;
1851 s->vb_queue.buf_struct_size = sizeof(struct msi3101_frame_buf); 1410 s->vb_queue.buf_struct_size = sizeof(struct msi3101_frame_buf);
1852 s->vb_queue.ops = &msi3101_vb2_ops; 1411 s->vb_queue.ops = &msi3101_vb2_ops;
1853 s->vb_queue.mem_ops = &vb2_vmalloc_memops; 1412 s->vb_queue.mem_ops = &vb2_vmalloc_memops;
1854 s->vb_queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1413 s->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1855 ret = vb2_queue_init(&s->vb_queue); 1414 ret = vb2_queue_init(&s->vb_queue);
1856 if (ret < 0) { 1415 if (ret) {
1857 dev_err(&s->udev->dev, "Could not initialize vb2 queue\n"); 1416 dev_err(&s->udev->dev, "Could not initialize vb2 queue\n");
1858 goto err_free_mem; 1417 goto err_free_mem;
1859 } 1418 }
@@ -1865,36 +1424,59 @@ static int msi3101_probe(struct usb_interface *intf,
1865 set_bit(V4L2_FL_USE_FH_PRIO, &s->vdev.flags); 1424 set_bit(V4L2_FL_USE_FH_PRIO, &s->vdev.flags);
1866 video_set_drvdata(&s->vdev, s); 1425 video_set_drvdata(&s->vdev, s);
1867 1426
1868 /* Register controls */
1869 v4l2_ctrl_handler_init(&s->ctrl_handler, 7);
1870 v4l2_ctrl_new_custom(&s->ctrl_handler, &ctrl_sampling_mode, NULL);
1871 s->ctrl_sampling_rate = v4l2_ctrl_new_custom(&s->ctrl_handler, &ctrl_sampling_rate, NULL);
1872 v4l2_ctrl_new_custom(&s->ctrl_handler, &ctrl_sampling_resolution, NULL);
1873 s->ctrl_tuner_rf = v4l2_ctrl_new_custom(&s->ctrl_handler, &ctrl_tuner_rf, NULL);
1874 s->ctrl_tuner_bw = v4l2_ctrl_new_custom(&s->ctrl_handler, &ctrl_tuner_bw, NULL);
1875 s->ctrl_tuner_if = v4l2_ctrl_new_custom(&s->ctrl_handler, &ctrl_tuner_if, NULL);
1876 s->ctrl_tuner_gain = v4l2_ctrl_new_custom(&s->ctrl_handler, &ctrl_tuner_gain, NULL);
1877 if (s->ctrl_handler.error) {
1878 ret = s->ctrl_handler.error;
1879 dev_err(&s->udev->dev, "Could not initialize controls\n");
1880 goto err_free_controls;
1881 }
1882
1883 /* Register the v4l2_device structure */ 1427 /* Register the v4l2_device structure */
1884 s->v4l2_dev.release = msi3101_video_release; 1428 s->v4l2_dev.release = msi3101_video_release;
1885 ret = v4l2_device_register(&intf->dev, &s->v4l2_dev); 1429 ret = v4l2_device_register(&intf->dev, &s->v4l2_dev);
1886 if (ret) { 1430 if (ret) {
1887 dev_err(&s->udev->dev, 1431 dev_err(&s->udev->dev,
1888 "Failed to register v4l2-device (%d)\n", ret); 1432 "Failed to register v4l2-device (%d)\n", ret);
1433 goto err_free_mem;
1434 }
1435
1436 /* SPI master adapter */
1437 master = spi_alloc_master(&s->udev->dev, 0);
1438 if (master == NULL) {
1439 ret = -ENOMEM;
1440 goto err_unregister_v4l2_dev;
1441 }
1442
1443 s->master = master;
1444 master->bus_num = 0;
1445 master->num_chipselect = 1;
1446 master->transfer_one_message = msi3101_transfer_one_message;
1447 spi_master_set_devdata(master, s);
1448 ret = spi_register_master(master);
1449 if (ret) {
1450 spi_master_put(master);
1451 goto err_unregister_v4l2_dev;
1452 }
1453
1454 /* load v4l2 subdevice */
1455 sd = v4l2_spi_new_subdev(&s->v4l2_dev, master, &board_info);
1456 s->v4l2_subdev = sd;
1457 if (sd == NULL) {
1458 dev_err(&s->udev->dev, "cannot get v4l2 subdevice\n");
1459 ret = -ENODEV;
1460 goto err_unregister_master;
1461 }
1462
1463 /* Register controls */
1464 v4l2_ctrl_handler_init(&s->hdl, 0);
1465 if (s->hdl.error) {
1466 ret = s->hdl.error;
1467 dev_err(&s->udev->dev, "Could not initialize controls\n");
1889 goto err_free_controls; 1468 goto err_free_controls;
1890 } 1469 }
1891 1470
1892 s->v4l2_dev.ctrl_handler = &s->ctrl_handler; 1471 /* currently all controls are from subdev */
1472 v4l2_ctrl_add_handler(&s->hdl, sd->ctrl_handler, NULL);
1473
1474 s->v4l2_dev.ctrl_handler = &s->hdl;
1893 s->vdev.v4l2_dev = &s->v4l2_dev; 1475 s->vdev.v4l2_dev = &s->v4l2_dev;
1894 s->vdev.lock = &s->v4l2_lock; 1476 s->vdev.lock = &s->v4l2_lock;
1895 1477
1896 ret = video_register_device(&s->vdev, VFL_TYPE_GRABBER, -1); 1478 ret = video_register_device(&s->vdev, VFL_TYPE_SDR, -1);
1897 if (ret < 0) { 1479 if (ret) {
1898 dev_err(&s->udev->dev, 1480 dev_err(&s->udev->dev,
1899 "Failed to register as video device (%d)\n", 1481 "Failed to register as video device (%d)\n",
1900 ret); 1482 ret);
@@ -1905,10 +1487,12 @@ static int msi3101_probe(struct usb_interface *intf,
1905 1487
1906 return 0; 1488 return 0;
1907 1489
1490err_free_controls:
1491 v4l2_ctrl_handler_free(&s->hdl);
1492err_unregister_master:
1493 spi_unregister_master(s->master);
1908err_unregister_v4l2_dev: 1494err_unregister_v4l2_dev:
1909 v4l2_device_unregister(&s->v4l2_dev); 1495 v4l2_device_unregister(&s->v4l2_dev);
1910err_free_controls:
1911 v4l2_ctrl_handler_free(&s->ctrl_handler);
1912err_free_mem: 1496err_free_mem:
1913 kfree(s); 1497 kfree(s);
1914 return ret; 1498 return ret;
diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
index 8c7f35029cd5..ded31ea6bd39 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -1074,7 +1074,7 @@ static int iss_video_open(struct file *file)
1074 q->ops = &iss_video_vb2ops; 1074 q->ops = &iss_video_vb2ops;
1075 q->mem_ops = &vb2_dma_contig_memops; 1075 q->mem_ops = &vb2_dma_contig_memops;
1076 q->buf_struct_size = sizeof(struct iss_buffer); 1076 q->buf_struct_size = sizeof(struct iss_buffer);
1077 q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1077 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1078 1078
1079 ret = vb2_queue_init(q); 1079 ret = vb2_queue_init(q);
1080 if (ret) { 1080 if (ret) {
diff --git a/drivers/staging/media/rtl2832u_sdr/Kconfig b/drivers/staging/media/rtl2832u_sdr/Kconfig
new file mode 100644
index 000000000000..3ede5fe8f0a5
--- /dev/null
+++ b/drivers/staging/media/rtl2832u_sdr/Kconfig
@@ -0,0 +1,7 @@
1config DVB_RTL2832_SDR
2 tristate "Realtek RTL2832 SDR"
3 depends on USB && DVB_CORE && I2C && VIDEO_V4L2 && DVB_USB_RTL28XXU
4 select DVB_RTL2832
5 select VIDEOBUF2_VMALLOC
6 default m if !MEDIA_SUBDRV_AUTOSELECT
7
diff --git a/drivers/staging/media/rtl2832u_sdr/Makefile b/drivers/staging/media/rtl2832u_sdr/Makefile
new file mode 100644
index 000000000000..7e00a0df4631
--- /dev/null
+++ b/drivers/staging/media/rtl2832u_sdr/Makefile
@@ -0,0 +1,6 @@
1obj-$(CONFIG_DVB_RTL2832_SDR) += rtl2832_sdr.o
2
3ccflags-y += -Idrivers/media/dvb-core
4ccflags-y += -Idrivers/media/dvb-frontends
5ccflags-y += -Idrivers/media/tuners
6ccflags-y += -Idrivers/media/usb/dvb-usb-v2
diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
new file mode 100644
index 000000000000..104ee8af79af
--- /dev/null
+++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
@@ -0,0 +1,1500 @@
1/*
2 * Realtek RTL2832U SDR driver
3 *
4 * Copyright (C) 2013 Antti Palosaari <crope@iki.fi>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * GNU Radio plugin "gr-kernel" for device usage will be on:
21 * http://git.linuxtv.org/anttip/gr-kernel.git
22 *
23 */
24
25#include "dvb_frontend.h"
26#include "rtl2832_sdr.h"
27#include "dvb_usb.h"
28
29#include <media/v4l2-device.h>
30#include <media/v4l2-ioctl.h>
31#include <media/v4l2-ctrls.h>
32#include <media/v4l2-event.h>
33#include <media/videobuf2-vmalloc.h>
34
35#include <linux/jiffies.h>
36#include <linux/math64.h>
37
38#define MAX_BULK_BUFS (10)
39#define BULK_BUFFER_SIZE (128 * 512)
40
41static const struct v4l2_frequency_band bands_adc[] = {
42 {
43 .tuner = 0,
44 .type = V4L2_TUNER_ADC,
45 .index = 0,
46 .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
47 .rangelow = 300000,
48 .rangehigh = 300000,
49 },
50 {
51 .tuner = 0,
52 .type = V4L2_TUNER_ADC,
53 .index = 1,
54 .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
55 .rangelow = 900001,
56 .rangehigh = 2800000,
57 },
58 {
59 .tuner = 0,
60 .type = V4L2_TUNER_ADC,
61 .index = 2,
62 .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
63 .rangelow = 3200000,
64 .rangehigh = 3200000,
65 },
66};
67
68static const struct v4l2_frequency_band bands_fm[] = {
69 {
70 .tuner = 1,
71 .type = V4L2_TUNER_RF,
72 .index = 0,
73 .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
74 .rangelow = 50000000,
75 .rangehigh = 2000000000,
76 },
77};
78
79/* stream formats */
80struct rtl2832_sdr_format {
81 char *name;
82 u32 pixelformat;
83};
84
85static struct rtl2832_sdr_format formats[] = {
86 {
87 .name = "IQ U8",
88 .pixelformat = V4L2_SDR_FMT_CU8,
89 }, {
90 .name = "IQ U16LE (emulated)",
91 .pixelformat = V4L2_SDR_FMT_CU16LE,
92 },
93};
94
95static const unsigned int NUM_FORMATS = ARRAY_SIZE(formats);
96
97/* intermediate buffers with raw data from the USB device */
98struct rtl2832_sdr_frame_buf {
99 struct vb2_buffer vb; /* common v4l buffer stuff -- must be first */
100 struct list_head list;
101};
102
103struct rtl2832_sdr_state {
104#define POWER_ON (1 << 1)
105#define URB_BUF (1 << 2)
106 unsigned long flags;
107
108 const struct rtl2832_config *cfg;
109 struct dvb_frontend *fe;
110 struct dvb_usb_device *d;
111 struct i2c_adapter *i2c;
112 u8 bank;
113
114 struct video_device vdev;
115 struct v4l2_device v4l2_dev;
116
117 /* videobuf2 queue and queued buffers list */
118 struct vb2_queue vb_queue;
119 struct list_head queued_bufs;
120 spinlock_t queued_bufs_lock; /* Protects queued_bufs */
121 unsigned sequence; /* buffer sequence counter */
122
123 /* Note if taking both locks v4l2_lock must always be locked first! */
124 struct mutex v4l2_lock; /* Protects everything else */
125 struct mutex vb_queue_lock; /* Protects vb_queue and capt_file */
126
127 /* Pointer to our usb_device, will be NULL after unplug */
128 struct usb_device *udev; /* Both mutexes most be hold when setting! */
129
130 unsigned int vb_full; /* vb is full and packets dropped */
131
132 struct urb *urb_list[MAX_BULK_BUFS];
133 int buf_num;
134 unsigned long buf_size;
135 u8 *buf_list[MAX_BULK_BUFS];
136 dma_addr_t dma_addr[MAX_BULK_BUFS];
137 int urbs_initialized;
138 int urbs_submitted;
139
140 unsigned int f_adc, f_tuner;
141 u32 pixelformat;
142
143 /* Controls */
144 struct v4l2_ctrl_handler hdl;
145 struct v4l2_ctrl *bandwidth_auto;
146 struct v4l2_ctrl *bandwidth;
147
148 /* for sample rate calc */
149 unsigned int sample;
150 unsigned int sample_measured;
151 unsigned long jiffies_next;
152};
153
154/* write multiple hardware registers */
155static int rtl2832_sdr_wr(struct rtl2832_sdr_state *s, u8 reg, const u8 *val,
156 int len)
157{
158 int ret;
159#define MAX_WR_LEN 24
160#define MAX_WR_XFER_LEN (MAX_WR_LEN + 1)
161 u8 buf[MAX_WR_XFER_LEN];
162 struct i2c_msg msg[1] = {
163 {
164 .addr = s->cfg->i2c_addr,
165 .flags = 0,
166 .len = 1 + len,
167 .buf = buf,
168 }
169 };
170
171 if (WARN_ON(len > MAX_WR_LEN))
172 return -EINVAL;
173
174 buf[0] = reg;
175 memcpy(&buf[1], val, len);
176
177 ret = i2c_transfer(s->i2c, msg, 1);
178 if (ret == 1) {
179 ret = 0;
180 } else {
181 dev_err(&s->i2c->dev,
182 "%s: I2C wr failed=%d reg=%02x len=%d\n",
183 KBUILD_MODNAME, ret, reg, len);
184 ret = -EREMOTEIO;
185 }
186 return ret;
187}
188
189/* read multiple hardware registers */
190static int rtl2832_sdr_rd(struct rtl2832_sdr_state *s, u8 reg, u8 *val, int len)
191{
192 int ret;
193 struct i2c_msg msg[2] = {
194 {
195 .addr = s->cfg->i2c_addr,
196 .flags = 0,
197 .len = 1,
198 .buf = &reg,
199 }, {
200 .addr = s->cfg->i2c_addr,
201 .flags = I2C_M_RD,
202 .len = len,
203 .buf = val,
204 }
205 };
206
207 ret = i2c_transfer(s->i2c, msg, 2);
208 if (ret == 2) {
209 ret = 0;
210 } else {
211 dev_err(&s->i2c->dev,
212 "%s: I2C rd failed=%d reg=%02x len=%d\n",
213 KBUILD_MODNAME, ret, reg, len);
214 ret = -EREMOTEIO;
215 }
216 return ret;
217}
218
219/* write multiple registers */
220static int rtl2832_sdr_wr_regs(struct rtl2832_sdr_state *s, u16 reg,
221 const u8 *val, int len)
222{
223 int ret;
224 u8 reg2 = (reg >> 0) & 0xff;
225 u8 bank = (reg >> 8) & 0xff;
226
227 /* switch bank if needed */
228 if (bank != s->bank) {
229 ret = rtl2832_sdr_wr(s, 0x00, &bank, 1);
230 if (ret)
231 return ret;
232
233 s->bank = bank;
234 }
235
236 return rtl2832_sdr_wr(s, reg2, val, len);
237}
238
239/* read multiple registers */
240static int rtl2832_sdr_rd_regs(struct rtl2832_sdr_state *s, u16 reg, u8 *val,
241 int len)
242{
243 int ret;
244 u8 reg2 = (reg >> 0) & 0xff;
245 u8 bank = (reg >> 8) & 0xff;
246
247 /* switch bank if needed */
248 if (bank != s->bank) {
249 ret = rtl2832_sdr_wr(s, 0x00, &bank, 1);
250 if (ret)
251 return ret;
252
253 s->bank = bank;
254 }
255
256 return rtl2832_sdr_rd(s, reg2, val, len);
257}
258
259/* write single register */
260static int rtl2832_sdr_wr_reg(struct rtl2832_sdr_state *s, u16 reg, u8 val)
261{
262 return rtl2832_sdr_wr_regs(s, reg, &val, 1);
263}
264
265#if 0
266/* read single register */
267static int rtl2832_sdr_rd_reg(struct rtl2832_sdr_state *s, u16 reg, u8 *val)
268{
269 return rtl2832_sdr_rd_regs(s, reg, val, 1);
270}
271#endif
272
273/* write single register with mask */
274static int rtl2832_sdr_wr_reg_mask(struct rtl2832_sdr_state *s, u16 reg,
275 u8 val, u8 mask)
276{
277 int ret;
278 u8 tmp;
279
280 /* no need for read if whole reg is written */
281 if (mask != 0xff) {
282 ret = rtl2832_sdr_rd_regs(s, reg, &tmp, 1);
283 if (ret)
284 return ret;
285
286 val &= mask;
287 tmp &= ~mask;
288 val |= tmp;
289 }
290
291 return rtl2832_sdr_wr_regs(s, reg, &val, 1);
292}
293
294#if 0
295/* read single register with mask */
296static int rtl2832_sdr_rd_reg_mask(struct rtl2832_sdr_state *s, u16 reg,
297 u8 *val, u8 mask)
298{
299 int ret, i;
300 u8 tmp;
301
302 ret = rtl2832_sdr_rd_regs(s, reg, &tmp, 1);
303 if (ret)
304 return ret;
305
306 tmp &= mask;
307
308 /* find position of the first bit */
309 for (i = 0; i < 8; i++) {
310 if ((mask >> i) & 0x01)
311 break;
312 }
313 *val = tmp >> i;
314
315 return 0;
316}
317#endif
318
319/* Private functions */
320static struct rtl2832_sdr_frame_buf *rtl2832_sdr_get_next_fill_buf(
321 struct rtl2832_sdr_state *s)
322{
323 unsigned long flags = 0;
324 struct rtl2832_sdr_frame_buf *buf = NULL;
325
326 spin_lock_irqsave(&s->queued_bufs_lock, flags);
327 if (list_empty(&s->queued_bufs))
328 goto leave;
329
330 buf = list_entry(s->queued_bufs.next,
331 struct rtl2832_sdr_frame_buf, list);
332 list_del(&buf->list);
333leave:
334 spin_unlock_irqrestore(&s->queued_bufs_lock, flags);
335 return buf;
336}
337
338static unsigned int rtl2832_sdr_convert_stream(struct rtl2832_sdr_state *s,
339 void *dst, const u8 *src, unsigned int src_len)
340{
341 unsigned int dst_len;
342
343 if (s->pixelformat == V4L2_SDR_FMT_CU8) {
344 /* native stream, no need to convert */
345 memcpy(dst, src, src_len);
346 dst_len = src_len;
347 } else if (s->pixelformat == V4L2_SDR_FMT_CU16LE) {
348 /* convert u8 to u16 */
349 unsigned int i;
350 u16 *u16dst = dst;
351 for (i = 0; i < src_len; i++)
352 *u16dst++ = (src[i] << 8) | (src[i] >> 0);
353 dst_len = 2 * src_len;
354 } else {
355 dst_len = 0;
356 }
357
358 /* calculate samping rate and output it in 10 seconds intervals */
359 if (unlikely(time_is_before_jiffies(s->jiffies_next))) {
360#define MSECS 10000UL
361 unsigned int samples = s->sample - s->sample_measured;
362 s->jiffies_next = jiffies + msecs_to_jiffies(MSECS);
363 s->sample_measured = s->sample;
364 dev_dbg(&s->udev->dev,
365 "slen=%d samples=%u msecs=%lu sampling rate=%lu\n",
366 src_len, samples, MSECS,
367 samples * 1000UL / MSECS);
368 }
369
370 /* total number of I+Q pairs */
371 s->sample += src_len / 2;
372
373 return dst_len;
374}
375
376/*
377 * This gets called for the bulk stream pipe. This is done in interrupt
378 * time, so it has to be fast, not crash, and not stall. Neat.
379 */
380static void rtl2832_sdr_urb_complete(struct urb *urb)
381{
382 struct rtl2832_sdr_state *s = urb->context;
383 struct rtl2832_sdr_frame_buf *fbuf;
384
385 dev_dbg_ratelimited(&s->udev->dev,
386 "%s: status=%d length=%d/%d errors=%d\n",
387 __func__, urb->status, urb->actual_length,
388 urb->transfer_buffer_length, urb->error_count);
389
390 switch (urb->status) {
391 case 0: /* success */
392 case -ETIMEDOUT: /* NAK */
393 break;
394 case -ECONNRESET: /* kill */
395 case -ENOENT:
396 case -ESHUTDOWN:
397 return;
398 default: /* error */
399 dev_err_ratelimited(&s->udev->dev, "urb failed=%d\n",
400 urb->status);
401 break;
402 }
403
404 if (likely(urb->actual_length > 0)) {
405 void *ptr;
406 unsigned int len;
407 /* get free framebuffer */
408 fbuf = rtl2832_sdr_get_next_fill_buf(s);
409 if (unlikely(fbuf == NULL)) {
410 s->vb_full++;
411 dev_notice_ratelimited(&s->udev->dev,
412 "videobuf is full, %d packets dropped\n",
413 s->vb_full);
414 goto skip;
415 }
416
417 /* fill framebuffer */
418 ptr = vb2_plane_vaddr(&fbuf->vb, 0);
419 len = rtl2832_sdr_convert_stream(s, ptr, urb->transfer_buffer,
420 urb->actual_length);
421 vb2_set_plane_payload(&fbuf->vb, 0, len);
422 v4l2_get_timestamp(&fbuf->vb.v4l2_buf.timestamp);
423 fbuf->vb.v4l2_buf.sequence = s->sequence++;
424 vb2_buffer_done(&fbuf->vb, VB2_BUF_STATE_DONE);
425 }
426skip:
427 usb_submit_urb(urb, GFP_ATOMIC);
428}
429
430static int rtl2832_sdr_kill_urbs(struct rtl2832_sdr_state *s)
431{
432 int i;
433
434 for (i = s->urbs_submitted - 1; i >= 0; i--) {
435 dev_dbg(&s->udev->dev, "%s: kill urb=%d\n", __func__, i);
436 /* stop the URB */
437 usb_kill_urb(s->urb_list[i]);
438 }
439 s->urbs_submitted = 0;
440
441 return 0;
442}
443
444static int rtl2832_sdr_submit_urbs(struct rtl2832_sdr_state *s)
445{
446 int i, ret;
447
448 for (i = 0; i < s->urbs_initialized; i++) {
449 dev_dbg(&s->udev->dev, "%s: submit urb=%d\n", __func__, i);
450 ret = usb_submit_urb(s->urb_list[i], GFP_ATOMIC);
451 if (ret) {
452 dev_err(&s->udev->dev,
453 "Could not submit urb no. %d - get them all back\n",
454 i);
455 rtl2832_sdr_kill_urbs(s);
456 return ret;
457 }
458 s->urbs_submitted++;
459 }
460
461 return 0;
462}
463
464static int rtl2832_sdr_free_stream_bufs(struct rtl2832_sdr_state *s)
465{
466 if (s->flags & USB_STATE_URB_BUF) {
467 while (s->buf_num) {
468 s->buf_num--;
469 dev_dbg(&s->udev->dev, "%s: free buf=%d\n",
470 __func__, s->buf_num);
471 usb_free_coherent(s->udev, s->buf_size,
472 s->buf_list[s->buf_num],
473 s->dma_addr[s->buf_num]);
474 }
475 }
476 s->flags &= ~USB_STATE_URB_BUF;
477
478 return 0;
479}
480
481static int rtl2832_sdr_alloc_stream_bufs(struct rtl2832_sdr_state *s)
482{
483 s->buf_num = 0;
484 s->buf_size = BULK_BUFFER_SIZE;
485
486 dev_dbg(&s->udev->dev,
487 "%s: all in all I will use %u bytes for streaming\n",
488 __func__, MAX_BULK_BUFS * BULK_BUFFER_SIZE);
489
490 for (s->buf_num = 0; s->buf_num < MAX_BULK_BUFS; s->buf_num++) {
491 s->buf_list[s->buf_num] = usb_alloc_coherent(s->udev,
492 BULK_BUFFER_SIZE, GFP_ATOMIC,
493 &s->dma_addr[s->buf_num]);
494 if (!s->buf_list[s->buf_num]) {
495 dev_dbg(&s->udev->dev, "%s: alloc buf=%d failed\n",
496 __func__, s->buf_num);
497 rtl2832_sdr_free_stream_bufs(s);
498 return -ENOMEM;
499 }
500
501 dev_dbg(&s->udev->dev, "%s: alloc buf=%d %p (dma %llu)\n",
502 __func__, s->buf_num,
503 s->buf_list[s->buf_num],
504 (long long)s->dma_addr[s->buf_num]);
505 s->flags |= USB_STATE_URB_BUF;
506 }
507
508 return 0;
509}
510
511static int rtl2832_sdr_free_urbs(struct rtl2832_sdr_state *s)
512{
513 int i;
514
515 rtl2832_sdr_kill_urbs(s);
516
517 for (i = s->urbs_initialized - 1; i >= 0; i--) {
518 if (s->urb_list[i]) {
519 dev_dbg(&s->udev->dev, "%s: free urb=%d\n",
520 __func__, i);
521 /* free the URBs */
522 usb_free_urb(s->urb_list[i]);
523 }
524 }
525 s->urbs_initialized = 0;
526
527 return 0;
528}
529
530static int rtl2832_sdr_alloc_urbs(struct rtl2832_sdr_state *s)
531{
532 int i, j;
533
534 /* allocate the URBs */
535 for (i = 0; i < MAX_BULK_BUFS; i++) {
536 dev_dbg(&s->udev->dev, "%s: alloc urb=%d\n", __func__, i);
537 s->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC);
538 if (!s->urb_list[i]) {
539 dev_dbg(&s->udev->dev, "%s: failed\n", __func__);
540 for (j = 0; j < i; j++)
541 usb_free_urb(s->urb_list[j]);
542 return -ENOMEM;
543 }
544 usb_fill_bulk_urb(s->urb_list[i],
545 s->udev,
546 usb_rcvbulkpipe(s->udev, 0x81),
547 s->buf_list[i],
548 BULK_BUFFER_SIZE,
549 rtl2832_sdr_urb_complete, s);
550
551 s->urb_list[i]->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
552 s->urb_list[i]->transfer_dma = s->dma_addr[i];
553 s->urbs_initialized++;
554 }
555
556 return 0;
557}
558
559/* Must be called with vb_queue_lock hold */
560static void rtl2832_sdr_cleanup_queued_bufs(struct rtl2832_sdr_state *s)
561{
562 unsigned long flags = 0;
563 dev_dbg(&s->udev->dev, "%s:\n", __func__);
564
565 spin_lock_irqsave(&s->queued_bufs_lock, flags);
566 while (!list_empty(&s->queued_bufs)) {
567 struct rtl2832_sdr_frame_buf *buf;
568 buf = list_entry(s->queued_bufs.next,
569 struct rtl2832_sdr_frame_buf, list);
570 list_del(&buf->list);
571 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
572 }
573 spin_unlock_irqrestore(&s->queued_bufs_lock, flags);
574}
575
576/* The user yanked out the cable... */
577static void rtl2832_sdr_release_sec(struct dvb_frontend *fe)
578{
579 struct rtl2832_sdr_state *s = fe->sec_priv;
580 dev_dbg(&s->udev->dev, "%s:\n", __func__);
581
582 mutex_lock(&s->vb_queue_lock);
583 mutex_lock(&s->v4l2_lock);
584 /* No need to keep the urbs around after disconnection */
585 s->udev = NULL;
586
587 v4l2_device_disconnect(&s->v4l2_dev);
588 video_unregister_device(&s->vdev);
589 mutex_unlock(&s->v4l2_lock);
590 mutex_unlock(&s->vb_queue_lock);
591
592 v4l2_device_put(&s->v4l2_dev);
593
594 fe->sec_priv = NULL;
595}
596
597static int rtl2832_sdr_querycap(struct file *file, void *fh,
598 struct v4l2_capability *cap)
599{
600 struct rtl2832_sdr_state *s = video_drvdata(file);
601 dev_dbg(&s->udev->dev, "%s:\n", __func__);
602
603 strlcpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
604 strlcpy(cap->card, s->vdev.name, sizeof(cap->card));
605 usb_make_path(s->udev, cap->bus_info, sizeof(cap->bus_info));
606 cap->device_caps = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_STREAMING |
607 V4L2_CAP_READWRITE | V4L2_CAP_TUNER;
608 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
609 return 0;
610}
611
612/* Videobuf2 operations */
613static int rtl2832_sdr_queue_setup(struct vb2_queue *vq,
614 const struct v4l2_format *fmt, unsigned int *nbuffers,
615 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[])
616{
617 struct rtl2832_sdr_state *s = vb2_get_drv_priv(vq);
618 dev_dbg(&s->udev->dev, "%s: *nbuffers=%d\n", __func__, *nbuffers);
619
620 /* Need at least 8 buffers */
621 if (vq->num_buffers + *nbuffers < 8)
622 *nbuffers = 8 - vq->num_buffers;
623 *nplanes = 1;
624 /* 2 = max 16-bit sample returned */
625 sizes[0] = PAGE_ALIGN(BULK_BUFFER_SIZE * 2);
626 dev_dbg(&s->udev->dev, "%s: nbuffers=%d sizes[0]=%d\n",
627 __func__, *nbuffers, sizes[0]);
628 return 0;
629}
630
631static int rtl2832_sdr_buf_prepare(struct vb2_buffer *vb)
632{
633 struct rtl2832_sdr_state *s = vb2_get_drv_priv(vb->vb2_queue);
634
635 /* Don't allow queing new buffers after device disconnection */
636 if (!s->udev)
637 return -ENODEV;
638
639 return 0;
640}
641
642static void rtl2832_sdr_buf_queue(struct vb2_buffer *vb)
643{
644 struct rtl2832_sdr_state *s = vb2_get_drv_priv(vb->vb2_queue);
645 struct rtl2832_sdr_frame_buf *buf =
646 container_of(vb, struct rtl2832_sdr_frame_buf, vb);
647 unsigned long flags = 0;
648
649 /* Check the device has not disconnected between prep and queuing */
650 if (!s->udev) {
651 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
652 return;
653 }
654
655 spin_lock_irqsave(&s->queued_bufs_lock, flags);
656 list_add_tail(&buf->list, &s->queued_bufs);
657 spin_unlock_irqrestore(&s->queued_bufs_lock, flags);
658}
659
660static int rtl2832_sdr_set_adc(struct rtl2832_sdr_state *s)
661{
662 struct dvb_frontend *fe = s->fe;
663 int ret;
664 unsigned int f_sr, f_if;
665 u8 buf[4], u8tmp1, u8tmp2;
666 u64 u64tmp;
667 u32 u32tmp;
668 dev_dbg(&s->udev->dev, "%s: f_adc=%u\n", __func__, s->f_adc);
669
670 if (!test_bit(POWER_ON, &s->flags))
671 return 0;
672
673 if (s->f_adc == 0)
674 return 0;
675
676 f_sr = s->f_adc;
677
678 ret = rtl2832_sdr_wr_regs(s, 0x13e, "\x00\x00", 2);
679 if (ret)
680 goto err;
681
682 ret = rtl2832_sdr_wr_regs(s, 0x115, "\x00\x00\x00\x00", 4);
683 if (ret)
684 goto err;
685
686 /* get IF from tuner */
687 if (fe->ops.tuner_ops.get_if_frequency)
688 ret = fe->ops.tuner_ops.get_if_frequency(fe, &f_if);
689 else
690 ret = -EINVAL;
691
692 if (ret)
693 goto err;
694
695 /* program IF */
696 u64tmp = f_if % s->cfg->xtal;
697 u64tmp *= 0x400000;
698 u64tmp = div_u64(u64tmp, s->cfg->xtal);
699 u64tmp = -u64tmp;
700 u32tmp = u64tmp & 0x3fffff;
701
702 dev_dbg(&s->udev->dev, "%s: f_if=%u if_ctl=%08x\n",
703 __func__, f_if, u32tmp);
704
705 buf[0] = (u32tmp >> 16) & 0xff;
706 buf[1] = (u32tmp >> 8) & 0xff;
707 buf[2] = (u32tmp >> 0) & 0xff;
708
709 ret = rtl2832_sdr_wr_regs(s, 0x119, buf, 3);
710 if (ret)
711 goto err;
712
713 /* BB / IF mode */
714 /* POR: 0x1b1=0x1f, 0x008=0x0d, 0x006=0x80 */
715 if (f_if) {
716 u8tmp1 = 0x1a; /* disable Zero-IF */
717 u8tmp2 = 0x8d; /* enable ADC I */
718 } else {
719 u8tmp1 = 0x1b; /* enable Zero-IF, DC, IQ */
720 u8tmp2 = 0xcd; /* enable ADC I, ADC Q */
721 }
722
723 ret = rtl2832_sdr_wr_reg(s, 0x1b1, u8tmp1);
724 if (ret)
725 goto err;
726
727 ret = rtl2832_sdr_wr_reg(s, 0x008, u8tmp2);
728 if (ret)
729 goto err;
730
731 ret = rtl2832_sdr_wr_reg(s, 0x006, 0x80);
732 if (ret)
733 goto err;
734
735 /* program sampling rate (resampling down) */
736 u32tmp = div_u64(s->cfg->xtal * 0x400000ULL, f_sr * 4U);
737 u32tmp <<= 2;
738 buf[0] = (u32tmp >> 24) & 0xff;
739 buf[1] = (u32tmp >> 16) & 0xff;
740 buf[2] = (u32tmp >> 8) & 0xff;
741 buf[3] = (u32tmp >> 0) & 0xff;
742 ret = rtl2832_sdr_wr_regs(s, 0x19f, buf, 4);
743 if (ret)
744 goto err;
745
746 /* low-pass filter */
747 ret = rtl2832_sdr_wr_regs(s, 0x11c,
748 "\xca\xdc\xd7\xd8\xe0\xf2\x0e\x35\x06\x50\x9c\x0d\x71\x11\x14\x71\x74\x19\x41\xa5",
749 20);
750 if (ret)
751 goto err;
752
753 ret = rtl2832_sdr_wr_regs(s, 0x017, "\x11\x10", 2);
754 if (ret)
755 goto err;
756
757 /* mode */
758 ret = rtl2832_sdr_wr_regs(s, 0x019, "\x05", 1);
759 if (ret)
760 goto err;
761
762 ret = rtl2832_sdr_wr_regs(s, 0x01a, "\x1b\x16\x0d\x06\x01\xff", 6);
763 if (ret)
764 goto err;
765
766 /* FSM */
767 ret = rtl2832_sdr_wr_regs(s, 0x192, "\x00\xf0\x0f", 3);
768 if (ret)
769 goto err;
770
771 /* PID filter */
772 ret = rtl2832_sdr_wr_regs(s, 0x061, "\x60", 1);
773 if (ret)
774 goto err;
775
776 /* used RF tuner based settings */
777 switch (s->cfg->tuner) {
778 case RTL2832_TUNER_E4000:
779 ret = rtl2832_sdr_wr_regs(s, 0x112, "\x5a", 1);
780 ret = rtl2832_sdr_wr_regs(s, 0x102, "\x40", 1);
781 ret = rtl2832_sdr_wr_regs(s, 0x103, "\x5a", 1);
782 ret = rtl2832_sdr_wr_regs(s, 0x1c7, "\x30", 1);
783 ret = rtl2832_sdr_wr_regs(s, 0x104, "\xd0", 1);
784 ret = rtl2832_sdr_wr_regs(s, 0x105, "\xbe", 1);
785 ret = rtl2832_sdr_wr_regs(s, 0x1c8, "\x18", 1);
786 ret = rtl2832_sdr_wr_regs(s, 0x106, "\x35", 1);
787 ret = rtl2832_sdr_wr_regs(s, 0x1c9, "\x21", 1);
788 ret = rtl2832_sdr_wr_regs(s, 0x1ca, "\x21", 1);
789 ret = rtl2832_sdr_wr_regs(s, 0x1cb, "\x00", 1);
790 ret = rtl2832_sdr_wr_regs(s, 0x107, "\x40", 1);
791 ret = rtl2832_sdr_wr_regs(s, 0x1cd, "\x10", 1);
792 ret = rtl2832_sdr_wr_regs(s, 0x1ce, "\x10", 1);
793 ret = rtl2832_sdr_wr_regs(s, 0x108, "\x80", 1);
794 ret = rtl2832_sdr_wr_regs(s, 0x109, "\x7f", 1);
795 ret = rtl2832_sdr_wr_regs(s, 0x10a, "\x80", 1);
796 ret = rtl2832_sdr_wr_regs(s, 0x10b, "\x7f", 1);
797 ret = rtl2832_sdr_wr_regs(s, 0x00e, "\xfc", 1);
798 ret = rtl2832_sdr_wr_regs(s, 0x00e, "\xfc", 1);
799 ret = rtl2832_sdr_wr_regs(s, 0x011, "\xd4", 1);
800 ret = rtl2832_sdr_wr_regs(s, 0x1e5, "\xf0", 1);
801 ret = rtl2832_sdr_wr_regs(s, 0x1d9, "\x00", 1);
802 ret = rtl2832_sdr_wr_regs(s, 0x1db, "\x00", 1);
803 ret = rtl2832_sdr_wr_regs(s, 0x1dd, "\x14", 1);
804 ret = rtl2832_sdr_wr_regs(s, 0x1de, "\xec", 1);
805 ret = rtl2832_sdr_wr_regs(s, 0x1d8, "\x0c", 1);
806 ret = rtl2832_sdr_wr_regs(s, 0x1e6, "\x02", 1);
807 ret = rtl2832_sdr_wr_regs(s, 0x1d7, "\x09", 1);
808 ret = rtl2832_sdr_wr_regs(s, 0x00d, "\x83", 1);
809 ret = rtl2832_sdr_wr_regs(s, 0x010, "\x49", 1);
810 ret = rtl2832_sdr_wr_regs(s, 0x00d, "\x87", 1);
811 ret = rtl2832_sdr_wr_regs(s, 0x00d, "\x85", 1);
812 ret = rtl2832_sdr_wr_regs(s, 0x013, "\x02", 1);
813 break;
814 case RTL2832_TUNER_FC0012:
815 case RTL2832_TUNER_FC0013:
816 ret = rtl2832_sdr_wr_regs(s, 0x112, "\x5a", 1);
817 ret = rtl2832_sdr_wr_regs(s, 0x102, "\x40", 1);
818 ret = rtl2832_sdr_wr_regs(s, 0x103, "\x5a", 1);
819 ret = rtl2832_sdr_wr_regs(s, 0x1c7, "\x2c", 1);
820 ret = rtl2832_sdr_wr_regs(s, 0x104, "\xcc", 1);
821 ret = rtl2832_sdr_wr_regs(s, 0x105, "\xbe", 1);
822 ret = rtl2832_sdr_wr_regs(s, 0x1c8, "\x16", 1);
823 ret = rtl2832_sdr_wr_regs(s, 0x106, "\x35", 1);
824 ret = rtl2832_sdr_wr_regs(s, 0x1c9, "\x21", 1);
825 ret = rtl2832_sdr_wr_regs(s, 0x1ca, "\x21", 1);
826 ret = rtl2832_sdr_wr_regs(s, 0x1cb, "\x00", 1);
827 ret = rtl2832_sdr_wr_regs(s, 0x107, "\x40", 1);
828 ret = rtl2832_sdr_wr_regs(s, 0x1cd, "\x10", 1);
829 ret = rtl2832_sdr_wr_regs(s, 0x1ce, "\x10", 1);
830 ret = rtl2832_sdr_wr_regs(s, 0x108, "\x80", 1);
831 ret = rtl2832_sdr_wr_regs(s, 0x109, "\x7f", 1);
832 ret = rtl2832_sdr_wr_regs(s, 0x10a, "\x80", 1);
833 ret = rtl2832_sdr_wr_regs(s, 0x10b, "\x7f", 1);
834 ret = rtl2832_sdr_wr_regs(s, 0x00e, "\xfc", 1);
835 ret = rtl2832_sdr_wr_regs(s, 0x00e, "\xfc", 1);
836 ret = rtl2832_sdr_wr_regs(s, 0x011, "\xe9\xbf", 2);
837 ret = rtl2832_sdr_wr_regs(s, 0x1e5, "\xf0", 1);
838 ret = rtl2832_sdr_wr_regs(s, 0x1d9, "\x00", 1);
839 ret = rtl2832_sdr_wr_regs(s, 0x1db, "\x00", 1);
840 ret = rtl2832_sdr_wr_regs(s, 0x1dd, "\x11", 1);
841 ret = rtl2832_sdr_wr_regs(s, 0x1de, "\xef", 1);
842 ret = rtl2832_sdr_wr_regs(s, 0x1d8, "\x0c", 1);
843 ret = rtl2832_sdr_wr_regs(s, 0x1e6, "\x02", 1);
844 ret = rtl2832_sdr_wr_regs(s, 0x1d7, "\x09", 1);
845 break;
846 case RTL2832_TUNER_R820T:
847 ret = rtl2832_sdr_wr_regs(s, 0x112, "\x5a", 1);
848 ret = rtl2832_sdr_wr_regs(s, 0x102, "\x40", 1);
849 ret = rtl2832_sdr_wr_regs(s, 0x115, "\x01", 1);
850 ret = rtl2832_sdr_wr_regs(s, 0x103, "\x80", 1);
851 ret = rtl2832_sdr_wr_regs(s, 0x1c7, "\x24", 1);
852 ret = rtl2832_sdr_wr_regs(s, 0x104, "\xcc", 1);
853 ret = rtl2832_sdr_wr_regs(s, 0x105, "\xbe", 1);
854 ret = rtl2832_sdr_wr_regs(s, 0x1c8, "\x14", 1);
855 ret = rtl2832_sdr_wr_regs(s, 0x106, "\x35", 1);
856 ret = rtl2832_sdr_wr_regs(s, 0x1c9, "\x21", 1);
857 ret = rtl2832_sdr_wr_regs(s, 0x1ca, "\x21", 1);
858 ret = rtl2832_sdr_wr_regs(s, 0x1cb, "\x00", 1);
859 ret = rtl2832_sdr_wr_regs(s, 0x107, "\x40", 1);
860 ret = rtl2832_sdr_wr_regs(s, 0x1cd, "\x10", 1);
861 ret = rtl2832_sdr_wr_regs(s, 0x1ce, "\x10", 1);
862 ret = rtl2832_sdr_wr_regs(s, 0x108, "\x80", 1);
863 ret = rtl2832_sdr_wr_regs(s, 0x109, "\x7f", 1);
864 ret = rtl2832_sdr_wr_regs(s, 0x10a, "\x80", 1);
865 ret = rtl2832_sdr_wr_regs(s, 0x10b, "\x7f", 1);
866 ret = rtl2832_sdr_wr_regs(s, 0x00e, "\xfc", 1);
867 ret = rtl2832_sdr_wr_regs(s, 0x00e, "\xfc", 1);
868 ret = rtl2832_sdr_wr_regs(s, 0x011, "\xf4", 1);
869 break;
870 default:
871 dev_notice(&s->udev->dev, "Unsupported tuner\n");
872 }
873
874 /* software reset */
875 ret = rtl2832_sdr_wr_reg_mask(s, 0x101, 0x04, 0x04);
876 if (ret)
877 goto err;
878
879 ret = rtl2832_sdr_wr_reg_mask(s, 0x101, 0x00, 0x04);
880 if (ret)
881 goto err;
882err:
883 return ret;
884};
885
886static void rtl2832_sdr_unset_adc(struct rtl2832_sdr_state *s)
887{
888 int ret;
889
890 dev_dbg(&s->udev->dev, "%s:\n", __func__);
891
892 /* PID filter */
893 ret = rtl2832_sdr_wr_regs(s, 0x061, "\xe0", 1);
894 if (ret)
895 goto err;
896
897 /* mode */
898 ret = rtl2832_sdr_wr_regs(s, 0x019, "\x20", 1);
899 if (ret)
900 goto err;
901
902 ret = rtl2832_sdr_wr_regs(s, 0x017, "\x11\x10", 2);
903 if (ret)
904 goto err;
905
906 /* FSM */
907 ret = rtl2832_sdr_wr_regs(s, 0x192, "\x00\x0f\xff", 3);
908 if (ret)
909 goto err;
910
911 ret = rtl2832_sdr_wr_regs(s, 0x13e, "\x40\x00", 2);
912 if (ret)
913 goto err;
914
915 ret = rtl2832_sdr_wr_regs(s, 0x115, "\x06\x3f\xce\xcc", 4);
916 if (ret)
917 goto err;
918err:
919 return;
920};
921
922static int rtl2832_sdr_set_tuner_freq(struct rtl2832_sdr_state *s)
923{
924 struct dvb_frontend *fe = s->fe;
925 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
926 struct v4l2_ctrl *bandwidth_auto;
927 struct v4l2_ctrl *bandwidth;
928
929 /*
930 * tuner RF (Hz)
931 */
932 if (s->f_tuner == 0)
933 return 0;
934
935 /*
936 * bandwidth (Hz)
937 */
938 bandwidth_auto = v4l2_ctrl_find(&s->hdl, V4L2_CID_RF_TUNER_BANDWIDTH_AUTO);
939 bandwidth = v4l2_ctrl_find(&s->hdl, V4L2_CID_RF_TUNER_BANDWIDTH);
940 if (v4l2_ctrl_g_ctrl(bandwidth_auto)) {
941 c->bandwidth_hz = s->f_adc;
942 v4l2_ctrl_s_ctrl(bandwidth, s->f_adc);
943 } else {
944 c->bandwidth_hz = v4l2_ctrl_g_ctrl(bandwidth);
945 }
946
947 c->frequency = s->f_tuner;
948 c->delivery_system = SYS_DVBT;
949
950 dev_dbg(&s->udev->dev, "%s: frequency=%u bandwidth=%d\n",
951 __func__, c->frequency, c->bandwidth_hz);
952
953 if (!test_bit(POWER_ON, &s->flags))
954 return 0;
955
956 if (fe->ops.tuner_ops.set_params)
957 fe->ops.tuner_ops.set_params(fe);
958
959 return 0;
960};
961
962static int rtl2832_sdr_set_tuner(struct rtl2832_sdr_state *s)
963{
964 struct dvb_frontend *fe = s->fe;
965
966 dev_dbg(&s->udev->dev, "%s:\n", __func__);
967
968 if (fe->ops.tuner_ops.init)
969 fe->ops.tuner_ops.init(fe);
970
971 return 0;
972};
973
974static void rtl2832_sdr_unset_tuner(struct rtl2832_sdr_state *s)
975{
976 struct dvb_frontend *fe = s->fe;
977
978 dev_dbg(&s->udev->dev, "%s:\n", __func__);
979
980 if (fe->ops.tuner_ops.sleep)
981 fe->ops.tuner_ops.sleep(fe);
982
983 return;
984};
985
986static int rtl2832_sdr_start_streaming(struct vb2_queue *vq, unsigned int count)
987{
988 struct rtl2832_sdr_state *s = vb2_get_drv_priv(vq);
989 int ret;
990 dev_dbg(&s->udev->dev, "%s:\n", __func__);
991
992 if (!s->udev)
993 return -ENODEV;
994
995 if (mutex_lock_interruptible(&s->v4l2_lock))
996 return -ERESTARTSYS;
997
998 if (s->d->props->power_ctrl)
999 s->d->props->power_ctrl(s->d, 1);
1000
1001 set_bit(POWER_ON, &s->flags);
1002
1003 ret = rtl2832_sdr_set_tuner(s);
1004 if (ret)
1005 goto err;
1006
1007 ret = rtl2832_sdr_set_tuner_freq(s);
1008 if (ret)
1009 goto err;
1010
1011 ret = rtl2832_sdr_set_adc(s);
1012 if (ret)
1013 goto err;
1014
1015 ret = rtl2832_sdr_alloc_stream_bufs(s);
1016 if (ret)
1017 goto err;
1018
1019 ret = rtl2832_sdr_alloc_urbs(s);
1020 if (ret)
1021 goto err;
1022
1023 s->sequence = 0;
1024
1025 ret = rtl2832_sdr_submit_urbs(s);
1026 if (ret)
1027 goto err;
1028
1029err:
1030 mutex_unlock(&s->v4l2_lock);
1031
1032 return ret;
1033}
1034
1035static int rtl2832_sdr_stop_streaming(struct vb2_queue *vq)
1036{
1037 struct rtl2832_sdr_state *s = vb2_get_drv_priv(vq);
1038 dev_dbg(&s->udev->dev, "%s:\n", __func__);
1039
1040 if (mutex_lock_interruptible(&s->v4l2_lock))
1041 return -ERESTARTSYS;
1042
1043 rtl2832_sdr_kill_urbs(s);
1044 rtl2832_sdr_free_urbs(s);
1045 rtl2832_sdr_free_stream_bufs(s);
1046 rtl2832_sdr_cleanup_queued_bufs(s);
1047 rtl2832_sdr_unset_adc(s);
1048 rtl2832_sdr_unset_tuner(s);
1049
1050 clear_bit(POWER_ON, &s->flags);
1051
1052 if (s->d->props->power_ctrl)
1053 s->d->props->power_ctrl(s->d, 0);
1054
1055 mutex_unlock(&s->v4l2_lock);
1056
1057 return 0;
1058}
1059
1060static struct vb2_ops rtl2832_sdr_vb2_ops = {
1061 .queue_setup = rtl2832_sdr_queue_setup,
1062 .buf_prepare = rtl2832_sdr_buf_prepare,
1063 .buf_queue = rtl2832_sdr_buf_queue,
1064 .start_streaming = rtl2832_sdr_start_streaming,
1065 .stop_streaming = rtl2832_sdr_stop_streaming,
1066 .wait_prepare = vb2_ops_wait_prepare,
1067 .wait_finish = vb2_ops_wait_finish,
1068};
1069
1070static int rtl2832_sdr_g_tuner(struct file *file, void *priv,
1071 struct v4l2_tuner *v)
1072{
1073 struct rtl2832_sdr_state *s = video_drvdata(file);
1074 dev_dbg(&s->udev->dev, "%s: index=%d type=%d\n",
1075 __func__, v->index, v->type);
1076
1077 if (v->index == 0) {
1078 strlcpy(v->name, "ADC: Realtek RTL2832", sizeof(v->name));
1079 v->type = V4L2_TUNER_ADC;
1080 v->capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS;
1081 v->rangelow = 300000;
1082 v->rangehigh = 3200000;
1083 } else if (v->index == 1) {
1084 strlcpy(v->name, "RF: <unknown>", sizeof(v->name));
1085 v->type = V4L2_TUNER_RF;
1086 v->capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS;
1087 v->rangelow = 50000000;
1088 v->rangehigh = 2000000000;
1089 } else {
1090 return -EINVAL;
1091 }
1092
1093 return 0;
1094}
1095
1096static int rtl2832_sdr_s_tuner(struct file *file, void *priv,
1097 const struct v4l2_tuner *v)
1098{
1099 struct rtl2832_sdr_state *s = video_drvdata(file);
1100 dev_dbg(&s->udev->dev, "%s:\n", __func__);
1101
1102 if (v->index > 1)
1103 return -EINVAL;
1104 return 0;
1105}
1106
1107static int rtl2832_sdr_enum_freq_bands(struct file *file, void *priv,
1108 struct v4l2_frequency_band *band)
1109{
1110 struct rtl2832_sdr_state *s = video_drvdata(file);
1111 dev_dbg(&s->udev->dev, "%s: tuner=%d type=%d index=%d\n",
1112 __func__, band->tuner, band->type, band->index);
1113
1114 if (band->tuner == 0) {
1115 if (band->index >= ARRAY_SIZE(bands_adc))
1116 return -EINVAL;
1117
1118 *band = bands_adc[band->index];
1119 } else if (band->tuner == 1) {
1120 if (band->index >= ARRAY_SIZE(bands_fm))
1121 return -EINVAL;
1122
1123 *band = bands_fm[band->index];
1124 } else {
1125 return -EINVAL;
1126 }
1127
1128 return 0;
1129}
1130
1131static int rtl2832_sdr_g_frequency(struct file *file, void *priv,
1132 struct v4l2_frequency *f)
1133{
1134 struct rtl2832_sdr_state *s = video_drvdata(file);
1135 int ret = 0;
1136 dev_dbg(&s->udev->dev, "%s: tuner=%d type=%d\n",
1137 __func__, f->tuner, f->type);
1138
1139 if (f->tuner == 0) {
1140 f->frequency = s->f_adc;
1141 f->type = V4L2_TUNER_ADC;
1142 } else if (f->tuner == 1) {
1143 f->frequency = s->f_tuner;
1144 f->type = V4L2_TUNER_RF;
1145 } else {
1146 return -EINVAL;
1147 }
1148
1149 return ret;
1150}
1151
1152static int rtl2832_sdr_s_frequency(struct file *file, void *priv,
1153 const struct v4l2_frequency *f)
1154{
1155 struct rtl2832_sdr_state *s = video_drvdata(file);
1156 int ret, band;
1157
1158 dev_dbg(&s->udev->dev, "%s: tuner=%d type=%d frequency=%u\n",
1159 __func__, f->tuner, f->type, f->frequency);
1160
1161 /* ADC band midpoints */
1162 #define BAND_ADC_0 ((bands_adc[0].rangehigh + bands_adc[1].rangelow) / 2)
1163 #define BAND_ADC_1 ((bands_adc[1].rangehigh + bands_adc[2].rangelow) / 2)
1164
1165 if (f->tuner == 0 && f->type == V4L2_TUNER_ADC) {
1166 if (f->frequency < BAND_ADC_0)
1167 band = 0;
1168 else if (f->frequency < BAND_ADC_1)
1169 band = 1;
1170 else
1171 band = 2;
1172
1173 s->f_adc = clamp_t(unsigned int, f->frequency,
1174 bands_adc[band].rangelow,
1175 bands_adc[band].rangehigh);
1176
1177 dev_dbg(&s->udev->dev, "%s: ADC frequency=%u Hz\n",
1178 __func__, s->f_adc);
1179 ret = rtl2832_sdr_set_adc(s);
1180 } else if (f->tuner == 1) {
1181 s->f_tuner = clamp_t(unsigned int, f->frequency,
1182 bands_fm[0].rangelow,
1183 bands_fm[0].rangehigh);
1184 dev_dbg(&s->udev->dev, "%s: RF frequency=%u Hz\n",
1185 __func__, f->frequency);
1186
1187 ret = rtl2832_sdr_set_tuner_freq(s);
1188 } else {
1189 ret = -EINVAL;
1190 }
1191
1192 return ret;
1193}
1194
1195static int rtl2832_sdr_enum_fmt_sdr_cap(struct file *file, void *priv,
1196 struct v4l2_fmtdesc *f)
1197{
1198 struct rtl2832_sdr_state *s = video_drvdata(file);
1199 dev_dbg(&s->udev->dev, "%s:\n", __func__);
1200
1201 if (f->index >= NUM_FORMATS)
1202 return -EINVAL;
1203
1204 strlcpy(f->description, formats[f->index].name, sizeof(f->description));
1205 f->pixelformat = formats[f->index].pixelformat;
1206
1207 return 0;
1208}
1209
1210static int rtl2832_sdr_g_fmt_sdr_cap(struct file *file, void *priv,
1211 struct v4l2_format *f)
1212{
1213 struct rtl2832_sdr_state *s = video_drvdata(file);
1214 dev_dbg(&s->udev->dev, "%s:\n", __func__);
1215
1216 f->fmt.sdr.pixelformat = s->pixelformat;
1217 memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
1218
1219 return 0;
1220}
1221
1222static int rtl2832_sdr_s_fmt_sdr_cap(struct file *file, void *priv,
1223 struct v4l2_format *f)
1224{
1225 struct rtl2832_sdr_state *s = video_drvdata(file);
1226 struct vb2_queue *q = &s->vb_queue;
1227 int i;
1228 dev_dbg(&s->udev->dev, "%s: pixelformat fourcc %4.4s\n", __func__,
1229 (char *)&f->fmt.sdr.pixelformat);
1230
1231 if (vb2_is_busy(q))
1232 return -EBUSY;
1233
1234 memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
1235 for (i = 0; i < NUM_FORMATS; i++) {
1236 if (formats[i].pixelformat == f->fmt.sdr.pixelformat) {
1237 s->pixelformat = f->fmt.sdr.pixelformat;
1238 return 0;
1239 }
1240 }
1241
1242 f->fmt.sdr.pixelformat = formats[0].pixelformat;
1243 s->pixelformat = formats[0].pixelformat;
1244
1245 return 0;
1246}
1247
1248static int rtl2832_sdr_try_fmt_sdr_cap(struct file *file, void *priv,
1249 struct v4l2_format *f)
1250{
1251 struct rtl2832_sdr_state *s = video_drvdata(file);
1252 int i;
1253 dev_dbg(&s->udev->dev, "%s: pixelformat fourcc %4.4s\n", __func__,
1254 (char *)&f->fmt.sdr.pixelformat);
1255
1256 memset(f->fmt.sdr.reserved, 0, sizeof(f->fmt.sdr.reserved));
1257 for (i = 0; i < NUM_FORMATS; i++) {
1258 if (formats[i].pixelformat == f->fmt.sdr.pixelformat)
1259 return 0;
1260 }
1261
1262 f->fmt.sdr.pixelformat = formats[0].pixelformat;
1263
1264 return 0;
1265}
1266
1267static const struct v4l2_ioctl_ops rtl2832_sdr_ioctl_ops = {
1268 .vidioc_querycap = rtl2832_sdr_querycap,
1269
1270 .vidioc_enum_fmt_sdr_cap = rtl2832_sdr_enum_fmt_sdr_cap,
1271 .vidioc_g_fmt_sdr_cap = rtl2832_sdr_g_fmt_sdr_cap,
1272 .vidioc_s_fmt_sdr_cap = rtl2832_sdr_s_fmt_sdr_cap,
1273 .vidioc_try_fmt_sdr_cap = rtl2832_sdr_try_fmt_sdr_cap,
1274
1275 .vidioc_reqbufs = vb2_ioctl_reqbufs,
1276 .vidioc_create_bufs = vb2_ioctl_create_bufs,
1277 .vidioc_prepare_buf = vb2_ioctl_prepare_buf,
1278 .vidioc_querybuf = vb2_ioctl_querybuf,
1279 .vidioc_qbuf = vb2_ioctl_qbuf,
1280 .vidioc_dqbuf = vb2_ioctl_dqbuf,
1281
1282 .vidioc_streamon = vb2_ioctl_streamon,
1283 .vidioc_streamoff = vb2_ioctl_streamoff,
1284
1285 .vidioc_g_tuner = rtl2832_sdr_g_tuner,
1286 .vidioc_s_tuner = rtl2832_sdr_s_tuner,
1287
1288 .vidioc_enum_freq_bands = rtl2832_sdr_enum_freq_bands,
1289 .vidioc_g_frequency = rtl2832_sdr_g_frequency,
1290 .vidioc_s_frequency = rtl2832_sdr_s_frequency,
1291
1292 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
1293 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1294 .vidioc_log_status = v4l2_ctrl_log_status,
1295};
1296
1297static const struct v4l2_file_operations rtl2832_sdr_fops = {
1298 .owner = THIS_MODULE,
1299 .open = v4l2_fh_open,
1300 .release = vb2_fop_release,
1301 .read = vb2_fop_read,
1302 .poll = vb2_fop_poll,
1303 .mmap = vb2_fop_mmap,
1304 .unlocked_ioctl = video_ioctl2,
1305};
1306
1307static struct video_device rtl2832_sdr_template = {
1308 .name = "Realtek RTL2832 SDR",
1309 .release = video_device_release_empty,
1310 .fops = &rtl2832_sdr_fops,
1311 .ioctl_ops = &rtl2832_sdr_ioctl_ops,
1312};
1313
1314static int rtl2832_sdr_s_ctrl(struct v4l2_ctrl *ctrl)
1315{
1316 struct rtl2832_sdr_state *s =
1317 container_of(ctrl->handler, struct rtl2832_sdr_state,
1318 hdl);
1319 struct dvb_frontend *fe = s->fe;
1320 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1321 int ret;
1322 dev_dbg(&s->udev->dev,
1323 "%s: id=%d name=%s val=%d min=%d max=%d step=%d\n",
1324 __func__, ctrl->id, ctrl->name, ctrl->val,
1325 ctrl->minimum, ctrl->maximum, ctrl->step);
1326
1327 switch (ctrl->id) {
1328 case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO:
1329 case V4L2_CID_RF_TUNER_BANDWIDTH:
1330 /* TODO: these controls should be moved to tuner drivers */
1331 if (s->bandwidth_auto->val) {
1332 /* Round towards the closest legal value */
1333 s32 val = s->f_adc + s->bandwidth->step / 2;
1334 u32 offset;
1335 val = clamp(val, s->bandwidth->minimum, s->bandwidth->maximum);
1336 offset = val - s->bandwidth->minimum;
1337 offset = s->bandwidth->step * (offset / s->bandwidth->step);
1338 s->bandwidth->val = s->bandwidth->minimum + offset;
1339 }
1340
1341 c->bandwidth_hz = s->bandwidth->val;
1342
1343 if (!test_bit(POWER_ON, &s->flags))
1344 return 0;
1345
1346 if (fe->ops.tuner_ops.set_params)
1347 ret = fe->ops.tuner_ops.set_params(fe);
1348 else
1349 ret = 0;
1350 break;
1351 default:
1352 ret = -EINVAL;
1353 }
1354
1355 return ret;
1356}
1357
1358static const struct v4l2_ctrl_ops rtl2832_sdr_ctrl_ops = {
1359 .s_ctrl = rtl2832_sdr_s_ctrl,
1360};
1361
1362static void rtl2832_sdr_video_release(struct v4l2_device *v)
1363{
1364 struct rtl2832_sdr_state *s =
1365 container_of(v, struct rtl2832_sdr_state, v4l2_dev);
1366
1367 v4l2_ctrl_handler_free(&s->hdl);
1368 v4l2_device_unregister(&s->v4l2_dev);
1369 kfree(s);
1370}
1371
1372struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
1373 struct i2c_adapter *i2c, const struct rtl2832_config *cfg,
1374 struct v4l2_subdev *sd)
1375{
1376 int ret;
1377 struct rtl2832_sdr_state *s;
1378 const struct v4l2_ctrl_ops *ops = &rtl2832_sdr_ctrl_ops;
1379 struct dvb_usb_device *d = i2c_get_adapdata(i2c);
1380
1381 s = kzalloc(sizeof(struct rtl2832_sdr_state), GFP_KERNEL);
1382 if (s == NULL) {
1383 dev_err(&d->udev->dev,
1384 "Could not allocate memory for rtl2832_sdr_state\n");
1385 return NULL;
1386 }
1387
1388 /* setup the state */
1389 s->fe = fe;
1390 s->d = d;
1391 s->udev = d->udev;
1392 s->i2c = i2c;
1393 s->cfg = cfg;
1394 s->f_adc = bands_adc[0].rangelow;
1395 s->f_tuner = bands_fm[0].rangelow;
1396 s->pixelformat = V4L2_SDR_FMT_CU8;
1397
1398 mutex_init(&s->v4l2_lock);
1399 mutex_init(&s->vb_queue_lock);
1400 spin_lock_init(&s->queued_bufs_lock);
1401 INIT_LIST_HEAD(&s->queued_bufs);
1402
1403 /* Init videobuf2 queue structure */
1404 s->vb_queue.type = V4L2_BUF_TYPE_SDR_CAPTURE;
1405 s->vb_queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
1406 s->vb_queue.drv_priv = s;
1407 s->vb_queue.buf_struct_size = sizeof(struct rtl2832_sdr_frame_buf);
1408 s->vb_queue.ops = &rtl2832_sdr_vb2_ops;
1409 s->vb_queue.mem_ops = &vb2_vmalloc_memops;
1410 s->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1411 ret = vb2_queue_init(&s->vb_queue);
1412 if (ret) {
1413 dev_err(&s->udev->dev, "Could not initialize vb2 queue\n");
1414 goto err_free_mem;
1415 }
1416
1417 /* Register controls */
1418 switch (s->cfg->tuner) {
1419 case RTL2832_TUNER_E4000:
1420 v4l2_ctrl_handler_init(&s->hdl, 9);
1421 if (sd)
1422 v4l2_ctrl_add_handler(&s->hdl, sd->ctrl_handler, NULL);
1423 break;
1424 case RTL2832_TUNER_R820T:
1425 v4l2_ctrl_handler_init(&s->hdl, 2);
1426 s->bandwidth_auto = v4l2_ctrl_new_std(&s->hdl, ops, V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1);
1427 s->bandwidth = v4l2_ctrl_new_std(&s->hdl, ops, V4L2_CID_RF_TUNER_BANDWIDTH, 0, 8000000, 100000, 0);
1428 v4l2_ctrl_auto_cluster(2, &s->bandwidth_auto, 0, false);
1429 break;
1430 case RTL2832_TUNER_FC0012:
1431 case RTL2832_TUNER_FC0013:
1432 v4l2_ctrl_handler_init(&s->hdl, 2);
1433 s->bandwidth_auto = v4l2_ctrl_new_std(&s->hdl, ops, V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1);
1434 s->bandwidth = v4l2_ctrl_new_std(&s->hdl, ops, V4L2_CID_RF_TUNER_BANDWIDTH, 6000000, 8000000, 1000000, 6000000);
1435 v4l2_ctrl_auto_cluster(2, &s->bandwidth_auto, 0, false);
1436 break;
1437 default:
1438 v4l2_ctrl_handler_init(&s->hdl, 0);
1439 dev_notice(&s->udev->dev, "%s: Unsupported tuner\n",
1440 KBUILD_MODNAME);
1441 goto err_free_controls;
1442 }
1443
1444 if (s->hdl.error) {
1445 ret = s->hdl.error;
1446 dev_err(&s->udev->dev, "Could not initialize controls\n");
1447 goto err_free_controls;
1448 }
1449
1450 /* Init video_device structure */
1451 s->vdev = rtl2832_sdr_template;
1452 s->vdev.queue = &s->vb_queue;
1453 s->vdev.queue->lock = &s->vb_queue_lock;
1454 set_bit(V4L2_FL_USE_FH_PRIO, &s->vdev.flags);
1455 video_set_drvdata(&s->vdev, s);
1456
1457 /* Register the v4l2_device structure */
1458 s->v4l2_dev.release = rtl2832_sdr_video_release;
1459 ret = v4l2_device_register(&s->udev->dev, &s->v4l2_dev);
1460 if (ret) {
1461 dev_err(&s->udev->dev,
1462 "Failed to register v4l2-device (%d)\n", ret);
1463 goto err_free_controls;
1464 }
1465
1466 s->v4l2_dev.ctrl_handler = &s->hdl;
1467 s->vdev.v4l2_dev = &s->v4l2_dev;
1468 s->vdev.lock = &s->v4l2_lock;
1469 s->vdev.vfl_dir = VFL_DIR_RX;
1470
1471 ret = video_register_device(&s->vdev, VFL_TYPE_SDR, -1);
1472 if (ret) {
1473 dev_err(&s->udev->dev,
1474 "Failed to register as video device (%d)\n",
1475 ret);
1476 goto err_unregister_v4l2_dev;
1477 }
1478 dev_info(&s->udev->dev, "Registered as %s\n",
1479 video_device_node_name(&s->vdev));
1480
1481 fe->sec_priv = s;
1482 fe->ops.release_sec = rtl2832_sdr_release_sec;
1483
1484 dev_info(&s->i2c->dev, "%s: Realtek RTL2832 SDR attached\n",
1485 KBUILD_MODNAME);
1486 return fe;
1487
1488err_unregister_v4l2_dev:
1489 v4l2_device_unregister(&s->v4l2_dev);
1490err_free_controls:
1491 v4l2_ctrl_handler_free(&s->hdl);
1492err_free_mem:
1493 kfree(s);
1494 return NULL;
1495}
1496EXPORT_SYMBOL(rtl2832_sdr_attach);
1497
1498MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
1499MODULE_DESCRIPTION("Realtek RTL2832 SDR driver");
1500MODULE_LICENSE("GPL");
diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.h b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.h
new file mode 100644
index 000000000000..b865fadf184f
--- /dev/null
+++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.h
@@ -0,0 +1,54 @@
1/*
2 * Realtek RTL2832U SDR driver
3 *
4 * Copyright (C) 2013 Antti Palosaari <crope@iki.fi>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * GNU Radio plugin "gr-kernel" for device usage will be on:
21 * http://git.linuxtv.org/anttip/gr-kernel.git
22 *
23 * TODO:
24 * Help is very highly welcome for these + all the others you could imagine:
25 * - move controls to V4L2 API
26 * - use libv4l2 for stream format conversions
27 * - gr-kernel: switch to v4l2_mmap (current read eats a lot of cpu)
28 * - SDRSharp support
29 */
30
31#ifndef RTL2832_SDR_H
32#define RTL2832_SDR_H
33
34#include <linux/kconfig.h>
35#include <media/v4l2-subdev.h>
36
37/* for config struct */
38#include "rtl2832.h"
39
40#if IS_ENABLED(CONFIG_DVB_RTL2832_SDR)
41extern struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
42 struct i2c_adapter *i2c, const struct rtl2832_config *cfg,
43 struct v4l2_subdev *sd);
44#else
45static inline struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
46 struct i2c_adapter *i2c, const struct rtl2832_config *cfg,
47 struct v4l2_subdev *sd)
48{
49 dev_warn(&i2c->dev, "%s: driver disabled by Kconfig\n", __func__);
50 return NULL;
51}
52#endif
53
54#endif /* RTL2832_SDR_H */
diff --git a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
index 5aeb9c0c2781..2cbe088f1697 100644
--- a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
+++ b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c
@@ -1295,7 +1295,7 @@ static struct solo_enc_dev *solo_enc_alloc(struct solo_dev *solo_dev,
1295 solo_enc->vidq.mem_ops = &vb2_dma_sg_memops; 1295 solo_enc->vidq.mem_ops = &vb2_dma_sg_memops;
1296 solo_enc->vidq.drv_priv = solo_enc; 1296 solo_enc->vidq.drv_priv = solo_enc;
1297 solo_enc->vidq.gfp_flags = __GFP_DMA32; 1297 solo_enc->vidq.gfp_flags = __GFP_DMA32;
1298 solo_enc->vidq.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 1298 solo_enc->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1299 solo_enc->vidq.buf_struct_size = sizeof(struct solo_vb2_buf); 1299 solo_enc->vidq.buf_struct_size = sizeof(struct solo_vb2_buf);
1300 solo_enc->vidq.lock = &solo_enc->lock; 1300 solo_enc->vidq.lock = &solo_enc->lock;
1301 ret = vb2_queue_init(&solo_enc->vidq); 1301 ret = vb2_queue_init(&solo_enc->vidq);
diff --git a/drivers/staging/media/solo6x10/solo6x10-v4l2.c b/drivers/staging/media/solo6x10/solo6x10-v4l2.c
index 47e72dac9b13..1815f765d033 100644
--- a/drivers/staging/media/solo6x10/solo6x10-v4l2.c
+++ b/drivers/staging/media/solo6x10/solo6x10-v4l2.c
@@ -676,7 +676,7 @@ int solo_v4l2_init(struct solo_dev *solo_dev, unsigned nr)
676 solo_dev->vidq.ops = &solo_video_qops; 676 solo_dev->vidq.ops = &solo_video_qops;
677 solo_dev->vidq.mem_ops = &vb2_dma_contig_memops; 677 solo_dev->vidq.mem_ops = &vb2_dma_contig_memops;
678 solo_dev->vidq.drv_priv = solo_dev; 678 solo_dev->vidq.drv_priv = solo_dev;
679 solo_dev->vidq.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; 679 solo_dev->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
680 solo_dev->vidq.gfp_flags = __GFP_DMA32; 680 solo_dev->vidq.gfp_flags = __GFP_DMA32;
681 solo_dev->vidq.buf_struct_size = sizeof(struct solo_vb2_buf); 681 solo_dev->vidq.buf_struct_size = sizeof(struct solo_vb2_buf);
682 solo_dev->vidq.lock = &solo_dev->lock; 682 solo_dev->vidq.lock = &solo_dev->lock;
diff --git a/include/media/adv7842.h b/include/media/adv7842.h
index 39322091e8b0..924cbb8d004a 100644
--- a/include/media/adv7842.h
+++ b/include/media/adv7842.h
@@ -220,6 +220,9 @@ struct adv7842_platform_data {
220 unsigned sdp_free_run_cbar_en:1; 220 unsigned sdp_free_run_cbar_en:1;
221 unsigned sdp_free_run_force:1; 221 unsigned sdp_free_run_force:1;
222 222
223 /* HPA manual (0) or auto (1), affects HDMI register 0x69 */
224 unsigned hpa_auto:1;
225
223 struct adv7842_sdp_csc_coeff sdp_csc_coeff; 226 struct adv7842_sdp_csc_coeff sdp_csc_coeff;
224 227
225 struct adv7842_sdp_io_sync_adjustment sdp_io_sync_625; 228 struct adv7842_sdp_io_sync_adjustment sdp_io_sync_625;
diff --git a/include/media/lm3646.h b/include/media/lm3646.h
new file mode 100644
index 000000000000..c6acf5a1d640
--- /dev/null
+++ b/include/media/lm3646.h
@@ -0,0 +1,87 @@
1/*
2 * include/media/lm3646.h
3 *
4 * Copyright (C) 2014 Texas Instruments
5 *
6 * Contact: Daniel Jeong <gshark.jeong@gmail.com>
7 * Ldd-Mlp <ldd-mlp@list.ti.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 */
13
14#ifndef __LM3646_H__
15#define __LM3646_H__
16
17#include <media/v4l2-subdev.h>
18
19#define LM3646_NAME "lm3646"
20#define LM3646_I2C_ADDR_REV1 (0x67)
21#define LM3646_I2C_ADDR_REV0 (0x63)
22
23/* TOTAL FLASH Brightness Max
24 * min 93350uA, step 93750uA, max 1499600uA
25 */
26#define LM3646_TOTAL_FLASH_BRT_MIN 93350
27#define LM3646_TOTAL_FLASH_BRT_STEP 93750
28#define LM3646_TOTAL_FLASH_BRT_MAX 1499600
29#define LM3646_TOTAL_FLASH_BRT_uA_TO_REG(a) \
30 ((a) < LM3646_TOTAL_FLASH_BRT_MIN ? 0 : \
31 ((((a) - LM3646_TOTAL_FLASH_BRT_MIN) / LM3646_TOTAL_FLASH_BRT_STEP)))
32
33/* TOTAL TORCH Brightness Max
34 * min 23040uA, step 23430uA, max 187100uA
35 */
36#define LM3646_TOTAL_TORCH_BRT_MIN 23040
37#define LM3646_TOTAL_TORCH_BRT_STEP 23430
38#define LM3646_TOTAL_TORCH_BRT_MAX 187100
39#define LM3646_TOTAL_TORCH_BRT_uA_TO_REG(a) \
40 ((a) < LM3646_TOTAL_TORCH_BRT_MIN ? 0 : \
41 ((((a) - LM3646_TOTAL_TORCH_BRT_MIN) / LM3646_TOTAL_TORCH_BRT_STEP)))
42
43/* LED1 FLASH Brightness
44 * min 23040uA, step 11718uA, max 1499600uA
45 */
46#define LM3646_LED1_FLASH_BRT_MIN 23040
47#define LM3646_LED1_FLASH_BRT_STEP 11718
48#define LM3646_LED1_FLASH_BRT_MAX 1499600
49#define LM3646_LED1_FLASH_BRT_uA_TO_REG(a) \
50 ((a) <= LM3646_LED1_FLASH_BRT_MIN ? 0 : \
51 ((((a) - LM3646_LED1_FLASH_BRT_MIN) / LM3646_LED1_FLASH_BRT_STEP))+1)
52
53/* LED1 TORCH Brightness
54 * min 2530uA, step 1460uA, max 187100uA
55 */
56#define LM3646_LED1_TORCH_BRT_MIN 2530
57#define LM3646_LED1_TORCH_BRT_STEP 1460
58#define LM3646_LED1_TORCH_BRT_MAX 187100
59#define LM3646_LED1_TORCH_BRT_uA_TO_REG(a) \
60 ((a) <= LM3646_LED1_TORCH_BRT_MIN ? 0 : \
61 ((((a) - LM3646_LED1_TORCH_BRT_MIN) / LM3646_LED1_TORCH_BRT_STEP))+1)
62
63/* FLASH TIMEOUT DURATION
64 * min 50ms, step 50ms, max 400ms
65 */
66#define LM3646_FLASH_TOUT_MIN 50
67#define LM3646_FLASH_TOUT_STEP 50
68#define LM3646_FLASH_TOUT_MAX 400
69#define LM3646_FLASH_TOUT_ms_TO_REG(a) \
70 ((a) <= LM3646_FLASH_TOUT_MIN ? 0 : \
71 (((a) - LM3646_FLASH_TOUT_MIN) / LM3646_FLASH_TOUT_STEP))
72
73/* struct lm3646_platform_data
74 *
75 * @flash_timeout: flash timeout
76 * @led1_flash_brt: led1 flash mode brightness, uA
77 * @led1_torch_brt: led1 torch mode brightness, uA
78 */
79struct lm3646_platform_data {
80
81 u32 flash_timeout;
82
83 u32 led1_flash_brt;
84 u32 led1_torch_brt;
85};
86
87#endif /* __LM3646_H__ */
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 2f6f1f78d958..0b9f890ce431 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Remote Controller core header 2 * Remote Controller core header
3 * 3 *
4 * Copyright (C) 2009-2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 4 * Copyright (C) 2009-2010 by Mauro Carvalho Chehab
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
@@ -35,6 +35,29 @@ enum rc_driver_type {
35}; 35};
36 36
37/** 37/**
38 * struct rc_scancode_filter - Filter scan codes.
39 * @data: Scancode data to match.
40 * @mask: Mask of bits of scancode to compare.
41 */
42struct rc_scancode_filter {
43 u32 data;
44 u32 mask;
45};
46
47/**
48 * enum rc_filter_type - Filter type constants.
49 * @RC_FILTER_NORMAL: Filter for normal operation.
50 * @RC_FILTER_WAKEUP: Filter for waking from suspend.
51 * @RC_FILTER_MAX: Number of filter types.
52 */
53enum rc_filter_type {
54 RC_FILTER_NORMAL = 0,
55 RC_FILTER_WAKEUP,
56
57 RC_FILTER_MAX
58};
59
60/**
38 * struct rc_dev - represents a remote control device 61 * struct rc_dev - represents a remote control device
39 * @dev: driver model's view of this device 62 * @dev: driver model's view of this device
40 * @input_name: name of the input child device 63 * @input_name: name of the input child device
@@ -50,8 +73,10 @@ enum rc_driver_type {
50 * @input_dev: the input child device used to communicate events to userspace 73 * @input_dev: the input child device used to communicate events to userspace
51 * @driver_type: specifies if protocol decoding is done in hardware or software 74 * @driver_type: specifies if protocol decoding is done in hardware or software
52 * @idle: used to keep track of RX state 75 * @idle: used to keep track of RX state
53 * @allowed_protos: bitmask with the supported RC_BIT_* protocols 76 * @allowed_protocols: bitmask with the supported RC_BIT_* protocols for each
54 * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols 77 * filter type
78 * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols for each
79 * filter type
55 * @scanmask: some hardware decoders are not capable of providing the full 80 * @scanmask: some hardware decoders are not capable of providing the full
56 * scancode to the application. As this is a hardware limit, we can't do 81 * scancode to the application. As this is a hardware limit, we can't do
57 * anything with it. Yet, as the same keycode table can be used with other 82 * anything with it. Yet, as the same keycode table can be used with other
@@ -70,7 +95,10 @@ enum rc_driver_type {
70 * @max_timeout: maximum timeout supported by device 95 * @max_timeout: maximum timeout supported by device
71 * @rx_resolution : resolution (in ns) of input sampler 96 * @rx_resolution : resolution (in ns) of input sampler
72 * @tx_resolution: resolution (in ns) of output sampler 97 * @tx_resolution: resolution (in ns) of output sampler
98 * @scancode_filters: scancode filters (indexed by enum rc_filter_type)
73 * @change_protocol: allow changing the protocol used on hardware decoders 99 * @change_protocol: allow changing the protocol used on hardware decoders
100 * @change_wakeup_protocol: allow changing the protocol used for wakeup
101 * filtering
74 * @open: callback to allow drivers to enable polling/irq when IR input device 102 * @open: callback to allow drivers to enable polling/irq when IR input device
75 * is opened. 103 * is opened.
76 * @close: callback to allow drivers to disable polling/irq when IR input device 104 * @close: callback to allow drivers to disable polling/irq when IR input device
@@ -84,6 +112,7 @@ enum rc_driver_type {
84 * device doesn't interrupt host until it sees IR pulses 112 * device doesn't interrupt host until it sees IR pulses
85 * @s_learning_mode: enable wide band receiver used for learning 113 * @s_learning_mode: enable wide band receiver used for learning
86 * @s_carrier_report: enable carrier reports 114 * @s_carrier_report: enable carrier reports
115 * @s_filter: set the scancode filter of a given type
87 */ 116 */
88struct rc_dev { 117struct rc_dev {
89 struct device dev; 118 struct device dev;
@@ -99,8 +128,8 @@ struct rc_dev {
99 struct input_dev *input_dev; 128 struct input_dev *input_dev;
100 enum rc_driver_type driver_type; 129 enum rc_driver_type driver_type;
101 bool idle; 130 bool idle;
102 u64 allowed_protos; 131 u64 allowed_protocols[RC_FILTER_MAX];
103 u64 enabled_protocols; 132 u64 enabled_protocols[RC_FILTER_MAX];
104 u32 users; 133 u32 users;
105 u32 scanmask; 134 u32 scanmask;
106 void *priv; 135 void *priv;
@@ -116,7 +145,9 @@ struct rc_dev {
116 u32 max_timeout; 145 u32 max_timeout;
117 u32 rx_resolution; 146 u32 rx_resolution;
118 u32 tx_resolution; 147 u32 tx_resolution;
148 struct rc_scancode_filter scancode_filters[RC_FILTER_MAX];
119 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); 149 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type);
150 int (*change_wakeup_protocol)(struct rc_dev *dev, u64 *rc_type);
120 int (*open)(struct rc_dev *dev); 151 int (*open)(struct rc_dev *dev);
121 void (*close)(struct rc_dev *dev); 152 void (*close)(struct rc_dev *dev);
122 int (*s_tx_mask)(struct rc_dev *dev, u32 mask); 153 int (*s_tx_mask)(struct rc_dev *dev, u32 mask);
@@ -127,10 +158,49 @@ struct rc_dev {
127 void (*s_idle)(struct rc_dev *dev, bool enable); 158 void (*s_idle)(struct rc_dev *dev, bool enable);
128 int (*s_learning_mode)(struct rc_dev *dev, int enable); 159 int (*s_learning_mode)(struct rc_dev *dev, int enable);
129 int (*s_carrier_report) (struct rc_dev *dev, int enable); 160 int (*s_carrier_report) (struct rc_dev *dev, int enable);
161 int (*s_filter)(struct rc_dev *dev,
162 enum rc_filter_type type,
163 struct rc_scancode_filter *filter);
130}; 164};
131 165
132#define to_rc_dev(d) container_of(d, struct rc_dev, dev) 166#define to_rc_dev(d) container_of(d, struct rc_dev, dev)
133 167
168static inline bool rc_protocols_allowed(struct rc_dev *rdev, u64 protos)
169{
170 return rdev->allowed_protocols[RC_FILTER_NORMAL] & protos;
171}
172
173/* should be called prior to registration or with mutex held */
174static inline void rc_set_allowed_protocols(struct rc_dev *rdev, u64 protos)
175{
176 rdev->allowed_protocols[RC_FILTER_NORMAL] = protos;
177}
178
179static inline bool rc_protocols_enabled(struct rc_dev *rdev, u64 protos)
180{
181 return rdev->enabled_protocols[RC_FILTER_NORMAL] & protos;
182}
183
184/* should be called prior to registration or with mutex held */
185static inline void rc_set_enabled_protocols(struct rc_dev *rdev, u64 protos)
186{
187 rdev->enabled_protocols[RC_FILTER_NORMAL] = protos;
188}
189
190/* should be called prior to registration or with mutex held */
191static inline void rc_set_allowed_wakeup_protocols(struct rc_dev *rdev,
192 u64 protos)
193{
194 rdev->allowed_protocols[RC_FILTER_WAKEUP] = protos;
195}
196
197/* should be called prior to registration or with mutex held */
198static inline void rc_set_enabled_wakeup_protocols(struct rc_dev *rdev,
199 u64 protos)
200{
201 rdev->enabled_protocols[RC_FILTER_WAKEUP] = protos;
202}
203
134/* 204/*
135 * From rc-main.c 205 * From rc-main.c
136 * Those functions can be used on any type of Remote Controller. They 206 * Those functions can be used on any type of Remote Controller. They
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index a20ed97d7d8a..e5aa2409c0ea 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * rc-map.h - define RC map names used by RC drivers 2 * rc-map.h - define RC map names used by RC drivers
3 * 3 *
4 * Copyright (c) 2010 by Mauro Carvalho Chehab <mchehab@redhat.com> 4 * Copyright (c) 2010 by Mauro Carvalho Chehab
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
@@ -30,6 +30,7 @@ enum rc_type {
30 RC_TYPE_RC6_6A_24 = 15, /* Philips RC6-6A-24 protocol */ 30 RC_TYPE_RC6_6A_24 = 15, /* Philips RC6-6A-24 protocol */
31 RC_TYPE_RC6_6A_32 = 16, /* Philips RC6-6A-32 protocol */ 31 RC_TYPE_RC6_6A_32 = 16, /* Philips RC6-6A-32 protocol */
32 RC_TYPE_RC6_MCE = 17, /* MCE (Philips RC6-6A-32 subtype) protocol */ 32 RC_TYPE_RC6_MCE = 17, /* MCE (Philips RC6-6A-32 subtype) protocol */
33 RC_TYPE_SHARP = 18, /* Sharp protocol */
33}; 34};
34 35
35#define RC_BIT_NONE 0 36#define RC_BIT_NONE 0
@@ -51,6 +52,7 @@ enum rc_type {
51#define RC_BIT_RC6_6A_24 (1 << RC_TYPE_RC6_6A_24) 52#define RC_BIT_RC6_6A_24 (1 << RC_TYPE_RC6_6A_24)
52#define RC_BIT_RC6_6A_32 (1 << RC_TYPE_RC6_6A_32) 53#define RC_BIT_RC6_6A_32 (1 << RC_TYPE_RC6_6A_32)
53#define RC_BIT_RC6_MCE (1 << RC_TYPE_RC6_MCE) 54#define RC_BIT_RC6_MCE (1 << RC_TYPE_RC6_MCE)
55#define RC_BIT_SHARP (1 << RC_TYPE_SHARP)
54 56
55#define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | RC_BIT_LIRC | \ 57#define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | RC_BIT_LIRC | \
56 RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \ 58 RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \
@@ -58,7 +60,7 @@ enum rc_type {
58 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \ 60 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \
59 RC_BIT_NEC | RC_BIT_SANYO | RC_BIT_MCE_KBD | \ 61 RC_BIT_NEC | RC_BIT_SANYO | RC_BIT_MCE_KBD | \
60 RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \ 62 RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \
61 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE) 63 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP)
62 64
63struct rc_map_table { 65struct rc_map_table {
64 u32 scancode; 66 u32 scancode;
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index c768c9f8abc2..eec6e460f649 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -24,7 +24,8 @@
24#define VFL_TYPE_VBI 1 24#define VFL_TYPE_VBI 1
25#define VFL_TYPE_RADIO 2 25#define VFL_TYPE_RADIO 2
26#define VFL_TYPE_SUBDEV 3 26#define VFL_TYPE_SUBDEV 3
27#define VFL_TYPE_MAX 4 27#define VFL_TYPE_SDR 4
28#define VFL_TYPE_MAX 5
28 29
29/* Is this a receiver, transmitter or mem-to-mem? */ 30/* Is this a receiver, transmitter or mem-to-mem? */
30/* Ignored for VFL_TYPE_SUBDEV. */ 31/* Ignored for VFL_TYPE_SUBDEV. */
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
index e0b74a430b3a..50cf7c110a70 100644
--- a/include/media/v4l2-ioctl.h
+++ b/include/media/v4l2-ioctl.h
@@ -40,6 +40,8 @@ struct v4l2_ioctl_ops {
40 struct v4l2_fmtdesc *f); 40 struct v4l2_fmtdesc *f);
41 int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file, void *fh, 41 int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file, void *fh,
42 struct v4l2_fmtdesc *f); 42 struct v4l2_fmtdesc *f);
43 int (*vidioc_enum_fmt_sdr_cap) (struct file *file, void *fh,
44 struct v4l2_fmtdesc *f);
43 45
44 /* VIDIOC_G_FMT handlers */ 46 /* VIDIOC_G_FMT handlers */
45 int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh, 47 int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh,
@@ -62,6 +64,8 @@ struct v4l2_ioctl_ops {
62 struct v4l2_format *f); 64 struct v4l2_format *f);
63 int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh, 65 int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
64 struct v4l2_format *f); 66 struct v4l2_format *f);
67 int (*vidioc_g_fmt_sdr_cap) (struct file *file, void *fh,
68 struct v4l2_format *f);
65 69
66 /* VIDIOC_S_FMT handlers */ 70 /* VIDIOC_S_FMT handlers */
67 int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh, 71 int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh,
@@ -84,6 +88,8 @@ struct v4l2_ioctl_ops {
84 struct v4l2_format *f); 88 struct v4l2_format *f);
85 int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh, 89 int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
86 struct v4l2_format *f); 90 struct v4l2_format *f);
91 int (*vidioc_s_fmt_sdr_cap) (struct file *file, void *fh,
92 struct v4l2_format *f);
87 93
88 /* VIDIOC_TRY_FMT handlers */ 94 /* VIDIOC_TRY_FMT handlers */
89 int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh, 95 int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh,
@@ -106,6 +112,8 @@ struct v4l2_ioctl_ops {
106 struct v4l2_format *f); 112 struct v4l2_format *f);
107 int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh, 113 int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
108 struct v4l2_format *f); 114 struct v4l2_format *f);
115 int (*vidioc_try_fmt_sdr_cap) (struct file *file, void *fh,
116 struct v4l2_format *f);
109 117
110 /* Buffer handlers */ 118 /* Buffer handlers */
111 int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b); 119 int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
@@ -265,6 +273,8 @@ struct v4l2_ioctl_ops {
265 struct v4l2_enum_dv_timings *timings); 273 struct v4l2_enum_dv_timings *timings);
266 int (*vidioc_dv_timings_cap) (struct file *file, void *fh, 274 int (*vidioc_dv_timings_cap) (struct file *file, void *fh,
267 struct v4l2_dv_timings_cap *cap); 275 struct v4l2_dv_timings_cap *cap);
276 int (*vidioc_g_edid) (struct file *file, void *fh, struct v4l2_edid *edid);
277 int (*vidioc_s_edid) (struct file *file, void *fh, struct v4l2_edid *edid);
268 278
269 int (*vidioc_subscribe_event) (struct v4l2_fh *fh, 279 int (*vidioc_subscribe_event) (struct v4l2_fh *fh,
270 const struct v4l2_event_subscription *sub); 280 const struct v4l2_event_subscription *sub);
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index d67210a37ef3..28f4d8c3cf7d 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -162,6 +162,10 @@ struct v4l2_subdev_core_ops {
162 int (*g_std)(struct v4l2_subdev *sd, v4l2_std_id *norm); 162 int (*g_std)(struct v4l2_subdev *sd, v4l2_std_id *norm);
163 int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm); 163 int (*s_std)(struct v4l2_subdev *sd, v4l2_std_id norm);
164 long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg); 164 long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
165#ifdef CONFIG_COMPAT
166 long (*compat_ioctl32)(struct v4l2_subdev *sd, unsigned int cmd,
167 unsigned long arg);
168#endif
165#ifdef CONFIG_VIDEO_ADV_DEBUG 169#ifdef CONFIG_VIDEO_ADV_DEBUG
166 int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg); 170 int (*g_register)(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg);
167 int (*s_register)(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg); 171 int (*s_register)(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg);
@@ -192,6 +196,7 @@ struct v4l2_subdev_tuner_ops {
192 int (*s_radio)(struct v4l2_subdev *sd); 196 int (*s_radio)(struct v4l2_subdev *sd);
193 int (*s_frequency)(struct v4l2_subdev *sd, const struct v4l2_frequency *freq); 197 int (*s_frequency)(struct v4l2_subdev *sd, const struct v4l2_frequency *freq);
194 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); 198 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
199 int (*enum_freq_bands)(struct v4l2_subdev *sd, struct v4l2_frequency_band *band);
195 int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt); 200 int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
196 int (*s_tuner)(struct v4l2_subdev *sd, const struct v4l2_tuner *vt); 201 int (*s_tuner)(struct v4l2_subdev *sd, const struct v4l2_tuner *vt);
197 int (*g_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm); 202 int (*g_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm);
@@ -503,8 +508,8 @@ struct v4l2_subdev_pad_ops {
503 struct v4l2_subdev_selection *sel); 508 struct v4l2_subdev_selection *sel);
504 int (*set_selection)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 509 int (*set_selection)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh,
505 struct v4l2_subdev_selection *sel); 510 struct v4l2_subdev_selection *sel);
506 int (*get_edid)(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid); 511 int (*get_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
507 int (*set_edid)(struct v4l2_subdev *sd, struct v4l2_subdev_edid *edid); 512 int (*set_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
508#ifdef CONFIG_MEDIA_CONTROLLER 513#ifdef CONFIG_MEDIA_CONTROLLER
509 int (*link_validate)(struct v4l2_subdev *sd, struct media_link *link, 514 int (*link_validate)(struct v4l2_subdev *sd, struct media_link *link,
510 struct v4l2_subdev_format *source_fmt, 515 struct v4l2_subdev_format *source_fmt,
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index bef53ce555d2..af4621109726 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -34,49 +34,49 @@ struct vb2_fileio_data;
34 * usually will result in the allocator freeing the buffer (if 34 * usually will result in the allocator freeing the buffer (if
35 * no other users of this buffer are present); the buf_priv 35 * no other users of this buffer are present); the buf_priv
36 * argument is the allocator private per-buffer structure 36 * argument is the allocator private per-buffer structure
37 * previously returned from the alloc callback 37 * previously returned from the alloc callback.
38 * @get_userptr: acquire userspace memory for a hardware operation; used for 38 * @get_userptr: acquire userspace memory for a hardware operation; used for
39 * USERPTR memory types; vaddr is the address passed to the 39 * USERPTR memory types; vaddr is the address passed to the
40 * videobuf layer when queuing a video buffer of USERPTR type; 40 * videobuf layer when queuing a video buffer of USERPTR type;
41 * should return an allocator private per-buffer structure 41 * should return an allocator private per-buffer structure
42 * associated with the buffer on success, NULL on failure; 42 * associated with the buffer on success, NULL on failure;
43 * the returned private structure will then be passed as buf_priv 43 * the returned private structure will then be passed as buf_priv
44 * argument to other ops in this structure 44 * argument to other ops in this structure.
45 * @put_userptr: inform the allocator that a USERPTR buffer will no longer 45 * @put_userptr: inform the allocator that a USERPTR buffer will no longer
46 * be used 46 * be used.
47 * @attach_dmabuf: attach a shared struct dma_buf for a hardware operation; 47 * @attach_dmabuf: attach a shared struct dma_buf for a hardware operation;
48 * used for DMABUF memory types; alloc_ctx is the alloc context 48 * used for DMABUF memory types; alloc_ctx is the alloc context
49 * dbuf is the shared dma_buf; returns NULL on failure; 49 * dbuf is the shared dma_buf; returns NULL on failure;
50 * allocator private per-buffer structure on success; 50 * allocator private per-buffer structure on success;
51 * this needs to be used for further accesses to the buffer 51 * this needs to be used for further accesses to the buffer.
52 * @detach_dmabuf: inform the exporter of the buffer that the current DMABUF 52 * @detach_dmabuf: inform the exporter of the buffer that the current DMABUF
53 * buffer is no longer used; the buf_priv argument is the 53 * buffer is no longer used; the buf_priv argument is the
54 * allocator private per-buffer structure previously returned 54 * allocator private per-buffer structure previously returned
55 * from the attach_dmabuf callback 55 * from the attach_dmabuf callback.
56 * @map_dmabuf: request for access to the dmabuf from allocator; the allocator 56 * @map_dmabuf: request for access to the dmabuf from allocator; the allocator
57 * of dmabuf is informed that this driver is going to use the 57 * of dmabuf is informed that this driver is going to use the
58 * dmabuf 58 * dmabuf.
59 * @unmap_dmabuf: releases access control to the dmabuf - allocator is notified 59 * @unmap_dmabuf: releases access control to the dmabuf - allocator is notified
60 * that this driver is done using the dmabuf for now 60 * that this driver is done using the dmabuf for now.
61 * @prepare: called every time the buffer is passed from userspace to the 61 * @prepare: called every time the buffer is passed from userspace to the
62 * driver, useful for cache synchronisation, optional 62 * driver, useful for cache synchronisation, optional.
63 * @finish: called every time the buffer is passed back from the driver 63 * @finish: called every time the buffer is passed back from the driver
64 * to the userspace, also optional 64 * to the userspace, also optional.
65 * @vaddr: return a kernel virtual address to a given memory buffer 65 * @vaddr: return a kernel virtual address to a given memory buffer
66 * associated with the passed private structure or NULL if no 66 * associated with the passed private structure or NULL if no
67 * such mapping exists 67 * such mapping exists.
68 * @cookie: return allocator specific cookie for a given memory buffer 68 * @cookie: return allocator specific cookie for a given memory buffer
69 * associated with the passed private structure or NULL if not 69 * associated with the passed private structure or NULL if not
70 * available 70 * available.
71 * @num_users: return the current number of users of a memory buffer; 71 * @num_users: return the current number of users of a memory buffer;
72 * return 1 if the videobuf layer (or actually the driver using 72 * return 1 if the videobuf layer (or actually the driver using
73 * it) is the only user 73 * it) is the only user.
74 * @mmap: setup a userspace mapping for a given memory buffer under 74 * @mmap: setup a userspace mapping for a given memory buffer under
75 * the provided virtual memory region 75 * the provided virtual memory region.
76 * 76 *
77 * Required ops for USERPTR types: get_userptr, put_userptr. 77 * Required ops for USERPTR types: get_userptr, put_userptr.
78 * Required ops for MMAP types: alloc, put, num_users, mmap. 78 * Required ops for MMAP types: alloc, put, num_users, mmap.
79 * Required ops for read/write access types: alloc, put, num_users, vaddr 79 * Required ops for read/write access types: alloc, put, num_users, vaddr.
80 * Required ops for DMABUF types: attach_dmabuf, detach_dmabuf, map_dmabuf, 80 * Required ops for DMABUF types: attach_dmabuf, detach_dmabuf, map_dmabuf,
81 * unmap_dmabuf. 81 * unmap_dmabuf.
82 */ 82 */
@@ -203,6 +203,37 @@ struct vb2_buffer {
203 struct list_head done_entry; 203 struct list_head done_entry;
204 204
205 struct vb2_plane planes[VIDEO_MAX_PLANES]; 205 struct vb2_plane planes[VIDEO_MAX_PLANES];
206
207#ifdef CONFIG_VIDEO_ADV_DEBUG
208 /*
209 * Counters for how often these buffer-related ops are
210 * called. Used to check for unbalanced ops.
211 */
212 u32 cnt_mem_alloc;
213 u32 cnt_mem_put;
214 u32 cnt_mem_get_dmabuf;
215 u32 cnt_mem_get_userptr;
216 u32 cnt_mem_put_userptr;
217 u32 cnt_mem_prepare;
218 u32 cnt_mem_finish;
219 u32 cnt_mem_attach_dmabuf;
220 u32 cnt_mem_detach_dmabuf;
221 u32 cnt_mem_map_dmabuf;
222 u32 cnt_mem_unmap_dmabuf;
223 u32 cnt_mem_vaddr;
224 u32 cnt_mem_cookie;
225 u32 cnt_mem_num_users;
226 u32 cnt_mem_mmap;
227
228 u32 cnt_buf_init;
229 u32 cnt_buf_prepare;
230 u32 cnt_buf_finish;
231 u32 cnt_buf_cleanup;
232 u32 cnt_buf_queue;
233
234 /* This counts the number of calls to vb2_buffer_done() */
235 u32 cnt_buf_done;
236#endif
206}; 237};
207 238
208/** 239/**
@@ -227,27 +258,35 @@ struct vb2_buffer {
227 * @wait_prepare: release any locks taken while calling vb2 functions; 258 * @wait_prepare: release any locks taken while calling vb2 functions;
228 * it is called before an ioctl needs to wait for a new 259 * it is called before an ioctl needs to wait for a new
229 * buffer to arrive; required to avoid a deadlock in 260 * buffer to arrive; required to avoid a deadlock in
230 * blocking access type 261 * blocking access type.
231 * @wait_finish: reacquire all locks released in the previous callback; 262 * @wait_finish: reacquire all locks released in the previous callback;
232 * required to continue operation after sleeping while 263 * required to continue operation after sleeping while
233 * waiting for a new buffer to arrive 264 * waiting for a new buffer to arrive.
234 * @buf_init: called once after allocating a buffer (in MMAP case) 265 * @buf_init: called once after allocating a buffer (in MMAP case)
235 * or after acquiring a new USERPTR buffer; drivers may 266 * or after acquiring a new USERPTR buffer; drivers may
236 * perform additional buffer-related initialization; 267 * perform additional buffer-related initialization;
237 * initialization failure (return != 0) will prevent 268 * initialization failure (return != 0) will prevent
238 * queue setup from completing successfully; optional 269 * queue setup from completing successfully; optional.
239 * @buf_prepare: called every time the buffer is queued from userspace 270 * @buf_prepare: called every time the buffer is queued from userspace
240 * and from the VIDIOC_PREPARE_BUF ioctl; drivers may 271 * and from the VIDIOC_PREPARE_BUF ioctl; drivers may
241 * perform any initialization required before each hardware 272 * perform any initialization required before each hardware
242 * operation in this callback; drivers that support 273 * operation in this callback; drivers that support
243 * VIDIOC_CREATE_BUFS must also validate the buffer size; 274 * VIDIOC_CREATE_BUFS must also validate the buffer size;
244 * if an error is returned, the buffer will not be queued 275 * if an error is returned, the buffer will not be queued
245 * in driver; optional 276 * in driver; optional.
246 * @buf_finish: called before every dequeue of the buffer back to 277 * @buf_finish: called before every dequeue of the buffer back to
247 * userspace; drivers may perform any operations required 278 * userspace; drivers may perform any operations required
248 * before userspace accesses the buffer; optional 279 * before userspace accesses the buffer; optional. The
280 * buffer state can be one of the following: DONE and
281 * ERROR occur while streaming is in progress, and the
282 * PREPARED state occurs when the queue has been canceled
283 * and all pending buffers are being returned to their
284 * default DEQUEUED state. Typically you only have to do
285 * something if the state is VB2_BUF_STATE_DONE, since in
286 * all other cases the buffer contents will be ignored
287 * anyway.
249 * @buf_cleanup: called once before the buffer is freed; drivers may 288 * @buf_cleanup: called once before the buffer is freed; drivers may
250 * perform any additional cleanup; optional 289 * perform any additional cleanup; optional.
251 * @start_streaming: called once to enter 'streaming' state; the driver may 290 * @start_streaming: called once to enter 'streaming' state; the driver may
252 * receive buffers with @buf_queue callback before 291 * receive buffers with @buf_queue callback before
253 * @start_streaming is called; the driver gets the number 292 * @start_streaming is called; the driver gets the number
@@ -268,7 +307,7 @@ struct vb2_buffer {
268 * the buffer back by calling vb2_buffer_done() function; 307 * the buffer back by calling vb2_buffer_done() function;
269 * it is allways called after calling STREAMON ioctl; 308 * it is allways called after calling STREAMON ioctl;
270 * might be called before start_streaming callback if user 309 * might be called before start_streaming callback if user
271 * pre-queued buffers before calling STREAMON 310 * pre-queued buffers before calling STREAMON.
272 */ 311 */
273struct vb2_ops { 312struct vb2_ops {
274 int (*queue_setup)(struct vb2_queue *q, const struct v4l2_format *fmt, 313 int (*queue_setup)(struct vb2_queue *q, const struct v4l2_format *fmt,
@@ -280,7 +319,7 @@ struct vb2_ops {
280 319
281 int (*buf_init)(struct vb2_buffer *vb); 320 int (*buf_init)(struct vb2_buffer *vb);
282 int (*buf_prepare)(struct vb2_buffer *vb); 321 int (*buf_prepare)(struct vb2_buffer *vb);
283 int (*buf_finish)(struct vb2_buffer *vb); 322 void (*buf_finish)(struct vb2_buffer *vb);
284 void (*buf_cleanup)(struct vb2_buffer *vb); 323 void (*buf_cleanup)(struct vb2_buffer *vb);
285 324
286 int (*start_streaming)(struct vb2_queue *q, unsigned int count); 325 int (*start_streaming)(struct vb2_queue *q, unsigned int count);
@@ -312,23 +351,29 @@ struct v4l2_fh;
312 * @buf_struct_size: size of the driver-specific buffer structure; 351 * @buf_struct_size: size of the driver-specific buffer structure;
313 * "0" indicates the driver doesn't want to use a custom buffer 352 * "0" indicates the driver doesn't want to use a custom buffer
314 * structure type, so sizeof(struct vb2_buffer) will is used 353 * structure type, so sizeof(struct vb2_buffer) will is used
354 * @timestamp_flags: Timestamp flags; V4L2_BUF_FLAGS_TIMESTAMP_* and
355 * V4L2_BUF_FLAGS_TSTAMP_SRC_*
315 * @gfp_flags: additional gfp flags used when allocating the buffers. 356 * @gfp_flags: additional gfp flags used when allocating the buffers.
316 * Typically this is 0, but it may be e.g. GFP_DMA or __GFP_DMA32 357 * Typically this is 0, but it may be e.g. GFP_DMA or __GFP_DMA32
317 * to force the buffer allocation to a specific memory zone. 358 * to force the buffer allocation to a specific memory zone.
359 * @min_buffers_needed: the minimum number of buffers needed before
360 * start_streaming() can be called. Used when a DMA engine
361 * cannot be started unless at least this number of buffers
362 * have been queued into the driver.
318 * 363 *
319 * @memory: current memory type used 364 * @memory: current memory type used
320 * @bufs: videobuf buffer structures 365 * @bufs: videobuf buffer structures
321 * @num_buffers: number of allocated/used buffers 366 * @num_buffers: number of allocated/used buffers
322 * @queued_list: list of buffers currently queued from userspace 367 * @queued_list: list of buffers currently queued from userspace
323 * @queued_count: number of buffers owned by the driver 368 * @queued_count: number of buffers queued and ready for streaming.
369 * @owned_by_drv_count: number of buffers owned by the driver
324 * @done_list: list of buffers ready to be dequeued to userspace 370 * @done_list: list of buffers ready to be dequeued to userspace
325 * @done_lock: lock to protect done_list list 371 * @done_lock: lock to protect done_list list
326 * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued 372 * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued
327 * @alloc_ctx: memory type/allocator-specific contexts for each plane 373 * @alloc_ctx: memory type/allocator-specific contexts for each plane
328 * @streaming: current streaming state 374 * @streaming: current streaming state
329 * @retry_start_streaming: start_streaming() was called, but there were not enough 375 * @start_streaming_called: start_streaming() was called successfully and we
330 * buffers queued. If set, then retry calling start_streaming when 376 * started streaming.
331 * queuing a new buffer.
332 * @fileio: file io emulator internal data, used only if emulator is active 377 * @fileio: file io emulator internal data, used only if emulator is active
333 */ 378 */
334struct vb2_queue { 379struct vb2_queue {
@@ -342,8 +387,9 @@ struct vb2_queue {
342 const struct vb2_mem_ops *mem_ops; 387 const struct vb2_mem_ops *mem_ops;
343 void *drv_priv; 388 void *drv_priv;
344 unsigned int buf_struct_size; 389 unsigned int buf_struct_size;
345 u32 timestamp_type; 390 u32 timestamp_flags;
346 gfp_t gfp_flags; 391 gfp_t gfp_flags;
392 u32 min_buffers_needed;
347 393
348/* private: internal use only */ 394/* private: internal use only */
349 enum v4l2_memory memory; 395 enum v4l2_memory memory;
@@ -351,8 +397,9 @@ struct vb2_queue {
351 unsigned int num_buffers; 397 unsigned int num_buffers;
352 398
353 struct list_head queued_list; 399 struct list_head queued_list;
400 unsigned int queued_count;
354 401
355 atomic_t queued_count; 402 atomic_t owned_by_drv_count;
356 struct list_head done_list; 403 struct list_head done_list;
357 spinlock_t done_lock; 404 spinlock_t done_lock;
358 wait_queue_head_t done_wq; 405 wait_queue_head_t done_wq;
@@ -361,9 +408,21 @@ struct vb2_queue {
361 unsigned int plane_sizes[VIDEO_MAX_PLANES]; 408 unsigned int plane_sizes[VIDEO_MAX_PLANES];
362 409
363 unsigned int streaming:1; 410 unsigned int streaming:1;
364 unsigned int retry_start_streaming:1; 411 unsigned int start_streaming_called:1;
365 412
366 struct vb2_fileio_data *fileio; 413 struct vb2_fileio_data *fileio;
414
415#ifdef CONFIG_VIDEO_ADV_DEBUG
416 /*
417 * Counters for how often these queue-related ops are
418 * called. Used to check for unbalanced ops.
419 */
420 u32 cnt_queue_setup;
421 u32 cnt_wait_prepare;
422 u32 cnt_wait_finish;
423 u32 cnt_start_streaming;
424 u32 cnt_stop_streaming;
425#endif
367}; 426};
368 427
369void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no); 428void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no);
diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h
index ef94ecad1c94..b9bb1f204693 100644
--- a/include/trace/events/v4l2.h
+++ b/include/trace/events/v4l2.h
@@ -18,6 +18,7 @@
18 { V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, "VIDEO_OUTPUT_OVERLAY" },\ 18 { V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, "VIDEO_OUTPUT_OVERLAY" },\
19 { V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" },\ 19 { V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" },\
20 { V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, "VIDEO_OUTPUT_MPLANE" }, \ 20 { V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, "VIDEO_OUTPUT_MPLANE" }, \
21 { V4L2_BUF_TYPE_SDR_CAPTURE, "SDR_CAPTURE" }, \
21 { V4L2_BUF_TYPE_PRIVATE, "PRIVATE" }) 22 { V4L2_BUF_TYPE_PRIVATE, "PRIVATE" })
22 23
23#define show_field(field) \ 24#define show_field(field) \
diff --git a/include/uapi/linux/v4l2-common.h b/include/uapi/linux/v4l2-common.h
index 4f0667e010dd..270db8914c01 100644
--- a/include/uapi/linux/v4l2-common.h
+++ b/include/uapi/linux/v4l2-common.h
@@ -68,4 +68,12 @@
68#define V4L2_SUBDEV_SEL_FLAG_SIZE_LE V4L2_SEL_FLAG_LE 68#define V4L2_SUBDEV_SEL_FLAG_SIZE_LE V4L2_SEL_FLAG_LE
69#define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG V4L2_SEL_FLAG_KEEP_CONFIG 69#define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG V4L2_SEL_FLAG_KEEP_CONFIG
70 70
71struct v4l2_edid {
72 __u32 pad;
73 __u32 start_block;
74 __u32 blocks;
75 __u32 reserved[5];
76 __u8 __user *edid;
77};
78
71#endif /* __V4L2_COMMON__ */ 79#endif /* __V4L2_COMMON__ */
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index 2cbe605bbe04..2ac5597f3ee1 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -60,6 +60,7 @@
60#define V4L2_CTRL_CLASS_IMAGE_PROC 0x009f0000 /* Image processing controls */ 60#define V4L2_CTRL_CLASS_IMAGE_PROC 0x009f0000 /* Image processing controls */
61#define V4L2_CTRL_CLASS_DV 0x00a00000 /* Digital Video controls */ 61#define V4L2_CTRL_CLASS_DV 0x00a00000 /* Digital Video controls */
62#define V4L2_CTRL_CLASS_FM_RX 0x00a10000 /* FM Receiver controls */ 62#define V4L2_CTRL_CLASS_FM_RX 0x00a10000 /* FM Receiver controls */
63#define V4L2_CTRL_CLASS_RF_TUNER 0x00a20000 /* RF tuner controls */
63 64
64/* User-class control IDs */ 65/* User-class control IDs */
65 66
@@ -376,6 +377,8 @@ enum v4l2_mpeg_video_multi_slice_mode {
376#define V4L2_CID_MPEG_VIDEO_DEC_FRAME (V4L2_CID_MPEG_BASE+224) 377#define V4L2_CID_MPEG_VIDEO_DEC_FRAME (V4L2_CID_MPEG_BASE+224)
377#define V4L2_CID_MPEG_VIDEO_VBV_DELAY (V4L2_CID_MPEG_BASE+225) 378#define V4L2_CID_MPEG_VIDEO_VBV_DELAY (V4L2_CID_MPEG_BASE+225)
378#define V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER (V4L2_CID_MPEG_BASE+226) 379#define V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER (V4L2_CID_MPEG_BASE+226)
380#define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE (V4L2_CID_MPEG_BASE+227)
381#define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (V4L2_CID_MPEG_BASE+228)
379 382
380#define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP (V4L2_CID_MPEG_BASE+300) 383#define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP (V4L2_CID_MPEG_BASE+300)
381#define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP (V4L2_CID_MPEG_BASE+301) 384#define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP (V4L2_CID_MPEG_BASE+301)
@@ -812,6 +815,9 @@ enum v4l2_flash_strobe_source {
812#define V4L2_FLASH_FAULT_SHORT_CIRCUIT (1 << 3) 815#define V4L2_FLASH_FAULT_SHORT_CIRCUIT (1 << 3)
813#define V4L2_FLASH_FAULT_OVER_CURRENT (1 << 4) 816#define V4L2_FLASH_FAULT_OVER_CURRENT (1 << 4)
814#define V4L2_FLASH_FAULT_INDICATOR (1 << 5) 817#define V4L2_FLASH_FAULT_INDICATOR (1 << 5)
818#define V4L2_FLASH_FAULT_UNDER_VOLTAGE (1 << 6)
819#define V4L2_FLASH_FAULT_INPUT_VOLTAGE (1 << 7)
820#define V4L2_FLASH_FAULT_LED_OVER_TEMPERATURE (1 << 8)
815 821
816#define V4L2_CID_FLASH_CHARGE (V4L2_CID_FLASH_CLASS_BASE + 11) 822#define V4L2_CID_FLASH_CHARGE (V4L2_CID_FLASH_CLASS_BASE + 11)
817#define V4L2_CID_FLASH_READY (V4L2_CID_FLASH_CLASS_BASE + 12) 823#define V4L2_CID_FLASH_READY (V4L2_CID_FLASH_CLASS_BASE + 12)
@@ -895,4 +901,17 @@ enum v4l2_deemphasis {
895 901
896#define V4L2_CID_RDS_RECEPTION (V4L2_CID_FM_RX_CLASS_BASE + 2) 902#define V4L2_CID_RDS_RECEPTION (V4L2_CID_FM_RX_CLASS_BASE + 2)
897 903
904#define V4L2_CID_RF_TUNER_CLASS_BASE (V4L2_CTRL_CLASS_RF_TUNER | 0x900)
905#define V4L2_CID_RF_TUNER_CLASS (V4L2_CTRL_CLASS_RF_TUNER | 1)
906
907#define V4L2_CID_RF_TUNER_BANDWIDTH_AUTO (V4L2_CID_RF_TUNER_CLASS_BASE + 11)
908#define V4L2_CID_RF_TUNER_BANDWIDTH (V4L2_CID_RF_TUNER_CLASS_BASE + 12)
909#define V4L2_CID_RF_TUNER_LNA_GAIN_AUTO (V4L2_CID_RF_TUNER_CLASS_BASE + 41)
910#define V4L2_CID_RF_TUNER_LNA_GAIN (V4L2_CID_RF_TUNER_CLASS_BASE + 42)
911#define V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO (V4L2_CID_RF_TUNER_CLASS_BASE + 51)
912#define V4L2_CID_RF_TUNER_MIXER_GAIN (V4L2_CID_RF_TUNER_CLASS_BASE + 52)
913#define V4L2_CID_RF_TUNER_IF_GAIN_AUTO (V4L2_CID_RF_TUNER_CLASS_BASE + 61)
914#define V4L2_CID_RF_TUNER_IF_GAIN (V4L2_CID_RF_TUNER_CLASS_BASE + 62)
915#define V4L2_CID_RF_TUNER_PLL_LOCK (V4L2_CID_RF_TUNER_CLASS_BASE + 91)
916
898#endif 917#endif
diff --git a/include/uapi/linux/v4l2-dv-timings.h b/include/uapi/linux/v4l2-dv-timings.h
index be709fe29552..b6a5fe00a470 100644
--- a/include/uapi/linux/v4l2-dv-timings.h
+++ b/include/uapi/linux/v4l2-dv-timings.h
@@ -823,4 +823,21 @@
823 V4L2_DV_FL_REDUCED_BLANKING) \ 823 V4L2_DV_FL_REDUCED_BLANKING) \
824} 824}
825 825
826/* 4K resolutions */
827#define V4L2_DV_BT_DMT_4096X2160P60_RB { \
828 .type = V4L2_DV_BT_656_1120, \
829 V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
830 556744000, 8, 32, 40, 48, 8, 6, 0, 0, 0, \
831 V4L2_DV_BT_STD_DMT | V4L2_DV_BT_STD_CVT, \
832 V4L2_DV_FL_REDUCED_BLANKING) \
833}
834
835#define V4L2_DV_BT_DMT_4096X2160P59_94_RB { \
836 .type = V4L2_DV_BT_656_1120, \
837 V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \
838 556188000, 8, 32, 40, 48, 8, 6, 0, 0, 0, \
839 V4L2_DV_BT_STD_DMT | V4L2_DV_BT_STD_CVT, \
840 V4L2_DV_FL_REDUCED_BLANKING) \
841}
842
826#endif 843#endif
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index a33c4daadce3..87e05159f637 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -148,13 +148,8 @@ struct v4l2_subdev_selection {
148 __u32 reserved[8]; 148 __u32 reserved[8];
149}; 149};
150 150
151struct v4l2_subdev_edid { 151/* Backwards compatibility define --- to be removed */
152 __u32 pad; 152#define v4l2_subdev_edid v4l2_edid
153 __u32 start_block;
154 __u32 blocks;
155 __u32 reserved[5];
156 __u8 __user *edid;
157};
158 153
159#define VIDIOC_SUBDEV_G_FMT _IOWR('V', 4, struct v4l2_subdev_format) 154#define VIDIOC_SUBDEV_G_FMT _IOWR('V', 4, struct v4l2_subdev_format)
160#define VIDIOC_SUBDEV_S_FMT _IOWR('V', 5, struct v4l2_subdev_format) 155#define VIDIOC_SUBDEV_S_FMT _IOWR('V', 5, struct v4l2_subdev_format)
@@ -174,7 +169,8 @@ struct v4l2_subdev_edid {
174 _IOWR('V', 61, struct v4l2_subdev_selection) 169 _IOWR('V', 61, struct v4l2_subdev_selection)
175#define VIDIOC_SUBDEV_S_SELECTION \ 170#define VIDIOC_SUBDEV_S_SELECTION \
176 _IOWR('V', 62, struct v4l2_subdev_selection) 171 _IOWR('V', 62, struct v4l2_subdev_selection)
177#define VIDIOC_SUBDEV_G_EDID _IOWR('V', 40, struct v4l2_subdev_edid) 172/* These two G/S_EDID ioctls are identical to the ioctls in videodev2.h */
178#define VIDIOC_SUBDEV_S_EDID _IOWR('V', 41, struct v4l2_subdev_edid) 173#define VIDIOC_SUBDEV_G_EDID _IOWR('V', 40, struct v4l2_edid)
174#define VIDIOC_SUBDEV_S_EDID _IOWR('V', 41, struct v4l2_edid)
179 175
180#endif 176#endif
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 6ae7bbe988cc..ea468ee8fe21 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -139,6 +139,7 @@ enum v4l2_buf_type {
139#endif 139#endif
140 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9, 140 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
141 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10, 141 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10,
142 V4L2_BUF_TYPE_SDR_CAPTURE = 11,
142 /* Deprecated, do not use */ 143 /* Deprecated, do not use */
143 V4L2_BUF_TYPE_PRIVATE = 0x80, 144 V4L2_BUF_TYPE_PRIVATE = 0x80,
144}; 145};
@@ -159,6 +160,8 @@ enum v4l2_tuner_type {
159 V4L2_TUNER_RADIO = 1, 160 V4L2_TUNER_RADIO = 1,
160 V4L2_TUNER_ANALOG_TV = 2, 161 V4L2_TUNER_ANALOG_TV = 2,
161 V4L2_TUNER_DIGITAL_TV = 3, 162 V4L2_TUNER_DIGITAL_TV = 3,
163 V4L2_TUNER_ADC = 4,
164 V4L2_TUNER_RF = 5,
162}; 165};
163 166
164enum v4l2_memory { 167enum v4l2_memory {
@@ -264,6 +267,8 @@ struct v4l2_capability {
264#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */ 267#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */
265#define V4L2_CAP_MODULATOR 0x00080000 /* has a modulator */ 268#define V4L2_CAP_MODULATOR 0x00080000 /* has a modulator */
266 269
270#define V4L2_CAP_SDR_CAPTURE 0x00100000 /* Is a SDR capture device */
271
267#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */ 272#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */
268#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */ 273#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */
269#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */ 274#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */
@@ -431,6 +436,10 @@ struct v4l2_pix_format {
431#define V4L2_PIX_FMT_SE401 v4l2_fourcc('S', '4', '0', '1') /* se401 janggu compressed rgb */ 436#define V4L2_PIX_FMT_SE401 v4l2_fourcc('S', '4', '0', '1') /* se401 janggu compressed rgb */
432#define V4L2_PIX_FMT_S5C_UYVY_JPG v4l2_fourcc('S', '5', 'C', 'I') /* S5C73M3 interleaved UYVY/JPEG */ 437#define V4L2_PIX_FMT_S5C_UYVY_JPG v4l2_fourcc('S', '5', 'C', 'I') /* S5C73M3 interleaved UYVY/JPEG */
433 438
439/* SDR formats - used only for Software Defined Radio devices */
440#define V4L2_SDR_FMT_CU8 v4l2_fourcc('C', 'U', '0', '8') /* IQ u8 */
441#define V4L2_SDR_FMT_CU16LE v4l2_fourcc('C', 'U', '1', '6') /* IQ u16le */
442
434/* 443/*
435 * F O R M A T E N U M E R A T I O N 444 * F O R M A T E N U M E R A T I O N
436 */ 445 */
@@ -669,24 +678,36 @@ struct v4l2_buffer {
669}; 678};
670 679
671/* Flags for 'flags' field */ 680/* Flags for 'flags' field */
672#define V4L2_BUF_FLAG_MAPPED 0x0001 /* Buffer is mapped (flag) */ 681/* Buffer is mapped (flag) */
673#define V4L2_BUF_FLAG_QUEUED 0x0002 /* Buffer is queued for processing */ 682#define V4L2_BUF_FLAG_MAPPED 0x00000001
674#define V4L2_BUF_FLAG_DONE 0x0004 /* Buffer is ready */ 683/* Buffer is queued for processing */
675#define V4L2_BUF_FLAG_KEYFRAME 0x0008 /* Image is a keyframe (I-frame) */ 684#define V4L2_BUF_FLAG_QUEUED 0x00000002
676#define V4L2_BUF_FLAG_PFRAME 0x0010 /* Image is a P-frame */ 685/* Buffer is ready */
677#define V4L2_BUF_FLAG_BFRAME 0x0020 /* Image is a B-frame */ 686#define V4L2_BUF_FLAG_DONE 0x00000004
687/* Image is a keyframe (I-frame) */
688#define V4L2_BUF_FLAG_KEYFRAME 0x00000008
689/* Image is a P-frame */
690#define V4L2_BUF_FLAG_PFRAME 0x00000010
691/* Image is a B-frame */
692#define V4L2_BUF_FLAG_BFRAME 0x00000020
678/* Buffer is ready, but the data contained within is corrupted. */ 693/* Buffer is ready, but the data contained within is corrupted. */
679#define V4L2_BUF_FLAG_ERROR 0x0040 694#define V4L2_BUF_FLAG_ERROR 0x00000040
680#define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */ 695/* timecode field is valid */
681#define V4L2_BUF_FLAG_PREPARED 0x0400 /* Buffer is prepared for queuing */ 696#define V4L2_BUF_FLAG_TIMECODE 0x00000100
697/* Buffer is prepared for queuing */
698#define V4L2_BUF_FLAG_PREPARED 0x00000400
682/* Cache handling flags */ 699/* Cache handling flags */
683#define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 0x0800 700#define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 0x00000800
684#define V4L2_BUF_FLAG_NO_CACHE_CLEAN 0x1000 701#define V4L2_BUF_FLAG_NO_CACHE_CLEAN 0x00001000
685/* Timestamp type */ 702/* Timestamp type */
686#define V4L2_BUF_FLAG_TIMESTAMP_MASK 0xe000 703#define V4L2_BUF_FLAG_TIMESTAMP_MASK 0x0000e000
687#define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN 0x0000 704#define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN 0x00000000
688#define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC 0x2000 705#define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC 0x00002000
689#define V4L2_BUF_FLAG_TIMESTAMP_COPY 0x4000 706#define V4L2_BUF_FLAG_TIMESTAMP_COPY 0x00004000
707/* Timestamp sources. */
708#define V4L2_BUF_FLAG_TSTAMP_SRC_MASK 0x00070000
709#define V4L2_BUF_FLAG_TSTAMP_SRC_EOF 0x00000000
710#define V4L2_BUF_FLAG_TSTAMP_SRC_SOE 0x00010000
690 711
691/** 712/**
692 * struct v4l2_exportbuffer - export of video buffer as DMABUF file descriptor 713 * struct v4l2_exportbuffer - export of video buffer as DMABUF file descriptor
@@ -1059,14 +1080,14 @@ struct v4l2_bt_timings {
1059 1080
1060/* A few useful defines to calculate the total blanking and frame sizes */ 1081/* A few useful defines to calculate the total blanking and frame sizes */
1061#define V4L2_DV_BT_BLANKING_WIDTH(bt) \ 1082#define V4L2_DV_BT_BLANKING_WIDTH(bt) \
1062 (bt->hfrontporch + bt->hsync + bt->hbackporch) 1083 ((bt)->hfrontporch + (bt)->hsync + (bt)->hbackporch)
1063#define V4L2_DV_BT_FRAME_WIDTH(bt) \ 1084#define V4L2_DV_BT_FRAME_WIDTH(bt) \
1064 (bt->width + V4L2_DV_BT_BLANKING_WIDTH(bt)) 1085 ((bt)->width + V4L2_DV_BT_BLANKING_WIDTH(bt))
1065#define V4L2_DV_BT_BLANKING_HEIGHT(bt) \ 1086#define V4L2_DV_BT_BLANKING_HEIGHT(bt) \
1066 (bt->vfrontporch + bt->vsync + bt->vbackporch + \ 1087 ((bt)->vfrontporch + (bt)->vsync + (bt)->vbackporch + \
1067 bt->il_vfrontporch + bt->il_vsync + bt->il_vbackporch) 1088 (bt)->il_vfrontporch + (bt)->il_vsync + (bt)->il_vbackporch)
1068#define V4L2_DV_BT_FRAME_HEIGHT(bt) \ 1089#define V4L2_DV_BT_FRAME_HEIGHT(bt) \
1069 (bt->height + V4L2_DV_BT_BLANKING_HEIGHT(bt)) 1090 ((bt)->height + V4L2_DV_BT_BLANKING_HEIGHT(bt))
1070 1091
1071/** struct v4l2_dv_timings - DV timings 1092/** struct v4l2_dv_timings - DV timings
1072 * @type: the type of the timings 1093 * @type: the type of the timings
@@ -1339,6 +1360,7 @@ struct v4l2_modulator {
1339#define V4L2_TUNER_CAP_RDS_CONTROLS 0x0200 1360#define V4L2_TUNER_CAP_RDS_CONTROLS 0x0200
1340#define V4L2_TUNER_CAP_FREQ_BANDS 0x0400 1361#define V4L2_TUNER_CAP_FREQ_BANDS 0x0400
1341#define V4L2_TUNER_CAP_HWSEEK_PROG_LIM 0x0800 1362#define V4L2_TUNER_CAP_HWSEEK_PROG_LIM 0x0800
1363#define V4L2_TUNER_CAP_1HZ 0x1000
1342 1364
1343/* Flags for the 'rxsubchans' field */ 1365/* Flags for the 'rxsubchans' field */
1344#define V4L2_TUNER_SUB_MONO 0x0001 1366#define V4L2_TUNER_SUB_MONO 0x0001
@@ -1692,6 +1714,15 @@ struct v4l2_pix_format_mplane {
1692} __attribute__ ((packed)); 1714} __attribute__ ((packed));
1693 1715
1694/** 1716/**
1717 * struct v4l2_sdr_format - SDR format definition
1718 * @pixelformat: little endian four character code (fourcc)
1719 */
1720struct v4l2_sdr_format {
1721 __u32 pixelformat;
1722 __u8 reserved[28];
1723} __attribute__ ((packed));
1724
1725/**
1695 * struct v4l2_format - stream data format 1726 * struct v4l2_format - stream data format
1696 * @type: enum v4l2_buf_type; type of the data stream 1727 * @type: enum v4l2_buf_type; type of the data stream
1697 * @pix: definition of an image format 1728 * @pix: definition of an image format
@@ -1709,6 +1740,7 @@ struct v4l2_format {
1709 struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */ 1740 struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */
1710 struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */ 1741 struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */
1711 struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */ 1742 struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
1743 struct v4l2_sdr_format sdr; /* V4L2_BUF_TYPE_SDR_CAPTURE */
1712 __u8 raw_data[200]; /* user-defined */ 1744 __u8 raw_data[200]; /* user-defined */
1713 } fmt; 1745 } fmt;
1714}; 1746};
@@ -1885,6 +1917,8 @@ struct v4l2_create_buffers {
1885#define VIDIOC_QUERYMENU _IOWR('V', 37, struct v4l2_querymenu) 1917#define VIDIOC_QUERYMENU _IOWR('V', 37, struct v4l2_querymenu)
1886#define VIDIOC_G_INPUT _IOR('V', 38, int) 1918#define VIDIOC_G_INPUT _IOR('V', 38, int)
1887#define VIDIOC_S_INPUT _IOWR('V', 39, int) 1919#define VIDIOC_S_INPUT _IOWR('V', 39, int)
1920#define VIDIOC_G_EDID _IOWR('V', 40, struct v4l2_edid)
1921#define VIDIOC_S_EDID _IOWR('V', 41, struct v4l2_edid)
1888#define VIDIOC_G_OUTPUT _IOR('V', 46, int) 1922#define VIDIOC_G_OUTPUT _IOR('V', 46, int)
1889#define VIDIOC_S_OUTPUT _IOWR('V', 47, int) 1923#define VIDIOC_S_OUTPUT _IOWR('V', 47, int)
1890#define VIDIOC_ENUMOUTPUT _IOWR('V', 48, struct v4l2_output) 1924#define VIDIOC_ENUMOUTPUT _IOWR('V', 48, struct v4l2_output)