aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-07 15:53:14 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-07 15:53:14 -0400
commitc0da4fa0d1a54495d6055c009ac46b76d1da2c86 (patch)
tree81b00d651c7fd8adf91984c69331074af2a71c32
parentd969443064abf2f51510559a5b01325eaabfcb1d (diff)
parent1efdf1776e2253b77413c997bed862410e4b6aaf (diff)
Merge tag 'media/v4.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: "Brazil's Independence Day pull request :-) This is one of the biggest media pull requests, with 625 patches affecting almost all parts of media (RC, DVB, V4L2, CEC, docs). This contains: - A lot of new drivers: * DVB frontends: mxl5xx, stv0910, stv6111; * camera flash: as3645a led driver; * HDMI receiver: adv748X; * camera sensor: Omnivision 6650 5M driver (ov6650); * HDMI CEC: ao-cec meson driver; * V4L2: Qualcom camss driver; * Remote controller: gpio-ir-tx, pwm-ir-tx and zx-irdec drivers. - The DDbridge DVB driver got a massive update, with makes it in sync with modern hardware from that vendor; - There's an important milestone on this series: the DVB documentation was written in 2003, but only started to be updated in 2007. It also used to contain several gaps from the time it was kept out of tree, mentioning error codes and device nodes that never existed upstream. On this series, it received a massive update: all non-deprecated digital TV APIs are now in sync with the current implementation; - Some DVB APIs that aren't used by any upstream driver got removed; - Other parts of the media documentation algo got updated, fixing some bugs on its PDF output and making it compatible with Sphinx version 1.6. As the number of hacks required to build PDF output reduced, I hope we'll have less troubles as newer versions of our documentation toolchain are released (famous last words); - As usual, lots of driver cleanups and improvements" * tag 'media/v4.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (624 commits) media: leds: as3645a: add V4L2_FLASH_LED_CLASS dependency media: get rid of removed DMX_GET_CAPS and DMX_SET_SOURCE leftovers media: Revert "[media] v4l: async: make v4l2 coexist with devicetree nodes in a dt overlay" media: staging: atomisp: sh_css_calloc shall return a pointer to the allocated space media: Revert "[media] lirc_dev: remove superfluous get/put_device() calls" media: add qcom_camss.rst to v4l-drivers rst file media: dvb headers: make checkpatch happier media: dvb uapi: move frontend legacy API to another part of the book media: pixfmt-srggb12p.rst: better format the table for PDF output media: docs-rst: media: Don't use \small for V4L2_PIX_FMT_SRGGB10 documentation media: index.rst: don't write "Contents:" on PDF output media: pixfmt*.rst: replace a two dots by a comma media: vidioc-g-fmt.rst: adjust table format media: vivid.rst: add a blank line to correct ReST format media: v4l2 uapi book: get rid of driver programming's chapter media: format.rst: use the right markup for important notes media: docs-rst: cardlists: change their format to flat-tables media: em28xx-cardlist.rst: update to reflect last changes media: v4l2-event.rst: adjust table to fit on PDF output media: docs: don't show ToC for each part on PDF output ...
-rw-r--r--Documentation/devicetree/bindings/leds/ams,as3645a.txt71
-rw-r--r--Documentation/devicetree/bindings/leds/irled/gpio-ir-tx.txt14
-rw-r--r--Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.txt13
-rw-r--r--Documentation/devicetree/bindings/media/i2c/adv748x.txt95
-rw-r--r--Documentation/devicetree/bindings/media/i2c/dongwoon,dw9714.txt9
-rw-r--r--Documentation/devicetree/bindings/media/meson-ao-cec.txt28
-rw-r--r--Documentation/devicetree/bindings/media/mtk-cir.txt8
-rw-r--r--Documentation/devicetree/bindings/media/qcom,camss.txt197
-rw-r--r--Documentation/devicetree/bindings/media/renesas,drif.txt1
-rw-r--r--Documentation/devicetree/bindings/media/video-interfaces.txt8
-rw-r--r--Documentation/devicetree/bindings/media/zx-irdec.txt14
-rw-r--r--Documentation/devicetree/bindings/vendor-prefixes.txt1
-rw-r--r--Documentation/media/ca.h.rst.exceptions1
-rw-r--r--Documentation/media/cec-drivers/index.rst34
-rw-r--r--Documentation/media/cec-drivers/pulse8-cec.rst11
-rw-r--r--Documentation/media/dmx.h.rst.exceptions20
-rw-r--r--Documentation/media/dvb-drivers/ci.rst1
-rw-r--r--Documentation/media/dvb-drivers/index.rst4
-rw-r--r--Documentation/media/frontend.h.rst.exceptions185
-rw-r--r--Documentation/media/index.rst7
-rw-r--r--Documentation/media/kapi/cec-core.rst40
-rw-r--r--Documentation/media/kapi/csi2.rst10
-rw-r--r--Documentation/media/kapi/v4l2-event.rst2
-rw-r--r--Documentation/media/media_kapi.rst4
-rw-r--r--Documentation/media/media_uapi.rst4
-rw-r--r--Documentation/media/uapi/cec/cec-api.rst5
-rw-r--r--Documentation/media/uapi/cec/cec-func-close.rst2
-rw-r--r--Documentation/media/uapi/cec/cec-func-ioctl.rst2
-rw-r--r--Documentation/media/uapi/cec/cec-func-open.rst4
-rw-r--r--Documentation/media/uapi/cec/cec-func-poll.rst8
-rw-r--r--Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst9
-rw-r--r--Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst13
-rw-r--r--Documentation/media/uapi/cec/cec-ioc-dqevent.rst31
-rw-r--r--Documentation/media/uapi/cec/cec-ioc-g-mode.rst82
-rw-r--r--Documentation/media/uapi/cec/cec-ioc-receive.rst2
-rw-r--r--Documentation/media/uapi/dvb/audio-channel-select.rst2
-rw-r--r--Documentation/media/uapi/dvb/audio-fclose.rst8
-rw-r--r--Documentation/media/uapi/dvb/audio-fopen.rst8
-rw-r--r--Documentation/media/uapi/dvb/audio-fwrite.rst8
-rw-r--r--Documentation/media/uapi/dvb/audio-set-av-sync.rst2
-rw-r--r--Documentation/media/uapi/dvb/audio-set-bypass-mode.rst6
-rw-r--r--Documentation/media/uapi/dvb/audio-set-mute.rst2
-rw-r--r--Documentation/media/uapi/dvb/audio.rst13
-rw-r--r--Documentation/media/uapi/dvb/audio_h.rst9
-rw-r--r--Documentation/media/uapi/dvb/ca-fclose.rst21
-rw-r--r--Documentation/media/uapi/dvb/ca-fopen.rst71
-rw-r--r--Documentation/media/uapi/dvb/ca-get-cap.rst40
-rw-r--r--Documentation/media/uapi/dvb/ca-get-descr-info.rst29
-rw-r--r--Documentation/media/uapi/dvb/ca-get-msg.rst46
-rw-r--r--Documentation/media/uapi/dvb/ca-get-slot-info.rst102
-rw-r--r--Documentation/media/uapi/dvb/ca-reset.rst11
-rw-r--r--Documentation/media/uapi/dvb/ca-send-msg.rst14
-rw-r--r--Documentation/media/uapi/dvb/ca-set-descr.rst13
-rw-r--r--Documentation/media/uapi/dvb/ca-set-pid.rst60
-rw-r--r--Documentation/media/uapi/dvb/ca.rst16
-rw-r--r--Documentation/media/uapi/dvb/ca_data_types.rst103
-rw-r--r--Documentation/media/uapi/dvb/ca_function_calls.rst1
-rw-r--r--Documentation/media/uapi/dvb/ca_h.rst9
-rw-r--r--Documentation/media/uapi/dvb/demux.rst13
-rw-r--r--Documentation/media/uapi/dvb/dmx-add-pid.rst12
-rw-r--r--Documentation/media/uapi/dvb/dmx-fclose.rst26
-rw-r--r--Documentation/media/uapi/dvb/dmx-fopen.rst66
-rw-r--r--Documentation/media/uapi/dvb/dmx-fread.rst78
-rw-r--r--Documentation/media/uapi/dvb/dmx-fwrite.rst41
-rw-r--r--Documentation/media/uapi/dvb/dmx-get-caps.rst41
-rw-r--r--Documentation/media/uapi/dvb/dmx-get-event.rst60
-rw-r--r--Documentation/media/uapi/dvb/dmx-get-pes-pids.rst30
-rw-r--r--Documentation/media/uapi/dvb/dmx-get-stc.rst28
-rw-r--r--Documentation/media/uapi/dvb/dmx-remove-pid.rst12
-rw-r--r--Documentation/media/uapi/dvb/dmx-set-buffer-size.rst11
-rw-r--r--Documentation/media/uapi/dvb/dmx-set-filter.rst13
-rw-r--r--Documentation/media/uapi/dvb/dmx-set-pes-filter.rst12
-rw-r--r--Documentation/media/uapi/dvb/dmx-set-source.rst44
-rw-r--r--Documentation/media/uapi/dvb/dmx-start.rst15
-rw-r--r--Documentation/media/uapi/dvb/dmx-stop.rst12
-rw-r--r--Documentation/media/uapi/dvb/dmx_fcalls.rst3
-rw-r--r--Documentation/media/uapi/dvb/dmx_h.rst9
-rw-r--r--Documentation/media/uapi/dvb/dmx_types.rst225
-rw-r--r--Documentation/media/uapi/dvb/dtv-fe-stats.rst17
-rw-r--r--Documentation/media/uapi/dvb/dtv-properties.rst15
-rw-r--r--Documentation/media/uapi/dvb/dtv-property.rst31
-rw-r--r--Documentation/media/uapi/dvb/dtv-stats.rst18
-rw-r--r--Documentation/media/uapi/dvb/dvb-fe-read-status.rst2
-rw-r--r--Documentation/media/uapi/dvb/dvb-frontend-parameters.rst2
-rw-r--r--Documentation/media/uapi/dvb/dvbapi.rst43
-rw-r--r--Documentation/media/uapi/dvb/dvbproperty-006.rst12
-rw-r--r--Documentation/media/uapi/dvb/dvbproperty.rst90
-rw-r--r--Documentation/media/uapi/dvb/dvbstb.svg31
-rw-r--r--Documentation/media/uapi/dvb/examples.rst4
-rw-r--r--Documentation/media/uapi/dvb/fe-diseqc-recv-slave-reply.rst48
-rw-r--r--Documentation/media/uapi/dvb/fe-diseqc-reset-overload.rst10
-rw-r--r--Documentation/media/uapi/dvb/fe-diseqc-send-burst.rst39
-rw-r--r--Documentation/media/uapi/dvb/fe-diseqc-send-master-cmd.rst38
-rw-r--r--Documentation/media/uapi/dvb/fe-dishnetwork-send-legacy-cmd.rst8
-rw-r--r--Documentation/media/uapi/dvb/fe-enable-high-lnb-voltage.rst8
-rw-r--r--Documentation/media/uapi/dvb/fe-get-event.rst9
-rw-r--r--Documentation/media/uapi/dvb/fe-get-frontend.rst10
-rw-r--r--Documentation/media/uapi/dvb/fe-get-info.rst385
-rw-r--r--Documentation/media/uapi/dvb/fe-get-property.rst12
-rw-r--r--Documentation/media/uapi/dvb/fe-read-ber.rst8
-rw-r--r--Documentation/media/uapi/dvb/fe-read-signal-strength.rst8
-rw-r--r--Documentation/media/uapi/dvb/fe-read-snr.rst8
-rw-r--r--Documentation/media/uapi/dvb/fe-read-status.rst85
-rw-r--r--Documentation/media/uapi/dvb/fe-read-uncorrected-blocks.rst8
-rw-r--r--Documentation/media/uapi/dvb/fe-set-frontend-tune-mode.rst12
-rw-r--r--Documentation/media/uapi/dvb/fe-set-frontend.rst15
-rw-r--r--Documentation/media/uapi/dvb/fe-set-tone.rst38
-rw-r--r--Documentation/media/uapi/dvb/fe-set-voltage.rst8
-rw-r--r--Documentation/media/uapi/dvb/fe-type-t.rst2
-rw-r--r--Documentation/media/uapi/dvb/fe_property_parameters.rst1373
-rw-r--r--Documentation/media/uapi/dvb/frontend-header.rst4
-rw-r--r--Documentation/media/uapi/dvb/frontend-property-terrestrial-systems.rst2
-rw-r--r--Documentation/media/uapi/dvb/frontend.rst39
-rw-r--r--Documentation/media/uapi/dvb/frontend_f_close.rst16
-rw-r--r--Documentation/media/uapi/dvb/frontend_f_open.rst44
-rw-r--r--Documentation/media/uapi/dvb/frontend_h.rst9
-rw-r--r--Documentation/media/uapi/dvb/frontend_legacy_dvbv3_api.rst6
-rw-r--r--Documentation/media/uapi/dvb/headers.rst21
-rw-r--r--Documentation/media/uapi/dvb/intro.rst95
-rw-r--r--Documentation/media/uapi/dvb/legacy_dvb_apis.rst28
-rw-r--r--Documentation/media/uapi/dvb/net-add-if.rst42
-rw-r--r--Documentation/media/uapi/dvb/net-get-if.rst8
-rw-r--r--Documentation/media/uapi/dvb/net-remove-if.rst8
-rw-r--r--Documentation/media/uapi/dvb/net-types.rst9
-rw-r--r--Documentation/media/uapi/dvb/net.rst15
-rw-r--r--Documentation/media/uapi/dvb/net_h.rst9
-rw-r--r--Documentation/media/uapi/dvb/query-dvb-frontend-info.rst4
-rw-r--r--Documentation/media/uapi/dvb/video-continue.rst2
-rw-r--r--Documentation/media/uapi/dvb/video-freeze.rst4
-rw-r--r--Documentation/media/uapi/dvb/video-get-event.rst2
-rw-r--r--Documentation/media/uapi/dvb/video-play.rst2
-rw-r--r--Documentation/media/uapi/dvb/video-select-source.rst2
-rw-r--r--Documentation/media/uapi/dvb/video-stop.rst2
-rw-r--r--Documentation/media/uapi/dvb/video.rst15
-rw-r--r--Documentation/media/uapi/dvb/video_h.rst9
-rw-r--r--Documentation/media/uapi/gen-errors.rst49
-rw-r--r--Documentation/media/uapi/mediactl/media-controller.rst4
-rw-r--r--Documentation/media/uapi/mediactl/media-ioc-enum-entities.rst2
-rw-r--r--Documentation/media/uapi/mediactl/media-ioc-g-topology.rst2
-rw-r--r--Documentation/media/uapi/mediactl/media-types.rst2
-rw-r--r--Documentation/media/uapi/rc/rc-sysfs-nodes.rst10
-rw-r--r--Documentation/media/uapi/rc/remote_controllers.rst4
-rw-r--r--Documentation/media/uapi/v4l/colorspaces-defs.rst (renamed from Documentation/media/uapi/v4l/pixfmt-006.rst)4
-rw-r--r--Documentation/media/uapi/v4l/colorspaces-details.rst (renamed from Documentation/media/uapi/v4l/pixfmt-007.rst)47
-rw-r--r--Documentation/media/uapi/v4l/dev-meta.rst2
-rw-r--r--Documentation/media/uapi/v4l/dev-sliced-vbi.rst23
-rw-r--r--Documentation/media/uapi/v4l/dev-subdev.rst8
-rw-r--r--Documentation/media/uapi/v4l/driver.rst9
-rw-r--r--Documentation/media/uapi/v4l/extended-controls.rst32
-rw-r--r--Documentation/media/uapi/v4l/format.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-008.rst32
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-compressed.rst (renamed from Documentation/media/uapi/v4l/pixfmt-013.rst)0
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-intro.rst (renamed from Documentation/media/uapi/v4l/pixfmt-004.rst)0
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-inzi.rst7
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-m420.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-nv12.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-nv12m.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-nv16.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-nv16m.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst30
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-packed-rgb.rst178
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-packed-yuv.rst47
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-rgb.rst1
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-srggb10p.rst14
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-srggb12p.rst86
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-uyvy.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst (renamed from Documentation/media/uapi/v4l/pixfmt-003.rst)0
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-v4l2.rst (renamed from Documentation/media/uapi/v4l/pixfmt-002.rst)0
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-vyuy.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-y41p.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-yuv410.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-yuv411p.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-yuv420.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-yuv420m.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-yuv422m.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-yuv422p.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-yuv444m.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-yuyv.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt-yvyu.rst2
-rw-r--r--Documentation/media/uapi/v4l/pixfmt.rst15
-rw-r--r--Documentation/media/uapi/v4l/subdev-formats.rst17
-rw-r--r--Documentation/media/uapi/v4l/v4l2-selection-targets.rst2
-rw-r--r--Documentation/media/uapi/v4l/v4l2.rst5
-rw-r--r--Documentation/media/uapi/v4l/vidioc-create-bufs.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-cropcap.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-dbg-g-chip-info.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-dbg-g-register.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-dqevent.rst3
-rw-r--r--Documentation/media/uapi/v4l/vidioc-dv-timings-cap.rst3
-rw-r--r--Documentation/media/uapi/v4l/vidioc-encoder-cmd.rst2
-rw-r--r--Documentation/media/uapi/v4l/vidioc-enum-dv-timings.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-enum-fmt.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-enum-frameintervals.rst7
-rw-r--r--Documentation/media/uapi/v4l/vidioc-enum-framesizes.rst4
-rw-r--r--Documentation/media/uapi/v4l/vidioc-enum-freq-bands.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-enumaudio.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-enumaudioout.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-enuminput.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-enumoutput.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-enumstd.rst10
-rw-r--r--Documentation/media/uapi/v4l/vidioc-expbuf.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-audio.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-audioout.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-crop.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-ctrl.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst5
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-edid.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-enc-index.rst3
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-ext-ctrls.rst3
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-fbuf.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-fmt.rst3
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-frequency.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-input.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-jpegcomp.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-modulator.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-output.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-parm.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-priority.rst2
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-selection.rst5
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-sliced-vbi-cap.rst7
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-std.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-g-tuner.rst14
-rw-r--r--Documentation/media/uapi/v4l/vidioc-overlay.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-prepare-buf.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-qbuf.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-query-dv-timings.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-querybuf.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-querycap.rst8
-rw-r--r--Documentation/media/uapi/v4l/vidioc-queryctrl.rst4
-rw-r--r--Documentation/media/uapi/v4l/vidioc-querystd.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-reqbufs.rst2
-rw-r--r--Documentation/media/uapi/v4l/vidioc-s-hw-freq-seek.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-streamon.rst2
-rw-r--r--Documentation/media/uapi/v4l/vidioc-subdev-enum-frame-interval.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-subdev-enum-frame-size.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-subdev-enum-mbus-code.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-subdev-g-crop.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-subdev-g-fmt.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-subdev-g-frame-interval.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-subdev-g-selection.rst1
-rw-r--r--Documentation/media/uapi/v4l/vidioc-subscribe-event.rst5
-rw-r--r--Documentation/media/v4l-drivers/au0828-cardlist.rst44
-rw-r--r--Documentation/media/v4l-drivers/bttv-cardlist.rst849
-rw-r--r--Documentation/media/v4l-drivers/cx23885-cardlist.rst304
-rw-r--r--Documentation/media/v4l-drivers/cx88-cardlist.rst469
-rw-r--r--Documentation/media/v4l-drivers/em28xx-cardlist.rst523
-rw-r--r--Documentation/media/v4l-drivers/index.rst5
-rw-r--r--Documentation/media/v4l-drivers/ivtv-cardlist.rst169
-rw-r--r--Documentation/media/v4l-drivers/qcom_camss.rst156
-rw-r--r--Documentation/media/v4l-drivers/qcom_camss_graph.dot41
-rw-r--r--Documentation/media/v4l-drivers/saa7134-cardlist.rst999
-rw-r--r--Documentation/media/v4l-drivers/saa7164-cardlist.rst84
-rw-r--r--Documentation/media/v4l-drivers/tm6000-cardlist.rst99
-rw-r--r--Documentation/media/v4l-drivers/usbvision-cardlist.rst349
-rw-r--r--Documentation/media/v4l-drivers/vivid.rst1
-rw-r--r--MAINTAINERS82
-rw-r--r--arch/arm/boot/dts/omap3-n950-n9.dtsi14
-rw-r--r--arch/arm/configs/imx_v6_v7_defconfig2
-rw-r--r--arch/arm/configs/omap2plus_defconfig2
-rw-r--r--arch/arm/configs/sunxi_defconfig2
-rw-r--r--arch/mips/configs/pistachio_defconfig2
-rw-r--r--drivers/hid/hid-picolcd_cir.c4
-rw-r--r--drivers/leds/Kconfig9
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-aat1290.c4
-rw-r--r--drivers/leds/leds-as3645a.c763
-rw-r--r--drivers/leds/leds-max77693.c4
-rw-r--r--drivers/media/Kconfig20
-rw-r--r--drivers/media/cec/Makefile4
-rw-r--r--drivers/media/cec/cec-adap.c284
-rw-r--r--drivers/media/cec/cec-api.c92
-rw-r--r--drivers/media/cec/cec-core.c27
-rw-r--r--drivers/media/cec/cec-pin.c802
-rw-r--r--drivers/media/common/saa7146/saa7146_i2c.c2
-rw-r--r--drivers/media/common/saa7146/saa7146_vbi.c2
-rw-r--r--drivers/media/common/saa7146/saa7146_video.c2
-rw-r--r--drivers/media/common/siano/smsir.c6
-rw-r--r--drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c150
-rw-r--r--drivers/media/common/v4l2-tpg/v4l2-tpg-core.c2
-rw-r--r--drivers/media/dvb-core/demux.h2
-rw-r--r--drivers/media/dvb-core/dmxdev.c24
-rw-r--r--drivers/media/dvb-core/dvb-usb-ids.h1
-rw-r--r--drivers/media/dvb-core/dvb_ca_en50221.c945
-rw-r--r--drivers/media/dvb-core/dvb_ca_en50221.h10
-rw-r--r--drivers/media/dvb-core/dvb_frontend.c15
-rw-r--r--drivers/media/dvb-frontends/Kconfig27
-rw-r--r--drivers/media/dvb-frontends/Makefile3
-rw-r--r--drivers/media/dvb-frontends/cx24123.c2
-rw-r--r--drivers/media/dvb-frontends/cxd2841er.c75
-rw-r--r--drivers/media/dvb-frontends/dib0090.c11
-rw-r--r--drivers/media/dvb-frontends/dib7000p.c2
-rw-r--r--drivers/media/dvb-frontends/dib8000.c20
-rw-r--r--drivers/media/dvb-frontends/dib8000.h1
-rw-r--r--drivers/media/dvb-frontends/dib9000.c22
-rw-r--r--drivers/media/dvb-frontends/dib9000.h7
-rw-r--r--drivers/media/dvb-frontends/drx39xyj/drxj.c35
-rw-r--r--drivers/media/dvb-frontends/drxd_hard.c6
-rw-r--r--drivers/media/dvb-frontends/isl6421.c76
-rw-r--r--drivers/media/dvb-frontends/mb86a16.c25
-rw-r--r--drivers/media/dvb-frontends/mn88472.c4
-rw-r--r--drivers/media/dvb-frontends/mn88473.c4
-rw-r--r--drivers/media/dvb-frontends/mxl5xx.c1873
-rw-r--r--drivers/media/dvb-frontends/mxl5xx.h41
-rw-r--r--drivers/media/dvb-frontends/mxl5xx_defs.h731
-rw-r--r--drivers/media/dvb-frontends/mxl5xx_regs.h367
-rw-r--r--drivers/media/dvb-frontends/s5h1420.c2
-rw-r--r--drivers/media/dvb-frontends/stv0367.c156
-rw-r--r--drivers/media/dvb-frontends/stv0910.c1813
-rw-r--r--drivers/media/dvb-frontends/stv0910.h32
-rw-r--r--drivers/media/dvb-frontends/stv0910_regs.h4760
-rw-r--r--drivers/media/dvb-frontends/stv6111.c681
-rw-r--r--drivers/media/dvb-frontends/stv6111.h21
-rw-r--r--drivers/media/dvb-frontends/zd1301_demod.c2
-rw-r--r--drivers/media/i2c/Kconfig36
-rw-r--r--drivers/media/i2c/Makefile3
-rw-r--r--drivers/media/i2c/ad9389b.c2
-rw-r--r--drivers/media/i2c/adv7180.c2
-rw-r--r--drivers/media/i2c/adv748x/Makefile7
-rw-r--r--drivers/media/i2c/adv748x/adv748x-afe.c552
-rw-r--r--drivers/media/i2c/adv748x/adv748x-core.c833
-rw-r--r--drivers/media/i2c/adv748x/adv748x-csi2.c326
-rw-r--r--drivers/media/i2c/adv748x/adv748x-hdmi.c768
-rw-r--r--drivers/media/i2c/adv748x/adv748x.h425
-rw-r--r--drivers/media/i2c/adv7511.c5
-rw-r--r--drivers/media/i2c/adv7604.c7
-rw-r--r--drivers/media/i2c/adv7842.c5
-rw-r--r--drivers/media/i2c/dw9714.c26
-rw-r--r--drivers/media/i2c/et8ek8/et8ek8_driver.c26
-rw-r--r--drivers/media/i2c/ir-kbd-i2c.c59
-rw-r--r--drivers/media/i2c/m5mols/m5mols_core.c2
-rw-r--r--drivers/media/i2c/max2175.c2
-rw-r--r--drivers/media/i2c/mt9m111.c6
-rw-r--r--drivers/media/i2c/mt9t001.c8
-rw-r--r--drivers/media/i2c/ov13858.c101
-rw-r--r--drivers/media/i2c/ov5640.c3
-rw-r--r--drivers/media/i2c/ov5645.c49
-rw-r--r--drivers/media/i2c/ov5670.c2601
-rw-r--r--drivers/media/i2c/ov6650.c (renamed from drivers/media/i2c/soc_camera/ov6650.c)77
-rw-r--r--drivers/media/i2c/ov7670.c6
-rw-r--r--drivers/media/i2c/ov9650.c67
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3-core.c3
-rw-r--r--drivers/media/i2c/s5k5baf.c9
-rw-r--r--drivers/media/i2c/saa7127.c2
-rw-r--r--drivers/media/i2c/saa717x.c2
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c16
-rw-r--r--drivers/media/i2c/smiapp/smiapp-quirk.c8
-rw-r--r--drivers/media/i2c/soc_camera/Kconfig6
-rw-r--r--drivers/media/i2c/soc_camera/Makefile1
-rw-r--r--drivers/media/i2c/soc_camera/mt9t031.c2
-rw-r--r--drivers/media/i2c/tc358743.c2
-rw-r--r--drivers/media/i2c/ths8200.c2
-rw-r--r--drivers/media/i2c/vs6624.c2
-rw-r--r--drivers/media/media-device.c16
-rw-r--r--drivers/media/media-entity.c2
-rw-r--r--drivers/media/pci/b2c2/flexcop-pci.c2
-rw-r--r--drivers/media/pci/bt8xx/bt878.c2
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c4
-rw-r--r--drivers/media/pci/bt8xx/bttv-i2c.c2
-rw-r--r--drivers/media/pci/bt8xx/bttv-input.c18
-rw-r--r--drivers/media/pci/bt8xx/dst_ca.c70
-rw-r--r--drivers/media/pci/cobalt/cobalt-alsa-pcm.c4
-rw-r--r--drivers/media/pci/cobalt/cobalt-driver.c2
-rw-r--r--drivers/media/pci/cobalt/cobalt-i2c.c2
-rw-r--r--drivers/media/pci/cx18/cx18-alsa-mixer.c2
-rw-r--r--drivers/media/pci/cx18/cx18-alsa-pcm.c2
-rw-r--r--drivers/media/pci/cx18/cx18-driver.c2
-rw-r--r--drivers/media/pci/cx18/cx18-i2c.c8
-rw-r--r--drivers/media/pci/cx18/cx18-streams.c4
-rw-r--r--drivers/media/pci/cx23885/cx23885-417.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-alsa.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-cards.c6
-rw-r--r--drivers/media/pci/cx23885/cx23885-core.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-dvb.c10
-rw-r--r--drivers/media/pci/cx23885/cx23885-i2c.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-input.c16
-rw-r--r--drivers/media/pci/cx25821/cx25821-alsa.c2
-rw-r--r--drivers/media/pci/cx25821/cx25821-core.c5
-rw-r--r--drivers/media/pci/cx25821/cx25821-i2c.c2
-rw-r--r--drivers/media/pci/cx25821/cx25821.h2
-rw-r--r--drivers/media/pci/cx88/cx88-alsa.c2
-rw-r--r--drivers/media/pci/cx88/cx88-blackbird.c2
-rw-r--r--drivers/media/pci/cx88/cx88-input.c30
-rw-r--r--drivers/media/pci/ddbridge/Kconfig21
-rw-r--r--drivers/media/pci/ddbridge/Makefile3
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-core.c4070
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-hw.c376
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-hw.h43
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-i2c.c230
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-i2c.h112
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-io.h71
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-main.c346
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-maxs8.c444
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-maxs8.h29
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-regs.h159
-rw-r--r--drivers/media/pci/ddbridge/ddbridge.h341
-rw-r--r--drivers/media/pci/dm1105/dm1105.c8
-rw-r--r--drivers/media/pci/dt3155/dt3155.c2
-rw-r--r--drivers/media/pci/ivtv/ivtv-alsa-mixer.c2
-rw-r--r--drivers/media/pci/ivtv/ivtv-alsa-pcm.c2
-rw-r--r--drivers/media/pci/ivtv/ivtv-driver.c2
-rw-r--r--drivers/media/pci/ivtv/ivtv-i2c.c18
-rw-r--r--drivers/media/pci/mantis/hopper_cards.c2
-rw-r--r--drivers/media/pci/mantis/mantis_cards.c2
-rw-r--r--drivers/media/pci/mantis/mantis_common.h2
-rw-r--r--drivers/media/pci/mantis/mantis_i2c.c2
-rw-r--r--drivers/media/pci/mantis/mantis_input.c6
-rw-r--r--drivers/media/pci/meye/meye.c4
-rw-r--r--drivers/media/pci/netup_unidvb/netup_unidvb_core.c2
-rw-r--r--drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c2
-rw-r--r--drivers/media/pci/ngene/ngene-i2c.c2
-rw-r--r--drivers/media/pci/pluto2/pluto2.c2
-rw-r--r--drivers/media/pci/pt1/pt1.c2
-rw-r--r--drivers/media/pci/pt3/pt3.c11
-rw-r--r--drivers/media/pci/saa7134/saa7134-alsa.c2
-rw-r--r--drivers/media/pci/saa7134/saa7134-empress.c2
-rw-r--r--drivers/media/pci/saa7134/saa7134-i2c.c2
-rw-r--r--drivers/media/pci/saa7134/saa7134-input.c81
-rw-r--r--drivers/media/pci/saa7146/hexium_gemini.c2
-rw-r--r--drivers/media/pci/saa7146/hexium_orion.c2
-rw-r--r--drivers/media/pci/saa7146/mxb.c2
-rw-r--r--drivers/media/pci/saa7164/saa7164-core.c2
-rw-r--r--drivers/media/pci/saa7164/saa7164-i2c.c2
-rw-r--r--drivers/media/pci/smipcie/smipcie-ir.c6
-rw-r--r--drivers/media/pci/smipcie/smipcie.h2
-rw-r--r--drivers/media/pci/solo6x10/solo6x10-g723.c2
-rw-r--r--drivers/media/pci/solo6x10/solo6x10-gpio.c97
-rw-r--r--drivers/media/pci/solo6x10/solo6x10-tw28.c3
-rw-r--r--drivers/media/pci/solo6x10/solo6x10-v4l2.c2
-rw-r--r--drivers/media/pci/solo6x10/solo6x10.h5
-rw-r--r--drivers/media/pci/sta2x11/sta2x11_vip.c2
-rw-r--r--drivers/media/pci/ttpci/av7110.c2
-rw-r--r--drivers/media/pci/ttpci/av7110.h2
-rw-r--r--drivers/media/pci/ttpci/av7110_ca.c12
-rw-r--r--drivers/media/pci/ttpci/av7110_v4l.c2
-rw-r--r--drivers/media/pci/ttpci/budget-av.c2
-rw-r--r--drivers/media/pci/ttpci/budget-ci.c9
-rw-r--r--drivers/media/pci/ttpci/budget-patch.c2
-rw-r--r--drivers/media/pci/ttpci/budget.c2
-rw-r--r--drivers/media/pci/tw68/tw68-video.c2
-rw-r--r--drivers/media/pci/zoran/zoran_card.c2
-rw-r--r--drivers/media/platform/Kconfig21
-rw-r--r--drivers/media/platform/Makefile4
-rw-r--r--drivers/media/platform/am437x/am437x-vpfe.c4
-rw-r--r--drivers/media/platform/atmel/atmel-isc.c6
-rw-r--r--drivers/media/platform/blackfin/bfin_capture.c4
-rw-r--r--drivers/media/platform/coda/coda-bit.c29
-rw-r--r--drivers/media/platform/coda/coda-common.c78
-rw-r--r--drivers/media/platform/coda/coda_regs.h1
-rw-r--r--drivers/media/platform/coda/imx-vdoa.c2
-rw-r--r--drivers/media/platform/davinci/vpbe.c2
-rw-r--r--drivers/media/platform/davinci/vpbe_display.c4
-rw-r--r--drivers/media/platform/davinci/vpbe_osd.c2
-rw-r--r--drivers/media/platform/davinci/vpbe_venc.c2
-rw-r--r--drivers/media/platform/davinci/vpfe_capture.c2
-rw-r--r--drivers/media/platform/davinci/vpif_capture.c28
-rw-r--r--drivers/media/platform/davinci/vpif_display.c2
-rw-r--r--drivers/media/platform/exynos-gsc/gsc-m2m.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-is-i2c.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-is.c8
-rw-r--r--drivers/media/platform/exynos4-is/fimc-isp.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-lite.c5
-rw-r--r--drivers/media/platform/exynos4-is/fimc-m2m.c2
-rw-r--r--drivers/media/platform/exynos4-is/media-dev.c8
-rw-r--r--drivers/media/platform/exynos4-is/mipi-csis.c4
-rw-r--r--drivers/media/platform/fsl-viu.c6
-rw-r--r--drivers/media/platform/m2m-deinterlace.c4
-rw-r--r--drivers/media/platform/marvell-ccic/cafe-driver.c4
-rw-r--r--drivers/media/platform/marvell-ccic/mcam-core.c2
-rw-r--r--drivers/media/platform/meson/Makefile1
-rw-r--r--drivers/media/platform/meson/ao-cec.c744
-rw-r--r--drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c4
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_comp.c10
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_core.c8
-rw-r--r--drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c4
-rw-r--r--drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c37
-rw-r--r--drivers/media/platform/mx2_emmaprp.c6
-rw-r--r--drivers/media/platform/omap/omap_vout_vrfb.c3
-rw-r--r--drivers/media/platform/omap3isp/isp.c161
-rw-r--r--drivers/media/platform/omap3isp/isp.h4
-rw-r--r--drivers/media/platform/omap3isp/ispccdc.c22
-rw-r--r--drivers/media/platform/omap3isp/ispccp2.c18
-rw-r--r--drivers/media/platform/omap3isp/ispcsi2.c6
-rw-r--r--drivers/media/platform/omap3isp/ispcsiphy.c91
-rw-r--r--drivers/media/platform/omap3isp/ispcsiphy.h7
-rw-r--r--drivers/media/platform/omap3isp/ispreg.h4
-rw-r--r--drivers/media/platform/omap3isp/omap3isp.h6
-rw-r--r--drivers/media/platform/pxa_camera.c9
-rw-r--r--drivers/media/platform/qcom/camss-8x16/Makefile11
-rw-r--r--drivers/media/platform/qcom/camss-8x16/camss-csid.c1092
-rw-r--r--drivers/media/platform/qcom/camss-8x16/camss-csid.h82
-rw-r--r--drivers/media/platform/qcom/camss-8x16/camss-csiphy.c890
-rw-r--r--drivers/media/platform/qcom/camss-8x16/camss-csiphy.h77
-rw-r--r--drivers/media/platform/qcom/camss-8x16/camss-ispif.c1175
-rw-r--r--drivers/media/platform/qcom/camss-8x16/camss-ispif.h85
-rw-r--r--drivers/media/platform/qcom/camss-8x16/camss-vfe.c3088
-rw-r--r--drivers/media/platform/qcom/camss-8x16/camss-vfe.h123
-rw-r--r--drivers/media/platform/qcom/camss-8x16/camss-video.c860
-rw-r--r--drivers/media/platform/qcom/camss-8x16/camss-video.h70
-rw-r--r--drivers/media/platform/qcom/camss-8x16/camss.c746
-rw-r--r--drivers/media/platform/qcom/camss-8x16/camss.h106
-rw-r--r--drivers/media/platform/qcom/venus/helpers.c51
-rw-r--r--drivers/media/platform/qcom/venus/helpers.h1
-rw-r--r--drivers/media/platform/qcom/venus/vdec.c31
-rw-r--r--drivers/media/platform/qcom/venus/venc.c47
-rw-r--r--drivers/media/platform/rcar-vin/rcar-core.c4
-rw-r--r--drivers/media/platform/rcar_fdp1.c2
-rw-r--r--drivers/media/platform/rcar_jpu.c2
-rw-r--r--drivers/media/platform/s3c-camif/camif-core.c1
-rw-r--r--drivers/media/platform/s5p-cec/s5p_cec.c7
-rw-r--r--drivers/media/platform/s5p-g2d/g2d.c4
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-core.c200
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-core.h8
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c9
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-regs.h2
-rw-r--r--drivers/media/platform/soc_camera/soc_camera.c8
-rw-r--r--drivers/media/platform/soc_camera/soc_mediabus.c3
-rw-r--r--drivers/media/platform/sti/bdisp/bdisp-v4l2.c2
-rw-r--r--drivers/media/platform/sti/cec/stih-cec.c4
-rw-r--r--drivers/media/platform/sti/delta/delta-v4l2.c6
-rw-r--r--drivers/media/platform/stm32/stm32-cec.c4
-rw-r--r--drivers/media/platform/stm32/stm32-dcmi.c495
-rw-r--r--drivers/media/platform/ti-vpe/cal.c4
-rw-r--r--drivers/media/platform/ti-vpe/vpe.c4
-rw-r--r--drivers/media/platform/via-camera.c2
-rw-r--r--drivers/media/platform/video-mux.c53
-rw-r--r--drivers/media/platform/vim2m.c4
-rw-r--r--drivers/media/platform/vimc/vimc-debayer.c2
-rw-r--r--drivers/media/platform/vimc/vimc-scaler.c2
-rw-r--r--drivers/media/platform/vimc/vimc-sensor.c2
-rw-r--r--drivers/media/platform/vivid/vivid-cec.c66
-rw-r--r--drivers/media/platform/vivid/vivid-core.c8
-rw-r--r--drivers/media/platform/vsp1/vsp1_entity.h7
-rw-r--r--drivers/media/platform/vsp1/vsp1_pipe.c22
-rw-r--r--drivers/media/platform/vsp1/vsp1_pipe.h46
-rw-r--r--drivers/media/platform/vsp1/vsp1_regs.h14
-rw-r--r--drivers/media/platform/vsp1/vsp1_rpf.c27
-rw-r--r--drivers/media/platform/vsp1/vsp1_sru.c26
-rw-r--r--drivers/media/platform/vsp1/vsp1_uds.c57
-rw-r--r--drivers/media/platform/vsp1/vsp1_video.c182
-rw-r--r--drivers/media/platform/vsp1/vsp1_wpf.c24
-rw-r--r--drivers/media/platform/xilinx/xilinx-vipp.c52
-rw-r--r--drivers/media/radio/dsbr100.c2
-rw-r--r--drivers/media/radio/radio-cadet.c2
-rw-r--r--drivers/media/radio/radio-gemtek.c2
-rw-r--r--drivers/media/radio/radio-keene.c2
-rw-r--r--drivers/media/radio/radio-ma901.c2
-rw-r--r--drivers/media/radio/radio-maxiradio.c2
-rw-r--r--drivers/media/radio/radio-mr800.c2
-rw-r--r--drivers/media/radio/radio-raremono.c2
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c2
-rw-r--r--drivers/media/radio/radio-shark.c2
-rw-r--r--drivers/media/radio/radio-shark2.c2
-rw-r--r--drivers/media/radio/radio-tea5764.c2
-rw-r--r--drivers/media/radio/radio-wl1273.c2
-rw-r--r--drivers/media/radio/si470x/radio-si470x-usb.c2
-rw-r--r--drivers/media/radio/si4713/radio-platform-si4713.c2
-rw-r--r--drivers/media/radio/si4713/radio-usb-si4713.c4
-rw-r--r--drivers/media/radio/wl128x/fmdrv_v4l2.c2
-rw-r--r--drivers/media/rc/Kconfig53
-rw-r--r--drivers/media/rc/Makefile3
-rw-r--r--drivers/media/rc/ati_remote.c7
-rw-r--r--drivers/media/rc/ene_ir.c6
-rw-r--r--drivers/media/rc/fintek-cir.c4
-rw-r--r--drivers/media/rc/gpio-ir-recv.c31
-rw-r--r--drivers/media/rc/gpio-ir-tx.c176
-rw-r--r--drivers/media/rc/igorplugusb.c11
-rw-r--r--drivers/media/rc/iguanair.c4
-rw-r--r--drivers/media/rc/img-ir/img-ir-hw.c6
-rw-r--r--drivers/media/rc/img-ir/img-ir-hw.h4
-rw-r--r--drivers/media/rc/img-ir/img-ir-jvc.c4
-rw-r--r--drivers/media/rc/img-ir/img-ir-nec.c20
-rw-r--r--drivers/media/rc/img-ir/img-ir-raw.c6
-rw-r--r--drivers/media/rc/img-ir/img-ir-rc5.c4
-rw-r--r--drivers/media/rc/img-ir/img-ir-rc6.c4
-rw-r--r--drivers/media/rc/img-ir/img-ir-sanyo.c4
-rw-r--r--drivers/media/rc/img-ir/img-ir-sharp.c4
-rw-r--r--drivers/media/rc/img-ir/img-ir-sony.c27
-rw-r--r--drivers/media/rc/imon.c55
-rw-r--r--drivers/media/rc/ir-hix5hd2.c4
-rw-r--r--drivers/media/rc/ir-jvc-decoder.c6
-rw-r--r--drivers/media/rc/ir-mce_kbd-decoder.c12
-rw-r--r--drivers/media/rc/ir-nec-decoder.c57
-rw-r--r--drivers/media/rc/ir-rc5-decoder.c25
-rw-r--r--drivers/media/rc/ir-rc6-decoder.c30
-rw-r--r--drivers/media/rc/ir-sanyo-decoder.c16
-rw-r--r--drivers/media/rc/ir-sharp-decoder.c6
-rw-r--r--drivers/media/rc/ir-sony-decoder.c23
-rw-r--r--drivers/media/rc/ir-spi.c1
-rw-r--r--drivers/media/rc/ir-xmp-decoder.c4
-rw-r--r--drivers/media/rc/ite-cir.c4
-rw-r--r--drivers/media/rc/keymaps/Makefile3
-rw-r--r--drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c8
-rw-r--r--drivers/media/rc/keymaps/rc-alink-dtu-m.c8
-rw-r--r--drivers/media/rc/keymaps/rc-anysee.c8
-rw-r--r--drivers/media/rc/keymaps/rc-apac-viewcomp.c8
-rw-r--r--drivers/media/rc/keymaps/rc-asus-pc39.c8
-rw-r--r--drivers/media/rc/keymaps/rc-asus-ps3-100.c8
-rw-r--r--drivers/media/rc/keymaps/rc-ati-tv-wonder-hd-600.c8
-rw-r--r--drivers/media/rc/keymaps/rc-ati-x10.c8
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia-a16d.c8
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia-cardbus.c8
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia-dvbt.c8
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia-m135a.c8
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia-m733a-rm-k6.c8
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia-rm-ks.c8
-rw-r--r--drivers/media/rc/keymaps/rc-avermedia.c8
-rw-r--r--drivers/media/rc/keymaps/rc-avertv-303.c8
-rw-r--r--drivers/media/rc/keymaps/rc-azurewave-ad-tu700.c8
-rw-r--r--drivers/media/rc/keymaps/rc-behold-columbus.c8
-rw-r--r--drivers/media/rc/keymaps/rc-behold.c8
-rw-r--r--drivers/media/rc/keymaps/rc-budget-ci-old.c8
-rw-r--r--drivers/media/rc/keymaps/rc-cec.c2
-rw-r--r--drivers/media/rc/keymaps/rc-cinergy-1400.c8
-rw-r--r--drivers/media/rc/keymaps/rc-cinergy.c8
-rw-r--r--drivers/media/rc/keymaps/rc-d680-dmb.c8
-rw-r--r--drivers/media/rc/keymaps/rc-delock-61959.c8
-rw-r--r--drivers/media/rc/keymaps/rc-dib0700-nec.c8
-rw-r--r--drivers/media/rc/keymaps/rc-dib0700-rc5.c8
-rw-r--r--drivers/media/rc/keymaps/rc-digitalnow-tinytwin.c8
-rw-r--r--drivers/media/rc/keymaps/rc-digittrade.c8
-rw-r--r--drivers/media/rc/keymaps/rc-dm1105-nec.c8
-rw-r--r--drivers/media/rc/keymaps/rc-dntv-live-dvb-t.c8
-rw-r--r--drivers/media/rc/keymaps/rc-dntv-live-dvbt-pro.c8
-rw-r--r--drivers/media/rc/keymaps/rc-dtt200u.c8
-rw-r--r--drivers/media/rc/keymaps/rc-dvbsky.c8
-rw-r--r--drivers/media/rc/keymaps/rc-dvico-mce.c8
-rw-r--r--drivers/media/rc/keymaps/rc-dvico-portable.c8
-rw-r--r--drivers/media/rc/keymaps/rc-em-terratec.c8
-rw-r--r--drivers/media/rc/keymaps/rc-encore-enltv-fm53.c8
-rw-r--r--drivers/media/rc/keymaps/rc-encore-enltv.c8
-rw-r--r--drivers/media/rc/keymaps/rc-encore-enltv2.c8
-rw-r--r--drivers/media/rc/keymaps/rc-evga-indtube.c8
-rw-r--r--drivers/media/rc/keymaps/rc-eztv.c8
-rw-r--r--drivers/media/rc/keymaps/rc-flydvb.c8
-rw-r--r--drivers/media/rc/keymaps/rc-flyvideo.c8
-rw-r--r--drivers/media/rc/keymaps/rc-fusionhdtv-mce.c8
-rw-r--r--drivers/media/rc/keymaps/rc-gadmei-rm008z.c8
-rw-r--r--drivers/media/rc/keymaps/rc-geekbox.c8
-rw-r--r--drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c8
-rw-r--r--drivers/media/rc/keymaps/rc-gotview7135.c8
-rw-r--r--drivers/media/rc/keymaps/rc-hauppauge.c8
-rw-r--r--drivers/media/rc/keymaps/rc-imon-mce.c8
-rw-r--r--drivers/media/rc/keymaps/rc-imon-pad.c8
-rw-r--r--drivers/media/rc/keymaps/rc-iodata-bctv7e.c8
-rw-r--r--drivers/media/rc/keymaps/rc-it913x-v1.c8
-rw-r--r--drivers/media/rc/keymaps/rc-it913x-v2.c8
-rw-r--r--drivers/media/rc/keymaps/rc-kaiomy.c8
-rw-r--r--drivers/media/rc/keymaps/rc-kworld-315u.c8
-rw-r--r--drivers/media/rc/keymaps/rc-kworld-pc150u.c8
-rw-r--r--drivers/media/rc/keymaps/rc-kworld-plus-tv-analog.c8
-rw-r--r--drivers/media/rc/keymaps/rc-leadtek-y04g0051.c8
-rw-r--r--drivers/media/rc/keymaps/rc-lme2510.c8
-rw-r--r--drivers/media/rc/keymaps/rc-manli.c8
-rw-r--r--drivers/media/rc/keymaps/rc-medion-x10-digitainer.c8
-rw-r--r--drivers/media/rc/keymaps/rc-medion-x10-or2x.c8
-rw-r--r--drivers/media/rc/keymaps/rc-medion-x10.c8
-rw-r--r--drivers/media/rc/keymaps/rc-msi-digivox-ii.c8
-rw-r--r--drivers/media/rc/keymaps/rc-msi-digivox-iii.c8
-rw-r--r--drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c8
-rw-r--r--drivers/media/rc/keymaps/rc-msi-tvanywhere.c8
-rw-r--r--drivers/media/rc/keymaps/rc-nebula.c8
-rw-r--r--drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c8
-rw-r--r--drivers/media/rc/keymaps/rc-norwood.c8
-rw-r--r--drivers/media/rc/keymaps/rc-npgtech.c8
-rw-r--r--drivers/media/rc/keymaps/rc-pctv-sedna.c8
-rw-r--r--drivers/media/rc/keymaps/rc-pinnacle-color.c8
-rw-r--r--drivers/media/rc/keymaps/rc-pinnacle-grey.c8
-rw-r--r--drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c8
-rw-r--r--drivers/media/rc/keymaps/rc-pixelview-002t.c8
-rw-r--r--drivers/media/rc/keymaps/rc-pixelview-mk12.c8
-rw-r--r--drivers/media/rc/keymaps/rc-pixelview-new.c8
-rw-r--r--drivers/media/rc/keymaps/rc-pixelview.c8
-rw-r--r--drivers/media/rc/keymaps/rc-powercolor-real-angel.c8
-rw-r--r--drivers/media/rc/keymaps/rc-proteus-2309.c8
-rw-r--r--drivers/media/rc/keymaps/rc-purpletv.c8
-rw-r--r--drivers/media/rc/keymaps/rc-pv951.c8
-rw-r--r--drivers/media/rc/keymaps/rc-rc6-mce.c8
-rw-r--r--drivers/media/rc/keymaps/rc-real-audio-220-32-keys.c8
-rw-r--r--drivers/media/rc/keymaps/rc-reddo.c8
-rw-r--r--drivers/media/rc/keymaps/rc-snapstream-firefly.c8
-rw-r--r--drivers/media/rc/keymaps/rc-streamzap.c8
-rw-r--r--drivers/media/rc/keymaps/rc-su3000.c8
-rw-r--r--drivers/media/rc/keymaps/rc-tbs-nec.c8
-rw-r--r--drivers/media/rc/keymaps/rc-technisat-ts35.c8
-rw-r--r--drivers/media/rc/keymaps/rc-technisat-usb2.c8
-rw-r--r--drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.c8
-rw-r--r--drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.c8
-rw-r--r--drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c8
-rw-r--r--drivers/media/rc/keymaps/rc-terratec-slim-2.c8
-rw-r--r--drivers/media/rc/keymaps/rc-terratec-slim.c8
-rw-r--r--drivers/media/rc/keymaps/rc-tevii-nec.c8
-rw-r--r--drivers/media/rc/keymaps/rc-tivo.c8
-rw-r--r--drivers/media/rc/keymaps/rc-total-media-in-hand-02.c8
-rw-r--r--drivers/media/rc/keymaps/rc-total-media-in-hand.c8
-rw-r--r--drivers/media/rc/keymaps/rc-trekstor.c8
-rw-r--r--drivers/media/rc/keymaps/rc-tt-1500.c8
-rw-r--r--drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c8
-rw-r--r--drivers/media/rc/keymaps/rc-twinhan1027.c8
-rw-r--r--drivers/media/rc/keymaps/rc-videomate-m1f.c8
-rw-r--r--drivers/media/rc/keymaps/rc-videomate-s350.c8
-rw-r--r--drivers/media/rc/keymaps/rc-videomate-tv-pvr.c8
-rw-r--r--drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c8
-rw-r--r--drivers/media/rc/keymaps/rc-winfast.c8
-rw-r--r--drivers/media/rc/keymaps/rc-zx-irdec.c79
-rw-r--r--drivers/media/rc/lirc_dev.c4
-rw-r--r--drivers/media/rc/mceusb.c40
-rw-r--r--drivers/media/rc/meson-ir.c4
-rw-r--r--drivers/media/rc/mtk-cir.c246
-rw-r--r--drivers/media/rc/nuvoton-cir.c120
-rw-r--r--drivers/media/rc/nuvoton-cir.h24
-rw-r--r--drivers/media/rc/pwm-ir-tx.c138
-rw-r--r--drivers/media/rc/rc-core-priv.h5
-rw-r--r--drivers/media/rc/rc-ir-raw.c68
-rw-r--r--drivers/media/rc/rc-loopback.c6
-rw-r--r--drivers/media/rc/rc-main.c265
-rw-r--r--drivers/media/rc/redrat3.c4
-rw-r--r--drivers/media/rc/serial_ir.c46
-rw-r--r--drivers/media/rc/sir_ir.c6
-rw-r--r--drivers/media/rc/st_rc.c6
-rw-r--r--drivers/media/rc/streamzap.c4
-rw-r--r--drivers/media/rc/sunxi-cir.c6
-rw-r--r--drivers/media/rc/ttusbir.c4
-rw-r--r--drivers/media/rc/winbond-cir.c37
-rw-r--r--drivers/media/rc/zx-irdec.c184
-rw-r--r--drivers/media/tuners/fc0012.c2
-rw-r--r--drivers/media/tuners/fc0013.c2
-rw-r--r--drivers/media/tuners/tda18271-maps.c4
-rw-r--r--drivers/media/tuners/tuner-simple.c2
-rw-r--r--drivers/media/usb/airspy/airspy.c4
-rw-r--r--drivers/media/usb/as102/as102_usb_drv.c2
-rw-r--r--drivers/media/usb/au0828/Kconfig1
-rw-r--r--drivers/media/usb/au0828/au0828-core.c2
-rw-r--r--drivers/media/usb/au0828/au0828-i2c.c4
-rw-r--r--drivers/media/usb/au0828/au0828-input.c6
-rw-r--r--drivers/media/usb/au0828/au0828-video.c2
-rw-r--r--drivers/media/usb/b2c2/flexcop-usb.c2
-rw-r--r--drivers/media/usb/cpia2/cpia2_usb.c2
-rw-r--r--drivers/media/usb/cpia2/cpia2_v4l.c2
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-417.c4
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-audio.c2
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-core.c3
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-dvb.c6
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-i2c.c10
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-input.c6
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-video.c2
-rw-r--r--drivers/media/usb/cx231xx/cx231xx.h4
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9015.c11
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.c16
-rw-r--r--drivers/media/usb/dvb-usb-v2/anysee.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/az6007.c13
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb.h2
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvb_usb_core.c5
-rw-r--r--drivers/media/usb/dvb-usb-v2/dvbsky.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/lmedm04.c6
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf.c4
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.c13
-rw-r--r--drivers/media/usb/dvb-usb/cxusb.c30
-rw-r--r--drivers/media/usb/dvb-usb/dib0700.h2
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_core.c28
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_devices.c152
-rw-r--r--drivers/media/usb/dvb-usb/dtt200u.c12
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb-remote.c2
-rw-r--r--drivers/media/usb/dvb-usb/dvb-usb.h2
-rw-r--r--drivers/media/usb/dvb-usb/dw2102.c74
-rw-r--r--drivers/media/usb/dvb-usb/m920x.c4
-rw-r--r--drivers/media/usb/dvb-usb/pctv452e.c6
-rw-r--r--drivers/media/usb/dvb-usb/technisat-usb2.c2
-rw-r--r--drivers/media/usb/dvb-usb/ttusb2.c4
-rw-r--r--drivers/media/usb/em28xx/em28xx-audio.c4
-rw-r--r--drivers/media/usb/em28xx/em28xx-i2c.c2
-rw-r--r--drivers/media/usb/em28xx/em28xx-input.c126
-rw-r--r--drivers/media/usb/go7007/go7007-v4l2.c4
-rw-r--r--drivers/media/usb/go7007/snd-go7007.c2
-rw-r--r--drivers/media/usb/gspca/gspca.c2
-rw-r--r--drivers/media/usb/gspca/xirlink_cit.c2
-rw-r--r--drivers/media/usb/hackrf/hackrf.c4
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-core.c2
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-i2c.c5
-rw-r--r--drivers/media/usb/msi2500/msi2500.c4
-rw-r--r--drivers/media/usb/pulse8-cec/pulse8-cec.c7
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-encoder.c6
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c14
-rw-r--r--drivers/media/usb/pvrusb2/pvrusb2-v4l2.c2
-rw-r--r--drivers/media/usb/pwc/pwc-if.c2
-rw-r--r--drivers/media/usb/rainshadow-cec/rainshadow-cec.c7
-rw-r--r--drivers/media/usb/s2255/s2255drv.c4
-rw-r--r--drivers/media/usb/stk1160/stk1160-core.c2
-rw-r--r--drivers/media/usb/stk1160/stk1160-i2c.c2
-rw-r--r--drivers/media/usb/stk1160/stk1160-v4l.c4
-rw-r--r--drivers/media/usb/stkwebcam/stk-webcam.c6
-rw-r--r--drivers/media/usb/tm6000/tm6000-alsa.c2
-rw-r--r--drivers/media/usb/tm6000/tm6000-cards.c2
-rw-r--r--drivers/media/usb/tm6000/tm6000-input.c40
-rw-r--r--drivers/media/usb/tm6000/tm6000-video.c4
-rw-r--r--drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c4
-rw-r--r--drivers/media/usb/ttusb-dec/ttusb_dec.c2
-rw-r--r--drivers/media/usb/usbtv/usbtv-audio.c2
-rw-r--r--drivers/media/usb/usbtv/usbtv-core.c2
-rw-r--r--drivers/media/usb/usbtv/usbtv-video.c2
-rw-r--r--drivers/media/usb/usbvision/usbvision-i2c.c11
-rw-r--r--drivers/media/usb/usbvision/usbvision-video.c19
-rw-r--r--drivers/media/usb/uvc/uvc_ctrl.c7
-rw-r--r--drivers/media/usb/uvc/uvc_driver.c28
-rw-r--r--drivers/media/usb/uvc/uvc_entity.c2
-rw-r--r--drivers/media/usb/uvc/uvc_queue.c9
-rw-r--r--drivers/media/usb/uvc/uvcvideo.h4
-rw-r--r--drivers/media/usb/zr364xx/zr364xx.c6
-rw-r--r--drivers/media/v4l2-core/v4l2-async.c7
-rw-r--r--drivers/media/v4l2-core/v4l2-clk.c3
-rw-r--r--drivers/media/v4l2-core/v4l2-compat-ioctl32.c13
-rw-r--r--drivers/media/v4l2-core/v4l2-flash-led-class.c139
-rw-r--r--drivers/media/v4l2-core/v4l2-fwnode.c139
-rw-r--r--drivers/media/v4l2-core/v4l2-ioctl.c12
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c27
-rw-r--r--drivers/media/v4l2-core/videobuf2-dma-contig.c5
-rw-r--r--drivers/media/v4l2-core/videobuf2-dma-sg.c8
-rw-r--r--drivers/media/v4l2-core/videobuf2-vmalloc.c8
-rw-r--r--drivers/staging/greybus/light.c46
-rw-r--r--drivers/staging/media/atomisp/i2c/ap1302.c7
-rw-r--r--drivers/staging/media/atomisp/i2c/gc0310.c5
-rw-r--r--drivers/staging/media/atomisp/i2c/gc2235.c4
-rw-r--r--drivers/staging/media/atomisp/i2c/gc2235.h6
-rw-r--r--drivers/staging/media/atomisp/i2c/imx/ad5816g.c11
-rw-r--r--drivers/staging/media/atomisp/i2c/imx/drv201.c11
-rw-r--r--drivers/staging/media/atomisp/i2c/imx/dw9714.c14
-rw-r--r--drivers/staging/media/atomisp/i2c/imx/dw9718.c5
-rw-r--r--drivers/staging/media/atomisp/i2c/imx/dw9719.c11
-rw-r--r--drivers/staging/media/atomisp/i2c/imx/imx.c48
-rw-r--r--drivers/staging/media/atomisp/i2c/imx/imx.h29
-rw-r--r--drivers/staging/media/atomisp/i2c/lm3554.c2
-rw-r--r--drivers/staging/media/atomisp/i2c/mt9m114.c12
-rw-r--r--drivers/staging/media/atomisp/i2c/ov2680.c19
-rw-r--r--drivers/staging/media/atomisp/i2c/ov2722.c2
-rw-r--r--drivers/staging/media/atomisp/i2c/ov5693/ov5693.c10
-rw-r--r--drivers/staging/media/atomisp/i2c/ov8858.c2
-rw-r--r--drivers/staging/media/atomisp/i2c/ov8858.h3
-rw-r--r--drivers/staging/media/atomisp/i2c/ov8858_btns.h3
-rw-r--r--drivers/staging/media/atomisp/include/linux/atomisp.h6
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c50
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h3
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c8
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c4
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h13
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c3
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/atomisp_subdev.c6
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c35
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isys/src/ibuf_ctrl_rmgr.c27
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c1
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c8
-rw-r--r--drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c139
-rw-r--r--drivers/staging/media/bcm2048/radio-bcm2048.c3
-rw-r--r--drivers/staging/media/cxd2099/cxd2099.c21
-rw-r--r--drivers/staging/media/davinci_vpfe/vpfe_video.c2
-rw-r--r--drivers/staging/media/imx/Kconfig3
-rw-r--r--drivers/staging/media/imx/imx-ic-prpencvf.c57
-rw-r--r--drivers/staging/media/imx/imx-media-capture.c4
-rw-r--r--drivers/staging/media/imx/imx-media-csi.c37
-rw-r--r--drivers/staging/media/imx/imx-media-dev.c4
-rw-r--r--drivers/staging/media/imx/imx-media-of.c50
-rw-r--r--drivers/staging/media/imx/imx-media-vdic.c37
-rw-r--r--drivers/staging/media/lirc/lirc_zilog.c18
-rw-r--r--drivers/staging/media/omap4iss/iss_video.c2
-rw-r--r--fs/compat_ioctl.c2
-rw-r--r--include/media/cec-notifier.h12
-rw-r--r--include/media/cec-pin.h186
-rw-r--r--include/media/cec.h81
-rw-r--r--include/media/drv-intf/saa7146.h2
-rw-r--r--include/media/i2c/ir-kbd-i2c.h8
-rw-r--r--include/media/media-device.h7
-rw-r--r--include/media/media-entity.h2
-rw-r--r--include/media/rc-core.h72
-rw-r--r--include/media/rc-map.h216
-rw-r--r--include/media/v4l2-clk.h4
-rw-r--r--include/media/v4l2-ctrls.h16
-rw-r--r--include/media/v4l2-flash-led-class.h48
-rw-r--r--include/media/v4l2-fwnode.h25
-rw-r--r--include/media/v4l2-mediabus.h30
-rw-r--r--include/media/v4l2-subdev.h12
-rw-r--r--include/media/videobuf2-core.h13
-rw-r--r--include/uapi/linux/cec-funcs.h1
-rw-r--r--include/uapi/linux/cec.h8
-rw-r--r--include/uapi/linux/dvb/ca.h148
-rw-r--r--include/uapi/linux/dvb/dmx.h194
-rw-r--r--include/uapi/linux/dvb/frontend.h598
-rw-r--r--include/uapi/linux/dvb/net.h15
-rw-r--r--include/uapi/linux/media.h5
-rw-r--r--include/uapi/linux/videodev2.h5
-rw-r--r--samples/v4l/v4l2-pci-skeleton.c2
888 files changed, 44393 insertions, 10336 deletions
diff --git a/Documentation/devicetree/bindings/leds/ams,as3645a.txt b/Documentation/devicetree/bindings/leds/ams,as3645a.txt
new file mode 100644
index 000000000000..12c5ef26ec73
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/ams,as3645a.txt
@@ -0,0 +1,71 @@
1Analog devices AS3645A device tree bindings
2
3The AS3645A flash LED controller can drive two LEDs, one high current
4flash LED and one indicator LED. The high current flash LED can be
5used in torch mode as well.
6
7Ranges below noted as [a, b] are closed ranges between a and b, i.e. a
8and b are included in the range.
9
10Please also see common.txt in the same directory.
11
12
13Required properties
14===================
15
16compatible : Must be "ams,as3645a".
17reg : The I2C address of the device. Typically 0x30.
18
19
20Required properties of the "flash" child node
21=============================================
22
23flash-timeout-us: Flash timeout in microseconds. The value must be in
24 the range [100000, 850000] and divisible by 50000.
25flash-max-microamp: Maximum flash current in microamperes. Has to be
26 in the range between [200000, 500000] and
27 divisible by 20000.
28led-max-microamp: Maximum torch (assist) current in microamperes. The
29 value must be in the range between [20000, 160000] and
30 divisible by 20000.
31ams,input-max-microamp: Maximum flash controller input current. The
32 value must be in the range [1250000, 2000000]
33 and divisible by 50000.
34
35
36Optional properties of the "flash" child node
37=============================================
38
39label : The label of the flash LED.
40
41
42Required properties of the "indicator" child node
43=================================================
44
45led-max-microamp: Maximum indicator current. The allowed values are
46 2500, 5000, 7500 and 10000.
47
48Optional properties of the "indicator" child node
49=================================================
50
51label : The label of the indicator LED.
52
53
54Example
55=======
56
57 as3645a@30 {
58 reg = <0x30>;
59 compatible = "ams,as3645a";
60 flash {
61 flash-timeout-us = <150000>;
62 flash-max-microamp = <320000>;
63 led-max-microamp = <60000>;
64 ams,input-max-microamp = <1750000>;
65 label = "as3645a:flash";
66 };
67 indicator {
68 led-max-microamp = <10000>;
69 label = "as3645a:indicator";
70 };
71 };
diff --git a/Documentation/devicetree/bindings/leds/irled/gpio-ir-tx.txt b/Documentation/devicetree/bindings/leds/irled/gpio-ir-tx.txt
new file mode 100644
index 000000000000..cbe8dfd29715
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/irled/gpio-ir-tx.txt
@@ -0,0 +1,14 @@
1Device tree bindings for IR LED connected through gpio pin which is used as
2remote controller transmitter.
3
4Required properties:
5 - compatible: should be "gpio-ir-tx".
6 - gpios : Should specify the IR LED GPIO, see "gpios property" in
7 Documentation/devicetree/bindings/gpio/gpio.txt. Active low LEDs
8 should be indicated using flags in the GPIO specifier.
9
10Example:
11 irled@0 {
12 compatible = "gpio-ir-tx";
13 gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
14 };
diff --git a/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.txt b/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.txt
new file mode 100644
index 000000000000..66e5672c2e3d
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/irled/pwm-ir-tx.txt
@@ -0,0 +1,13 @@
1Device tree bindings for IR LED connected through pwm pin which is used as
2remote controller transmitter.
3
4Required properties:
5 - compatible: should be "pwm-ir-tx".
6 - pwms : PWM property to point to the PWM device (phandle)/port (id)
7 and to specify the period time to be used: <&phandle id period_ns>;
8
9Example:
10 irled {
11 compatible = "pwm-ir-tx";
12 pwms = <&pwm0 0 10000000>;
13 };
diff --git a/Documentation/devicetree/bindings/media/i2c/adv748x.txt b/Documentation/devicetree/bindings/media/i2c/adv748x.txt
new file mode 100644
index 000000000000..21ffb5ed8183
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/adv748x.txt
@@ -0,0 +1,95 @@
1* Analog Devices ADV748X video decoder with HDMI receiver
2
3The ADV7481 and ADV7482 are multi format video decoders with an integrated
4HDMI receiver. They can output CSI-2 on two independent outputs TXA and TXB
5from three input sources HDMI, analog and TTL.
6
7Required Properties:
8
9 - compatible: Must contain one of the following
10 - "adi,adv7481" for the ADV7481
11 - "adi,adv7482" for the ADV7482
12
13 - reg: I2C slave address
14
15Optional Properties:
16
17 - interrupt-names: Should specify the interrupts as "intrq1", "intrq2" and/or
18 "intrq3". All interrupts are optional. The "intrq3" interrupt
19 is only available on the adv7481
20 - interrupts: Specify the interrupt lines for the ADV748x
21
22The device node must contain one 'port' child node per device input and output
23port, in accordance with the video interface bindings defined in
24Documentation/devicetree/bindings/media/video-interfaces.txt. The port nodes
25are numbered as follows.
26
27 Name Type Port
28 ---------------------------------------
29 AIN0 sink 0
30 AIN1 sink 1
31 AIN2 sink 2
32 AIN3 sink 3
33 AIN4 sink 4
34 AIN5 sink 5
35 AIN6 sink 6
36 AIN7 sink 7
37 HDMI sink 8
38 TTL sink 9
39 TXA source 10
40 TXB source 11
41
42The digital output port nodes must contain at least one endpoint.
43
44Ports are optional if they are not connected to anything at the hardware level.
45
46Example:
47
48 video-receiver@70 {
49 compatible = "adi,adv7482";
50 reg = <0x70>;
51
52 #address-cells = <1>;
53 #size-cells = <0>;
54
55 interrupt-parent = <&gpio6>;
56 interrupt-names = "intrq1", "intrq2";
57 interrupts = <30 IRQ_TYPE_LEVEL_LOW>,
58 <31 IRQ_TYPE_LEVEL_LOW>;
59
60 port@7 {
61 reg = <7>;
62
63 adv7482_ain7: endpoint {
64 remote-endpoint = <&cvbs_in>;
65 };
66 };
67
68 port@8 {
69 reg = <8>;
70
71 adv7482_hdmi: endpoint {
72 remote-endpoint = <&hdmi_in>;
73 };
74 };
75
76 port@10 {
77 reg = <10>;
78
79 adv7482_txa: endpoint {
80 clock-lanes = <0>;
81 data-lanes = <1 2 3 4>;
82 remote-endpoint = <&csi40_in>;
83 };
84 };
85
86 port@11 {
87 reg = <11>;
88
89 adv7482_txb: endpoint {
90 clock-lanes = <0>;
91 data-lanes = <1>;
92 remote-endpoint = <&csi20_in>;
93 };
94 };
95 };
diff --git a/Documentation/devicetree/bindings/media/i2c/dongwoon,dw9714.txt b/Documentation/devicetree/bindings/media/i2c/dongwoon,dw9714.txt
new file mode 100644
index 000000000000..b88dcdd41def
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/dongwoon,dw9714.txt
@@ -0,0 +1,9 @@
1Dongwoon Anatech DW9714 camera voice coil lens driver
2
3DW9174 is a 10-bit DAC with current sink capability. It is intended
4for driving voice coil lenses in camera modules.
5
6Mandatory properties:
7
8- compatible: "dongwoon,dw9714"
9- reg: I²C slave address
diff --git a/Documentation/devicetree/bindings/media/meson-ao-cec.txt b/Documentation/devicetree/bindings/media/meson-ao-cec.txt
new file mode 100644
index 000000000000..8671bdb08080
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/meson-ao-cec.txt
@@ -0,0 +1,28 @@
1* Amlogic Meson AO-CEC driver
2
3The Amlogic Meson AO-CEC module is present is Amlogic SoCs and its purpose is
4to handle communication between HDMI connected devices over the CEC bus.
5
6Required properties:
7 - compatible : value should be following
8 "amlogic,meson-gx-ao-cec"
9
10 - reg : Physical base address of the IP registers and length of memory
11 mapped region.
12
13 - interrupts : AO-CEC interrupt number to the CPU.
14 - clocks : from common clock binding: handle to AO-CEC clock.
15 - clock-names : from common clock binding: must contain "core",
16 corresponding to entry in the clocks property.
17 - hdmi-phandle: phandle to the HDMI controller
18
19Example:
20
21cec_AO: cec@100 {
22 compatible = "amlogic,meson-gx-ao-cec";
23 reg = <0x0 0x00100 0x0 0x14>;
24 interrupts = <GIC_SPI 199 IRQ_TYPE_EDGE_RISING>;
25 clocks = <&clkc_AO CLKID_AO_CEC_32K>;
26 clock-names = "core";
27 hdmi-phandle = <&hdmi_tx>;
28};
diff --git a/Documentation/devicetree/bindings/media/mtk-cir.txt b/Documentation/devicetree/bindings/media/mtk-cir.txt
index 2be2005577d6..5e18087ce11f 100644
--- a/Documentation/devicetree/bindings/media/mtk-cir.txt
+++ b/Documentation/devicetree/bindings/media/mtk-cir.txt
@@ -2,10 +2,14 @@ Device-Tree bindings for Mediatek consumer IR controller
2found in Mediatek SoC family 2found in Mediatek SoC family
3 3
4Required properties: 4Required properties:
5- compatible : "mediatek,mt7623-cir" 5- compatible : Should be
6 "mediatek,mt7623-cir": for MT7623 SoC
7 "mediatek,mt7622-cir": for MT7622 SoC
6- clocks : list of clock specifiers, corresponding to 8- clocks : list of clock specifiers, corresponding to
7 entries in clock-names property; 9 entries in clock-names property;
8- clock-names : should contain "clk" entries; 10- clock-names : should contain
11 - "clk" entries: for MT7623 SoC
12 - "clk", "bus" entries: for MT7622 SoC
9- interrupts : should contain IR IRQ number; 13- interrupts : should contain IR IRQ number;
10- reg : should contain IO map address for IR. 14- reg : should contain IO map address for IR.
11 15
diff --git a/Documentation/devicetree/bindings/media/qcom,camss.txt b/Documentation/devicetree/bindings/media/qcom,camss.txt
new file mode 100644
index 000000000000..cadecebc73f7
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/qcom,camss.txt
@@ -0,0 +1,197 @@
1Qualcomm Camera Subsystem
2
3* Properties
4
5- compatible:
6 Usage: required
7 Value type: <stringlist>
8 Definition: Should contain:
9 - "qcom,msm8916-camss"
10- reg:
11 Usage: required
12 Value type: <prop-encoded-array>
13 Definition: Register ranges as listed in the reg-names property.
14- reg-names:
15 Usage: required
16 Value type: <stringlist>
17 Definition: Should contain the following entries:
18 - "csiphy0"
19 - "csiphy0_clk_mux"
20 - "csiphy1"
21 - "csiphy1_clk_mux"
22 - "csid0"
23 - "csid1"
24 - "ispif"
25 - "csi_clk_mux"
26 - "vfe0"
27- interrupts:
28 Usage: required
29 Value type: <prop-encoded-array>
30 Definition: Interrupts as listed in the interrupt-names property.
31- interrupt-names:
32 Usage: required
33 Value type: <stringlist>
34 Definition: Should contain the following entries:
35 - "csiphy0"
36 - "csiphy1"
37 - "csid0"
38 - "csid1"
39 - "ispif"
40 - "vfe0"
41- power-domains:
42 Usage: required
43 Value type: <prop-encoded-array>
44 Definition: A phandle and power domain specifier pairs to the
45 power domain which is responsible for collapsing
46 and restoring power to the peripheral.
47- clocks:
48 Usage: required
49 Value type: <prop-encoded-array>
50 Definition: A list of phandle and clock specifier pairs as listed
51 in clock-names property.
52- clock-names:
53 Usage: required
54 Value type: <stringlist>
55 Definition: Should contain the following entries:
56 - "camss_top_ahb"
57 - "ispif_ahb"
58 - "csiphy0_timer"
59 - "csiphy1_timer"
60 - "csi0_ahb"
61 - "csi0"
62 - "csi0_phy"
63 - "csi0_pix"
64 - "csi0_rdi"
65 - "csi1_ahb"
66 - "csi1"
67 - "csi1_phy"
68 - "csi1_pix"
69 - "csi1_rdi"
70 - "camss_ahb"
71 - "camss_vfe_vfe"
72 - "camss_csi_vfe"
73 - "iface"
74 - "bus"
75- vdda-supply:
76 Usage: required
77 Value type: <phandle>
78 Definition: A phandle to voltage supply for CSI2.
79- iommus:
80 Usage: required
81 Value type: <prop-encoded-array>
82 Definition: A list of phandle and IOMMU specifier pairs.
83
84* Nodes
85
86- ports:
87 Usage: required
88 Definition: As described in video-interfaces.txt in same directory.
89 Properties:
90 - reg:
91 Usage: required
92 Value type: <u32>
93 Definition: Selects CSI2 PHY interface - PHY0 or PHY1.
94 Endpoint node properties:
95 - clock-lanes:
96 Usage: required
97 Value type: <u32>
98 Definition: The physical clock lane index. The value
99 must always be <1> as the physical clock
100 lane is lane 1.
101 - data-lanes:
102 Usage: required
103 Value type: <prop-encoded-array>
104 Definition: An array of physical data lanes indexes.
105 Position of an entry determines the logical
106 lane number, while the value of an entry
107 indicates physical lane index. Lane swapping
108 is supported.
109
110* An Example
111
112 camss: camss@1b00000 {
113 compatible = "qcom,msm8916-camss";
114 reg = <0x1b0ac00 0x200>,
115 <0x1b00030 0x4>,
116 <0x1b0b000 0x200>,
117 <0x1b00038 0x4>,
118 <0x1b08000 0x100>,
119 <0x1b08400 0x100>,
120 <0x1b0a000 0x500>,
121 <0x1b00020 0x10>,
122 <0x1b10000 0x1000>;
123 reg-names = "csiphy0",
124 "csiphy0_clk_mux",
125 "csiphy1",
126 "csiphy1_clk_mux",
127 "csid0",
128 "csid1",
129 "ispif",
130 "csi_clk_mux",
131 "vfe0";
132 interrupts = <GIC_SPI 78 0>,
133 <GIC_SPI 79 0>,
134 <GIC_SPI 51 0>,
135 <GIC_SPI 52 0>,
136 <GIC_SPI 55 0>,
137 <GIC_SPI 57 0>;
138 interrupt-names = "csiphy0",
139 "csiphy1",
140 "csid0",
141 "csid1",
142 "ispif",
143 "vfe0";
144 power-domains = <&gcc VFE_GDSC>;
145 clocks = <&gcc GCC_CAMSS_TOP_AHB_CLK>,
146 <&gcc GCC_CAMSS_ISPIF_AHB_CLK>,
147 <&gcc GCC_CAMSS_CSI0PHYTIMER_CLK>,
148 <&gcc GCC_CAMSS_CSI1PHYTIMER_CLK>,
149 <&gcc GCC_CAMSS_CSI0_AHB_CLK>,
150 <&gcc GCC_CAMSS_CSI0_CLK>,
151 <&gcc GCC_CAMSS_CSI0PHY_CLK>,
152 <&gcc GCC_CAMSS_CSI0PIX_CLK>,
153 <&gcc GCC_CAMSS_CSI0RDI_CLK>,
154 <&gcc GCC_CAMSS_CSI1_AHB_CLK>,
155 <&gcc GCC_CAMSS_CSI1_CLK>,
156 <&gcc GCC_CAMSS_CSI1PHY_CLK>,
157 <&gcc GCC_CAMSS_CSI1PIX_CLK>,
158 <&gcc GCC_CAMSS_CSI1RDI_CLK>,
159 <&gcc GCC_CAMSS_AHB_CLK>,
160 <&gcc GCC_CAMSS_VFE0_CLK>,
161 <&gcc GCC_CAMSS_CSI_VFE0_CLK>,
162 <&gcc GCC_CAMSS_VFE_AHB_CLK>,
163 <&gcc GCC_CAMSS_VFE_AXI_CLK>;
164 clock-names = "camss_top_ahb",
165 "ispif_ahb",
166 "csiphy0_timer",
167 "csiphy1_timer",
168 "csi0_ahb",
169 "csi0",
170 "csi0_phy",
171 "csi0_pix",
172 "csi0_rdi",
173 "csi1_ahb",
174 "csi1",
175 "csi1_phy",
176 "csi1_pix",
177 "csi1_rdi",
178 "camss_ahb",
179 "camss_vfe_vfe",
180 "camss_csi_vfe",
181 "iface",
182 "bus";
183 vdda-supply = <&pm8916_l2>;
184 iommus = <&apps_iommu 3>;
185 ports {
186 #address-cells = <1>;
187 #size-cells = <0>;
188 port@0 {
189 reg = <0>;
190 csiphy0_ep: endpoint {
191 clock-lanes = <1>;
192 data-lanes = <0 2>;
193 remote-endpoint = <&ov5645_ep>;
194 };
195 };
196 };
197 };
diff --git a/Documentation/devicetree/bindings/media/renesas,drif.txt b/Documentation/devicetree/bindings/media/renesas,drif.txt
index 39516b94c28f..0d8974aa8b38 100644
--- a/Documentation/devicetree/bindings/media/renesas,drif.txt
+++ b/Documentation/devicetree/bindings/media/renesas,drif.txt
@@ -40,6 +40,7 @@ To summarize,
40Required properties of an internal channel: 40Required properties of an internal channel:
41------------------------------------------- 41-------------------------------------------
42- compatible: "renesas,r8a7795-drif" if DRIF controller is a part of R8A7795 SoC. 42- compatible: "renesas,r8a7795-drif" if DRIF controller is a part of R8A7795 SoC.
43 "renesas,r8a7796-drif" if DRIF controller is a part of R8A7796 SoC.
43 "renesas,rcar-gen3-drif" for a generic R-Car Gen3 compatible device. 44 "renesas,rcar-gen3-drif" for a generic R-Car Gen3 compatible device.
44 45
45 When compatible with the generic version, nodes must list the 46 When compatible with the generic version, nodes must list the
diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt b/Documentation/devicetree/bindings/media/video-interfaces.txt
index 9cd2a369125d..852041a7480c 100644
--- a/Documentation/devicetree/bindings/media/video-interfaces.txt
+++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
@@ -76,6 +76,11 @@ Optional endpoint properties
76 mode horizontal and vertical synchronization signals are provided to the 76 mode horizontal and vertical synchronization signals are provided to the
77 slave device (data source) by the master device (data sink). In the master 77 slave device (data source) by the master device (data sink). In the master
78 mode the data source device is also the source of the synchronization signals. 78 mode the data source device is also the source of the synchronization signals.
79- bus-type: data bus type. Possible values are:
80 0 - autodetect based on other properties (MIPI CSI-2 D-PHY, parallel or Bt656)
81 1 - MIPI CSI-2 C-PHY
82 2 - MIPI CSI1
83 3 - CCP2
79- bus-width: number of data lines actively used, valid for the parallel busses. 84- bus-width: number of data lines actively used, valid for the parallel busses.
80- data-shift: on the parallel data busses, if bus-width is used to specify the 85- data-shift: on the parallel data busses, if bus-width is used to specify the
81 number of data lines, data-shift can be used to specify which data lines are 86 number of data lines, data-shift can be used to specify which data lines are
@@ -112,7 +117,8 @@ Optional endpoint properties
112 should be the combined length of data-lanes and clock-lanes properties. 117 should be the combined length of data-lanes and clock-lanes properties.
113 If the lane-polarities property is omitted, the value must be interpreted 118 If the lane-polarities property is omitted, the value must be interpreted
114 as 0 (normal). This property is valid for serial busses only. 119 as 0 (normal). This property is valid for serial busses only.
115 120- strobe: Whether the clock signal is used as clock (0) or strobe (1). Used
121 with CCP2, for instance.
116 122
117Example 123Example
118------- 124-------
diff --git a/Documentation/devicetree/bindings/media/zx-irdec.txt b/Documentation/devicetree/bindings/media/zx-irdec.txt
new file mode 100644
index 000000000000..295b9fab593e
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/zx-irdec.txt
@@ -0,0 +1,14 @@
1IR Decoder (IRDEC) on ZTE ZX family SoCs
2
3Required properties:
4 - compatible: Should be "zte,zx296718-irdec".
5 - reg: Physical base address and length of IRDEC registers.
6 - interrupts: Interrupt number of IRDEC.
7
8Exmaples:
9
10 irdec: ir-decoder@111000 {
11 compatible = "zte,zx296718-irdec";
12 reg = <0x111000 0x1000>;
13 interrupts = <GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>;
14 };
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 4e72012928b4..f58c9323b92b 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -88,6 +88,7 @@ dlg Dialog Semiconductor
88dlink D-Link Corporation 88dlink D-Link Corporation
89dmo Data Modul AG 89dmo Data Modul AG
90domintech Domintech Co., Ltd. 90domintech Domintech Co., Ltd.
91dongwoon Dongwoon Anatech
91dptechnics DPTechnics 92dptechnics DPTechnics
92dragino Dragino Technology Co., Limited 93dragino Dragino Technology Co., Limited
93ea Embedded Artists AB 94ea Embedded Artists AB
diff --git a/Documentation/media/ca.h.rst.exceptions b/Documentation/media/ca.h.rst.exceptions
index d7c9fed8c004..553559cc6ad7 100644
--- a/Documentation/media/ca.h.rst.exceptions
+++ b/Documentation/media/ca.h.rst.exceptions
@@ -16,7 +16,6 @@ replace define CA_NDS :c:type:`ca_descr_info`
16replace define CA_DSS :c:type:`ca_descr_info` 16replace define CA_DSS :c:type:`ca_descr_info`
17 17
18# some typedefs should point to struct/enums 18# some typedefs should point to struct/enums
19replace typedef ca_pid_t :c:type:`ca_pid`
20replace typedef ca_slot_info_t :c:type:`ca_slot_info` 19replace typedef ca_slot_info_t :c:type:`ca_slot_info`
21replace typedef ca_descr_info_t :c:type:`ca_descr_info` 20replace typedef ca_descr_info_t :c:type:`ca_descr_info`
22replace typedef ca_caps_t :c:type:`ca_caps` 21replace typedef ca_caps_t :c:type:`ca_caps`
diff --git a/Documentation/media/cec-drivers/index.rst b/Documentation/media/cec-drivers/index.rst
new file mode 100644
index 000000000000..7ef204823422
--- /dev/null
+++ b/Documentation/media/cec-drivers/index.rst
@@ -0,0 +1,34 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. include:: <isonum.txt>
4
5.. _cec-drivers:
6
7#################################
8CEC driver-specific documentation
9#################################
10
11**Copyright** |copy| 2017 : LinuxTV Developers
12
13This documentation is free software; you can redistribute it and/or modify it
14under the terms of the GNU General Public License as published by the Free
15Software Foundation version 2 of the License.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
20more details.
21
22For more details see the file COPYING in the source distribution of Linux.
23
24.. only:: html
25
26 .. class:: toc-title
27
28 Table of Contents
29
30.. toctree::
31 :maxdepth: 5
32 :numbered:
33
34 pulse8-cec
diff --git a/Documentation/media/cec-drivers/pulse8-cec.rst b/Documentation/media/cec-drivers/pulse8-cec.rst
new file mode 100644
index 000000000000..99551c6a9bc5
--- /dev/null
+++ b/Documentation/media/cec-drivers/pulse8-cec.rst
@@ -0,0 +1,11 @@
1Pulse-Eight CEC Adapter driver
2==============================
3
4The pulse8-cec driver implements the following module option:
5
6``persistent_config``
7---------------------
8
9By default this is off, but when set to 1 the driver will store the current
10settings to the device's internal eeprom and restore it the next time the
11device is connected to the USB port.
diff --git a/Documentation/media/dmx.h.rst.exceptions b/Documentation/media/dmx.h.rst.exceptions
index 2fdb458564ba..629db384104a 100644
--- a/Documentation/media/dmx.h.rst.exceptions
+++ b/Documentation/media/dmx.h.rst.exceptions
@@ -40,27 +40,17 @@ replace enum dmx_input :c:type:`dmx_input`
40replace symbol DMX_IN_FRONTEND :c:type:`dmx_input` 40replace symbol DMX_IN_FRONTEND :c:type:`dmx_input`
41replace symbol DMX_IN_DVR :c:type:`dmx_input` 41replace symbol DMX_IN_DVR :c:type:`dmx_input`
42 42
43# dmx_source_t symbols
44replace enum dmx_source :c:type:`dmx_source`
45replace symbol DMX_SOURCE_FRONT0 :c:type:`dmx_source`
46replace symbol DMX_SOURCE_FRONT1 :c:type:`dmx_source`
47replace symbol DMX_SOURCE_FRONT2 :c:type:`dmx_source`
48replace symbol DMX_SOURCE_FRONT3 :c:type:`dmx_source`
49replace symbol DMX_SOURCE_DVR0 :c:type:`dmx_source`
50replace symbol DMX_SOURCE_DVR1 :c:type:`dmx_source`
51replace symbol DMX_SOURCE_DVR2 :c:type:`dmx_source`
52replace symbol DMX_SOURCE_DVR3 :c:type:`dmx_source`
53
54
55# Flags for struct dmx_sct_filter_params 43# Flags for struct dmx_sct_filter_params
56replace define DMX_CHECK_CRC :c:type:`dmx_sct_filter_params` 44replace define DMX_CHECK_CRC :c:type:`dmx_sct_filter_params`
57replace define DMX_ONESHOT :c:type:`dmx_sct_filter_params` 45replace define DMX_ONESHOT :c:type:`dmx_sct_filter_params`
58replace define DMX_IMMEDIATE_START :c:type:`dmx_sct_filter_params` 46replace define DMX_IMMEDIATE_START :c:type:`dmx_sct_filter_params`
59replace define DMX_KERNEL_CLIENT :c:type:`dmx_sct_filter_params`
60 47
61# some typedefs should point to struct/enums 48# some typedefs should point to struct/enums
62replace typedef dmx_caps_t :c:type:`dmx_caps`
63replace typedef dmx_filter_t :c:type:`dmx_filter` 49replace typedef dmx_filter_t :c:type:`dmx_filter`
64replace typedef dmx_pes_type_t :c:type:`dmx_pes_type` 50replace typedef dmx_pes_type_t :c:type:`dmx_pes_type`
65replace typedef dmx_input_t :c:type:`dmx_input` 51replace typedef dmx_input_t :c:type:`dmx_input`
66replace typedef dmx_source_t :c:type:`dmx_source` 52
53ignore symbol DMX_OUT_DECODER
54ignore symbol DMX_OUT_TAP
55ignore symbol DMX_OUT_TS_TAP
56ignore symbol DMX_OUT_TSDEMUX_TAP
diff --git a/Documentation/media/dvb-drivers/ci.rst b/Documentation/media/dvb-drivers/ci.rst
index 69b07e9d1816..87f3748c49b9 100644
--- a/Documentation/media/dvb-drivers/ci.rst
+++ b/Documentation/media/dvb-drivers/ci.rst
@@ -143,7 +143,6 @@ All these ioctls are also valid for the High level CI interface
143#define CA_GET_MSG _IOR('o', 132, ca_msg_t) 143#define CA_GET_MSG _IOR('o', 132, ca_msg_t)
144#define CA_SEND_MSG _IOW('o', 133, ca_msg_t) 144#define CA_SEND_MSG _IOW('o', 133, ca_msg_t)
145#define CA_SET_DESCR _IOW('o', 134, ca_descr_t) 145#define CA_SET_DESCR _IOW('o', 134, ca_descr_t)
146#define CA_SET_PID _IOW('o', 135, ca_pid_t)
147 146
148 147
149On querying the device, the device yields information thus: 148On querying the device, the device yields information thus:
diff --git a/Documentation/media/dvb-drivers/index.rst b/Documentation/media/dvb-drivers/index.rst
index ea0da6d63299..376141143ae9 100644
--- a/Documentation/media/dvb-drivers/index.rst
+++ b/Documentation/media/dvb-drivers/index.rst
@@ -19,7 +19,9 @@ more details.
19 19
20For more details see the file COPYING in the source distribution of Linux. 20For more details see the file COPYING in the source distribution of Linux.
21 21
22.. class:: toc-title 22.. only:: html
23
24 .. class:: toc-title
23 25
24 Table of Contents 26 Table of Contents
25 27
diff --git a/Documentation/media/frontend.h.rst.exceptions b/Documentation/media/frontend.h.rst.exceptions
index 7656770f1936..f7c4df620a52 100644
--- a/Documentation/media/frontend.h.rst.exceptions
+++ b/Documentation/media/frontend.h.rst.exceptions
@@ -25,19 +25,9 @@ ignore define DTV_MAX_COMMAND
25ignore define MAX_DTV_STATS 25ignore define MAX_DTV_STATS
26ignore define DTV_IOCTL_MAX_MSGS 26ignore define DTV_IOCTL_MAX_MSGS
27 27
28# Stats enum is documented altogether
29replace enum fecap_scale_params :ref:`frontend-stat-properties`
30replace symbol FE_SCALE_COUNTER frontend-stat-properties
31replace symbol FE_SCALE_DECIBEL frontend-stat-properties
32replace symbol FE_SCALE_NOT_AVAILABLE frontend-stat-properties
33replace symbol FE_SCALE_RELATIVE frontend-stat-properties
34
35# the same reference is used for both get and set ioctls 28# the same reference is used for both get and set ioctls
36replace ioctl FE_SET_PROPERTY :c:type:`FE_GET_PROPERTY` 29replace ioctl FE_SET_PROPERTY :c:type:`FE_GET_PROPERTY`
37 30
38# Ignore struct used only internally at Kernel
39ignore struct dtv_cmds_h
40
41# Typedefs that use the enum reference 31# Typedefs that use the enum reference
42replace typedef fe_sec_voltage_t :c:type:`fe_sec_voltage` 32replace typedef fe_sec_voltage_t :c:type:`fe_sec_voltage`
43 33
@@ -45,3 +35,178 @@ replace typedef fe_sec_voltage_t :c:type:`fe_sec_voltage`
45replace define FE_TUNE_MODE_ONESHOT :c:func:`FE_SET_FRONTEND_TUNE_MODE` 35replace define FE_TUNE_MODE_ONESHOT :c:func:`FE_SET_FRONTEND_TUNE_MODE`
46replace define LNA_AUTO dtv-lna 36replace define LNA_AUTO dtv-lna
47replace define NO_STREAM_ID_FILTER dtv-stream-id 37replace define NO_STREAM_ID_FILTER dtv-stream-id
38
39# Those enums are defined at the frontend.h header, and not externally
40
41ignore symbol FE_IS_STUPID
42ignore symbol FE_CAN_INVERSION_AUTO
43ignore symbol FE_CAN_FEC_1_2
44ignore symbol FE_CAN_FEC_2_3
45ignore symbol FE_CAN_FEC_3_4
46ignore symbol FE_CAN_FEC_4_5
47ignore symbol FE_CAN_FEC_5_6
48ignore symbol FE_CAN_FEC_6_7
49ignore symbol FE_CAN_FEC_7_8
50ignore symbol FE_CAN_FEC_8_9
51ignore symbol FE_CAN_FEC_AUTO
52ignore symbol FE_CAN_QPSK
53ignore symbol FE_CAN_QAM_16
54ignore symbol FE_CAN_QAM_32
55ignore symbol FE_CAN_QAM_64
56ignore symbol FE_CAN_QAM_128
57ignore symbol FE_CAN_QAM_256
58ignore symbol FE_CAN_QAM_AUTO
59ignore symbol FE_CAN_TRANSMISSION_MODE_AUTO
60ignore symbol FE_CAN_BANDWIDTH_AUTO
61ignore symbol FE_CAN_GUARD_INTERVAL_AUTO
62ignore symbol FE_CAN_HIERARCHY_AUTO
63ignore symbol FE_CAN_8VSB
64ignore symbol FE_CAN_16VSB
65ignore symbol FE_HAS_EXTENDED_CAPS
66ignore symbol FE_CAN_MULTISTREAM
67ignore symbol FE_CAN_TURBO_FEC
68ignore symbol FE_CAN_2G_MODULATION
69ignore symbol FE_NEEDS_BENDING
70ignore symbol FE_CAN_RECOVER
71ignore symbol FE_CAN_MUTE_TS
72
73ignore symbol QPSK
74ignore symbol QAM_16
75ignore symbol QAM_32
76ignore symbol QAM_64
77ignore symbol QAM_128
78ignore symbol QAM_256
79ignore symbol QAM_AUTO
80ignore symbol VSB_8
81ignore symbol VSB_16
82ignore symbol PSK_8
83ignore symbol APSK_16
84ignore symbol APSK_32
85ignore symbol DQPSK
86ignore symbol QAM_4_NR
87
88ignore symbol SEC_VOLTAGE_13
89ignore symbol SEC_VOLTAGE_18
90ignore symbol SEC_VOLTAGE_OFF
91
92ignore symbol SEC_TONE_ON
93ignore symbol SEC_TONE_OFF
94
95ignore symbol SEC_MINI_A
96ignore symbol SEC_MINI_B
97
98ignore symbol FE_NONE
99ignore symbol FE_HAS_SIGNAL
100ignore symbol FE_HAS_CARRIER
101ignore symbol FE_HAS_VITERBI
102ignore symbol FE_HAS_SYNC
103ignore symbol FE_HAS_LOCK
104ignore symbol FE_REINIT
105ignore symbol FE_TIMEDOUT
106
107ignore symbol FEC_NONE
108ignore symbol FEC_1_2
109ignore symbol FEC_2_3
110ignore symbol FEC_3_4
111ignore symbol FEC_4_5
112ignore symbol FEC_5_6
113ignore symbol FEC_6_7
114ignore symbol FEC_7_8
115ignore symbol FEC_8_9
116ignore symbol FEC_AUTO
117ignore symbol FEC_3_5
118ignore symbol FEC_9_10
119ignore symbol FEC_2_5
120
121ignore symbol TRANSMISSION_MODE_AUTO
122ignore symbol TRANSMISSION_MODE_1K
123ignore symbol TRANSMISSION_MODE_2K
124ignore symbol TRANSMISSION_MODE_8K
125ignore symbol TRANSMISSION_MODE_4K
126ignore symbol TRANSMISSION_MODE_16K
127ignore symbol TRANSMISSION_MODE_32K
128ignore symbol TRANSMISSION_MODE_C1
129ignore symbol TRANSMISSION_MODE_C3780
130ignore symbol TRANSMISSION_MODE_2K
131ignore symbol TRANSMISSION_MODE_8K
132
133ignore symbol GUARD_INTERVAL_AUTO
134ignore symbol GUARD_INTERVAL_1_128
135ignore symbol GUARD_INTERVAL_1_32
136ignore symbol GUARD_INTERVAL_1_16
137ignore symbol GUARD_INTERVAL_1_8
138ignore symbol GUARD_INTERVAL_1_4
139ignore symbol GUARD_INTERVAL_19_128
140ignore symbol GUARD_INTERVAL_19_256
141ignore symbol GUARD_INTERVAL_PN420
142ignore symbol GUARD_INTERVAL_PN595
143ignore symbol GUARD_INTERVAL_PN945
144
145ignore symbol HIERARCHY_NONE
146ignore symbol HIERARCHY_AUTO
147ignore symbol HIERARCHY_1
148ignore symbol HIERARCHY_2
149ignore symbol HIERARCHY_4
150
151ignore symbol INTERLEAVING_NONE
152ignore symbol INTERLEAVING_AUTO
153ignore symbol INTERLEAVING_240
154ignore symbol INTERLEAVING_720
155
156ignore symbol PILOT_ON
157ignore symbol PILOT_OFF
158ignore symbol PILOT_AUTO
159
160ignore symbol ROLLOFF_35
161ignore symbol ROLLOFF_20
162ignore symbol ROLLOFF_25
163ignore symbol ROLLOFF_AUTO
164
165ignore symbol INVERSION_ON
166ignore symbol INVERSION_OFF
167ignore symbol INVERSION_AUTO
168
169ignore symbol SYS_UNDEFINED
170ignore symbol SYS_DVBC_ANNEX_A
171ignore symbol SYS_DVBC_ANNEX_B
172ignore symbol SYS_DVBC_ANNEX_C
173ignore symbol SYS_ISDBC
174ignore symbol SYS_DVBT
175ignore symbol SYS_DVBT2
176ignore symbol SYS_ISDBT
177ignore symbol SYS_ATSC
178ignore symbol SYS_ATSCMH
179ignore symbol SYS_DTMB
180ignore symbol SYS_DVBS
181ignore symbol SYS_DVBS2
182ignore symbol SYS_TURBO
183ignore symbol SYS_ISDBS
184ignore symbol SYS_DAB
185ignore symbol SYS_DSS
186ignore symbol SYS_CMMB
187ignore symbol SYS_DVBH
188
189ignore symbol ATSCMH_SCCC_BLK_SEP
190ignore symbol ATSCMH_SCCC_BLK_COMB
191ignore symbol ATSCMH_SCCC_BLK_RES
192
193ignore symbol ATSCMH_SCCC_CODE_HLF
194ignore symbol ATSCMH_SCCC_CODE_QTR
195ignore symbol ATSCMH_SCCC_CODE_RES
196
197ignore symbol ATSCMH_RSFRAME_ENS_PRI
198ignore symbol ATSCMH_RSFRAME_ENS_SEC
199
200ignore symbol ATSCMH_RSFRAME_PRI_ONLY
201ignore symbol ATSCMH_RSFRAME_PRI_SEC
202ignore symbol ATSCMH_RSFRAME_RES
203
204ignore symbol ATSCMH_RSCODE_211_187
205ignore symbol ATSCMH_RSCODE_223_187
206ignore symbol ATSCMH_RSCODE_235_187
207ignore symbol ATSCMH_RSCODE_RES
208
209ignore symbol FE_SCALE_NOT_AVAILABLE
210ignore symbol FE_SCALE_DECIBEL
211ignore symbol FE_SCALE_RELATIVE
212ignore symbol FE_SCALE_COUNTER
diff --git a/Documentation/media/index.rst b/Documentation/media/index.rst
index 7f8f0af620ce..1cf5316c8ff8 100644
--- a/Documentation/media/index.rst
+++ b/Documentation/media/index.rst
@@ -1,7 +1,11 @@
1Linux Media Subsystem Documentation 1Linux Media Subsystem Documentation
2=================================== 2===================================
3 3
4Contents: 4.. only:: html
5
6 .. class:: toc-title
7
8 Table of Contents
5 9
6.. toctree:: 10.. toctree::
7 :maxdepth: 2 11 :maxdepth: 2
@@ -10,6 +14,7 @@ Contents:
10 media_kapi 14 media_kapi
11 dvb-drivers/index 15 dvb-drivers/index
12 v4l-drivers/index 16 v4l-drivers/index
17 cec-drivers/index
13 18
14.. only:: subproject 19.. only:: subproject
15 20
diff --git a/Documentation/media/kapi/cec-core.rst b/Documentation/media/kapi/cec-core.rst
index 8a65c69ed071..28866259998c 100644
--- a/Documentation/media/kapi/cec-core.rst
+++ b/Documentation/media/kapi/cec-core.rst
@@ -107,6 +107,7 @@ your driver:
107 int (*adap_transmit)(struct cec_adapter *adap, u8 attempts, 107 int (*adap_transmit)(struct cec_adapter *adap, u8 attempts,
108 u32 signal_free_time, struct cec_msg *msg); 108 u32 signal_free_time, struct cec_msg *msg);
109 void (*adap_status)(struct cec_adapter *adap, struct seq_file *file); 109 void (*adap_status)(struct cec_adapter *adap, struct seq_file *file);
110 void (*adap_free)(struct cec_adapter *adap);
110 111
111 /* High-level callbacks */ 112 /* High-level callbacks */
112 ... 113 ...
@@ -184,6 +185,14 @@ To log the current CEC hardware status:
184This optional callback can be used to show the status of the CEC hardware. 185This optional callback can be used to show the status of the CEC hardware.
185The status is available through debugfs: cat /sys/kernel/debug/cec/cecX/status 186The status is available through debugfs: cat /sys/kernel/debug/cec/cecX/status
186 187
188To free any resources when the adapter is deleted:
189
190.. c:function::
191 void (*adap_free)(struct cec_adapter *adap);
192
193This optional callback can be used to free any resources that might have been
194allocated by the driver. It's called from cec_delete_adapter.
195
187 196
188Your adapter driver will also have to react to events (typically interrupt 197Your adapter driver will also have to react to events (typically interrupt
189driven) by calling into the framework in the following situations: 198driven) by calling into the framework in the following situations:
@@ -336,3 +345,34 @@ log_addrs->num_log_addrs set to 0. The block argument is ignored when
336unconfiguring. This function will just return if the physical address is 345unconfiguring. This function will just return if the physical address is
337invalid. Once the physical address becomes valid, then the framework will 346invalid. Once the physical address becomes valid, then the framework will
338attempt to claim these logical addresses. 347attempt to claim these logical addresses.
348
349CEC Pin framework
350-----------------
351
352Most CEC hardware operates on full CEC messages where the software provides
353the message and the hardware handles the low-level CEC protocol. But some
354hardware only drives the CEC pin and software has to handle the low-level
355CEC protocol. The CEC pin framework was created to handle such devices.
356
357Note that due to the close-to-realtime requirements it can never be guaranteed
358to work 100%. This framework uses highres timers internally, but if a
359timer goes off too late by more than 300 microseconds wrong results can
360occur. In reality it appears to be fairly reliable.
361
362One advantage of this low-level implementation is that it can be used as
363a cheap CEC analyser, especially if interrupts can be used to detect
364CEC pin transitions from low to high or vice versa.
365
366.. kernel-doc:: include/media/cec-pin.h
367
368CEC Notifier framework
369----------------------
370
371Most drm HDMI implementations have an integrated CEC implementation and no
372notifier support is needed. But some have independent CEC implementations
373that have their own driver. This could be an IP block for an SoC or a
374completely separate chip that deals with the CEC pin. For those cases a
375drm driver can install a notifier and use the notifier to inform the
376CEC driver about changes in the physical address.
377
378.. kernel-doc:: include/media/cec-notifier.h
diff --git a/Documentation/media/kapi/csi2.rst b/Documentation/media/kapi/csi2.rst
index e33fcb967922..0560100efca2 100644
--- a/Documentation/media/kapi/csi2.rst
+++ b/Documentation/media/kapi/csi2.rst
@@ -51,6 +51,16 @@ not active. Some transmitters do this automatically but some have to
51be explicitly programmed to do so, and some are unable to do so 51be explicitly programmed to do so, and some are unable to do so
52altogether due to hardware constraints. 52altogether due to hardware constraints.
53 53
54Stopping the transmitter
55^^^^^^^^^^^^^^^^^^^^^^^^
56
57A transmitter stops sending the stream of images as a result of
58calling the ``.s_stream()`` callback. Some transmitters may stop the
59stream at a frame boundary whereas others stop immediately,
60effectively leaving the current frame unfinished. The receiver driver
61should not make assumptions either way, but function properly in both
62cases.
63
54Receiver drivers 64Receiver drivers
55---------------- 65----------------
56 66
diff --git a/Documentation/media/kapi/v4l2-event.rst b/Documentation/media/kapi/v4l2-event.rst
index 9a5e31546ae3..9938d21ef4d1 100644
--- a/Documentation/media/kapi/v4l2-event.rst
+++ b/Documentation/media/kapi/v4l2-event.rst
@@ -67,6 +67,8 @@ type).
67 67
68The ops argument allows the driver to specify a number of callbacks: 68The ops argument allows the driver to specify a number of callbacks:
69 69
70.. tabularcolumns:: |p{1.5cm}|p{16.0cm}|
71
70======== ============================================================== 72======== ==============================================================
71Callback Description 73Callback Description
72======== ============================================================== 74======== ==============================================================
diff --git a/Documentation/media/media_kapi.rst b/Documentation/media/media_kapi.rst
index bc0638956a43..83da736fad72 100644
--- a/Documentation/media/media_kapi.rst
+++ b/Documentation/media/media_kapi.rst
@@ -20,7 +20,9 @@ more details.
20 20
21For more details see the file COPYING in the source distribution of Linux. 21For more details see the file COPYING in the source distribution of Linux.
22 22
23.. class:: toc-title 23.. only:: html
24
25 .. class:: toc-title
24 26
25 Table of Contents 27 Table of Contents
26 28
diff --git a/Documentation/media/media_uapi.rst b/Documentation/media/media_uapi.rst
index fd8ebe002cd2..28eb35a1f965 100644
--- a/Documentation/media/media_uapi.rst
+++ b/Documentation/media/media_uapi.rst
@@ -14,7 +14,9 @@ any later version published by the Free Software Foundation. A copy of
14the license is included in the chapter entitled "GNU Free Documentation 14the license is included in the chapter entitled "GNU Free Documentation
15License". 15License".
16 16
17.. class:: toc-title 17.. only:: html
18
19 .. class:: toc-title
18 20
19 Table of Contents 21 Table of Contents
20 22
diff --git a/Documentation/media/uapi/cec/cec-api.rst b/Documentation/media/uapi/cec/cec-api.rst
index bb018709970c..b68ca9c1d2e0 100644
--- a/Documentation/media/uapi/cec/cec-api.rst
+++ b/Documentation/media/uapi/cec/cec-api.rst
@@ -10,7 +10,10 @@ Part V - Consumer Electronics Control API
10 10
11This part describes the CEC: Consumer Electronics Control 11This part describes the CEC: Consumer Electronics Control
12 12
13.. class:: toc-title 13
14.. only:: html
15
16 .. class:: toc-title
14 17
15 Table of Contents 18 Table of Contents
16 19
diff --git a/Documentation/media/uapi/cec/cec-func-close.rst b/Documentation/media/uapi/cec/cec-func-close.rst
index 895d9c2d1c04..334358dfa72e 100644
--- a/Documentation/media/uapi/cec/cec-func-close.rst
+++ b/Documentation/media/uapi/cec/cec-func-close.rst
@@ -40,7 +40,7 @@ freed. The device configuration remain unchanged.
40Return Value 40Return Value
41============ 41============
42 42
43:c:func:`close()` returns 0 on success. On error, -1 is returned, and 43:c:func:`close() <cec-close>` returns 0 on success. On error, -1 is returned, and
44``errno`` is set appropriately. Possible error codes are: 44``errno`` is set appropriately. Possible error codes are:
45 45
46``EBADF`` 46``EBADF``
diff --git a/Documentation/media/uapi/cec/cec-func-ioctl.rst b/Documentation/media/uapi/cec/cec-func-ioctl.rst
index 22fb6304a2df..e2b6260b0086 100644
--- a/Documentation/media/uapi/cec/cec-func-ioctl.rst
+++ b/Documentation/media/uapi/cec/cec-func-ioctl.rst
@@ -39,7 +39,7 @@ Arguments
39Description 39Description
40=========== 40===========
41 41
42The :c:func:`ioctl()` function manipulates cec device parameters. The 42The :c:func:`ioctl() <cec-ioctl>` function manipulates cec device parameters. The
43argument ``fd`` must be an open file descriptor. 43argument ``fd`` must be an open file descriptor.
44 44
45The ioctl ``request`` code specifies the cec function to be called. It 45The ioctl ``request`` code specifies the cec function to be called. It
diff --git a/Documentation/media/uapi/cec/cec-func-open.rst b/Documentation/media/uapi/cec/cec-func-open.rst
index 18dfb62f2efe..5d6663a649bd 100644
--- a/Documentation/media/uapi/cec/cec-func-open.rst
+++ b/Documentation/media/uapi/cec/cec-func-open.rst
@@ -46,7 +46,7 @@ Arguments
46Description 46Description
47=========== 47===========
48 48
49To open a cec device applications call :c:func:`open()` with the 49To open a cec device applications call :c:func:`open() <cec-open>` with the
50desired device name. The function has no side effects; the device 50desired device name. The function has no side effects; the device
51configuration remain unchanged. 51configuration remain unchanged.
52 52
@@ -58,7 +58,7 @@ EBADF.
58Return Value 58Return Value
59============ 59============
60 60
61:c:func:`open()` returns the new file descriptor on success. On error, 61:c:func:`open() <cec-open>` returns the new file descriptor on success. On error,
62-1 is returned, and ``errno`` is set appropriately. Possible error codes 62-1 is returned, and ``errno`` is set appropriately. Possible error codes
63include: 63include:
64 64
diff --git a/Documentation/media/uapi/cec/cec-func-poll.rst b/Documentation/media/uapi/cec/cec-func-poll.rst
index fa0abd8fb160..d49f1ee0742d 100644
--- a/Documentation/media/uapi/cec/cec-func-poll.rst
+++ b/Documentation/media/uapi/cec/cec-func-poll.rst
@@ -39,10 +39,10 @@ Arguments
39Description 39Description
40=========== 40===========
41 41
42With the :c:func:`poll()` function applications can wait for CEC 42With the :c:func:`poll() <cec-poll>` function applications can wait for CEC
43events. 43events.
44 44
45On success :c:func:`poll()` returns the number of file descriptors 45On success :c:func:`poll() <cec-poll>` returns the number of file descriptors
46that have been selected (that is, file descriptors for which the 46that have been selected (that is, file descriptors for which the
47``revents`` field of the respective struct :c:type:`pollfd` 47``revents`` field of the respective struct :c:type:`pollfd`
48is non-zero). CEC devices set the ``POLLIN`` and ``POLLRDNORM`` flags in 48is non-zero). CEC devices set the ``POLLIN`` and ``POLLRDNORM`` flags in
@@ -53,13 +53,13 @@ then the ``POLLPRI`` flag is set. When the function times out it returns
53a value of zero, on failure it returns -1 and the ``errno`` variable is 53a value of zero, on failure it returns -1 and the ``errno`` variable is
54set appropriately. 54set appropriately.
55 55
56For more details see the :c:func:`poll()` manual page. 56For more details see the :c:func:`poll() <cec-poll>` manual page.
57 57
58 58
59Return Value 59Return Value
60============ 60============
61 61
62On success, :c:func:`poll()` returns the number structures which have 62On success, :c:func:`poll() <cec-poll>` returns the number structures which have
63non-zero ``revents`` fields, or zero if the call timed out. On error -1 63non-zero ``revents`` fields, or zero if the call timed out. On error -1
64is returned, and the ``errno`` variable is set appropriately: 64is returned, and the ``errno`` variable is set appropriately:
65 65
diff --git a/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst b/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst
index 6d7bf7bef3eb..6c1f6efb822e 100644
--- a/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst
@@ -21,7 +21,7 @@ Arguments
21========= 21=========
22 22
23``fd`` 23``fd``
24 File descriptor returned by :ref:`open() <cec-func-open>`. 24 File descriptor returned by :c:func:`open() <cec-open>`.
25 25
26``argp`` 26``argp``
27 27
@@ -121,6 +121,13 @@ returns the information to the application. The ioctl never fails.
121 high. This makes it impossible to use CEC to wake up displays that 121 high. This makes it impossible to use CEC to wake up displays that
122 set the HPD pin low when in standby mode, but keep the CEC bus 122 set the HPD pin low when in standby mode, but keep the CEC bus
123 alive. 123 alive.
124 * .. _`CEC-CAP-MONITOR-PIN`:
125
126 - ``CEC_CAP_MONITOR_PIN``
127 - 0x00000080
128 - The CEC hardware can monitor CEC pin changes from low to high voltage
129 and vice versa. When in pin monitoring mode the application will
130 receive ``CEC_EVENT_PIN_CEC_LOW`` and ``CEC_EVENT_PIN_CEC_HIGH`` events.
124 131
125 132
126 133
diff --git a/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst b/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
index fcf863ab6f43..84f431a022ad 100644
--- a/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
@@ -48,7 +48,9 @@ can only be called by a file descriptor in initiator mode (see :ref:`CEC_S_MODE`
48the ``EBUSY`` error code will be returned. 48the ``EBUSY`` error code will be returned.
49 49
50To clear existing logical addresses set ``num_log_addrs`` to 0. All other fields 50To clear existing logical addresses set ``num_log_addrs`` to 0. All other fields
51will be ignored in that case. The adapter will go to the unconfigured state. 51will be ignored in that case. The adapter will go to the unconfigured state and the
52``cec_version``, ``vendor_id`` and ``osd_name`` fields are all reset to their default
53values (CEC version 2.0, no vendor ID and an empty OSD name).
52 54
53If the physical address is valid (see :ref:`ioctl CEC_ADAP_S_PHYS_ADDR <CEC_ADAP_S_PHYS_ADDR>`), 55If the physical address is valid (see :ref:`ioctl CEC_ADAP_S_PHYS_ADDR <CEC_ADAP_S_PHYS_ADDR>`),
54then this ioctl will block until all requested logical 56then this ioctl will block until all requested logical
@@ -63,7 +65,7 @@ logical address types are already defined will return with error ``EBUSY``.
63 65
64.. c:type:: cec_log_addrs 66.. c:type:: cec_log_addrs
65 67
66.. tabularcolumns:: |p{1.0cm}|p{7.5cm}|p{8.0cm}| 68.. tabularcolumns:: |p{1.0cm}|p{8.0cm}|p{7.5cm}|
67 69
68.. cssclass:: longtable 70.. cssclass:: longtable
69 71
@@ -146,6 +148,9 @@ logical address types are already defined will return with error ``EBUSY``.
146 give the CEC framework more information about the device type, even 148 give the CEC framework more information about the device type, even
147 though the framework won't use it directly in the CEC message. 149 though the framework won't use it directly in the CEC message.
148 150
151
152.. tabularcolumns:: |p{7.8cm}|p{1.0cm}|p{8.7cm}|
153
149.. _cec-log-addrs-flags: 154.. _cec-log-addrs-flags:
150 155
151.. flat-table:: Flags for struct cec_log_addrs 156.. flat-table:: Flags for struct cec_log_addrs
@@ -173,7 +178,7 @@ logical address types are already defined will return with error ``EBUSY``.
173 to avoid trivial snooping of the keystrokes. 178 to avoid trivial snooping of the keystrokes.
174 * .. _`CEC-LOG-ADDRS-FL-CDC-ONLY`: 179 * .. _`CEC-LOG-ADDRS-FL-CDC-ONLY`:
175 180
176 - `CEC_LOG_ADDRS_FL_CDC_ONLY` 181 - ``CEC_LOG_ADDRS_FL_CDC_ONLY``
177 - 4 182 - 4
178 - If this flag is set, then the device is CDC-Only. CDC-Only CEC devices 183 - If this flag is set, then the device is CDC-Only. CDC-Only CEC devices
179 are CEC devices that can only handle CDC messages. 184 are CEC devices that can only handle CDC messages.
@@ -181,7 +186,7 @@ logical address types are already defined will return with error ``EBUSY``.
181 All other messages are ignored. 186 All other messages are ignored.
182 187
183 188
184.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 189.. tabularcolumns:: |p{7.8cm}|p{1.0cm}|p{8.7cm}|
185 190
186.. _cec-versions: 191.. _cec-versions:
187 192
diff --git a/Documentation/media/uapi/cec/cec-ioc-dqevent.rst b/Documentation/media/uapi/cec/cec-ioc-dqevent.rst
index 4d3570c2e0b3..a5c821809cc6 100644
--- a/Documentation/media/uapi/cec/cec-ioc-dqevent.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-dqevent.rst
@@ -22,7 +22,7 @@ Arguments
22========= 22=========
23 23
24``fd`` 24``fd``
25 File descriptor returned by :ref:`open() <cec-func-open>`. 25 File descriptor returned by :c:func:`open() <cec-open>`.
26 26
27``argp`` 27``argp``
28 28
@@ -87,7 +87,7 @@ it is guaranteed that the state did change in between the two events.
87 this is more than enough. 87 this is more than enough.
88 88
89 89
90.. tabularcolumns:: |p{1.0cm}|p{4.2cm}|p{2.5cm}|p{8.8cm}| 90.. tabularcolumns:: |p{1.0cm}|p{4.4cm}|p{2.5cm}|p{9.6cm}|
91 91
92.. c:type:: cec_event 92.. c:type:: cec_event
93 93
@@ -98,10 +98,11 @@ it is guaranteed that the state did change in between the two events.
98 98
99 * - __u64 99 * - __u64
100 - ``ts`` 100 - ``ts``
101 - :cspan:`1` Timestamp of the event in ns. 101 - :cspan:`1`\ Timestamp of the event in ns.
102 102
103 The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access 103 The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock.
104 the same clock from userspace use :c:func:`clock_gettime`. 104
105 To access the same clock from userspace use :c:func:`clock_gettime`.
105 * - __u32 106 * - __u32
106 - ``event`` 107 - ``event``
107 - :cspan:`1` The CEC event type, see :ref:`cec-events`. 108 - :cspan:`1` The CEC event type, see :ref:`cec-events`.
@@ -146,6 +147,20 @@ it is guaranteed that the state did change in between the two events.
146 - 2 147 - 2
147 - Generated if one or more CEC messages were lost because the 148 - Generated if one or more CEC messages were lost because the
148 application didn't dequeue CEC messages fast enough. 149 application didn't dequeue CEC messages fast enough.
150 * .. _`CEC-EVENT-PIN-CEC-LOW`:
151
152 - ``CEC_EVENT_PIN_CEC_LOW``
153 - 3
154 - Generated if the CEC pin goes from a high voltage to a low voltage.
155 Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
156 capability set.
157 * .. _`CEC-EVENT-PIN-CEC-HIGH`:
158
159 - ``CEC_EVENT_PIN_CEC_HIGH``
160 - 4
161 - Generated if the CEC pin goes from a low voltage to a high voltage.
162 Only applies to adapters that have the ``CEC_CAP_MONITOR_PIN``
163 capability set.
149 164
150 165
151.. tabularcolumns:: |p{6.0cm}|p{0.6cm}|p{10.9cm}| 166.. tabularcolumns:: |p{6.0cm}|p{0.6cm}|p{10.9cm}|
@@ -165,6 +180,12 @@ it is guaranteed that the state did change in between the two events.
165 opened. See the table above for which events do this. This allows 180 opened. See the table above for which events do this. This allows
166 applications to learn the initial state of the CEC adapter at 181 applications to learn the initial state of the CEC adapter at
167 open() time. 182 open() time.
183 * .. _`CEC-EVENT-FL-DROPPED-EVENTS`:
184
185 - ``CEC_EVENT_FL_DROPPED_EVENTS``
186 - 2
187 - Set if one or more events of the given event type have been dropped.
188 This is an indication that the application cannot keep up.
168 189
169 190
170 191
diff --git a/Documentation/media/uapi/cec/cec-ioc-g-mode.rst b/Documentation/media/uapi/cec/cec-ioc-g-mode.rst
index 664f0d47bbcd..508e2e325683 100644
--- a/Documentation/media/uapi/cec/cec-ioc-g-mode.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-g-mode.rst
@@ -108,6 +108,8 @@ Available follower modes are:
108 108
109.. _cec-mode-follower_e: 109.. _cec-mode-follower_e:
110 110
111.. cssclass:: longtable
112
111.. flat-table:: Follower Modes 113.. flat-table:: Follower Modes
112 :header-rows: 0 114 :header-rows: 0
113 :stub-columns: 0 115 :stub-columns: 0
@@ -149,13 +151,28 @@ Available follower modes are:
149 code. You cannot become a follower if :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>` 151 code. You cannot become a follower if :ref:`CEC_CAP_TRANSMIT <CEC-CAP-TRANSMIT>`
150 is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>` was specified, 152 is not set or if :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>` was specified,
151 the ``EINVAL`` error code is returned in that case. 153 the ``EINVAL`` error code is returned in that case.
154 * .. _`CEC-MODE-MONITOR-PIN`:
155
156 - ``CEC_MODE_MONITOR_PIN``
157 - 0xd0
158 - Put the file descriptor into pin monitoring mode. Can only be used in
159 combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`,
160 otherwise the ``EINVAL`` error code will be returned.
161 This mode requires that the :ref:`CEC_CAP_MONITOR_PIN <CEC-CAP-MONITOR-PIN>`
162 capability is set, otherwise the ``EINVAL`` error code is returned.
163 While in pin monitoring mode this file descriptor can receive the
164 ``CEC_EVENT_PIN_CEC_LOW`` and ``CEC_EVENT_PIN_CEC_HIGH`` events to see the
165 low-level CEC pin transitions. This is very useful for debugging.
166 This mode is only allowed if the process has the ``CAP_NET_ADMIN``
167 capability. If that is not set, then the ``EPERM`` error code is returned.
152 * .. _`CEC-MODE-MONITOR`: 168 * .. _`CEC-MODE-MONITOR`:
153 169
154 - ``CEC_MODE_MONITOR`` 170 - ``CEC_MODE_MONITOR``
155 - 0xe0 171 - 0xe0
156 - Put the file descriptor into monitor mode. Can only be used in 172 - Put the file descriptor into monitor mode. Can only be used in
157 combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`, otherwise EINVAL error 173 combination with :ref:`CEC_MODE_NO_INITIATOR <CEC-MODE-NO-INITIATOR>`,i
158 code will be returned. In monitor mode all messages this CEC 174 otherwise the ``EINVAL`` error code will be returned.
175 In monitor mode all messages this CEC
159 device transmits and all messages it receives (both broadcast 176 device transmits and all messages it receives (both broadcast
160 messages and directed messages for one its logical addresses) will 177 messages and directed messages for one its logical addresses) will
161 be reported. This is very useful for debugging. This is only 178 be reported. This is very useful for debugging. This is only
@@ -191,55 +208,68 @@ Core message processing details:
191 * .. _`CEC-MSG-GET-CEC-VERSION`: 208 * .. _`CEC-MSG-GET-CEC-VERSION`:
192 209
193 - ``CEC_MSG_GET_CEC_VERSION`` 210 - ``CEC_MSG_GET_CEC_VERSION``
194 - When in passthrough mode this message has to be handled by 211 - The core will return the CEC version that was set with
195 userspace, otherwise the core will return the CEC version that was 212 :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`,
196 set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`. 213 except when in passthrough mode. In passthrough mode the core
214 does nothing and this message has to be handled by a follower
215 instead.
197 * .. _`CEC-MSG-GIVE-DEVICE-VENDOR-ID`: 216 * .. _`CEC-MSG-GIVE-DEVICE-VENDOR-ID`:
198 217
199 - ``CEC_MSG_GIVE_DEVICE_VENDOR_ID`` 218 - ``CEC_MSG_GIVE_DEVICE_VENDOR_ID``
200 - When in passthrough mode this message has to be handled by 219 - The core will return the vendor ID that was set with
201 userspace, otherwise the core will return the vendor ID that was 220 :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`,
202 set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`. 221 except when in passthrough mode. In passthrough mode the core
222 does nothing and this message has to be handled by a follower
223 instead.
203 * .. _`CEC-MSG-ABORT`: 224 * .. _`CEC-MSG-ABORT`:
204 225
205 - ``CEC_MSG_ABORT`` 226 - ``CEC_MSG_ABORT``
206 - When in passthrough mode this message has to be handled by 227 - The core will return a Feature Abort message with reason
207 userspace, otherwise the core will return a feature refused 228 'Feature Refused' as per the specification, except when in
208 message as per the specification. 229 passthrough mode. In passthrough mode the core does nothing
230 and this message has to be handled by a follower instead.
209 * .. _`CEC-MSG-GIVE-PHYSICAL-ADDR`: 231 * .. _`CEC-MSG-GIVE-PHYSICAL-ADDR`:
210 232
211 - ``CEC_MSG_GIVE_PHYSICAL_ADDR`` 233 - ``CEC_MSG_GIVE_PHYSICAL_ADDR``
212 - When in passthrough mode this message has to be handled by 234 - The core will report the current physical address, except when
213 userspace, otherwise the core will report the current physical 235 in passthrough mode. In passthrough mode the core does nothing
214 address. 236 and this message has to be handled by a follower instead.
215 * .. _`CEC-MSG-GIVE-OSD-NAME`: 237 * .. _`CEC-MSG-GIVE-OSD-NAME`:
216 238
217 - ``CEC_MSG_GIVE_OSD_NAME`` 239 - ``CEC_MSG_GIVE_OSD_NAME``
218 - When in passthrough mode this message has to be handled by 240 - The core will report the current OSD name that was set with
219 userspace, otherwise the core will report the current OSD name as 241 :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`,
220 was set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`. 242 except when in passthrough mode. In passthrough mode the core
243 does nothing and this message has to be handled by a follower
244 instead.
221 * .. _`CEC-MSG-GIVE-FEATURES`: 245 * .. _`CEC-MSG-GIVE-FEATURES`:
222 246
223 - ``CEC_MSG_GIVE_FEATURES`` 247 - ``CEC_MSG_GIVE_FEATURES``
224 - When in passthrough mode this message has to be handled by 248 - The core will do nothing if the CEC version is older than 2.0,
225 userspace, otherwise the core will report the current features as 249 otherwise it will report the current features that were set with
226 was set with :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>` 250 :ref:`ioctl CEC_ADAP_S_LOG_ADDRS <CEC_ADAP_S_LOG_ADDRS>`,
227 or the message is ignored if the CEC version was older than 2.0. 251 except when in passthrough mode. In passthrough mode the core
252 does nothing (for any CEC version) and this message has to be handled
253 by a follower instead.
228 * .. _`CEC-MSG-USER-CONTROL-PRESSED`: 254 * .. _`CEC-MSG-USER-CONTROL-PRESSED`:
229 255
230 - ``CEC_MSG_USER_CONTROL_PRESSED`` 256 - ``CEC_MSG_USER_CONTROL_PRESSED``
231 - If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set, then generate a remote control key 257 - If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set and if
232 press. This message is always passed on to userspace. 258 :ref:`CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU <CEC-LOG-ADDRS-FL-ALLOW-RC-PASSTHRU>`
259 is set, then generate a remote control key
260 press. This message is always passed on to the follower(s).
233 * .. _`CEC-MSG-USER-CONTROL-RELEASED`: 261 * .. _`CEC-MSG-USER-CONTROL-RELEASED`:
234 262
235 - ``CEC_MSG_USER_CONTROL_RELEASED`` 263 - ``CEC_MSG_USER_CONTROL_RELEASED``
236 - If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set, then generate a remote control key 264 - If :ref:`CEC_CAP_RC <CEC-CAP-RC>` is set and if
237 release. This message is always passed on to userspace. 265 :ref:`CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU <CEC-LOG-ADDRS-FL-ALLOW-RC-PASSTHRU>`
266 is set, then generate a remote control key
267 release. This message is always passed on to the follower(s).
238 * .. _`CEC-MSG-REPORT-PHYSICAL-ADDR`: 268 * .. _`CEC-MSG-REPORT-PHYSICAL-ADDR`:
239 269
240 - ``CEC_MSG_REPORT_PHYSICAL_ADDR`` 270 - ``CEC_MSG_REPORT_PHYSICAL_ADDR``
241 - The CEC framework will make note of the reported physical address 271 - The CEC framework will make note of the reported physical address
242 and then just pass the message on to userspace. 272 and then just pass the message on to the follower(s).
243 273
244 274
245 275
diff --git a/Documentation/media/uapi/cec/cec-ioc-receive.rst b/Documentation/media/uapi/cec/cec-ioc-receive.rst
index 267044f7ac30..0f397c535a4c 100644
--- a/Documentation/media/uapi/cec/cec-ioc-receive.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-receive.rst
@@ -195,6 +195,8 @@ View On' messages from initiator 0xf ('Unregistered') to destination 0 ('TV').
195 valid if the :ref:`CEC_TX_STATUS_ERROR <CEC-TX-STATUS-ERROR>` status bit is set. 195 valid if the :ref:`CEC_TX_STATUS_ERROR <CEC-TX-STATUS-ERROR>` status bit is set.
196 196
197 197
198.. tabularcolumns:: |p{6.2cm}|p{1.0cm}|p{10.3cm}|
199
198.. _cec-msg-flags: 200.. _cec-msg-flags:
199 201
200.. flat-table:: Flags for struct cec_msg 202.. flat-table:: Flags for struct cec_msg
diff --git a/Documentation/media/uapi/dvb/audio-channel-select.rst b/Documentation/media/uapi/dvb/audio-channel-select.rst
index 2ceb4efebdf0..8cab3d7abff5 100644
--- a/Documentation/media/uapi/dvb/audio-channel-select.rst
+++ b/Documentation/media/uapi/dvb/audio-channel-select.rst
@@ -44,7 +44,7 @@ Arguments
44Description 44Description
45----------- 45-----------
46 46
47This ioctl is for DVB devices only. To control a V4L2 decoder use the 47This ioctl is for Digital TV devices only. To control a V4L2 decoder use the
48V4L2 ``V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK`` control instead. 48V4L2 ``V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK`` control instead.
49 49
50This ioctl call asks the Audio Device to select the requested channel if 50This ioctl call asks the Audio Device to select the requested channel if
diff --git a/Documentation/media/uapi/dvb/audio-fclose.rst b/Documentation/media/uapi/dvb/audio-fclose.rst
index 4df24c8d74ed..58d351a3af4b 100644
--- a/Documentation/media/uapi/dvb/audio-fclose.rst
+++ b/Documentation/media/uapi/dvb/audio-fclose.rst
@@ -2,14 +2,14 @@
2 2
3.. _audio_fclose: 3.. _audio_fclose:
4 4
5================= 5========================
6DVB audio close() 6Digital TV audio close()
7================= 7========================
8 8
9Name 9Name
10---- 10----
11 11
12DVB audio close() 12Digital TV audio close()
13 13
14.. attention:: This ioctl is deprecated 14.. attention:: This ioctl is deprecated
15 15
diff --git a/Documentation/media/uapi/dvb/audio-fopen.rst b/Documentation/media/uapi/dvb/audio-fopen.rst
index a802c2e0dc6a..4a174640bf11 100644
--- a/Documentation/media/uapi/dvb/audio-fopen.rst
+++ b/Documentation/media/uapi/dvb/audio-fopen.rst
@@ -2,14 +2,14 @@
2 2
3.. _audio_fopen: 3.. _audio_fopen:
4 4
5================ 5=======================
6DVB audio open() 6Digital TV audio open()
7================ 7=======================
8 8
9Name 9Name
10---- 10----
11 11
12DVB audio open() 12Digital TV audio open()
13 13
14.. attention:: This ioctl is deprecated 14.. attention:: This ioctl is deprecated
15 15
diff --git a/Documentation/media/uapi/dvb/audio-fwrite.rst b/Documentation/media/uapi/dvb/audio-fwrite.rst
index 8882cad7d165..4980ae7953ef 100644
--- a/Documentation/media/uapi/dvb/audio-fwrite.rst
+++ b/Documentation/media/uapi/dvb/audio-fwrite.rst
@@ -2,14 +2,14 @@
2 2
3.. _audio_fwrite: 3.. _audio_fwrite:
4 4
5================= 5=========================
6DVB audio write() 6Digital TV audio write()
7================= 7=========================
8 8
9Name 9Name
10---- 10----
11 11
12DVB audio write() 12Digital TV audio write()
13 13
14.. attention:: This ioctl is deprecated 14.. attention:: This ioctl is deprecated
15 15
diff --git a/Documentation/media/uapi/dvb/audio-set-av-sync.rst b/Documentation/media/uapi/dvb/audio-set-av-sync.rst
index 0cef4917d2cf..cf621f3a3037 100644
--- a/Documentation/media/uapi/dvb/audio-set-av-sync.rst
+++ b/Documentation/media/uapi/dvb/audio-set-av-sync.rst
@@ -38,7 +38,7 @@ Arguments
38 38
39 - boolean state 39 - boolean state
40 40
41 - Tells the DVB subsystem if A/V synchronization shall be ON or OFF. 41 - Tells the Digital TV subsystem if A/V synchronization shall be ON or OFF.
42 42
43 TRUE: AV-sync ON 43 TRUE: AV-sync ON
44 44
diff --git a/Documentation/media/uapi/dvb/audio-set-bypass-mode.rst b/Documentation/media/uapi/dvb/audio-set-bypass-mode.rst
index b063c496c2eb..f0db1fbdb066 100644
--- a/Documentation/media/uapi/dvb/audio-set-bypass-mode.rst
+++ b/Documentation/media/uapi/dvb/audio-set-bypass-mode.rst
@@ -38,7 +38,7 @@ Arguments
38 - boolean mode 38 - boolean mode
39 39
40 - Enables or disables the decoding of the current Audio stream in 40 - Enables or disables the decoding of the current Audio stream in
41 the DVB subsystem. 41 the Digital TV subsystem.
42 42
43 TRUE: Bypass is disabled 43 TRUE: Bypass is disabled
44 44
@@ -50,8 +50,8 @@ Description
50 50
51This ioctl call asks the Audio Device to bypass the Audio decoder and 51This ioctl call asks the Audio Device to bypass the Audio decoder and
52forward the stream without decoding. This mode shall be used if streams 52forward the stream without decoding. This mode shall be used if streams
53that can’t be handled by the DVB system shall be decoded. Dolby 53that can’t be handled by the Digial TV system shall be decoded. Dolby
54DigitalTM streams are automatically forwarded by the DVB subsystem if 54DigitalTM streams are automatically forwarded by the Digital TV subsystem if
55the hardware can handle it. 55the hardware can handle it.
56 56
57 57
diff --git a/Documentation/media/uapi/dvb/audio-set-mute.rst b/Documentation/media/uapi/dvb/audio-set-mute.rst
index 897e7228f4d8..0af105a8ddcc 100644
--- a/Documentation/media/uapi/dvb/audio-set-mute.rst
+++ b/Documentation/media/uapi/dvb/audio-set-mute.rst
@@ -48,7 +48,7 @@ Arguments
48Description 48Description
49----------- 49-----------
50 50
51This ioctl is for DVB devices only. To control a V4L2 decoder use the 51This ioctl is for Digital TV devices only. To control a V4L2 decoder use the
52V4L2 :ref:`VIDIOC_DECODER_CMD` with the 52V4L2 :ref:`VIDIOC_DECODER_CMD` with the
53``V4L2_DEC_CMD_START_MUTE_AUDIO`` flag instead. 53``V4L2_DEC_CMD_START_MUTE_AUDIO`` flag instead.
54 54
diff --git a/Documentation/media/uapi/dvb/audio.rst b/Documentation/media/uapi/dvb/audio.rst
index 155622185ea4..e9f9e589c486 100644
--- a/Documentation/media/uapi/dvb/audio.rst
+++ b/Documentation/media/uapi/dvb/audio.rst
@@ -2,15 +2,16 @@
2 2
3.. _dvb_audio: 3.. _dvb_audio:
4 4
5################ 5#######################
6DVB Audio Device 6Digital TV Audio Device
7################ 7#######################
8The DVB audio device controls the MPEG2 audio decoder of the DVB 8
9hardware. It can be accessed through ``/dev/dvb/adapter?/audio?``. Data 9The Digital TV audio device controls the MPEG2 audio decoder of the Digital
10TV hardware. It can be accessed through ``/dev/dvb/adapter?/audio?``. Data
10types and and ioctl definitions can be accessed by including 11types and and ioctl definitions can be accessed by including
11``linux/dvb/audio.h`` in your application. 12``linux/dvb/audio.h`` in your application.
12 13
13Please note that some DVB cards don’t have their own MPEG decoder, which 14Please note that some Digital TV cards don’t have their own MPEG decoder, which
14results in the omission of the audio and video device. 15results in the omission of the audio and video device.
15 16
16These ioctls were also used by V4L2 to control MPEG decoders implemented 17These ioctls were also used by V4L2 to control MPEG decoders implemented
diff --git a/Documentation/media/uapi/dvb/audio_h.rst b/Documentation/media/uapi/dvb/audio_h.rst
deleted file mode 100644
index e00c3010fdf9..000000000000
--- a/Documentation/media/uapi/dvb/audio_h.rst
+++ /dev/null
@@ -1,9 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _audio_h:
4
5*********************
6DVB Audio Header File
7*********************
8
9.. kernel-include:: $BUILDDIR/audio.h.rst
diff --git a/Documentation/media/uapi/dvb/ca-fclose.rst b/Documentation/media/uapi/dvb/ca-fclose.rst
index 5ecefa4abc3d..e84bbfcfa184 100644
--- a/Documentation/media/uapi/dvb/ca-fclose.rst
+++ b/Documentation/media/uapi/dvb/ca-fclose.rst
@@ -2,14 +2,14 @@
2 2
3.. _ca_fclose: 3.. _ca_fclose:
4 4
5============== 5=====================
6DVB CA close() 6Digital TV CA close()
7============== 7=====================
8 8
9Name 9Name
10---- 10----
11 11
12DVB CA close() 12Digital TV CA close()
13 13
14 14
15Synopsis 15Synopsis
@@ -34,13 +34,10 @@ This system call closes a previously opened CA device.
34Return Value 34Return Value
35------------ 35------------
36 36
37.. flat-table:: 37On success 0 is returned.
38 :header-rows: 0
39 :stub-columns: 0
40 38
39On error -1 is returned, and the ``errno`` variable is set
40appropriately.
41 41
42 - .. row 1 42Generic error codes are described at the
43 43:ref:`Generic Error Codes <gen-errors>` chapter.
44 - ``EBADF``
45
46 - fd is not a valid open file descriptor.
diff --git a/Documentation/media/uapi/dvb/ca-fopen.rst b/Documentation/media/uapi/dvb/ca-fopen.rst
index 3d2819751446..056c71b53a70 100644
--- a/Documentation/media/uapi/dvb/ca-fopen.rst
+++ b/Documentation/media/uapi/dvb/ca-fopen.rst
@@ -2,14 +2,14 @@
2 2
3.. _ca_fopen: 3.. _ca_fopen:
4 4
5============= 5====================
6DVB CA open() 6Digital TV CA open()
7============= 7====================
8 8
9Name 9Name
10---- 10----
11 11
12DVB CA open() 12Digital TV CA open()
13 13
14 14
15Synopsis 15Synopsis
@@ -23,25 +23,25 @@ Arguments
23--------- 23---------
24 24
25``name`` 25``name``
26 Name of specific DVB CA device. 26 Name of specific Digital TV CA device.
27 27
28``flags`` 28``flags``
29 A bit-wise OR of the following flags: 29 A bit-wise OR of the following flags:
30 30
31.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
32
31.. flat-table:: 33.. flat-table::
32 :header-rows: 0 34 :header-rows: 0
33 :stub-columns: 0 35 :stub-columns: 0
36 :widths: 1 16
34 37
35 - 38 - - ``O_RDONLY``
36 - O_RDONLY
37 - read-only access 39 - read-only access
38 40
39 - 41 - - ``O_RDWR``
40 - O_RDWR
41 - read/write access 42 - read/write access
42 43
43 - 44 - - ``O_NONBLOCK``
44 - O_NONBLOCK
45 - open in non-blocking mode 45 - open in non-blocking mode
46 (blocking mode is the default) 46 (blocking mode is the default)
47 47
@@ -49,50 +49,29 @@ Arguments
49Description 49Description
50----------- 50-----------
51 51
52This system call opens a named ca device (e.g. /dev/ost/ca) for 52This system call opens a named ca device (e.g. ``/dev/dvb/adapter?/ca?``)
53subsequent use. 53for subsequent use.
54 54
55When an open() call has succeeded, the device will be ready for use. The 55When an ``open()`` call has succeeded, the device will be ready for use. The
56significance of blocking or non-blocking mode is described in the 56significance of blocking or non-blocking mode is described in the
57documentation for functions where there is a difference. It does not 57documentation for functions where there is a difference. It does not
58affect the semantics of the open() call itself. A device opened in 58affect the semantics of the ``open()`` call itself. A device opened in
59blocking mode can later be put into non-blocking mode (and vice versa) 59blocking mode can later be put into non-blocking mode (and vice versa)
60using the F_SETFL command of the fcntl system call. This is a standard 60using the ``F_SETFL`` command of the ``fcntl`` system call. This is a
61system call, documented in the Linux manual page for fcntl. Only one 61standard system call, documented in the Linux manual page for fcntl.
62user can open the CA Device in O_RDWR mode. All other attempts to open 62Only one user can open the CA Device in ``O_RDWR`` mode. All other
63the device in this mode will fail, and an error code will be returned. 63attempts to open the device in this mode will fail, and an error code
64will be returned.
64 65
65 66
66Return Value 67Return Value
67------------ 68------------
68 69
69.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
70
71.. flat-table::
72 :header-rows: 0
73 :stub-columns: 0
74
75
76 - .. row 1
77
78 - ``ENODEV``
79
80 - Device driver not loaded/available.
81
82 - .. row 2
83
84 - ``EINTERNAL``
85
86 - Internal error.
87
88 - .. row 3
89
90 - ``EBUSY``
91
92 - Device or resource busy.
93 70
94 - .. row 4 71On success 0 is returned.
95 72
96 - ``EINVAL`` 73On error -1 is returned, and the ``errno`` variable is set
74appropriately.
97 75
98 - Invalid argument. 76Generic error codes are described at the
77:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/ca-get-cap.rst b/Documentation/media/uapi/dvb/ca-get-cap.rst
index fbf7e359cb8a..d2d5c1355396 100644
--- a/Documentation/media/uapi/dvb/ca-get-cap.rst
+++ b/Documentation/media/uapi/dvb/ca-get-cap.rst
@@ -28,43 +28,19 @@ Arguments
28``caps`` 28``caps``
29 Pointer to struct :c:type:`ca_caps`. 29 Pointer to struct :c:type:`ca_caps`.
30 30
31.. c:type:: struct ca_caps
32
33.. flat-table:: struct ca_caps
34 :header-rows: 1
35 :stub-columns: 0
36
37 -
38 - type
39 - name
40 - description
41 -
42 - unsigned int
43 - slot_num
44 - total number of CA card and module slots
45 -
46 - unsigned int
47 - slot_type
48 - bitmask with all supported slot types
49 -
50 - unsigned int
51 - descr_num
52 - total number of descrambler slots (keys)
53 -
54 - unsigned int
55 - descr_type
56 - bit mask with all supported descr types
57
58
59Description 31Description
60----------- 32-----------
61 33
62.. note:: This ioctl is undocumented. Documentation is welcome. 34Queries the Kernel for information about the available CA and descrambler
63 35slots, and their types.
64 36
65Return Value 37Return Value
66------------ 38------------
67 39
68On success 0 is returned, on error -1 and the ``errno`` variable is set 40On success 0 is returned and :c:type:`ca_caps` is filled.
69appropriately. The generic error codes are described at the 41
42On error, -1 is returned and the ``errno`` variable is set
43appropriately.
44
45The generic error codes are described at the
70:ref:`Generic Error Codes <gen-errors>` chapter. 46:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/ca-get-descr-info.rst b/Documentation/media/uapi/dvb/ca-get-descr-info.rst
index 7bf327a3d0e3..e564fbb8d524 100644
--- a/Documentation/media/uapi/dvb/ca-get-descr-info.rst
+++ b/Documentation/media/uapi/dvb/ca-get-descr-info.rst
@@ -27,37 +27,16 @@ Arguments
27``desc`` 27``desc``
28 Pointer to struct :c:type:`ca_descr_info`. 28 Pointer to struct :c:type:`ca_descr_info`.
29 29
30.. c:type:: struct ca_descr_info
31
32.. flat-table:: struct ca_descr_info
33 :header-rows: 1
34 :stub-columns: 0
35
36 -
37 - type
38 - name
39 - description
40
41 -
42 - unsigned int
43 - num
44 - number of available descramblers (keys)
45 -
46 - unsigned int
47 - type
48 - type of supported scrambling system. Valid values are:
49 ``CA_ECD``, ``CA_NDS`` and ``CA_DSS``.
50
51
52Description 30Description
53----------- 31-----------
54 32
55.. note:: This ioctl is undocumented. Documentation is welcome. 33Returns information about all descrambler slots.
56
57 34
58Return Value 35Return Value
59------------ 36------------
60 37
61On success 0 is returned, on error -1 and the ``errno`` variable is set 38On success 0 is returned, and :c:type:`ca_descr_info` is filled.
39
40On error -1 is returned, and the ``errno`` variable is set
62appropriately. The generic error codes are described at the 41appropriately. The generic error codes are described at the
63:ref:`Generic Error Codes <gen-errors>` chapter. 42:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/ca-get-msg.rst b/Documentation/media/uapi/dvb/ca-get-msg.rst
index 121588da3ef1..ceeda623ce93 100644
--- a/Documentation/media/uapi/dvb/ca-get-msg.rst
+++ b/Documentation/media/uapi/dvb/ca-get-msg.rst
@@ -28,47 +28,25 @@ Arguments
28``msg`` 28``msg``
29 Pointer to struct :c:type:`ca_msg`. 29 Pointer to struct :c:type:`ca_msg`.
30 30
31Description
32-----------
31 33
32.. c:type:: struct ca_msg 34Receives a message via a CI CA module.
33
34.. flat-table:: struct ca_msg
35 :header-rows: 1
36 :stub-columns: 0
37
38 -
39 - type
40 - name
41 - description
42 -
43 - unsigned int
44 - index
45 -
46
47 -
48 - unsigned int
49 - type
50 -
51 35
52 - 36.. note::
53 - unsigned int
54 - length
55 -
56 37
57 - 38 Please notice that, on most drivers, this is done by reading from
58 - unsigned char 39 the /dev/adapter?/ca? device node.
59 - msg[256]
60 -
61 40
62 41
63Description 42Return Value
64----------- 43------------
65 44
66.. note:: This ioctl is undocumented. Documentation is welcome.
67 45
46On success 0 is returned.
68 47
69Return Value 48On error -1 is returned, and the ``errno`` variable is set
70------------ 49appropriately.
71 50
72On success 0 is returned, on error -1 and the ``errno`` variable is set 51Generic error codes are described at the
73appropriately. The generic error codes are described at the
74:ref:`Generic Error Codes <gen-errors>` chapter. 52:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/ca-get-slot-info.rst b/Documentation/media/uapi/dvb/ca-get-slot-info.rst
index 54e5dc78a2dc..1a1d6f0c71b9 100644
--- a/Documentation/media/uapi/dvb/ca-get-slot-info.rst
+++ b/Documentation/media/uapi/dvb/ca-get-slot-info.rst
@@ -26,100 +26,32 @@ Arguments
26 File descriptor returned by a previous call to :c:func:`open() <cec-open>`. 26 File descriptor returned by a previous call to :c:func:`open() <cec-open>`.
27 27
28``info`` 28``info``
29 Pointer to struct c:type:`ca_slot_info`. 29 Pointer to struct :c:type:`ca_slot_info`.
30 30
31.. _ca_slot_info_type: 31Description
32-----------
32 33
33.. flat-table:: ca_slot_info types 34Returns information about a CA slot identified by
34 :header-rows: 1 35:c:type:`ca_slot_info`.slot_num.
35 :stub-columns: 0
36 36
37 -
38 - type
39 - name
40 - description
41 -
42 - CA_CI
43 - 1
44 - CI high level interface
45
46 -
47 - CA_CI_LINK
48 - 2
49 - CI link layer level interface
50
51 -
52 - CA_CI_PHYS
53 - 4
54 - CI physical layer level interface
55
56 -
57 - CA_DESCR
58 - 8
59 - built-in descrambler
60
61 -
62 - CA_SC
63 - 128
64 - simple smart card interface
65
66.. _ca_slot_info_flag:
67
68.. flat-table:: ca_slot_info flags
69 :header-rows: 1
70 :stub-columns: 0
71 37
72 - 38Return Value
73 - type 39------------
74 - name
75 - description
76 40
77 - 41On success 0 is returned, and :c:type:`ca_slot_info` is filled.
78 - CA_CI_MODULE_PRESENT
79 - 1
80 - module (or card) inserted
81 42
82 - 43On error -1 is returned, and the ``errno`` variable is set
83 - CA_CI_MODULE_READY 44appropriately.
84 - 2
85 -
86 45
87.. c:type:: ca_slot_info 46.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
88 47
89.. flat-table:: struct ca_slot_info 48.. flat-table::
90 :header-rows: 1 49 :header-rows: 0
91 :stub-columns: 0 50 :stub-columns: 0
51 :widths: 1 16
92 52
93 - 53 - - ``ENODEV``
94 - type 54 - the slot is not available.
95 - name
96 - description
97
98 -
99 - int
100 - num
101 - slot number
102
103 -
104 - int
105 - type
106 - CA interface this slot supports, as defined at :ref:`ca_slot_info_type`.
107
108 -
109 - unsigned int
110 - flags
111 - flags as defined at :ref:`ca_slot_info_flag`.
112
113
114Description
115-----------
116
117.. note:: This ioctl is undocumented. Documentation is welcome.
118
119
120Return Value
121------------
122 55
123On success 0 is returned, on error -1 and the ``errno`` variable is set 56The generic error codes are described at the
124appropriately. The generic error codes are described at the
125:ref:`Generic Error Codes <gen-errors>` chapter. 57:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/ca-reset.rst b/Documentation/media/uapi/dvb/ca-reset.rst
index 477313121a65..29788325f90e 100644
--- a/Documentation/media/uapi/dvb/ca-reset.rst
+++ b/Documentation/media/uapi/dvb/ca-reset.rst
@@ -28,12 +28,17 @@ Arguments
28Description 28Description
29----------- 29-----------
30 30
31.. note:: This ioctl is undocumented. Documentation is welcome. 31Puts the Conditional Access hardware on its initial state. It should
32be called before start using the CA hardware.
32 33
33 34
34Return Value 35Return Value
35------------ 36------------
36 37
37On success 0 is returned, on error -1 and the ``errno`` variable is set 38On success 0 is returned.
38appropriately. The generic error codes are described at the 39
40On error -1 is returned, and the ``errno`` variable is set
41appropriately.
42
43Generic error codes are described at the
39:ref:`Generic Error Codes <gen-errors>` chapter. 44:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/ca-send-msg.rst b/Documentation/media/uapi/dvb/ca-send-msg.rst
index 532ef5f9d6ac..9e91287b7bbc 100644
--- a/Documentation/media/uapi/dvb/ca-send-msg.rst
+++ b/Documentation/media/uapi/dvb/ca-send-msg.rst
@@ -32,12 +32,20 @@ Arguments
32Description 32Description
33----------- 33-----------
34 34
35.. note:: This ioctl is undocumented. Documentation is welcome. 35Sends a message via a CI CA module.
36 36
37.. note::
38
39 Please notice that, on most drivers, this is done by writing
40 to the /dev/adapter?/ca? device node.
37 41
38Return Value 42Return Value
39------------ 43------------
40 44
41On success 0 is returned, on error -1 and the ``errno`` variable is set 45On success 0 is returned.
42appropriately. The generic error codes are described at the 46
47On error -1 is returned, and the ``errno`` variable is set
48appropriately.
49
50Generic error codes are described at the
43:ref:`Generic Error Codes <gen-errors>` chapter. 51:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/ca-set-descr.rst b/Documentation/media/uapi/dvb/ca-set-descr.rst
index 70f7b3cf12ad..a6c47205ffd8 100644
--- a/Documentation/media/uapi/dvb/ca-set-descr.rst
+++ b/Documentation/media/uapi/dvb/ca-set-descr.rst
@@ -28,16 +28,19 @@ Arguments
28``msg`` 28``msg``
29 Pointer to struct :c:type:`ca_descr`. 29 Pointer to struct :c:type:`ca_descr`.
30 30
31
32Description 31Description
33----------- 32-----------
34 33
35.. note:: This ioctl is undocumented. Documentation is welcome. 34CA_SET_DESCR is used for feeding descrambler CA slots with descrambling
36 35keys (refered as control words).
37 36
38Return Value 37Return Value
39------------ 38------------
40 39
41On success 0 is returned, on error -1 and the ``errno`` variable is set 40On success 0 is returned.
42appropriately. The generic error codes are described at the 41
42On error -1 is returned, and the ``errno`` variable is set
43appropriately.
44
45Generic error codes are described at the
43:ref:`Generic Error Codes <gen-errors>` chapter. 46:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/ca-set-pid.rst b/Documentation/media/uapi/dvb/ca-set-pid.rst
deleted file mode 100644
index 891c1c72ef24..000000000000
--- a/Documentation/media/uapi/dvb/ca-set-pid.rst
+++ /dev/null
@@ -1,60 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _CA_SET_PID:
4
5==========
6CA_SET_PID
7==========
8
9Name
10----
11
12CA_SET_PID
13
14
15Synopsis
16--------
17
18.. c:function:: int ioctl(fd, CA_SET_PID, struct ca_pid *pid)
19 :name: CA_SET_PID
20
21
22Arguments
23---------
24
25``fd``
26 File descriptor returned by a previous call to :c:func:`open() <dvb-ca-open>`.
27
28``pid``
29 Pointer to struct :c:type:`ca_pid`.
30
31.. c:type:: ca_pid
32
33.. flat-table:: struct ca_pid
34 :header-rows: 1
35 :stub-columns: 0
36
37 -
38 - unsigned int
39 - pid
40 - Program ID
41
42 -
43 - int
44 - index
45 - PID index. Use -1 to disable.
46
47
48
49Description
50-----------
51
52.. note:: This ioctl is undocumented. Documentation is welcome.
53
54
55Return Value
56------------
57
58On success 0 is returned, on error -1 and the ``errno`` variable is set
59appropriately. The generic error codes are described at the
60:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/ca.rst b/Documentation/media/uapi/dvb/ca.rst
index 14b14abda1ae..deac72d89e93 100644
--- a/Documentation/media/uapi/dvb/ca.rst
+++ b/Documentation/media/uapi/dvb/ca.rst
@@ -2,14 +2,20 @@
2 2
3.. _dvb_ca: 3.. _dvb_ca:
4 4
5############# 5####################
6DVB CA Device 6Digital TV CA Device
7############# 7####################
8The DVB CA device controls the conditional access hardware. It can be 8
9accessed through ``/dev/dvb/adapter?/ca?``. Data types and and ioctl 9The Digital TV CA device controls the conditional access hardware. It
10can be accessed through ``/dev/dvb/adapter?/ca?``. Data types and and ioctl
10definitions can be accessed by including ``linux/dvb/ca.h`` in your 11definitions can be accessed by including ``linux/dvb/ca.h`` in your
11application. 12application.
12 13
14.. note::
15
16 There are three ioctls at this API that aren't documented:
17 :ref:`CA_GET_MSG`, :ref:`CA_SEND_MSG` and :ref:`CA_SET_DESCR`.
18 Documentation for them are welcome.
13 19
14.. toctree:: 20.. toctree::
15 :maxdepth: 1 21 :maxdepth: 1
diff --git a/Documentation/media/uapi/dvb/ca_data_types.rst b/Documentation/media/uapi/dvb/ca_data_types.rst
index d9e27c77426c..ac7cbd76ddd5 100644
--- a/Documentation/media/uapi/dvb/ca_data_types.rst
+++ b/Documentation/media/uapi/dvb/ca_data_types.rst
@@ -6,105 +6,4 @@
6CA Data Types 6CA Data Types
7************* 7*************
8 8
9 9.. kernel-doc:: include/uapi/linux/dvb/ca.h
10.. c:type:: ca_slot_info
11
12ca_slot_info_t
13==============
14
15
16.. code-block:: c
17
18 typedef struct ca_slot_info {
19 int num; /* slot number */
20
21 int type; /* CA interface this slot supports */
22 #define CA_CI 1 /* CI high level interface */
23 #define CA_CI_LINK 2 /* CI link layer level interface */
24 #define CA_CI_PHYS 4 /* CI physical layer level interface */
25 #define CA_DESCR 8 /* built-in descrambler */
26 #define CA_SC 128 /* simple smart card interface */
27
28 unsigned int flags;
29 #define CA_CI_MODULE_PRESENT 1 /* module (or card) inserted */
30 #define CA_CI_MODULE_READY 2
31 } ca_slot_info_t;
32
33
34.. c:type:: ca_descr_info
35
36ca_descr_info_t
37===============
38
39
40.. code-block:: c
41
42 typedef struct ca_descr_info {
43 unsigned int num; /* number of available descramblers (keys) */
44 unsigned int type; /* type of supported scrambling system */
45 #define CA_ECD 1
46 #define CA_NDS 2
47 #define CA_DSS 4
48 } ca_descr_info_t;
49
50
51.. c:type:: ca_caps
52
53ca_caps_t
54=========
55
56
57.. code-block:: c
58
59 typedef struct ca_caps {
60 unsigned int slot_num; /* total number of CA card and module slots */
61 unsigned int slot_type; /* OR of all supported types */
62 unsigned int descr_num; /* total number of descrambler slots (keys) */
63 unsigned int descr_type;/* OR of all supported types */
64 } ca_cap_t;
65
66
67.. c:type:: ca_msg
68
69ca_msg_t
70========
71
72
73.. code-block:: c
74
75 /* a message to/from a CI-CAM */
76 typedef struct ca_msg {
77 unsigned int index;
78 unsigned int type;
79 unsigned int length;
80 unsigned char msg[256];
81 } ca_msg_t;
82
83
84.. c:type:: ca_descr
85
86ca_descr_t
87==========
88
89
90.. code-block:: c
91
92 typedef struct ca_descr {
93 unsigned int index;
94 unsigned int parity;
95 unsigned char cw[8];
96 } ca_descr_t;
97
98
99.. c:type:: ca_pid
100
101ca-pid
102======
103
104
105.. code-block:: c
106
107 typedef struct ca_pid {
108 unsigned int pid;
109 int index; /* -1 == disable*/
110 } ca_pid_t;
diff --git a/Documentation/media/uapi/dvb/ca_function_calls.rst b/Documentation/media/uapi/dvb/ca_function_calls.rst
index c085a0ebbc05..87d697851e82 100644
--- a/Documentation/media/uapi/dvb/ca_function_calls.rst
+++ b/Documentation/media/uapi/dvb/ca_function_calls.rst
@@ -18,4 +18,3 @@ CA Function Calls
18 ca-get-msg 18 ca-get-msg
19 ca-send-msg 19 ca-send-msg
20 ca-set-descr 20 ca-set-descr
21 ca-set-pid
diff --git a/Documentation/media/uapi/dvb/ca_h.rst b/Documentation/media/uapi/dvb/ca_h.rst
deleted file mode 100644
index f513592ef529..000000000000
--- a/Documentation/media/uapi/dvb/ca_h.rst
+++ /dev/null
@@ -1,9 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _ca_h:
4
5**********************************
6DVB Conditional Access Header File
7**********************************
8
9.. kernel-include:: $BUILDDIR/ca.h.rst
diff --git a/Documentation/media/uapi/dvb/demux.rst b/Documentation/media/uapi/dvb/demux.rst
index b12b5a2dac94..45c3d6405c46 100644
--- a/Documentation/media/uapi/dvb/demux.rst
+++ b/Documentation/media/uapi/dvb/demux.rst
@@ -2,10 +2,15 @@
2 2
3.. _dvb_demux: 3.. _dvb_demux:
4 4
5################ 5#######################
6DVB Demux Device 6Digital TV Demux Device
7################ 7#######################
8The DVB demux device controls the filters of the DVB hardware/software. 8
9The Digital TV demux device controls the MPEG-TS filters for the
10digital TV. If the driver and hardware supports, those filters are
11implemented at the hardware. Otherwise, the Kernel provides a software
12emulation.
13
9It can be accessed through ``/dev/adapter?/demux?``. Data types and and 14It can be accessed through ``/dev/adapter?/demux?``. Data types and and
10ioctl definitions can be accessed by including ``linux/dvb/dmx.h`` in 15ioctl definitions can be accessed by including ``linux/dvb/dmx.h`` in
11your application. 16your application.
diff --git a/Documentation/media/uapi/dvb/dmx-add-pid.rst b/Documentation/media/uapi/dvb/dmx-add-pid.rst
index 689cd1fc9142..4d5632dfb43e 100644
--- a/Documentation/media/uapi/dvb/dmx-add-pid.rst
+++ b/Documentation/media/uapi/dvb/dmx-add-pid.rst
@@ -33,13 +33,17 @@ Description
33----------- 33-----------
34 34
35This ioctl call allows to add multiple PIDs to a transport stream filter 35This ioctl call allows to add multiple PIDs to a transport stream filter
36previously set up with DMX_SET_PES_FILTER and output equal to 36previously set up with :ref:`DMX_SET_PES_FILTER` and output equal to
37DMX_OUT_TSDEMUX_TAP. 37:c:type:`DMX_OUT_TSDEMUX_TAP <dmx_output>`.
38 38
39 39
40Return Value 40Return Value
41------------ 41------------
42 42
43On success 0 is returned, on error -1 and the ``errno`` variable is set 43On success 0 is returned.
44appropriately. The generic error codes are described at the 44
45On error -1 is returned, and the ``errno`` variable is set
46appropriately.
47
48Generic error codes are described at the
45:ref:`Generic Error Codes <gen-errors>` chapter. 49:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/dmx-fclose.rst b/Documentation/media/uapi/dvb/dmx-fclose.rst
index ca93c23cde6d..578e929f4bde 100644
--- a/Documentation/media/uapi/dvb/dmx-fclose.rst
+++ b/Documentation/media/uapi/dvb/dmx-fclose.rst
@@ -2,14 +2,14 @@
2 2
3.. _dmx_fclose: 3.. _dmx_fclose:
4 4
5================= 5========================
6DVB demux close() 6Digital TV demux close()
7================= 7========================
8 8
9Name 9Name
10---- 10----
11 11
12DVB demux close() 12Digital TV demux close()
13 13
14 14
15Synopsis 15Synopsis
@@ -23,25 +23,23 @@ Arguments
23--------- 23---------
24 24
25``fd`` 25``fd``
26 File descriptor returned by a previous call to :c:func:`open() <dvb-ca-open>`. 26 File descriptor returned by a previous call to
27 :c:func:`open() <dvb-dmx-open>`.
27 28
28Description 29Description
29----------- 30-----------
30 31
31This system call deactivates and deallocates a filter that was 32This system call deactivates and deallocates a filter that was
32previously allocated via the open() call. 33previously allocated via the :c:func:`open() <dvb-dmx-open>` call.
33 34
34 35
35Return Value 36Return Value
36------------ 37------------
37 38
38.. flat-table:: 39On success 0 is returned.
39 :header-rows: 0
40 :stub-columns: 0
41 40
41On error, -1 is returned and the ``errno`` variable is set
42appropriately.
42 43
43 - .. row 1 44The generic error codes are described at the
44 45:ref:`Generic Error Codes <gen-errors>` chapter.
45 - ``EBADF``
46
47 - fd is not a valid open file descriptor.
diff --git a/Documentation/media/uapi/dvb/dmx-fopen.rst b/Documentation/media/uapi/dvb/dmx-fopen.rst
index a697e33c32ea..55628a18ba67 100644
--- a/Documentation/media/uapi/dvb/dmx-fopen.rst
+++ b/Documentation/media/uapi/dvb/dmx-fopen.rst
@@ -2,14 +2,14 @@
2 2
3.. _dmx_fopen: 3.. _dmx_fopen:
4 4
5================ 5=======================
6DVB demux open() 6Digital TV demux open()
7================ 7=======================
8 8
9Name 9Name
10---- 10----
11 11
12DVB demux open() 12Digital TV demux open()
13 13
14 14
15Synopsis 15Synopsis
@@ -22,25 +22,28 @@ Arguments
22--------- 22---------
23 23
24``name`` 24``name``
25 Name of specific DVB demux device. 25 Name of specific Digital TV demux device.
26 26
27``flags`` 27``flags``
28 A bit-wise OR of the following flags: 28 A bit-wise OR of the following flags:
29 29
30.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
31
30.. flat-table:: 32.. flat-table::
31 :header-rows: 0 33 :header-rows: 0
32 :stub-columns: 0 34 :stub-columns: 0
35 :widths: 1 16
33 36
34 - 37 -
35 - O_RDONLY 38 - ``O_RDONLY``
36 - read-only access 39 - read-only access
37 40
38 - 41 -
39 - O_RDWR 42 - ``O_RDWR``
40 - read/write access 43 - read/write access
41 44
42 - 45 -
43 - O_NONBLOCK 46 - ``O_NONBLOCK``
44 - open in non-blocking mode 47 - open in non-blocking mode
45 (blocking mode is the default) 48 (blocking mode is the default)
46 49
@@ -48,52 +51,41 @@ Arguments
48Description 51Description
49----------- 52-----------
50 53
51This system call, used with a device name of /dev/dvb/adapter0/demux0, 54This system call, used with a device name of ``/dev/dvb/adapter?/demux?``,
52allocates a new filter and returns a handle which can be used for 55allocates a new filter and returns a handle which can be used for
53subsequent control of that filter. This call has to be made for each 56subsequent control of that filter. This call has to be made for each
54filter to be used, i.e. every returned file descriptor is a reference to 57filter to be used, i.e. every returned file descriptor is a reference to
55a single filter. /dev/dvb/adapter0/dvr0 is a logical device to be used 58a single filter. ``/dev/dvb/adapter?/dvr?`` is a logical device to be used
56for retrieving Transport Streams for digital video recording. When 59for retrieving Transport Streams for digital video recording. When
57reading from this device a transport stream containing the packets from 60reading from this device a transport stream containing the packets from
58all PES filters set in the corresponding demux device 61all PES filters set in the corresponding demux device
59(/dev/dvb/adapter0/demux0) having the output set to DMX_OUT_TS_TAP. A 62(``/dev/dvb/adapter?/demux?``) having the output set to ``DMX_OUT_TS_TAP``.
60recorded Transport Stream is replayed by writing to this device. 63A recorded Transport Stream is replayed by writing to this device.
61 64
62The significance of blocking or non-blocking mode is described in the 65The significance of blocking or non-blocking mode is described in the
63documentation for functions where there is a difference. It does not 66documentation for functions where there is a difference. It does not
64affect the semantics of the open() call itself. A device opened in 67affect the semantics of the ``open()`` call itself. A device opened
65blocking mode can later be put into non-blocking mode (and vice versa) 68in blocking mode can later be put into non-blocking mode (and vice versa)
66using the F_SETFL command of the fcntl system call. 69using the ``F_SETFL`` command of the fcntl system call.
67 70
68 71
69Return Value 72Return Value
70------------ 73------------
71 74
72.. flat-table:: 75On success 0 is returned.
73 :header-rows: 0
74 :stub-columns: 0
75
76
77 - .. row 1
78
79 - ``ENODEV``
80
81 - Device driver not loaded/available.
82 76
83 - .. row 2 77On error -1 is returned, and the ``errno`` variable is set
78appropriately.
84 79
85 - ``EINVAL`` 80.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
86 81
87 - Invalid argument. 82.. flat-table::
88 83 :header-rows: 0
89 - .. row 3 84 :stub-columns: 0
90 85 :widths: 1 16
91 - ``EMFILE``
92 86
87 - - ``EMFILE``
93 - “Too many open files”, i.e. no more filters available. 88 - “Too many open files”, i.e. no more filters available.
94 89
95 - .. row 4 90The generic error codes are described at the
96 91:ref:`Generic Error Codes <gen-errors>` chapter.
97 - ``ENOMEM``
98
99 - The driver failed to allocate enough memory.
diff --git a/Documentation/media/uapi/dvb/dmx-fread.rst b/Documentation/media/uapi/dvb/dmx-fread.rst
index e8c7f4db353f..488bdc4ba178 100644
--- a/Documentation/media/uapi/dvb/dmx-fread.rst
+++ b/Documentation/media/uapi/dvb/dmx-fread.rst
@@ -2,14 +2,14 @@
2 2
3.. _dmx_fread: 3.. _dmx_fread:
4 4
5================ 5=======================
6DVB demux read() 6Digital TV demux read()
7================ 7=======================
8 8
9Name 9Name
10---- 10----
11 11
12DVB demux read() 12Digital TV demux read()
13 13
14 14
15Synopsis 15Synopsis
@@ -33,62 +33,48 @@ Arguments
33Description 33Description
34----------- 34-----------
35 35
36This system call returns filtered data, which might be section or PES 36This system call returns filtered data, which might be section or Packetized
37data. The filtered data is transferred from the driver’s internal 37Elementary Stream (PES) data. The filtered data is transferred from
38circular buffer to buf. The maximum amount of data to be transferred is 38the driver’s internal circular buffer to ``buf``. The maximum amount of data
39implied by count. 39to be transferred is implied by count.
40
41.. note::
42
43 if a section filter created with
44 :c:type:`DMX_CHECK_CRC <dmx_sct_filter_params>` flag set,
45 data that fails on CRC check will be silently ignored.
46
40 47
41Return Value 48Return Value
42------------ 49------------
43 50
51On success 0 is returned.
52
53On error -1 is returned, and the ``errno`` variable is set
54appropriately.
55
44.. tabularcolumns:: |p{2.5cm}|p{15.0cm}| 56.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
45 57
46.. flat-table:: 58.. flat-table::
47 :header-rows: 0 59 :header-rows: 0
48 :stub-columns: 0 60 :stub-columns: 0
61 :widths: 1 16
49 62
63 - - ``EWOULDBLOCK``
64 - No data to return and ``O_NONBLOCK`` was specified.
50 65
51 - .. row 1 66 - - ``EOVERFLOW``
52
53 - ``EWOULDBLOCK``
54
55 - No data to return and O_NONBLOCK was specified.
56
57 - .. row 2
58
59 - ``EBADF``
60
61 - fd is not a valid open file descriptor.
62
63 - .. row 3
64
65 - ``ECRC``
66
67 - Last section had a CRC error - no data returned. The buffer is
68 flushed.
69
70 - .. row 4
71
72 - ``EOVERFLOW``
73
74 -
75
76 - .. row 5
77
78 -
79 - The filtered data was not read from the buffer in due time, 67 - The filtered data was not read from the buffer in due time,
80 resulting in non-read data being lost. The buffer is flushed. 68 resulting in non-read data being lost. The buffer is flushed.
81 69
82 - .. row 6 70 - - ``ETIMEDOUT``
83 71 - The section was not loaded within the stated timeout period.
84 - ``ETIMEDOUT`` 72 See ioctl :ref:`DMX_SET_FILTER` for how to set a timeout.
85
86 - The section was not loaded within the stated timeout period. See
87 ioctl DMX_SET_FILTER for how to set a timeout.
88 73
89 - .. row 7 74 - - ``EFAULT``
75 - The driver failed to write to the callers buffer due to an
76 invalid \*buf pointer.
90 77
91 - ``EFAULT``
92 78
93 - The driver failed to write to the callers buffer due to an invalid 79The generic error codes are described at the
94 \*buf pointer. 80:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/dmx-fwrite.rst b/Documentation/media/uapi/dvb/dmx-fwrite.rst
index 8a90dfe28307..519e5733e53b 100644
--- a/Documentation/media/uapi/dvb/dmx-fwrite.rst
+++ b/Documentation/media/uapi/dvb/dmx-fwrite.rst
@@ -2,14 +2,14 @@
2 2
3.. _dmx_fwrite: 3.. _dmx_fwrite:
4 4
5================= 5========================
6DVB demux write() 6Digital TV demux write()
7================= 7========================
8 8
9Name 9Name
10---- 10----
11 11
12DVB demux write() 12Digital TV demux write()
13 13
14 14
15Synopsis 15Synopsis
@@ -34,42 +34,39 @@ Description
34----------- 34-----------
35 35
36This system call is only provided by the logical device 36This system call is only provided by the logical device
37/dev/dvb/adapter0/dvr0, associated with the physical demux device that 37``/dev/dvb/adapter?/dvr?``, associated with the physical demux device that
38provides the actual DVR functionality. It is used for replay of a 38provides the actual DVR functionality. It is used for replay of a
39digitally recorded Transport Stream. Matching filters have to be defined 39digitally recorded Transport Stream. Matching filters have to be defined
40in the corresponding physical demux device, /dev/dvb/adapter0/demux0. 40in the corresponding physical demux device, ``/dev/dvb/adapter?/demux?``.
41The amount of data to be transferred is implied by count. 41The amount of data to be transferred is implied by count.
42 42
43 43
44Return Value 44Return Value
45------------ 45------------
46 46
47On success 0 is returned.
48
49On error -1 is returned, and the ``errno`` variable is set
50appropriately.
51
47.. tabularcolumns:: |p{2.5cm}|p{15.0cm}| 52.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
48 53
49.. flat-table:: 54.. flat-table::
50 :header-rows: 0 55 :header-rows: 0
51 :stub-columns: 0 56 :stub-columns: 0
57 :widths: 1 16
52 58
53 - .. row 1 59 - - ``EWOULDBLOCK``
54 60 - No data was written. This might happen if ``O_NONBLOCK`` was
55 - ``EWOULDBLOCK``
56
57 - No data was written. This might happen if O_NONBLOCK was
58 specified and there is no more buffer space available (if 61 specified and there is no more buffer space available (if
59 O_NONBLOCK is not specified the function will block until buffer 62 ``O_NONBLOCK`` is not specified the function will block until buffer
60 space is available). 63 space is available).
61 64
62 - .. row 2 65 - - ``EBUSY``
63
64 - ``EBUSY``
65
66 - This error code indicates that there are conflicting requests. The 66 - This error code indicates that there are conflicting requests. The
67 corresponding demux device is setup to receive data from the 67 corresponding demux device is setup to receive data from the
68 front- end. Make sure that these filters are stopped and that the 68 front- end. Make sure that these filters are stopped and that the
69 filters with input set to DMX_IN_DVR are started. 69 filters with input set to ``DMX_IN_DVR`` are started.
70
71 - .. row 3
72
73 - ``EBADF``
74 70
75 - fd is not a valid open file descriptor. 71The generic error codes are described at the
72:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/dmx-get-caps.rst b/Documentation/media/uapi/dvb/dmx-get-caps.rst
deleted file mode 100644
index 145fb520d779..000000000000
--- a/Documentation/media/uapi/dvb/dmx-get-caps.rst
+++ /dev/null
@@ -1,41 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _DMX_GET_CAPS:
4
5============
6DMX_GET_CAPS
7============
8
9Name
10----
11
12DMX_GET_CAPS
13
14
15Synopsis
16--------
17
18.. c:function:: int ioctl(fd, DMX_GET_CAPS, struct dmx_caps *caps)
19 :name: DMX_GET_CAPS
20
21Arguments
22---------
23
24``fd``
25 File descriptor returned by :c:func:`open() <dvb-dmx-open>`.
26
27``caps``
28 Pointer to struct :c:type:`dmx_caps`
29
30
31Description
32-----------
33
34.. note:: This ioctl is undocumented. Documentation is welcome.
35
36Return Value
37------------
38
39On success 0 is returned, on error -1 and the ``errno`` variable is set
40appropriately. The generic error codes are described at the
41:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/dmx-get-event.rst b/Documentation/media/uapi/dvb/dmx-get-event.rst
deleted file mode 100644
index 8be626c29158..000000000000
--- a/Documentation/media/uapi/dvb/dmx-get-event.rst
+++ /dev/null
@@ -1,60 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _DMX_GET_EVENT:
4
5=============
6DMX_GET_EVENT
7=============
8
9Name
10----
11
12DMX_GET_EVENT
13
14
15Synopsis
16--------
17
18.. c:function:: int ioctl( int fd, DMX_GET_EVENT, struct dmx_event *ev)
19 :name: DMX_GET_EVENT
20
21
22Arguments
23---------
24
25``fd``
26 File descriptor returned by :c:func:`open() <dvb-dmx-open>`.
27
28``ev``
29 Pointer to the location where the event is to be stored.
30
31
32Description
33-----------
34
35This ioctl call returns an event if available. If an event is not
36available, the behavior depends on whether the device is in blocking or
37non-blocking mode. In the latter case, the call fails immediately with
38errno set to ``EWOULDBLOCK``. In the former case, the call blocks until an
39event becomes available.
40
41
42Return Value
43------------
44
45On success 0 is returned, on error -1 and the ``errno`` variable is set
46appropriately. The generic error codes are described at the
47:ref:`Generic Error Codes <gen-errors>` chapter.
48
49
50
51.. flat-table::
52 :header-rows: 0
53 :stub-columns: 0
54
55
56 - .. row 1
57
58 - ``EWOULDBLOCK``
59
60 - There is no event pending, and the device is in non-blocking mode.
diff --git a/Documentation/media/uapi/dvb/dmx-get-pes-pids.rst b/Documentation/media/uapi/dvb/dmx-get-pes-pids.rst
index b31634a1cca4..fbdbc12869d1 100644
--- a/Documentation/media/uapi/dvb/dmx-get-pes-pids.rst
+++ b/Documentation/media/uapi/dvb/dmx-get-pes-pids.rst
@@ -25,18 +25,40 @@ Arguments
25 File descriptor returned by :c:func:`open() <dvb-dmx-open>`. 25 File descriptor returned by :c:func:`open() <dvb-dmx-open>`.
26 26
27``pids`` 27``pids``
28 Undocumented. 28 Array used to store 5 Program IDs.
29 29
30 30
31Description 31Description
32----------- 32-----------
33 33
34.. note:: This ioctl is undocumented. Documentation is welcome. 34This ioctl allows to query a DVB device to return the first PID used
35by audio, video, textext, subtitle and PCR programs on a given service.
36They're stored as:
37
38======================= ======== =======================================
39PID element position content
40======================= ======== =======================================
41pids[DMX_PES_AUDIO] 0 first audio PID
42pids[DMX_PES_VIDEO] 1 first video PID
43pids[DMX_PES_TELETEXT] 2 first teletext PID
44pids[DMX_PES_SUBTITLE] 3 first subtitle PID
45pids[DMX_PES_PCR] 4 first Program Clock Reference PID
46======================= ======== =======================================
47
48
49.. note::
50
51 A value equal to 0xffff means that the PID was not filled by the
52 Kernel.
35 53
36 54
37Return Value 55Return Value
38------------ 56------------
39 57
40On success 0 is returned, on error -1 and the ``errno`` variable is set 58On success 0 is returned.
41appropriately. The generic error codes are described at the 59
60On error -1 is returned, and the ``errno`` variable is set
61appropriately.
62
63The generic error codes are described at the
42:ref:`Generic Error Codes <gen-errors>` chapter. 64:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/dmx-get-stc.rst b/Documentation/media/uapi/dvb/dmx-get-stc.rst
index 9fc501e8128a..604031f7904b 100644
--- a/Documentation/media/uapi/dvb/dmx-get-stc.rst
+++ b/Documentation/media/uapi/dvb/dmx-get-stc.rst
@@ -25,34 +25,42 @@ Arguments
25 File descriptor returned by :c:func:`open() <dvb-dmx-open>`. 25 File descriptor returned by :c:func:`open() <dvb-dmx-open>`.
26 26
27``stc`` 27``stc``
28 Pointer to the location where the stc is to be stored. 28 Pointer to :c:type:`dmx_stc` where the stc data is to be stored.
29 29
30 30
31Description 31Description
32----------- 32-----------
33 33
34This ioctl call returns the current value of the system time counter 34This ioctl call returns the current value of the system time counter
35(which is driven by a PES filter of type DMX_PES_PCR). Some hardware 35(which is driven by a PES filter of type :c:type:`DMX_PES_PCR <dmx_ts_pes>`).
36supports more than one STC, so you must specify which one by setting the 36Some hardware supports more than one STC, so you must specify which one by
37num field of stc before the ioctl (range 0...n). The result is returned 37setting the :c:type:`num <dmx_stc>` field of stc before the ioctl (range 0...n).
38in form of a ratio with a 64 bit numerator and a 32 bit denominator, so 38The result is returned in form of a ratio with a 64 bit numerator
39the real 90kHz STC value is stc->stc / stc->base . 39and a 32 bit denominator, so the real 90kHz STC value is
40``stc->stc / stc->base``.
40 41
41 42
42Return Value 43Return Value
43------------ 44------------
44 45
45On success 0 is returned, on error -1 and the ``errno`` variable is set 46On success 0 is returned.
46appropriately. The generic error codes are described at the 47
47:ref:`Generic Error Codes <gen-errors>` chapter. 48On error -1 is returned, and the ``errno`` variable is set
49appropriately.
50
51.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
48 52
49.. flat-table:: 53.. flat-table::
50 :header-rows: 0 54 :header-rows: 0
51 :stub-columns: 0 55 :stub-columns: 0
52 56 :widths: 1 16
53 57
54 - .. row 1 58 - .. row 1
55 59
56 - ``EINVAL`` 60 - ``EINVAL``
57 61
58 - Invalid stc number. 62 - Invalid stc number.
63
64
65The generic error codes are described at the
66:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/dmx-remove-pid.rst b/Documentation/media/uapi/dvb/dmx-remove-pid.rst
index e411495c619c..456cc2ded2c0 100644
--- a/Documentation/media/uapi/dvb/dmx-remove-pid.rst
+++ b/Documentation/media/uapi/dvb/dmx-remove-pid.rst
@@ -34,13 +34,17 @@ Description
34 34
35This ioctl call allows to remove a PID when multiple PIDs are set on a 35This ioctl call allows to remove a PID when multiple PIDs are set on a
36transport stream filter, e. g. a filter previously set up with output 36transport stream filter, e. g. a filter previously set up with output
37equal to DMX_OUT_TSDEMUX_TAP, created via either 37equal to :c:type:`DMX_OUT_TSDEMUX_TAP <dmx_output>`, created via either
38DMX_SET_PES_FILTER or DMX_ADD_PID. 38:ref:`DMX_SET_PES_FILTER` or :ref:`DMX_ADD_PID`.
39 39
40 40
41Return Value 41Return Value
42------------ 42------------
43 43
44On success 0 is returned, on error -1 and the ``errno`` variable is set 44On success 0 is returned.
45appropriately. The generic error codes are described at the 45
46On error -1 is returned, and the ``errno`` variable is set
47appropriately.
48
49The generic error codes are described at the
46:ref:`Generic Error Codes <gen-errors>` chapter. 50:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/dmx-set-buffer-size.rst b/Documentation/media/uapi/dvb/dmx-set-buffer-size.rst
index f2f7379f29ed..74fd076a9b90 100644
--- a/Documentation/media/uapi/dvb/dmx-set-buffer-size.rst
+++ b/Documentation/media/uapi/dvb/dmx-set-buffer-size.rst
@@ -33,13 +33,18 @@ Description
33 33
34This ioctl call is used to set the size of the circular buffer used for 34This ioctl call is used to set the size of the circular buffer used for
35filtered data. The default size is two maximum sized sections, i.e. if 35filtered data. The default size is two maximum sized sections, i.e. if
36this function is not called a buffer size of 2 \* 4096 bytes will be 36this function is not called a buffer size of ``2 * 4096`` bytes will be
37used. 37used.
38 38
39 39
40Return Value 40Return Value
41------------ 41------------
42 42
43On success 0 is returned, on error -1 and the ``errno`` variable is set 43
44appropriately. The generic error codes are described at the 44On success 0 is returned.
45
46On error -1 is returned, and the ``errno`` variable is set
47appropriately.
48
49The generic error codes are described at the
45:ref:`Generic Error Codes <gen-errors>` chapter. 50:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/dmx-set-filter.rst b/Documentation/media/uapi/dvb/dmx-set-filter.rst
index 1d50c803d69a..88594b8d3846 100644
--- a/Documentation/media/uapi/dvb/dmx-set-filter.rst
+++ b/Documentation/media/uapi/dvb/dmx-set-filter.rst
@@ -40,13 +40,18 @@ state whether a section should be CRC-checked, whether the filter should
40be a ”one-shot” filter, i.e. if the filtering operation should be 40be a ”one-shot” filter, i.e. if the filtering operation should be
41stopped after the first section is received, and whether the filtering 41stopped after the first section is received, and whether the filtering
42operation should be started immediately (without waiting for a 42operation should be started immediately (without waiting for a
43DMX_START ioctl call). If a filter was previously set-up, this filter 43:ref:`DMX_START` ioctl call). If a filter was previously set-up, this
44will be canceled, and the receive buffer will be flushed. 44filter will be canceled, and the receive buffer will be flushed.
45 45
46 46
47Return Value 47Return Value
48------------ 48------------
49 49
50On success 0 is returned, on error -1 and the ``errno`` variable is set 50
51appropriately. The generic error codes are described at the 51On success 0 is returned.
52
53On error -1 is returned, and the ``errno`` variable is set
54appropriately.
55
56The generic error codes are described at the
52:ref:`Generic Error Codes <gen-errors>` chapter. 57:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/dmx-set-pes-filter.rst b/Documentation/media/uapi/dvb/dmx-set-pes-filter.rst
index 145451d04f7d..d70e7bf96a41 100644
--- a/Documentation/media/uapi/dvb/dmx-set-pes-filter.rst
+++ b/Documentation/media/uapi/dvb/dmx-set-pes-filter.rst
@@ -42,15 +42,17 @@ capability is supported.
42Return Value 42Return Value
43------------ 43------------
44 44
45On success 0 is returned, on error -1 and the ``errno`` variable is set 45On success 0 is returned.
46appropriately. The generic error codes are described at the 46
47:ref:`Generic Error Codes <gen-errors>` chapter. 47On error -1 is returned, and the ``errno`` variable is set
48appropriately.
48 49
49.. tabularcolumns:: |p{2.5cm}|p{15.0cm}| 50.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
50 51
51.. flat-table:: 52.. flat-table::
52 :header-rows: 0 53 :header-rows: 0
53 :stub-columns: 0 54 :stub-columns: 0
55 :widths: 1 16
54 56
55 57
56 - .. row 1 58 - .. row 1
@@ -61,3 +63,7 @@ appropriately. The generic error codes are described at the
61 There are active filters filtering data from another input source. 63 There are active filters filtering data from another input source.
62 Make sure that these filters are stopped before starting this 64 Make sure that these filters are stopped before starting this
63 filter. 65 filter.
66
67
68The generic error codes are described at the
69:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/dmx-set-source.rst b/Documentation/media/uapi/dvb/dmx-set-source.rst
deleted file mode 100644
index ac7f77b25e06..000000000000
--- a/Documentation/media/uapi/dvb/dmx-set-source.rst
+++ /dev/null
@@ -1,44 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _DMX_SET_SOURCE:
4
5==============
6DMX_SET_SOURCE
7==============
8
9Name
10----
11
12DMX_SET_SOURCE
13
14
15Synopsis
16--------
17
18.. c:function:: int ioctl(fd, DMX_SET_SOURCE, struct dmx_source *src)
19 :name: DMX_SET_SOURCE
20
21
22Arguments
23---------
24
25
26``fd``
27 File descriptor returned by :c:func:`open() <dvb-dmx-open>`.
28
29``src``
30 Undocumented.
31
32
33Description
34-----------
35
36.. note:: This ioctl is undocumented. Documentation is welcome.
37
38
39Return Value
40------------
41
42On success 0 is returned, on error -1 and the ``errno`` variable is set
43appropriately. The generic error codes are described at the
44:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/dmx-start.rst b/Documentation/media/uapi/dvb/dmx-start.rst
index 641f3e017fb1..36700e775296 100644
--- a/Documentation/media/uapi/dvb/dmx-start.rst
+++ b/Documentation/media/uapi/dvb/dmx-start.rst
@@ -29,15 +29,16 @@ Description
29----------- 29-----------
30 30
31This ioctl call is used to start the actual filtering operation defined 31This ioctl call is used to start the actual filtering operation defined
32via the ioctl calls DMX_SET_FILTER or DMX_SET_PES_FILTER. 32via the ioctl calls :ref:`DMX_SET_FILTER` or :ref:`DMX_SET_PES_FILTER`.
33 33
34 34
35Return Value 35Return Value
36------------ 36------------
37 37
38On success 0 is returned, on error -1 and the ``errno`` variable is set 38On success 0 is returned.
39appropriately. The generic error codes are described at the 39
40:ref:`Generic Error Codes <gen-errors>` chapter. 40On error -1 is returned, and the ``errno`` variable is set
41appropriately.
41 42
42.. tabularcolumns:: |p{2.5cm}|p{15.0cm}| 43.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
43 44
@@ -51,7 +52,7 @@ appropriately. The generic error codes are described at the
51 - ``EINVAL`` 52 - ``EINVAL``
52 53
53 - Invalid argument, i.e. no filtering parameters provided via the 54 - Invalid argument, i.e. no filtering parameters provided via the
54 DMX_SET_FILTER or DMX_SET_PES_FILTER functions. 55 :ref:`DMX_SET_FILTER` or :ref:`DMX_SET_PES_FILTER` ioctls.
55 56
56 - .. row 2 57 - .. row 2
57 58
@@ -61,3 +62,7 @@ appropriately. The generic error codes are described at the
61 There are active filters filtering data from another input source. 62 There are active filters filtering data from another input source.
62 Make sure that these filters are stopped before starting this 63 Make sure that these filters are stopped before starting this
63 filter. 64 filter.
65
66
67The generic error codes are described at the
68:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/dmx-stop.rst b/Documentation/media/uapi/dvb/dmx-stop.rst
index 569a3df44923..6d9c927bcd5f 100644
--- a/Documentation/media/uapi/dvb/dmx-stop.rst
+++ b/Documentation/media/uapi/dvb/dmx-stop.rst
@@ -29,13 +29,17 @@ Description
29----------- 29-----------
30 30
31This ioctl call is used to stop the actual filtering operation defined 31This ioctl call is used to stop the actual filtering operation defined
32via the ioctl calls DMX_SET_FILTER or DMX_SET_PES_FILTER and 32via the ioctl calls :ref:`DMX_SET_FILTER` or :ref:`DMX_SET_PES_FILTER` and
33started via the DMX_START command. 33started via the :ref:`DMX_START` command.
34 34
35 35
36Return Value 36Return Value
37------------ 37------------
38 38
39On success 0 is returned, on error -1 and the ``errno`` variable is set 39On success 0 is returned.
40appropriately. The generic error codes are described at the 40
41On error -1 is returned, and the ``errno`` variable is set
42appropriately.
43
44The generic error codes are described at the
41:ref:`Generic Error Codes <gen-errors>` chapter. 45:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/dmx_fcalls.rst b/Documentation/media/uapi/dvb/dmx_fcalls.rst
index 77a1554d9834..a17289143220 100644
--- a/Documentation/media/uapi/dvb/dmx_fcalls.rst
+++ b/Documentation/media/uapi/dvb/dmx_fcalls.rst
@@ -18,10 +18,7 @@ Demux Function Calls
18 dmx-set-filter 18 dmx-set-filter
19 dmx-set-pes-filter 19 dmx-set-pes-filter
20 dmx-set-buffer-size 20 dmx-set-buffer-size
21 dmx-get-event
22 dmx-get-stc 21 dmx-get-stc
23 dmx-get-pes-pids 22 dmx-get-pes-pids
24 dmx-get-caps
25 dmx-set-source
26 dmx-add-pid 23 dmx-add-pid
27 dmx-remove-pid 24 dmx-remove-pid
diff --git a/Documentation/media/uapi/dvb/dmx_h.rst b/Documentation/media/uapi/dvb/dmx_h.rst
deleted file mode 100644
index 4fd1704a0833..000000000000
--- a/Documentation/media/uapi/dvb/dmx_h.rst
+++ /dev/null
@@ -1,9 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _dmx_h:
4
5*********************
6DVB Demux Header File
7*********************
8
9.. kernel-include:: $BUILDDIR/dmx.h.rst
diff --git a/Documentation/media/uapi/dvb/dmx_types.rst b/Documentation/media/uapi/dvb/dmx_types.rst
index 80dd659860d7..2a023a4f516c 100644
--- a/Documentation/media/uapi/dvb/dmx_types.rst
+++ b/Documentation/media/uapi/dvb/dmx_types.rst
@@ -6,227 +6,4 @@
6Demux Data Types 6Demux Data Types
7**************** 7****************
8 8
9Output for the demux 9.. kernel-doc:: include/uapi/linux/dvb/dmx.h
10====================
11
12.. c:type:: dmx_output
13
14.. tabularcolumns:: |p{5.0cm}|p{12.5cm}|
15
16.. flat-table:: enum dmx_output
17 :header-rows: 1
18 :stub-columns: 0
19
20
21 - .. row 1
22
23 - ID
24
25 - Description
26
27 - .. row 2
28
29 - .. _DMX-OUT-DECODER:
30
31 DMX_OUT_DECODER
32
33 - Streaming directly to decoder.
34
35 - .. row 3
36
37 - .. _DMX-OUT-TAP:
38
39 DMX_OUT_TAP
40
41 - Output going to a memory buffer (to be retrieved via the read
42 command). Delivers the stream output to the demux device on which
43 the ioctl is called.
44
45 - .. row 4
46
47 - .. _DMX-OUT-TS-TAP:
48
49 DMX_OUT_TS_TAP
50
51 - Output multiplexed into a new TS (to be retrieved by reading from
52 the logical DVR device). Routes output to the logical DVR device
53 ``/dev/dvb/adapter?/dvr?``, which delivers a TS multiplexed from
54 all filters for which ``DMX_OUT_TS_TAP`` was specified.
55
56 - .. row 5
57
58 - .. _DMX-OUT-TSDEMUX-TAP:
59
60 DMX_OUT_TSDEMUX_TAP
61
62 - Like :ref:`DMX_OUT_TS_TAP <DMX-OUT-TS-TAP>` but retrieved
63 from the DMX device.
64
65
66dmx_input_t
67===========
68
69.. c:type:: dmx_input
70
71.. code-block:: c
72
73 typedef enum
74 {
75 DMX_IN_FRONTEND, /* Input from a front-end device. */
76 DMX_IN_DVR /* Input from the logical DVR device. */
77 } dmx_input_t;
78
79
80dmx_pes_type_t
81==============
82
83.. c:type:: dmx_pes_type
84
85
86.. code-block:: c
87
88 typedef enum
89 {
90 DMX_PES_AUDIO0,
91 DMX_PES_VIDEO0,
92 DMX_PES_TELETEXT0,
93 DMX_PES_SUBTITLE0,
94 DMX_PES_PCR0,
95
96 DMX_PES_AUDIO1,
97 DMX_PES_VIDEO1,
98 DMX_PES_TELETEXT1,
99 DMX_PES_SUBTITLE1,
100 DMX_PES_PCR1,
101
102 DMX_PES_AUDIO2,
103 DMX_PES_VIDEO2,
104 DMX_PES_TELETEXT2,
105 DMX_PES_SUBTITLE2,
106 DMX_PES_PCR2,
107
108 DMX_PES_AUDIO3,
109 DMX_PES_VIDEO3,
110 DMX_PES_TELETEXT3,
111 DMX_PES_SUBTITLE3,
112 DMX_PES_PCR3,
113
114 DMX_PES_OTHER
115 } dmx_pes_type_t;
116
117
118struct dmx_filter
119=================
120
121.. c:type:: dmx_filter
122
123.. code-block:: c
124
125 typedef struct dmx_filter
126 {
127 __u8 filter[DMX_FILTER_SIZE];
128 __u8 mask[DMX_FILTER_SIZE];
129 __u8 mode[DMX_FILTER_SIZE];
130 } dmx_filter_t;
131
132
133.. c:type:: dmx_sct_filter_params
134
135struct dmx_sct_filter_params
136============================
137
138
139.. code-block:: c
140
141 struct dmx_sct_filter_params
142 {
143 __u16 pid;
144 dmx_filter_t filter;
145 __u32 timeout;
146 __u32 flags;
147 #define DMX_CHECK_CRC 1
148 #define DMX_ONESHOT 2
149 #define DMX_IMMEDIATE_START 4
150 #define DMX_KERNEL_CLIENT 0x8000
151 };
152
153
154struct dmx_pes_filter_params
155============================
156
157.. c:type:: dmx_pes_filter_params
158
159.. code-block:: c
160
161 struct dmx_pes_filter_params
162 {
163 __u16 pid;
164 dmx_input_t input;
165 dmx_output_t output;
166 dmx_pes_type_t pes_type;
167 __u32 flags;
168 };
169
170
171struct dmx_event
172================
173
174.. c:type:: dmx_event
175
176.. code-block:: c
177
178 struct dmx_event
179 {
180 dmx_event_t event;
181 time_t timeStamp;
182 union
183 {
184 dmx_scrambling_status_t scrambling;
185 } u;
186 };
187
188
189struct dmx_stc
190==============
191
192.. c:type:: dmx_stc
193
194.. code-block:: c
195
196 struct dmx_stc {
197 unsigned int num; /* input : which STC? 0..N */
198 unsigned int base; /* output: divisor for stc to get 90 kHz clock */
199 __u64 stc; /* output: stc in 'base'*90 kHz units */
200 };
201
202
203struct dmx_caps
204===============
205
206.. c:type:: dmx_caps
207
208.. code-block:: c
209
210 typedef struct dmx_caps {
211 __u32 caps;
212 int num_decoders;
213 } dmx_caps_t;
214
215
216enum dmx_source
217===============
218
219.. c:type:: dmx_source
220
221.. code-block:: c
222
223 typedef enum dmx_source {
224 DMX_SOURCE_FRONT0 = 0,
225 DMX_SOURCE_FRONT1,
226 DMX_SOURCE_FRONT2,
227 DMX_SOURCE_FRONT3,
228 DMX_SOURCE_DVR0 = 16,
229 DMX_SOURCE_DVR1,
230 DMX_SOURCE_DVR2,
231 DMX_SOURCE_DVR3
232 } dmx_source_t;
diff --git a/Documentation/media/uapi/dvb/dtv-fe-stats.rst b/Documentation/media/uapi/dvb/dtv-fe-stats.rst
deleted file mode 100644
index e8a02a1f138d..000000000000
--- a/Documentation/media/uapi/dvb/dtv-fe-stats.rst
+++ /dev/null
@@ -1,17 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. c:type:: dtv_fe_stats
4
5*******************
6struct dtv_fe_stats
7*******************
8
9
10.. code-block:: c
11
12 #define MAX_DTV_STATS 4
13
14 struct dtv_fe_stats {
15 __u8 len;
16 struct dtv_stats stat[MAX_DTV_STATS];
17 } __packed;
diff --git a/Documentation/media/uapi/dvb/dtv-properties.rst b/Documentation/media/uapi/dvb/dtv-properties.rst
deleted file mode 100644
index 48c4e834ad11..000000000000
--- a/Documentation/media/uapi/dvb/dtv-properties.rst
+++ /dev/null
@@ -1,15 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. c:type:: dtv_properties
4
5*********************
6struct dtv_properties
7*********************
8
9
10.. code-block:: c
11
12 struct dtv_properties {
13 __u32 num;
14 struct dtv_property *props;
15 };
diff --git a/Documentation/media/uapi/dvb/dtv-property.rst b/Documentation/media/uapi/dvb/dtv-property.rst
deleted file mode 100644
index 3ddc3474b00e..000000000000
--- a/Documentation/media/uapi/dvb/dtv-property.rst
+++ /dev/null
@@ -1,31 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. c:type:: dtv_property
4
5*******************
6struct dtv_property
7*******************
8
9
10.. code-block:: c
11
12 /* Reserved fields should be set to 0 */
13
14 struct dtv_property {
15 __u32 cmd;
16 __u32 reserved[3];
17 union {
18 __u32 data;
19 struct dtv_fe_stats st;
20 struct {
21 __u8 data[32];
22 __u32 len;
23 __u32 reserved1[3];
24 void *reserved2;
25 } buffer;
26 } u;
27 int result;
28 } __attribute__ ((packed));
29
30 /* num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl */
31 #define DTV_IOCTL_MAX_MSGS 64
diff --git a/Documentation/media/uapi/dvb/dtv-stats.rst b/Documentation/media/uapi/dvb/dtv-stats.rst
deleted file mode 100644
index 35239e72bf74..000000000000
--- a/Documentation/media/uapi/dvb/dtv-stats.rst
+++ /dev/null
@@ -1,18 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. c:type:: dtv_stats
4
5****************
6struct dtv_stats
7****************
8
9
10.. code-block:: c
11
12 struct dtv_stats {
13 __u8 scale; /* enum fecap_scale_params type */
14 union {
15 __u64 uvalue; /* for counters and relative scales */
16 __s64 svalue; /* for 1/1000 dB measures */
17 };
18 } __packed;
diff --git a/Documentation/media/uapi/dvb/dvb-fe-read-status.rst b/Documentation/media/uapi/dvb/dvb-fe-read-status.rst
index 76c20612b274..212f032cad8b 100644
--- a/Documentation/media/uapi/dvb/dvb-fe-read-status.rst
+++ b/Documentation/media/uapi/dvb/dvb-fe-read-status.rst
@@ -20,6 +20,6 @@ Signal statistics are provided via
20.. note:: 20.. note::
21 21
22 Most statistics require the demodulator to be fully locked 22 Most statistics require the demodulator to be fully locked
23 (e. g. with FE_HAS_LOCK bit set). See 23 (e. g. with :c:type:`FE_HAS_LOCK <fe_status>` bit set). See
24 :ref:`Frontend statistics indicators <frontend-stat-properties>` for 24 :ref:`Frontend statistics indicators <frontend-stat-properties>` for
25 more details. 25 more details.
diff --git a/Documentation/media/uapi/dvb/dvb-frontend-parameters.rst b/Documentation/media/uapi/dvb/dvb-frontend-parameters.rst
index 899fd5c3545e..b152166f8fa7 100644
--- a/Documentation/media/uapi/dvb/dvb-frontend-parameters.rst
+++ b/Documentation/media/uapi/dvb/dvb-frontend-parameters.rst
@@ -24,7 +24,7 @@ instead, in order to be able to support the newer System Delivery like
24DVB-S2, DVB-T2, DVB-C2, ISDB, etc. 24DVB-S2, DVB-T2, DVB-C2, ISDB, etc.
25 25
26All kinds of parameters are combined as a union in the 26All kinds of parameters are combined as a union in the
27FrontendParameters structure: 27``dvb_frontend_parameters`` structure:
28 28
29 29
30.. code-block:: c 30.. code-block:: c
diff --git a/Documentation/media/uapi/dvb/dvbapi.rst b/Documentation/media/uapi/dvb/dvbapi.rst
index 37680137e3f2..18c86b3a3af1 100644
--- a/Documentation/media/uapi/dvb/dvbapi.rst
+++ b/Documentation/media/uapi/dvb/dvbapi.rst
@@ -10,12 +10,27 @@ Part II - Digital TV API
10 10
11.. note:: 11.. note::
12 12
13 This API is also known as **DVB API**, although it is generic 13 This API is also known as Linux **DVB API**.
14 enough to support all digital TV standards. 14
15 It it was originally written to support the European digital TV
16 standard (DVB), and later extended to support all digital TV standards.
17
18 In order to avoid confusion, within this document, it was opted to refer to
19 it, and to associated hardware as **Digital TV**.
20
21 The word **DVB** is reserved to be used for:
22
23 - the Digital TV API version
24 (e. g. DVB API version 3 or DVB API version 5);
25 - digital TV data types (enums, structs, defines, etc);
26 - digital TV device nodes (``/dev/dvb/...``);
27 - the European DVB standard.
15 28
16**Version 5.10** 29**Version 5.10**
17 30
18.. class:: toc-title 31.. only:: html
32
33 .. class:: toc-title
19 34
20 Table of Contents 35 Table of Contents
21 36
@@ -30,12 +45,7 @@ Part II - Digital TV API
30 net 45 net
31 legacy_dvb_apis 46 legacy_dvb_apis
32 examples 47 examples
33 audio_h 48 headers
34 ca_h
35 dmx_h
36 frontend_h
37 net_h
38 video_h
39 49
40 50
41********************** 51**********************
@@ -46,11 +56,11 @@ Authors:
46 56
47- J. K. Metzler, Ralph <rjkm@metzlerbros.de> 57- J. K. Metzler, Ralph <rjkm@metzlerbros.de>
48 58
49 - Original author of the DVB API documentation. 59 - Original author of the Digital TV API documentation.
50 60
51- O. C. Metzler, Marcus <rjkm@metzlerbros.de> 61- O. C. Metzler, Marcus <rjkm@metzlerbros.de>
52 62
53 - Original author of the DVB API documentation. 63 - Original author of the Digital TV API documentation.
54 64
55- Carvalho Chehab, Mauro <m.chehab@kernel.org> 65- Carvalho Chehab, Mauro <m.chehab@kernel.org>
56 66
@@ -58,21 +68,26 @@ Authors:
58 68
59**Copyright** |copy| 2002-2003 : Convergence GmbH 69**Copyright** |copy| 2002-2003 : Convergence GmbH
60 70
61**Copyright** |copy| 2009-2016 : Mauro Carvalho Chehab 71**Copyright** |copy| 2009-2017 : Mauro Carvalho Chehab
62 72
63**************** 73****************
64Revision History 74Revision History
65**************** 75****************
66 76
77:revision: 2.2.0 / 2017-09-01 (*mcc*)
78
79Most gaps between the uAPI document and the Kernel implementation
80got fixed for the non-legacy API.
81
67:revision: 2.1.0 / 2015-05-29 (*mcc*) 82:revision: 2.1.0 / 2015-05-29 (*mcc*)
68 83
69DocBook improvements and cleanups, in order to document the system calls 84DocBook improvements and cleanups, in order to document the system calls
70on a more standard way and provide more description about the current 85on a more standard way and provide more description about the current
71DVB API. 86Digital TV API.
72 87
73:revision: 2.0.4 / 2011-05-06 (*mcc*) 88:revision: 2.0.4 / 2011-05-06 (*mcc*)
74 89
75Add more information about DVB APIv5, better describing the frontend 90Add more information about DVBv5 API, better describing the frontend
76GET/SET props ioctl's. 91GET/SET props ioctl's.
77 92
78 93
diff --git a/Documentation/media/uapi/dvb/dvbproperty-006.rst b/Documentation/media/uapi/dvb/dvbproperty-006.rst
deleted file mode 100644
index 3343a0f306fe..000000000000
--- a/Documentation/media/uapi/dvb/dvbproperty-006.rst
+++ /dev/null
@@ -1,12 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3**************
4Property types
5**************
6
7On :ref:`FE_GET_PROPERTY and FE_SET_PROPERTY <FE_GET_PROPERTY>`,
8the actual action is determined by the dtv_property cmd/data pairs.
9With one single ioctl, is possible to get/set up to 64 properties. The
10actual meaning of each property is described on the next sections.
11
12The available frontend property types are shown on the next section.
diff --git a/Documentation/media/uapi/dvb/dvbproperty.rst b/Documentation/media/uapi/dvb/dvbproperty.rst
index dd2d71ce43fa..1a56c1724e59 100644
--- a/Documentation/media/uapi/dvb/dvbproperty.rst
+++ b/Documentation/media/uapi/dvb/dvbproperty.rst
@@ -2,63 +2,76 @@
2 2
3.. _frontend-properties: 3.. _frontend-properties:
4 4
5DVB Frontend properties 5**************
6======================= 6Property types
7**************
7 8
8Tuning into a Digital TV physical channel and starting decoding it 9Tuning into a Digital TV physical channel and starting decoding it
9requires changing a set of parameters, in order to control the tuner, 10requires changing a set of parameters, in order to control the tuner,
10the demodulator, the Linear Low-noise Amplifier (LNA) and to set the 11the demodulator, the Linear Low-noise Amplifier (LNA) and to set the
11antenna subsystem via Satellite Equipment Control (SEC), on satellite 12antenna subsystem via Satellite Equipment Control - SEC (on satellite
12systems. The actual parameters are specific to each particular digital 13systems). The actual parameters are specific to each particular digital
13TV standards, and may change as the digital TV specs evolves. 14TV standards, and may change as the digital TV specs evolves.
14 15
15In the past, the strategy used was to have a union with the parameters 16In the past (up to DVB API version 3 - DVBv3), the strategy used was to have a
16needed to tune for DVB-S, DVB-C, DVB-T and ATSC delivery systems grouped 17union with the parameters needed to tune for DVB-S, DVB-C, DVB-T and
17there. The problem is that, as the second generation standards appeared, 18ATSC delivery systems grouped there. The problem is that, as the second
18those structs were not big enough to contain the additional parameters. 19generation standards appeared, the size of such union was not big
19Also, the union didn't have any space left to be expanded without 20enough to group the structs that would be required for those new
20breaking userspace. So, the decision was to deprecate the legacy 21standards. Also, extending it would break userspace.
21union/struct based approach, in favor of a properties set approach. 22
23So, the legacy union/struct based approach was deprecated, in favor
24of a properties set approach. On such approach,
25:ref:`FE_GET_PROPERTY and FE_SET_PROPERTY <FE_GET_PROPERTY>` are used
26to setup the frontend and read its status.
27
28The actual action is determined by a set of dtv_property cmd/data pairs.
29With one single ioctl, is possible to get/set up to 64 properties.
30
31This section describes the new and recommended way to set the frontend,
32with supports all digital TV delivery systems.
22 33
23.. note:: 34.. note::
24 35
25 On Linux DVB API version 3, setting a frontend were done via 36 1. On Linux DVB API version 3, setting a frontend was done via
26 struct :c:type:`dvb_frontend_parameters`. 37 struct :c:type:`dvb_frontend_parameters`.
27 This got replaced on version 5 (also called "S2API", as this API were 38
28 added originally_enabled to provide support for DVB-S2), because the 39 2. Don't use DVB API version 3 calls on hardware with supports
29 old API has a very limited support to new standards and new hardware. 40 newer standards. Such API provides no suport or a very limited
30 This section describes the new and recommended way to set the frontend, 41 support to new standards and/or new hardware.
31 with suppports all digital TV delivery systems. 42
32 43 3. Nowadays, most frontends support multiple delivery systems.
33Example: with the properties based approach, in order to set the tuner 44 Only with DVB API version 5 calls it is possible to switch between
34to a DVB-C channel at 651 kHz, modulated with 256-QAM, FEC 3/4 and 45 the multiple delivery systems supported by a frontend.
35symbol rate of 5.217 Mbauds, those properties should be sent to 46
47 4. DVB API version 5 is also called *S2API*, as the first
48 new standard added to it was DVB-S2.
49
50**Example**: in order to set the hardware to tune into a DVB-C channel
51at 651 kHz, modulated with 256-QAM, FEC 3/4 and symbol rate of 5.217
52Mbauds, those properties should be sent to
36:ref:`FE_SET_PROPERTY <FE_GET_PROPERTY>` ioctl: 53:ref:`FE_SET_PROPERTY <FE_GET_PROPERTY>` ioctl:
37 54
38- :ref:`DTV_DELIVERY_SYSTEM <DTV-DELIVERY-SYSTEM>` = 55 :ref:`DTV_DELIVERY_SYSTEM <DTV-DELIVERY-SYSTEM>` = SYS_DVBC_ANNEX_A
39 SYS_DVBC_ANNEX_A
40 56
41- :ref:`DTV_FREQUENCY <DTV-FREQUENCY>` = 651000000 57 :ref:`DTV_FREQUENCY <DTV-FREQUENCY>` = 651000000
42 58
43- :ref:`DTV_MODULATION <DTV-MODULATION>` = QAM_256 59 :ref:`DTV_MODULATION <DTV-MODULATION>` = QAM_256
44 60
45- :ref:`DTV_INVERSION <DTV-INVERSION>` = INVERSION_AUTO 61 :ref:`DTV_INVERSION <DTV-INVERSION>` = INVERSION_AUTO
46 62
47- :ref:`DTV_SYMBOL_RATE <DTV-SYMBOL-RATE>` = 5217000 63 :ref:`DTV_SYMBOL_RATE <DTV-SYMBOL-RATE>` = 5217000
48 64
49- :ref:`DTV_INNER_FEC <DTV-INNER-FEC>` = FEC_3_4 65 :ref:`DTV_INNER_FEC <DTV-INNER-FEC>` = FEC_3_4
50 66
51- :ref:`DTV_TUNE <DTV-TUNE>` 67 :ref:`DTV_TUNE <DTV-TUNE>`
52 68
53The code that would that would do the above is show in 69The code that would that would do the above is show in
54:ref:`dtv-prop-example`. 70:ref:`dtv-prop-example`.
55 71
56.. _dtv-prop-example:
57
58Example: Setting digital TV frontend properties
59===============================================
60
61.. code-block:: c 72.. code-block:: c
73 :caption: Example: Setting digital TV frontend properties
74 :name: dtv-prop-example
62 75
63 #include <stdio.h> 76 #include <stdio.h>
64 #include <fcntl.h> 77 #include <fcntl.h>
@@ -102,17 +115,12 @@ Example: Setting digital TV frontend properties
102 provides methods for usual operations like program scanning and to 115 provides methods for usual operations like program scanning and to
103 read/write channel descriptor files. 116 read/write channel descriptor files.
104 117
105
106.. toctree:: 118.. toctree::
107 :maxdepth: 1 119 :maxdepth: 1
108 120
109 dtv-stats
110 dtv-fe-stats
111 dtv-property
112 dtv-properties
113 dvbproperty-006
114 fe_property_parameters 121 fe_property_parameters
115 frontend-stat-properties 122 frontend-stat-properties
116 frontend-property-terrestrial-systems 123 frontend-property-terrestrial-systems
117 frontend-property-cable-systems 124 frontend-property-cable-systems
118 frontend-property-satellite-systems 125 frontend-property-satellite-systems
126 frontend-header
diff --git a/Documentation/media/uapi/dvb/dvbstb.svg b/Documentation/media/uapi/dvb/dvbstb.svg
index 4effe45b448d..f6fe2f837373 100644
--- a/Documentation/media/uapi/dvb/dvbstb.svg
+++ b/Documentation/media/uapi/dvb/dvbstb.svg
@@ -1,17 +1,16 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<svg id="svg2" width="237.7mm" height="126.28mm" fill-rule="evenodd" stroke-linejoin="round" stroke-width="28.222" preserveAspectRatio="xMidYMid" version="1.2" viewBox="0 0 23770.221 12628.221" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><metadata id="metadata519"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/><dc:title/></cc:Work></rdf:RDF></metadata><rect id="rect197" class="BoundingBox" x="5355.1" y="13.111" width="18403" height="9603" fill="none"/><path id="path199" d="m14556 9614.1h-9200v-9600h18400v9600h-9200z" fill="#fff"/><path id="path201" d="m14556 9614.1h-9200v-9600h18400v9600h-9200z" fill="none" stroke="#000"/><rect id="rect206" 2<svg id="svg2" width="15.847cm" height="8.4187cm" fill-rule="evenodd" stroke-linejoin="round" stroke-width="28.222" preserveAspectRatio="xMidYMid" version="1.2" viewBox="0 0 23770.123 12628.122" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><defs id="defs142"><marker id="Arrow1Lend" overflow="visible" orient="auto"><path id="path954" transform="matrix(-.8 0 0 -.8 -10 0)" d="m0 0 5-5-17.5 5 17.5 5z" fill-rule="evenodd" stroke="#000" stroke-width="1pt"/></marker><marker id="marker1243" overflow="visible" orient="auto"><path id="path1241" transform="matrix(-.8 0 0 -.8 -10 0)" d="m0 0 5-5-17.5 5 17.5 5z" fill-rule="evenodd" stroke="#000" stroke-width="1pt"/></marker></defs><metadata id="metadata519"><rdf:RDF><cc:Work
3class="BoundingBox" x="13.111" y="4013.1" width="4544" height="2403" fill="none"/><path id="path208" d="m2285.1 6414.1h-2271v-2400h4541v2400h-2270z" fill="#fff"/><path id="path210" d="m2285.1 6414.1h-2271v-2400h4541v2400h-2270z" fill="none" stroke="#000"/><text id="text212" class="TextShape" x="-2443.8889" y="-4585.8892"><tspan id="tspan214" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan216" class="TextPosition" x="1281.111" y="5435.1108"><tspan id="tspan218" fill="#000000">Antena</tspan></tspan></tspan></text> 3rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/><dc:title/></cc:Work></rdf:RDF></metadata><rect id="rect197" class="BoundingBox" x="5355.1" y="13.122" width="18403" height="9603" fill="none"/><path id="path199" d="m14556 9614.1h-9200v-9600h18400v9600z" fill="#fff"/><path id="path201" d="m14556 9614.1h-9200v-9600h18400v9600z" fill="none" stroke="#000"/><rect id="rect206" class="BoundingBox" x="13.122" y="4013.1" width="4544" height="2403" fill="none"/><path id="path208" d="m2285.1 6414.1h-2271v-2400h4541v2400z" fill="#fff"/><path id="path210" d="m2285.1 6414.1h-2271v-2400h4541v2400z" fill="none" stroke="#000"/><text id="text212" class="TextShape" x="-2443.8779" y="-4585.8779"><tspan id="tspan214" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan216" class="TextPosition"
4<rect id="rect223" class="BoundingBox" x="6213.1" y="1813.1" width="4544" height="2403" fill="none"/><path id="path225" d="m8485.1 4214.1h-2271v-2400h4541v2400h-2270z" fill="#fff"/><path id="path227" d="m8485.1 4214.1h-2271v-2400h4541v2400h-2270z" fill="none" stroke="#000"/><text id="text229" class="TextShape" x="-2443.8889" y="-4585.8892"><tspan id="tspan231" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan233" class="TextPosition" x="7217.1108" y="3235.1111"><tspan id="tspan235" fill="#000000">Frontend</tspan></tspan></tspan></text> 4x="1281.1219" y="5435.1221"><tspan id="tspan218" fill="#000000">Antena</tspan></tspan></tspan></text>
5<rect id="rect240" class="BoundingBox" x="12113" y="1813.1" width="4544" height="2403" fill="none"/><path id="path242" d="m14385 4214.1h-2271v-2400h4541v2400h-2270z" fill="#fff"/><path id="path244" d="m14385 4214.1h-2271v-2400h4541v2400h-2270z" fill="none" stroke="#000"/><text id="text246" class="TextShape" x="-2443.8889" y="-4585.8892"><tspan id="tspan248" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan250" class="TextPosition" x="13944.111" y="3235.1111"><tspan id="tspan252" fill="#000000">CA</tspan></tspan></tspan></text> 5<rect id="rect223" class="BoundingBox" x="6213.1" y="1813.1" width="4544" height="2403" fill="none"/><path id="path225" d="m8485.1 4214.1h-2271v-2400h4541v2400z" fill="#fff"/><path id="path227" d="m8485.1 4214.1h-2271v-2400h4541v2400z" fill="none" stroke="#000"/><text id="text229" class="TextShape" x="-2443.8779" y="-4585.8779"><tspan id="tspan231" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan233" class="TextPosition" x="7217.1221" y="3235.1221"><tspan id="tspan235" fill="#000000">Frontend</tspan></tspan></tspan></text>
6<rect id="rect257" class="BoundingBox" x="18113" y="1813.1" width="4544" height="2403" fill="none"/><path id="path259" d="m20385 4214.1h-2271v-2400h4541v2400h-2270z" fill="#fff"/><path id="path261" d="m20385 4214.1h-2271v-2400h4541v2400h-2270z" fill="none" stroke="#000"/><text id="text263" class="TextShape" x="-2443.8889" y="-4585.8892"><tspan id="tspan265" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan267" class="TextPosition" x="19384.111" y="3235.1111"><tspan id="tspan269" fill="#000000">Demux</tspan></tspan></tspan></text> 6<rect id="rect240" class="BoundingBox" x="12113" y="1813.1" width="4544" height="2403" fill="none"/><path id="path242" d="m14385 4214.1h-2271v-2400h4541v2400z" fill="#fff"/><path id="path244" d="m14385 4214.1h-2271v-2400h4541v2400z" fill="none" stroke="#000"/><text id="text246" class="TextShape" x="-2443.8779" y="-4585.8779"><tspan id="tspan248" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan250" class="TextPosition" x="13944.122" y="3235.1221"><tspan id="tspan252" fill="#000000">CA</tspan></tspan></tspan></text>
7<rect id="rect274" class="BoundingBox" x="6113.1" y="5813.1" width="4544" height="2403" fill="none"/><path id="path276" d="m8385.1 8214.1h-2271v-2400h4541v2400h-2270z" fill="#fff"/><path id="path278" d="m8385.1 8214.1h-2271v-2400h4541v2400h-2270z" fill="none" stroke="#000"/><text id="text280" class="TextShape" x="-2443.8889" y="-4585.8892"><tspan id="tspan282" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan284" class="TextPosition" x="7733.1108" y="7235.1108"><tspan id="tspan286" fill="#000000">SEC</tspan></tspan></tspan></text> 7<rect id="rect257" class="BoundingBox" x="18113" y="1813.1" width="4544" height="2403" fill="none"/><path id="path259" d="m20385 4214.1h-2271v-2400h4541v2400z" fill="#fff"/><path id="path261" d="m20385 4214.1h-2271v-2400h4541v2400z" fill="none" stroke="#000"/><text id="text263" class="TextShape" x="-2443.8779" y="-4585.8779"><tspan id="tspan265" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan267" class="TextPosition" x="19384.123" y="3235.1221"><tspan id="tspan269" fill="#000000">Demux</tspan></tspan></tspan></text>
8<rect id="rect291" class="BoundingBox" x="12213" y="5813.1" width="4544" height="2403" fill="none"/><path id="path293" d="m14485 8214.1h-2271v-2400h4541v2400h-2270z" fill="#fff"/><path id="path295" d="m14485 8214.1h-2271v-2400h4541v2400h-2270z" fill="none" stroke="#000"/><text id="text297" class="TextShape" x="-2443.8889" y="-4585.8892"><tspan id="tspan299" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan301" class="TextPosition" x="13676.111" y="7235.1108"><tspan id="tspan303" fill="#000000">Audio</tspan></tspan></tspan></text> 8<rect id="rect274" class="BoundingBox" x="6113.1" y="5813.1" width="4544" height="2403" fill="none"/><path id="path276" d="m8385.1 8214.1h-2271v-2400h4541v2400z" fill="#fff"/><path id="path278" d="m8385.1 8214.1h-2271v-2400h4541v2400z" fill="none" stroke="#000"/><text id="text280" class="TextShape" x="-2443.8779" y="-4585.8779"><tspan id="tspan282" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan284" class="TextPosition" x="7733.1221" y="7235.1221"><tspan id="tspan286" fill="#000000">SEC</tspan></tspan></tspan></text>
9<rect id="rect308" class="BoundingBox" x="18113" y="5813.1" width="4544" height="2403" fill="none"/><path id="path310" d="m20385 8214.1h-2271v-2400h4541v2400h-2270z" fill="#fff"/><path id="path312" d="m20385 8214.1h-2271v-2400h4541v2400h-2270z" fill="none" stroke="#000"/><text id="text314" class="TextShape" x="-2443.8889" y="-4585.8892"><tspan id="tspan316" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan318" class="TextPosition" x="19583.111" y="7235.1108"><tspan id="tspan320" fill="#000000">Video</tspan></tspan></tspan></text> 9<rect id="rect291" class="BoundingBox" x="12213" y="5813.1" width="4544" height="2403" fill="none"/><path id="path293" d="m14485 8214.1h-2271v-2400h4541v2400z" fill="#fff"/><path id="path295" d="m14485 8214.1h-2271v-2400h4541v2400z" fill="none" stroke="#000" stroke-dasharray="28.22200113,56.44400226" stroke-width="28.222"/><text id="text297" class="TextShape" x="-2443.8779" y="-4903.3779"><tspan id="tspan299" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan301" class="TextPosition" x="13676.122" y="6917.6221"><tspan id="tspan303" fill="#000000">Audio</tspan></tspan></tspan></text>
10<rect id="rect325" class="BoundingBox" x="15213" y="10213" width="4544" height="2403" fill="none"/><path id="path327" d="m17485 12614h-2271v-2400h4541v2400h-2270z" fill="#fff"/><path id="path329" d="m17485 12614h-2271v-2400h4541v2400h-2270z" fill="none" stroke="#000"/><text id="text331" class="TextShape" x="-2443.8889" y="-4585.8892"><tspan id="tspan333" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan335" class="TextPosition" x="17076.111" y="11635.111"><tspan id="tspan337" fill="#000000">TV</tspan></tspan></tspan></text> 10<rect id="rect308" class="BoundingBox" x="18113" y="5813.1" width="4544" height="2403" fill="none"/><path id="path310" d="m20385 8214.1h-2271v-2400h4541v2400z" fill="#fff"/><path id="path312" d="m20385 8214.1h-2271v-2400h4541v2400z" fill="none" stroke="#000" stroke-dasharray="28.22200113,56.44400226" stroke-width="28.222"/><text id="text314" class="TextShape" x="-2443.8779" y="-4903.3779"><tspan id="tspan316" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan318" class="TextPosition" x="19583.123" y="6917.6221"><tspan id="tspan320" fill="#000000">Video</tspan></tspan></tspan></text>
11<rect id="rect342" class="BoundingBox" x="4555.1" y="3014.1" width="1661" height="2202" fill="none"/><path id="path344" d="m4556.1 5214.1 1400-1857" fill="none" stroke="#000"/><path id="path346" d="m6215.1 3014.1-391 269 240 181 151-450z"/><rect id="rect351" class="BoundingBox" x="4555.1" y="5213.1" width="1561" height="1802" fill="none"/><path id="path353" d="m4556.1 5214.1 1277 1475" fill="none" stroke="#000"/><path id="path355" d="m6115.1 7014.1-181-438-227 196 408 242z"/><rect id="rect360" class="BoundingBox" x="10755" y="2864.1" width="1361" height="301" fill="none"/><path id="path362" d="m10756 3014.1h929" fill="none" stroke="#000"/><path id="path364" d="m12115 3014.1-450-150v300l450-150z"/><rect id="rect369" class="BoundingBox" x="16655" y="2864.1" width="1461" height="301" fill="none"/><path id="path371" d="m16656 3014.1h1029" fill="none" stroke="#000"/><path id="path373" 11<rect id="rect325" class="BoundingBox" x="15213" y="10213" width="4544" height="2403" fill="none"/><path id="path327" d="m17485 12614h-2271v-2400h4541v2400z" fill="#fff"/><path id="path329" d="m17485 12614h-2271v-2400h4541v2400z" fill="none" stroke="#000" stroke-dasharray="28.22200113,56.44400226" stroke-width="28.222"/><text id="text331" class="TextShape" x="-2443.8779" y="-4585.8779"><tspan id="tspan333" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400"><tspan id="tspan335" class="TextPosition" x="17076.123" y="11635.122"><tspan id="tspan337" fill="#000000">TV</tspan></tspan></tspan></text>
12d="m18115 3014.1-450-150v300l450-150z"/><rect id="rect378" class="BoundingBox" x="20235" y="4213.1" width="301" height="1602" fill="none"/><path id="path380" d="m20385 4214.1v1170" fill="none" stroke="#000"/><path id="path382" d="m20385 5814.1 150-450h-300l150 450z"/><rect id="rect387" class="BoundingBox" x="17485" y="8213.1" width="2902" height="2002" fill="none"/><path id="path389" d="m20385 8214.1-2546 1756" fill="none" stroke="#000"/><path id="path391" d="m17485 10214 456-132-171-247-285 379z"/><rect id="rect396" class="BoundingBox" x="14484" y="8213.1" width="3002" height="2002" fill="none"/><path id="path398" d="m14485 8214.1 2642 1761" fill="none" stroke="#000"/><path id="path400" d="m17485 10214-291-374-167 249 458 125z"/><rect id="rect405" class="BoundingBox" x="14485" y="4213.1" width="5902" height="1629" fill="none"/><path id="path407" d="m20385 4214.1-51 14" fill="none" 12<rect id="rect342" class="BoundingBox" x="4555.1" y="3014.1" width="1661" height="2202" fill="none"/><path id="path344" d="m4556.1 5214.1 1400-1857" fill="none" stroke="#000"/><path id="path346" d="m6215.1 3014.1-391 269 240 181z"/><rect id="rect351" class="BoundingBox" x="4555.1" y="5213.1" width="1561" height="1802" fill="none"/><path id="path353" d="m4556.1 5214.1 1277 1475" fill="none" stroke="#000"/><path id="path355" d="m6115.1 7014.1-181-438-227 196z"/><rect id="rect360" class="BoundingBox" x="10755" y="2864.1" width="1361" height="301" fill="none"/><path id="path362" d="m10756 3014.1h929" fill="none" stroke="#000"/><path id="path364" d="m12115 3014.1-450-150v300z"/><rect id="rect369" class="BoundingBox" x="16655" y="2864.1" width="1461" height="301" fill="none"/><path id="path371" d="m16656 3014.1h1029" fill="none" stroke="#000"/><path id="path373" d="m18115
13stroke="#000"/><path id="path409" d="m20283 4242.1-52 14" fill="none" stroke="#000"/><path id="path411" d="m20180 4270.1-51 13" fill="none" stroke="#000"/><path id="path413" d="m20078 4297.1-52 14" fill="none" stroke="#000"/><path id="path415" d="m19975 4325.1-51 14" fill="none" stroke="#000"/><path id="path417" d="m19873 4353.1-52 14" fill="none" stroke="#000"/><path id="path419" d="m19770 4381.1-51 14" fill="none" stroke="#000"/><path id="path421" d="m19668 4409.1-52 13" fill="none" stroke="#000"/><path id="path423" d="m19565 4436.1-51 14" fill="none" stroke="#000"/><path id="path425" d="m19463 4464.1-52 14" fill="none" stroke="#000"/><path id="path427" d="m19360 4492.1-51 14" fill="none" stroke="#000"/><path id="path429" d="m19258 4520.1-52 14" fill="none" stroke="#000"/><path id="path431" d="m19155 4547.1-51 14" fill="none" stroke="#000"/><path id="path433" d="m19053 4575.1-52 14" 133014.1-450-150v300z"/><rect id="rect378" class="BoundingBox" x="20235" y="4213.1" width="301" height="1602" fill="none"/><rect id="rect387" class="BoundingBox" x="17485" y="8213.1" width="2902" height="2002" fill="none"/><path id="path389" d="m20385 8214.1-2546 1756" fill="none" stroke="#000" stroke-dasharray="28.22200113,56.44400226" stroke-width="28.222"/><path id="path391" d="m17485 10214 456-132-171-247z"/><rect id="rect396" class="BoundingBox" x="14484" y="8213.1" width="3002" height="2002" fill="none"/><path id="path398" d="m14485 8214.1 2642 1761" fill="none" stroke="#000" stroke-dasharray="28.22200113,56.44400226" stroke-width="28.222"/><path id="path400" d="m17485 10214-291-374-167 249z"/><rect id="rect405" class="BoundingBox" x="14485" y="4213.1" width="5902" height="1629" fill="none"/><path id="path949" d="m20387 4213.1v1629" fill="none" marker-end="url(#Arrow1Lend)"
14fill="none" stroke="#000"/><path id="path435" d="m18950 4603.1-51 14" fill="none" stroke="#000"/><path id="path437" d="m18848 4631.1-51 14" fill="none" stroke="#000"/><path id="path439" d="m18745 4659.1-51 14" fill="none" stroke="#000"/><path id="path441" d="m18643 4686.1-51 14" fill="none" stroke="#000"/><path id="path443" d="m18540 4714.1-51 14" fill="none" stroke="#000"/><path id="path445" d="m18438 4742.1-51 14" fill="none" stroke="#000"/><path id="path447" d="m18335 4770.1-51 14" fill="none" stroke="#000"/><path id="path449" d="m18233 4798.1-51 14" fill="none" stroke="#000"/><path id="path451" d="m18130 4825.1-51 14" fill="none" stroke="#000"/><path id="path453" d="m18028 4853.1-51 14" fill="none" stroke="#000"/><path id="path455" d="m17925 4881.1-51 14" fill="none" stroke="#000"/><path id="path457" d="m17823 4909.1-51 14" fill="none" stroke="#000"/><path id="path459" d="m17720 14stroke="#000" stroke-dasharray="26.45879596, 52.91759192999999328" stroke-linejoin="miter" stroke-width="26.459"/><path id="path1233" d="m20385 4214.1-3628 1599" fill="none" marker-end="url(#marker1243)" stroke="#000" stroke-dasharray="26.45879596, 52.91759193" stroke-linejoin="miter" stroke-width="26.459"/><text id="text297-3" class="TextShape" x="-2911.9202" y="-4257.2061" font-size="12px" stroke-width="1"><tspan id="tspan299-6" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400" stroke-width="1"><tspan id="tspan301-7" class="TextPosition" x="13208.079" y="7563.793" stroke-width="1"><tspan id="tspan303-5" fill="#000000" stroke-width="1">Decoder</tspan></tspan></tspan></text>
154937.1-51 13" fill="none" stroke="#000"/><path id="path461" d="m17618 4964.1-51 14" fill="none" stroke="#000"/><path id="path463" d="m17516 4992.1-52 14" fill="none" stroke="#000"/><path id="path465" d="m17413 5020.1-51 14" fill="none" stroke="#000"/><path id="path467" d="m17311 5048.1-52 14" fill="none" stroke="#000"/><path id="path469" d="m17208 5076.1-51 13" fill="none" stroke="#000"/><path id="path471" d="m17106 5103.1-52 14" fill="none" stroke="#000"/><path id="path473" d="m17003 5131.1-51 14" fill="none" stroke="#000"/><path id="path475" d="m16901 5159.1-52 14" fill="none" stroke="#000"/><path id="path477" d="m16798 5187.1-51 14" fill="none" stroke="#000"/><path id="path479" d="m16696 5214.1-52 14" fill="none" stroke="#000"/><path id="path481" d="m16593 5242.1-51 14" fill="none" stroke="#000"/><path id="path483" d="m16491 5270.1-52 14" fill="none" stroke="#000"/><path id="path485" 15<text id="text297-3-3" class="TextShape" x="2950.9287" y="-4259.5928" font-size="12px" stroke-width="1"><tspan id="tspan299-6-5" class="TextParagraph" font-family="sans-serif" font-size="635px" font-weight="400" stroke-width="1"><tspan id="tspan301-7-6" class="TextPosition" x="19070.928" y="7561.4053" stroke-width="1"><tspan id="tspan303-5-2" fill="#000000" stroke-width="1">Decoder</tspan></tspan></tspan></text>
16d="m16388 5298.1-51 14" fill="none" stroke="#000"/><path id="path487" d="m16286 5326.1-52 14" fill="none" stroke="#000"/><path id="path489" d="m16183 5353.1-51 14" fill="none" stroke="#000"/><path id="path491" d="m16081 5381.1-51 14" fill="none" stroke="#000"/><path id="path493" d="m15978 5409.1-51 14" fill="none" stroke="#000"/><path id="path495" d="m15876 5437.1-51 14" fill="none" stroke="#000"/><path id="path497" d="m15773 5465.1-51 14" fill="none" stroke="#000"/><path id="path499" d="m15671 5492.1-51 14" fill="none" stroke="#000"/><path id="path501" d="m15568 5520.1-51 14" fill="none" stroke="#000"/><path id="path503" d="m15466 5548.1-51 14" fill="none" stroke="#000"/><path id="path505" d="m15363 5576.1-51 14" fill="none" stroke="#000"/><path id="path507" d="m15261 5604.1-51 13" fill="none" stroke="#000"/><path id="path509" d="m15158 5631.1-51 14" fill="none" stroke="#000"/><path 16</svg>
17id="path511" d="m15056 5659.1-51 14" fill="none" stroke="#000"/><path id="path513" d="m14953 5687.1-51 14" fill="none" stroke="#000"/><path id="path515" d="m14485 5814.1 474 27-79-290-395 263z"/></svg>
diff --git a/Documentation/media/uapi/dvb/examples.rst b/Documentation/media/uapi/dvb/examples.rst
index 1a94966312c0..e0f627ca2e4d 100644
--- a/Documentation/media/uapi/dvb/examples.rst
+++ b/Documentation/media/uapi/dvb/examples.rst
@@ -6,8 +6,8 @@
6Examples 6Examples
7******** 7********
8 8
9In this section we would like to present some examples for using the DVB 9In this section we would like to present some examples for using the Digital
10API. 10TV API.
11 11
12.. note:: 12.. note::
13 13
diff --git a/Documentation/media/uapi/dvb/fe-diseqc-recv-slave-reply.rst b/Documentation/media/uapi/dvb/fe-diseqc-recv-slave-reply.rst
index 302db2857f90..f220ee351e15 100644
--- a/Documentation/media/uapi/dvb/fe-diseqc-recv-slave-reply.rst
+++ b/Documentation/media/uapi/dvb/fe-diseqc-recv-slave-reply.rst
@@ -26,8 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <frontend_f_open>`. 26 File descriptor returned by :ref:`open() <frontend_f_open>`.
27 27
28``argp`` 28``argp``
29 pointer to struct 29 pointer to struct :c:type:`dvb_diseqc_slave_reply`.
30 :c:type:`dvb_diseqc_slave_reply`
31 30
32 31
33Description 32Description
@@ -35,46 +34,15 @@ Description
35 34
36Receives reply from a DiSEqC 2.0 command. 35Receives reply from a DiSEqC 2.0 command.
37 36
38.. c:type:: dvb_diseqc_slave_reply 37The received message is stored at the buffer pointed by ``argp``.
39
40.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
41
42.. flat-table:: struct dvb_diseqc_slave_reply
43 :header-rows: 0
44 :stub-columns: 0
45 :widths: 1 1 2
46
47
48 - .. row 1
49
50 - uint8_t
51
52 - msg[4]
53
54 - DiSEqC message (framing, data[3])
55
56 - .. row 2
57
58 - uint8_t
59
60 - msg_len
61
62 - Length of the DiSEqC message. Valid values are 0 to 4, where 0
63 means no msg
64
65 - .. row 3
66
67 - int
68
69 - timeout
70
71 - Return from ioctl after timeout ms with errorcode when no message
72 was received
73
74 38
75Return Value 39Return Value
76============ 40============
77 41
78On success 0 is returned, on error -1 and the ``errno`` variable is set 42On success 0 is returned.
79appropriately. The generic error codes are described at the 43
44On error -1 is returned, and the ``errno`` variable is set
45appropriately.
46
47Generic error codes are described at the
80:ref:`Generic Error Codes <gen-errors>` chapter. 48:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-diseqc-reset-overload.rst b/Documentation/media/uapi/dvb/fe-diseqc-reset-overload.rst
index 75116f283faf..78476c1c7bf5 100644
--- a/Documentation/media/uapi/dvb/fe-diseqc-reset-overload.rst
+++ b/Documentation/media/uapi/dvb/fe-diseqc-reset-overload.rst
@@ -31,12 +31,16 @@ Description
31If the bus has been automatically powered off due to power overload, 31If the bus has been automatically powered off due to power overload,
32this ioctl call restores the power to the bus. The call requires 32this ioctl call restores the power to the bus. The call requires
33read/write access to the device. This call has no effect if the device 33read/write access to the device. This call has no effect if the device
34is manually powered off. Not all DVB adapters support this ioctl. 34is manually powered off. Not all Digital TV adapters support this ioctl.
35 35
36 36
37Return Value 37Return Value
38============ 38============
39 39
40On success 0 is returned, on error -1 and the ``errno`` variable is set 40On success 0 is returned.
41appropriately. The generic error codes are described at the 41
42On error -1 is returned, and the ``errno`` variable is set
43appropriately.
44
45Generic error codes are described at the
42:ref:`Generic Error Codes <gen-errors>` chapter. 46:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-diseqc-send-burst.rst b/Documentation/media/uapi/dvb/fe-diseqc-send-burst.rst
index e962f6ec5aaf..a7e05914efae 100644
--- a/Documentation/media/uapi/dvb/fe-diseqc-send-burst.rst
+++ b/Documentation/media/uapi/dvb/fe-diseqc-send-burst.rst
@@ -26,7 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <frontend_f_open>`. 26 File descriptor returned by :ref:`open() <frontend_f_open>`.
27 27
28``tone`` 28``tone``
29 an integer enumered value described at :c:type:`fe_sec_mini_cmd` 29 An integer enumered value described at :c:type:`fe_sec_mini_cmd`.
30 30
31 31
32Description 32Description
@@ -39,39 +39,14 @@ read/write permissions.
39It provides support for what's specified at 39It provides support for what's specified at
40`Digital Satellite Equipment Control (DiSEqC) - Simple "ToneBurst" Detection Circuit specification. <http://www.eutelsat.com/files/contributed/satellites/pdf/Diseqc/associated%20docs/simple_tone_burst_detec.pdf>`__ 40`Digital Satellite Equipment Control (DiSEqC) - Simple "ToneBurst" Detection Circuit specification. <http://www.eutelsat.com/files/contributed/satellites/pdf/Diseqc/associated%20docs/simple_tone_burst_detec.pdf>`__
41 41
42.. c:type:: fe_sec_mini_cmd
43
44.. flat-table:: enum fe_sec_mini_cmd
45 :header-rows: 1
46 :stub-columns: 0
47
48
49 - .. row 1
50
51 - ID
52
53 - Description
54
55 - .. row 2
56
57 - .. _SEC-MINI-A:
58
59 ``SEC_MINI_A``
60
61 - Sends a mini-DiSEqC 22kHz '0' Tone Burst to select satellite-A
62
63 - .. row 3
64
65 - .. _SEC-MINI-B:
66
67 ``SEC_MINI_B``
68
69 - Sends a mini-DiSEqC 22kHz '1' Data Burst to select satellite-B
70
71 42
72Return Value 43Return Value
73============ 44============
74 45
75On success 0 is returned, on error -1 and the ``errno`` variable is set 46On success 0 is returned.
76appropriately. The generic error codes are described at the 47
48On error -1 is returned, and the ``errno`` variable is set
49appropriately.
50
51Generic error codes are described at the
77:ref:`Generic Error Codes <gen-errors>` chapter. 52:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-diseqc-send-master-cmd.rst b/Documentation/media/uapi/dvb/fe-diseqc-send-master-cmd.rst
index bbcab3df39b5..6bd3994edfc2 100644
--- a/Documentation/media/uapi/dvb/fe-diseqc-send-master-cmd.rst
+++ b/Documentation/media/uapi/dvb/fe-diseqc-send-master-cmd.rst
@@ -33,39 +33,17 @@ Arguments
33Description 33Description
34=========== 34===========
35 35
36Sends a DiSEqC command to the antenna subsystem. 36Sends the DiSEqC command pointed by :c:type:`dvb_diseqc_master_cmd`
37 37to the antenna subsystem.
38
39.. c:type:: dvb_diseqc_master_cmd
40
41.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
42
43.. flat-table:: struct dvb_diseqc_master_cmd
44 :header-rows: 0
45 :stub-columns: 0
46 :widths: 1 1 2
47
48
49 - .. row 1
50
51 - uint8_t
52
53 - msg[6]
54
55 - DiSEqC message (framing, address, command, data[3])
56
57 - .. row 2
58
59 - uint8_t
60
61 - msg_len
62
63 - Length of the DiSEqC message. Valid values are 3 to 6
64 38
65Return Value 39Return Value
66============ 40============
67 41
68On success 0 is returned, on error -1 and the ``errno`` variable is set 42On success 0 is returned.
69appropriately. The generic error codes are described at the 43
44On error -1 is returned, and the ``errno`` variable is set
45appropriately.
46
47Generic error codes are described at the
70:ref:`Generic Error Codes <gen-errors>` chapter. 48:ref:`Generic Error Codes <gen-errors>` chapter.
71 49
diff --git a/Documentation/media/uapi/dvb/fe-dishnetwork-send-legacy-cmd.rst b/Documentation/media/uapi/dvb/fe-dishnetwork-send-legacy-cmd.rst
index f41371f12456..dcf2d20d460f 100644
--- a/Documentation/media/uapi/dvb/fe-dishnetwork-send-legacy-cmd.rst
+++ b/Documentation/media/uapi/dvb/fe-dishnetwork-send-legacy-cmd.rst
@@ -46,6 +46,10 @@ dishes were already legacy in 2004.
46Return Value 46Return Value
47============ 47============
48 48
49On success 0 is returned, on error -1 and the ``errno`` variable is set 49On success 0 is returned.
50appropriately. The generic error codes are described at the 50
51On error -1 is returned, and the ``errno`` variable is set
52appropriately.
53
54Generic error codes are described at the
51:ref:`Generic Error Codes <gen-errors>` chapter. 55:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-enable-high-lnb-voltage.rst b/Documentation/media/uapi/dvb/fe-enable-high-lnb-voltage.rst
index bacafbc462d2..b20cb360fe37 100644
--- a/Documentation/media/uapi/dvb/fe-enable-high-lnb-voltage.rst
+++ b/Documentation/media/uapi/dvb/fe-enable-high-lnb-voltage.rst
@@ -45,6 +45,10 @@ voltages.
45Return Value 45Return Value
46============ 46============
47 47
48On success 0 is returned, on error -1 and the ``errno`` variable is set 48On success 0 is returned.
49appropriately. The generic error codes are described at the 49
50On error -1 is returned, and the ``errno`` variable is set
51appropriately.
52
53Generic error codes are described at the
50:ref:`Generic Error Codes <gen-errors>` chapter. 54:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-get-event.rst b/Documentation/media/uapi/dvb/fe-get-event.rst
index 8a719c33073d..505db94bf183 100644
--- a/Documentation/media/uapi/dvb/fe-get-event.rst
+++ b/Documentation/media/uapi/dvb/fe-get-event.rst
@@ -44,10 +44,10 @@ an event becomes available.
44Return Value 44Return Value
45============ 45============
46 46
47On success 0 is returned, on error -1 and the ``errno`` variable is set 47On success 0 is returned.
48appropriately. The generic error codes are described at the
49:ref:`Generic Error Codes <gen-errors>` chapter.
50 48
49On error -1 is returned, and the ``errno`` variable is set
50appropriately.
51 51
52 52
53.. flat-table:: 53.. flat-table::
@@ -66,3 +66,6 @@ appropriately. The generic error codes are described at the
66 - ``EOVERFLOW`` 66 - ``EOVERFLOW``
67 67
68 - Overflow in event queue - one or more events were lost. 68 - Overflow in event queue - one or more events were lost.
69
70Generic error codes are described at the
71:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-get-frontend.rst b/Documentation/media/uapi/dvb/fe-get-frontend.rst
index d53a3f8237c3..5db552cedd70 100644
--- a/Documentation/media/uapi/dvb/fe-get-frontend.rst
+++ b/Documentation/media/uapi/dvb/fe-get-frontend.rst
@@ -42,11 +42,10 @@ this command, read-only access to the device is sufficient.
42Return Value 42Return Value
43============ 43============
44 44
45On success 0 is returned, on error -1 and the ``errno`` variable is set 45On success 0 is returned.
46appropriately. The generic error codes are described at the
47:ref:`Generic Error Codes <gen-errors>` chapter.
48
49 46
47On error -1 is returned, and the ``errno`` variable is set
48appropriately.
50 49
51.. flat-table:: 50.. flat-table::
52 :header-rows: 0 51 :header-rows: 0
@@ -58,3 +57,6 @@ appropriately. The generic error codes are described at the
58 - ``EINVAL`` 57 - ``EINVAL``
59 58
60 - Maximum supported symbol rate reached. 59 - Maximum supported symbol rate reached.
60
61Generic error codes are described at the
62:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-get-info.rst b/Documentation/media/uapi/dvb/fe-get-info.rst
index e3d64b251f61..49307c0abfee 100644
--- a/Documentation/media/uapi/dvb/fe-get-info.rst
+++ b/Documentation/media/uapi/dvb/fe-get-info.rst
@@ -9,7 +9,8 @@ ioctl FE_GET_INFO
9Name 9Name
10==== 10====
11 11
12FE_GET_INFO - Query DVB frontend capabilities and returns information about the - front-end. This call only requires read-only access to the device 12FE_GET_INFO - Query Digital TV frontend capabilities and returns information
13about the - front-end. This call only requires read-only access to the device.
13 14
14 15
15Synopsis 16Synopsis
@@ -33,119 +34,13 @@ Arguments
33Description 34Description
34=========== 35===========
35 36
36All DVB frontend devices support the ``FE_GET_INFO`` ioctl. It is used 37All Digital TV frontend devices support the :ref:`FE_GET_INFO` ioctl. It is
37to identify kernel devices compatible with this specification and to 38used to identify kernel devices compatible with this specification and to
38obtain information about driver and hardware capabilities. The ioctl 39obtain information about driver and hardware capabilities. The ioctl
39takes a pointer to dvb_frontend_info which is filled by the driver. 40takes a pointer to dvb_frontend_info which is filled by the driver.
40When the driver is not compatible with this specification the ioctl 41When the driver is not compatible with this specification the ioctl
41returns an error. 42returns an error.
42 43
43.. c:type:: dvb_frontend_info
44
45.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
46
47.. flat-table:: struct dvb_frontend_info
48 :header-rows: 0
49 :stub-columns: 0
50 :widths: 1 1 2
51
52
53 - .. row 1
54
55 - char
56
57 - name[128]
58
59 - Name of the frontend
60
61 - .. row 2
62
63 - fe_type_t
64
65 - type
66
67 - **DEPRECATED**. DVBv3 type. Should not be used on modern programs,
68 as a frontend may have more than one type. So, the DVBv5 API
69 should be used instead to enumerate and select the frontend type.
70
71 - .. row 3
72
73 - uint32_t
74
75 - frequency_min
76
77 - Minimal frequency supported by the frontend
78
79 - .. row 4
80
81 - uint32_t
82
83 - frequency_max
84
85 - Maximal frequency supported by the frontend
86
87 - .. row 5
88
89 - uint32_t
90
91 - frequency_stepsize
92
93 - Frequency step - all frequencies are multiple of this value
94
95 - .. row 6
96
97 - uint32_t
98
99 - frequency_tolerance
100
101 - Tolerance of the frequency
102
103 - .. row 7
104
105 - uint32_t
106
107 - symbol_rate_min
108
109 - Minimal symbol rate (for Cable/Satellite systems), in bauds
110
111 - .. row 8
112
113 - uint32_t
114
115 - symbol_rate_max
116
117 - Maximal symbol rate (for Cable/Satellite systems), in bauds
118
119 - .. row 9
120
121 - uint32_t
122
123 - symbol_rate_tolerance
124
125 - Maximal symbol rate tolerance, in ppm
126
127 - .. row 10
128
129 - uint32_t
130
131 - notifier_delay
132
133 - **DEPRECATED**. Not used by any driver.
134
135 - .. row 11
136
137 - enum :c:type:`fe_caps`
138
139 - caps
140
141 - Capabilities supported by the frontend
142
143
144.. note::
145
146 The frequencies are specified in Hz for Terrestrial and Cable
147 systems. They're specified in kHz for Satellite systems
148
149 44
150frontend capabilities 45frontend capabilities
151===================== 46=====================
@@ -153,274 +48,16 @@ frontend capabilities
153Capabilities describe what a frontend can do. Some capabilities are 48Capabilities describe what a frontend can do. Some capabilities are
154supported only on some specific frontend types. 49supported only on some specific frontend types.
155 50
156.. c:type:: fe_caps 51The frontend capabilities are described at :c:type:`fe_caps`.
157
158.. tabularcolumns:: |p{6.5cm}|p{11.0cm}|
159
160.. flat-table:: enum fe_caps
161 :header-rows: 1
162 :stub-columns: 0
163
164
165 - .. row 1
166
167 - ID
168
169 - Description
170
171 - .. row 2
172
173 - .. _FE-IS-STUPID:
174
175 ``FE_IS_STUPID``
176
177 - There's something wrong at the frontend, and it can't report its
178 capabilities
179
180 - .. row 3
181
182 - .. _FE-CAN-INVERSION-AUTO:
183
184 ``FE_CAN_INVERSION_AUTO``
185
186 - The frontend is capable of auto-detecting inversion
187
188 - .. row 4
189
190 - .. _FE-CAN-FEC-1-2:
191
192 ``FE_CAN_FEC_1_2``
193
194 - The frontend supports FEC 1/2
195
196 - .. row 5
197
198 - .. _FE-CAN-FEC-2-3:
199
200 ``FE_CAN_FEC_2_3``
201
202 - The frontend supports FEC 2/3
203
204 - .. row 6
205
206 - .. _FE-CAN-FEC-3-4:
207
208 ``FE_CAN_FEC_3_4``
209
210 - The frontend supports FEC 3/4
211
212 - .. row 7
213
214 - .. _FE-CAN-FEC-4-5:
215
216 ``FE_CAN_FEC_4_5``
217
218 - The frontend supports FEC 4/5
219
220 - .. row 8
221
222 - .. _FE-CAN-FEC-5-6:
223
224 ``FE_CAN_FEC_5_6``
225
226 - The frontend supports FEC 5/6
227
228 - .. row 9
229
230 - .. _FE-CAN-FEC-6-7:
231
232 ``FE_CAN_FEC_6_7``
233
234 - The frontend supports FEC 6/7
235
236 - .. row 10
237
238 - .. _FE-CAN-FEC-7-8:
239
240 ``FE_CAN_FEC_7_8``
241
242 - The frontend supports FEC 7/8
243
244 - .. row 11
245
246 - .. _FE-CAN-FEC-8-9:
247
248 ``FE_CAN_FEC_8_9``
249
250 - The frontend supports FEC 8/9
251
252 - .. row 12
253
254 - .. _FE-CAN-FEC-AUTO:
255
256 ``FE_CAN_FEC_AUTO``
257
258 - The frontend can autodetect FEC.
259
260 - .. row 13
261
262 - .. _FE-CAN-QPSK:
263
264 ``FE_CAN_QPSK``
265
266 - The frontend supports QPSK modulation
267
268 - .. row 14
269
270 - .. _FE-CAN-QAM-16:
271
272 ``FE_CAN_QAM_16``
273
274 - The frontend supports 16-QAM modulation
275
276 - .. row 15
277
278 - .. _FE-CAN-QAM-32:
279
280 ``FE_CAN_QAM_32``
281
282 - The frontend supports 32-QAM modulation
283
284 - .. row 16
285
286 - .. _FE-CAN-QAM-64:
287
288 ``FE_CAN_QAM_64``
289
290 - The frontend supports 64-QAM modulation
291
292 - .. row 17
293
294 - .. _FE-CAN-QAM-128:
295
296 ``FE_CAN_QAM_128``
297
298 - The frontend supports 128-QAM modulation
299
300 - .. row 18
301
302 - .. _FE-CAN-QAM-256:
303
304 ``FE_CAN_QAM_256``
305
306 - The frontend supports 256-QAM modulation
307
308 - .. row 19
309
310 - .. _FE-CAN-QAM-AUTO:
311
312 ``FE_CAN_QAM_AUTO``
313
314 - The frontend can autodetect modulation
315
316 - .. row 20
317
318 - .. _FE-CAN-TRANSMISSION-MODE-AUTO:
319
320 ``FE_CAN_TRANSMISSION_MODE_AUTO``
321
322 - The frontend can autodetect the transmission mode
323
324 - .. row 21
325
326 - .. _FE-CAN-BANDWIDTH-AUTO:
327
328 ``FE_CAN_BANDWIDTH_AUTO``
329
330 - The frontend can autodetect the bandwidth
331
332 - .. row 22
333
334 - .. _FE-CAN-GUARD-INTERVAL-AUTO:
335
336 ``FE_CAN_GUARD_INTERVAL_AUTO``
337
338 - The frontend can autodetect the guard interval
339
340 - .. row 23
341
342 - .. _FE-CAN-HIERARCHY-AUTO:
343
344 ``FE_CAN_HIERARCHY_AUTO``
345
346 - The frontend can autodetect hierarch
347
348 - .. row 24
349
350 - .. _FE-CAN-8VSB:
351
352 ``FE_CAN_8VSB``
353
354 - The frontend supports 8-VSB modulation
355
356 - .. row 25
357
358 - .. _FE-CAN-16VSB:
359
360 ``FE_CAN_16VSB``
361
362 - The frontend supports 16-VSB modulation
363
364 - .. row 26
365
366 - .. _FE-HAS-EXTENDED-CAPS:
367
368 ``FE_HAS_EXTENDED_CAPS``
369
370 - Currently, unused
371
372 - .. row 27
373
374 - .. _FE-CAN-MULTISTREAM:
375
376 ``FE_CAN_MULTISTREAM``
377
378 - The frontend supports multistream filtering
379
380 - .. row 28
381
382 - .. _FE-CAN-TURBO-FEC:
383
384 ``FE_CAN_TURBO_FEC``
385
386 - The frontend supports turbo FEC modulation
387
388 - .. row 29
389
390 - .. _FE-CAN-2G-MODULATION:
391
392 ``FE_CAN_2G_MODULATION``
393
394 - The frontend supports "2nd generation modulation" (DVB-S2/T2)>
395
396 - .. row 30
397
398 - .. _FE-NEEDS-BENDING:
399
400 ``FE_NEEDS_BENDING``
401
402 - Not supported anymore, don't use it
403
404 - .. row 31
405
406 - .. _FE-CAN-RECOVER:
407
408 ``FE_CAN_RECOVER``
409
410 - The frontend can recover from a cable unplug automatically
411
412 - .. row 32
413
414 - .. _FE-CAN-MUTE-TS:
415
416 ``FE_CAN_MUTE_TS``
417
418 - The frontend can stop spurious TS data output
419 52
420 53
421Return Value 54Return Value
422============ 55============
423 56
424On success 0 is returned, on error -1 and the ``errno`` variable is set 57On success 0 is returned.
425appropriately. The generic error codes are described at the 58
59On error -1 is returned, and the ``errno`` variable is set
60appropriately.
61
62Generic error codes are described at the
426:ref:`Generic Error Codes <gen-errors>` chapter. 63:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-get-property.rst b/Documentation/media/uapi/dvb/fe-get-property.rst
index 015d4db597b5..948d2ba84f2c 100644
--- a/Documentation/media/uapi/dvb/fe-get-property.rst
+++ b/Documentation/media/uapi/dvb/fe-get-property.rst
@@ -29,13 +29,13 @@ Arguments
29 File descriptor returned by :ref:`open() <frontend_f_open>`. 29 File descriptor returned by :ref:`open() <frontend_f_open>`.
30 30
31``argp`` 31``argp``
32 pointer to struct :c:type:`dtv_properties` 32 Pointer to struct :c:type:`dtv_properties`.
33 33
34 34
35Description 35Description
36=========== 36===========
37 37
38All DVB frontend devices support the ``FE_SET_PROPERTY`` and 38All Digital TV frontend devices support the ``FE_SET_PROPERTY`` and
39``FE_GET_PROPERTY`` ioctls. The supported properties and statistics 39``FE_GET_PROPERTY`` ioctls. The supported properties and statistics
40depends on the delivery system and on the device: 40depends on the delivery system and on the device:
41 41
@@ -64,6 +64,10 @@ depends on the delivery system and on the device:
64Return Value 64Return Value
65============ 65============
66 66
67On success 0 is returned, on error -1 and the ``errno`` variable is set 67On success 0 is returned.
68appropriately. The generic error codes are described at the 68
69On error -1 is returned, and the ``errno`` variable is set
70appropriately.
71
72Generic error codes are described at the
69:ref:`Generic Error Codes <gen-errors>` chapter. 73:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-read-ber.rst b/Documentation/media/uapi/dvb/fe-read-ber.rst
index e54972ad5250..1e6a79567a4c 100644
--- a/Documentation/media/uapi/dvb/fe-read-ber.rst
+++ b/Documentation/media/uapi/dvb/fe-read-ber.rst
@@ -41,6 +41,10 @@ access to the device is sufficient.
41Return Value 41Return Value
42============ 42============
43 43
44On success 0 is returned, on error -1 and the ``errno`` variable is set 44On success 0 is returned.
45appropriately. The generic error codes are described at the 45
46On error -1 is returned, and the ``errno`` variable is set
47appropriately.
48
49Generic error codes are described at the
46:ref:`Generic Error Codes <gen-errors>` chapter. 50:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-read-signal-strength.rst b/Documentation/media/uapi/dvb/fe-read-signal-strength.rst
index 4b13c4757744..198f6dfb53a1 100644
--- a/Documentation/media/uapi/dvb/fe-read-signal-strength.rst
+++ b/Documentation/media/uapi/dvb/fe-read-signal-strength.rst
@@ -41,6 +41,10 @@ to the device is sufficient.
41Return Value 41Return Value
42============ 42============
43 43
44On success 0 is returned, on error -1 and the ``errno`` variable is set 44On success 0 is returned.
45appropriately. The generic error codes are described at the 45
46On error -1 is returned, and the ``errno`` variable is set
47appropriately.
48
49Generic error codes are described at the
46:ref:`Generic Error Codes <gen-errors>` chapter. 50:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-read-snr.rst b/Documentation/media/uapi/dvb/fe-read-snr.rst
index 2aed487f5c99..6db22c043512 100644
--- a/Documentation/media/uapi/dvb/fe-read-snr.rst
+++ b/Documentation/media/uapi/dvb/fe-read-snr.rst
@@ -41,6 +41,10 @@ to the device is sufficient.
41Return Value 41Return Value
42============ 42============
43 43
44On success 0 is returned, on error -1 and the ``errno`` variable is set 44On success 0 is returned.
45appropriately. The generic error codes are described at the 45
46On error -1 is returned, and the ``errno`` variable is set
47appropriately.
48
49Generic error codes are described at the
46:ref:`Generic Error Codes <gen-errors>` chapter. 50:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-read-status.rst b/Documentation/media/uapi/dvb/fe-read-status.rst
index 812f086c20f5..4adb52f084ff 100644
--- a/Documentation/media/uapi/dvb/fe-read-status.rst
+++ b/Documentation/media/uapi/dvb/fe-read-status.rst
@@ -33,7 +33,7 @@ Arguments
33Description 33Description
34=========== 34===========
35 35
36All DVB frontend devices support the ``FE_READ_STATUS`` ioctl. It is 36All Digital TV frontend devices support the ``FE_READ_STATUS`` ioctl. It is
37used to check about the locking status of the frontend after being 37used to check about the locking status of the frontend after being
38tuned. The ioctl takes a pointer to an integer where the status will be 38tuned. The ioctl takes a pointer to an integer where the status will be
39written. 39written.
@@ -52,85 +52,14 @@ The fe_status parameter is used to indicate the current state and/or
52state changes of the frontend hardware. It is produced using the enum 52state changes of the frontend hardware. It is produced using the enum
53:c:type:`fe_status` values on a bitmask 53:c:type:`fe_status` values on a bitmask
54 54
55.. c:type:: fe_status
56
57.. tabularcolumns:: |p{3.5cm}|p{14.0cm}|
58
59.. _fe-status:
60
61.. flat-table:: enum fe_status
62 :header-rows: 1
63 :stub-columns: 0
64
65
66 - .. row 1
67
68 - ID
69
70 - Description
71
72 - .. row 2
73
74 - .. _FE-HAS-SIGNAL:
75
76 ``FE_HAS_SIGNAL``
77
78 - The frontend has found something above the noise level
79
80 - .. row 3
81
82 - .. _FE-HAS-CARRIER:
83
84 ``FE_HAS_CARRIER``
85
86 - The frontend has found a DVB signal
87
88 - .. row 4
89
90 - .. _FE-HAS-VITERBI:
91
92 ``FE_HAS_VITERBI``
93
94 - The frontend FEC inner coding (Viterbi, LDPC or other inner code)
95 is stable
96
97 - .. row 5
98
99 - .. _FE-HAS-SYNC:
100
101 ``FE_HAS_SYNC``
102
103 - Synchronization bytes was found
104
105 - .. row 6
106
107 - .. _FE-HAS-LOCK:
108
109 ``FE_HAS_LOCK``
110
111 - The DVB were locked and everything is working
112
113 - .. row 7
114
115 - .. _FE-TIMEDOUT:
116
117 ``FE_TIMEDOUT``
118
119 - no lock within the last about 2 seconds
120
121 - .. row 8
122
123 - .. _FE-REINIT:
124
125 ``FE_REINIT``
126
127 - The frontend was reinitialized, application is recommended to
128 reset DiSEqC, tone and parameters
129
130 55
131Return Value 56Return Value
132============ 57============
133 58
134On success 0 is returned, on error -1 and the ``errno`` variable is set 59On success 0 is returned.
135appropriately. The generic error codes are described at the 60
61On error -1 is returned, and the ``errno`` variable is set
62appropriately.
63
64Generic error codes are described at the
136:ref:`Generic Error Codes <gen-errors>` chapter. 65:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-read-uncorrected-blocks.rst b/Documentation/media/uapi/dvb/fe-read-uncorrected-blocks.rst
index 46687c123402..f2c688bcacb3 100644
--- a/Documentation/media/uapi/dvb/fe-read-uncorrected-blocks.rst
+++ b/Documentation/media/uapi/dvb/fe-read-uncorrected-blocks.rst
@@ -43,6 +43,10 @@ sufficient.
43Return Value 43Return Value
44============ 44============
45 45
46On success 0 is returned, on error -1 and the ``errno`` variable is set 46On success 0 is returned.
47appropriately. The generic error codes are described at the 47
48On error -1 is returned, and the ``errno`` variable is set
49appropriately.
50
51Generic error codes are described at the
48:ref:`Generic Error Codes <gen-errors>` chapter. 52:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-set-frontend-tune-mode.rst b/Documentation/media/uapi/dvb/fe-set-frontend-tune-mode.rst
index 1d5878da2f41..3c4bc179b313 100644
--- a/Documentation/media/uapi/dvb/fe-set-frontend-tune-mode.rst
+++ b/Documentation/media/uapi/dvb/fe-set-frontend-tune-mode.rst
@@ -30,7 +30,7 @@ Arguments
30 30
31 - 0 - normal tune mode 31 - 0 - normal tune mode
32 32
33 - FE_TUNE_MODE_ONESHOT - When set, this flag will disable any 33 - ``FE_TUNE_MODE_ONESHOT`` - When set, this flag will disable any
34 zigzagging or other "normal" tuning behaviour. Additionally, 34 zigzagging or other "normal" tuning behaviour. Additionally,
35 there will be no automatic monitoring of the lock status, and 35 there will be no automatic monitoring of the lock status, and
36 hence no frontend events will be generated. If a frontend device 36 hence no frontend events will be generated. If a frontend device
@@ -42,12 +42,16 @@ Description
42=========== 42===========
43 43
44Allow setting tuner mode flags to the frontend, between 0 (normal) or 44Allow setting tuner mode flags to the frontend, between 0 (normal) or
45FE_TUNE_MODE_ONESHOT mode 45``FE_TUNE_MODE_ONESHOT`` mode
46 46
47 47
48Return Value 48Return Value
49============ 49============
50 50
51On success 0 is returned, on error -1 and the ``errno`` variable is set 51On success 0 is returned.
52appropriately. The generic error codes are described at the 52
53On error -1 is returned, and the ``errno`` variable is set
54appropriately.
55
56Generic error codes are described at the
53:ref:`Generic Error Codes <gen-errors>` chapter. 57:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-set-frontend.rst b/Documentation/media/uapi/dvb/fe-set-frontend.rst
index 7f97dce9aee6..4f3dcf338254 100644
--- a/Documentation/media/uapi/dvb/fe-set-frontend.rst
+++ b/Documentation/media/uapi/dvb/fe-set-frontend.rst
@@ -48,17 +48,24 @@ requires read/write access to the device.
48Return Value 48Return Value
49============ 49============
50 50
51On success 0 is returned, on error -1 and the ``errno`` variable is set 51On success 0 is returned.
52appropriately. The generic error codes are described at the 52
53:ref:`Generic Error Codes <gen-errors>` chapter. 53On error -1 is returned, and the ``errno`` variable is set
54appropriately.
55
56.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
54 57
55.. flat-table:: 58.. flat-table::
56 :header-rows: 0 59 :header-rows: 0
57 :stub-columns: 0 60 :stub-columns: 0
58 61 :widths: 1 16
59 62
60 - .. row 1 63 - .. row 1
61 64
62 - ``EINVAL`` 65 - ``EINVAL``
63 66
64 - Maximum supported symbol rate reached. 67 - Maximum supported symbol rate reached.
68
69
70Generic error codes are described at the
71:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-set-tone.rst b/Documentation/media/uapi/dvb/fe-set-tone.rst
index 84e4da3fd4c9..758efa11014c 100644
--- a/Documentation/media/uapi/dvb/fe-set-tone.rst
+++ b/Documentation/media/uapi/dvb/fe-set-tone.rst
@@ -45,40 +45,14 @@ this is done using the DiSEqC ioctls.
45 capability of selecting the band. So, it is recommended that applications 45 capability of selecting the band. So, it is recommended that applications
46 would change to SEC_TONE_OFF when the device is not used. 46 would change to SEC_TONE_OFF when the device is not used.
47 47
48.. c:type:: fe_sec_tone_mode
49
50.. flat-table:: enum fe_sec_tone_mode
51 :header-rows: 1
52 :stub-columns: 0
53
54
55 - .. row 1
56
57 - ID
58
59 - Description
60
61 - .. row 2
62
63 - .. _SEC-TONE-ON:
64
65 ``SEC_TONE_ON``
66
67 - Sends a 22kHz tone burst to the antenna
68
69 - .. row 3
70
71 - .. _SEC-TONE-OFF:
72
73 ``SEC_TONE_OFF``
74
75 - Don't send a 22kHz tone to the antenna (except if the
76 FE_DISEQC_* ioctls are called)
77
78 48
79Return Value 49Return Value
80============ 50============
81 51
82On success 0 is returned, on error -1 and the ``errno`` variable is set 52On success 0 is returned.
83appropriately. The generic error codes are described at the 53
54On error -1 is returned, and the ``errno`` variable is set
55appropriately.
56
57Generic error codes are described at the
84:ref:`Generic Error Codes <gen-errors>` chapter. 58:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-set-voltage.rst b/Documentation/media/uapi/dvb/fe-set-voltage.rst
index 052f316bb4a3..38d4485290a0 100644
--- a/Documentation/media/uapi/dvb/fe-set-voltage.rst
+++ b/Documentation/media/uapi/dvb/fe-set-voltage.rst
@@ -53,6 +53,10 @@ power up the LNBf.
53Return Value 53Return Value
54============ 54============
55 55
56On success 0 is returned, on error -1 and the ``errno`` variable is set 56On success 0 is returned.
57appropriately. The generic error codes are described at the 57
58On error -1 is returned, and the ``errno`` variable is set
59appropriately.
60
61Generic error codes are described at the
58:ref:`Generic Error Codes <gen-errors>` chapter. 62:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/fe-type-t.rst b/Documentation/media/uapi/dvb/fe-type-t.rst
index 548b965188d0..dee32ae104d7 100644
--- a/Documentation/media/uapi/dvb/fe-type-t.rst
+++ b/Documentation/media/uapi/dvb/fe-type-t.rst
@@ -78,7 +78,7 @@ parameter.
78 78
79In the old days, struct :c:type:`dvb_frontend_info` 79In the old days, struct :c:type:`dvb_frontend_info`
80used to contain ``fe_type_t`` field to indicate the delivery systems, 80used to contain ``fe_type_t`` field to indicate the delivery systems,
81filled with either FE_QPSK, FE_QAM, FE_OFDM or FE_ATSC. While this 81filled with either ``FE_QPSK, FE_QAM, FE_OFDM`` or ``FE_ATSC``. While this
82is still filled to keep backward compatibility, the usage of this field 82is still filled to keep backward compatibility, the usage of this field
83is deprecated, as it can report just one delivery system, but some 83is deprecated, as it can report just one delivery system, but some
84devices support multiple delivery systems. Please use 84devices support multiple delivery systems. Please use
diff --git a/Documentation/media/uapi/dvb/fe_property_parameters.rst b/Documentation/media/uapi/dvb/fe_property_parameters.rst
index 7bb7559c4500..6eef507fea50 100644
--- a/Documentation/media/uapi/dvb/fe_property_parameters.rst
+++ b/Documentation/media/uapi/dvb/fe_property_parameters.rst
@@ -6,6 +6,11 @@
6Digital TV property parameters 6Digital TV property parameters
7****************************** 7******************************
8 8
9There are several different Digital TV parameters that can be used by
10:ref:`FE_SET_PROPERTY and FE_GET_PROPERTY ioctls<FE_GET_PROPERTY>`.
11This section describes each of them. Please notice, however, that only
12a subset of them are needed to setup a frontend.
13
9 14
10.. _DTV-UNDEFINED: 15.. _DTV-UNDEFINED:
11 16
@@ -67,144 +72,36 @@ DTV_MODULATION
67============== 72==============
68 73
69Specifies the frontend modulation type for delivery systems that 74Specifies the frontend modulation type for delivery systems that
70supports more than one modulation type. The modulation can be one of the 75supports more multiple modulations.
71types defined by enum :c:type:`fe_modulation`. 76
72 77The modulation can be one of the types defined by enum :c:type:`fe_modulation`.
73 78
74.. c:type:: fe_modulation 79Most of the digital TV standards offers more than one possible
75 80modulation type.
76Modulation property 81
77------------------- 82The table below presents a summary of the types of modulation types
78 83supported by each delivery system, as currently defined by specs.
79Most of the digital TV standards currently offers more than one possible 84
80modulation (sometimes called as "constellation" on some standards). This 85======================= =======================================================
81enum contains the values used by the Kernel. Please note that not all 86Standard Modulation types
82modulations are supported by a given standard. 87======================= =======================================================
83 88ATSC (version 1) 8-VSB and 16-VSB.
84 89DMTB 4-QAM, 16-QAM, 32-QAM, 64-QAM and 4-QAM-NR.
85.. flat-table:: enum fe_modulation 90DVB-C Annex A/C 16-QAM, 32-QAM, 64-QAM and 256-QAM.
86 :header-rows: 1 91DVB-C Annex B 64-QAM.
87 :stub-columns: 0 92DVB-T QPSK, 16-QAM and 64-QAM.
88 93DVB-T2 QPSK, 16-QAM, 64-QAM and 256-QAM.
89 94DVB-S No need to set. It supports only QPSK.
90 - .. row 1 95DVB-S2 QPSK, 8-PSK, 16-APSK and 32-APSK.
91 96ISDB-T QPSK, DQPSK, 16-QAM and 64-QAM.
92 - ID 97ISDB-S 8-PSK, QPSK and BPSK.
93 98======================= =======================================================
94 - Description
95
96 - .. row 2
97
98 - .. _QPSK:
99
100 ``QPSK``
101
102 - QPSK modulation
103
104 - .. row 3
105
106 - .. _QAM-16:
107
108 ``QAM_16``
109
110 - 16-QAM modulation
111
112 - .. row 4
113
114 - .. _QAM-32:
115
116 ``QAM_32``
117
118 - 32-QAM modulation
119
120 - .. row 5
121
122 - .. _QAM-64:
123
124 ``QAM_64``
125
126 - 64-QAM modulation
127
128 - .. row 6
129
130 - .. _QAM-128:
131
132 ``QAM_128``
133
134 - 128-QAM modulation
135
136 - .. row 7
137
138 - .. _QAM-256:
139
140 ``QAM_256``
141
142 - 256-QAM modulation
143
144 - .. row 8
145
146 - .. _QAM-AUTO:
147 99
148 ``QAM_AUTO`` 100.. note::
149
150 - Autodetect QAM modulation
151
152 - .. row 9
153
154 - .. _VSB-8:
155
156 ``VSB_8``
157
158 - 8-VSB modulation
159
160 - .. row 10
161
162 - .. _VSB-16:
163
164 ``VSB_16``
165
166 - 16-VSB modulation
167
168 - .. row 11
169
170 - .. _PSK-8:
171
172 ``PSK_8``
173
174 - 8-PSK modulation
175
176 - .. row 12
177
178 - .. _APSK-16:
179
180 ``APSK_16``
181
182 - 16-APSK modulation
183
184 - .. row 13
185
186 - .. _APSK-32:
187
188 ``APSK_32``
189
190 - 32-APSK modulation
191
192 - .. row 14
193
194 - .. _DQPSK:
195
196 ``DQPSK``
197
198 - DQPSK modulation
199
200 - .. row 15
201
202 - .. _QAM-4-NR:
203
204 ``QAM_4_NR``
205
206 - 4-QAM-NR modulation
207 101
102 Please notice that some of the above modulation types may not be
103 defined currently at the Kernel. The reason is simple: no driver
104 needed such definition yet.
208 105
209 106
210.. _DTV-BANDWIDTH-HZ: 107.. _DTV-BANDWIDTH-HZ:
@@ -214,32 +111,42 @@ DTV_BANDWIDTH_HZ
214 111
215Bandwidth for the channel, in HZ. 112Bandwidth for the channel, in HZ.
216 113
114Should be set only for terrestrial delivery systems.
115
217Possible values: ``1712000``, ``5000000``, ``6000000``, ``7000000``, 116Possible values: ``1712000``, ``5000000``, ``6000000``, ``7000000``,
218``8000000``, ``10000000``. 117``8000000``, ``10000000``.
219 118
220.. note:: 119======================= =======================================================
120Terrestrial Standard Possible values for bandwidth
121======================= =======================================================
122ATSC (version 1) No need to set. It is always 6MHz.
123DMTB No need to set. It is always 8MHz.
124DVB-T 6MHz, 7MHz and 8MHz.
125DVB-T2 1.172 MHz, 5MHz, 6MHz, 7MHz, 8MHz and 10MHz
126ISDB-T 5MHz, 6MHz, 7MHz and 8MHz, although most places
127 use 6MHz.
128======================= =======================================================
221 129
222 #. DVB-T supports 6, 7 and 8MHz.
223 130
224 #. DVB-T2 supports 1.172, 5, 6, 7, 8 and 10MHz. 131.. note::
225 132
226 #. ISDB-T supports 5MHz, 6MHz, 7MHz and 8MHz, although most
227 places use 6MHz.
228 133
229 #. On DVB-C and DVB-S/S2, the bandwidth depends on the symbol rate. 134 #. For ISDB-Tsb, the bandwidth can vary depending on the number of
230 So, the Kernel will silently ignore setting :ref:`DTV-BANDWIDTH-HZ`. 135 connected segments.
231 136
232 #. For DVB-C and DVB-S/S2, the Kernel will return an estimation of the 137 It can be easily derived from other parameters
233 bandwidth, calculated from :ref:`DTV-SYMBOL-RATE` and from 138 (DTV_ISDBT_SB_SEGMENT_IDX, DTV_ISDBT_SB_SEGMENT_COUNT).
234 the rolloff, with is fixed for DVB-C and DVB-S.
235 139
236 #. For DVB-S2, the bandwidth estimation will use :ref:`DTV-ROLLOFF`. 140 #. On Satellite and Cable delivery systems, the bandwidth depends on
141 the symbol rate. So, the Kernel will silently ignore any setting
142 :ref:`DTV-BANDWIDTH-HZ`. I will however fill it back with a
143 bandwidth estimation.
237 144
238 #. For ISDB-Tsb, it can vary depending on the number of connected 145 Such bandwidth estimation takes into account the symbol rate set with
239 segments. 146 :ref:`DTV-SYMBOL-RATE`, and the rolloff factor, with is fixed for
147 DVB-C and DVB-S.
240 148
241 #. Bandwidth in ISDB-Tsb can be easily derived from other parameters 149 For DVB-S2, the rolloff should also be set via :ref:`DTV-ROLLOFF`.
242 (DTV_ISDBT_SB_SEGMENT_IDX, DTV_ISDBT_SB_SEGMENT_COUNT).
243 150
244 151
245.. _DTV-INVERSION: 152.. _DTV-INVERSION:
@@ -249,53 +156,7 @@ DTV_INVERSION
249 156
250Specifies if the frontend should do spectral inversion or not. 157Specifies if the frontend should do spectral inversion or not.
251 158
252.. c:type:: fe_spectral_inversion 159The acceptable values are defined by :c:type:`fe_spectral_inversion`.
253
254enum fe_modulation: Frontend spectral inversion
255-----------------------------------------------
256
257This parameter indicates if spectral inversion should be presumed or
258not. In the automatic setting (``INVERSION_AUTO``) the hardware will try
259to figure out the correct setting by itself. If the hardware doesn't
260support, the DVB core will try to lock at the carrier first with
261inversion off. If it fails, it will try to enable inversion.
262
263
264.. flat-table:: enum fe_modulation
265 :header-rows: 1
266 :stub-columns: 0
267
268
269 - .. row 1
270
271 - ID
272
273 - Description
274
275 - .. row 2
276
277 - .. _INVERSION-OFF:
278
279 ``INVERSION_OFF``
280
281 - Don't do spectral band inversion.
282
283 - .. row 3
284
285 - .. _INVERSION-ON:
286
287 ``INVERSION_ON``
288
289 - Do spectral band inversion.
290
291 - .. row 4
292
293 - .. _INVERSION-AUTO:
294
295 ``INVERSION_AUTO``
296
297 - Autodetect spectral band inversion.
298
299 160
300 161
301.. _DTV-DISEQC-MASTER: 162.. _DTV-DISEQC-MASTER:
@@ -311,8 +172,9 @@ Currently not implemented.
311DTV_SYMBOL_RATE 172DTV_SYMBOL_RATE
312=============== 173===============
313 174
314Digital TV symbol rate, in bauds (symbols/second). Used on cable 175Used on cable and satellite delivery systems.
315standards. 176
177Digital TV symbol rate, in bauds (symbols/second).
316 178
317 179
318.. _DTV-INNER-FEC: 180.. _DTV-INNER-FEC:
@@ -320,128 +182,9 @@ standards.
320DTV_INNER_FEC 182DTV_INNER_FEC
321============= 183=============
322 184
323Used cable/satellite transmissions. The acceptable values are: 185Used on cable and satellite delivery systems.
324
325.. c:type:: fe_code_rate
326
327enum fe_code_rate: type of the Forward Error Correction.
328--------------------------------------------------------
329
330.. flat-table:: enum fe_code_rate
331 :header-rows: 1
332 :stub-columns: 0
333
334
335 - .. row 1
336
337 - ID
338
339 - Description
340
341 - .. row 2
342
343 - .. _FEC-NONE:
344
345 ``FEC_NONE``
346
347 - No Forward Error Correction Code
348
349 - .. row 3
350
351 - .. _FEC-AUTO:
352
353 ``FEC_AUTO``
354
355 - Autodetect Error Correction Code
356
357 - .. row 4
358
359 - .. _FEC-1-2:
360
361 ``FEC_1_2``
362
363 - Forward Error Correction Code 1/2
364
365 - .. row 5
366
367 - .. _FEC-2-3:
368
369 ``FEC_2_3``
370
371 - Forward Error Correction Code 2/3
372
373 - .. row 6
374
375 - .. _FEC-3-4:
376
377 ``FEC_3_4``
378
379 - Forward Error Correction Code 3/4
380
381 - .. row 7
382
383 - .. _FEC-4-5:
384
385 ``FEC_4_5``
386
387 - Forward Error Correction Code 4/5
388
389 - .. row 8
390
391 - .. _FEC-5-6:
392
393 ``FEC_5_6``
394
395 - Forward Error Correction Code 5/6
396
397 - .. row 9
398
399 - .. _FEC-6-7:
400
401 ``FEC_6_7``
402
403 - Forward Error Correction Code 6/7
404
405 - .. row 10
406
407 - .. _FEC-7-8:
408
409 ``FEC_7_8``
410
411 - Forward Error Correction Code 7/8
412
413 - .. row 11
414
415 - .. _FEC-8-9:
416
417 ``FEC_8_9``
418
419 - Forward Error Correction Code 8/9
420
421 - .. row 12
422
423 - .. _FEC-9-10:
424
425 ``FEC_9_10``
426
427 - Forward Error Correction Code 9/10
428
429 - .. row 13
430
431 - .. _FEC-2-5:
432
433 ``FEC_2_5``
434
435 - Forward Error Correction Code 2/5
436
437 - .. row 14
438
439 - .. _FEC-3-5:
440
441 ``FEC_3_5``
442
443 - Forward Error Correction Code 3/5
444 186
187The acceptable values are defined by :c:type:`fe_code_rate`.
445 188
446 189
447.. _DTV-VOLTAGE: 190.. _DTV-VOLTAGE:
@@ -449,49 +192,14 @@ enum fe_code_rate: type of the Forward Error Correction.
449DTV_VOLTAGE 192DTV_VOLTAGE
450=========== 193===========
451 194
195Used on satellite delivery systems.
196
452The voltage is usually used with non-DiSEqC capable LNBs to switch the 197The voltage is usually used with non-DiSEqC capable LNBs to switch the
453polarzation (horizontal/vertical). When using DiSEqC epuipment this 198polarzation (horizontal/vertical). When using DiSEqC epuipment this
454voltage has to be switched consistently to the DiSEqC commands as 199voltage has to be switched consistently to the DiSEqC commands as
455described in the DiSEqC spec. 200described in the DiSEqC spec.
456 201
457 202The acceptable values are defined by :c:type:`fe_sec_voltage`.
458.. c:type:: fe_sec_voltage
459
460.. flat-table:: enum fe_sec_voltage
461 :header-rows: 1
462 :stub-columns: 0
463
464
465 - .. row 1
466
467 - ID
468
469 - Description
470
471 - .. row 2
472
473 - .. _SEC-VOLTAGE-13:
474
475 ``SEC_VOLTAGE_13``
476
477 - Set DC voltage level to 13V
478
479 - .. row 3
480
481 - .. _SEC-VOLTAGE-18:
482
483 ``SEC_VOLTAGE_18``
484
485 - Set DC voltage level to 18V
486
487 - .. row 4
488
489 - .. _SEC-VOLTAGE-OFF:
490
491 ``SEC_VOLTAGE_OFF``
492
493 - Don't send any voltage to the antenna
494
495 203
496 204
497.. _DTV-TONE: 205.. _DTV-TONE:
@@ -507,50 +215,11 @@ Currently not used.
507DTV_PILOT 215DTV_PILOT
508========= 216=========
509 217
510Sets DVB-S2 pilot 218Used on DVB-S2.
511
512
513.. c:type:: fe_pilot
514
515fe_pilot type
516-------------
517
518
519.. flat-table:: enum fe_pilot
520 :header-rows: 1
521 :stub-columns: 0
522
523
524 - .. row 1
525
526 - ID
527
528 - Description
529
530 - .. row 2
531
532 - .. _PILOT-ON:
533
534 ``PILOT_ON``
535
536 - Pilot tones enabled
537
538 - .. row 3
539
540 - .. _PILOT-OFF:
541
542 ``PILOT_OFF``
543 219
544 - Pilot tones disabled 220Sets DVB-S2 pilot.
545
546 - .. row 4
547
548 - .. _PILOT-AUTO:
549
550 ``PILOT_AUTO``
551
552 - Autodetect pilot tones
553 221
222The acceptable values are defined by :c:type:`fe_pilot`.
554 223
555 224
556.. _DTV-ROLLOFF: 225.. _DTV-ROLLOFF:
@@ -558,58 +227,11 @@ fe_pilot type
558DTV_ROLLOFF 227DTV_ROLLOFF
559=========== 228===========
560 229
561Sets DVB-S2 rolloff 230Used on DVB-S2.
562
563
564.. c:type:: fe_rolloff
565
566fe_rolloff type
567---------------
568
569
570.. flat-table:: enum fe_rolloff
571 :header-rows: 1
572 :stub-columns: 0
573
574
575 - .. row 1
576
577 - ID
578
579 - Description
580
581 - .. row 2
582
583 - .. _ROLLOFF-35:
584
585 ``ROLLOFF_35``
586 231
587 - Roloff factor: α=35% 232Sets DVB-S2 rolloff.
588
589 - .. row 3
590
591 - .. _ROLLOFF-20:
592
593 ``ROLLOFF_20``
594
595 - Roloff factor: α=20%
596
597 - .. row 4
598
599 - .. _ROLLOFF-25:
600
601 ``ROLLOFF_25``
602
603 - Roloff factor: α=25%
604
605 - .. row 5
606
607 - .. _ROLLOFF-AUTO:
608
609 ``ROLLOFF_AUTO``
610
611 - Auto-detect the roloff factor.
612 233
234The acceptable values are defined by :c:type:`fe_rolloff`.
613 235
614 236
615.. _DTV-DISEQC-SLAVE-REPLY: 237.. _DTV-DISEQC-SLAVE-REPLY:
@@ -641,180 +263,9 @@ Currently not implemented.
641DTV_DELIVERY_SYSTEM 263DTV_DELIVERY_SYSTEM
642=================== 264===================
643 265
644Specifies the type of Delivery system 266Specifies the type of the delivery system.
645
646
647.. c:type:: fe_delivery_system
648
649fe_delivery_system type
650-----------------------
651
652Possible values:
653
654
655.. flat-table:: enum fe_delivery_system
656 :header-rows: 1
657 :stub-columns: 0
658
659
660 - .. row 1
661
662 - ID
663
664 - Description
665
666 - .. row 2
667
668 - .. _SYS-UNDEFINED:
669
670 ``SYS_UNDEFINED``
671
672 - Undefined standard. Generally, indicates an error
673
674 - .. row 3
675
676 - .. _SYS-DVBC-ANNEX-A:
677
678 ``SYS_DVBC_ANNEX_A``
679
680 - Cable TV: DVB-C following ITU-T J.83 Annex A spec
681
682 - .. row 4
683
684 - .. _SYS-DVBC-ANNEX-B:
685
686 ``SYS_DVBC_ANNEX_B``
687
688 - Cable TV: DVB-C following ITU-T J.83 Annex B spec (ClearQAM)
689
690 - .. row 5
691
692 - .. _SYS-DVBC-ANNEX-C:
693
694 ``SYS_DVBC_ANNEX_C``
695
696 - Cable TV: DVB-C following ITU-T J.83 Annex C spec
697
698 - .. row 6
699
700 - .. _SYS-ISDBC:
701
702 ``SYS_ISDBC``
703
704 - Cable TV: ISDB-C (no drivers yet)
705
706 - .. row 7
707
708 - .. _SYS-DVBT:
709
710 ``SYS_DVBT``
711
712 - Terrestral TV: DVB-T
713
714 - .. row 8
715
716 - .. _SYS-DVBT2:
717
718 ``SYS_DVBT2``
719
720 - Terrestral TV: DVB-T2
721
722 - .. row 9
723
724 - .. _SYS-ISDBT:
725
726 ``SYS_ISDBT``
727
728 - Terrestral TV: ISDB-T
729
730 - .. row 10
731
732 - .. _SYS-ATSC:
733
734 ``SYS_ATSC``
735
736 - Terrestral TV: ATSC
737
738 - .. row 11
739
740 - .. _SYS-ATSCMH:
741
742 ``SYS_ATSCMH``
743
744 - Terrestral TV (mobile): ATSC-M/H
745
746 - .. row 12
747
748 - .. _SYS-DTMB:
749
750 ``SYS_DTMB``
751
752 - Terrestrial TV: DTMB
753
754 - .. row 13
755
756 - .. _SYS-DVBS:
757
758 ``SYS_DVBS``
759
760 - Satellite TV: DVB-S
761
762 - .. row 14
763
764 - .. _SYS-DVBS2:
765
766 ``SYS_DVBS2``
767
768 - Satellite TV: DVB-S2
769
770 - .. row 15
771
772 - .. _SYS-TURBO:
773
774 ``SYS_TURBO``
775
776 - Satellite TV: DVB-S Turbo
777
778 - .. row 16
779
780 - .. _SYS-ISDBS:
781
782 ``SYS_ISDBS``
783
784 - Satellite TV: ISDB-S
785
786 - .. row 17
787
788 - .. _SYS-DAB:
789
790 ``SYS_DAB``
791
792 - Digital audio: DAB (not fully supported)
793
794 - .. row 18
795
796 - .. _SYS-DSS:
797
798 ``SYS_DSS``
799
800 - Satellite TV:"DSS (not fully supported)
801
802 - .. row 19
803
804 - .. _SYS-CMMB:
805
806 ``SYS_CMMB``
807
808 - Terrestral TV (mobile):CMMB (not fully supported)
809
810 - .. row 20
811
812 - .. _SYS-DVBH:
813
814 ``SYS_DVBH``
815
816 - Terrestral TV (mobile): DVB-H (standard deprecated)
817 267
268The acceptable values are defined by :c:type:`fe_delivery_system`.
818 269
819 270
820.. _DTV-ISDBT-PARTIAL-RECEPTION: 271.. _DTV-ISDBT-PARTIAL-RECEPTION:
@@ -822,6 +273,8 @@ Possible values:
822DTV_ISDBT_PARTIAL_RECEPTION 273DTV_ISDBT_PARTIAL_RECEPTION
823=========================== 274===========================
824 275
276Used only on ISDB.
277
825If ``DTV_ISDBT_SOUND_BROADCASTING`` is '0' this bit-field represents 278If ``DTV_ISDBT_SOUND_BROADCASTING`` is '0' this bit-field represents
826whether the channel is in partial reception mode or not. 279whether the channel is in partial reception mode or not.
827 280
@@ -840,6 +293,8 @@ Possible values: 0, 1, -1 (AUTO)
840DTV_ISDBT_SOUND_BROADCASTING 293DTV_ISDBT_SOUND_BROADCASTING
841============================ 294============================
842 295
296Used only on ISDB.
297
843This field represents whether the other DTV_ISDBT_*-parameters are 298This field represents whether the other DTV_ISDBT_*-parameters are
844referring to an ISDB-T and an ISDB-Tsb channel. (See also 299referring to an ISDB-T and an ISDB-Tsb channel. (See also
845``DTV_ISDBT_PARTIAL_RECEPTION``). 300``DTV_ISDBT_PARTIAL_RECEPTION``).
@@ -852,6 +307,8 @@ Possible values: 0, 1, -1 (AUTO)
852DTV_ISDBT_SB_SUBCHANNEL_ID 307DTV_ISDBT_SB_SUBCHANNEL_ID
853========================== 308==========================
854 309
310Used only on ISDB.
311
855This field only applies if ``DTV_ISDBT_SOUND_BROADCASTING`` is '1'. 312This field only applies if ``DTV_ISDBT_SOUND_BROADCASTING`` is '1'.
856 313
857(Note of the author: This might not be the correct description of the 314(Note of the author: This might not be the correct description of the
@@ -887,6 +344,8 @@ Possible values: 0 .. 41, -1 (AUTO)
887DTV_ISDBT_SB_SEGMENT_IDX 344DTV_ISDBT_SB_SEGMENT_IDX
888======================== 345========================
889 346
347Used only on ISDB.
348
890This field only applies if ``DTV_ISDBT_SOUND_BROADCASTING`` is '1'. 349This field only applies if ``DTV_ISDBT_SOUND_BROADCASTING`` is '1'.
891 350
892``DTV_ISDBT_SB_SEGMENT_IDX`` gives the index of the segment to be 351``DTV_ISDBT_SB_SEGMENT_IDX`` gives the index of the segment to be
@@ -903,6 +362,8 @@ Note: This value cannot be determined by an automatic channel search.
903DTV_ISDBT_SB_SEGMENT_COUNT 362DTV_ISDBT_SB_SEGMENT_COUNT
904========================== 363==========================
905 364
365Used only on ISDB.
366
906This field only applies if ``DTV_ISDBT_SOUND_BROADCASTING`` is '1'. 367This field only applies if ``DTV_ISDBT_SOUND_BROADCASTING`` is '1'.
907 368
908``DTV_ISDBT_SB_SEGMENT_COUNT`` gives the total count of connected 369``DTV_ISDBT_SB_SEGMENT_COUNT`` gives the total count of connected
@@ -918,6 +379,8 @@ Note: This value cannot be determined by an automatic channel search.
918DTV-ISDBT-LAYER[A-C] parameters 379DTV-ISDBT-LAYER[A-C] parameters
919=============================== 380===============================
920 381
382Used only on ISDB.
383
921ISDB-T channels can be coded hierarchically. As opposed to DVB-T in 384ISDB-T channels can be coded hierarchically. As opposed to DVB-T in
922ISDB-T hierarchical layers can be decoded simultaneously. For that 385ISDB-T hierarchical layers can be decoded simultaneously. For that
923reason a ISDB-T demodulator has 3 Viterbi and 3 Reed-Solomon decoders. 386reason a ISDB-T demodulator has 3 Viterbi and 3 Reed-Solomon decoders.
@@ -934,6 +397,8 @@ There are 3 parameter sets, for Layers A, B and C.
934DTV_ISDBT_LAYER_ENABLED 397DTV_ISDBT_LAYER_ENABLED
935----------------------- 398-----------------------
936 399
400Used only on ISDB.
401
937Hierarchical reception in ISDB-T is achieved by enabling or disabling 402Hierarchical reception in ISDB-T is achieved by enabling or disabling
938layers in the decoding process. Setting all bits of 403layers in the decoding process. Setting all bits of
939``DTV_ISDBT_LAYER_ENABLED`` to '1' forces all layers (if applicable) to 404``DTV_ISDBT_LAYER_ENABLED`` to '1' forces all layers (if applicable) to
@@ -964,7 +429,13 @@ Only the values of the first 3 bits are used. Other bits will be silently ignore
964DTV_ISDBT_LAYER[A-C]_FEC 429DTV_ISDBT_LAYER[A-C]_FEC
965------------------------ 430------------------------
966 431
967Possible values: ``FEC_AUTO``, ``FEC_1_2``, ``FEC_2_3``, ``FEC_3_4``, 432Used only on ISDB.
433
434The Forward Error Correction mechanism used by a given ISDB Layer, as
435defined by :c:type:`fe_code_rate`.
436
437
438Possible values are: ``FEC_AUTO``, ``FEC_1_2``, ``FEC_2_3``, ``FEC_3_4``,
968``FEC_5_6``, ``FEC_7_8`` 439``FEC_5_6``, ``FEC_7_8``
969 440
970 441
@@ -973,11 +444,19 @@ Possible values: ``FEC_AUTO``, ``FEC_1_2``, ``FEC_2_3``, ``FEC_3_4``,
973DTV_ISDBT_LAYER[A-C]_MODULATION 444DTV_ISDBT_LAYER[A-C]_MODULATION
974------------------------------- 445-------------------------------
975 446
976Possible values: ``QAM_AUTO``, QP\ ``SK, QAM_16``, ``QAM_64``, ``DQPSK`` 447Used only on ISDB.
448
449The modulation used by a given ISDB Layer, as defined by
450:c:type:`fe_modulation`.
977 451
978Note: If layer C is ``DQPSK`` layer B has to be ``DQPSK``. If layer B is 452Possible values are: ``QAM_AUTO``, ``QPSK``, ``QAM_16``, ``QAM_64``, ``DQPSK``
979``DQPSK`` and ``DTV_ISDBT_PARTIAL_RECEPTION``\ =0 layer has to be 453
980``DQPSK``. 454.. note::
455
456 #. If layer C is ``DQPSK``, then layer B has to be ``DQPSK``.
457
458 #. If layer B is ``DQPSK`` and ``DTV_ISDBT_PARTIAL_RECEPTION``\ = 0,
459 then layer has to be ``DQPSK``.
981 460
982 461
983.. _DTV-ISDBT-LAYER-SEGMENT-COUNT: 462.. _DTV-ISDBT-LAYER-SEGMENT-COUNT:
@@ -985,6 +464,8 @@ Note: If layer C is ``DQPSK`` layer B has to be ``DQPSK``. If layer B is
985DTV_ISDBT_LAYER[A-C]_SEGMENT_COUNT 464DTV_ISDBT_LAYER[A-C]_SEGMENT_COUNT
986---------------------------------- 465----------------------------------
987 466
467Used only on ISDB.
468
988Possible values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1 (AUTO) 469Possible values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1 (AUTO)
989 470
990Note: Truth table for ``DTV_ISDBT_SOUND_BROADCASTING`` and 471Note: Truth table for ``DTV_ISDBT_SOUND_BROADCASTING`` and
@@ -993,15 +474,15 @@ Note: Truth table for ``DTV_ISDBT_SOUND_BROADCASTING`` and
993.. _isdbt-layer_seg-cnt-table: 474.. _isdbt-layer_seg-cnt-table:
994 475
995.. flat-table:: Truth table for ISDB-T Sound Broadcasting 476.. flat-table:: Truth table for ISDB-T Sound Broadcasting
996 :header-rows: 0 477 :header-rows: 1
997 :stub-columns: 0 478 :stub-columns: 0
998 479
999 480
1000 - .. row 1 481 - .. row 1
1001 482
1002 - PR 483 - Partial Reception
1003 484
1004 - SB 485 - Sound Broadcasting
1005 486
1006 - Layer A width 487 - Layer A width
1007 488
@@ -1074,6 +555,8 @@ Note: Truth table for ``DTV_ISDBT_SOUND_BROADCASTING`` and
1074DTV_ISDBT_LAYER[A-C]_TIME_INTERLEAVING 555DTV_ISDBT_LAYER[A-C]_TIME_INTERLEAVING
1075-------------------------------------- 556--------------------------------------
1076 557
558Used only on ISDB.
559
1077Valid values: 0, 1, 2, 4, -1 (AUTO) 560Valid values: 0, 1, 2, 4, -1 (AUTO)
1078 561
1079when DTV_ISDBT_SOUND_BROADCASTING is active, value 8 is also valid. 562when DTV_ISDBT_SOUND_BROADCASTING is active, value 8 is also valid.
@@ -1086,7 +569,7 @@ TMCC-structure, as shown in the table below.
1086.. c:type:: isdbt_layer_interleaving_table 569.. c:type:: isdbt_layer_interleaving_table
1087 570
1088.. flat-table:: ISDB-T time interleaving modes 571.. flat-table:: ISDB-T time interleaving modes
1089 :header-rows: 0 572 :header-rows: 1
1090 :stub-columns: 0 573 :stub-columns: 0
1091 574
1092 575
@@ -1147,6 +630,8 @@ TMCC-structure, as shown in the table below.
1147DTV_ATSCMH_FIC_VER 630DTV_ATSCMH_FIC_VER
1148------------------ 631------------------
1149 632
633Used only on ATSC-MH.
634
1150Version number of the FIC (Fast Information Channel) signaling data. 635Version number of the FIC (Fast Information Channel) signaling data.
1151 636
1152FIC is used for relaying information to allow rapid service acquisition 637FIC is used for relaying information to allow rapid service acquisition
@@ -1160,6 +645,8 @@ Possible values: 0, 1, 2, 3, ..., 30, 31
1160DTV_ATSCMH_PARADE_ID 645DTV_ATSCMH_PARADE_ID
1161-------------------- 646--------------------
1162 647
648Used only on ATSC-MH.
649
1163Parade identification number 650Parade identification number
1164 651
1165A parade is a collection of up to eight MH groups, conveying one or two 652A parade is a collection of up to eight MH groups, conveying one or two
@@ -1173,6 +660,8 @@ Possible values: 0, 1, 2, 3, ..., 126, 127
1173DTV_ATSCMH_NOG 660DTV_ATSCMH_NOG
1174-------------- 661--------------
1175 662
663Used only on ATSC-MH.
664
1176Number of MH groups per MH subframe for a designated parade. 665Number of MH groups per MH subframe for a designated parade.
1177 666
1178Possible values: 1, 2, 3, 4, 5, 6, 7, 8 667Possible values: 1, 2, 3, 4, 5, 6, 7, 8
@@ -1183,6 +672,8 @@ Possible values: 1, 2, 3, 4, 5, 6, 7, 8
1183DTV_ATSCMH_TNOG 672DTV_ATSCMH_TNOG
1184--------------- 673---------------
1185 674
675Used only on ATSC-MH.
676
1186Total number of MH groups including all MH groups belonging to all MH 677Total number of MH groups including all MH groups belonging to all MH
1187parades in one MH subframe. 678parades in one MH subframe.
1188 679
@@ -1194,6 +685,8 @@ Possible values: 0, 1, 2, 3, ..., 30, 31
1194DTV_ATSCMH_SGN 685DTV_ATSCMH_SGN
1195-------------- 686--------------
1196 687
688Used only on ATSC-MH.
689
1197Start group number. 690Start group number.
1198 691
1199Possible values: 0, 1, 2, 3, ..., 14, 15 692Possible values: 0, 1, 2, 3, ..., 14, 15
@@ -1204,6 +697,8 @@ Possible values: 0, 1, 2, 3, ..., 14, 15
1204DTV_ATSCMH_PRC 697DTV_ATSCMH_PRC
1205-------------- 698--------------
1206 699
700Used only on ATSC-MH.
701
1207Parade repetition cycle. 702Parade repetition cycle.
1208 703
1209Possible values: 1, 2, 3, 4, 5, 6, 7, 8 704Possible values: 1, 2, 3, 4, 5, 6, 7, 8
@@ -1214,44 +709,11 @@ Possible values: 1, 2, 3, 4, 5, 6, 7, 8
1214DTV_ATSCMH_RS_FRAME_MODE 709DTV_ATSCMH_RS_FRAME_MODE
1215------------------------ 710------------------------
1216 711
1217Reed Solomon (RS) frame mode. 712Used only on ATSC-MH.
1218
1219Possible values are:
1220
1221.. tabularcolumns:: |p{5.0cm}|p{12.5cm}|
1222
1223.. c:type:: atscmh_rs_frame_mode
1224
1225.. flat-table:: enum atscmh_rs_frame_mode
1226 :header-rows: 1
1227 :stub-columns: 0
1228
1229
1230 - .. row 1
1231
1232 - ID
1233
1234 - Description
1235
1236 - .. row 2
1237
1238 - .. _ATSCMH-RSFRAME-PRI-ONLY:
1239
1240 ``ATSCMH_RSFRAME_PRI_ONLY``
1241
1242 - Single Frame: There is only a primary RS Frame for all Group
1243 Regions.
1244
1245 - .. row 3
1246
1247 - .. _ATSCMH-RSFRAME-PRI-SEC:
1248
1249 ``ATSCMH_RSFRAME_PRI_SEC``
1250 713
1251 - Dual Frame: There are two separate RS Frames: Primary RS Frame for 714Reed Solomon (RS) frame mode.
1252 Group Region A and B and Secondary RS Frame for Group Region C and
1253 D.
1254 715
716The acceptable values are defined by :c:type:`atscmh_rs_frame_mode`.
1255 717
1256 718
1257.. _DTV-ATSCMH-RS-FRAME-ENSEMBLE: 719.. _DTV-ATSCMH-RS-FRAME-ENSEMBLE:
@@ -1259,48 +721,11 @@ Possible values are:
1259DTV_ATSCMH_RS_FRAME_ENSEMBLE 721DTV_ATSCMH_RS_FRAME_ENSEMBLE
1260---------------------------- 722----------------------------
1261 723
1262Reed Solomon(RS) frame ensemble. 724Used only on ATSC-MH.
1263
1264Possible values are:
1265
1266
1267.. c:type:: atscmh_rs_frame_ensemble
1268
1269.. flat-table:: enum atscmh_rs_frame_ensemble
1270 :header-rows: 1
1271 :stub-columns: 0
1272
1273
1274 - .. row 1
1275
1276 - ID
1277
1278 - Description
1279
1280 - .. row 2
1281
1282 - .. _ATSCMH-RSFRAME-ENS-PRI:
1283
1284 ``ATSCMH_RSFRAME_ENS_PRI``
1285
1286 - Primary Ensemble.
1287
1288 - .. row 3
1289
1290 - .. _ATSCMH-RSFRAME-ENS-SEC:
1291
1292 ``AATSCMH_RSFRAME_PRI_SEC``
1293
1294 - Secondary Ensemble.
1295
1296 - .. row 4
1297
1298 - .. _ATSCMH-RSFRAME-RES:
1299 725
1300 ``AATSCMH_RSFRAME_RES`` 726Reed Solomon(RS) frame ensemble.
1301
1302 - Reserved. Shouldn't be used.
1303 727
728The acceptable values are defined by :c:type:`atscmh_rs_frame_ensemble`.
1304 729
1305 730
1306.. _DTV-ATSCMH-RS-CODE-MODE-PRI: 731.. _DTV-ATSCMH-RS-CODE-MODE-PRI:
@@ -1308,56 +733,11 @@ Possible values are:
1308DTV_ATSCMH_RS_CODE_MODE_PRI 733DTV_ATSCMH_RS_CODE_MODE_PRI
1309--------------------------- 734---------------------------
1310 735
1311Reed Solomon (RS) code mode (primary). 736Used only on ATSC-MH.
1312
1313Possible values are:
1314
1315
1316.. c:type:: atscmh_rs_code_mode
1317
1318.. flat-table:: enum atscmh_rs_code_mode
1319 :header-rows: 1
1320 :stub-columns: 0
1321
1322
1323 - .. row 1
1324
1325 - ID
1326
1327 - Description
1328
1329 - .. row 2
1330
1331 - .. _ATSCMH-RSCODE-211-187:
1332
1333 ``ATSCMH_RSCODE_211_187``
1334
1335 - Reed Solomon code (211,187).
1336
1337 - .. row 3
1338
1339 - .. _ATSCMH-RSCODE-223-187:
1340
1341 ``ATSCMH_RSCODE_223_187``
1342
1343 - Reed Solomon code (223,187).
1344
1345 - .. row 4
1346
1347 - .. _ATSCMH-RSCODE-235-187:
1348 737
1349 ``ATSCMH_RSCODE_235_187`` 738Reed Solomon (RS) code mode (primary).
1350
1351 - Reed Solomon code (235,187).
1352
1353 - .. row 5
1354
1355 - .. _ATSCMH-RSCODE-RES:
1356
1357 ``ATSCMH_RSCODE_RES``
1358
1359 - Reserved. Shouldn't be used.
1360 739
740The acceptable values are defined by :c:type:`atscmh_rs_code_mode`.
1361 741
1362 742
1363.. _DTV-ATSCMH-RS-CODE-MODE-SEC: 743.. _DTV-ATSCMH-RS-CODE-MODE-SEC:
@@ -1365,10 +745,11 @@ Possible values are:
1365DTV_ATSCMH_RS_CODE_MODE_SEC 745DTV_ATSCMH_RS_CODE_MODE_SEC
1366--------------------------- 746---------------------------
1367 747
748Used only on ATSC-MH.
749
1368Reed Solomon (RS) code mode (secondary). 750Reed Solomon (RS) code mode (secondary).
1369 751
1370Possible values are the same as documented on enum 752The acceptable values are defined by :c:type:`atscmh_rs_code_mode`.
1371:c:type:`atscmh_rs_code_mode`:
1372 753
1373 754
1374.. _DTV-ATSCMH-SCCC-BLOCK-MODE: 755.. _DTV-ATSCMH-SCCC-BLOCK-MODE:
@@ -1376,51 +757,11 @@ Possible values are the same as documented on enum
1376DTV_ATSCMH_SCCC_BLOCK_MODE 757DTV_ATSCMH_SCCC_BLOCK_MODE
1377-------------------------- 758--------------------------
1378 759
1379Series Concatenated Convolutional Code Block Mode. 760Used only on ATSC-MH.
1380
1381Possible values are:
1382
1383.. tabularcolumns:: |p{4.5cm}|p{13.0cm}|
1384
1385.. c:type:: atscmh_sccc_block_mode
1386
1387.. flat-table:: enum atscmh_scc_block_mode
1388 :header-rows: 1
1389 :stub-columns: 0
1390
1391
1392 - .. row 1
1393
1394 - ID
1395
1396 - Description
1397
1398 - .. row 2
1399
1400 - .. _ATSCMH-SCCC-BLK-SEP:
1401
1402 ``ATSCMH_SCCC_BLK_SEP``
1403
1404 - Separate SCCC: the SCCC outer code mode shall be set independently
1405 for each Group Region (A, B, C, D)
1406
1407 - .. row 3
1408
1409 - .. _ATSCMH-SCCC-BLK-COMB:
1410
1411 ``ATSCMH_SCCC_BLK_COMB``
1412
1413 - Combined SCCC: all four Regions shall have the same SCCC outer
1414 code mode.
1415
1416 - .. row 4
1417
1418 - .. _ATSCMH-SCCC-BLK-RES:
1419
1420 ``ATSCMH_SCCC_BLK_RES``
1421 761
1422 - Reserved. Shouldn't be used. 762Series Concatenated Convolutional Code Block Mode.
1423 763
764The acceptable values are defined by :c:type:`atscmh_sccc_block_mode`.
1424 765
1425 766
1426.. _DTV-ATSCMH-SCCC-CODE-MODE-A: 767.. _DTV-ATSCMH-SCCC-CODE-MODE-A:
@@ -1428,55 +769,19 @@ Possible values are:
1428DTV_ATSCMH_SCCC_CODE_MODE_A 769DTV_ATSCMH_SCCC_CODE_MODE_A
1429--------------------------- 770---------------------------
1430 771
1431Series Concatenated Convolutional Code Rate. 772Used only on ATSC-MH.
1432
1433Possible values are:
1434
1435
1436.. c:type:: atscmh_sccc_code_mode
1437
1438.. flat-table:: enum atscmh_sccc_code_mode
1439 :header-rows: 1
1440 :stub-columns: 0
1441
1442
1443 - .. row 1
1444
1445 - ID
1446
1447 - Description
1448
1449 - .. row 2
1450
1451 - .. _ATSCMH-SCCC-CODE-HLF:
1452
1453 ``ATSCMH_SCCC_CODE_HLF``
1454
1455 - The outer code rate of a SCCC Block is 1/2 rate.
1456
1457 - .. row 3
1458
1459 - .. _ATSCMH-SCCC-CODE-QTR:
1460
1461 ``ATSCMH_SCCC_CODE_QTR``
1462
1463 - The outer code rate of a SCCC Block is 1/4 rate.
1464
1465 - .. row 4
1466
1467 - .. _ATSCMH-SCCC-CODE-RES:
1468
1469 ``ATSCMH_SCCC_CODE_RES``
1470
1471 - to be documented.
1472 773
774Series Concatenated Convolutional Code Rate.
1473 775
776The acceptable values are defined by :c:type:`atscmh_sccc_code_mode`.
1474 777
1475.. _DTV-ATSCMH-SCCC-CODE-MODE-B: 778.. _DTV-ATSCMH-SCCC-CODE-MODE-B:
1476 779
1477DTV_ATSCMH_SCCC_CODE_MODE_B 780DTV_ATSCMH_SCCC_CODE_MODE_B
1478--------------------------- 781---------------------------
1479 782
783Used only on ATSC-MH.
784
1480Series Concatenated Convolutional Code Rate. 785Series Concatenated Convolutional Code Rate.
1481 786
1482Possible values are the same as documented on enum 787Possible values are the same as documented on enum
@@ -1488,6 +793,8 @@ Possible values are the same as documented on enum
1488DTV_ATSCMH_SCCC_CODE_MODE_C 793DTV_ATSCMH_SCCC_CODE_MODE_C
1489--------------------------- 794---------------------------
1490 795
796Used only on ATSC-MH.
797
1491Series Concatenated Convolutional Code Rate. 798Series Concatenated Convolutional Code Rate.
1492 799
1493Possible values are the same as documented on enum 800Possible values are the same as documented on enum
@@ -1499,6 +806,8 @@ Possible values are the same as documented on enum
1499DTV_ATSCMH_SCCC_CODE_MODE_D 806DTV_ATSCMH_SCCC_CODE_MODE_D
1500--------------------------- 807---------------------------
1501 808
809Used only on ATSC-MH.
810
1502Series Concatenated Convolutional Code Rate. 811Series Concatenated Convolutional Code Rate.
1503 812
1504Possible values are the same as documented on enum 813Possible values are the same as documented on enum
@@ -1510,7 +819,7 @@ Possible values are the same as documented on enum
1510DTV_API_VERSION 819DTV_API_VERSION
1511=============== 820===============
1512 821
1513Returns the major/minor version of the DVB API 822Returns the major/minor version of the Digital TV API
1514 823
1515 824
1516.. _DTV-CODE-RATE-HP: 825.. _DTV-CODE-RATE-HP:
@@ -1518,8 +827,9 @@ Returns the major/minor version of the DVB API
1518DTV_CODE_RATE_HP 827DTV_CODE_RATE_HP
1519================ 828================
1520 829
1521Used on terrestrial transmissions. The acceptable values are the ones 830Used on terrestrial transmissions.
1522described at :c:type:`fe_transmit_mode`. 831
832The acceptable values are defined by :c:type:`fe_transmit_mode`.
1523 833
1524 834
1525.. _DTV-CODE-RATE-LP: 835.. _DTV-CODE-RATE-LP:
@@ -1527,8 +837,9 @@ described at :c:type:`fe_transmit_mode`.
1527DTV_CODE_RATE_LP 837DTV_CODE_RATE_LP
1528================ 838================
1529 839
1530Used on terrestrial transmissions. The acceptable values are the ones 840Used on terrestrial transmissions.
1531described at :c:type:`fe_transmit_mode`. 841
842The acceptable values are defined by :c:type:`fe_transmit_mode`.
1532 843
1533 844
1534.. _DTV-GUARD-INTERVAL: 845.. _DTV-GUARD-INTERVAL:
@@ -1536,242 +847,56 @@ described at :c:type:`fe_transmit_mode`.
1536DTV_GUARD_INTERVAL 847DTV_GUARD_INTERVAL
1537================== 848==================
1538 849
1539Possible values are: 850The acceptable values are defined by :c:type:`fe_guard_interval`.
1540
1541
1542.. c:type:: fe_guard_interval
1543
1544Modulation guard interval
1545-------------------------
1546
1547
1548.. flat-table:: enum fe_guard_interval
1549 :header-rows: 1
1550 :stub-columns: 0
1551
1552 851
1553 - .. row 1 852.. note::
1554
1555 - ID
1556
1557 - Description
1558
1559 - .. row 2
1560
1561 - .. _GUARD-INTERVAL-AUTO:
1562
1563 ``GUARD_INTERVAL_AUTO``
1564
1565 - Autodetect the guard interval
1566
1567 - .. row 3
1568
1569 - .. _GUARD-INTERVAL-1-128:
1570
1571 ``GUARD_INTERVAL_1_128``
1572
1573 - Guard interval 1/128
1574
1575 - .. row 4
1576
1577 - .. _GUARD-INTERVAL-1-32:
1578
1579 ``GUARD_INTERVAL_1_32``
1580
1581 - Guard interval 1/32
1582
1583 - .. row 5
1584
1585 - .. _GUARD-INTERVAL-1-16:
1586
1587 ``GUARD_INTERVAL_1_16``
1588
1589 - Guard interval 1/16
1590
1591 - .. row 6
1592
1593 - .. _GUARD-INTERVAL-1-8:
1594
1595 ``GUARD_INTERVAL_1_8``
1596
1597 - Guard interval 1/8
1598
1599 - .. row 7
1600
1601 - .. _GUARD-INTERVAL-1-4:
1602
1603 ``GUARD_INTERVAL_1_4``
1604
1605 - Guard interval 1/4
1606
1607 - .. row 8
1608
1609 - .. _GUARD-INTERVAL-19-128:
1610
1611 ``GUARD_INTERVAL_19_128``
1612
1613 - Guard interval 19/128
1614
1615 - .. row 9
1616
1617 - .. _GUARD-INTERVAL-19-256:
1618
1619 ``GUARD_INTERVAL_19_256``
1620
1621 - Guard interval 19/256
1622
1623 - .. row 10
1624
1625 - .. _GUARD-INTERVAL-PN420:
1626
1627 ``GUARD_INTERVAL_PN420``
1628
1629 - PN length 420 (1/4)
1630
1631 - .. row 11
1632
1633 - .. _GUARD-INTERVAL-PN595:
1634
1635 ``GUARD_INTERVAL_PN595``
1636
1637 - PN length 595 (1/6)
1638
1639 - .. row 12
1640
1641 - .. _GUARD-INTERVAL-PN945:
1642
1643 ``GUARD_INTERVAL_PN945``
1644
1645 - PN length 945 (1/9)
1646
1647
1648Notes:
1649
16501) If ``DTV_GUARD_INTERVAL`` is set the ``GUARD_INTERVAL_AUTO`` the
1651hardware will try to find the correct guard interval (if capable) and
1652will use TMCC to fill in the missing parameters.
1653
16542) Intervals 1/128, 19/128 and 19/256 are used only for DVB-T2 at
1655present
1656
16573) DTMB specifies PN420, PN595 and PN945.
1658 853
854 #. If ``DTV_GUARD_INTERVAL`` is set the ``GUARD_INTERVAL_AUTO`` the
855 hardware will try to find the correct guard interval (if capable) and
856 will use TMCC to fill in the missing parameters.
857 #. Intervals ``GUARD_INTERVAL_1_128``, ``GUARD_INTERVAL_19_128``
858 and ``GUARD_INTERVAL_19_256`` are used only for DVB-T2 at
859 present.
860 #. Intervals ``GUARD_INTERVAL_PN420``, ``GUARD_INTERVAL_PN595`` and
861 ``GUARD_INTERVAL_PN945`` are used only for DMTB at the present.
862 On such standard, only those intervals and ``GUARD_INTERVAL_AUTO``
863 are valid.
1659 864
1660.. _DTV-TRANSMISSION-MODE: 865.. _DTV-TRANSMISSION-MODE:
1661 866
1662DTV_TRANSMISSION_MODE 867DTV_TRANSMISSION_MODE
1663===================== 868=====================
1664 869
1665Specifies the number of carriers used by the standard. This is used only
1666on OFTM-based standards, e. g. DVB-T/T2, ISDB-T, DTMB
1667
1668
1669.. c:type:: fe_transmit_mode
1670
1671enum fe_transmit_mode: Number of carriers per channel
1672-----------------------------------------------------
1673
1674.. tabularcolumns:: |p{5.0cm}|p{12.5cm}|
1675
1676.. flat-table:: enum fe_transmit_mode
1677 :header-rows: 1
1678 :stub-columns: 0
1679
1680
1681 - .. row 1
1682
1683 - ID
1684
1685 - Description
1686
1687 - .. row 2
1688
1689 - .. _TRANSMISSION-MODE-AUTO:
1690
1691 ``TRANSMISSION_MODE_AUTO``
1692
1693 - Autodetect transmission mode. The hardware will try to find the
1694 correct FFT-size (if capable) to fill in the missing parameters.
1695
1696 - .. row 3
1697
1698 - .. _TRANSMISSION-MODE-1K:
1699
1700 ``TRANSMISSION_MODE_1K``
1701
1702 - Transmission mode 1K
1703
1704 - .. row 4
1705
1706 - .. _TRANSMISSION-MODE-2K:
1707
1708 ``TRANSMISSION_MODE_2K``
1709
1710 - Transmission mode 2K
1711
1712 - .. row 5
1713
1714 - .. _TRANSMISSION-MODE-8K:
1715
1716 ``TRANSMISSION_MODE_8K``
1717 870
1718 - Transmission mode 8K 871Used only on OFTM-based standards, e. g. DVB-T/T2, ISDB-T, DTMB.
1719 872
1720 - .. row 6 873Specifies the FFT size (with corresponds to the approximate number of
874carriers) used by the standard.
1721 875
1722 - .. _TRANSMISSION-MODE-4K: 876The acceptable values are defined by :c:type:`fe_transmit_mode`.
1723
1724 ``TRANSMISSION_MODE_4K``
1725
1726 - Transmission mode 4K
1727
1728 - .. row 7
1729
1730 - .. _TRANSMISSION-MODE-16K:
1731
1732 ``TRANSMISSION_MODE_16K``
1733
1734 - Transmission mode 16K
1735
1736 - .. row 8
1737
1738 - .. _TRANSMISSION-MODE-32K:
1739
1740 ``TRANSMISSION_MODE_32K``
1741
1742 - Transmission mode 32K
1743
1744 - .. row 9
1745
1746 - .. _TRANSMISSION-MODE-C1:
1747
1748 ``TRANSMISSION_MODE_C1``
1749
1750 - Single Carrier (C=1) transmission mode (DTMB)
1751
1752 - .. row 10
1753
1754 - .. _TRANSMISSION-MODE-C3780:
1755
1756 ``TRANSMISSION_MODE_C3780``
1757
1758 - Multi Carrier (C=3780) transmission mode (DTMB)
1759 877
878.. note::
1760 879
1761Notes: 880 #. ISDB-T supports three carrier/symbol-size: 8K, 4K, 2K. It is called
881 **mode** on such standard, and are numbered from 1 to 3:
1762 882
17631) ISDB-T supports three carrier/symbol-size: 8K, 4K, 2K. It is called 883 ==== ======== ========================
1764'mode' in the standard: Mode 1 is 2K, mode 2 is 4K, mode 3 is 8K 884 Mode FFT size Transmission mode
885 ==== ======== ========================
886 1 2K ``TRANSMISSION_MODE_2K``
887 2 4K ``TRANSMISSION_MODE_4K``
888 3 8K ``TRANSMISSION_MODE_8K``
889 ==== ======== ========================
1765 890
17662) If ``DTV_TRANSMISSION_MODE`` is set the ``TRANSMISSION_MODE_AUTO`` 891 #. If ``DTV_TRANSMISSION_MODE`` is set the ``TRANSMISSION_MODE_AUTO``
1767the hardware will try to find the correct FFT-size (if capable) and will 892 the hardware will try to find the correct FFT-size (if capable) and
1768use TMCC to fill in the missing parameters. 893 will use TMCC to fill in the missing parameters.
1769 894
17703) DVB-T specifies 2K and 8K as valid sizes. 895 #. DVB-T specifies 2K and 8K as valid sizes.
1771 896
17724) DVB-T2 specifies 1K, 2K, 4K, 8K, 16K and 32K. 897 #. DVB-T2 specifies 1K, 2K, 4K, 8K, 16K and 32K.
1773 898
17745) DTMB specifies C1 and C3780. 899 #. DTMB specifies C1 and C3780.
1775 900
1776 901
1777.. _DTV-HIERARCHY: 902.. _DTV-HIERARCHY:
@@ -1779,66 +904,11 @@ use TMCC to fill in the missing parameters.
1779DTV_HIERARCHY 904DTV_HIERARCHY
1780============= 905=============
1781 906
1782Frontend hierarchy 907Used only on DVB-T and DVB-T2.
1783
1784
1785.. c:type:: fe_hierarchy
1786
1787Frontend hierarchy
1788------------------
1789
1790
1791.. flat-table:: enum fe_hierarchy
1792 :header-rows: 1
1793 :stub-columns: 0
1794
1795
1796 - .. row 1
1797
1798 - ID
1799
1800 - Description
1801
1802 - .. row 2
1803
1804 - .. _HIERARCHY-NONE:
1805
1806 ``HIERARCHY_NONE``
1807
1808 - No hierarchy
1809
1810 - .. row 3
1811
1812 - .. _HIERARCHY-AUTO:
1813
1814 ``HIERARCHY_AUTO``
1815
1816 - Autodetect hierarchy (if supported)
1817
1818 - .. row 4
1819 908
1820 - .. _HIERARCHY-1: 909Frontend hierarchy.
1821
1822 ``HIERARCHY_1``
1823
1824 - Hierarchy 1
1825
1826 - .. row 5
1827
1828 - .. _HIERARCHY-2:
1829
1830 ``HIERARCHY_2``
1831
1832 - Hierarchy 2
1833
1834 - .. row 6
1835
1836 - .. _HIERARCHY-4:
1837
1838 ``HIERARCHY_4``
1839
1840 - Hierarchy 4
1841 910
911The acceptable values are defined by :c:type:`fe_hierarchy`.
1842 912
1843 913
1844.. _DTV-STREAM-ID: 914.. _DTV-STREAM-ID:
@@ -1846,8 +916,10 @@ Frontend hierarchy
1846DTV_STREAM_ID 916DTV_STREAM_ID
1847============= 917=============
1848 918
919Used on DVB-S2, DVB-T2 and ISDB-S.
920
1849DVB-S2, DVB-T2 and ISDB-S support the transmission of several streams on 921DVB-S2, DVB-T2 and ISDB-S support the transmission of several streams on
1850a single transport stream. This property enables the DVB driver to 922a single transport stream. This property enables the digital TV driver to
1851handle substream filtering, when supported by the hardware. By default, 923handle substream filtering, when supported by the hardware. By default,
1852substream filtering is disabled. 924substream filtering is disabled.
1853 925
@@ -1884,60 +956,17 @@ with it, rather than trying to use FE_GET_INFO. In the case of a
1884legacy frontend, the result is just the same as with FE_GET_INFO, but 956legacy frontend, the result is just the same as with FE_GET_INFO, but
1885in a more structured format 957in a more structured format
1886 958
959The acceptable values are defined by :c:type:`fe_delivery_system`.
960
1887 961
1888.. _DTV-INTERLEAVING: 962.. _DTV-INTERLEAVING:
1889 963
1890DTV_INTERLEAVING 964DTV_INTERLEAVING
1891================ 965================
1892 966
1893Time interleaving to be used. Currently, used only on DTMB. 967Time interleaving to be used.
1894
1895
1896.. c:type:: fe_interleaving
1897
1898.. flat-table:: enum fe_interleaving
1899 :header-rows: 1
1900 :stub-columns: 0
1901
1902
1903 - .. row 1
1904
1905 - ID
1906
1907 - Description
1908
1909 - .. row 2
1910
1911 - .. _INTERLEAVING-NONE:
1912
1913 ``INTERLEAVING_NONE``
1914
1915 - No interleaving.
1916
1917 - .. row 3
1918
1919 - .. _INTERLEAVING-AUTO:
1920
1921 ``INTERLEAVING_AUTO``
1922
1923 - Auto-detect interleaving.
1924
1925 - .. row 4
1926
1927 - .. _INTERLEAVING-240:
1928
1929 ``INTERLEAVING_240``
1930
1931 - Interleaving of 240 symbols.
1932
1933 - .. row 5
1934
1935 - .. _INTERLEAVING-720:
1936
1937 ``INTERLEAVING_720``
1938
1939 - Interleaving of 720 symbols.
1940 968
969The acceptable values are defined by :c:type:`fe_interleaving`.
1941 970
1942 971
1943.. _DTV-LNA: 972.. _DTV-LNA:
diff --git a/Documentation/media/uapi/dvb/frontend-header.rst b/Documentation/media/uapi/dvb/frontend-header.rst
new file mode 100644
index 000000000000..8d8433cf1e12
--- /dev/null
+++ b/Documentation/media/uapi/dvb/frontend-header.rst
@@ -0,0 +1,4 @@
1Frontend uAPI data types
2========================
3
4.. kernel-doc:: include/uapi/linux/dvb/frontend.h
diff --git a/Documentation/media/uapi/dvb/frontend-property-terrestrial-systems.rst b/Documentation/media/uapi/dvb/frontend-property-terrestrial-systems.rst
index dbc717cad9ee..0beb5cb3d729 100644
--- a/Documentation/media/uapi/dvb/frontend-property-terrestrial-systems.rst
+++ b/Documentation/media/uapi/dvb/frontend-property-terrestrial-systems.rst
@@ -100,7 +100,7 @@ to tune any ISDB-T/ISDB-Tsb hardware. Of course it is possible that some
100very sophisticated devices won't need certain parameters to tune. 100very sophisticated devices won't need certain parameters to tune.
101 101
102The information given here should help application writers to know how 102The information given here should help application writers to know how
103to handle ISDB-T and ISDB-Tsb hardware using the Linux DVB-API. 103to handle ISDB-T and ISDB-Tsb hardware using the Linux Digital TV API.
104 104
105The details given here about ISDB-T and ISDB-Tsb are just enough to 105The details given here about ISDB-T and ISDB-Tsb are just enough to
106basically show the dependencies between the needed parameter values, but 106basically show the dependencies between the needed parameter values, but
diff --git a/Documentation/media/uapi/dvb/frontend.rst b/Documentation/media/uapi/dvb/frontend.rst
index e051a9012540..4967c48d46ce 100644
--- a/Documentation/media/uapi/dvb/frontend.rst
+++ b/Documentation/media/uapi/dvb/frontend.rst
@@ -2,20 +2,22 @@
2 2
3.. _dvb_frontend: 3.. _dvb_frontend:
4 4
5################ 5#######################
6DVB Frontend API 6Digital TV Frontend API
7################ 7#######################
8The DVB frontend API was designed to support three types of delivery 8
9systems: 9The Digital TV frontend API was designed to support three groups of delivery
10systems: Terrestrial, cable and Satellite. Currently, the following
11delivery systems are supported:
10 12
11- Terrestrial systems: DVB-T, DVB-T2, ATSC, ATSC M/H, ISDB-T, DVB-H, 13- Terrestrial systems: DVB-T, DVB-T2, ATSC, ATSC M/H, ISDB-T, DVB-H,
12 DTMB, CMMB 14 DTMB, CMMB
13 15
14- Cable systems: DVB-C Annex A/C, ClearQAM (DVB-C Annex B), ISDB-C 16- Cable systems: DVB-C Annex A/C, ClearQAM (DVB-C Annex B)
15 17
16- Satellite systems: DVB-S, DVB-S2, DVB Turbo, ISDB-S, DSS 18- Satellite systems: DVB-S, DVB-S2, DVB Turbo, ISDB-S, DSS
17 19
18The DVB frontend controls several sub-devices including: 20The Digital TV frontend controls several sub-devices including:
19 21
20- Tuner 22- Tuner
21 23
@@ -23,7 +25,7 @@ The DVB frontend controls several sub-devices including:
23 25
24- Low noise amplifier (LNA) 26- Low noise amplifier (LNA)
25 27
26- Satellite Equipment Control (SEC) hardware (only for Satellite). 28- Satellite Equipment Control (SEC) [#f1]_.
27 29
28The frontend can be accessed through ``/dev/dvb/adapter?/frontend?``. 30The frontend can be accessed through ``/dev/dvb/adapter?/frontend?``.
29Data types and ioctl definitions can be accessed by including 31Data types and ioctl definitions can be accessed by including
@@ -31,16 +33,18 @@ Data types and ioctl definitions can be accessed by including
31 33
32.. note:: 34.. note::
33 35
34 Transmission via the internet (DVB-IP) is not yet handled by this 36 Transmission via the internet (DVB-IP) and MMT (MPEG Media Transport)
35 API but a future extension is possible. 37 is not yet handled by this API but a future extension is possible.
38
39.. [#f1]
36 40
37On Satellite systems, the API support for the Satellite Equipment 41 On Satellite systems, the API support for the Satellite Equipment
38Control (SEC) allows to power control and to send/receive signals to 42 Control (SEC) allows to power control and to send/receive signals to
39control the antenna subsystem, selecting the polarization and choosing 43 control the antenna subsystem, selecting the polarization and choosing
40the Intermediate Frequency IF) of the Low Noise Block Converter Feed 44 the Intermediate Frequency IF) of the Low Noise Block Converter Feed
41Horn (LNBf). It supports the DiSEqC and V-SEC protocols. The DiSEqC 45 Horn (LNBf). It supports the DiSEqC and V-SEC protocols. The DiSEqC
42(digital SEC) specification is available at 46 (digital SEC) specification is available at
43`Eutelsat <http://www.eutelsat.com/satellites/4_5_5.html>`__. 47 `Eutelsat <http://www.eutelsat.com/satellites/4_5_5.html>`__.
44 48
45 49
46.. toctree:: 50.. toctree::
@@ -50,4 +54,3 @@ Horn (LNBf). It supports the DiSEqC and V-SEC protocols. The DiSEqC
50 dvb-fe-read-status 54 dvb-fe-read-status
51 dvbproperty 55 dvbproperty
52 frontend_fcalls 56 frontend_fcalls
53 frontend_legacy_dvbv3_api
diff --git a/Documentation/media/uapi/dvb/frontend_f_close.rst b/Documentation/media/uapi/dvb/frontend_f_close.rst
index f3b04b60246c..67958d73cf34 100644
--- a/Documentation/media/uapi/dvb/frontend_f_close.rst
+++ b/Documentation/media/uapi/dvb/frontend_f_close.rst
@@ -2,9 +2,9 @@
2 2
3.. _frontend_f_close: 3.. _frontend_f_close:
4 4
5******************** 5***************************
6DVB frontend close() 6Digital TV frontend close()
7******************** 7***************************
8 8
9Name 9Name
10==== 10====
@@ -41,8 +41,10 @@ down automatically.
41Return Value 41Return Value
42============ 42============
43 43
44The function returns 0 on success, -1 on failure and the ``errno`` is 44On success 0 is returned.
45set appropriately. Possible error codes:
46 45
47EBADF 46On error -1 is returned, and the ``errno`` variable is set
48 ``fd`` is not a valid open file descriptor. 47appropriately.
48
49Generic error codes are described at the
50:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/frontend_f_open.rst b/Documentation/media/uapi/dvb/frontend_f_open.rst
index 690eb375bdc1..8e8cb466c24b 100644
--- a/Documentation/media/uapi/dvb/frontend_f_open.rst
+++ b/Documentation/media/uapi/dvb/frontend_f_open.rst
@@ -2,9 +2,9 @@
2 2
3.. _frontend_f_open: 3.. _frontend_f_open:
4 4
5******************* 5***************************
6DVB frontend open() 6Digital TV frontend open()
7******************* 7***************************
8 8
9Name 9Name
10==== 10====
@@ -79,24 +79,32 @@ On error, -1 is returned, and the ``errno`` variable is set appropriately.
79 79
80Possible error codes are: 80Possible error codes are:
81 81
82EACCES
83 The caller has no permission to access the device.
84 82
85EBUSY 83On success 0 is returned, and :c:type:`ca_slot_info` is filled.
86 The the device driver is already in use.
87 84
88ENXIO 85On error -1 is returned, and the ``errno`` variable is set
89 No device corresponding to this device special file exists. 86appropriately.
90 87
91ENOMEM 88.. tabularcolumns:: |p{2.5cm}|p{15.0cm}|
92 Not enough kernel memory was available to complete the request.
93 89
94EMFILE 90.. flat-table::
95 The process already has the maximum number of files open. 91 :header-rows: 0
92 :stub-columns: 0
93 :widths: 1 16
96 94
97ENFILE 95 - - ``EPERM``
98 The limit on the total number of files open on the system has been 96 - The caller has no permission to access the device.
99 reached.
100 97
101ENODEV 98 - - ``EBUSY``
102 The device got removed. 99 - The the device driver is already in use.
100
101 - - ``EMFILE``
102 - The process already has the maximum number of files open.
103
104 - - ``ENFILE``
105 - The limit on the total number of files open on the system has been
106 reached.
107
108
109The generic error codes are described at the
110:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/frontend_h.rst b/Documentation/media/uapi/dvb/frontend_h.rst
deleted file mode 100644
index 15fca04d1c32..000000000000
--- a/Documentation/media/uapi/dvb/frontend_h.rst
+++ /dev/null
@@ -1,9 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _frontend_h:
4
5************************
6DVB Frontend Header File
7************************
8
9.. kernel-include:: $BUILDDIR/frontend.h.rst
diff --git a/Documentation/media/uapi/dvb/frontend_legacy_dvbv3_api.rst b/Documentation/media/uapi/dvb/frontend_legacy_dvbv3_api.rst
index 7d4a091b7d7f..a4d5319cb76b 100644
--- a/Documentation/media/uapi/dvb/frontend_legacy_dvbv3_api.rst
+++ b/Documentation/media/uapi/dvb/frontend_legacy_dvbv3_api.rst
@@ -2,9 +2,9 @@
2 2
3.. _frontend_legacy_dvbv3_api: 3.. _frontend_legacy_dvbv3_api:
4 4
5**************************************** 5***********************************************
6DVB Frontend legacy API (a. k. a. DVBv3) 6Digital TV Frontend legacy API (a. k. a. DVBv3)
7**************************************** 7***********************************************
8 8
9The usage of this API is deprecated, as it doesn't support all digital 9The usage of this API is deprecated, as it doesn't support all digital
10TV standards, doesn't provide good statistics measurements and provides 10TV standards, doesn't provide good statistics measurements and provides
diff --git a/Documentation/media/uapi/dvb/headers.rst b/Documentation/media/uapi/dvb/headers.rst
new file mode 100644
index 000000000000..c13fd537fbff
--- /dev/null
+++ b/Documentation/media/uapi/dvb/headers.rst
@@ -0,0 +1,21 @@
1****************************
2Digital TV uAPI header files
3****************************
4
5Digital TV uAPI headers
6***********************
7
8.. kernel-include:: $BUILDDIR/frontend.h.rst
9
10.. kernel-include:: $BUILDDIR/dmx.h.rst
11
12.. kernel-include:: $BUILDDIR/ca.h.rst
13
14.. kernel-include:: $BUILDDIR/net.h.rst
15
16Legacy uAPI
17***********
18
19.. kernel-include:: $BUILDDIR/audio.h.rst
20
21.. kernel-include:: $BUILDDIR/video.h.rst
diff --git a/Documentation/media/uapi/dvb/intro.rst b/Documentation/media/uapi/dvb/intro.rst
index 652c4aacd2c6..79b4d0e4e920 100644
--- a/Documentation/media/uapi/dvb/intro.rst
+++ b/Documentation/media/uapi/dvb/intro.rst
@@ -13,15 +13,18 @@ What you need to know
13===================== 13=====================
14 14
15The reader of this document is required to have some knowledge in the 15The reader of this document is required to have some knowledge in the
16area of digital video broadcasting (DVB) and should be familiar with 16area of digital video broadcasting (Digital TV) and should be familiar with
17part I of the MPEG2 specification ISO/IEC 13818 (aka ITU-T H.222), i.e 17part I of the MPEG2 specification ISO/IEC 13818 (aka ITU-T H.222), i.e
18you should know what a program/transport stream (PS/TS) is and what is 18you should know what a program/transport stream (PS/TS) is and what is
19meant by a packetized elementary stream (PES) or an I-frame. 19meant by a packetized elementary stream (PES) or an I-frame.
20 20
21Various DVB standards documents are available from http://www.dvb.org 21Various Digital TV standards documents are available for download at:
22and/or http://www.etsi.org.
23 22
24It is also necessary to know how to access unix/linux devices and how to 23- European standards (DVB): http://www.dvb.org and/or http://www.etsi.org.
24- American standards (ATSC): https://www.atsc.org/standards/
25- Japanese standards (ISDB): http://www.dibeg.org/
26
27It is also necessary to know how to access Linux devices and how to
25use ioctl calls. This also includes the knowledge of C or C++. 28use ioctl calls. This also includes the knowledge of C or C++.
26 29
27 30
@@ -30,21 +33,25 @@ use ioctl calls. This also includes the knowledge of C or C++.
30History 33History
31======= 34=======
32 35
33The first API for DVB cards we used at Convergence in late 1999 was an 36The first API for Digital TV cards we used at Convergence in late 1999 was an
34extension of the Video4Linux API which was primarily developed for frame 37extension of the Video4Linux API which was primarily developed for frame
35grabber cards. As such it was not really well suited to be used for DVB 38grabber cards. As such it was not really well suited to be used for Digital
36cards and their new features like recording MPEG streams and filtering 39TV cards and their new features like recording MPEG streams and filtering
37several section and PES data streams at the same time. 40several section and PES data streams at the same time.
38 41
39In early 2000, we were approached by Nokia with a proposal for a new 42In early 2000, Convergence was approached by Nokia with a proposal for a new
40standard Linux DVB API. As a commitment to the development of terminals 43standard Linux Digital TV API. As a commitment to the development of terminals
41based on open standards, Nokia and Convergence made it available to all 44based on open standards, Nokia and Convergence made it available to all
42Linux developers and published it on https://linuxtv.org in September 45Linux developers and published it on https://linuxtv.org in September
432000. Convergence is the maintainer of the Linux DVB API. Together with 462000. With the Linux driver for the Siemens/Hauppauge DVB PCI card,
44the LinuxTV community (i.e. you, the reader of this document), the Linux 47Convergence provided a first implementation of the Linux Digital TV API.
45DVB API will be constantly reviewed and improved. With the Linux driver 48Convergence was the maintainer of the Linux Digital TV API in the early
46for the Siemens/Hauppauge DVB PCI card Convergence provides a first 49days.
47implementation of the Linux DVB API. 50
51Now, the API is maintained by the LinuxTV community (i.e. you, the reader
52of this document). The Linux Digital TV API is constantly reviewed and
53improved together with the improvements at the subsystem's core at the
54Kernel.
48 55
49 56
50.. _overview: 57.. _overview:
@@ -59,61 +66,65 @@ Overview
59 :alt: dvbstb.svg 66 :alt: dvbstb.svg
60 :align: center 67 :align: center
61 68
62 Components of a DVB card/STB 69 Components of a Digital TV card/STB
63 70
64A DVB PCI card or DVB set-top-box (STB) usually consists of the 71A Digital TV card or set-top-box (STB) usually consists of the
65following main hardware components: 72following main hardware components:
66 73
67- Frontend consisting of tuner and DVB demodulator 74Frontend consisting of tuner and digital TV demodulator
68 75 Here the raw signal reaches the digital TV hardware from a satellite dish or
69 Here the raw signal reaches the DVB hardware from a satellite dish or
70 antenna or directly from cable. The frontend down-converts and 76 antenna or directly from cable. The frontend down-converts and
71 demodulates this signal into an MPEG transport stream (TS). In case 77 demodulates this signal into an MPEG transport stream (TS). In case
72 of a satellite frontend, this includes a facility for satellite 78 of a satellite frontend, this includes a facility for satellite
73 equipment control (SEC), which allows control of LNB polarization, 79 equipment control (SEC), which allows control of LNB polarization,
74 multi feed switches or dish rotors. 80 multi feed switches or dish rotors.
75 81
76- Conditional Access (CA) hardware like CI adapters and smartcard slots 82Conditional Access (CA) hardware like CI adapters and smartcard slots
77
78 The complete TS is passed through the CA hardware. Programs to which 83 The complete TS is passed through the CA hardware. Programs to which
79 the user has access (controlled by the smart card) are decoded in 84 the user has access (controlled by the smart card) are decoded in
80 real time and re-inserted into the TS. 85 real time and re-inserted into the TS.
81 86
82- Demultiplexer which filters the incoming DVB stream 87 .. note::
83 88
89 Not every digital TV hardware provides conditional access hardware.
90
91Demultiplexer which filters the incoming Digital TV MPEG-TS stream
84 The demultiplexer splits the TS into its components like audio and 92 The demultiplexer splits the TS into its components like audio and
85 video streams. Besides usually several of such audio and video 93 video streams. Besides usually several of such audio and video
86 streams it also contains data streams with information about the 94 streams it also contains data streams with information about the
87 programs offered in this or other streams of the same provider. 95 programs offered in this or other streams of the same provider.
88 96
89- MPEG2 audio and video decoder 97Audio and video decoder
98 The main targets of the demultiplexer are audio and video
99 decoders. After decoding, they pass on the uncompressed audio and
100 video to the computer screen or to a TV set.
101
102 .. note::
90 103
91 The main targets of the demultiplexer are the MPEG2 audio and video 104 Modern hardware usually doesn't have a separate decoder hardware, as
92 decoders. After decoding they pass on the uncompressed audio and 105 such functionality can be provided by the main CPU, by the graphics
93 video to the computer screen or (through a PAL/NTSC encoder) to a TV 106 adapter of the system or by a signal processing hardware embedded on
94 set. 107 a Systems on a Chip (SoC) integrated circuit.
108
109 It may also not be needed for certain usages (e.g. for data-only
110 uses like “internet over satellite”).
95 111
96:ref:`stb_components` shows a crude schematic of the control and data 112:ref:`stb_components` shows a crude schematic of the control and data
97flow between those components. 113flow between those components.
98 114
99On a DVB PCI card not all of these have to be present since some
100functionality can be provided by the main CPU of the PC (e.g. MPEG
101picture and sound decoding) or is not needed (e.g. for data-only uses
102like “internet over satellite”). Also not every card or STB provides
103conditional access hardware.
104 115
105 116
106.. _dvb_devices: 117.. _dvb_devices:
107 118
108Linux DVB Devices 119Linux Digital TV Devices
109================= 120========================
110 121
111The Linux DVB API lets you control these hardware components through 122The Linux Digital TV API lets you control these hardware components through
112currently six Unix-style character devices for video, audio, frontend, 123currently six Unix-style character devices for video, audio, frontend,
113demux, CA and IP-over-DVB networking. The video and audio devices 124demux, CA and IP-over-DVB networking. The video and audio devices
114control the MPEG2 decoder hardware, the frontend device the tuner and 125control the MPEG2 decoder hardware, the frontend device the tuner and
115the DVB demodulator. The demux device gives you control over the PES and 126the Digital TV demodulator. The demux device gives you control over the PES
116section filters of the hardware. If the hardware does not support 127and section filters of the hardware. If the hardware does not support
117filtering these filters can be implemented in software. Finally, the CA 128filtering these filters can be implemented in software. Finally, the CA
118device controls all the conditional access capabilities of the hardware. 129device controls all the conditional access capabilities of the hardware.
119It can depend on the individual security requirements of the platform, 130It can depend on the individual security requirements of the platform,
@@ -137,9 +148,9 @@ individual devices are called:
137 148
138- ``/dev/dvb/adapterN/caM``, 149- ``/dev/dvb/adapterN/caM``,
139 150
140where N enumerates the DVB PCI cards in a system starting from 0, and M 151where ``N`` enumerates the Digital TV cards in a system starting from 0, and
141enumerates the devices of each type within each adapter, starting 152``M`` enumerates the devices of each type within each adapter, starting
142from 0, too. We will omit the “ ``/dev/dvb/adapterN/``\ ” in the further 153from 0, too. We will omit the “``/dev/dvb/adapterN/``\ ” in the further
143discussion of these devices. 154discussion of these devices.
144 155
145More details about the data structures and function calls of all the 156More details about the data structures and function calls of all the
@@ -151,8 +162,8 @@ devices are described in the following chapters.
151API include files 162API include files
152================= 163=================
153 164
154For each of the DVB devices a corresponding include file exists. The DVB 165For each of the Digital TV devices a corresponding include file exists. The
155API include files should be included in application sources with a 166Digital TV API include files should be included in application sources with a
156partial path like: 167partial path like:
157 168
158 169
diff --git a/Documentation/media/uapi/dvb/legacy_dvb_apis.rst b/Documentation/media/uapi/dvb/legacy_dvb_apis.rst
index 2957f5a988b0..e1b2c9c7b620 100644
--- a/Documentation/media/uapi/dvb/legacy_dvb_apis.rst
+++ b/Documentation/media/uapi/dvb/legacy_dvb_apis.rst
@@ -2,19 +2,31 @@
2 2
3.. _legacy_dvb_apis: 3.. _legacy_dvb_apis:
4 4
5******************* 5***************************
6DVB Deprecated APIs 6Digital TV Deprecated APIs
7******************* 7***************************
8 8
9The APIs described here are kept only for historical reasons. There's 9The APIs described here **should not** be used on new drivers or applications.
10just one driver for a very legacy hardware that uses this API. No modern 10
11drivers should use it. Instead, audio and video should be using the V4L2 11The DVBv3 frontend API has issues with new delivery systems, including
12and ALSA APIs, and the pipelines should be set using the Media 12DVB-S2, DVB-T2, ISDB, etc.
13Controller API 13
14There's just one driver for a very legacy hardware using the Digital TV
15audio and video APIs. No modern drivers should use it. Instead, audio and
16video should be using the V4L2 and ALSA APIs, and the pipelines should
17be set via the Media Controller API.
18
19.. attention::
20
21 The APIs described here doesn't necessarily reflect the current
22 code implementation, as this section of the document was written
23 for DVB version 1, while the code reflects DVB version 3
24 implementation.
14 25
15 26
16.. toctree:: 27.. toctree::
17 :maxdepth: 1 28 :maxdepth: 1
18 29
30 frontend_legacy_dvbv3_api
19 video 31 video
20 audio 32 audio
diff --git a/Documentation/media/uapi/dvb/net-add-if.rst b/Documentation/media/uapi/dvb/net-add-if.rst
index 82ce2438213f..6749b70246c5 100644
--- a/Documentation/media/uapi/dvb/net-add-if.rst
+++ b/Documentation/media/uapi/dvb/net-add-if.rst
@@ -41,43 +41,13 @@ created.
41The struct :c:type:`dvb_net_if`::ifnum field will be 41The struct :c:type:`dvb_net_if`::ifnum field will be
42filled with the number of the created interface. 42filled with the number of the created interface.
43 43
44.. c:type:: dvb_net_if
45
46.. flat-table:: struct dvb_net_if
47 :header-rows: 1
48 :stub-columns: 0
49
50
51 - .. row 1
52
53 - ID
54
55 - Description
56
57 - .. row 2
58
59 - pid
60
61 - Packet ID (PID) of the MPEG-TS that contains data
62
63 - .. row 3
64
65 - ifnum
66
67 - number of the DVB interface.
68
69 - .. row 4
70
71 - feedtype
72
73 - Encapsulation type of the feed. It can be:
74 ``DVB_NET_FEEDTYPE_MPE`` for MPE encoding or
75 ``DVB_NET_FEEDTYPE_ULE`` for ULE encoding.
76
77
78Return Value 44Return Value
79============ 45============
80 46
81On success 0 is returned, on error -1 and the ``errno`` variable is set 47On success 0 is returned, and :c:type:`ca_slot_info` is filled.
82appropriately. The generic error codes are described at the 48
49On error -1 is returned, and the ``errno`` variable is set
50appropriately.
51
52The generic error codes are described at the
83:ref:`Generic Error Codes <gen-errors>` chapter. 53:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/net-get-if.rst b/Documentation/media/uapi/dvb/net-get-if.rst
index 1bb8ee0cbced..3733b34da9db 100644
--- a/Documentation/media/uapi/dvb/net-get-if.rst
+++ b/Documentation/media/uapi/dvb/net-get-if.rst
@@ -43,6 +43,10 @@ the ``errno`` with ``EINVAL`` error code.
43Return Value 43Return Value
44============ 44============
45 45
46On success 0 is returned, on error -1 and the ``errno`` variable is set 46On success 0 is returned, and :c:type:`ca_slot_info` is filled.
47appropriately. The generic error codes are described at the 47
48On error -1 is returned, and the ``errno`` variable is set
49appropriately.
50
51The generic error codes are described at the
48:ref:`Generic Error Codes <gen-errors>` chapter. 52:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/net-remove-if.rst b/Documentation/media/uapi/dvb/net-remove-if.rst
index 646af23a925a..4ebe07a6b79a 100644
--- a/Documentation/media/uapi/dvb/net-remove-if.rst
+++ b/Documentation/media/uapi/dvb/net-remove-if.rst
@@ -39,6 +39,10 @@ The NET_REMOVE_IF ioctl deletes an interface previously created via
39Return Value 39Return Value
40============ 40============
41 41
42On success 0 is returned, on error -1 and the ``errno`` variable is set 42On success 0 is returned, and :c:type:`ca_slot_info` is filled.
43appropriately. The generic error codes are described at the 43
44On error -1 is returned, and the ``errno`` variable is set
45appropriately.
46
47The generic error codes are described at the
44:ref:`Generic Error Codes <gen-errors>` chapter. 48:ref:`Generic Error Codes <gen-errors>` chapter.
diff --git a/Documentation/media/uapi/dvb/net-types.rst b/Documentation/media/uapi/dvb/net-types.rst
new file mode 100644
index 000000000000..e1177bdcd623
--- /dev/null
+++ b/Documentation/media/uapi/dvb/net-types.rst
@@ -0,0 +1,9 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _dmx_types:
4
5**************
6Net Data Types
7**************
8
9.. kernel-doc:: include/uapi/linux/dvb/net.h
diff --git a/Documentation/media/uapi/dvb/net.rst b/Documentation/media/uapi/dvb/net.rst
index eca42dd53261..e0cd4e402627 100644
--- a/Documentation/media/uapi/dvb/net.rst
+++ b/Documentation/media/uapi/dvb/net.rst
@@ -2,10 +2,11 @@
2 2
3.. _net: 3.. _net:
4 4
5############### 5######################
6DVB Network API 6Digital TV Network API
7############### 7######################
8The DVB net device controls the mapping of data packages that are part 8
9The Digital TV net device controls the mapping of data packages that are part
9of a transport stream to be mapped into a virtual network interface, 10of a transport stream to be mapped into a virtual network interface,
10visible through the standard Linux network protocol stack. 11visible through the standard Linux network protocol stack.
11 12
@@ -28,13 +29,13 @@ header.
28 29
29.. _net_fcalls: 30.. _net_fcalls:
30 31
31###################### 32Digital TV net Function Calls
32DVB net Function Calls 33#############################
33######################
34 34
35.. toctree:: 35.. toctree::
36 :maxdepth: 1 36 :maxdepth: 1
37 37
38 net-types
38 net-add-if 39 net-add-if
39 net-remove-if 40 net-remove-if
40 net-get-if 41 net-get-if
diff --git a/Documentation/media/uapi/dvb/net_h.rst b/Documentation/media/uapi/dvb/net_h.rst
deleted file mode 100644
index 7bcf5ba9d1eb..000000000000
--- a/Documentation/media/uapi/dvb/net_h.rst
+++ /dev/null
@@ -1,9 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _net_h:
4
5***********************
6DVB Network Header File
7***********************
8
9.. kernel-include:: $BUILDDIR/net.h.rst
diff --git a/Documentation/media/uapi/dvb/query-dvb-frontend-info.rst b/Documentation/media/uapi/dvb/query-dvb-frontend-info.rst
index 81cd9b92a36c..51ec0b04b496 100644
--- a/Documentation/media/uapi/dvb/query-dvb-frontend-info.rst
+++ b/Documentation/media/uapi/dvb/query-dvb-frontend-info.rst
@@ -9,5 +9,5 @@ Querying frontend information
9Usually, the first thing to do when the frontend is opened is to check 9Usually, the first thing to do when the frontend is opened is to check
10the frontend capabilities. This is done using 10the frontend capabilities. This is done using
11:ref:`FE_GET_INFO`. This ioctl will enumerate the 11:ref:`FE_GET_INFO`. This ioctl will enumerate the
12DVB API version and other characteristics about the frontend, and can be 12Digital TV API version and other characteristics about the frontend, and can
13opened either in read only or read/write mode. 13be opened either in read only or read/write mode.
diff --git a/Documentation/media/uapi/dvb/video-continue.rst b/Documentation/media/uapi/dvb/video-continue.rst
index 030c2ec98869..e65e600be632 100644
--- a/Documentation/media/uapi/dvb/video-continue.rst
+++ b/Documentation/media/uapi/dvb/video-continue.rst
@@ -44,7 +44,7 @@ Arguments
44Description 44Description
45----------- 45-----------
46 46
47This ioctl is for DVB devices only. To control a V4L2 decoder use the 47This ioctl is for Digital TV devices only. To control a V4L2 decoder use the
48V4L2 :ref:`VIDIOC_DECODER_CMD` instead. 48V4L2 :ref:`VIDIOC_DECODER_CMD` instead.
49 49
50This ioctl call restarts decoding and playing processes of the video 50This ioctl call restarts decoding and playing processes of the video
diff --git a/Documentation/media/uapi/dvb/video-freeze.rst b/Documentation/media/uapi/dvb/video-freeze.rst
index 9cef65a02e8d..5a28bdc8badd 100644
--- a/Documentation/media/uapi/dvb/video-freeze.rst
+++ b/Documentation/media/uapi/dvb/video-freeze.rst
@@ -44,14 +44,14 @@ Arguments
44Description 44Description
45----------- 45-----------
46 46
47This ioctl is for DVB devices only. To control a V4L2 decoder use the 47This ioctl is for Digital TV devices only. To control a V4L2 decoder use the
48V4L2 :ref:`VIDIOC_DECODER_CMD` instead. 48V4L2 :ref:`VIDIOC_DECODER_CMD` instead.
49 49
50This ioctl call suspends the live video stream being played. Decoding 50This ioctl call suspends the live video stream being played. Decoding
51and playing are frozen. It is then possible to restart the decoding and 51and playing are frozen. It is then possible to restart the decoding and
52playing process of the video stream using the VIDEO_CONTINUE command. 52playing process of the video stream using the VIDEO_CONTINUE command.
53If VIDEO_SOURCE_MEMORY is selected in the ioctl call 53If VIDEO_SOURCE_MEMORY is selected in the ioctl call
54VIDEO_SELECT_SOURCE, the DVB subsystem will not decode any more data 54VIDEO_SELECT_SOURCE, the Digital TV subsystem will not decode any more data
55until the ioctl call VIDEO_CONTINUE or VIDEO_PLAY is performed. 55until the ioctl call VIDEO_CONTINUE or VIDEO_PLAY is performed.
56 56
57 57
diff --git a/Documentation/media/uapi/dvb/video-get-event.rst b/Documentation/media/uapi/dvb/video-get-event.rst
index 6ad14cdb894a..b4f53616db9a 100644
--- a/Documentation/media/uapi/dvb/video-get-event.rst
+++ b/Documentation/media/uapi/dvb/video-get-event.rst
@@ -50,7 +50,7 @@ Arguments
50Description 50Description
51----------- 51-----------
52 52
53This ioctl is for DVB devices only. To get events from a V4L2 decoder 53This ioctl is for Digital TV devices only. To get events from a V4L2 decoder
54use the V4L2 :ref:`VIDIOC_DQEVENT` ioctl instead. 54use the V4L2 :ref:`VIDIOC_DQEVENT` ioctl instead.
55 55
56This ioctl call returns an event of type video_event if available. If 56This ioctl call returns an event of type video_event if available. If
diff --git a/Documentation/media/uapi/dvb/video-play.rst b/Documentation/media/uapi/dvb/video-play.rst
index 3f66ae3b7e35..2124120aec22 100644
--- a/Documentation/media/uapi/dvb/video-play.rst
+++ b/Documentation/media/uapi/dvb/video-play.rst
@@ -44,7 +44,7 @@ Arguments
44Description 44Description
45----------- 45-----------
46 46
47This ioctl is for DVB devices only. To control a V4L2 decoder use the 47This ioctl is for Digital TV devices only. To control a V4L2 decoder use the
48V4L2 :ref:`VIDIOC_DECODER_CMD` instead. 48V4L2 :ref:`VIDIOC_DECODER_CMD` instead.
49 49
50This ioctl call asks the Video Device to start playing a video stream 50This ioctl call asks the Video Device to start playing a video stream
diff --git a/Documentation/media/uapi/dvb/video-select-source.rst b/Documentation/media/uapi/dvb/video-select-source.rst
index 2f4fbf4b490c..cde6542723ca 100644
--- a/Documentation/media/uapi/dvb/video-select-source.rst
+++ b/Documentation/media/uapi/dvb/video-select-source.rst
@@ -50,7 +50,7 @@ Arguments
50Description 50Description
51----------- 51-----------
52 52
53This ioctl is for DVB devices only. This ioctl was also supported by the 53This ioctl is for Digital TV devices only. This ioctl was also supported by the
54V4L2 ivtv driver, but that has been replaced by the ivtv-specific 54V4L2 ivtv driver, but that has been replaced by the ivtv-specific
55``IVTV_IOC_PASSTHROUGH_MODE`` ioctl. 55``IVTV_IOC_PASSTHROUGH_MODE`` ioctl.
56 56
diff --git a/Documentation/media/uapi/dvb/video-stop.rst b/Documentation/media/uapi/dvb/video-stop.rst
index fb827effb276..474309ad31c2 100644
--- a/Documentation/media/uapi/dvb/video-stop.rst
+++ b/Documentation/media/uapi/dvb/video-stop.rst
@@ -60,7 +60,7 @@ Arguments
60Description 60Description
61----------- 61-----------
62 62
63This ioctl is for DVB devices only. To control a V4L2 decoder use the 63This ioctl is for Digital TV devices only. To control a V4L2 decoder use the
64V4L2 :ref:`VIDIOC_DECODER_CMD` instead. 64V4L2 :ref:`VIDIOC_DECODER_CMD` instead.
65 65
66This ioctl call asks the Video Device to stop playing the current 66This ioctl call asks the Video Device to stop playing the current
diff --git a/Documentation/media/uapi/dvb/video.rst b/Documentation/media/uapi/dvb/video.rst
index 60d43fb7ce22..e7d68cd0cf23 100644
--- a/Documentation/media/uapi/dvb/video.rst
+++ b/Documentation/media/uapi/dvb/video.rst
@@ -2,20 +2,21 @@
2 2
3.. _dvb_video: 3.. _dvb_video:
4 4
5################ 5#######################
6DVB Video Device 6Digital TV Video Device
7################ 7#######################
8The DVB video device controls the MPEG2 video decoder of the DVB 8
9hardware. It can be accessed through **/dev/dvb/adapter0/video0**. Data 9The Digital TV video device controls the MPEG2 video decoder of the Digital
10TV hardware. It can be accessed through **/dev/dvb/adapter0/video0**. Data
10types and and ioctl definitions can be accessed by including 11types and and ioctl definitions can be accessed by including
11**linux/dvb/video.h** in your application. 12**linux/dvb/video.h** in your application.
12 13
13Note that the DVB video device only controls decoding of the MPEG video 14Note that the Digital TV video device only controls decoding of the MPEG video
14stream, not its presentation on the TV or computer screen. On PCs this 15stream, not its presentation on the TV or computer screen. On PCs this
15is typically handled by an associated video4linux device, e.g. 16is typically handled by an associated video4linux device, e.g.
16**/dev/video**, which allows scaling and defining output windows. 17**/dev/video**, which allows scaling and defining output windows.
17 18
18Some DVB cards don’t have their own MPEG decoder, which results in the 19Some Digital TV cards don’t have their own MPEG decoder, which results in the
19omission of the audio and video device as well as the video4linux 20omission of the audio and video device as well as the video4linux
20device. 21device.
21 22
diff --git a/Documentation/media/uapi/dvb/video_h.rst b/Documentation/media/uapi/dvb/video_h.rst
deleted file mode 100644
index 3f39b0c4879c..000000000000
--- a/Documentation/media/uapi/dvb/video_h.rst
+++ /dev/null
@@ -1,9 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _video_h:
4
5*********************
6DVB Video Header File
7*********************
8
9.. kernel-include:: $BUILDDIR/video.h.rst
diff --git a/Documentation/media/uapi/gen-errors.rst b/Documentation/media/uapi/gen-errors.rst
index d39e34d1b19d..689d3b101ede 100644
--- a/Documentation/media/uapi/gen-errors.rst
+++ b/Documentation/media/uapi/gen-errors.rst
@@ -17,9 +17,7 @@ Generic Error Codes
17 :widths: 1 16 17 :widths: 1 16
18 18
19 19
20 - .. row 1 20 - - ``EAGAIN`` (aka ``EWOULDBLOCK``)
21
22 - ``EAGAIN`` (aka ``EWOULDBLOCK``)
23 21
24 - The ioctl can't be handled because the device is in state where it 22 - The ioctl can't be handled because the device is in state where it
25 can't perform it. This could happen for example in case where 23 can't perform it. This could happen for example in case where
@@ -27,15 +25,11 @@ Generic Error Codes
27 is also returned when the ioctl would need to wait for an event, 25 is also returned when the ioctl would need to wait for an event,
28 but the device was opened in non-blocking mode. 26 but the device was opened in non-blocking mode.
29 27
30 - .. row 2 28 - - ``EBADF``
31
32 - ``EBADF``
33 29
34 - The file descriptor is not a valid. 30 - The file descriptor is not a valid.
35 31
36 - .. row 3 32 - - ``EBUSY``
37
38 - ``EBUSY``
39 33
40 - The ioctl can't be handled because the device is busy. This is 34 - The ioctl can't be handled because the device is busy. This is
41 typically return while device is streaming, and an ioctl tried to 35 typically return while device is streaming, and an ioctl tried to
@@ -44,64 +38,53 @@ Generic Error Codes
44 ioctl must not be retried without performing another action to fix 38 ioctl must not be retried without performing another action to fix
45 the problem first (typically: stop the stream before retrying). 39 the problem first (typically: stop the stream before retrying).
46 40
47 - .. row 4 41 - - ``EFAULT``
48
49 - ``EFAULT``
50 42
51 - There was a failure while copying data from/to userspace, probably 43 - There was a failure while copying data from/to userspace, probably
52 caused by an invalid pointer reference. 44 caused by an invalid pointer reference.
53 45
54 - .. row 5 46 - - ``EINVAL``
55
56 - ``EINVAL``
57 47
58 - One or more of the ioctl parameters are invalid or out of the 48 - One or more of the ioctl parameters are invalid or out of the
59 allowed range. This is a widely used error code. See the 49 allowed range. This is a widely used error code. See the
60 individual ioctl requests for specific causes. 50 individual ioctl requests for specific causes.
61 51
62 - .. row 6 52 - - ``ENODEV``
63
64 - ``ENODEV``
65 53
66 - Device not found or was removed. 54 - Device not found or was removed.
67 55
68 - .. row 7 56 - - ``ENOMEM``
69
70 - ``ENOMEM``
71 57
72 - There's not enough memory to handle the desired operation. 58 - There's not enough memory to handle the desired operation.
73 59
74 - .. row 8 60 - - ``ENOTTY``
75
76 - ``ENOTTY``
77 61
78 - The ioctl is not supported by the driver, actually meaning that 62 - The ioctl is not supported by the driver, actually meaning that
79 the required functionality is not available, or the file 63 the required functionality is not available, or the file
80 descriptor is not for a media device. 64 descriptor is not for a media device.
81 65
82 - .. row 9 66 - - ``ENOSPC``
83
84 - ``ENOSPC``
85 67
86 - On USB devices, the stream ioctl's can return this error, meaning 68 - On USB devices, the stream ioctl's can return this error, meaning
87 that this request would overcommit the usb bandwidth reserved for 69 that this request would overcommit the usb bandwidth reserved for
88 periodic transfers (up to 80% of the USB bandwidth). 70 periodic transfers (up to 80% of the USB bandwidth).
89 71
90 - .. row 10 72 - - ``EPERM``
91
92 - ``EPERM``
93 73
94 - Permission denied. Can be returned if the device needs write 74 - Permission denied. Can be returned if the device needs write
95 permission, or some special capabilities is needed (e. g. root) 75 permission, or some special capabilities is needed (e. g. root)
96 76
97 - .. row 11 77 - - ``EIO``
98
99 - ``EIO``
100 78
101 - I/O error. Typically used when there are problems communicating with 79 - I/O error. Typically used when there are problems communicating with
102 a hardware device. This could indicate broken or flaky hardware. 80 a hardware device. This could indicate broken or flaky hardware.
103 It's a 'Something is wrong, I give up!' type of error. 81 It's a 'Something is wrong, I give up!' type of error.
104 82
83 - - ``ENXIO``
84
85 - No device corresponding to this device special file exists.
86
87
105.. note:: 88.. note::
106 89
107 #. This list is not exhaustive; ioctls may return other error codes. 90 #. This list is not exhaustive; ioctls may return other error codes.
diff --git a/Documentation/media/uapi/mediactl/media-controller.rst b/Documentation/media/uapi/mediactl/media-controller.rst
index 7ae38d48969e..0eea4f9a07d5 100644
--- a/Documentation/media/uapi/mediactl/media-controller.rst
+++ b/Documentation/media/uapi/mediactl/media-controller.rst
@@ -8,7 +8,9 @@
8Part IV - Media Controller API 8Part IV - Media Controller API
9############################## 9##############################
10 10
11.. class:: toc-title 11.. only:: html
12
13 .. class:: toc-title
12 14
13 Table of Contents 15 Table of Contents
14 16
diff --git a/Documentation/media/uapi/mediactl/media-ioc-enum-entities.rst b/Documentation/media/uapi/mediactl/media-ioc-enum-entities.rst
index 0fd329279bef..b59ce149efb5 100644
--- a/Documentation/media/uapi/mediactl/media-ioc-enum-entities.rst
+++ b/Documentation/media/uapi/mediactl/media-ioc-enum-entities.rst
@@ -51,7 +51,7 @@ id's until they get an error.
51 51
52.. c:type:: media_entity_desc 52.. c:type:: media_entity_desc
53 53
54.. tabularcolumns:: |p{1.5cm}|p{1.5cm}|p{1.5cm}|p{1.5cm}|p{11.5cm}| 54.. tabularcolumns:: |p{1.5cm}|p{1.7cm}|p{1.6cm}|p{1.5cm}|p{11.2cm}|
55 55
56.. flat-table:: struct media_entity_desc 56.. flat-table:: struct media_entity_desc
57 :header-rows: 0 57 :header-rows: 0
diff --git a/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst b/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst
index add8281494f8..997e6b17440d 100644
--- a/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst
+++ b/Documentation/media/uapi/mediactl/media-ioc-g-topology.rst
@@ -46,7 +46,7 @@ other values untouched.
46If the ``topology_version`` remains the same, the ioctl should fill the 46If the ``topology_version`` remains the same, the ioctl should fill the
47desired arrays with the media graph elements. 47desired arrays with the media graph elements.
48 48
49.. tabularcolumns:: |p{1.6cm}|p{3.2cm}|p{12.7cm}| 49.. tabularcolumns:: |p{1.6cm}|p{3.4cm}|p{12.5cm}|
50 50
51.. c:type:: media_v2_topology 51.. c:type:: media_v2_topology
52 52
diff --git a/Documentation/media/uapi/mediactl/media-types.rst b/Documentation/media/uapi/mediactl/media-types.rst
index 71078565d644..8d64b0c06ebc 100644
--- a/Documentation/media/uapi/mediactl/media-types.rst
+++ b/Documentation/media/uapi/mediactl/media-types.rst
@@ -5,7 +5,7 @@
5Types and flags used to represent the media graph elements 5Types and flags used to represent the media graph elements
6========================================================== 6==========================================================
7 7
8.. tabularcolumns:: |p{8.0cm}|p{10.5cm}| 8.. tabularcolumns:: |p{8.2cm}|p{10.3cm}|
9 9
10.. _media-entity-type: 10.. _media-entity-type:
11 11
diff --git a/Documentation/media/uapi/rc/rc-sysfs-nodes.rst b/Documentation/media/uapi/rc/rc-sysfs-nodes.rst
index 3476ae29708f..2d01358d5504 100644
--- a/Documentation/media/uapi/rc/rc-sysfs-nodes.rst
+++ b/Documentation/media/uapi/rc/rc-sysfs-nodes.rst
@@ -34,9 +34,9 @@ receiver device where N is the number of the receiver.
34/sys/class/rc/rcN/protocols 34/sys/class/rc/rcN/protocols
35=========================== 35===========================
36 36
37Reading this file returns a list of available protocols, something like: 37Reading this file returns a list of available protocols, something like::
38 38
39``rc5 [rc6] nec jvc [sony]`` 39 rc5 [rc6] nec jvc [sony]
40 40
41Enabled protocols are shown in [] brackets. 41Enabled protocols are shown in [] brackets.
42 42
@@ -90,11 +90,11 @@ This value may be reset to 0 if the current protocol is altered.
90================================== 90==================================
91 91
92Reading this file returns a list of available protocols to use for the 92Reading this file returns a list of available protocols to use for the
93wakeup filter, something like: 93wakeup filter, something like::
94 94
95``rc-5 nec nec-x rc-6-0 rc-6-6a-24 [rc-6-6a-32] rc-6-mce`` 95 rc-5 nec nec-x rc-6-0 rc-6-6a-24 [rc-6-6a-32] rc-6-mce
96 96
97Note that protocol variants are listed, so "nec", "sony", "rc-5", "rc-6" 97Note that protocol variants are listed, so ``nec``, ``sony``, ``rc-5``, ``rc-6``
98have their different bit length encodings listed if available. 98have their different bit length encodings listed if available.
99 99
100Note that all protocol variants are listed. 100Note that all protocol variants are listed.
diff --git a/Documentation/media/uapi/rc/remote_controllers.rst b/Documentation/media/uapi/rc/remote_controllers.rst
index 3e25cc9f65e0..46a8acb82125 100644
--- a/Documentation/media/uapi/rc/remote_controllers.rst
+++ b/Documentation/media/uapi/rc/remote_controllers.rst
@@ -8,7 +8,9 @@
8Part III - Remote Controller API 8Part III - Remote Controller API
9################################ 9################################
10 10
11.. class:: toc-title 11.. only:: html
12
13 .. class:: toc-title
12 14
13 Table of Contents 15 Table of Contents
14 16
diff --git a/Documentation/media/uapi/v4l/pixfmt-006.rst b/Documentation/media/uapi/v4l/colorspaces-defs.rst
index 7ae7dcf73f63..410907fe9415 100644
--- a/Documentation/media/uapi/v4l/pixfmt-006.rst
+++ b/Documentation/media/uapi/v4l/colorspaces-defs.rst
@@ -76,6 +76,8 @@ whole range, 0-255, dividing the angular value by 1.41. The enum
76 76
77.. c:type:: v4l2_xfer_func 77.. c:type:: v4l2_xfer_func
78 78
79.. tabularcolumns:: |p{5.5cm}|p{12.0cm}|
80
79.. flat-table:: V4L2 Transfer Function 81.. flat-table:: V4L2 Transfer Function
80 :header-rows: 1 82 :header-rows: 1
81 :stub-columns: 0 83 :stub-columns: 0
@@ -97,7 +99,7 @@ whole range, 0-255, dividing the angular value by 1.41. The enum
97 * - ``V4L2_XFER_FUNC_DCI_P3`` 99 * - ``V4L2_XFER_FUNC_DCI_P3``
98 - Use the DCI-P3 transfer function. 100 - Use the DCI-P3 transfer function.
99 * - ``V4L2_XFER_FUNC_SMPTE2084`` 101 * - ``V4L2_XFER_FUNC_SMPTE2084``
100 - Use the SMPTE 2084 transfer function. 102 - Use the SMPTE 2084 transfer function. See :ref:`xf-smpte-2084`.
101 103
102 104
103 105
diff --git a/Documentation/media/uapi/v4l/pixfmt-007.rst b/Documentation/media/uapi/v4l/colorspaces-details.rst
index 0c30ee2577d3..b5d551b9cc8f 100644
--- a/Documentation/media/uapi/v4l/pixfmt-007.rst
+++ b/Documentation/media/uapi/v4l/colorspaces-details.rst
@@ -418,6 +418,11 @@ Inverse Transfer function:
418 418
419 L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081 419 L = \left( \frac{L' + 0.099}{1.099}\right) ^{\frac{1}{0.45} }\text{, for } L' \ge 0.081
420 420
421Please note that while Rec. 709 is defined as the default transfer function
422by the :ref:`itu2020` standard, in practice this colorspace is often used
423with the :ref:`xf-smpte-2084`. In particular Ultra HD Blu-ray discs use
424this combination.
425
421The luminance (Y') and color difference (Cb and Cr) are obtained with 426The luminance (Y') and color difference (Cb and Cr) are obtained with
422the following ``V4L2_YCBCR_ENC_BT2020`` encoding: 427the following ``V4L2_YCBCR_ENC_BT2020`` encoding:
423 428
@@ -758,3 +763,45 @@ scaled to [-128…128] and then clipped to [-128…127].
758 ``V4L2_COLORSPACE_JPEG`` can be considered to be an abbreviation for 763 ``V4L2_COLORSPACE_JPEG`` can be considered to be an abbreviation for
759 ``V4L2_COLORSPACE_SRGB``, ``V4L2_YCBCR_ENC_601`` and 764 ``V4L2_COLORSPACE_SRGB``, ``V4L2_YCBCR_ENC_601`` and
760 ``V4L2_QUANTIZATION_FULL_RANGE``. 765 ``V4L2_QUANTIZATION_FULL_RANGE``.
766
767***************************************
768Detailed Transfer Function Descriptions
769***************************************
770
771.. _xf-smpte-2084:
772
773Transfer Function SMPTE 2084 (V4L2_XFER_FUNC_SMPTE2084)
774=======================================================
775
776The :ref:`smpte2084` standard defines the transfer function used by
777High Dynamic Range content.
778
779Constants:
780 m1 = (2610 / 4096) / 4
781
782 m2 = (2523 / 4096) * 128
783
784 c1 = 3424 / 4096
785
786 c2 = (2413 / 4096) * 32
787
788 c3 = (2392 / 4096) * 32
789
790Transfer function:
791 L' = ((c1 + c2 * L\ :sup:`m1`) / (1 + c3 * L\ :sup:`m1`))\ :sup:`m2`
792
793Inverse Transfer function:
794 L = (max(L':sup:`1/m2` - c1, 0) / (c2 - c3 *
795 L'\ :sup:`1/m2`))\ :sup:`1/m1`
796
797Take care when converting between this transfer function and non-HDR transfer
798functions: the linear RGB values [0…1] of HDR content map to a luminance range
799of 0 to 10000 cd/m\ :sup:`2` whereas the linear RGB values of non-HDR (aka
800Standard Dynamic Range or SDR) map to a luminance range of 0 to 100 cd/m\ :sup:`2`.
801
802To go from SDR to HDR you will have to divide L by 100 first. To go in the other
803direction you will have to multiply L by 100. Of course, this clamps all
804luminance values over 100 cd/m\ :sup:`2` to 100 cd/m\ :sup:`2`.
805
806There are better methods, see e.g. :ref:`colimg` for more in-depth information
807about this.
diff --git a/Documentation/media/uapi/v4l/dev-meta.rst b/Documentation/media/uapi/v4l/dev-meta.rst
index 62518adfe37b..f7ac8d0d3af1 100644
--- a/Documentation/media/uapi/v4l/dev-meta.rst
+++ b/Documentation/media/uapi/v4l/dev-meta.rst
@@ -42,6 +42,8 @@ the :c:type:`v4l2_format` structure to 0.
42 42
43.. _v4l2-meta-format: 43.. _v4l2-meta-format:
44 44
45.. tabularcolumns:: |p{1.4cm}|p{2.2cm}|p{13.9cm}|
46
45.. flat-table:: struct v4l2_meta_format 47.. flat-table:: struct v4l2_meta_format
46 :header-rows: 0 48 :header-rows: 0
47 :stub-columns: 0 49 :stub-columns: 0
diff --git a/Documentation/media/uapi/v4l/dev-sliced-vbi.rst b/Documentation/media/uapi/v4l/dev-sliced-vbi.rst
index 5f6d534ea73b..9d6c860271cb 100644
--- a/Documentation/media/uapi/v4l/dev-sliced-vbi.rst
+++ b/Documentation/media/uapi/v4l/dev-sliced-vbi.rst
@@ -105,7 +105,13 @@ which may return ``EBUSY`` can be the
105struct v4l2_sliced_vbi_format 105struct v4l2_sliced_vbi_format
106----------------------------- 106-----------------------------
107 107
108.. tabularcolumns:: |p{1.0cm}|p{4.5cm}|p{4.0cm}|p{4.0cm}|p{4.0cm}| 108.. raw:: latex
109
110 \begingroup
111 \scriptsize
112 \setlength{\tabcolsep}{2pt}
113
114.. tabularcolumns:: |p{.75cm}|p{3.3cm}|p{3.4cm}|p{3.4cm}|p{3.4cm}|
109 115
110.. cssclass:: longtable 116.. cssclass:: longtable
111 117
@@ -199,6 +205,9 @@ struct v4l2_sliced_vbi_format
199 205
200 Applications and drivers must set it to zero. 206 Applications and drivers must set it to zero.
201 207
208.. raw:: latex
209
210 \endgroup
202 211
203.. _vbi-services2: 212.. _vbi-services2:
204 213
@@ -207,9 +216,9 @@ Sliced VBI services
207 216
208.. raw:: latex 217.. raw:: latex
209 218
210 \begin{adjustbox}{width=\columnwidth} 219 \footnotesize
211 220
212.. tabularcolumns:: |p{5.0cm}|p{1.4cm}|p{3.0cm}|p{2.5cm}|p{9.0cm}| 221.. tabularcolumns:: |p{4.1cm}|p{1.1cm}|p{2.4cm}|p{2.0cm}|p{7.3cm}|
213 222
214.. flat-table:: 223.. flat-table::
215 :header-rows: 1 224 :header-rows: 1
@@ -263,7 +272,7 @@ Sliced VBI services
263 272
264.. raw:: latex 273.. raw:: latex
265 274
266 \end{adjustbox}\newline\newline 275 \normalsize
267 276
268 277
269Drivers may return an ``EINVAL`` error code when applications attempt to 278Drivers may return an ``EINVAL`` error code when applications attempt to
@@ -457,7 +466,7 @@ number).
457struct v4l2_mpeg_vbi_fmt_ivtv 466struct v4l2_mpeg_vbi_fmt_ivtv
458----------------------------- 467-----------------------------
459 468
460.. tabularcolumns:: |p{1.0cm}|p{3.5cm}|p{1.0cm}|p{11.5cm}| 469.. tabularcolumns:: |p{1.0cm}|p{3.8cm}|p{1.0cm}|p{11.2cm}|
461 470
462.. flat-table:: 471.. flat-table::
463 :header-rows: 0 472 :header-rows: 0
@@ -525,7 +534,7 @@ Magic Constants for struct v4l2_mpeg_vbi_fmt_ivtv magic field
525structs v4l2_mpeg_vbi_itv0 and v4l2_mpeg_vbi_ITV0 534structs v4l2_mpeg_vbi_itv0 and v4l2_mpeg_vbi_ITV0
526------------------------------------------------- 535-------------------------------------------------
527 536
528.. tabularcolumns:: |p{4.4cm}|p{2.4cm}|p{10.7cm}| 537.. tabularcolumns:: |p{4.9cm}|p{2.4cm}|p{10.2cm}|
529 538
530.. flat-table:: 539.. flat-table::
531 :header-rows: 0 540 :header-rows: 0
@@ -574,7 +583,7 @@ structs v4l2_mpeg_vbi_itv0 and v4l2_mpeg_vbi_ITV0
574struct v4l2_mpeg_vbi_ITV0 583struct v4l2_mpeg_vbi_ITV0
575------------------------- 584-------------------------
576 585
577.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| 586.. tabularcolumns:: |p{4.9cm}|p{4.4cm}|p{8.2cm}|
578 587
579.. flat-table:: 588.. flat-table::
580 :header-rows: 0 589 :header-rows: 0
diff --git a/Documentation/media/uapi/v4l/dev-subdev.rst b/Documentation/media/uapi/v4l/dev-subdev.rst
index f0e762167730..d20d945803a7 100644
--- a/Documentation/media/uapi/v4l/dev-subdev.rst
+++ b/Documentation/media/uapi/v4l/dev-subdev.rst
@@ -204,9 +204,9 @@ list entity names and pad numbers).
204 204
205.. raw:: latex 205.. raw:: latex
206 206
207 \begin{adjustbox}{width=\columnwidth} 207 \tiny
208 208
209.. tabularcolumns:: |p{4.5cm}|p{4.5cm}|p{4.5cm}|p{4.5cm}|p{4.5cm}|p{4.5cm}|p{4.5cm}| 209.. tabularcolumns:: |p{2.0cm}|p{2.3cm}|p{2.3cm}|p{2.3cm}|p{2.3cm}|p{2.3cm}|p{2.3cm}|
210 210
211.. _sample-pipeline-config: 211.. _sample-pipeline-config:
212 212
@@ -253,7 +253,7 @@ list entity names and pad numbers).
253 253
254.. raw:: latex 254.. raw:: latex
255 255
256 \end{adjustbox}\newline\newline 256 \normalsize
257 257
2581. Initial state. The sensor source pad format is set to its native 3MP 2581. Initial state. The sensor source pad format is set to its native 3MP
259 size and V4L2_MBUS_FMT_SGRBG8_1X8 media bus code. Formats on the 259 size and V4L2_MBUS_FMT_SGRBG8_1X8 media bus code. Formats on the
@@ -370,7 +370,7 @@ circumstances. This may also cause the accessed rectangle to be adjusted
370by the driver, depending on the properties of the underlying hardware. 370by the driver, depending on the properties of the underlying hardware.
371 371
372The coordinates to a step always refer to the actual size of the 372The coordinates to a step always refer to the actual size of the
373previous step. The exception to this rule is the source compose 373previous step. The exception to this rule is the sink compose
374rectangle, which refers to the sink compose bounds rectangle --- if it 374rectangle, which refers to the sink compose bounds rectangle --- if it
375is supported by the hardware. 375is supported by the hardware.
376 376
diff --git a/Documentation/media/uapi/v4l/driver.rst b/Documentation/media/uapi/v4l/driver.rst
deleted file mode 100644
index 2319b383f0a4..000000000000
--- a/Documentation/media/uapi/v4l/driver.rst
+++ /dev/null
@@ -1,9 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _driver:
4
5***********************
6V4L2 Driver Programming
7***********************
8
9to do
diff --git a/Documentation/media/uapi/v4l/extended-controls.rst b/Documentation/media/uapi/v4l/extended-controls.rst
index 9acc9cad49e2..a3e81c1d276b 100644
--- a/Documentation/media/uapi/v4l/extended-controls.rst
+++ b/Documentation/media/uapi/v4l/extended-controls.rst
@@ -942,21 +942,21 @@ enum v4l2_mpeg_video_mpeg4_level -
942 :header-rows: 0 942 :header-rows: 0
943 :stub-columns: 0 943 :stub-columns: 0
944 944
945 * - ``V4L2_MPEG_VIDEO_LEVEL_0`` 945 * - ``V4L2_MPEG_VIDEO_MPEG4_LEVEL_0``
946 - Level 0 946 - Level 0
947 * - ``V4L2_MPEG_VIDEO_LEVEL_0B`` 947 * - ``V4L2_MPEG_VIDEO_MPEG4_LEVEL_0B``
948 - Level 0b 948 - Level 0b
949 * - ``V4L2_MPEG_VIDEO_LEVEL_1`` 949 * - ``V4L2_MPEG_VIDEO_MPEG4_LEVEL_1``
950 - Level 1 950 - Level 1
951 * - ``V4L2_MPEG_VIDEO_LEVEL_2`` 951 * - ``V4L2_MPEG_VIDEO_MPEG4_LEVEL_2``
952 - Level 2 952 - Level 2
953 * - ``V4L2_MPEG_VIDEO_LEVEL_3`` 953 * - ``V4L2_MPEG_VIDEO_MPEG4_LEVEL_3``
954 - Level 3 954 - Level 3
955 * - ``V4L2_MPEG_VIDEO_LEVEL_3B`` 955 * - ``V4L2_MPEG_VIDEO_MPEG4_LEVEL_3B``
956 - Level 3b 956 - Level 3b
957 * - ``V4L2_MPEG_VIDEO_LEVEL_4`` 957 * - ``V4L2_MPEG_VIDEO_MPEG4_LEVEL_4``
958 - Level 4 958 - Level 4
959 * - ``V4L2_MPEG_VIDEO_LEVEL_5`` 959 * - ``V4L2_MPEG_VIDEO_MPEG4_LEVEL_5``
960 - Level 5 960 - Level 5
961 961
962 962
@@ -1028,15 +1028,15 @@ enum v4l2_mpeg_video_mpeg4_profile -
1028 :header-rows: 0 1028 :header-rows: 0
1029 :stub-columns: 0 1029 :stub-columns: 0
1030 1030
1031 * - ``V4L2_MPEG_VIDEO_PROFILE_SIMPLE`` 1031 * - ``V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE``
1032 - Simple profile 1032 - Simple profile
1033 * - ``V4L2_MPEG_VIDEO_PROFILE_ADVANCED_SIMPLE`` 1033 * - ``V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_SIMPLE``
1034 - Advanced Simple profile 1034 - Advanced Simple profile
1035 * - ``V4L2_MPEG_VIDEO_PROFILE_CORE`` 1035 * - ``V4L2_MPEG_VIDEO_MPEG4_PROFILE_CORE``
1036 - Core profile 1036 - Core profile
1037 * - ``V4L2_MPEG_VIDEO_PROFILE_SIMPLE_SCALABLE`` 1037 * - ``V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE_SCALABLE``
1038 - Simple Scalable profile 1038 - Simple Scalable profile
1039 * - ``V4L2_MPEG_VIDEO_PROFILE_ADVANCED_CODING_EFFICIENCY`` 1039 * - ``V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_CODING_EFFICIENCY``
1040 - 1040 -
1041 1041
1042 1042
@@ -1922,9 +1922,9 @@ enum v4l2_vp8_golden_frame_sel -
1922 1922
1923.. raw:: latex 1923.. raw:: latex
1924 1924
1925 \begin{adjustbox}{width=\columnwidth} 1925 \footnotesize
1926 1926
1927.. tabularcolumns:: |p{11.0cm}|p{10.0cm}| 1927.. tabularcolumns:: |p{9.0cm}|p{8.0cm}|
1928 1928
1929.. flat-table:: 1929.. flat-table::
1930 :header-rows: 0 1930 :header-rows: 0
@@ -1940,7 +1940,7 @@ enum v4l2_vp8_golden_frame_sel -
1940 1940
1941.. raw:: latex 1941.. raw:: latex
1942 1942
1943 \end{adjustbox} 1943 \normalsize
1944 1944
1945 1945
1946``V4L2_CID_MPEG_VIDEO_VPX_MIN_QP (integer)`` 1946``V4L2_CID_MPEG_VIDEO_VPX_MIN_QP (integer)``
diff --git a/Documentation/media/uapi/v4l/format.rst b/Documentation/media/uapi/v4l/format.rst
index 452c6d59cad5..3e3efb0e349e 100644
--- a/Documentation/media/uapi/v4l/format.rst
+++ b/Documentation/media/uapi/v4l/format.rst
@@ -78,7 +78,7 @@ output devices is available. [#f1]_
78The :ref:`VIDIOC_ENUM_FMT` ioctl must be supported 78The :ref:`VIDIOC_ENUM_FMT` ioctl must be supported
79by all drivers exchanging image data with applications. 79by all drivers exchanging image data with applications.
80 80
81 **Important** 81.. important::
82 82
83 Drivers are not supposed to convert image formats in kernel space. 83 Drivers are not supposed to convert image formats in kernel space.
84 They must enumerate only formats directly supported by the hardware. 84 They must enumerate only formats directly supported by the hardware.
diff --git a/Documentation/media/uapi/v4l/pixfmt-008.rst b/Documentation/media/uapi/v4l/pixfmt-008.rst
deleted file mode 100644
index 4bec79784bdd..000000000000
--- a/Documentation/media/uapi/v4l/pixfmt-008.rst
+++ /dev/null
@@ -1,32 +0,0 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3***************************************
4Detailed Transfer Function Descriptions
5***************************************
6
7
8.. _xf-smpte-2084:
9
10Transfer Function SMPTE 2084 (V4L2_XFER_FUNC_SMPTE2084)
11=======================================================
12
13The :ref:`smpte2084` standard defines the transfer function used by
14High Dynamic Range content.
15
16Constants:
17 m1 = (2610 / 4096) / 4
18
19 m2 = (2523 / 4096) * 128
20
21 c1 = 3424 / 4096
22
23 c2 = (2413 / 4096) * 32
24
25 c3 = (2392 / 4096) * 32
26
27Transfer function:
28 L' = ((c1 + c2 * L\ :sup:`m1`) / (1 + c3 * L\ :sup:`m1`))\ :sup:`m2`
29
30Inverse Transfer function:
31 L = (max(L':sup:`1/m2` - c1, 0) / (c2 - c3 *
32 L'\ :sup:`1/m2`))\ :sup:`1/m1`
diff --git a/Documentation/media/uapi/v4l/pixfmt-013.rst b/Documentation/media/uapi/v4l/pixfmt-compressed.rst
index 728d7ede10fa..728d7ede10fa 100644
--- a/Documentation/media/uapi/v4l/pixfmt-013.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-compressed.rst
diff --git a/Documentation/media/uapi/v4l/pixfmt-004.rst b/Documentation/media/uapi/v4l/pixfmt-intro.rst
index 4bc116aa8193..4bc116aa8193 100644
--- a/Documentation/media/uapi/v4l/pixfmt-004.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-intro.rst
diff --git a/Documentation/media/uapi/v4l/pixfmt-inzi.rst b/Documentation/media/uapi/v4l/pixfmt-inzi.rst
index 9849e799f205..75272f80bc8a 100644
--- a/Documentation/media/uapi/v4l/pixfmt-inzi.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-inzi.rst
@@ -34,11 +34,12 @@ The second plane provides 16-bit per-pixel Depth data arranged in
34Each cell is a 16-bit word with more significant data stored at higher 34Each cell is a 16-bit word with more significant data stored at higher
35memory address (byte order is little-endian). 35memory address (byte order is little-endian).
36 36
37
37.. raw:: latex 38.. raw:: latex
38 39
39 \newline\newline\begin{adjustbox}{width=\columnwidth} 40 \small
40 41
41.. tabularcolumns:: |p{4.0cm}|p{4.0cm}|p{4.0cm}|p{4.0cm}|p{4.0cm}|p{4.0cm}| 42.. tabularcolumns:: |p{2.5cm}|p{2.5cm}|p{2.5cm}|p{2.5cm}|p{2.5cm}|p{2.5cm}|
42 43
43.. flat-table:: 44.. flat-table::
44 :header-rows: 0 45 :header-rows: 0
@@ -78,4 +79,4 @@ memory address (byte order is little-endian).
78 79
79.. raw:: latex 80.. raw:: latex
80 81
81 \end{adjustbox}\newline\newline 82 \normalsize
diff --git a/Documentation/media/uapi/v4l/pixfmt-m420.rst b/Documentation/media/uapi/v4l/pixfmt-m420.rst
index 7dd47c071e2f..6703f4079c3e 100644
--- a/Documentation/media/uapi/v4l/pixfmt-m420.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-m420.rst
@@ -66,7 +66,7 @@ Each cell is one byte.
66 - Cr\ :sub:`11` 66 - Cr\ :sub:`11`
67 67
68 68
69**Color Sample Location..** 69**Color Sample Location:**
70 70
71 71
72 72
diff --git a/Documentation/media/uapi/v4l/pixfmt-nv12.rst b/Documentation/media/uapi/v4l/pixfmt-nv12.rst
index 5b45a6d2ac95..2776b41377d5 100644
--- a/Documentation/media/uapi/v4l/pixfmt-nv12.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-nv12.rst
@@ -71,7 +71,7 @@ Each cell is one byte.
71 - Cr\ :sub:`11` 71 - Cr\ :sub:`11`
72 72
73 73
74**Color Sample Location..** 74**Color Sample Location:**
75 75
76.. flat-table:: 76.. flat-table::
77 :header-rows: 0 77 :header-rows: 0
diff --git a/Documentation/media/uapi/v4l/pixfmt-nv12m.rst b/Documentation/media/uapi/v4l/pixfmt-nv12m.rst
index de3051fd6b50..c1a2779f604c 100644
--- a/Documentation/media/uapi/v4l/pixfmt-nv12m.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-nv12m.rst
@@ -83,7 +83,7 @@ Each cell is one byte.
83 - Cr\ :sub:`11` 83 - Cr\ :sub:`11`
84 84
85 85
86**Color Sample Location..** 86**Color Sample Location:**
87 87
88 88
89 89
diff --git a/Documentation/media/uapi/v4l/pixfmt-nv16.rst b/Documentation/media/uapi/v4l/pixfmt-nv16.rst
index 8ceba79ff636..f0fdad3006cf 100644
--- a/Documentation/media/uapi/v4l/pixfmt-nv16.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-nv16.rst
@@ -79,7 +79,7 @@ Each cell is one byte.
79 - Cr\ :sub:`31` 79 - Cr\ :sub:`31`
80 80
81 81
82**Color Sample Location..** 82**Color Sample Location:**
83 83
84 84
85 85
diff --git a/Documentation/media/uapi/v4l/pixfmt-nv16m.rst b/Documentation/media/uapi/v4l/pixfmt-nv16m.rst
index 4d46ab39f9f1..c45f036763e7 100644
--- a/Documentation/media/uapi/v4l/pixfmt-nv16m.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-nv16m.rst
@@ -83,7 +83,7 @@ Each cell is one byte.
83 - Cr\ :sub:`32` 83 - Cr\ :sub:`32`
84 84
85 85
86**Color Sample Location..** 86**Color Sample Location:**
87 87
88 88
89 89
diff --git a/Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst b/Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst
index 3fdb34ce2f09..8edf65c80660 100644
--- a/Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-packed-hsv.rst
@@ -17,11 +17,14 @@ cylinder: 0 being the smallest value and 255 the maximum.
17 17
18The values are packed in 24 or 32 bit formats. 18The values are packed in 24 or 32 bit formats.
19 19
20
20.. raw:: latex 21.. raw:: latex
21 22
22 \newline\begin{adjustbox}{width=\columnwidth} 23 \begingroup
24 \tiny
25 \setlength{\tabcolsep}{2pt}
23 26
24.. tabularcolumns:: |p{4.2cm}|p{1.0cm}|p{0.7cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{1.7cm}| 27.. tabularcolumns:: |p{2.0cm}|p{0.54cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|
25 28
26.. _packed-hsv-formats: 29.. _packed-hsv-formats:
27 30
@@ -33,11 +36,8 @@ The values are packed in 24 or 32 bit formats.
33 - Code 36 - Code
34 - 37 -
35 - :cspan:`7` Byte 0 in memory 38 - :cspan:`7` Byte 0 in memory
36 -
37 - :cspan:`7` Byte 1 39 - :cspan:`7` Byte 1
38 -
39 - :cspan:`7` Byte 2 40 - :cspan:`7` Byte 2
40 -
41 - :cspan:`7` Byte 3 41 - :cspan:`7` Byte 3
42 * - 42 * -
43 - 43 -
@@ -50,7 +50,7 @@ The values are packed in 24 or 32 bit formats.
50 - 2 50 - 2
51 - 1 51 - 1
52 - 0 52 - 0
53 - 53
54 - 7 54 - 7
55 - 6 55 - 6
56 - 5 56 - 5
@@ -59,7 +59,7 @@ The values are packed in 24 or 32 bit formats.
59 - 2 59 - 2
60 - 1 60 - 1
61 - 0 61 - 0
62 - 62
63 - 7 63 - 7
64 - 6 64 - 6
65 - 5 65 - 5
@@ -68,7 +68,7 @@ The values are packed in 24 or 32 bit formats.
68 - 2 68 - 2
69 - 1 69 - 1
70 - 0 70 - 0
71 - 71
72 - 7 72 - 7
73 - 6 73 - 6
74 - 5 74 - 5
@@ -90,7 +90,7 @@ The values are packed in 24 or 32 bit formats.
90 - 90 -
91 - 91 -
92 - 92 -
93 - 93
94 - h\ :sub:`7` 94 - h\ :sub:`7`
95 - h\ :sub:`6` 95 - h\ :sub:`6`
96 - h\ :sub:`5` 96 - h\ :sub:`5`
@@ -99,7 +99,7 @@ The values are packed in 24 or 32 bit formats.
99 - h\ :sub:`2` 99 - h\ :sub:`2`
100 - h\ :sub:`1` 100 - h\ :sub:`1`
101 - h\ :sub:`0` 101 - h\ :sub:`0`
102 - 102
103 - s\ :sub:`7` 103 - s\ :sub:`7`
104 - s\ :sub:`6` 104 - s\ :sub:`6`
105 - s\ :sub:`5` 105 - s\ :sub:`5`
@@ -108,7 +108,7 @@ The values are packed in 24 or 32 bit formats.
108 - s\ :sub:`2` 108 - s\ :sub:`2`
109 - s\ :sub:`1` 109 - s\ :sub:`1`
110 - s\ :sub:`0` 110 - s\ :sub:`0`
111 - 111
112 - v\ :sub:`7` 112 - v\ :sub:`7`
113 - v\ :sub:`6` 113 - v\ :sub:`6`
114 - v\ :sub:`5` 114 - v\ :sub:`5`
@@ -130,7 +130,7 @@ The values are packed in 24 or 32 bit formats.
130 - h\ :sub:`2` 130 - h\ :sub:`2`
131 - h\ :sub:`1` 131 - h\ :sub:`1`
132 - h\ :sub:`0` 132 - h\ :sub:`0`
133 - 133
134 - s\ :sub:`7` 134 - s\ :sub:`7`
135 - s\ :sub:`6` 135 - s\ :sub:`6`
136 - s\ :sub:`5` 136 - s\ :sub:`5`
@@ -139,7 +139,7 @@ The values are packed in 24 or 32 bit formats.
139 - s\ :sub:`2` 139 - s\ :sub:`2`
140 - s\ :sub:`1` 140 - s\ :sub:`1`
141 - s\ :sub:`0` 141 - s\ :sub:`0`
142 - 142
143 - v\ :sub:`7` 143 - v\ :sub:`7`
144 - v\ :sub:`6` 144 - v\ :sub:`6`
145 - v\ :sub:`5` 145 - v\ :sub:`5`
@@ -149,9 +149,9 @@ The values are packed in 24 or 32 bit formats.
149 - v\ :sub:`1` 149 - v\ :sub:`1`
150 - v\ :sub:`0` 150 - v\ :sub:`0`
151 - 151 -
152 - 152
153.. raw:: latex 153.. raw:: latex
154 154
155 \end{adjustbox}\newline\newline 155 \endgroup
156 156
157Bit 7 is the most significant bit. 157Bit 7 is the most significant bit.
diff --git a/Documentation/media/uapi/v4l/pixfmt-packed-rgb.rst b/Documentation/media/uapi/v4l/pixfmt-packed-rgb.rst
index 84fcbcb74171..4938d9655a41 100644
--- a/Documentation/media/uapi/v4l/pixfmt-packed-rgb.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-packed-rgb.rst
@@ -16,9 +16,12 @@ next to each other in memory.
16 16
17.. raw:: latex 17.. raw:: latex
18 18
19 \begin{adjustbox}{width=\columnwidth} 19 \begingroup
20 \tiny
21 \setlength{\tabcolsep}{2pt}
22
23.. tabularcolumns:: |p{2.3cm}|p{1.6cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|
20 24
21.. tabularcolumns:: |p{4.5cm}|p{3.3cm}|p{0.7cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{1.7cm}|
22 25
23.. _rgb-formats: 26.. _rgb-formats:
24 27
@@ -28,17 +31,12 @@ next to each other in memory.
28 31
29 * - Identifier 32 * - Identifier
30 - Code 33 - Code
31 -
32 - :cspan:`7` Byte 0 in memory 34 - :cspan:`7` Byte 0 in memory
33 -
34 - :cspan:`7` Byte 1 35 - :cspan:`7` Byte 1
35 -
36 - :cspan:`7` Byte 2 36 - :cspan:`7` Byte 2
37 -
38 - :cspan:`7` Byte 3 37 - :cspan:`7` Byte 3
39 * - 38 * -
40 - 39 -
41 - Bit
42 - 7 40 - 7
43 - 6 41 - 6
44 - 5 42 - 5
@@ -47,7 +45,7 @@ next to each other in memory.
47 - 2 45 - 2
48 - 1 46 - 1
49 - 0 47 - 0
50 - 48
51 - 7 49 - 7
52 - 6 50 - 6
53 - 5 51 - 5
@@ -56,7 +54,7 @@ next to each other in memory.
56 - 2 54 - 2
57 - 1 55 - 1
58 - 0 56 - 0
59 - 57
60 - 7 58 - 7
61 - 6 59 - 6
62 - 5 60 - 5
@@ -65,7 +63,7 @@ next to each other in memory.
65 - 2 63 - 2
66 - 1 64 - 1
67 - 0 65 - 0
68 - 66
69 - 7 67 - 7
70 - 6 68 - 6
71 - 5 69 - 5
@@ -78,7 +76,7 @@ next to each other in memory.
78 76
79 - ``V4L2_PIX_FMT_RGB332`` 77 - ``V4L2_PIX_FMT_RGB332``
80 - 'RGB1' 78 - 'RGB1'
81 - 79
82 - r\ :sub:`2` 80 - r\ :sub:`2`
83 - r\ :sub:`1` 81 - r\ :sub:`1`
84 - r\ :sub:`0` 82 - r\ :sub:`0`
@@ -87,11 +85,12 @@ next to each other in memory.
87 - g\ :sub:`0` 85 - g\ :sub:`0`
88 - b\ :sub:`1` 86 - b\ :sub:`1`
89 - b\ :sub:`0` 87 - b\ :sub:`0`
88 -
90 * .. _V4L2-PIX-FMT-ARGB444: 89 * .. _V4L2-PIX-FMT-ARGB444:
91 90
92 - ``V4L2_PIX_FMT_ARGB444`` 91 - ``V4L2_PIX_FMT_ARGB444``
93 - 'AR12' 92 - 'AR12'
94 - 93
95 - g\ :sub:`3` 94 - g\ :sub:`3`
96 - g\ :sub:`2` 95 - g\ :sub:`2`
97 - g\ :sub:`1` 96 - g\ :sub:`1`
@@ -100,7 +99,7 @@ next to each other in memory.
100 - b\ :sub:`2` 99 - b\ :sub:`2`
101 - b\ :sub:`1` 100 - b\ :sub:`1`
102 - b\ :sub:`0` 101 - b\ :sub:`0`
103 - 102
104 - a\ :sub:`3` 103 - a\ :sub:`3`
105 - a\ :sub:`2` 104 - a\ :sub:`2`
106 - a\ :sub:`1` 105 - a\ :sub:`1`
@@ -109,11 +108,12 @@ next to each other in memory.
109 - r\ :sub:`2` 108 - r\ :sub:`2`
110 - r\ :sub:`1` 109 - r\ :sub:`1`
111 - r\ :sub:`0` 110 - r\ :sub:`0`
111 -
112 * .. _V4L2-PIX-FMT-XRGB444: 112 * .. _V4L2-PIX-FMT-XRGB444:
113 113
114 - ``V4L2_PIX_FMT_XRGB444`` 114 - ``V4L2_PIX_FMT_XRGB444``
115 - 'XR12' 115 - 'XR12'
116 - 116
117 - g\ :sub:`3` 117 - g\ :sub:`3`
118 - g\ :sub:`2` 118 - g\ :sub:`2`
119 - g\ :sub:`1` 119 - g\ :sub:`1`
@@ -122,7 +122,7 @@ next to each other in memory.
122 - b\ :sub:`2` 122 - b\ :sub:`2`
123 - b\ :sub:`1` 123 - b\ :sub:`1`
124 - b\ :sub:`0` 124 - b\ :sub:`0`
125 - 125
126 - 126 -
127 - 127 -
128 - 128 -
@@ -131,11 +131,12 @@ next to each other in memory.
131 - r\ :sub:`2` 131 - r\ :sub:`2`
132 - r\ :sub:`1` 132 - r\ :sub:`1`
133 - r\ :sub:`0` 133 - r\ :sub:`0`
134 -
134 * .. _V4L2-PIX-FMT-ARGB555: 135 * .. _V4L2-PIX-FMT-ARGB555:
135 136
136 - ``V4L2_PIX_FMT_ARGB555`` 137 - ``V4L2_PIX_FMT_ARGB555``
137 - 'AR15' 138 - 'AR15'
138 - 139
139 - g\ :sub:`2` 140 - g\ :sub:`2`
140 - g\ :sub:`1` 141 - g\ :sub:`1`
141 - g\ :sub:`0` 142 - g\ :sub:`0`
@@ -144,7 +145,7 @@ next to each other in memory.
144 - b\ :sub:`2` 145 - b\ :sub:`2`
145 - b\ :sub:`1` 146 - b\ :sub:`1`
146 - b\ :sub:`0` 147 - b\ :sub:`0`
147 - 148
148 - a 149 - a
149 - r\ :sub:`4` 150 - r\ :sub:`4`
150 - r\ :sub:`3` 151 - r\ :sub:`3`
@@ -153,11 +154,12 @@ next to each other in memory.
153 - r\ :sub:`0` 154 - r\ :sub:`0`
154 - g\ :sub:`4` 155 - g\ :sub:`4`
155 - g\ :sub:`3` 156 - g\ :sub:`3`
157 -
156 * .. _V4L2-PIX-FMT-XRGB555: 158 * .. _V4L2-PIX-FMT-XRGB555:
157 159
158 - ``V4L2_PIX_FMT_XRGB555`` 160 - ``V4L2_PIX_FMT_XRGB555``
159 - 'XR15' 161 - 'XR15'
160 - 162
161 - g\ :sub:`2` 163 - g\ :sub:`2`
162 - g\ :sub:`1` 164 - g\ :sub:`1`
163 - g\ :sub:`0` 165 - g\ :sub:`0`
@@ -166,7 +168,7 @@ next to each other in memory.
166 - b\ :sub:`2` 168 - b\ :sub:`2`
167 - b\ :sub:`1` 169 - b\ :sub:`1`
168 - b\ :sub:`0` 170 - b\ :sub:`0`
169 - 171
170 - 172 -
171 - r\ :sub:`4` 173 - r\ :sub:`4`
172 - r\ :sub:`3` 174 - r\ :sub:`3`
@@ -175,11 +177,12 @@ next to each other in memory.
175 - r\ :sub:`0` 177 - r\ :sub:`0`
176 - g\ :sub:`4` 178 - g\ :sub:`4`
177 - g\ :sub:`3` 179 - g\ :sub:`3`
180 -
178 * .. _V4L2-PIX-FMT-RGB565: 181 * .. _V4L2-PIX-FMT-RGB565:
179 182
180 - ``V4L2_PIX_FMT_RGB565`` 183 - ``V4L2_PIX_FMT_RGB565``
181 - 'RGBP' 184 - 'RGBP'
182 - 185
183 - g\ :sub:`2` 186 - g\ :sub:`2`
184 - g\ :sub:`1` 187 - g\ :sub:`1`
185 - g\ :sub:`0` 188 - g\ :sub:`0`
@@ -188,7 +191,7 @@ next to each other in memory.
188 - b\ :sub:`2` 191 - b\ :sub:`2`
189 - b\ :sub:`1` 192 - b\ :sub:`1`
190 - b\ :sub:`0` 193 - b\ :sub:`0`
191 - 194
192 - r\ :sub:`4` 195 - r\ :sub:`4`
193 - r\ :sub:`3` 196 - r\ :sub:`3`
194 - r\ :sub:`2` 197 - r\ :sub:`2`
@@ -197,11 +200,12 @@ next to each other in memory.
197 - g\ :sub:`5` 200 - g\ :sub:`5`
198 - g\ :sub:`4` 201 - g\ :sub:`4`
199 - g\ :sub:`3` 202 - g\ :sub:`3`
203 -
200 * .. _V4L2-PIX-FMT-ARGB555X: 204 * .. _V4L2-PIX-FMT-ARGB555X:
201 205
202 - ``V4L2_PIX_FMT_ARGB555X`` 206 - ``V4L2_PIX_FMT_ARGB555X``
203 - 'AR15' | (1 << 31) 207 - 'AR15' | (1 << 31)
204 - 208
205 - a 209 - a
206 - r\ :sub:`4` 210 - r\ :sub:`4`
207 - r\ :sub:`3` 211 - r\ :sub:`3`
@@ -210,7 +214,7 @@ next to each other in memory.
210 - r\ :sub:`0` 214 - r\ :sub:`0`
211 - g\ :sub:`4` 215 - g\ :sub:`4`
212 - g\ :sub:`3` 216 - g\ :sub:`3`
213 - 217
214 - g\ :sub:`2` 218 - g\ :sub:`2`
215 - g\ :sub:`1` 219 - g\ :sub:`1`
216 - g\ :sub:`0` 220 - g\ :sub:`0`
@@ -219,11 +223,12 @@ next to each other in memory.
219 - b\ :sub:`2` 223 - b\ :sub:`2`
220 - b\ :sub:`1` 224 - b\ :sub:`1`
221 - b\ :sub:`0` 225 - b\ :sub:`0`
226 -
222 * .. _V4L2-PIX-FMT-XRGB555X: 227 * .. _V4L2-PIX-FMT-XRGB555X:
223 228
224 - ``V4L2_PIX_FMT_XRGB555X`` 229 - ``V4L2_PIX_FMT_XRGB555X``
225 - 'XR15' | (1 << 31) 230 - 'XR15' | (1 << 31)
226 - 231
227 - 232 -
228 - r\ :sub:`4` 233 - r\ :sub:`4`
229 - r\ :sub:`3` 234 - r\ :sub:`3`
@@ -232,7 +237,7 @@ next to each other in memory.
232 - r\ :sub:`0` 237 - r\ :sub:`0`
233 - g\ :sub:`4` 238 - g\ :sub:`4`
234 - g\ :sub:`3` 239 - g\ :sub:`3`
235 - 240
236 - g\ :sub:`2` 241 - g\ :sub:`2`
237 - g\ :sub:`1` 242 - g\ :sub:`1`
238 - g\ :sub:`0` 243 - g\ :sub:`0`
@@ -241,11 +246,12 @@ next to each other in memory.
241 - b\ :sub:`2` 246 - b\ :sub:`2`
242 - b\ :sub:`1` 247 - b\ :sub:`1`
243 - b\ :sub:`0` 248 - b\ :sub:`0`
249 -
244 * .. _V4L2-PIX-FMT-RGB565X: 250 * .. _V4L2-PIX-FMT-RGB565X:
245 251
246 - ``V4L2_PIX_FMT_RGB565X`` 252 - ``V4L2_PIX_FMT_RGB565X``
247 - 'RGBR' 253 - 'RGBR'
248 - 254
249 - r\ :sub:`4` 255 - r\ :sub:`4`
250 - r\ :sub:`3` 256 - r\ :sub:`3`
251 - r\ :sub:`2` 257 - r\ :sub:`2`
@@ -254,7 +260,7 @@ next to each other in memory.
254 - g\ :sub:`5` 260 - g\ :sub:`5`
255 - g\ :sub:`4` 261 - g\ :sub:`4`
256 - g\ :sub:`3` 262 - g\ :sub:`3`
257 - 263
258 - g\ :sub:`2` 264 - g\ :sub:`2`
259 - g\ :sub:`1` 265 - g\ :sub:`1`
260 - g\ :sub:`0` 266 - g\ :sub:`0`
@@ -263,11 +269,12 @@ next to each other in memory.
263 - b\ :sub:`2` 269 - b\ :sub:`2`
264 - b\ :sub:`1` 270 - b\ :sub:`1`
265 - b\ :sub:`0` 271 - b\ :sub:`0`
272 -
266 * .. _V4L2-PIX-FMT-BGR24: 273 * .. _V4L2-PIX-FMT-BGR24:
267 274
268 - ``V4L2_PIX_FMT_BGR24`` 275 - ``V4L2_PIX_FMT_BGR24``
269 - 'BGR3' 276 - 'BGR3'
270 - 277
271 - b\ :sub:`7` 278 - b\ :sub:`7`
272 - b\ :sub:`6` 279 - b\ :sub:`6`
273 - b\ :sub:`5` 280 - b\ :sub:`5`
@@ -276,7 +283,7 @@ next to each other in memory.
276 - b\ :sub:`2` 283 - b\ :sub:`2`
277 - b\ :sub:`1` 284 - b\ :sub:`1`
278 - b\ :sub:`0` 285 - b\ :sub:`0`
279 - 286
280 - g\ :sub:`7` 287 - g\ :sub:`7`
281 - g\ :sub:`6` 288 - g\ :sub:`6`
282 - g\ :sub:`5` 289 - g\ :sub:`5`
@@ -285,7 +292,7 @@ next to each other in memory.
285 - g\ :sub:`2` 292 - g\ :sub:`2`
286 - g\ :sub:`1` 293 - g\ :sub:`1`
287 - g\ :sub:`0` 294 - g\ :sub:`0`
288 - 295
289 - r\ :sub:`7` 296 - r\ :sub:`7`
290 - r\ :sub:`6` 297 - r\ :sub:`6`
291 - r\ :sub:`5` 298 - r\ :sub:`5`
@@ -294,11 +301,12 @@ next to each other in memory.
294 - r\ :sub:`2` 301 - r\ :sub:`2`
295 - r\ :sub:`1` 302 - r\ :sub:`1`
296 - r\ :sub:`0` 303 - r\ :sub:`0`
304 -
297 * .. _V4L2-PIX-FMT-RGB24: 305 * .. _V4L2-PIX-FMT-RGB24:
298 306
299 - ``V4L2_PIX_FMT_RGB24`` 307 - ``V4L2_PIX_FMT_RGB24``
300 - 'RGB3' 308 - 'RGB3'
301 - 309
302 - r\ :sub:`7` 310 - r\ :sub:`7`
303 - r\ :sub:`6` 311 - r\ :sub:`6`
304 - r\ :sub:`5` 312 - r\ :sub:`5`
@@ -307,7 +315,7 @@ next to each other in memory.
307 - r\ :sub:`2` 315 - r\ :sub:`2`
308 - r\ :sub:`1` 316 - r\ :sub:`1`
309 - r\ :sub:`0` 317 - r\ :sub:`0`
310 - 318
311 - g\ :sub:`7` 319 - g\ :sub:`7`
312 - g\ :sub:`6` 320 - g\ :sub:`6`
313 - g\ :sub:`5` 321 - g\ :sub:`5`
@@ -316,7 +324,7 @@ next to each other in memory.
316 - g\ :sub:`2` 324 - g\ :sub:`2`
317 - g\ :sub:`1` 325 - g\ :sub:`1`
318 - g\ :sub:`0` 326 - g\ :sub:`0`
319 - 327
320 - b\ :sub:`7` 328 - b\ :sub:`7`
321 - b\ :sub:`6` 329 - b\ :sub:`6`
322 - b\ :sub:`5` 330 - b\ :sub:`5`
@@ -325,11 +333,12 @@ next to each other in memory.
325 - b\ :sub:`2` 333 - b\ :sub:`2`
326 - b\ :sub:`1` 334 - b\ :sub:`1`
327 - b\ :sub:`0` 335 - b\ :sub:`0`
336 -
328 * .. _V4L2-PIX-FMT-BGR666: 337 * .. _V4L2-PIX-FMT-BGR666:
329 338
330 - ``V4L2_PIX_FMT_BGR666`` 339 - ``V4L2_PIX_FMT_BGR666``
331 - 'BGRH' 340 - 'BGRH'
332 - 341
333 - b\ :sub:`5` 342 - b\ :sub:`5`
334 - b\ :sub:`4` 343 - b\ :sub:`4`
335 - b\ :sub:`3` 344 - b\ :sub:`3`
@@ -338,7 +347,7 @@ next to each other in memory.
338 - b\ :sub:`0` 347 - b\ :sub:`0`
339 - g\ :sub:`5` 348 - g\ :sub:`5`
340 - g\ :sub:`4` 349 - g\ :sub:`4`
341 - 350
342 - g\ :sub:`3` 351 - g\ :sub:`3`
343 - g\ :sub:`2` 352 - g\ :sub:`2`
344 - g\ :sub:`1` 353 - g\ :sub:`1`
@@ -347,7 +356,7 @@ next to each other in memory.
347 - r\ :sub:`4` 356 - r\ :sub:`4`
348 - r\ :sub:`3` 357 - r\ :sub:`3`
349 - r\ :sub:`2` 358 - r\ :sub:`2`
350 - 359
351 - r\ :sub:`1` 360 - r\ :sub:`1`
352 - r\ :sub:`0` 361 - r\ :sub:`0`
353 - 362 -
@@ -356,7 +365,7 @@ next to each other in memory.
356 - 365 -
357 - 366 -
358 - 367 -
359 - 368
360 - 369 -
361 - 370 -
362 - 371 -
@@ -369,7 +378,7 @@ next to each other in memory.
369 378
370 - ``V4L2_PIX_FMT_ABGR32`` 379 - ``V4L2_PIX_FMT_ABGR32``
371 - 'AR24' 380 - 'AR24'
372 - 381
373 - b\ :sub:`7` 382 - b\ :sub:`7`
374 - b\ :sub:`6` 383 - b\ :sub:`6`
375 - b\ :sub:`5` 384 - b\ :sub:`5`
@@ -378,7 +387,7 @@ next to each other in memory.
378 - b\ :sub:`2` 387 - b\ :sub:`2`
379 - b\ :sub:`1` 388 - b\ :sub:`1`
380 - b\ :sub:`0` 389 - b\ :sub:`0`
381 - 390
382 - g\ :sub:`7` 391 - g\ :sub:`7`
383 - g\ :sub:`6` 392 - g\ :sub:`6`
384 - g\ :sub:`5` 393 - g\ :sub:`5`
@@ -387,7 +396,7 @@ next to each other in memory.
387 - g\ :sub:`2` 396 - g\ :sub:`2`
388 - g\ :sub:`1` 397 - g\ :sub:`1`
389 - g\ :sub:`0` 398 - g\ :sub:`0`
390 - 399
391 - r\ :sub:`7` 400 - r\ :sub:`7`
392 - r\ :sub:`6` 401 - r\ :sub:`6`
393 - r\ :sub:`5` 402 - r\ :sub:`5`
@@ -396,7 +405,7 @@ next to each other in memory.
396 - r\ :sub:`2` 405 - r\ :sub:`2`
397 - r\ :sub:`1` 406 - r\ :sub:`1`
398 - r\ :sub:`0` 407 - r\ :sub:`0`
399 - 408
400 - a\ :sub:`7` 409 - a\ :sub:`7`
401 - a\ :sub:`6` 410 - a\ :sub:`6`
402 - a\ :sub:`5` 411 - a\ :sub:`5`
@@ -409,7 +418,7 @@ next to each other in memory.
409 418
410 - ``V4L2_PIX_FMT_XBGR32`` 419 - ``V4L2_PIX_FMT_XBGR32``
411 - 'XR24' 420 - 'XR24'
412 - 421
413 - b\ :sub:`7` 422 - b\ :sub:`7`
414 - b\ :sub:`6` 423 - b\ :sub:`6`
415 - b\ :sub:`5` 424 - b\ :sub:`5`
@@ -418,7 +427,7 @@ next to each other in memory.
418 - b\ :sub:`2` 427 - b\ :sub:`2`
419 - b\ :sub:`1` 428 - b\ :sub:`1`
420 - b\ :sub:`0` 429 - b\ :sub:`0`
421 - 430
422 - g\ :sub:`7` 431 - g\ :sub:`7`
423 - g\ :sub:`6` 432 - g\ :sub:`6`
424 - g\ :sub:`5` 433 - g\ :sub:`5`
@@ -427,7 +436,7 @@ next to each other in memory.
427 - g\ :sub:`2` 436 - g\ :sub:`2`
428 - g\ :sub:`1` 437 - g\ :sub:`1`
429 - g\ :sub:`0` 438 - g\ :sub:`0`
430 - 439
431 - r\ :sub:`7` 440 - r\ :sub:`7`
432 - r\ :sub:`6` 441 - r\ :sub:`6`
433 - r\ :sub:`5` 442 - r\ :sub:`5`
@@ -436,7 +445,7 @@ next to each other in memory.
436 - r\ :sub:`2` 445 - r\ :sub:`2`
437 - r\ :sub:`1` 446 - r\ :sub:`1`
438 - r\ :sub:`0` 447 - r\ :sub:`0`
439 - 448
440 - 449 -
441 - 450 -
442 - 451 -
@@ -449,7 +458,7 @@ next to each other in memory.
449 458
450 - ``V4L2_PIX_FMT_ARGB32`` 459 - ``V4L2_PIX_FMT_ARGB32``
451 - 'BA24' 460 - 'BA24'
452 - 461
453 - a\ :sub:`7` 462 - a\ :sub:`7`
454 - a\ :sub:`6` 463 - a\ :sub:`6`
455 - a\ :sub:`5` 464 - a\ :sub:`5`
@@ -458,7 +467,7 @@ next to each other in memory.
458 - a\ :sub:`2` 467 - a\ :sub:`2`
459 - a\ :sub:`1` 468 - a\ :sub:`1`
460 - a\ :sub:`0` 469 - a\ :sub:`0`
461 - 470
462 - r\ :sub:`7` 471 - r\ :sub:`7`
463 - r\ :sub:`6` 472 - r\ :sub:`6`
464 - r\ :sub:`5` 473 - r\ :sub:`5`
@@ -467,7 +476,7 @@ next to each other in memory.
467 - r\ :sub:`2` 476 - r\ :sub:`2`
468 - r\ :sub:`1` 477 - r\ :sub:`1`
469 - r\ :sub:`0` 478 - r\ :sub:`0`
470 - 479
471 - g\ :sub:`7` 480 - g\ :sub:`7`
472 - g\ :sub:`6` 481 - g\ :sub:`6`
473 - g\ :sub:`5` 482 - g\ :sub:`5`
@@ -476,7 +485,7 @@ next to each other in memory.
476 - g\ :sub:`2` 485 - g\ :sub:`2`
477 - g\ :sub:`1` 486 - g\ :sub:`1`
478 - g\ :sub:`0` 487 - g\ :sub:`0`
479 - 488
480 - b\ :sub:`7` 489 - b\ :sub:`7`
481 - b\ :sub:`6` 490 - b\ :sub:`6`
482 - b\ :sub:`5` 491 - b\ :sub:`5`
@@ -489,6 +498,7 @@ next to each other in memory.
489 498
490 - ``V4L2_PIX_FMT_XRGB32`` 499 - ``V4L2_PIX_FMT_XRGB32``
491 - 'BX24' 500 - 'BX24'
501
492 - 502 -
493 - 503 -
494 - 504 -
@@ -497,8 +507,7 @@ next to each other in memory.
497 - 507 -
498 - 508 -
499 - 509 -
500 - 510
501 -
502 - r\ :sub:`7` 511 - r\ :sub:`7`
503 - r\ :sub:`6` 512 - r\ :sub:`6`
504 - r\ :sub:`5` 513 - r\ :sub:`5`
@@ -507,7 +516,7 @@ next to each other in memory.
507 - r\ :sub:`2` 516 - r\ :sub:`2`
508 - r\ :sub:`1` 517 - r\ :sub:`1`
509 - r\ :sub:`0` 518 - r\ :sub:`0`
510 - 519
511 - g\ :sub:`7` 520 - g\ :sub:`7`
512 - g\ :sub:`6` 521 - g\ :sub:`6`
513 - g\ :sub:`5` 522 - g\ :sub:`5`
@@ -516,7 +525,7 @@ next to each other in memory.
516 - g\ :sub:`2` 525 - g\ :sub:`2`
517 - g\ :sub:`1` 526 - g\ :sub:`1`
518 - g\ :sub:`0` 527 - g\ :sub:`0`
519 - 528
520 - b\ :sub:`7` 529 - b\ :sub:`7`
521 - b\ :sub:`6` 530 - b\ :sub:`6`
522 - b\ :sub:`5` 531 - b\ :sub:`5`
@@ -528,7 +537,7 @@ next to each other in memory.
528 537
529.. raw:: latex 538.. raw:: latex
530 539
531 \end{adjustbox}\newline\newline 540 \endgroup
532 541
533.. note:: Bit 7 is the most significant bit. 542.. note:: Bit 7 is the most significant bit.
534 543
@@ -562,9 +571,9 @@ Each cell is one byte.
562 571
563.. raw:: latex 572.. raw:: latex
564 573
565 \newline\newline\begin{adjustbox}{width=\columnwidth} 574 \small
566 575
567.. tabularcolumns:: |p{4.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.1cm}|p{1.3cm}| 576.. tabularcolumns:: |p{3.1cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|p{0.8cm}|
568 577
569.. flat-table:: RGB byte order 578.. flat-table:: RGB byte order
570 :header-rows: 0 579 :header-rows: 0
@@ -626,19 +635,21 @@ Each cell is one byte.
626 635
627.. raw:: latex 636.. raw:: latex
628 637
629 \end{adjustbox}\newline\newline 638 \normalsize
630 639
631Formats defined in :ref:`rgb-formats-deprecated` are deprecated and 640Formats defined in :ref:`rgb-formats-deprecated` are deprecated and
632must not be used by new drivers. They are documented here for reference. 641must not be used by new drivers. They are documented here for reference.
633The meaning of their alpha bits (a) is ill-defined and interpreted as in 642The meaning of their alpha bits ``(a)`` are ill-defined and interpreted as in
634either the corresponding ARGB or XRGB format, depending on the driver. 643either the corresponding ARGB or XRGB format, depending on the driver.
635 644
636 645
637.. raw:: latex 646.. raw:: latex
638 647
639 \begin{adjustbox}{width=\columnwidth} 648 \begingroup
649 \tiny
650 \setlength{\tabcolsep}{2pt}
640 651
641.. tabularcolumns:: |p{4.2cm}|p{1.0cm}|p{0.7cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{1.7cm}| 652.. tabularcolumns:: |p{2.2cm}|p{0.60cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|
642 653
643.. _rgb-formats-deprecated: 654.. _rgb-formats-deprecated:
644 655
@@ -648,17 +659,15 @@ either the corresponding ARGB or XRGB format, depending on the driver.
648 659
649 * - Identifier 660 * - Identifier
650 - Code 661 - Code
651 -
652 - :cspan:`7` Byte 0 in memory 662 - :cspan:`7` Byte 0 in memory
653 - 663
654 - :cspan:`7` Byte 1 664 - :cspan:`7` Byte 1
655 - 665
656 - :cspan:`7` Byte 2 666 - :cspan:`7` Byte 2
657 - 667
658 - :cspan:`7` Byte 3 668 - :cspan:`7` Byte 3
659 * - 669 * -
660 - 670 -
661 - Bit
662 - 7 671 - 7
663 - 6 672 - 6
664 - 5 673 - 5
@@ -667,7 +676,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
667 - 2 676 - 2
668 - 1 677 - 1
669 - 0 678 - 0
670 - 679
671 - 7 680 - 7
672 - 6 681 - 6
673 - 5 682 - 5
@@ -676,7 +685,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
676 - 2 685 - 2
677 - 1 686 - 1
678 - 0 687 - 0
679 - 688
680 - 7 689 - 7
681 - 6 690 - 6
682 - 5 691 - 5
@@ -685,7 +694,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
685 - 2 694 - 2
686 - 1 695 - 1
687 - 0 696 - 0
688 - 697
689 - 7 698 - 7
690 - 6 699 - 6
691 - 5 700 - 5
@@ -698,7 +707,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
698 707
699 - ``V4L2_PIX_FMT_RGB444`` 708 - ``V4L2_PIX_FMT_RGB444``
700 - 'R444' 709 - 'R444'
701 - 710
702 - g\ :sub:`3` 711 - g\ :sub:`3`
703 - g\ :sub:`2` 712 - g\ :sub:`2`
704 - g\ :sub:`1` 713 - g\ :sub:`1`
@@ -707,7 +716,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
707 - b\ :sub:`2` 716 - b\ :sub:`2`
708 - b\ :sub:`1` 717 - b\ :sub:`1`
709 - b\ :sub:`0` 718 - b\ :sub:`0`
710 - 719
711 - a\ :sub:`3` 720 - a\ :sub:`3`
712 - a\ :sub:`2` 721 - a\ :sub:`2`
713 - a\ :sub:`1` 722 - a\ :sub:`1`
@@ -716,11 +725,12 @@ either the corresponding ARGB or XRGB format, depending on the driver.
716 - r\ :sub:`2` 725 - r\ :sub:`2`
717 - r\ :sub:`1` 726 - r\ :sub:`1`
718 - r\ :sub:`0` 727 - r\ :sub:`0`
728 -
719 * .. _V4L2-PIX-FMT-RGB555: 729 * .. _V4L2-PIX-FMT-RGB555:
720 730
721 - ``V4L2_PIX_FMT_RGB555`` 731 - ``V4L2_PIX_FMT_RGB555``
722 - 'RGBO' 732 - 'RGBO'
723 - 733
724 - g\ :sub:`2` 734 - g\ :sub:`2`
725 - g\ :sub:`1` 735 - g\ :sub:`1`
726 - g\ :sub:`0` 736 - g\ :sub:`0`
@@ -729,7 +739,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
729 - b\ :sub:`2` 739 - b\ :sub:`2`
730 - b\ :sub:`1` 740 - b\ :sub:`1`
731 - b\ :sub:`0` 741 - b\ :sub:`0`
732 - 742
733 - a 743 - a
734 - r\ :sub:`4` 744 - r\ :sub:`4`
735 - r\ :sub:`3` 745 - r\ :sub:`3`
@@ -738,11 +748,12 @@ either the corresponding ARGB or XRGB format, depending on the driver.
738 - r\ :sub:`0` 748 - r\ :sub:`0`
739 - g\ :sub:`4` 749 - g\ :sub:`4`
740 - g\ :sub:`3` 750 - g\ :sub:`3`
751 -
741 * .. _V4L2-PIX-FMT-RGB555X: 752 * .. _V4L2-PIX-FMT-RGB555X:
742 753
743 - ``V4L2_PIX_FMT_RGB555X`` 754 - ``V4L2_PIX_FMT_RGB555X``
744 - 'RGBQ' 755 - 'RGBQ'
745 - 756
746 - a 757 - a
747 - r\ :sub:`4` 758 - r\ :sub:`4`
748 - r\ :sub:`3` 759 - r\ :sub:`3`
@@ -751,7 +762,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
751 - r\ :sub:`0` 762 - r\ :sub:`0`
752 - g\ :sub:`4` 763 - g\ :sub:`4`
753 - g\ :sub:`3` 764 - g\ :sub:`3`
754 - 765
755 - g\ :sub:`2` 766 - g\ :sub:`2`
756 - g\ :sub:`1` 767 - g\ :sub:`1`
757 - g\ :sub:`0` 768 - g\ :sub:`0`
@@ -760,11 +771,12 @@ either the corresponding ARGB or XRGB format, depending on the driver.
760 - b\ :sub:`2` 771 - b\ :sub:`2`
761 - b\ :sub:`1` 772 - b\ :sub:`1`
762 - b\ :sub:`0` 773 - b\ :sub:`0`
774 -
763 * .. _V4L2-PIX-FMT-BGR32: 775 * .. _V4L2-PIX-FMT-BGR32:
764 776
765 - ``V4L2_PIX_FMT_BGR32`` 777 - ``V4L2_PIX_FMT_BGR32``
766 - 'BGR4' 778 - 'BGR4'
767 - 779
768 - b\ :sub:`7` 780 - b\ :sub:`7`
769 - b\ :sub:`6` 781 - b\ :sub:`6`
770 - b\ :sub:`5` 782 - b\ :sub:`5`
@@ -773,7 +785,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
773 - b\ :sub:`2` 785 - b\ :sub:`2`
774 - b\ :sub:`1` 786 - b\ :sub:`1`
775 - b\ :sub:`0` 787 - b\ :sub:`0`
776 - 788
777 - g\ :sub:`7` 789 - g\ :sub:`7`
778 - g\ :sub:`6` 790 - g\ :sub:`6`
779 - g\ :sub:`5` 791 - g\ :sub:`5`
@@ -782,7 +794,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
782 - g\ :sub:`2` 794 - g\ :sub:`2`
783 - g\ :sub:`1` 795 - g\ :sub:`1`
784 - g\ :sub:`0` 796 - g\ :sub:`0`
785 - 797
786 - r\ :sub:`7` 798 - r\ :sub:`7`
787 - r\ :sub:`6` 799 - r\ :sub:`6`
788 - r\ :sub:`5` 800 - r\ :sub:`5`
@@ -791,7 +803,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
791 - r\ :sub:`2` 803 - r\ :sub:`2`
792 - r\ :sub:`1` 804 - r\ :sub:`1`
793 - r\ :sub:`0` 805 - r\ :sub:`0`
794 - 806
795 - a\ :sub:`7` 807 - a\ :sub:`7`
796 - a\ :sub:`6` 808 - a\ :sub:`6`
797 - a\ :sub:`5` 809 - a\ :sub:`5`
@@ -804,7 +816,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
804 816
805 - ``V4L2_PIX_FMT_RGB32`` 817 - ``V4L2_PIX_FMT_RGB32``
806 - 'RGB4' 818 - 'RGB4'
807 - 819
808 - a\ :sub:`7` 820 - a\ :sub:`7`
809 - a\ :sub:`6` 821 - a\ :sub:`6`
810 - a\ :sub:`5` 822 - a\ :sub:`5`
@@ -813,7 +825,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
813 - a\ :sub:`2` 825 - a\ :sub:`2`
814 - a\ :sub:`1` 826 - a\ :sub:`1`
815 - a\ :sub:`0` 827 - a\ :sub:`0`
816 - 828
817 - r\ :sub:`7` 829 - r\ :sub:`7`
818 - r\ :sub:`6` 830 - r\ :sub:`6`
819 - r\ :sub:`5` 831 - r\ :sub:`5`
@@ -822,7 +834,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
822 - r\ :sub:`2` 834 - r\ :sub:`2`
823 - r\ :sub:`1` 835 - r\ :sub:`1`
824 - r\ :sub:`0` 836 - r\ :sub:`0`
825 - 837
826 - g\ :sub:`7` 838 - g\ :sub:`7`
827 - g\ :sub:`6` 839 - g\ :sub:`6`
828 - g\ :sub:`5` 840 - g\ :sub:`5`
@@ -831,7 +843,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
831 - g\ :sub:`2` 843 - g\ :sub:`2`
832 - g\ :sub:`1` 844 - g\ :sub:`1`
833 - g\ :sub:`0` 845 - g\ :sub:`0`
834 - 846
835 - b\ :sub:`7` 847 - b\ :sub:`7`
836 - b\ :sub:`6` 848 - b\ :sub:`6`
837 - b\ :sub:`5` 849 - b\ :sub:`5`
@@ -843,7 +855,7 @@ either the corresponding ARGB or XRGB format, depending on the driver.
843 855
844.. raw:: latex 856.. raw:: latex
845 857
846 \end{adjustbox}\newline\newline 858 \endgroup
847 859
848A test utility to determine which RGB formats a driver actually supports 860A test utility to determine which RGB formats a driver actually supports
849is available from the LinuxTV v4l-dvb repository. See 861is available from the LinuxTV v4l-dvb repository. See
diff --git a/Documentation/media/uapi/v4l/pixfmt-packed-yuv.rst b/Documentation/media/uapi/v4l/pixfmt-packed-yuv.rst
index ebc8fcc937ad..d7644b411ccc 100644
--- a/Documentation/media/uapi/v4l/pixfmt-packed-yuv.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-packed-yuv.rst
@@ -12,13 +12,16 @@ Description
12Similar to the packed RGB formats these formats store the Y, Cb and Cr 12Similar to the packed RGB formats these formats store the Y, Cb and Cr
13component of each pixel in one 16 or 32 bit word. 13component of each pixel in one 16 or 32 bit word.
14 14
15
15.. raw:: latex 16.. raw:: latex
16 17
17 \newline\newline\begin{adjustbox}{width=\columnwidth} 18 \begingroup
19 \tiny
20 \setlength{\tabcolsep}{2pt}
18 21
19.. _packed-yuv-formats: 22.. _packed-yuv-formats:
20 23
21.. tabularcolumns:: |p{4.5cm}|p{3.3cm}|p{0.7cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.2cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{0.4cm}|p{1.7cm}| 24.. tabularcolumns:: |p{2.0cm}|p{0.67cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|p{0.29cm}|
22 25
23.. flat-table:: Packed YUV Image Formats 26.. flat-table:: Packed YUV Image Formats
24 :header-rows: 2 27 :header-rows: 2
@@ -26,17 +29,16 @@ component of each pixel in one 16 or 32 bit word.
26 29
27 * - Identifier 30 * - Identifier
28 - Code 31 - Code
29 - 32
30 - :cspan:`7` Byte 0 in memory 33 - :cspan:`7` Byte 0 in memory
31 - 34
32 - :cspan:`7` Byte 1 35 - :cspan:`7` Byte 1
33 - 36
34 - :cspan:`7` Byte 2 37 - :cspan:`7` Byte 2
35 - 38
36 - :cspan:`7` Byte 3 39 - :cspan:`7` Byte 3
37 * - 40 * -
38 - 41 -
39 - Bit
40 - 7 42 - 7
41 - 6 43 - 6
42 - 5 44 - 5
@@ -45,7 +47,7 @@ component of each pixel in one 16 or 32 bit word.
45 - 2 47 - 2
46 - 1 48 - 1
47 - 0 49 - 0
48 - 50
49 - 7 51 - 7
50 - 6 52 - 6
51 - 5 53 - 5
@@ -54,7 +56,7 @@ component of each pixel in one 16 or 32 bit word.
54 - 2 56 - 2
55 - 1 57 - 1
56 - 0 58 - 0
57 - 59
58 - 7 60 - 7
59 - 6 61 - 6
60 - 5 62 - 5
@@ -63,7 +65,7 @@ component of each pixel in one 16 or 32 bit word.
63 - 2 65 - 2
64 - 1 66 - 1
65 - 0 67 - 0
66 - 68
67 - 7 69 - 7
68 - 6 70 - 6
69 - 5 71 - 5
@@ -76,7 +78,7 @@ component of each pixel in one 16 or 32 bit word.
76 78
77 - ``V4L2_PIX_FMT_YUV444`` 79 - ``V4L2_PIX_FMT_YUV444``
78 - 'Y444' 80 - 'Y444'
79 - 81
80 - Cb\ :sub:`3` 82 - Cb\ :sub:`3`
81 - Cb\ :sub:`2` 83 - Cb\ :sub:`2`
82 - Cb\ :sub:`1` 84 - Cb\ :sub:`1`
@@ -85,7 +87,7 @@ component of each pixel in one 16 or 32 bit word.
85 - Cr\ :sub:`2` 87 - Cr\ :sub:`2`
86 - Cr\ :sub:`1` 88 - Cr\ :sub:`1`
87 - Cr\ :sub:`0` 89 - Cr\ :sub:`0`
88 - 90
89 - a\ :sub:`3` 91 - a\ :sub:`3`
90 - a\ :sub:`2` 92 - a\ :sub:`2`
91 - a\ :sub:`1` 93 - a\ :sub:`1`
@@ -94,11 +96,12 @@ component of each pixel in one 16 or 32 bit word.
94 - Y'\ :sub:`2` 96 - Y'\ :sub:`2`
95 - Y'\ :sub:`1` 97 - Y'\ :sub:`1`
96 - Y'\ :sub:`0` 98 - Y'\ :sub:`0`
99 -
97 * .. _V4L2-PIX-FMT-YUV555: 100 * .. _V4L2-PIX-FMT-YUV555:
98 101
99 - ``V4L2_PIX_FMT_YUV555`` 102 - ``V4L2_PIX_FMT_YUV555``
100 - 'YUVO' 103 - 'YUVO'
101 - 104
102 - Cb\ :sub:`2` 105 - Cb\ :sub:`2`
103 - Cb\ :sub:`1` 106 - Cb\ :sub:`1`
104 - Cb\ :sub:`0` 107 - Cb\ :sub:`0`
@@ -107,7 +110,7 @@ component of each pixel in one 16 or 32 bit word.
107 - Cr\ :sub:`2` 110 - Cr\ :sub:`2`
108 - Cr\ :sub:`1` 111 - Cr\ :sub:`1`
109 - Cr\ :sub:`0` 112 - Cr\ :sub:`0`
110 - 113
111 - a 114 - a
112 - Y'\ :sub:`4` 115 - Y'\ :sub:`4`
113 - Y'\ :sub:`3` 116 - Y'\ :sub:`3`
@@ -116,11 +119,12 @@ component of each pixel in one 16 or 32 bit word.
116 - Y'\ :sub:`0` 119 - Y'\ :sub:`0`
117 - Cb\ :sub:`4` 120 - Cb\ :sub:`4`
118 - Cb\ :sub:`3` 121 - Cb\ :sub:`3`
122 -
119 * .. _V4L2-PIX-FMT-YUV565: 123 * .. _V4L2-PIX-FMT-YUV565:
120 124
121 - ``V4L2_PIX_FMT_YUV565`` 125 - ``V4L2_PIX_FMT_YUV565``
122 - 'YUVP' 126 - 'YUVP'
123 - 127
124 - Cb\ :sub:`2` 128 - Cb\ :sub:`2`
125 - Cb\ :sub:`1` 129 - Cb\ :sub:`1`
126 - Cb\ :sub:`0` 130 - Cb\ :sub:`0`
@@ -129,7 +133,7 @@ component of each pixel in one 16 or 32 bit word.
129 - Cr\ :sub:`2` 133 - Cr\ :sub:`2`
130 - Cr\ :sub:`1` 134 - Cr\ :sub:`1`
131 - Cr\ :sub:`0` 135 - Cr\ :sub:`0`
132 - 136
133 - Y'\ :sub:`4` 137 - Y'\ :sub:`4`
134 - Y'\ :sub:`3` 138 - Y'\ :sub:`3`
135 - Y'\ :sub:`2` 139 - Y'\ :sub:`2`
@@ -138,11 +142,12 @@ component of each pixel in one 16 or 32 bit word.
138 - Cb\ :sub:`5` 142 - Cb\ :sub:`5`
139 - Cb\ :sub:`4` 143 - Cb\ :sub:`4`
140 - Cb\ :sub:`3` 144 - Cb\ :sub:`3`
145 -
141 * .. _V4L2-PIX-FMT-YUV32: 146 * .. _V4L2-PIX-FMT-YUV32:
142 147
143 - ``V4L2_PIX_FMT_YUV32`` 148 - ``V4L2_PIX_FMT_YUV32``
144 - 'YUV4' 149 - 'YUV4'
145 - 150
146 - a\ :sub:`7` 151 - a\ :sub:`7`
147 - a\ :sub:`6` 152 - a\ :sub:`6`
148 - a\ :sub:`5` 153 - a\ :sub:`5`
@@ -151,7 +156,7 @@ component of each pixel in one 16 or 32 bit word.
151 - a\ :sub:`2` 156 - a\ :sub:`2`
152 - a\ :sub:`1` 157 - a\ :sub:`1`
153 - a\ :sub:`0` 158 - a\ :sub:`0`
154 - 159
155 - Y'\ :sub:`7` 160 - Y'\ :sub:`7`
156 - Y'\ :sub:`6` 161 - Y'\ :sub:`6`
157 - Y'\ :sub:`5` 162 - Y'\ :sub:`5`
@@ -160,7 +165,7 @@ component of each pixel in one 16 or 32 bit word.
160 - Y'\ :sub:`2` 165 - Y'\ :sub:`2`
161 - Y'\ :sub:`1` 166 - Y'\ :sub:`1`
162 - Y'\ :sub:`0` 167 - Y'\ :sub:`0`
163 - 168
164 - Cb\ :sub:`7` 169 - Cb\ :sub:`7`
165 - Cb\ :sub:`6` 170 - Cb\ :sub:`6`
166 - Cb\ :sub:`5` 171 - Cb\ :sub:`5`
@@ -169,7 +174,7 @@ component of each pixel in one 16 or 32 bit word.
169 - Cb\ :sub:`2` 174 - Cb\ :sub:`2`
170 - Cb\ :sub:`1` 175 - Cb\ :sub:`1`
171 - Cb\ :sub:`0` 176 - Cb\ :sub:`0`
172 - 177
173 - Cr\ :sub:`7` 178 - Cr\ :sub:`7`
174 - Cr\ :sub:`6` 179 - Cr\ :sub:`6`
175 - Cr\ :sub:`5` 180 - Cr\ :sub:`5`
@@ -181,7 +186,7 @@ component of each pixel in one 16 or 32 bit word.
181 186
182.. raw:: latex 187.. raw:: latex
183 188
184 \end{adjustbox}\newline\newline 189 \endgroup
185 190
186.. note:: 191.. note::
187 192
diff --git a/Documentation/media/uapi/v4l/pixfmt-rgb.rst b/Documentation/media/uapi/v4l/pixfmt-rgb.rst
index b0f35136021e..4cc27195dc79 100644
--- a/Documentation/media/uapi/v4l/pixfmt-rgb.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-rgb.rst
@@ -17,4 +17,5 @@ RGB Formats
17 pixfmt-srggb10alaw8 17 pixfmt-srggb10alaw8
18 pixfmt-srggb10dpcm8 18 pixfmt-srggb10dpcm8
19 pixfmt-srggb12 19 pixfmt-srggb12
20 pixfmt-srggb12p
20 pixfmt-srggb16 21 pixfmt-srggb16
diff --git a/Documentation/media/uapi/v4l/pixfmt-srggb10p.rst b/Documentation/media/uapi/v4l/pixfmt-srggb10p.rst
index b6d426c70ccd..d9e07a4b8b31 100644
--- a/Documentation/media/uapi/v4l/pixfmt-srggb10p.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-srggb10p.rst
@@ -33,11 +33,7 @@ of a small V4L2_PIX_FMT_SBGGR10P image:
33**Byte Order.** 33**Byte Order.**
34Each cell is one byte. 34Each cell is one byte.
35 35
36.. raw:: latex 36.. tabularcolumns:: |p{2.0cm}|p{1.0cm}|p{1.0cm}|p{1.0cm}|p{1.0cm}|p{5.4cm}|
37
38 \newline\newline\begin{adjustbox}{width=\columnwidth}
39
40.. tabularcolumns:: |p{2.0cm}|p{1.3cm}|p{1.3cm}|p{1.3cm}|p{1.3cm}|p{10.9cm}|
41 37
42.. flat-table:: 38.. flat-table::
43 :header-rows: 0 39 :header-rows: 0
@@ -50,6 +46,7 @@ Each cell is one byte.
50 - B\ :sub:`02high` 46 - B\ :sub:`02high`
51 - G\ :sub:`03high` 47 - G\ :sub:`03high`
52 - G\ :sub:`03low`\ (bits 7--6) B\ :sub:`02low`\ (bits 5--4) 48 - G\ :sub:`03low`\ (bits 7--6) B\ :sub:`02low`\ (bits 5--4)
49
53 G\ :sub:`01low`\ (bits 3--2) B\ :sub:`00low`\ (bits 1--0) 50 G\ :sub:`01low`\ (bits 3--2) B\ :sub:`00low`\ (bits 1--0)
54 * - start + 5: 51 * - start + 5:
55 - G\ :sub:`10high` 52 - G\ :sub:`10high`
@@ -57,6 +54,7 @@ Each cell is one byte.
57 - G\ :sub:`12high` 54 - G\ :sub:`12high`
58 - R\ :sub:`13high` 55 - R\ :sub:`13high`
59 - R\ :sub:`13low`\ (bits 7--6) G\ :sub:`12low`\ (bits 5--4) 56 - R\ :sub:`13low`\ (bits 7--6) G\ :sub:`12low`\ (bits 5--4)
57
60 R\ :sub:`11low`\ (bits 3--2) G\ :sub:`10low`\ (bits 1--0) 58 R\ :sub:`11low`\ (bits 3--2) G\ :sub:`10low`\ (bits 1--0)
61 * - start + 10: 59 * - start + 10:
62 - B\ :sub:`20high` 60 - B\ :sub:`20high`
@@ -64,6 +62,7 @@ Each cell is one byte.
64 - B\ :sub:`22high` 62 - B\ :sub:`22high`
65 - G\ :sub:`23high` 63 - G\ :sub:`23high`
66 - G\ :sub:`23low`\ (bits 7--6) B\ :sub:`22low`\ (bits 5--4) 64 - G\ :sub:`23low`\ (bits 7--6) B\ :sub:`22low`\ (bits 5--4)
65
67 G\ :sub:`21low`\ (bits 3--2) B\ :sub:`20low`\ (bits 1--0) 66 G\ :sub:`21low`\ (bits 3--2) B\ :sub:`20low`\ (bits 1--0)
68 * - start + 15: 67 * - start + 15:
69 - G\ :sub:`30high` 68 - G\ :sub:`30high`
@@ -71,8 +70,5 @@ Each cell is one byte.
71 - G\ :sub:`32high` 70 - G\ :sub:`32high`
72 - R\ :sub:`33high` 71 - R\ :sub:`33high`
73 - R\ :sub:`33low`\ (bits 7--6) G\ :sub:`32low`\ (bits 5--4) 72 - R\ :sub:`33low`\ (bits 7--6) G\ :sub:`32low`\ (bits 5--4)
74 R\ :sub:`31low`\ (bits 3--2) G\ :sub:`30low`\ (bits 1--0)
75 73
76.. raw:: latex 74 R\ :sub:`31low`\ (bits 3--2) G\ :sub:`30low`\ (bits 1--0)
77
78 \end{adjustbox}\newline\newline
diff --git a/Documentation/media/uapi/v4l/pixfmt-srggb12p.rst b/Documentation/media/uapi/v4l/pixfmt-srggb12p.rst
new file mode 100644
index 000000000000..59918a7913fe
--- /dev/null
+++ b/Documentation/media/uapi/v4l/pixfmt-srggb12p.rst
@@ -0,0 +1,86 @@
1.. -*- coding: utf-8; mode: rst -*-
2
3.. _V4L2-PIX-FMT-SRGGB12P:
4.. _v4l2-pix-fmt-sbggr12p:
5.. _v4l2-pix-fmt-sgbrg12p:
6.. _v4l2-pix-fmt-sgrbg12p:
7
8*******************************************************************************************************************************
9V4L2_PIX_FMT_SRGGB12P ('pRAA'), V4L2_PIX_FMT_SGRBG12P ('pgAA'), V4L2_PIX_FMT_SGBRG12P ('pGAA'), V4L2_PIX_FMT_SBGGR12P ('pBAA'),
10*******************************************************************************************************************************
11
12
1312-bit packed Bayer formats
14
15
16Description
17===========
18
19These four pixel formats are packed raw sRGB / Bayer formats with 12
20bits per colour. Every two consecutive samples are packed into three
21bytes. Each of the first two bytes contain the 8 high order bits of
22the pixels, and the third byte contains the four least significants
23bits of each pixel, in the same order.
24
25Each n-pixel row contains n/2 green samples and n/2 blue or red
26samples, with alternating green-red and green-blue rows. They are
27conventionally described as GRGR... BGBG..., RGRG... GBGB..., etc.
28Below is an example of a small V4L2_PIX_FMT_SBGGR12P image:
29
30**Byte Order.**
31Each cell is one byte.
32
33.. tabularcolumns:: |p{2.0cm}|p{1.0cm}|p{1.0cm}|p{2.7cm}|p{1.0cm}|p{1.0cm}|p{2.7cm}|
34
35
36.. flat-table::
37 :header-rows: 0
38 :stub-columns: 0
39 :widths: 2 1 1 1 1 1 1
40
41
42 - - start + 0:
43 - B\ :sub:`00high`
44 - G\ :sub:`01high`
45 - G\ :sub:`01low`\ (bits 7--4)
46
47 B\ :sub:`00low`\ (bits 3--0)
48 - B\ :sub:`02high`
49 - G\ :sub:`03high`
50 - G\ :sub:`03low`\ (bits 7--4)
51
52 B\ :sub:`02low`\ (bits 3--0)
53
54 - - start + 6:
55 - G\ :sub:`10high`
56 - R\ :sub:`11high`
57 - R\ :sub:`11low`\ (bits 7--4)
58
59 G\ :sub:`10low`\ (bits 3--0)
60 - G\ :sub:`12high`
61 - R\ :sub:`13high`
62 - R\ :sub:`13low`\ (bits 3--2)
63
64 G\ :sub:`12low`\ (bits 3--0)
65 - - start + 12:
66 - B\ :sub:`20high`
67 - G\ :sub:`21high`
68 - G\ :sub:`21low`\ (bits 7--4)
69
70 B\ :sub:`20low`\ (bits 3--0)
71 - B\ :sub:`22high`
72 - G\ :sub:`23high`
73 - G\ :sub:`23low`\ (bits 7--4)
74
75 B\ :sub:`22low`\ (bits 3--0)
76 - - start + 18:
77 - G\ :sub:`30high`
78 - R\ :sub:`31high`
79 - R\ :sub:`31low`\ (bits 7--4)
80
81 G\ :sub:`30low`\ (bits 3--0)
82 - G\ :sub:`32high`
83 - R\ :sub:`33high`
84 - R\ :sub:`33low`\ (bits 3--2)
85
86 G\ :sub:`32low`\ (bits 3--0)
diff --git a/Documentation/media/uapi/v4l/pixfmt-uyvy.rst b/Documentation/media/uapi/v4l/pixfmt-uyvy.rst
index 30660e04dd0e..ecdc2d94c209 100644
--- a/Documentation/media/uapi/v4l/pixfmt-uyvy.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-uyvy.rst
@@ -65,7 +65,7 @@ Each cell is one byte.
65 - Y'\ :sub:`33` 65 - Y'\ :sub:`33`
66 66
67 67
68**Color Sample Location..** 68**Color Sample Location:**
69 69
70 70
71 71
diff --git a/Documentation/media/uapi/v4l/pixfmt-003.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst
index 337e8188caf1..337e8188caf1 100644
--- a/Documentation/media/uapi/v4l/pixfmt-003.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-v4l2-mplane.rst
diff --git a/Documentation/media/uapi/v4l/pixfmt-002.rst b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst
index 2ee164c25637..2ee164c25637 100644
--- a/Documentation/media/uapi/v4l/pixfmt-002.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-v4l2.rst
diff --git a/Documentation/media/uapi/v4l/pixfmt-vyuy.rst b/Documentation/media/uapi/v4l/pixfmt-vyuy.rst
index a3f61f280b94..670c339c1714 100644
--- a/Documentation/media/uapi/v4l/pixfmt-vyuy.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-vyuy.rst
@@ -65,7 +65,7 @@ Each cell is one byte.
65 - Y'\ :sub:`33` 65 - Y'\ :sub:`33`
66 66
67 67
68**Color Sample Location..** 68**Color Sample Location:**
69 69
70.. flat-table:: 70.. flat-table::
71 :header-rows: 0 71 :header-rows: 0
diff --git a/Documentation/media/uapi/v4l/pixfmt-y41p.rst b/Documentation/media/uapi/v4l/pixfmt-y41p.rst
index 05d040c46a47..e1fe548807a4 100644
--- a/Documentation/media/uapi/v4l/pixfmt-y41p.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-y41p.rst
@@ -88,7 +88,7 @@ Each cell is one byte.
88 - Y'\ :sub:`37` 88 - Y'\ :sub:`37`
89 89
90 90
91**Color Sample Location..** 91**Color Sample Location:**
92 92
93.. flat-table:: 93.. flat-table::
94 :header-rows: 0 94 :header-rows: 0
diff --git a/Documentation/media/uapi/v4l/pixfmt-yuv410.rst b/Documentation/media/uapi/v4l/pixfmt-yuv410.rst
index 0c49915af850..b51a0d1c6108 100644
--- a/Documentation/media/uapi/v4l/pixfmt-yuv410.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-yuv410.rst
@@ -67,7 +67,7 @@ Each cell is one byte.
67 - Cb\ :sub:`00` 67 - Cb\ :sub:`00`
68 68
69 69
70**Color Sample Location..** 70**Color Sample Location:**
71 71
72 72
73 73
diff --git a/Documentation/media/uapi/v4l/pixfmt-yuv411p.rst b/Documentation/media/uapi/v4l/pixfmt-yuv411p.rst
index 2cf33fad7254..2582341972db 100644
--- a/Documentation/media/uapi/v4l/pixfmt-yuv411p.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-yuv411p.rst
@@ -75,7 +75,7 @@ Each cell is one byte.
75 - Cr\ :sub:`30` 75 - Cr\ :sub:`30`
76 76
77 77
78**Color Sample Location..** 78**Color Sample Location:**
79 79
80 80
81 81
diff --git a/Documentation/media/uapi/v4l/pixfmt-yuv420.rst b/Documentation/media/uapi/v4l/pixfmt-yuv420.rst
index fd98904058ed..a9b85c4b1dbc 100644
--- a/Documentation/media/uapi/v4l/pixfmt-yuv420.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-yuv420.rst
@@ -76,7 +76,7 @@ Each cell is one byte.
76 - Cb\ :sub:`11` 76 - Cb\ :sub:`11`
77 77
78 78
79**Color Sample Location..** 79**Color Sample Location:**
80 80
81 81
82 82
diff --git a/Documentation/media/uapi/v4l/pixfmt-yuv420m.rst b/Documentation/media/uapi/v4l/pixfmt-yuv420m.rst
index cce8c477fdfc..32c68c33f2b1 100644
--- a/Documentation/media/uapi/v4l/pixfmt-yuv420m.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-yuv420m.rst
@@ -85,7 +85,7 @@ Each cell is one byte.
85 - Cr\ :sub:`11` 85 - Cr\ :sub:`11`
86 86
87 87
88**Color Sample Location..** 88**Color Sample Location:**
89 89
90 90
91 91
diff --git a/Documentation/media/uapi/v4l/pixfmt-yuv422m.rst b/Documentation/media/uapi/v4l/pixfmt-yuv422m.rst
index d986393aa934..9e7028c4967c 100644
--- a/Documentation/media/uapi/v4l/pixfmt-yuv422m.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-yuv422m.rst
@@ -96,7 +96,7 @@ Each cell is one byte.
96 - Cr\ :sub:`31` 96 - Cr\ :sub:`31`
97 97
98 98
99**Color Sample Location..** 99**Color Sample Location:**
100 100
101 101
102 102
diff --git a/Documentation/media/uapi/v4l/pixfmt-yuv422p.rst b/Documentation/media/uapi/v4l/pixfmt-yuv422p.rst
index e6f5de546dba..a96f836c7fa5 100644
--- a/Documentation/media/uapi/v4l/pixfmt-yuv422p.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-yuv422p.rst
@@ -84,7 +84,7 @@ Each cell is one byte.
84 - Cr\ :sub:`31` 84 - Cr\ :sub:`31`
85 85
86 86
87**Color Sample Location..** 87**Color Sample Location:**
88 88
89 89
90 90
diff --git a/Documentation/media/uapi/v4l/pixfmt-yuv444m.rst b/Documentation/media/uapi/v4l/pixfmt-yuv444m.rst
index 830fbf6fcd1d..8605bfaee112 100644
--- a/Documentation/media/uapi/v4l/pixfmt-yuv444m.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-yuv444m.rst
@@ -106,7 +106,7 @@ Each cell is one byte.
106 - Cr\ :sub:`33` 106 - Cr\ :sub:`33`
107 107
108 108
109**Color Sample Location..** 109**Color Sample Location:**
110 110
111 111
112 112
diff --git a/Documentation/media/uapi/v4l/pixfmt-yuyv.rst b/Documentation/media/uapi/v4l/pixfmt-yuyv.rst
index e1bdd6b1aefc..53e876d053fb 100644
--- a/Documentation/media/uapi/v4l/pixfmt-yuyv.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-yuyv.rst
@@ -68,7 +68,7 @@ Each cell is one byte.
68 - Cr\ :sub:`31` 68 - Cr\ :sub:`31`
69 69
70 70
71**Color Sample Location..** 71**Color Sample Location:**
72 72
73 73
74 74
diff --git a/Documentation/media/uapi/v4l/pixfmt-yvyu.rst b/Documentation/media/uapi/v4l/pixfmt-yvyu.rst
index 0244ce6741a6..b9c31746e565 100644
--- a/Documentation/media/uapi/v4l/pixfmt-yvyu.rst
+++ b/Documentation/media/uapi/v4l/pixfmt-yvyu.rst
@@ -65,7 +65,7 @@ Each cell is one byte.
65 - Cb\ :sub:`31` 65 - Cb\ :sub:`31`
66 66
67 67
68**Color Sample Location..** 68**Color Sample Location:**
69 69
70.. flat-table:: 70.. flat-table::
71 :header-rows: 0 71 :header-rows: 0
diff --git a/Documentation/media/uapi/v4l/pixfmt.rst b/Documentation/media/uapi/v4l/pixfmt.rst
index 00737152497b..2aa449e2da67 100644
--- a/Documentation/media/uapi/v4l/pixfmt.rst
+++ b/Documentation/media/uapi/v4l/pixfmt.rst
@@ -19,20 +19,19 @@ see also :ref:`VIDIOC_G_FBUF <VIDIOC_G_FBUF>`.)
19.. toctree:: 19.. toctree::
20 :maxdepth: 1 20 :maxdepth: 1
21 21
22 pixfmt-002 22 pixfmt-v4l2
23 pixfmt-003 23 pixfmt-v4l2-mplane
24 pixfmt-004 24 pixfmt-intro
25 colorspaces
26 pixfmt-006
27 pixfmt-007
28 pixfmt-008
29 pixfmt-indexed 25 pixfmt-indexed
30 pixfmt-rgb 26 pixfmt-rgb
31 yuv-formats 27 yuv-formats
32 hsv-formats 28 hsv-formats
33 depth-formats 29 depth-formats
34 pixfmt-013 30 pixfmt-compressed
35 sdr-formats 31 sdr-formats
36 tch-formats 32 tch-formats
37 meta-formats 33 meta-formats
38 pixfmt-reserved 34 pixfmt-reserved
35 colorspaces
36 colorspaces-defs
37 colorspaces-details
diff --git a/Documentation/media/uapi/v4l/subdev-formats.rst b/Documentation/media/uapi/v4l/subdev-formats.rst
index 8e73bb00c0d5..b1eea44550e1 100644
--- a/Documentation/media/uapi/v4l/subdev-formats.rst
+++ b/Documentation/media/uapi/v4l/subdev-formats.rst
@@ -1586,7 +1586,7 @@ JEIDA defined bit mapping will be named
1586 1586
1587.. raw:: latex 1587.. raw:: latex
1588 1588
1589 \begin{adjustbox}{width=\columnwidth} 1589 \tiny
1590 1590
1591.. _v4l2-mbus-pixelcode-rgb-lvds: 1591.. _v4l2-mbus-pixelcode-rgb-lvds:
1592 1592
@@ -1784,7 +1784,7 @@ JEIDA defined bit mapping will be named
1784 1784
1785.. raw:: latex 1785.. raw:: latex
1786 1786
1787 \end{adjustbox}\newline\newline 1787 \normalsize
1788 1788
1789 1789
1790Bayer Formats 1790Bayer Formats
@@ -7321,11 +7321,14 @@ following information.
7321 7321
7322The following table lists existing HSV/HSL formats. 7322The following table lists existing HSV/HSL formats.
7323 7323
7324
7324.. raw:: latex 7325.. raw:: latex
7325 7326
7326 \newline\newline\begin{adjustbox}{width=\columnwidth} 7327 \begingroup
7328 \tiny
7329 \setlength{\tabcolsep}{2pt}
7327 7330
7328.. tabularcolumns:: |p{6.2cm}|p{1.6cm}|p{0.7cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}|p{0.5cm}| 7331.. tabularcolumns:: |p{3.0cm}|p{0.60cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|p{0.22cm}|
7329 7332
7330.. _v4l2-mbus-pixelcode-hsv: 7333.. _v4l2-mbus-pixelcode-hsv:
7331 7334
@@ -7413,7 +7416,7 @@ The following table lists existing HSV/HSL formats.
7413 7416
7414.. raw:: latex 7417.. raw:: latex
7415 7418
7416 \end{adjustbox}\newline\newline 7419 \normalsize
7417 7420
7418 7421
7419JPEG Compressed Formats 7422JPEG Compressed Formats
@@ -7435,7 +7438,7 @@ The following table lists existing JPEG compressed formats.
7435 7438
7436.. _v4l2-mbus-pixelcode-jpeg: 7439.. _v4l2-mbus-pixelcode-jpeg:
7437 7440
7438.. tabularcolumns:: |p{5.6cm}|p{1.2cm}|p{10.7cm}| 7441.. tabularcolumns:: |p{5.4cm}|p{1.4cm}|p{10.7cm}|
7439 7442
7440.. flat-table:: JPEG Formats 7443.. flat-table:: JPEG Formats
7441 :header-rows: 1 7444 :header-rows: 1
@@ -7468,7 +7471,7 @@ formats.
7468 7471
7469.. _v4l2-mbus-pixelcode-vendor-specific: 7472.. _v4l2-mbus-pixelcode-vendor-specific:
7470 7473
7471.. tabularcolumns:: |p{6.6cm}|p{1.2cm}|p{9.7cm}| 7474.. tabularcolumns:: |p{6.8cm}|p{1.4cm}|p{9.3cm}|
7472 7475
7473.. flat-table:: Vendor and device specific formats 7476.. flat-table:: Vendor and device specific formats
7474 :header-rows: 1 7477 :header-rows: 1
diff --git a/Documentation/media/uapi/v4l/v4l2-selection-targets.rst b/Documentation/media/uapi/v4l/v4l2-selection-targets.rst
index cab07de6f4da..87433ec76c6b 100644
--- a/Documentation/media/uapi/v4l/v4l2-selection-targets.rst
+++ b/Documentation/media/uapi/v4l/v4l2-selection-targets.rst
@@ -12,7 +12,7 @@ of the two interfaces they are used.
12 12
13.. _v4l2-selection-targets-table: 13.. _v4l2-selection-targets-table:
14 14
15.. tabularcolumns:: |p{5.8cm}|p{1.4cm}|p{6.5cm}|p{1.2cm}|p{1.6cm}| 15.. tabularcolumns:: |p{6.0cm}|p{1.4cm}|p{7.4cm}|p{1.2cm}|p{1.4cm}|
16 16
17.. flat-table:: Selection target definitions 17.. flat-table:: Selection target definitions
18 :header-rows: 1 18 :header-rows: 1
diff --git a/Documentation/media/uapi/v4l/v4l2.rst b/Documentation/media/uapi/v4l/v4l2.rst
index f52a11c949d3..2128717299b3 100644
--- a/Documentation/media/uapi/v4l/v4l2.rst
+++ b/Documentation/media/uapi/v4l/v4l2.rst
@@ -11,7 +11,9 @@ This part describes the Video for Linux API version 2 (V4L2 API) specification.
11 11
12**Revision 4.5** 12**Revision 4.5**
13 13
14.. class:: toc-title 14.. only:: html
15
16 .. class:: toc-title
15 17
16 Table of Contents 18 Table of Contents
17 19
@@ -23,7 +25,6 @@ This part describes the Video for Linux API version 2 (V4L2 API) specification.
23 pixfmt 25 pixfmt
24 io 26 io
25 devices 27 devices
26 driver
27 libv4l 28 libv4l
28 compat 29 compat
29 user-func 30 user-func
diff --git a/Documentation/media/uapi/v4l/vidioc-create-bufs.rst b/Documentation/media/uapi/v4l/vidioc-create-bufs.rst
index aaca12fca06e..a39e18d69511 100644
--- a/Documentation/media/uapi/v4l/vidioc-create-bufs.rst
+++ b/Documentation/media/uapi/v4l/vidioc-create-bufs.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_create_buffers`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-cropcap.rst b/Documentation/media/uapi/v4l/vidioc-cropcap.rst
index 0f80d5ca2643..a65dbec6b20b 100644
--- a/Documentation/media/uapi/v4l/vidioc-cropcap.rst
+++ b/Documentation/media/uapi/v4l/vidioc-cropcap.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_cropcap`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-dbg-g-chip-info.rst b/Documentation/media/uapi/v4l/vidioc-dbg-g-chip-info.rst
index e1e5507e79ff..7709852282c2 100644
--- a/Documentation/media/uapi/v4l/vidioc-dbg-g-chip-info.rst
+++ b/Documentation/media/uapi/v4l/vidioc-dbg-g-chip-info.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_dbg_chip_info`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-dbg-g-register.rst b/Documentation/media/uapi/v4l/vidioc-dbg-g-register.rst
index 5960a6547f41..f4e8dd5f7889 100644
--- a/Documentation/media/uapi/v4l/vidioc-dbg-g-register.rst
+++ b/Documentation/media/uapi/v4l/vidioc-dbg-g-register.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_dbg_register`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-dqevent.rst b/Documentation/media/uapi/v4l/vidioc-dqevent.rst
index 8d663a73818e..cb3565f36793 100644
--- a/Documentation/media/uapi/v4l/vidioc-dqevent.rst
+++ b/Documentation/media/uapi/v4l/vidioc-dqevent.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_event`.
29 30
30 31
31Description 32Description
@@ -38,7 +39,7 @@ exceptions which the application may get by e.g. using the select system
38call. 39call.
39 40
40 41
41.. tabularcolumns:: |p{3.0cm}|p{4.3cm}|p{2.5cm}|p{7.7cm}| 42.. tabularcolumns:: |p{3.0cm}|p{4.4cm}|p{2.4cm}|p{7.7cm}|
42 43
43.. c:type:: v4l2_event 44.. c:type:: v4l2_event
44 45
diff --git a/Documentation/media/uapi/v4l/vidioc-dv-timings-cap.rst b/Documentation/media/uapi/v4l/vidioc-dv-timings-cap.rst
index 424f3a1c7f56..63ead6b7a115 100644
--- a/Documentation/media/uapi/v4l/vidioc-dv-timings-cap.rst
+++ b/Documentation/media/uapi/v4l/vidioc-dv-timings-cap.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_dv_timings_cap`.
32 33
33 34
34Description 35Description
@@ -97,7 +98,7 @@ that doesn't support them will return an ``EINVAL`` error code.
97 98
98 99
99 100
100.. tabularcolumns:: |p{1.0cm}|p{3.5cm}|p{3.5cm}|p{9.5cm}| 101.. tabularcolumns:: |p{1.0cm}|p{4.0cm}|p{3.5cm}|p{9.2cm}|
101 102
102.. c:type:: v4l2_dv_timings_cap 103.. c:type:: v4l2_dv_timings_cap
103 104
diff --git a/Documentation/media/uapi/v4l/vidioc-encoder-cmd.rst b/Documentation/media/uapi/v4l/vidioc-encoder-cmd.rst
index ae20ee573757..5ae8c933b1b9 100644
--- a/Documentation/media/uapi/v4l/vidioc-encoder-cmd.rst
+++ b/Documentation/media/uapi/v4l/vidioc-encoder-cmd.rst
@@ -29,7 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 32 Pointer to struct :c:type:`v4l2_encoder_cmd`.
33 33
34Description 34Description
35=========== 35===========
diff --git a/Documentation/media/uapi/v4l/vidioc-enum-dv-timings.rst b/Documentation/media/uapi/v4l/vidioc-enum-dv-timings.rst
index 3e9d0f69cc73..63dca65f49e4 100644
--- a/Documentation/media/uapi/v4l/vidioc-enum-dv-timings.rst
+++ b/Documentation/media/uapi/v4l/vidioc-enum-dv-timings.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_enum_dv_timings`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-enum-fmt.rst b/Documentation/media/uapi/v4l/vidioc-enum-fmt.rst
index a2adaa4bd4dd..019c513df217 100644
--- a/Documentation/media/uapi/v4l/vidioc-enum-fmt.rst
+++ b/Documentation/media/uapi/v4l/vidioc-enum-fmt.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_fmtdesc`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-enum-frameintervals.rst b/Documentation/media/uapi/v4l/vidioc-enum-frameintervals.rst
index 39492453f02d..fea7dc3c879d 100644
--- a/Documentation/media/uapi/v4l/vidioc-enum-frameintervals.rst
+++ b/Documentation/media/uapi/v4l/vidioc-enum-frameintervals.rst
@@ -26,9 +26,8 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to a struct :c:type:`v4l2_frmivalenum` 29 Pointer to struct :c:type:`v4l2_frmivalenum`
30 structure that contains a pixel format and size and receives a frame 30 that contains a pixel format and size and receives a frame interval.
31 interval.
32 31
33 32
34Description 33Description
@@ -124,6 +123,8 @@ application should zero out all members except for the *IN* fields.
124 123
125.. c:type:: v4l2_frmivalenum 124.. c:type:: v4l2_frmivalenum
126 125
126.. tabularcolumns:: |p{1.8cm}|p{4.4cm}|p{2.4cm}|p{8.9cm}|
127
127.. flat-table:: struct v4l2_frmivalenum 128.. flat-table:: struct v4l2_frmivalenum
128 :header-rows: 0 129 :header-rows: 0
129 :stub-columns: 0 130 :stub-columns: 0
diff --git a/Documentation/media/uapi/v4l/vidioc-enum-framesizes.rst b/Documentation/media/uapi/v4l/vidioc-enum-framesizes.rst
index 628f1aa66338..6de117f163e0 100644
--- a/Documentation/media/uapi/v4l/vidioc-enum-framesizes.rst
+++ b/Documentation/media/uapi/v4l/vidioc-enum-framesizes.rst
@@ -26,7 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to a struct :c:type:`v4l2_frmsizeenum` 29 Pointer to struct :c:type:`v4l2_frmsizeenum`
30 that contains an index and pixel format and receives a frame width 30 that contains an index and pixel format and receives a frame width
31 and height. 31 and height.
32 32
@@ -140,6 +140,8 @@ application should zero out all members except for the *IN* fields.
140 140
141.. c:type:: v4l2_frmsizeenum 141.. c:type:: v4l2_frmsizeenum
142 142
143.. tabularcolumns:: |p{1.4cm}|p{5.9cm}|p{2.3cm}|p{8.0cm}|
144
143.. flat-table:: struct v4l2_frmsizeenum 145.. flat-table:: struct v4l2_frmsizeenum
144 :header-rows: 0 146 :header-rows: 0
145 :stub-columns: 0 147 :stub-columns: 0
diff --git a/Documentation/media/uapi/v4l/vidioc-enum-freq-bands.rst b/Documentation/media/uapi/v4l/vidioc-enum-freq-bands.rst
index 4e5f5e5bf632..195cf45f3c32 100644
--- a/Documentation/media/uapi/v4l/vidioc-enum-freq-bands.rst
+++ b/Documentation/media/uapi/v4l/vidioc-enum-freq-bands.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_frequency_band`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-enumaudio.rst b/Documentation/media/uapi/v4l/vidioc-enumaudio.rst
index 74bc3ed0bdd8..8e5193e8696f 100644
--- a/Documentation/media/uapi/v4l/vidioc-enumaudio.rst
+++ b/Documentation/media/uapi/v4l/vidioc-enumaudio.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_audio`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-enumaudioout.rst b/Documentation/media/uapi/v4l/vidioc-enumaudioout.rst
index 4470a1ece5cf..6d2b4f6e78b0 100644
--- a/Documentation/media/uapi/v4l/vidioc-enumaudioout.rst
+++ b/Documentation/media/uapi/v4l/vidioc-enumaudioout.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_audioout`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-enuminput.rst b/Documentation/media/uapi/v4l/vidioc-enuminput.rst
index 266e48ab237f..0350069a56c5 100644
--- a/Documentation/media/uapi/v4l/vidioc-enuminput.rst
+++ b/Documentation/media/uapi/v4l/vidioc-enuminput.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_input`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-enumoutput.rst b/Documentation/media/uapi/v4l/vidioc-enumoutput.rst
index 93a2cf3b310c..697dcd186ae3 100644
--- a/Documentation/media/uapi/v4l/vidioc-enumoutput.rst
+++ b/Documentation/media/uapi/v4l/vidioc-enumoutput.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_output`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-enumstd.rst b/Documentation/media/uapi/v4l/vidioc-enumstd.rst
index f2bdd45cfa0d..b7fda29f46a1 100644
--- a/Documentation/media/uapi/v4l/vidioc-enumstd.rst
+++ b/Documentation/media/uapi/v4l/vidioc-enumstd.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_standard`.
29 30
30 31
31Description 32Description
@@ -224,12 +225,15 @@ support digital TV. See also the Linux DVB API at
224 #define V4L2_STD_ALL (V4L2_STD_525_60 | 225 #define V4L2_STD_ALL (V4L2_STD_525_60 |
225 V4L2_STD_625_50) 226 V4L2_STD_625_50)
226 227
228
227.. raw:: latex 229.. raw:: latex
228 230
229 \begin{adjustbox}{width=\columnwidth} 231 \begingroup
232 \tiny
233 \setlength{\tabcolsep}{2pt}
230 234
231.. NTSC/M PAL/M /N /B /D /H /I SECAM/B /D /K1 /L 235.. NTSC/M PAL/M /N /B /D /H /I SECAM/B /D /K1 /L
232.. tabularcolumns:: |p{2.7cm}|p{2.6cm}|p{3.0cm}|p{3.2cm}|p{3.2cm}|p{2.2cm}|p{1.2cm}|p{3.2cm}|p{3.0cm}|p{2.0cm}|p{2.0cm}|p{2.0cm}| 236.. tabularcolumns:: |p{1.43cm}|p{1.38cm}|p{1.59cm}|p{1.7cm}|p{1.7cm}|p{1.17cm}|p{0.64cm}|p{1.71cm}|p{1.6cm}|p{1.07cm}|p{1.07cm}|p{1.07cm}|
233 237
234.. _video-standards: 238.. _video-standards:
235 239
@@ -293,7 +297,7 @@ support digital TV. See also the Linux DVB API at
293 297
294.. raw:: latex 298.. raw:: latex
295 299
296 \end{adjustbox}\newline\newline 300 \endgroup
297 301
298 302
299 303
diff --git a/Documentation/media/uapi/v4l/vidioc-expbuf.rst b/Documentation/media/uapi/v4l/vidioc-expbuf.rst
index 246e48028d40..226e83eb28a9 100644
--- a/Documentation/media/uapi/v4l/vidioc-expbuf.rst
+++ b/Documentation/media/uapi/v4l/vidioc-expbuf.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_exportbuffer`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-audio.rst b/Documentation/media/uapi/v4l/vidioc-g-audio.rst
index 5b67e81a0db6..290851f99386 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-audio.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-audio.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_audio`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-audioout.rst b/Documentation/media/uapi/v4l/vidioc-g-audioout.rst
index d16ecbaddc59..1c98af33ee70 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-audioout.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-audioout.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_audioout`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-crop.rst b/Documentation/media/uapi/v4l/vidioc-g-crop.rst
index 13771ee3e94a..a6ed43ba9ca3 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-crop.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-crop.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_crop`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-ctrl.rst b/Documentation/media/uapi/v4l/vidioc-g-ctrl.rst
index d8a379182a34..299b9aabbac2 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-ctrl.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-ctrl.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_control`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst b/Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst
index e573c74138de..2696380626d4 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-dv-timings.rst
@@ -35,6 +35,7 @@ Arguments
35 File descriptor returned by :ref:`open() <func-open>`. 35 File descriptor returned by :ref:`open() <func-open>`.
36 36
37``argp`` 37``argp``
38 Pointer to struct :c:type:`v4l2_dv_timings`.
38 39
39 40
40Description 41Description
@@ -208,7 +209,7 @@ EBUSY
208 - 0 209 - 0
209 - BT.656/1120 timings 210 - BT.656/1120 timings
210 211
211 212.. tabularcolumns:: |p{4.5cm}|p{12.8cm}|
212 213
213.. _dv-bt-standards: 214.. _dv-bt-standards:
214 215
@@ -231,7 +232,7 @@ EBUSY
231 There are no horizontal syncs/porches at all in this format. 232 There are no horizontal syncs/porches at all in this format.
232 Total blanking timings must be set in hsync or vsync fields only. 233 Total blanking timings must be set in hsync or vsync fields only.
233 234
234.. tabularcolumns:: |p{6.0cm}|p{11.5cm}| 235.. tabularcolumns:: |p{7.0cm}|p{10.5cm}|
235 236
236.. _dv-bt-flags: 237.. _dv-bt-flags:
237 238
diff --git a/Documentation/media/uapi/v4l/vidioc-g-edid.rst b/Documentation/media/uapi/v4l/vidioc-g-edid.rst
index a16a193a1cbf..acab90f06e5a 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-edid.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-edid.rst
@@ -36,6 +36,7 @@ Arguments
36 File descriptor returned by :ref:`open() <func-open>`. 36 File descriptor returned by :ref:`open() <func-open>`.
37 37
38``argp`` 38``argp``
39 Pointer to struct :c:type:`v4l2_edid`.
39 40
40 41
41Description 42Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-enc-index.rst b/Documentation/media/uapi/v4l/vidioc-g-enc-index.rst
index 418e886fd44b..9dfe64fc21a4 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-enc-index.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-enc-index.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_enc_idx`.
29 30
30 31
31Description 32Description
@@ -55,7 +56,7 @@ Currently this ioctl is only defined for MPEG-2 program streams and
55video elementary streams. 56video elementary streams.
56 57
57 58
58.. tabularcolumns:: |p{3.5cm}|p{5.6cm}|p{8.4cm}| 59.. tabularcolumns:: |p{3.8cm}|p{5.6cm}|p{8.1cm}|
59 60
60.. c:type:: v4l2_enc_idx 61.. c:type:: v4l2_enc_idx
61 62
diff --git a/Documentation/media/uapi/v4l/vidioc-g-ext-ctrls.rst b/Documentation/media/uapi/v4l/vidioc-g-ext-ctrls.rst
index 5ab8d2ac27b9..2011c2b2ee67 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-ext-ctrls.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-ext-ctrls.rst
@@ -34,6 +34,7 @@ Arguments
34 File descriptor returned by :ref:`open() <func-open>`. 34 File descriptor returned by :ref:`open() <func-open>`.
35 35
36``argp`` 36``argp``
37 Pointer to struct :c:type:`v4l2_ext_controls`.
37 38
38 39
39Description 40Description
@@ -180,7 +181,7 @@ still cause this situation.
180 ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is set for this control. 181 ``V4L2_CTRL_FLAG_HAS_PAYLOAD`` is set for this control.
181 182
182 183
183.. tabularcolumns:: |p{4.0cm}|p{2.0cm}|p{2.0cm}|p{8.5cm}| 184.. tabularcolumns:: |p{4.0cm}|p{2.2cm}|p{2.1cm}|p{8.2cm}|
184 185
185.. c:type:: v4l2_ext_controls 186.. c:type:: v4l2_ext_controls
186 187
diff --git a/Documentation/media/uapi/v4l/vidioc-g-fbuf.rst b/Documentation/media/uapi/v4l/vidioc-g-fbuf.rst
index 4a6a03d158ca..fc73bf0f6052 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-fbuf.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-fbuf.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_framebuffer`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-fmt.rst b/Documentation/media/uapi/v4l/vidioc-g-fmt.rst
index d082f9a21548..3ead350e099f 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-fmt.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-fmt.rst
@@ -31,6 +31,7 @@ Arguments
31 File descriptor returned by :ref:`open() <func-open>`. 31 File descriptor returned by :ref:`open() <func-open>`.
32 32
33``argp`` 33``argp``
34 Pointer to struct :c:type:`v4l2_format`.
34 35
35 36
36Description 37Description
@@ -87,7 +88,7 @@ The format as returned by :ref:`VIDIOC_TRY_FMT <VIDIOC_G_FMT>` must be identical
87 88
88.. c:type:: v4l2_format 89.. c:type:: v4l2_format
89 90
90.. tabularcolumns:: |p{1.2cm}|p{4.3cm}|p{3.0cm}|p{9.0cm}| 91.. tabularcolumns:: |p{1.2cm}|p{4.6cm}|p{3.0cm}|p{8.6cm}|
91 92
92.. flat-table:: struct v4l2_format 93.. flat-table:: struct v4l2_format
93 :header-rows: 0 94 :header-rows: 0
diff --git a/Documentation/media/uapi/v4l/vidioc-g-frequency.rst b/Documentation/media/uapi/v4l/vidioc-g-frequency.rst
index 46ab276f412b..c1cccb144660 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-frequency.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-frequency.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_frequency`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-input.rst b/Documentation/media/uapi/v4l/vidioc-g-input.rst
index 1364a918fbce..1dcef44eef02 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-input.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-input.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer an integer with input index.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-jpegcomp.rst b/Documentation/media/uapi/v4l/vidioc-g-jpegcomp.rst
index 8ba353067b33..a1773ea9543e 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-jpegcomp.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-jpegcomp.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_jpegcompression`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-modulator.rst b/Documentation/media/uapi/v4l/vidioc-g-modulator.rst
index 77d017eb3fcc..a47b6a15cfbe 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-modulator.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-modulator.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_modulator`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-output.rst b/Documentation/media/uapi/v4l/vidioc-g-output.rst
index 7750948fc61b..3e0093f66834 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-output.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-output.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to an integer with output index.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-parm.rst b/Documentation/media/uapi/v4l/vidioc-g-parm.rst
index 3b2e6e59a334..616a5ea3f8fa 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-parm.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-parm.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_streamparm`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-priority.rst b/Documentation/media/uapi/v4l/vidioc-g-priority.rst
index a763988f64e4..c28996b4a45c 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-priority.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-priority.rst
@@ -29,7 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to an enum v4l2_priority type. 32 Pointer to an enum :c:type:`v4l2_priority` type.
33 33
34 34
35Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-selection.rst b/Documentation/media/uapi/v4l/vidioc-g-selection.rst
index c1ee86472918..f1d9df029e0d 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-selection.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-selection.rst
@@ -29,11 +29,8 @@ Arguments
29``fd`` 29``fd``
30 File descriptor returned by :ref:`open() <func-open>`. 30 File descriptor returned by :ref:`open() <func-open>`.
31 31
32``request``
33 VIDIOC_G_SELECTION, VIDIOC_S_SELECTION
34
35``argp`` 32``argp``
36 33 Pointer to struct :c:type:`v4l2_selection`.
37 34
38Description 35Description
39=========== 36===========
diff --git a/Documentation/media/uapi/v4l/vidioc-g-sliced-vbi-cap.rst b/Documentation/media/uapi/v4l/vidioc-g-sliced-vbi-cap.rst
index d7e2b2fa8b88..a9633cae76c5 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-sliced-vbi-cap.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-sliced-vbi-cap.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_sliced_vbi_cap`.
29 30
30 31
31Description 32Description
@@ -122,9 +123,9 @@ the sliced VBI API is unsupported or ``type`` is invalid.
122 123
123.. raw:: latex 124.. raw:: latex
124 125
125 \begin{adjustbox}{width=\columnwidth} 126 \scriptsize
126 127
127.. tabularcolumns:: |p{5.0cm}|p{1.4cm}|p{3.0cm}|p{2.5cm}|p{9.0cm}| 128.. tabularcolumns:: |p{3.5cm}|p{1.0cm}|p{2.0cm}|p{2.0cm}|p{8.0cm}|
128 129
129.. _vbi-services: 130.. _vbi-services:
130 131
@@ -180,7 +181,7 @@ the sliced VBI API is unsupported or ``type`` is invalid.
180 181
181.. raw:: latex 182.. raw:: latex
182 183
183 \end{adjustbox}\newline\newline 184 \normalsize
184 185
185 186
186Return Value 187Return Value
diff --git a/Documentation/media/uapi/v4l/vidioc-g-std.rst b/Documentation/media/uapi/v4l/vidioc-g-std.rst
index cd856ad21a28..90791ab51a53 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-std.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-std.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to :c:type:`v4l2_std_id`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-g-tuner.rst b/Documentation/media/uapi/v4l/vidioc-g-tuner.rst
index 57c79fa43866..acdd15901a51 100644
--- a/Documentation/media/uapi/v4l/vidioc-g-tuner.rst
+++ b/Documentation/media/uapi/v4l/vidioc-g-tuner.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_tuner`.
32 33
33 34
34Description 35Description
@@ -392,22 +393,25 @@ To change the radio frequency the
392 393
393.. raw:: latex 394.. raw:: latex
394 395
395 \begin{adjustbox}{width=\columnwidth} 396 \scriptsize
397
398.. tabularcolumns:: |p{1.5cm}|p{1.5cm}|p{2.9cm}|p{2.9cm}|p{2.9cm}|p{2.9cm}|
396 399
397.. _tuner-matrix: 400.. _tuner-matrix:
398 401
399.. flat-table:: Tuner Audio Matrix 402.. flat-table:: Tuner Audio Matrix
400 :header-rows: 2 403 :header-rows: 2
401 :stub-columns: 0 404 :stub-columns: 0
405 :widths: 7 7 14 14 14 14
402 406
403 * - 407 * -
404 - :cspan:`5` Selected ``V4L2_TUNER_MODE_`` 408 - :cspan:`4` Selected ``V4L2_TUNER_MODE_``
405 * - Received ``V4L2_TUNER_SUB_`` 409 * - Received ``V4L2_TUNER_SUB_``
406 - ``MONO`` 410 - ``MONO``
407 - ``STEREO`` 411 - ``STEREO``
408 - ``LANG1`` 412 - ``LANG1``
409 - ``LANG2 = SAP`` 413 - ``LANG2 = SAP``
410 - ``LANG1_LANG2``\ [#f1]_ 414 - ``LANG1_LANG2``\ [#f1]_
411 * - ``MONO`` 415 * - ``MONO``
412 - Mono 416 - Mono
413 - Mono/Mono 417 - Mono/Mono
@@ -434,14 +438,14 @@ To change the radio frequency the
434 - L+R/SAP (preferred) or L/R or L+R/L+R 438 - L+R/SAP (preferred) or L/R or L+R/L+R
435 * - ``LANG1 | LANG2`` 439 * - ``LANG1 | LANG2``
436 - Language 1 440 - Language 1
437 - Lang1/Lang2 (deprecated [#f2]_) or Lang1/Lang1 441 - Lang1/Lang2 (deprecated\ [#f2]_) or Lang1/Lang1
438 - Language 1 442 - Language 1
439 - Language 2 443 - Language 2
440 - Lang1/Lang2 (preferred) or Lang1/Lang1 444 - Lang1/Lang2 (preferred) or Lang1/Lang1
441 445
442.. raw:: latex 446.. raw:: latex
443 447
444 \end{adjustbox}\newline\newline 448 \normalsize
445 449
446Return Value 450Return Value
447============ 451============
diff --git a/Documentation/media/uapi/v4l/vidioc-overlay.rst b/Documentation/media/uapi/v4l/vidioc-overlay.rst
index cd7b62ebc53b..1383e3db25fc 100644
--- a/Documentation/media/uapi/v4l/vidioc-overlay.rst
+++ b/Documentation/media/uapi/v4l/vidioc-overlay.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to an integer.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-prepare-buf.rst b/Documentation/media/uapi/v4l/vidioc-prepare-buf.rst
index bdcfd9fe550d..70687a86ae38 100644
--- a/Documentation/media/uapi/v4l/vidioc-prepare-buf.rst
+++ b/Documentation/media/uapi/v4l/vidioc-prepare-buf.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_buffer`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-qbuf.rst b/Documentation/media/uapi/v4l/vidioc-qbuf.rst
index 1f3612637200..9e448a4aa3aa 100644
--- a/Documentation/media/uapi/v4l/vidioc-qbuf.rst
+++ b/Documentation/media/uapi/v4l/vidioc-qbuf.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_buffer`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-query-dv-timings.rst b/Documentation/media/uapi/v4l/vidioc-query-dv-timings.rst
index 0d16853b1b51..6c82eafd28bb 100644
--- a/Documentation/media/uapi/v4l/vidioc-query-dv-timings.rst
+++ b/Documentation/media/uapi/v4l/vidioc-query-dv-timings.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_dv_timings`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-querybuf.rst b/Documentation/media/uapi/v4l/vidioc-querybuf.rst
index 0bdc8e0abddc..dd54747fabc9 100644
--- a/Documentation/media/uapi/v4l/vidioc-querybuf.rst
+++ b/Documentation/media/uapi/v4l/vidioc-querybuf.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_buffer`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-querycap.rst b/Documentation/media/uapi/v4l/vidioc-querycap.rst
index 12e0d9a63cd8..66fb1b3d6e6e 100644
--- a/Documentation/media/uapi/v4l/vidioc-querycap.rst
+++ b/Documentation/media/uapi/v4l/vidioc-querycap.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_capability`.
29 30
30 31
31Description 32Description
@@ -91,12 +92,13 @@ specification the ioctl returns an ``EINVAL`` error code.
91 stack from a newer kernel. 92 stack from a newer kernel.
92 93
93 The version number is formatted using the ``KERNEL_VERSION()`` 94 The version number is formatted using the ``KERNEL_VERSION()``
94 macro: 95 macro. For example if the media stack corresponds to the V4L2
96 version shipped with Kernel 4.14, it would be equivalent to:
95 * - :cspan:`2` 97 * - :cspan:`2`
96 98
97 ``#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))`` 99 ``#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))``
98 100
99 ``__u32 version = KERNEL_VERSION(0, 8, 1);`` 101 ``__u32 version = KERNEL_VERSION(4, 14, 0);``
100 102
101 ``printf ("Version: %u.%u.%u\\n",`` 103 ``printf ("Version: %u.%u.%u\\n",``
102 104
@@ -131,7 +133,7 @@ specification the ioctl returns an ``EINVAL`` error code.
131 133
132 134
133 135
134.. tabularcolumns:: |p{6cm}|p{2.2cm}|p{8.8cm}| 136.. tabularcolumns:: |p{6.1cm}|p{2.2cm}|p{8.7cm}|
135 137
136.. _device-capabilities: 138.. _device-capabilities:
137 139
diff --git a/Documentation/media/uapi/v4l/vidioc-queryctrl.rst b/Documentation/media/uapi/v4l/vidioc-queryctrl.rst
index 41c5744a1239..5bd26e8c9a1a 100644
--- a/Documentation/media/uapi/v4l/vidioc-queryctrl.rst
+++ b/Documentation/media/uapi/v4l/vidioc-queryctrl.rst
@@ -32,6 +32,8 @@ Arguments
32 File descriptor returned by :ref:`open() <func-open>`. 32 File descriptor returned by :ref:`open() <func-open>`.
33 33
34``argp`` 34``argp``
35 Pointer to struct :c:type:`v4l2_queryctl`, :c:type:`v4l2_query_ext_ctrl`
36 or :c:type`v4l2_querymenu` (depending on the ioctl).
35 37
36 38
37Description 39Description
@@ -274,7 +276,7 @@ See also the examples in :ref:`control`.
274 276
275 277
276 278
277.. tabularcolumns:: |p{1.2cm}|p{0.6cm}|p{1.6cm}|p{13.5cm}| 279.. tabularcolumns:: |p{1.2cm}|p{1.0cm}|p{1.7cm}|p{13.0cm}|
278 280
279.. _v4l2-querymenu: 281.. _v4l2-querymenu:
280 282
diff --git a/Documentation/media/uapi/v4l/vidioc-querystd.rst b/Documentation/media/uapi/v4l/vidioc-querystd.rst
index 3ef9ab37f582..cf40bca19b9f 100644
--- a/Documentation/media/uapi/v4l/vidioc-querystd.rst
+++ b/Documentation/media/uapi/v4l/vidioc-querystd.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to :c:type:`v4l2_std_id`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-reqbufs.rst b/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
index a4180d576ee5..316f52c8a310 100644
--- a/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
+++ b/Documentation/media/uapi/v4l/vidioc-reqbufs.rst
@@ -26,7 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 29 Pointer to struct :c:type:`v4l2_requestbuffers`.
30 30
31Description 31Description
32=========== 32===========
diff --git a/Documentation/media/uapi/v4l/vidioc-s-hw-freq-seek.rst b/Documentation/media/uapi/v4l/vidioc-s-hw-freq-seek.rst
index 5672ca48d2bd..b318cb8e1df3 100644
--- a/Documentation/media/uapi/v4l/vidioc-s-hw-freq-seek.rst
+++ b/Documentation/media/uapi/v4l/vidioc-s-hw-freq-seek.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_hw_freq_seek`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-streamon.rst b/Documentation/media/uapi/v4l/vidioc-streamon.rst
index 972d5b3c74aa..e851a6961b78 100644
--- a/Documentation/media/uapi/v4l/vidioc-streamon.rst
+++ b/Documentation/media/uapi/v4l/vidioc-streamon.rst
@@ -29,7 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 32 Pointer to an integer.
33 33
34Description 34Description
35=========== 35===========
diff --git a/Documentation/media/uapi/v4l/vidioc-subdev-enum-frame-interval.rst b/Documentation/media/uapi/v4l/vidioc-subdev-enum-frame-interval.rst
index 1a02c935c8b5..1bfe3865dcc2 100644
--- a/Documentation/media/uapi/v4l/vidioc-subdev-enum-frame-interval.rst
+++ b/Documentation/media/uapi/v4l/vidioc-subdev-enum-frame-interval.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_subdev_frame_interval_enum`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-subdev-enum-frame-size.rst b/Documentation/media/uapi/v4l/vidioc-subdev-enum-frame-size.rst
index 746c24ed97a0..33fdc3ac9316 100644
--- a/Documentation/media/uapi/v4l/vidioc-subdev-enum-frame-size.rst
+++ b/Documentation/media/uapi/v4l/vidioc-subdev-enum-frame-size.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_subdev_frame_size_enum`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-subdev-enum-mbus-code.rst b/Documentation/media/uapi/v4l/vidioc-subdev-enum-mbus-code.rst
index 0dfee3829ee2..4e4291798e4b 100644
--- a/Documentation/media/uapi/v4l/vidioc-subdev-enum-mbus-code.rst
+++ b/Documentation/media/uapi/v4l/vidioc-subdev-enum-mbus-code.rst
@@ -26,6 +26,7 @@ Arguments
26 File descriptor returned by :ref:`open() <func-open>`. 26 File descriptor returned by :ref:`open() <func-open>`.
27 27
28``argp`` 28``argp``
29 Pointer to struct :c:type:`v4l2_subdev_mbus_code_enum`.
29 30
30 31
31Description 32Description
diff --git a/Documentation/media/uapi/v4l/vidioc-subdev-g-crop.rst b/Documentation/media/uapi/v4l/vidioc-subdev-g-crop.rst
index 000e8fcd3f25..69b2ae8e7c15 100644
--- a/Documentation/media/uapi/v4l/vidioc-subdev-g-crop.rst
+++ b/Documentation/media/uapi/v4l/vidioc-subdev-g-crop.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_subdev_crop`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-subdev-g-fmt.rst b/Documentation/media/uapi/v4l/vidioc-subdev-g-fmt.rst
index b352456dfe2c..81c5d331af9a 100644
--- a/Documentation/media/uapi/v4l/vidioc-subdev-g-fmt.rst
+++ b/Documentation/media/uapi/v4l/vidioc-subdev-g-fmt.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_subdev_format`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-subdev-g-frame-interval.rst b/Documentation/media/uapi/v4l/vidioc-subdev-g-frame-interval.rst
index 46159dcfce30..5af0a7179941 100644
--- a/Documentation/media/uapi/v4l/vidioc-subdev-g-frame-interval.rst
+++ b/Documentation/media/uapi/v4l/vidioc-subdev-g-frame-interval.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_subdev_frame_interval`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-subdev-g-selection.rst b/Documentation/media/uapi/v4l/vidioc-subdev-g-selection.rst
index 071d9c033db6..b1d3dbbef42a 100644
--- a/Documentation/media/uapi/v4l/vidioc-subdev-g-selection.rst
+++ b/Documentation/media/uapi/v4l/vidioc-subdev-g-selection.rst
@@ -29,6 +29,7 @@ Arguments
29 File descriptor returned by :ref:`open() <func-open>`. 29 File descriptor returned by :ref:`open() <func-open>`.
30 30
31``argp`` 31``argp``
32 Pointer to struct :c:type:`v4l2_subdev_selection`.
32 33
33 34
34Description 35Description
diff --git a/Documentation/media/uapi/v4l/vidioc-subscribe-event.rst b/Documentation/media/uapi/v4l/vidioc-subscribe-event.rst
index e4a51431032c..b521efa53ceb 100644
--- a/Documentation/media/uapi/v4l/vidioc-subscribe-event.rst
+++ b/Documentation/media/uapi/v4l/vidioc-subscribe-event.rst
@@ -30,6 +30,7 @@ Arguments
30 File descriptor returned by :ref:`open() <func-open>`. 30 File descriptor returned by :ref:`open() <func-open>`.
31 31
32``argp`` 32``argp``
33 Pointer to struct :c:type:`v4l2_event_subscription`.
33 34
34 35
35Description 36Description
@@ -39,7 +40,7 @@ Subscribe or unsubscribe V4L2 event. Subscribed events are dequeued by
39using the :ref:`VIDIOC_DQEVENT` ioctl. 40using the :ref:`VIDIOC_DQEVENT` ioctl.
40 41
41 42
42.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| 43.. tabularcolumns:: |p{4.6cm}|p{4.4cm}|p{8.7cm}|
43 44
44.. c:type:: v4l2_event_subscription 45.. c:type:: v4l2_event_subscription
45 46
@@ -72,7 +73,7 @@ using the :ref:`VIDIOC_DQEVENT` ioctl.
72 73
73 74
74 75
75.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 76.. tabularcolumns:: |p{6.8cm}|p{2.2cm}|p{8.5cm}|
76 77
77.. _event-flags: 78.. _event-flags:
78 79
diff --git a/Documentation/media/v4l-drivers/au0828-cardlist.rst b/Documentation/media/v4l-drivers/au0828-cardlist.rst
index 82d2567bc7c1..bb87b7b36a83 100644
--- a/Documentation/media/v4l-drivers/au0828-cardlist.rst
+++ b/Documentation/media/v4l-drivers/au0828-cardlist.rst
@@ -1,13 +1,37 @@
1AU0828 cards list 1AU0828 cards list
2================= 2=================
3 3
4=========== ========================== ======================================================================================================================= 4.. tabularcolumns:: |p{1.4cm}|p{6.5cm}|p{10.0cm}|
5Card number Card name USB IDs 5
6=========== ========================== ======================================================================================================================= 6.. flat-table::
70 Unknown board 7 :header-rows: 1
81 Hauppauge HVR950Q 2040:7200, 2040:7210, 2040:7217, 2040:721b, 2040:721e, 2040:721f, 2040:7280, 0fd9:0008, 2040:7260, 2040:7213, 2040:7270 8 :widths: 2 19 18
92 Hauppauge HVR850 2040:7240 9 :stub-columns: 0
103 DViCO FusionHDTV USB 0fe9:d620 10
114 Hauppauge HVR950Q rev xxF8 2040:7201, 2040:7211, 2040:7281 11 * - Card number
125 Hauppauge Woodbury 05e1:0480, 2040:8200 12 - Card name
13=========== ========================== ======================================================================================================================= 13 - USB IDs
14
15 * - 0
16 - Unknown board
17 -
18
19 * - 1
20 - Hauppauge HVR950Q
21 - 2040:7200, 2040:7210, 2040:7217, 2040:721b, 2040:721e, 2040:721f, 2040:7280, 0fd9:0008, 2040:7260, 2040:7213, 2040:7270
22
23 * - 2
24 - Hauppauge HVR850
25 - 2040:7240
26
27 * - 3
28 - DViCO FusionHDTV USB
29 - 0fe9:d620
30
31 * - 4
32 - Hauppauge HVR950Q rev xxF8
33 - 2040:7201, 2040:7211, 2040:7281
34
35 * - 5
36 - Hauppauge Woodbury
37 - 05e1:0480, 2040:8200
diff --git a/Documentation/media/v4l-drivers/bttv-cardlist.rst b/Documentation/media/v4l-drivers/bttv-cardlist.rst
index 28a01cd6cf2e..8da27b924e01 100644
--- a/Documentation/media/v4l-drivers/bttv-cardlist.rst
+++ b/Documentation/media/v4l-drivers/bttv-cardlist.rst
@@ -1,174 +1,681 @@
1BTTV cards list 1BTTV cards list
2=============== 2===============
3 3
4=========== ================================================================================= ============================================================================================================================================================================== 4.. tabularcolumns:: |p{1.4cm}|p{11.1cm}|p{4.2cm}|
5Card number Card name PCI IDs 5
6=========== ================================================================================= ============================================================================================================================================================================== 6.. flat-table::
70 *** UNKNOWN/GENERIC *** 7 :header-rows: 1
81 MIRO PCTV 8 :widths: 2 19 18
92 Hauppauge (bt848) 9 :stub-columns: 0
103 STB, Gateway P/N 6000699 (bt848) 10
114 Intel Create and Share PCI/ Smart Video Recorder III 11 * - Card number
125 Diamond DTV2000 12 - Card name
136 AVerMedia TVPhone 13 - PCI IDs
147 MATRIX-Vision MV-Delta 14
158 Lifeview FlyVideo II (Bt848) LR26 / MAXI TV Video PCI2 LR26 15 * - 0
169 IMS/IXmicro TurboTV 16 - *** UNKNOWN/GENERIC ***
1710 Hauppauge (bt878) 0070:13eb, 0070:3900, 2636:10b4 17 -
1811 MIRO PCTV pro 18
1912 ADS Technologies Channel Surfer TV (bt848) 19 * - 1
2013 AVerMedia TVCapture 98 1461:0002, 1461:0004, 1461:0300 20 - MIRO PCTV
2114 Aimslab Video Highway Xtreme (VHX) 21 -
2215 Zoltrix TV-Max a1a0:a0fc 22
2316 Prolink Pixelview PlayTV (bt878) 23 * - 2
2417 Leadtek WinView 601 24 - Hauppauge (bt848)
2518 AVEC Intercapture 25 -
2619 Lifeview FlyVideo II EZ /FlyKit LR38 Bt848 (capture only) 26
2720 CEI Raffles Card 27 * - 3
2821 Lifeview FlyVideo 98/ Lucky Star Image World ConferenceTV LR50 28 - STB, Gateway P/N 6000699 (bt848)
2922 Askey CPH050/ Phoebe Tv Master + FM 14ff:3002 29 -
3023 Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV, bt878 14c7:0101 30
3124 Askey CPH05X/06X (bt878) [many vendors] 144f:3002, 144f:3005, 144f:5000, 14ff:3000 31 * - 4
3225 Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar 32 - Intel Create and Share PCI/ Smart Video Recorder III
3326 Hauppauge WinCam newer (bt878) 33 -
3427 Lifeview FlyVideo 98/ MAXI TV Video PCI2 LR50 34
3528 Terratec TerraTV+ Version 1.1 (bt878) 153b:1127, 1852:1852 35 * - 5
3629 Imagenation PXC200 1295:200a 36 - Diamond DTV2000
3730 Lifeview FlyVideo 98 LR50 1f7f:1850 37 -
3831 Formac iProTV, Formac ProTV I (bt848) 38
3932 Intel Create and Share PCI/ Smart Video Recorder III 39 * - 6
4033 Terratec TerraTValue Version Bt878 153b:1117, 153b:1118, 153b:1119, 153b:111a, 153b:1134, 153b:5018 40 - AVerMedia TVPhone
4134 Leadtek WinFast 2000/ WinFast 2000 XP 107d:6606, 107d:6609, 6606:217d, f6ff:fff6 41 -
4235 Lifeview FlyVideo 98 LR50 / Chronos Video Shuttle II 1851:1850, 1851:a050 42
4336 Lifeview FlyVideo 98FM LR50 / Typhoon TView TV/FM Tuner 1852:1852 43 * - 7
4437 Prolink PixelView PlayTV pro 44 - MATRIX-Vision MV-Delta
4538 Askey CPH06X TView99 144f:3000, 144f:a005, a04f:a0fc 45 -
4639 Pinnacle PCTV Studio/Rave 11bd:0012, bd11:1200, bd11:ff00, 11bd:ff12 46
4740 STB TV PCI FM, Gateway P/N 6000704 (bt878), 3Dfx VoodooTV 100 10b4:2636, 10b4:2645, 121a:3060 47 * - 8
4841 AVerMedia TVPhone 98 1461:0001, 1461:0003 48 - Lifeview FlyVideo II (Bt848) LR26 / MAXI TV Video PCI2 LR26
4942 ProVideo PV951 aa0c:146c 49 -
5043 Little OnAir TV 50
5144 Sigma TVII-FM 51 * - 9
5245 MATRIX-Vision MV-Delta 2 52 - IMS/IXmicro TurboTV
5346 Zoltrix Genie TV/FM 15b0:4000, 15b0:400a, 15b0:400d, 15b0:4010, 15b0:4016 53 -
5447 Terratec TV/Radio+ 153b:1123 54
5548 Askey CPH03x/ Dynalink Magic TView 55 * - 10
5649 IODATA GV-BCTV3/PCI 10fc:4020 56 - Hauppauge (bt878)
5750 Prolink PV-BT878P+4E / PixelView PlayTV PAK / Lenco MXTV-9578 CP 57 - 0070:13eb, 0070:3900, 2636:10b4
5851 Eagle Wireless Capricorn2 (bt878A) 58
5952 Pinnacle PCTV Studio Pro 59 * - 11
6053 Typhoon TView RDS + FM Stereo / KNC1 TV Station RDS 60 - MIRO PCTV pro
6154 Lifeview FlyVideo 2000 /FlyVideo A2/ Lifetec LT 9415 TV [LR90] 61 -
6255 Askey CPH031/ BESTBUY Easy TV 62
6356 Lifeview FlyVideo 98FM LR50 a051:41a0 63 * - 12
6457 GrandTec 'Grand Video Capture' (Bt848) 4344:4142 64 - ADS Technologies Channel Surfer TV (bt848)
6558 Askey CPH060/ Phoebe TV Master Only (No FM) 65 -
6659 Askey CPH03x TV Capturer 66
6760 Modular Technology MM100PCTV 67 * - 13
6861 AG Electronics GMV1 15cb:0101 68 - AVerMedia TVCapture 98
6962 Askey CPH061/ BESTBUY Easy TV (bt878) 69 - 1461:0002, 1461:0004, 1461:0300
7063 ATI TV-Wonder 1002:0001 70
7164 ATI TV-Wonder VE 1002:0003 71 * - 14
7265 Lifeview FlyVideo 2000S LR90 72 - Aimslab Video Highway Xtreme (VHX)
7366 Terratec TValueRadio 153b:1135, 153b:ff3b 73 -
7467 IODATA GV-BCTV4/PCI 10fc:4050 74
7568 3Dfx VoodooTV FM (Euro) 10b4:2637 75 * - 15
7669 Active Imaging AIMMS 76 - Zoltrix TV-Max
7770 Prolink Pixelview PV-BT878P+ (Rev.4C,8E) 77 - a1a0:a0fc
7871 Lifeview FlyVideo 98EZ (capture only) LR51 1851:1851 78
7972 Prolink Pixelview PV-BT878P+9B (PlayTV Pro rev.9B FM+NICAM) 1554:4011 79 * - 16
8073 Sensoray 311/611 6000:0311, 6000:0611 80 - Prolink Pixelview PlayTV (bt878)
8174 RemoteVision MX (RV605) 81 -
8275 Powercolor MTV878/ MTV878R/ MTV878F 82
8376 Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP) 0e11:0079 83 * - 17
8477 GrandTec Multi Capture Card (Bt878) 84 - Leadtek WinView 601
8578 Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF 0a01:17de 85 -
8679 DSP Design TCVIDEO 86
8780 Hauppauge WinTV PVR 0070:4500 87 * - 18
8881 IODATA GV-BCTV5/PCI 10fc:4070, 10fc:d018 88 - AVEC Intercapture
8982 Osprey 100/150 (878) 0070:ff00 89 -
9083 Osprey 100/150 (848) 90
9184 Osprey 101 (848) 91 * - 19
9285 Osprey 101/151 92 - Lifeview FlyVideo II EZ /FlyKit LR38 Bt848 (capture only)
9386 Osprey 101/151 w/ svid 93 -
9487 Osprey 200/201/250/251 94
9588 Osprey 200/250 0070:ff01 95 * - 20
9689 Osprey 210/220/230 96 - CEI Raffles Card
9790 Osprey 500 0070:ff02 97 -
9891 Osprey 540 0070:ff04 98
9992 Osprey 2000 0070:ff03 99 * - 21
10093 IDS Eagle 100 - Lifeview FlyVideo 98/ Lucky Star Image World ConferenceTV LR50
10194 Pinnacle PCTV Sat 11bd:001c 101 -
10295 Formac ProTV II (bt878) 102
10396 MachTV 103 * - 22
10497 Euresys Picolo 104 - Askey CPH050/ Phoebe Tv Master + FM
10598 ProVideo PV150 aa00:1460, aa01:1461, aa02:1462, aa03:1463, aa04:1464, aa05:1465, aa06:1466, aa07:1467 105 - 14ff:3002
10699 AD-TVK503 106
107100 Hercules Smart TV Stereo 107 * - 23
108101 Pace TV & Radio Card 108 - Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV, bt878
109102 IVC-200 0000:a155, 0001:a155, 0002:a155, 0003:a155, 0100:a155, 0101:a155, 0102:a155, 0103:a155, 0800:a155, 0801:a155, 0802:a155, 0803:a155 109 - 14c7:0101
110103 Grand X-Guard / Trust 814PCI 0304:0102 110
111104 Nebula Electronics DigiTV 0071:0101 111 * - 24
112105 ProVideo PV143 aa00:1430, aa00:1431, aa00:1432, aa00:1433, aa03:1433 112 - Askey CPH05X/06X (bt878) [many vendors]
113106 PHYTEC VD-009-X1 VD-011 MiniDIN (bt878) 113 - 144f:3002, 144f:3005, 144f:5000, 14ff:3000
114107 PHYTEC VD-009-X1 VD-011 Combi (bt878) 114
115108 PHYTEC VD-009 MiniDIN (bt878) 115 * - 25
116109 PHYTEC VD-009 Combi (bt878) 116 - Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar
117110 IVC-100 ff00:a132 117 -
118111 IVC-120G ff00:a182, ff01:a182, ff02:a182, ff03:a182, ff04:a182, ff05:a182, ff06:a182, ff07:a182, ff08:a182, ff09:a182, ff0a:a182, ff0b:a182, ff0c:a182, ff0d:a182, ff0e:a182, ff0f:a182 118
119112 pcHDTV HD-2000 TV 7063:2000 119 * - 26
120113 Twinhan DST + clones 11bd:0026, 1822:0001, 270f:fc00, 1822:0026 120 - Hauppauge WinCam newer (bt878)
121114 Winfast VC100 107d:6607 121 -
122115 Teppro TEV-560/InterVision IV-560 122
123116 SIMUS GVC1100 aa6a:82b2 123 * - 27
124117 NGS NGSTV+ 124 - Lifeview FlyVideo 98/ MAXI TV Video PCI2 LR50
125118 LMLBT4 125 -
126119 Tekram M205 PRO 126
127120 Conceptronic CONTVFMi 127 * - 28
128121 Euresys Picolo Tetra 1805:0105, 1805:0106, 1805:0107, 1805:0108 128 - Terratec TerraTV+ Version 1.1 (bt878)
129122 Spirit TV Tuner 129 - 153b:1127, 1852:1852
130123 AVerMedia AVerTV DVB-T 771 1461:0771 130
131124 AverMedia AverTV DVB-T 761 1461:0761 131 * - 29
132125 MATRIX Vision Sigma-SQ 132 - Imagenation PXC200
133126 MATRIX Vision Sigma-SLC 133 - 1295:200a
134127 APAC Viewcomp 878(AMAX) 134
135128 DViCO FusionHDTV DVB-T Lite 18ac:db10, 18ac:db11 135 * - 30
136129 V-Gear MyVCD 136 - Lifeview FlyVideo 98 LR50
137130 Super TV Tuner 137 - 1f7f:1850
138131 Tibet Systems 'Progress DVR' CS16 138
139132 Kodicom 4400R (master) 139 * - 31
140133 Kodicom 4400R (slave) 140 - Formac iProTV, Formac ProTV I (bt848)
141134 Adlink RTV24 141 -
142135 DViCO FusionHDTV 5 Lite 18ac:d500 142
143136 Acorp Y878F 9511:1540 143 * - 32
144137 Conceptronic CTVFMi v2 036e:109e 144 - Intel Create and Share PCI/ Smart Video Recorder III
145138 Prolink Pixelview PV-BT878P+ (Rev.2E) 145 -
146139 Prolink PixelView PlayTV MPEG2 PV-M4900 146
147140 Osprey 440 0070:ff07 147 * - 33
148141 Asound Skyeye PCTV 148 - Terratec TerraTValue Version Bt878
149142 Sabrent TV-FM (bttv version) 149 - 153b:1117, 153b:1118, 153b:1119, 153b:111a, 153b:1134, 153b:5018
150143 Hauppauge ImpactVCB (bt878) 0070:13eb 150
151144 MagicTV 151 * - 34
152145 SSAI Security Video Interface 4149:5353 152 - Leadtek WinFast 2000/ WinFast 2000 XP
153146 SSAI Ultrasound Video Interface 414a:5353 153 - 107d:6606, 107d:6609, 6606:217d, f6ff:fff6
154147 VoodooTV 200 (USA) 121a:3000 154
155148 DViCO FusionHDTV 2 dbc0:d200 155 * - 35
156149 Typhoon TV-Tuner PCI (50684) 156 - Lifeview FlyVideo 98 LR50 / Chronos Video Shuttle II
157150 Geovision GV-600 008a:763c 157 - 1851:1850, 1851:a050
158151 Kozumi KTV-01C 158
159152 Encore ENL TV-FM-2 1000:1801 159 * - 36
160153 PHYTEC VD-012 (bt878) 160 - Lifeview FlyVideo 98FM LR50 / Typhoon TView TV/FM Tuner
161154 PHYTEC VD-012-X1 (bt878) 161 - 1852:1852
162155 PHYTEC VD-012-X2 (bt878) 162
163156 IVCE-8784 0000:f050, 0001:f050, 0002:f050, 0003:f050 163 * - 37
164157 Geovision GV-800(S) (master) 800a:763d 164 - Prolink PixelView PlayTV pro
165158 Geovision GV-800(S) (slave) 800b:763d, 800c:763d, 800d:763d 165 -
166159 ProVideo PV183 1830:1540, 1831:1540, 1832:1540, 1833:1540, 1834:1540, 1835:1540, 1836:1540, 1837:1540 166
167160 Tongwei Video Technology TD-3116 f200:3116 167 * - 38
168161 Aposonic W-DVR 0279:0228 168 - Askey CPH06X TView99
169162 Adlink MPG24 169 - 144f:3000, 144f:a005, a04f:a0fc
170163 Bt848 Capture 14MHz 170
171164 CyberVision CV06 (SV) 171 * - 39
172165 Kworld V-Stream Xpert TV PVR878 172 - Pinnacle PCTV Studio/Rave
173166 PCI-8604PW 173 - 11bd:0012, bd11:1200, bd11:ff00, 11bd:ff12
174=========== ================================================================================= ============================================================================================================================================================================== 174
175 * - 40
176 - STB TV PCI FM, Gateway P/N 6000704 (bt878), 3Dfx VoodooTV 100
177 - 10b4:2636, 10b4:2645, 121a:3060
178
179 * - 41
180 - AVerMedia TVPhone 98
181 - 1461:0001, 1461:0003
182
183 * - 42
184 - ProVideo PV951
185 - aa0c:146c
186
187 * - 43
188 - Little OnAir TV
189 -
190
191 * - 44
192 - Sigma TVII-FM
193 -
194
195 * - 45
196 - MATRIX-Vision MV-Delta 2
197 -
198
199 * - 46
200 - Zoltrix Genie TV/FM
201 - 15b0:4000, 15b0:400a, 15b0:400d, 15b0:4010, 15b0:4016
202
203 * - 47
204 - Terratec TV/Radio+
205 - 153b:1123
206
207 * - 48
208 - Askey CPH03x/ Dynalink Magic TView
209 -
210
211 * - 49
212 - IODATA GV-BCTV3/PCI
213 - 10fc:4020
214
215 * - 50
216 - Prolink PV-BT878P+4E / PixelView PlayTV PAK / Lenco MXTV-9578 CP
217 -
218
219 * - 51
220 - Eagle Wireless Capricorn2 (bt878A)
221 -
222
223 * - 52
224 - Pinnacle PCTV Studio Pro
225 -
226
227 * - 53
228 - Typhoon TView RDS + FM Stereo / KNC1 TV Station RDS
229 -
230
231 * - 54
232 - Lifeview FlyVideo 2000 /FlyVideo A2/ Lifetec LT 9415 TV [LR90]
233 -
234
235 * - 55
236 - Askey CPH031/ BESTBUY Easy TV
237 -
238
239 * - 56
240 - Lifeview FlyVideo 98FM LR50
241 - a051:41a0
242
243 * - 57
244 - GrandTec 'Grand Video Capture' (Bt848)
245 - 4344:4142
246
247 * - 58
248 - Askey CPH060/ Phoebe TV Master Only (No FM)
249 -
250
251 * - 59
252 - Askey CPH03x TV Capturer
253 -
254
255 * - 60
256 - Modular Technology MM100PCTV
257 -
258
259 * - 61
260 - AG Electronics GMV1
261 - 15cb:0101
262
263 * - 62
264 - Askey CPH061/ BESTBUY Easy TV (bt878)
265 -
266
267 * - 63
268 - ATI TV-Wonder
269 - 1002:0001
270
271 * - 64
272 - ATI TV-Wonder VE
273 - 1002:0003
274
275 * - 65
276 - Lifeview FlyVideo 2000S LR90
277 -
278
279 * - 66
280 - Terratec TValueRadio
281 - 153b:1135, 153b:ff3b
282
283 * - 67
284 - IODATA GV-BCTV4/PCI
285 - 10fc:4050
286
287 * - 68
288 - 3Dfx VoodooTV FM (Euro)
289 - 10b4:2637
290
291 * - 69
292 - Active Imaging AIMMS
293 -
294
295 * - 70
296 - Prolink Pixelview PV-BT878P+ (Rev.4C,8E)
297 -
298
299 * - 71
300 - Lifeview FlyVideo 98EZ (capture only) LR51
301 - 1851:1851
302
303 * - 72
304 - Prolink Pixelview PV-BT878P+9B (PlayTV Pro rev.9B FM+NICAM)
305 - 1554:4011
306
307 * - 73
308 - Sensoray 311/611
309 - 6000:0311, 6000:0611
310
311 * - 74
312 - RemoteVision MX (RV605)
313 -
314
315 * - 75
316 - Powercolor MTV878/ MTV878R/ MTV878F
317 -
318
319 * - 76
320 - Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP)
321 - 0e11:0079
322
323 * - 77
324 - GrandTec Multi Capture Card (Bt878)
325 -
326
327 * - 78
328 - Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF
329 - 0a01:17de
330
331 * - 79
332 - DSP Design TCVIDEO
333 -
334
335 * - 80
336 - Hauppauge WinTV PVR
337 - 0070:4500
338
339 * - 81
340 - IODATA GV-BCTV5/PCI
341 - 10fc:4070, 10fc:d018
342
343 * - 82
344 - Osprey 100/150 (878)
345 - 0070:ff00
346
347 * - 83
348 - Osprey 100/150 (848)
349 -
350
351 * - 84
352 - Osprey 101 (848)
353 -
354
355 * - 85
356 - Osprey 101/151
357 -
358
359 * - 86
360 - Osprey 101/151 w/ svid
361 -
362
363 * - 87
364 - Osprey 200/201/250/251
365 -
366
367 * - 88
368 - Osprey 200/250
369 - 0070:ff01
370
371 * - 89
372 - Osprey 210/220/230
373 -
374
375 * - 90
376 - Osprey 500
377 - 0070:ff02
378
379 * - 91
380 - Osprey 540
381 - 0070:ff04
382
383 * - 92
384 - Osprey 2000
385 - 0070:ff03
386
387 * - 93
388 - IDS Eagle
389 -
390
391 * - 94
392 - Pinnacle PCTV Sat
393 - 11bd:001c
394
395 * - 95
396 - Formac ProTV II (bt878)
397 -
398
399 * - 96
400 - MachTV
401 -
402
403 * - 97
404 - Euresys Picolo
405 -
406
407 * - 98
408 - ProVideo PV150
409 - aa00:1460, aa01:1461, aa02:1462, aa03:1463, aa04:1464, aa05:1465, aa06:1466, aa07:1467
410
411 * - 99
412 - AD-TVK503
413 -
414
415 * - 100
416 - Hercules Smart TV Stereo
417 -
418
419 * - 101
420 - Pace TV & Radio Card
421 -
422
423 * - 102
424 - IVC-200
425 - 0000:a155, 0001:a155, 0002:a155, 0003:a155, 0100:a155, 0101:a155, 0102:a155, 0103:a155, 0800:a155, 0801:a155, 0802:a155, 0803:a155
426
427 * - 103
428 - Grand X-Guard / Trust 814PCI
429 - 0304:0102
430
431 * - 104
432 - Nebula Electronics DigiTV
433 - 0071:0101
434
435 * - 105
436 - ProVideo PV143
437 - aa00:1430, aa00:1431, aa00:1432, aa00:1433, aa03:1433
438
439 * - 106
440 - PHYTEC VD-009-X1 VD-011 MiniDIN (bt878)
441 -
442
443 * - 107
444 - PHYTEC VD-009-X1 VD-011 Combi (bt878)
445 -
446
447 * - 108
448 - PHYTEC VD-009 MiniDIN (bt878)
449 -
450
451 * - 109
452 - PHYTEC VD-009 Combi (bt878)
453 -
454
455 * - 110
456 - IVC-100
457 - ff00:a132
458
459 * - 111
460 - IVC-120G
461 - ff00:a182, ff01:a182, ff02:a182, ff03:a182, ff04:a182, ff05:a182, ff06:a182, ff07:a182, ff08:a182, ff09:a182, ff0a:a182, ff0b:a182, ff0c:a182, ff0d:a182, ff0e:a182, ff0f:a182
462
463 * - 112
464 - pcHDTV HD-2000 TV
465 - 7063:2000
466
467 * - 113
468 - Twinhan DST + clones
469 - 11bd:0026, 1822:0001, 270f:fc00, 1822:0026
470
471 * - 114
472 - Winfast VC100
473 - 107d:6607
474
475 * - 115
476 - Teppro TEV-560/InterVision IV-560
477 -
478
479 * - 116
480 - SIMUS GVC1100
481 - aa6a:82b2
482
483 * - 117
484 - NGS NGSTV+
485 -
486
487 * - 118
488 - LMLBT4
489 -
490
491 * - 119
492 - Tekram M205 PRO
493 -
494
495 * - 120
496 - Conceptronic CONTVFMi
497 -
498
499 * - 121
500 - Euresys Picolo Tetra
501 - 1805:0105, 1805:0106, 1805:0107, 1805:0108
502
503 * - 122
504 - Spirit TV Tuner
505 -
506
507 * - 123
508 - AVerMedia AVerTV DVB-T 771
509 - 1461:0771
510
511 * - 124
512 - AverMedia AverTV DVB-T 761
513 - 1461:0761
514
515 * - 125
516 - MATRIX Vision Sigma-SQ
517 -
518
519 * - 126
520 - MATRIX Vision Sigma-SLC
521 -
522
523 * - 127
524 - APAC Viewcomp 878(AMAX)
525 -
526
527 * - 128
528 - DViCO FusionHDTV DVB-T Lite
529 - 18ac:db10, 18ac:db11
530
531 * - 129
532 - V-Gear MyVCD
533 -
534
535 * - 130
536 - Super TV Tuner
537 -
538
539 * - 131
540 - Tibet Systems 'Progress DVR' CS16
541 -
542
543 * - 132
544 - Kodicom 4400R (master)
545 -
546
547 * - 133
548 - Kodicom 4400R (slave)
549 -
550
551 * - 134
552 - Adlink RTV24
553 -
554
555 * - 135
556 - DViCO FusionHDTV 5 Lite
557 - 18ac:d500
558
559 * - 136
560 - Acorp Y878F
561 - 9511:1540
562
563 * - 137
564 - Conceptronic CTVFMi v2
565 - 036e:109e
566
567 * - 138
568 - Prolink Pixelview PV-BT878P+ (Rev.2E)
569 -
570
571 * - 139
572 - Prolink PixelView PlayTV MPEG2 PV-M4900
573 -
574
575 * - 140
576 - Osprey 440
577 - 0070:ff07
578
579 * - 141
580 - Asound Skyeye PCTV
581 -
582
583 * - 142
584 - Sabrent TV-FM (bttv version)
585 -
586
587 * - 143
588 - Hauppauge ImpactVCB (bt878)
589 - 0070:13eb
590
591 * - 144
592 - MagicTV
593 -
594
595 * - 145
596 - SSAI Security Video Interface
597 - 4149:5353
598
599 * - 146
600 - SSAI Ultrasound Video Interface
601 - 414a:5353
602
603 * - 147
604 - VoodooTV 200 (USA)
605 - 121a:3000
606
607 * - 148
608 - DViCO FusionHDTV 2
609 - dbc0:d200
610
611 * - 149
612 - Typhoon TV-Tuner PCI (50684)
613 -
614
615 * - 150
616 - Geovision GV-600
617 - 008a:763c
618
619 * - 151
620 - Kozumi KTV-01C
621 -
622
623 * - 152
624 - Encore ENL TV-FM-2
625 - 1000:1801
626
627 * - 153
628 - PHYTEC VD-012 (bt878)
629 -
630
631 * - 154
632 - PHYTEC VD-012-X1 (bt878)
633 -
634
635 * - 155
636 - PHYTEC VD-012-X2 (bt878)
637 -
638
639 * - 156
640 - IVCE-8784
641 - 0000:f050, 0001:f050, 0002:f050, 0003:f050
642
643 * - 157
644 - Geovision GV-800(S) (master)
645 - 800a:763d
646
647 * - 158
648 - Geovision GV-800(S) (slave)
649 - 800b:763d, 800c:763d, 800d:763d
650
651 * - 159
652 - ProVideo PV183
653 - 1830:1540, 1831:1540, 1832:1540, 1833:1540, 1834:1540, 1835:1540, 1836:1540, 1837:1540
654
655 * - 160
656 - Tongwei Video Technology TD-3116
657 - f200:3116
658
659 * - 161
660 - Aposonic W-DVR
661 - 0279:0228
662
663 * - 162
664 - Adlink MPG24
665 -
666
667 * - 163
668 - Bt848 Capture 14MHz
669 -
670
671 * - 164
672 - CyberVision CV06 (SV)
673 -
674
675 * - 165
676 - Kworld V-Stream Xpert TV PVR878
677 -
678
679 * - 166
680 - PCI-8604PW
681 -
diff --git a/Documentation/media/v4l-drivers/cx23885-cardlist.rst b/Documentation/media/v4l-drivers/cx23885-cardlist.rst
index fd20b50d2c1d..3129ef04ddd3 100644
--- a/Documentation/media/v4l-drivers/cx23885-cardlist.rst
+++ b/Documentation/media/v4l-drivers/cx23885-cardlist.rst
@@ -1,65 +1,245 @@
1cx23885 cards list 1cx23885 cards list
2================== 2==================
3 3
4=========== ==================================== ====================================================================================== 4.. tabularcolumns:: |p{1.4cm}|p{11.1cm}|p{4.2cm}|
5Card number Card name PCI IDs 5
6=========== ==================================== ====================================================================================== 6.. flat-table::
70 UNKNOWN/GENERIC 0070:3400 7 :header-rows: 1
81 Hauppauge WinTV-HVR1800lp 0070:7600 8 :widths: 2 19 18
92 Hauppauge WinTV-HVR1800 0070:7800, 0070:7801, 0070:7809 9 :stub-columns: 0
103 Hauppauge WinTV-HVR1250 0070:7911 10
114 DViCO FusionHDTV5 Express 18ac:d500 11 * - Card number
125 Hauppauge WinTV-HVR1500Q 0070:7790, 0070:7797 12 - Card name
136 Hauppauge WinTV-HVR1500 0070:7710, 0070:7717 13 - PCI IDs
147 Hauppauge WinTV-HVR1200 0070:71d1, 0070:71d3 14
158 Hauppauge WinTV-HVR1700 0070:8101 15 * - 0
169 Hauppauge WinTV-HVR1400 0070:8010 16 - UNKNOWN/GENERIC
1710 DViCO FusionHDTV7 Dual Express 18ac:d618 17 - 0070:3400
1811 DViCO FusionHDTV DVB-T Dual Express 18ac:db78 18
1912 Leadtek Winfast PxDVR3200 H 107d:6681 19 * - 1
2013 Compro VideoMate E650F 185b:e800 20 - Hauppauge WinTV-HVR1800lp
2114 TurboSight TBS 6920 6920:8888 21 - 0070:7600
2215 TeVii S470 d470:9022 22
2316 DVBWorld DVB-S2 2005 0001:2005 23 * - 2
2417 NetUP Dual DVB-S2 CI 1b55:2a2c 24 - Hauppauge WinTV-HVR1800
2518 Hauppauge WinTV-HVR1270 0070:2211 25 - 0070:7800, 0070:7801, 0070:7809
2619 Hauppauge WinTV-HVR1275 0070:2215, 0070:221d, 0070:22f2 26
2720 Hauppauge WinTV-HVR1255 0070:2251, 0070:22f1 27 * - 3
2821 Hauppauge WinTV-HVR1210 0070:2291, 0070:2295, 0070:2299, 0070:229d, 0070:22f0, 0070:22f3, 0070:22f4, 0070:22f5 28 - Hauppauge WinTV-HVR1250
2922 Mygica X8506 DMB-TH 14f1:8651 29 - 0070:7911
3023 Magic-Pro ProHDTV Extreme 2 14f1:8657 30
3124 Hauppauge WinTV-HVR1850 0070:8541 31 * - 4
3225 Compro VideoMate E800 1858:e800 32 - DViCO FusionHDTV5 Express
3326 Hauppauge WinTV-HVR1290 0070:8551 33 - 18ac:d500
3427 Mygica X8558 PRO DMB-TH 14f1:8578 34
3528 LEADTEK WinFast PxTV1200 107d:6f22 35 * - 5
3629 GoTView X5 3D Hybrid 5654:2390 36 - Hauppauge WinTV-HVR1500Q
3730 NetUP Dual DVB-T/C-CI RF 1b55:e2e4 37 - 0070:7790, 0070:7797
3831 Leadtek Winfast PxDVR3200 H XC4000 107d:6f39 38
3932 MPX-885 39 * - 6
4033 Mygica X8502/X8507 ISDB-T 14f1:8502 40 - Hauppauge WinTV-HVR1500
4134 TerraTec Cinergy T PCIe Dual 153b:117e 41 - 0070:7710, 0070:7717
4235 TeVii S471 d471:9022 42
4336 Hauppauge WinTV-HVR1255 0070:2259 43 * - 7
4437 Prof Revolution DVB-S2 8000 8000:3034 44 - Hauppauge WinTV-HVR1200
4538 Hauppauge WinTV-HVR4400/HVR5500 0070:c108, 0070:c138, 0070:c1f8 45 - 0070:71d1, 0070:71d3
4639 AVerTV Hybrid Express Slim HC81R 1461:d939 46
4740 TurboSight TBS 6981 6981:8888 47 * - 8
4841 TurboSight TBS 6980 6980:8888 48 - Hauppauge WinTV-HVR1700
4942 Leadtek Winfast PxPVR2200 107d:6f21 49 - 0070:8101
5043 Hauppauge ImpactVCB-e 0070:7133 50
5144 DViCO FusionHDTV DVB-T Dual Express2 18ac:db98 51 * - 9
5245 DVBSky T9580 4254:9580 52 - Hauppauge WinTV-HVR1400
5346 DVBSky T980C 4254:980c 53 - 0070:8010
5447 DVBSky S950C 4254:950c 54
5548 Technotrend TT-budget CT2-4500 CI 13c2:3013 55 * - 10
5649 DVBSky S950 4254:0950 56 - DViCO FusionHDTV7 Dual Express
5750 DVBSky S952 4254:0952 57 - 18ac:d618
5851 DVBSky T982 4254:0982 58
5952 Hauppauge WinTV-HVR5525 0070:f038 59 * - 11
6053 Hauppauge WinTV Starburst 0070:c12a 60 - DViCO FusionHDTV DVB-T Dual Express
6154 ViewCast 260e 1576:0260 61 - 18ac:db78
6255 ViewCast 460e 1576:0460 62
6356 Hauppauge WinTV-QuadHD-DVB 0070:6a28, 0070:6b28 63 * - 12
6457 Hauppauge WinTV-QuadHD-ATSC 0070:6a18, 0070:6b18 64 - Leadtek Winfast PxDVR3200 H
65=========== ==================================== ====================================================================================== 65 - 107d:6681
66
67 * - 13
68 - Compro VideoMate E650F
69 - 185b:e800
70
71 * - 14
72 - TurboSight TBS 6920
73 - 6920:8888
74
75 * - 15
76 - TeVii S470
77 - d470:9022
78
79 * - 16
80 - DVBWorld DVB-S2 2005
81 - 0001:2005
82
83 * - 17
84 - NetUP Dual DVB-S2 CI
85 - 1b55:2a2c
86
87 * - 18
88 - Hauppauge WinTV-HVR1270
89 - 0070:2211
90
91 * - 19
92 - Hauppauge WinTV-HVR1275
93 - 0070:2215, 0070:221d, 0070:22f2
94
95 * - 20
96 - Hauppauge WinTV-HVR1255
97 - 0070:2251, 0070:22f1
98
99 * - 21
100 - Hauppauge WinTV-HVR1210
101 - 0070:2291, 0070:2295, 0070:2299, 0070:229d, 0070:22f0, 0070:22f3, 0070:22f4, 0070:22f5
102
103 * - 22
104 - Mygica X8506 DMB-TH
105 - 14f1:8651
106
107 * - 23
108 - Magic-Pro ProHDTV Extreme 2
109 - 14f1:8657
110
111 * - 24
112 - Hauppauge WinTV-HVR1850
113 - 0070:8541
114
115 * - 25
116 - Compro VideoMate E800
117 - 1858:e800
118
119 * - 26
120 - Hauppauge WinTV-HVR1290
121 - 0070:8551
122
123 * - 27
124 - Mygica X8558 PRO DMB-TH
125 - 14f1:8578
126
127 * - 28
128 - LEADTEK WinFast PxTV1200
129 - 107d:6f22
130
131 * - 29
132 - GoTView X5 3D Hybrid
133 - 5654:2390
134
135 * - 30
136 - NetUP Dual DVB-T/C-CI RF
137 - 1b55:e2e4
138
139 * - 31
140 - Leadtek Winfast PxDVR3200 H XC4000
141 - 107d:6f39
142
143 * - 32
144 - MPX-885
145 -
146
147 * - 33
148 - Mygica X8502/X8507 ISDB-T
149 - 14f1:8502
150
151 * - 34
152 - TerraTec Cinergy T PCIe Dual
153 - 153b:117e
154
155 * - 35
156 - TeVii S471
157 - d471:9022
158
159 * - 36
160 - Hauppauge WinTV-HVR1255
161 - 0070:2259
162
163 * - 37
164 - Prof Revolution DVB-S2 8000
165 - 8000:3034
166
167 * - 38
168 - Hauppauge WinTV-HVR4400/HVR5500
169 - 0070:c108, 0070:c138, 0070:c1f8
170
171 * - 39
172 - AVerTV Hybrid Express Slim HC81R
173 - 1461:d939
174
175 * - 40
176 - TurboSight TBS 6981
177 - 6981:8888
178
179 * - 41
180 - TurboSight TBS 6980
181 - 6980:8888
182
183 * - 42
184 - Leadtek Winfast PxPVR2200
185 - 107d:6f21
186
187 * - 43
188 - Hauppauge ImpactVCB-e
189 - 0070:7133
190
191 * - 44
192 - DViCO FusionHDTV DVB-T Dual Express2
193 - 18ac:db98
194
195 * - 45
196 - DVBSky T9580
197 - 4254:9580
198
199 * - 46
200 - DVBSky T980C
201 - 4254:980c
202
203 * - 47
204 - DVBSky S950C
205 - 4254:950c
206
207 * - 48
208 - Technotrend TT-budget CT2-4500 CI
209 - 13c2:3013
210
211 * - 49
212 - DVBSky S950
213 - 4254:0950
214
215 * - 50
216 - DVBSky S952
217 - 4254:0952
218
219 * - 51
220 - DVBSky T982
221 - 4254:0982
222
223 * - 52
224 - Hauppauge WinTV-HVR5525
225 - 0070:f038
226
227 * - 53
228 - Hauppauge WinTV Starburst
229 - 0070:c12a
230
231 * - 54
232 - ViewCast 260e
233 - 1576:0260
234
235 * - 55
236 - ViewCast 460e
237 - 1576:0460
238
239 * - 56
240 - Hauppauge WinTV-QuadHD-DVB
241 - 0070:6a28, 0070:6b28
242
243 * - 57
244 - Hauppauge WinTV-QuadHD-ATSC
245 - 0070:6a18, 0070:6b18
diff --git a/Documentation/media/v4l-drivers/cx88-cardlist.rst b/Documentation/media/v4l-drivers/cx88-cardlist.rst
index 8cc1cea17035..21648b8c2e83 100644
--- a/Documentation/media/v4l-drivers/cx88-cardlist.rst
+++ b/Documentation/media/v4l-drivers/cx88-cardlist.rst
@@ -1,98 +1,377 @@
1CX88 cards list 1CX88 cards list
2=============== 2===============
3 3
4=========== =================================================== ====================================================================================== 4.. tabularcolumns:: |p{1.4cm}|p{11.1cm}|p{4.2cm}|
5Card number Card name PCI IDs 5
6=========== =================================================== ====================================================================================== 6.. flat-table::
70 UNKNOWN/GENERIC 7 :header-rows: 1
81 Hauppauge WinTV 34xxx models 0070:3400, 0070:3401 8 :widths: 2 19 18
92 GDI Black Gold 14c7:0106, 14c7:0107 9 :stub-columns: 0
103 PixelView 1554:4811 10
114 ATI TV Wonder Pro 1002:00f8, 1002:00f9 11 * - Card number
125 Leadtek Winfast 2000XP Expert 107d:6611, 107d:6613 12 - Card name
136 AverTV Studio 303 (M126) 1461:000b 13 - PCI IDs
147 MSI TV-@nywhere Master 1462:8606 14
158 Leadtek Winfast DV2000 107d:6620, 107d:6621 15 * - 0
169 Leadtek PVR 2000 107d:663b, 107d:663c, 107d:6632, 107d:6630, 107d:6638, 107d:6631, 107d:6637, 107d:663d 16 - UNKNOWN/GENERIC
1710 IODATA GV-VCP3/PCI 10fc:d003 17 -
1811 Prolink PlayTV PVR 18
1912 ASUS PVR-416 1043:4823, 1461:c111 19 * - 1
2013 MSI TV-@nywhere 20 - Hauppauge WinTV 34xxx models
2114 KWorld/VStream XPert DVB-T 17de:08a6 21 - 0070:3400, 0070:3401
2215 DViCO FusionHDTV DVB-T1 18ac:db00 22
2316 KWorld LTV883RF 23 * - 2
2417 DViCO FusionHDTV 3 Gold-Q 18ac:d810, 18ac:d800 24 - GDI Black Gold
2518 Hauppauge Nova-T DVB-T 0070:9002, 0070:9001, 0070:9000 25 - 14c7:0106, 14c7:0107
2619 Conexant DVB-T reference design 14f1:0187 26
2720 Provideo PV259 1540:2580 27 * - 3
2821 DViCO FusionHDTV DVB-T Plus 18ac:db10, 18ac:db11 28 - PixelView
2922 pcHDTV HD3000 HDTV 7063:3000 29 - 1554:4811
3023 digitalnow DNTV Live! DVB-T 17de:a8a6 30
3124 Hauppauge WinTV 28xxx (Roslyn) models 0070:2801 31 * - 4
3225 Digital-Logic MICROSPACE Entertainment Center (MEC) 14f1:0342 32 - ATI TV Wonder Pro
3326 IODATA GV/BCTV7E 10fc:d035 33 - 1002:00f8, 1002:00f9
3427 PixelView PlayTV Ultra Pro (Stereo) 34
3528 DViCO FusionHDTV 3 Gold-T 18ac:d820 35 * - 5
3629 ADS Tech Instant TV DVB-T PCI 1421:0334 36 - Leadtek Winfast 2000XP Expert
3730 TerraTec Cinergy 1400 DVB-T 153b:1166 37 - 107d:6611, 107d:6613
3831 DViCO FusionHDTV 5 Gold 18ac:d500 38
3932 AverMedia UltraTV Media Center PCI 550 1461:8011 39 * - 6
4033 Kworld V-Stream Xpert DVD 40 - AverTV Studio 303 (M126)
4134 ATI HDTV Wonder 1002:a101 41 - 1461:000b
4235 WinFast DTV1000-T 107d:665f 42
4336 AVerTV 303 (M126) 1461:000a 43 * - 7
4437 Hauppauge Nova-S-Plus DVB-S 0070:9201, 0070:9202 44 - MSI TV-@nywhere Master
4538 Hauppauge Nova-SE2 DVB-S 0070:9200 45 - 1462:8606
4639 KWorld DVB-S 100 17de:08b2, 1421:0341 46
4740 Hauppauge WinTV-HVR1100 DVB-T/Hybrid 0070:9400, 0070:9402 47 * - 8
4841 Hauppauge WinTV-HVR1100 DVB-T/Hybrid (Low Profile) 0070:9800, 0070:9802 48 - Leadtek Winfast DV2000
4942 digitalnow DNTV Live! DVB-T Pro 1822:0025, 1822:0019 49 - 107d:6620, 107d:6621
5043 KWorld/VStream XPert DVB-T with cx22702 17de:08a1, 12ab:2300 50
5144 DViCO FusionHDTV DVB-T Dual Digital 18ac:db50, 18ac:db54 51 * - 9
5245 KWorld HardwareMpegTV XPert 17de:0840, 1421:0305 52 - Leadtek PVR 2000
5346 DViCO FusionHDTV DVB-T Hybrid 18ac:db40, 18ac:db44 53 - 107d:663b, 107d:663c, 107d:6632, 107d:6630, 107d:6638, 107d:6631, 107d:6637, 107d:663d
5447 pcHDTV HD5500 HDTV 7063:5500 54
5548 Kworld MCE 200 Deluxe 17de:0841 55 * - 10
5649 PixelView PlayTV P7000 1554:4813 56 - IODATA GV-VCP3/PCI
5750 NPG Tech Real TV FM Top 10 14f1:0842 57 - 10fc:d003
5851 WinFast DTV2000 H 107d:665e 58
5952 Geniatech DVB-S 14f1:0084 59 * - 11
6053 Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DVB-T 0070:1404, 0070:1400, 0070:1401, 0070:1402 60 - Prolink PlayTV PVR
6154 Norwood Micro TV Tuner 61 -
6255 Shenzhen Tungsten Ages Tech TE-DTV-250 / Swann OEM c180:c980 62
6356 Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder 0070:9600, 0070:9601, 0070:9602 63 * - 12
6457 ADS Tech Instant Video PCI 1421:0390 64 - ASUS PVR-416
6558 Pinnacle PCTV HD 800i 11bd:0051 65 - 1043:4823, 1461:c111
6659 DViCO FusionHDTV 5 PCI nano 18ac:d530 66
6760 Pinnacle Hybrid PCTV 12ab:1788 67 * - 13
6861 Leadtek TV2000 XP Global 107d:6f18, 107d:6618, 107d:6619 68 - MSI TV-@nywhere
6962 PowerColor RA330 14f1:ea3d 69 -
7063 Geniatech X8000-MT DVBT 14f1:8852 70
7164 DViCO FusionHDTV DVB-T PRO 18ac:db30 71 * - 14
7265 DViCO FusionHDTV 7 Gold 18ac:d610 72 - KWorld/VStream XPert DVB-T
7366 Prolink Pixelview MPEG 8000GT 1554:4935 73 - 17de:08a6
7467 Kworld PlusTV HD PCI 120 (ATSC 120) 17de:08c1 74
7568 Hauppauge WinTV-HVR4000 DVB-S/S2/T/Hybrid 0070:6900, 0070:6904, 0070:6902 75 * - 15
7669 Hauppauge WinTV-HVR4000(Lite) DVB-S/S2 0070:6905, 0070:6906 76 - DViCO FusionHDTV DVB-T1
7770 TeVii S460 DVB-S/S2 d460:9022 77 - 18ac:db00
7871 Omicom SS4 DVB-S/S2 PCI A044:2011 78
7972 TBS 8920 DVB-S/S2 8920:8888 79 * - 16
8073 TeVii S420 DVB-S d420:9022 80 - KWorld LTV883RF
8174 Prolink Pixelview Global Extreme 1554:4976 81 -
8275 PROF 7300 DVB-S/S2 B033:3033 82
8376 SATTRADE ST4200 DVB-S/S2 b200:4200 83 * - 17
8477 TBS 8910 DVB-S 8910:8888 84 - DViCO FusionHDTV 3 Gold-Q
8578 Prof 6200 DVB-S b022:3022 85 - 18ac:d810, 18ac:d800
8679 Terratec Cinergy HT PCI MKII 153b:1177 86
8780 Hauppauge WinTV-IR Only 0070:9290 87 * - 18
8881 Leadtek WinFast DTV1800 Hybrid 107d:6654 88 - Hauppauge Nova-T DVB-T
8982 WinFast DTV2000 H rev. J 107d:6f2b 89 - 0070:9002, 0070:9001, 0070:9000
9083 Prof 7301 DVB-S/S2 b034:3034 90
9184 Samsung SMT 7020 DVB-S 18ac:dc00, 18ac:dccd 91 * - 19
9285 Twinhan VP-1027 DVB-S 1822:0023 92 - Conexant DVB-T reference design
9386 TeVii S464 DVB-S/S2 d464:9022 93 - 14f1:0187
9487 Leadtek WinFast DTV2000 H PLUS 107d:6f42 94
9588 Leadtek WinFast DTV1800 H (XC4000) 107d:6f38 95 * - 20
9689 Leadtek TV2000 XP Global (SC4100) 107d:6f36 96 - Provideo PV259
9790 Leadtek TV2000 XP Global (XC4100) 107d:6f43 97 - 1540:2580
98=========== =================================================== ====================================================================================== 98
99 * - 21
100 - DViCO FusionHDTV DVB-T Plus
101 - 18ac:db10, 18ac:db11
102
103 * - 22
104 - pcHDTV HD3000 HDTV
105 - 7063:3000
106
107 * - 23
108 - digitalnow DNTV Live! DVB-T
109 - 17de:a8a6
110
111 * - 24
112 - Hauppauge WinTV 28xxx (Roslyn) models
113 - 0070:2801
114
115 * - 25
116 - Digital-Logic MICROSPACE Entertainment Center (MEC)
117 - 14f1:0342
118
119 * - 26
120 - IODATA GV/BCTV7E
121 - 10fc:d035
122
123 * - 27
124 - PixelView PlayTV Ultra Pro (Stereo)
125 -
126
127 * - 28
128 - DViCO FusionHDTV 3 Gold-T
129 - 18ac:d820
130
131 * - 29
132 - ADS Tech Instant TV DVB-T PCI
133 - 1421:0334
134
135 * - 30
136 - TerraTec Cinergy 1400 DVB-T
137 - 153b:1166
138
139 * - 31
140 - DViCO FusionHDTV 5 Gold
141 - 18ac:d500
142
143 * - 32
144 - AverMedia UltraTV Media Center PCI 550
145 - 1461:8011
146
147 * - 33
148 - Kworld V-Stream Xpert DVD
149 -
150
151 * - 34
152 - ATI HDTV Wonder
153 - 1002:a101
154
155 * - 35
156 - WinFast DTV1000-T
157 - 107d:665f
158
159 * - 36
160 - AVerTV 303 (M126)
161 - 1461:000a
162
163 * - 37
164 - Hauppauge Nova-S-Plus DVB-S
165 - 0070:9201, 0070:9202
166
167 * - 38
168 - Hauppauge Nova-SE2 DVB-S
169 - 0070:9200
170
171 * - 39
172 - KWorld DVB-S 100
173 - 17de:08b2, 1421:0341
174
175 * - 40
176 - Hauppauge WinTV-HVR1100 DVB-T/Hybrid
177 - 0070:9400, 0070:9402
178
179 * - 41
180 - Hauppauge WinTV-HVR1100 DVB-T/Hybrid (Low Profile)
181 - 0070:9800, 0070:9802
182
183 * - 42
184 - digitalnow DNTV Live! DVB-T Pro
185 - 1822:0025, 1822:0019
186
187 * - 43
188 - KWorld/VStream XPert DVB-T with cx22702
189 - 17de:08a1, 12ab:2300
190
191 * - 44
192 - DViCO FusionHDTV DVB-T Dual Digital
193 - 18ac:db50, 18ac:db54
194
195 * - 45
196 - KWorld HardwareMpegTV XPert
197 - 17de:0840, 1421:0305
198
199 * - 46
200 - DViCO FusionHDTV DVB-T Hybrid
201 - 18ac:db40, 18ac:db44
202
203 * - 47
204 - pcHDTV HD5500 HDTV
205 - 7063:5500
206
207 * - 48
208 - Kworld MCE 200 Deluxe
209 - 17de:0841
210
211 * - 49
212 - PixelView PlayTV P7000
213 - 1554:4813
214
215 * - 50
216 - NPG Tech Real TV FM Top 10
217 - 14f1:0842
218
219 * - 51
220 - WinFast DTV2000 H
221 - 107d:665e
222
223 * - 52
224 - Geniatech DVB-S
225 - 14f1:0084
226
227 * - 53
228 - Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DVB-T
229 - 0070:1404, 0070:1400, 0070:1401, 0070:1402
230
231 * - 54
232 - Norwood Micro TV Tuner
233 -
234
235 * - 55
236 - Shenzhen Tungsten Ages Tech TE-DTV-250 / Swann OEM
237 - c180:c980
238
239 * - 56
240 - Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder
241 - 0070:9600, 0070:9601, 0070:9602
242
243 * - 57
244 - ADS Tech Instant Video PCI
245 - 1421:0390
246
247 * - 58
248 - Pinnacle PCTV HD 800i
249 - 11bd:0051
250
251 * - 59
252 - DViCO FusionHDTV 5 PCI nano
253 - 18ac:d530
254
255 * - 60
256 - Pinnacle Hybrid PCTV
257 - 12ab:1788
258
259 * - 61
260 - Leadtek TV2000 XP Global
261 - 107d:6f18, 107d:6618, 107d:6619
262
263 * - 62
264 - PowerColor RA330
265 - 14f1:ea3d
266
267 * - 63
268 - Geniatech X8000-MT DVBT
269 - 14f1:8852
270
271 * - 64
272 - DViCO FusionHDTV DVB-T PRO
273 - 18ac:db30
274
275 * - 65
276 - DViCO FusionHDTV 7 Gold
277 - 18ac:d610
278
279 * - 66
280 - Prolink Pixelview MPEG 8000GT
281 - 1554:4935
282
283 * - 67
284 - Kworld PlusTV HD PCI 120 (ATSC 120)
285 - 17de:08c1
286
287 * - 68
288 - Hauppauge WinTV-HVR4000 DVB-S/S2/T/Hybrid
289 - 0070:6900, 0070:6904, 0070:6902
290
291 * - 69
292 - Hauppauge WinTV-HVR4000(Lite) DVB-S/S2
293 - 0070:6905, 0070:6906
294
295 * - 70
296 - TeVii S460 DVB-S/S2
297 - d460:9022
298
299 * - 71
300 - Omicom SS4 DVB-S/S2 PCI
301 - A044:2011
302
303 * - 72
304 - TBS 8920 DVB-S/S2
305 - 8920:8888
306
307 * - 73
308 - TeVii S420 DVB-S
309 - d420:9022
310
311 * - 74
312 - Prolink Pixelview Global Extreme
313 - 1554:4976
314
315 * - 75
316 - PROF 7300 DVB-S/S2
317 - B033:3033
318
319 * - 76
320 - SATTRADE ST4200 DVB-S/S2
321 - b200:4200
322
323 * - 77
324 - TBS 8910 DVB-S
325 - 8910:8888
326
327 * - 78
328 - Prof 6200 DVB-S
329 - b022:3022
330
331 * - 79
332 - Terratec Cinergy HT PCI MKII
333 - 153b:1177
334
335 * - 80
336 - Hauppauge WinTV-IR Only
337 - 0070:9290
338
339 * - 81
340 - Leadtek WinFast DTV1800 Hybrid
341 - 107d:6654
342
343 * - 82
344 - WinFast DTV2000 H rev. J
345 - 107d:6f2b
346
347 * - 83
348 - Prof 7301 DVB-S/S2
349 - b034:3034
350
351 * - 84
352 - Samsung SMT 7020 DVB-S
353 - 18ac:dc00, 18ac:dccd
354
355 * - 85
356 - Twinhan VP-1027 DVB-S
357 - 1822:0023
358
359 * - 86
360 - TeVii S464 DVB-S/S2
361 - d464:9022
362
363 * - 87
364 - Leadtek WinFast DTV2000 H PLUS
365 - 107d:6f42
366
367 * - 88
368 - Leadtek WinFast DTV1800 H (XC4000)
369 - 107d:6f38
370
371 * - 89
372 - Leadtek TV2000 XP Global (SC4100)
373 - 107d:6f36
374
375 * - 90
376 - Leadtek TV2000 XP Global (XC4100)
377 - 107d:6f43
diff --git a/Documentation/media/v4l-drivers/em28xx-cardlist.rst b/Documentation/media/v4l-drivers/em28xx-cardlist.rst
index 76b1d301754c..ec938c08f43d 100644
--- a/Documentation/media/v4l-drivers/em28xx-cardlist.rst
+++ b/Documentation/media/v4l-drivers/em28xx-cardlist.rst
@@ -1,107 +1,422 @@
1EM28xx cards list 1EM28xx cards list
2================= 2=================
3 3
4=========== ==================================================================== ================ ================================================================================================================================== 4.. tabularcolumns:: |p{1.4cm}|p{10.0cm}|p{1.9cm}|p{4.2cm}|
5Card number Card name Empia Chip USB IDs 5
6=========== ==================================================================== ================ ================================================================================================================================== 6.. flat-table::
70 Unknown EM2800 video grabber em2800 eb1a:2800 7 :header-rows: 1
81 Unknown EM2750/28xx video grabber em2820 or em2840 eb1a:2710, eb1a:2820, eb1a:2821, eb1a:2860, eb1a:2861, eb1a:2862, eb1a:2863, eb1a:2870, eb1a:2881, eb1a:2883, eb1a:2868, eb1a:2875 8 :widths: 2 12 3 16
92 Terratec Cinergy 250 USB em2820 or em2840 0ccd:0036 9 :stub-columns: 0
103 Pinnacle PCTV USB 2 em2820 or em2840 2304:0208 10
114 Hauppauge WinTV USB 2 em2820 or em2840 2040:4200, 2040:4201 11 * - Card number
125 MSI VOX USB 2.0 em2820 or em2840 12 - Card name
136 Terratec Cinergy 200 USB em2800 13 - Empia Chip
147 Leadtek Winfast USB II em2800 0413:6023 14 - USB IDs
158 Kworld USB2800 em2800 15 * - 0
169 Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker em2820 or em2840 1b80:e302, 1b80:e304, 2304:0207, 2304:021a, 093b:a003 16 - Unknown EM2800 video grabber
1710 Hauppauge WinTV HVR 900 em2880 2040:6500 17 - em2800
1811 Terratec Hybrid XS em2880 18 - eb1a:2800
1912 Kworld PVR TV 2800 RF em2820 or em2840 19 * - 1
2013 Terratec Prodigy XS em2880 20 - Unknown EM2750/28xx video grabber
2114 SIIG AVTuner-PVR / Pixelview Prolink PlayTV USB 2.0 em2820 or em2840 21 - em2820 or em2840
2215 V-Gear PocketTV em2800 22 - eb1a:2710, eb1a:2820, eb1a:2821, eb1a:2860, eb1a:2861, eb1a:2862, eb1a:2863, eb1a:2870, eb1a:2881, eb1a:2883, eb1a:2868, eb1a:2875
2316 Hauppauge WinTV HVR 950 em2883 2040:6513, 2040:6517, 2040:651b 23 * - 2
2417 Pinnacle PCTV HD Pro Stick em2880 2304:0227 24 - Terratec Cinergy 250 USB
2518 Hauppauge WinTV HVR 900 (R2) em2880 2040:6502 25 - em2820 or em2840
2619 EM2860/SAA711X Reference Design em2860 26 - 0ccd:0036
2720 AMD ATI TV Wonder HD 600 em2880 0438:b002 27 * - 3
2821 eMPIA Technology, Inc. GrabBeeX+ Video Encoder em2800 eb1a:2801 28 - Pinnacle PCTV USB 2
2922 EM2710/EM2750/EM2751 webcam grabber em2750 eb1a:2750, eb1a:2751 29 - em2820 or em2840
3023 Huaqi DLCW-130 em2750 30 - 2304:0208
3124 D-Link DUB-T210 TV Tuner em2820 or em2840 2001:f112 31 * - 4
3225 Gadmei UTV310 em2820 or em2840 32 - Hauppauge WinTV USB 2
3326 Hercules Smart TV USB 2.0 em2820 or em2840 33 - em2820 or em2840
3427 Pinnacle PCTV USB 2 (Philips FM1216ME) em2820 or em2840 34 - 2040:4200, 2040:4201
3528 Leadtek Winfast USB II Deluxe em2820 or em2840 35 * - 5
3629 EM2860/TVP5150 Reference Design em2860 36 - MSI VOX USB 2.0
3730 Videology 20K14XUSB USB2.0 em2820 or em2840 37 - em2820 or em2840
3831 Usbgear VD204v9 em2821 38 -
3932 Supercomp USB 2.0 TV em2821 39 * - 6
4033 Elgato Video Capture em2860 0fd9:0033 40 - Terratec Cinergy 200 USB
4134 Terratec Cinergy A Hybrid XS em2860 0ccd:004f 41 - em2800
4235 Typhoon DVD Maker em2860 42 -
4336 NetGMBH Cam em2860 43 * - 7
4437 Gadmei UTV330 em2860 eb1a:50a6 44 - Leadtek Winfast USB II
4538 Yakumo MovieMixer em2861 45 - em2800
4639 KWorld PVRTV 300U em2861 eb1a:e300 46 - 0413:6023
4740 Plextor ConvertX PX-TV100U em2861 093b:a005 47 * - 8
4841 Kworld 350 U DVB-T em2870 eb1a:e350 48 - Kworld USB2800
4942 Kworld 355 U DVB-T em2870 eb1a:e355, eb1a:e357, eb1a:e359 49 - em2800
5043 Terratec Cinergy T XS em2870 50 -
5144 Terratec Cinergy T XS (MT2060) em2870 0ccd:0043 51 * - 9
5245 Pinnacle PCTV DVB-T em2870 52 - Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker / Kworld DVD Maker 2 / Plextor ConvertX PX-AV100U
5346 Compro, VideoMate U3 em2870 185b:2870 53 - em2820 or em2840
5447 KWorld DVB-T 305U em2880 eb1a:e305 54 - 1b80:e302, 1b80:e304, 2304:0207, 2304:021a, 093b:a003
5548 KWorld DVB-T 310U em2880 55 * - 10
5649 MSI DigiVox A/D em2880 eb1a:e310 56 - Hauppauge WinTV HVR 900
5750 MSI DigiVox A/D II em2880 eb1a:e320 57 - em2880
5851 Terratec Hybrid XS Secam em2880 0ccd:004c 58 - 2040:6500
5952 DNT DA2 Hybrid em2881 59 * - 11
6053 Pinnacle Hybrid Pro em2881 60 - Terratec Hybrid XS
6154 Kworld VS-DVB-T 323UR em2882 eb1a:e323 61 - em2880
6255 Terratec Cinnergy Hybrid T USB XS (em2882) em2882 0ccd:005e, 0ccd:0042 62 -
6356 Pinnacle Hybrid Pro (330e) em2882 2304:0226 63 * - 12
6457 Kworld PlusTV HD Hybrid 330 em2883 eb1a:a316 64 - Kworld PVR TV 2800 RF
6558 Compro VideoMate ForYou/Stereo em2820 or em2840 185b:2041 65 - em2820 or em2840
6659 Pinnacle PCTV HD Mini em2874 2304:023f 66 -
6760 Hauppauge WinTV HVR 850 em2883 2040:651f 67 * - 13
6861 Pixelview PlayTV Box 4 USB 2.0 em2820 or em2840 68 - Terratec Prodigy XS
6962 Gadmei TVR200 em2820 or em2840 69 - em2880
7063 Kaiomy TVnPC U2 em2860 eb1a:e303 70 -
7164 Easy Cap Capture DC-60 em2860 1b80:e309 71 * - 14
7265 IO-DATA GV-MVP/SZ em2820 or em2840 04bb:0515 72 - SIIG AVTuner-PVR / Pixelview Prolink PlayTV USB 2.0
7366 Empire dual TV em2880 73 - em2820 or em2840
7467 Terratec Grabby em2860 0ccd:0096, 0ccd:10AF 74 -
7568 Terratec AV350 em2860 0ccd:0084 75 * - 15
7669 KWorld ATSC 315U HDTV TV Box em2882 eb1a:a313 76 - V-Gear PocketTV
7770 Evga inDtube em2882 77 - em2800
7871 Silvercrest Webcam 1.3mpix em2820 or em2840 78 -
7972 Gadmei UTV330+ em2861 79 * - 16
8073 Reddo DVB-C USB TV Box em2870 80 - Hauppauge WinTV HVR 950
8174 Actionmaster/LinXcel/Digitus VC211A em2800 81 - em2883
8275 Dikom DK300 em2882 82 - 2040:6513, 2040:6517, 2040:651b
8376 KWorld PlusTV 340U or UB435-Q (ATSC) em2870 1b80:a340 83 * - 17
8477 EM2874 Leadership ISDBT em2874 84 - Pinnacle PCTV HD Pro Stick
8578 PCTV nanoStick T2 290e em28174 2013:024f 85 - em2880
8679 Terratec Cinergy H5 em2884 eb1a:2885, 0ccd:10a2, 0ccd:10ad, 0ccd:10b6 86 - 2304:0227
8780 PCTV DVB-S2 Stick (460e) em28174 2013:024c 87 * - 18
8881 Hauppauge WinTV HVR 930C em2884 2040:1605 88 - Hauppauge WinTV HVR 900 (R2)
8982 Terratec Cinergy HTC Stick em2884 0ccd:00b2 89 - em2880
9083 Honestech Vidbox NW03 em2860 eb1a:5006 90 - 2040:6502
9184 MaxMedia UB425-TC em2874 1b80:e425 91 * - 19
9285 PCTV QuatroStick (510e) em2884 2304:0242 92 - EM2860/SAA711X Reference Design
9386 PCTV QuatroStick nano (520e) em2884 2013:0251 93 - em2860
9487 Terratec Cinergy HTC USB XS em2884 0ccd:008e, 0ccd:00ac 94 -
9588 C3 Tech Digital Duo HDTV/SDTV USB em2884 1b80:e755 95 * - 20
9689 Delock 61959 em2874 1b80:e1cc 96 - AMD ATI TV Wonder HD 600
9790 KWorld USB ATSC TV Stick UB435-Q V2 em2874 1b80:e346 97 - em2880
9891 SpeedLink Vicious And Devine Laplace webcam em2765 1ae7:9003, 1ae7:9004 98 - 0438:b002
9992 PCTV DVB-S2 Stick (461e) em28178 2013:0258 99 * - 21
10093 KWorld USB ATSC TV Stick UB435-Q V3 em2874 1b80:e34c 100 - eMPIA Technology, Inc. GrabBeeX+ Video Encoder
10194 PCTV tripleStick (292e) em28178 2013:025f, 2040:0264 101 - em2800
10295 Leadtek VC100 em2861 0413:6f07 102 - eb1a:2801
10396 Terratec Cinergy T2 Stick HD em28178 eb1a:8179 103 * - 22
10497 Elgato EyeTV Hybrid 2008 INT em2884 0fd9:0018 104 - EM2710/EM2750/EM2751 webcam grabber
10598 PLEX PX-BCUD em28178 3275:0085 105 - em2750
10699 Hauppauge WinTV-dualHD DVB em28174 2040:0265 106 - eb1a:2750, eb1a:2751
107=========== ==================================================================== ================ ================================================================================================================================== 107 * - 23
108 - Huaqi DLCW-130
109 - em2750
110 -
111 * - 24
112 - D-Link DUB-T210 TV Tuner
113 - em2820 or em2840
114 - 2001:f112
115 * - 25
116 - Gadmei UTV310
117 - em2820 or em2840
118 -
119 * - 26
120 - Hercules Smart TV USB 2.0
121 - em2820 or em2840
122 -
123 * - 27
124 - Pinnacle PCTV USB 2 (Philips FM1216ME)
125 - em2820 or em2840
126 -
127 * - 28
128 - Leadtek Winfast USB II Deluxe
129 - em2820 or em2840
130 -
131 * - 29
132 - EM2860/TVP5150 Reference Design
133 - em2860
134 - eb1a:5051
135 * - 30
136 - Videology 20K14XUSB USB2.0
137 - em2820 or em2840
138 -
139 * - 31
140 - Usbgear VD204v9
141 - em2821
142 -
143 * - 32
144 - Supercomp USB 2.0 TV
145 - em2821
146 -
147 * - 33
148 - Elgato Video Capture
149 - em2860
150 - 0fd9:0033
151 * - 34
152 - Terratec Cinergy A Hybrid XS
153 - em2860
154 - 0ccd:004f
155 * - 35
156 - Typhoon DVD Maker
157 - em2860
158 -
159 * - 36
160 - NetGMBH Cam
161 - em2860
162 -
163 * - 37
164 - Gadmei UTV330
165 - em2860
166 - eb1a:50a6
167 * - 38
168 - Yakumo MovieMixer
169 - em2861
170 -
171 * - 39
172 - KWorld PVRTV 300U
173 - em2861
174 - eb1a:e300
175 * - 40
176 - Plextor ConvertX PX-TV100U
177 - em2861
178 - 093b:a005
179 * - 41
180 - Kworld 350 U DVB-T
181 - em2870
182 - eb1a:e350
183 * - 42
184 - Kworld 355 U DVB-T
185 - em2870
186 - eb1a:e355, eb1a:e357, eb1a:e359
187 * - 43
188 - Terratec Cinergy T XS
189 - em2870
190 -
191 * - 44
192 - Terratec Cinergy T XS (MT2060)
193 - em2870
194 - 0ccd:0043
195 * - 45
196 - Pinnacle PCTV DVB-T
197 - em2870
198 -
199 * - 46
200 - Compro, VideoMate U3
201 - em2870
202 - 185b:2870
203 * - 47
204 - KWorld DVB-T 305U
205 - em2880
206 - eb1a:e305
207 * - 48
208 - KWorld DVB-T 310U
209 - em2880
210 -
211 * - 49
212 - MSI DigiVox A/D
213 - em2880
214 - eb1a:e310
215 * - 50
216 - MSI DigiVox A/D II
217 - em2880
218 - eb1a:e320
219 * - 51
220 - Terratec Hybrid XS Secam
221 - em2880
222 - 0ccd:004c
223 * - 52
224 - DNT DA2 Hybrid
225 - em2881
226 -
227 * - 53
228 - Pinnacle Hybrid Pro
229 - em2881
230 -
231 * - 54
232 - Kworld VS-DVB-T 323UR
233 - em2882
234 - eb1a:e323
235 * - 55
236 - Terratec Cinnergy Hybrid T USB XS (em2882)
237 - em2882
238 - 0ccd:005e, 0ccd:0042
239 * - 56
240 - Pinnacle Hybrid Pro (330e)
241 - em2882
242 - 2304:0226
243 * - 57
244 - Kworld PlusTV HD Hybrid 330
245 - em2883
246 - eb1a:a316
247 * - 58
248 - Compro VideoMate ForYou/Stereo
249 - em2820 or em2840
250 - 185b:2041
251 * - 59
252 - Pinnacle PCTV HD Mini
253 - em2874
254 - 2304:023f
255 * - 60
256 - Hauppauge WinTV HVR 850
257 - em2883
258 - 2040:651f
259 * - 61
260 - Pixelview PlayTV Box 4 USB 2.0
261 - em2820 or em2840
262 -
263 * - 62
264 - Gadmei TVR200
265 - em2820 or em2840
266 -
267 * - 63
268 - Kaiomy TVnPC U2
269 - em2860
270 - eb1a:e303
271 * - 64
272 - Easy Cap Capture DC-60
273 - em2860
274 - 1b80:e309
275 * - 65
276 - IO-DATA GV-MVP/SZ
277 - em2820 or em2840
278 - 04bb:0515
279 * - 66
280 - Empire dual TV
281 - em2880
282 -
283 * - 67
284 - Terratec Grabby
285 - em2860
286 - 0ccd:0096, 0ccd:10AF
287 * - 68
288 - Terratec AV350
289 - em2860
290 - 0ccd:0084
291 * - 69
292 - KWorld ATSC 315U HDTV TV Box
293 - em2882
294 - eb1a:a313
295 * - 70
296 - Evga inDtube
297 - em2882
298 -
299 * - 71
300 - Silvercrest Webcam 1.3mpix
301 - em2820 or em2840
302 -
303 * - 72
304 - Gadmei UTV330+
305 - em2861
306 -
307 * - 73
308 - Reddo DVB-C USB TV Box
309 - em2870
310 -
311 * - 74
312 - Actionmaster/LinXcel/Digitus VC211A
313 - em2800
314 -
315 * - 75
316 - Dikom DK300
317 - em2882
318 -
319 * - 76
320 - KWorld PlusTV 340U or UB435-Q (ATSC)
321 - em2870
322 - 1b80:a340
323 * - 77
324 - EM2874 Leadership ISDBT
325 - em2874
326 -
327 * - 78
328 - PCTV nanoStick T2 290e
329 - em28174
330 - 2013:024f
331 * - 79
332 - Terratec Cinergy H5
333 - em2884
334 - eb1a:2885, 0ccd:10a2, 0ccd:10ad, 0ccd:10b6
335 * - 80
336 - PCTV DVB-S2 Stick (460e)
337 - em28174
338 - 2013:024c
339 * - 81
340 - Hauppauge WinTV HVR 930C
341 - em2884
342 - 2040:1605
343 * - 82
344 - Terratec Cinergy HTC Stick
345 - em2884
346 - 0ccd:00b2
347 * - 83
348 - Honestech Vidbox NW03
349 - em2860
350 - eb1a:5006
351 * - 84
352 - MaxMedia UB425-TC
353 - em2874
354 - 1b80:e425
355 * - 85
356 - PCTV QuatroStick (510e)
357 - em2884
358 - 2304:0242
359 * - 86
360 - PCTV QuatroStick nano (520e)
361 - em2884
362 - 2013:0251
363 * - 87
364 - Terratec Cinergy HTC USB XS
365 - em2884
366 - 0ccd:008e, 0ccd:00ac
367 * - 88
368 - C3 Tech Digital Duo HDTV/SDTV USB
369 - em2884
370 - 1b80:e755
371 * - 89
372 - Delock 61959
373 - em2874
374 - 1b80:e1cc
375 * - 90
376 - KWorld USB ATSC TV Stick UB435-Q V2
377 - em2874
378 - 1b80:e346
379 * - 91
380 - SpeedLink Vicious And Devine Laplace webcam
381 - em2765
382 - 1ae7:9003, 1ae7:9004
383 * - 92
384 - PCTV DVB-S2 Stick (461e)
385 - em28178
386 - 2013:0258
387 * - 93
388 - KWorld USB ATSC TV Stick UB435-Q V3
389 - em2874
390 - 1b80:e34c
391 * - 94
392 - PCTV tripleStick (292e)
393 - em28178
394 - 2013:025f, 2040:0264
395 * - 95
396 - Leadtek VC100
397 - em2861
398 - 0413:6f07
399 * - 96
400 - Terratec Cinergy T2 Stick HD
401 - em28178
402 - eb1a:8179
403 * - 97
404 - Elgato EyeTV Hybrid 2008 INT
405 - em2884
406 - 0fd9:0018
407 * - 98
408 - PLEX PX-BCUD
409 - em28178
410 - 3275:0085
411 * - 99
412 - Hauppauge WinTV-dualHD DVB
413 - em28174
414 - 2040:0265
415 * - 100
416 - Hauppauge WinTV-dualHD 01595 ATSC/QAM
417 - em28174
418 - 2040:026d
419 * - 101
420 - Terratec Cinergy H6 rev. 2
421 - em2884
422 - 0ccd:10b2
diff --git a/Documentation/media/v4l-drivers/index.rst b/Documentation/media/v4l-drivers/index.rst
index 10f2ce42ece2..679238e786a7 100644
--- a/Documentation/media/v4l-drivers/index.rst
+++ b/Documentation/media/v4l-drivers/index.rst
@@ -21,7 +21,9 @@ more details.
21 21
22For more details see the file COPYING in the source distribution of Linux. 22For more details see the file COPYING in the source distribution of Linux.
23 23
24.. class:: toc-title 24.. only:: html
25
26 .. class:: toc-title
25 27
26 Table of Contents 28 Table of Contents
27 29
@@ -50,6 +52,7 @@ For more details see the file COPYING in the source distribution of Linux.
50 philips 52 philips
51 pvrusb2 53 pvrusb2
52 pxa_camera 54 pxa_camera
55 qcom_camss
53 radiotrack 56 radiotrack
54 rcar-fdp1 57 rcar-fdp1
55 saa7134 58 saa7134
diff --git a/Documentation/media/v4l-drivers/ivtv-cardlist.rst b/Documentation/media/v4l-drivers/ivtv-cardlist.rst
index 754ffa820b4c..022dca80c2c8 100644
--- a/Documentation/media/v4l-drivers/ivtv-cardlist.rst
+++ b/Documentation/media/v4l-drivers/ivtv-cardlist.rst
@@ -1,38 +1,137 @@
1IVTV cards list 1IVTV cards list
2=============== 2===============
3 3
4=========== ============================================================= ==================================================== 4.. tabularcolumns:: |p{1.4cm}|p{12.7cm}|p{3.4cm}|
5Card number Card name PCI IDs 5
6=========== ============================================================= ==================================================== 6.. flat-table::
70 Hauppauge WinTV PVR-250 IVTV16 104d:813d 7 :header-rows: 1
81 Hauppauge WinTV PVR-350 IVTV16 104d:813d 8 :widths: 2 19 18
92 Hauppauge WinTV PVR-150 IVTV16 104d:813d 9 :stub-columns: 0
103 AVerMedia M179 IVTV15 1461:a3cf, IVTV15 1461:a3ce 10
114 Yuan MPG600, Kuroutoshikou ITVC16-STVLP IVTV16 12ab:fff3, IVTV16 12ab:ffff 11 * - Card number
125 YUAN MPG160, Kuroutoshikou ITVC15-STVLP, I/O Data GV-M2TV/PCI IVTV15 10fc:40a0 12 - Card name
136 Yuan PG600, Diamond PVR-550 IVTV16 ff92:0070, IVTV16 ffab:0600 13 - PCI IDs
147 Adaptec VideOh! AVC-2410 IVTV16 9005:0093 14
158 Adaptec VideOh! AVC-2010 IVTV16 9005:0092 15 * - 0
169 Nagase Transgear 5000TV IVTV16 1461:bfff 16 - Hauppauge WinTV PVR-250
1710 AOpen VA2000MAX-SNT6 IVTV16 0000:ff5f 17 - IVTV16 104d:813d
1811 Yuan MPG600GR, Kuroutoshikou CX23416GYC-STVLP IVTV16 12ab:0600, IVTV16 fbab:0600, IVTV16 1154:0523 18
1912 I/O Data GV-MVP/RX, GV-MVP/RX2W (dual tuner) IVTV16 10fc:d01e, IVTV16 10fc:d038, IVTV16 10fc:d039 19 * - 1
2013 I/O Data GV-MVP/RX2E IVTV16 10fc:d025 20 - Hauppauge WinTV PVR-350
2114 GotView PCI DVD IVTV16 12ab:0600 21 - IVTV16 104d:813d
2215 GotView PCI DVD2 Deluxe IVTV16 ffac:0600 22
2316 Yuan MPC622 IVTV16 ff01:d998 23 * - 2
2417 Digital Cowboy DCT-MTVP1 IVTV16 1461:bfff 24 - Hauppauge WinTV PVR-150
2518 Yuan PG600-2, GotView PCI DVD Lite IVTV16 ffab:0600, IVTV16 ffad:0600 25 - IVTV16 104d:813d
2619 Club3D ZAP-TV1x01 IVTV16 ffab:0600 26
2720 AVerTV MCE 116 Plus IVTV16 1461:c439 27 * - 3
2821 ASUS Falcon2 IVTV16 1043:4b66, IVTV16 1043:462e, IVTV16 1043:4b2e 28 - AVerMedia M179
2922 AVerMedia PVR-150 Plus / AVerTV M113 Partsnic (Daewoo) Tuner IVTV16 1461:c034, IVTV16 1461:c035 29 - IVTV15 1461:a3cf, IVTV15 1461:a3ce
3023 AVerMedia EZMaker PCI Deluxe IVTV16 1461:c03f 30
3124 AVerMedia M104 IVTV16 1461:c136 31 * - 4
3225 Buffalo PC-MV5L/PCI IVTV16 1154:052b 32 - Yuan MPG600, Kuroutoshikou ITVC16-STVLP
3326 AVerMedia UltraTV 1500 MCE / AVerTV M113 Philips Tuner IVTV16 1461:c019, IVTV16 1461:c01b 33 - IVTV16 12ab:fff3, IVTV16 12ab:ffff
3427 Sony VAIO Giga Pocket (ENX Kikyou) IVTV16 104d:813d 34
3528 Hauppauge WinTV PVR-350 (V1) IVTV16 104d:813d 35 * - 5
3629 Yuan MPG600GR, Kuroutoshikou CX23416GYC-STVLP (no GR) IVTV16 104d:813d 36 - YUAN MPG160, Kuroutoshikou ITVC15-STVLP, I/O Data GV-M2TV/PCI
3730 Yuan MPG600GR, Kuroutoshikou CX23416GYC-STVLP (no GR/YCS) IVTV16 104d:813d 37 - IVTV15 10fc:40a0
38=========== ============================================================= ==================================================== 38
39 * - 6
40 - Yuan PG600, Diamond PVR-550
41 - IVTV16 ff92:0070, IVTV16 ffab:0600
42
43 * - 7
44 - Adaptec VideOh! AVC-2410
45 - IVTV16 9005:0093
46
47 * - 8
48 - Adaptec VideOh! AVC-2010
49 - IVTV16 9005:0092
50
51 * - 9
52 - Nagase Transgear 5000TV
53 - IVTV16 1461:bfff
54
55 * - 10
56 - AOpen VA2000MAX-SNT6
57 - IVTV16 0000:ff5f
58
59 * - 11
60 - Yuan MPG600GR, Kuroutoshikou CX23416GYC-STVLP
61 - IVTV16 12ab:0600, IVTV16 fbab:0600, IVTV16 1154:0523
62
63 * - 12
64 - I/O Data GV-MVP/RX, GV-MVP/RX2W (dual tuner)
65 - IVTV16 10fc:d01e, IVTV16 10fc:d038, IVTV16 10fc:d039
66
67 * - 13
68 - I/O Data GV-MVP/RX2E
69 - IVTV16 10fc:d025
70
71 * - 14
72 - GotView PCI DVD
73 - IVTV16 12ab:0600
74
75 * - 15
76 - GotView PCI DVD2 Deluxe
77 - IVTV16 ffac:0600
78
79 * - 16
80 - Yuan MPC622
81 - IVTV16 ff01:d998
82
83 * - 17
84 - Digital Cowboy DCT-MTVP1
85 - IVTV16 1461:bfff
86
87 * - 18
88 - Yuan PG600-2, GotView PCI DVD Lite
89 - IVTV16 ffab:0600, IVTV16 ffad:0600
90
91 * - 19
92 - Club3D ZAP-TV1x01
93 - IVTV16 ffab:0600
94
95 * - 20
96 - AVerTV MCE 116 Plus
97 - IVTV16 1461:c439
98
99 * - 21
100 - ASUS Falcon2
101 - IVTV16 1043:4b66, IVTV16 1043:462e, IVTV16 1043:4b2e
102
103 * - 22
104 - AVerMedia PVR-150 Plus / AVerTV M113 Partsnic (Daewoo) Tuner
105 - IVTV16 1461:c034, IVTV16 1461:c035
106
107 * - 23
108 - AVerMedia EZMaker PCI Deluxe
109 - IVTV16 1461:c03f
110
111 * - 24
112 - AVerMedia M104
113 - IVTV16 1461:c136
114
115 * - 25
116 - Buffalo PC-MV5L/PCI
117 - IVTV16 1154:052b
118
119 * - 26
120 - AVerMedia UltraTV 1500 MCE / AVerTV M113 Philips Tuner
121 - IVTV16 1461:c019, IVTV16 1461:c01b
122
123 * - 27
124 - Sony VAIO Giga Pocket (ENX Kikyou)
125 - IVTV16 104d:813d
126
127 * - 28
128 - Hauppauge WinTV PVR-350 (V1)
129 - IVTV16 104d:813d
130
131 * - 29
132 - Yuan MPG600GR, Kuroutoshikou CX23416GYC-STVLP (no GR)
133 - IVTV16 104d:813d
134
135 * - 30
136 - Yuan MPG600GR, Kuroutoshikou CX23416GYC-STVLP (no GR/YCS)
137 - IVTV16 104d:813d
diff --git a/Documentation/media/v4l-drivers/qcom_camss.rst b/Documentation/media/v4l-drivers/qcom_camss.rst
new file mode 100644
index 000000000000..9e66b7b5770f
--- /dev/null
+++ b/Documentation/media/v4l-drivers/qcom_camss.rst
@@ -0,0 +1,156 @@
1.. include:: <isonum.txt>
2
3Qualcomm Camera Subsystem driver
4================================
5
6Introduction
7------------
8
9This file documents the Qualcomm Camera Subsystem driver located under
10drivers/media/platform/qcom/camss-8x16.
11
12The current version of the driver supports the Camera Subsystem found on
13Qualcomm MSM8916 and APQ8016 processors.
14
15The driver implements V4L2, Media controller and V4L2 subdev interfaces.
16Camera sensor using V4L2 subdev interface in the kernel is supported.
17
18The driver is implemented using as a reference the Qualcomm Camera Subsystem
19driver for Android as found in Code Aurora [#f1]_.
20
21
22Qualcomm Camera Subsystem hardware
23----------------------------------
24
25The Camera Subsystem hardware found on 8x16 processors and supported by the
26driver consists of:
27
28- 2 CSIPHY modules. They handle the Physical layer of the CSI2 receivers.
29 A separate camera sensor can be connected to each of the CSIPHY module;
30- 2 CSID (CSI Decoder) modules. They handle the Protocol and Application layer
31 of the CSI2 receivers. A CSID can decode data stream from any of the CSIPHY.
32 Each CSID also contains a TG (Test Generator) block which can generate
33 artificial input data for test purposes;
34- ISPIF (ISP Interface) module. Handles the routing of the data streams from
35 the CSIDs to the inputs of the VFE;
36- VFE (Video Front End) module. Contains a pipeline of image processing hardware
37 blocks. The VFE has different input interfaces. The PIX (Pixel) input
38 interface feeds the input data to the image processing pipeline. The image
39 processing pipeline contains also a scale and crop module at the end. Three
40 RDI (Raw Dump Interface) input interfaces bypass the image processing
41 pipeline. The VFE also contains the AXI bus interface which writes the output
42 data to memory.
43
44
45Supported functionality
46-----------------------
47
48The current version of the driver supports:
49
50- Input from camera sensor via CSIPHY;
51- Generation of test input data by the TG in CSID;
52- RDI interface of VFE - raw dump of the input data to memory.
53
54 Supported formats:
55
56 - YUYV/UYVY/YVYU/VYUY (packed YUV 4:2:2 - V4L2_PIX_FMT_YUYV /
57 V4L2_PIX_FMT_UYVY / V4L2_PIX_FMT_YVYU / V4L2_PIX_FMT_VYUY);
58 - MIPI RAW8 (8bit Bayer RAW - V4L2_PIX_FMT_SRGGB8 /
59 V4L2_PIX_FMT_SGRBG8 / V4L2_PIX_FMT_SGBRG8 / V4L2_PIX_FMT_SBGGR8);
60 - MIPI RAW10 (10bit packed Bayer RAW - V4L2_PIX_FMT_SBGGR10P /
61 V4L2_PIX_FMT_SGBRG10P / V4L2_PIX_FMT_SGRBG10P / V4L2_PIX_FMT_SRGGB10P);
62 - MIPI RAW12 (12bit packed Bayer RAW - V4L2_PIX_FMT_SRGGB12P /
63 V4L2_PIX_FMT_SGBRG12P / V4L2_PIX_FMT_SGRBG12P / V4L2_PIX_FMT_SRGGB12P).
64
65- PIX interface of VFE
66
67 - Format conversion of the input data.
68
69 Supported input formats:
70
71 - YUYV/UYVY/YVYU/VYUY (packed YUV 4:2:2 - V4L2_PIX_FMT_YUYV /
72 V4L2_PIX_FMT_UYVY / V4L2_PIX_FMT_YVYU / V4L2_PIX_FMT_VYUY).
73
74 Supported output formats:
75
76 - NV12/NV21 (two plane YUV 4:2:0 - V4L2_PIX_FMT_NV12 / V4L2_PIX_FMT_NV21);
77 - NV16/NV61 (two plane YUV 4:2:2 - V4L2_PIX_FMT_NV16 / V4L2_PIX_FMT_NV61).
78
79 - Scaling support. Configuration of the VFE Encoder Scale module
80 for downscalling with ratio up to 16x.
81
82 - Cropping support. Configuration of the VFE Encoder Crop module.
83
84- Concurrent and independent usage of two data inputs - could be camera sensors
85 and/or TG.
86
87
88Driver Architecture and Design
89------------------------------
90
91The driver implements the V4L2 subdev interface. With the goal to model the
92hardware links between the modules and to expose a clean, logical and usable
93interface, the driver is split into V4L2 sub-devices as follows:
94
95- 2 CSIPHY sub-devices - each CSIPHY is represented by a single sub-device;
96- 2 CSID sub-devices - each CSID is represented by a single sub-device;
97- 2 ISPIF sub-devices - ISPIF is represented by a number of sub-devices equal
98 to the number of CSID sub-devices;
99- 4 VFE sub-devices - VFE is represented by a number of sub-devices equal to
100 the number of the input interfaces (3 RDI and 1 PIX).
101
102The considerations to split the driver in this particular way are as follows:
103
104- representing CSIPHY and CSID modules by a separate sub-device for each module
105 allows to model the hardware links between these modules;
106- representing VFE by a separate sub-devices for each input interface allows
107 to use the input interfaces concurently and independently as this is
108 supported by the hardware;
109- representing ISPIF by a number of sub-devices equal to the number of CSID
110 sub-devices allows to create linear media controller pipelines when using two
111 cameras simultaneously. This avoids branches in the pipelines which otherwise
112 will require a) userspace and b) media framework (e.g. power on/off
113 operations) to make assumptions about the data flow from a sink pad to a
114 source pad on a single media entity.
115
116Each VFE sub-device is linked to a separate video device node.
117
118The media controller pipeline graph is as follows (with connected two OV5645
119camera sensors):
120
121.. _qcom_camss_graph:
122
123.. kernel-figure:: qcom_camss_graph.dot
124 :alt: qcom_camss_graph.dot
125 :align: center
126
127 Media pipeline graph
128
129
130Implementation
131--------------
132
133Runtime configuration of the hardware (updating settings while streaming) is
134not required to implement the currently supported functionality. The complete
135configuration on each hardware module is applied on STREAMON ioctl based on
136the current active media links, formats and controls set.
137
138The output size of the scaler module in the VFE is configured with the actual
139compose selection rectangle on the sink pad of the 'msm_vfe0_pix' entity.
140
141The crop output area of the crop module in the VFE is configured with the actual
142crop selection rectangle on the source pad of the 'msm_vfe0_pix' entity.
143
144
145Documentation
146-------------
147
148APQ8016 Specification:
149https://developer.qualcomm.com/download/sd410/snapdragon-410-processor-device-specification.pdf
150Referenced 2016-11-24.
151
152
153References
154----------
155
156.. [#f1] https://source.codeaurora.org/quic/la/kernel/msm-3.10/
diff --git a/Documentation/media/v4l-drivers/qcom_camss_graph.dot b/Documentation/media/v4l-drivers/qcom_camss_graph.dot
new file mode 100644
index 000000000000..827fc7112c1e
--- /dev/null
+++ b/Documentation/media/v4l-drivers/qcom_camss_graph.dot
@@ -0,0 +1,41 @@
1digraph board {
2 rankdir=TB
3 n00000001 [label="{{<port0> 0} | msm_csiphy0\n/dev/v4l-subdev0 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
4 n00000001:port1 -> n00000007:port0 [style=dashed]
5 n00000001:port1 -> n0000000a:port0 [style=dashed]
6 n00000004 [label="{{<port0> 0} | msm_csiphy1\n/dev/v4l-subdev1 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
7 n00000004:port1 -> n00000007:port0 [style=dashed]
8 n00000004:port1 -> n0000000a:port0 [style=dashed]
9 n00000007 [label="{{<port0> 0} | msm_csid0\n/dev/v4l-subdev2 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
10 n00000007:port1 -> n0000000d:port0 [style=dashed]
11 n00000007:port1 -> n00000010:port0 [style=dashed]
12 n0000000a [label="{{<port0> 0} | msm_csid1\n/dev/v4l-subdev3 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
13 n0000000a:port1 -> n0000000d:port0 [style=dashed]
14 n0000000a:port1 -> n00000010:port0 [style=dashed]
15 n0000000d [label="{{<port0> 0} | msm_ispif0\n/dev/v4l-subdev4 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
16 n0000000d:port1 -> n00000013:port0 [style=dashed]
17 n0000000d:port1 -> n0000001c:port0 [style=dashed]
18 n0000000d:port1 -> n00000025:port0 [style=dashed]
19 n0000000d:port1 -> n0000002e:port0 [style=dashed]
20 n00000010 [label="{{<port0> 0} | msm_ispif1\n/dev/v4l-subdev5 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
21 n00000010:port1 -> n00000013:port0 [style=dashed]
22 n00000010:port1 -> n0000001c:port0 [style=dashed]
23 n00000010:port1 -> n00000025:port0 [style=dashed]
24 n00000010:port1 -> n0000002e:port0 [style=dashed]
25 n00000013 [label="{{<port0> 0} | msm_vfe0_rdi0\n/dev/v4l-subdev6 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
26 n00000013:port1 -> n00000016 [style=bold]
27 n00000016 [label="msm_vfe0_video0\n/dev/video0", shape=box, style=filled, fillcolor=yellow]
28 n0000001c [label="{{<port0> 0} | msm_vfe0_rdi1\n/dev/v4l-subdev7 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
29 n0000001c:port1 -> n0000001f [style=bold]
30 n0000001f [label="msm_vfe0_video1\n/dev/video1", shape=box, style=filled, fillcolor=yellow]
31 n00000025 [label="{{<port0> 0} | msm_vfe0_rdi2\n/dev/v4l-subdev8 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
32 n00000025:port1 -> n00000028 [style=bold]
33 n00000028 [label="msm_vfe0_video2\n/dev/video2", shape=box, style=filled, fillcolor=yellow]
34 n0000002e [label="{{<port0> 0} | msm_vfe0_pix\n/dev/v4l-subdev9 | {<port1> 1}}", shape=Mrecord, style=filled, fillcolor=green]
35 n0000002e:port1 -> n00000031 [style=bold]
36 n00000031 [label="msm_vfe0_video3\n/dev/video3", shape=box, style=filled, fillcolor=yellow]
37 n00000057 [label="{{} | ov5645 1-0076\n/dev/v4l-subdev10 | {<port0> 0}}", shape=Mrecord, style=filled, fillcolor=green]
38 n00000057:port0 -> n00000001:port0 [style=bold]
39 n00000059 [label="{{} | ov5645 1-0074\n/dev/v4l-subdev11 | {<port0> 0}}", shape=Mrecord, style=filled, fillcolor=green]
40 n00000059:port0 -> n00000004:port0 [style=bold]
41}
diff --git a/Documentation/media/v4l-drivers/saa7134-cardlist.rst b/Documentation/media/v4l-drivers/saa7134-cardlist.rst
index a5efa8f4b8e4..6e4c35cbaabf 100644
--- a/Documentation/media/v4l-drivers/saa7134-cardlist.rst
+++ b/Documentation/media/v4l-drivers/saa7134-cardlist.rst
@@ -1,204 +1,801 @@
1SAA7134 cards list 1SAA7134 cards list
2================== 2==================
3 3
4=========== ======================================================= ================================================================ 4.. tabularcolumns:: |p{1.4cm}|p{11.1cm}|p{4.2cm}|
5Card number Card name PCI IDs 5
6=========== ======================================================= ================================================================ 6.. flat-table::
70 UNKNOWN/GENERIC 7 :header-rows: 1
81 Proteus Pro [philips reference design] 1131:2001, 1131:2001 8 :widths: 2 19 18
92 LifeView FlyVIDEO3000 5168:0138, 4e42:0138 9 :stub-columns: 0
103 LifeView/Typhoon FlyVIDEO2000 5168:0138, 4e42:0138 10
114 EMPRESS 1131:6752 11 * - Card number
125 SKNet Monster TV 1131:4e85 12 - Card name
136 Tevion MD 9717 13 - PCI IDs
147 KNC One TV-Station RDS / Typhoon TV Tuner RDS 1131:fe01, 1894:fe01 14
158 Terratec Cinergy 400 TV 153b:1142 15 * - 0
169 Medion 5044 16 - UNKNOWN/GENERIC
1710 Kworld/KuroutoShikou SAA7130-TVPCI 17 -
1811 Terratec Cinergy 600 TV 153b:1143 18
1912 Medion 7134 16be:0003, 16be:5000 19 * - 1
2013 Typhoon TV+Radio 90031 20 - Proteus Pro [philips reference design]
2114 ELSA EX-VISION 300TV 1048:226b 21 - 1131:2001, 1131:2001
2215 ELSA EX-VISION 500TV 1048:226a 22
2316 ASUS TV-FM 7134 1043:4842, 1043:4830, 1043:4840 23 * - 2
2417 AOPEN VA1000 POWER 1131:7133 24 - LifeView FlyVIDEO3000
2518 BMK MPEX No Tuner 25 - 5168:0138, 4e42:0138
2619 Compro VideoMate TV 185b:c100 26
2720 Matrox CronosPlus 102B:48d0 27 * - 3
2821 10MOONS PCI TV CAPTURE CARD 1131:2001 28 - LifeView/Typhoon FlyVIDEO2000
2922 AverMedia M156 / Medion 2819 1461:a70b 29 - 5168:0138, 4e42:0138
3023 BMK MPEX Tuner 30
3124 KNC One TV-Station DVR 1894:a006 31 * - 4
3225 ASUS TV-FM 7133 1043:4843 32 - EMPRESS
3326 Pinnacle PCTV Stereo (saa7134) 11bd:002b 33 - 1131:6752
3427 Manli MuchTV M-TV002 34
3528 Manli MuchTV M-TV001 35 * - 5
3629 Nagase Sangyo TransGear 3000TV 1461:050c 36 - SKNet Monster TV
3730 Elitegroup ECS TVP3XP FM1216 Tuner Card(PAL-BG,FM) 1019:4cb4 37 - 1131:4e85
3831 Elitegroup ECS TVP3XP FM1236 Tuner Card (NTSC,FM) 1019:4cb5 38
3932 AVACS SmartTV 39 * - 6
4033 AVerMedia DVD EZMaker 1461:10ff 40 - Tevion MD 9717
4134 Noval Prime TV 7133 41 -
4235 AverMedia AverTV Studio 305 1461:2115 42
4336 UPMOST PURPLE TV 12ab:0800 43 * - 7
4437 Items MuchTV Plus / IT-005 44 - KNC One TV-Station RDS / Typhoon TV Tuner RDS
4538 Terratec Cinergy 200 TV 153b:1152 45 - 1131:fe01, 1894:fe01
4639 LifeView FlyTV Platinum Mini 5168:0212, 4e42:0212, 5169:1502 46
4740 Compro VideoMate TV PVR/FM 185b:c100 47 * - 8
4841 Compro VideoMate TV Gold+ 185b:c100 48 - Terratec Cinergy 400 TV
4942 Sabrent SBT-TVFM (saa7130) 49 - 153b:1142
5043 :Zolid Xpert TV7134 50
5144 Empire PCI TV-Radio LE 51 * - 9
5245 Avermedia AVerTV Studio 307 1461:9715 52 - Medion 5044
5346 AVerMedia Cardbus TV/Radio (E500) 1461:d6ee 53 -
5447 Terratec Cinergy 400 mobile 153b:1162 54
5548 Terratec Cinergy 600 TV MK3 153b:1158 55 * - 10
5649 Compro VideoMate Gold+ Pal 185b:c200 56 - Kworld/KuroutoShikou SAA7130-TVPCI
5750 Pinnacle PCTV 300i DVB-T + PAL 11bd:002d 57 -
5851 ProVideo PV952 1540:9524 58
5952 AverMedia AverTV/305 1461:2108 59 * - 11
6053 ASUS TV-FM 7135 1043:4845 60 - Terratec Cinergy 600 TV
6154 LifeView FlyTV Platinum FM / Gold 5168:0214, 5168:5214, 1489:0214, 5168:0304 61 - 153b:1143
6255 LifeView FlyDVB-T DUO / MSI TV@nywhere Duo 5168:0306, 4E42:0306 62
6356 Avermedia AVerTV 307 1461:a70a 63 * - 12
6457 Avermedia AVerTV GO 007 FM 1461:f31f 64 - Medion 7134
6558 ADS Tech Instant TV (saa7135) 1421:0350, 1421:0351, 1421:0370, 1421:1370 65 - 16be:0003, 16be:5000
6659 Kworld/Tevion V-Stream Xpert TV PVR7134 66
6760 LifeView/Typhoon/Genius FlyDVB-T Duo Cardbus 5168:0502, 4e42:0502, 1489:0502 67 * - 13
6861 Philips TOUGH DVB-T reference design 1131:2004 68 - Typhoon TV+Radio 90031
6962 Compro VideoMate TV Gold+II 69 -
7063 Kworld Xpert TV PVR7134 70
7164 FlyTV mini Asus Digimatrix 1043:0210 71 * - 14
7265 V-Stream Studio TV Terminator 72 - ELSA EX-VISION 300TV
7366 Yuan TUN-900 (saa7135) 73 - 1048:226b
7467 Beholder BeholdTV 409 FM 0000:4091 74
7568 GoTView 7135 PCI 5456:7135 75 * - 15
7669 Philips EUROPA V3 reference design 1131:2004 76 - ELSA EX-VISION 500TV
7770 Compro Videomate DVB-T300 185b:c900 77 - 1048:226a
7871 Compro Videomate DVB-T200 185b:c901 78
7972 RTD Embedded Technologies VFG7350 1435:7350 79 * - 16
8073 RTD Embedded Technologies VFG7330 1435:7330 80 - ASUS TV-FM 7134
8174 LifeView FlyTV Platinum Mini2 14c0:1212 81 - 1043:4842, 1043:4830, 1043:4840
8275 AVerMedia AVerTVHD MCE A180 1461:1044 82
8376 SKNet MonsterTV Mobile 1131:4ee9 83 * - 17
8477 Pinnacle PCTV 40i/50i/110i (saa7133) 11bd:002e 84 - AOPEN VA1000 POWER
8578 ASUSTeK P7131 Dual 1043:4862 85 - 1131:7133
8679 Sedna/MuchTV PC TV Cardbus TV/Radio (ITO25 Rev:2B) 86
8780 ASUS Digimatrix TV 1043:0210 87 * - 18
8881 Philips Tiger reference design 1131:2018 88 - BMK MPEX No Tuner
8982 MSI TV@Anywhere plus 1462:6231, 1462:8624 89 -
9083 Terratec Cinergy 250 PCI TV 153b:1160 90
9184 LifeView FlyDVB Trio 5168:0319 91 * - 19
9285 AverTV DVB-T 777 1461:2c05, 1461:2c05 92 - Compro VideoMate TV
9386 LifeView FlyDVB-T / Genius VideoWonder DVB-T 5168:0301, 1489:0301 93 - 185b:c100
9487 ADS Instant TV Duo Cardbus PTV331 0331:1421 94
9588 Tevion/KWorld DVB-T 220RF 17de:7201 95 * - 20
9689 ELSA EX-VISION 700TV 1048:226c 96 - Matrox CronosPlus
9790 Kworld ATSC110/115 17de:7350, 17de:7352 97 - 102B:48d0
9891 AVerMedia A169 B 1461:7360 98
9992 AVerMedia A169 B1 1461:6360 99 * - 21
10093 Medion 7134 Bridge #2 16be:0005 100 - 10MOONS PCI TV CAPTURE CARD
10194 LifeView FlyDVB-T Hybrid Cardbus/MSI TV @nywhere A/D NB 5168:3306, 5168:3502, 5168:3307, 4e42:3502 101 - 1131:2001
10295 LifeView FlyVIDEO3000 (NTSC) 5169:0138 102
10396 Medion Md8800 Quadro 16be:0007, 16be:0008, 16be:000d 103 * - 22
10497 LifeView FlyDVB-S /Acorp TV134DS 5168:0300, 4e42:0300 104 - AverMedia M156 / Medion 2819
10598 Proteus Pro 2309 0919:2003 105 - 1461:a70b
10699 AVerMedia TV Hybrid A16AR 1461:2c00 106
107100 Asus Europa2 OEM 1043:4860 107 * - 23
108101 Pinnacle PCTV 310i 11bd:002f 108 - BMK MPEX Tuner
109102 Avermedia AVerTV Studio 507 1461:9715 109 -
110103 Compro Videomate DVB-T200A 110
111104 Hauppauge WinTV-HVR1110 DVB-T/Hybrid 0070:6700, 0070:6701, 0070:6702, 0070:6703, 0070:6704, 0070:6705 111 * - 24
112105 Terratec Cinergy HT PCMCIA 153b:1172 112 - KNC One TV-Station DVR
113106 Encore ENLTV 1131:2342, 1131:2341, 3016:2344 113 - 1894:a006
114107 Encore ENLTV-FM 1131:230f 114
115108 Terratec Cinergy HT PCI 153b:1175 115 * - 25
116109 Philips Tiger - S Reference design 116 - ASUS TV-FM 7133
117110 Avermedia M102 1461:f31e 117 - 1043:4843
118111 ASUS P7131 4871 1043:4871 118
119112 ASUSTeK P7131 Hybrid 1043:4876 119 * - 26
120113 Elitegroup ECS TVP3XP FM1246 Tuner Card (PAL,FM) 1019:4cb6 120 - Pinnacle PCTV Stereo (saa7134)
121114 KWorld DVB-T 210 17de:7250 121 - 11bd:002b
122115 Sabrent PCMCIA TV-PCB05 0919:2003 122
123116 10MOONS TM300 TV Card 1131:2304 123 * - 27
124117 Avermedia Super 007 1461:f01d 124 - Manli MuchTV M-TV002
125118 Beholder BeholdTV 401 0000:4016 125 -
126119 Beholder BeholdTV 403 0000:4036 126
127120 Beholder BeholdTV 403 FM 0000:4037 127 * - 28
128121 Beholder BeholdTV 405 0000:4050 128 - Manli MuchTV M-TV001
129122 Beholder BeholdTV 405 FM 0000:4051 129 -
130123 Beholder BeholdTV 407 0000:4070 130
131124 Beholder BeholdTV 407 FM 0000:4071 131 * - 29
132125 Beholder BeholdTV 409 0000:4090 132 - Nagase Sangyo TransGear 3000TV
133126 Beholder BeholdTV 505 FM 5ace:5050 133 - 1461:050c
134127 Beholder BeholdTV 507 FM / BeholdTV 509 FM 5ace:5070, 5ace:5090 134
135128 Beholder BeholdTV Columbus TV/FM 0000:5201 135 * - 30
136129 Beholder BeholdTV 607 FM 5ace:6070 136 - Elitegroup ECS TVP3XP FM1216 Tuner Card(PAL-BG,FM)
137130 Beholder BeholdTV M6 5ace:6190 137 - 1019:4cb4
138131 Twinhan Hybrid DTV-DVB 3056 PCI 1822:0022 138
139132 Genius TVGO AM11MCE 139 * - 31
140133 NXP Snake DVB-S reference design 140 - Elitegroup ECS TVP3XP FM1236 Tuner Card (NTSC,FM)
141134 Medion/Creatix CTX953 Hybrid 16be:0010 141 - 1019:4cb5
142135 MSI TV@nywhere A/D v1.1 1462:8625 142
143136 AVerMedia Cardbus TV/Radio (E506R) 1461:f436 143 * - 32
144137 AVerMedia Hybrid TV/Radio (A16D) 1461:f936 144 - AVACS SmartTV
145138 Avermedia M115 1461:a836 145 -
146139 Compro VideoMate T750 185b:c900 146
147140 Avermedia DVB-S Pro A700 1461:a7a1 147 * - 33
148141 Avermedia DVB-S Hybrid+FM A700 1461:a7a2 148 - AVerMedia DVD EZMaker
149142 Beholder BeholdTV H6 5ace:6290 149 - 1461:10ff
150143 Beholder BeholdTV M63 5ace:6191 150
151144 Beholder BeholdTV M6 Extra 5ace:6193 151 * - 34
152145 AVerMedia MiniPCI DVB-T Hybrid M103 1461:f636, 1461:f736 152 - Noval Prime TV 7133
153146 ASUSTeK P7131 Analog 153 -
154147 Asus Tiger 3in1 1043:4878 154
155148 Encore ENLTV-FM v5.3 1a7f:2008 155 * - 35
156149 Avermedia PCI pure analog (M135A) 1461:f11d 156 - AverMedia AverTV Studio 305
157150 Zogis Real Angel 220 157 - 1461:2115
158151 ADS Tech Instant HDTV 1421:0380 158
159152 Asus Tiger Rev:1.00 1043:4857 159 * - 36
160153 Kworld Plus TV Analog Lite PCI 17de:7128 160 - UPMOST PURPLE TV
161154 Avermedia AVerTV GO 007 FM Plus 1461:f31d 161 - 12ab:0800
162155 Hauppauge WinTV-HVR1150 ATSC/QAM-Hybrid 0070:6706, 0070:6708 162
163156 Hauppauge WinTV-HVR1120 DVB-T/Hybrid 0070:6707, 0070:6709, 0070:670a 163 * - 37
164157 Avermedia AVerTV Studio 507UA 1461:a11b 164 - Items MuchTV Plus / IT-005
165158 AVerMedia Cardbus TV/Radio (E501R) 1461:b7e9 165 -
166159 Beholder BeholdTV 505 RDS 0000:505B 166
167160 Beholder BeholdTV 507 RDS 0000:5071 167 * - 38
168161 Beholder BeholdTV 507 RDS 0000:507B 168 - Terratec Cinergy 200 TV
169162 Beholder BeholdTV 607 FM 5ace:6071 169 - 153b:1152
170163 Beholder BeholdTV 609 FM 5ace:6090 170
171164 Beholder BeholdTV 609 FM 5ace:6091 171 * - 39
172165 Beholder BeholdTV 607 RDS 5ace:6072 172 - LifeView FlyTV Platinum Mini
173166 Beholder BeholdTV 607 RDS 5ace:6073 173 - 5168:0212, 4e42:0212, 5169:1502
174167 Beholder BeholdTV 609 RDS 5ace:6092 174
175168 Beholder BeholdTV 609 RDS 5ace:6093 175 * - 40
176169 Compro VideoMate S350/S300 185b:c900 176 - Compro VideoMate TV PVR/FM
177170 AverMedia AverTV Studio 505 1461:a115 177 - 185b:c100
178171 Beholder BeholdTV X7 5ace:7595 178
179172 RoverMedia TV Link Pro FM 19d1:0138 179 * - 41
180173 Zolid Hybrid TV Tuner PCI 1131:2004 180 - Compro VideoMate TV Gold+
181174 Asus Europa Hybrid OEM 1043:4847 181 - 185b:c100
182175 Leadtek Winfast DTV1000S 107d:6655 182
183176 Beholder BeholdTV 505 RDS 0000:5051 183 * - 42
184177 Hawell HW-404M7 184 - Sabrent SBT-TVFM (saa7130)
185178 Beholder BeholdTV H7 5ace:7190 185 -
186179 Beholder BeholdTV A7 5ace:7090 186
187180 Avermedia PCI M733A 1461:4155, 1461:4255 187 * - 43
188181 TechoTrend TT-budget T-3000 13c2:2804 188 - :Zolid Xpert TV7134
189182 Kworld PCI SBTVD/ISDB-T Full-Seg Hybrid 17de:b136 189 -
190183 Compro VideoMate Vista M1F 185b:c900 190
191184 Encore ENLTV-FM 3 1a7f:2108 191 * - 44
192185 MagicPro ProHDTV Pro2 DMB-TH/Hybrid 17de:d136 192 - Empire PCI TV-Radio LE
193186 Beholder BeholdTV 501 5ace:5010 193 -
194187 Beholder BeholdTV 503 FM 5ace:5030 194
195188 Sensoray 811/911 6000:0811, 6000:0911 195 * - 45
196189 Kworld PC150-U 17de:a134 196 - Avermedia AVerTV Studio 307
197190 Asus My Cinema PS3-100 1043:48cd 197 - 1461:9715
198191 Hawell HW-9004V1 198
199192 AverMedia AverTV Satellite Hybrid+FM A706 1461:2055 199 * - 46
200193 WIS Voyager or compatible 1905:7007 200 - AVerMedia Cardbus TV/Radio (E500)
201194 AverMedia AverTV/505 1461:a10a 201 - 1461:d6ee
202195 Leadtek Winfast TV2100 FM 107d:6f3a 202
203196 SnaZio* TVPVR PRO 1779:13cf 203 * - 47
204=========== ======================================================= ================================================================ 204 - Terratec Cinergy 400 mobile
205 - 153b:1162
206
207 * - 48
208 - Terratec Cinergy 600 TV MK3
209 - 153b:1158
210
211 * - 49
212 - Compro VideoMate Gold+ Pal
213 - 185b:c200
214
215 * - 50
216 - Pinnacle PCTV 300i DVB-T + PAL
217 - 11bd:002d
218
219 * - 51
220 - ProVideo PV952
221 - 1540:9524
222
223 * - 52
224 - AverMedia AverTV/305
225 - 1461:2108
226
227 * - 53
228 - ASUS TV-FM 7135
229 - 1043:4845
230
231 * - 54
232 - LifeView FlyTV Platinum FM / Gold
233 - 5168:0214, 5168:5214, 1489:0214, 5168:0304
234
235 * - 55
236 - LifeView FlyDVB-T DUO / MSI TV@nywhere Duo
237 - 5168:0306, 4E42:0306
238
239 * - 56
240 - Avermedia AVerTV 307
241 - 1461:a70a
242
243 * - 57
244 - Avermedia AVerTV GO 007 FM
245 - 1461:f31f
246
247 * - 58
248 - ADS Tech Instant TV (saa7135)
249 - 1421:0350, 1421:0351, 1421:0370, 1421:1370
250
251 * - 59
252 - Kworld/Tevion V-Stream Xpert TV PVR7134
253 -
254
255 * - 60
256 - LifeView/Typhoon/Genius FlyDVB-T Duo Cardbus
257 - 5168:0502, 4e42:0502, 1489:0502
258
259 * - 61
260 - Philips TOUGH DVB-T reference design
261 - 1131:2004
262
263 * - 62
264 - Compro VideoMate TV Gold+II
265 -
266
267 * - 63
268 - Kworld Xpert TV PVR7134
269 -
270
271 * - 64
272 - FlyTV mini Asus Digimatrix
273 - 1043:0210
274
275 * - 65
276 - V-Stream Studio TV Terminator
277 -
278
279 * - 66
280 - Yuan TUN-900 (saa7135)
281 -
282
283 * - 67
284 - Beholder BeholdTV 409 FM
285 - 0000:4091
286
287 * - 68
288 - GoTView 7135 PCI
289 - 5456:7135
290
291 * - 69
292 - Philips EUROPA V3 reference design
293 - 1131:2004
294
295 * - 70
296 - Compro Videomate DVB-T300
297 - 185b:c900
298
299 * - 71
300 - Compro Videomate DVB-T200
301 - 185b:c901
302
303 * - 72
304 - RTD Embedded Technologies VFG7350
305 - 1435:7350
306
307 * - 73
308 - RTD Embedded Technologies VFG7330
309 - 1435:7330
310
311 * - 74
312 - LifeView FlyTV Platinum Mini2
313 - 14c0:1212
314
315 * - 75
316 - AVerMedia AVerTVHD MCE A180
317 - 1461:1044
318
319 * - 76
320 - SKNet MonsterTV Mobile
321 - 1131:4ee9
322
323 * - 77
324 - Pinnacle PCTV 40i/50i/110i (saa7133)
325 - 11bd:002e
326
327 * - 78
328 - ASUSTeK P7131 Dual
329 - 1043:4862
330
331 * - 79
332 - Sedna/MuchTV PC TV Cardbus TV/Radio (ITO25 Rev:2B)
333 -
334
335 * - 80
336 - ASUS Digimatrix TV
337 - 1043:0210
338
339 * - 81
340 - Philips Tiger reference design
341 - 1131:2018
342
343 * - 82
344 - MSI TV@Anywhere plus
345 - 1462:6231, 1462:8624
346
347 * - 83
348 - Terratec Cinergy 250 PCI TV
349 - 153b:1160
350
351 * - 84
352 - LifeView FlyDVB Trio
353 - 5168:0319
354
355 * - 85
356 - AverTV DVB-T 777
357 - 1461:2c05, 1461:2c05
358
359 * - 86
360 - LifeView FlyDVB-T / Genius VideoWonder DVB-T
361 - 5168:0301, 1489:0301
362
363 * - 87
364 - ADS Instant TV Duo Cardbus PTV331
365 - 0331:1421
366
367 * - 88
368 - Tevion/KWorld DVB-T 220RF
369 - 17de:7201
370
371 * - 89
372 - ELSA EX-VISION 700TV
373 - 1048:226c
374
375 * - 90
376 - Kworld ATSC110/115
377 - 17de:7350, 17de:7352
378
379 * - 91
380 - AVerMedia A169 B
381 - 1461:7360
382
383 * - 92
384 - AVerMedia A169 B1
385 - 1461:6360
386
387 * - 93
388 - Medion 7134 Bridge #2
389 - 16be:0005
390
391 * - 94
392 - LifeView FlyDVB-T Hybrid Cardbus/MSI TV @nywhere A/D NB
393 - 5168:3306, 5168:3502, 5168:3307, 4e42:3502
394
395 * - 95
396 - LifeView FlyVIDEO3000 (NTSC)
397 - 5169:0138
398
399 * - 96
400 - Medion Md8800 Quadro
401 - 16be:0007, 16be:0008, 16be:000d
402
403 * - 97
404 - LifeView FlyDVB-S /Acorp TV134DS
405 - 5168:0300, 4e42:0300
406
407 * - 98
408 - Proteus Pro 2309
409 - 0919:2003
410
411 * - 99
412 - AVerMedia TV Hybrid A16AR
413 - 1461:2c00
414
415 * - 100
416 - Asus Europa2 OEM
417 - 1043:4860
418
419 * - 101
420 - Pinnacle PCTV 310i
421 - 11bd:002f
422
423 * - 102
424 - Avermedia AVerTV Studio 507
425 - 1461:9715
426
427 * - 103
428 - Compro Videomate DVB-T200A
429 -
430
431 * - 104
432 - Hauppauge WinTV-HVR1110 DVB-T/Hybrid
433 - 0070:6700, 0070:6701, 0070:6702, 0070:6703, 0070:6704, 0070:6705
434
435 * - 105
436 - Terratec Cinergy HT PCMCIA
437 - 153b:1172
438
439 * - 106
440 - Encore ENLTV
441 - 1131:2342, 1131:2341, 3016:2344
442
443 * - 107
444 - Encore ENLTV-FM
445 - 1131:230f
446
447 * - 108
448 - Terratec Cinergy HT PCI
449 - 153b:1175
450
451 * - 109
452 - Philips Tiger - S Reference design
453 -
454
455 * - 110
456 - Avermedia M102
457 - 1461:f31e
458
459 * - 111
460 - ASUS P7131 4871
461 - 1043:4871
462
463 * - 112
464 - ASUSTeK P7131 Hybrid
465 - 1043:4876
466
467 * - 113
468 - Elitegroup ECS TVP3XP FM1246 Tuner Card (PAL,FM)
469 - 1019:4cb6
470
471 * - 114
472 - KWorld DVB-T 210
473 - 17de:7250
474
475 * - 115
476 - Sabrent PCMCIA TV-PCB05
477 - 0919:2003
478
479 * - 116
480 - 10MOONS TM300 TV Card
481 - 1131:2304
482
483 * - 117
484 - Avermedia Super 007
485 - 1461:f01d
486
487 * - 118
488 - Beholder BeholdTV 401
489 - 0000:4016
490
491 * - 119
492 - Beholder BeholdTV 403
493 - 0000:4036
494
495 * - 120
496 - Beholder BeholdTV 403 FM
497 - 0000:4037
498
499 * - 121
500 - Beholder BeholdTV 405
501 - 0000:4050
502
503 * - 122
504 - Beholder BeholdTV 405 FM
505 - 0000:4051
506
507 * - 123
508 - Beholder BeholdTV 407
509 - 0000:4070
510
511 * - 124
512 - Beholder BeholdTV 407 FM
513 - 0000:4071
514
515 * - 125
516 - Beholder BeholdTV 409
517 - 0000:4090
518
519 * - 126
520 - Beholder BeholdTV 505 FM
521 - 5ace:5050
522
523 * - 127
524 - Beholder BeholdTV 507 FM / BeholdTV 509 FM
525 - 5ace:5070, 5ace:5090
526
527 * - 128
528 - Beholder BeholdTV Columbus TV/FM
529 - 0000:5201
530
531 * - 129
532 - Beholder BeholdTV 607 FM
533 - 5ace:6070
534
535 * - 130
536 - Beholder BeholdTV M6
537 - 5ace:6190
538
539 * - 131
540 - Twinhan Hybrid DTV-DVB 3056 PCI
541 - 1822:0022
542
543 * - 132
544 - Genius TVGO AM11MCE
545 -
546
547 * - 133
548 - NXP Snake DVB-S reference design
549 -
550
551 * - 134
552 - Medion/Creatix CTX953 Hybrid
553 - 16be:0010
554
555 * - 135
556 - MSI TV@nywhere A/D v1.1
557 - 1462:8625
558
559 * - 136
560 - AVerMedia Cardbus TV/Radio (E506R)
561 - 1461:f436
562
563 * - 137
564 - AVerMedia Hybrid TV/Radio (A16D)
565 - 1461:f936
566
567 * - 138
568 - Avermedia M115
569 - 1461:a836
570
571 * - 139
572 - Compro VideoMate T750
573 - 185b:c900
574
575 * - 140
576 - Avermedia DVB-S Pro A700
577 - 1461:a7a1
578
579 * - 141
580 - Avermedia DVB-S Hybrid+FM A700
581 - 1461:a7a2
582
583 * - 142
584 - Beholder BeholdTV H6
585 - 5ace:6290
586
587 * - 143
588 - Beholder BeholdTV M63
589 - 5ace:6191
590
591 * - 144
592 - Beholder BeholdTV M6 Extra
593 - 5ace:6193
594
595 * - 145
596 - AVerMedia MiniPCI DVB-T Hybrid M103
597 - 1461:f636, 1461:f736
598
599 * - 146
600 - ASUSTeK P7131 Analog
601 -
602
603 * - 147
604 - Asus Tiger 3in1
605 - 1043:4878
606
607 * - 148
608 - Encore ENLTV-FM v5.3
609 - 1a7f:2008
610
611 * - 149
612 - Avermedia PCI pure analog (M135A)
613 - 1461:f11d
614
615 * - 150
616 - Zogis Real Angel 220
617 -
618
619 * - 151
620 - ADS Tech Instant HDTV
621 - 1421:0380
622
623 * - 152
624 - Asus Tiger Rev:1.00
625 - 1043:4857
626
627 * - 153
628 - Kworld Plus TV Analog Lite PCI
629 - 17de:7128
630
631 * - 154
632 - Avermedia AVerTV GO 007 FM Plus
633 - 1461:f31d
634
635 * - 155
636 - Hauppauge WinTV-HVR1150 ATSC/QAM-Hybrid
637 - 0070:6706, 0070:6708
638
639 * - 156
640 - Hauppauge WinTV-HVR1120 DVB-T/Hybrid
641 - 0070:6707, 0070:6709, 0070:670a
642
643 * - 157
644 - Avermedia AVerTV Studio 507UA
645 - 1461:a11b
646
647 * - 158
648 - AVerMedia Cardbus TV/Radio (E501R)
649 - 1461:b7e9
650
651 * - 159
652 - Beholder BeholdTV 505 RDS
653 - 0000:505B
654
655 * - 160
656 - Beholder BeholdTV 507 RDS
657 - 0000:5071
658
659 * - 161
660 - Beholder BeholdTV 507 RDS
661 - 0000:507B
662
663 * - 162
664 - Beholder BeholdTV 607 FM
665 - 5ace:6071
666
667 * - 163
668 - Beholder BeholdTV 609 FM
669 - 5ace:6090
670
671 * - 164
672 - Beholder BeholdTV 609 FM
673 - 5ace:6091
674
675 * - 165
676 - Beholder BeholdTV 607 RDS
677 - 5ace:6072
678
679 * - 166
680 - Beholder BeholdTV 607 RDS
681 - 5ace:6073
682
683 * - 167
684 - Beholder BeholdTV 609 RDS
685 - 5ace:6092
686
687 * - 168
688 - Beholder BeholdTV 609 RDS
689 - 5ace:6093
690
691 * - 169
692 - Compro VideoMate S350/S300
693 - 185b:c900
694
695 * - 170
696 - AverMedia AverTV Studio 505
697 - 1461:a115
698
699 * - 171
700 - Beholder BeholdTV X7
701 - 5ace:7595
702
703 * - 172
704 - RoverMedia TV Link Pro FM
705 - 19d1:0138
706
707 * - 173
708 - Zolid Hybrid TV Tuner PCI
709 - 1131:2004
710
711 * - 174
712 - Asus Europa Hybrid OEM
713 - 1043:4847
714
715 * - 175
716 - Leadtek Winfast DTV1000S
717 - 107d:6655
718
719 * - 176
720 - Beholder BeholdTV 505 RDS
721 - 0000:5051
722
723 * - 177
724 - Hawell HW-404M7
725 -
726
727 * - 178
728 - Beholder BeholdTV H7
729 - 5ace:7190
730
731 * - 179
732 - Beholder BeholdTV A7
733 - 5ace:7090
734
735 * - 180
736 - Avermedia PCI M733A
737 - 1461:4155, 1461:4255
738
739 * - 181
740 - TechoTrend TT-budget T-3000
741 - 13c2:2804
742
743 * - 182
744 - Kworld PCI SBTVD/ISDB-T Full-Seg Hybrid
745 - 17de:b136
746
747 * - 183
748 - Compro VideoMate Vista M1F
749 - 185b:c900
750
751 * - 184
752 - Encore ENLTV-FM 3
753 - 1a7f:2108
754
755 * - 185
756 - MagicPro ProHDTV Pro2 DMB-TH/Hybrid
757 - 17de:d136
758
759 * - 186
760 - Beholder BeholdTV 501
761 - 5ace:5010
762
763 * - 187
764 - Beholder BeholdTV 503 FM
765 - 5ace:5030
766
767 * - 188
768 - Sensoray 811/911
769 - 6000:0811, 6000:0911
770
771 * - 189
772 - Kworld PC150-U
773 - 17de:a134
774
775 * - 190
776 - Asus My Cinema PS3-100
777 - 1043:48cd
778
779 * - 191
780 - Hawell HW-9004V1
781 -
782
783 * - 192
784 - AverMedia AverTV Satellite Hybrid+FM A706
785 - 1461:2055
786
787 * - 193
788 - WIS Voyager or compatible
789 - 1905:7007
790
791 * - 194
792 - AverMedia AverTV/505
793 - 1461:a10a
794
795 * - 195
796 - Leadtek Winfast TV2100 FM
797 - 107d:6f3a
798
799 * - 196
800 - SnaZio* TVPVR PRO
801 - 1779:13cf
diff --git a/Documentation/media/v4l-drivers/saa7164-cardlist.rst b/Documentation/media/v4l-drivers/saa7164-cardlist.rst
index 7d17d38df3bc..e28382ba82e6 100644
--- a/Documentation/media/v4l-drivers/saa7164-cardlist.rst
+++ b/Documentation/media/v4l-drivers/saa7164-cardlist.rst
@@ -1,21 +1,69 @@
1SAA7164 cards list 1SAA7164 cards list
2================== 2==================
3 3
4=========== ==================================== ==================== 4.. tabularcolumns:: |p{1.4cm}|p{11.1cm}|p{4.2cm}|
5Card number Card name PCI IDs 5
6=========== ==================================== ==================== 6.. flat-table::
70 Unknown 7 :header-rows: 1
81 Generic Rev2 8 :widths: 2 19 18
92 Generic Rev3 9 :stub-columns: 0
103 Hauppauge WinTV-HVR2250 0070:8880, 0070:8810 10
114 Hauppauge WinTV-HVR2200 0070:8980 11 * - Card number
125 Hauppauge WinTV-HVR2200 0070:8900 12 - Card name
136 Hauppauge WinTV-HVR2200 0070:8901 13 - PCI IDs
147 Hauppauge WinTV-HVR2250 0070:8891, 0070:8851 14
158 Hauppauge WinTV-HVR2250 0070:88A1 15 * - 0
169 Hauppauge WinTV-HVR2200 0070:8940 16 - Unknown
1710 Hauppauge WinTV-HVR2200 0070:8953 17 -
1811 Hauppauge WinTV-HVR2255(proto) 0070:f111 18
1912 Hauppauge WinTV-HVR2255 0070:f111 19 * - 1
2013 Hauppauge WinTV-HVR2205 0070:f123, 0070:f120 20 - Generic Rev2
21=========== ==================================== ==================== 21 -
22
23 * - 2
24 - Generic Rev3
25 -
26
27 * - 3
28 - Hauppauge WinTV-HVR2250
29 - 0070:8880, 0070:8810
30
31 * - 4
32 - Hauppauge WinTV-HVR2200
33 - 0070:8980
34
35 * - 5
36 - Hauppauge WinTV-HVR2200
37 - 0070:8900
38
39 * - 6
40 - Hauppauge WinTV-HVR2200
41 - 0070:8901
42
43 * - 7
44 - Hauppauge WinTV-HVR2250
45 - 0070:8891, 0070:8851
46
47 * - 8
48 - Hauppauge WinTV-HVR2250
49 - 0070:88A1
50
51 * - 9
52 - Hauppauge WinTV-HVR2200
53 - 0070:8940
54
55 * - 10
56 - Hauppauge WinTV-HVR2200
57 - 0070:8953
58
59 * - 11
60 - Hauppauge WinTV-HVR2255(proto)
61 - 0070:f111
62
63 * - 12
64 - Hauppauge WinTV-HVR2255
65 - 0070:f111
66
67 * - 13
68 - Hauppauge WinTV-HVR2205
69 - 0070:f123, 0070:f120
diff --git a/Documentation/media/v4l-drivers/tm6000-cardlist.rst b/Documentation/media/v4l-drivers/tm6000-cardlist.rst
index ae2952683ccf..6bd083544457 100644
--- a/Documentation/media/v4l-drivers/tm6000-cardlist.rst
+++ b/Documentation/media/v4l-drivers/tm6000-cardlist.rst
@@ -1,24 +1,81 @@
1TM6000 cards list 1TM6000 cards list
2================= 2=================
3 3
4=========== ================================================= ========================================== 4.. tabularcolumns:: |p{1.4cm}|p{11.1cm}|p{4.2cm}|
5Card number Card name USB IDs 5
6=========== ================================================= ========================================== 6.. flat-table::
70 Unknown tm6000 video grabber 7 :header-rows: 1
81 Generic tm5600 board 6000:0001 8 :widths: 2 19 18
92 Generic tm6000 board 9 :stub-columns: 0
103 Generic tm6010 board 6000:0002 10
114 10Moons UT 821 11 * - Card number
125 10Moons UT 330 12 - Card name
136 ADSTECH Dual TV USB 06e1:f332 13 - USB IDs
147 Freecom Hybrid Stick / Moka DVB-T Receiver Dual 14aa:0620 14
158 ADSTECH Mini Dual TV USB 06e1:b339 15 * - 0
169 Hauppauge WinTV HVR-900H / WinTV USB2-Stick 2040:6600, 2040:6601, 2040:6610, 2040:6611 16 - Unknown tm6000 video grabber
1710 Beholder Wander DVB-T/TV/FM USB2.0 6000:dec0 17 -
1811 Beholder Voyager TV/FM USB2.0 6000:dec1 18
1912 Terratec Cinergy Hybrid XE / Cinergy Hybrid-Stick 0ccd:0086, 0ccd:00A5 19 * - 1
2013 Twinhan TU501(704D1) 13d3:3240, 13d3:3241, 13d3:3243, 13d3:3264 20 - Generic tm5600 board
2114 Beholder Wander Lite DVB-T/TV/FM USB2.0 6000:dec2 21 - 6000:0001
2215 Beholder Voyager Lite TV/FM USB2.0 6000:dec3 22
2316 Terratec Grabster AV 150/250 MX 0ccd:0079 23 * - 2
24=========== ================================================= ========================================== 24 - Generic tm6000 board
25 -
26
27 * - 3
28 - Generic tm6010 board
29 - 6000:0002
30
31 * - 4
32 - 10Moons UT 821
33 -
34
35 * - 5
36 - 10Moons UT 330
37 -
38
39 * - 6
40 - ADSTECH Dual TV USB
41 - 06e1:f332
42
43 * - 7
44 - Freecom Hybrid Stick / Moka DVB-T Receiver Dual
45 - 14aa:0620
46
47 * - 8
48 - ADSTECH Mini Dual TV USB
49 - 06e1:b339
50
51 * - 9
52 - Hauppauge WinTV HVR-900H / WinTV USB2-Stick
53 - 2040:6600, 2040:6601, 2040:6610, 2040:6611
54
55 * - 10
56 - Beholder Wander DVB-T/TV/FM USB2.0
57 - 6000:dec0
58
59 * - 11
60 - Beholder Voyager TV/FM USB2.0
61 - 6000:dec1
62
63 * - 12
64 - Terratec Cinergy Hybrid XE / Cinergy Hybrid-Stick
65 - 0ccd:0086, 0ccd:00A5
66
67 * - 13
68 - Twinhan TU501(704D1)
69 - 13d3:3240, 13d3:3241, 13d3:3243, 13d3:3264
70
71 * - 14
72 - Beholder Wander Lite DVB-T/TV/FM USB2.0
73 - 6000:dec2
74
75 * - 15
76 - Beholder Voyager Lite TV/FM USB2.0
77 - 6000:dec3
78
79 * - 16
80 - Terratec Grabster AV 150/250 MX
81 - 0ccd:0079
diff --git a/Documentation/media/v4l-drivers/usbvision-cardlist.rst b/Documentation/media/v4l-drivers/usbvision-cardlist.rst
index 44d53dff0984..5a8ffbfc204e 100644
--- a/Documentation/media/v4l-drivers/usbvision-cardlist.rst
+++ b/Documentation/media/v4l-drivers/usbvision-cardlist.rst
@@ -1,74 +1,281 @@
1USBvision cards list 1USBvision cards list
2==================== 2====================
3 3
4=========== ======================================================== ========= 4.. tabularcolumns:: |p{1.4cm}|p{11.1cm}|p{4.2cm}|
5Card number Card name USB IDs 5
6=========== ======================================================== ========= 6.. flat-table::
70 Xanboo 0a6f:0400 7 :header-rows: 1
81 Belkin USB VideoBus II Adapter 050d:0106 8 :widths: 2 19 18
92 Belkin Components USB VideoBus 050d:0207 9 :stub-columns: 0
103 Belkin USB VideoBus II 050d:0208 10
114 echoFX InterView Lite 0571:0002 11 * - Card number
125 USBGear USBG-V1 resp. HAMA USB 0573:0003 12 - Card name
136 D-Link V100 0573:0400 13 - USB IDs
147 X10 USB Camera 0573:2000 14
158 Hauppauge WinTV USB Live (PAL B/G) 0573:2d00 15 * - 0
169 Hauppauge WinTV USB Live Pro (NTSC M/N) 0573:2d01 16 - Xanboo
1710 Zoran Co. PMD (Nogatech) AV-grabber Manhattan 0573:2101 17 - 0a6f:0400
1811 Nogatech USB-TV (NTSC) FM 0573:4100 18
1912 PNY USB-TV (NTSC) FM 0573:4110 19 * - 1
2013 PixelView PlayTv-USB PRO (PAL) FM 0573:4450 20 - Belkin USB VideoBus II Adapter
2114 ZTV ZT-721 2.4GHz USB A/V Receiver 0573:4550 21 - 050d:0106
2215 Hauppauge WinTV USB (NTSC M/N) 0573:4d00 22
2316 Hauppauge WinTV USB (PAL B/G) 0573:4d01 23 * - 2
2417 Hauppauge WinTV USB (PAL I) 0573:4d02 24 - Belkin Components USB VideoBus
2518 Hauppauge WinTV USB (PAL/SECAM L) 0573:4d03 25 - 050d:0207
2619 Hauppauge WinTV USB (PAL D/K) 0573:4d04 26
2720 Hauppauge WinTV USB (NTSC FM) 0573:4d10 27 * - 3
2821 Hauppauge WinTV USB (PAL B/G FM) 0573:4d11 28 - Belkin USB VideoBus II
2922 Hauppauge WinTV USB (PAL I FM) 0573:4d12 29 - 050d:0208
3023 Hauppauge WinTV USB (PAL D/K FM) 0573:4d14 30
3124 Hauppauge WinTV USB Pro (NTSC M/N) 0573:4d2a 31 * - 4
3225 Hauppauge WinTV USB Pro (NTSC M/N) V2 0573:4d2b 32 - echoFX InterView Lite
3326 Hauppauge WinTV USB Pro (PAL/SECAM B/G/I/D/K/L) 0573:4d2c 33 - 0571:0002
3427 Hauppauge WinTV USB Pro (NTSC M/N) V3 0573:4d20 34
3528 Hauppauge WinTV USB Pro (PAL B/G) 0573:4d21 35 * - 5
3629 Hauppauge WinTV USB Pro (PAL I) 0573:4d22 36 - USBGear USBG-V1 resp. HAMA USB
3730 Hauppauge WinTV USB Pro (PAL/SECAM L) 0573:4d23 37 - 0573:0003
3831 Hauppauge WinTV USB Pro (PAL D/K) 0573:4d24 38
3932 Hauppauge WinTV USB Pro (PAL/SECAM BGDK/I/L) 0573:4d25 39 * - 6
4033 Hauppauge WinTV USB Pro (PAL/SECAM BGDK/I/L) V2 0573:4d26 40 - D-Link V100
4134 Hauppauge WinTV USB Pro (PAL B/G) V2 0573:4d27 41 - 0573:0400
4235 Hauppauge WinTV USB Pro (PAL B/G,D/K) 0573:4d28 42
4336 Hauppauge WinTV USB Pro (PAL I,D/K) 0573:4d29 43 * - 7
4437 Hauppauge WinTV USB Pro (NTSC M/N FM) 0573:4d30 44 - X10 USB Camera
4538 Hauppauge WinTV USB Pro (PAL B/G FM) 0573:4d31 45 - 0573:2000
4639 Hauppauge WinTV USB Pro (PAL I FM) 0573:4d32 46
4740 Hauppauge WinTV USB Pro (PAL D/K FM) 0573:4d34 47 * - 8
4841 Hauppauge WinTV USB Pro (Temic PAL/SECAM B/G/I/D/K/L FM) 0573:4d35 48 - Hauppauge WinTV USB Live (PAL B/G)
4942 Hauppauge WinTV USB Pro (Temic PAL B/G FM) 0573:4d36 49 - 0573:2d00
5043 Hauppauge WinTV USB Pro (PAL/SECAM B/G/I/D/K/L FM) 0573:4d37 50
5144 Hauppauge WinTV USB Pro (NTSC M/N FM) V2 0573:4d38 51 * - 9
5245 Camtel Technology USB TV Genie Pro FM Model TVB330 0768:0006 52 - Hauppauge WinTV USB Live Pro (NTSC M/N)
5346 Digital Video Creator I 07d0:0001 53 - 0573:2d01
5447 Global Village GV-007 (NTSC) 07d0:0002 54
5548 Dazzle Fusion Model DVC-50 Rev 1 (NTSC) 07d0:0003 55 * - 10
5649 Dazzle Fusion Model DVC-80 Rev 1 (PAL) 07d0:0004 56 - Zoran Co. PMD (Nogatech) AV-grabber Manhattan
5750 Dazzle Fusion Model DVC-90 Rev 1 (SECAM) 07d0:0005 57 - 0573:2101
5851 Eskape Labs MyTV2Go 07f8:9104 58
5952 Pinnacle Studio PCTV USB (PAL) 2304:010d 59 * - 11
6053 Pinnacle Studio PCTV USB (SECAM) 2304:0109 60 - Nogatech USB-TV (NTSC) FM
6154 Pinnacle Studio PCTV USB (PAL) FM 2304:0110 61 - 0573:4100
6255 Miro PCTV USB 2304:0111 62
6356 Pinnacle Studio PCTV USB (NTSC) FM 2304:0112 63 * - 12
6457 Pinnacle Studio PCTV USB (PAL) FM V2 2304:0210 64 - PNY USB-TV (NTSC) FM
6558 Pinnacle Studio PCTV USB (NTSC) FM V2 2304:0212 65 - 0573:4110
6659 Pinnacle Studio PCTV USB (PAL) FM V3 2304:0214 66
6760 Pinnacle Studio Linx Video input cable (NTSC) 2304:0300 67 * - 13
6861 Pinnacle Studio Linx Video input cable (PAL) 2304:0301 68 - PixelView PlayTv-USB PRO (PAL) FM
6962 Pinnacle PCTV Bungee USB (PAL) FM 2304:0419 69 - 0573:4450
7063 Hauppauge WinTv-USB 2400:4200 70
7164 Pinnacle Studio PCTV USB (NTSC) FM V3 2304:0113 71 * - 14
7265 Nogatech USB MicroCam NTSC (NV3000N) 0573:3000 72 - ZTV ZT-721 2.4GHz USB A/V Receiver
7366 Nogatech USB MicroCam PAL (NV3001P) 0573:3001 73 - 0573:4550
74=========== ======================================================== ========= 74
75 * - 15
76 - Hauppauge WinTV USB (NTSC M/N)
77 - 0573:4d00
78
79 * - 16
80 - Hauppauge WinTV USB (PAL B/G)
81 - 0573:4d01
82
83 * - 17
84 - Hauppauge WinTV USB (PAL I)
85 - 0573:4d02
86
87 * - 18
88 - Hauppauge WinTV USB (PAL/SECAM L)
89 - 0573:4d03
90
91 * - 19
92 - Hauppauge WinTV USB (PAL D/K)
93 - 0573:4d04
94
95 * - 20
96 - Hauppauge WinTV USB (NTSC FM)
97 - 0573:4d10
98
99 * - 21
100 - Hauppauge WinTV USB (PAL B/G FM)
101 - 0573:4d11
102
103 * - 22
104 - Hauppauge WinTV USB (PAL I FM)
105 - 0573:4d12
106
107 * - 23
108 - Hauppauge WinTV USB (PAL D/K FM)
109 - 0573:4d14
110
111 * - 24
112 - Hauppauge WinTV USB Pro (NTSC M/N)
113 - 0573:4d2a
114
115 * - 25
116 - Hauppauge WinTV USB Pro (NTSC M/N) V2
117 - 0573:4d2b
118
119 * - 26
120 - Hauppauge WinTV USB Pro (PAL/SECAM B/G/I/D/K/L)
121 - 0573:4d2c
122
123 * - 27
124 - Hauppauge WinTV USB Pro (NTSC M/N) V3
125 - 0573:4d20
126
127 * - 28
128 - Hauppauge WinTV USB Pro (PAL B/G)
129 - 0573:4d21
130
131 * - 29
132 - Hauppauge WinTV USB Pro (PAL I)
133 - 0573:4d22
134
135 * - 30
136 - Hauppauge WinTV USB Pro (PAL/SECAM L)
137 - 0573:4d23
138
139 * - 31
140 - Hauppauge WinTV USB Pro (PAL D/K)
141 - 0573:4d24
142
143 * - 32
144 - Hauppauge WinTV USB Pro (PAL/SECAM BGDK/I/L)
145 - 0573:4d25
146
147 * - 33
148 - Hauppauge WinTV USB Pro (PAL/SECAM BGDK/I/L) V2
149 - 0573:4d26
150
151 * - 34
152 - Hauppauge WinTV USB Pro (PAL B/G) V2
153 - 0573:4d27
154
155 * - 35
156 - Hauppauge WinTV USB Pro (PAL B/G,D/K)
157 - 0573:4d28
158
159 * - 36
160 - Hauppauge WinTV USB Pro (PAL I,D/K)
161 - 0573:4d29
162
163 * - 37
164 - Hauppauge WinTV USB Pro (NTSC M/N FM)
165 - 0573:4d30
166
167 * - 38
168 - Hauppauge WinTV USB Pro (PAL B/G FM)
169 - 0573:4d31
170
171 * - 39
172 - Hauppauge WinTV USB Pro (PAL I FM)
173 - 0573:4d32
174
175 * - 40
176 - Hauppauge WinTV USB Pro (PAL D/K FM)
177 - 0573:4d34
178
179 * - 41
180 - Hauppauge WinTV USB Pro (Temic PAL/SECAM B/G/I/D/K/L FM)
181 - 0573:4d35
182
183 * - 42
184 - Hauppauge WinTV USB Pro (Temic PAL B/G FM)
185 - 0573:4d36
186
187 * - 43
188 - Hauppauge WinTV USB Pro (PAL/SECAM B/G/I/D/K/L FM)
189 - 0573:4d37
190
191 * - 44
192 - Hauppauge WinTV USB Pro (NTSC M/N FM) V2
193 - 0573:4d38
194
195 * - 45
196 - Camtel Technology USB TV Genie Pro FM Model TVB330
197 - 0768:0006
198
199 * - 46
200 - Digital Video Creator I
201 - 07d0:0001
202
203 * - 47
204 - Global Village GV-007 (NTSC)
205 - 07d0:0002
206
207 * - 48
208 - Dazzle Fusion Model DVC-50 Rev 1 (NTSC)
209 - 07d0:0003
210
211 * - 49
212 - Dazzle Fusion Model DVC-80 Rev 1 (PAL)
213 - 07d0:0004
214
215 * - 50
216 - Dazzle Fusion Model DVC-90 Rev 1 (SECAM)
217 - 07d0:0005
218
219 * - 51
220 - Eskape Labs MyTV2Go
221 - 07f8:9104
222
223 * - 52
224 - Pinnacle Studio PCTV USB (PAL)
225 - 2304:010d
226
227 * - 53
228 - Pinnacle Studio PCTV USB (SECAM)
229 - 2304:0109
230
231 * - 54
232 - Pinnacle Studio PCTV USB (PAL) FM
233 - 2304:0110
234
235 * - 55
236 - Miro PCTV USB
237 - 2304:0111
238
239 * - 56
240 - Pinnacle Studio PCTV USB (NTSC) FM
241 - 2304:0112
242
243 * - 57
244 - Pinnacle Studio PCTV USB (PAL) FM V2
245 - 2304:0210
246
247 * - 58
248 - Pinnacle Studio PCTV USB (NTSC) FM V2
249 - 2304:0212
250
251 * - 59
252 - Pinnacle Studio PCTV USB (PAL) FM V3
253 - 2304:0214
254
255 * - 60
256 - Pinnacle Studio Linx Video input cable (NTSC)
257 - 2304:0300
258
259 * - 61
260 - Pinnacle Studio Linx Video input cable (PAL)
261 - 2304:0301
262
263 * - 62
264 - Pinnacle PCTV Bungee USB (PAL) FM
265 - 2304:0419
266
267 * - 63
268 - Hauppauge WinTv-USB
269 - 2400:4200
270
271 * - 64
272 - Pinnacle Studio PCTV USB (NTSC) FM V3
273 - 2304:0113
274
275 * - 65
276 - Nogatech USB MicroCam NTSC (NV3000N)
277 - 0573:3000
278
279 * - 66
280 - Nogatech USB MicroCam PAL (NV3001P)
281 - 0573:3001
diff --git a/Documentation/media/v4l-drivers/vivid.rst b/Documentation/media/v4l-drivers/vivid.rst
index 3e44b2217f2d..089595ce11c5 100644
--- a/Documentation/media/v4l-drivers/vivid.rst
+++ b/Documentation/media/v4l-drivers/vivid.rst
@@ -829,6 +829,7 @@ The following two controls are only valid for video and vbi capture.
829The following two controls are only valid for video capture. 829The following two controls are only valid for video capture.
830 830
831- DV Timings Signal Mode: 831- DV Timings Signal Mode:
832
832 selects the behavior of VIDIOC_QUERY_DV_TIMINGS: what 833 selects the behavior of VIDIOC_QUERY_DV_TIMINGS: what
833 should it return? 834 should it return?
834 835
diff --git a/MAINTAINERS b/MAINTAINERS
index c620db0558f3..b07232679a66 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -778,6 +778,12 @@ W: http://ez.analog.com/community/linux-device-drivers
778S: Supported 778S: Supported
779F: drivers/media/i2c/adv7180.c 779F: drivers/media/i2c/adv7180.c
780 780
781ANALOG DEVICES INC ADV748X DRIVER
782M: Kieran Bingham <kieran.bingham@ideasonboard.com>
783L: linux-media@vger.kernel.org
784S: Maintained
785F: drivers/media/i2c/adv748x/*
786
781ANALOG DEVICES INC ADV7511 DRIVER 787ANALOG DEVICES INC ADV7511 DRIVER
782M: Hans Verkuil <hans.verkuil@cisco.com> 788M: Hans Verkuil <hans.verkuil@cisco.com>
783L: linux-media@vger.kernel.org 789L: linux-media@vger.kernel.org
@@ -2134,6 +2140,12 @@ F: arch/arm64/
2134F: Documentation/arm64/ 2140F: Documentation/arm64/
2135 2141
2136AS3645A LED FLASH CONTROLLER DRIVER 2142AS3645A LED FLASH CONTROLLER DRIVER
2143M: Sakari Ailus <sakari.ailus@iki.fi>
2144L: linux-leds@vger.kernel.org
2145S: Maintained
2146F: drivers/leds/leds-as3645a.c
2147
2148AS3645A LED FLASH CONTROLLER DRIVER
2137M: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 2149M: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2138L: linux-media@vger.kernel.org 2150L: linux-media@vger.kernel.org
2139T: git git://linuxtv.org/media_tree.git 2151T: git git://linuxtv.org/media_tree.git
@@ -5801,6 +5813,12 @@ S: Maintained
5801F: Documentation/acpi/gpio-properties.txt 5813F: Documentation/acpi/gpio-properties.txt
5802F: drivers/gpio/gpiolib-acpi.c 5814F: drivers/gpio/gpiolib-acpi.c
5803 5815
5816GPIO IR Transmitter
5817M: Sean Young <sean@mess.org>
5818L: linux-media@vger.kernel.org
5819S: Maintained
5820F: drivers/media/rc/gpio-ir-tx.c
5821
5804GPIO MOCKUP DRIVER 5822GPIO MOCKUP DRIVER
5805M: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org> 5823M: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
5806L: linux-gpio@vger.kernel.org 5824L: linux-gpio@vger.kernel.org
@@ -8397,6 +8415,14 @@ T: git git://linuxtv.org/media_tree.git
8397S: Supported 8415S: Supported
8398F: drivers/media/dvb-frontends/lnbh25* 8416F: drivers/media/dvb-frontends/lnbh25*
8399 8417
8418MEDIA DRIVERS FOR MXL5XX TUNER DEMODULATORS
8419M: Daniel Scheller <d.scheller.oss@gmail.com>
8420L: linux-media@vger.kernel.org
8421W: https://linuxtv.org
8422T: git git://linuxtv.org/media_tree.git
8423S: Maintained
8424F: drivers/media/dvb-frontends/mxl5xx*
8425
8400MEDIA DRIVERS FOR NETUP PCI UNIVERSAL DVB devices 8426MEDIA DRIVERS FOR NETUP PCI UNIVERSAL DVB devices
8401M: Sergey Kozlov <serjk@netup.ru> 8427M: Sergey Kozlov <serjk@netup.ru>
8402M: Abylay Ospan <aospan@netup.ru> 8428M: Abylay Ospan <aospan@netup.ru>
@@ -8453,6 +8479,30 @@ S: Supported
8453F: Documentation/devicetree/bindings/media/renesas,vsp1.txt 8479F: Documentation/devicetree/bindings/media/renesas,vsp1.txt
8454F: drivers/media/platform/vsp1/ 8480F: drivers/media/platform/vsp1/
8455 8481
8482MEDIA DRIVERS FOR ST STV0910 DEMODULATOR ICs
8483M: Daniel Scheller <d.scheller.oss@gmail.com>
8484L: linux-media@vger.kernel.org
8485W: https://linuxtv.org
8486T: git git://linuxtv.org/media_tree.git
8487S: Maintained
8488F: drivers/media/dvb-frontends/stv0910*
8489
8490MEDIA DRIVERS FOR ST STV6111 TUNER ICs
8491M: Daniel Scheller <d.scheller.oss@gmail.com>
8492L: linux-media@vger.kernel.org
8493W: https://linuxtv.org
8494T: git git://linuxtv.org/media_tree.git
8495S: Maintained
8496F: drivers/media/dvb-frontends/stv6111*
8497
8498MEDIA DRIVERS FOR DIGITAL DEVICES PCIE DEVICES
8499M: Daniel Scheller <d.scheller.oss@gmail.com>
8500L: linux-media@vger.kernel.org
8501W: https://linuxtv.org
8502T: git git://linuxtv.org/media_tree.git
8503S: Maintained
8504F: drivers/media/pci/ddbridge/*
8505
8456MEDIA INPUT INFRASTRUCTURE (V4L/DVB) 8506MEDIA INPUT INFRASTRUCTURE (V4L/DVB)
8457M: Mauro Carvalho Chehab <mchehab@s-opensource.com> 8507M: Mauro Carvalho Chehab <mchehab@s-opensource.com>
8458M: Mauro Carvalho Chehab <mchehab@kernel.org> 8508M: Mauro Carvalho Chehab <mchehab@kernel.org>
@@ -8516,6 +8566,11 @@ L: linux-wireless@vger.kernel.org
8516S: Maintained 8566S: Maintained
8517F: drivers/net/wireless/mediatek/mt7601u/ 8567F: drivers/net/wireless/mediatek/mt7601u/
8518 8568
8569MEDIATEK CIR DRIVER
8570M: Sean Wang <sean.wang@mediatek.com>
8571S: Maintained
8572F: drivers/media/rc/mtk-cir.c
8573
8519MEDIATEK RANDOM NUMBER GENERATOR SUPPORT 8574MEDIATEK RANDOM NUMBER GENERATOR SUPPORT
8520M: Sean Wang <sean.wang@mediatek.com> 8575M: Sean Wang <sean.wang@mediatek.com>
8521S: Maintained 8576S: Maintained
@@ -8747,6 +8802,16 @@ F: drivers/leds/leds-menf21bmc.c
8747F: drivers/hwmon/menf21bmc_hwmon.c 8802F: drivers/hwmon/menf21bmc_hwmon.c
8748F: Documentation/hwmon/menf21bmc 8803F: Documentation/hwmon/menf21bmc
8749 8804
8805MESON AO CEC DRIVER FOR AMLOGIC SOCS
8806M: Neil Armstrong <narmstrong@baylibre.com>
8807L: linux-media@lists.freedesktop.org
8808L: linux-amlogic@lists.infradead.org
8809W: http://linux-meson.com/
8810S: Supported
8811F: drivers/media/platform/meson/ao-cec.c
8812F: Documentation/devicetree/bindings/media/meson-ao-cec.txt
8813T: git git://linuxtv.org/media_tree.git
8814
8750METAG ARCHITECTURE 8815METAG ARCHITECTURE
8751M: James Hogan <james.hogan@imgtec.com> 8816M: James Hogan <james.hogan@imgtec.com>
8752L: linux-metag@vger.kernel.org 8817L: linux-metag@vger.kernel.org
@@ -9780,7 +9845,7 @@ S: Maintained
9780F: drivers/media/i2c/ov5640.c 9845F: drivers/media/i2c/ov5640.c
9781 9846
9782OMNIVISION OV5647 SENSOR DRIVER 9847OMNIVISION OV5647 SENSOR DRIVER
9783M: Ramiro Oliveira <roliveir@synopsys.com> 9848M: Luis Oliveira <lolivei@synopsys.com>
9784L: linux-media@vger.kernel.org 9849L: linux-media@vger.kernel.org
9785T: git git://linuxtv.org/media_tree.git 9850T: git git://linuxtv.org/media_tree.git
9786S: Maintained 9851S: Maintained
@@ -10778,6 +10843,7 @@ L: linux-media@vger.kernel.org
10778T: git git://linuxtv.org/media_tree.git 10843T: git git://linuxtv.org/media_tree.git
10779S: Maintained 10844S: Maintained
10780F: drivers/media/usb/pulse8-cec/* 10845F: drivers/media/usb/pulse8-cec/*
10846F: Documentation/media/cec-drivers/pulse8-cec.rst
10781 10847
10782PVRUSB2 VIDEO4LINUX DRIVER 10848PVRUSB2 VIDEO4LINUX DRIVER
10783M: Mike Isely <isely@pobox.com> 10849M: Mike Isely <isely@pobox.com>
@@ -10805,6 +10871,12 @@ F: Documentation/devicetree/bindings/hwmon/pwm-fan.txt
10805F: Documentation/hwmon/pwm-fan 10871F: Documentation/hwmon/pwm-fan
10806F: drivers/hwmon/pwm-fan.c 10872F: drivers/hwmon/pwm-fan.c
10807 10873
10874PWM IR Transmitter
10875M: Sean Young <sean@mess.org>
10876L: linux-media@vger.kernel.org
10877S: Maintained
10878F: drivers/media/rc/pwm-ir-tx.c
10879
10808PWM SUBSYSTEM 10880PWM SUBSYSTEM
10809M: Thierry Reding <thierry.reding@gmail.com> 10881M: Thierry Reding <thierry.reding@gmail.com>
10810L: linux-pwm@vger.kernel.org 10882L: linux-pwm@vger.kernel.org
@@ -10999,6 +11071,14 @@ W: http://wireless.kernel.org/en/users/Drivers/ath9k
10999S: Supported 11071S: Supported
11000F: drivers/net/wireless/ath/ath9k/ 11072F: drivers/net/wireless/ath/ath9k/
11001 11073
11074QUALCOMM CAMERA SUBSYSTEM DRIVER
11075M: Todor Tomov <todor.tomov@linaro.org>
11076L: linux-media@vger.kernel.org
11077S: Maintained
11078F: Documentation/devicetree/bindings/media/qcom,camss.txt
11079F: Documentation/media/v4l-drivers/qcom_camss.rst
11080F: drivers/media/platform/qcom/camss-8x16/
11081
11002QUALCOMM EMAC GIGABIT ETHERNET DRIVER 11082QUALCOMM EMAC GIGABIT ETHERNET DRIVER
11003M: Timur Tabi <timur@codeaurora.org> 11083M: Timur Tabi <timur@codeaurora.org>
11004L: netdev@vger.kernel.org 11084L: netdev@vger.kernel.org
diff --git a/arch/arm/boot/dts/omap3-n950-n9.dtsi b/arch/arm/boot/dts/omap3-n950-n9.dtsi
index df3366fa5409..cb47ae79a5f9 100644
--- a/arch/arm/boot/dts/omap3-n950-n9.dtsi
+++ b/arch/arm/boot/dts/omap3-n950-n9.dtsi
@@ -265,6 +265,20 @@
265 265
266&i2c2 { 266&i2c2 {
267 clock-frequency = <400000>; 267 clock-frequency = <400000>;
268
269 as3645a@30 {
270 reg = <0x30>;
271 compatible = "ams,as3645a";
272 flash {
273 flash-timeout-us = <150000>;
274 flash-max-microamp = <320000>;
275 led-max-microamp = <60000>;
276 peak-current-limit = <1750000>;
277 };
278 indicator {
279 led-max-microamp = <10000>;
280 };
281 };
268}; 282};
269 283
270&i2c3 { 284&i2c3 {
diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
index e74de69caeab..1736813bdea7 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -226,7 +226,7 @@ CONFIG_REGULATOR_MC13892=y
226CONFIG_REGULATOR_PFUZE100=y 226CONFIG_REGULATOR_PFUZE100=y
227CONFIG_MEDIA_SUPPORT=y 227CONFIG_MEDIA_SUPPORT=y
228CONFIG_MEDIA_CAMERA_SUPPORT=y 228CONFIG_MEDIA_CAMERA_SUPPORT=y
229CONFIG_MEDIA_RC_SUPPORT=y 229CONFIG_RC_CORE=y
230CONFIG_RC_DEVICES=y 230CONFIG_RC_DEVICES=y
231CONFIG_IR_GPIO_CIR=y 231CONFIG_IR_GPIO_CIR=y
232CONFIG_MEDIA_USB_SUPPORT=y 232CONFIG_MEDIA_USB_SUPPORT=y
diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index a120ae816260..0414acf731ce 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -304,7 +304,7 @@ CONFIG_REGULATOR_TPS65910=y
304CONFIG_REGULATOR_TWL4030=y 304CONFIG_REGULATOR_TWL4030=y
305CONFIG_MEDIA_SUPPORT=m 305CONFIG_MEDIA_SUPPORT=m
306CONFIG_MEDIA_CAMERA_SUPPORT=y 306CONFIG_MEDIA_CAMERA_SUPPORT=y
307CONFIG_MEDIA_RC_SUPPORT=y 307CONFIG_RC_CORE=m
308CONFIG_MEDIA_CONTROLLER=y 308CONFIG_MEDIA_CONTROLLER=y
309CONFIG_VIDEO_V4L2_SUBDEV_API=y 309CONFIG_VIDEO_V4L2_SUBDEV_API=y
310CONFIG_LIRC=m 310CONFIG_LIRC=m
diff --git a/arch/arm/configs/sunxi_defconfig b/arch/arm/configs/sunxi_defconfig
index 0ec1d1ec130f..22cd559531a9 100644
--- a/arch/arm/configs/sunxi_defconfig
+++ b/arch/arm/configs/sunxi_defconfig
@@ -95,7 +95,7 @@ CONFIG_REGULATOR_FIXED_VOLTAGE=y
95CONFIG_REGULATOR_AXP20X=y 95CONFIG_REGULATOR_AXP20X=y
96CONFIG_REGULATOR_GPIO=y 96CONFIG_REGULATOR_GPIO=y
97CONFIG_MEDIA_SUPPORT=y 97CONFIG_MEDIA_SUPPORT=y
98CONFIG_MEDIA_RC_SUPPORT=y 98CONFIG_RC_CORE=y
99CONFIG_RC_DEVICES=y 99CONFIG_RC_DEVICES=y
100CONFIG_IR_SUNXI=y 100CONFIG_IR_SUNXI=y
101CONFIG_DRM=y 101CONFIG_DRM=y
diff --git a/arch/mips/configs/pistachio_defconfig b/arch/mips/configs/pistachio_defconfig
index 7d32fbbca962..3598d58aac30 100644
--- a/arch/mips/configs/pistachio_defconfig
+++ b/arch/mips/configs/pistachio_defconfig
@@ -207,7 +207,7 @@ CONFIG_IMGPDC_WDT=y
207CONFIG_REGULATOR_FIXED_VOLTAGE=y 207CONFIG_REGULATOR_FIXED_VOLTAGE=y
208CONFIG_REGULATOR_GPIO=y 208CONFIG_REGULATOR_GPIO=y
209CONFIG_MEDIA_SUPPORT=y 209CONFIG_MEDIA_SUPPORT=y
210CONFIG_MEDIA_RC_SUPPORT=y 210CONFIG_RC_CORE=y
211# CONFIG_RC_DECODERS is not set 211# CONFIG_RC_DECODERS is not set
212CONFIG_RC_DEVICES=y 212CONFIG_RC_DEVICES=y
213CONFIG_IR_IMG=y 213CONFIG_IR_IMG=y
diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
index 8ffbb6f65a65..32747b7f917e 100644
--- a/drivers/hid/hid-picolcd_cir.c
+++ b/drivers/hid/hid-picolcd_cir.c
@@ -113,10 +113,10 @@ int picolcd_init_cir(struct picolcd_data *data, struct hid_report *report)
113 return -ENOMEM; 113 return -ENOMEM;
114 114
115 rdev->priv = data; 115 rdev->priv = data;
116 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 116 rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
117 rdev->open = picolcd_cir_open; 117 rdev->open = picolcd_cir_open;
118 rdev->close = picolcd_cir_close; 118 rdev->close = picolcd_cir_close;
119 rdev->input_name = data->hdev->name; 119 rdev->device_name = data->hdev->name;
120 rdev->input_phys = data->hdev->phys; 120 rdev->input_phys = data->hdev->phys;
121 rdev->input_id.bustype = data->hdev->bus; 121 rdev->input_id.bustype = data->hdev->bus;
122 rdev->input_id.vendor = data->hdev->vendor; 122 rdev->input_id.vendor = data->hdev->vendor;
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 594b24d410c3..27dc8002b121 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -58,6 +58,15 @@ config LEDS_AAT1290
58 help 58 help
59 This option enables support for the LEDs on the AAT1290. 59 This option enables support for the LEDs on the AAT1290.
60 60
61config LEDS_AS3645A
62 tristate "AS3645A LED flash controller support"
63 depends on I2C && LEDS_CLASS_FLASH
64 depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS
65 help
66 Enable LED flash class support for AS3645A LED flash
67 controller. V4L2 flash API is provided as well if
68 CONFIG_V4L2_FLASH_API is enabled.
69
61config LEDS_BCM6328 70config LEDS_BCM6328
62 tristate "LED Support for Broadcom BCM6328" 71 tristate "LED Support for Broadcom BCM6328"
63 depends on LEDS_CLASS 72 depends on LEDS_CLASS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 909dae62ba05..7d7b26552923 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o
8# LED Platform Drivers 8# LED Platform Drivers
9obj-$(CONFIG_LEDS_88PM860X) += leds-88pm860x.o 9obj-$(CONFIG_LEDS_88PM860X) += leds-88pm860x.o
10obj-$(CONFIG_LEDS_AAT1290) += leds-aat1290.o 10obj-$(CONFIG_LEDS_AAT1290) += leds-aat1290.o
11obj-$(CONFIG_LEDS_AS3645A) += leds-as3645a.o
11obj-$(CONFIG_LEDS_BCM6328) += leds-bcm6328.o 12obj-$(CONFIG_LEDS_BCM6328) += leds-bcm6328.o
12obj-$(CONFIG_LEDS_BCM6358) += leds-bcm6358.o 13obj-$(CONFIG_LEDS_BCM6358) += leds-bcm6358.o
13obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o 14obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o
diff --git a/drivers/leds/leds-aat1290.c b/drivers/leds/leds-aat1290.c
index a21e19297745..424898e6c69d 100644
--- a/drivers/leds/leds-aat1290.c
+++ b/drivers/leds/leds-aat1290.c
@@ -432,7 +432,7 @@ static void aat1290_init_v4l2_flash_config(struct aat1290_led *led,
432 strlcpy(v4l2_sd_cfg->dev_name, led_cdev->name, 432 strlcpy(v4l2_sd_cfg->dev_name, led_cdev->name,
433 sizeof(v4l2_sd_cfg->dev_name)); 433 sizeof(v4l2_sd_cfg->dev_name));
434 434
435 s = &v4l2_sd_cfg->torch_intensity; 435 s = &v4l2_sd_cfg->intensity;
436 s->min = led->mm_current_scale[0]; 436 s->min = led->mm_current_scale[0];
437 s->max = led_cfg->max_mm_current; 437 s->max = led_cfg->max_mm_current;
438 s->step = 1; 438 s->step = 1;
@@ -504,7 +504,7 @@ static int aat1290_led_probe(struct platform_device *pdev)
504 504
505 /* Create V4L2 Flash subdev. */ 505 /* Create V4L2 Flash subdev. */
506 led->v4l2_flash = v4l2_flash_init(dev, of_fwnode_handle(sub_node), 506 led->v4l2_flash = v4l2_flash_init(dev, of_fwnode_handle(sub_node),
507 fled_cdev, NULL, &v4l2_flash_ops, 507 fled_cdev, &v4l2_flash_ops,
508 &v4l2_sd_cfg); 508 &v4l2_sd_cfg);
509 if (IS_ERR(led->v4l2_flash)) { 509 if (IS_ERR(led->v4l2_flash)) {
510 ret = PTR_ERR(led->v4l2_flash); 510 ret = PTR_ERR(led->v4l2_flash);
diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
new file mode 100644
index 000000000000..bbbbe0898233
--- /dev/null
+++ b/drivers/leds/leds-as3645a.c
@@ -0,0 +1,763 @@
1/*
2 * drivers/leds/leds-as3645a.c - AS3645A and LM3555 flash controllers driver
3 *
4 * Copyright (C) 2008-2011 Nokia Corporation
5 * Copyright (c) 2011, 2017 Intel Corporation.
6 *
7 * Based on drivers/media/i2c/as3645a.c.
8 *
9 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * version 2 as published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 */
20
21#include <linux/delay.h>
22#include <linux/gpio/consumer.h>
23#include <linux/i2c.h>
24#include <linux/led-class-flash.h>
25#include <linux/leds.h>
26#include <linux/module.h>
27#include <linux/mutex.h>
28#include <linux/of.h>
29#include <linux/slab.h>
30
31#include <media/v4l2-flash-led-class.h>
32
33#define AS_TIMER_US_TO_CODE(t) (((t) / 1000 - 100) / 50)
34#define AS_TIMER_CODE_TO_US(c) ((50 * (c) + 100) * 1000)
35
36/* Register definitions */
37
38/* Read-only Design info register: Reset state: xxxx 0001 */
39#define AS_DESIGN_INFO_REG 0x00
40#define AS_DESIGN_INFO_FACTORY(x) (((x) >> 4))
41#define AS_DESIGN_INFO_MODEL(x) ((x) & 0x0f)
42
43/* Read-only Version control register: Reset state: 0000 0000
44 * for first engineering samples
45 */
46#define AS_VERSION_CONTROL_REG 0x01
47#define AS_VERSION_CONTROL_RFU(x) (((x) >> 4))
48#define AS_VERSION_CONTROL_VERSION(x) ((x) & 0x0f)
49
50/* Read / Write (Indicator and timer register): Reset state: 0000 1111 */
51#define AS_INDICATOR_AND_TIMER_REG 0x02
52#define AS_INDICATOR_AND_TIMER_TIMEOUT_SHIFT 0
53#define AS_INDICATOR_AND_TIMER_VREF_SHIFT 4
54#define AS_INDICATOR_AND_TIMER_INDICATOR_SHIFT 6
55
56/* Read / Write (Current set register): Reset state: 0110 1001 */
57#define AS_CURRENT_SET_REG 0x03
58#define AS_CURRENT_ASSIST_LIGHT_SHIFT 0
59#define AS_CURRENT_LED_DET_ON (1 << 3)
60#define AS_CURRENT_FLASH_CURRENT_SHIFT 4
61
62/* Read / Write (Control register): Reset state: 1011 0100 */
63#define AS_CONTROL_REG 0x04
64#define AS_CONTROL_MODE_SETTING_SHIFT 0
65#define AS_CONTROL_STROBE_ON (1 << 2)
66#define AS_CONTROL_OUT_ON (1 << 3)
67#define AS_CONTROL_EXT_TORCH_ON (1 << 4)
68#define AS_CONTROL_STROBE_TYPE_EDGE (0 << 5)
69#define AS_CONTROL_STROBE_TYPE_LEVEL (1 << 5)
70#define AS_CONTROL_COIL_PEAK_SHIFT 6
71
72/* Read only (D3 is read / write) (Fault and info): Reset state: 0000 x000 */
73#define AS_FAULT_INFO_REG 0x05
74#define AS_FAULT_INFO_INDUCTOR_PEAK_LIMIT (1 << 1)
75#define AS_FAULT_INFO_INDICATOR_LED (1 << 2)
76#define AS_FAULT_INFO_LED_AMOUNT (1 << 3)
77#define AS_FAULT_INFO_TIMEOUT (1 << 4)
78#define AS_FAULT_INFO_OVER_TEMPERATURE (1 << 5)
79#define AS_FAULT_INFO_SHORT_CIRCUIT (1 << 6)
80#define AS_FAULT_INFO_OVER_VOLTAGE (1 << 7)
81
82/* Boost register */
83#define AS_BOOST_REG 0x0d
84#define AS_BOOST_CURRENT_DISABLE (0 << 0)
85#define AS_BOOST_CURRENT_ENABLE (1 << 0)
86
87/* Password register is used to unlock boost register writing */
88#define AS_PASSWORD_REG 0x0f
89#define AS_PASSWORD_UNLOCK_VALUE 0x55
90
91#define AS_NAME "as3645a"
92#define AS_I2C_ADDR (0x60 >> 1) /* W:0x60, R:0x61 */
93
94#define AS_FLASH_TIMEOUT_MIN 100000 /* us */
95#define AS_FLASH_TIMEOUT_MAX 850000
96#define AS_FLASH_TIMEOUT_STEP 50000
97
98#define AS_FLASH_INTENSITY_MIN 200000 /* uA */
99#define AS_FLASH_INTENSITY_MAX_1LED 500000
100#define AS_FLASH_INTENSITY_MAX_2LEDS 400000
101#define AS_FLASH_INTENSITY_STEP 20000
102
103#define AS_TORCH_INTENSITY_MIN 20000 /* uA */
104#define AS_TORCH_INTENSITY_MAX 160000
105#define AS_TORCH_INTENSITY_STEP 20000
106
107#define AS_INDICATOR_INTENSITY_MIN 0 /* uA */
108#define AS_INDICATOR_INTENSITY_MAX 10000
109#define AS_INDICATOR_INTENSITY_STEP 2500
110
111#define AS_PEAK_mA_MAX 2000
112#define AS_PEAK_mA_TO_REG(a) \
113 ((min_t(u32, AS_PEAK_mA_MAX, a) - 1250) / 250)
114
115enum as_mode {
116 AS_MODE_EXT_TORCH = 0 << AS_CONTROL_MODE_SETTING_SHIFT,
117 AS_MODE_INDICATOR = 1 << AS_CONTROL_MODE_SETTING_SHIFT,
118 AS_MODE_ASSIST = 2 << AS_CONTROL_MODE_SETTING_SHIFT,
119 AS_MODE_FLASH = 3 << AS_CONTROL_MODE_SETTING_SHIFT,
120};
121
122struct as3645a_config {
123 u32 flash_timeout_us;
124 u32 flash_max_ua;
125 u32 assist_max_ua;
126 u32 indicator_max_ua;
127 u32 voltage_reference;
128 u32 peak;
129};
130
131struct as3645a_names {
132 char flash[32];
133 char indicator[32];
134};
135
136struct as3645a {
137 struct i2c_client *client;
138
139 struct mutex mutex;
140
141 struct led_classdev_flash fled;
142 struct led_classdev iled_cdev;
143
144 struct v4l2_flash *vf;
145 struct v4l2_flash *vfind;
146
147 struct device_node *flash_node;
148 struct device_node *indicator_node;
149
150 struct as3645a_config cfg;
151
152 enum as_mode mode;
153 unsigned int timeout;
154 unsigned int flash_current;
155 unsigned int assist_current;
156 unsigned int indicator_current;
157 enum v4l2_flash_strobe_source strobe_source;
158};
159
160#define fled_to_as3645a(__fled) container_of(__fled, struct as3645a, fled)
161#define iled_cdev_to_as3645a(__iled_cdev) \
162 container_of(__iled_cdev, struct as3645a, iled_cdev)
163
164/* Return negative errno else zero on success */
165static int as3645a_write(struct as3645a *flash, u8 addr, u8 val)
166{
167 struct i2c_client *client = flash->client;
168 int rval;
169
170 rval = i2c_smbus_write_byte_data(client, addr, val);
171
172 dev_dbg(&client->dev, "Write Addr:%02X Val:%02X %s\n", addr, val,
173 rval < 0 ? "fail" : "ok");
174
175 return rval;
176}
177
178/* Return negative errno else a data byte received from the device. */
179static int as3645a_read(struct as3645a *flash, u8 addr)
180{
181 struct i2c_client *client = flash->client;
182 int rval;
183
184 rval = i2c_smbus_read_byte_data(client, addr);
185
186 dev_dbg(&client->dev, "Read Addr:%02X Val:%02X %s\n", addr, rval,
187 rval < 0 ? "fail" : "ok");
188
189 return rval;
190}
191
192/* -----------------------------------------------------------------------------
193 * Hardware configuration and trigger
194 */
195
196/**
197 * as3645a_set_config - Set flash configuration registers
198 * @flash: The flash
199 *
200 * Configure the hardware with flash, assist and indicator currents, as well as
201 * flash timeout.
202 *
203 * Return 0 on success, or a negative error code if an I2C communication error
204 * occurred.
205 */
206static int as3645a_set_current(struct as3645a *flash)
207{
208 u8 val;
209
210 val = (flash->flash_current << AS_CURRENT_FLASH_CURRENT_SHIFT)
211 | (flash->assist_current << AS_CURRENT_ASSIST_LIGHT_SHIFT)
212 | AS_CURRENT_LED_DET_ON;
213
214 return as3645a_write(flash, AS_CURRENT_SET_REG, val);
215}
216
217static int as3645a_set_timeout(struct as3645a *flash)
218{
219 u8 val;
220
221 val = flash->timeout << AS_INDICATOR_AND_TIMER_TIMEOUT_SHIFT;
222
223 val |= (flash->cfg.voltage_reference
224 << AS_INDICATOR_AND_TIMER_VREF_SHIFT)
225 | ((flash->indicator_current ? flash->indicator_current - 1 : 0)
226 << AS_INDICATOR_AND_TIMER_INDICATOR_SHIFT);
227
228 return as3645a_write(flash, AS_INDICATOR_AND_TIMER_REG, val);
229}
230
231/**
232 * as3645a_set_control - Set flash control register
233 * @flash: The flash
234 * @mode: Desired output mode
235 * @on: Desired output state
236 *
237 * Configure the hardware with output mode and state.
238 *
239 * Return 0 on success, or a negative error code if an I2C communication error
240 * occurred.
241 */
242static int
243as3645a_set_control(struct as3645a *flash, enum as_mode mode, bool on)
244{
245 u8 reg;
246
247 /* Configure output parameters and operation mode. */
248 reg = (flash->cfg.peak << AS_CONTROL_COIL_PEAK_SHIFT)
249 | (on ? AS_CONTROL_OUT_ON : 0)
250 | mode;
251
252 if (mode == AS_MODE_FLASH &&
253 flash->strobe_source == V4L2_FLASH_STROBE_SOURCE_EXTERNAL)
254 reg |= AS_CONTROL_STROBE_TYPE_LEVEL
255 | AS_CONTROL_STROBE_ON;
256
257 return as3645a_write(flash, AS_CONTROL_REG, reg);
258}
259
260static int as3645a_get_fault(struct led_classdev_flash *fled, u32 *fault)
261{
262 struct as3645a *flash = fled_to_as3645a(fled);
263 int rval;
264
265 /* NOTE: reading register clears fault status */
266 rval = as3645a_read(flash, AS_FAULT_INFO_REG);
267 if (rval < 0)
268 return rval;
269
270 if (rval & AS_FAULT_INFO_INDUCTOR_PEAK_LIMIT)
271 *fault |= LED_FAULT_OVER_CURRENT;
272
273 if (rval & AS_FAULT_INFO_INDICATOR_LED)
274 *fault |= LED_FAULT_INDICATOR;
275
276 dev_dbg(&flash->client->dev, "%u connected LEDs\n",
277 rval & AS_FAULT_INFO_LED_AMOUNT ? 2 : 1);
278
279 if (rval & AS_FAULT_INFO_TIMEOUT)
280 *fault |= LED_FAULT_TIMEOUT;
281
282 if (rval & AS_FAULT_INFO_OVER_TEMPERATURE)
283 *fault |= LED_FAULT_OVER_TEMPERATURE;
284
285 if (rval & AS_FAULT_INFO_SHORT_CIRCUIT)
286 *fault |= LED_FAULT_OVER_CURRENT;
287
288 if (rval & AS_FAULT_INFO_OVER_VOLTAGE)
289 *fault |= LED_FAULT_INPUT_VOLTAGE;
290
291 return rval;
292}
293
294static unsigned int __as3645a_current_to_reg(unsigned int min, unsigned int max,
295 unsigned int step,
296 unsigned int val)
297{
298 if (val < min)
299 val = min;
300
301 if (val > max)
302 val = max;
303
304 return (val - min) / step;
305}
306
307static unsigned int as3645a_current_to_reg(struct as3645a *flash, bool is_flash,
308 unsigned int ua)
309{
310 if (is_flash)
311 return __as3645a_current_to_reg(AS_TORCH_INTENSITY_MIN,
312 flash->cfg.assist_max_ua,
313 AS_TORCH_INTENSITY_STEP, ua);
314 else
315 return __as3645a_current_to_reg(AS_FLASH_INTENSITY_MIN,
316 flash->cfg.flash_max_ua,
317 AS_FLASH_INTENSITY_STEP, ua);
318}
319
320static int as3645a_set_indicator_brightness(struct led_classdev *iled_cdev,
321 enum led_brightness brightness)
322{
323 struct as3645a *flash = iled_cdev_to_as3645a(iled_cdev);
324 int rval;
325
326 flash->indicator_current = brightness;
327
328 rval = as3645a_set_timeout(flash);
329 if (rval)
330 return rval;
331
332 return as3645a_set_control(flash, AS_MODE_INDICATOR, brightness);
333}
334
335static int as3645a_set_assist_brightness(struct led_classdev *fled_cdev,
336 enum led_brightness brightness)
337{
338 struct led_classdev_flash *fled = lcdev_to_flcdev(fled_cdev);
339 struct as3645a *flash = fled_to_as3645a(fled);
340 int rval;
341
342 if (brightness) {
343 /* Register value 0 is 20 mA. */
344 flash->assist_current = brightness - 1;
345
346 rval = as3645a_set_current(flash);
347 if (rval)
348 return rval;
349 }
350
351 return as3645a_set_control(flash, AS_MODE_ASSIST, brightness);
352}
353
354static int as3645a_set_flash_brightness(struct led_classdev_flash *fled,
355 u32 brightness_ua)
356{
357 struct as3645a *flash = fled_to_as3645a(fled);
358
359 flash->flash_current = as3645a_current_to_reg(flash, true, brightness_ua);
360
361 return as3645a_set_current(flash);
362}
363
364static int as3645a_set_flash_timeout(struct led_classdev_flash *fled,
365 u32 timeout_us)
366{
367 struct as3645a *flash = fled_to_as3645a(fled);
368
369 flash->timeout = AS_TIMER_US_TO_CODE(timeout_us);
370
371 return as3645a_set_timeout(flash);
372}
373
374static int as3645a_set_strobe(struct led_classdev_flash *fled, bool state)
375{
376 struct as3645a *flash = fled_to_as3645a(fled);
377
378 return as3645a_set_control(flash, AS_MODE_FLASH, state);
379}
380
381static const struct led_flash_ops as3645a_led_flash_ops = {
382 .flash_brightness_set = as3645a_set_flash_brightness,
383 .timeout_set = as3645a_set_flash_timeout,
384 .strobe_set = as3645a_set_strobe,
385 .fault_get = as3645a_get_fault,
386};
387
388static int as3645a_setup(struct as3645a *flash)
389{
390 struct device *dev = &flash->client->dev;
391 u32 fault = 0;
392 int rval;
393
394 /* clear errors */
395 rval = as3645a_read(flash, AS_FAULT_INFO_REG);
396 if (rval < 0)
397 return rval;
398
399 dev_dbg(dev, "Fault info: %02x\n", rval);
400
401 rval = as3645a_set_current(flash);
402 if (rval < 0)
403 return rval;
404
405 rval = as3645a_set_timeout(flash);
406 if (rval < 0)
407 return rval;
408
409 rval = as3645a_set_control(flash, AS_MODE_INDICATOR, false);
410 if (rval < 0)
411 return rval;
412
413 /* read status */
414 rval = as3645a_get_fault(&flash->fled, &fault);
415 if (rval < 0)
416 return rval;
417
418 dev_dbg(dev, "AS_INDICATOR_AND_TIMER_REG: %02x\n",
419 as3645a_read(flash, AS_INDICATOR_AND_TIMER_REG));
420 dev_dbg(dev, "AS_CURRENT_SET_REG: %02x\n",
421 as3645a_read(flash, AS_CURRENT_SET_REG));
422 dev_dbg(dev, "AS_CONTROL_REG: %02x\n",
423 as3645a_read(flash, AS_CONTROL_REG));
424
425 return rval & ~AS_FAULT_INFO_LED_AMOUNT ? -EIO : 0;
426}
427
428static int as3645a_detect(struct as3645a *flash)
429{
430 struct device *dev = &flash->client->dev;
431 int rval, man, model, rfu, version;
432 const char *vendor;
433
434 rval = as3645a_read(flash, AS_DESIGN_INFO_REG);
435 if (rval < 0) {
436 dev_err(dev, "can't read design info reg\n");
437 return rval;
438 }
439
440 man = AS_DESIGN_INFO_FACTORY(rval);
441 model = AS_DESIGN_INFO_MODEL(rval);
442
443 rval = as3645a_read(flash, AS_VERSION_CONTROL_REG);
444 if (rval < 0) {
445 dev_err(dev, "can't read version control reg\n");
446 return rval;
447 }
448
449 rfu = AS_VERSION_CONTROL_RFU(rval);
450 version = AS_VERSION_CONTROL_VERSION(rval);
451
452 /* Verify the chip model and version. */
453 if (model != 0x01 || rfu != 0x00) {
454 dev_err(dev, "AS3645A not detected "
455 "(model %d rfu %d)\n", model, rfu);
456 return -ENODEV;
457 }
458
459 switch (man) {
460 case 1:
461 vendor = "AMS, Austria Micro Systems";
462 break;
463 case 2:
464 vendor = "ADI, Analog Devices Inc.";
465 break;
466 case 3:
467 vendor = "NSC, National Semiconductor";
468 break;
469 case 4:
470 vendor = "NXP";
471 break;
472 case 5:
473 vendor = "TI, Texas Instrument";
474 break;
475 default:
476 vendor = "Unknown";
477 }
478
479 dev_info(dev, "Chip vendor: %s (%d) Version: %d\n", vendor,
480 man, version);
481
482 rval = as3645a_write(flash, AS_PASSWORD_REG, AS_PASSWORD_UNLOCK_VALUE);
483 if (rval < 0)
484 return rval;
485
486 return as3645a_write(flash, AS_BOOST_REG, AS_BOOST_CURRENT_DISABLE);
487}
488
489static int as3645a_parse_node(struct as3645a *flash,
490 struct as3645a_names *names,
491 struct device_node *node)
492{
493 struct as3645a_config *cfg = &flash->cfg;
494 const char *name;
495 int rval;
496
497 flash->flash_node = of_get_child_by_name(node, "flash");
498 if (!flash->flash_node) {
499 dev_err(&flash->client->dev, "can't find flash node\n");
500 return -ENODEV;
501 }
502
503 rval = of_property_read_string(flash->flash_node, "label", &name);
504 if (!rval)
505 strlcpy(names->flash, name, sizeof(names->flash));
506 else
507 snprintf(names->flash, sizeof(names->flash),
508 "%s:flash", node->name);
509
510 rval = of_property_read_u32(flash->flash_node, "flash-timeout-us",
511 &cfg->flash_timeout_us);
512 if (rval < 0) {
513 dev_err(&flash->client->dev,
514 "can't read flash-timeout-us property for flash\n");
515 goto out_err;
516 }
517
518 rval = of_property_read_u32(flash->flash_node, "flash-max-microamp",
519 &cfg->flash_max_ua);
520 if (rval < 0) {
521 dev_err(&flash->client->dev,
522 "can't read flash-max-microamp property for flash\n");
523 goto out_err;
524 }
525
526 rval = of_property_read_u32(flash->flash_node, "led-max-microamp",
527 &cfg->assist_max_ua);
528 if (rval < 0) {
529 dev_err(&flash->client->dev,
530 "can't read led-max-microamp property for flash\n");
531 goto out_err;
532 }
533
534 of_property_read_u32(flash->flash_node, "voltage-reference",
535 &cfg->voltage_reference);
536
537 of_property_read_u32(flash->flash_node, "peak-current-limit",
538 &cfg->peak);
539 cfg->peak = AS_PEAK_mA_TO_REG(cfg->peak);
540
541 flash->indicator_node = of_get_child_by_name(node, "indicator");
542 if (!flash->indicator_node) {
543 dev_warn(&flash->client->dev,
544 "can't find indicator node\n");
545 goto out_err;
546 }
547
548 rval = of_property_read_string(flash->indicator_node, "label", &name);
549 if (!rval)
550 strlcpy(names->indicator, name, sizeof(names->indicator));
551 else
552 snprintf(names->indicator, sizeof(names->indicator),
553 "%s:indicator", node->name);
554
555 rval = of_property_read_u32(flash->indicator_node, "led-max-microamp",
556 &cfg->indicator_max_ua);
557 if (rval < 0) {
558 dev_err(&flash->client->dev,
559 "can't read led-max-microamp property for indicator\n");
560 goto out_err;
561 }
562
563 return 0;
564
565out_err:
566 of_node_put(flash->flash_node);
567 of_node_put(flash->indicator_node);
568
569 return rval;
570}
571
572static int as3645a_led_class_setup(struct as3645a *flash,
573 struct as3645a_names *names)
574{
575 struct led_classdev *fled_cdev = &flash->fled.led_cdev;
576 struct led_classdev *iled_cdev = &flash->iled_cdev;
577 struct led_flash_setting *cfg;
578 int rval;
579
580 iled_cdev->name = names->indicator;
581 iled_cdev->brightness_set_blocking = as3645a_set_indicator_brightness;
582 iled_cdev->max_brightness =
583 flash->cfg.indicator_max_ua / AS_INDICATOR_INTENSITY_STEP;
584 iled_cdev->flags = LED_CORE_SUSPENDRESUME;
585
586 rval = led_classdev_register(&flash->client->dev, iled_cdev);
587 if (rval < 0)
588 return rval;
589
590 cfg = &flash->fled.brightness;
591 cfg->min = AS_FLASH_INTENSITY_MIN;
592 cfg->max = flash->cfg.flash_max_ua;
593 cfg->step = AS_FLASH_INTENSITY_STEP;
594 cfg->val = flash->cfg.flash_max_ua;
595
596 cfg = &flash->fled.timeout;
597 cfg->min = AS_FLASH_TIMEOUT_MIN;
598 cfg->max = flash->cfg.flash_timeout_us;
599 cfg->step = AS_FLASH_TIMEOUT_STEP;
600 cfg->val = flash->cfg.flash_timeout_us;
601
602 flash->fled.ops = &as3645a_led_flash_ops;
603
604 fled_cdev->name = names->flash;
605 fled_cdev->brightness_set_blocking = as3645a_set_assist_brightness;
606 /* Value 0 is off in LED class. */
607 fled_cdev->max_brightness =
608 as3645a_current_to_reg(flash, false,
609 flash->cfg.assist_max_ua) + 1;
610 fled_cdev->flags = LED_DEV_CAP_FLASH | LED_CORE_SUSPENDRESUME;
611
612 rval = led_classdev_flash_register(&flash->client->dev, &flash->fled);
613 if (rval) {
614 led_classdev_unregister(iled_cdev);
615 dev_err(&flash->client->dev,
616 "led_classdev_flash_register() failed, error %d\n",
617 rval);
618 }
619
620 return rval;
621}
622
623static int as3645a_v4l2_setup(struct as3645a *flash)
624{
625 struct led_classdev_flash *fled = &flash->fled;
626 struct led_classdev *led = &fled->led_cdev;
627 struct v4l2_flash_config cfg = {
628 .intensity = {
629 .min = AS_TORCH_INTENSITY_MIN,
630 .max = flash->cfg.assist_max_ua,
631 .step = AS_TORCH_INTENSITY_STEP,
632 .val = flash->cfg.assist_max_ua,
633 },
634 };
635 struct v4l2_flash_config cfgind = {
636 .intensity = {
637 .min = AS_INDICATOR_INTENSITY_MIN,
638 .max = flash->cfg.indicator_max_ua,
639 .step = AS_INDICATOR_INTENSITY_STEP,
640 .val = flash->cfg.indicator_max_ua,
641 },
642 };
643
644 strlcpy(cfg.dev_name, led->name, sizeof(cfg.dev_name));
645 strlcpy(cfgind.dev_name, flash->iled_cdev.name, sizeof(cfg.dev_name));
646
647 flash->vf = v4l2_flash_init(
648 &flash->client->dev, of_fwnode_handle(flash->flash_node),
649 &flash->fled, NULL, &cfg);
650 if (IS_ERR(flash->vf))
651 return PTR_ERR(flash->vf);
652
653 flash->vfind = v4l2_flash_indicator_init(
654 &flash->client->dev, of_fwnode_handle(flash->indicator_node),
655 &flash->iled_cdev, &cfgind);
656 if (IS_ERR(flash->vfind)) {
657 v4l2_flash_release(flash->vf);
658 return PTR_ERR(flash->vfind);
659 }
660
661 return 0;
662}
663
664static int as3645a_probe(struct i2c_client *client)
665{
666 struct as3645a_names names;
667 struct as3645a *flash;
668 int rval;
669
670 if (client->dev.of_node == NULL)
671 return -ENODEV;
672
673 flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL);
674 if (flash == NULL)
675 return -ENOMEM;
676
677 flash->client = client;
678
679 rval = as3645a_parse_node(flash, &names, client->dev.of_node);
680 if (rval < 0)
681 return rval;
682
683 rval = as3645a_detect(flash);
684 if (rval < 0)
685 goto out_put_nodes;
686
687 mutex_init(&flash->mutex);
688 i2c_set_clientdata(client, flash);
689
690 rval = as3645a_setup(flash);
691 if (rval)
692 goto out_mutex_destroy;
693
694 rval = as3645a_led_class_setup(flash, &names);
695 if (rval)
696 goto out_mutex_destroy;
697
698 rval = as3645a_v4l2_setup(flash);
699 if (rval)
700 goto out_led_classdev_flash_unregister;
701
702 return 0;
703
704out_led_classdev_flash_unregister:
705 led_classdev_flash_unregister(&flash->fled);
706
707out_mutex_destroy:
708 mutex_destroy(&flash->mutex);
709
710out_put_nodes:
711 of_node_put(flash->flash_node);
712 of_node_put(flash->indicator_node);
713
714 return rval;
715}
716
717static int as3645a_remove(struct i2c_client *client)
718{
719 struct as3645a *flash = i2c_get_clientdata(client);
720
721 as3645a_set_control(flash, AS_MODE_EXT_TORCH, false);
722
723 v4l2_flash_release(flash->vf);
724
725 led_classdev_flash_unregister(&flash->fled);
726 led_classdev_unregister(&flash->iled_cdev);
727
728 mutex_destroy(&flash->mutex);
729
730 of_node_put(flash->flash_node);
731 of_node_put(flash->indicator_node);
732
733 return 0;
734}
735
736static const struct i2c_device_id as3645a_id_table[] = {
737 { AS_NAME, 0 },
738 { },
739};
740MODULE_DEVICE_TABLE(i2c, as3645a_id_table);
741
742static const struct of_device_id as3645a_of_table[] = {
743 { .compatible = "ams,as3645a" },
744 { },
745};
746MODULE_DEVICE_TABLE(of, as3645a_of_table);
747
748static struct i2c_driver as3645a_i2c_driver = {
749 .driver = {
750 .of_match_table = as3645a_of_table,
751 .name = AS_NAME,
752 },
753 .probe_new = as3645a_probe,
754 .remove = as3645a_remove,
755 .id_table = as3645a_id_table,
756};
757
758module_i2c_driver(as3645a_i2c_driver);
759
760MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
761MODULE_AUTHOR("Sakari Ailus <sakari.ailus@iki.fi>");
762MODULE_DESCRIPTION("LED flash driver for AS3645A, LM3555 and their clones");
763MODULE_LICENSE("GPL v2");
diff --git a/drivers/leds/leds-max77693.c b/drivers/leds/leds-max77693.c
index 2d3062d53325..adf0f191f794 100644
--- a/drivers/leds/leds-max77693.c
+++ b/drivers/leds/leds-max77693.c
@@ -856,7 +856,7 @@ static void max77693_init_v4l2_flash_config(struct max77693_sub_led *sub_led,
856 "%s %d-%04x", sub_led->fled_cdev.led_cdev.name, 856 "%s %d-%04x", sub_led->fled_cdev.led_cdev.name,
857 i2c_adapter_id(i2c->adapter), i2c->addr); 857 i2c_adapter_id(i2c->adapter), i2c->addr);
858 858
859 s = &v4l2_sd_cfg->torch_intensity; 859 s = &v4l2_sd_cfg->intensity;
860 s->min = TORCH_IOUT_MIN; 860 s->min = TORCH_IOUT_MIN;
861 s->max = sub_led->fled_cdev.led_cdev.max_brightness * TORCH_IOUT_STEP; 861 s->max = sub_led->fled_cdev.led_cdev.max_brightness * TORCH_IOUT_STEP;
862 s->step = TORCH_IOUT_STEP; 862 s->step = TORCH_IOUT_STEP;
@@ -931,7 +931,7 @@ static int max77693_register_led(struct max77693_sub_led *sub_led,
931 931
932 /* Register in the V4L2 subsystem. */ 932 /* Register in the V4L2 subsystem. */
933 sub_led->v4l2_flash = v4l2_flash_init(dev, of_fwnode_handle(sub_node), 933 sub_led->v4l2_flash = v4l2_flash_init(dev, of_fwnode_handle(sub_node),
934 fled_cdev, NULL, &v4l2_flash_ops, 934 fled_cdev, &v4l2_flash_ops,
935 &v4l2_sd_cfg); 935 &v4l2_sd_cfg);
936 if (IS_ERR(sub_led->v4l2_flash)) { 936 if (IS_ERR(sub_led->v4l2_flash)) {
937 ret = PTR_ERR(sub_led->v4l2_flash); 937 ret = PTR_ERR(sub_led->v4l2_flash);
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index 55d9c2b82b7e..edfe99b22d56 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -8,6 +8,11 @@ config CEC_CORE
8config CEC_NOTIFIER 8config CEC_NOTIFIER
9 bool 9 bool
10 10
11config CEC_PIN
12 bool
13
14source "drivers/media/rc/Kconfig"
15
11menuconfig MEDIA_SUPPORT 16menuconfig MEDIA_SUPPORT
12 tristate "Multimedia support" 17 tristate "Multimedia support"
13 depends on HAS_IOMEM 18 depends on HAS_IOMEM
@@ -72,20 +77,6 @@ config MEDIA_SDR_SUPPORT
72 77
73 Say Y when you have a software defined radio device. 78 Say Y when you have a software defined radio device.
74 79
75config MEDIA_RC_SUPPORT
76 bool "Remote Controller support"
77 depends on INPUT
78 ---help---
79 Enable support for Remote Controllers on Linux. This is
80 needed in order to support several video capture adapters,
81 standalone IR receivers/transmitters, and RF receivers.
82
83 Enable this option if you have a video capture board even
84 if you don't need IR, as otherwise, you may not be able to
85 compile the driver for your adapter.
86
87 Say Y when you have a TV or an IR device.
88
89config MEDIA_CEC_SUPPORT 80config MEDIA_CEC_SUPPORT
90 bool "HDMI CEC support" 81 bool "HDMI CEC support"
91 ---help--- 82 ---help---
@@ -175,7 +166,6 @@ config TTPCI_EEPROM
175source "drivers/media/dvb-core/Kconfig" 166source "drivers/media/dvb-core/Kconfig"
176 167
177comment "Media drivers" 168comment "Media drivers"
178source "drivers/media/rc/Kconfig"
179 169
180# 170#
181# V4L platform/mem2mem drivers 171# V4L platform/mem2mem drivers
diff --git a/drivers/media/cec/Makefile b/drivers/media/cec/Makefile
index eaf408e64669..3353c1741961 100644
--- a/drivers/media/cec/Makefile
+++ b/drivers/media/cec/Makefile
@@ -4,4 +4,8 @@ ifeq ($(CONFIG_CEC_NOTIFIER),y)
4 cec-objs += cec-notifier.o 4 cec-objs += cec-notifier.o
5endif 5endif
6 6
7ifeq ($(CONFIG_CEC_PIN),y)
8 cec-objs += cec-pin.o
9endif
10
7obj-$(CONFIG_CEC_CORE) += cec.o 11obj-$(CONFIG_CEC_CORE) += cec.o
diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c
index d596b601ff42..dd769e40416f 100644
--- a/drivers/media/cec/cec-adap.c
+++ b/drivers/media/cec/cec-adap.c
@@ -78,42 +78,62 @@ static unsigned int cec_log_addr2dev(const struct cec_adapter *adap, u8 log_addr
78 * Queue a new event for this filehandle. If ts == 0, then set it 78 * Queue a new event for this filehandle. If ts == 0, then set it
79 * to the current time. 79 * to the current time.
80 * 80 *
81 * The two events that are currently defined do not need to keep track 81 * We keep a queue of at most max_event events where max_event differs
82 * of intermediate events, so no actual queue of events is needed, 82 * per event. If the queue becomes full, then drop the oldest event and
83 * instead just store the latest state and the total number of lost 83 * keep track of how many events we've dropped.
84 * messages.
85 *
86 * Should new events be added in the future that require intermediate
87 * results to be queued as well, then a proper queue data structure is
88 * required. But until then, just keep it simple.
89 */ 84 */
90void cec_queue_event_fh(struct cec_fh *fh, 85void cec_queue_event_fh(struct cec_fh *fh,
91 const struct cec_event *new_ev, u64 ts) 86 const struct cec_event *new_ev, u64 ts)
92{ 87{
93 struct cec_event *ev = &fh->events[new_ev->event - 1]; 88 static const u8 max_events[CEC_NUM_EVENTS] = {
89 1, 1, 64, 64,
90 };
91 struct cec_event_entry *entry;
92 unsigned int ev_idx = new_ev->event - 1;
93
94 if (WARN_ON(ev_idx >= ARRAY_SIZE(fh->events)))
95 return;
94 96
95 if (ts == 0) 97 if (ts == 0)
96 ts = ktime_get_ns(); 98 ts = ktime_get_ns();
97 99
98 mutex_lock(&fh->lock); 100 mutex_lock(&fh->lock);
99 if (new_ev->event == CEC_EVENT_LOST_MSGS && 101 if (ev_idx < CEC_NUM_CORE_EVENTS)
100 fh->pending_events & (1 << new_ev->event)) { 102 entry = &fh->core_events[ev_idx];
101 /* 103 else
102 * If there is already a lost_msgs event, then just 104 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
103 * update the lost_msgs count. This effectively 105 if (entry) {
104 * merges the old and new events into one. 106 if (new_ev->event == CEC_EVENT_LOST_MSGS &&
105 */ 107 fh->queued_events[ev_idx]) {
106 ev->lost_msgs.lost_msgs += new_ev->lost_msgs.lost_msgs; 108 entry->ev.lost_msgs.lost_msgs +=
107 goto unlock; 109 new_ev->lost_msgs.lost_msgs;
108 } 110 goto unlock;
111 }
112 entry->ev = *new_ev;
113 entry->ev.ts = ts;
114
115 if (fh->queued_events[ev_idx] < max_events[ev_idx]) {
116 /* Add new msg at the end of the queue */
117 list_add_tail(&entry->list, &fh->events[ev_idx]);
118 fh->queued_events[ev_idx]++;
119 fh->total_queued_events++;
120 goto unlock;
121 }
109 122
110 /* 123 if (ev_idx >= CEC_NUM_CORE_EVENTS) {
111 * Intermediate states are not interesting, so just 124 list_add_tail(&entry->list, &fh->events[ev_idx]);
112 * overwrite any older event. 125 /* drop the oldest event */
113 */ 126 entry = list_first_entry(&fh->events[ev_idx],
114 *ev = *new_ev; 127 struct cec_event_entry, list);
115 ev->ts = ts; 128 list_del(&entry->list);
116 fh->pending_events |= 1 << new_ev->event; 129 kfree(entry);
130 }
131 }
132 /* Mark that events were lost */
133 entry = list_first_entry_or_null(&fh->events[ev_idx],
134 struct cec_event_entry, list);
135 if (entry)
136 entry->ev.flags |= CEC_EVENT_FL_DROPPED_EVENTS;
117 137
118unlock: 138unlock:
119 mutex_unlock(&fh->lock); 139 mutex_unlock(&fh->lock);
@@ -133,47 +153,68 @@ static void cec_queue_event(struct cec_adapter *adap,
133 mutex_unlock(&adap->devnode.lock); 153 mutex_unlock(&adap->devnode.lock);
134} 154}
135 155
156/* Notify userspace that the CEC pin changed state at the given time. */
157void cec_queue_pin_cec_event(struct cec_adapter *adap, bool is_high, ktime_t ts)
158{
159 struct cec_event ev = {
160 .event = is_high ? CEC_EVENT_PIN_CEC_HIGH :
161 CEC_EVENT_PIN_CEC_LOW,
162 };
163 struct cec_fh *fh;
164
165 mutex_lock(&adap->devnode.lock);
166 list_for_each_entry(fh, &adap->devnode.fhs, list)
167 if (fh->mode_follower == CEC_MODE_MONITOR_PIN)
168 cec_queue_event_fh(fh, &ev, ktime_to_ns(ts));
169 mutex_unlock(&adap->devnode.lock);
170}
171EXPORT_SYMBOL_GPL(cec_queue_pin_cec_event);
172
136/* 173/*
137 * Queue a new message for this filehandle. If there is no more room 174 * Queue a new message for this filehandle.
138 * in the queue, then send the LOST_MSGS event instead. 175 *
176 * We keep a queue of at most CEC_MAX_MSG_RX_QUEUE_SZ messages. If the
177 * queue becomes full, then drop the oldest message and keep track
178 * of how many messages we've dropped.
139 */ 179 */
140static void cec_queue_msg_fh(struct cec_fh *fh, const struct cec_msg *msg) 180static void cec_queue_msg_fh(struct cec_fh *fh, const struct cec_msg *msg)
141{ 181{
142 static const struct cec_event ev_lost_msg = { 182 static const struct cec_event ev_lost_msgs = {
143 .ts = 0,
144 .event = CEC_EVENT_LOST_MSGS, 183 .event = CEC_EVENT_LOST_MSGS,
145 .flags = 0, 184 .lost_msgs.lost_msgs = 1,
146 {
147 .lost_msgs.lost_msgs = 1,
148 },
149 }; 185 };
150 struct cec_msg_entry *entry; 186 struct cec_msg_entry *entry;
151 187
152 mutex_lock(&fh->lock); 188 mutex_lock(&fh->lock);
153 entry = kmalloc(sizeof(*entry), GFP_KERNEL); 189 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
154 if (!entry) 190 if (entry) {
155 goto lost_msgs; 191 entry->msg = *msg;
156 192 /* Add new msg at the end of the queue */
157 entry->msg = *msg; 193 list_add_tail(&entry->list, &fh->msgs);
158 /* Add new msg at the end of the queue */ 194
159 list_add_tail(&entry->list, &fh->msgs); 195 if (fh->queued_msgs < CEC_MAX_MSG_RX_QUEUE_SZ) {
196 /* All is fine if there is enough room */
197 fh->queued_msgs++;
198 mutex_unlock(&fh->lock);
199 wake_up_interruptible(&fh->wait);
200 return;
201 }
160 202
161 /* 203 /*
162 * if the queue now has more than CEC_MAX_MSG_RX_QUEUE_SZ 204 * if the message queue is full, then drop the oldest one and
163 * messages, drop the oldest one and send a lost message event. 205 * send a lost message event.
164 */ 206 */
165 if (fh->queued_msgs == CEC_MAX_MSG_RX_QUEUE_SZ) { 207 entry = list_first_entry(&fh->msgs, struct cec_msg_entry, list);
166 list_del(&entry->list); 208 list_del(&entry->list);
167 goto lost_msgs; 209 kfree(entry);
168 } 210 }
169 fh->queued_msgs++;
170 mutex_unlock(&fh->lock); 211 mutex_unlock(&fh->lock);
171 wake_up_interruptible(&fh->wait);
172 return;
173 212
174lost_msgs: 213 /*
175 mutex_unlock(&fh->lock); 214 * We lost a message, either because kmalloc failed or the queue
176 cec_queue_event_fh(fh, &ev_lost_msg, 0); 215 * was full.
216 */
217 cec_queue_event_fh(fh, &ev_lost_msgs, ktime_get_ns());
177} 218}
178 219
179/* 220/*
@@ -394,13 +435,17 @@ int cec_thread_func(void *_adap)
394 435
395 if (adap->transmitting && timeout) { 436 if (adap->transmitting && timeout) {
396 /* 437 /*
397 * If we timeout, then log that. This really shouldn't 438 * If we timeout, then log that. Normally this does
398 * happen and is an indication of a faulty CEC adapter 439 * not happen and it is an indication of a faulty CEC
399 * driver, or the CEC bus is in some weird state. 440 * adapter driver, or the CEC bus is in some weird
441 * state. On rare occasions it can happen if there is
442 * so much traffic on the bus that the adapter was
443 * unable to transmit for CEC_XFER_TIMEOUT_MS (2.1s).
400 */ 444 */
401 dprintk(0, "%s: message %*ph timed out!\n", __func__, 445 dprintk(1, "%s: message %*ph timed out\n", __func__,
402 adap->transmitting->msg.len, 446 adap->transmitting->msg.len,
403 adap->transmitting->msg.msg); 447 adap->transmitting->msg.msg);
448 adap->tx_timeouts++;
404 /* Just give up on this. */ 449 /* Just give up on this. */
405 cec_data_cancel(adap->transmitting); 450 cec_data_cancel(adap->transmitting);
406 goto unlock; 451 goto unlock;
@@ -467,14 +512,19 @@ unlock:
467/* 512/*
468 * Called by the CEC adapter if a transmit finished. 513 * Called by the CEC adapter if a transmit finished.
469 */ 514 */
470void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt, 515void cec_transmit_done_ts(struct cec_adapter *adap, u8 status,
471 u8 nack_cnt, u8 low_drive_cnt, u8 error_cnt) 516 u8 arb_lost_cnt, u8 nack_cnt, u8 low_drive_cnt,
517 u8 error_cnt, ktime_t ts)
472{ 518{
473 struct cec_data *data; 519 struct cec_data *data;
474 struct cec_msg *msg; 520 struct cec_msg *msg;
475 u64 ts = ktime_get_ns(); 521 unsigned int attempts_made = arb_lost_cnt + nack_cnt +
522 low_drive_cnt + error_cnt;
476 523
477 dprintk(2, "%s: status %02x\n", __func__, status); 524 dprintk(2, "%s: status %02x\n", __func__, status);
525 if (attempts_made < 1)
526 attempts_made = 1;
527
478 mutex_lock(&adap->lock); 528 mutex_lock(&adap->lock);
479 data = adap->transmitting; 529 data = adap->transmitting;
480 if (!data) { 530 if (!data) {
@@ -492,7 +542,7 @@ void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt,
492 542
493 /* Drivers must fill in the status! */ 543 /* Drivers must fill in the status! */
494 WARN_ON(status == 0); 544 WARN_ON(status == 0);
495 msg->tx_ts = ts; 545 msg->tx_ts = ktime_to_ns(ts);
496 msg->tx_status |= status; 546 msg->tx_status |= status;
497 msg->tx_arb_lost_cnt += arb_lost_cnt; 547 msg->tx_arb_lost_cnt += arb_lost_cnt;
498 msg->tx_nack_cnt += nack_cnt; 548 msg->tx_nack_cnt += nack_cnt;
@@ -507,10 +557,10 @@ void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt,
507 * the hardware didn't signal that it retried itself (by setting 557 * the hardware didn't signal that it retried itself (by setting
508 * CEC_TX_STATUS_MAX_RETRIES), then we will retry ourselves. 558 * CEC_TX_STATUS_MAX_RETRIES), then we will retry ourselves.
509 */ 559 */
510 if (data->attempts > 1 && 560 if (data->attempts > attempts_made &&
511 !(status & (CEC_TX_STATUS_MAX_RETRIES | CEC_TX_STATUS_OK))) { 561 !(status & (CEC_TX_STATUS_MAX_RETRIES | CEC_TX_STATUS_OK))) {
512 /* Retry this message */ 562 /* Retry this message */
513 data->attempts--; 563 data->attempts -= attempts_made;
514 if (msg->timeout) 564 if (msg->timeout)
515 dprintk(2, "retransmit: %*ph (attempts: %d, wait for 0x%02x)\n", 565 dprintk(2, "retransmit: %*ph (attempts: %d, wait for 0x%02x)\n",
516 msg->len, msg->msg, data->attempts, msg->reply); 566 msg->len, msg->msg, data->attempts, msg->reply);
@@ -555,25 +605,26 @@ wake_thread:
555unlock: 605unlock:
556 mutex_unlock(&adap->lock); 606 mutex_unlock(&adap->lock);
557} 607}
558EXPORT_SYMBOL_GPL(cec_transmit_done); 608EXPORT_SYMBOL_GPL(cec_transmit_done_ts);
559 609
560void cec_transmit_attempt_done(struct cec_adapter *adap, u8 status) 610void cec_transmit_attempt_done_ts(struct cec_adapter *adap,
611 u8 status, ktime_t ts)
561{ 612{
562 switch (status & ~CEC_TX_STATUS_MAX_RETRIES) { 613 switch (status & ~CEC_TX_STATUS_MAX_RETRIES) {
563 case CEC_TX_STATUS_OK: 614 case CEC_TX_STATUS_OK:
564 cec_transmit_done(adap, status, 0, 0, 0, 0); 615 cec_transmit_done_ts(adap, status, 0, 0, 0, 0, ts);
565 return; 616 return;
566 case CEC_TX_STATUS_ARB_LOST: 617 case CEC_TX_STATUS_ARB_LOST:
567 cec_transmit_done(adap, status, 1, 0, 0, 0); 618 cec_transmit_done_ts(adap, status, 1, 0, 0, 0, ts);
568 return; 619 return;
569 case CEC_TX_STATUS_NACK: 620 case CEC_TX_STATUS_NACK:
570 cec_transmit_done(adap, status, 0, 1, 0, 0); 621 cec_transmit_done_ts(adap, status, 0, 1, 0, 0, ts);
571 return; 622 return;
572 case CEC_TX_STATUS_LOW_DRIVE: 623 case CEC_TX_STATUS_LOW_DRIVE:
573 cec_transmit_done(adap, status, 0, 0, 1, 0); 624 cec_transmit_done_ts(adap, status, 0, 0, 1, 0, ts);
574 return; 625 return;
575 case CEC_TX_STATUS_ERROR: 626 case CEC_TX_STATUS_ERROR:
576 cec_transmit_done(adap, status, 0, 0, 0, 1); 627 cec_transmit_done_ts(adap, status, 0, 0, 0, 1, ts);
577 return; 628 return;
578 default: 629 default:
579 /* Should never happen */ 630 /* Should never happen */
@@ -581,7 +632,7 @@ void cec_transmit_attempt_done(struct cec_adapter *adap, u8 status)
581 return; 632 return;
582 } 633 }
583} 634}
584EXPORT_SYMBOL_GPL(cec_transmit_attempt_done); 635EXPORT_SYMBOL_GPL(cec_transmit_attempt_done_ts);
585 636
586/* 637/*
587 * Called when waiting for a reply times out. 638 * Called when waiting for a reply times out.
@@ -630,9 +681,7 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
630 msg->tx_nack_cnt = 0; 681 msg->tx_nack_cnt = 0;
631 msg->tx_low_drive_cnt = 0; 682 msg->tx_low_drive_cnt = 0;
632 msg->tx_error_cnt = 0; 683 msg->tx_error_cnt = 0;
633 msg->sequence = ++adap->sequence; 684 msg->sequence = 0;
634 if (!msg->sequence)
635 msg->sequence = ++adap->sequence;
636 685
637 if (msg->reply && msg->timeout == 0) { 686 if (msg->reply && msg->timeout == 0) {
638 /* Make sure the timeout isn't 0. */ 687 /* Make sure the timeout isn't 0. */
@@ -671,6 +720,9 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
671 msg->tx_status = CEC_TX_STATUS_NACK | 720 msg->tx_status = CEC_TX_STATUS_NACK |
672 CEC_TX_STATUS_MAX_RETRIES; 721 CEC_TX_STATUS_MAX_RETRIES;
673 msg->tx_nack_cnt = 1; 722 msg->tx_nack_cnt = 1;
723 msg->sequence = ++adap->sequence;
724 if (!msg->sequence)
725 msg->sequence = ++adap->sequence;
674 return 0; 726 return 0;
675 } 727 }
676 } 728 }
@@ -705,6 +757,10 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
705 if (!data) 757 if (!data)
706 return -ENOMEM; 758 return -ENOMEM;
707 759
760 msg->sequence = ++adap->sequence;
761 if (!msg->sequence)
762 msg->sequence = ++adap->sequence;
763
708 if (msg->len > 1 && msg->msg[1] == CEC_MSG_CDC_MESSAGE) { 764 if (msg->len > 1 && msg->msg[1] == CEC_MSG_CDC_MESSAGE) {
709 msg->msg[2] = adap->phys_addr >> 8; 765 msg->msg[2] = adap->phys_addr >> 8;
710 msg->msg[3] = adap->phys_addr & 0xff; 766 msg->msg[3] = adap->phys_addr & 0xff;
@@ -712,7 +768,8 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
712 768
713 if (msg->timeout) 769 if (msg->timeout)
714 dprintk(2, "%s: %*ph (wait for 0x%02x%s)\n", 770 dprintk(2, "%s: %*ph (wait for 0x%02x%s)\n",
715 __func__, msg->len, msg->msg, msg->reply, !block ? ", nb" : ""); 771 __func__, msg->len, msg->msg, msg->reply,
772 !block ? ", nb" : "");
716 else 773 else
717 dprintk(2, "%s: %*ph%s\n", 774 dprintk(2, "%s: %*ph%s\n",
718 __func__, msg->len, msg->msg, !block ? " (nb)" : ""); 775 __func__, msg->len, msg->msg, !block ? " (nb)" : "");
@@ -909,7 +966,8 @@ static const u8 cec_msg_size[256] = {
909}; 966};
910 967
911/* Called by the CEC adapter if a message is received */ 968/* Called by the CEC adapter if a message is received */
912void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg) 969void cec_received_msg_ts(struct cec_adapter *adap,
970 struct cec_msg *msg, ktime_t ts)
913{ 971{
914 struct cec_data *data; 972 struct cec_data *data;
915 u8 msg_init = cec_msg_initiator(msg); 973 u8 msg_init = cec_msg_initiator(msg);
@@ -937,7 +995,7 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg)
937 cec_has_log_addr(adap, msg_init)) 995 cec_has_log_addr(adap, msg_init))
938 return; 996 return;
939 997
940 msg->rx_ts = ktime_get_ns(); 998 msg->rx_ts = ktime_to_ns(ts);
941 msg->rx_status = CEC_RX_STATUS_OK; 999 msg->rx_status = CEC_RX_STATUS_OK;
942 msg->sequence = msg->reply = msg->timeout = 0; 1000 msg->sequence = msg->reply = msg->timeout = 0;
943 msg->tx_status = 0; 1001 msg->tx_status = 0;
@@ -1102,7 +1160,7 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg)
1102 */ 1160 */
1103 cec_receive_notify(adap, msg, is_reply); 1161 cec_receive_notify(adap, msg, is_reply);
1104} 1162}
1105EXPORT_SYMBOL_GPL(cec_received_msg); 1163EXPORT_SYMBOL_GPL(cec_received_msg_ts);
1106 1164
1107/* Logical Address Handling */ 1165/* Logical Address Handling */
1108 1166
@@ -1390,7 +1448,9 @@ static void cec_claim_log_addrs(struct cec_adapter *adap, bool block)
1390 */ 1448 */
1391void __cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, bool block) 1449void __cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, bool block)
1392{ 1450{
1393 if (phys_addr == adap->phys_addr || adap->devnode.unregistered) 1451 if (phys_addr == adap->phys_addr)
1452 return;
1453 if (phys_addr != CEC_PHYS_ADDR_INVALID && adap->devnode.unregistered)
1394 return; 1454 return;
1395 1455
1396 dprintk(1, "new physical address %x.%x.%x.%x\n", 1456 dprintk(1, "new physical address %x.%x.%x.%x\n",
@@ -1471,8 +1531,13 @@ int __cec_s_log_addrs(struct cec_adapter *adap,
1471 return -ENODEV; 1531 return -ENODEV;
1472 1532
1473 if (!log_addrs || log_addrs->num_log_addrs == 0) { 1533 if (!log_addrs || log_addrs->num_log_addrs == 0) {
1474 adap->log_addrs.num_log_addrs = 0;
1475 cec_adap_unconfigure(adap); 1534 cec_adap_unconfigure(adap);
1535 adap->log_addrs.num_log_addrs = 0;
1536 for (i = 0; i < CEC_MAX_LOG_ADDRS; i++)
1537 adap->log_addrs.log_addr[i] = CEC_LOG_ADDR_INVALID;
1538 adap->log_addrs.osd_name[0] = '\0';
1539 adap->log_addrs.vendor_id = CEC_VENDOR_ID_NONE;
1540 adap->log_addrs.cec_version = CEC_OP_CEC_VERSION_2_0;
1476 return 0; 1541 return 0;
1477 } 1542 }
1478 1543
@@ -1704,6 +1769,9 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
1704 int la_idx = cec_log_addr2idx(adap, dest_laddr); 1769 int la_idx = cec_log_addr2idx(adap, dest_laddr);
1705 bool from_unregistered = init_laddr == 0xf; 1770 bool from_unregistered = init_laddr == 0xf;
1706 struct cec_msg tx_cec_msg = { }; 1771 struct cec_msg tx_cec_msg = { };
1772#ifdef CONFIG_MEDIA_CEC_RC
1773 int scancode;
1774#endif
1707 1775
1708 dprintk(2, "%s: %*ph\n", __func__, msg->len, msg->msg); 1776 dprintk(2, "%s: %*ph\n", __func__, msg->len, msg->msg);
1709 1777
@@ -1792,11 +1860,9 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
1792 */ 1860 */
1793 case 0x60: 1861 case 0x60:
1794 if (msg->len == 2) 1862 if (msg->len == 2)
1795 rc_keydown(adap->rc, RC_TYPE_CEC, 1863 scancode = msg->msg[2];
1796 msg->msg[2], 0);
1797 else 1864 else
1798 rc_keydown(adap->rc, RC_TYPE_CEC, 1865 scancode = msg->msg[2] << 8 | msg->msg[3];
1799 msg->msg[2] << 8 | msg->msg[3], 0);
1800 break; 1866 break;
1801 /* 1867 /*
1802 * Other function messages that are not handled. 1868 * Other function messages that are not handled.
@@ -1809,11 +1875,54 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
1809 */ 1875 */
1810 case 0x56: case 0x57: 1876 case 0x56: case 0x57:
1811 case 0x67: case 0x68: case 0x69: case 0x6a: 1877 case 0x67: case 0x68: case 0x69: case 0x6a:
1878 scancode = -1;
1812 break; 1879 break;
1813 default: 1880 default:
1814 rc_keydown(adap->rc, RC_TYPE_CEC, msg->msg[2], 0); 1881 scancode = msg->msg[2];
1815 break; 1882 break;
1816 } 1883 }
1884
1885 /* Was repeating, but keypress timed out */
1886 if (adap->rc_repeating && !adap->rc->keypressed) {
1887 adap->rc_repeating = false;
1888 adap->rc_last_scancode = -1;
1889 }
1890 /* Different keypress from last time, ends repeat mode */
1891 if (adap->rc_last_scancode != scancode) {
1892 rc_keyup(adap->rc);
1893 adap->rc_repeating = false;
1894 }
1895 /* We can't handle this scancode */
1896 if (scancode < 0) {
1897 adap->rc_last_scancode = scancode;
1898 break;
1899 }
1900
1901 /* Send key press */
1902 rc_keydown(adap->rc, RC_PROTO_CEC, scancode, 0);
1903
1904 /* When in repeating mode, we're done */
1905 if (adap->rc_repeating)
1906 break;
1907
1908 /*
1909 * We are not repeating, but the new scancode is
1910 * the same as the last one, and this second key press is
1911 * within 550 ms (the 'Follower Safety Timeout') from the
1912 * previous key press, so we now enable the repeating mode.
1913 */
1914 if (adap->rc_last_scancode == scancode &&
1915 msg->rx_ts - adap->rc_last_keypress < 550 * NSEC_PER_MSEC) {
1916 adap->rc_repeating = true;
1917 break;
1918 }
1919 /*
1920 * Not in repeating mode, so avoid triggering repeat mode
1921 * by calling keyup.
1922 */
1923 rc_keyup(adap->rc);
1924 adap->rc_last_scancode = scancode;
1925 adap->rc_last_keypress = msg->rx_ts;
1817#endif 1926#endif
1818 break; 1927 break;
1819 1928
@@ -1823,6 +1932,8 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
1823 break; 1932 break;
1824#ifdef CONFIG_MEDIA_CEC_RC 1933#ifdef CONFIG_MEDIA_CEC_RC
1825 rc_keyup(adap->rc); 1934 rc_keyup(adap->rc);
1935 adap->rc_repeating = false;
1936 adap->rc_last_scancode = -1;
1826#endif 1937#endif
1827 break; 1938 break;
1828 1939
@@ -1941,6 +2052,11 @@ int cec_adap_status(struct seq_file *file, void *priv)
1941 if (adap->monitor_all_cnt) 2052 if (adap->monitor_all_cnt)
1942 seq_printf(file, "file handles in Monitor All mode: %u\n", 2053 seq_printf(file, "file handles in Monitor All mode: %u\n",
1943 adap->monitor_all_cnt); 2054 adap->monitor_all_cnt);
2055 if (adap->tx_timeouts) {
2056 seq_printf(file, "transmit timeouts: %u\n",
2057 adap->tx_timeouts);
2058 adap->tx_timeouts = 0;
2059 }
1944 data = adap->transmitting; 2060 data = adap->transmitting;
1945 if (data) 2061 if (data)
1946 seq_printf(file, "transmitting message: %*ph (reply: %02x, timeout: %ums)\n", 2062 seq_printf(file, "transmitting message: %*ph (reply: %02x, timeout: %ums)\n",
diff --git a/drivers/media/cec/cec-api.c b/drivers/media/cec/cec-api.c
index f7eb4c54a354..a079f7fe018c 100644
--- a/drivers/media/cec/cec-api.c
+++ b/drivers/media/cec/cec-api.c
@@ -30,6 +30,7 @@
30#include <linux/uaccess.h> 30#include <linux/uaccess.h>
31#include <linux/version.h> 31#include <linux/version.h>
32 32
33#include <media/cec-pin.h>
33#include "cec-priv.h" 34#include "cec-priv.h"
34 35
35static inline struct cec_devnode *cec_devnode_data(struct file *filp) 36static inline struct cec_devnode *cec_devnode_data(struct file *filp)
@@ -57,7 +58,7 @@ static unsigned int cec_poll(struct file *filp,
57 res |= POLLOUT | POLLWRNORM; 58 res |= POLLOUT | POLLWRNORM;
58 if (fh->queued_msgs) 59 if (fh->queued_msgs)
59 res |= POLLIN | POLLRDNORM; 60 res |= POLLIN | POLLRDNORM;
60 if (fh->pending_events) 61 if (fh->total_queued_events)
61 res |= POLLPRI; 62 res |= POLLPRI;
62 poll_wait(filp, &fh->wait, poll); 63 poll_wait(filp, &fh->wait, poll);
63 mutex_unlock(&adap->lock); 64 mutex_unlock(&adap->lock);
@@ -289,15 +290,17 @@ static long cec_receive(struct cec_adapter *adap, struct cec_fh *fh,
289static long cec_dqevent(struct cec_adapter *adap, struct cec_fh *fh, 290static long cec_dqevent(struct cec_adapter *adap, struct cec_fh *fh,
290 bool block, struct cec_event __user *parg) 291 bool block, struct cec_event __user *parg)
291{ 292{
292 struct cec_event *ev = NULL; 293 struct cec_event_entry *ev = NULL;
293 u64 ts = ~0ULL; 294 u64 ts = ~0ULL;
294 unsigned int i; 295 unsigned int i;
296 unsigned int ev_idx;
295 long err = 0; 297 long err = 0;
296 298
297 mutex_lock(&fh->lock); 299 mutex_lock(&fh->lock);
298 while (!fh->pending_events && block) { 300 while (!fh->total_queued_events && block) {
299 mutex_unlock(&fh->lock); 301 mutex_unlock(&fh->lock);
300 err = wait_event_interruptible(fh->wait, fh->pending_events); 302 err = wait_event_interruptible(fh->wait,
303 fh->total_queued_events);
301 if (err) 304 if (err)
302 return err; 305 return err;
303 mutex_lock(&fh->lock); 306 mutex_lock(&fh->lock);
@@ -305,23 +308,29 @@ static long cec_dqevent(struct cec_adapter *adap, struct cec_fh *fh,
305 308
306 /* Find the oldest event */ 309 /* Find the oldest event */
307 for (i = 0; i < CEC_NUM_EVENTS; i++) { 310 for (i = 0; i < CEC_NUM_EVENTS; i++) {
308 if (fh->pending_events & (1 << (i + 1)) && 311 struct cec_event_entry *entry =
309 fh->events[i].ts <= ts) { 312 list_first_entry_or_null(&fh->events[i],
310 ev = &fh->events[i]; 313 struct cec_event_entry, list);
311 ts = ev->ts; 314
315 if (entry && entry->ev.ts <= ts) {
316 ev = entry;
317 ev_idx = i;
318 ts = ev->ev.ts;
312 } 319 }
313 } 320 }
321
314 if (!ev) { 322 if (!ev) {
315 err = -EAGAIN; 323 err = -EAGAIN;
316 goto unlock; 324 goto unlock;
317 } 325 }
326 list_del(&ev->list);
318 327
319 if (copy_to_user(parg, ev, sizeof(*ev))) { 328 if (copy_to_user(parg, &ev->ev, sizeof(ev->ev)))
320 err = -EFAULT; 329 err = -EFAULT;
321 goto unlock; 330 if (ev_idx >= CEC_NUM_CORE_EVENTS)
322 } 331 kfree(ev);
323 332 fh->queued_events[ev_idx]--;
324 fh->pending_events &= ~(1 << ev->event); 333 fh->total_queued_events--;
325 334
326unlock: 335unlock:
327 mutex_unlock(&fh->lock); 336 mutex_unlock(&fh->lock);
@@ -348,33 +357,50 @@ static long cec_s_mode(struct cec_adapter *adap, struct cec_fh *fh,
348 357
349 if (copy_from_user(&mode, parg, sizeof(mode))) 358 if (copy_from_user(&mode, parg, sizeof(mode)))
350 return -EFAULT; 359 return -EFAULT;
351 if (mode & ~(CEC_MODE_INITIATOR_MSK | CEC_MODE_FOLLOWER_MSK)) 360 if (mode & ~(CEC_MODE_INITIATOR_MSK | CEC_MODE_FOLLOWER_MSK)) {
361 dprintk(1, "%s: invalid mode bits set\n", __func__);
352 return -EINVAL; 362 return -EINVAL;
363 }
353 364
354 mode_initiator = mode & CEC_MODE_INITIATOR_MSK; 365 mode_initiator = mode & CEC_MODE_INITIATOR_MSK;
355 mode_follower = mode & CEC_MODE_FOLLOWER_MSK; 366 mode_follower = mode & CEC_MODE_FOLLOWER_MSK;
356 367
357 if (mode_initiator > CEC_MODE_EXCL_INITIATOR || 368 if (mode_initiator > CEC_MODE_EXCL_INITIATOR ||
358 mode_follower > CEC_MODE_MONITOR_ALL) 369 mode_follower > CEC_MODE_MONITOR_ALL) {
370 dprintk(1, "%s: unknown mode\n", __func__);
359 return -EINVAL; 371 return -EINVAL;
372 }
360 373
361 if (mode_follower == CEC_MODE_MONITOR_ALL && 374 if (mode_follower == CEC_MODE_MONITOR_ALL &&
362 !(adap->capabilities & CEC_CAP_MONITOR_ALL)) 375 !(adap->capabilities & CEC_CAP_MONITOR_ALL)) {
376 dprintk(1, "%s: MONITOR_ALL not supported\n", __func__);
363 return -EINVAL; 377 return -EINVAL;
378 }
379
380 if (mode_follower == CEC_MODE_MONITOR_PIN &&
381 !(adap->capabilities & CEC_CAP_MONITOR_PIN)) {
382 dprintk(1, "%s: MONITOR_PIN not supported\n", __func__);
383 return -EINVAL;
384 }
364 385
365 /* Follower modes should always be able to send CEC messages */ 386 /* Follower modes should always be able to send CEC messages */
366 if ((mode_initiator == CEC_MODE_NO_INITIATOR || 387 if ((mode_initiator == CEC_MODE_NO_INITIATOR ||
367 !(adap->capabilities & CEC_CAP_TRANSMIT)) && 388 !(adap->capabilities & CEC_CAP_TRANSMIT)) &&
368 mode_follower >= CEC_MODE_FOLLOWER && 389 mode_follower >= CEC_MODE_FOLLOWER &&
369 mode_follower <= CEC_MODE_EXCL_FOLLOWER_PASSTHRU) 390 mode_follower <= CEC_MODE_EXCL_FOLLOWER_PASSTHRU) {
391 dprintk(1, "%s: cannot transmit\n", __func__);
370 return -EINVAL; 392 return -EINVAL;
393 }
371 394
372 /* Monitor modes require CEC_MODE_NO_INITIATOR */ 395 /* Monitor modes require CEC_MODE_NO_INITIATOR */
373 if (mode_initiator && mode_follower >= CEC_MODE_MONITOR) 396 if (mode_initiator && mode_follower >= CEC_MODE_MONITOR_PIN) {
397 dprintk(1, "%s: monitor modes require NO_INITIATOR\n",
398 __func__);
374 return -EINVAL; 399 return -EINVAL;
400 }
375 401
376 /* Monitor modes require CAP_NET_ADMIN */ 402 /* Monitor modes require CAP_NET_ADMIN */
377 if (mode_follower >= CEC_MODE_MONITOR && !capable(CAP_NET_ADMIN)) 403 if (mode_follower >= CEC_MODE_MONITOR_PIN && !capable(CAP_NET_ADMIN))
378 return -EPERM; 404 return -EPERM;
379 405
380 mutex_lock(&adap->lock); 406 mutex_lock(&adap->lock);
@@ -413,8 +439,20 @@ static long cec_s_mode(struct cec_adapter *adap, struct cec_fh *fh,
413 439
414 if (fh->mode_follower == CEC_MODE_FOLLOWER) 440 if (fh->mode_follower == CEC_MODE_FOLLOWER)
415 adap->follower_cnt--; 441 adap->follower_cnt--;
442 if (fh->mode_follower == CEC_MODE_MONITOR_PIN)
443 adap->monitor_pin_cnt--;
416 if (mode_follower == CEC_MODE_FOLLOWER) 444 if (mode_follower == CEC_MODE_FOLLOWER)
417 adap->follower_cnt++; 445 adap->follower_cnt++;
446 if (mode_follower == CEC_MODE_MONITOR_PIN) {
447 struct cec_event ev = {
448 .flags = CEC_EVENT_FL_INITIAL_STATE,
449 };
450
451 ev.event = adap->cec_pin_is_high ? CEC_EVENT_PIN_CEC_HIGH :
452 CEC_EVENT_PIN_CEC_LOW;
453 cec_queue_event_fh(fh, &ev, 0);
454 adap->monitor_pin_cnt++;
455 }
418 if (mode_follower == CEC_MODE_EXCL_FOLLOWER || 456 if (mode_follower == CEC_MODE_EXCL_FOLLOWER ||
419 mode_follower == CEC_MODE_EXCL_FOLLOWER_PASSTHRU) { 457 mode_follower == CEC_MODE_EXCL_FOLLOWER_PASSTHRU) {
420 adap->passthrough = 458 adap->passthrough =
@@ -495,6 +533,7 @@ static int cec_open(struct inode *inode, struct file *filp)
495 .event = CEC_EVENT_STATE_CHANGE, 533 .event = CEC_EVENT_STATE_CHANGE,
496 .flags = CEC_EVENT_FL_INITIAL_STATE, 534 .flags = CEC_EVENT_FL_INITIAL_STATE,
497 }; 535 };
536 unsigned int i;
498 int err; 537 int err;
499 538
500 if (!fh) 539 if (!fh)
@@ -502,6 +541,8 @@ static int cec_open(struct inode *inode, struct file *filp)
502 541
503 INIT_LIST_HEAD(&fh->msgs); 542 INIT_LIST_HEAD(&fh->msgs);
504 INIT_LIST_HEAD(&fh->xfer_list); 543 INIT_LIST_HEAD(&fh->xfer_list);
544 for (i = 0; i < CEC_NUM_EVENTS; i++)
545 INIT_LIST_HEAD(&fh->events[i]);
505 mutex_init(&fh->lock); 546 mutex_init(&fh->lock);
506 init_waitqueue_head(&fh->wait); 547 init_waitqueue_head(&fh->wait);
507 548
@@ -544,6 +585,7 @@ static int cec_release(struct inode *inode, struct file *filp)
544 struct cec_devnode *devnode = cec_devnode_data(filp); 585 struct cec_devnode *devnode = cec_devnode_data(filp);
545 struct cec_adapter *adap = to_cec_adapter(devnode); 586 struct cec_adapter *adap = to_cec_adapter(devnode);
546 struct cec_fh *fh = filp->private_data; 587 struct cec_fh *fh = filp->private_data;
588 unsigned int i;
547 589
548 mutex_lock(&adap->lock); 590 mutex_lock(&adap->lock);
549 if (adap->cec_initiator == fh) 591 if (adap->cec_initiator == fh)
@@ -554,6 +596,8 @@ static int cec_release(struct inode *inode, struct file *filp)
554 } 596 }
555 if (fh->mode_follower == CEC_MODE_FOLLOWER) 597 if (fh->mode_follower == CEC_MODE_FOLLOWER)
556 adap->follower_cnt--; 598 adap->follower_cnt--;
599 if (fh->mode_follower == CEC_MODE_MONITOR_PIN)
600 adap->monitor_pin_cnt--;
557 if (fh->mode_follower == CEC_MODE_MONITOR_ALL) 601 if (fh->mode_follower == CEC_MODE_MONITOR_ALL)
558 cec_monitor_all_cnt_dec(adap); 602 cec_monitor_all_cnt_dec(adap);
559 mutex_unlock(&adap->lock); 603 mutex_unlock(&adap->lock);
@@ -585,6 +629,16 @@ static int cec_release(struct inode *inode, struct file *filp)
585 list_del(&entry->list); 629 list_del(&entry->list);
586 kfree(entry); 630 kfree(entry);
587 } 631 }
632 for (i = CEC_NUM_CORE_EVENTS; i < CEC_NUM_EVENTS; i++) {
633 while (!list_empty(&fh->events[i])) {
634 struct cec_event_entry *entry =
635 list_first_entry(&fh->events[i],
636 struct cec_event_entry, list);
637
638 list_del(&entry->list);
639 kfree(entry);
640 }
641 }
588 kfree(fh); 642 kfree(fh);
589 643
590 cec_put_device(devnode); 644 cec_put_device(devnode);
diff --git a/drivers/media/cec/cec-core.c b/drivers/media/cec/cec-core.c
index b516d599d6c4..648136e552d5 100644
--- a/drivers/media/cec/cec-core.c
+++ b/drivers/media/cec/cec-core.c
@@ -227,6 +227,7 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
227 return ERR_PTR(-ENOMEM); 227 return ERR_PTR(-ENOMEM);
228 strlcpy(adap->name, name, sizeof(adap->name)); 228 strlcpy(adap->name, name, sizeof(adap->name));
229 adap->phys_addr = CEC_PHYS_ADDR_INVALID; 229 adap->phys_addr = CEC_PHYS_ADDR_INVALID;
230 adap->cec_pin_is_high = true;
230 adap->log_addrs.cec_version = CEC_OP_CEC_VERSION_2_0; 231 adap->log_addrs.cec_version = CEC_OP_CEC_VERSION_2_0;
231 adap->log_addrs.vendor_id = CEC_VENDOR_ID_NONE; 232 adap->log_addrs.vendor_id = CEC_VENDOR_ID_NONE;
232 adap->capabilities = caps; 233 adap->capabilities = caps;
@@ -263,22 +264,24 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
263 return ERR_PTR(-ENOMEM); 264 return ERR_PTR(-ENOMEM);
264 } 265 }
265 266
266 snprintf(adap->input_name, sizeof(adap->input_name), 267 snprintf(adap->device_name, sizeof(adap->device_name),
267 "RC for %s", name); 268 "RC for %s", name);
268 snprintf(adap->input_phys, sizeof(adap->input_phys), 269 snprintf(adap->input_phys, sizeof(adap->input_phys),
269 "%s/input0", name); 270 "%s/input0", name);
270 271
271 adap->rc->input_name = adap->input_name; 272 adap->rc->device_name = adap->device_name;
272 adap->rc->input_phys = adap->input_phys; 273 adap->rc->input_phys = adap->input_phys;
273 adap->rc->input_id.bustype = BUS_CEC; 274 adap->rc->input_id.bustype = BUS_CEC;
274 adap->rc->input_id.vendor = 0; 275 adap->rc->input_id.vendor = 0;
275 adap->rc->input_id.product = 0; 276 adap->rc->input_id.product = 0;
276 adap->rc->input_id.version = 1; 277 adap->rc->input_id.version = 1;
277 adap->rc->driver_name = CEC_NAME; 278 adap->rc->driver_name = CEC_NAME;
278 adap->rc->allowed_protocols = RC_BIT_CEC; 279 adap->rc->allowed_protocols = RC_PROTO_BIT_CEC;
280 adap->rc->enabled_protocols = RC_PROTO_BIT_CEC;
279 adap->rc->priv = adap; 281 adap->rc->priv = adap;
280 adap->rc->map_name = RC_MAP_CEC; 282 adap->rc->map_name = RC_MAP_CEC;
281 adap->rc->timeout = MS_TO_NS(100); 283 adap->rc->timeout = MS_TO_NS(100);
284 adap->rc_last_scancode = -1;
282#endif 285#endif
283 return adap; 286 return adap;
284} 287}
@@ -310,6 +313,17 @@ int cec_register_adapter(struct cec_adapter *adap,
310 adap->rc = NULL; 313 adap->rc = NULL;
311 return res; 314 return res;
312 } 315 }
316 /*
317 * The REP_DELAY for CEC is really the time between the initial
318 * 'User Control Pressed' message and the second. The first
319 * keypress is always seen as non-repeating, the second
320 * (provided it has the same UI Command) will start the 'Press
321 * and Hold' (aka repeat) behavior. By setting REP_DELAY to the
322 * same value as REP_PERIOD the expected CEC behavior is
323 * reproduced.
324 */
325 adap->rc->input_dev->rep[REP_DELAY] =
326 adap->rc->input_dev->rep[REP_PERIOD];
313 } 327 }
314#endif 328#endif
315 329
@@ -374,6 +388,8 @@ void cec_delete_adapter(struct cec_adapter *adap)
374 kthread_stop(adap->kthread); 388 kthread_stop(adap->kthread);
375 if (adap->kthread_config) 389 if (adap->kthread_config)
376 kthread_stop(adap->kthread_config); 390 kthread_stop(adap->kthread_config);
391 if (adap->ops->adap_free)
392 adap->ops->adap_free(adap);
377#ifdef CONFIG_MEDIA_CEC_RC 393#ifdef CONFIG_MEDIA_CEC_RC
378 rc_free_device(adap->rc); 394 rc_free_device(adap->rc);
379#endif 395#endif
@@ -386,11 +402,8 @@ EXPORT_SYMBOL_GPL(cec_delete_adapter);
386 */ 402 */
387static int __init cec_devnode_init(void) 403static int __init cec_devnode_init(void)
388{ 404{
389 int ret; 405 int ret = alloc_chrdev_region(&cec_dev_t, 0, CEC_NUM_DEVICES, CEC_NAME);
390 406
391 pr_info("Linux cec interface: v0.10\n");
392 ret = alloc_chrdev_region(&cec_dev_t, 0, CEC_NUM_DEVICES,
393 CEC_NAME);
394 if (ret < 0) { 407 if (ret < 0) {
395 pr_warn("cec: unable to allocate major\n"); 408 pr_warn("cec: unable to allocate major\n");
396 return ret; 409 return ret;
diff --git a/drivers/media/cec/cec-pin.c b/drivers/media/cec/cec-pin.c
new file mode 100644
index 000000000000..c003b8eac617
--- /dev/null
+++ b/drivers/media/cec/cec-pin.c
@@ -0,0 +1,802 @@
1/*
2 * Copyright 2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
3 *
4 * This program is free software; you may redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15 * SOFTWARE.
16 */
17
18#include <linux/delay.h>
19#include <linux/slab.h>
20#include <linux/sched/types.h>
21
22#include <media/cec-pin.h>
23
24/* All timings are in microseconds */
25
26/* start bit timings */
27#define CEC_TIM_START_BIT_LOW 3700
28#define CEC_TIM_START_BIT_LOW_MIN 3500
29#define CEC_TIM_START_BIT_LOW_MAX 3900
30#define CEC_TIM_START_BIT_TOTAL 4500
31#define CEC_TIM_START_BIT_TOTAL_MIN 4300
32#define CEC_TIM_START_BIT_TOTAL_MAX 4700
33
34/* data bit timings */
35#define CEC_TIM_DATA_BIT_0_LOW 1500
36#define CEC_TIM_DATA_BIT_0_LOW_MIN 1300
37#define CEC_TIM_DATA_BIT_0_LOW_MAX 1700
38#define CEC_TIM_DATA_BIT_1_LOW 600
39#define CEC_TIM_DATA_BIT_1_LOW_MIN 400
40#define CEC_TIM_DATA_BIT_1_LOW_MAX 800
41#define CEC_TIM_DATA_BIT_TOTAL 2400
42#define CEC_TIM_DATA_BIT_TOTAL_MIN 2050
43#define CEC_TIM_DATA_BIT_TOTAL_MAX 2750
44/* earliest safe time to sample the bit state */
45#define CEC_TIM_DATA_BIT_SAMPLE 850
46/* earliest time the bit is back to 1 (T7 + 50) */
47#define CEC_TIM_DATA_BIT_HIGH 1750
48
49/* when idle, sample once per millisecond */
50#define CEC_TIM_IDLE_SAMPLE 1000
51/* when processing the start bit, sample twice per millisecond */
52#define CEC_TIM_START_BIT_SAMPLE 500
53/* when polling for a state change, sample once every 50 micoseconds */
54#define CEC_TIM_SAMPLE 50
55
56#define CEC_TIM_LOW_DRIVE_ERROR (1.5 * CEC_TIM_DATA_BIT_TOTAL)
57
58struct cec_state {
59 const char * const name;
60 unsigned int usecs;
61};
62
63static const struct cec_state states[CEC_PIN_STATES] = {
64 { "Off", 0 },
65 { "Idle", CEC_TIM_IDLE_SAMPLE },
66 { "Tx Wait", CEC_TIM_SAMPLE },
67 { "Tx Wait for High", CEC_TIM_IDLE_SAMPLE },
68 { "Tx Start Bit Low", CEC_TIM_START_BIT_LOW },
69 { "Tx Start Bit High", CEC_TIM_START_BIT_TOTAL - CEC_TIM_START_BIT_LOW },
70 { "Tx Data 0 Low", CEC_TIM_DATA_BIT_0_LOW },
71 { "Tx Data 0 High", CEC_TIM_DATA_BIT_TOTAL - CEC_TIM_DATA_BIT_0_LOW },
72 { "Tx Data 1 Low", CEC_TIM_DATA_BIT_1_LOW },
73 { "Tx Data 1 High", CEC_TIM_DATA_BIT_TOTAL - CEC_TIM_DATA_BIT_1_LOW },
74 { "Tx Data 1 Pre Sample", CEC_TIM_DATA_BIT_SAMPLE - CEC_TIM_DATA_BIT_1_LOW },
75 { "Tx Data 1 Post Sample", CEC_TIM_DATA_BIT_TOTAL - CEC_TIM_DATA_BIT_SAMPLE },
76 { "Rx Start Bit Low", CEC_TIM_SAMPLE },
77 { "Rx Start Bit High", CEC_TIM_SAMPLE },
78 { "Rx Data Sample", CEC_TIM_DATA_BIT_SAMPLE },
79 { "Rx Data Post Sample", CEC_TIM_DATA_BIT_HIGH - CEC_TIM_DATA_BIT_SAMPLE },
80 { "Rx Data High", CEC_TIM_SAMPLE },
81 { "Rx Ack Low", CEC_TIM_DATA_BIT_0_LOW },
82 { "Rx Ack Low Post", CEC_TIM_DATA_BIT_HIGH - CEC_TIM_DATA_BIT_0_LOW },
83 { "Rx Ack High Post", CEC_TIM_DATA_BIT_HIGH },
84 { "Rx Ack Finish", CEC_TIM_DATA_BIT_TOTAL_MIN - CEC_TIM_DATA_BIT_HIGH },
85 { "Rx Low Drive", CEC_TIM_LOW_DRIVE_ERROR },
86 { "Rx Irq", 0 },
87};
88
89static void cec_pin_update(struct cec_pin *pin, bool v, bool force)
90{
91 if (!force && v == pin->adap->cec_pin_is_high)
92 return;
93
94 pin->adap->cec_pin_is_high = v;
95 if (atomic_read(&pin->work_pin_events) < CEC_NUM_PIN_EVENTS) {
96 pin->work_pin_is_high[pin->work_pin_events_wr] = v;
97 pin->work_pin_ts[pin->work_pin_events_wr] = ktime_get();
98 pin->work_pin_events_wr =
99 (pin->work_pin_events_wr + 1) % CEC_NUM_PIN_EVENTS;
100 atomic_inc(&pin->work_pin_events);
101 }
102 wake_up_interruptible(&pin->kthread_waitq);
103}
104
105static bool cec_pin_read(struct cec_pin *pin)
106{
107 bool v = pin->ops->read(pin->adap);
108
109 cec_pin_update(pin, v, false);
110 return v;
111}
112
113static void cec_pin_low(struct cec_pin *pin)
114{
115 pin->ops->low(pin->adap);
116 cec_pin_update(pin, false, false);
117}
118
119static bool cec_pin_high(struct cec_pin *pin)
120{
121 pin->ops->high(pin->adap);
122 return cec_pin_read(pin);
123}
124
125static void cec_pin_to_idle(struct cec_pin *pin)
126{
127 /*
128 * Reset all status fields, release the bus and
129 * go to idle state.
130 */
131 pin->rx_bit = pin->tx_bit = 0;
132 pin->rx_msg.len = 0;
133 memset(pin->rx_msg.msg, 0, sizeof(pin->rx_msg.msg));
134 pin->state = CEC_ST_IDLE;
135 pin->ts = 0;
136}
137
138/*
139 * Handle Transmit-related states
140 *
141 * Basic state changes when transmitting:
142 *
143 * Idle -> Tx Wait (waiting for the end of signal free time) ->
144 * Tx Start Bit Low -> Tx Start Bit High ->
145 *
146 * Regular data bits + EOM:
147 * Tx Data 0 Low -> Tx Data 0 High ->
148 * or:
149 * Tx Data 1 Low -> Tx Data 1 High ->
150 *
151 * First 4 data bits or Ack bit:
152 * Tx Data 0 Low -> Tx Data 0 High ->
153 * or:
154 * Tx Data 1 Low -> Tx Data 1 High -> Tx Data 1 Pre Sample ->
155 * Tx Data 1 Post Sample ->
156 *
157 * After the last Ack go to Idle.
158 *
159 * If it detects a Low Drive condition then:
160 * Tx Wait For High -> Idle
161 *
162 * If it loses arbitration, then it switches to state Rx Data Post Sample.
163 */
164static void cec_pin_tx_states(struct cec_pin *pin, ktime_t ts)
165{
166 bool v;
167 bool is_ack_bit, ack;
168
169 switch (pin->state) {
170 case CEC_ST_TX_WAIT_FOR_HIGH:
171 if (cec_pin_read(pin))
172 cec_pin_to_idle(pin);
173 break;
174
175 case CEC_ST_TX_START_BIT_LOW:
176 pin->state = CEC_ST_TX_START_BIT_HIGH;
177 /* Generate start bit */
178 cec_pin_high(pin);
179 break;
180
181 case CEC_ST_TX_DATA_BIT_1_HIGH_POST_SAMPLE:
182 /* If the read value is 1, then all is OK */
183 if (!cec_pin_read(pin)) {
184 /*
185 * It's 0, so someone detected an error and pulled the
186 * line low for 1.5 times the nominal bit period.
187 */
188 pin->tx_msg.len = 0;
189 pin->work_tx_ts = ts;
190 pin->work_tx_status = CEC_TX_STATUS_LOW_DRIVE;
191 pin->state = CEC_ST_TX_WAIT_FOR_HIGH;
192 wake_up_interruptible(&pin->kthread_waitq);
193 break;
194 }
195 if (pin->tx_nacked) {
196 cec_pin_to_idle(pin);
197 pin->tx_msg.len = 0;
198 pin->work_tx_ts = ts;
199 pin->work_tx_status = CEC_TX_STATUS_NACK;
200 wake_up_interruptible(&pin->kthread_waitq);
201 break;
202 }
203 /* fall through */
204 case CEC_ST_TX_DATA_BIT_0_HIGH:
205 case CEC_ST_TX_DATA_BIT_1_HIGH:
206 pin->tx_bit++;
207 /* fall through */
208 case CEC_ST_TX_START_BIT_HIGH:
209 if (pin->tx_bit / 10 >= pin->tx_msg.len) {
210 cec_pin_to_idle(pin);
211 pin->tx_msg.len = 0;
212 pin->work_tx_ts = ts;
213 pin->work_tx_status = CEC_TX_STATUS_OK;
214 wake_up_interruptible(&pin->kthread_waitq);
215 break;
216 }
217
218 switch (pin->tx_bit % 10) {
219 default:
220 v = pin->tx_msg.msg[pin->tx_bit / 10] &
221 (1 << (7 - (pin->tx_bit % 10)));
222 pin->state = v ? CEC_ST_TX_DATA_BIT_1_LOW :
223 CEC_ST_TX_DATA_BIT_0_LOW;
224 break;
225 case 8:
226 v = pin->tx_bit / 10 == pin->tx_msg.len - 1;
227 pin->state = v ? CEC_ST_TX_DATA_BIT_1_LOW :
228 CEC_ST_TX_DATA_BIT_0_LOW;
229 break;
230 case 9:
231 pin->state = CEC_ST_TX_DATA_BIT_1_LOW;
232 break;
233 }
234 cec_pin_low(pin);
235 break;
236
237 case CEC_ST_TX_DATA_BIT_0_LOW:
238 case CEC_ST_TX_DATA_BIT_1_LOW:
239 v = pin->state == CEC_ST_TX_DATA_BIT_1_LOW;
240 pin->state = v ? CEC_ST_TX_DATA_BIT_1_HIGH :
241 CEC_ST_TX_DATA_BIT_0_HIGH;
242 is_ack_bit = pin->tx_bit % 10 == 9;
243 if (v && (pin->tx_bit < 4 || is_ack_bit))
244 pin->state = CEC_ST_TX_DATA_BIT_1_HIGH_PRE_SAMPLE;
245 cec_pin_high(pin);
246 break;
247
248 case CEC_ST_TX_DATA_BIT_1_HIGH_PRE_SAMPLE:
249 /* Read the CEC value at the sample time */
250 v = cec_pin_read(pin);
251 is_ack_bit = pin->tx_bit % 10 == 9;
252 /*
253 * If v == 0 and we're within the first 4 bits
254 * of the initiator, then someone else started
255 * transmitting and we lost the arbitration
256 * (i.e. the logical address of the other
257 * transmitter has more leading 0 bits in the
258 * initiator).
259 */
260 if (!v && !is_ack_bit) {
261 pin->tx_msg.len = 0;
262 pin->work_tx_ts = ts;
263 pin->work_tx_status = CEC_TX_STATUS_ARB_LOST;
264 wake_up_interruptible(&pin->kthread_waitq);
265 pin->rx_bit = pin->tx_bit;
266 pin->tx_bit = 0;
267 memset(pin->rx_msg.msg, 0, sizeof(pin->rx_msg.msg));
268 pin->rx_msg.msg[0] = pin->tx_msg.msg[0];
269 pin->rx_msg.msg[0] &= ~(1 << (7 - pin->rx_bit));
270 pin->rx_msg.len = 0;
271 pin->state = CEC_ST_RX_DATA_POST_SAMPLE;
272 pin->rx_bit++;
273 break;
274 }
275 pin->state = CEC_ST_TX_DATA_BIT_1_HIGH_POST_SAMPLE;
276 if (!is_ack_bit)
277 break;
278 /* Was the message ACKed? */
279 ack = cec_msg_is_broadcast(&pin->tx_msg) ? v : !v;
280 if (!ack) {
281 /*
282 * Note: the CEC spec is ambiguous regarding
283 * what action to take when a NACK appears
284 * before the last byte of the payload was
285 * transmitted: either stop transmitting
286 * immediately, or wait until the last byte
287 * was transmitted.
288 *
289 * Most CEC implementations appear to stop
290 * immediately, and that's what we do here
291 * as well.
292 */
293 pin->tx_nacked = true;
294 }
295 break;
296
297 default:
298 break;
299 }
300}
301
302/*
303 * Handle Receive-related states
304 *
305 * Basic state changes when receiving:
306 *
307 * Rx Start Bit Low -> Rx Start Bit High ->
308 * Regular data bits + EOM:
309 * Rx Data Sample -> Rx Data Post Sample -> Rx Data High ->
310 * Ack bit 0:
311 * Rx Ack Low -> Rx Ack Low Post -> Rx Data High ->
312 * Ack bit 1:
313 * Rx Ack High Post -> Rx Data High ->
314 * Ack bit 0 && EOM:
315 * Rx Ack Low -> Rx Ack Low Post -> Rx Ack Finish -> Idle
316 */
317static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts)
318{
319 s32 delta;
320 bool v;
321 bool ack;
322 bool bcast, for_us;
323 u8 dest;
324
325 switch (pin->state) {
326 /* Receive states */
327 case CEC_ST_RX_START_BIT_LOW:
328 v = cec_pin_read(pin);
329 if (!v)
330 break;
331 pin->state = CEC_ST_RX_START_BIT_HIGH;
332 delta = ktime_us_delta(ts, pin->ts);
333 pin->ts = ts;
334 /* Start bit low is too short, go back to idle */
335 if (delta < CEC_TIM_START_BIT_LOW_MIN -
336 CEC_TIM_IDLE_SAMPLE) {
337 cec_pin_to_idle(pin);
338 }
339 break;
340
341 case CEC_ST_RX_START_BIT_HIGH:
342 v = cec_pin_read(pin);
343 delta = ktime_us_delta(ts, pin->ts);
344 if (v && delta > CEC_TIM_START_BIT_TOTAL_MAX -
345 CEC_TIM_START_BIT_LOW_MIN) {
346 cec_pin_to_idle(pin);
347 break;
348 }
349 if (v)
350 break;
351 pin->state = CEC_ST_RX_DATA_SAMPLE;
352 pin->ts = ts;
353 pin->rx_eom = false;
354 break;
355
356 case CEC_ST_RX_DATA_SAMPLE:
357 v = cec_pin_read(pin);
358 pin->state = CEC_ST_RX_DATA_POST_SAMPLE;
359 switch (pin->rx_bit % 10) {
360 default:
361 if (pin->rx_bit / 10 < CEC_MAX_MSG_SIZE)
362 pin->rx_msg.msg[pin->rx_bit / 10] |=
363 v << (7 - (pin->rx_bit % 10));
364 break;
365 case 8:
366 pin->rx_eom = v;
367 pin->rx_msg.len = pin->rx_bit / 10 + 1;
368 break;
369 case 9:
370 break;
371 }
372 pin->rx_bit++;
373 break;
374
375 case CEC_ST_RX_DATA_POST_SAMPLE:
376 pin->state = CEC_ST_RX_DATA_HIGH;
377 break;
378
379 case CEC_ST_RX_DATA_HIGH:
380 v = cec_pin_read(pin);
381 delta = ktime_us_delta(ts, pin->ts);
382 if (v && delta > CEC_TIM_DATA_BIT_TOTAL_MAX) {
383 cec_pin_to_idle(pin);
384 break;
385 }
386 if (v)
387 break;
388 /*
389 * Go to low drive state when the total bit time is
390 * too short.
391 */
392 if (delta < CEC_TIM_DATA_BIT_TOTAL_MIN) {
393 cec_pin_low(pin);
394 pin->state = CEC_ST_LOW_DRIVE;
395 break;
396 }
397 pin->ts = ts;
398 if (pin->rx_bit % 10 != 9) {
399 pin->state = CEC_ST_RX_DATA_SAMPLE;
400 break;
401 }
402
403 dest = cec_msg_destination(&pin->rx_msg);
404 bcast = dest == CEC_LOG_ADDR_BROADCAST;
405 /* for_us == broadcast or directed to us */
406 for_us = bcast || (pin->la_mask & (1 << dest));
407 /* ACK bit value */
408 ack = bcast ? 1 : !for_us;
409
410 if (ack) {
411 /* No need to write to the bus, just wait */
412 pin->state = CEC_ST_RX_ACK_HIGH_POST;
413 break;
414 }
415 cec_pin_low(pin);
416 pin->state = CEC_ST_RX_ACK_LOW;
417 break;
418
419 case CEC_ST_RX_ACK_LOW:
420 cec_pin_high(pin);
421 pin->state = CEC_ST_RX_ACK_LOW_POST;
422 break;
423
424 case CEC_ST_RX_ACK_LOW_POST:
425 case CEC_ST_RX_ACK_HIGH_POST:
426 v = cec_pin_read(pin);
427 if (v && pin->rx_eom) {
428 pin->work_rx_msg = pin->rx_msg;
429 pin->work_rx_msg.rx_ts = ts;
430 wake_up_interruptible(&pin->kthread_waitq);
431 pin->ts = ts;
432 pin->state = CEC_ST_RX_ACK_FINISH;
433 break;
434 }
435 pin->rx_bit++;
436 pin->state = CEC_ST_RX_DATA_HIGH;
437 break;
438
439 case CEC_ST_RX_ACK_FINISH:
440 cec_pin_to_idle(pin);
441 break;
442
443 default:
444 break;
445 }
446}
447
448/*
449 * Main timer function
450 *
451 */
452static enum hrtimer_restart cec_pin_timer(struct hrtimer *timer)
453{
454 struct cec_pin *pin = container_of(timer, struct cec_pin, timer);
455 struct cec_adapter *adap = pin->adap;
456 ktime_t ts;
457 s32 delta;
458
459 ts = ktime_get();
460 if (pin->timer_ts) {
461 delta = ktime_us_delta(ts, pin->timer_ts);
462 pin->timer_cnt++;
463 if (delta > 100 && pin->state != CEC_ST_IDLE) {
464 /* Keep track of timer overruns */
465 pin->timer_sum_overrun += delta;
466 pin->timer_100ms_overruns++;
467 if (delta > 300)
468 pin->timer_300ms_overruns++;
469 if (delta > pin->timer_max_overrun)
470 pin->timer_max_overrun = delta;
471 }
472 }
473 if (adap->monitor_pin_cnt)
474 cec_pin_read(pin);
475
476 if (pin->wait_usecs) {
477 /*
478 * If we are monitoring the pin, then we have to
479 * sample at regular intervals.
480 */
481 if (pin->wait_usecs > 150) {
482 pin->wait_usecs -= 100;
483 pin->timer_ts = ktime_add_us(ts, 100);
484 hrtimer_forward_now(timer, 100000);
485 return HRTIMER_RESTART;
486 }
487 if (pin->wait_usecs > 100) {
488 pin->wait_usecs /= 2;
489 pin->timer_ts = ktime_add_us(ts, pin->wait_usecs);
490 hrtimer_forward_now(timer, pin->wait_usecs * 1000);
491 return HRTIMER_RESTART;
492 }
493 pin->timer_ts = ktime_add_us(ts, pin->wait_usecs);
494 hrtimer_forward_now(timer, pin->wait_usecs * 1000);
495 pin->wait_usecs = 0;
496 return HRTIMER_RESTART;
497 }
498
499 switch (pin->state) {
500 /* Transmit states */
501 case CEC_ST_TX_WAIT_FOR_HIGH:
502 case CEC_ST_TX_START_BIT_LOW:
503 case CEC_ST_TX_DATA_BIT_1_HIGH_POST_SAMPLE:
504 case CEC_ST_TX_DATA_BIT_0_HIGH:
505 case CEC_ST_TX_DATA_BIT_1_HIGH:
506 case CEC_ST_TX_START_BIT_HIGH:
507 case CEC_ST_TX_DATA_BIT_0_LOW:
508 case CEC_ST_TX_DATA_BIT_1_LOW:
509 case CEC_ST_TX_DATA_BIT_1_HIGH_PRE_SAMPLE:
510 cec_pin_tx_states(pin, ts);
511 break;
512
513 /* Receive states */
514 case CEC_ST_RX_START_BIT_LOW:
515 case CEC_ST_RX_START_BIT_HIGH:
516 case CEC_ST_RX_DATA_SAMPLE:
517 case CEC_ST_RX_DATA_POST_SAMPLE:
518 case CEC_ST_RX_DATA_HIGH:
519 case CEC_ST_RX_ACK_LOW:
520 case CEC_ST_RX_ACK_LOW_POST:
521 case CEC_ST_RX_ACK_HIGH_POST:
522 case CEC_ST_RX_ACK_FINISH:
523 cec_pin_rx_states(pin, ts);
524 break;
525
526 case CEC_ST_IDLE:
527 case CEC_ST_TX_WAIT:
528 if (!cec_pin_high(pin)) {
529 /* Start bit, switch to receive state */
530 pin->ts = ts;
531 pin->state = CEC_ST_RX_START_BIT_LOW;
532 break;
533 }
534 if (pin->ts == 0)
535 pin->ts = ts;
536 if (pin->tx_msg.len) {
537 /*
538 * Check if the bus has been free for long enough
539 * so we can kick off the pending transmit.
540 */
541 delta = ktime_us_delta(ts, pin->ts);
542 if (delta / CEC_TIM_DATA_BIT_TOTAL >
543 pin->tx_signal_free_time) {
544 pin->tx_nacked = false;
545 pin->state = CEC_ST_TX_START_BIT_LOW;
546 /* Generate start bit */
547 cec_pin_low(pin);
548 break;
549 }
550 if (delta / CEC_TIM_DATA_BIT_TOTAL >
551 pin->tx_signal_free_time - 1)
552 pin->state = CEC_ST_TX_WAIT;
553 break;
554 }
555 if (pin->state != CEC_ST_IDLE || pin->ops->enable_irq == NULL ||
556 pin->enable_irq_failed || adap->is_configuring ||
557 adap->is_configured || adap->monitor_all_cnt)
558 break;
559 /* Switch to interrupt mode */
560 atomic_set(&pin->work_irq_change, CEC_PIN_IRQ_ENABLE);
561 pin->state = CEC_ST_RX_IRQ;
562 wake_up_interruptible(&pin->kthread_waitq);
563 return HRTIMER_NORESTART;
564
565 case CEC_ST_LOW_DRIVE:
566 cec_pin_to_idle(pin);
567 break;
568
569 default:
570 break;
571 }
572 if (!adap->monitor_pin_cnt || states[pin->state].usecs <= 150) {
573 pin->wait_usecs = 0;
574 pin->timer_ts = ktime_add_us(ts, states[pin->state].usecs);
575 hrtimer_forward_now(timer, states[pin->state].usecs * 1000);
576 return HRTIMER_RESTART;
577 }
578 pin->wait_usecs = states[pin->state].usecs - 100;
579 pin->timer_ts = ktime_add_us(ts, 100);
580 hrtimer_forward_now(timer, 100000);
581 return HRTIMER_RESTART;
582}
583
584static int cec_pin_thread_func(void *_adap)
585{
586 struct cec_adapter *adap = _adap;
587 struct cec_pin *pin = adap->pin;
588
589 for (;;) {
590 wait_event_interruptible(pin->kthread_waitq,
591 kthread_should_stop() ||
592 pin->work_rx_msg.len ||
593 pin->work_tx_status ||
594 atomic_read(&pin->work_irq_change) ||
595 atomic_read(&pin->work_pin_events));
596
597 if (pin->work_rx_msg.len) {
598 cec_received_msg_ts(adap, &pin->work_rx_msg,
599 pin->work_rx_msg.rx_ts);
600 pin->work_rx_msg.len = 0;
601 }
602 if (pin->work_tx_status) {
603 unsigned int tx_status = pin->work_tx_status;
604
605 pin->work_tx_status = 0;
606 cec_transmit_attempt_done_ts(adap, tx_status,
607 pin->work_tx_ts);
608 }
609
610 while (atomic_read(&pin->work_pin_events)) {
611 unsigned int idx = pin->work_pin_events_rd;
612
613 cec_queue_pin_cec_event(adap,
614 pin->work_pin_is_high[idx],
615 pin->work_pin_ts[idx]);
616 pin->work_pin_events_rd = (idx + 1) % CEC_NUM_PIN_EVENTS;
617 atomic_dec(&pin->work_pin_events);
618 }
619
620 switch (atomic_xchg(&pin->work_irq_change,
621 CEC_PIN_IRQ_UNCHANGED)) {
622 case CEC_PIN_IRQ_DISABLE:
623 pin->ops->disable_irq(adap);
624 cec_pin_high(pin);
625 cec_pin_to_idle(pin);
626 hrtimer_start(&pin->timer, 0, HRTIMER_MODE_REL);
627 break;
628 case CEC_PIN_IRQ_ENABLE:
629 pin->enable_irq_failed = !pin->ops->enable_irq(adap);
630 if (pin->enable_irq_failed) {
631 cec_pin_to_idle(pin);
632 hrtimer_start(&pin->timer, 0, HRTIMER_MODE_REL);
633 }
634 break;
635 default:
636 break;
637 }
638
639 if (kthread_should_stop())
640 break;
641 }
642 return 0;
643}
644
645static int cec_pin_adap_enable(struct cec_adapter *adap, bool enable)
646{
647 struct cec_pin *pin = adap->pin;
648
649 pin->enabled = enable;
650 if (enable) {
651 atomic_set(&pin->work_pin_events, 0);
652 pin->work_pin_events_rd = pin->work_pin_events_wr = 0;
653 cec_pin_read(pin);
654 cec_pin_to_idle(pin);
655 pin->tx_msg.len = 0;
656 pin->timer_ts = 0;
657 atomic_set(&pin->work_irq_change, CEC_PIN_IRQ_UNCHANGED);
658 pin->kthread = kthread_run(cec_pin_thread_func, adap,
659 "cec-pin");
660 if (IS_ERR(pin->kthread)) {
661 pr_err("cec-pin: kernel_thread() failed\n");
662 return PTR_ERR(pin->kthread);
663 }
664 hrtimer_start(&pin->timer, 0, HRTIMER_MODE_REL);
665 } else {
666 if (pin->ops->disable_irq)
667 pin->ops->disable_irq(adap);
668 hrtimer_cancel(&pin->timer);
669 kthread_stop(pin->kthread);
670 cec_pin_read(pin);
671 cec_pin_to_idle(pin);
672 pin->state = CEC_ST_OFF;
673 }
674 return 0;
675}
676
677static int cec_pin_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
678{
679 struct cec_pin *pin = adap->pin;
680
681 if (log_addr == CEC_LOG_ADDR_INVALID)
682 pin->la_mask = 0;
683 else
684 pin->la_mask |= (1 << log_addr);
685 return 0;
686}
687
688static int cec_pin_adap_transmit(struct cec_adapter *adap, u8 attempts,
689 u32 signal_free_time, struct cec_msg *msg)
690{
691 struct cec_pin *pin = adap->pin;
692
693 pin->tx_signal_free_time = signal_free_time;
694 pin->tx_msg = *msg;
695 pin->work_tx_status = 0;
696 pin->tx_bit = 0;
697 if (pin->state == CEC_ST_RX_IRQ) {
698 atomic_set(&pin->work_irq_change, CEC_PIN_IRQ_UNCHANGED);
699 pin->ops->disable_irq(adap);
700 cec_pin_high(pin);
701 cec_pin_to_idle(pin);
702 hrtimer_start(&pin->timer, 0, HRTIMER_MODE_REL);
703 }
704 return 0;
705}
706
707static void cec_pin_adap_status(struct cec_adapter *adap,
708 struct seq_file *file)
709{
710 struct cec_pin *pin = adap->pin;
711
712 seq_printf(file, "state: %s\n", states[pin->state].name);
713 seq_printf(file, "tx_bit: %d\n", pin->tx_bit);
714 seq_printf(file, "rx_bit: %d\n", pin->rx_bit);
715 seq_printf(file, "cec pin: %d\n", pin->ops->read(adap));
716 seq_printf(file, "irq failed: %d\n", pin->enable_irq_failed);
717 if (pin->timer_100ms_overruns) {
718 seq_printf(file, "timer overruns > 100ms: %u of %u\n",
719 pin->timer_100ms_overruns, pin->timer_cnt);
720 seq_printf(file, "timer overruns > 300ms: %u of %u\n",
721 pin->timer_300ms_overruns, pin->timer_cnt);
722 seq_printf(file, "max timer overrun: %u usecs\n",
723 pin->timer_max_overrun);
724 seq_printf(file, "avg timer overrun: %u usecs\n",
725 pin->timer_sum_overrun / pin->timer_100ms_overruns);
726 }
727 pin->timer_cnt = 0;
728 pin->timer_100ms_overruns = 0;
729 pin->timer_300ms_overruns = 0;
730 pin->timer_max_overrun = 0;
731 pin->timer_sum_overrun = 0;
732 if (pin->ops->status)
733 pin->ops->status(adap, file);
734}
735
736static int cec_pin_adap_monitor_all_enable(struct cec_adapter *adap,
737 bool enable)
738{
739 struct cec_pin *pin = adap->pin;
740
741 pin->monitor_all = enable;
742 return 0;
743}
744
745static void cec_pin_adap_free(struct cec_adapter *adap)
746{
747 struct cec_pin *pin = adap->pin;
748
749 if (pin->ops->free)
750 pin->ops->free(adap);
751 adap->pin = NULL;
752 kfree(pin);
753}
754
755void cec_pin_changed(struct cec_adapter *adap, bool value)
756{
757 struct cec_pin *pin = adap->pin;
758
759 cec_pin_update(pin, value, false);
760 if (!value && (adap->is_configuring || adap->is_configured ||
761 adap->monitor_all_cnt))
762 atomic_set(&pin->work_irq_change, CEC_PIN_IRQ_DISABLE);
763}
764EXPORT_SYMBOL_GPL(cec_pin_changed);
765
766static const struct cec_adap_ops cec_pin_adap_ops = {
767 .adap_enable = cec_pin_adap_enable,
768 .adap_monitor_all_enable = cec_pin_adap_monitor_all_enable,
769 .adap_log_addr = cec_pin_adap_log_addr,
770 .adap_transmit = cec_pin_adap_transmit,
771 .adap_status = cec_pin_adap_status,
772 .adap_free = cec_pin_adap_free,
773};
774
775struct cec_adapter *cec_pin_allocate_adapter(const struct cec_pin_ops *pin_ops,
776 void *priv, const char *name, u32 caps)
777{
778 struct cec_adapter *adap;
779 struct cec_pin *pin = kzalloc(sizeof(*pin), GFP_KERNEL);
780
781 if (pin == NULL)
782 return ERR_PTR(-ENOMEM);
783 pin->ops = pin_ops;
784 hrtimer_init(&pin->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
785 pin->timer.function = cec_pin_timer;
786 init_waitqueue_head(&pin->kthread_waitq);
787
788 adap = cec_allocate_adapter(&cec_pin_adap_ops, priv, name,
789 caps | CEC_CAP_MONITOR_ALL | CEC_CAP_MONITOR_PIN,
790 CEC_MAX_LOG_ADDRS);
791
792 if (PTR_ERR_OR_ZERO(adap)) {
793 kfree(pin);
794 return adap;
795 }
796
797 adap->pin = pin;
798 pin->adap = adap;
799 cec_pin_update(pin, cec_pin_high(pin), true);
800 return adap;
801}
802EXPORT_SYMBOL_GPL(cec_pin_allocate_adapter);
diff --git a/drivers/media/common/saa7146/saa7146_i2c.c b/drivers/media/common/saa7146/saa7146_i2c.c
index 239a2db35068..75897f95e4b4 100644
--- a/drivers/media/common/saa7146/saa7146_i2c.c
+++ b/drivers/media/common/saa7146/saa7146_i2c.c
@@ -395,7 +395,7 @@ static int saa7146_i2c_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, in
395/* i2c-adapter helper functions */ 395/* i2c-adapter helper functions */
396 396
397/* exported algorithm data */ 397/* exported algorithm data */
398static struct i2c_algorithm saa7146_algo = { 398static const struct i2c_algorithm saa7146_algo = {
399 .master_xfer = saa7146_i2c_xfer, 399 .master_xfer = saa7146_i2c_xfer,
400 .functionality = saa7146_i2c_func, 400 .functionality = saa7146_i2c_func,
401}; 401};
diff --git a/drivers/media/common/saa7146/saa7146_vbi.c b/drivers/media/common/saa7146/saa7146_vbi.c
index 3553ac4cba5c..d79e4d7ecd9f 100644
--- a/drivers/media/common/saa7146/saa7146_vbi.c
+++ b/drivers/media/common/saa7146/saa7146_vbi.c
@@ -308,7 +308,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
308 saa7146_dma_free(dev,q,buf); 308 saa7146_dma_free(dev,q,buf);
309} 309}
310 310
311static struct videobuf_queue_ops vbi_qops = { 311static const struct videobuf_queue_ops vbi_qops = {
312 .buf_setup = buffer_setup, 312 .buf_setup = buffer_setup,
313 .buf_prepare = buffer_prepare, 313 .buf_prepare = buffer_prepare,
314 .buf_queue = buffer_queue, 314 .buf_queue = buffer_queue,
diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c
index b3b29d4f36ed..37b4654dc21c 100644
--- a/drivers/media/common/saa7146/saa7146_video.c
+++ b/drivers/media/common/saa7146/saa7146_video.c
@@ -1187,7 +1187,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
1187 release_all_pagetables(dev, buf); 1187 release_all_pagetables(dev, buf);
1188} 1188}
1189 1189
1190static struct videobuf_queue_ops video_qops = { 1190static const struct videobuf_queue_ops video_qops = {
1191 .buf_setup = buffer_setup, 1191 .buf_setup = buffer_setup,
1192 .buf_prepare = buffer_prepare, 1192 .buf_prepare = buffer_prepare,
1193 .buf_queue = buffer_queue, 1193 .buf_queue = buffer_queue,
diff --git a/drivers/media/common/siano/smsir.c b/drivers/media/common/siano/smsir.c
index 7c898b06d85c..e77bb0c95e69 100644
--- a/drivers/media/common/siano/smsir.c
+++ b/drivers/media/common/siano/smsir.c
@@ -73,7 +73,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
73 strlcpy(coredev->ir.phys, coredev->devpath, sizeof(coredev->ir.phys)); 73 strlcpy(coredev->ir.phys, coredev->devpath, sizeof(coredev->ir.phys));
74 strlcat(coredev->ir.phys, "/ir0", sizeof(coredev->ir.phys)); 74 strlcat(coredev->ir.phys, "/ir0", sizeof(coredev->ir.phys));
75 75
76 dev->input_name = coredev->ir.name; 76 dev->device_name = coredev->ir.name;
77 dev->input_phys = coredev->ir.phys; 77 dev->input_phys = coredev->ir.phys;
78 dev->dev.parent = coredev->device; 78 dev->dev.parent = coredev->device;
79 79
@@ -86,12 +86,12 @@ int sms_ir_init(struct smscore_device_t *coredev)
86#endif 86#endif
87 87
88 dev->priv = coredev; 88 dev->priv = coredev;
89 dev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 89 dev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
90 dev->map_name = sms_get_board(board_id)->rc_codes; 90 dev->map_name = sms_get_board(board_id)->rc_codes;
91 dev->driver_name = MODULE_NAME; 91 dev->driver_name = MODULE_NAME;
92 92
93 pr_debug("Input device (IR) %s is set for key events\n", 93 pr_debug("Input device (IR) %s is set for key events\n",
94 dev->input_name); 94 dev->device_name);
95 95
96 err = rc_register_device(dev); 96 err = rc_register_device(dev);
97 if (err < 0) { 97 if (err < 0) {
diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c
index 9bcbd318489b..5b5f95c38fe1 100644
--- a/drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c
+++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c
@@ -646,14 +646,14 @@ const struct color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1][V4L2_XFER_FUNC_S
646 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_DCI_P3][5] = { 3248, 944, 1094 }, 646 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_DCI_P3][5] = { 3248, 944, 1094 },
647 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_DCI_P3][6] = { 1017, 967, 3168 }, 647 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_DCI_P3][6] = { 1017, 967, 3168 },
648 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 }, 648 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 },
649 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][0] = { 3798, 3798, 3798 }, 649 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][0] = { 1812, 1812, 1812 },
650 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][1] = { 3802, 3805, 2602 }, 650 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][1] = { 1815, 1818, 910 },
651 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][2] = { 0, 3806, 3797 }, 651 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][2] = { 0, 1819, 1811 },
652 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][3] = { 1780, 3812, 2592 }, 652 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][3] = { 472, 1825, 904 },
653 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][4] = { 3820, 2215, 3796 }, 653 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][4] = { 1832, 686, 1810 },
654 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][5] = { 3824, 2409, 2574 }, 654 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][5] = { 1835, 794, 893 },
655 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][6] = { 2491, 2435, 3795 }, 655 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][6] = { 843, 809, 1810 },
656 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][7] = { 2563, 2563, 2563 }, 656 [V4L2_COLORSPACE_SMPTE170M][V4L2_XFER_FUNC_SMPTE2084][7] = { 886, 886, 886 },
657 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 }, 657 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 },
658 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_709][1] = { 2953, 2963, 586 }, 658 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_709][1] = { 2953, 2963, 586 },
659 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_709][2] = { 0, 2967, 2937 }, 659 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_709][2] = { 0, 2967, 2937 },
@@ -702,14 +702,14 @@ const struct color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1][V4L2_XFER_FUNC_S
702 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_DCI_P3][5] = { 3248, 944, 1094 }, 702 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_DCI_P3][5] = { 3248, 944, 1094 },
703 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_DCI_P3][6] = { 1017, 967, 3168 }, 703 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_DCI_P3][6] = { 1017, 967, 3168 },
704 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 }, 704 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 },
705 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][0] = { 3798, 3798, 3798 }, 705 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][0] = { 1812, 1812, 1812 },
706 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][1] = { 3802, 3805, 2602 }, 706 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][1] = { 1815, 1818, 910 },
707 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][2] = { 0, 3806, 3797 }, 707 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][2] = { 0, 1819, 1811 },
708 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][3] = { 1780, 3812, 2592 }, 708 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][3] = { 472, 1825, 904 },
709 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][4] = { 3820, 2215, 3796 }, 709 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][4] = { 1832, 686, 1810 },
710 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][5] = { 3824, 2409, 2574 }, 710 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][5] = { 1835, 794, 893 },
711 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][6] = { 2491, 2435, 3795 }, 711 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][6] = { 843, 809, 1810 },
712 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][7] = { 2563, 2563, 2563 }, 712 [V4L2_COLORSPACE_SMPTE240M][V4L2_XFER_FUNC_SMPTE2084][7] = { 886, 886, 886 },
713 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 }, 713 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 },
714 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_709][1] = { 2939, 2939, 547 }, 714 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_709][1] = { 2939, 2939, 547 },
715 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_709][2] = { 547, 2939, 2939 }, 715 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_709][2] = { 547, 2939, 2939 },
@@ -758,14 +758,14 @@ const struct color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1][V4L2_XFER_FUNC_S
758 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_DCI_P3][5] = { 3175, 1084, 1084 }, 758 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_DCI_P3][5] = { 3175, 1084, 1084 },
759 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_DCI_P3][6] = { 1084, 1084, 3175 }, 759 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_DCI_P3][6] = { 1084, 1084, 3175 },
760 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 }, 760 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 },
761 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][0] = { 3798, 3798, 3798 }, 761 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][0] = { 1812, 1812, 1812 },
762 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][1] = { 3798, 3798, 2563 }, 762 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][1] = { 1812, 1812, 886 },
763 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][2] = { 2563, 3798, 3798 }, 763 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][2] = { 886, 1812, 1812 },
764 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][3] = { 2563, 3798, 2563 }, 764 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][3] = { 886, 1812, 886 },
765 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][4] = { 3798, 2563, 3798 }, 765 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][4] = { 1812, 886, 1812 },
766 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][5] = { 3798, 2563, 2563 }, 766 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][5] = { 1812, 886, 886 },
767 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][6] = { 2563, 2563, 3798 }, 767 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][6] = { 886, 886, 1812 },
768 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][7] = { 2563, 2563, 2563 }, 768 [V4L2_COLORSPACE_REC709][V4L2_XFER_FUNC_SMPTE2084][7] = { 886, 886, 886 },
769 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 }, 769 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 },
770 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_709][1] = { 2892, 3034, 910 }, 770 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_709][1] = { 2892, 3034, 910 },
771 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_709][2] = { 1715, 2916, 2914 }, 771 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_709][2] = { 1715, 2916, 2914 },
@@ -814,14 +814,14 @@ const struct color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1][V4L2_XFER_FUNC_S
814 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_DCI_P3][5] = { 2765, 1182, 1190 }, 814 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_DCI_P3][5] = { 2765, 1182, 1190 },
815 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_DCI_P3][6] = { 1270, 0, 3094 }, 815 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_DCI_P3][6] = { 1270, 0, 3094 },
816 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 }, 816 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 },
817 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][0] = { 3798, 3798, 3798 }, 817 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][0] = { 1812, 1812, 1812 },
818 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][1] = { 3784, 3825, 2879 }, 818 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][1] = { 1800, 1836, 1090 },
819 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][2] = { 3351, 3791, 3790 }, 819 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][2] = { 1436, 1806, 1805 },
820 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][3] = { 3311, 3819, 2815 }, 820 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][3] = { 1405, 1830, 1047 },
821 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][4] = { 3659, 1900, 3777 }, 821 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][4] = { 1691, 527, 1793 },
822 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][5] = { 3640, 2662, 2669 }, 822 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][5] = { 1674, 947, 952 },
823 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][6] = { 2743, 0, 3769 }, 823 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][6] = { 1000, 0, 1786 },
824 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][7] = { 2563, 2563, 2563 }, 824 [V4L2_COLORSPACE_470_SYSTEM_M][V4L2_XFER_FUNC_SMPTE2084][7] = { 886, 886, 886 },
825 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 }, 825 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 },
826 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_709][1] = { 2939, 2939, 464 }, 826 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_709][1] = { 2939, 2939, 464 },
827 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_709][2] = { 786, 2939, 2939 }, 827 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_709][2] = { 786, 2939, 2939 },
@@ -870,14 +870,14 @@ const struct color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1][V4L2_XFER_FUNC_S
870 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_DCI_P3][5] = { 3126, 1084, 1084 }, 870 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_DCI_P3][5] = { 3126, 1084, 1084 },
871 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_DCI_P3][6] = { 1084, 1084, 3188 }, 871 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_DCI_P3][6] = { 1084, 1084, 3188 },
872 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 }, 872 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 },
873 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][0] = { 3798, 3798, 3798 }, 873 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][0] = { 1812, 1812, 1812 },
874 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][1] = { 3798, 3798, 2476 }, 874 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][1] = { 1812, 1812, 833 },
875 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][2] = { 2782, 3798, 3798 }, 875 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][2] = { 1025, 1812, 1812 },
876 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][3] = { 2782, 3798, 2476 }, 876 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][3] = { 1025, 1812, 833 },
877 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][4] = { 3780, 2563, 3803 }, 877 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][4] = { 1796, 886, 1816 },
878 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][5] = { 3780, 2563, 2563 }, 878 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][5] = { 1796, 886, 886 },
879 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][6] = { 2563, 2563, 3803 }, 879 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][6] = { 886, 886, 1816 },
880 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][7] = { 2563, 2563, 2563 }, 880 [V4L2_COLORSPACE_470_SYSTEM_BG][V4L2_XFER_FUNC_SMPTE2084][7] = { 886, 886, 886 },
881 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 }, 881 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 },
882 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_709][1] = { 2939, 2939, 547 }, 882 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_709][1] = { 2939, 2939, 547 },
883 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_709][2] = { 547, 2939, 2939 }, 883 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_709][2] = { 547, 2939, 2939 },
@@ -926,14 +926,14 @@ const struct color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1][V4L2_XFER_FUNC_S
926 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_DCI_P3][5] = { 3175, 1084, 1084 }, 926 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_DCI_P3][5] = { 3175, 1084, 1084 },
927 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_DCI_P3][6] = { 1084, 1084, 3175 }, 927 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_DCI_P3][6] = { 1084, 1084, 3175 },
928 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 }, 928 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 },
929 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][0] = { 3798, 3798, 3798 }, 929 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][0] = { 1812, 1812, 1812 },
930 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][1] = { 3798, 3798, 2563 }, 930 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][1] = { 1812, 1812, 886 },
931 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][2] = { 2563, 3798, 3798 }, 931 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][2] = { 886, 1812, 1812 },
932 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][3] = { 2563, 3798, 2563 }, 932 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][3] = { 886, 1812, 886 },
933 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][4] = { 3798, 2563, 3798 }, 933 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][4] = { 1812, 886, 1812 },
934 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][5] = { 3798, 2563, 2563 }, 934 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][5] = { 1812, 886, 886 },
935 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][6] = { 2563, 2563, 3798 }, 935 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][6] = { 886, 886, 1812 },
936 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][7] = { 2563, 2563, 2563 }, 936 [V4L2_COLORSPACE_SRGB][V4L2_XFER_FUNC_SMPTE2084][7] = { 886, 886, 886 },
937 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 }, 937 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 },
938 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_709][1] = { 2939, 2939, 781 }, 938 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_709][1] = { 2939, 2939, 781 },
939 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_709][2] = { 1622, 2939, 2939 }, 939 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_709][2] = { 1622, 2939, 2939 },
@@ -982,14 +982,14 @@ const struct color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1][V4L2_XFER_FUNC_S
982 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_DCI_P3][5] = { 2816, 1084, 1084 }, 982 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_DCI_P3][5] = { 2816, 1084, 1084 },
983 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_DCI_P3][6] = { 1084, 1084, 3127 }, 983 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_DCI_P3][6] = { 1084, 1084, 3127 },
984 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 }, 984 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 },
985 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][0] = { 3798, 3798, 3798 }, 985 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][0] = { 1812, 1812, 1812 },
986 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][1] = { 3798, 3798, 2778 }, 986 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][1] = { 1812, 1812, 1022 },
987 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][2] = { 3306, 3798, 3798 }, 987 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][2] = { 1402, 1812, 1812 },
988 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][3] = { 3306, 3798, 2778 }, 988 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][3] = { 1402, 1812, 1022 },
989 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][4] = { 3661, 2563, 3781 }, 989 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][4] = { 1692, 886, 1797 },
990 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][5] = { 3661, 2563, 2563 }, 990 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][5] = { 1692, 886, 886 },
991 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][6] = { 2563, 2563, 3781 }, 991 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][6] = { 886, 886, 1797 },
992 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][7] = { 2563, 2563, 2563 }, 992 [V4L2_COLORSPACE_ADOBERGB][V4L2_XFER_FUNC_SMPTE2084][7] = { 886, 886, 886 },
993 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 }, 993 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 },
994 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_709][1] = { 2877, 2923, 1058 }, 994 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_709][1] = { 2877, 2923, 1058 },
995 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_709][2] = { 1837, 2840, 2916 }, 995 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_709][2] = { 1837, 2840, 2916 },
@@ -1038,14 +1038,14 @@ const struct color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1][V4L2_XFER_FUNC_S
1038 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_DCI_P3][5] = { 2690, 1431, 1182 }, 1038 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_DCI_P3][5] = { 2690, 1431, 1182 },
1039 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_DCI_P3][6] = { 1318, 1153, 3051 }, 1039 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_DCI_P3][6] = { 1318, 1153, 3051 },
1040 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 }, 1040 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 },
1041 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][0] = { 3798, 3798, 3798 }, 1041 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][0] = { 1812, 1812, 1812 },
1042 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][1] = { 3780, 3793, 2984 }, 1042 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][1] = { 1796, 1808, 1163 },
1043 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][2] = { 3406, 3768, 3791 }, 1043 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][2] = { 1480, 1786, 1806 },
1044 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][3] = { 3359, 3763, 2939 }, 1044 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][3] = { 1443, 1781, 1131 },
1045 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][4] = { 3636, 2916, 3760 }, 1045 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][4] = { 1670, 1116, 1778 },
1046 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][5] = { 3609, 2880, 2661 }, 1046 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][5] = { 1648, 1091, 947 },
1047 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][6] = { 2786, 2633, 3753 }, 1047 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][6] = { 1028, 929, 1772 },
1048 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][7] = { 2563, 2563, 2563 }, 1048 [V4L2_COLORSPACE_BT2020][V4L2_XFER_FUNC_SMPTE2084][7] = { 886, 886, 886 },
1049 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 }, 1049 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_709][0] = { 2939, 2939, 2939 },
1050 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_709][1] = { 2936, 2934, 992 }, 1050 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_709][1] = { 2936, 2934, 992 },
1051 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_709][2] = { 1159, 2890, 2916 }, 1051 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_709][2] = { 1159, 2890, 2916 },
@@ -1094,14 +1094,14 @@ const struct color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1][V4L2_XFER_FUNC_S
1094 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_DCI_P3][5] = { 3018, 1276, 1184 }, 1094 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_DCI_P3][5] = { 3018, 1276, 1184 },
1095 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_DCI_P3][6] = { 1100, 1107, 3071 }, 1095 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_DCI_P3][6] = { 1100, 1107, 3071 },
1096 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 }, 1096 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_DCI_P3][7] = { 1084, 1084, 1084 },
1097 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][0] = { 3798, 3798, 3798 }, 1097 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][0] = { 1812, 1812, 1812 },
1098 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][1] = { 3797, 3796, 2938 }, 1098 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][1] = { 1811, 1810, 1131 },
1099 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][2] = { 3049, 3783, 3791 }, 1099 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][2] = { 1210, 1799, 1806 },
1100 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][3] = { 3044, 3782, 2887 }, 1100 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][3] = { 1206, 1798, 1096 },
1101 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][4] = { 3741, 2765, 3768 }, 1101 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][4] = { 1762, 1014, 1785 },
1102 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][5] = { 3740, 2749, 2663 }, 1102 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][5] = { 1761, 1004, 948 },
1103 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][6] = { 2580, 2587, 3760 }, 1103 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][6] = { 896, 901, 1778 },
1104 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][7] = { 2563, 2563, 2563 }, 1104 [V4L2_COLORSPACE_DCI_P3][V4L2_XFER_FUNC_SMPTE2084][7] = { 886, 886, 886 },
1105}; 1105};
1106 1106
1107#else 1107#else
@@ -1225,6 +1225,12 @@ static double transfer_rgb_to_smpte2084(double v)
1225 const double c2 = 32.0 * 2413.0 / 4096.0; 1225 const double c2 = 32.0 * 2413.0 / 4096.0;
1226 const double c3 = 32.0 * 2392.0 / 4096.0; 1226 const double c3 = 32.0 * 2392.0 / 4096.0;
1227 1227
1228 /*
1229 * The RGB input maps to the luminance range 0-100 cd/m^2, while
1230 * SMPTE-2084 maps values to the luminance range of 0-10000 cd/m^2.
1231 * Hence the factor 100.
1232 */
1233 v /= 100.0;
1228 v = pow(v, m1); 1234 v = pow(v, m1);
1229 return pow((c1 + c2 * v) / (1 + c3 * v), m2); 1235 return pow((c1 + c2 * v) / (1 + c3 * v), m2);
1230} 1236}
diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
index 3dd22da7e17d..a772976cfe26 100644
--- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
+++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
@@ -615,7 +615,7 @@ static void color_to_ycbcr(struct tpg_data *tpg, int r, int g, int b,
615 static const int bt2020_full[3][3] = { 615 static const int bt2020_full[3][3] = {
616 { COEFF(0.2627, 255), COEFF(0.6780, 255), COEFF(0.0593, 255) }, 616 { COEFF(0.2627, 255), COEFF(0.6780, 255), COEFF(0.0593, 255) },
617 { COEFF(-0.1396, 255), COEFF(-0.3604, 255), COEFF(0.5, 255) }, 617 { COEFF(-0.1396, 255), COEFF(-0.3604, 255), COEFF(0.5, 255) },
618 { COEFF(0.5, 255), COEFF(-0.4698, 255), COEFF(-0.0402, 255) }, 618 { COEFF(0.5, 255), COEFF(-0.4598, 255), COEFF(-0.0402, 255) },
619 }; 619 };
620 static const int bt2020c[4] = { 620 static const int bt2020c[4] = {
621 COEFF(1.0 / 1.9404, 224), COEFF(1.0 / 1.5816, 224), 621 COEFF(1.0 / 1.9404, 224), COEFF(1.0 / 1.5816, 224),
diff --git a/drivers/media/dvb-core/demux.h b/drivers/media/dvb-core/demux.h
index f854309ba8a5..c4df6cee48e6 100644
--- a/drivers/media/dvb-core/demux.h
+++ b/drivers/media/dvb-core/demux.h
@@ -210,7 +210,7 @@ struct dmx_section_feed {
210 * the start of the first undelivered TS packet within a circular buffer. 210 * the start of the first undelivered TS packet within a circular buffer.
211 * The @buffer2 buffer parameter is normally NULL, except when the received 211 * The @buffer2 buffer parameter is normally NULL, except when the received
212 * TS packets have crossed the last address of the circular buffer and 212 * TS packets have crossed the last address of the circular buffer and
213 * wrapped to the beginning of the buffer. In the latter case the @buffer1 213 * "wrapped" to the beginning of the buffer. In the latter case the @buffer1
214 * parameter would contain an address within the circular buffer, while the 214 * parameter would contain an address within the circular buffer, while the
215 * @buffer2 parameter would contain the first address of the circular buffer. 215 * @buffer2 parameter would contain the first address of the circular buffer.
216 * The number of bytes delivered with this function (i.e. @buffer1_length + 216 * The number of bytes delivered with this function (i.e. @buffer1_length +
diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index 45e91add73ba..18e4230865be 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -562,7 +562,7 @@ static int dvb_dmxdev_start_feed(struct dmxdev *dmxdev,
562{ 562{
563 ktime_t timeout = 0; 563 ktime_t timeout = 0;
564 struct dmx_pes_filter_params *para = &filter->params.pes; 564 struct dmx_pes_filter_params *para = &filter->params.pes;
565 dmx_output_t otype; 565 enum dmx_output otype;
566 int ret; 566 int ret;
567 int ts_type; 567 int ts_type;
568 enum dmx_ts_pes ts_pes; 568 enum dmx_ts_pes ts_pes;
@@ -787,7 +787,7 @@ static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev,
787 return 0; 787 return 0;
788} 788}
789 789
790static inline void invert_mode(dmx_filter_t *filter) 790static inline void invert_mode(struct dmx_filter *filter)
791{ 791{
792 int i; 792 int i;
793 793
@@ -1025,26 +1025,6 @@ static int dvb_demux_do_ioctl(struct file *file,
1025 dmxdev->demux->get_pes_pids(dmxdev->demux, parg); 1025 dmxdev->demux->get_pes_pids(dmxdev->demux, parg);
1026 break; 1026 break;
1027 1027
1028#if 0
1029 /* Not used upstream and never documented */
1030
1031 case DMX_GET_CAPS:
1032 if (!dmxdev->demux->get_caps) {
1033 ret = -EINVAL;
1034 break;
1035 }
1036 ret = dmxdev->demux->get_caps(dmxdev->demux, parg);
1037 break;
1038
1039 case DMX_SET_SOURCE:
1040 if (!dmxdev->demux->set_source) {
1041 ret = -EINVAL;
1042 break;
1043 }
1044 ret = dmxdev->demux->set_source(dmxdev->demux, parg);
1045 break;
1046#endif
1047
1048 case DMX_GET_STC: 1028 case DMX_GET_STC:
1049 if (!dmxdev->demux->get_stc) { 1029 if (!dmxdev->demux->get_stc) {
1050 ret = -EINVAL; 1030 ret = -EINVAL;
diff --git a/drivers/media/dvb-core/dvb-usb-ids.h b/drivers/media/dvb-core/dvb-usb-ids.h
index e200aa6f2d2f..5b6041d462bc 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -279,6 +279,7 @@
279#define USB_PID_TERRATEC_H7 0x10b4 279#define USB_PID_TERRATEC_H7 0x10b4
280#define USB_PID_TERRATEC_H7_2 0x10a3 280#define USB_PID_TERRATEC_H7_2 0x10a3
281#define USB_PID_TERRATEC_H7_3 0x10a5 281#define USB_PID_TERRATEC_H7_3 0x10a5
282#define USB_PID_TERRATEC_T1 0x10ae
282#define USB_PID_TERRATEC_T3 0x10a0 283#define USB_PID_TERRATEC_T3 0x10a0
283#define USB_PID_TERRATEC_T5 0x10a1 284#define USB_PID_TERRATEC_T5 0x10a1
284#define USB_PID_NOXON_DAB_STICK 0x00b3 285#define USB_PID_NOXON_DAB_STICK 0x00b3
diff --git a/drivers/media/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb-core/dvb_ca_en50221.c
index 17970cdd55fa..95b3723282f4 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb-core/dvb_ca_en50221.c
@@ -76,8 +76,6 @@ MODULE_PARM_DESC(cam_debug, "enable verbose debug messages");
76#define STATUSREG_WE 2 /* write error */ 76#define STATUSREG_WE 2 /* write error */
77#define STATUSREG_FR 0x40 /* module free */ 77#define STATUSREG_FR 0x40 /* module free */
78#define STATUSREG_DA 0x80 /* data available */ 78#define STATUSREG_DA 0x80 /* data available */
79#define STATUSREG_TXERR (STATUSREG_RE|STATUSREG_WE) /* general transfer error */
80
81 79
82#define DVB_CA_SLOTSTATE_NONE 0 80#define DVB_CA_SLOTSTATE_NONE 0
83#define DVB_CA_SLOTSTATE_UNINITIALISED 1 81#define DVB_CA_SLOTSTATE_UNINITIALISED 1
@@ -88,10 +86,8 @@ MODULE_PARM_DESC(cam_debug, "enable verbose debug messages");
88#define DVB_CA_SLOTSTATE_WAITFR 6 86#define DVB_CA_SLOTSTATE_WAITFR 6
89#define DVB_CA_SLOTSTATE_LINKINIT 7 87#define DVB_CA_SLOTSTATE_LINKINIT 7
90 88
91
92/* Information on a CA slot */ 89/* Information on a CA slot */
93struct dvb_ca_slot { 90struct dvb_ca_slot {
94
95 /* current state of the CAM */ 91 /* current state of the CAM */
96 int slot_state; 92 int slot_state;
97 93
@@ -157,7 +153,10 @@ struct dvb_ca_private {
157 /* Delay the main thread should use */ 153 /* Delay the main thread should use */
158 unsigned long delay; 154 unsigned long delay;
159 155
160 /* Slot to start looking for data to read from in the next user-space read operation */ 156 /*
157 * Slot to start looking for data to read from in the next user-space
158 * read operation
159 */
161 int next_read_slot; 160 int next_read_slot;
162 161
163 /* mutex serializing ioctls */ 162 /* mutex serializing ioctls */
@@ -178,7 +177,9 @@ static void dvb_ca_private_free(struct dvb_ca_private *ca)
178 177
179static void dvb_ca_private_release(struct kref *ref) 178static void dvb_ca_private_release(struct kref *ref)
180{ 179{
181 struct dvb_ca_private *ca = container_of(ref, struct dvb_ca_private, refcount); 180 struct dvb_ca_private *ca;
181
182 ca = container_of(ref, struct dvb_ca_private, refcount);
182 dvb_ca_private_free(ca); 183 dvb_ca_private_free(ca);
183} 184}
184 185
@@ -198,7 +199,6 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
198static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, 199static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
199 u8 *ebuf, int ecount); 200 u8 *ebuf, int ecount);
200 201
201
202/** 202/**
203 * Safely find needle in haystack. 203 * Safely find needle in haystack.
204 * 204 *
@@ -223,25 +223,22 @@ static char *findstr(char *haystack, int hlen, char *needle, int nlen)
223 return NULL; 223 return NULL;
224} 224}
225 225
226 226/* ************************************************************************** */
227
228/* ******************************************************************************** */
229/* EN50221 physical interface functions */ 227/* EN50221 physical interface functions */
230 228
231
232/** 229/**
233 * dvb_ca_en50221_check_camstatus - Check CAM status. 230 * dvb_ca_en50221_check_camstatus - Check CAM status.
234 */ 231 */
235static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot) 232static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot)
236{ 233{
234 struct dvb_ca_slot *sl = &ca->slot_info[slot];
237 int slot_status; 235 int slot_status;
238 int cam_present_now; 236 int cam_present_now;
239 int cam_changed; 237 int cam_changed;
240 238
241 /* IRQ mode */ 239 /* IRQ mode */
242 if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE) { 240 if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)
243 return (atomic_read(&ca->slot_info[slot].camchange_count) != 0); 241 return (atomic_read(&sl->camchange_count) != 0);
244 }
245 242
246 /* poll mode */ 243 /* poll mode */
247 slot_status = ca->pub->poll_slot_status(ca->pub, slot, ca->open); 244 slot_status = ca->pub->poll_slot_status(ca->pub, slot, ca->open);
@@ -249,29 +246,28 @@ static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot)
249 cam_present_now = (slot_status & DVB_CA_EN50221_POLL_CAM_PRESENT) ? 1 : 0; 246 cam_present_now = (slot_status & DVB_CA_EN50221_POLL_CAM_PRESENT) ? 1 : 0;
250 cam_changed = (slot_status & DVB_CA_EN50221_POLL_CAM_CHANGED) ? 1 : 0; 247 cam_changed = (slot_status & DVB_CA_EN50221_POLL_CAM_CHANGED) ? 1 : 0;
251 if (!cam_changed) { 248 if (!cam_changed) {
252 int cam_present_old = (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE); 249 int cam_present_old = (sl->slot_state != DVB_CA_SLOTSTATE_NONE);
250
253 cam_changed = (cam_present_now != cam_present_old); 251 cam_changed = (cam_present_now != cam_present_old);
254 } 252 }
255 253
256 if (cam_changed) { 254 if (cam_changed) {
257 if (!cam_present_now) { 255 if (!cam_present_now)
258 ca->slot_info[slot].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED; 256 sl->camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
259 } else { 257 else
260 ca->slot_info[slot].camchange_type = DVB_CA_EN50221_CAMCHANGE_INSERTED; 258 sl->camchange_type = DVB_CA_EN50221_CAMCHANGE_INSERTED;
261 } 259 atomic_set(&sl->camchange_count, 1);
262 atomic_set(&ca->slot_info[slot].camchange_count, 1);
263 } else { 260 } else {
264 if ((ca->slot_info[slot].slot_state == DVB_CA_SLOTSTATE_WAITREADY) && 261 if ((sl->slot_state == DVB_CA_SLOTSTATE_WAITREADY) &&
265 (slot_status & DVB_CA_EN50221_POLL_CAM_READY)) { 262 (slot_status & DVB_CA_EN50221_POLL_CAM_READY)) {
266 // move to validate state if reset is completed 263 /* move to validate state if reset is completed */
267 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_VALIDATE; 264 sl->slot_state = DVB_CA_SLOTSTATE_VALIDATE;
268 } 265 }
269 } 266 }
270 267
271 return cam_changed; 268 return cam_changed;
272} 269}
273 270
274
275/** 271/**
276 * dvb_ca_en50221_wait_if_status - Wait for flags to become set on the STATUS 272 * dvb_ca_en50221_wait_if_status - Wait for flags to become set on the STATUS
277 * register on a CAM interface, checking for errors and timeout. 273 * register on a CAM interface, checking for errors and timeout.
@@ -295,8 +291,10 @@ static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot,
295 start = jiffies; 291 start = jiffies;
296 timeout = jiffies + timeout_hz; 292 timeout = jiffies + timeout_hz;
297 while (1) { 293 while (1) {
294 int res;
295
298 /* read the status and check for error */ 296 /* read the status and check for error */
299 int res = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS); 297 res = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
300 if (res < 0) 298 if (res < 0)
301 return -EIO; 299 return -EIO;
302 300
@@ -308,12 +306,11 @@ static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot,
308 } 306 }
309 307
310 /* check for timeout */ 308 /* check for timeout */
311 if (time_after(jiffies, timeout)) { 309 if (time_after(jiffies, timeout))
312 break; 310 break;
313 }
314 311
315 /* wait for a bit */ 312 /* wait for a bit */
316 msleep(1); 313 usleep_range(1000, 1100);
317 } 314 }
318 315
319 dprintk("%s failed timeout:%lu\n", __func__, jiffies - start); 316 dprintk("%s failed timeout:%lu\n", __func__, jiffies - start);
@@ -322,7 +319,6 @@ static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot,
322 return -ETIMEDOUT; 319 return -ETIMEDOUT;
323} 320}
324 321
325
326/** 322/**
327 * dvb_ca_en50221_link_init - Initialise the link layer connection to a CAM. 323 * dvb_ca_en50221_link_init - Initialise the link layer connection to a CAM.
328 * 324 *
@@ -333,6 +329,7 @@ static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot,
333 */ 329 */
334static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot) 330static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
335{ 331{
332 struct dvb_ca_slot *sl = &ca->slot_info[slot];
336 int ret; 333 int ret;
337 int buf_size; 334 int buf_size;
338 u8 buf[2]; 335 u8 buf[2];
@@ -340,40 +337,54 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
340 dprintk("%s\n", __func__); 337 dprintk("%s\n", __func__);
341 338
342 /* we'll be determining these during this function */ 339 /* we'll be determining these during this function */
343 ca->slot_info[slot].da_irq_supported = 0; 340 sl->da_irq_supported = 0;
344 341
345 /* set the host link buffer size temporarily. it will be overwritten with the 342 /*
346 * real negotiated size later. */ 343 * set the host link buffer size temporarily. it will be overwritten
347 ca->slot_info[slot].link_buf_size = 2; 344 * with the real negotiated size later.
345 */
346 sl->link_buf_size = 2;
348 347
349 /* read the buffer size from the CAM */ 348 /* read the buffer size from the CAM */
350 if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SR)) != 0) 349 ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
350 IRQEN | CMDREG_SR);
351 if (ret)
351 return ret; 352 return ret;
352 ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_DA, HZ); 353 ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_DA, HZ);
353 if (ret != 0) 354 if (ret)
354 return ret; 355 return ret;
355 if ((ret = dvb_ca_en50221_read_data(ca, slot, buf, 2)) != 2) 356 ret = dvb_ca_en50221_read_data(ca, slot, buf, 2);
357 if (ret != 2)
356 return -EIO; 358 return -EIO;
357 if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN)) != 0) 359 ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN);
360 if (ret)
358 return ret; 361 return ret;
359 362
360 /* store it, and choose the minimum of our buffer and the CAM's buffer size */ 363 /*
364 * store it, and choose the minimum of our buffer and the CAM's buffer
365 * size
366 */
361 buf_size = (buf[0] << 8) | buf[1]; 367 buf_size = (buf[0] << 8) | buf[1];
362 if (buf_size > HOST_LINK_BUF_SIZE) 368 if (buf_size > HOST_LINK_BUF_SIZE)
363 buf_size = HOST_LINK_BUF_SIZE; 369 buf_size = HOST_LINK_BUF_SIZE;
364 ca->slot_info[slot].link_buf_size = buf_size; 370 sl->link_buf_size = buf_size;
365 buf[0] = buf_size >> 8; 371 buf[0] = buf_size >> 8;
366 buf[1] = buf_size & 0xff; 372 buf[1] = buf_size & 0xff;
367 dprintk("Chosen link buffer size of %i\n", buf_size); 373 dprintk("Chosen link buffer size of %i\n", buf_size);
368 374
369 /* write the buffer size to the CAM */ 375 /* write the buffer size to the CAM */
370 if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SW)) != 0) 376 ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
377 IRQEN | CMDREG_SW);
378 if (ret)
371 return ret; 379 return ret;
372 if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_FR, HZ / 10)) != 0) 380 ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_FR, HZ / 10);
381 if (ret)
373 return ret; 382 return ret;
374 if ((ret = dvb_ca_en50221_write_data(ca, slot, buf, 2)) != 2) 383 ret = dvb_ca_en50221_write_data(ca, slot, buf, 2);
384 if (ret != 2)
375 return -EIO; 385 return -EIO;
376 if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN)) != 0) 386 ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN);
387 if (ret)
377 return ret; 388 return ret;
378 389
379 /* success */ 390 /* success */
@@ -393,47 +404,50 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
393 * @return 0 on success, nonzero on error. 404 * @return 0 on success, nonzero on error.
394 */ 405 */
395static int dvb_ca_en50221_read_tuple(struct dvb_ca_private *ca, int slot, 406static int dvb_ca_en50221_read_tuple(struct dvb_ca_private *ca, int slot,
396 int *address, int *tupleType, 407 int *address, int *tuple_type,
397 int *tupleLength, u8 *tuple) 408 int *tuple_length, u8 *tuple)
398{ 409{
399 int i; 410 int i;
400 int _tupleType; 411 int _tuple_type;
401 int _tupleLength; 412 int _tuple_length;
402 int _address = *address; 413 int _address = *address;
403 414
404 /* grab the next tuple length and type */ 415 /* grab the next tuple length and type */
405 if ((_tupleType = ca->pub->read_attribute_mem(ca->pub, slot, _address)) < 0) 416 _tuple_type = ca->pub->read_attribute_mem(ca->pub, slot, _address);
406 return _tupleType; 417 if (_tuple_type < 0)
407 if (_tupleType == 0xff) { 418 return _tuple_type;
408 dprintk("END OF CHAIN TUPLE type:0x%x\n", _tupleType); 419 if (_tuple_type == 0xff) {
420 dprintk("END OF CHAIN TUPLE type:0x%x\n", _tuple_type);
409 *address += 2; 421 *address += 2;
410 *tupleType = _tupleType; 422 *tuple_type = _tuple_type;
411 *tupleLength = 0; 423 *tuple_length = 0;
412 return 0; 424 return 0;
413 } 425 }
414 if ((_tupleLength = ca->pub->read_attribute_mem(ca->pub, slot, _address + 2)) < 0) 426 _tuple_length = ca->pub->read_attribute_mem(ca->pub, slot,
415 return _tupleLength; 427 _address + 2);
428 if (_tuple_length < 0)
429 return _tuple_length;
416 _address += 4; 430 _address += 4;
417 431
418 dprintk("TUPLE type:0x%x length:%i\n", _tupleType, _tupleLength); 432 dprintk("TUPLE type:0x%x length:%i\n", _tuple_type, _tuple_length);
419 433
420 /* read in the whole tuple */ 434 /* read in the whole tuple */
421 for (i = 0; i < _tupleLength; i++) { 435 for (i = 0; i < _tuple_length; i++) {
422 tuple[i] = ca->pub->read_attribute_mem(ca->pub, slot, _address + (i * 2)); 436 tuple[i] = ca->pub->read_attribute_mem(ca->pub, slot,
437 _address + (i * 2));
423 dprintk(" 0x%02x: 0x%02x %c\n", 438 dprintk(" 0x%02x: 0x%02x %c\n",
424 i, tuple[i] & 0xff, 439 i, tuple[i] & 0xff,
425 ((tuple[i] > 31) && (tuple[i] < 127)) ? tuple[i] : '.'); 440 ((tuple[i] > 31) && (tuple[i] < 127)) ? tuple[i] : '.');
426 } 441 }
427 _address += (_tupleLength * 2); 442 _address += (_tuple_length * 2);
428 443
429 // success 444 /* success */
430 *tupleType = _tupleType; 445 *tuple_type = _tuple_type;
431 *tupleLength = _tupleLength; 446 *tuple_length = _tuple_length;
432 *address = _address; 447 *address = _address;
433 return 0; 448 return 0;
434} 449}
435 450
436
437/** 451/**
438 * dvb_ca_en50221_parse_attributes - Parse attribute memory of a CAM module, 452 * dvb_ca_en50221_parse_attributes - Parse attribute memory of a CAM module,
439 * extracting Config register, and checking it is a DVB CAM module. 453 * extracting Config register, and checking it is a DVB CAM module.
@@ -445,9 +459,10 @@ static int dvb_ca_en50221_read_tuple(struct dvb_ca_private *ca, int slot,
445 */ 459 */
446static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot) 460static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
447{ 461{
462 struct dvb_ca_slot *sl;
448 int address = 0; 463 int address = 0;
449 int tupleLength; 464 int tuple_length;
450 int tupleType; 465 int tuple_type;
451 u8 tuple[257]; 466 u8 tuple[257];
452 char *dvb_str; 467 char *dvb_str;
453 int rasz; 468 int rasz;
@@ -458,70 +473,66 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
458 u16 manfid = 0; 473 u16 manfid = 0;
459 u16 devid = 0; 474 u16 devid = 0;
460 475
461 476 /* CISTPL_DEVICE_0A */
462 // CISTPL_DEVICE_0A 477 status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type,
463 if ((status = 478 &tuple_length, tuple);
464 dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0) 479 if (status < 0)
465 return status; 480 return status;
466 if (tupleType != 0x1D) 481 if (tuple_type != 0x1D)
467 return -EINVAL; 482 return -EINVAL;
468 483
469 484 /* CISTPL_DEVICE_0C */
470 485 status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type,
471 // CISTPL_DEVICE_0C 486 &tuple_length, tuple);
472 if ((status = 487 if (status < 0)
473 dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
474 return status; 488 return status;
475 if (tupleType != 0x1C) 489 if (tuple_type != 0x1C)
476 return -EINVAL; 490 return -EINVAL;
477 491
478 492 /* CISTPL_VERS_1 */
479 493 status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type,
480 // CISTPL_VERS_1 494 &tuple_length, tuple);
481 if ((status = 495 if (status < 0)
482 dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
483 return status; 496 return status;
484 if (tupleType != 0x15) 497 if (tuple_type != 0x15)
485 return -EINVAL; 498 return -EINVAL;
486 499
487 500 /* CISTPL_MANFID */
488 501 status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type,
489 // CISTPL_MANFID 502 &tuple_length, tuple);
490 if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, 503 if (status < 0)
491 &tupleLength, tuple)) < 0)
492 return status; 504 return status;
493 if (tupleType != 0x20) 505 if (tuple_type != 0x20)
494 return -EINVAL; 506 return -EINVAL;
495 if (tupleLength != 4) 507 if (tuple_length != 4)
496 return -EINVAL; 508 return -EINVAL;
497 manfid = (tuple[1] << 8) | tuple[0]; 509 manfid = (tuple[1] << 8) | tuple[0];
498 devid = (tuple[3] << 8) | tuple[2]; 510 devid = (tuple[3] << 8) | tuple[2];
499 511
500 512 /* CISTPL_CONFIG */
501 513 status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tuple_type,
502 // CISTPL_CONFIG 514 &tuple_length, tuple);
503 if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, 515 if (status < 0)
504 &tupleLength, tuple)) < 0)
505 return status; 516 return status;
506 if (tupleType != 0x1A) 517 if (tuple_type != 0x1A)
507 return -EINVAL; 518 return -EINVAL;
508 if (tupleLength < 3) 519 if (tuple_length < 3)
509 return -EINVAL; 520 return -EINVAL;
510 521
511 /* extract the configbase */ 522 /* extract the configbase */
512 rasz = tuple[0] & 3; 523 rasz = tuple[0] & 3;
513 if (tupleLength < (3 + rasz + 14)) 524 if (tuple_length < (3 + rasz + 14))
514 return -EINVAL; 525 return -EINVAL;
515 ca->slot_info[slot].config_base = 0; 526 sl = &ca->slot_info[slot];
516 for (i = 0; i < rasz + 1; i++) { 527 sl->config_base = 0;
517 ca->slot_info[slot].config_base |= (tuple[2 + i] << (8 * i)); 528 for (i = 0; i < rasz + 1; i++)
518 } 529 sl->config_base |= (tuple[2 + i] << (8 * i));
519 530
520 /* check it contains the correct DVB string */ 531 /* check it contains the correct DVB string */
521 dvb_str = findstr((char *)tuple, tupleLength, "DVB_CI_V", 8); 532 dvb_str = findstr((char *)tuple, tuple_length, "DVB_CI_V", 8);
522 if (dvb_str == NULL) 533 if (!dvb_str)
523 return -EINVAL; 534 return -EINVAL;
524 if (tupleLength < ((dvb_str - (char *) tuple) + 12)) 535 if (tuple_length < ((dvb_str - (char *)tuple) + 12))
525 return -EINVAL; 536 return -EINVAL;
526 537
527 /* is it a version we support? */ 538 /* is it a version we support? */
@@ -534,12 +545,14 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
534 545
535 /* process the CFTABLE_ENTRY tuples, and any after those */ 546 /* process the CFTABLE_ENTRY tuples, and any after those */
536 while ((!end_chain) && (address < 0x1000)) { 547 while ((!end_chain) && (address < 0x1000)) {
537 if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, 548 status = dvb_ca_en50221_read_tuple(ca, slot, &address,
538 &tupleLength, tuple)) < 0) 549 &tuple_type, &tuple_length,
550 tuple);
551 if (status < 0)
539 return status; 552 return status;
540 switch (tupleType) { 553 switch (tuple_type) {
541 case 0x1B: // CISTPL_CFTABLE_ENTRY 554 case 0x1B: /* CISTPL_CFTABLE_ENTRY */
542 if (tupleLength < (2 + 11 + 17)) 555 if (tuple_length < (2 + 11 + 17))
543 break; 556 break;
544 557
545 /* if we've already parsed one, just use it */ 558 /* if we've already parsed one, just use it */
@@ -547,26 +560,28 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
547 break; 560 break;
548 561
549 /* get the config option */ 562 /* get the config option */
550 ca->slot_info[slot].config_option = tuple[0] & 0x3f; 563 sl->config_option = tuple[0] & 0x3f;
551 564
552 /* OK, check it contains the correct strings */ 565 /* OK, check it contains the correct strings */
553 if ((findstr((char *)tuple, tupleLength, "DVB_HOST", 8) == NULL) || 566 if (!findstr((char *)tuple, tuple_length,
554 (findstr((char *)tuple, tupleLength, "DVB_CI_MODULE", 13) == NULL)) 567 "DVB_HOST", 8) ||
568 !findstr((char *)tuple, tuple_length,
569 "DVB_CI_MODULE", 13))
555 break; 570 break;
556 571
557 got_cftableentry = 1; 572 got_cftableentry = 1;
558 break; 573 break;
559 574
560 case 0x14: // CISTPL_NO_LINK 575 case 0x14: /* CISTPL_NO_LINK */
561 break; 576 break;
562 577
563 case 0xFF: // CISTPL_END 578 case 0xFF: /* CISTPL_END */
564 end_chain = 1; 579 end_chain = 1;
565 break; 580 break;
566 581
567 default: /* Unknown tuple type - just skip this tuple and move to the next one */ 582 default: /* Unknown tuple type - just skip this tuple */
568 dprintk("dvb_ca: Skipping unknown tuple type:0x%x length:0x%x\n", 583 dprintk("dvb_ca: Skipping unknown tuple type:0x%x length:0x%x\n",
569 tupleType, tupleLength); 584 tuple_type, tuple_length);
570 break; 585 break;
571 } 586 }
572 } 587 }
@@ -575,14 +590,12 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
575 return -EINVAL; 590 return -EINVAL;
576 591
577 dprintk("Valid DVB CAM detected MANID:%x DEVID:%x CONFIGBASE:0x%x CONFIGOPTION:0x%x\n", 592 dprintk("Valid DVB CAM detected MANID:%x DEVID:%x CONFIGBASE:0x%x CONFIGOPTION:0x%x\n",
578 manfid, devid, ca->slot_info[slot].config_base, 593 manfid, devid, sl->config_base, sl->config_option);
579 ca->slot_info[slot].config_option);
580 594
581 // success! 595 /* success! */
582 return 0; 596 return 0;
583} 597}
584 598
585
586/** 599/**
587 * dvb_ca_en50221_set_configoption - Set CAM's configoption correctly. 600 * dvb_ca_en50221_set_configoption - Set CAM's configoption correctly.
588 * 601 *
@@ -591,26 +604,25 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
591 */ 604 */
592static int dvb_ca_en50221_set_configoption(struct dvb_ca_private *ca, int slot) 605static int dvb_ca_en50221_set_configoption(struct dvb_ca_private *ca, int slot)
593{ 606{
607 struct dvb_ca_slot *sl = &ca->slot_info[slot];
594 int configoption; 608 int configoption;
595 609
596 dprintk("%s\n", __func__); 610 dprintk("%s\n", __func__);
597 611
598 /* set the config option */ 612 /* set the config option */
599 ca->pub->write_attribute_mem(ca->pub, slot, 613 ca->pub->write_attribute_mem(ca->pub, slot, sl->config_base,
600 ca->slot_info[slot].config_base, 614 sl->config_option);
601 ca->slot_info[slot].config_option);
602 615
603 /* check it */ 616 /* check it */
604 configoption = ca->pub->read_attribute_mem(ca->pub, slot, ca->slot_info[slot].config_base); 617 configoption = ca->pub->read_attribute_mem(ca->pub, slot,
618 sl->config_base);
605 dprintk("Set configoption 0x%x, read configoption 0x%x\n", 619 dprintk("Set configoption 0x%x, read configoption 0x%x\n",
606 ca->slot_info[slot].config_option, configoption & 0x3f); 620 sl->config_option, configoption & 0x3f);
607 621
608 /* fine! */ 622 /* fine! */
609 return 0; 623 return 0;
610
611} 624}
612 625
613
614/** 626/**
615 * dvb_ca_en50221_read_data - This function talks to an EN50221 CAM control 627 * dvb_ca_en50221_read_data - This function talks to an EN50221 CAM control
616 * interface. It reads a buffer of data from the CAM. The data can either 628 * interface. It reads a buffer of data from the CAM. The data can either
@@ -628,6 +640,7 @@ static int dvb_ca_en50221_set_configoption(struct dvb_ca_private *ca, int slot)
628static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, 640static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
629 u8 *ebuf, int ecount) 641 u8 *ebuf, int ecount)
630{ 642{
643 struct dvb_ca_slot *sl = &ca->slot_info[slot];
631 int bytes_read; 644 int bytes_read;
632 int status; 645 int status;
633 u8 buf[HOST_LINK_BUF_SIZE]; 646 u8 buf[HOST_LINK_BUF_SIZE];
@@ -636,16 +649,16 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
636 dprintk("%s\n", __func__); 649 dprintk("%s\n", __func__);
637 650
638 /* check if we have space for a link buf in the rx_buffer */ 651 /* check if we have space for a link buf in the rx_buffer */
639 if (ebuf == NULL) { 652 if (!ebuf) {
640 int buf_free; 653 int buf_free;
641 654
642 if (ca->slot_info[slot].rx_buffer.data == NULL) { 655 if (!sl->rx_buffer.data) {
643 status = -EIO; 656 status = -EIO;
644 goto exit; 657 goto exit;
645 } 658 }
646 buf_free = dvb_ringbuffer_free(&ca->slot_info[slot].rx_buffer); 659 buf_free = dvb_ringbuffer_free(&sl->rx_buffer);
647 660
648 if (buf_free < (ca->slot_info[slot].link_buf_size + 661 if (buf_free < (sl->link_buf_size +
649 DVB_RINGBUFFER_PKTHDRSIZE)) { 662 DVB_RINGBUFFER_PKTHDRSIZE)) {
650 status = -EAGAIN; 663 status = -EAGAIN;
651 goto exit; 664 goto exit;
@@ -653,8 +666,8 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
653 } 666 }
654 667
655 if (ca->pub->read_data && 668 if (ca->pub->read_data &&
656 (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_LINKINIT)) { 669 (sl->slot_state != DVB_CA_SLOTSTATE_LINKINIT)) {
657 if (ebuf == NULL) 670 if (!ebuf)
658 status = ca->pub->read_data(ca->pub, slot, buf, 671 status = ca->pub->read_data(ca->pub, slot, buf,
659 sizeof(buf)); 672 sizeof(buf));
660 else 673 else
@@ -665,7 +678,6 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
665 if (status == 0) 678 if (status == 0)
666 goto exit; 679 goto exit;
667 } else { 680 } else {
668
669 /* check if there is data available */ 681 /* check if there is data available */
670 status = ca->pub->read_cam_control(ca->pub, slot, 682 status = ca->pub->read_cam_control(ca->pub, slot,
671 CTRLIF_STATUS); 683 CTRLIF_STATUS);
@@ -690,21 +702,19 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
690 bytes_read |= status; 702 bytes_read |= status;
691 703
692 /* check it will fit */ 704 /* check it will fit */
693 if (ebuf == NULL) { 705 if (!ebuf) {
694 if (bytes_read > ca->slot_info[slot].link_buf_size) { 706 if (bytes_read > sl->link_buf_size) {
695 pr_err("dvb_ca adapter %d: CAM tried to send a buffer larger than the link buffer size (%i > %i)!\n", 707 pr_err("dvb_ca adapter %d: CAM tried to send a buffer larger than the link buffer size (%i > %i)!\n",
696 ca->dvbdev->adapter->num, bytes_read, 708 ca->dvbdev->adapter->num, bytes_read,
697 ca->slot_info[slot].link_buf_size); 709 sl->link_buf_size);
698 ca->slot_info[slot].slot_state = 710 sl->slot_state = DVB_CA_SLOTSTATE_LINKINIT;
699 DVB_CA_SLOTSTATE_LINKINIT;
700 status = -EIO; 711 status = -EIO;
701 goto exit; 712 goto exit;
702 } 713 }
703 if (bytes_read < 2) { 714 if (bytes_read < 2) {
704 pr_err("dvb_ca adapter %d: CAM sent a buffer that was less than 2 bytes!\n", 715 pr_err("dvb_ca adapter %d: CAM sent a buffer that was less than 2 bytes!\n",
705 ca->dvbdev->adapter->num); 716 ca->dvbdev->adapter->num);
706 ca->slot_info[slot].slot_state = 717 sl->slot_state = DVB_CA_SLOTSTATE_LINKINIT;
707 DVB_CA_SLOTSTATE_LINKINIT;
708 status = -EIO; 718 status = -EIO;
709 goto exit; 719 goto exit;
710 } 720 }
@@ -735,20 +745,22 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
735 if (status < 0) 745 if (status < 0)
736 goto exit; 746 goto exit;
737 if (status & STATUSREG_RE) { 747 if (status & STATUSREG_RE) {
738 ca->slot_info[slot].slot_state = 748 sl->slot_state = DVB_CA_SLOTSTATE_LINKINIT;
739 DVB_CA_SLOTSTATE_LINKINIT;
740 status = -EIO; 749 status = -EIO;
741 goto exit; 750 goto exit;
742 } 751 }
743 } 752 }
744 753
745 /* OK, add it to the receive buffer, or copy into external buffer if supplied */ 754 /*
746 if (ebuf == NULL) { 755 * OK, add it to the receive buffer, or copy into external buffer if
747 if (ca->slot_info[slot].rx_buffer.data == NULL) { 756 * supplied
757 */
758 if (!ebuf) {
759 if (!sl->rx_buffer.data) {
748 status = -EIO; 760 status = -EIO;
749 goto exit; 761 goto exit;
750 } 762 }
751 dvb_ringbuffer_pkt_write(&ca->slot_info[slot].rx_buffer, buf, bytes_read); 763 dvb_ringbuffer_pkt_write(&sl->rx_buffer, buf, bytes_read);
752 } else { 764 } else {
753 memcpy(ebuf, buf, bytes_read); 765 memcpy(ebuf, buf, bytes_read);
754 } 766 }
@@ -757,16 +769,15 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot,
757 buf[0], (buf[1] & 0x80) == 0, bytes_read); 769 buf[0], (buf[1] & 0x80) == 0, bytes_read);
758 770
759 /* wake up readers when a last_fragment is received */ 771 /* wake up readers when a last_fragment is received */
760 if ((buf[1] & 0x80) == 0x00) { 772 if ((buf[1] & 0x80) == 0x00)
761 wake_up_interruptible(&ca->wait_queue); 773 wake_up_interruptible(&ca->wait_queue);
762 } 774
763 status = bytes_read; 775 status = bytes_read;
764 776
765exit: 777exit:
766 return status; 778 return status;
767} 779}
768 780
769
770/** 781/**
771 * dvb_ca_en50221_write_data - This function talks to an EN50221 CAM control 782 * dvb_ca_en50221_write_data - This function talks to an EN50221 CAM control
772 * interface. It writes a buffer of data to a CAM. 783 * interface. It writes a buffer of data to a CAM.
@@ -782,25 +793,28 @@ exit:
782static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, 793static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
783 u8 *buf, int bytes_write) 794 u8 *buf, int bytes_write)
784{ 795{
796 struct dvb_ca_slot *sl = &ca->slot_info[slot];
785 int status; 797 int status;
786 int i; 798 int i;
787 799
788 dprintk("%s\n", __func__); 800 dprintk("%s\n", __func__);
789 801
790
791 /* sanity check */ 802 /* sanity check */
792 if (bytes_write > ca->slot_info[slot].link_buf_size) 803 if (bytes_write > sl->link_buf_size)
793 return -EINVAL; 804 return -EINVAL;
794 805
795 if (ca->pub->write_data && 806 if (ca->pub->write_data &&
796 (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_LINKINIT)) 807 (sl->slot_state != DVB_CA_SLOTSTATE_LINKINIT))
797 return ca->pub->write_data(ca->pub, slot, buf, bytes_write); 808 return ca->pub->write_data(ca->pub, slot, buf, bytes_write);
798 809
799 /* it is possible we are dealing with a single buffer implementation, 810 /*
800 thus if there is data available for read or if there is even a read 811 * it is possible we are dealing with a single buffer implementation,
801 already in progress, we do nothing but awake the kernel thread to 812 * thus if there is data available for read or if there is even a read
802 process the data if necessary. */ 813 * already in progress, we do nothing but awake the kernel thread to
803 if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0) 814 * process the data if necessary.
815 */
816 status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
817 if (status < 0)
804 goto exitnowrite; 818 goto exitnowrite;
805 if (status & (STATUSREG_DA | STATUSREG_RE)) { 819 if (status & (STATUSREG_DA | STATUSREG_RE)) {
806 if (status & STATUSREG_DA) 820 if (status & STATUSREG_DA)
@@ -811,12 +825,14 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
811 } 825 }
812 826
813 /* OK, set HC bit */ 827 /* OK, set HC bit */
814 if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, 828 status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
815 IRQEN | CMDREG_HC)) != 0) 829 IRQEN | CMDREG_HC);
830 if (status)
816 goto exit; 831 goto exit;
817 832
818 /* check if interface is still free */ 833 /* check if interface is still free */
819 if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0) 834 status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
835 if (status < 0)
820 goto exit; 836 goto exit;
821 if (!(status & STATUSREG_FR)) { 837 if (!(status & STATUSREG_FR)) {
822 /* it wasn't free => try again later */ 838 /* it wasn't free => try again later */
@@ -848,23 +864,29 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot,
848 } 864 }
849 865
850 /* send the amount of data */ 866 /* send the amount of data */
851 if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH, bytes_write >> 8)) != 0) 867 status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH,
868 bytes_write >> 8);
869 if (status)
852 goto exit; 870 goto exit;
853 if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW, 871 status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW,
854 bytes_write & 0xff)) != 0) 872 bytes_write & 0xff);
873 if (status)
855 goto exit; 874 goto exit;
856 875
857 /* send the buffer */ 876 /* send the buffer */
858 for (i = 0; i < bytes_write; i++) { 877 for (i = 0; i < bytes_write; i++) {
859 if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_DATA, buf[i])) != 0) 878 status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_DATA,
879 buf[i]);
880 if (status)
860 goto exit; 881 goto exit;
861 } 882 }
862 883
863 /* check for write error (WE should now be 0) */ 884 /* check for write error (WE should now be 0) */
864 if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0) 885 status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
886 if (status < 0)
865 goto exit; 887 goto exit;
866 if (status & STATUSREG_WE) { 888 if (status & STATUSREG_WE) {
867 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT; 889 sl->slot_state = DVB_CA_SLOTSTATE_LINKINIT;
868 status = -EIO; 890 status = -EIO;
869 goto exit; 891 goto exit;
870 } 892 }
@@ -880,12 +902,9 @@ exitnowrite:
880 return status; 902 return status;
881} 903}
882 904
883 905/* ************************************************************************** */
884
885/* ******************************************************************************** */
886/* EN50221 higher level functions */ 906/* EN50221 higher level functions */
887 907
888
889/** 908/**
890 * dvb_ca_en50221_slot_shutdown - A CAM has been removed => shut it down. 909 * dvb_ca_en50221_slot_shutdown - A CAM has been removed => shut it down.
891 * 910 *
@@ -899,8 +918,10 @@ static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private *ca, int slot)
899 ca->pub->slot_shutdown(ca->pub, slot); 918 ca->pub->slot_shutdown(ca->pub, slot);
900 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; 919 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
901 920
902 /* need to wake up all processes to check if they're now 921 /*
903 trying to write to a defunct CAM */ 922 * need to wake up all processes to check if they're now trying to
923 * write to a defunct CAM
924 */
904 wake_up_interruptible(&ca->wait_queue); 925 wake_up_interruptible(&ca->wait_queue);
905 926
906 dprintk("Slot %i shutdown\n", slot); 927 dprintk("Slot %i shutdown\n", slot);
@@ -909,7 +930,6 @@ static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private *ca, int slot)
909 return 0; 930 return 0;
910} 931}
911 932
912
913/** 933/**
914 * dvb_ca_en50221_camchange_irq - A CAMCHANGE IRQ has occurred. 934 * dvb_ca_en50221_camchange_irq - A CAMCHANGE IRQ has occurred.
915 * 935 *
@@ -917,9 +937,11 @@ static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private *ca, int slot)
917 * @slot: Slot concerned. 937 * @slot: Slot concerned.
918 * @change_type: One of the DVB_CA_CAMCHANGE_* values. 938 * @change_type: One of the DVB_CA_CAMCHANGE_* values.
919 */ 939 */
920void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot, int change_type) 940void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot,
941 int change_type)
921{ 942{
922 struct dvb_ca_private *ca = pubca->private; 943 struct dvb_ca_private *ca = pubca->private;
944 struct dvb_ca_slot *sl = &ca->slot_info[slot];
923 945
924 dprintk("CAMCHANGE IRQ slot:%i change_type:%i\n", slot, change_type); 946 dprintk("CAMCHANGE IRQ slot:%i change_type:%i\n", slot, change_type);
925 947
@@ -932,13 +954,12 @@ void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot, int ch
932 return; 954 return;
933 } 955 }
934 956
935 ca->slot_info[slot].camchange_type = change_type; 957 sl->camchange_type = change_type;
936 atomic_inc(&ca->slot_info[slot].camchange_count); 958 atomic_inc(&sl->camchange_count);
937 dvb_ca_en50221_thread_wakeup(ca); 959 dvb_ca_en50221_thread_wakeup(ca);
938} 960}
939EXPORT_SYMBOL(dvb_ca_en50221_camchange_irq); 961EXPORT_SYMBOL(dvb_ca_en50221_camchange_irq);
940 962
941
942/** 963/**
943 * dvb_ca_en50221_camready_irq - A CAMREADY IRQ has occurred. 964 * dvb_ca_en50221_camready_irq - A CAMREADY IRQ has occurred.
944 * 965 *
@@ -948,17 +969,17 @@ EXPORT_SYMBOL(dvb_ca_en50221_camchange_irq);
948void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot) 969void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot)
949{ 970{
950 struct dvb_ca_private *ca = pubca->private; 971 struct dvb_ca_private *ca = pubca->private;
972 struct dvb_ca_slot *sl = &ca->slot_info[slot];
951 973
952 dprintk("CAMREADY IRQ slot:%i\n", slot); 974 dprintk("CAMREADY IRQ slot:%i\n", slot);
953 975
954 if (ca->slot_info[slot].slot_state == DVB_CA_SLOTSTATE_WAITREADY) { 976 if (sl->slot_state == DVB_CA_SLOTSTATE_WAITREADY) {
955 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_VALIDATE; 977 sl->slot_state = DVB_CA_SLOTSTATE_VALIDATE;
956 dvb_ca_en50221_thread_wakeup(ca); 978 dvb_ca_en50221_thread_wakeup(ca);
957 } 979 }
958} 980}
959EXPORT_SYMBOL(dvb_ca_en50221_camready_irq); 981EXPORT_SYMBOL(dvb_ca_en50221_camready_irq);
960 982
961
962/** 983/**
963 * dvb_ca_en50221_frda_irq - An FR or DA IRQ has occurred. 984 * dvb_ca_en50221_frda_irq - An FR or DA IRQ has occurred.
964 * 985 *
@@ -968,16 +989,17 @@ EXPORT_SYMBOL(dvb_ca_en50221_camready_irq);
968void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot) 989void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
969{ 990{
970 struct dvb_ca_private *ca = pubca->private; 991 struct dvb_ca_private *ca = pubca->private;
992 struct dvb_ca_slot *sl = &ca->slot_info[slot];
971 int flags; 993 int flags;
972 994
973 dprintk("FR/DA IRQ slot:%i\n", slot); 995 dprintk("FR/DA IRQ slot:%i\n", slot);
974 996
975 switch (ca->slot_info[slot].slot_state) { 997 switch (sl->slot_state) {
976 case DVB_CA_SLOTSTATE_LINKINIT: 998 case DVB_CA_SLOTSTATE_LINKINIT:
977 flags = ca->pub->read_cam_control(pubca, slot, CTRLIF_STATUS); 999 flags = ca->pub->read_cam_control(pubca, slot, CTRLIF_STATUS);
978 if (flags & STATUSREG_DA) { 1000 if (flags & STATUSREG_DA) {
979 dprintk("CAM supports DA IRQ\n"); 1001 dprintk("CAM supports DA IRQ\n");
980 ca->slot_info[slot].da_irq_supported = 1; 1002 sl->da_irq_supported = 1;
981 } 1003 }
982 break; 1004 break;
983 1005
@@ -989,8 +1011,7 @@ void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
989} 1011}
990EXPORT_SYMBOL(dvb_ca_en50221_frda_irq); 1012EXPORT_SYMBOL(dvb_ca_en50221_frda_irq);
991 1013
992 1014/* ************************************************************************** */
993/* ******************************************************************************** */
994/* EN50221 thread functions */ 1015/* EN50221 thread functions */
995 1016
996/** 1017/**
@@ -1000,7 +1021,6 @@ EXPORT_SYMBOL(dvb_ca_en50221_frda_irq);
1000 */ 1021 */
1001static void dvb_ca_en50221_thread_wakeup(struct dvb_ca_private *ca) 1022static void dvb_ca_en50221_thread_wakeup(struct dvb_ca_private *ca)
1002{ 1023{
1003
1004 dprintk("%s\n", __func__); 1024 dprintk("%s\n", __func__);
1005 1025
1006 ca->wakeup = 1; 1026 ca->wakeup = 1;
@@ -1019,11 +1039,14 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
1019 int curdelay = 100000000; 1039 int curdelay = 100000000;
1020 int slot; 1040 int slot;
1021 1041
1022 /* Beware of too high polling frequency, because one polling 1042 /*
1043 * Beware of too high polling frequency, because one polling
1023 * call might take several hundred milliseconds until timeout! 1044 * call might take several hundred milliseconds until timeout!
1024 */ 1045 */
1025 for (slot = 0; slot < ca->slot_count; slot++) { 1046 for (slot = 0; slot < ca->slot_count; slot++) {
1026 switch (ca->slot_info[slot].slot_state) { 1047 struct dvb_ca_slot *sl = &ca->slot_info[slot];
1048
1049 switch (sl->slot_state) {
1027 default: 1050 default:
1028 case DVB_CA_SLOTSTATE_NONE: 1051 case DVB_CA_SLOTSTATE_NONE:
1029 delay = HZ * 60; /* 60s */ 1052 delay = HZ * 60; /* 60s */
@@ -1049,7 +1072,7 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
1049 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) 1072 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE))
1050 delay = HZ / 10; /* 100ms */ 1073 delay = HZ / 10; /* 100ms */
1051 if (ca->open) { 1074 if (ca->open) {
1052 if ((!ca->slot_info[slot].da_irq_supported) || 1075 if ((!sl->da_irq_supported) ||
1053 (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_DA))) 1076 (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_DA)))
1054 delay = HZ / 10; /* 100ms */ 1077 delay = HZ / 10; /* 100ms */
1055 } 1078 }
@@ -1063,215 +1086,250 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
1063 ca->delay = curdelay; 1086 ca->delay = curdelay;
1064} 1087}
1065 1088
1089/**
1090 * Poll if the CAM is gone.
1091 *
1092 * @ca: CA instance.
1093 * @slot: Slot to process.
1094 * @return: 0 .. no change
1095 * 1 .. CAM state changed
1096 */
1066 1097
1098static int dvb_ca_en50221_poll_cam_gone(struct dvb_ca_private *ca, int slot)
1099{
1100 int changed = 0;
1101 int status;
1102
1103 /*
1104 * we need this extra check for annoying interfaces like the
1105 * budget-av
1106 */
1107 if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) &&
1108 (ca->pub->poll_slot_status)) {
1109 status = ca->pub->poll_slot_status(ca->pub, slot, 0);
1110 if (!(status &
1111 DVB_CA_EN50221_POLL_CAM_PRESENT)) {
1112 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
1113 dvb_ca_en50221_thread_update_delay(ca);
1114 changed = 1;
1115 }
1116 }
1117 return changed;
1118}
1067 1119
1068/** 1120/**
1069 * Kernel thread which monitors CA slots for CAM changes, and performs data transfers. 1121 * Thread state machine for one CA slot to perform the data transfer.
1122 *
1123 * @ca: CA instance.
1124 * @slot: Slot to process.
1070 */ 1125 */
1071static int dvb_ca_en50221_thread(void *data) 1126static void dvb_ca_en50221_thread_state_machine(struct dvb_ca_private *ca,
1127 int slot)
1072{ 1128{
1073 struct dvb_ca_private *ca = data; 1129 struct dvb_ca_slot *sl = &ca->slot_info[slot];
1074 int slot;
1075 int flags; 1130 int flags;
1076 int status;
1077 int pktcount; 1131 int pktcount;
1078 void *rxbuf; 1132 void *rxbuf;
1079 1133
1080 dprintk("%s\n", __func__); 1134 mutex_lock(&sl->slot_lock);
1081 1135
1082 /* choose the correct initial delay */ 1136 /* check the cam status + deal with CAMCHANGEs */
1083 dvb_ca_en50221_thread_update_delay(ca); 1137 while (dvb_ca_en50221_check_camstatus(ca, slot)) {
1138 /* clear down an old CI slot if necessary */
1139 if (sl->slot_state != DVB_CA_SLOTSTATE_NONE)
1140 dvb_ca_en50221_slot_shutdown(ca, slot);
1084 1141
1085 /* main loop */ 1142 /* if a CAM is NOW present, initialise it */
1086 while (!kthread_should_stop()) { 1143 if (sl->camchange_type == DVB_CA_EN50221_CAMCHANGE_INSERTED)
1087 /* sleep for a bit */ 1144 sl->slot_state = DVB_CA_SLOTSTATE_UNINITIALISED;
1088 if (!ca->wakeup) { 1145
1089 set_current_state(TASK_INTERRUPTIBLE); 1146 /* we've handled one CAMCHANGE */
1090 schedule_timeout(ca->delay); 1147 dvb_ca_en50221_thread_update_delay(ca);
1091 if (kthread_should_stop()) 1148 atomic_dec(&sl->camchange_count);
1092 return 0; 1149 }
1150
1151 /* CAM state machine */
1152 switch (sl->slot_state) {
1153 case DVB_CA_SLOTSTATE_NONE:
1154 case DVB_CA_SLOTSTATE_INVALID:
1155 /* no action needed */
1156 break;
1157
1158 case DVB_CA_SLOTSTATE_UNINITIALISED:
1159 sl->slot_state = DVB_CA_SLOTSTATE_WAITREADY;
1160 ca->pub->slot_reset(ca->pub, slot);
1161 sl->timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
1162 break;
1163
1164 case DVB_CA_SLOTSTATE_WAITREADY:
1165 if (time_after(jiffies, sl->timeout)) {
1166 pr_err("dvb_ca adaptor %d: PC card did not respond :(\n",
1167 ca->dvbdev->adapter->num);
1168 sl->slot_state = DVB_CA_SLOTSTATE_INVALID;
1169 dvb_ca_en50221_thread_update_delay(ca);
1170 break;
1093 } 1171 }
1094 ca->wakeup = 0; 1172 /*
1173 * no other action needed; will automatically change state when
1174 * ready
1175 */
1176 break;
1095 1177
1096 /* go through all the slots processing them */ 1178 case DVB_CA_SLOTSTATE_VALIDATE:
1097 for (slot = 0; slot < ca->slot_count; slot++) { 1179 if (dvb_ca_en50221_parse_attributes(ca, slot) != 0) {
1180 if (dvb_ca_en50221_poll_cam_gone(ca, slot))
1181 break;
1098 1182
1099 mutex_lock(&ca->slot_info[slot].slot_lock); 1183 pr_err("dvb_ca adapter %d: Invalid PC card inserted :(\n",
1184 ca->dvbdev->adapter->num);
1185 sl->slot_state = DVB_CA_SLOTSTATE_INVALID;
1186 dvb_ca_en50221_thread_update_delay(ca);
1187 break;
1188 }
1189 if (dvb_ca_en50221_set_configoption(ca, slot) != 0) {
1190 pr_err("dvb_ca adapter %d: Unable to initialise CAM :(\n",
1191 ca->dvbdev->adapter->num);
1192 sl->slot_state = DVB_CA_SLOTSTATE_INVALID;
1193 dvb_ca_en50221_thread_update_delay(ca);
1194 break;
1195 }
1196 if (ca->pub->write_cam_control(ca->pub, slot,
1197 CTRLIF_COMMAND,
1198 CMDREG_RS) != 0) {
1199 pr_err("dvb_ca adapter %d: Unable to reset CAM IF\n",
1200 ca->dvbdev->adapter->num);
1201 sl->slot_state = DVB_CA_SLOTSTATE_INVALID;
1202 dvb_ca_en50221_thread_update_delay(ca);
1203 break;
1204 }
1205 dprintk("DVB CAM validated successfully\n");
1100 1206
1101 // check the cam status + deal with CAMCHANGEs 1207 sl->timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
1102 while (dvb_ca_en50221_check_camstatus(ca, slot)) { 1208 sl->slot_state = DVB_CA_SLOTSTATE_WAITFR;
1103 /* clear down an old CI slot if necessary */ 1209 ca->wakeup = 1;
1104 if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE) 1210 break;
1105 dvb_ca_en50221_slot_shutdown(ca, slot);
1106 1211
1107 /* if a CAM is NOW present, initialise it */ 1212 case DVB_CA_SLOTSTATE_WAITFR:
1108 if (ca->slot_info[slot].camchange_type == DVB_CA_EN50221_CAMCHANGE_INSERTED) { 1213 if (time_after(jiffies, sl->timeout)) {
1109 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_UNINITIALISED; 1214 pr_err("dvb_ca adapter %d: DVB CAM did not respond :(\n",
1110 } 1215 ca->dvbdev->adapter->num);
1216 sl->slot_state = DVB_CA_SLOTSTATE_INVALID;
1217 dvb_ca_en50221_thread_update_delay(ca);
1218 break;
1219 }
1111 1220
1112 /* we've handled one CAMCHANGE */ 1221 flags = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
1113 dvb_ca_en50221_thread_update_delay(ca); 1222 if (flags & STATUSREG_FR) {
1114 atomic_dec(&ca->slot_info[slot].camchange_count); 1223 sl->slot_state = DVB_CA_SLOTSTATE_LINKINIT;
1115 } 1224 ca->wakeup = 1;
1225 }
1226 break;
1116 1227
1117 // CAM state machine 1228 case DVB_CA_SLOTSTATE_LINKINIT:
1118 switch (ca->slot_info[slot].slot_state) { 1229 if (dvb_ca_en50221_link_init(ca, slot) != 0) {
1119 case DVB_CA_SLOTSTATE_NONE: 1230 if (dvb_ca_en50221_poll_cam_gone(ca, slot))
1120 case DVB_CA_SLOTSTATE_INVALID:
1121 // no action needed
1122 break; 1231 break;
1123 1232
1124 case DVB_CA_SLOTSTATE_UNINITIALISED: 1233 pr_err("dvb_ca adapter %d: DVB CAM link initialisation failed :(\n",
1125 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_WAITREADY; 1234 ca->dvbdev->adapter->num);
1126 ca->pub->slot_reset(ca->pub, slot); 1235 sl->slot_state = DVB_CA_SLOTSTATE_UNINITIALISED;
1127 ca->slot_info[slot].timeout = jiffies + (INIT_TIMEOUT_SECS * HZ); 1236 dvb_ca_en50221_thread_update_delay(ca);
1128 break; 1237 break;
1238 }
1129 1239
1130 case DVB_CA_SLOTSTATE_WAITREADY: 1240 if (!sl->rx_buffer.data) {
1131 if (time_after(jiffies, ca->slot_info[slot].timeout)) { 1241 rxbuf = vmalloc(RX_BUFFER_SIZE);
1132 pr_err("dvb_ca adaptor %d: PC card did not respond :(\n", 1242 if (!rxbuf) {
1133 ca->dvbdev->adapter->num); 1243 pr_err("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n",
1134 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID; 1244 ca->dvbdev->adapter->num);
1135 dvb_ca_en50221_thread_update_delay(ca); 1245 sl->slot_state = DVB_CA_SLOTSTATE_INVALID;
1136 break; 1246 dvb_ca_en50221_thread_update_delay(ca);
1137 }
1138 // no other action needed; will automatically change state when ready
1139 break; 1247 break;
1248 }
1249 dvb_ringbuffer_init(&sl->rx_buffer, rxbuf,
1250 RX_BUFFER_SIZE);
1251 }
1140 1252
1141 case DVB_CA_SLOTSTATE_VALIDATE: 1253 ca->pub->slot_ts_enable(ca->pub, slot);
1142 if (dvb_ca_en50221_parse_attributes(ca, slot) != 0) { 1254 sl->slot_state = DVB_CA_SLOTSTATE_RUNNING;
1143 /* we need this extra check for annoying interfaces like the budget-av */ 1255 dvb_ca_en50221_thread_update_delay(ca);
1144 if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) && 1256 pr_err("dvb_ca adapter %d: DVB CAM detected and initialised successfully\n",
1145 (ca->pub->poll_slot_status)) { 1257 ca->dvbdev->adapter->num);
1146 status = ca->pub->poll_slot_status(ca->pub, slot, 0); 1258 break;
1147 if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
1148 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
1149 dvb_ca_en50221_thread_update_delay(ca);
1150 break;
1151 }
1152 }
1153
1154 pr_err("dvb_ca adapter %d: Invalid PC card inserted :(\n",
1155 ca->dvbdev->adapter->num);
1156 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1157 dvb_ca_en50221_thread_update_delay(ca);
1158 break;
1159 }
1160 if (dvb_ca_en50221_set_configoption(ca, slot) != 0) {
1161 pr_err("dvb_ca adapter %d: Unable to initialise CAM :(\n",
1162 ca->dvbdev->adapter->num);
1163 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1164 dvb_ca_en50221_thread_update_delay(ca);
1165 break;
1166 }
1167 if (ca->pub->write_cam_control(ca->pub, slot,
1168 CTRLIF_COMMAND, CMDREG_RS) != 0) {
1169 pr_err("dvb_ca adapter %d: Unable to reset CAM IF\n",
1170 ca->dvbdev->adapter->num);
1171 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1172 dvb_ca_en50221_thread_update_delay(ca);
1173 break;
1174 }
1175 dprintk("DVB CAM validated successfully\n");
1176
1177 ca->slot_info[slot].timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
1178 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_WAITFR;
1179 ca->wakeup = 1;
1180 break;
1181 1259
1182 case DVB_CA_SLOTSTATE_WAITFR: 1260 case DVB_CA_SLOTSTATE_RUNNING:
1183 if (time_after(jiffies, ca->slot_info[slot].timeout)) { 1261 if (!ca->open)
1184 pr_err("dvb_ca adapter %d: DVB CAM did not respond :(\n", 1262 break;
1185 ca->dvbdev->adapter->num);
1186 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1187 dvb_ca_en50221_thread_update_delay(ca);
1188 break;
1189 }
1190
1191 flags = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
1192 if (flags & STATUSREG_FR) {
1193 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
1194 ca->wakeup = 1;
1195 }
1196 break;
1197 1263
1198 case DVB_CA_SLOTSTATE_LINKINIT: 1264 /* poll slots for data */
1199 if (dvb_ca_en50221_link_init(ca, slot) != 0) { 1265 pktcount = 0;
1200 /* we need this extra check for annoying interfaces like the budget-av */ 1266 while (dvb_ca_en50221_read_data(ca, slot, NULL, 0) > 0) {
1201 if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) && 1267 if (!ca->open)
1202 (ca->pub->poll_slot_status)) {
1203 status = ca->pub->poll_slot_status(ca->pub, slot, 0);
1204 if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
1205 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
1206 dvb_ca_en50221_thread_update_delay(ca);
1207 break;
1208 }
1209 }
1210
1211 pr_err("dvb_ca adapter %d: DVB CAM link initialisation failed :(\n",
1212 ca->dvbdev->adapter->num);
1213 ca->slot_info[slot].slot_state =
1214 DVB_CA_SLOTSTATE_UNINITIALISED;
1215 dvb_ca_en50221_thread_update_delay(ca);
1216 break;
1217 }
1218
1219 if (ca->slot_info[slot].rx_buffer.data == NULL) {
1220 rxbuf = vmalloc(RX_BUFFER_SIZE);
1221 if (rxbuf == NULL) {
1222 pr_err("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n",
1223 ca->dvbdev->adapter->num);
1224 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1225 dvb_ca_en50221_thread_update_delay(ca);
1226 break;
1227 }
1228 dvb_ringbuffer_init(&ca->slot_info[slot].rx_buffer, rxbuf, RX_BUFFER_SIZE);
1229 }
1230
1231 ca->pub->slot_ts_enable(ca->pub, slot);
1232 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_RUNNING;
1233 dvb_ca_en50221_thread_update_delay(ca);
1234 pr_err("dvb_ca adapter %d: DVB CAM detected and initialised successfully\n",
1235 ca->dvbdev->adapter->num);
1236 break; 1268 break;
1237 1269
1238 case DVB_CA_SLOTSTATE_RUNNING: 1270 /*
1239 if (!ca->open) 1271 * if a CAMCHANGE occurred at some point, do not do any
1240 break; 1272 * more processing of this slot
1241 1273 */
1242 // poll slots for data 1274 if (dvb_ca_en50221_check_camstatus(ca, slot)) {
1243 pktcount = 0; 1275 /*
1244 while ((status = dvb_ca_en50221_read_data(ca, slot, NULL, 0)) > 0) { 1276 * we don't want to sleep on the next iteration
1245 if (!ca->open) 1277 * so we can handle the cam change
1246 break; 1278 */
1247 1279 ca->wakeup = 1;
1248 /* if a CAMCHANGE occurred at some point, do not do any more processing of this slot */
1249 if (dvb_ca_en50221_check_camstatus(ca, slot)) {
1250 // we dont want to sleep on the next iteration so we can handle the cam change
1251 ca->wakeup = 1;
1252 break;
1253 }
1254
1255 /* check if we've hit our limit this time */
1256 if (++pktcount >= MAX_RX_PACKETS_PER_ITERATION) {
1257 // dont sleep; there is likely to be more data to read
1258 ca->wakeup = 1;
1259 break;
1260 }
1261 }
1262 break; 1280 break;
1263 } 1281 }
1264 1282
1265 mutex_unlock(&ca->slot_info[slot].slot_lock); 1283 /* check if we've hit our limit this time */
1284 if (++pktcount >= MAX_RX_PACKETS_PER_ITERATION) {
1285 /*
1286 * don't sleep; there is likely to be more data
1287 * to read
1288 */
1289 ca->wakeup = 1;
1290 break;
1291 }
1266 } 1292 }
1293 break;
1267 } 1294 }
1268 1295
1269 return 0; 1296 mutex_unlock(&sl->slot_lock);
1270} 1297}
1271 1298
1299/**
1300 * Kernel thread which monitors CA slots for CAM changes, and performs data
1301 * transfers.
1302 */
1303static int dvb_ca_en50221_thread(void *data)
1304{
1305 struct dvb_ca_private *ca = data;
1306 int slot;
1307
1308 dprintk("%s\n", __func__);
1309
1310 /* choose the correct initial delay */
1311 dvb_ca_en50221_thread_update_delay(ca);
1312
1313 /* main loop */
1314 while (!kthread_should_stop()) {
1315 /* sleep for a bit */
1316 if (!ca->wakeup) {
1317 set_current_state(TASK_INTERRUPTIBLE);
1318 schedule_timeout(ca->delay);
1319 if (kthread_should_stop())
1320 return 0;
1321 }
1322 ca->wakeup = 0;
1323
1324 /* go through all the slots processing them */
1325 for (slot = 0; slot < ca->slot_count; slot++)
1326 dvb_ca_en50221_thread_state_machine(ca, slot);
1327 }
1272 1328
1329 return 0;
1330}
1273 1331
1274/* ******************************************************************************** */ 1332/* ************************************************************************** */
1275/* EN50221 IO interface functions */ 1333/* EN50221 IO interface functions */
1276 1334
1277/** 1335/**
@@ -1301,15 +1359,17 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file,
1301 switch (cmd) { 1359 switch (cmd) {
1302 case CA_RESET: 1360 case CA_RESET:
1303 for (slot = 0; slot < ca->slot_count; slot++) { 1361 for (slot = 0; slot < ca->slot_count; slot++) {
1304 mutex_lock(&ca->slot_info[slot].slot_lock); 1362 struct dvb_ca_slot *sl = &ca->slot_info[slot];
1305 if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE) { 1363
1364 mutex_lock(&sl->slot_lock);
1365 if (sl->slot_state != DVB_CA_SLOTSTATE_NONE) {
1306 dvb_ca_en50221_slot_shutdown(ca, slot); 1366 dvb_ca_en50221_slot_shutdown(ca, slot);
1307 if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE) 1367 if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)
1308 dvb_ca_en50221_camchange_irq(ca->pub, 1368 dvb_ca_en50221_camchange_irq(ca->pub,
1309 slot, 1369 slot,
1310 DVB_CA_EN50221_CAMCHANGE_INSERTED); 1370 DVB_CA_EN50221_CAMCHANGE_INSERTED);
1311 } 1371 }
1312 mutex_unlock(&ca->slot_info[slot].slot_lock); 1372 mutex_unlock(&sl->slot_lock);
1313 } 1373 }
1314 ca->next_read_slot = 0; 1374 ca->next_read_slot = 0;
1315 dvb_ca_en50221_thread_wakeup(ca); 1375 dvb_ca_en50221_thread_wakeup(ca);
@@ -1327,21 +1387,23 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file,
1327 1387
1328 case CA_GET_SLOT_INFO: { 1388 case CA_GET_SLOT_INFO: {
1329 struct ca_slot_info *info = parg; 1389 struct ca_slot_info *info = parg;
1390 struct dvb_ca_slot *sl;
1330 1391
1331 if ((info->num > ca->slot_count) || (info->num < 0)) { 1392 slot = info->num;
1393 if ((slot > ca->slot_count) || (slot < 0)) {
1332 err = -EINVAL; 1394 err = -EINVAL;
1333 goto out_unlock; 1395 goto out_unlock;
1334 } 1396 }
1335 1397
1336 info->type = CA_CI_LINK; 1398 info->type = CA_CI_LINK;
1337 info->flags = 0; 1399 info->flags = 0;
1338 if ((ca->slot_info[info->num].slot_state != DVB_CA_SLOTSTATE_NONE) 1400 sl = &ca->slot_info[slot];
1339 && (ca->slot_info[info->num].slot_state != DVB_CA_SLOTSTATE_INVALID)) { 1401 if ((sl->slot_state != DVB_CA_SLOTSTATE_NONE) &&
1402 (sl->slot_state != DVB_CA_SLOTSTATE_INVALID)) {
1340 info->flags = CA_CI_MODULE_PRESENT; 1403 info->flags = CA_CI_MODULE_PRESENT;
1341 } 1404 }
1342 if (ca->slot_info[info->num].slot_state == DVB_CA_SLOTSTATE_RUNNING) { 1405 if (sl->slot_state == DVB_CA_SLOTSTATE_RUNNING)
1343 info->flags |= CA_CI_MODULE_READY; 1406 info->flags |= CA_CI_MODULE_READY;
1344 }
1345 break; 1407 break;
1346 } 1408 }
1347 1409
@@ -1355,7 +1417,6 @@ out_unlock:
1355 return err; 1417 return err;
1356} 1418}
1357 1419
1358
1359/** 1420/**
1360 * Wrapper for ioctl implementation. 1421 * Wrapper for ioctl implementation.
1361 * 1422 *
@@ -1372,7 +1433,6 @@ static long dvb_ca_en50221_io_ioctl(struct file *file,
1372 return dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl); 1433 return dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
1373} 1434}
1374 1435
1375
1376/** 1436/**
1377 * Implementation of write() syscall. 1437 * Implementation of write() syscall.
1378 * 1438 *
@@ -1389,6 +1449,7 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
1389{ 1449{
1390 struct dvb_device *dvbdev = file->private_data; 1450 struct dvb_device *dvbdev = file->private_data;
1391 struct dvb_ca_private *ca = dvbdev->priv; 1451 struct dvb_ca_private *ca = dvbdev->priv;
1452 struct dvb_ca_slot *sl;
1392 u8 slot, connection_id; 1453 u8 slot, connection_id;
1393 int status; 1454 int status;
1394 u8 fragbuf[HOST_LINK_BUF_SIZE]; 1455 u8 fragbuf[HOST_LINK_BUF_SIZE];
@@ -1399,7 +1460,10 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
1399 1460
1400 dprintk("%s\n", __func__); 1461 dprintk("%s\n", __func__);
1401 1462
1402 /* Incoming packet has a 2 byte header. hdr[0] = slot_id, hdr[1] = connection_id */ 1463 /*
1464 * Incoming packet has a 2 byte header.
1465 * hdr[0] = slot_id, hdr[1] = connection_id
1466 */
1403 if (count < 2) 1467 if (count < 2)
1404 return -EINVAL; 1468 return -EINVAL;
1405 1469
@@ -1410,14 +1474,15 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
1410 return -EFAULT; 1474 return -EFAULT;
1411 buf += 2; 1475 buf += 2;
1412 count -= 2; 1476 count -= 2;
1477 sl = &ca->slot_info[slot];
1413 1478
1414 /* check if the slot is actually running */ 1479 /* check if the slot is actually running */
1415 if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING) 1480 if (sl->slot_state != DVB_CA_SLOTSTATE_RUNNING)
1416 return -EINVAL; 1481 return -EINVAL;
1417 1482
1418 /* fragment the packets & store in the buffer */ 1483 /* fragment the packets & store in the buffer */
1419 while (fragpos < count) { 1484 while (fragpos < count) {
1420 fraglen = ca->slot_info[slot].link_buf_size - 2; 1485 fraglen = sl->link_buf_size - 2;
1421 if (fraglen < 0) 1486 if (fraglen < 0)
1422 break; 1487 break;
1423 if (fraglen > HOST_LINK_BUF_SIZE - 2) 1488 if (fraglen > HOST_LINK_BUF_SIZE - 2)
@@ -1436,15 +1501,19 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
1436 timeout = jiffies + HZ / 2; 1501 timeout = jiffies + HZ / 2;
1437 written = 0; 1502 written = 0;
1438 while (!time_after(jiffies, timeout)) { 1503 while (!time_after(jiffies, timeout)) {
1439 /* check the CAM hasn't been removed/reset in the meantime */ 1504 /*
1440 if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING) { 1505 * check the CAM hasn't been removed/reset in the
1506 * meantime
1507 */
1508 if (sl->slot_state != DVB_CA_SLOTSTATE_RUNNING) {
1441 status = -EIO; 1509 status = -EIO;
1442 goto exit; 1510 goto exit;
1443 } 1511 }
1444 1512
1445 mutex_lock(&ca->slot_info[slot].slot_lock); 1513 mutex_lock(&sl->slot_lock);
1446 status = dvb_ca_en50221_write_data(ca, slot, fragbuf, fraglen + 2); 1514 status = dvb_ca_en50221_write_data(ca, slot, fragbuf,
1447 mutex_unlock(&ca->slot_info[slot].slot_lock); 1515 fraglen + 2);
1516 mutex_unlock(&sl->slot_lock);
1448 if (status == (fraglen + 2)) { 1517 if (status == (fraglen + 2)) {
1449 written = 1; 1518 written = 1;
1450 break; 1519 break;
@@ -1452,7 +1521,7 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
1452 if (status != -EAGAIN) 1521 if (status != -EAGAIN)
1453 goto exit; 1522 goto exit;
1454 1523
1455 msleep(1); 1524 usleep_range(1000, 1100);
1456 } 1525 }
1457 if (!written) { 1526 if (!written) {
1458 status = -EIO; 1527 status = -EIO;
@@ -1467,7 +1536,6 @@ exit:
1467 return status; 1536 return status;
1468} 1537}
1469 1538
1470
1471/** 1539/**
1472 * Condition for waking up in dvb_ca_en50221_io_read_condition 1540 * Condition for waking up in dvb_ca_en50221_io_read_condition
1473 */ 1541 */
@@ -1484,25 +1552,28 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca,
1484 1552
1485 slot = ca->next_read_slot; 1553 slot = ca->next_read_slot;
1486 while ((slot_count < ca->slot_count) && (!found)) { 1554 while ((slot_count < ca->slot_count) && (!found)) {
1487 if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING) 1555 struct dvb_ca_slot *sl = &ca->slot_info[slot];
1556
1557 if (sl->slot_state != DVB_CA_SLOTSTATE_RUNNING)
1488 goto nextslot; 1558 goto nextslot;
1489 1559
1490 if (ca->slot_info[slot].rx_buffer.data == NULL) { 1560 if (!sl->rx_buffer.data)
1491 return 0; 1561 return 0;
1492 }
1493 1562
1494 idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, -1, &fraglen); 1563 idx = dvb_ringbuffer_pkt_next(&sl->rx_buffer, -1, &fraglen);
1495 while (idx != -1) { 1564 while (idx != -1) {
1496 dvb_ringbuffer_pkt_read(&ca->slot_info[slot].rx_buffer, idx, 0, hdr, 2); 1565 dvb_ringbuffer_pkt_read(&sl->rx_buffer, idx, 0, hdr, 2);
1497 if (connection_id == -1) 1566 if (connection_id == -1)
1498 connection_id = hdr[0]; 1567 connection_id = hdr[0];
1499 if ((hdr[0] == connection_id) && ((hdr[1] & 0x80) == 0)) { 1568 if ((hdr[0] == connection_id) &&
1569 ((hdr[1] & 0x80) == 0)) {
1500 *_slot = slot; 1570 *_slot = slot;
1501 found = 1; 1571 found = 1;
1502 break; 1572 break;
1503 } 1573 }
1504 1574
1505 idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen); 1575 idx = dvb_ringbuffer_pkt_next(&sl->rx_buffer, idx,
1576 &fraglen);
1506 } 1577 }
1507 1578
1508nextslot: 1579nextslot:
@@ -1514,7 +1585,6 @@ nextslot:
1514 return found; 1585 return found;
1515} 1586}
1516 1587
1517
1518/** 1588/**
1519 * Implementation of read() syscall. 1589 * Implementation of read() syscall.
1520 * 1590 *
@@ -1530,6 +1600,7 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf,
1530{ 1600{
1531 struct dvb_device *dvbdev = file->private_data; 1601 struct dvb_device *dvbdev = file->private_data;
1532 struct dvb_ca_private *ca = dvbdev->priv; 1602 struct dvb_ca_private *ca = dvbdev->priv;
1603 struct dvb_ca_slot *sl;
1533 int status; 1604 int status;
1534 int result = 0; 1605 int result = 0;
1535 u8 hdr[2]; 1606 u8 hdr[2];
@@ -1543,13 +1614,16 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf,
1543 1614
1544 dprintk("%s\n", __func__); 1615 dprintk("%s\n", __func__);
1545 1616
1546 /* Outgoing packet has a 2 byte header. hdr[0] = slot_id, hdr[1] = connection_id */ 1617 /*
1618 * Outgoing packet has a 2 byte header.
1619 * hdr[0] = slot_id, hdr[1] = connection_id
1620 */
1547 if (count < 2) 1621 if (count < 2)
1548 return -EINVAL; 1622 return -EINVAL;
1549 1623
1550 /* wait for some data */ 1624 /* wait for some data */
1551 if ((status = dvb_ca_en50221_io_read_condition(ca, &result, &slot)) == 0) { 1625 status = dvb_ca_en50221_io_read_condition(ca, &result, &slot);
1552 1626 if (status == 0) {
1553 /* if we're in nonblocking mode, exit immediately */ 1627 /* if we're in nonblocking mode, exit immediately */
1554 if (file->f_flags & O_NONBLOCK) 1628 if (file->f_flags & O_NONBLOCK)
1555 return -EWOULDBLOCK; 1629 return -EWOULDBLOCK;
@@ -1565,7 +1639,8 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf,
1565 return status; 1639 return status;
1566 } 1640 }
1567 1641
1568 idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, -1, &fraglen); 1642 sl = &ca->slot_info[slot];
1643 idx = dvb_ringbuffer_pkt_next(&sl->rx_buffer, -1, &fraglen);
1569 pktlen = 2; 1644 pktlen = 2;
1570 do { 1645 do {
1571 if (idx == -1) { 1646 if (idx == -1) {
@@ -1575,21 +1650,24 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf,
1575 goto exit; 1650 goto exit;
1576 } 1651 }
1577 1652
1578 dvb_ringbuffer_pkt_read(&ca->slot_info[slot].rx_buffer, idx, 0, hdr, 2); 1653 dvb_ringbuffer_pkt_read(&sl->rx_buffer, idx, 0, hdr, 2);
1579 if (connection_id == -1) 1654 if (connection_id == -1)
1580 connection_id = hdr[0]; 1655 connection_id = hdr[0];
1581 if (hdr[0] == connection_id) { 1656 if (hdr[0] == connection_id) {
1582 if (pktlen < count) { 1657 if (pktlen < count) {
1583 if ((pktlen + fraglen - 2) > count) { 1658 if ((pktlen + fraglen - 2) > count)
1584 fraglen = count - pktlen; 1659 fraglen = count - pktlen;
1585 } else { 1660 else
1586 fraglen -= 2; 1661 fraglen -= 2;
1587 }
1588 1662
1589 if ((status = dvb_ringbuffer_pkt_read_user(&ca->slot_info[slot].rx_buffer, idx, 2, 1663 status =
1590 buf + pktlen, fraglen)) < 0) { 1664 dvb_ringbuffer_pkt_read_user(&sl->rx_buffer,
1665 idx, 2,
1666 buf + pktlen,
1667 fraglen);
1668 if (status < 0)
1591 goto exit; 1669 goto exit;
1592 } 1670
1593 pktlen += fraglen; 1671 pktlen += fraglen;
1594 } 1672 }
1595 1673
@@ -1598,9 +1676,9 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user *buf,
1598 dispose = 1; 1676 dispose = 1;
1599 } 1677 }
1600 1678
1601 idx2 = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen); 1679 idx2 = dvb_ringbuffer_pkt_next(&sl->rx_buffer, idx, &fraglen);
1602 if (dispose) 1680 if (dispose)
1603 dvb_ringbuffer_pkt_dispose(&ca->slot_info[slot].rx_buffer, idx); 1681 dvb_ringbuffer_pkt_dispose(&sl->rx_buffer, idx);
1604 idx = idx2; 1682 idx = idx2;
1605 dispose = 0; 1683 dispose = 0;
1606 } while (!last_fragment); 1684 } while (!last_fragment);
@@ -1618,7 +1696,6 @@ exit:
1618 return status; 1696 return status;
1619} 1697}
1620 1698
1621
1622/** 1699/**
1623 * Implementation of file open syscall. 1700 * Implementation of file open syscall.
1624 * 1701 *
@@ -1646,12 +1723,16 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
1646 } 1723 }
1647 1724
1648 for (i = 0; i < ca->slot_count; i++) { 1725 for (i = 0; i < ca->slot_count; i++) {
1649 1726 struct dvb_ca_slot *sl = &ca->slot_info[i];
1650 if (ca->slot_info[i].slot_state == DVB_CA_SLOTSTATE_RUNNING) { 1727
1651 if (ca->slot_info[i].rx_buffer.data != NULL) { 1728 if (sl->slot_state == DVB_CA_SLOTSTATE_RUNNING) {
1652 /* it is safe to call this here without locks because 1729 if (!sl->rx_buffer.data) {
1653 * ca->open == 0. Data is not read in this case */ 1730 /*
1654 dvb_ringbuffer_flush(&ca->slot_info[i].rx_buffer); 1731 * it is safe to call this here without locks
1732 * because ca->open == 0. Data is not read in
1733 * this case
1734 */
1735 dvb_ringbuffer_flush(&sl->rx_buffer);
1655 } 1736 }
1656 } 1737 }
1657 } 1738 }
@@ -1665,7 +1746,6 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
1665 return 0; 1746 return 0;
1666} 1747}
1667 1748
1668
1669/** 1749/**
1670 * Implementation of file close syscall. 1750 * Implementation of file close syscall.
1671 * 1751 *
@@ -1695,7 +1775,6 @@ static int dvb_ca_en50221_io_release(struct inode *inode, struct file *file)
1695 return err; 1775 return err;
1696} 1776}
1697 1777
1698
1699/** 1778/**
1700 * Implementation of poll() syscall. 1779 * Implementation of poll() syscall.
1701 * 1780 *
@@ -1714,9 +1793,8 @@ static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table *wait)
1714 1793
1715 dprintk("%s\n", __func__); 1794 dprintk("%s\n", __func__);
1716 1795
1717 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) { 1796 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1)
1718 mask |= POLLIN; 1797 mask |= POLLIN;
1719 }
1720 1798
1721 /* if there is something, return now */ 1799 /* if there is something, return now */
1722 if (mask) 1800 if (mask)
@@ -1725,14 +1803,11 @@ static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table *wait)
1725 /* wait for something to happen */ 1803 /* wait for something to happen */
1726 poll_wait(file, &ca->wait_queue, wait); 1804 poll_wait(file, &ca->wait_queue, wait);
1727 1805
1728 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) { 1806 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1)
1729 mask |= POLLIN; 1807 mask |= POLLIN;
1730 }
1731 1808
1732 return mask; 1809 return mask;
1733} 1810}
1734EXPORT_SYMBOL(dvb_ca_en50221_init);
1735
1736 1811
1737static const struct file_operations dvb_ca_fops = { 1812static const struct file_operations dvb_ca_fops = {
1738 .owner = THIS_MODULE, 1813 .owner = THIS_MODULE,
@@ -1756,10 +1831,9 @@ static const struct dvb_device dvbdev_ca = {
1756 .fops = &dvb_ca_fops, 1831 .fops = &dvb_ca_fops,
1757}; 1832};
1758 1833
1759/* ******************************************************************************** */ 1834/* ************************************************************************** */
1760/* Initialisation/shutdown functions */ 1835/* Initialisation/shutdown functions */
1761 1836
1762
1763/** 1837/**
1764 * Initialise a new DVB CA EN50221 interface device. 1838 * Initialise a new DVB CA EN50221 interface device.
1765 * 1839 *
@@ -1783,7 +1857,8 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
1783 return -EINVAL; 1857 return -EINVAL;
1784 1858
1785 /* initialise the system data */ 1859 /* initialise the system data */
1786 if ((ca = kzalloc(sizeof(struct dvb_ca_private), GFP_KERNEL)) == NULL) { 1860 ca = kzalloc(sizeof(*ca), GFP_KERNEL);
1861 if (!ca) {
1787 ret = -ENOMEM; 1862 ret = -ENOMEM;
1788 goto exit; 1863 goto exit;
1789 } 1864 }
@@ -1791,7 +1866,9 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
1791 ca->pub = pubca; 1866 ca->pub = pubca;
1792 ca->flags = flags; 1867 ca->flags = flags;
1793 ca->slot_count = slot_count; 1868 ca->slot_count = slot_count;
1794 if ((ca->slot_info = kcalloc(slot_count, sizeof(struct dvb_ca_slot), GFP_KERNEL)) == NULL) { 1869 ca->slot_info = kcalloc(slot_count, sizeof(struct dvb_ca_slot),
1870 GFP_KERNEL);
1871 if (!ca->slot_info) {
1795 ret = -ENOMEM; 1872 ret = -ENOMEM;
1796 goto free_ca; 1873 goto free_ca;
1797 } 1874 }
@@ -1802,17 +1879,20 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
1802 pubca->private = ca; 1879 pubca->private = ca;
1803 1880
1804 /* register the DVB device */ 1881 /* register the DVB device */
1805 ret = dvb_register_device(dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca, DVB_DEVICE_CA, 0); 1882 ret = dvb_register_device(dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca,
1883 DVB_DEVICE_CA, 0);
1806 if (ret) 1884 if (ret)
1807 goto free_slot_info; 1885 goto free_slot_info;
1808 1886
1809 /* now initialise each slot */ 1887 /* now initialise each slot */
1810 for (i = 0; i < slot_count; i++) { 1888 for (i = 0; i < slot_count; i++) {
1811 memset(&ca->slot_info[i], 0, sizeof(struct dvb_ca_slot)); 1889 struct dvb_ca_slot *sl = &ca->slot_info[i];
1812 ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE; 1890
1813 atomic_set(&ca->slot_info[i].camchange_count, 0); 1891 memset(sl, 0, sizeof(struct dvb_ca_slot));
1814 ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED; 1892 sl->slot_state = DVB_CA_SLOTSTATE_NONE;
1815 mutex_init(&ca->slot_info[i].slot_lock); 1893 atomic_set(&sl->camchange_count, 0);
1894 sl->camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
1895 mutex_init(&sl->slot_lock);
1816 } 1896 }
1817 1897
1818 mutex_init(&ca->ioctl_mutex); 1898 mutex_init(&ca->ioctl_mutex);
@@ -1844,9 +1924,7 @@ exit:
1844 pubca->private = NULL; 1924 pubca->private = NULL;
1845 return ret; 1925 return ret;
1846} 1926}
1847EXPORT_SYMBOL(dvb_ca_en50221_release); 1927EXPORT_SYMBOL(dvb_ca_en50221_init);
1848
1849
1850 1928
1851/** 1929/**
1852 * Release a DVB CA EN50221 interface device. 1930 * Release a DVB CA EN50221 interface device.
@@ -1864,10 +1942,11 @@ void dvb_ca_en50221_release(struct dvb_ca_en50221 *pubca)
1864 /* shutdown the thread if there was one */ 1942 /* shutdown the thread if there was one */
1865 kthread_stop(ca->thread); 1943 kthread_stop(ca->thread);
1866 1944
1867 for (i = 0; i < ca->slot_count; i++) { 1945 for (i = 0; i < ca->slot_count; i++)
1868 dvb_ca_en50221_slot_shutdown(ca, i); 1946 dvb_ca_en50221_slot_shutdown(ca, i);
1869 } 1947
1870 dvb_remove_device(ca->dvbdev); 1948 dvb_remove_device(ca->dvbdev);
1871 dvb_ca_private_put(ca); 1949 dvb_ca_private_put(ca);
1872 pubca->private = NULL; 1950 pubca->private = NULL;
1873} 1951}
1952EXPORT_SYMBOL(dvb_ca_en50221_release);
diff --git a/drivers/media/dvb-core/dvb_ca_en50221.h b/drivers/media/dvb-core/dvb_ca_en50221.h
index 82617bac0875..367687d2b41a 100644
--- a/drivers/media/dvb-core/dvb_ca_en50221.h
+++ b/drivers/media/dvb-core/dvb_ca_en50221.h
@@ -69,9 +69,9 @@ struct dvb_ca_en50221 {
69 int slot, u8 address, u8 value); 69 int slot, u8 address, u8 value);
70 70
71 int (*read_data)(struct dvb_ca_en50221 *ca, 71 int (*read_data)(struct dvb_ca_en50221 *ca,
72 int slot, u8 *ebuf, int ecount); 72 int slot, u8 *ebuf, int ecount);
73 int (*write_data)(struct dvb_ca_en50221 *ca, 73 int (*write_data)(struct dvb_ca_en50221 *ca,
74 int slot, u8 *ebuf, int ecount); 74 int slot, u8 *ebuf, int ecount);
75 75
76 int (*slot_reset)(struct dvb_ca_en50221 *ca, int slot); 76 int (*slot_reset)(struct dvb_ca_en50221 *ca, int slot);
77 int (*slot_shutdown)(struct dvb_ca_en50221 *ca, int slot); 77 int (*slot_shutdown)(struct dvb_ca_en50221 *ca, int slot);
@@ -128,8 +128,8 @@ void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *ca, int slot);
128 * 128 *
129 * @return 0 on success, nonzero on failure 129 * @return 0 on success, nonzero on failure
130 */ 130 */
131extern int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, 131int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
132 struct dvb_ca_en50221 *ca, int flags, 132 struct dvb_ca_en50221 *ca, int flags,
133 int slot_count); 133 int slot_count);
134 134
135/** 135/**
@@ -137,6 +137,6 @@ extern int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
137 * 137 *
138 * @ca: The associated dvb_ca instance. 138 * @ca: The associated dvb_ca instance.
139 */ 139 */
140extern void dvb_ca_en50221_release(struct dvb_ca_en50221 *ca); 140void dvb_ca_en50221_release(struct dvb_ca_en50221 *ca);
141 141
142#endif 142#endif
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index e3fff8f64d37..2fcba1616168 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -460,7 +460,7 @@ static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wra
460 460
461static void dvb_frontend_swzigzag(struct dvb_frontend *fe) 461static void dvb_frontend_swzigzag(struct dvb_frontend *fe)
462{ 462{
463 enum fe_status s = 0; 463 enum fe_status s = FE_NONE;
464 int retval = 0; 464 int retval = 0;
465 struct dvb_frontend_private *fepriv = fe->frontend_priv; 465 struct dvb_frontend_private *fepriv = fe->frontend_priv;
466 struct dtv_frontend_properties *c = &fe->dtv_property_cache, tmp; 466 struct dtv_frontend_properties *c = &fe->dtv_property_cache, tmp;
@@ -631,7 +631,7 @@ static int dvb_frontend_thread(void *data)
631 struct dvb_frontend *fe = data; 631 struct dvb_frontend *fe = data;
632 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 632 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
633 struct dvb_frontend_private *fepriv = fe->frontend_priv; 633 struct dvb_frontend_private *fepriv = fe->frontend_priv;
634 enum fe_status s; 634 enum fe_status s = FE_NONE;
635 enum dvbfe_algo algo; 635 enum dvbfe_algo algo;
636 bool re_tune = false; 636 bool re_tune = false;
637 bool semheld = false; 637 bool semheld = false;
@@ -1000,6 +1000,17 @@ static int dvb_frontend_clear_cache(struct dvb_frontend *fe)
1000 .buffer = b \ 1000 .buffer = b \
1001} 1001}
1002 1002
1003struct dtv_cmds_h {
1004 char *name; /* A display name for debugging purposes */
1005
1006 __u32 cmd; /* A unique ID */
1007
1008 /* Flags */
1009 __u32 set:1; /* Either a set or get property */
1010 __u32 buffer:1; /* Does this property use the buffer? */
1011 __u32 reserved:30; /* Align */
1012};
1013
1003static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = { 1014static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = {
1004 _DTV_CMD(DTV_TUNE, 1, 0), 1015 _DTV_CMD(DTV_TUNE, 1, 0),
1005 _DTV_CMD(DTV_CLEAR, 1, 0), 1016 _DTV_CMD(DTV_CLEAR, 1, 0),
diff --git a/drivers/media/dvb-frontends/Kconfig b/drivers/media/dvb-frontends/Kconfig
index 3a260b82b3e8..2631d0e0a024 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -28,6 +28,15 @@ config DVB_STV090x
28 DVB-S/S2/DSS Multistandard Professional/Broadcast demodulators. 28 DVB-S/S2/DSS Multistandard Professional/Broadcast demodulators.
29 Say Y when you want to support these frontends. 29 Say Y when you want to support these frontends.
30 30
31config DVB_STV0910
32 tristate "STV0910 based"
33 depends on DVB_CORE && I2C
34 default m if !MEDIA_SUBDRV_AUTOSELECT
35 help
36 ST STV0910 DVB-S/S2 demodulator driver.
37
38 Say Y when you want to support these frontends.
39
31config DVB_STV6110x 40config DVB_STV6110x
32 tristate "STV6110/(A) based tuners" 41 tristate "STV6110/(A) based tuners"
33 depends on DVB_CORE && I2C 42 depends on DVB_CORE && I2C
@@ -35,6 +44,24 @@ config DVB_STV6110x
35 help 44 help
36 A Silicon tuner that supports DVB-S and DVB-S2 modes 45 A Silicon tuner that supports DVB-S and DVB-S2 modes
37 46
47config DVB_STV6111
48 tristate "STV6111 based tuners"
49 depends on DVB_CORE && I2C
50 default m if !MEDIA_SUBDRV_AUTOSELECT
51 help
52 A Silicon tuner that supports DVB-S and DVB-S2 modes
53
54 Say Y when you want to support these frontends.
55
56config DVB_MXL5XX
57 tristate "MaxLinear MxL5xx based tuner-demodulators"
58 depends on DVB_CORE && I2C
59 default m if !MEDIA_SUBDRV_AUTOSELECT
60 help
61 MaxLinear MxL5xx family of DVB-S/S2 tuners/demodulators.
62
63 Say Y when you want to support these frontends.
64
38config DVB_M88DS3103 65config DVB_M88DS3103
39 tristate "Montage Technology M88DS3103" 66 tristate "Montage Technology M88DS3103"
40 depends on DVB_CORE && I2C && I2C_MUX 67 depends on DVB_CORE && I2C && I2C_MUX
diff --git a/drivers/media/dvb-frontends/Makefile b/drivers/media/dvb-frontends/Makefile
index 3fccaf34ef52..f45f6a4a4371 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -110,6 +110,9 @@ obj-$(CONFIG_DVB_CXD2820R) += cxd2820r.o
110obj-$(CONFIG_DVB_CXD2841ER) += cxd2841er.o 110obj-$(CONFIG_DVB_CXD2841ER) += cxd2841er.o
111obj-$(CONFIG_DVB_DRXK) += drxk.o 111obj-$(CONFIG_DVB_DRXK) += drxk.o
112obj-$(CONFIG_DVB_TDA18271C2DD) += tda18271c2dd.o 112obj-$(CONFIG_DVB_TDA18271C2DD) += tda18271c2dd.o
113obj-$(CONFIG_DVB_STV0910) += stv0910.o
114obj-$(CONFIG_DVB_STV6111) += stv6111.o
115obj-$(CONFIG_DVB_MXL5XX) += mxl5xx.o
113obj-$(CONFIG_DVB_SI2165) += si2165.o 116obj-$(CONFIG_DVB_SI2165) += si2165.o
114obj-$(CONFIG_DVB_A8293) += a8293.o 117obj-$(CONFIG_DVB_A8293) += a8293.o
115obj-$(CONFIG_DVB_SP2) += sp2.o 118obj-$(CONFIG_DVB_SP2) += sp2.o
diff --git a/drivers/media/dvb-frontends/cx24123.c b/drivers/media/dvb-frontends/cx24123.c
index 4ae3d922a8e8..1d59d1d3bd82 100644
--- a/drivers/media/dvb-frontends/cx24123.c
+++ b/drivers/media/dvb-frontends/cx24123.c
@@ -1032,7 +1032,7 @@ static u32 cx24123_tuner_i2c_func(struct i2c_adapter *adapter)
1032 return I2C_FUNC_I2C; 1032 return I2C_FUNC_I2C;
1033} 1033}
1034 1034
1035static struct i2c_algorithm cx24123_tuner_i2c_algo = { 1035static const struct i2c_algorithm cx24123_tuner_i2c_algo = {
1036 .master_xfer = cx24123_tuner_i2c_tuner_xfer, 1036 .master_xfer = cx24123_tuner_i2c_tuner_xfer,
1037 .functionality = cx24123_tuner_i2c_func, 1037 .functionality = cx24123_tuner_i2c_func,
1038}; 1038};
diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c
index 12bff778c97f..48ee9bc00c06 100644
--- a/drivers/media/dvb-frontends/cxd2841er.c
+++ b/drivers/media/dvb-frontends/cxd2841er.c
@@ -487,6 +487,8 @@ static int cxd2841er_sleep_tc_to_shutdown(struct cxd2841er_priv *priv);
487 487
488static int cxd2841er_shutdown_to_sleep_tc(struct cxd2841er_priv *priv); 488static int cxd2841er_shutdown_to_sleep_tc(struct cxd2841er_priv *priv);
489 489
490static int cxd2841er_sleep_tc(struct dvb_frontend *fe);
491
490static int cxd2841er_retune_active(struct cxd2841er_priv *priv, 492static int cxd2841er_retune_active(struct cxd2841er_priv *priv,
491 struct dtv_frontend_properties *p) 493 struct dtv_frontend_properties *p)
492{ 494{
@@ -2178,42 +2180,42 @@ static int cxd2841er_sleep_tc_to_active_t2_band(struct cxd2841er_priv *priv,
2178 u32 iffreq, ifhz; 2180 u32 iffreq, ifhz;
2179 u8 data[MAX_WRITE_REGSIZE]; 2181 u8 data[MAX_WRITE_REGSIZE];
2180 2182
2181 const uint8_t nominalRate8bw[3][5] = { 2183 static const uint8_t nominalRate8bw[3][5] = {
2182 /* TRCG Nominal Rate [37:0] */ 2184 /* TRCG Nominal Rate [37:0] */
2183 {0x11, 0xF0, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */ 2185 {0x11, 0xF0, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */
2184 {0x15, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */ 2186 {0x15, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2185 {0x11, 0xF0, 0x00, 0x00, 0x00} /* 41MHz XTal */ 2187 {0x11, 0xF0, 0x00, 0x00, 0x00} /* 41MHz XTal */
2186 }; 2188 };
2187 2189
2188 const uint8_t nominalRate7bw[3][5] = { 2190 static const uint8_t nominalRate7bw[3][5] = {
2189 /* TRCG Nominal Rate [37:0] */ 2191 /* TRCG Nominal Rate [37:0] */
2190 {0x14, 0x80, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */ 2192 {0x14, 0x80, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */
2191 {0x18, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */ 2193 {0x18, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2192 {0x14, 0x80, 0x00, 0x00, 0x00} /* 41MHz XTal */ 2194 {0x14, 0x80, 0x00, 0x00, 0x00} /* 41MHz XTal */
2193 }; 2195 };
2194 2196
2195 const uint8_t nominalRate6bw[3][5] = { 2197 static const uint8_t nominalRate6bw[3][5] = {
2196 /* TRCG Nominal Rate [37:0] */ 2198 /* TRCG Nominal Rate [37:0] */
2197 {0x17, 0xEA, 0xAA, 0xAA, 0xAA}, /* 20.5MHz XTal */ 2199 {0x17, 0xEA, 0xAA, 0xAA, 0xAA}, /* 20.5MHz XTal */
2198 {0x1C, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */ 2200 {0x1C, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2199 {0x17, 0xEA, 0xAA, 0xAA, 0xAA} /* 41MHz XTal */ 2201 {0x17, 0xEA, 0xAA, 0xAA, 0xAA} /* 41MHz XTal */
2200 }; 2202 };
2201 2203
2202 const uint8_t nominalRate5bw[3][5] = { 2204 static const uint8_t nominalRate5bw[3][5] = {
2203 /* TRCG Nominal Rate [37:0] */ 2205 /* TRCG Nominal Rate [37:0] */
2204 {0x1C, 0xB3, 0x33, 0x33, 0x33}, /* 20.5MHz XTal */ 2206 {0x1C, 0xB3, 0x33, 0x33, 0x33}, /* 20.5MHz XTal */
2205 {0x21, 0x99, 0x99, 0x99, 0x99}, /* 24MHz XTal */ 2207 {0x21, 0x99, 0x99, 0x99, 0x99}, /* 24MHz XTal */
2206 {0x1C, 0xB3, 0x33, 0x33, 0x33} /* 41MHz XTal */ 2208 {0x1C, 0xB3, 0x33, 0x33, 0x33} /* 41MHz XTal */
2207 }; 2209 };
2208 2210
2209 const uint8_t nominalRate17bw[3][5] = { 2211 static const uint8_t nominalRate17bw[3][5] = {
2210 /* TRCG Nominal Rate [37:0] */ 2212 /* TRCG Nominal Rate [37:0] */
2211 {0x58, 0xE2, 0xAF, 0xE0, 0xBC}, /* 20.5MHz XTal */ 2213 {0x58, 0xE2, 0xAF, 0xE0, 0xBC}, /* 20.5MHz XTal */
2212 {0x68, 0x0F, 0xA2, 0x32, 0xD0}, /* 24MHz XTal */ 2214 {0x68, 0x0F, 0xA2, 0x32, 0xD0}, /* 24MHz XTal */
2213 {0x58, 0xE2, 0xAF, 0xE0, 0xBC} /* 41MHz XTal */ 2215 {0x58, 0xE2, 0xAF, 0xE0, 0xBC} /* 41MHz XTal */
2214 }; 2216 };
2215 2217
2216 const uint8_t itbCoef8bw[3][14] = { 2218 static const uint8_t itbCoef8bw[3][14] = {
2217 {0x26, 0xAF, 0x06, 0xCD, 0x13, 0xBB, 0x28, 0xBA, 2219 {0x26, 0xAF, 0x06, 0xCD, 0x13, 0xBB, 0x28, 0xBA,
2218 0x23, 0xA9, 0x1F, 0xA8, 0x2C, 0xC8}, /* 20.5MHz XTal */ 2220 0x23, 0xA9, 0x1F, 0xA8, 0x2C, 0xC8}, /* 20.5MHz XTal */
2219 {0x2F, 0xBA, 0x28, 0x9B, 0x28, 0x9D, 0x28, 0xA1, 2221 {0x2F, 0xBA, 0x28, 0x9B, 0x28, 0x9D, 0x28, 0xA1,
@@ -2222,7 +2224,7 @@ static int cxd2841er_sleep_tc_to_active_t2_band(struct cxd2841er_priv *priv,
2222 0x23, 0xA9, 0x1F, 0xA8, 0x2C, 0xC8} /* 41MHz XTal */ 2224 0x23, 0xA9, 0x1F, 0xA8, 0x2C, 0xC8} /* 41MHz XTal */
2223 }; 2225 };
2224 2226
2225 const uint8_t itbCoef7bw[3][14] = { 2227 static const uint8_t itbCoef7bw[3][14] = {
2226 {0x2C, 0xBD, 0x02, 0xCF, 0x04, 0xF8, 0x23, 0xA6, 2228 {0x2C, 0xBD, 0x02, 0xCF, 0x04, 0xF8, 0x23, 0xA6,
2227 0x29, 0xB0, 0x26, 0xA9, 0x21, 0xA5}, /* 20.5MHz XTal */ 2229 0x29, 0xB0, 0x26, 0xA9, 0x21, 0xA5}, /* 20.5MHz XTal */
2228 {0x30, 0xB1, 0x29, 0x9A, 0x28, 0x9C, 0x28, 0xA0, 2230 {0x30, 0xB1, 0x29, 0x9A, 0x28, 0x9C, 0x28, 0xA0,
@@ -2231,7 +2233,7 @@ static int cxd2841er_sleep_tc_to_active_t2_band(struct cxd2841er_priv *priv,
2231 0x29, 0xB0, 0x26, 0xA9, 0x21, 0xA5} /* 41MHz XTal */ 2233 0x29, 0xB0, 0x26, 0xA9, 0x21, 0xA5} /* 41MHz XTal */
2232 }; 2234 };
2233 2235
2234 const uint8_t itbCoef6bw[3][14] = { 2236 static const uint8_t itbCoef6bw[3][14] = {
2235 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 2237 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8,
2236 0x00, 0xCF, 0x00, 0xE6, 0x23, 0xA4}, /* 20.5MHz XTal */ 2238 0x00, 0xCF, 0x00, 0xE6, 0x23, 0xA4}, /* 20.5MHz XTal */
2237 {0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E, 2239 {0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E,
@@ -2240,7 +2242,7 @@ static int cxd2841er_sleep_tc_to_active_t2_band(struct cxd2841er_priv *priv,
2240 0x00, 0xCF, 0x00, 0xE6, 0x23, 0xA4} /* 41MHz XTal */ 2242 0x00, 0xCF, 0x00, 0xE6, 0x23, 0xA4} /* 41MHz XTal */
2241 }; 2243 };
2242 2244
2243 const uint8_t itbCoef5bw[3][14] = { 2245 static const uint8_t itbCoef5bw[3][14] = {
2244 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 2246 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8,
2245 0x00, 0xCF, 0x00, 0xE6, 0x23, 0xA4}, /* 20.5MHz XTal */ 2247 0x00, 0xCF, 0x00, 0xE6, 0x23, 0xA4}, /* 20.5MHz XTal */
2246 {0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E, 2248 {0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E,
@@ -2249,7 +2251,7 @@ static int cxd2841er_sleep_tc_to_active_t2_band(struct cxd2841er_priv *priv,
2249 0x00, 0xCF, 0x00, 0xE6, 0x23, 0xA4} /* 41MHz XTal */ 2251 0x00, 0xCF, 0x00, 0xE6, 0x23, 0xA4} /* 41MHz XTal */
2250 }; 2252 };
2251 2253
2252 const uint8_t itbCoef17bw[3][14] = { 2254 static const uint8_t itbCoef17bw[3][14] = {
2253 {0x25, 0xA0, 0x36, 0x8D, 0x2E, 0x94, 0x28, 0x9B, 2255 {0x25, 0xA0, 0x36, 0x8D, 0x2E, 0x94, 0x28, 0x9B,
2254 0x32, 0x90, 0x2C, 0x9D, 0x29, 0x99}, /* 20.5MHz XTal */ 2256 0x32, 0x90, 0x2C, 0x9D, 0x29, 0x99}, /* 20.5MHz XTal */
2255 {0x33, 0x8E, 0x2B, 0x97, 0x2D, 0x95, 0x37, 0x8B, 2257 {0x33, 0x8E, 0x2B, 0x97, 0x2D, 0x95, 0x37, 0x8B,
@@ -2423,32 +2425,32 @@ static int cxd2841er_sleep_tc_to_active_t_band(
2423{ 2425{
2424 u8 data[MAX_WRITE_REGSIZE]; 2426 u8 data[MAX_WRITE_REGSIZE];
2425 u32 iffreq, ifhz; 2427 u32 iffreq, ifhz;
2426 u8 nominalRate8bw[3][5] = { 2428 static const u8 nominalRate8bw[3][5] = {
2427 /* TRCG Nominal Rate [37:0] */ 2429 /* TRCG Nominal Rate [37:0] */
2428 {0x11, 0xF0, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */ 2430 {0x11, 0xF0, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */
2429 {0x15, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */ 2431 {0x15, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2430 {0x11, 0xF0, 0x00, 0x00, 0x00} /* 41MHz XTal */ 2432 {0x11, 0xF0, 0x00, 0x00, 0x00} /* 41MHz XTal */
2431 }; 2433 };
2432 u8 nominalRate7bw[3][5] = { 2434 static const u8 nominalRate7bw[3][5] = {
2433 /* TRCG Nominal Rate [37:0] */ 2435 /* TRCG Nominal Rate [37:0] */
2434 {0x14, 0x80, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */ 2436 {0x14, 0x80, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */
2435 {0x18, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */ 2437 {0x18, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2436 {0x14, 0x80, 0x00, 0x00, 0x00} /* 41MHz XTal */ 2438 {0x14, 0x80, 0x00, 0x00, 0x00} /* 41MHz XTal */
2437 }; 2439 };
2438 u8 nominalRate6bw[3][5] = { 2440 static const u8 nominalRate6bw[3][5] = {
2439 /* TRCG Nominal Rate [37:0] */ 2441 /* TRCG Nominal Rate [37:0] */
2440 {0x17, 0xEA, 0xAA, 0xAA, 0xAA}, /* 20.5MHz XTal */ 2442 {0x17, 0xEA, 0xAA, 0xAA, 0xAA}, /* 20.5MHz XTal */
2441 {0x1C, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */ 2443 {0x1C, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2442 {0x17, 0xEA, 0xAA, 0xAA, 0xAA} /* 41MHz XTal */ 2444 {0x17, 0xEA, 0xAA, 0xAA, 0xAA} /* 41MHz XTal */
2443 }; 2445 };
2444 u8 nominalRate5bw[3][5] = { 2446 static const u8 nominalRate5bw[3][5] = {
2445 /* TRCG Nominal Rate [37:0] */ 2447 /* TRCG Nominal Rate [37:0] */
2446 {0x1C, 0xB3, 0x33, 0x33, 0x33}, /* 20.5MHz XTal */ 2448 {0x1C, 0xB3, 0x33, 0x33, 0x33}, /* 20.5MHz XTal */
2447 {0x21, 0x99, 0x99, 0x99, 0x99}, /* 24MHz XTal */ 2449 {0x21, 0x99, 0x99, 0x99, 0x99}, /* 24MHz XTal */
2448 {0x1C, 0xB3, 0x33, 0x33, 0x33} /* 41MHz XTal */ 2450 {0x1C, 0xB3, 0x33, 0x33, 0x33} /* 41MHz XTal */
2449 }; 2451 };
2450 2452
2451 u8 itbCoef8bw[3][14] = { 2453 static const u8 itbCoef8bw[3][14] = {
2452 {0x26, 0xAF, 0x06, 0xCD, 0x13, 0xBB, 0x28, 0xBA, 0x23, 0xA9, 2454 {0x26, 0xAF, 0x06, 0xCD, 0x13, 0xBB, 0x28, 0xBA, 0x23, 0xA9,
2453 0x1F, 0xA8, 0x2C, 0xC8}, /* 20.5MHz XTal */ 2455 0x1F, 0xA8, 0x2C, 0xC8}, /* 20.5MHz XTal */
2454 {0x2F, 0xBA, 0x28, 0x9B, 0x28, 0x9D, 0x28, 0xA1, 0x29, 0xA5, 2456 {0x2F, 0xBA, 0x28, 0x9B, 0x28, 0x9D, 0x28, 0xA1, 0x29, 0xA5,
@@ -2456,7 +2458,7 @@ static int cxd2841er_sleep_tc_to_active_t_band(
2456 {0x26, 0xAF, 0x06, 0xCD, 0x13, 0xBB, 0x28, 0xBA, 0x23, 0xA9, 2458 {0x26, 0xAF, 0x06, 0xCD, 0x13, 0xBB, 0x28, 0xBA, 0x23, 0xA9,
2457 0x1F, 0xA8, 0x2C, 0xC8} /* 41MHz XTal */ 2459 0x1F, 0xA8, 0x2C, 0xC8} /* 41MHz XTal */
2458 }; 2460 };
2459 u8 itbCoef7bw[3][14] = { 2461 static const u8 itbCoef7bw[3][14] = {
2460 {0x2C, 0xBD, 0x02, 0xCF, 0x04, 0xF8, 0x23, 0xA6, 0x29, 0xB0, 2462 {0x2C, 0xBD, 0x02, 0xCF, 0x04, 0xF8, 0x23, 0xA6, 0x29, 0xB0,
2461 0x26, 0xA9, 0x21, 0xA5}, /* 20.5MHz XTal */ 2463 0x26, 0xA9, 0x21, 0xA5}, /* 20.5MHz XTal */
2462 {0x30, 0xB1, 0x29, 0x9A, 0x28, 0x9C, 0x28, 0xA0, 0x29, 0xA2, 2464 {0x30, 0xB1, 0x29, 0x9A, 0x28, 0x9C, 0x28, 0xA0, 0x29, 0xA2,
@@ -2464,7 +2466,7 @@ static int cxd2841er_sleep_tc_to_active_t_band(
2464 {0x2C, 0xBD, 0x02, 0xCF, 0x04, 0xF8, 0x23, 0xA6, 0x29, 0xB0, 2466 {0x2C, 0xBD, 0x02, 0xCF, 0x04, 0xF8, 0x23, 0xA6, 0x29, 0xB0,
2465 0x26, 0xA9, 0x21, 0xA5} /* 41MHz XTal */ 2467 0x26, 0xA9, 0x21, 0xA5} /* 41MHz XTal */
2466 }; 2468 };
2467 u8 itbCoef6bw[3][14] = { 2469 static const u8 itbCoef6bw[3][14] = {
2468 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00, 0xCF, 2470 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00, 0xCF,
2469 0x00, 0xE6, 0x23, 0xA4}, /* 20.5MHz XTal */ 2471 0x00, 0xE6, 0x23, 0xA4}, /* 20.5MHz XTal */
2470 {0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E, 0x29, 0xA4, 2472 {0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E, 0x29, 0xA4,
@@ -2472,7 +2474,7 @@ static int cxd2841er_sleep_tc_to_active_t_band(
2472 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00, 0xCF, 2474 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00, 0xCF,
2473 0x00, 0xE6, 0x23, 0xA4} /* 41MHz XTal */ 2475 0x00, 0xE6, 0x23, 0xA4} /* 41MHz XTal */
2474 }; 2476 };
2475 u8 itbCoef5bw[3][14] = { 2477 static const u8 itbCoef5bw[3][14] = {
2476 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00, 0xCF, 2478 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00, 0xCF,
2477 0x00, 0xE6, 0x23, 0xA4}, /* 20.5MHz XTal */ 2479 0x00, 0xE6, 0x23, 0xA4}, /* 20.5MHz XTal */
2478 {0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E, 0x29, 0xA4, 2480 {0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E, 0x29, 0xA4,
@@ -2652,39 +2654,39 @@ static int cxd2841er_sleep_tc_to_active_i_band(
2652 u8 data[3]; 2654 u8 data[3];
2653 2655
2654 /* TRCG Nominal Rate */ 2656 /* TRCG Nominal Rate */
2655 u8 nominalRate8bw[3][5] = { 2657 static const u8 nominalRate8bw[3][5] = {
2656 {0x00, 0x00, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */ 2658 {0x00, 0x00, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */
2657 {0x11, 0xB8, 0x00, 0x00, 0x00}, /* 24MHz XTal */ 2659 {0x11, 0xB8, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2658 {0x00, 0x00, 0x00, 0x00, 0x00} /* 41MHz XTal */ 2660 {0x00, 0x00, 0x00, 0x00, 0x00} /* 41MHz XTal */
2659 }; 2661 };
2660 2662
2661 u8 nominalRate7bw[3][5] = { 2663 static const u8 nominalRate7bw[3][5] = {
2662 {0x00, 0x00, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */ 2664 {0x00, 0x00, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */
2663 {0x14, 0x40, 0x00, 0x00, 0x00}, /* 24MHz XTal */ 2665 {0x14, 0x40, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2664 {0x00, 0x00, 0x00, 0x00, 0x00} /* 41MHz XTal */ 2666 {0x00, 0x00, 0x00, 0x00, 0x00} /* 41MHz XTal */
2665 }; 2667 };
2666 2668
2667 u8 nominalRate6bw[3][5] = { 2669 static const u8 nominalRate6bw[3][5] = {
2668 {0x14, 0x2E, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */ 2670 {0x14, 0x2E, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */
2669 {0x17, 0xA0, 0x00, 0x00, 0x00}, /* 24MHz XTal */ 2671 {0x17, 0xA0, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2670 {0x14, 0x2E, 0x00, 0x00, 0x00} /* 41MHz XTal */ 2672 {0x14, 0x2E, 0x00, 0x00, 0x00} /* 41MHz XTal */
2671 }; 2673 };
2672 2674
2673 u8 itbCoef8bw[3][14] = { 2675 static const u8 itbCoef8bw[3][14] = {
2674 {0x00}, /* 20.5MHz XTal */ 2676 {0x00}, /* 20.5MHz XTal */
2675 {0x2F, 0xBA, 0x28, 0x9B, 0x28, 0x9D, 0x28, 0xA1, 0x29, 2677 {0x2F, 0xBA, 0x28, 0x9B, 0x28, 0x9D, 0x28, 0xA1, 0x29,
2676 0xA5, 0x2A, 0xAC, 0x29, 0xB5}, /* 24MHz Xtal */ 2678 0xA5, 0x2A, 0xAC, 0x29, 0xB5}, /* 24MHz Xtal */
2677 {0x0}, /* 41MHz XTal */ 2679 {0x0}, /* 41MHz XTal */
2678 }; 2680 };
2679 2681
2680 u8 itbCoef7bw[3][14] = { 2682 static const u8 itbCoef7bw[3][14] = {
2681 {0x00}, /* 20.5MHz XTal */ 2683 {0x00}, /* 20.5MHz XTal */
2682 {0x30, 0xB1, 0x29, 0x9A, 0x28, 0x9C, 0x28, 0xA0, 0x29, 2684 {0x30, 0xB1, 0x29, 0x9A, 0x28, 0x9C, 0x28, 0xA0, 0x29,
2683 0xA2, 0x2B, 0xA6, 0x2B, 0xAD}, /* 24MHz Xtal */ 2685 0xA2, 0x2B, 0xA6, 0x2B, 0xAD}, /* 24MHz Xtal */
2684 {0x00}, /* 41MHz XTal */ 2686 {0x00}, /* 41MHz XTal */
2685 }; 2687 };
2686 2688
2687 u8 itbCoef6bw[3][14] = { 2689 static const u8 itbCoef6bw[3][14] = {
2688 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00, 2690 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00,
2689 0xCF, 0x00, 0xE6, 0x23, 0xA4}, /* 20.5MHz XTal */ 2691 0xCF, 0x00, 0xE6, 0x23, 0xA4}, /* 20.5MHz XTal */
2690 {0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E, 0x29, 2692 {0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E, 0x29,
@@ -3378,6 +3380,14 @@ static int cxd2841er_set_frontend_tc(struct dvb_frontend *fe)
3378 if (priv->flags & CXD2841ER_EARLY_TUNE) 3380 if (priv->flags & CXD2841ER_EARLY_TUNE)
3379 cxd2841er_tuner_set(fe); 3381 cxd2841er_tuner_set(fe);
3380 3382
3383 /* deconfigure/put demod to sleep on delsys switch if active */
3384 if (priv->state == STATE_ACTIVE_TC &&
3385 priv->system != p->delivery_system) {
3386 dev_dbg(&priv->i2c->dev, "%s(): old_delsys=%d, new_delsys=%d -> sleep\n",
3387 __func__, priv->system, p->delivery_system);
3388 cxd2841er_sleep_tc(fe);
3389 }
3390
3381 if (p->delivery_system == SYS_DVBT) { 3391 if (p->delivery_system == SYS_DVBT) {
3382 priv->system = SYS_DVBT; 3392 priv->system = SYS_DVBT;
3383 switch (priv->state) { 3393 switch (priv->state) {
@@ -3594,6 +3604,7 @@ static int cxd2841er_sleep_tc(struct dvb_frontend *fe)
3594 struct cxd2841er_priv *priv = fe->demodulator_priv; 3604 struct cxd2841er_priv *priv = fe->demodulator_priv;
3595 3605
3596 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); 3606 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
3607
3597 if (priv->state == STATE_ACTIVE_TC) { 3608 if (priv->state == STATE_ACTIVE_TC) {
3598 switch (priv->system) { 3609 switch (priv->system) {
3599 case SYS_DVBT: 3610 case SYS_DVBT:
@@ -3619,7 +3630,17 @@ static int cxd2841er_sleep_tc(struct dvb_frontend *fe)
3619 __func__, priv->state); 3630 __func__, priv->state);
3620 return -EINVAL; 3631 return -EINVAL;
3621 } 3632 }
3622 cxd2841er_sleep_tc_to_shutdown(priv); 3633 return 0;
3634}
3635
3636static int cxd2841er_shutdown_tc(struct dvb_frontend *fe)
3637{
3638 struct cxd2841er_priv *priv = fe->demodulator_priv;
3639
3640 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
3641
3642 if (!cxd2841er_sleep_tc(fe))
3643 cxd2841er_sleep_tc_to_shutdown(priv);
3623 return 0; 3644 return 0;
3624} 3645}
3625 3646
@@ -3968,7 +3989,7 @@ static struct dvb_frontend_ops cxd2841er_t_c_ops = {
3968 .symbol_rate_max = 11700000 3989 .symbol_rate_max = 11700000
3969 }, 3990 },
3970 .init = cxd2841er_init_tc, 3991 .init = cxd2841er_init_tc,
3971 .sleep = cxd2841er_sleep_tc, 3992 .sleep = cxd2841er_shutdown_tc,
3972 .release = cxd2841er_release, 3993 .release = cxd2841er_release,
3973 .set_frontend = cxd2841er_set_frontend_tc, 3994 .set_frontend = cxd2841er_set_frontend_tc,
3974 .get_frontend = cxd2841er_get_frontend, 3995 .get_frontend = cxd2841er_get_frontend,
@@ -3978,6 +3999,6 @@ static struct dvb_frontend_ops cxd2841er_t_c_ops = {
3978 .get_frontend_algo = cxd2841er_get_algo 3999 .get_frontend_algo = cxd2841er_get_algo
3979}; 4000};
3980 4001
3981MODULE_DESCRIPTION("Sony CXD2841ER/CXD2854ER DVB-C/C2/T/T2/S/S2 demodulator driver"); 4002MODULE_DESCRIPTION("Sony CXD2837/38/41/43/54ER DVB-C/C2/T/T2/S/S2 demodulator driver");
3982MODULE_AUTHOR("Sergey Kozlov <serjk@netup.ru>, Abylay Ospan <aospan@netup.ru>"); 4003MODULE_AUTHOR("Sergey Kozlov <serjk@netup.ru>, Abylay Ospan <aospan@netup.ru>");
3983MODULE_LICENSE("GPL"); 4004MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/dib0090.c b/drivers/media/dvb-frontends/dib0090.c
index 33af14df27bd..d9d730dfe0b1 100644
--- a/drivers/media/dvb-frontends/dib0090.c
+++ b/drivers/media/dvb-frontends/dib0090.c
@@ -2052,7 +2052,7 @@ int dib0090_update_tuning_table_7090(struct dvb_frontend *fe,
2052 struct dib0090_state *state = fe->tuner_priv; 2052 struct dib0090_state *state = fe->tuner_priv;
2053 const struct dib0090_tuning *tune = 2053 const struct dib0090_tuning *tune =
2054 dib0090_tuning_table_cband_7090e_sensitivity; 2054 dib0090_tuning_table_cband_7090e_sensitivity;
2055 const struct dib0090_tuning dib0090_tuning_table_cband_7090e_aci[] = { 2055 static const struct dib0090_tuning dib0090_tuning_table_cband_7090e_aci[] = {
2056 { 300000, 0 , 3, 0x8165, 0x2c0, 0x2d12, 0xb84e, EN_CAB }, 2056 { 300000, 0 , 3, 0x8165, 0x2c0, 0x2d12, 0xb84e, EN_CAB },
2057 { 650000, 0 , 4, 0x815B, 0x280, 0x2d12, 0xb84e, EN_CAB }, 2057 { 650000, 0 , 4, 0x815B, 0x280, 0x2d12, 0xb84e, EN_CAB },
2058 { 860000, 0 , 5, 0x84EF, 0x280, 0x2d12, 0xb84e, EN_CAB }, 2058 { 860000, 0 , 5, 0x84EF, 0x280, 0x2d12, 0xb84e, EN_CAB },
@@ -2435,14 +2435,7 @@ static int dib0090_tune(struct dvb_frontend *fe)
2435 Den = 1; 2435 Den = 1;
2436 2436
2437 if (Rest > 0) { 2437 if (Rest > 0) {
2438 if (state->config->analog_output) 2438 lo6 |= (1 << 2) | 2;
2439 lo6 |= (1 << 2) | 2;
2440 else {
2441 if (state->identity.in_soc)
2442 lo6 |= (1 << 2) | 2;
2443 else
2444 lo6 |= (1 << 2) | 2;
2445 }
2446 Den = 255; 2439 Den = 255;
2447 } 2440 }
2448 dib0090_write_reg(state, 0x15, (u16) FBDiv); 2441 dib0090_write_reg(state, 0x15, (u16) FBDiv);
diff --git a/drivers/media/dvb-frontends/dib7000p.c b/drivers/media/dvb-frontends/dib7000p.c
index 1caa04d8f60f..0fbaabe43682 100644
--- a/drivers/media/dvb-frontends/dib7000p.c
+++ b/drivers/media/dvb-frontends/dib7000p.c
@@ -2388,7 +2388,7 @@ static u32 dib7000p_i2c_func(struct i2c_adapter *adapter)
2388 return I2C_FUNC_I2C; 2388 return I2C_FUNC_I2C;
2389} 2389}
2390 2390
2391static struct i2c_algorithm dib7090_tuner_xfer_algo = { 2391static const struct i2c_algorithm dib7090_tuner_xfer_algo = {
2392 .master_xfer = dib7090_tuner_xfer, 2392 .master_xfer = dib7090_tuner_xfer,
2393 .functionality = dib7000p_i2c_func, 2393 .functionality = dib7000p_i2c_func,
2394}; 2394};
diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c
index e501ec964df1..5d9381509b07 100644
--- a/drivers/media/dvb-frontends/dib8000.c
+++ b/drivers/media/dvb-frontends/dib8000.c
@@ -1880,7 +1880,7 @@ static u32 dib8096p_i2c_func(struct i2c_adapter *adapter)
1880 return I2C_FUNC_I2C; 1880 return I2C_FUNC_I2C;
1881} 1881}
1882 1882
1883static struct i2c_algorithm dib8096p_tuner_xfer_algo = { 1883static const struct i2c_algorithm dib8096p_tuner_xfer_algo = {
1884 .master_xfer = dib8096p_tuner_xfer, 1884 .master_xfer = dib8096p_tuner_xfer,
1885 .functionality = dib8096p_i2c_func, 1885 .functionality = dib8096p_i2c_func,
1886}; 1886};
@@ -4255,23 +4255,6 @@ static int dib8000_set_slave_frontend(struct dvb_frontend *fe, struct dvb_fronte
4255 return -ENOMEM; 4255 return -ENOMEM;
4256} 4256}
4257 4257
4258static int dib8000_remove_slave_frontend(struct dvb_frontend *fe)
4259{
4260 struct dib8000_state *state = fe->demodulator_priv;
4261 u8 index_frontend = 1;
4262
4263 while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL))
4264 index_frontend++;
4265 if (index_frontend != 1) {
4266 dprintk("remove slave fe %p (index %i)\n", state->fe[index_frontend-1], index_frontend-1);
4267 state->fe[index_frontend] = NULL;
4268 return 0;
4269 }
4270
4271 dprintk("no frontend to be removed\n");
4272 return -ENODEV;
4273}
4274
4275static struct dvb_frontend *dib8000_get_slave_frontend(struct dvb_frontend *fe, int slave_index) 4258static struct dvb_frontend *dib8000_get_slave_frontend(struct dvb_frontend *fe, int slave_index)
4276{ 4259{
4277 struct dib8000_state *state = fe->demodulator_priv; 4260 struct dib8000_state *state = fe->demodulator_priv;
@@ -4506,7 +4489,6 @@ void *dib8000_attach(struct dib8000_ops *ops)
4506 ops->get_slave_frontend = dib8000_get_slave_frontend; 4489 ops->get_slave_frontend = dib8000_get_slave_frontend;
4507 ops->set_tune_state = dib8000_set_tune_state; 4490 ops->set_tune_state = dib8000_set_tune_state;
4508 ops->pid_filter_ctrl = dib8000_pid_filter_ctrl; 4491 ops->pid_filter_ctrl = dib8000_pid_filter_ctrl;
4509 ops->remove_slave_frontend = dib8000_remove_slave_frontend;
4510 ops->get_adc_power = dib8000_get_adc_power; 4492 ops->get_adc_power = dib8000_get_adc_power;
4511 ops->update_pll = dib8000_update_pll; 4493 ops->update_pll = dib8000_update_pll;
4512 ops->tuner_sleep = dib8096p_tuner_sleep; 4494 ops->tuner_sleep = dib8096p_tuner_sleep;
diff --git a/drivers/media/dvb-frontends/dib8000.h b/drivers/media/dvb-frontends/dib8000.h
index 2b8b4b1656a2..75cc8e47ec8f 100644
--- a/drivers/media/dvb-frontends/dib8000.h
+++ b/drivers/media/dvb-frontends/dib8000.h
@@ -53,7 +53,6 @@ struct dib8000_ops {
53 enum frontend_tune_state (*get_tune_state)(struct dvb_frontend *fe); 53 enum frontend_tune_state (*get_tune_state)(struct dvb_frontend *fe);
54 int (*set_tune_state)(struct dvb_frontend *fe, enum frontend_tune_state tune_state); 54 int (*set_tune_state)(struct dvb_frontend *fe, enum frontend_tune_state tune_state);
55 int (*set_slave_frontend)(struct dvb_frontend *fe, struct dvb_frontend *fe_slave); 55 int (*set_slave_frontend)(struct dvb_frontend *fe, struct dvb_frontend *fe_slave);
56 int (*remove_slave_frontend)(struct dvb_frontend *fe);
57 struct dvb_frontend *(*get_slave_frontend)(struct dvb_frontend *fe, int slave_index); 56 struct dvb_frontend *(*get_slave_frontend)(struct dvb_frontend *fe, int slave_index);
58 int (*i2c_enumeration)(struct i2c_adapter *host, int no_of_demods, 57 int (*i2c_enumeration)(struct i2c_adapter *host, int no_of_demods,
59 u8 default_addr, u8 first_addr, u8 is_dib8096p); 58 u8 default_addr, u8 first_addr, u8 is_dib8096p);
diff --git a/drivers/media/dvb-frontends/dib9000.c b/drivers/media/dvb-frontends/dib9000.c
index c95fff4f9582..1b7a4331af05 100644
--- a/drivers/media/dvb-frontends/dib9000.c
+++ b/drivers/media/dvb-frontends/dib9000.c
@@ -1714,12 +1714,12 @@ static u32 dib9000_i2c_func(struct i2c_adapter *adapter)
1714 return I2C_FUNC_I2C; 1714 return I2C_FUNC_I2C;
1715} 1715}
1716 1716
1717static struct i2c_algorithm dib9000_tuner_algo = { 1717static const struct i2c_algorithm dib9000_tuner_algo = {
1718 .master_xfer = dib9000_tuner_xfer, 1718 .master_xfer = dib9000_tuner_xfer,
1719 .functionality = dib9000_i2c_func, 1719 .functionality = dib9000_i2c_func,
1720}; 1720};
1721 1721
1722static struct i2c_algorithm dib9000_component_bus_algo = { 1722static const struct i2c_algorithm dib9000_component_bus_algo = {
1723 .master_xfer = dib9000_fw_component_bus_xfer, 1723 .master_xfer = dib9000_fw_component_bus_xfer,
1724 .functionality = dib9000_i2c_func, 1724 .functionality = dib9000_i2c_func,
1725}; 1725};
@@ -2462,24 +2462,6 @@ int dib9000_set_slave_frontend(struct dvb_frontend *fe, struct dvb_frontend *fe_
2462} 2462}
2463EXPORT_SYMBOL(dib9000_set_slave_frontend); 2463EXPORT_SYMBOL(dib9000_set_slave_frontend);
2464 2464
2465int dib9000_remove_slave_frontend(struct dvb_frontend *fe)
2466{
2467 struct dib9000_state *state = fe->demodulator_priv;
2468 u8 index_frontend = 1;
2469
2470 while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL))
2471 index_frontend++;
2472 if (index_frontend != 1) {
2473 dprintk("remove slave fe %p (index %i)\n", state->fe[index_frontend - 1], index_frontend - 1);
2474 state->fe[index_frontend] = NULL;
2475 return 0;
2476 }
2477
2478 dprintk("no frontend to be removed\n");
2479 return -ENODEV;
2480}
2481EXPORT_SYMBOL(dib9000_remove_slave_frontend);
2482
2483struct dvb_frontend *dib9000_get_slave_frontend(struct dvb_frontend *fe, int slave_index) 2465struct dvb_frontend *dib9000_get_slave_frontend(struct dvb_frontend *fe, int slave_index)
2484{ 2466{
2485 struct dib9000_state *state = fe->demodulator_priv; 2467 struct dib9000_state *state = fe->demodulator_priv;
diff --git a/drivers/media/dvb-frontends/dib9000.h b/drivers/media/dvb-frontends/dib9000.h
index b10a70aa7c9f..40883b41e66b 100644
--- a/drivers/media/dvb-frontends/dib9000.h
+++ b/drivers/media/dvb-frontends/dib9000.h
@@ -37,7 +37,6 @@ extern int dib9000_fw_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff);
37extern int dib9000_fw_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff); 37extern int dib9000_fw_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff);
38extern int dib9000_firmware_post_pll_init(struct dvb_frontend *fe); 38extern int dib9000_firmware_post_pll_init(struct dvb_frontend *fe);
39extern int dib9000_set_slave_frontend(struct dvb_frontend *fe, struct dvb_frontend *fe_slave); 39extern int dib9000_set_slave_frontend(struct dvb_frontend *fe, struct dvb_frontend *fe_slave);
40extern int dib9000_remove_slave_frontend(struct dvb_frontend *fe);
41extern struct dvb_frontend *dib9000_get_slave_frontend(struct dvb_frontend *fe, int slave_index); 40extern struct dvb_frontend *dib9000_get_slave_frontend(struct dvb_frontend *fe, int slave_index);
42extern struct i2c_adapter *dib9000_get_component_bus_interface(struct dvb_frontend *fe); 41extern struct i2c_adapter *dib9000_get_component_bus_interface(struct dvb_frontend *fe);
43extern int dib9000_set_i2c_adapter(struct dvb_frontend *fe, struct i2c_adapter *i2c); 42extern int dib9000_set_i2c_adapter(struct dvb_frontend *fe, struct i2c_adapter *i2c);
@@ -97,12 +96,6 @@ static inline int dib9000_set_slave_frontend(struct dvb_frontend *fe, struct dvb
97 return -ENODEV; 96 return -ENODEV;
98} 97}
99 98
100static inline int dib9000_remove_slave_frontend(struct dvb_frontend *fe)
101{
102 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
103 return -ENODEV;
104}
105
106static inline struct dvb_frontend *dib9000_get_slave_frontend(struct dvb_frontend *fe, int slave_index) 99static inline struct dvb_frontend *dib9000_get_slave_frontend(struct dvb_frontend *fe, int slave_index)
107{ 100{
108 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 101 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index 14040c915dbb..499ccff557bf 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -5489,7 +5489,7 @@ static int set_vsb_leak_n_gain(struct drx_demod_instance *demod)
5489 struct i2c_device_addr *dev_addr = NULL; 5489 struct i2c_device_addr *dev_addr = NULL;
5490 int rc; 5490 int rc;
5491 5491
5492 const u8 vsb_ffe_leak_gain_ram0[] = { 5492 static const u8 vsb_ffe_leak_gain_ram0[] = {
5493 DRXJ_16TO8(0x8), /* FFETRAINLKRATIO1 */ 5493 DRXJ_16TO8(0x8), /* FFETRAINLKRATIO1 */
5494 DRXJ_16TO8(0x8), /* FFETRAINLKRATIO2 */ 5494 DRXJ_16TO8(0x8), /* FFETRAINLKRATIO2 */
5495 DRXJ_16TO8(0x8), /* FFETRAINLKRATIO3 */ 5495 DRXJ_16TO8(0x8), /* FFETRAINLKRATIO3 */
@@ -5620,7 +5620,7 @@ static int set_vsb_leak_n_gain(struct drx_demod_instance *demod)
5620 DRXJ_16TO8(0x1010) /* FIRRCA1GAIN8 */ 5620 DRXJ_16TO8(0x1010) /* FIRRCA1GAIN8 */
5621 }; 5621 };
5622 5622
5623 const u8 vsb_ffe_leak_gain_ram1[] = { 5623 static const u8 vsb_ffe_leak_gain_ram1[] = {
5624 DRXJ_16TO8(0x1010), /* FIRRCA1GAIN9 */ 5624 DRXJ_16TO8(0x1010), /* FIRRCA1GAIN9 */
5625 DRXJ_16TO8(0x0808), /* FIRRCA1GAIN10 */ 5625 DRXJ_16TO8(0x0808), /* FIRRCA1GAIN10 */
5626 DRXJ_16TO8(0x0808), /* FIRRCA1GAIN11 */ 5626 DRXJ_16TO8(0x0808), /* FIRRCA1GAIN11 */
@@ -5710,7 +5710,7 @@ static int set_vsb(struct drx_demod_instance *demod)
5710 struct drxj_data *ext_attr = NULL; 5710 struct drxj_data *ext_attr = NULL;
5711 u16 cmd_result = 0; 5711 u16 cmd_result = 0;
5712 u16 cmd_param = 0; 5712 u16 cmd_param = 0;
5713 const u8 vsb_taps_re[] = { 5713 static const u8 vsb_taps_re[] = {
5714 DRXJ_16TO8(-2), /* re0 */ 5714 DRXJ_16TO8(-2), /* re0 */
5715 DRXJ_16TO8(4), /* re1 */ 5715 DRXJ_16TO8(4), /* re1 */
5716 DRXJ_16TO8(1), /* re2 */ 5716 DRXJ_16TO8(1), /* re2 */
@@ -6666,7 +6666,7 @@ static int set_qam16(struct drx_demod_instance *demod)
6666{ 6666{
6667 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr; 6667 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
6668 int rc; 6668 int rc;
6669 const u8 qam_dq_qual_fun[] = { 6669 static const u8 qam_dq_qual_fun[] = {
6670 DRXJ_16TO8(2), /* fun0 */ 6670 DRXJ_16TO8(2), /* fun0 */
6671 DRXJ_16TO8(2), /* fun1 */ 6671 DRXJ_16TO8(2), /* fun1 */
6672 DRXJ_16TO8(2), /* fun2 */ 6672 DRXJ_16TO8(2), /* fun2 */
@@ -6674,7 +6674,7 @@ static int set_qam16(struct drx_demod_instance *demod)
6674 DRXJ_16TO8(3), /* fun4 */ 6674 DRXJ_16TO8(3), /* fun4 */
6675 DRXJ_16TO8(3), /* fun5 */ 6675 DRXJ_16TO8(3), /* fun5 */
6676 }; 6676 };
6677 const u8 qam_eq_cma_rad[] = { 6677 static const u8 qam_eq_cma_rad[] = {
6678 DRXJ_16TO8(13517), /* RAD0 */ 6678 DRXJ_16TO8(13517), /* RAD0 */
6679 DRXJ_16TO8(13517), /* RAD1 */ 6679 DRXJ_16TO8(13517), /* RAD1 */
6680 DRXJ_16TO8(13517), /* RAD2 */ 6680 DRXJ_16TO8(13517), /* RAD2 */
@@ -6901,7 +6901,7 @@ static int set_qam32(struct drx_demod_instance *demod)
6901{ 6901{
6902 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr; 6902 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
6903 int rc; 6903 int rc;
6904 const u8 qam_dq_qual_fun[] = { 6904 static const u8 qam_dq_qual_fun[] = {
6905 DRXJ_16TO8(3), /* fun0 */ 6905 DRXJ_16TO8(3), /* fun0 */
6906 DRXJ_16TO8(3), /* fun1 */ 6906 DRXJ_16TO8(3), /* fun1 */
6907 DRXJ_16TO8(3), /* fun2 */ 6907 DRXJ_16TO8(3), /* fun2 */
@@ -6909,7 +6909,7 @@ static int set_qam32(struct drx_demod_instance *demod)
6909 DRXJ_16TO8(4), /* fun4 */ 6909 DRXJ_16TO8(4), /* fun4 */
6910 DRXJ_16TO8(4), /* fun5 */ 6910 DRXJ_16TO8(4), /* fun5 */
6911 }; 6911 };
6912 const u8 qam_eq_cma_rad[] = { 6912 static const u8 qam_eq_cma_rad[] = {
6913 DRXJ_16TO8(6707), /* RAD0 */ 6913 DRXJ_16TO8(6707), /* RAD0 */
6914 DRXJ_16TO8(6707), /* RAD1 */ 6914 DRXJ_16TO8(6707), /* RAD1 */
6915 DRXJ_16TO8(6707), /* RAD2 */ 6915 DRXJ_16TO8(6707), /* RAD2 */
@@ -7136,7 +7136,8 @@ static int set_qam64(struct drx_demod_instance *demod)
7136{ 7136{
7137 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr; 7137 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
7138 int rc; 7138 int rc;
7139 const u8 qam_dq_qual_fun[] = { /* this is hw reset value. no necessary to re-write */ 7139 static const u8 qam_dq_qual_fun[] = {
7140 /* this is hw reset value. no necessary to re-write */
7140 DRXJ_16TO8(4), /* fun0 */ 7141 DRXJ_16TO8(4), /* fun0 */
7141 DRXJ_16TO8(4), /* fun1 */ 7142 DRXJ_16TO8(4), /* fun1 */
7142 DRXJ_16TO8(4), /* fun2 */ 7143 DRXJ_16TO8(4), /* fun2 */
@@ -7144,7 +7145,7 @@ static int set_qam64(struct drx_demod_instance *demod)
7144 DRXJ_16TO8(6), /* fun4 */ 7145 DRXJ_16TO8(6), /* fun4 */
7145 DRXJ_16TO8(6), /* fun5 */ 7146 DRXJ_16TO8(6), /* fun5 */
7146 }; 7147 };
7147 const u8 qam_eq_cma_rad[] = { 7148 static const u8 qam_eq_cma_rad[] = {
7148 DRXJ_16TO8(13336), /* RAD0 */ 7149 DRXJ_16TO8(13336), /* RAD0 */
7149 DRXJ_16TO8(12618), /* RAD1 */ 7150 DRXJ_16TO8(12618), /* RAD1 */
7150 DRXJ_16TO8(11988), /* RAD2 */ 7151 DRXJ_16TO8(11988), /* RAD2 */
@@ -7371,7 +7372,7 @@ static int set_qam128(struct drx_demod_instance *demod)
7371{ 7372{
7372 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr; 7373 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
7373 int rc; 7374 int rc;
7374 const u8 qam_dq_qual_fun[] = { 7375 static const u8 qam_dq_qual_fun[] = {
7375 DRXJ_16TO8(6), /* fun0 */ 7376 DRXJ_16TO8(6), /* fun0 */
7376 DRXJ_16TO8(6), /* fun1 */ 7377 DRXJ_16TO8(6), /* fun1 */
7377 DRXJ_16TO8(6), /* fun2 */ 7378 DRXJ_16TO8(6), /* fun2 */
@@ -7379,7 +7380,7 @@ static int set_qam128(struct drx_demod_instance *demod)
7379 DRXJ_16TO8(9), /* fun4 */ 7380 DRXJ_16TO8(9), /* fun4 */
7380 DRXJ_16TO8(9), /* fun5 */ 7381 DRXJ_16TO8(9), /* fun5 */
7381 }; 7382 };
7382 const u8 qam_eq_cma_rad[] = { 7383 static const u8 qam_eq_cma_rad[] = {
7383 DRXJ_16TO8(6164), /* RAD0 */ 7384 DRXJ_16TO8(6164), /* RAD0 */
7384 DRXJ_16TO8(6598), /* RAD1 */ 7385 DRXJ_16TO8(6598), /* RAD1 */
7385 DRXJ_16TO8(6394), /* RAD2 */ 7386 DRXJ_16TO8(6394), /* RAD2 */
@@ -7606,7 +7607,7 @@ static int set_qam256(struct drx_demod_instance *demod)
7606{ 7607{
7607 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr; 7608 struct i2c_device_addr *dev_addr = demod->my_i2c_dev_addr;
7608 int rc; 7609 int rc;
7609 const u8 qam_dq_qual_fun[] = { 7610 static const u8 qam_dq_qual_fun[] = {
7610 DRXJ_16TO8(8), /* fun0 */ 7611 DRXJ_16TO8(8), /* fun0 */
7611 DRXJ_16TO8(8), /* fun1 */ 7612 DRXJ_16TO8(8), /* fun1 */
7612 DRXJ_16TO8(8), /* fun2 */ 7613 DRXJ_16TO8(8), /* fun2 */
@@ -7614,7 +7615,7 @@ static int set_qam256(struct drx_demod_instance *demod)
7614 DRXJ_16TO8(12), /* fun4 */ 7615 DRXJ_16TO8(12), /* fun4 */
7615 DRXJ_16TO8(12), /* fun5 */ 7616 DRXJ_16TO8(12), /* fun5 */
7616 }; 7617 };
7617 const u8 qam_eq_cma_rad[] = { 7618 static const u8 qam_eq_cma_rad[] = {
7618 DRXJ_16TO8(12345), /* RAD0 */ 7619 DRXJ_16TO8(12345), /* RAD0 */
7619 DRXJ_16TO8(12345), /* RAD1 */ 7620 DRXJ_16TO8(12345), /* RAD1 */
7620 DRXJ_16TO8(13626), /* RAD2 */ 7621 DRXJ_16TO8(13626), /* RAD2 */
@@ -7862,7 +7863,7 @@ set_qam(struct drx_demod_instance *demod,
7862 /* parameter */ NULL, 7863 /* parameter */ NULL,
7863 /* result */ NULL 7864 /* result */ NULL
7864 }; 7865 };
7865 const u8 qam_a_taps[] = { 7866 static const u8 qam_a_taps[] = {
7866 DRXJ_16TO8(-1), /* re0 */ 7867 DRXJ_16TO8(-1), /* re0 */
7867 DRXJ_16TO8(1), /* re1 */ 7868 DRXJ_16TO8(1), /* re1 */
7868 DRXJ_16TO8(1), /* re2 */ 7869 DRXJ_16TO8(1), /* re2 */
@@ -7892,7 +7893,7 @@ set_qam(struct drx_demod_instance *demod,
7892 DRXJ_16TO8(-40), /* re26 */ 7893 DRXJ_16TO8(-40), /* re26 */
7893 DRXJ_16TO8(619) /* re27 */ 7894 DRXJ_16TO8(619) /* re27 */
7894 }; 7895 };
7895 const u8 qam_b64_taps[] = { 7896 static const u8 qam_b64_taps[] = {
7896 DRXJ_16TO8(0), /* re0 */ 7897 DRXJ_16TO8(0), /* re0 */
7897 DRXJ_16TO8(-2), /* re1 */ 7898 DRXJ_16TO8(-2), /* re1 */
7898 DRXJ_16TO8(1), /* re2 */ 7899 DRXJ_16TO8(1), /* re2 */
@@ -7922,7 +7923,7 @@ set_qam(struct drx_demod_instance *demod,
7922 DRXJ_16TO8(-46), /* re26 */ 7923 DRXJ_16TO8(-46), /* re26 */
7923 DRXJ_16TO8(614) /* re27 */ 7924 DRXJ_16TO8(614) /* re27 */
7924 }; 7925 };
7925 const u8 qam_b256_taps[] = { 7926 static const u8 qam_b256_taps[] = {
7926 DRXJ_16TO8(-2), /* re0 */ 7927 DRXJ_16TO8(-2), /* re0 */
7927 DRXJ_16TO8(4), /* re1 */ 7928 DRXJ_16TO8(4), /* re1 */
7928 DRXJ_16TO8(1), /* re2 */ 7929 DRXJ_16TO8(1), /* re2 */
@@ -7952,7 +7953,7 @@ set_qam(struct drx_demod_instance *demod,
7952 DRXJ_16TO8(-32), /* re26 */ 7953 DRXJ_16TO8(-32), /* re26 */
7953 DRXJ_16TO8(628) /* re27 */ 7954 DRXJ_16TO8(628) /* re27 */
7954 }; 7955 };
7955 const u8 qam_c_taps[] = { 7956 static const u8 qam_c_taps[] = {
7956 DRXJ_16TO8(-3), /* re0 */ 7957 DRXJ_16TO8(-3), /* re0 */
7957 DRXJ_16TO8(3), /* re1 */ 7958 DRXJ_16TO8(3), /* re1 */
7958 DRXJ_16TO8(2), /* re2 */ 7959 DRXJ_16TO8(2), /* re2 */
diff --git a/drivers/media/dvb-frontends/drxd_hard.c b/drivers/media/dvb-frontends/drxd_hard.c
index 17638e08835a..7d04400b18dd 100644
--- a/drivers/media/dvb-frontends/drxd_hard.c
+++ b/drivers/media/dvb-frontends/drxd_hard.c
@@ -638,8 +638,10 @@ static int SetCfgIfAgc(struct drxd_state *state, struct SCfgAgc *cfg)
638 /* == Speed == */ 638 /* == Speed == */
639 { 639 {
640 const u16 maxRur = 8; 640 const u16 maxRur = 8;
641 const u16 slowIncrDecLUT[] = { 3, 4, 4, 5, 6 }; 641 static const u16 slowIncrDecLUT[] = {
642 const u16 fastIncrDecLUT[] = { 14, 15, 15, 16, 642 3, 4, 4, 5, 6 };
643 const u16 fastIncrDecLUT[] = {
644 14, 15, 15, 16,
643 17, 18, 18, 19, 645 17, 18, 18, 19,
644 20, 21, 22, 23, 646 20, 21, 22, 23,
645 24, 26, 27, 28, 647 24, 26, 27, 28,
diff --git a/drivers/media/dvb-frontends/isl6421.c b/drivers/media/dvb-frontends/isl6421.c
index 838b42771a05..3f3487887672 100644
--- a/drivers/media/dvb-frontends/isl6421.c
+++ b/drivers/media/dvb-frontends/isl6421.c
@@ -38,35 +38,101 @@ struct isl6421 {
38 u8 override_and; 38 u8 override_and;
39 struct i2c_adapter *i2c; 39 struct i2c_adapter *i2c;
40 u8 i2c_addr; 40 u8 i2c_addr;
41 bool is_off;
41}; 42};
42 43
43static int isl6421_set_voltage(struct dvb_frontend *fe, 44static int isl6421_set_voltage(struct dvb_frontend *fe,
44 enum fe_sec_voltage voltage) 45 enum fe_sec_voltage voltage)
45{ 46{
47 int ret;
48 u8 buf;
49 bool is_off;
46 struct isl6421 *isl6421 = (struct isl6421 *) fe->sec_priv; 50 struct isl6421 *isl6421 = (struct isl6421 *) fe->sec_priv;
47 struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0, 51 struct i2c_msg msg[2] = {
48 .buf = &isl6421->config, 52 {
49 .len = sizeof(isl6421->config) }; 53 .addr = isl6421->i2c_addr,
54 .flags = 0,
55 .buf = &isl6421->config,
56 .len = 1,
57 }, {
58 .addr = isl6421->i2c_addr,
59 .flags = I2C_M_RD,
60 .buf = &buf,
61 .len = 1,
62 }
63
64 };
50 65
51 isl6421->config &= ~(ISL6421_VSEL1 | ISL6421_EN1); 66 isl6421->config &= ~(ISL6421_VSEL1 | ISL6421_EN1);
52 67
53 switch(voltage) { 68 switch(voltage) {
54 case SEC_VOLTAGE_OFF: 69 case SEC_VOLTAGE_OFF:
70 is_off = true;
55 break; 71 break;
56 case SEC_VOLTAGE_13: 72 case SEC_VOLTAGE_13:
73 is_off = false;
57 isl6421->config |= ISL6421_EN1; 74 isl6421->config |= ISL6421_EN1;
58 break; 75 break;
59 case SEC_VOLTAGE_18: 76 case SEC_VOLTAGE_18:
77 is_off = false;
60 isl6421->config |= (ISL6421_EN1 | ISL6421_VSEL1); 78 isl6421->config |= (ISL6421_EN1 | ISL6421_VSEL1);
61 break; 79 break;
62 default: 80 default:
63 return -EINVAL; 81 return -EINVAL;
64 } 82 }
65 83
84 /*
85 * If LNBf were not powered on, disable dynamic current limit, as,
86 * according with datasheet, highly capacitive load on the output may
87 * cause a difficult start-up.
88 */
89 if (isl6421->is_off && !is_off)
90 isl6421->config |= ISL6421_DCL;
91
66 isl6421->config |= isl6421->override_or; 92 isl6421->config |= isl6421->override_or;
67 isl6421->config &= isl6421->override_and; 93 isl6421->config &= isl6421->override_and;
68 94
69 return (i2c_transfer(isl6421->i2c, &msg, 1) == 1) ? 0 : -EIO; 95 ret = i2c_transfer(isl6421->i2c, msg, 2);
96 if (ret < 0)
97 return ret;
98 if (ret != 2)
99 return -EIO;
100
101 /* Store off status now incase future commands fail */
102 isl6421->is_off = is_off;
103
104 /* On overflow, the device will try again after 900 ms (typically) */
105 if (!is_off && (buf & ISL6421_OLF1))
106 msleep(1000);
107
108 /* Re-enable dynamic current limit */
109 if ((isl6421->config & ISL6421_DCL) &&
110 !(isl6421->override_or & ISL6421_DCL)) {
111 isl6421->config &= ~ISL6421_DCL;
112
113 ret = i2c_transfer(isl6421->i2c, msg, 2);
114 if (ret < 0)
115 return ret;
116 if (ret != 2)
117 return -EIO;
118 }
119
120 /* Check if overload flag is active. If so, disable power */
121 if (!is_off && (buf & ISL6421_OLF1)) {
122 isl6421->config &= ~(ISL6421_VSEL1 | ISL6421_EN1);
123 ret = i2c_transfer(isl6421->i2c, msg, 1);
124 if (ret < 0)
125 return ret;
126 if (ret != 1)
127 return -EIO;
128 isl6421->is_off = true;
129
130 dev_warn(&isl6421->i2c->dev,
131 "Overload current detected. disabling LNBf power\n");
132 return -EINVAL;
133 }
134
135 return 0;
70} 136}
71 137
72static int isl6421_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg) 138static int isl6421_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
@@ -148,6 +214,8 @@ struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter
148 return NULL; 214 return NULL;
149 } 215 }
150 216
217 isl6421->is_off = true;
218
151 /* install release callback */ 219 /* install release callback */
152 fe->ops.release_sec = isl6421_release; 220 fe->ops.release_sec = isl6421_release;
153 221
diff --git a/drivers/media/dvb-frontends/mb86a16.c b/drivers/media/dvb-frontends/mb86a16.c
index 9bb122c39c1b..dfe322eccaa1 100644
--- a/drivers/media/dvb-frontends/mb86a16.c
+++ b/drivers/media/dvb-frontends/mb86a16.c
@@ -415,27 +415,21 @@ static int signal_det(struct mb86a16_state *state,
415 int smrt, 415 int smrt,
416 unsigned char *SIG) 416 unsigned char *SIG)
417{ 417{
418 418 int ret;
419 int ret ; 419 int smrtd;
420 int smrtd ; 420 unsigned char S[3];
421 int wait_sym ; 421 int i;
422
423 u32 wait_t;
424 unsigned char S[3] ;
425 int i ;
426 422
427 if (*SIG > 45) { 423 if (*SIG > 45) {
428 if (CNTM_set(state, 2, 1, 2) < 0) { 424 if (CNTM_set(state, 2, 1, 2) < 0) {
429 dprintk(verbose, MB86A16_ERROR, 1, "CNTM set Error"); 425 dprintk(verbose, MB86A16_ERROR, 1, "CNTM set Error");
430 return -1; 426 return -1;
431 } 427 }
432 wait_sym = 40000;
433 } else { 428 } else {
434 if (CNTM_set(state, 3, 1, 2) < 0) { 429 if (CNTM_set(state, 3, 1, 2) < 0) {
435 dprintk(verbose, MB86A16_ERROR, 1, "CNTM set Error"); 430 dprintk(verbose, MB86A16_ERROR, 1, "CNTM set Error");
436 return -1; 431 return -1;
437 } 432 }
438 wait_sym = 80000;
439 } 433 }
440 for (i = 0; i < 3; i++) { 434 for (i = 0; i < 3; i++) {
441 if (i == 0) 435 if (i == 0)
@@ -447,22 +441,17 @@ static int signal_det(struct mb86a16_state *state,
447 smrt_info_get(state, smrtd); 441 smrt_info_get(state, smrtd);
448 smrt_set(state, smrtd); 442 smrt_set(state, smrtd);
449 srst(state); 443 srst(state);
450 wait_t = (wait_sym + 99 * smrtd / 100) / smrtd;
451 if (wait_t == 0)
452 wait_t = 1;
453 msleep_interruptible(10); 444 msleep_interruptible(10);
454 if (mb86a16_read(state, 0x37, &(S[i])) != 2) { 445 if (mb86a16_read(state, 0x37, &(S[i])) != 2) {
455 dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error"); 446 dprintk(verbose, MB86A16_ERROR, 1, "I2C transfer error");
456 return -EREMOTEIO; 447 return -EREMOTEIO;
457 } 448 }
458 } 449 }
459 if ((S[1] > S[0] * 112 / 100) && 450 if ((S[1] > S[0] * 112 / 100) && (S[1] > S[2] * 112 / 100))
460 (S[1] > S[2] * 112 / 100)) {
461
462 ret = 1; 451 ret = 1;
463 } else { 452 else
464 ret = 0; 453 ret = 0;
465 } 454
466 *SIG = S[1]; 455 *SIG = S[1];
467 456
468 if (CNTM_set(state, 0, 1, 2) < 0) { 457 if (CNTM_set(state, 0, 1, 2) < 0) {
diff --git a/drivers/media/dvb-frontends/mn88472.c b/drivers/media/dvb-frontends/mn88472.c
index f6938f9607ac..5e8fd63832e9 100644
--- a/drivers/media/dvb-frontends/mn88472.c
+++ b/drivers/media/dvb-frontends/mn88472.c
@@ -377,7 +377,9 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
377 ret = regmap_write(dev->regmap[1], 0xf6, 0x05); 377 ret = regmap_write(dev->regmap[1], 0xf6, 0x05);
378 if (ret) 378 if (ret)
379 goto err; 379 goto err;
380 ret = regmap_write(dev->regmap[2], 0x32, c->stream_id); 380 ret = regmap_write(dev->regmap[2], 0x32,
381 (c->stream_id == NO_STREAM_ID_FILTER) ? 0 :
382 c->stream_id );
381 if (ret) 383 if (ret)
382 goto err; 384 goto err;
383 break; 385 break;
diff --git a/drivers/media/dvb-frontends/mn88473.c b/drivers/media/dvb-frontends/mn88473.c
index 15874244fd8b..58247432a628 100644
--- a/drivers/media/dvb-frontends/mn88473.c
+++ b/drivers/media/dvb-frontends/mn88473.c
@@ -225,7 +225,9 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
225 225
226 /* PLP */ 226 /* PLP */
227 if (c->delivery_system == SYS_DVBT2) { 227 if (c->delivery_system == SYS_DVBT2) {
228 ret = regmap_write(dev->regmap[2], 0x36, c->stream_id); 228 ret = regmap_write(dev->regmap[2], 0x36,
229 (c->stream_id == NO_STREAM_ID_FILTER) ? 0 :
230 c->stream_id );
229 if (ret) 231 if (ret)
230 goto err; 232 goto err;
231 } 233 }
diff --git a/drivers/media/dvb-frontends/mxl5xx.c b/drivers/media/dvb-frontends/mxl5xx.c
new file mode 100644
index 000000000000..676c96c216c3
--- /dev/null
+++ b/drivers/media/dvb-frontends/mxl5xx.c
@@ -0,0 +1,1873 @@
1/*
2 * Driver for the MaxLinear MxL5xx family of tuners/demods
3 *
4 * Copyright (C) 2014-2015 Ralph Metzler <rjkm@metzlerbros.de>
5 * Marcus Metzler <mocm@metzlerbros.de>
6 * developed for Digital Devices GmbH
7 *
8 * based on code:
9 * Copyright (c) 2011-2013 MaxLinear, Inc. All rights reserved
10 * which was released under GPL V2
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * version 2, as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 */
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/moduleparam.h>
26#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/firmware.h>
29#include <linux/i2c.h>
30#include <linux/version.h>
31#include <linux/mutex.h>
32#include <linux/vmalloc.h>
33#include <asm/div64.h>
34#include <asm/unaligned.h>
35
36#include "dvb_frontend.h"
37#include "mxl5xx.h"
38#include "mxl5xx_regs.h"
39#include "mxl5xx_defs.h"
40
41#define BYTE0(v) ((v >> 0) & 0xff)
42#define BYTE1(v) ((v >> 8) & 0xff)
43#define BYTE2(v) ((v >> 16) & 0xff)
44#define BYTE3(v) ((v >> 24) & 0xff)
45
46LIST_HEAD(mxllist);
47
48struct mxl_base {
49 struct list_head mxllist;
50 struct list_head mxls;
51
52 u8 adr;
53 struct i2c_adapter *i2c;
54
55 u32 count;
56 u32 type;
57 u32 sku_type;
58 u32 chipversion;
59 u32 clock;
60 u32 fwversion;
61
62 u8 *ts_map;
63 u8 can_clkout;
64 u8 chan_bond;
65 u8 demod_num;
66 u8 tuner_num;
67
68 unsigned long next_tune;
69
70 struct mutex i2c_lock;
71 struct mutex status_lock;
72 struct mutex tune_lock;
73
74 u8 buf[MXL_HYDRA_OEM_MAX_CMD_BUFF_LEN];
75
76 u32 cmd_size;
77 u8 cmd_data[MAX_CMD_DATA];
78};
79
80struct mxl {
81 struct list_head mxl;
82
83 struct mxl_base *base;
84 struct dvb_frontend fe;
85 struct device *i2cdev;
86 u32 demod;
87 u32 tuner;
88 u32 tuner_in_use;
89 u8 xbar[3];
90
91 unsigned long tune_time;
92};
93
94static void convert_endian(u8 flag, u32 size, u8 *d)
95{
96 u32 i;
97
98 if (!flag)
99 return;
100 for (i = 0; i < (size & ~3); i += 4) {
101 d[i + 0] ^= d[i + 3];
102 d[i + 3] ^= d[i + 0];
103 d[i + 0] ^= d[i + 3];
104
105 d[i + 1] ^= d[i + 2];
106 d[i + 2] ^= d[i + 1];
107 d[i + 1] ^= d[i + 2];
108 }
109
110 switch (size & 3) {
111 case 0:
112 case 1:
113 /* do nothing */
114 break;
115 case 2:
116 d[i + 0] ^= d[i + 1];
117 d[i + 1] ^= d[i + 0];
118 d[i + 0] ^= d[i + 1];
119 break;
120
121 case 3:
122 d[i + 0] ^= d[i + 2];
123 d[i + 2] ^= d[i + 0];
124 d[i + 0] ^= d[i + 2];
125 break;
126 }
127
128}
129
130static int i2c_write(struct i2c_adapter *adap, u8 adr,
131 u8 *data, u32 len)
132{
133 struct i2c_msg msg = {.addr = adr, .flags = 0,
134 .buf = data, .len = len};
135
136 return (i2c_transfer(adap, &msg, 1) == 1) ? 0 : -1;
137}
138
139static int i2c_read(struct i2c_adapter *adap, u8 adr,
140 u8 *data, u32 len)
141{
142 struct i2c_msg msg = {.addr = adr, .flags = I2C_M_RD,
143 .buf = data, .len = len};
144
145 return (i2c_transfer(adap, &msg, 1) == 1) ? 0 : -1;
146}
147
148static int i2cread(struct mxl *state, u8 *data, int len)
149{
150 return i2c_read(state->base->i2c, state->base->adr, data, len);
151}
152
153static int i2cwrite(struct mxl *state, u8 *data, int len)
154{
155 return i2c_write(state->base->i2c, state->base->adr, data, len);
156}
157
158static int read_register_unlocked(struct mxl *state, u32 reg, u32 *val)
159{
160 int stat;
161 u8 data[MXL_HYDRA_REG_SIZE_IN_BYTES + MXL_HYDRA_I2C_HDR_SIZE] = {
162 MXL_HYDRA_PLID_REG_READ, 0x04,
163 GET_BYTE(reg, 0), GET_BYTE(reg, 1),
164 GET_BYTE(reg, 2), GET_BYTE(reg, 3),
165 };
166
167 stat = i2cwrite(state, data,
168 MXL_HYDRA_REG_SIZE_IN_BYTES + MXL_HYDRA_I2C_HDR_SIZE);
169 if (stat)
170 dev_err(state->i2cdev, "i2c read error 1\n");
171 if (!stat)
172 stat = i2cread(state, (u8 *) val,
173 MXL_HYDRA_REG_SIZE_IN_BYTES);
174 le32_to_cpus(val);
175 if (stat)
176 dev_err(state->i2cdev, "i2c read error 2\n");
177 return stat;
178}
179
180#define DMA_I2C_INTERRUPT_ADDR 0x8000011C
181#define DMA_INTR_PROT_WR_CMP 0x08
182
183static int send_command(struct mxl *state, u32 size, u8 *buf)
184{
185 int stat;
186 u32 val, count = 10;
187
188 mutex_lock(&state->base->i2c_lock);
189 if (state->base->fwversion > 0x02010109) {
190 read_register_unlocked(state, DMA_I2C_INTERRUPT_ADDR, &val);
191 if (DMA_INTR_PROT_WR_CMP & val)
192 dev_info(state->i2cdev, "%s busy\n", __func__);
193 while ((DMA_INTR_PROT_WR_CMP & val) && --count) {
194 mutex_unlock(&state->base->i2c_lock);
195 usleep_range(1000, 2000);
196 mutex_lock(&state->base->i2c_lock);
197 read_register_unlocked(state, DMA_I2C_INTERRUPT_ADDR,
198 &val);
199 }
200 if (!count) {
201 dev_info(state->i2cdev, "%s busy\n", __func__);
202 mutex_unlock(&state->base->i2c_lock);
203 return -EBUSY;
204 }
205 }
206 stat = i2cwrite(state, buf, size);
207 mutex_unlock(&state->base->i2c_lock);
208 return stat;
209}
210
211static int write_register(struct mxl *state, u32 reg, u32 val)
212{
213 int stat;
214 u8 data[MXL_HYDRA_REG_WRITE_LEN] = {
215 MXL_HYDRA_PLID_REG_WRITE, 0x08,
216 BYTE0(reg), BYTE1(reg), BYTE2(reg), BYTE3(reg),
217 BYTE0(val), BYTE1(val), BYTE2(val), BYTE3(val),
218 };
219 mutex_lock(&state->base->i2c_lock);
220 stat = i2cwrite(state, data, sizeof(data));
221 mutex_unlock(&state->base->i2c_lock);
222 if (stat)
223 dev_err(state->i2cdev, "i2c write error\n");
224 return stat;
225}
226
227static int write_firmware_block(struct mxl *state,
228 u32 reg, u32 size, u8 *reg_data_ptr)
229{
230 int stat;
231 u8 *buf = state->base->buf;
232
233 mutex_lock(&state->base->i2c_lock);
234 buf[0] = MXL_HYDRA_PLID_REG_WRITE;
235 buf[1] = size + 4;
236 buf[2] = GET_BYTE(reg, 0);
237 buf[3] = GET_BYTE(reg, 1);
238 buf[4] = GET_BYTE(reg, 2);
239 buf[5] = GET_BYTE(reg, 3);
240 memcpy(&buf[6], reg_data_ptr, size);
241 stat = i2cwrite(state, buf,
242 MXL_HYDRA_I2C_HDR_SIZE +
243 MXL_HYDRA_REG_SIZE_IN_BYTES + size);
244 mutex_unlock(&state->base->i2c_lock);
245 if (stat)
246 dev_err(state->i2cdev, "fw block write failed\n");
247 return stat;
248}
249
250static int read_register(struct mxl *state, u32 reg, u32 *val)
251{
252 int stat;
253 u8 data[MXL_HYDRA_REG_SIZE_IN_BYTES + MXL_HYDRA_I2C_HDR_SIZE] = {
254 MXL_HYDRA_PLID_REG_READ, 0x04,
255 GET_BYTE(reg, 0), GET_BYTE(reg, 1),
256 GET_BYTE(reg, 2), GET_BYTE(reg, 3),
257 };
258
259 mutex_lock(&state->base->i2c_lock);
260 stat = i2cwrite(state, data,
261 MXL_HYDRA_REG_SIZE_IN_BYTES + MXL_HYDRA_I2C_HDR_SIZE);
262 if (stat)
263 dev_err(state->i2cdev, "i2c read error 1\n");
264 if (!stat)
265 stat = i2cread(state, (u8 *) val,
266 MXL_HYDRA_REG_SIZE_IN_BYTES);
267 mutex_unlock(&state->base->i2c_lock);
268 le32_to_cpus(val);
269 if (stat)
270 dev_err(state->i2cdev, "i2c read error 2\n");
271 return stat;
272}
273
274static int read_register_block(struct mxl *state, u32 reg, u32 size, u8 *data)
275{
276 int stat;
277 u8 *buf = state->base->buf;
278
279 mutex_lock(&state->base->i2c_lock);
280
281 buf[0] = MXL_HYDRA_PLID_REG_READ;
282 buf[1] = size + 4;
283 buf[2] = GET_BYTE(reg, 0);
284 buf[3] = GET_BYTE(reg, 1);
285 buf[4] = GET_BYTE(reg, 2);
286 buf[5] = GET_BYTE(reg, 3);
287 stat = i2cwrite(state, buf,
288 MXL_HYDRA_I2C_HDR_SIZE + MXL_HYDRA_REG_SIZE_IN_BYTES);
289 if (!stat) {
290 stat = i2cread(state, data, size);
291 convert_endian(MXL_ENABLE_BIG_ENDIAN, size, data);
292 }
293 mutex_unlock(&state->base->i2c_lock);
294 return stat;
295}
296
297static int read_by_mnemonic(struct mxl *state,
298 u32 reg, u8 lsbloc, u8 numofbits, u32 *val)
299{
300 u32 data = 0, mask = 0;
301 int stat;
302
303 stat = read_register(state, reg, &data);
304 if (stat)
305 return stat;
306 mask = MXL_GET_REG_MASK_32(lsbloc, numofbits);
307 data &= mask;
308 data >>= lsbloc;
309 *val = data;
310 return 0;
311}
312
313
314static int update_by_mnemonic(struct mxl *state,
315 u32 reg, u8 lsbloc, u8 numofbits, u32 val)
316{
317 u32 data, mask;
318 int stat;
319
320 stat = read_register(state, reg, &data);
321 if (stat)
322 return stat;
323 mask = MXL_GET_REG_MASK_32(lsbloc, numofbits);
324 data = (data & ~mask) | ((val << lsbloc) & mask);
325 stat = write_register(state, reg, data);
326 return stat;
327}
328
329static int firmware_is_alive(struct mxl *state)
330{
331 u32 hb0, hb1;
332
333 if (read_register(state, HYDRA_HEAR_BEAT, &hb0))
334 return 0;
335 msleep(20);
336 if (read_register(state, HYDRA_HEAR_BEAT, &hb1))
337 return 0;
338 if (hb1 == hb0)
339 return 0;
340 return 1;
341}
342
343static int init(struct dvb_frontend *fe)
344{
345 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
346
347 /* init fe stats */
348 p->strength.len = 1;
349 p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
350 p->cnr.len = 1;
351 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
352 p->pre_bit_error.len = 1;
353 p->pre_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
354 p->pre_bit_count.len = 1;
355 p->pre_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
356 p->post_bit_error.len = 1;
357 p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
358 p->post_bit_count.len = 1;
359 p->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
360
361 return 0;
362}
363
364static void release(struct dvb_frontend *fe)
365{
366 struct mxl *state = fe->demodulator_priv;
367
368 list_del(&state->mxl);
369 /* Release one frontend, two more shall take its place! */
370 state->base->count--;
371 if (state->base->count == 0) {
372 list_del(&state->base->mxllist);
373 kfree(state->base);
374 }
375 kfree(state);
376}
377
378static int get_algo(struct dvb_frontend *fe)
379{
380 return DVBFE_ALGO_HW;
381}
382
383static int cfg_demod_abort_tune(struct mxl *state)
384{
385 struct MXL_HYDRA_DEMOD_ABORT_TUNE_T abort_tune_cmd;
386 u8 cmd_size = sizeof(abort_tune_cmd);
387 u8 cmd_buff[MXL_HYDRA_OEM_MAX_CMD_BUFF_LEN];
388
389 abort_tune_cmd.demod_id = state->demod;
390 BUILD_HYDRA_CMD(MXL_HYDRA_ABORT_TUNE_CMD, MXL_CMD_WRITE,
391 cmd_size, &abort_tune_cmd, cmd_buff);
392 return send_command(state, cmd_size + MXL_HYDRA_CMD_HEADER_SIZE,
393 &cmd_buff[0]);
394}
395
396static int send_master_cmd(struct dvb_frontend *fe,
397 struct dvb_diseqc_master_cmd *cmd)
398{
399 /*struct mxl *state = fe->demodulator_priv;*/
400
401 return 0; /*CfgDemodAbortTune(state);*/
402}
403
404static int set_parameters(struct dvb_frontend *fe)
405{
406 struct mxl *state = fe->demodulator_priv;
407 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
408 struct MXL_HYDRA_DEMOD_PARAM_T demod_chan_cfg;
409 u8 cmd_size = sizeof(demod_chan_cfg);
410 u8 cmd_buff[MXL_HYDRA_OEM_MAX_CMD_BUFF_LEN];
411 u32 srange = 10;
412 int stat;
413
414 if (p->frequency < 950000 || p->frequency > 2150000)
415 return -EINVAL;
416 if (p->symbol_rate < 1000000 || p->symbol_rate > 45000000)
417 return -EINVAL;
418
419 /* CfgDemodAbortTune(state); */
420
421 switch (p->delivery_system) {
422 case SYS_DSS:
423 demod_chan_cfg.standard = MXL_HYDRA_DSS;
424 demod_chan_cfg.roll_off = MXL_HYDRA_ROLLOFF_AUTO;
425 break;
426 case SYS_DVBS:
427 srange = p->symbol_rate / 1000000;
428 if (srange > 10)
429 srange = 10;
430 demod_chan_cfg.standard = MXL_HYDRA_DVBS;
431 demod_chan_cfg.roll_off = MXL_HYDRA_ROLLOFF_0_35;
432 demod_chan_cfg.modulation_scheme = MXL_HYDRA_MOD_QPSK;
433 demod_chan_cfg.pilots = MXL_HYDRA_PILOTS_OFF;
434 break;
435 case SYS_DVBS2:
436 demod_chan_cfg.standard = MXL_HYDRA_DVBS2;
437 demod_chan_cfg.roll_off = MXL_HYDRA_ROLLOFF_AUTO;
438 demod_chan_cfg.modulation_scheme = MXL_HYDRA_MOD_AUTO;
439 demod_chan_cfg.pilots = MXL_HYDRA_PILOTS_AUTO;
440 /* cfg_scrambler(state); */
441 break;
442 default:
443 return -EINVAL;
444 }
445 demod_chan_cfg.tuner_index = state->tuner;
446 demod_chan_cfg.demod_index = state->demod;
447 demod_chan_cfg.frequency_in_hz = p->frequency * 1000;
448 demod_chan_cfg.symbol_rate_in_hz = p->symbol_rate;
449 demod_chan_cfg.max_carrier_offset_in_mhz = srange;
450 demod_chan_cfg.spectrum_inversion = MXL_HYDRA_SPECTRUM_AUTO;
451 demod_chan_cfg.fec_code_rate = MXL_HYDRA_FEC_AUTO;
452
453 mutex_lock(&state->base->tune_lock);
454 if (time_after(jiffies + msecs_to_jiffies(200),
455 state->base->next_tune))
456 while (time_before(jiffies, state->base->next_tune))
457 usleep_range(10000, 11000);
458 state->base->next_tune = jiffies + msecs_to_jiffies(100);
459 state->tuner_in_use = state->tuner;
460 BUILD_HYDRA_CMD(MXL_HYDRA_DEMOD_SET_PARAM_CMD, MXL_CMD_WRITE,
461 cmd_size, &demod_chan_cfg, cmd_buff);
462 stat = send_command(state, cmd_size + MXL_HYDRA_CMD_HEADER_SIZE,
463 &cmd_buff[0]);
464 mutex_unlock(&state->base->tune_lock);
465 return stat;
466}
467
468static int enable_tuner(struct mxl *state, u32 tuner, u32 enable);
469
470static int sleep(struct dvb_frontend *fe)
471{
472 struct mxl *state = fe->demodulator_priv;
473 struct mxl *p;
474
475 cfg_demod_abort_tune(state);
476 if (state->tuner_in_use != 0xffffffff) {
477 mutex_lock(&state->base->tune_lock);
478 state->tuner_in_use = 0xffffffff;
479 list_for_each_entry(p, &state->base->mxls, mxl) {
480 if (p->tuner_in_use == state->tuner)
481 break;
482 }
483 if (&p->mxl == &state->base->mxls)
484 enable_tuner(state, state->tuner, 0);
485 mutex_unlock(&state->base->tune_lock);
486 }
487 return 0;
488}
489
490static int read_snr(struct dvb_frontend *fe)
491{
492 struct mxl *state = fe->demodulator_priv;
493 int stat;
494 u32 reg_data = 0;
495 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
496
497 mutex_lock(&state->base->status_lock);
498 HYDRA_DEMOD_STATUS_LOCK(state, state->demod);
499 stat = read_register(state, (HYDRA_DMD_SNR_ADDR_OFFSET +
500 HYDRA_DMD_STATUS_OFFSET(state->demod)),
501 &reg_data);
502 HYDRA_DEMOD_STATUS_UNLOCK(state, state->demod);
503 mutex_unlock(&state->base->status_lock);
504
505 p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
506 p->cnr.stat[0].svalue = (s16)reg_data * 10;
507
508 return stat;
509}
510
511static int read_ber(struct dvb_frontend *fe)
512{
513 struct mxl *state = fe->demodulator_priv;
514 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
515 u32 reg[8];
516
517 mutex_lock(&state->base->status_lock);
518 HYDRA_DEMOD_STATUS_LOCK(state, state->demod);
519 read_register_block(state,
520 (HYDRA_DMD_DVBS_1ST_CORR_RS_ERRORS_ADDR_OFFSET +
521 HYDRA_DMD_STATUS_OFFSET(state->demod)),
522 (4 * sizeof(u32)),
523 (u8 *) &reg[0]);
524 HYDRA_DEMOD_STATUS_UNLOCK(state, state->demod);
525
526 switch (p->delivery_system) {
527 case SYS_DSS:
528 case SYS_DVBS:
529 p->pre_bit_error.stat[0].scale = FE_SCALE_COUNTER;
530 p->pre_bit_error.stat[0].uvalue = reg[2];
531 p->pre_bit_count.stat[0].scale = FE_SCALE_COUNTER;
532 p->pre_bit_count.stat[0].uvalue = reg[3];
533 break;
534 default:
535 break;
536 }
537
538 read_register_block(state,
539 (HYDRA_DMD_DVBS2_CRC_ERRORS_ADDR_OFFSET +
540 HYDRA_DMD_STATUS_OFFSET(state->demod)),
541 (7 * sizeof(u32)),
542 (u8 *) &reg[0]);
543
544 switch (p->delivery_system) {
545 case SYS_DSS:
546 case SYS_DVBS:
547 p->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
548 p->post_bit_error.stat[0].uvalue = reg[5];
549 p->post_bit_count.stat[0].scale = FE_SCALE_COUNTER;
550 p->post_bit_count.stat[0].uvalue = reg[6];
551 break;
552 case SYS_DVBS2:
553 p->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
554 p->post_bit_error.stat[0].uvalue = reg[1];
555 p->post_bit_count.stat[0].scale = FE_SCALE_COUNTER;
556 p->post_bit_count.stat[0].uvalue = reg[2];
557 break;
558 default:
559 break;
560 }
561
562 mutex_unlock(&state->base->status_lock);
563
564 return 0;
565}
566
567static int read_signal_strength(struct dvb_frontend *fe)
568{
569 struct mxl *state = fe->demodulator_priv;
570 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
571 int stat;
572 u32 reg_data = 0;
573
574 mutex_lock(&state->base->status_lock);
575 HYDRA_DEMOD_STATUS_LOCK(state, state->demod);
576 stat = read_register(state, (HYDRA_DMD_STATUS_INPUT_POWER_ADDR +
577 HYDRA_DMD_STATUS_OFFSET(state->demod)),
578 &reg_data);
579 HYDRA_DEMOD_STATUS_UNLOCK(state, state->demod);
580 mutex_unlock(&state->base->status_lock);
581
582 p->strength.stat[0].scale = FE_SCALE_DECIBEL;
583 p->strength.stat[0].svalue = (s16) reg_data * 10; /* fix scale */
584
585 return stat;
586}
587
588static int read_status(struct dvb_frontend *fe, enum fe_status *status)
589{
590 struct mxl *state = fe->demodulator_priv;
591 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
592 u32 reg_data = 0;
593
594 mutex_lock(&state->base->status_lock);
595 HYDRA_DEMOD_STATUS_LOCK(state, state->demod);
596 read_register(state, (HYDRA_DMD_LOCK_STATUS_ADDR_OFFSET +
597 HYDRA_DMD_STATUS_OFFSET(state->demod)),
598 &reg_data);
599 HYDRA_DEMOD_STATUS_UNLOCK(state, state->demod);
600 mutex_unlock(&state->base->status_lock);
601
602 *status = (reg_data == 1) ? 0x1f : 0;
603
604 /* signal statistics */
605
606 /* signal strength is always available */
607 read_signal_strength(fe);
608
609 if (*status & FE_HAS_CARRIER)
610 read_snr(fe);
611 else
612 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
613
614 if (*status & FE_HAS_SYNC)
615 read_ber(fe);
616 else {
617 p->pre_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
618 p->pre_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
619 p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
620 p->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
621 }
622
623 return 0;
624}
625
626static int tune(struct dvb_frontend *fe, bool re_tune,
627 unsigned int mode_flags,
628 unsigned int *delay, enum fe_status *status)
629{
630 struct mxl *state = fe->demodulator_priv;
631 int r = 0;
632
633 *delay = HZ / 2;
634 if (re_tune) {
635 r = set_parameters(fe);
636 if (r)
637 return r;
638 state->tune_time = jiffies;
639 return 0;
640 }
641 if (*status & FE_HAS_LOCK)
642 return 0;
643
644 r = read_status(fe, status);
645 if (r)
646 return r;
647
648 return 0;
649}
650
651static enum fe_code_rate conv_fec(enum MXL_HYDRA_FEC_E fec)
652{
653 enum fe_code_rate fec2fec[11] = {
654 FEC_NONE, FEC_1_2, FEC_3_5, FEC_2_3,
655 FEC_3_4, FEC_4_5, FEC_5_6, FEC_6_7,
656 FEC_7_8, FEC_8_9, FEC_9_10
657 };
658
659 if (fec > MXL_HYDRA_FEC_9_10)
660 return FEC_NONE;
661 return fec2fec[fec];
662}
663
664static int get_frontend(struct dvb_frontend *fe,
665 struct dtv_frontend_properties *p)
666{
667 struct mxl *state = fe->demodulator_priv;
668 u32 reg_data[MXL_DEMOD_CHAN_PARAMS_BUFF_SIZE];
669 u32 freq;
670
671 mutex_lock(&state->base->status_lock);
672 HYDRA_DEMOD_STATUS_LOCK(state, state->demod);
673 read_register_block(state,
674 (HYDRA_DMD_STANDARD_ADDR_OFFSET +
675 HYDRA_DMD_STATUS_OFFSET(state->demod)),
676 (MXL_DEMOD_CHAN_PARAMS_BUFF_SIZE * 4), /* 25 * 4 bytes */
677 (u8 *) &reg_data[0]);
678 /* read demod channel parameters */
679 read_register_block(state,
680 (HYDRA_DMD_STATUS_CENTER_FREQ_IN_KHZ_ADDR +
681 HYDRA_DMD_STATUS_OFFSET(state->demod)),
682 (4), /* 4 bytes */
683 (u8 *) &freq);
684 HYDRA_DEMOD_STATUS_UNLOCK(state, state->demod);
685 mutex_unlock(&state->base->status_lock);
686
687 dev_dbg(state->i2cdev, "freq=%u delsys=%u srate=%u\n",
688 freq * 1000, reg_data[DMD_STANDARD_ADDR],
689 reg_data[DMD_SYMBOL_RATE_ADDR]);
690 p->symbol_rate = reg_data[DMD_SYMBOL_RATE_ADDR];
691 p->frequency = freq;
692 /*
693 * p->delivery_system =
694 * (MXL_HYDRA_BCAST_STD_E) regData[DMD_STANDARD_ADDR];
695 * p->inversion =
696 * (MXL_HYDRA_SPECTRUM_E) regData[DMD_SPECTRUM_INVERSION_ADDR];
697 * freqSearchRangeKHz =
698 * (regData[DMD_FREQ_SEARCH_RANGE_IN_KHZ_ADDR]);
699 */
700
701 p->fec_inner = conv_fec(reg_data[DMD_FEC_CODE_RATE_ADDR]);
702 switch (p->delivery_system) {
703 case SYS_DSS:
704 break;
705 case SYS_DVBS2:
706 switch ((enum MXL_HYDRA_PILOTS_E)
707 reg_data[DMD_DVBS2_PILOT_ON_OFF_ADDR]) {
708 case MXL_HYDRA_PILOTS_OFF:
709 p->pilot = PILOT_OFF;
710 break;
711 case MXL_HYDRA_PILOTS_ON:
712 p->pilot = PILOT_ON;
713 break;
714 default:
715 break;
716 }
717 case SYS_DVBS:
718 switch ((enum MXL_HYDRA_MODULATION_E)
719 reg_data[DMD_MODULATION_SCHEME_ADDR]) {
720 case MXL_HYDRA_MOD_QPSK:
721 p->modulation = QPSK;
722 break;
723 case MXL_HYDRA_MOD_8PSK:
724 p->modulation = PSK_8;
725 break;
726 default:
727 break;
728 }
729 switch ((enum MXL_HYDRA_ROLLOFF_E)
730 reg_data[DMD_SPECTRUM_ROLL_OFF_ADDR]) {
731 case MXL_HYDRA_ROLLOFF_0_20:
732 p->rolloff = ROLLOFF_20;
733 break;
734 case MXL_HYDRA_ROLLOFF_0_35:
735 p->rolloff = ROLLOFF_35;
736 break;
737 case MXL_HYDRA_ROLLOFF_0_25:
738 p->rolloff = ROLLOFF_25;
739 break;
740 default:
741 break;
742 }
743 break;
744 default:
745 return -EINVAL;
746 }
747 return 0;
748}
749
750static int set_input(struct dvb_frontend *fe, int input)
751{
752 struct mxl *state = fe->demodulator_priv;
753
754 state->tuner = input;
755 return 0;
756}
757
758static struct dvb_frontend_ops mxl_ops = {
759 .delsys = { SYS_DVBS, SYS_DVBS2, SYS_DSS },
760 .info = {
761 .name = "MaxLinear MxL5xx DVB-S/S2 tuner-demodulator",
762 .frequency_min = 300000,
763 .frequency_max = 2350000,
764 .frequency_stepsize = 0,
765 .frequency_tolerance = 0,
766 .symbol_rate_min = 1000000,
767 .symbol_rate_max = 45000000,
768 .caps = FE_CAN_INVERSION_AUTO |
769 FE_CAN_FEC_AUTO |
770 FE_CAN_QPSK |
771 FE_CAN_2G_MODULATION
772 },
773 .init = init,
774 .release = release,
775 .get_frontend_algo = get_algo,
776 .tune = tune,
777 .read_status = read_status,
778 .sleep = sleep,
779 .get_frontend = get_frontend,
780 .diseqc_send_master_cmd = send_master_cmd,
781};
782
783static struct mxl_base *match_base(struct i2c_adapter *i2c, u8 adr)
784{
785 struct mxl_base *p;
786
787 list_for_each_entry(p, &mxllist, mxllist)
788 if (p->i2c == i2c && p->adr == adr)
789 return p;
790 return NULL;
791}
792
793static void cfg_dev_xtal(struct mxl *state, u32 freq, u32 cap, u32 enable)
794{
795 if (state->base->can_clkout || !enable)
796 update_by_mnemonic(state, 0x90200054, 23, 1, enable);
797
798 if (freq == 24000000)
799 write_register(state, HYDRA_CRYSTAL_SETTING, 0);
800 else
801 write_register(state, HYDRA_CRYSTAL_SETTING, 1);
802
803 write_register(state, HYDRA_CRYSTAL_CAP, cap);
804}
805
806static u32 get_big_endian(u8 num_of_bits, const u8 buf[])
807{
808 u32 ret_value = 0;
809
810 switch (num_of_bits) {
811 case 24:
812 ret_value = (((u32) buf[0]) << 16) |
813 (((u32) buf[1]) << 8) | buf[2];
814 break;
815 case 32:
816 ret_value = (((u32) buf[0]) << 24) |
817 (((u32) buf[1]) << 16) |
818 (((u32) buf[2]) << 8) | buf[3];
819 break;
820 default:
821 break;
822 }
823
824 return ret_value;
825}
826
827static int write_fw_segment(struct mxl *state,
828 u32 mem_addr, u32 total_size, u8 *data_ptr)
829{
830 int status;
831 u32 data_count = 0;
832 u32 size = 0;
833 u32 orig_size = 0;
834 u8 *w_buf_ptr = NULL;
835 u32 block_size = ((MXL_HYDRA_OEM_MAX_BLOCK_WRITE_LENGTH -
836 (MXL_HYDRA_I2C_HDR_SIZE +
837 MXL_HYDRA_REG_SIZE_IN_BYTES)) / 4) * 4;
838 u8 w_msg_buffer[MXL_HYDRA_OEM_MAX_BLOCK_WRITE_LENGTH -
839 (MXL_HYDRA_I2C_HDR_SIZE + MXL_HYDRA_REG_SIZE_IN_BYTES)];
840
841 do {
842 size = orig_size = (((u32)(data_count + block_size)) > total_size) ?
843 (total_size - data_count) : block_size;
844
845 if (orig_size & 3)
846 size = (orig_size + 4) & ~3;
847 w_buf_ptr = &w_msg_buffer[0];
848 memset((void *) w_buf_ptr, 0, size);
849 memcpy((void *) w_buf_ptr, (void *) data_ptr, orig_size);
850 convert_endian(1, size, w_buf_ptr);
851 status = write_firmware_block(state, mem_addr, size, w_buf_ptr);
852 if (status)
853 return status;
854 data_count += size;
855 mem_addr += size;
856 data_ptr += size;
857 } while (data_count < total_size);
858
859 return status;
860}
861
862static int do_firmware_download(struct mxl *state, u8 *mbin_buffer_ptr,
863 u32 mbin_buffer_size)
864
865{
866 int status;
867 u32 index = 0;
868 u32 seg_length = 0;
869 u32 seg_address = 0;
870 struct MBIN_FILE_T *mbin_ptr = (struct MBIN_FILE_T *)mbin_buffer_ptr;
871 struct MBIN_SEGMENT_T *segment_ptr;
872 enum MXL_BOOL_E xcpu_fw_flag = MXL_FALSE;
873
874 if (mbin_ptr->header.id != MBIN_FILE_HEADER_ID) {
875 dev_err(state->i2cdev, "%s: Invalid file header ID (%c)\n",
876 __func__, mbin_ptr->header.id);
877 return -EINVAL;
878 }
879 status = write_register(state, FW_DL_SIGN_ADDR, 0);
880 if (status)
881 return status;
882 segment_ptr = (struct MBIN_SEGMENT_T *) (&mbin_ptr->data[0]);
883 for (index = 0; index < mbin_ptr->header.num_segments; index++) {
884 if (segment_ptr->header.id != MBIN_SEGMENT_HEADER_ID) {
885 dev_err(state->i2cdev, "%s: Invalid segment header ID (%c)\n",
886 __func__, segment_ptr->header.id);
887 return -EINVAL;
888 }
889 seg_length = get_big_endian(24,
890 &(segment_ptr->header.len24[0]));
891 seg_address = get_big_endian(32,
892 &(segment_ptr->header.address[0]));
893
894 if (state->base->type == MXL_HYDRA_DEVICE_568) {
895 if ((((seg_address & 0x90760000) == 0x90760000) ||
896 ((seg_address & 0x90740000) == 0x90740000)) &&
897 (xcpu_fw_flag == MXL_FALSE)) {
898 update_by_mnemonic(state, 0x8003003C, 0, 1, 1);
899 msleep(200);
900 write_register(state, 0x90720000, 0);
901 usleep_range(10000, 11000);
902 xcpu_fw_flag = MXL_TRUE;
903 }
904 status = write_fw_segment(state, seg_address,
905 seg_length,
906 (u8 *) segment_ptr->data);
907 } else {
908 if (((seg_address & 0x90760000) != 0x90760000) &&
909 ((seg_address & 0x90740000) != 0x90740000))
910 status = write_fw_segment(state, seg_address,
911 seg_length, (u8 *) segment_ptr->data);
912 }
913 if (status)
914 return status;
915 segment_ptr = (struct MBIN_SEGMENT_T *)
916 &(segment_ptr->data[((seg_length + 3) / 4) * 4]);
917 }
918 return status;
919}
920
921static int check_fw(struct mxl *state, u8 *mbin, u32 mbin_len)
922{
923 struct MBIN_FILE_HEADER_T *fh = (struct MBIN_FILE_HEADER_T *) mbin;
924 u32 flen = (fh->image_size24[0] << 16) |
925 (fh->image_size24[1] << 8) | fh->image_size24[2];
926 u8 *fw, cs = 0;
927 u32 i;
928
929 if (fh->id != 'M' || fh->fmt_version != '1' || flen > 0x3FFF0) {
930 dev_info(state->i2cdev, "Invalid FW Header\n");
931 return -1;
932 }
933 fw = mbin + sizeof(struct MBIN_FILE_HEADER_T);
934 for (i = 0; i < flen; i += 1)
935 cs += fw[i];
936 if (cs != fh->image_checksum) {
937 dev_info(state->i2cdev, "Invalid FW Checksum\n");
938 return -1;
939 }
940 return 0;
941}
942
943static int firmware_download(struct mxl *state, u8 *mbin, u32 mbin_len)
944{
945 int status;
946 u32 reg_data = 0;
947 struct MXL_HYDRA_SKU_COMMAND_T dev_sku_cfg;
948 u8 cmd_size = sizeof(struct MXL_HYDRA_SKU_COMMAND_T);
949 u8 cmd_buff[sizeof(struct MXL_HYDRA_SKU_COMMAND_T) + 6];
950
951 if (check_fw(state, mbin, mbin_len))
952 return -1;
953
954 /* put CPU into reset */
955 status = update_by_mnemonic(state, 0x8003003C, 0, 1, 0);
956 if (status)
957 return status;
958 usleep_range(1000, 2000);
959
960 /* Reset TX FIFO's, BBAND, XBAR */
961 status = write_register(state, HYDRA_RESET_TRANSPORT_FIFO_REG,
962 HYDRA_RESET_TRANSPORT_FIFO_DATA);
963 if (status)
964 return status;
965 status = write_register(state, HYDRA_RESET_BBAND_REG,
966 HYDRA_RESET_BBAND_DATA);
967 if (status)
968 return status;
969 status = write_register(state, HYDRA_RESET_XBAR_REG,
970 HYDRA_RESET_XBAR_DATA);
971 if (status)
972 return status;
973
974 /* Disable clock to Baseband, Wideband, SerDes,
975 * Alias ext & Transport modules
976 */
977 status = write_register(state, HYDRA_MODULES_CLK_2_REG,
978 HYDRA_DISABLE_CLK_2);
979 if (status)
980 return status;
981 /* Clear Software & Host interrupt status - (Clear on read) */
982 status = read_register(state, HYDRA_PRCM_ROOT_CLK_REG, &reg_data);
983 if (status)
984 return status;
985 status = do_firmware_download(state, mbin, mbin_len);
986 if (status)
987 return status;
988
989 if (state->base->type == MXL_HYDRA_DEVICE_568) {
990 usleep_range(10000, 11000);
991
992 /* bring XCPU out of reset */
993 status = write_register(state, 0x90720000, 1);
994 if (status)
995 return status;
996 msleep(500);
997
998 /* Enable XCPU UART message processing in MCPU */
999 status = write_register(state, 0x9076B510, 1);
1000 if (status)
1001 return status;
1002 } else {
1003 /* Bring CPU out of reset */
1004 status = update_by_mnemonic(state, 0x8003003C, 0, 1, 1);
1005 if (status)
1006 return status;
1007 /* Wait until FW boots */
1008 msleep(150);
1009 }
1010
1011 /* Initialize XPT XBAR */
1012 status = write_register(state, XPT_DMD0_BASEADDR, 0x76543210);
1013 if (status)
1014 return status;
1015
1016 if (!firmware_is_alive(state))
1017 return -1;
1018
1019 dev_info(state->i2cdev, "Hydra FW alive. Hail!\n");
1020
1021 /* sometimes register values are wrong shortly
1022 * after first heart beats
1023 */
1024 msleep(50);
1025
1026 dev_sku_cfg.sku_type = state->base->sku_type;
1027 BUILD_HYDRA_CMD(MXL_HYDRA_DEV_CFG_SKU_CMD, MXL_CMD_WRITE,
1028 cmd_size, &dev_sku_cfg, cmd_buff);
1029 status = send_command(state, cmd_size + MXL_HYDRA_CMD_HEADER_SIZE,
1030 &cmd_buff[0]);
1031
1032 return status;
1033}
1034
1035static int cfg_ts_pad_mux(struct mxl *state, enum MXL_BOOL_E enable_serial_ts)
1036{
1037 int status = 0;
1038 u32 pad_mux_value = 0;
1039
1040 if (enable_serial_ts == MXL_TRUE) {
1041 pad_mux_value = 0;
1042 if ((state->base->type == MXL_HYDRA_DEVICE_541) ||
1043 (state->base->type == MXL_HYDRA_DEVICE_541S))
1044 pad_mux_value = 2;
1045 } else {
1046 if ((state->base->type == MXL_HYDRA_DEVICE_581) ||
1047 (state->base->type == MXL_HYDRA_DEVICE_581S))
1048 pad_mux_value = 2;
1049 else
1050 pad_mux_value = 3;
1051 }
1052
1053 switch (state->base->type) {
1054 case MXL_HYDRA_DEVICE_561:
1055 case MXL_HYDRA_DEVICE_581:
1056 case MXL_HYDRA_DEVICE_541:
1057 case MXL_HYDRA_DEVICE_541S:
1058 case MXL_HYDRA_DEVICE_561S:
1059 case MXL_HYDRA_DEVICE_581S:
1060 status |= update_by_mnemonic(state, 0x90000170, 24, 3,
1061 pad_mux_value);
1062 status |= update_by_mnemonic(state, 0x90000170, 28, 3,
1063 pad_mux_value);
1064 status |= update_by_mnemonic(state, 0x90000174, 0, 3,
1065 pad_mux_value);
1066 status |= update_by_mnemonic(state, 0x90000174, 4, 3,
1067 pad_mux_value);
1068 status |= update_by_mnemonic(state, 0x90000174, 8, 3,
1069 pad_mux_value);
1070 status |= update_by_mnemonic(state, 0x90000174, 12, 3,
1071 pad_mux_value);
1072 status |= update_by_mnemonic(state, 0x90000174, 16, 3,
1073 pad_mux_value);
1074 status |= update_by_mnemonic(state, 0x90000174, 20, 3,
1075 pad_mux_value);
1076 status |= update_by_mnemonic(state, 0x90000174, 24, 3,
1077 pad_mux_value);
1078 status |= update_by_mnemonic(state, 0x90000174, 28, 3,
1079 pad_mux_value);
1080 status |= update_by_mnemonic(state, 0x90000178, 0, 3,
1081 pad_mux_value);
1082 status |= update_by_mnemonic(state, 0x90000178, 4, 3,
1083 pad_mux_value);
1084 status |= update_by_mnemonic(state, 0x90000178, 8, 3,
1085 pad_mux_value);
1086 break;
1087
1088 case MXL_HYDRA_DEVICE_544:
1089 case MXL_HYDRA_DEVICE_542:
1090 status |= update_by_mnemonic(state, 0x9000016C, 4, 3, 1);
1091 status |= update_by_mnemonic(state, 0x9000016C, 8, 3, 0);
1092 status |= update_by_mnemonic(state, 0x9000016C, 12, 3, 0);
1093 status |= update_by_mnemonic(state, 0x9000016C, 16, 3, 0);
1094 status |= update_by_mnemonic(state, 0x90000170, 0, 3, 0);
1095 status |= update_by_mnemonic(state, 0x90000178, 12, 3, 1);
1096 status |= update_by_mnemonic(state, 0x90000178, 16, 3, 1);
1097 status |= update_by_mnemonic(state, 0x90000178, 20, 3, 1);
1098 status |= update_by_mnemonic(state, 0x90000178, 24, 3, 1);
1099 status |= update_by_mnemonic(state, 0x9000017C, 0, 3, 1);
1100 status |= update_by_mnemonic(state, 0x9000017C, 4, 3, 1);
1101 if (enable_serial_ts == MXL_ENABLE) {
1102 status |= update_by_mnemonic(state,
1103 0x90000170, 4, 3, 0);
1104 status |= update_by_mnemonic(state,
1105 0x90000170, 8, 3, 0);
1106 status |= update_by_mnemonic(state,
1107 0x90000170, 12, 3, 0);
1108 status |= update_by_mnemonic(state,
1109 0x90000170, 16, 3, 0);
1110 status |= update_by_mnemonic(state,
1111 0x90000170, 20, 3, 1);
1112 status |= update_by_mnemonic(state,
1113 0x90000170, 24, 3, 1);
1114 status |= update_by_mnemonic(state,
1115 0x90000170, 28, 3, 2);
1116 status |= update_by_mnemonic(state,
1117 0x90000174, 0, 3, 2);
1118 status |= update_by_mnemonic(state,
1119 0x90000174, 4, 3, 2);
1120 status |= update_by_mnemonic(state,
1121 0x90000174, 8, 3, 2);
1122 status |= update_by_mnemonic(state,
1123 0x90000174, 12, 3, 2);
1124 status |= update_by_mnemonic(state,
1125 0x90000174, 16, 3, 2);
1126 status |= update_by_mnemonic(state,
1127 0x90000174, 20, 3, 2);
1128 status |= update_by_mnemonic(state,
1129 0x90000174, 24, 3, 2);
1130 status |= update_by_mnemonic(state,
1131 0x90000174, 28, 3, 2);
1132 status |= update_by_mnemonic(state,
1133 0x90000178, 0, 3, 2);
1134 status |= update_by_mnemonic(state,
1135 0x90000178, 4, 3, 2);
1136 status |= update_by_mnemonic(state,
1137 0x90000178, 8, 3, 2);
1138 } else {
1139 status |= update_by_mnemonic(state,
1140 0x90000170, 4, 3, 3);
1141 status |= update_by_mnemonic(state,
1142 0x90000170, 8, 3, 3);
1143 status |= update_by_mnemonic(state,
1144 0x90000170, 12, 3, 3);
1145 status |= update_by_mnemonic(state,
1146 0x90000170, 16, 3, 3);
1147 status |= update_by_mnemonic(state,
1148 0x90000170, 20, 3, 3);
1149 status |= update_by_mnemonic(state,
1150 0x90000170, 24, 3, 3);
1151 status |= update_by_mnemonic(state,
1152 0x90000170, 28, 3, 3);
1153 status |= update_by_mnemonic(state,
1154 0x90000174, 0, 3, 3);
1155 status |= update_by_mnemonic(state,
1156 0x90000174, 4, 3, 3);
1157 status |= update_by_mnemonic(state,
1158 0x90000174, 8, 3, 3);
1159 status |= update_by_mnemonic(state,
1160 0x90000174, 12, 3, 3);
1161 status |= update_by_mnemonic(state,
1162 0x90000174, 16, 3, 3);
1163 status |= update_by_mnemonic(state,
1164 0x90000174, 20, 3, 1);
1165 status |= update_by_mnemonic(state,
1166 0x90000174, 24, 3, 1);
1167 status |= update_by_mnemonic(state,
1168 0x90000174, 28, 3, 1);
1169 status |= update_by_mnemonic(state,
1170 0x90000178, 0, 3, 1);
1171 status |= update_by_mnemonic(state,
1172 0x90000178, 4, 3, 1);
1173 status |= update_by_mnemonic(state,
1174 0x90000178, 8, 3, 1);
1175 }
1176 break;
1177
1178 case MXL_HYDRA_DEVICE_568:
1179 if (enable_serial_ts == MXL_FALSE) {
1180 status |= update_by_mnemonic(state,
1181 0x9000016C, 8, 3, 5);
1182 status |= update_by_mnemonic(state,
1183 0x9000016C, 12, 3, 5);
1184 status |= update_by_mnemonic(state,
1185 0x9000016C, 16, 3, 5);
1186 status |= update_by_mnemonic(state,
1187 0x9000016C, 20, 3, 5);
1188 status |= update_by_mnemonic(state,
1189 0x9000016C, 24, 3, 5);
1190 status |= update_by_mnemonic(state,
1191 0x9000016C, 28, 3, 5);
1192 status |= update_by_mnemonic(state,
1193 0x90000170, 0, 3, 5);
1194 status |= update_by_mnemonic(state,
1195 0x90000170, 4, 3, 5);
1196 status |= update_by_mnemonic(state,
1197 0x90000170, 8, 3, 5);
1198 status |= update_by_mnemonic(state,
1199 0x90000170, 12, 3, 5);
1200 status |= update_by_mnemonic(state,
1201 0x90000170, 16, 3, 5);
1202 status |= update_by_mnemonic(state,
1203 0x90000170, 20, 3, 5);
1204
1205 status |= update_by_mnemonic(state,
1206 0x90000170, 24, 3, pad_mux_value);
1207 status |= update_by_mnemonic(state,
1208 0x90000174, 0, 3, pad_mux_value);
1209 status |= update_by_mnemonic(state,
1210 0x90000174, 4, 3, pad_mux_value);
1211 status |= update_by_mnemonic(state,
1212 0x90000174, 8, 3, pad_mux_value);
1213 status |= update_by_mnemonic(state,
1214 0x90000174, 12, 3, pad_mux_value);
1215 status |= update_by_mnemonic(state,
1216 0x90000174, 16, 3, pad_mux_value);
1217 status |= update_by_mnemonic(state,
1218 0x90000174, 20, 3, pad_mux_value);
1219 status |= update_by_mnemonic(state,
1220 0x90000174, 24, 3, pad_mux_value);
1221 status |= update_by_mnemonic(state,
1222 0x90000174, 28, 3, pad_mux_value);
1223 status |= update_by_mnemonic(state,
1224 0x90000178, 0, 3, pad_mux_value);
1225 status |= update_by_mnemonic(state,
1226 0x90000178, 4, 3, pad_mux_value);
1227
1228 status |= update_by_mnemonic(state,
1229 0x90000178, 8, 3, 5);
1230 status |= update_by_mnemonic(state,
1231 0x90000178, 12, 3, 5);
1232 status |= update_by_mnemonic(state,
1233 0x90000178, 16, 3, 5);
1234 status |= update_by_mnemonic(state,
1235 0x90000178, 20, 3, 5);
1236 status |= update_by_mnemonic(state,
1237 0x90000178, 24, 3, 5);
1238 status |= update_by_mnemonic(state,
1239 0x90000178, 28, 3, 5);
1240 status |= update_by_mnemonic(state,
1241 0x9000017C, 0, 3, 5);
1242 status |= update_by_mnemonic(state,
1243 0x9000017C, 4, 3, 5);
1244 } else {
1245 status |= update_by_mnemonic(state,
1246 0x90000170, 4, 3, pad_mux_value);
1247 status |= update_by_mnemonic(state,
1248 0x90000170, 8, 3, pad_mux_value);
1249 status |= update_by_mnemonic(state,
1250 0x90000170, 12, 3, pad_mux_value);
1251 status |= update_by_mnemonic(state,
1252 0x90000170, 16, 3, pad_mux_value);
1253 status |= update_by_mnemonic(state,
1254 0x90000170, 20, 3, pad_mux_value);
1255 status |= update_by_mnemonic(state,
1256 0x90000170, 24, 3, pad_mux_value);
1257 status |= update_by_mnemonic(state,
1258 0x90000170, 28, 3, pad_mux_value);
1259 status |= update_by_mnemonic(state,
1260 0x90000174, 0, 3, pad_mux_value);
1261 status |= update_by_mnemonic(state,
1262 0x90000174, 4, 3, pad_mux_value);
1263 status |= update_by_mnemonic(state,
1264 0x90000174, 8, 3, pad_mux_value);
1265 status |= update_by_mnemonic(state,
1266 0x90000174, 12, 3, pad_mux_value);
1267 }
1268 break;
1269
1270
1271 case MXL_HYDRA_DEVICE_584:
1272 default:
1273 status |= update_by_mnemonic(state,
1274 0x90000170, 4, 3, pad_mux_value);
1275 status |= update_by_mnemonic(state,
1276 0x90000170, 8, 3, pad_mux_value);
1277 status |= update_by_mnemonic(state,
1278 0x90000170, 12, 3, pad_mux_value);
1279 status |= update_by_mnemonic(state,
1280 0x90000170, 16, 3, pad_mux_value);
1281 status |= update_by_mnemonic(state,
1282 0x90000170, 20, 3, pad_mux_value);
1283 status |= update_by_mnemonic(state,
1284 0x90000170, 24, 3, pad_mux_value);
1285 status |= update_by_mnemonic(state,
1286 0x90000170, 28, 3, pad_mux_value);
1287 status |= update_by_mnemonic(state,
1288 0x90000174, 0, 3, pad_mux_value);
1289 status |= update_by_mnemonic(state,
1290 0x90000174, 4, 3, pad_mux_value);
1291 status |= update_by_mnemonic(state,
1292 0x90000174, 8, 3, pad_mux_value);
1293 status |= update_by_mnemonic(state,
1294 0x90000174, 12, 3, pad_mux_value);
1295 break;
1296 }
1297 return status;
1298}
1299
1300static int set_drive_strength(struct mxl *state,
1301 enum MXL_HYDRA_TS_DRIVE_STRENGTH_E ts_drive_strength)
1302{
1303 int stat = 0;
1304 u32 val;
1305
1306 read_register(state, 0x90000194, &val);
1307 dev_info(state->i2cdev, "DIGIO = %08x\n", val);
1308 dev_info(state->i2cdev, "set drive_strength = %u\n", ts_drive_strength);
1309
1310
1311 stat |= update_by_mnemonic(state, 0x90000194, 0, 3, ts_drive_strength);
1312 stat |= update_by_mnemonic(state, 0x90000194, 20, 3, ts_drive_strength);
1313 stat |= update_by_mnemonic(state, 0x90000194, 24, 3, ts_drive_strength);
1314 stat |= update_by_mnemonic(state, 0x90000198, 12, 3, ts_drive_strength);
1315 stat |= update_by_mnemonic(state, 0x90000198, 16, 3, ts_drive_strength);
1316 stat |= update_by_mnemonic(state, 0x90000198, 20, 3, ts_drive_strength);
1317 stat |= update_by_mnemonic(state, 0x90000198, 24, 3, ts_drive_strength);
1318 stat |= update_by_mnemonic(state, 0x9000019C, 0, 3, ts_drive_strength);
1319 stat |= update_by_mnemonic(state, 0x9000019C, 4, 3, ts_drive_strength);
1320 stat |= update_by_mnemonic(state, 0x9000019C, 8, 3, ts_drive_strength);
1321 stat |= update_by_mnemonic(state, 0x9000019C, 24, 3, ts_drive_strength);
1322 stat |= update_by_mnemonic(state, 0x9000019C, 28, 3, ts_drive_strength);
1323 stat |= update_by_mnemonic(state, 0x900001A0, 0, 3, ts_drive_strength);
1324 stat |= update_by_mnemonic(state, 0x900001A0, 4, 3, ts_drive_strength);
1325 stat |= update_by_mnemonic(state, 0x900001A0, 20, 3, ts_drive_strength);
1326 stat |= update_by_mnemonic(state, 0x900001A0, 24, 3, ts_drive_strength);
1327 stat |= update_by_mnemonic(state, 0x900001A0, 28, 3, ts_drive_strength);
1328
1329 return stat;
1330}
1331
1332static int enable_tuner(struct mxl *state, u32 tuner, u32 enable)
1333{
1334 int stat = 0;
1335 struct MXL_HYDRA_TUNER_CMD ctrl_tuner_cmd;
1336 u8 cmd_size = sizeof(ctrl_tuner_cmd);
1337 u8 cmd_buff[MXL_HYDRA_OEM_MAX_CMD_BUFF_LEN];
1338 u32 val, count = 10;
1339
1340 ctrl_tuner_cmd.tuner_id = tuner;
1341 ctrl_tuner_cmd.enable = enable;
1342 BUILD_HYDRA_CMD(MXL_HYDRA_TUNER_ACTIVATE_CMD, MXL_CMD_WRITE,
1343 cmd_size, &ctrl_tuner_cmd, cmd_buff);
1344 stat = send_command(state, cmd_size + MXL_HYDRA_CMD_HEADER_SIZE,
1345 &cmd_buff[0]);
1346 if (stat)
1347 return stat;
1348 read_register(state, HYDRA_TUNER_ENABLE_COMPLETE, &val);
1349 while (--count && ((val >> tuner) & 1) != enable) {
1350 msleep(20);
1351 read_register(state, HYDRA_TUNER_ENABLE_COMPLETE, &val);
1352 }
1353 if (!count)
1354 return -1;
1355 read_register(state, HYDRA_TUNER_ENABLE_COMPLETE, &val);
1356 dev_dbg(state->i2cdev, "tuner %u ready = %u\n",
1357 tuner, (val >> tuner) & 1);
1358
1359 return 0;
1360}
1361
1362
1363static int config_ts(struct mxl *state, enum MXL_HYDRA_DEMOD_ID_E demod_id,
1364 struct MXL_HYDRA_MPEGOUT_PARAM_T *mpeg_out_param_ptr)
1365{
1366 int status = 0;
1367 u32 nco_count_min = 0;
1368 u32 clk_type = 0;
1369
1370 struct MXL_REG_FIELD_T xpt_sync_polarity[MXL_HYDRA_DEMOD_MAX] = {
1371 {0x90700010, 8, 1}, {0x90700010, 9, 1},
1372 {0x90700010, 10, 1}, {0x90700010, 11, 1},
1373 {0x90700010, 12, 1}, {0x90700010, 13, 1},
1374 {0x90700010, 14, 1}, {0x90700010, 15, 1} };
1375 struct MXL_REG_FIELD_T xpt_clock_polarity[MXL_HYDRA_DEMOD_MAX] = {
1376 {0x90700010, 16, 1}, {0x90700010, 17, 1},
1377 {0x90700010, 18, 1}, {0x90700010, 19, 1},
1378 {0x90700010, 20, 1}, {0x90700010, 21, 1},
1379 {0x90700010, 22, 1}, {0x90700010, 23, 1} };
1380 struct MXL_REG_FIELD_T xpt_valid_polarity[MXL_HYDRA_DEMOD_MAX] = {
1381 {0x90700014, 0, 1}, {0x90700014, 1, 1},
1382 {0x90700014, 2, 1}, {0x90700014, 3, 1},
1383 {0x90700014, 4, 1}, {0x90700014, 5, 1},
1384 {0x90700014, 6, 1}, {0x90700014, 7, 1} };
1385 struct MXL_REG_FIELD_T xpt_ts_clock_phase[MXL_HYDRA_DEMOD_MAX] = {
1386 {0x90700018, 0, 3}, {0x90700018, 4, 3},
1387 {0x90700018, 8, 3}, {0x90700018, 12, 3},
1388 {0x90700018, 16, 3}, {0x90700018, 20, 3},
1389 {0x90700018, 24, 3}, {0x90700018, 28, 3} };
1390 struct MXL_REG_FIELD_T xpt_lsb_first[MXL_HYDRA_DEMOD_MAX] = {
1391 {0x9070000C, 16, 1}, {0x9070000C, 17, 1},
1392 {0x9070000C, 18, 1}, {0x9070000C, 19, 1},
1393 {0x9070000C, 20, 1}, {0x9070000C, 21, 1},
1394 {0x9070000C, 22, 1}, {0x9070000C, 23, 1} };
1395 struct MXL_REG_FIELD_T xpt_sync_byte[MXL_HYDRA_DEMOD_MAX] = {
1396 {0x90700010, 0, 1}, {0x90700010, 1, 1},
1397 {0x90700010, 2, 1}, {0x90700010, 3, 1},
1398 {0x90700010, 4, 1}, {0x90700010, 5, 1},
1399 {0x90700010, 6, 1}, {0x90700010, 7, 1} };
1400 struct MXL_REG_FIELD_T xpt_enable_output[MXL_HYDRA_DEMOD_MAX] = {
1401 {0x9070000C, 0, 1}, {0x9070000C, 1, 1},
1402 {0x9070000C, 2, 1}, {0x9070000C, 3, 1},
1403 {0x9070000C, 4, 1}, {0x9070000C, 5, 1},
1404 {0x9070000C, 6, 1}, {0x9070000C, 7, 1} };
1405 struct MXL_REG_FIELD_T xpt_err_replace_sync[MXL_HYDRA_DEMOD_MAX] = {
1406 {0x9070000C, 24, 1}, {0x9070000C, 25, 1},
1407 {0x9070000C, 26, 1}, {0x9070000C, 27, 1},
1408 {0x9070000C, 28, 1}, {0x9070000C, 29, 1},
1409 {0x9070000C, 30, 1}, {0x9070000C, 31, 1} };
1410 struct MXL_REG_FIELD_T xpt_err_replace_valid[MXL_HYDRA_DEMOD_MAX] = {
1411 {0x90700014, 8, 1}, {0x90700014, 9, 1},
1412 {0x90700014, 10, 1}, {0x90700014, 11, 1},
1413 {0x90700014, 12, 1}, {0x90700014, 13, 1},
1414 {0x90700014, 14, 1}, {0x90700014, 15, 1} };
1415 struct MXL_REG_FIELD_T xpt_continuous_clock[MXL_HYDRA_DEMOD_MAX] = {
1416 {0x907001D4, 0, 1}, {0x907001D4, 1, 1},
1417 {0x907001D4, 2, 1}, {0x907001D4, 3, 1},
1418 {0x907001D4, 4, 1}, {0x907001D4, 5, 1},
1419 {0x907001D4, 6, 1}, {0x907001D4, 7, 1} };
1420 struct MXL_REG_FIELD_T xpt_nco_clock_rate[MXL_HYDRA_DEMOD_MAX] = {
1421 {0x90700044, 16, 80}, {0x90700044, 16, 81},
1422 {0x90700044, 16, 82}, {0x90700044, 16, 83},
1423 {0x90700044, 16, 84}, {0x90700044, 16, 85},
1424 {0x90700044, 16, 86}, {0x90700044, 16, 87} };
1425
1426 demod_id = state->base->ts_map[demod_id];
1427
1428 if (mpeg_out_param_ptr->enable == MXL_ENABLE) {
1429 if (mpeg_out_param_ptr->mpeg_mode ==
1430 MXL_HYDRA_MPEG_MODE_PARALLEL) {
1431 } else {
1432 cfg_ts_pad_mux(state, MXL_TRUE);
1433 update_by_mnemonic(state,
1434 0x90700010, 27, 1, MXL_FALSE);
1435 }
1436 }
1437
1438 nco_count_min =
1439 (u32)(MXL_HYDRA_NCO_CLK / mpeg_out_param_ptr->max_mpeg_clk_rate);
1440
1441 if (state->base->chipversion >= 2) {
1442 status |= update_by_mnemonic(state,
1443 xpt_nco_clock_rate[demod_id].reg_addr, /* Reg Addr */
1444 xpt_nco_clock_rate[demod_id].lsb_pos, /* LSB pos */
1445 xpt_nco_clock_rate[demod_id].num_of_bits, /* Num of bits */
1446 nco_count_min); /* Data */
1447 } else
1448 update_by_mnemonic(state, 0x90700044, 16, 8, nco_count_min);
1449
1450 if (mpeg_out_param_ptr->mpeg_clk_type == MXL_HYDRA_MPEG_CLK_CONTINUOUS)
1451 clk_type = 1;
1452
1453 if (mpeg_out_param_ptr->mpeg_mode < MXL_HYDRA_MPEG_MODE_PARALLEL) {
1454 status |= update_by_mnemonic(state,
1455 xpt_continuous_clock[demod_id].reg_addr,
1456 xpt_continuous_clock[demod_id].lsb_pos,
1457 xpt_continuous_clock[demod_id].num_of_bits,
1458 clk_type);
1459 } else
1460 update_by_mnemonic(state, 0x907001D4, 8, 1, clk_type);
1461
1462 status |= update_by_mnemonic(state,
1463 xpt_sync_polarity[demod_id].reg_addr,
1464 xpt_sync_polarity[demod_id].lsb_pos,
1465 xpt_sync_polarity[demod_id].num_of_bits,
1466 mpeg_out_param_ptr->mpeg_sync_pol);
1467
1468 status |= update_by_mnemonic(state,
1469 xpt_valid_polarity[demod_id].reg_addr,
1470 xpt_valid_polarity[demod_id].lsb_pos,
1471 xpt_valid_polarity[demod_id].num_of_bits,
1472 mpeg_out_param_ptr->mpeg_valid_pol);
1473
1474 status |= update_by_mnemonic(state,
1475 xpt_clock_polarity[demod_id].reg_addr,
1476 xpt_clock_polarity[demod_id].lsb_pos,
1477 xpt_clock_polarity[demod_id].num_of_bits,
1478 mpeg_out_param_ptr->mpeg_clk_pol);
1479
1480 status |= update_by_mnemonic(state,
1481 xpt_sync_byte[demod_id].reg_addr,
1482 xpt_sync_byte[demod_id].lsb_pos,
1483 xpt_sync_byte[demod_id].num_of_bits,
1484 mpeg_out_param_ptr->mpeg_sync_pulse_width);
1485
1486 status |= update_by_mnemonic(state,
1487 xpt_ts_clock_phase[demod_id].reg_addr,
1488 xpt_ts_clock_phase[demod_id].lsb_pos,
1489 xpt_ts_clock_phase[demod_id].num_of_bits,
1490 mpeg_out_param_ptr->mpeg_clk_phase);
1491
1492 status |= update_by_mnemonic(state,
1493 xpt_lsb_first[demod_id].reg_addr,
1494 xpt_lsb_first[demod_id].lsb_pos,
1495 xpt_lsb_first[demod_id].num_of_bits,
1496 mpeg_out_param_ptr->lsb_or_msb_first);
1497
1498 switch (mpeg_out_param_ptr->mpeg_error_indication) {
1499 case MXL_HYDRA_MPEG_ERR_REPLACE_SYNC:
1500 status |= update_by_mnemonic(state,
1501 xpt_err_replace_sync[demod_id].reg_addr,
1502 xpt_err_replace_sync[demod_id].lsb_pos,
1503 xpt_err_replace_sync[demod_id].num_of_bits,
1504 MXL_TRUE);
1505 status |= update_by_mnemonic(state,
1506 xpt_err_replace_valid[demod_id].reg_addr,
1507 xpt_err_replace_valid[demod_id].lsb_pos,
1508 xpt_err_replace_valid[demod_id].num_of_bits,
1509 MXL_FALSE);
1510 break;
1511
1512 case MXL_HYDRA_MPEG_ERR_REPLACE_VALID:
1513 status |= update_by_mnemonic(state,
1514 xpt_err_replace_sync[demod_id].reg_addr,
1515 xpt_err_replace_sync[demod_id].lsb_pos,
1516 xpt_err_replace_sync[demod_id].num_of_bits,
1517 MXL_FALSE);
1518
1519 status |= update_by_mnemonic(state,
1520 xpt_err_replace_valid[demod_id].reg_addr,
1521 xpt_err_replace_valid[demod_id].lsb_pos,
1522 xpt_err_replace_valid[demod_id].num_of_bits,
1523 MXL_TRUE);
1524 break;
1525
1526 case MXL_HYDRA_MPEG_ERR_INDICATION_DISABLED:
1527 default:
1528 status |= update_by_mnemonic(state,
1529 xpt_err_replace_sync[demod_id].reg_addr,
1530 xpt_err_replace_sync[demod_id].lsb_pos,
1531 xpt_err_replace_sync[demod_id].num_of_bits,
1532 MXL_FALSE);
1533
1534 status |= update_by_mnemonic(state,
1535 xpt_err_replace_valid[demod_id].reg_addr,
1536 xpt_err_replace_valid[demod_id].lsb_pos,
1537 xpt_err_replace_valid[demod_id].num_of_bits,
1538 MXL_FALSE);
1539
1540 break;
1541
1542 }
1543
1544 if (mpeg_out_param_ptr->mpeg_mode != MXL_HYDRA_MPEG_MODE_PARALLEL) {
1545 status |= update_by_mnemonic(state,
1546 xpt_enable_output[demod_id].reg_addr,
1547 xpt_enable_output[demod_id].lsb_pos,
1548 xpt_enable_output[demod_id].num_of_bits,
1549 mpeg_out_param_ptr->enable);
1550 }
1551 return status;
1552}
1553
1554static int config_mux(struct mxl *state)
1555{
1556 update_by_mnemonic(state, 0x9070000C, 0, 1, 0);
1557 update_by_mnemonic(state, 0x9070000C, 1, 1, 0);
1558 update_by_mnemonic(state, 0x9070000C, 2, 1, 0);
1559 update_by_mnemonic(state, 0x9070000C, 3, 1, 0);
1560 update_by_mnemonic(state, 0x9070000C, 4, 1, 0);
1561 update_by_mnemonic(state, 0x9070000C, 5, 1, 0);
1562 update_by_mnemonic(state, 0x9070000C, 6, 1, 0);
1563 update_by_mnemonic(state, 0x9070000C, 7, 1, 0);
1564 update_by_mnemonic(state, 0x90700008, 0, 2, 1);
1565 update_by_mnemonic(state, 0x90700008, 2, 2, 1);
1566 return 0;
1567}
1568
1569static int load_fw(struct mxl *state, struct mxl5xx_cfg *cfg)
1570{
1571 int stat = 0;
1572 u8 *buf;
1573
1574 if (cfg->fw)
1575 return firmware_download(state, cfg->fw, cfg->fw_len);
1576
1577 if (!cfg->fw_read)
1578 return -1;
1579
1580 buf = vmalloc(0x40000);
1581 if (!buf)
1582 return -ENOMEM;
1583
1584 cfg->fw_read(cfg->fw_priv, buf, 0x40000);
1585 stat = firmware_download(state, buf, 0x40000);
1586 vfree(buf);
1587
1588 return stat;
1589}
1590
1591static int validate_sku(struct mxl *state)
1592{
1593 u32 pad_mux_bond = 0, prcm_chip_id = 0, prcm_so_cid = 0;
1594 int status;
1595 u32 type = state->base->type;
1596
1597 status = read_by_mnemonic(state, 0x90000190, 0, 3, &pad_mux_bond);
1598 status |= read_by_mnemonic(state, 0x80030000, 0, 12, &prcm_chip_id);
1599 status |= read_by_mnemonic(state, 0x80030004, 24, 8, &prcm_so_cid);
1600 if (status)
1601 return -1;
1602
1603 dev_info(state->i2cdev, "padMuxBond=%08x, prcmChipId=%08x, prcmSoCId=%08x\n",
1604 pad_mux_bond, prcm_chip_id, prcm_so_cid);
1605
1606 if (prcm_chip_id != 0x560) {
1607 switch (pad_mux_bond) {
1608 case MXL_HYDRA_SKU_ID_581:
1609 if (type == MXL_HYDRA_DEVICE_581)
1610 return 0;
1611 if (type == MXL_HYDRA_DEVICE_581S) {
1612 state->base->type = MXL_HYDRA_DEVICE_581;
1613 return 0;
1614 }
1615 break;
1616 case MXL_HYDRA_SKU_ID_584:
1617 if (type == MXL_HYDRA_DEVICE_584)
1618 return 0;
1619 break;
1620 case MXL_HYDRA_SKU_ID_544:
1621 if (type == MXL_HYDRA_DEVICE_544)
1622 return 0;
1623 if (type == MXL_HYDRA_DEVICE_542)
1624 return 0;
1625 break;
1626 case MXL_HYDRA_SKU_ID_582:
1627 if (type == MXL_HYDRA_DEVICE_582)
1628 return 0;
1629 break;
1630 default:
1631 return -1;
1632 }
1633 } else {
1634
1635 }
1636 return -1;
1637}
1638
1639static int get_fwinfo(struct mxl *state)
1640{
1641 int status;
1642 u32 val = 0;
1643
1644 status = read_by_mnemonic(state, 0x90000190, 0, 3, &val);
1645 if (status)
1646 return status;
1647 dev_info(state->i2cdev, "chipID=%08x\n", val);
1648
1649 status = read_by_mnemonic(state, 0x80030004, 8, 8, &val);
1650 if (status)
1651 return status;
1652 dev_info(state->i2cdev, "chipVer=%08x\n", val);
1653
1654 status = read_register(state, HYDRA_FIRMWARE_VERSION, &val);
1655 if (status)
1656 return status;
1657 dev_info(state->i2cdev, "FWVer=%08x\n", val);
1658
1659 state->base->fwversion = val;
1660 return status;
1661}
1662
1663
1664static u8 ts_map1_to_1[MXL_HYDRA_DEMOD_MAX] = {
1665 MXL_HYDRA_DEMOD_ID_0,
1666 MXL_HYDRA_DEMOD_ID_1,
1667 MXL_HYDRA_DEMOD_ID_2,
1668 MXL_HYDRA_DEMOD_ID_3,
1669 MXL_HYDRA_DEMOD_ID_4,
1670 MXL_HYDRA_DEMOD_ID_5,
1671 MXL_HYDRA_DEMOD_ID_6,
1672 MXL_HYDRA_DEMOD_ID_7,
1673};
1674
1675static u8 ts_map54x[MXL_HYDRA_DEMOD_MAX] = {
1676 MXL_HYDRA_DEMOD_ID_2,
1677 MXL_HYDRA_DEMOD_ID_3,
1678 MXL_HYDRA_DEMOD_ID_4,
1679 MXL_HYDRA_DEMOD_ID_5,
1680 MXL_HYDRA_DEMOD_MAX,
1681 MXL_HYDRA_DEMOD_MAX,
1682 MXL_HYDRA_DEMOD_MAX,
1683 MXL_HYDRA_DEMOD_MAX,
1684};
1685
1686static int probe(struct mxl *state, struct mxl5xx_cfg *cfg)
1687{
1688 u32 chipver;
1689 int fw, status, j;
1690 struct MXL_HYDRA_MPEGOUT_PARAM_T mpeg_interface_cfg;
1691
1692 state->base->ts_map = ts_map1_to_1;
1693
1694 switch (state->base->type) {
1695 case MXL_HYDRA_DEVICE_581:
1696 case MXL_HYDRA_DEVICE_581S:
1697 state->base->can_clkout = 1;
1698 state->base->demod_num = 8;
1699 state->base->tuner_num = 1;
1700 state->base->sku_type = MXL_HYDRA_SKU_TYPE_581;
1701 break;
1702 case MXL_HYDRA_DEVICE_582:
1703 state->base->can_clkout = 1;
1704 state->base->demod_num = 8;
1705 state->base->tuner_num = 3;
1706 state->base->sku_type = MXL_HYDRA_SKU_TYPE_582;
1707 break;
1708 case MXL_HYDRA_DEVICE_585:
1709 state->base->can_clkout = 0;
1710 state->base->demod_num = 8;
1711 state->base->tuner_num = 4;
1712 state->base->sku_type = MXL_HYDRA_SKU_TYPE_585;
1713 break;
1714 case MXL_HYDRA_DEVICE_544:
1715 state->base->can_clkout = 0;
1716 state->base->demod_num = 4;
1717 state->base->tuner_num = 4;
1718 state->base->sku_type = MXL_HYDRA_SKU_TYPE_544;
1719 state->base->ts_map = ts_map54x;
1720 break;
1721 case MXL_HYDRA_DEVICE_541:
1722 case MXL_HYDRA_DEVICE_541S:
1723 state->base->can_clkout = 0;
1724 state->base->demod_num = 4;
1725 state->base->tuner_num = 1;
1726 state->base->sku_type = MXL_HYDRA_SKU_TYPE_541;
1727 state->base->ts_map = ts_map54x;
1728 break;
1729 case MXL_HYDRA_DEVICE_561:
1730 case MXL_HYDRA_DEVICE_561S:
1731 state->base->can_clkout = 0;
1732 state->base->demod_num = 6;
1733 state->base->tuner_num = 1;
1734 state->base->sku_type = MXL_HYDRA_SKU_TYPE_561;
1735 break;
1736 case MXL_HYDRA_DEVICE_568:
1737 state->base->can_clkout = 0;
1738 state->base->demod_num = 8;
1739 state->base->tuner_num = 1;
1740 state->base->chan_bond = 1;
1741 state->base->sku_type = MXL_HYDRA_SKU_TYPE_568;
1742 break;
1743 case MXL_HYDRA_DEVICE_542:
1744 state->base->can_clkout = 1;
1745 state->base->demod_num = 4;
1746 state->base->tuner_num = 3;
1747 state->base->sku_type = MXL_HYDRA_SKU_TYPE_542;
1748 state->base->ts_map = ts_map54x;
1749 break;
1750 case MXL_HYDRA_DEVICE_TEST:
1751 case MXL_HYDRA_DEVICE_584:
1752 default:
1753 state->base->can_clkout = 0;
1754 state->base->demod_num = 8;
1755 state->base->tuner_num = 4;
1756 state->base->sku_type = MXL_HYDRA_SKU_TYPE_584;
1757 break;
1758 }
1759
1760 status = validate_sku(state);
1761 if (status)
1762 return status;
1763
1764 update_by_mnemonic(state, 0x80030014, 9, 1, 1);
1765 update_by_mnemonic(state, 0x8003003C, 12, 1, 1);
1766 status = read_by_mnemonic(state, 0x80030000, 12, 4, &chipver);
1767 if (status)
1768 state->base->chipversion = 0;
1769 else
1770 state->base->chipversion = (chipver == 2) ? 2 : 1;
1771 dev_info(state->i2cdev, "Hydra chip version %u\n",
1772 state->base->chipversion);
1773
1774 cfg_dev_xtal(state, cfg->clk, cfg->cap, 0);
1775
1776 fw = firmware_is_alive(state);
1777 if (!fw) {
1778 status = load_fw(state, cfg);
1779 if (status)
1780 return status;
1781 }
1782 get_fwinfo(state);
1783
1784 config_mux(state);
1785 mpeg_interface_cfg.enable = MXL_ENABLE;
1786 mpeg_interface_cfg.lsb_or_msb_first = MXL_HYDRA_MPEG_SERIAL_MSB_1ST;
1787 /* supports only (0-104&139)MHz */
1788 if (cfg->ts_clk)
1789 mpeg_interface_cfg.max_mpeg_clk_rate = cfg->ts_clk;
1790 else
1791 mpeg_interface_cfg.max_mpeg_clk_rate = 69; /* 139; */
1792 mpeg_interface_cfg.mpeg_clk_phase = MXL_HYDRA_MPEG_CLK_PHASE_SHIFT_0_DEG;
1793 mpeg_interface_cfg.mpeg_clk_pol = MXL_HYDRA_MPEG_CLK_IN_PHASE;
1794 /* MXL_HYDRA_MPEG_CLK_GAPPED; */
1795 mpeg_interface_cfg.mpeg_clk_type = MXL_HYDRA_MPEG_CLK_CONTINUOUS;
1796 mpeg_interface_cfg.mpeg_error_indication =
1797 MXL_HYDRA_MPEG_ERR_INDICATION_DISABLED;
1798 mpeg_interface_cfg.mpeg_mode = MXL_HYDRA_MPEG_MODE_SERIAL_3_WIRE;
1799 mpeg_interface_cfg.mpeg_sync_pol = MXL_HYDRA_MPEG_ACTIVE_HIGH;
1800 mpeg_interface_cfg.mpeg_sync_pulse_width = MXL_HYDRA_MPEG_SYNC_WIDTH_BIT;
1801 mpeg_interface_cfg.mpeg_valid_pol = MXL_HYDRA_MPEG_ACTIVE_HIGH;
1802
1803 for (j = 0; j < state->base->demod_num; j++) {
1804 status = config_ts(state, (enum MXL_HYDRA_DEMOD_ID_E) j,
1805 &mpeg_interface_cfg);
1806 if (status)
1807 return status;
1808 }
1809 set_drive_strength(state, 1);
1810 return 0;
1811}
1812
1813struct dvb_frontend *mxl5xx_attach(struct i2c_adapter *i2c,
1814 struct mxl5xx_cfg *cfg, u32 demod, u32 tuner,
1815 int (**fn_set_input)(struct dvb_frontend *, int))
1816{
1817 struct mxl *state;
1818 struct mxl_base *base;
1819
1820 state = kzalloc(sizeof(struct mxl), GFP_KERNEL);
1821 if (!state)
1822 return NULL;
1823
1824 state->demod = demod;
1825 state->tuner = tuner;
1826 state->tuner_in_use = 0xffffffff;
1827 state->i2cdev = &i2c->dev;
1828
1829 base = match_base(i2c, cfg->adr);
1830 if (base) {
1831 base->count++;
1832 if (base->count > base->demod_num)
1833 goto fail;
1834 state->base = base;
1835 } else {
1836 base = kzalloc(sizeof(struct mxl_base), GFP_KERNEL);
1837 if (!base)
1838 goto fail;
1839 base->i2c = i2c;
1840 base->adr = cfg->adr;
1841 base->type = cfg->type;
1842 base->count = 1;
1843 mutex_init(&base->i2c_lock);
1844 mutex_init(&base->status_lock);
1845 mutex_init(&base->tune_lock);
1846 INIT_LIST_HEAD(&base->mxls);
1847
1848 state->base = base;
1849 if (probe(state, cfg) < 0) {
1850 kfree(base);
1851 goto fail;
1852 }
1853 list_add(&base->mxllist, &mxllist);
1854 }
1855 state->fe.ops = mxl_ops;
1856 state->xbar[0] = 4;
1857 state->xbar[1] = demod;
1858 state->xbar[2] = 8;
1859 state->fe.demodulator_priv = state;
1860 *fn_set_input = set_input;
1861
1862 list_add(&state->mxl, &base->mxls);
1863 return &state->fe;
1864
1865fail:
1866 kfree(state);
1867 return NULL;
1868}
1869EXPORT_SYMBOL_GPL(mxl5xx_attach);
1870
1871MODULE_DESCRIPTION("MaxLinear MxL5xx DVB-S/S2 tuner-demodulator driver");
1872MODULE_AUTHOR("Ralph and Marcus Metzler, Metzler Brothers Systementwicklung GbR");
1873MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/mxl5xx.h b/drivers/media/dvb-frontends/mxl5xx.h
new file mode 100644
index 000000000000..532e08111537
--- /dev/null
+++ b/drivers/media/dvb-frontends/mxl5xx.h
@@ -0,0 +1,41 @@
1#ifndef _MXL5XX_H_
2#define _MXL5XX_H_
3
4#include <linux/types.h>
5#include <linux/i2c.h>
6
7#include "dvb_frontend.h"
8
9struct mxl5xx_cfg {
10 u8 adr;
11 u8 type;
12 u32 cap;
13 u32 clk;
14 u32 ts_clk;
15
16 u8 *fw;
17 u32 fw_len;
18
19 int (*fw_read)(void *priv, u8 *buf, u32 len);
20 void *fw_priv;
21};
22
23#if IS_REACHABLE(CONFIG_DVB_MXL5XX)
24
25extern struct dvb_frontend *mxl5xx_attach(struct i2c_adapter *i2c,
26 struct mxl5xx_cfg *cfg, u32 demod, u32 tuner,
27 int (**fn_set_input)(struct dvb_frontend *, int));
28
29#else
30
31static inline struct dvb_frontend *mxl5xx_attach(struct i2c_adapter *i2c,
32 struct mxl5xx_cfg *cfg, u32 demod, u32 tuner,
33 int (**fn_set_input)(struct dvb_frontend *, int))
34{
35 pr_warn("%s: driver disabled by Kconfig\n", __func__);
36 return NULL;
37}
38
39#endif /* CONFIG_DVB_MXL5XX */
40
41#endif /* _MXL5XX_H_ */
diff --git a/drivers/media/dvb-frontends/mxl5xx_defs.h b/drivers/media/dvb-frontends/mxl5xx_defs.h
new file mode 100644
index 000000000000..fd9e61e0188f
--- /dev/null
+++ b/drivers/media/dvb-frontends/mxl5xx_defs.h
@@ -0,0 +1,731 @@
1/*
2 * Defines for the Maxlinear MX58x family of tuners/demods
3 *
4 * Copyright (C) 2014 Digital Devices GmbH
5 *
6 * based on code:
7 * Copyright (c) 2011-2013 MaxLinear, Inc. All rights reserved
8 * which was released under GPL V2
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
15enum MXL_BOOL_E {
16 MXL_DISABLE = 0,
17 MXL_ENABLE = 1,
18
19 MXL_FALSE = 0,
20 MXL_TRUE = 1,
21
22 MXL_INVALID = 0,
23 MXL_VALID = 1,
24
25 MXL_NO = 0,
26 MXL_YES = 1,
27
28 MXL_OFF = 0,
29 MXL_ON = 1
30};
31
32/* Firmware-Host Command IDs */
33enum MXL_HYDRA_HOST_CMD_ID_E {
34 /* --Device command IDs-- */
35 MXL_HYDRA_DEV_NO_OP_CMD = 0, /* No OP */
36
37 MXL_HYDRA_DEV_SET_POWER_MODE_CMD = 1,
38 MXL_HYDRA_DEV_SET_OVERWRITE_DEF_CMD = 2,
39
40 /* Host-used CMD, not used by firmware */
41 MXL_HYDRA_DEV_FIRMWARE_DOWNLOAD_CMD = 3,
42
43 /* Additional CONTROL types from DTV */
44 MXL_HYDRA_DEV_SET_BROADCAST_PID_STB_ID_CMD = 4,
45 MXL_HYDRA_DEV_GET_PMM_SLEEP_CMD = 5,
46
47 /* --Tuner command IDs-- */
48 MXL_HYDRA_TUNER_TUNE_CMD = 6,
49 MXL_HYDRA_TUNER_GET_STATUS_CMD = 7,
50
51 /* --Demod command IDs-- */
52 MXL_HYDRA_DEMOD_SET_PARAM_CMD = 8,
53 MXL_HYDRA_DEMOD_GET_STATUS_CMD = 9,
54
55 MXL_HYDRA_DEMOD_RESET_FEC_COUNTER_CMD = 10,
56
57 MXL_HYDRA_DEMOD_SET_PKT_NUM_CMD = 11,
58
59 MXL_HYDRA_DEMOD_SET_IQ_SOURCE_CMD = 12,
60 MXL_HYDRA_DEMOD_GET_IQ_DATA_CMD = 13,
61
62 MXL_HYDRA_DEMOD_GET_M68HC05_VER_CMD = 14,
63
64 MXL_HYDRA_DEMOD_SET_ERROR_COUNTER_MODE_CMD = 15,
65
66 /* --- ABORT channel tune */
67 MXL_HYDRA_ABORT_TUNE_CMD = 16, /* Abort current tune command. */
68
69 /* --SWM/FSK command IDs-- */
70 MXL_HYDRA_FSK_RESET_CMD = 17,
71 MXL_HYDRA_FSK_MSG_CMD = 18,
72 MXL_HYDRA_FSK_SET_OP_MODE_CMD = 19,
73
74 /* --DiSeqC command IDs-- */
75 MXL_HYDRA_DISEQC_MSG_CMD = 20,
76 MXL_HYDRA_DISEQC_COPY_MSG_TO_MAILBOX = 21,
77 MXL_HYDRA_DISEQC_CFG_MSG_CMD = 22,
78
79 /* --- FFT Debug Command IDs-- */
80 MXL_HYDRA_REQ_FFT_SPECTRUM_CMD = 23,
81
82 /* -- Demod scramblle code */
83 MXL_HYDRA_DEMOD_SCRAMBLE_CODE_CMD = 24,
84
85 /* ---For host to know how many commands in total */
86 MXL_HYDRA_LAST_HOST_CMD = 25,
87
88 MXL_HYDRA_DEMOD_INTR_TYPE_CMD = 47,
89 MXL_HYDRA_DEV_INTR_CLEAR_CMD = 48,
90 MXL_HYDRA_TUNER_SPECTRUM_REQ_CMD = 53,
91 MXL_HYDRA_TUNER_ACTIVATE_CMD = 55,
92 MXL_HYDRA_DEV_CFG_POWER_MODE_CMD = 56,
93 MXL_HYDRA_DEV_XTAL_CAP_CMD = 57,
94 MXL_HYDRA_DEV_CFG_SKU_CMD = 58,
95 MXL_HYDRA_TUNER_SPECTRUM_MIN_GAIN_CMD = 59,
96 MXL_HYDRA_DISEQC_CONT_TONE_CFG = 60,
97 MXL_HYDRA_DEV_RF_WAKE_UP_CMD = 61,
98 MXL_HYDRA_DEMOD_CFG_EQ_CTRL_PARAM_CMD = 62,
99 MXL_HYDRA_DEMOD_FREQ_OFFSET_SEARCH_RANGE_CMD = 63,
100 MXL_HYDRA_DEV_REQ_PWR_FROM_ADCRSSI_CMD = 64,
101
102 MXL_XCPU_PID_FLT_CFG_CMD = 65,
103 MXL_XCPU_SHMEM_TEST_CMD = 66,
104 MXL_XCPU_ABORT_TUNE_CMD = 67,
105 MXL_XCPU_CHAN_TUNE_CMD = 68,
106 MXL_XCPU_FLT_BOND_HDRS_CMD = 69,
107
108 MXL_HYDRA_DEV_BROADCAST_WAKE_UP_CMD = 70,
109 MXL_HYDRA_FSK_CFG_FSK_FREQ_CMD = 71,
110 MXL_HYDRA_FSK_POWER_DOWN_CMD = 72,
111 MXL_XCPU_CLEAR_CB_STATS_CMD = 73,
112 MXL_XCPU_CHAN_BOND_RESTART_CMD = 74
113};
114
115#define MXL_ENABLE_BIG_ENDIAN (0)
116
117#define MXL_HYDRA_OEM_MAX_BLOCK_WRITE_LENGTH 248
118
119#define MXL_HYDRA_OEM_MAX_CMD_BUFF_LEN (248)
120
121#define MXL_HYDRA_CAP_MIN 10
122#define MXL_HYDRA_CAP_MAX 33
123
124#define MXL_HYDRA_PLID_REG_READ 0xFB /* Read register PLID */
125#define MXL_HYDRA_PLID_REG_WRITE 0xFC /* Write register PLID */
126
127#define MXL_HYDRA_PLID_CMD_READ 0xFD /* Command Read PLID */
128#define MXL_HYDRA_PLID_CMD_WRITE 0xFE /* Command Write PLID */
129
130#define MXL_HYDRA_REG_SIZE_IN_BYTES 4 /* Hydra register size in bytes */
131#define MXL_HYDRA_I2C_HDR_SIZE (2 * sizeof(u8)) /* PLID + LEN(0xFF) */
132#define MXL_HYDRA_CMD_HEADER_SIZE (MXL_HYDRA_REG_SIZE_IN_BYTES + MXL_HYDRA_I2C_HDR_SIZE)
133
134#define MXL_HYDRA_SKU_ID_581 0
135#define MXL_HYDRA_SKU_ID_584 1
136#define MXL_HYDRA_SKU_ID_585 2
137#define MXL_HYDRA_SKU_ID_544 3
138#define MXL_HYDRA_SKU_ID_561 4
139#define MXL_HYDRA_SKU_ID_582 5
140#define MXL_HYDRA_SKU_ID_568 6
141
142/* macro for register write data buffer size
143 * (PLID + LEN (0xFF) + RegAddr + RegData)
144 */
145#define MXL_HYDRA_REG_WRITE_LEN (MXL_HYDRA_I2C_HDR_SIZE + (2 * MXL_HYDRA_REG_SIZE_IN_BYTES))
146
147/* macro to extract a single byte from 4-byte(32-bit) data */
148#define GET_BYTE(x, n) (((x) >> (8*(n))) & 0xFF)
149
150#define MAX_CMD_DATA 512
151
152#define MXL_GET_REG_MASK_32(lsb_loc, num_of_bits) ((0xFFFFFFFF >> (32 - (num_of_bits))) << (lsb_loc))
153
154#define FW_DL_SIGN (0xDEADBEEF)
155
156#define MBIN_FORMAT_VERSION '1'
157#define MBIN_FILE_HEADER_ID 'M'
158#define MBIN_SEGMENT_HEADER_ID 'S'
159#define MBIN_MAX_FILE_LENGTH (1<<23)
160
161struct MBIN_FILE_HEADER_T {
162 u8 id;
163 u8 fmt_version;
164 u8 header_len;
165 u8 num_segments;
166 u8 entry_address[4];
167 u8 image_size24[3];
168 u8 image_checksum;
169 u8 reserved[4];
170};
171
172struct MBIN_FILE_T {
173 struct MBIN_FILE_HEADER_T header;
174 u8 data[1];
175};
176
177struct MBIN_SEGMENT_HEADER_T {
178 u8 id;
179 u8 len24[3];
180 u8 address[4];
181};
182
183struct MBIN_SEGMENT_T {
184 struct MBIN_SEGMENT_HEADER_T header;
185 u8 data[1];
186};
187
188enum MXL_CMD_TYPE_E { MXL_CMD_WRITE = 0, MXL_CMD_READ };
189
190#define BUILD_HYDRA_CMD(cmd_id, req_type, size, data_ptr, cmd_buff) \
191 do { \
192 cmd_buff[0] = ((req_type == MXL_CMD_WRITE) ? MXL_HYDRA_PLID_CMD_WRITE : MXL_HYDRA_PLID_CMD_READ); \
193 cmd_buff[1] = (size > 251) ? 0xff : (u8) (size + 4); \
194 cmd_buff[2] = size; \
195 cmd_buff[3] = cmd_id; \
196 cmd_buff[4] = 0x00; \
197 cmd_buff[5] = 0x00; \
198 convert_endian(MXL_ENABLE_BIG_ENDIAN, size, (u8 *)data_ptr); \
199 memcpy((void *)&cmd_buff[6], data_ptr, size); \
200 } while (0)
201
202struct MXL_REG_FIELD_T {
203 u32 reg_addr;
204 u8 lsb_pos;
205 u8 num_of_bits;
206};
207
208struct MXL_DEV_CMD_DATA_T {
209 u32 data_size;
210 u8 data[MAX_CMD_DATA];
211};
212
213enum MXL_HYDRA_SKU_TYPE_E {
214 MXL_HYDRA_SKU_TYPE_MIN = 0x00,
215 MXL_HYDRA_SKU_TYPE_581 = 0x00,
216 MXL_HYDRA_SKU_TYPE_584 = 0x01,
217 MXL_HYDRA_SKU_TYPE_585 = 0x02,
218 MXL_HYDRA_SKU_TYPE_544 = 0x03,
219 MXL_HYDRA_SKU_TYPE_561 = 0x04,
220 MXL_HYDRA_SKU_TYPE_5XX = 0x05,
221 MXL_HYDRA_SKU_TYPE_5YY = 0x06,
222 MXL_HYDRA_SKU_TYPE_511 = 0x07,
223 MXL_HYDRA_SKU_TYPE_561_DE = 0x08,
224 MXL_HYDRA_SKU_TYPE_582 = 0x09,
225 MXL_HYDRA_SKU_TYPE_541 = 0x0A,
226 MXL_HYDRA_SKU_TYPE_568 = 0x0B,
227 MXL_HYDRA_SKU_TYPE_542 = 0x0C,
228 MXL_HYDRA_SKU_TYPE_MAX = 0x0D,
229};
230
231struct MXL_HYDRA_SKU_COMMAND_T {
232 enum MXL_HYDRA_SKU_TYPE_E sku_type;
233};
234
235enum MXL_HYDRA_DEMOD_ID_E {
236 MXL_HYDRA_DEMOD_ID_0 = 0,
237 MXL_HYDRA_DEMOD_ID_1,
238 MXL_HYDRA_DEMOD_ID_2,
239 MXL_HYDRA_DEMOD_ID_3,
240 MXL_HYDRA_DEMOD_ID_4,
241 MXL_HYDRA_DEMOD_ID_5,
242 MXL_HYDRA_DEMOD_ID_6,
243 MXL_HYDRA_DEMOD_ID_7,
244 MXL_HYDRA_DEMOD_MAX
245};
246
247#define MXL_DEMOD_SCRAMBLE_SEQ_LEN 12
248
249#define MAX_STEP_SIZE_24_XTAL_102_05_KHZ 195
250#define MAX_STEP_SIZE_24_XTAL_204_10_KHZ 215
251#define MAX_STEP_SIZE_24_XTAL_306_15_KHZ 203
252#define MAX_STEP_SIZE_24_XTAL_408_20_KHZ 177
253
254#define MAX_STEP_SIZE_27_XTAL_102_05_KHZ 195
255#define MAX_STEP_SIZE_27_XTAL_204_10_KHZ 215
256#define MAX_STEP_SIZE_27_XTAL_306_15_KHZ 203
257#define MAX_STEP_SIZE_27_XTAL_408_20_KHZ 177
258
259#define MXL_HYDRA_SPECTRUM_MIN_FREQ_KHZ 300000
260#define MXL_HYDRA_SPECTRUM_MAX_FREQ_KHZ 2350000
261
262enum MXL_DEMOD_CHAN_PARAMS_OFFSET_E {
263 DMD_STANDARD_ADDR = 0,
264 DMD_SPECTRUM_INVERSION_ADDR,
265 DMD_SPECTRUM_ROLL_OFF_ADDR,
266 DMD_SYMBOL_RATE_ADDR,
267 DMD_MODULATION_SCHEME_ADDR,
268 DMD_FEC_CODE_RATE_ADDR,
269 DMD_SNR_ADDR,
270 DMD_FREQ_OFFSET_ADDR,
271 DMD_CTL_FREQ_OFFSET_ADDR,
272 DMD_STR_FREQ_OFFSET_ADDR,
273 DMD_FTL_FREQ_OFFSET_ADDR,
274 DMD_STR_NBC_SYNC_LOCK_ADDR,
275 DMD_CYCLE_SLIP_COUNT_ADDR,
276 DMD_DISPLAY_IQ_ADDR,
277 DMD_DVBS2_CRC_ERRORS_ADDR,
278 DMD_DVBS2_PER_COUNT_ADDR,
279 DMD_DVBS2_PER_WINDOW_ADDR,
280 DMD_DVBS_CORR_RS_ERRORS_ADDR,
281 DMD_DVBS_UNCORR_RS_ERRORS_ADDR,
282 DMD_DVBS_BER_COUNT_ADDR,
283 DMD_DVBS_BER_WINDOW_ADDR,
284 DMD_TUNER_ID_ADDR,
285 DMD_DVBS2_PILOT_ON_OFF_ADDR,
286 DMD_FREQ_SEARCH_RANGE_IN_KHZ_ADDR,
287
288 MXL_DEMOD_CHAN_PARAMS_BUFF_SIZE,
289};
290
291enum MXL_HYDRA_TUNER_ID_E {
292 MXL_HYDRA_TUNER_ID_0 = 0,
293 MXL_HYDRA_TUNER_ID_1,
294 MXL_HYDRA_TUNER_ID_2,
295 MXL_HYDRA_TUNER_ID_3,
296 MXL_HYDRA_TUNER_MAX
297};
298
299enum MXL_HYDRA_BCAST_STD_E {
300 MXL_HYDRA_DSS = 0,
301 MXL_HYDRA_DVBS,
302 MXL_HYDRA_DVBS2,
303};
304
305enum MXL_HYDRA_FEC_E {
306 MXL_HYDRA_FEC_AUTO = 0,
307 MXL_HYDRA_FEC_1_2,
308 MXL_HYDRA_FEC_3_5,
309 MXL_HYDRA_FEC_2_3,
310 MXL_HYDRA_FEC_3_4,
311 MXL_HYDRA_FEC_4_5,
312 MXL_HYDRA_FEC_5_6,
313 MXL_HYDRA_FEC_6_7,
314 MXL_HYDRA_FEC_7_8,
315 MXL_HYDRA_FEC_8_9,
316 MXL_HYDRA_FEC_9_10,
317};
318
319enum MXL_HYDRA_MODULATION_E {
320 MXL_HYDRA_MOD_AUTO = 0,
321 MXL_HYDRA_MOD_QPSK,
322 MXL_HYDRA_MOD_8PSK
323};
324
325enum MXL_HYDRA_SPECTRUM_E {
326 MXL_HYDRA_SPECTRUM_AUTO = 0,
327 MXL_HYDRA_SPECTRUM_INVERTED,
328 MXL_HYDRA_SPECTRUM_NON_INVERTED,
329};
330
331enum MXL_HYDRA_ROLLOFF_E {
332 MXL_HYDRA_ROLLOFF_AUTO = 0,
333 MXL_HYDRA_ROLLOFF_0_20,
334 MXL_HYDRA_ROLLOFF_0_25,
335 MXL_HYDRA_ROLLOFF_0_35
336};
337
338enum MXL_HYDRA_PILOTS_E {
339 MXL_HYDRA_PILOTS_OFF = 0,
340 MXL_HYDRA_PILOTS_ON,
341 MXL_HYDRA_PILOTS_AUTO
342};
343
344enum MXL_HYDRA_CONSTELLATION_SRC_E {
345 MXL_HYDRA_FORMATTER = 0,
346 MXL_HYDRA_LEGACY_FEC,
347 MXL_HYDRA_FREQ_RECOVERY,
348 MXL_HYDRA_NBC,
349 MXL_HYDRA_CTL,
350 MXL_HYDRA_EQ,
351};
352
353struct MXL_HYDRA_DEMOD_LOCK_T {
354 int agc_lock; /* AGC lock info */
355 int fec_lock; /* Demod FEC block lock info */
356};
357
358struct MXL_HYDRA_DEMOD_STATUS_DVBS_T {
359 u32 rs_errors; /* RS decoder err counter */
360 u32 ber_window; /* Ber Windows */
361 u32 ber_count; /* BER count */
362 u32 ber_window_iter1; /* Ber Windows - post viterbi */
363 u32 ber_count_iter1; /* BER count - post viterbi */
364};
365
366struct MXL_HYDRA_DEMOD_STATUS_DSS_T {
367 u32 rs_errors; /* RS decoder err counter */
368 u32 ber_window; /* Ber Windows */
369 u32 ber_count; /* BER count */
370};
371
372struct MXL_HYDRA_DEMOD_STATUS_DVBS2_T {
373 u32 crc_errors; /* CRC error counter */
374 u32 packet_error_count; /* Number of packet errors */
375 u32 total_packets; /* Total packets */
376};
377
378struct MXL_HYDRA_DEMOD_STATUS_T {
379 enum MXL_HYDRA_BCAST_STD_E standard_mask; /* Standard DVB-S, DVB-S2 or DSS */
380
381 union {
382 struct MXL_HYDRA_DEMOD_STATUS_DVBS_T demod_status_dvbs; /* DVB-S demod status */
383 struct MXL_HYDRA_DEMOD_STATUS_DVBS2_T demod_status_dvbs2; /* DVB-S2 demod status */
384 struct MXL_HYDRA_DEMOD_STATUS_DSS_T demod_status_dss; /* DSS demod status */
385 } u;
386};
387
388struct MXL_HYDRA_DEMOD_SIG_OFFSET_INFO_T {
389 s32 carrier_offset_in_hz; /* CRL offset info */
390 s32 symbol_offset_in_symbol; /* SRL offset info */
391};
392
393struct MXL_HYDRA_DEMOD_SCRAMBLE_INFO_T {
394 u8 scramble_sequence[MXL_DEMOD_SCRAMBLE_SEQ_LEN]; /* scramble sequence */
395 u32 scramble_code; /* scramble gold code */
396};
397
398enum MXL_HYDRA_SPECTRUM_STEP_SIZE_E {
399 MXL_HYDRA_STEP_SIZE_24_XTAL_102_05KHZ, /* 102.05 KHz for 24 MHz XTAL */
400 MXL_HYDRA_STEP_SIZE_24_XTAL_204_10KHZ, /* 204.10 KHz for 24 MHz XTAL */
401 MXL_HYDRA_STEP_SIZE_24_XTAL_306_15KHZ, /* 306.15 KHz for 24 MHz XTAL */
402 MXL_HYDRA_STEP_SIZE_24_XTAL_408_20KHZ, /* 408.20 KHz for 24 MHz XTAL */
403
404 MXL_HYDRA_STEP_SIZE_27_XTAL_102_05KHZ, /* 102.05 KHz for 27 MHz XTAL */
405 MXL_HYDRA_STEP_SIZE_27_XTAL_204_35KHZ, /* 204.35 KHz for 27 MHz XTAL */
406 MXL_HYDRA_STEP_SIZE_27_XTAL_306_52KHZ, /* 306.52 KHz for 27 MHz XTAL */
407 MXL_HYDRA_STEP_SIZE_27_XTAL_408_69KHZ, /* 408.69 KHz for 27 MHz XTAL */
408};
409
410enum MXL_HYDRA_SPECTRUM_RESOLUTION_E {
411 MXL_HYDRA_SPECTRUM_RESOLUTION_00_1_DB, /* 0.1 dB */
412 MXL_HYDRA_SPECTRUM_RESOLUTION_01_0_DB, /* 1.0 dB */
413 MXL_HYDRA_SPECTRUM_RESOLUTION_05_0_DB, /* 5.0 dB */
414 MXL_HYDRA_SPECTRUM_RESOLUTION_10_0_DB, /* 10 dB */
415};
416
417enum MXL_HYDRA_SPECTRUM_ERROR_CODE_E {
418 MXL_SPECTRUM_NO_ERROR,
419 MXL_SPECTRUM_INVALID_PARAMETER,
420 MXL_SPECTRUM_INVALID_STEP_SIZE,
421 MXL_SPECTRUM_BW_CANNOT_BE_COVERED,
422 MXL_SPECTRUM_DEMOD_BUSY,
423 MXL_SPECTRUM_TUNER_NOT_ENABLED,
424};
425
426struct MXL_HYDRA_SPECTRUM_REQ_T {
427 u32 tuner_index; /* TUNER Ctrl: one of MXL58x_TUNER_ID_E */
428 u32 demod_index; /* DEMOD Ctrl: one of MXL58x_DEMOD_ID_E */
429 enum MXL_HYDRA_SPECTRUM_STEP_SIZE_E step_size_in_khz;
430 u32 starting_freq_ink_hz;
431 u32 total_steps;
432 enum MXL_HYDRA_SPECTRUM_RESOLUTION_E spectrum_division;
433};
434
435enum MXL_HYDRA_SEARCH_FREQ_OFFSET_TYPE_E {
436 MXL_HYDRA_SEARCH_MAX_OFFSET = 0, /* DMD searches for max freq offset (i.e. 5MHz) */
437 MXL_HYDRA_SEARCH_BW_PLUS_ROLLOFF, /* DMD searches for BW + ROLLOFF/2 */
438};
439
440struct MXL58X_CFG_FREQ_OFF_SEARCH_RANGE_T {
441 u32 demod_index;
442 enum MXL_HYDRA_SEARCH_FREQ_OFFSET_TYPE_E search_type;
443};
444
445/* there are two slices
446 * slice0 - TS0, TS1, TS2 & TS3
447 * slice1 - TS4, TS5, TS6 & TS7
448 */
449#define MXL_HYDRA_TS_SLICE_MAX 2
450
451#define MAX_FIXED_PID_NUM 32
452
453#define MXL_HYDRA_NCO_CLK 418 /* 418 MHz */
454
455#define MXL_HYDRA_MAX_TS_CLOCK 139 /* 139 MHz */
456
457#define MXL_HYDRA_TS_FIXED_PID_FILT_SIZE 32
458
459#define MXL_HYDRA_SHARED_PID_FILT_SIZE_DEFAULT 33 /* Shared PID filter size in 1-1 mux mode */
460#define MXL_HYDRA_SHARED_PID_FILT_SIZE_2_TO_1 66 /* Shared PID filter size in 2-1 mux mode */
461#define MXL_HYDRA_SHARED_PID_FILT_SIZE_4_TO_1 132 /* Shared PID filter size in 4-1 mux mode */
462
463enum MXL_HYDRA_PID_BANK_TYPE_E {
464 MXL_HYDRA_SOFTWARE_PID_BANK = 0,
465 MXL_HYDRA_HARDWARE_PID_BANK,
466};
467
468enum MXL_HYDRA_TS_MUX_MODE_E {
469 MXL_HYDRA_TS_MUX_PID_REMAP = 0,
470 MXL_HYDRA_TS_MUX_PREFIX_EXTRA_HEADER = 1,
471};
472
473enum MXL_HYDRA_TS_MUX_TYPE_E {
474 MXL_HYDRA_TS_MUX_DISABLE = 0, /* No Mux ( 1 TSIF to 1 TSIF) */
475 MXL_HYDRA_TS_MUX_2_TO_1, /* Mux 2 TSIF to 1 TSIF */
476 MXL_HYDRA_TS_MUX_4_TO_1, /* Mux 4 TSIF to 1 TSIF */
477};
478
479enum MXL_HYDRA_TS_GROUP_E {
480 MXL_HYDRA_TS_GROUP_0_3 = 0, /* TS group 0 to 3 (TS0, TS1, TS2 & TS3) */
481 MXL_HYDRA_TS_GROUP_4_7, /* TS group 0 to 3 (TS4, TS5, TS6 & TS7) */
482};
483
484enum MXL_HYDRA_TS_PID_FLT_CTRL_E {
485 MXL_HYDRA_TS_PIDS_ALLOW_ALL = 0, /* Allow all pids */
486 MXL_HYDRA_TS_PIDS_DROP_ALL, /* Drop all pids */
487 MXL_HYDRA_TS_INVALIDATE_PID_FILTER, /* Delete current PD filter in the device */
488};
489
490enum MXL_HYDRA_TS_PID_TYPE_E {
491 MXL_HYDRA_TS_PID_FIXED = 0,
492 MXL_HYDRA_TS_PID_REGULAR,
493};
494
495struct MXL_HYDRA_TS_PID_T {
496 u16 original_pid; /* pid from TS */
497 u16 remapped_pid; /* remapped pid */
498 enum MXL_BOOL_E enable; /* enable or disable pid */
499 enum MXL_BOOL_E allow_or_drop; /* allow or drop pid */
500 enum MXL_BOOL_E enable_pid_remap; /* enable or disable pid remap */
501 u8 bond_id; /* Bond ID in A0 always 0 - Only for 568 Sku */
502 u8 dest_id; /* Output port ID for the PID - Only for 568 Sku */
503};
504
505struct MXL_HYDRA_TS_MUX_PREFIX_HEADER_T {
506 enum MXL_BOOL_E enable;
507 u8 num_byte;
508 u8 header[12];
509};
510
511enum MXL_HYDRA_PID_FILTER_BANK_E {
512 MXL_HYDRA_PID_BANK_A = 0,
513 MXL_HYDRA_PID_BANK_B,
514};
515
516enum MXL_HYDRA_MPEG_DATA_FMT_E {
517 MXL_HYDRA_MPEG_SERIAL_MSB_1ST = 0,
518 MXL_HYDRA_MPEG_SERIAL_LSB_1ST,
519
520 MXL_HYDRA_MPEG_SYNC_WIDTH_BIT = 0,
521 MXL_HYDRA_MPEG_SYNC_WIDTH_BYTE
522};
523
524enum MXL_HYDRA_MPEG_MODE_E {
525 MXL_HYDRA_MPEG_MODE_SERIAL_4_WIRE = 0, /* MPEG 4 Wire serial mode */
526 MXL_HYDRA_MPEG_MODE_SERIAL_3_WIRE, /* MPEG 3 Wire serial mode */
527 MXL_HYDRA_MPEG_MODE_SERIAL_2_WIRE, /* MPEG 2 Wire serial mode */
528 MXL_HYDRA_MPEG_MODE_PARALLEL /* MPEG parallel mode - valid only for MxL581 */
529};
530
531enum MXL_HYDRA_MPEG_CLK_TYPE_E {
532 MXL_HYDRA_MPEG_CLK_CONTINUOUS = 0, /* Continuous MPEG clock */
533 MXL_HYDRA_MPEG_CLK_GAPPED, /* Gapped (gated) MPEG clock */
534};
535
536enum MXL_HYDRA_MPEG_CLK_FMT_E {
537 MXL_HYDRA_MPEG_ACTIVE_LOW = 0,
538 MXL_HYDRA_MPEG_ACTIVE_HIGH,
539
540 MXL_HYDRA_MPEG_CLK_NEGATIVE = 0,
541 MXL_HYDRA_MPEG_CLK_POSITIVE,
542
543 MXL_HYDRA_MPEG_CLK_IN_PHASE = 0,
544 MXL_HYDRA_MPEG_CLK_INVERTED,
545};
546
547enum MXL_HYDRA_MPEG_CLK_PHASE_E {
548 MXL_HYDRA_MPEG_CLK_PHASE_SHIFT_0_DEG = 0,
549 MXL_HYDRA_MPEG_CLK_PHASE_SHIFT_90_DEG,
550 MXL_HYDRA_MPEG_CLK_PHASE_SHIFT_180_DEG,
551 MXL_HYDRA_MPEG_CLK_PHASE_SHIFT_270_DEG
552};
553
554enum MXL_HYDRA_MPEG_ERR_INDICATION_E {
555 MXL_HYDRA_MPEG_ERR_REPLACE_SYNC = 0,
556 MXL_HYDRA_MPEG_ERR_REPLACE_VALID,
557 MXL_HYDRA_MPEG_ERR_INDICATION_DISABLED
558};
559
560struct MXL_HYDRA_MPEGOUT_PARAM_T {
561 int enable; /* Enable or Disable MPEG OUT */
562 enum MXL_HYDRA_MPEG_CLK_TYPE_E mpeg_clk_type; /* Continuous or gapped */
563 enum MXL_HYDRA_MPEG_CLK_FMT_E mpeg_clk_pol; /* MPEG Clk polarity */
564 u8 max_mpeg_clk_rate; /* Max MPEG Clk rate (0 - 104 MHz, 139 MHz) */
565 enum MXL_HYDRA_MPEG_CLK_PHASE_E mpeg_clk_phase; /* MPEG Clk phase */
566 enum MXL_HYDRA_MPEG_DATA_FMT_E lsb_or_msb_first; /* LSB first or MSB first in TS transmission */
567 enum MXL_HYDRA_MPEG_DATA_FMT_E mpeg_sync_pulse_width; /* MPEG SYNC pulse width (1-bit or 1-byte) */
568 enum MXL_HYDRA_MPEG_CLK_FMT_E mpeg_valid_pol; /* MPEG VALID polarity */
569 enum MXL_HYDRA_MPEG_CLK_FMT_E mpeg_sync_pol; /* MPEG SYNC polarity */
570 enum MXL_HYDRA_MPEG_MODE_E mpeg_mode; /* config 4/3/2-wire serial or parallel TS out */
571 enum MXL_HYDRA_MPEG_ERR_INDICATION_E mpeg_error_indication; /* Enable or Disable MPEG error indication */
572};
573
574enum MXL_HYDRA_EXT_TS_IN_ID_E {
575 MXL_HYDRA_EXT_TS_IN_0 = 0,
576 MXL_HYDRA_EXT_TS_IN_1,
577 MXL_HYDRA_EXT_TS_IN_2,
578 MXL_HYDRA_EXT_TS_IN_3,
579 MXL_HYDRA_EXT_TS_IN_MAX
580};
581
582enum MXL_HYDRA_TS_OUT_ID_E {
583 MXL_HYDRA_TS_OUT_0 = 0,
584 MXL_HYDRA_TS_OUT_1,
585 MXL_HYDRA_TS_OUT_2,
586 MXL_HYDRA_TS_OUT_3,
587 MXL_HYDRA_TS_OUT_4,
588 MXL_HYDRA_TS_OUT_5,
589 MXL_HYDRA_TS_OUT_6,
590 MXL_HYDRA_TS_OUT_7,
591 MXL_HYDRA_TS_OUT_MAX
592};
593
594enum MXL_HYDRA_TS_DRIVE_STRENGTH_E {
595 MXL_HYDRA_TS_DRIVE_STRENGTH_1X = 0,
596 MXL_HYDRA_TS_DRIVE_STRENGTH_2X,
597 MXL_HYDRA_TS_DRIVE_STRENGTH_3X,
598 MXL_HYDRA_TS_DRIVE_STRENGTH_4X,
599 MXL_HYDRA_TS_DRIVE_STRENGTH_5X,
600 MXL_HYDRA_TS_DRIVE_STRENGTH_6X,
601 MXL_HYDRA_TS_DRIVE_STRENGTH_7X,
602 MXL_HYDRA_TS_DRIVE_STRENGTH_8X
603};
604
605enum MXL_HYDRA_DEVICE_E {
606 MXL_HYDRA_DEVICE_581 = 0,
607 MXL_HYDRA_DEVICE_584,
608 MXL_HYDRA_DEVICE_585,
609 MXL_HYDRA_DEVICE_544,
610 MXL_HYDRA_DEVICE_561,
611 MXL_HYDRA_DEVICE_TEST,
612 MXL_HYDRA_DEVICE_582,
613 MXL_HYDRA_DEVICE_541,
614 MXL_HYDRA_DEVICE_568,
615 MXL_HYDRA_DEVICE_542,
616 MXL_HYDRA_DEVICE_541S,
617 MXL_HYDRA_DEVICE_561S,
618 MXL_HYDRA_DEVICE_581S,
619 MXL_HYDRA_DEVICE_MAX
620};
621
622/* Demod IQ data */
623struct MXL_HYDRA_DEMOD_IQ_SRC_T {
624 u32 demod_id;
625 u32 source_of_iq; /* == 0, it means I/Q comes from Formatter
626 * == 1, Legacy FEC
627 * == 2, Frequency Recovery
628 * == 3, NBC
629 * == 4, CTL
630 * == 5, EQ
631 * == 6, FPGA
632 */
633};
634
635struct MXL_HYDRA_DEMOD_ABORT_TUNE_T {
636 u32 demod_id;
637};
638
639struct MXL_HYDRA_TUNER_CMD {
640 u8 tuner_id;
641 u8 enable;
642};
643
644/* Demod Para for Channel Tune */
645struct MXL_HYDRA_DEMOD_PARAM_T {
646 u32 tuner_index;
647 u32 demod_index;
648 u32 frequency_in_hz; /* Frequency */
649 u32 standard; /* one of MXL_HYDRA_BCAST_STD_E */
650 u32 spectrum_inversion; /* Input : Spectrum inversion. */
651 u32 roll_off; /* rollOff (alpha) factor */
652 u32 symbol_rate_in_hz; /* Symbol rate */
653 u32 pilots; /* TRUE = pilots enabled */
654 u32 modulation_scheme; /* Input : Modulation Scheme is one of MXL_HYDRA_MODULATION_E */
655 u32 fec_code_rate; /* Input : Forward error correction rate. Is one of MXL_HYDRA_FEC_E */
656 u32 max_carrier_offset_in_mhz; /* Maximum carrier freq offset in MHz. Same as freqSearchRangeKHz, but in unit of MHz. */
657};
658
659struct MXL_HYDRA_DEMOD_SCRAMBLE_CODE_T {
660 u32 demod_index;
661 u8 scramble_sequence[12]; /* scramble sequence */
662 u32 scramble_code; /* scramble gold code */
663};
664
665struct MXL_INTR_CFG_T {
666 u32 intr_type;
667 u32 intr_duration_in_nano_secs;
668 u32 intr_mask;
669};
670
671struct MXL_HYDRA_POWER_MODE_CMD {
672 u8 power_mode; /* enumeration values are defined in MXL_HYDRA_PWR_MODE_E (device API.h) */
673};
674
675struct MXL_HYDRA_RF_WAKEUP_PARAM_T {
676 u32 time_interval_in_seconds; /* in seconds */
677 u32 tuner_index;
678 s32 rssi_threshold;
679};
680
681struct MXL_HYDRA_RF_WAKEUP_CFG_T {
682 u32 tuner_count;
683 struct MXL_HYDRA_RF_WAKEUP_PARAM_T params;
684};
685
686enum MXL_HYDRA_AUX_CTRL_MODE_E {
687 MXL_HYDRA_AUX_CTRL_MODE_FSK = 0, /* Select FSK controller */
688 MXL_HYDRA_AUX_CTRL_MODE_DISEQC, /* Select DiSEqC controller */
689};
690
691enum MXL_HYDRA_DISEQC_OPMODE_E {
692 MXL_HYDRA_DISEQC_ENVELOPE_MODE = 0,
693 MXL_HYDRA_DISEQC_TONE_MODE,
694};
695
696enum MXL_HYDRA_DISEQC_VER_E {
697 MXL_HYDRA_DISEQC_1_X = 0, /* Config DiSEqC 1.x mode */
698 MXL_HYDRA_DISEQC_2_X, /* Config DiSEqC 2.x mode */
699 MXL_HYDRA_DISEQC_DISABLE /* Disable DiSEqC */
700};
701
702enum MXL_HYDRA_DISEQC_CARRIER_FREQ_E {
703 MXL_HYDRA_DISEQC_CARRIER_FREQ_22KHZ = 0, /* DiSEqC signal frequency of 22 KHz */
704 MXL_HYDRA_DISEQC_CARRIER_FREQ_33KHZ, /* DiSEqC signal frequency of 33 KHz */
705 MXL_HYDRA_DISEQC_CARRIER_FREQ_44KHZ /* DiSEqC signal frequency of 44 KHz */
706};
707
708enum MXL_HYDRA_DISEQC_ID_E {
709 MXL_HYDRA_DISEQC_ID_0 = 0,
710 MXL_HYDRA_DISEQC_ID_1,
711 MXL_HYDRA_DISEQC_ID_2,
712 MXL_HYDRA_DISEQC_ID_3
713};
714
715enum MXL_HYDRA_FSK_OP_MODE_E {
716 MXL_HYDRA_FSK_CFG_TYPE_39KPBS = 0, /* 39.0kbps */
717 MXL_HYDRA_FSK_CFG_TYPE_39_017KPBS, /* 39.017kbps */
718 MXL_HYDRA_FSK_CFG_TYPE_115_2KPBS /* 115.2kbps */
719};
720
721struct MXL58X_DSQ_OP_MODE_T {
722 u32 diseqc_id; /* DSQ 0, 1, 2 or 3 */
723 u32 op_mode; /* Envelope mode (0) or internal tone mode (1) */
724 u32 version; /* 0: 1.0, 1: 1.1, 2: Disable */
725 u32 center_freq; /* 0: 22KHz, 1: 33KHz and 2: 44 KHz */
726};
727
728struct MXL_HYDRA_DISEQC_CFG_CONT_TONE_T {
729 u32 diseqc_id;
730 u32 cont_tone_flag; /* 1: Enable , 0: Disable */
731};
diff --git a/drivers/media/dvb-frontends/mxl5xx_regs.h b/drivers/media/dvb-frontends/mxl5xx_regs.h
new file mode 100644
index 000000000000..5001dafe1ba8
--- /dev/null
+++ b/drivers/media/dvb-frontends/mxl5xx_regs.h
@@ -0,0 +1,367 @@
1/*
2 * Copyright (c) 2011-2013 MaxLinear, Inc. All rights reserved
3 *
4 * License type: GPLv2
5 *
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free Software
8 * Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 *
14 * This program may alternatively be licensed under a proprietary license from
15 * MaxLinear, Inc.
16 *
17 */
18
19#ifndef __MXL58X_REGISTERS_H__
20#define __MXL58X_REGISTERS_H__
21
22#define HYDRA_INTR_STATUS_REG 0x80030008
23#define HYDRA_INTR_MASK_REG 0x8003000C
24
25#define HYDRA_CRYSTAL_SETTING 0x3FFFC5F0 /* 0 - 24 MHz & 1 - 27 MHz */
26#define HYDRA_CRYSTAL_CAP 0x3FFFEDA4 /* 0 - 24 MHz & 1 - 27 MHz */
27
28#define HYDRA_CPU_RESET_REG 0x8003003C
29#define HYDRA_CPU_RESET_DATA 0x00000400
30
31#define HYDRA_RESET_TRANSPORT_FIFO_REG 0x80030028
32#define HYDRA_RESET_TRANSPORT_FIFO_DATA 0x00000000
33
34#define HYDRA_RESET_BBAND_REG 0x80030024
35#define HYDRA_RESET_BBAND_DATA 0x00000000
36
37#define HYDRA_RESET_XBAR_REG 0x80030020
38#define HYDRA_RESET_XBAR_DATA 0x00000000
39
40#define HYDRA_MODULES_CLK_1_REG 0x80030014
41#define HYDRA_DISABLE_CLK_1 0x00000000
42
43#define HYDRA_MODULES_CLK_2_REG 0x8003001C
44#define HYDRA_DISABLE_CLK_2 0x0000000B
45
46#define HYDRA_PRCM_ROOT_CLK_REG 0x80030018
47#define HYDRA_PRCM_ROOT_CLK_DISABLE 0x00000000
48
49#define HYDRA_CPU_RESET_CHECK_REG 0x80030008
50#define HYDRA_CPU_RESET_CHECK_OFFSET 0x40000000 /* <bit 30> */
51
52#define HYDRA_SKU_ID_REG 0x90000190
53
54#define FW_DL_SIGN_ADDR 0x3FFFEAE0
55
56/* Register to check if FW is running or not */
57#define HYDRA_HEAR_BEAT 0x3FFFEDDC
58
59/* Firmware version */
60#define HYDRA_FIRMWARE_VERSION 0x3FFFEDB8
61#define HYDRA_FW_RC_VERSION 0x3FFFCFAC
62
63/* Firmware patch version */
64#define HYDRA_FIRMWARE_PATCH_VERSION 0x3FFFEDC2
65
66/* SOC operating temperature in C */
67#define HYDRA_TEMPARATURE 0x3FFFEDB4
68
69/* Demod & Tuner status registers */
70/* Demod 0 status base address */
71#define HYDRA_DEMOD_0_BASE_ADDR 0x3FFFC64C
72
73/* Tuner 0 status base address */
74#define HYDRA_TUNER_0_BASE_ADDR 0x3FFFCE4C
75
76#define POWER_FROM_ADCRSSI_READBACK 0x3FFFEB6C
77
78/* Macros to determine base address of respective demod or tuner */
79#define HYDRA_DMD_STATUS_OFFSET(demodID) ((demodID) * 0x100)
80#define HYDRA_TUNER_STATUS_OFFSET(tunerID) ((tunerID) * 0x40)
81
82/* Demod status address offset from respective demod's base address */
83#define HYDRA_DMD_AGC_DIG_LEVEL_ADDR_OFFSET 0x3FFFC64C
84#define HYDRA_DMD_LOCK_STATUS_ADDR_OFFSET 0x3FFFC650
85#define HYDRA_DMD_ACQ_STATUS_ADDR_OFFSET 0x3FFFC654
86
87#define HYDRA_DMD_STANDARD_ADDR_OFFSET 0x3FFFC658
88#define HYDRA_DMD_SPECTRUM_INVERSION_ADDR_OFFSET 0x3FFFC65C
89#define HYDRA_DMD_SPECTRUM_ROLL_OFF_ADDR_OFFSET 0x3FFFC660
90#define HYDRA_DMD_SYMBOL_RATE_ADDR_OFFSET 0x3FFFC664
91#define HYDRA_DMD_MODULATION_SCHEME_ADDR_OFFSET 0x3FFFC668
92#define HYDRA_DMD_FEC_CODE_RATE_ADDR_OFFSET 0x3FFFC66C
93
94#define HYDRA_DMD_SNR_ADDR_OFFSET 0x3FFFC670
95#define HYDRA_DMD_FREQ_OFFSET_ADDR_OFFSET 0x3FFFC674
96#define HYDRA_DMD_CTL_FREQ_OFFSET_ADDR_OFFSET 0x3FFFC678
97#define HYDRA_DMD_STR_FREQ_OFFSET_ADDR_OFFSET 0x3FFFC67C
98#define HYDRA_DMD_FTL_FREQ_OFFSET_ADDR_OFFSET 0x3FFFC680
99#define HYDRA_DMD_STR_NBC_SYNC_LOCK_ADDR_OFFSET 0x3FFFC684
100#define HYDRA_DMD_CYCLE_SLIP_COUNT_ADDR_OFFSET 0x3FFFC688
101
102#define HYDRA_DMD_DISPLAY_I_ADDR_OFFSET 0x3FFFC68C
103#define HYDRA_DMD_DISPLAY_Q_ADDR_OFFSET 0x3FFFC68E
104
105#define HYDRA_DMD_DVBS2_CRC_ERRORS_ADDR_OFFSET 0x3FFFC690
106#define HYDRA_DMD_DVBS2_PER_COUNT_ADDR_OFFSET 0x3FFFC694
107#define HYDRA_DMD_DVBS2_PER_WINDOW_ADDR_OFFSET 0x3FFFC698
108
109#define HYDRA_DMD_DVBS_CORR_RS_ERRORS_ADDR_OFFSET 0x3FFFC69C
110#define HYDRA_DMD_DVBS_UNCORR_RS_ERRORS_ADDR_OFFSET 0x3FFFC6A0
111#define HYDRA_DMD_DVBS_BER_COUNT_ADDR_OFFSET 0x3FFFC6A4
112#define HYDRA_DMD_DVBS_BER_WINDOW_ADDR_OFFSET 0x3FFFC6A8
113
114/* Debug-purpose DVB-S DMD 0 */
115#define HYDRA_DMD_DVBS_1ST_CORR_RS_ERRORS_ADDR_OFFSET 0x3FFFC6C8 /* corrected RS Errors: 1st iteration */
116#define HYDRA_DMD_DVBS_1ST_UNCORR_RS_ERRORS_ADDR_OFFSET 0x3FFFC6CC /* uncorrected RS Errors: 1st iteration */
117#define HYDRA_DMD_DVBS_BER_COUNT_1ST_ADDR_OFFSET 0x3FFFC6D0
118#define HYDRA_DMD_DVBS_BER_WINDOW_1ST_ADDR_OFFSET 0x3FFFC6D4
119
120#define HYDRA_DMD_TUNER_ID_ADDR_OFFSET 0x3FFFC6AC
121#define HYDRA_DMD_DVBS2_PILOT_ON_OFF_ADDR_OFFSET 0x3FFFC6B0
122#define HYDRA_DMD_FREQ_SEARCH_RANGE_KHZ_ADDR_OFFSET 0x3FFFC6B4
123#define HYDRA_DMD_STATUS_LOCK_ADDR_OFFSET 0x3FFFC6B8
124#define HYDRA_DMD_STATUS_CENTER_FREQ_IN_KHZ_ADDR 0x3FFFC704
125#define HYDRA_DMD_STATUS_INPUT_POWER_ADDR 0x3FFFC708
126
127/* DVB-S new scaled_BER_count for a new BER API, see HYDRA-1343 "DVB-S post viterbi information" */
128#define DMD0_STATUS_DVBS_1ST_SCALED_BER_COUNT_ADDR 0x3FFFC710 /* DMD 0: 1st iteration BER count scaled by HYDRA_BER_COUNT_SCALING_FACTOR */
129#define DMD0_STATUS_DVBS_SCALED_BER_COUNT_ADDR 0x3FFFC714 /* DMD 0: 2nd iteration BER count scaled by HYDRA_BER_COUNT_SCALING_FACTOR */
130
131#define DMD0_SPECTRUM_MIN_GAIN_STATUS 0x3FFFC73C
132#define DMD0_SPECTRUM_MIN_GAIN_WB_SAGC_VALUE 0x3FFFC740
133#define DMD0_SPECTRUM_MIN_GAIN_NB_SAGC_VALUE 0x3FFFC744
134
135#define HYDRA_DMD_STATUS_END_ADDR_OFFSET 0x3FFFC748
136
137/* Tuner status address offset from respective tuners's base address */
138#define HYDRA_TUNER_DEMOD_ID_ADDR_OFFSET 0x3FFFCE4C
139#define HYDRA_TUNER_AGC_LOCK_OFFSET 0x3FFFCE50
140#define HYDRA_TUNER_SPECTRUM_STATUS_OFFSET 0x3FFFCE54
141#define HYDRA_TUNER_SPECTRUM_BIN_SIZE_OFFSET 0x3FFFCE58
142#define HYDRA_TUNER_SPECTRUM_ADDRESS_OFFSET 0x3FFFCE5C
143#define HYDRA_TUNER_ENABLE_COMPLETE 0x3FFFEB78
144
145#define HYDRA_DEMOD_STATUS_LOCK(devId, demodId) write_register(devId, (HYDRA_DMD_STATUS_LOCK_ADDR_OFFSET + HYDRA_DMD_STATUS_OFFSET(demodId)), MXL_YES)
146#define HYDRA_DEMOD_STATUS_UNLOCK(devId, demodId) write_register(devId, (HYDRA_DMD_STATUS_LOCK_ADDR_OFFSET + HYDRA_DMD_STATUS_OFFSET(demodId)), MXL_NO)
147
148#define HYDRA_VERSION 0x3FFFEDB8
149#define HYDRA_DEMOD0_VERSION 0x3FFFEDBC
150#define HYDRA_DEMOD1_VERSION 0x3FFFEDC0
151#define HYDRA_DEMOD2_VERSION 0x3FFFEDC4
152#define HYDRA_DEMOD3_VERSION 0x3FFFEDC8
153#define HYDRA_DEMOD4_VERSION 0x3FFFEDCC
154#define HYDRA_DEMOD5_VERSION 0x3FFFEDD0
155#define HYDRA_DEMOD6_VERSION 0x3FFFEDD4
156#define HYDRA_DEMOD7_VERSION 0x3FFFEDD8
157#define HYDRA_HEAR_BEAT 0x3FFFEDDC
158#define HYDRA_SKU_MGMT 0x3FFFEBC0
159
160#define MXL_HYDRA_FPGA_A_ADDRESS 0x91C00000
161#define MXL_HYDRA_FPGA_B_ADDRESS 0x91D00000
162
163/* TS control base address */
164#define HYDRA_TS_CTRL_BASE_ADDR 0x90700000
165
166#define MPEG_MUX_MODE_SLICE0_REG (HYDRA_TS_CTRL_BASE_ADDR + 0x08)
167
168#define MPEG_MUX_MODE_SLICE1_REG (HYDRA_TS_CTRL_BASE_ADDR + 0x08)
169
170#define PID_BANK_SEL_SLICE0_REG (HYDRA_TS_CTRL_BASE_ADDR + 0x190)
171#define PID_BANK_SEL_SLICE1_REG (HYDRA_TS_CTRL_BASE_ADDR + 0x1B0)
172
173#define MPEG_CLK_GATED_REG (HYDRA_TS_CTRL_BASE_ADDR + 0x20)
174
175#define MPEG_CLK_ALWAYS_ON_REG (HYDRA_TS_CTRL_BASE_ADDR + 0x1D4)
176
177#define HYDRA_REGULAR_PID_BANK_A_REG (HYDRA_TS_CTRL_BASE_ADDR + 0x190)
178
179#define HYDRA_FIXED_PID_BANK_A_REG (HYDRA_TS_CTRL_BASE_ADDR + 0x190)
180
181#define HYDRA_REGULAR_PID_BANK_B_REG (HYDRA_TS_CTRL_BASE_ADDR + 0x1B0)
182
183#define HYDRA_FIXED_PID_BANK_B_REG (HYDRA_TS_CTRL_BASE_ADDR + 0x1B0)
184
185#define FIXED_PID_TBL_REG_ADDRESS_0 (HYDRA_TS_CTRL_BASE_ADDR + 0x9000)
186#define FIXED_PID_TBL_REG_ADDRESS_1 (HYDRA_TS_CTRL_BASE_ADDR + 0x9100)
187#define FIXED_PID_TBL_REG_ADDRESS_2 (HYDRA_TS_CTRL_BASE_ADDR + 0x9200)
188#define FIXED_PID_TBL_REG_ADDRESS_3 (HYDRA_TS_CTRL_BASE_ADDR + 0x9300)
189
190#define FIXED_PID_TBL_REG_ADDRESS_4 (HYDRA_TS_CTRL_BASE_ADDR + 0xB000)
191#define FIXED_PID_TBL_REG_ADDRESS_5 (HYDRA_TS_CTRL_BASE_ADDR + 0xB100)
192#define FIXED_PID_TBL_REG_ADDRESS_6 (HYDRA_TS_CTRL_BASE_ADDR + 0xB200)
193#define FIXED_PID_TBL_REG_ADDRESS_7 (HYDRA_TS_CTRL_BASE_ADDR + 0xB300)
194
195#define REGULAR_PID_TBL_REG_ADDRESS_0 (HYDRA_TS_CTRL_BASE_ADDR + 0x8000)
196#define REGULAR_PID_TBL_REG_ADDRESS_1 (HYDRA_TS_CTRL_BASE_ADDR + 0x8200)
197#define REGULAR_PID_TBL_REG_ADDRESS_2 (HYDRA_TS_CTRL_BASE_ADDR + 0x8400)
198#define REGULAR_PID_TBL_REG_ADDRESS_3 (HYDRA_TS_CTRL_BASE_ADDR + 0x8600)
199
200#define REGULAR_PID_TBL_REG_ADDRESS_4 (HYDRA_TS_CTRL_BASE_ADDR + 0xA000)
201#define REGULAR_PID_TBL_REG_ADDRESS_5 (HYDRA_TS_CTRL_BASE_ADDR + 0xA200)
202#define REGULAR_PID_TBL_REG_ADDRESS_6 (HYDRA_TS_CTRL_BASE_ADDR + 0xA400)
203#define REGULAR_PID_TBL_REG_ADDRESS_7 (HYDRA_TS_CTRL_BASE_ADDR + 0xA600)
204
205/***************************************************************************/
206
207#define PAD_MUX_GPIO_00_SYNC_BASEADDR 0x90000188
208
209
210#define PAD_MUX_UART_RX_C_PINMUX_BASEADDR 0x9000001C
211
212#define XPT_PACKET_GAP_MIN_BASEADDR 0x90700044
213#define XPT_NCO_COUNT_BASEADDR 0x90700238
214
215#define XPT_NCO_COUNT_BASEADDR1 0x9070023C
216
217/* V2 DigRF status register */
218
219#define XPT_PID_BASEADDR 0x90708000
220
221#define XPT_PID_REMAP_BASEADDR 0x90708004
222
223#define XPT_KNOWN_PID_BASEADDR 0x90709000
224
225#define XPT_PID_BASEADDR1 0x9070A000
226
227#define XPT_PID_REMAP_BASEADDR1 0x9070A004
228
229#define XPT_KNOWN_PID_BASEADDR1 0x9070B000
230
231#define XPT_BERT_LOCK_BASEADDR 0x907000B8
232
233#define XPT_BERT_BASEADDR 0x907000BC
234
235#define XPT_BERT_INVERT_BASEADDR 0x907000C0
236
237#define XPT_BERT_HEADER_BASEADDR 0x907000C4
238
239#define XPT_BERT_BASEADDR1 0x907000C8
240
241#define XPT_BERT_BIT_COUNT0_BASEADDR 0x907000CC
242
243#define XPT_BERT_BIT_COUNT0_BASEADDR1 0x907000D0
244
245#define XPT_BERT_BIT_COUNT1_BASEADDR 0x907000D4
246
247#define XPT_BERT_BIT_COUNT1_BASEADDR1 0x907000D8
248
249#define XPT_BERT_BIT_COUNT2_BASEADDR 0x907000DC
250
251#define XPT_BERT_BIT_COUNT2_BASEADDR1 0x907000E0
252
253#define XPT_BERT_BIT_COUNT3_BASEADDR 0x907000E4
254
255#define XPT_BERT_BIT_COUNT3_BASEADDR1 0x907000E8
256
257#define XPT_BERT_BIT_COUNT4_BASEADDR 0x907000EC
258
259#define XPT_BERT_BIT_COUNT4_BASEADDR1 0x907000F0
260
261#define XPT_BERT_BIT_COUNT5_BASEADDR 0x907000F4
262
263#define XPT_BERT_BIT_COUNT5_BASEADDR1 0x907000F8
264
265#define XPT_BERT_BIT_COUNT6_BASEADDR 0x907000FC
266
267#define XPT_BERT_BIT_COUNT6_BASEADDR1 0x90700100
268
269#define XPT_BERT_BIT_COUNT7_BASEADDR 0x90700104
270
271#define XPT_BERT_BIT_COUNT7_BASEADDR1 0x90700108
272
273#define XPT_BERT_ERR_COUNT0_BASEADDR 0x9070010C
274
275#define XPT_BERT_ERR_COUNT0_BASEADDR1 0x90700110
276
277#define XPT_BERT_ERR_COUNT1_BASEADDR 0x90700114
278
279#define XPT_BERT_ERR_COUNT1_BASEADDR1 0x90700118
280
281#define XPT_BERT_ERR_COUNT2_BASEADDR 0x9070011C
282
283#define XPT_BERT_ERR_COUNT2_BASEADDR1 0x90700120
284
285#define XPT_BERT_ERR_COUNT3_BASEADDR 0x90700124
286
287#define XPT_BERT_ERR_COUNT3_BASEADDR1 0x90700128
288
289#define XPT_BERT_ERR_COUNT4_BASEADDR 0x9070012C
290
291#define XPT_BERT_ERR_COUNT4_BASEADDR1 0x90700130
292
293#define XPT_BERT_ERR_COUNT5_BASEADDR 0x90700134
294
295#define XPT_BERT_ERR_COUNT5_BASEADDR1 0x90700138
296
297#define XPT_BERT_ERR_COUNT6_BASEADDR 0x9070013C
298
299#define XPT_BERT_ERR_COUNT6_BASEADDR1 0x90700140
300
301#define XPT_BERT_ERR_COUNT7_BASEADDR 0x90700144
302
303#define XPT_BERT_ERR_COUNT7_BASEADDR1 0x90700148
304
305#define XPT_BERT_ERROR_BASEADDR 0x9070014C
306
307#define XPT_BERT_ANALYZER_BASEADDR 0x90700150
308
309#define XPT_BERT_ANALYZER_BASEADDR1 0x90700154
310
311#define XPT_BERT_ANALYZER_BASEADDR2 0x90700158
312
313#define XPT_BERT_ANALYZER_BASEADDR3 0x9070015C
314
315#define XPT_BERT_ANALYZER_BASEADDR4 0x90700160
316
317#define XPT_BERT_ANALYZER_BASEADDR5 0x90700164
318
319#define XPT_BERT_ANALYZER_BASEADDR6 0x90700168
320
321#define XPT_BERT_ANALYZER_BASEADDR7 0x9070016C
322
323#define XPT_BERT_ANALYZER_BASEADDR8 0x90700170
324
325#define XPT_BERT_ANALYZER_BASEADDR9 0x90700174
326
327#define XPT_DMD0_BASEADDR 0x9070024C
328
329/* V2 AGC Gain Freeze & step */
330#define DBG_ENABLE_DISABLE_AGC (0x3FFFCF60) /* 1: DISABLE, 0:ENABLE */
331#define WB_DFE0_DFE_FB_RF1_BASEADDR 0x903004A4
332
333#define WB_DFE1_DFE_FB_RF1_BASEADDR 0x904004A4
334
335#define WB_DFE2_DFE_FB_RF1_BASEADDR 0x905004A4
336
337#define WB_DFE3_DFE_FB_RF1_BASEADDR 0x906004A4
338
339#define AFE_REG_D2A_TA_RFFE_LNA_BO_1P8_BASEADDR 0x90200104
340
341#define AFE_REG_AFE_REG_SPARE_BASEADDR 0x902000A0
342
343#define AFE_REG_AFE_REG_SPARE_BASEADDR1 0x902000B4
344
345#define AFE_REG_AFE_REG_SPARE_BASEADDR2 0x902000C4
346
347#define AFE_REG_AFE_REG_SPARE_BASEADDR3 0x902000D4
348
349#define WB_DFE0_DFE_FB_AGC_BASEADDR 0x90300498
350
351#define WB_DFE1_DFE_FB_AGC_BASEADDR 0x90400498
352
353#define WB_DFE2_DFE_FB_AGC_BASEADDR 0x90500498
354
355#define WB_DFE3_DFE_FB_AGC_BASEADDR 0x90600498
356
357#define WDT_WD_INT_BASEADDR 0x8002000C
358
359#define FSK_TX_FTM_BASEADDR 0x80090000
360
361#define FSK_TX_FTM_TX_CNT_BASEADDR 0x80090018
362
363#define AFE_REG_D2A_FSK_BIAS_BASEADDR 0x90200040
364
365#define DMD_TEI_BASEADDR 0x3FFFEBE0
366
367#endif /* __MXL58X_REGISTERS_H__ */
diff --git a/drivers/media/dvb-frontends/s5h1420.c b/drivers/media/dvb-frontends/s5h1420.c
index cba9bff05b12..fd427a29c001 100644
--- a/drivers/media/dvb-frontends/s5h1420.c
+++ b/drivers/media/dvb-frontends/s5h1420.c
@@ -864,7 +864,7 @@ static int s5h1420_tuner_i2c_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c
864 return i2c_transfer(state->i2c, m, 1 + num) == 1 + num ? num : -EIO; 864 return i2c_transfer(state->i2c, m, 1 + num) == 1 + num ? num : -EIO;
865} 865}
866 866
867static struct i2c_algorithm s5h1420_tuner_i2c_algo = { 867static const struct i2c_algorithm s5h1420_tuner_i2c_algo = {
868 .master_xfer = s5h1420_tuner_i2c_tuner_xfer, 868 .master_xfer = s5h1420_tuner_i2c_tuner_xfer,
869 .functionality = s5h1420_tuner_i2c_func, 869 .functionality = s5h1420_tuner_i2c_func,
870}; 870};
diff --git a/drivers/media/dvb-frontends/stv0367.c b/drivers/media/dvb-frontends/stv0367.c
index 8ac0f598978d..f3529df8211d 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -2149,6 +2149,71 @@ static u32 stv0367cab_GetSymbolRate(struct stv0367_state *state, u32 mclk_hz)
2149 return regsym; 2149 return regsym;
2150} 2150}
2151 2151
2152static u32 stv0367cab_fsm_status(struct stv0367_state *state)
2153{
2154 return stv0367_readbits(state, F367CAB_FSM_STATUS);
2155}
2156
2157static u32 stv0367cab_qamfec_lock(struct stv0367_state *state)
2158{
2159 return stv0367_readbits(state,
2160 (state->cab_state->qamfec_status_reg ?
2161 state->cab_state->qamfec_status_reg :
2162 F367CAB_QAMFEC_LOCK));
2163}
2164
2165static
2166enum stv0367_cab_signal_type stv0367cab_fsm_signaltype(u32 qam_fsm_status)
2167{
2168 enum stv0367_cab_signal_type signaltype = FE_CAB_NOAGC;
2169
2170 switch (qam_fsm_status) {
2171 case 1:
2172 signaltype = FE_CAB_NOAGC;
2173 break;
2174 case 2:
2175 signaltype = FE_CAB_NOTIMING;
2176 break;
2177 case 3:
2178 signaltype = FE_CAB_TIMINGOK;
2179 break;
2180 case 4:
2181 signaltype = FE_CAB_NOCARRIER;
2182 break;
2183 case 5:
2184 signaltype = FE_CAB_CARRIEROK;
2185 break;
2186 case 7:
2187 signaltype = FE_CAB_NOBLIND;
2188 break;
2189 case 8:
2190 signaltype = FE_CAB_BLINDOK;
2191 break;
2192 case 10:
2193 signaltype = FE_CAB_NODEMOD;
2194 break;
2195 case 11:
2196 signaltype = FE_CAB_DEMODOK;
2197 break;
2198 case 12:
2199 signaltype = FE_CAB_DEMODOK;
2200 break;
2201 case 13:
2202 signaltype = FE_CAB_NODEMOD;
2203 break;
2204 case 14:
2205 signaltype = FE_CAB_NOBLIND;
2206 break;
2207 case 15:
2208 signaltype = FE_CAB_NOSIGNAL;
2209 break;
2210 default:
2211 break;
2212 }
2213
2214 return signaltype;
2215}
2216
2152static int stv0367cab_read_status(struct dvb_frontend *fe, 2217static int stv0367cab_read_status(struct dvb_frontend *fe,
2153 enum fe_status *status) 2218 enum fe_status *status)
2154{ 2219{
@@ -2158,22 +2223,26 @@ static int stv0367cab_read_status(struct dvb_frontend *fe,
2158 2223
2159 *status = 0; 2224 *status = 0;
2160 2225
2161 if (state->cab_state->state > FE_CAB_NOSIGNAL) 2226 /* update cab_state->state from QAM_FSM_STATUS */
2162 *status |= FE_HAS_SIGNAL; 2227 state->cab_state->state = stv0367cab_fsm_signaltype(
2228 stv0367cab_fsm_status(state));
2163 2229
2164 if (state->cab_state->state > FE_CAB_NOCARRIER) 2230 if (stv0367cab_qamfec_lock(state)) {
2165 *status |= FE_HAS_CARRIER; 2231 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI
2232 | FE_HAS_SYNC | FE_HAS_LOCK;
2233 dprintk("%s: stv0367 has locked\n", __func__);
2234 } else {
2235 if (state->cab_state->state > FE_CAB_NOSIGNAL)
2236 *status |= FE_HAS_SIGNAL;
2166 2237
2167 if (state->cab_state->state >= FE_CAB_DEMODOK) 2238 if (state->cab_state->state > FE_CAB_NOCARRIER)
2168 *status |= FE_HAS_VITERBI; 2239 *status |= FE_HAS_CARRIER;
2169 2240
2170 if (state->cab_state->state >= FE_CAB_DATAOK) 2241 if (state->cab_state->state >= FE_CAB_DEMODOK)
2171 *status |= FE_HAS_SYNC; 2242 *status |= FE_HAS_VITERBI;
2172 2243
2173 if (stv0367_readbits(state, (state->cab_state->qamfec_status_reg ? 2244 if (state->cab_state->state >= FE_CAB_DATAOK)
2174 state->cab_state->qamfec_status_reg : F367CAB_QAMFEC_LOCK))) { 2245 *status |= FE_HAS_SYNC;
2175 *status |= FE_HAS_LOCK;
2176 dprintk("%s: stv0367 has locked\n", __func__);
2177 } 2246 }
2178 2247
2179 return 0; 2248 return 0;
@@ -2374,7 +2443,7 @@ enum stv0367_cab_signal_type stv0367cab_algo(struct stv0367_state *state,
2374 LockTime = 0; 2443 LockTime = 0;
2375 stv0367_writereg(state, R367CAB_CTRL_1, 0x00); 2444 stv0367_writereg(state, R367CAB_CTRL_1, 0x00);
2376 do { 2445 do {
2377 QAM_Lock = stv0367_readbits(state, F367CAB_FSM_STATUS); 2446 QAM_Lock = stv0367cab_fsm_status(state);
2378 if ((LockTime >= (DemodTimeOut - EQLTimeOut)) && 2447 if ((LockTime >= (DemodTimeOut - EQLTimeOut)) &&
2379 (QAM_Lock == 0x04)) 2448 (QAM_Lock == 0x04))
2380 /* 2449 /*
@@ -2435,10 +2504,7 @@ enum stv0367_cab_signal_type stv0367cab_algo(struct stv0367_state *state,
2435 do { 2504 do {
2436 usleep_range(5000, 7000); 2505 usleep_range(5000, 7000);
2437 LockTime += 5; 2506 LockTime += 5;
2438 QAMFEC_Lock = stv0367_readbits(state, 2507 QAMFEC_Lock = stv0367cab_qamfec_lock(state);
2439 (state->cab_state->qamfec_status_reg ?
2440 state->cab_state->qamfec_status_reg :
2441 F367CAB_QAMFEC_LOCK));
2442 } while (!QAMFEC_Lock && (LockTime < FECTimeOut)); 2508 } while (!QAMFEC_Lock && (LockTime < FECTimeOut));
2443 } else 2509 } else
2444 QAMFEC_Lock = 0; 2510 QAMFEC_Lock = 0;
@@ -2474,52 +2540,8 @@ enum stv0367_cab_signal_type stv0367cab_algo(struct stv0367_state *state,
2474 cab_state->locked = 1; 2540 cab_state->locked = 1;
2475 2541
2476 /* stv0367_setbits(state, F367CAB_AGC_ACCUMRSTSEL,7);*/ 2542 /* stv0367_setbits(state, F367CAB_AGC_ACCUMRSTSEL,7);*/
2477 } else { 2543 } else
2478 switch (QAM_Lock) { 2544 signalType = stv0367cab_fsm_signaltype(QAM_Lock);
2479 case 1:
2480 signalType = FE_CAB_NOAGC;
2481 break;
2482 case 2:
2483 signalType = FE_CAB_NOTIMING;
2484 break;
2485 case 3:
2486 signalType = FE_CAB_TIMINGOK;
2487 break;
2488 case 4:
2489 signalType = FE_CAB_NOCARRIER;
2490 break;
2491 case 5:
2492 signalType = FE_CAB_CARRIEROK;
2493 break;
2494 case 7:
2495 signalType = FE_CAB_NOBLIND;
2496 break;
2497 case 8:
2498 signalType = FE_CAB_BLINDOK;
2499 break;
2500 case 10:
2501 signalType = FE_CAB_NODEMOD;
2502 break;
2503 case 11:
2504 signalType = FE_CAB_DEMODOK;
2505 break;
2506 case 12:
2507 signalType = FE_CAB_DEMODOK;
2508 break;
2509 case 13:
2510 signalType = FE_CAB_NODEMOD;
2511 break;
2512 case 14:
2513 signalType = FE_CAB_NOBLIND;
2514 break;
2515 case 15:
2516 signalType = FE_CAB_NOSIGNAL;
2517 break;
2518 default:
2519 break;
2520 }
2521
2522 }
2523 2545
2524 /* Set the AGC control values to tracking values */ 2546 /* Set the AGC control values to tracking values */
2525 stv0367_writebits(state, F367CAB_AGC_ACCUMRSTSEL, TrackAGCAccum); 2547 stv0367_writebits(state, F367CAB_AGC_ACCUMRSTSEL, TrackAGCAccum);
@@ -3090,7 +3112,7 @@ static int stv0367ddb_read_status(struct dvb_frontend *fe,
3090{ 3112{
3091 struct stv0367_state *state = fe->demodulator_priv; 3113 struct stv0367_state *state = fe->demodulator_priv;
3092 struct dtv_frontend_properties *p = &fe->dtv_property_cache; 3114 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
3093 int ret; 3115 int ret = 0;
3094 3116
3095 switch (state->activedemod) { 3117 switch (state->activedemod) {
3096 case demod_ter: 3118 case demod_ter:
@@ -3100,7 +3122,7 @@ static int stv0367ddb_read_status(struct dvb_frontend *fe,
3100 ret = stv0367cab_read_status(fe, status); 3122 ret = stv0367cab_read_status(fe, status);
3101 break; 3123 break;
3102 default: 3124 default:
3103 return 0; 3125 break;
3104 } 3126 }
3105 3127
3106 /* stop and report on *_read_status failure */ 3128 /* stop and report on *_read_status failure */
@@ -3138,7 +3160,7 @@ static int stv0367ddb_get_frontend(struct dvb_frontend *fe,
3138 break; 3160 break;
3139 } 3161 }
3140 3162
3141 return -EINVAL; 3163 return 0;
3142} 3164}
3143 3165
3144static int stv0367ddb_sleep(struct dvb_frontend *fe) 3166static int stv0367ddb_sleep(struct dvb_frontend *fe)
@@ -3261,7 +3283,7 @@ static const struct dvb_frontend_ops stv0367ddb_ops = {
3261 0x400 |/* FE_CAN_QAM_4 */ 3283 0x400 |/* FE_CAN_QAM_4 */
3262 FE_CAN_QAM_16 | FE_CAN_QAM_32 | 3284 FE_CAN_QAM_16 | FE_CAN_QAM_32 |
3263 FE_CAN_QAM_64 | FE_CAN_QAM_128 | 3285 FE_CAN_QAM_64 | FE_CAN_QAM_128 |
3264 FE_CAN_QAM_256 | FE_CAN_QAM_AUTO | 3286 FE_CAN_QAM_256 |
3265 /* DVB-T */ 3287 /* DVB-T */
3266 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 3288 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
3267 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | 3289 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
diff --git a/drivers/media/dvb-frontends/stv0910.c b/drivers/media/dvb-frontends/stv0910.c
new file mode 100644
index 000000000000..8bf855c301f5
--- /dev/null
+++ b/drivers/media/dvb-frontends/stv0910.c
@@ -0,0 +1,1813 @@
1/*
2 * Driver for the ST STV0910 DVB-S/S2 demodulator.
3 *
4 * Copyright (C) 2014-2015 Ralph Metzler <rjkm@metzlerbros.de>
5 * Marcus Metzler <mocm@metzlerbros.de>
6 * developed for Digital Devices GmbH
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 only, as 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
18#include <linux/kernel.h>
19#include <linux/module.h>
20#include <linux/moduleparam.h>
21#include <linux/init.h>
22#include <linux/delay.h>
23#include <linux/firmware.h>
24#include <linux/i2c.h>
25#include <asm/div64.h>
26
27#include "dvb_math.h"
28#include "dvb_frontend.h"
29#include "stv0910.h"
30#include "stv0910_regs.h"
31
32#define EXT_CLOCK 30000000
33#define TUNING_DELAY 200
34#define BER_SRC_S 0x20
35#define BER_SRC_S2 0x20
36
37static LIST_HEAD(stvlist);
38
39enum receive_mode { RCVMODE_NONE, RCVMODE_DVBS, RCVMODE_DVBS2, RCVMODE_AUTO };
40
41enum dvbs2_fectype { DVBS2_64K, DVBS2_16K };
42
43enum dvbs2_mod_cod {
44 DVBS2_DUMMY_PLF, DVBS2_QPSK_1_4, DVBS2_QPSK_1_3, DVBS2_QPSK_2_5,
45 DVBS2_QPSK_1_2, DVBS2_QPSK_3_5, DVBS2_QPSK_2_3, DVBS2_QPSK_3_4,
46 DVBS2_QPSK_4_5, DVBS2_QPSK_5_6, DVBS2_QPSK_8_9, DVBS2_QPSK_9_10,
47 DVBS2_8PSK_3_5, DVBS2_8PSK_2_3, DVBS2_8PSK_3_4, DVBS2_8PSK_5_6,
48 DVBS2_8PSK_8_9, DVBS2_8PSK_9_10, DVBS2_16APSK_2_3, DVBS2_16APSK_3_4,
49 DVBS2_16APSK_4_5, DVBS2_16APSK_5_6, DVBS2_16APSK_8_9, DVBS2_16APSK_9_10,
50 DVBS2_32APSK_3_4, DVBS2_32APSK_4_5, DVBS2_32APSK_5_6, DVBS2_32APSK_8_9,
51 DVBS2_32APSK_9_10
52};
53
54enum fe_stv0910_mod_cod {
55 FE_DUMMY_PLF, FE_QPSK_14, FE_QPSK_13, FE_QPSK_25,
56 FE_QPSK_12, FE_QPSK_35, FE_QPSK_23, FE_QPSK_34,
57 FE_QPSK_45, FE_QPSK_56, FE_QPSK_89, FE_QPSK_910,
58 FE_8PSK_35, FE_8PSK_23, FE_8PSK_34, FE_8PSK_56,
59 FE_8PSK_89, FE_8PSK_910, FE_16APSK_23, FE_16APSK_34,
60 FE_16APSK_45, FE_16APSK_56, FE_16APSK_89, FE_16APSK_910,
61 FE_32APSK_34, FE_32APSK_45, FE_32APSK_56, FE_32APSK_89,
62 FE_32APSK_910
63};
64
65enum fe_stv0910_roll_off { FE_SAT_35, FE_SAT_25, FE_SAT_20, FE_SAT_15 };
66
67static inline u32 muldiv32(u32 a, u32 b, u32 c)
68{
69 u64 tmp64;
70
71 tmp64 = (u64)a * (u64)b;
72 do_div(tmp64, c);
73
74 return (u32)tmp64;
75}
76
77struct stv_base {
78 struct list_head stvlist;
79
80 u8 adr;
81 struct i2c_adapter *i2c;
82 struct mutex i2c_lock; /* shared I2C access protect */
83 struct mutex reg_lock; /* shared register write protect */
84 int count;
85
86 u32 extclk;
87 u32 mclk;
88};
89
90struct stv {
91 struct stv_base *base;
92 struct dvb_frontend fe;
93 int nr;
94 u16 regoff;
95 u8 i2crpt;
96 u8 tscfgh;
97 u8 tsgeneral;
98 u8 tsspeed;
99 u8 single;
100 unsigned long tune_time;
101
102 s32 search_range;
103 u32 started;
104 u32 demod_lock_time;
105 enum receive_mode receive_mode;
106 u32 demod_timeout;
107 u32 fec_timeout;
108 u32 first_time_lock;
109 u8 demod_bits;
110 u32 symbol_rate;
111
112 u8 last_viterbi_rate;
113 enum fe_code_rate puncture_rate;
114 enum fe_stv0910_mod_cod mod_cod;
115 enum dvbs2_fectype fectype;
116 u32 pilots;
117 enum fe_stv0910_roll_off feroll_off;
118
119 int is_standard_broadcast;
120 int is_vcm;
121
122 u32 cur_scrambling_code;
123
124 u32 last_bernumerator;
125 u32 last_berdenominator;
126 u8 berscale;
127
128 u8 vth[6];
129};
130
131struct sinit_table {
132 u16 address;
133 u8 data;
134};
135
136struct slookup {
137 s16 value;
138 u32 reg_value;
139};
140
141static inline int i2c_write(struct i2c_adapter *adap, u8 adr,
142 u8 *data, int len)
143{
144 struct i2c_msg msg = {.addr = adr, .flags = 0,
145 .buf = data, .len = len};
146
147 if (i2c_transfer(adap, &msg, 1) != 1) {
148 dev_warn(&adap->dev, "i2c write error ([%02x] %04x: %02x)\n",
149 adr, (data[0] << 8) | data[1],
150 (len > 2 ? data[2] : 0));
151 return -EREMOTEIO;
152 }
153 return 0;
154}
155
156static int i2c_write_reg16(struct i2c_adapter *adap, u8 adr, u16 reg, u8 val)
157{
158 u8 msg[3] = {reg >> 8, reg & 0xff, val};
159
160 return i2c_write(adap, adr, msg, 3);
161}
162
163static int write_reg(struct stv *state, u16 reg, u8 val)
164{
165 return i2c_write_reg16(state->base->i2c, state->base->adr, reg, val);
166}
167
168static inline int i2c_read_regs16(struct i2c_adapter *adapter, u8 adr,
169 u16 reg, u8 *val, int count)
170{
171 u8 msg[2] = {reg >> 8, reg & 0xff};
172 struct i2c_msg msgs[2] = {{.addr = adr, .flags = 0,
173 .buf = msg, .len = 2},
174 {.addr = adr, .flags = I2C_M_RD,
175 .buf = val, .len = count } };
176
177 if (i2c_transfer(adapter, msgs, 2) != 2) {
178 dev_warn(&adapter->dev, "i2c read error ([%02x] %04x)\n",
179 adr, reg);
180 return -EREMOTEIO;
181 }
182 return 0;
183}
184
185static int read_reg(struct stv *state, u16 reg, u8 *val)
186{
187 return i2c_read_regs16(state->base->i2c, state->base->adr,
188 reg, val, 1);
189}
190
191static int read_regs(struct stv *state, u16 reg, u8 *val, int len)
192{
193 return i2c_read_regs16(state->base->i2c, state->base->adr,
194 reg, val, len);
195}
196
197static int write_shared_reg(struct stv *state, u16 reg, u8 mask, u8 val)
198{
199 int status;
200 u8 tmp;
201
202 mutex_lock(&state->base->reg_lock);
203 status = read_reg(state, reg, &tmp);
204 if (!status)
205 status = write_reg(state, reg, (tmp & ~mask) | (val & mask));
206 mutex_unlock(&state->base->reg_lock);
207 return status;
208}
209
210static const struct slookup s1_sn_lookup[] = {
211 { 0, 9242 }, /* C/N= 0dB */
212 { 5, 9105 }, /* C/N= 0.5dB */
213 { 10, 8950 }, /* C/N= 1.0dB */
214 { 15, 8780 }, /* C/N= 1.5dB */
215 { 20, 8566 }, /* C/N= 2.0dB */
216 { 25, 8366 }, /* C/N= 2.5dB */
217 { 30, 8146 }, /* C/N= 3.0dB */
218 { 35, 7908 }, /* C/N= 3.5dB */
219 { 40, 7666 }, /* C/N= 4.0dB */
220 { 45, 7405 }, /* C/N= 4.5dB */
221 { 50, 7136 }, /* C/N= 5.0dB */
222 { 55, 6861 }, /* C/N= 5.5dB */
223 { 60, 6576 }, /* C/N= 6.0dB */
224 { 65, 6330 }, /* C/N= 6.5dB */
225 { 70, 6048 }, /* C/N= 7.0dB */
226 { 75, 5768 }, /* C/N= 7.5dB */
227 { 80, 5492 }, /* C/N= 8.0dB */
228 { 85, 5224 }, /* C/N= 8.5dB */
229 { 90, 4959 }, /* C/N= 9.0dB */
230 { 95, 4709 }, /* C/N= 9.5dB */
231 { 100, 4467 }, /* C/N=10.0dB */
232 { 105, 4236 }, /* C/N=10.5dB */
233 { 110, 4013 }, /* C/N=11.0dB */
234 { 115, 3800 }, /* C/N=11.5dB */
235 { 120, 3598 }, /* C/N=12.0dB */
236 { 125, 3406 }, /* C/N=12.5dB */
237 { 130, 3225 }, /* C/N=13.0dB */
238 { 135, 3052 }, /* C/N=13.5dB */
239 { 140, 2889 }, /* C/N=14.0dB */
240 { 145, 2733 }, /* C/N=14.5dB */
241 { 150, 2587 }, /* C/N=15.0dB */
242 { 160, 2318 }, /* C/N=16.0dB */
243 { 170, 2077 }, /* C/N=17.0dB */
244 { 180, 1862 }, /* C/N=18.0dB */
245 { 190, 1670 }, /* C/N=19.0dB */
246 { 200, 1499 }, /* C/N=20.0dB */
247 { 210, 1347 }, /* C/N=21.0dB */
248 { 220, 1213 }, /* C/N=22.0dB */
249 { 230, 1095 }, /* C/N=23.0dB */
250 { 240, 992 }, /* C/N=24.0dB */
251 { 250, 900 }, /* C/N=25.0dB */
252 { 260, 826 }, /* C/N=26.0dB */
253 { 270, 758 }, /* C/N=27.0dB */
254 { 280, 702 }, /* C/N=28.0dB */
255 { 290, 653 }, /* C/N=29.0dB */
256 { 300, 613 }, /* C/N=30.0dB */
257 { 310, 579 }, /* C/N=31.0dB */
258 { 320, 550 }, /* C/N=32.0dB */
259 { 330, 526 }, /* C/N=33.0dB */
260 { 350, 490 }, /* C/N=33.0dB */
261 { 400, 445 }, /* C/N=40.0dB */
262 { 450, 430 }, /* C/N=45.0dB */
263 { 500, 426 }, /* C/N=50.0dB */
264 { 510, 425 } /* C/N=51.0dB */
265};
266
267static const struct slookup s2_sn_lookup[] = {
268 { -30, 13950 }, /* C/N=-2.5dB */
269 { -25, 13580 }, /* C/N=-2.5dB */
270 { -20, 13150 }, /* C/N=-2.0dB */
271 { -15, 12760 }, /* C/N=-1.5dB */
272 { -10, 12345 }, /* C/N=-1.0dB */
273 { -5, 11900 }, /* C/N=-0.5dB */
274 { 0, 11520 }, /* C/N= 0dB */
275 { 5, 11080 }, /* C/N= 0.5dB */
276 { 10, 10630 }, /* C/N= 1.0dB */
277 { 15, 10210 }, /* C/N= 1.5dB */
278 { 20, 9790 }, /* C/N= 2.0dB */
279 { 25, 9390 }, /* C/N= 2.5dB */
280 { 30, 8970 }, /* C/N= 3.0dB */
281 { 35, 8575 }, /* C/N= 3.5dB */
282 { 40, 8180 }, /* C/N= 4.0dB */
283 { 45, 7800 }, /* C/N= 4.5dB */
284 { 50, 7430 }, /* C/N= 5.0dB */
285 { 55, 7080 }, /* C/N= 5.5dB */
286 { 60, 6720 }, /* C/N= 6.0dB */
287 { 65, 6320 }, /* C/N= 6.5dB */
288 { 70, 6060 }, /* C/N= 7.0dB */
289 { 75, 5760 }, /* C/N= 7.5dB */
290 { 80, 5480 }, /* C/N= 8.0dB */
291 { 85, 5200 }, /* C/N= 8.5dB */
292 { 90, 4930 }, /* C/N= 9.0dB */
293 { 95, 4680 }, /* C/N= 9.5dB */
294 { 100, 4425 }, /* C/N=10.0dB */
295 { 105, 4210 }, /* C/N=10.5dB */
296 { 110, 3980 }, /* C/N=11.0dB */
297 { 115, 3765 }, /* C/N=11.5dB */
298 { 120, 3570 }, /* C/N=12.0dB */
299 { 125, 3315 }, /* C/N=12.5dB */
300 { 130, 3140 }, /* C/N=13.0dB */
301 { 135, 2980 }, /* C/N=13.5dB */
302 { 140, 2820 }, /* C/N=14.0dB */
303 { 145, 2670 }, /* C/N=14.5dB */
304 { 150, 2535 }, /* C/N=15.0dB */
305 { 160, 2270 }, /* C/N=16.0dB */
306 { 170, 2035 }, /* C/N=17.0dB */
307 { 180, 1825 }, /* C/N=18.0dB */
308 { 190, 1650 }, /* C/N=19.0dB */
309 { 200, 1485 }, /* C/N=20.0dB */
310 { 210, 1340 }, /* C/N=21.0dB */
311 { 220, 1212 }, /* C/N=22.0dB */
312 { 230, 1100 }, /* C/N=23.0dB */
313 { 240, 1000 }, /* C/N=24.0dB */
314 { 250, 910 }, /* C/N=25.0dB */
315 { 260, 836 }, /* C/N=26.0dB */
316 { 270, 772 }, /* C/N=27.0dB */
317 { 280, 718 }, /* C/N=28.0dB */
318 { 290, 671 }, /* C/N=29.0dB */
319 { 300, 635 }, /* C/N=30.0dB */
320 { 310, 602 }, /* C/N=31.0dB */
321 { 320, 575 }, /* C/N=32.0dB */
322 { 330, 550 }, /* C/N=33.0dB */
323 { 350, 517 }, /* C/N=35.0dB */
324 { 400, 480 }, /* C/N=40.0dB */
325 { 450, 466 }, /* C/N=45.0dB */
326 { 500, 464 }, /* C/N=50.0dB */
327 { 510, 463 }, /* C/N=51.0dB */
328};
329
330static const struct slookup padc_lookup[] = {
331 { 0, 118000 }, /* PADC= +0dBm */
332 { -100, 93600 }, /* PADC= -1dBm */
333 { -200, 74500 }, /* PADC= -2dBm */
334 { -300, 59100 }, /* PADC= -3dBm */
335 { -400, 47000 }, /* PADC= -4dBm */
336 { -500, 37300 }, /* PADC= -5dBm */
337 { -600, 29650 }, /* PADC= -6dBm */
338 { -700, 23520 }, /* PADC= -7dBm */
339 { -900, 14850 }, /* PADC= -9dBm */
340 { -1100, 9380 }, /* PADC=-11dBm */
341 { -1300, 5910 }, /* PADC=-13dBm */
342 { -1500, 3730 }, /* PADC=-15dBm */
343 { -1700, 2354 }, /* PADC=-17dBm */
344 { -1900, 1485 }, /* PADC=-19dBm */
345 { -2000, 1179 }, /* PADC=-20dBm */
346 { -2100, 1000 }, /* PADC=-21dBm */
347};
348
349/*********************************************************************
350 * Tracking carrier loop carrier QPSK 1/4 to 8PSK 9/10 long Frame
351 *********************************************************************/
352static const u8 s2car_loop[] = {
353 /*
354 * Modcod 2MPon 2MPoff 5MPon 5MPoff 10MPon 10MPoff
355 * 20MPon 20MPoff 30MPon 30MPoff
356 */
357
358 /* FE_QPSK_14 */
359 0x0C, 0x3C, 0x0B, 0x3C, 0x2A, 0x2C, 0x2A, 0x1C, 0x3A, 0x3B,
360 /* FE_QPSK_13 */
361 0x0C, 0x3C, 0x0B, 0x3C, 0x2A, 0x2C, 0x3A, 0x0C, 0x3A, 0x2B,
362 /* FE_QPSK_25 */
363 0x1C, 0x3C, 0x1B, 0x3C, 0x3A, 0x1C, 0x3A, 0x3B, 0x3A, 0x2B,
364 /* FE_QPSK_12 */
365 0x0C, 0x1C, 0x2B, 0x1C, 0x0B, 0x2C, 0x0B, 0x0C, 0x2A, 0x2B,
366 /* FE_QPSK_35 */
367 0x1C, 0x1C, 0x2B, 0x1C, 0x0B, 0x2C, 0x0B, 0x0C, 0x2A, 0x2B,
368 /* FE_QPSK_23 */
369 0x2C, 0x2C, 0x2B, 0x1C, 0x0B, 0x2C, 0x0B, 0x0C, 0x2A, 0x2B,
370 /* FE_QPSK_34 */
371 0x3C, 0x2C, 0x3B, 0x2C, 0x1B, 0x1C, 0x1B, 0x3B, 0x3A, 0x1B,
372 /* FE_QPSK_45 */
373 0x0D, 0x3C, 0x3B, 0x2C, 0x1B, 0x1C, 0x1B, 0x3B, 0x3A, 0x1B,
374 /* FE_QPSK_56 */
375 0x1D, 0x3C, 0x0C, 0x2C, 0x2B, 0x1C, 0x1B, 0x3B, 0x0B, 0x1B,
376 /* FE_QPSK_89 */
377 0x3D, 0x0D, 0x0C, 0x2C, 0x2B, 0x0C, 0x2B, 0x2B, 0x0B, 0x0B,
378 /* FE_QPSK_910 */
379 0x1E, 0x0D, 0x1C, 0x2C, 0x3B, 0x0C, 0x2B, 0x2B, 0x1B, 0x0B,
380 /* FE_8PSK_35 */
381 0x28, 0x09, 0x28, 0x09, 0x28, 0x09, 0x28, 0x08, 0x28, 0x27,
382 /* FE_8PSK_23 */
383 0x19, 0x29, 0x19, 0x29, 0x19, 0x29, 0x38, 0x19, 0x28, 0x09,
384 /* FE_8PSK_34 */
385 0x1A, 0x0B, 0x1A, 0x3A, 0x0A, 0x2A, 0x39, 0x2A, 0x39, 0x1A,
386 /* FE_8PSK_56 */
387 0x2B, 0x2B, 0x1B, 0x1B, 0x0B, 0x1B, 0x1A, 0x0B, 0x1A, 0x1A,
388 /* FE_8PSK_89 */
389 0x0C, 0x0C, 0x3B, 0x3B, 0x1B, 0x1B, 0x2A, 0x0B, 0x2A, 0x2A,
390 /* FE_8PSK_910 */
391 0x0C, 0x1C, 0x0C, 0x3B, 0x2B, 0x1B, 0x3A, 0x0B, 0x2A, 0x2A,
392
393 /**********************************************************************
394 * Tracking carrier loop carrier 16APSK 2/3 to 32APSK 9/10 long Frame
395 **********************************************************************/
396
397 /*
398 * Modcod 2MPon 2MPoff 5MPon 5MPoff 10MPon 10MPoff 20MPon
399 * 20MPoff 30MPon 30MPoff
400 */
401
402 /* FE_16APSK_23 */
403 0x0A, 0x0A, 0x0A, 0x0A, 0x1A, 0x0A, 0x39, 0x0A, 0x29, 0x0A,
404 /* FE_16APSK_34 */
405 0x0A, 0x0A, 0x0A, 0x0A, 0x0B, 0x0A, 0x2A, 0x0A, 0x1A, 0x0A,
406 /* FE_16APSK_45 */
407 0x0A, 0x0A, 0x0A, 0x0A, 0x1B, 0x0A, 0x3A, 0x0A, 0x2A, 0x0A,
408 /* FE_16APSK_56 */
409 0x0A, 0x0A, 0x0A, 0x0A, 0x1B, 0x0A, 0x3A, 0x0A, 0x2A, 0x0A,
410 /* FE_16APSK_89 */
411 0x0A, 0x0A, 0x0A, 0x0A, 0x2B, 0x0A, 0x0B, 0x0A, 0x3A, 0x0A,
412 /* FE_16APSK_910 */
413 0x0A, 0x0A, 0x0A, 0x0A, 0x2B, 0x0A, 0x0B, 0x0A, 0x3A, 0x0A,
414 /* FE_32APSK_34 */
415 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
416 /* FE_32APSK_45 */
417 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
418 /* FE_32APSK_56 */
419 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
420 /* FE_32APSK_89 */
421 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
422 /* FE_32APSK_910 */
423 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
424};
425
426static u8 get_optim_cloop(struct stv *state,
427 enum fe_stv0910_mod_cod mod_cod, u32 pilots)
428{
429 int i = 0;
430
431 if (mod_cod >= FE_32APSK_910)
432 i = ((int)FE_32APSK_910 - (int)FE_QPSK_14) * 10;
433 else if (mod_cod >= FE_QPSK_14)
434 i = ((int)mod_cod - (int)FE_QPSK_14) * 10;
435
436 if (state->symbol_rate <= 3000000)
437 i += 0;
438 else if (state->symbol_rate <= 7000000)
439 i += 2;
440 else if (state->symbol_rate <= 15000000)
441 i += 4;
442 else if (state->symbol_rate <= 25000000)
443 i += 6;
444 else
445 i += 8;
446
447 if (!pilots)
448 i += 1;
449
450 return s2car_loop[i];
451}
452
453static int get_cur_symbol_rate(struct stv *state, u32 *p_symbol_rate)
454{
455 int status = 0;
456 u8 symb_freq0;
457 u8 symb_freq1;
458 u8 symb_freq2;
459 u8 symb_freq3;
460 u8 tim_offs0;
461 u8 tim_offs1;
462 u8 tim_offs2;
463 u32 symbol_rate;
464 s32 timing_offset;
465
466 *p_symbol_rate = 0;
467 if (!state->started)
468 return status;
469
470 read_reg(state, RSTV0910_P2_SFR3 + state->regoff, &symb_freq3);
471 read_reg(state, RSTV0910_P2_SFR2 + state->regoff, &symb_freq2);
472 read_reg(state, RSTV0910_P2_SFR1 + state->regoff, &symb_freq1);
473 read_reg(state, RSTV0910_P2_SFR0 + state->regoff, &symb_freq0);
474 read_reg(state, RSTV0910_P2_TMGREG2 + state->regoff, &tim_offs2);
475 read_reg(state, RSTV0910_P2_TMGREG1 + state->regoff, &tim_offs1);
476 read_reg(state, RSTV0910_P2_TMGREG0 + state->regoff, &tim_offs0);
477
478 symbol_rate = ((u32)symb_freq3 << 24) | ((u32)symb_freq2 << 16) |
479 ((u32)symb_freq1 << 8) | (u32)symb_freq0;
480 timing_offset = ((u32)tim_offs2 << 16) | ((u32)tim_offs1 << 8) |
481 (u32)tim_offs0;
482
483 if ((timing_offset & (1 << 23)) != 0)
484 timing_offset |= 0xFF000000; /* Sign extent */
485
486 symbol_rate = (u32)(((u64)symbol_rate * state->base->mclk) >> 32);
487 timing_offset = (s32)(((s64)symbol_rate * (s64)timing_offset) >> 29);
488
489 *p_symbol_rate = symbol_rate + timing_offset;
490
491 return 0;
492}
493
494static int get_signal_parameters(struct stv *state)
495{
496 u8 tmp;
497
498 if (!state->started)
499 return -EINVAL;
500
501 if (state->receive_mode == RCVMODE_DVBS2) {
502 read_reg(state, RSTV0910_P2_DMDMODCOD + state->regoff, &tmp);
503 state->mod_cod = (enum fe_stv0910_mod_cod)((tmp & 0x7c) >> 2);
504 state->pilots = (tmp & 0x01) != 0;
505 state->fectype = (enum dvbs2_fectype)((tmp & 0x02) >> 1);
506
507 } else if (state->receive_mode == RCVMODE_DVBS) {
508 read_reg(state, RSTV0910_P2_VITCURPUN + state->regoff, &tmp);
509 state->puncture_rate = FEC_NONE;
510 switch (tmp & 0x1F) {
511 case 0x0d:
512 state->puncture_rate = FEC_1_2;
513 break;
514 case 0x12:
515 state->puncture_rate = FEC_2_3;
516 break;
517 case 0x15:
518 state->puncture_rate = FEC_3_4;
519 break;
520 case 0x18:
521 state->puncture_rate = FEC_5_6;
522 break;
523 case 0x1a:
524 state->puncture_rate = FEC_7_8;
525 break;
526 }
527 state->is_vcm = 0;
528 state->is_standard_broadcast = 1;
529 state->feroll_off = FE_SAT_35;
530 }
531 return 0;
532}
533
534static int tracking_optimization(struct stv *state)
535{
536 u32 symbol_rate = 0;
537 u8 tmp;
538
539 get_cur_symbol_rate(state, &symbol_rate);
540 read_reg(state, RSTV0910_P2_DMDCFGMD + state->regoff, &tmp);
541 tmp &= ~0xC0;
542
543 switch (state->receive_mode) {
544 case RCVMODE_DVBS:
545 tmp |= 0x40;
546 break;
547 case RCVMODE_DVBS2:
548 tmp |= 0x80;
549 break;
550 default:
551 tmp |= 0xC0;
552 break;
553 }
554 write_reg(state, RSTV0910_P2_DMDCFGMD + state->regoff, tmp);
555
556 if (state->receive_mode == RCVMODE_DVBS2) {
557 /* Disable Reed-Solomon */
558 write_shared_reg(state,
559 RSTV0910_TSTTSRS, state->nr ? 0x02 : 0x01,
560 0x03);
561
562 if (state->fectype == DVBS2_64K) {
563 u8 aclc = get_optim_cloop(state, state->mod_cod,
564 state->pilots);
565
566 if (state->mod_cod <= FE_QPSK_910) {
567 write_reg(state, RSTV0910_P2_ACLC2S2Q +
568 state->regoff, aclc);
569 } else if (state->mod_cod <= FE_8PSK_910) {
570 write_reg(state, RSTV0910_P2_ACLC2S2Q +
571 state->regoff, 0x2a);
572 write_reg(state, RSTV0910_P2_ACLC2S28 +
573 state->regoff, aclc);
574 } else if (state->mod_cod <= FE_16APSK_910) {
575 write_reg(state, RSTV0910_P2_ACLC2S2Q +
576 state->regoff, 0x2a);
577 write_reg(state, RSTV0910_P2_ACLC2S216A +
578 state->regoff, aclc);
579 } else if (state->mod_cod <= FE_32APSK_910) {
580 write_reg(state, RSTV0910_P2_ACLC2S2Q +
581 state->regoff, 0x2a);
582 write_reg(state, RSTV0910_P2_ACLC2S232A +
583 state->regoff, aclc);
584 }
585 }
586 }
587 return 0;
588}
589
590static s32 table_lookup(const struct slookup *table,
591 int table_size, u32 reg_value)
592{
593 s32 value;
594 int imin = 0;
595 int imax = table_size - 1;
596 int i;
597 s32 reg_diff;
598
599 /* Assumes Table[0].RegValue > Table[imax].RegValue */
600 if (reg_value >= table[0].reg_value) {
601 value = table[0].value;
602 } else if (reg_value <= table[imax].reg_value) {
603 value = table[imax].value;
604 } else {
605 while ((imax - imin) > 1) {
606 i = (imax + imin) / 2;
607 if ((table[imin].reg_value >= reg_value) &&
608 (reg_value >= table[i].reg_value))
609 imax = i;
610 else
611 imin = i;
612 }
613
614 reg_diff = table[imax].reg_value - table[imin].reg_value;
615 value = table[imin].value;
616 if (reg_diff != 0)
617 value += ((s32)(reg_value - table[imin].reg_value) *
618 (s32)(table[imax].value
619 - table[imin].value))
620 / (reg_diff);
621 }
622
623 return value;
624}
625
626static int get_signal_to_noise(struct stv *state, s32 *signal_to_noise)
627{
628 u8 data0;
629 u8 data1;
630 u16 data;
631 int n_lookup;
632 const struct slookup *lookup;
633
634 *signal_to_noise = 0;
635
636 if (!state->started)
637 return -EINVAL;
638
639 if (state->receive_mode == RCVMODE_DVBS2) {
640 read_reg(state, RSTV0910_P2_NNOSPLHT1 + state->regoff,
641 &data1);
642 read_reg(state, RSTV0910_P2_NNOSPLHT0 + state->regoff,
643 &data0);
644 n_lookup = ARRAY_SIZE(s2_sn_lookup);
645 lookup = s2_sn_lookup;
646 } else {
647 read_reg(state, RSTV0910_P2_NNOSDATAT1 + state->regoff,
648 &data1);
649 read_reg(state, RSTV0910_P2_NNOSDATAT0 + state->regoff,
650 &data0);
651 n_lookup = ARRAY_SIZE(s1_sn_lookup);
652 lookup = s1_sn_lookup;
653 }
654 data = (((u16)data1) << 8) | (u16)data0;
655 *signal_to_noise = table_lookup(lookup, n_lookup, data);
656 return 0;
657}
658
659static int get_bit_error_rate_s(struct stv *state, u32 *bernumerator,
660 u32 *berdenominator)
661{
662 u8 regs[3];
663
664 int status = read_regs(state,
665 RSTV0910_P2_ERRCNT12 + state->regoff,
666 regs, 3);
667
668 if (status)
669 return -EINVAL;
670
671 if ((regs[0] & 0x80) == 0) {
672 state->last_berdenominator = 1 << ((state->berscale * 2) +
673 10 + 3);
674 state->last_bernumerator = ((u32)(regs[0] & 0x7F) << 16) |
675 ((u32)regs[1] << 8) | regs[2];
676 if (state->last_bernumerator < 256 && state->berscale < 6) {
677 state->berscale += 1;
678 status = write_reg(state, RSTV0910_P2_ERRCTRL1 +
679 state->regoff,
680 0x20 | state->berscale);
681 } else if (state->last_bernumerator > 1024 &&
682 state->berscale > 2) {
683 state->berscale -= 1;
684 status = write_reg(state, RSTV0910_P2_ERRCTRL1 +
685 state->regoff, 0x20 |
686 state->berscale);
687 }
688 }
689 *bernumerator = state->last_bernumerator;
690 *berdenominator = state->last_berdenominator;
691 return 0;
692}
693
694static u32 dvbs2_nbch(enum dvbs2_mod_cod mod_cod, enum dvbs2_fectype fectype)
695{
696 static const u32 nbch[][2] = {
697 { 0, 0}, /* DUMMY_PLF */
698 {16200, 3240}, /* QPSK_1_4, */
699 {21600, 5400}, /* QPSK_1_3, */
700 {25920, 6480}, /* QPSK_2_5, */
701 {32400, 7200}, /* QPSK_1_2, */
702 {38880, 9720}, /* QPSK_3_5, */
703 {43200, 10800}, /* QPSK_2_3, */
704 {48600, 11880}, /* QPSK_3_4, */
705 {51840, 12600}, /* QPSK_4_5, */
706 {54000, 13320}, /* QPSK_5_6, */
707 {57600, 14400}, /* QPSK_8_9, */
708 {58320, 16000}, /* QPSK_9_10, */
709 {43200, 9720}, /* 8PSK_3_5, */
710 {48600, 10800}, /* 8PSK_2_3, */
711 {51840, 11880}, /* 8PSK_3_4, */
712 {54000, 13320}, /* 8PSK_5_6, */
713 {57600, 14400}, /* 8PSK_8_9, */
714 {58320, 16000}, /* 8PSK_9_10, */
715 {43200, 10800}, /* 16APSK_2_3, */
716 {48600, 11880}, /* 16APSK_3_4, */
717 {51840, 12600}, /* 16APSK_4_5, */
718 {54000, 13320}, /* 16APSK_5_6, */
719 {57600, 14400}, /* 16APSK_8_9, */
720 {58320, 16000}, /* 16APSK_9_10 */
721 {48600, 11880}, /* 32APSK_3_4, */
722 {51840, 12600}, /* 32APSK_4_5, */
723 {54000, 13320}, /* 32APSK_5_6, */
724 {57600, 14400}, /* 32APSK_8_9, */
725 {58320, 16000}, /* 32APSK_9_10 */
726 };
727
728 if (mod_cod >= DVBS2_QPSK_1_4 &&
729 mod_cod <= DVBS2_32APSK_9_10 && fectype <= DVBS2_16K)
730 return nbch[mod_cod][fectype];
731 return 64800;
732}
733
734static int get_bit_error_rate_s2(struct stv *state, u32 *bernumerator,
735 u32 *berdenominator)
736{
737 u8 regs[3];
738
739 int status = read_regs(state, RSTV0910_P2_ERRCNT12 + state->regoff,
740 regs, 3);
741
742 if (status)
743 return -EINVAL;
744
745 if ((regs[0] & 0x80) == 0) {
746 state->last_berdenominator =
747 dvbs2_nbch((enum dvbs2_mod_cod)state->mod_cod,
748 state->fectype) <<
749 (state->berscale * 2);
750 state->last_bernumerator = (((u32)regs[0] & 0x7F) << 16) |
751 ((u32)regs[1] << 8) | regs[2];
752 if (state->last_bernumerator < 256 && state->berscale < 6) {
753 state->berscale += 1;
754 write_reg(state, RSTV0910_P2_ERRCTRL1 + state->regoff,
755 0x20 | state->berscale);
756 } else if (state->last_bernumerator > 1024 &&
757 state->berscale > 2) {
758 state->berscale -= 1;
759 write_reg(state, RSTV0910_P2_ERRCTRL1 + state->regoff,
760 0x20 | state->berscale);
761 }
762 }
763 *bernumerator = state->last_bernumerator;
764 *berdenominator = state->last_berdenominator;
765 return status;
766}
767
768static int get_bit_error_rate(struct stv *state, u32 *bernumerator,
769 u32 *berdenominator)
770{
771 *bernumerator = 0;
772 *berdenominator = 1;
773
774 switch (state->receive_mode) {
775 case RCVMODE_DVBS:
776 return get_bit_error_rate_s(state,
777 bernumerator, berdenominator);
778 case RCVMODE_DVBS2:
779 return get_bit_error_rate_s2(state,
780 bernumerator, berdenominator);
781 default:
782 break;
783 }
784 return 0;
785}
786
787static int set_mclock(struct stv *state, u32 master_clock)
788{
789 u32 idf = 1;
790 u32 odf = 4;
791 u32 quartz = state->base->extclk / 1000000;
792 u32 fphi = master_clock / 1000000;
793 u32 ndiv = (fphi * odf * idf) / quartz;
794 u32 cp = 7;
795 u32 fvco;
796
797 if (ndiv >= 7 && ndiv <= 71)
798 cp = 7;
799 else if (ndiv >= 72 && ndiv <= 79)
800 cp = 8;
801 else if (ndiv >= 80 && ndiv <= 87)
802 cp = 9;
803 else if (ndiv >= 88 && ndiv <= 95)
804 cp = 10;
805 else if (ndiv >= 96 && ndiv <= 103)
806 cp = 11;
807 else if (ndiv >= 104 && ndiv <= 111)
808 cp = 12;
809 else if (ndiv >= 112 && ndiv <= 119)
810 cp = 13;
811 else if (ndiv >= 120 && ndiv <= 127)
812 cp = 14;
813 else if (ndiv >= 128 && ndiv <= 135)
814 cp = 15;
815 else if (ndiv >= 136 && ndiv <= 143)
816 cp = 16;
817 else if (ndiv >= 144 && ndiv <= 151)
818 cp = 17;
819 else if (ndiv >= 152 && ndiv <= 159)
820 cp = 18;
821 else if (ndiv >= 160 && ndiv <= 167)
822 cp = 19;
823 else if (ndiv >= 168 && ndiv <= 175)
824 cp = 20;
825 else if (ndiv >= 176 && ndiv <= 183)
826 cp = 21;
827 else if (ndiv >= 184 && ndiv <= 191)
828 cp = 22;
829 else if (ndiv >= 192 && ndiv <= 199)
830 cp = 23;
831 else if (ndiv >= 200 && ndiv <= 207)
832 cp = 24;
833 else if (ndiv >= 208 && ndiv <= 215)
834 cp = 25;
835 else if (ndiv >= 216 && ndiv <= 223)
836 cp = 26;
837 else if (ndiv >= 224 && ndiv <= 225)
838 cp = 27;
839
840 write_reg(state, RSTV0910_NCOARSE, (cp << 3) | idf);
841 write_reg(state, RSTV0910_NCOARSE2, odf);
842 write_reg(state, RSTV0910_NCOARSE1, ndiv);
843
844 fvco = (quartz * 2 * ndiv) / idf;
845 state->base->mclk = fvco / (2 * odf) * 1000000;
846
847 return 0;
848}
849
850static int stop(struct stv *state)
851{
852 if (state->started) {
853 u8 tmp;
854
855 write_reg(state, RSTV0910_P2_TSCFGH + state->regoff,
856 state->tscfgh | 0x01);
857 read_reg(state, RSTV0910_P2_PDELCTRL1 + state->regoff, &tmp);
858 tmp &= ~0x01; /* release reset DVBS2 packet delin */
859 write_reg(state, RSTV0910_P2_PDELCTRL1 + state->regoff, tmp);
860 /* Blind optim*/
861 write_reg(state, RSTV0910_P2_AGC2O + state->regoff, 0x5B);
862 /* Stop the demod */
863 write_reg(state, RSTV0910_P2_DMDISTATE + state->regoff, 0x5c);
864 state->started = 0;
865 }
866 state->receive_mode = RCVMODE_NONE;
867 return 0;
868}
869
870static int init_search_param(struct stv *state)
871{
872 u8 tmp;
873
874 read_reg(state, RSTV0910_P2_PDELCTRL1 + state->regoff, &tmp);
875 tmp |= 0x20; /* Filter_en (no effect if SIS=non-MIS */
876 write_reg(state, RSTV0910_P2_PDELCTRL1 + state->regoff, tmp);
877
878 read_reg(state, RSTV0910_P2_PDELCTRL2 + state->regoff, &tmp);
879 tmp &= ~0x02; /* frame mode = 0 */
880 write_reg(state, RSTV0910_P2_PDELCTRL2 + state->regoff, tmp);
881
882 write_reg(state, RSTV0910_P2_UPLCCST0 + state->regoff, 0xe0);
883 write_reg(state, RSTV0910_P2_ISIBITENA + state->regoff, 0x00);
884
885 read_reg(state, RSTV0910_P2_TSSTATEM + state->regoff, &tmp);
886 tmp &= ~0x01; /* nosync = 0, in case next signal is standard TS */
887 write_reg(state, RSTV0910_P2_TSSTATEM + state->regoff, tmp);
888
889 read_reg(state, RSTV0910_P2_TSCFGL + state->regoff, &tmp);
890 tmp &= ~0x04; /* embindvb = 0 */
891 write_reg(state, RSTV0910_P2_TSCFGL + state->regoff, tmp);
892
893 read_reg(state, RSTV0910_P2_TSINSDELH + state->regoff, &tmp);
894 tmp &= ~0x80; /* syncbyte = 0 */
895 write_reg(state, RSTV0910_P2_TSINSDELH + state->regoff, tmp);
896
897 read_reg(state, RSTV0910_P2_TSINSDELM + state->regoff, &tmp);
898 tmp &= ~0x08; /* token = 0 */
899 write_reg(state, RSTV0910_P2_TSINSDELM + state->regoff, tmp);
900
901 read_reg(state, RSTV0910_P2_TSDLYSET2 + state->regoff, &tmp);
902 tmp &= ~0x30; /* hysteresis threshold = 0 */
903 write_reg(state, RSTV0910_P2_TSDLYSET2 + state->regoff, tmp);
904
905 read_reg(state, RSTV0910_P2_PDELCTRL0 + state->regoff, &tmp);
906 tmp = (tmp & ~0x30) | 0x10; /* isi obs mode = 1, observe min ISI */
907 write_reg(state, RSTV0910_P2_PDELCTRL0 + state->regoff, tmp);
908
909 return 0;
910}
911
912static int enable_puncture_rate(struct stv *state, enum fe_code_rate rate)
913{
914 switch (rate) {
915 case FEC_1_2:
916 return write_reg(state,
917 RSTV0910_P2_PRVIT + state->regoff, 0x01);
918 case FEC_2_3:
919 return write_reg(state,
920 RSTV0910_P2_PRVIT + state->regoff, 0x02);
921 case FEC_3_4:
922 return write_reg(state,
923 RSTV0910_P2_PRVIT + state->regoff, 0x04);
924 case FEC_5_6:
925 return write_reg(state,
926 RSTV0910_P2_PRVIT + state->regoff, 0x08);
927 case FEC_7_8:
928 return write_reg(state,
929 RSTV0910_P2_PRVIT + state->regoff, 0x20);
930 case FEC_NONE:
931 default:
932 return write_reg(state,
933 RSTV0910_P2_PRVIT + state->regoff, 0x2f);
934 }
935}
936
937static int set_vth_default(struct stv *state)
938{
939 state->vth[0] = 0xd7;
940 state->vth[1] = 0x85;
941 state->vth[2] = 0x58;
942 state->vth[3] = 0x3a;
943 state->vth[4] = 0x34;
944 state->vth[5] = 0x28;
945 write_reg(state, RSTV0910_P2_VTH12 + state->regoff + 0, state->vth[0]);
946 write_reg(state, RSTV0910_P2_VTH12 + state->regoff + 1, state->vth[1]);
947 write_reg(state, RSTV0910_P2_VTH12 + state->regoff + 2, state->vth[2]);
948 write_reg(state, RSTV0910_P2_VTH12 + state->regoff + 3, state->vth[3]);
949 write_reg(state, RSTV0910_P2_VTH12 + state->regoff + 4, state->vth[4]);
950 write_reg(state, RSTV0910_P2_VTH12 + state->regoff + 5, state->vth[5]);
951 return 0;
952}
953
954static int set_vth(struct stv *state)
955{
956 static const struct slookup vthlookup_table[] = {
957 {250, 8780}, /* C/N= 1.5dB */
958 {100, 7405}, /* C/N= 4.5dB */
959 {40, 6330}, /* C/N= 6.5dB */
960 {12, 5224}, /* C/N= 8.5dB */
961 {5, 4236} /* C/N=10.5dB */
962 };
963
964 int i;
965 u8 tmp[2];
966 int status = read_regs(state,
967 RSTV0910_P2_NNOSDATAT1 + state->regoff,
968 tmp, 2);
969 u16 reg_value = (tmp[0] << 8) | tmp[1];
970 s32 vth = table_lookup(vthlookup_table, ARRAY_SIZE(vthlookup_table),
971 reg_value);
972
973 for (i = 0; i < 6; i += 1)
974 if (state->vth[i] > vth)
975 state->vth[i] = vth;
976
977 write_reg(state, RSTV0910_P2_VTH12 + state->regoff + 0, state->vth[0]);
978 write_reg(state, RSTV0910_P2_VTH12 + state->regoff + 1, state->vth[1]);
979 write_reg(state, RSTV0910_P2_VTH12 + state->regoff + 2, state->vth[2]);
980 write_reg(state, RSTV0910_P2_VTH12 + state->regoff + 3, state->vth[3]);
981 write_reg(state, RSTV0910_P2_VTH12 + state->regoff + 4, state->vth[4]);
982 write_reg(state, RSTV0910_P2_VTH12 + state->regoff + 5, state->vth[5]);
983 return status;
984}
985
986static int start(struct stv *state, struct dtv_frontend_properties *p)
987{
988 s32 freq;
989 u8 reg_dmdcfgmd;
990 u16 symb;
991 u32 scrambling_code = 1;
992
993 if (p->symbol_rate < 100000 || p->symbol_rate > 70000000)
994 return -EINVAL;
995
996 state->receive_mode = RCVMODE_NONE;
997 state->demod_lock_time = 0;
998
999 /* Demod Stop */
1000 if (state->started)
1001 write_reg(state, RSTV0910_P2_DMDISTATE + state->regoff, 0x5C);
1002
1003 init_search_param(state);
1004
1005 if (p->stream_id != NO_STREAM_ID_FILTER) {
1006 /*
1007 * Backwards compatibility to "crazy" API.
1008 * PRBS X root cannot be 0, so this should always work.
1009 */
1010 if (p->stream_id & 0xffffff00)
1011 scrambling_code = p->stream_id >> 8;
1012 write_reg(state, RSTV0910_P2_ISIENTRY + state->regoff,
1013 p->stream_id & 0xff);
1014 write_reg(state, RSTV0910_P2_ISIBITENA + state->regoff,
1015 0xff);
1016 }
1017
1018 if (scrambling_code != state->cur_scrambling_code) {
1019 write_reg(state, RSTV0910_P2_PLROOT0 + state->regoff,
1020 scrambling_code & 0xff);
1021 write_reg(state, RSTV0910_P2_PLROOT1 + state->regoff,
1022 (scrambling_code >> 8) & 0xff);
1023 write_reg(state, RSTV0910_P2_PLROOT2 + state->regoff,
1024 (scrambling_code >> 16) & 0x0f);
1025 state->cur_scrambling_code = scrambling_code;
1026 }
1027
1028 if (p->symbol_rate <= 1000000) { /* SR <=1Msps */
1029 state->demod_timeout = 3000;
1030 state->fec_timeout = 2000;
1031 } else if (p->symbol_rate <= 2000000) { /* 1Msps < SR <=2Msps */
1032 state->demod_timeout = 2500;
1033 state->fec_timeout = 1300;
1034 } else if (p->symbol_rate <= 5000000) { /* 2Msps< SR <=5Msps */
1035 state->demod_timeout = 1000;
1036 state->fec_timeout = 650;
1037 } else if (p->symbol_rate <= 10000000) { /* 5Msps< SR <=10Msps */
1038 state->demod_timeout = 700;
1039 state->fec_timeout = 350;
1040 } else if (p->symbol_rate < 20000000) { /* 10Msps< SR <=20Msps */
1041 state->demod_timeout = 400;
1042 state->fec_timeout = 200;
1043 } else { /* SR >=20Msps */
1044 state->demod_timeout = 300;
1045 state->fec_timeout = 200;
1046 }
1047
1048 /* Set the Init Symbol rate */
1049 symb = muldiv32(p->symbol_rate, 65536, state->base->mclk);
1050 write_reg(state, RSTV0910_P2_SFRINIT1 + state->regoff,
1051 ((symb >> 8) & 0x7F));
1052 write_reg(state, RSTV0910_P2_SFRINIT0 + state->regoff, (symb & 0xFF));
1053
1054 state->demod_bits |= 0x80;
1055 write_reg(state, RSTV0910_P2_DEMOD + state->regoff, state->demod_bits);
1056
1057 /* FE_STV0910_SetSearchStandard */
1058 read_reg(state, RSTV0910_P2_DMDCFGMD + state->regoff, &reg_dmdcfgmd);
1059 write_reg(state, RSTV0910_P2_DMDCFGMD + state->regoff,
1060 reg_dmdcfgmd |= 0xC0);
1061
1062 write_shared_reg(state,
1063 RSTV0910_TSTTSRS, state->nr ? 0x02 : 0x01, 0x00);
1064
1065 /* Disable DSS */
1066 write_reg(state, RSTV0910_P2_FECM + state->regoff, 0x00);
1067 write_reg(state, RSTV0910_P2_PRVIT + state->regoff, 0x2F);
1068
1069 enable_puncture_rate(state, FEC_NONE);
1070
1071 /* 8PSK 3/5, 8PSK 2/3 Poff tracking optimization WA */
1072 write_reg(state, RSTV0910_P2_ACLC2S2Q + state->regoff, 0x0B);
1073 write_reg(state, RSTV0910_P2_ACLC2S28 + state->regoff, 0x0A);
1074 write_reg(state, RSTV0910_P2_BCLC2S2Q + state->regoff, 0x84);
1075 write_reg(state, RSTV0910_P2_BCLC2S28 + state->regoff, 0x84);
1076 write_reg(state, RSTV0910_P2_CARHDR + state->regoff, 0x1C);
1077 write_reg(state, RSTV0910_P2_CARFREQ + state->regoff, 0x79);
1078
1079 write_reg(state, RSTV0910_P2_ACLC2S216A + state->regoff, 0x29);
1080 write_reg(state, RSTV0910_P2_ACLC2S232A + state->regoff, 0x09);
1081 write_reg(state, RSTV0910_P2_BCLC2S216A + state->regoff, 0x84);
1082 write_reg(state, RSTV0910_P2_BCLC2S232A + state->regoff, 0x84);
1083
1084 /*
1085 * Reset CAR3, bug DVBS2->DVBS1 lock
1086 * Note: The bit is only pulsed -> no lock on shared register needed
1087 */
1088 write_reg(state, RSTV0910_TSTRES0, state->nr ? 0x04 : 0x08);
1089 write_reg(state, RSTV0910_TSTRES0, 0);
1090
1091 set_vth_default(state);
1092 /* Reset demod */
1093 write_reg(state, RSTV0910_P2_DMDISTATE + state->regoff, 0x1F);
1094
1095 write_reg(state, RSTV0910_P2_CARCFG + state->regoff, 0x46);
1096
1097 if (p->symbol_rate <= 5000000)
1098 freq = (state->search_range / 2000) + 80;
1099 else
1100 freq = (state->search_range / 2000) + 1600;
1101 freq = (freq << 16) / (state->base->mclk / 1000);
1102
1103 write_reg(state, RSTV0910_P2_CFRUP1 + state->regoff,
1104 (freq >> 8) & 0xff);
1105 write_reg(state, RSTV0910_P2_CFRUP0 + state->regoff, (freq & 0xff));
1106 /* CFR Low Setting */
1107 freq = -freq;
1108 write_reg(state, RSTV0910_P2_CFRLOW1 + state->regoff,
1109 (freq >> 8) & 0xff);
1110 write_reg(state, RSTV0910_P2_CFRLOW0 + state->regoff, (freq & 0xff));
1111
1112 /* init the demod frequency offset to 0 */
1113 write_reg(state, RSTV0910_P2_CFRINIT1 + state->regoff, 0);
1114 write_reg(state, RSTV0910_P2_CFRINIT0 + state->regoff, 0);
1115
1116 write_reg(state, RSTV0910_P2_DMDISTATE + state->regoff, 0x1F);
1117 /* Trigger acq */
1118 write_reg(state, RSTV0910_P2_DMDISTATE + state->regoff, 0x15);
1119
1120 state->demod_lock_time += TUNING_DELAY;
1121 state->started = 1;
1122
1123 return 0;
1124}
1125
1126static int init_diseqc(struct stv *state)
1127{
1128 u16 offs = state->nr ? 0x40 : 0; /* Address offset */
1129 u8 freq = ((state->base->mclk + 11000 * 32) / (22000 * 32));
1130
1131 /* Disable receiver */
1132 write_reg(state, RSTV0910_P1_DISRXCFG + offs, 0x00);
1133 write_reg(state, RSTV0910_P1_DISTXCFG + offs, 0xBA); /* Reset = 1 */
1134 write_reg(state, RSTV0910_P1_DISTXCFG + offs, 0x3A); /* Reset = 0 */
1135 write_reg(state, RSTV0910_P1_DISTXF22 + offs, freq);
1136 return 0;
1137}
1138
1139static int probe(struct stv *state)
1140{
1141 u8 id;
1142
1143 state->receive_mode = RCVMODE_NONE;
1144 state->started = 0;
1145
1146 if (read_reg(state, RSTV0910_MID, &id) < 0)
1147 return -ENODEV;
1148
1149 if (id != 0x51)
1150 return -EINVAL;
1151
1152 /* Configure the I2C repeater to off */
1153 write_reg(state, RSTV0910_P1_I2CRPT, 0x24);
1154 /* Configure the I2C repeater to off */
1155 write_reg(state, RSTV0910_P2_I2CRPT, 0x24);
1156 /* Set the I2C to oversampling ratio */
1157 write_reg(state, RSTV0910_I2CCFG, 0x88); /* state->i2ccfg */
1158
1159 write_reg(state, RSTV0910_OUTCFG, 0x00); /* OUTCFG */
1160 write_reg(state, RSTV0910_PADCFG, 0x05); /* RFAGC Pads Dev = 05 */
1161 write_reg(state, RSTV0910_SYNTCTRL, 0x02); /* SYNTCTRL */
1162 write_reg(state, RSTV0910_TSGENERAL, state->tsgeneral); /* TSGENERAL */
1163 write_reg(state, RSTV0910_CFGEXT, 0x02); /* CFGEXT */
1164
1165 if (state->single)
1166 write_reg(state, RSTV0910_GENCFG, 0x14); /* GENCFG */
1167 else
1168 write_reg(state, RSTV0910_GENCFG, 0x15); /* GENCFG */
1169
1170 write_reg(state, RSTV0910_P1_TNRCFG2, 0x02); /* IQSWAP = 0 */
1171 write_reg(state, RSTV0910_P2_TNRCFG2, 0x82); /* IQSWAP = 1 */
1172
1173 write_reg(state, RSTV0910_P1_CAR3CFG, 0x02);
1174 write_reg(state, RSTV0910_P2_CAR3CFG, 0x02);
1175 write_reg(state, RSTV0910_P1_DMDCFG4, 0x04);
1176 write_reg(state, RSTV0910_P2_DMDCFG4, 0x04);
1177
1178 write_reg(state, RSTV0910_TSTRES0, 0x80); /* LDPC Reset */
1179 write_reg(state, RSTV0910_TSTRES0, 0x00);
1180
1181 write_reg(state, RSTV0910_P1_TSPIDFLT1, 0x00);
1182 write_reg(state, RSTV0910_P2_TSPIDFLT1, 0x00);
1183
1184 write_reg(state, RSTV0910_P1_TMGCFG2, 0x80);
1185 write_reg(state, RSTV0910_P2_TMGCFG2, 0x80);
1186
1187 set_mclock(state, 135000000);
1188
1189 /* TS output */
1190 write_reg(state, RSTV0910_P1_TSCFGH, state->tscfgh | 0x01);
1191 write_reg(state, RSTV0910_P1_TSCFGH, state->tscfgh);
1192 write_reg(state, RSTV0910_P1_TSCFGM, 0xC0); /* Manual speed */
1193 write_reg(state, RSTV0910_P1_TSCFGL, 0x20);
1194
1195 /* Speed = 67.5 MHz */
1196 write_reg(state, RSTV0910_P1_TSSPEED, state->tsspeed);
1197
1198 write_reg(state, RSTV0910_P2_TSCFGH, state->tscfgh | 0x01);
1199 write_reg(state, RSTV0910_P2_TSCFGH, state->tscfgh);
1200 write_reg(state, RSTV0910_P2_TSCFGM, 0xC0); /* Manual speed */
1201 write_reg(state, RSTV0910_P2_TSCFGL, 0x20);
1202
1203 /* Speed = 67.5 MHz */
1204 write_reg(state, RSTV0910_P2_TSSPEED, state->tsspeed);
1205
1206 /* Reset stream merger */
1207 write_reg(state, RSTV0910_P1_TSCFGH, state->tscfgh | 0x01);
1208 write_reg(state, RSTV0910_P2_TSCFGH, state->tscfgh | 0x01);
1209 write_reg(state, RSTV0910_P1_TSCFGH, state->tscfgh);
1210 write_reg(state, RSTV0910_P2_TSCFGH, state->tscfgh);
1211
1212 write_reg(state, RSTV0910_P1_I2CRPT, state->i2crpt);
1213 write_reg(state, RSTV0910_P2_I2CRPT, state->i2crpt);
1214
1215 init_diseqc(state);
1216 return 0;
1217}
1218
1219static int gate_ctrl(struct dvb_frontend *fe, int enable)
1220{
1221 struct stv *state = fe->demodulator_priv;
1222 u8 i2crpt = state->i2crpt & ~0x86;
1223
1224 /*
1225 * mutex_lock note: Concurrent I2C gate bus accesses must be
1226 * prevented (STV0910 = dual demod on a single IC with a single I2C
1227 * gate/bus, and two tuners attached), similar to most (if not all)
1228 * other I2C host interfaces/busses.
1229 *
1230 * enable=1 (open I2C gate) will grab the lock
1231 * enable=0 (close I2C gate) releases the lock
1232 */
1233
1234 if (enable) {
1235 mutex_lock(&state->base->i2c_lock);
1236 i2crpt |= 0x80;
1237 } else {
1238 i2crpt |= 0x02;
1239 }
1240
1241 if (write_reg(state, state->nr ? RSTV0910_P2_I2CRPT :
1242 RSTV0910_P1_I2CRPT, i2crpt) < 0) {
1243 /* don't hold the I2C bus lock on failure */
1244 mutex_unlock(&state->base->i2c_lock);
1245 dev_err(&state->base->i2c->dev,
1246 "%s() write_reg failure (enable=%d)\n",
1247 __func__, enable);
1248 return -EIO;
1249 }
1250
1251 state->i2crpt = i2crpt;
1252
1253 if (!enable)
1254 mutex_unlock(&state->base->i2c_lock);
1255 return 0;
1256}
1257
1258static void release(struct dvb_frontend *fe)
1259{
1260 struct stv *state = fe->demodulator_priv;
1261
1262 state->base->count--;
1263 if (state->base->count == 0) {
1264 list_del(&state->base->stvlist);
1265 kfree(state->base);
1266 }
1267 kfree(state);
1268}
1269
1270static int set_parameters(struct dvb_frontend *fe)
1271{
1272 int stat = 0;
1273 struct stv *state = fe->demodulator_priv;
1274 u32 iffreq;
1275 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1276
1277 stop(state);
1278 if (fe->ops.tuner_ops.set_params)
1279 fe->ops.tuner_ops.set_params(fe);
1280 if (fe->ops.tuner_ops.get_if_frequency)
1281 fe->ops.tuner_ops.get_if_frequency(fe, &iffreq);
1282 state->symbol_rate = p->symbol_rate;
1283 stat = start(state, p);
1284 return stat;
1285}
1286
1287static int manage_matype_info(struct stv *state)
1288{
1289 if (!state->started)
1290 return -EINVAL;
1291 if (state->receive_mode == RCVMODE_DVBS2) {
1292 u8 bbheader[2];
1293
1294 read_regs(state, RSTV0910_P2_MATSTR1 + state->regoff,
1295 bbheader, 2);
1296 state->feroll_off =
1297 (enum fe_stv0910_roll_off)(bbheader[0] & 0x03);
1298 state->is_vcm = (bbheader[0] & 0x10) == 0;
1299 state->is_standard_broadcast = (bbheader[0] & 0xFC) == 0xF0;
1300 } else if (state->receive_mode == RCVMODE_DVBS) {
1301 state->is_vcm = 0;
1302 state->is_standard_broadcast = 1;
1303 state->feroll_off = FE_SAT_35;
1304 }
1305 return 0;
1306}
1307
1308static int read_snr(struct dvb_frontend *fe)
1309{
1310 struct stv *state = fe->demodulator_priv;
1311 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1312 s32 snrval;
1313
1314 if (!get_signal_to_noise(state, &snrval)) {
1315 p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
1316 p->cnr.stat[0].uvalue = 100 * snrval; /* fix scale */
1317 } else {
1318 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1319 }
1320
1321 return 0;
1322}
1323
1324static int read_ber(struct dvb_frontend *fe)
1325{
1326 struct stv *state = fe->demodulator_priv;
1327 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1328 u32 n, d;
1329
1330 get_bit_error_rate(state, &n, &d);
1331
1332 p->pre_bit_error.stat[0].scale = FE_SCALE_COUNTER;
1333 p->pre_bit_error.stat[0].uvalue = n;
1334 p->pre_bit_count.stat[0].scale = FE_SCALE_COUNTER;
1335 p->pre_bit_count.stat[0].uvalue = d;
1336
1337 return 0;
1338}
1339
1340static void read_signal_strength(struct dvb_frontend *fe)
1341{
1342 struct stv *state = fe->demodulator_priv;
1343 struct dtv_frontend_properties *p = &state->fe.dtv_property_cache;
1344 u8 reg[2];
1345 u16 agc;
1346 s32 padc, power = 0;
1347 int i;
1348
1349 read_regs(state, RSTV0910_P2_AGCIQIN1 + state->regoff, reg, 2);
1350
1351 agc = (((u32)reg[0]) << 8) | reg[1];
1352
1353 for (i = 0; i < 5; i += 1) {
1354 read_regs(state, RSTV0910_P2_POWERI + state->regoff, reg, 2);
1355 power += (u32)reg[0] * (u32)reg[0]
1356 + (u32)reg[1] * (u32)reg[1];
1357 usleep_range(3000, 4000);
1358 }
1359 power /= 5;
1360
1361 padc = table_lookup(padc_lookup, ARRAY_SIZE(padc_lookup), power) + 352;
1362
1363 p->strength.stat[0].scale = FE_SCALE_DECIBEL;
1364 p->strength.stat[0].svalue = (padc - agc);
1365}
1366
1367static int read_status(struct dvb_frontend *fe, enum fe_status *status)
1368{
1369 struct stv *state = fe->demodulator_priv;
1370 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1371 u8 dmd_state = 0;
1372 u8 dstatus = 0;
1373 enum receive_mode cur_receive_mode = RCVMODE_NONE;
1374 u32 feclock = 0;
1375
1376 *status = 0;
1377
1378 read_reg(state, RSTV0910_P2_DMDSTATE + state->regoff, &dmd_state);
1379
1380 if (dmd_state & 0x40) {
1381 read_reg(state, RSTV0910_P2_DSTATUS + state->regoff, &dstatus);
1382 if (dstatus & 0x08)
1383 cur_receive_mode = (dmd_state & 0x20) ?
1384 RCVMODE_DVBS : RCVMODE_DVBS2;
1385 }
1386 if (cur_receive_mode == RCVMODE_NONE) {
1387 set_vth(state);
1388
1389 /* reset signal statistics */
1390 p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1391 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1392 p->pre_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1393 p->pre_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1394
1395 return 0;
1396 }
1397
1398 *status |= (FE_HAS_SIGNAL
1399 | FE_HAS_CARRIER
1400 | FE_HAS_VITERBI
1401 | FE_HAS_SYNC);
1402
1403 if (state->receive_mode == RCVMODE_NONE) {
1404 state->receive_mode = cur_receive_mode;
1405 state->demod_lock_time = jiffies;
1406 state->first_time_lock = 1;
1407
1408 get_signal_parameters(state);
1409 tracking_optimization(state);
1410
1411 write_reg(state, RSTV0910_P2_TSCFGH + state->regoff,
1412 state->tscfgh);
1413 usleep_range(3000, 4000);
1414 write_reg(state, RSTV0910_P2_TSCFGH + state->regoff,
1415 state->tscfgh | 0x01);
1416 write_reg(state, RSTV0910_P2_TSCFGH + state->regoff,
1417 state->tscfgh);
1418 }
1419 if (dmd_state & 0x40) {
1420 if (state->receive_mode == RCVMODE_DVBS2) {
1421 u8 pdelstatus;
1422
1423 read_reg(state,
1424 RSTV0910_P2_PDELSTATUS1 + state->regoff,
1425 &pdelstatus);
1426 feclock = (pdelstatus & 0x02) != 0;
1427 } else {
1428 u8 vstatus;
1429
1430 read_reg(state,
1431 RSTV0910_P2_VSTATUSVIT + state->regoff,
1432 &vstatus);
1433 feclock = (vstatus & 0x08) != 0;
1434 }
1435 }
1436
1437 if (feclock) {
1438 *status |= FE_HAS_LOCK;
1439
1440 if (state->first_time_lock) {
1441 u8 tmp;
1442
1443 state->first_time_lock = 0;
1444
1445 manage_matype_info(state);
1446
1447 if (state->receive_mode == RCVMODE_DVBS2) {
1448 /*
1449 * FSTV0910_P2_MANUALSX_ROLLOFF,
1450 * FSTV0910_P2_MANUALS2_ROLLOFF = 0
1451 */
1452 state->demod_bits &= ~0x84;
1453 write_reg(state,
1454 RSTV0910_P2_DEMOD + state->regoff,
1455 state->demod_bits);
1456 read_reg(state,
1457 RSTV0910_P2_PDELCTRL2 + state->regoff,
1458 &tmp);
1459 /* reset DVBS2 packet delinator error counter */
1460 tmp |= 0x40;
1461 write_reg(state,
1462 RSTV0910_P2_PDELCTRL2 + state->regoff,
1463 tmp);
1464 /* reset DVBS2 packet delinator error counter */
1465 tmp &= ~0x40;
1466 write_reg(state,
1467 RSTV0910_P2_PDELCTRL2 + state->regoff,
1468 tmp);
1469
1470 state->berscale = 2;
1471 state->last_bernumerator = 0;
1472 state->last_berdenominator = 1;
1473 /* force to PRE BCH Rate */
1474 write_reg(state,
1475 RSTV0910_P2_ERRCTRL1 + state->regoff,
1476 BER_SRC_S2 | state->berscale);
1477 } else {
1478 state->berscale = 2;
1479 state->last_bernumerator = 0;
1480 state->last_berdenominator = 1;
1481 /* force to PRE RS Rate */
1482 write_reg(state,
1483 RSTV0910_P2_ERRCTRL1 + state->regoff,
1484 BER_SRC_S | state->berscale);
1485 }
1486 /* Reset the Total packet counter */
1487 write_reg(state,
1488 RSTV0910_P2_FBERCPT4 + state->regoff, 0x00);
1489 /*
1490 * Reset the packet Error counter2 (and Set it to
1491 * infinit error count mode)
1492 */
1493 write_reg(state,
1494 RSTV0910_P2_ERRCTRL2 + state->regoff, 0xc1);
1495
1496 set_vth_default(state);
1497 if (state->receive_mode == RCVMODE_DVBS)
1498 enable_puncture_rate(state,
1499 state->puncture_rate);
1500 }
1501 }
1502
1503 /* read signal statistics */
1504
1505 /* read signal strength */
1506 read_signal_strength(fe);
1507
1508 /* read carrier/noise on FE_HAS_CARRIER */
1509 if (*status & FE_HAS_CARRIER)
1510 read_snr(fe);
1511 else
1512 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1513
1514 /* read ber */
1515 if (*status & FE_HAS_VITERBI) {
1516 read_ber(fe);
1517 } else {
1518 p->pre_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1519 p->pre_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1520 }
1521
1522 return 0;
1523}
1524
1525static int get_frontend(struct dvb_frontend *fe,
1526 struct dtv_frontend_properties *p)
1527{
1528 struct stv *state = fe->demodulator_priv;
1529 u8 tmp;
1530
1531 if (state->receive_mode == RCVMODE_DVBS2) {
1532 u32 mc;
1533 const enum fe_modulation modcod2mod[0x20] = {
1534 QPSK, QPSK, QPSK, QPSK,
1535 QPSK, QPSK, QPSK, QPSK,
1536 QPSK, QPSK, QPSK, QPSK,
1537 PSK_8, PSK_8, PSK_8, PSK_8,
1538 PSK_8, PSK_8, APSK_16, APSK_16,
1539 APSK_16, APSK_16, APSK_16, APSK_16,
1540 APSK_32, APSK_32, APSK_32, APSK_32,
1541 APSK_32,
1542 };
1543 const enum fe_code_rate modcod2fec[0x20] = {
1544 FEC_NONE, FEC_NONE, FEC_NONE, FEC_2_5,
1545 FEC_1_2, FEC_3_5, FEC_2_3, FEC_3_4,
1546 FEC_4_5, FEC_5_6, FEC_8_9, FEC_9_10,
1547 FEC_3_5, FEC_2_3, FEC_3_4, FEC_5_6,
1548 FEC_8_9, FEC_9_10, FEC_2_3, FEC_3_4,
1549 FEC_4_5, FEC_5_6, FEC_8_9, FEC_9_10,
1550 FEC_3_4, FEC_4_5, FEC_5_6, FEC_8_9,
1551 FEC_9_10
1552 };
1553 read_reg(state, RSTV0910_P2_DMDMODCOD + state->regoff, &tmp);
1554 mc = ((tmp & 0x7c) >> 2);
1555 p->pilot = (tmp & 0x01) ? PILOT_ON : PILOT_OFF;
1556 p->modulation = modcod2mod[mc];
1557 p->fec_inner = modcod2fec[mc];
1558 } else if (state->receive_mode == RCVMODE_DVBS) {
1559 read_reg(state, RSTV0910_P2_VITCURPUN + state->regoff, &tmp);
1560 switch (tmp & 0x1F) {
1561 case 0x0d:
1562 p->fec_inner = FEC_1_2;
1563 break;
1564 case 0x12:
1565 p->fec_inner = FEC_2_3;
1566 break;
1567 case 0x15:
1568 p->fec_inner = FEC_3_4;
1569 break;
1570 case 0x18:
1571 p->fec_inner = FEC_5_6;
1572 break;
1573 case 0x1a:
1574 p->fec_inner = FEC_7_8;
1575 break;
1576 default:
1577 p->fec_inner = FEC_NONE;
1578 break;
1579 }
1580 p->rolloff = ROLLOFF_35;
1581 }
1582
1583 return 0;
1584}
1585
1586static int tune(struct dvb_frontend *fe, bool re_tune,
1587 unsigned int mode_flags,
1588 unsigned int *delay, enum fe_status *status)
1589{
1590 struct stv *state = fe->demodulator_priv;
1591 int r;
1592
1593 if (re_tune) {
1594 r = set_parameters(fe);
1595 if (r)
1596 return r;
1597 state->tune_time = jiffies;
1598 }
1599
1600 r = read_status(fe, status);
1601 if (r)
1602 return r;
1603
1604 if (*status & FE_HAS_LOCK)
1605 return 0;
1606 *delay = HZ;
1607
1608 return 0;
1609}
1610
1611static int get_algo(struct dvb_frontend *fe)
1612{
1613 return DVBFE_ALGO_HW;
1614}
1615
1616static int set_tone(struct dvb_frontend *fe, enum fe_sec_tone_mode tone)
1617{
1618 struct stv *state = fe->demodulator_priv;
1619 u16 offs = state->nr ? 0x40 : 0;
1620
1621 switch (tone) {
1622 case SEC_TONE_ON:
1623 return write_reg(state, RSTV0910_P1_DISTXCFG + offs, 0x38);
1624 case SEC_TONE_OFF:
1625 return write_reg(state, RSTV0910_P1_DISTXCFG + offs, 0x3a);
1626 default:
1627 break;
1628 }
1629 return -EINVAL;
1630}
1631
1632static int wait_dis(struct stv *state, u8 flag, u8 val)
1633{
1634 int i;
1635 u8 stat;
1636 u16 offs = state->nr ? 0x40 : 0;
1637
1638 for (i = 0; i < 10; i++) {
1639 read_reg(state, RSTV0910_P1_DISTXSTATUS + offs, &stat);
1640 if ((stat & flag) == val)
1641 return 0;
1642 usleep_range(10000, 11000);
1643 }
1644 return -ETIMEDOUT;
1645}
1646
1647static int send_master_cmd(struct dvb_frontend *fe,
1648 struct dvb_diseqc_master_cmd *cmd)
1649{
1650 struct stv *state = fe->demodulator_priv;
1651 u16 offs = state->nr ? 0x40 : 0;
1652 int i;
1653
1654 write_reg(state, RSTV0910_P1_DISTXCFG + offs, 0x3E);
1655 for (i = 0; i < cmd->msg_len; i++) {
1656 wait_dis(state, 0x40, 0x00);
1657 write_reg(state, RSTV0910_P1_DISTXFIFO + offs, cmd->msg[i]);
1658 }
1659 write_reg(state, RSTV0910_P1_DISTXCFG + offs, 0x3A);
1660 wait_dis(state, 0x20, 0x20);
1661 return 0;
1662}
1663
1664static int send_burst(struct dvb_frontend *fe, enum fe_sec_mini_cmd burst)
1665{
1666 struct stv *state = fe->demodulator_priv;
1667 u16 offs = state->nr ? 0x40 : 0;
1668 u8 value;
1669
1670 if (burst == SEC_MINI_A) {
1671 write_reg(state, RSTV0910_P1_DISTXCFG + offs, 0x3F);
1672 value = 0x00;
1673 } else {
1674 write_reg(state, RSTV0910_P1_DISTXCFG + offs, 0x3E);
1675 value = 0xFF;
1676 }
1677 wait_dis(state, 0x40, 0x00);
1678 write_reg(state, RSTV0910_P1_DISTXFIFO + offs, value);
1679 write_reg(state, RSTV0910_P1_DISTXCFG + offs, 0x3A);
1680 wait_dis(state, 0x20, 0x20);
1681
1682 return 0;
1683}
1684
1685static int sleep(struct dvb_frontend *fe)
1686{
1687 struct stv *state = fe->demodulator_priv;
1688
1689 stop(state);
1690 return 0;
1691}
1692
1693static const struct dvb_frontend_ops stv0910_ops = {
1694 .delsys = { SYS_DVBS, SYS_DVBS2, SYS_DSS },
1695 .info = {
1696 .name = "ST STV0910",
1697 .frequency_min = 950000,
1698 .frequency_max = 2150000,
1699 .frequency_stepsize = 0,
1700 .frequency_tolerance = 0,
1701 .symbol_rate_min = 100000,
1702 .symbol_rate_max = 70000000,
1703 .caps = FE_CAN_INVERSION_AUTO |
1704 FE_CAN_FEC_AUTO |
1705 FE_CAN_QPSK |
1706 FE_CAN_2G_MODULATION |
1707 FE_CAN_MULTISTREAM
1708 },
1709 .sleep = sleep,
1710 .release = release,
1711 .i2c_gate_ctrl = gate_ctrl,
1712 .set_frontend = set_parameters,
1713 .get_frontend_algo = get_algo,
1714 .get_frontend = get_frontend,
1715 .tune = tune,
1716 .read_status = read_status,
1717 .set_tone = set_tone,
1718
1719 .diseqc_send_master_cmd = send_master_cmd,
1720 .diseqc_send_burst = send_burst,
1721};
1722
1723static struct stv_base *match_base(struct i2c_adapter *i2c, u8 adr)
1724{
1725 struct stv_base *p;
1726
1727 list_for_each_entry(p, &stvlist, stvlist)
1728 if (p->i2c == i2c && p->adr == adr)
1729 return p;
1730 return NULL;
1731}
1732
1733static void stv0910_init_stats(struct stv *state)
1734{
1735 struct dtv_frontend_properties *p = &state->fe.dtv_property_cache;
1736
1737 p->strength.len = 1;
1738 p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1739 p->cnr.len = 1;
1740 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1741 p->pre_bit_error.len = 1;
1742 p->pre_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1743 p->pre_bit_count.len = 1;
1744 p->pre_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
1745}
1746
1747struct dvb_frontend *stv0910_attach(struct i2c_adapter *i2c,
1748 struct stv0910_cfg *cfg,
1749 int nr)
1750{
1751 struct stv *state;
1752 struct stv_base *base;
1753
1754 state = kzalloc(sizeof(*state), GFP_KERNEL);
1755 if (!state)
1756 return NULL;
1757
1758 state->tscfgh = 0x20 | (cfg->parallel ? 0 : 0x40);
1759 state->tsgeneral = (cfg->parallel == 2) ? 0x02 : 0x00;
1760 state->i2crpt = 0x0A | ((cfg->rptlvl & 0x07) << 4);
1761 state->tsspeed = 0x28;
1762 state->nr = nr;
1763 state->regoff = state->nr ? 0 : 0x200;
1764 state->search_range = 16000000;
1765 state->demod_bits = 0x10; /* Inversion : Auto with reset to 0 */
1766 state->receive_mode = RCVMODE_NONE;
1767 state->cur_scrambling_code = (~0U);
1768 state->single = cfg->single ? 1 : 0;
1769
1770 base = match_base(i2c, cfg->adr);
1771 if (base) {
1772 base->count++;
1773 state->base = base;
1774 } else {
1775 base = kzalloc(sizeof(*base), GFP_KERNEL);
1776 if (!base)
1777 goto fail;
1778 base->i2c = i2c;
1779 base->adr = cfg->adr;
1780 base->count = 1;
1781 base->extclk = cfg->clk ? cfg->clk : 30000000;
1782
1783 mutex_init(&base->i2c_lock);
1784 mutex_init(&base->reg_lock);
1785 state->base = base;
1786 if (probe(state) < 0) {
1787 dev_info(&i2c->dev, "No demod found at adr %02X on %s\n",
1788 cfg->adr, dev_name(&i2c->dev));
1789 kfree(base);
1790 goto fail;
1791 }
1792 list_add(&base->stvlist, &stvlist);
1793 }
1794 state->fe.ops = stv0910_ops;
1795 state->fe.demodulator_priv = state;
1796 state->nr = nr;
1797
1798 dev_info(&i2c->dev, "%s demod found at adr %02X on %s\n",
1799 state->fe.ops.info.name, cfg->adr, dev_name(&i2c->dev));
1800
1801 stv0910_init_stats(state);
1802
1803 return &state->fe;
1804
1805fail:
1806 kfree(state);
1807 return NULL;
1808}
1809EXPORT_SYMBOL_GPL(stv0910_attach);
1810
1811MODULE_DESCRIPTION("ST STV0910 multistandard frontend driver");
1812MODULE_AUTHOR("Ralph and Marcus Metzler, Manfred Voelkel");
1813MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/stv0910.h b/drivers/media/dvb-frontends/stv0910.h
new file mode 100644
index 000000000000..fccd8d9b665f
--- /dev/null
+++ b/drivers/media/dvb-frontends/stv0910.h
@@ -0,0 +1,32 @@
1#ifndef _STV0910_H_
2#define _STV0910_H_
3
4#include <linux/types.h>
5#include <linux/i2c.h>
6
7struct stv0910_cfg {
8 u32 clk;
9 u8 adr;
10 u8 parallel;
11 u8 rptlvl;
12 u8 single;
13};
14
15#if IS_REACHABLE(CONFIG_DVB_STV0910)
16
17struct dvb_frontend *stv0910_attach(struct i2c_adapter *i2c,
18 struct stv0910_cfg *cfg, int nr);
19
20#else
21
22static inline struct dvb_frontend *stv0910_attach(struct i2c_adapter *i2c,
23 struct stv0910_cfg *cfg,
24 int nr)
25{
26 pr_warn("%s: driver disabled by Kconfig\n", __func__);
27 return NULL;
28}
29
30#endif /* CONFIG_DVB_STV0910 */
31
32#endif /* _STV0910_H_ */
diff --git a/drivers/media/dvb-frontends/stv0910_regs.h b/drivers/media/dvb-frontends/stv0910_regs.h
new file mode 100644
index 000000000000..32ced4eaf296
--- /dev/null
+++ b/drivers/media/dvb-frontends/stv0910_regs.h
@@ -0,0 +1,4760 @@
1/*
2 * @DVB-S/DVB-S2 STMicroelectronics STV0900 register definitions
3 * Author Manfred Voelkel, August 2013
4 * (c) 2013 Digital Devices GmbH Germany. All rights reserved
5 *
6 * =======================================================================
7 * Registers Declaration (Internal ST, All Applications )
8 * -------------------------
9 * Each register (RSTV0910__XXXXX) is defined by its address (2 bytes).
10 *
11 * Each field (FSTV0910__XXXXX)is defined as follow:
12 * [register address -- 2bytes][field sign -- 1byte][field mask -- 1byte]
13 * ======================================================================
14 */
15
16/* MID */
17#define RSTV0910_MID 0xf100
18#define FSTV0910_MCHIP_IDENT 0xf10000f0
19#define FSTV0910_MRELEASE 0xf100000f
20
21/* DID */
22#define RSTV0910_DID 0xf101
23#define FSTV0910_DEVICE_ID 0xf10100ff
24
25/* DACR1 */
26#define RSTV0910_DACR1 0xf113
27#define FSTV0910_DAC_MODE 0xf11300e0
28#define FSTV0910_DAC_VALUE1 0xf113000f
29
30/* DACR2 */
31#define RSTV0910_DACR2 0xf114
32#define FSTV0910_DAC_VALUE0 0xf11400ff
33
34/* PADCFG */
35#define RSTV0910_PADCFG 0xf11a
36#define FSTV0910_AGCRF2_OPD 0xf11a0008
37#define FSTV0910_AGCRF2_XOR 0xf11a0004
38#define FSTV0910_AGCRF1_OPD 0xf11a0002
39#define FSTV0910_AGCRF1_XOR 0xf11a0001
40
41/* OUTCFG2 */
42#define RSTV0910_OUTCFG2 0xf11b
43#define FSTV0910_TS2_ERROR_XOR 0xf11b0080
44#define FSTV0910_TS2_DPN_XOR 0xf11b0040
45#define FSTV0910_TS2_STROUT_XOR 0xf11b0020
46#define FSTV0910_TS2_CLOCKOUT_XOR 0xf11b0010
47#define FSTV0910_TS1_ERROR_XOR 0xf11b0008
48#define FSTV0910_TS1_DPN_XOR 0xf11b0004
49#define FSTV0910_TS1_STROUT_XOR 0xf11b0002
50#define FSTV0910_TS1_CLOCKOUT_XOR 0xf11b0001
51
52/* OUTCFG */
53#define RSTV0910_OUTCFG 0xf11c
54#define FSTV0910_TS2_OUTSER_HZ 0xf11c0020
55#define FSTV0910_TS1_OUTSER_HZ 0xf11c0010
56#define FSTV0910_TS2_OUTPAR_HZ 0xf11c0008
57#define FSTV0910_TS1_OUTPAR_HZ 0xf11c0004
58#define FSTV0910_TS_SERDATA0 0xf11c0002
59
60/* IRQSTATUS3 */
61#define RSTV0910_IRQSTATUS3 0xf120
62#define FSTV0910_SPLL_LOCK 0xf1200020
63#define FSTV0910_SSTREAM_LCK_1 0xf1200010
64#define FSTV0910_SSTREAM_LCK_2 0xf1200008
65#define FSTV0910_SDVBS1_PRF_2 0xf1200002
66#define FSTV0910_SDVBS1_PRF_1 0xf1200001
67
68/* IRQSTATUS2 */
69#define RSTV0910_IRQSTATUS2 0xf121
70#define FSTV0910_SSPY_ENDSIM_1 0xf1210080
71#define FSTV0910_SSPY_ENDSIM_2 0xf1210040
72#define FSTV0910_SPKTDEL_ERROR_2 0xf1210010
73#define FSTV0910_SPKTDEL_LOCKB_2 0xf1210008
74#define FSTV0910_SPKTDEL_LOCK_2 0xf1210004
75#define FSTV0910_SPKTDEL_ERROR_1 0xf1210002
76#define FSTV0910_SPKTDEL_LOCKB_1 0xf1210001
77
78/* IRQSTATUS1 */
79#define RSTV0910_IRQSTATUS1 0xf122
80#define FSTV0910_SPKTDEL_LOCK_1 0xf1220080
81#define FSTV0910_SFEC_LOCKB_2 0xf1220040
82#define FSTV0910_SFEC_LOCK_2 0xf1220020
83#define FSTV0910_SFEC_LOCKB_1 0xf1220010
84#define FSTV0910_SFEC_LOCK_1 0xf1220008
85#define FSTV0910_SDEMOD_LOCKB_2 0xf1220004
86#define FSTV0910_SDEMOD_LOCK_2 0xf1220002
87#define FSTV0910_SDEMOD_IRQ_2 0xf1220001
88
89/* IRQSTATUS0 */
90#define RSTV0910_IRQSTATUS0 0xf123
91#define FSTV0910_SDEMOD_LOCKB_1 0xf1230080
92#define FSTV0910_SDEMOD_LOCK_1 0xf1230040
93#define FSTV0910_SDEMOD_IRQ_1 0xf1230020
94#define FSTV0910_SBCH_ERRFLAG 0xf1230010
95#define FSTV0910_SDISEQC2_IRQ 0xf1230004
96#define FSTV0910_SDISEQC1_IRQ 0xf1230001
97
98/* IRQMASK3 */
99#define RSTV0910_IRQMASK3 0xf124
100#define FSTV0910_MPLL_LOCK 0xf1240020
101#define FSTV0910_MSTREAM_LCK_1 0xf1240010
102#define FSTV0910_MSTREAM_LCK_2 0xf1240008
103#define FSTV0910_MDVBS1_PRF_2 0xf1240002
104#define FSTV0910_MDVBS1_PRF_1 0xf1240001
105
106/* IRQMASK2 */
107#define RSTV0910_IRQMASK2 0xf125
108#define FSTV0910_MSPY_ENDSIM_1 0xf1250080
109#define FSTV0910_MSPY_ENDSIM_2 0xf1250040
110#define FSTV0910_MPKTDEL_ERROR_2 0xf1250010
111#define FSTV0910_MPKTDEL_LOCKB_2 0xf1250008
112#define FSTV0910_MPKTDEL_LOCK_2 0xf1250004
113#define FSTV0910_MPKTDEL_ERROR_1 0xf1250002
114#define FSTV0910_MPKTDEL_LOCKB_1 0xf1250001
115
116/* IRQMASK1 */
117#define RSTV0910_IRQMASK1 0xf126
118#define FSTV0910_MPKTDEL_LOCK_1 0xf1260080
119#define FSTV0910_MFEC_LOCKB_2 0xf1260040
120#define FSTV0910_MFEC_LOCK_2 0xf1260020
121#define FSTV0910_MFEC_LOCKB_1 0xf1260010
122#define FSTV0910_MFEC_LOCK_1 0xf1260008
123#define FSTV0910_MDEMOD_LOCKB_2 0xf1260004
124#define FSTV0910_MDEMOD_LOCK_2 0xf1260002
125#define FSTV0910_MDEMOD_IRQ_2 0xf1260001
126
127/* IRQMASK0 */
128#define RSTV0910_IRQMASK0 0xf127
129#define FSTV0910_MDEMOD_LOCKB_1 0xf1270080
130#define FSTV0910_MDEMOD_LOCK_1 0xf1270040
131#define FSTV0910_MDEMOD_IRQ_1 0xf1270020
132#define FSTV0910_MBCH_ERRFLAG 0xf1270010
133#define FSTV0910_MDISEQC2_IRQ 0xf1270004
134#define FSTV0910_MDISEQC1_IRQ 0xf1270001
135
136/* I2CCFG */
137#define RSTV0910_I2CCFG 0xf129
138#define FSTV0910_I2C_FASTMODE 0xf1290008
139#define FSTV0910_I2CADDR_INC 0xf1290003
140
141/* P1_I2CRPT */
142#define RSTV0910_P1_I2CRPT 0xf12a
143#define FSTV0910_P1_I2CT_ON 0xf12a0080
144#define FSTV0910_P1_ENARPT_LEVEL 0xf12a0070
145#define FSTV0910_P1_SCLT_DELAY 0xf12a0008
146#define FSTV0910_P1_STOP_ENABLE 0xf12a0004
147#define FSTV0910_P1_STOP_SDAT2SDA 0xf12a0002
148
149/* P2_I2CRPT */
150#define RSTV0910_P2_I2CRPT 0xf12b
151#define FSTV0910_P2_I2CT_ON 0xf12b0080
152#define FSTV0910_P2_ENARPT_LEVEL 0xf12b0070
153#define FSTV0910_P2_SCLT_DELAY 0xf12b0008
154#define FSTV0910_P2_STOP_ENABLE 0xf12b0004
155#define FSTV0910_P2_STOP_SDAT2SDA 0xf12b0002
156
157/* GPIO0CFG */
158#define RSTV0910_GPIO0CFG 0xf140
159#define FSTV0910_GPIO0_OPD 0xf1400080
160#define FSTV0910_GPIO0_CONFIG 0xf140007e
161#define FSTV0910_GPIO0_XOR 0xf1400001
162
163/* GPIO1CFG */
164#define RSTV0910_GPIO1CFG 0xf141
165#define FSTV0910_GPIO1_OPD 0xf1410080
166#define FSTV0910_GPIO1_CONFIG 0xf141007e
167#define FSTV0910_GPIO1_XOR 0xf1410001
168
169/* GPIO2CFG */
170#define RSTV0910_GPIO2CFG 0xf142
171#define FSTV0910_GPIO2_OPD 0xf1420080
172#define FSTV0910_GPIO2_CONFIG 0xf142007e
173#define FSTV0910_GPIO2_XOR 0xf1420001
174
175/* GPIO3CFG */
176#define RSTV0910_GPIO3CFG 0xf143
177#define FSTV0910_GPIO3_OPD 0xf1430080
178#define FSTV0910_GPIO3_CONFIG 0xf143007e
179#define FSTV0910_GPIO3_XOR 0xf1430001
180
181/* GPIO4CFG */
182#define RSTV0910_GPIO4CFG 0xf144
183#define FSTV0910_GPIO4_OPD 0xf1440080
184#define FSTV0910_GPIO4_CONFIG 0xf144007e
185#define FSTV0910_GPIO4_XOR 0xf1440001
186
187/* GPIO5CFG */
188#define RSTV0910_GPIO5CFG 0xf145
189#define FSTV0910_GPIO5_OPD 0xf1450080
190#define FSTV0910_GPIO5_CONFIG 0xf145007e
191#define FSTV0910_GPIO5_XOR 0xf1450001
192
193/* GPIO6CFG */
194#define RSTV0910_GPIO6CFG 0xf146
195#define FSTV0910_GPIO6_OPD 0xf1460080
196#define FSTV0910_GPIO6_CONFIG 0xf146007e
197#define FSTV0910_GPIO6_XOR 0xf1460001
198
199/* GPIO7CFG */
200#define RSTV0910_GPIO7CFG 0xf147
201#define FSTV0910_GPIO7_OPD 0xf1470080
202#define FSTV0910_GPIO7_CONFIG 0xf147007e
203#define FSTV0910_GPIO7_XOR 0xf1470001
204
205/* GPIO8CFG */
206#define RSTV0910_GPIO8CFG 0xf148
207#define FSTV0910_GPIO8_OPD 0xf1480080
208#define FSTV0910_GPIO8_CONFIG 0xf148007e
209#define FSTV0910_GPIO8_XOR 0xf1480001
210
211/* GPIO9CFG */
212#define RSTV0910_GPIO9CFG 0xf149
213#define FSTV0910_GPIO9_OPD 0xf1490080
214#define FSTV0910_GPIO9_CONFIG 0xf149007e
215#define FSTV0910_GPIO9_XOR 0xf1490001
216
217/* GPIO10CFG */
218#define RSTV0910_GPIO10CFG 0xf14a
219#define FSTV0910_GPIO10_OPD 0xf14a0080
220#define FSTV0910_GPIO10_CONFIG 0xf14a007e
221#define FSTV0910_GPIO10_XOR 0xf14a0001
222
223/* GPIO11CFG */
224#define RSTV0910_GPIO11CFG 0xf14b
225#define FSTV0910_GPIO11_OPD 0xf14b0080
226#define FSTV0910_GPIO11_CONFIG 0xf14b007e
227#define FSTV0910_GPIO11_XOR 0xf14b0001
228
229/* GPIO12CFG */
230#define RSTV0910_GPIO12CFG 0xf14c
231#define FSTV0910_GPIO12_OPD 0xf14c0080
232#define FSTV0910_GPIO12_CONFIG 0xf14c007e
233#define FSTV0910_GPIO12_XOR 0xf14c0001
234
235/* GPIO13CFG */
236#define RSTV0910_GPIO13CFG 0xf14d
237#define FSTV0910_GPIO13_OPD 0xf14d0080
238#define FSTV0910_GPIO13_CONFIG 0xf14d007e
239#define FSTV0910_GPIO13_XOR 0xf14d0001
240
241/* GPIO14CFG */
242#define RSTV0910_GPIO14CFG 0xf14e
243#define FSTV0910_GPIO14_OPD 0xf14e0080
244#define FSTV0910_GPIO14_CONFIG 0xf14e007e
245#define FSTV0910_GPIO14_XOR 0xf14e0001
246
247/* GPIO15CFG */
248#define RSTV0910_GPIO15CFG 0xf14f
249#define FSTV0910_GPIO15_OPD 0xf14f0080
250#define FSTV0910_GPIO15_CONFIG 0xf14f007e
251#define FSTV0910_GPIO15_XOR 0xf14f0001
252
253/* GPIO16CFG */
254#define RSTV0910_GPIO16CFG 0xf150
255#define FSTV0910_GPIO16_OPD 0xf1500080
256#define FSTV0910_GPIO16_CONFIG 0xf150007e
257#define FSTV0910_GPIO16_XOR 0xf1500001
258
259/* GPIO17CFG */
260#define RSTV0910_GPIO17CFG 0xf151
261#define FSTV0910_GPIO17_OPD 0xf1510080
262#define FSTV0910_GPIO17_CONFIG 0xf151007e
263#define FSTV0910_GPIO17_XOR 0xf1510001
264
265/* GPIO18CFG */
266#define RSTV0910_GPIO18CFG 0xf152
267#define FSTV0910_GPIO18_OPD 0xf1520080
268#define FSTV0910_GPIO18_CONFIG 0xf152007e
269#define FSTV0910_GPIO18_XOR 0xf1520001
270
271/* GPIO19CFG */
272#define RSTV0910_GPIO19CFG 0xf153
273#define FSTV0910_GPIO19_OPD 0xf1530080
274#define FSTV0910_GPIO19_CONFIG 0xf153007e
275#define FSTV0910_GPIO19_XOR 0xf1530001
276
277/* GPIO20CFG */
278#define RSTV0910_GPIO20CFG 0xf154
279#define FSTV0910_GPIO20_OPD 0xf1540080
280#define FSTV0910_GPIO20_CONFIG 0xf154007e
281#define FSTV0910_GPIO20_XOR 0xf1540001
282
283/* GPIO21CFG */
284#define RSTV0910_GPIO21CFG 0xf155
285#define FSTV0910_GPIO21_OPD 0xf1550080
286#define FSTV0910_GPIO21_CONFIG 0xf155007e
287#define FSTV0910_GPIO21_XOR 0xf1550001
288
289/* GPIO22CFG */
290#define RSTV0910_GPIO22CFG 0xf156
291#define FSTV0910_GPIO22_OPD 0xf1560080
292#define FSTV0910_GPIO22_CONFIG 0xf156007e
293#define FSTV0910_GPIO22_XOR 0xf1560001
294
295/* STRSTATUS1 */
296#define RSTV0910_STRSTATUS1 0xf16a
297#define FSTV0910_STRSTATUS_SEL2 0xf16a00f0
298#define FSTV0910_STRSTATUS_SEL1 0xf16a000f
299
300/* STRSTATUS2 */
301#define RSTV0910_STRSTATUS2 0xf16b
302#define FSTV0910_STRSTATUS_SEL4 0xf16b00f0
303#define FSTV0910_STRSTATUS_SEL3 0xf16b000f
304
305/* STRSTATUS3 */
306#define RSTV0910_STRSTATUS3 0xf16c
307#define FSTV0910_STRSTATUS_SEL6 0xf16c00f0
308#define FSTV0910_STRSTATUS_SEL5 0xf16c000f
309
310/* FSKTFC2 */
311#define RSTV0910_FSKTFC2 0xf170
312#define FSTV0910_FSKT_KMOD 0xf17000fc
313#define FSTV0910_FSKT_CAR2 0xf1700003
314
315/* FSKTFC1 */
316#define RSTV0910_FSKTFC1 0xf171
317#define FSTV0910_FSKT_CAR1 0xf17100ff
318
319/* FSKTFC0 */
320#define RSTV0910_FSKTFC0 0xf172
321#define FSTV0910_FSKT_CAR0 0xf17200ff
322
323/* FSKTDELTAF1 */
324#define RSTV0910_FSKTDELTAF1 0xf173
325#define FSTV0910_FSKT_DELTAF1 0xf173000f
326
327/* FSKTDELTAF0 */
328#define RSTV0910_FSKTDELTAF0 0xf174
329#define FSTV0910_FSKT_DELTAF0 0xf17400ff
330
331/* FSKTCTRL */
332#define RSTV0910_FSKTCTRL 0xf175
333#define FSTV0910_FSKT_PINSEL 0xf1750080
334#define FSTV0910_FSKT_EN_SGN 0xf1750040
335#define FSTV0910_FSKT_MOD_SGN 0xf1750020
336#define FSTV0910_FSKT_MOD_EN 0xf175001c
337#define FSTV0910_FSKT_DACMODE 0xf1750003
338
339/* FSKRFC2 */
340#define RSTV0910_FSKRFC2 0xf176
341#define FSTV0910_FSKR_DETSGN 0xf1760040
342#define FSTV0910_FSKR_OUTSGN 0xf1760020
343#define FSTV0910_FSKR_KAGC 0xf176001c
344#define FSTV0910_FSKR_CAR2 0xf1760003
345
346/* FSKRFC1 */
347#define RSTV0910_FSKRFC1 0xf177
348#define FSTV0910_FSKR_CAR1 0xf17700ff
349
350/* FSKRFC0 */
351#define RSTV0910_FSKRFC0 0xf178
352#define FSTV0910_FSKR_CAR0 0xf17800ff
353
354/* FSKRK1 */
355#define RSTV0910_FSKRK1 0xf179
356#define FSTV0910_FSKR_K1_EXP 0xf17900e0
357#define FSTV0910_FSKR_K1_MANT 0xf179001f
358
359/* FSKRK2 */
360#define RSTV0910_FSKRK2 0xf17a
361#define FSTV0910_FSKR_K2_EXP 0xf17a00e0
362#define FSTV0910_FSKR_K2_MANT 0xf17a001f
363
364/* FSKRAGCR */
365#define RSTV0910_FSKRAGCR 0xf17b
366#define FSTV0910_FSKR_OUTCTL 0xf17b00c0
367#define FSTV0910_FSKR_AGC_REF 0xf17b003f
368
369/* FSKRAGC */
370#define RSTV0910_FSKRAGC 0xf17c
371#define FSTV0910_FSKR_AGC_ACCU 0xf17c00ff
372
373/* FSKRALPHA */
374#define RSTV0910_FSKRALPHA 0xf17d
375#define FSTV0910_FSKR_ALPHA_EXP 0xf17d001c
376#define FSTV0910_FSKR_ALPHA_M 0xf17d0003
377
378/* FSKRPLTH1 */
379#define RSTV0910_FSKRPLTH1 0xf17e
380#define FSTV0910_FSKR_BETA 0xf17e00f0
381#define FSTV0910_FSKR_PLL_TRESH1 0xf17e000f
382
383/* FSKRPLTH0 */
384#define RSTV0910_FSKRPLTH0 0xf17f
385#define FSTV0910_FSKR_PLL_TRESH0 0xf17f00ff
386
387/* FSKRDF1 */
388#define RSTV0910_FSKRDF1 0xf180
389#define FSTV0910_FSKR_OUT 0xf1800080
390#define FSTV0910_FSKR_STATE 0xf1800060
391#define FSTV0910_FSKR_DELTAF1 0xf180001f
392
393/* FSKRDF0 */
394#define RSTV0910_FSKRDF0 0xf181
395#define FSTV0910_FSKR_DELTAF0 0xf18100ff
396
397/* FSKRSTEPP */
398#define RSTV0910_FSKRSTEPP 0xf182
399#define FSTV0910_FSKR_STEP_PLUS 0xf18200ff
400
401/* FSKRSTEPM */
402#define RSTV0910_FSKRSTEPM 0xf183
403#define FSTV0910_FSKR_STEP_MINUS 0xf18300ff
404
405/* FSKRDET1 */
406#define RSTV0910_FSKRDET1 0xf184
407#define FSTV0910_FSKR_DETECT 0xf1840080
408#define FSTV0910_FSKR_CARDET_ACCU1 0xf184000f
409
410/* FSKRDET0 */
411#define RSTV0910_FSKRDET0 0xf185
412#define FSTV0910_FSKR_CARDET_ACCU0 0xf18500ff
413
414/* FSKRDTH1 */
415#define RSTV0910_FSKRDTH1 0xf186
416#define FSTV0910_FSKR_CARLOSS_THRESH1 0xf18600f0
417#define FSTV0910_FSKR_CARDET_THRESH1 0xf186000f
418
419/* FSKRDTH0 */
420#define RSTV0910_FSKRDTH0 0xf187
421#define FSTV0910_FSKR_CARDET_THRESH0 0xf18700ff
422
423/* FSKRLOSS */
424#define RSTV0910_FSKRLOSS 0xf188
425#define FSTV0910_FSKR_CARLOSS_THRESH0 0xf18800ff
426
427/* NCOARSE */
428#define RSTV0910_NCOARSE 0xf1b3
429#define FSTV0910_CP 0xf1b300f8
430#define FSTV0910_IDF 0xf1b30007
431
432/* NCOARSE1 */
433#define RSTV0910_NCOARSE1 0xf1b4
434#define FSTV0910_N_DIV 0xf1b400ff
435
436/* NCOARSE2 */
437#define RSTV0910_NCOARSE2 0xf1b5
438#define FSTV0910_ODF 0xf1b5003f
439
440/* SYNTCTRL */
441#define RSTV0910_SYNTCTRL 0xf1b6
442#define FSTV0910_STANDBY 0xf1b60080
443#define FSTV0910_BYPASSPLLCORE 0xf1b60040
444#define FSTV0910_STOP_PLL 0xf1b60008
445#define FSTV0910_OSCI_E 0xf1b60002
446
447/* FILTCTRL */
448#define RSTV0910_FILTCTRL 0xf1b7
449#define FSTV0910_INV_CLKFSK 0xf1b70002
450#define FSTV0910_BYPASS_APPLI 0xf1b70001
451
452/* PLLSTAT */
453#define RSTV0910_PLLSTAT 0xf1b8
454#define FSTV0910_PLLLOCK 0xf1b80001
455
456/* STOPCLK1 */
457#define RSTV0910_STOPCLK1 0xf1c2
458#define FSTV0910_INV_CLKADCI2 0xf1c20004
459#define FSTV0910_INV_CLKADCI1 0xf1c20001
460
461/* STOPCLK2 */
462#define RSTV0910_STOPCLK2 0xf1c3
463#define FSTV0910_STOP_DVBS2FEC2 0xf1c30020
464#define FSTV0910_STOP_DVBS2FEC 0xf1c30010
465#define FSTV0910_STOP_DVBS1FEC2 0xf1c30008
466#define FSTV0910_STOP_DVBS1FEC 0xf1c30004
467#define FSTV0910_STOP_DEMOD2 0xf1c30002
468#define FSTV0910_STOP_DEMOD 0xf1c30001
469
470/* PREGCTL */
471#define RSTV0910_PREGCTL 0xf1c8
472#define FSTV0910_REG3V3TO2V5_POFF 0xf1c80080
473
474/* TSTTNR0 */
475#define RSTV0910_TSTTNR0 0xf1df
476#define FSTV0910_FSK_PON 0xf1df0004
477
478/* TSTTNR1 */
479#define RSTV0910_TSTTNR1 0xf1e0
480#define FSTV0910_ADC1_PON 0xf1e00002
481
482/* TSTTNR2 */
483#define RSTV0910_TSTTNR2 0xf1e1
484#define FSTV0910_I2C_DISEQC_PON 0xf1e10020
485#define FSTV0910_DISEQC_CLKDIV 0xf1e1000f
486
487/* TSTTNR3 */
488#define RSTV0910_TSTTNR3 0xf1e2
489#define FSTV0910_ADC2_PON 0xf1e20002
490
491/* P2_IQCONST */
492#define RSTV0910_P2_IQCONST 0xf200
493#define FSTV0910_P2_CONSTEL_SELECT 0xf2000060
494#define FSTV0910_P2_IQSYMB_SEL 0xf200001f
495
496/* P2_NOSCFG */
497#define RSTV0910_P2_NOSCFG 0xf201
498#define FSTV0910_P2_DUMMYPL_NOSDATA 0xf2010020
499#define FSTV0910_P2_NOSPLH_BETA 0xf2010018
500#define FSTV0910_P2_NOSDATA_BETA 0xf2010007
501
502/* P2_ISYMB */
503#define RSTV0910_P2_ISYMB 0xf202
504#define FSTV0910_P2_I_SYMBOL 0xf20201ff
505
506/* P2_QSYMB */
507#define RSTV0910_P2_QSYMB 0xf203
508#define FSTV0910_P2_Q_SYMBOL 0xf20301ff
509
510/* P2_AGC1CFG */
511#define RSTV0910_P2_AGC1CFG 0xf204
512#define FSTV0910_P2_DC_FROZEN 0xf2040080
513#define FSTV0910_P2_DC_CORRECT 0xf2040040
514#define FSTV0910_P2_AMM_FROZEN 0xf2040020
515#define FSTV0910_P2_AMM_CORRECT 0xf2040010
516#define FSTV0910_P2_QUAD_FROZEN 0xf2040008
517#define FSTV0910_P2_QUAD_CORRECT 0xf2040004
518
519/* P2_AGC1CN */
520#define RSTV0910_P2_AGC1CN 0xf206
521#define FSTV0910_P2_AGC1_LOCKED 0xf2060080
522#define FSTV0910_P2_AGC1_MINPOWER 0xf2060010
523#define FSTV0910_P2_AGCOUT_FAST 0xf2060008
524#define FSTV0910_P2_AGCIQ_BETA 0xf2060007
525
526/* P2_AGC1REF */
527#define RSTV0910_P2_AGC1REF 0xf207
528#define FSTV0910_P2_AGCIQ_REF 0xf20700ff
529
530/* P2_IDCCOMP */
531#define RSTV0910_P2_IDCCOMP 0xf208
532#define FSTV0910_P2_IAVERAGE_ADJ 0xf20801ff
533
534/* P2_QDCCOMP */
535#define RSTV0910_P2_QDCCOMP 0xf209
536#define FSTV0910_P2_QAVERAGE_ADJ 0xf20901ff
537
538/* P2_POWERI */
539#define RSTV0910_P2_POWERI 0xf20a
540#define FSTV0910_P2_POWER_I 0xf20a00ff
541
542/* P2_POWERQ */
543#define RSTV0910_P2_POWERQ 0xf20b
544#define FSTV0910_P2_POWER_Q 0xf20b00ff
545
546/* P2_AGC1AMM */
547#define RSTV0910_P2_AGC1AMM 0xf20c
548#define FSTV0910_P2_AMM_VALUE 0xf20c00ff
549
550/* P2_AGC1QUAD */
551#define RSTV0910_P2_AGC1QUAD 0xf20d
552#define FSTV0910_P2_QUAD_VALUE 0xf20d01ff
553
554/* P2_AGCIQIN1 */
555#define RSTV0910_P2_AGCIQIN1 0xf20e
556#define FSTV0910_P2_AGCIQ_VALUE1 0xf20e00ff
557
558/* P2_AGCIQIN0 */
559#define RSTV0910_P2_AGCIQIN0 0xf20f
560#define FSTV0910_P2_AGCIQ_VALUE0 0xf20f00ff
561
562/* P2_DEMOD */
563#define RSTV0910_P2_DEMOD 0xf210
564#define FSTV0910_P2_MANUALS2_ROLLOFF 0xf2100080
565#define FSTV0910_P2_SPECINV_CONTROL 0xf2100030
566#define FSTV0910_P2_MANUALSX_ROLLOFF 0xf2100004
567#define FSTV0910_P2_ROLLOFF_CONTROL 0xf2100003
568
569/* P2_DMDMODCOD */
570#define RSTV0910_P2_DMDMODCOD 0xf211
571#define FSTV0910_P2_MANUAL_MODCOD 0xf2110080
572#define FSTV0910_P2_DEMOD_MODCOD 0xf211007c
573#define FSTV0910_P2_DEMOD_TYPE 0xf2110003
574
575/* P2_DSTATUS */
576#define RSTV0910_P2_DSTATUS 0xf212
577#define FSTV0910_P2_CAR_LOCK 0xf2120080
578#define FSTV0910_P2_TMGLOCK_QUALITY 0xf2120060
579#define FSTV0910_P2_LOCK_DEFINITIF 0xf2120008
580#define FSTV0910_P2_OVADC_DETECT 0xf2120001
581
582/* P2_DSTATUS2 */
583#define RSTV0910_P2_DSTATUS2 0xf213
584#define FSTV0910_P2_DEMOD_DELOCK 0xf2130080
585#define FSTV0910_P2_MODCODRQ_SYNCTAG 0xf2130020
586#define FSTV0910_P2_POLYPH_SATEVENT 0xf2130010
587#define FSTV0910_P2_AGC1_NOSIGNALACK 0xf2130008
588#define FSTV0910_P2_AGC2_OVERFLOW 0xf2130004
589#define FSTV0910_P2_CFR_OVERFLOW 0xf2130002
590#define FSTV0910_P2_GAMMA_OVERUNDER 0xf2130001
591
592/* P2_DMDCFGMD */
593#define RSTV0910_P2_DMDCFGMD 0xf214
594#define FSTV0910_P2_DVBS2_ENABLE 0xf2140080
595#define FSTV0910_P2_DVBS1_ENABLE 0xf2140040
596#define FSTV0910_P2_SCAN_ENABLE 0xf2140010
597#define FSTV0910_P2_CFR_AUTOSCAN 0xf2140008
598#define FSTV0910_P2_TUN_RNG 0xf2140003
599
600/* P2_DMDCFG2 */
601#define RSTV0910_P2_DMDCFG2 0xf215
602#define FSTV0910_P2_S1S2_SEQUENTIAL 0xf2150040
603#define FSTV0910_P2_INFINITE_RELOCK 0xf2150010
604
605/* P2_DMDISTATE */
606#define RSTV0910_P2_DMDISTATE 0xf216
607#define FSTV0910_P2_I2C_NORESETDMODE 0xf2160080
608#define FSTV0910_P2_I2C_DEMOD_MODE 0xf216001f
609
610/* P2_DMDT0M */
611#define RSTV0910_P2_DMDT0M 0xf217
612#define FSTV0910_P2_DMDT0_MIN 0xf21700ff
613
614/* P2_DMDSTATE */
615#define RSTV0910_P2_DMDSTATE 0xf21b
616#define FSTV0910_P2_HEADER_MODE 0xf21b0060
617
618/* P2_DMDFLYW */
619#define RSTV0910_P2_DMDFLYW 0xf21c
620#define FSTV0910_P2_I2C_IRQVAL 0xf21c00f0
621#define FSTV0910_P2_FLYWHEEL_CPT 0xf21c000f
622
623/* P2_DSTATUS3 */
624#define RSTV0910_P2_DSTATUS3 0xf21d
625#define FSTV0910_P2_CFR_ZIGZAG 0xf21d0080
626#define FSTV0910_P2_DEMOD_CFGMODE 0xf21d0060
627#define FSTV0910_P2_GAMMA_LOWBAUDRATE 0xf21d0010
628
629/* P2_DMDCFG3 */
630#define RSTV0910_P2_DMDCFG3 0xf21e
631#define FSTV0910_P2_NOSTOP_FIFOFULL 0xf21e0008
632
633/* P2_DMDCFG4 */
634#define RSTV0910_P2_DMDCFG4 0xf21f
635#define FSTV0910_P2_DIS_VITLOCK 0xf21f0080
636#define FSTV0910_P2_DIS_CLKENABLE 0xf21f0004
637
638/* P2_CORRELMANT */
639#define RSTV0910_P2_CORRELMANT 0xf220
640#define FSTV0910_P2_CORREL_MANT 0xf22000ff
641
642/* P2_CORRELABS */
643#define RSTV0910_P2_CORRELABS 0xf221
644#define FSTV0910_P2_CORREL_ABS 0xf22100ff
645
646/* P2_CORRELEXP */
647#define RSTV0910_P2_CORRELEXP 0xf222
648#define FSTV0910_P2_CORREL_ABSEXP 0xf22200f0
649#define FSTV0910_P2_CORREL_EXP 0xf222000f
650
651/* P2_PLHMODCOD */
652#define RSTV0910_P2_PLHMODCOD 0xf224
653#define FSTV0910_P2_SPECINV_DEMOD 0xf2240080
654#define FSTV0910_P2_PLH_MODCOD 0xf224007c
655#define FSTV0910_P2_PLH_TYPE 0xf2240003
656
657/* P2_DMDREG */
658#define RSTV0910_P2_DMDREG 0xf225
659#define FSTV0910_P2_DECIM_PLFRAMES 0xf2250001
660
661/* P2_AGCNADJ */
662#define RSTV0910_P2_AGCNADJ 0xf226
663#define FSTV0910_P2_RADJOFF_AGC2 0xf2260080
664#define FSTV0910_P2_RADJOFF_AGC1 0xf2260040
665#define FSTV0910_P2_AGC_NADJ 0xf226013f
666
667/* P2_AGCKS */
668#define RSTV0910_P2_AGCKS 0xf227
669#define FSTV0910_P2_RSADJ_MANUALCFG 0xf2270080
670#define FSTV0910_P2_RSADJ_CCMMODE 0xf2270040
671#define FSTV0910_P2_RADJ_SPSK 0xf227013f
672
673/* P2_AGCKQ */
674#define RSTV0910_P2_AGCKQ 0xf228
675#define FSTV0910_P2_RADJON_DVBS1 0xf2280040
676#define FSTV0910_P2_RADJ_QPSK 0xf228013f
677
678/* P2_AGCK8 */
679#define RSTV0910_P2_AGCK8 0xf229
680#define FSTV0910_P2_RADJ_8PSK 0xf229013f
681
682/* P2_AGCK16 */
683#define RSTV0910_P2_AGCK16 0xf22a
684#define FSTV0910_P2_R2ADJOFF_16APSK 0xf22a0040
685#define FSTV0910_P2_R1ADJOFF_16APSK 0xf22a0020
686#define FSTV0910_P2_RADJ_16APSK 0xf22a011f
687
688/* P2_AGCK32 */
689#define RSTV0910_P2_AGCK32 0xf22b
690#define FSTV0910_P2_R3ADJOFF_32APSK 0xf22b0080
691#define FSTV0910_P2_R2ADJOFF_32APSK 0xf22b0040
692#define FSTV0910_P2_R1ADJOFF_32APSK 0xf22b0020
693#define FSTV0910_P2_RADJ_32APSK 0xf22b011f
694
695/* P2_AGC2O */
696#define RSTV0910_P2_AGC2O 0xf22c
697#define FSTV0910_P2_CSTENV_MODE 0xf22c00c0
698#define FSTV0910_P2_AGC2_COEF 0xf22c0007
699
700/* P2_AGC2REF */
701#define RSTV0910_P2_AGC2REF 0xf22d
702#define FSTV0910_P2_AGC2_REF 0xf22d00ff
703
704/* P2_AGC1ADJ */
705#define RSTV0910_P2_AGC1ADJ 0xf22e
706#define FSTV0910_P2_AGC1_ADJUSTED 0xf22e007f
707
708/* P2_AGCRSADJ */
709#define RSTV0910_P2_AGCRSADJ 0xf22f
710#define FSTV0910_P2_RS_ADJUSTED 0xf22f007f
711
712/* P2_AGCRQADJ */
713#define RSTV0910_P2_AGCRQADJ 0xf230
714#define FSTV0910_P2_RQ_ADJUSTED 0xf230007f
715
716/* P2_AGCR8ADJ */
717#define RSTV0910_P2_AGCR8ADJ 0xf231
718#define FSTV0910_P2_R8_ADJUSTED 0xf231007f
719
720/* P2_AGCR1ADJ */
721#define RSTV0910_P2_AGCR1ADJ 0xf232
722#define FSTV0910_P2_R1_ADJUSTED 0xf232007f
723
724/* P2_AGCR2ADJ */
725#define RSTV0910_P2_AGCR2ADJ 0xf233
726#define FSTV0910_P2_R2_ADJUSTED 0xf233007f
727
728/* P2_AGCR3ADJ */
729#define RSTV0910_P2_AGCR3ADJ 0xf234
730#define FSTV0910_P2_R3_ADJUSTED 0xf234007f
731
732/* P2_AGCREFADJ */
733#define RSTV0910_P2_AGCREFADJ 0xf235
734#define FSTV0910_P2_AGC2REF_ADJUSTED 0xf235007f
735
736/* P2_AGC2I1 */
737#define RSTV0910_P2_AGC2I1 0xf236
738#define FSTV0910_P2_AGC2_INTEGRATOR1 0xf23600ff
739
740/* P2_AGC2I0 */
741#define RSTV0910_P2_AGC2I0 0xf237
742#define FSTV0910_P2_AGC2_INTEGRATOR0 0xf23700ff
743
744/* P2_CARCFG */
745#define RSTV0910_P2_CARCFG 0xf238
746#define FSTV0910_P2_ROTAON 0xf2380004
747#define FSTV0910_P2_PH_DET_ALGO 0xf2380003
748
749/* P2_ACLC */
750#define RSTV0910_P2_ACLC 0xf239
751#define FSTV0910_P2_CAR_ALPHA_MANT 0xf2390030
752#define FSTV0910_P2_CAR_ALPHA_EXP 0xf239000f
753
754/* P2_BCLC */
755#define RSTV0910_P2_BCLC 0xf23a
756#define FSTV0910_P2_CAR_BETA_MANT 0xf23a0030
757#define FSTV0910_P2_CAR_BETA_EXP 0xf23a000f
758
759/* P2_ACLCS2 */
760#define RSTV0910_P2_ACLCS2 0xf23b
761#define FSTV0910_P2_CARS2_APLHA_MANTISSE 0xf23b0030
762#define FSTV0910_P2_CARS2_ALPHA_EXP 0xf23b000f
763
764/* P2_BCLCS2 */
765#define RSTV0910_P2_BCLCS2 0xf23c
766#define FSTV0910_P2_CARS2_BETA_MANTISSE 0xf23c0030
767#define FSTV0910_P2_CARS2_BETA_EXP 0xf23c000f
768
769/* P2_CARFREQ */
770#define RSTV0910_P2_CARFREQ 0xf23d
771#define FSTV0910_P2_KC_COARSE_EXP 0xf23d00f0
772#define FSTV0910_P2_BETA_FREQ 0xf23d000f
773
774/* P2_CARHDR */
775#define RSTV0910_P2_CARHDR 0xf23e
776#define FSTV0910_P2_K_FREQ_HDR 0xf23e00ff
777
778/* P2_LDT */
779#define RSTV0910_P2_LDT 0xf23f
780#define FSTV0910_P2_CARLOCK_THRES 0xf23f01ff
781
782/* P2_LDT2 */
783#define RSTV0910_P2_LDT2 0xf240
784#define FSTV0910_P2_CARLOCK_THRES2 0xf24001ff
785
786/* P2_CFRICFG */
787#define RSTV0910_P2_CFRICFG 0xf241
788#define FSTV0910_P2_NEG_CFRSTEP 0xf2410001
789
790/* P2_CFRUP1 */
791#define RSTV0910_P2_CFRUP1 0xf242
792#define FSTV0910_P2_CFR_UP1 0xf24201ff
793
794/* P2_CFRUP0 */
795#define RSTV0910_P2_CFRUP0 0xf243
796#define FSTV0910_P2_CFR_UP0 0xf24300ff
797
798/* P2_CFRIBASE1 */
799#define RSTV0910_P2_CFRIBASE1 0xf244
800#define FSTV0910_P2_CFRINIT_BASE1 0xf24400ff
801
802/* P2_CFRIBASE0 */
803#define RSTV0910_P2_CFRIBASE0 0xf245
804#define FSTV0910_P2_CFRINIT_BASE0 0xf24500ff
805
806/* P2_CFRLOW1 */
807#define RSTV0910_P2_CFRLOW1 0xf246
808#define FSTV0910_P2_CFR_LOW1 0xf24601ff
809
810/* P2_CFRLOW0 */
811#define RSTV0910_P2_CFRLOW0 0xf247
812#define FSTV0910_P2_CFR_LOW0 0xf24700ff
813
814/* P2_CFRINIT1 */
815#define RSTV0910_P2_CFRINIT1 0xf248
816#define FSTV0910_P2_CFR_INIT1 0xf24801ff
817
818/* P2_CFRINIT0 */
819#define RSTV0910_P2_CFRINIT0 0xf249
820#define FSTV0910_P2_CFR_INIT0 0xf24900ff
821
822/* P2_CFRINC1 */
823#define RSTV0910_P2_CFRINC1 0xf24a
824#define FSTV0910_P2_MANUAL_CFRINC 0xf24a0080
825#define FSTV0910_P2_CFR_INC1 0xf24a003f
826
827/* P2_CFRINC0 */
828#define RSTV0910_P2_CFRINC0 0xf24b
829#define FSTV0910_P2_CFR_INC0 0xf24b00ff
830
831/* P2_CFR2 */
832#define RSTV0910_P2_CFR2 0xf24c
833#define FSTV0910_P2_CAR_FREQ2 0xf24c01ff
834
835/* P2_CFR1 */
836#define RSTV0910_P2_CFR1 0xf24d
837#define FSTV0910_P2_CAR_FREQ1 0xf24d00ff
838
839/* P2_CFR0 */
840#define RSTV0910_P2_CFR0 0xf24e
841#define FSTV0910_P2_CAR_FREQ0 0xf24e00ff
842
843/* P2_LDI */
844#define RSTV0910_P2_LDI 0xf24f
845#define FSTV0910_P2_LOCK_DET_INTEGR 0xf24f01ff
846
847/* P2_TMGCFG */
848#define RSTV0910_P2_TMGCFG 0xf250
849#define FSTV0910_P2_TMGLOCK_BETA 0xf25000c0
850#define FSTV0910_P2_DO_TIMING_CORR 0xf2500010
851#define FSTV0910_P2_TMG_MINFREQ 0xf2500003
852
853/* P2_RTC */
854#define RSTV0910_P2_RTC 0xf251
855#define FSTV0910_P2_TMGALPHA_EXP 0xf25100f0
856#define FSTV0910_P2_TMGBETA_EXP 0xf251000f
857
858/* P2_RTCS2 */
859#define RSTV0910_P2_RTCS2 0xf252
860#define FSTV0910_P2_TMGALPHAS2_EXP 0xf25200f0
861#define FSTV0910_P2_TMGBETAS2_EXP 0xf252000f
862
863/* P2_TMGTHRISE */
864#define RSTV0910_P2_TMGTHRISE 0xf253
865#define FSTV0910_P2_TMGLOCK_THRISE 0xf25300ff
866
867/* P2_TMGTHFALL */
868#define RSTV0910_P2_TMGTHFALL 0xf254
869#define FSTV0910_P2_TMGLOCK_THFALL 0xf25400ff
870
871/* P2_SFRUPRATIO */
872#define RSTV0910_P2_SFRUPRATIO 0xf255
873#define FSTV0910_P2_SFR_UPRATIO 0xf25500ff
874
875/* P2_SFRLOWRATIO */
876#define RSTV0910_P2_SFRLOWRATIO 0xf256
877#define FSTV0910_P2_SFR_LOWRATIO 0xf25600ff
878
879/* P2_KTTMG */
880#define RSTV0910_P2_KTTMG 0xf257
881#define FSTV0910_P2_KT_TMG_EXP 0xf25700f0
882
883/* P2_KREFTMG */
884#define RSTV0910_P2_KREFTMG 0xf258
885#define FSTV0910_P2_KREF_TMG 0xf25800ff
886
887/* P2_SFRSTEP */
888#define RSTV0910_P2_SFRSTEP 0xf259
889#define FSTV0910_P2_SFR_SCANSTEP 0xf25900f0
890#define FSTV0910_P2_SFR_CENTERSTEP 0xf259000f
891
892/* P2_TMGCFG2 */
893#define RSTV0910_P2_TMGCFG2 0xf25a
894#define FSTV0910_P2_DIS_AUTOSAMP 0xf25a0008
895#define FSTV0910_P2_SFRRATIO_FINE 0xf25a0001
896
897/* P2_KREFTMG2 */
898#define RSTV0910_P2_KREFTMG2 0xf25b
899#define FSTV0910_P2_KREF_TMG2 0xf25b00ff
900
901/* P2_TMGCFG3 */
902#define RSTV0910_P2_TMGCFG3 0xf25d
903#define FSTV0910_P2_CONT_TMGCENTER 0xf25d0008
904#define FSTV0910_P2_AUTO_GUP 0xf25d0004
905#define FSTV0910_P2_AUTO_GLOW 0xf25d0002
906
907/* P2_SFRINIT1 */
908#define RSTV0910_P2_SFRINIT1 0xf25e
909#define FSTV0910_P2_SFR_INIT1 0xf25e00ff
910
911/* P2_SFRINIT0 */
912#define RSTV0910_P2_SFRINIT0 0xf25f
913#define FSTV0910_P2_SFR_INIT0 0xf25f00ff
914
915/* P2_SFRUP1 */
916#define RSTV0910_P2_SFRUP1 0xf260
917#define FSTV0910_P2_SYMB_FREQ_UP1 0xf26000ff
918
919/* P2_SFRUP0 */
920#define RSTV0910_P2_SFRUP0 0xf261
921#define FSTV0910_P2_SYMB_FREQ_UP0 0xf26100ff
922
923/* P2_SFRLOW1 */
924#define RSTV0910_P2_SFRLOW1 0xf262
925#define FSTV0910_P2_SYMB_FREQ_LOW1 0xf26200ff
926
927/* P2_SFRLOW0 */
928#define RSTV0910_P2_SFRLOW0 0xf263
929#define FSTV0910_P2_SYMB_FREQ_LOW0 0xf26300ff
930
931/* P2_SFR3 */
932#define RSTV0910_P2_SFR3 0xf264
933#define FSTV0910_P2_SYMB_FREQ3 0xf26400ff
934
935/* P2_SFR2 */
936#define RSTV0910_P2_SFR2 0xf265
937#define FSTV0910_P2_SYMB_FREQ2 0xf26500ff
938
939/* P2_SFR1 */
940#define RSTV0910_P2_SFR1 0xf266
941#define FSTV0910_P2_SYMB_FREQ1 0xf26600ff
942
943/* P2_SFR0 */
944#define RSTV0910_P2_SFR0 0xf267
945#define FSTV0910_P2_SYMB_FREQ0 0xf26700ff
946
947/* P2_TMGREG2 */
948#define RSTV0910_P2_TMGREG2 0xf268
949#define FSTV0910_P2_TMGREG2 0xf26800ff
950
951/* P2_TMGREG1 */
952#define RSTV0910_P2_TMGREG1 0xf269
953#define FSTV0910_P2_TMGREG1 0xf26900ff
954
955/* P2_TMGREG0 */
956#define RSTV0910_P2_TMGREG0 0xf26a
957#define FSTV0910_P2_TMGREG0 0xf26a00ff
958
959/* P2_TMGLOCK1 */
960#define RSTV0910_P2_TMGLOCK1 0xf26b
961#define FSTV0910_P2_TMGLOCK_LEVEL1 0xf26b01ff
962
963/* P2_TMGLOCK0 */
964#define RSTV0910_P2_TMGLOCK0 0xf26c
965#define FSTV0910_P2_TMGLOCK_LEVEL0 0xf26c00ff
966
967/* P2_TMGOBS */
968#define RSTV0910_P2_TMGOBS 0xf26d
969#define FSTV0910_P2_ROLLOFF_STATUS 0xf26d00c0
970
971/* P2_EQUALCFG */
972#define RSTV0910_P2_EQUALCFG 0xf26f
973#define FSTV0910_P2_EQUAL_ON 0xf26f0040
974#define FSTV0910_P2_MU_EQUALDFE 0xf26f0007
975
976/* P2_EQUAI1 */
977#define RSTV0910_P2_EQUAI1 0xf270
978#define FSTV0910_P2_EQUA_ACCI1 0xf27001ff
979
980/* P2_EQUAQ1 */
981#define RSTV0910_P2_EQUAQ1 0xf271
982#define FSTV0910_P2_EQUA_ACCQ1 0xf27101ff
983
984/* P2_EQUAI2 */
985#define RSTV0910_P2_EQUAI2 0xf272
986#define FSTV0910_P2_EQUA_ACCI2 0xf27201ff
987
988/* P2_EQUAQ2 */
989#define RSTV0910_P2_EQUAQ2 0xf273
990#define FSTV0910_P2_EQUA_ACCQ2 0xf27301ff
991
992/* P2_EQUAI3 */
993#define RSTV0910_P2_EQUAI3 0xf274
994#define FSTV0910_P2_EQUA_ACCI3 0xf27401ff
995
996/* P2_EQUAQ3 */
997#define RSTV0910_P2_EQUAQ3 0xf275
998#define FSTV0910_P2_EQUA_ACCQ3 0xf27501ff
999
1000/* P2_EQUAI4 */
1001#define RSTV0910_P2_EQUAI4 0xf276
1002#define FSTV0910_P2_EQUA_ACCI4 0xf27601ff
1003
1004/* P2_EQUAQ4 */
1005#define RSTV0910_P2_EQUAQ4 0xf277
1006#define FSTV0910_P2_EQUA_ACCQ4 0xf27701ff
1007
1008/* P2_EQUAI5 */
1009#define RSTV0910_P2_EQUAI5 0xf278
1010#define FSTV0910_P2_EQUA_ACCI5 0xf27801ff
1011
1012/* P2_EQUAQ5 */
1013#define RSTV0910_P2_EQUAQ5 0xf279
1014#define FSTV0910_P2_EQUA_ACCQ5 0xf27901ff
1015
1016/* P2_EQUAI6 */
1017#define RSTV0910_P2_EQUAI6 0xf27a
1018#define FSTV0910_P2_EQUA_ACCI6 0xf27a01ff
1019
1020/* P2_EQUAQ6 */
1021#define RSTV0910_P2_EQUAQ6 0xf27b
1022#define FSTV0910_P2_EQUA_ACCQ6 0xf27b01ff
1023
1024/* P2_EQUAI7 */
1025#define RSTV0910_P2_EQUAI7 0xf27c
1026#define FSTV0910_P2_EQUA_ACCI7 0xf27c01ff
1027
1028/* P2_EQUAQ7 */
1029#define RSTV0910_P2_EQUAQ7 0xf27d
1030#define FSTV0910_P2_EQUA_ACCQ7 0xf27d01ff
1031
1032/* P2_EQUAI8 */
1033#define RSTV0910_P2_EQUAI8 0xf27e
1034#define FSTV0910_P2_EQUA_ACCI8 0xf27e01ff
1035
1036/* P2_EQUAQ8 */
1037#define RSTV0910_P2_EQUAQ8 0xf27f
1038#define FSTV0910_P2_EQUA_ACCQ8 0xf27f01ff
1039
1040/* P2_NNOSDATAT1 */
1041#define RSTV0910_P2_NNOSDATAT1 0xf280
1042#define FSTV0910_P2_NOSDATAT_NORMED1 0xf28000ff
1043
1044/* P2_NNOSDATAT0 */
1045#define RSTV0910_P2_NNOSDATAT0 0xf281
1046#define FSTV0910_P2_NOSDATAT_NORMED0 0xf28100ff
1047
1048/* P2_NNOSDATA1 */
1049#define RSTV0910_P2_NNOSDATA1 0xf282
1050#define FSTV0910_P2_NOSDATA_NORMED1 0xf28200ff
1051
1052/* P2_NNOSDATA0 */
1053#define RSTV0910_P2_NNOSDATA0 0xf283
1054#define FSTV0910_P2_NOSDATA_NORMED0 0xf28300ff
1055
1056/* P2_NNOSPLHT1 */
1057#define RSTV0910_P2_NNOSPLHT1 0xf284
1058#define FSTV0910_P2_NOSPLHT_NORMED1 0xf28400ff
1059
1060/* P2_NNOSPLHT0 */
1061#define RSTV0910_P2_NNOSPLHT0 0xf285
1062#define FSTV0910_P2_NOSPLHT_NORMED0 0xf28500ff
1063
1064/* P2_NNOSPLH1 */
1065#define RSTV0910_P2_NNOSPLH1 0xf286
1066#define FSTV0910_P2_NOSPLH_NORMED1 0xf28600ff
1067
1068/* P2_NNOSPLH0 */
1069#define RSTV0910_P2_NNOSPLH0 0xf287
1070#define FSTV0910_P2_NOSPLH_NORMED0 0xf28700ff
1071
1072/* P2_NOSDATAT1 */
1073#define RSTV0910_P2_NOSDATAT1 0xf288
1074#define FSTV0910_P2_NOSDATAT_UNNORMED1 0xf28800ff
1075
1076/* P2_NOSDATAT0 */
1077#define RSTV0910_P2_NOSDATAT0 0xf289
1078#define FSTV0910_P2_NOSDATAT_UNNORMED0 0xf28900ff
1079
1080/* P2_NNOSFRAME1 */
1081#define RSTV0910_P2_NNOSFRAME1 0xf28a
1082#define FSTV0910_P2_NOSFRAME_NORMED1 0xf28a00ff
1083
1084/* P2_NNOSFRAME0 */
1085#define RSTV0910_P2_NNOSFRAME0 0xf28b
1086#define FSTV0910_P2_NOSFRAME_NORMED0 0xf28b00ff
1087
1088/* P2_NNOSRAD1 */
1089#define RSTV0910_P2_NNOSRAD1 0xf28c
1090#define FSTV0910_P2_NOSRADIAL_NORMED1 0xf28c00ff
1091
1092/* P2_NNOSRAD0 */
1093#define RSTV0910_P2_NNOSRAD0 0xf28d
1094#define FSTV0910_P2_NOSRADIAL_NORMED0 0xf28d00ff
1095
1096/* P2_NOSCFGF1 */
1097#define RSTV0910_P2_NOSCFGF1 0xf28e
1098#define FSTV0910_P2_LOWNOISE_MESURE 0xf28e0080
1099#define FSTV0910_P2_NOS_DELFRAME 0xf28e0040
1100#define FSTV0910_P2_NOSDATA_MODE 0xf28e0030
1101#define FSTV0910_P2_FRAMESEL_TYPESEL 0xf28e000c
1102#define FSTV0910_P2_FRAMESEL_TYPE 0xf28e0003
1103
1104/* P2_NOSCFGF2 */
1105#define RSTV0910_P2_NOSCFGF2 0xf28f
1106#define FSTV0910_P2_DIS_NOSPILOTS 0xf28f0080
1107#define FSTV0910_P2_FRAMESEL_MODCODSEL 0xf28f0060
1108#define FSTV0910_P2_FRAMESEL_MODCOD 0xf28f001f
1109
1110/* P2_CAR2CFG */
1111#define RSTV0910_P2_CAR2CFG 0xf290
1112#define FSTV0910_P2_ROTA2ON 0xf2900004
1113#define FSTV0910_P2_PH_DET_ALGO2 0xf2900003
1114
1115/* P2_CFR2CFR1 */
1116#define RSTV0910_P2_CFR2CFR1 0xf291
1117#define FSTV0910_P2_EN_S2CAR2CENTER 0xf2910020
1118#define FSTV0910_P2_CFR2TOCFR1_BETA 0xf2910007
1119
1120/* P2_CAR3CFG */
1121#define RSTV0910_P2_CAR3CFG 0xf292
1122#define FSTV0910_P2_CARRIER23_MODE 0xf29200c0
1123#define FSTV0910_P2_CAR3INTERM_DVBS1 0xf2920020
1124#define FSTV0910_P2_ABAMPLIF_MODE 0xf2920018
1125#define FSTV0910_P2_CARRIER3_ALPHA3DL 0xf2920007
1126
1127/* P2_CFR22 */
1128#define RSTV0910_P2_CFR22 0xf293
1129#define FSTV0910_P2_CAR2_FREQ2 0xf29301ff
1130
1131/* P2_CFR21 */
1132#define RSTV0910_P2_CFR21 0xf294
1133#define FSTV0910_P2_CAR2_FREQ1 0xf29400ff
1134
1135/* P2_CFR20 */
1136#define RSTV0910_P2_CFR20 0xf295
1137#define FSTV0910_P2_CAR2_FREQ0 0xf29500ff
1138
1139/* P2_ACLC2S2Q */
1140#define RSTV0910_P2_ACLC2S2Q 0xf297
1141#define FSTV0910_P2_ENAB_SPSKSYMB 0xf2970080
1142#define FSTV0910_P2_CAR2S2_Q_ALPH_M 0xf2970030
1143#define FSTV0910_P2_CAR2S2_Q_ALPH_E 0xf297000f
1144
1145/* P2_ACLC2S28 */
1146#define RSTV0910_P2_ACLC2S28 0xf298
1147#define FSTV0910_P2_CAR2S2_8_ALPH_M 0xf2980030
1148#define FSTV0910_P2_CAR2S2_8_ALPH_E 0xf298000f
1149
1150/* P2_ACLC2S216A */
1151#define RSTV0910_P2_ACLC2S216A 0xf299
1152#define FSTV0910_P2_CAR2S2_16A_ALPH_M 0xf2990030
1153#define FSTV0910_P2_CAR2S2_16A_ALPH_E 0xf299000f
1154
1155/* P2_ACLC2S232A */
1156#define RSTV0910_P2_ACLC2S232A 0xf29a
1157#define FSTV0910_P2_CAR2S2_32A_ALPH_M 0xf29a0030
1158#define FSTV0910_P2_CAR2S2_32A_ALPH_E 0xf29a000f
1159
1160/* P2_BCLC2S2Q */
1161#define RSTV0910_P2_BCLC2S2Q 0xf29c
1162#define FSTV0910_P2_CAR2S2_Q_BETA_M 0xf29c0030
1163#define FSTV0910_P2_CAR2S2_Q_BETA_E 0xf29c000f
1164
1165/* P2_BCLC2S28 */
1166#define RSTV0910_P2_BCLC2S28 0xf29d
1167#define FSTV0910_P2_CAR2S2_8_BETA_M 0xf29d0030
1168#define FSTV0910_P2_CAR2S2_8_BETA_E 0xf29d000f
1169
1170/* P2_BCLC2S216A */
1171#define RSTV0910_P2_BCLC2S216A 0xf29e
1172#define FSTV0910_P2_DVBS2S216A_NIP 0xf29e0080
1173#define FSTV0910_P2_CAR2S2_16A_BETA_M 0xf29e0030
1174#define FSTV0910_P2_CAR2S2_16A_BETA_E 0xf29e000f
1175
1176/* P2_BCLC2S232A */
1177#define RSTV0910_P2_BCLC2S232A 0xf29f
1178#define FSTV0910_P2_DVBS2S232A_NIP 0xf29f0080
1179#define FSTV0910_P2_CAR2S2_32A_BETA_M 0xf29f0030
1180#define FSTV0910_P2_CAR2S2_32A_BETA_E 0xf29f000f
1181
1182/* P2_PLROOT2 */
1183#define RSTV0910_P2_PLROOT2 0xf2ac
1184#define FSTV0910_P2_PLSCRAMB_MODE 0xf2ac000c
1185#define FSTV0910_P2_PLSCRAMB_ROOT2 0xf2ac0003
1186
1187/* P2_PLROOT1 */
1188#define RSTV0910_P2_PLROOT1 0xf2ad
1189#define FSTV0910_P2_PLSCRAMB_ROOT1 0xf2ad00ff
1190
1191/* P2_PLROOT0 */
1192#define RSTV0910_P2_PLROOT0 0xf2ae
1193#define FSTV0910_P2_PLSCRAMB_ROOT0 0xf2ae00ff
1194
1195/* P2_MODCODLST0 */
1196#define RSTV0910_P2_MODCODLST0 0xf2b0
1197#define FSTV0910_P2_NACCES_MODCODCH 0xf2b00001
1198
1199/* P2_MODCODLST1 */
1200#define RSTV0910_P2_MODCODLST1 0xf2b1
1201#define FSTV0910_P2_SYMBRATE_FILTER 0xf2b10008
1202#define FSTV0910_P2_NRESET_MODCODLST 0xf2b10004
1203#define FSTV0910_P2_DIS_32PSK_9_10 0xf2b10003
1204
1205/* P2_MODCODLST2 */
1206#define RSTV0910_P2_MODCODLST2 0xf2b2
1207#define FSTV0910_P2_DIS_32PSK_8_9 0xf2b200f0
1208#define FSTV0910_P2_DIS_32PSK_5_6 0xf2b2000f
1209
1210/* P2_MODCODLST3 */
1211#define RSTV0910_P2_MODCODLST3 0xf2b3
1212#define FSTV0910_P2_DIS_32PSK_4_5 0xf2b300f0
1213#define FSTV0910_P2_DIS_32PSK_3_4 0xf2b3000f
1214
1215/* P2_MODCODLST4 */
1216#define RSTV0910_P2_MODCODLST4 0xf2b4
1217#define FSTV0910_P2_DUMMYPL_PILOT 0xf2b40080
1218#define FSTV0910_P2_DUMMYPL_NOPILOT 0xf2b40040
1219#define FSTV0910_P2_DIS_16PSK_9_10 0xf2b40030
1220#define FSTV0910_P2_DIS_16PSK_8_9 0xf2b4000f
1221
1222/* P2_MODCODLST5 */
1223#define RSTV0910_P2_MODCODLST5 0xf2b5
1224#define FSTV0910_P2_DIS_16PSK_5_6 0xf2b500f0
1225#define FSTV0910_P2_DIS_16PSK_4_5 0xf2b5000f
1226
1227/* P2_MODCODLST6 */
1228#define RSTV0910_P2_MODCODLST6 0xf2b6
1229#define FSTV0910_P2_DIS_16PSK_3_4 0xf2b600f0
1230#define FSTV0910_P2_DIS_16PSK_2_3 0xf2b6000f
1231
1232/* P2_MODCODLST7 */
1233#define RSTV0910_P2_MODCODLST7 0xf2b7
1234#define FSTV0910_P2_MODCOD_NNOSFILTER 0xf2b70080
1235#define FSTV0910_P2_DIS_8PSK_9_10 0xf2b70030
1236#define FSTV0910_P2_DIS_8PSK_8_9 0xf2b7000f
1237
1238/* P2_MODCODLST8 */
1239#define RSTV0910_P2_MODCODLST8 0xf2b8
1240#define FSTV0910_P2_DIS_8PSK_5_6 0xf2b800f0
1241#define FSTV0910_P2_DIS_8PSK_3_4 0xf2b8000f
1242
1243/* P2_MODCODLST9 */
1244#define RSTV0910_P2_MODCODLST9 0xf2b9
1245#define FSTV0910_P2_DIS_8PSK_2_3 0xf2b900f0
1246#define FSTV0910_P2_DIS_8PSK_3_5 0xf2b9000f
1247
1248/* P2_MODCODLSTA */
1249#define RSTV0910_P2_MODCODLSTA 0xf2ba
1250#define FSTV0910_P2_NOSFILTER_LIMITE 0xf2ba0080
1251#define FSTV0910_P2_DIS_QPSK_9_10 0xf2ba0030
1252#define FSTV0910_P2_DIS_QPSK_8_9 0xf2ba000f
1253
1254/* P2_MODCODLSTB */
1255#define RSTV0910_P2_MODCODLSTB 0xf2bb
1256#define FSTV0910_P2_DIS_QPSK_5_6 0xf2bb00f0
1257#define FSTV0910_P2_DIS_QPSK_4_5 0xf2bb000f
1258
1259/* P2_MODCODLSTC */
1260#define RSTV0910_P2_MODCODLSTC 0xf2bc
1261#define FSTV0910_P2_DIS_QPSK_3_4 0xf2bc00f0
1262#define FSTV0910_P2_DIS_QPSK_2_3 0xf2bc000f
1263
1264/* P2_MODCODLSTD */
1265#define RSTV0910_P2_MODCODLSTD 0xf2bd
1266#define FSTV0910_P2_DIS_QPSK_3_5 0xf2bd00f0
1267#define FSTV0910_P2_DIS_QPSK_1_2 0xf2bd000f
1268
1269/* P2_MODCODLSTE */
1270#define RSTV0910_P2_MODCODLSTE 0xf2be
1271#define FSTV0910_P2_DIS_QPSK_2_5 0xf2be00f0
1272#define FSTV0910_P2_DIS_QPSK_1_3 0xf2be000f
1273
1274/* P2_MODCODLSTF */
1275#define RSTV0910_P2_MODCODLSTF 0xf2bf
1276#define FSTV0910_P2_DIS_QPSK_1_4 0xf2bf00f0
1277#define FSTV0910_P2_DEMOD_INVMODLST 0xf2bf0008
1278#define FSTV0910_P2_DEMODOUT_ENABLE 0xf2bf0004
1279#define FSTV0910_P2_DDEMOD_NSET 0xf2bf0002
1280#define FSTV0910_P2_MODCOD_NSTOCK 0xf2bf0001
1281
1282/* P2_GAUSSR0 */
1283#define RSTV0910_P2_GAUSSR0 0xf2c0
1284#define FSTV0910_P2_EN_CCIMODE 0xf2c00080
1285#define FSTV0910_P2_R0_GAUSSIEN 0xf2c0007f
1286
1287/* P2_CCIR0 */
1288#define RSTV0910_P2_CCIR0 0xf2c1
1289#define FSTV0910_P2_CCIDETECT_PLHONLY 0xf2c10080
1290#define FSTV0910_P2_R0_CCI 0xf2c1007f
1291
1292/* P2_CCIQUANT */
1293#define RSTV0910_P2_CCIQUANT 0xf2c2
1294#define FSTV0910_P2_CCI_BETA 0xf2c200e0
1295#define FSTV0910_P2_CCI_QUANT 0xf2c2001f
1296
1297/* P2_CCITHRES */
1298#define RSTV0910_P2_CCITHRES 0xf2c3
1299#define FSTV0910_P2_CCI_THRESHOLD 0xf2c300ff
1300
1301/* P2_CCIACC */
1302#define RSTV0910_P2_CCIACC 0xf2c4
1303#define FSTV0910_P2_CCI_VALUE 0xf2c400ff
1304
1305/* P2_DSTATUS4 */
1306#define RSTV0910_P2_DSTATUS4 0xf2c5
1307#define FSTV0910_P2_RAINFADE_DETECT 0xf2c50080
1308#define FSTV0910_P2_NOTHRES2_FAIL 0xf2c50040
1309#define FSTV0910_P2_NOTHRES1_FAIL 0xf2c50020
1310#define FSTV0910_P2_DMDPROG_ERROR 0xf2c50004
1311#define FSTV0910_P2_CSTENV_DETECT 0xf2c50002
1312#define FSTV0910_P2_DETECTION_TRIAX 0xf2c50001
1313
1314/* P2_DMDRESCFG */
1315#define RSTV0910_P2_DMDRESCFG 0xf2c6
1316#define FSTV0910_P2_DMDRES_RESET 0xf2c60080
1317#define FSTV0910_P2_DMDRES_STRALL 0xf2c60008
1318#define FSTV0910_P2_DMDRES_NEWONLY 0xf2c60004
1319#define FSTV0910_P2_DMDRES_NOSTORE 0xf2c60002
1320
1321/* P2_DMDRESADR */
1322#define RSTV0910_P2_DMDRESADR 0xf2c7
1323#define FSTV0910_P2_DMDRES_VALIDCFR 0xf2c70040
1324#define FSTV0910_P2_DMDRES_MEMFULL 0xf2c70030
1325#define FSTV0910_P2_DMDRES_RESNBR 0xf2c7000f
1326
1327/* P2_DMDRESDATA7 */
1328#define RSTV0910_P2_DMDRESDATA7 0xf2c8
1329#define FSTV0910_P2_DMDRES_DATA7 0xf2c800ff
1330
1331/* P2_DMDRESDATA6 */
1332#define RSTV0910_P2_DMDRESDATA6 0xf2c9
1333#define FSTV0910_P2_DMDRES_DATA6 0xf2c900ff
1334
1335/* P2_DMDRESDATA5 */
1336#define RSTV0910_P2_DMDRESDATA5 0xf2ca
1337#define FSTV0910_P2_DMDRES_DATA5 0xf2ca00ff
1338
1339/* P2_DMDRESDATA4 */
1340#define RSTV0910_P2_DMDRESDATA4 0xf2cb
1341#define FSTV0910_P2_DMDRES_DATA4 0xf2cb00ff
1342
1343/* P2_DMDRESDATA3 */
1344#define RSTV0910_P2_DMDRESDATA3 0xf2cc
1345#define FSTV0910_P2_DMDRES_DATA3 0xf2cc00ff
1346
1347/* P2_DMDRESDATA2 */
1348#define RSTV0910_P2_DMDRESDATA2 0xf2cd
1349#define FSTV0910_P2_DMDRES_DATA2 0xf2cd00ff
1350
1351/* P2_DMDRESDATA1 */
1352#define RSTV0910_P2_DMDRESDATA1 0xf2ce
1353#define FSTV0910_P2_DMDRES_DATA1 0xf2ce00ff
1354
1355/* P2_DMDRESDATA0 */
1356#define RSTV0910_P2_DMDRESDATA0 0xf2cf
1357#define FSTV0910_P2_DMDRES_DATA0 0xf2cf00ff
1358
1359/* P2_FFEI1 */
1360#define RSTV0910_P2_FFEI1 0xf2d0
1361#define FSTV0910_P2_FFE_ACCI1 0xf2d001ff
1362
1363/* P2_FFEQ1 */
1364#define RSTV0910_P2_FFEQ1 0xf2d1
1365#define FSTV0910_P2_FFE_ACCQ1 0xf2d101ff
1366
1367/* P2_FFEI2 */
1368#define RSTV0910_P2_FFEI2 0xf2d2
1369#define FSTV0910_P2_FFE_ACCI2 0xf2d201ff
1370
1371/* P2_FFEQ2 */
1372#define RSTV0910_P2_FFEQ2 0xf2d3
1373#define FSTV0910_P2_FFE_ACCQ2 0xf2d301ff
1374
1375/* P2_FFEI3 */
1376#define RSTV0910_P2_FFEI3 0xf2d4
1377#define FSTV0910_P2_FFE_ACCI3 0xf2d401ff
1378
1379/* P2_FFEQ3 */
1380#define RSTV0910_P2_FFEQ3 0xf2d5
1381#define FSTV0910_P2_FFE_ACCQ3 0xf2d501ff
1382
1383/* P2_FFEI4 */
1384#define RSTV0910_P2_FFEI4 0xf2d6
1385#define FSTV0910_P2_FFE_ACCI4 0xf2d601ff
1386
1387/* P2_FFEQ4 */
1388#define RSTV0910_P2_FFEQ4 0xf2d7
1389#define FSTV0910_P2_FFE_ACCQ4 0xf2d701ff
1390
1391/* P2_FFECFG */
1392#define RSTV0910_P2_FFECFG 0xf2d8
1393#define FSTV0910_P2_EQUALFFE_ON 0xf2d80040
1394#define FSTV0910_P2_EQUAL_USEDSYMB 0xf2d80030
1395#define FSTV0910_P2_MU_EQUALFFE 0xf2d80007
1396
1397/* P2_TNRCFG2 */
1398#define RSTV0910_P2_TNRCFG2 0xf2e1
1399#define FSTV0910_P2_TUN_IQSWAP 0xf2e10080
1400
1401/* P2_SMAPCOEF7 */
1402#define RSTV0910_P2_SMAPCOEF7 0xf300
1403#define FSTV0910_P2_DIS_QSCALE 0xf3000080
1404#define FSTV0910_P2_SMAPCOEF_Q_LLR12 0xf300017f
1405
1406/* P2_SMAPCOEF6 */
1407#define RSTV0910_P2_SMAPCOEF6 0xf301
1408#define FSTV0910_P2_DIS_AGC2SCALE 0xf3010080
1409#define FSTV0910_P2_ADJ_8PSKLLR1 0xf3010004
1410#define FSTV0910_P2_OLD_8PSKLLR1 0xf3010002
1411#define FSTV0910_P2_DIS_AB8PSK 0xf3010001
1412
1413/* P2_SMAPCOEF5 */
1414#define RSTV0910_P2_SMAPCOEF5 0xf302
1415#define FSTV0910_P2_DIS_8SCALE 0xf3020080
1416#define FSTV0910_P2_SMAPCOEF_8P_LLR23 0xf302017f
1417
1418/* P2_SMAPCOEF4 */
1419#define RSTV0910_P2_SMAPCOEF4 0xf303
1420#define FSTV0910_P2_SMAPCOEF_16APSK_LLR12 0xf303017f
1421
1422/* P2_SMAPCOEF3 */
1423#define RSTV0910_P2_SMAPCOEF3 0xf304
1424#define FSTV0910_P2_SMAPCOEF_16APSK_LLR34 0xf304017f
1425
1426/* P2_SMAPCOEF2 */
1427#define RSTV0910_P2_SMAPCOEF2 0xf305
1428#define FSTV0910_P2_SMAPCOEF_32APSK_R2R3 0xf30501f0
1429#define FSTV0910_P2_SMAPCOEF_32APSK_LLR2 0xf305010f
1430
1431/* P2_SMAPCOEF1 */
1432#define RSTV0910_P2_SMAPCOEF1 0xf306
1433#define FSTV0910_P2_DIS_16SCALE 0xf3060080
1434#define FSTV0910_P2_SMAPCOEF_32_LLR34 0xf306017f
1435
1436/* P2_SMAPCOEF0 */
1437#define RSTV0910_P2_SMAPCOEF0 0xf307
1438#define FSTV0910_P2_DIS_32SCALE 0xf3070080
1439#define FSTV0910_P2_SMAPCOEF_32_LLR15 0xf307017f
1440
1441/* P2_NOSTHRES1 */
1442#define RSTV0910_P2_NOSTHRES1 0xf309
1443#define FSTV0910_P2_NOS_THRESHOLD1 0xf30900ff
1444
1445/* P2_NOSTHRES2 */
1446#define RSTV0910_P2_NOSTHRES2 0xf30a
1447#define FSTV0910_P2_NOS_THRESHOLD2 0xf30a00ff
1448
1449/* P2_NOSDIFF1 */
1450#define RSTV0910_P2_NOSDIFF1 0xf30b
1451#define FSTV0910_P2_NOSTHRES1_DIFF 0xf30b00ff
1452
1453/* P2_RAINFADE */
1454#define RSTV0910_P2_RAINFADE 0xf30c
1455#define FSTV0910_P2_NOSTHRES_DATAT 0xf30c0080
1456#define FSTV0910_P2_RAINFADE_CNLIMIT 0xf30c0070
1457#define FSTV0910_P2_RAINFADE_TIMEOUT 0xf30c0007
1458
1459/* P2_NOSRAMCFG */
1460#define RSTV0910_P2_NOSRAMCFG 0xf30d
1461#define FSTV0910_P2_NOSRAM_ACTIVATION 0xf30d0030
1462#define FSTV0910_P2_NOSRAM_CNRONLY 0xf30d0008
1463#define FSTV0910_P2_NOSRAM_LGNCNR1 0xf30d0007
1464
1465/* P2_NOSRAMPOS */
1466#define RSTV0910_P2_NOSRAMPOS 0xf30e
1467#define FSTV0910_P2_NOSRAM_LGNCNR0 0xf30e00f0
1468#define FSTV0910_P2_NOSRAM_VALIDE 0xf30e0004
1469#define FSTV0910_P2_NOSRAM_CNRVAL1 0xf30e0003
1470
1471/* P2_NOSRAMVAL */
1472#define RSTV0910_P2_NOSRAMVAL 0xf30f
1473#define FSTV0910_P2_NOSRAM_CNRVAL0 0xf30f00ff
1474
1475/* P2_DMDPLHSTAT */
1476#define RSTV0910_P2_DMDPLHSTAT 0xf320
1477#define FSTV0910_P2_PLH_STATISTIC 0xf32000ff
1478
1479/* P2_LOCKTIME3 */
1480#define RSTV0910_P2_LOCKTIME3 0xf322
1481#define FSTV0910_P2_DEMOD_LOCKTIME3 0xf32200ff
1482
1483/* P2_LOCKTIME2 */
1484#define RSTV0910_P2_LOCKTIME2 0xf323
1485#define FSTV0910_P2_DEMOD_LOCKTIME2 0xf32300ff
1486
1487/* P2_LOCKTIME1 */
1488#define RSTV0910_P2_LOCKTIME1 0xf324
1489#define FSTV0910_P2_DEMOD_LOCKTIME1 0xf32400ff
1490
1491/* P2_LOCKTIME0 */
1492#define RSTV0910_P2_LOCKTIME0 0xf325
1493#define FSTV0910_P2_DEMOD_LOCKTIME0 0xf32500ff
1494
1495/* P2_VITSCALE */
1496#define RSTV0910_P2_VITSCALE 0xf332
1497#define FSTV0910_P2_NVTH_NOSRANGE 0xf3320080
1498#define FSTV0910_P2_VERROR_MAXMODE 0xf3320040
1499#define FSTV0910_P2_NSLOWSN_LOCKED 0xf3320008
1500#define FSTV0910_P2_DIS_RSFLOCK 0xf3320002
1501
1502/* P2_FECM */
1503#define RSTV0910_P2_FECM 0xf333
1504#define FSTV0910_P2_DSS_DVB 0xf3330080
1505#define FSTV0910_P2_DSS_SRCH 0xf3330010
1506#define FSTV0910_P2_SYNCVIT 0xf3330002
1507#define FSTV0910_P2_IQINV 0xf3330001
1508
1509/* P2_VTH12 */
1510#define RSTV0910_P2_VTH12 0xf334
1511#define FSTV0910_P2_VTH12 0xf33400ff
1512
1513/* P2_VTH23 */
1514#define RSTV0910_P2_VTH23 0xf335
1515#define FSTV0910_P2_VTH23 0xf33500ff
1516
1517/* P2_VTH34 */
1518#define RSTV0910_P2_VTH34 0xf336
1519#define FSTV0910_P2_VTH34 0xf33600ff
1520
1521/* P2_VTH56 */
1522#define RSTV0910_P2_VTH56 0xf337
1523#define FSTV0910_P2_VTH56 0xf33700ff
1524
1525/* P2_VTH67 */
1526#define RSTV0910_P2_VTH67 0xf338
1527#define FSTV0910_P2_VTH67 0xf33800ff
1528
1529/* P2_VTH78 */
1530#define RSTV0910_P2_VTH78 0xf339
1531#define FSTV0910_P2_VTH78 0xf33900ff
1532
1533/* P2_VITCURPUN */
1534#define RSTV0910_P2_VITCURPUN 0xf33a
1535#define FSTV0910_P2_VIT_CURPUN 0xf33a001f
1536
1537/* P2_VERROR */
1538#define RSTV0910_P2_VERROR 0xf33b
1539#define FSTV0910_P2_REGERR_VIT 0xf33b00ff
1540
1541/* P2_PRVIT */
1542#define RSTV0910_P2_PRVIT 0xf33c
1543#define FSTV0910_P2_DIS_VTHLOCK 0xf33c0040
1544#define FSTV0910_P2_E7_8VIT 0xf33c0020
1545#define FSTV0910_P2_E6_7VIT 0xf33c0010
1546#define FSTV0910_P2_E5_6VIT 0xf33c0008
1547#define FSTV0910_P2_E3_4VIT 0xf33c0004
1548#define FSTV0910_P2_E2_3VIT 0xf33c0002
1549#define FSTV0910_P2_E1_2VIT 0xf33c0001
1550
1551/* P2_VAVSRVIT */
1552#define RSTV0910_P2_VAVSRVIT 0xf33d
1553#define FSTV0910_P2_AMVIT 0xf33d0080
1554#define FSTV0910_P2_FROZENVIT 0xf33d0040
1555#define FSTV0910_P2_SNVIT 0xf33d0030
1556#define FSTV0910_P2_TOVVIT 0xf33d000c
1557#define FSTV0910_P2_HYPVIT 0xf33d0003
1558
1559/* P2_VSTATUSVIT */
1560#define RSTV0910_P2_VSTATUSVIT 0xf33e
1561#define FSTV0910_P2_PRFVIT 0xf33e0010
1562#define FSTV0910_P2_LOCKEDVIT 0xf33e0008
1563
1564/* P2_VTHINUSE */
1565#define RSTV0910_P2_VTHINUSE 0xf33f
1566#define FSTV0910_P2_VIT_INUSE 0xf33f00ff
1567
1568/* P2_KDIV12 */
1569#define RSTV0910_P2_KDIV12 0xf340
1570#define FSTV0910_P2_K_DIVIDER_12 0xf340007f
1571
1572/* P2_KDIV23 */
1573#define RSTV0910_P2_KDIV23 0xf341
1574#define FSTV0910_P2_K_DIVIDER_23 0xf341007f
1575
1576/* P2_KDIV34 */
1577#define RSTV0910_P2_KDIV34 0xf342
1578#define FSTV0910_P2_K_DIVIDER_34 0xf342007f
1579
1580/* P2_KDIV56 */
1581#define RSTV0910_P2_KDIV56 0xf343
1582#define FSTV0910_P2_K_DIVIDER_56 0xf343007f
1583
1584/* P2_KDIV67 */
1585#define RSTV0910_P2_KDIV67 0xf344
1586#define FSTV0910_P2_K_DIVIDER_67 0xf344007f
1587
1588/* P2_KDIV78 */
1589#define RSTV0910_P2_KDIV78 0xf345
1590#define FSTV0910_P2_K_DIVIDER_78 0xf345007f
1591
1592/* P2_TSPIDFLT1 */
1593#define RSTV0910_P2_TSPIDFLT1 0xf346
1594#define FSTV0910_P2_PIDFLT_ADDR 0xf34600ff
1595
1596/* P2_TSPIDFLT0 */
1597#define RSTV0910_P2_TSPIDFLT0 0xf347
1598#define FSTV0910_P2_PIDFLT_DATA 0xf34700ff
1599
1600/* P2_PDELCTRL0 */
1601#define RSTV0910_P2_PDELCTRL0 0xf34f
1602#define FSTV0910_P2_ISIOBS_MODE 0xf34f0030
1603
1604/* P2_PDELCTRL1 */
1605#define RSTV0910_P2_PDELCTRL1 0xf350
1606#define FSTV0910_P2_INV_MISMASK 0xf3500080
1607#define FSTV0910_P2_FILTER_EN 0xf3500020
1608#define FSTV0910_P2_HYSTEN 0xf3500008
1609#define FSTV0910_P2_HYSTSWRST 0xf3500004
1610#define FSTV0910_P2_EN_MIS00 0xf3500002
1611#define FSTV0910_P2_ALGOSWRST 0xf3500001
1612
1613/* P2_PDELCTRL2 */
1614#define RSTV0910_P2_PDELCTRL2 0xf351
1615#define FSTV0910_P2_FORCE_CONTINUOUS 0xf3510080
1616#define FSTV0910_P2_RESET_UPKO_COUNT 0xf3510040
1617#define FSTV0910_P2_USER_PKTDELIN_NB 0xf3510020
1618#define FSTV0910_P2_FRAME_MODE 0xf3510002
1619
1620/* P2_HYSTTHRESH */
1621#define RSTV0910_P2_HYSTTHRESH 0xf354
1622#define FSTV0910_P2_DELIN_LOCKTHRES 0xf35400f0
1623#define FSTV0910_P2_DELIN_UNLOCKTHRES 0xf354000f
1624
1625/* P2_UPLCCST0 */
1626#define RSTV0910_P2_UPLCCST0 0xf358
1627#define FSTV0910_P2_UPL_CST0 0xf35800f8
1628#define FSTV0910_P2_UPL_MODE 0xf3580007
1629
1630/* P2_ISIENTRY */
1631#define RSTV0910_P2_ISIENTRY 0xf35e
1632#define FSTV0910_P2_ISI_ENTRY 0xf35e00ff
1633
1634/* P2_ISIBITENA */
1635#define RSTV0910_P2_ISIBITENA 0xf35f
1636#define FSTV0910_P2_ISI_BIT_EN 0xf35f00ff
1637
1638/* P2_MATSTR1 */
1639#define RSTV0910_P2_MATSTR1 0xf360
1640#define FSTV0910_P2_MATYPE_CURRENT1 0xf36000ff
1641
1642/* P2_MATSTR0 */
1643#define RSTV0910_P2_MATSTR0 0xf361
1644#define FSTV0910_P2_MATYPE_CURRENT0 0xf36100ff
1645
1646/* P2_UPLSTR1 */
1647#define RSTV0910_P2_UPLSTR1 0xf362
1648#define FSTV0910_P2_UPL_CURRENT1 0xf36200ff
1649
1650/* P2_UPLSTR0 */
1651#define RSTV0910_P2_UPLSTR0 0xf363
1652#define FSTV0910_P2_UPL_CURRENT0 0xf36300ff
1653
1654/* P2_DFLSTR1 */
1655#define RSTV0910_P2_DFLSTR1 0xf364
1656#define FSTV0910_P2_DFL_CURRENT1 0xf36400ff
1657
1658/* P2_DFLSTR0 */
1659#define RSTV0910_P2_DFLSTR0 0xf365
1660#define FSTV0910_P2_DFL_CURRENT0 0xf36500ff
1661
1662/* P2_SYNCSTR */
1663#define RSTV0910_P2_SYNCSTR 0xf366
1664#define FSTV0910_P2_SYNC_CURRENT 0xf36600ff
1665
1666/* P2_SYNCDSTR1 */
1667#define RSTV0910_P2_SYNCDSTR1 0xf367
1668#define FSTV0910_P2_SYNCD_CURRENT1 0xf36700ff
1669
1670/* P2_SYNCDSTR0 */
1671#define RSTV0910_P2_SYNCDSTR0 0xf368
1672#define FSTV0910_P2_SYNCD_CURRENT0 0xf36800ff
1673
1674/* P2_PDELSTATUS1 */
1675#define RSTV0910_P2_PDELSTATUS1 0xf369
1676#define FSTV0910_P2_PKTDELIN_DELOCK 0xf3690080
1677#define FSTV0910_P2_SYNCDUPDFL_BADDFL 0xf3690040
1678#define FSTV0910_P2_UNACCEPTED_STREAM 0xf3690010
1679#define FSTV0910_P2_BCH_ERROR_FLAG 0xf3690008
1680#define FSTV0910_P2_PKTDELIN_LOCK 0xf3690002
1681#define FSTV0910_P2_FIRST_LOCK 0xf3690001
1682
1683/* P2_PDELSTATUS2 */
1684#define RSTV0910_P2_PDELSTATUS2 0xf36a
1685#define FSTV0910_P2_FRAME_MODCOD 0xf36a007c
1686#define FSTV0910_P2_FRAME_TYPE 0xf36a0003
1687
1688/* P2_BBFCRCKO1 */
1689#define RSTV0910_P2_BBFCRCKO1 0xf36b
1690#define FSTV0910_P2_BBHCRC_KOCNT1 0xf36b00ff
1691
1692/* P2_BBFCRCKO0 */
1693#define RSTV0910_P2_BBFCRCKO0 0xf36c
1694#define FSTV0910_P2_BBHCRC_KOCNT0 0xf36c00ff
1695
1696/* P2_UPCRCKO1 */
1697#define RSTV0910_P2_UPCRCKO1 0xf36d
1698#define FSTV0910_P2_PKTCRC_KOCNT1 0xf36d00ff
1699
1700/* P2_UPCRCKO0 */
1701#define RSTV0910_P2_UPCRCKO0 0xf36e
1702#define FSTV0910_P2_PKTCRC_KOCNT0 0xf36e00ff
1703
1704/* P2_PDELCTRL3 */
1705#define RSTV0910_P2_PDELCTRL3 0xf36f
1706#define FSTV0910_P2_NOFIFO_BCHERR 0xf36f0020
1707#define FSTV0910_P2_PKTDELIN_DELACMERR 0xf36f0010
1708
1709/* P2_TSSTATEM */
1710#define RSTV0910_P2_TSSTATEM 0xf370
1711#define FSTV0910_P2_TSDIL_ON 0xf3700080
1712#define FSTV0910_P2_TSRS_ON 0xf3700020
1713#define FSTV0910_P2_TSDESCRAMB_ON 0xf3700010
1714#define FSTV0910_P2_TSFRAME_MODE 0xf3700008
1715#define FSTV0910_P2_TS_DISABLE 0xf3700004
1716#define FSTV0910_P2_TSACM_MODE 0xf3700002
1717#define FSTV0910_P2_TSOUT_NOSYNC 0xf3700001
1718
1719/* P2_TSSTATEL */
1720#define RSTV0910_P2_TSSTATEL 0xf371
1721#define FSTV0910_P2_TSNOSYNCBYTE 0xf3710080
1722#define FSTV0910_P2_TSPARITY_ON 0xf3710040
1723#define FSTV0910_P2_TSISSYI_ON 0xf3710008
1724#define FSTV0910_P2_TSNPD_ON 0xf3710004
1725#define FSTV0910_P2_TSCRC8_ON 0xf3710002
1726#define FSTV0910_P2_TSDSS_PACKET 0xf3710001
1727
1728/* P2_TSCFGH */
1729#define RSTV0910_P2_TSCFGH 0xf372
1730#define FSTV0910_P2_TSFIFO_DVBCI 0xf3720080
1731#define FSTV0910_P2_TSFIFO_SERIAL 0xf3720040
1732#define FSTV0910_P2_TSFIFO_TEIUPDATE 0xf3720020
1733#define FSTV0910_P2_TSFIFO_DUTY50 0xf3720010
1734#define FSTV0910_P2_TSFIFO_HSGNLOUT 0xf3720008
1735#define FSTV0910_P2_TSFIFO_ERRMODE 0xf3720006
1736#define FSTV0910_P2_RST_HWARE 0xf3720001
1737
1738/* P2_TSCFGM */
1739#define RSTV0910_P2_TSCFGM 0xf373
1740#define FSTV0910_P2_TSFIFO_MANSPEED 0xf37300c0
1741#define FSTV0910_P2_TSFIFO_PERMDATA 0xf3730020
1742#define FSTV0910_P2_TSFIFO_NONEWSGNL 0xf3730010
1743#define FSTV0910_P2_TSFIFO_INVDATA 0xf3730001
1744
1745/* P2_TSCFGL */
1746#define RSTV0910_P2_TSCFGL 0xf374
1747#define FSTV0910_P2_TSFIFO_BCLKDEL1CK 0xf37400c0
1748#define FSTV0910_P2_BCHERROR_MODE 0xf3740030
1749#define FSTV0910_P2_TSFIFO_NSGNL2DATA 0xf3740008
1750#define FSTV0910_P2_TSFIFO_EMBINDVB 0xf3740004
1751#define FSTV0910_P2_TSFIFO_BITSPEED 0xf3740003
1752
1753/* P2_TSSYNC */
1754#define RSTV0910_P2_TSSYNC 0xf375
1755#define FSTV0910_P2_TSFIFO_SYNCMODE 0xf3750018
1756
1757/* P2_TSINSDELH */
1758#define RSTV0910_P2_TSINSDELH 0xf376
1759#define FSTV0910_P2_TSDEL_SYNCBYTE 0xf3760080
1760#define FSTV0910_P2_TSDEL_XXHEADER 0xf3760040
1761#define FSTV0910_P2_TSDEL_DATAFIELD 0xf3760010
1762#define FSTV0910_P2_TSINSDEL_RSPARITY 0xf3760002
1763#define FSTV0910_P2_TSINSDEL_CRC8 0xf3760001
1764
1765/* P2_TSINSDELM */
1766#define RSTV0910_P2_TSINSDELM 0xf377
1767#define FSTV0910_P2_TSINS_EMODCOD 0xf3770010
1768#define FSTV0910_P2_TSINS_TOKEN 0xf3770008
1769#define FSTV0910_P2_TSINS_XXXERR 0xf3770004
1770#define FSTV0910_P2_TSINS_MATYPE 0xf3770002
1771#define FSTV0910_P2_TSINS_UPL 0xf3770001
1772
1773/* P2_TSINSDELL */
1774#define RSTV0910_P2_TSINSDELL 0xf378
1775#define FSTV0910_P2_TSINS_DFL 0xf3780080
1776#define FSTV0910_P2_TSINS_SYNCD 0xf3780040
1777#define FSTV0910_P2_TSINS_BLOCLEN 0xf3780020
1778#define FSTV0910_P2_TSINS_SIGPCOUNT 0xf3780010
1779#define FSTV0910_P2_TSINS_FIFO 0xf3780008
1780#define FSTV0910_P2_TSINS_REALPACK 0xf3780004
1781#define FSTV0910_P2_TSINS_TSCONFIG 0xf3780002
1782#define FSTV0910_P2_TSINS_LATENCY 0xf3780001
1783
1784/* P2_TSDIVN */
1785#define RSTV0910_P2_TSDIVN 0xf379
1786#define FSTV0910_P2_TSFIFO_SPEEDMODE 0xf37900c0
1787#define FSTV0910_P2_TSFIFO_RISEOK 0xf3790007
1788
1789/* P2_TSCFG4 */
1790#define RSTV0910_P2_TSCFG4 0xf37a
1791#define FSTV0910_P2_TSFIFO_TSSPEEDMODE 0xf37a00c0
1792
1793/* P2_TSSPEED */
1794#define RSTV0910_P2_TSSPEED 0xf380
1795#define FSTV0910_P2_TSFIFO_OUTSPEED 0xf38000ff
1796
1797/* P2_TSSTATUS */
1798#define RSTV0910_P2_TSSTATUS 0xf381
1799#define FSTV0910_P2_TSFIFO_LINEOK 0xf3810080
1800#define FSTV0910_P2_TSFIFO_ERROR 0xf3810040
1801#define FSTV0910_P2_TSFIFO_NOSYNC 0xf3810010
1802#define FSTV0910_P2_TSREGUL_ERROR 0xf3810004
1803#define FSTV0910_P2_DIL_READY 0xf3810001
1804
1805/* P2_TSSTATUS2 */
1806#define RSTV0910_P2_TSSTATUS2 0xf382
1807#define FSTV0910_P2_TSFIFO_DEMODSEL 0xf3820080
1808#define FSTV0910_P2_TSFIFOSPEED_STORE 0xf3820040
1809#define FSTV0910_P2_DILXX_RESET 0xf3820020
1810#define FSTV0910_P2_SCRAMBDETECT 0xf3820002
1811
1812/* P2_TSBITRATE1 */
1813#define RSTV0910_P2_TSBITRATE1 0xf383
1814#define FSTV0910_P2_TSFIFO_BITRATE1 0xf38300ff
1815
1816/* P2_TSBITRATE0 */
1817#define RSTV0910_P2_TSBITRATE0 0xf384
1818#define FSTV0910_P2_TSFIFO_BITRATE0 0xf38400ff
1819
1820/* P2_TSPACKLEN1 */
1821#define RSTV0910_P2_TSPACKLEN1 0xf385
1822#define FSTV0910_P2_TSFIFO_PACKCPT 0xf38500e0
1823
1824/* P2_TSDLY2 */
1825#define RSTV0910_P2_TSDLY2 0xf389
1826#define FSTV0910_P2_SOFFIFO_LATENCY2 0xf389000f
1827
1828/* P2_TSDLY1 */
1829#define RSTV0910_P2_TSDLY1 0xf38a
1830#define FSTV0910_P2_SOFFIFO_LATENCY1 0xf38a00ff
1831
1832/* P2_TSDLY0 */
1833#define RSTV0910_P2_TSDLY0 0xf38b
1834#define FSTV0910_P2_SOFFIFO_LATENCY0 0xf38b00ff
1835
1836/* P2_TSNPDAV */
1837#define RSTV0910_P2_TSNPDAV 0xf38c
1838#define FSTV0910_P2_TSNPD_AVERAGE 0xf38c00ff
1839
1840/* P2_TSBUFSTAT2 */
1841#define RSTV0910_P2_TSBUFSTAT2 0xf38d
1842#define FSTV0910_P2_TSISCR_3BYTES 0xf38d0080
1843#define FSTV0910_P2_TSISCR_NEWDATA 0xf38d0040
1844#define FSTV0910_P2_TSISCR_BUFSTAT2 0xf38d003f
1845
1846/* P2_TSBUFSTAT1 */
1847#define RSTV0910_P2_TSBUFSTAT1 0xf38e
1848#define FSTV0910_P2_TSISCR_BUFSTAT1 0xf38e00ff
1849
1850/* P2_TSBUFSTAT0 */
1851#define RSTV0910_P2_TSBUFSTAT0 0xf38f
1852#define FSTV0910_P2_TSISCR_BUFSTAT0 0xf38f00ff
1853
1854/* P2_TSDEBUGL */
1855#define RSTV0910_P2_TSDEBUGL 0xf391
1856#define FSTV0910_P2_TSFIFO_ERROR_EVNT 0xf3910004
1857#define FSTV0910_P2_TSFIFO_OVERFLOWM 0xf3910001
1858
1859/* P2_TSDLYSET2 */
1860#define RSTV0910_P2_TSDLYSET2 0xf392
1861#define FSTV0910_P2_SOFFIFO_OFFSET 0xf39200c0
1862#define FSTV0910_P2_HYSTERESIS_THRESHOLD 0xf3920030
1863#define FSTV0910_P2_SOFFIFO_SYMBOFFS2 0xf392000f
1864
1865/* P2_TSDLYSET1 */
1866#define RSTV0910_P2_TSDLYSET1 0xf393
1867#define FSTV0910_P2_SOFFIFO_SYMBOFFS1 0xf39300ff
1868
1869/* P2_TSDLYSET0 */
1870#define RSTV0910_P2_TSDLYSET0 0xf394
1871#define FSTV0910_P2_SOFFIFO_SYMBOFFS0 0xf39400ff
1872
1873/* P2_ERRCTRL1 */
1874#define RSTV0910_P2_ERRCTRL1 0xf398
1875#define FSTV0910_P2_ERR_SOURCE1 0xf39800f0
1876#define FSTV0910_P2_NUM_EVENT1 0xf3980007
1877
1878/* P2_ERRCNT12 */
1879#define RSTV0910_P2_ERRCNT12 0xf399
1880#define FSTV0910_P2_ERRCNT1_OLDVALUE 0xf3990080
1881#define FSTV0910_P2_ERR_CNT12 0xf399007f
1882
1883/* P2_ERRCNT11 */
1884#define RSTV0910_P2_ERRCNT11 0xf39a
1885#define FSTV0910_P2_ERR_CNT11 0xf39a00ff
1886
1887/* P2_ERRCNT10 */
1888#define RSTV0910_P2_ERRCNT10 0xf39b
1889#define FSTV0910_P2_ERR_CNT10 0xf39b00ff
1890
1891/* P2_ERRCTRL2 */
1892#define RSTV0910_P2_ERRCTRL2 0xf39c
1893#define FSTV0910_P2_ERR_SOURCE2 0xf39c00f0
1894#define FSTV0910_P2_NUM_EVENT2 0xf39c0007
1895
1896/* P2_ERRCNT22 */
1897#define RSTV0910_P2_ERRCNT22 0xf39d
1898#define FSTV0910_P2_ERRCNT2_OLDVALUE 0xf39d0080
1899#define FSTV0910_P2_ERR_CNT22 0xf39d007f
1900
1901/* P2_ERRCNT21 */
1902#define RSTV0910_P2_ERRCNT21 0xf39e
1903#define FSTV0910_P2_ERR_CNT21 0xf39e00ff
1904
1905/* P2_ERRCNT20 */
1906#define RSTV0910_P2_ERRCNT20 0xf39f
1907#define FSTV0910_P2_ERR_CNT20 0xf39f00ff
1908
1909/* P2_FECSPY */
1910#define RSTV0910_P2_FECSPY 0xf3a0
1911#define FSTV0910_P2_SPY_ENABLE 0xf3a00080
1912#define FSTV0910_P2_NO_SYNCBYTE 0xf3a00040
1913#define FSTV0910_P2_SERIAL_MODE 0xf3a00020
1914#define FSTV0910_P2_UNUSUAL_PACKET 0xf3a00010
1915#define FSTV0910_P2_BERMETER_DATAMODE 0xf3a0000c
1916#define FSTV0910_P2_BERMETER_LMODE 0xf3a00002
1917#define FSTV0910_P2_BERMETER_RESET 0xf3a00001
1918
1919/* P2_FSPYCFG */
1920#define RSTV0910_P2_FSPYCFG 0xf3a1
1921#define FSTV0910_P2_FECSPY_INPUT 0xf3a100c0
1922#define FSTV0910_P2_RST_ON_ERROR 0xf3a10020
1923#define FSTV0910_P2_ONE_SHOT 0xf3a10010
1924#define FSTV0910_P2_I2C_MODE 0xf3a1000c
1925#define FSTV0910_P2_SPY_HYSTERESIS 0xf3a10003
1926
1927/* P2_FSPYDATA */
1928#define RSTV0910_P2_FSPYDATA 0xf3a2
1929#define FSTV0910_P2_SPY_STUFFING 0xf3a20080
1930#define FSTV0910_P2_SPY_CNULLPKT 0xf3a20020
1931#define FSTV0910_P2_SPY_OUTDATA_MODE 0xf3a2001f
1932
1933/* P2_FSPYOUT */
1934#define RSTV0910_P2_FSPYOUT 0xf3a3
1935#define FSTV0910_P2_FSPY_DIRECT 0xf3a30080
1936#define FSTV0910_P2_STUFF_MODE 0xf3a30007
1937
1938/* P2_FSTATUS */
1939#define RSTV0910_P2_FSTATUS 0xf3a4
1940#define FSTV0910_P2_SPY_ENDSIM 0xf3a40080
1941#define FSTV0910_P2_VALID_SIM 0xf3a40040
1942#define FSTV0910_P2_FOUND_SIGNAL 0xf3a40020
1943#define FSTV0910_P2_DSS_SYNCBYTE 0xf3a40010
1944#define FSTV0910_P2_RESULT_STATE 0xf3a4000f
1945
1946/* P2_FBERCPT4 */
1947#define RSTV0910_P2_FBERCPT4 0xf3a8
1948#define FSTV0910_P2_FBERMETER_CPT4 0xf3a800ff
1949
1950/* P2_FBERCPT3 */
1951#define RSTV0910_P2_FBERCPT3 0xf3a9
1952#define FSTV0910_P2_FBERMETER_CPT3 0xf3a900ff
1953
1954/* P2_FBERCPT2 */
1955#define RSTV0910_P2_FBERCPT2 0xf3aa
1956#define FSTV0910_P2_FBERMETER_CPT2 0xf3aa00ff
1957
1958/* P2_FBERCPT1 */
1959#define RSTV0910_P2_FBERCPT1 0xf3ab
1960#define FSTV0910_P2_FBERMETER_CPT1 0xf3ab00ff
1961
1962/* P2_FBERCPT0 */
1963#define RSTV0910_P2_FBERCPT0 0xf3ac
1964#define FSTV0910_P2_FBERMETER_CPT0 0xf3ac00ff
1965
1966/* P2_FBERERR2 */
1967#define RSTV0910_P2_FBERERR2 0xf3ad
1968#define FSTV0910_P2_FBERMETER_ERR2 0xf3ad00ff
1969
1970/* P2_FBERERR1 */
1971#define RSTV0910_P2_FBERERR1 0xf3ae
1972#define FSTV0910_P2_FBERMETER_ERR1 0xf3ae00ff
1973
1974/* P2_FBERERR0 */
1975#define RSTV0910_P2_FBERERR0 0xf3af
1976#define FSTV0910_P2_FBERMETER_ERR0 0xf3af00ff
1977
1978/* P2_FSPYBER */
1979#define RSTV0910_P2_FSPYBER 0xf3b2
1980#define FSTV0910_P2_FSPYBER_SYNCBYTE 0xf3b20010
1981#define FSTV0910_P2_FSPYBER_UNSYNC 0xf3b20008
1982#define FSTV0910_P2_FSPYBER_CTIME 0xf3b20007
1983
1984/* P2_SFERROR */
1985#define RSTV0910_P2_SFERROR 0xf3c1
1986#define FSTV0910_P2_SFEC_REGERR_VIT 0xf3c100ff
1987
1988/* P2_SFECSTATUS */
1989#define RSTV0910_P2_SFECSTATUS 0xf3c3
1990#define FSTV0910_P2_SFEC_ON 0xf3c30080
1991#define FSTV0910_P2_SFEC_OFF 0xf3c30040
1992#define FSTV0910_P2_LOCKEDSFEC 0xf3c30008
1993#define FSTV0910_P2_SFEC_DELOCK 0xf3c30004
1994#define FSTV0910_P2_SFEC_DEMODSEL 0xf3c30002
1995#define FSTV0910_P2_SFEC_OVFON 0xf3c30001
1996
1997/* P2_SFKDIV12 */
1998#define RSTV0910_P2_SFKDIV12 0xf3c4
1999#define FSTV0910_P2_SFECKDIV12_MAN 0xf3c40080
2000
2001/* P2_SFKDIV23 */
2002#define RSTV0910_P2_SFKDIV23 0xf3c5
2003#define FSTV0910_P2_SFECKDIV23_MAN 0xf3c50080
2004
2005/* P2_SFKDIV34 */
2006#define RSTV0910_P2_SFKDIV34 0xf3c6
2007#define FSTV0910_P2_SFECKDIV34_MAN 0xf3c60080
2008
2009/* P2_SFKDIV56 */
2010#define RSTV0910_P2_SFKDIV56 0xf3c7
2011#define FSTV0910_P2_SFECKDIV56_MAN 0xf3c70080
2012
2013/* P2_SFKDIV67 */
2014#define RSTV0910_P2_SFKDIV67 0xf3c8
2015#define FSTV0910_P2_SFECKDIV67_MAN 0xf3c80080
2016
2017/* P2_SFKDIV78 */
2018#define RSTV0910_P2_SFKDIV78 0xf3c9
2019#define FSTV0910_P2_SFECKDIV78_MAN 0xf3c90080
2020
2021/* P2_SFSTATUS */
2022#define RSTV0910_P2_SFSTATUS 0xf3cc
2023#define FSTV0910_P2_SFEC_LINEOK 0xf3cc0080
2024#define FSTV0910_P2_SFEC_ERROR 0xf3cc0040
2025#define FSTV0910_P2_SFEC_DATA7 0xf3cc0020
2026#define FSTV0910_P2_SFEC_PKTDNBRFAIL 0xf3cc0010
2027#define FSTV0910_P2_TSSFEC_DEMODSEL 0xf3cc0008
2028#define FSTV0910_P2_SFEC_NOSYNC 0xf3cc0004
2029#define FSTV0910_P2_SFEC_UNREGULA 0xf3cc0002
2030#define FSTV0910_P2_SFEC_READY 0xf3cc0001
2031
2032/* P2_SFDLYSET2 */
2033#define RSTV0910_P2_SFDLYSET2 0xf3d0
2034#define FSTV0910_P2_SFEC_DISABLE 0xf3d00002
2035
2036/* P2_SFERRCTRL */
2037#define RSTV0910_P2_SFERRCTRL 0xf3d8
2038#define FSTV0910_P2_SFEC_ERR_SOURCE 0xf3d800f0
2039#define FSTV0910_P2_SFEC_NUM_EVENT 0xf3d80007
2040
2041/* P2_SFERRCNT2 */
2042#define RSTV0910_P2_SFERRCNT2 0xf3d9
2043#define FSTV0910_P2_SFERRC_OLDVALUE 0xf3d90080
2044#define FSTV0910_P2_SFEC_ERR_CNT2 0xf3d9007f
2045
2046/* P2_SFERRCNT1 */
2047#define RSTV0910_P2_SFERRCNT1 0xf3da
2048#define FSTV0910_P2_SFEC_ERR_CNT1 0xf3da00ff
2049
2050/* P2_SFERRCNT0 */
2051#define RSTV0910_P2_SFERRCNT0 0xf3db
2052#define FSTV0910_P2_SFEC_ERR_CNT0 0xf3db00ff
2053
2054/* P1_IQCONST */
2055#define RSTV0910_P1_IQCONST 0xf400
2056#define FSTV0910_P1_CONSTEL_SELECT 0xf4000060
2057#define FSTV0910_P1_IQSYMB_SEL 0xf400001f
2058
2059/* P1_NOSCFG */
2060#define RSTV0910_P1_NOSCFG 0xf401
2061#define FSTV0910_P1_DUMMYPL_NOSDATA 0xf4010020
2062#define FSTV0910_P1_NOSPLH_BETA 0xf4010018
2063#define FSTV0910_P1_NOSDATA_BETA 0xf4010007
2064
2065/* P1_ISYMB */
2066#define RSTV0910_P1_ISYMB 0xf402
2067#define FSTV0910_P1_I_SYMBOL 0xf40201ff
2068
2069/* P1_QSYMB */
2070#define RSTV0910_P1_QSYMB 0xf403
2071#define FSTV0910_P1_Q_SYMBOL 0xf40301ff
2072
2073/* P1_AGC1CFG */
2074#define RSTV0910_P1_AGC1CFG 0xf404
2075#define FSTV0910_P1_DC_FROZEN 0xf4040080
2076#define FSTV0910_P1_DC_CORRECT 0xf4040040
2077#define FSTV0910_P1_AMM_FROZEN 0xf4040020
2078#define FSTV0910_P1_AMM_CORRECT 0xf4040010
2079#define FSTV0910_P1_QUAD_FROZEN 0xf4040008
2080#define FSTV0910_P1_QUAD_CORRECT 0xf4040004
2081
2082/* P1_AGC1CN */
2083#define RSTV0910_P1_AGC1CN 0xf406
2084#define FSTV0910_P1_AGC1_LOCKED 0xf4060080
2085#define FSTV0910_P1_AGC1_MINPOWER 0xf4060010
2086#define FSTV0910_P1_AGCOUT_FAST 0xf4060008
2087#define FSTV0910_P1_AGCIQ_BETA 0xf4060007
2088
2089/* P1_AGC1REF */
2090#define RSTV0910_P1_AGC1REF 0xf407
2091#define FSTV0910_P1_AGCIQ_REF 0xf40700ff
2092
2093/* P1_IDCCOMP */
2094#define RSTV0910_P1_IDCCOMP 0xf408
2095#define FSTV0910_P1_IAVERAGE_ADJ 0xf40801ff
2096
2097/* P1_QDCCOMP */
2098#define RSTV0910_P1_QDCCOMP 0xf409
2099#define FSTV0910_P1_QAVERAGE_ADJ 0xf40901ff
2100
2101/* P1_POWERI */
2102#define RSTV0910_P1_POWERI 0xf40a
2103#define FSTV0910_P1_POWER_I 0xf40a00ff
2104
2105/* P1_POWERQ */
2106#define RSTV0910_P1_POWERQ 0xf40b
2107#define FSTV0910_P1_POWER_Q 0xf40b00ff
2108
2109/* P1_AGC1AMM */
2110#define RSTV0910_P1_AGC1AMM 0xf40c
2111#define FSTV0910_P1_AMM_VALUE 0xf40c00ff
2112
2113/* P1_AGC1QUAD */
2114#define RSTV0910_P1_AGC1QUAD 0xf40d
2115#define FSTV0910_P1_QUAD_VALUE 0xf40d01ff
2116
2117/* P1_AGCIQIN1 */
2118#define RSTV0910_P1_AGCIQIN1 0xf40e
2119#define FSTV0910_P1_AGCIQ_VALUE1 0xf40e00ff
2120
2121/* P1_AGCIQIN0 */
2122#define RSTV0910_P1_AGCIQIN0 0xf40f
2123#define FSTV0910_P1_AGCIQ_VALUE0 0xf40f00ff
2124
2125/* P1_DEMOD */
2126#define RSTV0910_P1_DEMOD 0xf410
2127#define FSTV0910_P1_MANUALS2_ROLLOFF 0xf4100080
2128#define FSTV0910_P1_SPECINV_CONTROL 0xf4100030
2129#define FSTV0910_P1_MANUALSX_ROLLOFF 0xf4100004
2130#define FSTV0910_P1_ROLLOFF_CONTROL 0xf4100003
2131
2132/* P1_DMDMODCOD */
2133#define RSTV0910_P1_DMDMODCOD 0xf411
2134#define FSTV0910_P1_MANUAL_MODCOD 0xf4110080
2135#define FSTV0910_P1_DEMOD_MODCOD 0xf411007c
2136#define FSTV0910_P1_DEMOD_TYPE 0xf4110003
2137
2138/* P1_DSTATUS */
2139#define RSTV0910_P1_DSTATUS 0xf412
2140#define FSTV0910_P1_CAR_LOCK 0xf4120080
2141#define FSTV0910_P1_TMGLOCK_QUALITY 0xf4120060
2142#define FSTV0910_P1_LOCK_DEFINITIF 0xf4120008
2143#define FSTV0910_P1_OVADC_DETECT 0xf4120001
2144
2145/* P1_DSTATUS2 */
2146#define RSTV0910_P1_DSTATUS2 0xf413
2147#define FSTV0910_P1_DEMOD_DELOCK 0xf4130080
2148#define FSTV0910_P1_MODCODRQ_SYNCTAG 0xf4130020
2149#define FSTV0910_P1_POLYPH_SATEVENT 0xf4130010
2150#define FSTV0910_P1_AGC1_NOSIGNALACK 0xf4130008
2151#define FSTV0910_P1_AGC2_OVERFLOW 0xf4130004
2152#define FSTV0910_P1_CFR_OVERFLOW 0xf4130002
2153#define FSTV0910_P1_GAMMA_OVERUNDER 0xf4130001
2154
2155/* P1_DMDCFGMD */
2156#define RSTV0910_P1_DMDCFGMD 0xf414
2157#define FSTV0910_P1_DVBS2_ENABLE 0xf4140080
2158#define FSTV0910_P1_DVBS1_ENABLE 0xf4140040
2159#define FSTV0910_P1_SCAN_ENABLE 0xf4140010
2160#define FSTV0910_P1_CFR_AUTOSCAN 0xf4140008
2161#define FSTV0910_P1_TUN_RNG 0xf4140003
2162
2163/* P1_DMDCFG2 */
2164#define RSTV0910_P1_DMDCFG2 0xf415
2165#define FSTV0910_P1_S1S2_SEQUENTIAL 0xf4150040
2166#define FSTV0910_P1_INFINITE_RELOCK 0xf4150010
2167
2168/* P1_DMDISTATE */
2169#define RSTV0910_P1_DMDISTATE 0xf416
2170#define FSTV0910_P1_I2C_NORESETDMODE 0xf4160080
2171#define FSTV0910_P1_I2C_DEMOD_MODE 0xf416001f
2172
2173/* P1_DMDT0M */
2174#define RSTV0910_P1_DMDT0M 0xf417
2175#define FSTV0910_P1_DMDT0_MIN 0xf41700ff
2176
2177/* P1_DMDSTATE */
2178#define RSTV0910_P1_DMDSTATE 0xf41b
2179#define FSTV0910_P1_HEADER_MODE 0xf41b0060
2180
2181/* P1_DMDFLYW */
2182#define RSTV0910_P1_DMDFLYW 0xf41c
2183#define FSTV0910_P1_I2C_IRQVAL 0xf41c00f0
2184#define FSTV0910_P1_FLYWHEEL_CPT 0xf41c000f
2185
2186/* P1_DSTATUS3 */
2187#define RSTV0910_P1_DSTATUS3 0xf41d
2188#define FSTV0910_P1_CFR_ZIGZAG 0xf41d0080
2189#define FSTV0910_P1_DEMOD_CFGMODE 0xf41d0060
2190#define FSTV0910_P1_GAMMA_LOWBAUDRATE 0xf41d0010
2191
2192/* P1_DMDCFG3 */
2193#define RSTV0910_P1_DMDCFG3 0xf41e
2194#define FSTV0910_P1_NOSTOP_FIFOFULL 0xf41e0008
2195
2196/* P1_DMDCFG4 */
2197#define RSTV0910_P1_DMDCFG4 0xf41f
2198#define FSTV0910_P1_DIS_VITLOCK 0xf41f0080
2199#define FSTV0910_P1_DIS_CLKENABLE 0xf41f0004
2200
2201/* P1_CORRELMANT */
2202#define RSTV0910_P1_CORRELMANT 0xf420
2203#define FSTV0910_P1_CORREL_MANT 0xf42000ff
2204
2205/* P1_CORRELABS */
2206#define RSTV0910_P1_CORRELABS 0xf421
2207#define FSTV0910_P1_CORREL_ABS 0xf42100ff
2208
2209/* P1_CORRELEXP */
2210#define RSTV0910_P1_CORRELEXP 0xf422
2211#define FSTV0910_P1_CORREL_ABSEXP 0xf42200f0
2212#define FSTV0910_P1_CORREL_EXP 0xf422000f
2213
2214/* P1_PLHMODCOD */
2215#define RSTV0910_P1_PLHMODCOD 0xf424
2216#define FSTV0910_P1_SPECINV_DEMOD 0xf4240080
2217#define FSTV0910_P1_PLH_MODCOD 0xf424007c
2218#define FSTV0910_P1_PLH_TYPE 0xf4240003
2219
2220/* P1_DMDREG */
2221#define RSTV0910_P1_DMDREG 0xf425
2222#define FSTV0910_P1_DECIM_PLFRAMES 0xf4250001
2223
2224/* P1_AGCNADJ */
2225#define RSTV0910_P1_AGCNADJ 0xf426
2226#define FSTV0910_P1_RADJOFF_AGC2 0xf4260080
2227#define FSTV0910_P1_RADJOFF_AGC1 0xf4260040
2228#define FSTV0910_P1_AGC_NADJ 0xf426013f
2229
2230/* P1_AGCKS */
2231#define RSTV0910_P1_AGCKS 0xf427
2232#define FSTV0910_P1_RSADJ_MANUALCFG 0xf4270080
2233#define FSTV0910_P1_RSADJ_CCMMODE 0xf4270040
2234#define FSTV0910_P1_RADJ_SPSK 0xf427013f
2235
2236/* P1_AGCKQ */
2237#define RSTV0910_P1_AGCKQ 0xf428
2238#define FSTV0910_P1_RADJON_DVBS1 0xf4280040
2239#define FSTV0910_P1_RADJ_QPSK 0xf428013f
2240
2241/* P1_AGCK8 */
2242#define RSTV0910_P1_AGCK8 0xf429
2243#define FSTV0910_P1_RADJ_8PSK 0xf429013f
2244
2245/* P1_AGCK16 */
2246#define RSTV0910_P1_AGCK16 0xf42a
2247#define FSTV0910_P1_R2ADJOFF_16APSK 0xf42a0040
2248#define FSTV0910_P1_R1ADJOFF_16APSK 0xf42a0020
2249#define FSTV0910_P1_RADJ_16APSK 0xf42a011f
2250
2251/* P1_AGCK32 */
2252#define RSTV0910_P1_AGCK32 0xf42b
2253#define FSTV0910_P1_R3ADJOFF_32APSK 0xf42b0080
2254#define FSTV0910_P1_R2ADJOFF_32APSK 0xf42b0040
2255#define FSTV0910_P1_R1ADJOFF_32APSK 0xf42b0020
2256#define FSTV0910_P1_RADJ_32APSK 0xf42b011f
2257
2258/* P1_AGC2O */
2259#define RSTV0910_P1_AGC2O 0xf42c
2260#define FSTV0910_P1_CSTENV_MODE 0xf42c00c0
2261#define FSTV0910_P1_AGC2_COEF 0xf42c0007
2262
2263/* P1_AGC2REF */
2264#define RSTV0910_P1_AGC2REF 0xf42d
2265#define FSTV0910_P1_AGC2_REF 0xf42d00ff
2266
2267/* P1_AGC1ADJ */
2268#define RSTV0910_P1_AGC1ADJ 0xf42e
2269#define FSTV0910_P1_AGC1_ADJUSTED 0xf42e007f
2270
2271/* P1_AGCRSADJ */
2272#define RSTV0910_P1_AGCRSADJ 0xf42f
2273#define FSTV0910_P1_RS_ADJUSTED 0xf42f007f
2274
2275/* P1_AGCRQADJ */
2276#define RSTV0910_P1_AGCRQADJ 0xf430
2277#define FSTV0910_P1_RQ_ADJUSTED 0xf430007f
2278
2279/* P1_AGCR8ADJ */
2280#define RSTV0910_P1_AGCR8ADJ 0xf431
2281#define FSTV0910_P1_R8_ADJUSTED 0xf431007f
2282
2283/* P1_AGCR1ADJ */
2284#define RSTV0910_P1_AGCR1ADJ 0xf432
2285#define FSTV0910_P1_R1_ADJUSTED 0xf432007f
2286
2287/* P1_AGCR2ADJ */
2288#define RSTV0910_P1_AGCR2ADJ 0xf433
2289#define FSTV0910_P1_R2_ADJUSTED 0xf433007f
2290
2291/* P1_AGCR3ADJ */
2292#define RSTV0910_P1_AGCR3ADJ 0xf434
2293#define FSTV0910_P1_R3_ADJUSTED 0xf434007f
2294
2295/* P1_AGCREFADJ */
2296#define RSTV0910_P1_AGCREFADJ 0xf435
2297#define FSTV0910_P1_AGC2REF_ADJUSTED 0xf435007f
2298
2299/* P1_AGC2I1 */
2300#define RSTV0910_P1_AGC2I1 0xf436
2301#define FSTV0910_P1_AGC2_INTEGRATOR1 0xf43600ff
2302
2303/* P1_AGC2I0 */
2304#define RSTV0910_P1_AGC2I0 0xf437
2305#define FSTV0910_P1_AGC2_INTEGRATOR0 0xf43700ff
2306
2307/* P1_CARCFG */
2308#define RSTV0910_P1_CARCFG 0xf438
2309#define FSTV0910_P1_ROTAON 0xf4380004
2310#define FSTV0910_P1_PH_DET_ALGO 0xf4380003
2311
2312/* P1_ACLC */
2313#define RSTV0910_P1_ACLC 0xf439
2314#define FSTV0910_P1_CAR_ALPHA_MANT 0xf4390030
2315#define FSTV0910_P1_CAR_ALPHA_EXP 0xf439000f
2316
2317/* P1_BCLC */
2318#define RSTV0910_P1_BCLC 0xf43a
2319#define FSTV0910_P1_CAR_BETA_MANT 0xf43a0030
2320#define FSTV0910_P1_CAR_BETA_EXP 0xf43a000f
2321
2322/* P1_ACLCS2 */
2323#define RSTV0910_P1_ACLCS2 0xf43b
2324#define FSTV0910_P1_CARS2_APLHA_MANTISSE 0xf43b0030
2325#define FSTV0910_P1_CARS2_ALPHA_EXP 0xf43b000f
2326
2327/* P1_BCLCS2 */
2328#define RSTV0910_P1_BCLCS2 0xf43c
2329#define FSTV0910_P1_CARS2_BETA_MANTISSE 0xf43c0030
2330#define FSTV0910_P1_CARS2_BETA_EXP 0xf43c000f
2331
2332/* P1_CARFREQ */
2333#define RSTV0910_P1_CARFREQ 0xf43d
2334#define FSTV0910_P1_KC_COARSE_EXP 0xf43d00f0
2335#define FSTV0910_P1_BETA_FREQ 0xf43d000f
2336
2337/* P1_CARHDR */
2338#define RSTV0910_P1_CARHDR 0xf43e
2339#define FSTV0910_P1_K_FREQ_HDR 0xf43e00ff
2340
2341/* P1_LDT */
2342#define RSTV0910_P1_LDT 0xf43f
2343#define FSTV0910_P1_CARLOCK_THRES 0xf43f01ff
2344
2345/* P1_LDT2 */
2346#define RSTV0910_P1_LDT2 0xf440
2347#define FSTV0910_P1_CARLOCK_THRES2 0xf44001ff
2348
2349/* P1_CFRICFG */
2350#define RSTV0910_P1_CFRICFG 0xf441
2351#define FSTV0910_P1_NEG_CFRSTEP 0xf4410001
2352
2353/* P1_CFRUP1 */
2354#define RSTV0910_P1_CFRUP1 0xf442
2355#define FSTV0910_P1_CFR_UP1 0xf44201ff
2356
2357/* P1_CFRUP0 */
2358#define RSTV0910_P1_CFRUP0 0xf443
2359#define FSTV0910_P1_CFR_UP0 0xf44300ff
2360
2361/* P1_CFRIBASE1 */
2362#define RSTV0910_P1_CFRIBASE1 0xf444
2363#define FSTV0910_P1_CFRINIT_BASE1 0xf44400ff
2364
2365/* P1_CFRIBASE0 */
2366#define RSTV0910_P1_CFRIBASE0 0xf445
2367#define FSTV0910_P1_CFRINIT_BASE0 0xf44500ff
2368
2369/* P1_CFRLOW1 */
2370#define RSTV0910_P1_CFRLOW1 0xf446
2371#define FSTV0910_P1_CFR_LOW1 0xf44601ff
2372
2373/* P1_CFRLOW0 */
2374#define RSTV0910_P1_CFRLOW0 0xf447
2375#define FSTV0910_P1_CFR_LOW0 0xf44700ff
2376
2377/* P1_CFRINIT1 */
2378#define RSTV0910_P1_CFRINIT1 0xf448
2379#define FSTV0910_P1_CFR_INIT1 0xf44801ff
2380
2381/* P1_CFRINIT0 */
2382#define RSTV0910_P1_CFRINIT0 0xf449
2383#define FSTV0910_P1_CFR_INIT0 0xf44900ff
2384
2385/* P1_CFRINC1 */
2386#define RSTV0910_P1_CFRINC1 0xf44a
2387#define FSTV0910_P1_MANUAL_CFRINC 0xf44a0080
2388#define FSTV0910_P1_CFR_INC1 0xf44a003f
2389
2390/* P1_CFRINC0 */
2391#define RSTV0910_P1_CFRINC0 0xf44b
2392#define FSTV0910_P1_CFR_INC0 0xf44b00ff
2393
2394/* P1_CFR2 */
2395#define RSTV0910_P1_CFR2 0xf44c
2396#define FSTV0910_P1_CAR_FREQ2 0xf44c01ff
2397
2398/* P1_CFR1 */
2399#define RSTV0910_P1_CFR1 0xf44d
2400#define FSTV0910_P1_CAR_FREQ1 0xf44d00ff
2401
2402/* P1_CFR0 */
2403#define RSTV0910_P1_CFR0 0xf44e
2404#define FSTV0910_P1_CAR_FREQ0 0xf44e00ff
2405
2406/* P1_LDI */
2407#define RSTV0910_P1_LDI 0xf44f
2408#define FSTV0910_P1_LOCK_DET_INTEGR 0xf44f01ff
2409
2410/* P1_TMGCFG */
2411#define RSTV0910_P1_TMGCFG 0xf450
2412#define FSTV0910_P1_TMGLOCK_BETA 0xf45000c0
2413#define FSTV0910_P1_DO_TIMING_CORR 0xf4500010
2414#define FSTV0910_P1_TMG_MINFREQ 0xf4500003
2415
2416/* P1_RTC */
2417#define RSTV0910_P1_RTC 0xf451
2418#define FSTV0910_P1_TMGALPHA_EXP 0xf45100f0
2419#define FSTV0910_P1_TMGBETA_EXP 0xf451000f
2420
2421/* P1_RTCS2 */
2422#define RSTV0910_P1_RTCS2 0xf452
2423#define FSTV0910_P1_TMGALPHAS2_EXP 0xf45200f0
2424#define FSTV0910_P1_TMGBETAS2_EXP 0xf452000f
2425
2426/* P1_TMGTHRISE */
2427#define RSTV0910_P1_TMGTHRISE 0xf453
2428#define FSTV0910_P1_TMGLOCK_THRISE 0xf45300ff
2429
2430/* P1_TMGTHFALL */
2431#define RSTV0910_P1_TMGTHFALL 0xf454
2432#define FSTV0910_P1_TMGLOCK_THFALL 0xf45400ff
2433
2434/* P1_SFRUPRATIO */
2435#define RSTV0910_P1_SFRUPRATIO 0xf455
2436#define FSTV0910_P1_SFR_UPRATIO 0xf45500ff
2437
2438/* P1_SFRLOWRATIO */
2439#define RSTV0910_P1_SFRLOWRATIO 0xf456
2440#define FSTV0910_P1_SFR_LOWRATIO 0xf45600ff
2441
2442/* P1_KTTMG */
2443#define RSTV0910_P1_KTTMG 0xf457
2444#define FSTV0910_P1_KT_TMG_EXP 0xf45700f0
2445
2446/* P1_KREFTMG */
2447#define RSTV0910_P1_KREFTMG 0xf458
2448#define FSTV0910_P1_KREF_TMG 0xf45800ff
2449
2450/* P1_SFRSTEP */
2451#define RSTV0910_P1_SFRSTEP 0xf459
2452#define FSTV0910_P1_SFR_SCANSTEP 0xf45900f0
2453#define FSTV0910_P1_SFR_CENTERSTEP 0xf459000f
2454
2455/* P1_TMGCFG2 */
2456#define RSTV0910_P1_TMGCFG2 0xf45a
2457#define FSTV0910_P1_DIS_AUTOSAMP 0xf45a0008
2458#define FSTV0910_P1_SFRRATIO_FINE 0xf45a0001
2459
2460/* P1_KREFTMG2 */
2461#define RSTV0910_P1_KREFTMG2 0xf45b
2462#define FSTV0910_P1_KREF_TMG2 0xf45b00ff
2463
2464/* P1_TMGCFG3 */
2465#define RSTV0910_P1_TMGCFG3 0xf45d
2466#define FSTV0910_P1_CONT_TMGCENTER 0xf45d0008
2467#define FSTV0910_P1_AUTO_GUP 0xf45d0004
2468#define FSTV0910_P1_AUTO_GLOW 0xf45d0002
2469
2470/* P1_SFRINIT1 */
2471#define RSTV0910_P1_SFRINIT1 0xf45e
2472#define FSTV0910_P1_SFR_INIT1 0xf45e00ff
2473
2474/* P1_SFRINIT0 */
2475#define RSTV0910_P1_SFRINIT0 0xf45f
2476#define FSTV0910_P1_SFR_INIT0 0xf45f00ff
2477
2478/* P1_SFRUP1 */
2479#define RSTV0910_P1_SFRUP1 0xf460
2480#define FSTV0910_P1_SYMB_FREQ_UP1 0xf46000ff
2481
2482/* P1_SFRUP0 */
2483#define RSTV0910_P1_SFRUP0 0xf461
2484#define FSTV0910_P1_SYMB_FREQ_UP0 0xf46100ff
2485
2486/* P1_SFRLOW1 */
2487#define RSTV0910_P1_SFRLOW1 0xf462
2488#define FSTV0910_P1_SYMB_FREQ_LOW1 0xf46200ff
2489
2490/* P1_SFRLOW0 */
2491#define RSTV0910_P1_SFRLOW0 0xf463
2492#define FSTV0910_P1_SYMB_FREQ_LOW0 0xf46300ff
2493
2494/* P1_SFR3 */
2495#define RSTV0910_P1_SFR3 0xf464
2496#define FSTV0910_P1_SYMB_FREQ3 0xf46400ff
2497
2498/* P1_SFR2 */
2499#define RSTV0910_P1_SFR2 0xf465
2500#define FSTV0910_P1_SYMB_FREQ2 0xf46500ff
2501
2502/* P1_SFR1 */
2503#define RSTV0910_P1_SFR1 0xf466
2504#define FSTV0910_P1_SYMB_FREQ1 0xf46600ff
2505
2506/* P1_SFR0 */
2507#define RSTV0910_P1_SFR0 0xf467
2508#define FSTV0910_P1_SYMB_FREQ0 0xf46700ff
2509
2510/* P1_TMGREG2 */
2511#define RSTV0910_P1_TMGREG2 0xf468
2512#define FSTV0910_P1_TMGREG2 0xf46800ff
2513
2514/* P1_TMGREG1 */
2515#define RSTV0910_P1_TMGREG1 0xf469
2516#define FSTV0910_P1_TMGREG1 0xf46900ff
2517
2518/* P1_TMGREG0 */
2519#define RSTV0910_P1_TMGREG0 0xf46a
2520#define FSTV0910_P1_TMGREG0 0xf46a00ff
2521
2522/* P1_TMGLOCK1 */
2523#define RSTV0910_P1_TMGLOCK1 0xf46b
2524#define FSTV0910_P1_TMGLOCK_LEVEL1 0xf46b01ff
2525
2526/* P1_TMGLOCK0 */
2527#define RSTV0910_P1_TMGLOCK0 0xf46c
2528#define FSTV0910_P1_TMGLOCK_LEVEL0 0xf46c00ff
2529
2530/* P1_TMGOBS */
2531#define RSTV0910_P1_TMGOBS 0xf46d
2532#define FSTV0910_P1_ROLLOFF_STATUS 0xf46d00c0
2533
2534/* P1_EQUALCFG */
2535#define RSTV0910_P1_EQUALCFG 0xf46f
2536#define FSTV0910_P1_EQUAL_ON 0xf46f0040
2537#define FSTV0910_P1_MU_EQUALDFE 0xf46f0007
2538
2539/* P1_EQUAI1 */
2540#define RSTV0910_P1_EQUAI1 0xf470
2541#define FSTV0910_P1_EQUA_ACCI1 0xf47001ff
2542
2543/* P1_EQUAQ1 */
2544#define RSTV0910_P1_EQUAQ1 0xf471
2545#define FSTV0910_P1_EQUA_ACCQ1 0xf47101ff
2546
2547/* P1_EQUAI2 */
2548#define RSTV0910_P1_EQUAI2 0xf472
2549#define FSTV0910_P1_EQUA_ACCI2 0xf47201ff
2550
2551/* P1_EQUAQ2 */
2552#define RSTV0910_P1_EQUAQ2 0xf473
2553#define FSTV0910_P1_EQUA_ACCQ2 0xf47301ff
2554
2555/* P1_EQUAI3 */
2556#define RSTV0910_P1_EQUAI3 0xf474
2557#define FSTV0910_P1_EQUA_ACCI3 0xf47401ff
2558
2559/* P1_EQUAQ3 */
2560#define RSTV0910_P1_EQUAQ3 0xf475
2561#define FSTV0910_P1_EQUA_ACCQ3 0xf47501ff
2562
2563/* P1_EQUAI4 */
2564#define RSTV0910_P1_EQUAI4 0xf476
2565#define FSTV0910_P1_EQUA_ACCI4 0xf47601ff
2566
2567/* P1_EQUAQ4 */
2568#define RSTV0910_P1_EQUAQ4 0xf477
2569#define FSTV0910_P1_EQUA_ACCQ4 0xf47701ff
2570
2571/* P1_EQUAI5 */
2572#define RSTV0910_P1_EQUAI5 0xf478
2573#define FSTV0910_P1_EQUA_ACCI5 0xf47801ff
2574
2575/* P1_EQUAQ5 */
2576#define RSTV0910_P1_EQUAQ5 0xf479
2577#define FSTV0910_P1_EQUA_ACCQ5 0xf47901ff
2578
2579/* P1_EQUAI6 */
2580#define RSTV0910_P1_EQUAI6 0xf47a
2581#define FSTV0910_P1_EQUA_ACCI6 0xf47a01ff
2582
2583/* P1_EQUAQ6 */
2584#define RSTV0910_P1_EQUAQ6 0xf47b
2585#define FSTV0910_P1_EQUA_ACCQ6 0xf47b01ff
2586
2587/* P1_EQUAI7 */
2588#define RSTV0910_P1_EQUAI7 0xf47c
2589#define FSTV0910_P1_EQUA_ACCI7 0xf47c01ff
2590
2591/* P1_EQUAQ7 */
2592#define RSTV0910_P1_EQUAQ7 0xf47d
2593#define FSTV0910_P1_EQUA_ACCQ7 0xf47d01ff
2594
2595/* P1_EQUAI8 */
2596#define RSTV0910_P1_EQUAI8 0xf47e
2597#define FSTV0910_P1_EQUA_ACCI8 0xf47e01ff
2598
2599/* P1_EQUAQ8 */
2600#define RSTV0910_P1_EQUAQ8 0xf47f
2601#define FSTV0910_P1_EQUA_ACCQ8 0xf47f01ff
2602
2603/* P1_NNOSDATAT1 */
2604#define RSTV0910_P1_NNOSDATAT1 0xf480
2605#define FSTV0910_P1_NOSDATAT_NORMED1 0xf48000ff
2606
2607/* P1_NNOSDATAT0 */
2608#define RSTV0910_P1_NNOSDATAT0 0xf481
2609#define FSTV0910_P1_NOSDATAT_NORMED0 0xf48100ff
2610
2611/* P1_NNOSDATA1 */
2612#define RSTV0910_P1_NNOSDATA1 0xf482
2613#define FSTV0910_P1_NOSDATA_NORMED1 0xf48200ff
2614
2615/* P1_NNOSDATA0 */
2616#define RSTV0910_P1_NNOSDATA0 0xf483
2617#define FSTV0910_P1_NOSDATA_NORMED0 0xf48300ff
2618
2619/* P1_NNOSPLHT1 */
2620#define RSTV0910_P1_NNOSPLHT1 0xf484
2621#define FSTV0910_P1_NOSPLHT_NORMED1 0xf48400ff
2622
2623/* P1_NNOSPLHT0 */
2624#define RSTV0910_P1_NNOSPLHT0 0xf485
2625#define FSTV0910_P1_NOSPLHT_NORMED0 0xf48500ff
2626
2627/* P1_NNOSPLH1 */
2628#define RSTV0910_P1_NNOSPLH1 0xf486
2629#define FSTV0910_P1_NOSPLH_NORMED1 0xf48600ff
2630
2631/* P1_NNOSPLH0 */
2632#define RSTV0910_P1_NNOSPLH0 0xf487
2633#define FSTV0910_P1_NOSPLH_NORMED0 0xf48700ff
2634
2635/* P1_NOSDATAT1 */
2636#define RSTV0910_P1_NOSDATAT1 0xf488
2637#define FSTV0910_P1_NOSDATAT_UNNORMED1 0xf48800ff
2638
2639/* P1_NOSDATAT0 */
2640#define RSTV0910_P1_NOSDATAT0 0xf489
2641#define FSTV0910_P1_NOSDATAT_UNNORMED0 0xf48900ff
2642
2643/* P1_NNOSFRAME1 */
2644#define RSTV0910_P1_NNOSFRAME1 0xf48a
2645#define FSTV0910_P1_NOSFRAME_NORMED1 0xf48a00ff
2646
2647/* P1_NNOSFRAME0 */
2648#define RSTV0910_P1_NNOSFRAME0 0xf48b
2649#define FSTV0910_P1_NOSFRAME_NORMED0 0xf48b00ff
2650
2651/* P1_NNOSRAD1 */
2652#define RSTV0910_P1_NNOSRAD1 0xf48c
2653#define FSTV0910_P1_NOSRADIAL_NORMED1 0xf48c00ff
2654
2655/* P1_NNOSRAD0 */
2656#define RSTV0910_P1_NNOSRAD0 0xf48d
2657#define FSTV0910_P1_NOSRADIAL_NORMED0 0xf48d00ff
2658
2659/* P1_NOSCFGF1 */
2660#define RSTV0910_P1_NOSCFGF1 0xf48e
2661#define FSTV0910_P1_LOWNOISE_MESURE 0xf48e0080
2662#define FSTV0910_P1_NOS_DELFRAME 0xf48e0040
2663#define FSTV0910_P1_NOSDATA_MODE 0xf48e0030
2664#define FSTV0910_P1_FRAMESEL_TYPESEL 0xf48e000c
2665#define FSTV0910_P1_FRAMESEL_TYPE 0xf48e0003
2666
2667/* P1_NOSCFGF2 */
2668#define RSTV0910_P1_NOSCFGF2 0xf48f
2669#define FSTV0910_P1_DIS_NOSPILOTS 0xf48f0080
2670#define FSTV0910_P1_FRAMESEL_MODCODSEL 0xf48f0060
2671#define FSTV0910_P1_FRAMESEL_MODCOD 0xf48f001f
2672
2673/* P1_CAR2CFG */
2674#define RSTV0910_P1_CAR2CFG 0xf490
2675#define FSTV0910_P1_ROTA2ON 0xf4900004
2676#define FSTV0910_P1_PH_DET_ALGO2 0xf4900003
2677
2678/* P1_CFR2CFR1 */
2679#define RSTV0910_P1_CFR2CFR1 0xf491
2680#define FSTV0910_P1_EN_S2CAR2CENTER 0xf4910020
2681#define FSTV0910_P1_CFR2TOCFR1_BETA 0xf4910007
2682
2683/* P1_CAR3CFG */
2684#define RSTV0910_P1_CAR3CFG 0xf492
2685#define FSTV0910_P1_CARRIER23_MODE 0xf49200c0
2686#define FSTV0910_P1_CAR3INTERM_DVBS1 0xf4920020
2687#define FSTV0910_P1_ABAMPLIF_MODE 0xf4920018
2688#define FSTV0910_P1_CARRIER3_ALPHA3DL 0xf4920007
2689
2690/* P1_CFR22 */
2691#define RSTV0910_P1_CFR22 0xf493
2692#define FSTV0910_P1_CAR2_FREQ2 0xf49301ff
2693
2694/* P1_CFR21 */
2695#define RSTV0910_P1_CFR21 0xf494
2696#define FSTV0910_P1_CAR2_FREQ1 0xf49400ff
2697
2698/* P1_CFR20 */
2699#define RSTV0910_P1_CFR20 0xf495
2700#define FSTV0910_P1_CAR2_FREQ0 0xf49500ff
2701
2702/* P1_ACLC2S2Q */
2703#define RSTV0910_P1_ACLC2S2Q 0xf497
2704#define FSTV0910_P1_ENAB_SPSKSYMB 0xf4970080
2705#define FSTV0910_P1_CAR2S2_Q_ALPH_M 0xf4970030
2706#define FSTV0910_P1_CAR2S2_Q_ALPH_E 0xf497000f
2707
2708/* P1_ACLC2S28 */
2709#define RSTV0910_P1_ACLC2S28 0xf498
2710#define FSTV0910_P1_CAR2S2_8_ALPH_M 0xf4980030
2711#define FSTV0910_P1_CAR2S2_8_ALPH_E 0xf498000f
2712
2713/* P1_ACLC2S216A */
2714#define RSTV0910_P1_ACLC2S216A 0xf499
2715#define FSTV0910_P1_CAR2S2_16A_ALPH_M 0xf4990030
2716#define FSTV0910_P1_CAR2S2_16A_ALPH_E 0xf499000f
2717
2718/* P1_ACLC2S232A */
2719#define RSTV0910_P1_ACLC2S232A 0xf49a
2720#define FSTV0910_P1_CAR2S2_32A_ALPH_M 0xf49a0030
2721#define FSTV0910_P1_CAR2S2_32A_ALPH_E 0xf49a000f
2722
2723/* P1_BCLC2S2Q */
2724#define RSTV0910_P1_BCLC2S2Q 0xf49c
2725#define FSTV0910_P1_CAR2S2_Q_BETA_M 0xf49c0030
2726#define FSTV0910_P1_CAR2S2_Q_BETA_E 0xf49c000f
2727
2728/* P1_BCLC2S28 */
2729#define RSTV0910_P1_BCLC2S28 0xf49d
2730#define FSTV0910_P1_CAR2S2_8_BETA_M 0xf49d0030
2731#define FSTV0910_P1_CAR2S2_8_BETA_E 0xf49d000f
2732
2733/* P1_BCLC2S216A */
2734#define RSTV0910_P1_BCLC2S216A 0xf49e
2735#define FSTV0910_P1_DVBS2S216A_NIP 0xf49e0080
2736#define FSTV0910_P1_CAR2S2_16A_BETA_M 0xf49e0030
2737#define FSTV0910_P1_CAR2S2_16A_BETA_E 0xf49e000f
2738
2739/* P1_BCLC2S232A */
2740#define RSTV0910_P1_BCLC2S232A 0xf49f
2741#define FSTV0910_P1_DVBS2S232A_NIP 0xf49f0080
2742#define FSTV0910_P1_CAR2S2_32A_BETA_M 0xf49f0030
2743#define FSTV0910_P1_CAR2S2_32A_BETA_E 0xf49f000f
2744
2745/* P1_PLROOT2 */
2746#define RSTV0910_P1_PLROOT2 0xf4ac
2747#define FSTV0910_P1_PLSCRAMB_MODE 0xf4ac000c
2748#define FSTV0910_P1_PLSCRAMB_ROOT2 0xf4ac0003
2749
2750/* P1_PLROOT1 */
2751#define RSTV0910_P1_PLROOT1 0xf4ad
2752#define FSTV0910_P1_PLSCRAMB_ROOT1 0xf4ad00ff
2753
2754/* P1_PLROOT0 */
2755#define RSTV0910_P1_PLROOT0 0xf4ae
2756#define FSTV0910_P1_PLSCRAMB_ROOT0 0xf4ae00ff
2757
2758/* P1_MODCODLST0 */
2759#define RSTV0910_P1_MODCODLST0 0xf4b0
2760#define FSTV0910_P1_NACCES_MODCODCH 0xf4b00001
2761
2762/* P1_MODCODLST1 */
2763#define RSTV0910_P1_MODCODLST1 0xf4b1
2764#define FSTV0910_P1_SYMBRATE_FILTER 0xf4b10008
2765#define FSTV0910_P1_NRESET_MODCODLST 0xf4b10004
2766#define FSTV0910_P1_DIS_32PSK_9_10 0xf4b10003
2767
2768/* P1_MODCODLST2 */
2769#define RSTV0910_P1_MODCODLST2 0xf4b2
2770#define FSTV0910_P1_DIS_32PSK_8_9 0xf4b200f0
2771#define FSTV0910_P1_DIS_32PSK_5_6 0xf4b2000f
2772
2773/* P1_MODCODLST3 */
2774#define RSTV0910_P1_MODCODLST3 0xf4b3
2775#define FSTV0910_P1_DIS_32PSK_4_5 0xf4b300f0
2776#define FSTV0910_P1_DIS_32PSK_3_4 0xf4b3000f
2777
2778/* P1_MODCODLST4 */
2779#define RSTV0910_P1_MODCODLST4 0xf4b4
2780#define FSTV0910_P1_DUMMYPL_PILOT 0xf4b40080
2781#define FSTV0910_P1_DUMMYPL_NOPILOT 0xf4b40040
2782#define FSTV0910_P1_DIS_16PSK_9_10 0xf4b40030
2783#define FSTV0910_P1_DIS_16PSK_8_9 0xf4b4000f
2784
2785/* P1_MODCODLST5 */
2786#define RSTV0910_P1_MODCODLST5 0xf4b5
2787#define FSTV0910_P1_DIS_16PSK_5_6 0xf4b500f0
2788#define FSTV0910_P1_DIS_16PSK_4_5 0xf4b5000f
2789
2790/* P1_MODCODLST6 */
2791#define RSTV0910_P1_MODCODLST6 0xf4b6
2792#define FSTV0910_P1_DIS_16PSK_3_4 0xf4b600f0
2793#define FSTV0910_P1_DIS_16PSK_2_3 0xf4b6000f
2794
2795/* P1_MODCODLST7 */
2796#define RSTV0910_P1_MODCODLST7 0xf4b7
2797#define FSTV0910_P1_MODCOD_NNOSFILTER 0xf4b70080
2798#define FSTV0910_P1_DIS_8PSK_9_10 0xf4b70030
2799#define FSTV0910_P1_DIS_8PSK_8_9 0xf4b7000f
2800
2801/* P1_MODCODLST8 */
2802#define RSTV0910_P1_MODCODLST8 0xf4b8
2803#define FSTV0910_P1_DIS_8PSK_5_6 0xf4b800f0
2804#define FSTV0910_P1_DIS_8PSK_3_4 0xf4b8000f
2805
2806/* P1_MODCODLST9 */
2807#define RSTV0910_P1_MODCODLST9 0xf4b9
2808#define FSTV0910_P1_DIS_8PSK_2_3 0xf4b900f0
2809#define FSTV0910_P1_DIS_8PSK_3_5 0xf4b9000f
2810
2811/* P1_MODCODLSTA */
2812#define RSTV0910_P1_MODCODLSTA 0xf4ba
2813#define FSTV0910_P1_NOSFILTER_LIMITE 0xf4ba0080
2814#define FSTV0910_P1_DIS_QPSK_9_10 0xf4ba0030
2815#define FSTV0910_P1_DIS_QPSK_8_9 0xf4ba000f
2816
2817/* P1_MODCODLSTB */
2818#define RSTV0910_P1_MODCODLSTB 0xf4bb
2819#define FSTV0910_P1_DIS_QPSK_5_6 0xf4bb00f0
2820#define FSTV0910_P1_DIS_QPSK_4_5 0xf4bb000f
2821
2822/* P1_MODCODLSTC */
2823#define RSTV0910_P1_MODCODLSTC 0xf4bc
2824#define FSTV0910_P1_DIS_QPSK_3_4 0xf4bc00f0
2825#define FSTV0910_P1_DIS_QPSK_2_3 0xf4bc000f
2826
2827/* P1_MODCODLSTD */
2828#define RSTV0910_P1_MODCODLSTD 0xf4bd
2829#define FSTV0910_P1_DIS_QPSK_3_5 0xf4bd00f0
2830#define FSTV0910_P1_DIS_QPSK_1_2 0xf4bd000f
2831
2832/* P1_MODCODLSTE */
2833#define RSTV0910_P1_MODCODLSTE 0xf4be
2834#define FSTV0910_P1_DIS_QPSK_2_5 0xf4be00f0
2835#define FSTV0910_P1_DIS_QPSK_1_3 0xf4be000f
2836
2837/* P1_MODCODLSTF */
2838#define RSTV0910_P1_MODCODLSTF 0xf4bf
2839#define FSTV0910_P1_DIS_QPSK_1_4 0xf4bf00f0
2840#define FSTV0910_P1_DEMOD_INVMODLST 0xf4bf0008
2841#define FSTV0910_P1_DEMODOUT_ENABLE 0xf4bf0004
2842#define FSTV0910_P1_DDEMOD_NSET 0xf4bf0002
2843#define FSTV0910_P1_MODCOD_NSTOCK 0xf4bf0001
2844
2845/* P1_GAUSSR0 */
2846#define RSTV0910_P1_GAUSSR0 0xf4c0
2847#define FSTV0910_P1_EN_CCIMODE 0xf4c00080
2848#define FSTV0910_P1_R0_GAUSSIEN 0xf4c0007f
2849
2850/* P1_CCIR0 */
2851#define RSTV0910_P1_CCIR0 0xf4c1
2852#define FSTV0910_P1_CCIDETECT_PLHONLY 0xf4c10080
2853#define FSTV0910_P1_R0_CCI 0xf4c1007f
2854
2855/* P1_CCIQUANT */
2856#define RSTV0910_P1_CCIQUANT 0xf4c2
2857#define FSTV0910_P1_CCI_BETA 0xf4c200e0
2858#define FSTV0910_P1_CCI_QUANT 0xf4c2001f
2859
2860/* P1_CCITHRES */
2861#define RSTV0910_P1_CCITHRES 0xf4c3
2862#define FSTV0910_P1_CCI_THRESHOLD 0xf4c300ff
2863
2864/* P1_CCIACC */
2865#define RSTV0910_P1_CCIACC 0xf4c4
2866#define FSTV0910_P1_CCI_VALUE 0xf4c400ff
2867
2868/* P1_DSTATUS4 */
2869#define RSTV0910_P1_DSTATUS4 0xf4c5
2870#define FSTV0910_P1_RAINFADE_DETECT 0xf4c50080
2871#define FSTV0910_P1_NOTHRES2_FAIL 0xf4c50040
2872#define FSTV0910_P1_NOTHRES1_FAIL 0xf4c50020
2873#define FSTV0910_P1_DMDPROG_ERROR 0xf4c50004
2874#define FSTV0910_P1_CSTENV_DETECT 0xf4c50002
2875#define FSTV0910_P1_DETECTION_TRIAX 0xf4c50001
2876
2877/* P1_DMDRESCFG */
2878#define RSTV0910_P1_DMDRESCFG 0xf4c6
2879#define FSTV0910_P1_DMDRES_RESET 0xf4c60080
2880#define FSTV0910_P1_DMDRES_STRALL 0xf4c60008
2881#define FSTV0910_P1_DMDRES_NEWONLY 0xf4c60004
2882#define FSTV0910_P1_DMDRES_NOSTORE 0xf4c60002
2883
2884/* P1_DMDRESADR */
2885#define RSTV0910_P1_DMDRESADR 0xf4c7
2886#define FSTV0910_P1_DMDRES_VALIDCFR 0xf4c70040
2887#define FSTV0910_P1_DMDRES_MEMFULL 0xf4c70030
2888#define FSTV0910_P1_DMDRES_RESNBR 0xf4c7000f
2889
2890/* P1_DMDRESDATA7 */
2891#define RSTV0910_P1_DMDRESDATA7 0xf4c8
2892#define FSTV0910_P1_DMDRES_DATA7 0xf4c800ff
2893
2894/* P1_DMDRESDATA6 */
2895#define RSTV0910_P1_DMDRESDATA6 0xf4c9
2896#define FSTV0910_P1_DMDRES_DATA6 0xf4c900ff
2897
2898/* P1_DMDRESDATA5 */
2899#define RSTV0910_P1_DMDRESDATA5 0xf4ca
2900#define FSTV0910_P1_DMDRES_DATA5 0xf4ca00ff
2901
2902/* P1_DMDRESDATA4 */
2903#define RSTV0910_P1_DMDRESDATA4 0xf4cb
2904#define FSTV0910_P1_DMDRES_DATA4 0xf4cb00ff
2905
2906/* P1_DMDRESDATA3 */
2907#define RSTV0910_P1_DMDRESDATA3 0xf4cc
2908#define FSTV0910_P1_DMDRES_DATA3 0xf4cc00ff
2909
2910/* P1_DMDRESDATA2 */
2911#define RSTV0910_P1_DMDRESDATA2 0xf4cd
2912#define FSTV0910_P1_DMDRES_DATA2 0xf4cd00ff
2913
2914/* P1_DMDRESDATA1 */
2915#define RSTV0910_P1_DMDRESDATA1 0xf4ce
2916#define FSTV0910_P1_DMDRES_DATA1 0xf4ce00ff
2917
2918/* P1_DMDRESDATA0 */
2919#define RSTV0910_P1_DMDRESDATA0 0xf4cf
2920#define FSTV0910_P1_DMDRES_DATA0 0xf4cf00ff
2921
2922/* P1_FFEI1 */
2923#define RSTV0910_P1_FFEI1 0xf4d0
2924#define FSTV0910_P1_FFE_ACCI1 0xf4d001ff
2925
2926/* P1_FFEQ1 */
2927#define RSTV0910_P1_FFEQ1 0xf4d1
2928#define FSTV0910_P1_FFE_ACCQ1 0xf4d101ff
2929
2930/* P1_FFEI2 */
2931#define RSTV0910_P1_FFEI2 0xf4d2
2932#define FSTV0910_P1_FFE_ACCI2 0xf4d201ff
2933
2934/* P1_FFEQ2 */
2935#define RSTV0910_P1_FFEQ2 0xf4d3
2936#define FSTV0910_P1_FFE_ACCQ2 0xf4d301ff
2937
2938/* P1_FFEI3 */
2939#define RSTV0910_P1_FFEI3 0xf4d4
2940#define FSTV0910_P1_FFE_ACCI3 0xf4d401ff
2941
2942/* P1_FFEQ3 */
2943#define RSTV0910_P1_FFEQ3 0xf4d5
2944#define FSTV0910_P1_FFE_ACCQ3 0xf4d501ff
2945
2946/* P1_FFEI4 */
2947#define RSTV0910_P1_FFEI4 0xf4d6
2948#define FSTV0910_P1_FFE_ACCI4 0xf4d601ff
2949
2950/* P1_FFEQ4 */
2951#define RSTV0910_P1_FFEQ4 0xf4d7
2952#define FSTV0910_P1_FFE_ACCQ4 0xf4d701ff
2953
2954/* P1_FFECFG */
2955#define RSTV0910_P1_FFECFG 0xf4d8
2956#define FSTV0910_P1_EQUALFFE_ON 0xf4d80040
2957#define FSTV0910_P1_EQUAL_USEDSYMB 0xf4d80030
2958#define FSTV0910_P1_MU_EQUALFFE 0xf4d80007
2959
2960/* P1_TNRCFG2 */
2961#define RSTV0910_P1_TNRCFG2 0xf4e1
2962#define FSTV0910_P1_TUN_IQSWAP 0xf4e10080
2963
2964/* P1_SMAPCOEF7 */
2965#define RSTV0910_P1_SMAPCOEF7 0xf500
2966#define FSTV0910_P1_DIS_QSCALE 0xf5000080
2967#define FSTV0910_P1_SMAPCOEF_Q_LLR12 0xf500017f
2968
2969/* P1_SMAPCOEF6 */
2970#define RSTV0910_P1_SMAPCOEF6 0xf501
2971#define FSTV0910_P1_DIS_AGC2SCALE 0xf5010080
2972#define FSTV0910_P1_ADJ_8PSKLLR1 0xf5010004
2973#define FSTV0910_P1_OLD_8PSKLLR1 0xf5010002
2974#define FSTV0910_P1_DIS_AB8PSK 0xf5010001
2975
2976/* P1_SMAPCOEF5 */
2977#define RSTV0910_P1_SMAPCOEF5 0xf502
2978#define FSTV0910_P1_DIS_8SCALE 0xf5020080
2979#define FSTV0910_P1_SMAPCOEF_8P_LLR23 0xf502017f
2980
2981/* P1_SMAPCOEF4 */
2982#define RSTV0910_P1_SMAPCOEF4 0xf503
2983#define FSTV0910_P1_SMAPCOEF_16APSK_LLR12 0xf503017f
2984
2985/* P1_SMAPCOEF3 */
2986#define RSTV0910_P1_SMAPCOEF3 0xf504
2987#define FSTV0910_P1_SMAPCOEF_16APSK_LLR34 0xf504017f
2988
2989/* P1_SMAPCOEF2 */
2990#define RSTV0910_P1_SMAPCOEF2 0xf505
2991#define FSTV0910_P1_SMAPCOEF_32APSK_R2R3 0xf50501f0
2992#define FSTV0910_P1_SMAPCOEF_32APSK_LLR2 0xf505010f
2993
2994/* P1_SMAPCOEF1 */
2995#define RSTV0910_P1_SMAPCOEF1 0xf506
2996#define FSTV0910_P1_DIS_16SCALE 0xf5060080
2997#define FSTV0910_P1_SMAPCOEF_32_LLR34 0xf506017f
2998
2999/* P1_SMAPCOEF0 */
3000#define RSTV0910_P1_SMAPCOEF0 0xf507
3001#define FSTV0910_P1_DIS_32SCALE 0xf5070080
3002#define FSTV0910_P1_SMAPCOEF_32_LLR15 0xf507017f
3003
3004/* P1_NOSTHRES1 */
3005#define RSTV0910_P1_NOSTHRES1 0xf509
3006#define FSTV0910_P1_NOS_THRESHOLD1 0xf50900ff
3007
3008/* P1_NOSTHRES2 */
3009#define RSTV0910_P1_NOSTHRES2 0xf50a
3010#define FSTV0910_P1_NOS_THRESHOLD2 0xf50a00ff
3011
3012/* P1_NOSDIFF1 */
3013#define RSTV0910_P1_NOSDIFF1 0xf50b
3014#define FSTV0910_P1_NOSTHRES1_DIFF 0xf50b00ff
3015
3016/* P1_RAINFADE */
3017#define RSTV0910_P1_RAINFADE 0xf50c
3018#define FSTV0910_P1_NOSTHRES_DATAT 0xf50c0080
3019#define FSTV0910_P1_RAINFADE_CNLIMIT 0xf50c0070
3020#define FSTV0910_P1_RAINFADE_TIMEOUT 0xf50c0007
3021
3022/* P1_NOSRAMCFG */
3023#define RSTV0910_P1_NOSRAMCFG 0xf50d
3024#define FSTV0910_P1_NOSRAM_ACTIVATION 0xf50d0030
3025#define FSTV0910_P1_NOSRAM_CNRONLY 0xf50d0008
3026#define FSTV0910_P1_NOSRAM_LGNCNR1 0xf50d0007
3027
3028/* P1_NOSRAMPOS */
3029#define RSTV0910_P1_NOSRAMPOS 0xf50e
3030#define FSTV0910_P1_NOSRAM_LGNCNR0 0xf50e00f0
3031#define FSTV0910_P1_NOSRAM_VALIDE 0xf50e0004
3032#define FSTV0910_P1_NOSRAM_CNRVAL1 0xf50e0003
3033
3034/* P1_NOSRAMVAL */
3035#define RSTV0910_P1_NOSRAMVAL 0xf50f
3036#define FSTV0910_P1_NOSRAM_CNRVAL0 0xf50f00ff
3037
3038/* P1_DMDPLHSTAT */
3039#define RSTV0910_P1_DMDPLHSTAT 0xf520
3040#define FSTV0910_P1_PLH_STATISTIC 0xf52000ff
3041
3042/* P1_LOCKTIME3 */
3043#define RSTV0910_P1_LOCKTIME3 0xf522
3044#define FSTV0910_P1_DEMOD_LOCKTIME3 0xf52200ff
3045
3046/* P1_LOCKTIME2 */
3047#define RSTV0910_P1_LOCKTIME2 0xf523
3048#define FSTV0910_P1_DEMOD_LOCKTIME2 0xf52300ff
3049
3050/* P1_LOCKTIME1 */
3051#define RSTV0910_P1_LOCKTIME1 0xf524
3052#define FSTV0910_P1_DEMOD_LOCKTIME1 0xf52400ff
3053
3054/* P1_LOCKTIME0 */
3055#define RSTV0910_P1_LOCKTIME0 0xf525
3056#define FSTV0910_P1_DEMOD_LOCKTIME0 0xf52500ff
3057
3058/* P1_VITSCALE */
3059#define RSTV0910_P1_VITSCALE 0xf532
3060#define FSTV0910_P1_NVTH_NOSRANGE 0xf5320080
3061#define FSTV0910_P1_VERROR_MAXMODE 0xf5320040
3062#define FSTV0910_P1_NSLOWSN_LOCKED 0xf5320008
3063#define FSTV0910_P1_DIS_RSFLOCK 0xf5320002
3064
3065/* P1_FECM */
3066#define RSTV0910_P1_FECM 0xf533
3067#define FSTV0910_P1_DSS_DVB 0xf5330080
3068#define FSTV0910_P1_DSS_SRCH 0xf5330010
3069#define FSTV0910_P1_SYNCVIT 0xf5330002
3070#define FSTV0910_P1_IQINV 0xf5330001
3071
3072/* P1_VTH12 */
3073#define RSTV0910_P1_VTH12 0xf534
3074#define FSTV0910_P1_VTH12 0xf53400ff
3075
3076/* P1_VTH23 */
3077#define RSTV0910_P1_VTH23 0xf535
3078#define FSTV0910_P1_VTH23 0xf53500ff
3079
3080/* P1_VTH34 */
3081#define RSTV0910_P1_VTH34 0xf536
3082#define FSTV0910_P1_VTH34 0xf53600ff
3083
3084/* P1_VTH56 */
3085#define RSTV0910_P1_VTH56 0xf537
3086#define FSTV0910_P1_VTH56 0xf53700ff
3087
3088/* P1_VTH67 */
3089#define RSTV0910_P1_VTH67 0xf538
3090#define FSTV0910_P1_VTH67 0xf53800ff
3091
3092/* P1_VTH78 */
3093#define RSTV0910_P1_VTH78 0xf539
3094#define FSTV0910_P1_VTH78 0xf53900ff
3095
3096/* P1_VITCURPUN */
3097#define RSTV0910_P1_VITCURPUN 0xf53a
3098#define FSTV0910_P1_VIT_CURPUN 0xf53a001f
3099
3100/* P1_VERROR */
3101#define RSTV0910_P1_VERROR 0xf53b
3102#define FSTV0910_P1_REGERR_VIT 0xf53b00ff
3103
3104/* P1_PRVIT */
3105#define RSTV0910_P1_PRVIT 0xf53c
3106#define FSTV0910_P1_DIS_VTHLOCK 0xf53c0040
3107#define FSTV0910_P1_E7_8VIT 0xf53c0020
3108#define FSTV0910_P1_E6_7VIT 0xf53c0010
3109#define FSTV0910_P1_E5_6VIT 0xf53c0008
3110#define FSTV0910_P1_E3_4VIT 0xf53c0004
3111#define FSTV0910_P1_E2_3VIT 0xf53c0002
3112#define FSTV0910_P1_E1_2VIT 0xf53c0001
3113
3114/* P1_VAVSRVIT */
3115#define RSTV0910_P1_VAVSRVIT 0xf53d
3116#define FSTV0910_P1_AMVIT 0xf53d0080
3117#define FSTV0910_P1_FROZENVIT 0xf53d0040
3118#define FSTV0910_P1_SNVIT 0xf53d0030
3119#define FSTV0910_P1_TOVVIT 0xf53d000c
3120#define FSTV0910_P1_HYPVIT 0xf53d0003
3121
3122/* P1_VSTATUSVIT */
3123#define RSTV0910_P1_VSTATUSVIT 0xf53e
3124#define FSTV0910_P1_PRFVIT 0xf53e0010
3125#define FSTV0910_P1_LOCKEDVIT 0xf53e0008
3126
3127/* P1_VTHINUSE */
3128#define RSTV0910_P1_VTHINUSE 0xf53f
3129#define FSTV0910_P1_VIT_INUSE 0xf53f00ff
3130
3131/* P1_KDIV12 */
3132#define RSTV0910_P1_KDIV12 0xf540
3133#define FSTV0910_P1_K_DIVIDER_12 0xf540007f
3134
3135/* P1_KDIV23 */
3136#define RSTV0910_P1_KDIV23 0xf541
3137#define FSTV0910_P1_K_DIVIDER_23 0xf541007f
3138
3139/* P1_KDIV34 */
3140#define RSTV0910_P1_KDIV34 0xf542
3141#define FSTV0910_P1_K_DIVIDER_34 0xf542007f
3142
3143/* P1_KDIV56 */
3144#define RSTV0910_P1_KDIV56 0xf543
3145#define FSTV0910_P1_K_DIVIDER_56 0xf543007f
3146
3147/* P1_KDIV67 */
3148#define RSTV0910_P1_KDIV67 0xf544
3149#define FSTV0910_P1_K_DIVIDER_67 0xf544007f
3150
3151/* P1_KDIV78 */
3152#define RSTV0910_P1_KDIV78 0xf545
3153#define FSTV0910_P1_K_DIVIDER_78 0xf545007f
3154
3155/* P1_TSPIDFLT1 */
3156#define RSTV0910_P1_TSPIDFLT1 0xf546
3157#define FSTV0910_P1_PIDFLT_ADDR 0xf54600ff
3158
3159/* P1_TSPIDFLT0 */
3160#define RSTV0910_P1_TSPIDFLT0 0xf547
3161#define FSTV0910_P1_PIDFLT_DATA 0xf54700ff
3162
3163/* P1_PDELCTRL0 */
3164#define RSTV0910_P1_PDELCTRL0 0xf54f
3165#define FSTV0910_P1_ISIOBS_MODE 0xf54f0030
3166
3167/* P1_PDELCTRL1 */
3168#define RSTV0910_P1_PDELCTRL1 0xf550
3169#define FSTV0910_P1_INV_MISMASK 0xf5500080
3170#define FSTV0910_P1_FILTER_EN 0xf5500020
3171#define FSTV0910_P1_HYSTEN 0xf5500008
3172#define FSTV0910_P1_HYSTSWRST 0xf5500004
3173#define FSTV0910_P1_EN_MIS00 0xf5500002
3174#define FSTV0910_P1_ALGOSWRST 0xf5500001
3175
3176/* P1_PDELCTRL2 */
3177#define RSTV0910_P1_PDELCTRL2 0xf551
3178#define FSTV0910_P1_FORCE_CONTINUOUS 0xf5510080
3179#define FSTV0910_P1_RESET_UPKO_COUNT 0xf5510040
3180#define FSTV0910_P1_USER_PKTDELIN_NB 0xf5510020
3181#define FSTV0910_P1_FRAME_MODE 0xf5510002
3182
3183/* P1_HYSTTHRESH */
3184#define RSTV0910_P1_HYSTTHRESH 0xf554
3185#define FSTV0910_P1_DELIN_LOCKTHRES 0xf55400f0
3186#define FSTV0910_P1_DELIN_UNLOCKTHRES 0xf554000f
3187
3188/* P1_UPLCCST0 */
3189#define RSTV0910_P1_UPLCCST0 0xf558
3190#define FSTV0910_P1_UPL_CST0 0xf55800f8
3191#define FSTV0910_P1_UPL_MODE 0xf5580007
3192
3193/* P1_ISIENTRY */
3194#define RSTV0910_P1_ISIENTRY 0xf55e
3195#define FSTV0910_P1_ISI_ENTRY 0xf55e00ff
3196
3197/* P1_ISIBITENA */
3198#define RSTV0910_P1_ISIBITENA 0xf55f
3199#define FSTV0910_P1_ISI_BIT_EN 0xf55f00ff
3200
3201/* P1_MATSTR1 */
3202#define RSTV0910_P1_MATSTR1 0xf560
3203#define FSTV0910_P1_MATYPE_CURRENT1 0xf56000ff
3204
3205/* P1_MATSTR0 */
3206#define RSTV0910_P1_MATSTR0 0xf561
3207#define FSTV0910_P1_MATYPE_CURRENT0 0xf56100ff
3208
3209/* P1_UPLSTR1 */
3210#define RSTV0910_P1_UPLSTR1 0xf562
3211#define FSTV0910_P1_UPL_CURRENT1 0xf56200ff
3212
3213/* P1_UPLSTR0 */
3214#define RSTV0910_P1_UPLSTR0 0xf563
3215#define FSTV0910_P1_UPL_CURRENT0 0xf56300ff
3216
3217/* P1_DFLSTR1 */
3218#define RSTV0910_P1_DFLSTR1 0xf564
3219#define FSTV0910_P1_DFL_CURRENT1 0xf56400ff
3220
3221/* P1_DFLSTR0 */
3222#define RSTV0910_P1_DFLSTR0 0xf565
3223#define FSTV0910_P1_DFL_CURRENT0 0xf56500ff
3224
3225/* P1_SYNCSTR */
3226#define RSTV0910_P1_SYNCSTR 0xf566
3227#define FSTV0910_P1_SYNC_CURRENT 0xf56600ff
3228
3229/* P1_SYNCDSTR1 */
3230#define RSTV0910_P1_SYNCDSTR1 0xf567
3231#define FSTV0910_P1_SYNCD_CURRENT1 0xf56700ff
3232
3233/* P1_SYNCDSTR0 */
3234#define RSTV0910_P1_SYNCDSTR0 0xf568
3235#define FSTV0910_P1_SYNCD_CURRENT0 0xf56800ff
3236
3237/* P1_PDELSTATUS1 */
3238#define RSTV0910_P1_PDELSTATUS1 0xf569
3239#define FSTV0910_P1_PKTDELIN_DELOCK 0xf5690080
3240#define FSTV0910_P1_SYNCDUPDFL_BADDFL 0xf5690040
3241#define FSTV0910_P1_UNACCEPTED_STREAM 0xf5690010
3242#define FSTV0910_P1_BCH_ERROR_FLAG 0xf5690008
3243#define FSTV0910_P1_PKTDELIN_LOCK 0xf5690002
3244#define FSTV0910_P1_FIRST_LOCK 0xf5690001
3245
3246/* P1_PDELSTATUS2 */
3247#define RSTV0910_P1_PDELSTATUS2 0xf56a
3248#define FSTV0910_P1_FRAME_MODCOD 0xf56a007c
3249#define FSTV0910_P1_FRAME_TYPE 0xf56a0003
3250
3251/* P1_BBFCRCKO1 */
3252#define RSTV0910_P1_BBFCRCKO1 0xf56b
3253#define FSTV0910_P1_BBHCRC_KOCNT1 0xf56b00ff
3254
3255/* P1_BBFCRCKO0 */
3256#define RSTV0910_P1_BBFCRCKO0 0xf56c
3257#define FSTV0910_P1_BBHCRC_KOCNT0 0xf56c00ff
3258
3259/* P1_UPCRCKO1 */
3260#define RSTV0910_P1_UPCRCKO1 0xf56d
3261#define FSTV0910_P1_PKTCRC_KOCNT1 0xf56d00ff
3262
3263/* P1_UPCRCKO0 */
3264#define RSTV0910_P1_UPCRCKO0 0xf56e
3265#define FSTV0910_P1_PKTCRC_KOCNT0 0xf56e00ff
3266
3267/* P1_PDELCTRL3 */
3268#define RSTV0910_P1_PDELCTRL3 0xf56f
3269#define FSTV0910_P1_NOFIFO_BCHERR 0xf56f0020
3270#define FSTV0910_P1_PKTDELIN_DELACMERR 0xf56f0010
3271
3272/* P1_TSSTATEM */
3273#define RSTV0910_P1_TSSTATEM 0xf570
3274#define FSTV0910_P1_TSDIL_ON 0xf5700080
3275#define FSTV0910_P1_TSRS_ON 0xf5700020
3276#define FSTV0910_P1_TSDESCRAMB_ON 0xf5700010
3277#define FSTV0910_P1_TSFRAME_MODE 0xf5700008
3278#define FSTV0910_P1_TS_DISABLE 0xf5700004
3279#define FSTV0910_P1_TSACM_MODE 0xf5700002
3280#define FSTV0910_P1_TSOUT_NOSYNC 0xf5700001
3281
3282/* P1_TSSTATEL */
3283#define RSTV0910_P1_TSSTATEL 0xf571
3284#define FSTV0910_P1_TSNOSYNCBYTE 0xf5710080
3285#define FSTV0910_P1_TSPARITY_ON 0xf5710040
3286#define FSTV0910_P1_TSISSYI_ON 0xf5710008
3287#define FSTV0910_P1_TSNPD_ON 0xf5710004
3288#define FSTV0910_P1_TSCRC8_ON 0xf5710002
3289#define FSTV0910_P1_TSDSS_PACKET 0xf5710001
3290
3291/* P1_TSCFGH */
3292#define RSTV0910_P1_TSCFGH 0xf572
3293#define FSTV0910_P1_TSFIFO_DVBCI 0xf5720080
3294#define FSTV0910_P1_TSFIFO_SERIAL 0xf5720040
3295#define FSTV0910_P1_TSFIFO_TEIUPDATE 0xf5720020
3296#define FSTV0910_P1_TSFIFO_DUTY50 0xf5720010
3297#define FSTV0910_P1_TSFIFO_HSGNLOUT 0xf5720008
3298#define FSTV0910_P1_TSFIFO_ERRMODE 0xf5720006
3299#define FSTV0910_P1_RST_HWARE 0xf5720001
3300
3301/* P1_TSCFGM */
3302#define RSTV0910_P1_TSCFGM 0xf573
3303#define FSTV0910_P1_TSFIFO_MANSPEED 0xf57300c0
3304#define FSTV0910_P1_TSFIFO_PERMDATA 0xf5730020
3305#define FSTV0910_P1_TSFIFO_NONEWSGNL 0xf5730010
3306#define FSTV0910_P1_TSFIFO_INVDATA 0xf5730001
3307
3308/* P1_TSCFGL */
3309#define RSTV0910_P1_TSCFGL 0xf574
3310#define FSTV0910_P1_TSFIFO_BCLKDEL1CK 0xf57400c0
3311#define FSTV0910_P1_BCHERROR_MODE 0xf5740030
3312#define FSTV0910_P1_TSFIFO_NSGNL2DATA 0xf5740008
3313#define FSTV0910_P1_TSFIFO_EMBINDVB 0xf5740004
3314#define FSTV0910_P1_TSFIFO_BITSPEED 0xf5740003
3315
3316/* P1_TSSYNC */
3317#define RSTV0910_P1_TSSYNC 0xf575
3318#define FSTV0910_P1_TSFIFO_SYNCMODE 0xf5750018
3319
3320/* P1_TSINSDELH */
3321#define RSTV0910_P1_TSINSDELH 0xf576
3322#define FSTV0910_P1_TSDEL_SYNCBYTE 0xf5760080
3323#define FSTV0910_P1_TSDEL_XXHEADER 0xf5760040
3324#define FSTV0910_P1_TSDEL_DATAFIELD 0xf5760010
3325#define FSTV0910_P1_TSINSDEL_RSPARITY 0xf5760002
3326#define FSTV0910_P1_TSINSDEL_CRC8 0xf5760001
3327
3328/* P1_TSINSDELM */
3329#define RSTV0910_P1_TSINSDELM 0xf577
3330#define FSTV0910_P1_TSINS_EMODCOD 0xf5770010
3331#define FSTV0910_P1_TSINS_TOKEN 0xf5770008
3332#define FSTV0910_P1_TSINS_XXXERR 0xf5770004
3333#define FSTV0910_P1_TSINS_MATYPE 0xf5770002
3334#define FSTV0910_P1_TSINS_UPL 0xf5770001
3335
3336/* P1_TSINSDELL */
3337#define RSTV0910_P1_TSINSDELL 0xf578
3338#define FSTV0910_P1_TSINS_DFL 0xf5780080
3339#define FSTV0910_P1_TSINS_SYNCD 0xf5780040
3340#define FSTV0910_P1_TSINS_BLOCLEN 0xf5780020
3341#define FSTV0910_P1_TSINS_SIGPCOUNT 0xf5780010
3342#define FSTV0910_P1_TSINS_FIFO 0xf5780008
3343#define FSTV0910_P1_TSINS_REALPACK 0xf5780004
3344#define FSTV0910_P1_TSINS_TSCONFIG 0xf5780002
3345#define FSTV0910_P1_TSINS_LATENCY 0xf5780001
3346
3347/* P1_TSDIVN */
3348#define RSTV0910_P1_TSDIVN 0xf579
3349#define FSTV0910_P1_TSFIFO_SPEEDMODE 0xf57900c0
3350#define FSTV0910_P1_TSFIFO_RISEOK 0xf5790007
3351
3352/* P1_TSCFG4 */
3353#define RSTV0910_P1_TSCFG4 0xf57a
3354#define FSTV0910_P1_TSFIFO_TSSPEEDMODE 0xf57a00c0
3355
3356/* P1_TSSPEED */
3357#define RSTV0910_P1_TSSPEED 0xf580
3358#define FSTV0910_P1_TSFIFO_OUTSPEED 0xf58000ff
3359
3360/* P1_TSSTATUS */
3361#define RSTV0910_P1_TSSTATUS 0xf581
3362#define FSTV0910_P1_TSFIFO_LINEOK 0xf5810080
3363#define FSTV0910_P1_TSFIFO_ERROR 0xf5810040
3364#define FSTV0910_P1_TSFIFO_NOSYNC 0xf5810010
3365#define FSTV0910_P1_TSREGUL_ERROR 0xf5810004
3366#define FSTV0910_P1_DIL_READY 0xf5810001
3367
3368/* P1_TSSTATUS2 */
3369#define RSTV0910_P1_TSSTATUS2 0xf582
3370#define FSTV0910_P1_TSFIFO_DEMODSEL 0xf5820080
3371#define FSTV0910_P1_TSFIFOSPEED_STORE 0xf5820040
3372#define FSTV0910_P1_DILXX_RESET 0xf5820020
3373#define FSTV0910_P1_SCRAMBDETECT 0xf5820002
3374
3375/* P1_TSBITRATE1 */
3376#define RSTV0910_P1_TSBITRATE1 0xf583
3377#define FSTV0910_P1_TSFIFO_BITRATE1 0xf58300ff
3378
3379/* P1_TSBITRATE0 */
3380#define RSTV0910_P1_TSBITRATE0 0xf584
3381#define FSTV0910_P1_TSFIFO_BITRATE0 0xf58400ff
3382
3383/* P1_TSPACKLEN1 */
3384#define RSTV0910_P1_TSPACKLEN1 0xf585
3385#define FSTV0910_P1_TSFIFO_PACKCPT 0xf58500e0
3386
3387/* P1_TSDLY2 */
3388#define RSTV0910_P1_TSDLY2 0xf589
3389#define FSTV0910_P1_SOFFIFO_LATENCY2 0xf589000f
3390
3391/* P1_TSDLY1 */
3392#define RSTV0910_P1_TSDLY1 0xf58a
3393#define FSTV0910_P1_SOFFIFO_LATENCY1 0xf58a00ff
3394
3395/* P1_TSDLY0 */
3396#define RSTV0910_P1_TSDLY0 0xf58b
3397#define FSTV0910_P1_SOFFIFO_LATENCY0 0xf58b00ff
3398
3399/* P1_TSNPDAV */
3400#define RSTV0910_P1_TSNPDAV 0xf58c
3401#define FSTV0910_P1_TSNPD_AVERAGE 0xf58c00ff
3402
3403/* P1_TSBUFSTAT2 */
3404#define RSTV0910_P1_TSBUFSTAT2 0xf58d
3405#define FSTV0910_P1_TSISCR_3BYTES 0xf58d0080
3406#define FSTV0910_P1_TSISCR_NEWDATA 0xf58d0040
3407#define FSTV0910_P1_TSISCR_BUFSTAT2 0xf58d003f
3408
3409/* P1_TSBUFSTAT1 */
3410#define RSTV0910_P1_TSBUFSTAT1 0xf58e
3411#define FSTV0910_P1_TSISCR_BUFSTAT1 0xf58e00ff
3412
3413/* P1_TSBUFSTAT0 */
3414#define RSTV0910_P1_TSBUFSTAT0 0xf58f
3415#define FSTV0910_P1_TSISCR_BUFSTAT0 0xf58f00ff
3416
3417/* P1_TSDEBUGL */
3418#define RSTV0910_P1_TSDEBUGL 0xf591
3419#define FSTV0910_P1_TSFIFO_ERROR_EVNT 0xf5910004
3420#define FSTV0910_P1_TSFIFO_OVERFLOWM 0xf5910001
3421
3422/* P1_TSDLYSET2 */
3423#define RSTV0910_P1_TSDLYSET2 0xf592
3424#define FSTV0910_P1_SOFFIFO_OFFSET 0xf59200c0
3425#define FSTV0910_P1_HYSTERESIS_THRESHOLD 0xf5920030
3426#define FSTV0910_P1_SOFFIFO_SYMBOFFS2 0xf592000f
3427
3428/* P1_TSDLYSET1 */
3429#define RSTV0910_P1_TSDLYSET1 0xf593
3430#define FSTV0910_P1_SOFFIFO_SYMBOFFS1 0xf59300ff
3431
3432/* P1_TSDLYSET0 */
3433#define RSTV0910_P1_TSDLYSET0 0xf594
3434#define FSTV0910_P1_SOFFIFO_SYMBOFFS0 0xf59400ff
3435
3436/* P1_ERRCTRL1 */
3437#define RSTV0910_P1_ERRCTRL1 0xf598
3438#define FSTV0910_P1_ERR_SOURCE1 0xf59800f0
3439#define FSTV0910_P1_NUM_EVENT1 0xf5980007
3440
3441/* P1_ERRCNT12 */
3442#define RSTV0910_P1_ERRCNT12 0xf599
3443#define FSTV0910_P1_ERRCNT1_OLDVALUE 0xf5990080
3444#define FSTV0910_P1_ERR_CNT12 0xf599007f
3445
3446/* P1_ERRCNT11 */
3447#define RSTV0910_P1_ERRCNT11 0xf59a
3448#define FSTV0910_P1_ERR_CNT11 0xf59a00ff
3449
3450/* P1_ERRCNT10 */
3451#define RSTV0910_P1_ERRCNT10 0xf59b
3452#define FSTV0910_P1_ERR_CNT10 0xf59b00ff
3453
3454/* P1_ERRCTRL2 */
3455#define RSTV0910_P1_ERRCTRL2 0xf59c
3456#define FSTV0910_P1_ERR_SOURCE2 0xf59c00f0
3457#define FSTV0910_P1_NUM_EVENT2 0xf59c0007
3458
3459/* P1_ERRCNT22 */
3460#define RSTV0910_P1_ERRCNT22 0xf59d
3461#define FSTV0910_P1_ERRCNT2_OLDVALUE 0xf59d0080
3462#define FSTV0910_P1_ERR_CNT22 0xf59d007f
3463
3464/* P1_ERRCNT21 */
3465#define RSTV0910_P1_ERRCNT21 0xf59e
3466#define FSTV0910_P1_ERR_CNT21 0xf59e00ff
3467
3468/* P1_ERRCNT20 */
3469#define RSTV0910_P1_ERRCNT20 0xf59f
3470#define FSTV0910_P1_ERR_CNT20 0xf59f00ff
3471
3472/* P1_FECSPY */
3473#define RSTV0910_P1_FECSPY 0xf5a0
3474#define FSTV0910_P1_SPY_ENABLE 0xf5a00080
3475#define FSTV0910_P1_NO_SYNCBYTE 0xf5a00040
3476#define FSTV0910_P1_SERIAL_MODE 0xf5a00020
3477#define FSTV0910_P1_UNUSUAL_PACKET 0xf5a00010
3478#define FSTV0910_P1_BERMETER_DATAMODE 0xf5a0000c
3479#define FSTV0910_P1_BERMETER_LMODE 0xf5a00002
3480#define FSTV0910_P1_BERMETER_RESET 0xf5a00001
3481
3482/* P1_FSPYCFG */
3483#define RSTV0910_P1_FSPYCFG 0xf5a1
3484#define FSTV0910_P1_FECSPY_INPUT 0xf5a100c0
3485#define FSTV0910_P1_RST_ON_ERROR 0xf5a10020
3486#define FSTV0910_P1_ONE_SHOT 0xf5a10010
3487#define FSTV0910_P1_I2C_MODE 0xf5a1000c
3488#define FSTV0910_P1_SPY_HYSTERESIS 0xf5a10003
3489
3490/* P1_FSPYDATA */
3491#define RSTV0910_P1_FSPYDATA 0xf5a2
3492#define FSTV0910_P1_SPY_STUFFING 0xf5a20080
3493#define FSTV0910_P1_SPY_CNULLPKT 0xf5a20020
3494#define FSTV0910_P1_SPY_OUTDATA_MODE 0xf5a2001f
3495
3496/* P1_FSPYOUT */
3497#define RSTV0910_P1_FSPYOUT 0xf5a3
3498#define FSTV0910_P1_FSPY_DIRECT 0xf5a30080
3499#define FSTV0910_P1_STUFF_MODE 0xf5a30007
3500
3501/* P1_FSTATUS */
3502#define RSTV0910_P1_FSTATUS 0xf5a4
3503#define FSTV0910_P1_SPY_ENDSIM 0xf5a40080
3504#define FSTV0910_P1_VALID_SIM 0xf5a40040
3505#define FSTV0910_P1_FOUND_SIGNAL 0xf5a40020
3506#define FSTV0910_P1_DSS_SYNCBYTE 0xf5a40010
3507#define FSTV0910_P1_RESULT_STATE 0xf5a4000f
3508
3509/* P1_FBERCPT4 */
3510#define RSTV0910_P1_FBERCPT4 0xf5a8
3511#define FSTV0910_P1_FBERMETER_CPT4 0xf5a800ff
3512
3513/* P1_FBERCPT3 */
3514#define RSTV0910_P1_FBERCPT3 0xf5a9
3515#define FSTV0910_P1_FBERMETER_CPT3 0xf5a900ff
3516
3517/* P1_FBERCPT2 */
3518#define RSTV0910_P1_FBERCPT2 0xf5aa
3519#define FSTV0910_P1_FBERMETER_CPT2 0xf5aa00ff
3520
3521/* P1_FBERCPT1 */
3522#define RSTV0910_P1_FBERCPT1 0xf5ab
3523#define FSTV0910_P1_FBERMETER_CPT1 0xf5ab00ff
3524
3525/* P1_FBERCPT0 */
3526#define RSTV0910_P1_FBERCPT0 0xf5ac
3527#define FSTV0910_P1_FBERMETER_CPT0 0xf5ac00ff
3528
3529/* P1_FBERERR2 */
3530#define RSTV0910_P1_FBERERR2 0xf5ad
3531#define FSTV0910_P1_FBERMETER_ERR2 0xf5ad00ff
3532
3533/* P1_FBERERR1 */
3534#define RSTV0910_P1_FBERERR1 0xf5ae
3535#define FSTV0910_P1_FBERMETER_ERR1 0xf5ae00ff
3536
3537/* P1_FBERERR0 */
3538#define RSTV0910_P1_FBERERR0 0xf5af
3539#define FSTV0910_P1_FBERMETER_ERR0 0xf5af00ff
3540
3541/* P1_FSPYBER */
3542#define RSTV0910_P1_FSPYBER 0xf5b2
3543#define FSTV0910_P1_FSPYBER_SYNCBYTE 0xf5b20010
3544#define FSTV0910_P1_FSPYBER_UNSYNC 0xf5b20008
3545#define FSTV0910_P1_FSPYBER_CTIME 0xf5b20007
3546
3547/* P1_SFERROR */
3548#define RSTV0910_P1_SFERROR 0xf5c1
3549#define FSTV0910_P1_SFEC_REGERR_VIT 0xf5c100ff
3550
3551/* P1_SFECSTATUS */
3552#define RSTV0910_P1_SFECSTATUS 0xf5c3
3553#define FSTV0910_P1_SFEC_ON 0xf5c30080
3554#define FSTV0910_P1_SFEC_OFF 0xf5c30040
3555#define FSTV0910_P1_LOCKEDSFEC 0xf5c30008
3556#define FSTV0910_P1_SFEC_DELOCK 0xf5c30004
3557#define FSTV0910_P1_SFEC_DEMODSEL 0xf5c30002
3558#define FSTV0910_P1_SFEC_OVFON 0xf5c30001
3559
3560/* P1_SFKDIV12 */
3561#define RSTV0910_P1_SFKDIV12 0xf5c4
3562#define FSTV0910_P1_SFECKDIV12_MAN 0xf5c40080
3563
3564/* P1_SFKDIV23 */
3565#define RSTV0910_P1_SFKDIV23 0xf5c5
3566#define FSTV0910_P1_SFECKDIV23_MAN 0xf5c50080
3567
3568/* P1_SFKDIV34 */
3569#define RSTV0910_P1_SFKDIV34 0xf5c6
3570#define FSTV0910_P1_SFECKDIV34_MAN 0xf5c60080
3571
3572/* P1_SFKDIV56 */
3573#define RSTV0910_P1_SFKDIV56 0xf5c7
3574#define FSTV0910_P1_SFECKDIV56_MAN 0xf5c70080
3575
3576/* P1_SFKDIV67 */
3577#define RSTV0910_P1_SFKDIV67 0xf5c8
3578#define FSTV0910_P1_SFECKDIV67_MAN 0xf5c80080
3579
3580/* P1_SFKDIV78 */
3581#define RSTV0910_P1_SFKDIV78 0xf5c9
3582#define FSTV0910_P1_SFECKDIV78_MAN 0xf5c90080
3583
3584/* P1_SFSTATUS */
3585#define RSTV0910_P1_SFSTATUS 0xf5cc
3586#define FSTV0910_P1_SFEC_LINEOK 0xf5cc0080
3587#define FSTV0910_P1_SFEC_ERROR 0xf5cc0040
3588#define FSTV0910_P1_SFEC_DATA7 0xf5cc0020
3589#define FSTV0910_P1_SFEC_PKTDNBRFAIL 0xf5cc0010
3590#define FSTV0910_P1_TSSFEC_DEMODSEL 0xf5cc0008
3591#define FSTV0910_P1_SFEC_NOSYNC 0xf5cc0004
3592#define FSTV0910_P1_SFEC_UNREGULA 0xf5cc0002
3593#define FSTV0910_P1_SFEC_READY 0xf5cc0001
3594
3595/* P1_SFDLYSET2 */
3596#define RSTV0910_P1_SFDLYSET2 0xf5d0
3597#define FSTV0910_P1_SFEC_DISABLE 0xf5d00002
3598
3599/* P1_SFERRCTRL */
3600#define RSTV0910_P1_SFERRCTRL 0xf5d8
3601#define FSTV0910_P1_SFEC_ERR_SOURCE 0xf5d800f0
3602#define FSTV0910_P1_SFEC_NUM_EVENT 0xf5d80007
3603
3604/* P1_SFERRCNT2 */
3605#define RSTV0910_P1_SFERRCNT2 0xf5d9
3606#define FSTV0910_P1_SFERRC_OLDVALUE 0xf5d90080
3607#define FSTV0910_P1_SFEC_ERR_CNT2 0xf5d9007f
3608
3609/* P1_SFERRCNT1 */
3610#define RSTV0910_P1_SFERRCNT1 0xf5da
3611#define FSTV0910_P1_SFEC_ERR_CNT1 0xf5da00ff
3612
3613/* P1_SFERRCNT0 */
3614#define RSTV0910_P1_SFERRCNT0 0xf5db
3615#define FSTV0910_P1_SFEC_ERR_CNT0 0xf5db00ff
3616
3617/* RCCFG2 */
3618#define RSTV0910_RCCFG2 0xf600
3619#define FSTV0910_TSRCFIFO_DVBCI 0xf6000080
3620#define FSTV0910_TSRCFIFO_SERIAL 0xf6000040
3621#define FSTV0910_TSRCFIFO_DISABLE 0xf6000020
3622#define FSTV0910_TSFIFO_2TORC 0xf6000010
3623#define FSTV0910_TSRCFIFO_HSGNLOUT 0xf6000008
3624#define FSTV0910_TSRCFIFO_ERRMODE 0xf6000006
3625
3626/* RCCFG1 */
3627#define RSTV0910_RCCFG1 0xf601
3628#define FSTV0910_TSRCFIFO_MANSPEED 0xf60100c0
3629#define FSTV0910_TSRCFIFO_PERMDATA 0xf6010020
3630#define FSTV0910_TSRCFIFO_NONEWSGNL 0xf6010010
3631#define FSTV0910_TSRCFIFO_INVDATA 0xf6010001
3632
3633/* RCCFG0 */
3634#define RSTV0910_RCCFG0 0xf602
3635#define FSTV0910_TSRCFIFO_BCLKDEL1CK 0xf60200c0
3636#define FSTV0910_TSRCFIFO_DUTY50 0xf6020010
3637#define FSTV0910_TSRCFIFO_NSGNL2DATA 0xf6020008
3638#define FSTV0910_TSRCFIFO_NPDSGNL 0xf6020004
3639
3640/* RCINSDEL2 */
3641#define RSTV0910_RCINSDEL2 0xf603
3642#define FSTV0910_TSRCDEL_SYNCBYTE 0xf6030080
3643#define FSTV0910_TSRCDEL_XXHEADER 0xf6030040
3644#define FSTV0910_TSRCDEL_BBHEADER 0xf6030020
3645#define FSTV0910_TSRCDEL_DATAFIELD 0xf6030010
3646#define FSTV0910_TSRCINSDEL_ISCR 0xf6030008
3647#define FSTV0910_TSRCINSDEL_NPD 0xf6030004
3648#define FSTV0910_TSRCINSDEL_RSPARITY 0xf6030002
3649#define FSTV0910_TSRCINSDEL_CRC8 0xf6030001
3650
3651/* RCINSDEL1 */
3652#define RSTV0910_RCINSDEL1 0xf604
3653#define FSTV0910_TSRCINS_BBPADDING 0xf6040080
3654#define FSTV0910_TSRCINS_BCHFEC 0xf6040040
3655#define FSTV0910_TSRCINS_EMODCOD 0xf6040010
3656#define FSTV0910_TSRCINS_TOKEN 0xf6040008
3657#define FSTV0910_TSRCINS_XXXERR 0xf6040004
3658#define FSTV0910_TSRCINS_MATYPE 0xf6040002
3659#define FSTV0910_TSRCINS_UPL 0xf6040001
3660
3661/* RCINSDEL0 */
3662#define RSTV0910_RCINSDEL0 0xf605
3663#define FSTV0910_TSRCINS_DFL 0xf6050080
3664#define FSTV0910_TSRCINS_SYNCD 0xf6050040
3665#define FSTV0910_TSRCINS_BLOCLEN 0xf6050020
3666#define FSTV0910_TSRCINS_SIGPCOUNT 0xf6050010
3667#define FSTV0910_TSRCINS_FIFO 0xf6050008
3668#define FSTV0910_TSRCINS_REALPACK 0xf6050004
3669#define FSTV0910_TSRCINS_TSCONFIG 0xf6050002
3670#define FSTV0910_TSRCINS_LATENCY 0xf6050001
3671
3672/* RCSTATUS */
3673#define RSTV0910_RCSTATUS 0xf606
3674#define FSTV0910_TSRCFIFO_LINEOK 0xf6060080
3675#define FSTV0910_TSRCFIFO_ERROR 0xf6060040
3676#define FSTV0910_TSRCREGUL_ERROR 0xf6060010
3677#define FSTV0910_TSRCFIFO_DEMODSEL 0xf6060008
3678#define FSTV0910_TSRCFIFOSPEED_STORE 0xf6060004
3679#define FSTV0910_TSRCSPEED_IMPOSSIBLE 0xf6060001
3680
3681/* RCSPEED */
3682#define RSTV0910_RCSPEED 0xf607
3683#define FSTV0910_TSRCFIFO_OUTSPEED 0xf60700ff
3684
3685/* TSGENERAL */
3686#define RSTV0910_TSGENERAL 0xf630
3687#define FSTV0910_TSFIFO_DISTS2PAR 0xf6300040
3688#define FSTV0910_MUXSTREAM_OUTMODE 0xf6300008
3689#define FSTV0910_TSFIFO_PERMPARAL 0xf6300006
3690
3691/* P1_DISIRQCFG */
3692#define RSTV0910_P1_DISIRQCFG 0xf700
3693#define FSTV0910_P1_ENRXEND 0xf7000040
3694#define FSTV0910_P1_ENRXFIFO8B 0xf7000020
3695#define FSTV0910_P1_ENTRFINISH 0xf7000010
3696#define FSTV0910_P1_ENTIMEOUT 0xf7000008
3697#define FSTV0910_P1_ENTXEND 0xf7000004
3698#define FSTV0910_P1_ENTXFIFO64B 0xf7000002
3699#define FSTV0910_P1_ENGAPBURST 0xf7000001
3700
3701/* P1_DISIRQSTAT */
3702#define RSTV0910_P1_DISIRQSTAT 0xf701
3703#define FSTV0910_P1_IRQRXEND 0xf7010040
3704#define FSTV0910_P1_IRQRXFIFO8B 0xf7010020
3705#define FSTV0910_P1_IRQTRFINISH 0xf7010010
3706#define FSTV0910_P1_IRQTIMEOUT 0xf7010008
3707#define FSTV0910_P1_IRQTXEND 0xf7010004
3708#define FSTV0910_P1_IRQTXFIFO64B 0xf7010002
3709#define FSTV0910_P1_IRQGAPBURST 0xf7010001
3710
3711/* P1_DISTXCFG */
3712#define RSTV0910_P1_DISTXCFG 0xf702
3713#define FSTV0910_P1_DISTX_RESET 0xf7020080
3714#define FSTV0910_P1_TIM_OFF 0xf7020040
3715#define FSTV0910_P1_TIM_CMD 0xf7020030
3716#define FSTV0910_P1_ENVELOP 0xf7020008
3717#define FSTV0910_P1_DIS_PRECHARGE 0xf7020004
3718#define FSTV0910_P1_DISEQC_MODE 0xf7020003
3719
3720/* P1_DISTXSTATUS */
3721#define RSTV0910_P1_DISTXSTATUS 0xf703
3722#define FSTV0910_P1_TX_FIFO_FULL 0xf7030040
3723#define FSTV0910_P1_TX_IDLE 0xf7030020
3724#define FSTV0910_P1_GAP_BURST 0xf7030010
3725#define FSTV0910_P1_TX_FIFO64B 0xf7030008
3726#define FSTV0910_P1_TX_END 0xf7030004
3727#define FSTV0910_P1_TR_TIMEOUT 0xf7030002
3728#define FSTV0910_P1_TR_FINISH 0xf7030001
3729
3730/* P1_DISTXBYTES */
3731#define RSTV0910_P1_DISTXBYTES 0xf704
3732#define FSTV0910_P1_TXFIFO_BYTES 0xf70400ff
3733
3734/* P1_DISTXFIFO */
3735#define RSTV0910_P1_DISTXFIFO 0xf705
3736#define FSTV0910_P1_DISEQC_TX_FIFO 0xf70500ff
3737
3738/* P1_DISTXF22 */
3739#define RSTV0910_P1_DISTXF22 0xf706
3740#define FSTV0910_P1_F22TX 0xf70600ff
3741
3742/* P1_DISTIMEOCFG */
3743#define RSTV0910_P1_DISTIMEOCFG 0xf708
3744#define FSTV0910_P1_RXCHOICE 0xf7080006
3745#define FSTV0910_P1_TIMEOUT_OFF 0xf7080001
3746
3747/* P1_DISTIMEOUT */
3748#define RSTV0910_P1_DISTIMEOUT 0xf709
3749#define FSTV0910_P1_TIMEOUT_COUNT 0xf70900ff
3750
3751/* P1_DISRXCFG */
3752#define RSTV0910_P1_DISRXCFG 0xf70a
3753#define FSTV0910_P1_DISRX_RESET 0xf70a0080
3754#define FSTV0910_P1_EXTENVELOP 0xf70a0040
3755#define FSTV0910_P1_PINSELECT 0xf70a0038
3756#define FSTV0910_P1_IGNORE_SHORT22K 0xf70a0004
3757#define FSTV0910_P1_SIGNED_RXIN 0xf70a0002
3758#define FSTV0910_P1_DISRX_ON 0xf70a0001
3759
3760/* P1_DISRXSTAT1 */
3761#define RSTV0910_P1_DISRXSTAT1 0xf70b
3762#define FSTV0910_P1_RXEND 0xf70b0080
3763#define FSTV0910_P1_RXACTIVE 0xf70b0040
3764#define FSTV0910_P1_RXDETECT 0xf70b0020
3765#define FSTV0910_P1_CONTTONE 0xf70b0010
3766#define FSTV0910_P1_8BFIFOREADY 0xf70b0008
3767#define FSTV0910_P1_FIFOEMPTY 0xf70b0004
3768
3769/* P1_DISRXSTAT0 */
3770#define RSTV0910_P1_DISRXSTAT0 0xf70c
3771#define FSTV0910_P1_RXFAIL 0xf70c0080
3772#define FSTV0910_P1_FIFOPFAIL 0xf70c0040
3773#define FSTV0910_P1_RXNONBYTE 0xf70c0020
3774#define FSTV0910_P1_FIFOOVF 0xf70c0010
3775#define FSTV0910_P1_SHORT22K 0xf70c0008
3776#define FSTV0910_P1_RXMSGLOST 0xf70c0004
3777
3778/* P1_DISRXBYTES */
3779#define RSTV0910_P1_DISRXBYTES 0xf70d
3780#define FSTV0910_P1_RXFIFO_BYTES 0xf70d001f
3781
3782/* P1_DISRXPARITY1 */
3783#define RSTV0910_P1_DISRXPARITY1 0xf70e
3784#define FSTV0910_P1_DISRX_PARITY1 0xf70e00ff
3785
3786/* P1_DISRXPARITY0 */
3787#define RSTV0910_P1_DISRXPARITY0 0xf70f
3788#define FSTV0910_P1_DISRX_PARITY0 0xf70f00ff
3789
3790/* P1_DISRXFIFO */
3791#define RSTV0910_P1_DISRXFIFO 0xf710
3792#define FSTV0910_P1_DISEQC_RX_FIFO 0xf71000ff
3793
3794/* P1_DISRXDC1 */
3795#define RSTV0910_P1_DISRXDC1 0xf711
3796#define FSTV0910_P1_DC_VALUE1 0xf7110103
3797
3798/* P1_DISRXDC0 */
3799#define RSTV0910_P1_DISRXDC0 0xf712
3800#define FSTV0910_P1_DC_VALUE0 0xf71200ff
3801
3802/* P1_DISRXF221 */
3803#define RSTV0910_P1_DISRXF221 0xf714
3804#define FSTV0910_P1_F22RX1 0xf714000f
3805
3806/* P1_DISRXF220 */
3807#define RSTV0910_P1_DISRXF220 0xf715
3808#define FSTV0910_P1_F22RX0 0xf71500ff
3809
3810/* P1_DISRXF100 */
3811#define RSTV0910_P1_DISRXF100 0xf716
3812#define FSTV0910_P1_F100RX 0xf71600ff
3813
3814/* P1_DISRXSHORT22K */
3815#define RSTV0910_P1_DISRXSHORT22K 0xf71c
3816#define FSTV0910_P1_SHORT22K_LENGTH 0xf71c001f
3817
3818/* P1_ACRPRESC */
3819#define RSTV0910_P1_ACRPRESC 0xf71e
3820#define FSTV0910_P1_ACR_PRESC 0xf71e0007
3821
3822/* P1_ACRDIV */
3823#define RSTV0910_P1_ACRDIV 0xf71f
3824#define FSTV0910_P1_ACR_DIV 0xf71f00ff
3825
3826/* P2_DISIRQCFG */
3827#define RSTV0910_P2_DISIRQCFG 0xf740
3828#define FSTV0910_P2_ENRXEND 0xf7400040
3829#define FSTV0910_P2_ENRXFIFO8B 0xf7400020
3830#define FSTV0910_P2_ENTRFINISH 0xf7400010
3831#define FSTV0910_P2_ENTIMEOUT 0xf7400008
3832#define FSTV0910_P2_ENTXEND 0xf7400004
3833#define FSTV0910_P2_ENTXFIFO64B 0xf7400002
3834#define FSTV0910_P2_ENGAPBURST 0xf7400001
3835
3836/* P2_DISIRQSTAT */
3837#define RSTV0910_P2_DISIRQSTAT 0xf741
3838#define FSTV0910_P2_IRQRXEND 0xf7410040
3839#define FSTV0910_P2_IRQRXFIFO8B 0xf7410020
3840#define FSTV0910_P2_IRQTRFINISH 0xf7410010
3841#define FSTV0910_P2_IRQTIMEOUT 0xf7410008
3842#define FSTV0910_P2_IRQTXEND 0xf7410004
3843#define FSTV0910_P2_IRQTXFIFO64B 0xf7410002
3844#define FSTV0910_P2_IRQGAPBURST 0xf7410001
3845
3846/* P2_DISTXCFG */
3847#define RSTV0910_P2_DISTXCFG 0xf742
3848#define FSTV0910_P2_DISTX_RESET 0xf7420080
3849#define FSTV0910_P2_TIM_OFF 0xf7420040
3850#define FSTV0910_P2_TIM_CMD 0xf7420030
3851#define FSTV0910_P2_ENVELOP 0xf7420008
3852#define FSTV0910_P2_DIS_PRECHARGE 0xf7420004
3853#define FSTV0910_P2_DISEQC_MODE 0xf7420003
3854
3855/* P2_DISTXSTATUS */
3856#define RSTV0910_P2_DISTXSTATUS 0xf743
3857#define FSTV0910_P2_TX_FIFO_FULL 0xf7430040
3858#define FSTV0910_P2_TX_IDLE 0xf7430020
3859#define FSTV0910_P2_GAP_BURST 0xf7430010
3860#define FSTV0910_P2_TX_FIFO64B 0xf7430008
3861#define FSTV0910_P2_TX_END 0xf7430004
3862#define FSTV0910_P2_TR_TIMEOUT 0xf7430002
3863#define FSTV0910_P2_TR_FINISH 0xf7430001
3864
3865/* P2_DISTXBYTES */
3866#define RSTV0910_P2_DISTXBYTES 0xf744
3867#define FSTV0910_P2_TXFIFO_BYTES 0xf74400ff
3868
3869/* P2_DISTXFIFO */
3870#define RSTV0910_P2_DISTXFIFO 0xf745
3871#define FSTV0910_P2_DISEQC_TX_FIFO 0xf74500ff
3872
3873/* P2_DISTXF22 */
3874#define RSTV0910_P2_DISTXF22 0xf746
3875#define FSTV0910_P2_F22TX 0xf74600ff
3876
3877/* P2_DISTIMEOCFG */
3878#define RSTV0910_P2_DISTIMEOCFG 0xf748
3879#define FSTV0910_P2_RXCHOICE 0xf7480006
3880#define FSTV0910_P2_TIMEOUT_OFF 0xf7480001
3881
3882/* P2_DISTIMEOUT */
3883#define RSTV0910_P2_DISTIMEOUT 0xf749
3884#define FSTV0910_P2_TIMEOUT_COUNT 0xf74900ff
3885
3886/* P2_DISRXCFG */
3887#define RSTV0910_P2_DISRXCFG 0xf74a
3888#define FSTV0910_P2_DISRX_RESET 0xf74a0080
3889#define FSTV0910_P2_EXTENVELOP 0xf74a0040
3890#define FSTV0910_P2_PINSELECT 0xf74a0038
3891#define FSTV0910_P2_IGNORE_SHORT22K 0xf74a0004
3892#define FSTV0910_P2_SIGNED_RXIN 0xf74a0002
3893#define FSTV0910_P2_DISRX_ON 0xf74a0001
3894
3895/* P2_DISRXSTAT1 */
3896#define RSTV0910_P2_DISRXSTAT1 0xf74b
3897#define FSTV0910_P2_RXEND 0xf74b0080
3898#define FSTV0910_P2_RXACTIVE 0xf74b0040
3899#define FSTV0910_P2_RXDETECT 0xf74b0020
3900#define FSTV0910_P2_CONTTONE 0xf74b0010
3901#define FSTV0910_P2_8BFIFOREADY 0xf74b0008
3902#define FSTV0910_P2_FIFOEMPTY 0xf74b0004
3903
3904/* P2_DISRXSTAT0 */
3905#define RSTV0910_P2_DISRXSTAT0 0xf74c
3906#define FSTV0910_P2_RXFAIL 0xf74c0080
3907#define FSTV0910_P2_FIFOPFAIL 0xf74c0040
3908#define FSTV0910_P2_RXNONBYTE 0xf74c0020
3909#define FSTV0910_P2_FIFOOVF 0xf74c0010
3910#define FSTV0910_P2_SHORT22K 0xf74c0008
3911#define FSTV0910_P2_RXMSGLOST 0xf74c0004
3912
3913/* P2_DISRXBYTES */
3914#define RSTV0910_P2_DISRXBYTES 0xf74d
3915#define FSTV0910_P2_RXFIFO_BYTES 0xf74d001f
3916
3917/* P2_DISRXPARITY1 */
3918#define RSTV0910_P2_DISRXPARITY1 0xf74e
3919#define FSTV0910_P2_DISRX_PARITY1 0xf74e00ff
3920
3921/* P2_DISRXPARITY0 */
3922#define RSTV0910_P2_DISRXPARITY0 0xf74f
3923#define FSTV0910_P2_DISRX_PARITY0 0xf74f00ff
3924
3925/* P2_DISRXFIFO */
3926#define RSTV0910_P2_DISRXFIFO 0xf750
3927#define FSTV0910_P2_DISEQC_RX_FIFO 0xf75000ff
3928
3929/* P2_DISRXDC1 */
3930#define RSTV0910_P2_DISRXDC1 0xf751
3931#define FSTV0910_P2_DC_VALUE1 0xf7510103
3932
3933/* P2_DISRXDC0 */
3934#define RSTV0910_P2_DISRXDC0 0xf752
3935#define FSTV0910_P2_DC_VALUE0 0xf75200ff
3936
3937/* P2_DISRXF221 */
3938#define RSTV0910_P2_DISRXF221 0xf754
3939#define FSTV0910_P2_F22RX1 0xf754000f
3940
3941/* P2_DISRXF220 */
3942#define RSTV0910_P2_DISRXF220 0xf755
3943#define FSTV0910_P2_F22RX0 0xf75500ff
3944
3945/* P2_DISRXF100 */
3946#define RSTV0910_P2_DISRXF100 0xf756
3947#define FSTV0910_P2_F100RX 0xf75600ff
3948
3949/* P2_DISRXSHORT22K */
3950#define RSTV0910_P2_DISRXSHORT22K 0xf75c
3951#define FSTV0910_P2_SHORT22K_LENGTH 0xf75c001f
3952
3953/* P2_ACRPRESC */
3954#define RSTV0910_P2_ACRPRESC 0xf75e
3955#define FSTV0910_P2_ACR_PRESC 0xf75e0007
3956
3957/* P2_ACRDIV */
3958#define RSTV0910_P2_ACRDIV 0xf75f
3959#define FSTV0910_P2_ACR_DIV 0xf75f00ff
3960
3961/* P1_NBITER_NF1 */
3962#define RSTV0910_P1_NBITER_NF1 0xfa00
3963#define FSTV0910_P1_NBITER_NF_QPSK_1_4 0xfa0000ff
3964
3965/* P1_NBITER_NF2 */
3966#define RSTV0910_P1_NBITER_NF2 0xfa01
3967#define FSTV0910_P1_NBITER_NF_QPSK_1_3 0xfa0100ff
3968
3969/* P1_NBITER_NF3 */
3970#define RSTV0910_P1_NBITER_NF3 0xfa02
3971#define FSTV0910_P1_NBITER_NF_QPSK_2_5 0xfa0200ff
3972
3973/* P1_NBITER_NF4 */
3974#define RSTV0910_P1_NBITER_NF4 0xfa03
3975#define FSTV0910_P1_NBITER_NF_QPSK_1_2 0xfa0300ff
3976
3977/* P1_NBITER_NF5 */
3978#define RSTV0910_P1_NBITER_NF5 0xfa04
3979#define FSTV0910_P1_NBITER_NF_QPSK_3_5 0xfa0400ff
3980
3981/* P1_NBITER_NF6 */
3982#define RSTV0910_P1_NBITER_NF6 0xfa05
3983#define FSTV0910_P1_NBITER_NF_QPSK_2_3 0xfa0500ff
3984
3985/* P1_NBITER_NF7 */
3986#define RSTV0910_P1_NBITER_NF7 0xfa06
3987#define FSTV0910_P1_NBITER_NF_QPSK_3_4 0xfa0600ff
3988
3989/* P1_NBITER_NF8 */
3990#define RSTV0910_P1_NBITER_NF8 0xfa07
3991#define FSTV0910_P1_NBITER_NF_QPSK_4_5 0xfa0700ff
3992
3993/* P1_NBITER_NF9 */
3994#define RSTV0910_P1_NBITER_NF9 0xfa08
3995#define FSTV0910_P1_NBITER_NF_QPSK_5_6 0xfa0800ff
3996
3997/* P1_NBITER_NF10 */
3998#define RSTV0910_P1_NBITER_NF10 0xfa09
3999#define FSTV0910_P1_NBITER_NF_QPSK_8_9 0xfa0900ff
4000
4001/* P1_NBITER_NF11 */
4002#define RSTV0910_P1_NBITER_NF11 0xfa0a
4003#define FSTV0910_P1_NBITER_NF_QPSK_9_10 0xfa0a00ff
4004
4005/* P1_NBITER_NF12 */
4006#define RSTV0910_P1_NBITER_NF12 0xfa0b
4007#define FSTV0910_P1_NBITER_NF_8PSK_3_5 0xfa0b00ff
4008
4009/* P1_NBITER_NF13 */
4010#define RSTV0910_P1_NBITER_NF13 0xfa0c
4011#define FSTV0910_P1_NBITER_NF_8PSK_2_3 0xfa0c00ff
4012
4013/* P1_NBITER_NF14 */
4014#define RSTV0910_P1_NBITER_NF14 0xfa0d
4015#define FSTV0910_P1_NBITER_NF_8PSK_3_4 0xfa0d00ff
4016
4017/* P1_NBITER_NF15 */
4018#define RSTV0910_P1_NBITER_NF15 0xfa0e
4019#define FSTV0910_P1_NBITER_NF_8PSK_5_6 0xfa0e00ff
4020
4021/* P1_NBITER_NF16 */
4022#define RSTV0910_P1_NBITER_NF16 0xfa0f
4023#define FSTV0910_P1_NBITER_NF_8PSK_8_9 0xfa0f00ff
4024
4025/* P1_NBITER_NF17 */
4026#define RSTV0910_P1_NBITER_NF17 0xfa10
4027#define FSTV0910_P1_NBITER_NF_8PSK_9_10 0xfa1000ff
4028
4029/* P1_NBITER_NF18 */
4030#define RSTV0910_P1_NBITER_NF18 0xfa11
4031#define FSTV0910_P1_NBITER_NF_16APSK_2_3 0xfa1100ff
4032
4033/* P1_NBITER_NF19 */
4034#define RSTV0910_P1_NBITER_NF19 0xfa12
4035#define FSTV0910_P1_NBITER_NF_16APSK_3_4 0xfa1200ff
4036
4037/* P1_NBITER_NF20 */
4038#define RSTV0910_P1_NBITER_NF20 0xfa13
4039#define FSTV0910_P1_NBITER_NF_16APSK_4_5 0xfa1300ff
4040
4041/* P1_NBITER_NF21 */
4042#define RSTV0910_P1_NBITER_NF21 0xfa14
4043#define FSTV0910_P1_NBITER_NF_16APSK_5_6 0xfa1400ff
4044
4045/* P1_NBITER_NF22 */
4046#define RSTV0910_P1_NBITER_NF22 0xfa15
4047#define FSTV0910_P1_NBITER_NF_16APSK_8_9 0xfa1500ff
4048
4049/* P1_NBITER_NF23 */
4050#define RSTV0910_P1_NBITER_NF23 0xfa16
4051#define FSTV0910_P1_NBITER_NF_16APSK_9_10 0xfa1600ff
4052
4053/* P1_NBITER_NF24 */
4054#define RSTV0910_P1_NBITER_NF24 0xfa17
4055#define FSTV0910_P1_NBITER_NF_32APSK_3_4 0xfa1700ff
4056
4057/* P1_NBITER_NF25 */
4058#define RSTV0910_P1_NBITER_NF25 0xfa18
4059#define FSTV0910_P1_NBITER_NF_32APSK_4_5 0xfa1800ff
4060
4061/* P1_NBITER_NF26 */
4062#define RSTV0910_P1_NBITER_NF26 0xfa19
4063#define FSTV0910_P1_NBITER_NF_32APSK_5_6 0xfa1900ff
4064
4065/* P1_NBITER_NF27 */
4066#define RSTV0910_P1_NBITER_NF27 0xfa1a
4067#define FSTV0910_P1_NBITER_NF_32APSK_8_9 0xfa1a00ff
4068
4069/* P1_NBITER_NF28 */
4070#define RSTV0910_P1_NBITER_NF28 0xfa1b
4071#define FSTV0910_P1_NBITER_NF_32APSK_9_10 0xfa1b00ff
4072
4073/* P1_NBITER_SF1 */
4074#define RSTV0910_P1_NBITER_SF1 0xfa1c
4075#define FSTV0910_P1_NBITER_SF_QPSK_1_4 0xfa1c00ff
4076
4077/* P1_NBITER_SF2 */
4078#define RSTV0910_P1_NBITER_SF2 0xfa1d
4079#define FSTV0910_P1_NBITER_SF_QPSK_1_3 0xfa1d00ff
4080
4081/* P1_NBITER_SF3 */
4082#define RSTV0910_P1_NBITER_SF3 0xfa1e
4083#define FSTV0910_P1_NBITER_SF_QPSK_2_5 0xfa1e00ff
4084
4085/* P1_NBITER_SF4 */
4086#define RSTV0910_P1_NBITER_SF4 0xfa1f
4087#define FSTV0910_P1_NBITER_SF_QPSK_1_2 0xfa1f00ff
4088
4089/* P1_NBITER_SF5 */
4090#define RSTV0910_P1_NBITER_SF5 0xfa20
4091#define FSTV0910_P1_NBITER_SF_QPSK_3_5 0xfa2000ff
4092
4093/* P1_NBITER_SF6 */
4094#define RSTV0910_P1_NBITER_SF6 0xfa21
4095#define FSTV0910_P1_NBITER_SF_QPSK_2_3 0xfa2100ff
4096
4097/* P1_NBITER_SF7 */
4098#define RSTV0910_P1_NBITER_SF7 0xfa22
4099#define FSTV0910_P1_NBITER_SF_QPSK_3_4 0xfa2200ff
4100
4101/* P1_NBITER_SF8 */
4102#define RSTV0910_P1_NBITER_SF8 0xfa23
4103#define FSTV0910_P1_NBITER_SF_QPSK_4_5 0xfa2300ff
4104
4105/* P1_NBITER_SF9 */
4106#define RSTV0910_P1_NBITER_SF9 0xfa24
4107#define FSTV0910_P1_NBITER_SF_QPSK_5_6 0xfa2400ff
4108
4109/* P1_NBITER_SF10 */
4110#define RSTV0910_P1_NBITER_SF10 0xfa25
4111#define FSTV0910_P1_NBITER_SF_QPSK_8_9 0xfa2500ff
4112
4113/* P1_NBITER_SF12 */
4114#define RSTV0910_P1_NBITER_SF12 0xfa26
4115#define FSTV0910_P1_NBITER_SF_8PSK_3_5 0xfa2600ff
4116
4117/* P1_NBITER_SF13 */
4118#define RSTV0910_P1_NBITER_SF13 0xfa27
4119#define FSTV0910_P1_NBITER_SF_8PSK_2_3 0xfa2700ff
4120
4121/* P1_NBITER_SF14 */
4122#define RSTV0910_P1_NBITER_SF14 0xfa28
4123#define FSTV0910_P1_NBITER_SF_8PSK_3_4 0xfa2800ff
4124
4125/* P1_NBITER_SF15 */
4126#define RSTV0910_P1_NBITER_SF15 0xfa29
4127#define FSTV0910_P1_NBITER_SF_8PSK_5_6 0xfa2900ff
4128
4129/* P1_NBITER_SF16 */
4130#define RSTV0910_P1_NBITER_SF16 0xfa2a
4131#define FSTV0910_P1_NBITER_SF_8PSK_8_9 0xfa2a00ff
4132
4133/* P1_NBITER_SF18 */
4134#define RSTV0910_P1_NBITER_SF18 0xfa2b
4135#define FSTV0910_P1_NBITER_SF_16APSK_2_3 0xfa2b00ff
4136
4137/* P1_NBITER_SF19 */
4138#define RSTV0910_P1_NBITER_SF19 0xfa2c
4139#define FSTV0910_P1_NBITER_SF_16APSK_3_4 0xfa2c00ff
4140
4141/* P1_NBITER_SF20 */
4142#define RSTV0910_P1_NBITER_SF20 0xfa2d
4143#define FSTV0910_P1_NBITER_SF_16APSK_4_5 0xfa2d00ff
4144
4145/* P1_NBITER_SF21 */
4146#define RSTV0910_P1_NBITER_SF21 0xfa2e
4147#define FSTV0910_P1_NBITER_SF_16APSK_5_6 0xfa2e00ff
4148
4149/* P1_NBITER_SF22 */
4150#define RSTV0910_P1_NBITER_SF22 0xfa2f
4151#define FSTV0910_P1_NBITER_SF_16APSK_8_9 0xfa2f00ff
4152
4153/* P1_NBITER_SF24 */
4154#define RSTV0910_P1_NBITER_SF24 0xfa30
4155#define FSTV0910_P1_NBITER_SF_32APSK_3_4 0xfa3000ff
4156
4157/* P1_NBITER_SF25 */
4158#define RSTV0910_P1_NBITER_SF25 0xfa31
4159#define FSTV0910_P1_NBITER_SF_32APSK_4_5 0xfa3100ff
4160
4161/* P1_NBITER_SF26 */
4162#define RSTV0910_P1_NBITER_SF26 0xfa32
4163#define FSTV0910_P1_NBITER_SF_32APSK_5_6 0xfa3200ff
4164
4165/* P1_NBITER_SF27 */
4166#define RSTV0910_P1_NBITER_SF27 0xfa33
4167#define FSTV0910_P1_NBITER_SF_32APSK_8_9 0xfa3300ff
4168
4169/* SELSATUR6 */
4170#define RSTV0910_SELSATUR6 0xfa34
4171#define FSTV0910_SSAT_SF27 0xfa340008
4172#define FSTV0910_SSAT_SF26 0xfa340004
4173#define FSTV0910_SSAT_SF25 0xfa340002
4174#define FSTV0910_SSAT_SF24 0xfa340001
4175
4176/* SELSATUR5 */
4177#define RSTV0910_SELSATUR5 0xfa35
4178#define FSTV0910_SSAT_SF22 0xfa350080
4179#define FSTV0910_SSAT_SF21 0xfa350040
4180#define FSTV0910_SSAT_SF20 0xfa350020
4181#define FSTV0910_SSAT_SF19 0xfa350010
4182#define FSTV0910_SSAT_SF18 0xfa350008
4183#define FSTV0910_SSAT_SF16 0xfa350004
4184#define FSTV0910_SSAT_SF15 0xfa350002
4185#define FSTV0910_SSAT_SF14 0xfa350001
4186
4187/* SELSATUR4 */
4188#define RSTV0910_SELSATUR4 0xfa36
4189#define FSTV0910_SSAT_SF13 0xfa360080
4190#define FSTV0910_SSAT_SF12 0xfa360040
4191#define FSTV0910_SSAT_SF10 0xfa360020
4192#define FSTV0910_SSAT_SF9 0xfa360010
4193#define FSTV0910_SSAT_SF8 0xfa360008
4194#define FSTV0910_SSAT_SF7 0xfa360004
4195#define FSTV0910_SSAT_SF6 0xfa360002
4196#define FSTV0910_SSAT_SF5 0xfa360001
4197
4198/* SELSATUR3 */
4199#define RSTV0910_SELSATUR3 0xfa37
4200#define FSTV0910_SSAT_SF4 0xfa370080
4201#define FSTV0910_SSAT_SF3 0xfa370040
4202#define FSTV0910_SSAT_SF2 0xfa370020
4203#define FSTV0910_SSAT_SF1 0xfa370010
4204#define FSTV0910_SSAT_NF28 0xfa370008
4205#define FSTV0910_SSAT_NF27 0xfa370004
4206#define FSTV0910_SSAT_NF26 0xfa370002
4207#define FSTV0910_SSAT_NF25 0xfa370001
4208
4209/* SELSATUR2 */
4210#define RSTV0910_SELSATUR2 0xfa38
4211#define FSTV0910_SSAT_NF24 0xfa380080
4212#define FSTV0910_SSAT_NF23 0xfa380040
4213#define FSTV0910_SSAT_NF22 0xfa380020
4214#define FSTV0910_SSAT_NF21 0xfa380010
4215#define FSTV0910_SSAT_NF20 0xfa380008
4216#define FSTV0910_SSAT_NF19 0xfa380004
4217#define FSTV0910_SSAT_NF18 0xfa380002
4218#define FSTV0910_SSAT_NF17 0xfa380001
4219
4220/* SELSATUR1 */
4221#define RSTV0910_SELSATUR1 0xfa39
4222#define FSTV0910_SSAT_NF16 0xfa390080
4223#define FSTV0910_SSAT_NF15 0xfa390040
4224#define FSTV0910_SSAT_NF14 0xfa390020
4225#define FSTV0910_SSAT_NF13 0xfa390010
4226#define FSTV0910_SSAT_NF12 0xfa390008
4227#define FSTV0910_SSAT_NF11 0xfa390004
4228#define FSTV0910_SSAT_NF10 0xfa390002
4229#define FSTV0910_SSAT_NF9 0xfa390001
4230
4231/* SELSATUR0 */
4232#define RSTV0910_SELSATUR0 0xfa3a
4233#define FSTV0910_SSAT_NF8 0xfa3a0080
4234#define FSTV0910_SSAT_NF7 0xfa3a0040
4235#define FSTV0910_SSAT_NF6 0xfa3a0020
4236#define FSTV0910_SSAT_NF5 0xfa3a0010
4237#define FSTV0910_SSAT_NF4 0xfa3a0008
4238#define FSTV0910_SSAT_NF3 0xfa3a0004
4239#define FSTV0910_SSAT_NF2 0xfa3a0002
4240#define FSTV0910_SSAT_NF1 0xfa3a0001
4241
4242/* GAINLLR_NF1 */
4243#define RSTV0910_GAINLLR_NF1 0xfa40
4244#define FSTV0910_GAINLLR_NF_QPSK_1_4 0xfa40007f
4245
4246/* GAINLLR_NF2 */
4247#define RSTV0910_GAINLLR_NF2 0xfa41
4248#define FSTV0910_GAINLLR_NF_QPSK_1_3 0xfa41007f
4249
4250/* GAINLLR_NF3 */
4251#define RSTV0910_GAINLLR_NF3 0xfa42
4252#define FSTV0910_GAINLLR_NF_QPSK_2_5 0xfa42007f
4253
4254/* GAINLLR_NF4 */
4255#define RSTV0910_GAINLLR_NF4 0xfa43
4256#define FSTV0910_GAINLLR_NF_QPSK_1_2 0xfa43007f
4257
4258/* GAINLLR_NF5 */
4259#define RSTV0910_GAINLLR_NF5 0xfa44
4260#define FSTV0910_GAINLLR_NF_QPSK_3_5 0xfa44007f
4261
4262/* GAINLLR_NF6 */
4263#define RSTV0910_GAINLLR_NF6 0xfa45
4264#define FSTV0910_GAINLLR_NF_QPSK_2_3 0xfa45007f
4265
4266/* GAINLLR_NF7 */
4267#define RSTV0910_GAINLLR_NF7 0xfa46
4268#define FSTV0910_GAINLLR_NF_QPSK_3_4 0xfa46007f
4269
4270/* GAINLLR_NF8 */
4271#define RSTV0910_GAINLLR_NF8 0xfa47
4272#define FSTV0910_GAINLLR_NF_QPSK_4_5 0xfa47007f
4273
4274/* GAINLLR_NF9 */
4275#define RSTV0910_GAINLLR_NF9 0xfa48
4276#define FSTV0910_GAINLLR_NF_QPSK_5_6 0xfa48007f
4277
4278/* GAINLLR_NF10 */
4279#define RSTV0910_GAINLLR_NF10 0xfa49
4280#define FSTV0910_GAINLLR_NF_QPSK_8_9 0xfa49007f
4281
4282/* GAINLLR_NF11 */
4283#define RSTV0910_GAINLLR_NF11 0xfa4a
4284#define FSTV0910_GAINLLR_NF_QPSK_9_10 0xfa4a007f
4285
4286/* GAINLLR_NF12 */
4287#define RSTV0910_GAINLLR_NF12 0xfa4b
4288#define FSTV0910_GAINLLR_NF_8PSK_3_5 0xfa4b007f
4289
4290/* GAINLLR_NF13 */
4291#define RSTV0910_GAINLLR_NF13 0xfa4c
4292#define FSTV0910_GAINLLR_NF_8PSK_2_3 0xfa4c007f
4293
4294/* GAINLLR_NF14 */
4295#define RSTV0910_GAINLLR_NF14 0xfa4d
4296#define FSTV0910_GAINLLR_NF_8PSK_3_4 0xfa4d007f
4297
4298/* GAINLLR_NF15 */
4299#define RSTV0910_GAINLLR_NF15 0xfa4e
4300#define FSTV0910_GAINLLR_NF_8PSK_5_6 0xfa4e007f
4301
4302/* GAINLLR_NF16 */
4303#define RSTV0910_GAINLLR_NF16 0xfa4f
4304#define FSTV0910_GAINLLR_NF_8PSK_8_9 0xfa4f007f
4305
4306/* GAINLLR_NF17 */
4307#define RSTV0910_GAINLLR_NF17 0xfa50
4308#define FSTV0910_GAINLLR_NF_8PSK_9_10 0xfa50007f
4309
4310/* GAINLLR_NF18 */
4311#define RSTV0910_GAINLLR_NF18 0xfa51
4312#define FSTV0910_GAINLLR_NF_16APSK_2_3 0xfa51007f
4313
4314/* GAINLLR_NF19 */
4315#define RSTV0910_GAINLLR_NF19 0xfa52
4316#define FSTV0910_GAINLLR_NF_16APSK_3_4 0xfa52007f
4317
4318/* GAINLLR_NF20 */
4319#define RSTV0910_GAINLLR_NF20 0xfa53
4320#define FSTV0910_GAINLLR_NF_16APSK_4_5 0xfa53007f
4321
4322/* GAINLLR_NF21 */
4323#define RSTV0910_GAINLLR_NF21 0xfa54
4324#define FSTV0910_GAINLLR_NF_16APSK_5_6 0xfa54007f
4325
4326/* GAINLLR_NF22 */
4327#define RSTV0910_GAINLLR_NF22 0xfa55
4328#define FSTV0910_GAINLLR_NF_16APSK_8_9 0xfa55007f
4329
4330/* GAINLLR_NF23 */
4331#define RSTV0910_GAINLLR_NF23 0xfa56
4332#define FSTV0910_GAINLLR_NF_16APSK_9_10 0xfa56007f
4333
4334/* GAINLLR_NF24 */
4335#define RSTV0910_GAINLLR_NF24 0xfa57
4336#define FSTV0910_GAINLLR_NF_32APSK_3_4 0xfa57007f
4337
4338/* GAINLLR_NF25 */
4339#define RSTV0910_GAINLLR_NF25 0xfa58
4340#define FSTV0910_GAINLLR_NF_32APSK_4_5 0xfa58007f
4341
4342/* GAINLLR_NF26 */
4343#define RSTV0910_GAINLLR_NF26 0xfa59
4344#define FSTV0910_GAINLLR_NF_32APSK_5_6 0xfa59007f
4345
4346/* GAINLLR_NF27 */
4347#define RSTV0910_GAINLLR_NF27 0xfa5a
4348#define FSTV0910_GAINLLR_NF_32APSK_8_9 0xfa5a007f
4349
4350/* GAINLLR_NF28 */
4351#define RSTV0910_GAINLLR_NF28 0xfa5b
4352#define FSTV0910_GAINLLR_NF_32APSK_9_10 0xfa5b007f
4353
4354/* GAINLLR_SF1 */
4355#define RSTV0910_GAINLLR_SF1 0xfa5c
4356#define FSTV0910_GAINLLR_SF_QPSK_1_4 0xfa5c007f
4357
4358/* GAINLLR_SF2 */
4359#define RSTV0910_GAINLLR_SF2 0xfa5d
4360#define FSTV0910_GAINLLR_SF_QPSK_1_3 0xfa5d007f
4361
4362/* GAINLLR_SF3 */
4363#define RSTV0910_GAINLLR_SF3 0xfa5e
4364#define FSTV0910_GAINLLR_SF_QPSK_2_5 0xfa5e007f
4365
4366/* GAINLLR_SF4 */
4367#define RSTV0910_GAINLLR_SF4 0xfa5f
4368#define FSTV0910_GAINLLR_SF_QPSK_1_2 0xfa5f007f
4369
4370/* GAINLLR_SF5 */
4371#define RSTV0910_GAINLLR_SF5 0xfa60
4372#define FSTV0910_GAINLLR_SF_QPSK_3_5 0xfa60007f
4373
4374/* GAINLLR_SF6 */
4375#define RSTV0910_GAINLLR_SF6 0xfa61
4376#define FSTV0910_GAINLLR_SF_QPSK_2_3 0xfa61007f
4377
4378/* GAINLLR_SF7 */
4379#define RSTV0910_GAINLLR_SF7 0xfa62
4380#define FSTV0910_GAINLLR_SF_QPSK_3_4 0xfa62007f
4381
4382/* GAINLLR_SF8 */
4383#define RSTV0910_GAINLLR_SF8 0xfa63
4384#define FSTV0910_GAINLLR_SF_QPSK_4_5 0xfa63007f
4385
4386/* GAINLLR_SF9 */
4387#define RSTV0910_GAINLLR_SF9 0xfa64
4388#define FSTV0910_GAINLLR_SF_QPSK_5_6 0xfa64007f
4389
4390/* GAINLLR_SF10 */
4391#define RSTV0910_GAINLLR_SF10 0xfa65
4392#define FSTV0910_GAINLLR_SF_QPSK_8_9 0xfa65007f
4393
4394/* GAINLLR_SF12 */
4395#define RSTV0910_GAINLLR_SF12 0xfa66
4396#define FSTV0910_GAINLLR_SF_8PSK_3_5 0xfa66007f
4397
4398/* GAINLLR_SF13 */
4399#define RSTV0910_GAINLLR_SF13 0xfa67
4400#define FSTV0910_GAINLLR_SF_8PSK_2_3 0xfa67007f
4401
4402/* GAINLLR_SF14 */
4403#define RSTV0910_GAINLLR_SF14 0xfa68
4404#define FSTV0910_GAINLLR_SF_8PSK_3_4 0xfa68007f
4405
4406/* GAINLLR_SF15 */
4407#define RSTV0910_GAINLLR_SF15 0xfa69
4408#define FSTV0910_GAINLLR_SF_8PSK_5_6 0xfa69007f
4409
4410/* GAINLLR_SF16 */
4411#define RSTV0910_GAINLLR_SF16 0xfa6a
4412#define FSTV0910_GAINLLR_SF_8PSK_8_9 0xfa6a007f
4413
4414/* GAINLLR_SF18 */
4415#define RSTV0910_GAINLLR_SF18 0xfa6b
4416#define FSTV0910_GAINLLR_SF_16APSK_2_3 0xfa6b007f
4417
4418/* GAINLLR_SF19 */
4419#define RSTV0910_GAINLLR_SF19 0xfa6c
4420#define FSTV0910_GAINLLR_SF_16APSK_3_4 0xfa6c007f
4421
4422/* GAINLLR_SF20 */
4423#define RSTV0910_GAINLLR_SF20 0xfa6d
4424#define FSTV0910_GAINLLR_SF_16APSK_4_5 0xfa6d007f
4425
4426/* GAINLLR_SF21 */
4427#define RSTV0910_GAINLLR_SF21 0xfa6e
4428#define FSTV0910_GAINLLR_SF_16APSK_5_6 0xfa6e007f
4429
4430/* GAINLLR_SF22 */
4431#define RSTV0910_GAINLLR_SF22 0xfa6f
4432#define FSTV0910_GAINLLR_SF_16APSK_8_9 0xfa6f007f
4433
4434/* GAINLLR_SF24 */
4435#define RSTV0910_GAINLLR_SF24 0xfa70
4436#define FSTV0910_GAINLLR_SF_32APSK_3_4 0xfa70007f
4437
4438/* GAINLLR_SF25 */
4439#define RSTV0910_GAINLLR_SF25 0xfa71
4440#define FSTV0910_GAINLLR_SF_32APSK_4_5 0xfa71007f
4441
4442/* GAINLLR_SF26 */
4443#define RSTV0910_GAINLLR_SF26 0xfa72
4444#define FSTV0910_GAINLLR_SF_32APSK_5_6 0xfa72007f
4445
4446/* GAINLLR_SF27 */
4447#define RSTV0910_GAINLLR_SF27 0xfa73
4448#define FSTV0910_GAINLLR_SF_32APSK_8_9 0xfa73007f
4449
4450/* CFGEXT */
4451#define RSTV0910_CFGEXT 0xfa80
4452#define FSTV0910_BYPBCH 0xfa800040
4453#define FSTV0910_BYPLDPC 0xfa800020
4454#define FSTV0910_SHORTMULT 0xfa800004
4455
4456/* GENCFG */
4457#define RSTV0910_GENCFG 0xfa86
4458#define FSTV0910_BROADCAST 0xfa860010
4459#define FSTV0910_CROSSINPUT 0xfa860002
4460#define FSTV0910_DDEMOD 0xfa860001
4461
4462/* LDPCERR1 */
4463#define RSTV0910_LDPCERR1 0xfa96
4464#define FSTV0910_LDPC_ERRORS1 0xfa9600ff
4465
4466/* LDPCERR0 */
4467#define RSTV0910_LDPCERR0 0xfa97
4468#define FSTV0910_LDPC_ERRORS0 0xfa9700ff
4469
4470/* BCHERR */
4471#define RSTV0910_BCHERR 0xfa98
4472#define FSTV0910_ERRORFLAG 0xfa980010
4473#define FSTV0910_BCH_ERRORS_COUNTER 0xfa98000f
4474
4475/* P1_MAXEXTRAITER */
4476#define RSTV0910_P1_MAXEXTRAITER 0xfab1
4477#define FSTV0910_P1_MAX_EXTRA_ITER 0xfab100ff
4478
4479/* P2_MAXEXTRAITER */
4480#define RSTV0910_P2_MAXEXTRAITER 0xfab6
4481#define FSTV0910_P2_MAX_EXTRA_ITER 0xfab600ff
4482
4483/* P1_STATUSITER */
4484#define RSTV0910_P1_STATUSITER 0xfabc
4485#define FSTV0910_P1_STATUS_ITER 0xfabc00ff
4486
4487/* P1_STATUSMAXITER */
4488#define RSTV0910_P1_STATUSMAXITER 0xfabd
4489#define FSTV0910_P1_STATUS_MAX_ITER 0xfabd00ff
4490
4491/* P2_STATUSITER */
4492#define RSTV0910_P2_STATUSITER 0xfabe
4493#define FSTV0910_P2_STATUS_ITER 0xfabe00ff
4494
4495/* P2_STATUSMAXITER */
4496#define RSTV0910_P2_STATUSMAXITER 0xfabf
4497#define FSTV0910_P2_STATUS_MAX_ITER 0xfabf00ff
4498
4499/* P2_NBITER_NF1 */
4500#define RSTV0910_P2_NBITER_NF1 0xfac0
4501#define FSTV0910_P2_NBITER_NF_QPSK_1_4 0xfac000ff
4502
4503/* P2_NBITER_NF2 */
4504#define RSTV0910_P2_NBITER_NF2 0xfac1
4505#define FSTV0910_P2_NBITER_NF_QPSK_1_3 0xfac100ff
4506
4507/* P2_NBITER_NF3 */
4508#define RSTV0910_P2_NBITER_NF3 0xfac2
4509#define FSTV0910_P2_NBITER_NF_QPSK_2_5 0xfac200ff
4510
4511/* P2_NBITER_NF4 */
4512#define RSTV0910_P2_NBITER_NF4 0xfac3
4513#define FSTV0910_P2_NBITER_NF_QPSK_1_2 0xfac300ff
4514
4515/* P2_NBITER_NF5 */
4516#define RSTV0910_P2_NBITER_NF5 0xfac4
4517#define FSTV0910_P2_NBITER_NF_QPSK_3_5 0xfac400ff
4518
4519/* P2_NBITER_NF6 */
4520#define RSTV0910_P2_NBITER_NF6 0xfac5
4521#define FSTV0910_P2_NBITER_NF_QPSK_2_3 0xfac500ff
4522
4523/* P2_NBITER_NF7 */
4524#define RSTV0910_P2_NBITER_NF7 0xfac6
4525#define FSTV0910_P2_NBITER_NF_QPSK_3_4 0xfac600ff
4526
4527/* P2_NBITER_NF8 */
4528#define RSTV0910_P2_NBITER_NF8 0xfac7
4529#define FSTV0910_P2_NBITER_NF_QPSK_4_5 0xfac700ff
4530
4531/* P2_NBITER_NF9 */
4532#define RSTV0910_P2_NBITER_NF9 0xfac8
4533#define FSTV0910_P2_NBITER_NF_QPSK_5_6 0xfac800ff
4534
4535/* P2_NBITER_NF10 */
4536#define RSTV0910_P2_NBITER_NF10 0xfac9
4537#define FSTV0910_P2_NBITER_NF_QPSK_8_9 0xfac900ff
4538
4539/* P2_NBITER_NF11 */
4540#define RSTV0910_P2_NBITER_NF11 0xfaca
4541#define FSTV0910_P2_NBITER_NF_QPSK_9_10 0xfaca00ff
4542
4543/* P2_NBITER_NF12 */
4544#define RSTV0910_P2_NBITER_NF12 0xfacb
4545#define FSTV0910_P2_NBITER_NF_8PSK_3_5 0xfacb00ff
4546
4547/* P2_NBITER_NF13 */
4548#define RSTV0910_P2_NBITER_NF13 0xfacc
4549#define FSTV0910_P2_NBITER_NF_8PSK_2_3 0xfacc00ff
4550
4551/* P2_NBITER_NF14 */
4552#define RSTV0910_P2_NBITER_NF14 0xfacd
4553#define FSTV0910_P2_NBITER_NF_8PSK_3_4 0xfacd00ff
4554
4555/* P2_NBITER_NF15 */
4556#define RSTV0910_P2_NBITER_NF15 0xface
4557#define FSTV0910_P2_NBITER_NF_8PSK_5_6 0xface00ff
4558
4559/* P2_NBITER_NF16 */
4560#define RSTV0910_P2_NBITER_NF16 0xfacf
4561#define FSTV0910_P2_NBITER_NF_8PSK_8_9 0xfacf00ff
4562
4563/* P2_NBITER_NF17 */
4564#define RSTV0910_P2_NBITER_NF17 0xfad0
4565#define FSTV0910_P2_NBITER_NF_8PSK_9_10 0xfad000ff
4566
4567/* P2_NBITER_NF18 */
4568#define RSTV0910_P2_NBITER_NF18 0xfad1
4569#define FSTV0910_P2_NBITER_NF_16APSK_2_3 0xfad100ff
4570
4571/* P2_NBITER_NF19 */
4572#define RSTV0910_P2_NBITER_NF19 0xfad2
4573#define FSTV0910_P2_NBITER_NF_16APSK_3_4 0xfad200ff
4574
4575/* P2_NBITER_NF20 */
4576#define RSTV0910_P2_NBITER_NF20 0xfad3
4577#define FSTV0910_P2_NBITER_NF_16APSK_4_5 0xfad300ff
4578
4579/* P2_NBITER_NF21 */
4580#define RSTV0910_P2_NBITER_NF21 0xfad4
4581#define FSTV0910_P2_NBITER_NF_16APSK_5_6 0xfad400ff
4582
4583/* P2_NBITER_NF22 */
4584#define RSTV0910_P2_NBITER_NF22 0xfad5
4585#define FSTV0910_P2_NBITER_NF_16APSK_8_9 0xfad500ff
4586
4587/* P2_NBITER_NF23 */
4588#define RSTV0910_P2_NBITER_NF23 0xfad6
4589#define FSTV0910_P2_NBITER_NF_16APSK_9_10 0xfad600ff
4590
4591/* P2_NBITER_NF24 */
4592#define RSTV0910_P2_NBITER_NF24 0xfad7
4593#define FSTV0910_P2_NBITER_NF_32APSK_3_4 0xfad700ff
4594
4595/* P2_NBITER_NF25 */
4596#define RSTV0910_P2_NBITER_NF25 0xfad8
4597#define FSTV0910_P2_NBITER_NF_32APSK_4_5 0xfad800ff
4598
4599/* P2_NBITER_NF26 */
4600#define RSTV0910_P2_NBITER_NF26 0xfad9
4601#define FSTV0910_P2_NBITER_NF_32APSK_5_6 0xfad900ff
4602
4603/* P2_NBITER_NF27 */
4604#define RSTV0910_P2_NBITER_NF27 0xfada
4605#define FSTV0910_P2_NBITER_NF_32APSK_8_9 0xfada00ff
4606
4607/* P2_NBITER_NF28 */
4608#define RSTV0910_P2_NBITER_NF28 0xfadb
4609#define FSTV0910_P2_NBITER_NF_32APSK_9_10 0xfadb00ff
4610
4611/* P2_NBITER_SF1 */
4612#define RSTV0910_P2_NBITER_SF1 0xfadc
4613#define FSTV0910_P2_NBITER_SF_QPSK_1_4 0xfadc00ff
4614
4615/* P2_NBITER_SF2 */
4616#define RSTV0910_P2_NBITER_SF2 0xfadd
4617#define FSTV0910_P2_NBITER_SF_QPSK_1_3 0xfadd00ff
4618
4619/* P2_NBITER_SF3 */
4620#define RSTV0910_P2_NBITER_SF3 0xfade
4621#define FSTV0910_P2_NBITER_SF_QPSK_2_5 0xfade00ff
4622
4623/* P2_NBITER_SF4 */
4624#define RSTV0910_P2_NBITER_SF4 0xfadf
4625#define FSTV0910_P2_NBITER_SF_QPSK_1_2 0xfadf00ff
4626
4627/* P2_NBITER_SF5 */
4628#define RSTV0910_P2_NBITER_SF5 0xfae0
4629#define FSTV0910_P2_NBITER_SF_QPSK_3_5 0xfae000ff
4630
4631/* P2_NBITER_SF6 */
4632#define RSTV0910_P2_NBITER_SF6 0xfae1
4633#define FSTV0910_P2_NBITER_SF_QPSK_2_3 0xfae100ff
4634
4635/* P2_NBITER_SF7 */
4636#define RSTV0910_P2_NBITER_SF7 0xfae2
4637#define FSTV0910_P2_NBITER_SF_QPSK_3_4 0xfae200ff
4638
4639/* P2_NBITER_SF8 */
4640#define RSTV0910_P2_NBITER_SF8 0xfae3
4641#define FSTV0910_P2_NBITER_SF_QPSK_4_5 0xfae300ff
4642
4643/* P2_NBITER_SF9 */
4644#define RSTV0910_P2_NBITER_SF9 0xfae4
4645#define FSTV0910_P2_NBITER_SF_QPSK_5_6 0xfae400ff
4646
4647/* P2_NBITER_SF10 */
4648#define RSTV0910_P2_NBITER_SF10 0xfae5
4649#define FSTV0910_P2_NBITER_SF_QPSK_8_9 0xfae500ff
4650
4651/* P2_NBITER_SF12 */
4652#define RSTV0910_P2_NBITER_SF12 0xfae6
4653#define FSTV0910_P2_NBITER_SF_8PSK_3_5 0xfae600ff
4654
4655/* P2_NBITER_SF13 */
4656#define RSTV0910_P2_NBITER_SF13 0xfae7
4657#define FSTV0910_P2_NBITER_SF_8PSK_2_3 0xfae700ff
4658
4659/* P2_NBITER_SF14 */
4660#define RSTV0910_P2_NBITER_SF14 0xfae8
4661#define FSTV0910_P2_NBITER_SF_8PSK_3_4 0xfae800ff
4662
4663/* P2_NBITER_SF15 */
4664#define RSTV0910_P2_NBITER_SF15 0xfae9
4665#define FSTV0910_P2_NBITER_SF_8PSK_5_6 0xfae900ff
4666
4667/* P2_NBITER_SF16 */
4668#define RSTV0910_P2_NBITER_SF16 0xfaea
4669#define FSTV0910_P2_NBITER_SF_8PSK_8_9 0xfaea00ff
4670
4671/* P2_NBITER_SF18 */
4672#define RSTV0910_P2_NBITER_SF18 0xfaeb
4673#define FSTV0910_P2_NBITER_SF_16APSK_2_3 0xfaeb00ff
4674
4675/* P2_NBITER_SF19 */
4676#define RSTV0910_P2_NBITER_SF19 0xfaec
4677#define FSTV0910_P2_NBITER_SF_16APSK_3_4 0xfaec00ff
4678
4679/* P2_NBITER_SF20 */
4680#define RSTV0910_P2_NBITER_SF20 0xfaed
4681#define FSTV0910_P2_NBITER_SF_16APSK_4_5 0xfaed00ff
4682
4683/* P2_NBITER_SF21 */
4684#define RSTV0910_P2_NBITER_SF21 0xfaee
4685#define FSTV0910_P2_NBITER_SF_16APSK_5_6 0xfaee00ff
4686
4687/* P2_NBITER_SF22 */
4688#define RSTV0910_P2_NBITER_SF22 0xfaef
4689#define FSTV0910_P2_NBITER_SF_16APSK_8_9 0xfaef00ff
4690
4691/* P2_NBITER_SF24 */
4692#define RSTV0910_P2_NBITER_SF24 0xfaf0
4693#define FSTV0910_P2_NBITER_SF_32APSK_3_4 0xfaf000ff
4694
4695/* P2_NBITER_SF25 */
4696#define RSTV0910_P2_NBITER_SF25 0xfaf1
4697#define FSTV0910_P2_NBITER_SF_32APSK_4_5 0xfaf100ff
4698
4699/* P2_NBITER_SF26 */
4700#define RSTV0910_P2_NBITER_SF26 0xfaf2
4701#define FSTV0910_P2_NBITER_SF_32APSK_5_6 0xfaf200ff
4702
4703/* P2_NBITER_SF27 */
4704#define RSTV0910_P2_NBITER_SF27 0xfaf3
4705#define FSTV0910_P2_NBITER_SF_32APSK_8_9 0xfaf300ff
4706
4707/* TSTRES0 */
4708#define RSTV0910_TSTRES0 0xff11
4709#define FSTV0910_FRESFEC 0xff110080
4710#define FSTV0910_FRESSYM1 0xff110008
4711#define FSTV0910_FRESSYM2 0xff110004
4712
4713/* TSTOUT */
4714#define RSTV0910_TSTOUT 0xff12
4715#define FSTV0910_TS 0xff12003e
4716#define FSTV0910_TEST_OUT 0xff120001
4717
4718/* TSTIN */
4719#define RSTV0910_TSTIN 0xff13
4720#define FSTV0910_TEST_IN 0xff130080
4721
4722/* P2_TSTDMD */
4723#define RSTV0910_P2_TSTDMD 0xff20
4724#define FSTV0910_P2_CFRINIT_INVZIGZAG 0xff200008
4725
4726/* P2_TCTL1 */
4727#define RSTV0910_P2_TCTL1 0xff24
4728#define FSTV0910_P2_TST_IQSYMBSEL 0xff24001f
4729
4730/* P2_TCTL4 */
4731#define RSTV0910_P2_TCTL4 0xff28
4732#define FSTV0910_P2_CFR2TOCFR1_DVBS1 0xff2800c0
4733
4734/* P2_TPKTDELIN */
4735#define RSTV0910_P2_TPKTDELIN 0xff37
4736#define FSTV0910_P2_CFG_RSPARITYON 0xff370080
4737
4738/* P1_TSTDMD */
4739#define RSTV0910_P1_TSTDMD 0xff40
4740#define FSTV0910_P1_CFRINIT_INVZIGZAG 0xff400008
4741
4742/* P1_TCTL1 */
4743#define RSTV0910_P1_TCTL1 0xff44
4744#define FSTV0910_P1_TST_IQSYMBSEL 0xff44001f
4745
4746/* P1_TCTL4 */
4747#define RSTV0910_P1_TCTL4 0xff48
4748#define FSTV0910_P1_CFR2TOCFR1_DVBS1 0xff4800c0
4749
4750/* P1_TPKTDELIN */
4751#define RSTV0910_P1_TPKTDELIN 0xff57
4752#define FSTV0910_P1_CFG_RSPARITYON 0xff570080
4753
4754/* TSTTSRS */
4755#define RSTV0910_TSTTSRS 0xff6d
4756#define FSTV0910_TSTRS_DISRS2 0xff6d0002
4757#define FSTV0910_TSTRS_DISRS1 0xff6d0001
4758
4759#define STV0910_NBREGS 975
4760#define STV0910_NBFIELDS 1818
diff --git a/drivers/media/dvb-frontends/stv6111.c b/drivers/media/dvb-frontends/stv6111.c
new file mode 100644
index 000000000000..e3e90070e293
--- /dev/null
+++ b/drivers/media/dvb-frontends/stv6111.c
@@ -0,0 +1,681 @@
1/*
2 * Driver for the ST STV6111 tuner
3 *
4 * Copyright (C) 2014 Digital Devices GmbH
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 only, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/moduleparam.h>
20#include <linux/init.h>
21#include <linux/delay.h>
22#include <linux/firmware.h>
23#include <linux/i2c.h>
24#include <asm/div64.h>
25
26#include "stv6111.h"
27
28#include "dvb_frontend.h"
29
30struct stv {
31 struct i2c_adapter *i2c;
32 u8 adr;
33
34 u8 reg[11];
35 u32 ref_freq;
36 u32 frequency;
37};
38
39struct slookup {
40 s16 value;
41 u16 reg_value;
42};
43
44static const struct slookup lnagain_nf_lookup[] = {
45 /* Gain *100dB // Reg */
46 { 2572, 0 },
47 { 2575, 1 },
48 { 2580, 2 },
49 { 2588, 3 },
50 { 2596, 4 },
51 { 2611, 5 },
52 { 2633, 6 },
53 { 2664, 7 },
54 { 2701, 8 },
55 { 2753, 9 },
56 { 2816, 10 },
57 { 2902, 11 },
58 { 2995, 12 },
59 { 3104, 13 },
60 { 3215, 14 },
61 { 3337, 15 },
62 { 3492, 16 },
63 { 3614, 17 },
64 { 3731, 18 },
65 { 3861, 19 },
66 { 3988, 20 },
67 { 4124, 21 },
68 { 4253, 22 },
69 { 4386, 23 },
70 { 4505, 24 },
71 { 4623, 25 },
72 { 4726, 26 },
73 { 4821, 27 },
74 { 4903, 28 },
75 { 4979, 29 },
76 { 5045, 30 },
77 { 5102, 31 }
78};
79
80static const struct slookup lnagain_iip3_lookup[] = {
81 /* Gain *100dB // reg */
82 { 1548, 0 },
83 { 1552, 1 },
84 { 1569, 2 },
85 { 1565, 3 },
86 { 1577, 4 },
87 { 1594, 5 },
88 { 1627, 6 },
89 { 1656, 7 },
90 { 1700, 8 },
91 { 1748, 9 },
92 { 1805, 10 },
93 { 1896, 11 },
94 { 1995, 12 },
95 { 2113, 13 },
96 { 2233, 14 },
97 { 2366, 15 },
98 { 2543, 16 },
99 { 2687, 17 },
100 { 2842, 18 },
101 { 2999, 19 },
102 { 3167, 20 },
103 { 3342, 21 },
104 { 3507, 22 },
105 { 3679, 23 },
106 { 3827, 24 },
107 { 3970, 25 },
108 { 4094, 26 },
109 { 4210, 27 },
110 { 4308, 28 },
111 { 4396, 29 },
112 { 4468, 30 },
113 { 4535, 31 }
114};
115
116static const struct slookup gain_rfagc_lookup[] = {
117 /* Gain *100dB // reg */
118 { 4870, 0x3000 },
119 { 4850, 0x3C00 },
120 { 4800, 0x4500 },
121 { 4750, 0x4800 },
122 { 4700, 0x4B00 },
123 { 4650, 0x4D00 },
124 { 4600, 0x4F00 },
125 { 4550, 0x5100 },
126 { 4500, 0x5200 },
127 { 4420, 0x5500 },
128 { 4316, 0x5800 },
129 { 4200, 0x5B00 },
130 { 4119, 0x5D00 },
131 { 3999, 0x6000 },
132 { 3950, 0x6100 },
133 { 3876, 0x6300 },
134 { 3755, 0x6600 },
135 { 3641, 0x6900 },
136 { 3567, 0x6B00 },
137 { 3425, 0x6F00 },
138 { 3350, 0x7100 },
139 { 3236, 0x7400 },
140 { 3118, 0x7700 },
141 { 3004, 0x7A00 },
142 { 2917, 0x7C00 },
143 { 2776, 0x7F00 },
144 { 2635, 0x8200 },
145 { 2516, 0x8500 },
146 { 2406, 0x8800 },
147 { 2290, 0x8B00 },
148 { 2170, 0x8E00 },
149 { 2073, 0x9100 },
150 { 1949, 0x9400 },
151 { 1836, 0x9700 },
152 { 1712, 0x9A00 },
153 { 1631, 0x9C00 },
154 { 1515, 0x9F00 },
155 { 1400, 0xA200 },
156 { 1323, 0xA400 },
157 { 1203, 0xA700 },
158 { 1091, 0xAA00 },
159 { 1011, 0xAC00 },
160 { 904, 0xAF00 },
161 { 787, 0xB200 },
162 { 685, 0xB500 },
163 { 571, 0xB800 },
164 { 464, 0xBB00 },
165 { 374, 0xBE00 },
166 { 275, 0xC200 },
167 { 181, 0xC600 },
168 { 102, 0xCC00 },
169 { 49, 0xD900 }
170};
171
172/*
173 * This table is 6 dB too low comapred to the others (probably created with
174 * a different BB_MAG setting)
175 */
176static const struct slookup gain_channel_agc_nf_lookup[] = {
177 /* Gain *100dB // reg */
178 { 7082, 0x3000 },
179 { 7052, 0x4000 },
180 { 7007, 0x4600 },
181 { 6954, 0x4A00 },
182 { 6909, 0x4D00 },
183 { 6833, 0x5100 },
184 { 6753, 0x5400 },
185 { 6659, 0x5700 },
186 { 6561, 0x5A00 },
187 { 6472, 0x5C00 },
188 { 6366, 0x5F00 },
189 { 6259, 0x6100 },
190 { 6151, 0x6400 },
191 { 6026, 0x6700 },
192 { 5920, 0x6900 },
193 { 5835, 0x6B00 },
194 { 5770, 0x6C00 },
195 { 5681, 0x6E00 },
196 { 5596, 0x7000 },
197 { 5503, 0x7200 },
198 { 5429, 0x7300 },
199 { 5319, 0x7500 },
200 { 5220, 0x7700 },
201 { 5111, 0x7900 },
202 { 4983, 0x7B00 },
203 { 4876, 0x7D00 },
204 { 4755, 0x7F00 },
205 { 4635, 0x8100 },
206 { 4499, 0x8300 },
207 { 4405, 0x8500 },
208 { 4323, 0x8600 },
209 { 4233, 0x8800 },
210 { 4156, 0x8A00 },
211 { 4038, 0x8C00 },
212 { 3935, 0x8E00 },
213 { 3823, 0x9000 },
214 { 3712, 0x9200 },
215 { 3601, 0x9500 },
216 { 3511, 0x9700 },
217 { 3413, 0x9900 },
218 { 3309, 0x9B00 },
219 { 3213, 0x9D00 },
220 { 3088, 0x9F00 },
221 { 2992, 0xA100 },
222 { 2878, 0xA400 },
223 { 2769, 0xA700 },
224 { 2645, 0xAA00 },
225 { 2538, 0xAD00 },
226 { 2441, 0xB000 },
227 { 2350, 0xB600 },
228 { 2237, 0xBA00 },
229 { 2137, 0xBF00 },
230 { 2039, 0xC500 },
231 { 1938, 0xDF00 },
232 { 1927, 0xFF00 }
233};
234
235static const struct slookup gain_channel_agc_iip3_lookup[] = {
236 /* Gain *100dB // reg */
237 { 7070, 0x3000 },
238 { 7028, 0x4000 },
239 { 7019, 0x4600 },
240 { 6900, 0x4A00 },
241 { 6811, 0x4D00 },
242 { 6763, 0x5100 },
243 { 6690, 0x5400 },
244 { 6644, 0x5700 },
245 { 6617, 0x5A00 },
246 { 6598, 0x5C00 },
247 { 6462, 0x5F00 },
248 { 6348, 0x6100 },
249 { 6197, 0x6400 },
250 { 6154, 0x6700 },
251 { 6098, 0x6900 },
252 { 5893, 0x6B00 },
253 { 5812, 0x6C00 },
254 { 5773, 0x6E00 },
255 { 5723, 0x7000 },
256 { 5661, 0x7200 },
257 { 5579, 0x7300 },
258 { 5460, 0x7500 },
259 { 5308, 0x7700 },
260 { 5099, 0x7900 },
261 { 4910, 0x7B00 },
262 { 4800, 0x7D00 },
263 { 4785, 0x7F00 },
264 { 4635, 0x8100 },
265 { 4466, 0x8300 },
266 { 4314, 0x8500 },
267 { 4295, 0x8600 },
268 { 4144, 0x8800 },
269 { 3920, 0x8A00 },
270 { 3889, 0x8C00 },
271 { 3771, 0x8E00 },
272 { 3655, 0x9000 },
273 { 3446, 0x9200 },
274 { 3298, 0x9500 },
275 { 3083, 0x9700 },
276 { 3015, 0x9900 },
277 { 2833, 0x9B00 },
278 { 2746, 0x9D00 },
279 { 2632, 0x9F00 },
280 { 2598, 0xA100 },
281 { 2480, 0xA400 },
282 { 2236, 0xA700 },
283 { 2171, 0xAA00 },
284 { 2060, 0xAD00 },
285 { 1999, 0xB000 },
286 { 1974, 0xB600 },
287 { 1820, 0xBA00 },
288 { 1741, 0xBF00 },
289 { 1655, 0xC500 },
290 { 1444, 0xDF00 },
291 { 1325, 0xFF00 },
292};
293
294static inline u32 muldiv32(u32 a, u32 b, u32 c)
295{
296 u64 tmp64;
297
298 tmp64 = (u64)a * (u64)b;
299 do_div(tmp64, c);
300
301 return (u32)tmp64;
302}
303
304static int i2c_read(struct i2c_adapter *adap,
305 u8 adr, u8 *msg, int len, u8 *answ, int alen)
306{
307 struct i2c_msg msgs[2] = { { .addr = adr, .flags = 0,
308 .buf = msg, .len = len},
309 { .addr = adr, .flags = I2C_M_RD,
310 .buf = answ, .len = alen } };
311 if (i2c_transfer(adap, msgs, 2) != 2) {
312 dev_err(&adap->dev, "i2c read error\n");
313 return -EIO;
314 }
315 return 0;
316}
317
318static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len)
319{
320 struct i2c_msg msg = {.addr = adr, .flags = 0,
321 .buf = data, .len = len};
322
323 if (i2c_transfer(adap, &msg, 1) != 1) {
324 dev_err(&adap->dev, "i2c write error\n");
325 return -EIO;
326 }
327 return 0;
328}
329
330static int write_regs(struct stv *state, int reg, int len)
331{
332 u8 d[12];
333
334 memcpy(&d[1], &state->reg[reg], len);
335 d[0] = reg;
336 return i2c_write(state->i2c, state->adr, d, len + 1);
337}
338
339static int write_reg(struct stv *state, u8 reg, u8 val)
340{
341 u8 d[2] = {reg, val};
342
343 return i2c_write(state->i2c, state->adr, d, 2);
344}
345
346static int read_reg(struct stv *state, u8 reg, u8 *val)
347{
348 return i2c_read(state->i2c, state->adr, &reg, 1, val, 1);
349}
350
351static int wait_for_call_done(struct stv *state, u8 mask)
352{
353 int status = 0;
354 u32 lock_retry_count = 10;
355
356 while (lock_retry_count > 0) {
357 u8 regval;
358
359 status = read_reg(state, 9, &regval);
360 if (status < 0)
361 return status;
362
363 if ((regval & mask) == 0)
364 break;
365 usleep_range(4000, 6000);
366 lock_retry_count -= 1;
367
368 status = -EIO;
369 }
370 return status;
371}
372
373static void init_state(struct stv *state)
374{
375 u32 clkdiv = 0;
376 u32 agcmode = 0;
377 u32 agcref = 2;
378 u32 agcset = 0xffffffff;
379 u32 bbmode = 0xffffffff;
380
381 state->reg[0] = 0x08;
382 state->reg[1] = 0x41;
383 state->reg[2] = 0x8f;
384 state->reg[3] = 0x00;
385 state->reg[4] = 0xce;
386 state->reg[5] = 0x54;
387 state->reg[6] = 0x55;
388 state->reg[7] = 0x45;
389 state->reg[8] = 0x46;
390 state->reg[9] = 0xbd;
391 state->reg[10] = 0x11;
392
393 state->ref_freq = 16000;
394
395 if (clkdiv <= 3)
396 state->reg[0x00] |= (clkdiv & 0x03);
397 if (agcmode <= 3) {
398 state->reg[0x03] |= (agcmode << 5);
399 if (agcmode == 0x01)
400 state->reg[0x01] |= 0x30;
401 }
402 if (bbmode <= 3)
403 state->reg[0x01] = (state->reg[0x01] & ~0x30) | (bbmode << 4);
404 if (agcref <= 7)
405 state->reg[0x03] |= agcref;
406 if (agcset <= 31)
407 state->reg[0x02] = (state->reg[0x02] & ~0x1F) | agcset | 0x40;
408}
409
410static int attach_init(struct stv *state)
411{
412 if (write_regs(state, 0, 11))
413 return -ENODEV;
414 return 0;
415}
416
417static void release(struct dvb_frontend *fe)
418{
419 kfree(fe->tuner_priv);
420 fe->tuner_priv = NULL;
421}
422
423static int set_bandwidth(struct dvb_frontend *fe, u32 cutoff_frequency)
424{
425 struct stv *state = fe->tuner_priv;
426 u32 index = (cutoff_frequency + 999999) / 1000000;
427
428 if (index < 6)
429 index = 6;
430 if (index > 50)
431 index = 50;
432 if ((state->reg[0x08] & ~0xFC) == ((index - 6) << 2))
433 return 0;
434
435 state->reg[0x08] = (state->reg[0x08] & ~0xFC) | ((index - 6) << 2);
436 state->reg[0x09] = (state->reg[0x09] & ~0x0C) | 0x08;
437 if (fe->ops.i2c_gate_ctrl)
438 fe->ops.i2c_gate_ctrl(fe, 1);
439 write_regs(state, 0x08, 2);
440 wait_for_call_done(state, 0x08);
441 if (fe->ops.i2c_gate_ctrl)
442 fe->ops.i2c_gate_ctrl(fe, 0);
443 return 0;
444}
445
446static int set_lof(struct stv *state, u32 local_frequency, u32 cutoff_frequency)
447{
448 u32 index = (cutoff_frequency + 999999) / 1000000;
449 u32 frequency = (local_frequency + 500) / 1000;
450 u32 p = 1, psel = 0, fvco, div, frac;
451 u8 icp, tmp;
452
453 if (index < 6)
454 index = 6;
455 if (index > 50)
456 index = 50;
457
458 if (frequency <= 1300000) {
459 p = 4;
460 psel = 1;
461 } else {
462 p = 2;
463 psel = 0;
464 }
465 fvco = frequency * p;
466 div = fvco / state->ref_freq;
467 frac = fvco % state->ref_freq;
468 frac = muldiv32(frac, 0x40000, state->ref_freq);
469
470 icp = 0;
471 if (fvco < 2700000)
472 icp = 0;
473 else if (fvco < 2950000)
474 icp = 1;
475 else if (fvco < 3300000)
476 icp = 2;
477 else if (fvco < 3700000)
478 icp = 3;
479 else if (fvco < 4200000)
480 icp = 5;
481 else if (fvco < 4800000)
482 icp = 6;
483 else
484 icp = 7;
485
486 state->reg[0x02] |= 0x80; /* LNA IIP3 Mode */
487
488 state->reg[0x03] = (state->reg[0x03] & ~0x80) | (psel << 7);
489 state->reg[0x04] = (div & 0xFF);
490 state->reg[0x05] = (((div >> 8) & 0x01) | ((frac & 0x7F) << 1)) & 0xff;
491 state->reg[0x06] = ((frac >> 7) & 0xFF);
492 state->reg[0x07] = (state->reg[0x07] & ~0x07) | ((frac >> 15) & 0x07);
493 state->reg[0x07] = (state->reg[0x07] & ~0xE0) | (icp << 5);
494
495 state->reg[0x08] = (state->reg[0x08] & ~0xFC) | ((index - 6) << 2);
496 /* Start cal vco,CF */
497 state->reg[0x09] = (state->reg[0x09] & ~0x0C) | 0x0C;
498 write_regs(state, 2, 8);
499
500 wait_for_call_done(state, 0x0C);
501
502 usleep_range(10000, 12000);
503
504 read_reg(state, 0x03, &tmp);
505 if (tmp & 0x10) {
506 state->reg[0x02] &= ~0x80; /* LNA NF Mode */
507 write_regs(state, 2, 1);
508 }
509 read_reg(state, 0x08, &tmp);
510
511 state->frequency = frequency;
512
513 return 0;
514}
515
516static int set_params(struct dvb_frontend *fe)
517{
518 struct stv *state = fe->tuner_priv;
519 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
520 u32 freq, cutoff;
521
522 if (p->delivery_system != SYS_DVBS && p->delivery_system != SYS_DVBS2)
523 return -EINVAL;
524
525 freq = p->frequency * 1000;
526 cutoff = 5000000 + muldiv32(p->symbol_rate, 135, 200);
527
528 if (fe->ops.i2c_gate_ctrl)
529 fe->ops.i2c_gate_ctrl(fe, 1);
530 set_lof(state, freq, cutoff);
531 if (fe->ops.i2c_gate_ctrl)
532 fe->ops.i2c_gate_ctrl(fe, 0);
533 return 0;
534}
535
536static s32 table_lookup(const struct slookup *table,
537 int table_size, u16 reg_value)
538{
539 s32 gain;
540 s32 reg_diff;
541 int imin = 0;
542 int imax = table_size - 1;
543 int i;
544
545 /* Assumes Table[0].RegValue < Table[imax].RegValue */
546 if (reg_value <= table[0].reg_value) {
547 gain = table[0].value;
548 } else if (reg_value >= table[imax].reg_value) {
549 gain = table[imax].value;
550 } else {
551 while ((imax - imin) > 1) {
552 i = (imax + imin) / 2;
553 if ((table[imin].reg_value <= reg_value) &&
554 (reg_value <= table[i].reg_value))
555 imax = i;
556 else
557 imin = i;
558 }
559 reg_diff = table[imax].reg_value - table[imin].reg_value;
560 gain = table[imin].value;
561 if (reg_diff != 0)
562 gain += ((s32)(reg_value - table[imin].reg_value) *
563 (s32)(table[imax].value
564 - table[imin].value)) / reg_diff;
565 }
566 return gain;
567}
568
569static int get_rf_strength(struct dvb_frontend *fe, u16 *st)
570{
571 struct stv *state = fe->tuner_priv;
572 u16 rfagc = *st;
573 s32 gain;
574
575 if ((state->reg[0x03] & 0x60) == 0) {
576 /* RF Mode, Read AGC ADC */
577 u8 reg = 0;
578
579 if (fe->ops.i2c_gate_ctrl)
580 fe->ops.i2c_gate_ctrl(fe, 1);
581 write_reg(state, 0x02, state->reg[0x02] | 0x20);
582 read_reg(state, 2, &reg);
583 if (reg & 0x20)
584 read_reg(state, 2, &reg);
585 if (fe->ops.i2c_gate_ctrl)
586 fe->ops.i2c_gate_ctrl(fe, 0);
587
588 if ((state->reg[0x02] & 0x80) == 0)
589 /* NF */
590 gain = table_lookup(lnagain_nf_lookup,
591 ARRAY_SIZE(lnagain_nf_lookup),
592 reg & 0x1F);
593 else
594 /* IIP3 */
595 gain = table_lookup(lnagain_iip3_lookup,
596 ARRAY_SIZE(lnagain_iip3_lookup),
597 reg & 0x1F);
598
599 gain += table_lookup(gain_rfagc_lookup,
600 ARRAY_SIZE(gain_rfagc_lookup), rfagc);
601
602 gain -= 2400;
603 } else {
604 /* Channel Mode */
605 if ((state->reg[0x02] & 0x80) == 0) {
606 /* NF */
607 gain = table_lookup(
608 gain_channel_agc_nf_lookup,
609 ARRAY_SIZE(gain_channel_agc_nf_lookup), rfagc);
610
611 gain += 600;
612 } else {
613 /* IIP3 */
614 gain = table_lookup(
615 gain_channel_agc_iip3_lookup,
616 ARRAY_SIZE(gain_channel_agc_iip3_lookup),
617 rfagc);
618 }
619 }
620
621 if (state->frequency > 0)
622 /* Tilt correction ( 0.00016 dB/MHz ) */
623 gain -= ((((s32)(state->frequency / 1000) - 1550) * 2) / 12);
624
625 /* + (BBGain * 10); */
626 gain += (s32)((state->reg[0x01] & 0xC0) >> 6) * 600 - 1300;
627
628 if (gain < 0)
629 gain = 0;
630 else if (gain > 10000)
631 gain = 10000;
632
633 *st = 10000 - gain;
634
635 return 0;
636}
637
638static const struct dvb_tuner_ops tuner_ops = {
639 .info = {
640 .name = "ST STV6111",
641 .frequency_min = 950000,
642 .frequency_max = 2150000,
643 .frequency_step = 0
644 },
645 .set_params = set_params,
646 .release = release,
647 .get_rf_strength = get_rf_strength,
648 .set_bandwidth = set_bandwidth,
649};
650
651struct dvb_frontend *stv6111_attach(struct dvb_frontend *fe,
652 struct i2c_adapter *i2c, u8 adr)
653{
654 struct stv *state;
655 int stat;
656
657 state = kzalloc(sizeof(*state), GFP_KERNEL);
658 if (!state)
659 return NULL;
660 state->adr = adr;
661 state->i2c = i2c;
662 memcpy(&fe->ops.tuner_ops, &tuner_ops, sizeof(struct dvb_tuner_ops));
663 init_state(state);
664
665 if (fe->ops.i2c_gate_ctrl)
666 fe->ops.i2c_gate_ctrl(fe, 1);
667 stat = attach_init(state);
668 if (fe->ops.i2c_gate_ctrl)
669 fe->ops.i2c_gate_ctrl(fe, 0);
670 if (stat < 0) {
671 kfree(state);
672 return NULL;
673 }
674 fe->tuner_priv = state;
675 return fe;
676}
677EXPORT_SYMBOL_GPL(stv6111_attach);
678
679MODULE_DESCRIPTION("ST STV6111 satellite tuner driver");
680MODULE_AUTHOR("Ralph Metzler, Manfred Voelkel");
681MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb-frontends/stv6111.h b/drivers/media/dvb-frontends/stv6111.h
new file mode 100644
index 000000000000..5bc1228dc9bd
--- /dev/null
+++ b/drivers/media/dvb-frontends/stv6111.h
@@ -0,0 +1,21 @@
1#ifndef _STV6111_H_
2#define _STV6111_H_
3
4#if IS_REACHABLE(CONFIG_DVB_STV6111)
5
6struct dvb_frontend *stv6111_attach(struct dvb_frontend *fe,
7 struct i2c_adapter *i2c, u8 adr);
8
9#else
10
11static inline struct dvb_frontend *stv6111_attach(struct dvb_frontend *fe,
12 struct i2c_adapter *i2c,
13 u8 adr)
14{
15 pr_warn("%s: Driver disabled by Kconfig\n", __func__);
16 return NULL;
17}
18
19#endif /* CONFIG_DVB_STV6111 */
20
21#endif /* _STV6111_H_ */
diff --git a/drivers/media/dvb-frontends/zd1301_demod.c b/drivers/media/dvb-frontends/zd1301_demod.c
index fcf5f69de0c5..84a2b25a574a 100644
--- a/drivers/media/dvb-frontends/zd1301_demod.c
+++ b/drivers/media/dvb-frontends/zd1301_demod.c
@@ -445,7 +445,7 @@ static u32 zd1301_demod_i2c_functionality(struct i2c_adapter *adapter)
445 return I2C_FUNC_I2C; 445 return I2C_FUNC_I2C;
446} 446}
447 447
448static struct i2c_algorithm zd1301_demod_i2c_algorithm = { 448static const struct i2c_algorithm zd1301_demod_i2c_algorithm = {
449 .master_xfer = zd1301_demod_i2c_master_xfer, 449 .master_xfer = zd1301_demod_i2c_master_xfer,
450 .functionality = zd1301_demod_i2c_functionality, 450 .functionality = zd1301_demod_i2c_functionality,
451}; 451};
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 121b3b5394cb..94153895fcd4 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -204,6 +204,18 @@ config VIDEO_ADV7183
204 To compile this driver as a module, choose M here: the 204 To compile this driver as a module, choose M here: the
205 module will be called adv7183. 205 module will be called adv7183.
206 206
207config VIDEO_ADV748X
208 tristate "Analog Devices ADV748x decoder"
209 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
210 depends on OF
211 select REGMAP_I2C
212 ---help---
213 V4L2 subdevice driver for the Analog Devices
214 ADV7481 and ADV7482 HDMI/Analog video decoders.
215
216 To compile this driver as a module, choose M here: the
217 module will be called adv748x.
218
207config VIDEO_ADV7604 219config VIDEO_ADV7604
208 tristate "Analog Devices ADV7604 decoder" 220 tristate "Analog Devices ADV7604 decoder"
209 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API 221 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
@@ -593,6 +605,30 @@ config VIDEO_OV5647
593 To compile this driver as a module, choose M here: the 605 To compile this driver as a module, choose M here: the
594 module will be called ov5647. 606 module will be called ov5647.
595 607
608config VIDEO_OV6650
609 tristate "OmniVision OV6650 sensor support"
610 depends on I2C && VIDEO_V4L2
611 depends on MEDIA_CAMERA_SUPPORT
612 ---help---
613 This is a Video4Linux2 sensor-level driver for the OmniVision
614 OV6650 camera.
615
616 To compile this driver as a module, choose M here: the
617 module will be called ov6650.
618
619config VIDEO_OV5670
620 tristate "OmniVision OV5670 sensor support"
621 depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
622 depends on MEDIA_CAMERA_SUPPORT
623 depends on MEDIA_CONTROLLER
624 select V4L2_FWNODE
625 ---help---
626 This is a Video4Linux2 sensor-level driver for the OmniVision
627 OV5670 camera.
628
629 To compile this driver as a module, choose M here: the
630 module will be called ov5670.
631
596config VIDEO_OV7640 632config VIDEO_OV7640
597 tristate "OmniVision OV7640 sensor support" 633 tristate "OmniVision OV7640 sensor support"
598 depends on I2C && VIDEO_V4L2 634 depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 2c0868fa6034..c843c181dfb9 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o
28obj-$(CONFIG_VIDEO_ADV7183) += adv7183.o 28obj-$(CONFIG_VIDEO_ADV7183) += adv7183.o
29obj-$(CONFIG_VIDEO_ADV7343) += adv7343.o 29obj-$(CONFIG_VIDEO_ADV7343) += adv7343.o
30obj-$(CONFIG_VIDEO_ADV7393) += adv7393.o 30obj-$(CONFIG_VIDEO_ADV7393) += adv7393.o
31obj-$(CONFIG_VIDEO_ADV748X) += adv748x/
31obj-$(CONFIG_VIDEO_ADV7604) += adv7604.o 32obj-$(CONFIG_VIDEO_ADV7604) += adv7604.o
32obj-$(CONFIG_VIDEO_ADV7842) += adv7842.o 33obj-$(CONFIG_VIDEO_ADV7842) += adv7842.o
33obj-$(CONFIG_VIDEO_AD9389B) += ad9389b.o 34obj-$(CONFIG_VIDEO_AD9389B) += ad9389b.o
@@ -62,6 +63,8 @@ obj-$(CONFIG_VIDEO_OV2640) += ov2640.o
62obj-$(CONFIG_VIDEO_OV5640) += ov5640.o 63obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
63obj-$(CONFIG_VIDEO_OV5645) += ov5645.o 64obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
64obj-$(CONFIG_VIDEO_OV5647) += ov5647.o 65obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
66obj-$(CONFIG_VIDEO_OV5670) += ov5670.o
67obj-$(CONFIG_VIDEO_OV6650) += ov6650.o
65obj-$(CONFIG_VIDEO_OV7640) += ov7640.o 68obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
66obj-$(CONFIG_VIDEO_OV7670) += ov7670.o 69obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
67obj-$(CONFIG_VIDEO_OV9650) += ov9650.o 70obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index 50f354144ee7..a056d6cdaaaa 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -1208,7 +1208,7 @@ static int ad9389b_remove(struct i2c_client *client)
1208 1208
1209/* ----------------------------------------------------------------------- */ 1209/* ----------------------------------------------------------------------- */
1210 1210
1211static struct i2c_device_id ad9389b_id[] = { 1211static const struct i2c_device_id ad9389b_id[] = {
1212 { "ad9389b", 0 }, 1212 { "ad9389b", 0 },
1213 { "ad9889b", 0 }, 1213 { "ad9889b", 0 },
1214 { } 1214 { }
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 78de7ddf5081..3df28f2f9b38 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -1402,6 +1402,8 @@ static int adv7180_remove(struct i2c_client *client)
1402 1402
1403static const struct i2c_device_id adv7180_id[] = { 1403static const struct i2c_device_id adv7180_id[] = {
1404 { "adv7180", (kernel_ulong_t)&adv7180_info }, 1404 { "adv7180", (kernel_ulong_t)&adv7180_info },
1405 { "adv7180cp", (kernel_ulong_t)&adv7180_info },
1406 { "adv7180st", (kernel_ulong_t)&adv7180_info },
1405 { "adv7182", (kernel_ulong_t)&adv7182_info }, 1407 { "adv7182", (kernel_ulong_t)&adv7182_info },
1406 { "adv7280", (kernel_ulong_t)&adv7280_info }, 1408 { "adv7280", (kernel_ulong_t)&adv7280_info },
1407 { "adv7280-m", (kernel_ulong_t)&adv7280_m_info }, 1409 { "adv7280-m", (kernel_ulong_t)&adv7280_m_info },
diff --git a/drivers/media/i2c/adv748x/Makefile b/drivers/media/i2c/adv748x/Makefile
new file mode 100644
index 000000000000..c0711e076f1d
--- /dev/null
+++ b/drivers/media/i2c/adv748x/Makefile
@@ -0,0 +1,7 @@
1adv748x-objs := \
2 adv748x-afe.o \
3 adv748x-core.o \
4 adv748x-csi2.o \
5 adv748x-hdmi.o
6
7obj-$(CONFIG_VIDEO_ADV748X) += adv748x.o
diff --git a/drivers/media/i2c/adv748x/adv748x-afe.c b/drivers/media/i2c/adv748x/adv748x-afe.c
new file mode 100644
index 000000000000..b33ccfc08708
--- /dev/null
+++ b/drivers/media/i2c/adv748x/adv748x-afe.c
@@ -0,0 +1,552 @@
1/*
2 * Driver for Analog Devices ADV748X 8 channel analog front end (AFE) receiver
3 * with standard definition processor (SDP)
4 *
5 * Copyright (C) 2017 Renesas Electronics Corp.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/delay.h>
14#include <linux/module.h>
15#include <linux/mutex.h>
16#include <linux/v4l2-dv-timings.h>
17
18#include <media/v4l2-ctrls.h>
19#include <media/v4l2-device.h>
20#include <media/v4l2-dv-timings.h>
21#include <media/v4l2-ioctl.h>
22
23#include "adv748x.h"
24
25/* -----------------------------------------------------------------------------
26 * SDP
27 */
28
29#define ADV748X_AFE_STD_AD_PAL_BG_NTSC_J_SECAM 0x0
30#define ADV748X_AFE_STD_AD_PAL_BG_NTSC_J_SECAM_PED 0x1
31#define ADV748X_AFE_STD_AD_PAL_N_NTSC_J_SECAM 0x2
32#define ADV748X_AFE_STD_AD_PAL_N_NTSC_M_SECAM 0x3
33#define ADV748X_AFE_STD_NTSC_J 0x4
34#define ADV748X_AFE_STD_NTSC_M 0x5
35#define ADV748X_AFE_STD_PAL60 0x6
36#define ADV748X_AFE_STD_NTSC_443 0x7
37#define ADV748X_AFE_STD_PAL_BG 0x8
38#define ADV748X_AFE_STD_PAL_N 0x9
39#define ADV748X_AFE_STD_PAL_M 0xa
40#define ADV748X_AFE_STD_PAL_M_PED 0xb
41#define ADV748X_AFE_STD_PAL_COMB_N 0xc
42#define ADV748X_AFE_STD_PAL_COMB_N_PED 0xd
43#define ADV748X_AFE_STD_PAL_SECAM 0xe
44#define ADV748X_AFE_STD_PAL_SECAM_PED 0xf
45
46static int adv748x_afe_read_ro_map(struct adv748x_state *state, u8 reg)
47{
48 int ret;
49
50 /* Select SDP Read-Only Main Map */
51 ret = sdp_write(state, ADV748X_SDP_MAP_SEL,
52 ADV748X_SDP_MAP_SEL_RO_MAIN);
53 if (ret < 0)
54 return ret;
55
56 return sdp_read(state, reg);
57}
58
59static int adv748x_afe_status(struct adv748x_afe *afe, u32 *signal,
60 v4l2_std_id *std)
61{
62 struct adv748x_state *state = adv748x_afe_to_state(afe);
63 int info;
64
65 /* Read status from reg 0x10 of SDP RO Map */
66 info = adv748x_afe_read_ro_map(state, ADV748X_SDP_RO_10);
67 if (info < 0)
68 return info;
69
70 if (signal)
71 *signal = info & ADV748X_SDP_RO_10_IN_LOCK ?
72 0 : V4L2_IN_ST_NO_SIGNAL;
73
74 if (!std)
75 return 0;
76
77 /* Standard not valid if there is no signal */
78 if (!(info & ADV748X_SDP_RO_10_IN_LOCK)) {
79 *std = V4L2_STD_UNKNOWN;
80 return 0;
81 }
82
83 switch (info & 0x70) {
84 case 0x00:
85 *std = V4L2_STD_NTSC;
86 break;
87 case 0x10:
88 *std = V4L2_STD_NTSC_443;
89 break;
90 case 0x20:
91 *std = V4L2_STD_PAL_M;
92 break;
93 case 0x30:
94 *std = V4L2_STD_PAL_60;
95 break;
96 case 0x40:
97 *std = V4L2_STD_PAL;
98 break;
99 case 0x50:
100 *std = V4L2_STD_SECAM;
101 break;
102 case 0x60:
103 *std = V4L2_STD_PAL_Nc | V4L2_STD_PAL_N;
104 break;
105 case 0x70:
106 *std = V4L2_STD_SECAM;
107 break;
108 default:
109 *std = V4L2_STD_UNKNOWN;
110 break;
111 }
112
113 return 0;
114}
115
116static void adv748x_afe_fill_format(struct adv748x_afe *afe,
117 struct v4l2_mbus_framefmt *fmt)
118{
119 memset(fmt, 0, sizeof(*fmt));
120
121 fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
122 fmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
123 fmt->field = V4L2_FIELD_ALTERNATE;
124
125 fmt->width = 720;
126 fmt->height = afe->curr_norm & V4L2_STD_525_60 ? 480 : 576;
127
128 /* Field height */
129 fmt->height /= 2;
130}
131
132static int adv748x_afe_std(v4l2_std_id std)
133{
134 if (std == V4L2_STD_PAL_60)
135 return ADV748X_AFE_STD_PAL60;
136 if (std == V4L2_STD_NTSC_443)
137 return ADV748X_AFE_STD_NTSC_443;
138 if (std == V4L2_STD_PAL_N)
139 return ADV748X_AFE_STD_PAL_N;
140 if (std == V4L2_STD_PAL_M)
141 return ADV748X_AFE_STD_PAL_M;
142 if (std == V4L2_STD_PAL_Nc)
143 return ADV748X_AFE_STD_PAL_COMB_N;
144 if (std & V4L2_STD_NTSC)
145 return ADV748X_AFE_STD_NTSC_M;
146 if (std & V4L2_STD_PAL)
147 return ADV748X_AFE_STD_PAL_BG;
148 if (std & V4L2_STD_SECAM)
149 return ADV748X_AFE_STD_PAL_SECAM;
150
151 return -EINVAL;
152}
153
154static void adv748x_afe_set_video_standard(struct adv748x_state *state,
155 int sdpstd)
156{
157 sdp_clrset(state, ADV748X_SDP_VID_SEL, ADV748X_SDP_VID_SEL_MASK,
158 (sdpstd & 0xf) << ADV748X_SDP_VID_SEL_SHIFT);
159}
160
161static int adv748x_afe_s_input(struct adv748x_afe *afe, unsigned int input)
162{
163 struct adv748x_state *state = adv748x_afe_to_state(afe);
164
165 return sdp_write(state, ADV748X_SDP_INSEL, input);
166}
167
168static int adv748x_afe_g_pixelaspect(struct v4l2_subdev *sd,
169 struct v4l2_fract *aspect)
170{
171 struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
172
173 if (afe->curr_norm & V4L2_STD_525_60) {
174 aspect->numerator = 11;
175 aspect->denominator = 10;
176 } else {
177 aspect->numerator = 54;
178 aspect->denominator = 59;
179 }
180
181 return 0;
182}
183
184/* -----------------------------------------------------------------------------
185 * v4l2_subdev_video_ops
186 */
187
188static int adv748x_afe_g_std(struct v4l2_subdev *sd, v4l2_std_id *norm)
189{
190 struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
191
192 *norm = afe->curr_norm;
193
194 return 0;
195}
196
197static int adv748x_afe_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
198{
199 struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
200 struct adv748x_state *state = adv748x_afe_to_state(afe);
201 int afe_std = adv748x_afe_std(std);
202
203 if (afe_std < 0)
204 return afe_std;
205
206 mutex_lock(&state->mutex);
207
208 adv748x_afe_set_video_standard(state, afe_std);
209 afe->curr_norm = std;
210
211 mutex_unlock(&state->mutex);
212
213 return 0;
214}
215
216static int adv748x_afe_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
217{
218 struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
219 struct adv748x_state *state = adv748x_afe_to_state(afe);
220 int ret;
221
222 mutex_lock(&state->mutex);
223
224 if (afe->streaming) {
225 ret = -EBUSY;
226 goto unlock;
227 }
228
229 /* Set auto detect mode */
230 adv748x_afe_set_video_standard(state,
231 ADV748X_AFE_STD_AD_PAL_BG_NTSC_J_SECAM);
232
233 msleep(100);
234
235 /* Read detected standard */
236 ret = adv748x_afe_status(afe, NULL, std);
237
238 /* Restore original state */
239 adv748x_afe_set_video_standard(state, afe->curr_norm);
240
241unlock:
242 mutex_unlock(&state->mutex);
243
244 return ret;
245}
246
247static int adv748x_afe_g_tvnorms(struct v4l2_subdev *sd, v4l2_std_id *norm)
248{
249 *norm = V4L2_STD_ALL;
250
251 return 0;
252}
253
254static int adv748x_afe_g_input_status(struct v4l2_subdev *sd, u32 *status)
255{
256 struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
257 struct adv748x_state *state = adv748x_afe_to_state(afe);
258 int ret;
259
260 mutex_lock(&state->mutex);
261
262 ret = adv748x_afe_status(afe, status, NULL);
263
264 mutex_unlock(&state->mutex);
265 return ret;
266}
267
268static int adv748x_afe_s_stream(struct v4l2_subdev *sd, int enable)
269{
270 struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
271 struct adv748x_state *state = adv748x_afe_to_state(afe);
272 int ret, signal = V4L2_IN_ST_NO_SIGNAL;
273
274 mutex_lock(&state->mutex);
275
276 if (enable) {
277 ret = adv748x_afe_s_input(afe, afe->input);
278 if (ret)
279 goto unlock;
280 }
281
282 ret = adv748x_txb_power(state, enable);
283 if (ret)
284 goto unlock;
285
286 afe->streaming = enable;
287
288 adv748x_afe_status(afe, &signal, NULL);
289 if (signal != V4L2_IN_ST_NO_SIGNAL)
290 adv_dbg(state, "Detected SDP signal\n");
291 else
292 adv_dbg(state, "Couldn't detect SDP video signal\n");
293
294unlock:
295 mutex_unlock(&state->mutex);
296
297 return ret;
298}
299
300static const struct v4l2_subdev_video_ops adv748x_afe_video_ops = {
301 .g_std = adv748x_afe_g_std,
302 .s_std = adv748x_afe_s_std,
303 .querystd = adv748x_afe_querystd,
304 .g_tvnorms = adv748x_afe_g_tvnorms,
305 .g_input_status = adv748x_afe_g_input_status,
306 .s_stream = adv748x_afe_s_stream,
307 .g_pixelaspect = adv748x_afe_g_pixelaspect,
308};
309
310/* -----------------------------------------------------------------------------
311 * v4l2_subdev_pad_ops
312 */
313
314static int adv748x_afe_propagate_pixelrate(struct adv748x_afe *afe)
315{
316 struct v4l2_subdev *tx;
317 unsigned int width, height, fps;
318
319 tx = adv748x_get_remote_sd(&afe->pads[ADV748X_AFE_SOURCE]);
320 if (!tx)
321 return -ENOLINK;
322
323 width = 720;
324 height = afe->curr_norm & V4L2_STD_525_60 ? 480 : 576;
325 fps = afe->curr_norm & V4L2_STD_525_60 ? 30 : 25;
326
327 return adv748x_csi2_set_pixelrate(tx, width * height * fps);
328}
329
330static int adv748x_afe_enum_mbus_code(struct v4l2_subdev *sd,
331 struct v4l2_subdev_pad_config *cfg,
332 struct v4l2_subdev_mbus_code_enum *code)
333{
334 if (code->index != 0)
335 return -EINVAL;
336
337 code->code = MEDIA_BUS_FMT_UYVY8_2X8;
338
339 return 0;
340}
341
342static int adv748x_afe_get_format(struct v4l2_subdev *sd,
343 struct v4l2_subdev_pad_config *cfg,
344 struct v4l2_subdev_format *sdformat)
345{
346 struct adv748x_afe *afe = adv748x_sd_to_afe(sd);
347 struct v4l2_mbus_framefmt *mbusformat;
348
349 /* It makes no sense to get the format of the analog sink pads */
350 if (sdformat->pad != ADV748X_AFE_SOURCE)
351 return -EINVAL;
352
353 if (sdformat->which == V4L2_SUBDEV_FORMAT_TRY) {
354 mbusformat = v4l2_subdev_get_try_format(sd, cfg, sdformat->pad);
355 sdformat->format = *mbusformat;
356 } else {
357 adv748x_afe_fill_format(afe, &sdformat->format);
358 adv748x_afe_propagate_pixelrate(afe);
359 }
360
361 return 0;
362}
363
364static int adv748x_afe_set_format(struct v4l2_subdev *sd,
365 struct v4l2_subdev_pad_config *cfg,
366 struct v4l2_subdev_format *sdformat)
367{
368 struct v4l2_mbus_framefmt *mbusformat;
369
370 /* It makes no sense to get the format of the analog sink pads */
371 if (sdformat->pad != ADV748X_AFE_SOURCE)
372 return -EINVAL;
373
374 if (sdformat->which == V4L2_SUBDEV_FORMAT_ACTIVE)
375 return adv748x_afe_get_format(sd, cfg, sdformat);
376
377 mbusformat = v4l2_subdev_get_try_format(sd, cfg, sdformat->pad);
378 *mbusformat = sdformat->format;
379
380 return 0;
381}
382
383static const struct v4l2_subdev_pad_ops adv748x_afe_pad_ops = {
384 .enum_mbus_code = adv748x_afe_enum_mbus_code,
385 .set_fmt = adv748x_afe_set_format,
386 .get_fmt = adv748x_afe_get_format,
387};
388
389/* -----------------------------------------------------------------------------
390 * v4l2_subdev_ops
391 */
392
393static const struct v4l2_subdev_ops adv748x_afe_ops = {
394 .video = &adv748x_afe_video_ops,
395 .pad = &adv748x_afe_pad_ops,
396};
397
398/* -----------------------------------------------------------------------------
399 * Controls
400 */
401
402static const char * const afe_ctrl_frp_menu[] = {
403 "Disabled",
404 "Solid Blue",
405 "Color Bars",
406 "Grey Ramp",
407 "Cb Ramp",
408 "Cr Ramp",
409 "Boundary"
410};
411
412static int adv748x_afe_s_ctrl(struct v4l2_ctrl *ctrl)
413{
414 struct adv748x_afe *afe = adv748x_ctrl_to_afe(ctrl);
415 struct adv748x_state *state = adv748x_afe_to_state(afe);
416 bool enable;
417 int ret;
418
419 ret = sdp_write(state, 0x0e, 0x00);
420 if (ret < 0)
421 return ret;
422
423 switch (ctrl->id) {
424 case V4L2_CID_BRIGHTNESS:
425 ret = sdp_write(state, ADV748X_SDP_BRI, ctrl->val);
426 break;
427 case V4L2_CID_HUE:
428 /* Hue is inverted according to HSL chart */
429 ret = sdp_write(state, ADV748X_SDP_HUE, -ctrl->val);
430 break;
431 case V4L2_CID_CONTRAST:
432 ret = sdp_write(state, ADV748X_SDP_CON, ctrl->val);
433 break;
434 case V4L2_CID_SATURATION:
435 ret = sdp_write(state, ADV748X_SDP_SD_SAT_U, ctrl->val);
436 if (ret)
437 break;
438 ret = sdp_write(state, ADV748X_SDP_SD_SAT_V, ctrl->val);
439 break;
440 case V4L2_CID_TEST_PATTERN:
441 enable = !!ctrl->val;
442
443 /* Enable/Disable Color bar test patterns */
444 ret = sdp_clrset(state, ADV748X_SDP_DEF, ADV748X_SDP_DEF_VAL_EN,
445 enable);
446 if (ret)
447 break;
448 ret = sdp_clrset(state, ADV748X_SDP_FRP, ADV748X_SDP_FRP_MASK,
449 enable ? ctrl->val - 1 : 0);
450 break;
451 default:
452 return -EINVAL;
453 }
454
455 return ret;
456}
457
458static const struct v4l2_ctrl_ops adv748x_afe_ctrl_ops = {
459 .s_ctrl = adv748x_afe_s_ctrl,
460};
461
462static int adv748x_afe_init_controls(struct adv748x_afe *afe)
463{
464 struct adv748x_state *state = adv748x_afe_to_state(afe);
465
466 v4l2_ctrl_handler_init(&afe->ctrl_hdl, 5);
467
468 /* Use our mutex for the controls */
469 afe->ctrl_hdl.lock = &state->mutex;
470
471 v4l2_ctrl_new_std(&afe->ctrl_hdl, &adv748x_afe_ctrl_ops,
472 V4L2_CID_BRIGHTNESS, ADV748X_SDP_BRI_MIN,
473 ADV748X_SDP_BRI_MAX, 1, ADV748X_SDP_BRI_DEF);
474 v4l2_ctrl_new_std(&afe->ctrl_hdl, &adv748x_afe_ctrl_ops,
475 V4L2_CID_CONTRAST, ADV748X_SDP_CON_MIN,
476 ADV748X_SDP_CON_MAX, 1, ADV748X_SDP_CON_DEF);
477 v4l2_ctrl_new_std(&afe->ctrl_hdl, &adv748x_afe_ctrl_ops,
478 V4L2_CID_SATURATION, ADV748X_SDP_SAT_MIN,
479 ADV748X_SDP_SAT_MAX, 1, ADV748X_SDP_SAT_DEF);
480 v4l2_ctrl_new_std(&afe->ctrl_hdl, &adv748x_afe_ctrl_ops,
481 V4L2_CID_HUE, ADV748X_SDP_HUE_MIN,
482 ADV748X_SDP_HUE_MAX, 1, ADV748X_SDP_HUE_DEF);
483
484 v4l2_ctrl_new_std_menu_items(&afe->ctrl_hdl, &adv748x_afe_ctrl_ops,
485 V4L2_CID_TEST_PATTERN,
486 ARRAY_SIZE(afe_ctrl_frp_menu) - 1,
487 0, 0, afe_ctrl_frp_menu);
488
489 afe->sd.ctrl_handler = &afe->ctrl_hdl;
490 if (afe->ctrl_hdl.error) {
491 v4l2_ctrl_handler_free(&afe->ctrl_hdl);
492 return afe->ctrl_hdl.error;
493 }
494
495 return v4l2_ctrl_handler_setup(&afe->ctrl_hdl);
496}
497
498int adv748x_afe_init(struct adv748x_afe *afe)
499{
500 struct adv748x_state *state = adv748x_afe_to_state(afe);
501 int ret;
502 unsigned int i;
503
504 afe->input = 0;
505 afe->streaming = false;
506 afe->curr_norm = V4L2_STD_NTSC_M;
507
508 adv748x_subdev_init(&afe->sd, state, &adv748x_afe_ops,
509 MEDIA_ENT_F_ATV_DECODER, "afe");
510
511 /* Identify the first connector found as a default input if set */
512 for (i = ADV748X_PORT_AIN0; i <= ADV748X_PORT_AIN7; i++) {
513 /* Inputs and ports are 1-indexed to match the data sheet */
514 if (state->endpoints[i]) {
515 afe->input = i;
516 break;
517 }
518 }
519
520 adv748x_afe_s_input(afe, afe->input);
521
522 adv_dbg(state, "AFE Default input set to %d\n", afe->input);
523
524 /* Entity pads and sinks are 0-indexed to match the pads */
525 for (i = ADV748X_AFE_SINK_AIN0; i <= ADV748X_AFE_SINK_AIN7; i++)
526 afe->pads[i].flags = MEDIA_PAD_FL_SINK;
527
528 afe->pads[ADV748X_AFE_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
529
530 ret = media_entity_pads_init(&afe->sd.entity, ADV748X_AFE_NR_PADS,
531 afe->pads);
532 if (ret)
533 return ret;
534
535 ret = adv748x_afe_init_controls(afe);
536 if (ret)
537 goto error;
538
539 return 0;
540
541error:
542 media_entity_cleanup(&afe->sd.entity);
543
544 return ret;
545}
546
547void adv748x_afe_cleanup(struct adv748x_afe *afe)
548{
549 v4l2_device_unregister_subdev(&afe->sd);
550 media_entity_cleanup(&afe->sd.entity);
551 v4l2_ctrl_handler_free(&afe->ctrl_hdl);
552}
diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
new file mode 100644
index 000000000000..5ee14f2c2747
--- /dev/null
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -0,0 +1,833 @@
1/*
2 * Driver for Analog Devices ADV748X HDMI receiver with AFE
3 *
4 * Copyright (C) 2017 Renesas Electronics Corp.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 * Authors:
12 * Koji Matsuoka <koji.matsuoka.xm@renesas.com>
13 * Niklas Söderlund <niklas.soderlund@ragnatech.se>
14 * Kieran Bingham <kieran.bingham@ideasonboard.com>
15 */
16
17#include <linux/delay.h>
18#include <linux/errno.h>
19#include <linux/i2c.h>
20#include <linux/module.h>
21#include <linux/mutex.h>
22#include <linux/of_graph.h>
23#include <linux/regmap.h>
24#include <linux/slab.h>
25#include <linux/v4l2-dv-timings.h>
26
27#include <media/v4l2-ctrls.h>
28#include <media/v4l2-device.h>
29#include <media/v4l2-dv-timings.h>
30#include <media/v4l2-ioctl.h>
31
32#include "adv748x.h"
33
34/* -----------------------------------------------------------------------------
35 * Register manipulation
36 */
37
38static const struct regmap_config adv748x_regmap_cnf[] = {
39 {
40 .name = "io",
41 .reg_bits = 8,
42 .val_bits = 8,
43
44 .max_register = 0xff,
45 .cache_type = REGCACHE_NONE,
46 },
47 {
48 .name = "dpll",
49 .reg_bits = 8,
50 .val_bits = 8,
51
52 .max_register = 0xff,
53 .cache_type = REGCACHE_NONE,
54 },
55 {
56 .name = "cp",
57 .reg_bits = 8,
58 .val_bits = 8,
59
60 .max_register = 0xff,
61 .cache_type = REGCACHE_NONE,
62 },
63 {
64 .name = "hdmi",
65 .reg_bits = 8,
66 .val_bits = 8,
67
68 .max_register = 0xff,
69 .cache_type = REGCACHE_NONE,
70 },
71 {
72 .name = "edid",
73 .reg_bits = 8,
74 .val_bits = 8,
75
76 .max_register = 0xff,
77 .cache_type = REGCACHE_NONE,
78 },
79 {
80 .name = "repeater",
81 .reg_bits = 8,
82 .val_bits = 8,
83
84 .max_register = 0xff,
85 .cache_type = REGCACHE_NONE,
86 },
87 {
88 .name = "infoframe",
89 .reg_bits = 8,
90 .val_bits = 8,
91
92 .max_register = 0xff,
93 .cache_type = REGCACHE_NONE,
94 },
95 {
96 .name = "cec",
97 .reg_bits = 8,
98 .val_bits = 8,
99
100 .max_register = 0xff,
101 .cache_type = REGCACHE_NONE,
102 },
103 {
104 .name = "sdp",
105 .reg_bits = 8,
106 .val_bits = 8,
107
108 .max_register = 0xff,
109 .cache_type = REGCACHE_NONE,
110 },
111
112 {
113 .name = "txb",
114 .reg_bits = 8,
115 .val_bits = 8,
116
117 .max_register = 0xff,
118 .cache_type = REGCACHE_NONE,
119 },
120 {
121 .name = "txa",
122 .reg_bits = 8,
123 .val_bits = 8,
124
125 .max_register = 0xff,
126 .cache_type = REGCACHE_NONE,
127 },
128};
129
130static int adv748x_configure_regmap(struct adv748x_state *state, int region)
131{
132 int err;
133
134 if (!state->i2c_clients[region])
135 return -ENODEV;
136
137 state->regmap[region] =
138 devm_regmap_init_i2c(state->i2c_clients[region],
139 &adv748x_regmap_cnf[region]);
140
141 if (IS_ERR(state->regmap[region])) {
142 err = PTR_ERR(state->regmap[region]);
143 adv_err(state,
144 "Error initializing regmap %d with error %d\n",
145 region, err);
146 return -EINVAL;
147 }
148
149 return 0;
150}
151
152/* Default addresses for the I2C pages */
153static int adv748x_i2c_addresses[ADV748X_PAGE_MAX] = {
154 ADV748X_I2C_IO,
155 ADV748X_I2C_DPLL,
156 ADV748X_I2C_CP,
157 ADV748X_I2C_HDMI,
158 ADV748X_I2C_EDID,
159 ADV748X_I2C_REPEATER,
160 ADV748X_I2C_INFOFRAME,
161 ADV748X_I2C_CEC,
162 ADV748X_I2C_SDP,
163 ADV748X_I2C_TXB,
164 ADV748X_I2C_TXA,
165};
166
167static int adv748x_read_check(struct adv748x_state *state,
168 int client_page, u8 reg)
169{
170 struct i2c_client *client = state->i2c_clients[client_page];
171 int err;
172 unsigned int val;
173
174 err = regmap_read(state->regmap[client_page], reg, &val);
175
176 if (err) {
177 adv_err(state, "error reading %02x, %02x\n",
178 client->addr, reg);
179 return err;
180 }
181
182 return val;
183}
184
185int adv748x_read(struct adv748x_state *state, u8 page, u8 reg)
186{
187 return adv748x_read_check(state, page, reg);
188}
189
190int adv748x_write(struct adv748x_state *state, u8 page, u8 reg, u8 value)
191{
192 return regmap_write(state->regmap[page], reg, value);
193}
194
195/* adv748x_write_block(): Write raw data with a maximum of I2C_SMBUS_BLOCK_MAX
196 * size to one or more registers.
197 *
198 * A value of zero will be returned on success, a negative errno will
199 * be returned in error cases.
200 */
201int adv748x_write_block(struct adv748x_state *state, int client_page,
202 unsigned int init_reg, const void *val,
203 size_t val_len)
204{
205 struct regmap *regmap = state->regmap[client_page];
206
207 if (val_len > I2C_SMBUS_BLOCK_MAX)
208 val_len = I2C_SMBUS_BLOCK_MAX;
209
210 return regmap_raw_write(regmap, init_reg, val, val_len);
211}
212
213static struct i2c_client *adv748x_dummy_client(struct adv748x_state *state,
214 u8 addr, u8 io_reg)
215{
216 struct i2c_client *client = state->client;
217
218 if (addr)
219 io_write(state, io_reg, addr << 1);
220
221 return i2c_new_dummy(client->adapter, io_read(state, io_reg) >> 1);
222}
223
224static void adv748x_unregister_clients(struct adv748x_state *state)
225{
226 unsigned int i;
227
228 for (i = 1; i < ARRAY_SIZE(state->i2c_clients); ++i) {
229 if (state->i2c_clients[i])
230 i2c_unregister_device(state->i2c_clients[i]);
231 }
232}
233
234static int adv748x_initialise_clients(struct adv748x_state *state)
235{
236 int i;
237 int ret;
238
239 for (i = ADV748X_PAGE_DPLL; i < ADV748X_PAGE_MAX; ++i) {
240 state->i2c_clients[i] =
241 adv748x_dummy_client(state, adv748x_i2c_addresses[i],
242 ADV748X_IO_SLAVE_ADDR_BASE + i);
243 if (state->i2c_clients[i] == NULL) {
244 adv_err(state, "failed to create i2c client %u\n", i);
245 return -ENOMEM;
246 }
247
248 ret = adv748x_configure_regmap(state, i);
249 if (ret)
250 return ret;
251 }
252
253 return 0;
254}
255
256/**
257 * struct adv748x_reg_value - Register write instruction
258 * @page: Regmap page identifier
259 * @reg: I2C register
260 * @value: value to write to @page at @reg
261 */
262struct adv748x_reg_value {
263 u8 page;
264 u8 reg;
265 u8 value;
266};
267
268static int adv748x_write_regs(struct adv748x_state *state,
269 const struct adv748x_reg_value *regs)
270{
271 int ret;
272
273 while (regs->page != ADV748X_PAGE_EOR) {
274 if (regs->page == ADV748X_PAGE_WAIT) {
275 msleep(regs->value);
276 } else {
277 ret = adv748x_write(state, regs->page, regs->reg,
278 regs->value);
279 if (ret < 0) {
280 adv_err(state,
281 "Error regs page: 0x%02x reg: 0x%02x\n",
282 regs->page, regs->reg);
283 return ret;
284 }
285 }
286 regs++;
287 }
288
289 return 0;
290}
291
292/* -----------------------------------------------------------------------------
293 * TXA and TXB
294 */
295
296static const struct adv748x_reg_value adv748x_power_up_txa_4lane[] = {
297
298 {ADV748X_PAGE_TXA, 0x00, 0x84}, /* Enable 4-lane MIPI */
299 {ADV748X_PAGE_TXA, 0x00, 0xa4}, /* Set Auto DPHY Timing */
300
301 {ADV748X_PAGE_TXA, 0x31, 0x82}, /* ADI Required Write */
302 {ADV748X_PAGE_TXA, 0x1e, 0x40}, /* ADI Required Write */
303 {ADV748X_PAGE_TXA, 0xda, 0x01}, /* i2c_mipi_pll_en - 1'b1 */
304 {ADV748X_PAGE_WAIT, 0x00, 0x02},/* delay 2 */
305 {ADV748X_PAGE_TXA, 0x00, 0x24 },/* Power-up CSI-TX */
306 {ADV748X_PAGE_WAIT, 0x00, 0x01},/* delay 1 */
307 {ADV748X_PAGE_TXA, 0xc1, 0x2b}, /* ADI Required Write */
308 {ADV748X_PAGE_WAIT, 0x00, 0x01},/* delay 1 */
309 {ADV748X_PAGE_TXA, 0x31, 0x80}, /* ADI Required Write */
310
311 {ADV748X_PAGE_EOR, 0xff, 0xff} /* End of register table */
312};
313
314static const struct adv748x_reg_value adv748x_power_down_txa_4lane[] = {
315
316 {ADV748X_PAGE_TXA, 0x31, 0x82}, /* ADI Required Write */
317 {ADV748X_PAGE_TXA, 0x1e, 0x00}, /* ADI Required Write */
318 {ADV748X_PAGE_TXA, 0x00, 0x84}, /* Enable 4-lane MIPI */
319 {ADV748X_PAGE_TXA, 0xda, 0x01}, /* i2c_mipi_pll_en - 1'b1 */
320 {ADV748X_PAGE_TXA, 0xc1, 0x3b}, /* ADI Required Write */
321
322 {ADV748X_PAGE_EOR, 0xff, 0xff} /* End of register table */
323};
324
325static const struct adv748x_reg_value adv748x_power_up_txb_1lane[] = {
326
327 {ADV748X_PAGE_TXB, 0x00, 0x81}, /* Enable 1-lane MIPI */
328 {ADV748X_PAGE_TXB, 0x00, 0xa1}, /* Set Auto DPHY Timing */
329
330 {ADV748X_PAGE_TXB, 0x31, 0x82}, /* ADI Required Write */
331 {ADV748X_PAGE_TXB, 0x1e, 0x40}, /* ADI Required Write */
332 {ADV748X_PAGE_TXB, 0xda, 0x01}, /* i2c_mipi_pll_en - 1'b1 */
333 {ADV748X_PAGE_WAIT, 0x00, 0x02},/* delay 2 */
334 {ADV748X_PAGE_TXB, 0x00, 0x21 },/* Power-up CSI-TX */
335 {ADV748X_PAGE_WAIT, 0x00, 0x01},/* delay 1 */
336 {ADV748X_PAGE_TXB, 0xc1, 0x2b}, /* ADI Required Write */
337 {ADV748X_PAGE_WAIT, 0x00, 0x01},/* delay 1 */
338 {ADV748X_PAGE_TXB, 0x31, 0x80}, /* ADI Required Write */
339
340 {ADV748X_PAGE_EOR, 0xff, 0xff} /* End of register table */
341};
342
343static const struct adv748x_reg_value adv748x_power_down_txb_1lane[] = {
344
345 {ADV748X_PAGE_TXB, 0x31, 0x82}, /* ADI Required Write */
346 {ADV748X_PAGE_TXB, 0x1e, 0x00}, /* ADI Required Write */
347 {ADV748X_PAGE_TXB, 0x00, 0x81}, /* Enable 4-lane MIPI */
348 {ADV748X_PAGE_TXB, 0xda, 0x01}, /* i2c_mipi_pll_en - 1'b1 */
349 {ADV748X_PAGE_TXB, 0xc1, 0x3b}, /* ADI Required Write */
350
351 {ADV748X_PAGE_EOR, 0xff, 0xff} /* End of register table */
352};
353
354int adv748x_txa_power(struct adv748x_state *state, bool on)
355{
356 int val;
357
358 val = txa_read(state, ADV748X_CSI_FS_AS_LS);
359 if (val < 0)
360 return val;
361
362 /*
363 * This test against BIT(6) is not documented by the datasheet, but was
364 * specified in the downstream driver.
365 * Track with a WARN_ONCE to determine if it is ever set by HW.
366 */
367 WARN_ONCE((on && val & ADV748X_CSI_FS_AS_LS_UNKNOWN),
368 "Enabling with unknown bit set");
369
370 if (on)
371 return adv748x_write_regs(state, adv748x_power_up_txa_4lane);
372
373 return adv748x_write_regs(state, adv748x_power_down_txa_4lane);
374}
375
376int adv748x_txb_power(struct adv748x_state *state, bool on)
377{
378 int val;
379
380 val = txb_read(state, ADV748X_CSI_FS_AS_LS);
381 if (val < 0)
382 return val;
383
384 /*
385 * This test against BIT(6) is not documented by the datasheet, but was
386 * specified in the downstream driver.
387 * Track with a WARN_ONCE to determine if it is ever set by HW.
388 */
389 WARN_ONCE((on && val & ADV748X_CSI_FS_AS_LS_UNKNOWN),
390 "Enabling with unknown bit set");
391
392 if (on)
393 return adv748x_write_regs(state, adv748x_power_up_txb_1lane);
394
395 return adv748x_write_regs(state, adv748x_power_down_txb_1lane);
396}
397
398/* -----------------------------------------------------------------------------
399 * Media Operations
400 */
401
402static const struct media_entity_operations adv748x_media_ops = {
403 .link_validate = v4l2_subdev_link_validate,
404};
405
406/* -----------------------------------------------------------------------------
407 * HW setup
408 */
409
410static const struct adv748x_reg_value adv748x_sw_reset[] = {
411
412 {ADV748X_PAGE_IO, 0xff, 0xff}, /* SW reset */
413 {ADV748X_PAGE_WAIT, 0x00, 0x05},/* delay 5 */
414 {ADV748X_PAGE_IO, 0x01, 0x76}, /* ADI Required Write */
415 {ADV748X_PAGE_IO, 0xf2, 0x01}, /* Enable I2C Read Auto-Increment */
416 {ADV748X_PAGE_EOR, 0xff, 0xff} /* End of register table */
417};
418
419static const struct adv748x_reg_value adv748x_set_slave_address[] = {
420 {ADV748X_PAGE_IO, 0xf3, ADV748X_I2C_DPLL << 1},
421 {ADV748X_PAGE_IO, 0xf4, ADV748X_I2C_CP << 1},
422 {ADV748X_PAGE_IO, 0xf5, ADV748X_I2C_HDMI << 1},
423 {ADV748X_PAGE_IO, 0xf6, ADV748X_I2C_EDID << 1},
424 {ADV748X_PAGE_IO, 0xf7, ADV748X_I2C_REPEATER << 1},
425 {ADV748X_PAGE_IO, 0xf8, ADV748X_I2C_INFOFRAME << 1},
426 {ADV748X_PAGE_IO, 0xfa, ADV748X_I2C_CEC << 1},
427 {ADV748X_PAGE_IO, 0xfb, ADV748X_I2C_SDP << 1},
428 {ADV748X_PAGE_IO, 0xfc, ADV748X_I2C_TXB << 1},
429 {ADV748X_PAGE_IO, 0xfd, ADV748X_I2C_TXA << 1},
430 {ADV748X_PAGE_EOR, 0xff, 0xff} /* End of register table */
431};
432
433/* Supported Formats For Script Below */
434/* - 01-29 HDMI to MIPI TxA CSI 4-Lane - RGB888: */
435static const struct adv748x_reg_value adv748x_init_txa_4lane[] = {
436 /* Disable chip powerdown & Enable HDMI Rx block */
437 {ADV748X_PAGE_IO, 0x00, 0x40},
438
439 {ADV748X_PAGE_REPEATER, 0x40, 0x83}, /* Enable HDCP 1.1 */
440
441 {ADV748X_PAGE_HDMI, 0x00, 0x08},/* Foreground Channel = A */
442 {ADV748X_PAGE_HDMI, 0x98, 0xff},/* ADI Required Write */
443 {ADV748X_PAGE_HDMI, 0x99, 0xa3},/* ADI Required Write */
444 {ADV748X_PAGE_HDMI, 0x9a, 0x00},/* ADI Required Write */
445 {ADV748X_PAGE_HDMI, 0x9b, 0x0a},/* ADI Required Write */
446 {ADV748X_PAGE_HDMI, 0x9d, 0x40},/* ADI Required Write */
447 {ADV748X_PAGE_HDMI, 0xcb, 0x09},/* ADI Required Write */
448 {ADV748X_PAGE_HDMI, 0x3d, 0x10},/* ADI Required Write */
449 {ADV748X_PAGE_HDMI, 0x3e, 0x7b},/* ADI Required Write */
450 {ADV748X_PAGE_HDMI, 0x3f, 0x5e},/* ADI Required Write */
451 {ADV748X_PAGE_HDMI, 0x4e, 0xfe},/* ADI Required Write */
452 {ADV748X_PAGE_HDMI, 0x4f, 0x18},/* ADI Required Write */
453 {ADV748X_PAGE_HDMI, 0x57, 0xa3},/* ADI Required Write */
454 {ADV748X_PAGE_HDMI, 0x58, 0x04},/* ADI Required Write */
455 {ADV748X_PAGE_HDMI, 0x85, 0x10},/* ADI Required Write */
456
457 {ADV748X_PAGE_HDMI, 0x83, 0x00},/* Enable All Terminations */
458 {ADV748X_PAGE_HDMI, 0xa3, 0x01},/* ADI Required Write */
459 {ADV748X_PAGE_HDMI, 0xbe, 0x00},/* ADI Required Write */
460
461 {ADV748X_PAGE_HDMI, 0x6c, 0x01},/* HPA Manual Enable */
462 {ADV748X_PAGE_HDMI, 0xf8, 0x01},/* HPA Asserted */
463 {ADV748X_PAGE_HDMI, 0x0f, 0x00},/* Audio Mute Speed Set to Fastest */
464 /* (Smallest Step Size) */
465
466 {ADV748X_PAGE_IO, 0x04, 0x02}, /* RGB Out of CP */
467 {ADV748X_PAGE_IO, 0x12, 0xf0}, /* CSC Depends on ip Packets, SDR 444 */
468 {ADV748X_PAGE_IO, 0x17, 0x80}, /* Luma & Chroma can reach 254d */
469 {ADV748X_PAGE_IO, 0x03, 0x86}, /* CP-Insert_AV_Code */
470
471 {ADV748X_PAGE_CP, 0x7c, 0x00}, /* ADI Required Write */
472
473 {ADV748X_PAGE_IO, 0x0c, 0xe0}, /* Enable LLC_DLL & Double LLC Timing */
474 {ADV748X_PAGE_IO, 0x0e, 0xdd}, /* LLC/PIX/SPI PINS TRISTATED AUD */
475 /* Outputs Enabled */
476 {ADV748X_PAGE_IO, 0x10, 0xa0}, /* Enable 4-lane CSI Tx & Pixel Port */
477
478 {ADV748X_PAGE_TXA, 0x00, 0x84}, /* Enable 4-lane MIPI */
479 {ADV748X_PAGE_TXA, 0x00, 0xa4}, /* Set Auto DPHY Timing */
480 {ADV748X_PAGE_TXA, 0xdb, 0x10}, /* ADI Required Write */
481 {ADV748X_PAGE_TXA, 0xd6, 0x07}, /* ADI Required Write */
482 {ADV748X_PAGE_TXA, 0xc4, 0x0a}, /* ADI Required Write */
483 {ADV748X_PAGE_TXA, 0x71, 0x33}, /* ADI Required Write */
484 {ADV748X_PAGE_TXA, 0x72, 0x11}, /* ADI Required Write */
485 {ADV748X_PAGE_TXA, 0xf0, 0x00}, /* i2c_dphy_pwdn - 1'b0 */
486
487 {ADV748X_PAGE_TXA, 0x31, 0x82}, /* ADI Required Write */
488 {ADV748X_PAGE_TXA, 0x1e, 0x40}, /* ADI Required Write */
489 {ADV748X_PAGE_TXA, 0xda, 0x01}, /* i2c_mipi_pll_en - 1'b1 */
490 {ADV748X_PAGE_WAIT, 0x00, 0x02},/* delay 2 */
491 {ADV748X_PAGE_TXA, 0x00, 0x24 },/* Power-up CSI-TX */
492 {ADV748X_PAGE_WAIT, 0x00, 0x01},/* delay 1 */
493 {ADV748X_PAGE_TXA, 0xc1, 0x2b}, /* ADI Required Write */
494 {ADV748X_PAGE_WAIT, 0x00, 0x01},/* delay 1 */
495 {ADV748X_PAGE_TXA, 0x31, 0x80}, /* ADI Required Write */
496
497 {ADV748X_PAGE_EOR, 0xff, 0xff} /* End of register table */
498};
499
500/* 02-01 Analog CVBS to MIPI TX-B CSI 1-Lane - */
501/* Autodetect CVBS Single Ended In Ain 1 - MIPI Out */
502static const struct adv748x_reg_value adv748x_init_txb_1lane[] = {
503
504 {ADV748X_PAGE_IO, 0x00, 0x30}, /* Disable chip powerdown Rx */
505 {ADV748X_PAGE_IO, 0xf2, 0x01}, /* Enable I2C Read Auto-Increment */
506
507 {ADV748X_PAGE_IO, 0x0e, 0xff}, /* LLC/PIX/AUD/SPI PINS TRISTATED */
508
509 {ADV748X_PAGE_SDP, 0x0f, 0x00}, /* Exit Power Down Mode */
510 {ADV748X_PAGE_SDP, 0x52, 0xcd}, /* ADI Required Write */
511
512 {ADV748X_PAGE_SDP, 0x0e, 0x80}, /* ADI Required Write */
513 {ADV748X_PAGE_SDP, 0x9c, 0x00}, /* ADI Required Write */
514 {ADV748X_PAGE_SDP, 0x9c, 0xff}, /* ADI Required Write */
515 {ADV748X_PAGE_SDP, 0x0e, 0x00}, /* ADI Required Write */
516
517 /* ADI recommended writes for improved video quality */
518 {ADV748X_PAGE_SDP, 0x80, 0x51}, /* ADI Required Write */
519 {ADV748X_PAGE_SDP, 0x81, 0x51}, /* ADI Required Write */
520 {ADV748X_PAGE_SDP, 0x82, 0x68}, /* ADI Required Write */
521
522 {ADV748X_PAGE_SDP, 0x03, 0x42}, /* Tri-S Output , PwrDwn 656 pads */
523 {ADV748X_PAGE_SDP, 0x04, 0xb5}, /* ITU-R BT.656-4 compatible */
524 {ADV748X_PAGE_SDP, 0x13, 0x00}, /* ADI Required Write */
525
526 {ADV748X_PAGE_SDP, 0x17, 0x41}, /* Select SH1 */
527 {ADV748X_PAGE_SDP, 0x31, 0x12}, /* ADI Required Write */
528 {ADV748X_PAGE_SDP, 0xe6, 0x4f}, /* V bit end pos manually in NTSC */
529
530 /* Enable 1-Lane MIPI Tx, */
531 /* enable pixel output and route SD through Pixel port */
532 {ADV748X_PAGE_IO, 0x10, 0x70},
533
534 {ADV748X_PAGE_TXB, 0x00, 0x81}, /* Enable 1-lane MIPI */
535 {ADV748X_PAGE_TXB, 0x00, 0xa1}, /* Set Auto DPHY Timing */
536 {ADV748X_PAGE_TXB, 0xd2, 0x40}, /* ADI Required Write */
537 {ADV748X_PAGE_TXB, 0xc4, 0x0a}, /* ADI Required Write */
538 {ADV748X_PAGE_TXB, 0x71, 0x33}, /* ADI Required Write */
539 {ADV748X_PAGE_TXB, 0x72, 0x11}, /* ADI Required Write */
540 {ADV748X_PAGE_TXB, 0xf0, 0x00}, /* i2c_dphy_pwdn - 1'b0 */
541 {ADV748X_PAGE_TXB, 0x31, 0x82}, /* ADI Required Write */
542 {ADV748X_PAGE_TXB, 0x1e, 0x40}, /* ADI Required Write */
543 {ADV748X_PAGE_TXB, 0xda, 0x01}, /* i2c_mipi_pll_en - 1'b1 */
544
545 {ADV748X_PAGE_WAIT, 0x00, 0x02},/* delay 2 */
546 {ADV748X_PAGE_TXB, 0x00, 0x21 },/* Power-up CSI-TX */
547 {ADV748X_PAGE_WAIT, 0x00, 0x01},/* delay 1 */
548 {ADV748X_PAGE_TXB, 0xc1, 0x2b}, /* ADI Required Write */
549 {ADV748X_PAGE_WAIT, 0x00, 0x01},/* delay 1 */
550 {ADV748X_PAGE_TXB, 0x31, 0x80}, /* ADI Required Write */
551
552 {ADV748X_PAGE_EOR, 0xff, 0xff} /* End of register table */
553};
554
555static int adv748x_reset(struct adv748x_state *state)
556{
557 int ret;
558
559 ret = adv748x_write_regs(state, adv748x_sw_reset);
560 if (ret < 0)
561 return ret;
562
563 ret = adv748x_write_regs(state, adv748x_set_slave_address);
564 if (ret < 0)
565 return ret;
566
567 /* Init and power down TXA */
568 ret = adv748x_write_regs(state, adv748x_init_txa_4lane);
569 if (ret)
570 return ret;
571
572 adv748x_txa_power(state, 0);
573
574 /* Init and power down TXB */
575 ret = adv748x_write_regs(state, adv748x_init_txb_1lane);
576 if (ret)
577 return ret;
578
579 adv748x_txb_power(state, 0);
580
581 /* Disable chip powerdown & Enable HDMI Rx block */
582 io_write(state, ADV748X_IO_PD, ADV748X_IO_PD_RX_EN);
583
584 /* Enable 4-lane CSI Tx & Pixel Port */
585 io_write(state, ADV748X_IO_10, ADV748X_IO_10_CSI4_EN |
586 ADV748X_IO_10_CSI1_EN |
587 ADV748X_IO_10_PIX_OUT_EN);
588
589 /* Use vid_std and v_freq as freerun resolution for CP */
590 cp_clrset(state, ADV748X_CP_CLMP_POS, ADV748X_CP_CLMP_POS_DIS_AUTO,
591 ADV748X_CP_CLMP_POS_DIS_AUTO);
592
593 return 0;
594}
595
596static int adv748x_identify_chip(struct adv748x_state *state)
597{
598 int msb, lsb;
599
600 lsb = io_read(state, ADV748X_IO_CHIP_REV_ID_1);
601 msb = io_read(state, ADV748X_IO_CHIP_REV_ID_2);
602
603 if (lsb < 0 || msb < 0) {
604 adv_err(state, "Failed to read chip revision\n");
605 return -EIO;
606 }
607
608 adv_info(state, "chip found @ 0x%02x revision %02x%02x\n",
609 state->client->addr << 1, lsb, msb);
610
611 return 0;
612}
613
614/* -----------------------------------------------------------------------------
615 * i2c driver
616 */
617
618void adv748x_subdev_init(struct v4l2_subdev *sd, struct adv748x_state *state,
619 const struct v4l2_subdev_ops *ops, u32 function,
620 const char *ident)
621{
622 v4l2_subdev_init(sd, ops);
623 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
624
625 /* the owner is the same as the i2c_client's driver owner */
626 sd->owner = state->dev->driver->owner;
627 sd->dev = state->dev;
628
629 v4l2_set_subdevdata(sd, state);
630
631 /* initialize name */
632 snprintf(sd->name, sizeof(sd->name), "%s %d-%04x %s",
633 state->dev->driver->name,
634 i2c_adapter_id(state->client->adapter),
635 state->client->addr, ident);
636
637 sd->entity.function = function;
638 sd->entity.ops = &adv748x_media_ops;
639}
640
641static int adv748x_parse_dt(struct adv748x_state *state)
642{
643 struct device_node *ep_np = NULL;
644 struct of_endpoint ep;
645 bool found = false;
646
647 for_each_endpoint_of_node(state->dev->of_node, ep_np) {
648 of_graph_parse_endpoint(ep_np, &ep);
649 adv_info(state, "Endpoint %s on port %d",
650 of_node_full_name(ep.local_node),
651 ep.port);
652
653 if (ep.port >= ADV748X_PORT_MAX) {
654 adv_err(state, "Invalid endpoint %s on port %d",
655 of_node_full_name(ep.local_node),
656 ep.port);
657
658 continue;
659 }
660
661 if (state->endpoints[ep.port]) {
662 adv_err(state,
663 "Multiple port endpoints are not supported");
664 continue;
665 }
666
667 of_node_get(ep_np);
668 state->endpoints[ep.port] = ep_np;
669
670 found = true;
671 }
672
673 return found ? 0 : -ENODEV;
674}
675
676static void adv748x_dt_cleanup(struct adv748x_state *state)
677{
678 unsigned int i;
679
680 for (i = 0; i < ADV748X_PORT_MAX; i++)
681 of_node_put(state->endpoints[i]);
682}
683
684static int adv748x_probe(struct i2c_client *client,
685 const struct i2c_device_id *id)
686{
687 struct adv748x_state *state;
688 int ret;
689
690 /* Check if the adapter supports the needed features */
691 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
692 return -EIO;
693
694 state = kzalloc(sizeof(struct adv748x_state), GFP_KERNEL);
695 if (!state)
696 return -ENOMEM;
697
698 mutex_init(&state->mutex);
699
700 state->dev = &client->dev;
701 state->client = client;
702 state->i2c_clients[ADV748X_PAGE_IO] = client;
703 i2c_set_clientdata(client, state);
704
705 /* Discover and process ports declared by the Device tree endpoints */
706 ret = adv748x_parse_dt(state);
707 if (ret) {
708 adv_err(state, "Failed to parse device tree");
709 goto err_free_mutex;
710 }
711
712 /* Configure IO Regmap region */
713 ret = adv748x_configure_regmap(state, ADV748X_PAGE_IO);
714 if (ret) {
715 adv_err(state, "Error configuring IO regmap region");
716 goto err_cleanup_dt;
717 }
718
719 ret = adv748x_identify_chip(state);
720 if (ret) {
721 adv_err(state, "Failed to identify chip");
722 goto err_cleanup_clients;
723 }
724
725 /* Configure remaining pages as I2C clients with regmap access */
726 ret = adv748x_initialise_clients(state);
727 if (ret) {
728 adv_err(state, "Failed to setup client regmap pages");
729 goto err_cleanup_clients;
730 }
731
732 /* SW reset ADV748X to its default values */
733 ret = adv748x_reset(state);
734 if (ret) {
735 adv_err(state, "Failed to reset hardware");
736 goto err_cleanup_clients;
737 }
738
739 /* Initialise HDMI */
740 ret = adv748x_hdmi_init(&state->hdmi);
741 if (ret) {
742 adv_err(state, "Failed to probe HDMI");
743 goto err_cleanup_clients;
744 }
745
746 /* Initialise AFE */
747 ret = adv748x_afe_init(&state->afe);
748 if (ret) {
749 adv_err(state, "Failed to probe AFE");
750 goto err_cleanup_hdmi;
751 }
752
753 /* Initialise TXA */
754 ret = adv748x_csi2_init(state, &state->txa);
755 if (ret) {
756 adv_err(state, "Failed to probe TXA");
757 goto err_cleanup_afe;
758 }
759
760 /* Initialise TXB */
761 ret = adv748x_csi2_init(state, &state->txb);
762 if (ret) {
763 adv_err(state, "Failed to probe TXB");
764 goto err_cleanup_txa;
765 }
766
767 return 0;
768
769err_cleanup_txa:
770 adv748x_csi2_cleanup(&state->txa);
771err_cleanup_afe:
772 adv748x_afe_cleanup(&state->afe);
773err_cleanup_hdmi:
774 adv748x_hdmi_cleanup(&state->hdmi);
775err_cleanup_clients:
776 adv748x_unregister_clients(state);
777err_cleanup_dt:
778 adv748x_dt_cleanup(state);
779err_free_mutex:
780 mutex_destroy(&state->mutex);
781 kfree(state);
782
783 return ret;
784}
785
786static int adv748x_remove(struct i2c_client *client)
787{
788 struct adv748x_state *state = i2c_get_clientdata(client);
789
790 adv748x_afe_cleanup(&state->afe);
791 adv748x_hdmi_cleanup(&state->hdmi);
792
793 adv748x_csi2_cleanup(&state->txa);
794 adv748x_csi2_cleanup(&state->txb);
795
796 adv748x_unregister_clients(state);
797 adv748x_dt_cleanup(state);
798 mutex_destroy(&state->mutex);
799
800 kfree(state);
801
802 return 0;
803}
804
805static const struct i2c_device_id adv748x_id[] = {
806 { "adv7481", 0 },
807 { "adv7482", 0 },
808 { },
809};
810MODULE_DEVICE_TABLE(i2c, adv748x_id);
811
812static const struct of_device_id adv748x_of_table[] = {
813 { .compatible = "adi,adv7481", },
814 { .compatible = "adi,adv7482", },
815 { }
816};
817MODULE_DEVICE_TABLE(of, adv748x_of_table);
818
819static struct i2c_driver adv748x_driver = {
820 .driver = {
821 .name = "adv748x",
822 .of_match_table = adv748x_of_table,
823 },
824 .probe = adv748x_probe,
825 .remove = adv748x_remove,
826 .id_table = adv748x_id,
827};
828
829module_i2c_driver(adv748x_driver);
830
831MODULE_AUTHOR("Kieran Bingham <kieran.bingham@ideasonboard.com>");
832MODULE_DESCRIPTION("ADV748X video decoder");
833MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c
new file mode 100644
index 000000000000..979825d4a419
--- /dev/null
+++ b/drivers/media/i2c/adv748x/adv748x-csi2.c
@@ -0,0 +1,326 @@
1/*
2 * Driver for Analog Devices ADV748X CSI-2 Transmitter
3 *
4 * Copyright (C) 2017 Renesas Electronics Corp.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/module.h>
13#include <linux/mutex.h>
14
15#include <media/v4l2-ctrls.h>
16#include <media/v4l2-device.h>
17#include <media/v4l2-ioctl.h>
18
19#include "adv748x.h"
20
21static bool is_txa(struct adv748x_csi2 *tx)
22{
23 return tx == &tx->state->txa;
24}
25
26static int adv748x_csi2_set_virtual_channel(struct adv748x_csi2 *tx,
27 unsigned int vc)
28{
29 return tx_write(tx, ADV748X_CSI_VC_REF, vc << ADV748X_CSI_VC_REF_SHIFT);
30}
31
32/**
33 * adv748x_csi2_register_link : Register and link internal entities
34 *
35 * @tx: CSI2 private entity
36 * @v4l2_dev: Video registration device
37 * @src: Source subdevice to establish link
38 * @src_pad: Pad number of source to link to this @tx
39 *
40 * Ensure that the subdevice is registered against the v4l2_device, and link the
41 * source pad to the sink pad of the CSI2 bus entity.
42 */
43static int adv748x_csi2_register_link(struct adv748x_csi2 *tx,
44 struct v4l2_device *v4l2_dev,
45 struct v4l2_subdev *src,
46 unsigned int src_pad)
47{
48 int enabled = MEDIA_LNK_FL_ENABLED;
49 int ret;
50
51 /*
52 * Dynamic linking of the AFE is not supported.
53 * Register the links as immutable.
54 */
55 enabled |= MEDIA_LNK_FL_IMMUTABLE;
56
57 if (!src->v4l2_dev) {
58 ret = v4l2_device_register_subdev(v4l2_dev, src);
59 if (ret)
60 return ret;
61 }
62
63 return media_create_pad_link(&src->entity, src_pad,
64 &tx->sd.entity, ADV748X_CSI2_SINK,
65 enabled);
66}
67
68/* -----------------------------------------------------------------------------
69 * v4l2_subdev_internal_ops
70 *
71 * We use the internal registered operation to be able to ensure that our
72 * incremental subdevices (not connected in the forward path) can be registered
73 * against the resulting video path and media device.
74 */
75
76static int adv748x_csi2_registered(struct v4l2_subdev *sd)
77{
78 struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
79 struct adv748x_state *state = tx->state;
80
81 adv_dbg(state, "Registered %s (%s)", is_txa(tx) ? "TXA":"TXB",
82 sd->name);
83
84 /*
85 * The adv748x hardware allows the AFE to route through the TXA, however
86 * this is not currently supported in this driver.
87 *
88 * Link HDMI->TXA, and AFE->TXB directly.
89 */
90 if (is_txa(tx)) {
91 return adv748x_csi2_register_link(tx, sd->v4l2_dev,
92 &state->hdmi.sd,
93 ADV748X_HDMI_SOURCE);
94 } else {
95 return adv748x_csi2_register_link(tx, sd->v4l2_dev,
96 &state->afe.sd,
97 ADV748X_AFE_SOURCE);
98 }
99}
100
101static const struct v4l2_subdev_internal_ops adv748x_csi2_internal_ops = {
102 .registered = adv748x_csi2_registered,
103};
104
105/* -----------------------------------------------------------------------------
106 * v4l2_subdev_video_ops
107 */
108
109static int adv748x_csi2_s_stream(struct v4l2_subdev *sd, int enable)
110{
111 struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
112 struct v4l2_subdev *src;
113
114 src = adv748x_get_remote_sd(&tx->pads[ADV748X_CSI2_SINK]);
115 if (!src)
116 return -EPIPE;
117
118 return v4l2_subdev_call(src, video, s_stream, enable);
119}
120
121static const struct v4l2_subdev_video_ops adv748x_csi2_video_ops = {
122 .s_stream = adv748x_csi2_s_stream,
123};
124
125/* -----------------------------------------------------------------------------
126 * v4l2_subdev_pad_ops
127 *
128 * The CSI2 bus pads are ignorant to the data sizes or formats.
129 * But we must support setting the pad formats for format propagation.
130 */
131
132static struct v4l2_mbus_framefmt *
133adv748x_csi2_get_pad_format(struct v4l2_subdev *sd,
134 struct v4l2_subdev_pad_config *cfg,
135 unsigned int pad, u32 which)
136{
137 struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
138
139 if (which == V4L2_SUBDEV_FORMAT_TRY)
140 return v4l2_subdev_get_try_format(sd, cfg, pad);
141
142 return &tx->format;
143}
144
145static int adv748x_csi2_get_format(struct v4l2_subdev *sd,
146 struct v4l2_subdev_pad_config *cfg,
147 struct v4l2_subdev_format *sdformat)
148{
149 struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
150 struct adv748x_state *state = tx->state;
151 struct v4l2_mbus_framefmt *mbusformat;
152
153 mbusformat = adv748x_csi2_get_pad_format(sd, cfg, sdformat->pad,
154 sdformat->which);
155 if (!mbusformat)
156 return -EINVAL;
157
158 mutex_lock(&state->mutex);
159
160 sdformat->format = *mbusformat;
161
162 mutex_unlock(&state->mutex);
163
164 return 0;
165}
166
167static int adv748x_csi2_set_format(struct v4l2_subdev *sd,
168 struct v4l2_subdev_pad_config *cfg,
169 struct v4l2_subdev_format *sdformat)
170{
171 struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
172 struct adv748x_state *state = tx->state;
173 struct v4l2_mbus_framefmt *mbusformat;
174 int ret = 0;
175
176 mbusformat = adv748x_csi2_get_pad_format(sd, cfg, sdformat->pad,
177 sdformat->which);
178 if (!mbusformat)
179 return -EINVAL;
180
181 mutex_lock(&state->mutex);
182
183 if (sdformat->pad == ADV748X_CSI2_SOURCE) {
184 const struct v4l2_mbus_framefmt *sink_fmt;
185
186 sink_fmt = adv748x_csi2_get_pad_format(sd, cfg,
187 ADV748X_CSI2_SINK,
188 sdformat->which);
189
190 if (!sink_fmt) {
191 ret = -EINVAL;
192 goto unlock;
193 }
194
195 sdformat->format = *sink_fmt;
196 }
197
198 *mbusformat = sdformat->format;
199
200unlock:
201 mutex_unlock(&state->mutex);
202
203 return ret;
204}
205
206static const struct v4l2_subdev_pad_ops adv748x_csi2_pad_ops = {
207 .get_fmt = adv748x_csi2_get_format,
208 .set_fmt = adv748x_csi2_set_format,
209};
210
211/* -----------------------------------------------------------------------------
212 * v4l2_subdev_ops
213 */
214
215static const struct v4l2_subdev_ops adv748x_csi2_ops = {
216 .video = &adv748x_csi2_video_ops,
217 .pad = &adv748x_csi2_pad_ops,
218};
219
220/* -----------------------------------------------------------------------------
221 * Subdev module and controls
222 */
223
224int adv748x_csi2_set_pixelrate(struct v4l2_subdev *sd, s64 rate)
225{
226 struct v4l2_ctrl *ctrl;
227
228 ctrl = v4l2_ctrl_find(sd->ctrl_handler, V4L2_CID_PIXEL_RATE);
229 if (!ctrl)
230 return -EINVAL;
231
232 return v4l2_ctrl_s_ctrl_int64(ctrl, rate);
233}
234
235static int adv748x_csi2_s_ctrl(struct v4l2_ctrl *ctrl)
236{
237 switch (ctrl->id) {
238 case V4L2_CID_PIXEL_RATE:
239 return 0;
240 default:
241 return -EINVAL;
242 }
243}
244
245static const struct v4l2_ctrl_ops adv748x_csi2_ctrl_ops = {
246 .s_ctrl = adv748x_csi2_s_ctrl,
247};
248
249static int adv748x_csi2_init_controls(struct adv748x_csi2 *tx)
250{
251
252 v4l2_ctrl_handler_init(&tx->ctrl_hdl, 1);
253
254 v4l2_ctrl_new_std(&tx->ctrl_hdl, &adv748x_csi2_ctrl_ops,
255 V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, 1);
256
257 tx->sd.ctrl_handler = &tx->ctrl_hdl;
258 if (tx->ctrl_hdl.error) {
259 v4l2_ctrl_handler_free(&tx->ctrl_hdl);
260 return tx->ctrl_hdl.error;
261 }
262
263 return v4l2_ctrl_handler_setup(&tx->ctrl_hdl);
264}
265
266int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx)
267{
268 struct device_node *ep;
269 int ret;
270
271 /* We can not use container_of to get back to the state with two TXs */
272 tx->state = state;
273 tx->page = is_txa(tx) ? ADV748X_PAGE_TXA : ADV748X_PAGE_TXB;
274
275 ep = state->endpoints[is_txa(tx) ? ADV748X_PORT_TXA : ADV748X_PORT_TXB];
276 if (!ep) {
277 adv_err(state, "No endpoint found for %s\n",
278 is_txa(tx) ? "txa" : "txb");
279 return -ENODEV;
280 }
281
282 /* Initialise the virtual channel */
283 adv748x_csi2_set_virtual_channel(tx, 0);
284
285 adv748x_subdev_init(&tx->sd, state, &adv748x_csi2_ops,
286 MEDIA_ENT_F_UNKNOWN,
287 is_txa(tx) ? "txa" : "txb");
288
289 /* Ensure that matching is based upon the endpoint fwnodes */
290 tx->sd.fwnode = of_fwnode_handle(ep);
291
292 /* Register internal ops for incremental subdev registration */
293 tx->sd.internal_ops = &adv748x_csi2_internal_ops;
294
295 tx->pads[ADV748X_CSI2_SINK].flags = MEDIA_PAD_FL_SINK;
296 tx->pads[ADV748X_CSI2_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
297
298 ret = media_entity_pads_init(&tx->sd.entity, ADV748X_CSI2_NR_PADS,
299 tx->pads);
300 if (ret)
301 return ret;
302
303 ret = adv748x_csi2_init_controls(tx);
304 if (ret)
305 goto err_free_media;
306
307 ret = v4l2_async_register_subdev(&tx->sd);
308 if (ret)
309 goto err_free_ctrl;
310
311 return 0;
312
313err_free_ctrl:
314 v4l2_ctrl_handler_free(&tx->ctrl_hdl);
315err_free_media:
316 media_entity_cleanup(&tx->sd.entity);
317
318 return ret;
319}
320
321void adv748x_csi2_cleanup(struct adv748x_csi2 *tx)
322{
323 v4l2_async_unregister_subdev(&tx->sd);
324 media_entity_cleanup(&tx->sd.entity);
325 v4l2_ctrl_handler_free(&tx->ctrl_hdl);
326}
diff --git a/drivers/media/i2c/adv748x/adv748x-hdmi.c b/drivers/media/i2c/adv748x/adv748x-hdmi.c
new file mode 100644
index 000000000000..4da4253553fc
--- /dev/null
+++ b/drivers/media/i2c/adv748x/adv748x-hdmi.c
@@ -0,0 +1,768 @@
1/*
2 * Driver for Analog Devices ADV748X HDMI receiver and Component Processor (CP)
3 *
4 * Copyright (C) 2017 Renesas Electronics Corp.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/module.h>
13#include <linux/mutex.h>
14
15#include <media/v4l2-ctrls.h>
16#include <media/v4l2-device.h>
17#include <media/v4l2-dv-timings.h>
18#include <media/v4l2-ioctl.h>
19
20#include <uapi/linux/v4l2-dv-timings.h>
21
22#include "adv748x.h"
23
24/* -----------------------------------------------------------------------------
25 * HDMI and CP
26 */
27
28#define ADV748X_HDMI_MIN_WIDTH 640
29#define ADV748X_HDMI_MAX_WIDTH 1920
30#define ADV748X_HDMI_MIN_HEIGHT 480
31#define ADV748X_HDMI_MAX_HEIGHT 1200
32
33/* V4L2_DV_BT_CEA_720X480I59_94 - 0.5 MHz */
34#define ADV748X_HDMI_MIN_PIXELCLOCK 13000000
35/* V4L2_DV_BT_DMT_1600X1200P60 */
36#define ADV748X_HDMI_MAX_PIXELCLOCK 162000000
37
38static const struct v4l2_dv_timings_cap adv748x_hdmi_timings_cap = {
39 .type = V4L2_DV_BT_656_1120,
40 /* keep this initialization for compatibility with GCC < 4.4.6 */
41 .reserved = { 0 },
42
43 V4L2_INIT_BT_TIMINGS(ADV748X_HDMI_MIN_WIDTH, ADV748X_HDMI_MAX_WIDTH,
44 ADV748X_HDMI_MIN_HEIGHT, ADV748X_HDMI_MAX_HEIGHT,
45 ADV748X_HDMI_MIN_PIXELCLOCK,
46 ADV748X_HDMI_MAX_PIXELCLOCK,
47 V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT,
48 V4L2_DV_BT_CAP_PROGRESSIVE)
49};
50
51struct adv748x_hdmi_video_standards {
52 struct v4l2_dv_timings timings;
53 u8 vid_std;
54 u8 v_freq;
55};
56
57static const struct adv748x_hdmi_video_standards
58adv748x_hdmi_video_standards[] = {
59 { V4L2_DV_BT_CEA_720X480P59_94, 0x4a, 0x00 },
60 { V4L2_DV_BT_CEA_720X576P50, 0x4b, 0x00 },
61 { V4L2_DV_BT_CEA_1280X720P60, 0x53, 0x00 },
62 { V4L2_DV_BT_CEA_1280X720P50, 0x53, 0x01 },
63 { V4L2_DV_BT_CEA_1280X720P30, 0x53, 0x02 },
64 { V4L2_DV_BT_CEA_1280X720P25, 0x53, 0x03 },
65 { V4L2_DV_BT_CEA_1280X720P24, 0x53, 0x04 },
66 { V4L2_DV_BT_CEA_1920X1080P60, 0x5e, 0x00 },
67 { V4L2_DV_BT_CEA_1920X1080P50, 0x5e, 0x01 },
68 { V4L2_DV_BT_CEA_1920X1080P30, 0x5e, 0x02 },
69 { V4L2_DV_BT_CEA_1920X1080P25, 0x5e, 0x03 },
70 { V4L2_DV_BT_CEA_1920X1080P24, 0x5e, 0x04 },
71 /* SVGA */
72 { V4L2_DV_BT_DMT_800X600P56, 0x80, 0x00 },
73 { V4L2_DV_BT_DMT_800X600P60, 0x81, 0x00 },
74 { V4L2_DV_BT_DMT_800X600P72, 0x82, 0x00 },
75 { V4L2_DV_BT_DMT_800X600P75, 0x83, 0x00 },
76 { V4L2_DV_BT_DMT_800X600P85, 0x84, 0x00 },
77 /* SXGA */
78 { V4L2_DV_BT_DMT_1280X1024P60, 0x85, 0x00 },
79 { V4L2_DV_BT_DMT_1280X1024P75, 0x86, 0x00 },
80 /* VGA */
81 { V4L2_DV_BT_DMT_640X480P60, 0x88, 0x00 },
82 { V4L2_DV_BT_DMT_640X480P72, 0x89, 0x00 },
83 { V4L2_DV_BT_DMT_640X480P75, 0x8a, 0x00 },
84 { V4L2_DV_BT_DMT_640X480P85, 0x8b, 0x00 },
85 /* XGA */
86 { V4L2_DV_BT_DMT_1024X768P60, 0x8c, 0x00 },
87 { V4L2_DV_BT_DMT_1024X768P70, 0x8d, 0x00 },
88 { V4L2_DV_BT_DMT_1024X768P75, 0x8e, 0x00 },
89 { V4L2_DV_BT_DMT_1024X768P85, 0x8f, 0x00 },
90 /* UXGA */
91 { V4L2_DV_BT_DMT_1600X1200P60, 0x96, 0x00 },
92};
93
94static void adv748x_hdmi_fill_format(struct adv748x_hdmi *hdmi,
95 struct v4l2_mbus_framefmt *fmt)
96{
97 memset(fmt, 0, sizeof(*fmt));
98
99 fmt->code = MEDIA_BUS_FMT_RGB888_1X24;
100 fmt->field = hdmi->timings.bt.interlaced ?
101 V4L2_FIELD_ALTERNATE : V4L2_FIELD_NONE;
102
103 /* TODO: The colorspace depends on the AVI InfoFrame contents */
104 fmt->colorspace = V4L2_COLORSPACE_SRGB;
105
106 fmt->width = hdmi->timings.bt.width;
107 fmt->height = hdmi->timings.bt.height;
108}
109
110static void adv748x_fill_optional_dv_timings(struct v4l2_dv_timings *timings)
111{
112 v4l2_find_dv_timings_cap(timings, &adv748x_hdmi_timings_cap,
113 250000, NULL, NULL);
114}
115
116static bool adv748x_hdmi_has_signal(struct adv748x_state *state)
117{
118 int val;
119
120 /* Check that VERT_FILTER and DE_REGEN is locked */
121 val = hdmi_read(state, ADV748X_HDMI_LW1);
122 return (val & ADV748X_HDMI_LW1_VERT_FILTER) &&
123 (val & ADV748X_HDMI_LW1_DE_REGEN);
124}
125
126static int adv748x_hdmi_read_pixelclock(struct adv748x_state *state)
127{
128 int a, b;
129
130 a = hdmi_read(state, ADV748X_HDMI_TMDS_1);
131 b = hdmi_read(state, ADV748X_HDMI_TMDS_2);
132 if (a < 0 || b < 0)
133 return -ENODATA;
134
135 /*
136 * The high 9 bits store TMDS frequency measurement in MHz
137 * The low 7 bits of TMDS_2 store the 7-bit TMDS fractional frequency
138 * measurement in 1/128 MHz
139 */
140 return ((a << 1) | (b >> 7)) * 1000000 + (b & 0x7f) * 1000000 / 128;
141}
142
143/*
144 * adv748x_hdmi_set_de_timings: Adjust horizontal picture offset through DE
145 *
146 * HDMI CP uses a Data Enable synchronisation timing reference
147 *
148 * Vary the leading and trailing edge position of the DE signal output by the CP
149 * core. Values are stored as signed-twos-complement in one-pixel-clock units
150 *
151 * The start and end are shifted equally by the 10-bit shift value.
152 */
153static void adv748x_hdmi_set_de_timings(struct adv748x_state *state, int shift)
154{
155 u8 high, low;
156
157 /* POS_HIGH stores bits 8 and 9 of both the start and end */
158 high = ADV748X_CP_DE_POS_HIGH_SET;
159 high |= (shift & 0x300) >> 8;
160 low = shift & 0xff;
161
162 /* The sequence of the writes is important and must be followed */
163 cp_write(state, ADV748X_CP_DE_POS_HIGH, high);
164 cp_write(state, ADV748X_CP_DE_POS_END_LOW, low);
165
166 high |= (shift & 0x300) >> 6;
167
168 cp_write(state, ADV748X_CP_DE_POS_HIGH, high);
169 cp_write(state, ADV748X_CP_DE_POS_START_LOW, low);
170}
171
172static int adv748x_hdmi_set_video_timings(struct adv748x_state *state,
173 const struct v4l2_dv_timings *timings)
174{
175 const struct adv748x_hdmi_video_standards *stds =
176 adv748x_hdmi_video_standards;
177 unsigned int i;
178
179 for (i = 0; i < ARRAY_SIZE(adv748x_hdmi_video_standards); i++) {
180 if (!v4l2_match_dv_timings(timings, &stds[i].timings, 250000,
181 false))
182 continue;
183 }
184
185 if (i >= ARRAY_SIZE(adv748x_hdmi_video_standards))
186 return -EINVAL;
187
188 /*
189 * When setting cp_vid_std to either 720p, 1080i, or 1080p, the video
190 * will get shifted horizontally to the left in active video mode.
191 * The de_h_start and de_h_end controls are used to centre the picture
192 * correctly
193 */
194 switch (stds[i].vid_std) {
195 case 0x53: /* 720p */
196 adv748x_hdmi_set_de_timings(state, -40);
197 break;
198 case 0x54: /* 1080i */
199 case 0x5e: /* 1080p */
200 adv748x_hdmi_set_de_timings(state, -44);
201 break;
202 default:
203 adv748x_hdmi_set_de_timings(state, 0);
204 break;
205 }
206
207 io_write(state, ADV748X_IO_VID_STD, stds[i].vid_std);
208 io_clrset(state, ADV748X_IO_DATAPATH, ADV748X_IO_DATAPATH_VFREQ_M,
209 stds[i].v_freq << ADV748X_IO_DATAPATH_VFREQ_SHIFT);
210
211 return 0;
212}
213
214/* -----------------------------------------------------------------------------
215 * v4l2_subdev_video_ops
216 */
217
218static int adv748x_hdmi_s_dv_timings(struct v4l2_subdev *sd,
219 struct v4l2_dv_timings *timings)
220{
221 struct adv748x_hdmi *hdmi = adv748x_sd_to_hdmi(sd);
222 struct adv748x_state *state = adv748x_hdmi_to_state(hdmi);
223 int ret;
224
225 if (!timings)
226 return -EINVAL;
227
228 if (v4l2_match_dv_timings(&hdmi->timings, timings, 0, false))
229 return 0;
230
231 if (!v4l2_valid_dv_timings(timings, &adv748x_hdmi_timings_cap,
232 NULL, NULL))
233 return -ERANGE;
234
235 adv748x_fill_optional_dv_timings(timings);
236
237 mutex_lock(&state->mutex);
238
239 ret = adv748x_hdmi_set_video_timings(state, timings);
240 if (ret)
241 goto error;
242
243 hdmi->timings = *timings;
244
245 cp_clrset(state, ADV748X_CP_VID_ADJ_2, ADV748X_CP_VID_ADJ_2_INTERLACED,
246 timings->bt.interlaced ?
247 ADV748X_CP_VID_ADJ_2_INTERLACED : 0);
248
249 mutex_unlock(&state->mutex);
250
251 return 0;
252
253error:
254 mutex_unlock(&state->mutex);
255 return ret;
256}
257
258static int adv748x_hdmi_g_dv_timings(struct v4l2_subdev *sd,
259 struct v4l2_dv_timings *timings)
260{
261 struct adv748x_hdmi *hdmi = adv748x_sd_to_hdmi(sd);
262 struct adv748x_state *state = adv748x_hdmi_to_state(hdmi);
263
264 mutex_lock(&state->mutex);
265
266 *timings = hdmi->timings;
267
268 mutex_unlock(&state->mutex);
269
270 return 0;
271}
272
273static int adv748x_hdmi_query_dv_timings(struct v4l2_subdev *sd,
274 struct v4l2_dv_timings *timings)
275{
276 struct adv748x_hdmi *hdmi = adv748x_sd_to_hdmi(sd);
277 struct adv748x_state *state = adv748x_hdmi_to_state(hdmi);
278 struct v4l2_bt_timings *bt = &timings->bt;
279 int pixelclock;
280 int polarity;
281
282 if (!timings)
283 return -EINVAL;
284
285 memset(timings, 0, sizeof(struct v4l2_dv_timings));
286
287 if (!adv748x_hdmi_has_signal(state))
288 return -ENOLINK;
289
290 pixelclock = adv748x_hdmi_read_pixelclock(state);
291 if (pixelclock < 0)
292 return -ENODATA;
293
294 timings->type = V4L2_DV_BT_656_1120;
295
296 bt->pixelclock = pixelclock;
297 bt->interlaced = hdmi_read(state, ADV748X_HDMI_F1H1) &
298 ADV748X_HDMI_F1H1_INTERLACED ?
299 V4L2_DV_INTERLACED : V4L2_DV_PROGRESSIVE;
300 bt->width = hdmi_read16(state, ADV748X_HDMI_LW1,
301 ADV748X_HDMI_LW1_WIDTH_MASK);
302 bt->height = hdmi_read16(state, ADV748X_HDMI_F0H1,
303 ADV748X_HDMI_F0H1_HEIGHT_MASK);
304 bt->hfrontporch = hdmi_read16(state, ADV748X_HDMI_HFRONT_PORCH,
305 ADV748X_HDMI_HFRONT_PORCH_MASK);
306 bt->hsync = hdmi_read16(state, ADV748X_HDMI_HSYNC_WIDTH,
307 ADV748X_HDMI_HSYNC_WIDTH_MASK);
308 bt->hbackporch = hdmi_read16(state, ADV748X_HDMI_HBACK_PORCH,
309 ADV748X_HDMI_HBACK_PORCH_MASK);
310 bt->vfrontporch = hdmi_read16(state, ADV748X_HDMI_VFRONT_PORCH,
311 ADV748X_HDMI_VFRONT_PORCH_MASK) / 2;
312 bt->vsync = hdmi_read16(state, ADV748X_HDMI_VSYNC_WIDTH,
313 ADV748X_HDMI_VSYNC_WIDTH_MASK) / 2;
314 bt->vbackporch = hdmi_read16(state, ADV748X_HDMI_VBACK_PORCH,
315 ADV748X_HDMI_VBACK_PORCH_MASK) / 2;
316
317 polarity = hdmi_read(state, 0x05);
318 bt->polarities = (polarity & BIT(4) ? V4L2_DV_VSYNC_POS_POL : 0) |
319 (polarity & BIT(5) ? V4L2_DV_HSYNC_POS_POL : 0);
320
321 if (bt->interlaced == V4L2_DV_INTERLACED) {
322 bt->height += hdmi_read16(state, 0x0b, 0x1fff);
323 bt->il_vfrontporch = hdmi_read16(state, 0x2c, 0x3fff) / 2;
324 bt->il_vsync = hdmi_read16(state, 0x30, 0x3fff) / 2;
325 bt->il_vbackporch = hdmi_read16(state, 0x34, 0x3fff) / 2;
326 }
327
328 adv748x_fill_optional_dv_timings(timings);
329
330 /*
331 * No interrupt handling is implemented yet.
332 * There should be an IRQ when a cable is plugged and the new timings
333 * should be figured out and stored to state.
334 */
335 hdmi->timings = *timings;
336
337 return 0;
338}
339
340static int adv748x_hdmi_g_input_status(struct v4l2_subdev *sd, u32 *status)
341{
342 struct adv748x_hdmi *hdmi = adv748x_sd_to_hdmi(sd);
343 struct adv748x_state *state = adv748x_hdmi_to_state(hdmi);
344
345 mutex_lock(&state->mutex);
346
347 *status = adv748x_hdmi_has_signal(state) ? 0 : V4L2_IN_ST_NO_SIGNAL;
348
349 mutex_unlock(&state->mutex);
350
351 return 0;
352}
353
354static int adv748x_hdmi_s_stream(struct v4l2_subdev *sd, int enable)
355{
356 struct adv748x_hdmi *hdmi = adv748x_sd_to_hdmi(sd);
357 struct adv748x_state *state = adv748x_hdmi_to_state(hdmi);
358 int ret;
359
360 mutex_lock(&state->mutex);
361
362 ret = adv748x_txa_power(state, enable);
363 if (ret)
364 goto done;
365
366 if (adv748x_hdmi_has_signal(state))
367 adv_dbg(state, "Detected HDMI signal\n");
368 else
369 adv_dbg(state, "Couldn't detect HDMI video signal\n");
370
371done:
372 mutex_unlock(&state->mutex);
373 return ret;
374}
375
376static int adv748x_hdmi_g_pixelaspect(struct v4l2_subdev *sd,
377 struct v4l2_fract *aspect)
378{
379 aspect->numerator = 1;
380 aspect->denominator = 1;
381
382 return 0;
383}
384
385static const struct v4l2_subdev_video_ops adv748x_video_ops_hdmi = {
386 .s_dv_timings = adv748x_hdmi_s_dv_timings,
387 .g_dv_timings = adv748x_hdmi_g_dv_timings,
388 .query_dv_timings = adv748x_hdmi_query_dv_timings,
389 .g_input_status = adv748x_hdmi_g_input_status,
390 .s_stream = adv748x_hdmi_s_stream,
391 .g_pixelaspect = adv748x_hdmi_g_pixelaspect,
392};
393
394/* -----------------------------------------------------------------------------
395 * v4l2_subdev_pad_ops
396 */
397
398static int adv748x_hdmi_propagate_pixelrate(struct adv748x_hdmi *hdmi)
399{
400 struct v4l2_subdev *tx;
401 struct v4l2_dv_timings timings;
402 struct v4l2_bt_timings *bt = &timings.bt;
403 unsigned int fps;
404
405 tx = adv748x_get_remote_sd(&hdmi->pads[ADV748X_HDMI_SOURCE]);
406 if (!tx)
407 return -ENOLINK;
408
409 adv748x_hdmi_query_dv_timings(&hdmi->sd, &timings);
410
411 fps = DIV_ROUND_CLOSEST_ULL(bt->pixelclock,
412 V4L2_DV_BT_FRAME_WIDTH(bt) *
413 V4L2_DV_BT_FRAME_HEIGHT(bt));
414
415 return adv748x_csi2_set_pixelrate(tx, bt->width * bt->height * fps);
416}
417
418static int adv748x_hdmi_enum_mbus_code(struct v4l2_subdev *sd,
419 struct v4l2_subdev_pad_config *cfg,
420 struct v4l2_subdev_mbus_code_enum *code)
421{
422 if (code->index != 0)
423 return -EINVAL;
424
425 code->code = MEDIA_BUS_FMT_RGB888_1X24;
426
427 return 0;
428}
429
430static int adv748x_hdmi_get_format(struct v4l2_subdev *sd,
431 struct v4l2_subdev_pad_config *cfg,
432 struct v4l2_subdev_format *sdformat)
433{
434 struct adv748x_hdmi *hdmi = adv748x_sd_to_hdmi(sd);
435 struct v4l2_mbus_framefmt *mbusformat;
436
437 if (sdformat->pad != ADV748X_HDMI_SOURCE)
438 return -EINVAL;
439
440 if (sdformat->which == V4L2_SUBDEV_FORMAT_TRY) {
441 mbusformat = v4l2_subdev_get_try_format(sd, cfg, sdformat->pad);
442 sdformat->format = *mbusformat;
443 } else {
444 adv748x_hdmi_fill_format(hdmi, &sdformat->format);
445 adv748x_hdmi_propagate_pixelrate(hdmi);
446 }
447
448 return 0;
449}
450
451static int adv748x_hdmi_set_format(struct v4l2_subdev *sd,
452 struct v4l2_subdev_pad_config *cfg,
453 struct v4l2_subdev_format *sdformat)
454{
455 struct v4l2_mbus_framefmt *mbusformat;
456
457 if (sdformat->pad != ADV748X_HDMI_SOURCE)
458 return -EINVAL;
459
460 if (sdformat->which == V4L2_SUBDEV_FORMAT_ACTIVE)
461 return adv748x_hdmi_get_format(sd, cfg, sdformat);
462
463 mbusformat = v4l2_subdev_get_try_format(sd, cfg, sdformat->pad);
464 *mbusformat = sdformat->format;
465
466 return 0;
467}
468
469static int adv748x_hdmi_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
470{
471 struct adv748x_hdmi *hdmi = adv748x_sd_to_hdmi(sd);
472
473 memset(edid->reserved, 0, sizeof(edid->reserved));
474
475 if (!hdmi->edid.present)
476 return -ENODATA;
477
478 if (edid->start_block == 0 && edid->blocks == 0) {
479 edid->blocks = hdmi->edid.blocks;
480 return 0;
481 }
482
483 if (edid->start_block >= hdmi->edid.blocks)
484 return -EINVAL;
485
486 if (edid->start_block + edid->blocks > hdmi->edid.blocks)
487 edid->blocks = hdmi->edid.blocks - edid->start_block;
488
489 memcpy(edid->edid, hdmi->edid.edid + edid->start_block * 128,
490 edid->blocks * 128);
491
492 return 0;
493}
494
495static inline int adv748x_hdmi_edid_write_block(struct adv748x_hdmi *hdmi,
496 unsigned int total_len, const u8 *val)
497{
498 struct adv748x_state *state = adv748x_hdmi_to_state(hdmi);
499 int err = 0;
500 int i = 0;
501 int len = 0;
502
503 adv_dbg(state, "%s: write EDID block (%d byte)\n",
504 __func__, total_len);
505
506 while (!err && i < total_len) {
507 len = (total_len - i) > I2C_SMBUS_BLOCK_MAX ?
508 I2C_SMBUS_BLOCK_MAX :
509 (total_len - i);
510
511 err = adv748x_write_block(state, ADV748X_PAGE_EDID,
512 i, val + i, len);
513 i += len;
514 }
515
516 return err;
517}
518
519static int adv748x_hdmi_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
520{
521 struct adv748x_hdmi *hdmi = adv748x_sd_to_hdmi(sd);
522 struct adv748x_state *state = adv748x_hdmi_to_state(hdmi);
523 int err;
524
525 memset(edid->reserved, 0, sizeof(edid->reserved));
526
527 if (edid->start_block != 0)
528 return -EINVAL;
529
530 if (edid->blocks == 0) {
531 hdmi->edid.blocks = 0;
532 hdmi->edid.present = 0;
533
534 /* Fall back to a 16:9 aspect ratio */
535 hdmi->aspect_ratio.numerator = 16;
536 hdmi->aspect_ratio.denominator = 9;
537
538 /* Disable the EDID */
539 repeater_write(state, ADV748X_REPEATER_EDID_SZ,
540 edid->blocks << ADV748X_REPEATER_EDID_SZ_SHIFT);
541
542 repeater_write(state, ADV748X_REPEATER_EDID_CTL, 0);
543
544 return 0;
545 }
546
547 if (edid->blocks > 4) {
548 edid->blocks = 4;
549 return -E2BIG;
550 }
551
552 memcpy(hdmi->edid.edid, edid->edid, 128 * edid->blocks);
553 hdmi->edid.blocks = edid->blocks;
554 hdmi->edid.present = true;
555
556 hdmi->aspect_ratio = v4l2_calc_aspect_ratio(edid->edid[0x15],
557 edid->edid[0x16]);
558
559 err = adv748x_hdmi_edid_write_block(hdmi, 128 * edid->blocks,
560 hdmi->edid.edid);
561 if (err < 0) {
562 v4l2_err(sd, "error %d writing edid pad %d\n", err, edid->pad);
563 return err;
564 }
565
566 repeater_write(state, ADV748X_REPEATER_EDID_SZ,
567 edid->blocks << ADV748X_REPEATER_EDID_SZ_SHIFT);
568
569 repeater_write(state, ADV748X_REPEATER_EDID_CTL,
570 ADV748X_REPEATER_EDID_CTL_EN);
571
572 return 0;
573}
574
575static bool adv748x_hdmi_check_dv_timings(const struct v4l2_dv_timings *timings,
576 void *hdl)
577{
578 const struct adv748x_hdmi_video_standards *stds =
579 adv748x_hdmi_video_standards;
580 unsigned int i;
581
582 for (i = 0; stds[i].timings.bt.width; i++)
583 if (v4l2_match_dv_timings(timings, &stds[i].timings, 0, false))
584 return true;
585
586 return false;
587}
588
589static int adv748x_hdmi_enum_dv_timings(struct v4l2_subdev *sd,
590 struct v4l2_enum_dv_timings *timings)
591{
592 return v4l2_enum_dv_timings_cap(timings, &adv748x_hdmi_timings_cap,
593 adv748x_hdmi_check_dv_timings, NULL);
594}
595
596static int adv748x_hdmi_dv_timings_cap(struct v4l2_subdev *sd,
597 struct v4l2_dv_timings_cap *cap)
598{
599 *cap = adv748x_hdmi_timings_cap;
600 return 0;
601}
602
603static const struct v4l2_subdev_pad_ops adv748x_pad_ops_hdmi = {
604 .enum_mbus_code = adv748x_hdmi_enum_mbus_code,
605 .set_fmt = adv748x_hdmi_set_format,
606 .get_fmt = adv748x_hdmi_get_format,
607 .get_edid = adv748x_hdmi_get_edid,
608 .set_edid = adv748x_hdmi_set_edid,
609 .dv_timings_cap = adv748x_hdmi_dv_timings_cap,
610 .enum_dv_timings = adv748x_hdmi_enum_dv_timings,
611};
612
613/* -----------------------------------------------------------------------------
614 * v4l2_subdev_ops
615 */
616
617static const struct v4l2_subdev_ops adv748x_ops_hdmi = {
618 .video = &adv748x_video_ops_hdmi,
619 .pad = &adv748x_pad_ops_hdmi,
620};
621
622/* -----------------------------------------------------------------------------
623 * Controls
624 */
625
626static const char * const hdmi_ctrl_patgen_menu[] = {
627 "Disabled",
628 "Solid Color",
629 "Color Bars",
630 "Ramp Grey",
631 "Ramp Blue",
632 "Ramp Red",
633 "Checkered"
634};
635
636static int adv748x_hdmi_s_ctrl(struct v4l2_ctrl *ctrl)
637{
638 struct adv748x_hdmi *hdmi = adv748x_ctrl_to_hdmi(ctrl);
639 struct adv748x_state *state = adv748x_hdmi_to_state(hdmi);
640 int ret;
641 u8 pattern;
642
643 /* Enable video adjustment first */
644 ret = cp_clrset(state, ADV748X_CP_VID_ADJ,
645 ADV748X_CP_VID_ADJ_ENABLE,
646 ADV748X_CP_VID_ADJ_ENABLE);
647 if (ret < 0)
648 return ret;
649
650 switch (ctrl->id) {
651 case V4L2_CID_BRIGHTNESS:
652 ret = cp_write(state, ADV748X_CP_BRI, ctrl->val);
653 break;
654 case V4L2_CID_HUE:
655 ret = cp_write(state, ADV748X_CP_HUE, ctrl->val);
656 break;
657 case V4L2_CID_CONTRAST:
658 ret = cp_write(state, ADV748X_CP_CON, ctrl->val);
659 break;
660 case V4L2_CID_SATURATION:
661 ret = cp_write(state, ADV748X_CP_SAT, ctrl->val);
662 break;
663 case V4L2_CID_TEST_PATTERN:
664 pattern = ctrl->val;
665
666 /* Pattern is 0-indexed. Ctrl Menu is 1-indexed */
667 if (pattern) {
668 pattern--;
669 pattern |= ADV748X_CP_PAT_GEN_EN;
670 }
671
672 ret = cp_write(state, ADV748X_CP_PAT_GEN, pattern);
673
674 break;
675 default:
676 return -EINVAL;
677 }
678
679 return ret;
680}
681
682static const struct v4l2_ctrl_ops adv748x_hdmi_ctrl_ops = {
683 .s_ctrl = adv748x_hdmi_s_ctrl,
684};
685
686static int adv748x_hdmi_init_controls(struct adv748x_hdmi *hdmi)
687{
688 struct adv748x_state *state = adv748x_hdmi_to_state(hdmi);
689
690 v4l2_ctrl_handler_init(&hdmi->ctrl_hdl, 5);
691
692 /* Use our mutex for the controls */
693 hdmi->ctrl_hdl.lock = &state->mutex;
694
695 v4l2_ctrl_new_std(&hdmi->ctrl_hdl, &adv748x_hdmi_ctrl_ops,
696 V4L2_CID_BRIGHTNESS, ADV748X_CP_BRI_MIN,
697 ADV748X_CP_BRI_MAX, 1, ADV748X_CP_BRI_DEF);
698 v4l2_ctrl_new_std(&hdmi->ctrl_hdl, &adv748x_hdmi_ctrl_ops,
699 V4L2_CID_CONTRAST, ADV748X_CP_CON_MIN,
700 ADV748X_CP_CON_MAX, 1, ADV748X_CP_CON_DEF);
701 v4l2_ctrl_new_std(&hdmi->ctrl_hdl, &adv748x_hdmi_ctrl_ops,
702 V4L2_CID_SATURATION, ADV748X_CP_SAT_MIN,
703 ADV748X_CP_SAT_MAX, 1, ADV748X_CP_SAT_DEF);
704 v4l2_ctrl_new_std(&hdmi->ctrl_hdl, &adv748x_hdmi_ctrl_ops,
705 V4L2_CID_HUE, ADV748X_CP_HUE_MIN,
706 ADV748X_CP_HUE_MAX, 1, ADV748X_CP_HUE_DEF);
707
708 /*
709 * Todo: V4L2_CID_DV_RX_POWER_PRESENT should also be supported when
710 * interrupts are handled correctly
711 */
712
713 v4l2_ctrl_new_std_menu_items(&hdmi->ctrl_hdl, &adv748x_hdmi_ctrl_ops,
714 V4L2_CID_TEST_PATTERN,
715 ARRAY_SIZE(hdmi_ctrl_patgen_menu) - 1,
716 0, 0, hdmi_ctrl_patgen_menu);
717
718 hdmi->sd.ctrl_handler = &hdmi->ctrl_hdl;
719 if (hdmi->ctrl_hdl.error) {
720 v4l2_ctrl_handler_free(&hdmi->ctrl_hdl);
721 return hdmi->ctrl_hdl.error;
722 }
723
724 return v4l2_ctrl_handler_setup(&hdmi->ctrl_hdl);
725}
726
727int adv748x_hdmi_init(struct adv748x_hdmi *hdmi)
728{
729 struct adv748x_state *state = adv748x_hdmi_to_state(hdmi);
730 static const struct v4l2_dv_timings cea1280x720 =
731 V4L2_DV_BT_CEA_1280X720P30;
732 int ret;
733
734 hdmi->timings = cea1280x720;
735
736 /* Initialise a default 16:9 aspect ratio */
737 hdmi->aspect_ratio.numerator = 16;
738 hdmi->aspect_ratio.denominator = 9;
739
740 adv748x_subdev_init(&hdmi->sd, state, &adv748x_ops_hdmi,
741 MEDIA_ENT_F_IO_DTV, "hdmi");
742
743 hdmi->pads[ADV748X_HDMI_SINK].flags = MEDIA_PAD_FL_SINK;
744 hdmi->pads[ADV748X_HDMI_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
745
746 ret = media_entity_pads_init(&hdmi->sd.entity,
747 ADV748X_HDMI_NR_PADS, hdmi->pads);
748 if (ret)
749 return ret;
750
751 ret = adv748x_hdmi_init_controls(hdmi);
752 if (ret)
753 goto err_free_media;
754
755 return 0;
756
757err_free_media:
758 media_entity_cleanup(&hdmi->sd.entity);
759
760 return ret;
761}
762
763void adv748x_hdmi_cleanup(struct adv748x_hdmi *hdmi)
764{
765 v4l2_device_unregister_subdev(&hdmi->sd);
766 media_entity_cleanup(&hdmi->sd.entity);
767 v4l2_ctrl_handler_free(&hdmi->ctrl_hdl);
768}
diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h
new file mode 100644
index 000000000000..cc4151b5b31e
--- /dev/null
+++ b/drivers/media/i2c/adv748x/adv748x.h
@@ -0,0 +1,425 @@
1/*
2 * Driver for Analog Devices ADV748X video decoder and HDMI receiver
3 *
4 * Copyright (C) 2017 Renesas Electronics Corp.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 * Authors:
12 * Koji Matsuoka <koji.matsuoka.xm@renesas.com>
13 * Niklas Söderlund <niklas.soderlund@ragnatech.se>
14 * Kieran Bingham <kieran.bingham@ideasonboard.com>
15 *
16 * The ADV748x range of receivers have the following configurations:
17 *
18 * Analog HDMI MHL 4-Lane 1-Lane
19 * In In CSI CSI
20 * ADV7480 X X X
21 * ADV7481 X X X X X
22 * ADV7482 X X X X
23 */
24
25#include <linux/i2c.h>
26
27#ifndef _ADV748X_H_
28#define _ADV748X_H_
29
30/* I2C slave addresses */
31#define ADV748X_I2C_IO 0x70 /* IO Map */
32#define ADV748X_I2C_DPLL 0x26 /* DPLL Map */
33#define ADV748X_I2C_CP 0x22 /* CP Map */
34#define ADV748X_I2C_HDMI 0x34 /* HDMI Map */
35#define ADV748X_I2C_EDID 0x36 /* EDID Map */
36#define ADV748X_I2C_REPEATER 0x32 /* HDMI RX Repeater Map */
37#define ADV748X_I2C_INFOFRAME 0x31 /* HDMI RX InfoFrame Map */
38#define ADV748X_I2C_CEC 0x41 /* CEC Map */
39#define ADV748X_I2C_SDP 0x79 /* SDP Map */
40#define ADV748X_I2C_TXB 0x48 /* CSI-TXB Map */
41#define ADV748X_I2C_TXA 0x4a /* CSI-TXA Map */
42
43enum adv748x_page {
44 ADV748X_PAGE_IO,
45 ADV748X_PAGE_DPLL,
46 ADV748X_PAGE_CP,
47 ADV748X_PAGE_HDMI,
48 ADV748X_PAGE_EDID,
49 ADV748X_PAGE_REPEATER,
50 ADV748X_PAGE_INFOFRAME,
51 ADV748X_PAGE_CEC,
52 ADV748X_PAGE_SDP,
53 ADV748X_PAGE_TXB,
54 ADV748X_PAGE_TXA,
55 ADV748X_PAGE_MAX,
56
57 /* Fake pages for register sequences */
58 ADV748X_PAGE_WAIT, /* Wait x msec */
59 ADV748X_PAGE_EOR, /* End Mark */
60};
61
62/**
63 * enum adv748x_ports - Device tree port number definitions
64 *
65 * The ADV748X ports define the mapping between subdevices
66 * and the device tree specification
67 */
68enum adv748x_ports {
69 ADV748X_PORT_AIN0 = 0,
70 ADV748X_PORT_AIN1 = 1,
71 ADV748X_PORT_AIN2 = 2,
72 ADV748X_PORT_AIN3 = 3,
73 ADV748X_PORT_AIN4 = 4,
74 ADV748X_PORT_AIN5 = 5,
75 ADV748X_PORT_AIN6 = 6,
76 ADV748X_PORT_AIN7 = 7,
77 ADV748X_PORT_HDMI = 8,
78 ADV748X_PORT_TTL = 9,
79 ADV748X_PORT_TXA = 10,
80 ADV748X_PORT_TXB = 11,
81 ADV748X_PORT_MAX = 12,
82};
83
84enum adv748x_csi2_pads {
85 ADV748X_CSI2_SINK,
86 ADV748X_CSI2_SOURCE,
87 ADV748X_CSI2_NR_PADS,
88};
89
90/* CSI2 transmitters can have 2 internal connections, HDMI/AFE */
91#define ADV748X_CSI2_MAX_SUBDEVS 2
92
93struct adv748x_csi2 {
94 struct adv748x_state *state;
95 struct v4l2_mbus_framefmt format;
96 unsigned int page;
97
98 struct media_pad pads[ADV748X_CSI2_NR_PADS];
99 struct v4l2_ctrl_handler ctrl_hdl;
100 struct v4l2_subdev sd;
101};
102
103#define notifier_to_csi2(n) container_of(n, struct adv748x_csi2, notifier)
104#define adv748x_sd_to_csi2(sd) container_of(sd, struct adv748x_csi2, sd)
105
106enum adv748x_hdmi_pads {
107 ADV748X_HDMI_SINK,
108 ADV748X_HDMI_SOURCE,
109 ADV748X_HDMI_NR_PADS,
110};
111
112struct adv748x_hdmi {
113 struct media_pad pads[ADV748X_HDMI_NR_PADS];
114 struct v4l2_ctrl_handler ctrl_hdl;
115 struct v4l2_subdev sd;
116 struct v4l2_mbus_framefmt format;
117
118 struct v4l2_dv_timings timings;
119 struct v4l2_fract aspect_ratio;
120
121 struct {
122 u8 edid[512];
123 u32 present;
124 unsigned int blocks;
125 } edid;
126};
127
128#define adv748x_ctrl_to_hdmi(ctrl) \
129 container_of(ctrl->handler, struct adv748x_hdmi, ctrl_hdl)
130#define adv748x_sd_to_hdmi(sd) container_of(sd, struct adv748x_hdmi, sd)
131
132enum adv748x_afe_pads {
133 ADV748X_AFE_SINK_AIN0,
134 ADV748X_AFE_SINK_AIN1,
135 ADV748X_AFE_SINK_AIN2,
136 ADV748X_AFE_SINK_AIN3,
137 ADV748X_AFE_SINK_AIN4,
138 ADV748X_AFE_SINK_AIN5,
139 ADV748X_AFE_SINK_AIN6,
140 ADV748X_AFE_SINK_AIN7,
141 ADV748X_AFE_SOURCE,
142 ADV748X_AFE_NR_PADS,
143};
144
145struct adv748x_afe {
146 struct media_pad pads[ADV748X_AFE_NR_PADS];
147 struct v4l2_ctrl_handler ctrl_hdl;
148 struct v4l2_subdev sd;
149 struct v4l2_mbus_framefmt format;
150
151 bool streaming;
152 v4l2_std_id curr_norm;
153 unsigned int input;
154};
155
156#define adv748x_ctrl_to_afe(ctrl) \
157 container_of(ctrl->handler, struct adv748x_afe, ctrl_hdl)
158#define adv748x_sd_to_afe(sd) container_of(sd, struct adv748x_afe, sd)
159
160/**
161 * struct adv748x_state - State of ADV748X
162 * @dev: (OF) device
163 * @client: I2C client
164 * @mutex: protect global state
165 *
166 * @endpoints: parsed device node endpoints for each port
167 *
168 * @i2c_addresses I2C Page addresses
169 * @i2c_clients I2C clients for the page accesses
170 * @regmap regmap configuration pages.
171 *
172 * @hdmi: state of HDMI receiver context
173 * @afe: state of AFE receiver context
174 * @txa: state of TXA transmitter context
175 * @txb: state of TXB transmitter context
176 */
177struct adv748x_state {
178 struct device *dev;
179 struct i2c_client *client;
180 struct mutex mutex;
181
182 struct device_node *endpoints[ADV748X_PORT_MAX];
183
184 struct i2c_client *i2c_clients[ADV748X_PAGE_MAX];
185 struct regmap *regmap[ADV748X_PAGE_MAX];
186
187 struct adv748x_hdmi hdmi;
188 struct adv748x_afe afe;
189 struct adv748x_csi2 txa;
190 struct adv748x_csi2 txb;
191};
192
193#define adv748x_hdmi_to_state(h) container_of(h, struct adv748x_state, hdmi)
194#define adv748x_afe_to_state(a) container_of(a, struct adv748x_state, afe)
195
196#define adv_err(a, fmt, arg...) dev_err(a->dev, fmt, ##arg)
197#define adv_info(a, fmt, arg...) dev_info(a->dev, fmt, ##arg)
198#define adv_dbg(a, fmt, arg...) dev_dbg(a->dev, fmt, ##arg)
199
200/* Register Mappings */
201
202/* IO Map */
203#define ADV748X_IO_PD 0x00 /* power down controls */
204#define ADV748X_IO_PD_RX_EN BIT(6)
205
206#define ADV748X_IO_REG_04 0x04
207#define ADV748X_IO_REG_04_FORCE_FR BIT(0) /* Force CP free-run */
208
209#define ADV748X_IO_DATAPATH 0x03 /* datapath cntrl */
210#define ADV748X_IO_DATAPATH_VFREQ_M 0x70
211#define ADV748X_IO_DATAPATH_VFREQ_SHIFT 4
212
213#define ADV748X_IO_VID_STD 0x05
214
215#define ADV748X_IO_10 0x10 /* io_reg_10 */
216#define ADV748X_IO_10_CSI4_EN BIT(7)
217#define ADV748X_IO_10_CSI1_EN BIT(6)
218#define ADV748X_IO_10_PIX_OUT_EN BIT(5)
219
220#define ADV748X_IO_CHIP_REV_ID_1 0xdf
221#define ADV748X_IO_CHIP_REV_ID_2 0xe0
222
223#define ADV748X_IO_SLAVE_ADDR_BASE 0xf2
224
225/* HDMI RX Map */
226#define ADV748X_HDMI_LW1 0x07 /* line width_1 */
227#define ADV748X_HDMI_LW1_VERT_FILTER BIT(7)
228#define ADV748X_HDMI_LW1_DE_REGEN BIT(5)
229#define ADV748X_HDMI_LW1_WIDTH_MASK 0x1fff
230
231#define ADV748X_HDMI_F0H1 0x09 /* field0 height_1 */
232#define ADV748X_HDMI_F0H1_HEIGHT_MASK 0x1fff
233
234#define ADV748X_HDMI_F1H1 0x0b /* field1 height_1 */
235#define ADV748X_HDMI_F1H1_INTERLACED BIT(5)
236
237#define ADV748X_HDMI_HFRONT_PORCH 0x20 /* hsync_front_porch_1 */
238#define ADV748X_HDMI_HFRONT_PORCH_MASK 0x1fff
239
240#define ADV748X_HDMI_HSYNC_WIDTH 0x22 /* hsync_pulse_width_1 */
241#define ADV748X_HDMI_HSYNC_WIDTH_MASK 0x1fff
242
243#define ADV748X_HDMI_HBACK_PORCH 0x24 /* hsync_back_porch_1 */
244#define ADV748X_HDMI_HBACK_PORCH_MASK 0x1fff
245
246#define ADV748X_HDMI_VFRONT_PORCH 0x2a /* field0_vs_front_porch_1 */
247#define ADV748X_HDMI_VFRONT_PORCH_MASK 0x3fff
248
249#define ADV748X_HDMI_VSYNC_WIDTH 0x2e /* field0_vs_pulse_width_1 */
250#define ADV748X_HDMI_VSYNC_WIDTH_MASK 0x3fff
251
252#define ADV748X_HDMI_VBACK_PORCH 0x32 /* field0_vs_back_porch_1 */
253#define ADV748X_HDMI_VBACK_PORCH_MASK 0x3fff
254
255#define ADV748X_HDMI_TMDS_1 0x51 /* hdmi_reg_51 */
256#define ADV748X_HDMI_TMDS_2 0x52 /* hdmi_reg_52 */
257
258/* HDMI RX Repeater Map */
259#define ADV748X_REPEATER_EDID_SZ 0x70 /* primary_edid_size */
260#define ADV748X_REPEATER_EDID_SZ_SHIFT 4
261
262#define ADV748X_REPEATER_EDID_CTL 0x74 /* hdcp edid controls */
263#define ADV748X_REPEATER_EDID_CTL_EN BIT(0) /* man_edid_a_enable */
264
265/* SDP Main Map */
266#define ADV748X_SDP_INSEL 0x00 /* user_map_rw_reg_00 */
267
268#define ADV748X_SDP_VID_SEL 0x02 /* user_map_rw_reg_02 */
269#define ADV748X_SDP_VID_SEL_MASK 0xf0
270#define ADV748X_SDP_VID_SEL_SHIFT 4
271
272/* Contrast - Unsigned*/
273#define ADV748X_SDP_CON 0x08 /* user_map_rw_reg_08 */
274#define ADV748X_SDP_CON_MIN 0
275#define ADV748X_SDP_CON_DEF 128
276#define ADV748X_SDP_CON_MAX 255
277
278/* Brightness - Signed */
279#define ADV748X_SDP_BRI 0x0a /* user_map_rw_reg_0a */
280#define ADV748X_SDP_BRI_MIN -128
281#define ADV748X_SDP_BRI_DEF 0
282#define ADV748X_SDP_BRI_MAX 127
283
284/* Hue - Signed, inverted*/
285#define ADV748X_SDP_HUE 0x0b /* user_map_rw_reg_0b */
286#define ADV748X_SDP_HUE_MIN -127
287#define ADV748X_SDP_HUE_DEF 0
288#define ADV748X_SDP_HUE_MAX 128
289
290/* Test Patterns / Default Values */
291#define ADV748X_SDP_DEF 0x0c /* user_map_rw_reg_0c */
292#define ADV748X_SDP_DEF_VAL_EN BIT(0) /* Force free run mode */
293#define ADV748X_SDP_DEF_VAL_AUTO_EN BIT(1) /* Free run when no signal */
294
295#define ADV748X_SDP_MAP_SEL 0x0e /* user_map_rw_reg_0e */
296#define ADV748X_SDP_MAP_SEL_RO_MAIN 1
297
298/* Free run pattern select */
299#define ADV748X_SDP_FRP 0x14
300#define ADV748X_SDP_FRP_MASK GENMASK(3, 1)
301
302/* Saturation */
303#define ADV748X_SDP_SD_SAT_U 0xe3 /* user_map_rw_reg_e3 */
304#define ADV748X_SDP_SD_SAT_V 0xe4 /* user_map_rw_reg_e4 */
305#define ADV748X_SDP_SAT_MIN 0
306#define ADV748X_SDP_SAT_DEF 128
307#define ADV748X_SDP_SAT_MAX 255
308
309/* SDP RO Main Map */
310#define ADV748X_SDP_RO_10 0x10
311#define ADV748X_SDP_RO_10_IN_LOCK BIT(0)
312
313/* CP Map */
314#define ADV748X_CP_PAT_GEN 0x37 /* int_pat_gen_1 */
315#define ADV748X_CP_PAT_GEN_EN BIT(7)
316
317/* Contrast Control - Unsigned */
318#define ADV748X_CP_CON 0x3a /* contrast_cntrl */
319#define ADV748X_CP_CON_MIN 0 /* Minimum contrast */
320#define ADV748X_CP_CON_DEF 128 /* Default */
321#define ADV748X_CP_CON_MAX 255 /* Maximum contrast */
322
323/* Saturation Control - Unsigned */
324#define ADV748X_CP_SAT 0x3b /* saturation_cntrl */
325#define ADV748X_CP_SAT_MIN 0 /* Minimum saturation */
326#define ADV748X_CP_SAT_DEF 128 /* Default */
327#define ADV748X_CP_SAT_MAX 255 /* Maximum saturation */
328
329/* Brightness Control - Signed */
330#define ADV748X_CP_BRI 0x3c /* brightness_cntrl */
331#define ADV748X_CP_BRI_MIN -128 /* Luma is -512d */
332#define ADV748X_CP_BRI_DEF 0 /* Luma is 0 */
333#define ADV748X_CP_BRI_MAX 127 /* Luma is 508d */
334
335/* Hue Control */
336#define ADV748X_CP_HUE 0x3d /* hue_cntrl */
337#define ADV748X_CP_HUE_MIN 0 /* -90 degree */
338#define ADV748X_CP_HUE_DEF 0 /* -90 degree */
339#define ADV748X_CP_HUE_MAX 255 /* +90 degree */
340
341#define ADV748X_CP_VID_ADJ 0x3e /* vid_adj_0 */
342#define ADV748X_CP_VID_ADJ_ENABLE BIT(7) /* Enable colour controls */
343
344#define ADV748X_CP_DE_POS_HIGH 0x8b /* de_pos_adj_6 */
345#define ADV748X_CP_DE_POS_HIGH_SET BIT(6)
346#define ADV748X_CP_DE_POS_END_LOW 0x8c /* de_pos_adj_7 */
347#define ADV748X_CP_DE_POS_START_LOW 0x8d /* de_pos_adj_8 */
348
349#define ADV748X_CP_VID_ADJ_2 0x91
350#define ADV748X_CP_VID_ADJ_2_INTERLACED BIT(6)
351#define ADV748X_CP_VID_ADJ_2_INTERLACED_3D BIT(4)
352
353#define ADV748X_CP_CLMP_POS 0xc9 /* clmp_pos_cntrl_4 */
354#define ADV748X_CP_CLMP_POS_DIS_AUTO BIT(0) /* dis_auto_param_buff */
355
356/* CSI : TXA/TXB Maps */
357#define ADV748X_CSI_VC_REF 0x0d /* csi_tx_top_reg_0d */
358#define ADV748X_CSI_VC_REF_SHIFT 6
359
360#define ADV748X_CSI_FS_AS_LS 0x1e /* csi_tx_top_reg_1e */
361#define ADV748X_CSI_FS_AS_LS_UNKNOWN BIT(6) /* Undocumented bit */
362
363/* Register handling */
364
365int adv748x_read(struct adv748x_state *state, u8 addr, u8 reg);
366int adv748x_write(struct adv748x_state *state, u8 page, u8 reg, u8 value);
367int adv748x_write_block(struct adv748x_state *state, int client_page,
368 unsigned int init_reg, const void *val,
369 size_t val_len);
370
371#define io_read(s, r) adv748x_read(s, ADV748X_PAGE_IO, r)
372#define io_write(s, r, v) adv748x_write(s, ADV748X_PAGE_IO, r, v)
373#define io_clrset(s, r, m, v) io_write(s, r, (io_read(s, r) & ~m) | v)
374
375#define hdmi_read(s, r) adv748x_read(s, ADV748X_PAGE_HDMI, r)
376#define hdmi_read16(s, r, m) (((hdmi_read(s, r) << 8) | hdmi_read(s, r+1)) & m)
377#define hdmi_write(s, r, v) adv748x_write(s, ADV748X_PAGE_HDMI, r, v)
378
379#define repeater_read(s, r) adv748x_read(s, ADV748X_PAGE_REPEATER, r)
380#define repeater_write(s, r, v) adv748x_write(s, ADV748X_PAGE_REPEATER, r, v)
381
382#define sdp_read(s, r) adv748x_read(s, ADV748X_PAGE_SDP, r)
383#define sdp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_SDP, r, v)
384#define sdp_clrset(s, r, m, v) sdp_write(s, r, (sdp_read(s, r) & ~m) | v)
385
386#define cp_read(s, r) adv748x_read(s, ADV748X_PAGE_CP, r)
387#define cp_write(s, r, v) adv748x_write(s, ADV748X_PAGE_CP, r, v)
388#define cp_clrset(s, r, m, v) cp_write(s, r, (cp_read(s, r) & ~m) | v)
389
390#define txa_read(s, r) adv748x_read(s, ADV748X_PAGE_TXA, r)
391#define txb_read(s, r) adv748x_read(s, ADV748X_PAGE_TXB, r)
392
393#define tx_read(t, r) adv748x_read(t->state, t->page, r)
394#define tx_write(t, r, v) adv748x_write(t->state, t->page, r, v)
395
396static inline struct v4l2_subdev *adv748x_get_remote_sd(struct media_pad *pad)
397{
398 pad = media_entity_remote_pad(pad);
399 if (!pad)
400 return NULL;
401
402 return media_entity_to_v4l2_subdev(pad->entity);
403}
404
405void adv748x_subdev_init(struct v4l2_subdev *sd, struct adv748x_state *state,
406 const struct v4l2_subdev_ops *ops, u32 function,
407 const char *ident);
408
409int adv748x_register_subdevs(struct adv748x_state *state,
410 struct v4l2_device *v4l2_dev);
411
412int adv748x_txa_power(struct adv748x_state *state, bool on);
413int adv748x_txb_power(struct adv748x_state *state, bool on);
414
415int adv748x_afe_init(struct adv748x_afe *afe);
416void adv748x_afe_cleanup(struct adv748x_afe *afe);
417
418int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx);
419void adv748x_csi2_cleanup(struct adv748x_csi2 *tx);
420int adv748x_csi2_set_pixelrate(struct v4l2_subdev *sd, s64 rate);
421
422int adv748x_hdmi_init(struct adv748x_hdmi *hdmi);
423void adv748x_hdmi_cleanup(struct adv748x_hdmi *hdmi);
424
425#endif /* _ADV748X_H_ */
diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index ccc478605643..2817bafc67bf 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -1927,8 +1927,7 @@ static int adv7511_probe(struct i2c_client *client, const struct i2c_device_id *
1927 1927
1928#if IS_ENABLED(CONFIG_VIDEO_ADV7511_CEC) 1928#if IS_ENABLED(CONFIG_VIDEO_ADV7511_CEC)
1929 state->cec_adap = cec_allocate_adapter(&adv7511_cec_adap_ops, 1929 state->cec_adap = cec_allocate_adapter(&adv7511_cec_adap_ops,
1930 state, dev_name(&client->dev), CEC_CAP_TRANSMIT | 1930 state, dev_name(&client->dev), CEC_CAP_DEFAULTS,
1931 CEC_CAP_LOG_ADDRS | CEC_CAP_PASSTHROUGH | CEC_CAP_RC,
1932 ADV7511_MAX_ADDRS); 1931 ADV7511_MAX_ADDRS);
1933 err = PTR_ERR_OR_ZERO(state->cec_adap); 1932 err = PTR_ERR_OR_ZERO(state->cec_adap);
1934 if (err) { 1933 if (err) {
@@ -1986,7 +1985,7 @@ static int adv7511_remove(struct i2c_client *client)
1986 1985
1987/* ----------------------------------------------------------------------- */ 1986/* ----------------------------------------------------------------------- */
1988 1987
1989static struct i2c_device_id adv7511_id[] = { 1988static const struct i2c_device_id adv7511_id[] = {
1990 { "adv7511", 0 }, 1989 { "adv7511", 0 },
1991 { } 1990 { }
1992}; 1991};
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 660bacb8f7d9..f289b8aca1da 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -618,7 +618,7 @@ static int adv76xx_read_reg(struct v4l2_subdev *sd, unsigned int reg)
618 unsigned int val; 618 unsigned int val;
619 int err; 619 int err;
620 620
621 if (!(BIT(page) & state->info->page_mask)) 621 if (page >= ADV76XX_PAGE_MAX || !(BIT(page) & state->info->page_mask))
622 return -EINVAL; 622 return -EINVAL;
623 623
624 reg &= 0xff; 624 reg &= 0xff;
@@ -633,7 +633,7 @@ static int adv76xx_write_reg(struct v4l2_subdev *sd, unsigned int reg, u8 val)
633 struct adv76xx_state *state = to_state(sd); 633 struct adv76xx_state *state = to_state(sd);
634 unsigned int page = reg >> 8; 634 unsigned int page = reg >> 8;
635 635
636 if (!(BIT(page) & state->info->page_mask)) 636 if (page >= ADV76XX_PAGE_MAX || !(BIT(page) & state->info->page_mask))
637 return -EINVAL; 637 return -EINVAL;
638 638
639 reg &= 0xff; 639 reg &= 0xff;
@@ -3515,8 +3515,7 @@ static int adv76xx_probe(struct i2c_client *client,
3515#if IS_ENABLED(CONFIG_VIDEO_ADV7604_CEC) 3515#if IS_ENABLED(CONFIG_VIDEO_ADV7604_CEC)
3516 state->cec_adap = cec_allocate_adapter(&adv76xx_cec_adap_ops, 3516 state->cec_adap = cec_allocate_adapter(&adv76xx_cec_adap_ops,
3517 state, dev_name(&client->dev), 3517 state, dev_name(&client->dev),
3518 CEC_CAP_TRANSMIT | CEC_CAP_LOG_ADDRS | 3518 CEC_CAP_DEFAULTS, ADV76XX_MAX_ADDRS);
3519 CEC_CAP_PASSTHROUGH | CEC_CAP_RC, ADV76XX_MAX_ADDRS);
3520 err = PTR_ERR_OR_ZERO(state->cec_adap); 3519 err = PTR_ERR_OR_ZERO(state->cec_adap);
3521 if (err) 3520 if (err)
3522 goto err_entity; 3521 goto err_entity;
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 303effda1a2e..65f34e7e146f 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -3568,8 +3568,7 @@ static int adv7842_probe(struct i2c_client *client,
3568#if IS_ENABLED(CONFIG_VIDEO_ADV7842_CEC) 3568#if IS_ENABLED(CONFIG_VIDEO_ADV7842_CEC)
3569 state->cec_adap = cec_allocate_adapter(&adv7842_cec_adap_ops, 3569 state->cec_adap = cec_allocate_adapter(&adv7842_cec_adap_ops,
3570 state, dev_name(&client->dev), 3570 state, dev_name(&client->dev),
3571 CEC_CAP_TRANSMIT | CEC_CAP_LOG_ADDRS | 3571 CEC_CAP_DEFAULTS, ADV7842_MAX_ADDRS);
3572 CEC_CAP_PASSTHROUGH | CEC_CAP_RC, ADV7842_MAX_ADDRS);
3573 err = PTR_ERR_OR_ZERO(state->cec_adap); 3572 err = PTR_ERR_OR_ZERO(state->cec_adap);
3574 if (err) 3573 if (err)
3575 goto err_entity; 3574 goto err_entity;
@@ -3608,7 +3607,7 @@ static int adv7842_remove(struct i2c_client *client)
3608 3607
3609/* ----------------------------------------------------------------------- */ 3608/* ----------------------------------------------------------------------- */
3610 3609
3611static struct i2c_device_id adv7842_id[] = { 3610static const struct i2c_device_id adv7842_id[] = {
3612 { "adv7842", 0 }, 3611 { "adv7842", 0 },
3613 { } 3612 { }
3614}; 3613};
diff --git a/drivers/media/i2c/dw9714.c b/drivers/media/i2c/dw9714.c
index 6a607d7f82de..95af4fc99cd0 100644
--- a/drivers/media/i2c/dw9714.c
+++ b/drivers/media/i2c/dw9714.c
@@ -11,7 +11,6 @@
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 */ 12 */
13 13
14#include <linux/acpi.h>
15#include <linux/delay.h> 14#include <linux/delay.h>
16#include <linux/i2c.h> 15#include <linux/i2c.h>
17#include <linux/module.h> 16#include <linux/module.h>
@@ -147,8 +146,7 @@ static int dw9714_init_controls(struct dw9714_device *dev_vcm)
147 return hdl->error; 146 return hdl->error;
148} 147}
149 148
150static int dw9714_probe(struct i2c_client *client, 149static int dw9714_probe(struct i2c_client *client)
151 const struct i2c_device_id *devid)
152{ 150{
153 struct dw9714_device *dw9714_dev; 151 struct dw9714_device *dw9714_dev;
154 int rval; 152 int rval;
@@ -250,20 +248,18 @@ static int __maybe_unused dw9714_vcm_resume(struct device *dev)
250 return 0; 248 return 0;
251} 249}
252 250
253#ifdef CONFIG_ACPI
254static const struct acpi_device_id dw9714_acpi_match[] = {
255 {},
256};
257MODULE_DEVICE_TABLE(acpi, dw9714_acpi_match);
258#endif
259
260static const struct i2c_device_id dw9714_id_table[] = { 251static const struct i2c_device_id dw9714_id_table[] = {
261 {DW9714_NAME, 0}, 252 { DW9714_NAME, 0 },
262 {} 253 { { 0 } }
263}; 254};
264
265MODULE_DEVICE_TABLE(i2c, dw9714_id_table); 255MODULE_DEVICE_TABLE(i2c, dw9714_id_table);
266 256
257static const struct of_device_id dw9714_of_table[] = {
258 { .compatible = "dongwoon,dw9714" },
259 { { 0 } }
260};
261MODULE_DEVICE_TABLE(of, dw9714_of_table);
262
267static const struct dev_pm_ops dw9714_pm_ops = { 263static const struct dev_pm_ops dw9714_pm_ops = {
268 SET_SYSTEM_SLEEP_PM_OPS(dw9714_vcm_suspend, dw9714_vcm_resume) 264 SET_SYSTEM_SLEEP_PM_OPS(dw9714_vcm_suspend, dw9714_vcm_resume)
269 SET_RUNTIME_PM_OPS(dw9714_vcm_suspend, dw9714_vcm_resume, NULL) 265 SET_RUNTIME_PM_OPS(dw9714_vcm_suspend, dw9714_vcm_resume, NULL)
@@ -273,9 +269,9 @@ static struct i2c_driver dw9714_i2c_driver = {
273 .driver = { 269 .driver = {
274 .name = DW9714_NAME, 270 .name = DW9714_NAME,
275 .pm = &dw9714_pm_ops, 271 .pm = &dw9714_pm_ops,
276 .acpi_match_table = ACPI_PTR(dw9714_acpi_match), 272 .of_match_table = dw9714_of_table,
277 }, 273 },
278 .probe = dw9714_probe, 274 .probe_new = dw9714_probe,
279 .remove = dw9714_remove, 275 .remove = dw9714_remove,
280 .id_table = dw9714_id_table, 276 .id_table = dw9714_id_table,
281}; 277};
diff --git a/drivers/media/i2c/et8ek8/et8ek8_driver.c b/drivers/media/i2c/et8ek8/et8ek8_driver.c
index f39f5179dd95..c14f0fd6ded3 100644
--- a/drivers/media/i2c/et8ek8/et8ek8_driver.c
+++ b/drivers/media/i2c/et8ek8/et8ek8_driver.c
@@ -43,7 +43,7 @@
43 43
44#define ET8EK8_NAME "et8ek8" 44#define ET8EK8_NAME "et8ek8"
45#define ET8EK8_PRIV_MEM_SIZE 128 45#define ET8EK8_PRIV_MEM_SIZE 128
46#define ET8EK8_MAX_MSG 48 46#define ET8EK8_MAX_MSG 8
47 47
48struct et8ek8_sensor { 48struct et8ek8_sensor {
49 struct v4l2_subdev subdev; 49 struct v4l2_subdev subdev;
@@ -220,7 +220,8 @@ static void et8ek8_i2c_create_msg(struct i2c_client *client, u16 len, u16 reg,
220 220
221/* 221/*
222 * A buffered write method that puts the wanted register write 222 * A buffered write method that puts the wanted register write
223 * commands in a message list and passes the list to the i2c framework 223 * commands in smaller number of message lists and passes the lists to
224 * the i2c framework
224 */ 225 */
225static int et8ek8_i2c_buffered_write_regs(struct i2c_client *client, 226static int et8ek8_i2c_buffered_write_regs(struct i2c_client *client,
226 const struct et8ek8_reg *wnext, 227 const struct et8ek8_reg *wnext,
@@ -231,11 +232,7 @@ static int et8ek8_i2c_buffered_write_regs(struct i2c_client *client,
231 int wcnt = 0; 232 int wcnt = 0;
232 u16 reg, data_length; 233 u16 reg, data_length;
233 u32 val; 234 u32 val;
234 235 int rval;
235 if (WARN_ONCE(cnt > ET8EK8_MAX_MSG,
236 ET8EK8_NAME ": %s: too many messages.\n", __func__)) {
237 return -EINVAL;
238 }
239 236
240 /* Create new write messages for all writes */ 237 /* Create new write messages for all writes */
241 while (wcnt < cnt) { 238 while (wcnt < cnt) {
@@ -249,10 +246,21 @@ static int et8ek8_i2c_buffered_write_regs(struct i2c_client *client,
249 246
250 /* Update write count */ 247 /* Update write count */
251 wcnt++; 248 wcnt++;
249
250 if (wcnt < ET8EK8_MAX_MSG)
251 continue;
252
253 rval = i2c_transfer(client->adapter, msg, wcnt);
254 if (rval < 0)
255 return rval;
256
257 cnt -= wcnt;
258 wcnt = 0;
252 } 259 }
253 260
254 /* Now we send everything ... */ 261 rval = i2c_transfer(client->adapter, msg, wcnt);
255 return i2c_transfer(client->adapter, msg, wcnt); 262
263 return rval < 0 ? rval : 0;
256} 264}
257 265
258/* 266/*
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index cee7fd9cf08b..a374e2a0ac3d 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -59,8 +59,8 @@ module_param(debug, int, 0644); /* debug level (0,1,2) */
59 59
60/* ----------------------------------------------------------------------- */ 60/* ----------------------------------------------------------------------- */
61 61
62static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol, 62static int get_key_haup_common(struct IR_i2c *ir, enum rc_proto *protocol,
63 u32 *scancode, u8 *ptoggle, int size) 63 u32 *scancode, u8 *ptoggle, int size)
64{ 64{
65 unsigned char buf[6]; 65 unsigned char buf[6];
66 int start, range, toggle, dev, code, ircode, vendor; 66 int start, range, toggle, dev, code, ircode, vendor;
@@ -99,7 +99,7 @@ static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol,
99 dprintk(1, "ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n", 99 dprintk(1, "ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n",
100 start, range, toggle, dev, code); 100 start, range, toggle, dev, code);
101 101
102 *protocol = RC_TYPE_RC5; 102 *protocol = RC_PROTO_RC5;
103 *scancode = RC_SCANCODE_RC5(dev, code); 103 *scancode = RC_SCANCODE_RC5(dev, code);
104 *ptoggle = toggle; 104 *ptoggle = toggle;
105 105
@@ -111,13 +111,13 @@ static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol,
111 111
112 if (vendor == 0x800f) { 112 if (vendor == 0x800f) {
113 *ptoggle = (dev & 0x80) != 0; 113 *ptoggle = (dev & 0x80) != 0;
114 *protocol = RC_TYPE_RC6_MCE; 114 *protocol = RC_PROTO_RC6_MCE;
115 dev &= 0x7f; 115 dev &= 0x7f;
116 dprintk(1, "ir hauppauge (rc6-mce): t%d vendor=%d dev=%d code=%d\n", 116 dprintk(1, "ir hauppauge (rc6-mce): t%d vendor=%d dev=%d code=%d\n",
117 *ptoggle, vendor, dev, code); 117 *ptoggle, vendor, dev, code);
118 } else { 118 } else {
119 *ptoggle = 0; 119 *ptoggle = 0;
120 *protocol = RC_TYPE_RC6_6A_32; 120 *protocol = RC_PROTO_RC6_6A_32;
121 dprintk(1, "ir hauppauge (rc6-6a-32): vendor=%d dev=%d code=%d\n", 121 dprintk(1, "ir hauppauge (rc6-6a-32): vendor=%d dev=%d code=%d\n",
122 vendor, dev, code); 122 vendor, dev, code);
123 } 123 }
@@ -130,13 +130,13 @@ static int get_key_haup_common(struct IR_i2c *ir, enum rc_type *protocol,
130 return 0; 130 return 0;
131} 131}
132 132
133static int get_key_haup(struct IR_i2c *ir, enum rc_type *protocol, 133static int get_key_haup(struct IR_i2c *ir, enum rc_proto *protocol,
134 u32 *scancode, u8 *toggle) 134 u32 *scancode, u8 *toggle)
135{ 135{
136 return get_key_haup_common(ir, protocol, scancode, toggle, 3); 136 return get_key_haup_common(ir, protocol, scancode, toggle, 3);
137} 137}
138 138
139static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_type *protocol, 139static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_proto *protocol,
140 u32 *scancode, u8 *toggle) 140 u32 *scancode, u8 *toggle)
141{ 141{
142 int ret; 142 int ret;
@@ -155,7 +155,7 @@ static int get_key_haup_xvr(struct IR_i2c *ir, enum rc_type *protocol,
155 return get_key_haup_common(ir, protocol, scancode, toggle, 6); 155 return get_key_haup_common(ir, protocol, scancode, toggle, 6);
156} 156}
157 157
158static int get_key_pixelview(struct IR_i2c *ir, enum rc_type *protocol, 158static int get_key_pixelview(struct IR_i2c *ir, enum rc_proto *protocol,
159 u32 *scancode, u8 *toggle) 159 u32 *scancode, u8 *toggle)
160{ 160{
161 unsigned char b; 161 unsigned char b;
@@ -166,13 +166,13 @@ static int get_key_pixelview(struct IR_i2c *ir, enum rc_type *protocol,
166 return -EIO; 166 return -EIO;
167 } 167 }
168 168
169 *protocol = RC_TYPE_OTHER; 169 *protocol = RC_PROTO_OTHER;
170 *scancode = b; 170 *scancode = b;
171 *toggle = 0; 171 *toggle = 0;
172 return 1; 172 return 1;
173} 173}
174 174
175static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_type *protocol, 175static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_proto *protocol,
176 u32 *scancode, u8 *toggle) 176 u32 *scancode, u8 *toggle)
177{ 177{
178 unsigned char buf[4]; 178 unsigned char buf[4];
@@ -191,13 +191,13 @@ static int get_key_fusionhdtv(struct IR_i2c *ir, enum rc_type *protocol,
191 if(buf[0] != 0x1 || buf[1] != 0xfe) 191 if(buf[0] != 0x1 || buf[1] != 0xfe)
192 return 0; 192 return 0;
193 193
194 *protocol = RC_TYPE_UNKNOWN; 194 *protocol = RC_PROTO_UNKNOWN;
195 *scancode = buf[2]; 195 *scancode = buf[2];
196 *toggle = 0; 196 *toggle = 0;
197 return 1; 197 return 1;
198} 198}
199 199
200static int get_key_knc1(struct IR_i2c *ir, enum rc_type *protocol, 200static int get_key_knc1(struct IR_i2c *ir, enum rc_proto *protocol,
201 u32 *scancode, u8 *toggle) 201 u32 *scancode, u8 *toggle)
202{ 202{
203 unsigned char b; 203 unsigned char b;
@@ -221,13 +221,13 @@ static int get_key_knc1(struct IR_i2c *ir, enum rc_type *protocol,
221 /* keep old data */ 221 /* keep old data */
222 return 1; 222 return 1;
223 223
224 *protocol = RC_TYPE_UNKNOWN; 224 *protocol = RC_PROTO_UNKNOWN;
225 *scancode = b; 225 *scancode = b;
226 *toggle = 0; 226 *toggle = 0;
227 return 1; 227 return 1;
228} 228}
229 229
230static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_type *protocol, 230static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_proto *protocol,
231 u32 *scancode, u8 *toggle) 231 u32 *scancode, u8 *toggle)
232{ 232{
233 unsigned char subaddr, key, keygroup; 233 unsigned char subaddr, key, keygroup;
@@ -262,7 +262,7 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_type *protocol,
262 } 262 }
263 key |= (keygroup & 1) << 6; 263 key |= (keygroup & 1) << 6;
264 264
265 *protocol = RC_TYPE_UNKNOWN; 265 *protocol = RC_PROTO_UNKNOWN;
266 *scancode = key; 266 *scancode = key;
267 if (ir->c->addr == 0x41) /* AVerMedia EM78P153 */ 267 if (ir->c->addr == 0x41) /* AVerMedia EM78P153 */
268 *scancode |= keygroup << 8; 268 *scancode |= keygroup << 8;
@@ -274,7 +274,7 @@ static int get_key_avermedia_cardbus(struct IR_i2c *ir, enum rc_type *protocol,
274 274
275static int ir_key_poll(struct IR_i2c *ir) 275static int ir_key_poll(struct IR_i2c *ir)
276{ 276{
277 enum rc_type protocol; 277 enum rc_proto protocol;
278 u32 scancode; 278 u32 scancode;
279 u8 toggle; 279 u8 toggle;
280 int rc; 280 int rc;
@@ -315,7 +315,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
315{ 315{
316 char *ir_codes = NULL; 316 char *ir_codes = NULL;
317 const char *name = NULL; 317 const char *name = NULL;
318 u64 rc_type = RC_BIT_UNKNOWN; 318 u64 rc_proto = RC_PROTO_BIT_UNKNOWN;
319 struct IR_i2c *ir; 319 struct IR_i2c *ir;
320 struct rc_dev *rc = NULL; 320 struct rc_dev *rc = NULL;
321 struct i2c_adapter *adap = client->adapter; 321 struct i2c_adapter *adap = client->adapter;
@@ -334,7 +334,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
334 case 0x64: 334 case 0x64:
335 name = "Pixelview"; 335 name = "Pixelview";
336 ir->get_key = get_key_pixelview; 336 ir->get_key = get_key_pixelview;
337 rc_type = RC_BIT_OTHER; 337 rc_proto = RC_PROTO_BIT_OTHER;
338 ir_codes = RC_MAP_EMPTY; 338 ir_codes = RC_MAP_EMPTY;
339 break; 339 break;
340 case 0x18: 340 case 0x18:
@@ -342,38 +342,39 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
342 case 0x1a: 342 case 0x1a:
343 name = "Hauppauge"; 343 name = "Hauppauge";
344 ir->get_key = get_key_haup; 344 ir->get_key = get_key_haup;
345 rc_type = RC_BIT_RC5; 345 rc_proto = RC_PROTO_BIT_RC5;
346 ir_codes = RC_MAP_HAUPPAUGE; 346 ir_codes = RC_MAP_HAUPPAUGE;
347 break; 347 break;
348 case 0x30: 348 case 0x30:
349 name = "KNC One"; 349 name = "KNC One";
350 ir->get_key = get_key_knc1; 350 ir->get_key = get_key_knc1;
351 rc_type = RC_BIT_OTHER; 351 rc_proto = RC_PROTO_BIT_OTHER;
352 ir_codes = RC_MAP_EMPTY; 352 ir_codes = RC_MAP_EMPTY;
353 break; 353 break;
354 case 0x6b: 354 case 0x6b:
355 name = "FusionHDTV"; 355 name = "FusionHDTV";
356 ir->get_key = get_key_fusionhdtv; 356 ir->get_key = get_key_fusionhdtv;
357 rc_type = RC_BIT_UNKNOWN; 357 rc_proto = RC_PROTO_BIT_UNKNOWN;
358 ir_codes = RC_MAP_FUSIONHDTV_MCE; 358 ir_codes = RC_MAP_FUSIONHDTV_MCE;
359 break; 359 break;
360 case 0x40: 360 case 0x40:
361 name = "AVerMedia Cardbus remote"; 361 name = "AVerMedia Cardbus remote";
362 ir->get_key = get_key_avermedia_cardbus; 362 ir->get_key = get_key_avermedia_cardbus;
363 rc_type = RC_BIT_OTHER; 363 rc_proto = RC_PROTO_BIT_OTHER;
364 ir_codes = RC_MAP_AVERMEDIA_CARDBUS; 364 ir_codes = RC_MAP_AVERMEDIA_CARDBUS;
365 break; 365 break;
366 case 0x41: 366 case 0x41:
367 name = "AVerMedia EM78P153"; 367 name = "AVerMedia EM78P153";
368 ir->get_key = get_key_avermedia_cardbus; 368 ir->get_key = get_key_avermedia_cardbus;
369 rc_type = RC_BIT_OTHER; 369 rc_proto = RC_PROTO_BIT_OTHER;
370 /* RM-KV remote, seems to be same as RM-K6 */ 370 /* RM-KV remote, seems to be same as RM-K6 */
371 ir_codes = RC_MAP_AVERMEDIA_M733A_RM_K6; 371 ir_codes = RC_MAP_AVERMEDIA_M733A_RM_K6;
372 break; 372 break;
373 case 0x71: 373 case 0x71:
374 name = "Hauppauge/Zilog Z8"; 374 name = "Hauppauge/Zilog Z8";
375 ir->get_key = get_key_haup_xvr; 375 ir->get_key = get_key_haup_xvr;
376 rc_type = RC_BIT_RC5 | RC_BIT_RC6_MCE | RC_BIT_RC6_6A_32; 376 rc_proto = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC6_MCE |
377 RC_PROTO_BIT_RC6_6A_32;
377 ir_codes = RC_MAP_HAUPPAUGE; 378 ir_codes = RC_MAP_HAUPPAUGE;
378 break; 379 break;
379 } 380 }
@@ -388,7 +389,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
388 389
389 name = init_data->name; 390 name = init_data->name;
390 if (init_data->type) 391 if (init_data->type)
391 rc_type = init_data->type; 392 rc_proto = init_data->type;
392 393
393 if (init_data->polling_interval) 394 if (init_data->polling_interval)
394 ir->polling_interval = init_data->polling_interval; 395 ir->polling_interval = init_data->polling_interval;
@@ -431,7 +432,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
431 ir->rc = rc; 432 ir->rc = rc;
432 433
433 /* Make sure we are all setup before going on */ 434 /* Make sure we are all setup before going on */
434 if (!name || !ir->get_key || !rc_type || !ir_codes) { 435 if (!name || !ir->get_key || !rc_proto || !ir_codes) {
435 dprintk(1, ": Unsupported device at address 0x%02x\n", 436 dprintk(1, ": Unsupported device at address 0x%02x\n",
436 addr); 437 addr);
437 err = -ENODEV; 438 err = -ENODEV;
@@ -452,14 +453,14 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
452 */ 453 */
453 rc->input_id.bustype = BUS_I2C; 454 rc->input_id.bustype = BUS_I2C;
454 rc->input_phys = ir->phys; 455 rc->input_phys = ir->phys;
455 rc->input_name = ir->name; 456 rc->device_name = ir->name;
456 457
457 /* 458 /*
458 * Initialize the other fields of rc_dev 459 * Initialize the other fields of rc_dev
459 */ 460 */
460 rc->map_name = ir->ir_codes; 461 rc->map_name = ir->ir_codes;
461 rc->allowed_protocols = rc_type; 462 rc->allowed_protocols = rc_proto;
462 rc->enabled_protocols = rc_type; 463 rc->enabled_protocols = rc_proto;
463 if (!rc->driver_name) 464 if (!rc->driver_name)
464 rc->driver_name = MODULE_NAME; 465 rc->driver_name = MODULE_NAME;
465 466
diff --git a/drivers/media/i2c/m5mols/m5mols_core.c b/drivers/media/i2c/m5mols/m5mols_core.c
index 9ccb5ee55fa9..463534d44756 100644
--- a/drivers/media/i2c/m5mols/m5mols_core.c
+++ b/drivers/media/i2c/m5mols/m5mols_core.c
@@ -457,7 +457,7 @@ static int m5mols_get_version(struct v4l2_subdev *sd)
457 457
458 v4l2_info(sd, "Manufacturer\t[%s]\n", 458 v4l2_info(sd, "Manufacturer\t[%s]\n",
459 is_manufacturer(info, REG_SAMSUNG_ELECTRO) ? 459 is_manufacturer(info, REG_SAMSUNG_ELECTRO) ?
460 "Samsung Electro-Machanics" : 460 "Samsung Electro-Mechanics" :
461 is_manufacturer(info, REG_SAMSUNG_OPTICS) ? 461 is_manufacturer(info, REG_SAMSUNG_OPTICS) ?
462 "Samsung Fiber-Optics" : 462 "Samsung Fiber-Optics" :
463 is_manufacturer(info, REG_SAMSUNG_TECHWIN) ? 463 is_manufacturer(info, REG_SAMSUNG_TECHWIN) ?
diff --git a/drivers/media/i2c/max2175.c b/drivers/media/i2c/max2175.c
index a4736a8a7792..bf0e821a2b93 100644
--- a/drivers/media/i2c/max2175.c
+++ b/drivers/media/i2c/max2175.c
@@ -1319,7 +1319,7 @@ static int max2175_probe(struct i2c_client *client,
1319 if (IS_ERR(clk)) { 1319 if (IS_ERR(clk)) {
1320 ret = PTR_ERR(clk); 1320 ret = PTR_ERR(clk);
1321 dev_err(&client->dev, "cannot get clock %d\n", ret); 1321 dev_err(&client->dev, "cannot get clock %d\n", ret);
1322 return -ENODEV; 1322 return ret;
1323 } 1323 }
1324 1324
1325 regmap = devm_regmap_init_i2c(client, &max2175_regmap_config); 1325 regmap = devm_regmap_init_i2c(client, &max2175_regmap_config);
diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index 72e71b762827..99b992e46702 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -835,7 +835,7 @@ static const struct v4l2_ctrl_ops mt9m111_ctrl_ops = {
835 .s_ctrl = mt9m111_s_ctrl, 835 .s_ctrl = mt9m111_s_ctrl,
836}; 836};
837 837
838static struct v4l2_subdev_core_ops mt9m111_subdev_core_ops = { 838static const struct v4l2_subdev_core_ops mt9m111_subdev_core_ops = {
839 .s_power = mt9m111_s_power, 839 .s_power = mt9m111_s_power,
840#ifdef CONFIG_VIDEO_ADV_DEBUG 840#ifdef CONFIG_VIDEO_ADV_DEBUG
841 .g_register = mt9m111_g_register, 841 .g_register = mt9m111_g_register,
@@ -865,7 +865,7 @@ static int mt9m111_g_mbus_config(struct v4l2_subdev *sd,
865 return 0; 865 return 0;
866} 866}
867 867
868static struct v4l2_subdev_video_ops mt9m111_subdev_video_ops = { 868static const struct v4l2_subdev_video_ops mt9m111_subdev_video_ops = {
869 .g_mbus_config = mt9m111_g_mbus_config, 869 .g_mbus_config = mt9m111_g_mbus_config,
870}; 870};
871 871
@@ -877,7 +877,7 @@ static const struct v4l2_subdev_pad_ops mt9m111_subdev_pad_ops = {
877 .set_fmt = mt9m111_set_fmt, 877 .set_fmt = mt9m111_set_fmt,
878}; 878};
879 879
880static struct v4l2_subdev_ops mt9m111_subdev_ops = { 880static const struct v4l2_subdev_ops mt9m111_subdev_ops = {
881 .core = &mt9m111_subdev_core_ops, 881 .core = &mt9m111_subdev_core_ops,
882 .video = &mt9m111_subdev_video_ops, 882 .video = &mt9m111_subdev_video_ops,
883 .pad = &mt9m111_subdev_pad_ops, 883 .pad = &mt9m111_subdev_pad_ops,
diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c
index 842017fa4aab..9d981d9f5686 100644
--- a/drivers/media/i2c/mt9t001.c
+++ b/drivers/media/i2c/mt9t001.c
@@ -822,15 +822,15 @@ static int mt9t001_close(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
822 return mt9t001_set_power(subdev, 0); 822 return mt9t001_set_power(subdev, 0);
823} 823}
824 824
825static struct v4l2_subdev_core_ops mt9t001_subdev_core_ops = { 825static const struct v4l2_subdev_core_ops mt9t001_subdev_core_ops = {
826 .s_power = mt9t001_set_power, 826 .s_power = mt9t001_set_power,
827}; 827};
828 828
829static struct v4l2_subdev_video_ops mt9t001_subdev_video_ops = { 829static const struct v4l2_subdev_video_ops mt9t001_subdev_video_ops = {
830 .s_stream = mt9t001_s_stream, 830 .s_stream = mt9t001_s_stream,
831}; 831};
832 832
833static struct v4l2_subdev_pad_ops mt9t001_subdev_pad_ops = { 833static const struct v4l2_subdev_pad_ops mt9t001_subdev_pad_ops = {
834 .enum_mbus_code = mt9t001_enum_mbus_code, 834 .enum_mbus_code = mt9t001_enum_mbus_code,
835 .enum_frame_size = mt9t001_enum_frame_size, 835 .enum_frame_size = mt9t001_enum_frame_size,
836 .get_fmt = mt9t001_get_format, 836 .get_fmt = mt9t001_get_format,
@@ -839,7 +839,7 @@ static struct v4l2_subdev_pad_ops mt9t001_subdev_pad_ops = {
839 .set_selection = mt9t001_set_selection, 839 .set_selection = mt9t001_set_selection,
840}; 840};
841 841
842static struct v4l2_subdev_ops mt9t001_subdev_ops = { 842static const struct v4l2_subdev_ops mt9t001_subdev_ops = {
843 .core = &mt9t001_subdev_core_ops, 843 .core = &mt9t001_subdev_core_ops,
844 .video = &mt9t001_subdev_video_ops, 844 .video = &mt9t001_subdev_video_ops,
845 .pad = &mt9t001_subdev_pad_ops, 845 .pad = &mt9t001_subdev_pad_ops,
diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c
index 86550d8ddfee..af7af0d14c69 100644
--- a/drivers/media/i2c/ov13858.c
+++ b/drivers/media/i2c/ov13858.c
@@ -57,16 +57,14 @@
57#define OV13858_VTS_30FPS 0x0c8e /* 30 fps */ 57#define OV13858_VTS_30FPS 0x0c8e /* 30 fps */
58#define OV13858_VTS_60FPS 0x0648 /* 60 fps */ 58#define OV13858_VTS_60FPS 0x0648 /* 60 fps */
59#define OV13858_VTS_MAX 0x7fff 59#define OV13858_VTS_MAX 0x7fff
60#define OV13858_VBLANK_MIN 56
61 60
62/* HBLANK control - read only */ 61/* HBLANK control - read only */
63#define OV13858_PPL_540MHZ 2244 62#define OV13858_PPL_270MHZ 2244
64#define OV13858_PPL_1080MHZ 4488 63#define OV13858_PPL_540MHZ 4488
65 64
66/* Exposure control */ 65/* Exposure control */
67#define OV13858_REG_EXPOSURE 0x3500 66#define OV13858_REG_EXPOSURE 0x3500
68#define OV13858_EXPOSURE_MIN 4 67#define OV13858_EXPOSURE_MIN 4
69#define OV13858_EXPOSURE_MAX (OV13858_VTS_MAX - 8)
70#define OV13858_EXPOSURE_STEP 1 68#define OV13858_EXPOSURE_STEP 1
71#define OV13858_EXPOSURE_DEFAULT 0x640 69#define OV13858_EXPOSURE_DEFAULT 0x640
72 70
@@ -78,13 +76,13 @@
78#define OV13858_ANA_GAIN_DEFAULT 0x80 76#define OV13858_ANA_GAIN_DEFAULT 0x80
79 77
80/* Digital gain control */ 78/* Digital gain control */
81#define OV13858_REG_DIGITAL_GAIN 0x350a 79#define OV13858_REG_B_MWB_GAIN 0x5100
82#define OV13858_DGTL_GAIN_MASK 0xf3 80#define OV13858_REG_G_MWB_GAIN 0x5102
83#define OV13858_DGTL_GAIN_SHIFT 2 81#define OV13858_REG_R_MWB_GAIN 0x5104
84#define OV13858_DGTL_GAIN_MIN 1 82#define OV13858_DGTL_GAIN_MIN 0
85#define OV13858_DGTL_GAIN_MAX 4 83#define OV13858_DGTL_GAIN_MAX 16384 /* Max = 16 X */
86#define OV13858_DGTL_GAIN_STEP 1 84#define OV13858_DGTL_GAIN_DEFAULT 1024 /* Default gain = 1 X */
87#define OV13858_DGTL_GAIN_DEFAULT 1 85#define OV13858_DGTL_GAIN_STEP 1 /* Each step = 1/1024 */
88 86
89/* Test Pattern Control */ 87/* Test Pattern Control */
90#define OV13858_REG_TEST_PATTERN 0x4503 88#define OV13858_REG_TEST_PATTERN 0x4503
@@ -121,7 +119,8 @@ struct ov13858_mode {
121 u32 height; 119 u32 height;
122 120
123 /* V-timing */ 121 /* V-timing */
124 u32 vts; 122 u32 vts_def;
123 u32 vts_min;
125 124
126 /* Index of Link frequency config to be used */ 125 /* Index of Link frequency config to be used */
127 u32 link_freq_index; 126 u32 link_freq_index;
@@ -944,31 +943,33 @@ static const char * const ov13858_test_pattern_menu[] = {
944 943
945/* Configurations for supported link frequencies */ 944/* Configurations for supported link frequencies */
946#define OV13858_NUM_OF_LINK_FREQS 2 945#define OV13858_NUM_OF_LINK_FREQS 2
947#define OV13858_LINK_FREQ_1080MBPS 1080000000 946#define OV13858_LINK_FREQ_540MHZ 540000000ULL
948#define OV13858_LINK_FREQ_540MBPS 540000000 947#define OV13858_LINK_FREQ_270MHZ 270000000ULL
949#define OV13858_LINK_FREQ_INDEX_0 0 948#define OV13858_LINK_FREQ_INDEX_0 0
950#define OV13858_LINK_FREQ_INDEX_1 1 949#define OV13858_LINK_FREQ_INDEX_1 1
951 950
952/* Menu items for LINK_FREQ V4L2 control */ 951/* Menu items for LINK_FREQ V4L2 control */
953static const s64 link_freq_menu_items[OV13858_NUM_OF_LINK_FREQS] = { 952static const s64 link_freq_menu_items[OV13858_NUM_OF_LINK_FREQS] = {
954 OV13858_LINK_FREQ_1080MBPS, 953 OV13858_LINK_FREQ_540MHZ,
955 OV13858_LINK_FREQ_540MBPS 954 OV13858_LINK_FREQ_270MHZ
956}; 955};
957 956
958/* Link frequency configs */ 957/* Link frequency configs */
959static const struct ov13858_link_freq_config 958static const struct ov13858_link_freq_config
960 link_freq_configs[OV13858_NUM_OF_LINK_FREQS] = { 959 link_freq_configs[OV13858_NUM_OF_LINK_FREQS] = {
961 { 960 {
962 .pixel_rate = 864000000, 961 /* pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample */
963 .pixels_per_line = OV13858_PPL_1080MHZ, 962 .pixel_rate = (OV13858_LINK_FREQ_540MHZ * 2 * 4) / 10,
963 .pixels_per_line = OV13858_PPL_540MHZ,
964 .reg_list = { 964 .reg_list = {
965 .num_of_regs = ARRAY_SIZE(mipi_data_rate_1080mbps), 965 .num_of_regs = ARRAY_SIZE(mipi_data_rate_1080mbps),
966 .regs = mipi_data_rate_1080mbps, 966 .regs = mipi_data_rate_1080mbps,
967 } 967 }
968 }, 968 },
969 { 969 {
970 .pixel_rate = 432000000, 970 /* pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample */
971 .pixels_per_line = OV13858_PPL_540MHZ, 971 .pixel_rate = (OV13858_LINK_FREQ_270MHZ * 2 * 4) / 10,
972 .pixels_per_line = OV13858_PPL_270MHZ,
972 .reg_list = { 973 .reg_list = {
973 .num_of_regs = ARRAY_SIZE(mipi_data_rate_540mbps), 974 .num_of_regs = ARRAY_SIZE(mipi_data_rate_540mbps),
974 .regs = mipi_data_rate_540mbps, 975 .regs = mipi_data_rate_540mbps,
@@ -981,7 +982,8 @@ static const struct ov13858_mode supported_modes[] = {
981 { 982 {
982 .width = 4224, 983 .width = 4224,
983 .height = 3136, 984 .height = 3136,
984 .vts = OV13858_VTS_30FPS, 985 .vts_def = OV13858_VTS_30FPS,
986 .vts_min = OV13858_VTS_30FPS,
985 .reg_list = { 987 .reg_list = {
986 .num_of_regs = ARRAY_SIZE(mode_4224x3136_regs), 988 .num_of_regs = ARRAY_SIZE(mode_4224x3136_regs),
987 .regs = mode_4224x3136_regs, 989 .regs = mode_4224x3136_regs,
@@ -991,7 +993,8 @@ static const struct ov13858_mode supported_modes[] = {
991 { 993 {
992 .width = 2112, 994 .width = 2112,
993 .height = 1568, 995 .height = 1568,
994 .vts = OV13858_VTS_30FPS, 996 .vts_def = OV13858_VTS_30FPS,
997 .vts_min = 1608,
995 .reg_list = { 998 .reg_list = {
996 .num_of_regs = ARRAY_SIZE(mode_2112x1568_regs), 999 .num_of_regs = ARRAY_SIZE(mode_2112x1568_regs),
997 .regs = mode_2112x1568_regs, 1000 .regs = mode_2112x1568_regs,
@@ -1001,7 +1004,8 @@ static const struct ov13858_mode supported_modes[] = {
1001 { 1004 {
1002 .width = 2112, 1005 .width = 2112,
1003 .height = 1188, 1006 .height = 1188,
1004 .vts = OV13858_VTS_30FPS, 1007 .vts_def = OV13858_VTS_30FPS,
1008 .vts_min = 1608,
1005 .reg_list = { 1009 .reg_list = {
1006 .num_of_regs = ARRAY_SIZE(mode_2112x1188_regs), 1010 .num_of_regs = ARRAY_SIZE(mode_2112x1188_regs),
1007 .regs = mode_2112x1188_regs, 1011 .regs = mode_2112x1188_regs,
@@ -1011,7 +1015,8 @@ static const struct ov13858_mode supported_modes[] = {
1011 { 1015 {
1012 .width = 1056, 1016 .width = 1056,
1013 .height = 784, 1017 .height = 784,
1014 .vts = OV13858_VTS_30FPS, 1018 .vts_def = OV13858_VTS_30FPS,
1019 .vts_min = 804,
1015 .reg_list = { 1020 .reg_list = {
1016 .num_of_regs = ARRAY_SIZE(mode_1056x784_regs), 1021 .num_of_regs = ARRAY_SIZE(mode_1056x784_regs),
1017 .regs = mode_1056x784_regs, 1022 .regs = mode_1056x784_regs,
@@ -1161,21 +1166,21 @@ static int ov13858_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1161static int ov13858_update_digital_gain(struct ov13858 *ov13858, u32 d_gain) 1166static int ov13858_update_digital_gain(struct ov13858 *ov13858, u32 d_gain)
1162{ 1167{
1163 int ret; 1168 int ret;
1164 u32 val;
1165 1169
1166 if (d_gain == 3) 1170 ret = ov13858_write_reg(ov13858, OV13858_REG_B_MWB_GAIN,
1167 return -EINVAL; 1171 OV13858_REG_VALUE_16BIT, d_gain);
1172 if (ret)
1173 return ret;
1168 1174
1169 ret = ov13858_read_reg(ov13858, OV13858_REG_DIGITAL_GAIN, 1175 ret = ov13858_write_reg(ov13858, OV13858_REG_G_MWB_GAIN,
1170 OV13858_REG_VALUE_08BIT, &val); 1176 OV13858_REG_VALUE_16BIT, d_gain);
1171 if (ret) 1177 if (ret)
1172 return ret; 1178 return ret;
1173 1179
1174 val &= OV13858_DGTL_GAIN_MASK; 1180 ret = ov13858_write_reg(ov13858, OV13858_REG_R_MWB_GAIN,
1175 val |= (d_gain - 1) << OV13858_DGTL_GAIN_SHIFT; 1181 OV13858_REG_VALUE_16BIT, d_gain);
1176 1182
1177 return ov13858_write_reg(ov13858, OV13858_REG_DIGITAL_GAIN, 1183 return ret;
1178 OV13858_REG_VALUE_08BIT, val);
1179} 1184}
1180 1185
1181static int ov13858_enable_test_pattern(struct ov13858 *ov13858, u32 pattern) 1186static int ov13858_enable_test_pattern(struct ov13858 *ov13858, u32 pattern)
@@ -1377,6 +1382,8 @@ ov13858_set_pad_format(struct v4l2_subdev *sd,
1377 struct ov13858 *ov13858 = to_ov13858(sd); 1382 struct ov13858 *ov13858 = to_ov13858(sd);
1378 const struct ov13858_mode *mode; 1383 const struct ov13858_mode *mode;
1379 struct v4l2_mbus_framefmt *framefmt; 1384 struct v4l2_mbus_framefmt *framefmt;
1385 s32 vblank_def;
1386 s32 vblank_min;
1380 s64 h_blank; 1387 s64 h_blank;
1381 1388
1382 mutex_lock(&ov13858->mutex); 1389 mutex_lock(&ov13858->mutex);
@@ -1397,10 +1404,15 @@ ov13858_set_pad_format(struct v4l2_subdev *sd,
1397 ov13858->pixel_rate, 1404 ov13858->pixel_rate,
1398 link_freq_configs[mode->link_freq_index].pixel_rate); 1405 link_freq_configs[mode->link_freq_index].pixel_rate);
1399 /* Update limits and set FPS to default */ 1406 /* Update limits and set FPS to default */
1407 vblank_def = ov13858->cur_mode->vts_def -
1408 ov13858->cur_mode->height;
1409 vblank_min = ov13858->cur_mode->vts_min -
1410 ov13858->cur_mode->height;
1400 __v4l2_ctrl_modify_range( 1411 __v4l2_ctrl_modify_range(
1401 ov13858->vblank, OV13858_VBLANK_MIN, 1412 ov13858->vblank, vblank_min,
1402 OV13858_VTS_MAX - ov13858->cur_mode->height, 1, 1413 OV13858_VTS_MAX - ov13858->cur_mode->height, 1,
1403 ov13858->cur_mode->vts - ov13858->cur_mode->height); 1414 vblank_def);
1415 __v4l2_ctrl_s_ctrl(ov13858->vblank, vblank_def);
1404 h_blank = 1416 h_blank =
1405 link_freq_configs[mode->link_freq_index].pixels_per_line 1417 link_freq_configs[mode->link_freq_index].pixels_per_line
1406 - ov13858->cur_mode->width; 1418 - ov13858->cur_mode->width;
@@ -1602,6 +1614,9 @@ static int ov13858_init_controls(struct ov13858 *ov13858)
1602{ 1614{
1603 struct i2c_client *client = v4l2_get_subdevdata(&ov13858->sd); 1615 struct i2c_client *client = v4l2_get_subdevdata(&ov13858->sd);
1604 struct v4l2_ctrl_handler *ctrl_hdlr; 1616 struct v4l2_ctrl_handler *ctrl_hdlr;
1617 s64 exposure_max;
1618 s64 vblank_def;
1619 s64 vblank_min;
1605 int ret; 1620 int ret;
1606 1621
1607 ctrl_hdlr = &ov13858->ctrl_handler; 1622 ctrl_hdlr = &ov13858->ctrl_handler;
@@ -1625,25 +1640,27 @@ static int ov13858_init_controls(struct ov13858 *ov13858)
1625 link_freq_configs[0].pixel_rate, 1, 1640 link_freq_configs[0].pixel_rate, 1,
1626 link_freq_configs[0].pixel_rate); 1641 link_freq_configs[0].pixel_rate);
1627 1642
1643 vblank_def = ov13858->cur_mode->vts_def - ov13858->cur_mode->height;
1644 vblank_min = ov13858->cur_mode->vts_min - ov13858->cur_mode->height;
1628 ov13858->vblank = v4l2_ctrl_new_std( 1645 ov13858->vblank = v4l2_ctrl_new_std(
1629 ctrl_hdlr, &ov13858_ctrl_ops, V4L2_CID_VBLANK, 1646 ctrl_hdlr, &ov13858_ctrl_ops, V4L2_CID_VBLANK,
1630 OV13858_VBLANK_MIN, 1647 vblank_min,
1631 OV13858_VTS_MAX - ov13858->cur_mode->height, 1, 1648 OV13858_VTS_MAX - ov13858->cur_mode->height, 1,
1632 ov13858->cur_mode->vts 1649 vblank_def);
1633 - ov13858->cur_mode->height);
1634 1650
1635 ov13858->hblank = v4l2_ctrl_new_std( 1651 ov13858->hblank = v4l2_ctrl_new_std(
1636 ctrl_hdlr, &ov13858_ctrl_ops, V4L2_CID_HBLANK, 1652 ctrl_hdlr, &ov13858_ctrl_ops, V4L2_CID_HBLANK,
1637 OV13858_PPL_1080MHZ - ov13858->cur_mode->width, 1653 OV13858_PPL_540MHZ - ov13858->cur_mode->width,
1638 OV13858_PPL_1080MHZ - ov13858->cur_mode->width, 1654 OV13858_PPL_540MHZ - ov13858->cur_mode->width,
1639 1, 1655 1,
1640 OV13858_PPL_1080MHZ - ov13858->cur_mode->width); 1656 OV13858_PPL_540MHZ - ov13858->cur_mode->width);
1641 ov13858->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; 1657 ov13858->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
1642 1658
1659 exposure_max = ov13858->cur_mode->vts_def - 8;
1643 ov13858->exposure = v4l2_ctrl_new_std( 1660 ov13858->exposure = v4l2_ctrl_new_std(
1644 ctrl_hdlr, &ov13858_ctrl_ops, 1661 ctrl_hdlr, &ov13858_ctrl_ops,
1645 V4L2_CID_EXPOSURE, OV13858_EXPOSURE_MIN, 1662 V4L2_CID_EXPOSURE, OV13858_EXPOSURE_MIN,
1646 OV13858_EXPOSURE_MAX, OV13858_EXPOSURE_STEP, 1663 exposure_max, OV13858_EXPOSURE_STEP,
1647 OV13858_EXPOSURE_DEFAULT); 1664 OV13858_EXPOSURE_DEFAULT);
1648 1665
1649 v4l2_ctrl_new_std(ctrl_hdlr, &ov13858_ctrl_ops, V4L2_CID_ANALOGUE_GAIN, 1666 v4l2_ctrl_new_std(ctrl_hdlr, &ov13858_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 1f5b483cf334..39a2269c0bee 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -1524,8 +1524,7 @@ static int ov5640_restore_mode(struct ov5640_dev *sensor)
1524 1524
1525static void ov5640_power(struct ov5640_dev *sensor, bool enable) 1525static void ov5640_power(struct ov5640_dev *sensor, bool enable)
1526{ 1526{
1527 if (sensor->pwdn_gpio) 1527 gpiod_set_value(sensor->pwdn_gpio, enable ? 0 : 1);
1528 gpiod_set_value(sensor->pwdn_gpio, enable ? 0 : 1);
1529} 1528}
1530 1529
1531static void ov5640_reset(struct ov5640_dev *sensor) 1530static void ov5640_reset(struct ov5640_dev *sensor)
diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index d1e844f7f03f..d28845f7356f 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -80,6 +80,8 @@ struct ov5645_mode_info {
80 u32 height; 80 u32 height;
81 const struct reg_value *data; 81 const struct reg_value *data;
82 u32 data_size; 82 u32 data_size;
83 u32 pixel_clock;
84 u32 link_freq;
83}; 85};
84 86
85struct ov5645 { 87struct ov5645 {
@@ -99,6 +101,8 @@ struct ov5645 {
99 const struct ov5645_mode_info *current_mode; 101 const struct ov5645_mode_info *current_mode;
100 102
101 struct v4l2_ctrl_handler ctrls; 103 struct v4l2_ctrl_handler ctrls;
104 struct v4l2_ctrl *pixel_clock;
105 struct v4l2_ctrl *link_freq;
102 106
103 /* Cached register values */ 107 /* Cached register values */
104 u8 aec_pk_manual; 108 u8 aec_pk_manual;
@@ -505,24 +509,35 @@ static const struct reg_value ov5645_setting_full[] = {
505 { 0x4202, 0x00 } 509 { 0x4202, 0x00 }
506}; 510};
507 511
512static const s64 link_freq[] = {
513 222880000,
514 334320000
515};
516
508static const struct ov5645_mode_info ov5645_mode_info_data[] = { 517static const struct ov5645_mode_info ov5645_mode_info_data[] = {
509 { 518 {
510 .width = 1280, 519 .width = 1280,
511 .height = 960, 520 .height = 960,
512 .data = ov5645_setting_sxga, 521 .data = ov5645_setting_sxga,
513 .data_size = ARRAY_SIZE(ov5645_setting_sxga) 522 .data_size = ARRAY_SIZE(ov5645_setting_sxga),
523 .pixel_clock = 111440000,
524 .link_freq = 0 /* an index in link_freq[] */
514 }, 525 },
515 { 526 {
516 .width = 1920, 527 .width = 1920,
517 .height = 1080, 528 .height = 1080,
518 .data = ov5645_setting_1080p, 529 .data = ov5645_setting_1080p,
519 .data_size = ARRAY_SIZE(ov5645_setting_1080p) 530 .data_size = ARRAY_SIZE(ov5645_setting_1080p),
531 .pixel_clock = 167160000,
532 .link_freq = 1 /* an index in link_freq[] */
520 }, 533 },
521 { 534 {
522 .width = 2592, 535 .width = 2592,
523 .height = 1944, 536 .height = 1944,
524 .data = ov5645_setting_full, 537 .data = ov5645_setting_full,
525 .data_size = ARRAY_SIZE(ov5645_setting_full) 538 .data_size = ARRAY_SIZE(ov5645_setting_full),
539 .pixel_clock = 167160000,
540 .link_freq = 1 /* an index in link_freq[] */
526 }, 541 },
527}; 542};
528 543
@@ -969,6 +984,7 @@ static int ov5645_set_format(struct v4l2_subdev *sd,
969 struct v4l2_mbus_framefmt *__format; 984 struct v4l2_mbus_framefmt *__format;
970 struct v4l2_rect *__crop; 985 struct v4l2_rect *__crop;
971 const struct ov5645_mode_info *new_mode; 986 const struct ov5645_mode_info *new_mode;
987 int ret;
972 988
973 __crop = __ov5645_get_pad_crop(ov5645, cfg, format->pad, 989 __crop = __ov5645_get_pad_crop(ov5645, cfg, format->pad,
974 format->which); 990 format->which);
@@ -978,8 +994,19 @@ static int ov5645_set_format(struct v4l2_subdev *sd,
978 __crop->width = new_mode->width; 994 __crop->width = new_mode->width;
979 __crop->height = new_mode->height; 995 __crop->height = new_mode->height;
980 996
981 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 997 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
998 ret = v4l2_ctrl_s_ctrl_int64(ov5645->pixel_clock,
999 new_mode->pixel_clock);
1000 if (ret < 0)
1001 return ret;
1002
1003 ret = v4l2_ctrl_s_ctrl(ov5645->link_freq,
1004 new_mode->link_freq);
1005 if (ret < 0)
1006 return ret;
1007
982 ov5645->current_mode = new_mode; 1008 ov5645->current_mode = new_mode;
1009 }
983 1010
984 __format = __ov5645_get_pad_format(ov5645, cfg, format->pad, 1011 __format = __ov5645_get_pad_format(ov5645, cfg, format->pad,
985 format->which); 1012 format->which);
@@ -1197,7 +1224,7 @@ static int ov5645_probe(struct i2c_client *client,
1197 1224
1198 mutex_init(&ov5645->power_lock); 1225 mutex_init(&ov5645->power_lock);
1199 1226
1200 v4l2_ctrl_handler_init(&ov5645->ctrls, 7); 1227 v4l2_ctrl_handler_init(&ov5645->ctrls, 9);
1201 v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops, 1228 v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
1202 V4L2_CID_SATURATION, -4, 4, 1, 0); 1229 V4L2_CID_SATURATION, -4, 4, 1, 0);
1203 v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops, 1230 v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
@@ -1215,6 +1242,17 @@ static int ov5645_probe(struct i2c_client *client,
1215 V4L2_CID_TEST_PATTERN, 1242 V4L2_CID_TEST_PATTERN,
1216 ARRAY_SIZE(ov5645_test_pattern_menu) - 1, 1243 ARRAY_SIZE(ov5645_test_pattern_menu) - 1,
1217 0, 0, ov5645_test_pattern_menu); 1244 0, 0, ov5645_test_pattern_menu);
1245 ov5645->pixel_clock = v4l2_ctrl_new_std(&ov5645->ctrls,
1246 &ov5645_ctrl_ops,
1247 V4L2_CID_PIXEL_RATE,
1248 1, INT_MAX, 1, 1);
1249 ov5645->link_freq = v4l2_ctrl_new_int_menu(&ov5645->ctrls,
1250 &ov5645_ctrl_ops,
1251 V4L2_CID_LINK_FREQ,
1252 ARRAY_SIZE(link_freq) - 1,
1253 0, link_freq);
1254 if (ov5645->link_freq)
1255 ov5645->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
1218 1256
1219 ov5645->sd.ctrl_handler = &ov5645->ctrls; 1257 ov5645->sd.ctrl_handler = &ov5645->ctrls;
1220 1258
@@ -1229,6 +1267,7 @@ static int ov5645_probe(struct i2c_client *client,
1229 ov5645->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; 1267 ov5645->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
1230 ov5645->pad.flags = MEDIA_PAD_FL_SOURCE; 1268 ov5645->pad.flags = MEDIA_PAD_FL_SOURCE;
1231 ov5645->sd.dev = &client->dev; 1269 ov5645->sd.dev = &client->dev;
1270 ov5645->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
1232 1271
1233 ret = media_entity_pads_init(&ov5645->sd.entity, 1, &ov5645->pad); 1272 ret = media_entity_pads_init(&ov5645->sd.entity, 1, &ov5645->pad);
1234 if (ret < 0) { 1273 if (ret < 0) {
diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
new file mode 100644
index 000000000000..6f7a1d6d2200
--- /dev/null
+++ b/drivers/media/i2c/ov5670.c
@@ -0,0 +1,2601 @@
1/*
2 * Copyright (c) 2017 Intel Corporation.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License version
6 * 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#include <linux/acpi.h>
16#include <linux/i2c.h>
17#include <linux/module.h>
18#include <linux/pm_runtime.h>
19#include <media/v4l2-ctrls.h>
20#include <media/v4l2-device.h>
21
22#define OV5670_REG_CHIP_ID 0x300a
23#define OV5670_CHIP_ID 0x005670
24
25#define OV5670_REG_MODE_SELECT 0x0100
26#define OV5670_MODE_STANDBY 0x00
27#define OV5670_MODE_STREAMING 0x01
28
29#define OV5670_REG_SOFTWARE_RST 0x0103
30#define OV5670_SOFTWARE_RST 0x01
31
32/* vertical-timings from sensor */
33#define OV5670_REG_VTS 0x380e
34#define OV5670_VTS_30FPS 0x0808 /* default for 30 fps */
35#define OV5670_VTS_MAX 0xffff
36
37/* horizontal-timings from sensor */
38#define OV5670_REG_HTS 0x380c
39
40/*
41 * Pixels-per-line(PPL) = Time-per-line * pixel-rate
42 * In OV5670, Time-per-line = HTS/SCLK.
43 * HTS is fixed for all resolutions, not recommended to change.
44 */
45#define OV5670_FIXED_PPL 2724 /* Pixels per line */
46
47/* Exposure controls from sensor */
48#define OV5670_REG_EXPOSURE 0x3500
49#define OV5670_EXPOSURE_MIN 4
50#define OV5670_EXPOSURE_STEP 1
51
52/* Analog gain controls from sensor */
53#define OV5670_REG_ANALOG_GAIN 0x3508
54#define ANALOG_GAIN_MIN 0
55#define ANALOG_GAIN_MAX 8191
56#define ANALOG_GAIN_STEP 1
57#define ANALOG_GAIN_DEFAULT 128
58
59/* Digital gain controls from sensor */
60#define OV5670_REG_R_DGTL_GAIN 0x5032
61#define OV5670_REG_G_DGTL_GAIN 0x5034
62#define OV5670_REG_B_DGTL_GAIN 0x5036
63#define OV5670_DGTL_GAIN_MIN 0
64#define OV5670_DGTL_GAIN_MAX 4095
65#define OV5670_DGTL_GAIN_STEP 1
66#define OV5670_DGTL_GAIN_DEFAULT 1024
67
68/* Test Pattern Control */
69#define OV5670_REG_TEST_PATTERN 0x4303
70#define OV5670_TEST_PATTERN_ENABLE BIT(3)
71#define OV5670_REG_TEST_PATTERN_CTRL 0x4320
72
73#define OV5670_REG_VALUE_08BIT 1
74#define OV5670_REG_VALUE_16BIT 2
75#define OV5670_REG_VALUE_24BIT 3
76
77/* Initial number of frames to skip to avoid possible garbage */
78#define OV5670_NUM_OF_SKIP_FRAMES 2
79
80struct ov5670_reg {
81 u16 address;
82 u8 val;
83};
84
85struct ov5670_reg_list {
86 u32 num_of_regs;
87 const struct ov5670_reg *regs;
88};
89
90struct ov5670_link_freq_config {
91 u32 pixel_rate;
92 const struct ov5670_reg_list reg_list;
93};
94
95struct ov5670_mode {
96 /* Frame width in pixels */
97 u32 width;
98
99 /* Frame height in pixels */
100 u32 height;
101
102 /* Default vertical timining size */
103 u32 vts_def;
104
105 /* Min vertical timining size */
106 u32 vts_min;
107
108 /* Link frequency needed for this resolution */
109 u32 link_freq_index;
110
111 /* Sensor register settings for this resolution */
112 const struct ov5670_reg_list reg_list;
113};
114
115static const struct ov5670_reg mipi_data_rate_840mbps[] = {
116 {0x0300, 0x04},
117 {0x0301, 0x00},
118 {0x0302, 0x84},
119 {0x0303, 0x00},
120 {0x0304, 0x03},
121 {0x0305, 0x01},
122 {0x0306, 0x01},
123 {0x030a, 0x00},
124 {0x030b, 0x00},
125 {0x030c, 0x00},
126 {0x030d, 0x26},
127 {0x030e, 0x00},
128 {0x030f, 0x06},
129 {0x0312, 0x01},
130 {0x3031, 0x0a},
131};
132
133static const struct ov5670_reg mode_2592x1944_regs[] = {
134 {0x3000, 0x00},
135 {0x3002, 0x21},
136 {0x3005, 0xf0},
137 {0x3007, 0x00},
138 {0x3015, 0x0f},
139 {0x3018, 0x32},
140 {0x301a, 0xf0},
141 {0x301b, 0xf0},
142 {0x301c, 0xf0},
143 {0x301d, 0xf0},
144 {0x301e, 0xf0},
145 {0x3030, 0x00},
146 {0x3031, 0x0a},
147 {0x303c, 0xff},
148 {0x303e, 0xff},
149 {0x3040, 0xf0},
150 {0x3041, 0x00},
151 {0x3042, 0xf0},
152 {0x3106, 0x11},
153 {0x3500, 0x00},
154 {0x3501, 0x80},
155 {0x3502, 0x00},
156 {0x3503, 0x04},
157 {0x3504, 0x03},
158 {0x3505, 0x83},
159 {0x3508, 0x04},
160 {0x3509, 0x00},
161 {0x350e, 0x04},
162 {0x350f, 0x00},
163 {0x3510, 0x00},
164 {0x3511, 0x02},
165 {0x3512, 0x00},
166 {0x3601, 0xc8},
167 {0x3610, 0x88},
168 {0x3612, 0x48},
169 {0x3614, 0x5b},
170 {0x3615, 0x96},
171 {0x3621, 0xd0},
172 {0x3622, 0x00},
173 {0x3623, 0x00},
174 {0x3633, 0x13},
175 {0x3634, 0x13},
176 {0x3635, 0x13},
177 {0x3636, 0x13},
178 {0x3645, 0x13},
179 {0x3646, 0x82},
180 {0x3650, 0x00},
181 {0x3652, 0xff},
182 {0x3655, 0x20},
183 {0x3656, 0xff},
184 {0x365a, 0xff},
185 {0x365e, 0xff},
186 {0x3668, 0x00},
187 {0x366a, 0x07},
188 {0x366e, 0x10},
189 {0x366d, 0x00},
190 {0x366f, 0x80},
191 {0x3700, 0x28},
192 {0x3701, 0x10},
193 {0x3702, 0x3a},
194 {0x3703, 0x19},
195 {0x3704, 0x10},
196 {0x3705, 0x00},
197 {0x3706, 0x66},
198 {0x3707, 0x08},
199 {0x3708, 0x34},
200 {0x3709, 0x40},
201 {0x370a, 0x01},
202 {0x370b, 0x1b},
203 {0x3714, 0x24},
204 {0x371a, 0x3e},
205 {0x3733, 0x00},
206 {0x3734, 0x00},
207 {0x373a, 0x05},
208 {0x373b, 0x06},
209 {0x373c, 0x0a},
210 {0x373f, 0xa0},
211 {0x3755, 0x00},
212 {0x3758, 0x00},
213 {0x375b, 0x0e},
214 {0x3766, 0x5f},
215 {0x3768, 0x00},
216 {0x3769, 0x22},
217 {0x3773, 0x08},
218 {0x3774, 0x1f},
219 {0x3776, 0x06},
220 {0x37a0, 0x88},
221 {0x37a1, 0x5c},
222 {0x37a7, 0x88},
223 {0x37a8, 0x70},
224 {0x37aa, 0x88},
225 {0x37ab, 0x48},
226 {0x37b3, 0x66},
227 {0x37c2, 0x04},
228 {0x37c5, 0x00},
229 {0x37c8, 0x00},
230 {0x3800, 0x00},
231 {0x3801, 0x0c},
232 {0x3802, 0x00},
233 {0x3803, 0x04},
234 {0x3804, 0x0a},
235 {0x3805, 0x33},
236 {0x3806, 0x07},
237 {0x3807, 0xa3},
238 {0x3808, 0x0a},
239 {0x3809, 0x20},
240 {0x380a, 0x07},
241 {0x380b, 0x98},
242 {0x380c, 0x06},
243 {0x380d, 0x90},
244 {0x380e, 0x08},
245 {0x380f, 0x08},
246 {0x3811, 0x04},
247 {0x3813, 0x02},
248 {0x3814, 0x01},
249 {0x3815, 0x01},
250 {0x3816, 0x00},
251 {0x3817, 0x00},
252 {0x3818, 0x00},
253 {0x3819, 0x00},
254 {0x3820, 0x84},
255 {0x3821, 0x46},
256 {0x3822, 0x48},
257 {0x3826, 0x00},
258 {0x3827, 0x08},
259 {0x382a, 0x01},
260 {0x382b, 0x01},
261 {0x3830, 0x08},
262 {0x3836, 0x02},
263 {0x3837, 0x00},
264 {0x3838, 0x10},
265 {0x3841, 0xff},
266 {0x3846, 0x48},
267 {0x3861, 0x00},
268 {0x3862, 0x04},
269 {0x3863, 0x06},
270 {0x3a11, 0x01},
271 {0x3a12, 0x78},
272 {0x3b00, 0x00},
273 {0x3b02, 0x00},
274 {0x3b03, 0x00},
275 {0x3b04, 0x00},
276 {0x3b05, 0x00},
277 {0x3c00, 0x89},
278 {0x3c01, 0xab},
279 {0x3c02, 0x01},
280 {0x3c03, 0x00},
281 {0x3c04, 0x00},
282 {0x3c05, 0x03},
283 {0x3c06, 0x00},
284 {0x3c07, 0x05},
285 {0x3c0c, 0x00},
286 {0x3c0d, 0x00},
287 {0x3c0e, 0x00},
288 {0x3c0f, 0x00},
289 {0x3c40, 0x00},
290 {0x3c41, 0xa3},
291 {0x3c43, 0x7d},
292 {0x3c45, 0xd7},
293 {0x3c47, 0xfc},
294 {0x3c50, 0x05},
295 {0x3c52, 0xaa},
296 {0x3c54, 0x71},
297 {0x3c56, 0x80},
298 {0x3d85, 0x17},
299 {0x3f03, 0x00},
300 {0x3f0a, 0x00},
301 {0x3f0b, 0x00},
302 {0x4001, 0x60},
303 {0x4009, 0x0d},
304 {0x4020, 0x00},
305 {0x4021, 0x00},
306 {0x4022, 0x00},
307 {0x4023, 0x00},
308 {0x4024, 0x00},
309 {0x4025, 0x00},
310 {0x4026, 0x00},
311 {0x4027, 0x00},
312 {0x4028, 0x00},
313 {0x4029, 0x00},
314 {0x402a, 0x00},
315 {0x402b, 0x00},
316 {0x402c, 0x00},
317 {0x402d, 0x00},
318 {0x402e, 0x00},
319 {0x402f, 0x00},
320 {0x4040, 0x00},
321 {0x4041, 0x03},
322 {0x4042, 0x00},
323 {0x4043, 0x7A},
324 {0x4044, 0x00},
325 {0x4045, 0x7A},
326 {0x4046, 0x00},
327 {0x4047, 0x7A},
328 {0x4048, 0x00},
329 {0x4049, 0x7A},
330 {0x4307, 0x30},
331 {0x4500, 0x58},
332 {0x4501, 0x04},
333 {0x4502, 0x40},
334 {0x4503, 0x10},
335 {0x4508, 0xaa},
336 {0x4509, 0xaa},
337 {0x450a, 0x00},
338 {0x450b, 0x00},
339 {0x4600, 0x01},
340 {0x4601, 0x03},
341 {0x4700, 0xa4},
342 {0x4800, 0x4c},
343 {0x4816, 0x53},
344 {0x481f, 0x40},
345 {0x4837, 0x13},
346 {0x5000, 0x56},
347 {0x5001, 0x01},
348 {0x5002, 0x28},
349 {0x5004, 0x0c},
350 {0x5006, 0x0c},
351 {0x5007, 0xe0},
352 {0x5008, 0x01},
353 {0x5009, 0xb0},
354 {0x5901, 0x00},
355 {0x5a01, 0x00},
356 {0x5a03, 0x00},
357 {0x5a04, 0x0c},
358 {0x5a05, 0xe0},
359 {0x5a06, 0x09},
360 {0x5a07, 0xb0},
361 {0x5a08, 0x06},
362 {0x5e00, 0x00},
363 {0x3734, 0x40},
364 {0x5b00, 0x01},
365 {0x5b01, 0x10},
366 {0x5b02, 0x01},
367 {0x5b03, 0xdb},
368 {0x3d8c, 0x71},
369 {0x3d8d, 0xea},
370 {0x4017, 0x08},
371 {0x3618, 0x2a},
372 {0x5780, 0x3e},
373 {0x5781, 0x0f},
374 {0x5782, 0x44},
375 {0x5783, 0x02},
376 {0x5784, 0x01},
377 {0x5785, 0x01},
378 {0x5786, 0x00},
379 {0x5787, 0x04},
380 {0x5788, 0x02},
381 {0x5789, 0x0f},
382 {0x578a, 0xfd},
383 {0x578b, 0xf5},
384 {0x578c, 0xf5},
385 {0x578d, 0x03},
386 {0x578e, 0x08},
387 {0x578f, 0x0c},
388 {0x5790, 0x08},
389 {0x5791, 0x06},
390 {0x5792, 0x00},
391 {0x5793, 0x52},
392 {0x5794, 0xa3},
393 {0x3503, 0x00}
394};
395
396static const struct ov5670_reg mode_1296x972_regs[] = {
397 {0x3000, 0x00},
398 {0x3002, 0x21},
399 {0x3005, 0xf0},
400 {0x3007, 0x00},
401 {0x3015, 0x0f},
402 {0x3018, 0x32},
403 {0x301a, 0xf0},
404 {0x301b, 0xf0},
405 {0x301c, 0xf0},
406 {0x301d, 0xf0},
407 {0x301e, 0xf0},
408 {0x3030, 0x00},
409 {0x3031, 0x0a},
410 {0x303c, 0xff},
411 {0x303e, 0xff},
412 {0x3040, 0xf0},
413 {0x3041, 0x00},
414 {0x3042, 0xf0},
415 {0x3106, 0x11},
416 {0x3500, 0x00},
417 {0x3501, 0x80},
418 {0x3502, 0x00},
419 {0x3503, 0x04},
420 {0x3504, 0x03},
421 {0x3505, 0x83},
422 {0x3508, 0x07},
423 {0x3509, 0x80},
424 {0x350e, 0x04},
425 {0x350f, 0x00},
426 {0x3510, 0x00},
427 {0x3511, 0x02},
428 {0x3512, 0x00},
429 {0x3601, 0xc8},
430 {0x3610, 0x88},
431 {0x3612, 0x48},
432 {0x3614, 0x5b},
433 {0x3615, 0x96},
434 {0x3621, 0xd0},
435 {0x3622, 0x00},
436 {0x3623, 0x00},
437 {0x3633, 0x13},
438 {0x3634, 0x13},
439 {0x3635, 0x13},
440 {0x3636, 0x13},
441 {0x3645, 0x13},
442 {0x3646, 0x82},
443 {0x3650, 0x00},
444 {0x3652, 0xff},
445 {0x3655, 0x20},
446 {0x3656, 0xff},
447 {0x365a, 0xff},
448 {0x365e, 0xff},
449 {0x3668, 0x00},
450 {0x366a, 0x07},
451 {0x366e, 0x08},
452 {0x366d, 0x00},
453 {0x366f, 0x80},
454 {0x3700, 0x28},
455 {0x3701, 0x10},
456 {0x3702, 0x3a},
457 {0x3703, 0x19},
458 {0x3704, 0x10},
459 {0x3705, 0x00},
460 {0x3706, 0x66},
461 {0x3707, 0x08},
462 {0x3708, 0x34},
463 {0x3709, 0x40},
464 {0x370a, 0x01},
465 {0x370b, 0x1b},
466 {0x3714, 0x24},
467 {0x371a, 0x3e},
468 {0x3733, 0x00},
469 {0x3734, 0x00},
470 {0x373a, 0x05},
471 {0x373b, 0x06},
472 {0x373c, 0x0a},
473 {0x373f, 0xa0},
474 {0x3755, 0x00},
475 {0x3758, 0x00},
476 {0x375b, 0x0e},
477 {0x3766, 0x5f},
478 {0x3768, 0x00},
479 {0x3769, 0x22},
480 {0x3773, 0x08},
481 {0x3774, 0x1f},
482 {0x3776, 0x06},
483 {0x37a0, 0x88},
484 {0x37a1, 0x5c},
485 {0x37a7, 0x88},
486 {0x37a8, 0x70},
487 {0x37aa, 0x88},
488 {0x37ab, 0x48},
489 {0x37b3, 0x66},
490 {0x37c2, 0x04},
491 {0x37c5, 0x00},
492 {0x37c8, 0x00},
493 {0x3800, 0x00},
494 {0x3801, 0x0c},
495 {0x3802, 0x00},
496 {0x3803, 0x04},
497 {0x3804, 0x0a},
498 {0x3805, 0x33},
499 {0x3806, 0x07},
500 {0x3807, 0xa3},
501 {0x3808, 0x05},
502 {0x3809, 0x10},
503 {0x380a, 0x03},
504 {0x380b, 0xcc},
505 {0x380c, 0x06},
506 {0x380d, 0x90},
507 {0x380e, 0x08},
508 {0x380f, 0x08},
509 {0x3811, 0x04},
510 {0x3813, 0x04},
511 {0x3814, 0x03},
512 {0x3815, 0x01},
513 {0x3816, 0x00},
514 {0x3817, 0x00},
515 {0x3818, 0x00},
516 {0x3819, 0x00},
517 {0x3820, 0x94},
518 {0x3821, 0x47},
519 {0x3822, 0x48},
520 {0x3826, 0x00},
521 {0x3827, 0x08},
522 {0x382a, 0x03},
523 {0x382b, 0x01},
524 {0x3830, 0x08},
525 {0x3836, 0x02},
526 {0x3837, 0x00},
527 {0x3838, 0x10},
528 {0x3841, 0xff},
529 {0x3846, 0x48},
530 {0x3861, 0x00},
531 {0x3862, 0x04},
532 {0x3863, 0x06},
533 {0x3a11, 0x01},
534 {0x3a12, 0x78},
535 {0x3b00, 0x00},
536 {0x3b02, 0x00},
537 {0x3b03, 0x00},
538 {0x3b04, 0x00},
539 {0x3b05, 0x00},
540 {0x3c00, 0x89},
541 {0x3c01, 0xab},
542 {0x3c02, 0x01},
543 {0x3c03, 0x00},
544 {0x3c04, 0x00},
545 {0x3c05, 0x03},
546 {0x3c06, 0x00},
547 {0x3c07, 0x05},
548 {0x3c0c, 0x00},
549 {0x3c0d, 0x00},
550 {0x3c0e, 0x00},
551 {0x3c0f, 0x00},
552 {0x3c40, 0x00},
553 {0x3c41, 0xa3},
554 {0x3c43, 0x7d},
555 {0x3c45, 0xd7},
556 {0x3c47, 0xfc},
557 {0x3c50, 0x05},
558 {0x3c52, 0xaa},
559 {0x3c54, 0x71},
560 {0x3c56, 0x80},
561 {0x3d85, 0x17},
562 {0x3f03, 0x00},
563 {0x3f0a, 0x00},
564 {0x3f0b, 0x00},
565 {0x4001, 0x60},
566 {0x4009, 0x05},
567 {0x4020, 0x00},
568 {0x4021, 0x00},
569 {0x4022, 0x00},
570 {0x4023, 0x00},
571 {0x4024, 0x00},
572 {0x4025, 0x00},
573 {0x4026, 0x00},
574 {0x4027, 0x00},
575 {0x4028, 0x00},
576 {0x4029, 0x00},
577 {0x402a, 0x00},
578 {0x402b, 0x00},
579 {0x402c, 0x00},
580 {0x402d, 0x00},
581 {0x402e, 0x00},
582 {0x402f, 0x00},
583 {0x4040, 0x00},
584 {0x4041, 0x03},
585 {0x4042, 0x00},
586 {0x4043, 0x7A},
587 {0x4044, 0x00},
588 {0x4045, 0x7A},
589 {0x4046, 0x00},
590 {0x4047, 0x7A},
591 {0x4048, 0x00},
592 {0x4049, 0x7A},
593 {0x4307, 0x30},
594 {0x4500, 0x58},
595 {0x4501, 0x04},
596 {0x4502, 0x48},
597 {0x4503, 0x10},
598 {0x4508, 0x55},
599 {0x4509, 0x55},
600 {0x450a, 0x00},
601 {0x450b, 0x00},
602 {0x4600, 0x00},
603 {0x4601, 0x81},
604 {0x4700, 0xa4},
605 {0x4800, 0x4c},
606 {0x4816, 0x53},
607 {0x481f, 0x40},
608 {0x4837, 0x13},
609 {0x5000, 0x56},
610 {0x5001, 0x01},
611 {0x5002, 0x28},
612 {0x5004, 0x0c},
613 {0x5006, 0x0c},
614 {0x5007, 0xe0},
615 {0x5008, 0x01},
616 {0x5009, 0xb0},
617 {0x5901, 0x00},
618 {0x5a01, 0x00},
619 {0x5a03, 0x00},
620 {0x5a04, 0x0c},
621 {0x5a05, 0xe0},
622 {0x5a06, 0x09},
623 {0x5a07, 0xb0},
624 {0x5a08, 0x06},
625 {0x5e00, 0x00},
626 {0x3734, 0x40},
627 {0x5b00, 0x01},
628 {0x5b01, 0x10},
629 {0x5b02, 0x01},
630 {0x5b03, 0xdb},
631 {0x3d8c, 0x71},
632 {0x3d8d, 0xea},
633 {0x4017, 0x10},
634 {0x3618, 0x2a},
635 {0x5780, 0x3e},
636 {0x5781, 0x0f},
637 {0x5782, 0x44},
638 {0x5783, 0x02},
639 {0x5784, 0x01},
640 {0x5785, 0x01},
641 {0x5786, 0x00},
642 {0x5787, 0x04},
643 {0x5788, 0x02},
644 {0x5789, 0x0f},
645 {0x578a, 0xfd},
646 {0x578b, 0xf5},
647 {0x578c, 0xf5},
648 {0x578d, 0x03},
649 {0x578e, 0x08},
650 {0x578f, 0x0c},
651 {0x5790, 0x08},
652 {0x5791, 0x04},
653 {0x5792, 0x00},
654 {0x5793, 0x52},
655 {0x5794, 0xa3},
656 {0x3503, 0x00}
657};
658
659static const struct ov5670_reg mode_648x486_regs[] = {
660 {0x3000, 0x00},
661 {0x3002, 0x21},
662 {0x3005, 0xf0},
663 {0x3007, 0x00},
664 {0x3015, 0x0f},
665 {0x3018, 0x32},
666 {0x301a, 0xf0},
667 {0x301b, 0xf0},
668 {0x301c, 0xf0},
669 {0x301d, 0xf0},
670 {0x301e, 0xf0},
671 {0x3030, 0x00},
672 {0x3031, 0x0a},
673 {0x303c, 0xff},
674 {0x303e, 0xff},
675 {0x3040, 0xf0},
676 {0x3041, 0x00},
677 {0x3042, 0xf0},
678 {0x3106, 0x11},
679 {0x3500, 0x00},
680 {0x3501, 0x80},
681 {0x3502, 0x00},
682 {0x3503, 0x04},
683 {0x3504, 0x03},
684 {0x3505, 0x83},
685 {0x3508, 0x04},
686 {0x3509, 0x00},
687 {0x350e, 0x04},
688 {0x350f, 0x00},
689 {0x3510, 0x00},
690 {0x3511, 0x02},
691 {0x3512, 0x00},
692 {0x3601, 0xc8},
693 {0x3610, 0x88},
694 {0x3612, 0x48},
695 {0x3614, 0x5b},
696 {0x3615, 0x96},
697 {0x3621, 0xd0},
698 {0x3622, 0x00},
699 {0x3623, 0x04},
700 {0x3633, 0x13},
701 {0x3634, 0x13},
702 {0x3635, 0x13},
703 {0x3636, 0x13},
704 {0x3645, 0x13},
705 {0x3646, 0x82},
706 {0x3650, 0x00},
707 {0x3652, 0xff},
708 {0x3655, 0x20},
709 {0x3656, 0xff},
710 {0x365a, 0xff},
711 {0x365e, 0xff},
712 {0x3668, 0x00},
713 {0x366a, 0x07},
714 {0x366e, 0x08},
715 {0x366d, 0x00},
716 {0x366f, 0x80},
717 {0x3700, 0x28},
718 {0x3701, 0x10},
719 {0x3702, 0x3a},
720 {0x3703, 0x19},
721 {0x3704, 0x10},
722 {0x3705, 0x00},
723 {0x3706, 0x66},
724 {0x3707, 0x08},
725 {0x3708, 0x34},
726 {0x3709, 0x40},
727 {0x370a, 0x01},
728 {0x370b, 0x1b},
729 {0x3714, 0x24},
730 {0x371a, 0x3e},
731 {0x3733, 0x00},
732 {0x3734, 0x00},
733 {0x373a, 0x05},
734 {0x373b, 0x06},
735 {0x373c, 0x0a},
736 {0x373f, 0xa0},
737 {0x3755, 0x00},
738 {0x3758, 0x00},
739 {0x375b, 0x0e},
740 {0x3766, 0x5f},
741 {0x3768, 0x00},
742 {0x3769, 0x22},
743 {0x3773, 0x08},
744 {0x3774, 0x1f},
745 {0x3776, 0x06},
746 {0x37a0, 0x88},
747 {0x37a1, 0x5c},
748 {0x37a7, 0x88},
749 {0x37a8, 0x70},
750 {0x37aa, 0x88},
751 {0x37ab, 0x48},
752 {0x37b3, 0x66},
753 {0x37c2, 0x04},
754 {0x37c5, 0x00},
755 {0x37c8, 0x00},
756 {0x3800, 0x00},
757 {0x3801, 0x0c},
758 {0x3802, 0x00},
759 {0x3803, 0x04},
760 {0x3804, 0x0a},
761 {0x3805, 0x33},
762 {0x3806, 0x07},
763 {0x3807, 0xa3},
764 {0x3808, 0x02},
765 {0x3809, 0x88},
766 {0x380a, 0x01},
767 {0x380b, 0xe6},
768 {0x380c, 0x06},
769 {0x380d, 0x90},
770 {0x380e, 0x08},
771 {0x380f, 0x08},
772 {0x3811, 0x04},
773 {0x3813, 0x02},
774 {0x3814, 0x07},
775 {0x3815, 0x01},
776 {0x3816, 0x00},
777 {0x3817, 0x00},
778 {0x3818, 0x00},
779 {0x3819, 0x00},
780 {0x3820, 0x94},
781 {0x3821, 0xc6},
782 {0x3822, 0x48},
783 {0x3826, 0x00},
784 {0x3827, 0x08},
785 {0x382a, 0x07},
786 {0x382b, 0x01},
787 {0x3830, 0x08},
788 {0x3836, 0x02},
789 {0x3837, 0x00},
790 {0x3838, 0x10},
791 {0x3841, 0xff},
792 {0x3846, 0x48},
793 {0x3861, 0x00},
794 {0x3862, 0x04},
795 {0x3863, 0x06},
796 {0x3a11, 0x01},
797 {0x3a12, 0x78},
798 {0x3b00, 0x00},
799 {0x3b02, 0x00},
800 {0x3b03, 0x00},
801 {0x3b04, 0x00},
802 {0x3b05, 0x00},
803 {0x3c00, 0x89},
804 {0x3c01, 0xab},
805 {0x3c02, 0x01},
806 {0x3c03, 0x00},
807 {0x3c04, 0x00},
808 {0x3c05, 0x03},
809 {0x3c06, 0x00},
810 {0x3c07, 0x05},
811 {0x3c0c, 0x00},
812 {0x3c0d, 0x00},
813 {0x3c0e, 0x00},
814 {0x3c0f, 0x00},
815 {0x3c40, 0x00},
816 {0x3c41, 0xa3},
817 {0x3c43, 0x7d},
818 {0x3c45, 0xd7},
819 {0x3c47, 0xfc},
820 {0x3c50, 0x05},
821 {0x3c52, 0xaa},
822 {0x3c54, 0x71},
823 {0x3c56, 0x80},
824 {0x3d85, 0x17},
825 {0x3f03, 0x00},
826 {0x3f0a, 0x00},
827 {0x3f0b, 0x00},
828 {0x4001, 0x60},
829 {0x4009, 0x05},
830 {0x4020, 0x00},
831 {0x4021, 0x00},
832 {0x4022, 0x00},
833 {0x4023, 0x00},
834 {0x4024, 0x00},
835 {0x4025, 0x00},
836 {0x4026, 0x00},
837 {0x4027, 0x00},
838 {0x4028, 0x00},
839 {0x4029, 0x00},
840 {0x402a, 0x00},
841 {0x402b, 0x00},
842 {0x402c, 0x00},
843 {0x402d, 0x00},
844 {0x402e, 0x00},
845 {0x402f, 0x00},
846 {0x4040, 0x00},
847 {0x4041, 0x03},
848 {0x4042, 0x00},
849 {0x4043, 0x7A},
850 {0x4044, 0x00},
851 {0x4045, 0x7A},
852 {0x4046, 0x00},
853 {0x4047, 0x7A},
854 {0x4048, 0x00},
855 {0x4049, 0x7A},
856 {0x4307, 0x30},
857 {0x4500, 0x58},
858 {0x4501, 0x04},
859 {0x4502, 0x40},
860 {0x4503, 0x10},
861 {0x4508, 0x55},
862 {0x4509, 0x55},
863 {0x450a, 0x02},
864 {0x450b, 0x00},
865 {0x4600, 0x00},
866 {0x4601, 0x40},
867 {0x4700, 0xa4},
868 {0x4800, 0x4c},
869 {0x4816, 0x53},
870 {0x481f, 0x40},
871 {0x4837, 0x13},
872 {0x5000, 0x56},
873 {0x5001, 0x01},
874 {0x5002, 0x28},
875 {0x5004, 0x0c},
876 {0x5006, 0x0c},
877 {0x5007, 0xe0},
878 {0x5008, 0x01},
879 {0x5009, 0xb0},
880 {0x5901, 0x00},
881 {0x5a01, 0x00},
882 {0x5a03, 0x00},
883 {0x5a04, 0x0c},
884 {0x5a05, 0xe0},
885 {0x5a06, 0x09},
886 {0x5a07, 0xb0},
887 {0x5a08, 0x06},
888 {0x5e00, 0x00},
889 {0x3734, 0x40},
890 {0x5b00, 0x01},
891 {0x5b01, 0x10},
892 {0x5b02, 0x01},
893 {0x5b03, 0xdb},
894 {0x3d8c, 0x71},
895 {0x3d8d, 0xea},
896 {0x4017, 0x10},
897 {0x3618, 0x2a},
898 {0x5780, 0x3e},
899 {0x5781, 0x0f},
900 {0x5782, 0x44},
901 {0x5783, 0x02},
902 {0x5784, 0x01},
903 {0x5785, 0x01},
904 {0x5786, 0x00},
905 {0x5787, 0x04},
906 {0x5788, 0x02},
907 {0x5789, 0x0f},
908 {0x578a, 0xfd},
909 {0x578b, 0xf5},
910 {0x578c, 0xf5},
911 {0x578d, 0x03},
912 {0x578e, 0x08},
913 {0x578f, 0x0c},
914 {0x5790, 0x08},
915 {0x5791, 0x06},
916 {0x5792, 0x00},
917 {0x5793, 0x52},
918 {0x5794, 0xa3},
919 {0x3503, 0x00}
920};
921
922static const struct ov5670_reg mode_2560x1440_regs[] = {
923 {0x3000, 0x00},
924 {0x3002, 0x21},
925 {0x3005, 0xf0},
926 {0x3007, 0x00},
927 {0x3015, 0x0f},
928 {0x3018, 0x32},
929 {0x301a, 0xf0},
930 {0x301b, 0xf0},
931 {0x301c, 0xf0},
932 {0x301d, 0xf0},
933 {0x301e, 0xf0},
934 {0x3030, 0x00},
935 {0x3031, 0x0a},
936 {0x303c, 0xff},
937 {0x303e, 0xff},
938 {0x3040, 0xf0},
939 {0x3041, 0x00},
940 {0x3042, 0xf0},
941 {0x3106, 0x11},
942 {0x3500, 0x00},
943 {0x3501, 0x80},
944 {0x3502, 0x00},
945 {0x3503, 0x04},
946 {0x3504, 0x03},
947 {0x3505, 0x83},
948 {0x3508, 0x04},
949 {0x3509, 0x00},
950 {0x350e, 0x04},
951 {0x350f, 0x00},
952 {0x3510, 0x00},
953 {0x3511, 0x02},
954 {0x3512, 0x00},
955 {0x3601, 0xc8},
956 {0x3610, 0x88},
957 {0x3612, 0x48},
958 {0x3614, 0x5b},
959 {0x3615, 0x96},
960 {0x3621, 0xd0},
961 {0x3622, 0x00},
962 {0x3623, 0x00},
963 {0x3633, 0x13},
964 {0x3634, 0x13},
965 {0x3635, 0x13},
966 {0x3636, 0x13},
967 {0x3645, 0x13},
968 {0x3646, 0x82},
969 {0x3650, 0x00},
970 {0x3652, 0xff},
971 {0x3655, 0x20},
972 {0x3656, 0xff},
973 {0x365a, 0xff},
974 {0x365e, 0xff},
975 {0x3668, 0x00},
976 {0x366a, 0x07},
977 {0x366e, 0x10},
978 {0x366d, 0x00},
979 {0x366f, 0x80},
980 {0x3700, 0x28},
981 {0x3701, 0x10},
982 {0x3702, 0x3a},
983 {0x3703, 0x19},
984 {0x3704, 0x10},
985 {0x3705, 0x00},
986 {0x3706, 0x66},
987 {0x3707, 0x08},
988 {0x3708, 0x34},
989 {0x3709, 0x40},
990 {0x370a, 0x01},
991 {0x370b, 0x1b},
992 {0x3714, 0x24},
993 {0x371a, 0x3e},
994 {0x3733, 0x00},
995 {0x3734, 0x00},
996 {0x373a, 0x05},
997 {0x373b, 0x06},
998 {0x373c, 0x0a},
999 {0x373f, 0xa0},
1000 {0x3755, 0x00},
1001 {0x3758, 0x00},
1002 {0x375b, 0x0e},
1003 {0x3766, 0x5f},
1004 {0x3768, 0x00},
1005 {0x3769, 0x22},
1006 {0x3773, 0x08},
1007 {0x3774, 0x1f},
1008 {0x3776, 0x06},
1009 {0x37a0, 0x88},
1010 {0x37a1, 0x5c},
1011 {0x37a7, 0x88},
1012 {0x37a8, 0x70},
1013 {0x37aa, 0x88},
1014 {0x37ab, 0x48},
1015 {0x37b3, 0x66},
1016 {0x37c2, 0x04},
1017 {0x37c5, 0x00},
1018 {0x37c8, 0x00},
1019 {0x3800, 0x00},
1020 {0x3801, 0x0c},
1021 {0x3802, 0x00},
1022 {0x3803, 0x04},
1023 {0x3804, 0x0a},
1024 {0x3805, 0x33},
1025 {0x3806, 0x07},
1026 {0x3807, 0xa3},
1027 {0x3808, 0x0a},
1028 {0x3809, 0x00},
1029 {0x380a, 0x05},
1030 {0x380b, 0xa0},
1031 {0x380c, 0x06},
1032 {0x380d, 0x90},
1033 {0x380e, 0x08},
1034 {0x380f, 0x08},
1035 {0x3811, 0x04},
1036 {0x3813, 0x02},
1037 {0x3814, 0x01},
1038 {0x3815, 0x01},
1039 {0x3816, 0x00},
1040 {0x3817, 0x00},
1041 {0x3818, 0x00},
1042 {0x3819, 0x00},
1043 {0x3820, 0x84},
1044 {0x3821, 0x46},
1045 {0x3822, 0x48},
1046 {0x3826, 0x00},
1047 {0x3827, 0x08},
1048 {0x382a, 0x01},
1049 {0x382b, 0x01},
1050 {0x3830, 0x08},
1051 {0x3836, 0x02},
1052 {0x3837, 0x00},
1053 {0x3838, 0x10},
1054 {0x3841, 0xff},
1055 {0x3846, 0x48},
1056 {0x3861, 0x00},
1057 {0x3862, 0x04},
1058 {0x3863, 0x06},
1059 {0x3a11, 0x01},
1060 {0x3a12, 0x78},
1061 {0x3b00, 0x00},
1062 {0x3b02, 0x00},
1063 {0x3b03, 0x00},
1064 {0x3b04, 0x00},
1065 {0x3b05, 0x00},
1066 {0x3c00, 0x89},
1067 {0x3c01, 0xab},
1068 {0x3c02, 0x01},
1069 {0x3c03, 0x00},
1070 {0x3c04, 0x00},
1071 {0x3c05, 0x03},
1072 {0x3c06, 0x00},
1073 {0x3c07, 0x05},
1074 {0x3c0c, 0x00},
1075 {0x3c0d, 0x00},
1076 {0x3c0e, 0x00},
1077 {0x3c0f, 0x00},
1078 {0x3c40, 0x00},
1079 {0x3c41, 0xa3},
1080 {0x3c43, 0x7d},
1081 {0x3c45, 0xd7},
1082 {0x3c47, 0xfc},
1083 {0x3c50, 0x05},
1084 {0x3c52, 0xaa},
1085 {0x3c54, 0x71},
1086 {0x3c56, 0x80},
1087 {0x3d85, 0x17},
1088 {0x3f03, 0x00},
1089 {0x3f0a, 0x00},
1090 {0x3f0b, 0x00},
1091 {0x4001, 0x60},
1092 {0x4009, 0x0d},
1093 {0x4020, 0x00},
1094 {0x4021, 0x00},
1095 {0x4022, 0x00},
1096 {0x4023, 0x00},
1097 {0x4024, 0x00},
1098 {0x4025, 0x00},
1099 {0x4026, 0x00},
1100 {0x4027, 0x00},
1101 {0x4028, 0x00},
1102 {0x4029, 0x00},
1103 {0x402a, 0x00},
1104 {0x402b, 0x00},
1105 {0x402c, 0x00},
1106 {0x402d, 0x00},
1107 {0x402e, 0x00},
1108 {0x402f, 0x00},
1109 {0x4040, 0x00},
1110 {0x4041, 0x03},
1111 {0x4042, 0x00},
1112 {0x4043, 0x7A},
1113 {0x4044, 0x00},
1114 {0x4045, 0x7A},
1115 {0x4046, 0x00},
1116 {0x4047, 0x7A},
1117 {0x4048, 0x00},
1118 {0x4049, 0x7A},
1119 {0x4307, 0x30},
1120 {0x4500, 0x58},
1121 {0x4501, 0x04},
1122 {0x4502, 0x40},
1123 {0x4503, 0x10},
1124 {0x4508, 0xaa},
1125 {0x4509, 0xaa},
1126 {0x450a, 0x00},
1127 {0x450b, 0x00},
1128 {0x4600, 0x01},
1129 {0x4601, 0x00},
1130 {0x4700, 0xa4},
1131 {0x4800, 0x4c},
1132 {0x4816, 0x53},
1133 {0x481f, 0x40},
1134 {0x4837, 0x13},
1135 {0x5000, 0x56},
1136 {0x5001, 0x01},
1137 {0x5002, 0x28},
1138 {0x5004, 0x0c},
1139 {0x5006, 0x0c},
1140 {0x5007, 0xe0},
1141 {0x5008, 0x01},
1142 {0x5009, 0xb0},
1143 {0x5901, 0x00},
1144 {0x5a01, 0x00},
1145 {0x5a03, 0x00},
1146 {0x5a04, 0x0c},
1147 {0x5a05, 0xe0},
1148 {0x5a06, 0x09},
1149 {0x5a07, 0xb0},
1150 {0x5a08, 0x06},
1151 {0x5e00, 0x00},
1152 {0x3734, 0x40},
1153 {0x5b00, 0x01},
1154 {0x5b01, 0x10},
1155 {0x5b02, 0x01},
1156 {0x5b03, 0xdb},
1157 {0x3d8c, 0x71},
1158 {0x3d8d, 0xea},
1159 {0x4017, 0x08},
1160 {0x3618, 0x2a},
1161 {0x5780, 0x3e},
1162 {0x5781, 0x0f},
1163 {0x5782, 0x44},
1164 {0x5783, 0x02},
1165 {0x5784, 0x01},
1166 {0x5785, 0x01},
1167 {0x5786, 0x00},
1168 {0x5787, 0x04},
1169 {0x5788, 0x02},
1170 {0x5789, 0x0f},
1171 {0x578a, 0xfd},
1172 {0x578b, 0xf5},
1173 {0x578c, 0xf5},
1174 {0x578d, 0x03},
1175 {0x578e, 0x08},
1176 {0x578f, 0x0c},
1177 {0x5790, 0x08},
1178 {0x5791, 0x06},
1179 {0x5792, 0x00},
1180 {0x5793, 0x52},
1181 {0x5794, 0xa3}
1182};
1183
1184static const struct ov5670_reg mode_1280x720_regs[] = {
1185 {0x3000, 0x00},
1186 {0x3002, 0x21},
1187 {0x3005, 0xf0},
1188 {0x3007, 0x00},
1189 {0x3015, 0x0f},
1190 {0x3018, 0x32},
1191 {0x301a, 0xf0},
1192 {0x301b, 0xf0},
1193 {0x301c, 0xf0},
1194 {0x301d, 0xf0},
1195 {0x301e, 0xf0},
1196 {0x3030, 0x00},
1197 {0x3031, 0x0a},
1198 {0x303c, 0xff},
1199 {0x303e, 0xff},
1200 {0x3040, 0xf0},
1201 {0x3041, 0x00},
1202 {0x3042, 0xf0},
1203 {0x3106, 0x11},
1204 {0x3500, 0x00},
1205 {0x3501, 0x80},
1206 {0x3502, 0x00},
1207 {0x3503, 0x04},
1208 {0x3504, 0x03},
1209 {0x3505, 0x83},
1210 {0x3508, 0x04},
1211 {0x3509, 0x00},
1212 {0x350e, 0x04},
1213 {0x350f, 0x00},
1214 {0x3510, 0x00},
1215 {0x3511, 0x02},
1216 {0x3512, 0x00},
1217 {0x3601, 0xc8},
1218 {0x3610, 0x88},
1219 {0x3612, 0x48},
1220 {0x3614, 0x5b},
1221 {0x3615, 0x96},
1222 {0x3621, 0xd0},
1223 {0x3622, 0x00},
1224 {0x3623, 0x00},
1225 {0x3633, 0x13},
1226 {0x3634, 0x13},
1227 {0x3635, 0x13},
1228 {0x3636, 0x13},
1229 {0x3645, 0x13},
1230 {0x3646, 0x82},
1231 {0x3650, 0x00},
1232 {0x3652, 0xff},
1233 {0x3655, 0x20},
1234 {0x3656, 0xff},
1235 {0x365a, 0xff},
1236 {0x365e, 0xff},
1237 {0x3668, 0x00},
1238 {0x366a, 0x07},
1239 {0x366e, 0x08},
1240 {0x366d, 0x00},
1241 {0x366f, 0x80},
1242 {0x3700, 0x28},
1243 {0x3701, 0x10},
1244 {0x3702, 0x3a},
1245 {0x3703, 0x19},
1246 {0x3704, 0x10},
1247 {0x3705, 0x00},
1248 {0x3706, 0x66},
1249 {0x3707, 0x08},
1250 {0x3708, 0x34},
1251 {0x3709, 0x40},
1252 {0x370a, 0x01},
1253 {0x370b, 0x1b},
1254 {0x3714, 0x24},
1255 {0x371a, 0x3e},
1256 {0x3733, 0x00},
1257 {0x3734, 0x00},
1258 {0x373a, 0x05},
1259 {0x373b, 0x06},
1260 {0x373c, 0x0a},
1261 {0x373f, 0xa0},
1262 {0x3755, 0x00},
1263 {0x3758, 0x00},
1264 {0x375b, 0x0e},
1265 {0x3766, 0x5f},
1266 {0x3768, 0x00},
1267 {0x3769, 0x22},
1268 {0x3773, 0x08},
1269 {0x3774, 0x1f},
1270 {0x3776, 0x06},
1271 {0x37a0, 0x88},
1272 {0x37a1, 0x5c},
1273 {0x37a7, 0x88},
1274 {0x37a8, 0x70},
1275 {0x37aa, 0x88},
1276 {0x37ab, 0x48},
1277 {0x37b3, 0x66},
1278 {0x37c2, 0x04},
1279 {0x37c5, 0x00},
1280 {0x37c8, 0x00},
1281 {0x3800, 0x00},
1282 {0x3801, 0x0c},
1283 {0x3802, 0x00},
1284 {0x3803, 0x04},
1285 {0x3804, 0x0a},
1286 {0x3805, 0x33},
1287 {0x3806, 0x07},
1288 {0x3807, 0xa3},
1289 {0x3808, 0x05},
1290 {0x3809, 0x00},
1291 {0x380a, 0x02},
1292 {0x380b, 0xd0},
1293 {0x380c, 0x06},
1294 {0x380d, 0x90},
1295 {0x380e, 0x08},
1296 {0x380f, 0x08},
1297 {0x3811, 0x04},
1298 {0x3813, 0x02},
1299 {0x3814, 0x03},
1300 {0x3815, 0x01},
1301 {0x3816, 0x00},
1302 {0x3817, 0x00},
1303 {0x3818, 0x00},
1304 {0x3819, 0x00},
1305 {0x3820, 0x94},
1306 {0x3821, 0x47},
1307 {0x3822, 0x48},
1308 {0x3826, 0x00},
1309 {0x3827, 0x08},
1310 {0x382a, 0x03},
1311 {0x382b, 0x01},
1312 {0x3830, 0x08},
1313 {0x3836, 0x02},
1314 {0x3837, 0x00},
1315 {0x3838, 0x10},
1316 {0x3841, 0xff},
1317 {0x3846, 0x48},
1318 {0x3861, 0x00},
1319 {0x3862, 0x04},
1320 {0x3863, 0x06},
1321 {0x3a11, 0x01},
1322 {0x3a12, 0x78},
1323 {0x3b00, 0x00},
1324 {0x3b02, 0x00},
1325 {0x3b03, 0x00},
1326 {0x3b04, 0x00},
1327 {0x3b05, 0x00},
1328 {0x3c00, 0x89},
1329 {0x3c01, 0xab},
1330 {0x3c02, 0x01},
1331 {0x3c03, 0x00},
1332 {0x3c04, 0x00},
1333 {0x3c05, 0x03},
1334 {0x3c06, 0x00},
1335 {0x3c07, 0x05},
1336 {0x3c0c, 0x00},
1337 {0x3c0d, 0x00},
1338 {0x3c0e, 0x00},
1339 {0x3c0f, 0x00},
1340 {0x3c40, 0x00},
1341 {0x3c41, 0xa3},
1342 {0x3c43, 0x7d},
1343 {0x3c45, 0xd7},
1344 {0x3c47, 0xfc},
1345 {0x3c50, 0x05},
1346 {0x3c52, 0xaa},
1347 {0x3c54, 0x71},
1348 {0x3c56, 0x80},
1349 {0x3d85, 0x17},
1350 {0x3f03, 0x00},
1351 {0x3f0a, 0x00},
1352 {0x3f0b, 0x00},
1353 {0x4001, 0x60},
1354 {0x4009, 0x05},
1355 {0x4020, 0x00},
1356 {0x4021, 0x00},
1357 {0x4022, 0x00},
1358 {0x4023, 0x00},
1359 {0x4024, 0x00},
1360 {0x4025, 0x00},
1361 {0x4026, 0x00},
1362 {0x4027, 0x00},
1363 {0x4028, 0x00},
1364 {0x4029, 0x00},
1365 {0x402a, 0x00},
1366 {0x402b, 0x00},
1367 {0x402c, 0x00},
1368 {0x402d, 0x00},
1369 {0x402e, 0x00},
1370 {0x402f, 0x00},
1371 {0x4040, 0x00},
1372 {0x4041, 0x03},
1373 {0x4042, 0x00},
1374 {0x4043, 0x7A},
1375 {0x4044, 0x00},
1376 {0x4045, 0x7A},
1377 {0x4046, 0x00},
1378 {0x4047, 0x7A},
1379 {0x4048, 0x00},
1380 {0x4049, 0x7A},
1381 {0x4307, 0x30},
1382 {0x4500, 0x58},
1383 {0x4501, 0x04},
1384 {0x4502, 0x48},
1385 {0x4503, 0x10},
1386 {0x4508, 0x55},
1387 {0x4509, 0x55},
1388 {0x450a, 0x00},
1389 {0x450b, 0x00},
1390 {0x4600, 0x00},
1391 {0x4601, 0x80},
1392 {0x4700, 0xa4},
1393 {0x4800, 0x4c},
1394 {0x4816, 0x53},
1395 {0x481f, 0x40},
1396 {0x4837, 0x13},
1397 {0x5000, 0x56},
1398 {0x5001, 0x01},
1399 {0x5002, 0x28},
1400 {0x5004, 0x0c},
1401 {0x5006, 0x0c},
1402 {0x5007, 0xe0},
1403 {0x5008, 0x01},
1404 {0x5009, 0xb0},
1405 {0x5901, 0x00},
1406 {0x5a01, 0x00},
1407 {0x5a03, 0x00},
1408 {0x5a04, 0x0c},
1409 {0x5a05, 0xe0},
1410 {0x5a06, 0x09},
1411 {0x5a07, 0xb0},
1412 {0x5a08, 0x06},
1413 {0x5e00, 0x00},
1414 {0x3734, 0x40},
1415 {0x5b00, 0x01},
1416 {0x5b01, 0x10},
1417 {0x5b02, 0x01},
1418 {0x5b03, 0xdb},
1419 {0x3d8c, 0x71},
1420 {0x3d8d, 0xea},
1421 {0x4017, 0x10},
1422 {0x3618, 0x2a},
1423 {0x5780, 0x3e},
1424 {0x5781, 0x0f},
1425 {0x5782, 0x44},
1426 {0x5783, 0x02},
1427 {0x5784, 0x01},
1428 {0x5785, 0x01},
1429 {0x5786, 0x00},
1430 {0x5787, 0x04},
1431 {0x5788, 0x02},
1432 {0x5789, 0x0f},
1433 {0x578a, 0xfd},
1434 {0x578b, 0xf5},
1435 {0x578c, 0xf5},
1436 {0x578d, 0x03},
1437 {0x578e, 0x08},
1438 {0x578f, 0x0c},
1439 {0x5790, 0x08},
1440 {0x5791, 0x06},
1441 {0x5792, 0x00},
1442 {0x5793, 0x52},
1443 {0x5794, 0xa3},
1444 {0x3503, 0x00}
1445};
1446
1447static const struct ov5670_reg mode_640x360_regs[] = {
1448 {0x3000, 0x00},
1449 {0x3002, 0x21},
1450 {0x3005, 0xf0},
1451 {0x3007, 0x00},
1452 {0x3015, 0x0f},
1453 {0x3018, 0x32},
1454 {0x301a, 0xf0},
1455 {0x301b, 0xf0},
1456 {0x301c, 0xf0},
1457 {0x301d, 0xf0},
1458 {0x301e, 0xf0},
1459 {0x3030, 0x00},
1460 {0x3031, 0x0a},
1461 {0x303c, 0xff},
1462 {0x303e, 0xff},
1463 {0x3040, 0xf0},
1464 {0x3041, 0x00},
1465 {0x3042, 0xf0},
1466 {0x3106, 0x11},
1467 {0x3500, 0x00},
1468 {0x3501, 0x80},
1469 {0x3502, 0x00},
1470 {0x3503, 0x04},
1471 {0x3504, 0x03},
1472 {0x3505, 0x83},
1473 {0x3508, 0x04},
1474 {0x3509, 0x00},
1475 {0x350e, 0x04},
1476 {0x350f, 0x00},
1477 {0x3510, 0x00},
1478 {0x3511, 0x02},
1479 {0x3512, 0x00},
1480 {0x3601, 0xc8},
1481 {0x3610, 0x88},
1482 {0x3612, 0x48},
1483 {0x3614, 0x5b},
1484 {0x3615, 0x96},
1485 {0x3621, 0xd0},
1486 {0x3622, 0x00},
1487 {0x3623, 0x04},
1488 {0x3633, 0x13},
1489 {0x3634, 0x13},
1490 {0x3635, 0x13},
1491 {0x3636, 0x13},
1492 {0x3645, 0x13},
1493 {0x3646, 0x82},
1494 {0x3650, 0x00},
1495 {0x3652, 0xff},
1496 {0x3655, 0x20},
1497 {0x3656, 0xff},
1498 {0x365a, 0xff},
1499 {0x365e, 0xff},
1500 {0x3668, 0x00},
1501 {0x366a, 0x07},
1502 {0x366e, 0x08},
1503 {0x366d, 0x00},
1504 {0x366f, 0x80},
1505 {0x3700, 0x28},
1506 {0x3701, 0x10},
1507 {0x3702, 0x3a},
1508 {0x3703, 0x19},
1509 {0x3704, 0x10},
1510 {0x3705, 0x00},
1511 {0x3706, 0x66},
1512 {0x3707, 0x08},
1513 {0x3708, 0x34},
1514 {0x3709, 0x40},
1515 {0x370a, 0x01},
1516 {0x370b, 0x1b},
1517 {0x3714, 0x24},
1518 {0x371a, 0x3e},
1519 {0x3733, 0x00},
1520 {0x3734, 0x00},
1521 {0x373a, 0x05},
1522 {0x373b, 0x06},
1523 {0x373c, 0x0a},
1524 {0x373f, 0xa0},
1525 {0x3755, 0x00},
1526 {0x3758, 0x00},
1527 {0x375b, 0x0e},
1528 {0x3766, 0x5f},
1529 {0x3768, 0x00},
1530 {0x3769, 0x22},
1531 {0x3773, 0x08},
1532 {0x3774, 0x1f},
1533 {0x3776, 0x06},
1534 {0x37a0, 0x88},
1535 {0x37a1, 0x5c},
1536 {0x37a7, 0x88},
1537 {0x37a8, 0x70},
1538 {0x37aa, 0x88},
1539 {0x37ab, 0x48},
1540 {0x37b3, 0x66},
1541 {0x37c2, 0x04},
1542 {0x37c5, 0x00},
1543 {0x37c8, 0x00},
1544 {0x3800, 0x00},
1545 {0x3801, 0x0c},
1546 {0x3802, 0x00},
1547 {0x3803, 0x04},
1548 {0x3804, 0x0a},
1549 {0x3805, 0x33},
1550 {0x3806, 0x07},
1551 {0x3807, 0xa3},
1552 {0x3808, 0x02},
1553 {0x3809, 0x80},
1554 {0x380a, 0x01},
1555 {0x380b, 0x68},
1556 {0x380c, 0x06},
1557 {0x380d, 0x90},
1558 {0x380e, 0x08},
1559 {0x380f, 0x08},
1560 {0x3811, 0x04},
1561 {0x3813, 0x02},
1562 {0x3814, 0x07},
1563 {0x3815, 0x01},
1564 {0x3816, 0x00},
1565 {0x3817, 0x00},
1566 {0x3818, 0x00},
1567 {0x3819, 0x00},
1568 {0x3820, 0x94},
1569 {0x3821, 0xc6},
1570 {0x3822, 0x48},
1571 {0x3826, 0x00},
1572 {0x3827, 0x08},
1573 {0x382a, 0x07},
1574 {0x382b, 0x01},
1575 {0x3830, 0x08},
1576 {0x3836, 0x02},
1577 {0x3837, 0x00},
1578 {0x3838, 0x10},
1579 {0x3841, 0xff},
1580 {0x3846, 0x48},
1581 {0x3861, 0x00},
1582 {0x3862, 0x04},
1583 {0x3863, 0x06},
1584 {0x3a11, 0x01},
1585 {0x3a12, 0x78},
1586 {0x3b00, 0x00},
1587 {0x3b02, 0x00},
1588 {0x3b03, 0x00},
1589 {0x3b04, 0x00},
1590 {0x3b05, 0x00},
1591 {0x3c00, 0x89},
1592 {0x3c01, 0xab},
1593 {0x3c02, 0x01},
1594 {0x3c03, 0x00},
1595 {0x3c04, 0x00},
1596 {0x3c05, 0x03},
1597 {0x3c06, 0x00},
1598 {0x3c07, 0x05},
1599 {0x3c0c, 0x00},
1600 {0x3c0d, 0x00},
1601 {0x3c0e, 0x00},
1602 {0x3c0f, 0x00},
1603 {0x3c40, 0x00},
1604 {0x3c41, 0xa3},
1605 {0x3c43, 0x7d},
1606 {0x3c45, 0xd7},
1607 {0x3c47, 0xfc},
1608 {0x3c50, 0x05},
1609 {0x3c52, 0xaa},
1610 {0x3c54, 0x71},
1611 {0x3c56, 0x80},
1612 {0x3d85, 0x17},
1613 {0x3f03, 0x00},
1614 {0x3f0a, 0x00},
1615 {0x3f0b, 0x00},
1616 {0x4001, 0x60},
1617 {0x4009, 0x05},
1618 {0x4020, 0x00},
1619 {0x4021, 0x00},
1620 {0x4022, 0x00},
1621 {0x4023, 0x00},
1622 {0x4024, 0x00},
1623 {0x4025, 0x00},
1624 {0x4026, 0x00},
1625 {0x4027, 0x00},
1626 {0x4028, 0x00},
1627 {0x4029, 0x00},
1628 {0x402a, 0x00},
1629 {0x402b, 0x00},
1630 {0x402c, 0x00},
1631 {0x402d, 0x00},
1632 {0x402e, 0x00},
1633 {0x402f, 0x00},
1634 {0x4040, 0x00},
1635 {0x4041, 0x03},
1636 {0x4042, 0x00},
1637 {0x4043, 0x7A},
1638 {0x4044, 0x00},
1639 {0x4045, 0x7A},
1640 {0x4046, 0x00},
1641 {0x4047, 0x7A},
1642 {0x4048, 0x00},
1643 {0x4049, 0x7A},
1644 {0x4307, 0x30},
1645 {0x4500, 0x58},
1646 {0x4501, 0x04},
1647 {0x4502, 0x40},
1648 {0x4503, 0x10},
1649 {0x4508, 0x55},
1650 {0x4509, 0x55},
1651 {0x450a, 0x02},
1652 {0x450b, 0x00},
1653 {0x4600, 0x00},
1654 {0x4601, 0x40},
1655 {0x4700, 0xa4},
1656 {0x4800, 0x4c},
1657 {0x4816, 0x53},
1658 {0x481f, 0x40},
1659 {0x4837, 0x13},
1660 {0x5000, 0x56},
1661 {0x5001, 0x01},
1662 {0x5002, 0x28},
1663 {0x5004, 0x0c},
1664 {0x5006, 0x0c},
1665 {0x5007, 0xe0},
1666 {0x5008, 0x01},
1667 {0x5009, 0xb0},
1668 {0x5901, 0x00},
1669 {0x5a01, 0x00},
1670 {0x5a03, 0x00},
1671 {0x5a04, 0x0c},
1672 {0x5a05, 0xe0},
1673 {0x5a06, 0x09},
1674 {0x5a07, 0xb0},
1675 {0x5a08, 0x06},
1676 {0x5e00, 0x00},
1677 {0x3734, 0x40},
1678 {0x5b00, 0x01},
1679 {0x5b01, 0x10},
1680 {0x5b02, 0x01},
1681 {0x5b03, 0xdb},
1682 {0x3d8c, 0x71},
1683 {0x3d8d, 0xea},
1684 {0x4017, 0x10},
1685 {0x3618, 0x2a},
1686 {0x5780, 0x3e},
1687 {0x5781, 0x0f},
1688 {0x5782, 0x44},
1689 {0x5783, 0x02},
1690 {0x5784, 0x01},
1691 {0x5785, 0x01},
1692 {0x5786, 0x00},
1693 {0x5787, 0x04},
1694 {0x5788, 0x02},
1695 {0x5789, 0x0f},
1696 {0x578a, 0xfd},
1697 {0x578b, 0xf5},
1698 {0x578c, 0xf5},
1699 {0x578d, 0x03},
1700 {0x578e, 0x08},
1701 {0x578f, 0x0c},
1702 {0x5790, 0x08},
1703 {0x5791, 0x06},
1704 {0x5792, 0x00},
1705 {0x5793, 0x52},
1706 {0x5794, 0xa3},
1707 {0x3503, 0x00}
1708};
1709
1710static const char * const ov5670_test_pattern_menu[] = {
1711 "Disabled",
1712 "Vertical Color Bar Type 1",
1713};
1714
1715/* Supported link frequencies */
1716#define OV5670_LINK_FREQ_422MHZ 422400000
1717#define OV5670_LINK_FREQ_422MHZ_INDEX 0
1718static const struct ov5670_link_freq_config link_freq_configs[] = {
1719 {
1720 /* pixel_rate = link_freq * 2 * nr_of_lanes / bits_per_sample */
1721 .pixel_rate = (OV5670_LINK_FREQ_422MHZ * 2 * 2) / 10,
1722 .reg_list = {
1723 .num_of_regs = ARRAY_SIZE(mipi_data_rate_840mbps),
1724 .regs = mipi_data_rate_840mbps,
1725 }
1726 }
1727};
1728
1729static const s64 link_freq_menu_items[] = {
1730 OV5670_LINK_FREQ_422MHZ
1731};
1732
1733/*
1734 * OV5670 sensor supports following resolutions with full FOV:
1735 * 4:3 ==> {2592x1944, 1296x972, 648x486}
1736 * 16:9 ==> {2560x1440, 1280x720, 640x360}
1737 */
1738static const struct ov5670_mode supported_modes[] = {
1739 {
1740 .width = 2592,
1741 .height = 1944,
1742 .vts_def = OV5670_VTS_30FPS,
1743 .vts_min = OV5670_VTS_30FPS,
1744 .reg_list = {
1745 .num_of_regs = ARRAY_SIZE(mode_2592x1944_regs),
1746 .regs = mode_2592x1944_regs,
1747 },
1748 .link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
1749 },
1750 {
1751 .width = 1296,
1752 .height = 972,
1753 .vts_def = OV5670_VTS_30FPS,
1754 .vts_min = 996,
1755 .reg_list = {
1756 .num_of_regs = ARRAY_SIZE(mode_1296x972_regs),
1757 .regs = mode_1296x972_regs,
1758 },
1759 .link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
1760 },
1761 {
1762 .width = 648,
1763 .height = 486,
1764 .vts_def = OV5670_VTS_30FPS,
1765 .vts_min = 516,
1766 .reg_list = {
1767 .num_of_regs = ARRAY_SIZE(mode_648x486_regs),
1768 .regs = mode_648x486_regs,
1769 },
1770 .link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
1771 },
1772 {
1773 .width = 2560,
1774 .height = 1440,
1775 .vts_def = OV5670_VTS_30FPS,
1776 .vts_min = OV5670_VTS_30FPS,
1777 .reg_list = {
1778 .num_of_regs = ARRAY_SIZE(mode_2560x1440_regs),
1779 .regs = mode_2560x1440_regs,
1780 },
1781 .link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
1782 },
1783 {
1784 .width = 1280,
1785 .height = 720,
1786 .vts_def = OV5670_VTS_30FPS,
1787 .vts_min = 1020,
1788 .reg_list = {
1789 .num_of_regs = ARRAY_SIZE(mode_1280x720_regs),
1790 .regs = mode_1280x720_regs,
1791 },
1792 .link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
1793 },
1794 {
1795 .width = 640,
1796 .height = 360,
1797 .vts_def = OV5670_VTS_30FPS,
1798 .vts_min = 510,
1799 .reg_list = {
1800 .num_of_regs = ARRAY_SIZE(mode_640x360_regs),
1801 .regs = mode_640x360_regs,
1802 },
1803 .link_freq_index = OV5670_LINK_FREQ_422MHZ_INDEX,
1804 }
1805};
1806
1807struct ov5670 {
1808 struct v4l2_subdev sd;
1809 struct media_pad pad;
1810
1811 struct v4l2_ctrl_handler ctrl_handler;
1812 /* V4L2 Controls */
1813 struct v4l2_ctrl *link_freq;
1814 struct v4l2_ctrl *pixel_rate;
1815 struct v4l2_ctrl *vblank;
1816 struct v4l2_ctrl *hblank;
1817 struct v4l2_ctrl *exposure;
1818
1819 /* Current mode */
1820 const struct ov5670_mode *cur_mode;
1821
1822 /* To serialize asynchronus callbacks */
1823 struct mutex mutex;
1824
1825 /* Streaming on/off */
1826 bool streaming;
1827};
1828
1829#define to_ov5670(_sd) container_of(_sd, struct ov5670, sd)
1830
1831/* Read registers up to 4 at a time */
1832static int ov5670_read_reg(struct ov5670 *ov5670, u16 reg, unsigned int len,
1833 u32 *val)
1834{
1835 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
1836 struct i2c_msg msgs[2];
1837 u8 *data_be_p;
1838 u32 data_be = 0;
1839 u16 reg_addr_be = cpu_to_be16(reg);
1840 int ret;
1841
1842 if (len > 4)
1843 return -EINVAL;
1844
1845 data_be_p = (u8 *)&data_be;
1846 /* Write register address */
1847 msgs[0].addr = client->addr;
1848 msgs[0].flags = 0;
1849 msgs[0].len = 2;
1850 msgs[0].buf = (u8 *)&reg_addr_be;
1851
1852 /* Read data from register */
1853 msgs[1].addr = client->addr;
1854 msgs[1].flags = I2C_M_RD;
1855 msgs[1].len = len;
1856 msgs[1].buf = &data_be_p[4 - len];
1857
1858 ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
1859 if (ret != ARRAY_SIZE(msgs))
1860 return -EIO;
1861
1862 *val = be32_to_cpu(data_be);
1863
1864 return 0;
1865}
1866
1867/* Write registers up to 4 at a time */
1868static int ov5670_write_reg(struct ov5670 *ov5670, u16 reg, unsigned int len,
1869 u32 val)
1870{
1871 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
1872 int buf_i;
1873 int val_i;
1874 u8 buf[6];
1875 u8 *val_p;
1876
1877 if (len > 4)
1878 return -EINVAL;
1879
1880 buf[0] = reg >> 8;
1881 buf[1] = reg & 0xff;
1882
1883 val = cpu_to_be32(val);
1884 val_p = (u8 *)&val;
1885 buf_i = 2;
1886 val_i = 4 - len;
1887
1888 while (val_i < 4)
1889 buf[buf_i++] = val_p[val_i++];
1890
1891 if (i2c_master_send(client, buf, len + 2) != len + 2)
1892 return -EIO;
1893
1894 return 0;
1895}
1896
1897/* Write a list of registers */
1898static int ov5670_write_regs(struct ov5670 *ov5670,
1899 const struct ov5670_reg *regs, unsigned int len)
1900{
1901 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
1902 unsigned int i;
1903 int ret;
1904
1905 for (i = 0; i < len; i++) {
1906 ret = ov5670_write_reg(ov5670, regs[i].address, 1, regs[i].val);
1907 if (ret) {
1908 dev_err_ratelimited(
1909 &client->dev,
1910 "Failed to write reg 0x%4.4x. error = %d\n",
1911 regs[i].address, ret);
1912
1913 return ret;
1914 }
1915 }
1916
1917 return 0;
1918}
1919
1920static int ov5670_write_reg_list(struct ov5670 *ov5670,
1921 const struct ov5670_reg_list *r_list)
1922{
1923 return ov5670_write_regs(ov5670, r_list->regs, r_list->num_of_regs);
1924}
1925
1926/* Open sub-device */
1927static int ov5670_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1928{
1929 struct ov5670 *ov5670 = to_ov5670(sd);
1930 struct v4l2_mbus_framefmt *try_fmt =
1931 v4l2_subdev_get_try_format(sd, fh->pad, 0);
1932
1933 mutex_lock(&ov5670->mutex);
1934
1935 /* Initialize try_fmt */
1936 try_fmt->width = ov5670->cur_mode->width;
1937 try_fmt->height = ov5670->cur_mode->height;
1938 try_fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
1939 try_fmt->field = V4L2_FIELD_NONE;
1940
1941 /* No crop or compose */
1942 mutex_unlock(&ov5670->mutex);
1943
1944 return 0;
1945}
1946
1947static int ov5670_update_digital_gain(struct ov5670 *ov5670, u32 d_gain)
1948{
1949 int ret;
1950
1951 ret = ov5670_write_reg(ov5670, OV5670_REG_R_DGTL_GAIN,
1952 OV5670_REG_VALUE_16BIT, d_gain);
1953 if (ret)
1954 return ret;
1955
1956 ret = ov5670_write_reg(ov5670, OV5670_REG_G_DGTL_GAIN,
1957 OV5670_REG_VALUE_16BIT, d_gain);
1958 if (ret)
1959 return ret;
1960
1961 return ov5670_write_reg(ov5670, OV5670_REG_B_DGTL_GAIN,
1962 OV5670_REG_VALUE_16BIT, d_gain);
1963}
1964
1965static int ov5670_enable_test_pattern(struct ov5670 *ov5670, u32 pattern)
1966{
1967 u32 val;
1968 int ret;
1969
1970 /* Set the bayer order that we support */
1971 ret = ov5670_write_reg(ov5670, OV5670_REG_TEST_PATTERN_CTRL,
1972 OV5670_REG_VALUE_08BIT, 0);
1973 if (ret)
1974 return ret;
1975
1976 ret = ov5670_read_reg(ov5670, OV5670_REG_TEST_PATTERN,
1977 OV5670_REG_VALUE_08BIT, &val);
1978 if (ret)
1979 return ret;
1980
1981 if (pattern)
1982 val |= OV5670_TEST_PATTERN_ENABLE;
1983 else
1984 val &= ~OV5670_TEST_PATTERN_ENABLE;
1985
1986 return ov5670_write_reg(ov5670, OV5670_REG_TEST_PATTERN,
1987 OV5670_REG_VALUE_08BIT, val);
1988}
1989
1990/* Initialize control handlers */
1991static int ov5670_set_ctrl(struct v4l2_ctrl *ctrl)
1992{
1993 struct ov5670 *ov5670 = container_of(ctrl->handler,
1994 struct ov5670, ctrl_handler);
1995 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
1996 s64 max;
1997 int ret = 0;
1998
1999 /* Propagate change of current control to all related controls */
2000 switch (ctrl->id) {
2001 case V4L2_CID_VBLANK:
2002 /* Update max exposure while meeting expected vblanking */
2003 max = ov5670->cur_mode->height + ctrl->val - 8;
2004 __v4l2_ctrl_modify_range(ov5670->exposure,
2005 ov5670->exposure->minimum, max,
2006 ov5670->exposure->step, max);
2007 break;
2008 }
2009
2010 /* V4L2 controls values will be applied only when power is already up */
2011 if (pm_runtime_get_if_in_use(&client->dev) <= 0)
2012 return 0;
2013
2014 switch (ctrl->id) {
2015 case V4L2_CID_ANALOGUE_GAIN:
2016 ret = ov5670_write_reg(ov5670, OV5670_REG_ANALOG_GAIN,
2017 OV5670_REG_VALUE_16BIT, ctrl->val);
2018 break;
2019 case V4L2_CID_DIGITAL_GAIN:
2020 ret = ov5670_update_digital_gain(ov5670, ctrl->val);
2021 break;
2022 case V4L2_CID_EXPOSURE:
2023 /* 4 least significant bits of expsoure are fractional part */
2024 ret = ov5670_write_reg(ov5670, OV5670_REG_EXPOSURE,
2025 OV5670_REG_VALUE_24BIT, ctrl->val << 4);
2026 break;
2027 case V4L2_CID_VBLANK:
2028 /* Update VTS that meets expected vertical blanking */
2029 ret = ov5670_write_reg(ov5670, OV5670_REG_VTS,
2030 OV5670_REG_VALUE_16BIT,
2031 ov5670->cur_mode->height + ctrl->val);
2032 break;
2033 case V4L2_CID_TEST_PATTERN:
2034 ret = ov5670_enable_test_pattern(ov5670, ctrl->val);
2035 break;
2036 default:
2037 dev_info(&client->dev, "%s Unhandled id:0x%x, val:0x%x\n",
2038 __func__, ctrl->id, ctrl->val);
2039 break;
2040 }
2041
2042 pm_runtime_put(&client->dev);
2043
2044 return ret;
2045}
2046
2047static const struct v4l2_ctrl_ops ov5670_ctrl_ops = {
2048 .s_ctrl = ov5670_set_ctrl,
2049};
2050
2051/* Initialize control handlers */
2052static int ov5670_init_controls(struct ov5670 *ov5670)
2053{
2054 struct v4l2_ctrl_handler *ctrl_hdlr;
2055 s64 vblank_max;
2056 s64 vblank_def;
2057 s64 vblank_min;
2058 s64 exposure_max;
2059 int ret;
2060
2061 ctrl_hdlr = &ov5670->ctrl_handler;
2062 ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8);
2063 if (ret)
2064 return ret;
2065
2066 ctrl_hdlr->lock = &ov5670->mutex;
2067 ov5670->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr,
2068 &ov5670_ctrl_ops,
2069 V4L2_CID_LINK_FREQ,
2070 0, 0, link_freq_menu_items);
2071 if (ov5670->link_freq)
2072 ov5670->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
2073
2074 /* By default, V4L2_CID_PIXEL_RATE is read only */
2075 ov5670->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops,
2076 V4L2_CID_PIXEL_RATE, 0,
2077 link_freq_configs[0].pixel_rate,
2078 1,
2079 link_freq_configs[0].pixel_rate);
2080
2081 vblank_max = OV5670_VTS_MAX - ov5670->cur_mode->height;
2082 vblank_def = ov5670->cur_mode->vts_def - ov5670->cur_mode->height;
2083 vblank_min = ov5670->cur_mode->vts_min - ov5670->cur_mode->height;
2084 ov5670->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops,
2085 V4L2_CID_VBLANK, vblank_min,
2086 vblank_max, 1, vblank_def);
2087
2088 ov5670->hblank = v4l2_ctrl_new_std(
2089 ctrl_hdlr, &ov5670_ctrl_ops, V4L2_CID_HBLANK,
2090 OV5670_FIXED_PPL - ov5670->cur_mode->width,
2091 OV5670_FIXED_PPL - ov5670->cur_mode->width, 1,
2092 OV5670_FIXED_PPL - ov5670->cur_mode->width);
2093 if (ov5670->hblank)
2094 ov5670->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
2095
2096 /* Get min, max, step, default from sensor */
2097 v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
2098 ANALOG_GAIN_MIN, ANALOG_GAIN_MAX, ANALOG_GAIN_STEP,
2099 ANALOG_GAIN_DEFAULT);
2100
2101 /* Digital gain */
2102 v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops, V4L2_CID_DIGITAL_GAIN,
2103 OV5670_DGTL_GAIN_MIN, OV5670_DGTL_GAIN_MAX,
2104 OV5670_DGTL_GAIN_STEP, OV5670_DGTL_GAIN_DEFAULT);
2105
2106 /* Get min, max, step, default from sensor */
2107 exposure_max = ov5670->cur_mode->vts_def - 8;
2108 ov5670->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops,
2109 V4L2_CID_EXPOSURE,
2110 OV5670_EXPOSURE_MIN,
2111 exposure_max, OV5670_EXPOSURE_STEP,
2112 exposure_max);
2113
2114 v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &ov5670_ctrl_ops,
2115 V4L2_CID_TEST_PATTERN,
2116 ARRAY_SIZE(ov5670_test_pattern_menu) - 1,
2117 0, 0, ov5670_test_pattern_menu);
2118
2119 if (ctrl_hdlr->error) {
2120 ret = ctrl_hdlr->error;
2121 goto error;
2122 }
2123
2124 ov5670->sd.ctrl_handler = ctrl_hdlr;
2125
2126 return 0;
2127
2128error:
2129 v4l2_ctrl_handler_free(ctrl_hdlr);
2130
2131 return ret;
2132}
2133
2134static int ov5670_enum_mbus_code(struct v4l2_subdev *sd,
2135 struct v4l2_subdev_pad_config *cfg,
2136 struct v4l2_subdev_mbus_code_enum *code)
2137{
2138 /* Only one bayer order GRBG is supported */
2139 if (code->index > 0)
2140 return -EINVAL;
2141
2142 code->code = MEDIA_BUS_FMT_SGRBG10_1X10;
2143
2144 return 0;
2145}
2146
2147static int ov5670_enum_frame_size(struct v4l2_subdev *sd,
2148 struct v4l2_subdev_pad_config *cfg,
2149 struct v4l2_subdev_frame_size_enum *fse)
2150{
2151 if (fse->index >= ARRAY_SIZE(supported_modes))
2152 return -EINVAL;
2153
2154 if (fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
2155 return -EINVAL;
2156
2157 fse->min_width = supported_modes[fse->index].width;
2158 fse->max_width = fse->min_width;
2159 fse->min_height = supported_modes[fse->index].height;
2160 fse->max_height = fse->min_height;
2161
2162 return 0;
2163}
2164
2165/* Calculate resolution distance */
2166static int ov5670_get_reso_dist(const struct ov5670_mode *mode,
2167 struct v4l2_mbus_framefmt *framefmt)
2168{
2169 return abs(mode->width - framefmt->width) +
2170 abs(mode->height - framefmt->height);
2171}
2172
2173/* Find the closest supported resolution to the requested resolution */
2174static const struct ov5670_mode *ov5670_find_best_fit(
2175 struct ov5670 *ov5670,
2176 struct v4l2_subdev_format *fmt)
2177{
2178 struct v4l2_mbus_framefmt *framefmt = &fmt->format;
2179 int dist;
2180 int cur_best_fit = 0;
2181 int cur_best_fit_dist = -1;
2182 int i;
2183
2184 for (i = 0; i < ARRAY_SIZE(supported_modes); i++) {
2185 dist = ov5670_get_reso_dist(&supported_modes[i], framefmt);
2186 if (cur_best_fit_dist == -1 || dist < cur_best_fit_dist) {
2187 cur_best_fit_dist = dist;
2188 cur_best_fit = i;
2189 }
2190 }
2191
2192 return &supported_modes[cur_best_fit];
2193}
2194
2195static void ov5670_update_pad_format(const struct ov5670_mode *mode,
2196 struct v4l2_subdev_format *fmt)
2197{
2198 fmt->format.width = mode->width;
2199 fmt->format.height = mode->height;
2200 fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
2201 fmt->format.field = V4L2_FIELD_NONE;
2202}
2203
2204static int ov5670_do_get_pad_format(struct ov5670 *ov5670,
2205 struct v4l2_subdev_pad_config *cfg,
2206 struct v4l2_subdev_format *fmt)
2207{
2208 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
2209 fmt->format = *v4l2_subdev_get_try_format(&ov5670->sd, cfg,
2210 fmt->pad);
2211 else
2212 ov5670_update_pad_format(ov5670->cur_mode, fmt);
2213
2214 return 0;
2215}
2216
2217static int ov5670_get_pad_format(struct v4l2_subdev *sd,
2218 struct v4l2_subdev_pad_config *cfg,
2219 struct v4l2_subdev_format *fmt)
2220{
2221 struct ov5670 *ov5670 = to_ov5670(sd);
2222 int ret;
2223
2224 mutex_lock(&ov5670->mutex);
2225 ret = ov5670_do_get_pad_format(ov5670, cfg, fmt);
2226 mutex_unlock(&ov5670->mutex);
2227
2228 return ret;
2229}
2230
2231static int ov5670_set_pad_format(struct v4l2_subdev *sd,
2232 struct v4l2_subdev_pad_config *cfg,
2233 struct v4l2_subdev_format *fmt)
2234{
2235 struct ov5670 *ov5670 = to_ov5670(sd);
2236 const struct ov5670_mode *mode;
2237 s32 vblank_def;
2238 s32 h_blank;
2239
2240 mutex_lock(&ov5670->mutex);
2241
2242 fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
2243
2244 mode = ov5670_find_best_fit(ov5670, fmt);
2245 ov5670_update_pad_format(mode, fmt);
2246 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
2247 *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format;
2248 } else {
2249 ov5670->cur_mode = mode;
2250 __v4l2_ctrl_s_ctrl(ov5670->link_freq, mode->link_freq_index);
2251 __v4l2_ctrl_s_ctrl_int64(
2252 ov5670->pixel_rate,
2253 link_freq_configs[mode->link_freq_index].pixel_rate);
2254 /* Update limits and set FPS to default */
2255 vblank_def = ov5670->cur_mode->vts_def -
2256 ov5670->cur_mode->height;
2257 __v4l2_ctrl_modify_range(
2258 ov5670->vblank,
2259 ov5670->cur_mode->vts_min - ov5670->cur_mode->height,
2260 OV5670_VTS_MAX - ov5670->cur_mode->height, 1,
2261 vblank_def);
2262 __v4l2_ctrl_s_ctrl(ov5670->vblank, vblank_def);
2263 h_blank = OV5670_FIXED_PPL - ov5670->cur_mode->width;
2264 __v4l2_ctrl_modify_range(ov5670->hblank, h_blank, h_blank, 1,
2265 h_blank);
2266 }
2267
2268 mutex_unlock(&ov5670->mutex);
2269
2270 return 0;
2271}
2272
2273static int ov5670_get_skip_frames(struct v4l2_subdev *sd, u32 *frames)
2274{
2275 *frames = OV5670_NUM_OF_SKIP_FRAMES;
2276
2277 return 0;
2278}
2279
2280/* Prepare streaming by writing default values and customized values */
2281static int ov5670_start_streaming(struct ov5670 *ov5670)
2282{
2283 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
2284 const struct ov5670_reg_list *reg_list;
2285 int link_freq_index;
2286 int ret;
2287
2288 /* Get out of from software reset */
2289 ret = ov5670_write_reg(ov5670, OV5670_REG_SOFTWARE_RST,
2290 OV5670_REG_VALUE_08BIT, OV5670_SOFTWARE_RST);
2291 if (ret) {
2292 dev_err(&client->dev, "%s failed to set powerup registers\n",
2293 __func__);
2294 return ret;
2295 }
2296
2297 /* Setup PLL */
2298 link_freq_index = ov5670->cur_mode->link_freq_index;
2299 reg_list = &link_freq_configs[link_freq_index].reg_list;
2300 ret = ov5670_write_reg_list(ov5670, reg_list);
2301 if (ret) {
2302 dev_err(&client->dev, "%s failed to set plls\n", __func__);
2303 return ret;
2304 }
2305
2306 /* Apply default values of current mode */
2307 reg_list = &ov5670->cur_mode->reg_list;
2308 ret = ov5670_write_reg_list(ov5670, reg_list);
2309 if (ret) {
2310 dev_err(&client->dev, "%s failed to set mode\n", __func__);
2311 return ret;
2312 }
2313
2314 ret = __v4l2_ctrl_handler_setup(ov5670->sd.ctrl_handler);
2315 if (ret)
2316 return ret;
2317
2318 /* Write stream on list */
2319 ret = ov5670_write_reg(ov5670, OV5670_REG_MODE_SELECT,
2320 OV5670_REG_VALUE_08BIT, OV5670_MODE_STREAMING);
2321 if (ret) {
2322 dev_err(&client->dev, "%s failed to set stream\n", __func__);
2323 return ret;
2324 }
2325
2326 ov5670->streaming = true;
2327
2328 return 0;
2329}
2330
2331static int ov5670_stop_streaming(struct ov5670 *ov5670)
2332{
2333 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
2334 int ret;
2335
2336 ret = ov5670_write_reg(ov5670, OV5670_REG_MODE_SELECT,
2337 OV5670_REG_VALUE_08BIT, OV5670_MODE_STANDBY);
2338 if (ret)
2339 dev_err(&client->dev, "%s failed to set stream\n", __func__);
2340
2341 ov5670->streaming = false;
2342
2343 /* Return success even if it was an error, as there is nothing the
2344 * caller can do about it.
2345 */
2346 return 0;
2347}
2348
2349static int ov5670_set_stream(struct v4l2_subdev *sd, int enable)
2350{
2351 struct ov5670 *ov5670 = to_ov5670(sd);
2352 struct i2c_client *client = v4l2_get_subdevdata(sd);
2353 int ret = 0;
2354
2355 mutex_lock(&ov5670->mutex);
2356 if (ov5670->streaming == enable)
2357 goto unlock_and_return;
2358
2359 if (enable) {
2360 ret = pm_runtime_get_sync(&client->dev);
2361 if (ret < 0) {
2362 pm_runtime_put_noidle(&client->dev);
2363 goto unlock_and_return;
2364 }
2365
2366 ret = ov5670_start_streaming(ov5670);
2367 if (ret)
2368 goto error;
2369 } else {
2370 ret = ov5670_stop_streaming(ov5670);
2371 pm_runtime_put(&client->dev);
2372 }
2373 goto unlock_and_return;
2374
2375error:
2376 pm_runtime_put(&client->dev);
2377
2378unlock_and_return:
2379 mutex_unlock(&ov5670->mutex);
2380
2381 return ret;
2382}
2383
2384static int __maybe_unused ov5670_suspend(struct device *dev)
2385{
2386 struct i2c_client *client = to_i2c_client(dev);
2387 struct v4l2_subdev *sd = i2c_get_clientdata(client);
2388 struct ov5670 *ov5670 = to_ov5670(sd);
2389
2390 if (ov5670->streaming)
2391 ov5670_stop_streaming(ov5670);
2392
2393 return 0;
2394}
2395
2396static int __maybe_unused ov5670_resume(struct device *dev)
2397{
2398 struct i2c_client *client = to_i2c_client(dev);
2399 struct v4l2_subdev *sd = i2c_get_clientdata(client);
2400 struct ov5670 *ov5670 = to_ov5670(sd);
2401 int ret;
2402
2403 if (ov5670->streaming) {
2404 ret = ov5670_start_streaming(ov5670);
2405 if (ret) {
2406 ov5670_stop_streaming(ov5670);
2407 return ret;
2408 }
2409 }
2410
2411 return 0;
2412}
2413
2414/* Verify chip ID */
2415static int ov5670_identify_module(struct ov5670 *ov5670)
2416{
2417 struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd);
2418 int ret;
2419 u32 val;
2420
2421 ret = ov5670_read_reg(ov5670, OV5670_REG_CHIP_ID,
2422 OV5670_REG_VALUE_24BIT, &val);
2423 if (ret)
2424 return ret;
2425
2426 if (val != OV5670_CHIP_ID) {
2427 dev_err(&client->dev, "chip id mismatch: %x!=%x\n",
2428 OV5670_CHIP_ID, val);
2429 return -ENXIO;
2430 }
2431
2432 return 0;
2433}
2434
2435static const struct v4l2_subdev_video_ops ov5670_video_ops = {
2436 .s_stream = ov5670_set_stream,
2437};
2438
2439static const struct v4l2_subdev_pad_ops ov5670_pad_ops = {
2440 .enum_mbus_code = ov5670_enum_mbus_code,
2441 .get_fmt = ov5670_get_pad_format,
2442 .set_fmt = ov5670_set_pad_format,
2443 .enum_frame_size = ov5670_enum_frame_size,
2444};
2445
2446static const struct v4l2_subdev_sensor_ops ov5670_sensor_ops = {
2447 .g_skip_frames = ov5670_get_skip_frames,
2448};
2449
2450static const struct v4l2_subdev_ops ov5670_subdev_ops = {
2451 .video = &ov5670_video_ops,
2452 .pad = &ov5670_pad_ops,
2453 .sensor = &ov5670_sensor_ops,
2454};
2455
2456static const struct media_entity_operations ov5670_subdev_entity_ops = {
2457 .link_validate = v4l2_subdev_link_validate,
2458};
2459
2460static const struct v4l2_subdev_internal_ops ov5670_internal_ops = {
2461 .open = ov5670_open,
2462};
2463
2464static int ov5670_probe(struct i2c_client *client)
2465{
2466 struct ov5670 *ov5670;
2467 const char *err_msg;
2468 u32 input_clk = 0;
2469 int ret;
2470
2471 device_property_read_u32(&client->dev, "clock-frequency", &input_clk);
2472 if (input_clk != 19200000)
2473 return -EINVAL;
2474
2475 ov5670 = devm_kzalloc(&client->dev, sizeof(*ov5670), GFP_KERNEL);
2476 if (!ov5670) {
2477 ret = -ENOMEM;
2478 err_msg = "devm_kzalloc() error";
2479 goto error_print;
2480 }
2481
2482 /* Initialize subdev */
2483 v4l2_i2c_subdev_init(&ov5670->sd, client, &ov5670_subdev_ops);
2484
2485 /* Check module identity */
2486 ret = ov5670_identify_module(ov5670);
2487 if (ret) {
2488 err_msg = "ov5670_identify_module() error";
2489 goto error_print;
2490 }
2491
2492 mutex_init(&ov5670->mutex);
2493
2494 /* Set default mode to max resolution */
2495 ov5670->cur_mode = &supported_modes[0];
2496
2497 ret = ov5670_init_controls(ov5670);
2498 if (ret) {
2499 err_msg = "ov5670_init_controls() error";
2500 goto error_mutex_destroy;
2501 }
2502
2503 ov5670->sd.internal_ops = &ov5670_internal_ops;
2504 ov5670->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
2505 ov5670->sd.entity.ops = &ov5670_subdev_entity_ops;
2506 ov5670->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
2507
2508 /* Source pad initialization */
2509 ov5670->pad.flags = MEDIA_PAD_FL_SOURCE;
2510 ret = media_entity_pads_init(&ov5670->sd.entity, 1, &ov5670->pad);
2511 if (ret) {
2512 err_msg = "media_entity_pads_init() error";
2513 goto error_handler_free;
2514 }
2515
2516 /* Async register for subdev */
2517 ret = v4l2_async_register_subdev(&ov5670->sd);
2518 if (ret < 0) {
2519 err_msg = "v4l2_async_register_subdev() error";
2520 goto error_entity_cleanup;
2521 }
2522
2523 ov5670->streaming = false;
2524
2525 /*
2526 * Device is already turned on by i2c-core with ACPI domain PM.
2527 * Enable runtime PM and turn off the device.
2528 */
2529 pm_runtime_get_noresume(&client->dev);
2530 pm_runtime_set_active(&client->dev);
2531 pm_runtime_enable(&client->dev);
2532 pm_runtime_put(&client->dev);
2533
2534 return 0;
2535
2536error_entity_cleanup:
2537 media_entity_cleanup(&ov5670->sd.entity);
2538
2539error_handler_free:
2540 v4l2_ctrl_handler_free(ov5670->sd.ctrl_handler);
2541
2542error_mutex_destroy:
2543 mutex_destroy(&ov5670->mutex);
2544
2545error_print:
2546 dev_err(&client->dev, "%s: %s %d\n", __func__, err_msg, ret);
2547
2548 return ret;
2549}
2550
2551static int ov5670_remove(struct i2c_client *client)
2552{
2553 struct v4l2_subdev *sd = i2c_get_clientdata(client);
2554 struct ov5670 *ov5670 = to_ov5670(sd);
2555
2556 v4l2_async_unregister_subdev(sd);
2557 media_entity_cleanup(&sd->entity);
2558 v4l2_ctrl_handler_free(sd->ctrl_handler);
2559 mutex_destroy(&ov5670->mutex);
2560
2561 /*
2562 * Disable runtime PM but keep the device turned on.
2563 * i2c-core with ACPI domain PM will turn off the device.
2564 */
2565 pm_runtime_get_sync(&client->dev);
2566 pm_runtime_disable(&client->dev);
2567 pm_runtime_set_suspended(&client->dev);
2568 pm_runtime_put_noidle(&client->dev);
2569
2570 return 0;
2571}
2572
2573static const struct dev_pm_ops ov5670_pm_ops = {
2574 SET_SYSTEM_SLEEP_PM_OPS(ov5670_suspend, ov5670_resume)
2575};
2576
2577#ifdef CONFIG_ACPI
2578static const struct acpi_device_id ov5670_acpi_ids[] = {
2579 {"INT3479"},
2580 { /* sentinel */ }
2581};
2582
2583MODULE_DEVICE_TABLE(acpi, ov5670_acpi_ids);
2584#endif
2585
2586static struct i2c_driver ov5670_i2c_driver = {
2587 .driver = {
2588 .name = "ov5670",
2589 .pm = &ov5670_pm_ops,
2590 .acpi_match_table = ACPI_PTR(ov5670_acpi_ids),
2591 },
2592 .probe_new = ov5670_probe,
2593 .remove = ov5670_remove,
2594};
2595
2596module_i2c_driver(ov5670_i2c_driver);
2597
2598MODULE_AUTHOR("Rapolu, Chiranjeevi <chiranjeevi.rapolu@intel.com>");
2599MODULE_AUTHOR("Yang, Hyungwoo <hyungwoo.yang@intel.com>");
2600MODULE_DESCRIPTION("Omnivision ov5670 sensor driver");
2601MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/i2c/soc_camera/ov6650.c b/drivers/media/i2c/ov6650.c
index d2be64d54b22..768f2950ea36 100644
--- a/drivers/media/i2c/soc_camera/ov6650.c
+++ b/drivers/media/i2c/ov6650.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * V4L2 SoC Camera driver for OmniVision OV6650 Camera Sensor 2 * V4L2 subdevice driver for OmniVision OV6650 Camera Sensor
3 * 3 *
4 * Copyright (C) 2010 Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> 4 * Copyright (C) 2010 Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
5 * 5 *
@@ -31,9 +31,9 @@
31#include <linux/v4l2-mediabus.h> 31#include <linux/v4l2-mediabus.h>
32#include <linux/module.h> 32#include <linux/module.h>
33 33
34#include <media/soc_camera.h>
35#include <media/v4l2-clk.h> 34#include <media/v4l2-clk.h>
36#include <media/v4l2-ctrls.h> 35#include <media/v4l2-ctrls.h>
36#include <media/v4l2-device.h>
37 37
38/* Register definitions */ 38/* Register definitions */
39#define REG_GAIN 0x00 /* range 00 - 3F */ 39#define REG_GAIN 0x00 /* range 00 - 3F */
@@ -426,10 +426,15 @@ static int ov6650_set_register(struct v4l2_subdev *sd,
426static int ov6650_s_power(struct v4l2_subdev *sd, int on) 426static int ov6650_s_power(struct v4l2_subdev *sd, int on)
427{ 427{
428 struct i2c_client *client = v4l2_get_subdevdata(sd); 428 struct i2c_client *client = v4l2_get_subdevdata(sd);
429 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
430 struct ov6650 *priv = to_ov6650(client); 429 struct ov6650 *priv = to_ov6650(client);
430 int ret = 0;
431 431
432 return soc_camera_set_power(&client->dev, ssdd, priv->clk, on); 432 if (on)
433 ret = v4l2_clk_enable(priv->clk);
434 else
435 v4l2_clk_disable(priv->clk);
436
437 return ret;
433} 438}
434 439
435static int ov6650_get_selection(struct v4l2_subdev *sd, 440static int ov6650_get_selection(struct v4l2_subdev *sd,
@@ -471,14 +476,13 @@ static int ov6650_set_selection(struct v4l2_subdev *sd,
471 sel->target != V4L2_SEL_TGT_CROP) 476 sel->target != V4L2_SEL_TGT_CROP)
472 return -EINVAL; 477 return -EINVAL;
473 478
474 rect.left = ALIGN(rect.left, 2); 479 v4l_bound_align_image(&rect.width, 2, W_CIF, 1,
475 rect.width = ALIGN(rect.width, 2); 480 &rect.height, 2, H_CIF, 1, 0);
476 rect.top = ALIGN(rect.top, 2); 481 v4l_bound_align_image(&rect.left, DEF_HSTRT << 1,
477 rect.height = ALIGN(rect.height, 2); 482 (DEF_HSTRT << 1) + W_CIF - (__s32)rect.width, 1,
478 soc_camera_limit_side(&rect.left, &rect.width, 483 &rect.top, DEF_VSTRT << 1,
479 DEF_HSTRT << 1, 2, W_CIF); 484 (DEF_VSTRT << 1) + H_CIF - (__s32)rect.height, 1,
480 soc_camera_limit_side(&rect.top, &rect.height, 485 0);
481 DEF_VSTRT << 1, 2, H_CIF);
482 486
483 ret = ov6650_reg_write(client, REG_HSTRT, rect.left >> 1); 487 ret = ov6650_reg_write(client, REG_HSTRT, rect.left >> 1);
484 if (!ret) { 488 if (!ret) {
@@ -547,8 +551,6 @@ static u8 to_clkrc(struct v4l2_fract *timeperframe,
547static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) 551static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
548{ 552{
549 struct i2c_client *client = v4l2_get_subdevdata(sd); 553 struct i2c_client *client = v4l2_get_subdevdata(sd);
550 struct soc_camera_device *icd = v4l2_get_subdev_hostdata(sd);
551 struct soc_camera_sense *sense = icd->sense;
552 struct ov6650 *priv = to_ov6650(client); 554 struct ov6650 *priv = to_ov6650(client);
553 bool half_scale = !is_unscaled_ok(mf->width, mf->height, &priv->rect); 555 bool half_scale = !is_unscaled_ok(mf->width, mf->height, &priv->rect);
554 struct v4l2_subdev_selection sel = { 556 struct v4l2_subdev_selection sel = {
@@ -640,32 +642,10 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
640 } 642 }
641 priv->half_scale = half_scale; 643 priv->half_scale = half_scale;
642 644
643 if (sense) { 645 clkrc = CLKRC_12MHz;
644 if (sense->master_clock == 8000000) { 646 mclk = 12000000;
645 dev_dbg(&client->dev, "8MHz input clock\n"); 647 priv->pclk_limit = 1334000;
646 clkrc = CLKRC_6MHz; 648 dev_dbg(&client->dev, "using 12MHz input clock\n");
647 } else if (sense->master_clock == 12000000) {
648 dev_dbg(&client->dev, "12MHz input clock\n");
649 clkrc = CLKRC_12MHz;
650 } else if (sense->master_clock == 16000000) {
651 dev_dbg(&client->dev, "16MHz input clock\n");
652 clkrc = CLKRC_16MHz;
653 } else if (sense->master_clock == 24000000) {
654 dev_dbg(&client->dev, "24MHz input clock\n");
655 clkrc = CLKRC_24MHz;
656 } else {
657 dev_err(&client->dev,
658 "unsupported input clock, check platform data\n");
659 return -EINVAL;
660 }
661 mclk = sense->master_clock;
662 priv->pclk_limit = sense->pixel_clock_max;
663 } else {
664 clkrc = CLKRC_24MHz;
665 mclk = 24000000;
666 priv->pclk_limit = 0;
667 dev_dbg(&client->dev, "using default 24MHz input clock\n");
668 }
669 649
670 clkrc |= to_clkrc(&priv->tpf, priv->pclk_limit, priv->pclk_max); 650 clkrc |= to_clkrc(&priv->tpf, priv->pclk_limit, priv->pclk_max);
671 651
@@ -899,8 +879,6 @@ static const struct v4l2_subdev_core_ops ov6650_core_ops = {
899static int ov6650_g_mbus_config(struct v4l2_subdev *sd, 879static int ov6650_g_mbus_config(struct v4l2_subdev *sd,
900 struct v4l2_mbus_config *cfg) 880 struct v4l2_mbus_config *cfg)
901{ 881{
902 struct i2c_client *client = v4l2_get_subdevdata(sd);
903 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
904 882
905 cfg->flags = V4L2_MBUS_MASTER | 883 cfg->flags = V4L2_MBUS_MASTER |
906 V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_PCLK_SAMPLE_FALLING | 884 V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_PCLK_SAMPLE_FALLING |
@@ -908,7 +886,6 @@ static int ov6650_g_mbus_config(struct v4l2_subdev *sd,
908 V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_LOW | 886 V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_LOW |
909 V4L2_MBUS_DATA_ACTIVE_HIGH; 887 V4L2_MBUS_DATA_ACTIVE_HIGH;
910 cfg->type = V4L2_MBUS_PARALLEL; 888 cfg->type = V4L2_MBUS_PARALLEL;
911 cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
912 889
913 return 0; 890 return 0;
914} 891}
@@ -918,25 +895,23 @@ static int ov6650_s_mbus_config(struct v4l2_subdev *sd,
918 const struct v4l2_mbus_config *cfg) 895 const struct v4l2_mbus_config *cfg)
919{ 896{
920 struct i2c_client *client = v4l2_get_subdevdata(sd); 897 struct i2c_client *client = v4l2_get_subdevdata(sd);
921 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
922 unsigned long flags = soc_camera_apply_board_flags(ssdd, cfg);
923 int ret; 898 int ret;
924 899
925 if (flags & V4L2_MBUS_PCLK_SAMPLE_RISING) 900 if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
926 ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0); 901 ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
927 else 902 else
928 ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING); 903 ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);
929 if (ret) 904 if (ret)
930 return ret; 905 return ret;
931 906
932 if (flags & V4L2_MBUS_HSYNC_ACTIVE_LOW) 907 if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
933 ret = ov6650_reg_rmw(client, REG_COMF, COMF_HREF_LOW, 0); 908 ret = ov6650_reg_rmw(client, REG_COMF, COMF_HREF_LOW, 0);
934 else 909 else
935 ret = ov6650_reg_rmw(client, REG_COMF, 0, COMF_HREF_LOW); 910 ret = ov6650_reg_rmw(client, REG_COMF, 0, COMF_HREF_LOW);
936 if (ret) 911 if (ret)
937 return ret; 912 return ret;
938 913
939 if (flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) 914 if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
940 ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_VSYNC_HIGH, 0); 915 ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_VSYNC_HIGH, 0);
941 else 916 else
942 ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_VSYNC_HIGH); 917 ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_VSYNC_HIGH);
@@ -973,14 +948,8 @@ static int ov6650_probe(struct i2c_client *client,
973 const struct i2c_device_id *did) 948 const struct i2c_device_id *did)
974{ 949{
975 struct ov6650 *priv; 950 struct ov6650 *priv;
976 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
977 int ret; 951 int ret;
978 952
979 if (!ssdd) {
980 dev_err(&client->dev, "Missing platform_data for driver\n");
981 return -EINVAL;
982 }
983
984 priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL); 953 priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
985 if (!priv) { 954 if (!priv) {
986 dev_err(&client->dev, 955 dev_err(&client->dev,
diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index 7270c68ed18a..e88549f0e704 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -1614,8 +1614,10 @@ static int ov7670_probe(struct i2c_client *client,
1614 1614
1615 info->clk = devm_clk_get(&client->dev, "xclk"); 1615 info->clk = devm_clk_get(&client->dev, "xclk");
1616 if (IS_ERR(info->clk)) 1616 if (IS_ERR(info->clk))
1617 return -EPROBE_DEFER; 1617 return PTR_ERR(info->clk);
1618 clk_prepare_enable(info->clk); 1618 ret = clk_prepare_enable(info->clk);
1619 if (ret)
1620 return ret;
1619 1621
1620 ret = ov7670_init_gpio(client, info); 1622 ret = ov7670_init_gpio(client, info);
1621 if (ret) 1623 if (ret)
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 2de2fbb13b85..6ffb460e8589 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -484,6 +484,7 @@ static int ov965x_set_default_gamma_curve(struct ov965x *ov965x)
484 484
485 for (i = 0; i < ARRAY_SIZE(gamma_curve); i++) { 485 for (i = 0; i < ARRAY_SIZE(gamma_curve); i++) {
486 int ret = ov965x_write(ov965x->client, addr, gamma_curve[i]); 486 int ret = ov965x_write(ov965x->client, addr, gamma_curve[i]);
487
487 if (ret < 0) 488 if (ret < 0)
488 return ret; 489 return ret;
489 addr++; 490 addr++;
@@ -503,6 +504,7 @@ static int ov965x_set_color_matrix(struct ov965x *ov965x)
503 504
504 for (i = 0; i < ARRAY_SIZE(mtx); i++) { 505 for (i = 0; i < ARRAY_SIZE(mtx); i++) {
505 int ret = ov965x_write(ov965x->client, addr, mtx[i]); 506 int ret = ov965x_write(ov965x->client, addr, mtx[i]);
507
506 if (ret < 0) 508 if (ret < 0)
507 return ret; 509 return ret;
508 addr++; 510 addr++;
@@ -611,7 +613,7 @@ static int ov965x_set_banding_filter(struct ov965x *ov965x, int value)
611 } 613 }
612 if (value == V4L2_CID_POWER_LINE_FREQUENCY_DISABLED) 614 if (value == V4L2_CID_POWER_LINE_FREQUENCY_DISABLED)
613 return 0; 615 return 0;
614 if (WARN_ON(ov965x->fiv == NULL)) 616 if (WARN_ON(!ov965x->fiv))
615 return -EINVAL; 617 return -EINVAL;
616 /* Set minimal exposure time for 50/60 HZ lighting */ 618 /* Set minimal exposure time for 50/60 HZ lighting */
617 if (value == V4L2_CID_POWER_LINE_FREQUENCY_50HZ) 619 if (value == V4L2_CID_POWER_LINE_FREQUENCY_50HZ)
@@ -999,44 +1001,47 @@ static int ov965x_initialize_controls(struct ov965x *ov965x)
999 1001
1000 /* Auto/manual white balance */ 1002 /* Auto/manual white balance */
1001 ctrls->auto_wb = v4l2_ctrl_new_std(hdl, ops, 1003 ctrls->auto_wb = v4l2_ctrl_new_std(hdl, ops,
1002 V4L2_CID_AUTO_WHITE_BALANCE, 1004 V4L2_CID_AUTO_WHITE_BALANCE,
1003 0, 1, 1, 1); 1005 0, 1, 1, 1);
1004 ctrls->blue_balance = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BLUE_BALANCE, 1006 ctrls->blue_balance = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BLUE_BALANCE,
1005 0, 0xff, 1, 0x80); 1007 0, 0xff, 1, 0x80);
1006 ctrls->red_balance = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_RED_BALANCE, 1008 ctrls->red_balance = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_RED_BALANCE,
1007 0, 0xff, 1, 0x80); 1009 0, 0xff, 1, 0x80);
1008 /* Auto/manual exposure */ 1010 /* Auto/manual exposure */
1009 ctrls->auto_exp = v4l2_ctrl_new_std_menu(hdl, ops, 1011 ctrls->auto_exp =
1010 V4L2_CID_EXPOSURE_AUTO, 1012 v4l2_ctrl_new_std_menu(hdl, ops,
1011 V4L2_EXPOSURE_MANUAL, 0, V4L2_EXPOSURE_AUTO); 1013 V4L2_CID_EXPOSURE_AUTO,
1014 V4L2_EXPOSURE_MANUAL, 0,
1015 V4L2_EXPOSURE_AUTO);
1012 /* Exposure time, in 100 us units. min/max is updated dynamically. */ 1016 /* Exposure time, in 100 us units. min/max is updated dynamically. */
1013 ctrls->exposure = v4l2_ctrl_new_std(hdl, ops, 1017 ctrls->exposure = v4l2_ctrl_new_std(hdl, ops,
1014 V4L2_CID_EXPOSURE_ABSOLUTE, 1018 V4L2_CID_EXPOSURE_ABSOLUTE,
1015 2, 1500, 1, 500); 1019 2, 1500, 1, 500);
1016 /* Auto/manual gain */ 1020 /* Auto/manual gain */
1017 ctrls->auto_gain = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_AUTOGAIN, 1021 ctrls->auto_gain = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_AUTOGAIN,
1018 0, 1, 1, 1); 1022 0, 1, 1, 1);
1019 ctrls->gain = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_GAIN, 1023 ctrls->gain = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_GAIN,
1020 16, 64 * (16 + 15), 1, 64 * 16); 1024 16, 64 * (16 + 15), 1, 64 * 16);
1021 1025
1022 ctrls->saturation = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_SATURATION, 1026 ctrls->saturation = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_SATURATION,
1023 -2, 2, 1, 0); 1027 -2, 2, 1, 0);
1024 ctrls->brightness = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BRIGHTNESS, 1028 ctrls->brightness = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BRIGHTNESS,
1025 -3, 3, 1, 0); 1029 -3, 3, 1, 0);
1026 ctrls->sharpness = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_SHARPNESS, 1030 ctrls->sharpness = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_SHARPNESS,
1027 0, 32, 1, 6); 1031 0, 32, 1, 6);
1028 1032
1029 ctrls->hflip = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_HFLIP, 0, 1, 1, 0); 1033 ctrls->hflip = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_HFLIP, 0, 1, 1, 0);
1030 ctrls->vflip = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_VFLIP, 0, 1, 1, 0); 1034 ctrls->vflip = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_VFLIP, 0, 1, 1, 0);
1031 1035
1032 ctrls->light_freq = v4l2_ctrl_new_std_menu(hdl, ops, 1036 ctrls->light_freq =
1033 V4L2_CID_POWER_LINE_FREQUENCY, 1037 v4l2_ctrl_new_std_menu(hdl, ops,
1034 V4L2_CID_POWER_LINE_FREQUENCY_60HZ, ~0x7, 1038 V4L2_CID_POWER_LINE_FREQUENCY,
1035 V4L2_CID_POWER_LINE_FREQUENCY_50HZ); 1039 V4L2_CID_POWER_LINE_FREQUENCY_60HZ, ~0x7,
1040 V4L2_CID_POWER_LINE_FREQUENCY_50HZ);
1036 1041
1037 v4l2_ctrl_new_std_menu_items(hdl, ops, V4L2_CID_TEST_PATTERN, 1042 v4l2_ctrl_new_std_menu_items(hdl, ops, V4L2_CID_TEST_PATTERN,
1038 ARRAY_SIZE(test_pattern_menu) - 1, 0, 0, 1043 ARRAY_SIZE(test_pattern_menu) - 1, 0, 0,
1039 test_pattern_menu); 1044 test_pattern_menu);
1040 if (hdl->error) { 1045 if (hdl->error) {
1041 ret = hdl->error; 1046 ret = hdl->error;
1042 v4l2_ctrl_handler_free(hdl); 1047 v4l2_ctrl_handler_free(hdl);
@@ -1121,7 +1126,6 @@ static int __ov965x_set_frame_interval(struct ov965x *ov965x,
1121 u64 req_int, err, min_err = ~0ULL; 1126 u64 req_int, err, min_err = ~0ULL;
1122 unsigned int i; 1127 unsigned int i;
1123 1128
1124
1125 if (fi->interval.denominator == 0) 1129 if (fi->interval.denominator == 0)
1126 return -EINVAL; 1130 return -EINVAL;
1127 1131
@@ -1165,7 +1169,8 @@ static int ov965x_s_frame_interval(struct v4l2_subdev *sd,
1165 return ret; 1169 return ret;
1166} 1170}
1167 1171
1168static int ov965x_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, 1172static int ov965x_get_fmt(struct v4l2_subdev *sd,
1173 struct v4l2_subdev_pad_config *cfg,
1169 struct v4l2_subdev_format *fmt) 1174 struct v4l2_subdev_format *fmt)
1170{ 1175{
1171 struct ov965x *ov965x = to_ov965x(sd); 1176 struct ov965x *ov965x = to_ov965x(sd);
@@ -1209,7 +1214,8 @@ static void __ov965x_try_frame_size(struct v4l2_mbus_framefmt *mf,
1209 *size = match; 1214 *size = match;
1210} 1215}
1211 1216
1212static int ov965x_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, 1217static int ov965x_set_fmt(struct v4l2_subdev *sd,
1218 struct v4l2_subdev_pad_config *cfg,
1213 struct v4l2_subdev_format *fmt) 1219 struct v4l2_subdev_format *fmt)
1214{ 1220{
1215 unsigned int index = ARRAY_SIZE(ov965x_formats); 1221 unsigned int index = ARRAY_SIZE(ov965x_formats);
@@ -1231,7 +1237,7 @@ static int ov965x_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config
1231 mutex_lock(&ov965x->lock); 1237 mutex_lock(&ov965x->lock);
1232 1238
1233 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 1239 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
1234 if (cfg != NULL) { 1240 if (cfg) {
1235 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad); 1241 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
1236 *mf = fmt->format; 1242 *mf = fmt->format;
1237 } 1243 }
@@ -1362,7 +1368,8 @@ static int ov965x_s_stream(struct v4l2_subdev *sd, int on)
1362 */ 1368 */
1363static int ov965x_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) 1369static int ov965x_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1364{ 1370{
1365 struct v4l2_mbus_framefmt *mf = v4l2_subdev_get_try_format(sd, fh->pad, 0); 1371 struct v4l2_mbus_framefmt *mf =
1372 v4l2_subdev_get_try_format(sd, fh->pad, 0);
1366 1373
1367 ov965x_get_default_format(mf); 1374 ov965x_get_default_format(mf);
1368 return 0; 1375 return 0;
@@ -1470,7 +1477,7 @@ static int ov965x_probe(struct i2c_client *client,
1470 struct ov965x *ov965x; 1477 struct ov965x *ov965x;
1471 int ret; 1478 int ret;
1472 1479
1473 if (pdata == NULL) { 1480 if (!pdata) {
1474 dev_err(&client->dev, "platform data not specified\n"); 1481 dev_err(&client->dev, "platform data not specified\n");
1475 return -EINVAL; 1482 return -EINVAL;
1476 } 1483 }
@@ -1498,13 +1505,13 @@ static int ov965x_probe(struct i2c_client *client,
1498 1505
1499 ret = ov965x_configure_gpios(ov965x, pdata); 1506 ret = ov965x_configure_gpios(ov965x, pdata);
1500 if (ret < 0) 1507 if (ret < 0)
1501 return ret; 1508 goto err_mutex;
1502 1509
1503 ov965x->pad.flags = MEDIA_PAD_FL_SOURCE; 1510 ov965x->pad.flags = MEDIA_PAD_FL_SOURCE;
1504 sd->entity.function = MEDIA_ENT_F_CAM_SENSOR; 1511 sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
1505 ret = media_entity_pads_init(&sd->entity, 1, &ov965x->pad); 1512 ret = media_entity_pads_init(&sd->entity, 1, &ov965x->pad);
1506 if (ret < 0) 1513 if (ret < 0)
1507 return ret; 1514 goto err_mutex;
1508 1515
1509 ret = ov965x_initialize_controls(ov965x); 1516 ret = ov965x_initialize_controls(ov965x);
1510 if (ret < 0) 1517 if (ret < 0)
@@ -1530,16 +1537,20 @@ err_ctrls:
1530 v4l2_ctrl_handler_free(sd->ctrl_handler); 1537 v4l2_ctrl_handler_free(sd->ctrl_handler);
1531err_me: 1538err_me:
1532 media_entity_cleanup(&sd->entity); 1539 media_entity_cleanup(&sd->entity);
1540err_mutex:
1541 mutex_destroy(&ov965x->lock);
1533 return ret; 1542 return ret;
1534} 1543}
1535 1544
1536static int ov965x_remove(struct i2c_client *client) 1545static int ov965x_remove(struct i2c_client *client)
1537{ 1546{
1538 struct v4l2_subdev *sd = i2c_get_clientdata(client); 1547 struct v4l2_subdev *sd = i2c_get_clientdata(client);
1548 struct ov965x *ov965x = to_ov965x(sd);
1539 1549
1540 v4l2_async_unregister_subdev(sd); 1550 v4l2_async_unregister_subdev(sd);
1541 v4l2_ctrl_handler_free(sd->ctrl_handler); 1551 v4l2_ctrl_handler_free(sd->ctrl_handler);
1542 media_entity_cleanup(&sd->entity); 1552 media_entity_cleanup(&sd->entity);
1553 mutex_destroy(&ov965x->lock);
1543 1554
1544 return 0; 1555 return 0;
1545} 1556}
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index f434fb2ee6fc..cdc4f2392ef9 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1635,8 +1635,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)
1635 1635
1636 node_ep = of_graph_get_next_endpoint(node, NULL); 1636 node_ep = of_graph_get_next_endpoint(node, NULL);
1637 if (!node_ep) { 1637 if (!node_ep) {
1638 dev_warn(dev, "no endpoint defined for node: %s\n", 1638 dev_warn(dev, "no endpoint defined for node: %pOF\n", node);
1639 node->full_name);
1640 return 0; 1639 return 0;
1641 } 1640 }
1642 1641
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 962051b9939d..ff46d2c96cea 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -1374,7 +1374,7 @@ static int s5k5baf_get_selection(struct v4l2_subdev *sd,
1374 struct v4l2_subdev_pad_config *cfg, 1374 struct v4l2_subdev_pad_config *cfg,
1375 struct v4l2_subdev_selection *sel) 1375 struct v4l2_subdev_selection *sel)
1376{ 1376{
1377 static enum selection_rect rtype; 1377 enum selection_rect rtype;
1378 struct s5k5baf *state = to_s5k5baf(sd); 1378 struct s5k5baf *state = to_s5k5baf(sd);
1379 1379
1380 rtype = s5k5baf_get_sel_rect(sel->pad, sel->target); 1380 rtype = s5k5baf_get_sel_rect(sel->pad, sel->target);
@@ -1863,8 +1863,7 @@ static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev)
1863 1863
1864 node_ep = of_graph_get_next_endpoint(node, NULL); 1864 node_ep = of_graph_get_next_endpoint(node, NULL);
1865 if (!node_ep) { 1865 if (!node_ep) {
1866 dev_err(dev, "no endpoint defined at node %s\n", 1866 dev_err(dev, "no endpoint defined at node %pOF\n", node);
1867 node->full_name);
1868 return -EINVAL; 1867 return -EINVAL;
1869 } 1868 }
1870 1869
@@ -1882,8 +1881,8 @@ static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev)
1882 case V4L2_MBUS_PARALLEL: 1881 case V4L2_MBUS_PARALLEL:
1883 break; 1882 break;
1884 default: 1883 default:
1885 dev_err(dev, "unsupported bus in endpoint defined at node %s\n", 1884 dev_err(dev, "unsupported bus in endpoint defined at node %pOF\n",
1886 node->full_name); 1885 node);
1887 return -EINVAL; 1886 return -EINVAL;
1888 } 1887 }
1889 1888
diff --git a/drivers/media/i2c/saa7127.c b/drivers/media/i2c/saa7127.c
index 99c303002e90..01784d441ae6 100644
--- a/drivers/media/i2c/saa7127.c
+++ b/drivers/media/i2c/saa7127.c
@@ -806,7 +806,7 @@ static int saa7127_remove(struct i2c_client *client)
806 806
807/* ----------------------------------------------------------------------- */ 807/* ----------------------------------------------------------------------- */
808 808
809static struct i2c_device_id saa7127_id[] = { 809static const struct i2c_device_id saa7127_id[] = {
810 { "saa7127_auto", 0 }, /* auto-detection */ 810 { "saa7127_auto", 0 }, /* auto-detection */
811 { "saa7126", SAA7127 }, 811 { "saa7126", SAA7127 },
812 { "saa7127", SAA7127 }, 812 { "saa7127", SAA7127 },
diff --git a/drivers/media/i2c/saa717x.c b/drivers/media/i2c/saa717x.c
index e1f6bc219c64..102467e00fb3 100644
--- a/drivers/media/i2c/saa717x.c
+++ b/drivers/media/i2c/saa717x.c
@@ -1069,7 +1069,7 @@ static int saa717x_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
1069 struct saa717x_state *decoder = to_state(sd); 1069 struct saa717x_state *decoder = to_state(sd);
1070 1070
1071 v4l2_dbg(1, debug, sd, "decoder set norm "); 1071 v4l2_dbg(1, debug, sd, "decoder set norm ");
1072 v4l2_dbg(1, debug, sd, "(not yet implementd)\n"); 1072 v4l2_dbg(1, debug, sd, "(not yet implemented)\n");
1073 1073
1074 decoder->radio = 0; 1074 decoder->radio = 0;
1075 decoder->std = std; 1075 decoder->std = std;
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index e0b0c032c4ac..700f433261d0 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -841,6 +841,8 @@ static int smiapp_get_mbus_formats(struct smiapp_sensor *sensor)
841 &client->dev, 841 &client->dev,
842 compressed_max_bpp - sensor->compressed_min_bpp + 1, 842 compressed_max_bpp - sensor->compressed_min_bpp + 1,
843 sizeof(*sensor->valid_link_freqs), GFP_KERNEL); 843 sizeof(*sensor->valid_link_freqs), GFP_KERNEL);
844 if (!sensor->valid_link_freqs)
845 return -ENOMEM;
844 846
845 for (i = 0; i < ARRAY_SIZE(smiapp_csi_data_formats); i++) { 847 for (i = 0; i < ARRAY_SIZE(smiapp_csi_data_formats); i++) {
846 const struct smiapp_csi_data_format *f = 848 const struct smiapp_csi_data_format *f =
@@ -2809,13 +2811,19 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)
2809 switch (bus_cfg->bus_type) { 2811 switch (bus_cfg->bus_type) {
2810 case V4L2_MBUS_CSI2: 2812 case V4L2_MBUS_CSI2:
2811 hwcfg->csi_signalling_mode = SMIAPP_CSI_SIGNALLING_MODE_CSI2; 2813 hwcfg->csi_signalling_mode = SMIAPP_CSI_SIGNALLING_MODE_CSI2;
2814 hwcfg->lanes = bus_cfg->bus.mipi_csi2.num_data_lanes;
2815 break;
2816 case V4L2_MBUS_CCP2:
2817 hwcfg->csi_signalling_mode = (bus_cfg->bus.mipi_csi1.strobe) ?
2818 SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_STROBE :
2819 SMIAPP_CSI_SIGNALLING_MODE_CCP2_DATA_CLOCK;
2820 hwcfg->lanes = 1;
2812 break; 2821 break;
2813 /* FIXME: add CCP2 support. */
2814 default: 2822 default:
2823 dev_err(dev, "unsupported bus %u\n", bus_cfg->bus_type);
2815 goto out_err; 2824 goto out_err;
2816 } 2825 }
2817 2826
2818 hwcfg->lanes = bus_cfg->bus.mipi_csi2.num_data_lanes;
2819 dev_dbg(dev, "lanes %u\n", hwcfg->lanes); 2827 dev_dbg(dev, "lanes %u\n", hwcfg->lanes);
2820 2828
2821 /* NVM size is not mandatory */ 2829 /* NVM size is not mandatory */
@@ -2828,8 +2836,8 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)
2828 goto out_err; 2836 goto out_err;
2829 } 2837 }
2830 2838
2831 dev_dbg(dev, "nvm %d, clk %d, csi %d\n", hwcfg->nvm_size, 2839 dev_dbg(dev, "nvm %d, clk %d, mode %d\n",
2832 hwcfg->ext_clk, hwcfg->csi_signalling_mode); 2840 hwcfg->nvm_size, hwcfg->ext_clk, hwcfg->csi_signalling_mode);
2833 2841
2834 if (!bus_cfg->nr_of_link_frequencies) { 2842 if (!bus_cfg->nr_of_link_frequencies) {
2835 dev_warn(dev, "no link frequencies defined\n"); 2843 dev_warn(dev, "no link frequencies defined\n");
diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.c b/drivers/media/i2c/smiapp/smiapp-quirk.c
index cb128eae9c54..95c0272bb014 100644
--- a/drivers/media/i2c/smiapp/smiapp-quirk.c
+++ b/drivers/media/i2c/smiapp/smiapp-quirk.c
@@ -71,7 +71,7 @@ static int jt8ew9_limits(struct smiapp_sensor *sensor)
71 71
72static int jt8ew9_post_poweron(struct smiapp_sensor *sensor) 72static int jt8ew9_post_poweron(struct smiapp_sensor *sensor)
73{ 73{
74 const struct smiapp_reg_8 regs[] = { 74 static const struct smiapp_reg_8 regs[] = {
75 { 0x30a3, 0xd8 }, /* Output port control : LVDS ports only */ 75 { 0x30a3, 0xd8 }, /* Output port control : LVDS ports only */
76 { 0x30ae, 0x00 }, /* 0x0307 pll_multiplier maximum value on PLL input 9.6MHz ( 19.2MHz is divided on pre_pll_div) */ 76 { 0x30ae, 0x00 }, /* 0x0307 pll_multiplier maximum value on PLL input 9.6MHz ( 19.2MHz is divided on pre_pll_div) */
77 { 0x30af, 0xd0 }, /* 0x0307 pll_multiplier maximum value on PLL input 9.6MHz ( 19.2MHz is divided on pre_pll_div) */ 77 { 0x30af, 0xd0 }, /* 0x0307 pll_multiplier maximum value on PLL input 9.6MHz ( 19.2MHz is divided on pre_pll_div) */
@@ -115,7 +115,7 @@ const struct smiapp_quirk smiapp_jt8ew9_quirk = {
115static int imx125es_post_poweron(struct smiapp_sensor *sensor) 115static int imx125es_post_poweron(struct smiapp_sensor *sensor)
116{ 116{
117 /* Taken from v02. No idea what the other two are. */ 117 /* Taken from v02. No idea what the other two are. */
118 const struct smiapp_reg_8 regs[] = { 118 static const struct smiapp_reg_8 regs[] = {
119 /* 119 /*
120 * 0x3302: clk during frame blanking: 120 * 0x3302: clk during frame blanking:
121 * 0x00 - HS mode, 0x01 - LP11 121 * 0x00 - HS mode, 0x01 - LP11
@@ -145,7 +145,7 @@ static int jt8ev1_post_poweron(struct smiapp_sensor *sensor)
145{ 145{
146 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); 146 struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
147 int rval; 147 int rval;
148 const struct smiapp_reg_8 regs[] = { 148 static const struct smiapp_reg_8 regs[] = {
149 { 0x3031, 0xcd }, /* For digital binning (EQ_MONI) */ 149 { 0x3031, 0xcd }, /* For digital binning (EQ_MONI) */
150 { 0x30a3, 0xd0 }, /* FLASH STROBE enable */ 150 { 0x30a3, 0xd0 }, /* FLASH STROBE enable */
151 { 0x3237, 0x00 }, /* For control of pulse timing for ADC */ 151 { 0x3237, 0x00 }, /* For control of pulse timing for ADC */
@@ -166,7 +166,7 @@ static int jt8ev1_post_poweron(struct smiapp_sensor *sensor)
166 { 0x33cf, 0xec }, /* For Black sun */ 166 { 0x33cf, 0xec }, /* For Black sun */
167 { 0x3328, 0x80 }, /* Ugh. No idea what's this. */ 167 { 0x3328, 0x80 }, /* Ugh. No idea what's this. */
168 }; 168 };
169 const struct smiapp_reg_8 regs_96[] = { 169 static const struct smiapp_reg_8 regs_96[] = {
170 { 0x30ae, 0x00 }, /* For control of ADC clock */ 170 { 0x30ae, 0x00 }, /* For control of ADC clock */
171 { 0x30af, 0xd0 }, 171 { 0x30af, 0xd0 },
172 { 0x30b0, 0x01 }, 172 { 0x30b0, 0x01 },
diff --git a/drivers/media/i2c/soc_camera/Kconfig b/drivers/media/i2c/soc_camera/Kconfig
index 96859f37cb1c..72b369895b37 100644
--- a/drivers/media/i2c/soc_camera/Kconfig
+++ b/drivers/media/i2c/soc_camera/Kconfig
@@ -47,12 +47,6 @@ config SOC_CAMERA_OV5642
47 help 47 help
48 This is a V4L2 camera driver for the OmniVision OV5642 sensor 48 This is a V4L2 camera driver for the OmniVision OV5642 sensor
49 49
50config SOC_CAMERA_OV6650
51 tristate "ov6650 sensor support"
52 depends on SOC_CAMERA && I2C
53 ---help---
54 This is a V4L2 SoC camera driver for the OmniVision OV6650 sensor
55
56config SOC_CAMERA_OV772X 50config SOC_CAMERA_OV772X
57 tristate "ov772x camera support" 51 tristate "ov772x camera support"
58 depends on SOC_CAMERA && I2C 52 depends on SOC_CAMERA && I2C
diff --git a/drivers/media/i2c/soc_camera/Makefile b/drivers/media/i2c/soc_camera/Makefile
index 974bdb721dbe..78532a7fb8e2 100644
--- a/drivers/media/i2c/soc_camera/Makefile
+++ b/drivers/media/i2c/soc_camera/Makefile
@@ -4,7 +4,6 @@ obj-$(CONFIG_SOC_CAMERA_MT9T031) += mt9t031.o
4obj-$(CONFIG_SOC_CAMERA_MT9T112) += mt9t112.o 4obj-$(CONFIG_SOC_CAMERA_MT9T112) += mt9t112.o
5obj-$(CONFIG_SOC_CAMERA_MT9V022) += mt9v022.o 5obj-$(CONFIG_SOC_CAMERA_MT9V022) += mt9v022.o
6obj-$(CONFIG_SOC_CAMERA_OV5642) += ov5642.o 6obj-$(CONFIG_SOC_CAMERA_OV5642) += ov5642.o
7obj-$(CONFIG_SOC_CAMERA_OV6650) += ov6650.o
8obj-$(CONFIG_SOC_CAMERA_OV772X) += ov772x.o 7obj-$(CONFIG_SOC_CAMERA_OV772X) += ov772x.o
9obj-$(CONFIG_SOC_CAMERA_OV9640) += ov9640.o 8obj-$(CONFIG_SOC_CAMERA_OV9640) += ov9640.o
10obj-$(CONFIG_SOC_CAMERA_OV9740) += ov9740.o 9obj-$(CONFIG_SOC_CAMERA_OV9740) += ov9740.o
diff --git a/drivers/media/i2c/soc_camera/mt9t031.c b/drivers/media/i2c/soc_camera/mt9t031.c
index 714fb3555b34..4802d30e47de 100644
--- a/drivers/media/i2c/soc_camera/mt9t031.c
+++ b/drivers/media/i2c/soc_camera/mt9t031.c
@@ -592,7 +592,7 @@ static const struct dev_pm_ops mt9t031_dev_pm_ops = {
592 .runtime_resume = mt9t031_runtime_resume, 592 .runtime_resume = mt9t031_runtime_resume,
593}; 593};
594 594
595static struct device_type mt9t031_dev_type = { 595static const struct device_type mt9t031_dev_type = {
596 .name = "MT9T031", 596 .name = "MT9T031",
597 .pm = &mt9t031_dev_pm_ops, 597 .pm = &mt9t031_dev_pm_ops,
598}; 598};
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 5788af238b86..e6f5c363ccab 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -2013,7 +2013,7 @@ static int tc358743_remove(struct i2c_client *client)
2013 return 0; 2013 return 0;
2014} 2014}
2015 2015
2016static struct i2c_device_id tc358743_id[] = { 2016static const struct i2c_device_id tc358743_id[] = {
2017 {"tc358743", 0}, 2017 {"tc358743", 0},
2018 {} 2018 {}
2019}; 2019};
diff --git a/drivers/media/i2c/ths8200.c b/drivers/media/i2c/ths8200.c
index 42340e364cea..498ad2368cbc 100644
--- a/drivers/media/i2c/ths8200.c
+++ b/drivers/media/i2c/ths8200.c
@@ -483,7 +483,7 @@ static int ths8200_remove(struct i2c_client *client)
483 return 0; 483 return 0;
484} 484}
485 485
486static struct i2c_device_id ths8200_id[] = { 486static const struct i2c_device_id ths8200_id[] = {
487 { "ths8200", 0 }, 487 { "ths8200", 0 },
488 {}, 488 {},
489}; 489};
diff --git a/drivers/media/i2c/vs6624.c b/drivers/media/i2c/vs6624.c
index f0741ab338df..560738213c00 100644
--- a/drivers/media/i2c/vs6624.c
+++ b/drivers/media/i2c/vs6624.c
@@ -58,7 +58,7 @@ static const struct vs6624_format {
58 }, 58 },
59}; 59};
60 60
61static struct v4l2_mbus_framefmt vs6624_default_fmt = { 61static const struct v4l2_mbus_framefmt vs6624_default_fmt = {
62 .width = VGA_WIDTH, 62 .width = VGA_WIDTH,
63 .height = VGA_HEIGHT, 63 .height = VGA_HEIGHT,
64 .code = MEDIA_BUS_FMT_UYVY8_2X8, 64 .code = MEDIA_BUS_FMT_UYVY8_2X8,
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 760e3e424e23..e79f72b8b858 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -69,9 +69,9 @@ static int media_device_get_info(struct media_device *dev,
69 strlcpy(info->serial, dev->serial, sizeof(info->serial)); 69 strlcpy(info->serial, dev->serial, sizeof(info->serial));
70 strlcpy(info->bus_info, dev->bus_info, sizeof(info->bus_info)); 70 strlcpy(info->bus_info, dev->bus_info, sizeof(info->bus_info));
71 71
72 info->media_version = MEDIA_API_VERSION; 72 info->media_version = LINUX_VERSION_CODE;
73 info->driver_version = info->media_version;
73 info->hw_revision = dev->hw_revision; 74 info->hw_revision = dev->hw_revision;
74 info->driver_version = dev->driver_version;
75 75
76 return 0; 76 return 0;
77} 77}
@@ -537,9 +537,9 @@ static DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
537 * Registration/unregistration 537 * Registration/unregistration
538 */ 538 */
539 539
540static void media_device_release(struct media_devnode *mdev) 540static void media_device_release(struct media_devnode *devnode)
541{ 541{
542 dev_dbg(mdev->parent, "Media device released\n"); 542 dev_dbg(devnode->parent, "Media device released\n");
543} 543}
544 544
545/** 545/**
@@ -591,9 +591,8 @@ int __must_check media_device_register_entity(struct media_device *mdev,
591 &entity->pads[i].graph_obj); 591 &entity->pads[i].graph_obj);
592 592
593 /* invoke entity_notify callbacks */ 593 /* invoke entity_notify callbacks */
594 list_for_each_entry_safe(notify, next, &mdev->entity_notify, list) { 594 list_for_each_entry_safe(notify, next, &mdev->entity_notify, list)
595 (notify)->notify(entity, notify->notify_data); 595 notify->notify(entity, notify->notify_data);
596 }
597 596
598 if (mdev->entity_internal_idx_max 597 if (mdev->entity_internal_idx_max
599 >= mdev->pm_count_walk.ent_enum.idx_max) { 598 >= mdev->pm_count_walk.ent_enum.idx_max) {
@@ -834,8 +833,6 @@ void media_device_pci_init(struct media_device *mdev,
834 mdev->hw_revision = (pci_dev->subsystem_vendor << 16) 833 mdev->hw_revision = (pci_dev->subsystem_vendor << 16)
835 | pci_dev->subsystem_device; 834 | pci_dev->subsystem_device;
836 835
837 mdev->driver_version = LINUX_VERSION_CODE;
838
839 media_device_init(mdev); 836 media_device_init(mdev);
840} 837}
841EXPORT_SYMBOL_GPL(media_device_pci_init); 838EXPORT_SYMBOL_GPL(media_device_pci_init);
@@ -863,7 +860,6 @@ void __media_device_usb_init(struct media_device *mdev,
863 strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial)); 860 strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
864 usb_make_path(udev, mdev->bus_info, sizeof(mdev->bus_info)); 861 usb_make_path(udev, mdev->bus_info, sizeof(mdev->bus_info));
865 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); 862 mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
866 mdev->driver_version = LINUX_VERSION_CODE;
867 863
868 media_device_init(mdev); 864 media_device_init(mdev);
869} 865}
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index dd0f0ead9516..2ace0410d277 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -917,7 +917,7 @@ media_entity_find_link(struct media_pad *source, struct media_pad *sink)
917} 917}
918EXPORT_SYMBOL_GPL(media_entity_find_link); 918EXPORT_SYMBOL_GPL(media_entity_find_link);
919 919
920struct media_pad *media_entity_remote_pad(struct media_pad *pad) 920struct media_pad *media_entity_remote_pad(const struct media_pad *pad)
921{ 921{
922 struct media_link *link; 922 struct media_link *link;
923 923
diff --git a/drivers/media/pci/b2c2/flexcop-pci.c b/drivers/media/pci/b2c2/flexcop-pci.c
index 6e60decb2198..cc6527e35537 100644
--- a/drivers/media/pci/b2c2/flexcop-pci.c
+++ b/drivers/media/pci/b2c2/flexcop-pci.c
@@ -415,7 +415,7 @@ static void flexcop_pci_remove(struct pci_dev *pdev)
415 flexcop_device_kfree(fc_pci->fc_dev); 415 flexcop_device_kfree(fc_pci->fc_dev);
416} 416}
417 417
418static struct pci_device_id flexcop_pci_tbl[] = { 418static const struct pci_device_id flexcop_pci_tbl[] = {
419 { PCI_DEVICE(0x13d0, 0x2103) }, 419 { PCI_DEVICE(0x13d0, 0x2103) },
420 { }, 420 { },
421}; 421};
diff --git a/drivers/media/pci/bt8xx/bt878.c b/drivers/media/pci/bt8xx/bt878.c
index 8aa726651630..a5f52137d306 100644
--- a/drivers/media/pci/bt8xx/bt878.c
+++ b/drivers/media/pci/bt8xx/bt878.c
@@ -383,7 +383,7 @@ EXPORT_SYMBOL(bt878_device_control);
383 .driver_data = (unsigned long) name \ 383 .driver_data = (unsigned long) name \
384 } 384 }
385 385
386static struct pci_device_id bt878_pci_tbl[] = { 386static const struct pci_device_id bt878_pci_tbl[] = {
387 BROOKTREE_878_DEVICE(0x0071, 0x0101, "Nebula Electronics DigiTV"), 387 BROOKTREE_878_DEVICE(0x0071, 0x0101, "Nebula Electronics DigiTV"),
388 BROOKTREE_878_DEVICE(0x1461, 0x0761, "AverMedia AverTV DVB-T 761"), 388 BROOKTREE_878_DEVICE(0x1461, 0x0761, "AverMedia AverTV DVB-T 761"),
389 BROOKTREE_878_DEVICE(0x11bd, 0x001c, "Pinnacle PCTV Sat"), 389 BROOKTREE_878_DEVICE(0x11bd, 0x001c, "Pinnacle PCTV Sat"),
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index ed319f18ba48..227086a2e99c 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -1702,7 +1702,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
1702 bttv_dma_free(q,fh->btv,buf); 1702 bttv_dma_free(q,fh->btv,buf);
1703} 1703}
1704 1704
1705static struct videobuf_queue_ops bttv_video_qops = { 1705static const struct videobuf_queue_ops bttv_video_qops = {
1706 .buf_setup = buffer_setup, 1706 .buf_setup = buffer_setup,
1707 .buf_prepare = buffer_prepare, 1707 .buf_prepare = buffer_prepare,
1708 .buf_queue = buffer_queue, 1708 .buf_queue = buffer_queue,
@@ -4388,7 +4388,7 @@ static int bttv_resume(struct pci_dev *pci_dev)
4388} 4388}
4389#endif 4389#endif
4390 4390
4391static struct pci_device_id bttv_pci_tbl[] = { 4391static const struct pci_device_id bttv_pci_tbl[] = {
4392 {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT848), 0}, 4392 {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT848), 0},
4393 {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT849), 0}, 4393 {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT849), 0},
4394 {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT878), 0}, 4394 {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT878), 0},
diff --git a/drivers/media/pci/bt8xx/bttv-i2c.c b/drivers/media/pci/bt8xx/bttv-i2c.c
index 274fd036b306..eccd1e3d717a 100644
--- a/drivers/media/pci/bt8xx/bttv-i2c.c
+++ b/drivers/media/pci/bt8xx/bttv-i2c.c
@@ -97,7 +97,7 @@ static int bttv_bit_getsda(void *data)
97 return state; 97 return state;
98} 98}
99 99
100static struct i2c_algo_bit_data bttv_i2c_algo_bit_template = { 100static const struct i2c_algo_bit_data bttv_i2c_algo_bit_template = {
101 .setsda = bttv_bit_setsda, 101 .setsda = bttv_bit_setsda,
102 .setscl = bttv_bit_setscl, 102 .setscl = bttv_bit_setscl,
103 .getsda = bttv_bit_getsda, 103 .getsda = bttv_bit_getsda,
diff --git a/drivers/media/pci/bt8xx/bttv-input.c b/drivers/media/pci/bt8xx/bttv-input.c
index 2fd07a8afcd2..73d655d073d6 100644
--- a/drivers/media/pci/bt8xx/bttv-input.c
+++ b/drivers/media/pci/bt8xx/bttv-input.c
@@ -69,12 +69,13 @@ static void ir_handle_key(struct bttv *btv)
69 69
70 if ((ir->mask_keydown && (gpio & ir->mask_keydown)) || 70 if ((ir->mask_keydown && (gpio & ir->mask_keydown)) ||
71 (ir->mask_keyup && !(gpio & ir->mask_keyup))) { 71 (ir->mask_keyup && !(gpio & ir->mask_keyup))) {
72 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); 72 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data, 0);
73 } else { 73 } else {
74 /* HACK: Probably, ir->mask_keydown is missing 74 /* HACK: Probably, ir->mask_keydown is missing
75 for this board */ 75 for this board */
76 if (btv->c.type == BTTV_BOARD_WINFAST2000) 76 if (btv->c.type == BTTV_BOARD_WINFAST2000)
77 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); 77 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data,
78 0);
78 79
79 rc_keyup(ir->dev); 80 rc_keyup(ir->dev);
80 } 81 }
@@ -99,7 +100,7 @@ static void ir_enltv_handle_key(struct bttv *btv)
99 gpio, data, 100 gpio, data,
100 (gpio & ir->mask_keyup) ? " up" : "up/down"); 101 (gpio & ir->mask_keyup) ? " up" : "up/down");
101 102
102 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); 103 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data, 0);
103 if (keyup) 104 if (keyup)
104 rc_keyup(ir->dev); 105 rc_keyup(ir->dev);
105 } else { 106 } else {
@@ -113,7 +114,8 @@ static void ir_enltv_handle_key(struct bttv *btv)
113 if (keyup) 114 if (keyup)
114 rc_keyup(ir->dev); 115 rc_keyup(ir->dev);
115 else 116 else
116 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); 117 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data,
118 0);
117 } 119 }
118 120
119 ir->last_gpio = data | keyup; 121 ir->last_gpio = data | keyup;
@@ -235,7 +237,7 @@ static void bttv_rc5_timer_end(unsigned long data)
235 } 237 }
236 238
237 scancode = RC_SCANCODE_RC5(system, command); 239 scancode = RC_SCANCODE_RC5(system, command);
238 rc_keydown(ir->dev, RC_TYPE_RC5, scancode, toggle); 240 rc_keydown(ir->dev, RC_PROTO_RC5, scancode, toggle);
239 dprintk("scancode %x, toggle %x\n", scancode, toggle); 241 dprintk("scancode %x, toggle %x\n", scancode, toggle);
240} 242}
241 243
@@ -327,7 +329,7 @@ static void bttv_ir_stop(struct bttv *btv)
327 * Get_key functions used by I2C remotes 329 * Get_key functions used by I2C remotes
328 */ 330 */
329 331
330static int get_key_pv951(struct IR_i2c *ir, enum rc_type *protocol, 332static int get_key_pv951(struct IR_i2c *ir, enum rc_proto *protocol,
331 u32 *scancode, u8 *toggle) 333 u32 *scancode, u8 *toggle)
332{ 334{
333 unsigned char b; 335 unsigned char b;
@@ -355,7 +357,7 @@ static int get_key_pv951(struct IR_i2c *ir, enum rc_type *protocol,
355 * the device is bound to the vendor-provided RC. 357 * the device is bound to the vendor-provided RC.
356 */ 358 */
357 359
358 *protocol = RC_TYPE_UNKNOWN; 360 *protocol = RC_PROTO_UNKNOWN;
359 *scancode = b; 361 *scancode = b;
360 *toggle = 0; 362 *toggle = 0;
361 return 1; 363 return 1;
@@ -535,7 +537,7 @@ int bttv_input_init(struct bttv *btv)
535 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", 537 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
536 pci_name(btv->c.pci)); 538 pci_name(btv->c.pci));
537 539
538 rc->input_name = ir->name; 540 rc->device_name = ir->name;
539 rc->input_phys = ir->phys; 541 rc->input_phys = ir->phys;
540 rc->input_id.bustype = BUS_PCI; 542 rc->input_id.bustype = BUS_PCI;
541 rc->input_id.version = 1; 543 rc->input_id.version = 1;
diff --git a/drivers/media/pci/bt8xx/dst_ca.c b/drivers/media/pci/bt8xx/dst_ca.c
index 90f4263452d3..530b3e9764ce 100644
--- a/drivers/media/pci/bt8xx/dst_ca.c
+++ b/drivers/media/pci/bt8xx/dst_ca.c
@@ -57,20 +57,6 @@ static unsigned int verbose = 5;
57module_param(verbose, int, 0644); 57module_param(verbose, int, 0644);
58MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); 58MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
59 59
60/* Need some more work */
61static int ca_set_slot_descr(void)
62{
63 /* We could make this more graceful ? */
64 return -EOPNOTSUPP;
65}
66
67/* Need some more work */
68static int ca_set_pid(void)
69{
70 /* We could make this more graceful ? */
71 return -EOPNOTSUPP;
72}
73
74static void put_command_and_length(u8 *data, int command, int length) 60static void put_command_and_length(u8 *data, int command, int length)
75{ 61{
76 data[0] = (command >> 16) & 0xff; 62 data[0] = (command >> 16) & 0xff;
@@ -144,7 +130,7 @@ static int dst_put_ci(struct dst_state *state, u8 *data, int len, u8 *ca_string,
144 } 130 }
145 131
146 if(dst_ca_comm_err == RETRIES) 132 if(dst_ca_comm_err == RETRIES)
147 return -1; 133 return -EIO;
148 134
149 return 0; 135 return 0;
150} 136}
@@ -159,7 +145,7 @@ static int ca_get_app_info(struct dst_state *state)
159 put_checksum(&command[0], command[0]); 145 put_checksum(&command[0], command[0]);
160 if ((dst_put_ci(state, command, sizeof(command), state->messages, GET_REPLY)) < 0) { 146 if ((dst_put_ci(state, command, sizeof(command), state->messages, GET_REPLY)) < 0) {
161 dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); 147 dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
162 return -1; 148 return -EIO;
163 } 149 }
164 dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !"); 150 dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !");
165 dprintk(verbose, DST_CA_INFO, 1, " ================================ CI Module Application Info ======================================"); 151 dprintk(verbose, DST_CA_INFO, 1, " ================================ CI Module Application Info ======================================");
@@ -198,7 +184,7 @@ static int ca_get_ca_info(struct dst_state *state)
198 put_checksum(&slot_command[0], slot_command[0]); 184 put_checksum(&slot_command[0], slot_command[0]);
199 if ((dst_put_ci(state, slot_command, sizeof (slot_command), state->messages, GET_REPLY)) < 0) { 185 if ((dst_put_ci(state, slot_command, sizeof (slot_command), state->messages, GET_REPLY)) < 0) {
200 dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); 186 dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
201 return -1; 187 return -EIO;
202 } 188 }
203 dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !"); 189 dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !");
204 190
@@ -242,7 +228,7 @@ static int ca_get_slot_caps(struct dst_state *state, struct ca_caps *p_ca_caps,
242 put_checksum(&slot_command[0], slot_command[0]); 228 put_checksum(&slot_command[0], slot_command[0]);
243 if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_cap, GET_REPLY)) < 0) { 229 if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_cap, GET_REPLY)) < 0) {
244 dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); 230 dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
245 return -1; 231 return -EIO;
246 } 232 }
247 dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !"); 233 dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !");
248 234
@@ -282,7 +268,7 @@ static int ca_get_slot_info(struct dst_state *state, struct ca_slot_info *p_ca_s
282 put_checksum(&slot_command[0], 7); 268 put_checksum(&slot_command[0], 7);
283 if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_info, GET_REPLY)) < 0) { 269 if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_info, GET_REPLY)) < 0) {
284 dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !"); 270 dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
285 return -1; 271 return -EIO;
286 } 272 }
287 dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !"); 273 dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !");
288 274
@@ -354,7 +340,7 @@ static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message,
354 } else { 340 } else {
355 if (length > 247) { 341 if (length > 247) {
356 dprintk(verbose, DST_CA_ERROR, 1, " Message too long ! *** Bailing Out *** !"); 342 dprintk(verbose, DST_CA_ERROR, 1, " Message too long ! *** Bailing Out *** !");
357 return -1; 343 return -EIO;
358 } 344 }
359 hw_buffer->msg[0] = (length & 0xff) + 7; 345 hw_buffer->msg[0] = (length & 0xff) + 7;
360 hw_buffer->msg[1] = 0x40; 346 hw_buffer->msg[1] = 0x40;
@@ -380,7 +366,7 @@ static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 l
380 dprintk(verbose, DST_CA_ERROR, 1, " DST-CI Command failed."); 366 dprintk(verbose, DST_CA_ERROR, 1, " DST-CI Command failed.");
381 dprintk(verbose, DST_CA_NOTICE, 1, " Resetting DST."); 367 dprintk(verbose, DST_CA_NOTICE, 1, " Resetting DST.");
382 rdc_reset_state(state); 368 rdc_reset_state(state);
383 return -1; 369 return -EIO;
384 } 370 }
385 dprintk(verbose, DST_CA_NOTICE, 1, " DST-CI Command success."); 371 dprintk(verbose, DST_CA_NOTICE, 1, " DST-CI Command success.");
386 372
@@ -453,7 +439,7 @@ static int dst_check_ca_pmt(struct dst_state *state, struct ca_msg *p_ca_message
453 if (ca_pmt_reply_test) { 439 if (ca_pmt_reply_test) {
454 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 1, GET_REPLY)) < 0) { 440 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 1, GET_REPLY)) < 0) {
455 dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !"); 441 dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !");
456 return -1; 442 return -EIO;
457 } 443 }
458 444
459 /* Process CA PMT Reply */ 445 /* Process CA PMT Reply */
@@ -464,7 +450,7 @@ static int dst_check_ca_pmt(struct dst_state *state, struct ca_msg *p_ca_message
464 if (!ca_pmt_reply_test) { 450 if (!ca_pmt_reply_test) {
465 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, NO_REPLY)) < 0) { 451 if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, NO_REPLY)) < 0) {
466 dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !"); 452 dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !");
467 return -1; 453 return -EIO;
468 } 454 }
469 dprintk(verbose, DST_CA_NOTICE, 1, " ca_set_pmt.. success !"); 455 dprintk(verbose, DST_CA_NOTICE, 1, " ca_set_pmt.. success !");
470 /* put a dummy message */ 456 /* put a dummy message */
@@ -573,17 +559,18 @@ static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned long ioct
573 switch (cmd) { 559 switch (cmd) {
574 case CA_SEND_MSG: 560 case CA_SEND_MSG:
575 dprintk(verbose, DST_CA_INFO, 1, " Sending message"); 561 dprintk(verbose, DST_CA_INFO, 1, " Sending message");
576 if ((ca_send_message(state, p_ca_message, arg)) < 0) { 562 result = ca_send_message(state, p_ca_message, arg);
563
564 if (result < 0) {
577 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SEND_MSG Failed !"); 565 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SEND_MSG Failed !");
578 result = -1;
579 goto free_mem_and_exit; 566 goto free_mem_and_exit;
580 } 567 }
581 break; 568 break;
582 case CA_GET_MSG: 569 case CA_GET_MSG:
583 dprintk(verbose, DST_CA_INFO, 1, " Getting message"); 570 dprintk(verbose, DST_CA_INFO, 1, " Getting message");
584 if ((ca_get_message(state, p_ca_message, arg)) < 0) { 571 result = ca_get_message(state, p_ca_message, arg);
572 if (result < 0) {
585 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_MSG Failed !"); 573 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_MSG Failed !");
586 result = -1;
587 goto free_mem_and_exit; 574 goto free_mem_and_exit;
588 } 575 }
589 dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_MSG Success !"); 576 dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_MSG Success !");
@@ -595,7 +582,8 @@ static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned long ioct
595 break; 582 break;
596 case CA_GET_SLOT_INFO: 583 case CA_GET_SLOT_INFO:
597 dprintk(verbose, DST_CA_INFO, 1, " Getting Slot info"); 584 dprintk(verbose, DST_CA_INFO, 1, " Getting Slot info");
598 if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) { 585 result = ca_get_slot_info(state, p_ca_slot_info, arg);
586 if (result < 0) {
599 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_SLOT_INFO Failed !"); 587 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_SLOT_INFO Failed !");
600 result = -1; 588 result = -1;
601 goto free_mem_and_exit; 589 goto free_mem_and_exit;
@@ -604,40 +592,22 @@ static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned long ioct
604 break; 592 break;
605 case CA_GET_CAP: 593 case CA_GET_CAP:
606 dprintk(verbose, DST_CA_INFO, 1, " Getting Slot capabilities"); 594 dprintk(verbose, DST_CA_INFO, 1, " Getting Slot capabilities");
607 if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) { 595 result = ca_get_slot_caps(state, p_ca_caps, arg);
596 if (result < 0) {
608 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_CAP Failed !"); 597 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_CAP Failed !");
609 result = -1;
610 goto free_mem_and_exit; 598 goto free_mem_and_exit;
611 } 599 }
612 dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_CAP Success !"); 600 dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_CAP Success !");
613 break; 601 break;
614 case CA_GET_DESCR_INFO: 602 case CA_GET_DESCR_INFO:
615 dprintk(verbose, DST_CA_INFO, 1, " Getting descrambler description"); 603 dprintk(verbose, DST_CA_INFO, 1, " Getting descrambler description");
616 if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) { 604 result = ca_get_slot_descr(state, p_ca_message, arg);
605 if (result < 0) {
617 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_DESCR_INFO Failed !"); 606 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_DESCR_INFO Failed !");
618 result = -1;
619 goto free_mem_and_exit; 607 goto free_mem_and_exit;
620 } 608 }
621 dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_DESCR_INFO Success !"); 609 dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_DESCR_INFO Success !");
622 break; 610 break;
623 case CA_SET_DESCR:
624 dprintk(verbose, DST_CA_INFO, 1, " Setting descrambler");
625 if ((ca_set_slot_descr()) < 0) {
626 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_DESCR Failed !");
627 result = -1;
628 goto free_mem_and_exit;
629 }
630 dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_DESCR Success !");
631 break;
632 case CA_SET_PID:
633 dprintk(verbose, DST_CA_INFO, 1, " Setting PID");
634 if ((ca_set_pid()) < 0) {
635 dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_PID Failed !");
636 result = -1;
637 goto free_mem_and_exit;
638 }
639 dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_PID Success !");
640 break;
641 default: 611 default:
642 result = -EOPNOTSUPP; 612 result = -EOPNOTSUPP;
643 } 613 }
diff --git a/drivers/media/pci/cobalt/cobalt-alsa-pcm.c b/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
index 49013c6b8646..b69b258d39b9 100644
--- a/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
+++ b/drivers/media/pci/cobalt/cobalt-alsa-pcm.c
@@ -43,7 +43,7 @@ MODULE_PARM_DESC(pcm_debug, "enable debug messages for pcm");
43 pr_info("cobalt-alsa-pcm %s: " fmt, __func__, ##arg); \ 43 pr_info("cobalt-alsa-pcm %s: " fmt, __func__, ##arg); \
44 } while (0) 44 } while (0)
45 45
46static struct snd_pcm_hardware snd_cobalt_hdmi_capture = { 46static const struct snd_pcm_hardware snd_cobalt_hdmi_capture = {
47 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER | 47 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER |
48 SNDRV_PCM_INFO_MMAP | 48 SNDRV_PCM_INFO_MMAP |
49 SNDRV_PCM_INFO_INTERLEAVED | 49 SNDRV_PCM_INFO_INTERLEAVED |
@@ -64,7 +64,7 @@ static struct snd_pcm_hardware snd_cobalt_hdmi_capture = {
64 .periods_max = 4, 64 .periods_max = 4,
65}; 65};
66 66
67static struct snd_pcm_hardware snd_cobalt_playback = { 67static const struct snd_pcm_hardware snd_cobalt_playback = {
68 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER | 68 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER |
69 SNDRV_PCM_INFO_MMAP | 69 SNDRV_PCM_INFO_MMAP |
70 SNDRV_PCM_INFO_INTERLEAVED | 70 SNDRV_PCM_INFO_INTERLEAVED |
diff --git a/drivers/media/pci/cobalt/cobalt-driver.c b/drivers/media/pci/cobalt/cobalt-driver.c
index f8e173f3e9e2..98b6cb9505d1 100644
--- a/drivers/media/pci/cobalt/cobalt-driver.c
+++ b/drivers/media/pci/cobalt/cobalt-driver.c
@@ -36,7 +36,7 @@
36#include "cobalt-omnitek.h" 36#include "cobalt-omnitek.h"
37 37
38/* add your revision and whatnot here */ 38/* add your revision and whatnot here */
39static struct pci_device_id cobalt_pci_tbl[] = { 39static const struct pci_device_id cobalt_pci_tbl[] = {
40 {PCI_VENDOR_ID_CISCO, PCI_DEVICE_ID_COBALT, 40 {PCI_VENDOR_ID_CISCO, PCI_DEVICE_ID_COBALT,
41 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 41 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
42 {0,} 42 {0,}
diff --git a/drivers/media/pci/cobalt/cobalt-i2c.c b/drivers/media/pci/cobalt/cobalt-i2c.c
index ad16b89b8d0c..1a5c55673ea8 100644
--- a/drivers/media/pci/cobalt/cobalt-i2c.c
+++ b/drivers/media/pci/cobalt/cobalt-i2c.c
@@ -301,7 +301,7 @@ static u32 cobalt_func(struct i2c_adapter *adap)
301} 301}
302 302
303/* template for i2c-bit-algo */ 303/* template for i2c-bit-algo */
304static struct i2c_adapter cobalt_i2c_adap_template = { 304static const struct i2c_adapter cobalt_i2c_adap_template = {
305 .name = "cobalt i2c driver", 305 .name = "cobalt i2c driver",
306 .algo = NULL, /* set by i2c-algo-bit */ 306 .algo = NULL, /* set by i2c-algo-bit */
307 .algo_data = NULL, /* filled from template */ 307 .algo_data = NULL, /* filled from template */
diff --git a/drivers/media/pci/cx18/cx18-alsa-mixer.c b/drivers/media/pci/cx18/cx18-alsa-mixer.c
index 06b066bc9301..cb04c3d820e2 100644
--- a/drivers/media/pci/cx18/cx18-alsa-mixer.c
+++ b/drivers/media/pci/cx18/cx18-alsa-mixer.c
@@ -161,7 +161,7 @@ int __init snd_cx18_mixer_create(struct snd_cx18_card *cxsc)
161 161
162 strlcpy(sc->mixername, "CX23418 Mixer", sizeof(sc->mixername)); 162 strlcpy(sc->mixername, "CX23418 Mixer", sizeof(sc->mixername));
163 163
164 ret = snd_ctl_add(sc, snd_ctl_new1(snd_cx18_mixer_tv_vol, cxsc)); 164 ret = snd_ctl_add(sc, snd_ctl_new1(&snd_cx18_mixer_tv_vol, cxsc));
165 if (ret) { 165 if (ret) {
166 CX18_ALSA_WARN("%s: failed to add %s control, err %d\n", 166 CX18_ALSA_WARN("%s: failed to add %s control, err %d\n",
167 __func__, snd_cx18_mixer_tv_vol.name, ret); 167 __func__, snd_cx18_mixer_tv_vol.name, ret);
diff --git a/drivers/media/pci/cx18/cx18-alsa-pcm.c b/drivers/media/pci/cx18/cx18-alsa-pcm.c
index f68ee57a9ae2..aadd76466aec 100644
--- a/drivers/media/pci/cx18/cx18-alsa-pcm.c
+++ b/drivers/media/pci/cx18/cx18-alsa-pcm.c
@@ -44,7 +44,7 @@ MODULE_PARM_DESC(pcm_debug, "enable debug messages for pcm");
44 __func__, ##arg); \ 44 __func__, ##arg); \
45 } while (0) 45 } while (0)
46 46
47static struct snd_pcm_hardware snd_cx18_hw_capture = { 47static const struct snd_pcm_hardware snd_cx18_hw_capture = {
48 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER | 48 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER |
49 SNDRV_PCM_INFO_MMAP | 49 SNDRV_PCM_INFO_MMAP |
50 SNDRV_PCM_INFO_INTERLEAVED | 50 SNDRV_PCM_INFO_INTERLEAVED |
diff --git a/drivers/media/pci/cx18/cx18-driver.c b/drivers/media/pci/cx18/cx18-driver.c
index 8bce49cdad46..8654710464cc 100644
--- a/drivers/media/pci/cx18/cx18-driver.c
+++ b/drivers/media/pci/cx18/cx18-driver.c
@@ -48,7 +48,7 @@ int (*cx18_ext_init)(struct cx18 *);
48EXPORT_SYMBOL(cx18_ext_init); 48EXPORT_SYMBOL(cx18_ext_init);
49 49
50/* add your revision and whatnot here */ 50/* add your revision and whatnot here */
51static struct pci_device_id cx18_pci_tbl[] = { 51static const struct pci_device_id cx18_pci_tbl[] = {
52 {PCI_VENDOR_ID_CX, PCI_DEVICE_ID_CX23418, 52 {PCI_VENDOR_ID_CX, PCI_DEVICE_ID_CX23418,
53 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 53 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
54 {0,} 54 {0,}
diff --git a/drivers/media/pci/cx18/cx18-i2c.c b/drivers/media/pci/cx18/cx18-i2c.c
index eabdd4c5520a..7f588eeac60f 100644
--- a/drivers/media/pci/cx18/cx18-i2c.c
+++ b/drivers/media/pci/cx18/cx18-i2c.c
@@ -93,8 +93,8 @@ static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw,
93 case CX18_HW_Z8F0811_IR_RX_HAUP: 93 case CX18_HW_Z8F0811_IR_RX_HAUP:
94 init_data->ir_codes = RC_MAP_HAUPPAUGE; 94 init_data->ir_codes = RC_MAP_HAUPPAUGE;
95 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 95 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
96 init_data->type = RC_BIT_RC5 | RC_BIT_RC6_MCE | 96 init_data->type = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC6_MCE |
97 RC_BIT_RC6_6A_32; 97 RC_PROTO_BIT_RC6_6A_32;
98 init_data->name = cx->card_name; 98 init_data->name = cx->card_name;
99 info.platform_data = init_data; 99 info.platform_data = init_data;
100 break; 100 break;
@@ -206,7 +206,7 @@ static int cx18_getsda(void *data)
206} 206}
207 207
208/* template for i2c-bit-algo */ 208/* template for i2c-bit-algo */
209static struct i2c_adapter cx18_i2c_adap_template = { 209static const struct i2c_adapter cx18_i2c_adap_template = {
210 .name = "cx18 i2c driver", 210 .name = "cx18 i2c driver",
211 .algo = NULL, /* set by i2c-algo-bit */ 211 .algo = NULL, /* set by i2c-algo-bit */
212 .algo_data = NULL, /* filled from template */ 212 .algo_data = NULL, /* filled from template */
@@ -216,7 +216,7 @@ static struct i2c_adapter cx18_i2c_adap_template = {
216#define CX18_SCL_PERIOD (10) /* usecs. 10 usec is period for a 100 KHz clock */ 216#define CX18_SCL_PERIOD (10) /* usecs. 10 usec is period for a 100 KHz clock */
217#define CX18_ALGO_BIT_TIMEOUT (2) /* seconds */ 217#define CX18_ALGO_BIT_TIMEOUT (2) /* seconds */
218 218
219static struct i2c_algo_bit_data cx18_i2c_algo_template = { 219static const struct i2c_algo_bit_data cx18_i2c_algo_template = {
220 .setsda = cx18_setsda, 220 .setsda = cx18_setsda,
221 .setscl = cx18_setscl, 221 .setscl = cx18_setscl,
222 .getsda = cx18_getsda, 222 .getsda = cx18_getsda,
diff --git a/drivers/media/pci/cx18/cx18-streams.c b/drivers/media/pci/cx18/cx18-streams.c
index 3c45e0071530..8385411af641 100644
--- a/drivers/media/pci/cx18/cx18-streams.c
+++ b/drivers/media/pci/cx18/cx18-streams.c
@@ -31,7 +31,7 @@
31 31
32#define CX18_DSP0_INTERRUPT_MASK 0xd0004C 32#define CX18_DSP0_INTERRUPT_MASK 0xd0004C
33 33
34static struct v4l2_file_operations cx18_v4l2_enc_fops = { 34static const struct v4l2_file_operations cx18_v4l2_enc_fops = {
35 .owner = THIS_MODULE, 35 .owner = THIS_MODULE,
36 .read = cx18_v4l2_read, 36 .read = cx18_v4l2_read,
37 .open = cx18_v4l2_open, 37 .open = cx18_v4l2_open,
@@ -240,7 +240,7 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
240 list_add_tail(&buf->vb.queue, &s->vb_capture); 240 list_add_tail(&buf->vb.queue, &s->vb_capture);
241} 241}
242 242
243static struct videobuf_queue_ops cx18_videobuf_qops = { 243static const struct videobuf_queue_ops cx18_videobuf_qops = {
244 .buf_setup = buffer_setup, 244 .buf_setup = buffer_setup,
245 .buf_prepare = buffer_prepare, 245 .buf_prepare = buffer_prepare,
246 .buf_queue = buffer_queue, 246 .buf_queue = buffer_queue,
diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c
index 2ff1d1e274be..a71f3c7569ce 100644
--- a/drivers/media/pci/cx23885/cx23885-417.c
+++ b/drivers/media/pci/cx23885/cx23885-417.c
@@ -1416,7 +1416,7 @@ static int vidioc_log_status(struct file *file, void *priv)
1416 return 0; 1416 return 0;
1417} 1417}
1418 1418
1419static struct v4l2_file_operations mpeg_fops = { 1419static const struct v4l2_file_operations mpeg_fops = {
1420 .owner = THIS_MODULE, 1420 .owner = THIS_MODULE,
1421 .open = v4l2_fh_open, 1421 .open = v4l2_fh_open,
1422 .release = vb2_fop_release, 1422 .release = vb2_fop_release,
diff --git a/drivers/media/pci/cx23885/cx23885-alsa.c b/drivers/media/pci/cx23885/cx23885-alsa.c
index c148f9a4a9ac..d8c3637e492e 100644
--- a/drivers/media/pci/cx23885/cx23885-alsa.c
+++ b/drivers/media/pci/cx23885/cx23885-alsa.c
@@ -293,7 +293,7 @@ static int dsp_buffer_free(struct cx23885_audio_dev *chip)
293 */ 293 */
294#define DEFAULT_FIFO_SIZE 4096 294#define DEFAULT_FIFO_SIZE 4096
295 295
296static struct snd_pcm_hardware snd_cx23885_digital_hw = { 296static const struct snd_pcm_hardware snd_cx23885_digital_hw = {
297 .info = SNDRV_PCM_INFO_MMAP | 297 .info = SNDRV_PCM_INFO_MMAP |
298 SNDRV_PCM_INFO_INTERLEAVED | 298 SNDRV_PCM_INFO_INTERLEAVED |
299 SNDRV_PCM_INFO_BLOCK_TRANSFER | 299 SNDRV_PCM_INFO_BLOCK_TRANSFER |
diff --git a/drivers/media/pci/cx23885/cx23885-cards.c b/drivers/media/pci/cx23885/cx23885-cards.c
index c48fa8e25a70..78a8836d03e4 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -1278,6 +1278,12 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
1278 case 85721: 1278 case 85721:
1279 /* WinTV-HVR1290 (PCIe, OEM, RCA in, IR, 1279 /* WinTV-HVR1290 (PCIe, OEM, RCA in, IR,
1280 Dual channel ATSC and Basic analog */ 1280 Dual channel ATSC and Basic analog */
1281 case 121019:
1282 /* WinTV-HVR4400 (PCIe, DVB-S2, DVB-C/T) */
1283 break;
1284 case 121029:
1285 /* WinTV-HVR5500 (PCIe, DVB-S2, DVB-C/T) */
1286 break;
1281 case 150329: 1287 case 150329:
1282 /* WinTV-HVR5525 (PCIe, DVB-S/S2, DVB-T/T2/C) */ 1288 /* WinTV-HVR5525 (PCIe, DVB-S/S2, DVB-T/T2/C) */
1283 break; 1289 break;
diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c
index 02b5ec549369..8f63df1cb418 100644
--- a/drivers/media/pci/cx23885/cx23885-core.c
+++ b/drivers/media/pci/cx23885/cx23885-core.c
@@ -2056,7 +2056,7 @@ static void cx23885_finidev(struct pci_dev *pci_dev)
2056 kfree(dev); 2056 kfree(dev);
2057} 2057}
2058 2058
2059static struct pci_device_id cx23885_pci_tbl[] = { 2059static const struct pci_device_id cx23885_pci_tbl[] = {
2060 { 2060 {
2061 /* CX23885 */ 2061 /* CX23885 */
2062 .vendor = 0x14f1, 2062 .vendor = 0x14f1,
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index 979b66627f60..e795ddeb7fe2 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -2637,6 +2637,11 @@ int cx23885_dvb_unregister(struct cx23885_tsport *port)
2637 struct vb2_dvb_frontend *fe0; 2637 struct vb2_dvb_frontend *fe0;
2638 struct i2c_client *client; 2638 struct i2c_client *client;
2639 2639
2640 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
2641
2642 if (fe0 && fe0->dvb.frontend)
2643 vb2_dvb_unregister_bus(&port->frontends);
2644
2640 /* remove I2C client for CI */ 2645 /* remove I2C client for CI */
2641 client = port->i2c_client_ci; 2646 client = port->i2c_client_ci;
2642 if (client) { 2647 if (client) {
@@ -2665,11 +2670,6 @@ int cx23885_dvb_unregister(struct cx23885_tsport *port)
2665 i2c_unregister_device(client); 2670 i2c_unregister_device(client);
2666 } 2671 }
2667 2672
2668 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
2669
2670 if (fe0 && fe0->dvb.frontend)
2671 vb2_dvb_unregister_bus(&port->frontends);
2672
2673 switch (port->dev->board) { 2673 switch (port->dev->board) {
2674 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: 2674 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
2675 netup_ci_exit(port); 2675 netup_ci_exit(port);
diff --git a/drivers/media/pci/cx23885/cx23885-i2c.c b/drivers/media/pci/cx23885/cx23885-i2c.c
index 8528032090f2..0f21467ae88e 100644
--- a/drivers/media/pci/cx23885/cx23885-i2c.c
+++ b/drivers/media/pci/cx23885/cx23885-i2c.c
@@ -264,7 +264,7 @@ static const struct i2c_algorithm cx23885_i2c_algo_template = {
264 264
265/* ----------------------------------------------------------------------- */ 265/* ----------------------------------------------------------------------- */
266 266
267static struct i2c_adapter cx23885_i2c_adap_template = { 267static const struct i2c_adapter cx23885_i2c_adap_template = {
268 .name = "cx23885", 268 .name = "cx23885",
269 .owner = THIS_MODULE, 269 .owner = THIS_MODULE,
270 .algo = &cx23885_i2c_algo_template, 270 .algo = &cx23885_i2c_algo_template,
diff --git a/drivers/media/pci/cx23885/cx23885-input.c b/drivers/media/pci/cx23885/cx23885-input.c
index 4367cb3162b6..944b70831f12 100644
--- a/drivers/media/pci/cx23885/cx23885-input.c
+++ b/drivers/media/pci/cx23885/cx23885-input.c
@@ -284,32 +284,32 @@ int cx23885_input_init(struct cx23885_dev *dev)
284 case CX23885_BOARD_HAUPPAUGE_HVR1290: 284 case CX23885_BOARD_HAUPPAUGE_HVR1290:
285 case CX23885_BOARD_HAUPPAUGE_HVR1250: 285 case CX23885_BOARD_HAUPPAUGE_HVR1250:
286 /* Integrated CX2388[58] IR controller */ 286 /* Integrated CX2388[58] IR controller */
287 allowed_protos = RC_BIT_ALL_IR_DECODER; 287 allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
288 /* The grey Hauppauge RC-5 remote */ 288 /* The grey Hauppauge RC-5 remote */
289 rc_map = RC_MAP_HAUPPAUGE; 289 rc_map = RC_MAP_HAUPPAUGE;
290 break; 290 break;
291 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL: 291 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
292 /* Integrated CX23885 IR controller */ 292 /* Integrated CX23885 IR controller */
293 allowed_protos = RC_BIT_ALL_IR_DECODER; 293 allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
294 /* The grey Terratec remote with orange buttons */ 294 /* The grey Terratec remote with orange buttons */
295 rc_map = RC_MAP_NEC_TERRATEC_CINERGY_XS; 295 rc_map = RC_MAP_NEC_TERRATEC_CINERGY_XS;
296 break; 296 break;
297 case CX23885_BOARD_TEVII_S470: 297 case CX23885_BOARD_TEVII_S470:
298 /* Integrated CX23885 IR controller */ 298 /* Integrated CX23885 IR controller */
299 allowed_protos = RC_BIT_ALL_IR_DECODER; 299 allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
300 /* A guess at the remote */ 300 /* A guess at the remote */
301 rc_map = RC_MAP_TEVII_NEC; 301 rc_map = RC_MAP_TEVII_NEC;
302 break; 302 break;
303 case CX23885_BOARD_MYGICA_X8507: 303 case CX23885_BOARD_MYGICA_X8507:
304 /* Integrated CX23885 IR controller */ 304 /* Integrated CX23885 IR controller */
305 allowed_protos = RC_BIT_ALL_IR_DECODER; 305 allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
306 /* A guess at the remote */ 306 /* A guess at the remote */
307 rc_map = RC_MAP_TOTAL_MEDIA_IN_HAND_02; 307 rc_map = RC_MAP_TOTAL_MEDIA_IN_HAND_02;
308 break; 308 break;
309 case CX23885_BOARD_TBS_6980: 309 case CX23885_BOARD_TBS_6980:
310 case CX23885_BOARD_TBS_6981: 310 case CX23885_BOARD_TBS_6981:
311 /* Integrated CX23885 IR controller */ 311 /* Integrated CX23885 IR controller */
312 allowed_protos = RC_BIT_ALL_IR_DECODER; 312 allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
313 /* A guess at the remote */ 313 /* A guess at the remote */
314 rc_map = RC_MAP_TBS_NEC; 314 rc_map = RC_MAP_TBS_NEC;
315 break; 315 break;
@@ -320,12 +320,12 @@ int cx23885_input_init(struct cx23885_dev *dev)
320 case CX23885_BOARD_DVBSKY_S952: 320 case CX23885_BOARD_DVBSKY_S952:
321 case CX23885_BOARD_DVBSKY_T982: 321 case CX23885_BOARD_DVBSKY_T982:
322 /* Integrated CX23885 IR controller */ 322 /* Integrated CX23885 IR controller */
323 allowed_protos = RC_BIT_ALL_IR_DECODER; 323 allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
324 rc_map = RC_MAP_DVBSKY; 324 rc_map = RC_MAP_DVBSKY;
325 break; 325 break;
326 case CX23885_BOARD_TT_CT2_4500_CI: 326 case CX23885_BOARD_TT_CT2_4500_CI:
327 /* Integrated CX23885 IR controller */ 327 /* Integrated CX23885 IR controller */
328 allowed_protos = RC_BIT_ALL_IR_DECODER; 328 allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
329 rc_map = RC_MAP_TT_1500; 329 rc_map = RC_MAP_TT_1500;
330 break; 330 break;
331 default: 331 default:
@@ -351,7 +351,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
351 } 351 }
352 352
353 kernel_ir->rc = rc; 353 kernel_ir->rc = rc;
354 rc->input_name = kernel_ir->name; 354 rc->device_name = kernel_ir->name;
355 rc->input_phys = kernel_ir->phys; 355 rc->input_phys = kernel_ir->phys;
356 rc->input_id.bustype = BUS_PCI; 356 rc->input_id.bustype = BUS_PCI;
357 rc->input_id.version = 1; 357 rc->input_id.version = 1;
diff --git a/drivers/media/pci/cx25821/cx25821-alsa.c b/drivers/media/pci/cx25821/cx25821-alsa.c
index 519b81c0c837..2b34990e86f2 100644
--- a/drivers/media/pci/cx25821/cx25821-alsa.c
+++ b/drivers/media/pci/cx25821/cx25821-alsa.c
@@ -428,7 +428,7 @@ static int dsp_buffer_free(struct cx25821_audio_dev *chip)
428 * Digital hardware definition 428 * Digital hardware definition
429 */ 429 */
430#define DEFAULT_FIFO_SIZE 384 430#define DEFAULT_FIFO_SIZE 384
431static struct snd_pcm_hardware snd_cx25821_digital_hw = { 431static const struct snd_pcm_hardware snd_cx25821_digital_hw = {
432 .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 432 .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
433 SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID, 433 SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID,
434 .formats = SNDRV_PCM_FMTBIT_S16_LE, 434 .formats = SNDRV_PCM_FMTBIT_S16_LE,
diff --git a/drivers/media/pci/cx25821/cx25821-core.c b/drivers/media/pci/cx25821/cx25821-core.c
index fbc0229183bd..04aa4a68a0ae 100644
--- a/drivers/media/pci/cx25821/cx25821-core.c
+++ b/drivers/media/pci/cx25821/cx25821-core.c
@@ -1390,10 +1390,7 @@ static struct pci_driver cx25821_pci_driver = {
1390 1390
1391static int __init cx25821_init(void) 1391static int __init cx25821_init(void)
1392{ 1392{
1393 pr_info("driver version %d.%d.%d loaded\n", 1393 pr_info("driver loaded\n");
1394 (CX25821_VERSION_CODE >> 16) & 0xff,
1395 (CX25821_VERSION_CODE >> 8) & 0xff,
1396 CX25821_VERSION_CODE & 0xff);
1397 return pci_register_driver(&cx25821_pci_driver); 1394 return pci_register_driver(&cx25821_pci_driver);
1398} 1395}
1399 1396
diff --git a/drivers/media/pci/cx25821/cx25821-i2c.c b/drivers/media/pci/cx25821/cx25821-i2c.c
index 263a1cf36ef1..000049d3c71b 100644
--- a/drivers/media/pci/cx25821/cx25821-i2c.c
+++ b/drivers/media/pci/cx25821/cx25821-i2c.c
@@ -285,7 +285,7 @@ static const struct i2c_algorithm cx25821_i2c_algo_template = {
285#endif 285#endif
286}; 286};
287 287
288static struct i2c_adapter cx25821_i2c_adap_template = { 288static const struct i2c_adapter cx25821_i2c_adap_template = {
289 .name = "cx25821", 289 .name = "cx25821",
290 .owner = THIS_MODULE, 290 .owner = THIS_MODULE,
291 .algo = &cx25821_i2c_algo_template, 291 .algo = &cx25821_i2c_algo_template,
diff --git a/drivers/media/pci/cx25821/cx25821.h b/drivers/media/pci/cx25821/cx25821.h
index 0f20e89b0cde..b3eb2dabb30b 100644
--- a/drivers/media/pci/cx25821/cx25821.h
+++ b/drivers/media/pci/cx25821/cx25821.h
@@ -41,8 +41,6 @@
41#include <linux/version.h> 41#include <linux/version.h>
42#include <linux/mutex.h> 42#include <linux/mutex.h>
43 43
44#define CX25821_VERSION_CODE KERNEL_VERSION(0, 0, 106)
45
46#define UNSET (-1U) 44#define UNSET (-1U)
47#define NO_SYNC_LINE (-1U) 45#define NO_SYNC_LINE (-1U)
48 46
diff --git a/drivers/media/pci/cx88/cx88-alsa.c b/drivers/media/pci/cx88/cx88-alsa.c
index c81fe4681d14..9740326bc93f 100644
--- a/drivers/media/pci/cx88/cx88-alsa.c
+++ b/drivers/media/pci/cx88/cx88-alsa.c
@@ -799,7 +799,7 @@ static int snd_cx88_alc_put(struct snd_kcontrol *kcontrol,
799 return 0; 799 return 0;
800} 800}
801 801
802static struct snd_kcontrol_new snd_cx88_alc_switch = { 802static const struct snd_kcontrol_new snd_cx88_alc_switch = {
803 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 803 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
804 .name = "Line-In ALC Switch", 804 .name = "Line-In ALC Switch",
805 .info = snd_ctl_boolean_mono_info, 805 .info = snd_ctl_boolean_mono_info,
diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c
index aa49c9597d9c..e3101f04941c 100644
--- a/drivers/media/pci/cx88/cx88-blackbird.c
+++ b/drivers/media/pci/cx88/cx88-blackbird.c
@@ -1075,7 +1075,7 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
1075 .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 1075 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1076}; 1076};
1077 1077
1078static struct video_device cx8802_mpeg_template = { 1078static const struct video_device cx8802_mpeg_template = {
1079 .name = "cx8802", 1079 .name = "cx8802",
1080 .fops = &mpeg_fops, 1080 .fops = &mpeg_fops,
1081 .ioctl_ops = &mpeg_ioctl_ops, 1081 .ioctl_ops = &mpeg_ioctl_ops,
diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c
index 01f2e472a2a0..e02449bf2041 100644
--- a/drivers/media/pci/cx88/cx88-input.c
+++ b/drivers/media/pci/cx88/cx88-input.c
@@ -132,7 +132,7 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
132 132
133 data = (data << 4) | ((gpio_key & 0xf0) >> 4); 133 data = (data << 4) | ((gpio_key & 0xf0) >> 4);
134 134
135 rc_keydown(ir->dev, RC_TYPE_UNKNOWN, data, 0); 135 rc_keydown(ir->dev, RC_PROTO_UNKNOWN, data, 0);
136 136
137 } else if (ir->core->boardnr == CX88_BOARD_PROLINK_PLAYTVPVR || 137 } else if (ir->core->boardnr == CX88_BOARD_PROLINK_PLAYTVPVR ||
138 ir->core->boardnr == CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO) { 138 ir->core->boardnr == CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO) {
@@ -146,7 +146,7 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
146 scancode = RC_SCANCODE_NECX(addr, cmd); 146 scancode = RC_SCANCODE_NECX(addr, cmd);
147 147
148 if (0 == (gpio & ir->mask_keyup)) 148 if (0 == (gpio & ir->mask_keyup))
149 rc_keydown_notimeout(ir->dev, RC_TYPE_NECX, scancode, 149 rc_keydown_notimeout(ir->dev, RC_PROTO_NECX, scancode,
150 0); 150 0);
151 else 151 else
152 rc_keyup(ir->dev); 152 rc_keyup(ir->dev);
@@ -154,20 +154,22 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
154 } else if (ir->mask_keydown) { 154 } else if (ir->mask_keydown) {
155 /* bit set on keydown */ 155 /* bit set on keydown */
156 if (gpio & ir->mask_keydown) 156 if (gpio & ir->mask_keydown)
157 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); 157 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data,
158 0);
158 else 159 else
159 rc_keyup(ir->dev); 160 rc_keyup(ir->dev);
160 161
161 } else if (ir->mask_keyup) { 162 } else if (ir->mask_keyup) {
162 /* bit cleared on keydown */ 163 /* bit cleared on keydown */
163 if (0 == (gpio & ir->mask_keyup)) 164 if (0 == (gpio & ir->mask_keyup))
164 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); 165 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data,
166 0);
165 else 167 else
166 rc_keyup(ir->dev); 168 rc_keyup(ir->dev);
167 169
168 } else { 170 } else {
169 /* can't distinguish keydown/up :-/ */ 171 /* can't distinguish keydown/up :-/ */
170 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); 172 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data, 0);
171 rc_keyup(ir->dev); 173 rc_keyup(ir->dev);
172 } 174 }
173} 175}
@@ -267,7 +269,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
267 struct cx88_IR *ir; 269 struct cx88_IR *ir;
268 struct rc_dev *dev; 270 struct rc_dev *dev;
269 char *ir_codes = NULL; 271 char *ir_codes = NULL;
270 u64 rc_type = RC_BIT_OTHER; 272 u64 rc_proto = RC_PROTO_BIT_OTHER;
271 int err = -ENOMEM; 273 int err = -ENOMEM;
272 u32 hardware_mask = 0; /* For devices with a hardware mask, when 274 u32 hardware_mask = 0; /* For devices with a hardware mask, when
273 * used with a full-code IR table 275 * used with a full-code IR table
@@ -348,7 +350,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
348 * 002-T mini RC, provided with newer PV hardware 350 * 002-T mini RC, provided with newer PV hardware
349 */ 351 */
350 ir_codes = RC_MAP_PIXELVIEW_MK12; 352 ir_codes = RC_MAP_PIXELVIEW_MK12;
351 rc_type = RC_BIT_NECX; 353 rc_proto = RC_PROTO_BIT_NECX;
352 ir->gpio_addr = MO_GP1_IO; 354 ir->gpio_addr = MO_GP1_IO;
353 ir->mask_keyup = 0x80; 355 ir->mask_keyup = 0x80;
354 ir->polling = 10; /* ms */ 356 ir->polling = 10; /* ms */
@@ -464,7 +466,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
464 snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", core->board.name); 466 snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", core->board.name);
465 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci)); 467 snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci));
466 468
467 dev->input_name = ir->name; 469 dev->device_name = ir->name;
468 dev->input_phys = ir->phys; 470 dev->input_phys = ir->phys;
469 dev->input_id.bustype = BUS_PCI; 471 dev->input_id.bustype = BUS_PCI;
470 dev->input_id.version = 1; 472 dev->input_id.version = 1;
@@ -487,7 +489,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
487 dev->timeout = 10 * 1000 * 1000; /* 10 ms */ 489 dev->timeout = 10 * 1000 * 1000; /* 10 ms */
488 } else { 490 } else {
489 dev->driver_type = RC_DRIVER_SCANCODE; 491 dev->driver_type = RC_DRIVER_SCANCODE;
490 dev->allowed_protocols = rc_type; 492 dev->allowed_protocols = rc_proto;
491 } 493 }
492 494
493 ir->core = core; 495 ir->core = core;
@@ -557,7 +559,7 @@ void cx88_ir_irq(struct cx88_core *core)
557 ir_raw_event_handle(ir->dev); 559 ir_raw_event_handle(ir->dev);
558} 560}
559 561
560static int get_key_pvr2000(struct IR_i2c *ir, enum rc_type *protocol, 562static int get_key_pvr2000(struct IR_i2c *ir, enum rc_proto *protocol,
561 u32 *scancode, u8 *toggle) 563 u32 *scancode, u8 *toggle)
562{ 564{
563 int flags, code; 565 int flags, code;
@@ -582,7 +584,7 @@ static int get_key_pvr2000(struct IR_i2c *ir, enum rc_type *protocol,
582 dprintk("IR Key/Flags: (0x%02x/0x%02x)\n", 584 dprintk("IR Key/Flags: (0x%02x/0x%02x)\n",
583 code & 0xff, flags & 0xff); 585 code & 0xff, flags & 0xff);
584 586
585 *protocol = RC_TYPE_UNKNOWN; 587 *protocol = RC_PROTO_UNKNOWN;
586 *scancode = code & 0xff; 588 *scancode = code & 0xff;
587 *toggle = 0; 589 *toggle = 0;
588 return 1; 590 return 1;
@@ -612,7 +614,7 @@ void cx88_i2c_init_ir(struct cx88_core *core)
612 case CX88_BOARD_LEADTEK_PVR2000: 614 case CX88_BOARD_LEADTEK_PVR2000:
613 addr_list = pvr2000_addr_list; 615 addr_list = pvr2000_addr_list;
614 core->init_data.name = "cx88 Leadtek PVR 2000 remote"; 616 core->init_data.name = "cx88 Leadtek PVR 2000 remote";
615 core->init_data.type = RC_BIT_UNKNOWN; 617 core->init_data.type = RC_PROTO_BIT_UNKNOWN;
616 core->init_data.get_key = get_key_pvr2000; 618 core->init_data.get_key = get_key_pvr2000;
617 core->init_data.ir_codes = RC_MAP_EMPTY; 619 core->init_data.ir_codes = RC_MAP_EMPTY;
618 break; 620 break;
@@ -633,8 +635,8 @@ void cx88_i2c_init_ir(struct cx88_core *core)
633 /* Hauppauge XVR */ 635 /* Hauppauge XVR */
634 core->init_data.name = "cx88 Hauppauge XVR remote"; 636 core->init_data.name = "cx88 Hauppauge XVR remote";
635 core->init_data.ir_codes = RC_MAP_HAUPPAUGE; 637 core->init_data.ir_codes = RC_MAP_HAUPPAUGE;
636 core->init_data.type = RC_BIT_RC5 | RC_BIT_RC6_MCE | 638 core->init_data.type = RC_PROTO_BIT_RC5 |
637 RC_BIT_RC6_6A_32; 639 RC_PROTO_BIT_RC6_MCE | RC_PROTO_BIT_RC6_6A_32;
638 core->init_data.internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 640 core->init_data.internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
639 641
640 info.platform_data = &core->init_data; 642 info.platform_data = &core->init_data;
diff --git a/drivers/media/pci/ddbridge/Kconfig b/drivers/media/pci/ddbridge/Kconfig
index ffed78c2ffb4..f43d0b83fc0c 100644
--- a/drivers/media/pci/ddbridge/Kconfig
+++ b/drivers/media/pci/ddbridge/Kconfig
@@ -8,7 +8,11 @@ config DVB_DDBRIDGE
8 select DVB_TDA18271C2DD if MEDIA_SUBDRV_AUTOSELECT 8 select DVB_TDA18271C2DD if MEDIA_SUBDRV_AUTOSELECT
9 select DVB_STV0367 if MEDIA_SUBDRV_AUTOSELECT 9 select DVB_STV0367 if MEDIA_SUBDRV_AUTOSELECT
10 select DVB_CXD2841ER if MEDIA_SUBDRV_AUTOSELECT 10 select DVB_CXD2841ER if MEDIA_SUBDRV_AUTOSELECT
11 select DVB_STV0910 if MEDIA_SUBDRV_AUTOSELECT
12 select DVB_STV6111 if MEDIA_SUBDRV_AUTOSELECT
13 select DVB_LNBH25 if MEDIA_SUBDRV_AUTOSELECT
11 select MEDIA_TUNER_TDA18212 if MEDIA_SUBDRV_AUTOSELECT 14 select MEDIA_TUNER_TDA18212 if MEDIA_SUBDRV_AUTOSELECT
15 select DVB_MXL5XX if MEDIA_SUBDRV_AUTOSELECT
12 ---help--- 16 ---help---
13 Support for cards with the Digital Devices PCI express bridge: 17 Support for cards with the Digital Devices PCI express bridge:
14 - Octopus PCIe Bridge 18 - Octopus PCIe Bridge
@@ -20,5 +24,22 @@ config DVB_DDBRIDGE
20 - CineCTv6 and DuoFlex CT (STV0367-based) 24 - CineCTv6 and DuoFlex CT (STV0367-based)
21 - CineCTv7 and DuoFlex CT2/C2T2/C2T2I (Sony CXD28xx-based) 25 - CineCTv7 and DuoFlex CT2/C2T2/C2T2I (Sony CXD28xx-based)
22 - MaxA8 series 26 - MaxA8 series
27 - CineS2 V7/V7A and DuoFlex S2 V4 (ST STV0910-based)
28 - Max S4/8
23 29
24 Say Y if you own such a card and want to use it. 30 Say Y if you own such a card and want to use it.
31
32config DVB_DDBRIDGE_MSIENABLE
33 bool "Enable Message Signaled Interrupts (MSI) per default (EXPERIMENTAL)"
34 depends on DVB_DDBRIDGE
35 depends on PCI_MSI
36 default n
37 ---help---
38 Use PCI MSI (Message Signaled Interrupts) per default. Enabling this
39 might lead to I2C errors originating from the bridge in conjunction
40 with certain SATA controllers, requiring a reload of the ddbridge
41 module. MSI can still be disabled by passing msi=0 as option, as
42 this will just change the msi option default value.
43
44 If you're unsure, concerned about stability and don't want to pass
45 module options in case of troubles, say N.
diff --git a/drivers/media/pci/ddbridge/Makefile b/drivers/media/pci/ddbridge/Makefile
index 7446c8b677b5..09703312a3f1 100644
--- a/drivers/media/pci/ddbridge/Makefile
+++ b/drivers/media/pci/ddbridge/Makefile
@@ -2,7 +2,8 @@
2# Makefile for the ddbridge device driver 2# Makefile for the ddbridge device driver
3# 3#
4 4
5ddbridge-objs := ddbridge-core.o 5ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-hw.o \
6 ddbridge-i2c.o ddbridge-maxs8.o
6 7
7obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o 8obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o
8 9
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
index cd1723e79a07..f4bd4908acdd 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1,7 +1,10 @@
1/* 1/*
2 * ddbridge.c: Digital Devices PCIe bridge driver 2 * ddbridge-core.c: Digital Devices bridge core functions
3 *
4 * Copyright (C) 2010-2017 Digital Devices GmbH
5 * Marcus Metzler <mocm@metzlerbros.de>
6 * Ralph Metzler <rjkm@metzlerbros.de>
3 * 7 *
4 * Copyright (C) 2010-2011 Digital Devices GmbH
5 * 8 *
6 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
@@ -17,8 +20,6 @@
17 * http://www.gnu.org/copyleft/gpl.html 20 * http://www.gnu.org/copyleft/gpl.html
18 */ 21 */
19 22
20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21
22#include <linux/module.h> 23#include <linux/module.h>
23#include <linux/init.h> 24#include <linux/init.h>
24#include <linux/interrupt.h> 25#include <linux/interrupt.h>
@@ -32,9 +33,12 @@
32#include <linux/i2c.h> 33#include <linux/i2c.h>
33#include <linux/swab.h> 34#include <linux/swab.h>
34#include <linux/vmalloc.h> 35#include <linux/vmalloc.h>
35#include "ddbridge.h"
36 36
37#include "ddbridge.h"
38#include "ddbridge-i2c.h"
37#include "ddbridge-regs.h" 39#include "ddbridge-regs.h"
40#include "ddbridge-maxs8.h"
41#include "ddbridge-io.h"
38 42
39#include "tda18271c2dd.h" 43#include "tda18271c2dd.h"
40#include "stv6110x.h" 44#include "stv6110x.h"
@@ -45,446 +49,511 @@
45#include "stv0367_priv.h" 49#include "stv0367_priv.h"
46#include "cxd2841er.h" 50#include "cxd2841er.h"
47#include "tda18212.h" 51#include "tda18212.h"
52#include "stv0910.h"
53#include "stv6111.h"
54#include "lnbh25.h"
55#include "cxd2099.h"
48 56
49static int xo2_speed = 2; 57/****************************************************************************/
50module_param(xo2_speed, int, 0444);
51MODULE_PARM_DESC(xo2_speed, "default transfer speed for xo2 based duoflex, 0=55,1=75,2=90,3=104 MBit/s, default=2, use attribute to change for individual cards");
52
53DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
54 58
55/* MSI had problems with lost interrupts, fixed but needs testing */ 59#define DDB_MAX_ADAPTER 64
56#undef CONFIG_PCI_MSI
57 60
58/******************************************************************************/ 61/****************************************************************************/
59 62
60static int i2c_io(struct i2c_adapter *adapter, u8 adr, 63DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
61 u8 *wbuf, u32 wlen, u8 *rbuf, u32 rlen)
62{
63 struct i2c_msg msgs[2] = {{.addr = adr, .flags = 0,
64 .buf = wbuf, .len = wlen },
65 {.addr = adr, .flags = I2C_M_RD,
66 .buf = rbuf, .len = rlen } };
67 return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1;
68}
69 64
70static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len) 65static int adapter_alloc;
71{ 66module_param(adapter_alloc, int, 0444);
72 struct i2c_msg msg = {.addr = adr, .flags = 0, 67MODULE_PARM_DESC(adapter_alloc,
73 .buf = data, .len = len}; 68 "0-one adapter per io, 1-one per tab with io, 2-one per tab, 3-one for all");
74 69
75 return (i2c_transfer(adap, &msg, 1) == 1) ? 0 : -1; 70/****************************************************************************/
76}
77 71
78static int i2c_read(struct i2c_adapter *adapter, u8 adr, u8 *val) 72static DEFINE_MUTEX(redirect_lock);
79{
80 struct i2c_msg msgs[1] = {{.addr = adr, .flags = I2C_M_RD,
81 .buf = val, .len = 1 } };
82 return (i2c_transfer(adapter, msgs, 1) == 1) ? 0 : -1;
83}
84 73
85static int i2c_read_regs(struct i2c_adapter *adapter, 74struct workqueue_struct *ddb_wq;
86 u8 adr, u8 reg, u8 *val, u8 len)
87{
88 struct i2c_msg msgs[2] = {{.addr = adr, .flags = 0,
89 .buf = &reg, .len = 1 },
90 {.addr = adr, .flags = I2C_M_RD,
91 .buf = val, .len = len } };
92 return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1;
93}
94 75
95static int i2c_read_reg(struct i2c_adapter *adapter, u8 adr, u8 reg, u8 *val) 76static struct ddb *ddbs[DDB_MAX_ADAPTER];
96{
97 return i2c_read_regs(adapter, adr, reg, val, 1);
98}
99 77
100static int i2c_read_reg16(struct i2c_adapter *adapter, u8 adr, 78/****************************************************************************/
101 u16 reg, u8 *val) 79/****************************************************************************/
102{ 80/****************************************************************************/
103 u8 msg[2] = {reg>>8, reg&0xff};
104 struct i2c_msg msgs[2] = {{.addr = adr, .flags = 0,
105 .buf = msg, .len = 2},
106 {.addr = adr, .flags = I2C_M_RD,
107 .buf = val, .len = 1} };
108 return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1;
109}
110 81
111static int i2c_write_reg(struct i2c_adapter *adap, u8 adr, 82static void ddb_set_dma_table(struct ddb_io *io)
112 u8 reg, u8 val)
113{ 83{
114 u8 msg[2] = {reg, val}; 84 struct ddb *dev = io->port->dev;
85 struct ddb_dma *dma = io->dma;
86 u32 i;
87 u64 mem;
115 88
116 return i2c_write(adap, adr, msg, 2); 89 if (!dma)
90 return;
91 for (i = 0; i < dma->num; i++) {
92 mem = dma->pbuf[i];
93 ddbwritel(dev, mem & 0xffffffff, dma->bufregs + i * 8);
94 ddbwritel(dev, mem >> 32, dma->bufregs + i * 8 + 4);
95 }
96 dma->bufval = ((dma->div & 0x0f) << 16) |
97 ((dma->num & 0x1f) << 11) |
98 ((dma->size >> 7) & 0x7ff);
117} 99}
118 100
119static inline u32 safe_ddbreadl(struct ddb *dev, u32 adr) 101static void ddb_set_dma_tables(struct ddb *dev)
120{ 102{
121 u32 val = ddbreadl(adr); 103 u32 i;
122 104
123 /* (ddb)readl returns (uint)-1 (all bits set) on failure, catch that */ 105 for (i = 0; i < DDB_MAX_PORT; i++) {
124 if (val == ~0) { 106 if (dev->port[i].input[0])
125 dev_err(&dev->pdev->dev, "ddbreadl failure, adr=%08x\n", adr); 107 ddb_set_dma_table(dev->port[i].input[0]);
126 return 0; 108 if (dev->port[i].input[1])
109 ddb_set_dma_table(dev->port[i].input[1]);
110 if (dev->port[i].output)
111 ddb_set_dma_table(dev->port[i].output);
127 } 112 }
128
129 return val;
130} 113}
131 114
132static int ddb_i2c_cmd(struct ddb_i2c *i2c, u32 adr, u32 cmd) 115
116/****************************************************************************/
117/****************************************************************************/
118/****************************************************************************/
119
120static void ddb_redirect_dma(struct ddb *dev,
121 struct ddb_dma *sdma,
122 struct ddb_dma *ddma)
133{ 123{
134 struct ddb *dev = i2c->dev; 124 u32 i, base;
135 long stat; 125 u64 mem;
136 u32 val;
137 126
138 i2c->done = 0; 127 sdma->bufval = ddma->bufval;
139 ddbwritel((adr << 9) | cmd, i2c->regs + I2C_COMMAND); 128 base = sdma->bufregs;
140 stat = wait_event_timeout(i2c->wq, i2c->done == 1, HZ); 129 for (i = 0; i < ddma->num; i++) {
141 if (stat == 0) { 130 mem = ddma->pbuf[i];
142 dev_err(&dev->pdev->dev, "I2C timeout\n"); 131 ddbwritel(dev, mem & 0xffffffff, base + i * 8);
143 { /* MSI debugging*/ 132 ddbwritel(dev, mem >> 32, base + i * 8 + 4);
144 u32 istat = ddbreadl(INTERRUPT_STATUS);
145 dev_err(&dev->pdev->dev, "IRS %08x\n", istat);
146 ddbwritel(istat, INTERRUPT_ACK);
147 }
148 return -EIO;
149 } 133 }
150 val = ddbreadl(i2c->regs+I2C_COMMAND);
151 if (val & 0x70000)
152 return -EIO;
153 return 0;
154} 134}
155 135
156static int ddb_i2c_master_xfer(struct i2c_adapter *adapter, 136static int ddb_unredirect(struct ddb_port *port)
157 struct i2c_msg msg[], int num)
158{ 137{
159 struct ddb_i2c *i2c = (struct ddb_i2c *)i2c_get_adapdata(adapter); 138 struct ddb_input *oredi, *iredi = NULL;
160 struct ddb *dev = i2c->dev; 139 struct ddb_output *iredo = NULL;
161 u8 addr = 0;
162
163 if (num)
164 addr = msg[0].addr;
165
166 if (num == 2 && msg[1].flags & I2C_M_RD &&
167 !(msg[0].flags & I2C_M_RD)) {
168 memcpy_toio(dev->regs + I2C_TASKMEM_BASE + i2c->wbuf,
169 msg[0].buf, msg[0].len);
170 ddbwritel(msg[0].len|(msg[1].len << 16),
171 i2c->regs+I2C_TASKLENGTH);
172 if (!ddb_i2c_cmd(i2c, addr, 1)) {
173 memcpy_fromio(msg[1].buf,
174 dev->regs + I2C_TASKMEM_BASE + i2c->rbuf,
175 msg[1].len);
176 return num;
177 }
178 }
179 140
180 if (num == 1 && !(msg[0].flags & I2C_M_RD)) { 141 /* dev_info(port->dev->dev,
181 ddbcpyto(I2C_TASKMEM_BASE + i2c->wbuf, msg[0].buf, msg[0].len); 142 * "unredirect %d.%d\n", port->dev->nr, port->nr);
182 ddbwritel(msg[0].len, i2c->regs + I2C_TASKLENGTH); 143 */
183 if (!ddb_i2c_cmd(i2c, addr, 2)) 144 mutex_lock(&redirect_lock);
184 return num; 145 if (port->output->dma->running) {
146 mutex_unlock(&redirect_lock);
147 return -EBUSY;
185 } 148 }
186 if (num == 1 && (msg[0].flags & I2C_M_RD)) { 149 oredi = port->output->redi;
187 ddbwritel(msg[0].len << 16, i2c->regs + I2C_TASKLENGTH); 150 if (!oredi)
188 if (!ddb_i2c_cmd(i2c, addr, 3)) { 151 goto done;
189 ddbcpyfrom(msg[0].buf, 152 if (port->input[0]) {
190 I2C_TASKMEM_BASE + i2c->rbuf, msg[0].len); 153 iredi = port->input[0]->redi;
191 return num; 154 iredo = port->input[0]->redo;
155
156 if (iredo) {
157 iredo->port->output->redi = oredi;
158 if (iredo->port->input[0]) {
159 iredo->port->input[0]->redi = iredi;
160 ddb_redirect_dma(oredi->port->dev,
161 oredi->dma, iredo->dma);
162 }
163 port->input[0]->redo = NULL;
164 ddb_set_dma_table(port->input[0]);
192 } 165 }
166 oredi->redi = iredi;
167 port->input[0]->redi = NULL;
193 } 168 }
194 return -EIO; 169 oredi->redo = NULL;
195} 170 port->output->redi = NULL;
196
197
198static u32 ddb_i2c_functionality(struct i2c_adapter *adap)
199{
200 return I2C_FUNC_SMBUS_EMUL;
201}
202
203static struct i2c_algorithm ddb_i2c_algo = {
204 .master_xfer = ddb_i2c_master_xfer,
205 .functionality = ddb_i2c_functionality,
206};
207
208static void ddb_i2c_release(struct ddb *dev)
209{
210 int i;
211 struct ddb_i2c *i2c;
212 struct i2c_adapter *adap;
213 171
214 for (i = 0; i < dev->info->port_num; i++) { 172 ddb_set_dma_table(oredi);
215 i2c = &dev->i2c[i]; 173done:
216 adap = &i2c->adap; 174 mutex_unlock(&redirect_lock);
217 i2c_del_adapter(adap); 175 return 0;
218 }
219} 176}
220 177
221static int ddb_i2c_init(struct ddb *dev) 178static int ddb_redirect(u32 i, u32 p)
222{ 179{
223 int i, j, stat = 0; 180 struct ddb *idev = ddbs[(i >> 4) & 0x3f];
224 struct ddb_i2c *i2c; 181 struct ddb_input *input, *input2;
225 struct i2c_adapter *adap; 182 struct ddb *pdev = ddbs[(p >> 4) & 0x3f];
226 183 struct ddb_port *port;
227 for (i = 0; i < dev->info->port_num; i++) {
228 i2c = &dev->i2c[i];
229 i2c->dev = dev;
230 i2c->nr = i;
231 i2c->wbuf = i * (I2C_TASKMEM_SIZE / 4);
232 i2c->rbuf = i2c->wbuf + (I2C_TASKMEM_SIZE / 8);
233 i2c->regs = 0x80 + i * 0x20;
234 ddbwritel(I2C_SPEED_100, i2c->regs + I2C_TIMING);
235 ddbwritel((i2c->rbuf << 16) | i2c->wbuf,
236 i2c->regs + I2C_TASKADDRESS);
237 init_waitqueue_head(&i2c->wq);
238
239 adap = &i2c->adap;
240 i2c_set_adapdata(adap, i2c);
241#ifdef I2C_ADAP_CLASS_TV_DIGITAL
242 adap->class = I2C_ADAP_CLASS_TV_DIGITAL|I2C_CLASS_TV_ANALOG;
243#else
244#ifdef I2C_CLASS_TV_ANALOG
245 adap->class = I2C_CLASS_TV_ANALOG;
246#endif
247#endif
248 strcpy(adap->name, "ddbridge");
249 adap->algo = &ddb_i2c_algo;
250 adap->algo_data = (void *)i2c;
251 adap->dev.parent = &dev->pdev->dev;
252 stat = i2c_add_adapter(adap);
253 if (stat)
254 break;
255 }
256 if (stat)
257 for (j = 0; j < i; j++) {
258 i2c = &dev->i2c[j];
259 adap = &i2c->adap;
260 i2c_del_adapter(adap);
261 }
262 return stat;
263}
264 184
185 if (!idev || !pdev)
186 return -EINVAL;
187 if (!idev->has_dma || !pdev->has_dma)
188 return -EINVAL;
265 189
266/******************************************************************************/ 190 port = &pdev->port[p & 0x0f];
267/******************************************************************************/ 191 if (!port->output)
268/******************************************************************************/ 192 return -EINVAL;
193 if (ddb_unredirect(port))
194 return -EBUSY;
269 195
270#if 0 196 if (i == 8)
271static void set_table(struct ddb *dev, u32 off, 197 return 0;
272 dma_addr_t *pbuf, u32 num)
273{
274 u32 i, base;
275 u64 mem;
276 198
277 base = DMA_BASE_ADDRESS_TABLE + off; 199 input = &idev->input[i & 7];
278 for (i = 0; i < num; i++) { 200 if (!input)
279 mem = pbuf[i]; 201 return -EINVAL;
280 ddbwritel(mem & 0xffffffff, base + i * 8);
281 ddbwritel(mem >> 32, base + i * 8 + 4);
282 }
283}
284#endif
285 202
286static void ddb_address_table(struct ddb *dev) 203 mutex_lock(&redirect_lock);
287{ 204 if (port->output->dma->running || input->dma->running) {
288 u32 i, j, base; 205 mutex_unlock(&redirect_lock);
289 u64 mem; 206 return -EBUSY;
290 dma_addr_t *pbuf;
291
292 for (i = 0; i < dev->info->port_num * 2; i++) {
293 base = DMA_BASE_ADDRESS_TABLE + i * 0x100;
294 pbuf = dev->input[i].pbuf;
295 for (j = 0; j < dev->input[i].dma_buf_num; j++) {
296 mem = pbuf[j];
297 ddbwritel(mem & 0xffffffff, base + j * 8);
298 ddbwritel(mem >> 32, base + j * 8 + 4);
299 }
300 } 207 }
301 for (i = 0; i < dev->info->port_num; i++) { 208 input2 = port->input[0];
302 base = DMA_BASE_ADDRESS_TABLE + 0x800 + i * 0x100; 209 if (input2) {
303 pbuf = dev->output[i].pbuf; 210 if (input->redi) {
304 for (j = 0; j < dev->output[i].dma_buf_num; j++) { 211 input2->redi = input->redi;
305 mem = pbuf[j]; 212 input->redi = NULL;
306 ddbwritel(mem & 0xffffffff, base + j * 8); 213 } else
307 ddbwritel(mem >> 32, base + j * 8 + 4); 214 input2->redi = input;
308 }
309 } 215 }
216 input->redo = port->output;
217 port->output->redi = input;
218
219 ddb_redirect_dma(input->port->dev, input->dma, port->output->dma);
220 mutex_unlock(&redirect_lock);
221 return 0;
310} 222}
311 223
312static void io_free(struct pci_dev *pdev, u8 **vbuf, 224/****************************************************************************/
313 dma_addr_t *pbuf, u32 size, int num) 225/****************************************************************************/
226/****************************************************************************/
227
228static void dma_free(struct pci_dev *pdev, struct ddb_dma *dma, int dir)
314{ 229{
315 int i; 230 int i;
316 231
317 for (i = 0; i < num; i++) { 232 if (!dma)
318 if (vbuf[i]) { 233 return;
319 pci_free_consistent(pdev, size, vbuf[i], pbuf[i]); 234 for (i = 0; i < dma->num; i++) {
320 vbuf[i] = NULL; 235 if (dma->vbuf[i]) {
236 if (alt_dma) {
237 dma_unmap_single(&pdev->dev, dma->pbuf[i],
238 dma->size,
239 dir ? DMA_TO_DEVICE :
240 DMA_FROM_DEVICE);
241 kfree(dma->vbuf[i]);
242 dma->vbuf[i] = NULL;
243 } else {
244 dma_free_coherent(&pdev->dev, dma->size,
245 dma->vbuf[i], dma->pbuf[i]);
246 }
247
248 dma->vbuf[i] = NULL;
321 } 249 }
322 } 250 }
323} 251}
324 252
325static int io_alloc(struct pci_dev *pdev, u8 **vbuf, 253static int dma_alloc(struct pci_dev *pdev, struct ddb_dma *dma, int dir)
326 dma_addr_t *pbuf, u32 size, int num)
327{ 254{
328 int i; 255 int i;
329 256
330 for (i = 0; i < num; i++) { 257 if (!dma)
331 vbuf[i] = pci_alloc_consistent(pdev, size, &pbuf[i]); 258 return 0;
332 if (!vbuf[i]) 259 for (i = 0; i < dma->num; i++) {
333 return -ENOMEM; 260 if (alt_dma) {
261 dma->vbuf[i] = kmalloc(dma->size, __GFP_RETRY_MAYFAIL);
262 if (!dma->vbuf[i])
263 return -ENOMEM;
264 dma->pbuf[i] = dma_map_single(&pdev->dev,
265 dma->vbuf[i],
266 dma->size,
267 dir ? DMA_TO_DEVICE :
268 DMA_FROM_DEVICE);
269 if (dma_mapping_error(&pdev->dev, dma->pbuf[i])) {
270 kfree(dma->vbuf[i]);
271 dma->vbuf[i] = NULL;
272 return -ENOMEM;
273 }
274 } else {
275 dma->vbuf[i] = dma_alloc_coherent(&pdev->dev,
276 dma->size,
277 &dma->pbuf[i],
278 GFP_KERNEL);
279 if (!dma->vbuf[i])
280 return -ENOMEM;
281 }
334 } 282 }
335 return 0; 283 return 0;
336} 284}
337 285
338static int ddb_buffers_alloc(struct ddb *dev) 286int ddb_buffers_alloc(struct ddb *dev)
339{ 287{
340 int i; 288 int i;
341 struct ddb_port *port; 289 struct ddb_port *port;
342 290
343 for (i = 0; i < dev->info->port_num; i++) { 291 for (i = 0; i < dev->port_num; i++) {
344 port = &dev->port[i]; 292 port = &dev->port[i];
345 switch (port->class) { 293 switch (port->class) {
346 case DDB_PORT_TUNER: 294 case DDB_PORT_TUNER:
347 if (io_alloc(dev->pdev, port->input[0]->vbuf, 295 if (port->input[0]->dma)
348 port->input[0]->pbuf, 296 if (dma_alloc(dev->pdev, port->input[0]->dma, 0)
349 port->input[0]->dma_buf_size, 297 < 0)
350 port->input[0]->dma_buf_num) < 0) 298 return -1;
351 return -1; 299 if (port->input[1]->dma)
352 if (io_alloc(dev->pdev, port->input[1]->vbuf, 300 if (dma_alloc(dev->pdev, port->input[1]->dma, 0)
353 port->input[1]->pbuf, 301 < 0)
354 port->input[1]->dma_buf_size, 302 return -1;
355 port->input[1]->dma_buf_num) < 0)
356 return -1;
357 break; 303 break;
358 case DDB_PORT_CI: 304 case DDB_PORT_CI:
359 if (io_alloc(dev->pdev, port->input[0]->vbuf, 305 case DDB_PORT_LOOP:
360 port->input[0]->pbuf, 306 if (port->input[0]->dma)
361 port->input[0]->dma_buf_size, 307 if (dma_alloc(dev->pdev, port->input[0]->dma, 0)
362 port->input[0]->dma_buf_num) < 0) 308 < 0)
363 return -1; 309 return -1;
364 if (io_alloc(dev->pdev, port->output->vbuf, 310 if (port->output->dma)
365 port->output->pbuf, 311 if (dma_alloc(dev->pdev, port->output->dma, 1)
366 port->output->dma_buf_size, 312 < 0)
367 port->output->dma_buf_num) < 0) 313 return -1;
368 return -1;
369 break; 314 break;
370 default: 315 default:
371 break; 316 break;
372 } 317 }
373 } 318 }
374 ddb_address_table(dev); 319 ddb_set_dma_tables(dev);
375 return 0; 320 return 0;
376} 321}
377 322
378static void ddb_buffers_free(struct ddb *dev) 323void ddb_buffers_free(struct ddb *dev)
379{ 324{
380 int i; 325 int i;
381 struct ddb_port *port; 326 struct ddb_port *port;
382 327
383 for (i = 0; i < dev->info->port_num; i++) { 328 for (i = 0; i < dev->port_num; i++) {
384 port = &dev->port[i]; 329 port = &dev->port[i];
385 io_free(dev->pdev, port->input[0]->vbuf, 330
386 port->input[0]->pbuf, 331 if (port->input[0] && port->input[0]->dma)
387 port->input[0]->dma_buf_size, 332 dma_free(dev->pdev, port->input[0]->dma, 0);
388 port->input[0]->dma_buf_num); 333 if (port->input[1] && port->input[1]->dma)
389 io_free(dev->pdev, port->input[1]->vbuf, 334 dma_free(dev->pdev, port->input[1]->dma, 0);
390 port->input[1]->pbuf, 335 if (port->output && port->output->dma)
391 port->input[1]->dma_buf_size, 336 dma_free(dev->pdev, port->output->dma, 1);
392 port->input[1]->dma_buf_num);
393 io_free(dev->pdev, port->output->vbuf,
394 port->output->pbuf,
395 port->output->dma_buf_size,
396 port->output->dma_buf_num);
397 } 337 }
398} 338}
399 339
400static void ddb_input_start(struct ddb_input *input) 340static void calc_con(struct ddb_output *output, u32 *con, u32 *con2, u32 flags)
401{ 341{
402 struct ddb *dev = input->port->dev; 342 struct ddb *dev = output->port->dev;
343 u32 bitrate = output->port->obr, max_bitrate = 72000;
344 u32 gap = 4, nco = 0;
345
346 *con = 0x1c;
347 if (output->port->gap != 0xffffffff) {
348 flags |= 1;
349 gap = output->port->gap;
350 max_bitrate = 0;
351 }
352 if (dev->link[0].info->type == DDB_OCTOPUS_CI && output->port->nr > 1) {
353 *con = 0x10c;
354 if (dev->link[0].ids.regmapid >= 0x10003 && !(flags & 1)) {
355 if (!(flags & 2)) {
356 /* NCO */
357 max_bitrate = 0;
358 gap = 0;
359 if (bitrate != 72000) {
360 if (bitrate >= 96000)
361 *con |= 0x800;
362 else {
363 *con |= 0x1000;
364 nco = (bitrate * 8192 + 71999)
365 / 72000;
366 }
367 }
368 } else {
369 /* Divider and gap */
370 *con |= 0x1810;
371 if (bitrate <= 64000) {
372 max_bitrate = 64000;
373 nco = 8;
374 } else if (bitrate <= 72000) {
375 max_bitrate = 72000;
376 nco = 7;
377 } else {
378 max_bitrate = 96000;
379 nco = 5;
380 }
381 }
382 } else {
383 if (bitrate > 72000) {
384 *con |= 0x810; /* 96 MBit/s and gap */
385 max_bitrate = 96000;
386 }
387 *con |= 0x10; /* enable gap */
388 }
389 }
390 if (max_bitrate > 0) {
391 if (bitrate > max_bitrate)
392 bitrate = max_bitrate;
393 if (bitrate < 31000)
394 bitrate = 31000;
395 gap = ((max_bitrate - bitrate) * 94) / bitrate;
396 if (gap < 2)
397 *con &= ~0x10; /* Disable gap */
398 else
399 gap -= 2;
400 if (gap > 127)
401 gap = 127;
402 }
403
404 *con2 = (nco << 16) | gap;
405}
403 406
404 spin_lock_irq(&input->lock); 407static void ddb_output_start(struct ddb_output *output)
405 input->cbuf = 0; 408{
406 input->coff = 0; 409 struct ddb *dev = output->port->dev;
410 u32 con = 0x11c, con2 = 0;
411
412 if (output->dma) {
413 spin_lock_irq(&output->dma->lock);
414 output->dma->cbuf = 0;
415 output->dma->coff = 0;
416 output->dma->stat = 0;
417 ddbwritel(dev, 0, DMA_BUFFER_CONTROL(output->dma));
418 }
407 419
408 /* reset */ 420 if (output->port->input[0]->port->class == DDB_PORT_LOOP)
409 ddbwritel(0, TS_INPUT_CONTROL(input->nr)); 421 con = (1UL << 13) | 0x14;
410 ddbwritel(2, TS_INPUT_CONTROL(input->nr)); 422 else
411 ddbwritel(0, TS_INPUT_CONTROL(input->nr)); 423 calc_con(output, &con, &con2, 0);
424
425 ddbwritel(dev, 0, TS_CONTROL(output));
426 ddbwritel(dev, 2, TS_CONTROL(output));
427 ddbwritel(dev, 0, TS_CONTROL(output));
428 ddbwritel(dev, con, TS_CONTROL(output));
429 ddbwritel(dev, con2, TS_CONTROL2(output));
430
431 if (output->dma) {
432 ddbwritel(dev, output->dma->bufval,
433 DMA_BUFFER_SIZE(output->dma));
434 ddbwritel(dev, 0, DMA_BUFFER_ACK(output->dma));
435 ddbwritel(dev, 1, DMA_BASE_READ);
436 ddbwritel(dev, 7, DMA_BUFFER_CONTROL(output->dma));
437 }
412 438
413 ddbwritel((1 << 16) | 439 ddbwritel(dev, con | 1, TS_CONTROL(output));
414 (input->dma_buf_num << 11) |
415 (input->dma_buf_size >> 7),
416 DMA_BUFFER_SIZE(input->nr));
417 ddbwritel(0, DMA_BUFFER_ACK(input->nr));
418 440
419 ddbwritel(1, DMA_BASE_WRITE); 441 if (output->dma) {
420 ddbwritel(3, DMA_BUFFER_CONTROL(input->nr)); 442 output->dma->running = 1;
421 ddbwritel(9, TS_INPUT_CONTROL(input->nr)); 443 spin_unlock_irq(&output->dma->lock);
422 input->running = 1; 444 }
423 spin_unlock_irq(&input->lock); 445}
446
447static void ddb_output_stop(struct ddb_output *output)
448{
449 struct ddb *dev = output->port->dev;
450
451 if (output->dma)
452 spin_lock_irq(&output->dma->lock);
453
454 ddbwritel(dev, 0, TS_CONTROL(output));
455
456 if (output->dma) {
457 ddbwritel(dev, 0, DMA_BUFFER_CONTROL(output->dma));
458 output->dma->running = 0;
459 spin_unlock_irq(&output->dma->lock);
460 }
424} 461}
425 462
426static void ddb_input_stop(struct ddb_input *input) 463static void ddb_input_stop(struct ddb_input *input)
427{ 464{
428 struct ddb *dev = input->port->dev; 465 struct ddb *dev = input->port->dev;
466 u32 tag = DDB_LINK_TAG(input->port->lnr);
467
468 if (input->dma)
469 spin_lock_irq(&input->dma->lock);
470 ddbwritel(dev, 0, tag | TS_CONTROL(input));
471 if (input->dma) {
472 ddbwritel(dev, 0, DMA_BUFFER_CONTROL(input->dma));
473 input->dma->running = 0;
474 spin_unlock_irq(&input->dma->lock);
475 }
476}
477
478static void ddb_input_start(struct ddb_input *input)
479{
480 struct ddb *dev = input->port->dev;
481
482 if (input->dma) {
483 spin_lock_irq(&input->dma->lock);
484 input->dma->cbuf = 0;
485 input->dma->coff = 0;
486 input->dma->stat = 0;
487 ddbwritel(dev, 0, DMA_BUFFER_CONTROL(input->dma));
488 }
489 ddbwritel(dev, 0, TS_CONTROL(input));
490 ddbwritel(dev, 2, TS_CONTROL(input));
491 ddbwritel(dev, 0, TS_CONTROL(input));
492
493 if (input->dma) {
494 ddbwritel(dev, input->dma->bufval,
495 DMA_BUFFER_SIZE(input->dma));
496 ddbwritel(dev, 0, DMA_BUFFER_ACK(input->dma));
497 ddbwritel(dev, 1, DMA_BASE_WRITE);
498 ddbwritel(dev, 3, DMA_BUFFER_CONTROL(input->dma));
499 }
429 500
430 spin_lock_irq(&input->lock); 501 ddbwritel(dev, 0x09, TS_CONTROL(input));
431 ddbwritel(0, TS_INPUT_CONTROL(input->nr)); 502
432 ddbwritel(0, DMA_BUFFER_CONTROL(input->nr)); 503 if (input->dma) {
433 input->running = 0; 504 input->dma->running = 1;
434 spin_unlock_irq(&input->lock); 505 spin_unlock_irq(&input->dma->lock);
506 }
435} 507}
436 508
437static void ddb_output_start(struct ddb_output *output) 509
510static void ddb_input_start_all(struct ddb_input *input)
438{ 511{
439 struct ddb *dev = output->port->dev; 512 struct ddb_input *i = input;
513 struct ddb_output *o;
440 514
441 spin_lock_irq(&output->lock); 515 mutex_lock(&redirect_lock);
442 output->cbuf = 0; 516 while (i && (o = i->redo)) {
443 output->coff = 0; 517 ddb_output_start(o);
444 ddbwritel(0, TS_OUTPUT_CONTROL(output->nr)); 518 i = o->port->input[0];
445 ddbwritel(2, TS_OUTPUT_CONTROL(output->nr)); 519 if (i)
446 ddbwritel(0, TS_OUTPUT_CONTROL(output->nr)); 520 ddb_input_start(i);
447 ddbwritel(0x3c, TS_OUTPUT_CONTROL(output->nr)); 521 }
448 ddbwritel((1 << 16) | 522 ddb_input_start(input);
449 (output->dma_buf_num << 11) | 523 mutex_unlock(&redirect_lock);
450 (output->dma_buf_size >> 7),
451 DMA_BUFFER_SIZE(output->nr + 8));
452 ddbwritel(0, DMA_BUFFER_ACK(output->nr + 8));
453
454 ddbwritel(1, DMA_BASE_READ);
455 ddbwritel(3, DMA_BUFFER_CONTROL(output->nr + 8));
456 /* ddbwritel(0xbd, TS_OUTPUT_CONTROL(output->nr)); */
457 ddbwritel(0x1d, TS_OUTPUT_CONTROL(output->nr));
458 output->running = 1;
459 spin_unlock_irq(&output->lock);
460} 524}
461 525
462static void ddb_output_stop(struct ddb_output *output) 526static void ddb_input_stop_all(struct ddb_input *input)
463{ 527{
464 struct ddb *dev = output->port->dev; 528 struct ddb_input *i = input;
529 struct ddb_output *o;
465 530
466 spin_lock_irq(&output->lock); 531 mutex_lock(&redirect_lock);
467 ddbwritel(0, TS_OUTPUT_CONTROL(output->nr)); 532 ddb_input_stop(input);
468 ddbwritel(0, DMA_BUFFER_CONTROL(output->nr + 8)); 533 while (i && (o = i->redo)) {
469 output->running = 0; 534 ddb_output_stop(o);
470 spin_unlock_irq(&output->lock); 535 i = o->port->input[0];
536 if (i)
537 ddb_input_stop(i);
538 }
539 mutex_unlock(&redirect_lock);
471} 540}
472 541
473static u32 ddb_output_free(struct ddb_output *output) 542static u32 ddb_output_free(struct ddb_output *output)
474{ 543{
475 u32 idx, off, stat = output->stat; 544 u32 idx, off, stat = output->dma->stat;
476 s32 diff; 545 s32 diff;
477 546
478 idx = (stat >> 11) & 0x1f; 547 idx = (stat >> 11) & 0x1f;
479 off = (stat & 0x7ff) << 7; 548 off = (stat & 0x7ff) << 7;
480 549
481 if (output->cbuf != idx) { 550 if (output->dma->cbuf != idx) {
482 if ((((output->cbuf + 1) % output->dma_buf_num) == idx) && 551 if ((((output->dma->cbuf + 1) % output->dma->num) == idx) &&
483 (output->dma_buf_size - output->coff <= 188)) 552 (output->dma->size - output->dma->coff <= 188))
484 return 0; 553 return 0;
485 return 188; 554 return 188;
486 } 555 }
487 diff = off - output->coff; 556 diff = off - output->dma->coff;
488 if (diff <= 0 || diff > 188) 557 if (diff <= 0 || diff > 188)
489 return 188; 558 return 188;
490 return 0; 559 return 0;
@@ -494,46 +563,51 @@ static ssize_t ddb_output_write(struct ddb_output *output,
494 const __user u8 *buf, size_t count) 563 const __user u8 *buf, size_t count)
495{ 564{
496 struct ddb *dev = output->port->dev; 565 struct ddb *dev = output->port->dev;
497 u32 idx, off, stat = output->stat; 566 u32 idx, off, stat = output->dma->stat;
498 u32 left = count, len; 567 u32 left = count, len;
499 568
500 idx = (stat >> 11) & 0x1f; 569 idx = (stat >> 11) & 0x1f;
501 off = (stat & 0x7ff) << 7; 570 off = (stat & 0x7ff) << 7;
502 571
503 while (left) { 572 while (left) {
504 len = output->dma_buf_size - output->coff; 573 len = output->dma->size - output->dma->coff;
505 if ((((output->cbuf + 1) % output->dma_buf_num) == idx) && 574 if ((((output->dma->cbuf + 1) % output->dma->num) == idx) &&
506 (off == 0)) { 575 (off == 0)) {
507 if (len <= 188) 576 if (len <= 188)
508 break; 577 break;
509 len -= 188; 578 len -= 188;
510 } 579 }
511 if (output->cbuf == idx) { 580 if (output->dma->cbuf == idx) {
512 if (off > output->coff) { 581 if (off > output->dma->coff) {
513#if 1 582 len = off - output->dma->coff;
514 len = off - output->coff;
515 len -= (len % 188); 583 len -= (len % 188);
516 if (len <= 188) 584 if (len <= 188)
517
518#endif
519 break; 585 break;
520 len -= 188; 586 len -= 188;
521 } 587 }
522 } 588 }
523 if (len > left) 589 if (len > left)
524 len = left; 590 len = left;
525 if (copy_from_user(output->vbuf[output->cbuf] + output->coff, 591 if (copy_from_user(output->dma->vbuf[output->dma->cbuf] +
592 output->dma->coff,
526 buf, len)) 593 buf, len))
527 return -EIO; 594 return -EIO;
595 if (alt_dma)
596 dma_sync_single_for_device(dev->dev,
597 output->dma->pbuf[output->dma->cbuf],
598 output->dma->size, DMA_TO_DEVICE);
528 left -= len; 599 left -= len;
529 buf += len; 600 buf += len;
530 output->coff += len; 601 output->dma->coff += len;
531 if (output->coff == output->dma_buf_size) { 602 if (output->dma->coff == output->dma->size) {
532 output->coff = 0; 603 output->dma->coff = 0;
533 output->cbuf = ((output->cbuf + 1) % output->dma_buf_num); 604 output->dma->cbuf = ((output->dma->cbuf + 1) %
605 output->dma->num);
534 } 606 }
535 ddbwritel((output->cbuf << 11) | (output->coff >> 7), 607 ddbwritel(dev,
536 DMA_BUFFER_ACK(output->nr + 8)); 608 (output->dma->cbuf << 11) |
609 (output->dma->coff >> 7),
610 DMA_BUFFER_ACK(output->dma));
537 } 611 }
538 return count - left; 612 return count - left;
539} 613}
@@ -541,81 +615,229 @@ static ssize_t ddb_output_write(struct ddb_output *output,
541static u32 ddb_input_avail(struct ddb_input *input) 615static u32 ddb_input_avail(struct ddb_input *input)
542{ 616{
543 struct ddb *dev = input->port->dev; 617 struct ddb *dev = input->port->dev;
544 u32 idx, off, stat = input->stat; 618 u32 idx, off, stat = input->dma->stat;
545 u32 ctrl = ddbreadl(DMA_BUFFER_CONTROL(input->nr)); 619 u32 ctrl = ddbreadl(dev, DMA_BUFFER_CONTROL(input->dma));
546 620
547 idx = (stat >> 11) & 0x1f; 621 idx = (stat >> 11) & 0x1f;
548 off = (stat & 0x7ff) << 7; 622 off = (stat & 0x7ff) << 7;
549 623
550 if (ctrl & 4) { 624 if (ctrl & 4) {
551 dev_err(&dev->pdev->dev, "IA %d %d %08x\n", idx, off, ctrl); 625 dev_err(dev->dev, "IA %d %d %08x\n", idx, off, ctrl);
552 ddbwritel(input->stat, DMA_BUFFER_ACK(input->nr)); 626 ddbwritel(dev, stat, DMA_BUFFER_ACK(input->dma));
553 return 0; 627 return 0;
554 } 628 }
555 if (input->cbuf != idx) 629 if (input->dma->cbuf != idx)
556 return 188; 630 return 188;
557 return 0; 631 return 0;
558} 632}
559 633
560static ssize_t ddb_input_read(struct ddb_input *input, __user u8 *buf, size_t count) 634static ssize_t ddb_input_read(struct ddb_input *input,
635 __user u8 *buf, size_t count)
561{ 636{
562 struct ddb *dev = input->port->dev; 637 struct ddb *dev = input->port->dev;
563 u32 left = count; 638 u32 left = count;
564 u32 idx, free, stat = input->stat; 639 u32 idx, free, stat = input->dma->stat;
565 int ret; 640 int ret;
566 641
567 idx = (stat >> 11) & 0x1f; 642 idx = (stat >> 11) & 0x1f;
568 643
569 while (left) { 644 while (left) {
570 if (input->cbuf == idx) 645 if (input->dma->cbuf == idx)
571 return count - left; 646 return count - left;
572 free = input->dma_buf_size - input->coff; 647 free = input->dma->size - input->dma->coff;
573 if (free > left) 648 if (free > left)
574 free = left; 649 free = left;
575 ret = copy_to_user(buf, input->vbuf[input->cbuf] + 650 if (alt_dma)
576 input->coff, free); 651 dma_sync_single_for_cpu(dev->dev,
652 input->dma->pbuf[input->dma->cbuf],
653 input->dma->size, DMA_FROM_DEVICE);
654 ret = copy_to_user(buf, input->dma->vbuf[input->dma->cbuf] +
655 input->dma->coff, free);
577 if (ret) 656 if (ret)
578 return -EFAULT; 657 return -EFAULT;
579 input->coff += free; 658 input->dma->coff += free;
580 if (input->coff == input->dma_buf_size) { 659 if (input->dma->coff == input->dma->size) {
581 input->coff = 0; 660 input->dma->coff = 0;
582 input->cbuf = (input->cbuf+1) % input->dma_buf_num; 661 input->dma->cbuf = (input->dma->cbuf + 1) %
662 input->dma->num;
583 } 663 }
584 left -= free; 664 left -= free;
585 ddbwritel((input->cbuf << 11) | (input->coff >> 7), 665 buf += free;
586 DMA_BUFFER_ACK(input->nr)); 666 ddbwritel(dev,
667 (input->dma->cbuf << 11) | (input->dma->coff >> 7),
668 DMA_BUFFER_ACK(input->dma));
587 } 669 }
588 return count; 670 return count;
589} 671}
590 672
591/******************************************************************************/ 673/****************************************************************************/
592/******************************************************************************/ 674/****************************************************************************/
593/******************************************************************************/
594 675
595#if 0 676static ssize_t ts_write(struct file *file, const __user char *buf,
596static struct ddb_input *fe2input(struct ddb *dev, struct dvb_frontend *fe) 677 size_t count, loff_t *ppos)
597{ 678{
598 int i; 679 struct dvb_device *dvbdev = file->private_data;
680 struct ddb_output *output = dvbdev->priv;
681 struct ddb *dev = output->port->dev;
682 size_t left = count;
683 int stat;
599 684
600 for (i = 0; i < dev->info->port_num * 2; i++) { 685 if (!dev->has_dma)
601 if (dev->input[i].fe == fe) 686 return -EINVAL;
602 return &dev->input[i]; 687 while (left) {
688 if (ddb_output_free(output) < 188) {
689 if (file->f_flags & O_NONBLOCK)
690 break;
691 if (wait_event_interruptible(
692 output->dma->wq,
693 ddb_output_free(output) >= 188) < 0)
694 break;
695 }
696 stat = ddb_output_write(output, buf, left);
697 if (stat < 0)
698 return stat;
699 buf += stat;
700 left -= stat;
603 } 701 }
604 return NULL; 702 return (left == count) ? -EAGAIN : (count - left);
605} 703}
606#endif
607 704
608static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable) 705static ssize_t ts_read(struct file *file, __user char *buf,
706 size_t count, loff_t *ppos)
707{
708 struct dvb_device *dvbdev = file->private_data;
709 struct ddb_output *output = dvbdev->priv;
710 struct ddb_input *input = output->port->input[0];
711 struct ddb *dev = output->port->dev;
712 size_t left = count;
713 int stat;
714
715 if (!dev->has_dma)
716 return -EINVAL;
717 while (left) {
718 if (ddb_input_avail(input) < 188) {
719 if (file->f_flags & O_NONBLOCK)
720 break;
721 if (wait_event_interruptible(
722 input->dma->wq,
723 ddb_input_avail(input) >= 188) < 0)
724 break;
725 }
726 stat = ddb_input_read(input, buf, left);
727 if (stat < 0)
728 return stat;
729 left -= stat;
730 buf += stat;
731 }
732 return (count && (left == count)) ? -EAGAIN : (count - left);
733}
734
735static unsigned int ts_poll(struct file *file, poll_table *wait)
736{
737 struct dvb_device *dvbdev = file->private_data;
738 struct ddb_output *output = dvbdev->priv;
739 struct ddb_input *input = output->port->input[0];
740
741 unsigned int mask = 0;
742
743 poll_wait(file, &input->dma->wq, wait);
744 poll_wait(file, &output->dma->wq, wait);
745 if (ddb_input_avail(input) >= 188)
746 mask |= POLLIN | POLLRDNORM;
747 if (ddb_output_free(output) >= 188)
748 mask |= POLLOUT | POLLWRNORM;
749 return mask;
750}
751
752static int ts_release(struct inode *inode, struct file *file)
753{
754 struct dvb_device *dvbdev = file->private_data;
755 struct ddb_output *output = NULL;
756 struct ddb_input *input = NULL;
757
758 if (dvbdev) {
759 output = dvbdev->priv;
760 input = output->port->input[0];
761 }
762
763 if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
764 if (!input)
765 return -EINVAL;
766 ddb_input_stop(input);
767 } else if ((file->f_flags & O_ACCMODE) == O_WRONLY) {
768 if (!output)
769 return -EINVAL;
770 ddb_output_stop(output);
771 }
772 return dvb_generic_release(inode, file);
773}
774
775static int ts_open(struct inode *inode, struct file *file)
776{
777 int err;
778 struct dvb_device *dvbdev = file->private_data;
779 struct ddb_output *output = NULL;
780 struct ddb_input *input = NULL;
781
782 if (dvbdev) {
783 output = dvbdev->priv;
784 input = output->port->input[0];
785 }
786
787 if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
788 if (!input)
789 return -EINVAL;
790 if (input->redo || input->redi)
791 return -EBUSY;
792 } else if ((file->f_flags & O_ACCMODE) == O_WRONLY) {
793 if (!output)
794 return -EINVAL;
795 } else
796 return -EINVAL;
797 err = dvb_generic_open(inode, file);
798 if (err < 0)
799 return err;
800 if ((file->f_flags & O_ACCMODE) == O_RDONLY)
801 ddb_input_start(input);
802 else if ((file->f_flags & O_ACCMODE) == O_WRONLY)
803 ddb_output_start(output);
804 return err;
805}
806
807static const struct file_operations ci_fops = {
808 .owner = THIS_MODULE,
809 .read = ts_read,
810 .write = ts_write,
811 .open = ts_open,
812 .release = ts_release,
813 .poll = ts_poll,
814 .mmap = NULL,
815};
816
817static struct dvb_device dvbdev_ci = {
818 .priv = NULL,
819 .readers = 1,
820 .writers = 1,
821 .users = 2,
822 .fops = &ci_fops,
823};
824
825
826/****************************************************************************/
827/****************************************************************************/
828
829static int locked_gate_ctrl(struct dvb_frontend *fe, int enable)
609{ 830{
610 struct ddb_input *input = fe->sec_priv; 831 struct ddb_input *input = fe->sec_priv;
611 struct ddb_port *port = input->port; 832 struct ddb_port *port = input->port;
833 struct ddb_dvb *dvb = &port->dvb[input->nr & 1];
612 int status; 834 int status;
613 835
614 if (enable) { 836 if (enable) {
615 mutex_lock(&port->i2c_gate_lock); 837 mutex_lock(&port->i2c_gate_lock);
616 status = input->gate_ctrl(fe, 1); 838 status = dvb->i2c_gate_ctrl(fe, 1);
617 } else { 839 } else {
618 status = input->gate_ctrl(fe, 0); 840 status = dvb->i2c_gate_ctrl(fe, 0);
619 mutex_unlock(&port->i2c_gate_lock); 841 mutex_unlock(&port->i2c_gate_lock);
620 } 842 }
621 return status; 843 return status;
@@ -624,41 +846,42 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
624static int demod_attach_drxk(struct ddb_input *input) 846static int demod_attach_drxk(struct ddb_input *input)
625{ 847{
626 struct i2c_adapter *i2c = &input->port->i2c->adap; 848 struct i2c_adapter *i2c = &input->port->i2c->adap;
849 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
850 struct device *dev = input->port->dev->dev;
627 struct dvb_frontend *fe; 851 struct dvb_frontend *fe;
628 struct drxk_config config; 852 struct drxk_config config;
629 struct device *dev = &input->port->dev->pdev->dev;
630 853
631 memset(&config, 0, sizeof(config)); 854 memset(&config, 0, sizeof(config));
632 config.microcode_name = "drxk_a3.mc";
633 config.qam_demod_parameter_count = 4;
634 config.adr = 0x29 + (input->nr & 1); 855 config.adr = 0x29 + (input->nr & 1);
856 config.microcode_name = "drxk_a3.mc";
635 857
636 fe = input->fe = dvb_attach(drxk_attach, &config, i2c); 858 fe = dvb->fe = dvb_attach(drxk_attach, &config, i2c);
637 if (!input->fe) { 859 if (!fe) {
638 dev_err(dev, "No DRXK found!\n"); 860 dev_err(dev, "No DRXK found!\n");
639 return -ENODEV; 861 return -ENODEV;
640 } 862 }
641 fe->sec_priv = input; 863 fe->sec_priv = input;
642 input->gate_ctrl = fe->ops.i2c_gate_ctrl; 864 dvb->i2c_gate_ctrl = fe->ops.i2c_gate_ctrl;
643 fe->ops.i2c_gate_ctrl = drxk_gate_ctrl; 865 fe->ops.i2c_gate_ctrl = locked_gate_ctrl;
644 return 0; 866 return 0;
645} 867}
646 868
647static int tuner_attach_tda18271(struct ddb_input *input) 869static int tuner_attach_tda18271(struct ddb_input *input)
648{ 870{
649 struct i2c_adapter *i2c = &input->port->i2c->adap; 871 struct i2c_adapter *i2c = &input->port->i2c->adap;
872 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
873 struct device *dev = input->port->dev->dev;
650 struct dvb_frontend *fe; 874 struct dvb_frontend *fe;
651 struct device *dev = &input->port->dev->pdev->dev;
652 875
653 if (input->fe->ops.i2c_gate_ctrl) 876 if (dvb->fe->ops.i2c_gate_ctrl)
654 input->fe->ops.i2c_gate_ctrl(input->fe, 1); 877 dvb->fe->ops.i2c_gate_ctrl(dvb->fe, 1);
655 fe = dvb_attach(tda18271c2dd_attach, input->fe, i2c, 0x60); 878 fe = dvb_attach(tda18271c2dd_attach, dvb->fe, i2c, 0x60);
879 if (dvb->fe->ops.i2c_gate_ctrl)
880 dvb->fe->ops.i2c_gate_ctrl(dvb->fe, 0);
656 if (!fe) { 881 if (!fe) {
657 dev_err(dev, "No TDA18271 found!\n"); 882 dev_err(dev, "No TDA18271 found!\n");
658 return -ENODEV; 883 return -ENODEV;
659 } 884 }
660 if (input->fe->ops.i2c_gate_ctrl)
661 input->fe->ops.i2c_gate_ctrl(input->fe, 0);
662 return 0; 885 return 0;
663} 886}
664 887
@@ -687,43 +910,43 @@ static struct stv0367_config ddb_stv0367_config[] = {
687static int demod_attach_stv0367(struct ddb_input *input) 910static int demod_attach_stv0367(struct ddb_input *input)
688{ 911{
689 struct i2c_adapter *i2c = &input->port->i2c->adap; 912 struct i2c_adapter *i2c = &input->port->i2c->adap;
690 struct device *dev = &input->port->dev->pdev->dev; 913 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
914 struct device *dev = input->port->dev->dev;
915 struct dvb_frontend *fe;
691 916
692 /* attach frontend */ 917 /* attach frontend */
693 input->fe = dvb_attach(stv0367ddb_attach, 918 fe = dvb->fe = dvb_attach(stv0367ddb_attach,
694 &ddb_stv0367_config[(input->nr & 1)], i2c); 919 &ddb_stv0367_config[(input->nr & 1)], i2c);
695 920
696 if (!input->fe) { 921 if (!dvb->fe) {
697 dev_err(dev, "stv0367ddb_attach failed (not found?)\n"); 922 dev_err(dev, "No stv0367 found!\n");
698 return -ENODEV; 923 return -ENODEV;
699 } 924 }
700 925 fe->sec_priv = input;
701 input->fe->sec_priv = input; 926 dvb->i2c_gate_ctrl = fe->ops.i2c_gate_ctrl;
702 input->gate_ctrl = input->fe->ops.i2c_gate_ctrl; 927 fe->ops.i2c_gate_ctrl = locked_gate_ctrl;
703 input->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
704
705 return 0; 928 return 0;
706} 929}
707 930
708static int tuner_tda18212_ping(struct ddb_input *input, unsigned short adr) 931static int tuner_tda18212_ping(struct ddb_input *input, unsigned short adr)
709{ 932{
710 struct i2c_adapter *adapter = &input->port->i2c->adap; 933 struct i2c_adapter *adapter = &input->port->i2c->adap;
711 struct device *dev = &input->port->dev->pdev->dev; 934 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
712 935 struct device *dev = input->port->dev->dev;
713 u8 tda_id[2]; 936 u8 tda_id[2];
714 u8 subaddr = 0x00; 937 u8 subaddr = 0x00;
715 938
716 dev_dbg(dev, "stv0367-tda18212 tuner ping\n"); 939 dev_dbg(dev, "stv0367-tda18212 tuner ping\n");
717 if (input->fe->ops.i2c_gate_ctrl) 940 if (dvb->fe->ops.i2c_gate_ctrl)
718 input->fe->ops.i2c_gate_ctrl(input->fe, 1); 941 dvb->fe->ops.i2c_gate_ctrl(dvb->fe, 1);
719 942
720 if (i2c_read_regs(adapter, adr, subaddr, tda_id, sizeof(tda_id)) < 0) 943 if (i2c_read_regs(adapter, adr, subaddr, tda_id, sizeof(tda_id)) < 0)
721 dev_dbg(dev, "tda18212 ping 1 fail\n"); 944 dev_dbg(dev, "tda18212 ping 1 fail\n");
722 if (i2c_read_regs(adapter, adr, subaddr, tda_id, sizeof(tda_id)) < 0) 945 if (i2c_read_regs(adapter, adr, subaddr, tda_id, sizeof(tda_id)) < 0)
723 dev_warn(dev, "tda18212 ping failed, expect problems\n"); 946 dev_warn(dev, "tda18212 ping failed, expect problems\n");
724 947
725 if (input->fe->ops.i2c_gate_ctrl) 948 if (dvb->fe->ops.i2c_gate_ctrl)
726 input->fe->ops.i2c_gate_ctrl(input->fe, 0); 949 dvb->fe->ops.i2c_gate_ctrl(dvb->fe, 0);
727 950
728 return 0; 951 return 0;
729} 952}
@@ -731,7 +954,9 @@ static int tuner_tda18212_ping(struct ddb_input *input, unsigned short adr)
731static int demod_attach_cxd28xx(struct ddb_input *input, int par, int osc24) 954static int demod_attach_cxd28xx(struct ddb_input *input, int par, int osc24)
732{ 955{
733 struct i2c_adapter *i2c = &input->port->i2c->adap; 956 struct i2c_adapter *i2c = &input->port->i2c->adap;
734 struct device *dev = &input->port->dev->pdev->dev; 957 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
958 struct device *dev = input->port->dev->dev;
959 struct dvb_frontend *fe;
735 struct cxd2841er_config cfg; 960 struct cxd2841er_config cfg;
736 961
737 /* the cxd2841er driver expects 8bit/shifted I2C addresses */ 962 /* the cxd2841er driver expects 8bit/shifted I2C addresses */
@@ -746,27 +971,26 @@ static int demod_attach_cxd28xx(struct ddb_input *input, int par, int osc24)
746 cfg.flags |= CXD2841ER_TS_SERIAL; 971 cfg.flags |= CXD2841ER_TS_SERIAL;
747 972
748 /* attach frontend */ 973 /* attach frontend */
749 input->fe = dvb_attach(cxd2841er_attach_t_c, &cfg, i2c); 974 fe = dvb->fe = dvb_attach(cxd2841er_attach_t_c, &cfg, i2c);
750 975
751 if (!input->fe) { 976 if (!dvb->fe) {
752 dev_err(dev, "No Sony CXD28xx found!\n"); 977 dev_err(dev, "No cxd2837/38/43/54 found!\n");
753 return -ENODEV; 978 return -ENODEV;
754 } 979 }
755 980 fe->sec_priv = input;
756 input->fe->sec_priv = input; 981 dvb->i2c_gate_ctrl = fe->ops.i2c_gate_ctrl;
757 input->gate_ctrl = input->fe->ops.i2c_gate_ctrl; 982 fe->ops.i2c_gate_ctrl = locked_gate_ctrl;
758 input->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
759
760 return 0; 983 return 0;
761} 984}
762 985
763static int tuner_attach_tda18212(struct ddb_input *input, u32 porttype) 986static int tuner_attach_tda18212(struct ddb_input *input, u32 porttype)
764{ 987{
765 struct i2c_adapter *adapter = &input->port->i2c->adap; 988 struct i2c_adapter *adapter = &input->port->i2c->adap;
766 struct device *dev = &input->port->dev->pdev->dev; 989 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
990 struct device *dev = input->port->dev->dev;
767 struct i2c_client *client; 991 struct i2c_client *client;
768 struct tda18212_config config = { 992 struct tda18212_config config = {
769 .fe = input->fe, 993 .fe = dvb->fe,
770 .if_dvbt_6 = 3550, 994 .if_dvbt_6 = 3550,
771 .if_dvbt_7 = 3700, 995 .if_dvbt_7 = 3700,
772 .if_dvbt_8 = 4150, 996 .if_dvbt_8 = 4150,
@@ -804,17 +1028,17 @@ static int tuner_attach_tda18212(struct ddb_input *input, u32 porttype)
804 goto err; 1028 goto err;
805 } 1029 }
806 1030
807 input->i2c_client[0] = client; 1031 dvb->i2c_client[0] = client;
808 1032
809 return 0; 1033 return 0;
810err: 1034err:
811 dev_warn(dev, "TDA18212 tuner not found. Device is not fully operational.\n"); 1035 dev_notice(dev, "TDA18212 tuner not found. Device is not fully operational.\n");
812 return -ENODEV; 1036 return -ENODEV;
813} 1037}
814 1038
815/******************************************************************************/ 1039/****************************************************************************/
816/******************************************************************************/ 1040/****************************************************************************/
817/******************************************************************************/ 1041/****************************************************************************/
818 1042
819static struct stv090x_config stv0900 = { 1043static struct stv090x_config stv0900 = {
820 .device = STV0900, 1044 .device = STV0900,
@@ -827,6 +1051,9 @@ static struct stv090x_config stv0900 = {
827 .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED, 1051 .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED,
828 .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED, 1052 .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED,
829 1053
1054 .ts1_tei = 1,
1055 .ts2_tei = 1,
1056
830 .repeater_level = STV090x_RPTLEVEL_16, 1057 .repeater_level = STV090x_RPTLEVEL_16,
831 1058
832 .adc1_range = STV090x_ADC_1Vpp, 1059 .adc1_range = STV090x_ADC_1Vpp,
@@ -846,6 +1073,9 @@ static struct stv090x_config stv0900_aa = {
846 .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED, 1073 .ts1_mode = STV090x_TSMODE_SERIAL_PUNCTURED,
847 .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED, 1074 .ts2_mode = STV090x_TSMODE_SERIAL_PUNCTURED,
848 1075
1076 .ts1_tei = 1,
1077 .ts2_tei = 1,
1078
849 .repeater_level = STV090x_RPTLEVEL_16, 1079 .repeater_level = STV090x_RPTLEVEL_16,
850 1080
851 .adc1_range = STV090x_ADC_1Vpp, 1081 .adc1_range = STV090x_ADC_1Vpp,
@@ -869,17 +1099,18 @@ static struct stv6110x_config stv6110b = {
869static int demod_attach_stv0900(struct ddb_input *input, int type) 1099static int demod_attach_stv0900(struct ddb_input *input, int type)
870{ 1100{
871 struct i2c_adapter *i2c = &input->port->i2c->adap; 1101 struct i2c_adapter *i2c = &input->port->i2c->adap;
872 struct device *dev = &input->port->dev->pdev->dev;
873 struct stv090x_config *feconf = type ? &stv0900_aa : &stv0900; 1102 struct stv090x_config *feconf = type ? &stv0900_aa : &stv0900;
1103 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
1104 struct device *dev = input->port->dev->dev;
874 1105
875 input->fe = dvb_attach(stv090x_attach, feconf, i2c, 1106 dvb->fe = dvb_attach(stv090x_attach, feconf, i2c,
876 (input->nr & 1) ? STV090x_DEMODULATOR_1 1107 (input->nr & 1) ? STV090x_DEMODULATOR_1
877 : STV090x_DEMODULATOR_0); 1108 : STV090x_DEMODULATOR_0);
878 if (!input->fe) { 1109 if (!dvb->fe) {
879 dev_err(dev, "No STV0900 found!\n"); 1110 dev_err(dev, "No STV0900 found!\n");
880 return -ENODEV; 1111 return -ENODEV;
881 } 1112 }
882 if (!dvb_attach(lnbh24_attach, input->fe, i2c, 0, 1113 if (!dvb_attach(lnbh24_attach, dvb->fe, i2c, 0,
883 0, (input->nr & 1) ? 1114 0, (input->nr & 1) ?
884 (0x09 - type) : (0x0b - type))) { 1115 (0x09 - type) : (0x0b - type))) {
885 dev_err(dev, "No LNBH24 found!\n"); 1116 dev_err(dev, "No LNBH24 found!\n");
@@ -891,19 +1122,20 @@ static int demod_attach_stv0900(struct ddb_input *input, int type)
891static int tuner_attach_stv6110(struct ddb_input *input, int type) 1122static int tuner_attach_stv6110(struct ddb_input *input, int type)
892{ 1123{
893 struct i2c_adapter *i2c = &input->port->i2c->adap; 1124 struct i2c_adapter *i2c = &input->port->i2c->adap;
894 struct device *dev = &input->port->dev->pdev->dev; 1125 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
1126 struct device *dev = input->port->dev->dev;
895 struct stv090x_config *feconf = type ? &stv0900_aa : &stv0900; 1127 struct stv090x_config *feconf = type ? &stv0900_aa : &stv0900;
896 struct stv6110x_config *tunerconf = (input->nr & 1) ? 1128 struct stv6110x_config *tunerconf = (input->nr & 1) ?
897 &stv6110b : &stv6110a; 1129 &stv6110b : &stv6110a;
898 const struct stv6110x_devctl *ctl; 1130 const struct stv6110x_devctl *ctl;
899 1131
900 ctl = dvb_attach(stv6110x_attach, input->fe, tunerconf, i2c); 1132 ctl = dvb_attach(stv6110x_attach, dvb->fe, tunerconf, i2c);
901 if (!ctl) { 1133 if (!ctl) {
902 dev_err(dev, "No STV6110X found!\n"); 1134 dev_err(dev, "No STV6110X found!\n");
903 return -ENODEV; 1135 return -ENODEV;
904 } 1136 }
905 dev_info(dev, "attach tuner input %d adr %02x\n", 1137 dev_info(dev, "attach tuner input %d adr %02x\n",
906 input->nr, tunerconf->addr); 1138 input->nr, tunerconf->addr);
907 1139
908 feconf->tuner_init = ctl->tuner_init; 1140 feconf->tuner_init = ctl->tuner_init;
909 feconf->tuner_sleep = ctl->tuner_sleep; 1141 feconf->tuner_sleep = ctl->tuner_sleep;
@@ -920,388 +1152,1062 @@ static int tuner_attach_stv6110(struct ddb_input *input, int type)
920 return 0; 1152 return 0;
921} 1153}
922 1154
923static int my_dvb_dmx_ts_card_init(struct dvb_demux *dvbdemux, char *id, 1155static const struct stv0910_cfg stv0910_p = {
924 int (*start_feed)(struct dvb_demux_feed *), 1156 .adr = 0x68,
925 int (*stop_feed)(struct dvb_demux_feed *), 1157 .parallel = 1,
926 void *priv) 1158 .rptlvl = 4,
1159 .clk = 30000000,
1160};
1161
1162static const struct lnbh25_config lnbh25_cfg = {
1163 .i2c_address = 0x0c << 1,
1164 .data2_config = LNBH25_TEN
1165};
1166
1167static int demod_attach_stv0910(struct ddb_input *input, int type)
927{ 1168{
928 dvbdemux->priv = priv; 1169 struct i2c_adapter *i2c = &input->port->i2c->adap;
1170 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
1171 struct device *dev = input->port->dev->dev;
1172 struct stv0910_cfg cfg = stv0910_p;
1173 struct lnbh25_config lnbcfg = lnbh25_cfg;
1174
1175 if (stv0910_single)
1176 cfg.single = 1;
1177
1178 if (type)
1179 cfg.parallel = 2;
1180 dvb->fe = dvb_attach(stv0910_attach, i2c, &cfg, (input->nr & 1));
1181 if (!dvb->fe) {
1182 cfg.adr = 0x6c;
1183 dvb->fe = dvb_attach(stv0910_attach, i2c,
1184 &cfg, (input->nr & 1));
1185 }
1186 if (!dvb->fe) {
1187 dev_err(dev, "No STV0910 found!\n");
1188 return -ENODEV;
1189 }
929 1190
930 dvbdemux->filternum = 256; 1191 /* attach lnbh25 - leftshift by one as the lnbh25 driver expects 8bit
931 dvbdemux->feednum = 256; 1192 * i2c addresses
932 dvbdemux->start_feed = start_feed; 1193 */
933 dvbdemux->stop_feed = stop_feed; 1194 lnbcfg.i2c_address = (((input->nr & 1) ? 0x0d : 0x0c) << 1);
934 dvbdemux->write_to_decoder = NULL; 1195 if (!dvb_attach(lnbh25_attach, dvb->fe, &lnbcfg, i2c)) {
935 dvbdemux->dmx.capabilities = (DMX_TS_FILTERING | 1196 lnbcfg.i2c_address = (((input->nr & 1) ? 0x09 : 0x08) << 1);
936 DMX_SECTION_FILTERING | 1197 if (!dvb_attach(lnbh25_attach, dvb->fe, &lnbcfg, i2c)) {
937 DMX_MEMORY_BASED_FILTERING); 1198 dev_err(dev, "No LNBH25 found!\n");
938 return dvb_dmx_init(dvbdemux); 1199 return -ENODEV;
1200 }
1201 }
1202
1203 return 0;
939} 1204}
940 1205
941static int my_dvb_dmxdev_ts_card_init(struct dmxdev *dmxdev, 1206static int tuner_attach_stv6111(struct ddb_input *input, int type)
942 struct dvb_demux *dvbdemux,
943 struct dmx_frontend *hw_frontend,
944 struct dmx_frontend *mem_frontend,
945 struct dvb_adapter *dvb_adapter)
946{ 1207{
947 int ret; 1208 struct i2c_adapter *i2c = &input->port->i2c->adap;
948 1209 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
949 dmxdev->filternum = 256; 1210 struct device *dev = input->port->dev->dev;
950 dmxdev->demux = &dvbdemux->dmx; 1211 struct dvb_frontend *fe;
951 dmxdev->capabilities = 0; 1212 u8 adr = (type ? 0 : 4) + ((input->nr & 1) ? 0x63 : 0x60);
952 ret = dvb_dmxdev_init(dmxdev, dvb_adapter);
953 if (ret < 0)
954 return ret;
955 1213
956 hw_frontend->source = DMX_FRONTEND_0; 1214 fe = dvb_attach(stv6111_attach, dvb->fe, i2c, adr);
957 dvbdemux->dmx.add_frontend(&dvbdemux->dmx, hw_frontend); 1215 if (!fe) {
958 mem_frontend->source = DMX_MEMORY_FE; 1216 fe = dvb_attach(stv6111_attach, dvb->fe, i2c, adr & ~4);
959 dvbdemux->dmx.add_frontend(&dvbdemux->dmx, mem_frontend); 1217 if (!fe) {
960 return dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, hw_frontend); 1218 dev_err(dev, "No STV6111 found at 0x%02x!\n", adr);
1219 return -ENODEV;
1220 }
1221 }
1222 return 0;
961} 1223}
962 1224
963static int start_feed(struct dvb_demux_feed *dvbdmxfeed) 1225static int start_feed(struct dvb_demux_feed *dvbdmxfeed)
964{ 1226{
965 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 1227 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
966 struct ddb_input *input = dvbdmx->priv; 1228 struct ddb_input *input = dvbdmx->priv;
1229 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
967 1230
968 if (!input->users) 1231 if (!dvb->users)
969 ddb_input_start(input); 1232 ddb_input_start_all(input);
970 1233
971 return ++input->users; 1234 return ++dvb->users;
972} 1235}
973 1236
974static int stop_feed(struct dvb_demux_feed *dvbdmxfeed) 1237static int stop_feed(struct dvb_demux_feed *dvbdmxfeed)
975{ 1238{
976 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 1239 struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
977 struct ddb_input *input = dvbdmx->priv; 1240 struct ddb_input *input = dvbdmx->priv;
1241 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
978 1242
979 if (--input->users) 1243 if (--dvb->users)
980 return input->users; 1244 return dvb->users;
981 1245
982 ddb_input_stop(input); 1246 ddb_input_stop_all(input);
983 return 0; 1247 return 0;
984} 1248}
985 1249
986
987static void dvb_input_detach(struct ddb_input *input) 1250static void dvb_input_detach(struct ddb_input *input)
988{ 1251{
989 struct dvb_adapter *adap = &input->adap; 1252 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
990 struct dvb_demux *dvbdemux = &input->demux; 1253 struct dvb_demux *dvbdemux = &dvb->demux;
991 struct i2c_client *client; 1254 struct i2c_client *client;
992 1255
993 switch (input->attached) { 1256 switch (dvb->attached) {
994 case 5: 1257 case 0x31:
995 client = input->i2c_client[0]; 1258 if (dvb->fe2)
1259 dvb_unregister_frontend(dvb->fe2);
1260 if (dvb->fe)
1261 dvb_unregister_frontend(dvb->fe);
1262 /* fallthrough */
1263 case 0x30:
1264 if (dvb->fe2)
1265 dvb_frontend_detach(dvb->fe2);
1266 if (dvb->fe)
1267 dvb_frontend_detach(dvb->fe);
1268 dvb->fe = dvb->fe2 = NULL;
1269 /* fallthrough */
1270 case 0x20:
1271 client = dvb->i2c_client[0];
996 if (client) { 1272 if (client) {
997 module_put(client->dev.driver->owner); 1273 module_put(client->dev.driver->owner);
998 i2c_unregister_device(client); 1274 i2c_unregister_device(client);
999 } 1275 }
1000 if (input->fe2) { 1276
1001 dvb_unregister_frontend(input->fe2); 1277 dvb_net_release(&dvb->dvbnet);
1002 input->fe2 = NULL; 1278 /* fallthrough */
1003 } 1279 case 0x12:
1004 if (input->fe) {
1005 dvb_unregister_frontend(input->fe);
1006 dvb_frontend_detach(input->fe);
1007 input->fe = NULL;
1008 }
1009 /* fall-through */
1010 case 4:
1011 dvb_net_release(&input->dvbnet);
1012 /* fall-through */
1013 case 3:
1014 dvbdemux->dmx.close(&dvbdemux->dmx);
1015 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, 1280 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx,
1016 &input->hw_frontend); 1281 &dvb->hw_frontend);
1017 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, 1282 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx,
1018 &input->mem_frontend); 1283 &dvb->mem_frontend);
1019 dvb_dmxdev_release(&input->dmxdev); 1284 /* fallthrough */
1020 /* fall-through */ 1285 case 0x11:
1021 case 2: 1286 dvb_dmxdev_release(&dvb->dmxdev);
1022 dvb_dmx_release(&input->demux); 1287 /* fallthrough */
1023 /* fall-through */ 1288 case 0x10:
1024 case 1: 1289 dvb_dmx_release(&dvb->demux);
1025 dvb_unregister_adapter(adap); 1290 /* fallthrough */
1291 case 0x01:
1292 break;
1293 }
1294 dvb->attached = 0x00;
1295}
1296
1297static int dvb_register_adapters(struct ddb *dev)
1298{
1299 int i, ret = 0;
1300 struct ddb_port *port;
1301 struct dvb_adapter *adap;
1302
1303 if (adapter_alloc == 3) {
1304 port = &dev->port[0];
1305 adap = port->dvb[0].adap;
1306 ret = dvb_register_adapter(adap, "DDBridge", THIS_MODULE,
1307 port->dev->dev,
1308 adapter_nr);
1309 if (ret < 0)
1310 return ret;
1311 port->dvb[0].adap_registered = 1;
1312 for (i = 0; i < dev->port_num; i++) {
1313 port = &dev->port[i];
1314 port->dvb[0].adap = adap;
1315 port->dvb[1].adap = adap;
1316 }
1317 return 0;
1318 }
1319
1320 for (i = 0; i < dev->port_num; i++) {
1321 port = &dev->port[i];
1322 switch (port->class) {
1323 case DDB_PORT_TUNER:
1324 adap = port->dvb[0].adap;
1325 ret = dvb_register_adapter(adap, "DDBridge",
1326 THIS_MODULE,
1327 port->dev->dev,
1328 adapter_nr);
1329 if (ret < 0)
1330 return ret;
1331 port->dvb[0].adap_registered = 1;
1332
1333 if (adapter_alloc > 0) {
1334 port->dvb[1].adap = port->dvb[0].adap;
1335 break;
1336 }
1337 adap = port->dvb[1].adap;
1338 ret = dvb_register_adapter(adap, "DDBridge",
1339 THIS_MODULE,
1340 port->dev->dev,
1341 adapter_nr);
1342 if (ret < 0)
1343 return ret;
1344 port->dvb[1].adap_registered = 1;
1345 break;
1346
1347 case DDB_PORT_CI:
1348 case DDB_PORT_LOOP:
1349 adap = port->dvb[0].adap;
1350 ret = dvb_register_adapter(adap, "DDBridge",
1351 THIS_MODULE,
1352 port->dev->dev,
1353 adapter_nr);
1354 if (ret < 0)
1355 return ret;
1356 port->dvb[0].adap_registered = 1;
1357 break;
1358 default:
1359 if (adapter_alloc < 2)
1360 break;
1361 adap = port->dvb[0].adap;
1362 ret = dvb_register_adapter(adap, "DDBridge",
1363 THIS_MODULE,
1364 port->dev->dev,
1365 adapter_nr);
1366 if (ret < 0)
1367 return ret;
1368 port->dvb[0].adap_registered = 1;
1369 break;
1370 }
1371 }
1372 return ret;
1373}
1374
1375static void dvb_unregister_adapters(struct ddb *dev)
1376{
1377 int i;
1378 struct ddb_port *port;
1379 struct ddb_dvb *dvb;
1380
1381 for (i = 0; i < dev->link[0].info->port_num; i++) {
1382 port = &dev->port[i];
1383
1384 dvb = &port->dvb[0];
1385 if (dvb->adap_registered)
1386 dvb_unregister_adapter(dvb->adap);
1387 dvb->adap_registered = 0;
1388
1389 dvb = &port->dvb[1];
1390 if (dvb->adap_registered)
1391 dvb_unregister_adapter(dvb->adap);
1392 dvb->adap_registered = 0;
1026 } 1393 }
1027 input->attached = 0;
1028} 1394}
1029 1395
1030static int dvb_input_attach(struct ddb_input *input) 1396static int dvb_input_attach(struct ddb_input *input)
1031{ 1397{
1032 int ret; 1398 int ret = 0;
1399 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
1033 struct ddb_port *port = input->port; 1400 struct ddb_port *port = input->port;
1034 struct dvb_adapter *adap = &input->adap; 1401 struct dvb_adapter *adap = dvb->adap;
1035 struct dvb_demux *dvbdemux = &input->demux; 1402 struct dvb_demux *dvbdemux = &dvb->demux;
1036 struct device *dev = &input->port->dev->pdev->dev; 1403 int par = 0, osc24 = 0;
1037 int sony_osc24 = 0, sony_tspar = 0; 1404
1038 1405 dvb->attached = 0x01;
1039 ret = dvb_register_adapter(adap, "DDBridge", THIS_MODULE, 1406
1040 &input->port->dev->pdev->dev, 1407 dvbdemux->priv = input;
1041 adapter_nr); 1408 dvbdemux->dmx.capabilities = DMX_TS_FILTERING |
1042 if (ret < 0) { 1409 DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING;
1043 dev_err(dev, "Could not register adapter. Check if you enabled enough adapters in dvb-core!\n"); 1410 dvbdemux->start_feed = start_feed;
1411 dvbdemux->stop_feed = stop_feed;
1412 dvbdemux->filternum = dvbdemux->feednum = 256;
1413 ret = dvb_dmx_init(dvbdemux);
1414 if (ret < 0)
1044 return ret; 1415 return ret;
1045 } 1416 dvb->attached = 0x10;
1046 input->attached = 1;
1047 1417
1048 ret = my_dvb_dmx_ts_card_init(dvbdemux, "SW demux", 1418 dvb->dmxdev.filternum = 256;
1049 start_feed, 1419 dvb->dmxdev.demux = &dvbdemux->dmx;
1050 stop_feed, input); 1420 ret = dvb_dmxdev_init(&dvb->dmxdev, adap);
1051 if (ret < 0) 1421 if (ret < 0)
1052 return ret; 1422 return ret;
1053 input->attached = 2; 1423 dvb->attached = 0x11;
1054 1424
1055 ret = my_dvb_dmxdev_ts_card_init(&input->dmxdev, &input->demux, 1425 dvb->mem_frontend.source = DMX_MEMORY_FE;
1056 &input->hw_frontend, 1426 dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->mem_frontend);
1057 &input->mem_frontend, adap); 1427 dvb->hw_frontend.source = DMX_FRONTEND_0;
1428 dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->hw_frontend);
1429 ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, &dvb->hw_frontend);
1058 if (ret < 0) 1430 if (ret < 0)
1059 return ret; 1431 return ret;
1060 input->attached = 3; 1432 dvb->attached = 0x12;
1061 1433
1062 ret = dvb_net_init(adap, &input->dvbnet, input->dmxdev.demux); 1434 ret = dvb_net_init(adap, &dvb->dvbnet, dvb->dmxdev.demux);
1063 if (ret < 0) 1435 if (ret < 0)
1064 return ret; 1436 return ret;
1065 input->attached = 4; 1437 dvb->attached = 0x20;
1066 1438
1067 input->fe = NULL; 1439 dvb->fe = dvb->fe2 = NULL;
1068 switch (port->type) { 1440 switch (port->type) {
1441 case DDB_TUNER_MXL5XX:
1442 if (fe_attach_mxl5xx(input) < 0)
1443 return -ENODEV;
1444 break;
1069 case DDB_TUNER_DVBS_ST: 1445 case DDB_TUNER_DVBS_ST:
1070 if (demod_attach_stv0900(input, 0) < 0) 1446 if (demod_attach_stv0900(input, 0) < 0)
1071 return -ENODEV; 1447 return -ENODEV;
1072 if (tuner_attach_stv6110(input, 0) < 0) 1448 if (tuner_attach_stv6110(input, 0) < 0)
1073 return -ENODEV; 1449 return -ENODEV;
1074 if (input->fe) {
1075 if (dvb_register_frontend(adap, input->fe) < 0)
1076 return -ENODEV;
1077 }
1078 break; 1450 break;
1079 case DDB_TUNER_DVBS_ST_AA: 1451 case DDB_TUNER_DVBS_ST_AA:
1080 if (demod_attach_stv0900(input, 1) < 0) 1452 if (demod_attach_stv0900(input, 1) < 0)
1081 return -ENODEV; 1453 return -ENODEV;
1082 if (tuner_attach_stv6110(input, 1) < 0) 1454 if (tuner_attach_stv6110(input, 1) < 0)
1083 return -ENODEV; 1455 return -ENODEV;
1084 if (input->fe) { 1456 break;
1085 if (dvb_register_frontend(adap, input->fe) < 0) 1457 case DDB_TUNER_DVBS_STV0910:
1086 return -ENODEV; 1458 if (demod_attach_stv0910(input, 0) < 0)
1087 } 1459 return -ENODEV;
1460 if (tuner_attach_stv6111(input, 0) < 0)
1461 return -ENODEV;
1462 break;
1463 case DDB_TUNER_DVBS_STV0910_PR:
1464 if (demod_attach_stv0910(input, 1) < 0)
1465 return -ENODEV;
1466 if (tuner_attach_stv6111(input, 1) < 0)
1467 return -ENODEV;
1468 break;
1469 case DDB_TUNER_DVBS_STV0910_P:
1470 if (demod_attach_stv0910(input, 0) < 0)
1471 return -ENODEV;
1472 if (tuner_attach_stv6111(input, 1) < 0)
1473 return -ENODEV;
1088 break; 1474 break;
1089 case DDB_TUNER_DVBCT_TR: 1475 case DDB_TUNER_DVBCT_TR:
1090 if (demod_attach_drxk(input) < 0) 1476 if (demod_attach_drxk(input) < 0)
1091 return -ENODEV; 1477 return -ENODEV;
1092 if (tuner_attach_tda18271(input) < 0) 1478 if (tuner_attach_tda18271(input) < 0)
1093 return -ENODEV; 1479 return -ENODEV;
1094 if (dvb_register_frontend(adap, input->fe) < 0)
1095 return -ENODEV;
1096 if (input->fe2) {
1097 if (dvb_register_frontend(adap, input->fe2) < 0)
1098 return -ENODEV;
1099 input->fe2->tuner_priv = input->fe->tuner_priv;
1100 memcpy(&input->fe2->ops.tuner_ops,
1101 &input->fe->ops.tuner_ops,
1102 sizeof(struct dvb_tuner_ops));
1103 }
1104 break; 1480 break;
1105 case DDB_TUNER_DVBCT_ST: 1481 case DDB_TUNER_DVBCT_ST:
1106 if (demod_attach_stv0367(input) < 0) 1482 if (demod_attach_stv0367(input) < 0)
1107 return -ENODEV; 1483 return -ENODEV;
1108 if (tuner_attach_tda18212(input, port->type) < 0) 1484 if (tuner_attach_tda18212(input, port->type) < 0) {
1485 if (dvb->fe2)
1486 dvb_frontend_detach(dvb->fe2);
1487 if (dvb->fe)
1488 dvb_frontend_detach(dvb->fe);
1109 return -ENODEV; 1489 return -ENODEV;
1110 if (input->fe) {
1111 if (dvb_register_frontend(adap, input->fe) < 0)
1112 return -ENODEV;
1113 } 1490 }
1114 break; 1491 break;
1115 case DDB_TUNER_DVBC2T2I_SONY_P: 1492 case DDB_TUNER_DVBC2T2I_SONY_P:
1493 if (input->port->dev->link[input->port->lnr].info->ts_quirks &
1494 TS_QUIRK_ALT_OSC)
1495 osc24 = 0;
1496 else
1497 osc24 = 1;
1498 /* fall-through */
1116 case DDB_TUNER_DVBCT2_SONY_P: 1499 case DDB_TUNER_DVBCT2_SONY_P:
1117 case DDB_TUNER_DVBC2T2_SONY_P: 1500 case DDB_TUNER_DVBC2T2_SONY_P:
1118 case DDB_TUNER_ISDBT_SONY_P: 1501 case DDB_TUNER_ISDBT_SONY_P:
1119 if (port->type == DDB_TUNER_DVBC2T2I_SONY_P) 1502 if (input->port->dev->link[input->port->lnr].info->ts_quirks
1120 sony_osc24 = 1; 1503 & TS_QUIRK_SERIAL)
1121 if (input->port->dev->info->ts_quirks & TS_QUIRK_ALT_OSC) 1504 par = 0;
1122 sony_osc24 = 0;
1123 if (input->port->dev->info->ts_quirks & TS_QUIRK_SERIAL)
1124 sony_tspar = 0;
1125 else 1505 else
1126 sony_tspar = 1; 1506 par = 1;
1127 1507 if (demod_attach_cxd28xx(input, par, osc24) < 0)
1128 if (demod_attach_cxd28xx(input, sony_tspar, sony_osc24) < 0)
1129 return -ENODEV; 1508 return -ENODEV;
1130 if (tuner_attach_tda18212(input, port->type) < 0) 1509 if (tuner_attach_tda18212(input, port->type) < 0) {
1510 if (dvb->fe2)
1511 dvb_frontend_detach(dvb->fe2);
1512 if (dvb->fe)
1513 dvb_frontend_detach(dvb->fe);
1131 return -ENODEV; 1514 return -ENODEV;
1132 if (input->fe) {
1133 if (dvb_register_frontend(adap, input->fe) < 0)
1134 return -ENODEV;
1135 } 1515 }
1136 break; 1516 break;
1137 case DDB_TUNER_XO2_DVBC2T2I_SONY: 1517 case DDB_TUNER_DVBC2T2I_SONY:
1138 case DDB_TUNER_XO2_DVBCT2_SONY: 1518 osc24 = 1;
1139 case DDB_TUNER_XO2_DVBC2T2_SONY: 1519 /* fall-through */
1140 case DDB_TUNER_XO2_ISDBT_SONY: 1520 case DDB_TUNER_DVBCT2_SONY:
1141 if (port->type == DDB_TUNER_XO2_DVBC2T2I_SONY) 1521 case DDB_TUNER_DVBC2T2_SONY:
1142 sony_osc24 = 1; 1522 case DDB_TUNER_ISDBT_SONY:
1143 1523 if (demod_attach_cxd28xx(input, 0, osc24) < 0)
1144 if (demod_attach_cxd28xx(input, 0, sony_osc24) < 0)
1145 return -ENODEV; 1524 return -ENODEV;
1146 if (tuner_attach_tda18212(input, port->type) < 0) 1525 if (tuner_attach_tda18212(input, port->type) < 0) {
1526 if (dvb->fe2)
1527 dvb_frontend_detach(dvb->fe2);
1528 if (dvb->fe)
1529 dvb_frontend_detach(dvb->fe);
1147 return -ENODEV; 1530 return -ENODEV;
1148 if (input->fe) {
1149 if (dvb_register_frontend(adap, input->fe) < 0)
1150 return -ENODEV;
1151 } 1531 }
1152 break; 1532 break;
1533 default:
1534 return 0;
1535 }
1536 dvb->attached = 0x30;
1537
1538 if (dvb->fe) {
1539 if (dvb_register_frontend(adap, dvb->fe) < 0)
1540 return -ENODEV;
1541
1542 if (dvb->fe2) {
1543 if (dvb_register_frontend(adap, dvb->fe2) < 0)
1544 return -ENODEV;
1545 dvb->fe2->tuner_priv = dvb->fe->tuner_priv;
1546 memcpy(&dvb->fe2->ops.tuner_ops,
1547 &dvb->fe->ops.tuner_ops,
1548 sizeof(struct dvb_tuner_ops));
1549 }
1153 } 1550 }
1154 1551
1155 input->attached = 5; 1552 dvb->attached = 0x31;
1156 return 0; 1553 return 0;
1157} 1554}
1158 1555
1159/****************************************************************************/ 1556static int port_has_encti(struct ddb_port *port)
1160/****************************************************************************/ 1557{
1558 struct device *dev = port->dev->dev;
1559 u8 val;
1560 int ret = i2c_read_reg(&port->i2c->adap, 0x20, 0, &val);
1161 1561
1162static ssize_t ts_write(struct file *file, const __user char *buf, 1562 if (!ret)
1163 size_t count, loff_t *ppos) 1563 dev_info(dev, "[0x20]=0x%02x\n", val);
1564 return ret ? 0 : 1;
1565}
1566
1567static int port_has_cxd(struct ddb_port *port, u8 *type)
1164{ 1568{
1165 struct dvb_device *dvbdev = file->private_data; 1569 u8 val;
1166 struct ddb_output *output = dvbdev->priv; 1570 u8 probe[4] = { 0xe0, 0x00, 0x00, 0x00 }, data[4];
1167 size_t left = count; 1571 struct i2c_msg msgs[2] = {{ .addr = 0x40, .flags = 0,
1168 int stat; 1572 .buf = probe, .len = 4 },
1573 { .addr = 0x40, .flags = I2C_M_RD,
1574 .buf = data, .len = 4 } };
1575 val = i2c_transfer(&port->i2c->adap, msgs, 2);
1576 if (val != 2)
1577 return 0;
1169 1578
1170 while (left) { 1579 if (data[0] == 0x02 && data[1] == 0x2b && data[3] == 0x43)
1171 if (ddb_output_free(output) < 188) { 1580 *type = 2;
1172 if (file->f_flags & O_NONBLOCK) 1581 else
1173 break; 1582 *type = 1;
1174 if (wait_event_interruptible( 1583 return 1;
1175 output->wq, ddb_output_free(output) >= 188) < 0) 1584}
1176 break; 1585
1177 } 1586static int port_has_xo2(struct ddb_port *port, u8 *type, u8 *id)
1178 stat = ddb_output_write(output, buf, left); 1587{
1179 if (stat < 0) 1588 u8 probe[1] = { 0x00 }, data[4];
1180 break; 1589
1181 buf += stat; 1590 if (i2c_io(&port->i2c->adap, 0x10, probe, 1, data, 4))
1182 left -= stat; 1591 return 0;
1592 if (data[0] == 'D' && data[1] == 'F') {
1593 *id = data[2];
1594 *type = 1;
1595 return 1;
1183 } 1596 }
1184 return (left == count) ? -EAGAIN : (count - left); 1597 if (data[0] == 'C' && data[1] == 'I') {
1598 *id = data[2];
1599 *type = 2;
1600 return 1;
1601 }
1602 return 0;
1185} 1603}
1186 1604
1187static ssize_t ts_read(struct file *file, __user char *buf, 1605static int port_has_stv0900(struct ddb_port *port)
1188 size_t count, loff_t *ppos)
1189{ 1606{
1190 struct dvb_device *dvbdev = file->private_data; 1607 u8 val;
1191 struct ddb_output *output = dvbdev->priv;
1192 struct ddb_input *input = output->port->input[0];
1193 int left, read;
1194 1608
1195 count -= count % 188; 1609 if (i2c_read_reg16(&port->i2c->adap, 0x69, 0xf100, &val) < 0)
1196 left = count; 1610 return 0;
1197 while (left) { 1611 return 1;
1198 if (ddb_input_avail(input) < 188) { 1612}
1199 if (file->f_flags & O_NONBLOCK) 1613
1200 break; 1614static int port_has_stv0900_aa(struct ddb_port *port, u8 *id)
1201 if (wait_event_interruptible( 1615{
1202 input->wq, ddb_input_avail(input) >= 188) < 0) 1616 if (i2c_read_reg16(&port->i2c->adap, 0x68, 0xf100, id) < 0)
1203 break; 1617 return 0;
1204 } 1618 return 1;
1205 read = ddb_input_read(input, buf, left); 1619}
1206 if (read < 0) 1620
1207 return read; 1621static int port_has_drxks(struct ddb_port *port)
1208 left -= read; 1622{
1209 buf += read; 1623 u8 val;
1624
1625 if (i2c_read(&port->i2c->adap, 0x29, &val) < 0)
1626 return 0;
1627 if (i2c_read(&port->i2c->adap, 0x2a, &val) < 0)
1628 return 0;
1629 return 1;
1630}
1631
1632static int port_has_stv0367(struct ddb_port *port)
1633{
1634 u8 val;
1635
1636 if (i2c_read_reg16(&port->i2c->adap, 0x1e, 0xf000, &val) < 0)
1637 return 0;
1638 if (val != 0x60)
1639 return 0;
1640 if (i2c_read_reg16(&port->i2c->adap, 0x1f, 0xf000, &val) < 0)
1641 return 0;
1642 if (val != 0x60)
1643 return 0;
1644 return 1;
1645}
1646
1647static int init_xo2(struct ddb_port *port)
1648{
1649 struct i2c_adapter *i2c = &port->i2c->adap;
1650 struct ddb *dev = port->dev;
1651 u8 val, data[2];
1652 int res;
1653
1654 res = i2c_read_regs(i2c, 0x10, 0x04, data, 2);
1655 if (res < 0)
1656 return res;
1657
1658 if (data[0] != 0x01) {
1659 dev_info(dev->dev, "Port %d: invalid XO2\n", port->nr);
1660 return -1;
1210 } 1661 }
1211 return (left == count) ? -EAGAIN : (count - left); 1662
1663 i2c_read_reg(i2c, 0x10, 0x08, &val);
1664 if (val != 0) {
1665 i2c_write_reg(i2c, 0x10, 0x08, 0x00);
1666 msleep(100);
1667 }
1668 /* Enable tuner power, disable pll, reset demods */
1669 i2c_write_reg(i2c, 0x10, 0x08, 0x04);
1670 usleep_range(2000, 3000);
1671 /* Release demod resets */
1672 i2c_write_reg(i2c, 0x10, 0x08, 0x07);
1673
1674 /* speed: 0=55,1=75,2=90,3=104 MBit/s */
1675 i2c_write_reg(i2c, 0x10, 0x09, xo2_speed);
1676
1677 if (dev->link[port->lnr].info->con_clock) {
1678 dev_info(dev->dev, "Setting continuous clock for XO2\n");
1679 i2c_write_reg(i2c, 0x10, 0x0a, 0x03);
1680 i2c_write_reg(i2c, 0x10, 0x0b, 0x03);
1681 } else {
1682 i2c_write_reg(i2c, 0x10, 0x0a, 0x01);
1683 i2c_write_reg(i2c, 0x10, 0x0b, 0x01);
1684 }
1685
1686 usleep_range(2000, 3000);
1687 /* Start XO2 PLL */
1688 i2c_write_reg(i2c, 0x10, 0x08, 0x87);
1689
1690 return 0;
1212} 1691}
1213 1692
1214static unsigned int ts_poll(struct file *file, poll_table *wait) 1693static int init_xo2_ci(struct ddb_port *port)
1215{ 1694{
1216 /* 1695 struct i2c_adapter *i2c = &port->i2c->adap;
1217 struct dvb_device *dvbdev = file->private_data; 1696 struct ddb *dev = port->dev;
1218 struct ddb_output *output = dvbdev->priv; 1697 u8 val, data[2];
1219 struct ddb_input *input = output->port->input[0]; 1698 int res;
1220 */
1221 unsigned int mask = 0;
1222 1699
1223#if 0 1700 res = i2c_read_regs(i2c, 0x10, 0x04, data, 2);
1224 if (data_avail_to_read) 1701 if (res < 0)
1225 mask |= POLLIN | POLLRDNORM; 1702 return res;
1226 if (data_avail_to_write)
1227 mask |= POLLOUT | POLLWRNORM;
1228 1703
1229 poll_wait(file, &read_queue, wait); 1704 if (data[0] > 1) {
1230 poll_wait(file, &write_queue, wait); 1705 dev_info(dev->dev, "Port %d: invalid XO2 CI %02x\n",
1231#endif 1706 port->nr, data[0]);
1232 return mask; 1707 return -1;
1708 }
1709 dev_info(dev->dev, "Port %d: DuoFlex CI %u.%u\n",
1710 port->nr, data[0], data[1]);
1711
1712 i2c_read_reg(i2c, 0x10, 0x08, &val);
1713 if (val != 0) {
1714 i2c_write_reg(i2c, 0x10, 0x08, 0x00);
1715 msleep(100);
1716 }
1717 /* Enable both CI */
1718 i2c_write_reg(i2c, 0x10, 0x08, 3);
1719 usleep_range(2000, 3000);
1720
1721
1722 /* speed: 0=55,1=75,2=90,3=104 MBit/s */
1723 i2c_write_reg(i2c, 0x10, 0x09, 1);
1724
1725 i2c_write_reg(i2c, 0x10, 0x08, 0x83);
1726 usleep_range(2000, 3000);
1727
1728 if (dev->link[port->lnr].info->con_clock) {
1729 dev_info(dev->dev, "Setting continuous clock for DuoFlex CI\n");
1730 i2c_write_reg(i2c, 0x10, 0x0a, 0x03);
1731 i2c_write_reg(i2c, 0x10, 0x0b, 0x03);
1732 } else {
1733 i2c_write_reg(i2c, 0x10, 0x0a, 0x01);
1734 i2c_write_reg(i2c, 0x10, 0x0b, 0x01);
1735 }
1736 return 0;
1233} 1737}
1234 1738
1235static const struct file_operations ci_fops = { 1739static int port_has_cxd28xx(struct ddb_port *port, u8 *id)
1236 .owner = THIS_MODULE, 1740{
1237 .read = ts_read, 1741 struct i2c_adapter *i2c = &port->i2c->adap;
1238 .write = ts_write, 1742 int status;
1239 .open = dvb_generic_open, 1743
1240 .release = dvb_generic_release, 1744 status = i2c_write_reg(&port->i2c->adap, 0x6e, 0, 0);
1241 .poll = ts_poll, 1745 if (status)
1746 return 0;
1747 status = i2c_read_reg(i2c, 0x6e, 0xfd, id);
1748 if (status)
1749 return 0;
1750 return 1;
1751}
1752
1753static char *xo2names[] = {
1754 "DUAL DVB-S2", "DUAL DVB-C/T/T2",
1755 "DUAL DVB-ISDBT", "DUAL DVB-C/C2/T/T2",
1756 "DUAL ATSC", "DUAL DVB-C/C2/T/T2,ISDB-T",
1757 "", ""
1242}; 1758};
1243 1759
1244static struct dvb_device dvbdev_ci = { 1760static char *xo2types[] = {
1245 .readers = -1, 1761 "DVBS_ST", "DVBCT2_SONY",
1246 .writers = -1, 1762 "ISDBT_SONY", "DVBC2T2_SONY",
1247 .users = -1, 1763 "ATSC_ST", "DVBC2T2I_SONY"
1248 .fops = &ci_fops,
1249}; 1764};
1250 1765
1766static void ddb_port_probe(struct ddb_port *port)
1767{
1768 struct ddb *dev = port->dev;
1769 u32 l = port->lnr;
1770 u8 id, type;
1771
1772 port->name = "NO MODULE";
1773 port->type_name = "NONE";
1774 port->class = DDB_PORT_NONE;
1775
1776 /* Handle missing ports and ports without I2C */
1777
1778 if (port->nr == ts_loop) {
1779 port->name = "TS LOOP";
1780 port->class = DDB_PORT_LOOP;
1781 return;
1782 }
1783
1784 if (port->nr == 1 && dev->link[l].info->type == DDB_OCTOPUS_CI &&
1785 dev->link[l].info->i2c_mask == 1) {
1786 port->name = "NO TAB";
1787 port->class = DDB_PORT_NONE;
1788 return;
1789 }
1790
1791 if (dev->link[l].info->type == DDB_OCTOPUS_MAX) {
1792 port->name = "DUAL DVB-S2 MAX";
1793 port->type_name = "MXL5XX";
1794 port->class = DDB_PORT_TUNER;
1795 port->type = DDB_TUNER_MXL5XX;
1796 if (port->i2c)
1797 ddbwritel(dev, I2C_SPEED_400,
1798 port->i2c->regs + I2C_TIMING);
1799 return;
1800 }
1801
1802 if (port->nr > 1 && dev->link[l].info->type == DDB_OCTOPUS_CI) {
1803 port->name = "CI internal";
1804 port->type_name = "INTERNAL";
1805 port->class = DDB_PORT_CI;
1806 port->type = DDB_CI_INTERNAL;
1807 }
1808
1809 if (!port->i2c)
1810 return;
1811
1812 /* Probe ports with I2C */
1813
1814 if (port_has_cxd(port, &id)) {
1815 if (id == 1) {
1816 port->name = "CI";
1817 port->type_name = "CXD2099";
1818 port->class = DDB_PORT_CI;
1819 port->type = DDB_CI_EXTERNAL_SONY;
1820 ddbwritel(dev, I2C_SPEED_400,
1821 port->i2c->regs + I2C_TIMING);
1822 } else {
1823 dev_info(dev->dev, "Port %d: Uninitialized DuoFlex\n",
1824 port->nr);
1825 return;
1826 }
1827 } else if (port_has_xo2(port, &type, &id)) {
1828 ddbwritel(dev, I2C_SPEED_400, port->i2c->regs + I2C_TIMING);
1829 /*dev_info(dev->dev, "XO2 ID %02x\n", id);*/
1830 if (type == 2) {
1831 port->name = "DuoFlex CI";
1832 port->class = DDB_PORT_CI;
1833 port->type = DDB_CI_EXTERNAL_XO2;
1834 port->type_name = "CI_XO2";
1835 init_xo2_ci(port);
1836 return;
1837 }
1838 id >>= 2;
1839 if (id > 5) {
1840 port->name = "unknown XO2 DuoFlex";
1841 port->type_name = "UNKNOWN";
1842 } else {
1843 port->name = xo2names[id];
1844 port->class = DDB_PORT_TUNER;
1845 port->type = DDB_TUNER_XO2 + id;
1846 port->type_name = xo2types[id];
1847 init_xo2(port);
1848 }
1849 } else if (port_has_cxd28xx(port, &id)) {
1850 switch (id) {
1851 case 0xa4:
1852 port->name = "DUAL DVB-C2T2 CXD2843";
1853 port->type = DDB_TUNER_DVBC2T2_SONY_P;
1854 port->type_name = "DVBC2T2_SONY";
1855 break;
1856 case 0xb1:
1857 port->name = "DUAL DVB-CT2 CXD2837";
1858 port->type = DDB_TUNER_DVBCT2_SONY_P;
1859 port->type_name = "DVBCT2_SONY";
1860 break;
1861 case 0xb0:
1862 port->name = "DUAL ISDB-T CXD2838";
1863 port->type = DDB_TUNER_ISDBT_SONY_P;
1864 port->type_name = "ISDBT_SONY";
1865 break;
1866 case 0xc1:
1867 port->name = "DUAL DVB-C2T2 ISDB-T CXD2854";
1868 port->type = DDB_TUNER_DVBC2T2I_SONY_P;
1869 port->type_name = "DVBC2T2I_ISDBT_SONY";
1870 break;
1871 default:
1872 return;
1873 }
1874 port->class = DDB_PORT_TUNER;
1875 ddbwritel(dev, I2C_SPEED_400, port->i2c->regs + I2C_TIMING);
1876 } else if (port_has_stv0900(port)) {
1877 port->name = "DUAL DVB-S2";
1878 port->class = DDB_PORT_TUNER;
1879 port->type = DDB_TUNER_DVBS_ST;
1880 port->type_name = "DVBS_ST";
1881 ddbwritel(dev, I2C_SPEED_100, port->i2c->regs + I2C_TIMING);
1882 } else if (port_has_stv0900_aa(port, &id)) {
1883 port->name = "DUAL DVB-S2";
1884 port->class = DDB_PORT_TUNER;
1885 if (id == 0x51) {
1886 if (port->nr == 0 &&
1887 dev->link[l].info->ts_quirks & TS_QUIRK_REVERSED)
1888 port->type = DDB_TUNER_DVBS_STV0910_PR;
1889 else
1890 port->type = DDB_TUNER_DVBS_STV0910_P;
1891 port->type_name = "DVBS_ST_0910";
1892 } else {
1893 port->type = DDB_TUNER_DVBS_ST_AA;
1894 port->type_name = "DVBS_ST_AA";
1895 }
1896 ddbwritel(dev, I2C_SPEED_100, port->i2c->regs + I2C_TIMING);
1897 } else if (port_has_drxks(port)) {
1898 port->name = "DUAL DVB-C/T";
1899 port->class = DDB_PORT_TUNER;
1900 port->type = DDB_TUNER_DVBCT_TR;
1901 port->type_name = "DVBCT_TR";
1902 ddbwritel(dev, I2C_SPEED_400, port->i2c->regs + I2C_TIMING);
1903 } else if (port_has_stv0367(port)) {
1904 port->name = "DUAL DVB-C/T";
1905 port->class = DDB_PORT_TUNER;
1906 port->type = DDB_TUNER_DVBCT_ST;
1907 port->type_name = "DVBCT_ST";
1908 ddbwritel(dev, I2C_SPEED_100, port->i2c->regs + I2C_TIMING);
1909 } else if (port_has_encti(port)) {
1910 port->name = "ENCTI";
1911 port->class = DDB_PORT_LOOP;
1912 }
1913}
1914
1915
1251/****************************************************************************/ 1916/****************************************************************************/
1252/****************************************************************************/ 1917/****************************************************************************/
1253/****************************************************************************/ 1918/****************************************************************************/
1254 1919
1255static void input_tasklet(unsigned long data) 1920static int wait_ci_ready(struct ddb_ci *ci)
1256{ 1921{
1257 struct ddb_input *input = (struct ddb_input *) data; 1922 u32 count = 10;
1258 struct ddb *dev = input->port->dev; 1923
1924 ndelay(500);
1925 do {
1926 if (ddbreadl(ci->port->dev,
1927 CI_CONTROL(ci->nr)) & CI_READY)
1928 break;
1929 usleep_range(1, 2);
1930 if ((--count) == 0)
1931 return -1;
1932 } while (1);
1933 return 0;
1934}
1935
1936static int read_attribute_mem(struct dvb_ca_en50221 *ca,
1937 int slot, int address)
1938{
1939 struct ddb_ci *ci = ca->data;
1940 u32 val, off = (address >> 1) & (CI_BUFFER_SIZE - 1);
1941
1942 if (address > CI_BUFFER_SIZE)
1943 return -1;
1944 ddbwritel(ci->port->dev, CI_READ_CMD | (1 << 16) | address,
1945 CI_DO_READ_ATTRIBUTES(ci->nr));
1946 wait_ci_ready(ci);
1947 val = 0xff & ddbreadl(ci->port->dev, CI_BUFFER(ci->nr) + off);
1948 return val;
1949}
1950
1951static int write_attribute_mem(struct dvb_ca_en50221 *ca, int slot,
1952 int address, u8 value)
1953{
1954 struct ddb_ci *ci = ca->data;
1955
1956 ddbwritel(ci->port->dev, CI_WRITE_CMD | (value << 16) | address,
1957 CI_DO_ATTRIBUTE_RW(ci->nr));
1958 wait_ci_ready(ci);
1959 return 0;
1960}
1259 1961
1260 spin_lock(&input->lock); 1962static int read_cam_control(struct dvb_ca_en50221 *ca,
1261 if (!input->running) { 1963 int slot, u8 address)
1262 spin_unlock(&input->lock); 1964{
1965 u32 count = 100;
1966 struct ddb_ci *ci = ca->data;
1967 u32 res;
1968
1969 ddbwritel(ci->port->dev, CI_READ_CMD | address,
1970 CI_DO_IO_RW(ci->nr));
1971 ndelay(500);
1972 do {
1973 res = ddbreadl(ci->port->dev, CI_READDATA(ci->nr));
1974 if (res & CI_READY)
1975 break;
1976 usleep_range(1, 2);
1977 if ((--count) == 0)
1978 return -1;
1979 } while (1);
1980 return 0xff & res;
1981}
1982
1983static int write_cam_control(struct dvb_ca_en50221 *ca, int slot,
1984 u8 address, u8 value)
1985{
1986 struct ddb_ci *ci = ca->data;
1987
1988 ddbwritel(ci->port->dev, CI_WRITE_CMD | (value << 16) | address,
1989 CI_DO_IO_RW(ci->nr));
1990 wait_ci_ready(ci);
1991 return 0;
1992}
1993
1994static int slot_reset(struct dvb_ca_en50221 *ca, int slot)
1995{
1996 struct ddb_ci *ci = ca->data;
1997
1998 ddbwritel(ci->port->dev, CI_POWER_ON,
1999 CI_CONTROL(ci->nr));
2000 msleep(100);
2001 ddbwritel(ci->port->dev, CI_POWER_ON | CI_RESET_CAM,
2002 CI_CONTROL(ci->nr));
2003 ddbwritel(ci->port->dev, CI_ENABLE | CI_POWER_ON | CI_RESET_CAM,
2004 CI_CONTROL(ci->nr));
2005 udelay(20);
2006 ddbwritel(ci->port->dev, CI_ENABLE | CI_POWER_ON,
2007 CI_CONTROL(ci->nr));
2008 return 0;
2009}
2010
2011static int slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
2012{
2013 struct ddb_ci *ci = ca->data;
2014
2015 ddbwritel(ci->port->dev, 0, CI_CONTROL(ci->nr));
2016 msleep(300);
2017 return 0;
2018}
2019
2020static int slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
2021{
2022 struct ddb_ci *ci = ca->data;
2023 u32 val = ddbreadl(ci->port->dev, CI_CONTROL(ci->nr));
2024
2025 ddbwritel(ci->port->dev, val | CI_BYPASS_DISABLE,
2026 CI_CONTROL(ci->nr));
2027 return 0;
2028}
2029
2030static int poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open)
2031{
2032 struct ddb_ci *ci = ca->data;
2033 u32 val = ddbreadl(ci->port->dev, CI_CONTROL(ci->nr));
2034 int stat = 0;
2035
2036 if (val & CI_CAM_DETECT)
2037 stat |= DVB_CA_EN50221_POLL_CAM_PRESENT;
2038 if (val & CI_CAM_READY)
2039 stat |= DVB_CA_EN50221_POLL_CAM_READY;
2040 return stat;
2041}
2042
2043static struct dvb_ca_en50221 en_templ = {
2044 .read_attribute_mem = read_attribute_mem,
2045 .write_attribute_mem = write_attribute_mem,
2046 .read_cam_control = read_cam_control,
2047 .write_cam_control = write_cam_control,
2048 .slot_reset = slot_reset,
2049 .slot_shutdown = slot_shutdown,
2050 .slot_ts_enable = slot_ts_enable,
2051 .poll_slot_status = poll_slot_status,
2052};
2053
2054static void ci_attach(struct ddb_port *port)
2055{
2056 struct ddb_ci *ci = NULL;
2057
2058 ci = kzalloc(sizeof(*ci), GFP_KERNEL);
2059 if (!ci)
1263 return; 2060 return;
1264 } 2061 memcpy(&ci->en, &en_templ, sizeof(en_templ));
1265 input->stat = ddbreadl(DMA_BUFFER_CURRENT(input->nr)); 2062 ci->en.data = ci;
2063 port->en = &ci->en;
2064 ci->port = port;
2065 ci->nr = port->nr - 2;
2066}
2067
2068/****************************************************************************/
2069/****************************************************************************/
2070/****************************************************************************/
1266 2071
1267 if (input->port->class == DDB_PORT_TUNER) { 2072static int write_creg(struct ddb_ci *ci, u8 data, u8 mask)
1268 if (4&ddbreadl(DMA_BUFFER_CONTROL(input->nr))) 2073{
1269 dev_err(&dev->pdev->dev, "Overflow input %d\n", input->nr); 2074 struct i2c_adapter *i2c = &ci->port->i2c->adap;
1270 while (input->cbuf != ((input->stat >> 11) & 0x1f) 2075 u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13;
1271 || (4 & safe_ddbreadl(dev, DMA_BUFFER_CONTROL(input->nr)))) {
1272 dvb_dmx_swfilter_packets(&input->demux,
1273 input->vbuf[input->cbuf],
1274 input->dma_buf_size / 188);
1275 2076
1276 input->cbuf = (input->cbuf + 1) % input->dma_buf_num; 2077 ci->port->creg = (ci->port->creg & ~mask) | data;
1277 ddbwritel((input->cbuf << 11), 2078 return i2c_write_reg(i2c, adr, 0x02, ci->port->creg);
1278 DMA_BUFFER_ACK(input->nr));
1279 input->stat = ddbreadl(DMA_BUFFER_CURRENT(input->nr));
1280 }
1281 }
1282 if (input->port->class == DDB_PORT_CI)
1283 wake_up(&input->wq);
1284 spin_unlock(&input->lock);
1285} 2079}
1286 2080
1287static void output_tasklet(unsigned long data) 2081static int read_attribute_mem_xo2(struct dvb_ca_en50221 *ca,
2082 int slot, int address)
1288{ 2083{
1289 struct ddb_output *output = (struct ddb_output *) data; 2084 struct ddb_ci *ci = ca->data;
1290 struct ddb *dev = output->port->dev; 2085 struct i2c_adapter *i2c = &ci->port->i2c->adap;
2086 u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13;
2087 int res;
2088 u8 val;
1291 2089
1292 spin_lock(&output->lock); 2090 res = i2c_read_reg16(i2c, adr, 0x8000 | address, &val);
1293 if (!output->running) { 2091 return res ? res : val;
1294 spin_unlock(&output->lock); 2092}
2093
2094static int write_attribute_mem_xo2(struct dvb_ca_en50221 *ca, int slot,
2095 int address, u8 value)
2096{
2097 struct ddb_ci *ci = ca->data;
2098 struct i2c_adapter *i2c = &ci->port->i2c->adap;
2099 u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13;
2100
2101 return i2c_write_reg16(i2c, adr, 0x8000 | address, value);
2102}
2103
2104static int read_cam_control_xo2(struct dvb_ca_en50221 *ca,
2105 int slot, u8 address)
2106{
2107 struct ddb_ci *ci = ca->data;
2108 struct i2c_adapter *i2c = &ci->port->i2c->adap;
2109 u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13;
2110 u8 val;
2111 int res;
2112
2113 res = i2c_read_reg(i2c, adr, 0x20 | (address & 3), &val);
2114 return res ? res : val;
2115}
2116
2117static int write_cam_control_xo2(struct dvb_ca_en50221 *ca, int slot,
2118 u8 address, u8 value)
2119{
2120 struct ddb_ci *ci = ca->data;
2121 struct i2c_adapter *i2c = &ci->port->i2c->adap;
2122 u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13;
2123
2124 return i2c_write_reg(i2c, adr, 0x20 | (address & 3), value);
2125}
2126
2127static int slot_reset_xo2(struct dvb_ca_en50221 *ca, int slot)
2128{
2129 struct ddb_ci *ci = ca->data;
2130
2131 dev_dbg(ci->port->dev->dev, "%s\n", __func__);
2132 write_creg(ci, 0x01, 0x01);
2133 write_creg(ci, 0x04, 0x04);
2134 msleep(20);
2135 write_creg(ci, 0x02, 0x02);
2136 write_creg(ci, 0x00, 0x04);
2137 write_creg(ci, 0x18, 0x18);
2138 return 0;
2139}
2140
2141static int slot_shutdown_xo2(struct dvb_ca_en50221 *ca, int slot)
2142{
2143 struct ddb_ci *ci = ca->data;
2144
2145 dev_dbg(ci->port->dev->dev, "%s\n", __func__);
2146 write_creg(ci, 0x10, 0xff);
2147 write_creg(ci, 0x08, 0x08);
2148 return 0;
2149}
2150
2151static int slot_ts_enable_xo2(struct dvb_ca_en50221 *ca, int slot)
2152{
2153 struct ddb_ci *ci = ca->data;
2154
2155 dev_info(ci->port->dev->dev, "%s\n", __func__);
2156 write_creg(ci, 0x00, 0x10);
2157 return 0;
2158}
2159
2160static int poll_slot_status_xo2(struct dvb_ca_en50221 *ca, int slot, int open)
2161{
2162 struct ddb_ci *ci = ca->data;
2163 struct i2c_adapter *i2c = &ci->port->i2c->adap;
2164 u8 adr = (ci->port->type == DDB_CI_EXTERNAL_XO2) ? 0x12 : 0x13;
2165 u8 val = 0;
2166 int stat = 0;
2167
2168 i2c_read_reg(i2c, adr, 0x01, &val);
2169
2170 if (val & 2)
2171 stat |= DVB_CA_EN50221_POLL_CAM_PRESENT;
2172 if (val & 1)
2173 stat |= DVB_CA_EN50221_POLL_CAM_READY;
2174 return stat;
2175}
2176
2177static struct dvb_ca_en50221 en_xo2_templ = {
2178 .read_attribute_mem = read_attribute_mem_xo2,
2179 .write_attribute_mem = write_attribute_mem_xo2,
2180 .read_cam_control = read_cam_control_xo2,
2181 .write_cam_control = write_cam_control_xo2,
2182 .slot_reset = slot_reset_xo2,
2183 .slot_shutdown = slot_shutdown_xo2,
2184 .slot_ts_enable = slot_ts_enable_xo2,
2185 .poll_slot_status = poll_slot_status_xo2,
2186};
2187
2188static void ci_xo2_attach(struct ddb_port *port)
2189{
2190 struct ddb_ci *ci;
2191
2192 ci = kzalloc(sizeof(*ci), GFP_KERNEL);
2193 if (!ci)
1295 return; 2194 return;
1296 } 2195 memcpy(&ci->en, &en_xo2_templ, sizeof(en_xo2_templ));
1297 output->stat = ddbreadl(DMA_BUFFER_CURRENT(output->nr + 8)); 2196 ci->en.data = ci;
1298 wake_up(&output->wq); 2197 port->en = &ci->en;
1299 spin_unlock(&output->lock); 2198 ci->port = port;
2199 ci->nr = port->nr - 2;
2200 ci->port->creg = 0;
2201 write_creg(ci, 0x10, 0xff);
2202 write_creg(ci, 0x08, 0x08);
1300} 2203}
1301 2204
2205/****************************************************************************/
2206/****************************************************************************/
2207/****************************************************************************/
1302 2208
1303static struct cxd2099_cfg cxd_cfg = { 2209static struct cxd2099_cfg cxd_cfg = {
1304 .bitrate = 62000, 2210 .bitrate = 72000,
1305 .adr = 0x40, 2211 .adr = 0x40,
1306 .polarity = 1, 2212 .polarity = 1,
1307 .clock_mode = 1, 2213 .clock_mode = 1,
@@ -1310,33 +2216,36 @@ static struct cxd2099_cfg cxd_cfg = {
1310 2216
1311static int ddb_ci_attach(struct ddb_port *port) 2217static int ddb_ci_attach(struct ddb_port *port)
1312{ 2218{
1313 int ret; 2219 switch (port->type) {
2220 case DDB_CI_EXTERNAL_SONY:
2221 cxd_cfg.bitrate = ci_bitrate;
2222 port->en = cxd2099_attach(&cxd_cfg, port, &port->i2c->adap);
2223 if (!port->en)
2224 return -ENODEV;
2225 dvb_ca_en50221_init(port->dvb[0].adap,
2226 port->en, 0, 1);
2227 break;
1314 2228
1315 ret = dvb_register_adapter(&port->output->adap, 2229 case DDB_CI_EXTERNAL_XO2:
1316 "DDBridge", 2230 case DDB_CI_EXTERNAL_XO2_B:
1317 THIS_MODULE, 2231 ci_xo2_attach(port);
1318 &port->dev->pdev->dev, 2232 if (!port->en)
1319 adapter_nr); 2233 return -ENODEV;
1320 if (ret < 0) 2234 dvb_ca_en50221_init(port->dvb[0].adap, port->en, 0, 1);
1321 return ret; 2235 break;
1322 port->en = cxd2099_attach(&cxd_cfg, port, &port->i2c->adap); 2236
1323 if (!port->en) { 2237 case DDB_CI_INTERNAL:
1324 dvb_unregister_adapter(&port->output->adap); 2238 ci_attach(port);
1325 return -ENODEV; 2239 if (!port->en)
2240 return -ENODEV;
2241 dvb_ca_en50221_init(port->dvb[0].adap, port->en, 0, 1);
2242 break;
1326 } 2243 }
1327 ddb_input_start(port->input[0]); 2244 return 0;
1328 ddb_output_start(port->output);
1329 dvb_ca_en50221_init(&port->output->adap,
1330 port->en, 0, 1);
1331 ret = dvb_register_device(&port->output->adap, &port->output->dev,
1332 &dvbdev_ci, (void *) port->output,
1333 DVB_DEVICE_SEC, 0);
1334 return ret;
1335} 2245}
1336 2246
1337static int ddb_port_attach(struct ddb_port *port) 2247static int ddb_port_attach(struct ddb_port *port)
1338{ 2248{
1339 struct device *dev = &port->dev->pdev->dev;
1340 int ret = 0; 2249 int ret = 0;
1341 2250
1342 switch (port->class) { 2251 switch (port->class) {
@@ -1345,371 +2254,429 @@ static int ddb_port_attach(struct ddb_port *port)
1345 if (ret < 0) 2254 if (ret < 0)
1346 break; 2255 break;
1347 ret = dvb_input_attach(port->input[1]); 2256 ret = dvb_input_attach(port->input[1]);
2257 if (ret < 0)
2258 break;
2259 port->input[0]->redi = port->input[0];
2260 port->input[1]->redi = port->input[1];
1348 break; 2261 break;
1349 case DDB_PORT_CI: 2262 case DDB_PORT_CI:
1350 ret = ddb_ci_attach(port); 2263 ret = ddb_ci_attach(port);
2264 if (ret < 0)
2265 break;
2266 /* fall-through */
2267 case DDB_PORT_LOOP:
2268 ret = dvb_register_device(port->dvb[0].adap,
2269 &port->dvb[0].dev,
2270 &dvbdev_ci, (void *) port->output,
2271 DVB_DEVICE_SEC, 0);
1351 break; 2272 break;
1352 default: 2273 default:
1353 break; 2274 break;
1354 } 2275 }
1355 if (ret < 0) 2276 if (ret < 0)
1356 dev_err(dev, "port_attach on port %d failed\n", port->nr); 2277 dev_err(port->dev->dev, "port_attach on port %d failed\n",
2278 port->nr);
1357 return ret; 2279 return ret;
1358} 2280}
1359 2281
1360static int ddb_ports_attach(struct ddb *dev) 2282int ddb_ports_attach(struct ddb *dev)
1361{ 2283{
1362 int i, ret = 0; 2284 int i, ret = 0;
1363 struct ddb_port *port; 2285 struct ddb_port *port;
1364 2286
1365 for (i = 0; i < dev->info->port_num; i++) { 2287 if (dev->port_num) {
2288 ret = dvb_register_adapters(dev);
2289 if (ret < 0) {
2290 dev_err(dev->dev, "Registering adapters failed. Check DVB_MAX_ADAPTERS in config.\n");
2291 return ret;
2292 }
2293 }
2294 for (i = 0; i < dev->port_num; i++) {
1366 port = &dev->port[i]; 2295 port = &dev->port[i];
1367 ret = ddb_port_attach(port); 2296 ret = ddb_port_attach(port);
1368 if (ret < 0)
1369 break;
1370 } 2297 }
1371 return ret; 2298 return ret;
1372} 2299}
1373 2300
1374static void ddb_ports_detach(struct ddb *dev) 2301void ddb_ports_detach(struct ddb *dev)
1375{ 2302{
1376 int i; 2303 int i;
1377 struct ddb_port *port; 2304 struct ddb_port *port;
1378 2305
1379 for (i = 0; i < dev->info->port_num; i++) { 2306 for (i = 0; i < dev->port_num; i++) {
1380 port = &dev->port[i]; 2307 port = &dev->port[i];
2308
1381 switch (port->class) { 2309 switch (port->class) {
1382 case DDB_PORT_TUNER: 2310 case DDB_PORT_TUNER:
1383 dvb_input_detach(port->input[0]); 2311 dvb_input_detach(port->input[0]);
1384 dvb_input_detach(port->input[1]); 2312 dvb_input_detach(port->input[1]);
1385 break; 2313 break;
1386 case DDB_PORT_CI: 2314 case DDB_PORT_CI:
1387 dvb_unregister_device(port->output->dev); 2315 case DDB_PORT_LOOP:
2316 if (port->dvb[0].dev)
2317 dvb_unregister_device(port->dvb[0].dev);
1388 if (port->en) { 2318 if (port->en) {
1389 ddb_input_stop(port->input[0]);
1390 ddb_output_stop(port->output);
1391 dvb_ca_en50221_release(port->en); 2319 dvb_ca_en50221_release(port->en);
1392 kfree(port->en); 2320 kfree(port->en);
1393 port->en = NULL; 2321 port->en = NULL;
1394 dvb_unregister_adapter(&port->output->adap);
1395 } 2322 }
1396 break; 2323 break;
1397 } 2324 }
1398 } 2325 }
2326 dvb_unregister_adapters(dev);
1399} 2327}
1400 2328
1401/****************************************************************************/
1402/****************************************************************************/
1403 2329
1404static int init_xo2(struct ddb_port *port) 2330/* Copy input DMA pointers to output DMA and ACK. */
2331
2332static void input_write_output(struct ddb_input *input,
2333 struct ddb_output *output)
1405{ 2334{
1406 struct i2c_adapter *i2c = &port->i2c->adap; 2335 ddbwritel(output->port->dev,
1407 struct device *dev = &port->dev->pdev->dev; 2336 input->dma->stat, DMA_BUFFER_ACK(output->dma));
1408 u8 val, data[2]; 2337 output->dma->cbuf = (input->dma->stat >> 11) & 0x1f;
1409 int res; 2338 output->dma->coff = (input->dma->stat & 0x7ff) << 7;
2339}
1410 2340
1411 res = i2c_read_regs(i2c, 0x10, 0x04, data, 2); 2341static void output_ack_input(struct ddb_output *output,
1412 if (res < 0) 2342 struct ddb_input *input)
1413 return res; 2343{
2344 ddbwritel(input->port->dev,
2345 output->dma->stat, DMA_BUFFER_ACK(input->dma));
2346}
1414 2347
1415 if (data[0] != 0x01) { 2348static void input_write_dvb(struct ddb_input *input,
1416 dev_info(dev, "Port %d: invalid XO2\n", port->nr); 2349 struct ddb_input *input2)
1417 return -1; 2350{
2351 struct ddb_dvb *dvb = &input2->port->dvb[input2->nr & 1];
2352 struct ddb_dma *dma, *dma2;
2353 struct ddb *dev = input->port->dev;
2354 int ack = 1;
2355
2356 dma = dma2 = input->dma;
2357 /* if there also is an output connected, do not ACK.
2358 * input_write_output will ACK.
2359 */
2360 if (input->redo) {
2361 dma2 = input->redo->dma;
2362 ack = 0;
2363 }
2364 while (dma->cbuf != ((dma->stat >> 11) & 0x1f)
2365 || (4 & dma->ctrl)) {
2366 if (4 & dma->ctrl) {
2367 /* dev_err(dev->dev, "Overflow dma %d\n", dma->nr); */
2368 ack = 1;
2369 }
2370 if (alt_dma)
2371 dma_sync_single_for_cpu(dev->dev, dma2->pbuf[dma->cbuf],
2372 dma2->size, DMA_FROM_DEVICE);
2373 dvb_dmx_swfilter_packets(&dvb->demux,
2374 dma2->vbuf[dma->cbuf],
2375 dma2->size / 188);
2376 dma->cbuf = (dma->cbuf + 1) % dma2->num;
2377 if (ack)
2378 ddbwritel(dev, (dma->cbuf << 11),
2379 DMA_BUFFER_ACK(dma));
2380 dma->stat = safe_ddbreadl(dev, DMA_BUFFER_CURRENT(dma));
2381 dma->ctrl = safe_ddbreadl(dev, DMA_BUFFER_CONTROL(dma));
1418 } 2382 }
2383}
1419 2384
1420 i2c_read_reg(i2c, 0x10, 0x08, &val); 2385static void input_work(struct work_struct *work)
1421 if (val != 0) { 2386{
1422 i2c_write_reg(i2c, 0x10, 0x08, 0x00); 2387 struct ddb_dma *dma = container_of(work, struct ddb_dma, work);
1423 msleep(100); 2388 struct ddb_input *input = (struct ddb_input *) dma->io;
2389 struct ddb *dev = input->port->dev;
2390 unsigned long flags;
2391
2392 spin_lock_irqsave(&dma->lock, flags);
2393 if (!dma->running) {
2394 spin_unlock_irqrestore(&dma->lock, flags);
2395 return;
1424 } 2396 }
1425 /* Enable tuner power, disable pll, reset demods */ 2397 dma->stat = ddbreadl(dev, DMA_BUFFER_CURRENT(dma));
1426 i2c_write_reg(i2c, 0x10, 0x08, 0x04); 2398 dma->ctrl = ddbreadl(dev, DMA_BUFFER_CONTROL(dma));
1427 usleep_range(2000, 3000);
1428 /* Release demod resets */
1429 i2c_write_reg(i2c, 0x10, 0x08, 0x07);
1430 2399
1431 /* speed: 0=55,1=75,2=90,3=104 MBit/s */ 2400 if (input->redi)
1432 i2c_write_reg(i2c, 0x10, 0x09, 2401 input_write_dvb(input, input->redi);
1433 ((xo2_speed >= 0 && xo2_speed <= 3) ? xo2_speed : 2)); 2402 if (input->redo)
2403 input_write_output(input, input->redo);
2404 wake_up(&dma->wq);
2405 spin_unlock_irqrestore(&dma->lock, flags);
2406}
1434 2407
1435 i2c_write_reg(i2c, 0x10, 0x0a, 0x01); 2408static void input_handler(unsigned long data)
1436 i2c_write_reg(i2c, 0x10, 0x0b, 0x01); 2409{
2410 struct ddb_input *input = (struct ddb_input *) data;
2411 struct ddb_dma *dma = input->dma;
1437 2412
1438 usleep_range(2000, 3000);
1439 /* Start XO2 PLL */
1440 i2c_write_reg(i2c, 0x10, 0x08, 0x87);
1441 2413
1442 return 0; 2414 /* If there is no input connected, input_tasklet() will
2415 * just copy pointers and ACK. So, there is no need to go
2416 * through the tasklet scheduler.
2417 */
2418 if (input->redi)
2419 queue_work(ddb_wq, &dma->work);
2420 else
2421 input_work(&dma->work);
1443} 2422}
1444 2423
1445static int port_has_xo2(struct ddb_port *port, u8 *type, u8 *id) 2424static void output_handler(unsigned long data)
1446{ 2425{
1447 u8 probe[1] = { 0x00 }, data[4]; 2426 struct ddb_output *output = (struct ddb_output *) data;
1448 2427 struct ddb_dma *dma = output->dma;
1449 *type = DDB_XO2_TYPE_NONE; 2428 struct ddb *dev = output->port->dev;
1450 2429
1451 if (i2c_io(&port->i2c->adap, 0x10, probe, 1, data, 4)) 2430 spin_lock(&dma->lock);
1452 return 0; 2431 if (!dma->running) {
1453 if (data[0] == 'D' && data[1] == 'F') { 2432 spin_unlock(&dma->lock);
1454 *id = data[2]; 2433 return;
1455 *type = DDB_XO2_TYPE_DUOFLEX;
1456 return 1;
1457 }
1458 if (data[0] == 'C' && data[1] == 'I') {
1459 *id = data[2];
1460 *type = DDB_XO2_TYPE_CI;
1461 return 1;
1462 } 2434 }
1463 return 0; 2435 dma->stat = ddbreadl(dev, DMA_BUFFER_CURRENT(dma));
2436 dma->ctrl = ddbreadl(dev, DMA_BUFFER_CONTROL(dma));
2437 if (output->redi)
2438 output_ack_input(output, output->redi);
2439 wake_up(&dma->wq);
2440 spin_unlock(&dma->lock);
1464} 2441}
1465 2442
1466/****************************************************************************/ 2443/****************************************************************************/
1467/****************************************************************************/ 2444/****************************************************************************/
1468 2445
1469static int port_has_ci(struct ddb_port *port) 2446static const struct ddb_regmap *io_regmap(struct ddb_io *io, int link)
1470{ 2447{
1471 u8 val; 2448 const struct ddb_info *info;
1472 return i2c_read_reg(&port->i2c->adap, 0x40, 0, &val) ? 0 : 1;
1473}
1474 2449
1475static int port_has_stv0900(struct ddb_port *port) 2450 if (link)
1476{ 2451 info = io->port->dev->link[io->port->lnr].info;
1477 u8 val; 2452 else
1478 if (i2c_read_reg16(&port->i2c->adap, 0x69, 0xf100, &val) < 0) 2453 info = io->port->dev->link[0].info;
1479 return 0;
1480 return 1;
1481}
1482 2454
1483static int port_has_stv0900_aa(struct ddb_port *port) 2455 if (!info)
1484{ 2456 return NULL;
1485 u8 val;
1486 if (i2c_read_reg16(&port->i2c->adap, 0x68, 0xf100, &val) < 0)
1487 return 0;
1488 return 1;
1489}
1490 2457
1491static int port_has_drxks(struct ddb_port *port) 2458 return info->regmap;
1492{
1493 u8 val;
1494 if (i2c_read(&port->i2c->adap, 0x29, &val) < 0)
1495 return 0;
1496 if (i2c_read(&port->i2c->adap, 0x2a, &val) < 0)
1497 return 0;
1498 return 1;
1499} 2459}
1500 2460
1501static int port_has_stv0367(struct ddb_port *port) 2461static void ddb_dma_init(struct ddb_io *io, int nr, int out)
1502{ 2462{
1503 u8 val; 2463 struct ddb_dma *dma;
1504 if (i2c_read_reg16(&port->i2c->adap, 0x1e, 0xf000, &val) < 0) 2464 const struct ddb_regmap *rm = io_regmap(io, 0);
1505 return 0; 2465
1506 if (val != 0x60) 2466 dma = out ? &io->port->dev->odma[nr] : &io->port->dev->idma[nr];
1507 return 0; 2467 io->dma = dma;
1508 if (i2c_read_reg16(&port->i2c->adap, 0x1f, 0xf000, &val) < 0) 2468 dma->io = io;
1509 return 0; 2469
1510 if (val != 0x60) 2470 spin_lock_init(&dma->lock);
1511 return 0; 2471 init_waitqueue_head(&dma->wq);
1512 return 1; 2472 if (out) {
2473 dma->regs = rm->odma->base + rm->odma->size * nr;
2474 dma->bufregs = rm->odma_buf->base + rm->odma_buf->size * nr;
2475 dma->num = OUTPUT_DMA_BUFS;
2476 dma->size = OUTPUT_DMA_SIZE;
2477 dma->div = OUTPUT_DMA_IRQ_DIV;
2478 } else {
2479 INIT_WORK(&dma->work, input_work);
2480 dma->regs = rm->idma->base + rm->idma->size * nr;
2481 dma->bufregs = rm->idma_buf->base + rm->idma_buf->size * nr;
2482 dma->num = INPUT_DMA_BUFS;
2483 dma->size = INPUT_DMA_SIZE;
2484 dma->div = INPUT_DMA_IRQ_DIV;
2485 }
2486 ddbwritel(io->port->dev, 0, DMA_BUFFER_ACK(dma));
2487 dev_dbg(io->port->dev->dev, "init link %u, io %u, dma %u, dmaregs %08x bufregs %08x\n",
2488 io->port->lnr, io->nr, nr, dma->regs, dma->bufregs);
1513} 2489}
1514 2490
1515static int port_has_cxd28xx(struct ddb_port *port, u8 *id) 2491static void ddb_input_init(struct ddb_port *port, int nr, int pnr, int anr)
1516{ 2492{
1517 struct i2c_adapter *i2c = &port->i2c->adap; 2493 struct ddb *dev = port->dev;
1518 int status; 2494 struct ddb_input *input = &dev->input[anr];
2495 const struct ddb_regmap *rm;
1519 2496
1520 status = i2c_write_reg(&port->i2c->adap, 0x6e, 0, 0); 2497 port->input[pnr] = input;
1521 if (status) 2498 input->nr = nr;
1522 return 0; 2499 input->port = port;
1523 status = i2c_read_reg(i2c, 0x6e, 0xfd, id); 2500 rm = io_regmap(input, 1);
1524 if (status) 2501 input->regs = DDB_LINK_TAG(port->lnr) |
1525 return 0; 2502 (rm->input->base + rm->input->size * nr);
1526 return 1; 2503 dev_dbg(dev->dev, "init link %u, input %u, regs %08x\n",
2504 port->lnr, nr, input->regs);
2505
2506 if (dev->has_dma) {
2507 const struct ddb_regmap *rm0 = io_regmap(input, 0);
2508 u32 base = rm0->irq_base_idma;
2509 u32 dma_nr = nr;
2510
2511 if (port->lnr)
2512 dma_nr += 32 + (port->lnr - 1) * 8;
2513
2514 dev_dbg(dev->dev, "init link %u, input %u, handler %u\n",
2515 port->lnr, nr, dma_nr + base);
2516
2517 dev->handler[0][dma_nr + base] = input_handler;
2518 dev->handler_data[0][dma_nr + base] = (unsigned long) input;
2519 ddb_dma_init(input, dma_nr, 0);
2520 }
1527} 2521}
1528 2522
1529static void ddb_port_probe(struct ddb_port *port) 2523static void ddb_output_init(struct ddb_port *port, int nr)
1530{ 2524{
1531 struct ddb *dev = port->dev; 2525 struct ddb *dev = port->dev;
1532 char *modname = "NO MODULE"; 2526 struct ddb_output *output = &dev->output[nr];
1533 u8 xo2_type, xo2_id, cxd_id; 2527 const struct ddb_regmap *rm;
1534 2528
1535 port->class = DDB_PORT_NONE; 2529 port->output = output;
2530 output->nr = nr;
2531 output->port = port;
2532 rm = io_regmap(output, 1);
2533 output->regs = DDB_LINK_TAG(port->lnr) |
2534 (rm->output->base + rm->output->size * nr);
1536 2535
1537 if (port_has_ci(port)) { 2536 dev_dbg(dev->dev, "init link %u, output %u, regs %08x\n",
1538 modname = "CI"; 2537 port->lnr, nr, output->regs);
1539 port->class = DDB_PORT_CI;
1540 ddbwritel(I2C_SPEED_400, port->i2c->regs + I2C_TIMING);
1541 } else if (port_has_xo2(port, &xo2_type, &xo2_id)) {
1542 dev_dbg(&dev->pdev->dev, "Port %d (TAB %d): XO2 type: %d, id: %d\n",
1543 port->nr, port->nr+1, xo2_type, xo2_id);
1544 2538
1545 ddbwritel(I2C_SPEED_400, port->i2c->regs + I2C_TIMING); 2539 if (dev->has_dma) {
2540 const struct ddb_regmap *rm0 = io_regmap(output, 0);
2541 u32 base = rm0->irq_base_odma;
1546 2542
1547 switch (xo2_type) { 2543 dev->handler[0][nr + base] = output_handler;
1548 case DDB_XO2_TYPE_DUOFLEX: 2544 dev->handler_data[0][nr + base] = (unsigned long) output;
1549 init_xo2(port); 2545 ddb_dma_init(output, nr, 1);
1550 switch (xo2_id >> 2) {
1551 case 0:
1552 modname = "DUAL DVB-S2 (unsupported)";
1553 port->class = DDB_PORT_NONE;
1554 port->type = DDB_TUNER_XO2_DVBS_STV0910;
1555 break;
1556 case 1:
1557 modname = "DUAL DVB-C/T/T2";
1558 port->class = DDB_PORT_TUNER;
1559 port->type = DDB_TUNER_XO2_DVBCT2_SONY;
1560 break;
1561 case 2:
1562 modname = "DUAL DVB-ISDBT";
1563 port->class = DDB_PORT_TUNER;
1564 port->type = DDB_TUNER_XO2_ISDBT_SONY;
1565 break;
1566 case 3:
1567 modname = "DUAL DVB-C/C2/T/T2";
1568 port->class = DDB_PORT_TUNER;
1569 port->type = DDB_TUNER_XO2_DVBC2T2_SONY;
1570 break;
1571 case 4:
1572 modname = "DUAL ATSC (unsupported)";
1573 port->class = DDB_PORT_NONE;
1574 port->type = DDB_TUNER_XO2_ATSC_ST;
1575 break;
1576 case 5:
1577 modname = "DUAL DVB-C/C2/T/T2/ISDBT";
1578 port->class = DDB_PORT_TUNER;
1579 port->type = DDB_TUNER_XO2_DVBC2T2I_SONY;
1580 break;
1581 default:
1582 modname = "Unknown XO2 DuoFlex module\n";
1583 break;
1584 }
1585 break;
1586 case DDB_XO2_TYPE_CI:
1587 dev_info(&dev->pdev->dev, "DuoFlex CI modules not supported\n");
1588 break;
1589 default:
1590 dev_info(&dev->pdev->dev, "Unknown XO2 DuoFlex module\n");
1591 break;
1592 }
1593 } else if (port_has_cxd28xx(port, &cxd_id)) {
1594 switch (cxd_id) {
1595 case 0xa4:
1596 modname = "DUAL DVB-C2T2 CXD2843";
1597 port->class = DDB_PORT_TUNER;
1598 port->type = DDB_TUNER_DVBC2T2_SONY_P;
1599 break;
1600 case 0xb1:
1601 modname = "DUAL DVB-CT2 CXD2837";
1602 port->class = DDB_PORT_TUNER;
1603 port->type = DDB_TUNER_DVBCT2_SONY_P;
1604 break;
1605 case 0xb0:
1606 modname = "DUAL ISDB-T CXD2838";
1607 port->class = DDB_PORT_TUNER;
1608 port->type = DDB_TUNER_ISDBT_SONY_P;
1609 break;
1610 case 0xc1:
1611 modname = "DUAL DVB-C2T2 ISDB-T CXD2854";
1612 port->class = DDB_PORT_TUNER;
1613 port->type = DDB_TUNER_DVBC2T2I_SONY_P;
1614 break;
1615 default:
1616 modname = "Unknown CXD28xx tuner";
1617 break;
1618 }
1619 ddbwritel(I2C_SPEED_400, port->i2c->regs + I2C_TIMING);
1620 } else if (port_has_stv0900(port)) {
1621 modname = "DUAL DVB-S2";
1622 port->class = DDB_PORT_TUNER;
1623 port->type = DDB_TUNER_DVBS_ST;
1624 ddbwritel(I2C_SPEED_100, port->i2c->regs + I2C_TIMING);
1625 } else if (port_has_stv0900_aa(port)) {
1626 modname = "DUAL DVB-S2";
1627 port->class = DDB_PORT_TUNER;
1628 port->type = DDB_TUNER_DVBS_ST_AA;
1629 ddbwritel(I2C_SPEED_100, port->i2c->regs + I2C_TIMING);
1630 } else if (port_has_drxks(port)) {
1631 modname = "DUAL DVB-C/T";
1632 port->class = DDB_PORT_TUNER;
1633 port->type = DDB_TUNER_DVBCT_TR;
1634 ddbwritel(I2C_SPEED_400, port->i2c->regs + I2C_TIMING);
1635 } else if (port_has_stv0367(port)) {
1636 modname = "DUAL DVB-C/T";
1637 port->class = DDB_PORT_TUNER;
1638 port->type = DDB_TUNER_DVBCT_ST;
1639 ddbwritel(I2C_SPEED_100, port->i2c->regs + I2C_TIMING);
1640 } 2546 }
1641
1642 dev_info(&dev->pdev->dev, "Port %d (TAB %d): %s\n",
1643 port->nr, port->nr+1, modname);
1644} 2547}
1645 2548
1646static void ddb_input_init(struct ddb_port *port, int nr) 2549static int ddb_port_match_i2c(struct ddb_port *port)
1647{ 2550{
1648 struct ddb *dev = port->dev; 2551 struct ddb *dev = port->dev;
1649 struct ddb_input *input = &dev->input[nr]; 2552 u32 i;
1650 2553
1651 input->nr = nr; 2554 for (i = 0; i < dev->i2c_num; i++) {
1652 input->port = port; 2555 if (dev->i2c[i].link == port->lnr &&
1653 input->dma_buf_num = INPUT_DMA_BUFS; 2556 dev->i2c[i].nr == port->nr) {
1654 input->dma_buf_size = INPUT_DMA_SIZE; 2557 port->i2c = &dev->i2c[i];
1655 ddbwritel(0, TS_INPUT_CONTROL(nr)); 2558 return 1;
1656 ddbwritel(2, TS_INPUT_CONTROL(nr)); 2559 }
1657 ddbwritel(0, TS_INPUT_CONTROL(nr)); 2560 }
1658 ddbwritel(0, DMA_BUFFER_ACK(nr)); 2561 return 0;
1659 tasklet_init(&input->tasklet, input_tasklet, (unsigned long) input);
1660 spin_lock_init(&input->lock);
1661 init_waitqueue_head(&input->wq);
1662} 2562}
1663 2563
1664static void ddb_output_init(struct ddb_port *port, int nr) 2564static int ddb_port_match_link_i2c(struct ddb_port *port)
1665{ 2565{
1666 struct ddb *dev = port->dev; 2566 struct ddb *dev = port->dev;
1667 struct ddb_output *output = &dev->output[nr]; 2567 u32 i;
1668 output->nr = nr;
1669 output->port = port;
1670 output->dma_buf_num = OUTPUT_DMA_BUFS;
1671 output->dma_buf_size = OUTPUT_DMA_SIZE;
1672 2568
1673 ddbwritel(0, TS_OUTPUT_CONTROL(nr)); 2569 for (i = 0; i < dev->i2c_num; i++) {
1674 ddbwritel(2, TS_OUTPUT_CONTROL(nr)); 2570 if (dev->i2c[i].link == port->lnr) {
1675 ddbwritel(0, TS_OUTPUT_CONTROL(nr)); 2571 port->i2c = &dev->i2c[i];
1676 tasklet_init(&output->tasklet, output_tasklet, (unsigned long) output); 2572 return 1;
1677 init_waitqueue_head(&output->wq); 2573 }
2574 }
2575 return 0;
1678} 2576}
1679 2577
1680static void ddb_ports_init(struct ddb *dev) 2578void ddb_ports_init(struct ddb *dev)
1681{ 2579{
1682 int i; 2580 u32 i, l, p;
1683 struct ddb_port *port; 2581 struct ddb_port *port;
2582 const struct ddb_info *info;
2583 const struct ddb_regmap *rm;
2584
2585 for (p = l = 0; l < DDB_MAX_LINK; l++) {
2586 info = dev->link[l].info;
2587 if (!info)
2588 continue;
2589 rm = info->regmap;
2590 if (!rm)
2591 continue;
2592 for (i = 0; i < info->port_num; i++, p++) {
2593 port = &dev->port[p];
2594 port->dev = dev;
2595 port->nr = i;
2596 port->lnr = l;
2597 port->pnr = p;
2598 port->gap = 0xffffffff;
2599 port->obr = ci_bitrate;
2600 mutex_init(&port->i2c_gate_lock);
2601
2602 if (!ddb_port_match_i2c(port)) {
2603 if (info->type == DDB_OCTOPUS_MAX)
2604 ddb_port_match_link_i2c(port);
2605 }
1684 2606
1685 for (i = 0; i < dev->info->port_num; i++) { 2607 ddb_port_probe(port);
1686 port = &dev->port[i]; 2608
1687 port->dev = dev; 2609 port->dvb[0].adap = &dev->adap[2 * p];
1688 port->nr = i; 2610 port->dvb[1].adap = &dev->adap[2 * p + 1];
1689 port->i2c = &dev->i2c[i]; 2611
1690 port->input[0] = &dev->input[2 * i]; 2612 if ((port->class == DDB_PORT_NONE) && i && p &&
1691 port->input[1] = &dev->input[2 * i + 1]; 2613 dev->port[p - 1].type == DDB_CI_EXTERNAL_XO2) {
1692 port->output = &dev->output[i]; 2614 port->class = DDB_PORT_CI;
2615 port->type = DDB_CI_EXTERNAL_XO2_B;
2616 port->name = "DuoFlex CI_B";
2617 port->i2c = dev->port[p - 1].i2c;
2618 }
2619
2620 dev_info(dev->dev, "Port %u: Link %u, Link Port %u (TAB %u): %s\n",
2621 port->pnr, port->lnr, port->nr, port->nr + 1,
2622 port->name);
1693 2623
1694 mutex_init(&port->i2c_gate_lock); 2624 if (port->class == DDB_PORT_CI &&
1695 ddb_port_probe(port); 2625 port->type == DDB_CI_EXTERNAL_XO2) {
1696 ddb_input_init(port, 2 * i); 2626 ddb_input_init(port, 2 * i, 0, 2 * i);
1697 ddb_input_init(port, 2 * i + 1); 2627 ddb_output_init(port, i);
1698 ddb_output_init(port, i); 2628 continue;
2629 }
2630
2631 if (port->class == DDB_PORT_CI &&
2632 port->type == DDB_CI_EXTERNAL_XO2_B) {
2633 ddb_input_init(port, 2 * i - 1, 0, 2 * i - 1);
2634 ddb_output_init(port, i);
2635 continue;
2636 }
2637
2638 if (port->class == DDB_PORT_NONE)
2639 continue;
2640
2641 switch (dev->link[l].info->type) {
2642 case DDB_OCTOPUS_CI:
2643 if (i >= 2) {
2644 ddb_input_init(port, 2 + i, 0, 2 + i);
2645 ddb_input_init(port, 4 + i, 1, 4 + i);
2646 ddb_output_init(port, i);
2647 break;
2648 } /* fallthrough */
2649 case DDB_OCTOPUS:
2650 ddb_input_init(port, 2 * i, 0, 2 * i);
2651 ddb_input_init(port, 2 * i + 1, 1, 2 * i + 1);
2652 ddb_output_init(port, i);
2653 break;
2654 case DDB_OCTOPUS_MAX:
2655 case DDB_OCTOPUS_MAX_CT:
2656 ddb_input_init(port, 2 * i, 0, 2 * p);
2657 ddb_input_init(port, 2 * i + 1, 1, 2 * p + 1);
2658 break;
2659 default:
2660 break;
2661 }
2662 }
1699 } 2663 }
2664 dev->port_num = p;
1700} 2665}
1701 2666
1702static void ddb_ports_release(struct ddb *dev) 2667void ddb_ports_release(struct ddb *dev)
1703{ 2668{
1704 int i; 2669 int i;
1705 struct ddb_port *port; 2670 struct ddb_port *port;
1706 2671
1707 for (i = 0; i < dev->info->port_num; i++) { 2672 for (i = 0; i < dev->port_num; i++) {
1708 port = &dev->port[i]; 2673 port = &dev->port[i];
1709 port->dev = dev; 2674 if (port->input[0] && port->input[0]->dma)
1710 tasklet_kill(&port->input[0]->tasklet); 2675 cancel_work_sync(&port->input[0]->dma->work);
1711 tasklet_kill(&port->input[1]->tasklet); 2676 if (port->input[1] && port->input[1]->dma)
1712 tasklet_kill(&port->output->tasklet); 2677 cancel_work_sync(&port->input[1]->dma->work);
2678 if (port->output && port->output->dma)
2679 cancel_work_sync(&port->output->dma->work);
1713 } 2680 }
1714} 2681}
1715 2682
@@ -1717,90 +2684,158 @@ static void ddb_ports_release(struct ddb *dev)
1717/****************************************************************************/ 2684/****************************************************************************/
1718/****************************************************************************/ 2685/****************************************************************************/
1719 2686
1720static void irq_handle_i2c(struct ddb *dev, int n) 2687#define IRQ_HANDLE(_nr) \
2688 do { if ((s & (1UL << ((_nr) & 0x1f))) && dev->handler[0][_nr]) \
2689 dev->handler[0][_nr](dev->handler_data[0][_nr]); } \
2690 while (0)
2691
2692static void irq_handle_msg(struct ddb *dev, u32 s)
1721{ 2693{
1722 struct ddb_i2c *i2c = &dev->i2c[n]; 2694 dev->i2c_irq++;
2695 IRQ_HANDLE(0);
2696 IRQ_HANDLE(1);
2697 IRQ_HANDLE(2);
2698 IRQ_HANDLE(3);
2699}
1723 2700
1724 i2c->done = 1; 2701static void irq_handle_io(struct ddb *dev, u32 s)
1725 wake_up(&i2c->wq); 2702{
2703 dev->ts_irq++;
2704 if ((s & 0x000000f0)) {
2705 IRQ_HANDLE(4);
2706 IRQ_HANDLE(5);
2707 IRQ_HANDLE(6);
2708 IRQ_HANDLE(7);
2709 }
2710 if ((s & 0x0000ff00)) {
2711 IRQ_HANDLE(8);
2712 IRQ_HANDLE(9);
2713 IRQ_HANDLE(10);
2714 IRQ_HANDLE(11);
2715 IRQ_HANDLE(12);
2716 IRQ_HANDLE(13);
2717 IRQ_HANDLE(14);
2718 IRQ_HANDLE(15);
2719 }
2720 if ((s & 0x00ff0000)) {
2721 IRQ_HANDLE(16);
2722 IRQ_HANDLE(17);
2723 IRQ_HANDLE(18);
2724 IRQ_HANDLE(19);
2725 IRQ_HANDLE(20);
2726 IRQ_HANDLE(21);
2727 IRQ_HANDLE(22);
2728 IRQ_HANDLE(23);
2729 }
2730 if ((s & 0xff000000)) {
2731 IRQ_HANDLE(24);
2732 IRQ_HANDLE(25);
2733 IRQ_HANDLE(26);
2734 IRQ_HANDLE(27);
2735 IRQ_HANDLE(28);
2736 IRQ_HANDLE(29);
2737 IRQ_HANDLE(30);
2738 IRQ_HANDLE(31);
2739 }
1726} 2740}
1727 2741
1728static irqreturn_t irq_handler(int irq, void *dev_id) 2742irqreturn_t ddb_irq_handler0(int irq, void *dev_id)
1729{ 2743{
1730 struct ddb *dev = (struct ddb *) dev_id; 2744 struct ddb *dev = (struct ddb *) dev_id;
1731 u32 s = ddbreadl(INTERRUPT_STATUS); 2745 u32 s = ddbreadl(dev, INTERRUPT_STATUS);
1732 2746
1733 if (!s) 2747 do {
1734 return IRQ_NONE; 2748 if (s & 0x80000000)
2749 return IRQ_NONE;
2750 if (!(s & 0xfffff00))
2751 return IRQ_NONE;
2752 ddbwritel(dev, s & 0xfffff00, INTERRUPT_ACK);
2753 irq_handle_io(dev, s);
2754 } while ((s = ddbreadl(dev, INTERRUPT_STATUS)));
2755
2756 return IRQ_HANDLED;
2757}
2758
2759irqreturn_t ddb_irq_handler1(int irq, void *dev_id)
2760{
2761 struct ddb *dev = (struct ddb *) dev_id;
2762 u32 s = ddbreadl(dev, INTERRUPT_STATUS);
1735 2763
1736 do { 2764 do {
1737 ddbwritel(s, INTERRUPT_ACK); 2765 if (s & 0x80000000)
1738 2766 return IRQ_NONE;
1739 if (s & 0x00000001) 2767 if (!(s & 0x0000f))
1740 irq_handle_i2c(dev, 0); 2768 return IRQ_NONE;
1741 if (s & 0x00000002) 2769 ddbwritel(dev, s & 0x0000f, INTERRUPT_ACK);
1742 irq_handle_i2c(dev, 1); 2770 irq_handle_msg(dev, s);
1743 if (s & 0x00000004) 2771 } while ((s = ddbreadl(dev, INTERRUPT_STATUS)));
1744 irq_handle_i2c(dev, 2);
1745 if (s & 0x00000008)
1746 irq_handle_i2c(dev, 3);
1747
1748 if (s & 0x00000100)
1749 tasklet_schedule(&dev->input[0].tasklet);
1750 if (s & 0x00000200)
1751 tasklet_schedule(&dev->input[1].tasklet);
1752 if (s & 0x00000400)
1753 tasklet_schedule(&dev->input[2].tasklet);
1754 if (s & 0x00000800)
1755 tasklet_schedule(&dev->input[3].tasklet);
1756 if (s & 0x00001000)
1757 tasklet_schedule(&dev->input[4].tasklet);
1758 if (s & 0x00002000)
1759 tasklet_schedule(&dev->input[5].tasklet);
1760 if (s & 0x00004000)
1761 tasklet_schedule(&dev->input[6].tasklet);
1762 if (s & 0x00008000)
1763 tasklet_schedule(&dev->input[7].tasklet);
1764
1765 if (s & 0x00010000)
1766 tasklet_schedule(&dev->output[0].tasklet);
1767 if (s & 0x00020000)
1768 tasklet_schedule(&dev->output[1].tasklet);
1769 if (s & 0x00040000)
1770 tasklet_schedule(&dev->output[2].tasklet);
1771 if (s & 0x00080000)
1772 tasklet_schedule(&dev->output[3].tasklet);
1773
1774 /* if (s & 0x000f0000) printk(KERN_DEBUG "%08x\n", istat); */
1775 } while ((s = ddbreadl(INTERRUPT_STATUS)));
1776 2772
1777 return IRQ_HANDLED; 2773 return IRQ_HANDLED;
1778} 2774}
1779 2775
1780/******************************************************************************/ 2776irqreturn_t ddb_irq_handler(int irq, void *dev_id)
1781/******************************************************************************/ 2777{
1782/******************************************************************************/ 2778 struct ddb *dev = (struct ddb *) dev_id;
2779 u32 s = ddbreadl(dev, INTERRUPT_STATUS);
2780 int ret = IRQ_HANDLED;
2781
2782 if (!s)
2783 return IRQ_NONE;
2784 do {
2785 if (s & 0x80000000)
2786 return IRQ_NONE;
2787 ddbwritel(dev, s, INTERRUPT_ACK);
2788
2789 if (s & 0x0000000f)
2790 irq_handle_msg(dev, s);
2791 if (s & 0x0fffff00)
2792 irq_handle_io(dev, s);
2793 } while ((s = ddbreadl(dev, INTERRUPT_STATUS)));
2794
2795 return ret;
2796}
2797
2798/****************************************************************************/
2799/****************************************************************************/
2800/****************************************************************************/
2801
2802static int reg_wait(struct ddb *dev, u32 reg, u32 bit)
2803{
2804 u32 count = 0;
2805
2806 while (safe_ddbreadl(dev, reg) & bit) {
2807 ndelay(10);
2808 if (++count == 100)
2809 return -1;
2810 }
2811 return 0;
2812}
1783 2813
1784static int flashio(struct ddb *dev, u8 *wbuf, u32 wlen, u8 *rbuf, u32 rlen) 2814static int flashio(struct ddb *dev, u32 lnr, u8 *wbuf, u32 wlen, u8 *rbuf,
2815 u32 rlen)
1785{ 2816{
1786 u32 data, shift; 2817 u32 data, shift;
2818 u32 tag = DDB_LINK_TAG(lnr);
2819 struct ddb_link *link = &dev->link[lnr];
1787 2820
2821 mutex_lock(&link->flash_mutex);
1788 if (wlen > 4) 2822 if (wlen > 4)
1789 ddbwritel(1, SPI_CONTROL); 2823 ddbwritel(dev, 1, tag | SPI_CONTROL);
1790 while (wlen > 4) { 2824 while (wlen > 4) {
1791 /* FIXME: check for big-endian */ 2825 /* FIXME: check for big-endian */
1792 data = swab32(*(u32 *)wbuf); 2826 data = swab32(*(u32 *) wbuf);
1793 wbuf += 4; 2827 wbuf += 4;
1794 wlen -= 4; 2828 wlen -= 4;
1795 ddbwritel(data, SPI_DATA); 2829 ddbwritel(dev, data, tag | SPI_DATA);
1796 while (safe_ddbreadl(dev, SPI_CONTROL) & 0x0004) 2830 if (reg_wait(dev, tag | SPI_CONTROL, 4))
1797 ; 2831 goto fail;
1798 } 2832 }
1799
1800 if (rlen) 2833 if (rlen)
1801 ddbwritel(0x0001 | ((wlen << (8 + 3)) & 0x1f00), SPI_CONTROL); 2834 ddbwritel(dev, 0x0001 | ((wlen << (8 + 3)) & 0x1f00),
2835 tag | SPI_CONTROL);
1802 else 2836 else
1803 ddbwritel(0x0003 | ((wlen << (8 + 3)) & 0x1f00), SPI_CONTROL); 2837 ddbwritel(dev, 0x0003 | ((wlen << (8 + 3)) & 0x1f00),
2838 tag | SPI_CONTROL);
1804 2839
1805 data = 0; 2840 data = 0;
1806 shift = ((4 - wlen) * 8); 2841 shift = ((4 - wlen) * 8);
@@ -1812,33 +2847,34 @@ static int flashio(struct ddb *dev, u8 *wbuf, u32 wlen, u8 *rbuf, u32 rlen)
1812 } 2847 }
1813 if (shift) 2848 if (shift)
1814 data <<= shift; 2849 data <<= shift;
1815 ddbwritel(data, SPI_DATA); 2850 ddbwritel(dev, data, tag | SPI_DATA);
1816 while (safe_ddbreadl(dev, SPI_CONTROL) & 0x0004) 2851 if (reg_wait(dev, tag | SPI_CONTROL, 4))
1817 ; 2852 goto fail;
1818 2853
1819 if (!rlen) { 2854 if (!rlen) {
1820 ddbwritel(0, SPI_CONTROL); 2855 ddbwritel(dev, 0, tag | SPI_CONTROL);
1821 return 0; 2856 goto exit;
1822 } 2857 }
1823 if (rlen > 4) 2858 if (rlen > 4)
1824 ddbwritel(1, SPI_CONTROL); 2859 ddbwritel(dev, 1, tag | SPI_CONTROL);
1825 2860
1826 while (rlen > 4) { 2861 while (rlen > 4) {
1827 ddbwritel(0xffffffff, SPI_DATA); 2862 ddbwritel(dev, 0xffffffff, tag | SPI_DATA);
1828 while (safe_ddbreadl(dev, SPI_CONTROL) & 0x0004) 2863 if (reg_wait(dev, tag | SPI_CONTROL, 4))
1829 ; 2864 goto fail;
1830 data = ddbreadl(SPI_DATA); 2865 data = ddbreadl(dev, tag | SPI_DATA);
1831 *(u32 *) rbuf = swab32(data); 2866 *(u32 *) rbuf = swab32(data);
1832 rbuf += 4; 2867 rbuf += 4;
1833 rlen -= 4; 2868 rlen -= 4;
1834 } 2869 }
1835 ddbwritel(0x0003 | ((rlen << (8 + 3)) & 0x1F00), SPI_CONTROL); 2870 ddbwritel(dev, 0x0003 | ((rlen << (8 + 3)) & 0x1F00),
1836 ddbwritel(0xffffffff, SPI_DATA); 2871 tag | SPI_CONTROL);
1837 while (safe_ddbreadl(dev, SPI_CONTROL) & 0x0004) 2872 ddbwritel(dev, 0xffffffff, tag | SPI_DATA);
1838 ; 2873 if (reg_wait(dev, tag | SPI_CONTROL, 4))
2874 goto fail;
1839 2875
1840 data = ddbreadl(SPI_DATA); 2876 data = ddbreadl(dev, tag | SPI_DATA);
1841 ddbwritel(0, SPI_CONTROL); 2877 ddbwritel(dev, 0, tag | SPI_CONTROL);
1842 2878
1843 if (rlen < 4) 2879 if (rlen < 4)
1844 data <<= ((4 - rlen) * 8); 2880 data <<= ((4 - rlen) * 8);
@@ -1849,31 +2885,47 @@ static int flashio(struct ddb *dev, u8 *wbuf, u32 wlen, u8 *rbuf, u32 rlen)
1849 rbuf++; 2885 rbuf++;
1850 rlen--; 2886 rlen--;
1851 } 2887 }
2888exit:
2889 mutex_unlock(&link->flash_mutex);
1852 return 0; 2890 return 0;
2891fail:
2892 mutex_unlock(&link->flash_mutex);
2893 return -1;
1853} 2894}
1854 2895
1855#define DDB_MAGIC 'd' 2896int ddbridge_flashread(struct ddb *dev, u32 link, u8 *buf, u32 addr, u32 len)
2897{
2898 u8 cmd[4] = {0x03, (addr >> 16) & 0xff,
2899 (addr >> 8) & 0xff, addr & 0xff};
1856 2900
1857struct ddb_flashio { 2901 return flashio(dev, link, cmd, 4, buf, len);
1858 __user __u8 *write_buf; 2902}
1859 __u32 write_len;
1860 __user __u8 *read_buf;
1861 __u32 read_len;
1862};
1863 2903
1864#define IOCTL_DDB_FLASHIO _IOWR(DDB_MAGIC, 0x00, struct ddb_flashio) 2904/*
2905 * TODO/FIXME: add/implement IOCTLs from upstream driver
2906 */
1865 2907
1866#define DDB_NAME "ddbridge" 2908#define DDB_NAME "ddbridge"
1867 2909
1868static u32 ddb_num; 2910static u32 ddb_num;
1869static struct ddb *ddbs[32];
1870static struct class *ddb_class;
1871static int ddb_major; 2911static int ddb_major;
2912static DEFINE_MUTEX(ddb_mutex);
2913
2914static int ddb_release(struct inode *inode, struct file *file)
2915{
2916 struct ddb *dev = file->private_data;
2917
2918 dev->ddb_dev_users--;
2919 return 0;
2920}
1872 2921
1873static int ddb_open(struct inode *inode, struct file *file) 2922static int ddb_open(struct inode *inode, struct file *file)
1874{ 2923{
1875 struct ddb *dev = ddbs[iminor(inode)]; 2924 struct ddb *dev = ddbs[iminor(inode)];
1876 2925
2926 if (dev->ddb_dev_users)
2927 return -EBUSY;
2928 dev->ddb_dev_users++;
1877 file->private_data = dev; 2929 file->private_data = dev;
1878 return 0; 2930 return 0;
1879} 2931}
@@ -1881,44 +2933,17 @@ static int ddb_open(struct inode *inode, struct file *file)
1881static long ddb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 2933static long ddb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1882{ 2934{
1883 struct ddb *dev = file->private_data; 2935 struct ddb *dev = file->private_data;
1884 __user void *parg = (__user void *)arg;
1885 int res;
1886 2936
1887 switch (cmd) { 2937 dev_warn(dev->dev, "DDB IOCTLs unsupported (cmd: %d, arg: %lu)\n",
1888 case IOCTL_DDB_FLASHIO: 2938 cmd, arg);
1889 {
1890 struct ddb_flashio fio;
1891 u8 *rbuf, *wbuf;
1892 2939
1893 if (copy_from_user(&fio, parg, sizeof(fio))) 2940 return -ENOTTY;
1894 return -EFAULT;
1895
1896 if (fio.write_len > 1028 || fio.read_len > 1028)
1897 return -EINVAL;
1898 if (fio.write_len + fio.read_len > 1028)
1899 return -EINVAL;
1900
1901 wbuf = &dev->iobuf[0];
1902 rbuf = wbuf + fio.write_len;
1903
1904 if (copy_from_user(wbuf, fio.write_buf, fio.write_len))
1905 return -EFAULT;
1906 res = flashio(dev, wbuf, fio.write_len, rbuf, fio.read_len);
1907 if (res)
1908 return res;
1909 if (copy_to_user(fio.read_buf, rbuf, fio.read_len))
1910 return -EFAULT;
1911 break;
1912 }
1913 default:
1914 return -ENOTTY;
1915 }
1916 return 0;
1917} 2941}
1918 2942
1919static const struct file_operations ddb_fops = { 2943static const struct file_operations ddb_fops = {
1920 .unlocked_ioctl = ddb_ioctl, 2944 .unlocked_ioctl = ddb_ioctl,
1921 .open = ddb_open, 2945 .open = ddb_open,
2946 .release = ddb_release,
1922}; 2947};
1923 2948
1924static char *ddb_devnode(struct device *device, umode_t *mode) 2949static char *ddb_devnode(struct device *device, umode_t *mode)
@@ -1928,369 +2953,684 @@ static char *ddb_devnode(struct device *device, umode_t *mode)
1928 return kasprintf(GFP_KERNEL, "ddbridge/card%d", dev->nr); 2953 return kasprintf(GFP_KERNEL, "ddbridge/card%d", dev->nr);
1929} 2954}
1930 2955
1931static int ddb_class_create(void) 2956#define __ATTR_MRO(_name, _show) { \
2957 .attr = { .name = __stringify(_name), .mode = 0444 }, \
2958 .show = _show, \
2959}
2960
2961#define __ATTR_MWO(_name, _store) { \
2962 .attr = { .name = __stringify(_name), .mode = 0222 }, \
2963 .store = _store, \
2964}
2965
2966static ssize_t ports_show(struct device *device,
2967 struct device_attribute *attr, char *buf)
1932{ 2968{
1933 ddb_major = register_chrdev(0, DDB_NAME, &ddb_fops); 2969 struct ddb *dev = dev_get_drvdata(device);
1934 if (ddb_major < 0)
1935 return ddb_major;
1936 2970
1937 ddb_class = class_create(THIS_MODULE, DDB_NAME); 2971 return sprintf(buf, "%d\n", dev->port_num);
1938 if (IS_ERR(ddb_class)) {
1939 unregister_chrdev(ddb_major, DDB_NAME);
1940 return PTR_ERR(ddb_class);
1941 }
1942 ddb_class->devnode = ddb_devnode;
1943 return 0;
1944} 2972}
1945 2973
1946static void ddb_class_destroy(void) 2974static ssize_t ts_irq_show(struct device *device,
2975 struct device_attribute *attr, char *buf)
1947{ 2976{
1948 class_destroy(ddb_class); 2977 struct ddb *dev = dev_get_drvdata(device);
1949 unregister_chrdev(ddb_major, DDB_NAME); 2978
2979 return sprintf(buf, "%d\n", dev->ts_irq);
1950} 2980}
1951 2981
1952static int ddb_device_create(struct ddb *dev) 2982static ssize_t i2c_irq_show(struct device *device,
2983 struct device_attribute *attr, char *buf)
1953{ 2984{
1954 dev->nr = ddb_num++; 2985 struct ddb *dev = dev_get_drvdata(device);
1955 dev->ddb_dev = device_create(ddb_class, NULL, 2986
1956 MKDEV(ddb_major, dev->nr), 2987 return sprintf(buf, "%d\n", dev->i2c_irq);
1957 dev, "ddbridge%d", dev->nr);
1958 ddbs[dev->nr] = dev;
1959 if (IS_ERR(dev->ddb_dev))
1960 return -1;
1961 return 0;
1962} 2988}
1963 2989
1964static void ddb_device_destroy(struct ddb *dev) 2990static ssize_t fan_show(struct device *device,
2991 struct device_attribute *attr, char *buf)
1965{ 2992{
1966 ddb_num--; 2993 struct ddb *dev = dev_get_drvdata(device);
1967 if (IS_ERR(dev->ddb_dev)) 2994 u32 val;
1968 return; 2995
1969 device_destroy(ddb_class, MKDEV(ddb_major, 0)); 2996 val = ddbreadl(dev, GPIO_OUTPUT) & 1;
2997 return sprintf(buf, "%d\n", val);
1970} 2998}
1971 2999
3000static ssize_t fan_store(struct device *device, struct device_attribute *d,
3001 const char *buf, size_t count)
3002{
3003 struct ddb *dev = dev_get_drvdata(device);
3004 u32 val;
1972 3005
1973/****************************************************************************/ 3006 if (sscanf(buf, "%u\n", &val) != 1)
1974/****************************************************************************/ 3007 return -EINVAL;
1975/****************************************************************************/ 3008 ddbwritel(dev, 1, GPIO_DIRECTION);
3009 ddbwritel(dev, val & 1, GPIO_OUTPUT);
3010 return count;
3011}
1976 3012
1977static void ddb_unmap(struct ddb *dev) 3013static ssize_t fanspeed_show(struct device *device,
3014 struct device_attribute *attr, char *buf)
1978{ 3015{
1979 if (dev->regs) 3016 struct ddb *dev = dev_get_drvdata(device);
1980 iounmap(dev->regs); 3017 int num = attr->attr.name[8] - 0x30;
1981 vfree(dev); 3018 struct ddb_link *link = &dev->link[num];
3019 u32 spd;
3020
3021 spd = ddblreadl(link, TEMPMON_FANCONTROL) & 0xff;
3022 return sprintf(buf, "%u\n", spd * 100);
1982} 3023}
1983 3024
3025static ssize_t temp_show(struct device *device,
3026 struct device_attribute *attr, char *buf)
3027{
3028 struct ddb *dev = dev_get_drvdata(device);
3029 struct ddb_link *link = &dev->link[0];
3030 struct i2c_adapter *adap;
3031 int temp, temp2;
3032 u8 tmp[2];
3033
3034 if (!link->info->temp_num)
3035 return sprintf(buf, "no sensor\n");
3036 adap = &dev->i2c[link->info->temp_bus].adap;
3037 if (i2c_read_regs(adap, 0x48, 0, tmp, 2) < 0)
3038 return sprintf(buf, "read_error\n");
3039 temp = (tmp[0] << 3) | (tmp[1] >> 5);
3040 temp *= 125;
3041 if (link->info->temp_num == 2) {
3042 if (i2c_read_regs(adap, 0x49, 0, tmp, 2) < 0)
3043 return sprintf(buf, "read_error\n");
3044 temp2 = (tmp[0] << 3) | (tmp[1] >> 5);
3045 temp2 *= 125;
3046 return sprintf(buf, "%d %d\n", temp, temp2);
3047 }
3048 return sprintf(buf, "%d\n", temp);
3049}
1984 3050
1985static void ddb_remove(struct pci_dev *pdev) 3051static ssize_t ctemp_show(struct device *device,
3052 struct device_attribute *attr, char *buf)
1986{ 3053{
1987 struct ddb *dev = pci_get_drvdata(pdev); 3054 struct ddb *dev = dev_get_drvdata(device);
3055 struct i2c_adapter *adap;
3056 int temp;
3057 u8 tmp[2];
3058 int num = attr->attr.name[4] - 0x30;
1988 3059
1989 ddb_ports_detach(dev); 3060 adap = &dev->i2c[num].adap;
1990 ddb_i2c_release(dev); 3061 if (!adap)
3062 return 0;
3063 if (i2c_read_regs(adap, 0x49, 0, tmp, 2) < 0)
3064 if (i2c_read_regs(adap, 0x4d, 0, tmp, 2) < 0)
3065 return sprintf(buf, "no sensor\n");
3066 temp = tmp[0] * 1000;
3067 return sprintf(buf, "%d\n", temp);
3068}
1991 3069
1992 ddbwritel(0, INTERRUPT_ENABLE); 3070static ssize_t led_show(struct device *device,
1993 free_irq(dev->pdev->irq, dev); 3071 struct device_attribute *attr, char *buf)
1994#ifdef CONFIG_PCI_MSI 3072{
1995 if (dev->msi) 3073 struct ddb *dev = dev_get_drvdata(device);
1996 pci_disable_msi(dev->pdev); 3074 int num = attr->attr.name[3] - 0x30;
1997#endif
1998 ddb_ports_release(dev);
1999 ddb_buffers_free(dev);
2000 ddb_device_destroy(dev);
2001 3075
2002 ddb_unmap(dev); 3076 return sprintf(buf, "%d\n", dev->leds & (1 << num) ? 1 : 0);
2003 pci_set_drvdata(pdev, NULL);
2004 pci_disable_device(pdev);
2005} 3077}
2006 3078
2007 3079
2008static int ddb_probe(struct pci_dev *pdev, const struct pci_device_id *id) 3080static void ddb_set_led(struct ddb *dev, int num, int val)
2009{ 3081{
2010 struct ddb *dev; 3082 if (!dev->link[0].info->led_num)
2011 int stat = 0; 3083 return;
2012 int irq_flag = IRQF_SHARED; 3084 switch (dev->port[num].class) {
3085 case DDB_PORT_TUNER:
3086 switch (dev->port[num].type) {
3087 case DDB_TUNER_DVBS_ST:
3088 i2c_write_reg16(&dev->i2c[num].adap,
3089 0x69, 0xf14c, val ? 2 : 0);
3090 break;
3091 case DDB_TUNER_DVBCT_ST:
3092 i2c_write_reg16(&dev->i2c[num].adap,
3093 0x1f, 0xf00e, 0);
3094 i2c_write_reg16(&dev->i2c[num].adap,
3095 0x1f, 0xf00f, val ? 1 : 0);
3096 break;
3097 case DDB_TUNER_XO2 ... DDB_TUNER_DVBC2T2I_SONY:
3098 {
3099 u8 v;
2013 3100
2014 if (pci_enable_device(pdev) < 0) 3101 i2c_read_reg(&dev->i2c[num].adap, 0x10, 0x08, &v);
2015 return -ENODEV; 3102 v = (v & ~0x10) | (val ? 0x10 : 0);
3103 i2c_write_reg(&dev->i2c[num].adap, 0x10, 0x08, v);
3104 break;
3105 }
3106 default:
3107 break;
3108 }
3109 break;
3110 }
3111}
2016 3112
2017 dev = vzalloc(sizeof(struct ddb)); 3113static ssize_t led_store(struct device *device,
2018 if (dev == NULL) 3114 struct device_attribute *attr,
2019 return -ENOMEM; 3115 const char *buf, size_t count)
3116{
3117 struct ddb *dev = dev_get_drvdata(device);
3118 int num = attr->attr.name[3] - 0x30;
3119 u32 val;
2020 3120
2021 dev->pdev = pdev; 3121 if (sscanf(buf, "%u\n", &val) != 1)
2022 pci_set_drvdata(pdev, dev); 3122 return -EINVAL;
2023 dev->info = (struct ddb_info *) id->driver_data; 3123 if (val)
2024 dev_info(&pdev->dev, "Detected %s\n", dev->info->name); 3124 dev->leds |= (1 << num);
3125 else
3126 dev->leds &= ~(1 << num);
3127 ddb_set_led(dev, num, val);
3128 return count;
3129}
2025 3130
2026 dev->regs = ioremap(pci_resource_start(dev->pdev, 0), 3131static ssize_t snr_show(struct device *device,
2027 pci_resource_len(dev->pdev, 0)); 3132 struct device_attribute *attr, char *buf)
2028 if (!dev->regs) { 3133{
2029 stat = -ENOMEM; 3134 struct ddb *dev = dev_get_drvdata(device);
2030 goto fail; 3135 char snr[32];
2031 } 3136 int num = attr->attr.name[3] - 0x30;
2032 dev_info(&pdev->dev, "HW %08x FW %08x\n", ddbreadl(0), ddbreadl(4));
2033 3137
2034#ifdef CONFIG_PCI_MSI 3138 if (dev->port[num].type >= DDB_TUNER_XO2) {
2035 if (pci_msi_enabled()) 3139 if (i2c_read_regs(&dev->i2c[num].adap, 0x10, 0x10, snr, 16) < 0)
2036 stat = pci_enable_msi(dev->pdev); 3140 return sprintf(buf, "NO SNR\n");
2037 if (stat) { 3141 snr[16] = 0;
2038 dev_info(&pdev->dev, "MSI not available.\n");
2039 } else { 3142 } else {
2040 irq_flag = 0; 3143 /* serial number at 0x100-0x11f */
2041 dev->msi = 1; 3144 if (i2c_read_regs16(&dev->i2c[num].adap,
2042 } 3145 0x57, 0x100, snr, 32) < 0)
2043#endif 3146 if (i2c_read_regs16(&dev->i2c[num].adap,
2044 stat = request_irq(dev->pdev->irq, irq_handler, 3147 0x50, 0x100, snr, 32) < 0)
2045 irq_flag, "DDBridge", (void *) dev); 3148 return sprintf(buf, "NO SNR\n");
2046 if (stat < 0) 3149 snr[31] = 0; /* in case it is not terminated on EEPROM */
2047 goto fail1;
2048 ddbwritel(0, DMA_BASE_WRITE);
2049 ddbwritel(0, DMA_BASE_READ);
2050 ddbwritel(0xffffffff, INTERRUPT_ACK);
2051 ddbwritel(0xfff0f, INTERRUPT_ENABLE);
2052 ddbwritel(0, MSI1_ENABLE);
2053
2054 /* board control */
2055 if (dev->info->board_control) {
2056 ddbwritel(0, DDB_LINK_TAG(0) | BOARD_CONTROL);
2057 msleep(100);
2058 ddbwritel(dev->info->board_control_2,
2059 DDB_LINK_TAG(0) | BOARD_CONTROL);
2060 usleep_range(2000, 3000);
2061 ddbwritel(dev->info->board_control_2
2062 | dev->info->board_control,
2063 DDB_LINK_TAG(0) | BOARD_CONTROL);
2064 usleep_range(2000, 3000);
2065 } 3150 }
3151 return sprintf(buf, "%s\n", snr);
3152}
2066 3153
2067 if (ddb_i2c_init(dev) < 0) 3154static ssize_t bsnr_show(struct device *device,
2068 goto fail1; 3155 struct device_attribute *attr, char *buf)
2069 ddb_ports_init(dev); 3156{
2070 if (ddb_buffers_alloc(dev) < 0) { 3157 struct ddb *dev = dev_get_drvdata(device);
2071 dev_err(&pdev->dev, "Could not allocate buffer memory\n"); 3158 char snr[16];
2072 goto fail2; 3159
2073 } 3160 ddbridge_flashread(dev, 0, snr, 0x10, 15);
2074 if (ddb_ports_attach(dev) < 0) 3161 snr[15] = 0; /* in case it is not terminated on EEPROM */
2075 goto fail3; 3162 return sprintf(buf, "%s\n", snr);
2076 ddb_device_create(dev); 3163}
3164
3165static ssize_t bpsnr_show(struct device *device,
3166 struct device_attribute *attr, char *buf)
3167{
3168 struct ddb *dev = dev_get_drvdata(device);
3169 unsigned char snr[32];
3170
3171 if (!dev->i2c_num)
3172 return 0;
3173
3174 if (i2c_read_regs16(&dev->i2c[0].adap,
3175 0x50, 0x0000, snr, 32) < 0 ||
3176 snr[0] == 0xff)
3177 return sprintf(buf, "NO SNR\n");
3178 snr[31] = 0; /* in case it is not terminated on EEPROM */
3179 return sprintf(buf, "%s\n", snr);
3180}
3181
3182static ssize_t redirect_show(struct device *device,
3183 struct device_attribute *attr, char *buf)
3184{
2077 return 0; 3185 return 0;
3186}
2078 3187
2079fail3: 3188static ssize_t redirect_store(struct device *device,
2080 ddb_ports_detach(dev); 3189 struct device_attribute *attr,
2081 dev_err(&pdev->dev, "fail3\n"); 3190 const char *buf, size_t count)
2082 ddb_ports_release(dev); 3191{
2083fail2: 3192 unsigned int i, p;
2084 dev_err(&pdev->dev, "fail2\n"); 3193 int res;
2085 ddb_buffers_free(dev); 3194
2086fail1: 3195 if (sscanf(buf, "%x %x\n", &i, &p) != 2)
2087 dev_err(&pdev->dev, "fail1\n"); 3196 return -EINVAL;
2088 if (dev->msi) 3197 res = ddb_redirect(i, p);
2089 pci_disable_msi(dev->pdev); 3198 if (res < 0)
2090 if (stat == 0) 3199 return res;
2091 free_irq(dev->pdev->irq, dev); 3200 dev_info(device, "redirect: %02x, %02x\n", i, p);
2092fail: 3201 return count;
2093 dev_err(&pdev->dev, "fail\n");
2094 ddb_unmap(dev);
2095 pci_set_drvdata(pdev, NULL);
2096 pci_disable_device(pdev);
2097 return -1;
2098} 3202}
2099 3203
2100/******************************************************************************/ 3204static ssize_t gap_show(struct device *device,
2101/******************************************************************************/ 3205 struct device_attribute *attr, char *buf)
2102/******************************************************************************/ 3206{
3207 struct ddb *dev = dev_get_drvdata(device);
3208 int num = attr->attr.name[3] - 0x30;
2103 3209
2104static const struct ddb_info ddb_none = { 3210 return sprintf(buf, "%d\n", dev->port[num].gap);
2105 .type = DDB_NONE,
2106 .name = "Digital Devices PCIe bridge",
2107};
2108 3211
2109static const struct ddb_info ddb_octopus = { 3212}
2110 .type = DDB_OCTOPUS,
2111 .name = "Digital Devices Octopus DVB adapter",
2112 .port_num = 4,
2113};
2114 3213
2115static const struct ddb_info ddb_octopus_le = { 3214static ssize_t gap_store(struct device *device, struct device_attribute *attr,
2116 .type = DDB_OCTOPUS, 3215 const char *buf, size_t count)
2117 .name = "Digital Devices Octopus LE DVB adapter", 3216{
2118 .port_num = 2, 3217 struct ddb *dev = dev_get_drvdata(device);
2119}; 3218 int num = attr->attr.name[3] - 0x30;
3219 unsigned int val;
3220
3221 if (sscanf(buf, "%u\n", &val) != 1)
3222 return -EINVAL;
3223 if (val > 128)
3224 return -EINVAL;
3225 if (val == 128)
3226 val = 0xffffffff;
3227 dev->port[num].gap = val;
3228 return count;
3229}
3230
3231static ssize_t version_show(struct device *device,
3232 struct device_attribute *attr, char *buf)
3233{
3234 struct ddb *dev = dev_get_drvdata(device);
3235
3236 return sprintf(buf, "%08x %08x\n",
3237 dev->link[0].ids.hwid, dev->link[0].ids.regmapid);
3238}
3239
3240static ssize_t hwid_show(struct device *device,
3241 struct device_attribute *attr, char *buf)
3242{
3243 struct ddb *dev = dev_get_drvdata(device);
3244
3245 return sprintf(buf, "0x%08X\n", dev->link[0].ids.hwid);
3246}
3247
3248static ssize_t regmap_show(struct device *device,
3249 struct device_attribute *attr, char *buf)
3250{
3251 struct ddb *dev = dev_get_drvdata(device);
3252
3253 return sprintf(buf, "0x%08X\n", dev->link[0].ids.regmapid);
3254}
3255
3256static ssize_t fmode_show(struct device *device,
3257 struct device_attribute *attr, char *buf)
3258{
3259 int num = attr->attr.name[5] - 0x30;
3260 struct ddb *dev = dev_get_drvdata(device);
3261
3262 return sprintf(buf, "%u\n", dev->link[num].lnb.fmode);
3263}
2120 3264
2121static const struct ddb_info ddb_octopus_oem = { 3265static ssize_t devid_show(struct device *device,
2122 .type = DDB_OCTOPUS, 3266 struct device_attribute *attr, char *buf)
2123 .name = "Digital Devices Octopus OEM", 3267{
2124 .port_num = 4, 3268 int num = attr->attr.name[5] - 0x30;
3269 struct ddb *dev = dev_get_drvdata(device);
3270
3271 return sprintf(buf, "%08x\n", dev->link[num].ids.devid);
3272}
3273
3274static ssize_t fmode_store(struct device *device, struct device_attribute *attr,
3275 const char *buf, size_t count)
3276{
3277 struct ddb *dev = dev_get_drvdata(device);
3278 int num = attr->attr.name[5] - 0x30;
3279 unsigned int val;
3280
3281 if (sscanf(buf, "%u\n", &val) != 1)
3282 return -EINVAL;
3283 if (val > 3)
3284 return -EINVAL;
3285 lnb_init_fmode(dev, &dev->link[num], val);
3286 return count;
3287}
3288
3289static struct device_attribute ddb_attrs[] = {
3290 __ATTR_RO(version),
3291 __ATTR_RO(ports),
3292 __ATTR_RO(ts_irq),
3293 __ATTR_RO(i2c_irq),
3294 __ATTR(gap0, 0664, gap_show, gap_store),
3295 __ATTR(gap1, 0664, gap_show, gap_store),
3296 __ATTR(gap2, 0664, gap_show, gap_store),
3297 __ATTR(gap3, 0664, gap_show, gap_store),
3298 __ATTR(fmode0, 0664, fmode_show, fmode_store),
3299 __ATTR(fmode1, 0664, fmode_show, fmode_store),
3300 __ATTR(fmode2, 0664, fmode_show, fmode_store),
3301 __ATTR(fmode3, 0664, fmode_show, fmode_store),
3302 __ATTR_MRO(devid0, devid_show),
3303 __ATTR_MRO(devid1, devid_show),
3304 __ATTR_MRO(devid2, devid_show),
3305 __ATTR_MRO(devid3, devid_show),
3306 __ATTR_RO(hwid),
3307 __ATTR_RO(regmap),
3308 __ATTR(redirect, 0664, redirect_show, redirect_store),
3309 __ATTR_MRO(snr, bsnr_show),
3310 __ATTR_RO(bpsnr),
3311 __ATTR_NULL,
2125}; 3312};
2126 3313
2127static const struct ddb_info ddb_octopus_mini = { 3314static struct device_attribute ddb_attrs_temp[] = {
2128 .type = DDB_OCTOPUS, 3315 __ATTR_RO(temp),
2129 .name = "Digital Devices Octopus Mini",
2130 .port_num = 4,
2131}; 3316};
2132 3317
2133static const struct ddb_info ddb_v6 = { 3318static struct device_attribute ddb_attrs_fan[] = {
2134 .type = DDB_OCTOPUS, 3319 __ATTR(fan, 0664, fan_show, fan_store),
2135 .name = "Digital Devices Cine S2 V6 DVB adapter",
2136 .port_num = 3,
2137}; 3320};
2138static const struct ddb_info ddb_v6_5 = { 3321
2139 .type = DDB_OCTOPUS, 3322static struct device_attribute ddb_attrs_snr[] = {
2140 .name = "Digital Devices Cine S2 V6.5 DVB adapter", 3323 __ATTR_MRO(snr0, snr_show),
2141 .port_num = 4, 3324 __ATTR_MRO(snr1, snr_show),
3325 __ATTR_MRO(snr2, snr_show),
3326 __ATTR_MRO(snr3, snr_show),
2142}; 3327};
2143 3328
2144static const struct ddb_info ddb_dvbct = { 3329static struct device_attribute ddb_attrs_ctemp[] = {
2145 .type = DDB_OCTOPUS, 3330 __ATTR_MRO(temp0, ctemp_show),
2146 .name = "Digital Devices DVBCT V6.1 DVB adapter", 3331 __ATTR_MRO(temp1, ctemp_show),
2147 .port_num = 3, 3332 __ATTR_MRO(temp2, ctemp_show),
3333 __ATTR_MRO(temp3, ctemp_show),
2148}; 3334};
2149 3335
2150static const struct ddb_info ddb_ctv7 = { 3336static struct device_attribute ddb_attrs_led[] = {
2151 .type = DDB_OCTOPUS, 3337 __ATTR(led0, 0664, led_show, led_store),
2152 .name = "Digital Devices Cine CT V7 DVB adapter", 3338 __ATTR(led1, 0664, led_show, led_store),
2153 .port_num = 4, 3339 __ATTR(led2, 0664, led_show, led_store),
2154 .board_control = 3, 3340 __ATTR(led3, 0664, led_show, led_store),
2155 .board_control_2 = 4,
2156}; 3341};
2157 3342
2158static const struct ddb_info ddb_satixS2v3 = { 3343static struct device_attribute ddb_attrs_fanspeed[] = {
2159 .type = DDB_OCTOPUS, 3344 __ATTR_MRO(fanspeed0, fanspeed_show),
2160 .name = "Mystique SaTiX-S2 V3 DVB adapter", 3345 __ATTR_MRO(fanspeed1, fanspeed_show),
2161 .port_num = 3, 3346 __ATTR_MRO(fanspeed2, fanspeed_show),
3347 __ATTR_MRO(fanspeed3, fanspeed_show),
2162}; 3348};
2163 3349
2164static const struct ddb_info ddb_octopusv3 = { 3350static struct class ddb_class = {
2165 .type = DDB_OCTOPUS, 3351 .name = "ddbridge",
2166 .name = "Digital Devices Octopus V3 DVB adapter", 3352 .owner = THIS_MODULE,
2167 .port_num = 4, 3353 .devnode = ddb_devnode,
2168}; 3354};
2169 3355
2170/*** MaxA8 adapters ***********************************************************/ 3356int ddb_class_create(void)
3357{
3358 ddb_major = register_chrdev(0, DDB_NAME, &ddb_fops);
3359 if (ddb_major < 0)
3360 return ddb_major;
3361 if (class_register(&ddb_class) < 0)
3362 return -1;
3363 return 0;
3364}
2171 3365
2172static struct ddb_info ddb_ct2_8 = { 3366void ddb_class_destroy(void)
2173 .type = DDB_OCTOPUS_MAX_CT, 3367{
2174 .name = "Digital Devices MAX A8 CT2", 3368 class_unregister(&ddb_class);
2175 .port_num = 4, 3369 unregister_chrdev(ddb_major, DDB_NAME);
2176 .board_control = 0x0ff, 3370}
2177 .board_control_2 = 0xf00,
2178 .ts_quirks = TS_QUIRK_SERIAL,
2179};
2180 3371
2181static struct ddb_info ddb_c2t2_8 = { 3372static void ddb_device_attrs_del(struct ddb *dev)
2182 .type = DDB_OCTOPUS_MAX_CT, 3373{
2183 .name = "Digital Devices MAX A8 C2T2", 3374 int i;
2184 .port_num = 4,
2185 .board_control = 0x0ff,
2186 .board_control_2 = 0xf00,
2187 .ts_quirks = TS_QUIRK_SERIAL,
2188};
2189 3375
2190static struct ddb_info ddb_isdbt_8 = { 3376 for (i = 0; i < 4; i++)
2191 .type = DDB_OCTOPUS_MAX_CT, 3377 if (dev->link[i].info && dev->link[i].info->tempmon_irq)
2192 .name = "Digital Devices MAX A8 ISDBT", 3378 device_remove_file(dev->ddb_dev,
2193 .port_num = 4, 3379 &ddb_attrs_fanspeed[i]);
2194 .board_control = 0x0ff, 3380 for (i = 0; i < dev->link[0].info->temp_num; i++)
2195 .board_control_2 = 0xf00, 3381 device_remove_file(dev->ddb_dev, &ddb_attrs_temp[i]);
2196 .ts_quirks = TS_QUIRK_SERIAL, 3382 for (i = 0; i < dev->link[0].info->fan_num; i++)
2197}; 3383 device_remove_file(dev->ddb_dev, &ddb_attrs_fan[i]);
3384 for (i = 0; i < dev->i2c_num && i < 4; i++) {
3385 if (dev->link[0].info->led_num)
3386 device_remove_file(dev->ddb_dev, &ddb_attrs_led[i]);
3387 device_remove_file(dev->ddb_dev, &ddb_attrs_snr[i]);
3388 device_remove_file(dev->ddb_dev, &ddb_attrs_ctemp[i]);
3389 }
3390 for (i = 0; ddb_attrs[i].attr.name != NULL; i++)
3391 device_remove_file(dev->ddb_dev, &ddb_attrs[i]);
3392}
2198 3393
2199static struct ddb_info ddb_c2t2i_v0_8 = { 3394static int ddb_device_attrs_add(struct ddb *dev)
2200 .type = DDB_OCTOPUS_MAX_CT, 3395{
2201 .name = "Digital Devices MAX A8 C2T2I V0", 3396 int i;
2202 .port_num = 4,
2203 .board_control = 0x0ff,
2204 .board_control_2 = 0xf00,
2205 .ts_quirks = TS_QUIRK_SERIAL | TS_QUIRK_ALT_OSC,
2206};
2207 3397
2208static struct ddb_info ddb_c2t2i_8 = { 3398 for (i = 0; ddb_attrs[i].attr.name != NULL; i++)
2209 .type = DDB_OCTOPUS_MAX_CT, 3399 if (device_create_file(dev->ddb_dev, &ddb_attrs[i]))
2210 .name = "Digital Devices MAX A8 C2T2I", 3400 goto fail;
2211 .port_num = 4, 3401 for (i = 0; i < dev->link[0].info->temp_num; i++)
2212 .board_control = 0x0ff, 3402 if (device_create_file(dev->ddb_dev, &ddb_attrs_temp[i]))
2213 .board_control_2 = 0xf00, 3403 goto fail;
2214 .ts_quirks = TS_QUIRK_SERIAL, 3404 for (i = 0; i < dev->link[0].info->fan_num; i++)
2215}; 3405 if (device_create_file(dev->ddb_dev, &ddb_attrs_fan[i]))
3406 goto fail;
3407 for (i = 0; (i < dev->i2c_num) && (i < 4); i++) {
3408 if (device_create_file(dev->ddb_dev, &ddb_attrs_snr[i]))
3409 goto fail;
3410 if (device_create_file(dev->ddb_dev, &ddb_attrs_ctemp[i]))
3411 goto fail;
3412 if (dev->link[0].info->led_num)
3413 if (device_create_file(dev->ddb_dev,
3414 &ddb_attrs_led[i]))
3415 goto fail;
3416 }
3417 for (i = 0; i < 4; i++)
3418 if (dev->link[i].info && dev->link[i].info->tempmon_irq)
3419 if (device_create_file(dev->ddb_dev,
3420 &ddb_attrs_fanspeed[i]))
3421 goto fail;
3422 return 0;
3423fail:
3424 return -1;
3425}
2216 3426
2217/******************************************************************************/ 3427int ddb_device_create(struct ddb *dev)
3428{
3429 int res = 0;
2218 3430
2219#define DDVID 0xdd01 /* Digital Devices Vendor ID */ 3431 if (ddb_num == DDB_MAX_ADAPTER)
2220 3432 return -ENOMEM;
2221#define DDB_ID(_vend, _dev, _subvend, _subdev, _driverdata) { \ 3433 mutex_lock(&ddb_mutex);
2222 .vendor = _vend, .device = _dev, \ 3434 dev->nr = ddb_num;
2223 .subvendor = _subvend, .subdevice = _subdev, \ 3435 ddbs[dev->nr] = dev;
2224 .driver_data = (unsigned long)&_driverdata } 3436 dev->ddb_dev = device_create(&ddb_class, dev->dev,
2225 3437 MKDEV(ddb_major, dev->nr),
2226static const struct pci_device_id ddb_id_tbl[] = { 3438 dev, "ddbridge%d", dev->nr);
2227 DDB_ID(DDVID, 0x0002, DDVID, 0x0001, ddb_octopus), 3439 if (IS_ERR(dev->ddb_dev)) {
2228 DDB_ID(DDVID, 0x0003, DDVID, 0x0001, ddb_octopus), 3440 res = PTR_ERR(dev->ddb_dev);
2229 DDB_ID(DDVID, 0x0005, DDVID, 0x0004, ddb_octopusv3), 3441 dev_info(dev->dev, "Could not create ddbridge%d\n", dev->nr);
2230 DDB_ID(DDVID, 0x0003, DDVID, 0x0002, ddb_octopus_le), 3442 goto fail;
2231 DDB_ID(DDVID, 0x0003, DDVID, 0x0003, ddb_octopus_oem), 3443 }
2232 DDB_ID(DDVID, 0x0003, DDVID, 0x0010, ddb_octopus_mini), 3444 res = ddb_device_attrs_add(dev);
2233 DDB_ID(DDVID, 0x0005, DDVID, 0x0011, ddb_octopus_mini), 3445 if (res) {
2234 DDB_ID(DDVID, 0x0003, DDVID, 0x0020, ddb_v6), 3446 ddb_device_attrs_del(dev);
2235 DDB_ID(DDVID, 0x0003, DDVID, 0x0021, ddb_v6_5), 3447 device_destroy(&ddb_class, MKDEV(ddb_major, dev->nr));
2236 DDB_ID(DDVID, 0x0003, DDVID, 0x0030, ddb_dvbct), 3448 ddbs[dev->nr] = NULL;
2237 DDB_ID(DDVID, 0x0003, DDVID, 0xdb03, ddb_satixS2v3), 3449 dev->ddb_dev = ERR_PTR(-ENODEV);
2238 DDB_ID(DDVID, 0x0006, DDVID, 0x0031, ddb_ctv7), 3450 } else
2239 DDB_ID(DDVID, 0x0006, DDVID, 0x0032, ddb_ctv7), 3451 ddb_num++;
2240 DDB_ID(DDVID, 0x0006, DDVID, 0x0033, ddb_ctv7), 3452fail:
2241 DDB_ID(DDVID, 0x0008, DDVID, 0x0034, ddb_ct2_8), 3453 mutex_unlock(&ddb_mutex);
2242 DDB_ID(DDVID, 0x0008, DDVID, 0x0035, ddb_c2t2_8), 3454 return res;
2243 DDB_ID(DDVID, 0x0008, DDVID, 0x0036, ddb_isdbt_8), 3455}
2244 DDB_ID(DDVID, 0x0008, DDVID, 0x0037, ddb_c2t2i_v0_8),
2245 DDB_ID(DDVID, 0x0008, DDVID, 0x0038, ddb_c2t2i_8),
2246 DDB_ID(DDVID, 0x0006, DDVID, 0x0039, ddb_ctv7),
2247 /* in case sub-ids got deleted in flash */
2248 DDB_ID(DDVID, 0x0003, PCI_ANY_ID, PCI_ANY_ID, ddb_none),
2249 DDB_ID(DDVID, 0x0005, PCI_ANY_ID, PCI_ANY_ID, ddb_none),
2250 DDB_ID(DDVID, 0x0006, PCI_ANY_ID, PCI_ANY_ID, ddb_none),
2251 DDB_ID(DDVID, 0x0007, PCI_ANY_ID, PCI_ANY_ID, ddb_none),
2252 DDB_ID(DDVID, 0x0008, PCI_ANY_ID, PCI_ANY_ID, ddb_none),
2253 DDB_ID(DDVID, 0x0011, PCI_ANY_ID, PCI_ANY_ID, ddb_none),
2254 DDB_ID(DDVID, 0x0013, PCI_ANY_ID, PCI_ANY_ID, ddb_none),
2255 DDB_ID(DDVID, 0x0201, PCI_ANY_ID, PCI_ANY_ID, ddb_none),
2256 DDB_ID(DDVID, 0x0320, PCI_ANY_ID, PCI_ANY_ID, ddb_none),
2257 {0}
2258};
2259MODULE_DEVICE_TABLE(pci, ddb_id_tbl);
2260 3456
3457void ddb_device_destroy(struct ddb *dev)
3458{
3459 if (IS_ERR(dev->ddb_dev))
3460 return;
3461 ddb_device_attrs_del(dev);
3462 device_destroy(&ddb_class, MKDEV(ddb_major, dev->nr));
3463}
2261 3464
2262static struct pci_driver ddb_pci_driver = { 3465/****************************************************************************/
2263 .name = "DDBridge", 3466/****************************************************************************/
2264 .id_table = ddb_id_tbl, 3467/****************************************************************************/
2265 .probe = ddb_probe,
2266 .remove = ddb_remove,
2267};
2268 3468
2269static __init int module_init_ddbridge(void) 3469static void tempmon_setfan(struct ddb_link *link)
2270{ 3470{
2271 int ret; 3471 u32 temp, temp2, pwm;
3472
3473 if ((ddblreadl(link, TEMPMON_CONTROL) &
3474 TEMPMON_CONTROL_OVERTEMP) != 0) {
3475 dev_info(link->dev->dev, "Over temperature condition\n");
3476 link->overtemperature_error = 1;
3477 }
3478 temp = (ddblreadl(link, TEMPMON_SENSOR0) >> 8) & 0xFF;
3479 if (temp & 0x80)
3480 temp = 0;
3481 temp2 = (ddblreadl(link, TEMPMON_SENSOR1) >> 8) & 0xFF;
3482 if (temp2 & 0x80)
3483 temp2 = 0;
3484 if (temp2 > temp)
3485 temp = temp2;
3486
3487 pwm = (ddblreadl(link, TEMPMON_FANCONTROL) >> 8) & 0x0F;
3488 if (pwm > 10)
3489 pwm = 10;
3490
3491 if (temp >= link->temp_tab[pwm]) {
3492 while (pwm < 10 && temp >= link->temp_tab[pwm + 1])
3493 pwm += 1;
3494 } else {
3495 while (pwm > 1 && temp < link->temp_tab[pwm - 2])
3496 pwm -= 1;
3497 }
3498 ddblwritel(link, (pwm << 8), TEMPMON_FANCONTROL);
3499}
2272 3500
2273 pr_info("Digital Devices PCIE bridge driver, Copyright (C) 2010-11 Digital Devices GmbH\n"); 3501static void temp_handler(unsigned long data)
3502{
3503 struct ddb_link *link = (struct ddb_link *) data;
2274 3504
2275 ret = ddb_class_create(); 3505 spin_lock(&link->temp_lock);
2276 if (ret < 0) 3506 tempmon_setfan(link);
2277 return ret; 3507 spin_unlock(&link->temp_lock);
2278 ret = pci_register_driver(&ddb_pci_driver); 3508}
2279 if (ret < 0) 3509
2280 ddb_class_destroy(); 3510static int tempmon_init(struct ddb_link *link, int first_time)
2281 return ret; 3511{
3512 struct ddb *dev = link->dev;
3513 int status = 0;
3514 u32 l = link->nr;
3515
3516 spin_lock_irq(&link->temp_lock);
3517 if (first_time) {
3518 static u8 temperature_table[11] = {
3519 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80 };
3520
3521 memcpy(link->temp_tab, temperature_table,
3522 sizeof(temperature_table));
3523 }
3524 dev->handler[l][link->info->tempmon_irq] = temp_handler;
3525 dev->handler_data[l][link->info->tempmon_irq] = (unsigned long) link;
3526 ddblwritel(link, (TEMPMON_CONTROL_OVERTEMP | TEMPMON_CONTROL_AUTOSCAN |
3527 TEMPMON_CONTROL_INTENABLE),
3528 TEMPMON_CONTROL);
3529 ddblwritel(link, (3 << 8), TEMPMON_FANCONTROL);
3530
3531 link->overtemperature_error =
3532 ((ddblreadl(link, TEMPMON_CONTROL) &
3533 TEMPMON_CONTROL_OVERTEMP) != 0);
3534 if (link->overtemperature_error) {
3535 dev_info(link->dev->dev, "Over temperature condition\n");
3536 status = -1;
3537 }
3538 tempmon_setfan(link);
3539 spin_unlock_irq(&link->temp_lock);
3540 return status;
2282} 3541}
2283 3542
2284static __exit void module_exit_ddbridge(void) 3543static int ddb_init_tempmon(struct ddb_link *link)
2285{ 3544{
2286 pci_unregister_driver(&ddb_pci_driver); 3545 const struct ddb_info *info = link->info;
2287 ddb_class_destroy(); 3546
3547 if (!info->tempmon_irq)
3548 return 0;
3549 if (info->type == DDB_OCTOPUS_MAX_CT)
3550 if (link->ids.regmapid < 0x00010002)
3551 return 0;
3552 spin_lock_init(&link->temp_lock);
3553 dev_dbg(link->dev->dev, "init_tempmon\n");
3554 return tempmon_init(link, 1);
3555}
3556
3557/****************************************************************************/
3558/****************************************************************************/
3559/****************************************************************************/
3560
3561static int ddb_init_boards(struct ddb *dev)
3562{
3563 const struct ddb_info *info;
3564 struct ddb_link *link;
3565 u32 l;
3566
3567 for (l = 0; l < DDB_MAX_LINK; l++) {
3568 link = &dev->link[l];
3569 info = link->info;
3570
3571 if (!info)
3572 continue;
3573 if (info->board_control) {
3574 ddbwritel(dev, 0, DDB_LINK_TAG(l) | BOARD_CONTROL);
3575 msleep(100);
3576 ddbwritel(dev, info->board_control_2,
3577 DDB_LINK_TAG(l) | BOARD_CONTROL);
3578 usleep_range(2000, 3000);
3579 ddbwritel(dev,
3580 info->board_control_2 | info->board_control,
3581 DDB_LINK_TAG(l) | BOARD_CONTROL);
3582 usleep_range(2000, 3000);
3583 }
3584 ddb_init_tempmon(link);
3585 }
3586 return 0;
2288} 3587}
2289 3588
2290module_init(module_init_ddbridge); 3589int ddb_init(struct ddb *dev)
2291module_exit(module_exit_ddbridge); 3590{
3591 mutex_init(&dev->link[0].lnb.lock);
3592 mutex_init(&dev->link[0].flash_mutex);
3593 if (no_init) {
3594 ddb_device_create(dev);
3595 return 0;
3596 }
3597
3598 ddb_init_boards(dev);
3599
3600 if (ddb_i2c_init(dev) < 0)
3601 goto fail;
3602 ddb_ports_init(dev);
3603 if (ddb_buffers_alloc(dev) < 0) {
3604 dev_info(dev->dev, "Could not allocate buffer memory\n");
3605 goto fail2;
3606 }
3607 if (ddb_ports_attach(dev) < 0)
3608 goto fail3;
3609
3610 ddb_device_create(dev);
3611
3612 if (dev->link[0].info->fan_num) {
3613 ddbwritel(dev, 1, GPIO_DIRECTION);
3614 ddbwritel(dev, 1, GPIO_OUTPUT);
3615 }
3616 return 0;
3617
3618fail3:
3619 ddb_ports_detach(dev);
3620 dev_err(dev->dev, "fail3\n");
3621 ddb_ports_release(dev);
3622fail2:
3623 dev_err(dev->dev, "fail2\n");
3624 ddb_buffers_free(dev);
3625 ddb_i2c_release(dev);
3626fail:
3627 dev_err(dev->dev, "fail1\n");
3628 return -1;
3629}
2292 3630
2293MODULE_DESCRIPTION("Digital Devices PCIe Bridge"); 3631void ddb_unmap(struct ddb *dev)
2294MODULE_AUTHOR("Ralph Metzler"); 3632{
2295MODULE_LICENSE("GPL"); 3633 if (dev->regs)
2296MODULE_VERSION("0.5"); 3634 iounmap(dev->regs);
3635 vfree(dev);
3636}
diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.c b/drivers/media/pci/ddbridge/ddbridge-hw.c
new file mode 100644
index 000000000000..48248bcd59c2
--- /dev/null
+++ b/drivers/media/pci/ddbridge/ddbridge-hw.c
@@ -0,0 +1,376 @@
1/*
2 * ddbridge-hw.c: Digital Devices bridge hardware maps
3 *
4 * Copyright (C) 2010-2017 Digital Devices GmbH
5 * Ralph Metzler <rjkm@metzlerbros.de>
6 * Marcus Metzler <mocm@metzlerbros.de>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 only, as 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 */
18
19#include "ddbridge.h"
20#include "ddbridge-hw.h"
21
22/******************************************************************************/
23
24static const struct ddb_regset octopus_input = {
25 .base = 0x200,
26 .num = 0x08,
27 .size = 0x10,
28};
29
30static const struct ddb_regset octopus_output = {
31 .base = 0x280,
32 .num = 0x08,
33 .size = 0x10,
34};
35
36static const struct ddb_regset octopus_idma = {
37 .base = 0x300,
38 .num = 0x08,
39 .size = 0x10,
40};
41
42static const struct ddb_regset octopus_idma_buf = {
43 .base = 0x2000,
44 .num = 0x08,
45 .size = 0x100,
46};
47
48static const struct ddb_regset octopus_odma = {
49 .base = 0x380,
50 .num = 0x04,
51 .size = 0x10,
52};
53
54static const struct ddb_regset octopus_odma_buf = {
55 .base = 0x2800,
56 .num = 0x04,
57 .size = 0x100,
58};
59
60static const struct ddb_regset octopus_i2c = {
61 .base = 0x80,
62 .num = 0x04,
63 .size = 0x20,
64};
65
66static const struct ddb_regset octopus_i2c_buf = {
67 .base = 0x1000,
68 .num = 0x04,
69 .size = 0x200,
70};
71
72/****************************************************************************/
73
74static const struct ddb_regmap octopus_map = {
75 .irq_base_i2c = 0,
76 .irq_base_idma = 8,
77 .irq_base_odma = 16,
78 .i2c = &octopus_i2c,
79 .i2c_buf = &octopus_i2c_buf,
80 .idma = &octopus_idma,
81 .idma_buf = &octopus_idma_buf,
82 .odma = &octopus_odma,
83 .odma_buf = &octopus_odma_buf,
84 .input = &octopus_input,
85 .output = &octopus_output,
86};
87
88/****************************************************************************/
89
90static const struct ddb_info ddb_none = {
91 .type = DDB_NONE,
92 .name = "unknown Digital Devices PCIe card, install newer driver",
93 .regmap = &octopus_map,
94};
95
96static const struct ddb_info ddb_octopus = {
97 .type = DDB_OCTOPUS,
98 .name = "Digital Devices Octopus DVB adapter",
99 .regmap = &octopus_map,
100 .port_num = 4,
101 .i2c_mask = 0x0f,
102};
103
104static const struct ddb_info ddb_octopusv3 = {
105 .type = DDB_OCTOPUS,
106 .name = "Digital Devices Octopus V3 DVB adapter",
107 .regmap = &octopus_map,
108 .port_num = 4,
109 .i2c_mask = 0x0f,
110};
111
112static const struct ddb_info ddb_octopus_le = {
113 .type = DDB_OCTOPUS,
114 .name = "Digital Devices Octopus LE DVB adapter",
115 .regmap = &octopus_map,
116 .port_num = 2,
117 .i2c_mask = 0x03,
118};
119
120static const struct ddb_info ddb_octopus_oem = {
121 .type = DDB_OCTOPUS,
122 .name = "Digital Devices Octopus OEM",
123 .regmap = &octopus_map,
124 .port_num = 4,
125 .i2c_mask = 0x0f,
126 .led_num = 1,
127 .fan_num = 1,
128 .temp_num = 1,
129 .temp_bus = 0,
130};
131
132static const struct ddb_info ddb_octopus_mini = {
133 .type = DDB_OCTOPUS,
134 .name = "Digital Devices Octopus Mini",
135 .regmap = &octopus_map,
136 .port_num = 4,
137 .i2c_mask = 0x0f,
138};
139
140static const struct ddb_info ddb_v6 = {
141 .type = DDB_OCTOPUS,
142 .name = "Digital Devices Cine S2 V6 DVB adapter",
143 .regmap = &octopus_map,
144 .port_num = 3,
145 .i2c_mask = 0x07,
146};
147
148static const struct ddb_info ddb_v6_5 = {
149 .type = DDB_OCTOPUS,
150 .name = "Digital Devices Cine S2 V6.5 DVB adapter",
151 .regmap = &octopus_map,
152 .port_num = 4,
153 .i2c_mask = 0x0f,
154};
155
156static const struct ddb_info ddb_v7 = {
157 .type = DDB_OCTOPUS,
158 .name = "Digital Devices Cine S2 V7 DVB adapter",
159 .regmap = &octopus_map,
160 .port_num = 4,
161 .i2c_mask = 0x0f,
162 .board_control = 2,
163 .board_control_2 = 4,
164 .ts_quirks = TS_QUIRK_REVERSED,
165};
166
167static const struct ddb_info ddb_v7a = {
168 .type = DDB_OCTOPUS,
169 .name = "Digital Devices Cine S2 V7 Advanced DVB adapter",
170 .regmap = &octopus_map,
171 .port_num = 4,
172 .i2c_mask = 0x0f,
173 .board_control = 2,
174 .board_control_2 = 4,
175 .ts_quirks = TS_QUIRK_REVERSED,
176};
177
178static const struct ddb_info ddb_ctv7 = {
179 .type = DDB_OCTOPUS,
180 .name = "Digital Devices Cine CT V7 DVB adapter",
181 .regmap = &octopus_map,
182 .port_num = 4,
183 .i2c_mask = 0x0f,
184 .board_control = 3,
185 .board_control_2 = 4,
186};
187
188static const struct ddb_info ddb_satixS2v3 = {
189 .type = DDB_OCTOPUS,
190 .name = "Mystique SaTiX-S2 V3 DVB adapter",
191 .regmap = &octopus_map,
192 .port_num = 3,
193 .i2c_mask = 0x07,
194};
195
196static const struct ddb_info ddb_ci = {
197 .type = DDB_OCTOPUS_CI,
198 .name = "Digital Devices Octopus CI",
199 .regmap = &octopus_map,
200 .port_num = 4,
201 .i2c_mask = 0x03,
202};
203
204static const struct ddb_info ddb_cis = {
205 .type = DDB_OCTOPUS_CI,
206 .name = "Digital Devices Octopus CI single",
207 .regmap = &octopus_map,
208 .port_num = 3,
209 .i2c_mask = 0x03,
210};
211
212static const struct ddb_info ddb_ci_s2_pro = {
213 .type = DDB_OCTOPUS_CI,
214 .name = "Digital Devices Octopus CI S2 Pro",
215 .regmap = &octopus_map,
216 .port_num = 4,
217 .i2c_mask = 0x01,
218 .board_control = 2,
219 .board_control_2 = 4,
220};
221
222static const struct ddb_info ddb_ci_s2_pro_a = {
223 .type = DDB_OCTOPUS_CI,
224 .name = "Digital Devices Octopus CI S2 Pro Advanced",
225 .regmap = &octopus_map,
226 .port_num = 4,
227 .i2c_mask = 0x01,
228 .board_control = 2,
229 .board_control_2 = 4,
230};
231
232static const struct ddb_info ddb_dvbct = {
233 .type = DDB_OCTOPUS,
234 .name = "Digital Devices DVBCT V6.1 DVB adapter",
235 .regmap = &octopus_map,
236 .port_num = 3,
237 .i2c_mask = 0x07,
238};
239
240/****************************************************************************/
241
242static const struct ddb_info ddb_ct2_8 = {
243 .type = DDB_OCTOPUS_MAX_CT,
244 .name = "Digital Devices MAX A8 CT2",
245 .regmap = &octopus_map,
246 .port_num = 4,
247 .i2c_mask = 0x0f,
248 .board_control = 0x0ff,
249 .board_control_2 = 0xf00,
250 .ts_quirks = TS_QUIRK_SERIAL,
251 .tempmon_irq = 24,
252};
253
254static const struct ddb_info ddb_c2t2_8 = {
255 .type = DDB_OCTOPUS_MAX_CT,
256 .name = "Digital Devices MAX A8 C2T2",
257 .regmap = &octopus_map,
258 .port_num = 4,
259 .i2c_mask = 0x0f,
260 .board_control = 0x0ff,
261 .board_control_2 = 0xf00,
262 .ts_quirks = TS_QUIRK_SERIAL,
263 .tempmon_irq = 24,
264};
265
266static const struct ddb_info ddb_isdbt_8 = {
267 .type = DDB_OCTOPUS_MAX_CT,
268 .name = "Digital Devices MAX A8 ISDBT",
269 .regmap = &octopus_map,
270 .port_num = 4,
271 .i2c_mask = 0x0f,
272 .board_control = 0x0ff,
273 .board_control_2 = 0xf00,
274 .ts_quirks = TS_QUIRK_SERIAL,
275 .tempmon_irq = 24,
276};
277
278static const struct ddb_info ddb_c2t2i_v0_8 = {
279 .type = DDB_OCTOPUS_MAX_CT,
280 .name = "Digital Devices MAX A8 C2T2I V0",
281 .regmap = &octopus_map,
282 .port_num = 4,
283 .i2c_mask = 0x0f,
284 .board_control = 0x0ff,
285 .board_control_2 = 0xf00,
286 .ts_quirks = TS_QUIRK_SERIAL | TS_QUIRK_ALT_OSC,
287 .tempmon_irq = 24,
288};
289
290static const struct ddb_info ddb_c2t2i_8 = {
291 .type = DDB_OCTOPUS_MAX_CT,
292 .name = "Digital Devices MAX A8 C2T2I",
293 .regmap = &octopus_map,
294 .port_num = 4,
295 .i2c_mask = 0x0f,
296 .board_control = 0x0ff,
297 .board_control_2 = 0xf00,
298 .ts_quirks = TS_QUIRK_SERIAL,
299 .tempmon_irq = 24,
300};
301
302/****************************************************************************/
303
304static const struct ddb_info ddb_s2_48 = {
305 .type = DDB_OCTOPUS_MAX,
306 .name = "Digital Devices MAX S8 4/8",
307 .regmap = &octopus_map,
308 .port_num = 4,
309 .i2c_mask = 0x01,
310 .board_control = 1,
311 .tempmon_irq = 24,
312};
313
314/****************************************************************************/
315/****************************************************************************/
316/****************************************************************************/
317
318#define DDB_DEVID(_device, _subdevice, _info) { \
319 .vendor = DDVID, \
320 .device = _device, \
321 .subvendor = DDVID, \
322 .subdevice = _subdevice, \
323 .info = &_info }
324
325static const struct ddb_device_id ddb_device_ids[] = {
326 /* PCIe devices */
327 DDB_DEVID(0x0002, 0x0001, ddb_octopus),
328 DDB_DEVID(0x0003, 0x0001, ddb_octopus),
329 DDB_DEVID(0x0005, 0x0004, ddb_octopusv3),
330 DDB_DEVID(0x0003, 0x0002, ddb_octopus_le),
331 DDB_DEVID(0x0003, 0x0003, ddb_octopus_oem),
332 DDB_DEVID(0x0003, 0x0010, ddb_octopus_mini),
333 DDB_DEVID(0x0005, 0x0011, ddb_octopus_mini),
334 DDB_DEVID(0x0003, 0x0020, ddb_v6),
335 DDB_DEVID(0x0003, 0x0021, ddb_v6_5),
336 DDB_DEVID(0x0006, 0x0022, ddb_v7),
337 DDB_DEVID(0x0006, 0x0024, ddb_v7a),
338 DDB_DEVID(0x0003, 0x0030, ddb_dvbct),
339 DDB_DEVID(0x0003, 0xdb03, ddb_satixS2v3),
340 DDB_DEVID(0x0006, 0x0031, ddb_ctv7),
341 DDB_DEVID(0x0006, 0x0032, ddb_ctv7),
342 DDB_DEVID(0x0006, 0x0033, ddb_ctv7),
343 DDB_DEVID(0x0007, 0x0023, ddb_s2_48),
344 DDB_DEVID(0x0008, 0x0034, ddb_ct2_8),
345 DDB_DEVID(0x0008, 0x0035, ddb_c2t2_8),
346 DDB_DEVID(0x0008, 0x0036, ddb_isdbt_8),
347 DDB_DEVID(0x0008, 0x0037, ddb_c2t2i_v0_8),
348 DDB_DEVID(0x0008, 0x0038, ddb_c2t2i_8),
349 DDB_DEVID(0x0006, 0x0039, ddb_ctv7),
350 DDB_DEVID(0x0011, 0x0040, ddb_ci),
351 DDB_DEVID(0x0011, 0x0041, ddb_cis),
352 DDB_DEVID(0x0012, 0x0042, ddb_ci),
353 DDB_DEVID(0x0013, 0x0043, ddb_ci_s2_pro),
354 DDB_DEVID(0x0013, 0x0044, ddb_ci_s2_pro_a),
355};
356
357/****************************************************************************/
358
359const struct ddb_info *get_ddb_info(u16 vendor, u16 device,
360 u16 subvendor, u16 subdevice)
361{
362 int i;
363
364 for (i = 0; i < ARRAY_SIZE(ddb_device_ids); i++) {
365 const struct ddb_device_id *id = &ddb_device_ids[i];
366
367 if (vendor == id->vendor &&
368 device == id->device &&
369 subvendor == id->subvendor &&
370 ((subdevice == id->subdevice) ||
371 (id->subdevice == 0xffff)))
372 return id->info;
373 }
374
375 return &ddb_none;
376}
diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.h b/drivers/media/pci/ddbridge/ddbridge-hw.h
new file mode 100644
index 000000000000..7c142419419c
--- /dev/null
+++ b/drivers/media/pci/ddbridge/ddbridge-hw.h
@@ -0,0 +1,43 @@
1/*
2 * ddbridge-hw.h: Digital Devices bridge hardware maps
3 *
4 * Copyright (C) 2010-2017 Digital Devices GmbH
5 * Ralph Metzler <rjkm@metzlerbros.de>
6 * Marcus Metzler <mocm@metzlerbros.de>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 only, as 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 */
18
19#ifndef _DDBRIDGE_HW_H_
20#define _DDBRIDGE_HW_H_
21
22#include "ddbridge.h"
23
24/******************************************************************************/
25
26#define DDVID 0xdd01 /* Digital Devices Vendor ID */
27
28/******************************************************************************/
29
30struct ddb_device_id {
31 u16 vendor;
32 u16 device;
33 u16 subvendor;
34 u16 subdevice;
35 const struct ddb_info *info;
36};
37
38/******************************************************************************/
39
40const struct ddb_info *get_ddb_info(u16 vendor, u16 device,
41 u16 subvendor, u16 subdevice);
42
43#endif /* _DDBRIDGE_HW_H */
diff --git a/drivers/media/pci/ddbridge/ddbridge-i2c.c b/drivers/media/pci/ddbridge/ddbridge-i2c.c
new file mode 100644
index 000000000000..e4d39c3270ae
--- /dev/null
+++ b/drivers/media/pci/ddbridge/ddbridge-i2c.c
@@ -0,0 +1,230 @@
1/*
2 * ddbridge-i2c.c: Digital Devices bridge i2c driver
3 *
4 * Copyright (C) 2010-2017 Digital Devices GmbH
5 * Ralph Metzler <rjkm@metzlerbros.de>
6 * Marcus Metzler <mocm@metzlerbros.de>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 only, as 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 */
18
19#include <linux/module.h>
20#include <linux/init.h>
21#include <linux/interrupt.h>
22#include <linux/delay.h>
23#include <linux/slab.h>
24#include <linux/poll.h>
25#include <linux/io.h>
26#include <linux/pci.h>
27#include <linux/pci_ids.h>
28#include <linux/timer.h>
29#include <linux/i2c.h>
30#include <linux/swab.h>
31#include <linux/vmalloc.h>
32
33#include "ddbridge.h"
34#include "ddbridge-i2c.h"
35#include "ddbridge-regs.h"
36#include "ddbridge-io.h"
37
38/******************************************************************************/
39
40static int ddb_i2c_cmd(struct ddb_i2c *i2c, u32 adr, u32 cmd)
41{
42 struct ddb *dev = i2c->dev;
43 unsigned long stat;
44 u32 val;
45
46 ddbwritel(dev, (adr << 9) | cmd, i2c->regs + I2C_COMMAND);
47 stat = wait_for_completion_timeout(&i2c->completion, HZ);
48 val = ddbreadl(dev, i2c->regs + I2C_COMMAND);
49 if (stat == 0) {
50 dev_err(dev->dev, "I2C timeout, card %d, port %d, link %u\n",
51 dev->nr, i2c->nr, i2c->link);
52 {
53 u32 istat = ddbreadl(dev, INTERRUPT_STATUS);
54
55 dev_err(dev->dev, "DDBridge IRS %08x\n", istat);
56 if (i2c->link) {
57 u32 listat = ddbreadl(dev,
58 DDB_LINK_TAG(i2c->link) |
59 INTERRUPT_STATUS);
60
61 dev_err(dev->dev, "DDBridge link %u IRS %08x\n",
62 i2c->link, listat);
63 }
64 if (istat & 1) {
65 ddbwritel(dev, istat & 1, INTERRUPT_ACK);
66 } else {
67 u32 mon = ddbreadl(dev,
68 i2c->regs + I2C_MONITOR);
69
70 dev_err(dev->dev, "I2C cmd=%08x mon=%08x\n",
71 val, mon);
72 }
73 }
74 return -EIO;
75 }
76 if (val & 0x70000)
77 return -EIO;
78 return 0;
79}
80
81static int ddb_i2c_master_xfer(struct i2c_adapter *adapter,
82 struct i2c_msg msg[], int num)
83{
84 struct ddb_i2c *i2c = (struct ddb_i2c *) i2c_get_adapdata(adapter);
85 struct ddb *dev = i2c->dev;
86 u8 addr = 0;
87
88 addr = msg[0].addr;
89 if (msg[0].len > i2c->bsize)
90 return -EIO;
91 switch (num) {
92 case 1:
93 if (msg[0].flags & I2C_M_RD) {
94 ddbwritel(dev, msg[0].len << 16,
95 i2c->regs + I2C_TASKLENGTH);
96 if (ddb_i2c_cmd(i2c, addr, 3))
97 break;
98 ddbcpyfrom(dev, msg[0].buf,
99 i2c->rbuf, msg[0].len);
100 return num;
101 }
102 ddbcpyto(dev, i2c->wbuf, msg[0].buf, msg[0].len);
103 ddbwritel(dev, msg[0].len, i2c->regs + I2C_TASKLENGTH);
104 if (ddb_i2c_cmd(i2c, addr, 2))
105 break;
106 return num;
107 case 2:
108 if ((msg[0].flags & I2C_M_RD) == I2C_M_RD)
109 break;
110 if ((msg[1].flags & I2C_M_RD) != I2C_M_RD)
111 break;
112 if (msg[1].len > i2c->bsize)
113 break;
114 ddbcpyto(dev, i2c->wbuf, msg[0].buf, msg[0].len);
115 ddbwritel(dev, msg[0].len | (msg[1].len << 16),
116 i2c->regs + I2C_TASKLENGTH);
117 if (ddb_i2c_cmd(i2c, addr, 1))
118 break;
119 ddbcpyfrom(dev, msg[1].buf,
120 i2c->rbuf,
121 msg[1].len);
122 return num;
123 default:
124 break;
125 }
126 return -EIO;
127}
128
129static u32 ddb_i2c_functionality(struct i2c_adapter *adap)
130{
131 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
132}
133
134static const struct i2c_algorithm ddb_i2c_algo = {
135 .master_xfer = ddb_i2c_master_xfer,
136 .functionality = ddb_i2c_functionality,
137};
138
139void ddb_i2c_release(struct ddb *dev)
140{
141 int i;
142 struct ddb_i2c *i2c;
143
144 for (i = 0; i < dev->i2c_num; i++) {
145 i2c = &dev->i2c[i];
146 i2c_del_adapter(&i2c->adap);
147 }
148}
149
150static void i2c_handler(unsigned long priv)
151{
152 struct ddb_i2c *i2c = (struct ddb_i2c *) priv;
153
154 complete(&i2c->completion);
155}
156
157static int ddb_i2c_add(struct ddb *dev, struct ddb_i2c *i2c,
158 const struct ddb_regmap *regmap, int link,
159 int i, int num)
160{
161 struct i2c_adapter *adap;
162
163 i2c->nr = i;
164 i2c->dev = dev;
165 i2c->link = link;
166 i2c->bsize = regmap->i2c_buf->size;
167 i2c->wbuf = DDB_LINK_TAG(link) |
168 (regmap->i2c_buf->base + i2c->bsize * i);
169 i2c->rbuf = i2c->wbuf; /* + i2c->bsize / 2 */
170 i2c->regs = DDB_LINK_TAG(link) |
171 (regmap->i2c->base + regmap->i2c->size * i);
172 ddbwritel(dev, I2C_SPEED_100, i2c->regs + I2C_TIMING);
173 ddbwritel(dev, ((i2c->rbuf & 0xffff) << 16) | (i2c->wbuf & 0xffff),
174 i2c->regs + I2C_TASKADDRESS);
175 init_completion(&i2c->completion);
176
177 adap = &i2c->adap;
178 i2c_set_adapdata(adap, i2c);
179#ifdef I2C_ADAP_CLASS_TV_DIGITAL
180 adap->class = I2C_ADAP_CLASS_TV_DIGITAL|I2C_CLASS_TV_ANALOG;
181#else
182#ifdef I2C_CLASS_TV_ANALOG
183 adap->class = I2C_CLASS_TV_ANALOG;
184#endif
185#endif
186 snprintf(adap->name, I2C_NAME_SIZE, "ddbridge_%02x.%x.%x",
187 dev->nr, i2c->link, i);
188 adap->algo = &ddb_i2c_algo;
189 adap->algo_data = (void *)i2c;
190 adap->dev.parent = dev->dev;
191 return i2c_add_adapter(adap);
192}
193
194int ddb_i2c_init(struct ddb *dev)
195{
196 int stat = 0;
197 u32 i, j, num = 0, l, base;
198 struct ddb_i2c *i2c;
199 struct i2c_adapter *adap;
200 const struct ddb_regmap *regmap;
201
202 for (l = 0; l < DDB_MAX_LINK; l++) {
203 if (!dev->link[l].info)
204 continue;
205 regmap = dev->link[l].info->regmap;
206 if (!regmap || !regmap->i2c)
207 continue;
208 base = regmap->irq_base_i2c;
209 for (i = 0; i < regmap->i2c->num; i++) {
210 if (!(dev->link[l].info->i2c_mask & (1 << i)))
211 continue;
212 i2c = &dev->i2c[num];
213 dev->handler_data[l][i + base] = (unsigned long) i2c;
214 dev->handler[l][i + base] = i2c_handler;
215 stat = ddb_i2c_add(dev, i2c, regmap, l, i, num);
216 if (stat)
217 break;
218 num++;
219 }
220 }
221 if (stat) {
222 for (j = 0; j < num; j++) {
223 i2c = &dev->i2c[j];
224 adap = &i2c->adap;
225 i2c_del_adapter(adap);
226 }
227 } else
228 dev->i2c_num = num;
229 return stat;
230}
diff --git a/drivers/media/pci/ddbridge/ddbridge-i2c.h b/drivers/media/pci/ddbridge/ddbridge-i2c.h
new file mode 100644
index 000000000000..7ed220506c05
--- /dev/null
+++ b/drivers/media/pci/ddbridge/ddbridge-i2c.h
@@ -0,0 +1,112 @@
1/*
2 * ddbridge-i2c.c: Digital Devices bridge i2c driver
3 *
4 * Copyright (C) 2010-2017 Digital Devices GmbH
5 * Ralph Metzler <rjkm@metzlerbros.de>
6 * Marcus Metzler <mocm@metzlerbros.de>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 only, as 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 */
18
19#ifndef __DDBRIDGE_I2C_H__
20#define __DDBRIDGE_I2C_H__
21
22#include <linux/i2c.h>
23
24#include "ddbridge.h"
25
26/******************************************************************************/
27
28void ddb_i2c_release(struct ddb *dev);
29int ddb_i2c_init(struct ddb *dev);
30
31/******************************************************************************/
32
33static int __maybe_unused i2c_io(struct i2c_adapter *adapter, u8 adr,
34 u8 *wbuf, u32 wlen, u8 *rbuf, u32 rlen)
35{
36 struct i2c_msg msgs[2] = { { .addr = adr, .flags = 0,
37 .buf = wbuf, .len = wlen },
38 { .addr = adr, .flags = I2C_M_RD,
39 .buf = rbuf, .len = rlen } };
40
41 return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1;
42}
43
44static int __maybe_unused i2c_write(struct i2c_adapter *adap, u8 adr,
45 u8 *data, int len)
46{
47 struct i2c_msg msg = { .addr = adr, .flags = 0,
48 .buf = data, .len = len };
49
50 return (i2c_transfer(adap, &msg, 1) == 1) ? 0 : -1;
51}
52
53static int __maybe_unused i2c_read(struct i2c_adapter *adapter, u8 adr, u8 *val)
54{
55 struct i2c_msg msgs[1] = { { .addr = adr, .flags = I2C_M_RD,
56 .buf = val, .len = 1 } };
57
58 return (i2c_transfer(adapter, msgs, 1) == 1) ? 0 : -1;
59}
60
61static int __maybe_unused i2c_read_regs(struct i2c_adapter *adapter,
62 u8 adr, u8 reg, u8 *val, u8 len)
63{
64 struct i2c_msg msgs[2] = { { .addr = adr, .flags = 0,
65 .buf = &reg, .len = 1 },
66 { .addr = adr, .flags = I2C_M_RD,
67 .buf = val, .len = len } };
68
69 return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1;
70}
71
72static int __maybe_unused i2c_read_regs16(struct i2c_adapter *adapter,
73 u8 adr, u16 reg, u8 *val, u8 len)
74{
75 u8 msg[2] = { reg >> 8, reg & 0xff };
76 struct i2c_msg msgs[2] = { { .addr = adr, .flags = 0,
77 .buf = msg, .len = 2 },
78 { .addr = adr, .flags = I2C_M_RD,
79 .buf = val, .len = len } };
80
81 return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1;
82}
83
84static int __maybe_unused i2c_write_reg16(struct i2c_adapter *adap,
85 u8 adr, u16 reg, u8 val)
86{
87 u8 msg[3] = { reg >> 8, reg & 0xff, val };
88
89 return i2c_write(adap, adr, msg, 3);
90}
91
92static int __maybe_unused i2c_write_reg(struct i2c_adapter *adap,
93 u8 adr, u8 reg, u8 val)
94{
95 u8 msg[2] = { reg, val };
96
97 return i2c_write(adap, adr, msg, 2);
98}
99
100static int __maybe_unused i2c_read_reg16(struct i2c_adapter *adapter,
101 u8 adr, u16 reg, u8 *val)
102{
103 return i2c_read_regs16(adapter, adr, reg, val, 1);
104}
105
106static int __maybe_unused i2c_read_reg(struct i2c_adapter *adapter,
107 u8 adr, u8 reg, u8 *val)
108{
109 return i2c_read_regs(adapter, adr, reg, val, 1);
110}
111
112#endif /* __DDBRIDGE_I2C_H__ */
diff --git a/drivers/media/pci/ddbridge/ddbridge-io.h b/drivers/media/pci/ddbridge/ddbridge-io.h
new file mode 100644
index 000000000000..a4c6bbe09168
--- /dev/null
+++ b/drivers/media/pci/ddbridge/ddbridge-io.h
@@ -0,0 +1,71 @@
1/*
2 * ddbridge-io.h: Digital Devices bridge I/O inline functions
3 *
4 * Copyright (C) 2010-2017 Digital Devices GmbH
5 * Ralph Metzler <rjkm@metzlerbros.de>
6 * Marcus Metzler <mocm@metzlerbros.de>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 only, as 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 */
18
19#ifndef __DDBRIDGE_IO_H__
20#define __DDBRIDGE_IO_H__
21
22#include <linux/io.h>
23
24#include "ddbridge.h"
25
26/******************************************************************************/
27
28static inline u32 ddblreadl(struct ddb_link *link, u32 adr)
29{
30 return readl(link->dev->regs + adr);
31}
32
33static inline void ddblwritel(struct ddb_link *link, u32 val, u32 adr)
34{
35 writel(val, link->dev->regs + adr);
36}
37
38static inline u32 ddbreadl(struct ddb *dev, u32 adr)
39{
40 return readl(dev->regs + adr);
41}
42
43static inline void ddbwritel(struct ddb *dev, u32 val, u32 adr)
44{
45 writel(val, dev->regs + adr);
46}
47
48static inline void ddbcpyto(struct ddb *dev, u32 adr, void *src, long count)
49{
50 return memcpy_toio(dev->regs + adr, src, count);
51}
52
53static inline void ddbcpyfrom(struct ddb *dev, void *dst, u32 adr, long count)
54{
55 return memcpy_fromio(dst, dev->regs + adr, count);
56}
57
58static inline u32 safe_ddbreadl(struct ddb *dev, u32 adr)
59{
60 u32 val = ddbreadl(dev, adr);
61
62 /* (ddb)readl returns (uint)-1 (all bits set) on failure, catch that */
63 if (val == ~0) {
64 dev_err(&dev->pdev->dev, "ddbreadl failure, adr=%08x\n", adr);
65 return 0;
66 }
67
68 return val;
69}
70
71#endif /* __DDBRIDGE_IO_H__ */
diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c b/drivers/media/pci/ddbridge/ddbridge-main.c
new file mode 100644
index 000000000000..ccac7fe31336
--- /dev/null
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -0,0 +1,346 @@
1/*
2 * ddbridge.c: Digital Devices PCIe bridge driver
3 *
4 * Copyright (C) 2010-2017 Digital Devices GmbH
5 * Ralph Metzler <rjkm@metzlerbros.de>
6 * Marcus Metzler <mocm@metzlerbros.de>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 only, as 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 */
18
19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20
21#include <linux/module.h>
22#include <linux/init.h>
23#include <linux/interrupt.h>
24#include <linux/delay.h>
25#include <linux/slab.h>
26#include <linux/poll.h>
27#include <linux/io.h>
28#include <linux/pci.h>
29#include <linux/pci_ids.h>
30#include <linux/timer.h>
31#include <linux/i2c.h>
32#include <linux/swab.h>
33#include <linux/vmalloc.h>
34
35#include "ddbridge.h"
36#include "ddbridge-i2c.h"
37#include "ddbridge-regs.h"
38#include "ddbridge-hw.h"
39#include "ddbridge-io.h"
40
41/****************************************************************************/
42/* module parameters */
43
44#ifdef CONFIG_PCI_MSI
45#ifdef CONFIG_DVB_DDBRIDGE_MSIENABLE
46static int msi = 1;
47#else
48static int msi;
49#endif
50module_param(msi, int, 0444);
51#ifdef CONFIG_DVB_DDBRIDGE_MSIENABLE
52MODULE_PARM_DESC(msi, "Control MSI interrupts: 0-disable, 1-enable (default)");
53#else
54MODULE_PARM_DESC(msi, "Control MSI interrupts: 0-disable (default), 1-enable");
55#endif
56#endif
57
58int ci_bitrate = 70000;
59module_param(ci_bitrate, int, 0444);
60MODULE_PARM_DESC(ci_bitrate, " Bitrate in KHz for output to CI.");
61
62int ts_loop = -1;
63module_param(ts_loop, int, 0444);
64MODULE_PARM_DESC(ts_loop, "TS in/out test loop on port ts_loop");
65
66int xo2_speed = 2;
67module_param(xo2_speed, int, 0444);
68MODULE_PARM_DESC(xo2_speed, "default transfer speed for xo2 based duoflex, 0=55,1=75,2=90,3=104 MBit/s, default=2, use attribute to change for individual cards");
69
70#ifdef __arm__
71int alt_dma = 1;
72#else
73int alt_dma;
74#endif
75module_param(alt_dma, int, 0444);
76MODULE_PARM_DESC(alt_dma, "use alternative DMA buffer handling");
77
78int no_init;
79module_param(no_init, int, 0444);
80MODULE_PARM_DESC(no_init, "do not initialize most devices");
81
82int stv0910_single;
83module_param(stv0910_single, int, 0444);
84MODULE_PARM_DESC(stv0910_single, "use stv0910 cards as single demods");
85
86/****************************************************************************/
87/****************************************************************************/
88/****************************************************************************/
89
90static void ddb_irq_disable(struct ddb *dev)
91{
92 ddbwritel(dev, 0, INTERRUPT_ENABLE);
93 ddbwritel(dev, 0, MSI1_ENABLE);
94}
95
96static void ddb_irq_exit(struct ddb *dev)
97{
98 ddb_irq_disable(dev);
99 if (dev->msi == 2)
100 free_irq(dev->pdev->irq + 1, dev);
101 free_irq(dev->pdev->irq, dev);
102#ifdef CONFIG_PCI_MSI
103 if (dev->msi)
104 pci_disable_msi(dev->pdev);
105#endif
106}
107
108static void ddb_remove(struct pci_dev *pdev)
109{
110 struct ddb *dev = (struct ddb *) pci_get_drvdata(pdev);
111
112 ddb_device_destroy(dev);
113 ddb_ports_detach(dev);
114 ddb_i2c_release(dev);
115
116 ddb_irq_exit(dev);
117 ddb_ports_release(dev);
118 ddb_buffers_free(dev);
119
120 ddb_unmap(dev);
121 pci_set_drvdata(pdev, NULL);
122 pci_disable_device(pdev);
123}
124
125#ifdef CONFIG_PCI_MSI
126static void ddb_irq_msi(struct ddb *dev, int nr)
127{
128 int stat;
129
130 if (msi && pci_msi_enabled()) {
131 stat = pci_alloc_irq_vectors(dev->pdev, 1, nr, PCI_IRQ_MSI);
132 if (stat >= 1) {
133 dev->msi = stat;
134 dev_info(dev->dev, "using %d MSI interrupt(s)\n",
135 dev->msi);
136 } else
137 dev_info(dev->dev, "MSI not available.\n");
138 }
139}
140#endif
141
142static int ddb_irq_init(struct ddb *dev)
143{
144 int stat;
145 int irq_flag = IRQF_SHARED;
146
147 ddbwritel(dev, 0x00000000, INTERRUPT_ENABLE);
148 ddbwritel(dev, 0x00000000, MSI1_ENABLE);
149 ddbwritel(dev, 0x00000000, MSI2_ENABLE);
150 ddbwritel(dev, 0x00000000, MSI3_ENABLE);
151 ddbwritel(dev, 0x00000000, MSI4_ENABLE);
152 ddbwritel(dev, 0x00000000, MSI5_ENABLE);
153 ddbwritel(dev, 0x00000000, MSI6_ENABLE);
154 ddbwritel(dev, 0x00000000, MSI7_ENABLE);
155
156#ifdef CONFIG_PCI_MSI
157 ddb_irq_msi(dev, 2);
158
159 if (dev->msi)
160 irq_flag = 0;
161 if (dev->msi == 2) {
162 stat = request_irq(dev->pdev->irq, ddb_irq_handler0,
163 irq_flag, "ddbridge", (void *) dev);
164 if (stat < 0)
165 return stat;
166 stat = request_irq(dev->pdev->irq + 1, ddb_irq_handler1,
167 irq_flag, "ddbridge", (void *) dev);
168 if (stat < 0) {
169 free_irq(dev->pdev->irq, dev);
170 return stat;
171 }
172 } else
173#endif
174 {
175 stat = request_irq(dev->pdev->irq, ddb_irq_handler,
176 irq_flag, "ddbridge", (void *) dev);
177 if (stat < 0)
178 return stat;
179 }
180 if (dev->msi == 2) {
181 ddbwritel(dev, 0x0fffff00, INTERRUPT_ENABLE);
182 ddbwritel(dev, 0x0000000f, MSI1_ENABLE);
183 } else {
184 ddbwritel(dev, 0x0fffff0f, INTERRUPT_ENABLE);
185 ddbwritel(dev, 0x00000000, MSI1_ENABLE);
186 }
187 return stat;
188}
189
190static int ddb_probe(struct pci_dev *pdev,
191 const struct pci_device_id *id)
192{
193 struct ddb *dev;
194 int stat = 0;
195
196 if (pci_enable_device(pdev) < 0)
197 return -ENODEV;
198
199 pci_set_master(pdev);
200
201 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)))
202 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))
203 return -ENODEV;
204
205 dev = vzalloc(sizeof(struct ddb));
206 if (dev == NULL)
207 return -ENOMEM;
208
209 mutex_init(&dev->mutex);
210 dev->has_dma = 1;
211 dev->pdev = pdev;
212 dev->dev = &pdev->dev;
213 pci_set_drvdata(pdev, dev);
214
215 dev->link[0].ids.vendor = id->vendor;
216 dev->link[0].ids.device = id->device;
217 dev->link[0].ids.subvendor = id->subvendor;
218 dev->link[0].ids.subdevice = pdev->subsystem_device;
219
220 dev->link[0].dev = dev;
221 dev->link[0].info = get_ddb_info(id->vendor, id->device,
222 id->subvendor, pdev->subsystem_device);
223
224 dev_info(&pdev->dev, "detected %s\n", dev->link[0].info->name);
225
226 dev->regs_len = pci_resource_len(dev->pdev, 0);
227 dev->regs = ioremap(pci_resource_start(dev->pdev, 0),
228 pci_resource_len(dev->pdev, 0));
229
230 if (!dev->regs) {
231 dev_err(&pdev->dev, "not enough memory for register map\n");
232 stat = -ENOMEM;
233 goto fail;
234 }
235 if (ddbreadl(dev, 0) == 0xffffffff) {
236 dev_err(&pdev->dev, "cannot read registers\n");
237 stat = -ENODEV;
238 goto fail;
239 }
240
241 dev->link[0].ids.hwid = ddbreadl(dev, 0);
242 dev->link[0].ids.regmapid = ddbreadl(dev, 4);
243
244 dev_info(&pdev->dev, "HW %08x REGMAP %08x\n",
245 dev->link[0].ids.hwid, dev->link[0].ids.regmapid);
246
247 ddbwritel(dev, 0, DMA_BASE_READ);
248 ddbwritel(dev, 0, DMA_BASE_WRITE);
249
250 stat = ddb_irq_init(dev);
251 if (stat < 0)
252 goto fail0;
253
254 if (ddb_init(dev) == 0)
255 return 0;
256
257 ddb_irq_exit(dev);
258fail0:
259 dev_err(&pdev->dev, "fail0\n");
260 if (dev->msi)
261 pci_disable_msi(dev->pdev);
262fail:
263 dev_err(&pdev->dev, "fail\n");
264
265 ddb_unmap(dev);
266 pci_set_drvdata(pdev, NULL);
267 pci_disable_device(pdev);
268 return -1;
269}
270
271/****************************************************************************/
272/****************************************************************************/
273/****************************************************************************/
274
275#define DDB_DEVICE_ANY(_device) \
276 { PCI_DEVICE_SUB(DDVID, _device, DDVID, PCI_ANY_ID) }
277
278static const struct pci_device_id ddb_id_table[] = {
279 DDB_DEVICE_ANY(0x0002),
280 DDB_DEVICE_ANY(0x0003),
281 DDB_DEVICE_ANY(0x0005),
282 DDB_DEVICE_ANY(0x0006),
283 DDB_DEVICE_ANY(0x0007),
284 DDB_DEVICE_ANY(0x0008),
285 DDB_DEVICE_ANY(0x0011),
286 DDB_DEVICE_ANY(0x0012),
287 DDB_DEVICE_ANY(0x0013),
288 DDB_DEVICE_ANY(0x0201),
289 DDB_DEVICE_ANY(0x0203),
290 DDB_DEVICE_ANY(0x0210),
291 DDB_DEVICE_ANY(0x0220),
292 DDB_DEVICE_ANY(0x0320),
293 DDB_DEVICE_ANY(0x0321),
294 DDB_DEVICE_ANY(0x0322),
295 DDB_DEVICE_ANY(0x0323),
296 DDB_DEVICE_ANY(0x0328),
297 DDB_DEVICE_ANY(0x0329),
298 {0}
299};
300
301MODULE_DEVICE_TABLE(pci, ddb_id_table);
302
303static struct pci_driver ddb_pci_driver = {
304 .name = "ddbridge",
305 .id_table = ddb_id_table,
306 .probe = ddb_probe,
307 .remove = ddb_remove,
308};
309
310static __init int module_init_ddbridge(void)
311{
312 int stat = -1;
313
314 pr_info("Digital Devices PCIE bridge driver "
315 DDBRIDGE_VERSION
316 ", Copyright (C) 2010-17 Digital Devices GmbH\n");
317 if (ddb_class_create() < 0)
318 return -1;
319 ddb_wq = create_workqueue("ddbridge");
320 if (ddb_wq == NULL)
321 goto exit1;
322 stat = pci_register_driver(&ddb_pci_driver);
323 if (stat < 0)
324 goto exit2;
325 return stat;
326exit2:
327 destroy_workqueue(ddb_wq);
328exit1:
329 ddb_class_destroy();
330 return stat;
331}
332
333static __exit void module_exit_ddbridge(void)
334{
335 pci_unregister_driver(&ddb_pci_driver);
336 destroy_workqueue(ddb_wq);
337 ddb_class_destroy();
338}
339
340module_init(module_init_ddbridge);
341module_exit(module_exit_ddbridge);
342
343MODULE_DESCRIPTION("Digital Devices PCIe Bridge");
344MODULE_AUTHOR("Ralph and Marcus Metzler, Metzler Brothers Systementwicklung GbR");
345MODULE_LICENSE("GPL");
346MODULE_VERSION(DDBRIDGE_VERSION);
diff --git a/drivers/media/pci/ddbridge/ddbridge-maxs8.c b/drivers/media/pci/ddbridge/ddbridge-maxs8.c
new file mode 100644
index 000000000000..f8a53bc7c86c
--- /dev/null
+++ b/drivers/media/pci/ddbridge/ddbridge-maxs8.c
@@ -0,0 +1,444 @@
1/*
2 * ddbridge-maxs8.c: Digital Devices bridge MaxS4/8 support
3 *
4 * Copyright (C) 2010-2017 Digital Devices GmbH
5 * Ralph Metzler <rjkm@metzlerbros.de>
6 * Marcus Metzler <mocm@metzlerbros.de>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 only, as 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 */
18
19#include <linux/module.h>
20#include <linux/init.h>
21#include <linux/interrupt.h>
22#include <linux/delay.h>
23#include <linux/slab.h>
24#include <linux/poll.h>
25#include <linux/io.h>
26#include <linux/pci.h>
27#include <linux/pci_ids.h>
28#include <linux/timer.h>
29#include <linux/i2c.h>
30#include <linux/swab.h>
31#include <linux/vmalloc.h>
32
33#include "ddbridge.h"
34#include "ddbridge-regs.h"
35#include "ddbridge-io.h"
36
37#include "ddbridge-maxs8.h"
38#include "mxl5xx.h"
39
40/******************************************************************************/
41
42/* MaxS4/8 related modparams */
43static int fmode;
44module_param(fmode, int, 0444);
45MODULE_PARM_DESC(fmode, "frontend emulation mode");
46
47static int fmode_sat = -1;
48module_param(fmode_sat, int, 0444);
49MODULE_PARM_DESC(fmode_sat, "set frontend emulation mode sat");
50
51static int old_quattro;
52module_param(old_quattro, int, 0444);
53MODULE_PARM_DESC(old_quattro, "old quattro LNB input order ");
54
55/******************************************************************************/
56
57static int lnb_command(struct ddb *dev, u32 link, u32 lnb, u32 cmd)
58{
59 u32 c, v = 0, tag = DDB_LINK_TAG(link);
60
61 v = LNB_TONE & (dev->link[link].lnb.tone << (15 - lnb));
62 ddbwritel(dev, cmd | v, tag | LNB_CONTROL(lnb));
63 for (c = 0; c < 10; c++) {
64 v = ddbreadl(dev, tag | LNB_CONTROL(lnb));
65 if ((v & LNB_BUSY) == 0)
66 break;
67 msleep(20);
68 }
69 if (c == 10)
70 dev_info(dev->dev, "%s lnb = %08x cmd = %08x\n",
71 __func__, lnb, cmd);
72 return 0;
73}
74
75static int max_send_master_cmd(struct dvb_frontend *fe,
76 struct dvb_diseqc_master_cmd *cmd)
77{
78 struct ddb_input *input = fe->sec_priv;
79 struct ddb_port *port = input->port;
80 struct ddb *dev = port->dev;
81 struct ddb_dvb *dvb = &port->dvb[input->nr & 1];
82 u32 tag = DDB_LINK_TAG(port->lnr);
83 int i;
84 u32 fmode = dev->link[port->lnr].lnb.fmode;
85
86 if (fmode == 2 || fmode == 1)
87 return 0;
88 if (dvb->diseqc_send_master_cmd)
89 dvb->diseqc_send_master_cmd(fe, cmd);
90
91 mutex_lock(&dev->link[port->lnr].lnb.lock);
92 ddbwritel(dev, 0, tag | LNB_BUF_LEVEL(dvb->input));
93 for (i = 0; i < cmd->msg_len; i++)
94 ddbwritel(dev, cmd->msg[i], tag | LNB_BUF_WRITE(dvb->input));
95 lnb_command(dev, port->lnr, dvb->input, LNB_CMD_DISEQC);
96 mutex_unlock(&dev->link[port->lnr].lnb.lock);
97 return 0;
98}
99
100static int lnb_send_diseqc(struct ddb *dev, u32 link, u32 input,
101 struct dvb_diseqc_master_cmd *cmd)
102{
103 u32 tag = DDB_LINK_TAG(link);
104 int i;
105
106 ddbwritel(dev, 0, tag | LNB_BUF_LEVEL(input));
107 for (i = 0; i < cmd->msg_len; i++)
108 ddbwritel(dev, cmd->msg[i], tag | LNB_BUF_WRITE(input));
109 lnb_command(dev, link, input, LNB_CMD_DISEQC);
110 return 0;
111}
112
113static int lnb_set_sat(struct ddb *dev, u32 link, u32 input, u32 sat, u32 band,
114 u32 hor)
115{
116 struct dvb_diseqc_master_cmd cmd = {
117 .msg = {0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00},
118 .msg_len = 4
119 };
120 cmd.msg[3] = 0xf0 | (((sat << 2) & 0x0c) | (band ? 1 : 0) |
121 (hor ? 2 : 0));
122 return lnb_send_diseqc(dev, link, input, &cmd);
123}
124
125static int lnb_set_tone(struct ddb *dev, u32 link, u32 input,
126 enum fe_sec_tone_mode tone)
127{
128 int s = 0;
129 u32 mask = (1ULL << input);
130
131 switch (tone) {
132 case SEC_TONE_OFF:
133 if (!(dev->link[link].lnb.tone & mask))
134 return 0;
135 dev->link[link].lnb.tone &= ~(1ULL << input);
136 break;
137 case SEC_TONE_ON:
138 if (dev->link[link].lnb.tone & mask)
139 return 0;
140 dev->link[link].lnb.tone |= (1ULL << input);
141 break;
142 default:
143 s = -EINVAL;
144 break;
145 }
146 if (!s)
147 s = lnb_command(dev, link, input, LNB_CMD_NOP);
148 return s;
149}
150
151static int lnb_set_voltage(struct ddb *dev, u32 link, u32 input,
152 enum fe_sec_voltage voltage)
153{
154 int s = 0;
155
156 if (dev->link[link].lnb.oldvoltage[input] == voltage)
157 return 0;
158 switch (voltage) {
159 case SEC_VOLTAGE_OFF:
160 if (dev->link[link].lnb.voltage[input])
161 return 0;
162 lnb_command(dev, link, input, LNB_CMD_OFF);
163 break;
164 case SEC_VOLTAGE_13:
165 lnb_command(dev, link, input, LNB_CMD_LOW);
166 break;
167 case SEC_VOLTAGE_18:
168 lnb_command(dev, link, input, LNB_CMD_HIGH);
169 break;
170 default:
171 s = -EINVAL;
172 break;
173 }
174 dev->link[link].lnb.oldvoltage[input] = voltage;
175 return s;
176}
177
178static int max_set_input_unlocked(struct dvb_frontend *fe, int in)
179{
180 struct ddb_input *input = fe->sec_priv;
181 struct ddb_port *port = input->port;
182 struct ddb *dev = port->dev;
183 struct ddb_dvb *dvb = &port->dvb[input->nr & 1];
184 int res = 0;
185
186 if (in > 3)
187 return -EINVAL;
188 if (dvb->input != in) {
189 u32 bit = (1ULL << input->nr);
190 u32 obit =
191 dev->link[port->lnr].lnb.voltage[dvb->input & 3] & bit;
192
193 dev->link[port->lnr].lnb.voltage[dvb->input & 3] &= ~bit;
194 dvb->input = in;
195 dev->link[port->lnr].lnb.voltage[dvb->input & 3] |= obit;
196 }
197 res = dvb->set_input(fe, in);
198 return res;
199}
200
201static int max_set_tone(struct dvb_frontend *fe, enum fe_sec_tone_mode tone)
202{
203 struct ddb_input *input = fe->sec_priv;
204 struct ddb_port *port = input->port;
205 struct ddb *dev = port->dev;
206 struct ddb_dvb *dvb = &port->dvb[input->nr & 1];
207 int tuner = 0;
208 int res = 0;
209 u32 fmode = dev->link[port->lnr].lnb.fmode;
210
211 mutex_lock(&dev->link[port->lnr].lnb.lock);
212 dvb->tone = tone;
213 switch (fmode) {
214 default:
215 case 0:
216 case 3:
217 res = lnb_set_tone(dev, port->lnr, dvb->input, tone);
218 break;
219 case 1:
220 case 2:
221 if (old_quattro) {
222 if (dvb->tone == SEC_TONE_ON)
223 tuner |= 2;
224 if (dvb->voltage == SEC_VOLTAGE_18)
225 tuner |= 1;
226 } else {
227 if (dvb->tone == SEC_TONE_ON)
228 tuner |= 1;
229 if (dvb->voltage == SEC_VOLTAGE_18)
230 tuner |= 2;
231 }
232 res = max_set_input_unlocked(fe, tuner);
233 break;
234 }
235 mutex_unlock(&dev->link[port->lnr].lnb.lock);
236 return res;
237}
238
239static int max_set_voltage(struct dvb_frontend *fe, enum fe_sec_voltage voltage)
240{
241 struct ddb_input *input = fe->sec_priv;
242 struct ddb_port *port = input->port;
243 struct ddb *dev = port->dev;
244 struct ddb_dvb *dvb = &port->dvb[input->nr & 1];
245 int tuner = 0;
246 u32 nv, ov = dev->link[port->lnr].lnb.voltages;
247 int res = 0;
248 u32 fmode = dev->link[port->lnr].lnb.fmode;
249
250 mutex_lock(&dev->link[port->lnr].lnb.lock);
251 dvb->voltage = voltage;
252
253 switch (fmode) {
254 case 3:
255 default:
256 case 0:
257 if (fmode == 3)
258 max_set_input_unlocked(fe, 0);
259 if (voltage == SEC_VOLTAGE_OFF)
260 dev->link[port->lnr].lnb.voltage[dvb->input] &=
261 ~(1ULL << input->nr);
262 else
263 dev->link[port->lnr].lnb.voltage[dvb->input] |=
264 (1ULL << input->nr);
265
266 res = lnb_set_voltage(dev, port->lnr, dvb->input, voltage);
267 break;
268 case 1:
269 case 2:
270 if (voltage == SEC_VOLTAGE_OFF)
271 dev->link[port->lnr].lnb.voltages &=
272 ~(1ULL << input->nr);
273 else
274 dev->link[port->lnr].lnb.voltages |=
275 (1ULL << input->nr);
276
277 nv = dev->link[port->lnr].lnb.voltages;
278
279 if (old_quattro) {
280 if (dvb->tone == SEC_TONE_ON)
281 tuner |= 2;
282 if (dvb->voltage == SEC_VOLTAGE_18)
283 tuner |= 1;
284 } else {
285 if (dvb->tone == SEC_TONE_ON)
286 tuner |= 1;
287 if (dvb->voltage == SEC_VOLTAGE_18)
288 tuner |= 2;
289 }
290 res = max_set_input_unlocked(fe, tuner);
291
292 if (nv != ov) {
293 if (nv) {
294 lnb_set_voltage(dev,
295 port->lnr, 0, SEC_VOLTAGE_13);
296 if (fmode == 1) {
297 lnb_set_voltage(dev, port->lnr,
298 0, SEC_VOLTAGE_13);
299 if (old_quattro) {
300 lnb_set_voltage(dev, port->lnr,
301 1, SEC_VOLTAGE_18);
302 lnb_set_voltage(dev, port->lnr,
303 2, SEC_VOLTAGE_13);
304 } else {
305 lnb_set_voltage(dev, port->lnr,
306 1, SEC_VOLTAGE_13);
307 lnb_set_voltage(dev, port->lnr,
308 2, SEC_VOLTAGE_18);
309 }
310 lnb_set_voltage(dev, port->lnr,
311 3, SEC_VOLTAGE_18);
312 }
313 } else {
314 lnb_set_voltage(dev, port->lnr,
315 0, SEC_VOLTAGE_OFF);
316 if (fmode == 1) {
317 lnb_set_voltage(dev, port->lnr,
318 1, SEC_VOLTAGE_OFF);
319 lnb_set_voltage(dev, port->lnr,
320 2, SEC_VOLTAGE_OFF);
321 lnb_set_voltage(dev, port->lnr,
322 3, SEC_VOLTAGE_OFF);
323 }
324 }
325 }
326 break;
327 }
328 mutex_unlock(&dev->link[port->lnr].lnb.lock);
329 return res;
330}
331
332static int max_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
333{
334
335 return 0;
336}
337
338static int max_send_burst(struct dvb_frontend *fe, enum fe_sec_mini_cmd burst)
339{
340 return 0;
341}
342
343static int mxl_fw_read(void *priv, u8 *buf, u32 len)
344{
345 struct ddb_link *link = priv;
346 struct ddb *dev = link->dev;
347
348 dev_info(dev->dev, "Read mxl_fw from link %u\n", link->nr);
349
350 return ddbridge_flashread(dev, link->nr, buf, 0xc0000, len);
351}
352
353int lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm)
354{
355 u32 l = link->nr;
356
357 if (link->lnb.fmode == fm)
358 return 0;
359 dev_info(dev->dev, "Set fmode link %u = %u\n", l, fm);
360 mutex_lock(&link->lnb.lock);
361 if (fm == 2 || fm == 1) {
362 if (fmode_sat >= 0) {
363 lnb_set_sat(dev, l, 0, fmode_sat, 0, 0);
364 if (old_quattro) {
365 lnb_set_sat(dev, l, 1, fmode_sat, 0, 1);
366 lnb_set_sat(dev, l, 2, fmode_sat, 1, 0);
367 } else {
368 lnb_set_sat(dev, l, 1, fmode_sat, 1, 0);
369 lnb_set_sat(dev, l, 2, fmode_sat, 0, 1);
370 }
371 lnb_set_sat(dev, l, 3, fmode_sat, 1, 1);
372 }
373 lnb_set_tone(dev, l, 0, SEC_TONE_OFF);
374 if (old_quattro) {
375 lnb_set_tone(dev, l, 1, SEC_TONE_OFF);
376 lnb_set_tone(dev, l, 2, SEC_TONE_ON);
377 } else {
378 lnb_set_tone(dev, l, 1, SEC_TONE_ON);
379 lnb_set_tone(dev, l, 2, SEC_TONE_OFF);
380 }
381 lnb_set_tone(dev, l, 3, SEC_TONE_ON);
382 }
383 link->lnb.fmode = fm;
384 mutex_unlock(&link->lnb.lock);
385 return 0;
386}
387
388static struct mxl5xx_cfg mxl5xx = {
389 .adr = 0x60,
390 .type = 0x01,
391 .clk = 27000000,
392 .ts_clk = 139,
393 .cap = 12,
394 .fw_read = mxl_fw_read,
395};
396
397int fe_attach_mxl5xx(struct ddb_input *input)
398{
399 struct ddb *dev = input->port->dev;
400 struct i2c_adapter *i2c = &input->port->i2c->adap;
401 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1];
402 struct ddb_port *port = input->port;
403 struct ddb_link *link = &dev->link[port->lnr];
404 struct mxl5xx_cfg cfg;
405 int demod, tuner;
406
407 cfg = mxl5xx;
408 cfg.fw_priv = link;
409 dvb->set_input = NULL;
410
411 demod = input->nr;
412 tuner = demod & 3;
413 if (fmode == 3)
414 tuner = 0;
415
416 dvb->fe = dvb_attach(mxl5xx_attach, i2c, &cfg,
417 demod, tuner, &dvb->set_input);
418
419 if (!dvb->fe) {
420 dev_err(dev->dev, "No MXL5XX found!\n");
421 return -ENODEV;
422 }
423
424 if (!dvb->set_input) {
425 dev_err(dev->dev, "No mxl5xx_set_input function pointer!\n");
426 return -ENODEV;
427 }
428
429 if (input->nr < 4) {
430 lnb_command(dev, port->lnr, input->nr, LNB_CMD_INIT);
431 lnb_set_voltage(dev, port->lnr, input->nr, SEC_VOLTAGE_OFF);
432 }
433 lnb_init_fmode(dev, link, fmode);
434
435 dvb->fe->ops.set_voltage = max_set_voltage;
436 dvb->fe->ops.enable_high_lnb_voltage = max_enable_high_lnb_voltage;
437 dvb->fe->ops.set_tone = max_set_tone;
438 dvb->diseqc_send_master_cmd = dvb->fe->ops.diseqc_send_master_cmd;
439 dvb->fe->ops.diseqc_send_master_cmd = max_send_master_cmd;
440 dvb->fe->ops.diseqc_send_burst = max_send_burst;
441 dvb->fe->sec_priv = input;
442 dvb->input = tuner;
443 return 0;
444}
diff --git a/drivers/media/pci/ddbridge/ddbridge-maxs8.h b/drivers/media/pci/ddbridge/ddbridge-maxs8.h
new file mode 100644
index 000000000000..bb8884811a46
--- /dev/null
+++ b/drivers/media/pci/ddbridge/ddbridge-maxs8.h
@@ -0,0 +1,29 @@
1/*
2 * ddbridge-maxs8.h: Digital Devices bridge MaxS4/8 support
3 *
4 * Copyright (C) 2010-2017 Digital Devices GmbH
5 * Ralph Metzler <rjkm@metzlerbros.de>
6 * Marcus Metzler <mocm@metzlerbros.de>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 only, as 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 */
18
19#ifndef _DDBRIDGE_MAXS8_H_
20#define _DDBRIDGE_MAXS8_H_
21
22#include "ddbridge.h"
23
24/******************************************************************************/
25
26int lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm);
27int fe_attach_mxl5xx(struct ddb_input *input);
28
29#endif /* _DDBRIDGE_MAXS8_H */
diff --git a/drivers/media/pci/ddbridge/ddbridge-regs.h b/drivers/media/pci/ddbridge/ddbridge-regs.h
index 98cebb97d64f..9d44f8d3af75 100644
--- a/drivers/media/pci/ddbridge/ddbridge-regs.h
+++ b/drivers/media/pci/ddbridge/ddbridge-regs.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * ddbridge-regs.h: Digital Devices PCIe bridge driver 2 * ddbridge-regs.h: Digital Devices PCIe bridge driver
3 * 3 *
4 * Copyright (C) 2010-2011 Digital Devices GmbH 4 * Copyright (C) 2010-2017 Digital Devices GmbH
5 * 5 *
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
@@ -17,20 +17,26 @@
17 * http://www.gnu.org/copyleft/gpl.html 17 * http://www.gnu.org/copyleft/gpl.html
18 */ 18 */
19 19
20/* DD-DVBBridgeV1.h 273 2010-09-17 05:03:16Z manfred */ 20/* ------------------------------------------------------------------------- */
21/* SPI Controller */
21 22
22/* Register Definitions */ 23#define SPI_CONTROL 0x10
24#define SPI_DATA 0x14
23 25
24#define CUR_REGISTERMAP_VERSION 0x10000 26/* ------------------------------------------------------------------------- */
27/* GPIO */
25 28
26#define HARDWARE_VERSION 0x00 29#define GPIO_OUTPUT 0x20
27#define REGISTERMAP_VERSION 0x04 30#define GPIO_INPUT 0x24
31#define GPIO_DIRECTION 0x28
28 32
29/* ------------------------------------------------------------------------- */ 33/* ------------------------------------------------------------------------- */
30/* SPI Controller */ 34/* MDIO */
31 35
32#define SPI_CONTROL 0x10 36#define MDIO_CTRL 0x20
33#define SPI_DATA 0x14 37#define MDIO_ADR 0x24
38#define MDIO_REG 0x28
39#define MDIO_VAL 0x2C
34 40
35/* ------------------------------------------------------------------------- */ 41/* ------------------------------------------------------------------------- */
36 42
@@ -38,14 +44,14 @@
38 44
39/* ------------------------------------------------------------------------- */ 45/* ------------------------------------------------------------------------- */
40 46
41/* Interrupt controller */ 47/* Interrupt controller
42/* How many MSI's are available depends on HW (Min 2 max 8) */ 48 * How many MSI's are available depends on HW (Min 2 max 8)
43/* How many are usable also depends on Host platform */ 49 * How many are usable also depends on Host platform
50 */
44 51
45#define INTERRUPT_BASE (0x40) 52#define INTERRUPT_BASE (0x40)
46 53
47#define INTERRUPT_ENABLE (INTERRUPT_BASE + 0x00) 54#define INTERRUPT_ENABLE (INTERRUPT_BASE + 0x00)
48#define MSI0_ENABLE (INTERRUPT_BASE + 0x00)
49#define MSI1_ENABLE (INTERRUPT_BASE + 0x04) 55#define MSI1_ENABLE (INTERRUPT_BASE + 0x04)
50#define MSI2_ENABLE (INTERRUPT_BASE + 0x08) 56#define MSI2_ENABLE (INTERRUPT_BASE + 0x08)
51#define MSI3_ENABLE (INTERRUPT_BASE + 0x0C) 57#define MSI3_ENABLE (INTERRUPT_BASE + 0x0C)
@@ -57,59 +63,31 @@
57#define INTERRUPT_STATUS (INTERRUPT_BASE + 0x20) 63#define INTERRUPT_STATUS (INTERRUPT_BASE + 0x20)
58#define INTERRUPT_ACK (INTERRUPT_BASE + 0x20) 64#define INTERRUPT_ACK (INTERRUPT_BASE + 0x20)
59 65
60#define INTMASK_I2C1 (0x00000001) 66/* Temperature Monitor ( 2x LM75A @ 0x90,0x92 I2c ) */
61#define INTMASK_I2C2 (0x00000002) 67#define TEMPMON_BASE (0x1c0)
62#define INTMASK_I2C3 (0x00000004) 68#define TEMPMON_CONTROL (TEMPMON_BASE + 0x00)
63#define INTMASK_I2C4 (0x00000008) 69
64 70#define TEMPMON_CONTROL_AUTOSCAN (0x00000002)
65#define INTMASK_CIRQ1 (0x00000010) 71#define TEMPMON_CONTROL_INTENABLE (0x00000004)
66#define INTMASK_CIRQ2 (0x00000020) 72#define TEMPMON_CONTROL_OVERTEMP (0x00008000)
67#define INTMASK_CIRQ3 (0x00000040) 73
68#define INTMASK_CIRQ4 (0x00000080) 74/* SHORT Temperature in Celsius x 256 */
69 75#define TEMPMON_SENSOR0 (TEMPMON_BASE + 0x04)
70#define INTMASK_TSINPUT1 (0x00000100) 76#define TEMPMON_SENSOR1 (TEMPMON_BASE + 0x08)
71#define INTMASK_TSINPUT2 (0x00000200) 77
72#define INTMASK_TSINPUT3 (0x00000400) 78#define TEMPMON_FANCONTROL (TEMPMON_BASE + 0x10)
73#define INTMASK_TSINPUT4 (0x00000800)
74#define INTMASK_TSINPUT5 (0x00001000)
75#define INTMASK_TSINPUT6 (0x00002000)
76#define INTMASK_TSINPUT7 (0x00004000)
77#define INTMASK_TSINPUT8 (0x00008000)
78
79#define INTMASK_TSOUTPUT1 (0x00010000)
80#define INTMASK_TSOUTPUT2 (0x00020000)
81#define INTMASK_TSOUTPUT3 (0x00040000)
82#define INTMASK_TSOUTPUT4 (0x00080000)
83 79
84/* ------------------------------------------------------------------------- */ 80/* ------------------------------------------------------------------------- */
85/* I2C Master Controller */ 81/* I2C Master Controller */
86 82
87#define I2C_BASE (0x80) /* Byte offset */
88
89#define I2C_COMMAND (0x00) 83#define I2C_COMMAND (0x00)
90#define I2C_TIMING (0x04) 84#define I2C_TIMING (0x04)
91#define I2C_TASKLENGTH (0x08) /* High read, low write */ 85#define I2C_TASKLENGTH (0x08) /* High read, low write */
92#define I2C_TASKADDRESS (0x0C) /* High read, low write */ 86#define I2C_TASKADDRESS (0x0C) /* High read, low write */
93
94#define I2C_MONITOR (0x1C) 87#define I2C_MONITOR (0x1C)
95 88
96#define I2C_BASE_1 (I2C_BASE + 0x00)
97#define I2C_BASE_2 (I2C_BASE + 0x20)
98#define I2C_BASE_3 (I2C_BASE + 0x40)
99#define I2C_BASE_4 (I2C_BASE + 0x60)
100
101#define I2C_BASE_N(i) (I2C_BASE + (i) * 0x20)
102
103#define I2C_TASKMEM_BASE (0x1000) /* Byte offset */
104#define I2C_TASKMEM_SIZE (0x1000)
105
106#define I2C_SPEED_400 (0x04030404) 89#define I2C_SPEED_400 (0x04030404)
107#define I2C_SPEED_200 (0x09080909)
108#define I2C_SPEED_154 (0x0C0B0C0C)
109#define I2C_SPEED_100 (0x13121313) 90#define I2C_SPEED_100 (0x13121313)
110#define I2C_SPEED_77 (0x19181919)
111#define I2C_SPEED_50 (0x27262727)
112
113 91
114/* ------------------------------------------------------------------------- */ 92/* ------------------------------------------------------------------------- */
115/* DMA Controller */ 93/* DMA Controller */
@@ -117,35 +95,62 @@
117#define DMA_BASE_WRITE (0x100) 95#define DMA_BASE_WRITE (0x100)
118#define DMA_BASE_READ (0x140) 96#define DMA_BASE_READ (0x140)
119 97
120#define DMA_CONTROL (0x00) /* 64 */ 98#define TS_CONTROL(_io) (_io->regs + 0x00)
121#define DMA_ERROR (0x04) /* 65 ( only read instance ) */ 99#define TS_CONTROL2(_io) (_io->regs + 0x04)
122
123#define DMA_DIAG_CONTROL (0x1C) /* 71 */
124#define DMA_DIAG_PACKETCOUNTER_LOW (0x20) /* 72 */
125#define DMA_DIAG_PACKETCOUNTER_HIGH (0x24) /* 73 */
126#define DMA_DIAG_TIMECOUNTER_LOW (0x28) /* 74 */
127#define DMA_DIAG_TIMECOUNTER_HIGH (0x2C) /* 75 */
128#define DMA_DIAG_RECHECKCOUNTER (0x30) /* 76 ( Split completions on read ) */
129#define DMA_DIAG_WAITTIMEOUTINIT (0x34) /* 77 */
130#define DMA_DIAG_WAITOVERFLOWCOUNTER (0x38) /* 78 */
131#define DMA_DIAG_WAITCOUNTER (0x3C) /* 79 */
132 100
133/* ------------------------------------------------------------------------- */ 101/* ------------------------------------------------------------------------- */
134/* DMA Buffer */ 102/* DMA Buffer */
135 103
136#define TS_INPUT_BASE (0x200) 104#define DMA_BUFFER_CONTROL(_dma) (_dma->regs + 0x00)
137#define TS_INPUT_CONTROL(i) (TS_INPUT_BASE + (i) * 16 + 0x00) 105#define DMA_BUFFER_ACK(_dma) (_dma->regs + 0x04)
106#define DMA_BUFFER_CURRENT(_dma) (_dma->regs + 0x08)
107#define DMA_BUFFER_SIZE(_dma) (_dma->regs + 0x0c)
108
109/* ------------------------------------------------------------------------- */
110/* CI Interface (only CI-Bridge) */
111
112#define CI_BASE (0x400)
113#define CI_CONTROL(i) (CI_BASE + (i) * 32 + 0x00)
114
115#define CI_DO_ATTRIBUTE_RW(i) (CI_BASE + (i) * 32 + 0x04)
116#define CI_DO_IO_RW(i) (CI_BASE + (i) * 32 + 0x08)
117#define CI_READDATA(i) (CI_BASE + (i) * 32 + 0x0c)
118#define CI_DO_READ_ATTRIBUTES(i) (CI_BASE + (i) * 32 + 0x10)
119
120#define CI_RESET_CAM (0x00000001)
121#define CI_POWER_ON (0x00000002)
122#define CI_ENABLE (0x00000004)
123#define CI_BYPASS_DISABLE (0x00000010)
124
125#define CI_CAM_READY (0x00010000)
126#define CI_CAM_DETECT (0x00020000)
127#define CI_READY (0x80000000)
128
129#define CI_READ_CMD (0x40000000)
130#define CI_WRITE_CMD (0x80000000)
131
132#define CI_BUFFER_BASE (0x3000)
133#define CI_BUFFER_SIZE (0x0800)
134
135#define CI_BUFFER(i) (CI_BUFFER_BASE + (i) * CI_BUFFER_SIZE)
136
137/* ------------------------------------------------------------------------- */
138/* LNB commands (mxl5xx / Max S8) */
138 139
139#define TS_OUTPUT_BASE (0x280) 140#define LNB_BASE (0x400)
140#define TS_OUTPUT_CONTROL(i) (TS_OUTPUT_BASE + (i) * 16 + 0x00) 141#define LNB_CONTROL(i) (LNB_BASE + (i) * 0x20 + 0x00)
141 142
142#define DMA_BUFFER_BASE (0x300) 143#define LNB_CMD (7ULL << 0)
144#define LNB_CMD_NOP 0
145#define LNB_CMD_INIT 1
146#define LNB_CMD_LOW 3
147#define LNB_CMD_HIGH 4
148#define LNB_CMD_OFF 5
149#define LNB_CMD_DISEQC 6
143 150
144#define DMA_BUFFER_CONTROL(i) (DMA_BUFFER_BASE + (i) * 16 + 0x00) 151#define LNB_BUSY (1ULL << 4)
145#define DMA_BUFFER_ACK(i) (DMA_BUFFER_BASE + (i) * 16 + 0x04) 152#define LNB_TONE (1ULL << 15)
146#define DMA_BUFFER_CURRENT(i) (DMA_BUFFER_BASE + (i) * 16 + 0x08)
147#define DMA_BUFFER_SIZE(i) (DMA_BUFFER_BASE + (i) * 16 + 0x0c)
148 153
149#define DMA_BASE_ADDRESS_TABLE (0x2000) 154#define LNB_BUF_LEVEL(i) (LNB_BASE + (i) * 0x20 + 0x10)
150#define DMA_BASE_ADDRESS_TABLE_ENTRIES (512) 155#define LNB_BUF_WRITE(i) (LNB_BASE + (i) * 0x20 + 0x14)
151 156
diff --git a/drivers/media/pci/ddbridge/ddbridge.h b/drivers/media/pci/ddbridge/ddbridge.h
index 4a0e3283d646..e9afa96bd9df 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -1,7 +1,8 @@
1/* 1/*
2 * ddbridge.h: Digital Devices PCIe bridge driver 2 * ddbridge.h: Digital Devices PCIe bridge driver
3 * 3 *
4 * Copyright (C) 2010-2011 Digital Devices GmbH 4 * Copyright (C) 2010-2017 Digital Devices GmbH
5 * Ralph Metzler <rmetzler@digitaldevices.de>
5 * 6 *
6 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
@@ -20,15 +21,39 @@
20#ifndef _DDBRIDGE_H_ 21#ifndef _DDBRIDGE_H_
21#define _DDBRIDGE_H_ 22#define _DDBRIDGE_H_
22 23
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/interrupt.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/poll.h>
30#include <linux/io.h>
31#include <linux/pci.h>
32#include <linux/timer.h>
33#include <linux/i2c.h>
34#include <linux/swab.h>
35#include <linux/vmalloc.h>
36#include <linux/workqueue.h>
37#include <linux/kthread.h>
38#include <linux/platform_device.h>
39#include <linux/clk.h>
40#include <linux/spi/spi.h>
41#include <linux/gpio.h>
42#include <linux/completion.h>
43
23#include <linux/types.h> 44#include <linux/types.h>
24#include <linux/sched.h> 45#include <linux/sched.h>
25#include <linux/interrupt.h> 46#include <linux/interrupt.h>
26#include <linux/i2c.h>
27#include <linux/mutex.h> 47#include <linux/mutex.h>
28#include <asm/dma.h> 48#include <asm/dma.h>
29#include <linux/dvb/frontend.h> 49#include <asm/irq.h>
50#include <linux/io.h>
51#include <linux/uaccess.h>
52
30#include <linux/dvb/ca.h> 53#include <linux/dvb/ca.h>
31#include <linux/socket.h> 54#include <linux/socket.h>
55#include <linux/device.h>
56#include <linux/io.h>
32 57
33#include "dmxdev.h" 58#include "dmxdev.h"
34#include "dvbdev.h" 59#include "dvbdev.h"
@@ -37,69 +62,122 @@
37#include "dvb_ringbuffer.h" 62#include "dvb_ringbuffer.h"
38#include "dvb_ca_en50221.h" 63#include "dvb_ca_en50221.h"
39#include "dvb_net.h" 64#include "dvb_net.h"
40#include "cxd2099.h"
41 65
42#define DDB_MAX_I2C 4 66#define DDBRIDGE_VERSION "0.9.31intermediate-integrated"
43#define DDB_MAX_PORT 4 67
44#define DDB_MAX_INPUT 8 68#define DDB_MAX_I2C 32
45#define DDB_MAX_OUTPUT 4 69#define DDB_MAX_PORT 32
70#define DDB_MAX_INPUT 64
71#define DDB_MAX_OUTPUT 32
46#define DDB_MAX_LINK 4 72#define DDB_MAX_LINK 4
47#define DDB_LINK_SHIFT 28 73#define DDB_LINK_SHIFT 28
48 74
49#define DDB_LINK_TAG(_x) (_x << DDB_LINK_SHIFT) 75#define DDB_LINK_TAG(_x) (_x << DDB_LINK_SHIFT)
50 76
51#define DDB_XO2_TYPE_NONE 0 77struct ddb_regset {
52#define DDB_XO2_TYPE_DUOFLEX 1 78 u32 base;
53#define DDB_XO2_TYPE_CI 2 79 u32 num;
80 u32 size;
81};
82
83struct ddb_regmap {
84 u32 irq_base_i2c;
85 u32 irq_base_idma;
86 u32 irq_base_odma;
87
88 const struct ddb_regset *i2c;
89 const struct ddb_regset *i2c_buf;
90 const struct ddb_regset *idma;
91 const struct ddb_regset *idma_buf;
92 const struct ddb_regset *odma;
93 const struct ddb_regset *odma_buf;
94
95 const struct ddb_regset *input;
96 const struct ddb_regset *output;
97
98 const struct ddb_regset *channel;
99};
100
101struct ddb_ids {
102 u16 vendor;
103 u16 device;
104 u16 subvendor;
105 u16 subdevice;
106
107 u32 hwid;
108 u32 regmapid;
109 u32 devid;
110 u32 mac;
111};
54 112
55struct ddb_info { 113struct ddb_info {
56 int type; 114 int type;
57#define DDB_NONE 0 115#define DDB_NONE 0
58#define DDB_OCTOPUS 1 116#define DDB_OCTOPUS 1
59#define DDB_OCTOPUS_MAX_CT 6 117#define DDB_OCTOPUS_CI 2
118#define DDB_OCTOPUS_MAX 5
119#define DDB_OCTOPUS_MAX_CT 6
60 char *name; 120 char *name;
61 int port_num; 121 u32 i2c_mask;
62 u32 port_type[DDB_MAX_PORT]; 122 u8 port_num;
123 u8 led_num;
124 u8 fan_num;
125 u8 temp_num;
126 u8 temp_bus;
63 u32 board_control; 127 u32 board_control;
64 u32 board_control_2; 128 u32 board_control_2;
129 u8 mdio_num;
130 u8 con_clock; /* use a continuous clock */
65 u8 ts_quirks; 131 u8 ts_quirks;
66#define TS_QUIRK_SERIAL 1 132#define TS_QUIRK_SERIAL 1
67#define TS_QUIRK_REVERSED 2 133#define TS_QUIRK_REVERSED 2
68#define TS_QUIRK_ALT_OSC 8 134#define TS_QUIRK_ALT_OSC 8
135 u32 tempmon_irq;
136 const struct ddb_regmap *regmap;
69}; 137};
70 138
71/* DMA_SIZE MUST be divisible by 188 and 128 !!! */ 139/* DMA_SIZE MUST be smaller than 256k and
140 * MUST be divisible by 188 and 128 !!!
141 */
142
143#define DMA_MAX_BUFS 32 /* hardware table limit */
72 144
73#define INPUT_DMA_MAX_BUFS 32 /* hardware table limit */
74#define INPUT_DMA_BUFS 8 145#define INPUT_DMA_BUFS 8
75#define INPUT_DMA_SIZE (128*47*21) 146#define INPUT_DMA_SIZE (128*47*21)
147#define INPUT_DMA_IRQ_DIV 1
76 148
77#define OUTPUT_DMA_MAX_BUFS 32
78#define OUTPUT_DMA_BUFS 8 149#define OUTPUT_DMA_BUFS 8
79#define OUTPUT_DMA_SIZE (128*47*21) 150#define OUTPUT_DMA_SIZE (128*47*21)
151#define OUTPUT_DMA_IRQ_DIV 1
80 152
81struct ddb; 153struct ddb;
82struct ddb_port; 154struct ddb_port;
83 155
84struct ddb_input { 156struct ddb_dma {
85 struct ddb_port *port; 157 void *io;
86 u32 nr; 158 u32 regs;
87 int attached; 159 u32 bufregs;
88 160
89 dma_addr_t pbuf[INPUT_DMA_MAX_BUFS]; 161 dma_addr_t pbuf[DMA_MAX_BUFS];
90 u8 *vbuf[INPUT_DMA_MAX_BUFS]; 162 u8 *vbuf[DMA_MAX_BUFS];
91 u32 dma_buf_num; 163 u32 num;
92 u32 dma_buf_size; 164 u32 size;
165 u32 div;
166 u32 bufval;
93 167
94 struct tasklet_struct tasklet; 168 struct work_struct work;
95 spinlock_t lock; 169 spinlock_t lock;
96 wait_queue_head_t wq; 170 wait_queue_head_t wq;
97 int running; 171 int running;
98 u32 stat; 172 u32 stat;
173 u32 ctrl;
99 u32 cbuf; 174 u32 cbuf;
100 u32 coff; 175 u32 coff;
176};
101 177
102 struct dvb_adapter adap; 178struct ddb_dvb {
179 struct dvb_adapter *adap;
180 int adap_registered;
103 struct dvb_device *dev; 181 struct dvb_device *dev;
104 struct i2c_client *i2c_client[1]; 182 struct i2c_client *i2c_client[1];
105 struct dvb_frontend *fe; 183 struct dvb_frontend *fe;
@@ -110,97 +188,210 @@ struct ddb_input {
110 struct dmx_frontend hw_frontend; 188 struct dmx_frontend hw_frontend;
111 struct dmx_frontend mem_frontend; 189 struct dmx_frontend mem_frontend;
112 int users; 190 int users;
113 int (*gate_ctrl)(struct dvb_frontend *, int); 191 u32 attached;
192 u8 input;
193
194 enum fe_sec_tone_mode tone;
195 enum fe_sec_voltage voltage;
196
197 int (*i2c_gate_ctrl)(struct dvb_frontend *, int);
198 int (*set_voltage)(struct dvb_frontend *fe,
199 enum fe_sec_voltage voltage);
200 int (*set_input)(struct dvb_frontend *fe, int input);
201 int (*diseqc_send_master_cmd)(struct dvb_frontend *fe,
202 struct dvb_diseqc_master_cmd *cmd);
114}; 203};
115 204
116struct ddb_output { 205struct ddb_ci {
206 struct dvb_ca_en50221 en;
117 struct ddb_port *port; 207 struct ddb_port *port;
118 u32 nr; 208 u32 nr;
119 dma_addr_t pbuf[OUTPUT_DMA_MAX_BUFS]; 209 struct mutex lock;
120 u8 *vbuf[OUTPUT_DMA_MAX_BUFS]; 210};
121 u32 dma_buf_num;
122 u32 dma_buf_size;
123 struct tasklet_struct tasklet;
124 spinlock_t lock;
125 wait_queue_head_t wq;
126 int running;
127 u32 stat;
128 u32 cbuf;
129 u32 coff;
130 211
131 struct dvb_adapter adap; 212struct ddb_io {
132 struct dvb_device *dev; 213 struct ddb_port *port;
214 u32 nr;
215 u32 regs;
216 struct ddb_dma *dma;
217 struct ddb_io *redo;
218 struct ddb_io *redi;
133}; 219};
134 220
221#define ddb_output ddb_io
222#define ddb_input ddb_io
223
135struct ddb_i2c { 224struct ddb_i2c {
136 struct ddb *dev; 225 struct ddb *dev;
137 u32 nr; 226 u32 nr;
138 struct i2c_adapter adap;
139 struct i2c_adapter adap2;
140 u32 regs; 227 u32 regs;
228 u32 link;
229 struct i2c_adapter adap;
141 u32 rbuf; 230 u32 rbuf;
142 u32 wbuf; 231 u32 wbuf;
143 int done; 232 u32 bsize;
144 wait_queue_head_t wq; 233 struct completion completion;
145}; 234};
146 235
147struct ddb_port { 236struct ddb_port {
148 struct ddb *dev; 237 struct ddb *dev;
149 u32 nr; 238 u32 nr;
239 u32 pnr;
240 u32 regs;
241 u32 lnr;
150 struct ddb_i2c *i2c; 242 struct ddb_i2c *i2c;
151 struct mutex i2c_gate_lock; 243 struct mutex i2c_gate_lock;
152 u32 class; 244 u32 class;
153#define DDB_PORT_NONE 0 245#define DDB_PORT_NONE 0
154#define DDB_PORT_CI 1 246#define DDB_PORT_CI 1
155#define DDB_PORT_TUNER 2 247#define DDB_PORT_TUNER 2
156 u32 type; 248#define DDB_PORT_LOOP 3
157#define DDB_TUNER_NONE 0 249 char *name;
158#define DDB_TUNER_DVBS_ST 1 250 char *type_name;
159#define DDB_TUNER_DVBS_ST_AA 2 251 u32 type;
160#define DDB_TUNER_DVBCT2_SONY_P 7 252#define DDB_TUNER_NONE 0
161#define DDB_TUNER_DVBC2T2_SONY_P 8 253#define DDB_TUNER_DVBS_ST 1
162#define DDB_TUNER_ISDBT_SONY_P 9 254#define DDB_TUNER_DVBS_ST_AA 2
163#define DDB_TUNER_DVBC2T2I_SONY_P 15 255#define DDB_TUNER_DVBCT_TR 3
164#define DDB_TUNER_DVBCT_TR 16 256#define DDB_TUNER_DVBCT_ST 4
165#define DDB_TUNER_DVBCT_ST 17 257#define DDB_CI_INTERNAL 5
166#define DDB_TUNER_XO2_DVBS_STV0910 32 258#define DDB_CI_EXTERNAL_SONY 6
167#define DDB_TUNER_XO2_DVBCT2_SONY 33 259#define DDB_TUNER_DVBCT2_SONY_P 7
168#define DDB_TUNER_XO2_ISDBT_SONY 34 260#define DDB_TUNER_DVBC2T2_SONY_P 8
169#define DDB_TUNER_XO2_DVBC2T2_SONY 35 261#define DDB_TUNER_ISDBT_SONY_P 9
170#define DDB_TUNER_XO2_ATSC_ST 36 262#define DDB_TUNER_DVBS_STV0910_P 10
171#define DDB_TUNER_XO2_DVBC2T2I_SONY 37 263#define DDB_TUNER_MXL5XX 11
172 264#define DDB_CI_EXTERNAL_XO2 12
173 u32 adr; 265#define DDB_CI_EXTERNAL_XO2_B 13
266#define DDB_TUNER_DVBS_STV0910_PR 14
267#define DDB_TUNER_DVBC2T2I_SONY_P 15
268
269#define DDB_TUNER_XO2 32
270#define DDB_TUNER_DVBS_STV0910 (DDB_TUNER_XO2 + 0)
271#define DDB_TUNER_DVBCT2_SONY (DDB_TUNER_XO2 + 1)
272#define DDB_TUNER_ISDBT_SONY (DDB_TUNER_XO2 + 2)
273#define DDB_TUNER_DVBC2T2_SONY (DDB_TUNER_XO2 + 3)
274#define DDB_TUNER_ATSC_ST (DDB_TUNER_XO2 + 4)
275#define DDB_TUNER_DVBC2T2I_SONY (DDB_TUNER_XO2 + 5)
174 276
175 struct ddb_input *input[2]; 277 struct ddb_input *input[2];
176 struct ddb_output *output; 278 struct ddb_output *output;
177 struct dvb_ca_en50221 *en; 279 struct dvb_ca_en50221 *en;
280 struct ddb_dvb dvb[2];
281 u32 gap;
282 u32 obr;
283 u8 creg;
284};
285
286#define CM_STARTUP_DELAY 2
287#define CM_AVERAGE 20
288#define CM_GAIN 10
289
290#define HW_LSB_SHIFT 12
291#define HW_LSB_MASK 0x1000
292
293#define CM_IDLE 0
294#define CM_STARTUP 1
295#define CM_ADJUST 2
296
297#define TS_CAPTURE_LEN (4096)
298
299struct ddb_lnb {
300 struct mutex lock;
301 u32 tone;
302 enum fe_sec_voltage oldvoltage[4];
303 u32 voltage[4];
304 u32 voltages;
305 u32 fmode;
306};
307
308struct ddb_link {
309 struct ddb *dev;
310 const struct ddb_info *info;
311 u32 nr;
312 u32 regs;
313 spinlock_t lock;
314 struct mutex flash_mutex;
315 struct ddb_lnb lnb;
316 struct tasklet_struct tasklet;
317 struct ddb_ids ids;
318
319 spinlock_t temp_lock;
320 int overtemperature_error;
321 u8 temp_tab[11];
178}; 322};
179 323
180struct ddb { 324struct ddb {
181 struct pci_dev *pdev; 325 struct pci_dev *pdev;
326 struct platform_device *pfdev;
327 struct device *dev;
328
329 int msi;
330 struct workqueue_struct *wq;
331 u32 has_dma;
332
333 struct ddb_link link[DDB_MAX_LINK];
182 unsigned char __iomem *regs; 334 unsigned char __iomem *regs;
335 u32 regs_len;
336 u32 port_num;
183 struct ddb_port port[DDB_MAX_PORT]; 337 struct ddb_port port[DDB_MAX_PORT];
338 u32 i2c_num;
184 struct ddb_i2c i2c[DDB_MAX_I2C]; 339 struct ddb_i2c i2c[DDB_MAX_I2C];
185 struct ddb_input input[DDB_MAX_INPUT]; 340 struct ddb_input input[DDB_MAX_INPUT];
186 struct ddb_output output[DDB_MAX_OUTPUT]; 341 struct ddb_output output[DDB_MAX_OUTPUT];
342 struct dvb_adapter adap[DDB_MAX_INPUT];
343 struct ddb_dma idma[DDB_MAX_INPUT];
344 struct ddb_dma odma[DDB_MAX_OUTPUT];
345
346 void (*handler[4][256])(unsigned long);
347 unsigned long handler_data[4][256];
187 348
188 struct device *ddb_dev; 349 struct device *ddb_dev;
189 int nr; 350 u32 ddb_dev_users;
351 u32 nr;
190 u8 iobuf[1028]; 352 u8 iobuf[1028];
191 353
192 struct ddb_info *info; 354 u8 leds;
193 int msi; 355 u32 ts_irq;
356 u32 i2c_irq;
357
358 struct mutex mutex;
359
360 u8 tsbuf[TS_CAPTURE_LEN];
194}; 361};
195 362
196/****************************************************************************/ 363/****************************************************************************/
364/****************************************************************************/
365/****************************************************************************/
197 366
198#define ddbwritel(_val, _adr) writel((_val), \ 367int ddbridge_flashread(struct ddb *dev, u32 link, u8 *buf, u32 addr, u32 len);
199 dev->regs+(_adr))
200#define ddbreadl(_adr) readl(dev->regs+(_adr))
201#define ddbcpyto(_adr, _src, _count) memcpy_toio(dev->regs+(_adr), (_src), (_count))
202#define ddbcpyfrom(_dst, _adr, _count) memcpy_fromio((_dst), dev->regs+(_adr), (_count))
203 368
204/****************************************************************************/ 369/****************************************************************************/
205 370
206#endif 371/* ddbridge-main.c (modparams) */
372extern int ci_bitrate;
373extern int ts_loop;
374extern int xo2_speed;
375extern int alt_dma;
376extern int no_init;
377extern int stv0910_single;
378extern struct workqueue_struct *ddb_wq;
379
380/* ddbridge-core.c */
381void ddb_ports_detach(struct ddb *dev);
382void ddb_ports_release(struct ddb *dev);
383void ddb_buffers_free(struct ddb *dev);
384void ddb_device_destroy(struct ddb *dev);
385irqreturn_t ddb_irq_handler0(int irq, void *dev_id);
386irqreturn_t ddb_irq_handler1(int irq, void *dev_id);
387irqreturn_t ddb_irq_handler(int irq, void *dev_id);
388void ddb_ports_init(struct ddb *dev);
389int ddb_buffers_alloc(struct ddb *dev);
390int ddb_ports_attach(struct ddb *dev);
391int ddb_device_create(struct ddb *dev);
392int ddb_class_create(void);
393void ddb_class_destroy(void);
394int ddb_init(struct ddb *dev);
395void ddb_unmap(struct ddb *dev);
396
397#endif /* DDBRIDGE_H */
diff --git a/drivers/media/pci/dm1105/dm1105.c b/drivers/media/pci/dm1105/dm1105.c
index 1d41934cfaf5..7c3900dec368 100644
--- a/drivers/media/pci/dm1105/dm1105.c
+++ b/drivers/media/pci/dm1105/dm1105.c
@@ -571,7 +571,7 @@ static u32 functionality(struct i2c_adapter *adap)
571 return I2C_FUNC_I2C; 571 return I2C_FUNC_I2C;
572} 572}
573 573
574static struct i2c_algorithm dm1105_algo = { 574static const struct i2c_algorithm dm1105_algo = {
575 .master_xfer = dm1105_i2c_xfer, 575 .master_xfer = dm1105_i2c_xfer,
576 .functionality = functionality, 576 .functionality = functionality,
577}; 577};
@@ -675,7 +675,7 @@ static void dm1105_emit_key(struct work_struct *work)
675 data = (ircom >> 8) & 0x7f; 675 data = (ircom >> 8) & 0x7f;
676 676
677 /* FIXME: UNKNOWN because we don't generate a full NEC scancode (yet?) */ 677 /* FIXME: UNKNOWN because we don't generate a full NEC scancode (yet?) */
678 rc_keydown(ir->dev, RC_TYPE_UNKNOWN, data, 0); 678 rc_keydown(ir->dev, RC_PROTO_UNKNOWN, data, 0);
679} 679}
680 680
681/* work handler */ 681/* work handler */
@@ -748,7 +748,7 @@ static int dm1105_ir_init(struct dm1105_dev *dm1105)
748 748
749 dev->driver_name = MODULE_NAME; 749 dev->driver_name = MODULE_NAME;
750 dev->map_name = RC_MAP_DM1105_NEC; 750 dev->map_name = RC_MAP_DM1105_NEC;
751 dev->input_name = "DVB on-card IR receiver"; 751 dev->device_name = "DVB on-card IR receiver";
752 dev->input_phys = dm1105->ir.input_phys; 752 dev->input_phys = dm1105->ir.input_phys;
753 dev->input_id.bustype = BUS_PCI; 753 dev->input_id.bustype = BUS_PCI;
754 dev->input_id.version = 1; 754 dev->input_id.version = 1;
@@ -1208,7 +1208,7 @@ static void dm1105_remove(struct pci_dev *pdev)
1208 kfree(dev); 1208 kfree(dev);
1209} 1209}
1210 1210
1211static struct pci_device_id dm1105_id_table[] = { 1211static const struct pci_device_id dm1105_id_table[] = {
1212 { 1212 {
1213 .vendor = PCI_VENDOR_ID_TRIGEM, 1213 .vendor = PCI_VENDOR_ID_TRIGEM,
1214 .device = PCI_DEVICE_ID_DM1105, 1214 .device = PCI_DEVICE_ID_DM1105,
diff --git a/drivers/media/pci/dt3155/dt3155.c b/drivers/media/pci/dt3155/dt3155.c
index 6a219694b225..1775c36891ae 100644
--- a/drivers/media/pci/dt3155/dt3155.c
+++ b/drivers/media/pci/dt3155/dt3155.c
@@ -499,7 +499,7 @@ static int dt3155_init_board(struct dt3155_priv *pd)
499 return 0; 499 return 0;
500} 500}
501 501
502static struct video_device dt3155_vdev = { 502static const struct video_device dt3155_vdev = {
503 .name = DT3155_NAME, 503 .name = DT3155_NAME,
504 .fops = &dt3155_fops, 504 .fops = &dt3155_fops,
505 .ioctl_ops = &dt3155_ioctl_ops, 505 .ioctl_ops = &dt3155_ioctl_ops,
diff --git a/drivers/media/pci/ivtv/ivtv-alsa-mixer.c b/drivers/media/pci/ivtv/ivtv-alsa-mixer.c
index ba372a23eb5c..aee453fcff37 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-mixer.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-mixer.c
@@ -156,7 +156,7 @@ int __init snd_ivtv_mixer_create(struct snd_ivtv_card *itvsc)
156 156
157 strlcpy(sc->mixername, "CX2341[56] Mixer", sizeof(sc->mixername)); 157 strlcpy(sc->mixername, "CX2341[56] Mixer", sizeof(sc->mixername));
158 158
159 ret = snd_ctl_add(sc, snd_ctl_new1(snd_ivtv_mixer_tv_vol, itvsc)); 159 ret = snd_ctl_add(sc, snd_ctl_new1(&snd_ivtv_mixer_tv_vol, itvsc));
160 if (ret) { 160 if (ret) {
161 IVTV_ALSA_WARN("%s: failed to add %s control, err %d\n", 161 IVTV_ALSA_WARN("%s: failed to add %s control, err %d\n",
162 __func__, snd_ivtv_mixer_tv_vol.name, ret); 162 __func__, snd_ivtv_mixer_tv_vol.name, ret);
diff --git a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
index 417d03da01f0..5326d86fa375 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
@@ -41,7 +41,7 @@ MODULE_PARM_DESC(pcm_debug, "enable debug messages for pcm");
41 pr_info("ivtv-alsa-pcm %s: " fmt, __func__, ##arg); \ 41 pr_info("ivtv-alsa-pcm %s: " fmt, __func__, ##arg); \
42 } while (0) 42 } while (0)
43 43
44static struct snd_pcm_hardware snd_ivtv_hw_capture = { 44static const struct snd_pcm_hardware snd_ivtv_hw_capture = {
45 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER | 45 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER |
46 SNDRV_PCM_INFO_MMAP | 46 SNDRV_PCM_INFO_MMAP |
47 SNDRV_PCM_INFO_INTERLEAVED | 47 SNDRV_PCM_INFO_INTERLEAVED |
diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
index e8fa99b6c7b4..54dcac4b2229 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -73,7 +73,7 @@ int (*ivtv_ext_init)(struct ivtv *);
73EXPORT_SYMBOL(ivtv_ext_init); 73EXPORT_SYMBOL(ivtv_ext_init);
74 74
75/* add your revision and whatnot here */ 75/* add your revision and whatnot here */
76static struct pci_device_id ivtv_pci_tbl[] = { 76static const struct pci_device_id ivtv_pci_tbl[] = {
77 {PCI_VENDOR_ID_ICOMP, PCI_DEVICE_ID_IVTV15, 77 {PCI_VENDOR_ID_ICOMP, PCI_DEVICE_ID_IVTV15,
78 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 78 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
79 {PCI_VENDOR_ID_ICOMP, PCI_DEVICE_ID_IVTV16, 79 {PCI_VENDOR_ID_ICOMP, PCI_DEVICE_ID_IVTV16,
diff --git a/drivers/media/pci/ivtv/ivtv-i2c.c b/drivers/media/pci/ivtv/ivtv-i2c.c
index dea80efd5836..5a35e366f4c0 100644
--- a/drivers/media/pci/ivtv/ivtv-i2c.c
+++ b/drivers/media/pci/ivtv/ivtv-i2c.c
@@ -148,7 +148,7 @@ static const char * const hw_devicenames[] = {
148 "ir_video", /* IVTV_HW_I2C_IR_RX_ADAPTEC */ 148 "ir_video", /* IVTV_HW_I2C_IR_RX_ADAPTEC */
149}; 149};
150 150
151static int get_key_adaptec(struct IR_i2c *ir, enum rc_type *protocol, 151static int get_key_adaptec(struct IR_i2c *ir, enum rc_proto *protocol,
152 u32 *scancode, u8 *toggle) 152 u32 *scancode, u8 *toggle)
153{ 153{
154 unsigned char keybuf[4]; 154 unsigned char keybuf[4];
@@ -168,7 +168,7 @@ static int get_key_adaptec(struct IR_i2c *ir, enum rc_type *protocol,
168 keybuf[2] &= 0x7f; 168 keybuf[2] &= 0x7f;
169 keybuf[3] |= 0x80; 169 keybuf[3] |= 0x80;
170 170
171 *protocol = RC_TYPE_UNKNOWN; 171 *protocol = RC_PROTO_UNKNOWN;
172 *scancode = keybuf[3] | keybuf[2] << 8 | keybuf[1] << 16 |keybuf[0] << 24; 172 *scancode = keybuf[3] | keybuf[2] << 8 | keybuf[1] << 16 |keybuf[0] << 24;
173 *toggle = 0; 173 *toggle = 0;
174 return 1; 174 return 1;
@@ -201,22 +201,22 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
201 init_data->ir_codes = RC_MAP_AVERMEDIA_CARDBUS; 201 init_data->ir_codes = RC_MAP_AVERMEDIA_CARDBUS;
202 init_data->internal_get_key_func = 202 init_data->internal_get_key_func =
203 IR_KBD_GET_KEY_AVERMEDIA_CARDBUS; 203 IR_KBD_GET_KEY_AVERMEDIA_CARDBUS;
204 init_data->type = RC_BIT_OTHER; 204 init_data->type = RC_PROTO_BIT_OTHER;
205 init_data->name = "AVerMedia AVerTV card"; 205 init_data->name = "AVerMedia AVerTV card";
206 break; 206 break;
207 case IVTV_HW_I2C_IR_RX_HAUP_EXT: 207 case IVTV_HW_I2C_IR_RX_HAUP_EXT:
208 case IVTV_HW_I2C_IR_RX_HAUP_INT: 208 case IVTV_HW_I2C_IR_RX_HAUP_INT:
209 init_data->ir_codes = RC_MAP_HAUPPAUGE; 209 init_data->ir_codes = RC_MAP_HAUPPAUGE;
210 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP; 210 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP;
211 init_data->type = RC_BIT_RC5; 211 init_data->type = RC_PROTO_BIT_RC5;
212 init_data->name = itv->card_name; 212 init_data->name = itv->card_name;
213 break; 213 break;
214 case IVTV_HW_Z8F0811_IR_RX_HAUP: 214 case IVTV_HW_Z8F0811_IR_RX_HAUP:
215 /* Default to grey remote */ 215 /* Default to grey remote */
216 init_data->ir_codes = RC_MAP_HAUPPAUGE; 216 init_data->ir_codes = RC_MAP_HAUPPAUGE;
217 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 217 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
218 init_data->type = RC_BIT_RC5 | RC_BIT_RC6_MCE | 218 init_data->type = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC6_MCE |
219 RC_BIT_RC6_6A_32; 219 RC_PROTO_BIT_RC6_6A_32;
220 init_data->name = itv->card_name; 220 init_data->name = itv->card_name;
221 break; 221 break;
222 case IVTV_HW_I2C_IR_RX_ADAPTEC: 222 case IVTV_HW_I2C_IR_RX_ADAPTEC:
@@ -224,7 +224,7 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
224 init_data->name = itv->card_name; 224 init_data->name = itv->card_name;
225 /* FIXME: The protocol and RC_MAP needs to be corrected */ 225 /* FIXME: The protocol and RC_MAP needs to be corrected */
226 init_data->ir_codes = RC_MAP_EMPTY; 226 init_data->ir_codes = RC_MAP_EMPTY;
227 init_data->type = RC_BIT_UNKNOWN; 227 init_data->type = RC_PROTO_BIT_UNKNOWN;
228 break; 228 break;
229 } 229 }
230 230
@@ -632,7 +632,7 @@ static const struct i2c_algorithm ivtv_algo = {
632}; 632};
633 633
634/* template for our-bit banger */ 634/* template for our-bit banger */
635static struct i2c_adapter ivtv_i2c_adap_hw_template = { 635static const struct i2c_adapter ivtv_i2c_adap_hw_template = {
636 .name = "ivtv i2c driver", 636 .name = "ivtv i2c driver",
637 .algo = &ivtv_algo, 637 .algo = &ivtv_algo,
638 .algo_data = NULL, /* filled from template */ 638 .algo_data = NULL, /* filled from template */
@@ -682,7 +682,7 @@ static int ivtv_getsda_old(void *data)
682} 682}
683 683
684/* template for i2c-bit-algo */ 684/* template for i2c-bit-algo */
685static struct i2c_adapter ivtv_i2c_adap_template = { 685static const struct i2c_adapter ivtv_i2c_adap_template = {
686 .name = "ivtv i2c driver", 686 .name = "ivtv i2c driver",
687 .algo = NULL, /* set by i2c-algo-bit */ 687 .algo = NULL, /* set by i2c-algo-bit */
688 .algo_data = NULL, /* filled from template */ 688 .algo_data = NULL, /* filled from template */
diff --git a/drivers/media/pci/mantis/hopper_cards.c b/drivers/media/pci/mantis/hopper_cards.c
index 68b5800030b7..11e987860b23 100644
--- a/drivers/media/pci/mantis/hopper_cards.c
+++ b/drivers/media/pci/mantis/hopper_cards.c
@@ -255,7 +255,7 @@ static void hopper_pci_remove(struct pci_dev *pdev)
255 255
256} 256}
257 257
258static struct pci_device_id hopper_pci_table[] = { 258static const struct pci_device_id hopper_pci_table[] = {
259 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3028_DVB_T, &vp3028_config, 259 MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3028_DVB_T, &vp3028_config,
260 NULL), 260 NULL),
261 { } 261 { }
diff --git a/drivers/media/pci/mantis/mantis_cards.c b/drivers/media/pci/mantis/mantis_cards.c
index cdefffc16d9e..adc980d33711 100644
--- a/drivers/media/pci/mantis/mantis_cards.c
+++ b/drivers/media/pci/mantis/mantis_cards.c
@@ -281,7 +281,7 @@ static void mantis_pci_remove(struct pci_dev *pdev)
281 return; 281 return;
282} 282}
283 283
284static struct pci_device_id mantis_pci_table[] = { 284static const struct pci_device_id mantis_pci_table[] = {
285 MAKE_ENTRY(TECHNISAT, CABLESTAR_HD2, &vp2040_config, 285 MAKE_ENTRY(TECHNISAT, CABLESTAR_HD2, &vp2040_config,
286 RC_MAP_TECHNISAT_TS35), 286 RC_MAP_TECHNISAT_TS35),
287 MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_10, &vp1041_config, 287 MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_10, &vp1041_config,
diff --git a/drivers/media/pci/mantis/mantis_common.h b/drivers/media/pci/mantis/mantis_common.h
index d48778a366a9..a664c319ef0a 100644
--- a/drivers/media/pci/mantis/mantis_common.h
+++ b/drivers/media/pci/mantis/mantis_common.h
@@ -176,7 +176,7 @@ struct mantis_pci {
176 struct work_struct uart_work; 176 struct work_struct uart_work;
177 177
178 struct rc_dev *rc; 178 struct rc_dev *rc;
179 char input_name[80]; 179 char device_name[80];
180 char input_phys[80]; 180 char input_phys[80];
181 char *rc_map_name; 181 char *rc_map_name;
182}; 182};
diff --git a/drivers/media/pci/mantis/mantis_i2c.c b/drivers/media/pci/mantis/mantis_i2c.c
index d72ee47dc6e4..496c10dfc4df 100644
--- a/drivers/media/pci/mantis/mantis_i2c.c
+++ b/drivers/media/pci/mantis/mantis_i2c.c
@@ -212,7 +212,7 @@ static u32 mantis_i2c_func(struct i2c_adapter *adapter)
212 return I2C_FUNC_SMBUS_EMUL; 212 return I2C_FUNC_SMBUS_EMUL;
213} 213}
214 214
215static struct i2c_algorithm mantis_algo = { 215static const struct i2c_algorithm mantis_algo = {
216 .master_xfer = mantis_i2c_xfer, 216 .master_xfer = mantis_i2c_xfer,
217 .functionality = mantis_i2c_func, 217 .functionality = mantis_i2c_func,
218}; 218};
diff --git a/drivers/media/pci/mantis/mantis_input.c b/drivers/media/pci/mantis/mantis_input.c
index 50d10cb7d49d..7519dcc934dd 100644
--- a/drivers/media/pci/mantis/mantis_input.c
+++ b/drivers/media/pci/mantis/mantis_input.c
@@ -31,7 +31,7 @@
31void mantis_input_process(struct mantis_pci *mantis, int scancode) 31void mantis_input_process(struct mantis_pci *mantis, int scancode)
32{ 32{
33 if (mantis->rc) 33 if (mantis->rc)
34 rc_keydown(mantis->rc, RC_TYPE_UNKNOWN, scancode, 0); 34 rc_keydown(mantis->rc, RC_PROTO_UNKNOWN, scancode, 0);
35} 35}
36 36
37int mantis_input_init(struct mantis_pci *mantis) 37int mantis_input_init(struct mantis_pci *mantis)
@@ -46,12 +46,12 @@ int mantis_input_init(struct mantis_pci *mantis)
46 goto out; 46 goto out;
47 } 47 }
48 48
49 snprintf(mantis->input_name, sizeof(mantis->input_name), 49 snprintf(mantis->device_name, sizeof(mantis->device_name),
50 "Mantis %s IR receiver", mantis->hwconfig->model_name); 50 "Mantis %s IR receiver", mantis->hwconfig->model_name);
51 snprintf(mantis->input_phys, sizeof(mantis->input_phys), 51 snprintf(mantis->input_phys, sizeof(mantis->input_phys),
52 "pci-%s/ir0", pci_name(mantis->pdev)); 52 "pci-%s/ir0", pci_name(mantis->pdev));
53 53
54 dev->input_name = mantis->input_name; 54 dev->device_name = mantis->device_name;
55 dev->input_phys = mantis->input_phys; 55 dev->input_phys = mantis->input_phys;
56 dev->input_id.bustype = BUS_PCI; 56 dev->input_id.bustype = BUS_PCI;
57 dev->input_id.vendor = mantis->vendor_id; 57 dev->input_id.vendor = mantis->vendor_id;
diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c
index 9c4a024745de..49e047e4a81e 100644
--- a/drivers/media/pci/meye/meye.c
+++ b/drivers/media/pci/meye/meye.c
@@ -1533,7 +1533,7 @@ static const struct v4l2_ioctl_ops meye_ioctl_ops = {
1533 .vidioc_default = vidioc_default, 1533 .vidioc_default = vidioc_default,
1534}; 1534};
1535 1535
1536static struct video_device meye_template = { 1536static const struct video_device meye_template = {
1537 .name = "meye", 1537 .name = "meye",
1538 .fops = &meye_fops, 1538 .fops = &meye_fops,
1539 .ioctl_ops = &meye_ioctl_ops, 1539 .ioctl_ops = &meye_ioctl_ops,
@@ -1801,7 +1801,7 @@ static void meye_remove(struct pci_dev *pcidev)
1801 printk(KERN_INFO "meye: removed\n"); 1801 printk(KERN_INFO "meye: removed\n");
1802} 1802}
1803 1803
1804static struct pci_device_id meye_pci_tbl[] = { 1804static const struct pci_device_id meye_pci_tbl[] = {
1805 { PCI_VDEVICE(KAWASAKI, PCI_DEVICE_ID_MCHIP_KL5A72002), 0 }, 1805 { PCI_VDEVICE(KAWASAKI, PCI_DEVICE_ID_MCHIP_KL5A72002), 0 },
1806 { } 1806 { }
1807}; 1807};
diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
index 5c0a4e614413..60e6cd5b3a03 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
@@ -1014,7 +1014,7 @@ static void netup_unidvb_finidev(struct pci_dev *pci_dev)
1014} 1014}
1015 1015
1016 1016
1017static struct pci_device_id netup_unidvb_pci_tbl[] = { 1017static const struct pci_device_id netup_unidvb_pci_tbl[] = {
1018 { PCI_DEVICE(0x1b55, 0x18f6) }, /* hw rev. 1.3 */ 1018 { PCI_DEVICE(0x1b55, 0x18f6) }, /* hw rev. 1.3 */
1019 { PCI_DEVICE(0x1b55, 0x18f7) }, /* hw rev. 1.4 */ 1019 { PCI_DEVICE(0x1b55, 0x18f7) }, /* hw rev. 1.4 */
1020 { 0, } 1020 { 0, }
diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c b/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c
index b49e4f9788e8..b13e319d24b7 100644
--- a/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c
+++ b/drivers/media/pci/netup_unidvb/netup_unidvb_i2c.c
@@ -300,7 +300,7 @@ static const struct i2c_algorithm netup_i2c_algorithm = {
300 .functionality = netup_i2c_func, 300 .functionality = netup_i2c_func,
301}; 301};
302 302
303static struct i2c_adapter netup_i2c_adapter = { 303static const struct i2c_adapter netup_i2c_adapter = {
304 .owner = THIS_MODULE, 304 .owner = THIS_MODULE,
305 .name = NETUP_UNIDVB_NAME, 305 .name = NETUP_UNIDVB_NAME,
306 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD, 306 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
diff --git a/drivers/media/pci/ngene/ngene-i2c.c b/drivers/media/pci/ngene/ngene-i2c.c
index fbf36353c701..3004947f300b 100644
--- a/drivers/media/pci/ngene/ngene-i2c.c
+++ b/drivers/media/pci/ngene/ngene-i2c.c
@@ -150,7 +150,7 @@ static u32 ngene_i2c_functionality(struct i2c_adapter *adap)
150 return I2C_FUNC_SMBUS_EMUL; 150 return I2C_FUNC_SMBUS_EMUL;
151} 151}
152 152
153static struct i2c_algorithm ngene_i2c_algo = { 153static const struct i2c_algorithm ngene_i2c_algo = {
154 .master_xfer = ngene_i2c_master_xfer, 154 .master_xfer = ngene_i2c_master_xfer,
155 .functionality = ngene_i2c_functionality, 155 .functionality = ngene_i2c_functionality,
156}; 156};
diff --git a/drivers/media/pci/pluto2/pluto2.c b/drivers/media/pci/pluto2/pluto2.c
index 74838109afe5..39dcba2b620c 100644
--- a/drivers/media/pci/pluto2/pluto2.c
+++ b/drivers/media/pci/pluto2/pluto2.c
@@ -770,7 +770,7 @@ static void pluto2_remove(struct pci_dev *pdev)
770#define PCI_DEVICE_ID_PLUTO2 0x0001 770#define PCI_DEVICE_ID_PLUTO2 0x0001
771#endif 771#endif
772 772
773static struct pci_device_id pluto2_id_table[] = { 773static const struct pci_device_id pluto2_id_table[] = {
774 { 774 {
775 .vendor = PCI_VENDOR_ID_SCM, 775 .vendor = PCI_VENDOR_ID_SCM,
776 .device = PCI_DEVICE_ID_PLUTO2, 776 .device = PCI_DEVICE_ID_PLUTO2,
diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c
index 3219d2f3271e..b6b1a8d20d86 100644
--- a/drivers/media/pci/pt1/pt1.c
+++ b/drivers/media/pci/pt1/pt1.c
@@ -1202,7 +1202,7 @@ err:
1202 1202
1203} 1203}
1204 1204
1205static struct pci_device_id pt1_id_table[] = { 1205static const struct pci_device_id pt1_id_table[] = {
1206 { PCI_DEVICE(0x10ee, 0x211a) }, 1206 { PCI_DEVICE(0x10ee, 0x211a) },
1207 { PCI_DEVICE(0x10ee, 0x222a) }, 1207 { PCI_DEVICE(0x10ee, 0x222a) },
1208 { }, 1208 { },
diff --git a/drivers/media/pci/pt3/pt3.c b/drivers/media/pci/pt3/pt3.c
index e8b5d0992157..34044a45fecc 100644
--- a/drivers/media/pci/pt3/pt3.c
+++ b/drivers/media/pci/pt3/pt3.c
@@ -472,7 +472,6 @@ static int pt3_fetch_thread(void *data)
472 } 472 }
473 dev_dbg(adap->dvb_adap.device, "PT3: [%s] exited\n", 473 dev_dbg(adap->dvb_adap.device, "PT3: [%s] exited\n",
474 adap->thread->comm); 474 adap->thread->comm);
475 adap->thread = NULL;
476 return 0; 475 return 0;
477} 476}
478 477
@@ -486,6 +485,7 @@ static int pt3_start_streaming(struct pt3_adapter *adap)
486 if (IS_ERR(thread)) { 485 if (IS_ERR(thread)) {
487 int ret = PTR_ERR(thread); 486 int ret = PTR_ERR(thread);
488 487
488 adap->thread = NULL;
489 dev_warn(adap->dvb_adap.device, 489 dev_warn(adap->dvb_adap.device,
490 "PT3 (adap:%d, dmx:%d): failed to start kthread\n", 490 "PT3 (adap:%d, dmx:%d): failed to start kthread\n",
491 adap->dvb_adap.num, adap->dmxdev.dvbdev->id); 491 adap->dvb_adap.num, adap->dmxdev.dvbdev->id);
@@ -508,6 +508,7 @@ static int pt3_stop_streaming(struct pt3_adapter *adap)
508 508
509 /* kill the fetching thread */ 509 /* kill the fetching thread */
510 ret = kthread_stop(adap->thread); 510 ret = kthread_stop(adap->thread);
511 adap->thread = NULL;
511 return ret; 512 return ret;
512} 513}
513 514
@@ -520,14 +521,8 @@ static int pt3_start_feed(struct dvb_demux_feed *feed)
520 521
521 adap = container_of(feed->demux, struct pt3_adapter, demux); 522 adap = container_of(feed->demux, struct pt3_adapter, demux);
522 adap->num_feeds++; 523 adap->num_feeds++;
523 if (adap->thread) 524 if (adap->num_feeds > 1)
524 return 0; 525 return 0;
525 if (adap->num_feeds != 1) {
526 dev_warn(adap->dvb_adap.device,
527 "%s: unmatched start/stop_feed in adap:%i/dmx:%i\n",
528 __func__, adap->dvb_adap.num, adap->dmxdev.dvbdev->id);
529 adap->num_feeds = 1;
530 }
531 526
532 return pt3_start_streaming(adap); 527 return pt3_start_streaming(adap);
533 528
diff --git a/drivers/media/pci/saa7134/saa7134-alsa.c b/drivers/media/pci/saa7134/saa7134-alsa.c
index bf358ec7aca5..c59b69f1af9d 100644
--- a/drivers/media/pci/saa7134/saa7134-alsa.c
+++ b/drivers/media/pci/saa7134/saa7134-alsa.c
@@ -627,7 +627,7 @@ snd_card_saa7134_capture_pointer(struct snd_pcm_substream * substream)
627 * switching to 32kHz without any frequency translation 627 * switching to 32kHz without any frequency translation
628 */ 628 */
629 629
630static struct snd_pcm_hardware snd_card_saa7134_capture = 630static const struct snd_pcm_hardware snd_card_saa7134_capture =
631{ 631{
632 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 632 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
633 SNDRV_PCM_INFO_BLOCK_TRANSFER | 633 SNDRV_PCM_INFO_BLOCK_TRANSFER |
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c
index b1d3648dcba1..66acfd35ffc6 100644
--- a/drivers/media/pci/saa7134/saa7134-empress.c
+++ b/drivers/media/pci/saa7134/saa7134-empress.c
@@ -205,7 +205,7 @@ static const struct v4l2_ioctl_ops ts_ioctl_ops = {
205 205
206/* ----------------------------------------------------------- */ 206/* ----------------------------------------------------------- */
207 207
208static struct video_device saa7134_empress_template = { 208static const struct video_device saa7134_empress_template = {
209 .name = "saa7134-empress", 209 .name = "saa7134-empress",
210 .fops = &ts_fops, 210 .fops = &ts_fops,
211 .ioctl_ops = &ts_ioctl_ops, 211 .ioctl_ops = &ts_ioctl_ops,
diff --git a/drivers/media/pci/saa7134/saa7134-i2c.c b/drivers/media/pci/saa7134/saa7134-i2c.c
index 9d0e69eae036..8f2ed632840f 100644
--- a/drivers/media/pci/saa7134/saa7134-i2c.c
+++ b/drivers/media/pci/saa7134/saa7134-i2c.c
@@ -339,7 +339,7 @@ static const struct i2c_algorithm saa7134_algo = {
339 .functionality = functionality, 339 .functionality = functionality,
340}; 340};
341 341
342static struct i2c_adapter saa7134_adap_template = { 342static const struct i2c_adapter saa7134_adap_template = {
343 .owner = THIS_MODULE, 343 .owner = THIS_MODULE,
344 .name = "saa7134", 344 .name = "saa7134",
345 .algo = &saa7134_algo, 345 .algo = &saa7134_algo,
diff --git a/drivers/media/pci/saa7134/saa7134-input.c b/drivers/media/pci/saa7134/saa7134-input.c
index 78849c19f68a..9337e4615519 100644
--- a/drivers/media/pci/saa7134/saa7134-input.c
+++ b/drivers/media/pci/saa7134/saa7134-input.c
@@ -83,14 +83,16 @@ static int build_key(struct saa7134_dev *dev)
83 if (data == ir->mask_keycode) 83 if (data == ir->mask_keycode)
84 rc_keyup(ir->dev); 84 rc_keyup(ir->dev);
85 else 85 else
86 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); 86 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data,
87 0);
87 return 0; 88 return 0;
88 } 89 }
89 90
90 if (ir->polling) { 91 if (ir->polling) {
91 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || 92 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
92 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { 93 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
93 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); 94 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data,
95 0);
94 } else { 96 } else {
95 rc_keyup(ir->dev); 97 rc_keyup(ir->dev);
96 } 98 }
@@ -98,7 +100,8 @@ static int build_key(struct saa7134_dev *dev)
98 else { /* IRQ driven mode - handle key press and release in one go */ 100 else { /* IRQ driven mode - handle key press and release in one go */
99 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || 101 if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
100 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { 102 (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
101 rc_keydown_notimeout(ir->dev, RC_TYPE_UNKNOWN, data, 0); 103 rc_keydown_notimeout(ir->dev, RC_PROTO_UNKNOWN, data,
104 0);
102 rc_keyup(ir->dev); 105 rc_keyup(ir->dev);
103 } 106 }
104 } 107 }
@@ -108,7 +111,7 @@ static int build_key(struct saa7134_dev *dev)
108 111
109/* --------------------- Chip specific I2C key builders ----------------- */ 112/* --------------------- Chip specific I2C key builders ----------------- */
110 113
111static int get_key_flydvb_trio(struct IR_i2c *ir, enum rc_type *protocol, 114static int get_key_flydvb_trio(struct IR_i2c *ir, enum rc_proto *protocol,
112 u32 *scancode, u8 *toggle) 115 u32 *scancode, u8 *toggle)
113{ 116{
114 int gpio; 117 int gpio;
@@ -154,13 +157,14 @@ static int get_key_flydvb_trio(struct IR_i2c *ir, enum rc_type *protocol,
154 return -EIO; 157 return -EIO;
155 } 158 }
156 159
157 *protocol = RC_TYPE_UNKNOWN; 160 *protocol = RC_PROTO_UNKNOWN;
158 *scancode = b; 161 *scancode = b;
159 *toggle = 0; 162 *toggle = 0;
160 return 1; 163 return 1;
161} 164}
162 165
163static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir, enum rc_type *protocol, 166static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir,
167 enum rc_proto *protocol,
164 u32 *scancode, u8 *toggle) 168 u32 *scancode, u8 *toggle)
165{ 169{
166 unsigned char b; 170 unsigned char b;
@@ -201,14 +205,14 @@ static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir, enum rc_type *protocol
201 /* Button pressed */ 205 /* Button pressed */
202 206
203 input_dbg("get_key_msi_tvanywhere_plus: Key = 0x%02X\n", b); 207 input_dbg("get_key_msi_tvanywhere_plus: Key = 0x%02X\n", b);
204 *protocol = RC_TYPE_UNKNOWN; 208 *protocol = RC_PROTO_UNKNOWN;
205 *scancode = b; 209 *scancode = b;
206 *toggle = 0; 210 *toggle = 0;
207 return 1; 211 return 1;
208} 212}
209 213
210/* copied and modified from get_key_msi_tvanywhere_plus() */ 214/* copied and modified from get_key_msi_tvanywhere_plus() */
211static int get_key_kworld_pc150u(struct IR_i2c *ir, enum rc_type *protocol, 215static int get_key_kworld_pc150u(struct IR_i2c *ir, enum rc_proto *protocol,
212 u32 *scancode, u8 *toggle) 216 u32 *scancode, u8 *toggle)
213{ 217{
214 unsigned char b; 218 unsigned char b;
@@ -249,13 +253,13 @@ static int get_key_kworld_pc150u(struct IR_i2c *ir, enum rc_type *protocol,
249 /* Button pressed */ 253 /* Button pressed */
250 254
251 input_dbg("get_key_kworld_pc150u: Key = 0x%02X\n", b); 255 input_dbg("get_key_kworld_pc150u: Key = 0x%02X\n", b);
252 *protocol = RC_TYPE_UNKNOWN; 256 *protocol = RC_PROTO_UNKNOWN;
253 *scancode = b; 257 *scancode = b;
254 *toggle = 0; 258 *toggle = 0;
255 return 1; 259 return 1;
256} 260}
257 261
258static int get_key_purpletv(struct IR_i2c *ir, enum rc_type *protocol, 262static int get_key_purpletv(struct IR_i2c *ir, enum rc_proto *protocol,
259 u32 *scancode, u8 *toggle) 263 u32 *scancode, u8 *toggle)
260{ 264{
261 unsigned char b; 265 unsigned char b;
@@ -274,13 +278,13 @@ static int get_key_purpletv(struct IR_i2c *ir, enum rc_type *protocol,
274 if (b & 0x80) 278 if (b & 0x80)
275 return 1; 279 return 1;
276 280
277 *protocol = RC_TYPE_UNKNOWN; 281 *protocol = RC_PROTO_UNKNOWN;
278 *scancode = b; 282 *scancode = b;
279 *toggle = 0; 283 *toggle = 0;
280 return 1; 284 return 1;
281} 285}
282 286
283static int get_key_hvr1110(struct IR_i2c *ir, enum rc_type *protocol, 287static int get_key_hvr1110(struct IR_i2c *ir, enum rc_proto *protocol,
284 u32 *scancode, u8 *toggle) 288 u32 *scancode, u8 *toggle)
285{ 289{
286 unsigned char buf[5]; 290 unsigned char buf[5];
@@ -304,14 +308,14 @@ static int get_key_hvr1110(struct IR_i2c *ir, enum rc_type *protocol,
304 * 308 *
305 * FIXME: start bits could maybe be used...? 309 * FIXME: start bits could maybe be used...?
306 */ 310 */
307 *protocol = RC_TYPE_RC5; 311 *protocol = RC_PROTO_RC5;
308 *scancode = RC_SCANCODE_RC5(buf[3] & 0x1f, buf[4] >> 2); 312 *scancode = RC_SCANCODE_RC5(buf[3] & 0x1f, buf[4] >> 2);
309 *toggle = !!(buf[3] & 0x40); 313 *toggle = !!(buf[3] & 0x40);
310 return 1; 314 return 1;
311} 315}
312 316
313 317
314static int get_key_beholdm6xx(struct IR_i2c *ir, enum rc_type *protocol, 318static int get_key_beholdm6xx(struct IR_i2c *ir, enum rc_proto *protocol,
315 u32 *scancode, u8 *toggle) 319 u32 *scancode, u8 *toggle)
316{ 320{
317 unsigned char data[12]; 321 unsigned char data[12];
@@ -338,7 +342,7 @@ static int get_key_beholdm6xx(struct IR_i2c *ir, enum rc_type *protocol,
338 if (data[9] != (unsigned char)(~data[8])) 342 if (data[9] != (unsigned char)(~data[8]))
339 return 0; 343 return 0;
340 344
341 *protocol = RC_TYPE_NECX; 345 *protocol = RC_PROTO_NECX;
342 *scancode = RC_SCANCODE_NECX(data[11] << 8 | data[10], data[9]); 346 *scancode = RC_SCANCODE_NECX(data[11] << 8 | data[10], data[9]);
343 *toggle = 0; 347 *toggle = 0;
344 return 1; 348 return 1;
@@ -347,7 +351,7 @@ static int get_key_beholdm6xx(struct IR_i2c *ir, enum rc_type *protocol,
347/* Common (grey or coloured) pinnacle PCTV remote handling 351/* Common (grey or coloured) pinnacle PCTV remote handling
348 * 352 *
349 */ 353 */
350static int get_key_pinnacle(struct IR_i2c *ir, enum rc_type *protocol, 354static int get_key_pinnacle(struct IR_i2c *ir, enum rc_proto *protocol,
351 u32 *scancode, u8 *toggle, int parity_offset, 355 u32 *scancode, u8 *toggle, int parity_offset,
352 int marker, int code_modulo) 356 int marker, int code_modulo)
353{ 357{
@@ -384,7 +388,7 @@ static int get_key_pinnacle(struct IR_i2c *ir, enum rc_type *protocol,
384 388
385 code %= code_modulo; 389 code %= code_modulo;
386 390
387 *protocol = RC_TYPE_UNKNOWN; 391 *protocol = RC_PROTO_UNKNOWN;
388 *scancode = code; 392 *scancode = code;
389 *toggle = 0; 393 *toggle = 0;
390 394
@@ -401,7 +405,7 @@ static int get_key_pinnacle(struct IR_i2c *ir, enum rc_type *protocol,
401 * 405 *
402 * Sylvain Pasche <sylvain.pasche@gmail.com> 406 * Sylvain Pasche <sylvain.pasche@gmail.com>
403 */ 407 */
404static int get_key_pinnacle_grey(struct IR_i2c *ir, enum rc_type *protocol, 408static int get_key_pinnacle_grey(struct IR_i2c *ir, enum rc_proto *protocol,
405 u32 *scancode, u8 *toggle) 409 u32 *scancode, u8 *toggle)
406{ 410{
407 411
@@ -413,7 +417,7 @@ static int get_key_pinnacle_grey(struct IR_i2c *ir, enum rc_type *protocol,
413 * 417 *
414 * Ricardo Cerqueira <v4l@cerqueira.org> 418 * Ricardo Cerqueira <v4l@cerqueira.org>
415 */ 419 */
416static int get_key_pinnacle_color(struct IR_i2c *ir, enum rc_type *protocol, 420static int get_key_pinnacle_color(struct IR_i2c *ir, enum rc_proto *protocol,
417 u32 *scancode, u8 *toggle) 421 u32 *scancode, u8 *toggle)
418{ 422{
419 /* code_modulo parameter (0x88) is used to reduce code value to fit inside IR_KEYTAB_SIZE 423 /* code_modulo parameter (0x88) is used to reduce code value to fit inside IR_KEYTAB_SIZE
@@ -452,13 +456,6 @@ static void saa7134_input_timer(unsigned long data)
452 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); 456 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
453} 457}
454 458
455static void ir_raw_decode_timer_end(unsigned long data)
456{
457 struct saa7134_dev *dev = (struct saa7134_dev *)data;
458
459 ir_raw_event_handle(dev->remote->dev);
460}
461
462static int __saa7134_ir_start(void *priv) 459static int __saa7134_ir_start(void *priv)
463{ 460{
464 struct saa7134_dev *dev = priv; 461 struct saa7134_dev *dev = priv;
@@ -514,10 +511,6 @@ static int __saa7134_ir_start(void *priv)
514 (unsigned long)dev); 511 (unsigned long)dev);
515 ir->timer.expires = jiffies + HZ; 512 ir->timer.expires = jiffies + HZ;
516 add_timer(&ir->timer); 513 add_timer(&ir->timer);
517 } else if (ir->raw_decode) {
518 /* set timer_end for code completion */
519 setup_timer(&ir->timer, ir_raw_decode_timer_end,
520 (unsigned long)dev);
521 } 514 }
522 515
523 return 0; 516 return 0;
@@ -535,7 +528,7 @@ static void __saa7134_ir_stop(void *priv)
535 if (!ir->running) 528 if (!ir->running)
536 return; 529 return;
537 530
538 if (ir->polling || ir->raw_decode) 531 if (ir->polling)
539 del_timer_sync(&ir->timer); 532 del_timer_sync(&ir->timer);
540 533
541 ir->running = false; 534 ir->running = false;
@@ -867,10 +860,12 @@ int saa7134_input_init1(struct saa7134_dev *dev)
867 rc->priv = dev; 860 rc->priv = dev;
868 rc->open = saa7134_ir_open; 861 rc->open = saa7134_ir_open;
869 rc->close = saa7134_ir_close; 862 rc->close = saa7134_ir_close;
870 if (raw_decode) 863 if (raw_decode) {
871 rc->driver_type = RC_DRIVER_IR_RAW; 864 rc->driver_type = RC_DRIVER_IR_RAW;
865 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
866 }
872 867
873 rc->input_name = ir->name; 868 rc->device_name = ir->name;
874 rc->input_phys = ir->phys; 869 rc->input_phys = ir->phys;
875 rc->input_id.bustype = BUS_PCI; 870 rc->input_id.bustype = BUS_PCI;
876 rc->input_id.version = 1; 871 rc->input_id.version = 1;
@@ -884,6 +879,9 @@ int saa7134_input_init1(struct saa7134_dev *dev)
884 rc->dev.parent = &dev->pci->dev; 879 rc->dev.parent = &dev->pci->dev;
885 rc->map_name = ir_codes; 880 rc->map_name = ir_codes;
886 rc->driver_name = MODULE_NAME; 881 rc->driver_name = MODULE_NAME;
882 rc->min_timeout = 1;
883 rc->timeout = IR_DEFAULT_TIMEOUT;
884 rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
887 885
888 err = rc_register_device(rc); 886 err = rc_register_device(rc);
889 if (err) 887 if (err)
@@ -1028,7 +1026,7 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
1028 dev->init_data.name = "BeholdTV"; 1026 dev->init_data.name = "BeholdTV";
1029 dev->init_data.get_key = get_key_beholdm6xx; 1027 dev->init_data.get_key = get_key_beholdm6xx;
1030 dev->init_data.ir_codes = RC_MAP_BEHOLD; 1028 dev->init_data.ir_codes = RC_MAP_BEHOLD;
1031 dev->init_data.type = RC_BIT_NECX; 1029 dev->init_data.type = RC_PROTO_BIT_NECX;
1032 info.addr = 0x2d; 1030 info.addr = 0x2d;
1033 break; 1031 break;
1034 case SAA7134_BOARD_AVERMEDIA_CARDBUS_501: 1032 case SAA7134_BOARD_AVERMEDIA_CARDBUS_501:
@@ -1057,26 +1055,13 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
1057static int saa7134_raw_decode_irq(struct saa7134_dev *dev) 1055static int saa7134_raw_decode_irq(struct saa7134_dev *dev)
1058{ 1056{
1059 struct saa7134_card_ir *ir = dev->remote; 1057 struct saa7134_card_ir *ir = dev->remote;
1060 unsigned long timeout;
1061 int space; 1058 int space;
1062 1059
1063 /* Generate initial event */ 1060 /* Generate initial event */
1064 saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); 1061 saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
1065 saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN); 1062 saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
1066 space = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown; 1063 space = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & ir->mask_keydown;
1067 ir_raw_event_store_edge(dev->remote->dev, space ? IR_SPACE : IR_PULSE); 1064 ir_raw_event_store_edge(dev->remote->dev, !space);
1068
1069 /*
1070 * Wait 15 ms from the start of the first IR event before processing
1071 * the event. This time is enough for NEC protocol. May need adjustments
1072 * to work with other protocols.
1073 */
1074 smp_mb();
1075
1076 if (!timer_pending(&ir->timer)) {
1077 timeout = jiffies + msecs_to_jiffies(15);
1078 mod_timer(&ir->timer, timeout);
1079 }
1080 1065
1081 return 1; 1066 return 1;
1082} 1067}
diff --git a/drivers/media/pci/saa7146/hexium_gemini.c b/drivers/media/pci/saa7146/hexium_gemini.c
index c889ec9f8a5a..f708cab01fef 100644
--- a/drivers/media/pci/saa7146/hexium_gemini.c
+++ b/drivers/media/pci/saa7146/hexium_gemini.c
@@ -363,7 +363,7 @@ static struct saa7146_pci_extension_data hexium_gemini_dual_4bnc = {
363 .ext = &hexium_extension, 363 .ext = &hexium_extension,
364}; 364};
365 365
366static struct pci_device_id pci_tbl[] = { 366static const struct pci_device_id pci_tbl[] = {
367 { 367 {
368 .vendor = PCI_VENDOR_ID_PHILIPS, 368 .vendor = PCI_VENDOR_ID_PHILIPS,
369 .device = PCI_DEVICE_ID_PHILIPS_SAA7146, 369 .device = PCI_DEVICE_ID_PHILIPS_SAA7146,
diff --git a/drivers/media/pci/saa7146/hexium_orion.c b/drivers/media/pci/saa7146/hexium_orion.c
index c306a92e8909..01f01580c7ca 100644
--- a/drivers/media/pci/saa7146/hexium_orion.c
+++ b/drivers/media/pci/saa7146/hexium_orion.c
@@ -427,7 +427,7 @@ static struct saa7146_pci_extension_data hexium_orion_4bnc = {
427 .ext = &extension, 427 .ext = &extension,
428}; 428};
429 429
430static struct pci_device_id pci_tbl[] = { 430static const struct pci_device_id pci_tbl[] = {
431 { 431 {
432 .vendor = PCI_VENDOR_ID_PHILIPS, 432 .vendor = PCI_VENDOR_ID_PHILIPS,
433 .device = PCI_DEVICE_ID_PHILIPS_SAA7146, 433 .device = PCI_DEVICE_ID_PHILIPS_SAA7146,
diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c
index 504d78807639..930218cc2de1 100644
--- a/drivers/media/pci/saa7146/mxb.c
+++ b/drivers/media/pci/saa7146/mxb.c
@@ -819,7 +819,7 @@ static struct saa7146_pci_extension_data mxb = {
819 .ext = &extension, 819 .ext = &extension,
820}; 820};
821 821
822static struct pci_device_id pci_tbl[] = { 822static const struct pci_device_id pci_tbl[] = {
823 { 823 {
824 .vendor = PCI_VENDOR_ID_PHILIPS, 824 .vendor = PCI_VENDOR_ID_PHILIPS,
825 .device = PCI_DEVICE_ID_PHILIPS_SAA7146, 825 .device = PCI_DEVICE_ID_PHILIPS_SAA7146,
diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c
index 75eed4cc4823..fca36a4910c2 100644
--- a/drivers/media/pci/saa7164/saa7164-core.c
+++ b/drivers/media/pci/saa7164/saa7164-core.c
@@ -1490,7 +1490,7 @@ static void saa7164_finidev(struct pci_dev *pci_dev)
1490 kfree(dev); 1490 kfree(dev);
1491} 1491}
1492 1492
1493static struct pci_device_id saa7164_pci_tbl[] = { 1493static const struct pci_device_id saa7164_pci_tbl[] = {
1494 { 1494 {
1495 /* SAA7164 */ 1495 /* SAA7164 */
1496 .vendor = 0x1131, 1496 .vendor = 0x1131,
diff --git a/drivers/media/pci/saa7164/saa7164-i2c.c b/drivers/media/pci/saa7164/saa7164-i2c.c
index 430f6789f222..4bcde7c79dc3 100644
--- a/drivers/media/pci/saa7164/saa7164-i2c.c
+++ b/drivers/media/pci/saa7164/saa7164-i2c.c
@@ -78,7 +78,7 @@ static const struct i2c_algorithm saa7164_i2c_algo_template = {
78 78
79/* ----------------------------------------------------------------------- */ 79/* ----------------------------------------------------------------------- */
80 80
81static struct i2c_adapter saa7164_i2c_adap_template = { 81static const struct i2c_adapter saa7164_i2c_adap_template = {
82 .name = "saa7164", 82 .name = "saa7164",
83 .owner = THIS_MODULE, 83 .owner = THIS_MODULE,
84 .algo = &saa7164_i2c_algo_template, 84 .algo = &saa7164_i2c_algo_template,
diff --git a/drivers/media/pci/smipcie/smipcie-ir.c b/drivers/media/pci/smipcie/smipcie-ir.c
index d2730c3fdbae..c5595af6b976 100644
--- a/drivers/media/pci/smipcie/smipcie-ir.c
+++ b/drivers/media/pci/smipcie/smipcie-ir.c
@@ -144,7 +144,7 @@ static void smi_ir_decode(struct work_struct *work)
144 rc5_system = (dwIRCode & 0x7C0) >> 6; 144 rc5_system = (dwIRCode & 0x7C0) >> 6;
145 toggle = (dwIRCode & 0x800) ? 1 : 0; 145 toggle = (dwIRCode & 0x800) ? 1 : 0;
146 scancode = rc5_system << 8 | rc5_command; 146 scancode = rc5_system << 8 | rc5_command;
147 rc_keydown(rc_dev, RC_TYPE_RC5, scancode, toggle); 147 rc_keydown(rc_dev, RC_PROTO_RC5, scancode, toggle);
148 } 148 }
149 } 149 }
150end_ir_decode: 150end_ir_decode:
@@ -188,14 +188,14 @@ int smi_ir_init(struct smi_dev *dev)
188 return -ENOMEM; 188 return -ENOMEM;
189 189
190 /* init input device */ 190 /* init input device */
191 snprintf(ir->input_name, sizeof(ir->input_name), "IR (%s)", 191 snprintf(ir->device_name, sizeof(ir->device_name), "IR (%s)",
192 dev->info->name); 192 dev->info->name);
193 snprintf(ir->input_phys, sizeof(ir->input_phys), "pci-%s/ir0", 193 snprintf(ir->input_phys, sizeof(ir->input_phys), "pci-%s/ir0",
194 pci_name(dev->pci_dev)); 194 pci_name(dev->pci_dev));
195 195
196 rc_dev->driver_name = "SMI_PCIe"; 196 rc_dev->driver_name = "SMI_PCIe";
197 rc_dev->input_phys = ir->input_phys; 197 rc_dev->input_phys = ir->input_phys;
198 rc_dev->input_name = ir->input_name; 198 rc_dev->device_name = ir->device_name;
199 rc_dev->input_id.bustype = BUS_PCI; 199 rc_dev->input_id.bustype = BUS_PCI;
200 rc_dev->input_id.version = 1; 200 rc_dev->input_id.version = 1;
201 rc_dev->input_id.vendor = dev->pci_dev->subsystem_vendor; 201 rc_dev->input_id.vendor = dev->pci_dev->subsystem_vendor;
diff --git a/drivers/media/pci/smipcie/smipcie.h b/drivers/media/pci/smipcie/smipcie.h
index 611e4f02cadd..c8368c78ddd5 100644
--- a/drivers/media/pci/smipcie/smipcie.h
+++ b/drivers/media/pci/smipcie/smipcie.h
@@ -240,7 +240,7 @@ struct smi_rc {
240 struct smi_dev *dev; 240 struct smi_dev *dev;
241 struct rc_dev *rc_dev; 241 struct rc_dev *rc_dev;
242 char input_phys[64]; 242 char input_phys[64];
243 char input_name[64]; 243 char device_name[64];
244 struct work_struct work; 244 struct work_struct work;
245 u8 irData[256]; 245 u8 irData[256];
246 246
diff --git a/drivers/media/pci/solo6x10/solo6x10-g723.c b/drivers/media/pci/solo6x10/solo6x10-g723.c
index 3ca947092775..81be1b8df758 100644
--- a/drivers/media/pci/solo6x10/solo6x10-g723.c
+++ b/drivers/media/pci/solo6x10/solo6x10-g723.c
@@ -319,7 +319,7 @@ static int snd_solo_capture_volume_put(struct snd_kcontrol *kcontrol,
319 return 1; 319 return 1;
320} 320}
321 321
322static struct snd_kcontrol_new snd_solo_capture_volume = { 322static const struct snd_kcontrol_new snd_solo_capture_volume = {
323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
324 .name = "Capture Volume", 324 .name = "Capture Volume",
325 .info = snd_solo_capture_volume_info, 325 .info = snd_solo_capture_volume_info,
diff --git a/drivers/media/pci/solo6x10/solo6x10-gpio.c b/drivers/media/pci/solo6x10/solo6x10-gpio.c
index 6d3b4a36bc11..3d0d1aa2f6a8 100644
--- a/drivers/media/pci/solo6x10/solo6x10-gpio.c
+++ b/drivers/media/pci/solo6x10/solo6x10-gpio.c
@@ -57,6 +57,9 @@ static void solo_gpio_mode(struct solo_dev *solo_dev,
57 ret |= 1 << port; 57 ret |= 1 << port;
58 } 58 }
59 59
60 /* Enable GPIO[31:16] */
61 ret |= 0xffff0000;
62
60 solo_reg_write(solo_dev, SOLO_GPIO_CONFIG_1, ret); 63 solo_reg_write(solo_dev, SOLO_GPIO_CONFIG_1, ret);
61} 64}
62 65
@@ -90,16 +93,110 @@ static void solo_gpio_config(struct solo_dev *solo_dev)
90 93
91 /* Initially set relay status to 0 */ 94 /* Initially set relay status to 0 */
92 solo_gpio_clear(solo_dev, 0xff00); 95 solo_gpio_clear(solo_dev, 0xff00);
96
97 /* Set input pins direction */
98 solo_gpio_mode(solo_dev, 0xffff0000, 0);
99}
100
101#ifdef CONFIG_GPIOLIB
102/* Pins 0-7 are not exported, because it seems from code above they are
103 * used for internal purposes. So offset 0 corresponds to pin 8, therefore
104 * offsets 0-7 are relay GPIOs, 8-23 - input GPIOs.
105 */
106static int solo_gpiochip_get_direction(struct gpio_chip *chip,
107 unsigned int offset)
108{
109 int ret, mode;
110 struct solo_dev *solo_dev = gpiochip_get_data(chip);
111
112 if (offset < 8) {
113 ret = solo_reg_read(solo_dev, SOLO_GPIO_CONFIG_0);
114 mode = 3 & (ret >> ((offset + 8) * 2));
115 } else {
116 ret = solo_reg_read(solo_dev, SOLO_GPIO_CONFIG_1);
117 mode = 1 & (ret >> (offset - 8));
118 }
119
120 if (!mode)
121 return 1;
122 else if (mode == 1)
123 return 0;
124
125 return -1;
93} 126}
94 127
128static int solo_gpiochip_direction_input(struct gpio_chip *chip,
129 unsigned int offset)
130{
131 return -1;
132}
133
134static int solo_gpiochip_direction_output(struct gpio_chip *chip,
135 unsigned int offset, int value)
136{
137 return -1;
138}
139
140static int solo_gpiochip_get(struct gpio_chip *chip,
141 unsigned int offset)
142{
143 int ret;
144 struct solo_dev *solo_dev = gpiochip_get_data(chip);
145
146 ret = solo_reg_read(solo_dev, SOLO_GPIO_DATA_IN);
147
148 return 1 & (ret >> (offset + 8));
149}
150
151static void solo_gpiochip_set(struct gpio_chip *chip,
152 unsigned int offset, int value)
153{
154 struct solo_dev *solo_dev = gpiochip_get_data(chip);
155
156 if (value)
157 solo_gpio_set(solo_dev, 1 << (offset + 8));
158 else
159 solo_gpio_clear(solo_dev, 1 << (offset + 8));
160}
161#endif
162
95int solo_gpio_init(struct solo_dev *solo_dev) 163int solo_gpio_init(struct solo_dev *solo_dev)
96{ 164{
165 int ret;
166
97 solo_gpio_config(solo_dev); 167 solo_gpio_config(solo_dev);
168#ifdef CONFIG_GPIOLIB
169 solo_dev->gpio_dev.label = SOLO6X10_NAME"_gpio";
170 solo_dev->gpio_dev.parent = &solo_dev->pdev->dev;
171 solo_dev->gpio_dev.owner = THIS_MODULE;
172 solo_dev->gpio_dev.base = -1;
173 solo_dev->gpio_dev.ngpio = 24;
174 solo_dev->gpio_dev.can_sleep = 0;
175
176 solo_dev->gpio_dev.get_direction = solo_gpiochip_get_direction;
177 solo_dev->gpio_dev.direction_input = solo_gpiochip_direction_input;
178 solo_dev->gpio_dev.direction_output = solo_gpiochip_direction_output;
179 solo_dev->gpio_dev.get = solo_gpiochip_get;
180 solo_dev->gpio_dev.set = solo_gpiochip_set;
181
182 ret = gpiochip_add_data(&solo_dev->gpio_dev, solo_dev);
183
184 if (ret) {
185 solo_dev->gpio_dev.label = NULL;
186 return -1;
187 }
188#endif
98 return 0; 189 return 0;
99} 190}
100 191
101void solo_gpio_exit(struct solo_dev *solo_dev) 192void solo_gpio_exit(struct solo_dev *solo_dev)
102{ 193{
194#ifdef CONFIG_GPIOLIB
195 if (solo_dev->gpio_dev.label) {
196 gpiochip_remove(&solo_dev->gpio_dev);
197 solo_dev->gpio_dev.label = NULL;
198 }
199#endif
103 solo_gpio_clear(solo_dev, 0x30); 200 solo_gpio_clear(solo_dev, 0x30);
104 solo_gpio_config(solo_dev); 201 solo_gpio_config(solo_dev);
105} 202}
diff --git a/drivers/media/pci/solo6x10/solo6x10-tw28.c b/drivers/media/pci/solo6x10/solo6x10-tw28.c
index 0632d3f7c73c..7ecb725b6dd2 100644
--- a/drivers/media/pci/solo6x10/solo6x10-tw28.c
+++ b/drivers/media/pci/solo6x10/solo6x10-tw28.c
@@ -532,7 +532,7 @@ static void saa712x_write_regs(struct solo_dev *dev, const u8 *vals,
532static void saa712x_setup(struct solo_dev *dev) 532static void saa712x_setup(struct solo_dev *dev)
533{ 533{
534 const int reg_start = 0x26; 534 const int reg_start = 0x26;
535 const u8 saa7128_regs_ntsc[] = { 535 static const u8 saa7128_regs_ntsc[] = {
536 /* :0x26 */ 536 /* :0x26 */
537 0x0d, 0x00, 537 0x0d, 0x00,
538 /* :0x28 */ 538 /* :0x28 */
@@ -606,6 +606,7 @@ int solo_tw28_init(struct solo_dev *solo_dev)
606 solo_dev->tw28_cnt++; 606 solo_dev->tw28_cnt++;
607 break; 607 break;
608 case 0x0c: 608 case 0x0c:
609 case 0x0d:
609 solo_dev->tw2864 |= 1 << i; 610 solo_dev->tw2864 |= 1 << i;
610 solo_dev->tw28_cnt++; 611 solo_dev->tw28_cnt++;
611 break; 612 break;
diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2.c b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
index 3266fc21825f..99ffd1ed4a73 100644
--- a/drivers/media/pci/solo6x10/solo6x10-v4l2.c
+++ b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
@@ -630,7 +630,7 @@ static const struct v4l2_ioctl_ops solo_v4l2_ioctl_ops = {
630 .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 630 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
631}; 631};
632 632
633static struct video_device solo_v4l2_template = { 633static const struct video_device solo_v4l2_template = {
634 .name = SOLO6X10_NAME, 634 .name = SOLO6X10_NAME,
635 .fops = &solo_v4l2_fops, 635 .fops = &solo_v4l2_fops,
636 .ioctl_ops = &solo_v4l2_ioctl_ops, 636 .ioctl_ops = &solo_v4l2_ioctl_ops,
diff --git a/drivers/media/pci/solo6x10/solo6x10.h b/drivers/media/pci/solo6x10/solo6x10.h
index 3f8da5e8c430..3a1893ae2dad 100644
--- a/drivers/media/pci/solo6x10/solo6x10.h
+++ b/drivers/media/pci/solo6x10/solo6x10.h
@@ -31,6 +31,7 @@
31#include <linux/atomic.h> 31#include <linux/atomic.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/videodev2.h> 33#include <linux/videodev2.h>
34#include <linux/gpio/driver.h>
34 35
35#include <media/v4l2-dev.h> 36#include <media/v4l2-dev.h>
36#include <media/v4l2-device.h> 37#include <media/v4l2-device.h>
@@ -199,6 +200,10 @@ struct solo_dev {
199 u32 irq_mask; 200 u32 irq_mask;
200 u32 motion_mask; 201 u32 motion_mask;
201 struct v4l2_device v4l2_dev; 202 struct v4l2_device v4l2_dev;
203#ifdef CONFIG_GPIOLIB
204 /* GPIO */
205 struct gpio_chip gpio_dev;
206#endif
202 207
203 /* tw28xx accounting */ 208 /* tw28xx accounting */
204 u8 tw2865, tw2864, tw2815; 209 u8 tw2865, tw2864, tw2815;
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c
index 6343d24eb1d5..eb5a9eae7c8e 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -754,7 +754,7 @@ static const struct v4l2_ioctl_ops vip_ioctl_ops = {
754 .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 754 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
755}; 755};
756 756
757static struct video_device video_dev_template = { 757static const struct video_device video_dev_template = {
758 .name = KBUILD_MODNAME, 758 .name = KBUILD_MODNAME,
759 .release = video_device_release_empty, 759 .release = video_device_release_empty,
760 .fops = &vip_fops, 760 .fops = &vip_fops,
diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c
index f2905bd80366..f46947d8adf8 100644
--- a/drivers/media/pci/ttpci/av7110.c
+++ b/drivers/media/pci/ttpci/av7110.c
@@ -2872,7 +2872,7 @@ MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C");
2872MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6"); 2872MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6");
2873MAKE_AV7110_INFO(gxs_1_3, "Galaxis DVB-S rev1.3"); 2873MAKE_AV7110_INFO(gxs_1_3, "Galaxis DVB-S rev1.3");
2874 2874
2875static struct pci_device_id pci_tbl[] = { 2875static const struct pci_device_id pci_tbl[] = {
2876 MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000), 2876 MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000),
2877 MAKE_EXTENSION_PCI(tts_1_X_fsc, 0x13c2, 0x0000), 2877 MAKE_EXTENSION_PCI(tts_1_X_fsc, 0x13c2, 0x0000),
2878 MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001), 2878 MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001),
diff --git a/drivers/media/pci/ttpci/av7110.h b/drivers/media/pci/ttpci/av7110.h
index 824c1e262fbb..347827925c14 100644
--- a/drivers/media/pci/ttpci/av7110.h
+++ b/drivers/media/pci/ttpci/av7110.h
@@ -177,7 +177,7 @@ struct av7110 {
177 177
178 /* CA */ 178 /* CA */
179 179
180 ca_slot_info_t ci_slot[2]; 180 struct ca_slot_info ci_slot[2];
181 181
182 enum av7110_video_mode vidmode; 182 enum av7110_video_mode vidmode;
183 struct dmxdev dmxdev; 183 struct dmxdev dmxdev;
diff --git a/drivers/media/pci/ttpci/av7110_ca.c b/drivers/media/pci/ttpci/av7110_ca.c
index f64723aea56b..1fe49171d823 100644
--- a/drivers/media/pci/ttpci/av7110_ca.c
+++ b/drivers/media/pci/ttpci/av7110_ca.c
@@ -119,7 +119,7 @@ static void ci_ll_release(struct dvb_ringbuffer *cirbuf, struct dvb_ringbuffer *
119} 119}
120 120
121static int ci_ll_reset(struct dvb_ringbuffer *cibuf, struct file *file, 121static int ci_ll_reset(struct dvb_ringbuffer *cibuf, struct file *file,
122 int slots, ca_slot_info_t *slot) 122 int slots, struct ca_slot_info *slot)
123{ 123{
124 int i; 124 int i;
125 int len = 0; 125 int len = 0;
@@ -264,7 +264,7 @@ static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
264 break; 264 break;
265 case CA_GET_CAP: 265 case CA_GET_CAP:
266 { 266 {
267 ca_caps_t cap; 267 struct ca_caps cap;
268 268
269 cap.slot_num = 2; 269 cap.slot_num = 2;
270 cap.slot_type = (FW_CI_LL_SUPPORT(av7110->arm_app) ? 270 cap.slot_type = (FW_CI_LL_SUPPORT(av7110->arm_app) ?
@@ -277,7 +277,7 @@ static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
277 277
278 case CA_GET_SLOT_INFO: 278 case CA_GET_SLOT_INFO:
279 { 279 {
280 ca_slot_info_t *info=(ca_slot_info_t *)parg; 280 struct ca_slot_info *info=(struct ca_slot_info *)parg;
281 281
282 if (info->num < 0 || info->num > 1) { 282 if (info->num < 0 || info->num > 1) {
283 mutex_unlock(&av7110->ioctl_mutex); 283 mutex_unlock(&av7110->ioctl_mutex);
@@ -286,7 +286,7 @@ static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
286 av7110->ci_slot[info->num].num = info->num; 286 av7110->ci_slot[info->num].num = info->num;
287 av7110->ci_slot[info->num].type = FW_CI_LL_SUPPORT(av7110->arm_app) ? 287 av7110->ci_slot[info->num].type = FW_CI_LL_SUPPORT(av7110->arm_app) ?
288 CA_CI_LINK : CA_CI; 288 CA_CI_LINK : CA_CI;
289 memcpy(info, &av7110->ci_slot[info->num], sizeof(ca_slot_info_t)); 289 memcpy(info, &av7110->ci_slot[info->num], sizeof(struct ca_slot_info));
290 break; 290 break;
291 } 291 }
292 292
@@ -298,7 +298,7 @@ static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
298 298
299 case CA_GET_DESCR_INFO: 299 case CA_GET_DESCR_INFO:
300 { 300 {
301 ca_descr_info_t info; 301 struct ca_descr_info info;
302 302
303 info.num = 16; 303 info.num = 16;
304 info.type = CA_ECD; 304 info.type = CA_ECD;
@@ -308,7 +308,7 @@ static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
308 308
309 case CA_SET_DESCR: 309 case CA_SET_DESCR:
310 { 310 {
311 ca_descr_t *descr = (ca_descr_t*) parg; 311 struct ca_descr *descr = (struct ca_descr*) parg;
312 312
313 if (descr->index >= 16 || descr->parity > 1) { 313 if (descr->index >= 16 || descr->parity > 1) {
314 mutex_unlock(&av7110->ioctl_mutex); 314 mutex_unlock(&av7110->ioctl_mutex);
diff --git a/drivers/media/pci/ttpci/av7110_v4l.c b/drivers/media/pci/ttpci/av7110_v4l.c
index 397fe146dedd..e4cf42c32284 100644
--- a/drivers/media/pci/ttpci/av7110_v4l.c
+++ b/drivers/media/pci/ttpci/av7110_v4l.c
@@ -218,7 +218,7 @@ static struct saa7146_standard analog_standard[];
218static struct saa7146_standard dvb_standard[]; 218static struct saa7146_standard dvb_standard[];
219static struct saa7146_standard standard[]; 219static struct saa7146_standard standard[];
220 220
221static struct v4l2_audio msp3400_v4l2_audio = { 221static const struct v4l2_audio msp3400_v4l2_audio = {
222 .index = 0, 222 .index = 0,
223 .name = "Television", 223 .name = "Television",
224 .capability = V4L2_AUDCAP_STEREO 224 .capability = V4L2_AUDCAP_STEREO
diff --git a/drivers/media/pci/ttpci/budget-av.c b/drivers/media/pci/ttpci/budget-av.c
index dc7be8fac9a3..ac83fff9fe0b 100644
--- a/drivers/media/pci/ttpci/budget-av.c
+++ b/drivers/media/pci/ttpci/budget-av.c
@@ -1567,7 +1567,7 @@ MAKE_BUDGET_INFO(cin1200c, "Terratec Cinergy 1200 DVB-C", BUDGET_CIN1200C);
1567MAKE_BUDGET_INFO(cin1200cmk3, "Terratec Cinergy 1200 DVB-C MK3", BUDGET_CIN1200C_MK3); 1567MAKE_BUDGET_INFO(cin1200cmk3, "Terratec Cinergy 1200 DVB-C MK3", BUDGET_CIN1200C_MK3);
1568MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T); 1568MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T);
1569 1569
1570static struct pci_device_id pci_tbl[] = { 1570static const struct pci_device_id pci_tbl[] = {
1571 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56), 1571 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56),
1572 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010), 1572 MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010),
1573 MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010), 1573 MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010),
diff --git a/drivers/media/pci/ttpci/budget-ci.c b/drivers/media/pci/ttpci/budget-ci.c
index 11b9227307bf..57af11804fd6 100644
--- a/drivers/media/pci/ttpci/budget-ci.c
+++ b/drivers/media/pci/ttpci/budget-ci.c
@@ -158,14 +158,15 @@ static void msp430_ir_interrupt(unsigned long data)
158 return; 158 return;
159 159
160 if (budget_ci->ir.full_rc5) { 160 if (budget_ci->ir.full_rc5) {
161 rc_keydown(dev, RC_TYPE_RC5, 161 rc_keydown(dev, RC_PROTO_RC5,
162 RC_SCANCODE_RC5(budget_ci->ir.rc5_device, budget_ci->ir.ir_key), 162 RC_SCANCODE_RC5(budget_ci->ir.rc5_device, budget_ci->ir.ir_key),
163 !!(command & 0x20)); 163 !!(command & 0x20));
164 return; 164 return;
165 } 165 }
166 166
167 /* FIXME: We should generate complete scancodes for all devices */ 167 /* FIXME: We should generate complete scancodes for all devices */
168 rc_keydown(dev, RC_TYPE_UNKNOWN, budget_ci->ir.ir_key, !!(command & 0x20)); 168 rc_keydown(dev, RC_PROTO_UNKNOWN, budget_ci->ir.ir_key,
169 !!(command & 0x20));
169} 170}
170 171
171static int msp430_ir_init(struct budget_ci *budget_ci) 172static int msp430_ir_init(struct budget_ci *budget_ci)
@@ -186,7 +187,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
186 "pci-%s/ir0", pci_name(saa->pci)); 187 "pci-%s/ir0", pci_name(saa->pci));
187 188
188 dev->driver_name = MODULE_NAME; 189 dev->driver_name = MODULE_NAME;
189 dev->input_name = budget_ci->ir.name; 190 dev->device_name = budget_ci->ir.name;
190 dev->input_phys = budget_ci->ir.phys; 191 dev->input_phys = budget_ci->ir.phys;
191 dev->input_id.bustype = BUS_PCI; 192 dev->input_id.bustype = BUS_PCI;
192 dev->input_id.version = 1; 193 dev->input_id.version = 1;
@@ -1538,7 +1539,7 @@ MAKE_BUDGET_INFO(ttc1501, "TT-Budget C-1501 PCI", BUDGET_TT);
1538MAKE_BUDGET_INFO(tt3200, "TT-Budget S2-3200 PCI", BUDGET_TT); 1539MAKE_BUDGET_INFO(tt3200, "TT-Budget S2-3200 PCI", BUDGET_TT);
1539MAKE_BUDGET_INFO(ttbs1500b, "TT-Budget S-1500B PCI", BUDGET_TT); 1540MAKE_BUDGET_INFO(ttbs1500b, "TT-Budget S-1500B PCI", BUDGET_TT);
1540 1541
1541static struct pci_device_id pci_tbl[] = { 1542static const struct pci_device_id pci_tbl[] = {
1542 MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c), 1543 MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c),
1543 MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f), 1544 MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f),
1544 MAKE_EXTENSION_PCI(ttbcci, 0x13c2, 0x1010), 1545 MAKE_EXTENSION_PCI(ttbcci, 0x13c2, 0x1010),
diff --git a/drivers/media/pci/ttpci/budget-patch.c b/drivers/media/pci/ttpci/budget-patch.c
index 442992372008..a738018cdca8 100644
--- a/drivers/media/pci/ttpci/budget-patch.c
+++ b/drivers/media/pci/ttpci/budget-patch.c
@@ -45,7 +45,7 @@ static struct saa7146_extension budget_extension;
45MAKE_BUDGET_INFO(ttbp, "TT-Budget/Patch DVB-S 1.x PCI", BUDGET_PATCH); 45MAKE_BUDGET_INFO(ttbp, "TT-Budget/Patch DVB-S 1.x PCI", BUDGET_PATCH);
46//MAKE_BUDGET_INFO(satel,"TT-Budget/Patch SATELCO PCI", BUDGET_TT_HW_DISEQC); 46//MAKE_BUDGET_INFO(satel,"TT-Budget/Patch SATELCO PCI", BUDGET_TT_HW_DISEQC);
47 47
48static struct pci_device_id pci_tbl[] = { 48static const struct pci_device_id pci_tbl[] = {
49 MAKE_EXTENSION_PCI(ttbp,0x13c2, 0x0000), 49 MAKE_EXTENSION_PCI(ttbp,0x13c2, 0x0000),
50// MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013), 50// MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013),
51 { 51 {
diff --git a/drivers/media/pci/ttpci/budget.c b/drivers/media/pci/ttpci/budget.c
index 81fe35cedd10..f59eadb7a5eb 100644
--- a/drivers/media/pci/ttpci/budget.c
+++ b/drivers/media/pci/ttpci/budget.c
@@ -845,7 +845,7 @@ MAKE_BUDGET_INFO(fsact1, "Fujitsu Siemens Activy Budget-T PCI (rev AL/ALPS TDHD1
845MAKE_BUDGET_INFO(omicom, "Omicom S2 PCI", BUDGET_TT); 845MAKE_BUDGET_INFO(omicom, "Omicom S2 PCI", BUDGET_TT);
846MAKE_BUDGET_INFO(sylt, "Philips Semi Sylt PCI", BUDGET_TT_HW_DISEQC); 846MAKE_BUDGET_INFO(sylt, "Philips Semi Sylt PCI", BUDGET_TT_HW_DISEQC);
847 847
848static struct pci_device_id pci_tbl[] = { 848static const struct pci_device_id pci_tbl[] = {
849 MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1003), 849 MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1003),
850 MAKE_EXTENSION_PCI(ttbc, 0x13c2, 0x1004), 850 MAKE_EXTENSION_PCI(ttbc, 0x13c2, 0x1004),
851 MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005), 851 MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005),
diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
index 58c4dd75bfa1..8c1f4a049764 100644
--- a/drivers/media/pci/tw68/tw68-video.c
+++ b/drivers/media/pci/tw68/tw68-video.c
@@ -916,7 +916,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
916#endif 916#endif
917}; 917};
918 918
919static struct video_device tw68_video_template = { 919static const struct video_device tw68_video_template = {
920 .name = "tw68_video", 920 .name = "tw68_video",
921 .fops = &video_fops, 921 .fops = &video_fops,
922 .ioctl_ops = &video_ioctl_ops, 922 .ioctl_ops = &video_ioctl_ops,
diff --git a/drivers/media/pci/zoran/zoran_card.c b/drivers/media/pci/zoran/zoran_card.c
index 4680f001653a..a6b9ebd20263 100644
--- a/drivers/media/pci/zoran/zoran_card.c
+++ b/drivers/media/pci/zoran/zoran_card.c
@@ -130,7 +130,7 @@ MODULE_VERSION(ZORAN_VERSION);
130 .vendor = PCI_VENDOR_ID_ZORAN, .device = PCI_DEVICE_ID_ZORAN_36057, \ 130 .vendor = PCI_VENDOR_ID_ZORAN, .device = PCI_DEVICE_ID_ZORAN_36057, \
131 .subvendor = (subven), .subdevice = (subdev), .driver_data = (data) } 131 .subvendor = (subven), .subdevice = (subdev), .driver_data = (data) }
132 132
133static struct pci_device_id zr36067_pci_tbl[] = { 133static const struct pci_device_id zr36067_pci_tbl[] = {
134 ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC10PLUS, DC10plus), 134 ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC10PLUS, DC10plus),
135 ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC30PLUS, DC30plus), 135 ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC30PLUS, DC30plus),
136 ZR_DEVICE(PCI_VENDOR_ID_ELECTRONICDESIGNGMBH, PCI_DEVICE_ID_LML_33R10, LML33R10), 136 ZR_DEVICE(PCI_VENDOR_ID_ELECTRONICDESIGNGMBH, PCI_DEVICE_ID_LML_33R10, LML33R10),
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index fb1fa0b82077..7e7cc49b8674 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -76,7 +76,8 @@ config VIDEO_M32R_AR_M64278
76 76
77config VIDEO_MUX 77config VIDEO_MUX
78 tristate "Video Multiplexer" 78 tristate "Video Multiplexer"
79 depends on OF && VIDEO_V4L2_SUBDEV_API && MEDIA_CONTROLLER 79 select MULTIPLEXER
80 depends on VIDEO_V4L2 && OF && VIDEO_V4L2_SUBDEV_API && MEDIA_CONTROLLER
80 select REGMAP 81 select REGMAP
81 help 82 help
82 This driver provides support for N:1 video bus multiplexers. 83 This driver provides support for N:1 video bus multiplexers.
@@ -109,6 +110,13 @@ config VIDEO_PXA27x
109 ---help--- 110 ---help---
110 This is a v4l2 driver for the PXA27x Quick Capture Interface 111 This is a v4l2 driver for the PXA27x Quick Capture Interface
111 112
113config VIDEO_QCOM_CAMSS
114 tristate "Qualcomm 8x16 V4L2 Camera Subsystem driver"
115 depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
116 depends on (ARCH_QCOM && IOMMU_DMA) || COMPILE_TEST
117 select VIDEOBUF2_DMA_SG
118 select V4L2_FWNODE
119
112config VIDEO_S3C_CAMIF 120config VIDEO_S3C_CAMIF
113 tristate "Samsung S3C24XX/S3C64XX SoC Camera Interface driver" 121 tristate "Samsung S3C24XX/S3C64XX SoC Camera Interface driver"
114 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API 122 depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
@@ -536,6 +544,17 @@ menuconfig CEC_PLATFORM_DRIVERS
536 544
537if CEC_PLATFORM_DRIVERS 545if CEC_PLATFORM_DRIVERS
538 546
547config VIDEO_MESON_AO_CEC
548 tristate "Amlogic Meson AO CEC driver"
549 depends on ARCH_MESON || COMPILE_TEST
550 select CEC_CORE
551 select CEC_NOTIFIER
552 ---help---
553 This is a driver for Amlogic Meson SoCs AO CEC interface. It uses the
554 generic CEC framework interface.
555 CEC bus is present in the HDMI connector and enables communication
556 between compatible devices.
557
539config VIDEO_SAMSUNG_S5P_CEC 558config VIDEO_SAMSUNG_S5P_CEC
540 tristate "Samsung S5P CEC driver" 559 tristate "Samsung S5P CEC driver"
541 depends on PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST 560 depends on PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 9beadc760467..c1ef946bf032 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -85,4 +85,8 @@ obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp/
85 85
86obj-$(CONFIG_VIDEO_MEDIATEK_JPEG) += mtk-jpeg/ 86obj-$(CONFIG_VIDEO_MEDIATEK_JPEG) += mtk-jpeg/
87 87
88obj-$(CONFIG_VIDEO_QCOM_CAMSS) += qcom/camss-8x16/
89
88obj-$(CONFIG_VIDEO_QCOM_VENUS) += qcom/venus/ 90obj-$(CONFIG_VIDEO_QCOM_VENUS) += qcom/venus/
91
92obj-y += meson/
diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c
index 466aba8b0e00..dfcc484cab89 100644
--- a/drivers/media/platform/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/am437x/am437x-vpfe.c
@@ -2490,8 +2490,8 @@ vpfe_get_pdata(struct platform_device *pdev)
2490 2490
2491 rem = of_graph_get_remote_port_parent(endpoint); 2491 rem = of_graph_get_remote_port_parent(endpoint);
2492 if (!rem) { 2492 if (!rem) {
2493 dev_err(&pdev->dev, "Remote device at %s not found\n", 2493 dev_err(&pdev->dev, "Remote device at %pOF not found\n",
2494 endpoint->full_name); 2494 endpoint);
2495 goto done; 2495 goto done;
2496 } 2496 }
2497 2497
diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c
index d6534252cdcd..d7103c5f92c3 100644
--- a/drivers/media/platform/atmel/atmel-isc.c
+++ b/drivers/media/platform/atmel/atmel-isc.c
@@ -873,7 +873,7 @@ static void isc_buffer_queue(struct vb2_buffer *vb)
873 spin_unlock_irqrestore(&isc->dma_queue_lock, flags); 873 spin_unlock_irqrestore(&isc->dma_queue_lock, flags);
874} 874}
875 875
876static struct vb2_ops isc_vb2_ops = { 876static const struct vb2_ops isc_vb2_ops = {
877 .queue_setup = isc_queue_setup, 877 .queue_setup = isc_queue_setup,
878 .wait_prepare = vb2_ops_wait_prepare, 878 .wait_prepare = vb2_ops_wait_prepare,
879 .wait_finish = vb2_ops_wait_finish, 879 .wait_finish = vb2_ops_wait_finish,
@@ -1700,8 +1700,8 @@ static int isc_parse_dt(struct device *dev, struct isc_device *isc)
1700 1700
1701 rem = of_graph_get_remote_port_parent(epn); 1701 rem = of_graph_get_remote_port_parent(epn);
1702 if (!rem) { 1702 if (!rem) {
1703 dev_notice(dev, "Remote device at %s not found\n", 1703 dev_notice(dev, "Remote device at %pOF not found\n",
1704 of_node_full_name(epn)); 1704 epn);
1705 continue; 1705 continue;
1706 } 1706 }
1707 1707
diff --git a/drivers/media/platform/blackfin/bfin_capture.c b/drivers/media/platform/blackfin/bfin_capture.c
index 1c5166df46f5..41f179117fb0 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -375,7 +375,7 @@ static void bcap_stop_streaming(struct vb2_queue *vq)
375 } 375 }
376} 376}
377 377
378static struct vb2_ops bcap_video_qops = { 378static const struct vb2_ops bcap_video_qops = {
379 .queue_setup = bcap_queue_setup, 379 .queue_setup = bcap_queue_setup,
380 .buf_prepare = bcap_buffer_prepare, 380 .buf_prepare = bcap_buffer_prepare,
381 .buf_cleanup = bcap_buffer_cleanup, 381 .buf_cleanup = bcap_buffer_cleanup,
@@ -769,7 +769,7 @@ static const struct v4l2_ioctl_ops bcap_ioctl_ops = {
769 .vidioc_log_status = bcap_log_status, 769 .vidioc_log_status = bcap_log_status,
770}; 770};
771 771
772static struct v4l2_file_operations bcap_fops = { 772static const struct v4l2_file_operations bcap_fops = {
773 .owner = THIS_MODULE, 773 .owner = THIS_MODULE,
774 .open = v4l2_fh_open, 774 .open = v4l2_fh_open,
775 .release = vb2_fop_release, 775 .release = vb2_fop_release,
diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index bba1eb43b5d8..291c40933935 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -394,7 +394,8 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx,
394 int i; 394 int i;
395 395
396 if (ctx->codec->src_fourcc == V4L2_PIX_FMT_H264 || 396 if (ctx->codec->src_fourcc == V4L2_PIX_FMT_H264 ||
397 ctx->codec->dst_fourcc == V4L2_PIX_FMT_H264) { 397 ctx->codec->dst_fourcc == V4L2_PIX_FMT_H264 ||
398 ctx->codec->dst_fourcc == V4L2_PIX_FMT_MPEG4) {
398 width = round_up(q_data->width, 16); 399 width = round_up(q_data->width, 16);
399 height = round_up(q_data->height, 16); 400 height = round_up(q_data->height, 16);
400 } else { 401 } else {
@@ -702,6 +703,8 @@ static u32 coda_supported_firmwares[] = {
702 CODA_FIRMWARE_VERNUM(CODA_DX6, 2, 2, 5), 703 CODA_FIRMWARE_VERNUM(CODA_DX6, 2, 2, 5),
703 CODA_FIRMWARE_VERNUM(CODA_7541, 1, 4, 50), 704 CODA_FIRMWARE_VERNUM(CODA_7541, 1, 4, 50),
704 CODA_FIRMWARE_VERNUM(CODA_960, 2, 1, 5), 705 CODA_FIRMWARE_VERNUM(CODA_960, 2, 1, 5),
706 CODA_FIRMWARE_VERNUM(CODA_960, 2, 3, 10),
707 CODA_FIRMWARE_VERNUM(CODA_960, 3, 1, 1),
705}; 708};
706 709
707static bool coda_firmware_supported(u32 vernum) 710static bool coda_firmware_supported(u32 vernum)
@@ -1006,7 +1009,7 @@ static int coda_start_encoding(struct coda_ctx *ctx)
1006 break; 1009 break;
1007 } 1010 }
1008 coda_write(dev, value, CODA_CMD_ENC_SEQ_SLICE_MODE); 1011 coda_write(dev, value, CODA_CMD_ENC_SEQ_SLICE_MODE);
1009 value = ctx->params.gop_size & CODA_GOP_SIZE_MASK; 1012 value = ctx->params.gop_size;
1010 coda_write(dev, value, CODA_CMD_ENC_SEQ_GOP_SIZE); 1013 coda_write(dev, value, CODA_CMD_ENC_SEQ_GOP_SIZE);
1011 } 1014 }
1012 1015
@@ -1250,7 +1253,8 @@ static int coda_prepare_encode(struct coda_ctx *ctx)
1250 force_ipicture = ctx->params.force_ipicture; 1253 force_ipicture = ctx->params.force_ipicture;
1251 if (force_ipicture) 1254 if (force_ipicture)
1252 ctx->params.force_ipicture = false; 1255 ctx->params.force_ipicture = false;
1253 else if ((src_buf->sequence % ctx->params.gop_size) == 0) 1256 else if (ctx->params.gop_size != 0 &&
1257 (src_buf->sequence % ctx->params.gop_size) == 0)
1254 force_ipicture = 1; 1258 force_ipicture = 1;
1255 1259
1256 /* 1260 /*
@@ -1411,6 +1415,7 @@ static void coda_finish_encode(struct coda_ctx *ctx)
1411 } 1415 }
1412 1416
1413 dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp; 1417 dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
1418 dst_buf->field = src_buf->field;
1414 dst_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 1419 dst_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
1415 dst_buf->flags |= 1420 dst_buf->flags |=
1416 src_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; 1421 src_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
@@ -1634,9 +1639,6 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
1634 ctx->frm_dis_flg = 0; 1639 ctx->frm_dis_flg = 0;
1635 coda_write(dev, 0, CODA_REG_BIT_FRM_DIS_FLG(ctx->reg_idx)); 1640 coda_write(dev, 0, CODA_REG_BIT_FRM_DIS_FLG(ctx->reg_idx));
1636 1641
1637 coda_write(dev, CODA_BIT_DEC_SEQ_INIT_ESCAPE,
1638 CODA_REG_BIT_BIT_STREAM_PARAM);
1639
1640 coda_write(dev, bitstream_buf, CODA_CMD_DEC_SEQ_BB_START); 1642 coda_write(dev, bitstream_buf, CODA_CMD_DEC_SEQ_BB_START);
1641 coda_write(dev, bitstream_size / 1024, CODA_CMD_DEC_SEQ_BB_SIZE); 1643 coda_write(dev, bitstream_size / 1024, CODA_CMD_DEC_SEQ_BB_SIZE);
1642 val = 0; 1644 val = 0;
@@ -1652,6 +1654,10 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
1652 ctx->params.codec_mode_aux = CODA_MP4_AUX_MPEG4; 1654 ctx->params.codec_mode_aux = CODA_MP4_AUX_MPEG4;
1653 else 1655 else
1654 ctx->params.codec_mode_aux = 0; 1656 ctx->params.codec_mode_aux = 0;
1657 if (src_fourcc == V4L2_PIX_FMT_MPEG4) {
1658 coda_write(dev, CODA_MP4_CLASS_MPEG4,
1659 CODA_CMD_DEC_SEQ_MP4_ASP_CLASS);
1660 }
1655 if (src_fourcc == V4L2_PIX_FMT_H264) { 1661 if (src_fourcc == V4L2_PIX_FMT_H264) {
1656 if (dev->devtype->product == CODA_7541) { 1662 if (dev->devtype->product == CODA_7541) {
1657 coda_write(dev, ctx->psbuf.paddr, 1663 coda_write(dev, ctx->psbuf.paddr,
@@ -1667,18 +1673,18 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
1667 if (dev->devtype->product != CODA_960) 1673 if (dev->devtype->product != CODA_960)
1668 coda_write(dev, 0, CODA_CMD_DEC_SEQ_SRC_SIZE); 1674 coda_write(dev, 0, CODA_CMD_DEC_SEQ_SRC_SIZE);
1669 1675
1670 if (coda_command_sync(ctx, CODA_COMMAND_SEQ_INIT)) { 1676 ctx->bit_stream_param = CODA_BIT_DEC_SEQ_INIT_ESCAPE;
1677 ret = coda_command_sync(ctx, CODA_COMMAND_SEQ_INIT);
1678 ctx->bit_stream_param = 0;
1679 if (ret) {
1671 v4l2_err(&dev->v4l2_dev, "CODA_COMMAND_SEQ_INIT timeout\n"); 1680 v4l2_err(&dev->v4l2_dev, "CODA_COMMAND_SEQ_INIT timeout\n");
1672 coda_write(dev, 0, CODA_REG_BIT_BIT_STREAM_PARAM); 1681 return ret;
1673 return -ETIMEDOUT;
1674 } 1682 }
1675 ctx->initialized = 1; 1683 ctx->initialized = 1;
1676 1684
1677 /* Update kfifo out pointer from coda bitstream read pointer */ 1685 /* Update kfifo out pointer from coda bitstream read pointer */
1678 coda_kfifo_sync_from_device(ctx); 1686 coda_kfifo_sync_from_device(ctx);
1679 1687
1680 coda_write(dev, 0, CODA_REG_BIT_BIT_STREAM_PARAM);
1681
1682 if (coda_read(dev, CODA_RET_DEC_SEQ_SUCCESS) == 0) { 1688 if (coda_read(dev, CODA_RET_DEC_SEQ_SUCCESS) == 0) {
1683 v4l2_err(&dev->v4l2_dev, 1689 v4l2_err(&dev->v4l2_dev,
1684 "CODA_COMMAND_SEQ_INIT failed, error code = %d\n", 1690 "CODA_COMMAND_SEQ_INIT failed, error code = %d\n",
@@ -2153,6 +2159,7 @@ static void coda_finish_decode(struct coda_ctx *ctx)
2153 dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); 2159 dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
2154 dst_buf->sequence = ctx->osequence++; 2160 dst_buf->sequence = ctx->osequence++;
2155 2161
2162 dst_buf->field = V4L2_FIELD_NONE;
2156 dst_buf->flags &= ~(V4L2_BUF_FLAG_KEYFRAME | 2163 dst_buf->flags &= ~(V4L2_BUF_FLAG_KEYFRAME |
2157 V4L2_BUF_FLAG_PFRAME | 2164 V4L2_BUF_FLAG_PFRAME |
2158 V4L2_BUF_FLAG_BFRAME); 2165 V4L2_BUF_FLAG_BFRAME);
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 829c7895a98a..15eb5dc4dff9 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -73,7 +73,7 @@ MODULE_PARM_DESC(disable_vdoa, "Disable Video Data Order Adapter tiled to raster
73 73
74static int enable_bwb = 0; 74static int enable_bwb = 0;
75module_param(enable_bwb, int, 0644); 75module_param(enable_bwb, int, 0644);
76MODULE_PARM_DESC(enable_bwb, "Enable BWB unit, may crash on certain streams"); 76MODULE_PARM_DESC(enable_bwb, "Enable BWB unit for decoding, may crash on certain streams");
77 77
78void coda_write(struct coda_dev *dev, u32 data, u32 reg) 78void coda_write(struct coda_dev *dev, u32 data, u32 reg)
79{ 79{
@@ -714,9 +714,10 @@ static int coda_s_fmt(struct coda_ctx *ctx, struct v4l2_format *f,
714 ctx->tiled_map_type = GDI_TILED_FRAME_MB_RASTER_MAP; 714 ctx->tiled_map_type = GDI_TILED_FRAME_MB_RASTER_MAP;
715 break; 715 break;
716 case V4L2_PIX_FMT_NV12: 716 case V4L2_PIX_FMT_NV12:
717 ctx->tiled_map_type = GDI_TILED_FRAME_MB_RASTER_MAP; 717 if (!disable_tiling) {
718 if (!disable_tiling) 718 ctx->tiled_map_type = GDI_TILED_FRAME_MB_RASTER_MAP;
719 break; 719 break;
720 }
720 /* else fall through */ 721 /* else fall through */
721 case V4L2_PIX_FMT_YUV420: 722 case V4L2_PIX_FMT_YUV420:
722 case V4L2_PIX_FMT_YVU420: 723 case V4L2_PIX_FMT_YVU420:
@@ -932,7 +933,7 @@ static int coda_encoder_cmd(struct file *file, void *fh,
932 ctx->bit_stream_param |= CODA_BIT_STREAM_END_FLAG; 933 ctx->bit_stream_param |= CODA_BIT_STREAM_END_FLAG;
933 934
934 /* If there is no buffer in flight, wake up */ 935 /* If there is no buffer in flight, wake up */
935 if (ctx->qsequence == ctx->osequence) { 936 if (!ctx->streamon_out || ctx->qsequence == ctx->osequence) {
936 dst_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, 937 dst_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx,
937 V4L2_BUF_TYPE_VIDEO_CAPTURE); 938 V4L2_BUF_TYPE_VIDEO_CAPTURE);
938 dst_vq->last_buffer_dequeued = true; 939 dst_vq->last_buffer_dequeued = true;
@@ -1683,12 +1684,23 @@ static int coda_s_ctrl(struct v4l2_ctrl *ctrl)
1683 ctx->params.h264_deblk_enabled = (ctrl->val == 1684 ctx->params.h264_deblk_enabled = (ctrl->val ==
1684 V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED); 1685 V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED);
1685 break; 1686 break;
1687 case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
1688 /* TODO: switch between baseline and constrained baseline */
1689 ctx->params.h264_profile_idc = 66;
1690 break;
1691 case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
1692 /* nothing to do, this is set by the encoder */
1693 break;
1686 case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP: 1694 case V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP:
1687 ctx->params.mpeg4_intra_qp = ctrl->val; 1695 ctx->params.mpeg4_intra_qp = ctrl->val;
1688 break; 1696 break;
1689 case V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP: 1697 case V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP:
1690 ctx->params.mpeg4_inter_qp = ctrl->val; 1698 ctx->params.mpeg4_inter_qp = ctrl->val;
1691 break; 1699 break;
1700 case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
1701 case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
1702 /* nothing to do, these are fixed */
1703 break;
1692 case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE: 1704 case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE:
1693 ctx->params.slice_mode = ctrl->val; 1705 ctx->params.slice_mode = ctrl->val;
1694 break; 1706 break;
@@ -1734,10 +1746,12 @@ static const struct v4l2_ctrl_ops coda_ctrl_ops = {
1734 1746
1735static void coda_encode_ctrls(struct coda_ctx *ctx) 1747static void coda_encode_ctrls(struct coda_ctx *ctx)
1736{ 1748{
1749 int max_gop_size = (ctx->dev->devtype->product == CODA_DX6) ? 60 : 99;
1750
1737 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, 1751 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
1738 V4L2_CID_MPEG_VIDEO_BITRATE, 0, 32767000, 1000, 0); 1752 V4L2_CID_MPEG_VIDEO_BITRATE, 0, 32767000, 1000, 0);
1739 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, 1753 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
1740 V4L2_CID_MPEG_VIDEO_GOP_SIZE, 1, 60, 1, 16); 1754 V4L2_CID_MPEG_VIDEO_GOP_SIZE, 0, max_gop_size, 1, 16);
1741 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, 1755 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
1742 V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP, 0, 51, 1, 25); 1756 V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP, 0, 51, 1, 25);
1743 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, 1757 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
@@ -1756,11 +1770,47 @@ static void coda_encode_ctrls(struct coda_ctx *ctx)
1756 V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE, 1770 V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE,
1757 V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED, 0x0, 1771 V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED, 0x0,
1758 V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED); 1772 V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_ENABLED);
1773 v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops,
1774 V4L2_CID_MPEG_VIDEO_H264_PROFILE,
1775 V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE, 0x0,
1776 V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE);
1777 if (ctx->dev->devtype->product == CODA_7541) {
1778 v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops,
1779 V4L2_CID_MPEG_VIDEO_H264_LEVEL,
1780 V4L2_MPEG_VIDEO_H264_LEVEL_3_1,
1781 ~((1 << V4L2_MPEG_VIDEO_H264_LEVEL_2_0) |
1782 (1 << V4L2_MPEG_VIDEO_H264_LEVEL_3_0) |
1783 (1 << V4L2_MPEG_VIDEO_H264_LEVEL_3_1)),
1784 V4L2_MPEG_VIDEO_H264_LEVEL_3_1);
1785 }
1786 if (ctx->dev->devtype->product == CODA_960) {
1787 v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops,
1788 V4L2_CID_MPEG_VIDEO_H264_LEVEL,
1789 V4L2_MPEG_VIDEO_H264_LEVEL_4_0,
1790 ~((1 << V4L2_MPEG_VIDEO_H264_LEVEL_2_0) |
1791 (1 << V4L2_MPEG_VIDEO_H264_LEVEL_3_0) |
1792 (1 << V4L2_MPEG_VIDEO_H264_LEVEL_3_1) |
1793 (1 << V4L2_MPEG_VIDEO_H264_LEVEL_3_2) |
1794 (1 << V4L2_MPEG_VIDEO_H264_LEVEL_4_0)),
1795 V4L2_MPEG_VIDEO_H264_LEVEL_4_0);
1796 }
1759 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, 1797 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
1760 V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP, 1, 31, 1, 2); 1798 V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP, 1, 31, 1, 2);
1761 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops, 1799 v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
1762 V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP, 1, 31, 1, 2); 1800 V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP, 1, 31, 1, 2);
1763 v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops, 1801 v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops,
1802 V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE,
1803 V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE, 0x0,
1804 V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE);
1805 if (ctx->dev->devtype->product == CODA_7541 ||
1806 ctx->dev->devtype->product == CODA_960) {
1807 v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops,
1808 V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL,
1809 V4L2_MPEG_VIDEO_MPEG4_LEVEL_5,
1810 ~(1 << V4L2_MPEG_VIDEO_MPEG4_LEVEL_5),
1811 V4L2_MPEG_VIDEO_MPEG4_LEVEL_5);
1812 }
1813 v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops,
1764 V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE, 1814 V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE,
1765 V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES, 0x0, 1815 V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES, 0x0,
1766 V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE); 1816 V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE);
@@ -1938,7 +1988,13 @@ static int coda_open(struct file *file)
1938 ctx->idx = idx; 1988 ctx->idx = idx;
1939 switch (dev->devtype->product) { 1989 switch (dev->devtype->product) {
1940 case CODA_960: 1990 case CODA_960:
1941 if (enable_bwb) 1991 /*
1992 * Enabling the BWB when decoding can hang the firmware with
1993 * certain streams. The issue was tracked as ENGR00293425 by
1994 * Freescale. As a workaround, disable BWB for all decoders.
1995 * The enable_bwb module parameter allows to override this.
1996 */
1997 if (enable_bwb || ctx->inst_type == CODA_INST_ENCODER)
1942 ctx->frame_mem_ctrl = CODA9_FRAME_ENABLE_BWB; 1998 ctx->frame_mem_ctrl = CODA9_FRAME_ENABLE_BWB;
1943 /* fallthrough */ 1999 /* fallthrough */
1944 case CODA_7541: 2000 case CODA_7541:
@@ -2142,7 +2198,8 @@ static int coda_hw_init(struct coda_dev *dev)
2142 CODA_REG_BIT_STREAM_CTRL); 2198 CODA_REG_BIT_STREAM_CTRL);
2143 } 2199 }
2144 if (dev->devtype->product == CODA_960) 2200 if (dev->devtype->product == CODA_960)
2145 coda_write(dev, 1 << 12, CODA_REG_BIT_FRAME_MEM_CTRL); 2201 coda_write(dev, CODA9_FRAME_ENABLE_BWB,
2202 CODA_REG_BIT_FRAME_MEM_CTRL);
2146 else 2203 else
2147 coda_write(dev, 0, CODA_REG_BIT_FRAME_MEM_CTRL); 2204 coda_write(dev, 0, CODA_REG_BIT_FRAME_MEM_CTRL);
2148 2205
@@ -2386,11 +2443,11 @@ static const struct coda_devtype coda_devdata[] = {
2386 .num_vdevs = ARRAY_SIZE(coda9_video_devices), 2443 .num_vdevs = ARRAY_SIZE(coda9_video_devices),
2387 .workbuf_size = 80 * 1024, 2444 .workbuf_size = 80 * 1024,
2388 .tempbuf_size = 204 * 1024, 2445 .tempbuf_size = 204 * 1024,
2389 .iram_size = 0x20000, 2446 .iram_size = 0x1f000, /* leave 4k for suspend code */
2390 }, 2447 },
2391}; 2448};
2392 2449
2393static struct platform_device_id coda_platform_ids[] = { 2450static const struct platform_device_id coda_platform_ids[] = {
2394 { .name = "coda-imx27", .driver_data = CODA_IMX27 }, 2451 { .name = "coda-imx27", .driver_data = CODA_IMX27 },
2395 { /* sentinel */ } 2452 { /* sentinel */ }
2396}; 2453};
@@ -2470,7 +2527,8 @@ static int coda_probe(struct platform_device *pdev)
2470 return ret; 2527 return ret;
2471 } 2528 }
2472 2529
2473 dev->rstc = devm_reset_control_get_optional(&pdev->dev, NULL); 2530 dev->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev,
2531 NULL);
2474 if (IS_ERR(dev->rstc)) { 2532 if (IS_ERR(dev->rstc)) {
2475 ret = PTR_ERR(dev->rstc); 2533 ret = PTR_ERR(dev->rstc);
2476 dev_err(&pdev->dev, "failed get reset control: %d\n", ret); 2534 dev_err(&pdev->dev, "failed get reset control: %d\n", ret);
diff --git a/drivers/media/platform/coda/coda_regs.h b/drivers/media/platform/coda/coda_regs.h
index 77ee46a93427..38df5fd9a2fa 100644
--- a/drivers/media/platform/coda/coda_regs.h
+++ b/drivers/media/platform/coda/coda_regs.h
@@ -158,6 +158,7 @@
158#define CODA_CMD_DEC_SEQ_PS_BB_START 0x194 158#define CODA_CMD_DEC_SEQ_PS_BB_START 0x194
159#define CODA_CMD_DEC_SEQ_PS_BB_SIZE 0x198 159#define CODA_CMD_DEC_SEQ_PS_BB_SIZE 0x198
160#define CODA_CMD_DEC_SEQ_MP4_ASP_CLASS 0x19c 160#define CODA_CMD_DEC_SEQ_MP4_ASP_CLASS 0x19c
161#define CODA_MP4_CLASS_MPEG4 0
161#define CODA_CMD_DEC_SEQ_X264_MV_EN 0x19c 162#define CODA_CMD_DEC_SEQ_X264_MV_EN 0x19c
162#define CODA_CMD_DEC_SEQ_SPP_CHUNK_SIZE 0x1a0 163#define CODA_CMD_DEC_SEQ_SPP_CHUNK_SIZE 0x1a0
163 164
diff --git a/drivers/media/platform/coda/imx-vdoa.c b/drivers/media/platform/coda/imx-vdoa.c
index df9b71621420..8eb3e0c05473 100644
--- a/drivers/media/platform/coda/imx-vdoa.c
+++ b/drivers/media/platform/coda/imx-vdoa.c
@@ -314,6 +314,8 @@ static int vdoa_probe(struct platform_device *pdev)
314 return PTR_ERR(vdoa->regs); 314 return PTR_ERR(vdoa->regs);
315 315
316 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 316 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
317 if (!res)
318 return -EINVAL;
317 vdoa->irq = devm_request_threaded_irq(&pdev->dev, res->start, NULL, 319 vdoa->irq = devm_request_threaded_irq(&pdev->dev, res->start, NULL,
318 vdoa_irq_handler, IRQF_ONESHOT, 320 vdoa_irq_handler, IRQF_ONESHOT,
319 "vdoa", vdoa); 321 "vdoa", vdoa);
diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
index 3679b1e7b39e..7f6462562579 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -790,7 +790,7 @@ static void vpbe_deinitialize(struct device *dev, struct vpbe_device *vpbe_dev)
790 vpss_enable_clock(VPSS_VPBE_CLOCK, 0); 790 vpss_enable_clock(VPSS_VPBE_CLOCK, 0);
791} 791}
792 792
793static struct vpbe_device_ops vpbe_dev_ops = { 793static const struct vpbe_device_ops vpbe_dev_ops = {
794 .g_cropcap = vpbe_g_cropcap, 794 .g_cropcap = vpbe_g_cropcap,
795 .enum_outputs = vpbe_enum_outputs, 795 .enum_outputs = vpbe_enum_outputs,
796 .set_output = vpbe_set_output, 796 .set_output = vpbe_set_output,
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index a9bc0175e4d3..13d027031ff0 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -355,7 +355,7 @@ static void vpbe_stop_streaming(struct vb2_queue *vq)
355 spin_unlock_irqrestore(&disp->dma_queue_lock, flags); 355 spin_unlock_irqrestore(&disp->dma_queue_lock, flags);
356} 356}
357 357
358static struct vb2_ops video_qops = { 358static const struct vb2_ops video_qops = {
359 .queue_setup = vpbe_buffer_queue_setup, 359 .queue_setup = vpbe_buffer_queue_setup,
360 .wait_prepare = vb2_ops_wait_prepare, 360 .wait_prepare = vb2_ops_wait_prepare,
361 .wait_finish = vb2_ops_wait_finish, 361 .wait_finish = vb2_ops_wait_finish,
@@ -1275,7 +1275,7 @@ static const struct v4l2_ioctl_ops vpbe_ioctl_ops = {
1275 .vidioc_enum_dv_timings = vpbe_display_enum_dv_timings, 1275 .vidioc_enum_dv_timings = vpbe_display_enum_dv_timings,
1276}; 1276};
1277 1277
1278static struct v4l2_file_operations vpbe_fops = { 1278static const struct v4l2_file_operations vpbe_fops = {
1279 .owner = THIS_MODULE, 1279 .owner = THIS_MODULE,
1280 .open = vpbe_display_open, 1280 .open = vpbe_display_open,
1281 .release = vpbe_display_release, 1281 .release = vpbe_display_release,
diff --git a/drivers/media/platform/davinci/vpbe_osd.c b/drivers/media/platform/davinci/vpbe_osd.c
index df042e84a678..66449791c70c 100644
--- a/drivers/media/platform/davinci/vpbe_osd.c
+++ b/drivers/media/platform/davinci/vpbe_osd.c
@@ -37,7 +37,7 @@
37 37
38#define MODULE_NAME "davinci-vpbe-osd" 38#define MODULE_NAME "davinci-vpbe-osd"
39 39
40static struct platform_device_id vpbe_osd_devtype[] = { 40static const struct platform_device_id vpbe_osd_devtype[] = {
41 { 41 {
42 .name = DM644X_VPBE_OSD_SUBDEV_NAME, 42 .name = DM644X_VPBE_OSD_SUBDEV_NAME,
43 .driver_data = VPBE_VERSION_1, 43 .driver_data = VPBE_VERSION_1,
diff --git a/drivers/media/platform/davinci/vpbe_venc.c b/drivers/media/platform/davinci/vpbe_venc.c
index 8bfe90a24681..3a4e78595149 100644
--- a/drivers/media/platform/davinci/vpbe_venc.c
+++ b/drivers/media/platform/davinci/vpbe_venc.c
@@ -36,7 +36,7 @@
36 36
37#define MODULE_NAME "davinci-vpbe-venc" 37#define MODULE_NAME "davinci-vpbe-venc"
38 38
39static struct platform_device_id vpbe_venc_devtype[] = { 39static const struct platform_device_id vpbe_venc_devtype[] = {
40 { 40 {
41 .name = DM644X_VPBE_VENC_SUBDEV_NAME, 41 .name = DM644X_VPBE_VENC_SUBDEV_NAME,
42 .driver_data = VPBE_VERSION_1, 42 .driver_data = VPBE_VERSION_1,
diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c
index b1bf4a7e8eb7..6792da16d9c7 100644
--- a/drivers/media/platform/davinci/vpfe_capture.c
+++ b/drivers/media/platform/davinci/vpfe_capture.c
@@ -1288,7 +1288,7 @@ static void vpfe_videobuf_release(struct videobuf_queue *vq,
1288 vb->state = VIDEOBUF_NEEDS_INIT; 1288 vb->state = VIDEOBUF_NEEDS_INIT;
1289} 1289}
1290 1290
1291static struct videobuf_queue_ops vpfe_videobuf_qops = { 1291static const struct videobuf_queue_ops vpfe_videobuf_qops = {
1292 .buf_setup = vpfe_videobuf_setup, 1292 .buf_setup = vpfe_videobuf_setup,
1293 .buf_prepare = vpfe_videobuf_prepare, 1293 .buf_prepare = vpfe_videobuf_prepare,
1294 .buf_queue = vpfe_videobuf_queue, 1294 .buf_queue = vpfe_videobuf_queue,
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index 4be6554c56c5..0ef36cec21d1 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -312,7 +312,7 @@ static void vpif_stop_streaming(struct vb2_queue *vq)
312 spin_unlock_irqrestore(&common->irqlock, flags); 312 spin_unlock_irqrestore(&common->irqlock, flags);
313} 313}
314 314
315static struct vb2_ops video_qops = { 315static const struct vb2_ops video_qops = {
316 .queue_setup = vpif_buffer_queue_setup, 316 .queue_setup = vpif_buffer_queue_setup,
317 .buf_prepare = vpif_buffer_prepare, 317 .buf_prepare = vpif_buffer_prepare,
318 .start_streaming = vpif_start_streaming, 318 .start_streaming = vpif_start_streaming,
@@ -1344,7 +1344,7 @@ static const struct v4l2_ioctl_ops vpif_ioctl_ops = {
1344}; 1344};
1345 1345
1346/* vpif file operations */ 1346/* vpif file operations */
1347static struct v4l2_file_operations vpif_fops = { 1347static const struct v4l2_file_operations vpif_fops = {
1348 .owner = THIS_MODULE, 1348 .owner = THIS_MODULE,
1349 .open = v4l2_fh_open, 1349 .open = v4l2_fh_open,
1350 .release = vb2_fop_release, 1350 .release = vb2_fop_release,
@@ -1397,9 +1397,9 @@ static int vpif_async_bound(struct v4l2_async_notifier *notifier,
1397 vpif_obj.config->chan_config->inputs[i].subdev_name = 1397 vpif_obj.config->chan_config->inputs[i].subdev_name =
1398 (char *)to_of_node(subdev->fwnode)->full_name; 1398 (char *)to_of_node(subdev->fwnode)->full_name;
1399 vpif_dbg(2, debug, 1399 vpif_dbg(2, debug,
1400 "%s: setting input %d subdev_name = %s\n", 1400 "%s: setting input %d subdev_name = %pOF\n",
1401 __func__, i, 1401 __func__, i,
1402 to_of_node(subdev->fwnode)->full_name); 1402 to_of_node(subdev->fwnode));
1403 return 0; 1403 return 0;
1404 } 1404 }
1405 } 1405 }
@@ -1557,8 +1557,8 @@ vpif_capture_get_pdata(struct platform_device *pdev)
1557 dev_err(&pdev->dev, "Could not parse the endpoint\n"); 1557 dev_err(&pdev->dev, "Could not parse the endpoint\n");
1558 goto done; 1558 goto done;
1559 } 1559 }
1560 dev_dbg(&pdev->dev, "Endpoint %s, bus_width = %d\n", 1560 dev_dbg(&pdev->dev, "Endpoint %pOF, bus_width = %d\n",
1561 endpoint->full_name, bus_cfg.bus.parallel.bus_width); 1561 endpoint, bus_cfg.bus.parallel.bus_width);
1562 flags = bus_cfg.bus.parallel.flags; 1562 flags = bus_cfg.bus.parallel.flags;
1563 1563
1564 if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) 1564 if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
@@ -1569,13 +1569,13 @@ vpif_capture_get_pdata(struct platform_device *pdev)
1569 1569
1570 rem = of_graph_get_remote_port_parent(endpoint); 1570 rem = of_graph_get_remote_port_parent(endpoint);
1571 if (!rem) { 1571 if (!rem) {
1572 dev_dbg(&pdev->dev, "Remote device at %s not found\n", 1572 dev_dbg(&pdev->dev, "Remote device at %pOF not found\n",
1573 endpoint->full_name); 1573 endpoint);
1574 goto done; 1574 goto done;
1575 } 1575 }
1576 1576
1577 dev_dbg(&pdev->dev, "Remote device %s, %s found\n", 1577 dev_dbg(&pdev->dev, "Remote device %s, %pOF found\n",
1578 rem->name, rem->full_name); 1578 rem->name, rem);
1579 sdinfo->name = rem->full_name; 1579 sdinfo->name = rem->full_name;
1580 1580
1581 pdata->asd[i] = devm_kzalloc(&pdev->dev, 1581 pdata->asd[i] = devm_kzalloc(&pdev->dev,
@@ -1593,9 +1593,11 @@ vpif_capture_get_pdata(struct platform_device *pdev)
1593 } 1593 }
1594 1594
1595done: 1595done:
1596 pdata->asd_sizes[0] = i; 1596 if (pdata) {
1597 pdata->subdev_count = i; 1597 pdata->asd_sizes[0] = i;
1598 pdata->card_name = "DA850/OMAP-L138 Video Capture"; 1598 pdata->subdev_count = i;
1599 pdata->card_name = "DA850/OMAP-L138 Video Capture";
1600 }
1599 1601
1600 return pdata; 1602 return pdata;
1601} 1603}
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index bf982bf86542..56fe4e5b396e 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -290,7 +290,7 @@ static void vpif_stop_streaming(struct vb2_queue *vq)
290 spin_unlock_irqrestore(&common->irqlock, flags); 290 spin_unlock_irqrestore(&common->irqlock, flags);
291} 291}
292 292
293static struct vb2_ops video_qops = { 293static const struct vb2_ops video_qops = {
294 .queue_setup = vpif_buffer_queue_setup, 294 .queue_setup = vpif_buffer_queue_setup,
295 .wait_prepare = vb2_ops_wait_prepare, 295 .wait_prepare = vb2_ops_wait_prepare,
296 .wait_finish = vb2_ops_wait_finish, 296 .wait_finish = vb2_ops_wait_finish,
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index 33611a46ce35..2a2994ef15d5 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -747,7 +747,7 @@ static const struct v4l2_file_operations gsc_m2m_fops = {
747 .mmap = gsc_m2m_mmap, 747 .mmap = gsc_m2m_mmap,
748}; 748};
749 749
750static struct v4l2_m2m_ops gsc_m2m_ops = { 750static const struct v4l2_m2m_ops gsc_m2m_ops = {
751 .device_run = gsc_m2m_device_run, 751 .device_run = gsc_m2m_device_run,
752 .job_abort = gsc_m2m_job_abort, 752 .job_abort = gsc_m2m_job_abort,
753}; 753};
diff --git a/drivers/media/platform/exynos4-is/fimc-is-i2c.c b/drivers/media/platform/exynos4-is/fimc-is-i2c.c
index 2f559663e51e..70dd4852b2b9 100644
--- a/drivers/media/platform/exynos4-is/fimc-is-i2c.c
+++ b/drivers/media/platform/exynos4-is/fimc-is-i2c.c
@@ -130,7 +130,7 @@ static int fimc_is_i2c_resume(struct device *dev)
130} 130}
131#endif 131#endif
132 132
133static struct dev_pm_ops fimc_is_i2c_pm_ops = { 133static const struct dev_pm_ops fimc_is_i2c_pm_ops = {
134 SET_RUNTIME_PM_OPS(fimc_is_i2c_runtime_suspend, 134 SET_RUNTIME_PM_OPS(fimc_is_i2c_runtime_suspend,
135 fimc_is_i2c_runtime_resume, NULL) 135 fimc_is_i2c_runtime_resume, NULL)
136 SET_SYSTEM_SLEEP_PM_OPS(fimc_is_i2c_suspend, fimc_is_i2c_resume) 136 SET_SYSTEM_SLEEP_PM_OPS(fimc_is_i2c_suspend, fimc_is_i2c_resume)
diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
index 340d906db370..5ddb2321e9e4 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -174,8 +174,8 @@ static int fimc_is_parse_sensor_config(struct fimc_is *is, unsigned int index,
174 174
175 sensor->drvdata = fimc_is_sensor_get_drvdata(node); 175 sensor->drvdata = fimc_is_sensor_get_drvdata(node);
176 if (!sensor->drvdata) { 176 if (!sensor->drvdata) {
177 dev_err(&is->pdev->dev, "no driver data found for: %s\n", 177 dev_err(&is->pdev->dev, "no driver data found for: %pOF\n",
178 node->full_name); 178 node);
179 return -EINVAL; 179 return -EINVAL;
180 } 180 }
181 181
@@ -191,8 +191,8 @@ static int fimc_is_parse_sensor_config(struct fimc_is *is, unsigned int index,
191 /* Use MIPI-CSIS channel id to determine the ISP I2C bus index. */ 191 /* Use MIPI-CSIS channel id to determine the ISP I2C bus index. */
192 ret = of_property_read_u32(port, "reg", &tmp); 192 ret = of_property_read_u32(port, "reg", &tmp);
193 if (ret < 0) { 193 if (ret < 0) {
194 dev_err(&is->pdev->dev, "reg property not found at: %s\n", 194 dev_err(&is->pdev->dev, "reg property not found at: %pOF\n",
195 port->full_name); 195 port);
196 of_node_put(port); 196 of_node_put(port);
197 return ret; 197 return ret;
198 } 198 }
diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c
index 8efe9160ab34..fd793d3ac072 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp.c
+++ b/drivers/media/platform/exynos4-is/fimc-isp.c
@@ -433,7 +433,7 @@ static const struct v4l2_subdev_core_ops fimc_is_core_ops = {
433 .s_power = fimc_isp_subdev_s_power, 433 .s_power = fimc_isp_subdev_s_power,
434}; 434};
435 435
436static struct v4l2_subdev_ops fimc_is_subdev_ops = { 436static const struct v4l2_subdev_ops fimc_is_subdev_ops = {
437 .core = &fimc_is_core_ops, 437 .core = &fimc_is_core_ops,
438 .video = &fimc_is_subdev_video_ops, 438 .video = &fimc_is_subdev_video_ops,
439 .pad = &fimc_is_subdev_pad_ops, 439 .pad = &fimc_is_subdev_pad_ops,
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index 7d3ec5cc6608..4a3c9948ca54 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -1361,7 +1361,7 @@ static const struct v4l2_subdev_core_ops fimc_lite_core_ops = {
1361 .log_status = fimc_lite_log_status, 1361 .log_status = fimc_lite_log_status,
1362}; 1362};
1363 1363
1364static struct v4l2_subdev_ops fimc_lite_subdev_ops = { 1364static const struct v4l2_subdev_ops fimc_lite_subdev_ops = {
1365 .core = &fimc_lite_core_ops, 1365 .core = &fimc_lite_core_ops,
1366 .video = &fimc_lite_subdev_video_ops, 1366 .video = &fimc_lite_subdev_video_ops,
1367 .pad = &fimc_lite_subdev_pad_ops, 1367 .pad = &fimc_lite_subdev_pad_ops,
@@ -1493,8 +1493,7 @@ static int fimc_lite_probe(struct platform_device *pdev)
1493 1493
1494 if (!drv_data || fimc->index >= drv_data->num_instances || 1494 if (!drv_data || fimc->index >= drv_data->num_instances ||
1495 fimc->index < 0) { 1495 fimc->index < 0) {
1496 dev_err(dev, "Wrong %s node alias\n", 1496 dev_err(dev, "Wrong %pOF node alias\n", dev->of_node);
1497 dev->of_node->full_name);
1498 return -EINVAL; 1497 return -EINVAL;
1499 } 1498 }
1500 1499
diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c
index d8724fe9e9da..9027d0b0d2bd 100644
--- a/drivers/media/platform/exynos4-is/fimc-m2m.c
+++ b/drivers/media/platform/exynos4-is/fimc-m2m.c
@@ -704,7 +704,7 @@ static const struct v4l2_file_operations fimc_m2m_fops = {
704 .mmap = v4l2_m2m_fop_mmap, 704 .mmap = v4l2_m2m_fop_mmap,
705}; 705};
706 706
707static struct v4l2_m2m_ops m2m_ops = { 707static const struct v4l2_m2m_ops m2m_ops = {
708 .device_run = fimc_device_run, 708 .device_run = fimc_device_run,
709 .job_abort = fimc_job_abort, 709 .job_abort = fimc_job_abort,
710}; 710};
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index 7d1cf78846c4..d4656d5175d7 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -412,8 +412,8 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
412 rem = of_graph_get_remote_port_parent(ep); 412 rem = of_graph_get_remote_port_parent(ep);
413 of_node_put(ep); 413 of_node_put(ep);
414 if (rem == NULL) { 414 if (rem == NULL) {
415 v4l2_info(&fmd->v4l2_dev, "Remote device at %s not found\n", 415 v4l2_info(&fmd->v4l2_dev, "Remote device at %pOF not found\n",
416 ep->full_name); 416 ep);
417 return 0; 417 return 0;
418 } 418 }
419 419
@@ -430,8 +430,8 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
430 */ 430 */
431 pd->sensor_bus_type = FIMC_BUS_TYPE_MIPI_CSI2; 431 pd->sensor_bus_type = FIMC_BUS_TYPE_MIPI_CSI2;
432 } else { 432 } else {
433 v4l2_err(&fmd->v4l2_dev, "Wrong port id (%u) at node %s\n", 433 v4l2_err(&fmd->v4l2_dev, "Wrong port id (%u) at node %pOF\n",
434 endpoint.base.port, rem->full_name); 434 endpoint.base.port, rem);
435 } 435 }
436 /* 436 /*
437 * For FIMC-IS handled sensors, that are placed under i2c-isp device 437 * For FIMC-IS handled sensors, that are placed under i2c-isp device
diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c
index 98c89873c2dc..560aadabcb11 100644
--- a/drivers/media/platform/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/exynos4-is/mipi-csis.c
@@ -730,8 +730,8 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
730 730
731 node = of_graph_get_next_endpoint(node, NULL); 731 node = of_graph_get_next_endpoint(node, NULL);
732 if (!node) { 732 if (!node) {
733 dev_err(&pdev->dev, "No port node at %s\n", 733 dev_err(&pdev->dev, "No port node at %pOF\n",
734 pdev->dev.of_node->full_name); 734 pdev->dev.of_node);
735 return -EINVAL; 735 return -EINVAL;
736 } 736 }
737 /* Get port node and validate MIPI-CSI channel id. */ 737 /* Get port node and validate MIPI-CSI channel id. */
diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c
index 97e164b2075a..fb43025df573 100644
--- a/drivers/media/platform/fsl-viu.c
+++ b/drivers/media/platform/fsl-viu.c
@@ -549,7 +549,7 @@ static void buffer_release(struct videobuf_queue *vq,
549 free_buffer(vq, buf); 549 free_buffer(vq, buf);
550} 550}
551 551
552static struct videobuf_queue_ops viu_video_qops = { 552static const struct videobuf_queue_ops viu_video_qops = {
553 .buf_setup = buffer_setup, 553 .buf_setup = buffer_setup,
554 .buf_prepare = buffer_prepare, 554 .buf_prepare = buffer_prepare,
555 .buf_queue = buffer_queue, 555 .buf_queue = buffer_queue,
@@ -1340,7 +1340,7 @@ static int viu_mmap(struct file *file, struct vm_area_struct *vma)
1340 return ret; 1340 return ret;
1341} 1341}
1342 1342
1343static struct v4l2_file_operations viu_fops = { 1343static const struct v4l2_file_operations viu_fops = {
1344 .owner = THIS_MODULE, 1344 .owner = THIS_MODULE,
1345 .open = viu_open, 1345 .open = viu_open,
1346 .release = viu_release, 1346 .release = viu_release,
@@ -1380,7 +1380,7 @@ static const struct v4l2_ioctl_ops viu_ioctl_ops = {
1380 .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 1380 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1381}; 1381};
1382 1382
1383static struct video_device viu_template = { 1383static const struct video_device viu_template = {
1384 .name = "FSL viu", 1384 .name = "FSL viu",
1385 .fops = &viu_fops, 1385 .fops = &viu_fops,
1386 .minor = -1, 1386 .minor = -1,
diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
index 980066b8d32a..c8a12493f395 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -979,7 +979,7 @@ static const struct v4l2_file_operations deinterlace_fops = {
979 .mmap = deinterlace_mmap, 979 .mmap = deinterlace_mmap,
980}; 980};
981 981
982static struct video_device deinterlace_videodev = { 982static const struct video_device deinterlace_videodev = {
983 .name = MEM2MEM_NAME, 983 .name = MEM2MEM_NAME,
984 .fops = &deinterlace_fops, 984 .fops = &deinterlace_fops,
985 .ioctl_ops = &deinterlace_ioctl_ops, 985 .ioctl_ops = &deinterlace_ioctl_ops,
@@ -988,7 +988,7 @@ static struct video_device deinterlace_videodev = {
988 .vfl_dir = VFL_DIR_M2M, 988 .vfl_dir = VFL_DIR_M2M,
989}; 989};
990 990
991static struct v4l2_m2m_ops m2m_ops = { 991static const struct v4l2_m2m_ops m2m_ops = {
992 .device_run = deinterlace_device_run, 992 .device_run = deinterlace_device_run,
993 .job_ready = deinterlace_job_ready, 993 .job_ready = deinterlace_job_ready,
994 .job_abort = deinterlace_job_abort, 994 .job_abort = deinterlace_job_abort,
diff --git a/drivers/media/platform/marvell-ccic/cafe-driver.c b/drivers/media/platform/marvell-ccic/cafe-driver.c
index 77890bd0deab..57d2c483ad09 100644
--- a/drivers/media/platform/marvell-ccic/cafe-driver.c
+++ b/drivers/media/platform/marvell-ccic/cafe-driver.c
@@ -326,7 +326,7 @@ static u32 cafe_smbus_func(struct i2c_adapter *adapter)
326 I2C_FUNC_SMBUS_WRITE_BYTE_DATA; 326 I2C_FUNC_SMBUS_WRITE_BYTE_DATA;
327} 327}
328 328
329static struct i2c_algorithm cafe_smbus_algo = { 329static const struct i2c_algorithm cafe_smbus_algo = {
330 .smbus_xfer = cafe_smbus_xfer, 330 .smbus_xfer = cafe_smbus_xfer,
331 .functionality = cafe_smbus_func 331 .functionality = cafe_smbus_func
332}; 332};
@@ -612,7 +612,7 @@ static int cafe_pci_resume(struct pci_dev *pdev)
612 612
613#endif /* CONFIG_PM */ 613#endif /* CONFIG_PM */
614 614
615static struct pci_device_id cafe_ids[] = { 615static const struct pci_device_id cafe_ids[] = {
616 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 616 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL,
617 PCI_DEVICE_ID_MARVELL_88ALP01_CCIC) }, 617 PCI_DEVICE_ID_MARVELL_88ALP01_CCIC) },
618 { 0, } 618 { 0, }
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 8cac2f202099..b07a251e8857 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1639,7 +1639,7 @@ static const struct v4l2_file_operations mcam_v4l_fops = {
1639 * This template device holds all of those v4l2 methods; we 1639 * This template device holds all of those v4l2 methods; we
1640 * clone it for specific real devices. 1640 * clone it for specific real devices.
1641 */ 1641 */
1642static struct video_device mcam_v4l_template = { 1642static const struct video_device mcam_v4l_template = {
1643 .name = "mcam", 1643 .name = "mcam",
1644 .fops = &mcam_v4l_fops, 1644 .fops = &mcam_v4l_fops,
1645 .ioctl_ops = &mcam_v4l_ioctl_ops, 1645 .ioctl_ops = &mcam_v4l_ioctl_ops,
diff --git a/drivers/media/platform/meson/Makefile b/drivers/media/platform/meson/Makefile
new file mode 100644
index 000000000000..597beb8f34d1
--- /dev/null
+++ b/drivers/media/platform/meson/Makefile
@@ -0,0 +1 @@
obj-$(CONFIG_VIDEO_MESON_AO_CEC) += ao-cec.o
diff --git a/drivers/media/platform/meson/ao-cec.c b/drivers/media/platform/meson/ao-cec.c
new file mode 100644
index 000000000000..8040a6285c3f
--- /dev/null
+++ b/drivers/media/platform/meson/ao-cec.c
@@ -0,0 +1,744 @@
1/*
2 * Driver for Amlogic Meson AO CEC Controller
3 *
4 * Copyright (C) 2015 Amlogic, Inc. All rights reserved
5 * Copyright (C) 2017 BayLibre, SAS
6 * Author: Neil Armstrong <narmstrong@baylibre.com>
7 *
8 * SPDX-License-Identifier: GPL-2.0+
9 */
10
11#include <linux/bitfield.h>
12#include <linux/clk.h>
13#include <linux/device.h>
14#include <linux/io.h>
15#include <linux/delay.h>
16#include <linux/kernel.h>
17#include <linux/module.h>
18#include <linux/of.h>
19#include <linux/of_platform.h>
20#include <linux/platform_device.h>
21#include <linux/types.h>
22#include <linux/interrupt.h>
23#include <linux/reset.h>
24#include <media/cec.h>
25#include <media/cec-notifier.h>
26
27/* CEC Registers */
28
29/*
30 * [2:1] cntl_clk
31 * - 0 = Disable clk (Power-off mode)
32 * - 1 = Enable gated clock (Normal mode)
33 * - 2 = Enable free-run clk (Debug mode)
34 */
35#define CEC_GEN_CNTL_REG 0x00
36
37#define CEC_GEN_CNTL_RESET BIT(0)
38#define CEC_GEN_CNTL_CLK_DISABLE 0
39#define CEC_GEN_CNTL_CLK_ENABLE 1
40#define CEC_GEN_CNTL_CLK_ENABLE_DBG 2
41#define CEC_GEN_CNTL_CLK_CTRL_MASK GENMASK(2, 1)
42
43/*
44 * [7:0] cec_reg_addr
45 * [15:8] cec_reg_wrdata
46 * [16] cec_reg_wr
47 * - 0 = Read
48 * - 1 = Write
49 * [23] bus free
50 * [31:24] cec_reg_rddata
51 */
52#define CEC_RW_REG 0x04
53
54#define CEC_RW_ADDR GENMASK(7, 0)
55#define CEC_RW_WR_DATA GENMASK(15, 8)
56#define CEC_RW_WRITE_EN BIT(16)
57#define CEC_RW_BUS_BUSY BIT(23)
58#define CEC_RW_RD_DATA GENMASK(31, 24)
59
60/*
61 * [1] tx intr
62 * [2] rx intr
63 */
64#define CEC_INTR_MASKN_REG 0x08
65#define CEC_INTR_CLR_REG 0x0c
66#define CEC_INTR_STAT_REG 0x10
67
68#define CEC_INTR_TX BIT(1)
69#define CEC_INTR_RX BIT(2)
70
71/* CEC Commands */
72
73#define CEC_TX_MSG_0_HEADER 0x00
74#define CEC_TX_MSG_1_OPCODE 0x01
75#define CEC_TX_MSG_2_OP1 0x02
76#define CEC_TX_MSG_3_OP2 0x03
77#define CEC_TX_MSG_4_OP3 0x04
78#define CEC_TX_MSG_5_OP4 0x05
79#define CEC_TX_MSG_6_OP5 0x06
80#define CEC_TX_MSG_7_OP6 0x07
81#define CEC_TX_MSG_8_OP7 0x08
82#define CEC_TX_MSG_9_OP8 0x09
83#define CEC_TX_MSG_A_OP9 0x0A
84#define CEC_TX_MSG_B_OP10 0x0B
85#define CEC_TX_MSG_C_OP11 0x0C
86#define CEC_TX_MSG_D_OP12 0x0D
87#define CEC_TX_MSG_E_OP13 0x0E
88#define CEC_TX_MSG_F_OP14 0x0F
89#define CEC_TX_MSG_LENGTH 0x10
90#define CEC_TX_MSG_CMD 0x11
91#define CEC_TX_WRITE_BUF 0x12
92#define CEC_TX_CLEAR_BUF 0x13
93#define CEC_RX_MSG_CMD 0x14
94#define CEC_RX_CLEAR_BUF 0x15
95#define CEC_LOGICAL_ADDR0 0x16
96#define CEC_LOGICAL_ADDR1 0x17
97#define CEC_LOGICAL_ADDR2 0x18
98#define CEC_LOGICAL_ADDR3 0x19
99#define CEC_LOGICAL_ADDR4 0x1A
100#define CEC_CLOCK_DIV_H 0x1B
101#define CEC_CLOCK_DIV_L 0x1C
102#define CEC_QUIESCENT_25MS_BIT7_0 0x20
103#define CEC_QUIESCENT_25MS_BIT11_8 0x21
104#define CEC_STARTBITMINL2H_3MS5_BIT7_0 0x22
105#define CEC_STARTBITMINL2H_3MS5_BIT8 0x23
106#define CEC_STARTBITMAXL2H_3MS9_BIT7_0 0x24
107#define CEC_STARTBITMAXL2H_3MS9_BIT8 0x25
108#define CEC_STARTBITMINH_0MS6_BIT7_0 0x26
109#define CEC_STARTBITMINH_0MS6_BIT8 0x27
110#define CEC_STARTBITMAXH_1MS0_BIT7_0 0x28
111#define CEC_STARTBITMAXH_1MS0_BIT8 0x29
112#define CEC_STARTBITMINTOT_4MS3_BIT7_0 0x2A
113#define CEC_STARTBITMINTOT_4MS3_BIT9_8 0x2B
114#define CEC_STARTBITMAXTOT_4MS7_BIT7_0 0x2C
115#define CEC_STARTBITMAXTOT_4MS7_BIT9_8 0x2D
116#define CEC_LOGIC1MINL2H_0MS4_BIT7_0 0x2E
117#define CEC_LOGIC1MINL2H_0MS4_BIT8 0x2F
118#define CEC_LOGIC1MAXL2H_0MS8_BIT7_0 0x30
119#define CEC_LOGIC1MAXL2H_0MS8_BIT8 0x31
120#define CEC_LOGIC0MINL2H_1MS3_BIT7_0 0x32
121#define CEC_LOGIC0MINL2H_1MS3_BIT8 0x33
122#define CEC_LOGIC0MAXL2H_1MS7_BIT7_0 0x34
123#define CEC_LOGIC0MAXL2H_1MS7_BIT8 0x35
124#define CEC_LOGICMINTOTAL_2MS05_BIT7_0 0x36
125#define CEC_LOGICMINTOTAL_2MS05_BIT9_8 0x37
126#define CEC_LOGICMAXHIGH_2MS8_BIT7_0 0x38
127#define CEC_LOGICMAXHIGH_2MS8_BIT8 0x39
128#define CEC_LOGICERRLOW_3MS4_BIT7_0 0x3A
129#define CEC_LOGICERRLOW_3MS4_BIT8 0x3B
130#define CEC_NOMSMPPOINT_1MS05 0x3C
131#define CEC_DELCNTR_LOGICERR 0x3E
132#define CEC_TXTIME_17MS_BIT7_0 0x40
133#define CEC_TXTIME_17MS_BIT10_8 0x41
134#define CEC_TXTIME_2BIT_BIT7_0 0x42
135#define CEC_TXTIME_2BIT_BIT10_8 0x43
136#define CEC_TXTIME_4BIT_BIT7_0 0x44
137#define CEC_TXTIME_4BIT_BIT10_8 0x45
138#define CEC_STARTBITNOML2H_3MS7_BIT7_0 0x46
139#define CEC_STARTBITNOML2H_3MS7_BIT8 0x47
140#define CEC_STARTBITNOMH_0MS8_BIT7_0 0x48
141#define CEC_STARTBITNOMH_0MS8_BIT8 0x49
142#define CEC_LOGIC1NOML2H_0MS6_BIT7_0 0x4A
143#define CEC_LOGIC1NOML2H_0MS6_BIT8 0x4B
144#define CEC_LOGIC0NOML2H_1MS5_BIT7_0 0x4C
145#define CEC_LOGIC0NOML2H_1MS5_BIT8 0x4D
146#define CEC_LOGIC1NOMH_1MS8_BIT7_0 0x4E
147#define CEC_LOGIC1NOMH_1MS8_BIT8 0x4F
148#define CEC_LOGIC0NOMH_0MS9_BIT7_0 0x50
149#define CEC_LOGIC0NOMH_0MS9_BIT8 0x51
150#define CEC_LOGICERRLOW_3MS6_BIT7_0 0x52
151#define CEC_LOGICERRLOW_3MS6_BIT8 0x53
152#define CEC_CHKCONTENTION_0MS1 0x54
153#define CEC_PREPARENXTBIT_0MS05_BIT7_0 0x56
154#define CEC_PREPARENXTBIT_0MS05_BIT8 0x57
155#define CEC_NOMSMPACKPOINT_0MS45 0x58
156#define CEC_ACK0NOML2H_1MS5_BIT7_0 0x5A
157#define CEC_ACK0NOML2H_1MS5_BIT8 0x5B
158#define CEC_BUGFIX_DISABLE_0 0x60
159#define CEC_BUGFIX_DISABLE_1 0x61
160#define CEC_RX_MSG_0_HEADER 0x80
161#define CEC_RX_MSG_1_OPCODE 0x81
162#define CEC_RX_MSG_2_OP1 0x82
163#define CEC_RX_MSG_3_OP2 0x83
164#define CEC_RX_MSG_4_OP3 0x84
165#define CEC_RX_MSG_5_OP4 0x85
166#define CEC_RX_MSG_6_OP5 0x86
167#define CEC_RX_MSG_7_OP6 0x87
168#define CEC_RX_MSG_8_OP7 0x88
169#define CEC_RX_MSG_9_OP8 0x89
170#define CEC_RX_MSG_A_OP9 0x8A
171#define CEC_RX_MSG_B_OP10 0x8B
172#define CEC_RX_MSG_C_OP11 0x8C
173#define CEC_RX_MSG_D_OP12 0x8D
174#define CEC_RX_MSG_E_OP13 0x8E
175#define CEC_RX_MSG_F_OP14 0x8F
176#define CEC_RX_MSG_LENGTH 0x90
177#define CEC_RX_MSG_STATUS 0x91
178#define CEC_RX_NUM_MSG 0x92
179#define CEC_TX_MSG_STATUS 0x93
180#define CEC_TX_NUM_MSG 0x94
181
182
183/* CEC_TX_MSG_CMD definition */
184#define TX_NO_OP 0 /* No transaction */
185#define TX_REQ_CURRENT 1 /* Transmit earliest message in buffer */
186#define TX_ABORT 2 /* Abort transmitting earliest message */
187#define TX_REQ_NEXT 3 /* Overwrite earliest msg, transmit next */
188
189/* tx_msg_status definition */
190#define TX_IDLE 0 /* No transaction */
191#define TX_BUSY 1 /* Transmitter is busy */
192#define TX_DONE 2 /* Message successfully transmitted */
193#define TX_ERROR 3 /* Message transmitted with error */
194
195/* rx_msg_cmd */
196#define RX_NO_OP 0 /* No transaction */
197#define RX_ACK_CURRENT 1 /* Read earliest message in buffer */
198#define RX_DISABLE 2 /* Disable receiving latest message */
199#define RX_ACK_NEXT 3 /* Clear earliest msg, read next */
200
201/* rx_msg_status */
202#define RX_IDLE 0 /* No transaction */
203#define RX_BUSY 1 /* Receiver is busy */
204#define RX_DONE 2 /* Message has been received successfully */
205#define RX_ERROR 3 /* Message has been received with error */
206
207/* RX_CLEAR_BUF options */
208#define CLEAR_START 1
209#define CLEAR_STOP 0
210
211/* CEC_LOGICAL_ADDRx options */
212#define LOGICAL_ADDR_MASK 0xf
213#define LOGICAL_ADDR_VALID BIT(4)
214#define LOGICAL_ADDR_DISABLE 0
215
216#define CEC_CLK_RATE 32768
217
218struct meson_ao_cec_device {
219 struct platform_device *pdev;
220 void __iomem *base;
221 struct clk *core;
222 spinlock_t cec_reg_lock;
223 struct cec_notifier *notify;
224 struct cec_adapter *adap;
225 struct cec_msg rx_msg;
226};
227
228#define writel_bits_relaxed(mask, val, addr) \
229 writel_relaxed((readl_relaxed(addr) & ~(mask)) | (val), addr)
230
231static inline int meson_ao_cec_wait_busy(struct meson_ao_cec_device *ao_cec)
232{
233 ktime_t timeout = ktime_add_us(ktime_get(), 5000);
234
235 while (readl_relaxed(ao_cec->base + CEC_RW_REG) & CEC_RW_BUS_BUSY) {
236 if (ktime_compare(ktime_get(), timeout) > 0)
237 return -ETIMEDOUT;
238 }
239
240 return 0;
241}
242
243static void meson_ao_cec_read(struct meson_ao_cec_device *ao_cec,
244 unsigned long address, u8 *data,
245 int *res)
246{
247 unsigned long flags;
248 u32 reg = FIELD_PREP(CEC_RW_ADDR, address);
249 int ret = 0;
250
251 if (res && *res)
252 return;
253
254 spin_lock_irqsave(&ao_cec->cec_reg_lock, flags);
255
256 ret = meson_ao_cec_wait_busy(ao_cec);
257 if (ret)
258 goto read_out;
259
260 writel_relaxed(reg, ao_cec->base + CEC_RW_REG);
261
262 ret = meson_ao_cec_wait_busy(ao_cec);
263 if (ret)
264 goto read_out;
265
266 *data = FIELD_GET(CEC_RW_RD_DATA,
267 readl_relaxed(ao_cec->base + CEC_RW_REG));
268
269read_out:
270 spin_unlock_irqrestore(&ao_cec->cec_reg_lock, flags);
271
272 if (res)
273 *res = ret;
274}
275
276static void meson_ao_cec_write(struct meson_ao_cec_device *ao_cec,
277 unsigned long address, u8 data,
278 int *res)
279{
280 unsigned long flags;
281 u32 reg = FIELD_PREP(CEC_RW_ADDR, address) |
282 FIELD_PREP(CEC_RW_WR_DATA, data) |
283 CEC_RW_WRITE_EN;
284 int ret = 0;
285
286 if (res && *res)
287 return;
288
289 spin_lock_irqsave(&ao_cec->cec_reg_lock, flags);
290
291 ret = meson_ao_cec_wait_busy(ao_cec);
292 if (ret)
293 goto write_out;
294
295 writel_relaxed(reg, ao_cec->base + CEC_RW_REG);
296
297write_out:
298 spin_unlock_irqrestore(&ao_cec->cec_reg_lock, flags);
299
300 if (res)
301 *res = ret;
302}
303
304static inline void meson_ao_cec_irq_setup(struct meson_ao_cec_device *ao_cec,
305 bool enable)
306{
307 u32 cfg = CEC_INTR_TX | CEC_INTR_RX;
308
309 writel_bits_relaxed(cfg, enable ? cfg : 0,
310 ao_cec->base + CEC_INTR_MASKN_REG);
311}
312
313static inline int meson_ao_cec_clear(struct meson_ao_cec_device *ao_cec)
314{
315 int ret = 0;
316
317 meson_ao_cec_write(ao_cec, CEC_RX_MSG_CMD, RX_DISABLE, &ret);
318 meson_ao_cec_write(ao_cec, CEC_TX_MSG_CMD, TX_ABORT, &ret);
319 meson_ao_cec_write(ao_cec, CEC_RX_CLEAR_BUF, 1, &ret);
320 meson_ao_cec_write(ao_cec, CEC_TX_CLEAR_BUF, 1, &ret);
321 if (ret)
322 return ret;
323
324 udelay(100);
325
326 meson_ao_cec_write(ao_cec, CEC_RX_CLEAR_BUF, 0, &ret);
327 meson_ao_cec_write(ao_cec, CEC_TX_CLEAR_BUF, 0, &ret);
328 if (ret)
329 return ret;
330
331 udelay(100);
332
333 meson_ao_cec_write(ao_cec, CEC_RX_MSG_CMD, RX_NO_OP, &ret);
334 meson_ao_cec_write(ao_cec, CEC_TX_MSG_CMD, TX_NO_OP, &ret);
335
336 return ret;
337}
338
339static int meson_ao_cec_arbit_bit_time_set(struct meson_ao_cec_device *ao_cec,
340 unsigned int bit_set,
341 unsigned int time_set)
342{
343 int ret = 0;
344
345 switch (bit_set) {
346 case CEC_SIGNAL_FREE_TIME_RETRY:
347 meson_ao_cec_write(ao_cec, CEC_TXTIME_4BIT_BIT7_0,
348 time_set & 0xff, &ret);
349 meson_ao_cec_write(ao_cec, CEC_TXTIME_4BIT_BIT10_8,
350 (time_set >> 8) & 0x7, &ret);
351 break;
352
353 case CEC_SIGNAL_FREE_TIME_NEW_INITIATOR:
354 meson_ao_cec_write(ao_cec, CEC_TXTIME_2BIT_BIT7_0,
355 time_set & 0xff, &ret);
356 meson_ao_cec_write(ao_cec, CEC_TXTIME_2BIT_BIT10_8,
357 (time_set >> 8) & 0x7, &ret);
358 break;
359
360 case CEC_SIGNAL_FREE_TIME_NEXT_XFER:
361 meson_ao_cec_write(ao_cec, CEC_TXTIME_17MS_BIT7_0,
362 time_set & 0xff, &ret);
363 meson_ao_cec_write(ao_cec, CEC_TXTIME_17MS_BIT10_8,
364 (time_set >> 8) & 0x7, &ret);
365 break;
366 }
367
368 return ret;
369}
370
371static irqreturn_t meson_ao_cec_irq(int irq, void *data)
372{
373 struct meson_ao_cec_device *ao_cec = data;
374 u32 stat = readl_relaxed(ao_cec->base + CEC_INTR_STAT_REG);
375
376 if (stat)
377 return IRQ_WAKE_THREAD;
378
379 return IRQ_NONE;
380}
381
382static void meson_ao_cec_irq_tx(struct meson_ao_cec_device *ao_cec)
383{
384 unsigned long tx_status = 0;
385 u8 stat;
386 int ret = 0;
387
388 meson_ao_cec_read(ao_cec, CEC_TX_MSG_STATUS, &stat, &ret);
389 if (ret)
390 goto tx_reg_err;
391
392 switch (stat) {
393 case TX_DONE:
394 tx_status = CEC_TX_STATUS_OK;
395 break;
396
397 case TX_BUSY:
398 tx_status = CEC_TX_STATUS_ARB_LOST;
399 break;
400
401 case TX_IDLE:
402 tx_status = CEC_TX_STATUS_LOW_DRIVE;
403 break;
404
405 case TX_ERROR:
406 default:
407 tx_status = CEC_TX_STATUS_NACK;
408 break;
409 }
410
411 /* Clear Interruption */
412 writel_relaxed(CEC_INTR_TX, ao_cec->base + CEC_INTR_CLR_REG);
413
414 /* Stop TX */
415 meson_ao_cec_write(ao_cec, CEC_TX_MSG_CMD, TX_NO_OP, &ret);
416 if (ret)
417 goto tx_reg_err;
418
419 cec_transmit_attempt_done(ao_cec->adap, tx_status);
420 return;
421
422tx_reg_err:
423 cec_transmit_attempt_done(ao_cec->adap, CEC_TX_STATUS_ERROR);
424}
425
426static void meson_ao_cec_irq_rx(struct meson_ao_cec_device *ao_cec)
427{
428 int i, ret = 0;
429 u8 reg;
430
431 meson_ao_cec_read(ao_cec, CEC_RX_MSG_STATUS, &reg, &ret);
432 if (reg != RX_DONE)
433 goto rx_out;
434
435 meson_ao_cec_read(ao_cec, CEC_RX_NUM_MSG, &reg, &ret);
436 if (reg != 1)
437 goto rx_out;
438
439 meson_ao_cec_read(ao_cec, CEC_RX_MSG_LENGTH, &reg, &ret);
440
441 ao_cec->rx_msg.len = reg + 1;
442 if (ao_cec->rx_msg.len > CEC_MAX_MSG_SIZE)
443 ao_cec->rx_msg.len = CEC_MAX_MSG_SIZE;
444
445 for (i = 0; i < ao_cec->rx_msg.len; i++) {
446 u8 byte;
447
448 meson_ao_cec_read(ao_cec, CEC_RX_MSG_0_HEADER + i, &byte, &ret);
449
450 ao_cec->rx_msg.msg[i] = byte;
451 }
452
453 if (ret)
454 goto rx_out;
455
456 cec_received_msg(ao_cec->adap, &ao_cec->rx_msg);
457
458rx_out:
459 /* Clear Interruption */
460 writel_relaxed(CEC_INTR_RX, ao_cec->base + CEC_INTR_CLR_REG);
461
462 /* Ack RX message */
463 meson_ao_cec_write(ao_cec, CEC_RX_MSG_CMD, RX_ACK_CURRENT, &ret);
464 meson_ao_cec_write(ao_cec, CEC_RX_MSG_CMD, RX_NO_OP, &ret);
465
466 /* Clear RX buffer */
467 meson_ao_cec_write(ao_cec, CEC_RX_CLEAR_BUF, CLEAR_START, &ret);
468 meson_ao_cec_write(ao_cec, CEC_RX_CLEAR_BUF, CLEAR_STOP, &ret);
469}
470
471static irqreturn_t meson_ao_cec_irq_thread(int irq, void *data)
472{
473 struct meson_ao_cec_device *ao_cec = data;
474 u32 stat = readl_relaxed(ao_cec->base + CEC_INTR_STAT_REG);
475
476 if (stat & CEC_INTR_TX)
477 meson_ao_cec_irq_tx(ao_cec);
478
479 meson_ao_cec_irq_rx(ao_cec);
480
481 return IRQ_HANDLED;
482}
483
484static int meson_ao_cec_set_log_addr(struct cec_adapter *adap, u8 logical_addr)
485{
486 struct meson_ao_cec_device *ao_cec = adap->priv;
487 int ret = 0;
488
489 meson_ao_cec_write(ao_cec, CEC_LOGICAL_ADDR0,
490 LOGICAL_ADDR_DISABLE, &ret);
491 if (ret)
492 return ret;
493
494 ret = meson_ao_cec_clear(ao_cec);
495 if (ret)
496 return ret;
497
498 if (logical_addr == CEC_LOG_ADDR_INVALID)
499 return 0;
500
501 meson_ao_cec_write(ao_cec, CEC_LOGICAL_ADDR0,
502 logical_addr & LOGICAL_ADDR_MASK, &ret);
503 if (ret)
504 return ret;
505
506 udelay(100);
507
508 meson_ao_cec_write(ao_cec, CEC_LOGICAL_ADDR0,
509 (logical_addr & LOGICAL_ADDR_MASK) |
510 LOGICAL_ADDR_VALID, &ret);
511
512 return ret;
513}
514
515static int meson_ao_cec_transmit(struct cec_adapter *adap, u8 attempts,
516 u32 signal_free_time, struct cec_msg *msg)
517{
518 struct meson_ao_cec_device *ao_cec = adap->priv;
519 int i, ret = 0;
520 u8 reg;
521
522 meson_ao_cec_read(ao_cec, CEC_TX_MSG_STATUS, &reg, &ret);
523 if (ret)
524 return ret;
525
526 if (reg == TX_BUSY) {
527 dev_err(&ao_cec->pdev->dev, "%s: busy TX: aborting\n",
528 __func__);
529 meson_ao_cec_write(ao_cec, CEC_TX_MSG_CMD, TX_ABORT, &ret);
530 }
531
532 for (i = 0; i < msg->len; i++) {
533 meson_ao_cec_write(ao_cec, CEC_TX_MSG_0_HEADER + i,
534 msg->msg[i], &ret);
535 }
536
537 meson_ao_cec_write(ao_cec, CEC_TX_MSG_LENGTH, msg->len - 1, &ret);
538 meson_ao_cec_write(ao_cec, CEC_TX_MSG_CMD, TX_REQ_CURRENT, &ret);
539
540 return ret;
541}
542
543static int meson_ao_cec_adap_enable(struct cec_adapter *adap, bool enable)
544{
545 struct meson_ao_cec_device *ao_cec = adap->priv;
546 int ret;
547
548 meson_ao_cec_irq_setup(ao_cec, false);
549
550 writel_bits_relaxed(CEC_GEN_CNTL_RESET, CEC_GEN_CNTL_RESET,
551 ao_cec->base + CEC_GEN_CNTL_REG);
552
553 if (!enable)
554 return 0;
555
556 /* Enable gated clock (Normal mode). */
557 writel_bits_relaxed(CEC_GEN_CNTL_CLK_CTRL_MASK,
558 FIELD_PREP(CEC_GEN_CNTL_CLK_CTRL_MASK,
559 CEC_GEN_CNTL_CLK_ENABLE),
560 ao_cec->base + CEC_GEN_CNTL_REG);
561
562 udelay(100);
563
564 /* Release Reset */
565 writel_bits_relaxed(CEC_GEN_CNTL_RESET, 0,
566 ao_cec->base + CEC_GEN_CNTL_REG);
567
568 /* Clear buffers */
569 ret = meson_ao_cec_clear(ao_cec);
570 if (ret)
571 return ret;
572
573 /* CEC arbitration 3/5/7 bit time set. */
574 ret = meson_ao_cec_arbit_bit_time_set(ao_cec,
575 CEC_SIGNAL_FREE_TIME_RETRY,
576 0x118);
577 if (ret)
578 return ret;
579 ret = meson_ao_cec_arbit_bit_time_set(ao_cec,
580 CEC_SIGNAL_FREE_TIME_NEW_INITIATOR,
581 0x000);
582 if (ret)
583 return ret;
584 ret = meson_ao_cec_arbit_bit_time_set(ao_cec,
585 CEC_SIGNAL_FREE_TIME_NEXT_XFER,
586 0x2aa);
587 if (ret)
588 return ret;
589
590 meson_ao_cec_irq_setup(ao_cec, true);
591
592 return 0;
593}
594
595static const struct cec_adap_ops meson_ao_cec_ops = {
596 .adap_enable = meson_ao_cec_adap_enable,
597 .adap_log_addr = meson_ao_cec_set_log_addr,
598 .adap_transmit = meson_ao_cec_transmit,
599};
600
601static int meson_ao_cec_probe(struct platform_device *pdev)
602{
603 struct meson_ao_cec_device *ao_cec;
604 struct platform_device *hdmi_dev;
605 struct device_node *np;
606 struct resource *res;
607 int ret, irq;
608
609 np = of_parse_phandle(pdev->dev.of_node, "hdmi-phandle", 0);
610 if (!np) {
611 dev_err(&pdev->dev, "Failed to find hdmi node\n");
612 return -ENODEV;
613 }
614
615 hdmi_dev = of_find_device_by_node(np);
616 if (hdmi_dev == NULL)
617 return -EPROBE_DEFER;
618
619 ao_cec = devm_kzalloc(&pdev->dev, sizeof(*ao_cec), GFP_KERNEL);
620 if (!ao_cec)
621 return -ENOMEM;
622
623 spin_lock_init(&ao_cec->cec_reg_lock);
624
625 ao_cec->notify = cec_notifier_get(&hdmi_dev->dev);
626 if (!ao_cec->notify)
627 return -ENOMEM;
628
629 ao_cec->adap = cec_allocate_adapter(&meson_ao_cec_ops, ao_cec,
630 "meson_ao_cec",
631 CEC_CAP_LOG_ADDRS |
632 CEC_CAP_TRANSMIT |
633 CEC_CAP_RC |
634 CEC_CAP_PASSTHROUGH,
635 1); /* Use 1 for now */
636 if (IS_ERR(ao_cec->adap)) {
637 ret = PTR_ERR(ao_cec->adap);
638 goto out_probe_notify;
639 }
640
641 ao_cec->adap->owner = THIS_MODULE;
642
643 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
644 ao_cec->base = devm_ioremap_resource(&pdev->dev, res);
645 if (IS_ERR(ao_cec->base)) {
646 ret = PTR_ERR(ao_cec->base);
647 goto out_probe_adapter;
648 }
649
650 irq = platform_get_irq(pdev, 0);
651 ret = devm_request_threaded_irq(&pdev->dev, irq,
652 meson_ao_cec_irq,
653 meson_ao_cec_irq_thread,
654 0, NULL, ao_cec);
655 if (ret) {
656 dev_err(&pdev->dev, "irq request failed\n");
657 goto out_probe_adapter;
658 }
659
660 ao_cec->core = devm_clk_get(&pdev->dev, "core");
661 if (IS_ERR(ao_cec->core)) {
662 dev_err(&pdev->dev, "core clock request failed\n");
663 ret = PTR_ERR(ao_cec->core);
664 goto out_probe_adapter;
665 }
666
667 ret = clk_prepare_enable(ao_cec->core);
668 if (ret) {
669 dev_err(&pdev->dev, "core clock enable failed\n");
670 goto out_probe_adapter;
671 }
672
673 ret = clk_set_rate(ao_cec->core, CEC_CLK_RATE);
674 if (ret) {
675 dev_err(&pdev->dev, "core clock set rate failed\n");
676 goto out_probe_clk;
677 }
678
679 device_reset_optional(&pdev->dev);
680
681 ao_cec->pdev = pdev;
682 platform_set_drvdata(pdev, ao_cec);
683
684 ret = cec_register_adapter(ao_cec->adap, &pdev->dev);
685 if (ret < 0) {
686 cec_notifier_put(ao_cec->notify);
687 goto out_probe_clk;
688 }
689
690 /* Setup Hardware */
691 writel_relaxed(CEC_GEN_CNTL_RESET,
692 ao_cec->base + CEC_GEN_CNTL_REG);
693
694 cec_register_cec_notifier(ao_cec->adap, ao_cec->notify);
695
696 return 0;
697
698out_probe_clk:
699 clk_disable_unprepare(ao_cec->core);
700
701out_probe_adapter:
702 cec_delete_adapter(ao_cec->adap);
703
704out_probe_notify:
705 cec_notifier_put(ao_cec->notify);
706
707 dev_err(&pdev->dev, "CEC controller registration failed\n");
708
709 return ret;
710}
711
712static int meson_ao_cec_remove(struct platform_device *pdev)
713{
714 struct meson_ao_cec_device *ao_cec = platform_get_drvdata(pdev);
715
716 clk_disable_unprepare(ao_cec->core);
717
718 cec_unregister_adapter(ao_cec->adap);
719
720 cec_notifier_put(ao_cec->notify);
721
722 return 0;
723}
724
725static const struct of_device_id meson_ao_cec_of_match[] = {
726 { .compatible = "amlogic,meson-gx-ao-cec", },
727 { /* sentinel */ }
728};
729MODULE_DEVICE_TABLE(of, meson_ao_cec_of_match);
730
731static struct platform_driver meson_ao_cec_driver = {
732 .probe = meson_ao_cec_probe,
733 .remove = meson_ao_cec_remove,
734 .driver = {
735 .name = "meson-ao-cec",
736 .of_match_table = of_match_ptr(meson_ao_cec_of_match),
737 },
738};
739
740module_platform_driver(meson_ao_cec_driver);
741
742MODULE_DESCRIPTION("Meson AO CEC Controller driver");
743MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
744MODULE_LICENSE("GPL");
diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
index 451a54039e65..226f90886484 100644
--- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
+++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
@@ -756,7 +756,7 @@ static void mtk_jpeg_stop_streaming(struct vb2_queue *q)
756 pm_runtime_put_sync(ctx->jpeg->dev); 756 pm_runtime_put_sync(ctx->jpeg->dev);
757} 757}
758 758
759static struct vb2_ops mtk_jpeg_qops = { 759static const struct vb2_ops mtk_jpeg_qops = {
760 .queue_setup = mtk_jpeg_queue_setup, 760 .queue_setup = mtk_jpeg_queue_setup,
761 .buf_prepare = mtk_jpeg_buf_prepare, 761 .buf_prepare = mtk_jpeg_buf_prepare,
762 .buf_queue = mtk_jpeg_buf_queue, 762 .buf_queue = mtk_jpeg_buf_queue,
@@ -865,7 +865,7 @@ static void mtk_jpeg_job_abort(void *priv)
865{ 865{
866} 866}
867 867
868static struct v4l2_m2m_ops mtk_jpeg_m2m_ops = { 868static const struct v4l2_m2m_ops mtk_jpeg_m2m_ops = {
869 .device_run = mtk_jpeg_device_run, 869 .device_run = mtk_jpeg_device_run,
870 .job_ready = mtk_jpeg_job_ready, 870 .job_ready = mtk_jpeg_job_ready,
871 .job_abort = mtk_jpeg_job_abort, 871 .job_abort = mtk_jpeg_job_abort,
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
index aa8f9fd1f1a2..03aba03a24c8 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
@@ -75,7 +75,7 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp)
75 } 75 }
76 76
77 for (i = 0; i < ARRAY_SIZE(comp->clk); i++) { 77 for (i = 0; i < ARRAY_SIZE(comp->clk); i++) {
78 if (!comp->clk[i]) 78 if (IS_ERR(comp->clk[i]))
79 continue; 79 continue;
80 err = clk_prepare_enable(comp->clk[i]); 80 err = clk_prepare_enable(comp->clk[i]);
81 if (err) 81 if (err)
@@ -90,7 +90,7 @@ void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp)
90 int i; 90 int i;
91 91
92 for (i = 0; i < ARRAY_SIZE(comp->clk); i++) { 92 for (i = 0; i < ARRAY_SIZE(comp->clk); i++) {
93 if (!comp->clk[i]) 93 if (IS_ERR(comp->clk[i]))
94 continue; 94 continue;
95 clk_disable_unprepare(comp->clk[i]); 95 clk_disable_unprepare(comp->clk[i]);
96 } 96 }
@@ -134,15 +134,13 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node,
134 larb_node = of_parse_phandle(node, "mediatek,larb", 0); 134 larb_node = of_parse_phandle(node, "mediatek,larb", 0);
135 if (!larb_node) { 135 if (!larb_node) {
136 dev_err(dev, 136 dev_err(dev,
137 "Missing mediadek,larb phandle in %s node\n", 137 "Missing mediadek,larb phandle in %pOF node\n", node);
138 node->full_name);
139 return -EINVAL; 138 return -EINVAL;
140 } 139 }
141 140
142 larb_pdev = of_find_device_by_node(larb_node); 141 larb_pdev = of_find_device_by_node(larb_node);
143 if (!larb_pdev) { 142 if (!larb_pdev) {
144 dev_warn(dev, "Waiting for larb device %s\n", 143 dev_warn(dev, "Waiting for larb device %pOF\n", larb_node);
145 larb_node->full_name);
146 of_node_put(larb_node); 144 of_node_put(larb_node);
147 return -EPROBE_DEFER; 145 return -EPROBE_DEFER;
148 } 146 }
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
index 81347558b24a..bbb24fb95b95 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c
@@ -137,16 +137,16 @@ static int mtk_mdp_probe(struct platform_device *pdev)
137 continue; 137 continue;
138 138
139 if (!of_device_is_available(node)) { 139 if (!of_device_is_available(node)) {
140 dev_err(dev, "Skipping disabled component %s\n", 140 dev_err(dev, "Skipping disabled component %pOF\n",
141 node->full_name); 141 node);
142 continue; 142 continue;
143 } 143 }
144 144
145 comp_type = (enum mtk_mdp_comp_type)of_id->data; 145 comp_type = (enum mtk_mdp_comp_type)of_id->data;
146 comp_id = mtk_mdp_comp_get_id(dev, node, comp_type); 146 comp_id = mtk_mdp_comp_get_id(dev, node, comp_type);
147 if (comp_id < 0) { 147 if (comp_id < 0) {
148 dev_warn(dev, "Skipping unknown component %s\n", 148 dev_warn(dev, "Skipping unknown component %pOF\n",
149 node->full_name); 149 node);
150 continue; 150 continue;
151 } 151 }
152 152
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
index 13afe48b9dc5..583d47724ee8 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
@@ -621,7 +621,7 @@ static void mtk_mdp_m2m_buf_queue(struct vb2_buffer *vb)
621 v4l2_m2m_buf_queue(ctx->m2m_ctx, to_vb2_v4l2_buffer(vb)); 621 v4l2_m2m_buf_queue(ctx->m2m_ctx, to_vb2_v4l2_buffer(vb));
622} 622}
623 623
624static struct vb2_ops mtk_mdp_m2m_qops = { 624static const struct vb2_ops mtk_mdp_m2m_qops = {
625 .queue_setup = mtk_mdp_m2m_queue_setup, 625 .queue_setup = mtk_mdp_m2m_queue_setup,
626 .buf_prepare = mtk_mdp_m2m_buf_prepare, 626 .buf_prepare = mtk_mdp_m2m_buf_prepare,
627 .buf_queue = mtk_mdp_m2m_buf_queue, 627 .buf_queue = mtk_mdp_m2m_buf_queue,
@@ -1225,7 +1225,7 @@ static const struct v4l2_file_operations mtk_mdp_m2m_fops = {
1225 .mmap = v4l2_m2m_fop_mmap, 1225 .mmap = v4l2_m2m_fop_mmap,
1226}; 1226};
1227 1227
1228static struct v4l2_m2m_ops mtk_mdp_m2m_ops = { 1228static const struct v4l2_m2m_ops mtk_mdp_m2m_ops = {
1229 .device_run = mtk_mdp_m2m_device_run, 1229 .device_run = mtk_mdp_m2m_device_run,
1230 .job_abort = mtk_mdp_m2m_job_abort, 1230 .job_abort = mtk_mdp_m2m_job_abort,
1231}; 1231};
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
index 1daee1207469..bc8349bc2e80 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
@@ -31,6 +31,7 @@
31#define MAX_NUM_REF_FRAMES 8 31#define MAX_NUM_REF_FRAMES 8
32#define VP9_MAX_FRM_BUF_NUM 9 32#define VP9_MAX_FRM_BUF_NUM 9
33#define VP9_MAX_FRM_BUF_NODE_NUM (VP9_MAX_FRM_BUF_NUM * 2) 33#define VP9_MAX_FRM_BUF_NODE_NUM (VP9_MAX_FRM_BUF_NUM * 2)
34#define VP9_SEG_ID_SZ 0x12000
34 35
35/** 36/**
36 * struct vp9_dram_buf - contains buffer info for vpu 37 * struct vp9_dram_buf - contains buffer info for vpu
@@ -132,6 +133,7 @@ struct vp9_sf_ref_fb {
132 * @frm_num : decoded frame number, include sub-frame count (AP-R, VPU-W) 133 * @frm_num : decoded frame number, include sub-frame count (AP-R, VPU-W)
133 * @mv_buf : motion vector working buffer (AP-W, VPU-R) 134 * @mv_buf : motion vector working buffer (AP-W, VPU-R)
134 * @frm_refs : maintain three reference buffer info (AP-R/W, VPU-R/W) 135 * @frm_refs : maintain three reference buffer info (AP-R/W, VPU-R/W)
136 * @seg_id_buf : segmentation map working buffer (AP-W, VPU-R)
135 */ 137 */
136struct vdec_vp9_vsi { 138struct vdec_vp9_vsi {
137 unsigned char sf_bs_buf[VP9_SUPER_FRAME_BS_SZ]; 139 unsigned char sf_bs_buf[VP9_SUPER_FRAME_BS_SZ];
@@ -167,11 +169,14 @@ struct vdec_vp9_vsi {
167 struct vp9_dram_buf mv_buf; 169 struct vp9_dram_buf mv_buf;
168 170
169 struct vp9_ref_buf frm_refs[REFS_PER_FRAME]; 171 struct vp9_ref_buf frm_refs[REFS_PER_FRAME];
172 struct vp9_dram_buf seg_id_buf;
173
170}; 174};
171 175
172/* 176/*
173 * struct vdec_vp9_inst - vp9 decode instance 177 * struct vdec_vp9_inst - vp9 decode instance
174 * @mv_buf : working buffer for mv 178 * @mv_buf : working buffer for mv
179 * @seg_id_buf : working buffer for segmentation map
175 * @dec_fb : vdec_fb node to link fb to different fb_xxx_list 180 * @dec_fb : vdec_fb node to link fb to different fb_xxx_list
176 * @available_fb_node_list : current available vdec_fb node 181 * @available_fb_node_list : current available vdec_fb node
177 * @fb_use_list : current used or referenced vdec_fb 182 * @fb_use_list : current used or referenced vdec_fb
@@ -187,6 +192,7 @@ struct vdec_vp9_vsi {
187 */ 192 */
188struct vdec_vp9_inst { 193struct vdec_vp9_inst {
189 struct mtk_vcodec_mem mv_buf; 194 struct mtk_vcodec_mem mv_buf;
195 struct mtk_vcodec_mem seg_id_buf;
190 196
191 struct vdec_fb_node dec_fb[VP9_MAX_FRM_BUF_NODE_NUM]; 197 struct vdec_fb_node dec_fb[VP9_MAX_FRM_BUF_NODE_NUM];
192 struct list_head available_fb_node_list; 198 struct list_head available_fb_node_list;
@@ -388,13 +394,11 @@ static bool vp9_alloc_work_buf(struct vdec_vp9_inst *inst)
388 vsi->buf_h); 394 vsi->buf_h);
389 395
390 mem = &inst->mv_buf; 396 mem = &inst->mv_buf;
391
392 if (mem->va) 397 if (mem->va)
393 mtk_vcodec_mem_free(inst->ctx, mem); 398 mtk_vcodec_mem_free(inst->ctx, mem);
394 399
395 mem->size = ((vsi->buf_w / 64) * 400 mem->size = ((vsi->buf_w / 64) *
396 (vsi->buf_h / 64) + 2) * 36 * 16; 401 (vsi->buf_h / 64) + 2) * 36 * 16;
397
398 result = mtk_vcodec_mem_alloc(inst->ctx, mem); 402 result = mtk_vcodec_mem_alloc(inst->ctx, mem);
399 if (result) { 403 if (result) {
400 mem->size = 0; 404 mem->size = 0;
@@ -406,6 +410,24 @@ static bool vp9_alloc_work_buf(struct vdec_vp9_inst *inst)
406 vsi->mv_buf.pa = (unsigned long)mem->dma_addr; 410 vsi->mv_buf.pa = (unsigned long)mem->dma_addr;
407 vsi->mv_buf.sz = (unsigned int)mem->size; 411 vsi->mv_buf.sz = (unsigned int)mem->size;
408 412
413
414 mem = &inst->seg_id_buf;
415 if (mem->va)
416 mtk_vcodec_mem_free(inst->ctx, mem);
417
418 mem->size = VP9_SEG_ID_SZ;
419 result = mtk_vcodec_mem_alloc(inst->ctx, mem);
420 if (result) {
421 mem->size = 0;
422 mtk_vcodec_err(inst, "Cannot allocate seg_id_buf");
423 return false;
424 }
425 /* Set the va again */
426 vsi->seg_id_buf.va = (unsigned long)mem->va;
427 vsi->seg_id_buf.pa = (unsigned long)mem->dma_addr;
428 vsi->seg_id_buf.sz = (unsigned int)mem->size;
429
430
409 vp9_free_all_sf_ref_fb(inst); 431 vp9_free_all_sf_ref_fb(inst);
410 vsi->sf_next_ref_fb_idx = vp9_get_sf_ref_fb(inst); 432 vsi->sf_next_ref_fb_idx = vp9_get_sf_ref_fb(inst);
411 433
@@ -653,6 +675,12 @@ static void vp9_reset(struct vdec_vp9_inst *inst)
653 inst->vsi->mv_buf.va = (unsigned long)inst->mv_buf.va; 675 inst->vsi->mv_buf.va = (unsigned long)inst->mv_buf.va;
654 inst->vsi->mv_buf.pa = (unsigned long)inst->mv_buf.dma_addr; 676 inst->vsi->mv_buf.pa = (unsigned long)inst->mv_buf.dma_addr;
655 inst->vsi->mv_buf.sz = (unsigned long)inst->mv_buf.size; 677 inst->vsi->mv_buf.sz = (unsigned long)inst->mv_buf.size;
678
679 /* Set the va again, since vpu_dec_reset will clear seg_id_buf in vpu */
680 inst->vsi->seg_id_buf.va = (unsigned long)inst->seg_id_buf.va;
681 inst->vsi->seg_id_buf.pa = (unsigned long)inst->seg_id_buf.dma_addr;
682 inst->vsi->seg_id_buf.sz = (unsigned long)inst->seg_id_buf.size;
683
656} 684}
657 685
658static void init_all_fb_lists(struct vdec_vp9_inst *inst) 686static void init_all_fb_lists(struct vdec_vp9_inst *inst)
@@ -752,6 +780,10 @@ static void vdec_vp9_deinit(unsigned long h_vdec)
752 if (mem->va) 780 if (mem->va)
753 mtk_vcodec_mem_free(inst->ctx, mem); 781 mtk_vcodec_mem_free(inst->ctx, mem);
754 782
783 mem = &inst->seg_id_buf;
784 if (mem->va)
785 mtk_vcodec_mem_free(inst->ctx, mem);
786
755 vp9_free_all_sf_ref_fb(inst); 787 vp9_free_all_sf_ref_fb(inst);
756 vp9_free_inst(inst); 788 vp9_free_inst(inst);
757} 789}
@@ -848,6 +880,7 @@ static int vdec_vp9_decode(unsigned long h_vdec, struct mtk_vcodec_mem *bs,
848 vsi->sf_frm_sz[idx]); 880 vsi->sf_frm_sz[idx]);
849 } 881 }
850 } 882 }
883 memset(inst->seg_id_buf.va, 0, inst->seg_id_buf.size);
851 ret = vpu_dec_start(&inst->vpu, data, 3); 884 ret = vpu_dec_start(&inst->vpu, data, 3);
852 if (ret) { 885 if (ret) {
853 mtk_vcodec_err(inst, "vpu_dec_start failed"); 886 mtk_vcodec_err(inst, "vpu_dec_start failed");
diff --git a/drivers/media/platform/mx2_emmaprp.c b/drivers/media/platform/mx2_emmaprp.c
index 03e47e0f778d..4a2b1afa19c4 100644
--- a/drivers/media/platform/mx2_emmaprp.c
+++ b/drivers/media/platform/mx2_emmaprp.c
@@ -873,7 +873,7 @@ static const struct v4l2_file_operations emmaprp_fops = {
873 .mmap = emmaprp_mmap, 873 .mmap = emmaprp_mmap,
874}; 874};
875 875
876static struct video_device emmaprp_videodev = { 876static const struct video_device emmaprp_videodev = {
877 .name = MEM2MEM_NAME, 877 .name = MEM2MEM_NAME,
878 .fops = &emmaprp_fops, 878 .fops = &emmaprp_fops,
879 .ioctl_ops = &emmaprp_ioctl_ops, 879 .ioctl_ops = &emmaprp_ioctl_ops,
@@ -882,7 +882,7 @@ static struct video_device emmaprp_videodev = {
882 .vfl_dir = VFL_DIR_M2M, 882 .vfl_dir = VFL_DIR_M2M,
883}; 883};
884 884
885static struct v4l2_m2m_ops m2m_ops = { 885static const struct v4l2_m2m_ops m2m_ops = {
886 .device_run = emmaprp_device_run, 886 .device_run = emmaprp_device_run,
887 .job_abort = emmaprp_job_abort, 887 .job_abort = emmaprp_job_abort,
888 .lock = emmaprp_lock, 888 .lock = emmaprp_lock,
@@ -942,6 +942,8 @@ static int emmaprp_probe(struct platform_device *pdev)
942 platform_set_drvdata(pdev, pcdev); 942 platform_set_drvdata(pdev, pcdev);
943 943
944 irq = platform_get_irq(pdev, 0); 944 irq = platform_get_irq(pdev, 0);
945 if (irq < 0)
946 return irq;
945 ret = devm_request_irq(&pdev->dev, irq, emmaprp_irq, 0, 947 ret = devm_request_irq(&pdev->dev, irq, emmaprp_irq, 0,
946 dev_name(&pdev->dev), pcdev); 948 dev_name(&pdev->dev), pcdev);
947 if (ret) 949 if (ret)
diff --git a/drivers/media/platform/omap/omap_vout_vrfb.c b/drivers/media/platform/omap/omap_vout_vrfb.c
index 45a553d4f5b2..123c2b26a933 100644
--- a/drivers/media/platform/omap/omap_vout_vrfb.c
+++ b/drivers/media/platform/omap/omap_vout_vrfb.c
@@ -12,6 +12,7 @@
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/videodev2.h> 14#include <linux/videodev2.h>
15#include <linux/slab.h>
15 16
16#include <media/videobuf-dma-contig.h> 17#include <media/videobuf-dma-contig.h>
17#include <media/v4l2-device.h> 18#include <media/v4l2-device.h>
@@ -233,7 +234,7 @@ int omap_vout_prepare_vrfb(struct omap_vout_device *vout,
233 struct videobuf_buffer *vb) 234 struct videobuf_buffer *vb)
234{ 235{
235 struct dma_async_tx_descriptor *tx; 236 struct dma_async_tx_descriptor *tx;
236 enum dma_ctrl_flags flags; 237 enum dma_ctrl_flags flags = DMA_PREP_INTERRUPT | DMA_CTRL_ACK;
237 struct dma_chan *chan = vout->vrfb_dma_tx.chan; 238 struct dma_chan *chan = vout->vrfb_dma_tx.chan;
238 struct dma_device *dmadev = chan->device; 239 struct dma_device *dmadev = chan->device;
239 struct dma_interleaved_template *xt = vout->vrfb_dma_tx.xt; 240 struct dma_interleaved_template *xt = vout->vrfb_dma_tx.xt;
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 9df64c189883..1a428fe9f070 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -1859,6 +1859,7 @@ static void isp_cleanup_modules(struct isp_device *isp)
1859 omap3isp_ccdc_cleanup(isp); 1859 omap3isp_ccdc_cleanup(isp);
1860 omap3isp_ccp2_cleanup(isp); 1860 omap3isp_ccp2_cleanup(isp);
1861 omap3isp_csi2_cleanup(isp); 1861 omap3isp_csi2_cleanup(isp);
1862 omap3isp_csiphy_cleanup(isp);
1862} 1863}
1863 1864
1864static int isp_initialize_modules(struct isp_device *isp) 1865static int isp_initialize_modules(struct isp_device *isp)
@@ -1868,7 +1869,7 @@ static int isp_initialize_modules(struct isp_device *isp)
1868 ret = omap3isp_csiphy_init(isp); 1869 ret = omap3isp_csiphy_init(isp);
1869 if (ret < 0) { 1870 if (ret < 0) {
1870 dev_err(isp->dev, "CSI PHY initialization failed\n"); 1871 dev_err(isp->dev, "CSI PHY initialization failed\n");
1871 goto error_csiphy; 1872 return ret;
1872 } 1873 }
1873 1874
1874 ret = omap3isp_csi2_init(isp); 1875 ret = omap3isp_csi2_init(isp);
@@ -1879,7 +1880,8 @@ static int isp_initialize_modules(struct isp_device *isp)
1879 1880
1880 ret = omap3isp_ccp2_init(isp); 1881 ret = omap3isp_ccp2_init(isp);
1881 if (ret < 0) { 1882 if (ret < 0) {
1882 dev_err(isp->dev, "CCP2 initialization failed\n"); 1883 if (ret != -EPROBE_DEFER)
1884 dev_err(isp->dev, "CCP2 initialization failed\n");
1883 goto error_ccp2; 1885 goto error_ccp2;
1884 } 1886 }
1885 1887
@@ -1936,7 +1938,8 @@ error_ccdc:
1936error_ccp2: 1938error_ccp2:
1937 omap3isp_csi2_cleanup(isp); 1939 omap3isp_csi2_cleanup(isp);
1938error_csi2: 1940error_csi2:
1939error_csiphy: 1941 omap3isp_csiphy_cleanup(isp);
1942
1940 return ret; 1943 return ret;
1941} 1944}
1942 1945
@@ -2015,13 +2018,14 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwnode,
2015 struct v4l2_fwnode_endpoint vep; 2018 struct v4l2_fwnode_endpoint vep;
2016 unsigned int i; 2019 unsigned int i;
2017 int ret; 2020 int ret;
2021 bool csi1 = false;
2018 2022
2019 ret = v4l2_fwnode_endpoint_parse(fwnode, &vep); 2023 ret = v4l2_fwnode_endpoint_parse(fwnode, &vep);
2020 if (ret) 2024 if (ret)
2021 return ret; 2025 return ret;
2022 2026
2023 dev_dbg(dev, "parsing endpoint %s, interface %u\n", 2027 dev_dbg(dev, "parsing endpoint %pOF, interface %u\n",
2024 to_of_node(fwnode)->full_name, vep.base.port); 2028 to_of_node(fwnode), vep.base.port);
2025 2029
2026 switch (vep.base.port) { 2030 switch (vep.base.port) {
2027 case ISP_OF_PHY_PARALLEL: 2031 case ISP_OF_PHY_PARALLEL:
@@ -2039,48 +2043,102 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwnode,
2039 !!(vep.bus.parallel.flags & V4L2_MBUS_FIELD_EVEN_LOW); 2043 !!(vep.bus.parallel.flags & V4L2_MBUS_FIELD_EVEN_LOW);
2040 buscfg->bus.parallel.data_pol = 2044 buscfg->bus.parallel.data_pol =
2041 !!(vep.bus.parallel.flags & V4L2_MBUS_DATA_ACTIVE_LOW); 2045 !!(vep.bus.parallel.flags & V4L2_MBUS_DATA_ACTIVE_LOW);
2046 buscfg->bus.parallel.bt656 = vep.bus_type == V4L2_MBUS_BT656;
2042 break; 2047 break;
2043 2048
2044 case ISP_OF_PHY_CSIPHY1: 2049 case ISP_OF_PHY_CSIPHY1:
2045 case ISP_OF_PHY_CSIPHY2: 2050 case ISP_OF_PHY_CSIPHY2:
2046 /* FIXME: always assume CSI-2 for now. */ 2051 switch (vep.bus_type) {
2052 case V4L2_MBUS_CCP2:
2053 case V4L2_MBUS_CSI1:
2054 dev_dbg(dev, "CSI-1/CCP-2 configuration\n");
2055 csi1 = true;
2056 break;
2057 case V4L2_MBUS_CSI2:
2058 dev_dbg(dev, "CSI-2 configuration\n");
2059 csi1 = false;
2060 break;
2061 default:
2062 dev_err(dev, "unsupported bus type %u\n",
2063 vep.bus_type);
2064 return -EINVAL;
2065 }
2066
2047 switch (vep.base.port) { 2067 switch (vep.base.port) {
2048 case ISP_OF_PHY_CSIPHY1: 2068 case ISP_OF_PHY_CSIPHY1:
2049 buscfg->interface = ISP_INTERFACE_CSI2C_PHY1; 2069 if (csi1)
2070 buscfg->interface = ISP_INTERFACE_CCP2B_PHY1;
2071 else
2072 buscfg->interface = ISP_INTERFACE_CSI2C_PHY1;
2050 break; 2073 break;
2051 case ISP_OF_PHY_CSIPHY2: 2074 case ISP_OF_PHY_CSIPHY2:
2052 buscfg->interface = ISP_INTERFACE_CSI2A_PHY2; 2075 if (csi1)
2076 buscfg->interface = ISP_INTERFACE_CCP2B_PHY2;
2077 else
2078 buscfg->interface = ISP_INTERFACE_CSI2A_PHY2;
2053 break; 2079 break;
2054 } 2080 }
2055 buscfg->bus.csi2.lanecfg.clk.pos = vep.bus.mipi_csi2.clock_lane; 2081 if (csi1) {
2056 buscfg->bus.csi2.lanecfg.clk.pol = 2082 buscfg->bus.ccp2.lanecfg.clk.pos =
2057 vep.bus.mipi_csi2.lane_polarities[0]; 2083 vep.bus.mipi_csi1.clock_lane;
2058 dev_dbg(dev, "clock lane polarity %u, pos %u\n", 2084 buscfg->bus.ccp2.lanecfg.clk.pol =
2059 buscfg->bus.csi2.lanecfg.clk.pol, 2085 vep.bus.mipi_csi1.lane_polarity[0];
2060 buscfg->bus.csi2.lanecfg.clk.pos); 2086 dev_dbg(dev, "clock lane polarity %u, pos %u\n",
2061 2087 buscfg->bus.ccp2.lanecfg.clk.pol,
2062 for (i = 0; i < ISP_CSIPHY2_NUM_DATA_LANES; i++) { 2088 buscfg->bus.ccp2.lanecfg.clk.pos);
2063 buscfg->bus.csi2.lanecfg.data[i].pos = 2089
2064 vep.bus.mipi_csi2.data_lanes[i]; 2090 buscfg->bus.ccp2.lanecfg.data[0].pos =
2065 buscfg->bus.csi2.lanecfg.data[i].pol = 2091 vep.bus.mipi_csi1.data_lane;
2066 vep.bus.mipi_csi2.lane_polarities[i + 1]; 2092 buscfg->bus.ccp2.lanecfg.data[0].pol =
2067 dev_dbg(dev, "data lane %u polarity %u, pos %u\n", i, 2093 vep.bus.mipi_csi1.lane_polarity[1];
2068 buscfg->bus.csi2.lanecfg.data[i].pol, 2094
2069 buscfg->bus.csi2.lanecfg.data[i].pos); 2095 dev_dbg(dev, "data lane polarity %u, pos %u\n",
2096 buscfg->bus.ccp2.lanecfg.data[0].pol,
2097 buscfg->bus.ccp2.lanecfg.data[0].pos);
2098
2099 buscfg->bus.ccp2.strobe_clk_pol =
2100 vep.bus.mipi_csi1.clock_inv;
2101 buscfg->bus.ccp2.phy_layer = vep.bus.mipi_csi1.strobe;
2102 buscfg->bus.ccp2.ccp2_mode =
2103 vep.bus_type == V4L2_MBUS_CCP2;
2104 buscfg->bus.ccp2.vp_clk_pol = 1;
2105
2106 buscfg->bus.ccp2.crc = 1;
2107 } else {
2108 buscfg->bus.csi2.lanecfg.clk.pos =
2109 vep.bus.mipi_csi2.clock_lane;
2110 buscfg->bus.csi2.lanecfg.clk.pol =
2111 vep.bus.mipi_csi2.lane_polarities[0];
2112 dev_dbg(dev, "clock lane polarity %u, pos %u\n",
2113 buscfg->bus.csi2.lanecfg.clk.pol,
2114 buscfg->bus.csi2.lanecfg.clk.pos);
2115
2116 buscfg->bus.csi2.num_data_lanes =
2117 vep.bus.mipi_csi2.num_data_lanes;
2118
2119 for (i = 0; i < buscfg->bus.csi2.num_data_lanes; i++) {
2120 buscfg->bus.csi2.lanecfg.data[i].pos =
2121 vep.bus.mipi_csi2.data_lanes[i];
2122 buscfg->bus.csi2.lanecfg.data[i].pol =
2123 vep.bus.mipi_csi2.lane_polarities[i + 1];
2124 dev_dbg(dev,
2125 "data lane %u polarity %u, pos %u\n", i,
2126 buscfg->bus.csi2.lanecfg.data[i].pol,
2127 buscfg->bus.csi2.lanecfg.data[i].pos);
2128 }
2129 /*
2130 * FIXME: now we assume the CRC is always there.
2131 * Implement a way to obtain this information from the
2132 * sensor. Frame descriptors, perhaps?
2133 */
2134 buscfg->bus.csi2.crc = 1;
2070 } 2135 }
2071
2072 /*
2073 * FIXME: now we assume the CRC is always there.
2074 * Implement a way to obtain this information from the
2075 * sensor. Frame descriptors, perhaps?
2076 */
2077 buscfg->bus.csi2.crc = 1;
2078 break; 2136 break;
2079 2137
2080 default: 2138 default:
2081 dev_warn(dev, "%s: invalid interface %u\n", 2139 dev_warn(dev, "%pOF: invalid interface %u\n",
2082 to_of_node(fwnode)->full_name, vep.base.port); 2140 to_of_node(fwnode), vep.base.port);
2083 break; 2141 return -EINVAL;
2084 } 2142 }
2085 2143
2086 return 0; 2144 return 0;
@@ -2105,10 +2163,12 @@ static int isp_fwnodes_parse(struct device *dev,
2105 if (!isd) 2163 if (!isd)
2106 goto error; 2164 goto error;
2107 2165
2108 notifier->subdevs[notifier->num_subdevs] = &isd->asd; 2166 if (isp_fwnode_parse(dev, fwnode, isd)) {
2167 devm_kfree(dev, isd);
2168 continue;
2169 }
2109 2170
2110 if (isp_fwnode_parse(dev, fwnode, isd)) 2171 notifier->subdevs[notifier->num_subdevs] = &isd->asd;
2111 goto error;
2112 2172
2113 isd->asd.match.fwnode.fwnode = 2173 isd->asd.match.fwnode.fwnode =
2114 fwnode_graph_get_remote_port_parent(fwnode); 2174 fwnode_graph_get_remote_port_parent(fwnode);
@@ -2128,26 +2188,12 @@ error:
2128 return -EINVAL; 2188 return -EINVAL;
2129} 2189}
2130 2190
2131static int isp_subdev_notifier_bound(struct v4l2_async_notifier *async,
2132 struct v4l2_subdev *subdev,
2133 struct v4l2_async_subdev *asd)
2134{
2135 struct isp_async_subdev *isd =
2136 container_of(asd, struct isp_async_subdev, asd);
2137
2138 isd->sd = subdev;
2139 isd->sd->host_priv = &isd->bus;
2140
2141 return 0;
2142}
2143
2144static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async) 2191static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)
2145{ 2192{
2146 struct isp_device *isp = container_of(async, struct isp_device, 2193 struct isp_device *isp = container_of(async, struct isp_device,
2147 notifier); 2194 notifier);
2148 struct v4l2_device *v4l2_dev = &isp->v4l2_dev; 2195 struct v4l2_device *v4l2_dev = &isp->v4l2_dev;
2149 struct v4l2_subdev *sd; 2196 struct v4l2_subdev *sd;
2150 struct isp_bus_cfg *bus;
2151 int ret; 2197 int ret;
2152 2198
2153 ret = media_entity_enum_init(&isp->crashed, &isp->media_dev); 2199 ret = media_entity_enum_init(&isp->crashed, &isp->media_dev);
@@ -2155,13 +2201,13 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)
2155 return ret; 2201 return ret;
2156 2202
2157 list_for_each_entry(sd, &v4l2_dev->subdevs, list) { 2203 list_for_each_entry(sd, &v4l2_dev->subdevs, list) {
2158 /* Only try to link entities whose interface was set on bound */ 2204 if (!sd->asd)
2159 if (sd->host_priv) { 2205 continue;
2160 bus = (struct isp_bus_cfg *)sd->host_priv; 2206
2161 ret = isp_link_entity(isp, &sd->entity, bus->interface); 2207 ret = isp_link_entity(isp, &sd->entity,
2162 if (ret < 0) 2208 v4l2_subdev_to_bus_cfg(sd)->interface);
2163 return ret; 2209 if (ret < 0)
2164 } 2210 return ret;
2165 } 2211 }
2166 2212
2167 ret = v4l2_device_register_subdev_nodes(&isp->v4l2_dev); 2213 ret = v4l2_device_register_subdev_nodes(&isp->v4l2_dev);
@@ -2339,7 +2385,6 @@ static int isp_probe(struct platform_device *pdev)
2339 if (ret < 0) 2385 if (ret < 0)
2340 goto error_register_entities; 2386 goto error_register_entities;
2341 2387
2342 isp->notifier.bound = isp_subdev_notifier_bound;
2343 isp->notifier.complete = isp_subdev_notifier_complete; 2388 isp->notifier.complete = isp_subdev_notifier_complete;
2344 2389
2345 ret = v4l2_async_notifier_register(&isp->v4l2_dev, &isp->notifier); 2390 ret = v4l2_async_notifier_register(&isp->v4l2_dev, &isp->notifier);
diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h
index 2f2ae609c548..e528df6efc09 100644
--- a/drivers/media/platform/omap3isp/isp.h
+++ b/drivers/media/platform/omap3isp/isp.h
@@ -226,11 +226,13 @@ struct isp_device {
226}; 226};
227 227
228struct isp_async_subdev { 228struct isp_async_subdev {
229 struct v4l2_subdev *sd;
230 struct isp_bus_cfg bus; 229 struct isp_bus_cfg bus;
231 struct v4l2_async_subdev asd; 230 struct v4l2_async_subdev asd;
232}; 231};
233 232
233#define v4l2_subdev_to_bus_cfg(sd) \
234 (&container_of((sd)->asd, struct isp_async_subdev, asd)->bus)
235
234#define v4l2_dev_to_isp_device(dev) \ 236#define v4l2_dev_to_isp_device(dev) \
235 container_of(dev, struct isp_device, v4l2_dev) 237 container_of(dev, struct isp_device, v4l2_dev)
236 238
diff --git a/drivers/media/platform/omap3isp/ispccdc.c b/drivers/media/platform/omap3isp/ispccdc.c
index 7207558d722c..b66276ab5765 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -1139,15 +1139,11 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc)
1139 pad = media_entity_remote_pad(&ccdc->pads[CCDC_PAD_SINK]); 1139 pad = media_entity_remote_pad(&ccdc->pads[CCDC_PAD_SINK]);
1140 sensor = media_entity_to_v4l2_subdev(pad->entity); 1140 sensor = media_entity_to_v4l2_subdev(pad->entity);
1141 if (ccdc->input == CCDC_INPUT_PARALLEL) { 1141 if (ccdc->input == CCDC_INPUT_PARALLEL) {
1142 struct v4l2_mbus_config cfg; 1142 struct v4l2_subdev *sd =
1143 int ret; 1143 to_isp_pipeline(&ccdc->subdev.entity)->external;
1144 1144
1145 ret = v4l2_subdev_call(sensor, video, g_mbus_config, &cfg); 1145 parcfg = &v4l2_subdev_to_bus_cfg(sd)->bus.parallel;
1146 if (!ret) 1146 ccdc->bt656 = parcfg->bt656;
1147 ccdc->bt656 = cfg.type == V4L2_MBUS_BT656;
1148
1149 parcfg = &((struct isp_bus_cfg *)sensor->host_priv)
1150 ->bus.parallel;
1151 } 1147 }
1152 1148
1153 /* CCDC_PAD_SINK */ 1149 /* CCDC_PAD_SINK */
@@ -2418,11 +2414,11 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,
2418 2414
2419 /* We've got a parallel sensor here. */ 2415 /* We've got a parallel sensor here. */
2420 if (ccdc->input == CCDC_INPUT_PARALLEL) { 2416 if (ccdc->input == CCDC_INPUT_PARALLEL) {
2421 struct isp_parallel_cfg *parcfg = 2417 struct v4l2_subdev *sd =
2422 &((struct isp_bus_cfg *) 2418 media_entity_to_v4l2_subdev(link->source->entity);
2423 media_entity_to_v4l2_subdev(link->source->entity) 2419 struct isp_bus_cfg *bus_cfg = v4l2_subdev_to_bus_cfg(sd);
2424 ->host_priv)->bus.parallel; 2420
2425 parallel_shift = parcfg->data_lane_shift; 2421 parallel_shift = bus_cfg->bus.parallel.data_lane_shift;
2426 } else { 2422 } else {
2427 parallel_shift = 0; 2423 parallel_shift = 0;
2428 } 2424 }
diff --git a/drivers/media/platform/omap3isp/ispccp2.c b/drivers/media/platform/omap3isp/ispccp2.c
index ca095238510d..e062939d0d05 100644
--- a/drivers/media/platform/omap3isp/ispccp2.c
+++ b/drivers/media/platform/omap3isp/ispccp2.c
@@ -213,14 +213,17 @@ static int ccp2_phyif_config(struct isp_ccp2_device *ccp2,
213 struct isp_device *isp = to_isp_device(ccp2); 213 struct isp_device *isp = to_isp_device(ccp2);
214 u32 val; 214 u32 val;
215 215
216 /* CCP2B mode */
217 val = isp_reg_readl(isp, OMAP3_ISP_IOMEM_CCP2, ISPCCP2_CTRL) | 216 val = isp_reg_readl(isp, OMAP3_ISP_IOMEM_CCP2, ISPCCP2_CTRL) |
218 ISPCCP2_CTRL_IO_OUT_SEL | ISPCCP2_CTRL_MODE; 217 ISPCCP2_CTRL_MODE;
219 /* Data/strobe physical layer */ 218 /* Data/strobe physical layer */
220 BIT_SET(val, ISPCCP2_CTRL_PHY_SEL_SHIFT, ISPCCP2_CTRL_PHY_SEL_MASK, 219 BIT_SET(val, ISPCCP2_CTRL_PHY_SEL_SHIFT, ISPCCP2_CTRL_PHY_SEL_MASK,
221 buscfg->phy_layer); 220 buscfg->phy_layer);
221 BIT_SET(val, ISPCCP2_CTRL_IO_OUT_SEL_SHIFT,
222 ISPCCP2_CTRL_IO_OUT_SEL_MASK, buscfg->ccp2_mode);
222 BIT_SET(val, ISPCCP2_CTRL_INV_SHIFT, ISPCCP2_CTRL_INV_MASK, 223 BIT_SET(val, ISPCCP2_CTRL_INV_SHIFT, ISPCCP2_CTRL_INV_MASK,
223 buscfg->strobe_clk_pol); 224 buscfg->strobe_clk_pol);
225 BIT_SET(val, ISPCCP2_CTRL_VP_CLK_POL_SHIFT,
226 ISPCCP2_CTRL_VP_CLK_POL_MASK, buscfg->vp_clk_pol);
224 isp_reg_writel(isp, val, OMAP3_ISP_IOMEM_CCP2, ISPCCP2_CTRL); 227 isp_reg_writel(isp, val, OMAP3_ISP_IOMEM_CCP2, ISPCCP2_CTRL);
225 228
226 val = isp_reg_readl(isp, OMAP3_ISP_IOMEM_CCP2, ISPCCP2_CTRL); 229 val = isp_reg_readl(isp, OMAP3_ISP_IOMEM_CCP2, ISPCCP2_CTRL);
@@ -347,6 +350,7 @@ static void ccp2_lcx_config(struct isp_ccp2_device *ccp2,
347 */ 350 */
348static int ccp2_if_configure(struct isp_ccp2_device *ccp2) 351static int ccp2_if_configure(struct isp_ccp2_device *ccp2)
349{ 352{
353 struct isp_pipeline *pipe = to_isp_pipeline(&ccp2->subdev.entity);
350 const struct isp_bus_cfg *buscfg; 354 const struct isp_bus_cfg *buscfg;
351 struct v4l2_mbus_framefmt *format; 355 struct v4l2_mbus_framefmt *format;
352 struct media_pad *pad; 356 struct media_pad *pad;
@@ -358,7 +362,7 @@ static int ccp2_if_configure(struct isp_ccp2_device *ccp2)
358 362
359 pad = media_entity_remote_pad(&ccp2->pads[CCP2_PAD_SINK]); 363 pad = media_entity_remote_pad(&ccp2->pads[CCP2_PAD_SINK]);
360 sensor = media_entity_to_v4l2_subdev(pad->entity); 364 sensor = media_entity_to_v4l2_subdev(pad->entity);
361 buscfg = sensor->host_priv; 365 buscfg = v4l2_subdev_to_bus_cfg(pipe->external);
362 366
363 ret = ccp2_phyif_config(ccp2, &buscfg->bus.ccp2); 367 ret = ccp2_phyif_config(ccp2, &buscfg->bus.ccp2);
364 if (ret < 0) 368 if (ret < 0)
@@ -838,7 +842,7 @@ static int ccp2_s_stream(struct v4l2_subdev *sd, int enable)
838 switch (enable) { 842 switch (enable) {
839 case ISP_PIPELINE_STREAM_CONTINUOUS: 843 case ISP_PIPELINE_STREAM_CONTINUOUS:
840 if (ccp2->phy) { 844 if (ccp2->phy) {
841 ret = omap3isp_csiphy_acquire(ccp2->phy); 845 ret = omap3isp_csiphy_acquire(ccp2->phy, &sd->entity);
842 if (ret < 0) 846 if (ret < 0)
843 return ret; 847 return ret;
844 } 848 }
@@ -1137,10 +1141,16 @@ int omap3isp_ccp2_init(struct isp_device *isp)
1137 if (isp->revision == ISP_REVISION_2_0) { 1141 if (isp->revision == ISP_REVISION_2_0) {
1138 ccp2->vdds_csib = devm_regulator_get(isp->dev, "vdds_csib"); 1142 ccp2->vdds_csib = devm_regulator_get(isp->dev, "vdds_csib");
1139 if (IS_ERR(ccp2->vdds_csib)) { 1143 if (IS_ERR(ccp2->vdds_csib)) {
1144 if (PTR_ERR(ccp2->vdds_csib) == -EPROBE_DEFER) {
1145 dev_dbg(isp->dev,
1146 "Can't get regulator vdds_csib, deferring probing\n");
1147 return -EPROBE_DEFER;
1148 }
1140 dev_dbg(isp->dev, 1149 dev_dbg(isp->dev,
1141 "Could not get regulator vdds_csib\n"); 1150 "Could not get regulator vdds_csib\n");
1142 ccp2->vdds_csib = NULL; 1151 ccp2->vdds_csib = NULL;
1143 } 1152 }
1153 ccp2->phy = &isp->isp_csiphy2;
1144 } else if (isp->revision == ISP_REVISION_15_0) { 1154 } else if (isp->revision == ISP_REVISION_15_0) {
1145 ccp2->phy = &isp->isp_csiphy1; 1155 ccp2->phy = &isp->isp_csiphy1;
1146 } 1156 }
diff --git a/drivers/media/platform/omap3isp/ispcsi2.c b/drivers/media/platform/omap3isp/ispcsi2.c
index 7dae2fe0d42d..a4d3d030e81e 100644
--- a/drivers/media/platform/omap3isp/ispcsi2.c
+++ b/drivers/media/platform/omap3isp/ispcsi2.c
@@ -490,7 +490,7 @@ int omap3isp_csi2_reset(struct isp_csi2_device *csi2)
490 if (!csi2->available) 490 if (!csi2->available)
491 return -ENODEV; 491 return -ENODEV;
492 492
493 if (csi2->phy->phy_in_use) 493 if (csi2->phy->entity)
494 return -EBUSY; 494 return -EBUSY;
495 495
496 isp_reg_set(isp, csi2->regs1, ISPCSI2_SYSCONFIG, 496 isp_reg_set(isp, csi2->regs1, ISPCSI2_SYSCONFIG,
@@ -566,7 +566,7 @@ static int csi2_configure(struct isp_csi2_device *csi2)
566 566
567 pad = media_entity_remote_pad(&csi2->pads[CSI2_PAD_SINK]); 567 pad = media_entity_remote_pad(&csi2->pads[CSI2_PAD_SINK]);
568 sensor = media_entity_to_v4l2_subdev(pad->entity); 568 sensor = media_entity_to_v4l2_subdev(pad->entity);
569 buscfg = sensor->host_priv; 569 buscfg = v4l2_subdev_to_bus_cfg(pipe->external);
570 570
571 csi2->frame_skip = 0; 571 csi2->frame_skip = 0;
572 v4l2_subdev_call(sensor, sensor, g_skip_frames, &csi2->frame_skip); 572 v4l2_subdev_call(sensor, sensor, g_skip_frames, &csi2->frame_skip);
@@ -1053,7 +1053,7 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
1053 1053
1054 switch (enable) { 1054 switch (enable) {
1055 case ISP_PIPELINE_STREAM_CONTINUOUS: 1055 case ISP_PIPELINE_STREAM_CONTINUOUS:
1056 if (omap3isp_csiphy_acquire(csi2->phy) < 0) 1056 if (omap3isp_csiphy_acquire(csi2->phy, &sd->entity) < 0)
1057 return -ENODEV; 1057 return -ENODEV;
1058 if (csi2->output & CSI2_OUTPUT_MEMORY) 1058 if (csi2->output & CSI2_OUTPUT_MEMORY)
1059 omap3isp_sbl_enable(isp, OMAP3_ISP_SBL_CSI2A_WRITE); 1059 omap3isp_sbl_enable(isp, OMAP3_ISP_SBL_CSI2A_WRITE);
diff --git a/drivers/media/platform/omap3isp/ispcsiphy.c b/drivers/media/platform/omap3isp/ispcsiphy.c
index 871d4fe09c7f..a28fb79abaac 100644
--- a/drivers/media/platform/omap3isp/ispcsiphy.c
+++ b/drivers/media/platform/omap3isp/ispcsiphy.c
@@ -164,30 +164,28 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power)
164 164
165static int omap3isp_csiphy_config(struct isp_csiphy *phy) 165static int omap3isp_csiphy_config(struct isp_csiphy *phy)
166{ 166{
167 struct isp_csi2_device *csi2 = phy->csi2; 167 struct isp_pipeline *pipe = to_isp_pipeline(phy->entity);
168 struct isp_pipeline *pipe = to_isp_pipeline(&csi2->subdev.entity); 168 struct isp_bus_cfg *buscfg = v4l2_subdev_to_bus_cfg(pipe->external);
169 struct isp_bus_cfg *buscfg = pipe->external->host_priv;
170 struct isp_csiphy_lanes_cfg *lanes; 169 struct isp_csiphy_lanes_cfg *lanes;
171 int csi2_ddrclk_khz; 170 int csi2_ddrclk_khz;
172 unsigned int used_lanes = 0; 171 unsigned int num_data_lanes, used_lanes = 0;
173 unsigned int i; 172 unsigned int i;
174 u32 reg; 173 u32 reg;
175 174
176 if (!buscfg) {
177 struct isp_async_subdev *isd =
178 container_of(pipe->external->asd,
179 struct isp_async_subdev, asd);
180 buscfg = &isd->bus;
181 }
182
183 if (buscfg->interface == ISP_INTERFACE_CCP2B_PHY1 175 if (buscfg->interface == ISP_INTERFACE_CCP2B_PHY1
184 || buscfg->interface == ISP_INTERFACE_CCP2B_PHY2) 176 || buscfg->interface == ISP_INTERFACE_CCP2B_PHY2) {
185 lanes = &buscfg->bus.ccp2.lanecfg; 177 lanes = &buscfg->bus.ccp2.lanecfg;
186 else 178 num_data_lanes = 1;
179 } else {
187 lanes = &buscfg->bus.csi2.lanecfg; 180 lanes = &buscfg->bus.csi2.lanecfg;
181 num_data_lanes = buscfg->bus.csi2.num_data_lanes;
182 }
183
184 if (num_data_lanes > phy->num_data_lanes)
185 return -EINVAL;
188 186
189 /* Clock and data lanes verification */ 187 /* Clock and data lanes verification */
190 for (i = 0; i < phy->num_data_lanes; i++) { 188 for (i = 0; i < num_data_lanes; i++) {
191 if (lanes->data[i].pol > 1 || lanes->data[i].pos > 3) 189 if (lanes->data[i].pol > 1 || lanes->data[i].pos > 3)
192 return -EINVAL; 190 return -EINVAL;
193 191
@@ -216,7 +214,7 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
216 csi2_ddrclk_khz = pipe->external_rate / 1000 214 csi2_ddrclk_khz = pipe->external_rate / 1000
217 / (2 * hweight32(used_lanes)) * pipe->external_width; 215 / (2 * hweight32(used_lanes)) * pipe->external_width;
218 216
219 reg = isp_reg_readl(csi2->isp, phy->phy_regs, ISPCSIPHY_REG0); 217 reg = isp_reg_readl(phy->isp, phy->phy_regs, ISPCSIPHY_REG0);
220 218
221 reg &= ~(ISPCSIPHY_REG0_THS_TERM_MASK | 219 reg &= ~(ISPCSIPHY_REG0_THS_TERM_MASK |
222 ISPCSIPHY_REG0_THS_SETTLE_MASK); 220 ISPCSIPHY_REG0_THS_SETTLE_MASK);
@@ -227,9 +225,9 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
227 reg |= (DIV_ROUND_UP(90 * csi2_ddrclk_khz, 1000000) + 3) 225 reg |= (DIV_ROUND_UP(90 * csi2_ddrclk_khz, 1000000) + 3)
228 << ISPCSIPHY_REG0_THS_SETTLE_SHIFT; 226 << ISPCSIPHY_REG0_THS_SETTLE_SHIFT;
229 227
230 isp_reg_writel(csi2->isp, reg, phy->phy_regs, ISPCSIPHY_REG0); 228 isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG0);
231 229
232 reg = isp_reg_readl(csi2->isp, phy->phy_regs, ISPCSIPHY_REG1); 230 reg = isp_reg_readl(phy->isp, phy->phy_regs, ISPCSIPHY_REG1);
233 231
234 reg &= ~(ISPCSIPHY_REG1_TCLK_TERM_MASK | 232 reg &= ~(ISPCSIPHY_REG1_TCLK_TERM_MASK |
235 ISPCSIPHY_REG1_TCLK_MISS_MASK | 233 ISPCSIPHY_REG1_TCLK_MISS_MASK |
@@ -238,12 +236,12 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
238 reg |= TCLK_MISS << ISPCSIPHY_REG1_TCLK_MISS_SHIFT; 236 reg |= TCLK_MISS << ISPCSIPHY_REG1_TCLK_MISS_SHIFT;
239 reg |= TCLK_SETTLE << ISPCSIPHY_REG1_TCLK_SETTLE_SHIFT; 237 reg |= TCLK_SETTLE << ISPCSIPHY_REG1_TCLK_SETTLE_SHIFT;
240 238
241 isp_reg_writel(csi2->isp, reg, phy->phy_regs, ISPCSIPHY_REG1); 239 isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG1);
242 240
243 /* DPHY lane configuration */ 241 /* DPHY lane configuration */
244 reg = isp_reg_readl(csi2->isp, phy->cfg_regs, ISPCSI2_PHY_CFG); 242 reg = isp_reg_readl(phy->isp, phy->cfg_regs, ISPCSI2_PHY_CFG);
245 243
246 for (i = 0; i < phy->num_data_lanes; i++) { 244 for (i = 0; i < num_data_lanes; i++) {
247 reg &= ~(ISPCSI2_PHY_CFG_DATA_POL_MASK(i + 1) | 245 reg &= ~(ISPCSI2_PHY_CFG_DATA_POL_MASK(i + 1) |
248 ISPCSI2_PHY_CFG_DATA_POSITION_MASK(i + 1)); 246 ISPCSI2_PHY_CFG_DATA_POSITION_MASK(i + 1));
249 reg |= (lanes->data[i].pol << 247 reg |= (lanes->data[i].pol <<
@@ -257,12 +255,12 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
257 reg |= lanes->clk.pol << ISPCSI2_PHY_CFG_CLOCK_POL_SHIFT; 255 reg |= lanes->clk.pol << ISPCSI2_PHY_CFG_CLOCK_POL_SHIFT;
258 reg |= lanes->clk.pos << ISPCSI2_PHY_CFG_CLOCK_POSITION_SHIFT; 256 reg |= lanes->clk.pos << ISPCSI2_PHY_CFG_CLOCK_POSITION_SHIFT;
259 257
260 isp_reg_writel(csi2->isp, reg, phy->cfg_regs, ISPCSI2_PHY_CFG); 258 isp_reg_writel(phy->isp, reg, phy->cfg_regs, ISPCSI2_PHY_CFG);
261 259
262 return 0; 260 return 0;
263} 261}
264 262
265int omap3isp_csiphy_acquire(struct isp_csiphy *phy) 263int omap3isp_csiphy_acquire(struct isp_csiphy *phy, struct media_entity *entity)
266{ 264{
267 int rval; 265 int rval;
268 266
@@ -282,20 +280,25 @@ int omap3isp_csiphy_acquire(struct isp_csiphy *phy)
282 if (rval < 0) 280 if (rval < 0)
283 goto done; 281 goto done;
284 282
283 phy->entity = entity;
284
285 rval = omap3isp_csiphy_config(phy); 285 rval = omap3isp_csiphy_config(phy);
286 if (rval < 0) 286 if (rval < 0)
287 goto done; 287 goto done;
288 288
289 rval = csiphy_set_power(phy, ISPCSI2_PHY_CFG_PWR_CMD_ON); 289 if (phy->isp->revision == ISP_REVISION_15_0) {
290 if (rval) { 290 rval = csiphy_set_power(phy, ISPCSI2_PHY_CFG_PWR_CMD_ON);
291 regulator_disable(phy->vdd); 291 if (rval) {
292 goto done; 292 regulator_disable(phy->vdd);
293 } 293 goto done;
294 294 }
295 csiphy_power_autoswitch_enable(phy, true);
296 phy->phy_in_use = 1;
297 295
296 csiphy_power_autoswitch_enable(phy, true);
297 }
298done: 298done:
299 if (rval < 0)
300 phy->entity = NULL;
301
299 mutex_unlock(&phy->mutex); 302 mutex_unlock(&phy->mutex);
300 return rval; 303 return rval;
301} 304}
@@ -303,18 +306,19 @@ done:
303void omap3isp_csiphy_release(struct isp_csiphy *phy) 306void omap3isp_csiphy_release(struct isp_csiphy *phy)
304{ 307{
305 mutex_lock(&phy->mutex); 308 mutex_lock(&phy->mutex);
306 if (phy->phy_in_use) { 309 if (phy->entity) {
307 struct isp_csi2_device *csi2 = phy->csi2; 310 struct isp_pipeline *pipe = to_isp_pipeline(phy->entity);
308 struct isp_pipeline *pipe = 311 struct isp_bus_cfg *buscfg =
309 to_isp_pipeline(&csi2->subdev.entity); 312 v4l2_subdev_to_bus_cfg(pipe->external);
310 struct isp_bus_cfg *buscfg = pipe->external->host_priv;
311 313
312 csiphy_routing_cfg(phy, buscfg->interface, false, 314 csiphy_routing_cfg(phy, buscfg->interface, false,
313 buscfg->bus.ccp2.phy_layer); 315 buscfg->bus.ccp2.phy_layer);
314 csiphy_power_autoswitch_enable(phy, false); 316 if (phy->isp->revision == ISP_REVISION_15_0) {
315 csiphy_set_power(phy, ISPCSI2_PHY_CFG_PWR_CMD_OFF); 317 csiphy_power_autoswitch_enable(phy, false);
318 csiphy_set_power(phy, ISPCSI2_PHY_CFG_PWR_CMD_OFF);
319 }
316 regulator_disable(phy->vdd); 320 regulator_disable(phy->vdd);
317 phy->phy_in_use = 0; 321 phy->entity = NULL;
318 } 322 }
319 mutex_unlock(&phy->mutex); 323 mutex_unlock(&phy->mutex);
320} 324}
@@ -334,14 +338,21 @@ int omap3isp_csiphy_init(struct isp_device *isp)
334 phy2->phy_regs = OMAP3_ISP_IOMEM_CSIPHY2; 338 phy2->phy_regs = OMAP3_ISP_IOMEM_CSIPHY2;
335 mutex_init(&phy2->mutex); 339 mutex_init(&phy2->mutex);
336 340
341 phy1->isp = isp;
342 mutex_init(&phy1->mutex);
343
337 if (isp->revision == ISP_REVISION_15_0) { 344 if (isp->revision == ISP_REVISION_15_0) {
338 phy1->isp = isp;
339 phy1->csi2 = &isp->isp_csi2c; 345 phy1->csi2 = &isp->isp_csi2c;
340 phy1->num_data_lanes = ISP_CSIPHY1_NUM_DATA_LANES; 346 phy1->num_data_lanes = ISP_CSIPHY1_NUM_DATA_LANES;
341 phy1->cfg_regs = OMAP3_ISP_IOMEM_CSI2C_REGS1; 347 phy1->cfg_regs = OMAP3_ISP_IOMEM_CSI2C_REGS1;
342 phy1->phy_regs = OMAP3_ISP_IOMEM_CSIPHY1; 348 phy1->phy_regs = OMAP3_ISP_IOMEM_CSIPHY1;
343 mutex_init(&phy1->mutex);
344 } 349 }
345 350
346 return 0; 351 return 0;
347} 352}
353
354void omap3isp_csiphy_cleanup(struct isp_device *isp)
355{
356 mutex_destroy(&isp->isp_csiphy1.mutex);
357 mutex_destroy(&isp->isp_csiphy2.mutex);
358}
diff --git a/drivers/media/platform/omap3isp/ispcsiphy.h b/drivers/media/platform/omap3isp/ispcsiphy.h
index 28b63b28f9f7..91543a09b28a 100644
--- a/drivers/media/platform/omap3isp/ispcsiphy.h
+++ b/drivers/media/platform/omap3isp/ispcsiphy.h
@@ -25,9 +25,10 @@ struct regulator;
25struct isp_csiphy { 25struct isp_csiphy {
26 struct isp_device *isp; 26 struct isp_device *isp;
27 struct mutex mutex; /* serialize csiphy configuration */ 27 struct mutex mutex; /* serialize csiphy configuration */
28 u8 phy_in_use;
29 struct isp_csi2_device *csi2; 28 struct isp_csi2_device *csi2;
30 struct regulator *vdd; 29 struct regulator *vdd;
30 /* the entity that acquired the phy */
31 struct media_entity *entity;
31 32
32 /* mem resources - enums as defined in enum isp_mem_resources */ 33 /* mem resources - enums as defined in enum isp_mem_resources */
33 unsigned int cfg_regs; 34 unsigned int cfg_regs;
@@ -36,8 +37,10 @@ struct isp_csiphy {
36 u8 num_data_lanes; /* number of CSI2 Data Lanes supported */ 37 u8 num_data_lanes; /* number of CSI2 Data Lanes supported */
37}; 38};
38 39
39int omap3isp_csiphy_acquire(struct isp_csiphy *phy); 40int omap3isp_csiphy_acquire(struct isp_csiphy *phy,
41 struct media_entity *entity);
40void omap3isp_csiphy_release(struct isp_csiphy *phy); 42void omap3isp_csiphy_release(struct isp_csiphy *phy);
41int omap3isp_csiphy_init(struct isp_device *isp); 43int omap3isp_csiphy_init(struct isp_device *isp);
44void omap3isp_csiphy_cleanup(struct isp_device *isp);
42 45
43#endif /* OMAP3_ISP_CSI_PHY_H */ 46#endif /* OMAP3_ISP_CSI_PHY_H */
diff --git a/drivers/media/platform/omap3isp/ispreg.h b/drivers/media/platform/omap3isp/ispreg.h
index b5ea8da0b904..d08483919a77 100644
--- a/drivers/media/platform/omap3isp/ispreg.h
+++ b/drivers/media/platform/omap3isp/ispreg.h
@@ -87,6 +87,8 @@
87#define ISPCCP2_CTRL_PHY_SEL_MASK 0x1 87#define ISPCCP2_CTRL_PHY_SEL_MASK 0x1
88#define ISPCCP2_CTRL_PHY_SEL_SHIFT 1 88#define ISPCCP2_CTRL_PHY_SEL_SHIFT 1
89#define ISPCCP2_CTRL_IO_OUT_SEL (1 << 2) 89#define ISPCCP2_CTRL_IO_OUT_SEL (1 << 2)
90#define ISPCCP2_CTRL_IO_OUT_SEL_MASK 0x1
91#define ISPCCP2_CTRL_IO_OUT_SEL_SHIFT 2
90#define ISPCCP2_CTRL_MODE (1 << 4) 92#define ISPCCP2_CTRL_MODE (1 << 4)
91#define ISPCCP2_CTRL_VP_CLK_FORCE_ON (1 << 9) 93#define ISPCCP2_CTRL_VP_CLK_FORCE_ON (1 << 9)
92#define ISPCCP2_CTRL_INV (1 << 10) 94#define ISPCCP2_CTRL_INV (1 << 10)
@@ -94,6 +96,8 @@
94#define ISPCCP2_CTRL_INV_SHIFT 10 96#define ISPCCP2_CTRL_INV_SHIFT 10
95#define ISPCCP2_CTRL_VP_ONLY_EN (1 << 11) 97#define ISPCCP2_CTRL_VP_ONLY_EN (1 << 11)
96#define ISPCCP2_CTRL_VP_CLK_POL (1 << 12) 98#define ISPCCP2_CTRL_VP_CLK_POL (1 << 12)
99#define ISPCCP2_CTRL_VP_CLK_POL_MASK 0x1
100#define ISPCCP2_CTRL_VP_CLK_POL_SHIFT 12
97#define ISPCCP2_CTRL_VPCLK_DIV_SHIFT 15 101#define ISPCCP2_CTRL_VPCLK_DIV_SHIFT 15
98#define ISPCCP2_CTRL_VPCLK_DIV_MASK 0x1ffff /* [31:15] */ 102#define ISPCCP2_CTRL_VPCLK_DIV_MASK 0x1ffff /* [31:15] */
99#define ISPCCP2_CTRL_VP_OUT_CTRL_SHIFT 8 /* 3430 bits */ 103#define ISPCCP2_CTRL_VP_OUT_CTRL_SHIFT 8 /* 3430 bits */
diff --git a/drivers/media/platform/omap3isp/omap3isp.h b/drivers/media/platform/omap3isp/omap3isp.h
index 443e8f7673e2..9fb4d5bce004 100644
--- a/drivers/media/platform/omap3isp/omap3isp.h
+++ b/drivers/media/platform/omap3isp/omap3isp.h
@@ -46,6 +46,7 @@ enum isp_interface_type {
46 * 0 - Positive, 1 - Negative 46 * 0 - Positive, 1 - Negative
47 * @data_pol: Data polarity 47 * @data_pol: Data polarity
48 * 0 - Normal, 1 - One's complement 48 * 0 - Normal, 1 - One's complement
49 * @bt656: Data contain BT.656 embedded synchronization
49 */ 50 */
50struct isp_parallel_cfg { 51struct isp_parallel_cfg {
51 unsigned int data_lane_shift:3; 52 unsigned int data_lane_shift:3;
@@ -54,6 +55,7 @@ struct isp_parallel_cfg {
54 unsigned int vs_pol:1; 55 unsigned int vs_pol:1;
55 unsigned int fld_pol:1; 56 unsigned int fld_pol:1;
56 unsigned int data_pol:1; 57 unsigned int data_pol:1;
58 unsigned int bt656:1;
57}; 59};
58 60
59enum { 61enum {
@@ -108,16 +110,20 @@ struct isp_ccp2_cfg {
108 unsigned int ccp2_mode:1; 110 unsigned int ccp2_mode:1;
109 unsigned int phy_layer:1; 111 unsigned int phy_layer:1;
110 unsigned int vpclk_div:2; 112 unsigned int vpclk_div:2;
113 unsigned int vp_clk_pol:1;
111 struct isp_csiphy_lanes_cfg lanecfg; 114 struct isp_csiphy_lanes_cfg lanecfg;
112}; 115};
113 116
114/** 117/**
115 * struct isp_csi2_cfg - CSI2 interface configuration 118 * struct isp_csi2_cfg - CSI2 interface configuration
116 * @crc: Enable the cyclic redundancy check 119 * @crc: Enable the cyclic redundancy check
120 * @lanecfg: CSI-2 lane configuration
121 * @num_data_lanes: The number of data lanes in use
117 */ 122 */
118struct isp_csi2_cfg { 123struct isp_csi2_cfg {
119 unsigned crc:1; 124 unsigned crc:1;
120 struct isp_csiphy_lanes_cfg lanecfg; 125 struct isp_csiphy_lanes_cfg lanecfg;
126 u8 num_data_lanes;
121}; 127};
122 128
123struct isp_bus_cfg { 129struct isp_bus_cfg {
diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c
index 399095170b6e..edca993c2b1f 100644
--- a/drivers/media/platform/pxa_camera.c
+++ b/drivers/media/platform/pxa_camera.c
@@ -638,6 +638,9 @@ static unsigned int pxa_mbus_config_compatible(const struct v4l2_mbus_config *cf
638 mipi_clock = common_flags & (V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK | 638 mipi_clock = common_flags & (V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK |
639 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK); 639 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK);
640 return (!mipi_lanes || !mipi_clock) ? 0 : common_flags; 640 return (!mipi_lanes || !mipi_clock) ? 0 : common_flags;
641 default:
642 WARN_ON(1);
643 return -EINVAL;
641 } 644 }
642 return 0; 645 return 0;
643} 646}
@@ -1557,7 +1560,7 @@ static void pxac_vb2_stop_streaming(struct vb2_queue *vq)
1557 pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_ERROR); 1560 pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_ERROR);
1558} 1561}
1559 1562
1560static struct vb2_ops pxac_vb2_ops = { 1563static const struct vb2_ops pxac_vb2_ops = {
1561 .queue_setup = pxac_vb2_queue_setup, 1564 .queue_setup = pxac_vb2_queue_setup,
1562 .buf_init = pxac_vb2_init, 1565 .buf_init = pxac_vb2_init,
1563 .buf_prepare = pxac_vb2_prepare, 1566 .buf_prepare = pxac_vb2_prepare,
@@ -2097,7 +2100,7 @@ static const struct v4l2_ioctl_ops pxa_camera_ioctl_ops = {
2097 .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 2100 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
2098}; 2101};
2099 2102
2100static struct v4l2_clk_ops pxa_camera_mclk_ops = { 2103static const struct v4l2_clk_ops pxa_camera_mclk_ops = {
2101}; 2104};
2102 2105
2103static const struct video_device pxa_camera_videodev_template = { 2106static const struct video_device pxa_camera_videodev_template = {
@@ -2328,7 +2331,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
2328 asd->match.fwnode.fwnode = of_fwnode_handle(remote); 2331 asd->match.fwnode.fwnode = of_fwnode_handle(remote);
2329 of_node_put(remote); 2332 of_node_put(remote);
2330 } else { 2333 } else {
2331 dev_notice(dev, "no remote for %s\n", of_node_full_name(np)); 2334 dev_notice(dev, "no remote for %pOF\n", np);
2332 } 2335 }
2333 2336
2334out: 2337out:
diff --git a/drivers/media/platform/qcom/camss-8x16/Makefile b/drivers/media/platform/qcom/camss-8x16/Makefile
new file mode 100644
index 000000000000..3c4024fbb768
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/Makefile
@@ -0,0 +1,11 @@
1# Makefile for Qualcomm CAMSS driver
2
3qcom-camss-objs += \
4 camss.o \
5 camss-csid.o \
6 camss-csiphy.o \
7 camss-ispif.o \
8 camss-vfe.o \
9 camss-video.o \
10
11obj-$(CONFIG_VIDEO_QCOM_CAMSS) += qcom-camss.o
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csid.c b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
new file mode 100644
index 000000000000..64df82817de3
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/camss-csid.c
@@ -0,0 +1,1092 @@
1/*
2 * camss-csid.c
3 *
4 * Qualcomm MSM Camera Subsystem - CSID (CSI Decoder) Module
5 *
6 * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
7 * Copyright (C) 2015-2017 Linaro Ltd.
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 version 2 and
11 * only version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18#include <linux/clk.h>
19#include <linux/completion.h>
20#include <linux/interrupt.h>
21#include <linux/kernel.h>
22#include <linux/of.h>
23#include <linux/platform_device.h>
24#include <linux/regulator/consumer.h>
25#include <media/media-entity.h>
26#include <media/v4l2-device.h>
27#include <media/v4l2-subdev.h>
28
29#include "camss-csid.h"
30#include "camss.h"
31
32#define MSM_CSID_NAME "msm_csid"
33
34#define CAMSS_CSID_HW_VERSION 0x0
35#define CAMSS_CSID_CORE_CTRL_0 0x004
36#define CAMSS_CSID_CORE_CTRL_1 0x008
37#define CAMSS_CSID_RST_CMD 0x00c
38#define CAMSS_CSID_CID_LUT_VC_n(n) (0x010 + 0x4 * (n))
39#define CAMSS_CSID_CID_n_CFG(n) (0x020 + 0x4 * (n))
40#define CAMSS_CSID_IRQ_CLEAR_CMD 0x060
41#define CAMSS_CSID_IRQ_MASK 0x064
42#define CAMSS_CSID_IRQ_STATUS 0x068
43#define CAMSS_CSID_TG_CTRL 0x0a0
44#define CAMSS_CSID_TG_CTRL_DISABLE 0xa06436
45#define CAMSS_CSID_TG_CTRL_ENABLE 0xa06437
46#define CAMSS_CSID_TG_VC_CFG 0x0a4
47#define CAMSS_CSID_TG_VC_CFG_H_BLANKING 0x3ff
48#define CAMSS_CSID_TG_VC_CFG_V_BLANKING 0x7f
49#define CAMSS_CSID_TG_DT_n_CGG_0(n) (0x0ac + 0xc * (n))
50#define CAMSS_CSID_TG_DT_n_CGG_1(n) (0x0b0 + 0xc * (n))
51#define CAMSS_CSID_TG_DT_n_CGG_2(n) (0x0b4 + 0xc * (n))
52
53#define DATA_TYPE_EMBEDDED_DATA_8BIT 0x12
54#define DATA_TYPE_YUV422_8BIT 0x1e
55#define DATA_TYPE_RAW_6BIT 0x28
56#define DATA_TYPE_RAW_8BIT 0x2a
57#define DATA_TYPE_RAW_10BIT 0x2b
58#define DATA_TYPE_RAW_12BIT 0x2c
59
60#define DECODE_FORMAT_UNCOMPRESSED_6_BIT 0x0
61#define DECODE_FORMAT_UNCOMPRESSED_8_BIT 0x1
62#define DECODE_FORMAT_UNCOMPRESSED_10_BIT 0x2
63#define DECODE_FORMAT_UNCOMPRESSED_12_BIT 0x3
64
65#define CSID_RESET_TIMEOUT_MS 500
66
67struct csid_fmts {
68 u32 code;
69 u8 data_type;
70 u8 decode_format;
71 u8 bpp;
72 u8 spp; /* bus samples per pixel */
73};
74
75static const struct csid_fmts csid_input_fmts[] = {
76 {
77 MEDIA_BUS_FMT_UYVY8_2X8,
78 DATA_TYPE_YUV422_8BIT,
79 DECODE_FORMAT_UNCOMPRESSED_8_BIT,
80 8,
81 2,
82 },
83 {
84 MEDIA_BUS_FMT_VYUY8_2X8,
85 DATA_TYPE_YUV422_8BIT,
86 DECODE_FORMAT_UNCOMPRESSED_8_BIT,
87 8,
88 2,
89 },
90 {
91 MEDIA_BUS_FMT_YUYV8_2X8,
92 DATA_TYPE_YUV422_8BIT,
93 DECODE_FORMAT_UNCOMPRESSED_8_BIT,
94 8,
95 2,
96 },
97 {
98 MEDIA_BUS_FMT_YVYU8_2X8,
99 DATA_TYPE_YUV422_8BIT,
100 DECODE_FORMAT_UNCOMPRESSED_8_BIT,
101 8,
102 2,
103 },
104 {
105 MEDIA_BUS_FMT_SBGGR8_1X8,
106 DATA_TYPE_RAW_8BIT,
107 DECODE_FORMAT_UNCOMPRESSED_8_BIT,
108 8,
109 1,
110 },
111 {
112 MEDIA_BUS_FMT_SGBRG8_1X8,
113 DATA_TYPE_RAW_8BIT,
114 DECODE_FORMAT_UNCOMPRESSED_8_BIT,
115 8,
116 1,
117 },
118 {
119 MEDIA_BUS_FMT_SGRBG8_1X8,
120 DATA_TYPE_RAW_8BIT,
121 DECODE_FORMAT_UNCOMPRESSED_8_BIT,
122 8,
123 1,
124 },
125 {
126 MEDIA_BUS_FMT_SRGGB8_1X8,
127 DATA_TYPE_RAW_8BIT,
128 DECODE_FORMAT_UNCOMPRESSED_8_BIT,
129 8,
130 1,
131 },
132 {
133 MEDIA_BUS_FMT_SBGGR10_1X10,
134 DATA_TYPE_RAW_10BIT,
135 DECODE_FORMAT_UNCOMPRESSED_10_BIT,
136 10,
137 1,
138 },
139 {
140 MEDIA_BUS_FMT_SGBRG10_1X10,
141 DATA_TYPE_RAW_10BIT,
142 DECODE_FORMAT_UNCOMPRESSED_10_BIT,
143 10,
144 1,
145 },
146 {
147 MEDIA_BUS_FMT_SGRBG10_1X10,
148 DATA_TYPE_RAW_10BIT,
149 DECODE_FORMAT_UNCOMPRESSED_10_BIT,
150 10,
151 1,
152 },
153 {
154 MEDIA_BUS_FMT_SRGGB10_1X10,
155 DATA_TYPE_RAW_10BIT,
156 DECODE_FORMAT_UNCOMPRESSED_10_BIT,
157 10,
158 1,
159 },
160 {
161 MEDIA_BUS_FMT_SBGGR12_1X12,
162 DATA_TYPE_RAW_12BIT,
163 DECODE_FORMAT_UNCOMPRESSED_12_BIT,
164 12,
165 1,
166 },
167 {
168 MEDIA_BUS_FMT_SGBRG12_1X12,
169 DATA_TYPE_RAW_12BIT,
170 DECODE_FORMAT_UNCOMPRESSED_12_BIT,
171 12,
172 1,
173 },
174 {
175 MEDIA_BUS_FMT_SGRBG12_1X12,
176 DATA_TYPE_RAW_12BIT,
177 DECODE_FORMAT_UNCOMPRESSED_12_BIT,
178 12,
179 1,
180 },
181 {
182 MEDIA_BUS_FMT_SRGGB12_1X12,
183 DATA_TYPE_RAW_12BIT,
184 DECODE_FORMAT_UNCOMPRESSED_12_BIT,
185 12,
186 1,
187 }
188};
189
190static const struct csid_fmts *csid_get_fmt_entry(u32 code)
191{
192 unsigned int i;
193
194 for (i = 0; i < ARRAY_SIZE(csid_input_fmts); i++)
195 if (code == csid_input_fmts[i].code)
196 return &csid_input_fmts[i];
197
198 WARN(1, "Unknown format\n");
199
200 return &csid_input_fmts[0];
201}
202
203/*
204 * csid_isr - CSID module interrupt handler
205 * @irq: Interrupt line
206 * @dev: CSID device
207 *
208 * Return IRQ_HANDLED on success
209 */
210static irqreturn_t csid_isr(int irq, void *dev)
211{
212 struct csid_device *csid = dev;
213 u32 value;
214
215 value = readl_relaxed(csid->base + CAMSS_CSID_IRQ_STATUS);
216 writel_relaxed(value, csid->base + CAMSS_CSID_IRQ_CLEAR_CMD);
217
218 if ((value >> 11) & 0x1)
219 complete(&csid->reset_complete);
220
221 return IRQ_HANDLED;
222}
223
224/*
225 * csid_set_clock_rates - Calculate and set clock rates on CSID module
226 * @csiphy: CSID device
227 */
228static int csid_set_clock_rates(struct csid_device *csid)
229{
230 struct device *dev = to_device_index(csid, csid->id);
231 u32 pixel_clock;
232 int i, j;
233 int ret;
234
235 ret = camss_get_pixel_clock(&csid->subdev.entity, &pixel_clock);
236 if (ret)
237 pixel_clock = 0;
238
239 for (i = 0; i < csid->nclocks; i++) {
240 struct camss_clock *clock = &csid->clock[i];
241
242 if (!strcmp(clock->name, "csi0") ||
243 !strcmp(clock->name, "csi1")) {
244 u8 bpp = csid_get_fmt_entry(
245 csid->fmt[MSM_CSIPHY_PAD_SINK].code)->bpp;
246 u8 num_lanes = csid->phy.lane_cnt;
247 u64 min_rate = pixel_clock * bpp / (2 * num_lanes * 4);
248 long rate;
249
250 camss_add_clock_margin(&min_rate);
251
252 for (j = 0; j < clock->nfreqs; j++)
253 if (min_rate < clock->freq[j])
254 break;
255
256 if (j == clock->nfreqs) {
257 dev_err(dev,
258 "Pixel clock is too high for CSID\n");
259 return -EINVAL;
260 }
261
262 /* if sensor pixel clock is not available */
263 /* set highest possible CSID clock rate */
264 if (min_rate == 0)
265 j = clock->nfreqs - 1;
266
267 rate = clk_round_rate(clock->clk, clock->freq[j]);
268 if (rate < 0) {
269 dev_err(dev, "clk round rate failed: %ld\n",
270 rate);
271 return -EINVAL;
272 }
273
274 ret = clk_set_rate(clock->clk, rate);
275 if (ret < 0) {
276 dev_err(dev, "clk set rate failed: %d\n", ret);
277 return ret;
278 }
279 }
280 }
281
282 return 0;
283}
284
285/*
286 * csid_reset - Trigger reset on CSID module and wait to complete
287 * @csid: CSID device
288 *
289 * Return 0 on success or a negative error code otherwise
290 */
291static int csid_reset(struct csid_device *csid)
292{
293 unsigned long time;
294
295 reinit_completion(&csid->reset_complete);
296
297 writel_relaxed(0x7fff, csid->base + CAMSS_CSID_RST_CMD);
298
299 time = wait_for_completion_timeout(&csid->reset_complete,
300 msecs_to_jiffies(CSID_RESET_TIMEOUT_MS));
301 if (!time) {
302 dev_err(to_device_index(csid, csid->id),
303 "CSID reset timeout\n");
304 return -EIO;
305 }
306
307 return 0;
308}
309
310/*
311 * csid_set_power - Power on/off CSID module
312 * @sd: CSID V4L2 subdevice
313 * @on: Requested power state
314 *
315 * Return 0 on success or a negative error code otherwise
316 */
317static int csid_set_power(struct v4l2_subdev *sd, int on)
318{
319 struct csid_device *csid = v4l2_get_subdevdata(sd);
320 struct device *dev = to_device_index(csid, csid->id);
321 int ret;
322
323 if (on) {
324 u32 hw_version;
325
326 ret = regulator_enable(csid->vdda);
327 if (ret < 0)
328 return ret;
329
330 ret = csid_set_clock_rates(csid);
331 if (ret < 0) {
332 regulator_disable(csid->vdda);
333 return ret;
334 }
335
336 ret = camss_enable_clocks(csid->nclocks, csid->clock, dev);
337 if (ret < 0) {
338 regulator_disable(csid->vdda);
339 return ret;
340 }
341
342 enable_irq(csid->irq);
343
344 ret = csid_reset(csid);
345 if (ret < 0) {
346 disable_irq(csid->irq);
347 camss_disable_clocks(csid->nclocks, csid->clock);
348 regulator_disable(csid->vdda);
349 return ret;
350 }
351
352 hw_version = readl_relaxed(csid->base + CAMSS_CSID_HW_VERSION);
353 dev_dbg(dev, "CSID HW Version = 0x%08x\n", hw_version);
354 } else {
355 disable_irq(csid->irq);
356 camss_disable_clocks(csid->nclocks, csid->clock);
357 ret = regulator_disable(csid->vdda);
358 }
359
360 return ret;
361}
362
363/*
364 * csid_set_stream - Enable/disable streaming on CSID module
365 * @sd: CSID V4L2 subdevice
366 * @enable: Requested streaming state
367 *
368 * Main configuration of CSID module is also done here.
369 *
370 * Return 0 on success or a negative error code otherwise
371 */
372static int csid_set_stream(struct v4l2_subdev *sd, int enable)
373{
374 struct csid_device *csid = v4l2_get_subdevdata(sd);
375 struct csid_testgen_config *tg = &csid->testgen;
376 u32 val;
377
378 if (enable) {
379 u8 vc = 0; /* Virtual Channel 0 */
380 u8 cid = vc * 4; /* id of Virtual Channel and Data Type set */
381 u8 dt, dt_shift, df;
382 int ret;
383
384 ret = v4l2_ctrl_handler_setup(&csid->ctrls);
385 if (ret < 0) {
386 dev_err(to_device_index(csid, csid->id),
387 "could not sync v4l2 controls: %d\n", ret);
388 return ret;
389 }
390
391 if (!tg->enabled &&
392 !media_entity_remote_pad(&csid->pads[MSM_CSID_PAD_SINK]))
393 return -ENOLINK;
394
395 dt = csid_get_fmt_entry(csid->fmt[MSM_CSID_PAD_SRC].code)->
396 data_type;
397
398 if (tg->enabled) {
399 /* Config Test Generator */
400 struct v4l2_mbus_framefmt *f =
401 &csid->fmt[MSM_CSID_PAD_SRC];
402 u8 bpp = csid_get_fmt_entry(f->code)->bpp;
403 u8 spp = csid_get_fmt_entry(f->code)->spp;
404 u32 num_bytes_per_line = f->width * bpp * spp / 8;
405 u32 num_lines = f->height;
406
407 /* 31:24 V blank, 23:13 H blank, 3:2 num of active DT */
408 /* 1:0 VC */
409 val = ((CAMSS_CSID_TG_VC_CFG_V_BLANKING & 0xff) << 24) |
410 ((CAMSS_CSID_TG_VC_CFG_H_BLANKING & 0x7ff) << 13);
411 writel_relaxed(val, csid->base + CAMSS_CSID_TG_VC_CFG);
412
413 /* 28:16 bytes per lines, 12:0 num of lines */
414 val = ((num_bytes_per_line & 0x1fff) << 16) |
415 (num_lines & 0x1fff);
416 writel_relaxed(val, csid->base +
417 CAMSS_CSID_TG_DT_n_CGG_0(0));
418
419 /* 5:0 data type */
420 val = dt;
421 writel_relaxed(val, csid->base +
422 CAMSS_CSID_TG_DT_n_CGG_1(0));
423
424 /* 2:0 output test pattern */
425 val = tg->payload_mode;
426 writel_relaxed(val, csid->base +
427 CAMSS_CSID_TG_DT_n_CGG_2(0));
428 } else {
429 struct csid_phy_config *phy = &csid->phy;
430
431 val = phy->lane_cnt - 1;
432 val |= phy->lane_assign << 4;
433
434 writel_relaxed(val,
435 csid->base + CAMSS_CSID_CORE_CTRL_0);
436
437 val = phy->csiphy_id << 17;
438 val |= 0x9;
439
440 writel_relaxed(val,
441 csid->base + CAMSS_CSID_CORE_CTRL_1);
442 }
443
444 /* Config LUT */
445
446 dt_shift = (cid % 4) * 8;
447 df = csid_get_fmt_entry(csid->fmt[MSM_CSID_PAD_SINK].code)->
448 decode_format;
449
450 val = readl_relaxed(csid->base + CAMSS_CSID_CID_LUT_VC_n(vc));
451 val &= ~(0xff << dt_shift);
452 val |= dt << dt_shift;
453 writel_relaxed(val, csid->base + CAMSS_CSID_CID_LUT_VC_n(vc));
454
455 val = (df << 4) | 0x3;
456 writel_relaxed(val, csid->base + CAMSS_CSID_CID_n_CFG(cid));
457
458 if (tg->enabled) {
459 val = CAMSS_CSID_TG_CTRL_ENABLE;
460 writel_relaxed(val, csid->base + CAMSS_CSID_TG_CTRL);
461 }
462 } else {
463 if (tg->enabled) {
464 val = CAMSS_CSID_TG_CTRL_DISABLE;
465 writel_relaxed(val, csid->base + CAMSS_CSID_TG_CTRL);
466 }
467 }
468
469 return 0;
470}
471
472/*
473 * __csid_get_format - Get pointer to format structure
474 * @csid: CSID device
475 * @cfg: V4L2 subdev pad configuration
476 * @pad: pad from which format is requested
477 * @which: TRY or ACTIVE format
478 *
479 * Return pointer to TRY or ACTIVE format structure
480 */
481static struct v4l2_mbus_framefmt *
482__csid_get_format(struct csid_device *csid,
483 struct v4l2_subdev_pad_config *cfg,
484 unsigned int pad,
485 enum v4l2_subdev_format_whence which)
486{
487 if (which == V4L2_SUBDEV_FORMAT_TRY)
488 return v4l2_subdev_get_try_format(&csid->subdev, cfg, pad);
489
490 return &csid->fmt[pad];
491}
492
493/*
494 * csid_try_format - Handle try format by pad subdev method
495 * @csid: CSID device
496 * @cfg: V4L2 subdev pad configuration
497 * @pad: pad on which format is requested
498 * @fmt: pointer to v4l2 format structure
499 * @which: wanted subdev format
500 */
501static void csid_try_format(struct csid_device *csid,
502 struct v4l2_subdev_pad_config *cfg,
503 unsigned int pad,
504 struct v4l2_mbus_framefmt *fmt,
505 enum v4l2_subdev_format_whence which)
506{
507 unsigned int i;
508
509 switch (pad) {
510 case MSM_CSID_PAD_SINK:
511 /* Set format on sink pad */
512
513 for (i = 0; i < ARRAY_SIZE(csid_input_fmts); i++)
514 if (fmt->code == csid_input_fmts[i].code)
515 break;
516
517 /* If not found, use UYVY as default */
518 if (i >= ARRAY_SIZE(csid_input_fmts))
519 fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
520
521 fmt->width = clamp_t(u32, fmt->width, 1, 8191);
522 fmt->height = clamp_t(u32, fmt->height, 1, 8191);
523
524 fmt->field = V4L2_FIELD_NONE;
525 fmt->colorspace = V4L2_COLORSPACE_SRGB;
526
527 break;
528
529 case MSM_CSID_PAD_SRC:
530 if (csid->testgen_mode->cur.val == 0) {
531 /* Test generator is disabled, keep pad formats */
532 /* in sync - set and return a format same as sink pad */
533 struct v4l2_mbus_framefmt format;
534
535 format = *__csid_get_format(csid, cfg,
536 MSM_CSID_PAD_SINK, which);
537 *fmt = format;
538 } else {
539 /* Test generator is enabled, set format on source*/
540 /* pad to allow test generator usage */
541
542 for (i = 0; i < ARRAY_SIZE(csid_input_fmts); i++)
543 if (csid_input_fmts[i].code == fmt->code)
544 break;
545
546 /* If not found, use UYVY as default */
547 if (i >= ARRAY_SIZE(csid_input_fmts))
548 fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
549
550 fmt->width = clamp_t(u32, fmt->width, 1, 8191);
551 fmt->height = clamp_t(u32, fmt->height, 1, 8191);
552
553 fmt->field = V4L2_FIELD_NONE;
554 }
555 break;
556 }
557
558 fmt->colorspace = V4L2_COLORSPACE_SRGB;
559}
560
561/*
562 * csid_enum_mbus_code - Handle pixel format enumeration
563 * @sd: CSID V4L2 subdevice
564 * @cfg: V4L2 subdev pad configuration
565 * @code: pointer to v4l2_subdev_mbus_code_enum structure
566 * return -EINVAL or zero on success
567 */
568static int csid_enum_mbus_code(struct v4l2_subdev *sd,
569 struct v4l2_subdev_pad_config *cfg,
570 struct v4l2_subdev_mbus_code_enum *code)
571{
572 struct csid_device *csid = v4l2_get_subdevdata(sd);
573 struct v4l2_mbus_framefmt *format;
574
575 if (code->pad == MSM_CSID_PAD_SINK) {
576 if (code->index >= ARRAY_SIZE(csid_input_fmts))
577 return -EINVAL;
578
579 code->code = csid_input_fmts[code->index].code;
580 } else {
581 if (csid->testgen_mode->cur.val == 0) {
582 if (code->index > 0)
583 return -EINVAL;
584
585 format = __csid_get_format(csid, cfg, MSM_CSID_PAD_SINK,
586 code->which);
587
588 code->code = format->code;
589 } else {
590 if (code->index >= ARRAY_SIZE(csid_input_fmts))
591 return -EINVAL;
592
593 code->code = csid_input_fmts[code->index].code;
594 }
595 }
596
597 return 0;
598}
599
600/*
601 * csid_enum_frame_size - Handle frame size enumeration
602 * @sd: CSID V4L2 subdevice
603 * @cfg: V4L2 subdev pad configuration
604 * @fse: pointer to v4l2_subdev_frame_size_enum structure
605 * return -EINVAL or zero on success
606 */
607static int csid_enum_frame_size(struct v4l2_subdev *sd,
608 struct v4l2_subdev_pad_config *cfg,
609 struct v4l2_subdev_frame_size_enum *fse)
610{
611 struct csid_device *csid = v4l2_get_subdevdata(sd);
612 struct v4l2_mbus_framefmt format;
613
614 if (fse->index != 0)
615 return -EINVAL;
616
617 format.code = fse->code;
618 format.width = 1;
619 format.height = 1;
620 csid_try_format(csid, cfg, fse->pad, &format, fse->which);
621 fse->min_width = format.width;
622 fse->min_height = format.height;
623
624 if (format.code != fse->code)
625 return -EINVAL;
626
627 format.code = fse->code;
628 format.width = -1;
629 format.height = -1;
630 csid_try_format(csid, cfg, fse->pad, &format, fse->which);
631 fse->max_width = format.width;
632 fse->max_height = format.height;
633
634 return 0;
635}
636
637/*
638 * csid_get_format - Handle get format by pads subdev method
639 * @sd: CSID V4L2 subdevice
640 * @cfg: V4L2 subdev pad configuration
641 * @fmt: pointer to v4l2 subdev format structure
642 *
643 * Return -EINVAL or zero on success
644 */
645static int csid_get_format(struct v4l2_subdev *sd,
646 struct v4l2_subdev_pad_config *cfg,
647 struct v4l2_subdev_format *fmt)
648{
649 struct csid_device *csid = v4l2_get_subdevdata(sd);
650 struct v4l2_mbus_framefmt *format;
651
652 format = __csid_get_format(csid, cfg, fmt->pad, fmt->which);
653 if (format == NULL)
654 return -EINVAL;
655
656 fmt->format = *format;
657
658 return 0;
659}
660
661/*
662 * csid_set_format - Handle set format by pads subdev method
663 * @sd: CSID V4L2 subdevice
664 * @cfg: V4L2 subdev pad configuration
665 * @fmt: pointer to v4l2 subdev format structure
666 *
667 * Return -EINVAL or zero on success
668 */
669static int csid_set_format(struct v4l2_subdev *sd,
670 struct v4l2_subdev_pad_config *cfg,
671 struct v4l2_subdev_format *fmt)
672{
673 struct csid_device *csid = v4l2_get_subdevdata(sd);
674 struct v4l2_mbus_framefmt *format;
675
676 format = __csid_get_format(csid, cfg, fmt->pad, fmt->which);
677 if (format == NULL)
678 return -EINVAL;
679
680 csid_try_format(csid, cfg, fmt->pad, &fmt->format, fmt->which);
681 *format = fmt->format;
682
683 /* Propagate the format from sink to source */
684 if (fmt->pad == MSM_CSID_PAD_SINK) {
685 format = __csid_get_format(csid, cfg, MSM_CSID_PAD_SRC,
686 fmt->which);
687
688 *format = fmt->format;
689 csid_try_format(csid, cfg, MSM_CSID_PAD_SRC, format,
690 fmt->which);
691 }
692
693 return 0;
694}
695
696/*
697 * csid_init_formats - Initialize formats on all pads
698 * @sd: CSID V4L2 subdevice
699 * @fh: V4L2 subdev file handle
700 *
701 * Initialize all pad formats with default values.
702 *
703 * Return 0 on success or a negative error code otherwise
704 */
705static int csid_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
706{
707 struct v4l2_subdev_format format = {
708 .pad = MSM_CSID_PAD_SINK,
709 .which = fh ? V4L2_SUBDEV_FORMAT_TRY :
710 V4L2_SUBDEV_FORMAT_ACTIVE,
711 .format = {
712 .code = MEDIA_BUS_FMT_UYVY8_2X8,
713 .width = 1920,
714 .height = 1080
715 }
716 };
717
718 return csid_set_format(sd, fh ? fh->pad : NULL, &format);
719}
720
721static const char * const csid_test_pattern_menu[] = {
722 "Disabled",
723 "Incrementing",
724 "Alternating 0x55/0xAA",
725 "All Zeros 0x00",
726 "All Ones 0xFF",
727 "Pseudo-random Data",
728};
729
730/*
731 * csid_set_test_pattern - Set test generator's pattern mode
732 * @csid: CSID device
733 * @value: desired test pattern mode
734 *
735 * Return 0 on success or a negative error code otherwise
736 */
737static int csid_set_test_pattern(struct csid_device *csid, s32 value)
738{
739 struct csid_testgen_config *tg = &csid->testgen;
740
741 /* If CSID is linked to CSIPHY, do not allow to enable test generator */
742 if (value && media_entity_remote_pad(&csid->pads[MSM_CSID_PAD_SINK]))
743 return -EBUSY;
744
745 tg->enabled = !!value;
746
747 switch (value) {
748 case 1:
749 tg->payload_mode = CSID_PAYLOAD_MODE_INCREMENTING;
750 break;
751 case 2:
752 tg->payload_mode = CSID_PAYLOAD_MODE_ALTERNATING_55_AA;
753 break;
754 case 3:
755 tg->payload_mode = CSID_PAYLOAD_MODE_ALL_ZEROES;
756 break;
757 case 4:
758 tg->payload_mode = CSID_PAYLOAD_MODE_ALL_ONES;
759 break;
760 case 5:
761 tg->payload_mode = CSID_PAYLOAD_MODE_RANDOM;
762 break;
763 }
764
765 return 0;
766}
767
768/*
769 * csid_s_ctrl - Handle set control subdev method
770 * @ctrl: pointer to v4l2 control structure
771 *
772 * Return 0 on success or a negative error code otherwise
773 */
774static int csid_s_ctrl(struct v4l2_ctrl *ctrl)
775{
776 struct csid_device *csid = container_of(ctrl->handler,
777 struct csid_device, ctrls);
778 int ret = -EINVAL;
779
780 switch (ctrl->id) {
781 case V4L2_CID_TEST_PATTERN:
782 ret = csid_set_test_pattern(csid, ctrl->val);
783 break;
784 }
785
786 return ret;
787}
788
789static const struct v4l2_ctrl_ops csid_ctrl_ops = {
790 .s_ctrl = csid_s_ctrl,
791};
792
793/*
794 * msm_csid_subdev_init - Initialize CSID device structure and resources
795 * @csid: CSID device
796 * @res: CSID module resources table
797 * @id: CSID module id
798 *
799 * Return 0 on success or a negative error code otherwise
800 */
801int msm_csid_subdev_init(struct csid_device *csid,
802 const struct resources *res, u8 id)
803{
804 struct device *dev = to_device_index(csid, id);
805 struct platform_device *pdev = to_platform_device(dev);
806 struct resource *r;
807 int i, j;
808 int ret;
809
810 csid->id = id;
811
812 /* Memory */
813
814 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, res->reg[0]);
815 csid->base = devm_ioremap_resource(dev, r);
816 if (IS_ERR(csid->base)) {
817 dev_err(dev, "could not map memory\n");
818 return PTR_ERR(csid->base);
819 }
820
821 /* Interrupt */
822
823 r = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
824 res->interrupt[0]);
825 if (!r) {
826 dev_err(dev, "missing IRQ\n");
827 return -EINVAL;
828 }
829
830 csid->irq = r->start;
831 snprintf(csid->irq_name, sizeof(csid->irq_name), "%s_%s%d",
832 dev_name(dev), MSM_CSID_NAME, csid->id);
833 ret = devm_request_irq(dev, csid->irq, csid_isr,
834 IRQF_TRIGGER_RISING, csid->irq_name, csid);
835 if (ret < 0) {
836 dev_err(dev, "request_irq failed: %d\n", ret);
837 return ret;
838 }
839
840 disable_irq(csid->irq);
841
842 /* Clocks */
843
844 csid->nclocks = 0;
845 while (res->clock[csid->nclocks])
846 csid->nclocks++;
847
848 csid->clock = devm_kzalloc(dev, csid->nclocks * sizeof(*csid->clock),
849 GFP_KERNEL);
850 if (!csid->clock)
851 return -ENOMEM;
852
853 for (i = 0; i < csid->nclocks; i++) {
854 struct camss_clock *clock = &csid->clock[i];
855
856 clock->clk = devm_clk_get(dev, res->clock[i]);
857 if (IS_ERR(clock->clk))
858 return PTR_ERR(clock->clk);
859
860 clock->name = res->clock[i];
861
862 clock->nfreqs = 0;
863 while (res->clock_rate[i][clock->nfreqs])
864 clock->nfreqs++;
865
866 if (!clock->nfreqs) {
867 clock->freq = NULL;
868 continue;
869 }
870
871 clock->freq = devm_kzalloc(dev, clock->nfreqs *
872 sizeof(*clock->freq), GFP_KERNEL);
873 if (!clock->freq)
874 return -ENOMEM;
875
876 for (j = 0; j < clock->nfreqs; j++)
877 clock->freq[j] = res->clock_rate[i][j];
878 }
879
880 /* Regulator */
881
882 csid->vdda = devm_regulator_get(dev, res->regulator[0]);
883 if (IS_ERR(csid->vdda)) {
884 dev_err(dev, "could not get regulator\n");
885 return PTR_ERR(csid->vdda);
886 }
887
888 init_completion(&csid->reset_complete);
889
890 return 0;
891}
892
893/*
894 * msm_csid_get_csid_id - Get CSID HW module id
895 * @entity: Pointer to CSID media entity structure
896 * @id: Return CSID HW module id here
897 */
898void msm_csid_get_csid_id(struct media_entity *entity, u8 *id)
899{
900 struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
901 struct csid_device *csid = v4l2_get_subdevdata(sd);
902
903 *id = csid->id;
904}
905
906/*
907 * csid_get_lane_assign - Calculate CSI2 lane assign configuration parameter
908 * @lane_cfg - CSI2 lane configuration
909 *
910 * Return lane assign
911 */
912static u32 csid_get_lane_assign(struct csiphy_lanes_cfg *lane_cfg)
913{
914 u32 lane_assign = 0;
915 int i;
916
917 for (i = 0; i < lane_cfg->num_data; i++)
918 lane_assign |= lane_cfg->data[i].pos << (i * 4);
919
920 return lane_assign;
921}
922
923/*
924 * csid_link_setup - Setup CSID connections
925 * @entity: Pointer to media entity structure
926 * @local: Pointer to local pad
927 * @remote: Pointer to remote pad
928 * @flags: Link flags
929 *
930 * Return 0 on success
931 */
932static int csid_link_setup(struct media_entity *entity,
933 const struct media_pad *local,
934 const struct media_pad *remote, u32 flags)
935{
936 if (flags & MEDIA_LNK_FL_ENABLED)
937 if (media_entity_remote_pad(local))
938 return -EBUSY;
939
940 if ((local->flags & MEDIA_PAD_FL_SINK) &&
941 (flags & MEDIA_LNK_FL_ENABLED)) {
942 struct v4l2_subdev *sd;
943 struct csid_device *csid;
944 struct csiphy_device *csiphy;
945 struct csiphy_lanes_cfg *lane_cfg;
946 struct v4l2_subdev_format format = { 0 };
947
948 sd = media_entity_to_v4l2_subdev(entity);
949 csid = v4l2_get_subdevdata(sd);
950
951 /* If test generator is enabled */
952 /* do not allow a link from CSIPHY to CSID */
953 if (csid->testgen_mode->cur.val != 0)
954 return -EBUSY;
955
956 sd = media_entity_to_v4l2_subdev(remote->entity);
957 csiphy = v4l2_get_subdevdata(sd);
958
959 /* If a sensor is not linked to CSIPHY */
960 /* do no allow a link from CSIPHY to CSID */
961 if (!csiphy->cfg.csi2)
962 return -EPERM;
963
964 csid->phy.csiphy_id = csiphy->id;
965
966 lane_cfg = &csiphy->cfg.csi2->lane_cfg;
967 csid->phy.lane_cnt = lane_cfg->num_data;
968 csid->phy.lane_assign = csid_get_lane_assign(lane_cfg);
969
970 /* Reset format on source pad to sink pad format */
971 format.pad = MSM_CSID_PAD_SRC;
972 format.which = V4L2_SUBDEV_FORMAT_ACTIVE;
973 csid_set_format(&csid->subdev, NULL, &format);
974 }
975
976 return 0;
977}
978
979static const struct v4l2_subdev_core_ops csid_core_ops = {
980 .s_power = csid_set_power,
981};
982
983static const struct v4l2_subdev_video_ops csid_video_ops = {
984 .s_stream = csid_set_stream,
985};
986
987static const struct v4l2_subdev_pad_ops csid_pad_ops = {
988 .enum_mbus_code = csid_enum_mbus_code,
989 .enum_frame_size = csid_enum_frame_size,
990 .get_fmt = csid_get_format,
991 .set_fmt = csid_set_format,
992};
993
994static const struct v4l2_subdev_ops csid_v4l2_ops = {
995 .core = &csid_core_ops,
996 .video = &csid_video_ops,
997 .pad = &csid_pad_ops,
998};
999
1000static const struct v4l2_subdev_internal_ops csid_v4l2_internal_ops = {
1001 .open = csid_init_formats,
1002};
1003
1004static const struct media_entity_operations csid_media_ops = {
1005 .link_setup = csid_link_setup,
1006 .link_validate = v4l2_subdev_link_validate,
1007};
1008
1009/*
1010 * msm_csid_register_entity - Register subdev node for CSID module
1011 * @csid: CSID device
1012 * @v4l2_dev: V4L2 device
1013 *
1014 * Return 0 on success or a negative error code otherwise
1015 */
1016int msm_csid_register_entity(struct csid_device *csid,
1017 struct v4l2_device *v4l2_dev)
1018{
1019 struct v4l2_subdev *sd = &csid->subdev;
1020 struct media_pad *pads = csid->pads;
1021 struct device *dev = to_device_index(csid, csid->id);
1022 int ret;
1023
1024 v4l2_subdev_init(sd, &csid_v4l2_ops);
1025 sd->internal_ops = &csid_v4l2_internal_ops;
1026 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
1027 snprintf(sd->name, ARRAY_SIZE(sd->name), "%s%d",
1028 MSM_CSID_NAME, csid->id);
1029 v4l2_set_subdevdata(sd, csid);
1030
1031 ret = v4l2_ctrl_handler_init(&csid->ctrls, 1);
1032 if (ret < 0) {
1033 dev_err(dev, "Failed to init ctrl handler: %d\n", ret);
1034 return ret;
1035 }
1036
1037 csid->testgen_mode = v4l2_ctrl_new_std_menu_items(&csid->ctrls,
1038 &csid_ctrl_ops, V4L2_CID_TEST_PATTERN,
1039 ARRAY_SIZE(csid_test_pattern_menu) - 1, 0, 0,
1040 csid_test_pattern_menu);
1041
1042 if (csid->ctrls.error) {
1043 dev_err(dev, "Failed to init ctrl: %d\n", csid->ctrls.error);
1044 ret = csid->ctrls.error;
1045 goto free_ctrl;
1046 }
1047
1048 csid->subdev.ctrl_handler = &csid->ctrls;
1049
1050 ret = csid_init_formats(sd, NULL);
1051 if (ret < 0) {
1052 dev_err(dev, "Failed to init format: %d\n", ret);
1053 goto free_ctrl;
1054 }
1055
1056 pads[MSM_CSID_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
1057 pads[MSM_CSID_PAD_SRC].flags = MEDIA_PAD_FL_SOURCE;
1058
1059 sd->entity.function = MEDIA_ENT_F_IO_V4L;
1060 sd->entity.ops = &csid_media_ops;
1061 ret = media_entity_pads_init(&sd->entity, MSM_CSID_PADS_NUM, pads);
1062 if (ret < 0) {
1063 dev_err(dev, "Failed to init media entity: %d\n", ret);
1064 goto free_ctrl;
1065 }
1066
1067 ret = v4l2_device_register_subdev(v4l2_dev, sd);
1068 if (ret < 0) {
1069 dev_err(dev, "Failed to register subdev: %d\n", ret);
1070 goto media_cleanup;
1071 }
1072
1073 return 0;
1074
1075media_cleanup:
1076 media_entity_cleanup(&sd->entity);
1077free_ctrl:
1078 v4l2_ctrl_handler_free(&csid->ctrls);
1079
1080 return ret;
1081}
1082
1083/*
1084 * msm_csid_unregister_entity - Unregister CSID module subdev node
1085 * @csid: CSID device
1086 */
1087void msm_csid_unregister_entity(struct csid_device *csid)
1088{
1089 v4l2_device_unregister_subdev(&csid->subdev);
1090 media_entity_cleanup(&csid->subdev.entity);
1091 v4l2_ctrl_handler_free(&csid->ctrls);
1092}
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csid.h b/drivers/media/platform/qcom/camss-8x16/camss-csid.h
new file mode 100644
index 000000000000..8682d3081bc3
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/camss-csid.h
@@ -0,0 +1,82 @@
1/*
2 * camss-csid.h
3 *
4 * Qualcomm MSM Camera Subsystem - CSID (CSI Decoder) Module
5 *
6 * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
7 * Copyright (C) 2015-2017 Linaro Ltd.
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 version 2 and
11 * only version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18#ifndef QC_MSM_CAMSS_CSID_H
19#define QC_MSM_CAMSS_CSID_H
20
21#include <linux/clk.h>
22#include <media/media-entity.h>
23#include <media/v4l2-ctrls.h>
24#include <media/v4l2-device.h>
25#include <media/v4l2-mediabus.h>
26#include <media/v4l2-subdev.h>
27
28#define MSM_CSID_PAD_SINK 0
29#define MSM_CSID_PAD_SRC 1
30#define MSM_CSID_PADS_NUM 2
31
32enum csid_payload_mode {
33 CSID_PAYLOAD_MODE_INCREMENTING = 0,
34 CSID_PAYLOAD_MODE_ALTERNATING_55_AA = 1,
35 CSID_PAYLOAD_MODE_ALL_ZEROES = 2,
36 CSID_PAYLOAD_MODE_ALL_ONES = 3,
37 CSID_PAYLOAD_MODE_RANDOM = 4,
38 CSID_PAYLOAD_MODE_USER_SPECIFIED = 5,
39};
40
41struct csid_testgen_config {
42 u8 enabled;
43 enum csid_payload_mode payload_mode;
44};
45
46struct csid_phy_config {
47 u8 csiphy_id;
48 u8 lane_cnt;
49 u32 lane_assign;
50};
51
52struct csid_device {
53 u8 id;
54 struct v4l2_subdev subdev;
55 struct media_pad pads[MSM_CSID_PADS_NUM];
56 void __iomem *base;
57 u32 irq;
58 char irq_name[30];
59 struct camss_clock *clock;
60 int nclocks;
61 struct regulator *vdda;
62 struct completion reset_complete;
63 struct csid_testgen_config testgen;
64 struct csid_phy_config phy;
65 struct v4l2_mbus_framefmt fmt[MSM_CSID_PADS_NUM];
66 struct v4l2_ctrl_handler ctrls;
67 struct v4l2_ctrl *testgen_mode;
68};
69
70struct resources;
71
72int msm_csid_subdev_init(struct csid_device *csid,
73 const struct resources *res, u8 id);
74
75int msm_csid_register_entity(struct csid_device *csid,
76 struct v4l2_device *v4l2_dev);
77
78void msm_csid_unregister_entity(struct csid_device *csid);
79
80void msm_csid_get_csid_id(struct media_entity *entity, u8 *id);
81
82#endif /* QC_MSM_CAMSS_CSID_H */
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csiphy.c b/drivers/media/platform/qcom/camss-8x16/camss-csiphy.c
new file mode 100644
index 000000000000..072c6cf053f6
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/camss-csiphy.c
@@ -0,0 +1,890 @@
1/*
2 * camss-csiphy.c
3 *
4 * Qualcomm MSM Camera Subsystem - CSIPHY Module
5 *
6 * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
7 * Copyright (C) 2016-2017 Linaro Ltd.
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 version 2 and
11 * only version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18#include <linux/clk.h>
19#include <linux/delay.h>
20#include <linux/interrupt.h>
21#include <linux/kernel.h>
22#include <linux/of.h>
23#include <linux/platform_device.h>
24#include <media/media-entity.h>
25#include <media/v4l2-device.h>
26#include <media/v4l2-subdev.h>
27
28#include "camss-csiphy.h"
29#include "camss.h"
30
31#define MSM_CSIPHY_NAME "msm_csiphy"
32
33#define CAMSS_CSI_PHY_LNn_CFG2(n) (0x004 + 0x40 * (n))
34#define CAMSS_CSI_PHY_LNn_CFG3(n) (0x008 + 0x40 * (n))
35#define CAMSS_CSI_PHY_GLBL_RESET 0x140
36#define CAMSS_CSI_PHY_GLBL_PWR_CFG 0x144
37#define CAMSS_CSI_PHY_GLBL_IRQ_CMD 0x164
38#define CAMSS_CSI_PHY_HW_VERSION 0x188
39#define CAMSS_CSI_PHY_INTERRUPT_STATUSn(n) (0x18c + 0x4 * (n))
40#define CAMSS_CSI_PHY_INTERRUPT_MASKn(n) (0x1ac + 0x4 * (n))
41#define CAMSS_CSI_PHY_INTERRUPT_CLEARn(n) (0x1cc + 0x4 * (n))
42#define CAMSS_CSI_PHY_GLBL_T_INIT_CFG0 0x1ec
43#define CAMSS_CSI_PHY_T_WAKEUP_CFG0 0x1f4
44
45static const struct {
46 u32 code;
47 u8 bpp;
48} csiphy_formats[] = {
49 {
50 MEDIA_BUS_FMT_UYVY8_2X8,
51 8,
52 },
53 {
54 MEDIA_BUS_FMT_VYUY8_2X8,
55 8,
56 },
57 {
58 MEDIA_BUS_FMT_YUYV8_2X8,
59 8,
60 },
61 {
62 MEDIA_BUS_FMT_YVYU8_2X8,
63 8,
64 },
65 {
66 MEDIA_BUS_FMT_SBGGR8_1X8,
67 8,
68 },
69 {
70 MEDIA_BUS_FMT_SGBRG8_1X8,
71 8,
72 },
73 {
74 MEDIA_BUS_FMT_SGRBG8_1X8,
75 8,
76 },
77 {
78 MEDIA_BUS_FMT_SRGGB8_1X8,
79 8,
80 },
81 {
82 MEDIA_BUS_FMT_SBGGR10_1X10,
83 10,
84 },
85 {
86 MEDIA_BUS_FMT_SGBRG10_1X10,
87 10,
88 },
89 {
90 MEDIA_BUS_FMT_SGRBG10_1X10,
91 10,
92 },
93 {
94 MEDIA_BUS_FMT_SRGGB10_1X10,
95 10,
96 },
97 {
98 MEDIA_BUS_FMT_SBGGR12_1X12,
99 12,
100 },
101 {
102 MEDIA_BUS_FMT_SGBRG12_1X12,
103 12,
104 },
105 {
106 MEDIA_BUS_FMT_SGRBG12_1X12,
107 12,
108 },
109 {
110 MEDIA_BUS_FMT_SRGGB12_1X12,
111 12,
112 }
113};
114
115/*
116 * csiphy_get_bpp - map media bus format to bits per pixel
117 * @code: media bus format code
118 *
119 * Return number of bits per pixel
120 */
121static u8 csiphy_get_bpp(u32 code)
122{
123 unsigned int i;
124
125 for (i = 0; i < ARRAY_SIZE(csiphy_formats); i++)
126 if (code == csiphy_formats[i].code)
127 return csiphy_formats[i].bpp;
128
129 WARN(1, "Unknown format\n");
130
131 return csiphy_formats[0].bpp;
132}
133
134/*
135 * csiphy_isr - CSIPHY module interrupt handler
136 * @irq: Interrupt line
137 * @dev: CSIPHY device
138 *
139 * Return IRQ_HANDLED on success
140 */
141static irqreturn_t csiphy_isr(int irq, void *dev)
142{
143 struct csiphy_device *csiphy = dev;
144 u8 i;
145
146 for (i = 0; i < 8; i++) {
147 u8 val = readl_relaxed(csiphy->base +
148 CAMSS_CSI_PHY_INTERRUPT_STATUSn(i));
149 writel_relaxed(val, csiphy->base +
150 CAMSS_CSI_PHY_INTERRUPT_CLEARn(i));
151 writel_relaxed(0x1, csiphy->base + CAMSS_CSI_PHY_GLBL_IRQ_CMD);
152 writel_relaxed(0x0, csiphy->base + CAMSS_CSI_PHY_GLBL_IRQ_CMD);
153 writel_relaxed(0x0, csiphy->base +
154 CAMSS_CSI_PHY_INTERRUPT_CLEARn(i));
155 }
156
157 return IRQ_HANDLED;
158}
159
160/*
161 * csiphy_set_clock_rates - Calculate and set clock rates on CSIPHY module
162 * @csiphy: CSIPHY device
163 */
164static int csiphy_set_clock_rates(struct csiphy_device *csiphy)
165{
166 struct device *dev = to_device_index(csiphy, csiphy->id);
167 u32 pixel_clock;
168 int i, j;
169 int ret;
170
171 ret = camss_get_pixel_clock(&csiphy->subdev.entity, &pixel_clock);
172 if (ret)
173 pixel_clock = 0;
174
175 for (i = 0; i < csiphy->nclocks; i++) {
176 struct camss_clock *clock = &csiphy->clock[i];
177
178 if (!strcmp(clock->name, "csiphy0_timer") ||
179 !strcmp(clock->name, "csiphy1_timer")) {
180 u8 bpp = csiphy_get_bpp(
181 csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
182 u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data;
183 u64 min_rate = pixel_clock * bpp / (2 * num_lanes * 4);
184 long round_rate;
185
186 camss_add_clock_margin(&min_rate);
187
188 for (j = 0; j < clock->nfreqs; j++)
189 if (min_rate < clock->freq[j])
190 break;
191
192 if (j == clock->nfreqs) {
193 dev_err(dev,
194 "Pixel clock is too high for CSIPHY\n");
195 return -EINVAL;
196 }
197
198 /* if sensor pixel clock is not available */
199 /* set highest possible CSIPHY clock rate */
200 if (min_rate == 0)
201 j = clock->nfreqs - 1;
202
203 round_rate = clk_round_rate(clock->clk, clock->freq[j]);
204 if (round_rate < 0) {
205 dev_err(dev, "clk round rate failed: %ld\n",
206 round_rate);
207 return -EINVAL;
208 }
209
210 csiphy->timer_clk_rate = round_rate;
211
212 ret = clk_set_rate(clock->clk, csiphy->timer_clk_rate);
213 if (ret < 0) {
214 dev_err(dev, "clk set rate failed: %d\n", ret);
215 return ret;
216 }
217 }
218 }
219
220 return 0;
221}
222
223/*
224 * csiphy_reset - Perform software reset on CSIPHY module
225 * @csiphy: CSIPHY device
226 */
227static void csiphy_reset(struct csiphy_device *csiphy)
228{
229 writel_relaxed(0x1, csiphy->base + CAMSS_CSI_PHY_GLBL_RESET);
230 usleep_range(5000, 8000);
231 writel_relaxed(0x0, csiphy->base + CAMSS_CSI_PHY_GLBL_RESET);
232}
233
234/*
235 * csiphy_set_power - Power on/off CSIPHY module
236 * @sd: CSIPHY V4L2 subdevice
237 * @on: Requested power state
238 *
239 * Return 0 on success or a negative error code otherwise
240 */
241static int csiphy_set_power(struct v4l2_subdev *sd, int on)
242{
243 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
244 struct device *dev = to_device_index(csiphy, csiphy->id);
245
246 if (on) {
247 u8 hw_version;
248 int ret;
249
250 ret = csiphy_set_clock_rates(csiphy);
251 if (ret < 0)
252 return ret;
253
254 ret = camss_enable_clocks(csiphy->nclocks, csiphy->clock, dev);
255 if (ret < 0)
256 return ret;
257
258 enable_irq(csiphy->irq);
259
260 csiphy_reset(csiphy);
261
262 hw_version = readl_relaxed(csiphy->base +
263 CAMSS_CSI_PHY_HW_VERSION);
264 dev_dbg(dev, "CSIPHY HW Version = 0x%02x\n", hw_version);
265 } else {
266 disable_irq(csiphy->irq);
267
268 camss_disable_clocks(csiphy->nclocks, csiphy->clock);
269 }
270
271 return 0;
272}
273
274/*
275 * csiphy_get_lane_mask - Calculate CSI2 lane mask configuration parameter
276 * @lane_cfg - CSI2 lane configuration
277 *
278 * Return lane mask
279 */
280static u8 csiphy_get_lane_mask(struct csiphy_lanes_cfg *lane_cfg)
281{
282 u8 lane_mask;
283 int i;
284
285 lane_mask = 1 << lane_cfg->clk.pos;
286
287 for (i = 0; i < lane_cfg->num_data; i++)
288 lane_mask |= 1 << lane_cfg->data[i].pos;
289
290 return lane_mask;
291}
292
293/*
294 * csiphy_settle_cnt_calc - Calculate settle count value
295 * @csiphy: CSIPHY device
296 *
297 * Helper function to calculate settle count value. This is
298 * based on the CSI2 T_hs_settle parameter which in turn
299 * is calculated based on the CSI2 transmitter pixel clock
300 * frequency.
301 *
302 * Return settle count value or 0 if the CSI2 pixel clock
303 * frequency is not available
304 */
305static u8 csiphy_settle_cnt_calc(struct csiphy_device *csiphy)
306{
307 u8 bpp = csiphy_get_bpp(
308 csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
309 u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data;
310 u32 pixel_clock; /* Hz */
311 u32 mipi_clock; /* Hz */
312 u32 ui; /* ps */
313 u32 timer_period; /* ps */
314 u32 t_hs_prepare_max; /* ps */
315 u32 t_hs_prepare_zero_min; /* ps */
316 u32 t_hs_settle; /* ps */
317 u8 settle_cnt;
318 int ret;
319
320 ret = camss_get_pixel_clock(&csiphy->subdev.entity, &pixel_clock);
321 if (ret) {
322 dev_err(to_device_index(csiphy, csiphy->id),
323 "Cannot get CSI2 transmitter's pixel clock\n");
324 return 0;
325 }
326 if (!pixel_clock) {
327 dev_err(to_device_index(csiphy, csiphy->id),
328 "Got pixel clock == 0, cannot continue\n");
329 return 0;
330 }
331
332 mipi_clock = pixel_clock * bpp / (2 * num_lanes);
333 ui = div_u64(1000000000000LL, mipi_clock);
334 ui /= 2;
335 t_hs_prepare_max = 85000 + 6 * ui;
336 t_hs_prepare_zero_min = 145000 + 10 * ui;
337 t_hs_settle = (t_hs_prepare_max + t_hs_prepare_zero_min) / 2;
338
339 timer_period = div_u64(1000000000000LL, csiphy->timer_clk_rate);
340 settle_cnt = t_hs_settle / timer_period;
341
342 return settle_cnt;
343}
344
345/*
346 * csiphy_stream_on - Enable streaming on CSIPHY module
347 * @csiphy: CSIPHY device
348 *
349 * Helper function to enable streaming on CSIPHY module.
350 * Main configuration of CSIPHY module is also done here.
351 *
352 * Return 0 on success or a negative error code otherwise
353 */
354static int csiphy_stream_on(struct csiphy_device *csiphy)
355{
356 struct csiphy_config *cfg = &csiphy->cfg;
357 u8 lane_mask = csiphy_get_lane_mask(&cfg->csi2->lane_cfg);
358 u8 settle_cnt;
359 u8 val;
360 int i = 0;
361
362 settle_cnt = csiphy_settle_cnt_calc(csiphy);
363 if (!settle_cnt)
364 return -EINVAL;
365
366 val = readl_relaxed(csiphy->base_clk_mux);
367 if (cfg->combo_mode && (lane_mask & 0x18) == 0x18) {
368 val &= ~0xf0;
369 val |= cfg->csid_id << 4;
370 } else {
371 val &= ~0xf;
372 val |= cfg->csid_id;
373 }
374 writel_relaxed(val, csiphy->base_clk_mux);
375
376 writel_relaxed(0x1, csiphy->base +
377 CAMSS_CSI_PHY_GLBL_T_INIT_CFG0);
378 writel_relaxed(0x1, csiphy->base +
379 CAMSS_CSI_PHY_T_WAKEUP_CFG0);
380
381 val = 0x1;
382 val |= lane_mask << 1;
383 writel_relaxed(val, csiphy->base + CAMSS_CSI_PHY_GLBL_PWR_CFG);
384
385 val = cfg->combo_mode << 4;
386 writel_relaxed(val, csiphy->base + CAMSS_CSI_PHY_GLBL_RESET);
387
388 while (lane_mask) {
389 if (lane_mask & 0x1) {
390 writel_relaxed(0x10, csiphy->base +
391 CAMSS_CSI_PHY_LNn_CFG2(i));
392 writel_relaxed(settle_cnt, csiphy->base +
393 CAMSS_CSI_PHY_LNn_CFG3(i));
394 writel_relaxed(0x3f, csiphy->base +
395 CAMSS_CSI_PHY_INTERRUPT_MASKn(i));
396 writel_relaxed(0x3f, csiphy->base +
397 CAMSS_CSI_PHY_INTERRUPT_CLEARn(i));
398 }
399
400 lane_mask >>= 1;
401 i++;
402 }
403
404 return 0;
405}
406
407/*
408 * csiphy_stream_off - Disable streaming on CSIPHY module
409 * @csiphy: CSIPHY device
410 *
411 * Helper function to disable streaming on CSIPHY module
412 */
413static void csiphy_stream_off(struct csiphy_device *csiphy)
414{
415 u8 lane_mask = csiphy_get_lane_mask(&csiphy->cfg.csi2->lane_cfg);
416 int i = 0;
417
418 while (lane_mask) {
419 if (lane_mask & 0x1)
420 writel_relaxed(0x0, csiphy->base +
421 CAMSS_CSI_PHY_LNn_CFG2(i));
422
423 lane_mask >>= 1;
424 i++;
425 }
426
427 writel_relaxed(0x0, csiphy->base + CAMSS_CSI_PHY_GLBL_PWR_CFG);
428}
429
430
431/*
432 * csiphy_set_stream - Enable/disable streaming on CSIPHY module
433 * @sd: CSIPHY V4L2 subdevice
434 * @enable: Requested streaming state
435 *
436 * Return 0 on success or a negative error code otherwise
437 */
438static int csiphy_set_stream(struct v4l2_subdev *sd, int enable)
439{
440 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
441 int ret = 0;
442
443 if (enable)
444 ret = csiphy_stream_on(csiphy);
445 else
446 csiphy_stream_off(csiphy);
447
448 return ret;
449}
450
451/*
452 * __csiphy_get_format - Get pointer to format structure
453 * @csiphy: CSIPHY device
454 * @cfg: V4L2 subdev pad configuration
455 * @pad: pad from which format is requested
456 * @which: TRY or ACTIVE format
457 *
458 * Return pointer to TRY or ACTIVE format structure
459 */
460static struct v4l2_mbus_framefmt *
461__csiphy_get_format(struct csiphy_device *csiphy,
462 struct v4l2_subdev_pad_config *cfg,
463 unsigned int pad,
464 enum v4l2_subdev_format_whence which)
465{
466 if (which == V4L2_SUBDEV_FORMAT_TRY)
467 return v4l2_subdev_get_try_format(&csiphy->subdev, cfg, pad);
468
469 return &csiphy->fmt[pad];
470}
471
472/*
473 * csiphy_try_format - Handle try format by pad subdev method
474 * @csiphy: CSIPHY device
475 * @cfg: V4L2 subdev pad configuration
476 * @pad: pad on which format is requested
477 * @fmt: pointer to v4l2 format structure
478 * @which: wanted subdev format
479 */
480static void csiphy_try_format(struct csiphy_device *csiphy,
481 struct v4l2_subdev_pad_config *cfg,
482 unsigned int pad,
483 struct v4l2_mbus_framefmt *fmt,
484 enum v4l2_subdev_format_whence which)
485{
486 unsigned int i;
487
488 switch (pad) {
489 case MSM_CSIPHY_PAD_SINK:
490 /* Set format on sink pad */
491
492 for (i = 0; i < ARRAY_SIZE(csiphy_formats); i++)
493 if (fmt->code == csiphy_formats[i].code)
494 break;
495
496 /* If not found, use UYVY as default */
497 if (i >= ARRAY_SIZE(csiphy_formats))
498 fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
499
500 fmt->width = clamp_t(u32, fmt->width, 1, 8191);
501 fmt->height = clamp_t(u32, fmt->height, 1, 8191);
502
503 fmt->field = V4L2_FIELD_NONE;
504 fmt->colorspace = V4L2_COLORSPACE_SRGB;
505
506 break;
507
508 case MSM_CSIPHY_PAD_SRC:
509 /* Set and return a format same as sink pad */
510
511 *fmt = *__csiphy_get_format(csiphy, cfg, MSM_CSID_PAD_SINK,
512 which);
513
514 break;
515 }
516}
517
518/*
519 * csiphy_enum_mbus_code - Handle pixel format enumeration
520 * @sd: CSIPHY V4L2 subdevice
521 * @cfg: V4L2 subdev pad configuration
522 * @code: pointer to v4l2_subdev_mbus_code_enum structure
523 * return -EINVAL or zero on success
524 */
525static int csiphy_enum_mbus_code(struct v4l2_subdev *sd,
526 struct v4l2_subdev_pad_config *cfg,
527 struct v4l2_subdev_mbus_code_enum *code)
528{
529 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
530 struct v4l2_mbus_framefmt *format;
531
532 if (code->pad == MSM_CSIPHY_PAD_SINK) {
533 if (code->index >= ARRAY_SIZE(csiphy_formats))
534 return -EINVAL;
535
536 code->code = csiphy_formats[code->index].code;
537 } else {
538 if (code->index > 0)
539 return -EINVAL;
540
541 format = __csiphy_get_format(csiphy, cfg, MSM_CSIPHY_PAD_SINK,
542 code->which);
543
544 code->code = format->code;
545 }
546
547 return 0;
548}
549
550/*
551 * csiphy_enum_frame_size - Handle frame size enumeration
552 * @sd: CSIPHY V4L2 subdevice
553 * @cfg: V4L2 subdev pad configuration
554 * @fse: pointer to v4l2_subdev_frame_size_enum structure
555 * return -EINVAL or zero on success
556 */
557static int csiphy_enum_frame_size(struct v4l2_subdev *sd,
558 struct v4l2_subdev_pad_config *cfg,
559 struct v4l2_subdev_frame_size_enum *fse)
560{
561 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
562 struct v4l2_mbus_framefmt format;
563
564 if (fse->index != 0)
565 return -EINVAL;
566
567 format.code = fse->code;
568 format.width = 1;
569 format.height = 1;
570 csiphy_try_format(csiphy, cfg, fse->pad, &format, fse->which);
571 fse->min_width = format.width;
572 fse->min_height = format.height;
573
574 if (format.code != fse->code)
575 return -EINVAL;
576
577 format.code = fse->code;
578 format.width = -1;
579 format.height = -1;
580 csiphy_try_format(csiphy, cfg, fse->pad, &format, fse->which);
581 fse->max_width = format.width;
582 fse->max_height = format.height;
583
584 return 0;
585}
586
587/*
588 * csiphy_get_format - Handle get format by pads subdev method
589 * @sd: CSIPHY V4L2 subdevice
590 * @cfg: V4L2 subdev pad configuration
591 * @fmt: pointer to v4l2 subdev format structure
592 *
593 * Return -EINVAL or zero on success
594 */
595static int csiphy_get_format(struct v4l2_subdev *sd,
596 struct v4l2_subdev_pad_config *cfg,
597 struct v4l2_subdev_format *fmt)
598{
599 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
600 struct v4l2_mbus_framefmt *format;
601
602 format = __csiphy_get_format(csiphy, cfg, fmt->pad, fmt->which);
603 if (format == NULL)
604 return -EINVAL;
605
606 fmt->format = *format;
607
608 return 0;
609}
610
611/*
612 * csiphy_set_format - Handle set format by pads subdev method
613 * @sd: CSIPHY V4L2 subdevice
614 * @cfg: V4L2 subdev pad configuration
615 * @fmt: pointer to v4l2 subdev format structure
616 *
617 * Return -EINVAL or zero on success
618 */
619static int csiphy_set_format(struct v4l2_subdev *sd,
620 struct v4l2_subdev_pad_config *cfg,
621 struct v4l2_subdev_format *fmt)
622{
623 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
624 struct v4l2_mbus_framefmt *format;
625
626 format = __csiphy_get_format(csiphy, cfg, fmt->pad, fmt->which);
627 if (format == NULL)
628 return -EINVAL;
629
630 csiphy_try_format(csiphy, cfg, fmt->pad, &fmt->format, fmt->which);
631 *format = fmt->format;
632
633 /* Propagate the format from sink to source */
634 if (fmt->pad == MSM_CSIPHY_PAD_SINK) {
635 format = __csiphy_get_format(csiphy, cfg, MSM_CSIPHY_PAD_SRC,
636 fmt->which);
637
638 *format = fmt->format;
639 csiphy_try_format(csiphy, cfg, MSM_CSIPHY_PAD_SRC, format,
640 fmt->which);
641 }
642
643 return 0;
644}
645
646/*
647 * csiphy_init_formats - Initialize formats on all pads
648 * @sd: CSIPHY V4L2 subdevice
649 * @fh: V4L2 subdev file handle
650 *
651 * Initialize all pad formats with default values.
652 *
653 * Return 0 on success or a negative error code otherwise
654 */
655static int csiphy_init_formats(struct v4l2_subdev *sd,
656 struct v4l2_subdev_fh *fh)
657{
658 struct v4l2_subdev_format format = {
659 .pad = MSM_CSIPHY_PAD_SINK,
660 .which = fh ? V4L2_SUBDEV_FORMAT_TRY :
661 V4L2_SUBDEV_FORMAT_ACTIVE,
662 .format = {
663 .code = MEDIA_BUS_FMT_UYVY8_2X8,
664 .width = 1920,
665 .height = 1080
666 }
667 };
668
669 return csiphy_set_format(sd, fh ? fh->pad : NULL, &format);
670}
671
672/*
673 * msm_csiphy_subdev_init - Initialize CSIPHY device structure and resources
674 * @csiphy: CSIPHY device
675 * @res: CSIPHY module resources table
676 * @id: CSIPHY module id
677 *
678 * Return 0 on success or a negative error code otherwise
679 */
680int msm_csiphy_subdev_init(struct csiphy_device *csiphy,
681 const struct resources *res, u8 id)
682{
683 struct device *dev = to_device_index(csiphy, id);
684 struct platform_device *pdev = to_platform_device(dev);
685 struct resource *r;
686 int i, j;
687 int ret;
688
689 csiphy->id = id;
690 csiphy->cfg.combo_mode = 0;
691
692 /* Memory */
693
694 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, res->reg[0]);
695 csiphy->base = devm_ioremap_resource(dev, r);
696 if (IS_ERR(csiphy->base)) {
697 dev_err(dev, "could not map memory\n");
698 return PTR_ERR(csiphy->base);
699 }
700
701 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, res->reg[1]);
702 csiphy->base_clk_mux = devm_ioremap_resource(dev, r);
703 if (IS_ERR(csiphy->base_clk_mux)) {
704 dev_err(dev, "could not map memory\n");
705 return PTR_ERR(csiphy->base_clk_mux);
706 }
707
708 /* Interrupt */
709
710 r = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
711 res->interrupt[0]);
712 if (!r) {
713 dev_err(dev, "missing IRQ\n");
714 return -EINVAL;
715 }
716
717 csiphy->irq = r->start;
718 snprintf(csiphy->irq_name, sizeof(csiphy->irq_name), "%s_%s%d",
719 dev_name(dev), MSM_CSIPHY_NAME, csiphy->id);
720 ret = devm_request_irq(dev, csiphy->irq, csiphy_isr,
721 IRQF_TRIGGER_RISING, csiphy->irq_name, csiphy);
722 if (ret < 0) {
723 dev_err(dev, "request_irq failed: %d\n", ret);
724 return ret;
725 }
726
727 disable_irq(csiphy->irq);
728
729 /* Clocks */
730
731 csiphy->nclocks = 0;
732 while (res->clock[csiphy->nclocks])
733 csiphy->nclocks++;
734
735 csiphy->clock = devm_kzalloc(dev, csiphy->nclocks *
736 sizeof(*csiphy->clock), GFP_KERNEL);
737 if (!csiphy->clock)
738 return -ENOMEM;
739
740 for (i = 0; i < csiphy->nclocks; i++) {
741 struct camss_clock *clock = &csiphy->clock[i];
742
743 clock->clk = devm_clk_get(dev, res->clock[i]);
744 if (IS_ERR(clock->clk))
745 return PTR_ERR(clock->clk);
746
747 clock->name = res->clock[i];
748
749 clock->nfreqs = 0;
750 while (res->clock_rate[i][clock->nfreqs])
751 clock->nfreqs++;
752
753 if (!clock->nfreqs) {
754 clock->freq = NULL;
755 continue;
756 }
757
758 clock->freq = devm_kzalloc(dev, clock->nfreqs *
759 sizeof(*clock->freq), GFP_KERNEL);
760 if (!clock->freq)
761 return -ENOMEM;
762
763 for (j = 0; j < clock->nfreqs; j++)
764 clock->freq[j] = res->clock_rate[i][j];
765 }
766
767 return 0;
768}
769
770/*
771 * csiphy_link_setup - Setup CSIPHY connections
772 * @entity: Pointer to media entity structure
773 * @local: Pointer to local pad
774 * @remote: Pointer to remote pad
775 * @flags: Link flags
776 *
777 * Rreturn 0 on success
778 */
779static int csiphy_link_setup(struct media_entity *entity,
780 const struct media_pad *local,
781 const struct media_pad *remote, u32 flags)
782{
783 if ((local->flags & MEDIA_PAD_FL_SOURCE) &&
784 (flags & MEDIA_LNK_FL_ENABLED)) {
785 struct v4l2_subdev *sd;
786 struct csiphy_device *csiphy;
787 struct csid_device *csid;
788
789 if (media_entity_remote_pad(local))
790 return -EBUSY;
791
792 sd = media_entity_to_v4l2_subdev(entity);
793 csiphy = v4l2_get_subdevdata(sd);
794
795 sd = media_entity_to_v4l2_subdev(remote->entity);
796 csid = v4l2_get_subdevdata(sd);
797
798 csiphy->cfg.csid_id = csid->id;
799 }
800
801 return 0;
802}
803
804static const struct v4l2_subdev_core_ops csiphy_core_ops = {
805 .s_power = csiphy_set_power,
806};
807
808static const struct v4l2_subdev_video_ops csiphy_video_ops = {
809 .s_stream = csiphy_set_stream,
810};
811
812static const struct v4l2_subdev_pad_ops csiphy_pad_ops = {
813 .enum_mbus_code = csiphy_enum_mbus_code,
814 .enum_frame_size = csiphy_enum_frame_size,
815 .get_fmt = csiphy_get_format,
816 .set_fmt = csiphy_set_format,
817};
818
819static const struct v4l2_subdev_ops csiphy_v4l2_ops = {
820 .core = &csiphy_core_ops,
821 .video = &csiphy_video_ops,
822 .pad = &csiphy_pad_ops,
823};
824
825static const struct v4l2_subdev_internal_ops csiphy_v4l2_internal_ops = {
826 .open = csiphy_init_formats,
827};
828
829static const struct media_entity_operations csiphy_media_ops = {
830 .link_setup = csiphy_link_setup,
831 .link_validate = v4l2_subdev_link_validate,
832};
833
834/*
835 * msm_csiphy_register_entity - Register subdev node for CSIPHY module
836 * @csiphy: CSIPHY device
837 * @v4l2_dev: V4L2 device
838 *
839 * Return 0 on success or a negative error code otherwise
840 */
841int msm_csiphy_register_entity(struct csiphy_device *csiphy,
842 struct v4l2_device *v4l2_dev)
843{
844 struct v4l2_subdev *sd = &csiphy->subdev;
845 struct media_pad *pads = csiphy->pads;
846 struct device *dev = to_device_index(csiphy, csiphy->id);
847 int ret;
848
849 v4l2_subdev_init(sd, &csiphy_v4l2_ops);
850 sd->internal_ops = &csiphy_v4l2_internal_ops;
851 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
852 snprintf(sd->name, ARRAY_SIZE(sd->name), "%s%d",
853 MSM_CSIPHY_NAME, csiphy->id);
854 v4l2_set_subdevdata(sd, csiphy);
855
856 ret = csiphy_init_formats(sd, NULL);
857 if (ret < 0) {
858 dev_err(dev, "Failed to init format: %d\n", ret);
859 return ret;
860 }
861
862 pads[MSM_CSIPHY_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
863 pads[MSM_CSIPHY_PAD_SRC].flags = MEDIA_PAD_FL_SOURCE;
864
865 sd->entity.function = MEDIA_ENT_F_IO_V4L;
866 sd->entity.ops = &csiphy_media_ops;
867 ret = media_entity_pads_init(&sd->entity, MSM_CSIPHY_PADS_NUM, pads);
868 if (ret < 0) {
869 dev_err(dev, "Failed to init media entity: %d\n", ret);
870 return ret;
871 }
872
873 ret = v4l2_device_register_subdev(v4l2_dev, sd);
874 if (ret < 0) {
875 dev_err(dev, "Failed to register subdev: %d\n", ret);
876 media_entity_cleanup(&sd->entity);
877 }
878
879 return ret;
880}
881
882/*
883 * msm_csiphy_unregister_entity - Unregister CSIPHY module subdev node
884 * @csiphy: CSIPHY device
885 */
886void msm_csiphy_unregister_entity(struct csiphy_device *csiphy)
887{
888 v4l2_device_unregister_subdev(&csiphy->subdev);
889 media_entity_cleanup(&csiphy->subdev.entity);
890}
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csiphy.h b/drivers/media/platform/qcom/camss-8x16/camss-csiphy.h
new file mode 100644
index 000000000000..ba8781122065
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/camss-csiphy.h
@@ -0,0 +1,77 @@
1/*
2 * camss-csiphy.h
3 *
4 * Qualcomm MSM Camera Subsystem - CSIPHY Module
5 *
6 * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
7 * Copyright (C) 2016-2017 Linaro Ltd.
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 version 2 and
11 * only version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18#ifndef QC_MSM_CAMSS_CSIPHY_H
19#define QC_MSM_CAMSS_CSIPHY_H
20
21#include <linux/clk.h>
22#include <media/media-entity.h>
23#include <media/v4l2-device.h>
24#include <media/v4l2-mediabus.h>
25#include <media/v4l2-subdev.h>
26
27#define MSM_CSIPHY_PAD_SINK 0
28#define MSM_CSIPHY_PAD_SRC 1
29#define MSM_CSIPHY_PADS_NUM 2
30
31struct csiphy_lane {
32 u8 pos;
33 u8 pol;
34};
35
36struct csiphy_lanes_cfg {
37 int num_data;
38 struct csiphy_lane *data;
39 struct csiphy_lane clk;
40};
41
42struct csiphy_csi2_cfg {
43 struct csiphy_lanes_cfg lane_cfg;
44};
45
46struct csiphy_config {
47 u8 combo_mode;
48 u8 csid_id;
49 struct csiphy_csi2_cfg *csi2;
50};
51
52struct csiphy_device {
53 u8 id;
54 struct v4l2_subdev subdev;
55 struct media_pad pads[MSM_CSIPHY_PADS_NUM];
56 void __iomem *base;
57 void __iomem *base_clk_mux;
58 u32 irq;
59 char irq_name[30];
60 struct camss_clock *clock;
61 int nclocks;
62 u32 timer_clk_rate;
63 struct csiphy_config cfg;
64 struct v4l2_mbus_framefmt fmt[MSM_CSIPHY_PADS_NUM];
65};
66
67struct resources;
68
69int msm_csiphy_subdev_init(struct csiphy_device *csiphy,
70 const struct resources *res, u8 id);
71
72int msm_csiphy_register_entity(struct csiphy_device *csiphy,
73 struct v4l2_device *v4l2_dev);
74
75void msm_csiphy_unregister_entity(struct csiphy_device *csiphy);
76
77#endif /* QC_MSM_CAMSS_CSIPHY_H */
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-ispif.c b/drivers/media/platform/qcom/camss-8x16/camss-ispif.c
new file mode 100644
index 000000000000..24da529397b5
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/camss-ispif.c
@@ -0,0 +1,1175 @@
1/*
2 * camss-ispif.c
3 *
4 * Qualcomm MSM Camera Subsystem - ISPIF (ISP Interface) Module
5 *
6 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
7 * Copyright (C) 2015-2017 Linaro Ltd.
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 version 2 and
11 * only version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18#include <linux/clk.h>
19#include <linux/completion.h>
20#include <linux/interrupt.h>
21#include <linux/iopoll.h>
22#include <linux/kernel.h>
23#include <linux/mutex.h>
24#include <linux/platform_device.h>
25#include <media/media-entity.h>
26#include <media/v4l2-device.h>
27#include <media/v4l2-subdev.h>
28
29#include "camss-ispif.h"
30#include "camss.h"
31
32#define MSM_ISPIF_NAME "msm_ispif"
33
34#define ispif_line_array(ptr_line) \
35 ((const struct ispif_line (*)[]) &(ptr_line[-(ptr_line->id)]))
36
37#define to_ispif(ptr_line) \
38 container_of(ispif_line_array(ptr_line), struct ispif_device, ptr_line)
39
40#define ISPIF_RST_CMD_0 0x008
41#define ISPIF_RST_CMD_0_STROBED_RST_EN (1 << 0)
42#define ISPIF_RST_CMD_0_MISC_LOGIC_RST (1 << 1)
43#define ISPIF_RST_CMD_0_SW_REG_RST (1 << 2)
44#define ISPIF_RST_CMD_0_PIX_INTF_0_CSID_RST (1 << 3)
45#define ISPIF_RST_CMD_0_PIX_INTF_0_VFE_RST (1 << 4)
46#define ISPIF_RST_CMD_0_PIX_INTF_1_CSID_RST (1 << 5)
47#define ISPIF_RST_CMD_0_PIX_INTF_1_VFE_RST (1 << 6)
48#define ISPIF_RST_CMD_0_RDI_INTF_0_CSID_RST (1 << 7)
49#define ISPIF_RST_CMD_0_RDI_INTF_0_VFE_RST (1 << 8)
50#define ISPIF_RST_CMD_0_RDI_INTF_1_CSID_RST (1 << 9)
51#define ISPIF_RST_CMD_0_RDI_INTF_1_VFE_RST (1 << 10)
52#define ISPIF_RST_CMD_0_RDI_INTF_2_CSID_RST (1 << 11)
53#define ISPIF_RST_CMD_0_RDI_INTF_2_VFE_RST (1 << 12)
54#define ISPIF_RST_CMD_0_PIX_OUTPUT_0_MISR_RST (1 << 16)
55#define ISPIF_RST_CMD_0_RDI_OUTPUT_0_MISR_RST (1 << 17)
56#define ISPIF_RST_CMD_0_RDI_OUTPUT_1_MISR_RST (1 << 18)
57#define ISPIF_RST_CMD_0_RDI_OUTPUT_2_MISR_RST (1 << 19)
58#define ISPIF_IRQ_GLOBAL_CLEAR_CMD 0x01c
59#define ISPIF_VFE_m_CTRL_0(m) (0x200 + 0x200 * (m))
60#define ISPIF_VFE_m_CTRL_0_PIX0_LINE_BUF_EN (1 << 6)
61#define ISPIF_VFE_m_IRQ_MASK_0(m) (0x208 + 0x200 * (m))
62#define ISPIF_VFE_m_IRQ_MASK_0_PIX0_ENABLE 0x00001249
63#define ISPIF_VFE_m_IRQ_MASK_0_PIX0_MASK 0x00001fff
64#define ISPIF_VFE_m_IRQ_MASK_0_RDI0_ENABLE 0x02492000
65#define ISPIF_VFE_m_IRQ_MASK_0_RDI0_MASK 0x03ffe000
66#define ISPIF_VFE_m_IRQ_MASK_1(m) (0x20c + 0x200 * (m))
67#define ISPIF_VFE_m_IRQ_MASK_1_PIX1_ENABLE 0x00001249
68#define ISPIF_VFE_m_IRQ_MASK_1_PIX1_MASK 0x00001fff
69#define ISPIF_VFE_m_IRQ_MASK_1_RDI1_ENABLE 0x02492000
70#define ISPIF_VFE_m_IRQ_MASK_1_RDI1_MASK 0x03ffe000
71#define ISPIF_VFE_m_IRQ_MASK_2(m) (0x210 + 0x200 * (m))
72#define ISPIF_VFE_m_IRQ_MASK_2_RDI2_ENABLE 0x00001249
73#define ISPIF_VFE_m_IRQ_MASK_2_RDI2_MASK 0x00001fff
74#define ISPIF_VFE_m_IRQ_STATUS_0(m) (0x21c + 0x200 * (m))
75#define ISPIF_VFE_m_IRQ_STATUS_0_PIX0_OVERFLOW (1 << 12)
76#define ISPIF_VFE_m_IRQ_STATUS_0_RDI0_OVERFLOW (1 << 25)
77#define ISPIF_VFE_m_IRQ_STATUS_1(m) (0x220 + 0x200 * (m))
78#define ISPIF_VFE_m_IRQ_STATUS_1_PIX1_OVERFLOW (1 << 12)
79#define ISPIF_VFE_m_IRQ_STATUS_1_RDI1_OVERFLOW (1 << 25)
80#define ISPIF_VFE_m_IRQ_STATUS_2(m) (0x224 + 0x200 * (m))
81#define ISPIF_VFE_m_IRQ_STATUS_2_RDI2_OVERFLOW (1 << 12)
82#define ISPIF_VFE_m_IRQ_CLEAR_0(m) (0x230 + 0x200 * (m))
83#define ISPIF_VFE_m_IRQ_CLEAR_1(m) (0x234 + 0x200 * (m))
84#define ISPIF_VFE_m_IRQ_CLEAR_2(m) (0x238 + 0x200 * (m))
85#define ISPIF_VFE_m_INTF_INPUT_SEL(m) (0x244 + 0x200 * (m))
86#define ISPIF_VFE_m_INTF_CMD_0(m) (0x248 + 0x200 * (m))
87#define ISPIF_VFE_m_INTF_CMD_1(m) (0x24c + 0x200 * (m))
88#define ISPIF_VFE_m_PIX_INTF_n_CID_MASK(m, n) \
89 (0x254 + 0x200 * (m) + 0x4 * (n))
90#define ISPIF_VFE_m_RDI_INTF_n_CID_MASK(m, n) \
91 (0x264 + 0x200 * (m) + 0x4 * (n))
92#define ISPIF_VFE_m_PIX_INTF_n_STATUS(m, n) \
93 (0x2c0 + 0x200 * (m) + 0x4 * (n))
94#define ISPIF_VFE_m_RDI_INTF_n_STATUS(m, n) \
95 (0x2d0 + 0x200 * (m) + 0x4 * (n))
96
97#define CSI_PIX_CLK_MUX_SEL 0x000
98#define CSI_RDI_CLK_MUX_SEL 0x008
99
100#define ISPIF_TIMEOUT_SLEEP_US 1000
101#define ISPIF_TIMEOUT_ALL_US 1000000
102#define ISPIF_RESET_TIMEOUT_MS 500
103
104enum ispif_intf_cmd {
105 CMD_DISABLE_FRAME_BOUNDARY = 0x0,
106 CMD_ENABLE_FRAME_BOUNDARY = 0x1,
107 CMD_DISABLE_IMMEDIATELY = 0x2,
108 CMD_ALL_DISABLE_IMMEDIATELY = 0xaaaaaaaa,
109 CMD_ALL_NO_CHANGE = 0xffffffff,
110};
111
112static const u32 ispif_formats[] = {
113 MEDIA_BUS_FMT_UYVY8_2X8,
114 MEDIA_BUS_FMT_VYUY8_2X8,
115 MEDIA_BUS_FMT_YUYV8_2X8,
116 MEDIA_BUS_FMT_YVYU8_2X8,
117 MEDIA_BUS_FMT_SBGGR8_1X8,
118 MEDIA_BUS_FMT_SGBRG8_1X8,
119 MEDIA_BUS_FMT_SGRBG8_1X8,
120 MEDIA_BUS_FMT_SRGGB8_1X8,
121 MEDIA_BUS_FMT_SBGGR10_1X10,
122 MEDIA_BUS_FMT_SGBRG10_1X10,
123 MEDIA_BUS_FMT_SGRBG10_1X10,
124 MEDIA_BUS_FMT_SRGGB10_1X10,
125 MEDIA_BUS_FMT_SBGGR12_1X12,
126 MEDIA_BUS_FMT_SGBRG12_1X12,
127 MEDIA_BUS_FMT_SGRBG12_1X12,
128 MEDIA_BUS_FMT_SRGGB12_1X12,
129};
130
131/*
132 * ispif_isr - ISPIF module interrupt handler
133 * @irq: Interrupt line
134 * @dev: ISPIF device
135 *
136 * Return IRQ_HANDLED on success
137 */
138static irqreturn_t ispif_isr(int irq, void *dev)
139{
140 struct ispif_device *ispif = dev;
141 u32 value0, value1, value2;
142
143 value0 = readl_relaxed(ispif->base + ISPIF_VFE_m_IRQ_STATUS_0(0));
144 value1 = readl_relaxed(ispif->base + ISPIF_VFE_m_IRQ_STATUS_1(0));
145 value2 = readl_relaxed(ispif->base + ISPIF_VFE_m_IRQ_STATUS_2(0));
146
147 writel_relaxed(value0, ispif->base + ISPIF_VFE_m_IRQ_CLEAR_0(0));
148 writel_relaxed(value1, ispif->base + ISPIF_VFE_m_IRQ_CLEAR_1(0));
149 writel_relaxed(value2, ispif->base + ISPIF_VFE_m_IRQ_CLEAR_2(0));
150
151 writel(0x1, ispif->base + ISPIF_IRQ_GLOBAL_CLEAR_CMD);
152
153 if ((value0 >> 27) & 0x1)
154 complete(&ispif->reset_complete);
155
156 if (unlikely(value0 & ISPIF_VFE_m_IRQ_STATUS_0_PIX0_OVERFLOW))
157 dev_err_ratelimited(to_device(ispif), "VFE0 pix0 overflow\n");
158
159 if (unlikely(value0 & ISPIF_VFE_m_IRQ_STATUS_0_RDI0_OVERFLOW))
160 dev_err_ratelimited(to_device(ispif), "VFE0 rdi0 overflow\n");
161
162 if (unlikely(value1 & ISPIF_VFE_m_IRQ_STATUS_1_PIX1_OVERFLOW))
163 dev_err_ratelimited(to_device(ispif), "VFE0 pix1 overflow\n");
164
165 if (unlikely(value1 & ISPIF_VFE_m_IRQ_STATUS_1_RDI1_OVERFLOW))
166 dev_err_ratelimited(to_device(ispif), "VFE0 rdi1 overflow\n");
167
168 if (unlikely(value2 & ISPIF_VFE_m_IRQ_STATUS_2_RDI2_OVERFLOW))
169 dev_err_ratelimited(to_device(ispif), "VFE0 rdi2 overflow\n");
170
171 return IRQ_HANDLED;
172}
173
174/*
175 * ispif_reset - Trigger reset on ISPIF module and wait to complete
176 * @ispif: ISPIF device
177 *
178 * Return 0 on success or a negative error code otherwise
179 */
180static int ispif_reset(struct ispif_device *ispif)
181{
182 unsigned long time;
183 u32 val;
184 int ret;
185
186 ret = camss_enable_clocks(ispif->nclocks_for_reset,
187 ispif->clock_for_reset,
188 to_device(ispif));
189 if (ret < 0)
190 return ret;
191
192 reinit_completion(&ispif->reset_complete);
193
194 val = ISPIF_RST_CMD_0_STROBED_RST_EN |
195 ISPIF_RST_CMD_0_MISC_LOGIC_RST |
196 ISPIF_RST_CMD_0_SW_REG_RST |
197 ISPIF_RST_CMD_0_PIX_INTF_0_CSID_RST |
198 ISPIF_RST_CMD_0_PIX_INTF_0_VFE_RST |
199 ISPIF_RST_CMD_0_PIX_INTF_1_CSID_RST |
200 ISPIF_RST_CMD_0_PIX_INTF_1_VFE_RST |
201 ISPIF_RST_CMD_0_RDI_INTF_0_CSID_RST |
202 ISPIF_RST_CMD_0_RDI_INTF_0_VFE_RST |
203 ISPIF_RST_CMD_0_RDI_INTF_1_CSID_RST |
204 ISPIF_RST_CMD_0_RDI_INTF_1_VFE_RST |
205 ISPIF_RST_CMD_0_RDI_INTF_2_CSID_RST |
206 ISPIF_RST_CMD_0_RDI_INTF_2_VFE_RST |
207 ISPIF_RST_CMD_0_PIX_OUTPUT_0_MISR_RST |
208 ISPIF_RST_CMD_0_RDI_OUTPUT_0_MISR_RST |
209 ISPIF_RST_CMD_0_RDI_OUTPUT_1_MISR_RST |
210 ISPIF_RST_CMD_0_RDI_OUTPUT_2_MISR_RST;
211
212 writel_relaxed(val, ispif->base + ISPIF_RST_CMD_0);
213
214 time = wait_for_completion_timeout(&ispif->reset_complete,
215 msecs_to_jiffies(ISPIF_RESET_TIMEOUT_MS));
216 if (!time) {
217 dev_err(to_device(ispif), "ISPIF reset timeout\n");
218 return -EIO;
219 }
220
221 camss_disable_clocks(ispif->nclocks_for_reset, ispif->clock_for_reset);
222
223 return 0;
224}
225
226/*
227 * ispif_set_power - Power on/off ISPIF module
228 * @sd: ISPIF V4L2 subdevice
229 * @on: Requested power state
230 *
231 * Return 0 on success or a negative error code otherwise
232 */
233static int ispif_set_power(struct v4l2_subdev *sd, int on)
234{
235 struct ispif_line *line = v4l2_get_subdevdata(sd);
236 struct ispif_device *ispif = to_ispif(line);
237 struct device *dev = to_device(ispif);
238 int ret = 0;
239
240 mutex_lock(&ispif->power_lock);
241
242 if (on) {
243 if (ispif->power_count) {
244 /* Power is already on */
245 ispif->power_count++;
246 goto exit;
247 }
248
249 ret = camss_enable_clocks(ispif->nclocks, ispif->clock, dev);
250 if (ret < 0)
251 goto exit;
252
253 ret = ispif_reset(ispif);
254 if (ret < 0) {
255 camss_disable_clocks(ispif->nclocks, ispif->clock);
256 goto exit;
257 }
258
259 ispif->intf_cmd[line->vfe_id].cmd_0 = CMD_ALL_NO_CHANGE;
260 ispif->intf_cmd[line->vfe_id].cmd_1 = CMD_ALL_NO_CHANGE;
261
262 ispif->power_count++;
263 } else {
264 if (ispif->power_count == 0) {
265 dev_err(dev, "ispif power off on power_count == 0\n");
266 goto exit;
267 } else if (ispif->power_count == 1) {
268 camss_disable_clocks(ispif->nclocks, ispif->clock);
269 }
270
271 ispif->power_count--;
272 }
273
274exit:
275 mutex_unlock(&ispif->power_lock);
276
277 return ret;
278}
279
280/*
281 * ispif_select_clk_mux - Select clock for PIX/RDI interface
282 * @ispif: ISPIF device
283 * @intf: VFE interface
284 * @csid: CSID HW module id
285 * @vfe: VFE HW module id
286 * @enable: enable or disable the selected clock
287 */
288static void ispif_select_clk_mux(struct ispif_device *ispif,
289 enum ispif_intf intf, u8 csid,
290 u8 vfe, u8 enable)
291{
292 u32 val;
293
294 switch (intf) {
295 case PIX0:
296 val = readl_relaxed(ispif->base_clk_mux + CSI_PIX_CLK_MUX_SEL);
297 val &= ~(0xf << (vfe * 8));
298 if (enable)
299 val |= (csid << (vfe * 8));
300 writel_relaxed(val, ispif->base_clk_mux + CSI_PIX_CLK_MUX_SEL);
301 break;
302
303 case RDI0:
304 val = readl_relaxed(ispif->base_clk_mux + CSI_RDI_CLK_MUX_SEL);
305 val &= ~(0xf << (vfe * 12));
306 if (enable)
307 val |= (csid << (vfe * 12));
308 writel_relaxed(val, ispif->base_clk_mux + CSI_RDI_CLK_MUX_SEL);
309 break;
310
311 case PIX1:
312 val = readl_relaxed(ispif->base_clk_mux + CSI_PIX_CLK_MUX_SEL);
313 val &= ~(0xf << (4 + (vfe * 8)));
314 if (enable)
315 val |= (csid << (4 + (vfe * 8)));
316 writel_relaxed(val, ispif->base_clk_mux + CSI_PIX_CLK_MUX_SEL);
317 break;
318
319 case RDI1:
320 val = readl_relaxed(ispif->base_clk_mux + CSI_RDI_CLK_MUX_SEL);
321 val &= ~(0xf << (4 + (vfe * 12)));
322 if (enable)
323 val |= (csid << (4 + (vfe * 12)));
324 writel_relaxed(val, ispif->base_clk_mux + CSI_RDI_CLK_MUX_SEL);
325 break;
326
327 case RDI2:
328 val = readl_relaxed(ispif->base_clk_mux + CSI_RDI_CLK_MUX_SEL);
329 val &= ~(0xf << (8 + (vfe * 12)));
330 if (enable)
331 val |= (csid << (8 + (vfe * 12)));
332 writel_relaxed(val, ispif->base_clk_mux + CSI_RDI_CLK_MUX_SEL);
333 break;
334 }
335
336 mb();
337}
338
339/*
340 * ispif_validate_intf_status - Validate current status of PIX/RDI interface
341 * @ispif: ISPIF device
342 * @intf: VFE interface
343 * @vfe: VFE HW module id
344 *
345 * Return 0 when interface is idle or -EBUSY otherwise
346 */
347static int ispif_validate_intf_status(struct ispif_device *ispif,
348 enum ispif_intf intf, u8 vfe)
349{
350 int ret = 0;
351 u32 val = 0;
352
353 switch (intf) {
354 case PIX0:
355 val = readl_relaxed(ispif->base +
356 ISPIF_VFE_m_PIX_INTF_n_STATUS(vfe, 0));
357 break;
358 case RDI0:
359 val = readl_relaxed(ispif->base +
360 ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe, 0));
361 break;
362 case PIX1:
363 val = readl_relaxed(ispif->base +
364 ISPIF_VFE_m_PIX_INTF_n_STATUS(vfe, 1));
365 break;
366 case RDI1:
367 val = readl_relaxed(ispif->base +
368 ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe, 1));
369 break;
370 case RDI2:
371 val = readl_relaxed(ispif->base +
372 ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe, 2));
373 break;
374 }
375
376 if ((val & 0xf) != 0xf) {
377 dev_err(to_device(ispif), "%s: ispif is busy: 0x%x\n",
378 __func__, val);
379 ret = -EBUSY;
380 }
381
382 return ret;
383}
384
385/*
386 * ispif_wait_for_stop - Wait for PIX/RDI interface to stop
387 * @ispif: ISPIF device
388 * @intf: VFE interface
389 * @vfe: VFE HW module id
390 *
391 * Return 0 on success or a negative error code otherwise
392 */
393static int ispif_wait_for_stop(struct ispif_device *ispif,
394 enum ispif_intf intf, u8 vfe)
395{
396 u32 addr = 0;
397 u32 stop_flag = 0;
398 int ret;
399
400 switch (intf) {
401 case PIX0:
402 addr = ISPIF_VFE_m_PIX_INTF_n_STATUS(vfe, 0);
403 break;
404 case RDI0:
405 addr = ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe, 0);
406 break;
407 case PIX1:
408 addr = ISPIF_VFE_m_PIX_INTF_n_STATUS(vfe, 1);
409 break;
410 case RDI1:
411 addr = ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe, 1);
412 break;
413 case RDI2:
414 addr = ISPIF_VFE_m_RDI_INTF_n_STATUS(vfe, 2);
415 break;
416 }
417
418 ret = readl_poll_timeout(ispif->base + addr,
419 stop_flag,
420 (stop_flag & 0xf) == 0xf,
421 ISPIF_TIMEOUT_SLEEP_US,
422 ISPIF_TIMEOUT_ALL_US);
423 if (ret < 0)
424 dev_err(to_device(ispif), "%s: ispif stop timeout\n",
425 __func__);
426
427 return ret;
428}
429
430/*
431 * ispif_select_csid - Select CSID HW module for input from
432 * @ispif: ISPIF device
433 * @intf: VFE interface
434 * @csid: CSID HW module id
435 * @vfe: VFE HW module id
436 * @enable: enable or disable the selected input
437 */
438static void ispif_select_csid(struct ispif_device *ispif, enum ispif_intf intf,
439 u8 csid, u8 vfe, u8 enable)
440{
441 u32 val;
442
443 val = readl_relaxed(ispif->base + ISPIF_VFE_m_INTF_INPUT_SEL(vfe));
444 switch (intf) {
445 case PIX0:
446 val &= ~(BIT(1) | BIT(0));
447 if (enable)
448 val |= csid;
449 break;
450 case RDI0:
451 val &= ~(BIT(5) | BIT(4));
452 if (enable)
453 val |= (csid << 4);
454 break;
455 case PIX1:
456 val &= ~(BIT(9) | BIT(8));
457 if (enable)
458 val |= (csid << 8);
459 break;
460 case RDI1:
461 val &= ~(BIT(13) | BIT(12));
462 if (enable)
463 val |= (csid << 12);
464 break;
465 case RDI2:
466 val &= ~(BIT(21) | BIT(20));
467 if (enable)
468 val |= (csid << 20);
469 break;
470 }
471
472 writel(val, ispif->base + ISPIF_VFE_m_INTF_INPUT_SEL(vfe));
473}
474
475/*
476 * ispif_select_cid - Enable/disable desired CID
477 * @ispif: ISPIF device
478 * @intf: VFE interface
479 * @cid: desired CID to enable/disable
480 * @vfe: VFE HW module id
481 * @enable: enable or disable the desired CID
482 */
483static void ispif_select_cid(struct ispif_device *ispif, enum ispif_intf intf,
484 u8 cid, u8 vfe, u8 enable)
485{
486 u32 cid_mask = 1 << cid;
487 u32 addr = 0;
488 u32 val;
489
490 switch (intf) {
491 case PIX0:
492 addr = ISPIF_VFE_m_PIX_INTF_n_CID_MASK(vfe, 0);
493 break;
494 case RDI0:
495 addr = ISPIF_VFE_m_RDI_INTF_n_CID_MASK(vfe, 0);
496 break;
497 case PIX1:
498 addr = ISPIF_VFE_m_PIX_INTF_n_CID_MASK(vfe, 1);
499 break;
500 case RDI1:
501 addr = ISPIF_VFE_m_RDI_INTF_n_CID_MASK(vfe, 1);
502 break;
503 case RDI2:
504 addr = ISPIF_VFE_m_RDI_INTF_n_CID_MASK(vfe, 2);
505 break;
506 }
507
508 val = readl_relaxed(ispif->base + addr);
509 if (enable)
510 val |= cid_mask;
511 else
512 val &= ~cid_mask;
513
514 writel(val, ispif->base + addr);
515}
516
517/*
518 * ispif_config_irq - Enable/disable interrupts for PIX/RDI interface
519 * @ispif: ISPIF device
520 * @intf: VFE interface
521 * @vfe: VFE HW module id
522 * @enable: enable or disable
523 */
524static void ispif_config_irq(struct ispif_device *ispif, enum ispif_intf intf,
525 u8 vfe, u8 enable)
526{
527 u32 val;
528
529 switch (intf) {
530 case PIX0:
531 val = readl_relaxed(ispif->base + ISPIF_VFE_m_IRQ_MASK_0(vfe));
532 val &= ~ISPIF_VFE_m_IRQ_MASK_0_PIX0_MASK;
533 if (enable)
534 val |= ISPIF_VFE_m_IRQ_MASK_0_PIX0_ENABLE;
535 writel_relaxed(val, ispif->base + ISPIF_VFE_m_IRQ_MASK_0(vfe));
536 writel_relaxed(ISPIF_VFE_m_IRQ_MASK_0_PIX0_ENABLE,
537 ispif->base + ISPIF_VFE_m_IRQ_CLEAR_0(vfe));
538 break;
539 case RDI0:
540 val = readl_relaxed(ispif->base + ISPIF_VFE_m_IRQ_MASK_0(vfe));
541 val &= ~ISPIF_VFE_m_IRQ_MASK_0_RDI0_MASK;
542 if (enable)
543 val |= ISPIF_VFE_m_IRQ_MASK_0_RDI0_ENABLE;
544 writel_relaxed(val, ispif->base + ISPIF_VFE_m_IRQ_MASK_0(vfe));
545 writel_relaxed(ISPIF_VFE_m_IRQ_MASK_0_RDI0_ENABLE,
546 ispif->base + ISPIF_VFE_m_IRQ_CLEAR_0(vfe));
547 break;
548 case PIX1:
549 val = readl_relaxed(ispif->base + ISPIF_VFE_m_IRQ_MASK_1(vfe));
550 val &= ~ISPIF_VFE_m_IRQ_MASK_1_PIX1_MASK;
551 if (enable)
552 val |= ISPIF_VFE_m_IRQ_MASK_1_PIX1_ENABLE;
553 writel_relaxed(val, ispif->base + ISPIF_VFE_m_IRQ_MASK_1(vfe));
554 writel_relaxed(ISPIF_VFE_m_IRQ_MASK_1_PIX1_ENABLE,
555 ispif->base + ISPIF_VFE_m_IRQ_CLEAR_1(vfe));
556 break;
557 case RDI1:
558 val = readl_relaxed(ispif->base + ISPIF_VFE_m_IRQ_MASK_1(vfe));
559 val &= ~ISPIF_VFE_m_IRQ_MASK_1_RDI1_MASK;
560 if (enable)
561 val |= ISPIF_VFE_m_IRQ_MASK_1_RDI1_ENABLE;
562 writel_relaxed(val, ispif->base + ISPIF_VFE_m_IRQ_MASK_1(vfe));
563 writel_relaxed(ISPIF_VFE_m_IRQ_MASK_1_RDI1_ENABLE,
564 ispif->base + ISPIF_VFE_m_IRQ_CLEAR_1(vfe));
565 break;
566 case RDI2:
567 val = readl_relaxed(ispif->base + ISPIF_VFE_m_IRQ_MASK_2(vfe));
568 val &= ~ISPIF_VFE_m_IRQ_MASK_2_RDI2_MASK;
569 if (enable)
570 val |= ISPIF_VFE_m_IRQ_MASK_2_RDI2_ENABLE;
571 writel_relaxed(val, ispif->base + ISPIF_VFE_m_IRQ_MASK_2(vfe));
572 writel_relaxed(ISPIF_VFE_m_IRQ_MASK_2_RDI2_ENABLE,
573 ispif->base + ISPIF_VFE_m_IRQ_CLEAR_2(vfe));
574 break;
575 }
576
577 writel(0x1, ispif->base + ISPIF_IRQ_GLOBAL_CLEAR_CMD);
578}
579
580/*
581 * ispif_set_intf_cmd - Set command to enable/disable interface
582 * @ispif: ISPIF device
583 * @cmd: interface command
584 * @intf: VFE interface
585 * @vfe: VFE HW module id
586 * @vc: virtual channel
587 */
588static void ispif_set_intf_cmd(struct ispif_device *ispif, u8 cmd,
589 enum ispif_intf intf, u8 vfe, u8 vc)
590{
591 u32 *val;
592
593 if (intf == RDI2) {
594 val = &ispif->intf_cmd[vfe].cmd_1;
595 *val &= ~(0x3 << (vc * 2 + 8));
596 *val |= (cmd << (vc * 2 + 8));
597 wmb();
598 writel_relaxed(*val, ispif->base + ISPIF_VFE_m_INTF_CMD_1(vfe));
599 wmb();
600 } else {
601 val = &ispif->intf_cmd[vfe].cmd_0;
602 *val &= ~(0x3 << (vc * 2 + intf * 8));
603 *val |= (cmd << (vc * 2 + intf * 8));
604 wmb();
605 writel_relaxed(*val, ispif->base + ISPIF_VFE_m_INTF_CMD_0(vfe));
606 wmb();
607 }
608}
609
610/*
611 * ispif_set_stream - Enable/disable streaming on ISPIF module
612 * @sd: ISPIF V4L2 subdevice
613 * @enable: Requested streaming state
614 *
615 * Main configuration of ISPIF module is also done here.
616 *
617 * Return 0 on success or a negative error code otherwise
618 */
619static int ispif_set_stream(struct v4l2_subdev *sd, int enable)
620{
621 struct ispif_line *line = v4l2_get_subdevdata(sd);
622 struct ispif_device *ispif = to_ispif(line);
623 enum ispif_intf intf = line->interface;
624 u8 csid = line->csid_id;
625 u8 vfe = line->vfe_id;
626 u8 vc = 0; /* Virtual Channel 0 */
627 u8 cid = vc * 4; /* id of Virtual Channel and Data Type set */
628 int ret;
629
630 if (enable) {
631 if (!media_entity_remote_pad(&line->pads[MSM_ISPIF_PAD_SINK]))
632 return -ENOLINK;
633
634 /* Config */
635
636 mutex_lock(&ispif->config_lock);
637 ispif_select_clk_mux(ispif, intf, csid, vfe, 1);
638
639 ret = ispif_validate_intf_status(ispif, intf, vfe);
640 if (ret < 0) {
641 mutex_unlock(&ispif->config_lock);
642 return ret;
643 }
644
645 ispif_select_csid(ispif, intf, csid, vfe, 1);
646 ispif_select_cid(ispif, intf, cid, vfe, 1);
647 ispif_config_irq(ispif, intf, vfe, 1);
648 ispif_set_intf_cmd(ispif, CMD_ENABLE_FRAME_BOUNDARY,
649 intf, vfe, vc);
650 } else {
651 mutex_lock(&ispif->config_lock);
652 ispif_set_intf_cmd(ispif, CMD_DISABLE_FRAME_BOUNDARY,
653 intf, vfe, vc);
654 mutex_unlock(&ispif->config_lock);
655
656 ret = ispif_wait_for_stop(ispif, intf, vfe);
657 if (ret < 0)
658 return ret;
659
660 mutex_lock(&ispif->config_lock);
661 ispif_config_irq(ispif, intf, vfe, 0);
662 ispif_select_cid(ispif, intf, cid, vfe, 0);
663 ispif_select_csid(ispif, intf, csid, vfe, 0);
664 ispif_select_clk_mux(ispif, intf, csid, vfe, 0);
665 }
666
667 mutex_unlock(&ispif->config_lock);
668
669 return 0;
670}
671
672/*
673 * __ispif_get_format - Get pointer to format structure
674 * @ispif: ISPIF line
675 * @cfg: V4L2 subdev pad configuration
676 * @pad: pad from which format is requested
677 * @which: TRY or ACTIVE format
678 *
679 * Return pointer to TRY or ACTIVE format structure
680 */
681static struct v4l2_mbus_framefmt *
682__ispif_get_format(struct ispif_line *line,
683 struct v4l2_subdev_pad_config *cfg,
684 unsigned int pad,
685 enum v4l2_subdev_format_whence which)
686{
687 if (which == V4L2_SUBDEV_FORMAT_TRY)
688 return v4l2_subdev_get_try_format(&line->subdev, cfg, pad);
689
690 return &line->fmt[pad];
691}
692
693/*
694 * ispif_try_format - Handle try format by pad subdev method
695 * @ispif: ISPIF line
696 * @cfg: V4L2 subdev pad configuration
697 * @pad: pad on which format is requested
698 * @fmt: pointer to v4l2 format structure
699 * @which: wanted subdev format
700 */
701static void ispif_try_format(struct ispif_line *line,
702 struct v4l2_subdev_pad_config *cfg,
703 unsigned int pad,
704 struct v4l2_mbus_framefmt *fmt,
705 enum v4l2_subdev_format_whence which)
706{
707 unsigned int i;
708
709 switch (pad) {
710 case MSM_ISPIF_PAD_SINK:
711 /* Set format on sink pad */
712
713 for (i = 0; i < ARRAY_SIZE(ispif_formats); i++)
714 if (fmt->code == ispif_formats[i])
715 break;
716
717 /* If not found, use UYVY as default */
718 if (i >= ARRAY_SIZE(ispif_formats))
719 fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
720
721 fmt->width = clamp_t(u32, fmt->width, 1, 8191);
722 fmt->height = clamp_t(u32, fmt->height, 1, 8191);
723
724 fmt->field = V4L2_FIELD_NONE;
725 fmt->colorspace = V4L2_COLORSPACE_SRGB;
726
727 break;
728
729 case MSM_ISPIF_PAD_SRC:
730 /* Set and return a format same as sink pad */
731
732 *fmt = *__ispif_get_format(line, cfg, MSM_ISPIF_PAD_SINK,
733 which);
734
735 break;
736 }
737
738 fmt->colorspace = V4L2_COLORSPACE_SRGB;
739}
740
741/*
742 * ispif_enum_mbus_code - Handle pixel format enumeration
743 * @sd: ISPIF V4L2 subdevice
744 * @cfg: V4L2 subdev pad configuration
745 * @code: pointer to v4l2_subdev_mbus_code_enum structure
746 * return -EINVAL or zero on success
747 */
748static int ispif_enum_mbus_code(struct v4l2_subdev *sd,
749 struct v4l2_subdev_pad_config *cfg,
750 struct v4l2_subdev_mbus_code_enum *code)
751{
752 struct ispif_line *line = v4l2_get_subdevdata(sd);
753 struct v4l2_mbus_framefmt *format;
754
755 if (code->pad == MSM_ISPIF_PAD_SINK) {
756 if (code->index >= ARRAY_SIZE(ispif_formats))
757 return -EINVAL;
758
759 code->code = ispif_formats[code->index];
760 } else {
761 if (code->index > 0)
762 return -EINVAL;
763
764 format = __ispif_get_format(line, cfg, MSM_ISPIF_PAD_SINK,
765 code->which);
766
767 code->code = format->code;
768 }
769
770 return 0;
771}
772
773/*
774 * ispif_enum_frame_size - Handle frame size enumeration
775 * @sd: ISPIF V4L2 subdevice
776 * @cfg: V4L2 subdev pad configuration
777 * @fse: pointer to v4l2_subdev_frame_size_enum structure
778 * return -EINVAL or zero on success
779 */
780static int ispif_enum_frame_size(struct v4l2_subdev *sd,
781 struct v4l2_subdev_pad_config *cfg,
782 struct v4l2_subdev_frame_size_enum *fse)
783{
784 struct ispif_line *line = v4l2_get_subdevdata(sd);
785 struct v4l2_mbus_framefmt format;
786
787 if (fse->index != 0)
788 return -EINVAL;
789
790 format.code = fse->code;
791 format.width = 1;
792 format.height = 1;
793 ispif_try_format(line, cfg, fse->pad, &format, fse->which);
794 fse->min_width = format.width;
795 fse->min_height = format.height;
796
797 if (format.code != fse->code)
798 return -EINVAL;
799
800 format.code = fse->code;
801 format.width = -1;
802 format.height = -1;
803 ispif_try_format(line, cfg, fse->pad, &format, fse->which);
804 fse->max_width = format.width;
805 fse->max_height = format.height;
806
807 return 0;
808}
809
810/*
811 * ispif_get_format - Handle get format by pads subdev method
812 * @sd: ISPIF V4L2 subdevice
813 * @cfg: V4L2 subdev pad configuration
814 * @fmt: pointer to v4l2 subdev format structure
815 *
816 * Return -EINVAL or zero on success
817 */
818static int ispif_get_format(struct v4l2_subdev *sd,
819 struct v4l2_subdev_pad_config *cfg,
820 struct v4l2_subdev_format *fmt)
821{
822 struct ispif_line *line = v4l2_get_subdevdata(sd);
823 struct v4l2_mbus_framefmt *format;
824
825 format = __ispif_get_format(line, cfg, fmt->pad, fmt->which);
826 if (format == NULL)
827 return -EINVAL;
828
829 fmt->format = *format;
830
831 return 0;
832}
833
834/*
835 * ispif_set_format - Handle set format by pads subdev method
836 * @sd: ISPIF V4L2 subdevice
837 * @cfg: V4L2 subdev pad configuration
838 * @fmt: pointer to v4l2 subdev format structure
839 *
840 * Return -EINVAL or zero on success
841 */
842static int ispif_set_format(struct v4l2_subdev *sd,
843 struct v4l2_subdev_pad_config *cfg,
844 struct v4l2_subdev_format *fmt)
845{
846 struct ispif_line *line = v4l2_get_subdevdata(sd);
847 struct v4l2_mbus_framefmt *format;
848
849 format = __ispif_get_format(line, cfg, fmt->pad, fmt->which);
850 if (format == NULL)
851 return -EINVAL;
852
853 ispif_try_format(line, cfg, fmt->pad, &fmt->format, fmt->which);
854 *format = fmt->format;
855
856 /* Propagate the format from sink to source */
857 if (fmt->pad == MSM_ISPIF_PAD_SINK) {
858 format = __ispif_get_format(line, cfg, MSM_ISPIF_PAD_SRC,
859 fmt->which);
860
861 *format = fmt->format;
862 ispif_try_format(line, cfg, MSM_ISPIF_PAD_SRC, format,
863 fmt->which);
864 }
865
866 return 0;
867}
868
869/*
870 * ispif_init_formats - Initialize formats on all pads
871 * @sd: ISPIF V4L2 subdevice
872 * @fh: V4L2 subdev file handle
873 *
874 * Initialize all pad formats with default values.
875 *
876 * Return 0 on success or a negative error code otherwise
877 */
878static int ispif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
879{
880 struct v4l2_subdev_format format = {
881 .pad = MSM_ISPIF_PAD_SINK,
882 .which = fh ? V4L2_SUBDEV_FORMAT_TRY :
883 V4L2_SUBDEV_FORMAT_ACTIVE,
884 .format = {
885 .code = MEDIA_BUS_FMT_UYVY8_2X8,
886 .width = 1920,
887 .height = 1080
888 }
889 };
890
891 return ispif_set_format(sd, fh ? fh->pad : NULL, &format);
892}
893
894/*
895 * msm_ispif_subdev_init - Initialize ISPIF device structure and resources
896 * @ispif: ISPIF device
897 * @res: ISPIF module resources table
898 *
899 * Return 0 on success or a negative error code otherwise
900 */
901int msm_ispif_subdev_init(struct ispif_device *ispif,
902 const struct resources_ispif *res)
903{
904 struct device *dev = to_device(ispif);
905 struct platform_device *pdev = to_platform_device(dev);
906 struct resource *r;
907 int i;
908 int ret;
909
910 /* Memory */
911
912 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, res->reg[0]);
913 ispif->base = devm_ioremap_resource(dev, r);
914 if (IS_ERR(ispif->base)) {
915 dev_err(dev, "could not map memory\n");
916 return PTR_ERR(ispif->base);
917 }
918
919 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, res->reg[1]);
920 ispif->base_clk_mux = devm_ioremap_resource(dev, r);
921 if (IS_ERR(ispif->base_clk_mux)) {
922 dev_err(dev, "could not map memory\n");
923 return PTR_ERR(ispif->base_clk_mux);
924 }
925
926 /* Interrupt */
927
928 r = platform_get_resource_byname(pdev, IORESOURCE_IRQ, res->interrupt);
929
930 if (!r) {
931 dev_err(dev, "missing IRQ\n");
932 return -EINVAL;
933 }
934
935 ispif->irq = r->start;
936 snprintf(ispif->irq_name, sizeof(ispif->irq_name), "%s_%s",
937 dev_name(dev), MSM_ISPIF_NAME);
938 ret = devm_request_irq(dev, ispif->irq, ispif_isr,
939 IRQF_TRIGGER_RISING, ispif->irq_name, ispif);
940 if (ret < 0) {
941 dev_err(dev, "request_irq failed: %d\n", ret);
942 return ret;
943 }
944
945 /* Clocks */
946
947 ispif->nclocks = 0;
948 while (res->clock[ispif->nclocks])
949 ispif->nclocks++;
950
951 ispif->clock = devm_kzalloc(dev, ispif->nclocks * sizeof(*ispif->clock),
952 GFP_KERNEL);
953 if (!ispif->clock)
954 return -ENOMEM;
955
956 for (i = 0; i < ispif->nclocks; i++) {
957 struct camss_clock *clock = &ispif->clock[i];
958
959 clock->clk = devm_clk_get(dev, res->clock[i]);
960 if (IS_ERR(clock->clk))
961 return PTR_ERR(clock->clk);
962
963 clock->freq = NULL;
964 clock->nfreqs = 0;
965 }
966
967 ispif->nclocks_for_reset = 0;
968 while (res->clock_for_reset[ispif->nclocks_for_reset])
969 ispif->nclocks_for_reset++;
970
971 ispif->clock_for_reset = devm_kzalloc(dev, ispif->nclocks_for_reset *
972 sizeof(*ispif->clock_for_reset), GFP_KERNEL);
973 if (!ispif->clock_for_reset)
974 return -ENOMEM;
975
976 for (i = 0; i < ispif->nclocks_for_reset; i++) {
977 struct camss_clock *clock = &ispif->clock_for_reset[i];
978
979 clock->clk = devm_clk_get(dev, res->clock_for_reset[i]);
980 if (IS_ERR(clock->clk))
981 return PTR_ERR(clock->clk);
982
983 clock->freq = NULL;
984 clock->nfreqs = 0;
985 }
986
987 for (i = 0; i < ARRAY_SIZE(ispif->line); i++)
988 ispif->line[i].id = i;
989
990 mutex_init(&ispif->power_lock);
991 ispif->power_count = 0;
992
993 mutex_init(&ispif->config_lock);
994
995 init_completion(&ispif->reset_complete);
996
997 return 0;
998}
999
1000/*
1001 * ispif_get_intf - Get ISPIF interface to use by VFE line id
1002 * @line_id: VFE line id that the ISPIF line is connected to
1003 *
1004 * Return ISPIF interface to use
1005 */
1006static enum ispif_intf ispif_get_intf(enum vfe_line_id line_id)
1007{
1008 switch (line_id) {
1009 case (VFE_LINE_RDI0):
1010 return RDI0;
1011 case (VFE_LINE_RDI1):
1012 return RDI1;
1013 case (VFE_LINE_RDI2):
1014 return RDI2;
1015 case (VFE_LINE_PIX):
1016 return PIX0;
1017 default:
1018 return RDI0;
1019 }
1020}
1021
1022/*
1023 * ispif_link_setup - Setup ISPIF connections
1024 * @entity: Pointer to media entity structure
1025 * @local: Pointer to local pad
1026 * @remote: Pointer to remote pad
1027 * @flags: Link flags
1028 *
1029 * Return 0 on success
1030 */
1031static int ispif_link_setup(struct media_entity *entity,
1032 const struct media_pad *local,
1033 const struct media_pad *remote, u32 flags)
1034{
1035 if (flags & MEDIA_LNK_FL_ENABLED) {
1036 if (media_entity_remote_pad(local))
1037 return -EBUSY;
1038
1039 if (local->flags & MEDIA_PAD_FL_SINK) {
1040 struct v4l2_subdev *sd;
1041 struct ispif_line *line;
1042
1043 sd = media_entity_to_v4l2_subdev(entity);
1044 line = v4l2_get_subdevdata(sd);
1045
1046 msm_csid_get_csid_id(remote->entity, &line->csid_id);
1047 } else { /* MEDIA_PAD_FL_SOURCE */
1048 struct v4l2_subdev *sd;
1049 struct ispif_line *line;
1050 enum vfe_line_id id;
1051
1052 sd = media_entity_to_v4l2_subdev(entity);
1053 line = v4l2_get_subdevdata(sd);
1054
1055 msm_vfe_get_vfe_id(remote->entity, &line->vfe_id);
1056 msm_vfe_get_vfe_line_id(remote->entity, &id);
1057 line->interface = ispif_get_intf(id);
1058 }
1059 }
1060
1061 return 0;
1062}
1063
1064static const struct v4l2_subdev_core_ops ispif_core_ops = {
1065 .s_power = ispif_set_power,
1066};
1067
1068static const struct v4l2_subdev_video_ops ispif_video_ops = {
1069 .s_stream = ispif_set_stream,
1070};
1071
1072static const struct v4l2_subdev_pad_ops ispif_pad_ops = {
1073 .enum_mbus_code = ispif_enum_mbus_code,
1074 .enum_frame_size = ispif_enum_frame_size,
1075 .get_fmt = ispif_get_format,
1076 .set_fmt = ispif_set_format,
1077};
1078
1079static const struct v4l2_subdev_ops ispif_v4l2_ops = {
1080 .core = &ispif_core_ops,
1081 .video = &ispif_video_ops,
1082 .pad = &ispif_pad_ops,
1083};
1084
1085static const struct v4l2_subdev_internal_ops ispif_v4l2_internal_ops = {
1086 .open = ispif_init_formats,
1087};
1088
1089static const struct media_entity_operations ispif_media_ops = {
1090 .link_setup = ispif_link_setup,
1091 .link_validate = v4l2_subdev_link_validate,
1092};
1093
1094/*
1095 * msm_ispif_register_entities - Register subdev node for ISPIF module
1096 * @ispif: ISPIF device
1097 * @v4l2_dev: V4L2 device
1098 *
1099 * Return 0 on success or a negative error code otherwise
1100 */
1101int msm_ispif_register_entities(struct ispif_device *ispif,
1102 struct v4l2_device *v4l2_dev)
1103{
1104 struct device *dev = to_device(ispif);
1105 int ret;
1106 int i;
1107
1108 for (i = 0; i < ARRAY_SIZE(ispif->line); i++) {
1109 struct v4l2_subdev *sd = &ispif->line[i].subdev;
1110 struct media_pad *pads = ispif->line[i].pads;
1111
1112 v4l2_subdev_init(sd, &ispif_v4l2_ops);
1113 sd->internal_ops = &ispif_v4l2_internal_ops;
1114 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
1115 snprintf(sd->name, ARRAY_SIZE(sd->name), "%s%d",
1116 MSM_ISPIF_NAME, i);
1117 v4l2_set_subdevdata(sd, &ispif->line[i]);
1118
1119 ret = ispif_init_formats(sd, NULL);
1120 if (ret < 0) {
1121 dev_err(dev, "Failed to init format: %d\n", ret);
1122 goto error;
1123 }
1124
1125 pads[MSM_ISPIF_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
1126 pads[MSM_ISPIF_PAD_SRC].flags = MEDIA_PAD_FL_SOURCE;
1127
1128 sd->entity.function = MEDIA_ENT_F_IO_V4L;
1129 sd->entity.ops = &ispif_media_ops;
1130 ret = media_entity_pads_init(&sd->entity, MSM_ISPIF_PADS_NUM,
1131 pads);
1132 if (ret < 0) {
1133 dev_err(dev, "Failed to init media entity: %d\n", ret);
1134 goto error;
1135 }
1136
1137 ret = v4l2_device_register_subdev(v4l2_dev, sd);
1138 if (ret < 0) {
1139 dev_err(dev, "Failed to register subdev: %d\n", ret);
1140 media_entity_cleanup(&sd->entity);
1141 goto error;
1142 }
1143 }
1144
1145 return 0;
1146
1147error:
1148 for (i--; i >= 0; i--) {
1149 struct v4l2_subdev *sd = &ispif->line[i].subdev;
1150
1151 v4l2_device_unregister_subdev(sd);
1152 media_entity_cleanup(&sd->entity);
1153 }
1154
1155 return ret;
1156}
1157
1158/*
1159 * msm_ispif_unregister_entities - Unregister ISPIF module subdev node
1160 * @ispif: ISPIF device
1161 */
1162void msm_ispif_unregister_entities(struct ispif_device *ispif)
1163{
1164 int i;
1165
1166 mutex_destroy(&ispif->power_lock);
1167 mutex_destroy(&ispif->config_lock);
1168
1169 for (i = 0; i < ARRAY_SIZE(ispif->line); i++) {
1170 struct v4l2_subdev *sd = &ispif->line[i].subdev;
1171
1172 v4l2_device_unregister_subdev(sd);
1173 media_entity_cleanup(&sd->entity);
1174 }
1175}
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-ispif.h b/drivers/media/platform/qcom/camss-8x16/camss-ispif.h
new file mode 100644
index 000000000000..f668306020c3
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/camss-ispif.h
@@ -0,0 +1,85 @@
1/*
2 * camss-ispif.h
3 *
4 * Qualcomm MSM Camera Subsystem - ISPIF (ISP Interface) Module
5 *
6 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
7 * Copyright (C) 2015-2017 Linaro Ltd.
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 version 2 and
11 * only version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18#ifndef QC_MSM_CAMSS_ISPIF_H
19#define QC_MSM_CAMSS_ISPIF_H
20
21#include <linux/clk.h>
22#include <media/media-entity.h>
23#include <media/v4l2-device.h>
24#include <media/v4l2-subdev.h>
25
26/* Number of ISPIF lines - same as number of CSID hardware modules */
27#define MSM_ISPIF_LINE_NUM 2
28
29#define MSM_ISPIF_PAD_SINK 0
30#define MSM_ISPIF_PAD_SRC 1
31#define MSM_ISPIF_PADS_NUM 2
32
33#define MSM_ISPIF_VFE_NUM 1
34
35enum ispif_intf {
36 PIX0,
37 RDI0,
38 PIX1,
39 RDI1,
40 RDI2
41};
42
43struct ispif_intf_cmd_reg {
44 u32 cmd_0;
45 u32 cmd_1;
46};
47
48struct ispif_line {
49 u8 id;
50 u8 csid_id;
51 u8 vfe_id;
52 enum ispif_intf interface;
53 struct v4l2_subdev subdev;
54 struct media_pad pads[MSM_ISPIF_PADS_NUM];
55 struct v4l2_mbus_framefmt fmt[MSM_ISPIF_PADS_NUM];
56};
57
58struct ispif_device {
59 void __iomem *base;
60 void __iomem *base_clk_mux;
61 u32 irq;
62 char irq_name[30];
63 struct camss_clock *clock;
64 int nclocks;
65 struct camss_clock *clock_for_reset;
66 int nclocks_for_reset;
67 struct completion reset_complete;
68 int power_count;
69 struct mutex power_lock;
70 struct ispif_intf_cmd_reg intf_cmd[MSM_ISPIF_VFE_NUM];
71 struct mutex config_lock;
72 struct ispif_line line[MSM_ISPIF_LINE_NUM];
73};
74
75struct resources_ispif;
76
77int msm_ispif_subdev_init(struct ispif_device *ispif,
78 const struct resources_ispif *res);
79
80int msm_ispif_register_entities(struct ispif_device *ispif,
81 struct v4l2_device *v4l2_dev);
82
83void msm_ispif_unregister_entities(struct ispif_device *ispif);
84
85#endif /* QC_MSM_CAMSS_ISPIF_H */
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-vfe.c b/drivers/media/platform/qcom/camss-8x16/camss-vfe.c
new file mode 100644
index 000000000000..b21b3c2dc77f
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/camss-vfe.c
@@ -0,0 +1,3088 @@
1/*
2 * camss-vfe.c
3 *
4 * Qualcomm MSM Camera Subsystem - VFE (Video Front End) Module
5 *
6 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
7 * Copyright (C) 2015-2017 Linaro Ltd.
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 version 2 and
11 * only version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18#include <linux/clk.h>
19#include <linux/completion.h>
20#include <linux/interrupt.h>
21#include <linux/iommu.h>
22#include <linux/iopoll.h>
23#include <linux/mutex.h>
24#include <linux/of.h>
25#include <linux/platform_device.h>
26#include <linux/spinlock_types.h>
27#include <linux/spinlock.h>
28#include <media/media-entity.h>
29#include <media/v4l2-device.h>
30#include <media/v4l2-subdev.h>
31
32#include "camss-vfe.h"
33#include "camss.h"
34
35#define MSM_VFE_NAME "msm_vfe"
36
37#define vfe_line_array(ptr_line) \
38 ((const struct vfe_line (*)[]) &(ptr_line[-(ptr_line->id)]))
39
40#define to_vfe(ptr_line) \
41 container_of(vfe_line_array(ptr_line), struct vfe_device, ptr_line)
42
43#define VFE_0_HW_VERSION 0x000
44
45#define VFE_0_GLOBAL_RESET_CMD 0x00c
46#define VFE_0_GLOBAL_RESET_CMD_CORE (1 << 0)
47#define VFE_0_GLOBAL_RESET_CMD_CAMIF (1 << 1)
48#define VFE_0_GLOBAL_RESET_CMD_BUS (1 << 2)
49#define VFE_0_GLOBAL_RESET_CMD_BUS_BDG (1 << 3)
50#define VFE_0_GLOBAL_RESET_CMD_REGISTER (1 << 4)
51#define VFE_0_GLOBAL_RESET_CMD_TIMER (1 << 5)
52#define VFE_0_GLOBAL_RESET_CMD_PM (1 << 6)
53#define VFE_0_GLOBAL_RESET_CMD_BUS_MISR (1 << 7)
54#define VFE_0_GLOBAL_RESET_CMD_TESTGEN (1 << 8)
55
56#define VFE_0_MODULE_CFG 0x018
57#define VFE_0_MODULE_CFG_DEMUX (1 << 2)
58#define VFE_0_MODULE_CFG_CHROMA_UPSAMPLE (1 << 3)
59#define VFE_0_MODULE_CFG_SCALE_ENC (1 << 23)
60#define VFE_0_MODULE_CFG_CROP_ENC (1 << 27)
61
62#define VFE_0_CORE_CFG 0x01c
63#define VFE_0_CORE_CFG_PIXEL_PATTERN_YCBYCR 0x4
64#define VFE_0_CORE_CFG_PIXEL_PATTERN_YCRYCB 0x5
65#define VFE_0_CORE_CFG_PIXEL_PATTERN_CBYCRY 0x6
66#define VFE_0_CORE_CFG_PIXEL_PATTERN_CRYCBY 0x7
67
68#define VFE_0_IRQ_CMD 0x024
69#define VFE_0_IRQ_CMD_GLOBAL_CLEAR (1 << 0)
70
71#define VFE_0_IRQ_MASK_0 0x028
72#define VFE_0_IRQ_MASK_0_CAMIF_SOF (1 << 0)
73#define VFE_0_IRQ_MASK_0_CAMIF_EOF (1 << 1)
74#define VFE_0_IRQ_MASK_0_RDIn_REG_UPDATE(n) (1 << ((n) + 5))
75#define VFE_0_IRQ_MASK_0_line_n_REG_UPDATE(n) \
76 ((n) == VFE_LINE_PIX ? (1 << 4) : VFE_0_IRQ_MASK_0_RDIn_REG_UPDATE(n))
77#define VFE_0_IRQ_MASK_0_IMAGE_MASTER_n_PING_PONG(n) (1 << ((n) + 8))
78#define VFE_0_IRQ_MASK_0_IMAGE_COMPOSITE_DONE_n(n) (1 << ((n) + 25))
79#define VFE_0_IRQ_MASK_0_RESET_ACK (1 << 31)
80#define VFE_0_IRQ_MASK_1 0x02c
81#define VFE_0_IRQ_MASK_1_CAMIF_ERROR (1 << 0)
82#define VFE_0_IRQ_MASK_1_VIOLATION (1 << 7)
83#define VFE_0_IRQ_MASK_1_BUS_BDG_HALT_ACK (1 << 8)
84#define VFE_0_IRQ_MASK_1_IMAGE_MASTER_n_BUS_OVERFLOW(n) (1 << ((n) + 9))
85#define VFE_0_IRQ_MASK_1_RDIn_SOF(n) (1 << ((n) + 29))
86
87#define VFE_0_IRQ_CLEAR_0 0x030
88#define VFE_0_IRQ_CLEAR_1 0x034
89
90#define VFE_0_IRQ_STATUS_0 0x038
91#define VFE_0_IRQ_STATUS_0_CAMIF_SOF (1 << 0)
92#define VFE_0_IRQ_STATUS_0_RDIn_REG_UPDATE(n) (1 << ((n) + 5))
93#define VFE_0_IRQ_STATUS_0_line_n_REG_UPDATE(n) \
94 ((n) == VFE_LINE_PIX ? (1 << 4) : VFE_0_IRQ_STATUS_0_RDIn_REG_UPDATE(n))
95#define VFE_0_IRQ_STATUS_0_IMAGE_MASTER_n_PING_PONG(n) (1 << ((n) + 8))
96#define VFE_0_IRQ_STATUS_0_IMAGE_COMPOSITE_DONE_n(n) (1 << ((n) + 25))
97#define VFE_0_IRQ_STATUS_0_RESET_ACK (1 << 31)
98#define VFE_0_IRQ_STATUS_1 0x03c
99#define VFE_0_IRQ_STATUS_1_VIOLATION (1 << 7)
100#define VFE_0_IRQ_STATUS_1_BUS_BDG_HALT_ACK (1 << 8)
101#define VFE_0_IRQ_STATUS_1_RDIn_SOF(n) (1 << ((n) + 29))
102
103#define VFE_0_IRQ_COMPOSITE_MASK_0 0x40
104#define VFE_0_VIOLATION_STATUS 0x48
105
106#define VFE_0_BUS_CMD 0x4c
107#define VFE_0_BUS_CMD_Mx_RLD_CMD(x) (1 << (x))
108
109#define VFE_0_BUS_CFG 0x050
110
111#define VFE_0_BUS_XBAR_CFG_x(x) (0x58 + 0x4 * ((x) / 2))
112#define VFE_0_BUS_XBAR_CFG_x_M_PAIR_STREAM_EN (1 << 1)
113#define VFE_0_BUS_XBAR_CFG_x_M_PAIR_STREAM_SWAP_INTER_INTRA (0x3 << 4)
114#define VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_SHIFT 8
115#define VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_LUMA 0
116#define VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_VAL_RDI0 5
117#define VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_VAL_RDI1 6
118#define VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_VAL_RDI2 7
119
120#define VFE_0_BUS_IMAGE_MASTER_n_WR_CFG(n) (0x06c + 0x24 * (n))
121#define VFE_0_BUS_IMAGE_MASTER_n_WR_CFG_WR_PATH_SHIFT 0
122#define VFE_0_BUS_IMAGE_MASTER_n_WR_CFG_FRM_BASED_SHIFT 1
123#define VFE_0_BUS_IMAGE_MASTER_n_WR_PING_ADDR(n) (0x070 + 0x24 * (n))
124#define VFE_0_BUS_IMAGE_MASTER_n_WR_PONG_ADDR(n) (0x074 + 0x24 * (n))
125#define VFE_0_BUS_IMAGE_MASTER_n_WR_ADDR_CFG(n) (0x078 + 0x24 * (n))
126#define VFE_0_BUS_IMAGE_MASTER_n_WR_ADDR_CFG_FRM_DROP_PER_SHIFT 2
127#define VFE_0_BUS_IMAGE_MASTER_n_WR_ADDR_CFG_FRM_DROP_PER_MASK (0x1F << 2)
128
129#define VFE_0_BUS_IMAGE_MASTER_n_WR_UB_CFG(n) (0x07c + 0x24 * (n))
130#define VFE_0_BUS_IMAGE_MASTER_n_WR_UB_CFG_OFFSET_SHIFT 16
131#define VFE_0_BUS_IMAGE_MASTER_n_WR_IMAGE_SIZE(n) (0x080 + 0x24 * (n))
132#define VFE_0_BUS_IMAGE_MASTER_n_WR_BUFFER_CFG(n) (0x084 + 0x24 * (n))
133#define VFE_0_BUS_IMAGE_MASTER_n_WR_FRAMEDROP_PATTERN(n) \
134 (0x088 + 0x24 * (n))
135#define VFE_0_BUS_IMAGE_MASTER_n_WR_IRQ_SUBSAMPLE_PATTERN(n) \
136 (0x08c + 0x24 * (n))
137#define VFE_0_BUS_IMAGE_MASTER_n_WR_IRQ_SUBSAMPLE_PATTERN_DEF 0xffffffff
138
139#define VFE_0_BUS_PING_PONG_STATUS 0x268
140
141#define VFE_0_BUS_BDG_CMD 0x2c0
142#define VFE_0_BUS_BDG_CMD_HALT_REQ 1
143
144#define VFE_0_BUS_BDG_QOS_CFG_0 0x2c4
145#define VFE_0_BUS_BDG_QOS_CFG_0_CFG 0xaaa5aaa5
146#define VFE_0_BUS_BDG_QOS_CFG_1 0x2c8
147#define VFE_0_BUS_BDG_QOS_CFG_2 0x2cc
148#define VFE_0_BUS_BDG_QOS_CFG_3 0x2d0
149#define VFE_0_BUS_BDG_QOS_CFG_4 0x2d4
150#define VFE_0_BUS_BDG_QOS_CFG_5 0x2d8
151#define VFE_0_BUS_BDG_QOS_CFG_6 0x2dc
152#define VFE_0_BUS_BDG_QOS_CFG_7 0x2e0
153#define VFE_0_BUS_BDG_QOS_CFG_7_CFG 0x0001aaa5
154
155#define VFE_0_RDI_CFG_x(x) (0x2e8 + (0x4 * (x)))
156#define VFE_0_RDI_CFG_x_RDI_STREAM_SEL_SHIFT 28
157#define VFE_0_RDI_CFG_x_RDI_STREAM_SEL_MASK (0xf << 28)
158#define VFE_0_RDI_CFG_x_RDI_M0_SEL_SHIFT 4
159#define VFE_0_RDI_CFG_x_RDI_M0_SEL_MASK (0xf << 4)
160#define VFE_0_RDI_CFG_x_RDI_EN_BIT (1 << 2)
161#define VFE_0_RDI_CFG_x_MIPI_EN_BITS 0x3
162#define VFE_0_RDI_CFG_x_RDI_Mr_FRAME_BASED_EN(r) (1 << (16 + (r)))
163
164#define VFE_0_CAMIF_CMD 0x2f4
165#define VFE_0_CAMIF_CMD_DISABLE_FRAME_BOUNDARY 0
166#define VFE_0_CAMIF_CMD_ENABLE_FRAME_BOUNDARY 1
167#define VFE_0_CAMIF_CMD_CLEAR_CAMIF_STATUS (1 << 2)
168#define VFE_0_CAMIF_CFG 0x2f8
169#define VFE_0_CAMIF_CFG_VFE_OUTPUT_EN (1 << 6)
170#define VFE_0_CAMIF_FRAME_CFG 0x300
171#define VFE_0_CAMIF_WINDOW_WIDTH_CFG 0x304
172#define VFE_0_CAMIF_WINDOW_HEIGHT_CFG 0x308
173#define VFE_0_CAMIF_SUBSAMPLE_CFG_0 0x30c
174#define VFE_0_CAMIF_IRQ_SUBSAMPLE_PATTERN 0x314
175#define VFE_0_CAMIF_STATUS 0x31c
176#define VFE_0_CAMIF_STATUS_HALT (1 << 31)
177
178#define VFE_0_REG_UPDATE 0x378
179#define VFE_0_REG_UPDATE_RDIn(n) (1 << (1 + (n)))
180#define VFE_0_REG_UPDATE_line_n(n) \
181 ((n) == VFE_LINE_PIX ? 1 : VFE_0_REG_UPDATE_RDIn(n))
182
183#define VFE_0_DEMUX_CFG 0x424
184#define VFE_0_DEMUX_CFG_PERIOD 0x3
185#define VFE_0_DEMUX_GAIN_0 0x428
186#define VFE_0_DEMUX_GAIN_0_CH0_EVEN (0x80 << 0)
187#define VFE_0_DEMUX_GAIN_0_CH0_ODD (0x80 << 16)
188#define VFE_0_DEMUX_GAIN_1 0x42c
189#define VFE_0_DEMUX_GAIN_1_CH1 (0x80 << 0)
190#define VFE_0_DEMUX_GAIN_1_CH2 (0x80 << 16)
191#define VFE_0_DEMUX_EVEN_CFG 0x438
192#define VFE_0_DEMUX_EVEN_CFG_PATTERN_YUYV 0x9cac
193#define VFE_0_DEMUX_EVEN_CFG_PATTERN_YVYU 0xac9c
194#define VFE_0_DEMUX_EVEN_CFG_PATTERN_UYVY 0xc9ca
195#define VFE_0_DEMUX_EVEN_CFG_PATTERN_VYUY 0xcac9
196#define VFE_0_DEMUX_ODD_CFG 0x43c
197#define VFE_0_DEMUX_ODD_CFG_PATTERN_YUYV 0x9cac
198#define VFE_0_DEMUX_ODD_CFG_PATTERN_YVYU 0xac9c
199#define VFE_0_DEMUX_ODD_CFG_PATTERN_UYVY 0xc9ca
200#define VFE_0_DEMUX_ODD_CFG_PATTERN_VYUY 0xcac9
201
202#define VFE_0_SCALE_ENC_Y_CFG 0x75c
203#define VFE_0_SCALE_ENC_Y_H_IMAGE_SIZE 0x760
204#define VFE_0_SCALE_ENC_Y_H_PHASE 0x764
205#define VFE_0_SCALE_ENC_Y_V_IMAGE_SIZE 0x76c
206#define VFE_0_SCALE_ENC_Y_V_PHASE 0x770
207#define VFE_0_SCALE_ENC_CBCR_CFG 0x778
208#define VFE_0_SCALE_ENC_CBCR_H_IMAGE_SIZE 0x77c
209#define VFE_0_SCALE_ENC_CBCR_H_PHASE 0x780
210#define VFE_0_SCALE_ENC_CBCR_V_IMAGE_SIZE 0x790
211#define VFE_0_SCALE_ENC_CBCR_V_PHASE 0x794
212
213#define VFE_0_CROP_ENC_Y_WIDTH 0x854
214#define VFE_0_CROP_ENC_Y_HEIGHT 0x858
215#define VFE_0_CROP_ENC_CBCR_WIDTH 0x85c
216#define VFE_0_CROP_ENC_CBCR_HEIGHT 0x860
217
218#define VFE_0_CLAMP_ENC_MAX_CFG 0x874
219#define VFE_0_CLAMP_ENC_MAX_CFG_CH0 (0xff << 0)
220#define VFE_0_CLAMP_ENC_MAX_CFG_CH1 (0xff << 8)
221#define VFE_0_CLAMP_ENC_MAX_CFG_CH2 (0xff << 16)
222#define VFE_0_CLAMP_ENC_MIN_CFG 0x878
223#define VFE_0_CLAMP_ENC_MIN_CFG_CH0 (0x0 << 0)
224#define VFE_0_CLAMP_ENC_MIN_CFG_CH1 (0x0 << 8)
225#define VFE_0_CLAMP_ENC_MIN_CFG_CH2 (0x0 << 16)
226
227#define VFE_0_CGC_OVERRIDE_1 0x974
228#define VFE_0_CGC_OVERRIDE_1_IMAGE_Mx_CGC_OVERRIDE(x) (1 << (x))
229
230/* VFE reset timeout */
231#define VFE_RESET_TIMEOUT_MS 50
232/* VFE halt timeout */
233#define VFE_HALT_TIMEOUT_MS 100
234/* Max number of frame drop updates per frame */
235#define VFE_FRAME_DROP_UPDATES 5
236/* Frame drop value. NOTE: VAL + UPDATES should not exceed 31 */
237#define VFE_FRAME_DROP_VAL 20
238
239#define VFE_NEXT_SOF_MS 500
240
241#define CAMIF_TIMEOUT_SLEEP_US 1000
242#define CAMIF_TIMEOUT_ALL_US 1000000
243
244#define SCALER_RATIO_MAX 16
245
246static const struct {
247 u32 code;
248 u8 bpp;
249} vfe_formats[] = {
250 {
251 MEDIA_BUS_FMT_UYVY8_2X8,
252 8,
253 },
254 {
255 MEDIA_BUS_FMT_VYUY8_2X8,
256 8,
257 },
258 {
259 MEDIA_BUS_FMT_YUYV8_2X8,
260 8,
261 },
262 {
263 MEDIA_BUS_FMT_YVYU8_2X8,
264 8,
265 },
266 {
267 MEDIA_BUS_FMT_SBGGR8_1X8,
268 8,
269 },
270 {
271 MEDIA_BUS_FMT_SGBRG8_1X8,
272 8,
273 },
274 {
275 MEDIA_BUS_FMT_SGRBG8_1X8,
276 8,
277 },
278 {
279 MEDIA_BUS_FMT_SRGGB8_1X8,
280 8,
281 },
282 {
283 MEDIA_BUS_FMT_SBGGR10_1X10,
284 10,
285 },
286 {
287 MEDIA_BUS_FMT_SGBRG10_1X10,
288 10,
289 },
290 {
291 MEDIA_BUS_FMT_SGRBG10_1X10,
292 10,
293 },
294 {
295 MEDIA_BUS_FMT_SRGGB10_1X10,
296 10,
297 },
298 {
299 MEDIA_BUS_FMT_SBGGR12_1X12,
300 12,
301 },
302 {
303 MEDIA_BUS_FMT_SGBRG12_1X12,
304 12,
305 },
306 {
307 MEDIA_BUS_FMT_SGRBG12_1X12,
308 12,
309 },
310 {
311 MEDIA_BUS_FMT_SRGGB12_1X12,
312 12,
313 }
314};
315
316/*
317 * vfe_get_bpp - map media bus format to bits per pixel
318 * @code: media bus format code
319 *
320 * Return number of bits per pixel
321 */
322static u8 vfe_get_bpp(u32 code)
323{
324 unsigned int i;
325
326 for (i = 0; i < ARRAY_SIZE(vfe_formats); i++)
327 if (code == vfe_formats[i].code)
328 return vfe_formats[i].bpp;
329
330 WARN(1, "Unknown format\n");
331
332 return vfe_formats[0].bpp;
333}
334
335static inline void vfe_reg_clr(struct vfe_device *vfe, u32 reg, u32 clr_bits)
336{
337 u32 bits = readl_relaxed(vfe->base + reg);
338
339 writel_relaxed(bits & ~clr_bits, vfe->base + reg);
340}
341
342static inline void vfe_reg_set(struct vfe_device *vfe, u32 reg, u32 set_bits)
343{
344 u32 bits = readl_relaxed(vfe->base + reg);
345
346 writel_relaxed(bits | set_bits, vfe->base + reg);
347}
348
349static void vfe_global_reset(struct vfe_device *vfe)
350{
351 u32 reset_bits = VFE_0_GLOBAL_RESET_CMD_TESTGEN |
352 VFE_0_GLOBAL_RESET_CMD_BUS_MISR |
353 VFE_0_GLOBAL_RESET_CMD_PM |
354 VFE_0_GLOBAL_RESET_CMD_TIMER |
355 VFE_0_GLOBAL_RESET_CMD_REGISTER |
356 VFE_0_GLOBAL_RESET_CMD_BUS_BDG |
357 VFE_0_GLOBAL_RESET_CMD_BUS |
358 VFE_0_GLOBAL_RESET_CMD_CAMIF |
359 VFE_0_GLOBAL_RESET_CMD_CORE;
360
361 writel_relaxed(reset_bits, vfe->base + VFE_0_GLOBAL_RESET_CMD);
362}
363
364static void vfe_wm_enable(struct vfe_device *vfe, u8 wm, u8 enable)
365{
366 if (enable)
367 vfe_reg_set(vfe, VFE_0_BUS_IMAGE_MASTER_n_WR_CFG(wm),
368 1 << VFE_0_BUS_IMAGE_MASTER_n_WR_CFG_WR_PATH_SHIFT);
369 else
370 vfe_reg_clr(vfe, VFE_0_BUS_IMAGE_MASTER_n_WR_CFG(wm),
371 1 << VFE_0_BUS_IMAGE_MASTER_n_WR_CFG_WR_PATH_SHIFT);
372}
373
374static void vfe_wm_frame_based(struct vfe_device *vfe, u8 wm, u8 enable)
375{
376 if (enable)
377 vfe_reg_set(vfe, VFE_0_BUS_IMAGE_MASTER_n_WR_CFG(wm),
378 1 << VFE_0_BUS_IMAGE_MASTER_n_WR_CFG_FRM_BASED_SHIFT);
379 else
380 vfe_reg_clr(vfe, VFE_0_BUS_IMAGE_MASTER_n_WR_CFG(wm),
381 1 << VFE_0_BUS_IMAGE_MASTER_n_WR_CFG_FRM_BASED_SHIFT);
382}
383
384#define CALC_WORD(width, M, N) (((width) * (M) + (N) - 1) / (N))
385
386static int vfe_word_per_line(uint32_t format, uint32_t pixel_per_line)
387{
388 int val = 0;
389
390 switch (format) {
391 case V4L2_PIX_FMT_NV12:
392 case V4L2_PIX_FMT_NV21:
393 case V4L2_PIX_FMT_NV16:
394 case V4L2_PIX_FMT_NV61:
395 val = CALC_WORD(pixel_per_line, 1, 8);
396 break;
397 case V4L2_PIX_FMT_YUYV:
398 case V4L2_PIX_FMT_YVYU:
399 case V4L2_PIX_FMT_UYVY:
400 case V4L2_PIX_FMT_VYUY:
401 val = CALC_WORD(pixel_per_line, 2, 8);
402 break;
403 }
404
405 return val;
406}
407
408static void vfe_get_wm_sizes(struct v4l2_pix_format_mplane *pix, u8 plane,
409 u16 *width, u16 *height, u16 *bytesperline)
410{
411 switch (pix->pixelformat) {
412 case V4L2_PIX_FMT_NV12:
413 case V4L2_PIX_FMT_NV21:
414 *width = pix->width;
415 *height = pix->height;
416 *bytesperline = pix->plane_fmt[0].bytesperline;
417 if (plane == 1)
418 *height /= 2;
419 break;
420 case V4L2_PIX_FMT_NV16:
421 case V4L2_PIX_FMT_NV61:
422 *width = pix->width;
423 *height = pix->height;
424 *bytesperline = pix->plane_fmt[0].bytesperline;
425 break;
426 }
427}
428
429static void vfe_wm_line_based(struct vfe_device *vfe, u32 wm,
430 struct v4l2_pix_format_mplane *pix,
431 u8 plane, u32 enable)
432{
433 u32 reg;
434
435 if (enable) {
436 u16 width = 0, height = 0, bytesperline = 0, wpl;
437
438 vfe_get_wm_sizes(pix, plane, &width, &height, &bytesperline);
439
440 wpl = vfe_word_per_line(pix->pixelformat, width);
441
442 reg = height - 1;
443 reg |= ((wpl + 1) / 2 - 1) << 16;
444
445 writel_relaxed(reg, vfe->base +
446 VFE_0_BUS_IMAGE_MASTER_n_WR_IMAGE_SIZE(wm));
447
448 wpl = vfe_word_per_line(pix->pixelformat, bytesperline);
449
450 reg = 0x3;
451 reg |= (height - 1) << 4;
452 reg |= wpl << 16;
453
454 writel_relaxed(reg, vfe->base +
455 VFE_0_BUS_IMAGE_MASTER_n_WR_BUFFER_CFG(wm));
456 } else {
457 writel_relaxed(0, vfe->base +
458 VFE_0_BUS_IMAGE_MASTER_n_WR_IMAGE_SIZE(wm));
459 writel_relaxed(0, vfe->base +
460 VFE_0_BUS_IMAGE_MASTER_n_WR_BUFFER_CFG(wm));
461 }
462}
463
464static void vfe_wm_set_framedrop_period(struct vfe_device *vfe, u8 wm, u8 per)
465{
466 u32 reg;
467
468 reg = readl_relaxed(vfe->base +
469 VFE_0_BUS_IMAGE_MASTER_n_WR_ADDR_CFG(wm));
470
471 reg &= ~(VFE_0_BUS_IMAGE_MASTER_n_WR_ADDR_CFG_FRM_DROP_PER_MASK);
472
473 reg |= (per << VFE_0_BUS_IMAGE_MASTER_n_WR_ADDR_CFG_FRM_DROP_PER_SHIFT)
474 & VFE_0_BUS_IMAGE_MASTER_n_WR_ADDR_CFG_FRM_DROP_PER_MASK;
475
476 writel_relaxed(reg,
477 vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_ADDR_CFG(wm));
478}
479
480static void vfe_wm_set_framedrop_pattern(struct vfe_device *vfe, u8 wm,
481 u32 pattern)
482{
483 writel_relaxed(pattern,
484 vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_FRAMEDROP_PATTERN(wm));
485}
486
487static void vfe_wm_set_ub_cfg(struct vfe_device *vfe, u8 wm, u16 offset,
488 u16 depth)
489{
490 u32 reg;
491
492 reg = (offset << VFE_0_BUS_IMAGE_MASTER_n_WR_UB_CFG_OFFSET_SHIFT) |
493 depth;
494 writel_relaxed(reg, vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_UB_CFG(wm));
495}
496
497static void vfe_bus_reload_wm(struct vfe_device *vfe, u8 wm)
498{
499 wmb();
500 writel_relaxed(VFE_0_BUS_CMD_Mx_RLD_CMD(wm), vfe->base + VFE_0_BUS_CMD);
501 wmb();
502}
503
504static void vfe_wm_set_ping_addr(struct vfe_device *vfe, u8 wm, u32 addr)
505{
506 writel_relaxed(addr,
507 vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_PING_ADDR(wm));
508}
509
510static void vfe_wm_set_pong_addr(struct vfe_device *vfe, u8 wm, u32 addr)
511{
512 writel_relaxed(addr,
513 vfe->base + VFE_0_BUS_IMAGE_MASTER_n_WR_PONG_ADDR(wm));
514}
515
516static int vfe_wm_get_ping_pong_status(struct vfe_device *vfe, u8 wm)
517{
518 u32 reg;
519
520 reg = readl_relaxed(vfe->base + VFE_0_BUS_PING_PONG_STATUS);
521
522 return (reg >> wm) & 0x1;
523}
524
525static void vfe_bus_enable_wr_if(struct vfe_device *vfe, u8 enable)
526{
527 if (enable)
528 writel_relaxed(0x10000009, vfe->base + VFE_0_BUS_CFG);
529 else
530 writel_relaxed(0, vfe->base + VFE_0_BUS_CFG);
531}
532
533static void vfe_bus_connect_wm_to_rdi(struct vfe_device *vfe, u8 wm,
534 enum vfe_line_id id)
535{
536 u32 reg;
537
538 reg = VFE_0_RDI_CFG_x_MIPI_EN_BITS;
539 reg |= VFE_0_RDI_CFG_x_RDI_Mr_FRAME_BASED_EN(id);
540 vfe_reg_set(vfe, VFE_0_RDI_CFG_x(0), reg);
541
542 reg = VFE_0_RDI_CFG_x_RDI_EN_BIT;
543 reg |= ((3 * id) << VFE_0_RDI_CFG_x_RDI_STREAM_SEL_SHIFT) &
544 VFE_0_RDI_CFG_x_RDI_STREAM_SEL_MASK;
545 vfe_reg_set(vfe, VFE_0_RDI_CFG_x(id), reg);
546
547 switch (id) {
548 case VFE_LINE_RDI0:
549 default:
550 reg = VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_VAL_RDI0 <<
551 VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_SHIFT;
552 break;
553 case VFE_LINE_RDI1:
554 reg = VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_VAL_RDI1 <<
555 VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_SHIFT;
556 break;
557 case VFE_LINE_RDI2:
558 reg = VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_VAL_RDI2 <<
559 VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_SHIFT;
560 break;
561 }
562
563 if (wm % 2 == 1)
564 reg <<= 16;
565
566 vfe_reg_set(vfe, VFE_0_BUS_XBAR_CFG_x(wm), reg);
567}
568
569static void vfe_wm_set_subsample(struct vfe_device *vfe, u8 wm)
570{
571 writel_relaxed(VFE_0_BUS_IMAGE_MASTER_n_WR_IRQ_SUBSAMPLE_PATTERN_DEF,
572 vfe->base +
573 VFE_0_BUS_IMAGE_MASTER_n_WR_IRQ_SUBSAMPLE_PATTERN(wm));
574}
575
576static void vfe_bus_disconnect_wm_from_rdi(struct vfe_device *vfe, u8 wm,
577 enum vfe_line_id id)
578{
579 u32 reg;
580
581 reg = VFE_0_RDI_CFG_x_RDI_Mr_FRAME_BASED_EN(id);
582 vfe_reg_clr(vfe, VFE_0_RDI_CFG_x(0), reg);
583
584 reg = VFE_0_RDI_CFG_x_RDI_EN_BIT;
585 vfe_reg_clr(vfe, VFE_0_RDI_CFG_x(id), reg);
586
587 switch (id) {
588 case VFE_LINE_RDI0:
589 default:
590 reg = VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_VAL_RDI0 <<
591 VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_SHIFT;
592 break;
593 case VFE_LINE_RDI1:
594 reg = VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_VAL_RDI1 <<
595 VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_SHIFT;
596 break;
597 case VFE_LINE_RDI2:
598 reg = VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_VAL_RDI2 <<
599 VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_SHIFT;
600 break;
601 }
602
603 if (wm % 2 == 1)
604 reg <<= 16;
605
606 vfe_reg_clr(vfe, VFE_0_BUS_XBAR_CFG_x(wm), reg);
607}
608
609static void vfe_set_xbar_cfg(struct vfe_device *vfe, struct vfe_output *output,
610 u8 enable)
611{
612 struct vfe_line *line = container_of(output, struct vfe_line, output);
613 u32 p = line->video_out.active_fmt.fmt.pix_mp.pixelformat;
614 u32 reg;
615 unsigned int i;
616
617 for (i = 0; i < output->wm_num; i++) {
618 if (i == 0) {
619 reg = VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_LUMA <<
620 VFE_0_BUS_XBAR_CFG_x_M_SINGLE_STREAM_SEL_SHIFT;
621 } else if (i == 1) {
622 reg = VFE_0_BUS_XBAR_CFG_x_M_PAIR_STREAM_EN;
623 if (p == V4L2_PIX_FMT_NV12 || p == V4L2_PIX_FMT_NV16)
624 reg |= VFE_0_BUS_XBAR_CFG_x_M_PAIR_STREAM_SWAP_INTER_INTRA;
625 }
626
627 if (output->wm_idx[i] % 2 == 1)
628 reg <<= 16;
629
630 if (enable)
631 vfe_reg_set(vfe,
632 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[i]),
633 reg);
634 else
635 vfe_reg_clr(vfe,
636 VFE_0_BUS_XBAR_CFG_x(output->wm_idx[i]),
637 reg);
638 }
639}
640
641static void vfe_set_rdi_cid(struct vfe_device *vfe, enum vfe_line_id id, u8 cid)
642{
643 vfe_reg_clr(vfe, VFE_0_RDI_CFG_x(id),
644 VFE_0_RDI_CFG_x_RDI_M0_SEL_MASK);
645
646 vfe_reg_set(vfe, VFE_0_RDI_CFG_x(id),
647 cid << VFE_0_RDI_CFG_x_RDI_M0_SEL_SHIFT);
648}
649
650static void vfe_reg_update(struct vfe_device *vfe, enum vfe_line_id line_id)
651{
652 vfe->reg_update |= VFE_0_REG_UPDATE_line_n(line_id);
653 wmb();
654 writel_relaxed(vfe->reg_update, vfe->base + VFE_0_REG_UPDATE);
655 wmb();
656}
657
658static void vfe_enable_irq_wm_line(struct vfe_device *vfe, u8 wm,
659 enum vfe_line_id line_id, u8 enable)
660{
661 u32 irq_en0 = VFE_0_IRQ_MASK_0_IMAGE_MASTER_n_PING_PONG(wm) |
662 VFE_0_IRQ_MASK_0_line_n_REG_UPDATE(line_id);
663 u32 irq_en1 = VFE_0_IRQ_MASK_1_IMAGE_MASTER_n_BUS_OVERFLOW(wm) |
664 VFE_0_IRQ_MASK_1_RDIn_SOF(line_id);
665
666 if (enable) {
667 vfe_reg_set(vfe, VFE_0_IRQ_MASK_0, irq_en0);
668 vfe_reg_set(vfe, VFE_0_IRQ_MASK_1, irq_en1);
669 } else {
670 vfe_reg_clr(vfe, VFE_0_IRQ_MASK_0, irq_en0);
671 vfe_reg_clr(vfe, VFE_0_IRQ_MASK_1, irq_en1);
672 }
673}
674
675static void vfe_enable_irq_pix_line(struct vfe_device *vfe, u8 comp,
676 enum vfe_line_id line_id, u8 enable)
677{
678 struct vfe_output *output = &vfe->line[line_id].output;
679 unsigned int i;
680 u32 irq_en0;
681 u32 irq_en1;
682 u32 comp_mask = 0;
683
684 irq_en0 = VFE_0_IRQ_MASK_0_CAMIF_SOF;
685 irq_en0 |= VFE_0_IRQ_MASK_0_CAMIF_EOF;
686 irq_en0 |= VFE_0_IRQ_MASK_0_IMAGE_COMPOSITE_DONE_n(comp);
687 irq_en0 |= VFE_0_IRQ_MASK_0_line_n_REG_UPDATE(line_id);
688 irq_en1 = VFE_0_IRQ_MASK_1_CAMIF_ERROR;
689 for (i = 0; i < output->wm_num; i++) {
690 irq_en1 |= VFE_0_IRQ_MASK_1_IMAGE_MASTER_n_BUS_OVERFLOW(
691 output->wm_idx[i]);
692 comp_mask |= (1 << output->wm_idx[i]) << comp * 8;
693 }
694
695 if (enable) {
696 vfe_reg_set(vfe, VFE_0_IRQ_MASK_0, irq_en0);
697 vfe_reg_set(vfe, VFE_0_IRQ_MASK_1, irq_en1);
698 vfe_reg_set(vfe, VFE_0_IRQ_COMPOSITE_MASK_0, comp_mask);
699 } else {
700 vfe_reg_clr(vfe, VFE_0_IRQ_MASK_0, irq_en0);
701 vfe_reg_clr(vfe, VFE_0_IRQ_MASK_1, irq_en1);
702 vfe_reg_clr(vfe, VFE_0_IRQ_COMPOSITE_MASK_0, comp_mask);
703 }
704}
705
706static void vfe_enable_irq_common(struct vfe_device *vfe)
707{
708 u32 irq_en0 = VFE_0_IRQ_MASK_0_RESET_ACK;
709 u32 irq_en1 = VFE_0_IRQ_MASK_1_VIOLATION |
710 VFE_0_IRQ_MASK_1_BUS_BDG_HALT_ACK;
711
712 vfe_reg_set(vfe, VFE_0_IRQ_MASK_0, irq_en0);
713 vfe_reg_set(vfe, VFE_0_IRQ_MASK_1, irq_en1);
714}
715
716static void vfe_set_demux_cfg(struct vfe_device *vfe, struct vfe_line *line)
717{
718 u32 val, even_cfg, odd_cfg;
719
720 writel_relaxed(VFE_0_DEMUX_CFG_PERIOD, vfe->base + VFE_0_DEMUX_CFG);
721
722 val = VFE_0_DEMUX_GAIN_0_CH0_EVEN | VFE_0_DEMUX_GAIN_0_CH0_ODD;
723 writel_relaxed(val, vfe->base + VFE_0_DEMUX_GAIN_0);
724
725 val = VFE_0_DEMUX_GAIN_1_CH1 | VFE_0_DEMUX_GAIN_1_CH2;
726 writel_relaxed(val, vfe->base + VFE_0_DEMUX_GAIN_1);
727
728 switch (line->fmt[MSM_VFE_PAD_SINK].code) {
729 case MEDIA_BUS_FMT_YUYV8_2X8:
730 even_cfg = VFE_0_DEMUX_EVEN_CFG_PATTERN_YUYV;
731 odd_cfg = VFE_0_DEMUX_ODD_CFG_PATTERN_YUYV;
732 break;
733 case MEDIA_BUS_FMT_YVYU8_2X8:
734 even_cfg = VFE_0_DEMUX_EVEN_CFG_PATTERN_YVYU;
735 odd_cfg = VFE_0_DEMUX_ODD_CFG_PATTERN_YVYU;
736 break;
737 case MEDIA_BUS_FMT_UYVY8_2X8:
738 default:
739 even_cfg = VFE_0_DEMUX_EVEN_CFG_PATTERN_UYVY;
740 odd_cfg = VFE_0_DEMUX_ODD_CFG_PATTERN_UYVY;
741 break;
742 case MEDIA_BUS_FMT_VYUY8_2X8:
743 even_cfg = VFE_0_DEMUX_EVEN_CFG_PATTERN_VYUY;
744 odd_cfg = VFE_0_DEMUX_ODD_CFG_PATTERN_VYUY;
745 break;
746 }
747
748 writel_relaxed(even_cfg, vfe->base + VFE_0_DEMUX_EVEN_CFG);
749 writel_relaxed(odd_cfg, vfe->base + VFE_0_DEMUX_ODD_CFG);
750}
751
752static inline u8 vfe_calc_interp_reso(u16 input, u16 output)
753{
754 if (input / output >= 16)
755 return 0;
756
757 if (input / output >= 8)
758 return 1;
759
760 if (input / output >= 4)
761 return 2;
762
763 return 3;
764}
765
766static void vfe_set_scale_cfg(struct vfe_device *vfe, struct vfe_line *line)
767{
768 u32 p = line->video_out.active_fmt.fmt.pix_mp.pixelformat;
769 u32 reg;
770 u16 input, output;
771 u8 interp_reso;
772 u32 phase_mult;
773
774 writel_relaxed(0x3, vfe->base + VFE_0_SCALE_ENC_Y_CFG);
775
776 input = line->fmt[MSM_VFE_PAD_SINK].width;
777 output = line->compose.width;
778 reg = (output << 16) | input;
779 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_H_IMAGE_SIZE);
780
781 interp_reso = vfe_calc_interp_reso(input, output);
782 phase_mult = input * (1 << (13 + interp_reso)) / output;
783 reg = (interp_reso << 20) | phase_mult;
784 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_H_PHASE);
785
786 input = line->fmt[MSM_VFE_PAD_SINK].height;
787 output = line->compose.height;
788 reg = (output << 16) | input;
789 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_V_IMAGE_SIZE);
790
791 interp_reso = vfe_calc_interp_reso(input, output);
792 phase_mult = input * (1 << (13 + interp_reso)) / output;
793 reg = (interp_reso << 20) | phase_mult;
794 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_V_PHASE);
795
796 writel_relaxed(0x3, vfe->base + VFE_0_SCALE_ENC_CBCR_CFG);
797
798 input = line->fmt[MSM_VFE_PAD_SINK].width;
799 output = line->compose.width / 2;
800 reg = (output << 16) | input;
801 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_H_IMAGE_SIZE);
802
803 interp_reso = vfe_calc_interp_reso(input, output);
804 phase_mult = input * (1 << (13 + interp_reso)) / output;
805 reg = (interp_reso << 20) | phase_mult;
806 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_H_PHASE);
807
808 input = line->fmt[MSM_VFE_PAD_SINK].height;
809 output = line->compose.height;
810 if (p == V4L2_PIX_FMT_NV12 || p == V4L2_PIX_FMT_NV21)
811 output = line->compose.height / 2;
812 reg = (output << 16) | input;
813 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_V_IMAGE_SIZE);
814
815 interp_reso = vfe_calc_interp_reso(input, output);
816 phase_mult = input * (1 << (13 + interp_reso)) / output;
817 reg = (interp_reso << 20) | phase_mult;
818 writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_V_PHASE);
819}
820
821static void vfe_set_crop_cfg(struct vfe_device *vfe, struct vfe_line *line)
822{
823 u32 p = line->video_out.active_fmt.fmt.pix_mp.pixelformat;
824 u32 reg;
825 u16 first, last;
826
827 first = line->crop.left;
828 last = line->crop.left + line->crop.width - 1;
829 reg = (first << 16) | last;
830 writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_Y_WIDTH);
831
832 first = line->crop.top;
833 last = line->crop.top + line->crop.height - 1;
834 reg = (first << 16) | last;
835 writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_Y_HEIGHT);
836
837 first = line->crop.left / 2;
838 last = line->crop.left / 2 + line->crop.width / 2 - 1;
839 reg = (first << 16) | last;
840 writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_CBCR_WIDTH);
841
842 first = line->crop.top;
843 last = line->crop.top + line->crop.height - 1;
844 if (p == V4L2_PIX_FMT_NV12 || p == V4L2_PIX_FMT_NV21) {
845 first = line->crop.top / 2;
846 last = line->crop.top / 2 + line->crop.height / 2 - 1;
847 }
848 reg = (first << 16) | last;
849 writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_CBCR_HEIGHT);
850}
851
852static void vfe_set_clamp_cfg(struct vfe_device *vfe)
853{
854 u32 val = VFE_0_CLAMP_ENC_MAX_CFG_CH0 |
855 VFE_0_CLAMP_ENC_MAX_CFG_CH1 |
856 VFE_0_CLAMP_ENC_MAX_CFG_CH2;
857
858 writel_relaxed(val, vfe->base + VFE_0_CLAMP_ENC_MAX_CFG);
859
860 val = VFE_0_CLAMP_ENC_MIN_CFG_CH0 |
861 VFE_0_CLAMP_ENC_MIN_CFG_CH1 |
862 VFE_0_CLAMP_ENC_MIN_CFG_CH2;
863
864 writel_relaxed(val, vfe->base + VFE_0_CLAMP_ENC_MIN_CFG);
865}
866
867/*
868 * vfe_reset - Trigger reset on VFE module and wait to complete
869 * @vfe: VFE device
870 *
871 * Return 0 on success or a negative error code otherwise
872 */
873static int vfe_reset(struct vfe_device *vfe)
874{
875 unsigned long time;
876
877 reinit_completion(&vfe->reset_complete);
878
879 vfe_global_reset(vfe);
880
881 time = wait_for_completion_timeout(&vfe->reset_complete,
882 msecs_to_jiffies(VFE_RESET_TIMEOUT_MS));
883 if (!time) {
884 dev_err(to_device(vfe), "VFE reset timeout\n");
885 return -EIO;
886 }
887
888 return 0;
889}
890
891/*
892 * vfe_halt - Trigger halt on VFE module and wait to complete
893 * @vfe: VFE device
894 *
895 * Return 0 on success or a negative error code otherwise
896 */
897static int vfe_halt(struct vfe_device *vfe)
898{
899 unsigned long time;
900
901 reinit_completion(&vfe->halt_complete);
902
903 writel_relaxed(VFE_0_BUS_BDG_CMD_HALT_REQ,
904 vfe->base + VFE_0_BUS_BDG_CMD);
905
906 time = wait_for_completion_timeout(&vfe->halt_complete,
907 msecs_to_jiffies(VFE_HALT_TIMEOUT_MS));
908 if (!time) {
909 dev_err(to_device(vfe), "VFE halt timeout\n");
910 return -EIO;
911 }
912
913 return 0;
914}
915
916static void vfe_init_outputs(struct vfe_device *vfe)
917{
918 int i;
919
920 for (i = 0; i < ARRAY_SIZE(vfe->line); i++) {
921 struct vfe_output *output = &vfe->line[i].output;
922
923 output->state = VFE_OUTPUT_OFF;
924 output->buf[0] = NULL;
925 output->buf[1] = NULL;
926 INIT_LIST_HEAD(&output->pending_bufs);
927
928 output->wm_num = 1;
929 if (vfe->line[i].id == VFE_LINE_PIX)
930 output->wm_num = 2;
931 }
932}
933
934static void vfe_reset_output_maps(struct vfe_device *vfe)
935{
936 int i;
937
938 for (i = 0; i < ARRAY_SIZE(vfe->wm_output_map); i++)
939 vfe->wm_output_map[i] = VFE_LINE_NONE;
940}
941
942static void vfe_set_qos(struct vfe_device *vfe)
943{
944 u32 val = VFE_0_BUS_BDG_QOS_CFG_0_CFG;
945 u32 val7 = VFE_0_BUS_BDG_QOS_CFG_7_CFG;
946
947 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_0);
948 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_1);
949 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_2);
950 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_3);
951 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_4);
952 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_5);
953 writel_relaxed(val, vfe->base + VFE_0_BUS_BDG_QOS_CFG_6);
954 writel_relaxed(val7, vfe->base + VFE_0_BUS_BDG_QOS_CFG_7);
955}
956
957static void vfe_set_cgc_override(struct vfe_device *vfe, u8 wm, u8 enable)
958{
959 u32 val = VFE_0_CGC_OVERRIDE_1_IMAGE_Mx_CGC_OVERRIDE(wm);
960
961 if (enable)
962 vfe_reg_set(vfe, VFE_0_CGC_OVERRIDE_1, val);
963 else
964 vfe_reg_clr(vfe, VFE_0_CGC_OVERRIDE_1, val);
965
966 wmb();
967}
968
969static void vfe_set_module_cfg(struct vfe_device *vfe, u8 enable)
970{
971 u32 val = VFE_0_MODULE_CFG_DEMUX |
972 VFE_0_MODULE_CFG_CHROMA_UPSAMPLE |
973 VFE_0_MODULE_CFG_SCALE_ENC |
974 VFE_0_MODULE_CFG_CROP_ENC;
975
976 if (enable)
977 writel_relaxed(val, vfe->base + VFE_0_MODULE_CFG);
978 else
979 writel_relaxed(0x0, vfe->base + VFE_0_MODULE_CFG);
980}
981
982static void vfe_set_camif_cfg(struct vfe_device *vfe, struct vfe_line *line)
983{
984 u32 val;
985
986 switch (line->fmt[MSM_VFE_PAD_SINK].code) {
987 case MEDIA_BUS_FMT_YUYV8_2X8:
988 val = VFE_0_CORE_CFG_PIXEL_PATTERN_YCBYCR;
989 break;
990 case MEDIA_BUS_FMT_YVYU8_2X8:
991 val = VFE_0_CORE_CFG_PIXEL_PATTERN_YCRYCB;
992 break;
993 case MEDIA_BUS_FMT_UYVY8_2X8:
994 default:
995 val = VFE_0_CORE_CFG_PIXEL_PATTERN_CBYCRY;
996 break;
997 case MEDIA_BUS_FMT_VYUY8_2X8:
998 val = VFE_0_CORE_CFG_PIXEL_PATTERN_CRYCBY;
999 break;
1000 }
1001
1002 writel_relaxed(val, vfe->base + VFE_0_CORE_CFG);
1003
1004 val = line->fmt[MSM_VFE_PAD_SINK].width * 2;
1005 val |= line->fmt[MSM_VFE_PAD_SINK].height << 16;
1006 writel_relaxed(val, vfe->base + VFE_0_CAMIF_FRAME_CFG);
1007
1008 val = line->fmt[MSM_VFE_PAD_SINK].width * 2 - 1;
1009 writel_relaxed(val, vfe->base + VFE_0_CAMIF_WINDOW_WIDTH_CFG);
1010
1011 val = line->fmt[MSM_VFE_PAD_SINK].height - 1;
1012 writel_relaxed(val, vfe->base + VFE_0_CAMIF_WINDOW_HEIGHT_CFG);
1013
1014 val = 0xffffffff;
1015 writel_relaxed(val, vfe->base + VFE_0_CAMIF_SUBSAMPLE_CFG_0);
1016
1017 val = 0xffffffff;
1018 writel_relaxed(val, vfe->base + VFE_0_CAMIF_IRQ_SUBSAMPLE_PATTERN);
1019
1020 val = VFE_0_RDI_CFG_x_MIPI_EN_BITS;
1021 vfe_reg_set(vfe, VFE_0_RDI_CFG_x(0), val);
1022
1023 val = VFE_0_CAMIF_CFG_VFE_OUTPUT_EN;
1024 writel_relaxed(val, vfe->base + VFE_0_CAMIF_CFG);
1025}
1026
1027static void vfe_set_camif_cmd(struct vfe_device *vfe, u32 cmd)
1028{
1029 writel_relaxed(VFE_0_CAMIF_CMD_CLEAR_CAMIF_STATUS,
1030 vfe->base + VFE_0_CAMIF_CMD);
1031
1032 writel_relaxed(cmd, vfe->base + VFE_0_CAMIF_CMD);
1033}
1034
1035static int vfe_camif_wait_for_stop(struct vfe_device *vfe)
1036{
1037 u32 val;
1038 int ret;
1039
1040 ret = readl_poll_timeout(vfe->base + VFE_0_CAMIF_STATUS,
1041 val,
1042 (val & VFE_0_CAMIF_STATUS_HALT),
1043 CAMIF_TIMEOUT_SLEEP_US,
1044 CAMIF_TIMEOUT_ALL_US);
1045 if (ret < 0)
1046 dev_err(to_device(vfe), "%s: camif stop timeout\n", __func__);
1047
1048 return ret;
1049}
1050
1051static void vfe_output_init_addrs(struct vfe_device *vfe,
1052 struct vfe_output *output, u8 sync)
1053{
1054 u32 ping_addr;
1055 u32 pong_addr;
1056 unsigned int i;
1057
1058 output->active_buf = 0;
1059
1060 for (i = 0; i < output->wm_num; i++) {
1061 if (output->buf[0])
1062 ping_addr = output->buf[0]->addr[i];
1063 else
1064 ping_addr = 0;
1065
1066 if (output->buf[1])
1067 pong_addr = output->buf[1]->addr[i];
1068 else
1069 pong_addr = ping_addr;
1070
1071 vfe_wm_set_ping_addr(vfe, output->wm_idx[i], ping_addr);
1072 vfe_wm_set_pong_addr(vfe, output->wm_idx[i], pong_addr);
1073 if (sync)
1074 vfe_bus_reload_wm(vfe, output->wm_idx[i]);
1075 }
1076}
1077
1078static void vfe_output_update_ping_addr(struct vfe_device *vfe,
1079 struct vfe_output *output, u8 sync)
1080{
1081 u32 addr;
1082 unsigned int i;
1083
1084 for (i = 0; i < output->wm_num; i++) {
1085 if (output->buf[0])
1086 addr = output->buf[0]->addr[i];
1087 else
1088 addr = 0;
1089
1090 vfe_wm_set_ping_addr(vfe, output->wm_idx[i], addr);
1091 if (sync)
1092 vfe_bus_reload_wm(vfe, output->wm_idx[i]);
1093 }
1094}
1095
1096static void vfe_output_update_pong_addr(struct vfe_device *vfe,
1097 struct vfe_output *output, u8 sync)
1098{
1099 u32 addr;
1100 unsigned int i;
1101
1102 for (i = 0; i < output->wm_num; i++) {
1103 if (output->buf[1])
1104 addr = output->buf[1]->addr[i];
1105 else
1106 addr = 0;
1107
1108 vfe_wm_set_pong_addr(vfe, output->wm_idx[i], addr);
1109 if (sync)
1110 vfe_bus_reload_wm(vfe, output->wm_idx[i]);
1111 }
1112
1113}
1114
1115static int vfe_reserve_wm(struct vfe_device *vfe, enum vfe_line_id line_id)
1116{
1117 int ret = -EBUSY;
1118 int i;
1119
1120 for (i = 0; i < ARRAY_SIZE(vfe->wm_output_map); i++) {
1121 if (vfe->wm_output_map[i] == VFE_LINE_NONE) {
1122 vfe->wm_output_map[i] = line_id;
1123 ret = i;
1124 break;
1125 }
1126 }
1127
1128 return ret;
1129}
1130
1131static int vfe_release_wm(struct vfe_device *vfe, u8 wm)
1132{
1133 if (wm >= ARRAY_SIZE(vfe->wm_output_map))
1134 return -EINVAL;
1135
1136 vfe->wm_output_map[wm] = VFE_LINE_NONE;
1137
1138 return 0;
1139}
1140
1141static void vfe_output_frame_drop(struct vfe_device *vfe,
1142 struct vfe_output *output,
1143 u32 drop_pattern)
1144{
1145 u8 drop_period;
1146 unsigned int i;
1147
1148 /* We need to toggle update period to be valid on next frame */
1149 output->drop_update_idx++;
1150 output->drop_update_idx %= VFE_FRAME_DROP_UPDATES;
1151 drop_period = VFE_FRAME_DROP_VAL + output->drop_update_idx;
1152
1153 for (i = 0; i < output->wm_num; i++) {
1154 vfe_wm_set_framedrop_period(vfe, output->wm_idx[i],
1155 drop_period);
1156 vfe_wm_set_framedrop_pattern(vfe, output->wm_idx[i],
1157 drop_pattern);
1158 }
1159 vfe_reg_update(vfe, container_of(output, struct vfe_line, output)->id);
1160}
1161
1162static struct camss_buffer *vfe_buf_get_pending(struct vfe_output *output)
1163{
1164 struct camss_buffer *buffer = NULL;
1165
1166 if (!list_empty(&output->pending_bufs)) {
1167 buffer = list_first_entry(&output->pending_bufs,
1168 struct camss_buffer,
1169 queue);
1170 list_del(&buffer->queue);
1171 }
1172
1173 return buffer;
1174}
1175
1176/*
1177 * vfe_buf_add_pending - Add output buffer to list of pending
1178 * @output: VFE output
1179 * @buffer: Video buffer
1180 */
1181static void vfe_buf_add_pending(struct vfe_output *output,
1182 struct camss_buffer *buffer)
1183{
1184 INIT_LIST_HEAD(&buffer->queue);
1185 list_add_tail(&buffer->queue, &output->pending_bufs);
1186}
1187
1188/*
1189 * vfe_buf_flush_pending - Flush all pending buffers.
1190 * @output: VFE output
1191 * @state: vb2 buffer state
1192 */
1193static void vfe_buf_flush_pending(struct vfe_output *output,
1194 enum vb2_buffer_state state)
1195{
1196 struct camss_buffer *buf;
1197 struct camss_buffer *t;
1198
1199 list_for_each_entry_safe(buf, t, &output->pending_bufs, queue) {
1200 vb2_buffer_done(&buf->vb.vb2_buf, state);
1201 list_del(&buf->queue);
1202 }
1203}
1204
1205static void vfe_buf_update_wm_on_next(struct vfe_device *vfe,
1206 struct vfe_output *output)
1207{
1208 switch (output->state) {
1209 case VFE_OUTPUT_CONTINUOUS:
1210 vfe_output_frame_drop(vfe, output, 3);
1211 break;
1212 case VFE_OUTPUT_SINGLE:
1213 default:
1214 dev_err_ratelimited(to_device(vfe),
1215 "Next buf in wrong state! %d\n",
1216 output->state);
1217 break;
1218 }
1219}
1220
1221static void vfe_buf_update_wm_on_last(struct vfe_device *vfe,
1222 struct vfe_output *output)
1223{
1224 switch (output->state) {
1225 case VFE_OUTPUT_CONTINUOUS:
1226 output->state = VFE_OUTPUT_SINGLE;
1227 vfe_output_frame_drop(vfe, output, 1);
1228 break;
1229 case VFE_OUTPUT_SINGLE:
1230 output->state = VFE_OUTPUT_STOPPING;
1231 vfe_output_frame_drop(vfe, output, 0);
1232 break;
1233 default:
1234 dev_err_ratelimited(to_device(vfe),
1235 "Last buff in wrong state! %d\n",
1236 output->state);
1237 break;
1238 }
1239}
1240
1241static void vfe_buf_update_wm_on_new(struct vfe_device *vfe,
1242 struct vfe_output *output,
1243 struct camss_buffer *new_buf)
1244{
1245 int inactive_idx;
1246
1247 switch (output->state) {
1248 case VFE_OUTPUT_SINGLE:
1249 inactive_idx = !output->active_buf;
1250
1251 if (!output->buf[inactive_idx]) {
1252 output->buf[inactive_idx] = new_buf;
1253
1254 if (inactive_idx)
1255 vfe_output_update_pong_addr(vfe, output, 0);
1256 else
1257 vfe_output_update_ping_addr(vfe, output, 0);
1258
1259 vfe_output_frame_drop(vfe, output, 3);
1260 output->state = VFE_OUTPUT_CONTINUOUS;
1261 } else {
1262 vfe_buf_add_pending(output, new_buf);
1263 dev_err_ratelimited(to_device(vfe),
1264 "Inactive buffer is busy\n");
1265 }
1266 break;
1267
1268 case VFE_OUTPUT_IDLE:
1269 if (!output->buf[0]) {
1270 output->buf[0] = new_buf;
1271
1272 vfe_output_init_addrs(vfe, output, 1);
1273
1274 vfe_output_frame_drop(vfe, output, 1);
1275 output->state = VFE_OUTPUT_SINGLE;
1276 } else {
1277 vfe_buf_add_pending(output, new_buf);
1278 dev_err_ratelimited(to_device(vfe),
1279 "Output idle with buffer set!\n");
1280 }
1281 break;
1282
1283 case VFE_OUTPUT_CONTINUOUS:
1284 default:
1285 vfe_buf_add_pending(output, new_buf);
1286 break;
1287 }
1288}
1289
1290static int vfe_get_output(struct vfe_line *line)
1291{
1292 struct vfe_device *vfe = to_vfe(line);
1293 struct vfe_output *output;
1294 unsigned long flags;
1295 int i;
1296 int wm_idx;
1297
1298 spin_lock_irqsave(&vfe->output_lock, flags);
1299
1300 output = &line->output;
1301 if (output->state != VFE_OUTPUT_OFF) {
1302 dev_err(to_device(vfe), "Output is running\n");
1303 goto error;
1304 }
1305 output->state = VFE_OUTPUT_RESERVED;
1306
1307 output->active_buf = 0;
1308
1309 for (i = 0; i < output->wm_num; i++) {
1310 wm_idx = vfe_reserve_wm(vfe, line->id);
1311 if (wm_idx < 0) {
1312 dev_err(to_device(vfe), "Can not reserve wm\n");
1313 goto error_get_wm;
1314 }
1315 output->wm_idx[i] = wm_idx;
1316 }
1317
1318 output->drop_update_idx = 0;
1319
1320 spin_unlock_irqrestore(&vfe->output_lock, flags);
1321
1322 return 0;
1323
1324error_get_wm:
1325 for (i--; i >= 0; i--)
1326 vfe_release_wm(vfe, output->wm_idx[i]);
1327 output->state = VFE_OUTPUT_OFF;
1328error:
1329 spin_unlock_irqrestore(&vfe->output_lock, flags);
1330
1331 return -EINVAL;
1332}
1333
1334static int vfe_put_output(struct vfe_line *line)
1335{
1336 struct vfe_device *vfe = to_vfe(line);
1337 struct vfe_output *output = &line->output;
1338 unsigned long flags;
1339 unsigned int i;
1340
1341 spin_lock_irqsave(&vfe->output_lock, flags);
1342
1343 for (i = 0; i < output->wm_num; i++)
1344 vfe_release_wm(vfe, output->wm_idx[i]);
1345
1346 output->state = VFE_OUTPUT_OFF;
1347
1348 spin_unlock_irqrestore(&vfe->output_lock, flags);
1349 return 0;
1350}
1351
1352static int vfe_enable_output(struct vfe_line *line)
1353{
1354 struct vfe_device *vfe = to_vfe(line);
1355 struct vfe_output *output = &line->output;
1356 unsigned long flags;
1357 unsigned int i;
1358 u16 ub_size;
1359
1360 switch (vfe->id) {
1361 case 0:
1362 ub_size = MSM_VFE_VFE0_UB_SIZE_RDI;
1363 break;
1364 case 1:
1365 ub_size = MSM_VFE_VFE1_UB_SIZE_RDI;
1366 break;
1367 default:
1368 return -EINVAL;
1369 }
1370
1371 spin_lock_irqsave(&vfe->output_lock, flags);
1372
1373 vfe->reg_update &= ~VFE_0_REG_UPDATE_line_n(line->id);
1374
1375 if (output->state != VFE_OUTPUT_RESERVED) {
1376 dev_err(to_device(vfe), "Output is not in reserved state %d\n",
1377 output->state);
1378 spin_unlock_irqrestore(&vfe->output_lock, flags);
1379 return -EINVAL;
1380 }
1381 output->state = VFE_OUTPUT_IDLE;
1382
1383 output->buf[0] = vfe_buf_get_pending(output);
1384 output->buf[1] = vfe_buf_get_pending(output);
1385
1386 if (!output->buf[0] && output->buf[1]) {
1387 output->buf[0] = output->buf[1];
1388 output->buf[1] = NULL;
1389 }
1390
1391 if (output->buf[0])
1392 output->state = VFE_OUTPUT_SINGLE;
1393
1394 if (output->buf[1])
1395 output->state = VFE_OUTPUT_CONTINUOUS;
1396
1397 switch (output->state) {
1398 case VFE_OUTPUT_SINGLE:
1399 vfe_output_frame_drop(vfe, output, 1);
1400 break;
1401 case VFE_OUTPUT_CONTINUOUS:
1402 vfe_output_frame_drop(vfe, output, 3);
1403 break;
1404 default:
1405 vfe_output_frame_drop(vfe, output, 0);
1406 break;
1407 }
1408
1409 output->sequence = 0;
1410 output->wait_sof = 0;
1411 output->wait_reg_update = 0;
1412 reinit_completion(&output->sof);
1413 reinit_completion(&output->reg_update);
1414
1415 vfe_output_init_addrs(vfe, output, 0);
1416
1417 if (line->id != VFE_LINE_PIX) {
1418 vfe_set_cgc_override(vfe, output->wm_idx[0], 1);
1419 vfe_enable_irq_wm_line(vfe, output->wm_idx[0], line->id, 1);
1420 vfe_bus_connect_wm_to_rdi(vfe, output->wm_idx[0], line->id);
1421 vfe_wm_set_subsample(vfe, output->wm_idx[0]);
1422 vfe_set_rdi_cid(vfe, line->id, 0);
1423 vfe_wm_set_ub_cfg(vfe, output->wm_idx[0],
1424 (ub_size + 1) * output->wm_idx[0], ub_size);
1425 vfe_wm_frame_based(vfe, output->wm_idx[0], 1);
1426 vfe_wm_enable(vfe, output->wm_idx[0], 1);
1427 vfe_bus_reload_wm(vfe, output->wm_idx[0]);
1428 } else {
1429 ub_size /= output->wm_num;
1430 for (i = 0; i < output->wm_num; i++) {
1431 vfe_set_cgc_override(vfe, output->wm_idx[i], 1);
1432 vfe_wm_set_subsample(vfe, output->wm_idx[i]);
1433 vfe_wm_set_ub_cfg(vfe, output->wm_idx[i],
1434 (ub_size + 1) * output->wm_idx[i],
1435 ub_size);
1436 vfe_wm_line_based(vfe, output->wm_idx[i],
1437 &line->video_out.active_fmt.fmt.pix_mp,
1438 i, 1);
1439 vfe_wm_enable(vfe, output->wm_idx[i], 1);
1440 vfe_bus_reload_wm(vfe, output->wm_idx[i]);
1441 }
1442 vfe_enable_irq_pix_line(vfe, 0, line->id, 1);
1443 vfe_set_module_cfg(vfe, 1);
1444 vfe_set_camif_cfg(vfe, line);
1445 vfe_set_xbar_cfg(vfe, output, 1);
1446 vfe_set_demux_cfg(vfe, line);
1447 vfe_set_scale_cfg(vfe, line);
1448 vfe_set_crop_cfg(vfe, line);
1449 vfe_set_clamp_cfg(vfe);
1450 vfe_set_camif_cmd(vfe, VFE_0_CAMIF_CMD_ENABLE_FRAME_BOUNDARY);
1451 }
1452
1453 vfe_reg_update(vfe, line->id);
1454
1455 spin_unlock_irqrestore(&vfe->output_lock, flags);
1456
1457 return 0;
1458}
1459
1460static int vfe_disable_output(struct vfe_line *line)
1461{
1462 struct vfe_device *vfe = to_vfe(line);
1463 struct vfe_output *output = &line->output;
1464 unsigned long flags;
1465 unsigned long time;
1466 unsigned int i;
1467
1468 spin_lock_irqsave(&vfe->output_lock, flags);
1469
1470 output->wait_sof = 1;
1471 spin_unlock_irqrestore(&vfe->output_lock, flags);
1472
1473 time = wait_for_completion_timeout(&output->sof,
1474 msecs_to_jiffies(VFE_NEXT_SOF_MS));
1475 if (!time)
1476 dev_err(to_device(vfe), "VFE sof timeout\n");
1477
1478 spin_lock_irqsave(&vfe->output_lock, flags);
1479 for (i = 0; i < output->wm_num; i++)
1480 vfe_wm_enable(vfe, output->wm_idx[i], 0);
1481
1482 vfe_reg_update(vfe, line->id);
1483 output->wait_reg_update = 1;
1484 spin_unlock_irqrestore(&vfe->output_lock, flags);
1485
1486 time = wait_for_completion_timeout(&output->reg_update,
1487 msecs_to_jiffies(VFE_NEXT_SOF_MS));
1488 if (!time)
1489 dev_err(to_device(vfe), "VFE reg update timeout\n");
1490
1491 spin_lock_irqsave(&vfe->output_lock, flags);
1492
1493 if (line->id != VFE_LINE_PIX) {
1494 vfe_wm_frame_based(vfe, output->wm_idx[0], 0);
1495 vfe_bus_disconnect_wm_from_rdi(vfe, output->wm_idx[0], line->id);
1496 vfe_enable_irq_wm_line(vfe, output->wm_idx[0], line->id, 0);
1497 vfe_set_cgc_override(vfe, output->wm_idx[0], 0);
1498 spin_unlock_irqrestore(&vfe->output_lock, flags);
1499 } else {
1500 for (i = 0; i < output->wm_num; i++) {
1501 vfe_wm_line_based(vfe, output->wm_idx[i], NULL, i, 0);
1502 vfe_set_cgc_override(vfe, output->wm_idx[i], 0);
1503 }
1504
1505 vfe_enable_irq_pix_line(vfe, 0, line->id, 0);
1506 vfe_set_module_cfg(vfe, 0);
1507 vfe_set_xbar_cfg(vfe, output, 0);
1508
1509 vfe_set_camif_cmd(vfe, VFE_0_CAMIF_CMD_DISABLE_FRAME_BOUNDARY);
1510 spin_unlock_irqrestore(&vfe->output_lock, flags);
1511
1512 vfe_camif_wait_for_stop(vfe);
1513 }
1514
1515 return 0;
1516}
1517
1518/*
1519 * vfe_enable - Enable streaming on VFE line
1520 * @line: VFE line
1521 *
1522 * Return 0 on success or a negative error code otherwise
1523 */
1524static int vfe_enable(struct vfe_line *line)
1525{
1526 struct vfe_device *vfe = to_vfe(line);
1527 int ret;
1528
1529 mutex_lock(&vfe->stream_lock);
1530
1531 if (!vfe->stream_count) {
1532 vfe_enable_irq_common(vfe);
1533
1534 vfe_bus_enable_wr_if(vfe, 1);
1535
1536 vfe_set_qos(vfe);
1537 }
1538
1539 vfe->stream_count++;
1540
1541 mutex_unlock(&vfe->stream_lock);
1542
1543 ret = vfe_get_output(line);
1544 if (ret < 0)
1545 goto error_get_output;
1546
1547 ret = vfe_enable_output(line);
1548 if (ret < 0)
1549 goto error_enable_output;
1550
1551 vfe->was_streaming = 1;
1552
1553 return 0;
1554
1555
1556error_enable_output:
1557 vfe_put_output(line);
1558
1559error_get_output:
1560 mutex_lock(&vfe->stream_lock);
1561
1562 if (vfe->stream_count == 1)
1563 vfe_bus_enable_wr_if(vfe, 0);
1564
1565 vfe->stream_count--;
1566
1567 mutex_unlock(&vfe->stream_lock);
1568
1569 return ret;
1570}
1571
1572/*
1573 * vfe_disable - Disable streaming on VFE line
1574 * @line: VFE line
1575 *
1576 * Return 0 on success or a negative error code otherwise
1577 */
1578static int vfe_disable(struct vfe_line *line)
1579{
1580 struct vfe_device *vfe = to_vfe(line);
1581
1582 vfe_disable_output(line);
1583
1584 vfe_put_output(line);
1585
1586 mutex_lock(&vfe->stream_lock);
1587
1588 if (vfe->stream_count == 1)
1589 vfe_bus_enable_wr_if(vfe, 0);
1590
1591 vfe->stream_count--;
1592
1593 mutex_unlock(&vfe->stream_lock);
1594
1595 return 0;
1596}
1597
1598/*
1599 * vfe_isr_sof - Process start of frame interrupt
1600 * @vfe: VFE Device
1601 * @line_id: VFE line
1602 */
1603static void vfe_isr_sof(struct vfe_device *vfe, enum vfe_line_id line_id)
1604{
1605 struct vfe_output *output;
1606 unsigned long flags;
1607
1608 spin_lock_irqsave(&vfe->output_lock, flags);
1609 output = &vfe->line[line_id].output;
1610 if (output->wait_sof) {
1611 output->wait_sof = 0;
1612 complete(&output->sof);
1613 }
1614 spin_unlock_irqrestore(&vfe->output_lock, flags);
1615}
1616
1617/*
1618 * vfe_isr_reg_update - Process reg update interrupt
1619 * @vfe: VFE Device
1620 * @line_id: VFE line
1621 */
1622static void vfe_isr_reg_update(struct vfe_device *vfe, enum vfe_line_id line_id)
1623{
1624 struct vfe_output *output;
1625 unsigned long flags;
1626
1627 spin_lock_irqsave(&vfe->output_lock, flags);
1628 vfe->reg_update &= ~VFE_0_REG_UPDATE_line_n(line_id);
1629
1630 output = &vfe->line[line_id].output;
1631
1632 if (output->wait_reg_update) {
1633 output->wait_reg_update = 0;
1634 complete(&output->reg_update);
1635 spin_unlock_irqrestore(&vfe->output_lock, flags);
1636 return;
1637 }
1638
1639 if (output->state == VFE_OUTPUT_STOPPING) {
1640 /* Release last buffer when hw is idle */
1641 if (output->last_buffer) {
1642 vb2_buffer_done(&output->last_buffer->vb.vb2_buf,
1643 VB2_BUF_STATE_DONE);
1644 output->last_buffer = NULL;
1645 }
1646 output->state = VFE_OUTPUT_IDLE;
1647
1648 /* Buffers received in stopping state are queued in */
1649 /* dma pending queue, start next capture here */
1650
1651 output->buf[0] = vfe_buf_get_pending(output);
1652 output->buf[1] = vfe_buf_get_pending(output);
1653
1654 if (!output->buf[0] && output->buf[1]) {
1655 output->buf[0] = output->buf[1];
1656 output->buf[1] = NULL;
1657 }
1658
1659 if (output->buf[0])
1660 output->state = VFE_OUTPUT_SINGLE;
1661
1662 if (output->buf[1])
1663 output->state = VFE_OUTPUT_CONTINUOUS;
1664
1665 switch (output->state) {
1666 case VFE_OUTPUT_SINGLE:
1667 vfe_output_frame_drop(vfe, output, 2);
1668 break;
1669 case VFE_OUTPUT_CONTINUOUS:
1670 vfe_output_frame_drop(vfe, output, 3);
1671 break;
1672 default:
1673 vfe_output_frame_drop(vfe, output, 0);
1674 break;
1675 }
1676
1677 vfe_output_init_addrs(vfe, output, 1);
1678 }
1679
1680 spin_unlock_irqrestore(&vfe->output_lock, flags);
1681}
1682
1683/*
1684 * vfe_isr_wm_done - Process write master done interrupt
1685 * @vfe: VFE Device
1686 * @wm: Write master id
1687 */
1688static void vfe_isr_wm_done(struct vfe_device *vfe, u8 wm)
1689{
1690 struct camss_buffer *ready_buf;
1691 struct vfe_output *output;
1692 dma_addr_t *new_addr;
1693 unsigned long flags;
1694 u32 active_index;
1695 u64 ts = ktime_get_ns();
1696 unsigned int i;
1697
1698 active_index = vfe_wm_get_ping_pong_status(vfe, wm);
1699
1700 spin_lock_irqsave(&vfe->output_lock, flags);
1701
1702 if (vfe->wm_output_map[wm] == VFE_LINE_NONE) {
1703 dev_err_ratelimited(to_device(vfe),
1704 "Received wm done for unmapped index\n");
1705 goto out_unlock;
1706 }
1707 output = &vfe->line[vfe->wm_output_map[wm]].output;
1708
1709 if (output->active_buf == active_index) {
1710 dev_err_ratelimited(to_device(vfe),
1711 "Active buffer mismatch!\n");
1712 goto out_unlock;
1713 }
1714 output->active_buf = active_index;
1715
1716 ready_buf = output->buf[!active_index];
1717 if (!ready_buf) {
1718 dev_err_ratelimited(to_device(vfe),
1719 "Missing ready buf %d %d!\n",
1720 !active_index, output->state);
1721 goto out_unlock;
1722 }
1723
1724 ready_buf->vb.vb2_buf.timestamp = ts;
1725 ready_buf->vb.sequence = output->sequence++;
1726
1727 /* Get next buffer */
1728 output->buf[!active_index] = vfe_buf_get_pending(output);
1729 if (!output->buf[!active_index]) {
1730 /* No next buffer - set same address */
1731 new_addr = ready_buf->addr;
1732 vfe_buf_update_wm_on_last(vfe, output);
1733 } else {
1734 new_addr = output->buf[!active_index]->addr;
1735 vfe_buf_update_wm_on_next(vfe, output);
1736 }
1737
1738 if (active_index)
1739 for (i = 0; i < output->wm_num; i++)
1740 vfe_wm_set_ping_addr(vfe, output->wm_idx[i],
1741 new_addr[i]);
1742 else
1743 for (i = 0; i < output->wm_num; i++)
1744 vfe_wm_set_pong_addr(vfe, output->wm_idx[i],
1745 new_addr[i]);
1746
1747 spin_unlock_irqrestore(&vfe->output_lock, flags);
1748
1749 if (output->state == VFE_OUTPUT_STOPPING)
1750 output->last_buffer = ready_buf;
1751 else
1752 vb2_buffer_done(&ready_buf->vb.vb2_buf, VB2_BUF_STATE_DONE);
1753
1754 return;
1755
1756out_unlock:
1757 spin_unlock_irqrestore(&vfe->output_lock, flags);
1758}
1759
1760/*
1761 * vfe_isr_wm_done - Process composite image done interrupt
1762 * @vfe: VFE Device
1763 * @comp: Composite image id
1764 */
1765static void vfe_isr_comp_done(struct vfe_device *vfe, u8 comp)
1766{
1767 unsigned int i;
1768
1769 for (i = 0; i < ARRAY_SIZE(vfe->wm_output_map); i++)
1770 if (vfe->wm_output_map[i] == VFE_LINE_PIX) {
1771 vfe_isr_wm_done(vfe, i);
1772 break;
1773 }
1774}
1775
1776/*
1777 * vfe_isr - ISPIF module interrupt handler
1778 * @irq: Interrupt line
1779 * @dev: VFE device
1780 *
1781 * Return IRQ_HANDLED on success
1782 */
1783static irqreturn_t vfe_isr(int irq, void *dev)
1784{
1785 struct vfe_device *vfe = dev;
1786 u32 value0, value1;
1787 u32 violation;
1788 int i, j;
1789
1790 value0 = readl_relaxed(vfe->base + VFE_0_IRQ_STATUS_0);
1791 value1 = readl_relaxed(vfe->base + VFE_0_IRQ_STATUS_1);
1792
1793 writel_relaxed(value0, vfe->base + VFE_0_IRQ_CLEAR_0);
1794 writel_relaxed(value1, vfe->base + VFE_0_IRQ_CLEAR_1);
1795
1796 wmb();
1797 writel_relaxed(VFE_0_IRQ_CMD_GLOBAL_CLEAR, vfe->base + VFE_0_IRQ_CMD);
1798
1799 if (value0 & VFE_0_IRQ_STATUS_0_RESET_ACK)
1800 complete(&vfe->reset_complete);
1801
1802 if (value1 & VFE_0_IRQ_STATUS_1_VIOLATION) {
1803 violation = readl_relaxed(vfe->base + VFE_0_VIOLATION_STATUS);
1804 dev_err_ratelimited(to_device(vfe),
1805 "VFE: violation = 0x%08x\n", violation);
1806 }
1807
1808 if (value1 & VFE_0_IRQ_STATUS_1_BUS_BDG_HALT_ACK) {
1809 complete(&vfe->halt_complete);
1810 writel_relaxed(0x0, vfe->base + VFE_0_BUS_BDG_CMD);
1811 }
1812
1813 for (i = VFE_LINE_RDI0; i <= VFE_LINE_PIX; i++)
1814 if (value0 & VFE_0_IRQ_STATUS_0_line_n_REG_UPDATE(i))
1815 vfe_isr_reg_update(vfe, i);
1816
1817 if (value0 & VFE_0_IRQ_STATUS_0_CAMIF_SOF)
1818 vfe_isr_sof(vfe, VFE_LINE_PIX);
1819
1820 for (i = VFE_LINE_RDI0; i <= VFE_LINE_RDI2; i++)
1821 if (value1 & VFE_0_IRQ_STATUS_1_RDIn_SOF(i))
1822 vfe_isr_sof(vfe, i);
1823
1824 for (i = 0; i < MSM_VFE_COMPOSITE_IRQ_NUM; i++)
1825 if (value0 & VFE_0_IRQ_STATUS_0_IMAGE_COMPOSITE_DONE_n(i)) {
1826 vfe_isr_comp_done(vfe, i);
1827 for (j = 0; j < ARRAY_SIZE(vfe->wm_output_map); j++)
1828 if (vfe->wm_output_map[j] == VFE_LINE_PIX)
1829 value0 &= ~VFE_0_IRQ_MASK_0_IMAGE_MASTER_n_PING_PONG(j);
1830 }
1831
1832 for (i = 0; i < MSM_VFE_IMAGE_MASTERS_NUM; i++)
1833 if (value0 & VFE_0_IRQ_STATUS_0_IMAGE_MASTER_n_PING_PONG(i))
1834 vfe_isr_wm_done(vfe, i);
1835
1836 return IRQ_HANDLED;
1837}
1838
1839/*
1840 * vfe_set_clock_rates - Calculate and set clock rates on VFE module
1841 * @vfe: VFE device
1842 *
1843 * Return 0 on success or a negative error code otherwise
1844 */
1845static int vfe_set_clock_rates(struct vfe_device *vfe)
1846{
1847 struct device *dev = to_device(vfe);
1848 u32 pixel_clock[MSM_VFE_LINE_NUM];
1849 int i, j;
1850 int ret;
1851
1852 for (i = VFE_LINE_RDI0; i <= VFE_LINE_PIX; i++) {
1853 ret = camss_get_pixel_clock(&vfe->line[i].subdev.entity,
1854 &pixel_clock[i]);
1855 if (ret)
1856 pixel_clock[i] = 0;
1857 }
1858
1859 for (i = 0; i < vfe->nclocks; i++) {
1860 struct camss_clock *clock = &vfe->clock[i];
1861
1862 if (!strcmp(clock->name, "camss_vfe_vfe")) {
1863 u64 min_rate = 0;
1864 long rate;
1865
1866 for (j = VFE_LINE_RDI0; j <= VFE_LINE_PIX; j++) {
1867 u32 tmp;
1868 u8 bpp;
1869
1870 if (j == VFE_LINE_PIX) {
1871 tmp = pixel_clock[j];
1872 } else {
1873 bpp = vfe_get_bpp(vfe->line[j].
1874 fmt[MSM_VFE_PAD_SINK].code);
1875 tmp = pixel_clock[j] * bpp / 64;
1876 }
1877
1878 if (min_rate < tmp)
1879 min_rate = tmp;
1880 }
1881
1882 camss_add_clock_margin(&min_rate);
1883
1884 for (j = 0; j < clock->nfreqs; j++)
1885 if (min_rate < clock->freq[j])
1886 break;
1887
1888 if (j == clock->nfreqs) {
1889 dev_err(dev,
1890 "Pixel clock is too high for VFE");
1891 return -EINVAL;
1892 }
1893
1894 /* if sensor pixel clock is not available */
1895 /* set highest possible VFE clock rate */
1896 if (min_rate == 0)
1897 j = clock->nfreqs - 1;
1898
1899 rate = clk_round_rate(clock->clk, clock->freq[j]);
1900 if (rate < 0) {
1901 dev_err(dev, "clk round rate failed: %ld\n",
1902 rate);
1903 return -EINVAL;
1904 }
1905
1906 ret = clk_set_rate(clock->clk, rate);
1907 if (ret < 0) {
1908 dev_err(dev, "clk set rate failed: %d\n", ret);
1909 return ret;
1910 }
1911 }
1912 }
1913
1914 return 0;
1915}
1916
1917/*
1918 * vfe_check_clock_rates - Check current clock rates on VFE module
1919 * @vfe: VFE device
1920 *
1921 * Return 0 if current clock rates are suitable for a new pipeline
1922 * or a negative error code otherwise
1923 */
1924static int vfe_check_clock_rates(struct vfe_device *vfe)
1925{
1926 u32 pixel_clock[MSM_VFE_LINE_NUM];
1927 int i, j;
1928 int ret;
1929
1930 for (i = VFE_LINE_RDI0; i <= VFE_LINE_PIX; i++) {
1931 ret = camss_get_pixel_clock(&vfe->line[i].subdev.entity,
1932 &pixel_clock[i]);
1933 if (ret)
1934 pixel_clock[i] = 0;
1935 }
1936
1937 for (i = 0; i < vfe->nclocks; i++) {
1938 struct camss_clock *clock = &vfe->clock[i];
1939
1940 if (!strcmp(clock->name, "camss_vfe_vfe")) {
1941 u64 min_rate = 0;
1942 unsigned long rate;
1943
1944 for (j = VFE_LINE_RDI0; j <= VFE_LINE_PIX; j++) {
1945 u32 tmp;
1946 u8 bpp;
1947
1948 if (j == VFE_LINE_PIX) {
1949 tmp = pixel_clock[j];
1950 } else {
1951 bpp = vfe_get_bpp(vfe->line[j].
1952 fmt[MSM_VFE_PAD_SINK].code);
1953 tmp = pixel_clock[j] * bpp / 64;
1954 }
1955
1956 if (min_rate < tmp)
1957 min_rate = tmp;
1958 }
1959
1960 camss_add_clock_margin(&min_rate);
1961
1962 rate = clk_get_rate(clock->clk);
1963 if (rate < min_rate)
1964 return -EBUSY;
1965 }
1966 }
1967
1968 return 0;
1969}
1970
1971/*
1972 * vfe_get - Power up and reset VFE module
1973 * @vfe: VFE Device
1974 *
1975 * Return 0 on success or a negative error code otherwise
1976 */
1977static int vfe_get(struct vfe_device *vfe)
1978{
1979 int ret;
1980
1981 mutex_lock(&vfe->power_lock);
1982
1983 if (vfe->power_count == 0) {
1984 ret = vfe_set_clock_rates(vfe);
1985 if (ret < 0)
1986 goto error_clocks;
1987
1988 ret = camss_enable_clocks(vfe->nclocks, vfe->clock,
1989 to_device(vfe));
1990 if (ret < 0)
1991 goto error_clocks;
1992
1993 ret = vfe_reset(vfe);
1994 if (ret < 0)
1995 goto error_reset;
1996
1997 vfe_reset_output_maps(vfe);
1998
1999 vfe_init_outputs(vfe);
2000 } else {
2001 ret = vfe_check_clock_rates(vfe);
2002 if (ret < 0)
2003 goto error_clocks;
2004 }
2005 vfe->power_count++;
2006
2007 mutex_unlock(&vfe->power_lock);
2008
2009 return 0;
2010
2011error_reset:
2012 camss_disable_clocks(vfe->nclocks, vfe->clock);
2013
2014error_clocks:
2015 mutex_unlock(&vfe->power_lock);
2016
2017 return ret;
2018}
2019
2020/*
2021 * vfe_put - Power down VFE module
2022 * @vfe: VFE Device
2023 */
2024static void vfe_put(struct vfe_device *vfe)
2025{
2026 mutex_lock(&vfe->power_lock);
2027
2028 if (vfe->power_count == 0) {
2029 dev_err(to_device(vfe), "vfe power off on power_count == 0\n");
2030 goto exit;
2031 } else if (vfe->power_count == 1) {
2032 if (vfe->was_streaming) {
2033 vfe->was_streaming = 0;
2034 vfe_halt(vfe);
2035 }
2036 camss_disable_clocks(vfe->nclocks, vfe->clock);
2037 }
2038
2039 vfe->power_count--;
2040
2041exit:
2042 mutex_unlock(&vfe->power_lock);
2043}
2044
2045/*
2046 * vfe_video_pad_to_line - Get pointer to VFE line by media pad
2047 * @pad: Media pad
2048 *
2049 * Return pointer to vfe line structure
2050 */
2051static struct vfe_line *vfe_video_pad_to_line(struct media_pad *pad)
2052{
2053 struct media_pad *vfe_pad;
2054 struct v4l2_subdev *subdev;
2055
2056 vfe_pad = media_entity_remote_pad(pad);
2057 if (vfe_pad == NULL)
2058 return NULL;
2059
2060 subdev = media_entity_to_v4l2_subdev(vfe_pad->entity);
2061
2062 return container_of(subdev, struct vfe_line, subdev);
2063}
2064
2065/*
2066 * vfe_queue_buffer - Add empty buffer
2067 * @vid: Video device structure
2068 * @buf: Buffer to be enqueued
2069 *
2070 * Add an empty buffer - depending on the current number of buffers it will be
2071 * put in pending buffer queue or directly given to the hardware to be filled.
2072 *
2073 * Return 0 on success or a negative error code otherwise
2074 */
2075static int vfe_queue_buffer(struct camss_video *vid,
2076 struct camss_buffer *buf)
2077{
2078 struct vfe_device *vfe = &vid->camss->vfe;
2079 struct vfe_line *line;
2080 struct vfe_output *output;
2081 unsigned long flags;
2082
2083 line = vfe_video_pad_to_line(&vid->pad);
2084 if (!line) {
2085 dev_err(to_device(vfe), "Can not queue buffer\n");
2086 return -1;
2087 }
2088 output = &line->output;
2089
2090 spin_lock_irqsave(&vfe->output_lock, flags);
2091
2092 vfe_buf_update_wm_on_new(vfe, output, buf);
2093
2094 spin_unlock_irqrestore(&vfe->output_lock, flags);
2095
2096 return 0;
2097}
2098
2099/*
2100 * vfe_flush_buffers - Return all vb2 buffers
2101 * @vid: Video device structure
2102 * @state: vb2 buffer state of the returned buffers
2103 *
2104 * Return all buffers to vb2. This includes queued pending buffers (still
2105 * unused) and any buffers given to the hardware but again still not used.
2106 *
2107 * Return 0 on success or a negative error code otherwise
2108 */
2109static int vfe_flush_buffers(struct camss_video *vid,
2110 enum vb2_buffer_state state)
2111{
2112 struct vfe_device *vfe = &vid->camss->vfe;
2113 struct vfe_line *line;
2114 struct vfe_output *output;
2115 unsigned long flags;
2116
2117 line = vfe_video_pad_to_line(&vid->pad);
2118 if (!line) {
2119 dev_err(to_device(vfe), "Can not flush buffers\n");
2120 return -1;
2121 }
2122 output = &line->output;
2123
2124 spin_lock_irqsave(&vfe->output_lock, flags);
2125
2126 vfe_buf_flush_pending(output, state);
2127
2128 if (output->buf[0])
2129 vb2_buffer_done(&output->buf[0]->vb.vb2_buf, state);
2130
2131 if (output->buf[1])
2132 vb2_buffer_done(&output->buf[1]->vb.vb2_buf, state);
2133
2134 if (output->last_buffer) {
2135 vb2_buffer_done(&output->last_buffer->vb.vb2_buf, state);
2136 output->last_buffer = NULL;
2137 }
2138
2139 spin_unlock_irqrestore(&vfe->output_lock, flags);
2140
2141 return 0;
2142}
2143
2144/*
2145 * vfe_set_power - Power on/off VFE module
2146 * @sd: VFE V4L2 subdevice
2147 * @on: Requested power state
2148 *
2149 * Return 0 on success or a negative error code otherwise
2150 */
2151static int vfe_set_power(struct v4l2_subdev *sd, int on)
2152{
2153 struct vfe_line *line = v4l2_get_subdevdata(sd);
2154 struct vfe_device *vfe = to_vfe(line);
2155 int ret;
2156
2157 if (on) {
2158 u32 hw_version;
2159
2160 ret = vfe_get(vfe);
2161 if (ret < 0)
2162 return ret;
2163
2164 hw_version = readl_relaxed(vfe->base + VFE_0_HW_VERSION);
2165 dev_dbg(to_device(vfe),
2166 "VFE HW Version = 0x%08x\n", hw_version);
2167 } else {
2168 vfe_put(vfe);
2169 }
2170
2171 return 0;
2172}
2173
2174/*
2175 * vfe_set_stream - Enable/disable streaming on VFE module
2176 * @sd: VFE V4L2 subdevice
2177 * @enable: Requested streaming state
2178 *
2179 * Main configuration of VFE module is triggered here.
2180 *
2181 * Return 0 on success or a negative error code otherwise
2182 */
2183static int vfe_set_stream(struct v4l2_subdev *sd, int enable)
2184{
2185 struct vfe_line *line = v4l2_get_subdevdata(sd);
2186 struct vfe_device *vfe = to_vfe(line);
2187 int ret;
2188
2189 if (enable) {
2190 ret = vfe_enable(line);
2191 if (ret < 0)
2192 dev_err(to_device(vfe),
2193 "Failed to enable vfe outputs\n");
2194 } else {
2195 ret = vfe_disable(line);
2196 if (ret < 0)
2197 dev_err(to_device(vfe),
2198 "Failed to disable vfe outputs\n");
2199 }
2200
2201 return ret;
2202}
2203
2204/*
2205 * __vfe_get_format - Get pointer to format structure
2206 * @line: VFE line
2207 * @cfg: V4L2 subdev pad configuration
2208 * @pad: pad from which format is requested
2209 * @which: TRY or ACTIVE format
2210 *
2211 * Return pointer to TRY or ACTIVE format structure
2212 */
2213static struct v4l2_mbus_framefmt *
2214__vfe_get_format(struct vfe_line *line,
2215 struct v4l2_subdev_pad_config *cfg,
2216 unsigned int pad,
2217 enum v4l2_subdev_format_whence which)
2218{
2219 if (which == V4L2_SUBDEV_FORMAT_TRY)
2220 return v4l2_subdev_get_try_format(&line->subdev, cfg, pad);
2221
2222 return &line->fmt[pad];
2223}
2224
2225/*
2226 * __vfe_get_compose - Get pointer to compose selection structure
2227 * @line: VFE line
2228 * @cfg: V4L2 subdev pad configuration
2229 * @which: TRY or ACTIVE format
2230 *
2231 * Return pointer to TRY or ACTIVE compose rectangle structure
2232 */
2233static struct v4l2_rect *
2234__vfe_get_compose(struct vfe_line *line,
2235 struct v4l2_subdev_pad_config *cfg,
2236 enum v4l2_subdev_format_whence which)
2237{
2238 if (which == V4L2_SUBDEV_FORMAT_TRY)
2239 return v4l2_subdev_get_try_compose(&line->subdev, cfg,
2240 MSM_VFE_PAD_SINK);
2241
2242 return &line->compose;
2243}
2244
2245/*
2246 * __vfe_get_crop - Get pointer to crop selection structure
2247 * @line: VFE line
2248 * @cfg: V4L2 subdev pad configuration
2249 * @which: TRY or ACTIVE format
2250 *
2251 * Return pointer to TRY or ACTIVE crop rectangle structure
2252 */
2253static struct v4l2_rect *
2254__vfe_get_crop(struct vfe_line *line,
2255 struct v4l2_subdev_pad_config *cfg,
2256 enum v4l2_subdev_format_whence which)
2257{
2258 if (which == V4L2_SUBDEV_FORMAT_TRY)
2259 return v4l2_subdev_get_try_crop(&line->subdev, cfg,
2260 MSM_VFE_PAD_SRC);
2261
2262 return &line->crop;
2263}
2264
2265/*
2266 * vfe_try_format - Handle try format by pad subdev method
2267 * @line: VFE line
2268 * @cfg: V4L2 subdev pad configuration
2269 * @pad: pad on which format is requested
2270 * @fmt: pointer to v4l2 format structure
2271 * @which: wanted subdev format
2272 */
2273static void vfe_try_format(struct vfe_line *line,
2274 struct v4l2_subdev_pad_config *cfg,
2275 unsigned int pad,
2276 struct v4l2_mbus_framefmt *fmt,
2277 enum v4l2_subdev_format_whence which)
2278{
2279 unsigned int i;
2280 u32 code;
2281
2282 switch (pad) {
2283 case MSM_VFE_PAD_SINK:
2284 /* Set format on sink pad */
2285
2286 for (i = 0; i < ARRAY_SIZE(vfe_formats); i++)
2287 if (fmt->code == vfe_formats[i].code)
2288 break;
2289
2290 /* If not found, use UYVY as default */
2291 if (i >= ARRAY_SIZE(vfe_formats))
2292 fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
2293
2294 fmt->width = clamp_t(u32, fmt->width, 1, 8191);
2295 fmt->height = clamp_t(u32, fmt->height, 1, 8191);
2296
2297 fmt->field = V4L2_FIELD_NONE;
2298 fmt->colorspace = V4L2_COLORSPACE_SRGB;
2299
2300 break;
2301
2302 case MSM_VFE_PAD_SRC:
2303 /* Set and return a format same as sink pad */
2304
2305 code = fmt->code;
2306
2307 *fmt = *__vfe_get_format(line, cfg, MSM_VFE_PAD_SINK,
2308 which);
2309
2310 if (line->id == VFE_LINE_PIX) {
2311 struct v4l2_rect *rect;
2312
2313 rect = __vfe_get_crop(line, cfg, which);
2314
2315 fmt->width = rect->width;
2316 fmt->height = rect->height;
2317
2318 switch (fmt->code) {
2319 case MEDIA_BUS_FMT_YUYV8_2X8:
2320 if (code == MEDIA_BUS_FMT_YUYV8_1_5X8)
2321 fmt->code = MEDIA_BUS_FMT_YUYV8_1_5X8;
2322 else
2323 fmt->code = MEDIA_BUS_FMT_YUYV8_2X8;
2324 break;
2325 case MEDIA_BUS_FMT_YVYU8_2X8:
2326 if (code == MEDIA_BUS_FMT_YVYU8_1_5X8)
2327 fmt->code = MEDIA_BUS_FMT_YVYU8_1_5X8;
2328 else
2329 fmt->code = MEDIA_BUS_FMT_YVYU8_2X8;
2330 break;
2331 case MEDIA_BUS_FMT_UYVY8_2X8:
2332 default:
2333 if (code == MEDIA_BUS_FMT_UYVY8_1_5X8)
2334 fmt->code = MEDIA_BUS_FMT_UYVY8_1_5X8;
2335 else
2336 fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
2337 break;
2338 case MEDIA_BUS_FMT_VYUY8_2X8:
2339 if (code == MEDIA_BUS_FMT_VYUY8_1_5X8)
2340 fmt->code = MEDIA_BUS_FMT_VYUY8_1_5X8;
2341 else
2342 fmt->code = MEDIA_BUS_FMT_VYUY8_2X8;
2343 break;
2344 }
2345 }
2346
2347 break;
2348 }
2349
2350 fmt->colorspace = V4L2_COLORSPACE_SRGB;
2351}
2352
2353/*
2354 * vfe_try_compose - Handle try compose selection by pad subdev method
2355 * @line: VFE line
2356 * @cfg: V4L2 subdev pad configuration
2357 * @rect: pointer to v4l2 rect structure
2358 * @which: wanted subdev format
2359 */
2360static void vfe_try_compose(struct vfe_line *line,
2361 struct v4l2_subdev_pad_config *cfg,
2362 struct v4l2_rect *rect,
2363 enum v4l2_subdev_format_whence which)
2364{
2365 struct v4l2_mbus_framefmt *fmt;
2366
2367 fmt = __vfe_get_format(line, cfg, MSM_VFE_PAD_SINK, which);
2368
2369 if (rect->width > fmt->width)
2370 rect->width = fmt->width;
2371
2372 if (rect->height > fmt->height)
2373 rect->height = fmt->height;
2374
2375 if (fmt->width > rect->width * SCALER_RATIO_MAX)
2376 rect->width = (fmt->width + SCALER_RATIO_MAX - 1) /
2377 SCALER_RATIO_MAX;
2378
2379 rect->width &= ~0x1;
2380
2381 if (fmt->height > rect->height * SCALER_RATIO_MAX)
2382 rect->height = (fmt->height + SCALER_RATIO_MAX - 1) /
2383 SCALER_RATIO_MAX;
2384
2385 if (rect->width < 16)
2386 rect->width = 16;
2387
2388 if (rect->height < 4)
2389 rect->height = 4;
2390}
2391
2392/*
2393 * vfe_try_crop - Handle try crop selection by pad subdev method
2394 * @line: VFE line
2395 * @cfg: V4L2 subdev pad configuration
2396 * @rect: pointer to v4l2 rect structure
2397 * @which: wanted subdev format
2398 */
2399static void vfe_try_crop(struct vfe_line *line,
2400 struct v4l2_subdev_pad_config *cfg,
2401 struct v4l2_rect *rect,
2402 enum v4l2_subdev_format_whence which)
2403{
2404 struct v4l2_rect *compose;
2405
2406 compose = __vfe_get_compose(line, cfg, which);
2407
2408 if (rect->width > compose->width)
2409 rect->width = compose->width;
2410
2411 if (rect->width + rect->left > compose->width)
2412 rect->left = compose->width - rect->width;
2413
2414 if (rect->height > compose->height)
2415 rect->height = compose->height;
2416
2417 if (rect->height + rect->top > compose->height)
2418 rect->top = compose->height - rect->height;
2419
2420 /* wm in line based mode writes multiple of 16 horizontally */
2421 rect->left += (rect->width & 0xf) >> 1;
2422 rect->width &= ~0xf;
2423
2424 if (rect->width < 16) {
2425 rect->left = 0;
2426 rect->width = 16;
2427 }
2428
2429 if (rect->height < 4) {
2430 rect->top = 0;
2431 rect->height = 4;
2432 }
2433}
2434
2435/*
2436 * vfe_enum_mbus_code - Handle pixel format enumeration
2437 * @sd: VFE V4L2 subdevice
2438 * @cfg: V4L2 subdev pad configuration
2439 * @code: pointer to v4l2_subdev_mbus_code_enum structure
2440 *
2441 * return -EINVAL or zero on success
2442 */
2443static int vfe_enum_mbus_code(struct v4l2_subdev *sd,
2444 struct v4l2_subdev_pad_config *cfg,
2445 struct v4l2_subdev_mbus_code_enum *code)
2446{
2447 struct vfe_line *line = v4l2_get_subdevdata(sd);
2448 struct v4l2_mbus_framefmt *format;
2449
2450 if (code->pad == MSM_VFE_PAD_SINK) {
2451 if (code->index >= ARRAY_SIZE(vfe_formats))
2452 return -EINVAL;
2453
2454 code->code = vfe_formats[code->index].code;
2455 } else {
2456 if (code->index > 0)
2457 return -EINVAL;
2458
2459 format = __vfe_get_format(line, cfg, MSM_VFE_PAD_SINK,
2460 code->which);
2461
2462 code->code = format->code;
2463 }
2464
2465 return 0;
2466}
2467
2468/*
2469 * vfe_enum_frame_size - Handle frame size enumeration
2470 * @sd: VFE V4L2 subdevice
2471 * @cfg: V4L2 subdev pad configuration
2472 * @fse: pointer to v4l2_subdev_frame_size_enum structure
2473 *
2474 * Return -EINVAL or zero on success
2475 */
2476static int vfe_enum_frame_size(struct v4l2_subdev *sd,
2477 struct v4l2_subdev_pad_config *cfg,
2478 struct v4l2_subdev_frame_size_enum *fse)
2479{
2480 struct vfe_line *line = v4l2_get_subdevdata(sd);
2481 struct v4l2_mbus_framefmt format;
2482
2483 if (fse->index != 0)
2484 return -EINVAL;
2485
2486 format.code = fse->code;
2487 format.width = 1;
2488 format.height = 1;
2489 vfe_try_format(line, cfg, fse->pad, &format, fse->which);
2490 fse->min_width = format.width;
2491 fse->min_height = format.height;
2492
2493 if (format.code != fse->code)
2494 return -EINVAL;
2495
2496 format.code = fse->code;
2497 format.width = -1;
2498 format.height = -1;
2499 vfe_try_format(line, cfg, fse->pad, &format, fse->which);
2500 fse->max_width = format.width;
2501 fse->max_height = format.height;
2502
2503 return 0;
2504}
2505
2506/*
2507 * vfe_get_format - Handle get format by pads subdev method
2508 * @sd: VFE V4L2 subdevice
2509 * @cfg: V4L2 subdev pad configuration
2510 * @fmt: pointer to v4l2 subdev format structure
2511 *
2512 * Return -EINVAL or zero on success
2513 */
2514static int vfe_get_format(struct v4l2_subdev *sd,
2515 struct v4l2_subdev_pad_config *cfg,
2516 struct v4l2_subdev_format *fmt)
2517{
2518 struct vfe_line *line = v4l2_get_subdevdata(sd);
2519 struct v4l2_mbus_framefmt *format;
2520
2521 format = __vfe_get_format(line, cfg, fmt->pad, fmt->which);
2522 if (format == NULL)
2523 return -EINVAL;
2524
2525 fmt->format = *format;
2526
2527 return 0;
2528}
2529
2530static int vfe_set_selection(struct v4l2_subdev *sd,
2531 struct v4l2_subdev_pad_config *cfg,
2532 struct v4l2_subdev_selection *sel);
2533
2534/*
2535 * vfe_set_format - Handle set format by pads subdev method
2536 * @sd: VFE V4L2 subdevice
2537 * @cfg: V4L2 subdev pad configuration
2538 * @fmt: pointer to v4l2 subdev format structure
2539 *
2540 * Return -EINVAL or zero on success
2541 */
2542static int vfe_set_format(struct v4l2_subdev *sd,
2543 struct v4l2_subdev_pad_config *cfg,
2544 struct v4l2_subdev_format *fmt)
2545{
2546 struct vfe_line *line = v4l2_get_subdevdata(sd);
2547 struct v4l2_mbus_framefmt *format;
2548
2549 format = __vfe_get_format(line, cfg, fmt->pad, fmt->which);
2550 if (format == NULL)
2551 return -EINVAL;
2552
2553 vfe_try_format(line, cfg, fmt->pad, &fmt->format, fmt->which);
2554 *format = fmt->format;
2555
2556 if (fmt->pad == MSM_VFE_PAD_SINK) {
2557 struct v4l2_subdev_selection sel = { 0 };
2558 int ret;
2559
2560 /* Propagate the format from sink to source */
2561 format = __vfe_get_format(line, cfg, MSM_VFE_PAD_SRC,
2562 fmt->which);
2563
2564 *format = fmt->format;
2565 vfe_try_format(line, cfg, MSM_VFE_PAD_SRC, format,
2566 fmt->which);
2567
2568 if (line->id != VFE_LINE_PIX)
2569 return 0;
2570
2571 /* Reset sink pad compose selection */
2572 sel.which = fmt->which;
2573 sel.pad = MSM_VFE_PAD_SINK;
2574 sel.target = V4L2_SEL_TGT_COMPOSE;
2575 sel.r.width = fmt->format.width;
2576 sel.r.height = fmt->format.height;
2577 ret = vfe_set_selection(sd, cfg, &sel);
2578 if (ret < 0)
2579 return ret;
2580 }
2581
2582 return 0;
2583}
2584
2585/*
2586 * vfe_get_selection - Handle get selection by pads subdev method
2587 * @sd: VFE V4L2 subdevice
2588 * @cfg: V4L2 subdev pad configuration
2589 * @sel: pointer to v4l2 subdev selection structure
2590 *
2591 * Return -EINVAL or zero on success
2592 */
2593static int vfe_get_selection(struct v4l2_subdev *sd,
2594 struct v4l2_subdev_pad_config *cfg,
2595 struct v4l2_subdev_selection *sel)
2596{
2597 struct vfe_line *line = v4l2_get_subdevdata(sd);
2598 struct v4l2_subdev_format fmt = { 0 };
2599 struct v4l2_rect *rect;
2600 int ret;
2601
2602 if (line->id != VFE_LINE_PIX)
2603 return -EINVAL;
2604
2605 if (sel->pad == MSM_VFE_PAD_SINK)
2606 switch (sel->target) {
2607 case V4L2_SEL_TGT_COMPOSE_BOUNDS:
2608 fmt.pad = sel->pad;
2609 fmt.which = sel->which;
2610 ret = vfe_get_format(sd, cfg, &fmt);
2611 if (ret < 0)
2612 return ret;
2613
2614 sel->r.left = 0;
2615 sel->r.top = 0;
2616 sel->r.width = fmt.format.width;
2617 sel->r.height = fmt.format.height;
2618 break;
2619 case V4L2_SEL_TGT_COMPOSE:
2620 rect = __vfe_get_compose(line, cfg, sel->which);
2621 if (rect == NULL)
2622 return -EINVAL;
2623
2624 sel->r = *rect;
2625 break;
2626 default:
2627 return -EINVAL;
2628 }
2629 else if (sel->pad == MSM_VFE_PAD_SRC)
2630 switch (sel->target) {
2631 case V4L2_SEL_TGT_CROP_BOUNDS:
2632 rect = __vfe_get_compose(line, cfg, sel->which);
2633 if (rect == NULL)
2634 return -EINVAL;
2635
2636 sel->r.left = rect->left;
2637 sel->r.top = rect->top;
2638 sel->r.width = rect->width;
2639 sel->r.height = rect->height;
2640 break;
2641 case V4L2_SEL_TGT_CROP:
2642 rect = __vfe_get_crop(line, cfg, sel->which);
2643 if (rect == NULL)
2644 return -EINVAL;
2645
2646 sel->r = *rect;
2647 break;
2648 default:
2649 return -EINVAL;
2650 }
2651
2652 return 0;
2653}
2654
2655/*
2656 * vfe_set_selection - Handle set selection by pads subdev method
2657 * @sd: VFE V4L2 subdevice
2658 * @cfg: V4L2 subdev pad configuration
2659 * @sel: pointer to v4l2 subdev selection structure
2660 *
2661 * Return -EINVAL or zero on success
2662 */
2663int vfe_set_selection(struct v4l2_subdev *sd,
2664 struct v4l2_subdev_pad_config *cfg,
2665 struct v4l2_subdev_selection *sel)
2666{
2667 struct vfe_line *line = v4l2_get_subdevdata(sd);
2668 struct v4l2_rect *rect;
2669 int ret;
2670
2671 if (line->id != VFE_LINE_PIX)
2672 return -EINVAL;
2673
2674 if (sel->target == V4L2_SEL_TGT_COMPOSE &&
2675 sel->pad == MSM_VFE_PAD_SINK) {
2676 struct v4l2_subdev_selection crop = { 0 };
2677
2678 rect = __vfe_get_compose(line, cfg, sel->which);
2679 if (rect == NULL)
2680 return -EINVAL;
2681
2682 vfe_try_compose(line, cfg, &sel->r, sel->which);
2683 *rect = sel->r;
2684
2685 /* Reset source crop selection */
2686 crop.which = sel->which;
2687 crop.pad = MSM_VFE_PAD_SRC;
2688 crop.target = V4L2_SEL_TGT_CROP;
2689 crop.r = *rect;
2690 ret = vfe_set_selection(sd, cfg, &crop);
2691 } else if (sel->target == V4L2_SEL_TGT_CROP &&
2692 sel->pad == MSM_VFE_PAD_SRC) {
2693 struct v4l2_subdev_format fmt = { 0 };
2694
2695 rect = __vfe_get_crop(line, cfg, sel->which);
2696 if (rect == NULL)
2697 return -EINVAL;
2698
2699 vfe_try_crop(line, cfg, &sel->r, sel->which);
2700 *rect = sel->r;
2701
2702 /* Reset source pad format width and height */
2703 fmt.which = sel->which;
2704 fmt.pad = MSM_VFE_PAD_SRC;
2705 ret = vfe_get_format(sd, cfg, &fmt);
2706 if (ret < 0)
2707 return ret;
2708
2709 fmt.format.width = rect->width;
2710 fmt.format.height = rect->height;
2711 ret = vfe_set_format(sd, cfg, &fmt);
2712 } else {
2713 ret = -EINVAL;
2714 }
2715
2716 return ret;
2717}
2718
2719/*
2720 * vfe_init_formats - Initialize formats on all pads
2721 * @sd: VFE V4L2 subdevice
2722 * @fh: V4L2 subdev file handle
2723 *
2724 * Initialize all pad formats with default values.
2725 *
2726 * Return 0 on success or a negative error code otherwise
2727 */
2728static int vfe_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
2729{
2730 struct v4l2_subdev_format format = {
2731 .pad = MSM_VFE_PAD_SINK,
2732 .which = fh ? V4L2_SUBDEV_FORMAT_TRY :
2733 V4L2_SUBDEV_FORMAT_ACTIVE,
2734 .format = {
2735 .code = MEDIA_BUS_FMT_UYVY8_2X8,
2736 .width = 1920,
2737 .height = 1080
2738 }
2739 };
2740
2741 return vfe_set_format(sd, fh ? fh->pad : NULL, &format);
2742}
2743
2744/*
2745 * msm_vfe_subdev_init - Initialize VFE device structure and resources
2746 * @vfe: VFE device
2747 * @res: VFE module resources table
2748 *
2749 * Return 0 on success or a negative error code otherwise
2750 */
2751int msm_vfe_subdev_init(struct vfe_device *vfe, const struct resources *res)
2752{
2753 struct device *dev = to_device(vfe);
2754 struct platform_device *pdev = to_platform_device(dev);
2755 struct resource *r;
2756 struct camss *camss = to_camss(vfe);
2757 int i, j;
2758 int ret;
2759
2760 /* Memory */
2761
2762 r = platform_get_resource_byname(pdev, IORESOURCE_MEM, res->reg[0]);
2763 vfe->base = devm_ioremap_resource(dev, r);
2764 if (IS_ERR(vfe->base)) {
2765 dev_err(dev, "could not map memory\n");
2766 return PTR_ERR(vfe->base);
2767 }
2768
2769 /* Interrupt */
2770
2771 r = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
2772 res->interrupt[0]);
2773 if (!r) {
2774 dev_err(dev, "missing IRQ\n");
2775 return -EINVAL;
2776 }
2777
2778 vfe->irq = r->start;
2779 snprintf(vfe->irq_name, sizeof(vfe->irq_name), "%s_%s%d",
2780 dev_name(dev), MSM_VFE_NAME, vfe->id);
2781 ret = devm_request_irq(dev, vfe->irq, vfe_isr,
2782 IRQF_TRIGGER_RISING, vfe->irq_name, vfe);
2783 if (ret < 0) {
2784 dev_err(dev, "request_irq failed: %d\n", ret);
2785 return ret;
2786 }
2787
2788 /* Clocks */
2789
2790 vfe->nclocks = 0;
2791 while (res->clock[vfe->nclocks])
2792 vfe->nclocks++;
2793
2794 vfe->clock = devm_kzalloc(dev, vfe->nclocks * sizeof(*vfe->clock),
2795 GFP_KERNEL);
2796 if (!vfe->clock)
2797 return -ENOMEM;
2798
2799 for (i = 0; i < vfe->nclocks; i++) {
2800 struct camss_clock *clock = &vfe->clock[i];
2801
2802 clock->clk = devm_clk_get(dev, res->clock[i]);
2803 if (IS_ERR(clock->clk))
2804 return PTR_ERR(clock->clk);
2805
2806 clock->name = res->clock[i];
2807
2808 clock->nfreqs = 0;
2809 while (res->clock_rate[i][clock->nfreqs])
2810 clock->nfreqs++;
2811
2812 if (!clock->nfreqs) {
2813 clock->freq = NULL;
2814 continue;
2815 }
2816
2817 clock->freq = devm_kzalloc(dev, clock->nfreqs *
2818 sizeof(*clock->freq), GFP_KERNEL);
2819 if (!clock->freq)
2820 return -ENOMEM;
2821
2822 for (j = 0; j < clock->nfreqs; j++)
2823 clock->freq[j] = res->clock_rate[i][j];
2824 }
2825
2826 mutex_init(&vfe->power_lock);
2827 vfe->power_count = 0;
2828
2829 mutex_init(&vfe->stream_lock);
2830 vfe->stream_count = 0;
2831
2832 spin_lock_init(&vfe->output_lock);
2833
2834 vfe->id = 0;
2835 vfe->reg_update = 0;
2836
2837 for (i = VFE_LINE_RDI0; i <= VFE_LINE_PIX; i++) {
2838 vfe->line[i].video_out.type =
2839 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
2840 vfe->line[i].video_out.camss = camss;
2841 vfe->line[i].id = i;
2842 init_completion(&vfe->line[i].output.sof);
2843 init_completion(&vfe->line[i].output.reg_update);
2844 }
2845
2846 init_completion(&vfe->reset_complete);
2847 init_completion(&vfe->halt_complete);
2848
2849 return 0;
2850}
2851
2852/*
2853 * msm_vfe_get_vfe_id - Get VFE HW module id
2854 * @entity: Pointer to VFE media entity structure
2855 * @id: Return CSID HW module id here
2856 */
2857void msm_vfe_get_vfe_id(struct media_entity *entity, u8 *id)
2858{
2859 struct v4l2_subdev *sd;
2860 struct vfe_line *line;
2861 struct vfe_device *vfe;
2862
2863 sd = media_entity_to_v4l2_subdev(entity);
2864 line = v4l2_get_subdevdata(sd);
2865 vfe = to_vfe(line);
2866
2867 *id = vfe->id;
2868}
2869
2870/*
2871 * msm_vfe_get_vfe_line_id - Get VFE line id by media entity
2872 * @entity: Pointer to VFE media entity structure
2873 * @id: Return VFE line id here
2874 */
2875void msm_vfe_get_vfe_line_id(struct media_entity *entity, enum vfe_line_id *id)
2876{
2877 struct v4l2_subdev *sd;
2878 struct vfe_line *line;
2879
2880 sd = media_entity_to_v4l2_subdev(entity);
2881 line = v4l2_get_subdevdata(sd);
2882
2883 *id = line->id;
2884}
2885
2886/*
2887 * vfe_link_setup - Setup VFE connections
2888 * @entity: Pointer to media entity structure
2889 * @local: Pointer to local pad
2890 * @remote: Pointer to remote pad
2891 * @flags: Link flags
2892 *
2893 * Return 0 on success
2894 */
2895static int vfe_link_setup(struct media_entity *entity,
2896 const struct media_pad *local,
2897 const struct media_pad *remote, u32 flags)
2898{
2899 if (flags & MEDIA_LNK_FL_ENABLED)
2900 if (media_entity_remote_pad(local))
2901 return -EBUSY;
2902
2903 return 0;
2904}
2905
2906static const struct v4l2_subdev_core_ops vfe_core_ops = {
2907 .s_power = vfe_set_power,
2908};
2909
2910static const struct v4l2_subdev_video_ops vfe_video_ops = {
2911 .s_stream = vfe_set_stream,
2912};
2913
2914static const struct v4l2_subdev_pad_ops vfe_pad_ops = {
2915 .enum_mbus_code = vfe_enum_mbus_code,
2916 .enum_frame_size = vfe_enum_frame_size,
2917 .get_fmt = vfe_get_format,
2918 .set_fmt = vfe_set_format,
2919 .get_selection = vfe_get_selection,
2920 .set_selection = vfe_set_selection,
2921};
2922
2923static const struct v4l2_subdev_ops vfe_v4l2_ops = {
2924 .core = &vfe_core_ops,
2925 .video = &vfe_video_ops,
2926 .pad = &vfe_pad_ops,
2927};
2928
2929static const struct v4l2_subdev_internal_ops vfe_v4l2_internal_ops = {
2930 .open = vfe_init_formats,
2931};
2932
2933static const struct media_entity_operations vfe_media_ops = {
2934 .link_setup = vfe_link_setup,
2935 .link_validate = v4l2_subdev_link_validate,
2936};
2937
2938static const struct camss_video_ops camss_vfe_video_ops = {
2939 .queue_buffer = vfe_queue_buffer,
2940 .flush_buffers = vfe_flush_buffers,
2941};
2942
2943void msm_vfe_stop_streaming(struct vfe_device *vfe)
2944{
2945 int i;
2946
2947 for (i = 0; i < ARRAY_SIZE(vfe->line); i++)
2948 msm_video_stop_streaming(&vfe->line[i].video_out);
2949}
2950
2951/*
2952 * msm_vfe_register_entities - Register subdev node for VFE module
2953 * @vfe: VFE device
2954 * @v4l2_dev: V4L2 device
2955 *
2956 * Initialize and register a subdev node for the VFE module. Then
2957 * call msm_video_register() to register the video device node which
2958 * will be connected to this subdev node. Then actually create the
2959 * media link between them.
2960 *
2961 * Return 0 on success or a negative error code otherwise
2962 */
2963int msm_vfe_register_entities(struct vfe_device *vfe,
2964 struct v4l2_device *v4l2_dev)
2965{
2966 struct device *dev = to_device(vfe);
2967 struct v4l2_subdev *sd;
2968 struct media_pad *pads;
2969 struct camss_video *video_out;
2970 int ret;
2971 int i;
2972
2973 for (i = 0; i < ARRAY_SIZE(vfe->line); i++) {
2974 char name[32];
2975
2976 sd = &vfe->line[i].subdev;
2977 pads = vfe->line[i].pads;
2978 video_out = &vfe->line[i].video_out;
2979
2980 v4l2_subdev_init(sd, &vfe_v4l2_ops);
2981 sd->internal_ops = &vfe_v4l2_internal_ops;
2982 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
2983 if (i == VFE_LINE_PIX)
2984 snprintf(sd->name, ARRAY_SIZE(sd->name), "%s%d_%s",
2985 MSM_VFE_NAME, vfe->id, "pix");
2986 else
2987 snprintf(sd->name, ARRAY_SIZE(sd->name), "%s%d_%s%d",
2988 MSM_VFE_NAME, vfe->id, "rdi", i);
2989
2990 v4l2_set_subdevdata(sd, &vfe->line[i]);
2991
2992 ret = vfe_init_formats(sd, NULL);
2993 if (ret < 0) {
2994 dev_err(dev, "Failed to init format: %d\n", ret);
2995 goto error_init;
2996 }
2997
2998 pads[MSM_VFE_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
2999 pads[MSM_VFE_PAD_SRC].flags = MEDIA_PAD_FL_SOURCE;
3000
3001 sd->entity.function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER;
3002 sd->entity.ops = &vfe_media_ops;
3003 ret = media_entity_pads_init(&sd->entity, MSM_VFE_PADS_NUM,
3004 pads);
3005 if (ret < 0) {
3006 dev_err(dev, "Failed to init media entity: %d\n", ret);
3007 goto error_init;
3008 }
3009
3010 ret = v4l2_device_register_subdev(v4l2_dev, sd);
3011 if (ret < 0) {
3012 dev_err(dev, "Failed to register subdev: %d\n", ret);
3013 goto error_reg_subdev;
3014 }
3015
3016 video_out->ops = &camss_vfe_video_ops;
3017 video_out->bpl_alignment = 8;
3018 video_out->line_based = 0;
3019 if (i == VFE_LINE_PIX) {
3020 video_out->bpl_alignment = 16;
3021 video_out->line_based = 1;
3022 }
3023 snprintf(name, ARRAY_SIZE(name), "%s%d_%s%d",
3024 MSM_VFE_NAME, vfe->id, "video", i);
3025 ret = msm_video_register(video_out, v4l2_dev, name,
3026 i == VFE_LINE_PIX ? 1 : 0);
3027 if (ret < 0) {
3028 dev_err(dev, "Failed to register video node: %d\n",
3029 ret);
3030 goto error_reg_video;
3031 }
3032
3033 ret = media_create_pad_link(
3034 &sd->entity, MSM_VFE_PAD_SRC,
3035 &video_out->vdev.entity, 0,
3036 MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED);
3037 if (ret < 0) {
3038 dev_err(dev, "Failed to link %s->%s entities: %d\n",
3039 sd->entity.name, video_out->vdev.entity.name,
3040 ret);
3041 goto error_link;
3042 }
3043 }
3044
3045 return 0;
3046
3047error_link:
3048 msm_video_unregister(video_out);
3049
3050error_reg_video:
3051 v4l2_device_unregister_subdev(sd);
3052
3053error_reg_subdev:
3054 media_entity_cleanup(&sd->entity);
3055
3056error_init:
3057 for (i--; i >= 0; i--) {
3058 sd = &vfe->line[i].subdev;
3059 video_out = &vfe->line[i].video_out;
3060
3061 msm_video_unregister(video_out);
3062 v4l2_device_unregister_subdev(sd);
3063 media_entity_cleanup(&sd->entity);
3064 }
3065
3066 return ret;
3067}
3068
3069/*
3070 * msm_vfe_unregister_entities - Unregister VFE module subdev node
3071 * @vfe: VFE device
3072 */
3073void msm_vfe_unregister_entities(struct vfe_device *vfe)
3074{
3075 int i;
3076
3077 mutex_destroy(&vfe->power_lock);
3078 mutex_destroy(&vfe->stream_lock);
3079
3080 for (i = 0; i < ARRAY_SIZE(vfe->line); i++) {
3081 struct v4l2_subdev *sd = &vfe->line[i].subdev;
3082 struct camss_video *video_out = &vfe->line[i].video_out;
3083
3084 msm_video_unregister(video_out);
3085 v4l2_device_unregister_subdev(sd);
3086 media_entity_cleanup(&sd->entity);
3087 }
3088}
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-vfe.h b/drivers/media/platform/qcom/camss-8x16/camss-vfe.h
new file mode 100644
index 000000000000..53d5b66a9dfb
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/camss-vfe.h
@@ -0,0 +1,123 @@
1/*
2 * camss-vfe.h
3 *
4 * Qualcomm MSM Camera Subsystem - VFE (Video Front End) Module
5 *
6 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
7 * Copyright (C) 2015-2017 Linaro Ltd.
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 version 2 and
11 * only version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18#ifndef QC_MSM_CAMSS_VFE_H
19#define QC_MSM_CAMSS_VFE_H
20
21#include <linux/clk.h>
22#include <linux/spinlock_types.h>
23#include <media/media-entity.h>
24#include <media/v4l2-device.h>
25#include <media/v4l2-subdev.h>
26
27#include "camss-video.h"
28
29#define MSM_VFE_PAD_SINK 0
30#define MSM_VFE_PAD_SRC 1
31#define MSM_VFE_PADS_NUM 2
32
33#define MSM_VFE_LINE_NUM 4
34#define MSM_VFE_IMAGE_MASTERS_NUM 7
35#define MSM_VFE_COMPOSITE_IRQ_NUM 4
36
37#define MSM_VFE_VFE0_UB_SIZE 1023
38#define MSM_VFE_VFE0_UB_SIZE_RDI (MSM_VFE_VFE0_UB_SIZE / 3)
39#define MSM_VFE_VFE1_UB_SIZE 1535
40#define MSM_VFE_VFE1_UB_SIZE_RDI (MSM_VFE_VFE1_UB_SIZE / 3)
41
42enum vfe_output_state {
43 VFE_OUTPUT_OFF,
44 VFE_OUTPUT_RESERVED,
45 VFE_OUTPUT_SINGLE,
46 VFE_OUTPUT_CONTINUOUS,
47 VFE_OUTPUT_IDLE,
48 VFE_OUTPUT_STOPPING
49};
50
51enum vfe_line_id {
52 VFE_LINE_NONE = -1,
53 VFE_LINE_RDI0 = 0,
54 VFE_LINE_RDI1 = 1,
55 VFE_LINE_RDI2 = 2,
56 VFE_LINE_PIX = 3
57};
58
59struct vfe_output {
60 u8 wm_num;
61 u8 wm_idx[3];
62
63 int active_buf;
64 struct camss_buffer *buf[2];
65 struct camss_buffer *last_buffer;
66 struct list_head pending_bufs;
67
68 unsigned int drop_update_idx;
69
70 enum vfe_output_state state;
71 unsigned int sequence;
72 int wait_sof;
73 int wait_reg_update;
74 struct completion sof;
75 struct completion reg_update;
76};
77
78struct vfe_line {
79 enum vfe_line_id id;
80 struct v4l2_subdev subdev;
81 struct media_pad pads[MSM_VFE_PADS_NUM];
82 struct v4l2_mbus_framefmt fmt[MSM_VFE_PADS_NUM];
83 struct v4l2_rect compose;
84 struct v4l2_rect crop;
85 struct camss_video video_out;
86 struct vfe_output output;
87};
88
89struct vfe_device {
90 u8 id;
91 void __iomem *base;
92 u32 irq;
93 char irq_name[30];
94 struct camss_clock *clock;
95 int nclocks;
96 struct completion reset_complete;
97 struct completion halt_complete;
98 struct mutex power_lock;
99 int power_count;
100 struct mutex stream_lock;
101 int stream_count;
102 spinlock_t output_lock;
103 enum vfe_line_id wm_output_map[MSM_VFE_IMAGE_MASTERS_NUM];
104 struct vfe_line line[MSM_VFE_LINE_NUM];
105 u32 reg_update;
106 u8 was_streaming;
107};
108
109struct resources;
110
111int msm_vfe_subdev_init(struct vfe_device *vfe, const struct resources *res);
112
113int msm_vfe_register_entities(struct vfe_device *vfe,
114 struct v4l2_device *v4l2_dev);
115
116void msm_vfe_unregister_entities(struct vfe_device *vfe);
117
118void msm_vfe_get_vfe_id(struct media_entity *entity, u8 *id);
119void msm_vfe_get_vfe_line_id(struct media_entity *entity, enum vfe_line_id *id);
120
121void msm_vfe_stop_streaming(struct vfe_device *vfe);
122
123#endif /* QC_MSM_CAMSS_VFE_H */
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-video.c b/drivers/media/platform/qcom/camss-8x16/camss-video.c
new file mode 100644
index 000000000000..cf4219e871bd
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/camss-video.c
@@ -0,0 +1,860 @@
1/*
2 * camss-video.c
3 *
4 * Qualcomm MSM Camera Subsystem - V4L2 device node
5 *
6 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
7 * Copyright (C) 2015-2017 Linaro Ltd.
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 version 2 and
11 * only version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18#include <linux/slab.h>
19#include <media/media-entity.h>
20#include <media/v4l2-dev.h>
21#include <media/v4l2-device.h>
22#include <media/v4l2-ioctl.h>
23#include <media/v4l2-mc.h>
24#include <media/videobuf-core.h>
25#include <media/videobuf2-dma-sg.h>
26
27#include "camss-video.h"
28#include "camss.h"
29
30struct fract {
31 u8 numerator;
32 u8 denominator;
33};
34
35/*
36 * struct camss_format_info - ISP media bus format information
37 * @code: V4L2 media bus format code
38 * @pixelformat: V4L2 pixel format FCC identifier
39 * @planes: Number of planes
40 * @hsub: Horizontal subsampling (for each plane)
41 * @vsub: Vertical subsampling (for each plane)
42 * @bpp: Bits per pixel when stored in memory (for each plane)
43 */
44struct camss_format_info {
45 u32 code;
46 u32 pixelformat;
47 u8 planes;
48 struct fract hsub[3];
49 struct fract vsub[3];
50 unsigned int bpp[3];
51};
52
53static const struct camss_format_info formats_rdi[] = {
54 { MEDIA_BUS_FMT_UYVY8_2X8, V4L2_PIX_FMT_UYVY, 1,
55 { { 1, 1 } }, { { 1, 1 } }, { 16 } },
56 { MEDIA_BUS_FMT_VYUY8_2X8, V4L2_PIX_FMT_VYUY, 1,
57 { { 1, 1 } }, { { 1, 1 } }, { 16 } },
58 { MEDIA_BUS_FMT_YUYV8_2X8, V4L2_PIX_FMT_YUYV, 1,
59 { { 1, 1 } }, { { 1, 1 } }, { 16 } },
60 { MEDIA_BUS_FMT_YVYU8_2X8, V4L2_PIX_FMT_YVYU, 1,
61 { { 1, 1 } }, { { 1, 1 } }, { 16 } },
62 { MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_PIX_FMT_SBGGR8, 1,
63 { { 1, 1 } }, { { 1, 1 } }, { 8 } },
64 { MEDIA_BUS_FMT_SGBRG8_1X8, V4L2_PIX_FMT_SGBRG8, 1,
65 { { 1, 1 } }, { { 1, 1 } }, { 8 } },
66 { MEDIA_BUS_FMT_SGRBG8_1X8, V4L2_PIX_FMT_SGRBG8, 1,
67 { { 1, 1 } }, { { 1, 1 } }, { 8 } },
68 { MEDIA_BUS_FMT_SRGGB8_1X8, V4L2_PIX_FMT_SRGGB8, 1,
69 { { 1, 1 } }, { { 1, 1 } }, { 8 } },
70 { MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_PIX_FMT_SBGGR10P, 1,
71 { { 1, 1 } }, { { 1, 1 } }, { 10 } },
72 { MEDIA_BUS_FMT_SGBRG10_1X10, V4L2_PIX_FMT_SGBRG10P, 1,
73 { { 1, 1 } }, { { 1, 1 } }, { 10 } },
74 { MEDIA_BUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10P, 1,
75 { { 1, 1 } }, { { 1, 1 } }, { 10 } },
76 { MEDIA_BUS_FMT_SRGGB10_1X10, V4L2_PIX_FMT_SRGGB10P, 1,
77 { { 1, 1 } }, { { 1, 1 } }, { 10 } },
78 { MEDIA_BUS_FMT_SBGGR12_1X12, V4L2_PIX_FMT_SBGGR12P, 1,
79 { { 1, 1 } }, { { 1, 1 } }, { 12 } },
80 { MEDIA_BUS_FMT_SGBRG12_1X12, V4L2_PIX_FMT_SGBRG12P, 1,
81 { { 1, 1 } }, { { 1, 1 } }, { 12 } },
82 { MEDIA_BUS_FMT_SGRBG12_1X12, V4L2_PIX_FMT_SGRBG12P, 1,
83 { { 1, 1 } }, { { 1, 1 } }, { 12 } },
84 { MEDIA_BUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12P, 1,
85 { { 1, 1 } }, { { 1, 1 } }, { 12 } },
86};
87
88static const struct camss_format_info formats_pix[] = {
89 { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV12, 1,
90 { { 1, 1 } }, { { 2, 3 } }, { 8 } },
91 { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV12, 1,
92 { { 1, 1 } }, { { 2, 3 } }, { 8 } },
93 { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
94 { { 1, 1 } }, { { 2, 3 } }, { 8 } },
95 { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
96 { { 1, 1 } }, { { 2, 3 } }, { 8 } },
97 { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV21, 1,
98 { { 1, 1 } }, { { 2, 3 } }, { 8 } },
99 { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV21, 1,
100 { { 1, 1 } }, { { 2, 3 } }, { 8 } },
101 { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
102 { { 1, 1 } }, { { 2, 3 } }, { 8 } },
103 { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
104 { { 1, 1 } }, { { 2, 3 } }, { 8 } },
105 { MEDIA_BUS_FMT_YUYV8_2X8, V4L2_PIX_FMT_NV16, 1,
106 { { 1, 1 } }, { { 1, 2 } }, { 8 } },
107 { MEDIA_BUS_FMT_YVYU8_2X8, V4L2_PIX_FMT_NV16, 1,
108 { { 1, 1 } }, { { 1, 2 } }, { 8 } },
109 { MEDIA_BUS_FMT_UYVY8_2X8, V4L2_PIX_FMT_NV16, 1,
110 { { 1, 1 } }, { { 1, 2 } }, { 8 } },
111 { MEDIA_BUS_FMT_VYUY8_2X8, V4L2_PIX_FMT_NV16, 1,
112 { { 1, 1 } }, { { 1, 2 } }, { 8 } },
113 { MEDIA_BUS_FMT_YUYV8_2X8, V4L2_PIX_FMT_NV61, 1,
114 { { 1, 1 } }, { { 1, 2 } }, { 8 } },
115 { MEDIA_BUS_FMT_YVYU8_2X8, V4L2_PIX_FMT_NV61, 1,
116 { { 1, 1 } }, { { 1, 2 } }, { 8 } },
117 { MEDIA_BUS_FMT_UYVY8_2X8, V4L2_PIX_FMT_NV61, 1,
118 { { 1, 1 } }, { { 1, 2 } }, { 8 } },
119 { MEDIA_BUS_FMT_VYUY8_2X8, V4L2_PIX_FMT_NV61, 1,
120 { { 1, 1 } }, { { 1, 2 } }, { 8 } },
121};
122
123/* -----------------------------------------------------------------------------
124 * Helper functions
125 */
126
127static int video_find_format(u32 code, u32 pixelformat,
128 const struct camss_format_info *formats,
129 unsigned int nformats)
130{
131 int i;
132
133 for (i = 0; i < nformats; i++) {
134 if (formats[i].code == code &&
135 formats[i].pixelformat == pixelformat)
136 return i;
137 }
138
139 for (i = 0; i < nformats; i++)
140 if (formats[i].code == code)
141 return i;
142
143 WARN_ON(1);
144
145 return -EINVAL;
146}
147
148/*
149 * video_mbus_to_pix_mp - Convert v4l2_mbus_framefmt to v4l2_pix_format_mplane
150 * @mbus: v4l2_mbus_framefmt format (input)
151 * @pix: v4l2_pix_format_mplane format (output)
152 * @f: a pointer to formats array element to be used for the conversion
153 * @alignment: bytesperline alignment value
154 *
155 * Fill the output pix structure with information from the input mbus format.
156 *
157 * Return 0 on success or a negative error code otherwise
158 */
159static int video_mbus_to_pix_mp(const struct v4l2_mbus_framefmt *mbus,
160 struct v4l2_pix_format_mplane *pix,
161 const struct camss_format_info *f,
162 unsigned int alignment)
163{
164 unsigned int i;
165 u32 bytesperline;
166
167 memset(pix, 0, sizeof(*pix));
168 v4l2_fill_pix_format_mplane(pix, mbus);
169 pix->pixelformat = f->pixelformat;
170 pix->num_planes = f->planes;
171 for (i = 0; i < pix->num_planes; i++) {
172 bytesperline = pix->width / f->hsub[i].numerator *
173 f->hsub[i].denominator * f->bpp[i] / 8;
174 bytesperline = ALIGN(bytesperline, alignment);
175 pix->plane_fmt[i].bytesperline = bytesperline;
176 pix->plane_fmt[i].sizeimage = pix->height /
177 f->vsub[i].numerator * f->vsub[i].denominator *
178 bytesperline;
179 }
180
181 return 0;
182}
183
184static struct v4l2_subdev *video_remote_subdev(struct camss_video *video,
185 u32 *pad)
186{
187 struct media_pad *remote;
188
189 remote = media_entity_remote_pad(&video->pad);
190
191 if (!remote || !is_media_entity_v4l2_subdev(remote->entity))
192 return NULL;
193
194 if (pad)
195 *pad = remote->index;
196
197 return media_entity_to_v4l2_subdev(remote->entity);
198}
199
200static int video_get_subdev_format(struct camss_video *video,
201 struct v4l2_format *format)
202{
203 struct v4l2_subdev_format fmt;
204 struct v4l2_subdev *subdev;
205 u32 pad;
206 int ret;
207
208 subdev = video_remote_subdev(video, &pad);
209 if (subdev == NULL)
210 return -EPIPE;
211
212 fmt.pad = pad;
213 fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
214
215 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
216 if (ret)
217 return ret;
218
219 ret = video_find_format(fmt.format.code,
220 format->fmt.pix_mp.pixelformat,
221 video->formats, video->nformats);
222 if (ret < 0)
223 return ret;
224
225 format->type = video->type;
226
227 return video_mbus_to_pix_mp(&fmt.format, &format->fmt.pix_mp,
228 &video->formats[ret], video->bpl_alignment);
229}
230
231/* -----------------------------------------------------------------------------
232 * Video queue operations
233 */
234
235static int video_queue_setup(struct vb2_queue *q,
236 unsigned int *num_buffers, unsigned int *num_planes,
237 unsigned int sizes[], struct device *alloc_devs[])
238{
239 struct camss_video *video = vb2_get_drv_priv(q);
240 const struct v4l2_pix_format_mplane *format =
241 &video->active_fmt.fmt.pix_mp;
242 unsigned int i;
243
244 if (*num_planes) {
245 if (*num_planes != format->num_planes)
246 return -EINVAL;
247
248 for (i = 0; i < *num_planes; i++)
249 if (sizes[i] < format->plane_fmt[i].sizeimage)
250 return -EINVAL;
251
252 return 0;
253 }
254
255 *num_planes = format->num_planes;
256
257 for (i = 0; i < *num_planes; i++)
258 sizes[i] = format->plane_fmt[i].sizeimage;
259
260 return 0;
261}
262
263static int video_buf_init(struct vb2_buffer *vb)
264{
265 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
266 struct camss_video *video = vb2_get_drv_priv(vb->vb2_queue);
267 struct camss_buffer *buffer = container_of(vbuf, struct camss_buffer,
268 vb);
269 const struct v4l2_pix_format_mplane *format =
270 &video->active_fmt.fmt.pix_mp;
271 struct sg_table *sgt;
272 unsigned int i;
273
274 for (i = 0; i < format->num_planes; i++) {
275 sgt = vb2_dma_sg_plane_desc(vb, i);
276 if (!sgt)
277 return -EFAULT;
278
279 buffer->addr[i] = sg_dma_address(sgt->sgl);
280 }
281
282 if (format->pixelformat == V4L2_PIX_FMT_NV12 ||
283 format->pixelformat == V4L2_PIX_FMT_NV21 ||
284 format->pixelformat == V4L2_PIX_FMT_NV16 ||
285 format->pixelformat == V4L2_PIX_FMT_NV61)
286 buffer->addr[1] = buffer->addr[0] +
287 format->plane_fmt[0].bytesperline *
288 format->height;
289
290 return 0;
291}
292
293static int video_buf_prepare(struct vb2_buffer *vb)
294{
295 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
296 struct camss_video *video = vb2_get_drv_priv(vb->vb2_queue);
297 const struct v4l2_pix_format_mplane *format =
298 &video->active_fmt.fmt.pix_mp;
299 unsigned int i;
300
301 for (i = 0; i < format->num_planes; i++) {
302 if (format->plane_fmt[i].sizeimage > vb2_plane_size(vb, i))
303 return -EINVAL;
304
305 vb2_set_plane_payload(vb, i, format->plane_fmt[i].sizeimage);
306 }
307
308 vbuf->field = V4L2_FIELD_NONE;
309
310 return 0;
311}
312
313static void video_buf_queue(struct vb2_buffer *vb)
314{
315 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
316 struct camss_video *video = vb2_get_drv_priv(vb->vb2_queue);
317 struct camss_buffer *buffer = container_of(vbuf, struct camss_buffer,
318 vb);
319
320 video->ops->queue_buffer(video, buffer);
321}
322
323static int video_check_format(struct camss_video *video)
324{
325 struct v4l2_pix_format_mplane *pix = &video->active_fmt.fmt.pix_mp;
326 struct v4l2_format format;
327 struct v4l2_pix_format_mplane *sd_pix = &format.fmt.pix_mp;
328 int ret;
329
330 sd_pix->pixelformat = pix->pixelformat;
331 ret = video_get_subdev_format(video, &format);
332 if (ret < 0)
333 return ret;
334
335 if (pix->pixelformat != sd_pix->pixelformat ||
336 pix->height != sd_pix->height ||
337 pix->width != sd_pix->width ||
338 pix->num_planes != sd_pix->num_planes ||
339 pix->field != format.fmt.pix_mp.field)
340 return -EPIPE;
341
342 return 0;
343}
344
345static int video_start_streaming(struct vb2_queue *q, unsigned int count)
346{
347 struct camss_video *video = vb2_get_drv_priv(q);
348 struct video_device *vdev = &video->vdev;
349 struct media_entity *entity;
350 struct media_pad *pad;
351 struct v4l2_subdev *subdev;
352 int ret;
353
354 ret = media_pipeline_start(&vdev->entity, &video->pipe);
355 if (ret < 0)
356 return ret;
357
358 ret = video_check_format(video);
359 if (ret < 0)
360 goto error;
361
362 entity = &vdev->entity;
363 while (1) {
364 pad = &entity->pads[0];
365 if (!(pad->flags & MEDIA_PAD_FL_SINK))
366 break;
367
368 pad = media_entity_remote_pad(pad);
369 if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
370 break;
371
372 entity = pad->entity;
373 subdev = media_entity_to_v4l2_subdev(entity);
374
375 ret = v4l2_subdev_call(subdev, video, s_stream, 1);
376 if (ret < 0 && ret != -ENOIOCTLCMD)
377 goto error;
378 }
379
380 return 0;
381
382error:
383 media_pipeline_stop(&vdev->entity);
384
385 video->ops->flush_buffers(video, VB2_BUF_STATE_QUEUED);
386
387 return ret;
388}
389
390static void video_stop_streaming(struct vb2_queue *q)
391{
392 struct camss_video *video = vb2_get_drv_priv(q);
393 struct video_device *vdev = &video->vdev;
394 struct media_entity *entity;
395 struct media_pad *pad;
396 struct v4l2_subdev *subdev;
397
398 entity = &vdev->entity;
399 while (1) {
400 pad = &entity->pads[0];
401 if (!(pad->flags & MEDIA_PAD_FL_SINK))
402 break;
403
404 pad = media_entity_remote_pad(pad);
405 if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
406 break;
407
408 entity = pad->entity;
409 subdev = media_entity_to_v4l2_subdev(entity);
410
411 v4l2_subdev_call(subdev, video, s_stream, 0);
412 }
413
414 media_pipeline_stop(&vdev->entity);
415
416 video->ops->flush_buffers(video, VB2_BUF_STATE_ERROR);
417}
418
419static const struct vb2_ops msm_video_vb2_q_ops = {
420 .queue_setup = video_queue_setup,
421 .wait_prepare = vb2_ops_wait_prepare,
422 .wait_finish = vb2_ops_wait_finish,
423 .buf_init = video_buf_init,
424 .buf_prepare = video_buf_prepare,
425 .buf_queue = video_buf_queue,
426 .start_streaming = video_start_streaming,
427 .stop_streaming = video_stop_streaming,
428};
429
430/* -----------------------------------------------------------------------------
431 * V4L2 ioctls
432 */
433
434static int video_querycap(struct file *file, void *fh,
435 struct v4l2_capability *cap)
436{
437 struct camss_video *video = video_drvdata(file);
438
439 strlcpy(cap->driver, "qcom-camss", sizeof(cap->driver));
440 strlcpy(cap->card, "Qualcomm Camera Subsystem", sizeof(cap->card));
441 snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
442 dev_name(video->camss->dev));
443
444 return 0;
445}
446
447static int video_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
448{
449 struct camss_video *video = video_drvdata(file);
450 int i, j, k;
451
452 if (f->type != video->type)
453 return -EINVAL;
454
455 if (f->index >= video->nformats)
456 return -EINVAL;
457
458 /* find index "i" of "k"th unique pixelformat in formats array */
459 k = -1;
460 for (i = 0; i < video->nformats; i++) {
461 for (j = 0; j < i; j++) {
462 if (video->formats[i].pixelformat ==
463 video->formats[j].pixelformat)
464 break;
465 }
466
467 if (j == i)
468 k++;
469
470 if (k == f->index)
471 break;
472 }
473
474 if (k < f->index)
475 return -EINVAL;
476
477 f->pixelformat = video->formats[i].pixelformat;
478
479 return 0;
480}
481
482static int video_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
483{
484 struct camss_video *video = video_drvdata(file);
485
486 *f = video->active_fmt;
487
488 return 0;
489}
490
491static int __video_try_fmt(struct camss_video *video, struct v4l2_format *f)
492{
493 struct v4l2_pix_format_mplane *pix_mp;
494 const struct camss_format_info *fi;
495 struct v4l2_plane_pix_format *p;
496 u32 bytesperline[3] = { 0 };
497 u32 sizeimage[3] = { 0 };
498 u32 width, height;
499 u32 bpl, lines;
500 int i, j;
501
502 pix_mp = &f->fmt.pix_mp;
503
504 if (video->line_based)
505 for (i = 0; i < pix_mp->num_planes && i < 3; i++) {
506 p = &pix_mp->plane_fmt[i];
507 bytesperline[i] = clamp_t(u32, p->bytesperline,
508 1, 65528);
509 sizeimage[i] = clamp_t(u32, p->sizeimage,
510 bytesperline[i],
511 bytesperline[i] * 4096);
512 }
513
514 for (j = 0; j < video->nformats; j++)
515 if (pix_mp->pixelformat == video->formats[j].pixelformat)
516 break;
517
518 if (j == video->nformats)
519 j = 0; /* default format */
520
521 fi = &video->formats[j];
522 width = pix_mp->width;
523 height = pix_mp->height;
524
525 memset(pix_mp, 0, sizeof(*pix_mp));
526
527 pix_mp->pixelformat = fi->pixelformat;
528 pix_mp->width = clamp_t(u32, width, 1, 8191);
529 pix_mp->height = clamp_t(u32, height, 1, 8191);
530 pix_mp->num_planes = fi->planes;
531 for (i = 0; i < pix_mp->num_planes; i++) {
532 bpl = pix_mp->width / fi->hsub[i].numerator *
533 fi->hsub[i].denominator * fi->bpp[i] / 8;
534 bpl = ALIGN(bpl, video->bpl_alignment);
535 pix_mp->plane_fmt[i].bytesperline = bpl;
536 pix_mp->plane_fmt[i].sizeimage = pix_mp->height /
537 fi->vsub[i].numerator * fi->vsub[i].denominator * bpl;
538 }
539
540 pix_mp->field = V4L2_FIELD_NONE;
541 pix_mp->colorspace = V4L2_COLORSPACE_SRGB;
542 pix_mp->flags = 0;
543 pix_mp->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(pix_mp->colorspace);
544 pix_mp->quantization = V4L2_MAP_QUANTIZATION_DEFAULT(true,
545 pix_mp->colorspace, pix_mp->ycbcr_enc);
546 pix_mp->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(pix_mp->colorspace);
547
548 if (video->line_based)
549 for (i = 0; i < pix_mp->num_planes; i++) {
550 p = &pix_mp->plane_fmt[i];
551 p->bytesperline = clamp_t(u32, p->bytesperline,
552 1, 65528);
553 p->sizeimage = clamp_t(u32, p->sizeimage,
554 p->bytesperline,
555 p->bytesperline * 4096);
556 lines = p->sizeimage / p->bytesperline;
557
558 if (p->bytesperline < bytesperline[i])
559 p->bytesperline = ALIGN(bytesperline[i], 8);
560
561 if (p->sizeimage < p->bytesperline * lines)
562 p->sizeimage = p->bytesperline * lines;
563
564 if (p->sizeimage < sizeimage[i])
565 p->sizeimage = sizeimage[i];
566 }
567
568 return 0;
569}
570
571static int video_try_fmt(struct file *file, void *fh, struct v4l2_format *f)
572{
573 struct camss_video *video = video_drvdata(file);
574
575 return __video_try_fmt(video, f);
576}
577
578static int video_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
579{
580 struct camss_video *video = video_drvdata(file);
581 int ret;
582
583 if (vb2_is_busy(&video->vb2_q))
584 return -EBUSY;
585
586 ret = __video_try_fmt(video, f);
587 if (ret < 0)
588 return ret;
589
590 video->active_fmt = *f;
591
592 return 0;
593}
594
595static int video_enum_input(struct file *file, void *fh,
596 struct v4l2_input *input)
597{
598 if (input->index > 0)
599 return -EINVAL;
600
601 strlcpy(input->name, "camera", sizeof(input->name));
602 input->type = V4L2_INPUT_TYPE_CAMERA;
603
604 return 0;
605}
606
607static int video_g_input(struct file *file, void *fh, unsigned int *input)
608{
609 *input = 0;
610
611 return 0;
612}
613
614static int video_s_input(struct file *file, void *fh, unsigned int input)
615{
616 return input == 0 ? 0 : -EINVAL;
617}
618
619static const struct v4l2_ioctl_ops msm_vid_ioctl_ops = {
620 .vidioc_querycap = video_querycap,
621 .vidioc_enum_fmt_vid_cap_mplane = video_enum_fmt,
622 .vidioc_g_fmt_vid_cap_mplane = video_g_fmt,
623 .vidioc_s_fmt_vid_cap_mplane = video_s_fmt,
624 .vidioc_try_fmt_vid_cap_mplane = video_try_fmt,
625 .vidioc_reqbufs = vb2_ioctl_reqbufs,
626 .vidioc_querybuf = vb2_ioctl_querybuf,
627 .vidioc_qbuf = vb2_ioctl_qbuf,
628 .vidioc_expbuf = vb2_ioctl_expbuf,
629 .vidioc_dqbuf = vb2_ioctl_dqbuf,
630 .vidioc_create_bufs = vb2_ioctl_create_bufs,
631 .vidioc_prepare_buf = vb2_ioctl_prepare_buf,
632 .vidioc_streamon = vb2_ioctl_streamon,
633 .vidioc_streamoff = vb2_ioctl_streamoff,
634 .vidioc_enum_input = video_enum_input,
635 .vidioc_g_input = video_g_input,
636 .vidioc_s_input = video_s_input,
637};
638
639/* -----------------------------------------------------------------------------
640 * V4L2 file operations
641 */
642
643static int video_open(struct file *file)
644{
645 struct video_device *vdev = video_devdata(file);
646 struct camss_video *video = video_drvdata(file);
647 struct v4l2_fh *vfh;
648 int ret;
649
650 mutex_lock(&video->lock);
651
652 vfh = kzalloc(sizeof(*vfh), GFP_KERNEL);
653 if (vfh == NULL) {
654 ret = -ENOMEM;
655 goto error_alloc;
656 }
657
658 v4l2_fh_init(vfh, vdev);
659 v4l2_fh_add(vfh);
660
661 file->private_data = vfh;
662
663 ret = v4l2_pipeline_pm_use(&vdev->entity, 1);
664 if (ret < 0) {
665 dev_err(video->camss->dev, "Failed to power up pipeline: %d\n",
666 ret);
667 goto error_pm_use;
668 }
669
670 mutex_unlock(&video->lock);
671
672 return 0;
673
674error_pm_use:
675 v4l2_fh_release(file);
676
677error_alloc:
678 mutex_unlock(&video->lock);
679
680 return ret;
681}
682
683static int video_release(struct file *file)
684{
685 struct video_device *vdev = video_devdata(file);
686
687 vb2_fop_release(file);
688
689 v4l2_pipeline_pm_use(&vdev->entity, 0);
690
691 file->private_data = NULL;
692
693 return 0;
694}
695
696static const struct v4l2_file_operations msm_vid_fops = {
697 .owner = THIS_MODULE,
698 .unlocked_ioctl = video_ioctl2,
699 .open = video_open,
700 .release = video_release,
701 .poll = vb2_fop_poll,
702 .mmap = vb2_fop_mmap,
703 .read = vb2_fop_read,
704};
705
706/* -----------------------------------------------------------------------------
707 * CAMSS video core
708 */
709
710static void msm_video_release(struct video_device *vdev)
711{
712 struct camss_video *video = video_get_drvdata(vdev);
713
714 media_entity_cleanup(&vdev->entity);
715
716 mutex_destroy(&video->q_lock);
717 mutex_destroy(&video->lock);
718
719 if (atomic_dec_and_test(&video->camss->ref_count))
720 camss_delete(video->camss);
721}
722
723/*
724 * msm_video_init_format - Helper function to initialize format
725 * @video: struct camss_video
726 *
727 * Initialize pad format with default value.
728 *
729 * Return 0 on success or a negative error code otherwise
730 */
731static int msm_video_init_format(struct camss_video *video)
732{
733 int ret;
734 struct v4l2_format format = {
735 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
736 .fmt.pix_mp = {
737 .width = 1920,
738 .height = 1080,
739 .pixelformat = video->formats[0].pixelformat,
740 },
741 };
742
743 ret = __video_try_fmt(video, &format);
744 if (ret < 0)
745 return ret;
746
747 video->active_fmt = format;
748
749 return 0;
750}
751
752/*
753 * msm_video_register - Register a video device node
754 * @video: struct camss_video
755 * @v4l2_dev: V4L2 device
756 * @name: name to be used for the video device node
757 *
758 * Initialize and register a video device node to a V4L2 device. Also
759 * initialize the vb2 queue.
760 *
761 * Return 0 on success or a negative error code otherwise
762 */
763
764int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev,
765 const char *name, int is_pix)
766{
767 struct media_pad *pad = &video->pad;
768 struct video_device *vdev;
769 struct vb2_queue *q;
770 int ret;
771
772 vdev = &video->vdev;
773
774 mutex_init(&video->q_lock);
775
776 q = &video->vb2_q;
777 q->drv_priv = video;
778 q->mem_ops = &vb2_dma_sg_memops;
779 q->ops = &msm_video_vb2_q_ops;
780 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
781 q->io_modes = VB2_DMABUF | VB2_MMAP | VB2_READ;
782 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
783 q->buf_struct_size = sizeof(struct camss_buffer);
784 q->dev = video->camss->dev;
785 q->lock = &video->q_lock;
786 ret = vb2_queue_init(q);
787 if (ret < 0) {
788 dev_err(v4l2_dev->dev, "Failed to init vb2 queue: %d\n", ret);
789 goto error_vb2_init;
790 }
791
792 pad->flags = MEDIA_PAD_FL_SINK;
793 ret = media_entity_pads_init(&vdev->entity, 1, pad);
794 if (ret < 0) {
795 dev_err(v4l2_dev->dev, "Failed to init video entity: %d\n",
796 ret);
797 goto error_media_init;
798 }
799
800 mutex_init(&video->lock);
801
802 video->formats = formats_rdi;
803 video->nformats = ARRAY_SIZE(formats_rdi);
804 if (is_pix) {
805 video->formats = formats_pix;
806 video->nformats = ARRAY_SIZE(formats_pix);
807 }
808
809 ret = msm_video_init_format(video);
810 if (ret < 0) {
811 dev_err(v4l2_dev->dev, "Failed to init format: %d\n", ret);
812 goto error_video_register;
813 }
814
815 vdev->fops = &msm_vid_fops;
816 vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_STREAMING |
817 V4L2_CAP_READWRITE;
818 vdev->ioctl_ops = &msm_vid_ioctl_ops;
819 vdev->release = msm_video_release;
820 vdev->v4l2_dev = v4l2_dev;
821 vdev->vfl_dir = VFL_DIR_RX;
822 vdev->queue = &video->vb2_q;
823 vdev->lock = &video->lock;
824 strlcpy(vdev->name, name, sizeof(vdev->name));
825
826 ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
827 if (ret < 0) {
828 dev_err(v4l2_dev->dev, "Failed to register video device: %d\n",
829 ret);
830 goto error_video_register;
831 }
832
833 video_set_drvdata(vdev, video);
834 atomic_inc(&video->camss->ref_count);
835
836 return 0;
837
838error_video_register:
839 media_entity_cleanup(&vdev->entity);
840 mutex_destroy(&video->lock);
841error_media_init:
842 vb2_queue_release(&video->vb2_q);
843error_vb2_init:
844 mutex_destroy(&video->q_lock);
845
846 return ret;
847}
848
849void msm_video_stop_streaming(struct camss_video *video)
850{
851 if (vb2_is_streaming(&video->vb2_q))
852 vb2_queue_release(&video->vb2_q);
853}
854
855void msm_video_unregister(struct camss_video *video)
856{
857 atomic_inc(&video->camss->ref_count);
858 video_unregister_device(&video->vdev);
859 atomic_dec(&video->camss->ref_count);
860}
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-video.h b/drivers/media/platform/qcom/camss-8x16/camss-video.h
new file mode 100644
index 000000000000..38bd1f2eec54
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/camss-video.h
@@ -0,0 +1,70 @@
1/*
2 * camss-video.h
3 *
4 * Qualcomm MSM Camera Subsystem - V4L2 device node
5 *
6 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
7 * Copyright (C) 2015-2017 Linaro Ltd.
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 version 2 and
11 * only version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18#ifndef QC_MSM_CAMSS_VIDEO_H
19#define QC_MSM_CAMSS_VIDEO_H
20
21#include <linux/mutex.h>
22#include <linux/videodev2.h>
23#include <media/media-entity.h>
24#include <media/v4l2-dev.h>
25#include <media/v4l2-device.h>
26#include <media/v4l2-fh.h>
27#include <media/v4l2-mediabus.h>
28#include <media/videobuf2-v4l2.h>
29
30struct camss_buffer {
31 struct vb2_v4l2_buffer vb;
32 dma_addr_t addr[3];
33 struct list_head queue;
34};
35
36struct camss_video;
37
38struct camss_video_ops {
39 int (*queue_buffer)(struct camss_video *vid, struct camss_buffer *buf);
40 int (*flush_buffers)(struct camss_video *vid,
41 enum vb2_buffer_state state);
42};
43
44struct camss_format_info;
45
46struct camss_video {
47 struct camss *camss;
48 struct vb2_queue vb2_q;
49 struct video_device vdev;
50 struct media_pad pad;
51 struct v4l2_format active_fmt;
52 enum v4l2_buf_type type;
53 struct media_pipeline pipe;
54 const struct camss_video_ops *ops;
55 struct mutex lock;
56 struct mutex q_lock;
57 unsigned int bpl_alignment;
58 unsigned int line_based;
59 const struct camss_format_info *formats;
60 unsigned int nformats;
61};
62
63void msm_video_stop_streaming(struct camss_video *video);
64
65int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev,
66 const char *name, int is_pix);
67
68void msm_video_unregister(struct camss_video *video);
69
70#endif /* QC_MSM_CAMSS_VIDEO_H */
diff --git a/drivers/media/platform/qcom/camss-8x16/camss.c b/drivers/media/platform/qcom/camss-8x16/camss.c
new file mode 100644
index 000000000000..a3760b5dd1d1
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/camss.c
@@ -0,0 +1,746 @@
1/*
2 * camss.c
3 *
4 * Qualcomm MSM Camera Subsystem - Core
5 *
6 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
7 * Copyright (C) 2015-2017 Linaro Ltd.
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 version 2 and
11 * only version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18#include <linux/clk.h>
19#include <linux/media-bus-format.h>
20#include <linux/media.h>
21#include <linux/module.h>
22#include <linux/platform_device.h>
23#include <linux/of.h>
24#include <linux/of_graph.h>
25#include <linux/slab.h>
26#include <linux/videodev2.h>
27
28#include <media/media-device.h>
29#include <media/v4l2-async.h>
30#include <media/v4l2-device.h>
31#include <media/v4l2-mc.h>
32#include <media/v4l2-fwnode.h>
33
34#include "camss.h"
35
36#define CAMSS_CLOCK_MARGIN_NUMERATOR 105
37#define CAMSS_CLOCK_MARGIN_DENOMINATOR 100
38
39static const struct resources csiphy_res[] = {
40 /* CSIPHY0 */
41 {
42 .regulator = { NULL },
43 .clock = { "camss_top_ahb", "ispif_ahb",
44 "camss_ahb", "csiphy0_timer" },
45 .clock_rate = { { 0 },
46 { 0 },
47 { 0 },
48 { 100000000, 200000000 } },
49 .reg = { "csiphy0", "csiphy0_clk_mux" },
50 .interrupt = { "csiphy0" }
51 },
52
53 /* CSIPHY1 */
54 {
55 .regulator = { NULL },
56 .clock = { "camss_top_ahb", "ispif_ahb",
57 "camss_ahb", "csiphy1_timer" },
58 .clock_rate = { { 0 },
59 { 0 },
60 { 0 },
61 { 100000000, 200000000 } },
62 .reg = { "csiphy1", "csiphy1_clk_mux" },
63 .interrupt = { "csiphy1" }
64 }
65};
66
67static const struct resources csid_res[] = {
68 /* CSID0 */
69 {
70 .regulator = { "vdda" },
71 .clock = { "camss_top_ahb", "ispif_ahb",
72 "csi0_ahb", "camss_ahb",
73 "csi0", "csi0_phy", "csi0_pix", "csi0_rdi" },
74 .clock_rate = { { 0 },
75 { 0 },
76 { 0 },
77 { 0 },
78 { 100000000, 200000000 },
79 { 0 },
80 { 0 },
81 { 0 } },
82 .reg = { "csid0" },
83 .interrupt = { "csid0" }
84 },
85
86 /* CSID1 */
87 {
88 .regulator = { "vdda" },
89 .clock = { "camss_top_ahb", "ispif_ahb",
90 "csi1_ahb", "camss_ahb",
91 "csi1", "csi1_phy", "csi1_pix", "csi1_rdi" },
92 .clock_rate = { { 0 },
93 { 0 },
94 { 0 },
95 { 0 },
96 { 100000000, 200000000 },
97 { 0 },
98 { 0 },
99 { 0 } },
100 .reg = { "csid1" },
101 .interrupt = { "csid1" }
102 },
103};
104
105static const struct resources_ispif ispif_res = {
106 /* ISPIF */
107 .clock = { "camss_top_ahb", "camss_ahb", "ispif_ahb",
108 "csi0", "csi0_pix", "csi0_rdi",
109 "csi1", "csi1_pix", "csi1_rdi" },
110 .clock_for_reset = { "camss_vfe_vfe", "camss_csi_vfe" },
111 .reg = { "ispif", "csi_clk_mux" },
112 .interrupt = "ispif"
113
114};
115
116static const struct resources vfe_res = {
117 /* VFE0 */
118 .regulator = { NULL },
119 .clock = { "camss_top_ahb", "camss_vfe_vfe", "camss_csi_vfe",
120 "iface", "bus", "camss_ahb" },
121 .clock_rate = { { 0 },
122 { 50000000, 80000000, 100000000, 160000000,
123 177780000, 200000000, 266670000, 320000000,
124 400000000, 465000000 },
125 { 0 },
126 { 0 },
127 { 0 },
128 { 0 },
129 { 0 },
130 { 0 },
131 { 0 } },
132 .reg = { "vfe0" },
133 .interrupt = { "vfe0" }
134};
135
136/*
137 * camss_add_clock_margin - Add margin to clock frequency rate
138 * @rate: Clock frequency rate
139 *
140 * When making calculations with physical clock frequency values
141 * some safety margin must be added. Add it.
142 */
143inline void camss_add_clock_margin(u64 *rate)
144{
145 *rate *= CAMSS_CLOCK_MARGIN_NUMERATOR;
146 *rate = div_u64(*rate, CAMSS_CLOCK_MARGIN_DENOMINATOR);
147}
148
149/*
150 * camss_enable_clocks - Enable multiple clocks
151 * @nclocks: Number of clocks in clock array
152 * @clock: Clock array
153 * @dev: Device
154 *
155 * Return 0 on success or a negative error code otherwise
156 */
157int camss_enable_clocks(int nclocks, struct camss_clock *clock,
158 struct device *dev)
159{
160 int ret;
161 int i;
162
163 for (i = 0; i < nclocks; i++) {
164 ret = clk_prepare_enable(clock[i].clk);
165 if (ret) {
166 dev_err(dev, "clock enable failed: %d\n", ret);
167 goto error;
168 }
169 }
170
171 return 0;
172
173error:
174 for (i--; i >= 0; i--)
175 clk_disable_unprepare(clock[i].clk);
176
177 return ret;
178}
179
180/*
181 * camss_disable_clocks - Disable multiple clocks
182 * @nclocks: Number of clocks in clock array
183 * @clock: Clock array
184 */
185void camss_disable_clocks(int nclocks, struct camss_clock *clock)
186{
187 int i;
188
189 for (i = nclocks - 1; i >= 0; i--)
190 clk_disable_unprepare(clock[i].clk);
191}
192
193/*
194 * camss_find_sensor - Find a linked media entity which represents a sensor
195 * @entity: Media entity to start searching from
196 *
197 * Return a pointer to sensor media entity or NULL if not found
198 */
199static struct media_entity *camss_find_sensor(struct media_entity *entity)
200{
201 struct media_pad *pad;
202
203 while (1) {
204 pad = &entity->pads[0];
205 if (!(pad->flags & MEDIA_PAD_FL_SINK))
206 return NULL;
207
208 pad = media_entity_remote_pad(pad);
209 if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
210 return NULL;
211
212 entity = pad->entity;
213
214 if (entity->function == MEDIA_ENT_F_CAM_SENSOR)
215 return entity;
216 }
217}
218
219/*
220 * camss_get_pixel_clock - Get pixel clock rate from sensor
221 * @entity: Media entity in the current pipeline
222 * @pixel_clock: Received pixel clock value
223 *
224 * Return 0 on success or a negative error code otherwise
225 */
226int camss_get_pixel_clock(struct media_entity *entity, u32 *pixel_clock)
227{
228 struct media_entity *sensor;
229 struct v4l2_subdev *subdev;
230 struct v4l2_ctrl *ctrl;
231
232 sensor = camss_find_sensor(entity);
233 if (!sensor)
234 return -ENODEV;
235
236 subdev = media_entity_to_v4l2_subdev(sensor);
237
238 ctrl = v4l2_ctrl_find(subdev->ctrl_handler, V4L2_CID_PIXEL_RATE);
239
240 if (!ctrl)
241 return -EINVAL;
242
243 *pixel_clock = v4l2_ctrl_g_ctrl_int64(ctrl);
244
245 return 0;
246}
247
248/*
249 * camss_of_parse_endpoint_node - Parse port endpoint node
250 * @dev: Device
251 * @node: Device node to be parsed
252 * @csd: Parsed data from port endpoint node
253 *
254 * Return 0 on success or a negative error code on failure
255 */
256static int camss_of_parse_endpoint_node(struct device *dev,
257 struct device_node *node,
258 struct camss_async_subdev *csd)
259{
260 struct csiphy_lanes_cfg *lncfg = &csd->interface.csi2.lane_cfg;
261 struct v4l2_fwnode_bus_mipi_csi2 *mipi_csi2;
262 struct v4l2_fwnode_endpoint vep = { { 0 } };
263 unsigned int i;
264
265 v4l2_fwnode_endpoint_parse(of_fwnode_handle(node), &vep);
266
267 csd->interface.csiphy_id = vep.base.port;
268
269 mipi_csi2 = &vep.bus.mipi_csi2;
270 lncfg->clk.pos = mipi_csi2->clock_lane;
271 lncfg->clk.pol = mipi_csi2->lane_polarities[0];
272 lncfg->num_data = mipi_csi2->num_data_lanes;
273
274 lncfg->data = devm_kzalloc(dev, lncfg->num_data * sizeof(*lncfg->data),
275 GFP_KERNEL);
276 if (!lncfg->data)
277 return -ENOMEM;
278
279 for (i = 0; i < lncfg->num_data; i++) {
280 lncfg->data[i].pos = mipi_csi2->data_lanes[i];
281 lncfg->data[i].pol = mipi_csi2->lane_polarities[i + 1];
282 }
283
284 return 0;
285}
286
287/*
288 * camss_of_parse_ports - Parse ports node
289 * @dev: Device
290 * @notifier: v4l2_device notifier data
291 *
292 * Return number of "port" nodes found in "ports" node
293 */
294static int camss_of_parse_ports(struct device *dev,
295 struct v4l2_async_notifier *notifier)
296{
297 struct device_node *node = NULL;
298 struct device_node *remote = NULL;
299 unsigned int size, i;
300 int ret;
301
302 while ((node = of_graph_get_next_endpoint(dev->of_node, node)))
303 if (of_device_is_available(node))
304 notifier->num_subdevs++;
305
306 size = sizeof(*notifier->subdevs) * notifier->num_subdevs;
307 notifier->subdevs = devm_kzalloc(dev, size, GFP_KERNEL);
308 if (!notifier->subdevs) {
309 dev_err(dev, "Failed to allocate memory\n");
310 return -ENOMEM;
311 }
312
313 i = 0;
314 while ((node = of_graph_get_next_endpoint(dev->of_node, node))) {
315 struct camss_async_subdev *csd;
316
317 if (!of_device_is_available(node))
318 continue;
319
320 csd = devm_kzalloc(dev, sizeof(*csd), GFP_KERNEL);
321 if (!csd) {
322 of_node_put(node);
323 dev_err(dev, "Failed to allocate memory\n");
324 return -ENOMEM;
325 }
326
327 notifier->subdevs[i++] = &csd->asd;
328
329 ret = camss_of_parse_endpoint_node(dev, node, csd);
330 if (ret < 0) {
331 of_node_put(node);
332 return ret;
333 }
334
335 remote = of_graph_get_remote_port_parent(node);
336 of_node_put(node);
337
338 if (!remote) {
339 dev_err(dev, "Cannot get remote parent\n");
340 return -EINVAL;
341 }
342
343 csd->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
344 csd->asd.match.fwnode.fwnode = of_fwnode_handle(remote);
345 }
346
347 return notifier->num_subdevs;
348}
349
350/*
351 * camss_init_subdevices - Initialize subdev structures and resources
352 * @camss: CAMSS device
353 *
354 * Return 0 on success or a negative error code on failure
355 */
356static int camss_init_subdevices(struct camss *camss)
357{
358 unsigned int i;
359 int ret;
360
361 for (i = 0; i < ARRAY_SIZE(camss->csiphy); i++) {
362 ret = msm_csiphy_subdev_init(&camss->csiphy[i],
363 &csiphy_res[i], i);
364 if (ret < 0) {
365 dev_err(camss->dev,
366 "Failed to init csiphy%d sub-device: %d\n",
367 i, ret);
368 return ret;
369 }
370 }
371
372 for (i = 0; i < ARRAY_SIZE(camss->csid); i++) {
373 ret = msm_csid_subdev_init(&camss->csid[i],
374 &csid_res[i], i);
375 if (ret < 0) {
376 dev_err(camss->dev,
377 "Failed to init csid%d sub-device: %d\n",
378 i, ret);
379 return ret;
380 }
381 }
382
383 ret = msm_ispif_subdev_init(&camss->ispif, &ispif_res);
384 if (ret < 0) {
385 dev_err(camss->dev, "Failed to init ispif sub-device: %d\n",
386 ret);
387 return ret;
388 }
389
390 ret = msm_vfe_subdev_init(&camss->vfe, &vfe_res);
391 if (ret < 0) {
392 dev_err(camss->dev, "Fail to init vfe sub-device: %d\n", ret);
393 return ret;
394 }
395
396 return 0;
397}
398
399/*
400 * camss_register_entities - Register subdev nodes and create links
401 * @camss: CAMSS device
402 *
403 * Return 0 on success or a negative error code on failure
404 */
405static int camss_register_entities(struct camss *camss)
406{
407 int i, j;
408 int ret;
409
410 for (i = 0; i < ARRAY_SIZE(camss->csiphy); i++) {
411 ret = msm_csiphy_register_entity(&camss->csiphy[i],
412 &camss->v4l2_dev);
413 if (ret < 0) {
414 dev_err(camss->dev,
415 "Failed to register csiphy%d entity: %d\n",
416 i, ret);
417 goto err_reg_csiphy;
418 }
419 }
420
421 for (i = 0; i < ARRAY_SIZE(camss->csid); i++) {
422 ret = msm_csid_register_entity(&camss->csid[i],
423 &camss->v4l2_dev);
424 if (ret < 0) {
425 dev_err(camss->dev,
426 "Failed to register csid%d entity: %d\n",
427 i, ret);
428 goto err_reg_csid;
429 }
430 }
431
432 ret = msm_ispif_register_entities(&camss->ispif, &camss->v4l2_dev);
433 if (ret < 0) {
434 dev_err(camss->dev, "Failed to register ispif entities: %d\n",
435 ret);
436 goto err_reg_ispif;
437 }
438
439 ret = msm_vfe_register_entities(&camss->vfe, &camss->v4l2_dev);
440 if (ret < 0) {
441 dev_err(camss->dev, "Failed to register vfe entities: %d\n",
442 ret);
443 goto err_reg_vfe;
444 }
445
446 for (i = 0; i < ARRAY_SIZE(camss->csiphy); i++) {
447 for (j = 0; j < ARRAY_SIZE(camss->csid); j++) {
448 ret = media_create_pad_link(
449 &camss->csiphy[i].subdev.entity,
450 MSM_CSIPHY_PAD_SRC,
451 &camss->csid[j].subdev.entity,
452 MSM_CSID_PAD_SINK,
453 0);
454 if (ret < 0) {
455 dev_err(camss->dev,
456 "Failed to link %s->%s entities: %d\n",
457 camss->csiphy[i].subdev.entity.name,
458 camss->csid[j].subdev.entity.name,
459 ret);
460 goto err_link;
461 }
462 }
463 }
464
465 for (i = 0; i < ARRAY_SIZE(camss->csid); i++) {
466 for (j = 0; j < ARRAY_SIZE(camss->ispif.line); j++) {
467 ret = media_create_pad_link(
468 &camss->csid[i].subdev.entity,
469 MSM_CSID_PAD_SRC,
470 &camss->ispif.line[j].subdev.entity,
471 MSM_ISPIF_PAD_SINK,
472 0);
473 if (ret < 0) {
474 dev_err(camss->dev,
475 "Failed to link %s->%s entities: %d\n",
476 camss->csid[i].subdev.entity.name,
477 camss->ispif.line[j].subdev.entity.name,
478 ret);
479 goto err_link;
480 }
481 }
482 }
483
484 for (i = 0; i < ARRAY_SIZE(camss->ispif.line); i++) {
485 for (j = 0; j < ARRAY_SIZE(camss->vfe.line); j++) {
486 ret = media_create_pad_link(
487 &camss->ispif.line[i].subdev.entity,
488 MSM_ISPIF_PAD_SRC,
489 &camss->vfe.line[j].subdev.entity,
490 MSM_VFE_PAD_SINK,
491 0);
492 if (ret < 0) {
493 dev_err(camss->dev,
494 "Failed to link %s->%s entities: %d\n",
495 camss->ispif.line[i].subdev.entity.name,
496 camss->vfe.line[j].subdev.entity.name,
497 ret);
498 goto err_link;
499 }
500 }
501 }
502
503 return 0;
504
505err_link:
506 msm_vfe_unregister_entities(&camss->vfe);
507err_reg_vfe:
508 msm_ispif_unregister_entities(&camss->ispif);
509err_reg_ispif:
510
511 i = ARRAY_SIZE(camss->csid);
512err_reg_csid:
513 for (i--; i >= 0; i--)
514 msm_csid_unregister_entity(&camss->csid[i]);
515
516 i = ARRAY_SIZE(camss->csiphy);
517err_reg_csiphy:
518 for (i--; i >= 0; i--)
519 msm_csiphy_unregister_entity(&camss->csiphy[i]);
520
521 return ret;
522}
523
524/*
525 * camss_unregister_entities - Unregister subdev nodes
526 * @camss: CAMSS device
527 *
528 * Return 0 on success or a negative error code on failure
529 */
530static void camss_unregister_entities(struct camss *camss)
531{
532 unsigned int i;
533
534 for (i = 0; i < ARRAY_SIZE(camss->csiphy); i++)
535 msm_csiphy_unregister_entity(&camss->csiphy[i]);
536
537 for (i = 0; i < ARRAY_SIZE(camss->csid); i++)
538 msm_csid_unregister_entity(&camss->csid[i]);
539
540 msm_ispif_unregister_entities(&camss->ispif);
541 msm_vfe_unregister_entities(&camss->vfe);
542}
543
544static int camss_subdev_notifier_bound(struct v4l2_async_notifier *async,
545 struct v4l2_subdev *subdev,
546 struct v4l2_async_subdev *asd)
547{
548 struct camss *camss = container_of(async, struct camss, notifier);
549 struct camss_async_subdev *csd =
550 container_of(asd, struct camss_async_subdev, asd);
551 u8 id = csd->interface.csiphy_id;
552 struct csiphy_device *csiphy = &camss->csiphy[id];
553
554 csiphy->cfg.csi2 = &csd->interface.csi2;
555 subdev->host_priv = csiphy;
556
557 return 0;
558}
559
560static int camss_subdev_notifier_complete(struct v4l2_async_notifier *async)
561{
562 struct camss *camss = container_of(async, struct camss, notifier);
563 struct v4l2_device *v4l2_dev = &camss->v4l2_dev;
564 struct v4l2_subdev *sd;
565 int ret;
566
567 list_for_each_entry(sd, &v4l2_dev->subdevs, list) {
568 if (sd->host_priv) {
569 struct media_entity *sensor = &sd->entity;
570 struct csiphy_device *csiphy =
571 (struct csiphy_device *) sd->host_priv;
572 struct media_entity *input = &csiphy->subdev.entity;
573 unsigned int i;
574
575 for (i = 0; i < sensor->num_pads; i++) {
576 if (sensor->pads[i].flags & MEDIA_PAD_FL_SOURCE)
577 break;
578 }
579 if (i == sensor->num_pads) {
580 dev_err(camss->dev,
581 "No source pad in external entity\n");
582 return -EINVAL;
583 }
584
585 ret = media_create_pad_link(sensor, i,
586 input, MSM_CSIPHY_PAD_SINK,
587 MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED);
588 if (ret < 0) {
589 dev_err(camss->dev,
590 "Failed to link %s->%s entities: %d\n",
591 sensor->name, input->name, ret);
592 return ret;
593 }
594 }
595 }
596
597 ret = v4l2_device_register_subdev_nodes(&camss->v4l2_dev);
598 if (ret < 0)
599 return ret;
600
601 return media_device_register(&camss->media_dev);
602}
603
604static const struct media_device_ops camss_media_ops = {
605 .link_notify = v4l2_pipeline_link_notify,
606};
607
608/*
609 * camss_probe - Probe CAMSS platform device
610 * @pdev: Pointer to CAMSS platform device
611 *
612 * Return 0 on success or a negative error code on failure
613 */
614static int camss_probe(struct platform_device *pdev)
615{
616 struct device *dev = &pdev->dev;
617 struct camss *camss;
618 int ret;
619
620 camss = kzalloc(sizeof(*camss), GFP_KERNEL);
621 if (!camss)
622 return -ENOMEM;
623
624 atomic_set(&camss->ref_count, 0);
625 camss->dev = dev;
626 platform_set_drvdata(pdev, camss);
627
628 ret = camss_of_parse_ports(dev, &camss->notifier);
629 if (ret < 0)
630 return ret;
631
632 ret = camss_init_subdevices(camss);
633 if (ret < 0)
634 return ret;
635
636 ret = dma_set_mask_and_coherent(dev, 0xffffffff);
637 if (ret)
638 return ret;
639
640 camss->media_dev.dev = camss->dev;
641 strlcpy(camss->media_dev.model, "Qualcomm Camera Subsystem",
642 sizeof(camss->media_dev.model));
643 camss->media_dev.ops = &camss_media_ops;
644 media_device_init(&camss->media_dev);
645
646 camss->v4l2_dev.mdev = &camss->media_dev;
647 ret = v4l2_device_register(camss->dev, &camss->v4l2_dev);
648 if (ret < 0) {
649 dev_err(dev, "Failed to register V4L2 device: %d\n", ret);
650 return ret;
651 }
652
653 ret = camss_register_entities(camss);
654 if (ret < 0)
655 goto err_register_entities;
656
657 if (camss->notifier.num_subdevs) {
658 camss->notifier.bound = camss_subdev_notifier_bound;
659 camss->notifier.complete = camss_subdev_notifier_complete;
660
661 ret = v4l2_async_notifier_register(&camss->v4l2_dev,
662 &camss->notifier);
663 if (ret) {
664 dev_err(dev,
665 "Failed to register async subdev nodes: %d\n",
666 ret);
667 goto err_register_subdevs;
668 }
669 } else {
670 ret = v4l2_device_register_subdev_nodes(&camss->v4l2_dev);
671 if (ret < 0) {
672 dev_err(dev, "Failed to register subdev nodes: %d\n",
673 ret);
674 goto err_register_subdevs;
675 }
676
677 ret = media_device_register(&camss->media_dev);
678 if (ret < 0) {
679 dev_err(dev, "Failed to register media device: %d\n",
680 ret);
681 goto err_register_subdevs;
682 }
683 }
684
685 return 0;
686
687err_register_subdevs:
688 camss_unregister_entities(camss);
689err_register_entities:
690 v4l2_device_unregister(&camss->v4l2_dev);
691
692 return ret;
693}
694
695void camss_delete(struct camss *camss)
696{
697 v4l2_device_unregister(&camss->v4l2_dev);
698 media_device_unregister(&camss->media_dev);
699 media_device_cleanup(&camss->media_dev);
700
701 kfree(camss);
702}
703
704/*
705 * camss_remove - Remove CAMSS platform device
706 * @pdev: Pointer to CAMSS platform device
707 *
708 * Always returns 0.
709 */
710static int camss_remove(struct platform_device *pdev)
711{
712 struct camss *camss = platform_get_drvdata(pdev);
713
714 msm_vfe_stop_streaming(&camss->vfe);
715
716 v4l2_async_notifier_unregister(&camss->notifier);
717 camss_unregister_entities(camss);
718
719 if (atomic_read(&camss->ref_count) == 0)
720 camss_delete(camss);
721
722 return 0;
723}
724
725static const struct of_device_id camss_dt_match[] = {
726 { .compatible = "qcom,msm8916-camss" },
727 { }
728};
729
730MODULE_DEVICE_TABLE(of, camss_dt_match);
731
732static struct platform_driver qcom_camss_driver = {
733 .probe = camss_probe,
734 .remove = camss_remove,
735 .driver = {
736 .name = "qcom-camss",
737 .of_match_table = camss_dt_match,
738 },
739};
740
741module_platform_driver(qcom_camss_driver);
742
743MODULE_ALIAS("platform:qcom-camss");
744MODULE_DESCRIPTION("Qualcomm Camera Subsystem driver");
745MODULE_AUTHOR("Todor Tomov <todor.tomov@linaro.org>");
746MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/qcom/camss-8x16/camss.h b/drivers/media/platform/qcom/camss-8x16/camss.h
new file mode 100644
index 000000000000..4ad223443e4b
--- /dev/null
+++ b/drivers/media/platform/qcom/camss-8x16/camss.h
@@ -0,0 +1,106 @@
1/*
2 * camss.h
3 *
4 * Qualcomm MSM Camera Subsystem - Core
5 *
6 * Copyright (c) 2015, The Linux Foundation. All rights reserved.
7 * Copyright (C) 2015-2017 Linaro Ltd.
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 version 2 and
11 * only version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18#ifndef QC_MSM_CAMSS_H
19#define QC_MSM_CAMSS_H
20
21#include <linux/types.h>
22#include <media/v4l2-async.h>
23#include <media/v4l2-device.h>
24#include <media/v4l2-subdev.h>
25#include <media/media-device.h>
26#include <media/media-entity.h>
27#include <linux/device.h>
28
29#include "camss-csid.h"
30#include "camss-csiphy.h"
31#include "camss-ispif.h"
32#include "camss-vfe.h"
33
34#define CAMSS_CSID_NUM 2
35#define CAMSS_CSIPHY_NUM 2
36
37#define to_camss(ptr_module) \
38 container_of(ptr_module, struct camss, ptr_module)
39
40#define to_device(ptr_module) \
41 (to_camss(ptr_module)->dev)
42
43#define module_pointer(ptr_module, index) \
44 ((const struct ptr_module##_device (*)[]) &(ptr_module[-(index)]))
45
46#define to_camss_index(ptr_module, index) \
47 container_of(module_pointer(ptr_module, index), \
48 struct camss, ptr_module)
49
50#define to_device_index(ptr_module, index) \
51 (to_camss_index(ptr_module, index)->dev)
52
53#define CAMSS_RES_MAX 15
54
55struct resources {
56 char *regulator[CAMSS_RES_MAX];
57 char *clock[CAMSS_RES_MAX];
58 u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX];
59 char *reg[CAMSS_RES_MAX];
60 char *interrupt[CAMSS_RES_MAX];
61};
62
63struct resources_ispif {
64 char *clock[CAMSS_RES_MAX];
65 char *clock_for_reset[CAMSS_RES_MAX];
66 char *reg[CAMSS_RES_MAX];
67 char *interrupt;
68};
69
70struct camss {
71 struct v4l2_device v4l2_dev;
72 struct v4l2_async_notifier notifier;
73 struct media_device media_dev;
74 struct device *dev;
75 struct csiphy_device csiphy[CAMSS_CSIPHY_NUM];
76 struct csid_device csid[CAMSS_CSID_NUM];
77 struct ispif_device ispif;
78 struct vfe_device vfe;
79 atomic_t ref_count;
80};
81
82struct camss_camera_interface {
83 u8 csiphy_id;
84 struct csiphy_csi2_cfg csi2;
85};
86
87struct camss_async_subdev {
88 struct camss_camera_interface interface;
89 struct v4l2_async_subdev asd;
90};
91
92struct camss_clock {
93 struct clk *clk;
94 const char *name;
95 u32 *freq;
96 u32 nfreqs;
97};
98
99void camss_add_clock_margin(u64 *rate);
100int camss_enable_clocks(int nclocks, struct camss_clock *clock,
101 struct device *dev);
102void camss_disable_clocks(int nclocks, struct camss_clock *clock);
103int camss_get_pixel_clock(struct media_entity *entity, u32 *pixel_clock);
104void camss_delete(struct camss *camss);
105
106#endif /* QC_MSM_CAMSS_H */
diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index 5f4434c0a8f1..68933d208063 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -34,6 +34,55 @@ struct intbuf {
34 unsigned long attrs; 34 unsigned long attrs;
35}; 35};
36 36
37bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt)
38{
39 struct venus_core *core = inst->core;
40 u32 session_type = inst->session_type;
41 u32 codec;
42
43 switch (v4l2_pixfmt) {
44 case V4L2_PIX_FMT_H264:
45 codec = HFI_VIDEO_CODEC_H264;
46 break;
47 case V4L2_PIX_FMT_H263:
48 codec = HFI_VIDEO_CODEC_H263;
49 break;
50 case V4L2_PIX_FMT_MPEG1:
51 codec = HFI_VIDEO_CODEC_MPEG1;
52 break;
53 case V4L2_PIX_FMT_MPEG2:
54 codec = HFI_VIDEO_CODEC_MPEG2;
55 break;
56 case V4L2_PIX_FMT_MPEG4:
57 codec = HFI_VIDEO_CODEC_MPEG4;
58 break;
59 case V4L2_PIX_FMT_VC1_ANNEX_G:
60 case V4L2_PIX_FMT_VC1_ANNEX_L:
61 codec = HFI_VIDEO_CODEC_VC1;
62 break;
63 case V4L2_PIX_FMT_VP8:
64 codec = HFI_VIDEO_CODEC_VP8;
65 break;
66 case V4L2_PIX_FMT_VP9:
67 codec = HFI_VIDEO_CODEC_VP9;
68 break;
69 case V4L2_PIX_FMT_XVID:
70 codec = HFI_VIDEO_CODEC_DIVX;
71 break;
72 default:
73 return false;
74 }
75
76 if (session_type == VIDC_SESSION_TYPE_ENC && core->enc_codecs & codec)
77 return true;
78
79 if (session_type == VIDC_SESSION_TYPE_DEC && core->dec_codecs & codec)
80 return true;
81
82 return false;
83}
84EXPORT_SYMBOL_GPL(venus_helper_check_codec);
85
37static int intbufs_set_buffer(struct venus_inst *inst, u32 type) 86static int intbufs_set_buffer(struct venus_inst *inst, u32 type)
38{ 87{
39 struct venus_core *core = inst->core; 88 struct venus_core *core = inst->core;
@@ -243,7 +292,7 @@ static void return_buf_error(struct venus_inst *inst,
243 if (vbuf->vb2_buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) 292 if (vbuf->vb2_buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
244 v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf); 293 v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf);
245 else 294 else
246 v4l2_m2m_src_buf_remove_by_buf(m2m_ctx, vbuf); 295 v4l2_m2m_dst_buf_remove_by_buf(m2m_ctx, vbuf);
247 296
248 v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR); 297 v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
249} 298}
diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h
index 6a061b417a93..971392be5df5 100644
--- a/drivers/media/platform/qcom/venus/helpers.h
+++ b/drivers/media/platform/qcom/venus/helpers.h
@@ -19,6 +19,7 @@
19 19
20struct venus_inst; 20struct venus_inst;
21 21
22bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt);
22struct vb2_v4l2_buffer *venus_helper_find_buf(struct venus_inst *inst, 23struct vb2_v4l2_buffer *venus_helper_find_buf(struct venus_inst *inst,
23 unsigned int type, u32 idx); 24 unsigned int type, u32 idx);
24void venus_helper_buffers_done(struct venus_inst *inst, 25void venus_helper_buffers_done(struct venus_inst *inst,
diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index eb0c1c51cfef..da611a5eb670 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -102,7 +102,8 @@ static const struct venus_format vdec_formats[] = {
102 }, 102 },
103}; 103};
104 104
105static const struct venus_format *find_format(u32 pixfmt, u32 type) 105static const struct venus_format *
106find_format(struct venus_inst *inst, u32 pixfmt, u32 type)
106{ 107{
107 const struct venus_format *fmt = vdec_formats; 108 const struct venus_format *fmt = vdec_formats;
108 unsigned int size = ARRAY_SIZE(vdec_formats); 109 unsigned int size = ARRAY_SIZE(vdec_formats);
@@ -116,11 +117,15 @@ static const struct venus_format *find_format(u32 pixfmt, u32 type)
116 if (i == size || fmt[i].type != type) 117 if (i == size || fmt[i].type != type)
117 return NULL; 118 return NULL;
118 119
120 if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
121 !venus_helper_check_codec(inst, fmt[i].pixfmt))
122 return NULL;
123
119 return &fmt[i]; 124 return &fmt[i];
120} 125}
121 126
122static const struct venus_format * 127static const struct venus_format *
123find_format_by_index(unsigned int index, u32 type) 128find_format_by_index(struct venus_inst *inst, unsigned int index, u32 type)
124{ 129{
125 const struct venus_format *fmt = vdec_formats; 130 const struct venus_format *fmt = vdec_formats;
126 unsigned int size = ARRAY_SIZE(vdec_formats); 131 unsigned int size = ARRAY_SIZE(vdec_formats);
@@ -140,6 +145,10 @@ find_format_by_index(unsigned int index, u32 type)
140 if (i == size) 145 if (i == size)
141 return NULL; 146 return NULL;
142 147
148 if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
149 !venus_helper_check_codec(inst, fmt[i].pixfmt))
150 return NULL;
151
143 return &fmt[i]; 152 return &fmt[i];
144} 153}
145 154
@@ -154,7 +163,7 @@ vdec_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
154 memset(pfmt[0].reserved, 0, sizeof(pfmt[0].reserved)); 163 memset(pfmt[0].reserved, 0, sizeof(pfmt[0].reserved));
155 memset(pixmp->reserved, 0, sizeof(pixmp->reserved)); 164 memset(pixmp->reserved, 0, sizeof(pixmp->reserved));
156 165
157 fmt = find_format(pixmp->pixelformat, f->type); 166 fmt = find_format(inst, pixmp->pixelformat, f->type);
158 if (!fmt) { 167 if (!fmt) {
159 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) 168 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
160 pixmp->pixelformat = V4L2_PIX_FMT_NV12; 169 pixmp->pixelformat = V4L2_PIX_FMT_NV12;
@@ -162,7 +171,7 @@ vdec_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
162 pixmp->pixelformat = V4L2_PIX_FMT_H264; 171 pixmp->pixelformat = V4L2_PIX_FMT_H264;
163 else 172 else
164 return NULL; 173 return NULL;
165 fmt = find_format(pixmp->pixelformat, f->type); 174 fmt = find_format(inst, pixmp->pixelformat, f->type);
166 pixmp->width = 1280; 175 pixmp->width = 1280;
167 pixmp->height = 720; 176 pixmp->height = 720;
168 } 177 }
@@ -364,11 +373,12 @@ vdec_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
364 373
365static int vdec_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f) 374static int vdec_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
366{ 375{
376 struct venus_inst *inst = to_inst(file);
367 const struct venus_format *fmt; 377 const struct venus_format *fmt;
368 378
369 memset(f->reserved, 0, sizeof(f->reserved)); 379 memset(f->reserved, 0, sizeof(f->reserved));
370 380
371 fmt = find_format_by_index(f->index, f->type); 381 fmt = find_format_by_index(inst, f->index, f->type);
372 if (!fmt) 382 if (!fmt)
373 return -EINVAL; 383 return -EINVAL;
374 384
@@ -417,10 +427,10 @@ static int vdec_enum_framesizes(struct file *file, void *fh,
417 struct venus_inst *inst = to_inst(file); 427 struct venus_inst *inst = to_inst(file);
418 const struct venus_format *fmt; 428 const struct venus_format *fmt;
419 429
420 fmt = find_format(fsize->pixel_format, 430 fmt = find_format(inst, fsize->pixel_format,
421 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); 431 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
422 if (!fmt) { 432 if (!fmt) {
423 fmt = find_format(fsize->pixel_format, 433 fmt = find_format(inst, fsize->pixel_format,
424 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); 434 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
425 if (!fmt) 435 if (!fmt)
426 return -EINVAL; 436 return -EINVAL;
@@ -1069,6 +1079,7 @@ static int vdec_probe(struct platform_device *pdev)
1069 if (!vdev) 1079 if (!vdev)
1070 return -ENOMEM; 1080 return -ENOMEM;
1071 1081
1082 strlcpy(vdev->name, "qcom-venus-decoder", sizeof(vdev->name));
1072 vdev->release = video_device_release; 1083 vdev->release = video_device_release;
1073 vdev->fops = &vdec_fops; 1084 vdev->fops = &vdec_fops;
1074 vdev->ioctl_ops = &vdec_ioctl_ops; 1085 vdev->ioctl_ops = &vdec_ioctl_ops;
@@ -1103,8 +1114,7 @@ static int vdec_remove(struct platform_device *pdev)
1103 return 0; 1114 return 0;
1104} 1115}
1105 1116
1106#ifdef CONFIG_PM 1117static __maybe_unused int vdec_runtime_suspend(struct device *dev)
1107static int vdec_runtime_suspend(struct device *dev)
1108{ 1118{
1109 struct venus_core *core = dev_get_drvdata(dev); 1119 struct venus_core *core = dev_get_drvdata(dev);
1110 1120
@@ -1118,7 +1128,7 @@ static int vdec_runtime_suspend(struct device *dev)
1118 return 0; 1128 return 0;
1119} 1129}
1120 1130
1121static int vdec_runtime_resume(struct device *dev) 1131static __maybe_unused int vdec_runtime_resume(struct device *dev)
1122{ 1132{
1123 struct venus_core *core = dev_get_drvdata(dev); 1133 struct venus_core *core = dev_get_drvdata(dev);
1124 int ret; 1134 int ret;
@@ -1132,7 +1142,6 @@ static int vdec_runtime_resume(struct device *dev)
1132 1142
1133 return ret; 1143 return ret;
1134} 1144}
1135#endif
1136 1145
1137static const struct dev_pm_ops vdec_pm_ops = { 1146static const struct dev_pm_ops vdec_pm_ops = {
1138 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 1147 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index 39748e7a08e4..6f123a387cf9 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -84,14 +84,11 @@ static const struct venus_format venc_formats[] = {
84 .pixfmt = V4L2_PIX_FMT_VP8, 84 .pixfmt = V4L2_PIX_FMT_VP8,
85 .num_planes = 1, 85 .num_planes = 1,
86 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, 86 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
87 }, {
88 .pixfmt = V4L2_PIX_FMT_VP9,
89 .num_planes = 1,
90 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
91 }, 87 },
92}; 88};
93 89
94static const struct venus_format *find_format(u32 pixfmt, u32 type) 90static const struct venus_format *
91find_format(struct venus_inst *inst, u32 pixfmt, u32 type)
95{ 92{
96 const struct venus_format *fmt = venc_formats; 93 const struct venus_format *fmt = venc_formats;
97 unsigned int size = ARRAY_SIZE(venc_formats); 94 unsigned int size = ARRAY_SIZE(venc_formats);
@@ -105,11 +102,15 @@ static const struct venus_format *find_format(u32 pixfmt, u32 type)
105 if (i == size || fmt[i].type != type) 102 if (i == size || fmt[i].type != type)
106 return NULL; 103 return NULL;
107 104
105 if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
106 !venus_helper_check_codec(inst, fmt[i].pixfmt))
107 return NULL;
108
108 return &fmt[i]; 109 return &fmt[i];
109} 110}
110 111
111static const struct venus_format * 112static const struct venus_format *
112find_format_by_index(unsigned int index, u32 type) 113find_format_by_index(struct venus_inst *inst, unsigned int index, u32 type)
113{ 114{
114 const struct venus_format *fmt = venc_formats; 115 const struct venus_format *fmt = venc_formats;
115 unsigned int size = ARRAY_SIZE(venc_formats); 116 unsigned int size = ARRAY_SIZE(venc_formats);
@@ -129,6 +130,10 @@ find_format_by_index(unsigned int index, u32 type)
129 if (i == size) 130 if (i == size)
130 return NULL; 131 return NULL;
131 132
133 if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
134 !venus_helper_check_codec(inst, fmt[i].pixfmt))
135 return NULL;
136
132 return &fmt[i]; 137 return &fmt[i];
133} 138}
134 139
@@ -246,9 +251,10 @@ venc_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
246 251
247static int venc_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f) 252static int venc_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
248{ 253{
254 struct venus_inst *inst = to_inst(file);
249 const struct venus_format *fmt; 255 const struct venus_format *fmt;
250 256
251 fmt = find_format_by_index(f->index, f->type); 257 fmt = find_format_by_index(inst, f->index, f->type);
252 258
253 memset(f->reserved, 0, sizeof(f->reserved)); 259 memset(f->reserved, 0, sizeof(f->reserved));
254 260
@@ -271,7 +277,7 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
271 memset(pfmt[0].reserved, 0, sizeof(pfmt[0].reserved)); 277 memset(pfmt[0].reserved, 0, sizeof(pfmt[0].reserved));
272 memset(pixmp->reserved, 0, sizeof(pixmp->reserved)); 278 memset(pixmp->reserved, 0, sizeof(pixmp->reserved));
273 279
274 fmt = find_format(pixmp->pixelformat, f->type); 280 fmt = find_format(inst, pixmp->pixelformat, f->type);
275 if (!fmt) { 281 if (!fmt) {
276 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) 282 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
277 pixmp->pixelformat = V4L2_PIX_FMT_H264; 283 pixmp->pixelformat = V4L2_PIX_FMT_H264;
@@ -279,7 +285,7 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
279 pixmp->pixelformat = V4L2_PIX_FMT_NV12; 285 pixmp->pixelformat = V4L2_PIX_FMT_NV12;
280 else 286 else
281 return NULL; 287 return NULL;
282 fmt = find_format(pixmp->pixelformat, f->type); 288 fmt = find_format(inst, pixmp->pixelformat, f->type);
283 pixmp->width = 1280; 289 pixmp->width = 1280;
284 pixmp->height = 720; 290 pixmp->height = 720;
285 } 291 }
@@ -289,7 +295,7 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
289 pixmp->height = clamp(pixmp->height, inst->cap_height.min, 295 pixmp->height = clamp(pixmp->height, inst->cap_height.min,
290 inst->cap_height.max); 296 inst->cap_height.max);
291 297
292 if (inst->core->res->hfi_version == HFI_VERSION_1XX) 298 if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
293 pixmp->height = ALIGN(pixmp->height, 32); 299 pixmp->height = ALIGN(pixmp->height, 32);
294 300
295 pixmp->width = ALIGN(pixmp->width, 2); 301 pixmp->width = ALIGN(pixmp->width, 2);
@@ -524,10 +530,10 @@ static int venc_enum_framesizes(struct file *file, void *fh,
524 530
525 fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; 531 fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
526 532
527 fmt = find_format(fsize->pixel_format, 533 fmt = find_format(inst, fsize->pixel_format,
528 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); 534 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
529 if (!fmt) { 535 if (!fmt) {
530 fmt = find_format(fsize->pixel_format, 536 fmt = find_format(inst, fsize->pixel_format,
531 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); 537 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
532 if (!fmt) 538 if (!fmt)
533 return -EINVAL; 539 return -EINVAL;
@@ -554,10 +560,10 @@ static int venc_enum_frameintervals(struct file *file, void *fh,
554 560
555 fival->type = V4L2_FRMIVAL_TYPE_STEPWISE; 561 fival->type = V4L2_FRMIVAL_TYPE_STEPWISE;
556 562
557 fmt = find_format(fival->pixel_format, 563 fmt = find_format(inst, fival->pixel_format,
558 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); 564 V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
559 if (!fmt) { 565 if (!fmt) {
560 fmt = find_format(fival->pixel_format, 566 fmt = find_format(inst, fival->pixel_format,
561 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); 567 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
562 if (!fmt) 568 if (!fmt)
563 return -EINVAL; 569 return -EINVAL;
@@ -747,8 +753,8 @@ static int venc_init_session(struct venus_inst *inst)
747 if (ret) 753 if (ret)
748 return ret; 754 return ret;
749 755
750 ret = venus_helper_set_input_resolution(inst, inst->out_width, 756 ret = venus_helper_set_input_resolution(inst, inst->width,
751 inst->out_height); 757 inst->height);
752 if (ret) 758 if (ret)
753 goto deinit; 759 goto deinit;
754 760
@@ -1010,6 +1016,8 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
1010 src_vq->allow_zero_bytesused = 1; 1016 src_vq->allow_zero_bytesused = 1;
1011 src_vq->min_buffers_needed = 1; 1017 src_vq->min_buffers_needed = 1;
1012 src_vq->dev = inst->core->dev; 1018 src_vq->dev = inst->core->dev;
1019 if (inst->core->res->hfi_version == HFI_VERSION_1XX)
1020 src_vq->bidirectional = 1;
1013 ret = vb2_queue_init(src_vq); 1021 ret = vb2_queue_init(src_vq);
1014 if (ret) 1022 if (ret)
1015 return ret; 1023 return ret;
@@ -1190,6 +1198,7 @@ static int venc_probe(struct platform_device *pdev)
1190 if (!vdev) 1198 if (!vdev)
1191 return -ENOMEM; 1199 return -ENOMEM;
1192 1200
1201 strlcpy(vdev->name, "qcom-venus-encoder", sizeof(vdev->name));
1193 vdev->release = video_device_release; 1202 vdev->release = video_device_release;
1194 vdev->fops = &venc_fops; 1203 vdev->fops = &venc_fops;
1195 vdev->ioctl_ops = &venc_ioctl_ops; 1204 vdev->ioctl_ops = &venc_ioctl_ops;
@@ -1224,8 +1233,7 @@ static int venc_remove(struct platform_device *pdev)
1224 return 0; 1233 return 0;
1225} 1234}
1226 1235
1227#ifdef CONFIG_PM 1236static __maybe_unused int venc_runtime_suspend(struct device *dev)
1228static int venc_runtime_suspend(struct device *dev)
1229{ 1237{
1230 struct venus_core *core = dev_get_drvdata(dev); 1238 struct venus_core *core = dev_get_drvdata(dev);
1231 1239
@@ -1239,7 +1247,7 @@ static int venc_runtime_suspend(struct device *dev)
1239 return 0; 1247 return 0;
1240} 1248}
1241 1249
1242static int venc_runtime_resume(struct device *dev) 1250static __maybe_unused int venc_runtime_resume(struct device *dev)
1243{ 1251{
1244 struct venus_core *core = dev_get_drvdata(dev); 1252 struct venus_core *core = dev_get_drvdata(dev);
1245 int ret; 1253 int ret;
@@ -1253,7 +1261,6 @@ static int venc_runtime_resume(struct device *dev)
1253 1261
1254 return ret; 1262 return ret;
1255} 1263}
1256#endif
1257 1264
1258static const struct dev_pm_ops venc_pm_ops = { 1265static const struct dev_pm_ops venc_pm_ops = {
1259 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 1266 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index 77dff047c41c..142de447aaaa 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -222,8 +222,8 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
222 222
223 subdevs[0] = &vin->digital.asd; 223 subdevs[0] = &vin->digital.asd;
224 224
225 vin_dbg(vin, "Found digital subdevice %s\n", 225 vin_dbg(vin, "Found digital subdevice %pOF\n",
226 of_node_full_name(to_of_node(subdevs[0]->match.fwnode.fwnode))); 226 to_of_node(subdevs[0]->match.fwnode.fwnode));
227 227
228 vin->notifier.num_subdevs = 1; 228 vin->notifier.num_subdevs = 1;
229 vin->notifier.subdevs = subdevs; 229 vin->notifier.subdevs = subdevs;
diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c
index 3ee51fc3bb50..3245bc45f4a0 100644
--- a/drivers/media/platform/rcar_fdp1.c
+++ b/drivers/media/platform/rcar_fdp1.c
@@ -2032,7 +2032,7 @@ static void fdp1_stop_streaming(struct vb2_queue *q)
2032 } 2032 }
2033} 2033}
2034 2034
2035static struct vb2_ops fdp1_qops = { 2035static const struct vb2_ops fdp1_qops = {
2036 .queue_setup = fdp1_queue_setup, 2036 .queue_setup = fdp1_queue_setup,
2037 .buf_prepare = fdp1_buf_prepare, 2037 .buf_prepare = fdp1_buf_prepare,
2038 .buf_queue = fdp1_buf_queue, 2038 .buf_queue = fdp1_buf_queue,
diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c
index d1746ecc645d..070bac36d766 100644
--- a/drivers/media/platform/rcar_jpu.c
+++ b/drivers/media/platform/rcar_jpu.c
@@ -1506,7 +1506,7 @@ static void jpu_job_abort(void *priv)
1506 jpu_cleanup(ctx, true); 1506 jpu_cleanup(ctx, true);
1507} 1507}
1508 1508
1509static struct v4l2_m2m_ops jpu_m2m_ops = { 1509static const struct v4l2_m2m_ops jpu_m2m_ops = {
1510 .device_run = jpu_device_run, 1510 .device_run = jpu_device_run,
1511 .job_ready = jpu_job_ready, 1511 .job_ready = jpu_job_ready,
1512 .job_abort = jpu_job_abort, 1512 .job_abort = jpu_job_abort,
diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c
index ec4001970313..c4ab63986c8f 100644
--- a/drivers/media/platform/s3c-camif/camif-core.c
+++ b/drivers/media/platform/s3c-camif/camif-core.c
@@ -317,7 +317,6 @@ static int camif_media_dev_init(struct camif_dev *camif)
317 ip_rev == S3C6410_CAMIF_IP_REV ? "6410" : "244X"); 317 ip_rev == S3C6410_CAMIF_IP_REV ? "6410" : "244X");
318 strlcpy(md->bus_info, "platform", sizeof(md->bus_info)); 318 strlcpy(md->bus_info, "platform", sizeof(md->bus_info));
319 md->hw_revision = ip_rev; 319 md->hw_revision = ip_rev;
320 md->driver_version = KERNEL_VERSION(1, 0, 0);
321 320
322 md->dev = camif->dev; 321 md->dev = camif->dev;
323 322
diff --git a/drivers/media/platform/s5p-cec/s5p_cec.c b/drivers/media/platform/s5p-cec/s5p_cec.c
index 8e06071a7977..58d200e7c838 100644
--- a/drivers/media/platform/s5p-cec/s5p_cec.c
+++ b/drivers/media/platform/s5p-cec/s5p_cec.c
@@ -219,11 +219,8 @@ static int s5p_cec_probe(struct platform_device *pdev)
219 if (cec->notifier == NULL) 219 if (cec->notifier == NULL)
220 return -ENOMEM; 220 return -ENOMEM;
221 221
222 cec->adap = cec_allocate_adapter(&s5p_cec_adap_ops, cec, 222 cec->adap = cec_allocate_adapter(&s5p_cec_adap_ops, cec, CEC_NAME,
223 CEC_NAME, 223 CEC_CAP_DEFAULTS | (needs_hpd ? CEC_CAP_NEEDS_HPD : 0), 1);
224 CEC_CAP_LOG_ADDRS | CEC_CAP_TRANSMIT |
225 CEC_CAP_PASSTHROUGH | CEC_CAP_RC |
226 (needs_hpd ? CEC_CAP_NEEDS_HPD : 0), 1);
227 ret = PTR_ERR_OR_ZERO(cec->adap); 224 ret = PTR_ERR_OR_ZERO(cec->adap);
228 if (ret) 225 if (ret)
229 return ret; 226 return ret;
diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
index 81ed5cd5cd5d..66aa8cf1d048 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -602,7 +602,7 @@ static const struct v4l2_ioctl_ops g2d_ioctl_ops = {
602 .vidioc_cropcap = vidioc_cropcap, 602 .vidioc_cropcap = vidioc_cropcap,
603}; 603};
604 604
605static struct video_device g2d_videodev = { 605static const struct video_device g2d_videodev = {
606 .name = G2D_NAME, 606 .name = G2D_NAME,
607 .fops = &g2d_fops, 607 .fops = &g2d_fops,
608 .ioctl_ops = &g2d_ioctl_ops, 608 .ioctl_ops = &g2d_ioctl_ops,
@@ -611,7 +611,7 @@ static struct video_device g2d_videodev = {
611 .vfl_dir = VFL_DIR_M2M, 611 .vfl_dir = VFL_DIR_M2M,
612}; 612};
613 613
614static struct v4l2_m2m_ops g2d_m2m_ops = { 614static const struct v4l2_m2m_ops g2d_m2m_ops = {
615 .device_run = device_run, 615 .device_run = device_run,
616 .job_abort = job_abort, 616 .job_abort = job_abort,
617}; 617};
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index d1e3ebb22577..faac8161b683 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -24,6 +24,7 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <linux/string.h> 26#include <linux/string.h>
27#include <media/v4l2-event.h>
27#include <media/v4l2-mem2mem.h> 28#include <media/v4l2-mem2mem.h>
28#include <media/v4l2-ioctl.h> 29#include <media/v4l2-ioctl.h>
29#include <media/videobuf2-v4l2.h> 30#include <media/videobuf2-v4l2.h>
@@ -614,24 +615,27 @@ static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh)
614 615
615static int s5p_jpeg_to_user_subsampling(struct s5p_jpeg_ctx *ctx) 616static int s5p_jpeg_to_user_subsampling(struct s5p_jpeg_ctx *ctx)
616{ 617{
617 WARN_ON(ctx->subsampling > 3);
618
619 switch (ctx->jpeg->variant->version) { 618 switch (ctx->jpeg->variant->version) {
620 case SJPEG_S5P: 619 case SJPEG_S5P:
620 WARN_ON(ctx->subsampling > 3);
621 if (ctx->subsampling > 2) 621 if (ctx->subsampling > 2)
622 return V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY; 622 return V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY;
623 return ctx->subsampling; 623 return ctx->subsampling;
624 case SJPEG_EXYNOS3250: 624 case SJPEG_EXYNOS3250:
625 case SJPEG_EXYNOS5420: 625 case SJPEG_EXYNOS5420:
626 WARN_ON(ctx->subsampling > 6);
626 if (ctx->subsampling > 3) 627 if (ctx->subsampling > 3)
627 return V4L2_JPEG_CHROMA_SUBSAMPLING_411; 628 return V4L2_JPEG_CHROMA_SUBSAMPLING_411;
628 return exynos3250_decoded_subsampling[ctx->subsampling]; 629 return exynos3250_decoded_subsampling[ctx->subsampling];
629 case SJPEG_EXYNOS4: 630 case SJPEG_EXYNOS4:
630 case SJPEG_EXYNOS5433: 631 WARN_ON(ctx->subsampling > 3);
631 if (ctx->subsampling > 2) 632 if (ctx->subsampling > 2)
632 return V4L2_JPEG_CHROMA_SUBSAMPLING_420; 633 return V4L2_JPEG_CHROMA_SUBSAMPLING_420;
633 return exynos4x12_decoded_subsampling[ctx->subsampling]; 634 return exynos4x12_decoded_subsampling[ctx->subsampling];
635 case SJPEG_EXYNOS5433:
636 return ctx->subsampling; /* parsed from header */
634 default: 637 default:
638 WARN_ON(ctx->subsampling > 3);
635 return V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY; 639 return V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY;
636 } 640 }
637} 641}
@@ -1094,6 +1098,44 @@ static void skip(struct s5p_jpeg_buffer *buf, long len)
1094 get_byte(buf); 1098 get_byte(buf);
1095} 1099}
1096 1100
1101static bool s5p_jpeg_subsampling_decode(struct s5p_jpeg_ctx *ctx,
1102 unsigned int subsampling)
1103{
1104 unsigned int version;
1105
1106 switch (subsampling) {
1107 case 0x11:
1108 ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444;
1109 break;
1110 case 0x21:
1111 ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_422;
1112 break;
1113 case 0x22:
1114 ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420;
1115 break;
1116 case 0x33:
1117 ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY;
1118 break;
1119 case 0x41:
1120 /*
1121 * 4:1:1 subsampling only supported by 3250, 5420, and 5433
1122 * variants
1123 */
1124 version = ctx->jpeg->variant->version;
1125 if (version != SJPEG_EXYNOS3250 &&
1126 version != SJPEG_EXYNOS5420 &&
1127 version != SJPEG_EXYNOS5433)
1128 return false;
1129
1130 ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_411;
1131 break;
1132 default:
1133 return false;
1134 }
1135
1136 return true;
1137}
1138
1097static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, 1139static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
1098 unsigned long buffer, unsigned long size, 1140 unsigned long buffer, unsigned long size,
1099 struct s5p_jpeg_ctx *ctx) 1141 struct s5p_jpeg_ctx *ctx)
@@ -1204,6 +1246,10 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
1204 break; 1246 break;
1205 } 1247 }
1206 } 1248 }
1249
1250 if (notfound || !sos || !s5p_jpeg_subsampling_decode(ctx, subsampling))
1251 return false;
1252
1207 result->w = width; 1253 result->w = width;
1208 result->h = height; 1254 result->h = height;
1209 result->sos = sos; 1255 result->sos = sos;
@@ -1219,26 +1265,9 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
1219 } 1265 }
1220 result->sof = sof; 1266 result->sof = sof;
1221 result->sof_len = sof_len; 1267 result->sof_len = sof_len;
1222 result->size = result->components = components; 1268 result->components = components;
1223
1224 switch (subsampling) {
1225 case 0x11:
1226 ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444;
1227 break;
1228 case 0x21:
1229 ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_422;
1230 break;
1231 case 0x22:
1232 ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420;
1233 break;
1234 case 0x33:
1235 ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY;
1236 break;
1237 default:
1238 return false;
1239 }
1240 1269
1241 return !notfound && sos; 1270 return true;
1242} 1271}
1243 1272
1244static int s5p_jpeg_querycap(struct file *file, void *priv, 1273static int s5p_jpeg_querycap(struct file *file, void *priv,
@@ -1606,8 +1635,12 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f)
1606 FMT_TYPE_OUTPUT : FMT_TYPE_CAPTURE; 1635 FMT_TYPE_OUTPUT : FMT_TYPE_CAPTURE;
1607 1636
1608 q_data->fmt = s5p_jpeg_find_format(ct, pix->pixelformat, f_type); 1637 q_data->fmt = s5p_jpeg_find_format(ct, pix->pixelformat, f_type);
1609 q_data->w = pix->width; 1638 if (ct->mode == S5P_JPEG_ENCODE ||
1610 q_data->h = pix->height; 1639 (ct->mode == S5P_JPEG_DECODE &&
1640 q_data->fmt->fourcc != V4L2_PIX_FMT_JPEG)) {
1641 q_data->w = pix->width;
1642 q_data->h = pix->height;
1643 }
1611 if (q_data->fmt->fourcc != V4L2_PIX_FMT_JPEG) { 1644 if (q_data->fmt->fourcc != V4L2_PIX_FMT_JPEG) {
1612 /* 1645 /*
1613 * During encoding Exynos4x12 SoCs access wider memory area 1646 * During encoding Exynos4x12 SoCs access wider memory area
@@ -1690,6 +1723,15 @@ static int s5p_jpeg_s_fmt_vid_out(struct file *file, void *priv,
1690 return s5p_jpeg_s_fmt(fh_to_ctx(priv), f); 1723 return s5p_jpeg_s_fmt(fh_to_ctx(priv), f);
1691} 1724}
1692 1725
1726static int s5p_jpeg_subscribe_event(struct v4l2_fh *fh,
1727 const struct v4l2_event_subscription *sub)
1728{
1729 if (sub->type == V4L2_EVENT_SOURCE_CHANGE)
1730 return v4l2_src_change_event_subscribe(fh, sub);
1731
1732 return -EINVAL;
1733}
1734
1693static int exynos3250_jpeg_try_downscale(struct s5p_jpeg_ctx *ctx, 1735static int exynos3250_jpeg_try_downscale(struct s5p_jpeg_ctx *ctx,
1694 struct v4l2_rect *r) 1736 struct v4l2_rect *r)
1695{ 1737{
@@ -2015,6 +2057,9 @@ static const struct v4l2_ioctl_ops s5p_jpeg_ioctl_ops = {
2015 2057
2016 .vidioc_g_selection = s5p_jpeg_g_selection, 2058 .vidioc_g_selection = s5p_jpeg_g_selection,
2017 .vidioc_s_selection = s5p_jpeg_s_selection, 2059 .vidioc_s_selection = s5p_jpeg_s_selection,
2060
2061 .vidioc_subscribe_event = s5p_jpeg_subscribe_event,
2062 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
2018}; 2063};
2019 2064
2020/* 2065/*
@@ -2259,6 +2304,7 @@ static void exynos4_jpeg_device_run(void *priv)
2259 exynos4_jpeg_set_dec_bitstream_size(jpeg->regs, bitstream_size); 2304 exynos4_jpeg_set_dec_bitstream_size(jpeg->regs, bitstream_size);
2260 } 2305 }
2261 2306
2307 exynos4_jpeg_set_sys_int_enable(jpeg->regs, 1);
2262 exynos4_jpeg_set_enc_dec_mode(jpeg->regs, ctx->mode); 2308 exynos4_jpeg_set_enc_dec_mode(jpeg->regs, ctx->mode);
2263 2309
2264 spin_unlock_irqrestore(&jpeg->slock, flags); 2310 spin_unlock_irqrestore(&jpeg->slock, flags);
@@ -2407,8 +2453,17 @@ static int s5p_jpeg_job_ready(void *priv)
2407{ 2453{
2408 struct s5p_jpeg_ctx *ctx = priv; 2454 struct s5p_jpeg_ctx *ctx = priv;
2409 2455
2410 if (ctx->mode == S5P_JPEG_DECODE) 2456 if (ctx->mode == S5P_JPEG_DECODE) {
2457 /*
2458 * We have only one input buffer and one output buffer. If there
2459 * is a resolution change event, no need to continue decoding.
2460 */
2461 if (ctx->state == JPEGCTX_RESOLUTION_CHANGE)
2462 return 0;
2463
2411 return ctx->hdr_parsed; 2464 return ctx->hdr_parsed;
2465 }
2466
2412 return 1; 2467 return 1;
2413} 2468}
2414 2469
@@ -2487,6 +2542,30 @@ static int s5p_jpeg_buf_prepare(struct vb2_buffer *vb)
2487 return 0; 2542 return 0;
2488} 2543}
2489 2544
2545static void s5p_jpeg_set_capture_queue_data(struct s5p_jpeg_ctx *ctx)
2546{
2547 struct s5p_jpeg_q_data *q_data = &ctx->cap_q;
2548
2549 q_data->w = ctx->out_q.w;
2550 q_data->h = ctx->out_q.h;
2551
2552 /*
2553 * This call to jpeg_bound_align_image() takes care of width and
2554 * height values alignment when user space calls the QBUF of
2555 * OUTPUT buffer after the S_FMT of CAPTURE buffer.
2556 * Please note that on Exynos4x12 SoCs, resigning from executing
2557 * S_FMT on capture buffer for each JPEG image can result in a
2558 * hardware hangup if subsampling is lower than the one of input
2559 * JPEG.
2560 */
2561 jpeg_bound_align_image(ctx, &q_data->w, S5P_JPEG_MIN_WIDTH,
2562 S5P_JPEG_MAX_WIDTH, q_data->fmt->h_align,
2563 &q_data->h, S5P_JPEG_MIN_HEIGHT,
2564 S5P_JPEG_MAX_HEIGHT, q_data->fmt->v_align);
2565
2566 q_data->size = q_data->w * q_data->h * q_data->fmt->depth >> 3;
2567}
2568
2490static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) 2569static void s5p_jpeg_buf_queue(struct vb2_buffer *vb)
2491{ 2570{
2492 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 2571 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
@@ -2494,9 +2573,20 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb)
2494 2573
2495 if (ctx->mode == S5P_JPEG_DECODE && 2574 if (ctx->mode == S5P_JPEG_DECODE &&
2496 vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { 2575 vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
2497 struct s5p_jpeg_q_data tmp, *q_data; 2576 static const struct v4l2_event ev_src_ch = {
2498 2577 .type = V4L2_EVENT_SOURCE_CHANGE,
2499 ctx->hdr_parsed = s5p_jpeg_parse_hdr(&tmp, 2578 .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION,
2579 };
2580 struct vb2_queue *dst_vq;
2581 u32 ori_w;
2582 u32 ori_h;
2583
2584 dst_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx,
2585 V4L2_BUF_TYPE_VIDEO_CAPTURE);
2586 ori_w = ctx->out_q.w;
2587 ori_h = ctx->out_q.h;
2588
2589 ctx->hdr_parsed = s5p_jpeg_parse_hdr(&ctx->out_q,
2500 (unsigned long)vb2_plane_vaddr(vb, 0), 2590 (unsigned long)vb2_plane_vaddr(vb, 0),
2501 min((unsigned long)ctx->out_q.size, 2591 min((unsigned long)ctx->out_q.size,
2502 vb2_get_plane_payload(vb, 0)), ctx); 2592 vb2_get_plane_payload(vb, 0)), ctx);
@@ -2505,24 +2595,18 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb)
2505 return; 2595 return;
2506 } 2596 }
2507 2597
2508 q_data = &ctx->out_q; 2598 /*
2509 q_data->w = tmp.w; 2599 * If there is a resolution change event, only update capture
2510 q_data->h = tmp.h; 2600 * queue when it is not streaming. Otherwise, update it in
2511 q_data->sos = tmp.sos; 2601 * STREAMOFF. See s5p_jpeg_stop_streaming for detail.
2512 memcpy(q_data->dht.marker, tmp.dht.marker, 2602 */
2513 sizeof(tmp.dht.marker)); 2603 if (ctx->out_q.w != ori_w || ctx->out_q.h != ori_h) {
2514 memcpy(q_data->dht.len, tmp.dht.len, sizeof(tmp.dht.len)); 2604 v4l2_event_queue_fh(&ctx->fh, &ev_src_ch);
2515 q_data->dht.n = tmp.dht.n; 2605 if (vb2_is_streaming(dst_vq))
2516 memcpy(q_data->dqt.marker, tmp.dqt.marker, 2606 ctx->state = JPEGCTX_RESOLUTION_CHANGE;
2517 sizeof(tmp.dqt.marker)); 2607 else
2518 memcpy(q_data->dqt.len, tmp.dqt.len, sizeof(tmp.dqt.len)); 2608 s5p_jpeg_set_capture_queue_data(ctx);
2519 q_data->dqt.n = tmp.dqt.n; 2609 }
2520 q_data->sof = tmp.sof;
2521 q_data->sof_len = tmp.sof_len;
2522
2523 q_data = &ctx->cap_q;
2524 q_data->w = tmp.w;
2525 q_data->h = tmp.h;
2526 } 2610 }
2527 2611
2528 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); 2612 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
@@ -2542,6 +2626,17 @@ static void s5p_jpeg_stop_streaming(struct vb2_queue *q)
2542{ 2626{
2543 struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(q); 2627 struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(q);
2544 2628
2629 /*
2630 * STREAMOFF is an acknowledgment for resolution change event.
2631 * Before STREAMOFF, we still have to return the old resolution and
2632 * subsampling. Update capture queue when the stream is off.
2633 */
2634 if (ctx->state == JPEGCTX_RESOLUTION_CHANGE &&
2635 q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
2636 s5p_jpeg_set_capture_queue_data(ctx);
2637 ctx->state = JPEGCTX_RUNNING;
2638 }
2639
2545 pm_runtime_put(ctx->jpeg->dev); 2640 pm_runtime_put(ctx->jpeg->dev);
2546} 2641}
2547 2642
@@ -2662,6 +2757,8 @@ static irqreturn_t exynos4_jpeg_irq(int irq, void *priv)
2662 2757
2663 spin_lock(&jpeg->slock); 2758 spin_lock(&jpeg->slock);
2664 2759
2760 exynos4_jpeg_set_sys_int_enable(jpeg->regs, 0);
2761
2665 curr_ctx = v4l2_m2m_get_curr_priv(jpeg->m2m_dev); 2762 curr_ctx = v4l2_m2m_get_curr_priv(jpeg->m2m_dev);
2666 2763
2667 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->fh.m2m_ctx); 2764 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->fh.m2m_ctx);
@@ -2710,6 +2807,8 @@ static irqreturn_t exynos4_jpeg_irq(int irq, void *priv)
2710 if (jpeg->variant->version == SJPEG_EXYNOS4) 2807 if (jpeg->variant->version == SJPEG_EXYNOS4)
2711 curr_ctx->subsampling = exynos4_jpeg_get_frame_fmt(jpeg->regs); 2808 curr_ctx->subsampling = exynos4_jpeg_get_frame_fmt(jpeg->regs);
2712 2809
2810 exynos4_jpeg_set_enc_dec_mode(jpeg->regs, S5P_JPEG_DISABLE);
2811
2713 spin_unlock(&jpeg->slock); 2812 spin_unlock(&jpeg->slock);
2714 2813
2715 v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); 2814 v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx);
@@ -2724,6 +2823,7 @@ static irqreturn_t exynos3250_jpeg_irq(int irq, void *dev_id)
2724 unsigned long payload_size = 0; 2823 unsigned long payload_size = 0;
2725 enum vb2_buffer_state state = VB2_BUF_STATE_DONE; 2824 enum vb2_buffer_state state = VB2_BUF_STATE_DONE;
2726 bool interrupt_timeout = false; 2825 bool interrupt_timeout = false;
2826 bool stream_error = false;
2727 u32 irq_status; 2827 u32 irq_status;
2728 2828
2729 spin_lock(&jpeg->slock); 2829 spin_lock(&jpeg->slock);
@@ -2740,6 +2840,12 @@ static irqreturn_t exynos3250_jpeg_irq(int irq, void *dev_id)
2740 2840
2741 jpeg->irq_status |= irq_status; 2841 jpeg->irq_status |= irq_status;
2742 2842
2843 if (jpeg->variant->version == SJPEG_EXYNOS5420 &&
2844 irq_status & EXYNOS3250_STREAM_STAT) {
2845 stream_error = true;
2846 dev_err(jpeg->dev, "Syntax error or unrecoverable error occurred.\n");
2847 }
2848
2743 curr_ctx = v4l2_m2m_get_curr_priv(jpeg->m2m_dev); 2849 curr_ctx = v4l2_m2m_get_curr_priv(jpeg->m2m_dev);
2744 2850
2745 if (!curr_ctx) 2851 if (!curr_ctx)
@@ -2756,7 +2862,7 @@ static irqreturn_t exynos3250_jpeg_irq(int irq, void *dev_id)
2756 EXYNOS3250_RDMA_DONE | 2862 EXYNOS3250_RDMA_DONE |
2757 EXYNOS3250_RESULT_STAT)) 2863 EXYNOS3250_RESULT_STAT))
2758 payload_size = exynos3250_jpeg_compressed_size(jpeg->regs); 2864 payload_size = exynos3250_jpeg_compressed_size(jpeg->regs);
2759 else if (interrupt_timeout) 2865 else if (interrupt_timeout || stream_error)
2760 state = VB2_BUF_STATE_ERROR; 2866 state = VB2_BUF_STATE_ERROR;
2761 else 2867 else
2762 goto exit_unlock; 2868 goto exit_unlock;
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.h b/drivers/media/platform/s5p-jpeg/jpeg-core.h
index 4492a3535df5..a46465e10351 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.h
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.h
@@ -63,6 +63,7 @@
63 63
64#define S5P_JPEG_ENCODE 0 64#define S5P_JPEG_ENCODE 0
65#define S5P_JPEG_DECODE 1 65#define S5P_JPEG_DECODE 1
66#define S5P_JPEG_DISABLE -1
66 67
67#define FMT_TYPE_OUTPUT 0 68#define FMT_TYPE_OUTPUT 0
68#define FMT_TYPE_CAPTURE 1 69#define FMT_TYPE_CAPTURE 1
@@ -98,6 +99,11 @@ enum exynos4_jpeg_img_quality_level {
98 QUALITY_LEVEL_4, /* low */ 99 QUALITY_LEVEL_4, /* low */
99}; 100};
100 101
102enum s5p_jpeg_ctx_state {
103 JPEGCTX_RUNNING = 0,
104 JPEGCTX_RESOLUTION_CHANGE,
105};
106
101/** 107/**
102 * struct s5p_jpeg - JPEG IP abstraction 108 * struct s5p_jpeg - JPEG IP abstraction
103 * @lock: the mutex protecting this structure 109 * @lock: the mutex protecting this structure
@@ -220,6 +226,7 @@ struct s5p_jpeg_q_data {
220 * @hdr_parsed: set if header has been parsed during decompression 226 * @hdr_parsed: set if header has been parsed during decompression
221 * @crop_altered: set if crop rectangle has been altered by the user space 227 * @crop_altered: set if crop rectangle has been altered by the user space
222 * @ctrl_handler: controls handler 228 * @ctrl_handler: controls handler
229 * @state: state of the context
223 */ 230 */
224struct s5p_jpeg_ctx { 231struct s5p_jpeg_ctx {
225 struct s5p_jpeg *jpeg; 232 struct s5p_jpeg *jpeg;
@@ -235,6 +242,7 @@ struct s5p_jpeg_ctx {
235 bool hdr_parsed; 242 bool hdr_parsed;
236 bool crop_altered; 243 bool crop_altered;
237 struct v4l2_ctrl_handler ctrl_handler; 244 struct v4l2_ctrl_handler ctrl_handler;
245 enum s5p_jpeg_ctx_state state;
238}; 246};
239 247
240/** 248/**
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c b/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c
index a1d823ab0c63..c72789bae6ed 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c
@@ -21,6 +21,10 @@ void exynos4_jpeg_sw_reset(void __iomem *base)
21 unsigned int reg; 21 unsigned int reg;
22 22
23 reg = readl(base + EXYNOS4_JPEG_CNTL_REG); 23 reg = readl(base + EXYNOS4_JPEG_CNTL_REG);
24 writel(reg & ~(EXYNOS4_DEC_MODE | EXYNOS4_ENC_MODE),
25 base + EXYNOS4_JPEG_CNTL_REG);
26
27 reg = readl(base + EXYNOS4_JPEG_CNTL_REG);
24 writel(reg & ~EXYNOS4_SOFT_RESET_HI, base + EXYNOS4_JPEG_CNTL_REG); 28 writel(reg & ~EXYNOS4_SOFT_RESET_HI, base + EXYNOS4_JPEG_CNTL_REG);
25 29
26 udelay(100); 30 udelay(100);
@@ -38,10 +42,13 @@ void exynos4_jpeg_set_enc_dec_mode(void __iomem *base, unsigned int mode)
38 writel((reg & EXYNOS4_ENC_DEC_MODE_MASK) | 42 writel((reg & EXYNOS4_ENC_DEC_MODE_MASK) |
39 EXYNOS4_DEC_MODE, 43 EXYNOS4_DEC_MODE,
40 base + EXYNOS4_JPEG_CNTL_REG); 44 base + EXYNOS4_JPEG_CNTL_REG);
41 } else {/* encode */ 45 } else if (mode == S5P_JPEG_ENCODE) {/* encode */
42 writel((reg & EXYNOS4_ENC_DEC_MODE_MASK) | 46 writel((reg & EXYNOS4_ENC_DEC_MODE_MASK) |
43 EXYNOS4_ENC_MODE, 47 EXYNOS4_ENC_MODE,
44 base + EXYNOS4_JPEG_CNTL_REG); 48 base + EXYNOS4_JPEG_CNTL_REG);
49 } else { /* disable both */
50 writel(reg & EXYNOS4_ENC_DEC_MODE_MASK,
51 base + EXYNOS4_JPEG_CNTL_REG);
45 } 52 }
46} 53}
47 54
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-regs.h b/drivers/media/platform/s5p-jpeg/jpeg-regs.h
index 1870400468b2..df790b10140c 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-regs.h
+++ b/drivers/media/platform/s5p-jpeg/jpeg-regs.h
@@ -371,7 +371,7 @@
371#define EXYNOS4_NF_SHIFT 16 371#define EXYNOS4_NF_SHIFT 16
372#define EXYNOS4_NF_MASK 0xff 372#define EXYNOS4_NF_MASK 0xff
373#define EXYNOS4_NF(x) \ 373#define EXYNOS4_NF(x) \
374 (((x) << EXYNOS4_NF_SHIFT) & EXYNOS4_NF_MASK) 374 (((x) & EXYNOS4_NF_MASK) << EXYNOS4_NF_SHIFT)
375 375
376/* JPEG quantizer table register */ 376/* JPEG quantizer table register */
377#define EXYNOS4_QTBL_CONTENT(n) (0x100 + (n) * 0x40) 377#define EXYNOS4_QTBL_CONTENT(n) (0x100 + (n) * 0x40)
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 45a0429d75bb..1f3c450c7a69 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -820,7 +820,7 @@ static unsigned int soc_camera_poll(struct file *file, poll_table *pt)
820 return res; 820 return res;
821} 821}
822 822
823static struct v4l2_file_operations soc_camera_fops = { 823static const struct v4l2_file_operations soc_camera_fops = {
824 .owner = THIS_MODULE, 824 .owner = THIS_MODULE,
825 .open = soc_camera_open, 825 .open = soc_camera_open,
826 .release = soc_camera_close, 826 .release = soc_camera_close,
@@ -1550,8 +1550,7 @@ static int soc_of_bind(struct soc_camera_host *ici,
1550 v4l2_clk_name_i2c(clk_name, sizeof(clk_name), 1550 v4l2_clk_name_i2c(clk_name, sizeof(clk_name),
1551 client->adapter->nr, client->addr); 1551 client->adapter->nr, client->addr);
1552 else 1552 else
1553 v4l2_clk_name_of(clk_name, sizeof(clk_name), 1553 v4l2_clk_name_of(clk_name, sizeof(clk_name), remote);
1554 of_node_full_name(remote));
1555 1554
1556 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd); 1555 icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, icd);
1557 if (IS_ERR(icd->clk)) { 1556 if (IS_ERR(icd->clk)) {
@@ -1590,8 +1589,7 @@ static void scan_of_host(struct soc_camera_host *ici)
1590 1589
1591 ren = of_graph_get_remote_port(epn); 1590 ren = of_graph_get_remote_port(epn);
1592 if (!ren) { 1591 if (!ren) {
1593 dev_notice(dev, "no remote for %s\n", 1592 dev_notice(dev, "no remote for %pOF\n", epn);
1594 of_node_full_name(epn));
1595 continue; 1593 continue;
1596 } 1594 }
1597 1595
diff --git a/drivers/media/platform/soc_camera/soc_mediabus.c b/drivers/media/platform/soc_camera/soc_mediabus.c
index 57581f626f4c..0ad4b28266e4 100644
--- a/drivers/media/platform/soc_camera/soc_mediabus.c
+++ b/drivers/media/platform/soc_camera/soc_mediabus.c
@@ -508,6 +508,9 @@ unsigned int soc_mbus_config_compatible(const struct v4l2_mbus_config *cfg,
508 mipi_clock = common_flags & (V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK | 508 mipi_clock = common_flags & (V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK |
509 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK); 509 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK);
510 return (!mipi_lanes || !mipi_clock) ? 0 : common_flags; 510 return (!mipi_lanes || !mipi_clock) ? 0 : common_flags;
511 default:
512 WARN_ON(1);
513 return -EINVAL;
511 } 514 }
512 return 0; 515 return 0;
513} 516}
diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
index 7918b928f058..939da6da7644 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c
@@ -360,7 +360,7 @@ out:
360 bdisp_job_finish(ctx, VB2_BUF_STATE_ERROR); 360 bdisp_job_finish(ctx, VB2_BUF_STATE_ERROR);
361} 361}
362 362
363static struct v4l2_m2m_ops bdisp_m2m_ops = { 363static const struct v4l2_m2m_ops bdisp_m2m_ops = {
364 .device_run = bdisp_device_run, 364 .device_run = bdisp_device_run,
365 .job_abort = bdisp_job_abort, 365 .job_abort = bdisp_job_abort,
366}; 366};
diff --git a/drivers/media/platform/sti/cec/stih-cec.c b/drivers/media/platform/sti/cec/stih-cec.c
index dccbdaebb7a8..70160df36de9 100644
--- a/drivers/media/platform/sti/cec/stih-cec.c
+++ b/drivers/media/platform/sti/cec/stih-cec.c
@@ -351,9 +351,7 @@ static int stih_cec_probe(struct platform_device *pdev)
351 } 351 }
352 352
353 cec->adap = cec_allocate_adapter(&sti_cec_adap_ops, cec, 353 cec->adap = cec_allocate_adapter(&sti_cec_adap_ops, cec,
354 CEC_NAME, 354 CEC_NAME, CEC_CAP_DEFAULTS, CEC_MAX_LOG_ADDRS);
355 CEC_CAP_LOG_ADDRS | CEC_CAP_PASSTHROUGH |
356 CEC_CAP_TRANSMIT, CEC_MAX_LOG_ADDRS);
357 ret = PTR_ERR_OR_ZERO(cec->adap); 355 ret = PTR_ERR_OR_ZERO(cec->adap);
358 if (ret) 356 if (ret)
359 return ret; 357 return ret;
diff --git a/drivers/media/platform/sti/delta/delta-v4l2.c b/drivers/media/platform/sti/delta/delta-v4l2.c
index c6f2e244b7a8..b2dc3d223a9c 100644
--- a/drivers/media/platform/sti/delta/delta-v4l2.c
+++ b/drivers/media/platform/sti/delta/delta-v4l2.c
@@ -1095,7 +1095,7 @@ static int delta_job_ready(void *priv)
1095} 1095}
1096 1096
1097/* mem-to-mem ops */ 1097/* mem-to-mem ops */
1098static struct v4l2_m2m_ops delta_m2m_ops = { 1098static const struct v4l2_m2m_ops delta_m2m_ops = {
1099 .device_run = delta_device_run, 1099 .device_run = delta_device_run,
1100 .job_ready = delta_job_ready, 1100 .job_ready = delta_job_ready,
1101 .job_abort = delta_job_abort, 1101 .job_abort = delta_job_abort,
@@ -1574,7 +1574,7 @@ static void delta_vb2_frame_stop_streaming(struct vb2_queue *q)
1574} 1574}
1575 1575
1576/* VB2 queue ops */ 1576/* VB2 queue ops */
1577static struct vb2_ops delta_vb2_au_ops = { 1577static const struct vb2_ops delta_vb2_au_ops = {
1578 .queue_setup = delta_vb2_au_queue_setup, 1578 .queue_setup = delta_vb2_au_queue_setup,
1579 .buf_prepare = delta_vb2_au_prepare, 1579 .buf_prepare = delta_vb2_au_prepare,
1580 .buf_queue = delta_vb2_au_queue, 1580 .buf_queue = delta_vb2_au_queue,
@@ -1584,7 +1584,7 @@ static struct vb2_ops delta_vb2_au_ops = {
1584 .stop_streaming = delta_vb2_au_stop_streaming, 1584 .stop_streaming = delta_vb2_au_stop_streaming,
1585}; 1585};
1586 1586
1587static struct vb2_ops delta_vb2_frame_ops = { 1587static const struct vb2_ops delta_vb2_frame_ops = {
1588 .queue_setup = delta_vb2_frame_queue_setup, 1588 .queue_setup = delta_vb2_frame_queue_setup,
1589 .buf_prepare = delta_vb2_frame_prepare, 1589 .buf_prepare = delta_vb2_frame_prepare,
1590 .buf_finish = delta_vb2_frame_finish, 1590 .buf_finish = delta_vb2_frame_finish,
diff --git a/drivers/media/platform/stm32/stm32-cec.c b/drivers/media/platform/stm32/stm32-cec.c
index 9ab896b01ee8..0e5aa17bdd40 100644
--- a/drivers/media/platform/stm32/stm32-cec.c
+++ b/drivers/media/platform/stm32/stm32-cec.c
@@ -246,9 +246,7 @@ static const struct regmap_config stm32_cec_regmap_cfg = {
246 246
247static int stm32_cec_probe(struct platform_device *pdev) 247static int stm32_cec_probe(struct platform_device *pdev)
248{ 248{
249 u32 caps = CEC_CAP_LOG_ADDRS | CEC_CAP_PASSTHROUGH | 249 u32 caps = CEC_CAP_DEFAULTS | CEC_CAP_PHYS_ADDR | CEC_MODE_MONITOR_ALL;
250 CEC_CAP_TRANSMIT | CEC_CAP_RC | CEC_CAP_PHYS_ADDR |
251 CEC_MODE_MONITOR_ALL;
252 struct resource *res; 250 struct resource *res;
253 struct stm32_cec *cec; 251 struct stm32_cec *cec;
254 void __iomem *mmio; 252 void __iomem *mmio;
diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
index 83d32a5d0f40..35ba6f211b79 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -33,6 +33,7 @@
33#include <media/v4l2-fwnode.h> 33#include <media/v4l2-fwnode.h>
34#include <media/v4l2-image-sizes.h> 34#include <media/v4l2-image-sizes.h>
35#include <media/v4l2-ioctl.h> 35#include <media/v4l2-ioctl.h>
36#include <media/v4l2-rect.h>
36#include <media/videobuf2-dma-contig.h> 37#include <media/videobuf2-dma-contig.h>
37 38
38#define DRV_NAME "stm32-dcmi" 39#define DRV_NAME "stm32-dcmi"
@@ -107,6 +108,11 @@ struct dcmi_format {
107 u8 bpp; 108 u8 bpp;
108}; 109};
109 110
111struct dcmi_framesize {
112 u32 width;
113 u32 height;
114};
115
110struct dcmi_buf { 116struct dcmi_buf {
111 struct vb2_v4l2_buffer vb; 117 struct vb2_v4l2_buffer vb;
112 bool prepared; 118 bool prepared;
@@ -131,10 +137,16 @@ struct stm32_dcmi {
131 struct v4l2_async_notifier notifier; 137 struct v4l2_async_notifier notifier;
132 struct dcmi_graph_entity entity; 138 struct dcmi_graph_entity entity;
133 struct v4l2_format fmt; 139 struct v4l2_format fmt;
140 struct v4l2_rect crop;
141 bool do_crop;
134 142
135 const struct dcmi_format **user_formats; 143 const struct dcmi_format **sd_formats;
136 unsigned int num_user_formats; 144 unsigned int num_of_sd_formats;
137 const struct dcmi_format *current_fmt; 145 const struct dcmi_format *sd_format;
146 struct dcmi_framesize *sd_framesizes;
147 unsigned int num_of_sd_framesizes;
148 struct dcmi_framesize sd_framesize;
149 struct v4l2_rect sd_bounds;
138 150
139 /* Protect this data structure */ 151 /* Protect this data structure */
140 struct mutex lock; 152 struct mutex lock;
@@ -295,6 +307,10 @@ static int dcmi_start_dma(struct stm32_dcmi *dcmi,
295 307
296 /* Push current DMA transaction in the pending queue */ 308 /* Push current DMA transaction in the pending queue */
297 dcmi->dma_cookie = dmaengine_submit(desc); 309 dcmi->dma_cookie = dmaengine_submit(desc);
310 if (dma_submit_error(dcmi->dma_cookie)) {
311 dev_err(dcmi->dev, "%s: DMA submission failed\n", __func__);
312 return -ENXIO;
313 }
298 314
299 dma_async_issue_pending(dcmi->dma_chan); 315 dma_async_issue_pending(dcmi->dma_chan);
300 316
@@ -321,6 +337,28 @@ static int dcmi_start_capture(struct stm32_dcmi *dcmi)
321 return 0; 337 return 0;
322} 338}
323 339
340static void dcmi_set_crop(struct stm32_dcmi *dcmi)
341{
342 u32 size, start;
343
344 /* Crop resolution */
345 size = ((dcmi->crop.height - 1) << 16) |
346 ((dcmi->crop.width << 1) - 1);
347 reg_write(dcmi->regs, DCMI_CWSIZE, size);
348
349 /* Crop start point */
350 start = ((dcmi->crop.top) << 16) |
351 ((dcmi->crop.left << 1));
352 reg_write(dcmi->regs, DCMI_CWSTRT, start);
353
354 dev_dbg(dcmi->dev, "Cropping to %ux%u@%u:%u\n",
355 dcmi->crop.width, dcmi->crop.height,
356 dcmi->crop.left, dcmi->crop.top);
357
358 /* Enable crop */
359 reg_set(dcmi->regs, DCMI_CR, CR_CROP);
360}
361
324static irqreturn_t dcmi_irq_thread(int irq, void *arg) 362static irqreturn_t dcmi_irq_thread(int irq, void *arg)
325{ 363{
326 struct stm32_dcmi *dcmi = arg; 364 struct stm32_dcmi *dcmi = arg;
@@ -486,7 +524,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count)
486{ 524{
487 struct stm32_dcmi *dcmi = vb2_get_drv_priv(vq); 525 struct stm32_dcmi *dcmi = vb2_get_drv_priv(vq);
488 struct dcmi_buf *buf, *node; 526 struct dcmi_buf *buf, *node;
489 u32 val; 527 u32 val = 0;
490 int ret; 528 int ret;
491 529
492 ret = clk_enable(dcmi->mclk); 530 ret = clk_enable(dcmi->mclk);
@@ -506,22 +544,16 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count)
506 544
507 spin_lock_irq(&dcmi->irqlock); 545 spin_lock_irq(&dcmi->irqlock);
508 546
509 val = reg_read(dcmi->regs, DCMI_CR);
510
511 val &= ~(CR_PCKPOL | CR_HSPOL | CR_VSPOL |
512 CR_EDM_0 | CR_EDM_1 | CR_FCRC_0 |
513 CR_FCRC_1 | CR_JPEG | CR_ESS);
514
515 /* Set bus width */ 547 /* Set bus width */
516 switch (dcmi->bus.bus_width) { 548 switch (dcmi->bus.bus_width) {
517 case 14: 549 case 14:
518 val &= CR_EDM_0 + CR_EDM_1; 550 val |= CR_EDM_0 | CR_EDM_1;
519 break; 551 break;
520 case 12: 552 case 12:
521 val &= CR_EDM_1; 553 val |= CR_EDM_1;
522 break; 554 break;
523 case 10: 555 case 10:
524 val &= CR_EDM_0; 556 val |= CR_EDM_0;
525 break; 557 break;
526 default: 558 default:
527 /* Set bus width to 8 bits by default */ 559 /* Set bus width to 8 bits by default */
@@ -542,6 +574,10 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count)
542 574
543 reg_write(dcmi->regs, DCMI_CR, val); 575 reg_write(dcmi->regs, DCMI_CR, val);
544 576
577 /* Set crop */
578 if (dcmi->do_crop)
579 dcmi_set_crop(dcmi);
580
545 /* Enable dcmi */ 581 /* Enable dcmi */
546 reg_set(dcmi->regs, DCMI_CR, CR_ENABLE); 582 reg_set(dcmi->regs, DCMI_CR, CR_ENABLE);
547 583
@@ -662,7 +698,7 @@ static void dcmi_stop_streaming(struct vb2_queue *vq)
662 dcmi->errors_count, dcmi->buffers_count); 698 dcmi->errors_count, dcmi->buffers_count);
663} 699}
664 700
665static struct vb2_ops dcmi_video_qops = { 701static const struct vb2_ops dcmi_video_qops = {
666 .queue_setup = dcmi_queue_setup, 702 .queue_setup = dcmi_queue_setup,
667 .buf_init = dcmi_buf_init, 703 .buf_init = dcmi_buf_init,
668 .buf_prepare = dcmi_buf_prepare, 704 .buf_prepare = dcmi_buf_prepare,
@@ -686,12 +722,12 @@ static int dcmi_g_fmt_vid_cap(struct file *file, void *priv,
686static const struct dcmi_format *find_format_by_fourcc(struct stm32_dcmi *dcmi, 722static const struct dcmi_format *find_format_by_fourcc(struct stm32_dcmi *dcmi,
687 unsigned int fourcc) 723 unsigned int fourcc)
688{ 724{
689 unsigned int num_formats = dcmi->num_user_formats; 725 unsigned int num_formats = dcmi->num_of_sd_formats;
690 const struct dcmi_format *fmt; 726 const struct dcmi_format *fmt;
691 unsigned int i; 727 unsigned int i;
692 728
693 for (i = 0; i < num_formats; i++) { 729 for (i = 0; i < num_formats; i++) {
694 fmt = dcmi->user_formats[i]; 730 fmt = dcmi->sd_formats[i];
695 if (fmt->fourcc == fourcc) 731 if (fmt->fourcc == fourcc)
696 return fmt; 732 return fmt;
697 } 733 }
@@ -699,41 +735,108 @@ static const struct dcmi_format *find_format_by_fourcc(struct stm32_dcmi *dcmi,
699 return NULL; 735 return NULL;
700} 736}
701 737
738static void __find_outer_frame_size(struct stm32_dcmi *dcmi,
739 struct v4l2_pix_format *pix,
740 struct dcmi_framesize *framesize)
741{
742 struct dcmi_framesize *match = NULL;
743 unsigned int i;
744 unsigned int min_err = UINT_MAX;
745
746 for (i = 0; i < dcmi->num_of_sd_framesizes; i++) {
747 struct dcmi_framesize *fsize = &dcmi->sd_framesizes[i];
748 int w_err = (fsize->width - pix->width);
749 int h_err = (fsize->height - pix->height);
750 int err = w_err + h_err;
751
752 if ((w_err >= 0) && (h_err >= 0) && (err < min_err)) {
753 min_err = err;
754 match = fsize;
755 }
756 }
757 if (!match)
758 match = &dcmi->sd_framesizes[0];
759
760 *framesize = *match;
761}
762
702static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f, 763static int dcmi_try_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f,
703 const struct dcmi_format **current_fmt) 764 const struct dcmi_format **sd_format,
765 struct dcmi_framesize *sd_framesize)
704{ 766{
705 const struct dcmi_format *dcmi_fmt; 767 const struct dcmi_format *sd_fmt;
706 struct v4l2_pix_format *pixfmt = &f->fmt.pix; 768 struct dcmi_framesize sd_fsize;
769 struct v4l2_pix_format *pix = &f->fmt.pix;
707 struct v4l2_subdev_pad_config pad_cfg; 770 struct v4l2_subdev_pad_config pad_cfg;
708 struct v4l2_subdev_format format = { 771 struct v4l2_subdev_format format = {
709 .which = V4L2_SUBDEV_FORMAT_TRY, 772 .which = V4L2_SUBDEV_FORMAT_TRY,
710 }; 773 };
711 int ret; 774 int ret;
712 775
713 dcmi_fmt = find_format_by_fourcc(dcmi, pixfmt->pixelformat); 776 sd_fmt = find_format_by_fourcc(dcmi, pix->pixelformat);
714 if (!dcmi_fmt) { 777 if (!sd_fmt) {
715 dcmi_fmt = dcmi->user_formats[dcmi->num_user_formats - 1]; 778 sd_fmt = dcmi->sd_formats[dcmi->num_of_sd_formats - 1];
716 pixfmt->pixelformat = dcmi_fmt->fourcc; 779 pix->pixelformat = sd_fmt->fourcc;
717 } 780 }
718 781
719 /* Limit to hardware capabilities */ 782 /* Limit to hardware capabilities */
720 pixfmt->width = clamp(pixfmt->width, MIN_WIDTH, MAX_WIDTH); 783 pix->width = clamp(pix->width, MIN_WIDTH, MAX_WIDTH);
721 pixfmt->height = clamp(pixfmt->height, MIN_HEIGHT, MAX_HEIGHT); 784 pix->height = clamp(pix->height, MIN_HEIGHT, MAX_HEIGHT);
722 785
723 v4l2_fill_mbus_format(&format.format, pixfmt, dcmi_fmt->mbus_code); 786 if (dcmi->do_crop && dcmi->num_of_sd_framesizes) {
787 struct dcmi_framesize outer_sd_fsize;
788 /*
789 * If crop is requested and sensor have discrete frame sizes,
790 * select the frame size that is just larger than request
791 */
792 __find_outer_frame_size(dcmi, pix, &outer_sd_fsize);
793 pix->width = outer_sd_fsize.width;
794 pix->height = outer_sd_fsize.height;
795 }
796
797 v4l2_fill_mbus_format(&format.format, pix, sd_fmt->mbus_code);
724 ret = v4l2_subdev_call(dcmi->entity.subdev, pad, set_fmt, 798 ret = v4l2_subdev_call(dcmi->entity.subdev, pad, set_fmt,
725 &pad_cfg, &format); 799 &pad_cfg, &format);
726 if (ret < 0) 800 if (ret < 0)
727 return ret; 801 return ret;
728 802
729 v4l2_fill_pix_format(pixfmt, &format.format); 803 /* Update pix regarding to what sensor can do */
804 v4l2_fill_pix_format(pix, &format.format);
805
806 /* Save resolution that sensor can actually do */
807 sd_fsize.width = pix->width;
808 sd_fsize.height = pix->height;
730 809
731 pixfmt->field = V4L2_FIELD_NONE; 810 if (dcmi->do_crop) {
732 pixfmt->bytesperline = pixfmt->width * dcmi_fmt->bpp; 811 struct v4l2_rect c = dcmi->crop;
733 pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; 812 struct v4l2_rect max_rect;
734 813
735 if (current_fmt) 814 /*
736 *current_fmt = dcmi_fmt; 815 * Adjust crop by making the intersection between
816 * format resolution request and crop request
817 */
818 max_rect.top = 0;
819 max_rect.left = 0;
820 max_rect.width = pix->width;
821 max_rect.height = pix->height;
822 v4l2_rect_map_inside(&c, &max_rect);
823 c.top = clamp_t(s32, c.top, 0, pix->height - c.height);
824 c.left = clamp_t(s32, c.left, 0, pix->width - c.width);
825 dcmi->crop = c;
826
827 /* Adjust format resolution request to crop */
828 pix->width = dcmi->crop.width;
829 pix->height = dcmi->crop.height;
830 }
831
832 pix->field = V4L2_FIELD_NONE;
833 pix->bytesperline = pix->width * sd_fmt->bpp;
834 pix->sizeimage = pix->bytesperline * pix->height;
835
836 if (sd_format)
837 *sd_format = sd_fmt;
838 if (sd_framesize)
839 *sd_framesize = sd_fsize;
737 840
738 return 0; 841 return 0;
739} 842}
@@ -743,22 +846,42 @@ static int dcmi_set_fmt(struct stm32_dcmi *dcmi, struct v4l2_format *f)
743 struct v4l2_subdev_format format = { 846 struct v4l2_subdev_format format = {
744 .which = V4L2_SUBDEV_FORMAT_ACTIVE, 847 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
745 }; 848 };
746 const struct dcmi_format *current_fmt; 849 const struct dcmi_format *sd_format;
850 struct dcmi_framesize sd_framesize;
851 struct v4l2_mbus_framefmt *mf = &format.format;
852 struct v4l2_pix_format *pix = &f->fmt.pix;
747 int ret; 853 int ret;
748 854
749 ret = dcmi_try_fmt(dcmi, f, &current_fmt); 855 /*
856 * Try format, fmt.width/height could have been changed
857 * to match sensor capability or crop request
858 * sd_format & sd_framesize will contain what subdev
859 * can do for this request.
860 */
861 ret = dcmi_try_fmt(dcmi, f, &sd_format, &sd_framesize);
750 if (ret) 862 if (ret)
751 return ret; 863 return ret;
752 864
753 v4l2_fill_mbus_format(&format.format, &f->fmt.pix, 865 /* pix to mbus format */
754 current_fmt->mbus_code); 866 v4l2_fill_mbus_format(mf, pix,
867 sd_format->mbus_code);
868 mf->width = sd_framesize.width;
869 mf->height = sd_framesize.height;
870
755 ret = v4l2_subdev_call(dcmi->entity.subdev, pad, 871 ret = v4l2_subdev_call(dcmi->entity.subdev, pad,
756 set_fmt, NULL, &format); 872 set_fmt, NULL, &format);
757 if (ret < 0) 873 if (ret < 0)
758 return ret; 874 return ret;
759 875
876 dev_dbg(dcmi->dev, "Sensor format set to 0x%x %ux%u\n",
877 mf->code, mf->width, mf->height);
878 dev_dbg(dcmi->dev, "Buffer format set to %4.4s %ux%u\n",
879 (char *)&pix->pixelformat,
880 pix->width, pix->height);
881
760 dcmi->fmt = *f; 882 dcmi->fmt = *f;
761 dcmi->current_fmt = current_fmt; 883 dcmi->sd_format = sd_format;
884 dcmi->sd_framesize = sd_framesize;
762 885
763 return 0; 886 return 0;
764} 887}
@@ -779,7 +902,7 @@ static int dcmi_try_fmt_vid_cap(struct file *file, void *priv,
779{ 902{
780 struct stm32_dcmi *dcmi = video_drvdata(file); 903 struct stm32_dcmi *dcmi = video_drvdata(file);
781 904
782 return dcmi_try_fmt(dcmi, f, NULL); 905 return dcmi_try_fmt(dcmi, f, NULL, NULL);
783} 906}
784 907
785static int dcmi_enum_fmt_vid_cap(struct file *file, void *priv, 908static int dcmi_enum_fmt_vid_cap(struct file *file, void *priv,
@@ -787,10 +910,197 @@ static int dcmi_enum_fmt_vid_cap(struct file *file, void *priv,
787{ 910{
788 struct stm32_dcmi *dcmi = video_drvdata(file); 911 struct stm32_dcmi *dcmi = video_drvdata(file);
789 912
790 if (f->index >= dcmi->num_user_formats) 913 if (f->index >= dcmi->num_of_sd_formats)
791 return -EINVAL; 914 return -EINVAL;
792 915
793 f->pixelformat = dcmi->user_formats[f->index]->fourcc; 916 f->pixelformat = dcmi->sd_formats[f->index]->fourcc;
917 return 0;
918}
919
920static int dcmi_get_sensor_format(struct stm32_dcmi *dcmi,
921 struct v4l2_pix_format *pix)
922{
923 struct v4l2_subdev_format fmt = {
924 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
925 };
926 int ret;
927
928 ret = v4l2_subdev_call(dcmi->entity.subdev, pad, get_fmt, NULL, &fmt);
929 if (ret)
930 return ret;
931
932 v4l2_fill_pix_format(pix, &fmt.format);
933
934 return 0;
935}
936
937static int dcmi_set_sensor_format(struct stm32_dcmi *dcmi,
938 struct v4l2_pix_format *pix)
939{
940 const struct dcmi_format *sd_fmt;
941 struct v4l2_subdev_format format = {
942 .which = V4L2_SUBDEV_FORMAT_TRY,
943 };
944 struct v4l2_subdev_pad_config pad_cfg;
945 int ret;
946
947 sd_fmt = find_format_by_fourcc(dcmi, pix->pixelformat);
948 if (!sd_fmt) {
949 sd_fmt = dcmi->sd_formats[dcmi->num_of_sd_formats - 1];
950 pix->pixelformat = sd_fmt->fourcc;
951 }
952
953 v4l2_fill_mbus_format(&format.format, pix, sd_fmt->mbus_code);
954 ret = v4l2_subdev_call(dcmi->entity.subdev, pad, set_fmt,
955 &pad_cfg, &format);
956 if (ret < 0)
957 return ret;
958
959 return 0;
960}
961
962static int dcmi_get_sensor_bounds(struct stm32_dcmi *dcmi,
963 struct v4l2_rect *r)
964{
965 struct v4l2_subdev_selection bounds = {
966 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
967 .target = V4L2_SEL_TGT_CROP_BOUNDS,
968 };
969 unsigned int max_width, max_height, max_pixsize;
970 struct v4l2_pix_format pix;
971 unsigned int i;
972 int ret;
973
974 /*
975 * Get sensor bounds first
976 */
977 ret = v4l2_subdev_call(dcmi->entity.subdev, pad, get_selection,
978 NULL, &bounds);
979 if (!ret)
980 *r = bounds.r;
981 if (ret != -ENOIOCTLCMD)
982 return ret;
983
984 /*
985 * If selection is not implemented,
986 * fallback by enumerating sensor frame sizes
987 * and take the largest one
988 */
989 max_width = 0;
990 max_height = 0;
991 max_pixsize = 0;
992 for (i = 0; i < dcmi->num_of_sd_framesizes; i++) {
993 struct dcmi_framesize *fsize = &dcmi->sd_framesizes[i];
994 unsigned int pixsize = fsize->width * fsize->height;
995
996 if (pixsize > max_pixsize) {
997 max_pixsize = pixsize;
998 max_width = fsize->width;
999 max_height = fsize->height;
1000 }
1001 }
1002 if (max_pixsize > 0) {
1003 r->top = 0;
1004 r->left = 0;
1005 r->width = max_width;
1006 r->height = max_height;
1007 return 0;
1008 }
1009
1010 /*
1011 * If frame sizes enumeration is not implemented,
1012 * fallback by getting current sensor frame size
1013 */
1014 ret = dcmi_get_sensor_format(dcmi, &pix);
1015 if (ret)
1016 return ret;
1017
1018 r->top = 0;
1019 r->left = 0;
1020 r->width = pix.width;
1021 r->height = pix.height;
1022
1023 return 0;
1024}
1025
1026static int dcmi_g_selection(struct file *file, void *fh,
1027 struct v4l2_selection *s)
1028{
1029 struct stm32_dcmi *dcmi = video_drvdata(file);
1030
1031 if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1032 return -EINVAL;
1033
1034 switch (s->target) {
1035 case V4L2_SEL_TGT_CROP_DEFAULT:
1036 case V4L2_SEL_TGT_CROP_BOUNDS:
1037 s->r = dcmi->sd_bounds;
1038 return 0;
1039 case V4L2_SEL_TGT_CROP:
1040 if (dcmi->do_crop) {
1041 s->r = dcmi->crop;
1042 } else {
1043 s->r.top = 0;
1044 s->r.left = 0;
1045 s->r.width = dcmi->fmt.fmt.pix.width;
1046 s->r.height = dcmi->fmt.fmt.pix.height;
1047 }
1048 break;
1049 default:
1050 return -EINVAL;
1051 }
1052
1053 return 0;
1054}
1055
1056static int dcmi_s_selection(struct file *file, void *priv,
1057 struct v4l2_selection *s)
1058{
1059 struct stm32_dcmi *dcmi = video_drvdata(file);
1060 struct v4l2_rect r = s->r;
1061 struct v4l2_rect max_rect;
1062 struct v4l2_pix_format pix;
1063
1064 if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
1065 s->target != V4L2_SEL_TGT_CROP)
1066 return -EINVAL;
1067
1068 /* Reset sensor resolution to max resolution */
1069 pix.pixelformat = dcmi->fmt.fmt.pix.pixelformat;
1070 pix.width = dcmi->sd_bounds.width;
1071 pix.height = dcmi->sd_bounds.height;
1072 dcmi_set_sensor_format(dcmi, &pix);
1073
1074 /*
1075 * Make the intersection between
1076 * sensor resolution
1077 * and crop request
1078 */
1079 max_rect.top = 0;
1080 max_rect.left = 0;
1081 max_rect.width = pix.width;
1082 max_rect.height = pix.height;
1083 v4l2_rect_map_inside(&r, &max_rect);
1084 r.top = clamp_t(s32, r.top, 0, pix.height - r.height);
1085 r.left = clamp_t(s32, r.left, 0, pix.width - r.width);
1086
1087 if (!((r.top == dcmi->sd_bounds.top) &&
1088 (r.left == dcmi->sd_bounds.left) &&
1089 (r.width == dcmi->sd_bounds.width) &&
1090 (r.height == dcmi->sd_bounds.height))) {
1091 /* Crop if request is different than sensor resolution */
1092 dcmi->do_crop = true;
1093 dcmi->crop = r;
1094 dev_dbg(dcmi->dev, "s_selection: crop %ux%u@(%u,%u) from %ux%u\n",
1095 r.width, r.height, r.left, r.top,
1096 pix.width, pix.height);
1097 } else {
1098 /* Disable crop */
1099 dcmi->do_crop = false;
1100 dev_dbg(dcmi->dev, "s_selection: crop is disabled\n");
1101 }
1102
1103 s->r = r;
794 return 0; 1104 return 0;
795} 1105}
796 1106
@@ -832,18 +1142,18 @@ static int dcmi_enum_framesizes(struct file *file, void *fh,
832 struct v4l2_frmsizeenum *fsize) 1142 struct v4l2_frmsizeenum *fsize)
833{ 1143{
834 struct stm32_dcmi *dcmi = video_drvdata(file); 1144 struct stm32_dcmi *dcmi = video_drvdata(file);
835 const struct dcmi_format *dcmi_fmt; 1145 const struct dcmi_format *sd_fmt;
836 struct v4l2_subdev_frame_size_enum fse = { 1146 struct v4l2_subdev_frame_size_enum fse = {
837 .index = fsize->index, 1147 .index = fsize->index,
838 .which = V4L2_SUBDEV_FORMAT_ACTIVE, 1148 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
839 }; 1149 };
840 int ret; 1150 int ret;
841 1151
842 dcmi_fmt = find_format_by_fourcc(dcmi, fsize->pixel_format); 1152 sd_fmt = find_format_by_fourcc(dcmi, fsize->pixel_format);
843 if (!dcmi_fmt) 1153 if (!sd_fmt)
844 return -EINVAL; 1154 return -EINVAL;
845 1155
846 fse.code = dcmi_fmt->mbus_code; 1156 fse.code = sd_fmt->mbus_code;
847 1157
848 ret = v4l2_subdev_call(dcmi->entity.subdev, pad, enum_frame_size, 1158 ret = v4l2_subdev_call(dcmi->entity.subdev, pad, enum_frame_size,
849 NULL, &fse); 1159 NULL, &fse);
@@ -861,7 +1171,7 @@ static int dcmi_enum_frameintervals(struct file *file, void *fh,
861 struct v4l2_frmivalenum *fival) 1171 struct v4l2_frmivalenum *fival)
862{ 1172{
863 struct stm32_dcmi *dcmi = video_drvdata(file); 1173 struct stm32_dcmi *dcmi = video_drvdata(file);
864 const struct dcmi_format *dcmi_fmt; 1174 const struct dcmi_format *sd_fmt;
865 struct v4l2_subdev_frame_interval_enum fie = { 1175 struct v4l2_subdev_frame_interval_enum fie = {
866 .index = fival->index, 1176 .index = fival->index,
867 .width = fival->width, 1177 .width = fival->width,
@@ -870,11 +1180,11 @@ static int dcmi_enum_frameintervals(struct file *file, void *fh,
870 }; 1180 };
871 int ret; 1181 int ret;
872 1182
873 dcmi_fmt = find_format_by_fourcc(dcmi, fival->pixel_format); 1183 sd_fmt = find_format_by_fourcc(dcmi, fival->pixel_format);
874 if (!dcmi_fmt) 1184 if (!sd_fmt)
875 return -EINVAL; 1185 return -EINVAL;
876 1186
877 fie.code = dcmi_fmt->mbus_code; 1187 fie.code = sd_fmt->mbus_code;
878 1188
879 ret = v4l2_subdev_call(dcmi->entity.subdev, pad, 1189 ret = v4l2_subdev_call(dcmi->entity.subdev, pad,
880 enum_frame_interval, NULL, &fie); 1190 enum_frame_interval, NULL, &fie);
@@ -952,6 +1262,8 @@ static const struct v4l2_ioctl_ops dcmi_ioctl_ops = {
952 .vidioc_g_fmt_vid_cap = dcmi_g_fmt_vid_cap, 1262 .vidioc_g_fmt_vid_cap = dcmi_g_fmt_vid_cap,
953 .vidioc_s_fmt_vid_cap = dcmi_s_fmt_vid_cap, 1263 .vidioc_s_fmt_vid_cap = dcmi_s_fmt_vid_cap,
954 .vidioc_enum_fmt_vid_cap = dcmi_enum_fmt_vid_cap, 1264 .vidioc_enum_fmt_vid_cap = dcmi_enum_fmt_vid_cap,
1265 .vidioc_g_selection = dcmi_g_selection,
1266 .vidioc_s_selection = dcmi_s_selection,
955 1267
956 .vidioc_enum_input = dcmi_enum_input, 1268 .vidioc_enum_input = dcmi_enum_input,
957 .vidioc_g_input = dcmi_g_input, 1269 .vidioc_g_input = dcmi_g_input,
@@ -996,15 +1308,15 @@ static int dcmi_set_default_fmt(struct stm32_dcmi *dcmi)
996 .width = CIF_WIDTH, 1308 .width = CIF_WIDTH,
997 .height = CIF_HEIGHT, 1309 .height = CIF_HEIGHT,
998 .field = V4L2_FIELD_NONE, 1310 .field = V4L2_FIELD_NONE,
999 .pixelformat = dcmi->user_formats[0]->fourcc, 1311 .pixelformat = dcmi->sd_formats[0]->fourcc,
1000 }, 1312 },
1001 }; 1313 };
1002 int ret; 1314 int ret;
1003 1315
1004 ret = dcmi_try_fmt(dcmi, &f, NULL); 1316 ret = dcmi_try_fmt(dcmi, &f, NULL, NULL);
1005 if (ret) 1317 if (ret)
1006 return ret; 1318 return ret;
1007 dcmi->current_fmt = dcmi->user_formats[0]; 1319 dcmi->sd_format = dcmi->sd_formats[0];
1008 dcmi->fmt = f; 1320 dcmi->fmt = f;
1009 return 0; 1321 return 0;
1010} 1322}
@@ -1027,7 +1339,7 @@ static const struct dcmi_format dcmi_formats[] = {
1027 1339
1028static int dcmi_formats_init(struct stm32_dcmi *dcmi) 1340static int dcmi_formats_init(struct stm32_dcmi *dcmi)
1029{ 1341{
1030 const struct dcmi_format *dcmi_fmts[ARRAY_SIZE(dcmi_formats)]; 1342 const struct dcmi_format *sd_fmts[ARRAY_SIZE(dcmi_formats)];
1031 unsigned int num_fmts = 0, i, j; 1343 unsigned int num_fmts = 0, i, j;
1032 struct v4l2_subdev *subdev = dcmi->entity.subdev; 1344 struct v4l2_subdev *subdev = dcmi->entity.subdev;
1033 struct v4l2_subdev_mbus_code_enum mbus_code = { 1345 struct v4l2_subdev_mbus_code_enum mbus_code = {
@@ -1042,13 +1354,13 @@ static int dcmi_formats_init(struct stm32_dcmi *dcmi)
1042 1354
1043 /* Code supported, have we got this fourcc yet? */ 1355 /* Code supported, have we got this fourcc yet? */
1044 for (j = 0; j < num_fmts; j++) 1356 for (j = 0; j < num_fmts; j++)
1045 if (dcmi_fmts[j]->fourcc == 1357 if (sd_fmts[j]->fourcc ==
1046 dcmi_formats[i].fourcc) 1358 dcmi_formats[i].fourcc)
1047 /* Already available */ 1359 /* Already available */
1048 break; 1360 break;
1049 if (j == num_fmts) 1361 if (j == num_fmts)
1050 /* New */ 1362 /* New */
1051 dcmi_fmts[num_fmts++] = dcmi_formats + i; 1363 sd_fmts[num_fmts++] = dcmi_formats + i;
1052 } 1364 }
1053 mbus_code.index++; 1365 mbus_code.index++;
1054 } 1366 }
@@ -1056,18 +1368,63 @@ static int dcmi_formats_init(struct stm32_dcmi *dcmi)
1056 if (!num_fmts) 1368 if (!num_fmts)
1057 return -ENXIO; 1369 return -ENXIO;
1058 1370
1059 dcmi->num_user_formats = num_fmts; 1371 dcmi->num_of_sd_formats = num_fmts;
1060 dcmi->user_formats = devm_kcalloc(dcmi->dev, 1372 dcmi->sd_formats = devm_kcalloc(dcmi->dev,
1061 num_fmts, sizeof(struct dcmi_format *), 1373 num_fmts, sizeof(struct dcmi_format *),
1062 GFP_KERNEL); 1374 GFP_KERNEL);
1063 if (!dcmi->user_formats) { 1375 if (!dcmi->sd_formats) {
1064 dev_err(dcmi->dev, "could not allocate memory\n"); 1376 dev_err(dcmi->dev, "Could not allocate memory\n");
1065 return -ENOMEM; 1377 return -ENOMEM;
1066 } 1378 }
1067 1379
1068 memcpy(dcmi->user_formats, dcmi_fmts, 1380 memcpy(dcmi->sd_formats, sd_fmts,
1069 num_fmts * sizeof(struct dcmi_format *)); 1381 num_fmts * sizeof(struct dcmi_format *));
1070 dcmi->current_fmt = dcmi->user_formats[0]; 1382 dcmi->sd_format = dcmi->sd_formats[0];
1383
1384 return 0;
1385}
1386
1387static int dcmi_framesizes_init(struct stm32_dcmi *dcmi)
1388{
1389 unsigned int num_fsize = 0;
1390 struct v4l2_subdev *subdev = dcmi->entity.subdev;
1391 struct v4l2_subdev_frame_size_enum fse = {
1392 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
1393 .code = dcmi->sd_format->mbus_code,
1394 };
1395 unsigned int ret;
1396 unsigned int i;
1397
1398 /* Allocate discrete framesizes array */
1399 while (!v4l2_subdev_call(subdev, pad, enum_frame_size,
1400 NULL, &fse))
1401 fse.index++;
1402
1403 num_fsize = fse.index;
1404 if (!num_fsize)
1405 return 0;
1406
1407 dcmi->num_of_sd_framesizes = num_fsize;
1408 dcmi->sd_framesizes = devm_kcalloc(dcmi->dev, num_fsize,
1409 sizeof(struct dcmi_framesize),
1410 GFP_KERNEL);
1411 if (!dcmi->sd_framesizes) {
1412 dev_err(dcmi->dev, "Could not allocate memory\n");
1413 return -ENOMEM;
1414 }
1415
1416 /* Fill array with sensor supported framesizes */
1417 dev_dbg(dcmi->dev, "Sensor supports %u frame sizes:\n", num_fsize);
1418 for (i = 0; i < dcmi->num_of_sd_framesizes; i++) {
1419 fse.index = i;
1420 ret = v4l2_subdev_call(subdev, pad, enum_frame_size,
1421 NULL, &fse);
1422 if (ret)
1423 return ret;
1424 dcmi->sd_framesizes[fse.index].width = fse.max_width;
1425 dcmi->sd_framesizes[fse.index].height = fse.max_height;
1426 dev_dbg(dcmi->dev, "%ux%u\n", fse.max_width, fse.max_height);
1427 }
1071 1428
1072 return 0; 1429 return 0;
1073} 1430}
@@ -1084,6 +1441,18 @@ static int dcmi_graph_notify_complete(struct v4l2_async_notifier *notifier)
1084 return ret; 1441 return ret;
1085 } 1442 }
1086 1443
1444 ret = dcmi_framesizes_init(dcmi);
1445 if (ret) {
1446 dev_err(dcmi->dev, "Could not initialize framesizes\n");
1447 return ret;
1448 }
1449
1450 ret = dcmi_get_sensor_bounds(dcmi, &dcmi->sd_bounds);
1451 if (ret) {
1452 dev_err(dcmi->dev, "Could not get sensor bounds\n");
1453 return ret;
1454 }
1455
1087 ret = dcmi_set_default_fmt(dcmi); 1456 ret = dcmi_set_default_fmt(dcmi);
1088 if (ret) { 1457 if (ret) {
1089 dev_err(dcmi->dev, "Could not set default format\n"); 1458 dev_err(dcmi->dev, "Could not set default format\n");
@@ -1209,7 +1578,7 @@ static int dcmi_probe(struct platform_device *pdev)
1209 if (!dcmi) 1578 if (!dcmi)
1210 return -ENOMEM; 1579 return -ENOMEM;
1211 1580
1212 dcmi->rstc = devm_reset_control_get(&pdev->dev, NULL); 1581 dcmi->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
1213 if (IS_ERR(dcmi->rstc)) { 1582 if (IS_ERR(dcmi->rstc)) {
1214 dev_err(&pdev->dev, "Could not get reset control\n"); 1583 dev_err(&pdev->dev, "Could not get reset control\n");
1215 return -ENODEV; 1584 return -ENODEV;
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 177faa36bc16..42e383a48ffe 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -1420,7 +1420,7 @@ static const struct v4l2_ioctl_ops cal_ioctl_ops = {
1420 .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 1420 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1421}; 1421};
1422 1422
1423static struct video_device cal_videodev = { 1423static const struct video_device cal_videodev = {
1424 .name = CAL_MODULE_NAME, 1424 .name = CAL_MODULE_NAME,
1425 .fops = &cal_fops, 1425 .fops = &cal_fops,
1426 .ioctl_ops = &cal_ioctl_ops, 1426 .ioctl_ops = &cal_ioctl_ops,
@@ -1702,7 +1702,7 @@ static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
1702 asd->match_type = V4L2_ASYNC_MATCH_FWNODE; 1702 asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
1703 asd->match.fwnode.fwnode = of_fwnode_handle(sensor_node); 1703 asd->match.fwnode.fwnode = of_fwnode_handle(sensor_node);
1704 1704
1705 remote_ep = of_parse_phandle(ep_node, "remote-endpoint", 0); 1705 remote_ep = of_graph_get_remote_endpoint(ep_node);
1706 if (!remote_ep) { 1706 if (!remote_ep) {
1707 ctx_dbg(3, ctx, "can't get remote-endpoint\n"); 1707 ctx_dbg(3, ctx, "can't get remote-endpoint\n");
1708 goto cleanup_exit; 1708 goto cleanup_exit;
diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
index c47151495b6f..45bd10544189 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -2421,7 +2421,7 @@ static const struct v4l2_file_operations vpe_fops = {
2421 .mmap = v4l2_m2m_fop_mmap, 2421 .mmap = v4l2_m2m_fop_mmap,
2422}; 2422};
2423 2423
2424static struct video_device vpe_videodev = { 2424static const struct video_device vpe_videodev = {
2425 .name = VPE_MODULE_NAME, 2425 .name = VPE_MODULE_NAME,
2426 .fops = &vpe_fops, 2426 .fops = &vpe_fops,
2427 .ioctl_ops = &vpe_ioctl_ops, 2427 .ioctl_ops = &vpe_ioctl_ops,
@@ -2430,7 +2430,7 @@ static struct video_device vpe_videodev = {
2430 .vfl_dir = VFL_DIR_M2M, 2430 .vfl_dir = VFL_DIR_M2M,
2431}; 2431};
2432 2432
2433static struct v4l2_m2m_ops m2m_ops = { 2433static const struct v4l2_m2m_ops m2m_ops = {
2434 .device_run = device_run, 2434 .device_run = device_run,
2435 .job_ready = job_ready, 2435 .job_ready = job_ready,
2436 .job_abort = job_abort, 2436 .job_abort = job_abort,
diff --git a/drivers/media/platform/via-camera.c b/drivers/media/platform/via-camera.c
index e16f70a5df1d..805d4a8fc17e 100644
--- a/drivers/media/platform/via-camera.c
+++ b/drivers/media/platform/via-camera.c
@@ -1259,7 +1259,7 @@ static struct viafb_pm_hooks viacam_pm_hooks = {
1259 * Setup stuff. 1259 * Setup stuff.
1260 */ 1260 */
1261 1261
1262static struct video_device viacam_v4l_template = { 1262static const struct video_device viacam_v4l_template = {
1263 .name = "via-camera", 1263 .name = "via-camera",
1264 .minor = -1, 1264 .minor = -1,
1265 .tvnorms = V4L2_STD_NTSC_M, 1265 .tvnorms = V4L2_STD_NTSC_M,
diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c
index 665744716f73..ee89ad76bee2 100644
--- a/drivers/media/platform/video-mux.c
+++ b/drivers/media/platform/video-mux.c
@@ -17,8 +17,7 @@
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/mutex.h> 19#include <linux/mutex.h>
20#include <linux/regmap.h> 20#include <linux/mux/consumer.h>
21#include <linux/mfd/syscon.h>
22#include <linux/of.h> 21#include <linux/of.h>
23#include <linux/of_graph.h> 22#include <linux/of_graph.h>
24#include <linux/platform_device.h> 23#include <linux/platform_device.h>
@@ -30,7 +29,7 @@ struct video_mux {
30 struct v4l2_subdev subdev; 29 struct v4l2_subdev subdev;
31 struct media_pad *pads; 30 struct media_pad *pads;
32 struct v4l2_mbus_framefmt *format_mbus; 31 struct v4l2_mbus_framefmt *format_mbus;
33 struct regmap_field *field; 32 struct mux_control *mux;
34 struct mutex lock; 33 struct mutex lock;
35 int active; 34 int active;
36}; 35};
@@ -71,7 +70,7 @@ static int video_mux_link_setup(struct media_entity *entity,
71 } 70 }
72 71
73 dev_dbg(sd->dev, "setting %d active\n", local->index); 72 dev_dbg(sd->dev, "setting %d active\n", local->index);
74 ret = regmap_field_write(vmux->field, local->index); 73 ret = mux_control_try_select(vmux->mux, local->index);
75 if (ret < 0) 74 if (ret < 0)
76 goto out; 75 goto out;
77 vmux->active = local->index; 76 vmux->active = local->index;
@@ -80,6 +79,7 @@ static int video_mux_link_setup(struct media_entity *entity,
80 goto out; 79 goto out;
81 80
82 dev_dbg(sd->dev, "going inactive\n"); 81 dev_dbg(sd->dev, "going inactive\n");
82 mux_control_deselect(vmux->mux);
83 vmux->active = -1; 83 vmux->active = -1;
84 } 84 }
85 85
@@ -193,46 +193,6 @@ static const struct v4l2_subdev_ops video_mux_subdev_ops = {
193 .video = &video_mux_subdev_video_ops, 193 .video = &video_mux_subdev_video_ops,
194}; 194};
195 195
196static int video_mux_probe_mmio_mux(struct video_mux *vmux)
197{
198 struct device *dev = vmux->subdev.dev;
199 struct of_phandle_args args;
200 struct reg_field field;
201 struct regmap *regmap;
202 u32 reg, mask;
203 int ret;
204
205 ret = of_parse_phandle_with_args(dev->of_node, "mux-controls",
206 "#mux-control-cells", 0, &args);
207 if (ret)
208 return ret;
209
210 if (!of_device_is_compatible(args.np, "mmio-mux"))
211 return -EINVAL;
212
213 regmap = syscon_node_to_regmap(args.np->parent);
214 if (IS_ERR(regmap))
215 return PTR_ERR(regmap);
216
217 ret = of_property_read_u32_index(args.np, "mux-reg-masks",
218 2 * args.args[0], &reg);
219 if (!ret)
220 ret = of_property_read_u32_index(args.np, "mux-reg-masks",
221 2 * args.args[0] + 1, &mask);
222 if (ret < 0)
223 return ret;
224
225 field.reg = reg;
226 field.msb = fls(mask) - 1;
227 field.lsb = ffs(mask) - 1;
228
229 vmux->field = devm_regmap_field_alloc(dev, regmap, field);
230 if (IS_ERR(vmux->field))
231 return PTR_ERR(vmux->field);
232
233 return 0;
234}
235
236static int video_mux_probe(struct platform_device *pdev) 196static int video_mux_probe(struct platform_device *pdev)
237{ 197{
238 struct device_node *np = pdev->dev.of_node; 198 struct device_node *np = pdev->dev.of_node;
@@ -270,8 +230,9 @@ static int video_mux_probe(struct platform_device *pdev)
270 return -EINVAL; 230 return -EINVAL;
271 } 231 }
272 232
273 ret = video_mux_probe_mmio_mux(vmux); 233 vmux->mux = devm_mux_control_get(dev, NULL);
274 if (ret) { 234 if (IS_ERR(vmux->mux)) {
235 ret = PTR_ERR(vmux->mux);
275 if (ret != -EPROBE_DEFER) 236 if (ret != -EPROBE_DEFER)
276 dev_err(dev, "Failed to get mux: %d\n", ret); 237 dev_err(dev, "Failed to get mux: %d\n", ret);
277 return ret; 238 return ret;
diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
index 970b9b6dab25..b01fba020d5f 100644
--- a/drivers/media/platform/vim2m.c
+++ b/drivers/media/platform/vim2m.c
@@ -974,7 +974,7 @@ static const struct v4l2_file_operations vim2m_fops = {
974 .mmap = v4l2_m2m_fop_mmap, 974 .mmap = v4l2_m2m_fop_mmap,
975}; 975};
976 976
977static struct video_device vim2m_videodev = { 977static const struct video_device vim2m_videodev = {
978 .name = MEM2MEM_NAME, 978 .name = MEM2MEM_NAME,
979 .vfl_dir = VFL_DIR_M2M, 979 .vfl_dir = VFL_DIR_M2M,
980 .fops = &vim2m_fops, 980 .fops = &vim2m_fops,
@@ -983,7 +983,7 @@ static struct video_device vim2m_videodev = {
983 .release = video_device_release_empty, 983 .release = video_device_release_empty,
984}; 984};
985 985
986static struct v4l2_m2m_ops m2m_ops = { 986static const struct v4l2_m2m_ops m2m_ops = {
987 .device_run = device_run, 987 .device_run = device_run,
988 .job_ready = job_ready, 988 .job_ready = job_ready,
989 .job_abort = job_abort, 989 .job_abort = job_abort,
diff --git a/drivers/media/platform/vimc/vimc-debayer.c b/drivers/media/platform/vimc/vimc-debayer.c
index 033a131f67af..4d663e89d33f 100644
--- a/drivers/media/platform/vimc/vimc-debayer.c
+++ b/drivers/media/platform/vimc/vimc-debayer.c
@@ -373,7 +373,7 @@ static int vimc_deb_s_stream(struct v4l2_subdev *sd, int enable)
373 return 0; 373 return 0;
374} 374}
375 375
376static struct v4l2_subdev_video_ops vimc_deb_video_ops = { 376static const struct v4l2_subdev_video_ops vimc_deb_video_ops = {
377 .s_stream = vimc_deb_s_stream, 377 .s_stream = vimc_deb_s_stream,
378}; 378};
379 379
diff --git a/drivers/media/platform/vimc/vimc-scaler.c b/drivers/media/platform/vimc/vimc-scaler.c
index 0a3e086e12f3..e1602e0bc230 100644
--- a/drivers/media/platform/vimc/vimc-scaler.c
+++ b/drivers/media/platform/vimc/vimc-scaler.c
@@ -267,7 +267,7 @@ static int vimc_sca_s_stream(struct v4l2_subdev *sd, int enable)
267 return 0; 267 return 0;
268} 268}
269 269
270static struct v4l2_subdev_video_ops vimc_sca_video_ops = { 270static const struct v4l2_subdev_video_ops vimc_sca_video_ops = {
271 .s_stream = vimc_sca_s_stream, 271 .s_stream = vimc_sca_s_stream,
272}; 272};
273 273
diff --git a/drivers/media/platform/vimc/vimc-sensor.c b/drivers/media/platform/vimc/vimc-sensor.c
index 615c2b18dcfc..02e68c8fc02b 100644
--- a/drivers/media/platform/vimc/vimc-sensor.c
+++ b/drivers/media/platform/vimc/vimc-sensor.c
@@ -282,7 +282,7 @@ static int vimc_sen_s_stream(struct v4l2_subdev *sd, int enable)
282 return 0; 282 return 0;
283} 283}
284 284
285static struct v4l2_subdev_video_ops vimc_sen_video_ops = { 285static const struct v4l2_subdev_video_ops vimc_sen_video_ops = {
286 .s_stream = vimc_sen_s_stream, 286 .s_stream = vimc_sen_s_stream,
287}; 287};
288 288
diff --git a/drivers/media/platform/vivid/vivid-cec.c b/drivers/media/platform/vivid/vivid-cec.c
index e15705758969..b55d278d38a7 100644
--- a/drivers/media/platform/vivid/vivid-cec.c
+++ b/drivers/media/platform/vivid/vivid-cec.c
@@ -22,6 +22,15 @@
22#include "vivid-core.h" 22#include "vivid-core.h"
23#include "vivid-cec.h" 23#include "vivid-cec.h"
24 24
25#define CEC_TIM_START_BIT_TOTAL 4500
26#define CEC_TIM_START_BIT_LOW 3700
27#define CEC_TIM_START_BIT_HIGH 800
28#define CEC_TIM_DATA_BIT_TOTAL 2400
29#define CEC_TIM_DATA_BIT_0_LOW 1500
30#define CEC_TIM_DATA_BIT_0_HIGH 900
31#define CEC_TIM_DATA_BIT_1_LOW 600
32#define CEC_TIM_DATA_BIT_1_HIGH 1800
33
25void vivid_cec_bus_free_work(struct vivid_dev *dev) 34void vivid_cec_bus_free_work(struct vivid_dev *dev)
26{ 35{
27 spin_lock(&dev->cec_slock); 36 spin_lock(&dev->cec_slock);
@@ -64,6 +73,58 @@ static bool vivid_cec_find_dest_adap(struct vivid_dev *dev,
64 return false; 73 return false;
65} 74}
66 75
76static void vivid_cec_pin_adap_events(struct cec_adapter *adap, ktime_t ts,
77 const struct cec_msg *msg, bool nacked)
78{
79 unsigned int len = nacked ? 1 : msg->len;
80 unsigned int i;
81 bool bit;
82
83 if (adap == NULL)
84 return;
85 ts = ktime_sub_us(ts, (CEC_TIM_START_BIT_TOTAL +
86 len * 10 * CEC_TIM_DATA_BIT_TOTAL));
87 cec_queue_pin_cec_event(adap, false, ts);
88 ts = ktime_add_us(ts, CEC_TIM_START_BIT_LOW);
89 cec_queue_pin_cec_event(adap, true, ts);
90 ts = ktime_add_us(ts, CEC_TIM_START_BIT_HIGH);
91
92 for (i = 0; i < 10 * len; i++) {
93 switch (i % 10) {
94 case 0 ... 7:
95 bit = msg->msg[i / 10] & (0x80 >> (i % 10));
96 break;
97 case 8: /* EOM */
98 bit = i / 10 == msg->len - 1;
99 break;
100 case 9: /* ACK */
101 bit = cec_msg_is_broadcast(msg) ^ nacked;
102 break;
103 }
104 cec_queue_pin_cec_event(adap, false, ts);
105 if (bit)
106 ts = ktime_add_us(ts, CEC_TIM_DATA_BIT_1_LOW);
107 else
108 ts = ktime_add_us(ts, CEC_TIM_DATA_BIT_0_LOW);
109 cec_queue_pin_cec_event(adap, true, ts);
110 if (bit)
111 ts = ktime_add_us(ts, CEC_TIM_DATA_BIT_1_HIGH);
112 else
113 ts = ktime_add_us(ts, CEC_TIM_DATA_BIT_0_HIGH);
114 }
115}
116
117static void vivid_cec_pin_events(struct vivid_dev *dev,
118 const struct cec_msg *msg, bool nacked)
119{
120 ktime_t ts = ktime_get();
121 unsigned int i;
122
123 vivid_cec_pin_adap_events(dev->cec_rx_adap, ts, msg, nacked);
124 for (i = 0; i < MAX_OUTPUTS; i++)
125 vivid_cec_pin_adap_events(dev->cec_tx_adap[i], ts, msg, nacked);
126}
127
67static void vivid_cec_xfer_done_worker(struct work_struct *work) 128static void vivid_cec_xfer_done_worker(struct work_struct *work)
68{ 129{
69 struct vivid_cec_work *cw = 130 struct vivid_cec_work *cw =
@@ -84,6 +145,7 @@ static void vivid_cec_xfer_done_worker(struct work_struct *work)
84 dev->cec_xfer_start_jiffies = 0; 145 dev->cec_xfer_start_jiffies = 0;
85 list_del(&cw->list); 146 list_del(&cw->list);
86 spin_unlock(&dev->cec_slock); 147 spin_unlock(&dev->cec_slock);
148 vivid_cec_pin_events(dev, &cw->msg, !valid_dest);
87 cec_transmit_attempt_done(cw->adap, cw->tx_status); 149 cec_transmit_attempt_done(cw->adap, cw->tx_status);
88 150
89 /* Broadcast message */ 151 /* Broadcast message */
@@ -118,6 +180,7 @@ static void vivid_cec_xfer_try_worker(struct work_struct *work)
118 180
119static int vivid_cec_adap_enable(struct cec_adapter *adap, bool enable) 181static int vivid_cec_adap_enable(struct cec_adapter *adap, bool enable)
120{ 182{
183 adap->cec_pin_is_high = true;
121 return 0; 184 return 0;
122} 185}
123 186
@@ -219,8 +282,7 @@ struct cec_adapter *vivid_cec_alloc_adap(struct vivid_dev *dev,
219 bool is_source) 282 bool is_source)
220{ 283{
221 char name[sizeof(dev->vid_out_dev.name) + 2]; 284 char name[sizeof(dev->vid_out_dev.name) + 2];
222 u32 caps = CEC_CAP_TRANSMIT | CEC_CAP_LOG_ADDRS | 285 u32 caps = CEC_CAP_DEFAULTS | CEC_CAP_MONITOR_ALL | CEC_CAP_MONITOR_PIN;
223 CEC_CAP_PASSTHROUGH | CEC_CAP_RC | CEC_CAP_MONITOR_ALL;
224 286
225 snprintf(name, sizeof(name), "%s%d", 287 snprintf(name, sizeof(name), "%s%d",
226 is_source ? dev->vid_out_dev.name : dev->vid_cap_dev.name, 288 is_source ? dev->vid_out_dev.name : dev->vid_cap_dev.name,
diff --git a/drivers/media/platform/vivid/vivid-core.c b/drivers/media/platform/vivid/vivid-core.c
index ef344b9a48af..5f316a5e38db 100644
--- a/drivers/media/platform/vivid/vivid-core.c
+++ b/drivers/media/platform/vivid/vivid-core.c
@@ -1201,8 +1201,8 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
1201 goto unreg_dev; 1201 goto unreg_dev;
1202 } 1202 }
1203 cec_s_phys_addr(adap, 0, false); 1203 cec_s_phys_addr(adap, 0, false);
1204 v4l2_info(&dev->v4l2_dev, "CEC adapter %s registered for HDMI input %d\n", 1204 v4l2_info(&dev->v4l2_dev, "CEC adapter %s registered for HDMI input 0\n",
1205 dev_name(&adap->devnode.dev), i); 1205 dev_name(&adap->devnode.dev));
1206 } 1206 }
1207#endif 1207#endif
1208 1208
@@ -1255,13 +1255,13 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
1255 dev->cec_tx_adap[bus_cnt] = NULL; 1255 dev->cec_tx_adap[bus_cnt] = NULL;
1256 goto unreg_dev; 1256 goto unreg_dev;
1257 } 1257 }
1258 v4l2_info(&dev->v4l2_dev, "CEC adapter %s registered for HDMI output %d\n",
1259 dev_name(&adap->devnode.dev), bus_cnt);
1258 bus_cnt++; 1260 bus_cnt++;
1259 if (bus_cnt <= out_type_counter[HDMI]) 1261 if (bus_cnt <= out_type_counter[HDMI])
1260 cec_s_phys_addr(adap, bus_cnt << 12, false); 1262 cec_s_phys_addr(adap, bus_cnt << 12, false);
1261 else 1263 else
1262 cec_s_phys_addr(adap, 0x1000, false); 1264 cec_s_phys_addr(adap, 0x1000, false);
1263 v4l2_info(&dev->v4l2_dev, "CEC adapter %s registered for HDMI output %d\n",
1264 dev_name(&adap->devnode.dev), i);
1265 } 1265 }
1266#endif 1266#endif
1267 1267
diff --git a/drivers/media/platform/vsp1/vsp1_entity.h b/drivers/media/platform/vsp1/vsp1_entity.h
index 11f8363fa6b0..408602ebeb97 100644
--- a/drivers/media/platform/vsp1/vsp1_entity.h
+++ b/drivers/media/platform/vsp1/vsp1_entity.h
@@ -21,6 +21,8 @@
21struct vsp1_device; 21struct vsp1_device;
22struct vsp1_dl_list; 22struct vsp1_dl_list;
23struct vsp1_pipeline; 23struct vsp1_pipeline;
24struct vsp1_partition;
25struct vsp1_partition_window;
24 26
25enum vsp1_entity_type { 27enum vsp1_entity_type {
26 VSP1_ENTITY_BRS, 28 VSP1_ENTITY_BRS,
@@ -82,12 +84,17 @@ struct vsp1_route {
82 * selection rectangles, ...) 84 * selection rectangles, ...)
83 * @max_width: Return the max supported width of data that the entity can 85 * @max_width: Return the max supported width of data that the entity can
84 * process in a single operation. 86 * process in a single operation.
87 * @partition: Process the partition construction based on this entity's
88 * configuration.
85 */ 89 */
86struct vsp1_entity_operations { 90struct vsp1_entity_operations {
87 void (*destroy)(struct vsp1_entity *); 91 void (*destroy)(struct vsp1_entity *);
88 void (*configure)(struct vsp1_entity *, struct vsp1_pipeline *, 92 void (*configure)(struct vsp1_entity *, struct vsp1_pipeline *,
89 struct vsp1_dl_list *, enum vsp1_entity_params); 93 struct vsp1_dl_list *, enum vsp1_entity_params);
90 unsigned int (*max_width)(struct vsp1_entity *, struct vsp1_pipeline *); 94 unsigned int (*max_width)(struct vsp1_entity *, struct vsp1_pipeline *);
95 void (*partition)(struct vsp1_entity *, struct vsp1_pipeline *,
96 struct vsp1_partition *, unsigned int,
97 struct vsp1_partition_window *);
91}; 98};
92 99
93struct vsp1_entity { 100struct vsp1_entity {
diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c b/drivers/media/platform/vsp1/vsp1_pipe.c
index 4f4b732df84b..44944ac86d9b 100644
--- a/drivers/media/platform/vsp1/vsp1_pipe.c
+++ b/drivers/media/platform/vsp1/vsp1_pipe.c
@@ -383,6 +383,28 @@ void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
383 vsp1_uds_set_alpha(pipe->uds, dl, alpha); 383 vsp1_uds_set_alpha(pipe->uds, dl, alpha);
384} 384}
385 385
386/*
387 * Propagate the partition calculations through the pipeline
388 *
389 * Work backwards through the pipe, allowing each entity to update the partition
390 * parameters based on its configuration, and the entity connected to its
391 * source. Each entity must produce the partition required for the previous
392 * entity in the pipeline.
393 */
394void vsp1_pipeline_propagate_partition(struct vsp1_pipeline *pipe,
395 struct vsp1_partition *partition,
396 unsigned int index,
397 struct vsp1_partition_window *window)
398{
399 struct vsp1_entity *entity;
400
401 list_for_each_entry_reverse(entity, &pipe->entities, list_pipe) {
402 if (entity->ops->partition)
403 entity->ops->partition(entity, pipe, partition, index,
404 window);
405 }
406}
407
386void vsp1_pipelines_suspend(struct vsp1_device *vsp1) 408void vsp1_pipelines_suspend(struct vsp1_device *vsp1)
387{ 409{
388 unsigned long flags; 410 unsigned long flags;
diff --git a/drivers/media/platform/vsp1/vsp1_pipe.h b/drivers/media/platform/vsp1/vsp1_pipe.h
index c5d01a365370..dfff9b5685fe 100644
--- a/drivers/media/platform/vsp1/vsp1_pipe.h
+++ b/drivers/media/platform/vsp1/vsp1_pipe.h
@@ -58,6 +58,33 @@ enum vsp1_pipeline_state {
58}; 58};
59 59
60/* 60/*
61 * struct vsp1_partition_window - Partition window coordinates
62 * @left: horizontal coordinate of the partition start in pixels relative to the
63 * left edge of the image
64 * @width: partition width in pixels
65 */
66struct vsp1_partition_window {
67 unsigned int left;
68 unsigned int width;
69};
70
71/*
72 * struct vsp1_partition - A description of a slice for the partition algorithm
73 * @rpf: The RPF partition window configuration
74 * @uds_sink: The UDS input partition window configuration
75 * @uds_source: The UDS output partition window configuration
76 * @sru: The SRU partition window configuration
77 * @wpf: The WPF partition window configuration
78 */
79struct vsp1_partition {
80 struct vsp1_partition_window rpf;
81 struct vsp1_partition_window uds_sink;
82 struct vsp1_partition_window uds_source;
83 struct vsp1_partition_window sru;
84 struct vsp1_partition_window wpf;
85};
86
87/*
61 * struct vsp1_pipeline - A VSP1 hardware pipeline 88 * struct vsp1_pipeline - A VSP1 hardware pipeline
62 * @pipe: the media pipeline 89 * @pipe: the media pipeline
63 * @irqlock: protects the pipeline state 90 * @irqlock: protects the pipeline state
@@ -80,9 +107,9 @@ enum vsp1_pipeline_state {
80 * @uds_input: entity at the input of the UDS, if the UDS is present 107 * @uds_input: entity at the input of the UDS, if the UDS is present
81 * @entities: list of entities in the pipeline 108 * @entities: list of entities in the pipeline
82 * @dl: display list associated with the pipeline 109 * @dl: display list associated with the pipeline
83 * @div_size: The maximum allowed partition size for the pipeline
84 * @partitions: The number of partitions used to process one frame 110 * @partitions: The number of partitions used to process one frame
85 * @current_partition: The partition number currently being configured 111 * @partition: The current partition for configuration to process
112 * @part_table: The pre-calculated partitions used by the pipeline
86 */ 113 */
87struct vsp1_pipeline { 114struct vsp1_pipeline {
88 struct media_pipeline pipe; 115 struct media_pipeline pipe;
@@ -109,14 +136,18 @@ struct vsp1_pipeline {
109 struct vsp1_entity *uds; 136 struct vsp1_entity *uds;
110 struct vsp1_entity *uds_input; 137 struct vsp1_entity *uds_input;
111 138
139 /*
140 * The order of this list must be identical to the order of the entities
141 * in the pipeline, as it is assumed by the partition algorithm that we
142 * can walk this list in sequence.
143 */
112 struct list_head entities; 144 struct list_head entities;
113 145
114 struct vsp1_dl_list *dl; 146 struct vsp1_dl_list *dl;
115 147
116 unsigned int div_size;
117 unsigned int partitions; 148 unsigned int partitions;
118 struct v4l2_rect partition; 149 struct vsp1_partition *partition;
119 unsigned int current_partition; 150 struct vsp1_partition *part_table;
120}; 151};
121 152
122void vsp1_pipeline_reset(struct vsp1_pipeline *pipe); 153void vsp1_pipeline_reset(struct vsp1_pipeline *pipe);
@@ -132,6 +163,11 @@ void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
132void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe, 163void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
133 struct vsp1_dl_list *dl, unsigned int alpha); 164 struct vsp1_dl_list *dl, unsigned int alpha);
134 165
166void vsp1_pipeline_propagate_partition(struct vsp1_pipeline *pipe,
167 struct vsp1_partition *partition,
168 unsigned int index,
169 struct vsp1_partition_window *window);
170
135void vsp1_pipelines_suspend(struct vsp1_device *vsp1); 171void vsp1_pipelines_suspend(struct vsp1_device *vsp1);
136void vsp1_pipelines_resume(struct vsp1_device *vsp1); 172void vsp1_pipelines_resume(struct vsp1_device *vsp1);
137 173
diff --git a/drivers/media/platform/vsp1/vsp1_regs.h b/drivers/media/platform/vsp1/vsp1_regs.h
index 58d0bea963a6..26c4ffad2f46 100644
--- a/drivers/media/platform/vsp1/vsp1_regs.h
+++ b/drivers/media/platform/vsp1/vsp1_regs.h
@@ -396,6 +396,7 @@
396#define VI6_UDS_CTRL_NE_RCR (1 << 18) 396#define VI6_UDS_CTRL_NE_RCR (1 << 18)
397#define VI6_UDS_CTRL_NE_GY (1 << 17) 397#define VI6_UDS_CTRL_NE_GY (1 << 17)
398#define VI6_UDS_CTRL_NE_BCB (1 << 16) 398#define VI6_UDS_CTRL_NE_BCB (1 << 16)
399#define VI6_UDS_CTRL_AMDSLH (1 << 2)
399#define VI6_UDS_CTRL_TDIPC (1 << 1) 400#define VI6_UDS_CTRL_TDIPC (1 << 1)
400 401
401#define VI6_UDS_SCALE 0x2304 402#define VI6_UDS_SCALE 0x2304
@@ -428,11 +429,24 @@
428#define VI6_UDS_PASS_BWIDTH_V_MASK (0x7f << 0) 429#define VI6_UDS_PASS_BWIDTH_V_MASK (0x7f << 0)
429#define VI6_UDS_PASS_BWIDTH_V_SHIFT 0 430#define VI6_UDS_PASS_BWIDTH_V_SHIFT 0
430 431
432#define VI6_UDS_HPHASE 0x2314
433#define VI6_UDS_HPHASE_HSTP_MASK (0xfff << 16)
434#define VI6_UDS_HPHASE_HSTP_SHIFT 16
435#define VI6_UDS_HPHASE_HEDP_MASK (0xfff << 0)
436#define VI6_UDS_HPHASE_HEDP_SHIFT 0
437
431#define VI6_UDS_IPC 0x2318 438#define VI6_UDS_IPC 0x2318
432#define VI6_UDS_IPC_FIELD (1 << 27) 439#define VI6_UDS_IPC_FIELD (1 << 27)
433#define VI6_UDS_IPC_VEDP_MASK (0xfff << 0) 440#define VI6_UDS_IPC_VEDP_MASK (0xfff << 0)
434#define VI6_UDS_IPC_VEDP_SHIFT 0 441#define VI6_UDS_IPC_VEDP_SHIFT 0
435 442
443#define VI6_UDS_HSZCLIP 0x231c
444#define VI6_UDS_HSZCLIP_HCEN (1 << 28)
445#define VI6_UDS_HSZCLIP_HCL_OFST_MASK (0xff << 16)
446#define VI6_UDS_HSZCLIP_HCL_OFST_SHIFT 16
447#define VI6_UDS_HSZCLIP_HCL_SIZE_MASK (0x1fff << 0)
448#define VI6_UDS_HSZCLIP_HCL_SIZE_SHIFT 0
449
436#define VI6_UDS_CLIP_SIZE 0x2324 450#define VI6_UDS_CLIP_SIZE 0x2324
437#define VI6_UDS_CLIP_SIZE_HSIZE_MASK (0x1fff << 16) 451#define VI6_UDS_CLIP_SIZE_HSIZE_MASK (0x1fff << 16)
438#define VI6_UDS_CLIP_SIZE_HSIZE_SHIFT 16 452#define VI6_UDS_CLIP_SIZE_HSIZE_SHIFT 16
diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c
index 8feddd59cf8d..fe0633da5a5f 100644
--- a/drivers/media/platform/vsp1/vsp1_rpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rpf.c
@@ -97,21 +97,8 @@ static void rpf_configure(struct vsp1_entity *entity,
97 * 'width' need to be adjusted. 97 * 'width' need to be adjusted.
98 */ 98 */
99 if (pipe->partitions > 1) { 99 if (pipe->partitions > 1) {
100 const struct v4l2_mbus_framefmt *output; 100 crop.width = pipe->partition->rpf.width;
101 struct vsp1_entity *wpf = &pipe->output->entity; 101 crop.left += pipe->partition->rpf.left;
102 unsigned int input_width = crop.width;
103
104 /*
105 * Scale the partition window based on the configuration
106 * of the pipeline.
107 */
108 output = vsp1_entity_get_pad_format(wpf, wpf->config,
109 RWPF_PAD_SINK);
110
111 crop.width = pipe->partition.width * input_width
112 / output->width;
113 crop.left += pipe->partition.left * input_width
114 / output->width;
115 } 102 }
116 103
117 vsp1_rpf_write(rpf, dl, VI6_RPF_SRC_BSIZE, 104 vsp1_rpf_write(rpf, dl, VI6_RPF_SRC_BSIZE,
@@ -260,8 +247,18 @@ static void rpf_configure(struct vsp1_entity *entity,
260 247
261} 248}
262 249
250static void rpf_partition(struct vsp1_entity *entity,
251 struct vsp1_pipeline *pipe,
252 struct vsp1_partition *partition,
253 unsigned int partition_idx,
254 struct vsp1_partition_window *window)
255{
256 partition->rpf = *window;
257}
258
263static const struct vsp1_entity_operations rpf_entity_ops = { 259static const struct vsp1_entity_operations rpf_entity_ops = {
264 .configure = rpf_configure, 260 .configure = rpf_configure,
261 .partition = rpf_partition,
265}; 262};
266 263
267/* ----------------------------------------------------------------------------- 264/* -----------------------------------------------------------------------------
diff --git a/drivers/media/platform/vsp1/vsp1_sru.c b/drivers/media/platform/vsp1/vsp1_sru.c
index 30142793dfcd..51e5691187c3 100644
--- a/drivers/media/platform/vsp1/vsp1_sru.c
+++ b/drivers/media/platform/vsp1/vsp1_sru.c
@@ -18,6 +18,7 @@
18 18
19#include "vsp1.h" 19#include "vsp1.h"
20#include "vsp1_dl.h" 20#include "vsp1_dl.h"
21#include "vsp1_pipe.h"
21#include "vsp1_sru.h" 22#include "vsp1_sru.h"
22 23
23#define SRU_MIN_SIZE 4U 24#define SRU_MIN_SIZE 4U
@@ -325,9 +326,34 @@ static unsigned int sru_max_width(struct vsp1_entity *entity,
325 return 256; 326 return 256;
326} 327}
327 328
329static void sru_partition(struct vsp1_entity *entity,
330 struct vsp1_pipeline *pipe,
331 struct vsp1_partition *partition,
332 unsigned int partition_idx,
333 struct vsp1_partition_window *window)
334{
335 struct vsp1_sru *sru = to_sru(&entity->subdev);
336 struct v4l2_mbus_framefmt *input;
337 struct v4l2_mbus_framefmt *output;
338
339 input = vsp1_entity_get_pad_format(&sru->entity, sru->entity.config,
340 SRU_PAD_SINK);
341 output = vsp1_entity_get_pad_format(&sru->entity, sru->entity.config,
342 SRU_PAD_SOURCE);
343
344 /* Adapt if SRUx2 is enabled */
345 if (input->width != output->width) {
346 window->width /= 2;
347 window->left /= 2;
348 }
349
350 partition->sru = *window;
351}
352
328static const struct vsp1_entity_operations sru_entity_ops = { 353static const struct vsp1_entity_operations sru_entity_ops = {
329 .configure = sru_configure, 354 .configure = sru_configure,
330 .max_width = sru_max_width, 355 .max_width = sru_max_width,
356 .partition = sru_partition,
331}; 357};
332 358
333/* ----------------------------------------------------------------------------- 359/* -----------------------------------------------------------------------------
diff --git a/drivers/media/platform/vsp1/vsp1_uds.c b/drivers/media/platform/vsp1/vsp1_uds.c
index 4226403ad235..72f72a9d2152 100644
--- a/drivers/media/platform/vsp1/vsp1_uds.c
+++ b/drivers/media/platform/vsp1/vsp1_uds.c
@@ -271,23 +271,32 @@ static void uds_configure(struct vsp1_entity *entity,
271 unsigned int vscale; 271 unsigned int vscale;
272 bool multitap; 272 bool multitap;
273 273
274 input = vsp1_entity_get_pad_format(&uds->entity, uds->entity.config,
275 UDS_PAD_SINK);
276 output = vsp1_entity_get_pad_format(&uds->entity, uds->entity.config,
277 UDS_PAD_SOURCE);
278
274 if (params == VSP1_ENTITY_PARAMS_PARTITION) { 279 if (params == VSP1_ENTITY_PARAMS_PARTITION) {
275 const struct v4l2_rect *clip = &pipe->partition; 280 struct vsp1_partition *partition = pipe->partition;
281
282 /* Input size clipping */
283 vsp1_uds_write(uds, dl, VI6_UDS_HSZCLIP, VI6_UDS_HSZCLIP_HCEN |
284 (0 << VI6_UDS_HSZCLIP_HCL_OFST_SHIFT) |
285 (partition->uds_sink.width
286 << VI6_UDS_HSZCLIP_HCL_SIZE_SHIFT));
276 287
288 /* Output size clipping */
277 vsp1_uds_write(uds, dl, VI6_UDS_CLIP_SIZE, 289 vsp1_uds_write(uds, dl, VI6_UDS_CLIP_SIZE,
278 (clip->width << VI6_UDS_CLIP_SIZE_HSIZE_SHIFT) | 290 (partition->uds_source.width
279 (clip->height << VI6_UDS_CLIP_SIZE_VSIZE_SHIFT)); 291 << VI6_UDS_CLIP_SIZE_HSIZE_SHIFT) |
292 (output->height
293 << VI6_UDS_CLIP_SIZE_VSIZE_SHIFT));
280 return; 294 return;
281 } 295 }
282 296
283 if (params != VSP1_ENTITY_PARAMS_INIT) 297 if (params != VSP1_ENTITY_PARAMS_INIT)
284 return; 298 return;
285 299
286 input = vsp1_entity_get_pad_format(&uds->entity, uds->entity.config,
287 UDS_PAD_SINK);
288 output = vsp1_entity_get_pad_format(&uds->entity, uds->entity.config,
289 UDS_PAD_SOURCE);
290
291 hscale = uds_compute_ratio(input->width, output->width); 300 hscale = uds_compute_ratio(input->width, output->width);
292 vscale = uds_compute_ratio(input->height, output->height); 301 vscale = uds_compute_ratio(input->height, output->height);
293 302
@@ -343,9 +352,41 @@ static unsigned int uds_max_width(struct vsp1_entity *entity,
343 return 2048; 352 return 2048;
344} 353}
345 354
355/* -----------------------------------------------------------------------------
356 * Partition Algorithm Support
357 */
358
359static void uds_partition(struct vsp1_entity *entity,
360 struct vsp1_pipeline *pipe,
361 struct vsp1_partition *partition,
362 unsigned int partition_idx,
363 struct vsp1_partition_window *window)
364{
365 struct vsp1_uds *uds = to_uds(&entity->subdev);
366 const struct v4l2_mbus_framefmt *output;
367 const struct v4l2_mbus_framefmt *input;
368
369 /* Initialise the partition state */
370 partition->uds_sink = *window;
371 partition->uds_source = *window;
372
373 input = vsp1_entity_get_pad_format(&uds->entity, uds->entity.config,
374 UDS_PAD_SINK);
375 output = vsp1_entity_get_pad_format(&uds->entity, uds->entity.config,
376 UDS_PAD_SOURCE);
377
378 partition->uds_sink.width = window->width * input->width
379 / output->width;
380 partition->uds_sink.left = window->left * input->width
381 / output->width;
382
383 *window = partition->uds_sink;
384}
385
346static const struct vsp1_entity_operations uds_entity_ops = { 386static const struct vsp1_entity_operations uds_entity_ops = {
347 .configure = uds_configure, 387 .configure = uds_configure,
348 .max_width = uds_max_width, 388 .max_width = uds_max_width,
389 .partition = uds_partition,
349}; 390};
350 391
351/* ----------------------------------------------------------------------------- 392/* -----------------------------------------------------------------------------
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index e9f5dcb8fae5..c2d3b8f0f487 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -182,57 +182,21 @@ static int __vsp1_video_try_format(struct vsp1_video *video,
182 * VSP1 Partition Algorithm support 182 * VSP1 Partition Algorithm support
183 */ 183 */
184 184
185static void vsp1_video_pipeline_setup_partitions(struct vsp1_pipeline *pipe)
186{
187 struct vsp1_device *vsp1 = pipe->output->entity.vsp1;
188 const struct v4l2_mbus_framefmt *format;
189 struct vsp1_entity *entity;
190 unsigned int div_size;
191
192 /*
193 * Partitions are computed on the size before rotation, use the format
194 * at the WPF sink.
195 */
196 format = vsp1_entity_get_pad_format(&pipe->output->entity,
197 pipe->output->entity.config,
198 RWPF_PAD_SINK);
199 div_size = format->width;
200
201 /* Gen2 hardware doesn't require image partitioning. */
202 if (vsp1->info->gen == 2) {
203 pipe->div_size = div_size;
204 pipe->partitions = 1;
205 return;
206 }
207
208 list_for_each_entry(entity, &pipe->entities, list_pipe) {
209 unsigned int entity_max = VSP1_VIDEO_MAX_WIDTH;
210
211 if (entity->ops->max_width) {
212 entity_max = entity->ops->max_width(entity, pipe);
213 if (entity_max)
214 div_size = min(div_size, entity_max);
215 }
216 }
217
218 pipe->div_size = div_size;
219 pipe->partitions = DIV_ROUND_UP(format->width, div_size);
220}
221
222/** 185/**
223 * vsp1_video_partition - Calculate the active partition output window 186 * vsp1_video_calculate_partition - Calculate the active partition output window
224 * 187 *
188 * @pipe: the pipeline
189 * @partition: partition that will hold the calculated values
225 * @div_size: pre-determined maximum partition division size 190 * @div_size: pre-determined maximum partition division size
226 * @index: partition index 191 * @index: partition index
227 *
228 * Returns a v4l2_rect describing the partition window.
229 */ 192 */
230static struct v4l2_rect vsp1_video_partition(struct vsp1_pipeline *pipe, 193static void vsp1_video_calculate_partition(struct vsp1_pipeline *pipe,
231 unsigned int div_size, 194 struct vsp1_partition *partition,
232 unsigned int index) 195 unsigned int div_size,
196 unsigned int index)
233{ 197{
234 const struct v4l2_mbus_framefmt *format; 198 const struct v4l2_mbus_framefmt *format;
235 struct v4l2_rect partition; 199 struct vsp1_partition_window window;
236 unsigned int modulus; 200 unsigned int modulus;
237 201
238 /* 202 /*
@@ -245,18 +209,17 @@ static struct v4l2_rect vsp1_video_partition(struct vsp1_pipeline *pipe,
245 209
246 /* A single partition simply processes the output size in full. */ 210 /* A single partition simply processes the output size in full. */
247 if (pipe->partitions <= 1) { 211 if (pipe->partitions <= 1) {
248 partition.left = 0; 212 window.left = 0;
249 partition.top = 0; 213 window.width = format->width;
250 partition.width = format->width; 214
251 partition.height = format->height; 215 vsp1_pipeline_propagate_partition(pipe, partition, index,
252 return partition; 216 &window);
217 return;
253 } 218 }
254 219
255 /* Initialise the partition with sane starting conditions. */ 220 /* Initialise the partition with sane starting conditions. */
256 partition.left = index * div_size; 221 window.left = index * div_size;
257 partition.top = 0; 222 window.width = div_size;
258 partition.width = div_size;
259 partition.height = format->height;
260 223
261 modulus = format->width % div_size; 224 modulus = format->width % div_size;
262 225
@@ -279,18 +242,65 @@ static struct v4l2_rect vsp1_video_partition(struct vsp1_pipeline *pipe,
279 if (modulus < div_size / 2) { 242 if (modulus < div_size / 2) {
280 if (index == partitions - 1) { 243 if (index == partitions - 1) {
281 /* Halve the penultimate partition. */ 244 /* Halve the penultimate partition. */
282 partition.width = div_size / 2; 245 window.width = div_size / 2;
283 } else if (index == partitions) { 246 } else if (index == partitions) {
284 /* Increase the final partition. */ 247 /* Increase the final partition. */
285 partition.width = (div_size / 2) + modulus; 248 window.width = (div_size / 2) + modulus;
286 partition.left -= div_size / 2; 249 window.left -= div_size / 2;
287 } 250 }
288 } else if (index == partitions) { 251 } else if (index == partitions) {
289 partition.width = modulus; 252 window.width = modulus;
290 } 253 }
291 } 254 }
292 255
293 return partition; 256 vsp1_pipeline_propagate_partition(pipe, partition, index, &window);
257}
258
259static int vsp1_video_pipeline_setup_partitions(struct vsp1_pipeline *pipe)
260{
261 struct vsp1_device *vsp1 = pipe->output->entity.vsp1;
262 const struct v4l2_mbus_framefmt *format;
263 struct vsp1_entity *entity;
264 unsigned int div_size;
265 unsigned int i;
266
267 /*
268 * Partitions are computed on the size before rotation, use the format
269 * at the WPF sink.
270 */
271 format = vsp1_entity_get_pad_format(&pipe->output->entity,
272 pipe->output->entity.config,
273 RWPF_PAD_SINK);
274 div_size = format->width;
275
276 /*
277 * Only Gen3 hardware requires image partitioning, Gen2 will operate
278 * with a single partition that covers the whole output.
279 */
280 if (vsp1->info->gen == 3) {
281 list_for_each_entry(entity, &pipe->entities, list_pipe) {
282 unsigned int entity_max;
283
284 if (!entity->ops->max_width)
285 continue;
286
287 entity_max = entity->ops->max_width(entity, pipe);
288 if (entity_max)
289 div_size = min(div_size, entity_max);
290 }
291 }
292
293 pipe->partitions = DIV_ROUND_UP(format->width, div_size);
294 pipe->part_table = kcalloc(pipe->partitions, sizeof(*pipe->part_table),
295 GFP_KERNEL);
296 if (!pipe->part_table)
297 return -ENOMEM;
298
299 for (i = 0; i < pipe->partitions; ++i)
300 vsp1_video_calculate_partition(pipe, &pipe->part_table[i],
301 div_size, i);
302
303 return 0;
294} 304}
295 305
296/* ----------------------------------------------------------------------------- 306/* -----------------------------------------------------------------------------
@@ -369,12 +379,12 @@ static void vsp1_video_frame_end(struct vsp1_pipeline *pipe,
369} 379}
370 380
371static void vsp1_video_pipeline_run_partition(struct vsp1_pipeline *pipe, 381static void vsp1_video_pipeline_run_partition(struct vsp1_pipeline *pipe,
372 struct vsp1_dl_list *dl) 382 struct vsp1_dl_list *dl,
383 unsigned int partition)
373{ 384{
374 struct vsp1_entity *entity; 385 struct vsp1_entity *entity;
375 386
376 pipe->partition = vsp1_video_partition(pipe, pipe->div_size, 387 pipe->partition = &pipe->part_table[partition];
377 pipe->current_partition);
378 388
379 list_for_each_entry(entity, &pipe->entities, list_pipe) { 389 list_for_each_entry(entity, &pipe->entities, list_pipe) {
380 if (entity->ops->configure) 390 if (entity->ops->configure)
@@ -387,6 +397,7 @@ static void vsp1_video_pipeline_run(struct vsp1_pipeline *pipe)
387{ 397{
388 struct vsp1_device *vsp1 = pipe->output->entity.vsp1; 398 struct vsp1_device *vsp1 = pipe->output->entity.vsp1;
389 struct vsp1_entity *entity; 399 struct vsp1_entity *entity;
400 unsigned int partition;
390 401
391 if (!pipe->dl) 402 if (!pipe->dl)
392 pipe->dl = vsp1_dl_list_get(pipe->output->dlm); 403 pipe->dl = vsp1_dl_list_get(pipe->output->dlm);
@@ -403,20 +414,12 @@ static void vsp1_video_pipeline_run(struct vsp1_pipeline *pipe)
403 } 414 }
404 415
405 /* Run the first partition */ 416 /* Run the first partition */
406 pipe->current_partition = 0; 417 vsp1_video_pipeline_run_partition(pipe, pipe->dl, 0);
407 vsp1_video_pipeline_run_partition(pipe, pipe->dl);
408 418
409 /* Process consecutive partitions as necessary */ 419 /* Process consecutive partitions as necessary */
410 for (pipe->current_partition = 1; 420 for (partition = 1; partition < pipe->partitions; ++partition) {
411 pipe->current_partition < pipe->partitions;
412 pipe->current_partition++) {
413 struct vsp1_dl_list *dl; 421 struct vsp1_dl_list *dl;
414 422
415 /*
416 * Partition configuration operations will utilise
417 * the pipe->current_partition variable to determine
418 * the work they should complete.
419 */
420 dl = vsp1_dl_list_get(pipe->output->dlm); 423 dl = vsp1_dl_list_get(pipe->output->dlm);
421 424
422 /* 425 /*
@@ -429,7 +432,7 @@ static void vsp1_video_pipeline_run(struct vsp1_pipeline *pipe)
429 break; 432 break;
430 } 433 }
431 434
432 vsp1_video_pipeline_run_partition(pipe, dl); 435 vsp1_video_pipeline_run_partition(pipe, dl, partition);
433 vsp1_dl_list_add_chain(pipe->dl, dl); 436 vsp1_dl_list_add_chain(pipe->dl, dl);
434 } 437 }
435 438
@@ -802,9 +805,12 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb)
802static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe) 805static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe)
803{ 806{
804 struct vsp1_entity *entity; 807 struct vsp1_entity *entity;
808 int ret;
805 809
806 /* Determine this pipelines sizes for image partitioning support. */ 810 /* Determine this pipelines sizes for image partitioning support. */
807 vsp1_video_pipeline_setup_partitions(pipe); 811 ret = vsp1_video_pipeline_setup_partitions(pipe);
812 if (ret < 0)
813 return ret;
808 814
809 /* Prepare the display list. */ 815 /* Prepare the display list. */
810 pipe->dl = vsp1_dl_list_get(pipe->output->dlm); 816 pipe->dl = vsp1_dl_list_get(pipe->output->dlm);
@@ -843,6 +849,26 @@ static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe)
843 return 0; 849 return 0;
844} 850}
845 851
852static void vsp1_video_cleanup_pipeline(struct vsp1_pipeline *pipe)
853{
854 struct vsp1_video *video = pipe->output->video;
855 struct vsp1_vb2_buffer *buffer;
856 unsigned long flags;
857
858 /* Remove all buffers from the IRQ queue. */
859 spin_lock_irqsave(&video->irqlock, flags);
860 list_for_each_entry(buffer, &video->irqqueue, queue)
861 vb2_buffer_done(&buffer->buf.vb2_buf, VB2_BUF_STATE_ERROR);
862 INIT_LIST_HEAD(&video->irqqueue);
863 spin_unlock_irqrestore(&video->irqlock, flags);
864
865 /* Release our partition table allocation */
866 mutex_lock(&pipe->lock);
867 kfree(pipe->part_table);
868 pipe->part_table = NULL;
869 mutex_unlock(&pipe->lock);
870}
871
846static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count) 872static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count)
847{ 873{
848 struct vsp1_video *video = vb2_get_drv_priv(vq); 874 struct vsp1_video *video = vb2_get_drv_priv(vq);
@@ -856,6 +882,7 @@ static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count)
856 ret = vsp1_video_setup_pipeline(pipe); 882 ret = vsp1_video_setup_pipeline(pipe);
857 if (ret < 0) { 883 if (ret < 0) {
858 mutex_unlock(&pipe->lock); 884 mutex_unlock(&pipe->lock);
885 vsp1_video_cleanup_pipeline(pipe);
859 return ret; 886 return ret;
860 } 887 }
861 888
@@ -887,7 +914,6 @@ static void vsp1_video_stop_streaming(struct vb2_queue *vq)
887{ 914{
888 struct vsp1_video *video = vb2_get_drv_priv(vq); 915 struct vsp1_video *video = vb2_get_drv_priv(vq);
889 struct vsp1_pipeline *pipe = video->rwpf->pipe; 916 struct vsp1_pipeline *pipe = video->rwpf->pipe;
890 struct vsp1_vb2_buffer *buffer;
891 unsigned long flags; 917 unsigned long flags;
892 int ret; 918 int ret;
893 919
@@ -912,14 +938,8 @@ static void vsp1_video_stop_streaming(struct vb2_queue *vq)
912 mutex_unlock(&pipe->lock); 938 mutex_unlock(&pipe->lock);
913 939
914 media_pipeline_stop(&video->video.entity); 940 media_pipeline_stop(&video->video.entity);
941 vsp1_video_cleanup_pipeline(pipe);
915 vsp1_video_pipeline_put(pipe); 942 vsp1_video_pipeline_put(pipe);
916
917 /* Remove all buffers from the IRQ queue. */
918 spin_lock_irqsave(&video->irqlock, flags);
919 list_for_each_entry(buffer, &video->irqqueue, queue)
920 vb2_buffer_done(&buffer->buf.vb2_buf, VB2_BUF_STATE_ERROR);
921 INIT_LIST_HEAD(&video->irqqueue);
922 spin_unlock_irqrestore(&video->irqlock, flags);
923} 943}
924 944
925static const struct vb2_ops vsp1_video_queue_qops = { 945static const struct vb2_ops vsp1_video_queue_qops = {
diff --git a/drivers/media/platform/vsp1/vsp1_wpf.c b/drivers/media/platform/vsp1/vsp1_wpf.c
index b6c902be225b..f7f3b4b2c2de 100644
--- a/drivers/media/platform/vsp1/vsp1_wpf.c
+++ b/drivers/media/platform/vsp1/vsp1_wpf.c
@@ -291,7 +291,7 @@ static void wpf_configure(struct vsp1_entity *entity,
291 * multiple slices. 291 * multiple slices.
292 */ 292 */
293 if (pipe->partitions > 1) 293 if (pipe->partitions > 1)
294 width = pipe->partition.width; 294 width = pipe->partition->wpf.width;
295 295
296 vsp1_wpf_write(wpf, dl, VI6_WPF_HSZCLIP, VI6_WPF_SZCLIP_EN | 296 vsp1_wpf_write(wpf, dl, VI6_WPF_HSZCLIP, VI6_WPF_SZCLIP_EN |
297 (0 << VI6_WPF_SZCLIP_OFST_SHIFT) | 297 (0 << VI6_WPF_SZCLIP_OFST_SHIFT) |
@@ -320,13 +320,13 @@ static void wpf_configure(struct vsp1_entity *entity,
320 * is applied horizontally or vertically accordingly. 320 * is applied horizontally or vertically accordingly.
321 */ 321 */
322 if (flip & BIT(WPF_CTRL_HFLIP) && !wpf->flip.rotate) 322 if (flip & BIT(WPF_CTRL_HFLIP) && !wpf->flip.rotate)
323 offset = format->width - pipe->partition.left 323 offset = format->width - pipe->partition->wpf.left
324 - pipe->partition.width; 324 - pipe->partition->wpf.width;
325 else if (flip & BIT(WPF_CTRL_VFLIP) && wpf->flip.rotate) 325 else if (flip & BIT(WPF_CTRL_VFLIP) && wpf->flip.rotate)
326 offset = format->height - pipe->partition.left 326 offset = format->height - pipe->partition->wpf.left
327 - pipe->partition.width; 327 - pipe->partition->wpf.width;
328 else 328 else
329 offset = pipe->partition.left; 329 offset = pipe->partition->wpf.left;
330 330
331 for (i = 0; i < format->num_planes; ++i) { 331 for (i = 0; i < format->num_planes; ++i) {
332 unsigned int hsub = i > 0 ? fmtinfo->hsub : 1; 332 unsigned int hsub = i > 0 ? fmtinfo->hsub : 1;
@@ -348,7 +348,7 @@ static void wpf_configure(struct vsp1_entity *entity,
348 * image height. 348 * image height.
349 */ 349 */
350 if (wpf->flip.rotate) 350 if (wpf->flip.rotate)
351 height = pipe->partition.width; 351 height = pipe->partition->wpf.width;
352 else 352 else
353 height = format->height; 353 height = format->height;
354 354
@@ -473,10 +473,20 @@ static unsigned int wpf_max_width(struct vsp1_entity *entity,
473 return wpf->flip.rotate ? 256 : wpf->max_width; 473 return wpf->flip.rotate ? 256 : wpf->max_width;
474} 474}
475 475
476static void wpf_partition(struct vsp1_entity *entity,
477 struct vsp1_pipeline *pipe,
478 struct vsp1_partition *partition,
479 unsigned int partition_idx,
480 struct vsp1_partition_window *window)
481{
482 partition->wpf = *window;
483}
484
476static const struct vsp1_entity_operations wpf_entity_ops = { 485static const struct vsp1_entity_operations wpf_entity_ops = {
477 .destroy = vsp1_wpf_destroy, 486 .destroy = vsp1_wpf_destroy,
478 .configure = wpf_configure, 487 .configure = wpf_configure,
479 .max_width = wpf_max_width, 488 .max_width = wpf_max_width,
489 .partition = wpf_partition,
480}; 490};
481 491
482/* ----------------------------------------------------------------------------- 492/* -----------------------------------------------------------------------------
diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
index ac4704388920..ebfdf334d99c 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -90,12 +90,12 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev,
90 of_node_put(ep); 90 of_node_put(ep);
91 ep = next; 91 ep = next;
92 92
93 dev_dbg(xdev->dev, "processing endpoint %s\n", ep->full_name); 93 dev_dbg(xdev->dev, "processing endpoint %pOF\n", ep);
94 94
95 ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link); 95 ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link);
96 if (ret < 0) { 96 if (ret < 0) {
97 dev_err(xdev->dev, "failed to parse link for %s\n", 97 dev_err(xdev->dev, "failed to parse link for %pOF\n",
98 ep->full_name); 98 ep);
99 continue; 99 continue;
100 } 100 }
101 101
@@ -103,9 +103,9 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev,
103 * the link. 103 * the link.
104 */ 104 */
105 if (link.local_port >= local->num_pads) { 105 if (link.local_port >= local->num_pads) {
106 dev_err(xdev->dev, "invalid port number %u for %s\n", 106 dev_err(xdev->dev, "invalid port number %u for %pOF\n",
107 link.local_port, 107 link.local_port,
108 to_of_node(link.local_node)->full_name); 108 to_of_node(link.local_node));
109 v4l2_fwnode_put_link(&link); 109 v4l2_fwnode_put_link(&link);
110 ret = -EINVAL; 110 ret = -EINVAL;
111 break; 111 break;
@@ -114,8 +114,8 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev,
114 local_pad = &local->pads[link.local_port]; 114 local_pad = &local->pads[link.local_port];
115 115
116 if (local_pad->flags & MEDIA_PAD_FL_SINK) { 116 if (local_pad->flags & MEDIA_PAD_FL_SINK) {
117 dev_dbg(xdev->dev, "skipping sink port %s:%u\n", 117 dev_dbg(xdev->dev, "skipping sink port %pOF:%u\n",
118 to_of_node(link.local_node)->full_name, 118 to_of_node(link.local_node),
119 link.local_port); 119 link.local_port);
120 v4l2_fwnode_put_link(&link); 120 v4l2_fwnode_put_link(&link);
121 continue; 121 continue;
@@ -123,8 +123,8 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev,
123 123
124 /* Skip DMA engines, they will be processed separately. */ 124 /* Skip DMA engines, they will be processed separately. */
125 if (link.remote_node == of_fwnode_handle(xdev->dev->of_node)) { 125 if (link.remote_node == of_fwnode_handle(xdev->dev->of_node)) {
126 dev_dbg(xdev->dev, "skipping DMA port %s:%u\n", 126 dev_dbg(xdev->dev, "skipping DMA port %pOF:%u\n",
127 to_of_node(link.local_node)->full_name, 127 to_of_node(link.local_node),
128 link.local_port); 128 link.local_port);
129 v4l2_fwnode_put_link(&link); 129 v4l2_fwnode_put_link(&link);
130 continue; 130 continue;
@@ -134,8 +134,8 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev,
134 ent = xvip_graph_find_entity(xdev, 134 ent = xvip_graph_find_entity(xdev,
135 to_of_node(link.remote_node)); 135 to_of_node(link.remote_node));
136 if (ent == NULL) { 136 if (ent == NULL) {
137 dev_err(xdev->dev, "no entity found for %s\n", 137 dev_err(xdev->dev, "no entity found for %pOF\n",
138 to_of_node(link.remote_node)->full_name); 138 to_of_node(link.remote_node));
139 v4l2_fwnode_put_link(&link); 139 v4l2_fwnode_put_link(&link);
140 ret = -ENODEV; 140 ret = -ENODEV;
141 break; 141 break;
@@ -144,9 +144,8 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev,
144 remote = ent->entity; 144 remote = ent->entity;
145 145
146 if (link.remote_port >= remote->num_pads) { 146 if (link.remote_port >= remote->num_pads) {
147 dev_err(xdev->dev, "invalid port number %u on %s\n", 147 dev_err(xdev->dev, "invalid port number %u on %pOF\n",
148 link.remote_port, 148 link.remote_port, to_of_node(link.remote_node));
149 to_of_node(link.remote_node)->full_name);
150 v4l2_fwnode_put_link(&link); 149 v4l2_fwnode_put_link(&link);
151 ret = -EINVAL; 150 ret = -EINVAL;
152 break; 151 break;
@@ -216,12 +215,12 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev)
216 of_node_put(ep); 215 of_node_put(ep);
217 ep = next; 216 ep = next;
218 217
219 dev_dbg(xdev->dev, "processing endpoint %s\n", ep->full_name); 218 dev_dbg(xdev->dev, "processing endpoint %pOF\n", ep);
220 219
221 ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link); 220 ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link);
222 if (ret < 0) { 221 if (ret < 0) {
223 dev_err(xdev->dev, "failed to parse link for %s\n", 222 dev_err(xdev->dev, "failed to parse link for %pOF\n",
224 ep->full_name); 223 ep);
225 continue; 224 continue;
226 } 225 }
227 226
@@ -242,17 +241,17 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev)
242 ent = xvip_graph_find_entity(xdev, 241 ent = xvip_graph_find_entity(xdev,
243 to_of_node(link.remote_node)); 242 to_of_node(link.remote_node));
244 if (ent == NULL) { 243 if (ent == NULL) {
245 dev_err(xdev->dev, "no entity found for %s\n", 244 dev_err(xdev->dev, "no entity found for %pOF\n",
246 to_of_node(link.remote_node)->full_name); 245 to_of_node(link.remote_node));
247 v4l2_fwnode_put_link(&link); 246 v4l2_fwnode_put_link(&link);
248 ret = -ENODEV; 247 ret = -ENODEV;
249 break; 248 break;
250 } 249 }
251 250
252 if (link.remote_port >= ent->entity->num_pads) { 251 if (link.remote_port >= ent->entity->num_pads) {
253 dev_err(xdev->dev, "invalid port number %u on %s\n", 252 dev_err(xdev->dev, "invalid port number %u on %pOF\n",
254 link.remote_port, 253 link.remote_port,
255 to_of_node(link.remote_node)->full_name); 254 to_of_node(link.remote_node));
256 v4l2_fwnode_put_link(&link); 255 v4l2_fwnode_put_link(&link);
257 ret = -EINVAL; 256 ret = -EINVAL;
258 break; 257 break;
@@ -337,8 +336,8 @@ static int xvip_graph_notify_bound(struct v4l2_async_notifier *notifier,
337 continue; 336 continue;
338 337
339 if (entity->subdev) { 338 if (entity->subdev) {
340 dev_err(xdev->dev, "duplicate subdev for node %s\n", 339 dev_err(xdev->dev, "duplicate subdev for node %pOF\n",
341 entity->node->full_name); 340 entity->node);
342 return -EINVAL; 341 return -EINVAL;
343 } 342 }
344 343
@@ -360,14 +359,14 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev,
360 struct device_node *ep = NULL; 359 struct device_node *ep = NULL;
361 int ret = 0; 360 int ret = 0;
362 361
363 dev_dbg(xdev->dev, "parsing node %s\n", node->full_name); 362 dev_dbg(xdev->dev, "parsing node %pOF\n", node);
364 363
365 while (1) { 364 while (1) {
366 ep = of_graph_get_next_endpoint(node, ep); 365 ep = of_graph_get_next_endpoint(node, ep);
367 if (ep == NULL) 366 if (ep == NULL)
368 break; 367 break;
369 368
370 dev_dbg(xdev->dev, "handling endpoint %s\n", ep->full_name); 369 dev_dbg(xdev->dev, "handling endpoint %pOF\n", ep);
371 370
372 remote = of_graph_get_remote_port_parent(ep); 371 remote = of_graph_get_remote_port_parent(ep);
373 if (remote == NULL) { 372 if (remote == NULL) {
@@ -452,8 +451,7 @@ static int xvip_graph_dma_init_one(struct xvip_composite_device *xdev,
452 451
453 ret = xvip_dma_init(xdev, dma, type, index); 452 ret = xvip_dma_init(xdev, dma, type, index);
454 if (ret < 0) { 453 if (ret < 0) {
455 dev_err(xdev->dev, "%s initialization failed\n", 454 dev_err(xdev->dev, "%pOF initialization failed\n", node);
456 node->full_name);
457 return ret; 455 return ret;
458 } 456 }
459 457
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c
index 53bc8c010035..8521bb2825e8 100644
--- a/drivers/media/radio/dsbr100.c
+++ b/drivers/media/radio/dsbr100.c
@@ -408,7 +408,7 @@ err_reg_dev:
408 return retval; 408 return retval;
409} 409}
410 410
411static struct usb_device_id usb_dsbr100_device_table[] = { 411static const struct usb_device_id usb_dsbr100_device_table[] = {
412 { USB_DEVICE(DSB100_VENDOR, DSB100_PRODUCT) }, 412 { USB_DEVICE(DSB100_VENDOR, DSB100_PRODUCT) },
413 { } /* Terminating entry */ 413 { } /* Terminating entry */
414}; 414};
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index cbaf850f4791..6888b7db449d 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -528,7 +528,7 @@ static const struct v4l2_ctrl_ops cadet_ctrl_ops = {
528 528
529#ifdef CONFIG_PNP 529#ifdef CONFIG_PNP
530 530
531static struct pnp_device_id cadet_pnp_devices[] = { 531static const struct pnp_device_id cadet_pnp_devices[] = {
532 /* ADS Cadet AM/FM Radio Card */ 532 /* ADS Cadet AM/FM Radio Card */
533 {.id = "MSM0c24", .driver_data = 0}, 533 {.id = "MSM0c24", .driver_data = 0},
534 {.id = ""} 534 {.id = ""}
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index ca051ccbc3e4..ddc12b16f77c 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -281,7 +281,7 @@ static const struct radio_isa_ops gemtek_ops = {
281static const int gemtek_ioports[] = { 0x20c, 0x30c, 0x24c, 0x34c, 0x248, 0x28c }; 281static const int gemtek_ioports[] = { 0x20c, 0x30c, 0x24c, 0x34c, 0x248, 0x28c };
282 282
283#ifdef CONFIG_PNP 283#ifdef CONFIG_PNP
284static struct pnp_device_id gemtek_pnp_devices[] = { 284static const struct pnp_device_id gemtek_pnp_devices[] = {
285 /* AOpen FX-3D/Pro Radio */ 285 /* AOpen FX-3D/Pro Radio */
286 {.id = "ADS7183", .driver_data = 0}, 286 {.id = "ADS7183", .driver_data = 0},
287 {.id = ""} 287 {.id = ""}
diff --git a/drivers/media/radio/radio-keene.c b/drivers/media/radio/radio-keene.c
index 53a7c2e87762..f2ea8bc5f5ee 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -45,7 +45,7 @@ MODULE_LICENSE("GPL");
45#define FREQ_MUL 16000U 45#define FREQ_MUL 16000U
46 46
47/* USB Device ID List */ 47/* USB Device ID List */
48static struct usb_device_id usb_keene_device_table[] = { 48static const struct usb_device_id usb_keene_device_table[] = {
49 {USB_DEVICE_AND_INTERFACE_INFO(USB_KEENE_VENDOR, USB_KEENE_PRODUCT, 49 {USB_DEVICE_AND_INTERFACE_INFO(USB_KEENE_VENDOR, USB_KEENE_PRODUCT,
50 USB_CLASS_HID, 0, 0) }, 50 USB_CLASS_HID, 0, 0) },
51 { } /* Terminating entry */ 51 { } /* Terminating entry */
diff --git a/drivers/media/radio/radio-ma901.c b/drivers/media/radio/radio-ma901.c
index c2010a905a47..fdc481257efd 100644
--- a/drivers/media/radio/radio-ma901.c
+++ b/drivers/media/radio/radio-ma901.c
@@ -444,7 +444,7 @@ err:
444} 444}
445 445
446/* USB Device ID List */ 446/* USB Device ID List */
447static struct usb_device_id usb_ma901radio_device_table[] = { 447static const struct usb_device_id usb_ma901radio_device_table[] = {
448 { USB_DEVICE_AND_INTERFACE_INFO(USB_MA901_VENDOR, USB_MA901_PRODUCT, 448 { USB_DEVICE_AND_INTERFACE_INFO(USB_MA901_VENDOR, USB_MA901_PRODUCT,
449 USB_CLASS_HID, 0, 0) }, 449 USB_CLASS_HID, 0, 0) },
450 { } /* Terminating entry */ 450 { } /* Terminating entry */
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index 8253f79d5d75..3aa5ad391581 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -186,7 +186,7 @@ static void maxiradio_remove(struct pci_dev *pdev)
186 kfree(dev); 186 kfree(dev);
187} 187}
188 188
189static struct pci_device_id maxiradio_pci_tbl[] = { 189static const struct pci_device_id maxiradio_pci_tbl[] = {
190 { PCI_VENDOR_ID_GUILLEMOT, PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO, 190 { PCI_VENDOR_ID_GUILLEMOT, PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO,
191 PCI_ANY_ID, PCI_ANY_ID, }, 191 PCI_ANY_ID, PCI_ANY_ID, },
192 { 0 } 192 { 0 }
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c
index 95c12532e87a..c9f59129af79 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -587,7 +587,7 @@ err:
587} 587}
588 588
589/* USB Device ID List */ 589/* USB Device ID List */
590static struct usb_device_id usb_amradio_device_table[] = { 590static const struct usb_device_id usb_amradio_device_table[] = {
591 { USB_DEVICE_AND_INTERFACE_INFO(USB_AMRADIO_VENDOR, USB_AMRADIO_PRODUCT, 591 { USB_DEVICE_AND_INTERFACE_INFO(USB_AMRADIO_VENDOR, USB_AMRADIO_PRODUCT,
592 USB_CLASS_HID, 0, 0) }, 592 USB_CLASS_HID, 0, 0) },
593 { } /* Terminating entry */ 593 { } /* Terminating entry */
diff --git a/drivers/media/radio/radio-raremono.c b/drivers/media/radio/radio-raremono.c
index bfb3a6d051ba..3c0a22a54113 100644
--- a/drivers/media/radio/radio-raremono.c
+++ b/drivers/media/radio/radio-raremono.c
@@ -58,7 +58,7 @@ MODULE_LICENSE("GPL v2");
58 */ 58 */
59 59
60/* USB Device ID List */ 60/* USB Device ID List */
61static struct usb_device_id usb_raremono_device_table[] = { 61static const struct usb_device_id usb_raremono_device_table[] = {
62 {USB_DEVICE_AND_INTERFACE_INFO(0x10c4, 0x818a, USB_CLASS_HID, 0, 0) }, 62 {USB_DEVICE_AND_INTERFACE_INFO(0x10c4, 0x818a, USB_CLASS_HID, 0, 0) },
63 { } /* Terminating entry */ 63 { } /* Terminating entry */
64}; 64};
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index dc81d422b394..de79d5569c2a 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -197,7 +197,7 @@ static int fmr2_tea_ext_init(struct snd_tea575x *tea)
197 return 0; 197 return 0;
198} 198}
199 199
200static struct pnp_device_id fmr2_pnp_ids[] = { 200static const struct pnp_device_id fmr2_pnp_ids[] = {
201 { .id = "MFRad13" }, /* tuner subdevice of SF16-FMD2 */ 201 { .id = "MFRad13" }, /* tuner subdevice of SF16-FMD2 */
202 { .id = "" } 202 { .id = "" }
203}; 203};
diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
index 23971f5502a8..22f3466af2b1 100644
--- a/drivers/media/radio/radio-shark.c
+++ b/drivers/media/radio/radio-shark.c
@@ -392,7 +392,7 @@ static int usb_shark_resume(struct usb_interface *intf)
392#endif 392#endif
393 393
394/* Specify the bcdDevice value, as the radioSHARK and radioSHARK2 share ids */ 394/* Specify the bcdDevice value, as the radioSHARK and radioSHARK2 share ids */
395static struct usb_device_id usb_shark_device_table[] = { 395static const struct usb_device_id usb_shark_device_table[] = {
396 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION | 396 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION |
397 USB_DEVICE_ID_MATCH_INT_CLASS, 397 USB_DEVICE_ID_MATCH_INT_CLASS,
398 .idVendor = 0x077d, 398 .idVendor = 0x077d,
diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
index b50638ec5f09..4d1a4b3d669c 100644
--- a/drivers/media/radio/radio-shark2.c
+++ b/drivers/media/radio/radio-shark2.c
@@ -358,7 +358,7 @@ static int usb_shark_resume(struct usb_interface *intf)
358#endif 358#endif
359 359
360/* Specify the bcdDevice value, as the radioSHARK and radioSHARK2 share ids */ 360/* Specify the bcdDevice value, as the radioSHARK and radioSHARK2 share ids */
361static struct usb_device_id usb_shark_device_table[] = { 361static const struct usb_device_id usb_shark_device_table[] = {
362 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION | 362 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION |
363 USB_DEVICE_ID_MATCH_INT_CLASS, 363 USB_DEVICE_ID_MATCH_INT_CLASS,
364 .idVendor = 0x077d, 364 .idVendor = 0x077d,
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
index 9db8331a0c75..bc7e69e7e32e 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -414,7 +414,7 @@ static const struct v4l2_ioctl_ops tea5764_ioctl_ops = {
414}; 414};
415 415
416/* V4L2 interface */ 416/* V4L2 interface */
417static struct video_device tea5764_radio_template = { 417static const struct video_device tea5764_radio_template = {
418 .name = "TEA5764 FM-Radio", 418 .name = "TEA5764 FM-Radio",
419 .fops = &tea5764_fops, 419 .fops = &tea5764_fops,
420 .ioctl_ops = &tea5764_ioctl_ops, 420 .ioctl_ops = &tea5764_ioctl_ops,
diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c
index 17e82a9a0109..903fcd5e99c0 100644
--- a/drivers/media/radio/radio-wl1273.c
+++ b/drivers/media/radio/radio-wl1273.c
@@ -1982,7 +1982,7 @@ static const struct v4l2_ioctl_ops wl1273_ioctl_ops = {
1982 .vidioc_log_status = wl1273_fm_vidioc_log_status, 1982 .vidioc_log_status = wl1273_fm_vidioc_log_status,
1983}; 1983};
1984 1984
1985static struct video_device wl1273_viddev_template = { 1985static const struct video_device wl1273_viddev_template = {
1986 .fops = &wl1273_fops, 1986 .fops = &wl1273_fops,
1987 .ioctl_ops = &wl1273_ioctl_ops, 1987 .ioctl_ops = &wl1273_ioctl_ops,
1988 .name = WL1273_FM_DRIVER_NAME, 1988 .name = WL1273_FM_DRIVER_NAME,
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
index 571f29a34bf8..c311f9951d80 100644
--- a/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -38,7 +38,7 @@
38 38
39 39
40/* USB Device ID List */ 40/* USB Device ID List */
41static struct usb_device_id si470x_usb_driver_id_table[] = { 41static const struct usb_device_id si470x_usb_driver_id_table[] = {
42 /* Silicon Labs USB FM Radio Reference Design */ 42 /* Silicon Labs USB FM Radio Reference Design */
43 { USB_DEVICE_AND_INTERFACE_INFO(0x10c4, 0x818a, USB_CLASS_HID, 0, 0) }, 43 { USB_DEVICE_AND_INTERFACE_INFO(0x10c4, 0x818a, USB_CLASS_HID, 0, 0) },
44 /* ADS/Tech FM Radio Receiver (formerly Instant FM Music) */ 44 /* ADS/Tech FM Radio Receiver (formerly Instant FM Music) */
diff --git a/drivers/media/radio/si4713/radio-platform-si4713.c b/drivers/media/radio/si4713/radio-platform-si4713.c
index 6f93ef1249a6..27339ec495f6 100644
--- a/drivers/media/radio/si4713/radio-platform-si4713.c
+++ b/drivers/media/radio/si4713/radio-platform-si4713.c
@@ -135,7 +135,7 @@ static struct v4l2_ioctl_ops radio_si4713_ioctl_ops = {
135}; 135};
136 136
137/* radio_si4713_vdev_template - video device interface */ 137/* radio_si4713_vdev_template - video device interface */
138static struct video_device radio_si4713_vdev_template = { 138static const struct video_device radio_si4713_vdev_template = {
139 .fops = &radio_si4713_fops, 139 .fops = &radio_si4713_fops,
140 .name = "radio-si4713", 140 .name = "radio-si4713",
141 .release = video_device_release_empty, 141 .release = video_device_release_empty,
diff --git a/drivers/media/radio/si4713/radio-usb-si4713.c b/drivers/media/radio/si4713/radio-usb-si4713.c
index e5e5a1672bdb..a115db24667b 100644
--- a/drivers/media/radio/si4713/radio-usb-si4713.c
+++ b/drivers/media/radio/si4713/radio-usb-si4713.c
@@ -49,7 +49,7 @@ MODULE_LICENSE("GPL v2");
49#define USB_RESP_TIMEOUT 50000 49#define USB_RESP_TIMEOUT 50000
50 50
51/* USB Device ID List */ 51/* USB Device ID List */
52static struct usb_device_id usb_si4713_usb_device_table[] = { 52static const struct usb_device_id usb_si4713_usb_device_table[] = {
53 {USB_DEVICE_AND_INTERFACE_INFO(USB_SI4713_VENDOR, USB_SI4713_PRODUCT, 53 {USB_DEVICE_AND_INTERFACE_INFO(USB_SI4713_VENDOR, USB_SI4713_PRODUCT,
54 USB_CLASS_HID, 0, 0) }, 54 USB_CLASS_HID, 0, 0) },
55 { } /* Terminating entry */ 55 { } /* Terminating entry */
@@ -409,7 +409,7 @@ static const struct i2c_algorithm si4713_algo = {
409 409
410/* This name value shows up in the sysfs filename associated 410/* This name value shows up in the sysfs filename associated
411 with this I2C adapter */ 411 with this I2C adapter */
412static struct i2c_adapter si4713_i2c_adapter_template = { 412static const struct i2c_adapter si4713_i2c_adapter_template = {
413 .name = "si4713-i2c", 413 .name = "si4713-i2c",
414 .owner = THIS_MODULE, 414 .owner = THIS_MODULE,
415 .algo = &si4713_algo, 415 .algo = &si4713_algo,
diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c
index 71423f45c05c..fc5a7abc83d2 100644
--- a/drivers/media/radio/wl128x/fmdrv_v4l2.c
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -509,7 +509,7 @@ static const struct v4l2_ioctl_ops fm_drv_ioctl_ops = {
509}; 509};
510 510
511/* V4L2 RADIO device parent structure */ 511/* V4L2 RADIO device parent structure */
512static struct video_device fm_viddev_template = { 512static const struct video_device fm_viddev_template = {
513 .fops = &fm_drv_fops, 513 .fops = &fm_drv_fops,
514 .ioctl_ops = &fm_drv_ioctl_ops, 514 .ioctl_ops = &fm_drv_ioctl_ops,
515 .name = FM_DRV_NAME, 515 .name = FM_DRV_NAME,
diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 5e83b76495f7..d9ce8ff55d0c 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -1,9 +1,20 @@
1config RC_CORE 1
2 tristate 2menuconfig RC_CORE
3 depends on MEDIA_RC_SUPPORT 3 tristate "Remote Controller support"
4 depends on INPUT 4 depends on INPUT
5 default y 5 default y
6 ---help---
7 Enable support for Remote Controllers on Linux. This is
8 needed in order to support several video capture adapters,
9 standalone IR receivers/transmitters, and RF receivers.
10
11 Enable this option if you have a video capture board even
12 if you don't need IR, as otherwise, you may not be able to
13 compile the driver for your adapter.
6 14
15 Say Y when you have a TV or an IR device.
16
17if RC_CORE
7source "drivers/media/rc/keymaps/Kconfig" 18source "drivers/media/rc/keymaps/Kconfig"
8 19
9menuconfig RC_DECODERS 20menuconfig RC_DECODERS
@@ -388,6 +399,29 @@ config IR_GPIO_CIR
388 To compile this driver as a module, choose M here: the module will 399 To compile this driver as a module, choose M here: the module will
389 be called gpio-ir-recv. 400 be called gpio-ir-recv.
390 401
402config IR_GPIO_TX
403 tristate "GPIO IR Bit Banging Transmitter"
404 depends on RC_CORE
405 depends on LIRC
406 ---help---
407 Say Y if you want to a GPIO based IR transmitter. This is a
408 bit banging driver.
409
410 To compile this driver as a module, choose M here: the module will
411 be called gpio-ir-tx.
412
413config IR_PWM_TX
414 tristate "PWM IR transmitter"
415 depends on RC_CORE
416 depends on LIRC
417 depends on PWM
418 ---help---
419 Say Y if you want to use a PWM based IR transmitter. This is
420 more power efficient than the bit banging gpio driver.
421
422 To compile this driver as a module, choose M here: the module will
423 be called pwm-ir-tx.
424
391config RC_ST 425config RC_ST
392 tristate "ST remote control receiver" 426 tristate "ST remote control receiver"
393 depends on RC_CORE 427 depends on RC_CORE
@@ -435,4 +469,17 @@ config IR_SIR
435 To compile this driver as a module, choose M here: the module will 469 To compile this driver as a module, choose M here: the module will
436 be called sir-ir. 470 be called sir-ir.
437 471
472config IR_ZX
473 tristate "ZTE ZX IR remote control"
474 depends on RC_CORE
475 depends on ARCH_ZX || COMPILE_TEST
476 ---help---
477 Say Y if you want to use the IR remote control available
478 on ZTE ZX family SoCs.
479
480 To compile this driver as a module, choose M here: the
481 module will be called zx-irdec.
482
438endif #RC_DEVICES 483endif #RC_DEVICES
484
485endif #RC_CORE
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index 245e2c2d0b22..9bc6a3980ed0 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -32,6 +32,8 @@ obj-$(CONFIG_IR_STREAMZAP) += streamzap.o
32obj-$(CONFIG_IR_WINBOND_CIR) += winbond-cir.o 32obj-$(CONFIG_IR_WINBOND_CIR) += winbond-cir.o
33obj-$(CONFIG_RC_LOOPBACK) += rc-loopback.o 33obj-$(CONFIG_RC_LOOPBACK) += rc-loopback.o
34obj-$(CONFIG_IR_GPIO_CIR) += gpio-ir-recv.o 34obj-$(CONFIG_IR_GPIO_CIR) += gpio-ir-recv.o
35obj-$(CONFIG_IR_GPIO_TX) += gpio-ir-tx.o
36obj-$(CONFIG_IR_PWM_TX) += pwm-ir-tx.o
35obj-$(CONFIG_IR_IGORPLUGUSB) += igorplugusb.o 37obj-$(CONFIG_IR_IGORPLUGUSB) += igorplugusb.o
36obj-$(CONFIG_IR_IGUANA) += iguanair.o 38obj-$(CONFIG_IR_IGUANA) += iguanair.o
37obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o 39obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o
@@ -41,3 +43,4 @@ obj-$(CONFIG_IR_IMG) += img-ir/
41obj-$(CONFIG_IR_SERIAL) += serial_ir.o 43obj-$(CONFIG_IR_SERIAL) += serial_ir.o
42obj-$(CONFIG_IR_SIR) += sir_ir.o 44obj-$(CONFIG_IR_SIR) += sir_ir.o
43obj-$(CONFIG_IR_MTK) += mtk-cir.o 45obj-$(CONFIG_IR_MTK) += mtk-cir.o
46obj-$(CONFIG_IR_ZX) += zx-irdec.o
diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
index a4c6ad4f67c1..d0871d60a723 100644
--- a/drivers/media/rc/ati_remote.c
+++ b/drivers/media/rc/ati_remote.c
@@ -622,7 +622,8 @@ static void ati_remote_input_report(struct urb *urb)
622 * it would cause ghost repeats which would be a 622 * it would cause ghost repeats which would be a
623 * regression for this driver. 623 * regression for this driver.
624 */ 624 */
625 rc_keydown_notimeout(ati_remote->rdev, RC_TYPE_OTHER, 625 rc_keydown_notimeout(ati_remote->rdev,
626 RC_PROTO_OTHER,
626 scancode, data[2]); 627 scancode, data[2]);
627 rc_keyup(ati_remote->rdev); 628 rc_keyup(ati_remote->rdev);
628 } 629 }
@@ -760,13 +761,13 @@ static void ati_remote_rc_init(struct ati_remote *ati_remote)
760 struct rc_dev *rdev = ati_remote->rdev; 761 struct rc_dev *rdev = ati_remote->rdev;
761 762
762 rdev->priv = ati_remote; 763 rdev->priv = ati_remote;
763 rdev->allowed_protocols = RC_BIT_OTHER; 764 rdev->allowed_protocols = RC_PROTO_BIT_OTHER;
764 rdev->driver_name = "ati_remote"; 765 rdev->driver_name = "ati_remote";
765 766
766 rdev->open = ati_remote_rc_open; 767 rdev->open = ati_remote_rc_open;
767 rdev->close = ati_remote_rc_close; 768 rdev->close = ati_remote_rc_close;
768 769
769 rdev->input_name = ati_remote->rc_name; 770 rdev->device_name = ati_remote->rc_name;
770 rdev->input_phys = ati_remote->rc_phys; 771 rdev->input_phys = ati_remote->rc_phys;
771 772
772 usb_to_input_id(ati_remote->udev, &rdev->input_id); 773 usb_to_input_id(ati_remote->udev, &rdev->input_id);
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index 60da963f40dc..af7ba23e16e1 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -1053,14 +1053,14 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1053 if (!dev->hw_learning_and_tx_capable) 1053 if (!dev->hw_learning_and_tx_capable)
1054 learning_mode_force = false; 1054 learning_mode_force = false;
1055 1055
1056 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 1056 rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
1057 rdev->priv = dev; 1057 rdev->priv = dev;
1058 rdev->open = ene_open; 1058 rdev->open = ene_open;
1059 rdev->close = ene_close; 1059 rdev->close = ene_close;
1060 rdev->s_idle = ene_set_idle; 1060 rdev->s_idle = ene_set_idle;
1061 rdev->driver_name = ENE_DRIVER_NAME; 1061 rdev->driver_name = ENE_DRIVER_NAME;
1062 rdev->map_name = RC_MAP_RC6_MCE; 1062 rdev->map_name = RC_MAP_RC6_MCE;
1063 rdev->input_name = "ENE eHome Infrared Remote Receiver"; 1063 rdev->device_name = "ENE eHome Infrared Remote Receiver";
1064 1064
1065 if (dev->hw_learning_and_tx_capable) { 1065 if (dev->hw_learning_and_tx_capable) {
1066 rdev->s_learning_mode = ene_set_learning_mode; 1066 rdev->s_learning_mode = ene_set_learning_mode;
@@ -1070,7 +1070,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1070 rdev->s_tx_carrier = ene_set_tx_carrier; 1070 rdev->s_tx_carrier = ene_set_tx_carrier;
1071 rdev->s_tx_duty_cycle = ene_set_tx_duty_cycle; 1071 rdev->s_tx_duty_cycle = ene_set_tx_duty_cycle;
1072 rdev->s_carrier_report = ene_set_carrier_report; 1072 rdev->s_carrier_report = ene_set_carrier_report;
1073 rdev->input_name = "ENE eHome Infrared Remote Transceiver"; 1073 rdev->device_name = "ENE eHome Infrared Remote Transceiver";
1074 } 1074 }
1075 1075
1076 dev->rdev = rdev; 1076 dev->rdev = rdev;
diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c
index 0d3562712f27..f2639d0c2fca 100644
--- a/drivers/media/rc/fintek-cir.c
+++ b/drivers/media/rc/fintek-cir.c
@@ -529,10 +529,10 @@ static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id
529 529
530 /* Set up the rc device */ 530 /* Set up the rc device */
531 rdev->priv = fintek; 531 rdev->priv = fintek;
532 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 532 rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
533 rdev->open = fintek_open; 533 rdev->open = fintek_open;
534 rdev->close = fintek_close; 534 rdev->close = fintek_close;
535 rdev->input_name = FINTEK_DESCRIPTION; 535 rdev->device_name = FINTEK_DESCRIPTION;
536 rdev->input_phys = "fintek/cir0"; 536 rdev->input_phys = "fintek/cir0";
537 rdev->input_id.bustype = BUS_HOST; 537 rdev->input_id.bustype = BUS_HOST;
538 rdev->input_id.vendor = VENDOR_ID_FINTEK; 538 rdev->input_id.vendor = VENDOR_ID_FINTEK;
diff --git a/drivers/media/rc/gpio-ir-recv.c b/drivers/media/rc/gpio-ir-recv.c
index b4f773b9dc1d..7248b3662285 100644
--- a/drivers/media/rc/gpio-ir-recv.c
+++ b/drivers/media/rc/gpio-ir-recv.c
@@ -30,7 +30,6 @@ struct gpio_rc_dev {
30 struct rc_dev *rcdev; 30 struct rc_dev *rcdev;
31 int gpio_nr; 31 int gpio_nr;
32 bool active_low; 32 bool active_low;
33 struct timer_list flush_timer;
34}; 33};
35 34
36#ifdef CONFIG_OF 35#ifdef CONFIG_OF
@@ -77,7 +76,6 @@ static irqreturn_t gpio_ir_recv_irq(int irq, void *dev_id)
77 struct gpio_rc_dev *gpio_dev = dev_id; 76 struct gpio_rc_dev *gpio_dev = dev_id;
78 int gval; 77 int gval;
79 int rc = 0; 78 int rc = 0;
80 enum raw_event_type type = IR_SPACE;
81 79
82 gval = gpio_get_value(gpio_dev->gpio_nr); 80 gval = gpio_get_value(gpio_dev->gpio_nr);
83 81
@@ -87,33 +85,14 @@ static irqreturn_t gpio_ir_recv_irq(int irq, void *dev_id)
87 if (gpio_dev->active_low) 85 if (gpio_dev->active_low)
88 gval = !gval; 86 gval = !gval;
89 87
90 if (gval == 1) 88 rc = ir_raw_event_store_edge(gpio_dev->rcdev, gval == 1);
91 type = IR_PULSE;
92
93 rc = ir_raw_event_store_edge(gpio_dev->rcdev, type);
94 if (rc < 0) 89 if (rc < 0)
95 goto err_get_value; 90 goto err_get_value;
96 91
97 mod_timer(&gpio_dev->flush_timer,
98 jiffies + nsecs_to_jiffies(gpio_dev->rcdev->timeout));
99
100 ir_raw_event_handle(gpio_dev->rcdev);
101
102err_get_value: 92err_get_value:
103 return IRQ_HANDLED; 93 return IRQ_HANDLED;
104} 94}
105 95
106static void flush_timer(unsigned long arg)
107{
108 struct gpio_rc_dev *gpio_dev = (struct gpio_rc_dev *)arg;
109 DEFINE_IR_RAW_EVENT(ev);
110
111 ev.timeout = true;
112 ev.duration = gpio_dev->rcdev->timeout;
113 ir_raw_event_store(gpio_dev->rcdev, &ev);
114 ir_raw_event_handle(gpio_dev->rcdev);
115}
116
117static int gpio_ir_recv_probe(struct platform_device *pdev) 96static int gpio_ir_recv_probe(struct platform_device *pdev)
118{ 97{
119 struct gpio_rc_dev *gpio_dev; 98 struct gpio_rc_dev *gpio_dev;
@@ -150,7 +129,7 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
150 } 129 }
151 130
152 rcdev->priv = gpio_dev; 131 rcdev->priv = gpio_dev;
153 rcdev->input_name = GPIO_IR_DEVICE_NAME; 132 rcdev->device_name = GPIO_IR_DEVICE_NAME;
154 rcdev->input_phys = GPIO_IR_DEVICE_NAME "/input0"; 133 rcdev->input_phys = GPIO_IR_DEVICE_NAME "/input0";
155 rcdev->input_id.bustype = BUS_HOST; 134 rcdev->input_id.bustype = BUS_HOST;
156 rcdev->input_id.vendor = 0x0001; 135 rcdev->input_id.vendor = 0x0001;
@@ -164,16 +143,13 @@ static int gpio_ir_recv_probe(struct platform_device *pdev)
164 if (pdata->allowed_protos) 143 if (pdata->allowed_protos)
165 rcdev->allowed_protocols = pdata->allowed_protos; 144 rcdev->allowed_protocols = pdata->allowed_protos;
166 else 145 else
167 rcdev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 146 rcdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
168 rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY; 147 rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY;
169 148
170 gpio_dev->rcdev = rcdev; 149 gpio_dev->rcdev = rcdev;
171 gpio_dev->gpio_nr = pdata->gpio_nr; 150 gpio_dev->gpio_nr = pdata->gpio_nr;
172 gpio_dev->active_low = pdata->active_low; 151 gpio_dev->active_low = pdata->active_low;
173 152
174 setup_timer(&gpio_dev->flush_timer, flush_timer,
175 (unsigned long)gpio_dev);
176
177 rc = gpio_request(pdata->gpio_nr, "gpio-ir-recv"); 153 rc = gpio_request(pdata->gpio_nr, "gpio-ir-recv");
178 if (rc < 0) 154 if (rc < 0)
179 goto err_gpio_request; 155 goto err_gpio_request;
@@ -216,7 +192,6 @@ static int gpio_ir_recv_remove(struct platform_device *pdev)
216 struct gpio_rc_dev *gpio_dev = platform_get_drvdata(pdev); 192 struct gpio_rc_dev *gpio_dev = platform_get_drvdata(pdev);
217 193
218 free_irq(gpio_to_irq(gpio_dev->gpio_nr), gpio_dev); 194 free_irq(gpio_to_irq(gpio_dev->gpio_nr), gpio_dev);
219 del_timer_sync(&gpio_dev->flush_timer);
220 rc_unregister_device(gpio_dev->rcdev); 195 rc_unregister_device(gpio_dev->rcdev);
221 gpio_free(gpio_dev->gpio_nr); 196 gpio_free(gpio_dev->gpio_nr);
222 kfree(gpio_dev); 197 kfree(gpio_dev);
diff --git a/drivers/media/rc/gpio-ir-tx.c b/drivers/media/rc/gpio-ir-tx.c
new file mode 100644
index 000000000000..cd476cab9782
--- /dev/null
+++ b/drivers/media/rc/gpio-ir-tx.c
@@ -0,0 +1,176 @@
1/*
2 * Copyright (C) 2017 Sean Young <sean@mess.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/kernel.h>
15#include <linux/module.h>
16#include <linux/gpio/consumer.h>
17#include <linux/delay.h>
18#include <linux/slab.h>
19#include <linux/of.h>
20#include <linux/platform_device.h>
21#include <media/rc-core.h>
22
23#define DRIVER_NAME "gpio-ir-tx"
24#define DEVICE_NAME "GPIO IR Bit Banging Transmitter"
25
26struct gpio_ir {
27 struct gpio_desc *gpio;
28 unsigned int carrier;
29 unsigned int duty_cycle;
30 /* we need a spinlock to hold the cpu while transmitting */
31 spinlock_t lock;
32};
33
34static const struct of_device_id gpio_ir_tx_of_match[] = {
35 { .compatible = "gpio-ir-tx", },
36 { },
37};
38MODULE_DEVICE_TABLE(of, gpio_ir_tx_of_match);
39
40static int gpio_ir_tx_set_duty_cycle(struct rc_dev *dev, u32 duty_cycle)
41{
42 struct gpio_ir *gpio_ir = dev->priv;
43
44 gpio_ir->duty_cycle = duty_cycle;
45
46 return 0;
47}
48
49static int gpio_ir_tx_set_carrier(struct rc_dev *dev, u32 carrier)
50{
51 struct gpio_ir *gpio_ir = dev->priv;
52
53 if (!carrier)
54 return -EINVAL;
55
56 gpio_ir->carrier = carrier;
57
58 return 0;
59}
60
61static int gpio_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
62 unsigned int count)
63{
64 struct gpio_ir *gpio_ir = dev->priv;
65 unsigned long flags;
66 ktime_t edge;
67 /*
68 * delta should never exceed 0.5 seconds (IR_MAX_DURATION) and on
69 * m68k ndelay(s64) does not compile; so use s32 rather than s64.
70 */
71 s32 delta;
72 int i;
73 unsigned int pulse, space;
74
75 /* Ensure the dividend fits into 32 bit */
76 pulse = DIV_ROUND_CLOSEST(gpio_ir->duty_cycle * (NSEC_PER_SEC / 100),
77 gpio_ir->carrier);
78 space = DIV_ROUND_CLOSEST((100 - gpio_ir->duty_cycle) *
79 (NSEC_PER_SEC / 100), gpio_ir->carrier);
80
81 spin_lock_irqsave(&gpio_ir->lock, flags);
82
83 edge = ktime_get();
84
85 for (i = 0; i < count; i++) {
86 if (i % 2) {
87 // space
88 edge = ktime_add_us(edge, txbuf[i]);
89 delta = ktime_us_delta(edge, ktime_get());
90 if (delta > 10) {
91 spin_unlock_irqrestore(&gpio_ir->lock, flags);
92 usleep_range(delta, delta + 10);
93 spin_lock_irqsave(&gpio_ir->lock, flags);
94 } else if (delta > 0) {
95 udelay(delta);
96 }
97 } else {
98 // pulse
99 ktime_t last = ktime_add_us(edge, txbuf[i]);
100
101 while (ktime_before(ktime_get(), last)) {
102 gpiod_set_value(gpio_ir->gpio, 1);
103 edge = ktime_add_ns(edge, pulse);
104 delta = ktime_to_ns(ktime_sub(edge,
105 ktime_get()));
106 if (delta > 0)
107 ndelay(delta);
108 gpiod_set_value(gpio_ir->gpio, 0);
109 edge = ktime_add_ns(edge, space);
110 delta = ktime_to_ns(ktime_sub(edge,
111 ktime_get()));
112 if (delta > 0)
113 ndelay(delta);
114 }
115
116 edge = last;
117 }
118 }
119
120 spin_unlock_irqrestore(&gpio_ir->lock, flags);
121
122 return count;
123}
124
125static int gpio_ir_tx_probe(struct platform_device *pdev)
126{
127 struct gpio_ir *gpio_ir;
128 struct rc_dev *rcdev;
129 int rc;
130
131 gpio_ir = devm_kmalloc(&pdev->dev, sizeof(*gpio_ir), GFP_KERNEL);
132 if (!gpio_ir)
133 return -ENOMEM;
134
135 rcdev = devm_rc_allocate_device(&pdev->dev, RC_DRIVER_IR_RAW_TX);
136 if (!rcdev)
137 return -ENOMEM;
138
139 gpio_ir->gpio = devm_gpiod_get(&pdev->dev, NULL, GPIOD_OUT_LOW);
140 if (IS_ERR(gpio_ir->gpio)) {
141 if (PTR_ERR(gpio_ir->gpio) != -EPROBE_DEFER)
142 dev_err(&pdev->dev, "Failed to get gpio (%ld)\n",
143 PTR_ERR(gpio_ir->gpio));
144 return PTR_ERR(gpio_ir->gpio);
145 }
146
147 rcdev->priv = gpio_ir;
148 rcdev->driver_name = DRIVER_NAME;
149 rcdev->device_name = DEVICE_NAME;
150 rcdev->tx_ir = gpio_ir_tx;
151 rcdev->s_tx_duty_cycle = gpio_ir_tx_set_duty_cycle;
152 rcdev->s_tx_carrier = gpio_ir_tx_set_carrier;
153
154 gpio_ir->carrier = 38000;
155 gpio_ir->duty_cycle = 50;
156 spin_lock_init(&gpio_ir->lock);
157
158 rc = devm_rc_register_device(&pdev->dev, rcdev);
159 if (rc < 0)
160 dev_err(&pdev->dev, "failed to register rc device\n");
161
162 return rc;
163}
164
165static struct platform_driver gpio_ir_tx_driver = {
166 .probe = gpio_ir_tx_probe,
167 .driver = {
168 .name = DRIVER_NAME,
169 .of_match_table = of_match_ptr(gpio_ir_tx_of_match),
170 },
171};
172module_platform_driver(gpio_ir_tx_driver);
173
174MODULE_DESCRIPTION("GPIO IR Bit Banging Transmitter");
175MODULE_AUTHOR("Sean Young <sean@mess.org>");
176MODULE_LICENSE("GPL");
diff --git a/drivers/media/rc/igorplugusb.c b/drivers/media/rc/igorplugusb.c
index cb6d4f1247da..a5ea86be8f44 100644
--- a/drivers/media/rc/igorplugusb.c
+++ b/drivers/media/rc/igorplugusb.c
@@ -194,7 +194,7 @@ static int igorplugusb_probe(struct usb_interface *intf,
194 if (!rc) 194 if (!rc)
195 goto fail; 195 goto fail;
196 196
197 rc->input_name = DRIVER_DESC; 197 rc->device_name = DRIVER_DESC;
198 rc->input_phys = ir->phys; 198 rc->input_phys = ir->phys;
199 usb_to_input_id(udev, &rc->input_id); 199 usb_to_input_id(udev, &rc->input_id);
200 rc->dev.parent = &intf->dev; 200 rc->dev.parent = &intf->dev;
@@ -202,10 +202,11 @@ static int igorplugusb_probe(struct usb_interface *intf,
202 * This device can only store 36 pulses + spaces, which is not enough 202 * This device can only store 36 pulses + spaces, which is not enough
203 * for the NEC protocol and many others. 203 * for the NEC protocol and many others.
204 */ 204 */
205 rc->allowed_protocols = RC_BIT_ALL_IR_DECODER & ~(RC_BIT_NEC | 205 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER &
206 RC_BIT_NECX | RC_BIT_NEC32 | RC_BIT_RC6_6A_20 | 206 ~(RC_PROTO_BIT_NEC | RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32 |
207 RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | 207 RC_PROTO_BIT_RC6_6A_20 | RC_PROTO_BIT_RC6_6A_24 |
208 RC_BIT_SONY20 | RC_BIT_SANYO); 208 RC_PROTO_BIT_RC6_6A_32 | RC_PROTO_BIT_RC6_MCE |
209 RC_PROTO_BIT_SONY20 | RC_PROTO_BIT_SANYO);
209 210
210 rc->priv = ir; 211 rc->priv = ir;
211 rc->driver_name = DRIVER_NAME; 212 rc->driver_name = DRIVER_NAME;
diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index 8711a7ff55cc..30e24da67226 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -487,11 +487,11 @@ static int iguanair_probe(struct usb_interface *intf,
487 487
488 usb_make_path(ir->udev, ir->phys, sizeof(ir->phys)); 488 usb_make_path(ir->udev, ir->phys, sizeof(ir->phys));
489 489
490 rc->input_name = ir->name; 490 rc->device_name = ir->name;
491 rc->input_phys = ir->phys; 491 rc->input_phys = ir->phys;
492 usb_to_input_id(ir->udev, &rc->input_id); 492 usb_to_input_id(ir->udev, &rc->input_id);
493 rc->dev.parent = &intf->dev; 493 rc->dev.parent = &intf->dev;
494 rc->allowed_protocols = RC_BIT_ALL_IR_DECODER; 494 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
495 rc->priv = ir; 495 rc->priv = ir;
496 rc->open = iguanair_open; 496 rc->open = iguanair_open;
497 rc->close = iguanair_close; 497 rc->close = iguanair_close;
diff --git a/drivers/media/rc/img-ir/img-ir-hw.c b/drivers/media/rc/img-ir/img-ir-hw.c
index 8d1439622533..82fdf4cc0824 100644
--- a/drivers/media/rc/img-ir/img-ir-hw.c
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -589,7 +589,7 @@ static void img_ir_set_decoder(struct img_ir_priv *priv,
589 /* clear the wakeup scancode filter */ 589 /* clear the wakeup scancode filter */
590 rdev->scancode_wakeup_filter.data = 0; 590 rdev->scancode_wakeup_filter.data = 0;
591 rdev->scancode_wakeup_filter.mask = 0; 591 rdev->scancode_wakeup_filter.mask = 0;
592 rdev->wakeup_protocol = RC_TYPE_UNKNOWN; 592 rdev->wakeup_protocol = RC_PROTO_UNKNOWN;
593 593
594 /* clear raw filters */ 594 /* clear raw filters */
595 _img_ir_set_filter(priv, NULL); 595 _img_ir_set_filter(priv, NULL);
@@ -823,7 +823,7 @@ static void img_ir_handle_data(struct img_ir_priv *priv, u32 len, u64 raw)
823 int ret = IMG_IR_SCANCODE; 823 int ret = IMG_IR_SCANCODE;
824 struct img_ir_scancode_req request; 824 struct img_ir_scancode_req request;
825 825
826 request.protocol = RC_TYPE_UNKNOWN; 826 request.protocol = RC_PROTO_UNKNOWN;
827 request.toggle = 0; 827 request.toggle = 0;
828 828
829 if (dec->scancode) 829 if (dec->scancode)
@@ -1083,7 +1083,7 @@ int img_ir_probe_hw(struct img_ir_priv *priv)
1083 rdev->priv = priv; 1083 rdev->priv = priv;
1084 rdev->map_name = RC_MAP_EMPTY; 1084 rdev->map_name = RC_MAP_EMPTY;
1085 rdev->allowed_protocols = img_ir_allowed_protos(priv); 1085 rdev->allowed_protocols = img_ir_allowed_protos(priv);
1086 rdev->input_name = "IMG Infrared Decoder"; 1086 rdev->device_name = "IMG Infrared Decoder";
1087 rdev->s_filter = img_ir_set_normal_filter; 1087 rdev->s_filter = img_ir_set_normal_filter;
1088 rdev->s_wakeup_filter = img_ir_set_wakeup_filter; 1088 rdev->s_wakeup_filter = img_ir_set_wakeup_filter;
1089 1089
diff --git a/drivers/media/rc/img-ir/img-ir-hw.h b/drivers/media/rc/img-ir/img-ir-hw.h
index 91a297731661..58b68dd6c67d 100644
--- a/drivers/media/rc/img-ir/img-ir-hw.h
+++ b/drivers/media/rc/img-ir/img-ir-hw.h
@@ -135,13 +135,13 @@ struct img_ir_timing_regvals {
135/** 135/**
136 * struct img_ir_scancode_req - Scancode request data. 136 * struct img_ir_scancode_req - Scancode request data.
137 * @protocol: Protocol code of received message (defaults to 137 * @protocol: Protocol code of received message (defaults to
138 * RC_TYPE_UNKNOWN). 138 * RC_PROTO_UNKNOWN).
139 * @scancode: Scan code of received message (must be written by 139 * @scancode: Scan code of received message (must be written by
140 * handler if IMG_IR_SCANCODE is returned). 140 * handler if IMG_IR_SCANCODE is returned).
141 * @toggle: Toggle bit (defaults to 0). 141 * @toggle: Toggle bit (defaults to 0).
142 */ 142 */
143struct img_ir_scancode_req { 143struct img_ir_scancode_req {
144 enum rc_type protocol; 144 enum rc_proto protocol;
145 u32 scancode; 145 u32 scancode;
146 u8 toggle; 146 u8 toggle;
147}; 147};
diff --git a/drivers/media/rc/img-ir/img-ir-jvc.c b/drivers/media/rc/img-ir/img-ir-jvc.c
index d3e2fc0bcfe1..4b07c76fbe1b 100644
--- a/drivers/media/rc/img-ir/img-ir-jvc.c
+++ b/drivers/media/rc/img-ir/img-ir-jvc.c
@@ -23,7 +23,7 @@ static int img_ir_jvc_scancode(int len, u64 raw, u64 enabled_protocols,
23 cust = (raw >> 0) & 0xff; 23 cust = (raw >> 0) & 0xff;
24 data = (raw >> 8) & 0xff; 24 data = (raw >> 8) & 0xff;
25 25
26 request->protocol = RC_TYPE_JVC; 26 request->protocol = RC_PROTO_JVC;
27 request->scancode = cust << 8 | data; 27 request->scancode = cust << 8 | data;
28 return IMG_IR_SCANCODE; 28 return IMG_IR_SCANCODE;
29} 29}
@@ -52,7 +52,7 @@ static int img_ir_jvc_filter(const struct rc_scancode_filter *in,
52 * http://support.jvc.com/consumer/support/documents/RemoteCodes.pdf 52 * http://support.jvc.com/consumer/support/documents/RemoteCodes.pdf
53 */ 53 */
54struct img_ir_decoder img_ir_jvc = { 54struct img_ir_decoder img_ir_jvc = {
55 .type = RC_BIT_JVC, 55 .type = RC_PROTO_BIT_JVC,
56 .control = { 56 .control = {
57 .decoden = 1, 57 .decoden = 1,
58 .code_type = IMG_IR_CODETYPE_PULSEDIST, 58 .code_type = IMG_IR_CODETYPE_PULSEDIST,
diff --git a/drivers/media/rc/img-ir/img-ir-nec.c b/drivers/media/rc/img-ir/img-ir-nec.c
index 044fd42b22a0..2fc0678ad2d7 100644
--- a/drivers/media/rc/img-ir/img-ir-nec.c
+++ b/drivers/media/rc/img-ir/img-ir-nec.c
@@ -35,20 +35,20 @@ static int img_ir_nec_scancode(int len, u64 raw, u64 enabled_protocols,
35 bitrev8(addr_inv) << 16 | 35 bitrev8(addr_inv) << 16 |
36 bitrev8(data) << 8 | 36 bitrev8(data) << 8 |
37 bitrev8(data_inv); 37 bitrev8(data_inv);
38 request->protocol = RC_TYPE_NEC32; 38 request->protocol = RC_PROTO_NEC32;
39 } else if ((addr_inv ^ addr) != 0xff) { 39 } else if ((addr_inv ^ addr) != 0xff) {
40 /* Extended NEC */ 40 /* Extended NEC */
41 /* scan encoding: AAaaDD */ 41 /* scan encoding: AAaaDD */
42 request->scancode = addr << 16 | 42 request->scancode = addr << 16 |
43 addr_inv << 8 | 43 addr_inv << 8 |
44 data; 44 data;
45 request->protocol = RC_TYPE_NECX; 45 request->protocol = RC_PROTO_NECX;
46 } else { 46 } else {
47 /* Normal NEC */ 47 /* Normal NEC */
48 /* scan encoding: AADD */ 48 /* scan encoding: AADD */
49 request->scancode = addr << 8 | 49 request->scancode = addr << 8 |
50 data; 50 data;
51 request->protocol = RC_TYPE_NEC; 51 request->protocol = RC_PROTO_NEC;
52 } 52 }
53 return IMG_IR_SCANCODE; 53 return IMG_IR_SCANCODE;
54} 54}
@@ -63,7 +63,7 @@ static int img_ir_nec_filter(const struct rc_scancode_filter *in,
63 data = in->data & 0xff; 63 data = in->data & 0xff;
64 data_m = in->mask & 0xff; 64 data_m = in->mask & 0xff;
65 65
66 protocols &= RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32; 66 protocols &= RC_PROTO_BIT_NEC | RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32;
67 67
68 /* 68 /*
69 * If only one bit is set, we were requested to do an exact 69 * If only one bit is set, we were requested to do an exact
@@ -72,14 +72,14 @@ static int img_ir_nec_filter(const struct rc_scancode_filter *in,
72 */ 72 */
73 if (!is_power_of_2(protocols)) { 73 if (!is_power_of_2(protocols)) {
74 if ((in->data | in->mask) & 0xff000000) 74 if ((in->data | in->mask) & 0xff000000)
75 protocols = RC_BIT_NEC32; 75 protocols = RC_PROTO_BIT_NEC32;
76 else if ((in->data | in->mask) & 0x00ff0000) 76 else if ((in->data | in->mask) & 0x00ff0000)
77 protocols = RC_BIT_NECX; 77 protocols = RC_PROTO_BIT_NECX;
78 else 78 else
79 protocols = RC_BIT_NEC; 79 protocols = RC_PROTO_BIT_NEC;
80 } 80 }
81 81
82 if (protocols == RC_BIT_NEC32) { 82 if (protocols == RC_PROTO_BIT_NEC32) {
83 /* 32-bit NEC (used by Apple and TiVo remotes) */ 83 /* 32-bit NEC (used by Apple and TiVo remotes) */
84 /* scan encoding: as transmitted, MSBit = first received bit */ 84 /* scan encoding: as transmitted, MSBit = first received bit */
85 addr = bitrev8(in->data >> 24); 85 addr = bitrev8(in->data >> 24);
@@ -90,7 +90,7 @@ static int img_ir_nec_filter(const struct rc_scancode_filter *in,
90 data_m = bitrev8(in->mask >> 8); 90 data_m = bitrev8(in->mask >> 8);
91 data_inv = bitrev8(in->data >> 0); 91 data_inv = bitrev8(in->data >> 0);
92 data_inv_m = bitrev8(in->mask >> 0); 92 data_inv_m = bitrev8(in->mask >> 0);
93 } else if (protocols == RC_BIT_NECX) { 93 } else if (protocols == RC_PROTO_BIT_NECX) {
94 /* Extended NEC */ 94 /* Extended NEC */
95 /* scan encoding AAaaDD */ 95 /* scan encoding AAaaDD */
96 addr = (in->data >> 16) & 0xff; 96 addr = (in->data >> 16) & 0xff;
@@ -128,7 +128,7 @@ static int img_ir_nec_filter(const struct rc_scancode_filter *in,
128 * http://wiki.altium.com/display/ADOH/NEC+Infrared+Transmission+Protocol 128 * http://wiki.altium.com/display/ADOH/NEC+Infrared+Transmission+Protocol
129 */ 129 */
130struct img_ir_decoder img_ir_nec = { 130struct img_ir_decoder img_ir_nec = {
131 .type = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32, 131 .type = RC_PROTO_BIT_NEC | RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32,
132 .control = { 132 .control = {
133 .decoden = 1, 133 .decoden = 1,
134 .code_type = IMG_IR_CODETYPE_PULSEDIST, 134 .code_type = IMG_IR_CODETYPE_PULSEDIST,
diff --git a/drivers/media/rc/img-ir/img-ir-raw.c b/drivers/media/rc/img-ir/img-ir-raw.c
index 8d2f8e2006e7..64714efc1145 100644
--- a/drivers/media/rc/img-ir/img-ir-raw.c
+++ b/drivers/media/rc/img-ir/img-ir-raw.c
@@ -40,9 +40,9 @@ static void img_ir_refresh_raw(struct img_ir_priv *priv, u32 irq_status)
40 40
41 /* report the edge to the IR raw decoders */ 41 /* report the edge to the IR raw decoders */
42 if (ir_status) /* low */ 42 if (ir_status) /* low */
43 ir_raw_event_store_edge(rc_dev, IR_SPACE); 43 ir_raw_event_store_edge(rc_dev, false);
44 else /* high */ 44 else /* high */
45 ir_raw_event_store_edge(rc_dev, IR_PULSE); 45 ir_raw_event_store_edge(rc_dev, true);
46 ir_raw_event_handle(rc_dev); 46 ir_raw_event_handle(rc_dev);
47} 47}
48 48
@@ -117,7 +117,7 @@ int img_ir_probe_raw(struct img_ir_priv *priv)
117 } 117 }
118 rdev->priv = priv; 118 rdev->priv = priv;
119 rdev->map_name = RC_MAP_EMPTY; 119 rdev->map_name = RC_MAP_EMPTY;
120 rdev->input_name = "IMG Infrared Decoder Raw"; 120 rdev->device_name = "IMG Infrared Decoder Raw";
121 121
122 /* Register raw decoder */ 122 /* Register raw decoder */
123 error = rc_register_device(rdev); 123 error = rc_register_device(rdev);
diff --git a/drivers/media/rc/img-ir/img-ir-rc5.c b/drivers/media/rc/img-ir/img-ir-rc5.c
index a8a28a377eee..a1bc8705472b 100644
--- a/drivers/media/rc/img-ir/img-ir-rc5.c
+++ b/drivers/media/rc/img-ir/img-ir-rc5.c
@@ -33,7 +33,7 @@ static int img_ir_rc5_scancode(int len, u64 raw, u64 enabled_protocols,
33 if (!start) 33 if (!start)
34 return -EINVAL; 34 return -EINVAL;
35 35
36 request->protocol = RC_TYPE_RC5; 36 request->protocol = RC_PROTO_RC5;
37 request->scancode = addr << 8 | cmd; 37 request->scancode = addr << 8 | cmd;
38 request->toggle = tgl; 38 request->toggle = tgl;
39 return IMG_IR_SCANCODE; 39 return IMG_IR_SCANCODE;
@@ -52,7 +52,7 @@ static int img_ir_rc5_filter(const struct rc_scancode_filter *in,
52 * see http://www.sbprojects.com/knowledge/ir/rc5.php 52 * see http://www.sbprojects.com/knowledge/ir/rc5.php
53 */ 53 */
54struct img_ir_decoder img_ir_rc5 = { 54struct img_ir_decoder img_ir_rc5 = {
55 .type = RC_BIT_RC5, 55 .type = RC_PROTO_BIT_RC5,
56 .control = { 56 .control = {
57 .bitoriend2 = 1, 57 .bitoriend2 = 1,
58 .code_type = IMG_IR_CODETYPE_BIPHASE, 58 .code_type = IMG_IR_CODETYPE_BIPHASE,
diff --git a/drivers/media/rc/img-ir/img-ir-rc6.c b/drivers/media/rc/img-ir/img-ir-rc6.c
index de1e27534968..5f34f59ca257 100644
--- a/drivers/media/rc/img-ir/img-ir-rc6.c
+++ b/drivers/media/rc/img-ir/img-ir-rc6.c
@@ -54,7 +54,7 @@ static int img_ir_rc6_scancode(int len, u64 raw, u64 enabled_protocols,
54 if (mode) 54 if (mode)
55 return -EINVAL; 55 return -EINVAL;
56 56
57 request->protocol = RC_TYPE_RC6_0; 57 request->protocol = RC_PROTO_RC6_0;
58 request->scancode = addr << 8 | cmd; 58 request->scancode = addr << 8 | cmd;
59 request->toggle = trl2; 59 request->toggle = trl2;
60 return IMG_IR_SCANCODE; 60 return IMG_IR_SCANCODE;
@@ -73,7 +73,7 @@ static int img_ir_rc6_filter(const struct rc_scancode_filter *in,
73 * see http://www.sbprojects.com/knowledge/ir/rc6.php 73 * see http://www.sbprojects.com/knowledge/ir/rc6.php
74 */ 74 */
75struct img_ir_decoder img_ir_rc6 = { 75struct img_ir_decoder img_ir_rc6 = {
76 .type = RC_BIT_RC6_0, 76 .type = RC_PROTO_BIT_RC6_0,
77 .control = { 77 .control = {
78 .bitorien = 1, 78 .bitorien = 1,
79 .code_type = IMG_IR_CODETYPE_BIPHASE, 79 .code_type = IMG_IR_CODETYPE_BIPHASE,
diff --git a/drivers/media/rc/img-ir/img-ir-sanyo.c b/drivers/media/rc/img-ir/img-ir-sanyo.c
index f394994ffc22..55a755bb437c 100644
--- a/drivers/media/rc/img-ir/img-ir-sanyo.c
+++ b/drivers/media/rc/img-ir/img-ir-sanyo.c
@@ -44,7 +44,7 @@ static int img_ir_sanyo_scancode(int len, u64 raw, u64 enabled_protocols,
44 return -EINVAL; 44 return -EINVAL;
45 45
46 /* Normal Sanyo */ 46 /* Normal Sanyo */
47 request->protocol = RC_TYPE_SANYO; 47 request->protocol = RC_PROTO_SANYO;
48 request->scancode = addr << 8 | data; 48 request->scancode = addr << 8 | data;
49 return IMG_IR_SCANCODE; 49 return IMG_IR_SCANCODE;
50} 50}
@@ -80,7 +80,7 @@ static int img_ir_sanyo_filter(const struct rc_scancode_filter *in,
80 80
81/* Sanyo decoder */ 81/* Sanyo decoder */
82struct img_ir_decoder img_ir_sanyo = { 82struct img_ir_decoder img_ir_sanyo = {
83 .type = RC_BIT_SANYO, 83 .type = RC_PROTO_BIT_SANYO,
84 .control = { 84 .control = {
85 .decoden = 1, 85 .decoden = 1,
86 .code_type = IMG_IR_CODETYPE_PULSEDIST, 86 .code_type = IMG_IR_CODETYPE_PULSEDIST,
diff --git a/drivers/media/rc/img-ir/img-ir-sharp.c b/drivers/media/rc/img-ir/img-ir-sharp.c
index fe5acc4f030e..2d2530902cfa 100644
--- a/drivers/media/rc/img-ir/img-ir-sharp.c
+++ b/drivers/media/rc/img-ir/img-ir-sharp.c
@@ -32,7 +32,7 @@ static int img_ir_sharp_scancode(int len, u64 raw, u64 enabled_protocols,
32 /* probably the second half of the message */ 32 /* probably the second half of the message */
33 return -EINVAL; 33 return -EINVAL;
34 34
35 request->protocol = RC_TYPE_SHARP; 35 request->protocol = RC_PROTO_SHARP;
36 request->scancode = addr << 8 | cmd; 36 request->scancode = addr << 8 | cmd;
37 return IMG_IR_SCANCODE; 37 return IMG_IR_SCANCODE;
38} 38}
@@ -73,7 +73,7 @@ static int img_ir_sharp_filter(const struct rc_scancode_filter *in,
73 * See also http://www.sbprojects.com/knowledge/ir/sharp.php 73 * See also http://www.sbprojects.com/knowledge/ir/sharp.php
74 */ 74 */
75struct img_ir_decoder img_ir_sharp = { 75struct img_ir_decoder img_ir_sharp = {
76 .type = RC_BIT_SHARP, 76 .type = RC_PROTO_BIT_SHARP,
77 .control = { 77 .control = {
78 .decoden = 0, 78 .decoden = 0,
79 .decodend2 = 1, 79 .decodend2 = 1,
diff --git a/drivers/media/rc/img-ir/img-ir-sony.c b/drivers/media/rc/img-ir/img-ir-sony.c
index 3fcba271a419..a942d0be908c 100644
--- a/drivers/media/rc/img-ir/img-ir-sony.c
+++ b/drivers/media/rc/img-ir/img-ir-sony.c
@@ -19,32 +19,32 @@ static int img_ir_sony_scancode(int len, u64 raw, u64 enabled_protocols,
19 19
20 switch (len) { 20 switch (len) {
21 case 12: 21 case 12:
22 if (!(enabled_protocols & RC_BIT_SONY12)) 22 if (!(enabled_protocols & RC_PROTO_BIT_SONY12))
23 return -EINVAL; 23 return -EINVAL;
24 func = raw & 0x7f; /* first 7 bits */ 24 func = raw & 0x7f; /* first 7 bits */
25 raw >>= 7; 25 raw >>= 7;
26 dev = raw & 0x1f; /* next 5 bits */ 26 dev = raw & 0x1f; /* next 5 bits */
27 subdev = 0; 27 subdev = 0;
28 request->protocol = RC_TYPE_SONY12; 28 request->protocol = RC_PROTO_SONY12;
29 break; 29 break;
30 case 15: 30 case 15:
31 if (!(enabled_protocols & RC_BIT_SONY15)) 31 if (!(enabled_protocols & RC_PROTO_BIT_SONY15))
32 return -EINVAL; 32 return -EINVAL;
33 func = raw & 0x7f; /* first 7 bits */ 33 func = raw & 0x7f; /* first 7 bits */
34 raw >>= 7; 34 raw >>= 7;
35 dev = raw & 0xff; /* next 8 bits */ 35 dev = raw & 0xff; /* next 8 bits */
36 subdev = 0; 36 subdev = 0;
37 request->protocol = RC_TYPE_SONY15; 37 request->protocol = RC_PROTO_SONY15;
38 break; 38 break;
39 case 20: 39 case 20:
40 if (!(enabled_protocols & RC_BIT_SONY20)) 40 if (!(enabled_protocols & RC_PROTO_BIT_SONY20))
41 return -EINVAL; 41 return -EINVAL;
42 func = raw & 0x7f; /* first 7 bits */ 42 func = raw & 0x7f; /* first 7 bits */
43 raw >>= 7; 43 raw >>= 7;
44 dev = raw & 0x1f; /* next 5 bits */ 44 dev = raw & 0x1f; /* next 5 bits */
45 raw >>= 5; 45 raw >>= 5;
46 subdev = raw & 0xff; /* next 8 bits */ 46 subdev = raw & 0xff; /* next 8 bits */
47 request->protocol = RC_TYPE_SONY20; 47 request->protocol = RC_PROTO_SONY20;
48 break; 48 break;
49 default: 49 default:
50 return -EINVAL; 50 return -EINVAL;
@@ -68,7 +68,8 @@ static int img_ir_sony_filter(const struct rc_scancode_filter *in,
68 func = (in->data >> 0) & 0x7f; 68 func = (in->data >> 0) & 0x7f;
69 func_m = (in->mask >> 0) & 0x7f; 69 func_m = (in->mask >> 0) & 0x7f;
70 70
71 protocols &= RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20; 71 protocols &= RC_PROTO_BIT_SONY12 | RC_PROTO_BIT_SONY15 |
72 RC_PROTO_BIT_SONY20;
72 73
73 /* 74 /*
74 * If only one bit is set, we were requested to do an exact 75 * If only one bit is set, we were requested to do an exact
@@ -77,20 +78,20 @@ static int img_ir_sony_filter(const struct rc_scancode_filter *in,
77 */ 78 */
78 if (!is_power_of_2(protocols)) { 79 if (!is_power_of_2(protocols)) {
79 if (subdev & subdev_m) 80 if (subdev & subdev_m)
80 protocols = RC_BIT_SONY20; 81 protocols = RC_PROTO_BIT_SONY20;
81 else if (dev & dev_m & 0xe0) 82 else if (dev & dev_m & 0xe0)
82 protocols = RC_BIT_SONY15; 83 protocols = RC_PROTO_BIT_SONY15;
83 else 84 else
84 protocols = RC_BIT_SONY12; 85 protocols = RC_PROTO_BIT_SONY12;
85 } 86 }
86 87
87 if (protocols == RC_BIT_SONY20) { 88 if (protocols == RC_PROTO_BIT_SONY20) {
88 /* can't encode subdev and higher device bits */ 89 /* can't encode subdev and higher device bits */
89 if (dev & dev_m & 0xe0) 90 if (dev & dev_m & 0xe0)
90 return -EINVAL; 91 return -EINVAL;
91 len = 20; 92 len = 20;
92 dev_m &= 0x1f; 93 dev_m &= 0x1f;
93 } else if (protocols == RC_BIT_SONY15) { 94 } else if (protocols == RC_PROTO_BIT_SONY15) {
94 len = 15; 95 len = 15;
95 subdev_m = 0; 96 subdev_m = 0;
96 } else { 97 } else {
@@ -128,7 +129,7 @@ static int img_ir_sony_filter(const struct rc_scancode_filter *in,
128 * http://picprojects.org.uk/projects/sirc/sonysirc.pdf 129 * http://picprojects.org.uk/projects/sirc/sonysirc.pdf
129 */ 130 */
130struct img_ir_decoder img_ir_sony = { 131struct img_ir_decoder img_ir_sony = {
131 .type = RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20, 132 .type = RC_PROTO_BIT_SONY12 | RC_PROTO_BIT_SONY15 | RC_PROTO_BIT_SONY20,
132 .control = { 133 .control = {
133 .decoden = 1, 134 .decoden = 1,
134 .code_type = IMG_IR_CODETYPE_PULSELEN, 135 .code_type = IMG_IR_CODETYPE_PULSELEN,
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index bd76534a2749..7b3f31cc63d2 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -148,7 +148,7 @@ struct imon_context {
148 u32 last_keycode; /* last reported input keycode */ 148 u32 last_keycode; /* last reported input keycode */
149 u32 rc_scancode; /* the computed remote scancode */ 149 u32 rc_scancode; /* the computed remote scancode */
150 u8 rc_toggle; /* the computed remote toggle bit */ 150 u8 rc_toggle; /* the computed remote toggle bit */
151 u64 rc_type; /* iMON or MCE (RC6) IR protocol? */ 151 u64 rc_proto; /* iMON or MCE (RC6) IR protocol? */
152 bool release_code; /* some keys send a release code */ 152 bool release_code; /* some keys send a release code */
153 153
154 u8 display_type; /* store the display type */ 154 u8 display_type; /* store the display type */
@@ -911,7 +911,7 @@ static struct attribute *imon_display_sysfs_entries[] = {
911 NULL 911 NULL
912}; 912};
913 913
914static struct attribute_group imon_display_attr_group = { 914static const struct attribute_group imon_display_attr_group = {
915 .attrs = imon_display_sysfs_entries 915 .attrs = imon_display_sysfs_entries
916}; 916};
917 917
@@ -920,7 +920,7 @@ static struct attribute *imon_rf_sysfs_entries[] = {
920 NULL 920 NULL
921}; 921};
922 922
923static struct attribute_group imon_rf_attr_group = { 923static const struct attribute_group imon_rf_attr_group = {
924 .attrs = imon_rf_sysfs_entries 924 .attrs = imon_rf_sysfs_entries
925}; 925};
926 926
@@ -1118,7 +1118,7 @@ static void imon_touch_display_timeout(unsigned long data)
1118 * it is not, so we must acquire it prior to calling send_packet, which 1118 * it is not, so we must acquire it prior to calling send_packet, which
1119 * requires that the lock is held. 1119 * requires that the lock is held.
1120 */ 1120 */
1121static int imon_ir_change_protocol(struct rc_dev *rc, u64 *rc_type) 1121static int imon_ir_change_protocol(struct rc_dev *rc, u64 *rc_proto)
1122{ 1122{
1123 int retval; 1123 int retval;
1124 struct imon_context *ictx = rc->priv; 1124 struct imon_context *ictx = rc->priv;
@@ -1127,25 +1127,25 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 *rc_type)
1127 unsigned char ir_proto_packet[] = { 1127 unsigned char ir_proto_packet[] = {
1128 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 }; 1128 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 };
1129 1129
1130 if (*rc_type && !(*rc_type & rc->allowed_protocols)) 1130 if (*rc_proto && !(*rc_proto & rc->allowed_protocols))
1131 dev_warn(dev, "Looks like you're trying to use an IR protocol this device does not support\n"); 1131 dev_warn(dev, "Looks like you're trying to use an IR protocol this device does not support\n");
1132 1132
1133 if (*rc_type & RC_BIT_RC6_MCE) { 1133 if (*rc_proto & RC_PROTO_BIT_RC6_MCE) {
1134 dev_dbg(dev, "Configuring IR receiver for MCE protocol\n"); 1134 dev_dbg(dev, "Configuring IR receiver for MCE protocol\n");
1135 ir_proto_packet[0] = 0x01; 1135 ir_proto_packet[0] = 0x01;
1136 *rc_type = RC_BIT_RC6_MCE; 1136 *rc_proto = RC_PROTO_BIT_RC6_MCE;
1137 } else if (*rc_type & RC_BIT_OTHER) { 1137 } else if (*rc_proto & RC_PROTO_BIT_OTHER) {
1138 dev_dbg(dev, "Configuring IR receiver for iMON protocol\n"); 1138 dev_dbg(dev, "Configuring IR receiver for iMON protocol\n");
1139 if (!pad_stabilize) 1139 if (!pad_stabilize)
1140 dev_dbg(dev, "PAD stabilize functionality disabled\n"); 1140 dev_dbg(dev, "PAD stabilize functionality disabled\n");
1141 /* ir_proto_packet[0] = 0x00; // already the default */ 1141 /* ir_proto_packet[0] = 0x00; // already the default */
1142 *rc_type = RC_BIT_OTHER; 1142 *rc_proto = RC_PROTO_BIT_OTHER;
1143 } else { 1143 } else {
1144 dev_warn(dev, "Unsupported IR protocol specified, overriding to iMON IR protocol\n"); 1144 dev_warn(dev, "Unsupported IR protocol specified, overriding to iMON IR protocol\n");
1145 if (!pad_stabilize) 1145 if (!pad_stabilize)
1146 dev_dbg(dev, "PAD stabilize functionality disabled\n"); 1146 dev_dbg(dev, "PAD stabilize functionality disabled\n");
1147 /* ir_proto_packet[0] = 0x00; // already the default */ 1147 /* ir_proto_packet[0] = 0x00; // already the default */
1148 *rc_type = RC_BIT_OTHER; 1148 *rc_proto = RC_PROTO_BIT_OTHER;
1149 } 1149 }
1150 1150
1151 memcpy(ictx->usb_tx_buf, &ir_proto_packet, sizeof(ir_proto_packet)); 1151 memcpy(ictx->usb_tx_buf, &ir_proto_packet, sizeof(ir_proto_packet));
@@ -1159,7 +1159,7 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 *rc_type)
1159 if (retval) 1159 if (retval)
1160 goto out; 1160 goto out;
1161 1161
1162 ictx->rc_type = *rc_type; 1162 ictx->rc_proto = *rc_proto;
1163 ictx->pad_mouse = false; 1163 ictx->pad_mouse = false;
1164 1164
1165out: 1165out:
@@ -1435,7 +1435,7 @@ static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf)
1435 rel_x = buf[2]; 1435 rel_x = buf[2];
1436 rel_y = buf[3]; 1436 rel_y = buf[3];
1437 1437
1438 if (ictx->rc_type == RC_BIT_OTHER && pad_stabilize) { 1438 if (ictx->rc_proto == RC_PROTO_BIT_OTHER && pad_stabilize) {
1439 if ((buf[1] == 0) && ((rel_x != 0) || (rel_y != 0))) { 1439 if ((buf[1] == 0) && ((rel_x != 0) || (rel_y != 0))) {
1440 dir = stabilize((int)rel_x, (int)rel_y, 1440 dir = stabilize((int)rel_x, (int)rel_y,
1441 timeout, threshold); 1441 timeout, threshold);
@@ -1502,7 +1502,7 @@ static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf)
1502 buf[0] = 0x01; 1502 buf[0] = 0x01;
1503 buf[1] = buf[4] = buf[5] = buf[6] = buf[7] = 0; 1503 buf[1] = buf[4] = buf[5] = buf[6] = buf[7] = 0;
1504 1504
1505 if (ictx->rc_type == RC_BIT_OTHER && pad_stabilize) { 1505 if (ictx->rc_proto == RC_PROTO_BIT_OTHER && pad_stabilize) {
1506 dir = stabilize((int)rel_x, (int)rel_y, 1506 dir = stabilize((int)rel_x, (int)rel_y,
1507 timeout, threshold); 1507 timeout, threshold);
1508 if (!dir) { 1508 if (!dir) {
@@ -1706,7 +1706,7 @@ static void imon_incoming_scancode(struct imon_context *ictx,
1706 ictx->release_code = false; 1706 ictx->release_code = false;
1707 } else { 1707 } else {
1708 scancode = be32_to_cpu(*((__be32 *)buf)); 1708 scancode = be32_to_cpu(*((__be32 *)buf));
1709 if (ictx->rc_type == RC_BIT_RC6_MCE) { 1709 if (ictx->rc_proto == RC_PROTO_BIT_RC6_MCE) {
1710 ktype = IMON_KEY_IMON; 1710 ktype = IMON_KEY_IMON;
1711 if (buf[0] == 0x80) 1711 if (buf[0] == 0x80)
1712 ktype = IMON_KEY_MCE; 1712 ktype = IMON_KEY_MCE;
@@ -1769,10 +1769,10 @@ static void imon_incoming_scancode(struct imon_context *ictx,
1769 if (press_type == 0) 1769 if (press_type == 0)
1770 rc_keyup(ictx->rdev); 1770 rc_keyup(ictx->rdev);
1771 else { 1771 else {
1772 if (ictx->rc_type == RC_BIT_RC6_MCE || 1772 if (ictx->rc_proto == RC_PROTO_BIT_RC6_MCE ||
1773 ictx->rc_type == RC_BIT_OTHER) 1773 ictx->rc_proto == RC_PROTO_BIT_OTHER)
1774 rc_keydown(ictx->rdev, 1774 rc_keydown(ictx->rdev,
1775 ictx->rc_type == RC_BIT_RC6_MCE ? RC_TYPE_RC6_MCE : RC_TYPE_OTHER, 1775 ictx->rc_proto == RC_PROTO_BIT_RC6_MCE ? RC_PROTO_RC6_MCE : RC_PROTO_OTHER,
1776 ictx->rc_scancode, ictx->rc_toggle); 1776 ictx->rc_scancode, ictx->rc_toggle);
1777 spin_lock_irqsave(&ictx->kc_lock, flags); 1777 spin_lock_irqsave(&ictx->kc_lock, flags);
1778 ictx->last_keycode = ictx->kc; 1778 ictx->last_keycode = ictx->kc;
@@ -1936,7 +1936,7 @@ static void imon_get_ffdc_type(struct imon_context *ictx)
1936{ 1936{
1937 u8 ffdc_cfg_byte = ictx->usb_rx_buf[6]; 1937 u8 ffdc_cfg_byte = ictx->usb_rx_buf[6];
1938 u8 detected_display_type = IMON_DISPLAY_TYPE_NONE; 1938 u8 detected_display_type = IMON_DISPLAY_TYPE_NONE;
1939 u64 allowed_protos = RC_BIT_OTHER; 1939 u64 allowed_protos = RC_PROTO_BIT_OTHER;
1940 1940
1941 switch (ffdc_cfg_byte) { 1941 switch (ffdc_cfg_byte) {
1942 /* iMON Knob, no display, iMON IR + vol knob */ 1942 /* iMON Knob, no display, iMON IR + vol knob */
@@ -1967,27 +1967,27 @@ static void imon_get_ffdc_type(struct imon_context *ictx)
1967 case 0x9e: 1967 case 0x9e:
1968 dev_info(ictx->dev, "0xffdc iMON VFD, MCE IR"); 1968 dev_info(ictx->dev, "0xffdc iMON VFD, MCE IR");
1969 detected_display_type = IMON_DISPLAY_TYPE_VFD; 1969 detected_display_type = IMON_DISPLAY_TYPE_VFD;
1970 allowed_protos = RC_BIT_RC6_MCE; 1970 allowed_protos = RC_PROTO_BIT_RC6_MCE;
1971 break; 1971 break;
1972 /* iMON LCD, MCE IR */ 1972 /* iMON LCD, MCE IR */
1973 case 0x9f: 1973 case 0x9f:
1974 dev_info(ictx->dev, "0xffdc iMON LCD, MCE IR"); 1974 dev_info(ictx->dev, "0xffdc iMON LCD, MCE IR");
1975 detected_display_type = IMON_DISPLAY_TYPE_LCD; 1975 detected_display_type = IMON_DISPLAY_TYPE_LCD;
1976 allowed_protos = RC_BIT_RC6_MCE; 1976 allowed_protos = RC_PROTO_BIT_RC6_MCE;
1977 break; 1977 break;
1978 default: 1978 default:
1979 dev_info(ictx->dev, "Unknown 0xffdc device, defaulting to VFD and iMON IR"); 1979 dev_info(ictx->dev, "Unknown 0xffdc device, defaulting to VFD and iMON IR");
1980 detected_display_type = IMON_DISPLAY_TYPE_VFD; 1980 detected_display_type = IMON_DISPLAY_TYPE_VFD;
1981 /* We don't know which one it is, allow user to set the 1981 /* We don't know which one it is, allow user to set the
1982 * RC6 one from userspace if OTHER wasn't correct. */ 1982 * RC6 one from userspace if OTHER wasn't correct. */
1983 allowed_protos |= RC_BIT_RC6_MCE; 1983 allowed_protos |= RC_PROTO_BIT_RC6_MCE;
1984 break; 1984 break;
1985 } 1985 }
1986 1986
1987 printk(KERN_CONT " (id 0x%02x)\n", ffdc_cfg_byte); 1987 printk(KERN_CONT " (id 0x%02x)\n", ffdc_cfg_byte);
1988 1988
1989 ictx->display_type = detected_display_type; 1989 ictx->display_type = detected_display_type;
1990 ictx->rc_type = allowed_protos; 1990 ictx->rc_proto = allowed_protos;
1991} 1991}
1992 1992
1993static void imon_set_display_type(struct imon_context *ictx) 1993static void imon_set_display_type(struct imon_context *ictx)
@@ -2063,17 +2063,18 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
2063 sizeof(ictx->phys_rdev)); 2063 sizeof(ictx->phys_rdev));
2064 strlcat(ictx->phys_rdev, "/input0", sizeof(ictx->phys_rdev)); 2064 strlcat(ictx->phys_rdev, "/input0", sizeof(ictx->phys_rdev));
2065 2065
2066 rdev->input_name = ictx->name_rdev; 2066 rdev->device_name = ictx->name_rdev;
2067 rdev->input_phys = ictx->phys_rdev; 2067 rdev->input_phys = ictx->phys_rdev;
2068 usb_to_input_id(ictx->usbdev_intf0, &rdev->input_id); 2068 usb_to_input_id(ictx->usbdev_intf0, &rdev->input_id);
2069 rdev->dev.parent = ictx->dev; 2069 rdev->dev.parent = ictx->dev;
2070 2070
2071 rdev->priv = ictx; 2071 rdev->priv = ictx;
2072 if (ictx->dev_descr->flags & IMON_IR_RAW) 2072 if (ictx->dev_descr->flags & IMON_IR_RAW)
2073 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 2073 rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
2074 else 2074 else
2075 /* iMON PAD or MCE */ 2075 /* iMON PAD or MCE */
2076 rdev->allowed_protocols = RC_BIT_OTHER | RC_BIT_RC6_MCE; 2076 rdev->allowed_protocols = RC_PROTO_BIT_OTHER |
2077 RC_PROTO_BIT_RC6_MCE;
2077 rdev->change_protocol = imon_ir_change_protocol; 2078 rdev->change_protocol = imon_ir_change_protocol;
2078 rdev->driver_name = MOD_NAME; 2079 rdev->driver_name = MOD_NAME;
2079 2080
@@ -2086,12 +2087,12 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
2086 2087
2087 if (ictx->product == 0xffdc) { 2088 if (ictx->product == 0xffdc) {
2088 imon_get_ffdc_type(ictx); 2089 imon_get_ffdc_type(ictx);
2089 rdev->allowed_protocols = ictx->rc_type; 2090 rdev->allowed_protocols = ictx->rc_proto;
2090 } 2091 }
2091 2092
2092 imon_set_display_type(ictx); 2093 imon_set_display_type(ictx);
2093 2094
2094 if (ictx->rc_type == RC_BIT_RC6_MCE || 2095 if (ictx->rc_proto == RC_PROTO_BIT_RC6_MCE ||
2095 ictx->dev_descr->flags & IMON_IR_RAW) 2096 ictx->dev_descr->flags & IMON_IR_RAW)
2096 rdev->map_name = RC_MAP_IMON_MCE; 2097 rdev->map_name = RC_MAP_IMON_MCE;
2097 else 2098 else
diff --git a/drivers/media/rc/ir-hix5hd2.c b/drivers/media/rc/ir-hix5hd2.c
index 50951f686852..0ce11c41dfae 100644
--- a/drivers/media/rc/ir-hix5hd2.c
+++ b/drivers/media/rc/ir-hix5hd2.c
@@ -242,14 +242,14 @@ static int hix5hd2_ir_probe(struct platform_device *pdev)
242 clk_prepare_enable(priv->clock); 242 clk_prepare_enable(priv->clock);
243 priv->rate = clk_get_rate(priv->clock); 243 priv->rate = clk_get_rate(priv->clock);
244 244
245 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 245 rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
246 rdev->priv = priv; 246 rdev->priv = priv;
247 rdev->open = hix5hd2_ir_open; 247 rdev->open = hix5hd2_ir_open;
248 rdev->close = hix5hd2_ir_close; 248 rdev->close = hix5hd2_ir_close;
249 rdev->driver_name = IR_HIX5HD2_NAME; 249 rdev->driver_name = IR_HIX5HD2_NAME;
250 map_name = of_get_property(node, "linux,rc-map-name", NULL); 250 map_name = of_get_property(node, "linux,rc-map-name", NULL);
251 rdev->map_name = map_name ?: RC_MAP_EMPTY; 251 rdev->map_name = map_name ?: RC_MAP_EMPTY;
252 rdev->input_name = IR_HIX5HD2_NAME; 252 rdev->device_name = IR_HIX5HD2_NAME;
253 rdev->input_phys = IR_HIX5HD2_NAME "/input0"; 253 rdev->input_phys = IR_HIX5HD2_NAME "/input0";
254 rdev->input_id.bustype = BUS_HOST; 254 rdev->input_id.bustype = BUS_HOST;
255 rdev->input_id.vendor = 0x0001; 255 rdev->input_id.vendor = 0x0001;
diff --git a/drivers/media/rc/ir-jvc-decoder.c b/drivers/media/rc/ir-jvc-decoder.c
index 674bf156edcb..e2bd68c42edf 100644
--- a/drivers/media/rc/ir-jvc-decoder.c
+++ b/drivers/media/rc/ir-jvc-decoder.c
@@ -137,7 +137,7 @@ again:
137 scancode = (bitrev8((data->bits >> 8) & 0xff) << 8) | 137 scancode = (bitrev8((data->bits >> 8) & 0xff) << 8) |
138 (bitrev8((data->bits >> 0) & 0xff) << 0); 138 (bitrev8((data->bits >> 0) & 0xff) << 0);
139 IR_dprintk(1, "JVC scancode 0x%04x\n", scancode); 139 IR_dprintk(1, "JVC scancode 0x%04x\n", scancode);
140 rc_keydown(dev, RC_TYPE_JVC, scancode, data->toggle); 140 rc_keydown(dev, RC_PROTO_JVC, scancode, data->toggle);
141 data->first = false; 141 data->first = false;
142 data->old_bits = data->bits; 142 data->old_bits = data->bits;
143 } else if (data->bits == data->old_bits) { 143 } else if (data->bits == data->old_bits) {
@@ -193,7 +193,7 @@ static const struct ir_raw_timings_pd ir_jvc_timings = {
193 * -ENOBUFS if there isn't enough space in the array to fit the 193 * -ENOBUFS if there isn't enough space in the array to fit the
194 * encoding. In this case all @max events will have been written. 194 * encoding. In this case all @max events will have been written.
195 */ 195 */
196static int ir_jvc_encode(enum rc_type protocol, u32 scancode, 196static int ir_jvc_encode(enum rc_proto protocol, u32 scancode,
197 struct ir_raw_event *events, unsigned int max) 197 struct ir_raw_event *events, unsigned int max)
198{ 198{
199 struct ir_raw_event *e = events; 199 struct ir_raw_event *e = events;
@@ -209,7 +209,7 @@ static int ir_jvc_encode(enum rc_type protocol, u32 scancode,
209} 209}
210 210
211static struct ir_raw_handler jvc_handler = { 211static struct ir_raw_handler jvc_handler = {
212 .protocols = RC_BIT_JVC, 212 .protocols = RC_PROTO_BIT_JVC,
213 .decode = ir_jvc_decode, 213 .decode = ir_jvc_decode,
214 .encode = ir_jvc_encode, 214 .encode = ir_jvc_encode,
215}; 215};
diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c
index 6a4d58b88d91..7c572a643656 100644
--- a/drivers/media/rc/ir-mce_kbd-decoder.c
+++ b/drivers/media/rc/ir-mce_kbd-decoder.c
@@ -358,6 +358,9 @@ static int ir_mce_kbd_register(struct rc_dev *dev)
358 struct input_dev *idev; 358 struct input_dev *idev;
359 int i, ret; 359 int i, ret;
360 360
361 if (dev->driver_type == RC_DRIVER_IR_RAW_TX)
362 return 0;
363
361 idev = input_allocate_device(); 364 idev = input_allocate_device();
362 if (!idev) 365 if (!idev)
363 return -ENOMEM; 366 return -ENOMEM;
@@ -413,6 +416,9 @@ static int ir_mce_kbd_unregister(struct rc_dev *dev)
413 struct mce_kbd_dec *mce_kbd = &dev->raw->mce_kbd; 416 struct mce_kbd_dec *mce_kbd = &dev->raw->mce_kbd;
414 struct input_dev *idev = mce_kbd->idev; 417 struct input_dev *idev = mce_kbd->idev;
415 418
419 if (dev->driver_type == RC_DRIVER_IR_RAW_TX)
420 return 0;
421
416 del_timer_sync(&mce_kbd->rx_timeout); 422 del_timer_sync(&mce_kbd->rx_timeout);
417 input_unregister_device(idev); 423 input_unregister_device(idev);
418 424
@@ -438,14 +444,14 @@ static const struct ir_raw_timings_manchester ir_mce_kbd_timings = {
438 * -ENOBUFS if there isn't enough space in the array to fit the 444 * -ENOBUFS if there isn't enough space in the array to fit the
439 * encoding. In this case all @max events will have been written. 445 * encoding. In this case all @max events will have been written.
440 */ 446 */
441static int ir_mce_kbd_encode(enum rc_type protocol, u32 scancode, 447static int ir_mce_kbd_encode(enum rc_proto protocol, u32 scancode,
442 struct ir_raw_event *events, unsigned int max) 448 struct ir_raw_event *events, unsigned int max)
443{ 449{
444 struct ir_raw_event *e = events; 450 struct ir_raw_event *e = events;
445 int len, ret; 451 int len, ret;
446 u64 raw; 452 u64 raw;
447 453
448 if (protocol == RC_TYPE_MCIR2_KBD) { 454 if (protocol == RC_PROTO_MCIR2_KBD) {
449 raw = scancode | 455 raw = scancode |
450 ((u64)MCIR2_KEYBOARD_HEADER << MCIR2_KEYBOARD_NBITS); 456 ((u64)MCIR2_KEYBOARD_HEADER << MCIR2_KEYBOARD_NBITS);
451 len = MCIR2_KEYBOARD_NBITS + MCIR2_HEADER_NBITS + 1; 457 len = MCIR2_KEYBOARD_NBITS + MCIR2_HEADER_NBITS + 1;
@@ -463,7 +469,7 @@ static int ir_mce_kbd_encode(enum rc_type protocol, u32 scancode,
463} 469}
464 470
465static struct ir_raw_handler mce_kbd_handler = { 471static struct ir_raw_handler mce_kbd_handler = {
466 .protocols = RC_BIT_MCIR2_KBD | RC_BIT_MCIR2_MSE, 472 .protocols = RC_PROTO_BIT_MCIR2_KBD | RC_PROTO_BIT_MCIR2_MSE,
467 .decode = ir_mce_kbd_decode, 473 .decode = ir_mce_kbd_decode,
468 .encode = ir_mce_kbd_encode, 474 .encode = ir_mce_kbd_encode,
469 .raw_register = ir_mce_kbd_register, 475 .raw_register = ir_mce_kbd_register,
diff --git a/drivers/media/rc/ir-nec-decoder.c b/drivers/media/rc/ir-nec-decoder.c
index 3ce850314dca..817c18f2ddd1 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -49,9 +49,8 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
49{ 49{
50 struct nec_dec *data = &dev->raw->nec; 50 struct nec_dec *data = &dev->raw->nec;
51 u32 scancode; 51 u32 scancode;
52 enum rc_type rc_type; 52 enum rc_proto rc_proto;
53 u8 address, not_address, command, not_command; 53 u8 address, not_address, command, not_command;
54 bool send_32bits = false;
55 54
56 if (!is_timing_event(ev)) { 55 if (!is_timing_event(ev)) {
57 if (ev.reset) 56 if (ev.reset)
@@ -88,13 +87,9 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
88 data->state = STATE_BIT_PULSE; 87 data->state = STATE_BIT_PULSE;
89 return 0; 88 return 0;
90 } else if (eq_margin(ev.duration, NEC_REPEAT_SPACE, NEC_UNIT / 2)) { 89 } else if (eq_margin(ev.duration, NEC_REPEAT_SPACE, NEC_UNIT / 2)) {
91 if (!dev->keypressed) { 90 rc_repeat(dev);
92 IR_dprintk(1, "Discarding last key repeat: event after key up\n"); 91 IR_dprintk(1, "Repeat last key\n");
93 } else { 92 data->state = STATE_TRAILER_PULSE;
94 rc_repeat(dev);
95 IR_dprintk(1, "Repeat last key\n");
96 data->state = STATE_TRAILER_PULSE;
97 }
98 return 0; 93 return 0;
99 } 94 }
100 95
@@ -161,39 +156,14 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
161 command = bitrev8((data->bits >> 8) & 0xff); 156 command = bitrev8((data->bits >> 8) & 0xff);
162 not_command = bitrev8((data->bits >> 0) & 0xff); 157 not_command = bitrev8((data->bits >> 0) & 0xff);
163 158
164 if ((command ^ not_command) != 0xff) { 159 scancode = ir_nec_bytes_to_scancode(address, not_address,
165 IR_dprintk(1, "NEC checksum error: received 0x%08x\n", 160 command, not_command,
166 data->bits); 161 &rc_proto);
167 send_32bits = true;
168 }
169
170 if (send_32bits) {
171 /* NEC transport, but modified protocol, used by at
172 * least Apple and TiVo remotes */
173 scancode = not_address << 24 |
174 address << 16 |
175 not_command << 8 |
176 command;
177 IR_dprintk(1, "NEC (modified) scancode 0x%08x\n", scancode);
178 rc_type = RC_TYPE_NEC32;
179 } else if ((address ^ not_address) != 0xff) {
180 /* Extended NEC */
181 scancode = address << 16 |
182 not_address << 8 |
183 command;
184 IR_dprintk(1, "NEC (Ext) scancode 0x%06x\n", scancode);
185 rc_type = RC_TYPE_NECX;
186 } else {
187 /* Normal NEC */
188 scancode = address << 8 | command;
189 IR_dprintk(1, "NEC scancode 0x%04x\n", scancode);
190 rc_type = RC_TYPE_NEC;
191 }
192 162
193 if (data->is_nec_x) 163 if (data->is_nec_x)
194 data->necx_repeat = true; 164 data->necx_repeat = true;
195 165
196 rc_keydown(dev, rc_type, scancode, 0); 166 rc_keydown(dev, rc_proto, scancode, 0);
197 data->state = STATE_INACTIVE; 167 data->state = STATE_INACTIVE;
198 return 0; 168 return 0;
199 } 169 }
@@ -210,19 +180,19 @@ static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
210 * @scancode: a single NEC scancode. 180 * @scancode: a single NEC scancode.
211 * @raw: raw data to be modulated. 181 * @raw: raw data to be modulated.
212 */ 182 */
213static u32 ir_nec_scancode_to_raw(enum rc_type protocol, u32 scancode) 183static u32 ir_nec_scancode_to_raw(enum rc_proto protocol, u32 scancode)
214{ 184{
215 unsigned int addr, addr_inv, data, data_inv; 185 unsigned int addr, addr_inv, data, data_inv;
216 186
217 data = scancode & 0xff; 187 data = scancode & 0xff;
218 188
219 if (protocol == RC_TYPE_NEC32) { 189 if (protocol == RC_PROTO_NEC32) {
220 /* 32-bit NEC (used by Apple and TiVo remotes) */ 190 /* 32-bit NEC (used by Apple and TiVo remotes) */
221 /* scan encoding: aaAAddDD */ 191 /* scan encoding: aaAAddDD */
222 addr_inv = (scancode >> 24) & 0xff; 192 addr_inv = (scancode >> 24) & 0xff;
223 addr = (scancode >> 16) & 0xff; 193 addr = (scancode >> 16) & 0xff;
224 data_inv = (scancode >> 8) & 0xff; 194 data_inv = (scancode >> 8) & 0xff;
225 } else if (protocol == RC_TYPE_NECX) { 195 } else if (protocol == RC_PROTO_NECX) {
226 /* Extended NEC */ 196 /* Extended NEC */
227 /* scan encoding AAaaDD */ 197 /* scan encoding AAaaDD */
228 addr = (scancode >> 16) & 0xff; 198 addr = (scancode >> 16) & 0xff;
@@ -266,7 +236,7 @@ static const struct ir_raw_timings_pd ir_nec_timings = {
266 * -ENOBUFS if there isn't enough space in the array to fit the 236 * -ENOBUFS if there isn't enough space in the array to fit the
267 * encoding. In this case all @max events will have been written. 237 * encoding. In this case all @max events will have been written.
268 */ 238 */
269static int ir_nec_encode(enum rc_type protocol, u32 scancode, 239static int ir_nec_encode(enum rc_proto protocol, u32 scancode,
270 struct ir_raw_event *events, unsigned int max) 240 struct ir_raw_event *events, unsigned int max)
271{ 241{
272 struct ir_raw_event *e = events; 242 struct ir_raw_event *e = events;
@@ -285,7 +255,8 @@ static int ir_nec_encode(enum rc_type protocol, u32 scancode,
285} 255}
286 256
287static struct ir_raw_handler nec_handler = { 257static struct ir_raw_handler nec_handler = {
288 .protocols = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32, 258 .protocols = RC_PROTO_BIT_NEC | RC_PROTO_BIT_NECX |
259 RC_PROTO_BIT_NEC32,
289 .decode = ir_nec_decode, 260 .decode = ir_nec_decode,
290 .encode = ir_nec_encode, 261 .encode = ir_nec_encode,
291}; 262};
diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c
index fcfedf95def7..1292f534de43 100644
--- a/drivers/media/rc/ir-rc5-decoder.c
+++ b/drivers/media/rc/ir-rc5-decoder.c
@@ -51,7 +51,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
51 struct rc5_dec *data = &dev->raw->rc5; 51 struct rc5_dec *data = &dev->raw->rc5;
52 u8 toggle; 52 u8 toggle;
53 u32 scancode; 53 u32 scancode;
54 enum rc_type protocol; 54 enum rc_proto protocol;
55 55
56 if (!is_timing_event(ev)) { 56 if (!is_timing_event(ev)) {
57 if (ev.reset) 57 if (ev.reset)
@@ -124,7 +124,7 @@ again:
124 if (data->is_rc5x && data->count == RC5X_NBITS) { 124 if (data->is_rc5x && data->count == RC5X_NBITS) {
125 /* RC5X */ 125 /* RC5X */
126 u8 xdata, command, system; 126 u8 xdata, command, system;
127 if (!(dev->enabled_protocols & RC_BIT_RC5X_20)) { 127 if (!(dev->enabled_protocols & RC_PROTO_BIT_RC5X_20)) {
128 data->state = STATE_INACTIVE; 128 data->state = STATE_INACTIVE;
129 return 0; 129 return 0;
130 } 130 }
@@ -134,12 +134,12 @@ again:
134 toggle = (data->bits & 0x20000) ? 1 : 0; 134 toggle = (data->bits & 0x20000) ? 1 : 0;
135 command += (data->bits & 0x40000) ? 0 : 0x40; 135 command += (data->bits & 0x40000) ? 0 : 0x40;
136 scancode = system << 16 | command << 8 | xdata; 136 scancode = system << 16 | command << 8 | xdata;
137 protocol = RC_TYPE_RC5X_20; 137 protocol = RC_PROTO_RC5X_20;
138 138
139 } else if (!data->is_rc5x && data->count == RC5_NBITS) { 139 } else if (!data->is_rc5x && data->count == RC5_NBITS) {
140 /* RC5 */ 140 /* RC5 */
141 u8 command, system; 141 u8 command, system;
142 if (!(dev->enabled_protocols & RC_BIT_RC5)) { 142 if (!(dev->enabled_protocols & RC_PROTO_BIT_RC5)) {
143 data->state = STATE_INACTIVE; 143 data->state = STATE_INACTIVE;
144 return 0; 144 return 0;
145 } 145 }
@@ -148,12 +148,12 @@ again:
148 toggle = (data->bits & 0x00800) ? 1 : 0; 148 toggle = (data->bits & 0x00800) ? 1 : 0;
149 command += (data->bits & 0x01000) ? 0 : 0x40; 149 command += (data->bits & 0x01000) ? 0 : 0x40;
150 scancode = system << 8 | command; 150 scancode = system << 8 | command;
151 protocol = RC_TYPE_RC5; 151 protocol = RC_PROTO_RC5;
152 152
153 } else if (!data->is_rc5x && data->count == RC5_SZ_NBITS) { 153 } else if (!data->is_rc5x && data->count == RC5_SZ_NBITS) {
154 /* RC5 StreamZap */ 154 /* RC5 StreamZap */
155 u8 command, system; 155 u8 command, system;
156 if (!(dev->enabled_protocols & RC_BIT_RC5_SZ)) { 156 if (!(dev->enabled_protocols & RC_PROTO_BIT_RC5_SZ)) {
157 data->state = STATE_INACTIVE; 157 data->state = STATE_INACTIVE;
158 return 0; 158 return 0;
159 } 159 }
@@ -161,7 +161,7 @@ again:
161 system = (data->bits & 0x02FC0) >> 6; 161 system = (data->bits & 0x02FC0) >> 6;
162 toggle = (data->bits & 0x01000) ? 1 : 0; 162 toggle = (data->bits & 0x01000) ? 1 : 0;
163 scancode = system << 6 | command; 163 scancode = system << 6 | command;
164 protocol = RC_TYPE_RC5_SZ; 164 protocol = RC_PROTO_RC5_SZ;
165 165
166 } else 166 } else
167 break; 167 break;
@@ -221,7 +221,7 @@ static const struct ir_raw_timings_manchester ir_rc5_sz_timings = {
221 * encoding. In this case all @max events will have been written. 221 * encoding. In this case all @max events will have been written.
222 * -EINVAL if the scancode is ambiguous or invalid. 222 * -EINVAL if the scancode is ambiguous or invalid.
223 */ 223 */
224static int ir_rc5_encode(enum rc_type protocol, u32 scancode, 224static int ir_rc5_encode(enum rc_proto protocol, u32 scancode,
225 struct ir_raw_event *events, unsigned int max) 225 struct ir_raw_event *events, unsigned int max)
226{ 226{
227 int ret; 227 int ret;
@@ -229,7 +229,7 @@ static int ir_rc5_encode(enum rc_type protocol, u32 scancode,
229 unsigned int data, xdata, command, commandx, system, pre_space_data; 229 unsigned int data, xdata, command, commandx, system, pre_space_data;
230 230
231 /* Detect protocol and convert scancode to raw data */ 231 /* Detect protocol and convert scancode to raw data */
232 if (protocol == RC_TYPE_RC5) { 232 if (protocol == RC_PROTO_RC5) {
233 /* decode scancode */ 233 /* decode scancode */
234 command = (scancode & 0x003f) >> 0; 234 command = (scancode & 0x003f) >> 0;
235 commandx = (scancode & 0x0040) >> 6; 235 commandx = (scancode & 0x0040) >> 6;
@@ -242,7 +242,7 @@ static int ir_rc5_encode(enum rc_type protocol, u32 scancode,
242 RC5_NBITS, data); 242 RC5_NBITS, data);
243 if (ret < 0) 243 if (ret < 0)
244 return ret; 244 return ret;
245 } else if (protocol == RC_TYPE_RC5X_20) { 245 } else if (protocol == RC_PROTO_RC5X_20) {
246 /* decode scancode */ 246 /* decode scancode */
247 xdata = (scancode & 0x00003f) >> 0; 247 xdata = (scancode & 0x00003f) >> 0;
248 command = (scancode & 0x003f00) >> 8; 248 command = (scancode & 0x003f00) >> 8;
@@ -264,7 +264,7 @@ static int ir_rc5_encode(enum rc_type protocol, u32 scancode,
264 data); 264 data);
265 if (ret < 0) 265 if (ret < 0)
266 return ret; 266 return ret;
267 } else if (protocol == RC_TYPE_RC5_SZ) { 267 } else if (protocol == RC_PROTO_RC5_SZ) {
268 /* RC5-SZ scancode is raw enough for Manchester as it is */ 268 /* RC5-SZ scancode is raw enough for Manchester as it is */
269 ret = ir_raw_gen_manchester(&e, max, &ir_rc5_sz_timings, 269 ret = ir_raw_gen_manchester(&e, max, &ir_rc5_sz_timings,
270 RC5_SZ_NBITS, scancode & 0x2fff); 270 RC5_SZ_NBITS, scancode & 0x2fff);
@@ -278,7 +278,8 @@ static int ir_rc5_encode(enum rc_type protocol, u32 scancode,
278} 278}
279 279
280static struct ir_raw_handler rc5_handler = { 280static struct ir_raw_handler rc5_handler = {
281 .protocols = RC_BIT_RC5 | RC_BIT_RC5X_20 | RC_BIT_RC5_SZ, 281 .protocols = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC5X_20 |
282 RC_PROTO_BIT_RC5_SZ,
282 .decode = ir_rc5_decode, 283 .decode = ir_rc5_decode,
283 .encode = ir_rc5_encode, 284 .encode = ir_rc5_encode,
284}; 285};
diff --git a/drivers/media/rc/ir-rc6-decoder.c b/drivers/media/rc/ir-rc6-decoder.c
index 6fe2268dada0..5d0d2fe3b7a7 100644
--- a/drivers/media/rc/ir-rc6-decoder.c
+++ b/drivers/media/rc/ir-rc6-decoder.c
@@ -88,7 +88,7 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev)
88 struct rc6_dec *data = &dev->raw->rc6; 88 struct rc6_dec *data = &dev->raw->rc6;
89 u32 scancode; 89 u32 scancode;
90 u8 toggle; 90 u8 toggle;
91 enum rc_type protocol; 91 enum rc_proto protocol;
92 92
93 if (!is_timing_event(ev)) { 93 if (!is_timing_event(ev)) {
94 if (ev.reset) 94 if (ev.reset)
@@ -229,7 +229,7 @@ again:
229 case RC6_MODE_0: 229 case RC6_MODE_0:
230 scancode = data->body; 230 scancode = data->body;
231 toggle = data->toggle; 231 toggle = data->toggle;
232 protocol = RC_TYPE_RC6_0; 232 protocol = RC_PROTO_RC6_0;
233 IR_dprintk(1, "RC6(0) scancode 0x%04x (toggle: %u)\n", 233 IR_dprintk(1, "RC6(0) scancode 0x%04x (toggle: %u)\n",
234 scancode, toggle); 234 scancode, toggle);
235 break; 235 break;
@@ -244,20 +244,20 @@ again:
244 scancode = data->body; 244 scancode = data->body;
245 switch (data->count) { 245 switch (data->count) {
246 case 20: 246 case 20:
247 protocol = RC_TYPE_RC6_6A_20; 247 protocol = RC_PROTO_RC6_6A_20;
248 toggle = 0; 248 toggle = 0;
249 break; 249 break;
250 case 24: 250 case 24:
251 protocol = RC_TYPE_RC6_6A_24; 251 protocol = RC_PROTO_RC6_6A_24;
252 toggle = 0; 252 toggle = 0;
253 break; 253 break;
254 case 32: 254 case 32:
255 if ((scancode & RC6_6A_LCC_MASK) == RC6_6A_MCE_CC) { 255 if ((scancode & RC6_6A_LCC_MASK) == RC6_6A_MCE_CC) {
256 protocol = RC_TYPE_RC6_MCE; 256 protocol = RC_PROTO_RC6_MCE;
257 toggle = !!(scancode & RC6_6A_MCE_TOGGLE_MASK); 257 toggle = !!(scancode & RC6_6A_MCE_TOGGLE_MASK);
258 scancode &= ~RC6_6A_MCE_TOGGLE_MASK; 258 scancode &= ~RC6_6A_MCE_TOGGLE_MASK;
259 } else { 259 } else {
260 protocol = RC_TYPE_RC6_6A_32; 260 protocol = RC_PROTO_RC6_6A_32;
261 toggle = 0; 261 toggle = 0;
262 } 262 }
263 break; 263 break;
@@ -322,13 +322,13 @@ static const struct ir_raw_timings_manchester ir_rc6_timings[4] = {
322 * encoding. In this case all @max events will have been written. 322 * encoding. In this case all @max events will have been written.
323 * -EINVAL if the scancode is ambiguous or invalid. 323 * -EINVAL if the scancode is ambiguous or invalid.
324 */ 324 */
325static int ir_rc6_encode(enum rc_type protocol, u32 scancode, 325static int ir_rc6_encode(enum rc_proto protocol, u32 scancode,
326 struct ir_raw_event *events, unsigned int max) 326 struct ir_raw_event *events, unsigned int max)
327{ 327{
328 int ret; 328 int ret;
329 struct ir_raw_event *e = events; 329 struct ir_raw_event *e = events;
330 330
331 if (protocol == RC_TYPE_RC6_0) { 331 if (protocol == RC_PROTO_RC6_0) {
332 /* Modulate the preamble */ 332 /* Modulate the preamble */
333 ret = ir_raw_gen_manchester(&e, max, &ir_rc6_timings[0], 0, 0); 333 ret = ir_raw_gen_manchester(&e, max, &ir_rc6_timings[0], 0, 0);
334 if (ret < 0) 334 if (ret < 0)
@@ -358,14 +358,14 @@ static int ir_rc6_encode(enum rc_type protocol, u32 scancode,
358 int bits; 358 int bits;
359 359
360 switch (protocol) { 360 switch (protocol) {
361 case RC_TYPE_RC6_MCE: 361 case RC_PROTO_RC6_MCE:
362 case RC_TYPE_RC6_6A_32: 362 case RC_PROTO_RC6_6A_32:
363 bits = 32; 363 bits = 32;
364 break; 364 break;
365 case RC_TYPE_RC6_6A_24: 365 case RC_PROTO_RC6_6A_24:
366 bits = 24; 366 bits = 24;
367 break; 367 break;
368 case RC_TYPE_RC6_6A_20: 368 case RC_PROTO_RC6_6A_20:
369 bits = 20; 369 bits = 20;
370 break; 370 break;
371 default: 371 default:
@@ -403,9 +403,9 @@ static int ir_rc6_encode(enum rc_type protocol, u32 scancode,
403} 403}
404 404
405static struct ir_raw_handler rc6_handler = { 405static struct ir_raw_handler rc6_handler = {
406 .protocols = RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | 406 .protocols = RC_PROTO_BIT_RC6_0 | RC_PROTO_BIT_RC6_6A_20 |
407 RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | 407 RC_PROTO_BIT_RC6_6A_24 | RC_PROTO_BIT_RC6_6A_32 |
408 RC_BIT_RC6_MCE, 408 RC_PROTO_BIT_RC6_MCE,
409 .decode = ir_rc6_decode, 409 .decode = ir_rc6_decode,
410 .encode = ir_rc6_encode, 410 .encode = ir_rc6_encode,
411}; 411};
diff --git a/drivers/media/rc/ir-sanyo-decoder.c b/drivers/media/rc/ir-sanyo-decoder.c
index 520bb77dcb62..758c60956850 100644
--- a/drivers/media/rc/ir-sanyo-decoder.c
+++ b/drivers/media/rc/ir-sanyo-decoder.c
@@ -110,13 +110,9 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev)
110 break; 110 break;
111 111
112 if (!data->count && geq_margin(ev.duration, SANYO_REPEAT_SPACE, SANYO_UNIT / 2)) { 112 if (!data->count && geq_margin(ev.duration, SANYO_REPEAT_SPACE, SANYO_UNIT / 2)) {
113 if (!dev->keypressed) { 113 rc_repeat(dev);
114 IR_dprintk(1, "SANYO discarding last key repeat: event after key up\n"); 114 IR_dprintk(1, "SANYO repeat last key\n");
115 } else { 115 data->state = STATE_INACTIVE;
116 rc_repeat(dev);
117 IR_dprintk(1, "SANYO repeat last key\n");
118 data->state = STATE_INACTIVE;
119 }
120 return 0; 116 return 0;
121 } 117 }
122 118
@@ -165,7 +161,7 @@ static int ir_sanyo_decode(struct rc_dev *dev, struct ir_raw_event ev)
165 161
166 scancode = address << 8 | command; 162 scancode = address << 8 | command;
167 IR_dprintk(1, "SANYO scancode: 0x%06x\n", scancode); 163 IR_dprintk(1, "SANYO scancode: 0x%06x\n", scancode);
168 rc_keydown(dev, RC_TYPE_SANYO, scancode, 0); 164 rc_keydown(dev, RC_PROTO_SANYO, scancode, 0);
169 data->state = STATE_INACTIVE; 165 data->state = STATE_INACTIVE;
170 return 0; 166 return 0;
171 } 167 }
@@ -199,7 +195,7 @@ static const struct ir_raw_timings_pd ir_sanyo_timings = {
199 * -ENOBUFS if there isn't enough space in the array to fit the 195 * -ENOBUFS if there isn't enough space in the array to fit the
200 * encoding. In this case all @max events will have been written. 196 * encoding. In this case all @max events will have been written.
201 */ 197 */
202static int ir_sanyo_encode(enum rc_type protocol, u32 scancode, 198static int ir_sanyo_encode(enum rc_proto protocol, u32 scancode,
203 struct ir_raw_event *events, unsigned int max) 199 struct ir_raw_event *events, unsigned int max)
204{ 200{
205 struct ir_raw_event *e = events; 201 struct ir_raw_event *e = events;
@@ -219,7 +215,7 @@ static int ir_sanyo_encode(enum rc_type protocol, u32 scancode,
219} 215}
220 216
221static struct ir_raw_handler sanyo_handler = { 217static struct ir_raw_handler sanyo_handler = {
222 .protocols = RC_BIT_SANYO, 218 .protocols = RC_PROTO_BIT_SANYO,
223 .decode = ir_sanyo_decode, 219 .decode = ir_sanyo_decode,
224 .encode = ir_sanyo_encode, 220 .encode = ir_sanyo_encode,
225}; 221};
diff --git a/drivers/media/rc/ir-sharp-decoder.c b/drivers/media/rc/ir-sharp-decoder.c
index b47e89e2c1bd..ed43a4212479 100644
--- a/drivers/media/rc/ir-sharp-decoder.c
+++ b/drivers/media/rc/ir-sharp-decoder.c
@@ -161,7 +161,7 @@ static int ir_sharp_decode(struct rc_dev *dev, struct ir_raw_event ev)
161 scancode = address << 8 | command; 161 scancode = address << 8 | command;
162 IR_dprintk(1, "Sharp scancode 0x%04x\n", scancode); 162 IR_dprintk(1, "Sharp scancode 0x%04x\n", scancode);
163 163
164 rc_keydown(dev, RC_TYPE_SHARP, scancode, 0); 164 rc_keydown(dev, RC_PROTO_SHARP, scancode, 0);
165 data->state = STATE_INACTIVE; 165 data->state = STATE_INACTIVE;
166 return 0; 166 return 0;
167 } 167 }
@@ -196,7 +196,7 @@ static const struct ir_raw_timings_pd ir_sharp_timings = {
196 * -ENOBUFS if there isn't enough space in the array to fit the 196 * -ENOBUFS if there isn't enough space in the array to fit the
197 * encoding. In this case all @max events will have been written. 197 * encoding. In this case all @max events will have been written.
198 */ 198 */
199static int ir_sharp_encode(enum rc_type protocol, u32 scancode, 199static int ir_sharp_encode(enum rc_proto protocol, u32 scancode,
200 struct ir_raw_event *events, unsigned int max) 200 struct ir_raw_event *events, unsigned int max)
201{ 201{
202 struct ir_raw_event *e = events; 202 struct ir_raw_event *e = events;
@@ -223,7 +223,7 @@ static int ir_sharp_encode(enum rc_type protocol, u32 scancode,
223} 223}
224 224
225static struct ir_raw_handler sharp_handler = { 225static struct ir_raw_handler sharp_handler = {
226 .protocols = RC_BIT_SHARP, 226 .protocols = RC_PROTO_BIT_SHARP,
227 .decode = ir_sharp_decode, 227 .decode = ir_sharp_decode,
228 .encode = ir_sharp_encode, 228 .encode = ir_sharp_encode,
229}; 229};
diff --git a/drivers/media/rc/ir-sony-decoder.c b/drivers/media/rc/ir-sony-decoder.c
index 355fa8198f5a..a47ced763031 100644
--- a/drivers/media/rc/ir-sony-decoder.c
+++ b/drivers/media/rc/ir-sony-decoder.c
@@ -42,7 +42,7 @@ enum sony_state {
42static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev) 42static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
43{ 43{
44 struct sony_dec *data = &dev->raw->sony; 44 struct sony_dec *data = &dev->raw->sony;
45 enum rc_type protocol; 45 enum rc_proto protocol;
46 u32 scancode; 46 u32 scancode;
47 u8 device, subdevice, function; 47 u8 device, subdevice, function;
48 48
@@ -121,31 +121,31 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
121 121
122 switch (data->count) { 122 switch (data->count) {
123 case 12: 123 case 12:
124 if (!(dev->enabled_protocols & RC_BIT_SONY12)) 124 if (!(dev->enabled_protocols & RC_PROTO_BIT_SONY12))
125 goto finish_state_machine; 125 goto finish_state_machine;
126 126
127 device = bitrev8((data->bits << 3) & 0xF8); 127 device = bitrev8((data->bits << 3) & 0xF8);
128 subdevice = 0; 128 subdevice = 0;
129 function = bitrev8((data->bits >> 4) & 0xFE); 129 function = bitrev8((data->bits >> 4) & 0xFE);
130 protocol = RC_TYPE_SONY12; 130 protocol = RC_PROTO_SONY12;
131 break; 131 break;
132 case 15: 132 case 15:
133 if (!(dev->enabled_protocols & RC_BIT_SONY15)) 133 if (!(dev->enabled_protocols & RC_PROTO_BIT_SONY15))
134 goto finish_state_machine; 134 goto finish_state_machine;
135 135
136 device = bitrev8((data->bits >> 0) & 0xFF); 136 device = bitrev8((data->bits >> 0) & 0xFF);
137 subdevice = 0; 137 subdevice = 0;
138 function = bitrev8((data->bits >> 7) & 0xFE); 138 function = bitrev8((data->bits >> 7) & 0xFE);
139 protocol = RC_TYPE_SONY15; 139 protocol = RC_PROTO_SONY15;
140 break; 140 break;
141 case 20: 141 case 20:
142 if (!(dev->enabled_protocols & RC_BIT_SONY20)) 142 if (!(dev->enabled_protocols & RC_PROTO_BIT_SONY20))
143 goto finish_state_machine; 143 goto finish_state_machine;
144 144
145 device = bitrev8((data->bits >> 5) & 0xF8); 145 device = bitrev8((data->bits >> 5) & 0xF8);
146 subdevice = bitrev8((data->bits >> 0) & 0xFF); 146 subdevice = bitrev8((data->bits >> 0) & 0xFF);
147 function = bitrev8((data->bits >> 12) & 0xFE); 147 function = bitrev8((data->bits >> 12) & 0xFE);
148 protocol = RC_TYPE_SONY20; 148 protocol = RC_PROTO_SONY20;
149 break; 149 break;
150 default: 150 default:
151 IR_dprintk(1, "Sony invalid bitcount %u\n", data->count); 151 IR_dprintk(1, "Sony invalid bitcount %u\n", data->count);
@@ -190,17 +190,17 @@ static const struct ir_raw_timings_pl ir_sony_timings = {
190 * -ENOBUFS if there isn't enough space in the array to fit the 190 * -ENOBUFS if there isn't enough space in the array to fit the
191 * encoding. In this case all @max events will have been written. 191 * encoding. In this case all @max events will have been written.
192 */ 192 */
193static int ir_sony_encode(enum rc_type protocol, u32 scancode, 193static int ir_sony_encode(enum rc_proto protocol, u32 scancode,
194 struct ir_raw_event *events, unsigned int max) 194 struct ir_raw_event *events, unsigned int max)
195{ 195{
196 struct ir_raw_event *e = events; 196 struct ir_raw_event *e = events;
197 u32 raw, len; 197 u32 raw, len;
198 int ret; 198 int ret;
199 199
200 if (protocol == RC_TYPE_SONY12) { 200 if (protocol == RC_PROTO_SONY12) {
201 raw = (scancode & 0x7f) | ((scancode & 0x1f0000) >> 9); 201 raw = (scancode & 0x7f) | ((scancode & 0x1f0000) >> 9);
202 len = 12; 202 len = 12;
203 } else if (protocol == RC_TYPE_SONY15) { 203 } else if (protocol == RC_PROTO_SONY15) {
204 raw = (scancode & 0x7f) | ((scancode & 0xff0000) >> 9); 204 raw = (scancode & 0x7f) | ((scancode & 0xff0000) >> 9);
205 len = 15; 205 len = 15;
206 } else { 206 } else {
@@ -217,7 +217,8 @@ static int ir_sony_encode(enum rc_type protocol, u32 scancode,
217} 217}
218 218
219static struct ir_raw_handler sony_handler = { 219static struct ir_raw_handler sony_handler = {
220 .protocols = RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20, 220 .protocols = RC_PROTO_BIT_SONY12 | RC_PROTO_BIT_SONY15 |
221 RC_PROTO_BIT_SONY20,
221 .decode = ir_sony_decode, 222 .decode = ir_sony_decode,
222 .encode = ir_sony_encode, 223 .encode = ir_sony_encode,
223}; 224};
diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c
index 7e383b3fedd5..29ed0638cb74 100644
--- a/drivers/media/rc/ir-spi.c
+++ b/drivers/media/rc/ir-spi.c
@@ -155,6 +155,7 @@ static int ir_spi_probe(struct spi_device *spi)
155 idata->rc->tx_ir = ir_spi_tx; 155 idata->rc->tx_ir = ir_spi_tx;
156 idata->rc->s_tx_carrier = ir_spi_set_tx_carrier; 156 idata->rc->s_tx_carrier = ir_spi_set_tx_carrier;
157 idata->rc->s_tx_duty_cycle = ir_spi_set_duty_cycle; 157 idata->rc->s_tx_duty_cycle = ir_spi_set_duty_cycle;
158 idata->rc->device_name = "IR SPI";
158 idata->rc->driver_name = IR_SPI_DRIVER_NAME; 159 idata->rc->driver_name = IR_SPI_DRIVER_NAME;
159 idata->rc->priv = idata; 160 idata->rc->priv = idata;
160 idata->spi = spi; 161 idata->spi = spi;
diff --git a/drivers/media/rc/ir-xmp-decoder.c b/drivers/media/rc/ir-xmp-decoder.c
index 18596190bbb8..6f464be1c8d7 100644
--- a/drivers/media/rc/ir-xmp-decoder.c
+++ b/drivers/media/rc/ir-xmp-decoder.c
@@ -141,7 +141,7 @@ static int ir_xmp_decode(struct rc_dev *dev, struct ir_raw_event ev)
141 IR_dprintk(1, "XMP scancode 0x%06x\n", scancode); 141 IR_dprintk(1, "XMP scancode 0x%06x\n", scancode);
142 142
143 if (toggle == 0) { 143 if (toggle == 0) {
144 rc_keydown(dev, RC_TYPE_XMP, scancode, 0); 144 rc_keydown(dev, RC_PROTO_XMP, scancode, 0);
145 } else { 145 } else {
146 rc_repeat(dev); 146 rc_repeat(dev);
147 IR_dprintk(1, "Repeat last key\n"); 147 IR_dprintk(1, "Repeat last key\n");
@@ -196,7 +196,7 @@ static int ir_xmp_decode(struct rc_dev *dev, struct ir_raw_event ev)
196} 196}
197 197
198static struct ir_raw_handler xmp_handler = { 198static struct ir_raw_handler xmp_handler = {
199 .protocols = RC_BIT_XMP, 199 .protocols = RC_PROTO_BIT_XMP,
200 .decode = ir_xmp_decode, 200 .decode = ir_xmp_decode,
201}; 201};
202 202
diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
index e9e4befbbebb..65e104c7ddfc 100644
--- a/drivers/media/rc/ite-cir.c
+++ b/drivers/media/rc/ite-cir.c
@@ -1556,7 +1556,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
1556 1556
1557 /* set up ir-core props */ 1557 /* set up ir-core props */
1558 rdev->priv = itdev; 1558 rdev->priv = itdev;
1559 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 1559 rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
1560 rdev->open = ite_open; 1560 rdev->open = ite_open;
1561 rdev->close = ite_close; 1561 rdev->close = ite_close;
1562 rdev->s_idle = ite_s_idle; 1562 rdev->s_idle = ite_s_idle;
@@ -1576,7 +1576,7 @@ static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id
1576 rdev->s_tx_duty_cycle = ite_set_tx_duty_cycle; 1576 rdev->s_tx_duty_cycle = ite_set_tx_duty_cycle;
1577 } 1577 }
1578 1578
1579 rdev->input_name = dev_desc->model; 1579 rdev->device_name = dev_desc->model;
1580 rdev->input_id.bustype = BUS_HOST; 1580 rdev->input_id.bustype = BUS_HOST;
1581 rdev->input_id.vendor = PCI_VENDOR_ID_ITE; 1581 rdev->input_id.vendor = PCI_VENDOR_ID_ITE;
1582 rdev->input_id.product = 0; 1582 rdev->input_id.product = 0;
diff --git a/drivers/media/rc/keymaps/Makefile b/drivers/media/rc/keymaps/Makefile
index 2945f99907b5..af6496d709fb 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -109,4 +109,5 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
109 rc-videomate-tv-pvr.o \ 109 rc-videomate-tv-pvr.o \
110 rc-winfast.o \ 110 rc-winfast.o \
111 rc-winfast-usbii-deluxe.o \ 111 rc-winfast-usbii-deluxe.o \
112 rc-su3000.o 112 rc-su3000.o \
113 rc-zx-irdec.o
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 01d901fbfc8b..2d303c2cee3b 100644
--- a/drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c
+++ b/drivers/media/rc/keymaps/rc-adstech-dvb-t-pci.c
@@ -66,10 +66,10 @@ static struct rc_map_table adstech_dvb_t_pci[] = {
66 66
67static struct rc_map_list adstech_dvb_t_pci_map = { 67static struct rc_map_list adstech_dvb_t_pci_map = {
68 .map = { 68 .map = {
69 .scan = adstech_dvb_t_pci, 69 .scan = adstech_dvb_t_pci,
70 .size = ARRAY_SIZE(adstech_dvb_t_pci), 70 .size = ARRAY_SIZE(adstech_dvb_t_pci),
71 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 71 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
72 .name = RC_MAP_ADSTECH_DVB_T_PCI, 72 .name = RC_MAP_ADSTECH_DVB_T_PCI,
73 } 73 }
74}; 74};
75 75
diff --git a/drivers/media/rc/keymaps/rc-alink-dtu-m.c b/drivers/media/rc/keymaps/rc-alink-dtu-m.c
index 4e6ade8e616f..3818c33734a1 100644
--- a/drivers/media/rc/keymaps/rc-alink-dtu-m.c
+++ b/drivers/media/rc/keymaps/rc-alink-dtu-m.c
@@ -45,10 +45,10 @@ static struct rc_map_table alink_dtu_m[] = {
45 45
46static struct rc_map_list alink_dtu_m_map = { 46static struct rc_map_list alink_dtu_m_map = {
47 .map = { 47 .map = {
48 .scan = alink_dtu_m, 48 .scan = alink_dtu_m,
49 .size = ARRAY_SIZE(alink_dtu_m), 49 .size = ARRAY_SIZE(alink_dtu_m),
50 .rc_type = RC_TYPE_NEC, 50 .rc_proto = RC_PROTO_NEC,
51 .name = RC_MAP_ALINK_DTU_M, 51 .name = RC_MAP_ALINK_DTU_M,
52 } 52 }
53}; 53};
54 54
diff --git a/drivers/media/rc/keymaps/rc-anysee.c b/drivers/media/rc/keymaps/rc-anysee.c
index c735fe10a390..e75e51b34d29 100644
--- a/drivers/media/rc/keymaps/rc-anysee.c
+++ b/drivers/media/rc/keymaps/rc-anysee.c
@@ -70,10 +70,10 @@ static struct rc_map_table anysee[] = {
70 70
71static struct rc_map_list anysee_map = { 71static struct rc_map_list anysee_map = {
72 .map = { 72 .map = {
73 .scan = anysee, 73 .scan = anysee,
74 .size = ARRAY_SIZE(anysee), 74 .size = ARRAY_SIZE(anysee),
75 .rc_type = RC_TYPE_NEC, 75 .rc_proto = RC_PROTO_NEC,
76 .name = RC_MAP_ANYSEE, 76 .name = RC_MAP_ANYSEE,
77 } 77 }
78}; 78};
79 79
diff --git a/drivers/media/rc/keymaps/rc-apac-viewcomp.c b/drivers/media/rc/keymaps/rc-apac-viewcomp.c
index bf9efa007e1c..65bc8957d9c3 100644
--- a/drivers/media/rc/keymaps/rc-apac-viewcomp.c
+++ b/drivers/media/rc/keymaps/rc-apac-viewcomp.c
@@ -57,10 +57,10 @@ static struct rc_map_table apac_viewcomp[] = {
57 57
58static struct rc_map_list apac_viewcomp_map = { 58static struct rc_map_list apac_viewcomp_map = {
59 .map = { 59 .map = {
60 .scan = apac_viewcomp, 60 .scan = apac_viewcomp,
61 .size = ARRAY_SIZE(apac_viewcomp), 61 .size = ARRAY_SIZE(apac_viewcomp),
62 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 62 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
63 .name = RC_MAP_APAC_VIEWCOMP, 63 .name = RC_MAP_APAC_VIEWCOMP,
64 } 64 }
65}; 65};
66 66
diff --git a/drivers/media/rc/keymaps/rc-asus-pc39.c b/drivers/media/rc/keymaps/rc-asus-pc39.c
index 9e674ba5dd4f..530e1d1158d1 100644
--- a/drivers/media/rc/keymaps/rc-asus-pc39.c
+++ b/drivers/media/rc/keymaps/rc-asus-pc39.c
@@ -68,10 +68,10 @@ static struct rc_map_table asus_pc39[] = {
68 68
69static struct rc_map_list asus_pc39_map = { 69static struct rc_map_list asus_pc39_map = {
70 .map = { 70 .map = {
71 .scan = asus_pc39, 71 .scan = asus_pc39,
72 .size = ARRAY_SIZE(asus_pc39), 72 .size = ARRAY_SIZE(asus_pc39),
73 .rc_type = RC_TYPE_RC5, 73 .rc_proto = RC_PROTO_RC5,
74 .name = RC_MAP_ASUS_PC39, 74 .name = RC_MAP_ASUS_PC39,
75 } 75 }
76}; 76};
77 77
diff --git a/drivers/media/rc/keymaps/rc-asus-ps3-100.c b/drivers/media/rc/keymaps/rc-asus-ps3-100.c
index e45de35f528f..c91ba332984c 100644
--- a/drivers/media/rc/keymaps/rc-asus-ps3-100.c
+++ b/drivers/media/rc/keymaps/rc-asus-ps3-100.c
@@ -67,10 +67,10 @@ static struct rc_map_table asus_ps3_100[] = {
67 67
68static struct rc_map_list asus_ps3_100_map = { 68static struct rc_map_list asus_ps3_100_map = {
69.map = { 69.map = {
70 .scan = asus_ps3_100, 70 .scan = asus_ps3_100,
71 .size = ARRAY_SIZE(asus_ps3_100), 71 .size = ARRAY_SIZE(asus_ps3_100),
72 .rc_type = RC_TYPE_RC5, 72 .rc_proto = RC_PROTO_RC5,
73 .name = RC_MAP_ASUS_PS3_100, 73 .name = RC_MAP_ASUS_PS3_100,
74} 74}
75}; 75};
76 76
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 91392d4cfd6d..11b4bdd2392b 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
@@ -46,10 +46,10 @@ static struct rc_map_table ati_tv_wonder_hd_600[] = {
46 46
47static struct rc_map_list ati_tv_wonder_hd_600_map = { 47static struct rc_map_list ati_tv_wonder_hd_600_map = {
48 .map = { 48 .map = {
49 .scan = ati_tv_wonder_hd_600, 49 .scan = ati_tv_wonder_hd_600,
50 .size = ARRAY_SIZE(ati_tv_wonder_hd_600), 50 .size = ARRAY_SIZE(ati_tv_wonder_hd_600),
51 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 51 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
52 .name = RC_MAP_ATI_TV_WONDER_HD_600, 52 .name = RC_MAP_ATI_TV_WONDER_HD_600,
53 } 53 }
54}; 54};
55 55
diff --git a/drivers/media/rc/keymaps/rc-ati-x10.c b/drivers/media/rc/keymaps/rc-ati-x10.c
index 4bdc709ec54d..11f1eb6ad712 100644
--- a/drivers/media/rc/keymaps/rc-ati-x10.c
+++ b/drivers/media/rc/keymaps/rc-ati-x10.c
@@ -114,10 +114,10 @@ static struct rc_map_table ati_x10[] = {
114 114
115static struct rc_map_list ati_x10_map = { 115static struct rc_map_list ati_x10_map = {
116 .map = { 116 .map = {
117 .scan = ati_x10, 117 .scan = ati_x10,
118 .size = ARRAY_SIZE(ati_x10), 118 .size = ARRAY_SIZE(ati_x10),
119 .rc_type = RC_TYPE_OTHER, 119 .rc_proto = RC_PROTO_OTHER,
120 .name = RC_MAP_ATI_X10, 120 .name = RC_MAP_ATI_X10,
121 } 121 }
122}; 122};
123 123
diff --git a/drivers/media/rc/keymaps/rc-avermedia-a16d.c b/drivers/media/rc/keymaps/rc-avermedia-a16d.c
index ff30a71d623e..510dc90ebf49 100644
--- a/drivers/media/rc/keymaps/rc-avermedia-a16d.c
+++ b/drivers/media/rc/keymaps/rc-avermedia-a16d.c
@@ -52,10 +52,10 @@ static struct rc_map_table avermedia_a16d[] = {
52 52
53static struct rc_map_list avermedia_a16d_map = { 53static struct rc_map_list avermedia_a16d_map = {
54 .map = { 54 .map = {
55 .scan = avermedia_a16d, 55 .scan = avermedia_a16d,
56 .size = ARRAY_SIZE(avermedia_a16d), 56 .size = ARRAY_SIZE(avermedia_a16d),
57 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 57 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
58 .name = RC_MAP_AVERMEDIA_A16D, 58 .name = RC_MAP_AVERMEDIA_A16D,
59 } 59 }
60}; 60};
61 61
diff --git a/drivers/media/rc/keymaps/rc-avermedia-cardbus.c b/drivers/media/rc/keymaps/rc-avermedia-cardbus.c
index d7471a6de9b4..4bbc1e68d1b8 100644
--- a/drivers/media/rc/keymaps/rc-avermedia-cardbus.c
+++ b/drivers/media/rc/keymaps/rc-avermedia-cardbus.c
@@ -74,10 +74,10 @@ static struct rc_map_table avermedia_cardbus[] = {
74 74
75static struct rc_map_list avermedia_cardbus_map = { 75static struct rc_map_list avermedia_cardbus_map = {
76 .map = { 76 .map = {
77 .scan = avermedia_cardbus, 77 .scan = avermedia_cardbus,
78 .size = ARRAY_SIZE(avermedia_cardbus), 78 .size = ARRAY_SIZE(avermedia_cardbus),
79 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 79 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
80 .name = RC_MAP_AVERMEDIA_CARDBUS, 80 .name = RC_MAP_AVERMEDIA_CARDBUS,
81 } 81 }
82}; 82};
83 83
diff --git a/drivers/media/rc/keymaps/rc-avermedia-dvbt.c b/drivers/media/rc/keymaps/rc-avermedia-dvbt.c
index e2417d6331fe..f6b8547dbad3 100644
--- a/drivers/media/rc/keymaps/rc-avermedia-dvbt.c
+++ b/drivers/media/rc/keymaps/rc-avermedia-dvbt.c
@@ -55,10 +55,10 @@ static struct rc_map_table avermedia_dvbt[] = {
55 55
56static struct rc_map_list avermedia_dvbt_map = { 56static struct rc_map_list avermedia_dvbt_map = {
57 .map = { 57 .map = {
58 .scan = avermedia_dvbt, 58 .scan = avermedia_dvbt,
59 .size = ARRAY_SIZE(avermedia_dvbt), 59 .size = ARRAY_SIZE(avermedia_dvbt),
60 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 60 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
61 .name = RC_MAP_AVERMEDIA_DVBT, 61 .name = RC_MAP_AVERMEDIA_DVBT,
62 } 62 }
63}; 63};
64 64
diff --git a/drivers/media/rc/keymaps/rc-avermedia-m135a.c b/drivers/media/rc/keymaps/rc-avermedia-m135a.c
index 843598a5f1b5..9882e2cde975 100644
--- a/drivers/media/rc/keymaps/rc-avermedia-m135a.c
+++ b/drivers/media/rc/keymaps/rc-avermedia-m135a.c
@@ -124,10 +124,10 @@ static struct rc_map_table avermedia_m135a[] = {
124 124
125static struct rc_map_list avermedia_m135a_map = { 125static struct rc_map_list avermedia_m135a_map = {
126 .map = { 126 .map = {
127 .scan = avermedia_m135a, 127 .scan = avermedia_m135a,
128 .size = ARRAY_SIZE(avermedia_m135a), 128 .size = ARRAY_SIZE(avermedia_m135a),
129 .rc_type = RC_TYPE_NEC, 129 .rc_proto = RC_PROTO_NEC,
130 .name = RC_MAP_AVERMEDIA_M135A, 130 .name = RC_MAP_AVERMEDIA_M135A,
131 } 131 }
132}; 132};
133 133
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 b24e7481ac21..d86126e10375 100644
--- a/drivers/media/rc/keymaps/rc-avermedia-m733a-rm-k6.c
+++ b/drivers/media/rc/keymaps/rc-avermedia-m733a-rm-k6.c
@@ -72,10 +72,10 @@ static struct rc_map_table avermedia_m733a_rm_k6[] = {
72 72
73static struct rc_map_list avermedia_m733a_rm_k6_map = { 73static struct rc_map_list avermedia_m733a_rm_k6_map = {
74 .map = { 74 .map = {
75 .scan = avermedia_m733a_rm_k6, 75 .scan = avermedia_m733a_rm_k6,
76 .size = ARRAY_SIZE(avermedia_m733a_rm_k6), 76 .size = ARRAY_SIZE(avermedia_m733a_rm_k6),
77 .rc_type = RC_TYPE_NEC, 77 .rc_proto = RC_PROTO_NEC,
78 .name = RC_MAP_AVERMEDIA_M733A_RM_K6, 78 .name = RC_MAP_AVERMEDIA_M733A_RM_K6,
79 } 79 }
80}; 80};
81 81
diff --git a/drivers/media/rc/keymaps/rc-avermedia-rm-ks.c b/drivers/media/rc/keymaps/rc-avermedia-rm-ks.c
index 2583400ca1b4..5d92d36d9174 100644
--- a/drivers/media/rc/keymaps/rc-avermedia-rm-ks.c
+++ b/drivers/media/rc/keymaps/rc-avermedia-rm-ks.c
@@ -56,10 +56,10 @@ static struct rc_map_table avermedia_rm_ks[] = {
56 56
57static struct rc_map_list avermedia_rm_ks_map = { 57static struct rc_map_list avermedia_rm_ks_map = {
58 .map = { 58 .map = {
59 .scan = avermedia_rm_ks, 59 .scan = avermedia_rm_ks,
60 .size = ARRAY_SIZE(avermedia_rm_ks), 60 .size = ARRAY_SIZE(avermedia_rm_ks),
61 .rc_type = RC_TYPE_NEC, 61 .rc_proto = RC_PROTO_NEC,
62 .name = RC_MAP_AVERMEDIA_RM_KS, 62 .name = RC_MAP_AVERMEDIA_RM_KS,
63 } 63 }
64}; 64};
65 65
diff --git a/drivers/media/rc/keymaps/rc-avermedia.c b/drivers/media/rc/keymaps/rc-avermedia.c
index 3f68fbecc188..6503f11c7df5 100644
--- a/drivers/media/rc/keymaps/rc-avermedia.c
+++ b/drivers/media/rc/keymaps/rc-avermedia.c
@@ -63,10 +63,10 @@ static struct rc_map_table avermedia[] = {
63 63
64static struct rc_map_list avermedia_map = { 64static struct rc_map_list avermedia_map = {
65 .map = { 65 .map = {
66 .scan = avermedia, 66 .scan = avermedia,
67 .size = ARRAY_SIZE(avermedia), 67 .size = ARRAY_SIZE(avermedia),
68 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 68 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
69 .name = RC_MAP_AVERMEDIA, 69 .name = RC_MAP_AVERMEDIA,
70 } 70 }
71}; 71};
72 72
diff --git a/drivers/media/rc/keymaps/rc-avertv-303.c b/drivers/media/rc/keymaps/rc-avertv-303.c
index c35bc5b835c4..fbdd7ada57ce 100644
--- a/drivers/media/rc/keymaps/rc-avertv-303.c
+++ b/drivers/media/rc/keymaps/rc-avertv-303.c
@@ -62,10 +62,10 @@ static struct rc_map_table avertv_303[] = {
62 62
63static struct rc_map_list avertv_303_map = { 63static struct rc_map_list avertv_303_map = {
64 .map = { 64 .map = {
65 .scan = avertv_303, 65 .scan = avertv_303,
66 .size = ARRAY_SIZE(avertv_303), 66 .size = ARRAY_SIZE(avertv_303),
67 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 67 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
68 .name = RC_MAP_AVERTV_303, 68 .name = RC_MAP_AVERTV_303,
69 } 69 }
70}; 70};
71 71
diff --git a/drivers/media/rc/keymaps/rc-azurewave-ad-tu700.c b/drivers/media/rc/keymaps/rc-azurewave-ad-tu700.c
index ea7f2d0f31eb..18d7dcb869b0 100644
--- a/drivers/media/rc/keymaps/rc-azurewave-ad-tu700.c
+++ b/drivers/media/rc/keymaps/rc-azurewave-ad-tu700.c
@@ -79,10 +79,10 @@ static struct rc_map_table azurewave_ad_tu700[] = {
79 79
80static struct rc_map_list azurewave_ad_tu700_map = { 80static struct rc_map_list azurewave_ad_tu700_map = {
81 .map = { 81 .map = {
82 .scan = azurewave_ad_tu700, 82 .scan = azurewave_ad_tu700,
83 .size = ARRAY_SIZE(azurewave_ad_tu700), 83 .size = ARRAY_SIZE(azurewave_ad_tu700),
84 .rc_type = RC_TYPE_NEC, 84 .rc_proto = RC_PROTO_NEC,
85 .name = RC_MAP_AZUREWAVE_AD_TU700, 85 .name = RC_MAP_AZUREWAVE_AD_TU700,
86 } 86 }
87}; 87};
88 88
diff --git a/drivers/media/rc/keymaps/rc-behold-columbus.c b/drivers/media/rc/keymaps/rc-behold-columbus.c
index 1fc344e9daa7..d256743be998 100644
--- a/drivers/media/rc/keymaps/rc-behold-columbus.c
+++ b/drivers/media/rc/keymaps/rc-behold-columbus.c
@@ -85,10 +85,10 @@ static struct rc_map_table behold_columbus[] = {
85 85
86static struct rc_map_list behold_columbus_map = { 86static struct rc_map_list behold_columbus_map = {
87 .map = { 87 .map = {
88 .scan = behold_columbus, 88 .scan = behold_columbus,
89 .size = ARRAY_SIZE(behold_columbus), 89 .size = ARRAY_SIZE(behold_columbus),
90 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 90 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
91 .name = RC_MAP_BEHOLD_COLUMBUS, 91 .name = RC_MAP_BEHOLD_COLUMBUS,
92 } 92 }
93}; 93};
94 94
diff --git a/drivers/media/rc/keymaps/rc-behold.c b/drivers/media/rc/keymaps/rc-behold.c
index 520a96f2ff86..93dc795adc67 100644
--- a/drivers/media/rc/keymaps/rc-behold.c
+++ b/drivers/media/rc/keymaps/rc-behold.c
@@ -118,10 +118,10 @@ static struct rc_map_table behold[] = {
118 118
119static struct rc_map_list behold_map = { 119static struct rc_map_list behold_map = {
120 .map = { 120 .map = {
121 .scan = behold, 121 .scan = behold,
122 .size = ARRAY_SIZE(behold), 122 .size = ARRAY_SIZE(behold),
123 .rc_type = RC_TYPE_NEC, 123 .rc_proto = RC_PROTO_NEC,
124 .name = RC_MAP_BEHOLD, 124 .name = RC_MAP_BEHOLD,
125 } 125 }
126}; 126};
127 127
diff --git a/drivers/media/rc/keymaps/rc-budget-ci-old.c b/drivers/media/rc/keymaps/rc-budget-ci-old.c
index b196a5f436a3..81ea1424d9e5 100644
--- a/drivers/media/rc/keymaps/rc-budget-ci-old.c
+++ b/drivers/media/rc/keymaps/rc-budget-ci-old.c
@@ -70,10 +70,10 @@ static struct rc_map_table budget_ci_old[] = {
70 70
71static struct rc_map_list budget_ci_old_map = { 71static struct rc_map_list budget_ci_old_map = {
72 .map = { 72 .map = {
73 .scan = budget_ci_old, 73 .scan = budget_ci_old,
74 .size = ARRAY_SIZE(budget_ci_old), 74 .size = ARRAY_SIZE(budget_ci_old),
75 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 75 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
76 .name = RC_MAP_BUDGET_CI_OLD, 76 .name = RC_MAP_BUDGET_CI_OLD,
77 } 77 }
78}; 78};
79 79
diff --git a/drivers/media/rc/keymaps/rc-cec.c b/drivers/media/rc/keymaps/rc-cec.c
index 354c8e724b8e..76d34abb7c85 100644
--- a/drivers/media/rc/keymaps/rc-cec.c
+++ b/drivers/media/rc/keymaps/rc-cec.c
@@ -160,7 +160,7 @@ static struct rc_map_list cec_map = {
160 .map = { 160 .map = {
161 .scan = cec, 161 .scan = cec,
162 .size = ARRAY_SIZE(cec), 162 .size = ARRAY_SIZE(cec),
163 .rc_type = RC_TYPE_CEC, 163 .rc_proto = RC_PROTO_CEC,
164 .name = RC_MAP_CEC, 164 .name = RC_MAP_CEC,
165 } 165 }
166}; 166};
diff --git a/drivers/media/rc/keymaps/rc-cinergy-1400.c b/drivers/media/rc/keymaps/rc-cinergy-1400.c
index a099c080bf8c..bcb96b3dda85 100644
--- a/drivers/media/rc/keymaps/rc-cinergy-1400.c
+++ b/drivers/media/rc/keymaps/rc-cinergy-1400.c
@@ -61,10 +61,10 @@ static struct rc_map_table cinergy_1400[] = {
61 61
62static struct rc_map_list cinergy_1400_map = { 62static struct rc_map_list cinergy_1400_map = {
63 .map = { 63 .map = {
64 .scan = cinergy_1400, 64 .scan = cinergy_1400,
65 .size = ARRAY_SIZE(cinergy_1400), 65 .size = ARRAY_SIZE(cinergy_1400),
66 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 66 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
67 .name = RC_MAP_CINERGY_1400, 67 .name = RC_MAP_CINERGY_1400,
68 } 68 }
69}; 69};
70 70
diff --git a/drivers/media/rc/keymaps/rc-cinergy.c b/drivers/media/rc/keymaps/rc-cinergy.c
index b0f4328bdd6f..fd56c402aae5 100644
--- a/drivers/media/rc/keymaps/rc-cinergy.c
+++ b/drivers/media/rc/keymaps/rc-cinergy.c
@@ -55,10 +55,10 @@ static struct rc_map_table cinergy[] = {
55 55
56static struct rc_map_list cinergy_map = { 56static struct rc_map_list cinergy_map = {
57 .map = { 57 .map = {
58 .scan = cinergy, 58 .scan = cinergy,
59 .size = ARRAY_SIZE(cinergy), 59 .size = ARRAY_SIZE(cinergy),
60 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 60 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
61 .name = RC_MAP_CINERGY, 61 .name = RC_MAP_CINERGY,
62 } 62 }
63}; 63};
64 64
diff --git a/drivers/media/rc/keymaps/rc-d680-dmb.c b/drivers/media/rc/keymaps/rc-d680-dmb.c
index bb5745d29d8a..2c94b9d88b67 100644
--- a/drivers/media/rc/keymaps/rc-d680-dmb.c
+++ b/drivers/media/rc/keymaps/rc-d680-dmb.c
@@ -51,10 +51,10 @@ static struct rc_map_table rc_map_d680_dmb_table[] = {
51 51
52static struct rc_map_list d680_dmb_map = { 52static struct rc_map_list d680_dmb_map = {
53 .map = { 53 .map = {
54 .scan = rc_map_d680_dmb_table, 54 .scan = rc_map_d680_dmb_table,
55 .size = ARRAY_SIZE(rc_map_d680_dmb_table), 55 .size = ARRAY_SIZE(rc_map_d680_dmb_table),
56 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 56 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
57 .name = RC_MAP_D680_DMB, 57 .name = RC_MAP_D680_DMB,
58 } 58 }
59}; 59};
60 60
diff --git a/drivers/media/rc/keymaps/rc-delock-61959.c b/drivers/media/rc/keymaps/rc-delock-61959.c
index 01bed864f09d..62de69d78d92 100644
--- a/drivers/media/rc/keymaps/rc-delock-61959.c
+++ b/drivers/media/rc/keymaps/rc-delock-61959.c
@@ -58,10 +58,10 @@ static struct rc_map_table delock_61959[] = {
58 58
59static struct rc_map_list delock_61959_map = { 59static struct rc_map_list delock_61959_map = {
60 .map = { 60 .map = {
61 .scan = delock_61959, 61 .scan = delock_61959,
62 .size = ARRAY_SIZE(delock_61959), 62 .size = ARRAY_SIZE(delock_61959),
63 .rc_type = RC_TYPE_NEC, 63 .rc_proto = RC_PROTO_NEC,
64 .name = RC_MAP_DELOCK_61959, 64 .name = RC_MAP_DELOCK_61959,
65 } 65 }
66}; 66};
67 67
diff --git a/drivers/media/rc/keymaps/rc-dib0700-nec.c b/drivers/media/rc/keymaps/rc-dib0700-nec.c
index a0fa543c9f9e..1b4df106b7b5 100644
--- a/drivers/media/rc/keymaps/rc-dib0700-nec.c
+++ b/drivers/media/rc/keymaps/rc-dib0700-nec.c
@@ -101,10 +101,10 @@ static struct rc_map_table dib0700_nec_table[] = {
101 101
102static struct rc_map_list dib0700_nec_map = { 102static struct rc_map_list dib0700_nec_map = {
103 .map = { 103 .map = {
104 .scan = dib0700_nec_table, 104 .scan = dib0700_nec_table,
105 .size = ARRAY_SIZE(dib0700_nec_table), 105 .size = ARRAY_SIZE(dib0700_nec_table),
106 .rc_type = RC_TYPE_NEC, 106 .rc_proto = RC_PROTO_NEC,
107 .name = RC_MAP_DIB0700_NEC_TABLE, 107 .name = RC_MAP_DIB0700_NEC_TABLE,
108 } 108 }
109}; 109};
110 110
diff --git a/drivers/media/rc/keymaps/rc-dib0700-rc5.c b/drivers/media/rc/keymaps/rc-dib0700-rc5.c
index 907941145eb7..b0f8151bb824 100644
--- a/drivers/media/rc/keymaps/rc-dib0700-rc5.c
+++ b/drivers/media/rc/keymaps/rc-dib0700-rc5.c
@@ -212,10 +212,10 @@ static struct rc_map_table dib0700_rc5_table[] = {
212 212
213static struct rc_map_list dib0700_rc5_map = { 213static struct rc_map_list dib0700_rc5_map = {
214 .map = { 214 .map = {
215 .scan = dib0700_rc5_table, 215 .scan = dib0700_rc5_table,
216 .size = ARRAY_SIZE(dib0700_rc5_table), 216 .size = ARRAY_SIZE(dib0700_rc5_table),
217 .rc_type = RC_TYPE_RC5, 217 .rc_proto = RC_PROTO_RC5,
218 .name = RC_MAP_DIB0700_RC5_TABLE, 218 .name = RC_MAP_DIB0700_RC5_TABLE,
219 } 219 }
220}; 220};
221 221
diff --git a/drivers/media/rc/keymaps/rc-digitalnow-tinytwin.c b/drivers/media/rc/keymaps/rc-digitalnow-tinytwin.c
index bed78acb9198..01ca8b39359f 100644
--- a/drivers/media/rc/keymaps/rc-digitalnow-tinytwin.c
+++ b/drivers/media/rc/keymaps/rc-digitalnow-tinytwin.c
@@ -75,10 +75,10 @@ static struct rc_map_table digitalnow_tinytwin[] = {
75 75
76static struct rc_map_list digitalnow_tinytwin_map = { 76static struct rc_map_list digitalnow_tinytwin_map = {
77 .map = { 77 .map = {
78 .scan = digitalnow_tinytwin, 78 .scan = digitalnow_tinytwin,
79 .size = ARRAY_SIZE(digitalnow_tinytwin), 79 .size = ARRAY_SIZE(digitalnow_tinytwin),
80 .rc_type = RC_TYPE_NEC, 80 .rc_proto = RC_PROTO_NEC,
81 .name = RC_MAP_DIGITALNOW_TINYTWIN, 81 .name = RC_MAP_DIGITALNOW_TINYTWIN,
82 } 82 }
83}; 83};
84 84
diff --git a/drivers/media/rc/keymaps/rc-digittrade.c b/drivers/media/rc/keymaps/rc-digittrade.c
index a3b97a1fe223..a54b1d632ca6 100644
--- a/drivers/media/rc/keymaps/rc-digittrade.c
+++ b/drivers/media/rc/keymaps/rc-digittrade.c
@@ -59,10 +59,10 @@ static struct rc_map_table digittrade[] = {
59 59
60static struct rc_map_list digittrade_map = { 60static struct rc_map_list digittrade_map = {
61 .map = { 61 .map = {
62 .scan = digittrade, 62 .scan = digittrade,
63 .size = ARRAY_SIZE(digittrade), 63 .size = ARRAY_SIZE(digittrade),
64 .rc_type = RC_TYPE_NEC, 64 .rc_proto = RC_PROTO_NEC,
65 .name = RC_MAP_DIGITTRADE, 65 .name = RC_MAP_DIGITTRADE,
66 } 66 }
67}; 67};
68 68
diff --git a/drivers/media/rc/keymaps/rc-dm1105-nec.c b/drivers/media/rc/keymaps/rc-dm1105-nec.c
index 46e7ae414cc8..c353445d10ed 100644
--- a/drivers/media/rc/keymaps/rc-dm1105-nec.c
+++ b/drivers/media/rc/keymaps/rc-dm1105-nec.c
@@ -53,10 +53,10 @@ static struct rc_map_table dm1105_nec[] = {
53 53
54static struct rc_map_list dm1105_nec_map = { 54static struct rc_map_list dm1105_nec_map = {
55 .map = { 55 .map = {
56 .scan = dm1105_nec, 56 .scan = dm1105_nec,
57 .size = ARRAY_SIZE(dm1105_nec), 57 .size = ARRAY_SIZE(dm1105_nec),
58 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 58 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
59 .name = RC_MAP_DM1105_NEC, 59 .name = RC_MAP_DM1105_NEC,
60 } 60 }
61}; 61};
62 62
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 d2826b46fea2..5bafd5b70f5e 100644
--- a/drivers/media/rc/keymaps/rc-dntv-live-dvb-t.c
+++ b/drivers/media/rc/keymaps/rc-dntv-live-dvb-t.c
@@ -55,10 +55,10 @@ static struct rc_map_table dntv_live_dvb_t[] = {
55 55
56static struct rc_map_list dntv_live_dvb_t_map = { 56static struct rc_map_list dntv_live_dvb_t_map = {
57 .map = { 57 .map = {
58 .scan = dntv_live_dvb_t, 58 .scan = dntv_live_dvb_t,
59 .size = ARRAY_SIZE(dntv_live_dvb_t), 59 .size = ARRAY_SIZE(dntv_live_dvb_t),
60 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 60 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
61 .name = RC_MAP_DNTV_LIVE_DVB_T, 61 .name = RC_MAP_DNTV_LIVE_DVB_T,
62 } 62 }
63}; 63};
64 64
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 0d74769467b5..360167c8829b 100644
--- a/drivers/media/rc/keymaps/rc-dntv-live-dvbt-pro.c
+++ b/drivers/media/rc/keymaps/rc-dntv-live-dvbt-pro.c
@@ -74,10 +74,10 @@ static struct rc_map_table dntv_live_dvbt_pro[] = {
74 74
75static struct rc_map_list dntv_live_dvbt_pro_map = { 75static struct rc_map_list dntv_live_dvbt_pro_map = {
76 .map = { 76 .map = {
77 .scan = dntv_live_dvbt_pro, 77 .scan = dntv_live_dvbt_pro,
78 .size = ARRAY_SIZE(dntv_live_dvbt_pro), 78 .size = ARRAY_SIZE(dntv_live_dvbt_pro),
79 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 79 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
80 .name = RC_MAP_DNTV_LIVE_DVBT_PRO, 80 .name = RC_MAP_DNTV_LIVE_DVBT_PRO,
81 } 81 }
82}; 82};
83 83
diff --git a/drivers/media/rc/keymaps/rc-dtt200u.c b/drivers/media/rc/keymaps/rc-dtt200u.c
index 25650e9e4664..c932d8b6c509 100644
--- a/drivers/media/rc/keymaps/rc-dtt200u.c
+++ b/drivers/media/rc/keymaps/rc-dtt200u.c
@@ -35,10 +35,10 @@ static struct rc_map_table dtt200u_table[] = {
35 35
36static struct rc_map_list dtt200u_map = { 36static struct rc_map_list dtt200u_map = {
37 .map = { 37 .map = {
38 .scan = dtt200u_table, 38 .scan = dtt200u_table,
39 .size = ARRAY_SIZE(dtt200u_table), 39 .size = ARRAY_SIZE(dtt200u_table),
40 .rc_type = RC_TYPE_NEC, 40 .rc_proto = RC_PROTO_NEC,
41 .name = RC_MAP_DTT200U, 41 .name = RC_MAP_DTT200U,
42 } 42 }
43}; 43};
44 44
diff --git a/drivers/media/rc/keymaps/rc-dvbsky.c b/drivers/media/rc/keymaps/rc-dvbsky.c
index c5115a1165d1..d6c0b4c1e20e 100644
--- a/drivers/media/rc/keymaps/rc-dvbsky.c
+++ b/drivers/media/rc/keymaps/rc-dvbsky.c
@@ -54,10 +54,10 @@ static struct rc_map_table rc5_dvbsky[] = {
54 54
55static struct rc_map_list rc5_dvbsky_map = { 55static struct rc_map_list rc5_dvbsky_map = {
56 .map = { 56 .map = {
57 .scan = rc5_dvbsky, 57 .scan = rc5_dvbsky,
58 .size = ARRAY_SIZE(rc5_dvbsky), 58 .size = ARRAY_SIZE(rc5_dvbsky),
59 .rc_type = RC_TYPE_RC5, 59 .rc_proto = RC_PROTO_RC5,
60 .name = RC_MAP_DVBSKY, 60 .name = RC_MAP_DVBSKY,
61 } 61 }
62}; 62};
63 63
diff --git a/drivers/media/rc/keymaps/rc-dvico-mce.c b/drivers/media/rc/keymaps/rc-dvico-mce.c
index d1e861f4d095..e4cee190b923 100644
--- a/drivers/media/rc/keymaps/rc-dvico-mce.c
+++ b/drivers/media/rc/keymaps/rc-dvico-mce.c
@@ -61,10 +61,10 @@ static struct rc_map_table rc_map_dvico_mce_table[] = {
61 61
62static struct rc_map_list dvico_mce_map = { 62static struct rc_map_list dvico_mce_map = {
63 .map = { 63 .map = {
64 .scan = rc_map_dvico_mce_table, 64 .scan = rc_map_dvico_mce_table,
65 .size = ARRAY_SIZE(rc_map_dvico_mce_table), 65 .size = ARRAY_SIZE(rc_map_dvico_mce_table),
66 .rc_type = RC_TYPE_NEC, 66 .rc_proto = RC_PROTO_NEC,
67 .name = RC_MAP_DVICO_MCE, 67 .name = RC_MAP_DVICO_MCE,
68 } 68 }
69}; 69};
70 70
diff --git a/drivers/media/rc/keymaps/rc-dvico-portable.c b/drivers/media/rc/keymaps/rc-dvico-portable.c
index ac4cb515cbf1..cdd21f54aa61 100644
--- a/drivers/media/rc/keymaps/rc-dvico-portable.c
+++ b/drivers/media/rc/keymaps/rc-dvico-portable.c
@@ -52,10 +52,10 @@ static struct rc_map_table rc_map_dvico_portable_table[] = {
52 52
53static struct rc_map_list dvico_portable_map = { 53static struct rc_map_list dvico_portable_map = {
54 .map = { 54 .map = {
55 .scan = rc_map_dvico_portable_table, 55 .scan = rc_map_dvico_portable_table,
56 .size = ARRAY_SIZE(rc_map_dvico_portable_table), 56 .size = ARRAY_SIZE(rc_map_dvico_portable_table),
57 .rc_type = RC_TYPE_NEC, 57 .rc_proto = RC_PROTO_NEC,
58 .name = RC_MAP_DVICO_PORTABLE, 58 .name = RC_MAP_DVICO_PORTABLE,
59 } 59 }
60}; 60};
61 61
diff --git a/drivers/media/rc/keymaps/rc-em-terratec.c b/drivers/media/rc/keymaps/rc-em-terratec.c
index 7f1e06be175b..18e1a2679c20 100644
--- a/drivers/media/rc/keymaps/rc-em-terratec.c
+++ b/drivers/media/rc/keymaps/rc-em-terratec.c
@@ -46,10 +46,10 @@ static struct rc_map_table em_terratec[] = {
46 46
47static struct rc_map_list em_terratec_map = { 47static struct rc_map_list em_terratec_map = {
48 .map = { 48 .map = {
49 .scan = em_terratec, 49 .scan = em_terratec,
50 .size = ARRAY_SIZE(em_terratec), 50 .size = ARRAY_SIZE(em_terratec),
51 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 51 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
52 .name = RC_MAP_EM_TERRATEC, 52 .name = RC_MAP_EM_TERRATEC,
53 } 53 }
54}; 54};
55 55
diff --git a/drivers/media/rc/keymaps/rc-encore-enltv-fm53.c b/drivers/media/rc/keymaps/rc-encore-enltv-fm53.c
index 4fc3904daf06..72ffd5cb0108 100644
--- a/drivers/media/rc/keymaps/rc-encore-enltv-fm53.c
+++ b/drivers/media/rc/keymaps/rc-encore-enltv-fm53.c
@@ -58,10 +58,10 @@ static struct rc_map_table encore_enltv_fm53[] = {
58 58
59static struct rc_map_list encore_enltv_fm53_map = { 59static struct rc_map_list encore_enltv_fm53_map = {
60 .map = { 60 .map = {
61 .scan = encore_enltv_fm53, 61 .scan = encore_enltv_fm53,
62 .size = ARRAY_SIZE(encore_enltv_fm53), 62 .size = ARRAY_SIZE(encore_enltv_fm53),
63 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 63 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
64 .name = RC_MAP_ENCORE_ENLTV_FM53, 64 .name = RC_MAP_ENCORE_ENLTV_FM53,
65 } 65 }
66}; 66};
67 67
diff --git a/drivers/media/rc/keymaps/rc-encore-enltv.c b/drivers/media/rc/keymaps/rc-encore-enltv.c
index f1914e23d203..e0381e7aa964 100644
--- a/drivers/media/rc/keymaps/rc-encore-enltv.c
+++ b/drivers/media/rc/keymaps/rc-encore-enltv.c
@@ -89,10 +89,10 @@ static struct rc_map_table encore_enltv[] = {
89 89
90static struct rc_map_list encore_enltv_map = { 90static struct rc_map_list encore_enltv_map = {
91 .map = { 91 .map = {
92 .scan = encore_enltv, 92 .scan = encore_enltv,
93 .size = ARRAY_SIZE(encore_enltv), 93 .size = ARRAY_SIZE(encore_enltv),
94 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 94 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
95 .name = RC_MAP_ENCORE_ENLTV, 95 .name = RC_MAP_ENCORE_ENLTV,
96 } 96 }
97}; 97};
98 98
diff --git a/drivers/media/rc/keymaps/rc-encore-enltv2.c b/drivers/media/rc/keymaps/rc-encore-enltv2.c
index 9c6c55240d18..e9b0bfba319c 100644
--- a/drivers/media/rc/keymaps/rc-encore-enltv2.c
+++ b/drivers/media/rc/keymaps/rc-encore-enltv2.c
@@ -67,10 +67,10 @@ static struct rc_map_table encore_enltv2[] = {
67 67
68static struct rc_map_list encore_enltv2_map = { 68static struct rc_map_list encore_enltv2_map = {
69 .map = { 69 .map = {
70 .scan = encore_enltv2, 70 .scan = encore_enltv2,
71 .size = ARRAY_SIZE(encore_enltv2), 71 .size = ARRAY_SIZE(encore_enltv2),
72 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 72 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
73 .name = RC_MAP_ENCORE_ENLTV2, 73 .name = RC_MAP_ENCORE_ENLTV2,
74 } 74 }
75}; 75};
76 76
diff --git a/drivers/media/rc/keymaps/rc-evga-indtube.c b/drivers/media/rc/keymaps/rc-evga-indtube.c
index 2370d2a3deb6..b77c5e908668 100644
--- a/drivers/media/rc/keymaps/rc-evga-indtube.c
+++ b/drivers/media/rc/keymaps/rc-evga-indtube.c
@@ -38,10 +38,10 @@ static struct rc_map_table evga_indtube[] = {
38 38
39static struct rc_map_list evga_indtube_map = { 39static struct rc_map_list evga_indtube_map = {
40 .map = { 40 .map = {
41 .scan = evga_indtube, 41 .scan = evga_indtube,
42 .size = ARRAY_SIZE(evga_indtube), 42 .size = ARRAY_SIZE(evga_indtube),
43 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 43 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
44 .name = RC_MAP_EVGA_INDTUBE, 44 .name = RC_MAP_EVGA_INDTUBE,
45 } 45 }
46}; 46};
47 47
diff --git a/drivers/media/rc/keymaps/rc-eztv.c b/drivers/media/rc/keymaps/rc-eztv.c
index b5c96ed84376..5013b3b2aa93 100644
--- a/drivers/media/rc/keymaps/rc-eztv.c
+++ b/drivers/media/rc/keymaps/rc-eztv.c
@@ -73,10 +73,10 @@ static struct rc_map_table eztv[] = {
73 73
74static struct rc_map_list eztv_map = { 74static struct rc_map_list eztv_map = {
75 .map = { 75 .map = {
76 .scan = eztv, 76 .scan = eztv,
77 .size = ARRAY_SIZE(eztv), 77 .size = ARRAY_SIZE(eztv),
78 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 78 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
79 .name = RC_MAP_EZTV, 79 .name = RC_MAP_EZTV,
80 } 80 }
81}; 81};
82 82
diff --git a/drivers/media/rc/keymaps/rc-flydvb.c b/drivers/media/rc/keymaps/rc-flydvb.c
index 25cb89fac03c..418b32521273 100644
--- a/drivers/media/rc/keymaps/rc-flydvb.c
+++ b/drivers/media/rc/keymaps/rc-flydvb.c
@@ -54,10 +54,10 @@ static struct rc_map_table flydvb[] = {
54 54
55static struct rc_map_list flydvb_map = { 55static struct rc_map_list flydvb_map = {
56 .map = { 56 .map = {
57 .scan = flydvb, 57 .scan = flydvb,
58 .size = ARRAY_SIZE(flydvb), 58 .size = ARRAY_SIZE(flydvb),
59 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 59 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
60 .name = RC_MAP_FLYDVB, 60 .name = RC_MAP_FLYDVB,
61 } 61 }
62}; 62};
63 63
diff --git a/drivers/media/rc/keymaps/rc-flyvideo.c b/drivers/media/rc/keymaps/rc-flyvideo.c
index e71377dd0534..93fb87ecf061 100644
--- a/drivers/media/rc/keymaps/rc-flyvideo.c
+++ b/drivers/media/rc/keymaps/rc-flyvideo.c
@@ -47,10 +47,10 @@ static struct rc_map_table flyvideo[] = {
47 47
48static struct rc_map_list flyvideo_map = { 48static struct rc_map_list flyvideo_map = {
49 .map = { 49 .map = {
50 .scan = flyvideo, 50 .scan = flyvideo,
51 .size = ARRAY_SIZE(flyvideo), 51 .size = ARRAY_SIZE(flyvideo),
52 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 52 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
53 .name = RC_MAP_FLYVIDEO, 53 .name = RC_MAP_FLYVIDEO,
54 } 54 }
55}; 55};
56 56
diff --git a/drivers/media/rc/keymaps/rc-fusionhdtv-mce.c b/drivers/media/rc/keymaps/rc-fusionhdtv-mce.c
index cf0608dc83d5..9ed3f749262b 100644
--- a/drivers/media/rc/keymaps/rc-fusionhdtv-mce.c
+++ b/drivers/media/rc/keymaps/rc-fusionhdtv-mce.c
@@ -75,10 +75,10 @@ static struct rc_map_table fusionhdtv_mce[] = {
75 75
76static struct rc_map_list fusionhdtv_mce_map = { 76static struct rc_map_list fusionhdtv_mce_map = {
77 .map = { 77 .map = {
78 .scan = fusionhdtv_mce, 78 .scan = fusionhdtv_mce,
79 .size = ARRAY_SIZE(fusionhdtv_mce), 79 .size = ARRAY_SIZE(fusionhdtv_mce),
80 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 80 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
81 .name = RC_MAP_FUSIONHDTV_MCE, 81 .name = RC_MAP_FUSIONHDTV_MCE,
82 } 82 }
83}; 83};
84 84
diff --git a/drivers/media/rc/keymaps/rc-gadmei-rm008z.c b/drivers/media/rc/keymaps/rc-gadmei-rm008z.c
index 03575bdb2eca..3443b721d092 100644
--- a/drivers/media/rc/keymaps/rc-gadmei-rm008z.c
+++ b/drivers/media/rc/keymaps/rc-gadmei-rm008z.c
@@ -58,10 +58,10 @@ static struct rc_map_table gadmei_rm008z[] = {
58 58
59static struct rc_map_list gadmei_rm008z_map = { 59static struct rc_map_list gadmei_rm008z_map = {
60 .map = { 60 .map = {
61 .scan = gadmei_rm008z, 61 .scan = gadmei_rm008z,
62 .size = ARRAY_SIZE(gadmei_rm008z), 62 .size = ARRAY_SIZE(gadmei_rm008z),
63 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 63 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
64 .name = RC_MAP_GADMEI_RM008Z, 64 .name = RC_MAP_GADMEI_RM008Z,
65 } 65 }
66}; 66};
67 67
diff --git a/drivers/media/rc/keymaps/rc-geekbox.c b/drivers/media/rc/keymaps/rc-geekbox.c
index affc4c481888..4aa1b54bb52e 100644
--- a/drivers/media/rc/keymaps/rc-geekbox.c
+++ b/drivers/media/rc/keymaps/rc-geekbox.c
@@ -31,10 +31,10 @@ static struct rc_map_table geekbox[] = {
31 31
32static struct rc_map_list geekbox_map = { 32static struct rc_map_list geekbox_map = {
33 .map = { 33 .map = {
34 .scan = geekbox, 34 .scan = geekbox,
35 .size = ARRAY_SIZE(geekbox), 35 .size = ARRAY_SIZE(geekbox),
36 .rc_type = RC_TYPE_NEC, 36 .rc_proto = RC_PROTO_NEC,
37 .name = RC_MAP_GEEKBOX, 37 .name = RC_MAP_GEEKBOX,
38 } 38 }
39}; 39};
40 40
diff --git a/drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c b/drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c
index b2ab13b0dcb1..d140e8d45bcc 100644
--- a/drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c
+++ b/drivers/media/rc/keymaps/rc-genius-tvgo-a11mce.c
@@ -61,10 +61,10 @@ static struct rc_map_table genius_tvgo_a11mce[] = {
61 61
62static struct rc_map_list genius_tvgo_a11mce_map = { 62static struct rc_map_list genius_tvgo_a11mce_map = {
63 .map = { 63 .map = {
64 .scan = genius_tvgo_a11mce, 64 .scan = genius_tvgo_a11mce,
65 .size = ARRAY_SIZE(genius_tvgo_a11mce), 65 .size = ARRAY_SIZE(genius_tvgo_a11mce),
66 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 66 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
67 .name = RC_MAP_GENIUS_TVGO_A11MCE, 67 .name = RC_MAP_GENIUS_TVGO_A11MCE,
68 } 68 }
69}; 69};
70 70
diff --git a/drivers/media/rc/keymaps/rc-gotview7135.c b/drivers/media/rc/keymaps/rc-gotview7135.c
index 229a36ac7f0a..51230fbb52ba 100644
--- a/drivers/media/rc/keymaps/rc-gotview7135.c
+++ b/drivers/media/rc/keymaps/rc-gotview7135.c
@@ -56,10 +56,10 @@ static struct rc_map_table gotview7135[] = {
56 56
57static struct rc_map_list gotview7135_map = { 57static struct rc_map_list gotview7135_map = {
58 .map = { 58 .map = {
59 .scan = gotview7135, 59 .scan = gotview7135,
60 .size = ARRAY_SIZE(gotview7135), 60 .size = ARRAY_SIZE(gotview7135),
61 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 61 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
62 .name = RC_MAP_GOTVIEW7135, 62 .name = RC_MAP_GOTVIEW7135,
63 } 63 }
64}; 64};
65 65
diff --git a/drivers/media/rc/keymaps/rc-hauppauge.c b/drivers/media/rc/keymaps/rc-hauppauge.c
index 36d57f7c532b..890164b68d64 100644
--- a/drivers/media/rc/keymaps/rc-hauppauge.c
+++ b/drivers/media/rc/keymaps/rc-hauppauge.c
@@ -269,10 +269,10 @@ static struct rc_map_table rc5_hauppauge_new[] = {
269 269
270static struct rc_map_list rc5_hauppauge_new_map = { 270static struct rc_map_list rc5_hauppauge_new_map = {
271 .map = { 271 .map = {
272 .scan = rc5_hauppauge_new, 272 .scan = rc5_hauppauge_new,
273 .size = ARRAY_SIZE(rc5_hauppauge_new), 273 .size = ARRAY_SIZE(rc5_hauppauge_new),
274 .rc_type = RC_TYPE_RC5, 274 .rc_proto = RC_PROTO_RC5,
275 .name = RC_MAP_HAUPPAUGE, 275 .name = RC_MAP_HAUPPAUGE,
276 } 276 }
277}; 277};
278 278
diff --git a/drivers/media/rc/keymaps/rc-imon-mce.c b/drivers/media/rc/keymaps/rc-imon-mce.c
index f0da960560b0..6a69ce1451f1 100644
--- a/drivers/media/rc/keymaps/rc-imon-mce.c
+++ b/drivers/media/rc/keymaps/rc-imon-mce.c
@@ -118,11 +118,11 @@ static struct rc_map_table imon_mce[] = {
118 118
119static struct rc_map_list imon_mce_map = { 119static struct rc_map_list imon_mce_map = {
120 .map = { 120 .map = {
121 .scan = imon_mce, 121 .scan = imon_mce,
122 .size = ARRAY_SIZE(imon_mce), 122 .size = ARRAY_SIZE(imon_mce),
123 /* its RC6, but w/a hardware decoder */ 123 /* its RC6, but w/a hardware decoder */
124 .rc_type = RC_TYPE_RC6_MCE, 124 .rc_proto = RC_PROTO_RC6_MCE,
125 .name = RC_MAP_IMON_MCE, 125 .name = RC_MAP_IMON_MCE,
126 } 126 }
127}; 127};
128 128
diff --git a/drivers/media/rc/keymaps/rc-imon-pad.c b/drivers/media/rc/keymaps/rc-imon-pad.c
index 999c6295c70e..a7296ffbf218 100644
--- a/drivers/media/rc/keymaps/rc-imon-pad.c
+++ b/drivers/media/rc/keymaps/rc-imon-pad.c
@@ -132,11 +132,11 @@ static struct rc_map_table imon_pad[] = {
132 132
133static struct rc_map_list imon_pad_map = { 133static struct rc_map_list imon_pad_map = {
134 .map = { 134 .map = {
135 .scan = imon_pad, 135 .scan = imon_pad,
136 .size = ARRAY_SIZE(imon_pad), 136 .size = ARRAY_SIZE(imon_pad),
137 /* actual protocol details unknown, hardware decoder */ 137 /* actual protocol details unknown, hardware decoder */
138 .rc_type = RC_TYPE_OTHER, 138 .rc_proto = RC_PROTO_OTHER,
139 .name = RC_MAP_IMON_PAD, 139 .name = RC_MAP_IMON_PAD,
140 } 140 }
141}; 141};
142 142
diff --git a/drivers/media/rc/keymaps/rc-iodata-bctv7e.c b/drivers/media/rc/keymaps/rc-iodata-bctv7e.c
index 9ee154cb0c6b..8cf87a15c4f2 100644
--- a/drivers/media/rc/keymaps/rc-iodata-bctv7e.c
+++ b/drivers/media/rc/keymaps/rc-iodata-bctv7e.c
@@ -65,10 +65,10 @@ static struct rc_map_table iodata_bctv7e[] = {
65 65
66static struct rc_map_list iodata_bctv7e_map = { 66static struct rc_map_list iodata_bctv7e_map = {
67 .map = { 67 .map = {
68 .scan = iodata_bctv7e, 68 .scan = iodata_bctv7e,
69 .size = ARRAY_SIZE(iodata_bctv7e), 69 .size = ARRAY_SIZE(iodata_bctv7e),
70 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 70 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
71 .name = RC_MAP_IODATA_BCTV7E, 71 .name = RC_MAP_IODATA_BCTV7E,
72 } 72 }
73}; 73};
74 74
diff --git a/drivers/media/rc/keymaps/rc-it913x-v1.c b/drivers/media/rc/keymaps/rc-it913x-v1.c
index 0ac775fd109d..908d14848ae8 100644
--- a/drivers/media/rc/keymaps/rc-it913x-v1.c
+++ b/drivers/media/rc/keymaps/rc-it913x-v1.c
@@ -71,10 +71,10 @@ static struct rc_map_table it913x_v1_rc[] = {
71 71
72static struct rc_map_list it913x_v1_map = { 72static struct rc_map_list it913x_v1_map = {
73 .map = { 73 .map = {
74 .scan = it913x_v1_rc, 74 .scan = it913x_v1_rc,
75 .size = ARRAY_SIZE(it913x_v1_rc), 75 .size = ARRAY_SIZE(it913x_v1_rc),
76 .rc_type = RC_TYPE_NEC, 76 .rc_proto = RC_PROTO_NEC,
77 .name = RC_MAP_IT913X_V1, 77 .name = RC_MAP_IT913X_V1,
78 } 78 }
79}; 79};
80 80
diff --git a/drivers/media/rc/keymaps/rc-it913x-v2.c b/drivers/media/rc/keymaps/rc-it913x-v2.c
index bd42a30ec06f..05ab7fa4f90b 100644
--- a/drivers/media/rc/keymaps/rc-it913x-v2.c
+++ b/drivers/media/rc/keymaps/rc-it913x-v2.c
@@ -70,10 +70,10 @@ static struct rc_map_table it913x_v2_rc[] = {
70 70
71static struct rc_map_list it913x_v2_map = { 71static struct rc_map_list it913x_v2_map = {
72 .map = { 72 .map = {
73 .scan = it913x_v2_rc, 73 .scan = it913x_v2_rc,
74 .size = ARRAY_SIZE(it913x_v2_rc), 74 .size = ARRAY_SIZE(it913x_v2_rc),
75 .rc_type = RC_TYPE_NEC, 75 .rc_proto = RC_PROTO_NEC,
76 .name = RC_MAP_IT913X_V2, 76 .name = RC_MAP_IT913X_V2,
77 } 77 }
78}; 78};
79 79
diff --git a/drivers/media/rc/keymaps/rc-kaiomy.c b/drivers/media/rc/keymaps/rc-kaiomy.c
index 60803a732c08..e791f1e1b43b 100644
--- a/drivers/media/rc/keymaps/rc-kaiomy.c
+++ b/drivers/media/rc/keymaps/rc-kaiomy.c
@@ -64,10 +64,10 @@ static struct rc_map_table kaiomy[] = {
64 64
65static struct rc_map_list kaiomy_map = { 65static struct rc_map_list kaiomy_map = {
66 .map = { 66 .map = {
67 .scan = kaiomy, 67 .scan = kaiomy,
68 .size = ARRAY_SIZE(kaiomy), 68 .size = ARRAY_SIZE(kaiomy),
69 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 69 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
70 .name = RC_MAP_KAIOMY, 70 .name = RC_MAP_KAIOMY,
71 } 71 }
72}; 72};
73 73
diff --git a/drivers/media/rc/keymaps/rc-kworld-315u.c b/drivers/media/rc/keymaps/rc-kworld-315u.c
index ba087eed1ed9..71dce0138f0e 100644
--- a/drivers/media/rc/keymaps/rc-kworld-315u.c
+++ b/drivers/media/rc/keymaps/rc-kworld-315u.c
@@ -60,10 +60,10 @@ static struct rc_map_table kworld_315u[] = {
60 60
61static struct rc_map_list kworld_315u_map = { 61static struct rc_map_list kworld_315u_map = {
62 .map = { 62 .map = {
63 .scan = kworld_315u, 63 .scan = kworld_315u,
64 .size = ARRAY_SIZE(kworld_315u), 64 .size = ARRAY_SIZE(kworld_315u),
65 .rc_type = RC_TYPE_NEC, 65 .rc_proto = RC_PROTO_NEC,
66 .name = RC_MAP_KWORLD_315U, 66 .name = RC_MAP_KWORLD_315U,
67 } 67 }
68}; 68};
69 69
diff --git a/drivers/media/rc/keymaps/rc-kworld-pc150u.c b/drivers/media/rc/keymaps/rc-kworld-pc150u.c
index b92e571f4def..3846059060aa 100644
--- a/drivers/media/rc/keymaps/rc-kworld-pc150u.c
+++ b/drivers/media/rc/keymaps/rc-kworld-pc150u.c
@@ -78,10 +78,10 @@ static struct rc_map_table kworld_pc150u[] = {
78 78
79static struct rc_map_list kworld_pc150u_map = { 79static struct rc_map_list kworld_pc150u_map = {
80 .map = { 80 .map = {
81 .scan = kworld_pc150u, 81 .scan = kworld_pc150u,
82 .size = ARRAY_SIZE(kworld_pc150u), 82 .size = ARRAY_SIZE(kworld_pc150u),
83 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 83 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
84 .name = RC_MAP_KWORLD_PC150U, 84 .name = RC_MAP_KWORLD_PC150U,
85 } 85 }
86}; 86};
87 87
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 edc868564f99..e0322ed16c94 100644
--- a/drivers/media/rc/keymaps/rc-kworld-plus-tv-analog.c
+++ b/drivers/media/rc/keymaps/rc-kworld-plus-tv-analog.c
@@ -76,10 +76,10 @@ static struct rc_map_table kworld_plus_tv_analog[] = {
76 76
77static struct rc_map_list kworld_plus_tv_analog_map = { 77static struct rc_map_list kworld_plus_tv_analog_map = {
78 .map = { 78 .map = {
79 .scan = kworld_plus_tv_analog, 79 .scan = kworld_plus_tv_analog,
80 .size = ARRAY_SIZE(kworld_plus_tv_analog), 80 .size = ARRAY_SIZE(kworld_plus_tv_analog),
81 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 81 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
82 .name = RC_MAP_KWORLD_PLUS_TV_ANALOG, 82 .name = RC_MAP_KWORLD_PLUS_TV_ANALOG,
83 } 83 }
84}; 84};
85 85
diff --git a/drivers/media/rc/keymaps/rc-leadtek-y04g0051.c b/drivers/media/rc/keymaps/rc-leadtek-y04g0051.c
index 03d762d986ee..e534a5601b6d 100644
--- a/drivers/media/rc/keymaps/rc-leadtek-y04g0051.c
+++ b/drivers/media/rc/keymaps/rc-leadtek-y04g0051.c
@@ -76,10 +76,10 @@ static struct rc_map_table leadtek_y04g0051[] = {
76 76
77static struct rc_map_list leadtek_y04g0051_map = { 77static struct rc_map_list leadtek_y04g0051_map = {
78 .map = { 78 .map = {
79 .scan = leadtek_y04g0051, 79 .scan = leadtek_y04g0051,
80 .size = ARRAY_SIZE(leadtek_y04g0051), 80 .size = ARRAY_SIZE(leadtek_y04g0051),
81 .rc_type = RC_TYPE_NEC, 81 .rc_proto = RC_PROTO_NEC,
82 .name = RC_MAP_LEADTEK_Y04G0051, 82 .name = RC_MAP_LEADTEK_Y04G0051,
83 } 83 }
84}; 84};
85 85
diff --git a/drivers/media/rc/keymaps/rc-lme2510.c b/drivers/media/rc/keymaps/rc-lme2510.c
index 2b0027c41332..9c93f90f5c2b 100644
--- a/drivers/media/rc/keymaps/rc-lme2510.c
+++ b/drivers/media/rc/keymaps/rc-lme2510.c
@@ -87,10 +87,10 @@ static struct rc_map_table lme2510_rc[] = {
87 87
88static struct rc_map_list lme2510_map = { 88static struct rc_map_list lme2510_map = {
89 .map = { 89 .map = {
90 .scan = lme2510_rc, 90 .scan = lme2510_rc,
91 .size = ARRAY_SIZE(lme2510_rc), 91 .size = ARRAY_SIZE(lme2510_rc),
92 .rc_type = RC_TYPE_NEC, 92 .rc_proto = RC_PROTO_NEC,
93 .name = RC_MAP_LME2510, 93 .name = RC_MAP_LME2510,
94 } 94 }
95}; 95};
96 96
diff --git a/drivers/media/rc/keymaps/rc-manli.c b/drivers/media/rc/keymaps/rc-manli.c
index 92424ef2aaa6..da566902a4dd 100644
--- a/drivers/media/rc/keymaps/rc-manli.c
+++ b/drivers/media/rc/keymaps/rc-manli.c
@@ -111,10 +111,10 @@ static struct rc_map_table manli[] = {
111 111
112static struct rc_map_list manli_map = { 112static struct rc_map_list manli_map = {
113 .map = { 113 .map = {
114 .scan = manli, 114 .scan = manli,
115 .size = ARRAY_SIZE(manli), 115 .size = ARRAY_SIZE(manli),
116 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 116 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
117 .name = RC_MAP_MANLI, 117 .name = RC_MAP_MANLI,
118 } 118 }
119}; 119};
120 120
diff --git a/drivers/media/rc/keymaps/rc-medion-x10-digitainer.c b/drivers/media/rc/keymaps/rc-medion-x10-digitainer.c
index 966f9b3c71da..c9973340e546 100644
--- a/drivers/media/rc/keymaps/rc-medion-x10-digitainer.c
+++ b/drivers/media/rc/keymaps/rc-medion-x10-digitainer.c
@@ -98,10 +98,10 @@ static struct rc_map_table medion_x10_digitainer[] = {
98 98
99static struct rc_map_list medion_x10_digitainer_map = { 99static struct rc_map_list medion_x10_digitainer_map = {
100 .map = { 100 .map = {
101 .scan = medion_x10_digitainer, 101 .scan = medion_x10_digitainer,
102 .size = ARRAY_SIZE(medion_x10_digitainer), 102 .size = ARRAY_SIZE(medion_x10_digitainer),
103 .rc_type = RC_TYPE_OTHER, 103 .rc_proto = RC_PROTO_OTHER,
104 .name = RC_MAP_MEDION_X10_DIGITAINER, 104 .name = RC_MAP_MEDION_X10_DIGITAINER,
105 } 105 }
106}; 106};
107 107
diff --git a/drivers/media/rc/keymaps/rc-medion-x10-or2x.c b/drivers/media/rc/keymaps/rc-medion-x10-or2x.c
index b077300ecb5c..103ad88d242c 100644
--- a/drivers/media/rc/keymaps/rc-medion-x10-or2x.c
+++ b/drivers/media/rc/keymaps/rc-medion-x10-or2x.c
@@ -83,10 +83,10 @@ static struct rc_map_table medion_x10_or2x[] = {
83 83
84static struct rc_map_list medion_x10_or2x_map = { 84static struct rc_map_list medion_x10_or2x_map = {
85 .map = { 85 .map = {
86 .scan = medion_x10_or2x, 86 .scan = medion_x10_or2x,
87 .size = ARRAY_SIZE(medion_x10_or2x), 87 .size = ARRAY_SIZE(medion_x10_or2x),
88 .rc_type = RC_TYPE_OTHER, 88 .rc_proto = RC_PROTO_OTHER,
89 .name = RC_MAP_MEDION_X10_OR2X, 89 .name = RC_MAP_MEDION_X10_OR2X,
90 } 90 }
91}; 91};
92 92
diff --git a/drivers/media/rc/keymaps/rc-medion-x10.c b/drivers/media/rc/keymaps/rc-medion-x10.c
index 479cdb897810..bbffa5dfe420 100644
--- a/drivers/media/rc/keymaps/rc-medion-x10.c
+++ b/drivers/media/rc/keymaps/rc-medion-x10.c
@@ -93,10 +93,10 @@ static struct rc_map_table medion_x10[] = {
93 93
94static struct rc_map_list medion_x10_map = { 94static struct rc_map_list medion_x10_map = {
95 .map = { 95 .map = {
96 .scan = medion_x10, 96 .scan = medion_x10,
97 .size = ARRAY_SIZE(medion_x10), 97 .size = ARRAY_SIZE(medion_x10),
98 .rc_type = RC_TYPE_OTHER, 98 .rc_proto = RC_PROTO_OTHER,
99 .name = RC_MAP_MEDION_X10, 99 .name = RC_MAP_MEDION_X10,
100 } 100 }
101}; 101};
102 102
diff --git a/drivers/media/rc/keymaps/rc-msi-digivox-ii.c b/drivers/media/rc/keymaps/rc-msi-digivox-ii.c
index 2fa71d0d72d7..94aa12d4b73c 100644
--- a/drivers/media/rc/keymaps/rc-msi-digivox-ii.c
+++ b/drivers/media/rc/keymaps/rc-msi-digivox-ii.c
@@ -44,10 +44,10 @@ static struct rc_map_table msi_digivox_ii[] = {
44 44
45static struct rc_map_list msi_digivox_ii_map = { 45static struct rc_map_list msi_digivox_ii_map = {
46 .map = { 46 .map = {
47 .scan = msi_digivox_ii, 47 .scan = msi_digivox_ii,
48 .size = ARRAY_SIZE(msi_digivox_ii), 48 .size = ARRAY_SIZE(msi_digivox_ii),
49 .rc_type = RC_TYPE_NEC, 49 .rc_proto = RC_PROTO_NEC,
50 .name = RC_MAP_MSI_DIGIVOX_II, 50 .name = RC_MAP_MSI_DIGIVOX_II,
51 } 51 }
52}; 52};
53 53
diff --git a/drivers/media/rc/keymaps/rc-msi-digivox-iii.c b/drivers/media/rc/keymaps/rc-msi-digivox-iii.c
index 303a0b73175b..8fec0c1dcb12 100644
--- a/drivers/media/rc/keymaps/rc-msi-digivox-iii.c
+++ b/drivers/media/rc/keymaps/rc-msi-digivox-iii.c
@@ -62,10 +62,10 @@ static struct rc_map_table msi_digivox_iii[] = {
62 62
63static struct rc_map_list msi_digivox_iii_map = { 63static struct rc_map_list msi_digivox_iii_map = {
64 .map = { 64 .map = {
65 .scan = msi_digivox_iii, 65 .scan = msi_digivox_iii,
66 .size = ARRAY_SIZE(msi_digivox_iii), 66 .size = ARRAY_SIZE(msi_digivox_iii),
67 .rc_type = RC_TYPE_NEC, 67 .rc_proto = RC_PROTO_NEC,
68 .name = RC_MAP_MSI_DIGIVOX_III, 68 .name = RC_MAP_MSI_DIGIVOX_III,
69 } 69 }
70}; 70};
71 71
diff --git a/drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c b/drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c
index fd7a55c56167..dfa0ed1d7667 100644
--- a/drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c
+++ b/drivers/media/rc/keymaps/rc-msi-tvanywhere-plus.c
@@ -100,10 +100,10 @@ static struct rc_map_table msi_tvanywhere_plus[] = {
100 100
101static struct rc_map_list msi_tvanywhere_plus_map = { 101static struct rc_map_list msi_tvanywhere_plus_map = {
102 .map = { 102 .map = {
103 .scan = msi_tvanywhere_plus, 103 .scan = msi_tvanywhere_plus,
104 .size = ARRAY_SIZE(msi_tvanywhere_plus), 104 .size = ARRAY_SIZE(msi_tvanywhere_plus),
105 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 105 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
106 .name = RC_MAP_MSI_TVANYWHERE_PLUS, 106 .name = RC_MAP_MSI_TVANYWHERE_PLUS,
107 } 107 }
108}; 108};
109 109
diff --git a/drivers/media/rc/keymaps/rc-msi-tvanywhere.c b/drivers/media/rc/keymaps/rc-msi-tvanywhere.c
index 4233a8d4d63e..2111816a3f59 100644
--- a/drivers/media/rc/keymaps/rc-msi-tvanywhere.c
+++ b/drivers/media/rc/keymaps/rc-msi-tvanywhere.c
@@ -46,10 +46,10 @@ static struct rc_map_table msi_tvanywhere[] = {
46 46
47static struct rc_map_list msi_tvanywhere_map = { 47static struct rc_map_list msi_tvanywhere_map = {
48 .map = { 48 .map = {
49 .scan = msi_tvanywhere, 49 .scan = msi_tvanywhere,
50 .size = ARRAY_SIZE(msi_tvanywhere), 50 .size = ARRAY_SIZE(msi_tvanywhere),
51 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 51 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
52 .name = RC_MAP_MSI_TVANYWHERE, 52 .name = RC_MAP_MSI_TVANYWHERE,
53 } 53 }
54}; 54};
55 55
diff --git a/drivers/media/rc/keymaps/rc-nebula.c b/drivers/media/rc/keymaps/rc-nebula.c
index 4c50f33c7c41..109b6e1a8b1a 100644
--- a/drivers/media/rc/keymaps/rc-nebula.c
+++ b/drivers/media/rc/keymaps/rc-nebula.c
@@ -73,10 +73,10 @@ static struct rc_map_table nebula[] = {
73 73
74static struct rc_map_list nebula_map = { 74static struct rc_map_list nebula_map = {
75 .map = { 75 .map = {
76 .scan = nebula, 76 .scan = nebula,
77 .size = ARRAY_SIZE(nebula), 77 .size = ARRAY_SIZE(nebula),
78 .rc_type = RC_TYPE_RC5, 78 .rc_proto = RC_PROTO_RC5,
79 .name = RC_MAP_NEBULA, 79 .name = RC_MAP_NEBULA,
80 } 80 }
81}; 81};
82 82
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 292bbad35d21..bb2d3a2962c0 100644
--- a/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
+++ b/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
@@ -134,10 +134,10 @@ static struct rc_map_table nec_terratec_cinergy_xs[] = {
134 134
135static struct rc_map_list nec_terratec_cinergy_xs_map = { 135static struct rc_map_list nec_terratec_cinergy_xs_map = {
136 .map = { 136 .map = {
137 .scan = nec_terratec_cinergy_xs, 137 .scan = nec_terratec_cinergy_xs,
138 .size = ARRAY_SIZE(nec_terratec_cinergy_xs), 138 .size = ARRAY_SIZE(nec_terratec_cinergy_xs),
139 .rc_type = RC_TYPE_NEC, 139 .rc_proto = RC_PROTO_NEC,
140 .name = RC_MAP_NEC_TERRATEC_CINERGY_XS, 140 .name = RC_MAP_NEC_TERRATEC_CINERGY_XS,
141 } 141 }
142}; 142};
143 143
diff --git a/drivers/media/rc/keymaps/rc-norwood.c b/drivers/media/rc/keymaps/rc-norwood.c
index ca1b82a2c54f..cd25df336749 100644
--- a/drivers/media/rc/keymaps/rc-norwood.c
+++ b/drivers/media/rc/keymaps/rc-norwood.c
@@ -62,10 +62,10 @@ static struct rc_map_table norwood[] = {
62 62
63static struct rc_map_list norwood_map = { 63static struct rc_map_list norwood_map = {
64 .map = { 64 .map = {
65 .scan = norwood, 65 .scan = norwood,
66 .size = ARRAY_SIZE(norwood), 66 .size = ARRAY_SIZE(norwood),
67 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 67 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
68 .name = RC_MAP_NORWOOD, 68 .name = RC_MAP_NORWOOD,
69 } 69 }
70}; 70};
71 71
diff --git a/drivers/media/rc/keymaps/rc-npgtech.c b/drivers/media/rc/keymaps/rc-npgtech.c
index 1fb946024512..140bbc20a764 100644
--- a/drivers/media/rc/keymaps/rc-npgtech.c
+++ b/drivers/media/rc/keymaps/rc-npgtech.c
@@ -57,10 +57,10 @@ static struct rc_map_table npgtech[] = {
57 57
58static struct rc_map_list npgtech_map = { 58static struct rc_map_list npgtech_map = {
59 .map = { 59 .map = {
60 .scan = npgtech, 60 .scan = npgtech,
61 .size = ARRAY_SIZE(npgtech), 61 .size = ARRAY_SIZE(npgtech),
62 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 62 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
63 .name = RC_MAP_NPGTECH, 63 .name = RC_MAP_NPGTECH,
64 } 64 }
65}; 65};
66 66
diff --git a/drivers/media/rc/keymaps/rc-pctv-sedna.c b/drivers/media/rc/keymaps/rc-pctv-sedna.c
index 5ef01ab3fd50..52b4558b7bd0 100644
--- a/drivers/media/rc/keymaps/rc-pctv-sedna.c
+++ b/drivers/media/rc/keymaps/rc-pctv-sedna.c
@@ -57,10 +57,10 @@ static struct rc_map_table pctv_sedna[] = {
57 57
58static struct rc_map_list pctv_sedna_map = { 58static struct rc_map_list pctv_sedna_map = {
59 .map = { 59 .map = {
60 .scan = pctv_sedna, 60 .scan = pctv_sedna,
61 .size = ARRAY_SIZE(pctv_sedna), 61 .size = ARRAY_SIZE(pctv_sedna),
62 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 62 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
63 .name = RC_MAP_PCTV_SEDNA, 63 .name = RC_MAP_PCTV_SEDNA,
64 } 64 }
65}; 65};
66 66
diff --git a/drivers/media/rc/keymaps/rc-pinnacle-color.c b/drivers/media/rc/keymaps/rc-pinnacle-color.c
index a218b471a4ca..973c9c34e304 100644
--- a/drivers/media/rc/keymaps/rc-pinnacle-color.c
+++ b/drivers/media/rc/keymaps/rc-pinnacle-color.c
@@ -71,10 +71,10 @@ static struct rc_map_table pinnacle_color[] = {
71 71
72static struct rc_map_list pinnacle_color_map = { 72static struct rc_map_list pinnacle_color_map = {
73 .map = { 73 .map = {
74 .scan = pinnacle_color, 74 .scan = pinnacle_color,
75 .size = ARRAY_SIZE(pinnacle_color), 75 .size = ARRAY_SIZE(pinnacle_color),
76 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 76 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
77 .name = RC_MAP_PINNACLE_COLOR, 77 .name = RC_MAP_PINNACLE_COLOR,
78 } 78 }
79}; 79};
80 80
diff --git a/drivers/media/rc/keymaps/rc-pinnacle-grey.c b/drivers/media/rc/keymaps/rc-pinnacle-grey.c
index 4a3f467a47a2..22e44b0d2a93 100644
--- a/drivers/media/rc/keymaps/rc-pinnacle-grey.c
+++ b/drivers/media/rc/keymaps/rc-pinnacle-grey.c
@@ -66,10 +66,10 @@ static struct rc_map_table pinnacle_grey[] = {
66 66
67static struct rc_map_list pinnacle_grey_map = { 67static struct rc_map_list pinnacle_grey_map = {
68 .map = { 68 .map = {
69 .scan = pinnacle_grey, 69 .scan = pinnacle_grey,
70 .size = ARRAY_SIZE(pinnacle_grey), 70 .size = ARRAY_SIZE(pinnacle_grey),
71 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 71 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
72 .name = RC_MAP_PINNACLE_GREY, 72 .name = RC_MAP_PINNACLE_GREY,
73 } 73 }
74}; 74};
75 75
diff --git a/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c b/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c
index e89cc10b68bf..186dcf8e0491 100644
--- a/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c
+++ b/drivers/media/rc/keymaps/rc-pinnacle-pctv-hd.c
@@ -47,10 +47,10 @@ static struct rc_map_table pinnacle_pctv_hd[] = {
47 47
48static struct rc_map_list pinnacle_pctv_hd_map = { 48static struct rc_map_list pinnacle_pctv_hd_map = {
49 .map = { 49 .map = {
50 .scan = pinnacle_pctv_hd, 50 .scan = pinnacle_pctv_hd,
51 .size = ARRAY_SIZE(pinnacle_pctv_hd), 51 .size = ARRAY_SIZE(pinnacle_pctv_hd),
52 .rc_type = RC_TYPE_RC5, 52 .rc_proto = RC_PROTO_RC5,
53 .name = RC_MAP_PINNACLE_PCTV_HD, 53 .name = RC_MAP_PINNACLE_PCTV_HD,
54 } 54 }
55}; 55};
56 56
diff --git a/drivers/media/rc/keymaps/rc-pixelview-002t.c b/drivers/media/rc/keymaps/rc-pixelview-002t.c
index d967c3816fdc..b235ada2e28f 100644
--- a/drivers/media/rc/keymaps/rc-pixelview-002t.c
+++ b/drivers/media/rc/keymaps/rc-pixelview-002t.c
@@ -54,10 +54,10 @@ static struct rc_map_table pixelview_002t[] = {
54 54
55static struct rc_map_list pixelview_map = { 55static struct rc_map_list pixelview_map = {
56 .map = { 56 .map = {
57 .scan = pixelview_002t, 57 .scan = pixelview_002t,
58 .size = ARRAY_SIZE(pixelview_002t), 58 .size = ARRAY_SIZE(pixelview_002t),
59 .rc_type = RC_TYPE_NEC, 59 .rc_proto = RC_PROTO_NEC,
60 .name = RC_MAP_PIXELVIEW_002T, 60 .name = RC_MAP_PIXELVIEW_002T,
61 } 61 }
62}; 62};
63 63
diff --git a/drivers/media/rc/keymaps/rc-pixelview-mk12.c b/drivers/media/rc/keymaps/rc-pixelview-mk12.c
index 224d0efaa6e5..453d52d663fe 100644
--- a/drivers/media/rc/keymaps/rc-pixelview-mk12.c
+++ b/drivers/media/rc/keymaps/rc-pixelview-mk12.c
@@ -60,10 +60,10 @@ static struct rc_map_table pixelview_mk12[] = {
60 60
61static struct rc_map_list pixelview_map = { 61static struct rc_map_list pixelview_map = {
62 .map = { 62 .map = {
63 .scan = pixelview_mk12, 63 .scan = pixelview_mk12,
64 .size = ARRAY_SIZE(pixelview_mk12), 64 .size = ARRAY_SIZE(pixelview_mk12),
65 .rc_type = RC_TYPE_NEC, 65 .rc_proto = RC_PROTO_NEC,
66 .name = RC_MAP_PIXELVIEW_MK12, 66 .name = RC_MAP_PIXELVIEW_MK12,
67 } 67 }
68}; 68};
69 69
diff --git a/drivers/media/rc/keymaps/rc-pixelview-new.c b/drivers/media/rc/keymaps/rc-pixelview-new.c
index 781d788d6b6d..ef97095ec8f1 100644
--- a/drivers/media/rc/keymaps/rc-pixelview-new.c
+++ b/drivers/media/rc/keymaps/rc-pixelview-new.c
@@ -60,10 +60,10 @@ static struct rc_map_table pixelview_new[] = {
60 60
61static struct rc_map_list pixelview_new_map = { 61static struct rc_map_list pixelview_new_map = {
62 .map = { 62 .map = {
63 .scan = pixelview_new, 63 .scan = pixelview_new,
64 .size = ARRAY_SIZE(pixelview_new), 64 .size = ARRAY_SIZE(pixelview_new),
65 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 65 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
66 .name = RC_MAP_PIXELVIEW_NEW, 66 .name = RC_MAP_PIXELVIEW_NEW,
67 } 67 }
68}; 68};
69 69
diff --git a/drivers/media/rc/keymaps/rc-pixelview.c b/drivers/media/rc/keymaps/rc-pixelview.c
index 39e6feaa35a3..cfd8f80d3617 100644
--- a/drivers/media/rc/keymaps/rc-pixelview.c
+++ b/drivers/media/rc/keymaps/rc-pixelview.c
@@ -59,10 +59,10 @@ static struct rc_map_table pixelview[] = {
59 59
60static struct rc_map_list pixelview_map = { 60static struct rc_map_list pixelview_map = {
61 .map = { 61 .map = {
62 .scan = pixelview, 62 .scan = pixelview,
63 .size = ARRAY_SIZE(pixelview), 63 .size = ARRAY_SIZE(pixelview),
64 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 64 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
65 .name = RC_MAP_PIXELVIEW, 65 .name = RC_MAP_PIXELVIEW,
66 } 66 }
67}; 67};
68 68
diff --git a/drivers/media/rc/keymaps/rc-powercolor-real-angel.c b/drivers/media/rc/keymaps/rc-powercolor-real-angel.c
index e96fa3ab9f4b..b63f82bcf29a 100644
--- a/drivers/media/rc/keymaps/rc-powercolor-real-angel.c
+++ b/drivers/media/rc/keymaps/rc-powercolor-real-angel.c
@@ -58,10 +58,10 @@ static struct rc_map_table powercolor_real_angel[] = {
58 58
59static struct rc_map_list powercolor_real_angel_map = { 59static struct rc_map_list powercolor_real_angel_map = {
60 .map = { 60 .map = {
61 .scan = powercolor_real_angel, 61 .scan = powercolor_real_angel,
62 .size = ARRAY_SIZE(powercolor_real_angel), 62 .size = ARRAY_SIZE(powercolor_real_angel),
63 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 63 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
64 .name = RC_MAP_POWERCOLOR_REAL_ANGEL, 64 .name = RC_MAP_POWERCOLOR_REAL_ANGEL,
65 } 65 }
66}; 66};
67 67
diff --git a/drivers/media/rc/keymaps/rc-proteus-2309.c b/drivers/media/rc/keymaps/rc-proteus-2309.c
index eef626ee02df..be34c517e4e1 100644
--- a/drivers/media/rc/keymaps/rc-proteus-2309.c
+++ b/drivers/media/rc/keymaps/rc-proteus-2309.c
@@ -46,10 +46,10 @@ static struct rc_map_table proteus_2309[] = {
46 46
47static struct rc_map_list proteus_2309_map = { 47static struct rc_map_list proteus_2309_map = {
48 .map = { 48 .map = {
49 .scan = proteus_2309, 49 .scan = proteus_2309,
50 .size = ARRAY_SIZE(proteus_2309), 50 .size = ARRAY_SIZE(proteus_2309),
51 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 51 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
52 .name = RC_MAP_PROTEUS_2309, 52 .name = RC_MAP_PROTEUS_2309,
53 } 53 }
54}; 54};
55 55
diff --git a/drivers/media/rc/keymaps/rc-purpletv.c b/drivers/media/rc/keymaps/rc-purpletv.c
index cec6fe466829..84c40b97ee00 100644
--- a/drivers/media/rc/keymaps/rc-purpletv.c
+++ b/drivers/media/rc/keymaps/rc-purpletv.c
@@ -58,10 +58,10 @@ static struct rc_map_table purpletv[] = {
58 58
59static struct rc_map_list purpletv_map = { 59static struct rc_map_list purpletv_map = {
60 .map = { 60 .map = {
61 .scan = purpletv, 61 .scan = purpletv,
62 .size = ARRAY_SIZE(purpletv), 62 .size = ARRAY_SIZE(purpletv),
63 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 63 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
64 .name = RC_MAP_PURPLETV, 64 .name = RC_MAP_PURPLETV,
65 } 65 }
66}; 66};
67 67
diff --git a/drivers/media/rc/keymaps/rc-pv951.c b/drivers/media/rc/keymaps/rc-pv951.c
index 5ac89ce8c053..be190ddebfc4 100644
--- a/drivers/media/rc/keymaps/rc-pv951.c
+++ b/drivers/media/rc/keymaps/rc-pv951.c
@@ -55,10 +55,10 @@ static struct rc_map_table pv951[] = {
55 55
56static struct rc_map_list pv951_map = { 56static struct rc_map_list pv951_map = {
57 .map = { 57 .map = {
58 .scan = pv951, 58 .scan = pv951,
59 .size = ARRAY_SIZE(pv951), 59 .size = ARRAY_SIZE(pv951),
60 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 60 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
61 .name = RC_MAP_PV951, 61 .name = RC_MAP_PV951,
62 } 62 }
63}; 63};
64 64
diff --git a/drivers/media/rc/keymaps/rc-rc6-mce.c b/drivers/media/rc/keymaps/rc-rc6-mce.c
index 5be567506bcd..0d87b20a0c43 100644
--- a/drivers/media/rc/keymaps/rc-rc6-mce.c
+++ b/drivers/media/rc/keymaps/rc-rc6-mce.c
@@ -96,10 +96,10 @@ static struct rc_map_table rc6_mce[] = {
96 96
97static struct rc_map_list rc6_mce_map = { 97static struct rc_map_list rc6_mce_map = {
98 .map = { 98 .map = {
99 .scan = rc6_mce, 99 .scan = rc6_mce,
100 .size = ARRAY_SIZE(rc6_mce), 100 .size = ARRAY_SIZE(rc6_mce),
101 .rc_type = RC_TYPE_RC6_MCE, 101 .rc_proto = RC_PROTO_RC6_MCE,
102 .name = RC_MAP_RC6_MCE, 102 .name = RC_MAP_RC6_MCE,
103 } 103 }
104}; 104};
105 105
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 9f778bd091db..957fa21747ea 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
@@ -55,10 +55,10 @@ static struct rc_map_table real_audio_220_32_keys[] = {
55 55
56static struct rc_map_list real_audio_220_32_keys_map = { 56static struct rc_map_list real_audio_220_32_keys_map = {
57 .map = { 57 .map = {
58 .scan = real_audio_220_32_keys, 58 .scan = real_audio_220_32_keys,
59 .size = ARRAY_SIZE(real_audio_220_32_keys), 59 .size = ARRAY_SIZE(real_audio_220_32_keys),
60 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 60 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
61 .name = RC_MAP_REAL_AUDIO_220_32_KEYS, 61 .name = RC_MAP_REAL_AUDIO_220_32_KEYS,
62 } 62 }
63}; 63};
64 64
diff --git a/drivers/media/rc/keymaps/rc-reddo.c b/drivers/media/rc/keymaps/rc-reddo.c
index b80b336e9284..3b37acc7b144 100644
--- a/drivers/media/rc/keymaps/rc-reddo.c
+++ b/drivers/media/rc/keymaps/rc-reddo.c
@@ -62,10 +62,10 @@ static struct rc_map_table reddo[] = {
62 62
63static struct rc_map_list reddo_map = { 63static struct rc_map_list reddo_map = {
64 .map = { 64 .map = {
65 .scan = reddo, 65 .scan = reddo,
66 .size = ARRAY_SIZE(reddo), 66 .size = ARRAY_SIZE(reddo),
67 .rc_type = RC_TYPE_NEC, 67 .rc_proto = RC_PROTO_NEC,
68 .name = RC_MAP_REDDO, 68 .name = RC_MAP_REDDO,
69 } 69 }
70}; 70};
71 71
diff --git a/drivers/media/rc/keymaps/rc-snapstream-firefly.c b/drivers/media/rc/keymaps/rc-snapstream-firefly.c
index c7f33ec719b4..30630a6f76ac 100644
--- a/drivers/media/rc/keymaps/rc-snapstream-firefly.c
+++ b/drivers/media/rc/keymaps/rc-snapstream-firefly.c
@@ -83,10 +83,10 @@ static struct rc_map_table snapstream_firefly[] = {
83 83
84static struct rc_map_list snapstream_firefly_map = { 84static struct rc_map_list snapstream_firefly_map = {
85 .map = { 85 .map = {
86 .scan = snapstream_firefly, 86 .scan = snapstream_firefly,
87 .size = ARRAY_SIZE(snapstream_firefly), 87 .size = ARRAY_SIZE(snapstream_firefly),
88 .rc_type = RC_TYPE_OTHER, 88 .rc_proto = RC_PROTO_OTHER,
89 .name = RC_MAP_SNAPSTREAM_FIREFLY, 89 .name = RC_MAP_SNAPSTREAM_FIREFLY,
90 } 90 }
91}; 91};
92 92
diff --git a/drivers/media/rc/keymaps/rc-streamzap.c b/drivers/media/rc/keymaps/rc-streamzap.c
index 23c061174ed7..b53bca9e4576 100644
--- a/drivers/media/rc/keymaps/rc-streamzap.c
+++ b/drivers/media/rc/keymaps/rc-streamzap.c
@@ -57,10 +57,10 @@ static struct rc_map_table streamzap[] = {
57 57
58static struct rc_map_list streamzap_map = { 58static struct rc_map_list streamzap_map = {
59 .map = { 59 .map = {
60 .scan = streamzap, 60 .scan = streamzap,
61 .size = ARRAY_SIZE(streamzap), 61 .size = ARRAY_SIZE(streamzap),
62 .rc_type = RC_TYPE_RC5_SZ, 62 .rc_proto = RC_PROTO_RC5_SZ,
63 .name = RC_MAP_STREAMZAP, 63 .name = RC_MAP_STREAMZAP,
64 } 64 }
65}; 65};
66 66
diff --git a/drivers/media/rc/keymaps/rc-su3000.c b/drivers/media/rc/keymaps/rc-su3000.c
index 8dbd3e9bc951..d9af7e3c55d9 100644
--- a/drivers/media/rc/keymaps/rc-su3000.c
+++ b/drivers/media/rc/keymaps/rc-su3000.c
@@ -51,10 +51,10 @@ static struct rc_map_table su3000[] = {
51 51
52static struct rc_map_list su3000_map = { 52static struct rc_map_list su3000_map = {
53 .map = { 53 .map = {
54 .scan = su3000, 54 .scan = su3000,
55 .size = ARRAY_SIZE(su3000), 55 .size = ARRAY_SIZE(su3000),
56 .rc_type = RC_TYPE_RC5, 56 .rc_proto = RC_PROTO_RC5,
57 .name = RC_MAP_SU3000, 57 .name = RC_MAP_SU3000,
58 } 58 }
59}; 59};
60 60
diff --git a/drivers/media/rc/keymaps/rc-tbs-nec.c b/drivers/media/rc/keymaps/rc-tbs-nec.c
index 24ce2a252502..05facc043272 100644
--- a/drivers/media/rc/keymaps/rc-tbs-nec.c
+++ b/drivers/media/rc/keymaps/rc-tbs-nec.c
@@ -52,10 +52,10 @@ static struct rc_map_table tbs_nec[] = {
52 52
53static struct rc_map_list tbs_nec_map = { 53static struct rc_map_list tbs_nec_map = {
54 .map = { 54 .map = {
55 .scan = tbs_nec, 55 .scan = tbs_nec,
56 .size = ARRAY_SIZE(tbs_nec), 56 .size = ARRAY_SIZE(tbs_nec),
57 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 57 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
58 .name = RC_MAP_TBS_NEC, 58 .name = RC_MAP_TBS_NEC,
59 } 59 }
60}; 60};
61 61
diff --git a/drivers/media/rc/keymaps/rc-technisat-ts35.c b/drivers/media/rc/keymaps/rc-technisat-ts35.c
index 3328cbefabad..dff7021734ba 100644
--- a/drivers/media/rc/keymaps/rc-technisat-ts35.c
+++ b/drivers/media/rc/keymaps/rc-technisat-ts35.c
@@ -53,10 +53,10 @@ static struct rc_map_table technisat_ts35[] = {
53 53
54static struct rc_map_list technisat_ts35_map = { 54static struct rc_map_list technisat_ts35_map = {
55 .map = { 55 .map = {
56 .scan = technisat_ts35, 56 .scan = technisat_ts35,
57 .size = ARRAY_SIZE(technisat_ts35), 57 .size = ARRAY_SIZE(technisat_ts35),
58 .rc_type = RC_TYPE_UNKNOWN, 58 .rc_proto = RC_PROTO_UNKNOWN,
59 .name = RC_MAP_TECHNISAT_TS35, 59 .name = RC_MAP_TECHNISAT_TS35,
60 } 60 }
61}; 61};
62 62
diff --git a/drivers/media/rc/keymaps/rc-technisat-usb2.c b/drivers/media/rc/keymaps/rc-technisat-usb2.c
index 02c9c243c060..58b3baf5ee96 100644
--- a/drivers/media/rc/keymaps/rc-technisat-usb2.c
+++ b/drivers/media/rc/keymaps/rc-technisat-usb2.c
@@ -66,10 +66,10 @@ static struct rc_map_table technisat_usb2[] = {
66 66
67static struct rc_map_list technisat_usb2_map = { 67static struct rc_map_list technisat_usb2_map = {
68 .map = { 68 .map = {
69 .scan = technisat_usb2, 69 .scan = technisat_usb2,
70 .size = ARRAY_SIZE(technisat_usb2), 70 .size = ARRAY_SIZE(technisat_usb2),
71 .rc_type = RC_TYPE_RC5, 71 .rc_proto = RC_PROTO_RC5,
72 .name = RC_MAP_TECHNISAT_USB2, 72 .name = RC_MAP_TECHNISAT_USB2,
73 } 73 }
74}; 74};
75 75
diff --git a/drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.c b/drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.c
index 7958f458527a..7ae88ccf1def 100644
--- a/drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.c
+++ b/drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.c
@@ -65,10 +65,10 @@ static struct rc_map_table terratec_cinergy_c_pci[] = {
65 65
66static struct rc_map_list terratec_cinergy_c_pci_map = { 66static struct rc_map_list terratec_cinergy_c_pci_map = {
67 .map = { 67 .map = {
68 .scan = terratec_cinergy_c_pci, 68 .scan = terratec_cinergy_c_pci,
69 .size = ARRAY_SIZE(terratec_cinergy_c_pci), 69 .size = ARRAY_SIZE(terratec_cinergy_c_pci),
70 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 70 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
71 .name = RC_MAP_TERRATEC_CINERGY_C_PCI, 71 .name = RC_MAP_TERRATEC_CINERGY_C_PCI,
72 } 72 }
73}; 73};
74 74
diff --git a/drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.c b/drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.c
index 1e096bbda4a0..bf0171b05ac2 100644
--- a/drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.c
+++ b/drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.c
@@ -63,10 +63,10 @@ static struct rc_map_table terratec_cinergy_s2_hd[] = {
63 63
64static struct rc_map_list terratec_cinergy_s2_hd_map = { 64static struct rc_map_list terratec_cinergy_s2_hd_map = {
65 .map = { 65 .map = {
66 .scan = terratec_cinergy_s2_hd, 66 .scan = terratec_cinergy_s2_hd,
67 .size = ARRAY_SIZE(terratec_cinergy_s2_hd), 67 .size = ARRAY_SIZE(terratec_cinergy_s2_hd),
68 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 68 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
69 .name = RC_MAP_TERRATEC_CINERGY_S2_HD, 69 .name = RC_MAP_TERRATEC_CINERGY_S2_HD,
70 } 70 }
71}; 71};
72 72
diff --git a/drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c b/drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c
index 97eb83ab5a35..3d0f6f7e5bea 100644
--- a/drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c
+++ b/drivers/media/rc/keymaps/rc-terratec-cinergy-xs.c
@@ -69,10 +69,10 @@ static struct rc_map_table terratec_cinergy_xs[] = {
69 69
70static struct rc_map_list terratec_cinergy_xs_map = { 70static struct rc_map_list terratec_cinergy_xs_map = {
71 .map = { 71 .map = {
72 .scan = terratec_cinergy_xs, 72 .scan = terratec_cinergy_xs,
73 .size = ARRAY_SIZE(terratec_cinergy_xs), 73 .size = ARRAY_SIZE(terratec_cinergy_xs),
74 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 74 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
75 .name = RC_MAP_TERRATEC_CINERGY_XS, 75 .name = RC_MAP_TERRATEC_CINERGY_XS,
76 } 76 }
77}; 77};
78 78
diff --git a/drivers/media/rc/keymaps/rc-terratec-slim-2.c b/drivers/media/rc/keymaps/rc-terratec-slim-2.c
index 4c149ef712dc..df57e0a45820 100644
--- a/drivers/media/rc/keymaps/rc-terratec-slim-2.c
+++ b/drivers/media/rc/keymaps/rc-terratec-slim-2.c
@@ -49,10 +49,10 @@ static struct rc_map_table terratec_slim_2[] = {
49 49
50static struct rc_map_list terratec_slim_2_map = { 50static struct rc_map_list terratec_slim_2_map = {
51 .map = { 51 .map = {
52 .scan = terratec_slim_2, 52 .scan = terratec_slim_2,
53 .size = ARRAY_SIZE(terratec_slim_2), 53 .size = ARRAY_SIZE(terratec_slim_2),
54 .rc_type = RC_TYPE_NEC, 54 .rc_proto = RC_PROTO_NEC,
55 .name = RC_MAP_TERRATEC_SLIM_2, 55 .name = RC_MAP_TERRATEC_SLIM_2,
56 } 56 }
57}; 57};
58 58
diff --git a/drivers/media/rc/keymaps/rc-terratec-slim.c b/drivers/media/rc/keymaps/rc-terratec-slim.c
index 3d8a19cdb5a2..628272c58d65 100644
--- a/drivers/media/rc/keymaps/rc-terratec-slim.c
+++ b/drivers/media/rc/keymaps/rc-terratec-slim.c
@@ -56,10 +56,10 @@ static struct rc_map_table terratec_slim[] = {
56 56
57static struct rc_map_list terratec_slim_map = { 57static struct rc_map_list terratec_slim_map = {
58 .map = { 58 .map = {
59 .scan = terratec_slim, 59 .scan = terratec_slim,
60 .size = ARRAY_SIZE(terratec_slim), 60 .size = ARRAY_SIZE(terratec_slim),
61 .rc_type = RC_TYPE_NEC, 61 .rc_proto = RC_PROTO_NEC,
62 .name = RC_MAP_TERRATEC_SLIM, 62 .name = RC_MAP_TERRATEC_SLIM,
63 } 63 }
64}; 64};
65 65
diff --git a/drivers/media/rc/keymaps/rc-tevii-nec.c b/drivers/media/rc/keymaps/rc-tevii-nec.c
index 38e0c0875596..31f8a0fd1f2c 100644
--- a/drivers/media/rc/keymaps/rc-tevii-nec.c
+++ b/drivers/media/rc/keymaps/rc-tevii-nec.c
@@ -65,10 +65,10 @@ static struct rc_map_table tevii_nec[] = {
65 65
66static struct rc_map_list tevii_nec_map = { 66static struct rc_map_list tevii_nec_map = {
67 .map = { 67 .map = {
68 .scan = tevii_nec, 68 .scan = tevii_nec,
69 .size = ARRAY_SIZE(tevii_nec), 69 .size = ARRAY_SIZE(tevii_nec),
70 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 70 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
71 .name = RC_MAP_TEVII_NEC, 71 .name = RC_MAP_TEVII_NEC,
72 } 72 }
73}; 73};
74 74
diff --git a/drivers/media/rc/keymaps/rc-tivo.c b/drivers/media/rc/keymaps/rc-tivo.c
index 5cc1b456e329..1962e33c8f4e 100644
--- a/drivers/media/rc/keymaps/rc-tivo.c
+++ b/drivers/media/rc/keymaps/rc-tivo.c
@@ -75,10 +75,10 @@ static struct rc_map_table tivo[] = {
75 75
76static struct rc_map_list tivo_map = { 76static struct rc_map_list tivo_map = {
77 .map = { 77 .map = {
78 .scan = tivo, 78 .scan = tivo,
79 .size = ARRAY_SIZE(tivo), 79 .size = ARRAY_SIZE(tivo),
80 .rc_type = RC_TYPE_NEC, 80 .rc_proto = RC_PROTO_NEC,
81 .name = RC_MAP_TIVO, 81 .name = RC_MAP_TIVO,
82 } 82 }
83}; 83};
84 84
diff --git a/drivers/media/rc/keymaps/rc-total-media-in-hand-02.c b/drivers/media/rc/keymaps/rc-total-media-in-hand-02.c
index 47270f72ebf0..eeeca142f7b1 100644
--- a/drivers/media/rc/keymaps/rc-total-media-in-hand-02.c
+++ b/drivers/media/rc/keymaps/rc-total-media-in-hand-02.c
@@ -62,10 +62,10 @@ static struct rc_map_table total_media_in_hand_02[] = {
62 62
63static struct rc_map_list total_media_in_hand_02_map = { 63static struct rc_map_list total_media_in_hand_02_map = {
64 .map = { 64 .map = {
65 .scan = total_media_in_hand_02, 65 .scan = total_media_in_hand_02,
66 .size = ARRAY_SIZE(total_media_in_hand_02), 66 .size = ARRAY_SIZE(total_media_in_hand_02),
67 .rc_type = RC_TYPE_RC5, 67 .rc_proto = RC_PROTO_RC5,
68 .name = RC_MAP_TOTAL_MEDIA_IN_HAND_02, 68 .name = RC_MAP_TOTAL_MEDIA_IN_HAND_02,
69 } 69 }
70}; 70};
71 71
diff --git a/drivers/media/rc/keymaps/rc-total-media-in-hand.c b/drivers/media/rc/keymaps/rc-total-media-in-hand.c
index 5b9f9ec13680..bc73bee309d8 100644
--- a/drivers/media/rc/keymaps/rc-total-media-in-hand.c
+++ b/drivers/media/rc/keymaps/rc-total-media-in-hand.c
@@ -62,10 +62,10 @@ static struct rc_map_table total_media_in_hand[] = {
62 62
63static struct rc_map_list total_media_in_hand_map = { 63static struct rc_map_list total_media_in_hand_map = {
64 .map = { 64 .map = {
65 .scan = total_media_in_hand, 65 .scan = total_media_in_hand,
66 .size = ARRAY_SIZE(total_media_in_hand), 66 .size = ARRAY_SIZE(total_media_in_hand),
67 .rc_type = RC_TYPE_NEC, 67 .rc_proto = RC_PROTO_NEC,
68 .name = RC_MAP_TOTAL_MEDIA_IN_HAND, 68 .name = RC_MAP_TOTAL_MEDIA_IN_HAND,
69 } 69 }
70}; 70};
71 71
diff --git a/drivers/media/rc/keymaps/rc-trekstor.c b/drivers/media/rc/keymaps/rc-trekstor.c
index f9a2e0fabb9f..63f966219342 100644
--- a/drivers/media/rc/keymaps/rc-trekstor.c
+++ b/drivers/media/rc/keymaps/rc-trekstor.c
@@ -57,10 +57,10 @@ static struct rc_map_table trekstor[] = {
57 57
58static struct rc_map_list trekstor_map = { 58static struct rc_map_list trekstor_map = {
59 .map = { 59 .map = {
60 .scan = trekstor, 60 .scan = trekstor,
61 .size = ARRAY_SIZE(trekstor), 61 .size = ARRAY_SIZE(trekstor),
62 .rc_type = RC_TYPE_NEC, 62 .rc_proto = RC_PROTO_NEC,
63 .name = RC_MAP_TREKSTOR, 63 .name = RC_MAP_TREKSTOR,
64 } 64 }
65}; 65};
66 66
diff --git a/drivers/media/rc/keymaps/rc-tt-1500.c b/drivers/media/rc/keymaps/rc-tt-1500.c
index c766d3b2b6b0..374c230705d2 100644
--- a/drivers/media/rc/keymaps/rc-tt-1500.c
+++ b/drivers/media/rc/keymaps/rc-tt-1500.c
@@ -59,10 +59,10 @@ static struct rc_map_table tt_1500[] = {
59 59
60static struct rc_map_list tt_1500_map = { 60static struct rc_map_list tt_1500_map = {
61 .map = { 61 .map = {
62 .scan = tt_1500, 62 .scan = tt_1500,
63 .size = ARRAY_SIZE(tt_1500), 63 .size = ARRAY_SIZE(tt_1500),
64 .rc_type = RC_TYPE_RC5, 64 .rc_proto = RC_PROTO_RC5,
65 .name = RC_MAP_TT_1500, 65 .name = RC_MAP_TT_1500,
66 } 66 }
67}; 67};
68 68
diff --git a/drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c b/drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c
index 202500cb3061..240d720d440c 100644
--- a/drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c
+++ b/drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c
@@ -75,10 +75,10 @@ static struct rc_map_table twinhan_dtv_cab_ci[] = {
75 75
76static struct rc_map_list twinhan_dtv_cab_ci_map = { 76static struct rc_map_list twinhan_dtv_cab_ci_map = {
77 .map = { 77 .map = {
78 .scan = twinhan_dtv_cab_ci, 78 .scan = twinhan_dtv_cab_ci,
79 .size = ARRAY_SIZE(twinhan_dtv_cab_ci), 79 .size = ARRAY_SIZE(twinhan_dtv_cab_ci),
80 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 80 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
81 .name = RC_MAP_TWINHAN_DTV_CAB_CI, 81 .name = RC_MAP_TWINHAN_DTV_CAB_CI,
82 } 82 }
83}; 83};
84 84
diff --git a/drivers/media/rc/keymaps/rc-twinhan1027.c b/drivers/media/rc/keymaps/rc-twinhan1027.c
index 509299b90c90..2275b37c61d2 100644
--- a/drivers/media/rc/keymaps/rc-twinhan1027.c
+++ b/drivers/media/rc/keymaps/rc-twinhan1027.c
@@ -64,10 +64,10 @@ static struct rc_map_table twinhan_vp1027[] = {
64 64
65static struct rc_map_list twinhan_vp1027_map = { 65static struct rc_map_list twinhan_vp1027_map = {
66 .map = { 66 .map = {
67 .scan = twinhan_vp1027, 67 .scan = twinhan_vp1027,
68 .size = ARRAY_SIZE(twinhan_vp1027), 68 .size = ARRAY_SIZE(twinhan_vp1027),
69 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 69 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
70 .name = RC_MAP_TWINHAN_VP1027_DVBS, 70 .name = RC_MAP_TWINHAN_VP1027_DVBS,
71 } 71 }
72}; 72};
73 73
diff --git a/drivers/media/rc/keymaps/rc-videomate-m1f.c b/drivers/media/rc/keymaps/rc-videomate-m1f.c
index 23ee05e53949..fe02e047bd01 100644
--- a/drivers/media/rc/keymaps/rc-videomate-m1f.c
+++ b/drivers/media/rc/keymaps/rc-videomate-m1f.c
@@ -69,10 +69,10 @@ static struct rc_map_table videomate_k100[] = {
69 69
70static struct rc_map_list videomate_k100_map = { 70static struct rc_map_list videomate_k100_map = {
71 .map = { 71 .map = {
72 .scan = videomate_k100, 72 .scan = videomate_k100,
73 .size = ARRAY_SIZE(videomate_k100), 73 .size = ARRAY_SIZE(videomate_k100),
74 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 74 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
75 .name = RC_MAP_VIDEOMATE_K100, 75 .name = RC_MAP_VIDEOMATE_K100,
76 } 76 }
77}; 77};
78 78
diff --git a/drivers/media/rc/keymaps/rc-videomate-s350.c b/drivers/media/rc/keymaps/rc-videomate-s350.c
index 8a354775a2d8..b4f103269872 100644
--- a/drivers/media/rc/keymaps/rc-videomate-s350.c
+++ b/drivers/media/rc/keymaps/rc-videomate-s350.c
@@ -62,10 +62,10 @@ static struct rc_map_table videomate_s350[] = {
62 62
63static struct rc_map_list videomate_s350_map = { 63static struct rc_map_list videomate_s350_map = {
64 .map = { 64 .map = {
65 .scan = videomate_s350, 65 .scan = videomate_s350,
66 .size = ARRAY_SIZE(videomate_s350), 66 .size = ARRAY_SIZE(videomate_s350),
67 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 67 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
68 .name = RC_MAP_VIDEOMATE_S350, 68 .name = RC_MAP_VIDEOMATE_S350,
69 } 69 }
70}; 70};
71 71
diff --git a/drivers/media/rc/keymaps/rc-videomate-tv-pvr.c b/drivers/media/rc/keymaps/rc-videomate-tv-pvr.c
index eb0cda7766c4..c431fdf44057 100644
--- a/drivers/media/rc/keymaps/rc-videomate-tv-pvr.c
+++ b/drivers/media/rc/keymaps/rc-videomate-tv-pvr.c
@@ -64,10 +64,10 @@ static struct rc_map_table videomate_tv_pvr[] = {
64 64
65static struct rc_map_list videomate_tv_pvr_map = { 65static struct rc_map_list videomate_tv_pvr_map = {
66 .map = { 66 .map = {
67 .scan = videomate_tv_pvr, 67 .scan = videomate_tv_pvr,
68 .size = ARRAY_SIZE(videomate_tv_pvr), 68 .size = ARRAY_SIZE(videomate_tv_pvr),
69 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 69 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
70 .name = RC_MAP_VIDEOMATE_TV_PVR, 70 .name = RC_MAP_VIDEOMATE_TV_PVR,
71 } 71 }
72}; 72};
73 73
diff --git a/drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c b/drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c
index c1dd598e828e..5a437e61bd5d 100644
--- a/drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c
+++ b/drivers/media/rc/keymaps/rc-winfast-usbii-deluxe.c
@@ -59,10 +59,10 @@ static struct rc_map_table winfast_usbii_deluxe[] = {
59 59
60static struct rc_map_list winfast_usbii_deluxe_map = { 60static struct rc_map_list winfast_usbii_deluxe_map = {
61 .map = { 61 .map = {
62 .scan = winfast_usbii_deluxe, 62 .scan = winfast_usbii_deluxe,
63 .size = ARRAY_SIZE(winfast_usbii_deluxe), 63 .size = ARRAY_SIZE(winfast_usbii_deluxe),
64 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 64 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
65 .name = RC_MAP_WINFAST_USBII_DELUXE, 65 .name = RC_MAP_WINFAST_USBII_DELUXE,
66 } 66 }
67}; 67};
68 68
diff --git a/drivers/media/rc/keymaps/rc-winfast.c b/drivers/media/rc/keymaps/rc-winfast.c
index 8a779da1e973..53685d1f9a47 100644
--- a/drivers/media/rc/keymaps/rc-winfast.c
+++ b/drivers/media/rc/keymaps/rc-winfast.c
@@ -79,10 +79,10 @@ static struct rc_map_table winfast[] = {
79 79
80static struct rc_map_list winfast_map = { 80static struct rc_map_list winfast_map = {
81 .map = { 81 .map = {
82 .scan = winfast, 82 .scan = winfast,
83 .size = ARRAY_SIZE(winfast), 83 .size = ARRAY_SIZE(winfast),
84 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 84 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
85 .name = RC_MAP_WINFAST, 85 .name = RC_MAP_WINFAST,
86 } 86 }
87}; 87};
88 88
diff --git a/drivers/media/rc/keymaps/rc-zx-irdec.c b/drivers/media/rc/keymaps/rc-zx-irdec.c
new file mode 100644
index 000000000000..5bf3ab002afc
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-zx-irdec.c
@@ -0,0 +1,79 @@
1/*
2 * Copyright (C) 2017 Sanechips Technology Co., Ltd.
3 * Copyright 2017 Linaro Ltd.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/module.h>
11#include <media/rc-map.h>
12
13static struct rc_map_table zx_irdec_table[] = {
14 { 0x01, KEY_1 },
15 { 0x02, KEY_2 },
16 { 0x03, KEY_3 },
17 { 0x04, KEY_4 },
18 { 0x05, KEY_5 },
19 { 0x06, KEY_6 },
20 { 0x07, KEY_7 },
21 { 0x08, KEY_8 },
22 { 0x09, KEY_9 },
23 { 0x31, KEY_0 },
24 { 0x16, KEY_DELETE },
25 { 0x0a, KEY_MODE }, /* Input method */
26 { 0x0c, KEY_VOLUMEUP },
27 { 0x18, KEY_VOLUMEDOWN },
28 { 0x0b, KEY_CHANNELUP },
29 { 0x15, KEY_CHANNELDOWN },
30 { 0x0d, KEY_PAGEUP },
31 { 0x13, KEY_PAGEDOWN },
32 { 0x46, KEY_FASTFORWARD },
33 { 0x43, KEY_REWIND },
34 { 0x44, KEY_PLAYPAUSE },
35 { 0x45, KEY_STOP },
36 { 0x49, KEY_OK },
37 { 0x47, KEY_UP },
38 { 0x4b, KEY_DOWN },
39 { 0x48, KEY_LEFT },
40 { 0x4a, KEY_RIGHT },
41 { 0x4d, KEY_MENU },
42 { 0x56, KEY_APPSELECT }, /* Application */
43 { 0x4c, KEY_BACK },
44 { 0x1e, KEY_INFO },
45 { 0x4e, KEY_F1 },
46 { 0x4f, KEY_F2 },
47 { 0x50, KEY_F3 },
48 { 0x51, KEY_F4 },
49 { 0x1c, KEY_AUDIO },
50 { 0x12, KEY_MUTE },
51 { 0x11, KEY_DOT }, /* Location */
52 { 0x1d, KEY_SETUP },
53 { 0x40, KEY_POWER },
54};
55
56static struct rc_map_list zx_irdec_map = {
57 .map = {
58 .scan = zx_irdec_table,
59 .size = ARRAY_SIZE(zx_irdec_table),
60 .rc_proto = RC_PROTO_NEC,
61 .name = RC_MAP_ZX_IRDEC,
62 }
63};
64
65static int __init init_rc_map_zx_irdec(void)
66{
67 return rc_map_register(&zx_irdec_map);
68}
69
70static void __exit exit_rc_map_zx_irdec(void)
71{
72 rc_map_unregister(&zx_irdec_map);
73}
74
75module_init(init_rc_map_zx_irdec)
76module_exit(exit_rc_map_zx_irdec)
77
78MODULE_AUTHOR("Shawn Guo <shawn.guo@linaro.org>");
79MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index db1e7b70c998..9080e39ea391 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -59,6 +59,8 @@ static void lirc_release(struct device *ld)
59{ 59{
60 struct irctl *ir = container_of(ld, struct irctl, dev); 60 struct irctl *ir = container_of(ld, struct irctl, dev);
61 61
62 put_device(ir->dev.parent);
63
62 if (ir->buf_internal) { 64 if (ir->buf_internal) {
63 lirc_buffer_free(ir->buf); 65 lirc_buffer_free(ir->buf);
64 kfree(ir->buf); 66 kfree(ir->buf);
@@ -218,6 +220,8 @@ int lirc_register_driver(struct lirc_driver *d)
218 220
219 mutex_unlock(&lirc_dev_lock); 221 mutex_unlock(&lirc_dev_lock);
220 222
223 get_device(ir->dev.parent);
224
221 dev_info(ir->d.dev, "lirc_dev: driver %s registered at minor = %d\n", 225 dev_info(ir->d.dev, "lirc_dev: driver %s registered at minor = %d\n",
222 ir->d.name, ir->d.minor); 226 ir->d.name, ir->d.minor);
223 227
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index eb130694bbb8..bf7aaff3aa37 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -538,12 +538,12 @@ static int mceusb_cmd_datasize(u8 cmd, u8 subcmd)
538 return datasize; 538 return datasize;
539} 539}
540 540
541static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf, 541static void mceusb_dev_printdata(struct mceusb_dev *ir, u8 *buf, int buf_len,
542 int buf_len, int offset, int len, bool out) 542 int offset, int len, bool out)
543{ 543{
544#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) 544#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
545 char *inout; 545 char *inout;
546 u8 cmd, subcmd, data1, data2, data3, data4; 546 u8 cmd, subcmd, *data;
547 struct device *dev = ir->dev; 547 struct device *dev = ir->dev;
548 int start, skip = 0; 548 int start, skip = 0;
549 u32 carrier, period; 549 u32 carrier, period;
@@ -564,17 +564,14 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
564 start = offset + skip; 564 start = offset + skip;
565 cmd = buf[start] & 0xff; 565 cmd = buf[start] & 0xff;
566 subcmd = buf[start + 1] & 0xff; 566 subcmd = buf[start + 1] & 0xff;
567 data1 = buf[start + 2] & 0xff; 567 data = buf + start + 2;
568 data2 = buf[start + 3] & 0xff;
569 data3 = buf[start + 4] & 0xff;
570 data4 = buf[start + 5] & 0xff;
571 568
572 switch (cmd) { 569 switch (cmd) {
573 case MCE_CMD_NULL: 570 case MCE_CMD_NULL:
574 if (subcmd == MCE_CMD_NULL) 571 if (subcmd == MCE_CMD_NULL)
575 break; 572 break;
576 if ((subcmd == MCE_CMD_PORT_SYS) && 573 if ((subcmd == MCE_CMD_PORT_SYS) &&
577 (data1 == MCE_CMD_RESUME)) 574 (data[0] == MCE_CMD_RESUME))
578 dev_dbg(dev, "Device resume requested"); 575 dev_dbg(dev, "Device resume requested");
579 else 576 else
580 dev_dbg(dev, "Unknown command 0x%02x 0x%02x", 577 dev_dbg(dev, "Unknown command 0x%02x 0x%02x",
@@ -585,7 +582,7 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
585 case MCE_RSP_EQEMVER: 582 case MCE_RSP_EQEMVER:
586 if (!out) 583 if (!out)
587 dev_dbg(dev, "Emulator interface version %x", 584 dev_dbg(dev, "Emulator interface version %x",
588 data1); 585 data[0]);
589 break; 586 break;
590 case MCE_CMD_G_REVISION: 587 case MCE_CMD_G_REVISION:
591 if (len == 2) 588 if (len == 2)
@@ -603,13 +600,13 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
603 case MCE_RSP_EQWAKEVERSION: 600 case MCE_RSP_EQWAKEVERSION:
604 if (!out) 601 if (!out)
605 dev_dbg(dev, "Wake version, proto: 0x%02x, payload: 0x%02x, address: 0x%02x, version: 0x%02x", 602 dev_dbg(dev, "Wake version, proto: 0x%02x, payload: 0x%02x, address: 0x%02x, version: 0x%02x",
606 data1, data2, data3, data4); 603 data[0], data[1], data[2], data[3]);
607 break; 604 break;
608 case MCE_RSP_GETPORTSTATUS: 605 case MCE_RSP_GETPORTSTATUS:
609 if (!out) 606 if (!out)
610 /* We use data1 + 1 here, to match hw labels */ 607 /* We use data1 + 1 here, to match hw labels */
611 dev_dbg(dev, "TX port %d: blaster is%s connected", 608 dev_dbg(dev, "TX port %d: blaster is%s connected",
612 data1 + 1, data4 ? " not" : ""); 609 data[0] + 1, data[3] ? " not" : "");
613 break; 610 break;
614 case MCE_CMD_FLASHLED: 611 case MCE_CMD_FLASHLED:
615 dev_dbg(dev, "Attempting to flash LED"); 612 dev_dbg(dev, "Attempting to flash LED");
@@ -630,11 +627,11 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
630 break; 627 break;
631 case MCE_CMD_UNKNOWN: 628 case MCE_CMD_UNKNOWN:
632 dev_dbg(dev, "Resp to 9f 05 of 0x%02x 0x%02x", 629 dev_dbg(dev, "Resp to 9f 05 of 0x%02x 0x%02x",
633 data1, data2); 630 data[0], data[1]);
634 break; 631 break;
635 case MCE_RSP_EQIRCFS: 632 case MCE_RSP_EQIRCFS:
636 period = DIV_ROUND_CLOSEST( 633 period = DIV_ROUND_CLOSEST((1U << data[0] * 2) *
637 (1U << data1 * 2) * (data2 + 1), 10); 634 (data[1] + 1), 10);
638 if (!period) 635 if (!period)
639 break; 636 break;
640 carrier = (1000 * 1000) / period; 637 carrier = (1000 * 1000) / period;
@@ -646,11 +643,12 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
646 break; 643 break;
647 case MCE_RSP_EQIRTXPORTS: 644 case MCE_RSP_EQIRTXPORTS:
648 dev_dbg(dev, "%s transmit blaster mask of 0x%02x", 645 dev_dbg(dev, "%s transmit blaster mask of 0x%02x",
649 inout, data1); 646 inout, data[0]);
650 break; 647 break;
651 case MCE_RSP_EQIRTIMEOUT: 648 case MCE_RSP_EQIRTIMEOUT:
652 /* value is in units of 50us, so x*50/1000 ms */ 649 /* value is in units of 50us, so x*50/1000 ms */
653 period = ((data1 << 8) | data2) * MCE_TIME_UNIT / 1000; 650 period = ((data[0] << 8) | data[1]) *
651 MCE_TIME_UNIT / 1000;
654 dev_dbg(dev, "%s receive timeout of %d ms", 652 dev_dbg(dev, "%s receive timeout of %d ms",
655 inout, period); 653 inout, period);
656 break; 654 break;
@@ -662,7 +660,7 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
662 break; 660 break;
663 case MCE_RSP_EQIRRXPORTEN: 661 case MCE_RSP_EQIRRXPORTEN:
664 dev_dbg(dev, "%s %s-range receive sensor in use", 662 dev_dbg(dev, "%s %s-range receive sensor in use",
665 inout, data1 == 0x02 ? "short" : "long"); 663 inout, data[0] == 0x02 ? "short" : "long");
666 break; 664 break;
667 case MCE_CMD_GETIRRXPORTEN: 665 case MCE_CMD_GETIRRXPORTEN:
668 /* aka MCE_RSP_EQIRRXCFCNT */ 666 /* aka MCE_RSP_EQIRRXCFCNT */
@@ -670,13 +668,13 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf,
670 dev_dbg(dev, "Get receive sensor"); 668 dev_dbg(dev, "Get receive sensor");
671 else if (ir->learning_enabled) 669 else if (ir->learning_enabled)
672 dev_dbg(dev, "RX pulse count: %d", 670 dev_dbg(dev, "RX pulse count: %d",
673 ((data1 << 8) | data2)); 671 ((data[0] << 8) | data[1]));
674 break; 672 break;
675 case MCE_RSP_EQIRNUMPORTS: 673 case MCE_RSP_EQIRNUMPORTS:
676 if (out) 674 if (out)
677 break; 675 break;
678 dev_dbg(dev, "Num TX ports: %x, num RX ports: %x", 676 dev_dbg(dev, "Num TX ports: %x, num RX ports: %x",
679 data1, data2); 677 data[0], data[1]);
680 break; 678 break;
681 case MCE_RSP_CMD_ILLEGAL: 679 case MCE_RSP_CMD_ILLEGAL:
682 dev_dbg(dev, "Illegal PORT_IR command"); 680 dev_dbg(dev, "Illegal PORT_IR command");
@@ -1264,12 +1262,12 @@ static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
1264 1262
1265 usb_make_path(ir->usbdev, ir->phys, sizeof(ir->phys)); 1263 usb_make_path(ir->usbdev, ir->phys, sizeof(ir->phys));
1266 1264
1267 rc->input_name = ir->name; 1265 rc->device_name = ir->name;
1268 rc->input_phys = ir->phys; 1266 rc->input_phys = ir->phys;
1269 usb_to_input_id(ir->usbdev, &rc->input_id); 1267 usb_to_input_id(ir->usbdev, &rc->input_id);
1270 rc->dev.parent = dev; 1268 rc->dev.parent = dev;
1271 rc->priv = ir; 1269 rc->priv = ir;
1272 rc->allowed_protocols = RC_BIT_ALL_IR_DECODER; 1270 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
1273 rc->timeout = MS_TO_NS(100); 1271 rc->timeout = MS_TO_NS(100);
1274 if (!ir->flags.no_tx) { 1272 if (!ir->flags.no_tx) {
1275 rc->s_tx_mask = mceusb_set_tx_mask; 1273 rc->s_tx_mask = mceusb_set_tx_mask;
diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c
index 65566d569cb1..f2204eb77e2a 100644
--- a/drivers/media/rc/meson-ir.c
+++ b/drivers/media/rc/meson-ir.c
@@ -138,12 +138,12 @@ static int meson_ir_probe(struct platform_device *pdev)
138 } 138 }
139 139
140 ir->rc->priv = ir; 140 ir->rc->priv = ir;
141 ir->rc->input_name = DRIVER_NAME; 141 ir->rc->device_name = DRIVER_NAME;
142 ir->rc->input_phys = DRIVER_NAME "/input0"; 142 ir->rc->input_phys = DRIVER_NAME "/input0";
143 ir->rc->input_id.bustype = BUS_HOST; 143 ir->rc->input_id.bustype = BUS_HOST;
144 map_name = of_get_property(node, "linux,rc-map-name", NULL); 144 map_name = of_get_property(node, "linux,rc-map-name", NULL);
145 ir->rc->map_name = map_name ? map_name : RC_MAP_EMPTY; 145 ir->rc->map_name = map_name ? map_name : RC_MAP_EMPTY;
146 ir->rc->allowed_protocols = RC_BIT_ALL_IR_DECODER; 146 ir->rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
147 ir->rc->rx_resolution = US_TO_NS(MESON_TRATE); 147 ir->rc->rx_resolution = US_TO_NS(MESON_TRATE);
148 ir->rc->timeout = MS_TO_NS(200); 148 ir->rc->timeout = MS_TO_NS(200);
149 ir->rc->driver_name = DRIVER_NAME; 149 ir->rc->driver_name = DRIVER_NAME;
diff --git a/drivers/media/rc/mtk-cir.c b/drivers/media/rc/mtk-cir.c
index f1e164e441e8..e88eb64e8e69 100644
--- a/drivers/media/rc/mtk-cir.c
+++ b/drivers/media/rc/mtk-cir.c
@@ -25,35 +25,28 @@
25 25
26/* Register to enable PWM and IR */ 26/* Register to enable PWM and IR */
27#define MTK_CONFIG_HIGH_REG 0x0c 27#define MTK_CONFIG_HIGH_REG 0x0c
28/* Enable IR pulse width detection */ 28
29/* Bit to enable IR pulse width detection */
29#define MTK_PWM_EN BIT(13) 30#define MTK_PWM_EN BIT(13)
30/* Enable IR hardware function */
31#define MTK_IR_EN BIT(0)
32 31
33/* Register to setting sample period */ 32/*
34#define MTK_CONFIG_LOW_REG 0x10 33 * Register to setting ok count whose unit based on hardware sampling period
35/* Field to set sample period */ 34 * indicating IR receiving completion and then making IRQ fires
36#define CHK_PERIOD DIV_ROUND_CLOSEST(MTK_IR_SAMPLE, \ 35 */
37 MTK_IR_CLK_PERIOD) 36#define MTK_OK_COUNT(x) (((x) & GENMASK(23, 16)) << 16)
38#define MTK_CHK_PERIOD (((CHK_PERIOD) << 8) & (GENMASK(20, 8))) 37
39#define MTK_CHK_PERIOD_MASK (GENMASK(20, 8)) 38/* Bit to enable IR hardware function */
39#define MTK_IR_EN BIT(0)
40 40
41/* Register to clear state of state machine */
42#define MTK_IRCLR_REG 0x20
43/* Bit to restart IR receiving */ 41/* Bit to restart IR receiving */
44#define MTK_IRCLR BIT(0) 42#define MTK_IRCLR BIT(0)
45 43
46/* Register containing pulse width data */ 44/* Fields containing pulse width data */
47#define MTK_CHKDATA_REG(i) (0x88 + 4 * (i))
48#define MTK_WIDTH_MASK (GENMASK(7, 0)) 45#define MTK_WIDTH_MASK (GENMASK(7, 0))
49 46
50/* Register to enable IR interrupt */
51#define MTK_IRINT_EN_REG 0xcc
52/* Bit to enable interrupt */ 47/* Bit to enable interrupt */
53#define MTK_IRINT_EN BIT(0) 48#define MTK_IRINT_EN BIT(0)
54 49
55/* Register to ack IR interrupt */
56#define MTK_IRINT_CLR_REG 0xd0
57/* Bit to clear interrupt status */ 50/* Bit to clear interrupt status */
58#define MTK_IRINT_CLR BIT(0) 51#define MTK_IRINT_CLR BIT(0)
59 52
@@ -63,24 +56,85 @@
63#define MTK_IR_END(v, p) ((v) == MTK_MAX_SAMPLES && (p) == 0) 56#define MTK_IR_END(v, p) ((v) == MTK_MAX_SAMPLES && (p) == 0)
64/* Number of registers to record the pulse width */ 57/* Number of registers to record the pulse width */
65#define MTK_CHKDATA_SZ 17 58#define MTK_CHKDATA_SZ 17
66/* Source clock frequency */
67#define MTK_IR_BASE_CLK 273000000
68/* Frequency after IR internal divider */
69#define MTK_IR_CLK_FREQ (MTK_IR_BASE_CLK / 4)
70/* Period for MTK_IR_CLK in ns*/
71#define MTK_IR_CLK_PERIOD DIV_ROUND_CLOSEST(1000000000ul, \
72 MTK_IR_CLK_FREQ)
73/* Sample period in ns */ 59/* Sample period in ns */
74#define MTK_IR_SAMPLE (MTK_IR_CLK_PERIOD * 0xc00) 60#define MTK_IR_SAMPLE 46000
61
62enum mtk_fields {
63 /* Register to setting software sampling period */
64 MTK_CHK_PERIOD,
65 /* Register to setting hardware sampling period */
66 MTK_HW_PERIOD,
67};
68
69enum mtk_regs {
70 /* Register to clear state of state machine */
71 MTK_IRCLR_REG,
72 /* Register containing pulse width data */
73 MTK_CHKDATA_REG,
74 /* Register to enable IR interrupt */
75 MTK_IRINT_EN_REG,
76 /* Register to ack IR interrupt */
77 MTK_IRINT_CLR_REG
78};
79
80static const u32 mt7623_regs[] = {
81 [MTK_IRCLR_REG] = 0x20,
82 [MTK_CHKDATA_REG] = 0x88,
83 [MTK_IRINT_EN_REG] = 0xcc,
84 [MTK_IRINT_CLR_REG] = 0xd0,
85};
86
87static const u32 mt7622_regs[] = {
88 [MTK_IRCLR_REG] = 0x18,
89 [MTK_CHKDATA_REG] = 0x30,
90 [MTK_IRINT_EN_REG] = 0x1c,
91 [MTK_IRINT_CLR_REG] = 0x20,
92};
93
94struct mtk_field_type {
95 u32 reg;
96 u8 offset;
97 u32 mask;
98};
99
100/*
101 * struct mtk_ir_data - This is the structure holding all differences among
102 various hardwares
103 * @regs: The pointer to the array holding registers offset
104 * @fields: The pointer to the array holding fields location
105 * @div: The internal divisor for the based reference clock
106 * @ok_count: The count indicating the completion of IR data
107 * receiving when count is reached
108 * @hw_period: The value indicating the hardware sampling period
109 */
110struct mtk_ir_data {
111 const u32 *regs;
112 const struct mtk_field_type *fields;
113 u8 div;
114 u8 ok_count;
115 u32 hw_period;
116};
117
118static const struct mtk_field_type mt7623_fields[] = {
119 [MTK_CHK_PERIOD] = {0x10, 8, GENMASK(20, 8)},
120 [MTK_HW_PERIOD] = {0x10, 0, GENMASK(7, 0)},
121};
122
123static const struct mtk_field_type mt7622_fields[] = {
124 [MTK_CHK_PERIOD] = {0x24, 0, GENMASK(24, 0)},
125 [MTK_HW_PERIOD] = {0x10, 0, GENMASK(24, 0)},
126};
75 127
76/* 128/*
77 * struct mtk_ir - This is the main datasructure for holding the state 129 * struct mtk_ir - This is the main datasructure for holding the state
78 * of the driver 130 * of the driver
79 * @dev: The device pointer 131 * @dev: The device pointer
80 * @rc: The rc instrance 132 * @rc: The rc instrance
81 * @irq: The IRQ that we are using
82 * @base: The mapped register i/o base 133 * @base: The mapped register i/o base
83 * @clk: The clock that we are using 134 * @irq: The IRQ that we are using
135 * @clk: The clock that IR internal is using
136 * @bus: The clock that software decoder is using
137 * @data: Holding specific data for vaious platform
84 */ 138 */
85struct mtk_ir { 139struct mtk_ir {
86 struct device *dev; 140 struct device *dev;
@@ -88,8 +142,36 @@ struct mtk_ir {
88 void __iomem *base; 142 void __iomem *base;
89 int irq; 143 int irq;
90 struct clk *clk; 144 struct clk *clk;
145 struct clk *bus;
146 const struct mtk_ir_data *data;
91}; 147};
92 148
149static inline u32 mtk_chkdata_reg(struct mtk_ir *ir, u32 i)
150{
151 return ir->data->regs[MTK_CHKDATA_REG] + 4 * i;
152}
153
154static inline u32 mtk_chk_period(struct mtk_ir *ir)
155{
156 u32 val;
157
158 /* Period of raw software sampling in ns */
159 val = DIV_ROUND_CLOSEST(1000000000ul,
160 clk_get_rate(ir->bus) / ir->data->div);
161
162 /*
163 * Period for software decoder used in the
164 * unit of raw software sampling
165 */
166 val = DIV_ROUND_CLOSEST(MTK_IR_SAMPLE, val);
167
168 dev_dbg(ir->dev, "@pwm clk = \t%lu\n",
169 clk_get_rate(ir->bus) / ir->data->div);
170 dev_dbg(ir->dev, "@chkperiod = %08x\n", val);
171
172 return val;
173}
174
93static void mtk_w32_mask(struct mtk_ir *ir, u32 val, u32 mask, unsigned int reg) 175static void mtk_w32_mask(struct mtk_ir *ir, u32 val, u32 mask, unsigned int reg)
94{ 176{
95 u32 tmp; 177 u32 tmp;
@@ -113,16 +195,16 @@ static inline void mtk_irq_disable(struct mtk_ir *ir, u32 mask)
113{ 195{
114 u32 val; 196 u32 val;
115 197
116 val = mtk_r32(ir, MTK_IRINT_EN_REG); 198 val = mtk_r32(ir, ir->data->regs[MTK_IRINT_EN_REG]);
117 mtk_w32(ir, val & ~mask, MTK_IRINT_EN_REG); 199 mtk_w32(ir, val & ~mask, ir->data->regs[MTK_IRINT_EN_REG]);
118} 200}
119 201
120static inline void mtk_irq_enable(struct mtk_ir *ir, u32 mask) 202static inline void mtk_irq_enable(struct mtk_ir *ir, u32 mask)
121{ 203{
122 u32 val; 204 u32 val;
123 205
124 val = mtk_r32(ir, MTK_IRINT_EN_REG); 206 val = mtk_r32(ir, ir->data->regs[MTK_IRINT_EN_REG]);
125 mtk_w32(ir, val | mask, MTK_IRINT_EN_REG); 207 mtk_w32(ir, val | mask, ir->data->regs[MTK_IRINT_EN_REG]);
126} 208}
127 209
128static irqreturn_t mtk_ir_irq(int irqno, void *dev_id) 210static irqreturn_t mtk_ir_irq(int irqno, void *dev_id)
@@ -140,7 +222,7 @@ static irqreturn_t mtk_ir_irq(int irqno, void *dev_id)
140 * every decoder to reset themselves through long enough 222 * every decoder to reset themselves through long enough
141 * trailing spaces and 2) the IRQ handler guarantees that 223 * trailing spaces and 2) the IRQ handler guarantees that
142 * start of IR message is always contained in and starting 224 * start of IR message is always contained in and starting
143 * from register MTK_CHKDATA_REG(0). 225 * from register mtk_chkdata_reg(ir, i).
144 */ 226 */
145 ir_raw_event_reset(ir->rc); 227 ir_raw_event_reset(ir->rc);
146 228
@@ -149,7 +231,7 @@ static irqreturn_t mtk_ir_irq(int irqno, void *dev_id)
149 231
150 /* Handle all pulse and space IR controller captures */ 232 /* Handle all pulse and space IR controller captures */
151 for (i = 0 ; i < MTK_CHKDATA_SZ ; i++) { 233 for (i = 0 ; i < MTK_CHKDATA_SZ ; i++) {
152 val = mtk_r32(ir, MTK_CHKDATA_REG(i)); 234 val = mtk_r32(ir, mtk_chkdata_reg(ir, i));
153 dev_dbg(ir->dev, "@reg%d=0x%08x\n", i, val); 235 dev_dbg(ir->dev, "@reg%d=0x%08x\n", i, val);
154 236
155 for (j = 0 ; j < 4 ; j++) { 237 for (j = 0 ; j < 4 ; j++) {
@@ -181,18 +263,44 @@ static irqreturn_t mtk_ir_irq(int irqno, void *dev_id)
181 * Restart controller for the next receive that would 263 * Restart controller for the next receive that would
182 * clear up all CHKDATA registers 264 * clear up all CHKDATA registers
183 */ 265 */
184 mtk_w32_mask(ir, 0x1, MTK_IRCLR, MTK_IRCLR_REG); 266 mtk_w32_mask(ir, 0x1, MTK_IRCLR, ir->data->regs[MTK_IRCLR_REG]);
185 267
186 /* Clear interrupt status */ 268 /* Clear interrupt status */
187 mtk_w32_mask(ir, 0x1, MTK_IRINT_CLR, MTK_IRINT_CLR_REG); 269 mtk_w32_mask(ir, 0x1, MTK_IRINT_CLR,
270 ir->data->regs[MTK_IRINT_CLR_REG]);
188 271
189 return IRQ_HANDLED; 272 return IRQ_HANDLED;
190} 273}
191 274
275static const struct mtk_ir_data mt7623_data = {
276 .regs = mt7623_regs,
277 .fields = mt7623_fields,
278 .ok_count = 0xf,
279 .hw_period = 0xff,
280 .div = 4,
281};
282
283static const struct mtk_ir_data mt7622_data = {
284 .regs = mt7622_regs,
285 .fields = mt7622_fields,
286 .ok_count = 0xf,
287 .hw_period = 0xffff,
288 .div = 32,
289};
290
291static const struct of_device_id mtk_ir_match[] = {
292 { .compatible = "mediatek,mt7623-cir", .data = &mt7623_data},
293 { .compatible = "mediatek,mt7622-cir", .data = &mt7622_data},
294 {},
295};
296MODULE_DEVICE_TABLE(of, mtk_ir_match);
297
192static int mtk_ir_probe(struct platform_device *pdev) 298static int mtk_ir_probe(struct platform_device *pdev)
193{ 299{
194 struct device *dev = &pdev->dev; 300 struct device *dev = &pdev->dev;
195 struct device_node *dn = dev->of_node; 301 struct device_node *dn = dev->of_node;
302 const struct of_device_id *of_id =
303 of_match_device(mtk_ir_match, &pdev->dev);
196 struct resource *res; 304 struct resource *res;
197 struct mtk_ir *ir; 305 struct mtk_ir *ir;
198 u32 val; 306 u32 val;
@@ -204,9 +312,7 @@ static int mtk_ir_probe(struct platform_device *pdev)
204 return -ENOMEM; 312 return -ENOMEM;
205 313
206 ir->dev = dev; 314 ir->dev = dev;
207 315 ir->data = of_id->data;
208 if (!of_device_is_compatible(dn, "mediatek,mt7623-cir"))
209 return -ENODEV;
210 316
211 ir->clk = devm_clk_get(dev, "clk"); 317 ir->clk = devm_clk_get(dev, "clk");
212 if (IS_ERR(ir->clk)) { 318 if (IS_ERR(ir->clk)) {
@@ -214,6 +320,15 @@ static int mtk_ir_probe(struct platform_device *pdev)
214 return PTR_ERR(ir->clk); 320 return PTR_ERR(ir->clk);
215 } 321 }
216 322
323 ir->bus = devm_clk_get(dev, "bus");
324 if (IS_ERR(ir->bus)) {
325 /*
326 * For compatibility with older device trees try unnamed
327 * ir->bus uses the same clock as ir->clock.
328 */
329 ir->bus = ir->clk;
330 }
331
217 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 332 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
218 ir->base = devm_ioremap_resource(dev, res); 333 ir->base = devm_ioremap_resource(dev, res);
219 if (IS_ERR(ir->base)) { 334 if (IS_ERR(ir->base)) {
@@ -228,7 +343,7 @@ static int mtk_ir_probe(struct platform_device *pdev)
228 } 343 }
229 344
230 ir->rc->priv = ir; 345 ir->rc->priv = ir;
231 ir->rc->input_name = MTK_IR_DEV; 346 ir->rc->device_name = MTK_IR_DEV;
232 ir->rc->input_phys = MTK_IR_DEV "/input0"; 347 ir->rc->input_phys = MTK_IR_DEV "/input0";
233 ir->rc->input_id.bustype = BUS_HOST; 348 ir->rc->input_id.bustype = BUS_HOST;
234 ir->rc->input_id.vendor = 0x0001; 349 ir->rc->input_id.vendor = 0x0001;
@@ -238,7 +353,7 @@ static int mtk_ir_probe(struct platform_device *pdev)
238 ir->rc->map_name = map_name ?: RC_MAP_EMPTY; 353 ir->rc->map_name = map_name ?: RC_MAP_EMPTY;
239 ir->rc->dev.parent = dev; 354 ir->rc->dev.parent = dev;
240 ir->rc->driver_name = MTK_IR_DEV; 355 ir->rc->driver_name = MTK_IR_DEV;
241 ir->rc->allowed_protocols = RC_BIT_ALL; 356 ir->rc->allowed_protocols = RC_PROTO_BIT_ALL;
242 ir->rc->rx_resolution = MTK_IR_SAMPLE; 357 ir->rc->rx_resolution = MTK_IR_SAMPLE;
243 ir->rc->timeout = MTK_MAX_SAMPLES * (MTK_IR_SAMPLE + 1); 358 ir->rc->timeout = MTK_MAX_SAMPLES * (MTK_IR_SAMPLE + 1);
244 359
@@ -256,40 +371,60 @@ static int mtk_ir_probe(struct platform_device *pdev)
256 return -ENODEV; 371 return -ENODEV;
257 } 372 }
258 373
259 /*
260 * Enable interrupt after proper hardware
261 * setup and IRQ handler registration
262 */
263 if (clk_prepare_enable(ir->clk)) { 374 if (clk_prepare_enable(ir->clk)) {
264 dev_err(dev, "try to enable ir_clk failed\n"); 375 dev_err(dev, "try to enable ir_clk failed\n");
376 return -EINVAL;
377 }
378
379 if (clk_prepare_enable(ir->bus)) {
380 dev_err(dev, "try to enable ir_clk failed\n");
265 ret = -EINVAL; 381 ret = -EINVAL;
266 goto exit_clkdisable_clk; 382 goto exit_clkdisable_clk;
267 } 383 }
268 384
385 /*
386 * Enable interrupt after proper hardware
387 * setup and IRQ handler registration
388 */
269 mtk_irq_disable(ir, MTK_IRINT_EN); 389 mtk_irq_disable(ir, MTK_IRINT_EN);
270 390
271 ret = devm_request_irq(dev, ir->irq, mtk_ir_irq, 0, MTK_IR_DEV, ir); 391 ret = devm_request_irq(dev, ir->irq, mtk_ir_irq, 0, MTK_IR_DEV, ir);
272 if (ret) { 392 if (ret) {
273 dev_err(dev, "failed request irq\n"); 393 dev_err(dev, "failed request irq\n");
274 goto exit_clkdisable_clk; 394 goto exit_clkdisable_bus;
275 } 395 }
276 396
397 /*
398 * Setup software sample period as the reference of software decoder
399 */
400 val = (mtk_chk_period(ir) << ir->data->fields[MTK_CHK_PERIOD].offset) &
401 ir->data->fields[MTK_CHK_PERIOD].mask;
402 mtk_w32_mask(ir, val, ir->data->fields[MTK_CHK_PERIOD].mask,
403 ir->data->fields[MTK_CHK_PERIOD].reg);
404
405 /*
406 * Setup hardware sampling period used to setup the proper timeout for
407 * indicating end of IR receiving completion
408 */
409 val = (ir->data->hw_period << ir->data->fields[MTK_HW_PERIOD].offset) &
410 ir->data->fields[MTK_HW_PERIOD].mask;
411 mtk_w32_mask(ir, val, ir->data->fields[MTK_HW_PERIOD].mask,
412 ir->data->fields[MTK_HW_PERIOD].reg);
413
277 /* Enable IR and PWM */ 414 /* Enable IR and PWM */
278 val = mtk_r32(ir, MTK_CONFIG_HIGH_REG); 415 val = mtk_r32(ir, MTK_CONFIG_HIGH_REG);
279 val |= MTK_PWM_EN | MTK_IR_EN; 416 val |= MTK_OK_COUNT(ir->data->ok_count) | MTK_PWM_EN | MTK_IR_EN;
280 mtk_w32(ir, val, MTK_CONFIG_HIGH_REG); 417 mtk_w32(ir, val, MTK_CONFIG_HIGH_REG);
281 418
282 /* Setting sample period */
283 mtk_w32_mask(ir, MTK_CHK_PERIOD, MTK_CHK_PERIOD_MASK,
284 MTK_CONFIG_LOW_REG);
285
286 mtk_irq_enable(ir, MTK_IRINT_EN); 419 mtk_irq_enable(ir, MTK_IRINT_EN);
287 420
288 dev_info(dev, "Initialized MT7623 IR driver, sample period = %luus\n", 421 dev_info(dev, "Initialized MT7623 IR driver, sample period = %dus\n",
289 DIV_ROUND_CLOSEST(MTK_IR_SAMPLE, 1000)); 422 DIV_ROUND_CLOSEST(MTK_IR_SAMPLE, 1000));
290 423
291 return 0; 424 return 0;
292 425
426exit_clkdisable_bus:
427 clk_disable_unprepare(ir->bus);
293exit_clkdisable_clk: 428exit_clkdisable_clk:
294 clk_disable_unprepare(ir->clk); 429 clk_disable_unprepare(ir->clk);
295 430
@@ -308,17 +443,12 @@ static int mtk_ir_remove(struct platform_device *pdev)
308 mtk_irq_disable(ir, MTK_IRINT_EN); 443 mtk_irq_disable(ir, MTK_IRINT_EN);
309 synchronize_irq(ir->irq); 444 synchronize_irq(ir->irq);
310 445
446 clk_disable_unprepare(ir->bus);
311 clk_disable_unprepare(ir->clk); 447 clk_disable_unprepare(ir->clk);
312 448
313 return 0; 449 return 0;
314} 450}
315 451
316static const struct of_device_id mtk_ir_match[] = {
317 { .compatible = "mediatek,mt7623-cir" },
318 {},
319};
320MODULE_DEVICE_TABLE(of, mtk_ir_match);
321
322static struct platform_driver mtk_ir_driver = { 452static struct platform_driver mtk_ir_driver = {
323 .probe = mtk_ir_probe, 453 .probe = mtk_ir_probe,
324 .remove = mtk_ir_remove, 454 .remove = mtk_ir_remove,
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index ec4b25bd2ec2..5e1d866a61a5 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -727,70 +727,6 @@ out_raw:
727 return ret; 727 return ret;
728} 728}
729 729
730/*
731 * nvt_tx_ir
732 *
733 * 1) clean TX fifo first (handled by AP)
734 * 2) copy data from user space
735 * 3) disable RX interrupts, enable TX interrupts: TTR & TFU
736 * 4) send 9 packets to TX FIFO to open TTR
737 * in interrupt_handler:
738 * 5) send all data out
739 * go back to write():
740 * 6) disable TX interrupts, re-enable RX interupts
741 *
742 * The key problem of this function is user space data may larger than
743 * driver's data buf length. So nvt_tx_ir() will only copy TX_BUF_LEN data to
744 * buf, and keep current copied data buf num in cur_buf_num. But driver's buf
745 * number may larger than TXFCONT (0xff). So in interrupt_handler, it has to
746 * set TXFCONT as 0xff, until buf_count less than 0xff.
747 */
748static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n)
749{
750 struct nvt_dev *nvt = dev->priv;
751 unsigned long flags;
752 unsigned int i;
753 u8 iren;
754 int ret;
755
756 spin_lock_irqsave(&nvt->lock, flags);
757
758 ret = min((unsigned)(TX_BUF_LEN / sizeof(unsigned)), n);
759 nvt->tx.buf_count = (ret * sizeof(unsigned));
760
761 memcpy(nvt->tx.buf, txbuf, nvt->tx.buf_count);
762
763 nvt->tx.cur_buf_num = 0;
764
765 /* save currently enabled interrupts */
766 iren = nvt_cir_reg_read(nvt, CIR_IREN);
767
768 /* now disable all interrupts, save TFU & TTR */
769 nvt_cir_reg_write(nvt, CIR_IREN_TFU | CIR_IREN_TTR, CIR_IREN);
770
771 nvt->tx.tx_state = ST_TX_REPLY;
772
773 nvt_cir_reg_write(nvt, CIR_FIFOCON_TX_TRIGGER_LEV_8 |
774 CIR_FIFOCON_RXFIFOCLR, CIR_FIFOCON);
775
776 /* trigger TTR interrupt by writing out ones, (yes, it's ugly) */
777 for (i = 0; i < 9; i++)
778 nvt_cir_reg_write(nvt, 0x01, CIR_STXFIFO);
779
780 spin_unlock_irqrestore(&nvt->lock, flags);
781
782 wait_event(nvt->tx.queue, nvt->tx.tx_state == ST_TX_REQUEST);
783
784 spin_lock_irqsave(&nvt->lock, flags);
785 nvt->tx.tx_state = ST_TX_NONE;
786 spin_unlock_irqrestore(&nvt->lock, flags);
787
788 /* restore enabled interrupts to prior state */
789 nvt_cir_reg_write(nvt, iren, CIR_IREN);
790
791 return ret;
792}
793
794/* dump contents of the last rx buffer we got from the hw rx fifo */ 730/* dump contents of the last rx buffer we got from the hw rx fifo */
795static void nvt_dump_rx_buf(struct nvt_dev *nvt) 731static void nvt_dump_rx_buf(struct nvt_dev *nvt)
796{ 732{
@@ -895,11 +831,6 @@ static void nvt_cir_log_irqs(u8 status, u8 iren)
895 CIR_IRSTS_TFU | CIR_IRSTS_GH) ? " ?" : ""); 831 CIR_IRSTS_TFU | CIR_IRSTS_GH) ? " ?" : "");
896} 832}
897 833
898static bool nvt_cir_tx_inactive(struct nvt_dev *nvt)
899{
900 return nvt->tx.tx_state == ST_TX_NONE;
901}
902
903/* interrupt service routine for incoming and outgoing CIR data */ 834/* interrupt service routine for incoming and outgoing CIR data */
904static irqreturn_t nvt_cir_isr(int irq, void *data) 835static irqreturn_t nvt_cir_isr(int irq, void *data)
905{ 836{
@@ -952,40 +883,8 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
952 883
953 if (status & CIR_IRSTS_RFO) 884 if (status & CIR_IRSTS_RFO)
954 nvt_handle_rx_fifo_overrun(nvt); 885 nvt_handle_rx_fifo_overrun(nvt);
955 886 else if (status & (CIR_IRSTS_RTR | CIR_IRSTS_PE))
956 else if (status & (CIR_IRSTS_RTR | CIR_IRSTS_PE)) { 887 nvt_get_rx_ir_data(nvt);
957 /* We only do rx if not tx'ing */
958 if (nvt_cir_tx_inactive(nvt))
959 nvt_get_rx_ir_data(nvt);
960 }
961
962 if (status & CIR_IRSTS_TE)
963 nvt_clear_tx_fifo(nvt);
964
965 if (status & CIR_IRSTS_TTR) {
966 unsigned int pos, count;
967 u8 tmp;
968
969 pos = nvt->tx.cur_buf_num;
970 count = nvt->tx.buf_count;
971
972 /* Write data into the hardware tx fifo while pos < count */
973 if (pos < count) {
974 nvt_cir_reg_write(nvt, nvt->tx.buf[pos], CIR_STXFIFO);
975 nvt->tx.cur_buf_num++;
976 /* Disable TX FIFO Trigger Level Reach (TTR) interrupt */
977 } else {
978 tmp = nvt_cir_reg_read(nvt, CIR_IREN);
979 nvt_cir_reg_write(nvt, tmp & ~CIR_IREN_TTR, CIR_IREN);
980 }
981 }
982
983 if (status & CIR_IRSTS_TFU) {
984 if (nvt->tx.tx_state == ST_TX_REPLY) {
985 nvt->tx.tx_state = ST_TX_REQUEST;
986 wake_up(&nvt->tx.queue);
987 }
988 }
989 888
990 spin_unlock(&nvt->lock); 889 spin_unlock(&nvt->lock);
991 890
@@ -1062,7 +961,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1062 if (!nvt) 961 if (!nvt)
1063 return -ENOMEM; 962 return -ENOMEM;
1064 963
1065 /* input device for IR remote (and tx) */ 964 /* input device for IR remote */
1066 nvt->rdev = devm_rc_allocate_device(&pdev->dev, RC_DRIVER_IR_RAW); 965 nvt->rdev = devm_rc_allocate_device(&pdev->dev, RC_DRIVER_IR_RAW);
1067 if (!nvt->rdev) 966 if (!nvt->rdev)
1068 return -ENOMEM; 967 return -ENOMEM;
@@ -1105,8 +1004,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1105 1004
1106 pnp_set_drvdata(pdev, nvt); 1005 pnp_set_drvdata(pdev, nvt);
1107 1006
1108 init_waitqueue_head(&nvt->tx.queue);
1109
1110 ret = nvt_hw_detect(nvt); 1007 ret = nvt_hw_detect(nvt);
1111 if (ret) 1008 if (ret)
1112 return ret; 1009 return ret;
@@ -1126,15 +1023,14 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1126 1023
1127 /* Set up the rc device */ 1024 /* Set up the rc device */
1128 rdev->priv = nvt; 1025 rdev->priv = nvt;
1129 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 1026 rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
1130 rdev->allowed_wakeup_protocols = RC_BIT_ALL_IR_ENCODER; 1027 rdev->allowed_wakeup_protocols = RC_PROTO_BIT_ALL_IR_ENCODER;
1131 rdev->encode_wakeup = true; 1028 rdev->encode_wakeup = true;
1132 rdev->open = nvt_open; 1029 rdev->open = nvt_open;
1133 rdev->close = nvt_close; 1030 rdev->close = nvt_close;
1134 rdev->tx_ir = nvt_tx_ir;
1135 rdev->s_tx_carrier = nvt_set_tx_carrier; 1031 rdev->s_tx_carrier = nvt_set_tx_carrier;
1136 rdev->s_wakeup_filter = nvt_ir_raw_set_wakeup_filter; 1032 rdev->s_wakeup_filter = nvt_ir_raw_set_wakeup_filter;
1137 rdev->input_name = "Nuvoton w836x7hg Infrared Remote Transceiver"; 1033 rdev->device_name = "Nuvoton w836x7hg Infrared Remote Transceiver";
1138 rdev->input_phys = "nuvoton/cir0"; 1034 rdev->input_phys = "nuvoton/cir0";
1139 rdev->input_id.bustype = BUS_HOST; 1035 rdev->input_id.bustype = BUS_HOST;
1140 rdev->input_id.vendor = PCI_VENDOR_ID_WINBOND2; 1036 rdev->input_id.vendor = PCI_VENDOR_ID_WINBOND2;
@@ -1148,8 +1044,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
1148#if 0 1044#if 0
1149 rdev->min_timeout = XYZ; 1045 rdev->min_timeout = XYZ;
1150 rdev->max_timeout = XYZ; 1046 rdev->max_timeout = XYZ;
1151 /* tx bits */
1152 rdev->tx_resolution = XYZ;
1153#endif 1047#endif
1154 ret = devm_rc_register_device(&pdev->dev, rdev); 1048 ret = devm_rc_register_device(&pdev->dev, rdev);
1155 if (ret) 1049 if (ret)
@@ -1205,8 +1099,6 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)
1205 1099
1206 spin_lock_irqsave(&nvt->lock, flags); 1100 spin_lock_irqsave(&nvt->lock, flags);
1207 1101
1208 nvt->tx.tx_state = ST_TX_NONE;
1209
1210 /* disable all CIR interrupts */ 1102 /* disable all CIR interrupts */
1211 nvt_cir_reg_write(nvt, 0, CIR_IREN); 1103 nvt_cir_reg_write(nvt, 0, CIR_IREN);
1212 1104
diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h
index 88a29df38a57..0737c27f7ddc 100644
--- a/drivers/media/rc/nuvoton-cir.h
+++ b/drivers/media/rc/nuvoton-cir.h
@@ -46,14 +46,6 @@ static int debug;
46 KBUILD_MODNAME ": " text "\n" , ## __VA_ARGS__) 46 KBUILD_MODNAME ": " text "\n" , ## __VA_ARGS__)
47 47
48 48
49/*
50 * Original lirc driver said min value of 76, and recommended value of 256
51 * for the buffer length, but then used 2048. Never mind that the size of the
52 * RX FIFO is 32 bytes... So I'm using 32 for RX and 256 for TX atm, but I'm
53 * not sure if maybe that TX value is off by a factor of 8 (bits vs. bytes),
54 * and I don't have TX-capable hardware to test/debug on...
55 */
56#define TX_BUF_LEN 256
57#define RX_BUF_LEN 32 49#define RX_BUF_LEN 32
58 50
59#define SIO_ID_MASK 0xfff0 51#define SIO_ID_MASK 0xfff0
@@ -81,14 +73,6 @@ struct nvt_dev {
81 u8 buf[RX_BUF_LEN]; 73 u8 buf[RX_BUF_LEN];
82 unsigned int pkts; 74 unsigned int pkts;
83 75
84 struct {
85 u8 buf[TX_BUF_LEN];
86 unsigned int buf_count;
87 unsigned int cur_buf_num;
88 wait_queue_head_t queue;
89 u8 tx_state;
90 } tx;
91
92 /* EFER Config register index/data pair */ 76 /* EFER Config register index/data pair */
93 u32 cr_efir; 77 u32 cr_efir;
94 u32 cr_efdr; 78 u32 cr_efdr;
@@ -103,18 +87,10 @@ struct nvt_dev {
103 u8 chip_major; 87 u8 chip_major;
104 u8 chip_minor; 88 u8 chip_minor;
105 89
106 /* hardware features */
107 bool hw_tx_capable;
108
109 /* carrier period = 1 / frequency */ 90 /* carrier period = 1 / frequency */
110 u32 carrier; 91 u32 carrier;
111}; 92};
112 93
113/* send states */
114#define ST_TX_NONE 0x0
115#define ST_TX_REQUEST 0x2
116#define ST_TX_REPLY 0x4
117
118/* buffer packet constants */ 94/* buffer packet constants */
119#define BUF_PULSE_BIT 0x80 95#define BUF_PULSE_BIT 0x80
120#define BUF_LEN_MASK 0x7f 96#define BUF_LEN_MASK 0x7f
diff --git a/drivers/media/rc/pwm-ir-tx.c b/drivers/media/rc/pwm-ir-tx.c
new file mode 100644
index 000000000000..27d0f5837a76
--- /dev/null
+++ b/drivers/media/rc/pwm-ir-tx.c
@@ -0,0 +1,138 @@
1/*
2 * Copyright (C) 2017 Sean Young <sean@mess.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/kernel.h>
15#include <linux/module.h>
16#include <linux/pwm.h>
17#include <linux/delay.h>
18#include <linux/slab.h>
19#include <linux/of.h>
20#include <linux/platform_device.h>
21#include <media/rc-core.h>
22
23#define DRIVER_NAME "pwm-ir-tx"
24#define DEVICE_NAME "PWM IR Transmitter"
25
26struct pwm_ir {
27 struct pwm_device *pwm;
28 unsigned int carrier;
29 unsigned int duty_cycle;
30};
31
32static const struct of_device_id pwm_ir_of_match[] = {
33 { .compatible = "pwm-ir-tx", },
34 { },
35};
36MODULE_DEVICE_TABLE(of, pwm_ir_of_match);
37
38static int pwm_ir_set_duty_cycle(struct rc_dev *dev, u32 duty_cycle)
39{
40 struct pwm_ir *pwm_ir = dev->priv;
41
42 pwm_ir->duty_cycle = duty_cycle;
43
44 return 0;
45}
46
47static int pwm_ir_set_carrier(struct rc_dev *dev, u32 carrier)
48{
49 struct pwm_ir *pwm_ir = dev->priv;
50
51 if (!carrier)
52 return -EINVAL;
53
54 pwm_ir->carrier = carrier;
55
56 return 0;
57}
58
59static int pwm_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
60 unsigned int count)
61{
62 struct pwm_ir *pwm_ir = dev->priv;
63 struct pwm_device *pwm = pwm_ir->pwm;
64 int i, duty, period;
65 ktime_t edge;
66 long delta;
67
68 period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier);
69 duty = DIV_ROUND_CLOSEST(pwm_ir->duty_cycle * period, 100);
70
71 pwm_config(pwm, duty, period);
72
73 edge = ktime_get();
74
75 for (i = 0; i < count; i++) {
76 if (i % 2) // space
77 pwm_disable(pwm);
78 else
79 pwm_enable(pwm);
80
81 edge = ktime_add_us(edge, txbuf[i]);
82 delta = ktime_us_delta(edge, ktime_get());
83 if (delta > 0)
84 usleep_range(delta, delta + 10);
85 }
86
87 pwm_disable(pwm);
88
89 return count;
90}
91
92static int pwm_ir_probe(struct platform_device *pdev)
93{
94 struct pwm_ir *pwm_ir;
95 struct rc_dev *rcdev;
96 int rc;
97
98 pwm_ir = devm_kmalloc(&pdev->dev, sizeof(*pwm_ir), GFP_KERNEL);
99 if (!pwm_ir)
100 return -ENOMEM;
101
102 pwm_ir->pwm = devm_pwm_get(&pdev->dev, NULL);
103 if (IS_ERR(pwm_ir->pwm))
104 return PTR_ERR(pwm_ir->pwm);
105
106 pwm_ir->carrier = 38000;
107 pwm_ir->duty_cycle = 50;
108
109 rcdev = devm_rc_allocate_device(&pdev->dev, RC_DRIVER_IR_RAW_TX);
110 if (!rcdev)
111 return -ENOMEM;
112
113 rcdev->priv = pwm_ir;
114 rcdev->driver_name = DRIVER_NAME;
115 rcdev->device_name = DEVICE_NAME;
116 rcdev->tx_ir = pwm_ir_tx;
117 rcdev->s_tx_duty_cycle = pwm_ir_set_duty_cycle;
118 rcdev->s_tx_carrier = pwm_ir_set_carrier;
119
120 rc = devm_rc_register_device(&pdev->dev, rcdev);
121 if (rc < 0)
122 dev_err(&pdev->dev, "failed to register rc device\n");
123
124 return rc;
125}
126
127static struct platform_driver pwm_ir_driver = {
128 .probe = pwm_ir_probe,
129 .driver = {
130 .name = DRIVER_NAME,
131 .of_match_table = of_match_ptr(pwm_ir_of_match),
132 },
133};
134module_platform_driver(pwm_ir_driver);
135
136MODULE_DESCRIPTION("PWM IR Transmitter");
137MODULE_AUTHOR("Sean Young <sean@mess.org>");
138MODULE_LICENSE("GPL");
diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h
index b3e7cac2c3ee..7da9c96cb058 100644
--- a/drivers/media/rc/rc-core-priv.h
+++ b/drivers/media/rc/rc-core-priv.h
@@ -27,7 +27,7 @@ struct ir_raw_handler {
27 27
28 u64 protocols; /* which are handled by this handler */ 28 u64 protocols; /* which are handled by this handler */
29 int (*decode)(struct rc_dev *dev, struct ir_raw_event event); 29 int (*decode)(struct rc_dev *dev, struct ir_raw_event event);
30 int (*encode)(enum rc_type protocol, u32 scancode, 30 int (*encode)(enum rc_proto protocol, u32 scancode,
31 struct ir_raw_event *events, unsigned int max); 31 struct ir_raw_event *events, unsigned int max);
32 32
33 /* These two should only be used by the lirc decoder */ 33 /* These two should only be used by the lirc decoder */
@@ -41,8 +41,9 @@ struct ir_raw_event_ctrl {
41 /* fifo for the pulse/space durations */ 41 /* fifo for the pulse/space durations */
42 DECLARE_KFIFO(kfifo, struct ir_raw_event, MAX_IR_EVENT_SIZE); 42 DECLARE_KFIFO(kfifo, struct ir_raw_event, MAX_IR_EVENT_SIZE);
43 ktime_t last_event; /* when last event occurred */ 43 ktime_t last_event; /* when last event occurred */
44 enum raw_event_type last_type; /* last event type */
45 struct rc_dev *dev; /* pointer to the parent rc_dev */ 44 struct rc_dev *dev; /* pointer to the parent rc_dev */
45 /* edge driver */
46 struct timer_list edge_handle;
46 47
47 /* raw decoder state follows */ 48 /* raw decoder state follows */
48 struct ir_raw_event prev_ev; 49 struct ir_raw_event prev_ev;
diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
index b6d256f03847..503bc425a187 100644
--- a/drivers/media/rc/rc-ir-raw.c
+++ b/drivers/media/rc/rc-ir-raw.c
@@ -88,7 +88,7 @@ EXPORT_SYMBOL_GPL(ir_raw_event_store);
88/** 88/**
89 * ir_raw_event_store_edge() - notify raw ir decoders of the start of a pulse/space 89 * ir_raw_event_store_edge() - notify raw ir decoders of the start of a pulse/space
90 * @dev: the struct rc_dev device descriptor 90 * @dev: the struct rc_dev device descriptor
91 * @type: the type of the event that has occurred 91 * @pulse: true for pulse, false for space
92 * 92 *
93 * This routine (which may be called from an interrupt context) is used to 93 * This routine (which may be called from an interrupt context) is used to
94 * store the beginning of an ir pulse or space (or the start/end of ir 94 * store the beginning of an ir pulse or space (or the start/end of ir
@@ -96,43 +96,31 @@ EXPORT_SYMBOL_GPL(ir_raw_event_store);
96 * hardware which does not provide durations directly but only interrupts 96 * hardware which does not provide durations directly but only interrupts
97 * (or similar events) on state change. 97 * (or similar events) on state change.
98 */ 98 */
99int ir_raw_event_store_edge(struct rc_dev *dev, enum raw_event_type type) 99int ir_raw_event_store_edge(struct rc_dev *dev, bool pulse)
100{ 100{
101 ktime_t now; 101 ktime_t now;
102 s64 delta; /* ns */
103 DEFINE_IR_RAW_EVENT(ev); 102 DEFINE_IR_RAW_EVENT(ev);
104 int rc = 0; 103 int rc = 0;
105 int delay;
106 104
107 if (!dev->raw) 105 if (!dev->raw)
108 return -EINVAL; 106 return -EINVAL;
109 107
110 now = ktime_get(); 108 now = ktime_get();
111 delta = ktime_to_ns(ktime_sub(now, dev->raw->last_event)); 109 ev.duration = ktime_to_ns(ktime_sub(now, dev->raw->last_event));
112 delay = MS_TO_NS(dev->input_dev->rep[REP_DELAY]); 110 ev.pulse = !pulse;
113 111
114 /* Check for a long duration since last event or if we're 112 rc = ir_raw_event_store(dev, &ev);
115 * being called for the first time, note that delta can't
116 * possibly be negative.
117 */
118 if (delta > delay || !dev->raw->last_type)
119 type |= IR_START_EVENT;
120 else
121 ev.duration = delta;
122
123 if (type & IR_START_EVENT)
124 ir_raw_event_reset(dev);
125 else if (dev->raw->last_type & IR_SPACE) {
126 ev.pulse = false;
127 rc = ir_raw_event_store(dev, &ev);
128 } else if (dev->raw->last_type & IR_PULSE) {
129 ev.pulse = true;
130 rc = ir_raw_event_store(dev, &ev);
131 } else
132 return 0;
133 113
134 dev->raw->last_event = now; 114 dev->raw->last_event = now;
135 dev->raw->last_type = type; 115
116 /* timer could be set to timeout (125ms by default) */
117 if (!timer_pending(&dev->raw->edge_handle) ||
118 time_after(dev->raw->edge_handle.expires,
119 jiffies + msecs_to_jiffies(15))) {
120 mod_timer(&dev->raw->edge_handle,
121 jiffies + msecs_to_jiffies(15));
122 }
123
136 return rc; 124 return rc;
137} 125}
138EXPORT_SYMBOL_GPL(ir_raw_event_store_edge); 126EXPORT_SYMBOL_GPL(ir_raw_event_store_edge);
@@ -225,7 +213,7 @@ ir_raw_get_allowed_protocols(void)
225 return atomic64_read(&available_protocols); 213 return atomic64_read(&available_protocols);
226} 214}
227 215
228static int change_protocol(struct rc_dev *dev, u64 *rc_type) 216static int change_protocol(struct rc_dev *dev, u64 *rc_proto)
229{ 217{
230 /* the caller will update dev->enabled_protocols */ 218 /* the caller will update dev->enabled_protocols */
231 return 0; 219 return 0;
@@ -462,7 +450,7 @@ EXPORT_SYMBOL(ir_raw_gen_pl);
462 * -EINVAL if the scancode is ambiguous or invalid, or if no 450 * -EINVAL if the scancode is ambiguous or invalid, or if no
463 * compatible encoder was found. 451 * compatible encoder was found.
464 */ 452 */
465int ir_raw_encode_scancode(enum rc_type protocol, u32 scancode, 453int ir_raw_encode_scancode(enum rc_proto protocol, u32 scancode,
466 struct ir_raw_event *events, unsigned int max) 454 struct ir_raw_event *events, unsigned int max)
467{ 455{
468 struct ir_raw_handler *handler; 456 struct ir_raw_handler *handler;
@@ -483,6 +471,27 @@ int ir_raw_encode_scancode(enum rc_type protocol, u32 scancode,
483} 471}
484EXPORT_SYMBOL(ir_raw_encode_scancode); 472EXPORT_SYMBOL(ir_raw_encode_scancode);
485 473
474static void edge_handle(unsigned long arg)
475{
476 struct rc_dev *dev = (struct rc_dev *)arg;
477 ktime_t interval = ktime_sub(ktime_get(), dev->raw->last_event);
478
479 if (ktime_to_ns(interval) >= dev->timeout) {
480 DEFINE_IR_RAW_EVENT(ev);
481
482 ev.timeout = true;
483 ev.duration = ktime_to_ns(interval);
484
485 ir_raw_event_store(dev, &ev);
486 } else {
487 mod_timer(&dev->raw->edge_handle,
488 jiffies + nsecs_to_jiffies(dev->timeout -
489 ktime_to_ns(interval)));
490 }
491
492 ir_raw_event_handle(dev);
493}
494
486/* 495/*
487 * Used to (un)register raw event clients 496 * Used to (un)register raw event clients
488 */ 497 */
@@ -504,6 +513,8 @@ int ir_raw_event_prepare(struct rc_dev *dev)
504 513
505 dev->raw->dev = dev; 514 dev->raw->dev = dev;
506 dev->change_protocol = change_protocol; 515 dev->change_protocol = change_protocol;
516 setup_timer(&dev->raw->edge_handle, edge_handle,
517 (unsigned long)dev);
507 INIT_KFIFO(dev->raw->kfifo); 518 INIT_KFIFO(dev->raw->kfifo);
508 519
509 return 0; 520 return 0;
@@ -555,6 +566,7 @@ void ir_raw_event_unregister(struct rc_dev *dev)
555 return; 566 return;
556 567
557 kthread_stop(dev->raw->thread); 568 kthread_stop(dev->raw->thread);
569 del_timer_sync(&dev->raw->edge_handle);
558 570
559 mutex_lock(&ir_raw_handler_lock); 571 mutex_lock(&ir_raw_handler_lock);
560 list_del(&dev->raw->list); 572 list_del(&dev->raw->list);
diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c
index 62195af24fbe..3822d9ebcb46 100644
--- a/drivers/media/rc/rc-loopback.c
+++ b/drivers/media/rc/rc-loopback.c
@@ -219,15 +219,15 @@ static int __init loop_init(void)
219 return -ENOMEM; 219 return -ENOMEM;
220 } 220 }
221 221
222 rc->input_name = "rc-core loopback device"; 222 rc->device_name = "rc-core loopback device";
223 rc->input_phys = "rc-core/virtual"; 223 rc->input_phys = "rc-core/virtual";
224 rc->input_id.bustype = BUS_VIRTUAL; 224 rc->input_id.bustype = BUS_VIRTUAL;
225 rc->input_id.version = 1; 225 rc->input_id.version = 1;
226 rc->driver_name = DRIVER_NAME; 226 rc->driver_name = DRIVER_NAME;
227 rc->map_name = RC_MAP_EMPTY; 227 rc->map_name = RC_MAP_EMPTY;
228 rc->priv = &loopdev; 228 rc->priv = &loopdev;
229 rc->allowed_protocols = RC_BIT_ALL_IR_DECODER; 229 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
230 rc->allowed_wakeup_protocols = RC_BIT_ALL_IR_ENCODER; 230 rc->allowed_wakeup_protocols = RC_PROTO_BIT_ALL_IR_ENCODER;
231 rc->encode_wakeup = true; 231 rc->encode_wakeup = true;
232 rc->timeout = 100 * 1000 * 1000; /* 100 ms */ 232 rc->timeout = 100 * 1000 * 1000; /* 100 ms */
233 rc->min_timeout = 1; 233 rc->min_timeout = 1;
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index a9eba0013525..981cccd6b988 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -30,8 +30,54 @@
30#define IR_TAB_MAX_SIZE 8192 30#define IR_TAB_MAX_SIZE 8192
31#define RC_DEV_MAX 256 31#define RC_DEV_MAX 256
32 32
33/* FIXME: IR_KEYPRESS_TIMEOUT should be protocol specific */ 33static const struct {
34#define IR_KEYPRESS_TIMEOUT 250 34 const char *name;
35 unsigned int repeat_period;
36 unsigned int scancode_bits;
37} protocols[] = {
38 [RC_PROTO_UNKNOWN] = { .name = "unknown", .repeat_period = 250 },
39 [RC_PROTO_OTHER] = { .name = "other", .repeat_period = 250 },
40 [RC_PROTO_RC5] = { .name = "rc-5",
41 .scancode_bits = 0x1f7f, .repeat_period = 164 },
42 [RC_PROTO_RC5X_20] = { .name = "rc-5x-20",
43 .scancode_bits = 0x1f7f3f, .repeat_period = 164 },
44 [RC_PROTO_RC5_SZ] = { .name = "rc-5-sz",
45 .scancode_bits = 0x2fff, .repeat_period = 164 },
46 [RC_PROTO_JVC] = { .name = "jvc",
47 .scancode_bits = 0xffff, .repeat_period = 250 },
48 [RC_PROTO_SONY12] = { .name = "sony-12",
49 .scancode_bits = 0x1f007f, .repeat_period = 100 },
50 [RC_PROTO_SONY15] = { .name = "sony-15",
51 .scancode_bits = 0xff007f, .repeat_period = 100 },
52 [RC_PROTO_SONY20] = { .name = "sony-20",
53 .scancode_bits = 0x1fff7f, .repeat_period = 100 },
54 [RC_PROTO_NEC] = { .name = "nec",
55 .scancode_bits = 0xffff, .repeat_period = 160 },
56 [RC_PROTO_NECX] = { .name = "nec-x",
57 .scancode_bits = 0xffffff, .repeat_period = 160 },
58 [RC_PROTO_NEC32] = { .name = "nec-32",
59 .scancode_bits = 0xffffffff, .repeat_period = 160 },
60 [RC_PROTO_SANYO] = { .name = "sanyo",
61 .scancode_bits = 0x1fffff, .repeat_period = 250 },
62 [RC_PROTO_MCIR2_KBD] = { .name = "mcir2-kbd",
63 .scancode_bits = 0xffff, .repeat_period = 150 },
64 [RC_PROTO_MCIR2_MSE] = { .name = "mcir2-mse",
65 .scancode_bits = 0x1fffff, .repeat_period = 150 },
66 [RC_PROTO_RC6_0] = { .name = "rc-6-0",
67 .scancode_bits = 0xffff, .repeat_period = 164 },
68 [RC_PROTO_RC6_6A_20] = { .name = "rc-6-6a-20",
69 .scancode_bits = 0xfffff, .repeat_period = 164 },
70 [RC_PROTO_RC6_6A_24] = { .name = "rc-6-6a-24",
71 .scancode_bits = 0xffffff, .repeat_period = 164 },
72 [RC_PROTO_RC6_6A_32] = { .name = "rc-6-6a-32",
73 .scancode_bits = 0xffffffff, .repeat_period = 164 },
74 [RC_PROTO_RC6_MCE] = { .name = "rc-6-mce",
75 .scancode_bits = 0xffff7fff, .repeat_period = 164 },
76 [RC_PROTO_SHARP] = { .name = "sharp",
77 .scancode_bits = 0x1fff, .repeat_period = 250 },
78 [RC_PROTO_XMP] = { .name = "xmp", .repeat_period = 250 },
79 [RC_PROTO_CEC] = { .name = "cec", .repeat_period = 550 },
80};
35 81
36/* Used to keep track of known keymaps */ 82/* Used to keep track of known keymaps */
37static LIST_HEAD(rc_map_list); 83static LIST_HEAD(rc_map_list);
@@ -110,10 +156,10 @@ static struct rc_map_table empty[] = {
110 156
111static struct rc_map_list empty_map = { 157static struct rc_map_list empty_map = {
112 .map = { 158 .map = {
113 .scan = empty, 159 .scan = empty,
114 .size = ARRAY_SIZE(empty), 160 .size = ARRAY_SIZE(empty),
115 .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ 161 .rc_proto = RC_PROTO_UNKNOWN, /* Legacy IR type */
116 .name = RC_MAP_EMPTY, 162 .name = RC_MAP_EMPTY,
117 } 163 }
118}; 164};
119 165
@@ -121,7 +167,7 @@ static struct rc_map_list empty_map = {
121 * ir_create_table() - initializes a scancode table 167 * ir_create_table() - initializes a scancode table
122 * @rc_map: the rc_map to initialize 168 * @rc_map: the rc_map to initialize
123 * @name: name to assign to the table 169 * @name: name to assign to the table
124 * @rc_type: ir type to assign to the new table 170 * @rc_proto: ir type to assign to the new table
125 * @size: initial size of the table 171 * @size: initial size of the table
126 * @return: zero on success or a negative error code 172 * @return: zero on success or a negative error code
127 * 173 *
@@ -129,12 +175,12 @@ static struct rc_map_list empty_map = {
129 * memory to hold at least the specified number of elements. 175 * memory to hold at least the specified number of elements.
130 */ 176 */
131static int ir_create_table(struct rc_map *rc_map, 177static int ir_create_table(struct rc_map *rc_map,
132 const char *name, u64 rc_type, size_t size) 178 const char *name, u64 rc_proto, size_t size)
133{ 179{
134 rc_map->name = kstrdup(name, GFP_KERNEL); 180 rc_map->name = kstrdup(name, GFP_KERNEL);
135 if (!rc_map->name) 181 if (!rc_map->name)
136 return -ENOMEM; 182 return -ENOMEM;
137 rc_map->rc_type = rc_type; 183 rc_map->rc_proto = rc_proto;
138 rc_map->alloc = roundup_pow_of_two(size * sizeof(struct rc_map_table)); 184 rc_map->alloc = roundup_pow_of_two(size * sizeof(struct rc_map_table));
139 rc_map->size = rc_map->alloc / sizeof(struct rc_map_table); 185 rc_map->size = rc_map->alloc / sizeof(struct rc_map_table);
140 rc_map->scan = kmalloc(rc_map->alloc, GFP_KERNEL); 186 rc_map->scan = kmalloc(rc_map->alloc, GFP_KERNEL);
@@ -389,7 +435,7 @@ static int ir_setkeytable(struct rc_dev *dev,
389 int rc; 435 int rc;
390 436
391 rc = ir_create_table(rc_map, from->name, 437 rc = ir_create_table(rc_map, from->name,
392 from->rc_type, from->size); 438 from->rc_proto, from->size);
393 if (rc) 439 if (rc)
394 return rc; 440 return rc;
395 441
@@ -530,7 +576,7 @@ u32 rc_g_keycode_from_table(struct rc_dev *dev, u32 scancode)
530 576
531 if (keycode != KEY_RESERVED) 577 if (keycode != KEY_RESERVED)
532 IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n", 578 IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n",
533 dev->input_name, scancode, keycode); 579 dev->device_name, scancode, keycode);
534 580
535 return keycode; 581 return keycode;
536} 582}
@@ -613,16 +659,17 @@ static void ir_timer_keyup(unsigned long cookie)
613void rc_repeat(struct rc_dev *dev) 659void rc_repeat(struct rc_dev *dev)
614{ 660{
615 unsigned long flags; 661 unsigned long flags;
662 unsigned int timeout = protocols[dev->last_protocol].repeat_period;
616 663
617 spin_lock_irqsave(&dev->keylock, flags); 664 spin_lock_irqsave(&dev->keylock, flags);
618 665
619 input_event(dev->input_dev, EV_MSC, MSC_SCAN, dev->last_scancode);
620 input_sync(dev->input_dev);
621
622 if (!dev->keypressed) 666 if (!dev->keypressed)
623 goto out; 667 goto out;
624 668
625 dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT); 669 input_event(dev->input_dev, EV_MSC, MSC_SCAN, dev->last_scancode);
670 input_sync(dev->input_dev);
671
672 dev->keyup_jiffies = jiffies + msecs_to_jiffies(timeout);
626 mod_timer(&dev->timer_keyup, dev->keyup_jiffies); 673 mod_timer(&dev->timer_keyup, dev->keyup_jiffies);
627 674
628out: 675out:
@@ -641,7 +688,7 @@ EXPORT_SYMBOL_GPL(rc_repeat);
641 * This function is used internally to register a keypress, it must be 688 * This function is used internally to register a keypress, it must be
642 * called with keylock held. 689 * called with keylock held.
643 */ 690 */
644static void ir_do_keydown(struct rc_dev *dev, enum rc_type protocol, 691static void ir_do_keydown(struct rc_dev *dev, enum rc_proto protocol,
645 u32 scancode, u32 keycode, u8 toggle) 692 u32 scancode, u32 keycode, u8 toggle)
646{ 693{
647 bool new_event = (!dev->keypressed || 694 bool new_event = (!dev->keypressed ||
@@ -663,7 +710,7 @@ static void ir_do_keydown(struct rc_dev *dev, enum rc_type protocol,
663 dev->last_keycode = keycode; 710 dev->last_keycode = keycode;
664 711
665 IR_dprintk(1, "%s: key down event, key 0x%04x, protocol 0x%04x, scancode 0x%08x\n", 712 IR_dprintk(1, "%s: key down event, key 0x%04x, protocol 0x%04x, scancode 0x%08x\n",
666 dev->input_name, keycode, protocol, scancode); 713 dev->device_name, keycode, protocol, scancode);
667 input_report_key(dev->input_dev, keycode, 1); 714 input_report_key(dev->input_dev, keycode, 1);
668 715
669 led_trigger_event(led_feedback, LED_FULL); 716 led_trigger_event(led_feedback, LED_FULL);
@@ -683,7 +730,8 @@ static void ir_do_keydown(struct rc_dev *dev, enum rc_type protocol,
683 * This routine is used to signal that a key has been pressed on the 730 * This routine is used to signal that a key has been pressed on the
684 * remote control. 731 * remote control.
685 */ 732 */
686void rc_keydown(struct rc_dev *dev, enum rc_type protocol, u32 scancode, u8 toggle) 733void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u32 scancode,
734 u8 toggle)
687{ 735{
688 unsigned long flags; 736 unsigned long flags;
689 u32 keycode = rc_g_keycode_from_table(dev, scancode); 737 u32 keycode = rc_g_keycode_from_table(dev, scancode);
@@ -692,7 +740,8 @@ void rc_keydown(struct rc_dev *dev, enum rc_type protocol, u32 scancode, u8 togg
692 ir_do_keydown(dev, protocol, scancode, keycode, toggle); 740 ir_do_keydown(dev, protocol, scancode, keycode, toggle);
693 741
694 if (dev->keypressed) { 742 if (dev->keypressed) {
695 dev->keyup_jiffies = jiffies + msecs_to_jiffies(IR_KEYPRESS_TIMEOUT); 743 dev->keyup_jiffies = jiffies +
744 msecs_to_jiffies(protocols[protocol].repeat_period);
696 mod_timer(&dev->timer_keyup, dev->keyup_jiffies); 745 mod_timer(&dev->timer_keyup, dev->keyup_jiffies);
697 } 746 }
698 spin_unlock_irqrestore(&dev->keylock, flags); 747 spin_unlock_irqrestore(&dev->keylock, flags);
@@ -711,7 +760,7 @@ EXPORT_SYMBOL_GPL(rc_keydown);
711 * This routine is used to signal that a key has been pressed on the 760 * This routine is used to signal that a key has been pressed on the
712 * remote control. The driver must manually call rc_keyup() at a later stage. 761 * remote control. The driver must manually call rc_keyup() at a later stage.
713 */ 762 */
714void rc_keydown_notimeout(struct rc_dev *dev, enum rc_type protocol, 763void rc_keydown_notimeout(struct rc_dev *dev, enum rc_proto protocol,
715 u32 scancode, u8 toggle) 764 u32 scancode, u8 toggle)
716{ 765{
717 unsigned long flags; 766 unsigned long flags;
@@ -733,44 +782,28 @@ EXPORT_SYMBOL_GPL(rc_keydown_notimeout);
733static int rc_validate_filter(struct rc_dev *dev, 782static int rc_validate_filter(struct rc_dev *dev,
734 struct rc_scancode_filter *filter) 783 struct rc_scancode_filter *filter)
735{ 784{
736 static u32 masks[] = { 785 u32 mask, s = filter->data;
737 [RC_TYPE_RC5] = 0x1f7f, 786 enum rc_proto protocol = dev->wakeup_protocol;
738 [RC_TYPE_RC5X_20] = 0x1f7f3f, 787
739 [RC_TYPE_RC5_SZ] = 0x2fff, 788 if (protocol >= ARRAY_SIZE(protocols))
740 [RC_TYPE_SONY12] = 0x1f007f, 789 return -EINVAL;
741 [RC_TYPE_SONY15] = 0xff007f, 790
742 [RC_TYPE_SONY20] = 0x1fff7f, 791 mask = protocols[protocol].scancode_bits;
743 [RC_TYPE_JVC] = 0xffff,
744 [RC_TYPE_NEC] = 0xffff,
745 [RC_TYPE_NECX] = 0xffffff,
746 [RC_TYPE_NEC32] = 0xffffffff,
747 [RC_TYPE_SANYO] = 0x1fffff,
748 [RC_TYPE_MCIR2_KBD] = 0xffff,
749 [RC_TYPE_MCIR2_MSE] = 0x1fffff,
750 [RC_TYPE_RC6_0] = 0xffff,
751 [RC_TYPE_RC6_6A_20] = 0xfffff,
752 [RC_TYPE_RC6_6A_24] = 0xffffff,
753 [RC_TYPE_RC6_6A_32] = 0xffffffff,
754 [RC_TYPE_RC6_MCE] = 0xffff7fff,
755 [RC_TYPE_SHARP] = 0x1fff,
756 };
757 u32 s = filter->data;
758 enum rc_type protocol = dev->wakeup_protocol;
759 792
760 switch (protocol) { 793 switch (protocol) {
761 case RC_TYPE_NECX: 794 case RC_PROTO_NECX:
762 if ((((s >> 16) ^ ~(s >> 8)) & 0xff) == 0) 795 if ((((s >> 16) ^ ~(s >> 8)) & 0xff) == 0)
763 return -EINVAL; 796 return -EINVAL;
764 break; 797 break;
765 case RC_TYPE_NEC32: 798 case RC_PROTO_NEC32:
766 if ((((s >> 24) ^ ~(s >> 16)) & 0xff) == 0) 799 if ((((s >> 24) ^ ~(s >> 16)) & 0xff) == 0)
767 return -EINVAL; 800 return -EINVAL;
768 break; 801 break;
769 case RC_TYPE_RC6_MCE: 802 case RC_PROTO_RC6_MCE:
770 if ((s & 0xffff0000) != 0x800f0000) 803 if ((s & 0xffff0000) != 0x800f0000)
771 return -EINVAL; 804 return -EINVAL;
772 break; 805 break;
773 case RC_TYPE_RC6_6A_32: 806 case RC_PROTO_RC6_6A_32:
774 if ((s & 0xffff0000) == 0x800f0000) 807 if ((s & 0xffff0000) == 0x800f0000)
775 return -EINVAL; 808 return -EINVAL;
776 break; 809 break;
@@ -778,14 +811,13 @@ static int rc_validate_filter(struct rc_dev *dev,
778 break; 811 break;
779 } 812 }
780 813
781 filter->data &= masks[protocol]; 814 filter->data &= mask;
782 filter->mask &= masks[protocol]; 815 filter->mask &= mask;
783 816
784 /* 817 /*
785 * If we have to raw encode the IR for wakeup, we cannot have a mask 818 * If we have to raw encode the IR for wakeup, we cannot have a mask
786 */ 819 */
787 if (dev->encode_wakeup && 820 if (dev->encode_wakeup && filter->mask != 0 && filter->mask != mask)
788 filter->mask != 0 && filter->mask != masks[protocol])
789 return -EINVAL; 821 return -EINVAL;
790 822
791 return 0; 823 return 0;
@@ -859,30 +891,30 @@ static const struct {
859 const char *name; 891 const char *name;
860 const char *module_name; 892 const char *module_name;
861} proto_names[] = { 893} proto_names[] = {
862 { RC_BIT_NONE, "none", NULL }, 894 { RC_PROTO_BIT_NONE, "none", NULL },
863 { RC_BIT_OTHER, "other", NULL }, 895 { RC_PROTO_BIT_OTHER, "other", NULL },
864 { RC_BIT_UNKNOWN, "unknown", NULL }, 896 { RC_PROTO_BIT_UNKNOWN, "unknown", NULL },
865 { RC_BIT_RC5 | 897 { RC_PROTO_BIT_RC5 |
866 RC_BIT_RC5X_20, "rc-5", "ir-rc5-decoder" }, 898 RC_PROTO_BIT_RC5X_20, "rc-5", "ir-rc5-decoder" },
867 { RC_BIT_NEC | 899 { RC_PROTO_BIT_NEC |
868 RC_BIT_NECX | 900 RC_PROTO_BIT_NECX |
869 RC_BIT_NEC32, "nec", "ir-nec-decoder" }, 901 RC_PROTO_BIT_NEC32, "nec", "ir-nec-decoder" },
870 { RC_BIT_RC6_0 | 902 { RC_PROTO_BIT_RC6_0 |
871 RC_BIT_RC6_6A_20 | 903 RC_PROTO_BIT_RC6_6A_20 |
872 RC_BIT_RC6_6A_24 | 904 RC_PROTO_BIT_RC6_6A_24 |
873 RC_BIT_RC6_6A_32 | 905 RC_PROTO_BIT_RC6_6A_32 |
874 RC_BIT_RC6_MCE, "rc-6", "ir-rc6-decoder" }, 906 RC_PROTO_BIT_RC6_MCE, "rc-6", "ir-rc6-decoder" },
875 { RC_BIT_JVC, "jvc", "ir-jvc-decoder" }, 907 { RC_PROTO_BIT_JVC, "jvc", "ir-jvc-decoder" },
876 { RC_BIT_SONY12 | 908 { RC_PROTO_BIT_SONY12 |
877 RC_BIT_SONY15 | 909 RC_PROTO_BIT_SONY15 |
878 RC_BIT_SONY20, "sony", "ir-sony-decoder" }, 910 RC_PROTO_BIT_SONY20, "sony", "ir-sony-decoder" },
879 { RC_BIT_RC5_SZ, "rc-5-sz", "ir-rc5-decoder" }, 911 { RC_PROTO_BIT_RC5_SZ, "rc-5-sz", "ir-rc5-decoder" },
880 { RC_BIT_SANYO, "sanyo", "ir-sanyo-decoder" }, 912 { RC_PROTO_BIT_SANYO, "sanyo", "ir-sanyo-decoder" },
881 { RC_BIT_SHARP, "sharp", "ir-sharp-decoder" }, 913 { RC_PROTO_BIT_SHARP, "sharp", "ir-sharp-decoder" },
882 { RC_BIT_MCIR2_KBD | 914 { RC_PROTO_BIT_MCIR2_KBD |
883 RC_BIT_MCIR2_MSE, "mce_kbd", "ir-mce_kbd-decoder" }, 915 RC_PROTO_BIT_MCIR2_MSE, "mce_kbd", "ir-mce_kbd-decoder" },
884 { RC_BIT_XMP, "xmp", "ir-xmp-decoder" }, 916 { RC_PROTO_BIT_XMP, "xmp", "ir-xmp-decoder" },
885 { RC_BIT_CEC, "cec", NULL }, 917 { RC_PROTO_BIT_CEC, "cec", NULL },
886}; 918};
887 919
888/** 920/**
@@ -1052,8 +1084,9 @@ static void ir_raw_load_modules(u64 *protocols)
1052 int i, ret; 1084 int i, ret;
1053 1085
1054 for (i = 0; i < ARRAY_SIZE(proto_names); i++) { 1086 for (i = 0; i < ARRAY_SIZE(proto_names); i++) {
1055 if (proto_names[i].type == RC_BIT_NONE || 1087 if (proto_names[i].type == RC_PROTO_BIT_NONE ||
1056 proto_names[i].type & (RC_BIT_OTHER | RC_BIT_UNKNOWN)) 1088 proto_names[i].type & (RC_PROTO_BIT_OTHER |
1089 RC_PROTO_BIT_UNKNOWN))
1057 continue; 1090 continue;
1058 1091
1059 available = ir_raw_get_allowed_protocols(); 1092 available = ir_raw_get_allowed_protocols();
@@ -1271,7 +1304,7 @@ static ssize_t store_filter(struct device *device,
1271 * Refuse to set a filter unless a protocol is enabled 1304 * Refuse to set a filter unless a protocol is enabled
1272 * and the filter is valid for that protocol 1305 * and the filter is valid for that protocol
1273 */ 1306 */
1274 if (dev->wakeup_protocol != RC_TYPE_UNKNOWN) 1307 if (dev->wakeup_protocol != RC_PROTO_UNKNOWN)
1275 ret = rc_validate_filter(dev, &new_filter); 1308 ret = rc_validate_filter(dev, &new_filter);
1276 else 1309 else
1277 ret = -EINVAL; 1310 ret = -EINVAL;
@@ -1298,40 +1331,6 @@ unlock:
1298 return (ret < 0) ? ret : len; 1331 return (ret < 0) ? ret : len;
1299} 1332}
1300 1333
1301/*
1302 * This is the list of all variants of all protocols, which is used by
1303 * the wakeup_protocols sysfs entry. In the protocols sysfs entry some
1304 * some protocols are grouped together (e.g. nec = nec + necx + nec32).
1305 *
1306 * For wakeup we need to know the exact protocol variant so the hardware
1307 * can be programmed exactly what to expect.
1308 */
1309static const char * const proto_variant_names[] = {
1310 [RC_TYPE_UNKNOWN] = "unknown",
1311 [RC_TYPE_OTHER] = "other",
1312 [RC_TYPE_RC5] = "rc-5",
1313 [RC_TYPE_RC5X_20] = "rc-5x-20",
1314 [RC_TYPE_RC5_SZ] = "rc-5-sz",
1315 [RC_TYPE_JVC] = "jvc",
1316 [RC_TYPE_SONY12] = "sony-12",
1317 [RC_TYPE_SONY15] = "sony-15",
1318 [RC_TYPE_SONY20] = "sony-20",
1319 [RC_TYPE_NEC] = "nec",
1320 [RC_TYPE_NECX] = "nec-x",
1321 [RC_TYPE_NEC32] = "nec-32",
1322 [RC_TYPE_SANYO] = "sanyo",
1323 [RC_TYPE_MCIR2_KBD] = "mcir2-kbd",
1324 [RC_TYPE_MCIR2_MSE] = "mcir2-mse",
1325 [RC_TYPE_RC6_0] = "rc-6-0",
1326 [RC_TYPE_RC6_6A_20] = "rc-6-6a-20",
1327 [RC_TYPE_RC6_6A_24] = "rc-6-6a-24",
1328 [RC_TYPE_RC6_6A_32] = "rc-6-6a-32",
1329 [RC_TYPE_RC6_MCE] = "rc-6-mce",
1330 [RC_TYPE_SHARP] = "sharp",
1331 [RC_TYPE_XMP] = "xmp",
1332 [RC_TYPE_CEC] = "cec",
1333};
1334
1335/** 1334/**
1336 * show_wakeup_protocols() - shows the wakeup IR protocol 1335 * show_wakeup_protocols() - shows the wakeup IR protocol
1337 * @device: the device descriptor 1336 * @device: the device descriptor
@@ -1352,7 +1351,7 @@ static ssize_t show_wakeup_protocols(struct device *device,
1352{ 1351{
1353 struct rc_dev *dev = to_rc_dev(device); 1352 struct rc_dev *dev = to_rc_dev(device);
1354 u64 allowed; 1353 u64 allowed;
1355 enum rc_type enabled; 1354 enum rc_proto enabled;
1356 char *tmp = buf; 1355 char *tmp = buf;
1357 int i; 1356 int i;
1358 1357
@@ -1366,14 +1365,12 @@ static ssize_t show_wakeup_protocols(struct device *device,
1366 IR_dprintk(1, "%s: allowed - 0x%llx, enabled - %d\n", 1365 IR_dprintk(1, "%s: allowed - 0x%llx, enabled - %d\n",
1367 __func__, (long long)allowed, enabled); 1366 __func__, (long long)allowed, enabled);
1368 1367
1369 for (i = 0; i < ARRAY_SIZE(proto_variant_names); i++) { 1368 for (i = 0; i < ARRAY_SIZE(protocols); i++) {
1370 if (allowed & (1ULL << i)) { 1369 if (allowed & (1ULL << i)) {
1371 if (i == enabled) 1370 if (i == enabled)
1372 tmp += sprintf(tmp, "[%s] ", 1371 tmp += sprintf(tmp, "[%s] ", protocols[i].name);
1373 proto_variant_names[i]);
1374 else 1372 else
1375 tmp += sprintf(tmp, "%s ", 1373 tmp += sprintf(tmp, "%s ", protocols[i].name);
1376 proto_variant_names[i]);
1377 } 1374 }
1378 } 1375 }
1379 1376
@@ -1403,7 +1400,7 @@ static ssize_t store_wakeup_protocols(struct device *device,
1403 const char *buf, size_t len) 1400 const char *buf, size_t len)
1404{ 1401{
1405 struct rc_dev *dev = to_rc_dev(device); 1402 struct rc_dev *dev = to_rc_dev(device);
1406 enum rc_type protocol; 1403 enum rc_proto protocol;
1407 ssize_t rc; 1404 ssize_t rc;
1408 u64 allowed; 1405 u64 allowed;
1409 int i; 1406 int i;
@@ -1413,17 +1410,17 @@ static ssize_t store_wakeup_protocols(struct device *device,
1413 allowed = dev->allowed_wakeup_protocols; 1410 allowed = dev->allowed_wakeup_protocols;
1414 1411
1415 if (sysfs_streq(buf, "none")) { 1412 if (sysfs_streq(buf, "none")) {
1416 protocol = RC_TYPE_UNKNOWN; 1413 protocol = RC_PROTO_UNKNOWN;
1417 } else { 1414 } else {
1418 for (i = 0; i < ARRAY_SIZE(proto_variant_names); i++) { 1415 for (i = 0; i < ARRAY_SIZE(protocols); i++) {
1419 if ((allowed & (1ULL << i)) && 1416 if ((allowed & (1ULL << i)) &&
1420 sysfs_streq(buf, proto_variant_names[i])) { 1417 sysfs_streq(buf, protocols[i].name)) {
1421 protocol = i; 1418 protocol = i;
1422 break; 1419 break;
1423 } 1420 }
1424 } 1421 }
1425 1422
1426 if (i == ARRAY_SIZE(proto_variant_names)) { 1423 if (i == ARRAY_SIZE(protocols)) {
1427 rc = -EINVAL; 1424 rc = -EINVAL;
1428 goto out; 1425 goto out;
1429 } 1426 }
@@ -1443,7 +1440,7 @@ static ssize_t store_wakeup_protocols(struct device *device,
1443 dev->wakeup_protocol = protocol; 1440 dev->wakeup_protocol = protocol;
1444 IR_dprintk(1, "Wakeup protocol changed to %d\n", protocol); 1441 IR_dprintk(1, "Wakeup protocol changed to %d\n", protocol);
1445 1442
1446 if (protocol == RC_TYPE_RC6_MCE) 1443 if (protocol == RC_PROTO_RC6_MCE)
1447 dev->scancode_wakeup_filter.data = 0x800f0000; 1444 dev->scancode_wakeup_filter.data = 0x800f0000;
1448 else 1445 else
1449 dev->scancode_wakeup_filter.data = 0; 1446 dev->scancode_wakeup_filter.data = 0;
@@ -1507,7 +1504,7 @@ static struct attribute *rc_dev_protocol_attrs[] = {
1507 NULL, 1504 NULL,
1508}; 1505};
1509 1506
1510static struct attribute_group rc_dev_protocol_attr_grp = { 1507static const struct attribute_group rc_dev_protocol_attr_grp = {
1511 .attrs = rc_dev_protocol_attrs, 1508 .attrs = rc_dev_protocol_attrs,
1512}; 1509};
1513 1510
@@ -1517,7 +1514,7 @@ static struct attribute *rc_dev_filter_attrs[] = {
1517 NULL, 1514 NULL,
1518}; 1515};
1519 1516
1520static struct attribute_group rc_dev_filter_attr_grp = { 1517static const struct attribute_group rc_dev_filter_attr_grp = {
1521 .attrs = rc_dev_filter_attrs, 1518 .attrs = rc_dev_filter_attrs,
1522}; 1519};
1523 1520
@@ -1528,7 +1525,7 @@ static struct attribute *rc_dev_wakeup_filter_attrs[] = {
1528 NULL, 1525 NULL,
1529}; 1526};
1530 1527
1531static struct attribute_group rc_dev_wakeup_filter_attr_grp = { 1528static const struct attribute_group rc_dev_wakeup_filter_attr_grp = {
1532 .attrs = rc_dev_wakeup_filter_attrs, 1529 .attrs = rc_dev_wakeup_filter_attrs,
1533}; 1530};
1534 1531
@@ -1624,7 +1621,7 @@ static int rc_prepare_rx_device(struct rc_dev *dev)
1624{ 1621{
1625 int rc; 1622 int rc;
1626 struct rc_map *rc_map; 1623 struct rc_map *rc_map;
1627 u64 rc_type; 1624 u64 rc_proto;
1628 1625
1629 if (!dev->map_name) 1626 if (!dev->map_name)
1630 return -EINVAL; 1627 return -EINVAL;
@@ -1639,17 +1636,17 @@ static int rc_prepare_rx_device(struct rc_dev *dev)
1639 if (rc) 1636 if (rc)
1640 return rc; 1637 return rc;
1641 1638
1642 rc_type = BIT_ULL(rc_map->rc_type); 1639 rc_proto = BIT_ULL(rc_map->rc_proto);
1643 1640
1644 if (dev->change_protocol) { 1641 if (dev->change_protocol) {
1645 rc = dev->change_protocol(dev, &rc_type); 1642 rc = dev->change_protocol(dev, &rc_proto);
1646 if (rc < 0) 1643 if (rc < 0)
1647 goto out_table; 1644 goto out_table;
1648 dev->enabled_protocols = rc_type; 1645 dev->enabled_protocols = rc_proto;
1649 } 1646 }
1650 1647
1651 if (dev->driver_type == RC_DRIVER_IR_RAW) 1648 if (dev->driver_type == RC_DRIVER_IR_RAW)
1652 ir_raw_load_modules(&rc_type); 1649 ir_raw_load_modules(&rc_proto);
1653 1650
1654 set_bit(EV_KEY, dev->input_dev->evbit); 1651 set_bit(EV_KEY, dev->input_dev->evbit);
1655 set_bit(EV_REP, dev->input_dev->evbit); 1652 set_bit(EV_REP, dev->input_dev->evbit);
@@ -1663,7 +1660,7 @@ static int rc_prepare_rx_device(struct rc_dev *dev)
1663 dev->input_dev->dev.parent = &dev->dev; 1660 dev->input_dev->dev.parent = &dev->dev;
1664 memcpy(&dev->input_dev->id, &dev->input_id, sizeof(dev->input_id)); 1661 memcpy(&dev->input_dev->id, &dev->input_id, sizeof(dev->input_id));
1665 dev->input_dev->phys = dev->input_phys; 1662 dev->input_dev->phys = dev->input_phys;
1666 dev->input_dev->name = dev->input_name; 1663 dev->input_dev->name = dev->device_name;
1667 1664
1668 return 0; 1665 return 0;
1669 1666
@@ -1759,7 +1756,7 @@ int rc_register_device(struct rc_dev *dev)
1759 1756
1760 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL); 1757 path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
1761 dev_info(&dev->dev, "%s as %s\n", 1758 dev_info(&dev->dev, "%s as %s\n",
1762 dev->input_name ?: "Unspecified device", path ?: "N/A"); 1759 dev->device_name ?: "Unspecified device", path ?: "N/A");
1763 kfree(path); 1760 kfree(path);
1764 1761
1765 if (dev->driver_type != RC_DRIVER_IR_RAW_TX) { 1762 if (dev->driver_type != RC_DRIVER_IR_RAW_TX) {
diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 56d43be2756b..6784cb9fc4e7 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -951,12 +951,12 @@ static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
951 951
952 usb_make_path(rr3->udev, rr3->phys, sizeof(rr3->phys)); 952 usb_make_path(rr3->udev, rr3->phys, sizeof(rr3->phys));
953 953
954 rc->input_name = rr3->name; 954 rc->device_name = rr3->name;
955 rc->input_phys = rr3->phys; 955 rc->input_phys = rr3->phys;
956 usb_to_input_id(rr3->udev, &rc->input_id); 956 usb_to_input_id(rr3->udev, &rc->input_id);
957 rc->dev.parent = dev; 957 rc->dev.parent = dev;
958 rc->priv = rr3; 958 rc->priv = rr3;
959 rc->allowed_protocols = RC_BIT_ALL_IR_DECODER; 959 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
960 rc->min_timeout = MS_TO_NS(RR3_RX_MIN_TIMEOUT); 960 rc->min_timeout = MS_TO_NS(RR3_RX_MIN_TIMEOUT);
961 rc->max_timeout = MS_TO_NS(RR3_RX_MAX_TIMEOUT); 961 rc->max_timeout = MS_TO_NS(RR3_RX_MAX_TIMEOUT);
962 rc->timeout = US_TO_NS(redrat3_get_timeout(rr3)); 962 rc->timeout = US_TO_NS(redrat3_get_timeout(rr3));
diff --git a/drivers/media/rc/serial_ir.c b/drivers/media/rc/serial_ir.c
index 77d5d4cbed0a..8b66926bc16a 100644
--- a/drivers/media/rc/serial_ir.c
+++ b/drivers/media/rc/serial_ir.c
@@ -139,10 +139,8 @@ struct serial_ir {
139 struct platform_device *pdev; 139 struct platform_device *pdev;
140 struct timer_list timeout_timer; 140 struct timer_list timeout_timer;
141 141
142 unsigned int freq; 142 unsigned int carrier;
143 unsigned int duty_cycle; 143 unsigned int duty_cycle;
144
145 unsigned int pulse_width, space_width;
146}; 144};
147 145
148static struct serial_ir serial_ir; 146static struct serial_ir serial_ir;
@@ -183,18 +181,6 @@ static void off(void)
183 soutp(UART_MCR, hardware[type].off); 181 soutp(UART_MCR, hardware[type].off);
184} 182}
185 183
186static void init_timing_params(unsigned int new_duty_cycle,
187 unsigned int new_freq)
188{
189 serial_ir.duty_cycle = new_duty_cycle;
190 serial_ir.freq = new_freq;
191
192 serial_ir.pulse_width = DIV_ROUND_CLOSEST(
193 new_duty_cycle * NSEC_PER_SEC, new_freq * 100l);
194 serial_ir.space_width = DIV_ROUND_CLOSEST(
195 (100l - new_duty_cycle) * NSEC_PER_SEC, new_freq * 100l);
196}
197
198static void send_pulse_irdeo(unsigned int length, ktime_t target) 184static void send_pulse_irdeo(unsigned int length, ktime_t target)
199{ 185{
200 long rawbits; 186 long rawbits;
@@ -241,13 +227,20 @@ static void send_pulse_homebrew_softcarrier(unsigned int length, ktime_t edge)
241 * ndelay(s64) does not compile; so use s32 rather than s64. 227 * ndelay(s64) does not compile; so use s32 rather than s64.
242 */ 228 */
243 s32 delta; 229 s32 delta;
230 unsigned int pulse, space;
231
232 /* Ensure the dividend fits into 32 bit */
233 pulse = DIV_ROUND_CLOSEST(serial_ir.duty_cycle * (NSEC_PER_SEC / 100),
234 serial_ir.carrier);
235 space = DIV_ROUND_CLOSEST((100 - serial_ir.duty_cycle) *
236 (NSEC_PER_SEC / 100), serial_ir.carrier);
244 237
245 for (;;) { 238 for (;;) {
246 now = ktime_get(); 239 now = ktime_get();
247 if (ktime_compare(now, target) >= 0) 240 if (ktime_compare(now, target) >= 0)
248 break; 241 break;
249 on(); 242 on();
250 edge = ktime_add_ns(edge, serial_ir.pulse_width); 243 edge = ktime_add_ns(edge, pulse);
251 delta = ktime_to_ns(ktime_sub(edge, now)); 244 delta = ktime_to_ns(ktime_sub(edge, now));
252 if (delta > 0) 245 if (delta > 0)
253 ndelay(delta); 246 ndelay(delta);
@@ -255,7 +248,7 @@ static void send_pulse_homebrew_softcarrier(unsigned int length, ktime_t edge)
255 off(); 248 off();
256 if (ktime_compare(now, target) >= 0) 249 if (ktime_compare(now, target) >= 0)
257 break; 250 break;
258 edge = ktime_add_ns(edge, serial_ir.space_width); 251 edge = ktime_add_ns(edge, space);
259 delta = ktime_to_ns(ktime_sub(edge, now)); 252 delta = ktime_to_ns(ktime_sub(edge, now));
260 if (delta > 0) 253 if (delta > 0)
261 ndelay(delta); 254 ndelay(delta);
@@ -513,19 +506,19 @@ static int serial_ir_probe(struct platform_device *dev)
513 506
514 switch (type) { 507 switch (type) {
515 case IR_HOMEBREW: 508 case IR_HOMEBREW:
516 rcdev->input_name = "Serial IR type home-brew"; 509 rcdev->device_name = "Serial IR type home-brew";
517 break; 510 break;
518 case IR_IRDEO: 511 case IR_IRDEO:
519 rcdev->input_name = "Serial IR type IRdeo"; 512 rcdev->device_name = "Serial IR type IRdeo";
520 break; 513 break;
521 case IR_IRDEO_REMOTE: 514 case IR_IRDEO_REMOTE:
522 rcdev->input_name = "Serial IR type IRdeo remote"; 515 rcdev->device_name = "Serial IR type IRdeo remote";
523 break; 516 break;
524 case IR_ANIMAX: 517 case IR_ANIMAX:
525 rcdev->input_name = "Serial IR type AnimaX"; 518 rcdev->device_name = "Serial IR type AnimaX";
526 break; 519 break;
527 case IR_IGOR: 520 case IR_IGOR:
528 rcdev->input_name = "Serial IR type IgorPlug"; 521 rcdev->device_name = "Serial IR type IgorPlug";
529 break; 522 break;
530 } 523 }
531 524
@@ -537,7 +530,7 @@ static int serial_ir_probe(struct platform_device *dev)
537 rcdev->open = serial_ir_open; 530 rcdev->open = serial_ir_open;
538 rcdev->close = serial_ir_close; 531 rcdev->close = serial_ir_close;
539 rcdev->dev.parent = &serial_ir.pdev->dev; 532 rcdev->dev.parent = &serial_ir.pdev->dev;
540 rcdev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 533 rcdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
541 rcdev->driver_name = KBUILD_MODNAME; 534 rcdev->driver_name = KBUILD_MODNAME;
542 rcdev->map_name = RC_MAP_RC6_MCE; 535 rcdev->map_name = RC_MAP_RC6_MCE;
543 rcdev->min_timeout = 1; 536 rcdev->min_timeout = 1;
@@ -580,7 +573,8 @@ static int serial_ir_probe(struct platform_device *dev)
580 return result; 573 return result;
581 574
582 /* Initialize pulse/space widths */ 575 /* Initialize pulse/space widths */
583 init_timing_params(50, 38000); 576 serial_ir.duty_cycle = 50;
577 serial_ir.carrier = 38000;
584 578
585 /* If pin is high, then this must be an active low receiver. */ 579 /* If pin is high, then this must be an active low receiver. */
586 if (sense == -1) { 580 if (sense == -1) {
@@ -684,7 +678,7 @@ static int serial_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
684 678
685static int serial_ir_tx_duty_cycle(struct rc_dev *dev, u32 cycle) 679static int serial_ir_tx_duty_cycle(struct rc_dev *dev, u32 cycle)
686{ 680{
687 init_timing_params(cycle, serial_ir.freq); 681 serial_ir.duty_cycle = cycle;
688 return 0; 682 return 0;
689} 683}
690 684
@@ -693,7 +687,7 @@ static int serial_ir_tx_carrier(struct rc_dev *dev, u32 carrier)
693 if (carrier > 500000 || carrier < 20000) 687 if (carrier > 500000 || carrier < 20000)
694 return -EINVAL; 688 return -EINVAL;
695 689
696 init_timing_params(serial_ir.duty_cycle, carrier); 690 serial_ir.carrier = carrier;
697 return 0; 691 return 0;
698} 692}
699 693
diff --git a/drivers/media/rc/sir_ir.c b/drivers/media/rc/sir_ir.c
index 20234ba0b318..bc906fb128d5 100644
--- a/drivers/media/rc/sir_ir.c
+++ b/drivers/media/rc/sir_ir.c
@@ -155,7 +155,7 @@ static irqreturn_t sir_interrupt(int irq, void *dev_id)
155{ 155{
156 unsigned char data; 156 unsigned char data;
157 ktime_t curr_time; 157 ktime_t curr_time;
158 static unsigned long delt; 158 unsigned long delt;
159 unsigned long deltintr; 159 unsigned long deltintr;
160 unsigned long flags; 160 unsigned long flags;
161 int counter = 0; 161 int counter = 0;
@@ -308,14 +308,14 @@ static int sir_ir_probe(struct platform_device *dev)
308 if (!rcdev) 308 if (!rcdev)
309 return -ENOMEM; 309 return -ENOMEM;
310 310
311 rcdev->input_name = "SIR IrDA port"; 311 rcdev->device_name = "SIR IrDA port";
312 rcdev->input_phys = KBUILD_MODNAME "/input0"; 312 rcdev->input_phys = KBUILD_MODNAME "/input0";
313 rcdev->input_id.bustype = BUS_HOST; 313 rcdev->input_id.bustype = BUS_HOST;
314 rcdev->input_id.vendor = 0x0001; 314 rcdev->input_id.vendor = 0x0001;
315 rcdev->input_id.product = 0x0001; 315 rcdev->input_id.product = 0x0001;
316 rcdev->input_id.version = 0x0100; 316 rcdev->input_id.version = 0x0100;
317 rcdev->tx_ir = sir_tx_ir; 317 rcdev->tx_ir = sir_tx_ir;
318 rcdev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 318 rcdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
319 rcdev->driver_name = KBUILD_MODNAME; 319 rcdev->driver_name = KBUILD_MODNAME;
320 rcdev->map_name = RC_MAP_RC6_MCE; 320 rcdev->map_name = RC_MAP_RC6_MCE;
321 rcdev->timeout = IR_DEFAULT_TIMEOUT; 321 rcdev->timeout = IR_DEFAULT_TIMEOUT;
diff --git a/drivers/media/rc/st_rc.c b/drivers/media/rc/st_rc.c
index a08e1dd06124..a8e39c635f34 100644
--- a/drivers/media/rc/st_rc.c
+++ b/drivers/media/rc/st_rc.c
@@ -280,7 +280,7 @@ static int st_rc_probe(struct platform_device *pdev)
280 else 280 else
281 rc_dev->rx_base = rc_dev->base; 281 rc_dev->rx_base = rc_dev->base;
282 282
283 rc_dev->rstc = reset_control_get_optional(dev, NULL); 283 rc_dev->rstc = reset_control_get_optional_exclusive(dev, NULL);
284 if (IS_ERR(rc_dev->rstc)) { 284 if (IS_ERR(rc_dev->rstc)) {
285 ret = PTR_ERR(rc_dev->rstc); 285 ret = PTR_ERR(rc_dev->rstc);
286 goto err; 286 goto err;
@@ -290,7 +290,7 @@ static int st_rc_probe(struct platform_device *pdev)
290 platform_set_drvdata(pdev, rc_dev); 290 platform_set_drvdata(pdev, rc_dev);
291 st_rc_hardware_init(rc_dev); 291 st_rc_hardware_init(rc_dev);
292 292
293 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 293 rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
294 /* rx sampling rate is 10Mhz */ 294 /* rx sampling rate is 10Mhz */
295 rdev->rx_resolution = 100; 295 rdev->rx_resolution = 100;
296 rdev->timeout = US_TO_NS(MAX_SYMB_TIME); 296 rdev->timeout = US_TO_NS(MAX_SYMB_TIME);
@@ -299,7 +299,7 @@ static int st_rc_probe(struct platform_device *pdev)
299 rdev->close = st_rc_close; 299 rdev->close = st_rc_close;
300 rdev->driver_name = IR_ST_NAME; 300 rdev->driver_name = IR_ST_NAME;
301 rdev->map_name = RC_MAP_EMPTY; 301 rdev->map_name = RC_MAP_EMPTY;
302 rdev->input_name = "ST Remote Control Receiver"; 302 rdev->device_name = "ST Remote Control Receiver";
303 303
304 ret = rc_register_device(rdev); 304 ret = rc_register_device(rdev);
305 if (ret < 0) 305 if (ret < 0)
diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
index b09c45abb5f3..f03a174ddf9d 100644
--- a/drivers/media/rc/streamzap.c
+++ b/drivers/media/rc/streamzap.c
@@ -299,12 +299,12 @@ static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz)
299 usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys)); 299 usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys));
300 strlcat(sz->phys, "/input0", sizeof(sz->phys)); 300 strlcat(sz->phys, "/input0", sizeof(sz->phys));
301 301
302 rdev->input_name = sz->name; 302 rdev->device_name = sz->name;
303 rdev->input_phys = sz->phys; 303 rdev->input_phys = sz->phys;
304 usb_to_input_id(sz->usbdev, &rdev->input_id); 304 usb_to_input_id(sz->usbdev, &rdev->input_id);
305 rdev->dev.parent = dev; 305 rdev->dev.parent = dev;
306 rdev->priv = sz; 306 rdev->priv = sz;
307 rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 307 rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
308 rdev->driver_name = DRIVER_NAME; 308 rdev->driver_name = DRIVER_NAME;
309 rdev->map_name = RC_MAP_STREAMZAP; 309 rdev->map_name = RC_MAP_STREAMZAP;
310 310
diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c
index 4b785dd775c1..97f367b446c4 100644
--- a/drivers/media/rc/sunxi-cir.c
+++ b/drivers/media/rc/sunxi-cir.c
@@ -173,7 +173,7 @@ static int sunxi_ir_probe(struct platform_device *pdev)
173 } 173 }
174 174
175 /* Reset (optional) */ 175 /* Reset (optional) */
176 ir->rst = devm_reset_control_get_optional(dev, NULL); 176 ir->rst = devm_reset_control_get_optional_exclusive(dev, NULL);
177 if (IS_ERR(ir->rst)) 177 if (IS_ERR(ir->rst))
178 return PTR_ERR(ir->rst); 178 return PTR_ERR(ir->rst);
179 ret = reset_control_deassert(ir->rst); 179 ret = reset_control_deassert(ir->rst);
@@ -215,7 +215,7 @@ static int sunxi_ir_probe(struct platform_device *pdev)
215 } 215 }
216 216
217 ir->rc->priv = ir; 217 ir->rc->priv = ir;
218 ir->rc->input_name = SUNXI_IR_DEV; 218 ir->rc->device_name = SUNXI_IR_DEV;
219 ir->rc->input_phys = "sunxi-ir/input0"; 219 ir->rc->input_phys = "sunxi-ir/input0";
220 ir->rc->input_id.bustype = BUS_HOST; 220 ir->rc->input_id.bustype = BUS_HOST;
221 ir->rc->input_id.vendor = 0x0001; 221 ir->rc->input_id.vendor = 0x0001;
@@ -224,7 +224,7 @@ static int sunxi_ir_probe(struct platform_device *pdev)
224 ir->map_name = of_get_property(dn, "linux,rc-map-name", NULL); 224 ir->map_name = of_get_property(dn, "linux,rc-map-name", NULL);
225 ir->rc->map_name = ir->map_name ?: RC_MAP_EMPTY; 225 ir->rc->map_name = ir->map_name ?: RC_MAP_EMPTY;
226 ir->rc->dev.parent = dev; 226 ir->rc->dev.parent = dev;
227 ir->rc->allowed_protocols = RC_BIT_ALL_IR_DECODER; 227 ir->rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
228 ir->rc->rx_resolution = SUNXI_IR_SAMPLE; 228 ir->rc->rx_resolution = SUNXI_IR_SAMPLE;
229 ir->rc->timeout = MS_TO_NS(SUNXI_IR_TIMEOUT); 229 ir->rc->timeout = MS_TO_NS(SUNXI_IR_TIMEOUT);
230 ir->rc->driver_name = SUNXI_IR_DEV; 230 ir->rc->driver_name = SUNXI_IR_DEV;
diff --git a/drivers/media/rc/ttusbir.c b/drivers/media/rc/ttusbir.c
index 23be7702e2df..aafea3c5170b 100644
--- a/drivers/media/rc/ttusbir.c
+++ b/drivers/media/rc/ttusbir.c
@@ -309,11 +309,11 @@ static int ttusbir_probe(struct usb_interface *intf,
309 309
310 usb_make_path(tt->udev, tt->phys, sizeof(tt->phys)); 310 usb_make_path(tt->udev, tt->phys, sizeof(tt->phys));
311 311
312 rc->input_name = DRIVER_DESC; 312 rc->device_name = DRIVER_DESC;
313 rc->input_phys = tt->phys; 313 rc->input_phys = tt->phys;
314 usb_to_input_id(tt->udev, &rc->input_id); 314 usb_to_input_id(tt->udev, &rc->input_id);
315 rc->dev.parent = &intf->dev; 315 rc->dev.parent = &intf->dev;
316 rc->allowed_protocols = RC_BIT_ALL_IR_DECODER; 316 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
317 rc->priv = tt; 317 rc->priv = tt;
318 rc->driver_name = DRIVER_NAME; 318 rc->driver_name = DRIVER_NAME;
319 rc->map_name = RC_MAP_TT_1500; 319 rc->map_name = RC_MAP_TT_1500;
diff --git a/drivers/media/rc/winbond-cir.c b/drivers/media/rc/winbond-cir.c
index 5a4d4a611197..3ca7ab48293d 100644
--- a/drivers/media/rc/winbond-cir.c
+++ b/drivers/media/rc/winbond-cir.c
@@ -429,7 +429,7 @@ wbcir_irq_tx(struct wbcir_data *data)
429 bytes[used] = byte; 429 bytes[used] = byte;
430 } 430 }
431 431
432 while (data->txbuf[data->txoff] == 0 && data->txoff != data->txlen) 432 while (data->txoff != data->txlen && data->txbuf[data->txoff] == 0)
433 data->txoff++; 433 data->txoff++;
434 434
435 if (used == 0) { 435 if (used == 0) {
@@ -697,7 +697,7 @@ wbcir_shutdown(struct pnp_dev *device)
697 } 697 }
698 698
699 switch (rc->wakeup_protocol) { 699 switch (rc->wakeup_protocol) {
700 case RC_TYPE_RC5: 700 case RC_PROTO_RC5:
701 /* Mask = 13 bits, ex toggle */ 701 /* Mask = 13 bits, ex toggle */
702 mask[0] = (mask_sc & 0x003f); 702 mask[0] = (mask_sc & 0x003f);
703 mask[0] |= (mask_sc & 0x0300) >> 2; 703 mask[0] |= (mask_sc & 0x0300) >> 2;
@@ -714,7 +714,7 @@ wbcir_shutdown(struct pnp_dev *device)
714 proto = IR_PROTOCOL_RC5; 714 proto = IR_PROTOCOL_RC5;
715 break; 715 break;
716 716
717 case RC_TYPE_NEC: 717 case RC_PROTO_NEC:
718 mask[1] = bitrev8(mask_sc); 718 mask[1] = bitrev8(mask_sc);
719 mask[0] = mask[1]; 719 mask[0] = mask[1];
720 mask[3] = bitrev8(mask_sc >> 8); 720 mask[3] = bitrev8(mask_sc >> 8);
@@ -728,7 +728,7 @@ wbcir_shutdown(struct pnp_dev *device)
728 proto = IR_PROTOCOL_NEC; 728 proto = IR_PROTOCOL_NEC;
729 break; 729 break;
730 730
731 case RC_TYPE_NECX: 731 case RC_PROTO_NECX:
732 mask[1] = bitrev8(mask_sc); 732 mask[1] = bitrev8(mask_sc);
733 mask[0] = mask[1]; 733 mask[0] = mask[1];
734 mask[2] = bitrev8(mask_sc >> 8); 734 mask[2] = bitrev8(mask_sc >> 8);
@@ -742,7 +742,7 @@ wbcir_shutdown(struct pnp_dev *device)
742 proto = IR_PROTOCOL_NEC; 742 proto = IR_PROTOCOL_NEC;
743 break; 743 break;
744 744
745 case RC_TYPE_NEC32: 745 case RC_PROTO_NEC32:
746 mask[0] = bitrev8(mask_sc); 746 mask[0] = bitrev8(mask_sc);
747 mask[1] = bitrev8(mask_sc >> 8); 747 mask[1] = bitrev8(mask_sc >> 8);
748 mask[2] = bitrev8(mask_sc >> 16); 748 mask[2] = bitrev8(mask_sc >> 16);
@@ -756,7 +756,7 @@ wbcir_shutdown(struct pnp_dev *device)
756 proto = IR_PROTOCOL_NEC; 756 proto = IR_PROTOCOL_NEC;
757 break; 757 break;
758 758
759 case RC_TYPE_RC6_0: 759 case RC_PROTO_RC6_0:
760 /* Command */ 760 /* Command */
761 match[0] = wbcir_to_rc6cells(wake_sc >> 0); 761 match[0] = wbcir_to_rc6cells(wake_sc >> 0);
762 mask[0] = wbcir_to_rc6cells(mask_sc >> 0); 762 mask[0] = wbcir_to_rc6cells(mask_sc >> 0);
@@ -779,9 +779,9 @@ wbcir_shutdown(struct pnp_dev *device)
779 proto = IR_PROTOCOL_RC6; 779 proto = IR_PROTOCOL_RC6;
780 break; 780 break;
781 781
782 case RC_TYPE_RC6_6A_24: 782 case RC_PROTO_RC6_6A_24:
783 case RC_TYPE_RC6_6A_32: 783 case RC_PROTO_RC6_6A_32:
784 case RC_TYPE_RC6_MCE: 784 case RC_PROTO_RC6_MCE:
785 i = 0; 785 i = 0;
786 786
787 /* Command */ 787 /* Command */
@@ -800,13 +800,13 @@ wbcir_shutdown(struct pnp_dev *device)
800 match[i] = wbcir_to_rc6cells(wake_sc >> 16); 800 match[i] = wbcir_to_rc6cells(wake_sc >> 16);
801 mask[i++] = wbcir_to_rc6cells(mask_sc >> 16); 801 mask[i++] = wbcir_to_rc6cells(mask_sc >> 16);
802 802
803 if (rc->wakeup_protocol == RC_TYPE_RC6_6A_20) { 803 if (rc->wakeup_protocol == RC_PROTO_RC6_6A_20) {
804 rc6_csl = 52; 804 rc6_csl = 52;
805 } else { 805 } else {
806 match[i] = wbcir_to_rc6cells(wake_sc >> 20); 806 match[i] = wbcir_to_rc6cells(wake_sc >> 20);
807 mask[i++] = wbcir_to_rc6cells(mask_sc >> 20); 807 mask[i++] = wbcir_to_rc6cells(mask_sc >> 20);
808 808
809 if (rc->wakeup_protocol == RC_TYPE_RC6_6A_24) { 809 if (rc->wakeup_protocol == RC_PROTO_RC6_6A_24) {
810 rc6_csl = 60; 810 rc6_csl = 60;
811 } else { 811 } else {
812 /* Customer range bit and bits 15 - 8 */ 812 /* Customer range bit and bits 15 - 8 */
@@ -1068,7 +1068,7 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1068 } 1068 }
1069 1069
1070 data->dev->driver_name = DRVNAME; 1070 data->dev->driver_name = DRVNAME;
1071 data->dev->input_name = WBCIR_NAME; 1071 data->dev->device_name = WBCIR_NAME;
1072 data->dev->input_phys = "wbcir/cir0"; 1072 data->dev->input_phys = "wbcir/cir0";
1073 data->dev->input_id.bustype = BUS_HOST; 1073 data->dev->input_id.bustype = BUS_HOST;
1074 data->dev->input_id.vendor = PCI_VENDOR_ID_WINBOND; 1074 data->dev->input_id.vendor = PCI_VENDOR_ID_WINBOND;
@@ -1086,12 +1086,13 @@ wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id)
1086 data->dev->timeout = IR_DEFAULT_TIMEOUT; 1086 data->dev->timeout = IR_DEFAULT_TIMEOUT;
1087 data->dev->max_timeout = 10 * IR_DEFAULT_TIMEOUT; 1087 data->dev->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
1088 data->dev->rx_resolution = US_TO_NS(2); 1088 data->dev->rx_resolution = US_TO_NS(2);
1089 data->dev->allowed_protocols = RC_BIT_ALL_IR_DECODER; 1089 data->dev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
1090 data->dev->allowed_wakeup_protocols = RC_BIT_NEC | RC_BIT_NECX | 1090 data->dev->allowed_wakeup_protocols = RC_PROTO_BIT_NEC |
1091 RC_BIT_NEC32 | RC_BIT_RC5 | RC_BIT_RC6_0 | 1091 RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32 | RC_PROTO_BIT_RC5 |
1092 RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | 1092 RC_PROTO_BIT_RC6_0 | RC_PROTO_BIT_RC6_6A_20 |
1093 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE; 1093 RC_PROTO_BIT_RC6_6A_24 | RC_PROTO_BIT_RC6_6A_32 |
1094 data->dev->wakeup_protocol = RC_TYPE_RC6_MCE; 1094 RC_PROTO_BIT_RC6_MCE;
1095 data->dev->wakeup_protocol = RC_PROTO_RC6_MCE;
1095 data->dev->scancode_wakeup_filter.data = 0x800f040c; 1096 data->dev->scancode_wakeup_filter.data = 0x800f040c;
1096 data->dev->scancode_wakeup_filter.mask = 0xffff7fff; 1097 data->dev->scancode_wakeup_filter.mask = 0xffff7fff;
1097 data->dev->s_wakeup_filter = wbcir_set_wakeup_filter; 1098 data->dev->s_wakeup_filter = wbcir_set_wakeup_filter;
diff --git a/drivers/media/rc/zx-irdec.c b/drivers/media/rc/zx-irdec.c
new file mode 100644
index 000000000000..12d322ec8a29
--- /dev/null
+++ b/drivers/media/rc/zx-irdec.c
@@ -0,0 +1,184 @@
1/*
2 * Copyright (C) 2017 Sanechips Technology Co., Ltd.
3 * Copyright 2017 Linaro Ltd.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/device.h>
11#include <linux/err.h>
12#include <linux/interrupt.h>
13#include <linux/io.h>
14#include <linux/module.h>
15#include <linux/of_platform.h>
16#include <linux/platform_device.h>
17
18#include <media/rc-core.h>
19
20#define DRIVER_NAME "zx-irdec"
21
22#define ZX_IR_ENABLE 0x04
23#define ZX_IREN BIT(0)
24#define ZX_IR_CTRL 0x08
25#define ZX_DEGL_MASK GENMASK(21, 20)
26#define ZX_DEGL_VALUE(x) (((x) << 20) & ZX_DEGL_MASK)
27#define ZX_WDBEGIN_MASK GENMASK(18, 8)
28#define ZX_WDBEGIN_VALUE(x) (((x) << 8) & ZX_WDBEGIN_MASK)
29#define ZX_IR_INTEN 0x10
30#define ZX_IR_INTSTCLR 0x14
31#define ZX_IR_CODE 0x30
32#define ZX_IR_CNUM 0x34
33#define ZX_NECRPT BIT(16)
34
35struct zx_irdec {
36 void __iomem *base;
37 struct rc_dev *rcd;
38};
39
40static void zx_irdec_set_mask(struct zx_irdec *irdec, unsigned int reg,
41 u32 mask, u32 value)
42{
43 u32 data;
44
45 data = readl(irdec->base + reg);
46 data &= ~mask;
47 data |= value & mask;
48 writel(data, irdec->base + reg);
49}
50
51static irqreturn_t zx_irdec_irq(int irq, void *dev_id)
52{
53 struct zx_irdec *irdec = dev_id;
54 u8 address, not_address;
55 u8 command, not_command;
56 u32 rawcode, scancode;
57 enum rc_proto rc_proto;
58
59 /* Clear interrupt */
60 writel(1, irdec->base + ZX_IR_INTSTCLR);
61
62 /* Check repeat frame */
63 if (readl(irdec->base + ZX_IR_CNUM) & ZX_NECRPT) {
64 rc_repeat(irdec->rcd);
65 goto done;
66 }
67
68 rawcode = readl(irdec->base + ZX_IR_CODE);
69 not_command = (rawcode >> 24) & 0xff;
70 command = (rawcode >> 16) & 0xff;
71 not_address = (rawcode >> 8) & 0xff;
72 address = rawcode & 0xff;
73
74 scancode = ir_nec_bytes_to_scancode(address, not_address,
75 command, not_command,
76 &rc_proto);
77 rc_keydown(irdec->rcd, rc_proto, scancode, 0);
78
79done:
80 return IRQ_HANDLED;
81}
82
83static int zx_irdec_probe(struct platform_device *pdev)
84{
85 struct device *dev = &pdev->dev;
86 struct zx_irdec *irdec;
87 struct resource *res;
88 struct rc_dev *rcd;
89 int irq;
90 int ret;
91
92 irdec = devm_kzalloc(dev, sizeof(*irdec), GFP_KERNEL);
93 if (!irdec)
94 return -ENOMEM;
95
96 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
97 irdec->base = devm_ioremap_resource(dev, res);
98 if (IS_ERR(irdec->base))
99 return PTR_ERR(irdec->base);
100
101 irq = platform_get_irq(pdev, 0);
102 if (irq < 0)
103 return irq;
104
105 rcd = devm_rc_allocate_device(dev, RC_DRIVER_SCANCODE);
106 if (!rcd) {
107 dev_err(dev, "failed to allocate rc device\n");
108 return -ENOMEM;
109 }
110
111 irdec->rcd = rcd;
112
113 rcd->priv = irdec;
114 rcd->input_phys = DRIVER_NAME "/input0";
115 rcd->input_id.bustype = BUS_HOST;
116 rcd->map_name = RC_MAP_ZX_IRDEC;
117 rcd->allowed_protocols = RC_PROTO_BIT_NEC | RC_PROTO_BIT_NECX |
118 RC_PROTO_BIT_NEC32;
119 rcd->driver_name = DRIVER_NAME;
120 rcd->device_name = DRIVER_NAME;
121
122 platform_set_drvdata(pdev, irdec);
123
124 ret = devm_rc_register_device(dev, rcd);
125 if (ret) {
126 dev_err(dev, "failed to register rc device\n");
127 return ret;
128 }
129
130 ret = devm_request_irq(dev, irq, zx_irdec_irq, 0, NULL, irdec);
131 if (ret) {
132 dev_err(dev, "failed to request irq\n");
133 return ret;
134 }
135
136 /*
137 * Initialize deglitch level and watchdog counter beginner as
138 * recommended by vendor BSP code.
139 */
140 zx_irdec_set_mask(irdec, ZX_IR_CTRL, ZX_DEGL_MASK, ZX_DEGL_VALUE(0));
141 zx_irdec_set_mask(irdec, ZX_IR_CTRL, ZX_WDBEGIN_MASK,
142 ZX_WDBEGIN_VALUE(0x21c));
143
144 /* Enable interrupt */
145 writel(1, irdec->base + ZX_IR_INTEN);
146
147 /* Enable the decoder */
148 zx_irdec_set_mask(irdec, ZX_IR_ENABLE, ZX_IREN, ZX_IREN);
149
150 return 0;
151}
152
153static int zx_irdec_remove(struct platform_device *pdev)
154{
155 struct zx_irdec *irdec = platform_get_drvdata(pdev);
156
157 /* Disable the decoder */
158 zx_irdec_set_mask(irdec, ZX_IR_ENABLE, ZX_IREN, 0);
159
160 /* Disable interrupt */
161 writel(0, irdec->base + ZX_IR_INTEN);
162
163 return 0;
164}
165
166static const struct of_device_id zx_irdec_match[] = {
167 { .compatible = "zte,zx296718-irdec" },
168 { },
169};
170MODULE_DEVICE_TABLE(of, zx_irdec_match);
171
172static struct platform_driver zx_irdec_driver = {
173 .probe = zx_irdec_probe,
174 .remove = zx_irdec_remove,
175 .driver = {
176 .name = DRIVER_NAME,
177 .of_match_table = zx_irdec_match,
178 },
179};
180module_platform_driver(zx_irdec_driver);
181
182MODULE_DESCRIPTION("ZTE ZX IR remote control driver");
183MODULE_AUTHOR("Shawn Guo <shawn.guo@linaro.org>");
184MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/tuners/fc0012.c b/drivers/media/tuners/fc0012.c
index dcc323ffbde7..625ac6f51c39 100644
--- a/drivers/media/tuners/fc0012.c
+++ b/drivers/media/tuners/fc0012.c
@@ -351,7 +351,7 @@ static int fc0012_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
351 int ret; 351 int ret;
352 unsigned char tmp; 352 unsigned char tmp;
353 int int_temp, lna_gain, int_lna, tot_agc_gain, power; 353 int int_temp, lna_gain, int_lna, tot_agc_gain, power;
354 const int fc0012_lna_gain_table[] = { 354 static const int fc0012_lna_gain_table[] = {
355 /* low gain */ 355 /* low gain */
356 -63, -58, -99, -73, 356 -63, -58, -99, -73,
357 -63, -65, -54, -60, 357 -63, -65, -54, -60,
diff --git a/drivers/media/tuners/fc0013.c b/drivers/media/tuners/fc0013.c
index 91dfa770a5cc..e606118d1a9b 100644
--- a/drivers/media/tuners/fc0013.c
+++ b/drivers/media/tuners/fc0013.c
@@ -511,7 +511,7 @@ static int fc0013_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
511 int ret; 511 int ret;
512 unsigned char tmp; 512 unsigned char tmp;
513 int int_temp, lna_gain, int_lna, tot_agc_gain, power; 513 int int_temp, lna_gain, int_lna, tot_agc_gain, power;
514 const int fc0013_lna_gain_table[] = { 514 static const int fc0013_lna_gain_table[] = {
515 /* low gain */ 515 /* low gain */
516 -63, -58, -99, -73, 516 -63, -58, -99, -73,
517 -63, -65, -54, -60, 517 -63, -65, -54, -60,
diff --git a/drivers/media/tuners/tda18271-maps.c b/drivers/media/tuners/tda18271-maps.c
index 7d114677b4ca..9679804fd219 100644
--- a/drivers/media/tuners/tda18271-maps.c
+++ b/drivers/media/tuners/tda18271-maps.c
@@ -1182,7 +1182,7 @@ fail:
1182 1182
1183/*---------------------------------------------------------------------*/ 1183/*---------------------------------------------------------------------*/
1184 1184
1185static struct tda18271_std_map tda18271c1_std_map = { 1185static const struct tda18271_std_map tda18271c1_std_map = {
1186 .fm_radio = { .if_freq = 1250, .fm_rfn = 1, .agc_mode = 3, .std = 0, 1186 .fm_radio = { .if_freq = 1250, .fm_rfn = 1, .agc_mode = 3, .std = 0,
1187 .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x18 */ 1187 .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x18 */
1188 .atv_b = { .if_freq = 6750, .fm_rfn = 0, .agc_mode = 1, .std = 6, 1188 .atv_b = { .if_freq = 6750, .fm_rfn = 0, .agc_mode = 1, .std = 6,
@@ -1215,7 +1215,7 @@ static struct tda18271_std_map tda18271c1_std_map = {
1215 .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1f */ 1215 .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1f */
1216}; 1216};
1217 1217
1218static struct tda18271_std_map tda18271c2_std_map = { 1218static const struct tda18271_std_map tda18271c2_std_map = {
1219 .fm_radio = { .if_freq = 1250, .fm_rfn = 1, .agc_mode = 3, .std = 0, 1219 .fm_radio = { .if_freq = 1250, .fm_rfn = 1, .agc_mode = 3, .std = 0,
1220 .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x18 */ 1220 .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x18 */
1221 .atv_b = { .if_freq = 6000, .fm_rfn = 0, .agc_mode = 1, .std = 5, 1221 .atv_b = { .if_freq = 6000, .fm_rfn = 0, .agc_mode = 1, .std = 5,
diff --git a/drivers/media/tuners/tuner-simple.c b/drivers/media/tuners/tuner-simple.c
index 3339b13dd3f5..cf44d3657f55 100644
--- a/drivers/media/tuners/tuner-simple.c
+++ b/drivers/media/tuners/tuner-simple.c
@@ -846,7 +846,7 @@ static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf,
846 /* This function returns the tuned frequency on success, 0 on error */ 846 /* This function returns the tuned frequency on success, 0 on error */
847 struct tuner_simple_priv *priv = fe->tuner_priv; 847 struct tuner_simple_priv *priv = fe->tuner_priv;
848 struct tunertype *tun = priv->tun; 848 struct tunertype *tun = priv->tun;
849 static struct tuner_params *t_params; 849 struct tuner_params *t_params;
850 u8 config, cb; 850 u8 config, cb;
851 u32 div; 851 u32 div;
852 int ret; 852 int ret;
diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c
index 8251942bcd12..e70c9e2f3798 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -859,7 +859,7 @@ static const struct v4l2_file_operations airspy_fops = {
859 .unlocked_ioctl = video_ioctl2, 859 .unlocked_ioctl = video_ioctl2,
860}; 860};
861 861
862static struct video_device airspy_template = { 862static const struct video_device airspy_template = {
863 .name = "AirSpy SDR", 863 .name = "AirSpy SDR",
864 .release = video_device_release_empty, 864 .release = video_device_release_empty,
865 .fops = &airspy_fops, 865 .fops = &airspy_fops,
@@ -1087,7 +1087,7 @@ err_free_mem:
1087} 1087}
1088 1088
1089/* USB device ID list */ 1089/* USB device ID list */
1090static struct usb_device_id airspy_id_table[] = { 1090static const struct usb_device_id airspy_id_table[] = {
1091 { USB_DEVICE(0x1d50, 0x60a1) }, /* AirSpy */ 1091 { USB_DEVICE(0x1d50, 0x60a1) }, /* AirSpy */
1092 { } 1092 { }
1093}; 1093};
diff --git a/drivers/media/usb/as102/as102_usb_drv.c b/drivers/media/usb/as102/as102_usb_drv.c
index 68c3a80ce349..ea57859aee77 100644
--- a/drivers/media/usb/as102/as102_usb_drv.c
+++ b/drivers/media/usb/as102/as102_usb_drv.c
@@ -33,7 +33,7 @@ static void as102_usb_stop_stream(struct as102_dev_t *dev);
33static int as102_open(struct inode *inode, struct file *file); 33static int as102_open(struct inode *inode, struct file *file);
34static int as102_release(struct inode *inode, struct file *file); 34static int as102_release(struct inode *inode, struct file *file);
35 35
36static struct usb_device_id as102_usb_id_table[] = { 36static const struct usb_device_id as102_usb_id_table[] = {
37 { USB_DEVICE(AS102_USB_DEVICE_VENDOR_ID, AS102_USB_DEVICE_PID_0001) }, 37 { USB_DEVICE(AS102_USB_DEVICE_VENDOR_ID, AS102_USB_DEVICE_PID_0001) },
38 { USB_DEVICE(PCTV_74E_USB_VID, PCTV_74E_USB_PID) }, 38 { USB_DEVICE(PCTV_74E_USB_VID, PCTV_74E_USB_PID) },
39 { USB_DEVICE(ELGATO_EYETV_DTT_USB_VID, ELGATO_EYETV_DTT_USB_PID) }, 39 { USB_DEVICE(ELGATO_EYETV_DTT_USB_VID, ELGATO_EYETV_DTT_USB_PID) },
diff --git a/drivers/media/usb/au0828/Kconfig b/drivers/media/usb/au0828/Kconfig
index 78b797e0b434..70521e0b4c53 100644
--- a/drivers/media/usb/au0828/Kconfig
+++ b/drivers/media/usb/au0828/Kconfig
@@ -31,6 +31,7 @@ config VIDEO_AU0828_V4L2
31config VIDEO_AU0828_RC 31config VIDEO_AU0828_RC
32 bool "AU0828 Remote Controller support" 32 bool "AU0828 Remote Controller support"
33 depends on RC_CORE 33 depends on RC_CORE
34 depends on !(RC_CORE=m && VIDEO_AU0828=y)
34 depends on VIDEO_AU0828 35 depends on VIDEO_AU0828
35 ---help--- 36 ---help---
36 Enables Remote Controller support on au0828 driver. 37 Enables Remote Controller support on au0828 driver.
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 739df61cec4f..cd363a2100d4 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -628,6 +628,8 @@ static int au0828_usb_probe(struct usb_interface *interface,
628 if (retval) { 628 if (retval) {
629 pr_err("%s() au0282_dev_register failed to register on V4L2\n", 629 pr_err("%s() au0282_dev_register failed to register on V4L2\n",
630 __func__); 630 __func__);
631 mutex_unlock(&dev->lock);
632 kfree(dev);
631 goto done; 633 goto done;
632 } 634 }
633 635
diff --git a/drivers/media/usb/au0828/au0828-i2c.c b/drivers/media/usb/au0828/au0828-i2c.c
index 42b352bb4f02..ef7d1b830ca3 100644
--- a/drivers/media/usb/au0828/au0828-i2c.c
+++ b/drivers/media/usb/au0828/au0828-i2c.c
@@ -329,14 +329,14 @@ static u32 au0828_functionality(struct i2c_adapter *adap)
329 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C; 329 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C;
330} 330}
331 331
332static struct i2c_algorithm au0828_i2c_algo_template = { 332static const struct i2c_algorithm au0828_i2c_algo_template = {
333 .master_xfer = i2c_xfer, 333 .master_xfer = i2c_xfer,
334 .functionality = au0828_functionality, 334 .functionality = au0828_functionality,
335}; 335};
336 336
337/* ----------------------------------------------------------------------- */ 337/* ----------------------------------------------------------------------- */
338 338
339static struct i2c_adapter au0828_i2c_adap_template = { 339static const struct i2c_adapter au0828_i2c_adap_template = {
340 .name = KBUILD_MODNAME, 340 .name = KBUILD_MODNAME,
341 .owner = THIS_MODULE, 341 .owner = THIS_MODULE,
342 .algo = &au0828_i2c_algo_template, 342 .algo = &au0828_i2c_algo_template,
diff --git a/drivers/media/usb/au0828/au0828-input.c b/drivers/media/usb/au0828/au0828-input.c
index 9d82ec0a4b64..7996eb83a54e 100644
--- a/drivers/media/usb/au0828/au0828-input.c
+++ b/drivers/media/usb/au0828/au0828-input.c
@@ -335,7 +335,7 @@ int au0828_rc_register(struct au0828_dev *dev)
335 usb_make_path(dev->usbdev, ir->phys, sizeof(ir->phys)); 335 usb_make_path(dev->usbdev, ir->phys, sizeof(ir->phys));
336 strlcat(ir->phys, "/input0", sizeof(ir->phys)); 336 strlcat(ir->phys, "/input0", sizeof(ir->phys));
337 337
338 rc->input_name = ir->name; 338 rc->device_name = ir->name;
339 rc->input_phys = ir->phys; 339 rc->input_phys = ir->phys;
340 rc->input_id.bustype = BUS_USB; 340 rc->input_id.bustype = BUS_USB;
341 rc->input_id.version = 1; 341 rc->input_id.version = 1;
@@ -343,8 +343,8 @@ int au0828_rc_register(struct au0828_dev *dev)
343 rc->input_id.product = le16_to_cpu(dev->usbdev->descriptor.idProduct); 343 rc->input_id.product = le16_to_cpu(dev->usbdev->descriptor.idProduct);
344 rc->dev.parent = &dev->usbdev->dev; 344 rc->dev.parent = &dev->usbdev->dev;
345 rc->driver_name = "au0828-input"; 345 rc->driver_name = "au0828-input";
346 rc->allowed_protocols = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 | 346 rc->allowed_protocols = RC_PROTO_BIT_NEC | RC_PROTO_BIT_NECX |
347 RC_BIT_RC5; 347 RC_PROTO_BIT_NEC32 | RC_PROTO_BIT_RC5;
348 348
349 /* all done */ 349 /* all done */
350 err = rc_register_device(rc); 350 err = rc_register_device(rc);
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 2a255bd32bb3..9342402b92f7 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -1740,7 +1740,7 @@ void au0828_v4l2_resume(struct au0828_dev *dev)
1740 } 1740 }
1741} 1741}
1742 1742
1743static struct v4l2_file_operations au0828_v4l_fops = { 1743static const struct v4l2_file_operations au0828_v4l_fops = {
1744 .owner = THIS_MODULE, 1744 .owner = THIS_MODULE,
1745 .open = au0828_v4l2_open, 1745 .open = au0828_v4l2_open,
1746 .release = au0828_v4l2_close, 1746 .release = au0828_v4l2_close,
diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c
index 788c73803138..a8f3169e30b3 100644
--- a/drivers/media/usb/b2c2/flexcop-usb.c
+++ b/drivers/media/usb/b2c2/flexcop-usb.c
@@ -596,7 +596,7 @@ static void flexcop_usb_disconnect(struct usb_interface *intf)
596 info("%s successfully deinitialized and disconnected.", DRIVER_NAME); 596 info("%s successfully deinitialized and disconnected.", DRIVER_NAME);
597} 597}
598 598
599static struct usb_device_id flexcop_usb_table [] = { 599static const struct usb_device_id flexcop_usb_table[] = {
600 { USB_DEVICE(0x0af7, 0x0101) }, 600 { USB_DEVICE(0x0af7, 0x0101) },
601 { } 601 { }
602}; 602};
diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
index 1c7e16e5d88b..6089036049d9 100644
--- a/drivers/media/usb/cpia2/cpia2_usb.c
+++ b/drivers/media/usb/cpia2/cpia2_usb.c
@@ -60,7 +60,7 @@ static int submit_urbs(struct camera_data *cam);
60static int set_alternate(struct camera_data *cam, unsigned int alt); 60static int set_alternate(struct camera_data *cam, unsigned int alt);
61static int configure_transfer_mode(struct camera_data *cam, unsigned int alt); 61static int configure_transfer_mode(struct camera_data *cam, unsigned int alt);
62 62
63static struct usb_device_id cpia2_id_table[] = { 63static const struct usb_device_id cpia2_id_table[] = {
64 {USB_DEVICE(0x0553, 0x0100)}, 64 {USB_DEVICE(0x0553, 0x0100)},
65 {USB_DEVICE(0x0553, 0x0140)}, 65 {USB_DEVICE(0x0553, 0x0140)},
66 {USB_DEVICE(0x0553, 0x0151)}, /* STV0676 */ 66 {USB_DEVICE(0x0553, 0x0151)}, /* STV0676 */
diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c b/drivers/media/usb/cpia2/cpia2_v4l.c
index 7122023e7004..3dedd83f0b19 100644
--- a/drivers/media/usb/cpia2/cpia2_v4l.c
+++ b/drivers/media/usb/cpia2/cpia2_v4l.c
@@ -1075,7 +1075,7 @@ static const struct v4l2_file_operations cpia2_fops = {
1075 .mmap = cpia2_mmap, 1075 .mmap = cpia2_mmap,
1076}; 1076};
1077 1077
1078static struct video_device cpia2_template = { 1078static const struct video_device cpia2_template = {
1079 /* I could not find any place for the old .initialize initializer?? */ 1079 /* I could not find any place for the old .initialize initializer?? */
1080 .name = "CPiA2 Camera", 1080 .name = "CPiA2 Camera",
1081 .fops = &cpia2_fops, 1081 .fops = &cpia2_fops,
diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c
index 509d9711d590..d538fa407742 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1490,7 +1490,7 @@ static void bb_buf_release(struct videobuf_queue *q,
1490 free_buffer(q, buf); 1490 free_buffer(q, buf);
1491} 1491}
1492 1492
1493static struct videobuf_queue_ops cx231xx_qops = { 1493static const struct videobuf_queue_ops cx231xx_qops = {
1494 .buf_setup = bb_buf_setup, 1494 .buf_setup = bb_buf_setup,
1495 .buf_prepare = bb_buf_prepare, 1495 .buf_prepare = bb_buf_prepare,
1496 .buf_queue = bb_buf_queue, 1496 .buf_queue = bb_buf_queue,
@@ -1843,7 +1843,7 @@ static int mpeg_mmap(struct file *file, struct vm_area_struct *vma)
1843 return videobuf_mmap_mapper(&fh->vidq, vma); 1843 return videobuf_mmap_mapper(&fh->vidq, vma);
1844} 1844}
1845 1845
1846static struct v4l2_file_operations mpeg_fops = { 1846static const struct v4l2_file_operations mpeg_fops = {
1847 .owner = THIS_MODULE, 1847 .owner = THIS_MODULE,
1848 .open = mpeg_open, 1848 .open = mpeg_open,
1849 .release = mpeg_release, 1849 .release = mpeg_release,
diff --git a/drivers/media/usb/cx231xx/cx231xx-audio.c b/drivers/media/usb/cx231xx/cx231xx-audio.c
index a050d125934c..06f10d7fc4b0 100644
--- a/drivers/media/usb/cx231xx/cx231xx-audio.c
+++ b/drivers/media/usb/cx231xx/cx231xx-audio.c
@@ -403,7 +403,7 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs,
403 return 0; 403 return 0;
404} 404}
405 405
406static struct snd_pcm_hardware snd_cx231xx_hw_capture = { 406static const struct snd_pcm_hardware snd_cx231xx_hw_capture = {
407 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER | 407 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER |
408 SNDRV_PCM_INFO_MMAP | 408 SNDRV_PCM_INFO_MMAP |
409 SNDRV_PCM_INFO_INTERLEAVED | 409 SNDRV_PCM_INFO_INTERLEAVED |
diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c
index 46646ecd2dbc..f372ad3917a8 100644
--- a/drivers/media/usb/cx231xx/cx231xx-core.c
+++ b/drivers/media/usb/cx231xx/cx231xx-core.c
@@ -1311,6 +1311,7 @@ int cx231xx_dev_init(struct cx231xx *dev)
1311 dev->i2c_bus[0].i2c_period = I2C_SPEED_100K; /* 100 KHz */ 1311 dev->i2c_bus[0].i2c_period = I2C_SPEED_100K; /* 100 KHz */
1312 dev->i2c_bus[0].i2c_nostop = 0; 1312 dev->i2c_bus[0].i2c_nostop = 0;
1313 dev->i2c_bus[0].i2c_reserve = 0; 1313 dev->i2c_bus[0].i2c_reserve = 0;
1314 dev->i2c_bus[0].i2c_rc = -ENODEV;
1314 1315
1315 /* External Master 2 Bus */ 1316 /* External Master 2 Bus */
1316 dev->i2c_bus[1].nr = 1; 1317 dev->i2c_bus[1].nr = 1;
@@ -1318,6 +1319,7 @@ int cx231xx_dev_init(struct cx231xx *dev)
1318 dev->i2c_bus[1].i2c_period = I2C_SPEED_100K; /* 100 KHz */ 1319 dev->i2c_bus[1].i2c_period = I2C_SPEED_100K; /* 100 KHz */
1319 dev->i2c_bus[1].i2c_nostop = 0; 1320 dev->i2c_bus[1].i2c_nostop = 0;
1320 dev->i2c_bus[1].i2c_reserve = 0; 1321 dev->i2c_bus[1].i2c_reserve = 0;
1322 dev->i2c_bus[1].i2c_rc = -ENODEV;
1321 1323
1322 /* Internal Master 3 Bus */ 1324 /* Internal Master 3 Bus */
1323 dev->i2c_bus[2].nr = 2; 1325 dev->i2c_bus[2].nr = 2;
@@ -1325,6 +1327,7 @@ int cx231xx_dev_init(struct cx231xx *dev)
1325 dev->i2c_bus[2].i2c_period = I2C_SPEED_100K; /* 100kHz */ 1327 dev->i2c_bus[2].i2c_period = I2C_SPEED_100K; /* 100kHz */
1326 dev->i2c_bus[2].i2c_nostop = 0; 1328 dev->i2c_bus[2].i2c_nostop = 0;
1327 dev->i2c_bus[2].i2c_reserve = 0; 1329 dev->i2c_bus[2].i2c_reserve = 0;
1330 dev->i2c_bus[2].i2c_rc = -ENODEV;
1328 1331
1329 /* register I2C buses */ 1332 /* register I2C buses */
1330 errCode = cx231xx_i2c_register(&dev->i2c_bus[0]); 1333 errCode = cx231xx_i2c_register(&dev->i2c_bus[0]);
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index ee3eeeb600f8..c18bb33e060e 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -585,6 +585,9 @@ static void unregister_dvb(struct cx231xx_dvb *dvb)
585 dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); 585 dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw);
586 dvb_dmxdev_release(&dvb->dmxdev); 586 dvb_dmxdev_release(&dvb->dmxdev);
587 dvb_dmx_release(&dvb->demux); 587 dvb_dmx_release(&dvb->demux);
588 dvb_unregister_frontend(dvb->frontend);
589 dvb_frontend_detach(dvb->frontend);
590 dvb_unregister_adapter(&dvb->adapter);
588 /* remove I2C tuner */ 591 /* remove I2C tuner */
589 client = dvb->i2c_client_tuner; 592 client = dvb->i2c_client_tuner;
590 if (client) { 593 if (client) {
@@ -597,9 +600,6 @@ static void unregister_dvb(struct cx231xx_dvb *dvb)
597 module_put(client->dev.driver->owner); 600 module_put(client->dev.driver->owner);
598 i2c_unregister_device(client); 601 i2c_unregister_device(client);
599 } 602 }
600 dvb_unregister_frontend(dvb->frontend);
601 dvb_frontend_detach(dvb->frontend);
602 dvb_unregister_adapter(&dvb->adapter);
603} 603}
604 604
605static int dvb_init(struct cx231xx *dev) 605static int dvb_init(struct cx231xx *dev)
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
index 8d95b1154e12..23648dab7be8 100644
--- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
@@ -459,7 +459,7 @@ static const struct i2c_algorithm cx231xx_algo = {
459 .functionality = functionality, 459 .functionality = functionality,
460}; 460};
461 461
462static struct i2c_adapter cx231xx_adap_template = { 462static const struct i2c_adapter cx231xx_adap_template = {
463 .owner = THIS_MODULE, 463 .owner = THIS_MODULE,
464 .name = "cx231xx", 464 .name = "cx231xx",
465 .algo = &cx231xx_algo, 465 .algo = &cx231xx_algo,
@@ -538,7 +538,7 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
538 538
539 bus->i2c_adap.algo_data = bus; 539 bus->i2c_adap.algo_data = bus;
540 i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev); 540 i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev);
541 i2c_add_adapter(&bus->i2c_adap); 541 bus->i2c_rc = i2c_add_adapter(&bus->i2c_adap);
542 542
543 if (0 != bus->i2c_rc) 543 if (0 != bus->i2c_rc)
544 dev_warn(dev->dev, 544 dev_warn(dev->dev,
@@ -551,10 +551,10 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
551 * cx231xx_i2c_unregister() 551 * cx231xx_i2c_unregister()
552 * unregister i2c_bus 552 * unregister i2c_bus
553 */ 553 */
554int cx231xx_i2c_unregister(struct cx231xx_i2c *bus) 554void cx231xx_i2c_unregister(struct cx231xx_i2c *bus)
555{ 555{
556 i2c_del_adapter(&bus->i2c_adap); 556 if (!bus->i2c_rc)
557 return 0; 557 i2c_del_adapter(&bus->i2c_adap);
558} 558}
559 559
560/* 560/*
diff --git a/drivers/media/usb/cx231xx/cx231xx-input.c b/drivers/media/usb/cx231xx/cx231xx-input.c
index eecf074b0a48..02ebeb16055f 100644
--- a/drivers/media/usb/cx231xx/cx231xx-input.c
+++ b/drivers/media/usb/cx231xx/cx231xx-input.c
@@ -24,7 +24,7 @@
24 24
25#define MODULE_NAME "cx231xx-input" 25#define MODULE_NAME "cx231xx-input"
26 26
27static int get_key_isdbt(struct IR_i2c *ir, enum rc_type *protocol, 27static int get_key_isdbt(struct IR_i2c *ir, enum rc_proto *protocol,
28 u32 *pscancode, u8 *toggle) 28 u32 *pscancode, u8 *toggle)
29{ 29{
30 int rc; 30 int rc;
@@ -50,7 +50,7 @@ static int get_key_isdbt(struct IR_i2c *ir, enum rc_type *protocol,
50 50
51 dev_dbg(&ir->rc->dev, "cmd %02x, scan = %02x\n", cmd, scancode); 51 dev_dbg(&ir->rc->dev, "cmd %02x, scan = %02x\n", cmd, scancode);
52 52
53 *protocol = RC_TYPE_OTHER; 53 *protocol = RC_PROTO_OTHER;
54 *pscancode = scancode; 54 *pscancode = scancode;
55 *toggle = 0; 55 *toggle = 0;
56 return 1; 56 return 1;
@@ -91,7 +91,7 @@ int cx231xx_ir_init(struct cx231xx *dev)
91 /* The i2c micro-controller only outputs the cmd part of NEC protocol */ 91 /* The i2c micro-controller only outputs the cmd part of NEC protocol */
92 dev->init_data.rc_dev->scancode_mask = 0xff; 92 dev->init_data.rc_dev->scancode_mask = 0xff;
93 dev->init_data.rc_dev->driver_name = "cx231xx"; 93 dev->init_data.rc_dev->driver_name = "cx231xx";
94 dev->init_data.type = RC_BIT_NEC; 94 dev->init_data.type = RC_PROTO_BIT_NEC;
95 info.addr = 0x30; 95 info.addr = 0x30;
96 96
97 /* Load and bind ir-kbd-i2c */ 97 /* Load and bind ir-kbd-i2c */
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index f67f86876625..179b8481a870 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -859,7 +859,7 @@ static void buffer_release(struct videobuf_queue *vq,
859 free_buffer(vq, buf); 859 free_buffer(vq, buf);
860} 860}
861 861
862static struct videobuf_queue_ops cx231xx_video_qops = { 862static const struct videobuf_queue_ops cx231xx_video_qops = {
863 .buf_setup = buffer_setup, 863 .buf_setup = buffer_setup,
864 .buf_prepare = buffer_prepare, 864 .buf_prepare = buffer_prepare,
865 .buf_queue = buffer_queue, 865 .buf_queue = buffer_queue,
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index 986c64ba5b56..72d5937a087e 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -476,7 +476,7 @@ struct cx231xx_i2c {
476 476
477 /* i2c i/o */ 477 /* i2c i/o */
478 struct i2c_adapter i2c_adap; 478 struct i2c_adapter i2c_adap;
479 u32 i2c_rc; 479 int i2c_rc;
480 480
481 /* different settings for each bus */ 481 /* different settings for each bus */
482 u8 i2c_period; 482 u8 i2c_period;
@@ -762,7 +762,7 @@ int cx231xx_reset_analog_tuner(struct cx231xx *dev);
762/* Provided by cx231xx-i2c.c */ 762/* Provided by cx231xx-i2c.c */
763void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port); 763void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port);
764int cx231xx_i2c_register(struct cx231xx_i2c *bus); 764int cx231xx_i2c_register(struct cx231xx_i2c *bus);
765int cx231xx_i2c_unregister(struct cx231xx_i2c *bus); 765void cx231xx_i2c_unregister(struct cx231xx_i2c *bus);
766int cx231xx_i2c_mux_create(struct cx231xx *dev); 766int cx231xx_i2c_mux_create(struct cx231xx *dev);
767int cx231xx_i2c_mux_register(struct cx231xx *dev, int mux_no); 767int cx231xx_i2c_mux_register(struct cx231xx *dev, int mux_no);
768void cx231xx_i2c_mux_unregister(struct cx231xx *dev); 768void cx231xx_i2c_mux_unregister(struct cx231xx *dev);
diff --git a/drivers/media/usb/dvb-usb-v2/af9015.c b/drivers/media/usb/dvb-usb-v2/af9015.c
index 23bbbf367b51..8013659c41b1 100644
--- a/drivers/media/usb/dvb-usb-v2/af9015.c
+++ b/drivers/media/usb/dvb-usb-v2/af9015.c
@@ -1237,7 +1237,7 @@ static int af9015_rc_query(struct dvb_usb_device *d)
1237 1237
1238 /* Only process key if canary killed */ 1238 /* Only process key if canary killed */
1239 if (buf[16] != 0xff && buf[0] != 0x01) { 1239 if (buf[16] != 0xff && buf[0] != 0x01) {
1240 enum rc_type proto; 1240 enum rc_proto proto;
1241 dev_dbg(&d->udev->dev, "%s: key pressed %*ph\n", 1241 dev_dbg(&d->udev->dev, "%s: key pressed %*ph\n",
1242 __func__, 4, buf + 12); 1242 __func__, 4, buf + 12);
1243 1243
@@ -1253,13 +1253,13 @@ static int af9015_rc_query(struct dvb_usb_device *d)
1253 /* NEC */ 1253 /* NEC */
1254 state->rc_keycode = RC_SCANCODE_NEC(buf[12], 1254 state->rc_keycode = RC_SCANCODE_NEC(buf[12],
1255 buf[14]); 1255 buf[14]);
1256 proto = RC_TYPE_NEC; 1256 proto = RC_PROTO_NEC;
1257 } else { 1257 } else {
1258 /* NEC extended*/ 1258 /* NEC extended*/
1259 state->rc_keycode = RC_SCANCODE_NECX(buf[12] << 8 | 1259 state->rc_keycode = RC_SCANCODE_NECX(buf[12] << 8 |
1260 buf[13], 1260 buf[13],
1261 buf[14]); 1261 buf[14]);
1262 proto = RC_TYPE_NECX; 1262 proto = RC_PROTO_NECX;
1263 } 1263 }
1264 } else { 1264 } else {
1265 /* 32 bit NEC */ 1265 /* 32 bit NEC */
@@ -1267,7 +1267,7 @@ static int af9015_rc_query(struct dvb_usb_device *d)
1267 buf[13] << 16 | 1267 buf[13] << 16 |
1268 buf[14] << 8 | 1268 buf[14] << 8 |
1269 buf[15]); 1269 buf[15]);
1270 proto = RC_TYPE_NEC32; 1270 proto = RC_PROTO_NEC32;
1271 } 1271 }
1272 rc_keydown(d->rc_dev, proto, state->rc_keycode, 0); 1272 rc_keydown(d->rc_dev, proto, state->rc_keycode, 0);
1273 } else { 1273 } else {
@@ -1336,7 +1336,8 @@ static int af9015_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
1336 if (!rc->map_name) 1336 if (!rc->map_name)
1337 rc->map_name = RC_MAP_EMPTY; 1337 rc->map_name = RC_MAP_EMPTY;
1338 1338
1339 rc->allowed_protos = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32; 1339 rc->allowed_protos = RC_PROTO_BIT_NEC | RC_PROTO_BIT_NECX |
1340 RC_PROTO_BIT_NEC32;
1340 rc->query = af9015_rc_query; 1341 rc->query = af9015_rc_query;
1341 rc->interval = 500; 1342 rc->interval = 500;
1342 1343
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 4df9486e19b9..666d319d3d1a 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1828,7 +1828,7 @@ static int af9035_rc_query(struct dvb_usb_device *d)
1828{ 1828{
1829 struct usb_interface *intf = d->intf; 1829 struct usb_interface *intf = d->intf;
1830 int ret; 1830 int ret;
1831 enum rc_type proto; 1831 enum rc_proto proto;
1832 u32 key; 1832 u32 key;
1833 u8 buf[4]; 1833 u8 buf[4];
1834 struct usb_req req = { CMD_IR_GET, 0, 0, NULL, 4, buf }; 1834 struct usb_req req = { CMD_IR_GET, 0, 0, NULL, 4, buf };
@@ -1843,17 +1843,17 @@ static int af9035_rc_query(struct dvb_usb_device *d)
1843 if ((buf[0] + buf[1]) == 0xff) { 1843 if ((buf[0] + buf[1]) == 0xff) {
1844 /* NEC standard 16bit */ 1844 /* NEC standard 16bit */
1845 key = RC_SCANCODE_NEC(buf[0], buf[2]); 1845 key = RC_SCANCODE_NEC(buf[0], buf[2]);
1846 proto = RC_TYPE_NEC; 1846 proto = RC_PROTO_NEC;
1847 } else { 1847 } else {
1848 /* NEC extended 24bit */ 1848 /* NEC extended 24bit */
1849 key = RC_SCANCODE_NECX(buf[0] << 8 | buf[1], buf[2]); 1849 key = RC_SCANCODE_NECX(buf[0] << 8 | buf[1], buf[2]);
1850 proto = RC_TYPE_NECX; 1850 proto = RC_PROTO_NECX;
1851 } 1851 }
1852 } else { 1852 } else {
1853 /* NEC full code 32bit */ 1853 /* NEC full code 32bit */
1854 key = RC_SCANCODE_NEC32(buf[0] << 24 | buf[1] << 16 | 1854 key = RC_SCANCODE_NEC32(buf[0] << 24 | buf[1] << 16 |
1855 buf[2] << 8 | buf[3]); 1855 buf[2] << 8 | buf[3]);
1856 proto = RC_TYPE_NEC32; 1856 proto = RC_PROTO_NEC32;
1857 } 1857 }
1858 1858
1859 dev_dbg(&intf->dev, "%*ph\n", 4, buf); 1859 dev_dbg(&intf->dev, "%*ph\n", 4, buf);
@@ -1881,11 +1881,11 @@ static int af9035_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
1881 switch (state->ir_type) { 1881 switch (state->ir_type) {
1882 case 0: /* NEC */ 1882 case 0: /* NEC */
1883 default: 1883 default:
1884 rc->allowed_protos = RC_BIT_NEC | RC_BIT_NECX | 1884 rc->allowed_protos = RC_PROTO_BIT_NEC |
1885 RC_BIT_NEC32; 1885 RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32;
1886 break; 1886 break;
1887 case 1: /* RC6 */ 1887 case 1: /* RC6 */
1888 rc->allowed_protos = RC_BIT_RC6_MCE; 1888 rc->allowed_protos = RC_PROTO_BIT_RC6_MCE;
1889 break; 1889 break;
1890 } 1890 }
1891 1891
@@ -2108,6 +2108,8 @@ static const struct usb_device_id af9035_id_table[] = {
2108 { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CTVDIGDUAL_V2, 2108 { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CTVDIGDUAL_V2,
2109 &af9035_props, "Digital Dual TV Receiver CTVDIGDUAL_V2", 2109 &af9035_props, "Digital Dual TV Receiver CTVDIGDUAL_V2",
2110 RC_MAP_IT913X_V1) }, 2110 RC_MAP_IT913X_V1) },
2111 { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T1,
2112 &af9035_props, "TerraTec T1", RC_MAP_IT913X_V1) },
2111 /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */ 2113 /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
2112 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099, 2114 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099,
2113 &af9035_props, "TerraTec Cinergy T Stick Dual RC (rev. 2)", 2115 &af9035_props, "TerraTec Cinergy T Stick Dual RC (rev. 2)",
diff --git a/drivers/media/usb/dvb-usb-v2/anysee.c b/drivers/media/usb/dvb-usb-v2/anysee.c
index 6795c0c609b1..20ee7eea2a91 100644
--- a/drivers/media/usb/dvb-usb-v2/anysee.c
+++ b/drivers/media/usb/dvb-usb-v2/anysee.c
@@ -1142,7 +1142,7 @@ static int anysee_rc_query(struct dvb_usb_device *d)
1142 if (ircode[0]) { 1142 if (ircode[0]) {
1143 dev_dbg(&d->udev->dev, "%s: key pressed %02x\n", __func__, 1143 dev_dbg(&d->udev->dev, "%s: key pressed %02x\n", __func__,
1144 ircode[1]); 1144 ircode[1]);
1145 rc_keydown(d->rc_dev, RC_TYPE_NEC, 1145 rc_keydown(d->rc_dev, RC_PROTO_NEC,
1146 RC_SCANCODE_NEC(0x08, ircode[1]), 0); 1146 RC_SCANCODE_NEC(0x08, ircode[1]), 0);
1147 } 1147 }
1148 1148
@@ -1151,7 +1151,7 @@ static int anysee_rc_query(struct dvb_usb_device *d)
1151 1151
1152static int anysee_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc) 1152static int anysee_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
1153{ 1153{
1154 rc->allowed_protos = RC_BIT_NEC; 1154 rc->allowed_protos = RC_PROTO_BIT_NEC;
1155 rc->query = anysee_rc_query; 1155 rc->query = anysee_rc_query;
1156 rc->interval = 250; /* windows driver uses 500ms */ 1156 rc->interval = 250; /* windows driver uses 500ms */
1157 1157
diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 50c07fe7dacb..1414d59e85ba 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -208,7 +208,7 @@ static int az6007_rc_query(struct dvb_usb_device *d)
208{ 208{
209 struct az6007_device_state *st = d_to_priv(d); 209 struct az6007_device_state *st = d_to_priv(d);
210 unsigned code; 210 unsigned code;
211 enum rc_type proto; 211 enum rc_proto proto;
212 212
213 az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10); 213 az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10);
214 214
@@ -218,18 +218,18 @@ static int az6007_rc_query(struct dvb_usb_device *d)
218 if ((st->data[3] ^ st->data[4]) == 0xff) { 218 if ((st->data[3] ^ st->data[4]) == 0xff) {
219 if ((st->data[1] ^ st->data[2]) == 0xff) { 219 if ((st->data[1] ^ st->data[2]) == 0xff) {
220 code = RC_SCANCODE_NEC(st->data[1], st->data[3]); 220 code = RC_SCANCODE_NEC(st->data[1], st->data[3]);
221 proto = RC_TYPE_NEC; 221 proto = RC_PROTO_NEC;
222 } else { 222 } else {
223 code = RC_SCANCODE_NECX(st->data[1] << 8 | st->data[2], 223 code = RC_SCANCODE_NECX(st->data[1] << 8 | st->data[2],
224 st->data[3]); 224 st->data[3]);
225 proto = RC_TYPE_NECX; 225 proto = RC_PROTO_NECX;
226 } 226 }
227 } else { 227 } else {
228 code = RC_SCANCODE_NEC32(st->data[1] << 24 | 228 code = RC_SCANCODE_NEC32(st->data[1] << 24 |
229 st->data[2] << 16 | 229 st->data[2] << 16 |
230 st->data[3] << 8 | 230 st->data[3] << 8 |
231 st->data[4]); 231 st->data[4]);
232 proto = RC_TYPE_NEC32; 232 proto = RC_PROTO_NEC32;
233 } 233 }
234 234
235 rc_keydown(d->rc_dev, proto, code, st->data[5]); 235 rc_keydown(d->rc_dev, proto, code, st->data[5]);
@@ -241,7 +241,8 @@ static int az6007_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
241{ 241{
242 pr_debug("Getting az6007 Remote Control properties\n"); 242 pr_debug("Getting az6007 Remote Control properties\n");
243 243
244 rc->allowed_protos = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32; 244 rc->allowed_protos = RC_PROTO_BIT_NEC | RC_PROTO_BIT_NECX |
245 RC_PROTO_BIT_NEC32;
245 rc->query = az6007_rc_query; 246 rc->query = az6007_rc_query;
246 rc->interval = 400; 247 rc->interval = 400;
247 248
@@ -933,7 +934,7 @@ static struct dvb_usb_device_properties az6007_cablestar_hdci_props = {
933 } 934 }
934}; 935};
935 936
936static struct usb_device_id az6007_usb_table[] = { 937static const struct usb_device_id az6007_usb_table[] = {
937 {DVB_USB_DEVICE(USB_VID_AZUREWAVE, USB_PID_AZUREWAVE_6007, 938 {DVB_USB_DEVICE(USB_VID_AZUREWAVE, USB_PID_AZUREWAVE_6007,
938 &az6007_props, "Azurewave 6007", RC_MAP_EMPTY)}, 939 &az6007_props, "Azurewave 6007", RC_MAP_EMPTY)},
939 {DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_H7, 940 {DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_H7,
diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb.h b/drivers/media/usb/dvb-usb-v2/dvb_usb.h
index 35f27e2e4e28..0005bdb2207d 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb.h
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb.h
@@ -138,7 +138,7 @@ struct dvb_usb_driver_info {
138struct dvb_usb_rc { 138struct dvb_usb_rc {
139 const char *map_name; 139 const char *map_name;
140 u64 allowed_protos; 140 u64 allowed_protos;
141 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); 141 int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto);
142 int (*query) (struct dvb_usb_device *d); 142 int (*query) (struct dvb_usb_device *d);
143 unsigned int interval; 143 unsigned int interval;
144 enum rc_driver_type driver_type; 144 enum rc_driver_type driver_type;
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 955fb0d07507..096bb75a24e5 100644
--- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
+++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
@@ -154,13 +154,12 @@ static int dvb_usbv2_remote_init(struct dvb_usb_device *d)
154 } 154 }
155 155
156 dev->dev.parent = &d->udev->dev; 156 dev->dev.parent = &d->udev->dev;
157 dev->input_name = d->name; 157 dev->device_name = d->name;
158 usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys)); 158 usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));
159 strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys)); 159 strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));
160 dev->input_phys = d->rc_phys; 160 dev->input_phys = d->rc_phys;
161 usb_to_input_id(d->udev, &dev->input_id); 161 usb_to_input_id(d->udev, &dev->input_id);
162 /* TODO: likely RC-core should took const char * */ 162 dev->driver_name = d->props->driver_name;
163 dev->driver_name = (char *) d->props->driver_name;
164 dev->map_name = d->rc.map_name; 163 dev->map_name = d->rc.map_name;
165 dev->allowed_protocols = d->rc.allowed_protos; 164 dev->allowed_protocols = d->rc.allowed_protos;
166 dev->change_protocol = d->rc.change_protocol; 165 dev->change_protocol = d->rc.change_protocol;
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index 5730760e4e93..131b6c08e199 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -211,7 +211,7 @@ static int dvbsky_rc_query(struct dvb_usb_device *d)
211 rc5_system = (code & 0x7C0) >> 6; 211 rc5_system = (code & 0x7C0) >> 6;
212 toggle = (code & 0x800) ? 1 : 0; 212 toggle = (code & 0x800) ? 1 : 0;
213 scancode = rc5_system << 8 | rc5_command; 213 scancode = rc5_system << 8 | rc5_command;
214 rc_keydown(d->rc_dev, RC_TYPE_RC5, scancode, toggle); 214 rc_keydown(d->rc_dev, RC_PROTO_RC5, scancode, toggle);
215 } 215 }
216 return 0; 216 return 0;
217} 217}
@@ -223,7 +223,7 @@ static int dvbsky_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
223 return 0; 223 return 0;
224 } 224 }
225 225
226 rc->allowed_protos = RC_BIT_RC5; 226 rc->allowed_protos = RC_PROTO_BIT_RC5;
227 rc->query = dvbsky_rc_query; 227 rc->query = dvbsky_rc_query;
228 rc->interval = 300; 228 rc->interval = 300;
229 return 0; 229 return 0;
diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index a91fdad8f8d4..5e320fa4a795 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -347,8 +347,8 @@ static void lme2510_int_response(struct urb *lme_urb)
347 ibuf[5]); 347 ibuf[5]);
348 348
349 deb_info(1, "INT Key = 0x%08x", key); 349 deb_info(1, "INT Key = 0x%08x", key);
350 rc_keydown(adap_to_d(adap)->rc_dev, RC_TYPE_NEC32, key, 350 rc_keydown(adap_to_d(adap)->rc_dev, RC_PROTO_NEC32, key,
351 0); 351 0);
352 break; 352 break;
353 case 0xbb: 353 case 0xbb:
354 switch (st->tuner_config) { 354 switch (st->tuner_config) {
@@ -1232,7 +1232,7 @@ static int lme2510_get_stream_config(struct dvb_frontend *fe, u8 *ts_type,
1232static int lme2510_get_rc_config(struct dvb_usb_device *d, 1232static int lme2510_get_rc_config(struct dvb_usb_device *d,
1233 struct dvb_usb_rc *rc) 1233 struct dvb_usb_rc *rc)
1234{ 1234{
1235 rc->allowed_protos = RC_BIT_NEC32; 1235 rc->allowed_protos = RC_PROTO_BIT_NEC32;
1236 return 0; 1236 return 0;
1237} 1237}
1238 1238
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
index b0d5904a4ea6..67953360fda5 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
@@ -77,7 +77,9 @@ int mxl111sf_ctrl_msg(struct mxl111sf_state *state,
77 dvb_usbv2_generic_rw(d, state->sndbuf, 1+wlen, state->rcvbuf, 77 dvb_usbv2_generic_rw(d, state->sndbuf, 1+wlen, state->rcvbuf,
78 rlen); 78 rlen);
79 79
80 memcpy(rbuf, state->rcvbuf, rlen); 80 if (rbuf)
81 memcpy(rbuf, state->rcvbuf, rlen);
82
81 mutex_unlock(&state->msg_lock); 83 mutex_unlock(&state->msg_lock);
82 84
83 mxl_fail(ret); 85 mxl_fail(ret);
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index e16ca07acf1d..95a7b9123f8e 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1631,24 +1631,24 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d)
1631 goto err; 1631 goto err;
1632 1632
1633 if (buf[4] & 0x01) { 1633 if (buf[4] & 0x01) {
1634 enum rc_type proto; 1634 enum rc_proto proto;
1635 1635
1636 if (buf[2] == (u8) ~buf[3]) { 1636 if (buf[2] == (u8) ~buf[3]) {
1637 if (buf[0] == (u8) ~buf[1]) { 1637 if (buf[0] == (u8) ~buf[1]) {
1638 /* NEC standard (16 bit) */ 1638 /* NEC standard (16 bit) */
1639 rc_code = RC_SCANCODE_NEC(buf[0], buf[2]); 1639 rc_code = RC_SCANCODE_NEC(buf[0], buf[2]);
1640 proto = RC_TYPE_NEC; 1640 proto = RC_PROTO_NEC;
1641 } else { 1641 } else {
1642 /* NEC extended (24 bit) */ 1642 /* NEC extended (24 bit) */
1643 rc_code = RC_SCANCODE_NECX(buf[0] << 8 | buf[1], 1643 rc_code = RC_SCANCODE_NECX(buf[0] << 8 | buf[1],
1644 buf[2]); 1644 buf[2]);
1645 proto = RC_TYPE_NECX; 1645 proto = RC_PROTO_NECX;
1646 } 1646 }
1647 } else { 1647 } else {
1648 /* NEC full (32 bit) */ 1648 /* NEC full (32 bit) */
1649 rc_code = RC_SCANCODE_NEC32(buf[0] << 24 | buf[1] << 16 | 1649 rc_code = RC_SCANCODE_NEC32(buf[0] << 24 | buf[1] << 16 |
1650 buf[2] << 8 | buf[3]); 1650 buf[2] << 8 | buf[3]);
1651 proto = RC_TYPE_NEC32; 1651 proto = RC_PROTO_NEC32;
1652 } 1652 }
1653 1653
1654 rc_keydown(d->rc_dev, proto, rc_code, 0); 1654 rc_keydown(d->rc_dev, proto, rc_code, 0);
@@ -1673,7 +1673,8 @@ static int rtl2831u_get_rc_config(struct dvb_usb_device *d,
1673 struct dvb_usb_rc *rc) 1673 struct dvb_usb_rc *rc)
1674{ 1674{
1675 rc->map_name = RC_MAP_EMPTY; 1675 rc->map_name = RC_MAP_EMPTY;
1676 rc->allowed_protos = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32; 1676 rc->allowed_protos = RC_PROTO_BIT_NEC | RC_PROTO_BIT_NECX |
1677 RC_PROTO_BIT_NEC32;
1677 rc->query = rtl2831u_rc_query; 1678 rc->query = rtl2831u_rc_query;
1678 rc->interval = 400; 1679 rc->interval = 400;
1679 1680
@@ -1778,7 +1779,7 @@ static int rtl2832u_get_rc_config(struct dvb_usb_device *d,
1778 /* load empty to enable rc */ 1779 /* load empty to enable rc */
1779 if (!rc->map_name) 1780 if (!rc->map_name)
1780 rc->map_name = RC_MAP_EMPTY; 1781 rc->map_name = RC_MAP_EMPTY;
1781 rc->allowed_protos = RC_BIT_ALL_IR_DECODER; 1782 rc->allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER;
1782 rc->driver_type = RC_DRIVER_IR_RAW; 1783 rc->driver_type = RC_DRIVER_IR_RAW;
1783 rc->query = rtl2832u_rc_query; 1784 rc->query = rtl2832u_rc_query;
1784 rc->interval = 200; 1785 rc->interval = 200;
diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
index 99a3f3625944..37dea0adc695 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -458,7 +458,7 @@ static int cxusb_rc_query(struct dvb_usb_device *d)
458 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4); 458 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
459 459
460 if (ircode[2] || ircode[3]) 460 if (ircode[2] || ircode[3])
461 rc_keydown(d->rc_dev, RC_TYPE_NEC, 461 rc_keydown(d->rc_dev, RC_PROTO_NEC,
462 RC_SCANCODE_NEC(~ircode[2] & 0xff, ircode[3]), 0); 462 RC_SCANCODE_NEC(~ircode[2] & 0xff, ircode[3]), 0);
463 return 0; 463 return 0;
464} 464}
@@ -473,7 +473,7 @@ static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d)
473 return 0; 473 return 0;
474 474
475 if (ircode[1] || ircode[2]) 475 if (ircode[1] || ircode[2])
476 rc_keydown(d->rc_dev, RC_TYPE_NEC, 476 rc_keydown(d->rc_dev, RC_PROTO_NEC,
477 RC_SCANCODE_NEC(~ircode[1] & 0xff, ircode[2]), 0); 477 RC_SCANCODE_NEC(~ircode[1] & 0xff, ircode[2]), 0);
478 return 0; 478 return 0;
479} 479}
@@ -486,7 +486,7 @@ static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d)
486 return 0; 486 return 0;
487 487
488 if (ircode[0] || ircode[1]) 488 if (ircode[0] || ircode[1])
489 rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, 489 rc_keydown(d->rc_dev, RC_PROTO_UNKNOWN,
490 RC_SCANCODE_RC5(ircode[0], ircode[1]), 0); 490 RC_SCANCODE_RC5(ircode[0], ircode[1]), 0);
491 return 0; 491 return 0;
492} 492}
@@ -1646,7 +1646,7 @@ static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
1646 .rc_codes = RC_MAP_DVICO_PORTABLE, 1646 .rc_codes = RC_MAP_DVICO_PORTABLE,
1647 .module_name = KBUILD_MODNAME, 1647 .module_name = KBUILD_MODNAME,
1648 .rc_query = cxusb_rc_query, 1648 .rc_query = cxusb_rc_query,
1649 .allowed_protos = RC_BIT_NEC, 1649 .allowed_protos = RC_PROTO_BIT_NEC,
1650 }, 1650 },
1651 1651
1652 .generic_bulk_ctrl_endpoint = 0x01, 1652 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1703,7 +1703,7 @@ static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
1703 .rc_codes = RC_MAP_DVICO_MCE, 1703 .rc_codes = RC_MAP_DVICO_MCE,
1704 .module_name = KBUILD_MODNAME, 1704 .module_name = KBUILD_MODNAME,
1705 .rc_query = cxusb_rc_query, 1705 .rc_query = cxusb_rc_query,
1706 .allowed_protos = RC_BIT_NEC, 1706 .allowed_protos = RC_PROTO_BIT_NEC,
1707 }, 1707 },
1708 1708
1709 .generic_bulk_ctrl_endpoint = 0x01, 1709 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1768,7 +1768,7 @@ static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
1768 .rc_codes = RC_MAP_DVICO_PORTABLE, 1768 .rc_codes = RC_MAP_DVICO_PORTABLE,
1769 .module_name = KBUILD_MODNAME, 1769 .module_name = KBUILD_MODNAME,
1770 .rc_query = cxusb_rc_query, 1770 .rc_query = cxusb_rc_query,
1771 .allowed_protos = RC_BIT_NEC, 1771 .allowed_protos = RC_PROTO_BIT_NEC,
1772 }, 1772 },
1773 1773
1774 .generic_bulk_ctrl_endpoint = 0x01, 1774 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1824,7 +1824,7 @@ static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
1824 .rc_codes = RC_MAP_DVICO_PORTABLE, 1824 .rc_codes = RC_MAP_DVICO_PORTABLE,
1825 .module_name = KBUILD_MODNAME, 1825 .module_name = KBUILD_MODNAME,
1826 .rc_query = cxusb_rc_query, 1826 .rc_query = cxusb_rc_query,
1827 .allowed_protos = RC_BIT_NEC, 1827 .allowed_protos = RC_PROTO_BIT_NEC,
1828 }, 1828 },
1829 1829
1830 .generic_bulk_ctrl_endpoint = 0x01, 1830 .generic_bulk_ctrl_endpoint = 0x01,
@@ -1879,7 +1879,7 @@ static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1879 .rc_codes = RC_MAP_DVICO_MCE, 1879 .rc_codes = RC_MAP_DVICO_MCE,
1880 .module_name = KBUILD_MODNAME, 1880 .module_name = KBUILD_MODNAME,
1881 .rc_query = cxusb_bluebird2_rc_query, 1881 .rc_query = cxusb_bluebird2_rc_query,
1882 .allowed_protos = RC_BIT_NEC, 1882 .allowed_protos = RC_PROTO_BIT_NEC,
1883 }, 1883 },
1884 1884
1885 .num_device_descs = 1, 1885 .num_device_descs = 1,
@@ -1933,7 +1933,7 @@ static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1933 .rc_codes = RC_MAP_DVICO_PORTABLE, 1933 .rc_codes = RC_MAP_DVICO_PORTABLE,
1934 .module_name = KBUILD_MODNAME, 1934 .module_name = KBUILD_MODNAME,
1935 .rc_query = cxusb_bluebird2_rc_query, 1935 .rc_query = cxusb_bluebird2_rc_query,
1936 .allowed_protos = RC_BIT_NEC, 1936 .allowed_protos = RC_PROTO_BIT_NEC,
1937 }, 1937 },
1938 1938
1939 .num_device_descs = 1, 1939 .num_device_descs = 1,
@@ -1989,7 +1989,7 @@ static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_prope
1989 .rc_codes = RC_MAP_DVICO_PORTABLE, 1989 .rc_codes = RC_MAP_DVICO_PORTABLE,
1990 .module_name = KBUILD_MODNAME, 1990 .module_name = KBUILD_MODNAME,
1991 .rc_query = cxusb_rc_query, 1991 .rc_query = cxusb_rc_query,
1992 .allowed_protos = RC_BIT_NEC, 1992 .allowed_protos = RC_PROTO_BIT_NEC,
1993 }, 1993 },
1994 1994
1995 .num_device_descs = 1, 1995 .num_device_descs = 1,
@@ -2088,7 +2088,7 @@ struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
2088 .rc_codes = RC_MAP_DVICO_MCE, 2088 .rc_codes = RC_MAP_DVICO_MCE,
2089 .module_name = KBUILD_MODNAME, 2089 .module_name = KBUILD_MODNAME,
2090 .rc_query = cxusb_rc_query, 2090 .rc_query = cxusb_rc_query,
2091 .allowed_protos = RC_BIT_NEC, 2091 .allowed_protos = RC_PROTO_BIT_NEC,
2092 }, 2092 },
2093 2093
2094 .num_device_descs = 1, 2094 .num_device_descs = 1,
@@ -2142,7 +2142,7 @@ static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
2142 .rc_codes = RC_MAP_D680_DMB, 2142 .rc_codes = RC_MAP_D680_DMB,
2143 .module_name = KBUILD_MODNAME, 2143 .module_name = KBUILD_MODNAME,
2144 .rc_query = cxusb_d680_dmb_rc_query, 2144 .rc_query = cxusb_d680_dmb_rc_query,
2145 .allowed_protos = RC_BIT_UNKNOWN, 2145 .allowed_protos = RC_PROTO_BIT_UNKNOWN,
2146 }, 2146 },
2147 2147
2148 .num_device_descs = 1, 2148 .num_device_descs = 1,
@@ -2197,7 +2197,7 @@ static struct dvb_usb_device_properties cxusb_mygica_d689_properties = {
2197 .rc_codes = RC_MAP_D680_DMB, 2197 .rc_codes = RC_MAP_D680_DMB,
2198 .module_name = KBUILD_MODNAME, 2198 .module_name = KBUILD_MODNAME,
2199 .rc_query = cxusb_d680_dmb_rc_query, 2199 .rc_query = cxusb_d680_dmb_rc_query,
2200 .allowed_protos = RC_BIT_UNKNOWN, 2200 .allowed_protos = RC_PROTO_BIT_UNKNOWN,
2201 }, 2201 },
2202 2202
2203 .num_device_descs = 1, 2203 .num_device_descs = 1,
@@ -2251,7 +2251,7 @@ static struct dvb_usb_device_properties cxusb_mygica_t230_properties = {
2251 .rc_codes = RC_MAP_TOTAL_MEDIA_IN_HAND_02, 2251 .rc_codes = RC_MAP_TOTAL_MEDIA_IN_HAND_02,
2252 .module_name = KBUILD_MODNAME, 2252 .module_name = KBUILD_MODNAME,
2253 .rc_query = cxusb_d680_dmb_rc_query, 2253 .rc_query = cxusb_d680_dmb_rc_query,
2254 .allowed_protos = RC_BIT_UNKNOWN, 2254 .allowed_protos = RC_PROTO_BIT_UNKNOWN,
2255 }, 2255 },
2256 2256
2257 .num_device_descs = 1, 2257 .num_device_descs = 1,
@@ -2305,7 +2305,7 @@ static struct dvb_usb_device_properties cxusb_mygica_t230c_properties = {
2305 .rc_codes = RC_MAP_TOTAL_MEDIA_IN_HAND_02, 2305 .rc_codes = RC_MAP_TOTAL_MEDIA_IN_HAND_02,
2306 .module_name = KBUILD_MODNAME, 2306 .module_name = KBUILD_MODNAME,
2307 .rc_query = cxusb_d680_dmb_rc_query, 2307 .rc_query = cxusb_d680_dmb_rc_query,
2308 .allowed_protos = RC_BIT_UNKNOWN, 2308 .allowed_protos = RC_PROTO_BIT_UNKNOWN,
2309 }, 2309 },
2310 2310
2311 .num_device_descs = 1, 2311 .num_device_descs = 1,
diff --git a/drivers/media/usb/dvb-usb/dib0700.h b/drivers/media/usb/dvb-usb/dib0700.h
index 8fd8f5b489d2..f89ab3b5a6c4 100644
--- a/drivers/media/usb/dvb-usb/dib0700.h
+++ b/drivers/media/usb/dvb-usb/dib0700.h
@@ -64,7 +64,7 @@ extern int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff);
64extern struct i2c_algorithm dib0700_i2c_algo; 64extern struct i2c_algorithm dib0700_i2c_algo;
65extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props, 65extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
66 struct dvb_usb_device_description **desc, int *cold); 66 struct dvb_usb_device_description **desc, int *cold);
67extern int dib0700_change_protocol(struct rc_dev *dev, u64 *rc_type); 67extern int dib0700_change_protocol(struct rc_dev *dev, u64 *rc_proto);
68extern int dib0700_set_i2c_speed(struct dvb_usb_device *d, u16 scl_kHz); 68extern int dib0700_set_i2c_speed(struct dvb_usb_device *d, u16 scl_kHz);
69 69
70extern int dib0700_device_count; 70extern int dib0700_device_count;
diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c
index bea1b4764a66..1ee7ec558293 100644
--- a/drivers/media/usb/dvb-usb/dib0700_core.c
+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
@@ -638,7 +638,7 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
638 return ret; 638 return ret;
639} 639}
640 640
641int dib0700_change_protocol(struct rc_dev *rc, u64 *rc_type) 641int dib0700_change_protocol(struct rc_dev *rc, u64 *rc_proto)
642{ 642{
643 struct dvb_usb_device *d = rc->priv; 643 struct dvb_usb_device *d = rc->priv;
644 struct dib0700_state *st = d->priv; 644 struct dib0700_state *st = d->priv;
@@ -654,19 +654,19 @@ int dib0700_change_protocol(struct rc_dev *rc, u64 *rc_type)
654 st->buf[2] = 0; 654 st->buf[2] = 0;
655 655
656 /* Set the IR mode */ 656 /* Set the IR mode */
657 if (*rc_type & RC_BIT_RC5) { 657 if (*rc_proto & RC_PROTO_BIT_RC5) {
658 new_proto = 1; 658 new_proto = 1;
659 *rc_type = RC_BIT_RC5; 659 *rc_proto = RC_PROTO_BIT_RC5;
660 } else if (*rc_type & RC_BIT_NEC) { 660 } else if (*rc_proto & RC_PROTO_BIT_NEC) {
661 new_proto = 0; 661 new_proto = 0;
662 *rc_type = RC_BIT_NEC; 662 *rc_proto = RC_PROTO_BIT_NEC;
663 } else if (*rc_type & RC_BIT_RC6_MCE) { 663 } else if (*rc_proto & RC_PROTO_BIT_RC6_MCE) {
664 if (st->fw_version < 0x10200) { 664 if (st->fw_version < 0x10200) {
665 ret = -EINVAL; 665 ret = -EINVAL;
666 goto out; 666 goto out;
667 } 667 }
668 new_proto = 2; 668 new_proto = 2;
669 *rc_type = RC_BIT_RC6_MCE; 669 *rc_proto = RC_PROTO_BIT_RC6_MCE;
670 } else { 670 } else {
671 ret = -EINVAL; 671 ret = -EINVAL;
672 goto out; 672 goto out;
@@ -680,7 +680,7 @@ int dib0700_change_protocol(struct rc_dev *rc, u64 *rc_type)
680 goto out; 680 goto out;
681 } 681 }
682 682
683 d->props.rc.core.protocol = *rc_type; 683 d->props.rc.core.protocol = *rc_proto;
684 684
685out: 685out:
686 mutex_unlock(&d->usb_mutex); 686 mutex_unlock(&d->usb_mutex);
@@ -712,7 +712,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
712{ 712{
713 struct dvb_usb_device *d = purb->context; 713 struct dvb_usb_device *d = purb->context;
714 struct dib0700_rc_response *poll_reply; 714 struct dib0700_rc_response *poll_reply;
715 enum rc_type protocol; 715 enum rc_proto protocol;
716 u32 keycode; 716 u32 keycode;
717 u8 toggle; 717 u8 toggle;
718 718
@@ -745,7 +745,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
745 purb->actual_length); 745 purb->actual_length);
746 746
747 switch (d->props.rc.core.protocol) { 747 switch (d->props.rc.core.protocol) {
748 case RC_BIT_NEC: 748 case RC_PROTO_BIT_NEC:
749 toggle = 0; 749 toggle = 0;
750 750
751 /* NEC protocol sends repeat code as 0 0 0 FF */ 751 /* NEC protocol sends repeat code as 0 0 0 FF */
@@ -764,25 +764,25 @@ static void dib0700_rc_urb_completion(struct urb *purb)
764 poll_reply->nec.not_system << 16 | 764 poll_reply->nec.not_system << 16 |
765 poll_reply->nec.data << 8 | 765 poll_reply->nec.data << 8 |
766 poll_reply->nec.not_data); 766 poll_reply->nec.not_data);
767 protocol = RC_TYPE_NEC32; 767 protocol = RC_PROTO_NEC32;
768 } else if ((poll_reply->nec.system ^ poll_reply->nec.not_system) != 0xff) { 768 } else if ((poll_reply->nec.system ^ poll_reply->nec.not_system) != 0xff) {
769 deb_data("NEC extended protocol\n"); 769 deb_data("NEC extended protocol\n");
770 keycode = RC_SCANCODE_NECX(poll_reply->nec.system << 8 | 770 keycode = RC_SCANCODE_NECX(poll_reply->nec.system << 8 |
771 poll_reply->nec.not_system, 771 poll_reply->nec.not_system,
772 poll_reply->nec.data); 772 poll_reply->nec.data);
773 773
774 protocol = RC_TYPE_NECX; 774 protocol = RC_PROTO_NECX;
775 } else { 775 } else {
776 deb_data("NEC normal protocol\n"); 776 deb_data("NEC normal protocol\n");
777 keycode = RC_SCANCODE_NEC(poll_reply->nec.system, 777 keycode = RC_SCANCODE_NEC(poll_reply->nec.system,
778 poll_reply->nec.data); 778 poll_reply->nec.data);
779 protocol = RC_TYPE_NEC; 779 protocol = RC_PROTO_NEC;
780 } 780 }
781 781
782 break; 782 break;
783 default: 783 default:
784 deb_data("RC5 protocol\n"); 784 deb_data("RC5 protocol\n");
785 protocol = RC_TYPE_RC5; 785 protocol = RC_PROTO_RC5;
786 toggle = poll_reply->report_id; 786 toggle = poll_reply->report_id;
787 keycode = RC_SCANCODE_RC5(poll_reply->rc5.system, poll_reply->rc5.data); 787 keycode = RC_SCANCODE_RC5(poll_reply->rc5.system, poll_reply->rc5.data);
788 788
diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c b/drivers/media/usb/dvb-usb/dib0700_devices.c
index 6a57fc6d3472..6020170fe99a 100644
--- a/drivers/media/usb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/usb/dvb-usb/dib0700_devices.c
@@ -514,7 +514,7 @@ static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
514 */ 514 */
515static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d) 515static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
516{ 516{
517 enum rc_type protocol; 517 enum rc_proto protocol;
518 u32 scancode; 518 u32 scancode;
519 u8 toggle; 519 u8 toggle;
520 int i; 520 int i;
@@ -547,7 +547,7 @@ static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
547 dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */ 547 dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */
548 548
549 switch (d->props.rc.core.protocol) { 549 switch (d->props.rc.core.protocol) {
550 case RC_BIT_NEC: 550 case RC_PROTO_BIT_NEC:
551 /* NEC protocol sends repeat code as 0 0 0 FF */ 551 /* NEC protocol sends repeat code as 0 0 0 FF */
552 if ((st->buf[3 - 2] == 0x00) && (st->buf[3 - 3] == 0x00) && 552 if ((st->buf[3 - 2] == 0x00) && (st->buf[3 - 3] == 0x00) &&
553 (st->buf[3] == 0xff)) { 553 (st->buf[3] == 0xff)) {
@@ -555,14 +555,14 @@ static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
555 return 0; 555 return 0;
556 } 556 }
557 557
558 protocol = RC_TYPE_NEC; 558 protocol = RC_PROTO_NEC;
559 scancode = RC_SCANCODE_NEC(st->buf[3 - 2], st->buf[3 - 3]); 559 scancode = RC_SCANCODE_NEC(st->buf[3 - 2], st->buf[3 - 3]);
560 toggle = 0; 560 toggle = 0;
561 break; 561 break;
562 562
563 default: 563 default:
564 /* RC-5 protocol changes toggle bit on new keypress */ 564 /* RC-5 protocol changes toggle bit on new keypress */
565 protocol = RC_TYPE_RC5; 565 protocol = RC_PROTO_RC5;
566 scancode = RC_SCANCODE_RC5(st->buf[3 - 2], st->buf[3 - 3]); 566 scancode = RC_SCANCODE_RC5(st->buf[3 - 2], st->buf[3 - 3]);
567 toggle = st->buf[3 - 1]; 567 toggle = st->buf[3 - 1];
568 break; 568 break;
@@ -3909,9 +3909,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
3909 .rc_interval = DEFAULT_RC_INTERVAL, 3909 .rc_interval = DEFAULT_RC_INTERVAL,
3910 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 3910 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3911 .rc_query = dib0700_rc_query_old_firmware, 3911 .rc_query = dib0700_rc_query_old_firmware,
3912 .allowed_protos = RC_BIT_RC5 | 3912 .allowed_protos = RC_PROTO_BIT_RC5 |
3913 RC_BIT_RC6_MCE | 3913 RC_PROTO_BIT_RC6_MCE |
3914 RC_BIT_NEC, 3914 RC_PROTO_BIT_NEC,
3915 .change_protocol = dib0700_change_protocol, 3915 .change_protocol = dib0700_change_protocol,
3916 }, 3916 },
3917 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 3917 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -3949,9 +3949,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
3949 .rc_interval = DEFAULT_RC_INTERVAL, 3949 .rc_interval = DEFAULT_RC_INTERVAL,
3950 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 3950 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
3951 .rc_query = dib0700_rc_query_old_firmware, 3951 .rc_query = dib0700_rc_query_old_firmware,
3952 .allowed_protos = RC_BIT_RC5 | 3952 .allowed_protos = RC_PROTO_BIT_RC5 |
3953 RC_BIT_RC6_MCE | 3953 RC_PROTO_BIT_RC6_MCE |
3954 RC_BIT_NEC, 3954 RC_PROTO_BIT_NEC,
3955 .change_protocol = dib0700_change_protocol, 3955 .change_protocol = dib0700_change_protocol,
3956 }, 3956 },
3957 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 3957 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4014,9 +4014,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4014 .rc_interval = DEFAULT_RC_INTERVAL, 4014 .rc_interval = DEFAULT_RC_INTERVAL,
4015 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4015 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4016 .rc_query = dib0700_rc_query_old_firmware, 4016 .rc_query = dib0700_rc_query_old_firmware,
4017 .allowed_protos = RC_BIT_RC5 | 4017 .allowed_protos = RC_PROTO_BIT_RC5 |
4018 RC_BIT_RC6_MCE | 4018 RC_PROTO_BIT_RC6_MCE |
4019 RC_BIT_NEC, 4019 RC_PROTO_BIT_NEC,
4020 .change_protocol = dib0700_change_protocol, 4020 .change_protocol = dib0700_change_protocol,
4021 }, 4021 },
4022 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4022 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4059,9 +4059,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4059 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4059 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4060 .module_name = "dib0700", 4060 .module_name = "dib0700",
4061 .rc_query = dib0700_rc_query_old_firmware, 4061 .rc_query = dib0700_rc_query_old_firmware,
4062 .allowed_protos = RC_BIT_RC5 | 4062 .allowed_protos = RC_PROTO_BIT_RC5 |
4063 RC_BIT_RC6_MCE | 4063 RC_PROTO_BIT_RC6_MCE |
4064 RC_BIT_NEC, 4064 RC_PROTO_BIT_NEC,
4065 .change_protocol = dib0700_change_protocol, 4065 .change_protocol = dib0700_change_protocol,
4066 }, 4066 },
4067 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4067 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4140,9 +4140,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4140 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4140 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4141 .module_name = "dib0700", 4141 .module_name = "dib0700",
4142 .rc_query = dib0700_rc_query_old_firmware, 4142 .rc_query = dib0700_rc_query_old_firmware,
4143 .allowed_protos = RC_BIT_RC5 | 4143 .allowed_protos = RC_PROTO_BIT_RC5 |
4144 RC_BIT_RC6_MCE | 4144 RC_PROTO_BIT_RC6_MCE |
4145 RC_BIT_NEC, 4145 RC_PROTO_BIT_NEC,
4146 .change_protocol = dib0700_change_protocol, 4146 .change_protocol = dib0700_change_protocol,
4147 }, 4147 },
4148 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4148 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4185,9 +4185,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4185 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4185 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4186 .module_name = "dib0700", 4186 .module_name = "dib0700",
4187 .rc_query = dib0700_rc_query_old_firmware, 4187 .rc_query = dib0700_rc_query_old_firmware,
4188 .allowed_protos = RC_BIT_RC5 | 4188 .allowed_protos = RC_PROTO_BIT_RC5 |
4189 RC_BIT_RC6_MCE | 4189 RC_PROTO_BIT_RC6_MCE |
4190 RC_BIT_NEC, 4190 RC_PROTO_BIT_NEC,
4191 .change_protocol = dib0700_change_protocol, 4191 .change_protocol = dib0700_change_protocol,
4192 }, 4192 },
4193 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4193 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4242,9 +4242,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4242 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4242 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4243 .module_name = "dib0700", 4243 .module_name = "dib0700",
4244 .rc_query = dib0700_rc_query_old_firmware, 4244 .rc_query = dib0700_rc_query_old_firmware,
4245 .allowed_protos = RC_BIT_RC5 | 4245 .allowed_protos = RC_PROTO_BIT_RC5 |
4246 RC_BIT_RC6_MCE | 4246 RC_PROTO_BIT_RC6_MCE |
4247 RC_BIT_NEC, 4247 RC_PROTO_BIT_NEC,
4248 .change_protocol = dib0700_change_protocol, 4248 .change_protocol = dib0700_change_protocol,
4249 }, 4249 },
4250 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4250 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4308,9 +4308,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4308 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4308 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4309 .module_name = "dib0700", 4309 .module_name = "dib0700",
4310 .rc_query = dib0700_rc_query_old_firmware, 4310 .rc_query = dib0700_rc_query_old_firmware,
4311 .allowed_protos = RC_BIT_RC5 | 4311 .allowed_protos = RC_PROTO_BIT_RC5 |
4312 RC_BIT_RC6_MCE | 4312 RC_PROTO_BIT_RC6_MCE |
4313 RC_BIT_NEC, 4313 RC_PROTO_BIT_NEC,
4314 .change_protocol = dib0700_change_protocol, 4314 .change_protocol = dib0700_change_protocol,
4315 }, 4315 },
4316 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4316 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4357,9 +4357,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4357 .rc_codes = RC_MAP_DIB0700_NEC_TABLE, 4357 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
4358 .module_name = "dib0700", 4358 .module_name = "dib0700",
4359 .rc_query = dib0700_rc_query_old_firmware, 4359 .rc_query = dib0700_rc_query_old_firmware,
4360 .allowed_protos = RC_BIT_RC5 | 4360 .allowed_protos = RC_PROTO_BIT_RC5 |
4361 RC_BIT_RC6_MCE | 4361 RC_PROTO_BIT_RC6_MCE |
4362 RC_BIT_NEC, 4362 RC_PROTO_BIT_NEC,
4363 .change_protocol = dib0700_change_protocol, 4363 .change_protocol = dib0700_change_protocol,
4364 }, 4364 },
4365 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4365 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4430,9 +4430,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4430 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4430 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4431 .module_name = "dib0700", 4431 .module_name = "dib0700",
4432 .rc_query = dib0700_rc_query_old_firmware, 4432 .rc_query = dib0700_rc_query_old_firmware,
4433 .allowed_protos = RC_BIT_RC5 | 4433 .allowed_protos = RC_PROTO_BIT_RC5 |
4434 RC_BIT_RC6_MCE | 4434 RC_PROTO_BIT_RC6_MCE |
4435 RC_BIT_NEC, 4435 RC_PROTO_BIT_NEC,
4436 .change_protocol = dib0700_change_protocol, 4436 .change_protocol = dib0700_change_protocol,
4437 }, 4437 },
4438 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4438 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4466,9 +4466,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4466 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4466 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4467 .module_name = "dib0700", 4467 .module_name = "dib0700",
4468 .rc_query = dib0700_rc_query_old_firmware, 4468 .rc_query = dib0700_rc_query_old_firmware,
4469 .allowed_protos = RC_BIT_RC5 | 4469 .allowed_protos = RC_PROTO_BIT_RC5 |
4470 RC_BIT_RC6_MCE | 4470 RC_PROTO_BIT_RC6_MCE |
4471 RC_BIT_NEC, 4471 RC_PROTO_BIT_NEC,
4472 .change_protocol = dib0700_change_protocol, 4472 .change_protocol = dib0700_change_protocol,
4473 }, 4473 },
4474 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4474 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4542,9 +4542,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4542 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4542 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4543 .module_name = "dib0700", 4543 .module_name = "dib0700",
4544 .rc_query = dib0700_rc_query_old_firmware, 4544 .rc_query = dib0700_rc_query_old_firmware,
4545 .allowed_protos = RC_BIT_RC5 | 4545 .allowed_protos = RC_PROTO_BIT_RC5 |
4546 RC_BIT_RC6_MCE | 4546 RC_PROTO_BIT_RC6_MCE |
4547 RC_BIT_NEC, 4547 RC_PROTO_BIT_NEC,
4548 .change_protocol = dib0700_change_protocol, 4548 .change_protocol = dib0700_change_protocol,
4549 }, 4549 },
4550 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4550 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4586,9 +4586,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4586 .rc_codes = RC_MAP_DIB0700_NEC_TABLE, 4586 .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
4587 .module_name = "dib0700", 4587 .module_name = "dib0700",
4588 .rc_query = dib0700_rc_query_old_firmware, 4588 .rc_query = dib0700_rc_query_old_firmware,
4589 .allowed_protos = RC_BIT_RC5 | 4589 .allowed_protos = RC_PROTO_BIT_RC5 |
4590 RC_BIT_RC6_MCE | 4590 RC_PROTO_BIT_RC6_MCE |
4591 RC_BIT_NEC, 4591 RC_PROTO_BIT_NEC,
4592 .change_protocol = dib0700_change_protocol, 4592 .change_protocol = dib0700_change_protocol,
4593 }, 4593 },
4594 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4594 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4635,9 +4635,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4635 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4635 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4636 .module_name = "dib0700", 4636 .module_name = "dib0700",
4637 .rc_query = dib0700_rc_query_old_firmware, 4637 .rc_query = dib0700_rc_query_old_firmware,
4638 .allowed_protos = RC_BIT_RC5 | 4638 .allowed_protos = RC_PROTO_BIT_RC5 |
4639 RC_BIT_RC6_MCE | 4639 RC_PROTO_BIT_RC6_MCE |
4640 RC_BIT_NEC, 4640 RC_PROTO_BIT_NEC,
4641 .change_protocol = dib0700_change_protocol, 4641 .change_protocol = dib0700_change_protocol,
4642 }, 4642 },
4643 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4643 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4672,9 +4672,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4672 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4672 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4673 .module_name = "dib0700", 4673 .module_name = "dib0700",
4674 .rc_query = dib0700_rc_query_old_firmware, 4674 .rc_query = dib0700_rc_query_old_firmware,
4675 .allowed_protos = RC_BIT_RC5 | 4675 .allowed_protos = RC_PROTO_BIT_RC5 |
4676 RC_BIT_RC6_MCE | 4676 RC_PROTO_BIT_RC6_MCE |
4677 RC_BIT_NEC, 4677 RC_PROTO_BIT_NEC,
4678 .change_protocol = dib0700_change_protocol, 4678 .change_protocol = dib0700_change_protocol,
4679 }, 4679 },
4680 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4680 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4709,9 +4709,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4709 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4709 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4710 .module_name = "dib0700", 4710 .module_name = "dib0700",
4711 .rc_query = dib0700_rc_query_old_firmware, 4711 .rc_query = dib0700_rc_query_old_firmware,
4712 .allowed_protos = RC_BIT_RC5 | 4712 .allowed_protos = RC_PROTO_BIT_RC5 |
4713 RC_BIT_RC6_MCE | 4713 RC_PROTO_BIT_RC6_MCE |
4714 RC_BIT_NEC, 4714 RC_PROTO_BIT_NEC,
4715 .change_protocol = dib0700_change_protocol, 4715 .change_protocol = dib0700_change_protocol,
4716 }, 4716 },
4717 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4717 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4746,9 +4746,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4746 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4746 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4747 .module_name = "dib0700", 4747 .module_name = "dib0700",
4748 .rc_query = dib0700_rc_query_old_firmware, 4748 .rc_query = dib0700_rc_query_old_firmware,
4749 .allowed_protos = RC_BIT_RC5 | 4749 .allowed_protos = RC_PROTO_BIT_RC5 |
4750 RC_BIT_RC6_MCE | 4750 RC_PROTO_BIT_RC6_MCE |
4751 RC_BIT_NEC, 4751 RC_PROTO_BIT_NEC,
4752 .change_protocol = dib0700_change_protocol, 4752 .change_protocol = dib0700_change_protocol,
4753 }, 4753 },
4754 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4754 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4783,9 +4783,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4783 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4783 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4784 .module_name = "dib0700", 4784 .module_name = "dib0700",
4785 .rc_query = dib0700_rc_query_old_firmware, 4785 .rc_query = dib0700_rc_query_old_firmware,
4786 .allowed_protos = RC_BIT_RC5 | 4786 .allowed_protos = RC_PROTO_BIT_RC5 |
4787 RC_BIT_RC6_MCE | 4787 RC_PROTO_BIT_RC6_MCE |
4788 RC_BIT_NEC, 4788 RC_PROTO_BIT_NEC,
4789 .change_protocol = dib0700_change_protocol, 4789 .change_protocol = dib0700_change_protocol,
4790 }, 4790 },
4791 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4791 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4820,9 +4820,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4820 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4820 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4821 .module_name = "dib0700", 4821 .module_name = "dib0700",
4822 .rc_query = dib0700_rc_query_old_firmware, 4822 .rc_query = dib0700_rc_query_old_firmware,
4823 .allowed_protos = RC_BIT_RC5 | 4823 .allowed_protos = RC_PROTO_BIT_RC5 |
4824 RC_BIT_RC6_MCE | 4824 RC_PROTO_BIT_RC6_MCE |
4825 RC_BIT_NEC, 4825 RC_PROTO_BIT_NEC,
4826 .change_protocol = dib0700_change_protocol, 4826 .change_protocol = dib0700_change_protocol,
4827 }, 4827 },
4828 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4828 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4871,9 +4871,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4871 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4871 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4872 .module_name = "dib0700", 4872 .module_name = "dib0700",
4873 .rc_query = dib0700_rc_query_old_firmware, 4873 .rc_query = dib0700_rc_query_old_firmware,
4874 .allowed_protos = RC_BIT_RC5 | 4874 .allowed_protos = RC_PROTO_BIT_RC5 |
4875 RC_BIT_RC6_MCE | 4875 RC_PROTO_BIT_RC6_MCE |
4876 RC_BIT_NEC, 4876 RC_PROTO_BIT_NEC,
4877 .change_protocol = dib0700_change_protocol, 4877 .change_protocol = dib0700_change_protocol,
4878 }, 4878 },
4879 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4879 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4906,9 +4906,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4906 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4906 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4907 .module_name = "dib0700", 4907 .module_name = "dib0700",
4908 .rc_query = dib0700_rc_query_old_firmware, 4908 .rc_query = dib0700_rc_query_old_firmware,
4909 .allowed_protos = RC_BIT_RC5 | 4909 .allowed_protos = RC_PROTO_BIT_RC5 |
4910 RC_BIT_RC6_MCE | 4910 RC_PROTO_BIT_RC6_MCE |
4911 RC_BIT_NEC, 4911 RC_PROTO_BIT_NEC,
4912 .change_protocol = dib0700_change_protocol, 4912 .change_protocol = dib0700_change_protocol,
4913 }, 4913 },
4914 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4914 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4943,9 +4943,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4943 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4943 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4944 .module_name = "dib0700", 4944 .module_name = "dib0700",
4945 .rc_query = dib0700_rc_query_old_firmware, 4945 .rc_query = dib0700_rc_query_old_firmware,
4946 .allowed_protos = RC_BIT_RC5 | 4946 .allowed_protos = RC_PROTO_BIT_RC5 |
4947 RC_BIT_RC6_MCE | 4947 RC_PROTO_BIT_RC6_MCE |
4948 RC_BIT_NEC, 4948 RC_PROTO_BIT_NEC,
4949 .change_protocol = dib0700_change_protocol, 4949 .change_protocol = dib0700_change_protocol,
4950 }, 4950 },
4951 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4951 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -4981,9 +4981,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
4981 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 4981 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
4982 .module_name = "dib0700", 4982 .module_name = "dib0700",
4983 .rc_query = dib0700_rc_query_old_firmware, 4983 .rc_query = dib0700_rc_query_old_firmware,
4984 .allowed_protos = RC_BIT_RC5 | 4984 .allowed_protos = RC_PROTO_BIT_RC5 |
4985 RC_BIT_RC6_MCE | 4985 RC_PROTO_BIT_RC6_MCE |
4986 RC_BIT_NEC, 4986 RC_PROTO_BIT_NEC,
4987 .change_protocol = dib0700_change_protocol, 4987 .change_protocol = dib0700_change_protocol,
4988 }, 4988 },
4989 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, 4989 }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
@@ -5035,9 +5035,9 @@ struct dvb_usb_device_properties dib0700_devices[] = {
5035 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 5035 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
5036 .module_name = "dib0700", 5036 .module_name = "dib0700",
5037 .rc_query = dib0700_rc_query_old_firmware, 5037 .rc_query = dib0700_rc_query_old_firmware,
5038 .allowed_protos = RC_BIT_RC5 | 5038 .allowed_protos = RC_PROTO_BIT_RC5 |
5039 RC_BIT_RC6_MCE | 5039 RC_PROTO_BIT_RC6_MCE |
5040 RC_BIT_NEC, 5040 RC_PROTO_BIT_NEC,
5041 .change_protocol = dib0700_change_protocol, 5041 .change_protocol = dib0700_change_protocol,
5042 }, 5042 },
5043 }, 5043 },
diff --git a/drivers/media/usb/dvb-usb/dtt200u.c b/drivers/media/usb/dvb-usb/dtt200u.c
index fcbff7fb0c4e..512370786696 100644
--- a/drivers/media/usb/dvb-usb/dtt200u.c
+++ b/drivers/media/usb/dvb-usb/dtt200u.c
@@ -100,14 +100,14 @@ static int dtt200u_rc_query(struct dvb_usb_device *d)
100 goto ret; 100 goto ret;
101 101
102 if (st->data[0] == 1) { 102 if (st->data[0] == 1) {
103 enum rc_type proto = RC_TYPE_NEC; 103 enum rc_proto proto = RC_PROTO_NEC;
104 104
105 scancode = st->data[1]; 105 scancode = st->data[1];
106 if ((u8) ~st->data[1] != st->data[2]) { 106 if ((u8) ~st->data[1] != st->data[2]) {
107 /* Extended NEC */ 107 /* Extended NEC */
108 scancode = scancode << 8; 108 scancode = scancode << 8;
109 scancode |= st->data[2]; 109 scancode |= st->data[2];
110 proto = RC_TYPE_NECX; 110 proto = RC_PROTO_NECX;
111 } 111 }
112 scancode = scancode << 8; 112 scancode = scancode << 8;
113 scancode |= st->data[3]; 113 scancode |= st->data[3];
@@ -213,7 +213,7 @@ static struct dvb_usb_device_properties dtt200u_properties = {
213 .rc_interval = 300, 213 .rc_interval = 300,
214 .rc_codes = RC_MAP_DTT200U, 214 .rc_codes = RC_MAP_DTT200U,
215 .rc_query = dtt200u_rc_query, 215 .rc_query = dtt200u_rc_query,
216 .allowed_protos = RC_BIT_NEC, 216 .allowed_protos = RC_PROTO_BIT_NEC,
217 }, 217 },
218 218
219 .generic_bulk_ctrl_endpoint = 0x01, 219 .generic_bulk_ctrl_endpoint = 0x01,
@@ -265,7 +265,7 @@ static struct dvb_usb_device_properties wt220u_properties = {
265 .rc_interval = 300, 265 .rc_interval = 300,
266 .rc_codes = RC_MAP_DTT200U, 266 .rc_codes = RC_MAP_DTT200U,
267 .rc_query = dtt200u_rc_query, 267 .rc_query = dtt200u_rc_query,
268 .allowed_protos = RC_BIT_NEC, 268 .allowed_protos = RC_PROTO_BIT_NEC,
269 }, 269 },
270 270
271 .generic_bulk_ctrl_endpoint = 0x01, 271 .generic_bulk_ctrl_endpoint = 0x01,
@@ -317,7 +317,7 @@ static struct dvb_usb_device_properties wt220u_fc_properties = {
317 .rc_interval = 300, 317 .rc_interval = 300,
318 .rc_codes = RC_MAP_DTT200U, 318 .rc_codes = RC_MAP_DTT200U,
319 .rc_query = dtt200u_rc_query, 319 .rc_query = dtt200u_rc_query,
320 .allowed_protos = RC_BIT_NEC, 320 .allowed_protos = RC_PROTO_BIT_NEC,
321 }, 321 },
322 322
323 .generic_bulk_ctrl_endpoint = 0x01, 323 .generic_bulk_ctrl_endpoint = 0x01,
@@ -369,7 +369,7 @@ static struct dvb_usb_device_properties wt220u_zl0353_properties = {
369 .rc_interval = 300, 369 .rc_interval = 300,
370 .rc_codes = RC_MAP_DTT200U, 370 .rc_codes = RC_MAP_DTT200U,
371 .rc_query = dtt200u_rc_query, 371 .rc_query = dtt200u_rc_query,
372 .allowed_protos = RC_BIT_NEC, 372 .allowed_protos = RC_PROTO_BIT_NEC,
373 }, 373 },
374 374
375 .generic_bulk_ctrl_endpoint = 0x01, 375 .generic_bulk_ctrl_endpoint = 0x01,
diff --git a/drivers/media/usb/dvb-usb/dvb-usb-remote.c b/drivers/media/usb/dvb-usb/dvb-usb-remote.c
index f05f1fc80729..0b03f9bd9c26 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/usb/dvb-usb/dvb-usb-remote.c
@@ -279,7 +279,7 @@ static int rc_core_dvb_usb_remote_init(struct dvb_usb_device *d)
279 dev->change_protocol = d->props.rc.core.change_protocol; 279 dev->change_protocol = d->props.rc.core.change_protocol;
280 dev->allowed_protocols = d->props.rc.core.allowed_protos; 280 dev->allowed_protocols = d->props.rc.core.allowed_protos;
281 usb_to_input_id(d->udev, &dev->input_id); 281 usb_to_input_id(d->udev, &dev->input_id);
282 dev->input_name = "IR-receiver inside an USB DVB receiver"; 282 dev->device_name = "IR-receiver inside an USB DVB receiver";
283 dev->input_phys = d->rc_phys; 283 dev->input_phys = d->rc_phys;
284 dev->dev.parent = &d->udev->dev; 284 dev->dev.parent = &d->udev->dev;
285 dev->priv = d; 285 dev->priv = d;
diff --git a/drivers/media/usb/dvb-usb/dvb-usb.h b/drivers/media/usb/dvb-usb/dvb-usb.h
index 67f898b6f6d0..72468fdffa18 100644
--- a/drivers/media/usb/dvb-usb/dvb-usb.h
+++ b/drivers/media/usb/dvb-usb/dvb-usb.h
@@ -202,7 +202,7 @@ struct dvb_rc {
202 u64 protocol; 202 u64 protocol;
203 u64 allowed_protos; 203 u64 allowed_protos;
204 enum rc_driver_type driver_type; 204 enum rc_driver_type driver_type;
205 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); 205 int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto);
206 char *module_name; 206 char *module_name;
207 int (*rc_query) (struct dvb_usb_device *d); 207 int (*rc_query) (struct dvb_usb_device *d);
208 int rc_interval; 208 int rc_interval;
diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
index 57b187240110..b421329b21fa 100644
--- a/drivers/media/usb/dvb-usb/dw2102.c
+++ b/drivers/media/usb/dvb-usb/dw2102.c
@@ -1671,7 +1671,7 @@ static int dw2102_rc_query(struct dvb_usb_device *d)
1671 if (msg.buf[0] != 0xff) { 1671 if (msg.buf[0] != 0xff) {
1672 deb_rc("%s: rc code: %x, %x\n", 1672 deb_rc("%s: rc code: %x, %x\n",
1673 __func__, key[0], key[1]); 1673 __func__, key[0], key[1]);
1674 rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, key[0], 0); 1674 rc_keydown(d->rc_dev, RC_PROTO_UNKNOWN, key[0], 0);
1675 } 1675 }
1676 } 1676 }
1677 1677
@@ -1692,7 +1692,8 @@ static int prof_rc_query(struct dvb_usb_device *d)
1692 if (msg.buf[0] != 0xff) { 1692 if (msg.buf[0] != 0xff) {
1693 deb_rc("%s: rc code: %x, %x\n", 1693 deb_rc("%s: rc code: %x, %x\n",
1694 __func__, key[0], key[1]); 1694 __func__, key[0], key[1]);
1695 rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, key[0]^0xff, 0); 1695 rc_keydown(d->rc_dev, RC_PROTO_UNKNOWN, key[0] ^ 0xff,
1696 0);
1696 } 1697 }
1697 } 1698 }
1698 1699
@@ -1713,7 +1714,7 @@ static int su3000_rc_query(struct dvb_usb_device *d)
1713 if (msg.buf[0] != 0xff) { 1714 if (msg.buf[0] != 0xff) {
1714 deb_rc("%s: rc code: %x, %x\n", 1715 deb_rc("%s: rc code: %x, %x\n",
1715 __func__, key[0], key[1]); 1716 __func__, key[0], key[1]);
1716 rc_keydown(d->rc_dev, RC_TYPE_RC5, 1717 rc_keydown(d->rc_dev, RC_PROTO_RC5,
1717 RC_SCANCODE_RC5(key[1], key[0]), 0); 1718 RC_SCANCODE_RC5(key[1], key[0]), 0);
1718 } 1719 }
1719 } 1720 }
@@ -1912,7 +1913,7 @@ static struct dvb_usb_device_properties dw2102_properties = {
1912 .rc_interval = 150, 1913 .rc_interval = 150,
1913 .rc_codes = RC_MAP_DM1105_NEC, 1914 .rc_codes = RC_MAP_DM1105_NEC,
1914 .module_name = "dw2102", 1915 .module_name = "dw2102",
1915 .allowed_protos = RC_BIT_NEC, 1916 .allowed_protos = RC_PROTO_BIT_NEC,
1916 .rc_query = dw2102_rc_query, 1917 .rc_query = dw2102_rc_query,
1917 }, 1918 },
1918 1919
@@ -1967,7 +1968,7 @@ static struct dvb_usb_device_properties dw2104_properties = {
1967 .rc_interval = 150, 1968 .rc_interval = 150,
1968 .rc_codes = RC_MAP_DM1105_NEC, 1969 .rc_codes = RC_MAP_DM1105_NEC,
1969 .module_name = "dw2102", 1970 .module_name = "dw2102",
1970 .allowed_protos = RC_BIT_NEC, 1971 .allowed_protos = RC_PROTO_BIT_NEC,
1971 .rc_query = dw2102_rc_query, 1972 .rc_query = dw2102_rc_query,
1972 }, 1973 },
1973 1974
@@ -2018,7 +2019,7 @@ static struct dvb_usb_device_properties dw3101_properties = {
2018 .rc_interval = 150, 2019 .rc_interval = 150,
2019 .rc_codes = RC_MAP_DM1105_NEC, 2020 .rc_codes = RC_MAP_DM1105_NEC,
2020 .module_name = "dw2102", 2021 .module_name = "dw2102",
2021 .allowed_protos = RC_BIT_NEC, 2022 .allowed_protos = RC_PROTO_BIT_NEC,
2022 .rc_query = dw2102_rc_query, 2023 .rc_query = dw2102_rc_query,
2023 }, 2024 },
2024 2025
@@ -2067,7 +2068,7 @@ static struct dvb_usb_device_properties s6x0_properties = {
2067 .rc_interval = 150, 2068 .rc_interval = 150,
2068 .rc_codes = RC_MAP_TEVII_NEC, 2069 .rc_codes = RC_MAP_TEVII_NEC,
2069 .module_name = "dw2102", 2070 .module_name = "dw2102",
2070 .allowed_protos = RC_BIT_NEC, 2071 .allowed_protos = RC_PROTO_BIT_NEC,
2071 .rc_query = dw2102_rc_query, 2072 .rc_query = dw2102_rc_query,
2072 }, 2073 },
2073 2074
@@ -2103,46 +2104,46 @@ static struct dvb_usb_device_properties s6x0_properties = {
2103}; 2104};
2104 2105
2105static struct dvb_usb_device_properties *p1100; 2106static struct dvb_usb_device_properties *p1100;
2106static struct dvb_usb_device_description d1100 = { 2107static const struct dvb_usb_device_description d1100 = {
2107 "Prof 1100 USB ", 2108 "Prof 1100 USB ",
2108 {&dw2102_table[PROF_1100], NULL}, 2109 {&dw2102_table[PROF_1100], NULL},
2109 {NULL}, 2110 {NULL},
2110}; 2111};
2111 2112
2112static struct dvb_usb_device_properties *s660; 2113static struct dvb_usb_device_properties *s660;
2113static struct dvb_usb_device_description d660 = { 2114static const struct dvb_usb_device_description d660 = {
2114 "TeVii S660 USB", 2115 "TeVii S660 USB",
2115 {&dw2102_table[TEVII_S660], NULL}, 2116 {&dw2102_table[TEVII_S660], NULL},
2116 {NULL}, 2117 {NULL},
2117}; 2118};
2118 2119
2119static struct dvb_usb_device_description d480_1 = { 2120static const struct dvb_usb_device_description d480_1 = {
2120 "TeVii S480.1 USB", 2121 "TeVii S480.1 USB",
2121 {&dw2102_table[TEVII_S480_1], NULL}, 2122 {&dw2102_table[TEVII_S480_1], NULL},
2122 {NULL}, 2123 {NULL},
2123}; 2124};
2124 2125
2125static struct dvb_usb_device_description d480_2 = { 2126static const struct dvb_usb_device_description d480_2 = {
2126 "TeVii S480.2 USB", 2127 "TeVii S480.2 USB",
2127 {&dw2102_table[TEVII_S480_2], NULL}, 2128 {&dw2102_table[TEVII_S480_2], NULL},
2128 {NULL}, 2129 {NULL},
2129}; 2130};
2130 2131
2131static struct dvb_usb_device_properties *p7500; 2132static struct dvb_usb_device_properties *p7500;
2132static struct dvb_usb_device_description d7500 = { 2133static const struct dvb_usb_device_description d7500 = {
2133 "Prof 7500 USB DVB-S2", 2134 "Prof 7500 USB DVB-S2",
2134 {&dw2102_table[PROF_7500], NULL}, 2135 {&dw2102_table[PROF_7500], NULL},
2135 {NULL}, 2136 {NULL},
2136}; 2137};
2137 2138
2138static struct dvb_usb_device_properties *s421; 2139static struct dvb_usb_device_properties *s421;
2139static struct dvb_usb_device_description d421 = { 2140static const struct dvb_usb_device_description d421 = {
2140 "TeVii S421 PCI", 2141 "TeVii S421 PCI",
2141 {&dw2102_table[TEVII_S421], NULL}, 2142 {&dw2102_table[TEVII_S421], NULL},
2142 {NULL}, 2143 {NULL},
2143}; 2144};
2144 2145
2145static struct dvb_usb_device_description d632 = { 2146static const struct dvb_usb_device_description d632 = {
2146 "TeVii S632 USB", 2147 "TeVii S632 USB",
2147 {&dw2102_table[TEVII_S632], NULL}, 2148 {&dw2102_table[TEVII_S632], NULL},
2148 {NULL}, 2149 {NULL},
@@ -2161,7 +2162,7 @@ static struct dvb_usb_device_properties su3000_properties = {
2161 .rc_interval = 150, 2162 .rc_interval = 150,
2162 .rc_codes = RC_MAP_SU3000, 2163 .rc_codes = RC_MAP_SU3000,
2163 .module_name = "dw2102", 2164 .module_name = "dw2102",
2164 .allowed_protos = RC_BIT_RC5, 2165 .allowed_protos = RC_PROTO_BIT_RC5,
2165 .rc_query = su3000_rc_query, 2166 .rc_query = su3000_rc_query,
2166 }, 2167 },
2167 2168
@@ -2230,7 +2231,7 @@ static struct dvb_usb_device_properties t220_properties = {
2230 .rc_interval = 150, 2231 .rc_interval = 150,
2231 .rc_codes = RC_MAP_SU3000, 2232 .rc_codes = RC_MAP_SU3000,
2232 .module_name = "dw2102", 2233 .module_name = "dw2102",
2233 .allowed_protos = RC_BIT_RC5, 2234 .allowed_protos = RC_PROTO_BIT_RC5,
2234 .rc_query = su3000_rc_query, 2235 .rc_query = su3000_rc_query,
2235 }, 2236 },
2236 2237
@@ -2279,7 +2280,7 @@ static struct dvb_usb_device_properties tt_s2_4600_properties = {
2279 .rc_interval = 250, 2280 .rc_interval = 250,
2280 .rc_codes = RC_MAP_TT_1500, 2281 .rc_codes = RC_MAP_TT_1500,
2281 .module_name = "dw2102", 2282 .module_name = "dw2102",
2282 .allowed_protos = RC_BIT_RC5, 2283 .allowed_protos = RC_PROTO_BIT_RC5,
2283 .rc_query = su3000_rc_query, 2284 .rc_query = su3000_rc_query,
2284 }, 2285 },
2285 2286
@@ -2334,10 +2335,12 @@ static struct dvb_usb_device_properties tt_s2_4600_properties = {
2334static int dw2102_probe(struct usb_interface *intf, 2335static int dw2102_probe(struct usb_interface *intf,
2335 const struct usb_device_id *id) 2336 const struct usb_device_id *id)
2336{ 2337{
2338 int retval = -ENOMEM;
2337 p1100 = kmemdup(&s6x0_properties, 2339 p1100 = kmemdup(&s6x0_properties,
2338 sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 2340 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
2339 if (!p1100) 2341 if (!p1100)
2340 return -ENOMEM; 2342 goto err0;
2343
2341 /* copy default structure */ 2344 /* copy default structure */
2342 /* fill only different fields */ 2345 /* fill only different fields */
2343 p1100->firmware = P1100_FIRMWARE; 2346 p1100->firmware = P1100_FIRMWARE;
@@ -2348,10 +2351,9 @@ static int dw2102_probe(struct usb_interface *intf,
2348 2351
2349 s660 = kmemdup(&s6x0_properties, 2352 s660 = kmemdup(&s6x0_properties,
2350 sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 2353 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
2351 if (!s660) { 2354 if (!s660)
2352 kfree(p1100); 2355 goto err1;
2353 return -ENOMEM; 2356
2354 }
2355 s660->firmware = S660_FIRMWARE; 2357 s660->firmware = S660_FIRMWARE;
2356 s660->num_device_descs = 3; 2358 s660->num_device_descs = 3;
2357 s660->devices[0] = d660; 2359 s660->devices[0] = d660;
@@ -2361,11 +2363,9 @@ static int dw2102_probe(struct usb_interface *intf,
2361 2363
2362 p7500 = kmemdup(&s6x0_properties, 2364 p7500 = kmemdup(&s6x0_properties,
2363 sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 2365 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
2364 if (!p7500) { 2366 if (!p7500)
2365 kfree(p1100); 2367 goto err2;
2366 kfree(s660); 2368
2367 return -ENOMEM;
2368 }
2369 p7500->firmware = P7500_FIRMWARE; 2369 p7500->firmware = P7500_FIRMWARE;
2370 p7500->devices[0] = d7500; 2370 p7500->devices[0] = d7500;
2371 p7500->rc.core.rc_query = prof_rc_query; 2371 p7500->rc.core.rc_query = prof_rc_query;
@@ -2375,12 +2375,9 @@ static int dw2102_probe(struct usb_interface *intf,
2375 2375
2376 s421 = kmemdup(&su3000_properties, 2376 s421 = kmemdup(&su3000_properties,
2377 sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 2377 sizeof(struct dvb_usb_device_properties), GFP_KERNEL);
2378 if (!s421) { 2378 if (!s421)
2379 kfree(p1100); 2379 goto err3;
2380 kfree(s660); 2380
2381 kfree(p7500);
2382 return -ENOMEM;
2383 }
2384 s421->num_device_descs = 2; 2381 s421->num_device_descs = 2;
2385 s421->devices[0] = d421; 2382 s421->devices[0] = d421;
2386 s421->devices[1] = d632; 2383 s421->devices[1] = d632;
@@ -2410,7 +2407,16 @@ static int dw2102_probe(struct usb_interface *intf,
2410 THIS_MODULE, NULL, adapter_nr)) 2407 THIS_MODULE, NULL, adapter_nr))
2411 return 0; 2408 return 0;
2412 2409
2413 return -ENODEV; 2410 retval = -ENODEV;
2411 kfree(s421);
2412err3:
2413 kfree(p7500);
2414err2:
2415 kfree(s660);
2416err1:
2417 kfree(p1100);
2418err0:
2419 return retval;
2414} 2420}
2415 2421
2416static void dw2102_disconnect(struct usb_interface *intf) 2422static void dw2102_disconnect(struct usb_interface *intf)
diff --git a/drivers/media/usb/dvb-usb/m920x.c b/drivers/media/usb/dvb-usb/m920x.c
index 70672e1e5ec7..32081c2ce0da 100644
--- a/drivers/media/usb/dvb-usb/m920x.c
+++ b/drivers/media/usb/dvb-usb/m920x.c
@@ -241,7 +241,7 @@ static int m920x_rc_core_query(struct dvb_usb_device *d)
241 else if (state == REMOTE_KEY_REPEAT) 241 else if (state == REMOTE_KEY_REPEAT)
242 rc_repeat(d->rc_dev); 242 rc_repeat(d->rc_dev);
243 else 243 else
244 rc_keydown(d->rc_dev, RC_TYPE_UNKNOWN, rc_state[1], 0); 244 rc_keydown(d->rc_dev, RC_PROTO_UNKNOWN, rc_state[1], 0);
245 245
246out: 246out:
247 kfree(rc_state); 247 kfree(rc_state);
@@ -1208,7 +1208,7 @@ static struct dvb_usb_device_properties vp7049_properties = {
1208 .rc_interval = 150, 1208 .rc_interval = 150,
1209 .rc_codes = RC_MAP_TWINHAN_VP1027_DVBS, 1209 .rc_codes = RC_MAP_TWINHAN_VP1027_DVBS,
1210 .rc_query = m920x_rc_core_query, 1210 .rc_query = m920x_rc_core_query,
1211 .allowed_protos = RC_BIT_UNKNOWN, 1211 .allowed_protos = RC_PROTO_BIT_UNKNOWN,
1212 }, 1212 },
1213 1213
1214 .size_of_priv = sizeof(struct m920x_state), 1214 .size_of_priv = sizeof(struct m920x_state),
diff --git a/drivers/media/usb/dvb-usb/pctv452e.c b/drivers/media/usb/dvb-usb/pctv452e.c
index d54ebe7e0215..601ade7ca48d 100644
--- a/drivers/media/usb/dvb-usb/pctv452e.c
+++ b/drivers/media/usb/dvb-usb/pctv452e.c
@@ -600,7 +600,7 @@ static int pctv452e_rc_query(struct dvb_usb_device *d)
600 info("%s: cmd=0x%02x sys=0x%02x\n", 600 info("%s: cmd=0x%02x sys=0x%02x\n",
601 __func__, rx[6], rx[7]); 601 __func__, rx[6], rx[7]);
602 602
603 rc_keydown(d->rc_dev, RC_TYPE_RC5, state->last_rc_key, 0); 603 rc_keydown(d->rc_dev, RC_PROTO_RC5, state->last_rc_key, 0);
604 } else if (state->last_rc_key) { 604 } else if (state->last_rc_key) {
605 rc_keyup(d->rc_dev); 605 rc_keyup(d->rc_dev);
606 state->last_rc_key = 0; 606 state->last_rc_key = 0;
@@ -958,7 +958,7 @@ static struct dvb_usb_device_properties pctv452e_properties = {
958 958
959 .rc.core = { 959 .rc.core = {
960 .rc_codes = RC_MAP_DIB0700_RC5_TABLE, 960 .rc_codes = RC_MAP_DIB0700_RC5_TABLE,
961 .allowed_protos = RC_BIT_RC5, 961 .allowed_protos = RC_PROTO_BIT_RC5,
962 .rc_query = pctv452e_rc_query, 962 .rc_query = pctv452e_rc_query,
963 .rc_interval = 100, 963 .rc_interval = 100,
964 }, 964 },
@@ -1011,7 +1011,7 @@ static struct dvb_usb_device_properties tt_connect_s2_3600_properties = {
1011 1011
1012 .rc.core = { 1012 .rc.core = {
1013 .rc_codes = RC_MAP_TT_1500, 1013 .rc_codes = RC_MAP_TT_1500,
1014 .allowed_protos = RC_BIT_RC5, 1014 .allowed_protos = RC_PROTO_BIT_RC5,
1015 .rc_query = pctv452e_rc_query, 1015 .rc_query = pctv452e_rc_query,
1016 .rc_interval = 100, 1016 .rc_interval = 100,
1017 }, 1017 },
diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
index 9f7dd1afcb15..18d0f8f5283f 100644
--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
+++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
@@ -749,7 +749,7 @@ static struct dvb_usb_device_properties technisat_usb2_devices = {
749 .rc_codes = RC_MAP_TECHNISAT_USB2, 749 .rc_codes = RC_MAP_TECHNISAT_USB2,
750 .module_name = "technisat-usb2", 750 .module_name = "technisat-usb2",
751 .rc_query = technisat_usb2_rc_query, 751 .rc_query = technisat_usb2_rc_query,
752 .allowed_protos = RC_BIT_ALL_IR_DECODER, 752 .allowed_protos = RC_PROTO_BIT_ALL_IR_DECODER,
753 .driver_type = RC_DRIVER_IR_RAW, 753 .driver_type = RC_DRIVER_IR_RAW,
754 } 754 }
755}; 755};
diff --git a/drivers/media/usb/dvb-usb/ttusb2.c b/drivers/media/usb/dvb-usb/ttusb2.c
index 9e0d6a4166d2..e7020f245f53 100644
--- a/drivers/media/usb/dvb-usb/ttusb2.c
+++ b/drivers/media/usb/dvb-usb/ttusb2.c
@@ -459,7 +459,7 @@ static int tt3650_rc_query(struct dvb_usb_device *d)
459 /* got a "press" event */ 459 /* got a "press" event */
460 st->last_rc_key = RC_SCANCODE_RC5(rx[3], rx[2]); 460 st->last_rc_key = RC_SCANCODE_RC5(rx[3], rx[2]);
461 deb_info("%s: cmd=0x%02x sys=0x%02x\n", __func__, rx[2], rx[3]); 461 deb_info("%s: cmd=0x%02x sys=0x%02x\n", __func__, rx[2], rx[3]);
462 rc_keydown(d->rc_dev, RC_TYPE_RC5, st->last_rc_key, rx[1]); 462 rc_keydown(d->rc_dev, RC_PROTO_RC5, st->last_rc_key, rx[1]);
463 } else if (st->last_rc_key) { 463 } else if (st->last_rc_key) {
464 rc_keyup(d->rc_dev); 464 rc_keyup(d->rc_dev);
465 st->last_rc_key = 0; 465 st->last_rc_key = 0;
@@ -766,7 +766,7 @@ static struct dvb_usb_device_properties ttusb2_properties_ct3650 = {
766 .rc_interval = 150, /* Less than IR_KEYPRESS_TIMEOUT */ 766 .rc_interval = 150, /* Less than IR_KEYPRESS_TIMEOUT */
767 .rc_codes = RC_MAP_TT_1500, 767 .rc_codes = RC_MAP_TT_1500,
768 .rc_query = tt3650_rc_query, 768 .rc_query = tt3650_rc_query,
769 .allowed_protos = RC_BIT_RC5, 769 .allowed_protos = RC_PROTO_BIT_RC5,
770 }, 770 },
771 771
772 .num_adapters = 1, 772 .num_adapters = 1,
diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
index ffad7f1af166..4628d73f46f2 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -216,7 +216,7 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs,
216 return 0; 216 return 0;
217} 217}
218 218
219static struct snd_pcm_hardware snd_em28xx_hw_capture = { 219static const struct snd_pcm_hardware snd_em28xx_hw_capture = {
220 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER | 220 .info = SNDRV_PCM_INFO_BLOCK_TRANSFER |
221 SNDRV_PCM_INFO_MMAP | 221 SNDRV_PCM_INFO_MMAP |
222 SNDRV_PCM_INFO_INTERLEAVED | 222 SNDRV_PCM_INFO_INTERLEAVED |
@@ -564,7 +564,7 @@ static int em28xx_vol_get(struct snd_kcontrol *kcontrol,
564 val, (int)kcontrol->private_value); 564 val, (int)kcontrol->private_value);
565 565
566 value->value.integer.value[0] = 0x1f - (val & 0x1f); 566 value->value.integer.value[0] = 0x1f - (val & 0x1f);
567 value->value.integer.value[1] = 0x1f - ((val << 8) & 0x1f); 567 value->value.integer.value[1] = 0x1f - ((val >> 8) & 0x1f);
568 568
569 return 0; 569 return 0;
570} 570}
diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c
index 60b195c157b8..66c5012a628a 100644
--- a/drivers/media/usb/em28xx/em28xx-i2c.c
+++ b/drivers/media/usb/em28xx/em28xx-i2c.c
@@ -876,7 +876,7 @@ static const struct i2c_algorithm em28xx_algo = {
876 .functionality = functionality, 876 .functionality = functionality,
877}; 877};
878 878
879static struct i2c_adapter em28xx_adap_template = { 879static const struct i2c_adapter em28xx_adap_template = {
880 .owner = THIS_MODULE, 880 .owner = THIS_MODULE,
881 .name = "em28xx", 881 .name = "em28xx",
882 .algo = &em28xx_algo, 882 .algo = &em28xx_algo,
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
index ca9673917ad5..046223de1e91 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -55,7 +55,7 @@ struct em28xx_ir_poll_result {
55 unsigned int toggle_bit:1; 55 unsigned int toggle_bit:1;
56 unsigned int read_count:7; 56 unsigned int read_count:7;
57 57
58 enum rc_type protocol; 58 enum rc_proto protocol;
59 u32 scancode; 59 u32 scancode;
60}; 60};
61 61
@@ -70,11 +70,12 @@ struct em28xx_IR {
70 struct delayed_work work; 70 struct delayed_work work;
71 unsigned int full_code:1; 71 unsigned int full_code:1;
72 unsigned int last_readcount; 72 unsigned int last_readcount;
73 u64 rc_type; 73 u64 rc_proto;
74 74
75 struct i2c_client *i2c_client; 75 struct i2c_client *i2c_client;
76 76
77 int (*get_key_i2c)(struct i2c_client *ir, enum rc_type *protocol, u32 *scancode); 77 int (*get_key_i2c)(struct i2c_client *ir, enum rc_proto *protocol,
78 u32 *scancode);
78 int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *); 79 int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *);
79}; 80};
80 81
@@ -83,7 +84,7 @@ struct em28xx_IR {
83 **********************************************************/ 84 **********************************************************/
84 85
85static int em28xx_get_key_terratec(struct i2c_client *i2c_dev, 86static int em28xx_get_key_terratec(struct i2c_client *i2c_dev,
86 enum rc_type *protocol, u32 *scancode) 87 enum rc_proto *protocol, u32 *scancode)
87{ 88{
88 unsigned char b; 89 unsigned char b;
89 90
@@ -101,13 +102,13 @@ static int em28xx_get_key_terratec(struct i2c_client *i2c_dev,
101 /* keep old data */ 102 /* keep old data */
102 return 1; 103 return 1;
103 104
104 *protocol = RC_TYPE_UNKNOWN; 105 *protocol = RC_PROTO_UNKNOWN;
105 *scancode = b; 106 *scancode = b;
106 return 1; 107 return 1;
107} 108}
108 109
109static int em28xx_get_key_em_haup(struct i2c_client *i2c_dev, 110static int em28xx_get_key_em_haup(struct i2c_client *i2c_dev,
110 enum rc_type *protocol, u32 *scancode) 111 enum rc_proto *protocol, u32 *scancode)
111{ 112{
112 unsigned char buf[2]; 113 unsigned char buf[2];
113 int size; 114 int size;
@@ -131,13 +132,14 @@ static int em28xx_get_key_em_haup(struct i2c_client *i2c_dev,
131 * So, the code translation is not complete. Yet, it is enough to 132 * So, the code translation is not complete. Yet, it is enough to
132 * work with the provided RC5 IR. 133 * work with the provided RC5 IR.
133 */ 134 */
134 *protocol = RC_TYPE_RC5; 135 *protocol = RC_PROTO_RC5;
135 *scancode = (bitrev8(buf[1]) & 0x1f) << 8 | bitrev8(buf[0]) >> 2; 136 *scancode = (bitrev8(buf[1]) & 0x1f) << 8 | bitrev8(buf[0]) >> 2;
136 return 1; 137 return 1;
137} 138}
138 139
139static int em28xx_get_key_pinnacle_usb_grey(struct i2c_client *i2c_dev, 140static int em28xx_get_key_pinnacle_usb_grey(struct i2c_client *i2c_dev,
140 enum rc_type *protocol, u32 *scancode) 141 enum rc_proto *protocol,
142 u32 *scancode)
141{ 143{
142 unsigned char buf[3]; 144 unsigned char buf[3];
143 145
@@ -149,13 +151,14 @@ static int em28xx_get_key_pinnacle_usb_grey(struct i2c_client *i2c_dev,
149 if (buf[0] != 0x00) 151 if (buf[0] != 0x00)
150 return 0; 152 return 0;
151 153
152 *protocol = RC_TYPE_UNKNOWN; 154 *protocol = RC_PROTO_UNKNOWN;
153 *scancode = buf[2] & 0x3f; 155 *scancode = buf[2] & 0x3f;
154 return 1; 156 return 1;
155} 157}
156 158
157static int em28xx_get_key_winfast_usbii_deluxe(struct i2c_client *i2c_dev, 159static int em28xx_get_key_winfast_usbii_deluxe(struct i2c_client *i2c_dev,
158 enum rc_type *protocol, u32 *scancode) 160 enum rc_proto *protocol,
161 u32 *scancode)
159{ 162{
160 unsigned char subaddr, keydetect, key; 163 unsigned char subaddr, keydetect, key;
161 164
@@ -175,7 +178,7 @@ static int em28xx_get_key_winfast_usbii_deluxe(struct i2c_client *i2c_dev,
175 if (key == 0x00) 178 if (key == 0x00)
176 return 0; 179 return 0;
177 180
178 *protocol = RC_TYPE_UNKNOWN; 181 *protocol = RC_PROTO_UNKNOWN;
179 *scancode = key; 182 *scancode = key;
180 return 1; 183 return 1;
181} 184}
@@ -207,19 +210,19 @@ static int default_polling_getkey(struct em28xx_IR *ir,
207 poll_result->read_count = (msg[0] & 0x7f); 210 poll_result->read_count = (msg[0] & 0x7f);
208 211
209 /* Remote Control Address/Data (Regs 0x46/0x47) */ 212 /* Remote Control Address/Data (Regs 0x46/0x47) */
210 switch (ir->rc_type) { 213 switch (ir->rc_proto) {
211 case RC_BIT_RC5: 214 case RC_PROTO_BIT_RC5:
212 poll_result->protocol = RC_TYPE_RC5; 215 poll_result->protocol = RC_PROTO_RC5;
213 poll_result->scancode = RC_SCANCODE_RC5(msg[1], msg[2]); 216 poll_result->scancode = RC_SCANCODE_RC5(msg[1], msg[2]);
214 break; 217 break;
215 218
216 case RC_BIT_NEC: 219 case RC_PROTO_BIT_NEC:
217 poll_result->protocol = RC_TYPE_NEC; 220 poll_result->protocol = RC_PROTO_NEC;
218 poll_result->scancode = RC_SCANCODE_NEC(msg[1], msg[2]); 221 poll_result->scancode = RC_SCANCODE_NEC(msg[1], msg[2]);
219 break; 222 break;
220 223
221 default: 224 default:
222 poll_result->protocol = RC_TYPE_UNKNOWN; 225 poll_result->protocol = RC_PROTO_UNKNOWN;
223 poll_result->scancode = msg[1] << 8 | msg[2]; 226 poll_result->scancode = msg[1] << 8 | msg[2];
224 break; 227 break;
225 } 228 }
@@ -252,37 +255,37 @@ static int em2874_polling_getkey(struct em28xx_IR *ir,
252 * Remote Control Address (Reg 0x52) 255 * Remote Control Address (Reg 0x52)
253 * Remote Control Data (Reg 0x53-0x55) 256 * Remote Control Data (Reg 0x53-0x55)
254 */ 257 */
255 switch (ir->rc_type) { 258 switch (ir->rc_proto) {
256 case RC_BIT_RC5: 259 case RC_PROTO_BIT_RC5:
257 poll_result->protocol = RC_TYPE_RC5; 260 poll_result->protocol = RC_PROTO_RC5;
258 poll_result->scancode = RC_SCANCODE_RC5(msg[1], msg[2]); 261 poll_result->scancode = RC_SCANCODE_RC5(msg[1], msg[2]);
259 break; 262 break;
260 263
261 case RC_BIT_NEC: 264 case RC_PROTO_BIT_NEC:
262 poll_result->scancode = msg[1] << 8 | msg[2]; 265 poll_result->scancode = msg[1] << 8 | msg[2];
263 if ((msg[3] ^ msg[4]) != 0xff) { /* 32 bits NEC */ 266 if ((msg[3] ^ msg[4]) != 0xff) { /* 32 bits NEC */
264 poll_result->protocol = RC_TYPE_NEC32; 267 poll_result->protocol = RC_PROTO_NEC32;
265 poll_result->scancode = RC_SCANCODE_NEC32((msg[1] << 24) | 268 poll_result->scancode = RC_SCANCODE_NEC32((msg[1] << 24) |
266 (msg[2] << 16) | 269 (msg[2] << 16) |
267 (msg[3] << 8) | 270 (msg[3] << 8) |
268 (msg[4])); 271 (msg[4]));
269 } else if ((msg[1] ^ msg[2]) != 0xff) { /* 24 bits NEC */ 272 } else if ((msg[1] ^ msg[2]) != 0xff) { /* 24 bits NEC */
270 poll_result->protocol = RC_TYPE_NECX; 273 poll_result->protocol = RC_PROTO_NECX;
271 poll_result->scancode = RC_SCANCODE_NECX(msg[1] << 8 | 274 poll_result->scancode = RC_SCANCODE_NECX(msg[1] << 8 |
272 msg[2], msg[3]); 275 msg[2], msg[3]);
273 } else { /* Normal NEC */ 276 } else { /* Normal NEC */
274 poll_result->protocol = RC_TYPE_NEC; 277 poll_result->protocol = RC_PROTO_NEC;
275 poll_result->scancode = RC_SCANCODE_NEC(msg[1], msg[3]); 278 poll_result->scancode = RC_SCANCODE_NEC(msg[1], msg[3]);
276 } 279 }
277 break; 280 break;
278 281
279 case RC_BIT_RC6_0: 282 case RC_PROTO_BIT_RC6_0:
280 poll_result->protocol = RC_TYPE_RC6_0; 283 poll_result->protocol = RC_PROTO_RC6_0;
281 poll_result->scancode = RC_SCANCODE_RC6_0(msg[1], msg[2]); 284 poll_result->scancode = RC_SCANCODE_RC6_0(msg[1], msg[2]);
282 break; 285 break;
283 286
284 default: 287 default:
285 poll_result->protocol = RC_TYPE_UNKNOWN; 288 poll_result->protocol = RC_PROTO_UNKNOWN;
286 poll_result->scancode = (msg[1] << 24) | (msg[2] << 16) | 289 poll_result->scancode = (msg[1] << 24) | (msg[2] << 16) |
287 (msg[3] << 8) | msg[4]; 290 (msg[3] << 8) | msg[4];
288 break; 291 break;
@@ -298,7 +301,7 @@ static int em2874_polling_getkey(struct em28xx_IR *ir,
298static int em28xx_i2c_ir_handle_key(struct em28xx_IR *ir) 301static int em28xx_i2c_ir_handle_key(struct em28xx_IR *ir)
299{ 302{
300 static u32 scancode; 303 static u32 scancode;
301 enum rc_type protocol; 304 enum rc_proto protocol;
302 int rc; 305 int rc;
303 306
304 rc = ir->get_key_i2c(ir->i2c_client, &protocol, &scancode); 307 rc = ir->get_key_i2c(ir->i2c_client, &protocol, &scancode);
@@ -338,7 +341,7 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir)
338 poll_result.toggle_bit); 341 poll_result.toggle_bit);
339 else 342 else
340 rc_keydown(ir->rc, 343 rc_keydown(ir->rc,
341 RC_TYPE_UNKNOWN, 344 RC_PROTO_UNKNOWN,
342 poll_result.scancode & 0xff, 345 poll_result.scancode & 0xff,
343 poll_result.toggle_bit); 346 poll_result.toggle_bit);
344 347
@@ -383,70 +386,71 @@ static void em28xx_ir_stop(struct rc_dev *rc)
383 cancel_delayed_work_sync(&ir->work); 386 cancel_delayed_work_sync(&ir->work);
384} 387}
385 388
386static int em2860_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_type) 389static int em2860_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_proto)
387{ 390{
388 struct em28xx_IR *ir = rc_dev->priv; 391 struct em28xx_IR *ir = rc_dev->priv;
389 struct em28xx *dev = ir->dev; 392 struct em28xx *dev = ir->dev;
390 393
391 /* Adjust xclk based on IR table for RC5/NEC tables */ 394 /* Adjust xclk based on IR table for RC5/NEC tables */
392 if (*rc_type & RC_BIT_RC5) { 395 if (*rc_proto & RC_PROTO_BIT_RC5) {
393 dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE; 396 dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE;
394 ir->full_code = 1; 397 ir->full_code = 1;
395 *rc_type = RC_BIT_RC5; 398 *rc_proto = RC_PROTO_BIT_RC5;
396 } else if (*rc_type & RC_BIT_NEC) { 399 } else if (*rc_proto & RC_PROTO_BIT_NEC) {
397 dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE; 400 dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE;
398 ir->full_code = 1; 401 ir->full_code = 1;
399 *rc_type = RC_BIT_NEC; 402 *rc_proto = RC_PROTO_BIT_NEC;
400 } else if (*rc_type & RC_BIT_UNKNOWN) { 403 } else if (*rc_proto & RC_PROTO_BIT_UNKNOWN) {
401 *rc_type = RC_BIT_UNKNOWN; 404 *rc_proto = RC_PROTO_BIT_UNKNOWN;
402 } else { 405 } else {
403 *rc_type = ir->rc_type; 406 *rc_proto = ir->rc_proto;
404 return -EINVAL; 407 return -EINVAL;
405 } 408 }
406 em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk, 409 em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk,
407 EM28XX_XCLK_IR_RC5_MODE); 410 EM28XX_XCLK_IR_RC5_MODE);
408 411
409 ir->rc_type = *rc_type; 412 ir->rc_proto = *rc_proto;
410 413
411 return 0; 414 return 0;
412} 415}
413 416
414static int em2874_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_type) 417static int em2874_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_proto)
415{ 418{
416 struct em28xx_IR *ir = rc_dev->priv; 419 struct em28xx_IR *ir = rc_dev->priv;
417 struct em28xx *dev = ir->dev; 420 struct em28xx *dev = ir->dev;
418 u8 ir_config = EM2874_IR_RC5; 421 u8 ir_config = EM2874_IR_RC5;
419 422
420 /* Adjust xclk and set type based on IR table for RC5/NEC/RC6 tables */ 423 /* Adjust xclk and set type based on IR table for RC5/NEC/RC6 tables */
421 if (*rc_type & RC_BIT_RC5) { 424 if (*rc_proto & RC_PROTO_BIT_RC5) {
422 dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE; 425 dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE;
423 ir->full_code = 1; 426 ir->full_code = 1;
424 *rc_type = RC_BIT_RC5; 427 *rc_proto = RC_PROTO_BIT_RC5;
425 } else if (*rc_type & RC_BIT_NEC) { 428 } else if (*rc_proto & RC_PROTO_BIT_NEC) {
426 dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE; 429 dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE;
427 ir_config = EM2874_IR_NEC | EM2874_IR_NEC_NO_PARITY; 430 ir_config = EM2874_IR_NEC | EM2874_IR_NEC_NO_PARITY;
428 ir->full_code = 1; 431 ir->full_code = 1;
429 *rc_type = RC_BIT_NEC; 432 *rc_proto = RC_PROTO_BIT_NEC;
430 } else if (*rc_type & RC_BIT_RC6_0) { 433 } else if (*rc_proto & RC_PROTO_BIT_RC6_0) {
431 dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE; 434 dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE;
432 ir_config = EM2874_IR_RC6_MODE_0; 435 ir_config = EM2874_IR_RC6_MODE_0;
433 ir->full_code = 1; 436 ir->full_code = 1;
434 *rc_type = RC_BIT_RC6_0; 437 *rc_proto = RC_PROTO_BIT_RC6_0;
435 } else if (*rc_type & RC_BIT_UNKNOWN) { 438 } else if (*rc_proto & RC_PROTO_BIT_UNKNOWN) {
436 *rc_type = RC_BIT_UNKNOWN; 439 *rc_proto = RC_PROTO_BIT_UNKNOWN;
437 } else { 440 } else {
438 *rc_type = ir->rc_type; 441 *rc_proto = ir->rc_proto;
439 return -EINVAL; 442 return -EINVAL;
440 } 443 }
441 em28xx_write_regs(dev, EM2874_R50_IR_CONFIG, &ir_config, 1); 444 em28xx_write_regs(dev, EM2874_R50_IR_CONFIG, &ir_config, 1);
442 em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk, 445 em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk,
443 EM28XX_XCLK_IR_RC5_MODE); 446 EM28XX_XCLK_IR_RC5_MODE);
444 447
445 ir->rc_type = *rc_type; 448 ir->rc_proto = *rc_proto;
446 449
447 return 0; 450 return 0;
448} 451}
449static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_type) 452
453static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_proto)
450{ 454{
451 struct em28xx_IR *ir = rc_dev->priv; 455 struct em28xx_IR *ir = rc_dev->priv;
452 struct em28xx *dev = ir->dev; 456 struct em28xx *dev = ir->dev;
@@ -455,12 +459,12 @@ static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_type)
455 switch (dev->chip_id) { 459 switch (dev->chip_id) {
456 case CHIP_ID_EM2860: 460 case CHIP_ID_EM2860:
457 case CHIP_ID_EM2883: 461 case CHIP_ID_EM2883:
458 return em2860_ir_change_protocol(rc_dev, rc_type); 462 return em2860_ir_change_protocol(rc_dev, rc_proto);
459 case CHIP_ID_EM2884: 463 case CHIP_ID_EM2884:
460 case CHIP_ID_EM2874: 464 case CHIP_ID_EM2874:
461 case CHIP_ID_EM28174: 465 case CHIP_ID_EM28174:
462 case CHIP_ID_EM28178: 466 case CHIP_ID_EM28178:
463 return em2874_ir_change_protocol(rc_dev, rc_type); 467 return em2874_ir_change_protocol(rc_dev, rc_proto);
464 default: 468 default:
465 dev_err(&ir->dev->intf->dev, 469 dev_err(&ir->dev->intf->dev,
466 "Unrecognized em28xx chip id 0x%02x: IR not supported\n", 470 "Unrecognized em28xx chip id 0x%02x: IR not supported\n",
@@ -686,7 +690,7 @@ static int em28xx_ir_init(struct em28xx *dev)
686 struct em28xx_IR *ir; 690 struct em28xx_IR *ir;
687 struct rc_dev *rc; 691 struct rc_dev *rc;
688 int err = -ENOMEM; 692 int err = -ENOMEM;
689 u64 rc_type; 693 u64 rc_proto;
690 u16 i2c_rc_dev_addr = 0; 694 u16 i2c_rc_dev_addr = 0;
691 695
692 if (dev->is_audio_only) { 696 if (dev->is_audio_only) {
@@ -749,7 +753,7 @@ static int em28xx_ir_init(struct em28xx *dev)
749 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2: 753 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
750 rc->map_name = RC_MAP_HAUPPAUGE; 754 rc->map_name = RC_MAP_HAUPPAUGE;
751 ir->get_key_i2c = em28xx_get_key_em_haup; 755 ir->get_key_i2c = em28xx_get_key_em_haup;
752 rc->allowed_protocols = RC_BIT_RC5; 756 rc->allowed_protocols = RC_PROTO_BIT_RC5;
753 break; 757 break;
754 case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE: 758 case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE:
755 rc->map_name = RC_MAP_WINFAST_USBII_DELUXE; 759 rc->map_name = RC_MAP_WINFAST_USBII_DELUXE;
@@ -771,7 +775,8 @@ static int em28xx_ir_init(struct em28xx *dev)
771 switch (dev->chip_id) { 775 switch (dev->chip_id) {
772 case CHIP_ID_EM2860: 776 case CHIP_ID_EM2860:
773 case CHIP_ID_EM2883: 777 case CHIP_ID_EM2883:
774 rc->allowed_protocols = RC_BIT_RC5 | RC_BIT_NEC; 778 rc->allowed_protocols = RC_PROTO_BIT_RC5 |
779 RC_PROTO_BIT_NEC;
775 ir->get_key = default_polling_getkey; 780 ir->get_key = default_polling_getkey;
776 break; 781 break;
777 case CHIP_ID_EM2884: 782 case CHIP_ID_EM2884:
@@ -779,8 +784,9 @@ static int em28xx_ir_init(struct em28xx *dev)
779 case CHIP_ID_EM28174: 784 case CHIP_ID_EM28174:
780 case CHIP_ID_EM28178: 785 case CHIP_ID_EM28178:
781 ir->get_key = em2874_polling_getkey; 786 ir->get_key = em2874_polling_getkey;
782 rc->allowed_protocols = RC_BIT_RC5 | RC_BIT_NEC | 787 rc->allowed_protocols = RC_PROTO_BIT_RC5 |
783 RC_BIT_NECX | RC_BIT_NEC32 | RC_BIT_RC6_0; 788 RC_PROTO_BIT_NEC | RC_PROTO_BIT_NECX |
789 RC_PROTO_BIT_NEC32 | RC_PROTO_BIT_RC6_0;
784 break; 790 break;
785 default: 791 default:
786 err = -ENODEV; 792 err = -ENODEV;
@@ -791,8 +797,8 @@ static int em28xx_ir_init(struct em28xx *dev)
791 rc->map_name = dev->board.ir_codes; 797 rc->map_name = dev->board.ir_codes;
792 798
793 /* By default, keep protocol field untouched */ 799 /* By default, keep protocol field untouched */
794 rc_type = RC_BIT_UNKNOWN; 800 rc_proto = RC_PROTO_BIT_UNKNOWN;
795 err = em28xx_ir_change_protocol(rc, &rc_type); 801 err = em28xx_ir_change_protocol(rc, &rc_proto);
796 if (err) 802 if (err)
797 goto error; 803 goto error;
798 } 804 }
@@ -807,7 +813,7 @@ static int em28xx_ir_init(struct em28xx *dev)
807 usb_make_path(udev, ir->phys, sizeof(ir->phys)); 813 usb_make_path(udev, ir->phys, sizeof(ir->phys));
808 strlcat(ir->phys, "/input0", sizeof(ir->phys)); 814 strlcat(ir->phys, "/input0", sizeof(ir->phys));
809 815
810 rc->input_name = ir->name; 816 rc->device_name = ir->name;
811 rc->input_phys = ir->phys; 817 rc->input_phys = ir->phys;
812 rc->input_id.bustype = BUS_USB; 818 rc->input_id.bustype = BUS_USB;
813 rc->input_id.version = 1; 819 rc->input_id.version = 1;
diff --git a/drivers/media/usb/go7007/go7007-v4l2.c b/drivers/media/usb/go7007/go7007-v4l2.c
index ed5ec9773969..98cd57eaf36a 100644
--- a/drivers/media/usb/go7007/go7007-v4l2.c
+++ b/drivers/media/usb/go7007/go7007-v4l2.c
@@ -857,7 +857,7 @@ static int go7007_s_ctrl(struct v4l2_ctrl *ctrl)
857 return 0; 857 return 0;
858} 858}
859 859
860static struct v4l2_file_operations go7007_fops = { 860static const struct v4l2_file_operations go7007_fops = {
861 .owner = THIS_MODULE, 861 .owner = THIS_MODULE,
862 .open = v4l2_fh_open, 862 .open = v4l2_fh_open,
863 .release = vb2_fop_release, 863 .release = vb2_fop_release,
@@ -901,7 +901,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
901 .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 901 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
902}; 902};
903 903
904static struct video_device go7007_template = { 904static const struct video_device go7007_template = {
905 .name = "go7007", 905 .name = "go7007",
906 .fops = &go7007_fops, 906 .fops = &go7007_fops,
907 .release = video_device_release_empty, 907 .release = video_device_release_empty,
diff --git a/drivers/media/usb/go7007/snd-go7007.c b/drivers/media/usb/go7007/snd-go7007.c
index 070871fb1fc4..c618764480c6 100644
--- a/drivers/media/usb/go7007/snd-go7007.c
+++ b/drivers/media/usb/go7007/snd-go7007.c
@@ -52,7 +52,7 @@ struct go7007_snd {
52 int capturing; 52 int capturing;
53}; 53};
54 54
55static struct snd_pcm_hardware go7007_snd_capture_hw = { 55static const struct snd_pcm_hardware go7007_snd_capture_hw = {
56 .info = (SNDRV_PCM_INFO_MMAP | 56 .info = (SNDRV_PCM_INFO_MMAP |
57 SNDRV_PCM_INFO_INTERLEAVED | 57 SNDRV_PCM_INFO_INTERLEAVED |
58 SNDRV_PCM_INFO_BLOCK_TRANSFER | 58 SNDRV_PCM_INFO_BLOCK_TRANSFER |
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 16bc1dde2c8c..0f141762abf1 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -1964,7 +1964,7 @@ out:
1964 return ret; 1964 return ret;
1965} 1965}
1966 1966
1967static struct v4l2_file_operations dev_fops = { 1967static const struct v4l2_file_operations dev_fops = {
1968 .owner = THIS_MODULE, 1968 .owner = THIS_MODULE,
1969 .open = dev_open, 1969 .open = dev_open,
1970 .release = dev_close, 1970 .release = dev_close,
diff --git a/drivers/media/usb/gspca/xirlink_cit.c b/drivers/media/usb/gspca/xirlink_cit.c
index b600ea6460d3..68656e7986c7 100644
--- a/drivers/media/usb/gspca/xirlink_cit.c
+++ b/drivers/media/usb/gspca/xirlink_cit.c
@@ -1315,7 +1315,7 @@ static int cit_set_sharpness(struct gspca_dev *gspca_dev, s32 val)
1315 break; 1315 break;
1316 case CIT_MODEL1: { 1316 case CIT_MODEL1: {
1317 int i; 1317 int i;
1318 const unsigned short sa[] = { 1318 static const unsigned short sa[] = {
1319 0x11, 0x13, 0x16, 0x18, 0x1a, 0x8, 0x0a }; 1319 0x11, 0x13, 0x16, 0x18, 0x1a, 0x8, 0x0a };
1320 1320
1321 for (i = 0; i < cit_model1_ntries; i++) 1321 for (i = 0; i < cit_model1_ntries; i++)
diff --git a/drivers/media/usb/hackrf/hackrf.c b/drivers/media/usb/hackrf/hackrf.c
index d9a525260511..7eb53517a82f 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
@@ -1263,7 +1263,7 @@ static const struct v4l2_file_operations hackrf_fops = {
1263 .unlocked_ioctl = video_ioctl2, 1263 .unlocked_ioctl = video_ioctl2,
1264}; 1264};
1265 1265
1266static struct video_device hackrf_template = { 1266static const struct video_device hackrf_template = {
1267 .name = "HackRF One", 1267 .name = "HackRF One",
1268 .release = video_device_release_empty, 1268 .release = video_device_release_empty,
1269 .fops = &hackrf_fops, 1269 .fops = &hackrf_fops,
@@ -1545,7 +1545,7 @@ err:
1545} 1545}
1546 1546
1547/* USB device ID list */ 1547/* USB device ID list */
1548static struct usb_device_id hackrf_id_table[] = { 1548static const struct usb_device_id hackrf_id_table[] = {
1549 { USB_DEVICE(0x1d50, 0x6089) }, /* HackRF One */ 1549 { USB_DEVICE(0x1d50, 0x6089) }, /* HackRF One */
1550 { } 1550 { }
1551}; 1551};
diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c
index 15f016ad5b89..dbe29c6c4d8b 100644
--- a/drivers/media/usb/hdpvr/hdpvr-core.c
+++ b/drivers/media/usb/hdpvr/hdpvr-core.c
@@ -53,7 +53,7 @@ MODULE_PARM_DESC(boost_audio, "boost the audio signal");
53 53
54 54
55/* table of devices that work with this driver */ 55/* table of devices that work with this driver */
56static struct usb_device_id hdpvr_table[] = { 56static const struct usb_device_id hdpvr_table[] = {
57 { USB_DEVICE(HD_PVR_VENDOR_ID, HD_PVR_PRODUCT_ID) }, 57 { USB_DEVICE(HD_PVR_VENDOR_ID, HD_PVR_PRODUCT_ID) },
58 { USB_DEVICE(HD_PVR_VENDOR_ID, HD_PVR_PRODUCT_ID1) }, 58 { USB_DEVICE(HD_PVR_VENDOR_ID, HD_PVR_PRODUCT_ID1) },
59 { USB_DEVICE(HD_PVR_VENDOR_ID, HD_PVR_PRODUCT_ID2) }, 59 { USB_DEVICE(HD_PVR_VENDOR_ID, HD_PVR_PRODUCT_ID2) },
diff --git a/drivers/media/usb/hdpvr/hdpvr-i2c.c b/drivers/media/usb/hdpvr/hdpvr-i2c.c
index fcab55038d99..1db49ed5eaf1 100644
--- a/drivers/media/usb/hdpvr/hdpvr-i2c.c
+++ b/drivers/media/usb/hdpvr/hdpvr-i2c.c
@@ -55,7 +55,8 @@ struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev)
55 /* Our default information for ir-kbd-i2c.c to use */ 55 /* Our default information for ir-kbd-i2c.c to use */
56 init_data->ir_codes = RC_MAP_HAUPPAUGE; 56 init_data->ir_codes = RC_MAP_HAUPPAUGE;
57 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 57 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
58 init_data->type = RC_BIT_RC5 | RC_BIT_RC6_MCE | RC_BIT_RC6_6A_32; 58 init_data->type = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC6_MCE |
59 RC_PROTO_BIT_RC6_6A_32;
59 init_data->name = "HD-PVR"; 60 init_data->name = "HD-PVR";
60 init_data->polling_interval = 405; /* ms, duplicated from Windows */ 61 init_data->polling_interval = 405; /* ms, duplicated from Windows */
61 hdpvr_ir_rx_i2c_board_info.platform_data = init_data; 62 hdpvr_ir_rx_i2c_board_info.platform_data = init_data;
@@ -184,7 +185,7 @@ static const struct i2c_algorithm hdpvr_algo = {
184 .functionality = hdpvr_functionality, 185 .functionality = hdpvr_functionality,
185}; 186};
186 187
187static struct i2c_adapter hdpvr_i2c_adapter_template = { 188static const struct i2c_adapter hdpvr_i2c_adapter_template = {
188 .name = "Hauppage HD PVR I2C", 189 .name = "Hauppage HD PVR I2C",
189 .owner = THIS_MODULE, 190 .owner = THIS_MODULE,
190 .algo = &hdpvr_algo, 191 .algo = &hdpvr_algo,
diff --git a/drivers/media/usb/msi2500/msi2500.c b/drivers/media/usb/msi2500/msi2500.c
index bb3d31e2a0b5..a097d3dbc141 100644
--- a/drivers/media/usb/msi2500/msi2500.c
+++ b/drivers/media/usb/msi2500/msi2500.c
@@ -1143,7 +1143,7 @@ static const struct v4l2_file_operations msi2500_fops = {
1143 .unlocked_ioctl = video_ioctl2, 1143 .unlocked_ioctl = video_ioctl2,
1144}; 1144};
1145 1145
1146static struct video_device msi2500_template = { 1146static const struct video_device msi2500_template = {
1147 .name = "Mirics MSi3101 SDR Dongle", 1147 .name = "Mirics MSi3101 SDR Dongle",
1148 .release = video_device_release_empty, 1148 .release = video_device_release_empty,
1149 .fops = &msi2500_fops, 1149 .fops = &msi2500_fops,
@@ -1308,7 +1308,7 @@ err:
1308} 1308}
1309 1309
1310/* USB device ID list */ 1310/* USB device ID list */
1311static struct usb_device_id msi2500_id_table[] = { 1311static const struct usb_device_id msi2500_id_table[] = {
1312 {USB_DEVICE(0x1df7, 0x2500)}, /* Mirics MSi3101 SDR Dongle */ 1312 {USB_DEVICE(0x1df7, 0x2500)}, /* Mirics MSi3101 SDR Dongle */
1313 {USB_DEVICE(0x2040, 0xd300)}, /* Hauppauge WinTV 133559 LF */ 1313 {USB_DEVICE(0x2040, 0xd300)}, /* Hauppauge WinTV 133559 LF */
1314 {} 1314 {}
diff --git a/drivers/media/usb/pulse8-cec/pulse8-cec.c b/drivers/media/usb/pulse8-cec/pulse8-cec.c
index f9ed9c950247..50146f263d90 100644
--- a/drivers/media/usb/pulse8-cec/pulse8-cec.c
+++ b/drivers/media/usb/pulse8-cec/pulse8-cec.c
@@ -642,8 +642,7 @@ static const struct cec_adap_ops pulse8_cec_adap_ops = {
642 642
643static int pulse8_connect(struct serio *serio, struct serio_driver *drv) 643static int pulse8_connect(struct serio *serio, struct serio_driver *drv)
644{ 644{
645 u32 caps = CEC_CAP_TRANSMIT | CEC_CAP_LOG_ADDRS | CEC_CAP_PHYS_ADDR | 645 u32 caps = CEC_CAP_DEFAULTS | CEC_CAP_PHYS_ADDR | CEC_CAP_MONITOR_ALL;
646 CEC_CAP_PASSTHROUGH | CEC_CAP_RC | CEC_CAP_MONITOR_ALL;
647 struct pulse8 *pulse8; 646 struct pulse8 *pulse8;
648 int err = -ENOMEM; 647 int err = -ENOMEM;
649 struct cec_log_addrs log_addrs = {}; 648 struct cec_log_addrs log_addrs = {};
@@ -656,7 +655,7 @@ static int pulse8_connect(struct serio *serio, struct serio_driver *drv)
656 655
657 pulse8->serio = serio; 656 pulse8->serio = serio;
658 pulse8->adap = cec_allocate_adapter(&pulse8_cec_adap_ops, pulse8, 657 pulse8->adap = cec_allocate_adapter(&pulse8_cec_adap_ops, pulse8,
659 "HDMI CEC", caps, 1); 658 dev_name(&serio->dev), caps, 1);
660 err = PTR_ERR_OR_ZERO(pulse8->adap); 659 err = PTR_ERR_OR_ZERO(pulse8->adap);
661 if (err < 0) 660 if (err < 0)
662 goto free_device; 661 goto free_device;
@@ -732,7 +731,7 @@ static void pulse8_ping_eeprom_work_handler(struct work_struct *work)
732 mutex_unlock(&pulse8->config_lock); 731 mutex_unlock(&pulse8->config_lock);
733} 732}
734 733
735static struct serio_device_id pulse8_serio_ids[] = { 734static const struct serio_device_id pulse8_serio_ids[] = {
736 { 735 {
737 .type = SERIO_RS232, 736 .type = SERIO_RS232,
738 .proto = SERIO_PULSE8_CEC, 737 .proto = SERIO_PULSE8_CEC,
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-encoder.c b/drivers/media/usb/pvrusb2/pvrusb2-encoder.c
index ca637074fa1f..43e43404095f 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-encoder.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-encoder.c
@@ -198,7 +198,7 @@ static int pvr2_encoder_cmd(void *ctxt,
198 } 198 }
199 199
200 200
201 LOCK_TAKE(hdw->ctl_lock); do { 201 LOCK_TAKE(hdw->ctl_lock); while (1) {
202 202
203 if (!hdw->state_encoder_ok) { 203 if (!hdw->state_encoder_ok) {
204 ret = -EIO; 204 ret = -EIO;
@@ -293,9 +293,9 @@ rdData[0]);
293 293
294 wrData[0] = 0x0; 294 wrData[0] = 0x0;
295 ret = pvr2_encoder_write_words(hdw,MBOX_BASE,wrData,1); 295 ret = pvr2_encoder_write_words(hdw,MBOX_BASE,wrData,1);
296 if (ret) break; 296 break;
297 297
298 } while(0); LOCK_GIVE(hdw->ctl_lock); 298 }; LOCK_GIVE(hdw->ctl_lock);
299 299
300 return ret; 300 return ret;
301} 301}
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
index 20a52b785fff..ff7b4d1d385d 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
@@ -514,12 +514,12 @@ static u32 pvr2_i2c_functionality(struct i2c_adapter *adap)
514 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C; 514 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C;
515} 515}
516 516
517static struct i2c_algorithm pvr2_i2c_algo_template = { 517static const struct i2c_algorithm pvr2_i2c_algo_template = {
518 .master_xfer = pvr2_i2c_xfer, 518 .master_xfer = pvr2_i2c_xfer,
519 .functionality = pvr2_i2c_functionality, 519 .functionality = pvr2_i2c_functionality,
520}; 520};
521 521
522static struct i2c_adapter pvr2_i2c_adap_template = { 522static const struct i2c_adapter pvr2_i2c_adap_template = {
523 .owner = THIS_MODULE, 523 .owner = THIS_MODULE,
524 .class = 0, 524 .class = 0,
525}; 525};
@@ -567,7 +567,7 @@ static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw)
567 case PVR2_IR_SCHEME_29XXX: /* Original 29xxx device */ 567 case PVR2_IR_SCHEME_29XXX: /* Original 29xxx device */
568 init_data->ir_codes = RC_MAP_HAUPPAUGE; 568 init_data->ir_codes = RC_MAP_HAUPPAUGE;
569 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP; 569 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP;
570 init_data->type = RC_BIT_RC5; 570 init_data->type = RC_PROTO_BIT_RC5;
571 init_data->name = hdw->hdw_desc->description; 571 init_data->name = hdw->hdw_desc->description;
572 init_data->polling_interval = 100; /* ms From ir-kbd-i2c */ 572 init_data->polling_interval = 100; /* ms From ir-kbd-i2c */
573 /* IR Receiver */ 573 /* IR Receiver */
@@ -580,11 +580,11 @@ static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw)
580 break; 580 break;
581 case PVR2_IR_SCHEME_ZILOG: /* HVR-1950 style */ 581 case PVR2_IR_SCHEME_ZILOG: /* HVR-1950 style */
582 case PVR2_IR_SCHEME_24XXX_MCE: /* 24xxx MCE device */ 582 case PVR2_IR_SCHEME_24XXX_MCE: /* 24xxx MCE device */
583 init_data->ir_codes = RC_MAP_HAUPPAUGE; 583 init_data->ir_codes = RC_MAP_HAUPPAUGE;
584 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 584 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
585 init_data->type = RC_BIT_RC5 | RC_BIT_RC6_MCE | 585 init_data->type = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC6_MCE |
586 RC_BIT_RC6_6A_32; 586 RC_PROTO_BIT_RC6_6A_32;
587 init_data->name = hdw->hdw_desc->description; 587 init_data->name = hdw->hdw_desc->description;
588 /* IR Receiver */ 588 /* IR Receiver */
589 info.addr = 0x71; 589 info.addr = 0x71;
590 info.platform_data = init_data; 590 info.platform_data = init_data;
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
index 8f13c60198ed..4320bda9352d 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
@@ -1226,7 +1226,7 @@ static const struct v4l2_file_operations vdev_fops = {
1226}; 1226};
1227 1227
1228 1228
1229static struct video_device vdev_template = { 1229static const struct video_device vdev_template = {
1230 .fops = &vdev_fops, 1230 .fops = &vdev_fops,
1231}; 1231};
1232 1232
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index 22420c14ac98..eb6921d2743e 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -146,7 +146,7 @@ static const struct v4l2_file_operations pwc_fops = {
146 .mmap = vb2_fop_mmap, 146 .mmap = vb2_fop_mmap,
147 .unlocked_ioctl = video_ioctl2, 147 .unlocked_ioctl = video_ioctl2,
148}; 148};
149static struct video_device pwc_template = { 149static const struct video_device pwc_template = {
150 .name = "Philips Webcam", /* Filled in later */ 150 .name = "Philips Webcam", /* Filled in later */
151 .release = video_device_release_empty, 151 .release = video_device_release_empty,
152 .fops = &pwc_fops, 152 .fops = &pwc_fops,
diff --git a/drivers/media/usb/rainshadow-cec/rainshadow-cec.c b/drivers/media/usb/rainshadow-cec/rainshadow-cec.c
index 65692576690f..cecdcbcd400c 100644
--- a/drivers/media/usb/rainshadow-cec/rainshadow-cec.c
+++ b/drivers/media/usb/rainshadow-cec/rainshadow-cec.c
@@ -309,8 +309,7 @@ static const struct cec_adap_ops rain_cec_adap_ops = {
309 309
310static int rain_connect(struct serio *serio, struct serio_driver *drv) 310static int rain_connect(struct serio *serio, struct serio_driver *drv)
311{ 311{
312 u32 caps = CEC_CAP_TRANSMIT | CEC_CAP_LOG_ADDRS | CEC_CAP_PHYS_ADDR | 312 u32 caps = CEC_CAP_DEFAULTS | CEC_CAP_PHYS_ADDR | CEC_CAP_MONITOR_ALL;
313 CEC_CAP_PASSTHROUGH | CEC_CAP_RC | CEC_CAP_MONITOR_ALL;
314 struct rain *rain; 313 struct rain *rain;
315 int err = -ENOMEM; 314 int err = -ENOMEM;
316 struct cec_log_addrs log_addrs = {}; 315 struct cec_log_addrs log_addrs = {};
@@ -323,7 +322,7 @@ static int rain_connect(struct serio *serio, struct serio_driver *drv)
323 322
324 rain->serio = serio; 323 rain->serio = serio;
325 rain->adap = cec_allocate_adapter(&rain_cec_adap_ops, rain, 324 rain->adap = cec_allocate_adapter(&rain_cec_adap_ops, rain,
326 "HDMI CEC", caps, 1); 325 dev_name(&serio->dev), caps, 1);
327 err = PTR_ERR_OR_ZERO(rain->adap); 326 err = PTR_ERR_OR_ZERO(rain->adap);
328 if (err < 0) 327 if (err < 0)
329 goto free_device; 328 goto free_device;
@@ -359,7 +358,7 @@ free_device:
359 return err; 358 return err;
360} 359}
361 360
362static struct serio_device_id rain_serio_ids[] = { 361static const struct serio_device_id rain_serio_ids[] = {
363 { 362 {
364 .type = SERIO_RS232, 363 .type = SERIO_RS232,
365 .proto = SERIO_RAINSHADOW_CEC, 364 .proto = SERIO_RAINSHADOW_CEC,
diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c
index 6a88b1dbb3a0..b2f239c4ba42 100644
--- a/drivers/media/usb/s2255/s2255drv.c
+++ b/drivers/media/usb/s2255/s2255drv.c
@@ -381,7 +381,7 @@ MODULE_PARM_DESC(jpeg_enable, "Jpeg enable(1-on 0-off) default 1");
381 381
382/* USB device table */ 382/* USB device table */
383#define USB_SENSORAY_VID 0x1943 383#define USB_SENSORAY_VID 0x1943
384static struct usb_device_id s2255_table[] = { 384static const struct usb_device_id s2255_table[] = {
385 {USB_DEVICE(USB_SENSORAY_VID, 0x2255)}, 385 {USB_DEVICE(USB_SENSORAY_VID, 0x2255)},
386 {USB_DEVICE(USB_SENSORAY_VID, 0x2257)}, /*same family as 2255*/ 386 {USB_DEVICE(USB_SENSORAY_VID, 0x2257)}, /*same family as 2255*/
387 { } /* Terminating entry */ 387 { } /* Terminating entry */
@@ -1590,7 +1590,7 @@ static void s2255_video_device_release(struct video_device *vdev)
1590 return; 1590 return;
1591} 1591}
1592 1592
1593static struct video_device template = { 1593static const struct video_device template = {
1594 .name = "s2255v", 1594 .name = "s2255v",
1595 .fops = &s2255_fops_v4l, 1595 .fops = &s2255_fops_v4l,
1596 .ioctl_ops = &s2255_ioctl_ops, 1596 .ioctl_ops = &s2255_ioctl_ops,
diff --git a/drivers/media/usb/stk1160/stk1160-core.c b/drivers/media/usb/stk1160/stk1160-core.c
index c86eb6164713..bea8bbbb84fb 100644
--- a/drivers/media/usb/stk1160/stk1160-core.c
+++ b/drivers/media/usb/stk1160/stk1160-core.c
@@ -47,7 +47,7 @@ MODULE_AUTHOR("Ezequiel Garcia");
47MODULE_DESCRIPTION("STK1160 driver"); 47MODULE_DESCRIPTION("STK1160 driver");
48 48
49/* Devices supported by this driver */ 49/* Devices supported by this driver */
50static struct usb_device_id stk1160_id_table[] = { 50static const struct usb_device_id stk1160_id_table[] = {
51 { USB_DEVICE(0x05e1, 0x0408) }, 51 { USB_DEVICE(0x05e1, 0x0408) },
52 { } 52 { }
53}; 53};
diff --git a/drivers/media/usb/stk1160/stk1160-i2c.c b/drivers/media/usb/stk1160/stk1160-i2c.c
index 3f2517be02bb..2c70173e3c82 100644
--- a/drivers/media/usb/stk1160/stk1160-i2c.c
+++ b/drivers/media/usb/stk1160/stk1160-i2c.c
@@ -240,7 +240,7 @@ static const struct i2c_algorithm algo = {
240 .functionality = functionality, 240 .functionality = functionality,
241}; 241};
242 242
243static struct i2c_adapter adap_template = { 243static const struct i2c_adapter adap_template = {
244 .owner = THIS_MODULE, 244 .owner = THIS_MODULE,
245 .name = "stk1160", 245 .name = "stk1160",
246 .algo = &algo, 246 .algo = &algo,
diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c b/drivers/media/usb/stk1160/stk1160-v4l.c
index a005d262392a..77b759a0bcd9 100644
--- a/drivers/media/usb/stk1160/stk1160-v4l.c
+++ b/drivers/media/usb/stk1160/stk1160-v4l.c
@@ -326,7 +326,7 @@ static int stk1160_stop_streaming(struct stk1160 *dev)
326 return 0; 326 return 0;
327} 327}
328 328
329static struct v4l2_file_operations stk1160_fops = { 329static const struct v4l2_file_operations stk1160_fops = {
330 .owner = THIS_MODULE, 330 .owner = THIS_MODULE,
331 .open = v4l2_fh_open, 331 .open = v4l2_fh_open,
332 .release = vb2_fop_release, 332 .release = vb2_fop_release,
@@ -751,7 +751,7 @@ static const struct vb2_ops stk1160_video_qops = {
751 .wait_finish = vb2_ops_wait_finish, 751 .wait_finish = vb2_ops_wait_finish,
752}; 752};
753 753
754static struct video_device v4l_template = { 754static const struct video_device v4l_template = {
755 .name = "stk1160", 755 .name = "stk1160",
756 .tvnorms = V4L2_STD_525_60 | V4L2_STD_625_50, 756 .tvnorms = V4L2_STD_525_60 | V4L2_STD_625_50,
757 .fops = &stk1160_fops, 757 .fops = &stk1160_fops,
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
index 90d4a08cda31..c0bba773db25 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.c
+++ b/drivers/media/usb/stkwebcam/stk-webcam.c
@@ -55,7 +55,7 @@ MODULE_AUTHOR("Jaime Velasco Juan <jsagarribay@gmail.com> and Nicolas VIVIEN");
55MODULE_DESCRIPTION("Syntek DC1125 webcam driver"); 55MODULE_DESCRIPTION("Syntek DC1125 webcam driver");
56 56
57/* Some cameras have audio interfaces, we aren't interested in those */ 57/* Some cameras have audio interfaces, we aren't interested in those */
58static struct usb_device_id stkwebcam_table[] = { 58static const struct usb_device_id stkwebcam_table[] = {
59 { USB_DEVICE_AND_INTERFACE_INFO(0x174f, 0xa311, 0xff, 0xff, 0xff) }, 59 { USB_DEVICE_AND_INTERFACE_INFO(0x174f, 0xa311, 0xff, 0xff, 0xff) },
60 { USB_DEVICE_AND_INTERFACE_INFO(0x05e1, 0x0501, 0xff, 0xff, 0xff) }, 60 { USB_DEVICE_AND_INTERFACE_INFO(0x05e1, 0x0501, 0xff, 0xff, 0xff) },
61 { } 61 { }
@@ -1202,7 +1202,7 @@ static const struct v4l2_ctrl_ops stk_ctrl_ops = {
1202 .s_ctrl = stk_s_ctrl, 1202 .s_ctrl = stk_s_ctrl,
1203}; 1203};
1204 1204
1205static struct v4l2_file_operations v4l_stk_fops = { 1205static const struct v4l2_file_operations v4l_stk_fops = {
1206 .owner = THIS_MODULE, 1206 .owner = THIS_MODULE,
1207 .open = v4l_stk_open, 1207 .open = v4l_stk_open,
1208 .release = v4l_stk_release, 1208 .release = v4l_stk_release,
@@ -1244,7 +1244,7 @@ static void stk_v4l_dev_release(struct video_device *vd)
1244 kfree(dev); 1244 kfree(dev);
1245} 1245}
1246 1246
1247static struct video_device stk_v4l_data = { 1247static const struct video_device stk_v4l_data = {
1248 .name = "stkwebcam", 1248 .name = "stkwebcam",
1249 .fops = &v4l_stk_fops, 1249 .fops = &v4l_stk_fops,
1250 .ioctl_ops = &v4l_stk_ioctl_ops, 1250 .ioctl_ops = &v4l_stk_ioctl_ops,
diff --git a/drivers/media/usb/tm6000/tm6000-alsa.c b/drivers/media/usb/tm6000/tm6000-alsa.c
index 422322541af6..3717a6844ea8 100644
--- a/drivers/media/usb/tm6000/tm6000-alsa.c
+++ b/drivers/media/usb/tm6000/tm6000-alsa.c
@@ -143,7 +143,7 @@ static int dsp_buffer_alloc(struct snd_pcm_substream *substream, int size)
143 */ 143 */
144#define DEFAULT_FIFO_SIZE 4096 144#define DEFAULT_FIFO_SIZE 4096
145 145
146static struct snd_pcm_hardware snd_tm6000_digital_hw = { 146static const struct snd_pcm_hardware snd_tm6000_digital_hw = {
147 .info = SNDRV_PCM_INFO_BATCH | 147 .info = SNDRV_PCM_INFO_BATCH |
148 SNDRV_PCM_INFO_MMAP | 148 SNDRV_PCM_INFO_MMAP |
149 SNDRV_PCM_INFO_INTERLEAVED | 149 SNDRV_PCM_INFO_INTERLEAVED |
diff --git a/drivers/media/usb/tm6000/tm6000-cards.c b/drivers/media/usb/tm6000/tm6000-cards.c
index b293dea6554f..2537643a1808 100644
--- a/drivers/media/usb/tm6000/tm6000-cards.c
+++ b/drivers/media/usb/tm6000/tm6000-cards.c
@@ -613,7 +613,7 @@ static struct tm6000_board tm6000_boards[] = {
613}; 613};
614 614
615/* table of devices that work with this driver */ 615/* table of devices that work with this driver */
616static struct usb_device_id tm6000_id_table[] = { 616static const struct usb_device_id tm6000_id_table[] = {
617 { USB_DEVICE(0x6000, 0x0001), .driver_info = TM5600_BOARD_GENERIC }, 617 { USB_DEVICE(0x6000, 0x0001), .driver_info = TM5600_BOARD_GENERIC },
618 { USB_DEVICE(0x6000, 0x0002), .driver_info = TM6010_BOARD_GENERIC }, 618 { USB_DEVICE(0x6000, 0x0002), .driver_info = TM6010_BOARD_GENERIC },
619 { USB_DEVICE(0x06e1, 0xf332), .driver_info = TM6000_BOARD_ADSTECH_DUAL_TV }, 619 { USB_DEVICE(0x06e1, 0xf332), .driver_info = TM6000_BOARD_ADSTECH_DUAL_TV },
diff --git a/drivers/media/usb/tm6000/tm6000-input.c b/drivers/media/usb/tm6000/tm6000-input.c
index 1a033f57fcc1..91889ad9cdd7 100644
--- a/drivers/media/usb/tm6000/tm6000-input.c
+++ b/drivers/media/usb/tm6000/tm6000-input.c
@@ -66,7 +66,7 @@ struct tm6000_IR {
66 struct urb *int_urb; 66 struct urb *int_urb;
67 67
68 /* IR device properties */ 68 /* IR device properties */
69 u64 rc_type; 69 u64 rc_proto;
70}; 70};
71 71
72void tm6000_ir_wait(struct tm6000_core *dev, u8 state) 72void tm6000_ir_wait(struct tm6000_core *dev, u8 state)
@@ -103,13 +103,13 @@ static int tm6000_ir_config(struct tm6000_IR *ir)
103 * IR, in order to discard such decoding 103 * IR, in order to discard such decoding
104 */ 104 */
105 105
106 switch (ir->rc_type) { 106 switch (ir->rc_proto) {
107 case RC_BIT_NEC: 107 case RC_PROTO_BIT_NEC:
108 leader = 900; /* ms */ 108 leader = 900; /* ms */
109 pulse = 700; /* ms - the actual value would be 562 */ 109 pulse = 700; /* ms - the actual value would be 562 */
110 break; 110 break;
111 default: 111 default:
112 case RC_BIT_RC5: 112 case RC_PROTO_BIT_RC5:
113 leader = 900; /* ms - from the NEC decoding */ 113 leader = 900; /* ms - from the NEC decoding */
114 pulse = 1780; /* ms - The actual value would be 1776 */ 114 pulse = 1780; /* ms - The actual value would be 1776 */
115 break; 115 break;
@@ -117,12 +117,12 @@ static int tm6000_ir_config(struct tm6000_IR *ir)
117 117
118 pulse = ir_clock_mhz * pulse; 118 pulse = ir_clock_mhz * pulse;
119 leader = ir_clock_mhz * leader; 119 leader = ir_clock_mhz * leader;
120 if (ir->rc_type == RC_BIT_NEC) 120 if (ir->rc_proto == RC_PROTO_BIT_NEC)
121 leader = leader | 0x8000; 121 leader = leader | 0x8000;
122 122
123 dprintk(2, "%s: %s, %d MHz, leader = 0x%04x, pulse = 0x%06x \n", 123 dprintk(2, "%s: %s, %d MHz, leader = 0x%04x, pulse = 0x%06x \n",
124 __func__, 124 __func__,
125 (ir->rc_type == RC_BIT_NEC) ? "NEC" : "RC-5", 125 (ir->rc_proto == RC_PROTO_BIT_NEC) ? "NEC" : "RC-5",
126 ir_clock_mhz, leader, pulse); 126 ir_clock_mhz, leader, pulse);
127 127
128 /* Remote WAKEUP = enable, normal mode, from IR decoder output */ 128 /* Remote WAKEUP = enable, normal mode, from IR decoder output */
@@ -162,24 +162,24 @@ static void tm6000_ir_keydown(struct tm6000_IR *ir,
162{ 162{
163 u8 device, command; 163 u8 device, command;
164 u32 scancode; 164 u32 scancode;
165 enum rc_type protocol; 165 enum rc_proto protocol;
166 166
167 if (len < 1) 167 if (len < 1)
168 return; 168 return;
169 169
170 command = buf[0]; 170 command = buf[0];
171 device = (len > 1 ? buf[1] : 0x0); 171 device = (len > 1 ? buf[1] : 0x0);
172 switch (ir->rc_type) { 172 switch (ir->rc_proto) {
173 case RC_BIT_RC5: 173 case RC_PROTO_BIT_RC5:
174 protocol = RC_TYPE_RC5; 174 protocol = RC_PROTO_RC5;
175 scancode = RC_SCANCODE_RC5(device, command); 175 scancode = RC_SCANCODE_RC5(device, command);
176 break; 176 break;
177 case RC_BIT_NEC: 177 case RC_PROTO_BIT_NEC:
178 protocol = RC_TYPE_NEC; 178 protocol = RC_PROTO_NEC;
179 scancode = RC_SCANCODE_NEC(device, command); 179 scancode = RC_SCANCODE_NEC(device, command);
180 break; 180 break;
181 default: 181 default:
182 protocol = RC_TYPE_OTHER; 182 protocol = RC_PROTO_OTHER;
183 scancode = RC_SCANCODE_OTHER(device << 8 | command); 183 scancode = RC_SCANCODE_OTHER(device << 8 | command);
184 break; 184 break;
185 } 185 }
@@ -311,7 +311,7 @@ static void tm6000_ir_stop(struct rc_dev *rc)
311 cancel_delayed_work_sync(&ir->work); 311 cancel_delayed_work_sync(&ir->work);
312} 312}
313 313
314static int tm6000_ir_change_protocol(struct rc_dev *rc, u64 *rc_type) 314static int tm6000_ir_change_protocol(struct rc_dev *rc, u64 *rc_proto)
315{ 315{
316 struct tm6000_IR *ir = rc->priv; 316 struct tm6000_IR *ir = rc->priv;
317 317
@@ -320,7 +320,7 @@ static int tm6000_ir_change_protocol(struct rc_dev *rc, u64 *rc_type)
320 320
321 dprintk(2, "%s\n",__func__); 321 dprintk(2, "%s\n",__func__);
322 322
323 ir->rc_type = *rc_type; 323 ir->rc_proto = *rc_proto;
324 324
325 tm6000_ir_config(ir); 325 tm6000_ir_config(ir);
326 /* TODO */ 326 /* TODO */
@@ -409,7 +409,7 @@ int tm6000_ir_init(struct tm6000_core *dev)
409 struct tm6000_IR *ir; 409 struct tm6000_IR *ir;
410 struct rc_dev *rc; 410 struct rc_dev *rc;
411 int err = -ENOMEM; 411 int err = -ENOMEM;
412 u64 rc_type; 412 u64 rc_proto;
413 413
414 if (!enable_ir) 414 if (!enable_ir)
415 return -ENODEV; 415 return -ENODEV;
@@ -433,7 +433,7 @@ int tm6000_ir_init(struct tm6000_core *dev)
433 ir->rc = rc; 433 ir->rc = rc;
434 434
435 /* input setup */ 435 /* input setup */
436 rc->allowed_protocols = RC_BIT_RC5 | RC_BIT_NEC; 436 rc->allowed_protocols = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_NEC;
437 /* Needed, in order to support NEC remotes with 24 or 32 bits */ 437 /* Needed, in order to support NEC remotes with 24 or 32 bits */
438 rc->scancode_mask = 0xffff; 438 rc->scancode_mask = 0xffff;
439 rc->priv = ir; 439 rc->priv = ir;
@@ -455,10 +455,10 @@ int tm6000_ir_init(struct tm6000_core *dev)
455 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys)); 455 usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
456 strlcat(ir->phys, "/input0", sizeof(ir->phys)); 456 strlcat(ir->phys, "/input0", sizeof(ir->phys));
457 457
458 rc_type = RC_BIT_UNKNOWN; 458 rc_proto = RC_PROTO_BIT_UNKNOWN;
459 tm6000_ir_change_protocol(rc, &rc_type); 459 tm6000_ir_change_protocol(rc, &rc_proto);
460 460
461 rc->input_name = ir->name; 461 rc->device_name = ir->name;
462 rc->input_phys = ir->phys; 462 rc->input_phys = ir->phys;
463 rc->input_id.bustype = BUS_USB; 463 rc->input_id.bustype = BUS_USB;
464 rc->input_id.version = 1; 464 rc->input_id.version = 1;
diff --git a/drivers/media/usb/tm6000/tm6000-video.c b/drivers/media/usb/tm6000/tm6000-video.c
index 7e960d0a5b92..ec8c4d2534dc 100644
--- a/drivers/media/usb/tm6000/tm6000-video.c
+++ b/drivers/media/usb/tm6000/tm6000-video.c
@@ -801,7 +801,7 @@ static void buffer_release(struct videobuf_queue *vq, struct videobuf_buffer *vb
801 free_buffer(vq, buf); 801 free_buffer(vq, buf);
802} 802}
803 803
804static struct videobuf_queue_ops tm6000_video_qops = { 804static const struct videobuf_queue_ops tm6000_video_qops = {
805 .buf_setup = buffer_setup, 805 .buf_setup = buffer_setup,
806 .buf_prepare = buffer_prepare, 806 .buf_prepare = buffer_prepare,
807 .buf_queue = buffer_queue, 807 .buf_queue = buffer_queue,
@@ -1532,7 +1532,7 @@ static int tm6000_mmap(struct file *file, struct vm_area_struct * vma)
1532 return res; 1532 return res;
1533} 1533}
1534 1534
1535static struct v4l2_file_operations tm6000_fops = { 1535static const struct v4l2_file_operations tm6000_fops = {
1536 .owner = THIS_MODULE, 1536 .owner = THIS_MODULE,
1537 .open = tm6000_open, 1537 .open = tm6000_open,
1538 .release = tm6000_release, 1538 .release = tm6000_release,
diff --git a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
index 361e40b56045..b842f367249f 100644
--- a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
@@ -1640,7 +1640,7 @@ static void frontend_init(struct ttusb* ttusb)
1640 1640
1641 1641
1642 1642
1643static struct i2c_algorithm ttusb_dec_algo = { 1643static const struct i2c_algorithm ttusb_dec_algo = {
1644 .master_xfer = master_xfer, 1644 .master_xfer = master_xfer,
1645 .functionality = functionality, 1645 .functionality = functionality,
1646}; 1646};
@@ -1795,7 +1795,7 @@ static void ttusb_disconnect(struct usb_interface *intf)
1795 dprintk("%s: TTUSB DVB disconnected\n", __func__); 1795 dprintk("%s: TTUSB DVB disconnected\n", __func__);
1796} 1796}
1797 1797
1798static struct usb_device_id ttusb_table[] = { 1798static const struct usb_device_id ttusb_table[] = {
1799 {USB_DEVICE(0xb48, 0x1003)}, 1799 {USB_DEVICE(0xb48, 0x1003)},
1800 {USB_DEVICE(0xb48, 0x1004)}, 1800 {USB_DEVICE(0xb48, 0x1004)},
1801 {USB_DEVICE(0xb48, 0x1005)}, 1801 {USB_DEVICE(0xb48, 0x1005)},
diff --git a/drivers/media/usb/ttusb-dec/ttusb_dec.c b/drivers/media/usb/ttusb-dec/ttusb_dec.c
index 01c7e6d4481c..cdefb5dfbbdc 100644
--- a/drivers/media/usb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/usb/ttusb-dec/ttusb_dec.c
@@ -1791,7 +1791,7 @@ static void ttusb_dec_set_model(struct ttusb_dec *dec,
1791 } 1791 }
1792} 1792}
1793 1793
1794static struct usb_device_id ttusb_dec_table[] = { 1794static const struct usb_device_id ttusb_dec_table[] = {
1795 {USB_DEVICE(0x0b48, 0x1006)}, /* DEC3000-s */ 1795 {USB_DEVICE(0x0b48, 0x1006)}, /* DEC3000-s */
1796 /*{USB_DEVICE(0x0b48, 0x1007)}, Unconfirmed */ 1796 /*{USB_DEVICE(0x0b48, 0x1007)}, Unconfirmed */
1797 {USB_DEVICE(0x0b48, 0x1008)}, /* DEC2000-t */ 1797 {USB_DEVICE(0x0b48, 0x1008)}, /* DEC2000-t */
diff --git a/drivers/media/usb/usbtv/usbtv-audio.c b/drivers/media/usb/usbtv/usbtv-audio.c
index 9db31db7d9ac..2c2ca77fa01f 100644
--- a/drivers/media/usb/usbtv/usbtv-audio.c
+++ b/drivers/media/usb/usbtv/usbtv-audio.c
@@ -43,7 +43,7 @@
43 43
44#include "usbtv.h" 44#include "usbtv.h"
45 45
46static struct snd_pcm_hardware snd_usbtv_digital_hw = { 46static const struct snd_pcm_hardware snd_usbtv_digital_hw = {
47 .info = SNDRV_PCM_INFO_BATCH | 47 .info = SNDRV_PCM_INFO_BATCH |
48 SNDRV_PCM_INFO_MMAP | 48 SNDRV_PCM_INFO_MMAP |
49 SNDRV_PCM_INFO_INTERLEAVED | 49 SNDRV_PCM_INFO_INTERLEAVED |
diff --git a/drivers/media/usb/usbtv/usbtv-core.c b/drivers/media/usb/usbtv/usbtv-core.c
index ceb953be0770..f06f09a0876e 100644
--- a/drivers/media/usb/usbtv/usbtv-core.c
+++ b/drivers/media/usb/usbtv/usbtv-core.c
@@ -142,7 +142,7 @@ static void usbtv_disconnect(struct usb_interface *intf)
142 v4l2_device_put(&usbtv->v4l2_dev); 142 v4l2_device_put(&usbtv->v4l2_dev);
143} 143}
144 144
145static struct usb_device_id usbtv_id_table[] = { 145static const struct usb_device_id usbtv_id_table[] = {
146 { USB_DEVICE(0x1b71, 0x3002) }, 146 { USB_DEVICE(0x1b71, 0x3002) },
147 {} 147 {}
148}; 148};
diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index 8135614f395a..95b5f4319ec2 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -629,7 +629,7 @@ static struct v4l2_ioctl_ops usbtv_ioctl_ops = {
629 .vidioc_streamoff = vb2_ioctl_streamoff, 629 .vidioc_streamoff = vb2_ioctl_streamoff,
630}; 630};
631 631
632static struct v4l2_file_operations usbtv_fops = { 632static const struct v4l2_file_operations usbtv_fops = {
633 .owner = THIS_MODULE, 633 .owner = THIS_MODULE,
634 .unlocked_ioctl = video_ioctl2, 634 .unlocked_ioctl = video_ioctl2,
635 .mmap = vb2_fop_mmap, 635 .mmap = vb2_fop_mmap,
diff --git a/drivers/media/usb/usbvision/usbvision-i2c.c b/drivers/media/usb/usbvision/usbvision-i2c.c
index fdf6b6e285da..837bd4d9db41 100644
--- a/drivers/media/usb/usbvision/usbvision-i2c.c
+++ b/drivers/media/usb/usbvision/usbvision-i2c.c
@@ -163,7 +163,7 @@ static u32 functionality(struct i2c_adapter *adap)
163 163
164/* -----exported algorithm data: ------------------------------------- */ 164/* -----exported algorithm data: ------------------------------------- */
165 165
166static struct i2c_algorithm usbvision_algo = { 166static const struct i2c_algorithm usbvision_algo = {
167 .master_xfer = usbvision_i2c_xfer, 167 .master_xfer = usbvision_i2c_xfer,
168 .smbus_xfer = NULL, 168 .smbus_xfer = NULL,
169 .functionality = functionality, 169 .functionality = functionality,
@@ -173,7 +173,7 @@ static struct i2c_algorithm usbvision_algo = {
173/* ----------------------------------------------------------------------- */ 173/* ----------------------------------------------------------------------- */
174/* usbvision specific I2C functions */ 174/* usbvision specific I2C functions */
175/* ----------------------------------------------------------------------- */ 175/* ----------------------------------------------------------------------- */
176static struct i2c_adapter i2c_adap_template; 176static const struct i2c_adapter i2c_adap_template;
177 177
178int usbvision_i2c_register(struct usb_usbvision *usbvision) 178int usbvision_i2c_register(struct usb_usbvision *usbvision)
179{ 179{
@@ -187,8 +187,9 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision)
187 187
188 usbvision->i2c_adap = i2c_adap_template; 188 usbvision->i2c_adap = i2c_adap_template;
189 189
190 sprintf(usbvision->i2c_adap.name, "%s-%d-%s", i2c_adap_template.name, 190 snprintf(usbvision->i2c_adap.name, sizeof(usbvision->i2c_adap.name),
191 usbvision->dev->bus->busnum, usbvision->dev->devpath); 191 "usbvision-%d-%s",
192 usbvision->dev->bus->busnum, usbvision->dev->devpath);
192 PDEBUG(DBG_I2C, "Adaptername: %s", usbvision->i2c_adap.name); 193 PDEBUG(DBG_I2C, "Adaptername: %s", usbvision->i2c_adap.name);
193 usbvision->i2c_adap.dev.parent = &usbvision->dev->dev; 194 usbvision->i2c_adap.dev.parent = &usbvision->dev->dev;
194 195
@@ -440,7 +441,7 @@ static int usbvision_i2c_read(struct usb_usbvision *usbvision, unsigned char add
440 return rdcount; 441 return rdcount;
441} 442}
442 443
443static struct i2c_adapter i2c_adap_template = { 444static const struct i2c_adapter i2c_adap_template = {
444 .owner = THIS_MODULE, 445 .owner = THIS_MODULE,
445 .name = "usbvision", 446 .name = "usbvision",
446}; 447};
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c
index 756322c4ac05..960272d3c924 100644
--- a/drivers/media/usb/usbvision/usbvision-video.c
+++ b/drivers/media/usb/usbvision/usbvision-video.c
@@ -904,7 +904,7 @@ static ssize_t usbvision_read(struct file *file, char __user *buf,
904 PDEBUG(DBG_IO, "%s: %ld bytes, noblock=%d", __func__, 904 PDEBUG(DBG_IO, "%s: %ld bytes, noblock=%d", __func__,
905 (unsigned long)count, noblock); 905 (unsigned long)count, noblock);
906 906
907 if (!USBVISION_IS_OPERATIONAL(usbvision) || (buf == NULL)) 907 if (!USBVISION_IS_OPERATIONAL(usbvision) || !buf)
908 return -EFAULT; 908 return -EFAULT;
909 909
910 /* This entry point is compatible with the mmap routines 910 /* This entry point is compatible with the mmap routines
@@ -1234,7 +1234,7 @@ static void usbvision_vdev_init(struct usb_usbvision *usbvision,
1234{ 1234{
1235 struct usb_device *usb_dev = usbvision->dev; 1235 struct usb_device *usb_dev = usbvision->dev;
1236 1236
1237 if (usb_dev == NULL) { 1237 if (!usb_dev) {
1238 dev_err(&usbvision->dev->dev, 1238 dev_err(&usbvision->dev->dev,
1239 "%s: usbvision->dev is not set\n", __func__); 1239 "%s: usbvision->dev is not set\n", __func__);
1240 return; 1240 return;
@@ -1319,8 +1319,8 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev,
1319{ 1319{
1320 struct usb_usbvision *usbvision; 1320 struct usb_usbvision *usbvision;
1321 1321
1322 usbvision = kzalloc(sizeof(struct usb_usbvision), GFP_KERNEL); 1322 usbvision = kzalloc(sizeof(*usbvision), GFP_KERNEL);
1323 if (usbvision == NULL) 1323 if (!usbvision)
1324 return NULL; 1324 return NULL;
1325 1325
1326 usbvision->dev = dev; 1326 usbvision->dev = dev;
@@ -1334,7 +1334,7 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev,
1334 1334
1335 /* prepare control urb for control messages during interrupts */ 1335 /* prepare control urb for control messages during interrupts */
1336 usbvision->ctrl_urb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); 1336 usbvision->ctrl_urb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL);
1337 if (usbvision->ctrl_urb == NULL) 1337 if (!usbvision->ctrl_urb)
1338 goto err_unreg; 1338 goto err_unreg;
1339 1339
1340 return usbvision; 1340 return usbvision;
@@ -1380,7 +1380,7 @@ static void usbvision_configure_video(struct usb_usbvision *usbvision)
1380{ 1380{
1381 int model; 1381 int model;
1382 1382
1383 if (usbvision == NULL) 1383 if (!usbvision)
1384 return; 1384 return;
1385 1385
1386 model = usbvision->dev_model; 1386 model = usbvision->dev_model;
@@ -1474,7 +1474,7 @@ static int usbvision_probe(struct usb_interface *intf,
1474 } 1474 }
1475 1475
1476 usbvision = usbvision_alloc(dev, intf); 1476 usbvision = usbvision_alloc(dev, intf);
1477 if (usbvision == NULL) { 1477 if (!usbvision) {
1478 dev_err(&intf->dev, "%s: couldn't allocate USBVision struct\n", __func__); 1478 dev_err(&intf->dev, "%s: couldn't allocate USBVision struct\n", __func__);
1479 ret = -ENOMEM; 1479 ret = -ENOMEM;
1480 goto err_usb; 1480 goto err_usb;
@@ -1494,8 +1494,7 @@ static int usbvision_probe(struct usb_interface *intf,
1494 usbvision->num_alt = uif->num_altsetting; 1494 usbvision->num_alt = uif->num_altsetting;
1495 PDEBUG(DBG_PROBE, "Alternate settings: %i", usbvision->num_alt); 1495 PDEBUG(DBG_PROBE, "Alternate settings: %i", usbvision->num_alt);
1496 usbvision->alt_max_pkt_size = kmalloc(32 * usbvision->num_alt, GFP_KERNEL); 1496 usbvision->alt_max_pkt_size = kmalloc(32 * usbvision->num_alt, GFP_KERNEL);
1497 if (usbvision->alt_max_pkt_size == NULL) { 1497 if (!usbvision->alt_max_pkt_size) {
1498 dev_err(&intf->dev, "usbvision: out of memory!\n");
1499 ret = -ENOMEM; 1498 ret = -ENOMEM;
1500 goto err_pkt; 1499 goto err_pkt;
1501 } 1500 }
@@ -1566,7 +1565,7 @@ static void usbvision_disconnect(struct usb_interface *intf)
1566 1565
1567 PDEBUG(DBG_PROBE, ""); 1566 PDEBUG(DBG_PROBE, "");
1568 1567
1569 if (usbvision == NULL) { 1568 if (!usbvision) {
1570 pr_err("%s: usb_get_intfdata() failed\n", __func__); 1569 pr_err("%s: usb_get_intfdata() failed\n", __func__);
1571 return; 1570 return;
1572 } 1571 }
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index c2ee6e39fd0c..20397aba6849 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -2002,6 +2002,13 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
2002 goto done; 2002 goto done;
2003 } 2003 }
2004 2004
2005 /* Validate the user-provided bit-size and offset */
2006 if (mapping->size > 32 ||
2007 mapping->offset + mapping->size > ctrl->info.size * 8) {
2008 ret = -EINVAL;
2009 goto done;
2010 }
2011
2005 list_for_each_entry(map, &ctrl->info.mappings, list) { 2012 list_for_each_entry(map, &ctrl->info.mappings, list) {
2006 if (mapping->id == map->id) { 2013 if (mapping->id == map->id) {
2007 uvc_trace(UVC_TRACE_CONTROL, "Can't add mapping '%s', " 2014 uvc_trace(UVC_TRACE_CONTROL, "Can't add mapping '%s', "
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 70842c5af05b..6d22b22cb35b 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1802,8 +1802,9 @@ static int uvc_scan_device(struct uvc_device *dev)
1802 * already been canceled by the USB core. There is no need to kill the 1802 * already been canceled by the USB core. There is no need to kill the
1803 * interrupt URB manually. 1803 * interrupt URB manually.
1804 */ 1804 */
1805static void uvc_delete(struct uvc_device *dev) 1805static void uvc_delete(struct kref *kref)
1806{ 1806{
1807 struct uvc_device *dev = container_of(kref, struct uvc_device, ref);
1807 struct list_head *p, *n; 1808 struct list_head *p, *n;
1808 1809
1809 uvc_status_cleanup(dev); 1810 uvc_status_cleanup(dev);
@@ -1854,11 +1855,7 @@ static void uvc_release(struct video_device *vdev)
1854 struct uvc_streaming *stream = video_get_drvdata(vdev); 1855 struct uvc_streaming *stream = video_get_drvdata(vdev);
1855 struct uvc_device *dev = stream->dev; 1856 struct uvc_device *dev = stream->dev;
1856 1857
1857 /* Decrement the registered streams count and delete the device when it 1858 kref_put(&dev->ref, uvc_delete);
1858 * reaches zero.
1859 */
1860 if (atomic_dec_and_test(&dev->nstreams))
1861 uvc_delete(dev);
1862} 1859}
1863 1860
1864/* 1861/*
@@ -1870,10 +1867,10 @@ static void uvc_unregister_video(struct uvc_device *dev)
1870 1867
1871 /* Unregistering all video devices might result in uvc_delete() being 1868 /* Unregistering all video devices might result in uvc_delete() being
1872 * called from inside the loop if there's no open file handle. To avoid 1869 * called from inside the loop if there's no open file handle. To avoid
1873 * that, increment the stream count before iterating over the streams 1870 * that, increment the refcount before iterating over the streams and
1874 * and decrement it when done. 1871 * decrement it when done.
1875 */ 1872 */
1876 atomic_inc(&dev->nstreams); 1873 kref_get(&dev->ref);
1877 1874
1878 list_for_each_entry(stream, &dev->streams, list) { 1875 list_for_each_entry(stream, &dev->streams, list) {
1879 if (!video_is_registered(&stream->vdev)) 1876 if (!video_is_registered(&stream->vdev))
@@ -1884,11 +1881,7 @@ static void uvc_unregister_video(struct uvc_device *dev)
1884 uvc_debugfs_cleanup_stream(stream); 1881 uvc_debugfs_cleanup_stream(stream);
1885 } 1882 }
1886 1883
1887 /* Decrement the stream count and call uvc_delete explicitly if there 1884 kref_put(&dev->ref, uvc_delete);
1888 * are no stream left.
1889 */
1890 if (atomic_dec_and_test(&dev->nstreams))
1891 uvc_delete(dev);
1892} 1885}
1893 1886
1894static int uvc_register_video(struct uvc_device *dev, 1887static int uvc_register_video(struct uvc_device *dev,
@@ -1946,7 +1939,7 @@ static int uvc_register_video(struct uvc_device *dev,
1946 else 1939 else
1947 stream->chain->caps |= V4L2_CAP_VIDEO_OUTPUT; 1940 stream->chain->caps |= V4L2_CAP_VIDEO_OUTPUT;
1948 1941
1949 atomic_inc(&dev->nstreams); 1942 kref_get(&dev->ref);
1950 return 0; 1943 return 0;
1951} 1944}
1952 1945
@@ -2031,7 +2024,7 @@ static int uvc_probe(struct usb_interface *intf,
2031 INIT_LIST_HEAD(&dev->entities); 2024 INIT_LIST_HEAD(&dev->entities);
2032 INIT_LIST_HEAD(&dev->chains); 2025 INIT_LIST_HEAD(&dev->chains);
2033 INIT_LIST_HEAD(&dev->streams); 2026 INIT_LIST_HEAD(&dev->streams);
2034 atomic_set(&dev->nstreams, 0); 2027 kref_init(&dev->ref);
2035 atomic_set(&dev->nmappings, 0); 2028 atomic_set(&dev->nmappings, 0);
2036 mutex_init(&dev->lock); 2029 mutex_init(&dev->lock);
2037 2030
@@ -2096,7 +2089,6 @@ static int uvc_probe(struct usb_interface *intf,
2096 sizeof(dev->mdev.serial)); 2089 sizeof(dev->mdev.serial));
2097 strcpy(dev->mdev.bus_info, udev->devpath); 2090 strcpy(dev->mdev.bus_info, udev->devpath);
2098 dev->mdev.hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); 2091 dev->mdev.hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
2099 dev->mdev.driver_version = LINUX_VERSION_CODE;
2100 media_device_init(&dev->mdev); 2092 media_device_init(&dev->mdev);
2101 2093
2102 dev->vdev.mdev = &dev->mdev; 2094 dev->vdev.mdev = &dev->mdev;
@@ -2284,7 +2276,7 @@ MODULE_PARM_DESC(timeout, "Streaming control requests timeout");
2284 * VENDOR_SPEC because they don't announce themselves as UVC devices, even 2276 * VENDOR_SPEC because they don't announce themselves as UVC devices, even
2285 * though they are compliant. 2277 * though they are compliant.
2286 */ 2278 */
2287static struct usb_device_id uvc_ids[] = { 2279static const struct usb_device_id uvc_ids[] = {
2288 /* LogiLink Wireless Webcam */ 2280 /* LogiLink Wireless Webcam */
2289 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 2281 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
2290 | USB_DEVICE_ID_MATCH_INT_INFO, 2282 | USB_DEVICE_ID_MATCH_INT_INFO,
diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c
index ac386bb547e6..554063c07d7a 100644
--- a/drivers/media/usb/uvc/uvc_entity.c
+++ b/drivers/media/usb/uvc/uvc_entity.c
@@ -61,7 +61,7 @@ static int uvc_mc_create_links(struct uvc_video_chain *chain,
61 return 0; 61 return 0;
62} 62}
63 63
64static struct v4l2_subdev_ops uvc_subdev_ops = { 64static const struct v4l2_subdev_ops uvc_subdev_ops = {
65}; 65};
66 66
67void uvc_mc_cleanup_entity(struct uvc_entity *entity) 67void uvc_mc_cleanup_entity(struct uvc_entity *entity)
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index aa2199775cb8..c8d78b2f3de4 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -82,9 +82,14 @@ static int uvc_queue_setup(struct vb2_queue *vq,
82 struct uvc_streaming *stream = uvc_queue_to_stream(queue); 82 struct uvc_streaming *stream = uvc_queue_to_stream(queue);
83 unsigned size = stream->ctrl.dwMaxVideoFrameSize; 83 unsigned size = stream->ctrl.dwMaxVideoFrameSize;
84 84
85 /* Make sure the image size is large enough. */ 85 /*
86 * When called with plane sizes, validate them. The driver supports
87 * single planar formats only, and requires buffers to be large enough
88 * to store a complete frame.
89 */
86 if (*nplanes) 90 if (*nplanes)
87 return sizes[0] < size ? -EINVAL : 0; 91 return *nplanes != 1 || sizes[0] < size ? -EINVAL : 0;
92
88 *nplanes = 1; 93 *nplanes = 1;
89 sizes[0] = size; 94 sizes[0] = size;
90 return 0; 95 return 0;
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 15e415e32c7f..34c7ee6cc9e5 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -166,7 +166,7 @@
166/* Maximum status buffer size in bytes of interrupt URB. */ 166/* Maximum status buffer size in bytes of interrupt URB. */
167#define UVC_MAX_STATUS_SIZE 16 167#define UVC_MAX_STATUS_SIZE 16
168 168
169#define UVC_CTRL_CONTROL_TIMEOUT 300 169#define UVC_CTRL_CONTROL_TIMEOUT 500
170#define UVC_CTRL_STREAMING_TIMEOUT 5000 170#define UVC_CTRL_STREAMING_TIMEOUT 5000
171 171
172/* Maximum allowed number of control mappings per device */ 172/* Maximum allowed number of control mappings per device */
@@ -575,7 +575,7 @@ struct uvc_device {
575 575
576 /* Video Streaming interfaces */ 576 /* Video Streaming interfaces */
577 struct list_head streams; 577 struct list_head streams;
578 atomic_t nstreams; 578 struct kref ref;
579 579
580 /* Status Interrupt Endpoint */ 580 /* Status Interrupt Endpoint */
581 struct usb_host_endpoint *int_ep; 581 struct usb_host_endpoint *int_ep;
diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c
index efdcd5bd6a4c..4ff8d0aed015 100644
--- a/drivers/media/usb/zr364xx/zr364xx.c
+++ b/drivers/media/usb/zr364xx/zr364xx.c
@@ -93,7 +93,7 @@ MODULE_PARM_DESC(mode, "0 = 320x240, 1 = 160x120, 2 = 640x480");
93 93
94/* Devices supported by this driver 94/* Devices supported by this driver
95 * .driver_info contains the init method used by the camera */ 95 * .driver_info contains the init method used by the camera */
96static struct usb_device_id device_table[] = { 96static const struct usb_device_id device_table[] = {
97 {USB_DEVICE(0x08ca, 0x0109), .driver_info = METHOD0 }, 97 {USB_DEVICE(0x08ca, 0x0109), .driver_info = METHOD0 },
98 {USB_DEVICE(0x041e, 0x4024), .driver_info = METHOD0 }, 98 {USB_DEVICE(0x041e, 0x4024), .driver_info = METHOD0 },
99 {USB_DEVICE(0x0d64, 0x0108), .driver_info = METHOD0 }, 99 {USB_DEVICE(0x0d64, 0x0108), .driver_info = METHOD0 },
@@ -439,7 +439,7 @@ static void buffer_release(struct videobuf_queue *vq,
439 free_buffer(vq, buf); 439 free_buffer(vq, buf);
440} 440}
441 441
442static struct videobuf_queue_ops zr364xx_video_qops = { 442static const struct videobuf_queue_ops zr364xx_video_qops = {
443 .buf_setup = buffer_setup, 443 .buf_setup = buffer_setup,
444 .buf_prepare = buffer_prepare, 444 .buf_prepare = buffer_prepare,
445 .buf_queue = buffer_queue, 445 .buf_queue = buffer_queue,
@@ -1335,7 +1335,7 @@ static const struct v4l2_ioctl_ops zr364xx_ioctl_ops = {
1335 .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 1335 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
1336}; 1336};
1337 1337
1338static struct video_device zr364xx_template = { 1338static const struct video_device zr364xx_template = {
1339 .name = DRIVER_DESC, 1339 .name = DRIVER_DESC,
1340 .fops = &zr364xx_fops, 1340 .fops = &zr364xx_fops,
1341 .ioctl_ops = &zr364xx_ioctl_ops, 1341 .ioctl_ops = &zr364xx_ioctl_ops,
diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index 851f128eba22..d741a8e0fdac 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -44,12 +44,7 @@ static bool match_devname(struct v4l2_subdev *sd,
44 44
45static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) 45static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
46{ 46{
47 if (!is_of_node(sd->fwnode) || !is_of_node(asd->match.fwnode.fwnode)) 47 return sd->fwnode == asd->match.fwnode.fwnode;
48 return sd->fwnode == asd->match.fwnode.fwnode;
49
50 return !of_node_cmp(of_node_full_name(to_of_node(sd->fwnode)),
51 of_node_full_name(
52 to_of_node(asd->match.fwnode.fwnode)));
53} 48}
54 49
55static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) 50static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
diff --git a/drivers/media/v4l2-core/v4l2-clk.c b/drivers/media/v4l2-core/v4l2-clk.c
index 297e10e69898..90628d7a04de 100644
--- a/drivers/media/v4l2-core/v4l2-clk.c
+++ b/drivers/media/v4l2-core/v4l2-clk.c
@@ -61,8 +61,7 @@ struct v4l2_clk *v4l2_clk_get(struct device *dev, const char *id)
61 61
62 /* if dev_name is not found, try use the OF name to find again */ 62 /* if dev_name is not found, try use the OF name to find again */
63 if (PTR_ERR(clk) == -ENODEV && dev->of_node) { 63 if (PTR_ERR(clk) == -ENODEV && dev->of_node) {
64 v4l2_clk_name_of(clk_name, sizeof(clk_name), 64 v4l2_clk_name_of(clk_name, sizeof(clk_name), dev->of_node);
65 of_node_full_name(dev->of_node));
66 clk = v4l2_clk_find(clk_name); 65 clk = v4l2_clk_find(clk_name);
67 } 66 }
68 67
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index 6f52970f8b54..821f2aa299ae 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -43,6 +43,7 @@ struct v4l2_window32 {
43 compat_caddr_t clips; /* actually struct v4l2_clip32 * */ 43 compat_caddr_t clips; /* actually struct v4l2_clip32 * */
44 __u32 clipcount; 44 __u32 clipcount;
45 compat_caddr_t bitmap; 45 compat_caddr_t bitmap;
46 __u8 global_alpha;
46}; 47};
47 48
48static int get_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up) 49static int get_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up)
@@ -51,7 +52,8 @@ static int get_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user
51 copy_from_user(&kp->w, &up->w, sizeof(up->w)) || 52 copy_from_user(&kp->w, &up->w, sizeof(up->w)) ||
52 get_user(kp->field, &up->field) || 53 get_user(kp->field, &up->field) ||
53 get_user(kp->chromakey, &up->chromakey) || 54 get_user(kp->chromakey, &up->chromakey) ||
54 get_user(kp->clipcount, &up->clipcount)) 55 get_user(kp->clipcount, &up->clipcount) ||
56 get_user(kp->global_alpha, &up->global_alpha))
55 return -EFAULT; 57 return -EFAULT;
56 if (kp->clipcount > 2048) 58 if (kp->clipcount > 2048)
57 return -EINVAL; 59 return -EINVAL;
@@ -84,7 +86,8 @@ static int put_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user
84 if (copy_to_user(&up->w, &kp->w, sizeof(kp->w)) || 86 if (copy_to_user(&up->w, &kp->w, sizeof(kp->w)) ||
85 put_user(kp->field, &up->field) || 87 put_user(kp->field, &up->field) ||
86 put_user(kp->chromakey, &up->chromakey) || 88 put_user(kp->chromakey, &up->chromakey) ||
87 put_user(kp->clipcount, &up->clipcount)) 89 put_user(kp->clipcount, &up->clipcount) ||
90 put_user(kp->global_alpha, &up->global_alpha))
88 return -EFAULT; 91 return -EFAULT;
89 return 0; 92 return 0;
90} 93}
@@ -627,7 +630,8 @@ struct v4l2_input32 {
627 __u32 tuner; /* Associated tuner */ 630 __u32 tuner; /* Associated tuner */
628 compat_u64 std; 631 compat_u64 std;
629 __u32 status; 632 __u32 status;
630 __u32 reserved[4]; 633 __u32 capabilities;
634 __u32 reserved[3];
631}; 635};
632 636
633/* The 64-bit v4l2_input struct has extra padding at the end of the struct. 637/* The 64-bit v4l2_input struct has extra padding at the end of the struct.
@@ -796,7 +800,8 @@ static int put_v4l2_event32(struct v4l2_event *kp, struct v4l2_event32 __user *u
796 copy_to_user(&up->u, &kp->u, sizeof(kp->u)) || 800 copy_to_user(&up->u, &kp->u, sizeof(kp->u)) ||
797 put_user(kp->pending, &up->pending) || 801 put_user(kp->pending, &up->pending) ||
798 put_user(kp->sequence, &up->sequence) || 802 put_user(kp->sequence, &up->sequence) ||
799 compat_put_timespec(&kp->timestamp, &up->timestamp) || 803 put_user(kp->timestamp.tv_sec, &up->timestamp.tv_sec) ||
804 put_user(kp->timestamp.tv_nsec, &up->timestamp.tv_nsec) ||
800 put_user(kp->id, &up->id) || 805 put_user(kp->id, &up->id) ||
801 copy_to_user(up->reserved, kp->reserved, 8 * sizeof(__u32))) 806 copy_to_user(up->reserved, kp->reserved, 8 * sizeof(__u32)))
802 return -EFAULT; 807 return -EFAULT;
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
index 7b8288108e8a..4ceef217de83 100644
--- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
+++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
@@ -18,7 +18,7 @@
18#include <media/v4l2-flash-led-class.h> 18#include <media/v4l2-flash-led-class.h>
19 19
20#define has_flash_op(v4l2_flash, op) \ 20#define has_flash_op(v4l2_flash, op) \
21 (v4l2_flash && v4l2_flash->ops->op) 21 (v4l2_flash && v4l2_flash->ops && v4l2_flash->ops->op)
22 22
23#define call_flash_op(v4l2_flash, op, arg) \ 23#define call_flash_op(v4l2_flash, op, arg) \
24 (has_flash_op(v4l2_flash, op) ? \ 24 (has_flash_op(v4l2_flash, op) ? \
@@ -110,7 +110,7 @@ static void v4l2_flash_set_led_brightness(struct v4l2_flash *v4l2_flash,
110 led_set_brightness_sync(&v4l2_flash->fled_cdev->led_cdev, 110 led_set_brightness_sync(&v4l2_flash->fled_cdev->led_cdev,
111 brightness); 111 brightness);
112 } else { 112 } else {
113 led_set_brightness_sync(&v4l2_flash->iled_cdev->led_cdev, 113 led_set_brightness_sync(v4l2_flash->iled_cdev,
114 brightness); 114 brightness);
115 } 115 }
116} 116}
@@ -133,7 +133,7 @@ static int v4l2_flash_update_led_brightness(struct v4l2_flash *v4l2_flash,
133 return 0; 133 return 0;
134 led_cdev = &v4l2_flash->fled_cdev->led_cdev; 134 led_cdev = &v4l2_flash->fled_cdev->led_cdev;
135 } else { 135 } else {
136 led_cdev = &v4l2_flash->iled_cdev->led_cdev; 136 led_cdev = v4l2_flash->iled_cdev;
137 } 137 }
138 138
139 ret = led_update_brightness(led_cdev); 139 ret = led_update_brightness(led_cdev);
@@ -197,7 +197,7 @@ static int v4l2_flash_s_ctrl(struct v4l2_ctrl *c)
197{ 197{
198 struct v4l2_flash *v4l2_flash = v4l2_ctrl_to_v4l2_flash(c); 198 struct v4l2_flash *v4l2_flash = v4l2_ctrl_to_v4l2_flash(c);
199 struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev; 199 struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev;
200 struct led_classdev *led_cdev = &fled_cdev->led_cdev; 200 struct led_classdev *led_cdev = fled_cdev ? &fled_cdev->led_cdev : NULL;
201 struct v4l2_ctrl **ctrls = v4l2_flash->ctrls; 201 struct v4l2_ctrl **ctrls = v4l2_flash->ctrls;
202 bool external_strobe; 202 bool external_strobe;
203 int ret = 0; 203 int ret = 0;
@@ -299,11 +299,26 @@ static void __fill_ctrl_init_data(struct v4l2_flash *v4l2_flash,
299 struct v4l2_flash_ctrl_data *ctrl_init_data) 299 struct v4l2_flash_ctrl_data *ctrl_init_data)
300{ 300{
301 struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev; 301 struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev;
302 const struct led_flash_ops *fled_cdev_ops = fled_cdev->ops; 302 struct led_classdev *led_cdev = fled_cdev ? &fled_cdev->led_cdev : NULL;
303 struct led_classdev *led_cdev = &fled_cdev->led_cdev;
304 struct v4l2_ctrl_config *ctrl_cfg; 303 struct v4l2_ctrl_config *ctrl_cfg;
305 u32 mask; 304 u32 mask;
306 305
306 /* Init INDICATOR_INTENSITY ctrl data */
307 if (v4l2_flash->iled_cdev) {
308 ctrl_init_data[INDICATOR_INTENSITY].cid =
309 V4L2_CID_FLASH_INDICATOR_INTENSITY;
310 ctrl_cfg = &ctrl_init_data[INDICATOR_INTENSITY].config;
311 __lfs_to_v4l2_ctrl_config(&flash_cfg->intensity,
312 ctrl_cfg);
313 ctrl_cfg->id = V4L2_CID_FLASH_INDICATOR_INTENSITY;
314 ctrl_cfg->min = 0;
315 ctrl_cfg->flags = V4L2_CTRL_FLAG_VOLATILE |
316 V4L2_CTRL_FLAG_EXECUTE_ON_WRITE;
317 }
318
319 if (!led_cdev || WARN_ON(!(led_cdev->flags & LED_DEV_CAP_FLASH)))
320 return;
321
307 /* Init FLASH_FAULT ctrl data */ 322 /* Init FLASH_FAULT ctrl data */
308 if (flash_cfg->flash_faults) { 323 if (flash_cfg->flash_faults) {
309 ctrl_init_data[FLASH_FAULT].cid = V4L2_CID_FLASH_FAULT; 324 ctrl_init_data[FLASH_FAULT].cid = V4L2_CID_FLASH_FAULT;
@@ -331,27 +346,11 @@ static void __fill_ctrl_init_data(struct v4l2_flash *v4l2_flash,
331 /* Init TORCH_INTENSITY ctrl data */ 346 /* Init TORCH_INTENSITY ctrl data */
332 ctrl_init_data[TORCH_INTENSITY].cid = V4L2_CID_FLASH_TORCH_INTENSITY; 347 ctrl_init_data[TORCH_INTENSITY].cid = V4L2_CID_FLASH_TORCH_INTENSITY;
333 ctrl_cfg = &ctrl_init_data[TORCH_INTENSITY].config; 348 ctrl_cfg = &ctrl_init_data[TORCH_INTENSITY].config;
334 __lfs_to_v4l2_ctrl_config(&flash_cfg->torch_intensity, ctrl_cfg); 349 __lfs_to_v4l2_ctrl_config(&flash_cfg->intensity, ctrl_cfg);
335 ctrl_cfg->id = V4L2_CID_FLASH_TORCH_INTENSITY; 350 ctrl_cfg->id = V4L2_CID_FLASH_TORCH_INTENSITY;
336 ctrl_cfg->flags = V4L2_CTRL_FLAG_VOLATILE | 351 ctrl_cfg->flags = V4L2_CTRL_FLAG_VOLATILE |
337 V4L2_CTRL_FLAG_EXECUTE_ON_WRITE; 352 V4L2_CTRL_FLAG_EXECUTE_ON_WRITE;
338 353
339 /* Init INDICATOR_INTENSITY ctrl data */
340 if (v4l2_flash->iled_cdev) {
341 ctrl_init_data[INDICATOR_INTENSITY].cid =
342 V4L2_CID_FLASH_INDICATOR_INTENSITY;
343 ctrl_cfg = &ctrl_init_data[INDICATOR_INTENSITY].config;
344 __lfs_to_v4l2_ctrl_config(&flash_cfg->indicator_intensity,
345 ctrl_cfg);
346 ctrl_cfg->id = V4L2_CID_FLASH_INDICATOR_INTENSITY;
347 ctrl_cfg->min = 0;
348 ctrl_cfg->flags = V4L2_CTRL_FLAG_VOLATILE |
349 V4L2_CTRL_FLAG_EXECUTE_ON_WRITE;
350 }
351
352 if (!(led_cdev->flags & LED_DEV_CAP_FLASH))
353 return;
354
355 /* Init FLASH_STROBE ctrl data */ 354 /* Init FLASH_STROBE ctrl data */
356 ctrl_init_data[FLASH_STROBE].cid = V4L2_CID_FLASH_STROBE; 355 ctrl_init_data[FLASH_STROBE].cid = V4L2_CID_FLASH_STROBE;
357 ctrl_cfg = &ctrl_init_data[FLASH_STROBE].config; 356 ctrl_cfg = &ctrl_init_data[FLASH_STROBE].config;
@@ -376,7 +375,7 @@ static void __fill_ctrl_init_data(struct v4l2_flash *v4l2_flash,
376 } 375 }
377 376
378 /* Init STROBE_STATUS ctrl data */ 377 /* Init STROBE_STATUS ctrl data */
379 if (fled_cdev_ops->strobe_get) { 378 if (has_flash_op(fled_cdev, strobe_get)) {
380 ctrl_init_data[STROBE_STATUS].cid = 379 ctrl_init_data[STROBE_STATUS].cid =
381 V4L2_CID_FLASH_STROBE_STATUS; 380 V4L2_CID_FLASH_STROBE_STATUS;
382 ctrl_cfg = &ctrl_init_data[STROBE_STATUS].config; 381 ctrl_cfg = &ctrl_init_data[STROBE_STATUS].config;
@@ -386,7 +385,7 @@ static void __fill_ctrl_init_data(struct v4l2_flash *v4l2_flash,
386 } 385 }
387 386
388 /* Init FLASH_TIMEOUT ctrl data */ 387 /* Init FLASH_TIMEOUT ctrl data */
389 if (fled_cdev_ops->timeout_set) { 388 if (has_flash_op(fled_cdev, timeout_set)) {
390 ctrl_init_data[FLASH_TIMEOUT].cid = V4L2_CID_FLASH_TIMEOUT; 389 ctrl_init_data[FLASH_TIMEOUT].cid = V4L2_CID_FLASH_TIMEOUT;
391 ctrl_cfg = &ctrl_init_data[FLASH_TIMEOUT].config; 390 ctrl_cfg = &ctrl_init_data[FLASH_TIMEOUT].config;
392 __lfs_to_v4l2_ctrl_config(&fled_cdev->timeout, ctrl_cfg); 391 __lfs_to_v4l2_ctrl_config(&fled_cdev->timeout, ctrl_cfg);
@@ -394,7 +393,7 @@ static void __fill_ctrl_init_data(struct v4l2_flash *v4l2_flash,
394 } 393 }
395 394
396 /* Init FLASH_INTENSITY ctrl data */ 395 /* Init FLASH_INTENSITY ctrl data */
397 if (fled_cdev_ops->flash_brightness_set) { 396 if (has_flash_op(fled_cdev, flash_brightness_set)) {
398 ctrl_init_data[FLASH_INTENSITY].cid = V4L2_CID_FLASH_INTENSITY; 397 ctrl_init_data[FLASH_INTENSITY].cid = V4L2_CID_FLASH_INTENSITY;
399 ctrl_cfg = &ctrl_init_data[FLASH_INTENSITY].config; 398 ctrl_cfg = &ctrl_init_data[FLASH_INTENSITY].config;
400 __lfs_to_v4l2_ctrl_config(&fled_cdev->brightness, ctrl_cfg); 399 __lfs_to_v4l2_ctrl_config(&fled_cdev->brightness, ctrl_cfg);
@@ -486,7 +485,9 @@ static int __sync_device_with_v4l2_controls(struct v4l2_flash *v4l2_flash)
486 struct v4l2_ctrl **ctrls = v4l2_flash->ctrls; 485 struct v4l2_ctrl **ctrls = v4l2_flash->ctrls;
487 int ret = 0; 486 int ret = 0;
488 487
489 v4l2_flash_set_led_brightness(v4l2_flash, ctrls[TORCH_INTENSITY]); 488 if (ctrls[TORCH_INTENSITY])
489 v4l2_flash_set_led_brightness(v4l2_flash,
490 ctrls[TORCH_INTENSITY]);
490 491
491 if (ctrls[INDICATOR_INTENSITY]) 492 if (ctrls[INDICATOR_INTENSITY])
492 v4l2_flash_set_led_brightness(v4l2_flash, 493 v4l2_flash_set_led_brightness(v4l2_flash,
@@ -528,24 +529,23 @@ static int v4l2_flash_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
528{ 529{
529 struct v4l2_flash *v4l2_flash = v4l2_subdev_to_v4l2_flash(sd); 530 struct v4l2_flash *v4l2_flash = v4l2_subdev_to_v4l2_flash(sd);
530 struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev; 531 struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev;
531 struct led_classdev *led_cdev = &fled_cdev->led_cdev; 532 struct led_classdev *led_cdev = fled_cdev ? &fled_cdev->led_cdev : NULL;
532 struct led_classdev_flash *iled_cdev = v4l2_flash->iled_cdev; 533 struct led_classdev *led_cdev_ind = v4l2_flash->iled_cdev;
533 struct led_classdev *led_cdev_ind = NULL;
534 int ret = 0; 534 int ret = 0;
535 535
536 if (!v4l2_fh_is_singular(&fh->vfh)) 536 if (!v4l2_fh_is_singular(&fh->vfh))
537 return 0; 537 return 0;
538 538
539 mutex_lock(&led_cdev->led_access); 539 if (led_cdev) {
540 540 mutex_lock(&led_cdev->led_access);
541 led_sysfs_disable(led_cdev);
542 led_trigger_remove(led_cdev);
543 541
544 mutex_unlock(&led_cdev->led_access); 542 led_sysfs_disable(led_cdev);
543 led_trigger_remove(led_cdev);
545 544
546 if (iled_cdev) { 545 mutex_unlock(&led_cdev->led_access);
547 led_cdev_ind = &iled_cdev->led_cdev; 546 }
548 547
548 if (led_cdev_ind) {
549 mutex_lock(&led_cdev_ind->led_access); 549 mutex_lock(&led_cdev_ind->led_access);
550 550
551 led_sysfs_disable(led_cdev_ind); 551 led_sysfs_disable(led_cdev_ind);
@@ -560,9 +560,11 @@ static int v4l2_flash_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
560 560
561 return 0; 561 return 0;
562out_sync_device: 562out_sync_device:
563 mutex_lock(&led_cdev->led_access); 563 if (led_cdev) {
564 led_sysfs_enable(led_cdev); 564 mutex_lock(&led_cdev->led_access);
565 mutex_unlock(&led_cdev->led_access); 565 led_sysfs_enable(led_cdev);
566 mutex_unlock(&led_cdev->led_access);
567 }
566 568
567 if (led_cdev_ind) { 569 if (led_cdev_ind) {
568 mutex_lock(&led_cdev_ind->led_access); 570 mutex_lock(&led_cdev_ind->led_access);
@@ -577,25 +579,26 @@ static int v4l2_flash_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
577{ 579{
578 struct v4l2_flash *v4l2_flash = v4l2_subdev_to_v4l2_flash(sd); 580 struct v4l2_flash *v4l2_flash = v4l2_subdev_to_v4l2_flash(sd);
579 struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev; 581 struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev;
580 struct led_classdev *led_cdev = &fled_cdev->led_cdev; 582 struct led_classdev *led_cdev = fled_cdev ? &fled_cdev->led_cdev : NULL;
581 struct led_classdev_flash *iled_cdev = v4l2_flash->iled_cdev; 583 struct led_classdev *led_cdev_ind = v4l2_flash->iled_cdev;
582 int ret = 0; 584 int ret = 0;
583 585
584 if (!v4l2_fh_is_singular(&fh->vfh)) 586 if (!v4l2_fh_is_singular(&fh->vfh))
585 return 0; 587 return 0;
586 588
587 mutex_lock(&led_cdev->led_access); 589 if (led_cdev) {
590 mutex_lock(&led_cdev->led_access);
588 591
589 if (v4l2_flash->ctrls[STROBE_SOURCE]) 592 if (v4l2_flash->ctrls[STROBE_SOURCE])
590 ret = v4l2_ctrl_s_ctrl(v4l2_flash->ctrls[STROBE_SOURCE], 593 ret = v4l2_ctrl_s_ctrl(
594 v4l2_flash->ctrls[STROBE_SOURCE],
591 V4L2_FLASH_STROBE_SOURCE_SOFTWARE); 595 V4L2_FLASH_STROBE_SOURCE_SOFTWARE);
592 led_sysfs_enable(led_cdev); 596 led_sysfs_enable(led_cdev);
593
594 mutex_unlock(&led_cdev->led_access);
595 597
596 if (iled_cdev) { 598 mutex_unlock(&led_cdev->led_access);
597 struct led_classdev *led_cdev_ind = &iled_cdev->led_cdev; 599 }
598 600
601 if (led_cdev_ind) {
599 mutex_lock(&led_cdev_ind->led_access); 602 mutex_lock(&led_cdev_ind->led_access);
600 led_sysfs_enable(led_cdev_ind); 603 led_sysfs_enable(led_cdev_ind);
601 mutex_unlock(&led_cdev_ind->led_access); 604 mutex_unlock(&led_cdev_ind->led_access);
@@ -611,25 +614,19 @@ static const struct v4l2_subdev_internal_ops v4l2_flash_subdev_internal_ops = {
611 614
612static const struct v4l2_subdev_ops v4l2_flash_subdev_ops; 615static const struct v4l2_subdev_ops v4l2_flash_subdev_ops;
613 616
614struct v4l2_flash *v4l2_flash_init( 617static struct v4l2_flash *__v4l2_flash_init(
615 struct device *dev, struct fwnode_handle *fwn, 618 struct device *dev, struct fwnode_handle *fwn,
616 struct led_classdev_flash *fled_cdev, 619 struct led_classdev_flash *fled_cdev, struct led_classdev *iled_cdev,
617 struct led_classdev_flash *iled_cdev, 620 const struct v4l2_flash_ops *ops, struct v4l2_flash_config *config)
618 const struct v4l2_flash_ops *ops,
619 struct v4l2_flash_config *config)
620{ 621{
621 struct v4l2_flash *v4l2_flash; 622 struct v4l2_flash *v4l2_flash;
622 struct led_classdev *led_cdev;
623 struct v4l2_subdev *sd; 623 struct v4l2_subdev *sd;
624 int ret; 624 int ret;
625 625
626 if (!fled_cdev || !ops || !config) 626 if (!config)
627 return ERR_PTR(-EINVAL); 627 return ERR_PTR(-EINVAL);
628 628
629 led_cdev = &fled_cdev->led_cdev; 629 v4l2_flash = devm_kzalloc(dev, sizeof(*v4l2_flash), GFP_KERNEL);
630
631 v4l2_flash = devm_kzalloc(led_cdev->dev, sizeof(*v4l2_flash),
632 GFP_KERNEL);
633 if (!v4l2_flash) 630 if (!v4l2_flash)
634 return ERR_PTR(-ENOMEM); 631 return ERR_PTR(-ENOMEM);
635 632
@@ -638,7 +635,7 @@ struct v4l2_flash *v4l2_flash_init(
638 v4l2_flash->iled_cdev = iled_cdev; 635 v4l2_flash->iled_cdev = iled_cdev;
639 v4l2_flash->ops = ops; 636 v4l2_flash->ops = ops;
640 sd->dev = dev; 637 sd->dev = dev;
641 sd->fwnode = fwn ? fwn : dev_fwnode(led_cdev->dev); 638 sd->fwnode = fwn ? fwn : dev_fwnode(dev);
642 v4l2_subdev_init(sd, &v4l2_flash_subdev_ops); 639 v4l2_subdev_init(sd, &v4l2_flash_subdev_ops);
643 sd->internal_ops = &v4l2_flash_subdev_internal_ops; 640 sd->internal_ops = &v4l2_flash_subdev_internal_ops;
644 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; 641 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
@@ -670,8 +667,26 @@ err_init_controls:
670 667
671 return ERR_PTR(ret); 668 return ERR_PTR(ret);
672} 669}
670
671struct v4l2_flash *v4l2_flash_init(
672 struct device *dev, struct fwnode_handle *fwn,
673 struct led_classdev_flash *fled_cdev,
674 const struct v4l2_flash_ops *ops,
675 struct v4l2_flash_config *config)
676{
677 return __v4l2_flash_init(dev, fwn, fled_cdev, NULL, ops, config);
678}
673EXPORT_SYMBOL_GPL(v4l2_flash_init); 679EXPORT_SYMBOL_GPL(v4l2_flash_init);
674 680
681struct v4l2_flash *v4l2_flash_indicator_init(
682 struct device *dev, struct fwnode_handle *fwn,
683 struct led_classdev *iled_cdev,
684 struct v4l2_flash_config *config)
685{
686 return __v4l2_flash_init(dev, fwn, NULL, iled_cdev, NULL, config);
687}
688EXPORT_SYMBOL_GPL(v4l2_flash_indicator_init);
689
675void v4l2_flash_release(struct v4l2_flash *v4l2_flash) 690void v4l2_flash_release(struct v4l2_flash *v4l2_flash)
676{ 691{
677 struct v4l2_subdev *sd; 692 struct v4l2_subdev *sd;
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index 153c53ca3925..40b2fbfe8865 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -28,8 +28,16 @@
28 28
29#include <media/v4l2-fwnode.h> 29#include <media/v4l2-fwnode.h>
30 30
31static int v4l2_fwnode_endpoint_parse_csi_bus(struct fwnode_handle *fwnode, 31enum v4l2_fwnode_bus_type {
32 struct v4l2_fwnode_endpoint *vep) 32 V4L2_FWNODE_BUS_TYPE_GUESS = 0,
33 V4L2_FWNODE_BUS_TYPE_CSI2_CPHY,
34 V4L2_FWNODE_BUS_TYPE_CSI1,
35 V4L2_FWNODE_BUS_TYPE_CCP2,
36 NR_OF_V4L2_FWNODE_BUS_TYPE,
37};
38
39static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
40 struct v4l2_fwnode_endpoint *vep)
33{ 41{
34 struct v4l2_fwnode_bus_mipi_csi2 *bus = &vep->bus.mipi_csi2; 42 struct v4l2_fwnode_bus_mipi_csi2 *bus = &vep->bus.mipi_csi2;
35 bool have_clk_lane = false; 43 bool have_clk_lane = false;
@@ -40,10 +48,10 @@ static int v4l2_fwnode_endpoint_parse_csi_bus(struct fwnode_handle *fwnode,
40 48
41 rval = fwnode_property_read_u32_array(fwnode, "data-lanes", NULL, 0); 49 rval = fwnode_property_read_u32_array(fwnode, "data-lanes", NULL, 0);
42 if (rval > 0) { 50 if (rval > 0) {
43 u32 array[ARRAY_SIZE(bus->data_lanes)]; 51 u32 array[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES];
44 52
45 bus->num_data_lanes = 53 bus->num_data_lanes =
46 min_t(int, ARRAY_SIZE(bus->data_lanes), rval); 54 min_t(int, V4L2_FWNODE_CSI2_MAX_DATA_LANES, rval);
47 55
48 fwnode_property_read_u32_array(fwnode, "data-lanes", array, 56 fwnode_property_read_u32_array(fwnode, "data-lanes", array,
49 bus->num_data_lanes); 57 bus->num_data_lanes);
@@ -56,24 +64,25 @@ static int v4l2_fwnode_endpoint_parse_csi_bus(struct fwnode_handle *fwnode,
56 64
57 bus->data_lanes[i] = array[i]; 65 bus->data_lanes[i] = array[i];
58 } 66 }
59 }
60
61 rval = fwnode_property_read_u32_array(fwnode, "lane-polarities", NULL,
62 0);
63 if (rval > 0) {
64 u32 array[ARRAY_SIZE(bus->lane_polarities)];
65 67
66 if (rval < 1 + bus->num_data_lanes /* clock + data */) { 68 rval = fwnode_property_read_u32_array(fwnode,
67 pr_warn("too few lane-polarities entries (need %u, got %u)\n", 69 "lane-polarities", NULL,
68 1 + bus->num_data_lanes, rval); 70 0);
69 return -EINVAL; 71 if (rval > 0) {
72 if (rval != 1 + bus->num_data_lanes /* clock+data */) {
73 pr_warn("invalid number of lane-polarities entries (need %u, got %u)\n",
74 1 + bus->num_data_lanes, rval);
75 return -EINVAL;
76 }
77
78 fwnode_property_read_u32_array(fwnode,
79 "lane-polarities", array,
80 1 + bus->num_data_lanes);
81
82 for (i = 0; i < 1 + bus->num_data_lanes; i++)
83 bus->lane_polarities[i] = array[i];
70 } 84 }
71 85
72 fwnode_property_read_u32_array(fwnode, "lane-polarities", array,
73 1 + bus->num_data_lanes);
74
75 for (i = 0; i < 1 + bus->num_data_lanes; i++)
76 bus->lane_polarities[i] = array[i];
77 } 86 }
78 87
79 if (!fwnode_property_read_u32(fwnode, "clock-lanes", &v)) { 88 if (!fwnode_property_read_u32(fwnode, "clock-lanes", &v)) {
@@ -146,6 +155,32 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
146 155
147} 156}
148 157
158static void
159v4l2_fwnode_endpoint_parse_csi1_bus(struct fwnode_handle *fwnode,
160 struct v4l2_fwnode_endpoint *vep,
161 u32 bus_type)
162{
163 struct v4l2_fwnode_bus_mipi_csi1 *bus = &vep->bus.mipi_csi1;
164 u32 v;
165
166 if (!fwnode_property_read_u32(fwnode, "clock-inv", &v))
167 bus->clock_inv = v;
168
169 if (!fwnode_property_read_u32(fwnode, "strobe", &v))
170 bus->strobe = v;
171
172 if (!fwnode_property_read_u32(fwnode, "data-lanes", &v))
173 bus->data_lane = v;
174
175 if (!fwnode_property_read_u32(fwnode, "clock-lanes", &v))
176 bus->clock_lane = v;
177
178 if (bus_type == V4L2_FWNODE_BUS_TYPE_CCP2)
179 vep->bus_type = V4L2_MBUS_CCP2;
180 else
181 vep->bus_type = V4L2_MBUS_CSI1;
182}
183
149/** 184/**
150 * v4l2_fwnode_endpoint_parse() - parse all fwnode node properties 185 * v4l2_fwnode_endpoint_parse() - parse all fwnode node properties
151 * @fwnode: pointer to the endpoint's fwnode handle 186 * @fwnode: pointer to the endpoint's fwnode handle
@@ -168,6 +203,7 @@ static void v4l2_fwnode_endpoint_parse_parallel_bus(
168int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode, 203int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
169 struct v4l2_fwnode_endpoint *vep) 204 struct v4l2_fwnode_endpoint *vep)
170{ 205{
206 u32 bus_type = 0;
171 int rval; 207 int rval;
172 208
173 fwnode_graph_parse_endpoint(fwnode, &vep->base); 209 fwnode_graph_parse_endpoint(fwnode, &vep->base);
@@ -176,17 +212,30 @@ int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode,
176 memset(&vep->bus_type, 0, sizeof(*vep) - 212 memset(&vep->bus_type, 0, sizeof(*vep) -
177 offsetof(typeof(*vep), bus_type)); 213 offsetof(typeof(*vep), bus_type));
178 214
179 rval = v4l2_fwnode_endpoint_parse_csi_bus(fwnode, vep); 215 fwnode_property_read_u32(fwnode, "bus-type", &bus_type);
180 if (rval) 216
181 return rval; 217 switch (bus_type) {
182 /* 218 case V4L2_FWNODE_BUS_TYPE_GUESS:
183 * Parse the parallel video bus properties only if none 219 rval = v4l2_fwnode_endpoint_parse_csi2_bus(fwnode, vep);
184 * of the MIPI CSI-2 specific properties were found. 220 if (rval)
185 */ 221 return rval;
186 if (vep->bus.mipi_csi2.flags == 0) 222 /*
187 v4l2_fwnode_endpoint_parse_parallel_bus(fwnode, vep); 223 * Parse the parallel video bus properties only if none
188 224 * of the MIPI CSI-2 specific properties were found.
189 return 0; 225 */
226 if (vep->bus.mipi_csi2.flags == 0)
227 v4l2_fwnode_endpoint_parse_parallel_bus(fwnode, vep);
228
229 return 0;
230 case V4L2_FWNODE_BUS_TYPE_CCP2:
231 case V4L2_FWNODE_BUS_TYPE_CSI1:
232 v4l2_fwnode_endpoint_parse_csi1_bus(fwnode, vep, bus_type);
233
234 return 0;
235 default:
236 pr_warn("unsupported bus type %u\n", bus_type);
237 return -EINVAL;
238 }
190} 239}
191EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_parse); 240EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_parse);
192 241
@@ -247,23 +296,23 @@ struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse(
247 296
248 rval = fwnode_property_read_u64_array(fwnode, "link-frequencies", 297 rval = fwnode_property_read_u64_array(fwnode, "link-frequencies",
249 NULL, 0); 298 NULL, 0);
250 if (rval < 0) 299 if (rval > 0) {
251 goto out_err; 300 vep->link_frequencies =
252 301 kmalloc_array(rval, sizeof(*vep->link_frequencies),
253 vep->link_frequencies = 302 GFP_KERNEL);
254 kmalloc_array(rval, sizeof(*vep->link_frequencies), GFP_KERNEL); 303 if (!vep->link_frequencies) {
255 if (!vep->link_frequencies) { 304 rval = -ENOMEM;
256 rval = -ENOMEM; 305 goto out_err;
257 goto out_err; 306 }
258 }
259 307
260 vep->nr_of_link_frequencies = rval; 308 vep->nr_of_link_frequencies = rval;
261 309
262 rval = fwnode_property_read_u64_array(fwnode, "link-frequencies", 310 rval = fwnode_property_read_u64_array(
263 vep->link_frequencies, 311 fwnode, "link-frequencies", vep->link_frequencies,
264 vep->nr_of_link_frequencies); 312 vep->nr_of_link_frequencies);
265 if (rval < 0) 313 if (rval < 0)
266 goto out_err; 314 goto out_err;
315 }
267 316
268 return vep; 317 return vep;
269 318
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index cab63bb49c97..b60a6b0841d1 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1195,10 +1195,6 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
1195 case V4L2_PIX_FMT_SGBRG10: descr = "10-bit Bayer GBGB/RGRG"; break; 1195 case V4L2_PIX_FMT_SGBRG10: descr = "10-bit Bayer GBGB/RGRG"; break;
1196 case V4L2_PIX_FMT_SGRBG10: descr = "10-bit Bayer GRGR/BGBG"; break; 1196 case V4L2_PIX_FMT_SGRBG10: descr = "10-bit Bayer GRGR/BGBG"; break;
1197 case V4L2_PIX_FMT_SRGGB10: descr = "10-bit Bayer RGRG/GBGB"; break; 1197 case V4L2_PIX_FMT_SRGGB10: descr = "10-bit Bayer RGRG/GBGB"; break;
1198 case V4L2_PIX_FMT_SBGGR12: descr = "12-bit Bayer BGBG/GRGR"; break;
1199 case V4L2_PIX_FMT_SGBRG12: descr = "12-bit Bayer GBGB/RGRG"; break;
1200 case V4L2_PIX_FMT_SGRBG12: descr = "12-bit Bayer GRGR/BGBG"; break;
1201 case V4L2_PIX_FMT_SRGGB12: descr = "12-bit Bayer RGRG/GBGB"; break;
1202 case V4L2_PIX_FMT_SBGGR10P: descr = "10-bit Bayer BGBG/GRGR Packed"; break; 1198 case V4L2_PIX_FMT_SBGGR10P: descr = "10-bit Bayer BGBG/GRGR Packed"; break;
1203 case V4L2_PIX_FMT_SGBRG10P: descr = "10-bit Bayer GBGB/RGRG Packed"; break; 1199 case V4L2_PIX_FMT_SGBRG10P: descr = "10-bit Bayer GBGB/RGRG Packed"; break;
1204 case V4L2_PIX_FMT_SGRBG10P: descr = "10-bit Bayer GRGR/BGBG Packed"; break; 1200 case V4L2_PIX_FMT_SGRBG10P: descr = "10-bit Bayer GRGR/BGBG Packed"; break;
@@ -1211,6 +1207,14 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
1211 case V4L2_PIX_FMT_SGBRG10DPCM8: descr = "8-bit Bayer GBGB/RGRG (DPCM)"; break; 1207 case V4L2_PIX_FMT_SGBRG10DPCM8: descr = "8-bit Bayer GBGB/RGRG (DPCM)"; break;
1212 case V4L2_PIX_FMT_SGRBG10DPCM8: descr = "8-bit Bayer GRGR/BGBG (DPCM)"; break; 1208 case V4L2_PIX_FMT_SGRBG10DPCM8: descr = "8-bit Bayer GRGR/BGBG (DPCM)"; break;
1213 case V4L2_PIX_FMT_SRGGB10DPCM8: descr = "8-bit Bayer RGRG/GBGB (DPCM)"; break; 1209 case V4L2_PIX_FMT_SRGGB10DPCM8: descr = "8-bit Bayer RGRG/GBGB (DPCM)"; break;
1210 case V4L2_PIX_FMT_SBGGR12: descr = "12-bit Bayer BGBG/GRGR"; break;
1211 case V4L2_PIX_FMT_SGBRG12: descr = "12-bit Bayer GBGB/RGRG"; break;
1212 case V4L2_PIX_FMT_SGRBG12: descr = "12-bit Bayer GRGR/BGBG"; break;
1213 case V4L2_PIX_FMT_SRGGB12: descr = "12-bit Bayer RGRG/GBGB"; break;
1214 case V4L2_PIX_FMT_SBGGR12P: descr = "12-bit Bayer BGBG/GRGR Packed"; break;
1215 case V4L2_PIX_FMT_SGBRG12P: descr = "12-bit Bayer GBGB/RGRG Packed"; break;
1216 case V4L2_PIX_FMT_SGRBG12P: descr = "12-bit Bayer GRGR/BGBG Packed"; break;
1217 case V4L2_PIX_FMT_SRGGB12P: descr = "12-bit Bayer RGRG/GBGB Packed"; break;
1214 case V4L2_PIX_FMT_SBGGR16: descr = "16-bit Bayer BGBG/GRGR"; break; 1218 case V4L2_PIX_FMT_SBGGR16: descr = "16-bit Bayer BGBG/GRGR"; break;
1215 case V4L2_PIX_FMT_SGBRG16: descr = "16-bit Bayer GBGB/RGRG"; break; 1219 case V4L2_PIX_FMT_SGBRG16: descr = "16-bit Bayer GBGB/RGRG"; break;
1216 case V4L2_PIX_FMT_SGRBG16: descr = "16-bit Bayer GRGR/BGBG"; break; 1220 case V4L2_PIX_FMT_SGRBG16: descr = "16-bit Bayer GRGR/BGBG"; break;
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index 14f83cecfa92..cb115ba6a1d2 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -194,8 +194,6 @@ static void __enqueue_in_driver(struct vb2_buffer *vb);
194static int __vb2_buf_mem_alloc(struct vb2_buffer *vb) 194static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
195{ 195{
196 struct vb2_queue *q = vb->vb2_queue; 196 struct vb2_queue *q = vb->vb2_queue;
197 enum dma_data_direction dma_dir =
198 q->is_output ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
199 void *mem_priv; 197 void *mem_priv;
200 int plane; 198 int plane;
201 int ret = -ENOMEM; 199 int ret = -ENOMEM;
@@ -209,7 +207,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
209 207
210 mem_priv = call_ptr_memop(vb, alloc, 208 mem_priv = call_ptr_memop(vb, alloc,
211 q->alloc_devs[plane] ? : q->dev, 209 q->alloc_devs[plane] ? : q->dev,
212 q->dma_attrs, size, dma_dir, q->gfp_flags); 210 q->dma_attrs, size, q->dma_dir, q->gfp_flags);
213 if (IS_ERR_OR_NULL(mem_priv)) { 211 if (IS_ERR_OR_NULL(mem_priv)) {
214 if (mem_priv) 212 if (mem_priv)
215 ret = PTR_ERR(mem_priv); 213 ret = PTR_ERR(mem_priv);
@@ -978,8 +976,6 @@ static int __prepare_userptr(struct vb2_buffer *vb, const void *pb)
978 void *mem_priv; 976 void *mem_priv;
979 unsigned int plane; 977 unsigned int plane;
980 int ret = 0; 978 int ret = 0;
981 enum dma_data_direction dma_dir =
982 q->is_output ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
983 bool reacquired = vb->planes[0].mem_priv == NULL; 979 bool reacquired = vb->planes[0].mem_priv == NULL;
984 980
985 memset(planes, 0, sizeof(planes[0]) * vb->num_planes); 981 memset(planes, 0, sizeof(planes[0]) * vb->num_planes);
@@ -1030,7 +1026,7 @@ static int __prepare_userptr(struct vb2_buffer *vb, const void *pb)
1030 mem_priv = call_ptr_memop(vb, get_userptr, 1026 mem_priv = call_ptr_memop(vb, get_userptr,
1031 q->alloc_devs[plane] ? : q->dev, 1027 q->alloc_devs[plane] ? : q->dev,
1032 planes[plane].m.userptr, 1028 planes[plane].m.userptr,
1033 planes[plane].length, dma_dir); 1029 planes[plane].length, q->dma_dir);
1034 if (IS_ERR(mem_priv)) { 1030 if (IS_ERR(mem_priv)) {
1035 dprintk(1, "failed acquiring userspace memory for plane %d\n", 1031 dprintk(1, "failed acquiring userspace memory for plane %d\n",
1036 plane); 1032 plane);
@@ -1096,8 +1092,6 @@ static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb)
1096 void *mem_priv; 1092 void *mem_priv;
1097 unsigned int plane; 1093 unsigned int plane;
1098 int ret = 0; 1094 int ret = 0;
1099 enum dma_data_direction dma_dir =
1100 q->is_output ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
1101 bool reacquired = vb->planes[0].mem_priv == NULL; 1095 bool reacquired = vb->planes[0].mem_priv == NULL;
1102 1096
1103 memset(planes, 0, sizeof(planes[0]) * vb->num_planes); 1097 memset(planes, 0, sizeof(planes[0]) * vb->num_planes);
@@ -1139,7 +1133,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb)
1139 continue; 1133 continue;
1140 } 1134 }
1141 1135
1142 dprintk(1, "buffer for plane %d changed\n", plane); 1136 dprintk(3, "buffer for plane %d changed\n", plane);
1143 1137
1144 if (!reacquired) { 1138 if (!reacquired) {
1145 reacquired = true; 1139 reacquired = true;
@@ -1156,7 +1150,7 @@ static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb)
1156 /* Acquire each plane's memory */ 1150 /* Acquire each plane's memory */
1157 mem_priv = call_ptr_memop(vb, attach_dmabuf, 1151 mem_priv = call_ptr_memop(vb, attach_dmabuf,
1158 q->alloc_devs[plane] ? : q->dev, 1152 q->alloc_devs[plane] ? : q->dev,
1159 dbuf, planes[plane].length, dma_dir); 1153 dbuf, planes[plane].length, q->dma_dir);
1160 if (IS_ERR(mem_priv)) { 1154 if (IS_ERR(mem_priv)) {
1161 dprintk(1, "failed to attach dmabuf\n"); 1155 dprintk(1, "failed to attach dmabuf\n");
1162 ret = PTR_ERR(mem_priv); 1156 ret = PTR_ERR(mem_priv);
@@ -1298,7 +1292,7 @@ int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)
1298 /* Fill buffer information for the userspace */ 1292 /* Fill buffer information for the userspace */
1299 call_void_bufop(q, fill_user_buffer, vb, pb); 1293 call_void_bufop(q, fill_user_buffer, vb, pb);
1300 1294
1301 dprintk(1, "prepare of buffer %d succeeded\n", vb->index); 1295 dprintk(2, "prepare of buffer %d succeeded\n", vb->index);
1302 1296
1303 return ret; 1297 return ret;
1304} 1298}
@@ -1428,7 +1422,7 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb)
1428 return ret; 1422 return ret;
1429 } 1423 }
1430 1424
1431 dprintk(1, "qbuf of buffer %d succeeded\n", vb->index); 1425 dprintk(2, "qbuf of buffer %d succeeded\n", vb->index);
1432 return 0; 1426 return 0;
1433} 1427}
1434EXPORT_SYMBOL_GPL(vb2_core_qbuf); 1428EXPORT_SYMBOL_GPL(vb2_core_qbuf);
@@ -1476,7 +1470,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking)
1476 } 1470 }
1477 1471
1478 if (nonblocking) { 1472 if (nonblocking) {
1479 dprintk(1, "nonblocking and no buffers to dequeue, will not wait\n"); 1473 dprintk(3, "nonblocking and no buffers to dequeue, will not wait\n");
1480 return -EAGAIN; 1474 return -EAGAIN;
1481 } 1475 }
1482 1476
@@ -1623,7 +1617,7 @@ int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
1623 /* go back to dequeued state */ 1617 /* go back to dequeued state */
1624 __vb2_dqbuf(vb); 1618 __vb2_dqbuf(vb);
1625 1619
1626 dprintk(1, "dqbuf of buffer %d, with state %d\n", 1620 dprintk(2, "dqbuf of buffer %d, with state %d\n",
1627 vb->index, vb->state); 1621 vb->index, vb->state);
1628 1622
1629 return 0; 1623 return 0;
@@ -2003,6 +1997,11 @@ int vb2_core_queue_init(struct vb2_queue *q)
2003 if (q->buf_struct_size == 0) 1997 if (q->buf_struct_size == 0)
2004 q->buf_struct_size = sizeof(struct vb2_buffer); 1998 q->buf_struct_size = sizeof(struct vb2_buffer);
2005 1999
2000 if (q->bidirectional)
2001 q->dma_dir = DMA_BIDIRECTIONAL;
2002 else
2003 q->dma_dir = q->is_output ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
2004
2006 return 0; 2005 return 0;
2007} 2006}
2008EXPORT_SYMBOL_GPL(vb2_core_queue_init); 2007EXPORT_SYMBOL_GPL(vb2_core_queue_init);
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index 4f246d166111..9f389f36566d 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -352,7 +352,7 @@ static int vb2_dc_dmabuf_ops_mmap(struct dma_buf *dbuf,
352 return vb2_dc_mmap(dbuf->priv, vma); 352 return vb2_dc_mmap(dbuf->priv, vma);
353} 353}
354 354
355static struct dma_buf_ops vb2_dc_dmabuf_ops = { 355static const struct dma_buf_ops vb2_dc_dmabuf_ops = {
356 .attach = vb2_dc_dmabuf_ops_attach, 356 .attach = vb2_dc_dmabuf_ops_attach,
357 .detach = vb2_dc_dmabuf_ops_detach, 357 .detach = vb2_dc_dmabuf_ops_detach,
358 .map_dma_buf = vb2_dc_dmabuf_ops_map, 358 .map_dma_buf = vb2_dc_dmabuf_ops_map,
@@ -508,7 +508,8 @@ static void *vb2_dc_get_userptr(struct device *dev, unsigned long vaddr,
508 buf->dma_dir = dma_dir; 508 buf->dma_dir = dma_dir;
509 509
510 offset = vaddr & ~PAGE_MASK; 510 offset = vaddr & ~PAGE_MASK;
511 vec = vb2_create_framevec(vaddr, size, dma_dir == DMA_FROM_DEVICE); 511 vec = vb2_create_framevec(vaddr, size, dma_dir == DMA_FROM_DEVICE ||
512 dma_dir == DMA_BIDIRECTIONAL);
512 if (IS_ERR(vec)) { 513 if (IS_ERR(vec)) {
513 ret = PTR_ERR(vec); 514 ret = PTR_ERR(vec);
514 goto fail_buf; 515 goto fail_buf;
diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c
index 5defa1f22ca2..6808231a6bdc 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-sg.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c
@@ -239,7 +239,8 @@ static void *vb2_dma_sg_get_userptr(struct device *dev, unsigned long vaddr,
239 buf->offset = vaddr & ~PAGE_MASK; 239 buf->offset = vaddr & ~PAGE_MASK;
240 buf->size = size; 240 buf->size = size;
241 buf->dma_sgt = &buf->sg_table; 241 buf->dma_sgt = &buf->sg_table;
242 vec = vb2_create_framevec(vaddr, size, buf->dma_dir == DMA_FROM_DEVICE); 242 vec = vb2_create_framevec(vaddr, size, dma_dir == DMA_FROM_DEVICE ||
243 dma_dir == DMA_BIDIRECTIONAL);
243 if (IS_ERR(vec)) 244 if (IS_ERR(vec))
244 goto userptr_fail_pfnvec; 245 goto userptr_fail_pfnvec;
245 buf->vec = vec; 246 buf->vec = vec;
@@ -292,7 +293,8 @@ static void vb2_dma_sg_put_userptr(void *buf_priv)
292 vm_unmap_ram(buf->vaddr, buf->num_pages); 293 vm_unmap_ram(buf->vaddr, buf->num_pages);
293 sg_free_table(buf->dma_sgt); 294 sg_free_table(buf->dma_sgt);
294 while (--i >= 0) { 295 while (--i >= 0) {
295 if (buf->dma_dir == DMA_FROM_DEVICE) 296 if (buf->dma_dir == DMA_FROM_DEVICE ||
297 buf->dma_dir == DMA_BIDIRECTIONAL)
296 set_page_dirty_lock(buf->pages[i]); 298 set_page_dirty_lock(buf->pages[i]);
297 } 299 }
298 vb2_destroy_framevec(buf->vec); 300 vb2_destroy_framevec(buf->vec);
@@ -500,7 +502,7 @@ static int vb2_dma_sg_dmabuf_ops_mmap(struct dma_buf *dbuf,
500 return vb2_dma_sg_mmap(dbuf->priv, vma); 502 return vb2_dma_sg_mmap(dbuf->priv, vma);
501} 503}
502 504
503static struct dma_buf_ops vb2_dma_sg_dmabuf_ops = { 505static const struct dma_buf_ops vb2_dma_sg_dmabuf_ops = {
504 .attach = vb2_dma_sg_dmabuf_ops_attach, 506 .attach = vb2_dma_sg_dmabuf_ops_attach,
505 .detach = vb2_dma_sg_dmabuf_ops_detach, 507 .detach = vb2_dma_sg_dmabuf_ops_detach,
506 .map_dma_buf = vb2_dma_sg_dmabuf_ops_map, 508 .map_dma_buf = vb2_dma_sg_dmabuf_ops_map,
diff --git a/drivers/media/v4l2-core/videobuf2-vmalloc.c b/drivers/media/v4l2-core/videobuf2-vmalloc.c
index b337d780844c..3a7c80cd1a17 100644
--- a/drivers/media/v4l2-core/videobuf2-vmalloc.c
+++ b/drivers/media/v4l2-core/videobuf2-vmalloc.c
@@ -87,7 +87,8 @@ static void *vb2_vmalloc_get_userptr(struct device *dev, unsigned long vaddr,
87 buf->dma_dir = dma_dir; 87 buf->dma_dir = dma_dir;
88 offset = vaddr & ~PAGE_MASK; 88 offset = vaddr & ~PAGE_MASK;
89 buf->size = size; 89 buf->size = size;
90 vec = vb2_create_framevec(vaddr, size, dma_dir == DMA_FROM_DEVICE); 90 vec = vb2_create_framevec(vaddr, size, dma_dir == DMA_FROM_DEVICE ||
91 dma_dir == DMA_BIDIRECTIONAL);
91 if (IS_ERR(vec)) { 92 if (IS_ERR(vec)) {
92 ret = PTR_ERR(vec); 93 ret = PTR_ERR(vec);
93 goto fail_pfnvec_create; 94 goto fail_pfnvec_create;
@@ -137,7 +138,8 @@ static void vb2_vmalloc_put_userptr(void *buf_priv)
137 pages = frame_vector_pages(buf->vec); 138 pages = frame_vector_pages(buf->vec);
138 if (vaddr) 139 if (vaddr)
139 vm_unmap_ram((void *)vaddr, n_pages); 140 vm_unmap_ram((void *)vaddr, n_pages);
140 if (buf->dma_dir == DMA_FROM_DEVICE) 141 if (buf->dma_dir == DMA_FROM_DEVICE ||
142 buf->dma_dir == DMA_BIDIRECTIONAL)
141 for (i = 0; i < n_pages; i++) 143 for (i = 0; i < n_pages; i++)
142 set_page_dirty_lock(pages[i]); 144 set_page_dirty_lock(pages[i]);
143 } else { 145 } else {
@@ -338,7 +340,7 @@ static int vb2_vmalloc_dmabuf_ops_mmap(struct dma_buf *dbuf,
338 return vb2_vmalloc_mmap(dbuf->priv, vma); 340 return vb2_vmalloc_mmap(dbuf->priv, vma);
339} 341}
340 342
341static struct dma_buf_ops vb2_vmalloc_dmabuf_ops = { 343static const struct dma_buf_ops vb2_vmalloc_dmabuf_ops = {
342 .attach = vb2_vmalloc_dmabuf_ops_attach, 344 .attach = vb2_vmalloc_dmabuf_ops_attach,
343 .detach = vb2_vmalloc_dmabuf_ops_detach, 345 .detach = vb2_vmalloc_dmabuf_ops_detach,
344 .map_dma_buf = vb2_vmalloc_dmabuf_ops_map, 346 .map_dma_buf = vb2_vmalloc_dmabuf_ops_map,
diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
index 861a249e6ef1..3f4148c92308 100644
--- a/drivers/staging/greybus/light.c
+++ b/drivers/staging/greybus/light.c
@@ -58,6 +58,7 @@ struct gb_light {
58 bool ready; 58 bool ready;
59#if IS_REACHABLE(CONFIG_V4L2_FLASH_LED_CLASS) 59#if IS_REACHABLE(CONFIG_V4L2_FLASH_LED_CLASS)
60 struct v4l2_flash *v4l2_flash; 60 struct v4l2_flash *v4l2_flash;
61 struct v4l2_flash *v4l2_flash_ind;
61#endif 62#endif
62}; 63};
63 64
@@ -534,26 +535,21 @@ static int gb_lights_light_v4l2_register(struct gb_light *light)
534{ 535{
535 struct gb_connection *connection = get_conn_from_light(light); 536 struct gb_connection *connection = get_conn_from_light(light);
536 struct device *dev = &connection->bundle->dev; 537 struct device *dev = &connection->bundle->dev;
537 struct v4l2_flash_config *sd_cfg; 538 struct v4l2_flash_config sd_cfg = { {0} }, sd_cfg_ind = { {0} };
538 struct led_classdev_flash *fled; 539 struct led_classdev_flash *fled;
539 struct led_classdev_flash *iled = NULL; 540 struct led_classdev *iled = NULL;
540 struct gb_channel *channel_torch, *channel_ind, *channel_flash; 541 struct gb_channel *channel_torch, *channel_ind, *channel_flash;
541 int ret = 0;
542
543 sd_cfg = kcalloc(1, sizeof(*sd_cfg), GFP_KERNEL);
544 if (!sd_cfg)
545 return -ENOMEM;
546 542
547 channel_torch = get_channel_from_mode(light, GB_CHANNEL_MODE_TORCH); 543 channel_torch = get_channel_from_mode(light, GB_CHANNEL_MODE_TORCH);
548 if (channel_torch) 544 if (channel_torch)
549 __gb_lights_channel_v4l2_config(&channel_torch->intensity_uA, 545 __gb_lights_channel_v4l2_config(&channel_torch->intensity_uA,
550 &sd_cfg->torch_intensity); 546 &sd_cfg.intensity);
551 547
552 channel_ind = get_channel_from_mode(light, GB_CHANNEL_MODE_INDICATOR); 548 channel_ind = get_channel_from_mode(light, GB_CHANNEL_MODE_INDICATOR);
553 if (channel_ind) { 549 if (channel_ind) {
554 __gb_lights_channel_v4l2_config(&channel_ind->intensity_uA, 550 __gb_lights_channel_v4l2_config(&channel_ind->intensity_uA,
555 &sd_cfg->indicator_intensity); 551 &sd_cfg_ind.intensity);
556 iled = &channel_ind->fled; 552 iled = &channel_ind->fled.led_cdev;
557 } 553 }
558 554
559 channel_flash = get_channel_from_mode(light, GB_CHANNEL_MODE_FLASH); 555 channel_flash = get_channel_from_mode(light, GB_CHANNEL_MODE_FLASH);
@@ -561,31 +557,37 @@ static int gb_lights_light_v4l2_register(struct gb_light *light)
561 557
562 fled = &channel_flash->fled; 558 fled = &channel_flash->fled;
563 559
564 snprintf(sd_cfg->dev_name, sizeof(sd_cfg->dev_name), "%s", light->name); 560 snprintf(sd_cfg.dev_name, sizeof(sd_cfg.dev_name), "%s", light->name);
561 snprintf(sd_cfg_ind.dev_name, sizeof(sd_cfg_ind.dev_name),
562 "%s indicator", light->name);
565 563
566 /* Set the possible values to faults, in our case all faults */ 564 /* Set the possible values to faults, in our case all faults */
567 sd_cfg->flash_faults = LED_FAULT_OVER_VOLTAGE | LED_FAULT_TIMEOUT | 565 sd_cfg.flash_faults = LED_FAULT_OVER_VOLTAGE | LED_FAULT_TIMEOUT |
568 LED_FAULT_OVER_TEMPERATURE | LED_FAULT_SHORT_CIRCUIT | 566 LED_FAULT_OVER_TEMPERATURE | LED_FAULT_SHORT_CIRCUIT |
569 LED_FAULT_OVER_CURRENT | LED_FAULT_INDICATOR | 567 LED_FAULT_OVER_CURRENT | LED_FAULT_INDICATOR |
570 LED_FAULT_UNDER_VOLTAGE | LED_FAULT_INPUT_VOLTAGE | 568 LED_FAULT_UNDER_VOLTAGE | LED_FAULT_INPUT_VOLTAGE |
571 LED_FAULT_LED_OVER_TEMPERATURE; 569 LED_FAULT_LED_OVER_TEMPERATURE;
572 570
573 light->v4l2_flash = v4l2_flash_init(dev, NULL, fled, iled, 571 light->v4l2_flash = v4l2_flash_init(dev, NULL, fled, &v4l2_flash_ops,
574 &v4l2_flash_ops, sd_cfg); 572 &sd_cfg);
575 if (IS_ERR_OR_NULL(light->v4l2_flash)) { 573 if (IS_ERR(light->v4l2_flash))
576 ret = PTR_ERR(light->v4l2_flash); 574 return PTR_ERR(light->v4l2_flash);
577 goto out_free;
578 }
579 575
580 return ret; 576 if (channel_ind) {
577 light->v4l2_flash_ind =
578 v4l2_flash_indicator_init(dev, NULL, iled, &sd_cfg_ind);
579 if (IS_ERR(light->v4l2_flash_ind)) {
580 v4l2_flash_release(light->v4l2_flash);
581 return PTR_ERR(light->v4l2_flash_ind);
582 }
583 }
581 584
582out_free: 585 return 0;
583 kfree(sd_cfg);
584 return ret;
585} 586}
586 587
587static void gb_lights_light_v4l2_unregister(struct gb_light *light) 588static void gb_lights_light_v4l2_unregister(struct gb_light *light)
588{ 589{
590 v4l2_flash_release(light->v4l2_flash_ind);
589 v4l2_flash_release(light->v4l2_flash); 591 v4l2_flash_release(light->v4l2_flash);
590} 592}
591#else 593#else
diff --git a/drivers/staging/media/atomisp/i2c/ap1302.c b/drivers/staging/media/atomisp/i2c/ap1302.c
index bacffbe962d4..2f772a020c8b 100644
--- a/drivers/staging/media/atomisp/i2c/ap1302.c
+++ b/drivers/staging/media/atomisp/i2c/ap1302.c
@@ -11,11 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 *
19 */ 14 */
20 15
21#include "../include/linux/atomisp.h" 16#include "../include/linux/atomisp.h"
@@ -1098,7 +1093,7 @@ static const struct v4l2_ctrl_config ctrls[] = {
1098 }, 1093 },
1099}; 1094};
1100 1095
1101static struct v4l2_subdev_sensor_ops ap1302_sensor_ops = { 1096static const struct v4l2_subdev_sensor_ops ap1302_sensor_ops = {
1102 .g_skip_frames = ap1302_g_skip_frames, 1097 .g_skip_frames = ap1302_g_skip_frames,
1103}; 1098};
1104 1099
diff --git a/drivers/staging/media/atomisp/i2c/gc0310.c b/drivers/staging/media/atomisp/i2c/gc0310.c
index 350fd7fd5b86..35ed51ffe944 100644
--- a/drivers/staging/media/atomisp/i2c/gc0310.c
+++ b/drivers/staging/media/atomisp/i2c/gc0310.c
@@ -118,9 +118,8 @@ static int gc0310_write_reg(struct i2c_client *client, u16 data_length,
118 /* high byte goes out first */ 118 /* high byte goes out first */
119 *wreg = (u8)(reg & 0xff); 119 *wreg = (u8)(reg & 0xff);
120 120
121 if (data_length == GC0310_8BIT) { 121 if (data_length == GC0310_8BIT)
122 data[1] = (u8)(val); 122 data[1] = (u8)(val);
123 }
124 123
125 ret = gc0310_i2c_write(client, len, data); 124 ret = gc0310_i2c_write(client, len, data);
126 if (ret) 125 if (ret)
@@ -1453,7 +1452,7 @@ out_free:
1453 return ret; 1452 return ret;
1454} 1453}
1455 1454
1456static struct acpi_device_id gc0310_acpi_match[] = { 1455static const struct acpi_device_id gc0310_acpi_match[] = {
1457 {"XXGC0310"}, 1456 {"XXGC0310"},
1458 {"INT0310"}, 1457 {"INT0310"},
1459 {}, 1458 {},
diff --git a/drivers/staging/media/atomisp/i2c/gc2235.c b/drivers/staging/media/atomisp/i2c/gc2235.c
index 50f431729b6c..e43d31ea9676 100644
--- a/drivers/staging/media/atomisp/i2c/gc2235.c
+++ b/drivers/staging/media/atomisp/i2c/gc2235.c
@@ -480,7 +480,7 @@ static const struct v4l2_ctrl_ops ctrl_ops = {
480 .g_volatile_ctrl = gc2235_g_volatile_ctrl 480 .g_volatile_ctrl = gc2235_g_volatile_ctrl
481}; 481};
482 482
483struct v4l2_ctrl_config gc2235_controls[] = { 483static struct v4l2_ctrl_config gc2235_controls[] = {
484 { 484 {
485 .ops = &ctrl_ops, 485 .ops = &ctrl_ops,
486 .id = V4L2_CID_EXPOSURE_ABSOLUTE, 486 .id = V4L2_CID_EXPOSURE_ABSOLUTE,
@@ -1183,7 +1183,7 @@ out_free:
1183 return ret; 1183 return ret;
1184} 1184}
1185 1185
1186static struct acpi_device_id gc2235_acpi_match[] = { 1186static const struct acpi_device_id gc2235_acpi_match[] = {
1187 { "INT33F8" }, 1187 { "INT33F8" },
1188 {}, 1188 {},
1189}; 1189};
diff --git a/drivers/staging/media/atomisp/i2c/gc2235.h b/drivers/staging/media/atomisp/i2c/gc2235.h
index 7c3d994180cc..a8d6aa9c9a5d 100644
--- a/drivers/staging/media/atomisp/i2c/gc2235.h
+++ b/drivers/staging/media/atomisp/i2c/gc2235.h
@@ -530,7 +530,7 @@ static struct gc2235_reg const gc2235_1616_1216_30fps[] = {
530 { GC2235_TOK_TERM, 0, 0 } 530 { GC2235_TOK_TERM, 0, 0 }
531}; 531};
532 532
533struct gc2235_resolution gc2235_res_preview[] = { 533static struct gc2235_resolution gc2235_res_preview[] = {
534 534
535 { 535 {
536 .desc = "gc2235_1600_900_30fps", 536 .desc = "gc2235_1600_900_30fps",
@@ -582,7 +582,7 @@ struct gc2235_resolution gc2235_res_preview[] = {
582}; 582};
583#define N_RES_PREVIEW (ARRAY_SIZE(gc2235_res_preview)) 583#define N_RES_PREVIEW (ARRAY_SIZE(gc2235_res_preview))
584 584
585struct gc2235_resolution gc2235_res_still[] = { 585static struct gc2235_resolution gc2235_res_still[] = {
586 { 586 {
587 .desc = "gc2235_1600_900_30fps", 587 .desc = "gc2235_1600_900_30fps",
588 .width = 1600, 588 .width = 1600,
@@ -632,7 +632,7 @@ struct gc2235_resolution gc2235_res_still[] = {
632}; 632};
633#define N_RES_STILL (ARRAY_SIZE(gc2235_res_still)) 633#define N_RES_STILL (ARRAY_SIZE(gc2235_res_still))
634 634
635struct gc2235_resolution gc2235_res_video[] = { 635static struct gc2235_resolution gc2235_res_video[] = {
636 { 636 {
637 .desc = "gc2235_1296_736_30fps", 637 .desc = "gc2235_1296_736_30fps",
638 .width = 1296, 638 .width = 1296,
diff --git a/drivers/staging/media/atomisp/i2c/imx/ad5816g.c b/drivers/staging/media/atomisp/i2c/imx/ad5816g.c
index d68ebb49f002..558dcdf135d9 100644
--- a/drivers/staging/media/atomisp/i2c/imx/ad5816g.c
+++ b/drivers/staging/media/atomisp/i2c/imx/ad5816g.c
@@ -136,7 +136,7 @@ int ad5816g_vcm_power_down(struct v4l2_subdev *sd)
136} 136}
137 137
138 138
139int ad5816g_t_focus_vcm(struct v4l2_subdev *sd, u16 val) 139static int ad5816g_t_focus_vcm(struct v4l2_subdev *sd, u16 val)
140{ 140{
141 struct i2c_client *client = v4l2_get_subdevdata(sd); 141 struct i2c_client *client = v4l2_get_subdevdata(sd);
142 u16 data = val & VCM_CODE_MASK; 142 u16 data = val & VCM_CODE_MASK;
@@ -214,12 +214,3 @@ int ad5816g_t_vcm_timing(struct v4l2_subdev *sd, s32 value)
214{ 214{
215 return 0; 215 return 0;
216} 216}
217
218int ad5816g_vcm_init(struct v4l2_subdev *sd)
219{
220 ad5816g_dev.platform_data = camera_get_af_platform_data();
221 return (NULL == ad5816g_dev.platform_data) ? -ENODEV : 0;
222
223}
224
225
diff --git a/drivers/staging/media/atomisp/i2c/imx/drv201.c b/drivers/staging/media/atomisp/i2c/imx/drv201.c
index 915e4019cfeb..6d9d4c968722 100644
--- a/drivers/staging/media/atomisp/i2c/imx/drv201.c
+++ b/drivers/staging/media/atomisp/i2c/imx/drv201.c
@@ -128,7 +128,7 @@ int drv201_vcm_power_down(struct v4l2_subdev *sd)
128} 128}
129 129
130 130
131int drv201_t_focus_vcm(struct v4l2_subdev *sd, u16 val) 131static int drv201_t_focus_vcm(struct v4l2_subdev *sd, u16 val)
132{ 132{
133 struct i2c_client *client = v4l2_get_subdevdata(sd); 133 struct i2c_client *client = v4l2_get_subdevdata(sd);
134 u16 data = val & VCM_CODE_MASK; 134 u16 data = val & VCM_CODE_MASK;
@@ -207,12 +207,3 @@ int drv201_t_vcm_timing(struct v4l2_subdev *sd, s32 value)
207{ 207{
208 return 0; 208 return 0;
209} 209}
210
211int drv201_vcm_init(struct v4l2_subdev *sd)
212{
213 drv201_dev.platform_data = camera_get_af_platform_data();
214 return (NULL == drv201_dev.platform_data) ? -ENODEV : 0;
215}
216
217
218
diff --git a/drivers/staging/media/atomisp/i2c/imx/dw9714.c b/drivers/staging/media/atomisp/i2c/imx/dw9714.c
index b7dee1b6bb37..6397a7ee0af6 100644
--- a/drivers/staging/media/atomisp/i2c/imx/dw9714.c
+++ b/drivers/staging/media/atomisp/i2c/imx/dw9714.c
@@ -56,7 +56,7 @@ int dw9714_vcm_power_down(struct v4l2_subdev *sd)
56} 56}
57 57
58 58
59int dw9714_t_focus_vcm(struct v4l2_subdev *sd, u16 val) 59static int dw9714_t_focus_vcm(struct v4l2_subdev *sd, u16 val)
60{ 60{
61 struct i2c_client *client = v4l2_get_subdevdata(sd); 61 struct i2c_client *client = v4l2_get_subdevdata(sd);
62 int ret = -EINVAL; 62 int ret = -EINVAL;
@@ -221,15 +221,3 @@ int dw9714_t_vcm_timing(struct v4l2_subdev *sd, s32 value)
221 221
222 return 0; 222 return 0;
223} 223}
224
225int dw9714_vcm_init(struct v4l2_subdev *sd)
226{
227
228 /* set VCM to home position and vcm mode to direct*/
229 dw9714_dev.vcm_mode = DW9714_DIRECT;
230 dw9714_dev.vcm_settings.update = false;
231 dw9714_dev.platform_data = camera_get_af_platform_data();
232 return (NULL == dw9714_dev.platform_data) ? -ENODEV : 0;
233
234}
235
diff --git a/drivers/staging/media/atomisp/i2c/imx/dw9718.c b/drivers/staging/media/atomisp/i2c/imx/dw9718.c
index 65a1fcf187d5..c02b9f0a2440 100644
--- a/drivers/staging/media/atomisp/i2c/imx/dw9718.c
+++ b/drivers/staging/media/atomisp/i2c/imx/dw9718.c
@@ -204,11 +204,6 @@ int dw9718_q_focus_status(struct v4l2_subdev *sd, s32 *value)
204 return 0; 204 return 0;
205} 205}
206 206
207int dw9718_t_focus_vcm(struct v4l2_subdev *sd, u16 val)
208{
209 return -EINVAL;
210}
211
212int dw9718_t_focus_rel(struct v4l2_subdev *sd, s32 value) 207int dw9718_t_focus_rel(struct v4l2_subdev *sd, s32 value)
213{ 208{
214 return dw9718_t_focus_abs(sd, dw9718_dev.focus + value); 209 return dw9718_t_focus_abs(sd, dw9718_dev.focus + value);
diff --git a/drivers/staging/media/atomisp/i2c/imx/dw9719.c b/drivers/staging/media/atomisp/i2c/imx/dw9719.c
index eca2d7640030..565237796bb4 100644
--- a/drivers/staging/media/atomisp/i2c/imx/dw9719.c
+++ b/drivers/staging/media/atomisp/i2c/imx/dw9719.c
@@ -161,11 +161,6 @@ int dw9719_q_focus_status(struct v4l2_subdev *sd, s32 *value)
161 return 0; 161 return 0;
162} 162}
163 163
164int dw9719_t_focus_vcm(struct v4l2_subdev *sd, u16 val)
165{
166 return -EINVAL;
167}
168
169int dw9719_t_focus_abs(struct v4l2_subdev *sd, s32 value) 164int dw9719_t_focus_abs(struct v4l2_subdev *sd, s32 value)
170{ 165{
171 struct i2c_client *client = v4l2_get_subdevdata(sd); 166 struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -201,9 +196,3 @@ int dw9719_t_vcm_timing(struct v4l2_subdev *sd, s32 value)
201{ 196{
202 return 0; 197 return 0;
203} 198}
204
205int dw9719_vcm_init(struct v4l2_subdev *sd)
206{
207 dw9719_dev.platform_data = camera_get_af_platform_data();
208 return (NULL == dw9719_dev.platform_data) ? -ENODEV : 0;
209}
diff --git a/drivers/staging/media/atomisp/i2c/imx/imx.c b/drivers/staging/media/atomisp/i2c/imx/imx.c
index 408a7b945153..49ab0af87096 100644
--- a/drivers/staging/media/atomisp/i2c/imx/imx.c
+++ b/drivers/staging/media/atomisp/i2c/imx/imx.c
@@ -1084,46 +1084,15 @@ static int imx_g_bin_factor_y(struct v4l2_subdev *sd, s32 *val)
1084 return 0; 1084 return 0;
1085} 1085}
1086 1086
1087int imx_vcm_power_up(struct v4l2_subdev *sd) 1087static int imx_t_focus_abs(struct v4l2_subdev *sd, s32 value)
1088{
1089 struct imx_device *dev = to_imx_sensor(sd);
1090 if (dev->vcm_driver && dev->vcm_driver->power_up)
1091 return dev->vcm_driver->power_up(sd);
1092 return 0;
1093}
1094
1095int imx_vcm_power_down(struct v4l2_subdev *sd)
1096{
1097 struct imx_device *dev = to_imx_sensor(sd);
1098 if (dev->vcm_driver && dev->vcm_driver->power_down)
1099 return dev->vcm_driver->power_down(sd);
1100 return 0;
1101}
1102
1103int imx_vcm_init(struct v4l2_subdev *sd)
1104{
1105 struct imx_device *dev = to_imx_sensor(sd);
1106 if (dev->vcm_driver && dev->vcm_driver->init)
1107 return dev->vcm_driver->init(sd);
1108 return 0;
1109}
1110
1111int imx_t_focus_vcm(struct v4l2_subdev *sd, u16 val)
1112{
1113 struct imx_device *dev = to_imx_sensor(sd);
1114 if (dev->vcm_driver && dev->vcm_driver->t_focus_vcm)
1115 return dev->vcm_driver->t_focus_vcm(sd, val);
1116 return 0;
1117}
1118
1119int imx_t_focus_abs(struct v4l2_subdev *sd, s32 value)
1120{ 1088{
1121 struct imx_device *dev = to_imx_sensor(sd); 1089 struct imx_device *dev = to_imx_sensor(sd);
1122 if (dev->vcm_driver && dev->vcm_driver->t_focus_abs) 1090 if (dev->vcm_driver && dev->vcm_driver->t_focus_abs)
1123 return dev->vcm_driver->t_focus_abs(sd, value); 1091 return dev->vcm_driver->t_focus_abs(sd, value);
1124 return 0; 1092 return 0;
1125} 1093}
1126int imx_t_focus_rel(struct v4l2_subdev *sd, s32 value) 1094
1095static int imx_t_focus_rel(struct v4l2_subdev *sd, s32 value)
1127{ 1096{
1128 struct imx_device *dev = to_imx_sensor(sd); 1097 struct imx_device *dev = to_imx_sensor(sd);
1129 if (dev->vcm_driver && dev->vcm_driver->t_focus_rel) 1098 if (dev->vcm_driver && dev->vcm_driver->t_focus_rel)
@@ -1131,7 +1100,7 @@ int imx_t_focus_rel(struct v4l2_subdev *sd, s32 value)
1131 return 0; 1100 return 0;
1132} 1101}
1133 1102
1134int imx_q_focus_status(struct v4l2_subdev *sd, s32 *value) 1103static int imx_q_focus_status(struct v4l2_subdev *sd, s32 *value)
1135{ 1104{
1136 struct imx_device *dev = to_imx_sensor(sd); 1105 struct imx_device *dev = to_imx_sensor(sd);
1137 if (dev->vcm_driver && dev->vcm_driver->q_focus_status) 1106 if (dev->vcm_driver && dev->vcm_driver->q_focus_status)
@@ -1139,7 +1108,7 @@ int imx_q_focus_status(struct v4l2_subdev *sd, s32 *value)
1139 return 0; 1108 return 0;
1140} 1109}
1141 1110
1142int imx_q_focus_abs(struct v4l2_subdev *sd, s32 *value) 1111static int imx_q_focus_abs(struct v4l2_subdev *sd, s32 *value)
1143{ 1112{
1144 struct imx_device *dev = to_imx_sensor(sd); 1113 struct imx_device *dev = to_imx_sensor(sd);
1145 if (dev->vcm_driver && dev->vcm_driver->q_focus_abs) 1114 if (dev->vcm_driver && dev->vcm_driver->q_focus_abs)
@@ -1147,7 +1116,7 @@ int imx_q_focus_abs(struct v4l2_subdev *sd, s32 *value)
1147 return 0; 1116 return 0;
1148} 1117}
1149 1118
1150int imx_t_vcm_slew(struct v4l2_subdev *sd, s32 value) 1119static int imx_t_vcm_slew(struct v4l2_subdev *sd, s32 value)
1151{ 1120{
1152 struct imx_device *dev = to_imx_sensor(sd); 1121 struct imx_device *dev = to_imx_sensor(sd);
1153 if (dev->vcm_driver && dev->vcm_driver->t_vcm_slew) 1122 if (dev->vcm_driver && dev->vcm_driver->t_vcm_slew)
@@ -1155,7 +1124,7 @@ int imx_t_vcm_slew(struct v4l2_subdev *sd, s32 value)
1155 return 0; 1124 return 0;
1156} 1125}
1157 1126
1158int imx_t_vcm_timing(struct v4l2_subdev *sd, s32 value) 1127static int imx_t_vcm_timing(struct v4l2_subdev *sd, s32 value)
1159{ 1128{
1160 struct imx_device *dev = to_imx_sensor(sd); 1129 struct imx_device *dev = to_imx_sensor(sd);
1161 if (dev->vcm_driver && dev->vcm_driver->t_vcm_timing) 1130 if (dev->vcm_driver && dev->vcm_driver->t_vcm_timing)
@@ -2105,8 +2074,7 @@ imx_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *param)
2105 return 0; 2074 return 0;
2106} 2075}
2107 2076
2108int 2077static int imx_g_frame_interval(struct v4l2_subdev *sd,
2109imx_g_frame_interval(struct v4l2_subdev *sd,
2110 struct v4l2_subdev_frame_interval *interval) 2078 struct v4l2_subdev_frame_interval *interval)
2111{ 2079{
2112 struct imx_device *dev = to_imx_sensor(sd); 2080 struct imx_device *dev = to_imx_sensor(sd);
diff --git a/drivers/staging/media/atomisp/i2c/imx/imx.h b/drivers/staging/media/atomisp/i2c/imx/imx.h
index 41b4133ca995..30beb2a0ed93 100644
--- a/drivers/staging/media/atomisp/i2c/imx/imx.h
+++ b/drivers/staging/media/atomisp/i2c/imx/imx.h
@@ -222,8 +222,6 @@
222struct imx_vcm { 222struct imx_vcm {
223 int (*power_up)(struct v4l2_subdev *sd); 223 int (*power_up)(struct v4l2_subdev *sd);
224 int (*power_down)(struct v4l2_subdev *sd); 224 int (*power_down)(struct v4l2_subdev *sd);
225 int (*init)(struct v4l2_subdev *sd);
226 int (*t_focus_vcm)(struct v4l2_subdev *sd, u16 val);
227 int (*t_focus_abs)(struct v4l2_subdev *sd, s32 value); 225 int (*t_focus_abs)(struct v4l2_subdev *sd, s32 value);
228 int (*t_focus_abs_init)(struct v4l2_subdev *sd); 226 int (*t_focus_abs_init)(struct v4l2_subdev *sd);
229 int (*t_focus_rel)(struct v4l2_subdev *sd, s32 value); 227 int (*t_focus_rel)(struct v4l2_subdev *sd, s32 value);
@@ -549,9 +547,6 @@ static const struct imx_reg imx219_param_update[] = {
549 547
550extern int ad5816g_vcm_power_up(struct v4l2_subdev *sd); 548extern int ad5816g_vcm_power_up(struct v4l2_subdev *sd);
551extern int ad5816g_vcm_power_down(struct v4l2_subdev *sd); 549extern int ad5816g_vcm_power_down(struct v4l2_subdev *sd);
552extern int ad5816g_vcm_init(struct v4l2_subdev *sd);
553
554extern int ad5816g_t_focus_vcm(struct v4l2_subdev *sd, u16 val);
555extern int ad5816g_t_focus_abs(struct v4l2_subdev *sd, s32 value); 550extern int ad5816g_t_focus_abs(struct v4l2_subdev *sd, s32 value);
556extern int ad5816g_t_focus_rel(struct v4l2_subdev *sd, s32 value); 551extern int ad5816g_t_focus_rel(struct v4l2_subdev *sd, s32 value);
557extern int ad5816g_q_focus_status(struct v4l2_subdev *sd, s32 *value); 552extern int ad5816g_q_focus_status(struct v4l2_subdev *sd, s32 *value);
@@ -561,9 +556,6 @@ extern int ad5816g_t_vcm_timing(struct v4l2_subdev *sd, s32 value);
561 556
562extern int drv201_vcm_power_up(struct v4l2_subdev *sd); 557extern int drv201_vcm_power_up(struct v4l2_subdev *sd);
563extern int drv201_vcm_power_down(struct v4l2_subdev *sd); 558extern int drv201_vcm_power_down(struct v4l2_subdev *sd);
564extern int drv201_vcm_init(struct v4l2_subdev *sd);
565
566extern int drv201_t_focus_vcm(struct v4l2_subdev *sd, u16 val);
567extern int drv201_t_focus_abs(struct v4l2_subdev *sd, s32 value); 559extern int drv201_t_focus_abs(struct v4l2_subdev *sd, s32 value);
568extern int drv201_t_focus_rel(struct v4l2_subdev *sd, s32 value); 560extern int drv201_t_focus_rel(struct v4l2_subdev *sd, s32 value);
569extern int drv201_q_focus_status(struct v4l2_subdev *sd, s32 *value); 561extern int drv201_q_focus_status(struct v4l2_subdev *sd, s32 *value);
@@ -573,9 +565,6 @@ extern int drv201_t_vcm_timing(struct v4l2_subdev *sd, s32 value);
573 565
574extern int dw9714_vcm_power_up(struct v4l2_subdev *sd); 566extern int dw9714_vcm_power_up(struct v4l2_subdev *sd);
575extern int dw9714_vcm_power_down(struct v4l2_subdev *sd); 567extern int dw9714_vcm_power_down(struct v4l2_subdev *sd);
576extern int dw9714_vcm_init(struct v4l2_subdev *sd);
577
578extern int dw9714_t_focus_vcm(struct v4l2_subdev *sd, u16 val);
579extern int dw9714_t_focus_abs(struct v4l2_subdev *sd, s32 value); 568extern int dw9714_t_focus_abs(struct v4l2_subdev *sd, s32 value);
580extern int dw9714_t_focus_abs_init(struct v4l2_subdev *sd); 569extern int dw9714_t_focus_abs_init(struct v4l2_subdev *sd);
581extern int dw9714_t_focus_rel(struct v4l2_subdev *sd, s32 value); 570extern int dw9714_t_focus_rel(struct v4l2_subdev *sd, s32 value);
@@ -586,9 +575,6 @@ extern int dw9714_t_vcm_timing(struct v4l2_subdev *sd, s32 value);
586 575
587extern int dw9719_vcm_power_up(struct v4l2_subdev *sd); 576extern int dw9719_vcm_power_up(struct v4l2_subdev *sd);
588extern int dw9719_vcm_power_down(struct v4l2_subdev *sd); 577extern int dw9719_vcm_power_down(struct v4l2_subdev *sd);
589extern int dw9719_vcm_init(struct v4l2_subdev *sd);
590
591extern int dw9719_t_focus_vcm(struct v4l2_subdev *sd, u16 val);
592extern int dw9719_t_focus_abs(struct v4l2_subdev *sd, s32 value); 578extern int dw9719_t_focus_abs(struct v4l2_subdev *sd, s32 value);
593extern int dw9719_t_focus_rel(struct v4l2_subdev *sd, s32 value); 579extern int dw9719_t_focus_rel(struct v4l2_subdev *sd, s32 value);
594extern int dw9719_q_focus_status(struct v4l2_subdev *sd, s32 *value); 580extern int dw9719_q_focus_status(struct v4l2_subdev *sd, s32 *value);
@@ -598,9 +584,6 @@ extern int dw9719_t_vcm_timing(struct v4l2_subdev *sd, s32 value);
598 584
599extern int dw9718_vcm_power_up(struct v4l2_subdev *sd); 585extern int dw9718_vcm_power_up(struct v4l2_subdev *sd);
600extern int dw9718_vcm_power_down(struct v4l2_subdev *sd); 586extern int dw9718_vcm_power_down(struct v4l2_subdev *sd);
601extern int dw9718_vcm_init(struct v4l2_subdev *sd);
602
603extern int dw9718_t_focus_vcm(struct v4l2_subdev *sd, u16 val);
604extern int dw9718_t_focus_abs(struct v4l2_subdev *sd, s32 value); 587extern int dw9718_t_focus_abs(struct v4l2_subdev *sd, s32 value);
605extern int dw9718_t_focus_rel(struct v4l2_subdev *sd, s32 value); 588extern int dw9718_t_focus_rel(struct v4l2_subdev *sd, s32 value);
606extern int dw9718_q_focus_status(struct v4l2_subdev *sd, s32 *value); 589extern int dw9718_q_focus_status(struct v4l2_subdev *sd, s32 *value);
@@ -615,8 +598,6 @@ struct imx_vcm imx_vcms[] = {
615 [IMX175_MERRFLD] = { 598 [IMX175_MERRFLD] = {
616 .power_up = drv201_vcm_power_up, 599 .power_up = drv201_vcm_power_up,
617 .power_down = drv201_vcm_power_down, 600 .power_down = drv201_vcm_power_down,
618 .init = drv201_vcm_init,
619 .t_focus_vcm = drv201_t_focus_vcm,
620 .t_focus_abs = drv201_t_focus_abs, 601 .t_focus_abs = drv201_t_focus_abs,
621 .t_focus_abs_init = NULL, 602 .t_focus_abs_init = NULL,
622 .t_focus_rel = drv201_t_focus_rel, 603 .t_focus_rel = drv201_t_focus_rel,
@@ -628,8 +609,6 @@ struct imx_vcm imx_vcms[] = {
628 [IMX175_VALLEYVIEW] = { 609 [IMX175_VALLEYVIEW] = {
629 .power_up = dw9714_vcm_power_up, 610 .power_up = dw9714_vcm_power_up,
630 .power_down = dw9714_vcm_power_down, 611 .power_down = dw9714_vcm_power_down,
631 .init = dw9714_vcm_init,
632 .t_focus_vcm = dw9714_t_focus_vcm,
633 .t_focus_abs = dw9714_t_focus_abs, 612 .t_focus_abs = dw9714_t_focus_abs,
634 .t_focus_abs_init = NULL, 613 .t_focus_abs_init = NULL,
635 .t_focus_rel = dw9714_t_focus_rel, 614 .t_focus_rel = dw9714_t_focus_rel,
@@ -641,8 +620,6 @@ struct imx_vcm imx_vcms[] = {
641 [IMX135_SALTBAY] = { 620 [IMX135_SALTBAY] = {
642 .power_up = ad5816g_vcm_power_up, 621 .power_up = ad5816g_vcm_power_up,
643 .power_down = ad5816g_vcm_power_down, 622 .power_down = ad5816g_vcm_power_down,
644 .init = ad5816g_vcm_init,
645 .t_focus_vcm = ad5816g_t_focus_vcm,
646 .t_focus_abs = ad5816g_t_focus_abs, 623 .t_focus_abs = ad5816g_t_focus_abs,
647 .t_focus_abs_init = NULL, 624 .t_focus_abs_init = NULL,
648 .t_focus_rel = ad5816g_t_focus_rel, 625 .t_focus_rel = ad5816g_t_focus_rel,
@@ -654,8 +631,6 @@ struct imx_vcm imx_vcms[] = {
654 [IMX135_VICTORIABAY] = { 631 [IMX135_VICTORIABAY] = {
655 .power_up = dw9719_vcm_power_up, 632 .power_up = dw9719_vcm_power_up,
656 .power_down = dw9719_vcm_power_down, 633 .power_down = dw9719_vcm_power_down,
657 .init = dw9719_vcm_init,
658 .t_focus_vcm = dw9719_t_focus_vcm,
659 .t_focus_abs = dw9719_t_focus_abs, 634 .t_focus_abs = dw9719_t_focus_abs,
660 .t_focus_abs_init = NULL, 635 .t_focus_abs_init = NULL,
661 .t_focus_rel = dw9719_t_focus_rel, 636 .t_focus_rel = dw9719_t_focus_rel,
@@ -667,8 +642,6 @@ struct imx_vcm imx_vcms[] = {
667 [IMX134_VALLEYVIEW] = { 642 [IMX134_VALLEYVIEW] = {
668 .power_up = dw9714_vcm_power_up, 643 .power_up = dw9714_vcm_power_up,
669 .power_down = dw9714_vcm_power_down, 644 .power_down = dw9714_vcm_power_down,
670 .init = dw9714_vcm_init,
671 .t_focus_vcm = dw9714_t_focus_vcm,
672 .t_focus_abs = dw9714_t_focus_abs, 645 .t_focus_abs = dw9714_t_focus_abs,
673 .t_focus_abs_init = dw9714_t_focus_abs_init, 646 .t_focus_abs_init = dw9714_t_focus_abs_init,
674 .t_focus_rel = dw9714_t_focus_rel, 647 .t_focus_rel = dw9714_t_focus_rel,
@@ -680,8 +653,6 @@ struct imx_vcm imx_vcms[] = {
680 [IMX219_MFV0_PRH] = { 653 [IMX219_MFV0_PRH] = {
681 .power_up = dw9718_vcm_power_up, 654 .power_up = dw9718_vcm_power_up,
682 .power_down = dw9718_vcm_power_down, 655 .power_down = dw9718_vcm_power_down,
683 .init = dw9718_vcm_init,
684 .t_focus_vcm = dw9718_t_focus_vcm,
685 .t_focus_abs = dw9718_t_focus_abs, 656 .t_focus_abs = dw9718_t_focus_abs,
686 .t_focus_abs_init = NULL, 657 .t_focus_abs_init = NULL,
687 .t_focus_rel = dw9718_t_focus_rel, 658 .t_focus_rel = dw9718_t_focus_rel,
diff --git a/drivers/staging/media/atomisp/i2c/lm3554.c b/drivers/staging/media/atomisp/i2c/lm3554.c
index 2b170c07aaba..679176f7c542 100644
--- a/drivers/staging/media/atomisp/i2c/lm3554.c
+++ b/drivers/staging/media/atomisp/i2c/lm3554.c
@@ -974,7 +974,7 @@ static const struct dev_pm_ops lm3554_pm_ops = {
974 .resume = lm3554_resume, 974 .resume = lm3554_resume,
975}; 975};
976 976
977static struct acpi_device_id lm3554_acpi_match[] = { 977static const struct acpi_device_id lm3554_acpi_match[] = {
978 { "INTCF1C" }, 978 { "INTCF1C" },
979 {}, 979 {},
980}; 980};
diff --git a/drivers/staging/media/atomisp/i2c/mt9m114.c b/drivers/staging/media/atomisp/i2c/mt9m114.c
index 3fa915313e53..3c837cb8859c 100644
--- a/drivers/staging/media/atomisp/i2c/mt9m114.c
+++ b/drivers/staging/media/atomisp/i2c/mt9m114.c
@@ -1209,10 +1209,10 @@ static int mt9m114_s_exposure_selection(struct v4l2_subdev *sd,
1209 return -EINVAL; 1209 return -EINVAL;
1210 } 1210 }
1211 1211
1212 clamp_t(int, win_left, 0, 4); 1212 win_left = clamp_t(int, win_left, 0, 4);
1213 clamp_t(int, win_top, 0, 4); 1213 win_top = clamp_t(int, win_top, 0, 4);
1214 clamp_t(int, win_right, 0, 4); 1214 win_right = clamp_t(int, win_right, 0, 4);
1215 clamp_t(int, win_bottom, 0, 4); 1215 win_bottom = clamp_t(int, win_bottom, 0, 4);
1216 1216
1217 ret = mt9m114_write_reg_array(client, mt9m114_exp_average, NO_POLLING); 1217 ret = mt9m114_write_reg_array(client, mt9m114_exp_average, NO_POLLING);
1218 if (ret) { 1218 if (ret) {
@@ -1806,7 +1806,7 @@ static const struct v4l2_subdev_video_ops mt9m114_video_ops = {
1806 .g_frame_interval = mt9m114_g_frame_interval, 1806 .g_frame_interval = mt9m114_g_frame_interval,
1807}; 1807};
1808 1808
1809static struct v4l2_subdev_sensor_ops mt9m114_sensor_ops = { 1809static const struct v4l2_subdev_sensor_ops mt9m114_sensor_ops = {
1810 .g_skip_frames = mt9m114_g_skip_frames, 1810 .g_skip_frames = mt9m114_g_skip_frames,
1811}; 1811};
1812 1812
@@ -1928,7 +1928,7 @@ static int mt9m114_probe(struct i2c_client *client,
1928 1928
1929MODULE_DEVICE_TABLE(i2c, mt9m114_id); 1929MODULE_DEVICE_TABLE(i2c, mt9m114_id);
1930 1930
1931static struct acpi_device_id mt9m114_acpi_match[] = { 1931static const struct acpi_device_id mt9m114_acpi_match[] = {
1932 { "INT33F0" }, 1932 { "INT33F0" },
1933 { "CRMT1040" }, 1933 { "CRMT1040" },
1934 {}, 1934 {},
diff --git a/drivers/staging/media/atomisp/i2c/ov2680.c b/drivers/staging/media/atomisp/i2c/ov2680.c
index 3cabfe54c669..51b7d61df0f5 100644
--- a/drivers/staging/media/atomisp/i2c/ov2680.c
+++ b/drivers/staging/media/atomisp/i2c/ov2680.c
@@ -89,7 +89,7 @@ static int ov2680_read_reg(struct i2c_client *client,
89 "read from offset 0x%x error %d", reg, err); 89 "read from offset 0x%x error %d", reg, err);
90 return err; 90 return err;
91 } 91 }
92 92
93 *val = 0; 93 *val = 0;
94 /* high byte comes first */ 94 /* high byte comes first */
95 if (data_length == OV2680_8BIT) 95 if (data_length == OV2680_8BIT)
@@ -285,7 +285,6 @@ static int ov2680_g_fnumber(struct v4l2_subdev *sd, s32 *val)
285 285
286static int ov2680_g_fnumber_range(struct v4l2_subdev *sd, s32 *val) 286static int ov2680_g_fnumber_range(struct v4l2_subdev *sd, s32 *val)
287{ 287{
288
289 *val = (OV2680_F_NUMBER_DEFAULT_NUM << 24) | 288 *val = (OV2680_F_NUMBER_DEFAULT_NUM << 24) |
290 (OV2680_F_NUMBER_DEM << 16) | 289 (OV2680_F_NUMBER_DEM << 16) |
291 (OV2680_F_NUMBER_DEFAULT_NUM << 8) | OV2680_F_NUMBER_DEM; 290 (OV2680_F_NUMBER_DEFAULT_NUM << 8) | OV2680_F_NUMBER_DEM;
@@ -306,7 +305,7 @@ static int ov2680_g_bin_factor_y(struct v4l2_subdev *sd, s32 *val)
306{ 305{
307 struct ov2680_device *dev = to_ov2680_sensor(sd); 306 struct ov2680_device *dev = to_ov2680_sensor(sd);
308 struct i2c_client *client = v4l2_get_subdevdata(sd); 307 struct i2c_client *client = v4l2_get_subdevdata(sd);
309 308
310 *val = ov2680_res[dev->fmt_idx].bin_factor_y; 309 *val = ov2680_res[dev->fmt_idx].bin_factor_y;
311 dev_dbg(&client->dev, "++++ov2680_g_bin_factor_y\n"); 310 dev_dbg(&client->dev, "++++ov2680_g_bin_factor_y\n");
312 return 0; 311 return 0;
@@ -399,7 +398,7 @@ static long __ov2680_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
399 struct ov2680_device *dev = to_ov2680_sensor(sd); 398 struct ov2680_device *dev = to_ov2680_sensor(sd);
400 u16 vts,hts; 399 u16 vts,hts;
401 int ret,exp_val; 400 int ret,exp_val;
402 401
403 dev_dbg(&client->dev, "+++++++__ov2680_set_exposure coarse_itg %d, gain %d, digitgain %d++\n",coarse_itg, gain, digitgain); 402 dev_dbg(&client->dev, "+++++++__ov2680_set_exposure coarse_itg %d, gain %d, digitgain %d++\n",coarse_itg, gain, digitgain);
404 403
405 hts = ov2680_res[dev->fmt_idx].pixels_per_line; 404 hts = ov2680_res[dev->fmt_idx].pixels_per_line;
@@ -542,7 +541,7 @@ static long ov2680_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
542 switch (cmd) { 541 switch (cmd) {
543 case ATOMISP_IOC_S_EXPOSURE: 542 case ATOMISP_IOC_S_EXPOSURE:
544 return ov2680_s_exposure(sd, arg); 543 return ov2680_s_exposure(sd, arg);
545 544
546 default: 545 default:
547 return -EINVAL; 546 return -EINVAL;
548 } 547 }
@@ -983,7 +982,7 @@ static int ov2680_s_power(struct v4l2_subdev *sd, int on)
983 if (on == 0){ 982 if (on == 0){
984 ret = power_down(sd); 983 ret = power_down(sd);
985 } else { 984 } else {
986 ret = power_up(sd); 985 ret = power_up(sd);
987 if (!ret) 986 if (!ret)
988 return ov2680_init(sd); 987 return ov2680_init(sd);
989 } 988 }
@@ -1207,7 +1206,7 @@ static int ov2680_s_stream(struct v4l2_subdev *sd, int enable)
1207 dev_dbg(&client->dev, "ov2680_s_stream one \n"); 1206 dev_dbg(&client->dev, "ov2680_s_stream one \n");
1208 else 1207 else
1209 dev_dbg(&client->dev, "ov2680_s_stream off \n"); 1208 dev_dbg(&client->dev, "ov2680_s_stream off \n");
1210 1209
1211 ret = ov2680_write_reg(client, OV2680_8BIT, OV2680_SW_STREAM, 1210 ret = ov2680_write_reg(client, OV2680_8BIT, OV2680_SW_STREAM,
1212 enable ? OV2680_START_STREAMING : 1211 enable ? OV2680_START_STREAMING :
1213 OV2680_STOP_STREAMING); 1212 OV2680_STOP_STREAMING);
@@ -1267,7 +1266,7 @@ static int ov2680_s_config(struct v4l2_subdev *sd,
1267 dev_err(&client->dev, "ov2680_detect err s_config.\n"); 1266 dev_err(&client->dev, "ov2680_detect err s_config.\n");
1268 goto fail_csi_cfg; 1267 goto fail_csi_cfg;
1269 } 1268 }
1270 1269
1271 /* turn off sensor, after probed */ 1270 /* turn off sensor, after probed */
1272 ret = power_down(sd); 1271 ret = power_down(sd);
1273 if (ret) { 1272 if (ret) {
@@ -1385,7 +1384,7 @@ static int ov2680_enum_frame_size(struct v4l2_subdev *sd,
1385static int ov2680_g_skip_frames(struct v4l2_subdev *sd, u32 *frames) 1384static int ov2680_g_skip_frames(struct v4l2_subdev *sd, u32 *frames)
1386{ 1385{
1387 struct ov2680_device *dev = to_ov2680_sensor(sd); 1386 struct ov2680_device *dev = to_ov2680_sensor(sd);
1388 1387
1389 mutex_lock(&dev->input_lock); 1388 mutex_lock(&dev->input_lock);
1390 *frames = ov2680_res[dev->fmt_idx].skip_frames; 1389 *frames = ov2680_res[dev->fmt_idx].skip_frames;
1391 mutex_unlock(&dev->input_lock); 1390 mutex_unlock(&dev->input_lock);
@@ -1517,7 +1516,7 @@ out_free:
1517 return ret; 1516 return ret;
1518} 1517}
1519 1518
1520static struct acpi_device_id ov2680_acpi_match[] = { 1519static const struct acpi_device_id ov2680_acpi_match[] = {
1521 {"XXOV2680"}, 1520 {"XXOV2680"},
1522 {"OVTI2680"}, 1521 {"OVTI2680"},
1523 {}, 1522 {},
diff --git a/drivers/staging/media/atomisp/i2c/ov2722.c b/drivers/staging/media/atomisp/i2c/ov2722.c
index b7afadebdf89..10094ac56561 100644
--- a/drivers/staging/media/atomisp/i2c/ov2722.c
+++ b/drivers/staging/media/atomisp/i2c/ov2722.c
@@ -1337,7 +1337,7 @@ out_free:
1337 1337
1338MODULE_DEVICE_TABLE(i2c, ov2722_id); 1338MODULE_DEVICE_TABLE(i2c, ov2722_id);
1339 1339
1340static struct acpi_device_id ov2722_acpi_match[] = { 1340static const struct acpi_device_id ov2722_acpi_match[] = {
1341 { "INT33FB" }, 1341 { "INT33FB" },
1342 {}, 1342 {},
1343}; 1343};
diff --git a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c
index d6447398f5ef..123642557aa8 100644
--- a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c
+++ b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.c
@@ -146,7 +146,7 @@ static int ov5693_read_reg(struct i2c_client *client,
146 return -EINVAL; 146 return -EINVAL;
147 } 147 }
148 148
149 memset(msg, 0 , sizeof(msg)); 149 memset(msg, 0, sizeof(msg));
150 150
151 msg[0].addr = client->addr; 151 msg[0].addr = client->addr;
152 msg[0].flags = 0; 152 msg[0].flags = 0;
@@ -702,7 +702,7 @@ static long ov5693_s_exposure(struct v4l2_subdev *sd,
702} 702}
703 703
704static int ov5693_read_otp_reg_array(struct i2c_client *client, u16 size, 704static int ov5693_read_otp_reg_array(struct i2c_client *client, u16 size,
705 u16 addr, u8 * buf) 705 u16 addr, u8 *buf)
706{ 706{
707 u16 index; 707 u16 index;
708 int ret; 708 int ret;
@@ -720,7 +720,7 @@ static int ov5693_read_otp_reg_array(struct i2c_client *client, u16 size,
720 return 0; 720 return 0;
721} 721}
722 722
723static int __ov5693_otp_read(struct v4l2_subdev *sd, u8 * buf) 723static int __ov5693_otp_read(struct v4l2_subdev *sd, u8 *buf)
724{ 724{
725 struct i2c_client *client = v4l2_get_subdevdata(sd); 725 struct i2c_client *client = v4l2_get_subdevdata(sd);
726 struct ov5693_device *dev = to_ov5693_sensor(sd); 726 struct ov5693_device *dev = to_ov5693_sensor(sd);
@@ -913,7 +913,7 @@ err:
913 return ret; 913 return ret;
914} 914}
915 915
916int ad5823_t_focus_vcm(struct v4l2_subdev *sd, u16 val) 916static int ad5823_t_focus_vcm(struct v4l2_subdev *sd, u16 val)
917{ 917{
918 struct i2c_client *client = v4l2_get_subdevdata(sd); 918 struct i2c_client *client = v4l2_get_subdevdata(sd);
919 int ret = -EINVAL; 919 int ret = -EINVAL;
@@ -2032,7 +2032,7 @@ out_free:
2032 2032
2033MODULE_DEVICE_TABLE(i2c, ov5693_id); 2033MODULE_DEVICE_TABLE(i2c, ov5693_id);
2034 2034
2035static struct acpi_device_id ov5693_acpi_match[] = { 2035static const struct acpi_device_id ov5693_acpi_match[] = {
2036 {"INT33BE"}, 2036 {"INT33BE"},
2037 {}, 2037 {},
2038}; 2038};
diff --git a/drivers/staging/media/atomisp/i2c/ov8858.c b/drivers/staging/media/atomisp/i2c/ov8858.c
index 9574bc49113c..43e1638fd674 100644
--- a/drivers/staging/media/atomisp/i2c/ov8858.c
+++ b/drivers/staging/media/atomisp/i2c/ov8858.c
@@ -2189,7 +2189,7 @@ static const struct i2c_device_id ov8858_id[] = {
2189 2189
2190MODULE_DEVICE_TABLE(i2c, ov8858_id); 2190MODULE_DEVICE_TABLE(i2c, ov8858_id);
2191 2191
2192static struct acpi_device_id ov8858_acpi_match[] = { 2192static const struct acpi_device_id ov8858_acpi_match[] = {
2193 {"INT3477"}, 2193 {"INT3477"},
2194 {}, 2194 {},
2195}; 2195};
diff --git a/drivers/staging/media/atomisp/i2c/ov8858.h b/drivers/staging/media/atomisp/i2c/ov8858.h
index d3fde200c013..638d1a803a2b 100644
--- a/drivers/staging/media/atomisp/i2c/ov8858.h
+++ b/drivers/staging/media/atomisp/i2c/ov8858.h
@@ -164,7 +164,6 @@ struct ov8858_vcm {
164 int (*power_up)(struct v4l2_subdev *sd); 164 int (*power_up)(struct v4l2_subdev *sd);
165 int (*power_down)(struct v4l2_subdev *sd); 165 int (*power_down)(struct v4l2_subdev *sd);
166 int (*init)(struct v4l2_subdev *sd); 166 int (*init)(struct v4l2_subdev *sd);
167 int (*t_focus_vcm)(struct v4l2_subdev *sd, u16 val);
168 int (*t_focus_abs)(struct v4l2_subdev *sd, s32 value); 167 int (*t_focus_abs)(struct v4l2_subdev *sd, s32 value);
169 int (*t_focus_rel)(struct v4l2_subdev *sd, s32 value); 168 int (*t_focus_rel)(struct v4l2_subdev *sd, s32 value);
170 int (*q_focus_status)(struct v4l2_subdev *sd, s32 *value); 169 int (*q_focus_status)(struct v4l2_subdev *sd, s32 *value);
@@ -312,7 +311,6 @@ static const struct ov8858_reg ov8858_param_update[] = {
312extern int dw9718_vcm_power_up(struct v4l2_subdev *sd); 311extern int dw9718_vcm_power_up(struct v4l2_subdev *sd);
313extern int dw9718_vcm_power_down(struct v4l2_subdev *sd); 312extern int dw9718_vcm_power_down(struct v4l2_subdev *sd);
314extern int dw9718_vcm_init(struct v4l2_subdev *sd); 313extern int dw9718_vcm_init(struct v4l2_subdev *sd);
315extern int dw9718_t_focus_vcm(struct v4l2_subdev *sd, u16 val);
316extern int dw9718_t_focus_abs(struct v4l2_subdev *sd, s32 value); 314extern int dw9718_t_focus_abs(struct v4l2_subdev *sd, s32 value);
317extern int dw9718_t_focus_rel(struct v4l2_subdev *sd, s32 value); 315extern int dw9718_t_focus_rel(struct v4l2_subdev *sd, s32 value);
318extern int dw9718_q_focus_status(struct v4l2_subdev *sd, s32 *value); 316extern int dw9718_q_focus_status(struct v4l2_subdev *sd, s32 *value);
@@ -328,7 +326,6 @@ static struct ov8858_vcm ov8858_vcms[] = {
328 .power_up = dw9718_vcm_power_up, 326 .power_up = dw9718_vcm_power_up,
329 .power_down = dw9718_vcm_power_down, 327 .power_down = dw9718_vcm_power_down,
330 .init = dw9718_vcm_init, 328 .init = dw9718_vcm_init,
331 .t_focus_vcm = dw9718_t_focus_vcm,
332 .t_focus_abs = dw9718_t_focus_abs, 329 .t_focus_abs = dw9718_t_focus_abs,
333 .t_focus_rel = dw9718_t_focus_rel, 330 .t_focus_rel = dw9718_t_focus_rel,
334 .q_focus_status = dw9718_q_focus_status, 331 .q_focus_status = dw9718_q_focus_status,
diff --git a/drivers/staging/media/atomisp/i2c/ov8858_btns.h b/drivers/staging/media/atomisp/i2c/ov8858_btns.h
index f9a3cf8fbf1a..7d74a8899fae 100644
--- a/drivers/staging/media/atomisp/i2c/ov8858_btns.h
+++ b/drivers/staging/media/atomisp/i2c/ov8858_btns.h
@@ -164,7 +164,6 @@ struct ov8858_vcm {
164 int (*power_up)(struct v4l2_subdev *sd); 164 int (*power_up)(struct v4l2_subdev *sd);
165 int (*power_down)(struct v4l2_subdev *sd); 165 int (*power_down)(struct v4l2_subdev *sd);
166 int (*init)(struct v4l2_subdev *sd); 166 int (*init)(struct v4l2_subdev *sd);
167 int (*t_focus_vcm)(struct v4l2_subdev *sd, u16 val);
168 int (*t_focus_abs)(struct v4l2_subdev *sd, s32 value); 167 int (*t_focus_abs)(struct v4l2_subdev *sd, s32 value);
169 int (*t_focus_rel)(struct v4l2_subdev *sd, s32 value); 168 int (*t_focus_rel)(struct v4l2_subdev *sd, s32 value);
170 int (*q_focus_status)(struct v4l2_subdev *sd, s32 *value); 169 int (*q_focus_status)(struct v4l2_subdev *sd, s32 *value);
@@ -312,7 +311,6 @@ static const struct ov8858_reg ov8858_param_update[] = {
312extern int dw9718_vcm_power_up(struct v4l2_subdev *sd); 311extern int dw9718_vcm_power_up(struct v4l2_subdev *sd);
313extern int dw9718_vcm_power_down(struct v4l2_subdev *sd); 312extern int dw9718_vcm_power_down(struct v4l2_subdev *sd);
314extern int dw9718_vcm_init(struct v4l2_subdev *sd); 313extern int dw9718_vcm_init(struct v4l2_subdev *sd);
315extern int dw9718_t_focus_vcm(struct v4l2_subdev *sd, u16 val);
316extern int dw9718_t_focus_abs(struct v4l2_subdev *sd, s32 value); 314extern int dw9718_t_focus_abs(struct v4l2_subdev *sd, s32 value);
317extern int dw9718_t_focus_rel(struct v4l2_subdev *sd, s32 value); 315extern int dw9718_t_focus_rel(struct v4l2_subdev *sd, s32 value);
318extern int dw9718_q_focus_status(struct v4l2_subdev *sd, s32 *value); 316extern int dw9718_q_focus_status(struct v4l2_subdev *sd, s32 *value);
@@ -328,7 +326,6 @@ static struct ov8858_vcm ov8858_vcms[] = {
328 .power_up = dw9718_vcm_power_up, 326 .power_up = dw9718_vcm_power_up,
329 .power_down = dw9718_vcm_power_down, 327 .power_down = dw9718_vcm_power_down,
330 .init = dw9718_vcm_init, 328 .init = dw9718_vcm_init,
331 .t_focus_vcm = dw9718_t_focus_vcm,
332 .t_focus_abs = dw9718_t_focus_abs, 329 .t_focus_abs = dw9718_t_focus_abs,
333 .t_focus_rel = dw9718_t_focus_rel, 330 .t_focus_rel = dw9718_t_focus_rel,
334 .q_focus_status = dw9718_q_focus_status, 331 .q_focus_status = dw9718_q_focus_status,
diff --git a/drivers/staging/media/atomisp/include/linux/atomisp.h b/drivers/staging/media/atomisp/include/linux/atomisp.h
index 35865462ccf9..d67dd658cff9 100644
--- a/drivers/staging/media/atomisp/include/linux/atomisp.h
+++ b/drivers/staging/media/atomisp/include/linux/atomisp.h
@@ -28,12 +28,6 @@
28#include <linux/types.h> 28#include <linux/types.h>
29#include <linux/version.h> 29#include <linux/version.h>
30 30
31/* struct media_device_info.driver_version */
32#define ATOMISP_CSS_VERSION_MASK 0x00ffffff
33#define ATOMISP_CSS_VERSION_15 KERNEL_VERSION(1, 5, 0)
34#define ATOMISP_CSS_VERSION_20 KERNEL_VERSION(2, 0, 0)
35#define ATOMISP_CSS_VERSION_21 KERNEL_VERSION(2, 1, 0)
36
37/* struct media_device_info.hw_revision */ 31/* struct media_device_info.hw_revision */
38#define ATOMISP_HW_REVISION_MASK 0x0000ff00 32#define ATOMISP_HW_REVISION_MASK 0x0000ff00
39#define ATOMISP_HW_REVISION_SHIFT 8 33#define ATOMISP_HW_REVISION_SHIFT 8
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 97093baf28ac..f48bf451c1f5 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -83,48 +83,6 @@ union host {
83}; 83};
84 84
85/* 85/*
86 * atomisp_kernel_malloc: chooses whether kmalloc() or vmalloc() is preferable.
87 *
88 * It is also a wrap functions to pass into css framework.
89 */
90void *atomisp_kernel_malloc(size_t bytes)
91{
92 /* vmalloc() is preferable if allocating more than 1 page */
93 if (bytes > PAGE_SIZE)
94 return vmalloc(bytes);
95
96 return kmalloc(bytes, GFP_KERNEL);
97}
98
99/*
100 * atomisp_kernel_zalloc: chooses whether set 0 to the allocated memory.
101 *
102 * It is also a wrap functions to pass into css framework.
103 */
104void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem)
105{
106 void *ptr = atomisp_kernel_malloc(bytes);
107
108 if (ptr && zero_mem)
109 memset(ptr, 0, bytes);
110
111 return ptr;
112}
113
114/*
115 * Free buffer allocated with atomisp_kernel_malloc()/atomisp_kernel_zalloc
116 * helper
117 */
118void atomisp_kernel_free(void *ptr)
119{
120 /* Verify if buffer was allocated by vmalloc() or kmalloc() */
121 if (is_vmalloc_addr(ptr))
122 vfree(ptr);
123 else
124 kfree(ptr);
125}
126
127/*
128 * get sensor:dis71430/ov2720 related info from v4l2_subdev->priv data field. 86 * get sensor:dis71430/ov2720 related info from v4l2_subdev->priv data field.
129 * subdev->priv is set in mrst.c 87 * subdev->priv is set in mrst.c
130 */ 88 */
@@ -785,7 +743,7 @@ void atomisp_flush_params_queue(struct atomisp_video_pipe *pipe)
785 struct atomisp_css_params_with_list, list); 743 struct atomisp_css_params_with_list, list);
786 list_del(&param->list); 744 list_del(&param->list);
787 atomisp_free_css_parameters(&param->params); 745 atomisp_free_css_parameters(&param->params);
788 atomisp_kernel_free(param); 746 kvfree(param);
789 } 747 }
790} 748}
791 749
@@ -1132,7 +1090,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
1132 asd->params.dvs_6axis = NULL; 1090 asd->params.dvs_6axis = NULL;
1133 atomisp_free_css_parameters( 1091 atomisp_free_css_parameters(
1134 &pipe->frame_params[vb->i]->params); 1092 &pipe->frame_params[vb->i]->params);
1135 atomisp_kernel_free(pipe->frame_params[vb->i]); 1093 kvfree(pipe->frame_params[vb->i]);
1136 pipe->frame_params[vb->i] = NULL; 1094 pipe->frame_params[vb->i] = NULL;
1137 } 1095 }
1138 1096
@@ -4329,7 +4287,7 @@ int atomisp_set_parameters(struct video_device *vdev,
4329 * are ready, the parameters will be set to CSS. 4287 * are ready, the parameters will be set to CSS.
4330 * per-frame setting only works for the main output frame. 4288 * per-frame setting only works for the main output frame.
4331 */ 4289 */
4332 param = atomisp_kernel_zalloc(sizeof(*param), true); 4290 param = kvzalloc(sizeof(*param), GFP_KERNEL);
4333 if (!param) { 4291 if (!param) {
4334 dev_err(asd->isp->dev, "%s: failed to alloc params buffer\n", 4292 dev_err(asd->isp->dev, "%s: failed to alloc params buffer\n",
4335 __func__); 4293 __func__);
@@ -4375,7 +4333,7 @@ apply_parameter_failed:
4375 if (css_param) 4333 if (css_param)
4376 atomisp_free_css_parameters(css_param); 4334 atomisp_free_css_parameters(css_param);
4377 if (param) 4335 if (param)
4378 atomisp_kernel_free(param); 4336 kvfree(param);
4379 4337
4380 return ret; 4338 return ret;
4381} 4339}
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h
index 8e6d9df7ad1a..31ba4e613d13 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h
@@ -78,9 +78,6 @@ static inline void __iomem *atomisp_get_io_virt_addr(unsigned int address)
78 return ret; 78 return ret;
79} 79}
80*/ 80*/
81void *atomisp_kernel_malloc(size_t bytes);
82void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem);
83void atomisp_kernel_free(void *ptr);
84 81
85/* 82/*
86 * Interrupt functions 83 * Interrupt functions
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
index ad2c610d2ce3..05897b747349 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
@@ -1671,12 +1671,12 @@ int atomisp_alloc_metadata_output_buf(struct atomisp_sub_device *asd)
1671 /* We allocate the cpu-side buffer used for communication with user 1671 /* We allocate the cpu-side buffer used for communication with user
1672 * space */ 1672 * space */
1673 for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) { 1673 for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
1674 asd->params.metadata_user[i] = atomisp_kernel_malloc( 1674 asd->params.metadata_user[i] = kvmalloc(
1675 asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]. 1675 asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].
1676 stream_info.metadata_info.size); 1676 stream_info.metadata_info.size, GFP_KERNEL);
1677 if (!asd->params.metadata_user[i]) { 1677 if (!asd->params.metadata_user[i]) {
1678 while (--i >= 0) { 1678 while (--i >= 0) {
1679 atomisp_kernel_free(asd->params.metadata_user[i]); 1679 kvfree(asd->params.metadata_user[i]);
1680 asd->params.metadata_user[i] = NULL; 1680 asd->params.metadata_user[i] = NULL;
1681 } 1681 }
1682 return -ENOMEM; 1682 return -ENOMEM;
@@ -1692,7 +1692,7 @@ void atomisp_free_metadata_output_buf(struct atomisp_sub_device *asd)
1692 1692
1693 for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) { 1693 for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
1694 if (asd->params.metadata_user[i]) { 1694 if (asd->params.metadata_user[i]) {
1695 atomisp_kernel_free(asd->params.metadata_user[i]); 1695 kvfree(asd->params.metadata_user[i]);
1696 asd->params.metadata_user[i] = NULL; 1696 asd->params.metadata_user[i] = NULL;
1697 } 1697 }
1698 } 1698 }
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c
index c151c848cf8f..d8cfed358d55 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c
@@ -643,14 +643,14 @@ static void atomisp_buf_release_output(struct videobuf_queue *vq,
643 vb->state = VIDEOBUF_NEEDS_INIT; 643 vb->state = VIDEOBUF_NEEDS_INIT;
644} 644}
645 645
646static struct videobuf_queue_ops videobuf_qops = { 646static const struct videobuf_queue_ops videobuf_qops = {
647 .buf_setup = atomisp_buf_setup, 647 .buf_setup = atomisp_buf_setup,
648 .buf_prepare = atomisp_buf_prepare, 648 .buf_prepare = atomisp_buf_prepare,
649 .buf_queue = atomisp_buf_queue, 649 .buf_queue = atomisp_buf_queue,
650 .buf_release = atomisp_buf_release, 650 .buf_release = atomisp_buf_release,
651}; 651};
652 652
653static struct videobuf_queue_ops videobuf_qops_output = { 653static const struct videobuf_queue_ops videobuf_qops_output = {
654 .buf_setup = atomisp_buf_setup_output, 654 .buf_setup = atomisp_buf_setup_output,
655 .buf_prepare = atomisp_buf_prepare_output, 655 .buf_prepare = atomisp_buf_prepare_output,
656 .buf_queue = atomisp_buf_queue_output, 656 .buf_queue = atomisp_buf_queue_output,
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h
index c8e0c4fe3717..7542a72f1d0f 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h
@@ -75,15 +75,6 @@
75#define ATOMISP_PCI_REV_MRFLD_A0_MAX 0 75#define ATOMISP_PCI_REV_MRFLD_A0_MAX 0
76#define ATOMISP_PCI_REV_BYT_A0_MAX 4 76#define ATOMISP_PCI_REV_BYT_A0_MAX 4
77 77
78#define ATOMISP_MAJOR 0
79#define ATOMISP_MINOR 5
80#define ATOMISP_PATCHLEVEL 1
81
82#define DRIVER_VERSION_STR __stringify(ATOMISP_MAJOR) \
83 "." __stringify(ATOMISP_MINOR) "." __stringify(ATOMISP_PATCHLEVEL)
84#define DRIVER_VERSION KERNEL_VERSION(ATOMISP_MAJOR, \
85 ATOMISP_MINOR, ATOMISP_PATCHLEVEL)
86
87#define ATOM_ISP_STEP_WIDTH 2 78#define ATOM_ISP_STEP_WIDTH 2
88#define ATOM_ISP_STEP_HEIGHT 2 79#define ATOM_ISP_STEP_HEIGHT 2
89 80
@@ -310,10 +301,6 @@ struct atomisp_device {
310 301
311extern struct device *atomisp_dev; 302extern struct device *atomisp_dev;
312 303
313extern void *atomisp_kernel_malloc(size_t bytes);
314
315extern void atomisp_kernel_free(void *ptr);
316
317#define atomisp_is_wdt_running(a) timer_pending(&(a)->wdt) 304#define atomisp_is_wdt_running(a) timer_pending(&(a)->wdt)
318#ifdef ISP2401 305#ifdef ISP2401
319extern void atomisp_wdt_refresh_pipe(struct atomisp_video_pipe *pipe, 306extern void atomisp_wdt_refresh_pipe(struct atomisp_video_pipe *pipe,
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c
index aa0526ebaff1..717647951fb6 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c
@@ -51,7 +51,6 @@
51static const char *DRIVER = "atomisp"; /* max size 15 */ 51static const char *DRIVER = "atomisp"; /* max size 15 */
52static const char *CARD = "ATOM ISP"; /* max size 31 */ 52static const char *CARD = "ATOM ISP"; /* max size 31 */
53static const char *BUS_INFO = "PCI-3"; /* max size 31 */ 53static const char *BUS_INFO = "PCI-3"; /* max size 31 */
54static const u32 VERSION = DRIVER_VERSION;
55 54
56/* 55/*
57 * FIXME: ISP should not know beforehand all CIDs supported by sensor. 56 * FIXME: ISP should not know beforehand all CIDs supported by sensor.
@@ -562,8 +561,6 @@ static int atomisp_querycap(struct file *file, void *fh,
562 strncpy(cap->card, CARD, sizeof(cap->card) - 1); 561 strncpy(cap->card, CARD, sizeof(cap->card) - 1);
563 strncpy(cap->bus_info, BUS_INFO, sizeof(cap->card) - 1); 562 strncpy(cap->bus_info, BUS_INFO, sizeof(cap->card) - 1);
564 563
565 cap->version = VERSION;
566
567 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | 564 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE |
568 V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_OUTPUT; 565 V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_OUTPUT;
569 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; 566 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_subdev.c
index 3d6bb166927c..744ab6eb42a0 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_subdev.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_subdev.c
@@ -1253,8 +1253,7 @@ int atomisp_create_pads_links(struct atomisp_device *isp)
1253{ 1253{
1254 struct atomisp_sub_device *asd; 1254 struct atomisp_sub_device *asd;
1255 int i, j, ret = 0; 1255 int i, j, ret = 0;
1256 isp->num_of_streams = isp->media_dev.driver_version >= 1256 isp->num_of_streams = 2;
1257 ATOMISP_CSS_VERSION_20 ? 2 : 1;
1258 for (i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++) { 1257 for (i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++) {
1259 for (j = 0; j < isp->num_of_streams; j++) { 1258 for (j = 0; j < isp->num_of_streams; j++) {
1260 ret = 1259 ret =
@@ -1414,8 +1413,7 @@ int atomisp_subdev_init(struct atomisp_device *isp)
1414 * CSS2.0 running ISP2400 support 1413 * CSS2.0 running ISP2400 support
1415 * multiple streams 1414 * multiple streams
1416 */ 1415 */
1417 isp->num_of_streams = isp->media_dev.driver_version >= 1416 isp->num_of_streams = 2;
1418 ATOMISP_CSS_VERSION_20 ? 2 : 1;
1419 isp->asd = devm_kzalloc(isp->dev, sizeof(struct atomisp_sub_device) * 1417 isp->asd = devm_kzalloc(isp->dev, sizeof(struct atomisp_sub_device) *
1420 isp->num_of_streams, GFP_KERNEL); 1418 isp->num_of_streams, GFP_KERNEL);
1421 if (!isp->asd) 1419 if (!isp->asd)
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c
index a543def739fc..663aa916e3ca 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c
@@ -1083,27 +1083,23 @@ atomisp_load_firmware(struct atomisp_device *isp)
1083 if (skip_fwload) 1083 if (skip_fwload)
1084 return NULL; 1084 return NULL;
1085 1085
1086 if (isp->media_dev.driver_version == ATOMISP_CSS_VERSION_21) { 1086 if (isp->media_dev.hw_revision ==
1087 if (isp->media_dev.hw_revision == 1087 ((ATOMISP_HW_REVISION_ISP2401 << ATOMISP_HW_REVISION_SHIFT)
1088 ((ATOMISP_HW_REVISION_ISP2401 << ATOMISP_HW_REVISION_SHIFT) 1088 | ATOMISP_HW_STEPPING_A0))
1089 | ATOMISP_HW_STEPPING_A0)) 1089 fw_path = "shisp_2401a0_v21.bin";
1090 fw_path = "shisp_2401a0_v21.bin"; 1090
1091 1091 if (isp->media_dev.hw_revision ==
1092 if (isp->media_dev.hw_revision == 1092 ((ATOMISP_HW_REVISION_ISP2401_LEGACY << ATOMISP_HW_REVISION_SHIFT)
1093 ((ATOMISP_HW_REVISION_ISP2401_LEGACY << ATOMISP_HW_REVISION_SHIFT) 1093 | ATOMISP_HW_STEPPING_A0))
1094 | ATOMISP_HW_STEPPING_A0)) 1094 fw_path = "shisp_2401a0_legacy_v21.bin";
1095 fw_path = "shisp_2401a0_legacy_v21.bin"; 1095
1096 1096 if (isp->media_dev.hw_revision ==
1097 if (isp->media_dev.hw_revision == 1097 ((ATOMISP_HW_REVISION_ISP2400 << ATOMISP_HW_REVISION_SHIFT)
1098 ((ATOMISP_HW_REVISION_ISP2400 << ATOMISP_HW_REVISION_SHIFT) 1098 | ATOMISP_HW_STEPPING_B0))
1099 | ATOMISP_HW_STEPPING_B0)) 1099 fw_path = "shisp_2400b0_v21.bin";
1100 fw_path = "shisp_2400b0_v21.bin";
1101 }
1102 1100
1103 if (!fw_path) { 1101 if (!fw_path) {
1104 dev_err(isp->dev, 1102 dev_err(isp->dev, "Unsupported hw_revision 0x%x\n",
1105 "Unsupported driver_version 0x%x, hw_revision 0x%x\n",
1106 isp->media_dev.driver_version,
1107 isp->media_dev.hw_revision); 1103 isp->media_dev.hw_revision);
1108 return NULL; 1104 return NULL;
1109 } 1105 }
@@ -1251,7 +1247,6 @@ static int atomisp_pci_probe(struct pci_dev *dev,
1251 /* This is not a true PCI device on SoC, so the delay is not needed. */ 1247 /* This is not a true PCI device on SoC, so the delay is not needed. */
1252 isp->pdev->d3_delay = 0; 1248 isp->pdev->d3_delay = 0;
1253 1249
1254 isp->media_dev.driver_version = ATOMISP_CSS_VERSION_21;
1255 switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) { 1250 switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) {
1256 case ATOMISP_PCI_DEVICE_SOC_MRFLD: 1251 case ATOMISP_PCI_DEVICE_SOC_MRFLD:
1257 isp->media_dev.hw_revision = 1252 isp->media_dev.hw_revision =
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isys/src/ibuf_ctrl_rmgr.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isys/src/ibuf_ctrl_rmgr.c
index 76d9142fd37e..faef97672eac 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isys/src/ibuf_ctrl_rmgr.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isys/src/ibuf_ctrl_rmgr.c
@@ -14,18 +14,18 @@
14 */ 14 */
15#else 15#else
16/** 16/**
17Support for Intel Camera Imaging ISP subsystem. 17 * Support for Intel Camera Imaging ISP subsystem.
18Copyright (c) 2010 - 2015, Intel Corporation. 18 * Copyright (c) 2010 - 2015, Intel Corporation.
19 19 *
20This program is free software; you can redistribute it and/or modify it 20 * This program is free software; you can redistribute it and/or modify it
21under the terms and conditions of the GNU General Public License, 21 * under the terms and conditions of the GNU General Public License,
22version 2, as published by the Free Software Foundation. 22 * version 2, as published by the Free Software Foundation.
23 23 *
24This program is distributed in the hope it will be useful, but WITHOUT 24 * This program is distributed in the hope it will be useful, but WITHOUT
25ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 25 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 26 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
27more details. 27 * more details.
28*/ 28 */
29#endif 29#endif
30 30
31#include "system_global.h" 31#include "system_global.h"
@@ -130,8 +130,7 @@ void ia_css_isys_ibuf_rmgr_release(
130 130
131 for (i = 0; i < ibuf_rsrc.num_allocated; i++) { 131 for (i = 0; i < ibuf_rsrc.num_allocated; i++) {
132 handle = getHandle(i); 132 handle = getHandle(i);
133 if ((handle->start_addr == *start_addr) 133 if (handle->active && handle->start_addr == *start_addr) {
134 && ( true == handle->active)) {
135 handle->active = false; 134 handle->active = false;
136 ibuf_rsrc.num_active--; 135 ibuf_rsrc.num_active--;
137 break; 136 break;
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
index 471f2be974e2..e882b5596813 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c
@@ -1939,6 +1939,7 @@ void *sh_css_calloc(size_t N, size_t size)
1939 p = sh_css_malloc(N*size); 1939 p = sh_css_malloc(N*size);
1940 if (p) 1940 if (p)
1941 memset(p, 0, size); 1941 memset(p, 0, size);
1942 return p;
1942 } 1943 }
1943 return NULL; 1944 return NULL;
1944} 1945}
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
index eecd8cf71951..63582161050a 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
@@ -131,14 +131,10 @@ sh_css_load_blob_info(const char *fw, const struct ia_css_fw_info *bi, struct ia
131 131
132 if (bi->type == ia_css_isp_firmware || bi->type == ia_css_sp_firmware) { 132 if (bi->type == ia_css_isp_firmware || bi->type == ia_css_sp_firmware) {
133 char *namebuffer; 133 char *namebuffer;
134 int namelength = (int)strlen(name);
135 134
136 namebuffer = (char *) kmalloc(namelength + 1, GFP_KERNEL); 135 namebuffer = kstrdup(name, GFP_KERNEL);
137 if (namebuffer == NULL) 136 if (!namebuffer)
138 return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY; 137 return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
139
140 memcpy(namebuffer, name, namelength + 1);
141
142 bd->name = fw_minibuffer[index].name = namebuffer; 138 bd->name = fw_minibuffer[index].name = namebuffer;
143 } else { 139 } else {
144 bd->name = name; 140 bd->name = name;
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
index 05eeff58a229..b8aae4ba5a78 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
@@ -46,14 +46,16 @@ static ia_css_ptr dummy_ptr;
46static bool hmm_initialized; 46static bool hmm_initialized;
47struct _hmm_mem_stat hmm_mem_stat; 47struct _hmm_mem_stat hmm_mem_stat;
48 48
49/* p: private 49/*
50 s: shared 50 * p: private
51 u: user 51 * s: shared
52 i: ion */ 52 * u: user
53 * i: ion
54 */
53static const char hmm_bo_type_string[] = "psui"; 55static const char hmm_bo_type_string[] = "psui";
54 56
55static ssize_t bo_show(struct device *dev, struct device_attribute *attr, 57static ssize_t bo_show(struct device *dev, struct device_attribute *attr,
56 char *buf, struct list_head *bo_list, bool active) 58 char *buf, struct list_head *bo_list, bool active)
57{ 59{
58 ssize_t ret = 0; 60 ssize_t ret = 0;
59 struct hmm_buffer_object *bo; 61 struct hmm_buffer_object *bo;
@@ -73,10 +75,10 @@ static ssize_t bo_show(struct device *dev, struct device_attribute *attr,
73 spin_lock_irqsave(&bo_device.list_lock, flags); 75 spin_lock_irqsave(&bo_device.list_lock, flags);
74 list_for_each_entry(bo, bo_list, list) { 76 list_for_each_entry(bo, bo_list, list) {
75 if ((active && (bo->status & HMM_BO_ALLOCED)) || 77 if ((active && (bo->status & HMM_BO_ALLOCED)) ||
76 (!active && !(bo->status & HMM_BO_ALLOCED))) { 78 (!active && !(bo->status & HMM_BO_ALLOCED))) {
77 ret = scnprintf(buf + index1, PAGE_SIZE - index1, 79 ret = scnprintf(buf + index1, PAGE_SIZE - index1,
78 "%c %d\n", 80 "%c %d\n",
79 hmm_bo_type_string[bo->type], bo->pgnr); 81 hmm_bo_type_string[bo->type], bo->pgnr);
80 82
81 total[bo->type] += bo->pgnr; 83 total[bo->type] += bo->pgnr;
82 count[bo->type]++; 84 count[bo->type]++;
@@ -89,9 +91,10 @@ static ssize_t bo_show(struct device *dev, struct device_attribute *attr,
89 for (i = 0; i < HMM_BO_LAST; i++) { 91 for (i = 0; i < HMM_BO_LAST; i++) {
90 if (count[i]) { 92 if (count[i]) {
91 ret = scnprintf(buf + index1 + index2, 93 ret = scnprintf(buf + index1 + index2,
92 PAGE_SIZE - index1 - index2, 94 PAGE_SIZE - index1 - index2,
93 "%ld %c buffer objects: %ld KB\n", 95 "%ld %c buffer objects: %ld KB\n",
94 count[i], hmm_bo_type_string[i], total[i] * 4); 96 count[i], hmm_bo_type_string[i],
97 total[i] * 4);
95 if (ret > 0) 98 if (ret > 0)
96 index2 += ret; 99 index2 += ret;
97 } 100 }
@@ -101,23 +104,21 @@ static ssize_t bo_show(struct device *dev, struct device_attribute *attr,
101 return index1 + index2 + 1; 104 return index1 + index2 + 1;
102} 105}
103 106
104static ssize_t active_bo_show(struct device *dev, 107static ssize_t active_bo_show(struct device *dev, struct device_attribute *attr,
105 struct device_attribute *attr, 108 char *buf)
106 char *buf)
107{ 109{
108 return bo_show(dev, attr, buf, &bo_device.entire_bo_list, true); 110 return bo_show(dev, attr, buf, &bo_device.entire_bo_list, true);
109} 111}
110 112
111static ssize_t free_bo_show(struct device *dev, 113static ssize_t free_bo_show(struct device *dev, struct device_attribute *attr,
112 struct device_attribute *attr, 114 char *buf)
113 char *buf)
114{ 115{
115 return bo_show(dev, attr, buf, &bo_device.entire_bo_list, false); 116 return bo_show(dev, attr, buf, &bo_device.entire_bo_list, false);
116} 117}
117 118
118static ssize_t reserved_pool_show(struct device *dev, 119static ssize_t reserved_pool_show(struct device *dev,
119 struct device_attribute *attr, 120 struct device_attribute *attr,
120 char *buf) 121 char *buf)
121{ 122{
122 ssize_t ret = 0; 123 ssize_t ret = 0;
123 124
@@ -129,7 +130,7 @@ static ssize_t reserved_pool_show(struct device *dev,
129 130
130 spin_lock_irqsave(&pinfo->list_lock, flags); 131 spin_lock_irqsave(&pinfo->list_lock, flags);
131 ret = scnprintf(buf, PAGE_SIZE, "%d out of %d pages available\n", 132 ret = scnprintf(buf, PAGE_SIZE, "%d out of %d pages available\n",
132 pinfo->index, pinfo->pgnr); 133 pinfo->index, pinfo->pgnr);
133 spin_unlock_irqrestore(&pinfo->list_lock, flags); 134 spin_unlock_irqrestore(&pinfo->list_lock, flags);
134 135
135 if (ret > 0) 136 if (ret > 0)
@@ -139,8 +140,8 @@ static ssize_t reserved_pool_show(struct device *dev,
139}; 140};
140 141
141static ssize_t dynamic_pool_show(struct device *dev, 142static ssize_t dynamic_pool_show(struct device *dev,
142 struct device_attribute *attr, 143 struct device_attribute *attr,
143 char *buf) 144 char *buf)
144{ 145{
145 ssize_t ret = 0; 146 ssize_t ret = 0;
146 147
@@ -152,7 +153,7 @@ static ssize_t dynamic_pool_show(struct device *dev,
152 153
153 spin_lock_irqsave(&pinfo->list_lock, flags); 154 spin_lock_irqsave(&pinfo->list_lock, flags);
154 ret = scnprintf(buf, PAGE_SIZE, "%d (max %d) pages available\n", 155 ret = scnprintf(buf, PAGE_SIZE, "%d (max %d) pages available\n",
155 pinfo->pgnr, pinfo->pool_size); 156 pinfo->pgnr, pinfo->pool_size);
156 spin_unlock_irqrestore(&pinfo->list_lock, flags); 157 spin_unlock_irqrestore(&pinfo->list_lock, flags);
157 158
158 if (ret > 0) 159 if (ret > 0)
@@ -200,7 +201,7 @@ int hmm_init(void)
200 201
201 if (!ret) { 202 if (!ret) {
202 ret = sysfs_create_group(&atomisp_dev->kobj, 203 ret = sysfs_create_group(&atomisp_dev->kobj,
203 atomisp_attribute_group); 204 atomisp_attribute_group);
204 if (ret) 205 if (ret)
205 dev_err(atomisp_dev, 206 dev_err(atomisp_dev,
206 "%s Failed to create sysfs\n", __func__); 207 "%s Failed to create sysfs\n", __func__);
@@ -213,9 +214,7 @@ void hmm_cleanup(void)
213{ 214{
214 sysfs_remove_group(&atomisp_dev->kobj, atomisp_attribute_group); 215 sysfs_remove_group(&atomisp_dev->kobj, atomisp_attribute_group);
215 216
216 /* 217 /* free dummy memory first */
217 * free dummy memory first
218 */
219 hmm_free(dummy_ptr); 218 hmm_free(dummy_ptr);
220 dummy_ptr = 0; 219 dummy_ptr = 0;
221 220
@@ -224,36 +223,37 @@ void hmm_cleanup(void)
224} 223}
225 224
226ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, 225ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
227 int from_highmem, void *userptr, bool cached) 226 int from_highmem, void *userptr, bool cached)
228{ 227{
229 unsigned int pgnr; 228 unsigned int pgnr;
230 struct hmm_buffer_object *bo; 229 struct hmm_buffer_object *bo;
231 int ret; 230 int ret;
232 231
233 /* Check if we are initialized. In the ideal world we wouldn't need 232 /*
234 this but we can tackle it once the driver is a lot cleaner */ 233 * Check if we are initialized. In the ideal world we wouldn't need
234 * this but we can tackle it once the driver is a lot cleaner
235 */
235 236
236 if (!hmm_initialized) 237 if (!hmm_initialized)
237 hmm_init(); 238 hmm_init();
238 /*Get page number from size*/ 239 /* Get page number from size */
239 pgnr = size_to_pgnr_ceil(bytes); 240 pgnr = size_to_pgnr_ceil(bytes);
240 241
241 /*Buffer object structure init*/ 242 /* Buffer object structure init */
242 bo = hmm_bo_alloc(&bo_device, pgnr); 243 bo = hmm_bo_alloc(&bo_device, pgnr);
243 if (!bo) { 244 if (!bo) {
244 dev_err(atomisp_dev, "hmm_bo_create failed.\n"); 245 dev_err(atomisp_dev, "hmm_bo_create failed.\n");
245 goto create_bo_err; 246 goto create_bo_err;
246 } 247 }
247 248
248 /*Allocate pages for memory*/ 249 /* Allocate pages for memory */
249 ret = hmm_bo_alloc_pages(bo, type, from_highmem, userptr, cached); 250 ret = hmm_bo_alloc_pages(bo, type, from_highmem, userptr, cached);
250 if (ret) { 251 if (ret) {
251 dev_err(atomisp_dev, 252 dev_err(atomisp_dev, "hmm_bo_alloc_pages failed.\n");
252 "hmm_bo_alloc_pages failed.\n");
253 goto alloc_page_err; 253 goto alloc_page_err;
254 } 254 }
255 255
256 /*Combind the virtual address and pages togather*/ 256 /* Combind the virtual address and pages togather */
257 ret = hmm_bo_bind(bo); 257 ret = hmm_bo_bind(bo);
258 if (ret) { 258 if (ret) {
259 dev_err(atomisp_dev, "hmm_bo_bind failed.\n"); 259 dev_err(atomisp_dev, "hmm_bo_bind failed.\n");
@@ -282,8 +282,8 @@ void hmm_free(ia_css_ptr virt)
282 282
283 if (!bo) { 283 if (!bo) {
284 dev_err(atomisp_dev, 284 dev_err(atomisp_dev,
285 "can not find buffer object start with " 285 "can not find buffer object start with address 0x%x\n",
286 "address 0x%x\n", (unsigned int)virt); 286 (unsigned int)virt);
287 return; 287 return;
288 } 288 }
289 289
@@ -298,29 +298,29 @@ static inline int hmm_check_bo(struct hmm_buffer_object *bo, unsigned int ptr)
298{ 298{
299 if (!bo) { 299 if (!bo) {
300 dev_err(atomisp_dev, 300 dev_err(atomisp_dev,
301 "can not find buffer object contains " 301 "can not find buffer object contains address 0x%x\n",
302 "address 0x%x\n", ptr); 302 ptr);
303 return -EINVAL; 303 return -EINVAL;
304 } 304 }
305 305
306 if (!hmm_bo_page_allocated(bo)) { 306 if (!hmm_bo_page_allocated(bo)) {
307 dev_err(atomisp_dev, 307 dev_err(atomisp_dev,
308 "buffer object has no page allocated.\n"); 308 "buffer object has no page allocated.\n");
309 return -EINVAL; 309 return -EINVAL;
310 } 310 }
311 311
312 if (!hmm_bo_allocated(bo)) { 312 if (!hmm_bo_allocated(bo)) {
313 dev_err(atomisp_dev, 313 dev_err(atomisp_dev,
314 "buffer object has no virtual address" 314 "buffer object has no virtual address space allocated.\n");
315 " space allocated.\n");
316 return -EINVAL; 315 return -EINVAL;
317 } 316 }
318 317
319 return 0; 318 return 0;
320} 319}
321 320
322/*Read function in ISP memory management*/ 321/* Read function in ISP memory management */
323static int load_and_flush_by_kmap(ia_css_ptr virt, void *data, unsigned int bytes) 322static int load_and_flush_by_kmap(ia_css_ptr virt, void *data,
323 unsigned int bytes)
324{ 324{
325 struct hmm_buffer_object *bo; 325 struct hmm_buffer_object *bo;
326 unsigned int idx, offset, len; 326 unsigned int idx, offset, len;
@@ -362,7 +362,7 @@ static int load_and_flush_by_kmap(ia_css_ptr virt, void *data, unsigned int byte
362 return 0; 362 return 0;
363} 363}
364 364
365/*Read function in ISP memory management*/ 365/* Read function in ISP memory management */
366static int load_and_flush(ia_css_ptr virt, void *data, unsigned int bytes) 366static int load_and_flush(ia_css_ptr virt, void *data, unsigned int bytes)
367{ 367{
368 struct hmm_buffer_object *bo; 368 struct hmm_buffer_object *bo;
@@ -397,24 +397,24 @@ static int load_and_flush(ia_css_ptr virt, void *data, unsigned int bytes)
397 return 0; 397 return 0;
398} 398}
399 399
400/*Read function in ISP memory management*/ 400/* Read function in ISP memory management */
401int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes) 401int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes)
402{ 402{
403 if (!data) { 403 if (!data) {
404 dev_err(atomisp_dev, 404 dev_err(atomisp_dev,
405 "hmm_load NULL argument\n"); 405 "hmm_load NULL argument\n");
406 return -EINVAL; 406 return -EINVAL;
407 } 407 }
408 return load_and_flush(virt, data, bytes); 408 return load_and_flush(virt, data, bytes);
409} 409}
410 410
411/*Flush hmm data from the data cache*/ 411/* Flush hmm data from the data cache */
412int hmm_flush(ia_css_ptr virt, unsigned int bytes) 412int hmm_flush(ia_css_ptr virt, unsigned int bytes)
413{ 413{
414 return load_and_flush(virt, NULL, bytes); 414 return load_and_flush(virt, NULL, bytes);
415} 415}
416 416
417/*Write function in ISP memory management*/ 417/* Write function in ISP memory management */
418int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes) 418int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes)
419{ 419{
420 struct hmm_buffer_object *bo; 420 struct hmm_buffer_object *bo;
@@ -460,8 +460,8 @@ int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes)
460 460
461 if (!des) { 461 if (!des) {
462 dev_err(atomisp_dev, 462 dev_err(atomisp_dev,
463 "kmap buffer object page failed: " 463 "kmap buffer object page failed: pg_idx = %d\n",
464 "pg_idx = %d\n", idx); 464 idx);
465 return -EINVAL; 465 return -EINVAL;
466 } 466 }
467 467
@@ -496,7 +496,7 @@ int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes)
496 return 0; 496 return 0;
497} 497}
498 498
499/*memset function in ISP memory management*/ 499/* memset function in ISP memory management */
500int hmm_set(ia_css_ptr virt, int c, unsigned int bytes) 500int hmm_set(ia_css_ptr virt, int c, unsigned int bytes)
501{ 501{
502 struct hmm_buffer_object *bo; 502 struct hmm_buffer_object *bo;
@@ -556,7 +556,7 @@ int hmm_set(ia_css_ptr virt, int c, unsigned int bytes)
556 return 0; 556 return 0;
557} 557}
558 558
559/*Virtual address to physical address convert*/ 559/* Virtual address to physical address convert */
560phys_addr_t hmm_virt_to_phys(ia_css_ptr virt) 560phys_addr_t hmm_virt_to_phys(ia_css_ptr virt)
561{ 561{
562 unsigned int idx, offset; 562 unsigned int idx, offset;
@@ -591,7 +591,7 @@ int hmm_mmap(struct vm_area_struct *vma, ia_css_ptr virt)
591 return hmm_bo_mmap(vma, bo); 591 return hmm_bo_mmap(vma, bo);
592} 592}
593 593
594/*Map ISP virtual address into IA virtual address*/ 594/* Map ISP virtual address into IA virtual address */
595void *hmm_vmap(ia_css_ptr virt, bool cached) 595void *hmm_vmap(ia_css_ptr virt, bool cached)
596{ 596{
597 struct hmm_buffer_object *bo; 597 struct hmm_buffer_object *bo;
@@ -600,8 +600,8 @@ void *hmm_vmap(ia_css_ptr virt, bool cached)
600 bo = hmm_bo_device_search_in_range(&bo_device, virt); 600 bo = hmm_bo_device_search_in_range(&bo_device, virt);
601 if (!bo) { 601 if (!bo) {
602 dev_err(atomisp_dev, 602 dev_err(atomisp_dev,
603 "can not find buffer object contains address 0x%x\n", 603 "can not find buffer object contains address 0x%x\n",
604 virt); 604 virt);
605 return NULL; 605 return NULL;
606 } 606 }
607 607
@@ -620,8 +620,8 @@ void hmm_flush_vmap(ia_css_ptr virt)
620 bo = hmm_bo_device_search_in_range(&bo_device, virt); 620 bo = hmm_bo_device_search_in_range(&bo_device, virt);
621 if (!bo) { 621 if (!bo) {
622 dev_warn(atomisp_dev, 622 dev_warn(atomisp_dev,
623 "can not find buffer object contains address 0x%x\n", 623 "can not find buffer object contains address 0x%x\n",
624 virt); 624 virt);
625 return; 625 return;
626 } 626 }
627 627
@@ -635,26 +635,25 @@ void hmm_vunmap(ia_css_ptr virt)
635 bo = hmm_bo_device_search_in_range(&bo_device, virt); 635 bo = hmm_bo_device_search_in_range(&bo_device, virt);
636 if (!bo) { 636 if (!bo) {
637 dev_warn(atomisp_dev, 637 dev_warn(atomisp_dev,
638 "can not find buffer object contains address 0x%x\n", 638 "can not find buffer object contains address 0x%x\n",
639 virt); 639 virt);
640 return; 640 return;
641 } 641 }
642 642
643 return hmm_bo_vunmap(bo); 643 hmm_bo_vunmap(bo);
644} 644}
645 645
646int hmm_pool_register(unsigned int pool_size, 646int hmm_pool_register(unsigned int pool_size, enum hmm_pool_type pool_type)
647 enum hmm_pool_type pool_type)
648{ 647{
649 switch (pool_type) { 648 switch (pool_type) {
650 case HMM_POOL_TYPE_RESERVED: 649 case HMM_POOL_TYPE_RESERVED:
651 reserved_pool.pops = &reserved_pops; 650 reserved_pool.pops = &reserved_pops;
652 return reserved_pool.pops->pool_init(&reserved_pool.pool_info, 651 return reserved_pool.pops->pool_init(&reserved_pool.pool_info,
653 pool_size); 652 pool_size);
654 case HMM_POOL_TYPE_DYNAMIC: 653 case HMM_POOL_TYPE_DYNAMIC:
655 dynamic_pool.pops = &dynamic_pops; 654 dynamic_pool.pops = &dynamic_pops;
656 return dynamic_pool.pops->pool_init(&dynamic_pool.pool_info, 655 return dynamic_pool.pops->pool_init(&dynamic_pool.pool_info,
657 pool_size); 656 pool_size);
658 default: 657 default:
659 dev_err(atomisp_dev, "invalid pool type.\n"); 658 dev_err(atomisp_dev, "invalid pool type.\n");
660 return -EINVAL; 659 return -EINVAL;
@@ -703,10 +702,10 @@ ia_css_ptr hmm_host_vaddr_to_hrt_vaddr(const void *ptr)
703void hmm_show_mem_stat(const char *func, const int line) 702void hmm_show_mem_stat(const char *func, const int line)
704{ 703{
705 trace_printk("tol_cnt=%d usr_size=%d res_size=%d res_cnt=%d sys_size=%d dyc_thr=%d dyc_size=%d.\n", 704 trace_printk("tol_cnt=%d usr_size=%d res_size=%d res_cnt=%d sys_size=%d dyc_thr=%d dyc_size=%d.\n",
706 hmm_mem_stat.tol_cnt, 705 hmm_mem_stat.tol_cnt,
707 hmm_mem_stat.usr_size, hmm_mem_stat.res_size, 706 hmm_mem_stat.usr_size, hmm_mem_stat.res_size,
708 hmm_mem_stat.res_cnt, hmm_mem_stat.sys_size, 707 hmm_mem_stat.res_cnt, hmm_mem_stat.sys_size,
709 hmm_mem_stat.dyc_thr, hmm_mem_stat.dyc_size); 708 hmm_mem_stat.dyc_thr, hmm_mem_stat.dyc_size);
710} 709}
711 710
712void hmm_init_mem_stat(int res_pgnr, int dyc_en, int dyc_pgnr) 711void hmm_init_mem_stat(int res_pgnr, int dyc_en, int dyc_pgnr)
diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c
index 38f72d069e27..58adaea44eb5 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -48,7 +48,6 @@
48/* driver definitions */ 48/* driver definitions */
49#define BCM2048_DRIVER_AUTHOR "Eero Nurkkala <ext-eero.nurkkala@nokia.com>" 49#define BCM2048_DRIVER_AUTHOR "Eero Nurkkala <ext-eero.nurkkala@nokia.com>"
50#define BCM2048_DRIVER_NAME BCM2048_NAME 50#define BCM2048_DRIVER_NAME BCM2048_NAME
51#define BCM2048_DRIVER_VERSION KERNEL_VERSION(0, 0, 1)
52#define BCM2048_DRIVER_CARD "Broadcom bcm2048 FM Radio Receiver" 51#define BCM2048_DRIVER_CARD "Broadcom bcm2048 FM Radio Receiver"
53#define BCM2048_DRIVER_DESC "I2C driver for BCM2048 FM Radio Receiver" 52#define BCM2048_DRIVER_DESC "I2C driver for BCM2048 FM Radio Receiver"
54 53
@@ -2565,7 +2564,7 @@ static const struct v4l2_ioctl_ops bcm2048_ioctl_ops = {
2565/* 2564/*
2566 * bcm2048_viddev_template - video device interface 2565 * bcm2048_viddev_template - video device interface
2567 */ 2566 */
2568static struct video_device bcm2048_viddev_template = { 2567static const struct video_device bcm2048_viddev_template = {
2569 .fops = &bcm2048_fops, 2568 .fops = &bcm2048_fops,
2570 .name = BCM2048_DRIVER_NAME, 2569 .name = BCM2048_DRIVER_NAME,
2571 .release = video_device_release_empty, 2570 .release = video_device_release_empty,
diff --git a/drivers/staging/media/cxd2099/cxd2099.c b/drivers/staging/media/cxd2099/cxd2099.c
index f28916ea69f1..3e30f4864e2b 100644
--- a/drivers/staging/media/cxd2099/cxd2099.c
+++ b/drivers/staging/media/cxd2099/cxd2099.c
@@ -33,8 +33,9 @@
33 33
34#include "cxd2099.h" 34#include "cxd2099.h"
35 35
36/* comment this line to deactivate the cxd2099ar buffer mode */ 36static int buffermode;
37#define BUFFER_MODE 1 37module_param(buffermode, int, 0444);
38MODULE_PARM_DESC(buffermode, "Enable use of the CXD2099AR buffer mode (default: disabled)");
38 39
39static int read_data(struct dvb_ca_en50221 *ca, int slot, u8 *ebuf, int ecount); 40static int read_data(struct dvb_ca_en50221 *ca, int slot, u8 *ebuf, int ecount);
40 41
@@ -221,7 +222,6 @@ static int write_reg(struct cxd *ci, u8 reg, u8 val)
221 return write_regm(ci, reg, val, 0xff); 222 return write_regm(ci, reg, val, 0xff);
222} 223}
223 224
224#ifdef BUFFER_MODE
225static int write_block(struct cxd *ci, u8 adr, u8 *data, u16 n) 225static int write_block(struct cxd *ci, u8 adr, u8 *data, u16 n)
226{ 226{
227 int status = 0; 227 int status = 0;
@@ -248,7 +248,6 @@ static int write_block(struct cxd *ci, u8 adr, u8 *data, u16 n)
248 } 248 }
249 return status; 249 return status;
250} 250}
251#endif
252 251
253static void set_mode(struct cxd *ci, int mode) 252static void set_mode(struct cxd *ci, int mode)
254{ 253{
@@ -642,8 +641,6 @@ static int read_data(struct dvb_ca_en50221 *ca, int slot, u8 *ebuf, int ecount)
642 return len; 641 return len;
643} 642}
644 643
645#ifdef BUFFER_MODE
646
647static int write_data(struct dvb_ca_en50221 *ca, int slot, u8 *ebuf, int ecount) 644static int write_data(struct dvb_ca_en50221 *ca, int slot, u8 *ebuf, int ecount)
648{ 645{
649 struct cxd *ci = ca->data; 646 struct cxd *ci = ca->data;
@@ -658,7 +655,6 @@ static int write_data(struct dvb_ca_en50221 *ca, int slot, u8 *ebuf, int ecount)
658 mutex_unlock(&ci->lock); 655 mutex_unlock(&ci->lock);
659 return ecount; 656 return ecount;
660} 657}
661#endif
662 658
663static struct dvb_ca_en50221 en_templ = { 659static struct dvb_ca_en50221 en_templ = {
664 .read_attribute_mem = read_attribute_mem, 660 .read_attribute_mem = read_attribute_mem,
@@ -669,11 +665,8 @@ static struct dvb_ca_en50221 en_templ = {
669 .slot_shutdown = slot_shutdown, 665 .slot_shutdown = slot_shutdown,
670 .slot_ts_enable = slot_ts_enable, 666 .slot_ts_enable = slot_ts_enable,
671 .poll_slot_status = poll_slot_status, 667 .poll_slot_status = poll_slot_status,
672#ifdef BUFFER_MODE
673 .read_data = read_data, 668 .read_data = read_data,
674 .write_data = write_data, 669 .write_data = write_data,
675#endif
676
677}; 670};
678 671
679struct dvb_ca_en50221 *cxd2099_attach(struct cxd2099_cfg *cfg, 672struct dvb_ca_en50221 *cxd2099_attach(struct cxd2099_cfg *cfg,
@@ -703,6 +696,14 @@ struct dvb_ca_en50221 *cxd2099_attach(struct cxd2099_cfg *cfg,
703 ci->en.data = ci; 696 ci->en.data = ci;
704 init(ci); 697 init(ci);
705 dev_info(&i2c->dev, "Attached CXD2099AR at %02x\n", ci->cfg.adr); 698 dev_info(&i2c->dev, "Attached CXD2099AR at %02x\n", ci->cfg.adr);
699
700 if (!buffermode) {
701 ci->en.read_data = NULL;
702 ci->en.write_data = NULL;
703 } else {
704 dev_info(&i2c->dev, "Using CXD2099AR buffer mode");
705 }
706
706 return &ci->en; 707 return &ci->en;
707} 708}
708EXPORT_SYMBOL(cxd2099_attach); 709EXPORT_SYMBOL(cxd2099_attach);
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 8b2117ee0f60..155e8c758e4b 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -1304,7 +1304,7 @@ static void vpfe_buf_cleanup(struct vb2_buffer *vb)
1304 list_del_init(&buf->list); 1304 list_del_init(&buf->list);
1305} 1305}
1306 1306
1307static struct vb2_ops video_qops = { 1307static const struct vb2_ops video_qops = {
1308 .queue_setup = vpfe_buffer_queue_setup, 1308 .queue_setup = vpfe_buffer_queue_setup,
1309 .buf_init = vpfe_buffer_init, 1309 .buf_init = vpfe_buffer_init,
1310 .buf_prepare = vpfe_buffer_prepare, 1310 .buf_prepare = vpfe_buffer_prepare,
diff --git a/drivers/staging/media/imx/Kconfig b/drivers/staging/media/imx/Kconfig
index 7eff50bcea39..2be921cd0d55 100644
--- a/drivers/staging/media/imx/Kconfig
+++ b/drivers/staging/media/imx/Kconfig
@@ -1,6 +1,8 @@
1config VIDEO_IMX_MEDIA 1config VIDEO_IMX_MEDIA
2 tristate "i.MX5/6 V4L2 media core driver" 2 tristate "i.MX5/6 V4L2 media core driver"
3 depends on MEDIA_CONTROLLER && VIDEO_V4L2 && ARCH_MXC && IMX_IPUV3_CORE 3 depends on MEDIA_CONTROLLER && VIDEO_V4L2 && ARCH_MXC && IMX_IPUV3_CORE
4 depends on VIDEO_V4L2_SUBDEV_API
5 select VIDEOBUF2_DMA_CONTIG
4 select V4L2_FWNODE 6 select V4L2_FWNODE
5 ---help--- 7 ---help---
6 Say yes here to enable support for video4linux media controller 8 Say yes here to enable support for video4linux media controller
@@ -12,7 +14,6 @@ menu "i.MX5/6 Media Sub devices"
12config VIDEO_IMX_CSI 14config VIDEO_IMX_CSI
13 tristate "i.MX5/6 Camera Sensor Interface driver" 15 tristate "i.MX5/6 Camera Sensor Interface driver"
14 depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C 16 depends on VIDEO_IMX_MEDIA && VIDEO_DEV && I2C
15 select VIDEOBUF2_DMA_CONTIG
16 default y 17 default y
17 ---help--- 18 ---help---
18 A video4linux camera sensor interface driver for i.MX5/6. 19 A video4linux camera sensor interface driver for i.MX5/6.
diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c
index ed363fe3b3d0..0790b3d9e255 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -134,19 +134,19 @@ static inline struct prp_priv *sd_to_priv(struct v4l2_subdev *sd)
134 134
135static void prp_put_ipu_resources(struct prp_priv *priv) 135static void prp_put_ipu_resources(struct prp_priv *priv)
136{ 136{
137 if (!IS_ERR_OR_NULL(priv->ic)) 137 if (priv->ic)
138 ipu_ic_put(priv->ic); 138 ipu_ic_put(priv->ic);
139 priv->ic = NULL; 139 priv->ic = NULL;
140 140
141 if (!IS_ERR_OR_NULL(priv->out_ch)) 141 if (priv->out_ch)
142 ipu_idmac_put(priv->out_ch); 142 ipu_idmac_put(priv->out_ch);
143 priv->out_ch = NULL; 143 priv->out_ch = NULL;
144 144
145 if (!IS_ERR_OR_NULL(priv->rot_in_ch)) 145 if (priv->rot_in_ch)
146 ipu_idmac_put(priv->rot_in_ch); 146 ipu_idmac_put(priv->rot_in_ch);
147 priv->rot_in_ch = NULL; 147 priv->rot_in_ch = NULL;
148 148
149 if (!IS_ERR_OR_NULL(priv->rot_out_ch)) 149 if (priv->rot_out_ch)
150 ipu_idmac_put(priv->rot_out_ch); 150 ipu_idmac_put(priv->rot_out_ch);
151 priv->rot_out_ch = NULL; 151 priv->rot_out_ch = NULL;
152} 152}
@@ -154,43 +154,46 @@ static void prp_put_ipu_resources(struct prp_priv *priv)
154static int prp_get_ipu_resources(struct prp_priv *priv) 154static int prp_get_ipu_resources(struct prp_priv *priv)
155{ 155{
156 struct imx_ic_priv *ic_priv = priv->ic_priv; 156 struct imx_ic_priv *ic_priv = priv->ic_priv;
157 struct ipu_ic *ic;
158 struct ipuv3_channel *out_ch, *rot_in_ch, *rot_out_ch;
157 int ret, task = ic_priv->task_id; 159 int ret, task = ic_priv->task_id;
158 160
159 priv->ipu = priv->md->ipu[ic_priv->ipu_id]; 161 priv->ipu = priv->md->ipu[ic_priv->ipu_id];
160 162
161 priv->ic = ipu_ic_get(priv->ipu, task); 163 ic = ipu_ic_get(priv->ipu, task);
162 if (IS_ERR(priv->ic)) { 164 if (IS_ERR(ic)) {
163 v4l2_err(&ic_priv->sd, "failed to get IC\n"); 165 v4l2_err(&ic_priv->sd, "failed to get IC\n");
164 ret = PTR_ERR(priv->ic); 166 ret = PTR_ERR(ic);
165 goto out; 167 goto out;
166 } 168 }
169 priv->ic = ic;
167 170
168 priv->out_ch = ipu_idmac_get(priv->ipu, 171 out_ch = ipu_idmac_get(priv->ipu, prp_channel[task].out_ch);
169 prp_channel[task].out_ch); 172 if (IS_ERR(out_ch)) {
170 if (IS_ERR(priv->out_ch)) {
171 v4l2_err(&ic_priv->sd, "could not get IDMAC channel %u\n", 173 v4l2_err(&ic_priv->sd, "could not get IDMAC channel %u\n",
172 prp_channel[task].out_ch); 174 prp_channel[task].out_ch);
173 ret = PTR_ERR(priv->out_ch); 175 ret = PTR_ERR(out_ch);
174 goto out; 176 goto out;
175 } 177 }
178 priv->out_ch = out_ch;
176 179
177 priv->rot_in_ch = ipu_idmac_get(priv->ipu, 180 rot_in_ch = ipu_idmac_get(priv->ipu, prp_channel[task].rot_in_ch);
178 prp_channel[task].rot_in_ch); 181 if (IS_ERR(rot_in_ch)) {
179 if (IS_ERR(priv->rot_in_ch)) {
180 v4l2_err(&ic_priv->sd, "could not get IDMAC channel %u\n", 182 v4l2_err(&ic_priv->sd, "could not get IDMAC channel %u\n",
181 prp_channel[task].rot_in_ch); 183 prp_channel[task].rot_in_ch);
182 ret = PTR_ERR(priv->rot_in_ch); 184 ret = PTR_ERR(rot_in_ch);
183 goto out; 185 goto out;
184 } 186 }
187 priv->rot_in_ch = rot_in_ch;
185 188
186 priv->rot_out_ch = ipu_idmac_get(priv->ipu, 189 rot_out_ch = ipu_idmac_get(priv->ipu, prp_channel[task].rot_out_ch);
187 prp_channel[task].rot_out_ch); 190 if (IS_ERR(rot_out_ch)) {
188 if (IS_ERR(priv->rot_out_ch)) {
189 v4l2_err(&ic_priv->sd, "could not get IDMAC channel %u\n", 191 v4l2_err(&ic_priv->sd, "could not get IDMAC channel %u\n",
190 prp_channel[task].rot_out_ch); 192 prp_channel[task].rot_out_ch);
191 ret = PTR_ERR(priv->rot_out_ch); 193 ret = PTR_ERR(rot_out_ch);
192 goto out; 194 goto out;
193 } 195 }
196 priv->rot_out_ch = rot_out_ch;
194 197
195 return 0; 198 return 0;
196out: 199out:
@@ -374,6 +377,17 @@ static int prp_setup_channel(struct prp_priv *priv,
374 image.phys0 = addr0; 377 image.phys0 = addr0;
375 image.phys1 = addr1; 378 image.phys1 = addr1;
376 379
380 if (channel == priv->out_ch || channel == priv->rot_out_ch) {
381 switch (image.pix.pixelformat) {
382 case V4L2_PIX_FMT_YUV420:
383 case V4L2_PIX_FMT_YVU420:
384 case V4L2_PIX_FMT_NV12:
385 /* Skip writing U and V components to odd rows */
386 ipu_cpmem_skip_odd_chroma_rows(channel);
387 break;
388 }
389 }
390
377 ret = ipu_cpmem_set_image(channel, &image); 391 ret = ipu_cpmem_set_image(channel, &image);
378 if (ret) 392 if (ret)
379 return ret; 393 return ret;
@@ -1278,9 +1292,8 @@ static int prp_init(struct imx_ic_priv *ic_priv)
1278 priv->ic_priv = ic_priv; 1292 priv->ic_priv = ic_priv;
1279 1293
1280 spin_lock_init(&priv->irqlock); 1294 spin_lock_init(&priv->irqlock);
1281 init_timer(&priv->eof_timeout_timer); 1295 setup_timer(&priv->eof_timeout_timer, prp_eof_timeout,
1282 priv->eof_timeout_timer.data = (unsigned long)priv; 1296 (unsigned long)priv);
1283 priv->eof_timeout_timer.function = prp_eof_timeout;
1284 1297
1285 priv->vdev = imx_media_capture_device_init(&ic_priv->sd, 1298 priv->vdev = imx_media_capture_device_init(&ic_priv->sd,
1286 PRPENCVF_SRC_PAD); 1299 PRPENCVF_SRC_PAD);
diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
index ddab4c249da2..ea145bafb880 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -62,7 +62,7 @@ struct capture_priv {
62/* In bytes, per queue */ 62/* In bytes, per queue */
63#define VID_MEM_LIMIT SZ_64M 63#define VID_MEM_LIMIT SZ_64M
64 64
65static struct vb2_ops capture_qops; 65static const struct vb2_ops capture_qops;
66 66
67/* 67/*
68 * Video ioctls follow 68 * Video ioctls follow
@@ -503,7 +503,7 @@ static void capture_stop_streaming(struct vb2_queue *vq)
503 spin_unlock_irqrestore(&priv->q_lock, flags); 503 spin_unlock_irqrestore(&priv->q_lock, flags);
504} 504}
505 505
506static struct vb2_ops capture_qops = { 506static const struct vb2_ops capture_qops = {
507 .queue_setup = capture_queue_setup, 507 .queue_setup = capture_queue_setup,
508 .buf_init = capture_buf_init, 508 .buf_init = capture_buf_init,
509 .buf_prepare = capture_buf_prepare, 509 .buf_prepare = capture_buf_prepare,
diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
index a2d26693912e..6d856118c223 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -122,11 +122,11 @@ static inline struct csi_priv *sd_to_dev(struct v4l2_subdev *sdev)
122 122
123static void csi_idmac_put_ipu_resources(struct csi_priv *priv) 123static void csi_idmac_put_ipu_resources(struct csi_priv *priv)
124{ 124{
125 if (!IS_ERR_OR_NULL(priv->idmac_ch)) 125 if (priv->idmac_ch)
126 ipu_idmac_put(priv->idmac_ch); 126 ipu_idmac_put(priv->idmac_ch);
127 priv->idmac_ch = NULL; 127 priv->idmac_ch = NULL;
128 128
129 if (!IS_ERR_OR_NULL(priv->smfc)) 129 if (priv->smfc)
130 ipu_smfc_put(priv->smfc); 130 ipu_smfc_put(priv->smfc);
131 priv->smfc = NULL; 131 priv->smfc = NULL;
132} 132}
@@ -134,23 +134,27 @@ static void csi_idmac_put_ipu_resources(struct csi_priv *priv)
134static int csi_idmac_get_ipu_resources(struct csi_priv *priv) 134static int csi_idmac_get_ipu_resources(struct csi_priv *priv)
135{ 135{
136 int ch_num, ret; 136 int ch_num, ret;
137 struct ipu_smfc *smfc;
138 struct ipuv3_channel *idmac_ch;
137 139
138 ch_num = IPUV3_CHANNEL_CSI0 + priv->smfc_id; 140 ch_num = IPUV3_CHANNEL_CSI0 + priv->smfc_id;
139 141
140 priv->smfc = ipu_smfc_get(priv->ipu, ch_num); 142 smfc = ipu_smfc_get(priv->ipu, ch_num);
141 if (IS_ERR(priv->smfc)) { 143 if (IS_ERR(smfc)) {
142 v4l2_err(&priv->sd, "failed to get SMFC\n"); 144 v4l2_err(&priv->sd, "failed to get SMFC\n");
143 ret = PTR_ERR(priv->smfc); 145 ret = PTR_ERR(smfc);
144 goto out; 146 goto out;
145 } 147 }
148 priv->smfc = smfc;
146 149
147 priv->idmac_ch = ipu_idmac_get(priv->ipu, ch_num); 150 idmac_ch = ipu_idmac_get(priv->ipu, ch_num);
148 if (IS_ERR(priv->idmac_ch)) { 151 if (IS_ERR(idmac_ch)) {
149 v4l2_err(&priv->sd, "could not get IDMAC channel %u\n", 152 v4l2_err(&priv->sd, "could not get IDMAC channel %u\n",
150 ch_num); 153 ch_num);
151 ret = PTR_ERR(priv->idmac_ch); 154 ret = PTR_ERR(idmac_ch);
152 goto out; 155 goto out;
153 } 156 }
157 priv->idmac_ch = idmac_ch;
154 158
155 return 0; 159 return 0;
156out: 160out:
@@ -357,6 +361,8 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
357 passthrough = (sensor_ep->bus_type != V4L2_MBUS_CSI2 && 361 passthrough = (sensor_ep->bus_type != V4L2_MBUS_CSI2 &&
358 sensor_ep->bus.parallel.bus_width >= 16); 362 sensor_ep->bus.parallel.bus_width >= 16);
359 passthrough_bits = 16; 363 passthrough_bits = 16;
364 /* Skip writing U and V components to odd rows */
365 ipu_cpmem_skip_odd_chroma_rows(priv->idmac_ch);
360 break; 366 break;
361 case V4L2_PIX_FMT_YUYV: 367 case V4L2_PIX_FMT_YUYV:
362 case V4L2_PIX_FMT_UYVY: 368 case V4L2_PIX_FMT_UYVY:
@@ -1583,6 +1589,7 @@ static int csi_unsubscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
1583static int csi_registered(struct v4l2_subdev *sd) 1589static int csi_registered(struct v4l2_subdev *sd)
1584{ 1590{
1585 struct csi_priv *priv = v4l2_get_subdevdata(sd); 1591 struct csi_priv *priv = v4l2_get_subdevdata(sd);
1592 struct ipu_csi *csi;
1586 int i, ret; 1593 int i, ret;
1587 u32 code; 1594 u32 code;
1588 1595
@@ -1590,11 +1597,12 @@ static int csi_registered(struct v4l2_subdev *sd)
1590 priv->md = dev_get_drvdata(sd->v4l2_dev->dev); 1597 priv->md = dev_get_drvdata(sd->v4l2_dev->dev);
1591 1598
1592 /* get handle to IPU CSI */ 1599 /* get handle to IPU CSI */
1593 priv->csi = ipu_csi_get(priv->ipu, priv->csi_id); 1600 csi = ipu_csi_get(priv->ipu, priv->csi_id);
1594 if (IS_ERR(priv->csi)) { 1601 if (IS_ERR(csi)) {
1595 v4l2_err(&priv->sd, "failed to get CSI%d\n", priv->csi_id); 1602 v4l2_err(&priv->sd, "failed to get CSI%d\n", priv->csi_id);
1596 return PTR_ERR(priv->csi); 1603 return PTR_ERR(csi);
1597 } 1604 }
1605 priv->csi = csi;
1598 1606
1599 for (i = 0; i < CSI_NUM_PADS; i++) { 1607 for (i = 0; i < CSI_NUM_PADS; i++) {
1600 priv->pad[i].flags = (i == CSI_SINK_PAD) ? 1608 priv->pad[i].flags = (i == CSI_SINK_PAD) ?
@@ -1663,7 +1671,7 @@ static void csi_unregistered(struct v4l2_subdev *sd)
1663 if (priv->fim) 1671 if (priv->fim)
1664 imx_media_fim_free(priv->fim); 1672 imx_media_fim_free(priv->fim);
1665 1673
1666 if (!IS_ERR_OR_NULL(priv->csi)) 1674 if (priv->csi)
1667 ipu_csi_put(priv->csi); 1675 ipu_csi_put(priv->csi);
1668} 1676}
1669 1677
@@ -1731,9 +1739,8 @@ static int imx_csi_probe(struct platform_device *pdev)
1731 priv->csi_id = pdata->csi; 1739 priv->csi_id = pdata->csi;
1732 priv->smfc_id = (priv->csi_id == 0) ? 0 : 2; 1740 priv->smfc_id = (priv->csi_id == 0) ? 0 : 2;
1733 1741
1734 init_timer(&priv->eof_timeout_timer); 1742 setup_timer(&priv->eof_timeout_timer, csi_idmac_eof_timeout,
1735 priv->eof_timeout_timer.data = (unsigned long)priv; 1743 (unsigned long)priv);
1736 priv->eof_timeout_timer.function = csi_idmac_eof_timeout;
1737 spin_lock_init(&priv->irqlock); 1744 spin_lock_init(&priv->irqlock);
1738 1745
1739 v4l2_subdev_init(&priv->sd, &csi_subdev_ops); 1746 v4l2_subdev_init(&priv->sd, &csi_subdev_ops);
diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c
index 48cbc7716758..d96f4512224f 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -87,11 +87,11 @@ imx_media_add_async_subdev(struct imx_media_dev *imxmd,
87 if (pdev) 87 if (pdev)
88 devname = dev_name(&pdev->dev); 88 devname = dev_name(&pdev->dev);
89 89
90 /* return NULL if this subdev already added */ 90 /* return -EEXIST if this subdev already added */
91 if (imx_media_find_async_subdev(imxmd, np, devname)) { 91 if (imx_media_find_async_subdev(imxmd, np, devname)) {
92 dev_dbg(imxmd->md.dev, "%s: already added %s\n", 92 dev_dbg(imxmd->md.dev, "%s: already added %s\n",
93 __func__, np ? np->name : devname); 93 __func__, np ? np->name : devname);
94 imxsd = NULL; 94 imxsd = ERR_PTR(-EEXIST);
95 goto out; 95 goto out;
96 } 96 }
97 97
diff --git a/drivers/staging/media/imx/imx-media-of.c b/drivers/staging/media/imx/imx-media-of.c
index b026fe66467c..12df09f52490 100644
--- a/drivers/staging/media/imx/imx-media-of.c
+++ b/drivers/staging/media/imx/imx-media-of.c
@@ -100,9 +100,9 @@ static void of_get_remote_pad(struct device_node *epnode,
100 } 100 }
101} 101}
102 102
103static struct imx_media_subdev * 103static int
104of_parse_subdev(struct imx_media_dev *imxmd, struct device_node *sd_np, 104of_parse_subdev(struct imx_media_dev *imxmd, struct device_node *sd_np,
105 bool is_csi_port) 105 bool is_csi_port, struct imx_media_subdev **subdev)
106{ 106{
107 struct imx_media_subdev *imxsd; 107 struct imx_media_subdev *imxsd;
108 int i, num_pads, ret; 108 int i, num_pads, ret;
@@ -110,13 +110,25 @@ of_parse_subdev(struct imx_media_dev *imxmd, struct device_node *sd_np,
110 if (!of_device_is_available(sd_np)) { 110 if (!of_device_is_available(sd_np)) {
111 dev_dbg(imxmd->md.dev, "%s: %s not enabled\n", __func__, 111 dev_dbg(imxmd->md.dev, "%s: %s not enabled\n", __func__,
112 sd_np->name); 112 sd_np->name);
113 return NULL; 113 *subdev = NULL;
114 /* unavailable is not an error */
115 return 0;
114 } 116 }
115 117
116 /* register this subdev with async notifier */ 118 /* register this subdev with async notifier */
117 imxsd = imx_media_add_async_subdev(imxmd, sd_np, NULL); 119 imxsd = imx_media_add_async_subdev(imxmd, sd_np, NULL);
118 if (IS_ERR_OR_NULL(imxsd)) 120 ret = PTR_ERR_OR_ZERO(imxsd);
119 return imxsd; 121 if (ret) {
122 if (ret == -EEXIST) {
123 /* already added, everything is fine */
124 *subdev = NULL;
125 return 0;
126 }
127
128 /* other error, can't continue */
129 return ret;
130 }
131 *subdev = imxsd;
120 132
121 if (is_csi_port) { 133 if (is_csi_port) {
122 /* 134 /*
@@ -137,10 +149,11 @@ of_parse_subdev(struct imx_media_dev *imxmd, struct device_node *sd_np,
137 } else { 149 } else {
138 num_pads = of_get_port_count(sd_np); 150 num_pads = of_get_port_count(sd_np);
139 if (num_pads != 1) { 151 if (num_pads != 1) {
152 /* confused, but no reason to give up here */
140 dev_warn(imxmd->md.dev, 153 dev_warn(imxmd->md.dev,
141 "%s: unknown device %s with %d ports\n", 154 "%s: unknown device %s with %d ports\n",
142 __func__, sd_np->name, num_pads); 155 __func__, sd_np->name, num_pads);
143 return NULL; 156 return 0;
144 } 157 }
145 158
146 /* 159 /*
@@ -151,7 +164,7 @@ of_parse_subdev(struct imx_media_dev *imxmd, struct device_node *sd_np,
151 } 164 }
152 165
153 if (imxsd->num_sink_pads >= num_pads) 166 if (imxsd->num_sink_pads >= num_pads)
154 return ERR_PTR(-EINVAL); 167 return -EINVAL;
155 168
156 imxsd->num_src_pads = num_pads - imxsd->num_sink_pads; 169 imxsd->num_src_pads = num_pads - imxsd->num_sink_pads;
157 170
@@ -191,20 +204,15 @@ of_parse_subdev(struct imx_media_dev *imxmd, struct device_node *sd_np,
191 204
192 ret = of_add_pad_link(imxmd, pad, sd_np, remote_np, 205 ret = of_add_pad_link(imxmd, pad, sd_np, remote_np,
193 i, remote_pad); 206 i, remote_pad);
194 if (ret) { 207 if (ret)
195 imxsd = ERR_PTR(ret);
196 break; 208 break;
197 }
198 209
199 if (i < imxsd->num_sink_pads) { 210 if (i < imxsd->num_sink_pads) {
200 /* follow sink endpoints upstream */ 211 /* follow sink endpoints upstream */
201 remote_imxsd = of_parse_subdev(imxmd, 212 ret = of_parse_subdev(imxmd, remote_np,
202 remote_np, 213 false, &remote_imxsd);
203 false); 214 if (ret)
204 if (IS_ERR(remote_imxsd)) {
205 imxsd = remote_imxsd;
206 break; 215 break;
207 }
208 } 216 }
209 217
210 of_node_put(remote_np); 218 of_node_put(remote_np);
@@ -212,14 +220,14 @@ of_parse_subdev(struct imx_media_dev *imxmd, struct device_node *sd_np,
212 220
213 if (port != sd_np) 221 if (port != sd_np)
214 of_node_put(port); 222 of_node_put(port);
215 if (IS_ERR(imxsd)) { 223 if (ret) {
216 of_node_put(remote_np); 224 of_node_put(remote_np);
217 of_node_put(epnode); 225 of_node_put(epnode);
218 break; 226 break;
219 } 227 }
220 } 228 }
221 229
222 return imxsd; 230 return ret;
223} 231}
224 232
225int imx_media_of_parse(struct imx_media_dev *imxmd, 233int imx_media_of_parse(struct imx_media_dev *imxmd,
@@ -236,11 +244,9 @@ int imx_media_of_parse(struct imx_media_dev *imxmd,
236 if (!csi_np) 244 if (!csi_np)
237 break; 245 break;
238 246
239 lcsi = of_parse_subdev(imxmd, csi_np, true); 247 ret = of_parse_subdev(imxmd, csi_np, true, &lcsi);
240 if (IS_ERR(lcsi)) { 248 if (ret)
241 ret = PTR_ERR(lcsi);
242 goto err_put; 249 goto err_put;
243 }
244 250
245 ret = of_property_read_u32(csi_np, "reg", &csi_id); 251 ret = of_property_read_u32(csi_np, "reg", &csi_id);
246 if (ret) { 252 if (ret) {
diff --git a/drivers/staging/media/imx/imx-media-vdic.c b/drivers/staging/media/imx/imx-media-vdic.c
index 7eabdc4aa79f..433474d58e3e 100644
--- a/drivers/staging/media/imx/imx-media-vdic.c
+++ b/drivers/staging/media/imx/imx-media-vdic.c
@@ -126,15 +126,15 @@ struct vdic_priv {
126 126
127static void vdic_put_ipu_resources(struct vdic_priv *priv) 127static void vdic_put_ipu_resources(struct vdic_priv *priv)
128{ 128{
129 if (!IS_ERR_OR_NULL(priv->vdi_in_ch_p)) 129 if (priv->vdi_in_ch_p)
130 ipu_idmac_put(priv->vdi_in_ch_p); 130 ipu_idmac_put(priv->vdi_in_ch_p);
131 priv->vdi_in_ch_p = NULL; 131 priv->vdi_in_ch_p = NULL;
132 132
133 if (!IS_ERR_OR_NULL(priv->vdi_in_ch)) 133 if (priv->vdi_in_ch)
134 ipu_idmac_put(priv->vdi_in_ch); 134 ipu_idmac_put(priv->vdi_in_ch);
135 priv->vdi_in_ch = NULL; 135 priv->vdi_in_ch = NULL;
136 136
137 if (!IS_ERR_OR_NULL(priv->vdi_in_ch_n)) 137 if (priv->vdi_in_ch_n)
138 ipu_idmac_put(priv->vdi_in_ch_n); 138 ipu_idmac_put(priv->vdi_in_ch_n);
139 priv->vdi_in_ch_n = NULL; 139 priv->vdi_in_ch_n = NULL;
140 140
@@ -146,40 +146,43 @@ static void vdic_put_ipu_resources(struct vdic_priv *priv)
146static int vdic_get_ipu_resources(struct vdic_priv *priv) 146static int vdic_get_ipu_resources(struct vdic_priv *priv)
147{ 147{
148 int ret, err_chan; 148 int ret, err_chan;
149 struct ipuv3_channel *ch;
150 struct ipu_vdi *vdi;
149 151
150 priv->ipu = priv->md->ipu[priv->ipu_id]; 152 priv->ipu = priv->md->ipu[priv->ipu_id];
151 153
152 priv->vdi = ipu_vdi_get(priv->ipu); 154 vdi = ipu_vdi_get(priv->ipu);
153 if (IS_ERR(priv->vdi)) { 155 if (IS_ERR(vdi)) {
154 v4l2_err(&priv->sd, "failed to get VDIC\n"); 156 v4l2_err(&priv->sd, "failed to get VDIC\n");
155 ret = PTR_ERR(priv->vdi); 157 ret = PTR_ERR(vdi);
156 goto out; 158 goto out;
157 } 159 }
160 priv->vdi = vdi;
158 161
159 if (!priv->csi_direct) { 162 if (!priv->csi_direct) {
160 priv->vdi_in_ch_p = ipu_idmac_get(priv->ipu, 163 ch = ipu_idmac_get(priv->ipu, IPUV3_CHANNEL_MEM_VDI_PREV);
161 IPUV3_CHANNEL_MEM_VDI_PREV); 164 if (IS_ERR(ch)) {
162 if (IS_ERR(priv->vdi_in_ch_p)) {
163 err_chan = IPUV3_CHANNEL_MEM_VDI_PREV; 165 err_chan = IPUV3_CHANNEL_MEM_VDI_PREV;
164 ret = PTR_ERR(priv->vdi_in_ch_p); 166 ret = PTR_ERR(ch);
165 goto out_err_chan; 167 goto out_err_chan;
166 } 168 }
169 priv->vdi_in_ch_p = ch;
167 170
168 priv->vdi_in_ch = ipu_idmac_get(priv->ipu, 171 ch = ipu_idmac_get(priv->ipu, IPUV3_CHANNEL_MEM_VDI_CUR);
169 IPUV3_CHANNEL_MEM_VDI_CUR); 172 if (IS_ERR(ch)) {
170 if (IS_ERR(priv->vdi_in_ch)) {
171 err_chan = IPUV3_CHANNEL_MEM_VDI_CUR; 173 err_chan = IPUV3_CHANNEL_MEM_VDI_CUR;
172 ret = PTR_ERR(priv->vdi_in_ch); 174 ret = PTR_ERR(ch);
173 goto out_err_chan; 175 goto out_err_chan;
174 } 176 }
177 priv->vdi_in_ch = ch;
175 178
176 priv->vdi_in_ch_n = ipu_idmac_get(priv->ipu, 179 ch = ipu_idmac_get(priv->ipu, IPUV3_CHANNEL_MEM_VDI_NEXT);
177 IPUV3_CHANNEL_MEM_VDI_NEXT);
178 if (IS_ERR(priv->vdi_in_ch_n)) { 180 if (IS_ERR(priv->vdi_in_ch_n)) {
179 err_chan = IPUV3_CHANNEL_MEM_VDI_NEXT; 181 err_chan = IPUV3_CHANNEL_MEM_VDI_NEXT;
180 ret = PTR_ERR(priv->vdi_in_ch_n); 182 ret = PTR_ERR(ch);
181 goto out_err_chan; 183 goto out_err_chan;
182 } 184 }
185 priv->vdi_in_ch_n = ch;
183 } 186 }
184 187
185 return 0; 188 return 0;
diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c
index 015e41bd036e..71af13bd0ebd 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -288,7 +288,7 @@ static void release_ir_tx(struct kref *ref)
288 struct IR_tx *tx = container_of(ref, struct IR_tx, ref); 288 struct IR_tx *tx = container_of(ref, struct IR_tx, ref);
289 struct IR *ir = tx->ir; 289 struct IR *ir = tx->ir;
290 290
291 ir->l.features &= ~LIRC_CAN_SEND_PULSE; 291 ir->l.features &= ~LIRC_CAN_SEND_LIRCCODE;
292 /* Don't put_ir_device(tx->ir) here, so our lock doesn't get freed */ 292 /* Don't put_ir_device(tx->ir) here, so our lock doesn't get freed */
293 ir->tx = NULL; 293 ir->tx = NULL;
294 kfree(tx); 294 kfree(tx);
@@ -1249,7 +1249,7 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
1249 break; 1249 break;
1250 case LIRC_GET_REC_MODE: 1250 case LIRC_GET_REC_MODE:
1251 if (!(features & LIRC_CAN_REC_MASK)) 1251 if (!(features & LIRC_CAN_REC_MASK))
1252 return -ENOSYS; 1252 return -ENOTTY;
1253 1253
1254 result = put_user(LIRC_REC2MODE 1254 result = put_user(LIRC_REC2MODE
1255 (features & LIRC_CAN_REC_MASK), 1255 (features & LIRC_CAN_REC_MASK),
@@ -1257,24 +1257,24 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
1257 break; 1257 break;
1258 case LIRC_SET_REC_MODE: 1258 case LIRC_SET_REC_MODE:
1259 if (!(features & LIRC_CAN_REC_MASK)) 1259 if (!(features & LIRC_CAN_REC_MASK))
1260 return -ENOSYS; 1260 return -ENOTTY;
1261 1261
1262 result = get_user(mode, uptr); 1262 result = get_user(mode, uptr);
1263 if (!result && !(LIRC_MODE2REC(mode) & features)) 1263 if (!result && !(LIRC_MODE2REC(mode) & features))
1264 result = -EINVAL; 1264 result = -ENOTTY;
1265 break; 1265 break;
1266 case LIRC_GET_SEND_MODE: 1266 case LIRC_GET_SEND_MODE:
1267 if (!(features & LIRC_CAN_SEND_MASK)) 1267 if (!(features & LIRC_CAN_SEND_MASK))
1268 return -ENOSYS; 1268 return -ENOTTY;
1269 1269
1270 result = put_user(LIRC_MODE_PULSE, uptr); 1270 result = put_user(LIRC_MODE_LIRCCODE, uptr);
1271 break; 1271 break;
1272 case LIRC_SET_SEND_MODE: 1272 case LIRC_SET_SEND_MODE:
1273 if (!(features & LIRC_CAN_SEND_MASK)) 1273 if (!(features & LIRC_CAN_SEND_MASK))
1274 return -ENOSYS; 1274 return -ENOTTY;
1275 1275
1276 result = get_user(mode, uptr); 1276 result = get_user(mode, uptr);
1277 if (!result && mode != LIRC_MODE_PULSE) 1277 if (!result && mode != LIRC_MODE_LIRCCODE)
1278 return -EINVAL; 1278 return -EINVAL;
1279 break; 1279 break;
1280 default: 1280 default:
@@ -1512,7 +1512,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
1512 kref_init(&tx->ref); 1512 kref_init(&tx->ref);
1513 ir->tx = tx; 1513 ir->tx = tx;
1514 1514
1515 ir->l.features |= LIRC_CAN_SEND_PULSE; 1515 ir->l.features |= LIRC_CAN_SEND_LIRCCODE;
1516 mutex_init(&tx->client_lock); 1516 mutex_init(&tx->client_lock);
1517 tx->c = client; 1517 tx->c = client;
1518 tx->need_boot = 1; 1518 tx->need_boot = 1;
diff --git a/drivers/staging/media/omap4iss/iss_video.c b/drivers/staging/media/omap4iss/iss_video.c
index 0bac58241a22..9e2f0421a01e 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -1199,7 +1199,7 @@ static int iss_video_mmap(struct file *file, struct vm_area_struct *vma)
1199 return vb2_mmap(&vfh->queue, vma); 1199 return vb2_mmap(&vfh->queue, vma);
1200} 1200}
1201 1201
1202static struct v4l2_file_operations iss_video_fops = { 1202static const struct v4l2_file_operations iss_video_fops = {
1203 .owner = THIS_MODULE, 1203 .owner = THIS_MODULE,
1204 .unlocked_ioctl = video_ioctl2, 1204 .unlocked_ioctl = video_ioctl2,
1205 .open = iss_video_open, 1205 .open = iss_video_open,
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 2dd4a7af7dd7..d27b326d96f4 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1331,8 +1331,6 @@ COMPATIBLE_IOCTL(DMX_SET_FILTER)
1331COMPATIBLE_IOCTL(DMX_SET_PES_FILTER) 1331COMPATIBLE_IOCTL(DMX_SET_PES_FILTER)
1332COMPATIBLE_IOCTL(DMX_SET_BUFFER_SIZE) 1332COMPATIBLE_IOCTL(DMX_SET_BUFFER_SIZE)
1333COMPATIBLE_IOCTL(DMX_GET_PES_PIDS) 1333COMPATIBLE_IOCTL(DMX_GET_PES_PIDS)
1334COMPATIBLE_IOCTL(DMX_GET_CAPS)
1335COMPATIBLE_IOCTL(DMX_SET_SOURCE)
1336COMPATIBLE_IOCTL(DMX_GET_STC) 1334COMPATIBLE_IOCTL(DMX_GET_STC)
1337COMPATIBLE_IOCTL(FE_GET_INFO) 1335COMPATIBLE_IOCTL(FE_GET_INFO)
1338COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD) 1336COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD)
diff --git a/include/media/cec-notifier.h b/include/media/cec-notifier.h
index a4f7429c4ae5..57ec319a7f44 100644
--- a/include/media/cec-notifier.h
+++ b/include/media/cec-notifier.h
@@ -88,6 +88,14 @@ void cec_notifier_register(struct cec_notifier *n,
88 */ 88 */
89void cec_notifier_unregister(struct cec_notifier *n); 89void cec_notifier_unregister(struct cec_notifier *n);
90 90
91/**
92 * cec_register_cec_notifier - register the notifier with the cec adapter.
93 * @adap: the CEC adapter
94 * @notifier: the CEC notifier
95 */
96void cec_register_cec_notifier(struct cec_adapter *adap,
97 struct cec_notifier *notifier);
98
91#else 99#else
92static inline struct cec_notifier *cec_notifier_get(struct device *dev) 100static inline struct cec_notifier *cec_notifier_get(struct device *dev)
93{ 101{
@@ -118,6 +126,10 @@ static inline void cec_notifier_unregister(struct cec_notifier *n)
118{ 126{
119} 127}
120 128
129static inline void cec_register_cec_notifier(struct cec_adapter *adap,
130 struct cec_notifier *notifier)
131{
132}
121#endif 133#endif
122 134
123/** 135/**
diff --git a/include/media/cec-pin.h b/include/media/cec-pin.h
new file mode 100644
index 000000000000..f09cc9579d53
--- /dev/null
+++ b/include/media/cec-pin.h
@@ -0,0 +1,186 @@
1/*
2 * cec-pin.h - low-level CEC pin control
3 *
4 * Copyright 2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
5 *
6 * This program is free software; you may redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
11 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
13 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
14 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
15 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17 * SOFTWARE.
18 */
19
20#ifndef LINUX_CEC_PIN_H
21#define LINUX_CEC_PIN_H
22
23#include <linux/types.h>
24#include <linux/atomic.h>
25#include <media/cec.h>
26
27enum cec_pin_state {
28 /* CEC is off */
29 CEC_ST_OFF,
30 /* CEC is idle, waiting for Rx or Tx */
31 CEC_ST_IDLE,
32
33 /* Tx states */
34
35 /* Pending Tx, waiting for Signal Free Time to expire */
36 CEC_ST_TX_WAIT,
37 /* Low-drive was detected, wait for bus to go high */
38 CEC_ST_TX_WAIT_FOR_HIGH,
39 /* Drive CEC low for the start bit */
40 CEC_ST_TX_START_BIT_LOW,
41 /* Drive CEC high for the start bit */
42 CEC_ST_TX_START_BIT_HIGH,
43 /* Drive CEC low for the 0 bit */
44 CEC_ST_TX_DATA_BIT_0_LOW,
45 /* Drive CEC high for the 0 bit */
46 CEC_ST_TX_DATA_BIT_0_HIGH,
47 /* Drive CEC low for the 1 bit */
48 CEC_ST_TX_DATA_BIT_1_LOW,
49 /* Drive CEC high for the 1 bit */
50 CEC_ST_TX_DATA_BIT_1_HIGH,
51 /*
52 * Wait for start of sample time to check for Ack bit or first
53 * four initiator bits to check for Arbitration Lost.
54 */
55 CEC_ST_TX_DATA_BIT_1_HIGH_PRE_SAMPLE,
56 /* Wait for end of bit period after sampling */
57 CEC_ST_TX_DATA_BIT_1_HIGH_POST_SAMPLE,
58
59 /* Rx states */
60
61 /* Start bit low detected */
62 CEC_ST_RX_START_BIT_LOW,
63 /* Start bit high detected */
64 CEC_ST_RX_START_BIT_HIGH,
65 /* Wait for bit sample time */
66 CEC_ST_RX_DATA_SAMPLE,
67 /* Wait for earliest end of bit period after sampling */
68 CEC_ST_RX_DATA_POST_SAMPLE,
69 /* Wait for CEC to go high (i.e. end of bit period */
70 CEC_ST_RX_DATA_HIGH,
71 /* Drive CEC low to send 0 Ack bit */
72 CEC_ST_RX_ACK_LOW,
73 /* End of 0 Ack time, wait for earliest end of bit period */
74 CEC_ST_RX_ACK_LOW_POST,
75 /* Wait for CEC to go high (i.e. end of bit period */
76 CEC_ST_RX_ACK_HIGH_POST,
77 /* Wait for earliest end of bit period and end of message */
78 CEC_ST_RX_ACK_FINISH,
79
80 /* Start low drive */
81 CEC_ST_LOW_DRIVE,
82 /* Monitor pin using interrupts */
83 CEC_ST_RX_IRQ,
84
85 /* Total number of pin states */
86 CEC_PIN_STATES
87};
88
89/**
90 * struct cec_pin_ops - low-level CEC pin operations
91 * @read: read the CEC pin. Return true if high, false if low.
92 * @low: drive the CEC pin low.
93 * @high: stop driving the CEC pin. The pull-up will drive the pin
94 * high, unless someone else is driving the pin low.
95 * @enable_irq: optional, enable the interrupt to detect pin voltage changes.
96 * @disable_irq: optional, disable the interrupt.
97 * @free: optional. Free any allocated resources. Called when the
98 * adapter is deleted.
99 * @status: optional, log status information.
100 *
101 * These operations are used by the cec pin framework to manipulate
102 * the CEC pin.
103 */
104struct cec_pin_ops {
105 bool (*read)(struct cec_adapter *adap);
106 void (*low)(struct cec_adapter *adap);
107 void (*high)(struct cec_adapter *adap);
108 bool (*enable_irq)(struct cec_adapter *adap);
109 void (*disable_irq)(struct cec_adapter *adap);
110 void (*free)(struct cec_adapter *adap);
111 void (*status)(struct cec_adapter *adap, struct seq_file *file);
112};
113
114#define CEC_NUM_PIN_EVENTS 128
115
116#define CEC_PIN_IRQ_UNCHANGED 0
117#define CEC_PIN_IRQ_DISABLE 1
118#define CEC_PIN_IRQ_ENABLE 2
119
120struct cec_pin {
121 struct cec_adapter *adap;
122 const struct cec_pin_ops *ops;
123 struct task_struct *kthread;
124 wait_queue_head_t kthread_waitq;
125 struct hrtimer timer;
126 ktime_t ts;
127 unsigned int wait_usecs;
128 u16 la_mask;
129 bool enabled;
130 bool monitor_all;
131 bool rx_eom;
132 bool enable_irq_failed;
133 enum cec_pin_state state;
134 struct cec_msg tx_msg;
135 u32 tx_bit;
136 bool tx_nacked;
137 u32 tx_signal_free_time;
138 struct cec_msg rx_msg;
139 u32 rx_bit;
140
141 struct cec_msg work_rx_msg;
142 u8 work_tx_status;
143 ktime_t work_tx_ts;
144 atomic_t work_irq_change;
145 atomic_t work_pin_events;
146 unsigned int work_pin_events_wr;
147 unsigned int work_pin_events_rd;
148 ktime_t work_pin_ts[CEC_NUM_PIN_EVENTS];
149 bool work_pin_is_high[CEC_NUM_PIN_EVENTS];
150 ktime_t timer_ts;
151 u32 timer_cnt;
152 u32 timer_100ms_overruns;
153 u32 timer_300ms_overruns;
154 u32 timer_max_overrun;
155 u32 timer_sum_overrun;
156};
157
158/**
159 * cec_pin_changed() - update pin state from interrupt
160 *
161 * @adap: pointer to the cec adapter
162 * @value: when true the pin is high, otherwise it is low
163 *
164 * If changes of the CEC voltage are detected via an interrupt, then
165 * cec_pin_changed is called from the interrupt with the new value.
166 */
167void cec_pin_changed(struct cec_adapter *adap, bool value);
168
169/**
170 * cec_pin_allocate_adapter() - allocate a pin-based cec adapter
171 *
172 * @pin_ops: low-level pin operations
173 * @priv: will be stored in adap->priv and can be used by the adapter ops.
174 * Use cec_get_drvdata(adap) to get the priv pointer.
175 * @name: the name of the CEC adapter. Note: this name will be copied.
176 * @caps: capabilities of the CEC adapter. This will be ORed with
177 * CEC_CAP_MONITOR_ALL and CEC_CAP_MONITOR_PIN.
178 *
179 * Allocate a cec adapter using the cec pin framework.
180 *
181 * Return: a pointer to the cec adapter or an error pointer
182 */
183struct cec_adapter *cec_pin_allocate_adapter(const struct cec_pin_ops *pin_ops,
184 void *priv, const char *name, u32 caps);
185
186#endif
diff --git a/include/media/cec.h b/include/media/cec.h
index 56643b27e4b8..df6b3bd31284 100644
--- a/include/media/cec.h
+++ b/include/media/cec.h
@@ -31,6 +31,9 @@
31#include <media/rc-core.h> 31#include <media/rc-core.h>
32#include <media/cec-notifier.h> 32#include <media/cec-notifier.h>
33 33
34#define CEC_CAP_DEFAULTS (CEC_CAP_LOG_ADDRS | CEC_CAP_TRANSMIT | \
35 CEC_CAP_PASSTHROUGH | CEC_CAP_RC)
36
34/** 37/**
35 * struct cec_devnode - cec device node 38 * struct cec_devnode - cec device node
36 * @dev: cec device 39 * @dev: cec device
@@ -61,6 +64,7 @@ struct cec_devnode {
61 64
62struct cec_adapter; 65struct cec_adapter;
63struct cec_data; 66struct cec_data;
67struct cec_pin;
64 68
65struct cec_data { 69struct cec_data {
66 struct list_head list; 70 struct list_head list;
@@ -81,7 +85,13 @@ struct cec_msg_entry {
81 struct cec_msg msg; 85 struct cec_msg msg;
82}; 86};
83 87
84#define CEC_NUM_EVENTS CEC_EVENT_LOST_MSGS 88struct cec_event_entry {
89 struct list_head list;
90 struct cec_event ev;
91};
92
93#define CEC_NUM_CORE_EVENTS 2
94#define CEC_NUM_EVENTS CEC_EVENT_PIN_CEC_HIGH
85 95
86struct cec_fh { 96struct cec_fh {
87 struct list_head list; 97 struct list_head list;
@@ -92,9 +102,11 @@ struct cec_fh {
92 102
93 /* Events */ 103 /* Events */
94 wait_queue_head_t wait; 104 wait_queue_head_t wait;
95 unsigned int pending_events;
96 struct cec_event events[CEC_NUM_EVENTS];
97 struct mutex lock; 105 struct mutex lock;
106 struct list_head events[CEC_NUM_EVENTS]; /* queued events */
107 u8 queued_events[CEC_NUM_EVENTS];
108 unsigned int total_queued_events;
109 struct cec_event_entry core_events[CEC_NUM_CORE_EVENTS];
98 struct list_head msgs; /* queued messages */ 110 struct list_head msgs; /* queued messages */
99 unsigned int queued_msgs; 111 unsigned int queued_msgs;
100}; 112};
@@ -114,6 +126,7 @@ struct cec_adap_ops {
114 int (*adap_transmit)(struct cec_adapter *adap, u8 attempts, 126 int (*adap_transmit)(struct cec_adapter *adap, u8 attempts,
115 u32 signal_free_time, struct cec_msg *msg); 127 u32 signal_free_time, struct cec_msg *msg);
116 void (*adap_status)(struct cec_adapter *adap, struct seq_file *file); 128 void (*adap_status)(struct cec_adapter *adap, struct seq_file *file);
129 void (*adap_free)(struct cec_adapter *adap);
117 130
118 /* High-level CEC message callback */ 131 /* High-level CEC message callback */
119 int (*received)(struct cec_adapter *adap, struct cec_msg *msg); 132 int (*received)(struct cec_adapter *adap, struct cec_msg *msg);
@@ -167,16 +180,28 @@ struct cec_adapter {
167 bool needs_hpd; 180 bool needs_hpd;
168 bool is_configuring; 181 bool is_configuring;
169 bool is_configured; 182 bool is_configured;
183 bool cec_pin_is_high;
170 u32 monitor_all_cnt; 184 u32 monitor_all_cnt;
185 u32 monitor_pin_cnt;
171 u32 follower_cnt; 186 u32 follower_cnt;
172 struct cec_fh *cec_follower; 187 struct cec_fh *cec_follower;
173 struct cec_fh *cec_initiator; 188 struct cec_fh *cec_initiator;
174 bool passthrough; 189 bool passthrough;
175 struct cec_log_addrs log_addrs; 190 struct cec_log_addrs log_addrs;
176 191
192 u32 tx_timeouts;
193
194#ifdef CONFIG_MEDIA_CEC_RC
195 bool rc_repeating;
196 int rc_last_scancode;
197 u64 rc_last_keypress;
198#endif
177#ifdef CONFIG_CEC_NOTIFIER 199#ifdef CONFIG_CEC_NOTIFIER
178 struct cec_notifier *notifier; 200 struct cec_notifier *notifier;
179#endif 201#endif
202#ifdef CONFIG_CEC_PIN
203 struct cec_pin *pin;
204#endif
180 205
181 struct dentry *cec_dir; 206 struct dentry *cec_dir;
182 struct dentry *status_file; 207 struct dentry *status_file;
@@ -184,7 +209,7 @@ struct cec_adapter {
184 u16 phys_addrs[15]; 209 u16 phys_addrs[15];
185 u32 sequence; 210 u32 sequence;
186 211
187 char input_name[32]; 212 char device_name[32];
188 char input_phys[32]; 213 char input_phys[32];
189 char input_drv[32]; 214 char input_drv[32];
190}; 215};
@@ -226,15 +251,50 @@ int cec_transmit_msg(struct cec_adapter *adap, struct cec_msg *msg,
226 bool block); 251 bool block);
227 252
228/* Called by the adapter */ 253/* Called by the adapter */
229void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt, 254void cec_transmit_done_ts(struct cec_adapter *adap, u8 status,
230 u8 nack_cnt, u8 low_drive_cnt, u8 error_cnt); 255 u8 arb_lost_cnt, u8 nack_cnt, u8 low_drive_cnt,
256 u8 error_cnt, ktime_t ts);
257
258static inline void cec_transmit_done(struct cec_adapter *adap, u8 status,
259 u8 arb_lost_cnt, u8 nack_cnt,
260 u8 low_drive_cnt, u8 error_cnt)
261{
262 cec_transmit_done_ts(adap, status, arb_lost_cnt, nack_cnt,
263 low_drive_cnt, error_cnt, ktime_get());
264}
231/* 265/*
232 * Simplified version of cec_transmit_done for hardware that doesn't retry 266 * Simplified version of cec_transmit_done for hardware that doesn't retry
233 * failed transmits. So this is always just one attempt in which case 267 * failed transmits. So this is always just one attempt in which case
234 * the status is sufficient. 268 * the status is sufficient.
235 */ 269 */
236void cec_transmit_attempt_done(struct cec_adapter *adap, u8 status); 270void cec_transmit_attempt_done_ts(struct cec_adapter *adap,
237void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg); 271 u8 status, ktime_t ts);
272
273static inline void cec_transmit_attempt_done(struct cec_adapter *adap,
274 u8 status)
275{
276 cec_transmit_attempt_done_ts(adap, status, ktime_get());
277}
278
279void cec_received_msg_ts(struct cec_adapter *adap,
280 struct cec_msg *msg, ktime_t ts);
281
282static inline void cec_received_msg(struct cec_adapter *adap,
283 struct cec_msg *msg)
284{
285 cec_received_msg_ts(adap, msg, ktime_get());
286}
287
288/**
289 * cec_queue_pin_cec_event() - queue a CEC pin event with a given timestamp.
290 *
291 * @adap: pointer to the cec adapter
292 * @is_high: when true the CEC pin is high, otherwise it is low
293 * @ts: the timestamp for this event
294 *
295 */
296void cec_queue_pin_cec_event(struct cec_adapter *adap,
297 bool is_high, ktime_t ts);
238 298
239/** 299/**
240 * cec_get_edid_phys_addr() - find and return the physical address 300 * cec_get_edid_phys_addr() - find and return the physical address
@@ -311,11 +371,6 @@ u16 cec_phys_addr_for_input(u16 phys_addr, u8 input);
311 */ 371 */
312int cec_phys_addr_validate(u16 phys_addr, u16 *parent, u16 *port); 372int cec_phys_addr_validate(u16 phys_addr, u16 *parent, u16 *port);
313 373
314#ifdef CONFIG_CEC_NOTIFIER
315void cec_register_cec_notifier(struct cec_adapter *adap,
316 struct cec_notifier *notifier);
317#endif
318
319#else 374#else
320 375
321static inline int cec_register_adapter(struct cec_adapter *adap, 376static inline int cec_register_adapter(struct cec_adapter *adap,
diff --git a/include/media/drv-intf/saa7146.h b/include/media/drv-intf/saa7146.h
index 96058a5a4acc..45294328614d 100644
--- a/include/media/drv-intf/saa7146.h
+++ b/include/media/drv-intf/saa7146.h
@@ -96,7 +96,7 @@ struct saa7146_extension
96 supported devices, last entry 0xffff, 0xfff */ 96 supported devices, last entry 0xffff, 0xfff */
97 struct module *module; 97 struct module *module;
98 struct pci_driver driver; 98 struct pci_driver driver;
99 struct pci_device_id *pci_tbl; 99 const struct pci_device_id *pci_tbl;
100 100
101 /* extension functions */ 101 /* extension functions */
102 int (*probe)(struct saa7146_dev *); 102 int (*probe)(struct saa7146_dev *);
diff --git a/include/media/i2c/ir-kbd-i2c.h b/include/media/i2c/ir-kbd-i2c.h
index d8564354debb..ac8c55617a79 100644
--- a/include/media/i2c/ir-kbd-i2c.h
+++ b/include/media/i2c/ir-kbd-i2c.h
@@ -20,7 +20,8 @@ struct IR_i2c {
20 struct delayed_work work; 20 struct delayed_work work;
21 char name[32]; 21 char name[32];
22 char phys[32]; 22 char phys[32];
23 int (*get_key)(struct IR_i2c *ir, enum rc_type *protocol, 23 int (*get_key)(struct IR_i2c *ir,
24 enum rc_proto *protocol,
24 u32 *scancode, u8 *toggle); 25 u32 *scancode, u8 *toggle);
25}; 26};
26 27
@@ -38,14 +39,15 @@ enum ir_kbd_get_key_fn {
38struct IR_i2c_init_data { 39struct IR_i2c_init_data {
39 char *ir_codes; 40 char *ir_codes;
40 const char *name; 41 const char *name;
41 u64 type; /* RC_BIT_RC5, etc */ 42 u64 type; /* RC_PROTO_BIT_RC5, etc */
42 u32 polling_interval; /* 0 means DEFAULT_POLLING_INTERVAL */ 43 u32 polling_interval; /* 0 means DEFAULT_POLLING_INTERVAL */
43 44
44 /* 45 /*
45 * Specify either a function pointer or a value indicating one of 46 * Specify either a function pointer or a value indicating one of
46 * ir_kbd_i2c's internal get_key functions 47 * ir_kbd_i2c's internal get_key functions
47 */ 48 */
48 int (*get_key)(struct IR_i2c *ir, enum rc_type *protocol, 49 int (*get_key)(struct IR_i2c *ir,
50 enum rc_proto *protocol,
49 u32 *scancode, u8 *toggle); 51 u32 *scancode, u8 *toggle);
50 enum ir_kbd_get_key_fn internal_get_key_func; 52 enum ir_kbd_get_key_fn internal_get_key_func;
51 53
diff --git a/include/media/media-device.h b/include/media/media-device.h
index 6896266031b9..bcc6ec434f1f 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -68,7 +68,6 @@ struct media_device_ops {
68 * @serial: Device serial number (optional) 68 * @serial: Device serial number (optional)
69 * @bus_info: Unique and stable device location identifier 69 * @bus_info: Unique and stable device location identifier
70 * @hw_revision: Hardware device revision 70 * @hw_revision: Hardware device revision
71 * @driver_version: Device driver version
72 * @topology_version: Monotonic counter for storing the version of the graph 71 * @topology_version: Monotonic counter for storing the version of the graph
73 * topology. Should be incremented each time the topology changes. 72 * topology. Should be incremented each time the topology changes.
74 * @id: Unique ID used on the last registered graph object 73 * @id: Unique ID used on the last registered graph object
@@ -134,7 +133,6 @@ struct media_device {
134 char serial[40]; 133 char serial[40];
135 char bus_info[32]; 134 char bus_info[32];
136 u32 hw_revision; 135 u32 hw_revision;
137 u32 driver_version;
138 136
139 u64 topology_version; 137 u64 topology_version;
140 138
@@ -249,11 +247,6 @@ void media_device_cleanup(struct media_device *mdev);
249 * driver-specific format. When possible the revision should be formatted 247 * driver-specific format. When possible the revision should be formatted
250 * with the KERNEL_VERSION() macro. 248 * with the KERNEL_VERSION() macro.
251 * 249 *
252 * - &media_entity.driver_version is formatted with the KERNEL_VERSION()
253 * macro. The version minor must be incremented when new features are added
254 * to the userspace API without breaking binary compatibility. The version
255 * major must be incremented when binary compatibility is broken.
256 *
257 * .. note:: 250 * .. note::
258 * 251 *
259 * #) Upon successful registration a character device named media[0-9]+ is created. The device major and minor numbers are dynamic. The model name is exported as a sysfs attribute. 252 * #) Upon successful registration a character device named media[0-9]+ is created. The device major and minor numbers are dynamic. The model name is exported as a sysfs attribute.
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 754182d29668..222d379960b7 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -805,7 +805,7 @@ struct media_link *media_entity_find_link(struct media_pad *source,
805 * Return: returns a pointer to the pad at the remote end of the first found 805 * Return: returns a pointer to the pad at the remote end of the first found
806 * enabled link, or %NULL if no enabled link has been found. 806 * enabled link, or %NULL if no enabled link has been found.
807 */ 807 */
808struct media_pad *media_entity_remote_pad(struct media_pad *pad); 808struct media_pad *media_entity_remote_pad(const struct media_pad *pad);
809 809
810/** 810/**
811 * media_entity_get - Get a reference to the parent module 811 * media_entity_get - Get a reference to the parent module
diff --git a/include/media/rc-core.h b/include/media/rc-core.h
index 78dea39a9b39..314a1edb6189 100644
--- a/include/media/rc-core.h
+++ b/include/media/rc-core.h
@@ -72,7 +72,7 @@ enum rc_filter_type {
72 * @dev: driver model's view of this device 72 * @dev: driver model's view of this device
73 * @managed_alloc: devm_rc_allocate_device was used to create rc_dev 73 * @managed_alloc: devm_rc_allocate_device was used to create rc_dev
74 * @sysfs_groups: sysfs attribute groups 74 * @sysfs_groups: sysfs attribute groups
75 * @input_name: name of the input child device 75 * @device_name: name of the rc child device
76 * @input_phys: physical path to the input child device 76 * @input_phys: physical path to the input child device
77 * @input_id: id of the input child device (struct input_id) 77 * @input_id: id of the input child device (struct input_id)
78 * @driver_name: name of the hardware driver which registered this device 78 * @driver_name: name of the hardware driver which registered this device
@@ -87,11 +87,12 @@ enum rc_filter_type {
87 * @idle: used to keep track of RX state 87 * @idle: used to keep track of RX state
88 * @encode_wakeup: wakeup filtering uses IR encode API, therefore the allowed 88 * @encode_wakeup: wakeup filtering uses IR encode API, therefore the allowed
89 * wakeup protocols is the set of all raw encoders 89 * wakeup protocols is the set of all raw encoders
90 * @allowed_protocols: bitmask with the supported RC_BIT_* protocols 90 * @allowed_protocols: bitmask with the supported RC_PROTO_BIT_* protocols
91 * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols 91 * @enabled_protocols: bitmask with the enabled RC_PROTO_BIT_* protocols
92 * @allowed_wakeup_protocols: bitmask with the supported RC_BIT_* wakeup protocols 92 * @allowed_wakeup_protocols: bitmask with the supported RC_PROTO_BIT_* wakeup
93 * @wakeup_protocol: the enabled RC_TYPE_* wakeup protocol or 93 * protocols
94 * RC_TYPE_UNKNOWN if disabled. 94 * @wakeup_protocol: the enabled RC_PROTO_* wakeup protocol or
95 * RC_PROTO_UNKNOWN if disabled.
95 * @scancode_filter: scancode filter 96 * @scancode_filter: scancode filter
96 * @scancode_wakeup_filter: scancode wakeup filters 97 * @scancode_wakeup_filter: scancode wakeup filters
97 * @scancode_mask: some hardware decoders are not capable of providing the full 98 * @scancode_mask: some hardware decoders are not capable of providing the full
@@ -138,10 +139,10 @@ struct rc_dev {
138 struct device dev; 139 struct device dev;
139 bool managed_alloc; 140 bool managed_alloc;
140 const struct attribute_group *sysfs_groups[5]; 141 const struct attribute_group *sysfs_groups[5];
141 const char *input_name; 142 const char *device_name;
142 const char *input_phys; 143 const char *input_phys;
143 struct input_id input_id; 144 struct input_id input_id;
144 char *driver_name; 145 const char *driver_name;
145 const char *map_name; 146 const char *map_name;
146 struct rc_map rc_map; 147 struct rc_map rc_map;
147 struct mutex lock; 148 struct mutex lock;
@@ -154,7 +155,7 @@ struct rc_dev {
154 u64 allowed_protocols; 155 u64 allowed_protocols;
155 u64 enabled_protocols; 156 u64 enabled_protocols;
156 u64 allowed_wakeup_protocols; 157 u64 allowed_wakeup_protocols;
157 enum rc_type wakeup_protocol; 158 enum rc_proto wakeup_protocol;
158 struct rc_scancode_filter scancode_filter; 159 struct rc_scancode_filter scancode_filter;
159 struct rc_scancode_filter scancode_wakeup_filter; 160 struct rc_scancode_filter scancode_wakeup_filter;
160 u32 scancode_mask; 161 u32 scancode_mask;
@@ -165,7 +166,7 @@ struct rc_dev {
165 unsigned long keyup_jiffies; 166 unsigned long keyup_jiffies;
166 struct timer_list timer_keyup; 167 struct timer_list timer_keyup;
167 u32 last_keycode; 168 u32 last_keycode;
168 enum rc_type last_protocol; 169 enum rc_proto last_protocol;
169 u32 last_scancode; 170 u32 last_scancode;
170 u8 last_toggle; 171 u8 last_toggle;
171 u32 timeout; 172 u32 timeout;
@@ -173,7 +174,7 @@ struct rc_dev {
173 u32 max_timeout; 174 u32 max_timeout;
174 u32 rx_resolution; 175 u32 rx_resolution;
175 u32 tx_resolution; 176 u32 tx_resolution;
176 int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); 177 int (*change_protocol)(struct rc_dev *dev, u64 *rc_proto);
177 int (*open)(struct rc_dev *dev); 178 int (*open)(struct rc_dev *dev);
178 void (*close)(struct rc_dev *dev); 179 void (*close)(struct rc_dev *dev);
179 int (*s_tx_mask)(struct rc_dev *dev, u32 mask); 180 int (*s_tx_mask)(struct rc_dev *dev, u32 mask);
@@ -262,8 +263,10 @@ int rc_open(struct rc_dev *rdev);
262void rc_close(struct rc_dev *rdev); 263void rc_close(struct rc_dev *rdev);
263 264
264void rc_repeat(struct rc_dev *dev); 265void rc_repeat(struct rc_dev *dev);
265void rc_keydown(struct rc_dev *dev, enum rc_type protocol, u32 scancode, u8 toggle); 266void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u32 scancode,
266void rc_keydown_notimeout(struct rc_dev *dev, enum rc_type protocol, u32 scancode, u8 toggle); 267 u8 toggle);
268void rc_keydown_notimeout(struct rc_dev *dev, enum rc_proto protocol,
269 u32 scancode, u8 toggle);
267void rc_keyup(struct rc_dev *dev); 270void rc_keyup(struct rc_dev *dev);
268u32 rc_g_keycode_from_table(struct rc_dev *dev, u32 scancode); 271u32 rc_g_keycode_from_table(struct rc_dev *dev, u32 scancode);
269 272
@@ -272,14 +275,6 @@ u32 rc_g_keycode_from_table(struct rc_dev *dev, u32 scancode);
272 * The Raw interface is specific to InfraRed. It may be a good idea to 275 * The Raw interface is specific to InfraRed. It may be a good idea to
273 * split it later into a separate header. 276 * split it later into a separate header.
274 */ 277 */
275
276enum raw_event_type {
277 IR_SPACE = (1 << 0),
278 IR_PULSE = (1 << 1),
279 IR_START_EVENT = (1 << 2),
280 IR_STOP_EVENT = (1 << 3),
281};
282
283struct ir_raw_event { 278struct ir_raw_event {
284 union { 279 union {
285 u32 duration; 280 u32 duration;
@@ -308,11 +303,11 @@ static inline void init_ir_raw_event(struct ir_raw_event *ev)
308 303
309void ir_raw_event_handle(struct rc_dev *dev); 304void ir_raw_event_handle(struct rc_dev *dev);
310int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev); 305int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev);
311int ir_raw_event_store_edge(struct rc_dev *dev, enum raw_event_type type); 306int ir_raw_event_store_edge(struct rc_dev *dev, bool pulse);
312int ir_raw_event_store_with_filter(struct rc_dev *dev, 307int ir_raw_event_store_with_filter(struct rc_dev *dev,
313 struct ir_raw_event *ev); 308 struct ir_raw_event *ev);
314void ir_raw_event_set_idle(struct rc_dev *dev, bool idle); 309void ir_raw_event_set_idle(struct rc_dev *dev, bool idle);
315int ir_raw_encode_scancode(enum rc_type protocol, u32 scancode, 310int ir_raw_encode_scancode(enum rc_proto protocol, u32 scancode,
316 struct ir_raw_event *events, unsigned int max); 311 struct ir_raw_event *events, unsigned int max);
317 312
318static inline void ir_raw_event_reset(struct rc_dev *dev) 313static inline void ir_raw_event_reset(struct rc_dev *dev)
@@ -340,4 +335,35 @@ static inline u32 ir_extract_bits(u32 data, u32 mask)
340 return value; 335 return value;
341} 336}
342 337
338/* Get NEC scancode and protocol type from address and command bytes */
339static inline u32 ir_nec_bytes_to_scancode(u8 address, u8 not_address,
340 u8 command, u8 not_command,
341 enum rc_proto *protocol)
342{
343 u32 scancode;
344
345 if ((command ^ not_command) != 0xff) {
346 /* NEC transport, but modified protocol, used by at
347 * least Apple and TiVo remotes
348 */
349 scancode = not_address << 24 |
350 address << 16 |
351 not_command << 8 |
352 command;
353 *protocol = RC_PROTO_NEC32;
354 } else if ((address ^ not_address) != 0xff) {
355 /* Extended NEC */
356 scancode = address << 16 |
357 not_address << 8 |
358 command;
359 *protocol = RC_PROTO_NECX;
360 } else {
361 /* Normal NEC */
362 scancode = address << 8 | command;
363 *protocol = RC_PROTO_NEC;
364 }
365
366 return scancode;
367}
368
343#endif /* _RC_CORE */ 369#endif /* _RC_CORE */
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index 1a815a572fa1..2a160e6e823c 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -12,113 +12,122 @@
12#include <linux/input.h> 12#include <linux/input.h>
13 13
14/** 14/**
15 * enum rc_type - type of the Remote Controller protocol 15 * enum rc_proto - the Remote Controller protocol
16 * 16 *
17 * @RC_TYPE_UNKNOWN: Protocol not known 17 * @RC_PROTO_UNKNOWN: Protocol not known
18 * @RC_TYPE_OTHER: Protocol known but proprietary 18 * @RC_PROTO_OTHER: Protocol known but proprietary
19 * @RC_TYPE_RC5: Philips RC5 protocol 19 * @RC_PROTO_RC5: Philips RC5 protocol
20 * @RC_TYPE_RC5X_20: Philips RC5x 20 bit protocol 20 * @RC_PROTO_RC5X_20: Philips RC5x 20 bit protocol
21 * @RC_TYPE_RC5_SZ: StreamZap variant of RC5 21 * @RC_PROTO_RC5_SZ: StreamZap variant of RC5
22 * @RC_TYPE_JVC: JVC protocol 22 * @RC_PROTO_JVC: JVC protocol
23 * @RC_TYPE_SONY12: Sony 12 bit protocol 23 * @RC_PROTO_SONY12: Sony 12 bit protocol
24 * @RC_TYPE_SONY15: Sony 15 bit protocol 24 * @RC_PROTO_SONY15: Sony 15 bit protocol
25 * @RC_TYPE_SONY20: Sony 20 bit protocol 25 * @RC_PROTO_SONY20: Sony 20 bit protocol
26 * @RC_TYPE_NEC: NEC protocol 26 * @RC_PROTO_NEC: NEC protocol
27 * @RC_TYPE_NECX: Extended NEC protocol 27 * @RC_PROTO_NECX: Extended NEC protocol
28 * @RC_TYPE_NEC32: NEC 32 bit protocol 28 * @RC_PROTO_NEC32: NEC 32 bit protocol
29 * @RC_TYPE_SANYO: Sanyo protocol 29 * @RC_PROTO_SANYO: Sanyo protocol
30 * @RC_TYPE_MCIR2_KBD: RC6-ish MCE keyboard 30 * @RC_PROTO_MCIR2_KBD: RC6-ish MCE keyboard
31 * @RC_TYPE_MCIR2_MSE: RC6-ish MCE mouse 31 * @RC_PROTO_MCIR2_MSE: RC6-ish MCE mouse
32 * @RC_TYPE_RC6_0: Philips RC6-0-16 protocol 32 * @RC_PROTO_RC6_0: Philips RC6-0-16 protocol
33 * @RC_TYPE_RC6_6A_20: Philips RC6-6A-20 protocol 33 * @RC_PROTO_RC6_6A_20: Philips RC6-6A-20 protocol
34 * @RC_TYPE_RC6_6A_24: Philips RC6-6A-24 protocol 34 * @RC_PROTO_RC6_6A_24: Philips RC6-6A-24 protocol
35 * @RC_TYPE_RC6_6A_32: Philips RC6-6A-32 protocol 35 * @RC_PROTO_RC6_6A_32: Philips RC6-6A-32 protocol
36 * @RC_TYPE_RC6_MCE: MCE (Philips RC6-6A-32 subtype) protocol 36 * @RC_PROTO_RC6_MCE: MCE (Philips RC6-6A-32 subtype) protocol
37 * @RC_TYPE_SHARP: Sharp protocol 37 * @RC_PROTO_SHARP: Sharp protocol
38 * @RC_TYPE_XMP: XMP protocol 38 * @RC_PROTO_XMP: XMP protocol
39 * @RC_TYPE_CEC: CEC protocol 39 * @RC_PROTO_CEC: CEC protocol
40 */ 40 */
41enum rc_type { 41enum rc_proto {
42 RC_TYPE_UNKNOWN = 0, 42 RC_PROTO_UNKNOWN = 0,
43 RC_TYPE_OTHER = 1, 43 RC_PROTO_OTHER = 1,
44 RC_TYPE_RC5 = 2, 44 RC_PROTO_RC5 = 2,
45 RC_TYPE_RC5X_20 = 3, 45 RC_PROTO_RC5X_20 = 3,
46 RC_TYPE_RC5_SZ = 4, 46 RC_PROTO_RC5_SZ = 4,
47 RC_TYPE_JVC = 5, 47 RC_PROTO_JVC = 5,
48 RC_TYPE_SONY12 = 6, 48 RC_PROTO_SONY12 = 6,
49 RC_TYPE_SONY15 = 7, 49 RC_PROTO_SONY15 = 7,
50 RC_TYPE_SONY20 = 8, 50 RC_PROTO_SONY20 = 8,
51 RC_TYPE_NEC = 9, 51 RC_PROTO_NEC = 9,
52 RC_TYPE_NECX = 10, 52 RC_PROTO_NECX = 10,
53 RC_TYPE_NEC32 = 11, 53 RC_PROTO_NEC32 = 11,
54 RC_TYPE_SANYO = 12, 54 RC_PROTO_SANYO = 12,
55 RC_TYPE_MCIR2_KBD = 13, 55 RC_PROTO_MCIR2_KBD = 13,
56 RC_TYPE_MCIR2_MSE = 14, 56 RC_PROTO_MCIR2_MSE = 14,
57 RC_TYPE_RC6_0 = 15, 57 RC_PROTO_RC6_0 = 15,
58 RC_TYPE_RC6_6A_20 = 16, 58 RC_PROTO_RC6_6A_20 = 16,
59 RC_TYPE_RC6_6A_24 = 17, 59 RC_PROTO_RC6_6A_24 = 17,
60 RC_TYPE_RC6_6A_32 = 18, 60 RC_PROTO_RC6_6A_32 = 18,
61 RC_TYPE_RC6_MCE = 19, 61 RC_PROTO_RC6_MCE = 19,
62 RC_TYPE_SHARP = 20, 62 RC_PROTO_SHARP = 20,
63 RC_TYPE_XMP = 21, 63 RC_PROTO_XMP = 21,
64 RC_TYPE_CEC = 22, 64 RC_PROTO_CEC = 22,
65}; 65};
66 66
67#define RC_BIT_NONE 0ULL 67#define RC_PROTO_BIT_NONE 0ULL
68#define RC_BIT_UNKNOWN BIT_ULL(RC_TYPE_UNKNOWN) 68#define RC_PROTO_BIT_UNKNOWN BIT_ULL(RC_PROTO_UNKNOWN)
69#define RC_BIT_OTHER BIT_ULL(RC_TYPE_OTHER) 69#define RC_PROTO_BIT_OTHER BIT_ULL(RC_PROTO_OTHER)
70#define RC_BIT_RC5 BIT_ULL(RC_TYPE_RC5) 70#define RC_PROTO_BIT_RC5 BIT_ULL(RC_PROTO_RC5)
71#define RC_BIT_RC5X_20 BIT_ULL(RC_TYPE_RC5X_20) 71#define RC_PROTO_BIT_RC5X_20 BIT_ULL(RC_PROTO_RC5X_20)
72#define RC_BIT_RC5_SZ BIT_ULL(RC_TYPE_RC5_SZ) 72#define RC_PROTO_BIT_RC5_SZ BIT_ULL(RC_PROTO_RC5_SZ)
73#define RC_BIT_JVC BIT_ULL(RC_TYPE_JVC) 73#define RC_PROTO_BIT_JVC BIT_ULL(RC_PROTO_JVC)
74#define RC_BIT_SONY12 BIT_ULL(RC_TYPE_SONY12) 74#define RC_PROTO_BIT_SONY12 BIT_ULL(RC_PROTO_SONY12)
75#define RC_BIT_SONY15 BIT_ULL(RC_TYPE_SONY15) 75#define RC_PROTO_BIT_SONY15 BIT_ULL(RC_PROTO_SONY15)
76#define RC_BIT_SONY20 BIT_ULL(RC_TYPE_SONY20) 76#define RC_PROTO_BIT_SONY20 BIT_ULL(RC_PROTO_SONY20)
77#define RC_BIT_NEC BIT_ULL(RC_TYPE_NEC) 77#define RC_PROTO_BIT_NEC BIT_ULL(RC_PROTO_NEC)
78#define RC_BIT_NECX BIT_ULL(RC_TYPE_NECX) 78#define RC_PROTO_BIT_NECX BIT_ULL(RC_PROTO_NECX)
79#define RC_BIT_NEC32 BIT_ULL(RC_TYPE_NEC32) 79#define RC_PROTO_BIT_NEC32 BIT_ULL(RC_PROTO_NEC32)
80#define RC_BIT_SANYO BIT_ULL(RC_TYPE_SANYO) 80#define RC_PROTO_BIT_SANYO BIT_ULL(RC_PROTO_SANYO)
81#define RC_BIT_MCIR2_KBD BIT_ULL(RC_TYPE_MCIR2_KBD) 81#define RC_PROTO_BIT_MCIR2_KBD BIT_ULL(RC_PROTO_MCIR2_KBD)
82#define RC_BIT_MCIR2_MSE BIT_ULL(RC_TYPE_MCIR2_MSE) 82#define RC_PROTO_BIT_MCIR2_MSE BIT_ULL(RC_PROTO_MCIR2_MSE)
83#define RC_BIT_RC6_0 BIT_ULL(RC_TYPE_RC6_0) 83#define RC_PROTO_BIT_RC6_0 BIT_ULL(RC_PROTO_RC6_0)
84#define RC_BIT_RC6_6A_20 BIT_ULL(RC_TYPE_RC6_6A_20) 84#define RC_PROTO_BIT_RC6_6A_20 BIT_ULL(RC_PROTO_RC6_6A_20)
85#define RC_BIT_RC6_6A_24 BIT_ULL(RC_TYPE_RC6_6A_24) 85#define RC_PROTO_BIT_RC6_6A_24 BIT_ULL(RC_PROTO_RC6_6A_24)
86#define RC_BIT_RC6_6A_32 BIT_ULL(RC_TYPE_RC6_6A_32) 86#define RC_PROTO_BIT_RC6_6A_32 BIT_ULL(RC_PROTO_RC6_6A_32)
87#define RC_BIT_RC6_MCE BIT_ULL(RC_TYPE_RC6_MCE) 87#define RC_PROTO_BIT_RC6_MCE BIT_ULL(RC_PROTO_RC6_MCE)
88#define RC_BIT_SHARP BIT_ULL(RC_TYPE_SHARP) 88#define RC_PROTO_BIT_SHARP BIT_ULL(RC_PROTO_SHARP)
89#define RC_BIT_XMP BIT_ULL(RC_TYPE_XMP) 89#define RC_PROTO_BIT_XMP BIT_ULL(RC_PROTO_XMP)
90#define RC_BIT_CEC BIT_ULL(RC_TYPE_CEC) 90#define RC_PROTO_BIT_CEC BIT_ULL(RC_PROTO_CEC)
91 91
92#define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | \ 92#define RC_PROTO_BIT_ALL \
93 RC_BIT_RC5 | RC_BIT_RC5X_20 | RC_BIT_RC5_SZ | \ 93 (RC_PROTO_BIT_UNKNOWN | RC_PROTO_BIT_OTHER | \
94 RC_BIT_JVC | \ 94 RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC5X_20 | \
95 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \ 95 RC_PROTO_BIT_RC5_SZ | RC_PROTO_BIT_JVC | \
96 RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 | \ 96 RC_PROTO_BIT_SONY12 | RC_PROTO_BIT_SONY15 | \
97 RC_BIT_SANYO | \ 97 RC_PROTO_BIT_SONY20 | RC_PROTO_BIT_NEC | \
98 RC_BIT_MCIR2_KBD | RC_BIT_MCIR2_MSE | \ 98 RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32 | \
99 RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \ 99 RC_PROTO_BIT_SANYO | \
100 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP | \ 100 RC_PROTO_BIT_MCIR2_KBD | RC_PROTO_BIT_MCIR2_MSE | \
101 RC_BIT_XMP | RC_BIT_CEC) 101 RC_PROTO_BIT_RC6_0 | RC_PROTO_BIT_RC6_6A_20 | \
102 RC_PROTO_BIT_RC6_6A_24 | RC_PROTO_BIT_RC6_6A_32 | \
103 RC_PROTO_BIT_RC6_MCE | RC_PROTO_BIT_SHARP | \
104 RC_PROTO_BIT_XMP | RC_PROTO_BIT_CEC)
102/* All rc protocols for which we have decoders */ 105/* All rc protocols for which we have decoders */
103#define RC_BIT_ALL_IR_DECODER \ 106#define RC_PROTO_BIT_ALL_IR_DECODER \
104 (RC_BIT_RC5 | RC_BIT_RC5X_20 | RC_BIT_RC5_SZ | \ 107 (RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC5X_20 | \
105 RC_BIT_JVC | \ 108 RC_PROTO_BIT_RC5_SZ | RC_PROTO_BIT_JVC | \
106 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \ 109 RC_PROTO_BIT_SONY12 | RC_PROTO_BIT_SONY15 | \
107 RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 | \ 110 RC_PROTO_BIT_SONY20 | RC_PROTO_BIT_NEC | \
108 RC_BIT_SANYO | RC_BIT_MCIR2_KBD | RC_BIT_MCIR2_MSE | \ 111 RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32 | \
109 RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \ 112 RC_PROTO_BIT_SANYO | RC_PROTO_BIT_MCIR2_KBD | \
110 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP | \ 113 RC_PROTO_BIT_MCIR2_MSE | \
111 RC_BIT_XMP) 114 RC_PROTO_BIT_RC6_0 | RC_PROTO_BIT_RC6_6A_20 | \
115 RC_PROTO_BIT_RC6_6A_24 | RC_PROTO_BIT_RC6_6A_32 | \
116 RC_PROTO_BIT_RC6_MCE | RC_PROTO_BIT_SHARP | \
117 RC_PROTO_BIT_XMP)
112 118
113#define RC_BIT_ALL_IR_ENCODER \ 119#define RC_PROTO_BIT_ALL_IR_ENCODER \
114 (RC_BIT_RC5 | RC_BIT_RC5X_20 | RC_BIT_RC5_SZ | \ 120 (RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC5X_20 | \
115 RC_BIT_JVC | \ 121 RC_PROTO_BIT_RC5_SZ | RC_PROTO_BIT_JVC | \
116 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \ 122 RC_PROTO_BIT_SONY12 | RC_PROTO_BIT_SONY15 | \
117 RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 | \ 123 RC_PROTO_BIT_SONY20 | RC_PROTO_BIT_NEC | \
118 RC_BIT_SANYO | RC_BIT_MCIR2_KBD | RC_BIT_MCIR2_MSE | \ 124 RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32 | \
119 RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \ 125 RC_PROTO_BIT_SANYO | RC_PROTO_BIT_MCIR2_KBD | \
120 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | \ 126 RC_PROTO_BIT_MCIR2_MSE | \
121 RC_BIT_SHARP) 127 RC_PROTO_BIT_RC6_0 | RC_PROTO_BIT_RC6_6A_20 | \
128 RC_PROTO_BIT_RC6_6A_24 | \
129 RC_PROTO_BIT_RC6_6A_32 | RC_PROTO_BIT_RC6_MCE | \
130 RC_PROTO_BIT_SHARP)
122 131
123#define RC_SCANCODE_UNKNOWN(x) (x) 132#define RC_SCANCODE_UNKNOWN(x) (x)
124#define RC_SCANCODE_OTHER(x) (x) 133#define RC_SCANCODE_OTHER(x) (x)
@@ -148,8 +157,8 @@ struct rc_map_table {
148 * @size: Max number of entries 157 * @size: Max number of entries
149 * @len: Number of entries that are in use 158 * @len: Number of entries that are in use
150 * @alloc: size of \*scan, in bytes 159 * @alloc: size of \*scan, in bytes
151 * @rc_type: type of the remote controller protocol, as defined at 160 * @rc_proto: type of the remote controller protocol, as defined at
152 * enum &rc_type 161 * enum &rc_proto
153 * @name: name of the key map table 162 * @name: name of the key map table
154 * @lock: lock to protect access to this structure 163 * @lock: lock to protect access to this structure
155 */ 164 */
@@ -158,7 +167,7 @@ struct rc_map {
158 unsigned int size; 167 unsigned int size;
159 unsigned int len; 168 unsigned int len;
160 unsigned int alloc; 169 unsigned int alloc;
161 enum rc_type rc_type; 170 enum rc_proto rc_proto;
162 const char *name; 171 const char *name;
163 spinlock_t lock; 172 spinlock_t lock;
164}; 173};
@@ -313,6 +322,7 @@ struct rc_map *rc_map_get(const char *name);
313#define RC_MAP_WINFAST "rc-winfast" 322#define RC_MAP_WINFAST "rc-winfast"
314#define RC_MAP_WINFAST_USBII_DELUXE "rc-winfast-usbii-deluxe" 323#define RC_MAP_WINFAST_USBII_DELUXE "rc-winfast-usbii-deluxe"
315#define RC_MAP_SU3000 "rc-su3000" 324#define RC_MAP_SU3000 "rc-su3000"
325#define RC_MAP_ZX_IRDEC "rc-zx-irdec"
316 326
317/* 327/*
318 * Please, do not just append newer Remote Controller names at the end. 328 * Please, do not just append newer Remote Controller names at the end.
diff --git a/include/media/v4l2-clk.h b/include/media/v4l2-clk.h
index 2b94662d005c..7ec857f805a6 100644
--- a/include/media/v4l2-clk.h
+++ b/include/media/v4l2-clk.h
@@ -70,7 +70,7 @@ static inline struct v4l2_clk *v4l2_clk_register_fixed(const char *dev_id,
70#define v4l2_clk_name_i2c(name, size, adap, client) snprintf(name, size, \ 70#define v4l2_clk_name_i2c(name, size, adap, client) snprintf(name, size, \
71 "%d-%04x", adap, client) 71 "%d-%04x", adap, client)
72 72
73#define v4l2_clk_name_of(name, size, of_full_name) snprintf(name, size, \ 73#define v4l2_clk_name_of(name, size, node) snprintf(name, size, \
74 "of-%s", of_full_name) 74 "of-%pOF", node)
75 75
76#endif 76#endif
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 2d2aed56922f..dacfe54057f8 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -340,17 +340,17 @@ struct v4l2_ctrl_config {
340 * v4l2_ctrl_fill - Fill in the control fields based on the control ID. 340 * v4l2_ctrl_fill - Fill in the control fields based on the control ID.
341 * 341 *
342 * @id: ID of the control 342 * @id: ID of the control
343 * @name: name of the control 343 * @name: pointer to be filled with a string with the name of the control
344 * @type: type of the control 344 * @type: pointer for storing the type of the control
345 * @min: minimum value for the control 345 * @min: pointer for storing the minimum value for the control
346 * @max: maximum value for the control 346 * @max: pointer for storing the maximum value for the control
347 * @step: control step 347 * @step: pointer for storing the control step
348 * @def: default value for the control 348 * @def: pointer for storing the default value for the control
349 * @flags: flags to be used on the control 349 * @flags: pointer for storing the flags to be used on the control
350 * 350 *
351 * This works for all standard V4L2 controls. 351 * This works for all standard V4L2 controls.
352 * For non-standard controls it will only fill in the given arguments 352 * For non-standard controls it will only fill in the given arguments
353 * and @name will be %NULL. 353 * and @name content will be set to %NULL.
354 * 354 *
355 * This function will overwrite the contents of @name, @type and @flags. 355 * This function will overwrite the contents of @name, @type and @flags.
356 * The contents of @min, @max, @step and @def may be modified depending on 356 * The contents of @min, @max, @step and @def may be modified depending on
diff --git a/include/media/v4l2-flash-led-class.h b/include/media/v4l2-flash-led-class.h
index f9dcd54c1745..5c1d50f78e12 100644
--- a/include/media/v4l2-flash-led-class.h
+++ b/include/media/v4l2-flash-led-class.h
@@ -56,8 +56,7 @@ struct v4l2_flash_ops {
56 * struct v4l2_flash_config - V4L2 Flash sub-device initialization data 56 * struct v4l2_flash_config - V4L2 Flash sub-device initialization data
57 * @dev_name: the name of the media entity, 57 * @dev_name: the name of the media entity,
58 * unique in the system 58 * unique in the system
59 * @torch_intensity: constraints for the LED in torch mode 59 * @intensity: non-flash strobe constraints for the LED
60 * @indicator_intensity: constraints for the indicator LED
61 * @flash_faults: bitmask of flash faults that the LED flash class 60 * @flash_faults: bitmask of flash faults that the LED flash class
62 * device can report; corresponding LED_FAULT* bit 61 * device can report; corresponding LED_FAULT* bit
63 * definitions are available in the header file 62 * definitions are available in the header file
@@ -66,8 +65,7 @@ struct v4l2_flash_ops {
66 */ 65 */
67struct v4l2_flash_config { 66struct v4l2_flash_config {
68 char dev_name[32]; 67 char dev_name[32];
69 struct led_flash_setting torch_intensity; 68 struct led_flash_setting intensity;
70 struct led_flash_setting indicator_intensity;
71 u32 flash_faults; 69 u32 flash_faults;
72 unsigned int has_external_strobe:1; 70 unsigned int has_external_strobe:1;
73}; 71};
@@ -85,7 +83,7 @@ struct v4l2_flash_config {
85 */ 83 */
86struct v4l2_flash { 84struct v4l2_flash {
87 struct led_classdev_flash *fled_cdev; 85 struct led_classdev_flash *fled_cdev;
88 struct led_classdev_flash *iled_cdev; 86 struct led_classdev *iled_cdev;
89 const struct v4l2_flash_ops *ops; 87 const struct v4l2_flash_ops *ops;
90 88
91 struct v4l2_subdev sd; 89 struct v4l2_subdev sd;
@@ -110,12 +108,13 @@ static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c)
110 * @dev: flash device, e.g. an I2C device 108 * @dev: flash device, e.g. an I2C device
111 * @fwn: fwnode_handle of the LED, may be NULL if the same as device's 109 * @fwn: fwnode_handle of the LED, may be NULL if the same as device's
112 * @fled_cdev: LED flash class device to wrap 110 * @fled_cdev: LED flash class device to wrap
113 * @iled_cdev: LED flash class device representing indicator LED associated
114 * with fled_cdev, may be NULL
115 * @ops: V4L2 Flash device ops 111 * @ops: V4L2 Flash device ops
116 * @config: initialization data for V4L2 Flash sub-device 112 * @config: initialization data for V4L2 Flash sub-device
117 * 113 *
118 * Create V4L2 Flash sub-device wrapping given LED subsystem device. 114 * Create V4L2 Flash sub-device wrapping given LED subsystem device.
115 * The ops pointer is stored by the V4L2 flash framework. No
116 * references are held to config nor its contents once this function
117 * has returned.
119 * 118 *
120 * Returns: A valid pointer, or, when an error occurs, the return 119 * Returns: A valid pointer, or, when an error occurs, the return
121 * value is encoded using ERR_PTR(). Use IS_ERR() to check and 120 * value is encoded using ERR_PTR(). Use IS_ERR() to check and
@@ -124,9 +123,27 @@ static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c)
124struct v4l2_flash *v4l2_flash_init( 123struct v4l2_flash *v4l2_flash_init(
125 struct device *dev, struct fwnode_handle *fwn, 124 struct device *dev, struct fwnode_handle *fwn,
126 struct led_classdev_flash *fled_cdev, 125 struct led_classdev_flash *fled_cdev,
127 struct led_classdev_flash *iled_cdev, 126 const struct v4l2_flash_ops *ops, struct v4l2_flash_config *config);
128 const struct v4l2_flash_ops *ops, 127
129 struct v4l2_flash_config *config); 128/**
129 * v4l2_flash_indicator_init - initialize V4L2 indicator sub-device
130 * @dev: flash device, e.g. an I2C device
131 * @fwn: fwnode_handle of the LED, may be NULL if the same as device's
132 * @iled_cdev: LED flash class device representing the indicator LED
133 * @config: initialization data for V4L2 Flash sub-device
134 *
135 * Create V4L2 Flash sub-device wrapping given LED subsystem device.
136 * The ops pointer is stored by the V4L2 flash framework. No
137 * references are held to config nor its contents once this function
138 * has returned.
139 *
140 * Returns: A valid pointer, or, when an error occurs, the return
141 * value is encoded using ERR_PTR(). Use IS_ERR() to check and
142 * PTR_ERR() to obtain the numeric return value.
143 */
144struct v4l2_flash *v4l2_flash_indicator_init(
145 struct device *dev, struct fwnode_handle *fwn,
146 struct led_classdev *iled_cdev, struct v4l2_flash_config *config);
130 147
131/** 148/**
132 * v4l2_flash_release - release V4L2 Flash sub-device 149 * v4l2_flash_release - release V4L2 Flash sub-device
@@ -140,9 +157,14 @@ void v4l2_flash_release(struct v4l2_flash *v4l2_flash);
140static inline struct v4l2_flash *v4l2_flash_init( 157static inline struct v4l2_flash *v4l2_flash_init(
141 struct device *dev, struct fwnode_handle *fwn, 158 struct device *dev, struct fwnode_handle *fwn,
142 struct led_classdev_flash *fled_cdev, 159 struct led_classdev_flash *fled_cdev,
143 struct led_classdev_flash *iled_cdev, 160 const struct v4l2_flash_ops *ops, struct v4l2_flash_config *config)
144 const struct v4l2_flash_ops *ops, 161{
145 struct v4l2_flash_config *config) 162 return NULL;
163}
164
165static inline struct v4l2_flash *v4l2_flash_indicator_init(
166 struct device *dev, struct fwnode_handle *fwn,
167 struct led_classdev *iled_cdev, struct v4l2_flash_config *config)
146{ 168{
147 return NULL; 169 return NULL;
148} 170}
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
index ecc1233a873e..7adec9851d9e 100644
--- a/include/media/v4l2-fwnode.h
+++ b/include/media/v4l2-fwnode.h
@@ -26,6 +26,8 @@
26 26
27struct fwnode_handle; 27struct fwnode_handle;
28 28
29#define V4L2_FWNODE_CSI2_MAX_DATA_LANES 4
30
29/** 31/**
30 * struct v4l2_fwnode_bus_mipi_csi2 - MIPI CSI-2 bus data structure 32 * struct v4l2_fwnode_bus_mipi_csi2 - MIPI CSI-2 bus data structure
31 * @flags: media bus (V4L2_MBUS_*) flags 33 * @flags: media bus (V4L2_MBUS_*) flags
@@ -37,10 +39,10 @@ struct fwnode_handle;
37 */ 39 */
38struct v4l2_fwnode_bus_mipi_csi2 { 40struct v4l2_fwnode_bus_mipi_csi2 {
39 unsigned int flags; 41 unsigned int flags;
40 unsigned char data_lanes[4]; 42 unsigned char data_lanes[V4L2_FWNODE_CSI2_MAX_DATA_LANES];
41 unsigned char clock_lane; 43 unsigned char clock_lane;
42 unsigned short num_data_lanes; 44 unsigned short num_data_lanes;
43 bool lane_polarities[5]; 45 bool lane_polarities[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES];
44}; 46};
45 47
46/** 48/**
@@ -56,6 +58,24 @@ struct v4l2_fwnode_bus_parallel {
56}; 58};
57 59
58/** 60/**
61 * struct v4l2_fwnode_bus_mipi_csi1 - CSI-1/CCP2 data bus structure
62 * @clock_inv: polarity of clock/strobe signal
63 * false - not inverted, true - inverted
64 * @strobe: false - data/clock, true - data/strobe
65 * @lane_polarity: the polarities of the clock (index 0) and data lanes
66 * index (1)
67 * @data_lane: the number of the data lane
68 * @clock_lane: the number of the clock lane
69 */
70struct v4l2_fwnode_bus_mipi_csi1 {
71 bool clock_inv;
72 bool strobe;
73 bool lane_polarity[2];
74 unsigned char data_lane;
75 unsigned char clock_lane;
76};
77
78/**
59 * struct v4l2_fwnode_endpoint - the endpoint data structure 79 * struct v4l2_fwnode_endpoint - the endpoint data structure
60 * @base: fwnode endpoint of the v4l2_fwnode 80 * @base: fwnode endpoint of the v4l2_fwnode
61 * @bus_type: bus type 81 * @bus_type: bus type
@@ -72,6 +92,7 @@ struct v4l2_fwnode_endpoint {
72 enum v4l2_mbus_type bus_type; 92 enum v4l2_mbus_type bus_type;
73 union { 93 union {
74 struct v4l2_fwnode_bus_parallel parallel; 94 struct v4l2_fwnode_bus_parallel parallel;
95 struct v4l2_fwnode_bus_mipi_csi1 mipi_csi1;
75 struct v4l2_fwnode_bus_mipi_csi2 mipi_csi2; 96 struct v4l2_fwnode_bus_mipi_csi2 mipi_csi2;
76 } bus; 97 } bus;
77 u64 *link_frequencies; 98 u64 *link_frequencies;
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
index 34cc99e093ef..93f8afcb7a22 100644
--- a/include/media/v4l2-mediabus.h
+++ b/include/media/v4l2-mediabus.h
@@ -69,11 +69,15 @@
69 * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync 69 * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync
70 * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can 70 * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can
71 * also be used for BT.1120 71 * also be used for BT.1120
72 * @V4L2_MBUS_CSI1: MIPI CSI-1 serial interface
73 * @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2)
72 * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface 74 * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface
73 */ 75 */
74enum v4l2_mbus_type { 76enum v4l2_mbus_type {
75 V4L2_MBUS_PARALLEL, 77 V4L2_MBUS_PARALLEL,
76 V4L2_MBUS_BT656, 78 V4L2_MBUS_BT656,
79 V4L2_MBUS_CSI1,
80 V4L2_MBUS_CCP2,
77 V4L2_MBUS_CSI2, 81 V4L2_MBUS_CSI2,
78}; 82};
79 83
@@ -113,4 +117,30 @@ static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt,
113 mbus_fmt->code = code; 117 mbus_fmt->code = code;
114} 118}
115 119
120static inline void v4l2_fill_pix_format_mplane(
121 struct v4l2_pix_format_mplane *pix_mp_fmt,
122 const struct v4l2_mbus_framefmt *mbus_fmt)
123{
124 pix_mp_fmt->width = mbus_fmt->width;
125 pix_mp_fmt->height = mbus_fmt->height;
126 pix_mp_fmt->field = mbus_fmt->field;
127 pix_mp_fmt->colorspace = mbus_fmt->colorspace;
128 pix_mp_fmt->ycbcr_enc = mbus_fmt->ycbcr_enc;
129 pix_mp_fmt->quantization = mbus_fmt->quantization;
130 pix_mp_fmt->xfer_func = mbus_fmt->xfer_func;
131}
132
133static inline void v4l2_fill_mbus_format_mplane(
134 struct v4l2_mbus_framefmt *mbus_fmt,
135 const struct v4l2_pix_format_mplane *pix_mp_fmt)
136{
137 mbus_fmt->width = pix_mp_fmt->width;
138 mbus_fmt->height = pix_mp_fmt->height;
139 mbus_fmt->field = pix_mp_fmt->field;
140 mbus_fmt->colorspace = pix_mp_fmt->colorspace;
141 mbus_fmt->ycbcr_enc = pix_mp_fmt->ycbcr_enc;
142 mbus_fmt->quantization = pix_mp_fmt->quantization;
143 mbus_fmt->xfer_func = pix_mp_fmt->xfer_func;
144}
145
116#endif 146#endif
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 0f92ebd2d710..e83872078376 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -982,8 +982,16 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
982 * Example: err = v4l2_subdev_call(sd, video, s_std, norm); 982 * Example: err = v4l2_subdev_call(sd, video, s_std, norm);
983 */ 983 */
984#define v4l2_subdev_call(sd, o, f, args...) \ 984#define v4l2_subdev_call(sd, o, f, args...) \
985 (!(sd) ? -ENODEV : (((sd)->ops->o && (sd)->ops->o->f) ? \ 985 ({ \
986 (sd)->ops->o->f((sd), ##args) : -ENOIOCTLCMD)) 986 int __result; \
987 if (!(sd)) \
988 __result = -ENODEV; \
989 else if (!((sd)->ops->o && (sd)->ops->o->f)) \
990 __result = -ENOIOCTLCMD; \
991 else \
992 __result = (sd)->ops->o->f((sd), ##args); \
993 __result; \
994 })
987 995
988#define v4l2_subdev_has_op(sd, o, f) \ 996#define v4l2_subdev_has_op(sd, o, f) \
989 ((sd)->ops->o && (sd)->ops->o->f) 997 ((sd)->ops->o && (sd)->ops->o->f)
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index cb97c224be73..ef9b64398c8c 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -427,6 +427,16 @@ struct vb2_buf_ops {
427 * @dev: device to use for the default allocation context if the driver 427 * @dev: device to use for the default allocation context if the driver
428 * doesn't fill in the @alloc_devs array. 428 * doesn't fill in the @alloc_devs array.
429 * @dma_attrs: DMA attributes to use for the DMA. 429 * @dma_attrs: DMA attributes to use for the DMA.
430 * @bidirectional: when this flag is set the DMA direction for the buffers of
431 * this queue will be overridden with DMA_BIDIRECTIONAL direction.
432 * This is useful in cases where the hardware (firmware) writes to
433 * a buffer which is mapped as read (DMA_TO_DEVICE), or reads from
434 * buffer which is mapped for write (DMA_FROM_DEVICE) in order
435 * to satisfy some internal hardware restrictions or adds a padding
436 * needed by the processing algorithm. In case the DMA mapping is
437 * not bidirectional but the hardware (firmware) trying to access
438 * the buffer (in the opposite direction) this could lead to an
439 * IOMMU protection faults.
430 * @fileio_read_once: report EOF after reading the first buffer 440 * @fileio_read_once: report EOF after reading the first buffer
431 * @fileio_write_immediately: queue buffer after each write() call 441 * @fileio_write_immediately: queue buffer after each write() call
432 * @allow_zero_bytesused: allow bytesused == 0 to be passed to the driver 442 * @allow_zero_bytesused: allow bytesused == 0 to be passed to the driver
@@ -465,6 +475,7 @@ struct vb2_buf_ops {
465 * Private elements (won't appear at the uAPI book): 475 * Private elements (won't appear at the uAPI book):
466 * @mmap_lock: private mutex used when buffers are allocated/freed/mmapped 476 * @mmap_lock: private mutex used when buffers are allocated/freed/mmapped
467 * @memory: current memory type used 477 * @memory: current memory type used
478 * @dma_dir: DMA mapping direction.
468 * @bufs: videobuf buffer structures 479 * @bufs: videobuf buffer structures
469 * @num_buffers: number of allocated/used buffers 480 * @num_buffers: number of allocated/used buffers
470 * @queued_list: list of buffers currently queued from userspace 481 * @queued_list: list of buffers currently queued from userspace
@@ -495,6 +506,7 @@ struct vb2_queue {
495 unsigned int io_modes; 506 unsigned int io_modes;
496 struct device *dev; 507 struct device *dev;
497 unsigned long dma_attrs; 508 unsigned long dma_attrs;
509 unsigned bidirectional:1;
498 unsigned fileio_read_once:1; 510 unsigned fileio_read_once:1;
499 unsigned fileio_write_immediately:1; 511 unsigned fileio_write_immediately:1;
500 unsigned allow_zero_bytesused:1; 512 unsigned allow_zero_bytesused:1;
@@ -516,6 +528,7 @@ struct vb2_queue {
516 /* private: internal use only */ 528 /* private: internal use only */
517 struct mutex mmap_lock; 529 struct mutex mmap_lock;
518 unsigned int memory; 530 unsigned int memory;
531 enum dma_data_direction dma_dir;
519 struct vb2_buffer *bufs[VB2_MAX_FRAME]; 532 struct vb2_buffer *bufs[VB2_MAX_FRAME];
520 unsigned int num_buffers; 533 unsigned int num_buffers;
521 534
diff --git a/include/uapi/linux/cec-funcs.h b/include/uapi/linux/cec-funcs.h
index c451eec42a83..270b251a3d9b 100644
--- a/include/uapi/linux/cec-funcs.h
+++ b/include/uapi/linux/cec-funcs.h
@@ -895,6 +895,7 @@ static inline void cec_ops_report_features(const struct cec_msg *msg,
895 *cec_version = msg->msg[2]; 895 *cec_version = msg->msg[2];
896 *all_device_types = msg->msg[3]; 896 *all_device_types = msg->msg[3];
897 *rc_profile = p; 897 *rc_profile = p;
898 *dev_features = NULL;
898 while (p < &msg->msg[14] && (*p & CEC_OP_FEAT_EXT)) 899 while (p < &msg->msg[14] && (*p & CEC_OP_FEAT_EXT))
899 p++; 900 p++;
900 if (!(*p & CEC_OP_FEAT_EXT)) { 901 if (!(*p & CEC_OP_FEAT_EXT)) {
diff --git a/include/uapi/linux/cec.h b/include/uapi/linux/cec.h
index 44579a24f95d..4351c3481aea 100644
--- a/include/uapi/linux/cec.h
+++ b/include/uapi/linux/cec.h
@@ -318,6 +318,7 @@ static inline int cec_is_unconfigured(__u16 log_addr_mask)
318#define CEC_MODE_FOLLOWER (0x1 << 4) 318#define CEC_MODE_FOLLOWER (0x1 << 4)
319#define CEC_MODE_EXCL_FOLLOWER (0x2 << 4) 319#define CEC_MODE_EXCL_FOLLOWER (0x2 << 4)
320#define CEC_MODE_EXCL_FOLLOWER_PASSTHRU (0x3 << 4) 320#define CEC_MODE_EXCL_FOLLOWER_PASSTHRU (0x3 << 4)
321#define CEC_MODE_MONITOR_PIN (0xd << 4)
321#define CEC_MODE_MONITOR (0xe << 4) 322#define CEC_MODE_MONITOR (0xe << 4)
322#define CEC_MODE_MONITOR_ALL (0xf << 4) 323#define CEC_MODE_MONITOR_ALL (0xf << 4)
323#define CEC_MODE_FOLLOWER_MSK 0xf0 324#define CEC_MODE_FOLLOWER_MSK 0xf0
@@ -338,6 +339,8 @@ static inline int cec_is_unconfigured(__u16 log_addr_mask)
338#define CEC_CAP_MONITOR_ALL (1 << 5) 339#define CEC_CAP_MONITOR_ALL (1 << 5)
339/* Hardware can use CEC only if the HDMI HPD pin is high. */ 340/* Hardware can use CEC only if the HDMI HPD pin is high. */
340#define CEC_CAP_NEEDS_HPD (1 << 6) 341#define CEC_CAP_NEEDS_HPD (1 << 6)
342/* Hardware can monitor CEC pin transitions */
343#define CEC_CAP_MONITOR_PIN (1 << 7)
341 344
342/** 345/**
343 * struct cec_caps - CEC capabilities structure. 346 * struct cec_caps - CEC capabilities structure.
@@ -405,8 +408,11 @@ struct cec_log_addrs {
405 * didn't empty the message queue in time 408 * didn't empty the message queue in time
406 */ 409 */
407#define CEC_EVENT_LOST_MSGS 2 410#define CEC_EVENT_LOST_MSGS 2
411#define CEC_EVENT_PIN_CEC_LOW 3
412#define CEC_EVENT_PIN_CEC_HIGH 4
408 413
409#define CEC_EVENT_FL_INITIAL_STATE (1 << 0) 414#define CEC_EVENT_FL_INITIAL_STATE (1 << 0)
415#define CEC_EVENT_FL_DROPPED_EVENTS (1 << 1)
410 416
411/** 417/**
412 * struct cec_event_state_change - used when the CEC adapter changes state. 418 * struct cec_event_state_change - used when the CEC adapter changes state.
@@ -419,7 +425,7 @@ struct cec_event_state_change {
419}; 425};
420 426
421/** 427/**
422 * struct cec_event_lost_msgs - tells you how many messages were lost due. 428 * struct cec_event_lost_msgs - tells you how many messages were lost.
423 * @lost_msgs: how many messages were lost. 429 * @lost_msgs: how many messages were lost.
424 */ 430 */
425struct cec_event_lost_msgs { 431struct cec_event_lost_msgs {
diff --git a/include/uapi/linux/dvb/ca.h b/include/uapi/linux/dvb/ca.h
index c18537f3e449..cb150029fdff 100644
--- a/include/uapi/linux/dvb/ca.h
+++ b/include/uapi/linux/dvb/ca.h
@@ -24,67 +24,131 @@
24#ifndef _DVBCA_H_ 24#ifndef _DVBCA_H_
25#define _DVBCA_H_ 25#define _DVBCA_H_
26 26
27/* slot interface types and info */ 27/**
28 28 * struct ca_slot_info - CA slot interface types and info.
29typedef struct ca_slot_info { 29 *
30 int num; /* slot number */ 30 * @num: slot number.
31 * @type: slot type.
32 * @flags: flags applicable to the slot.
33 *
34 * This struct stores the CA slot information.
35 *
36 * @type can be:
37 *
38 * - %CA_CI - CI high level interface;
39 * - %CA_CI_LINK - CI link layer level interface;
40 * - %CA_CI_PHYS - CI physical layer level interface;
41 * - %CA_DESCR - built-in descrambler;
42 * - %CA_SC -simple smart card interface.
43 *
44 * @flags can be:
45 *
46 * - %CA_CI_MODULE_PRESENT - module (or card) inserted;
47 * - %CA_CI_MODULE_READY - module is ready for usage.
48 */
31 49
32 int type; /* CA interface this slot supports */ 50struct ca_slot_info {
33#define CA_CI 1 /* CI high level interface */ 51 int num;
34#define CA_CI_LINK 2 /* CI link layer level interface */ 52 int type;
35#define CA_CI_PHYS 4 /* CI physical layer level interface */ 53#define CA_CI 1
36#define CA_DESCR 8 /* built-in descrambler */ 54#define CA_CI_LINK 2
37#define CA_SC 128 /* simple smart card interface */ 55#define CA_CI_PHYS 4
56#define CA_DESCR 8
57#define CA_SC 128
38 58
39 unsigned int flags; 59 unsigned int flags;
40#define CA_CI_MODULE_PRESENT 1 /* module (or card) inserted */ 60#define CA_CI_MODULE_PRESENT 1
41#define CA_CI_MODULE_READY 2 61#define CA_CI_MODULE_READY 2
42} ca_slot_info_t; 62};
43
44 63
45/* descrambler types and info */
46 64
47typedef struct ca_descr_info { 65/**
48 unsigned int num; /* number of available descramblers (keys) */ 66 * struct ca_descr_info - descrambler types and info.
49 unsigned int type; /* type of supported scrambling system */ 67 *
68 * @num: number of available descramblers (keys).
69 * @type: type of supported scrambling system.
70 *
71 * Identifies the number of descramblers and their type.
72 *
73 * @type can be:
74 *
75 * - %CA_ECD - European Common Descrambler (ECD) hardware;
76 * - %CA_NDS - Videoguard (NDS) hardware;
77 * - %CA_DSS - Distributed Sample Scrambling (DSS) hardware.
78 */
79struct ca_descr_info {
80 unsigned int num;
81 unsigned int type;
50#define CA_ECD 1 82#define CA_ECD 1
51#define CA_NDS 2 83#define CA_NDS 2
52#define CA_DSS 4 84#define CA_DSS 4
53} ca_descr_info_t; 85};
54 86
55typedef struct ca_caps { 87/**
56 unsigned int slot_num; /* total number of CA card and module slots */ 88 * struct ca_caps - CA slot interface capabilities.
57 unsigned int slot_type; /* OR of all supported types */ 89 *
58 unsigned int descr_num; /* total number of descrambler slots (keys) */ 90 * @slot_num: total number of CA card and module slots.
59 unsigned int descr_type; /* OR of all supported types */ 91 * @slot_type: bitmap with all supported types as defined at
60} ca_caps_t; 92 * &struct ca_slot_info (e. g. %CA_CI, %CA_CI_LINK, etc).
93 * @descr_num: total number of descrambler slots (keys)
94 * @descr_type: bitmap with all supported types as defined at
95 * &struct ca_descr_info (e. g. %CA_ECD, %CA_NDS, etc).
96 */
97struct ca_caps {
98 unsigned int slot_num;
99 unsigned int slot_type;
100 unsigned int descr_num;
101 unsigned int descr_type;
102};
61 103
62/* a message to/from a CI-CAM */ 104/**
63typedef struct ca_msg { 105 * struct ca_msg - a message to/from a CI-CAM
106 *
107 * @index: unused
108 * @type: unused
109 * @length: length of the message
110 * @msg: message
111 *
112 * This struct carries a message to be send/received from a CI CA module.
113 */
114struct ca_msg {
64 unsigned int index; 115 unsigned int index;
65 unsigned int type; 116 unsigned int type;
66 unsigned int length; 117 unsigned int length;
67 unsigned char msg[256]; 118 unsigned char msg[256];
68} ca_msg_t; 119};
69 120
70typedef struct ca_descr { 121/**
122 * struct ca_descr - CA descrambler control words info
123 *
124 * @index: CA Descrambler slot
125 * @parity: control words parity, where 0 means even and 1 means odd
126 * @cw: CA Descrambler control words
127 */
128struct ca_descr {
71 unsigned int index; 129 unsigned int index;
72 unsigned int parity; /* 0 == even, 1 == odd */ 130 unsigned int parity;
73 unsigned char cw[8]; 131 unsigned char cw[8];
74} ca_descr_t; 132};
75
76typedef struct ca_pid {
77 unsigned int pid;
78 int index; /* -1 == disable*/
79} ca_pid_t;
80 133
81#define CA_RESET _IO('o', 128) 134#define CA_RESET _IO('o', 128)
82#define CA_GET_CAP _IOR('o', 129, ca_caps_t) 135#define CA_GET_CAP _IOR('o', 129, struct ca_caps)
83#define CA_GET_SLOT_INFO _IOR('o', 130, ca_slot_info_t) 136#define CA_GET_SLOT_INFO _IOR('o', 130, struct ca_slot_info)
84#define CA_GET_DESCR_INFO _IOR('o', 131, ca_descr_info_t) 137#define CA_GET_DESCR_INFO _IOR('o', 131, struct ca_descr_info)
85#define CA_GET_MSG _IOR('o', 132, ca_msg_t) 138#define CA_GET_MSG _IOR('o', 132, struct ca_msg)
86#define CA_SEND_MSG _IOW('o', 133, ca_msg_t) 139#define CA_SEND_MSG _IOW('o', 133, struct ca_msg)
87#define CA_SET_DESCR _IOW('o', 134, ca_descr_t) 140#define CA_SET_DESCR _IOW('o', 134, struct ca_descr)
88#define CA_SET_PID _IOW('o', 135, ca_pid_t) 141
142#if !defined(__KERNEL__)
143
144/* This is needed for legacy userspace support */
145typedef struct ca_slot_info ca_slot_info_t;
146typedef struct ca_descr_info ca_descr_info_t;
147typedef struct ca_caps ca_caps_t;
148typedef struct ca_msg ca_msg_t;
149typedef struct ca_descr ca_descr_t;
150
151#endif
152
89 153
90#endif 154#endif
diff --git a/include/uapi/linux/dvb/dmx.h b/include/uapi/linux/dvb/dmx.h
index 427e4899ed69..4aa5f6a1815a 100644
--- a/include/uapi/linux/dvb/dmx.h
+++ b/include/uapi/linux/dvb/dmx.h
@@ -32,28 +32,74 @@
32 32
33#define DMX_FILTER_SIZE 16 33#define DMX_FILTER_SIZE 16
34 34
35enum dmx_output 35/**
36{ 36 * enum dmx_output - Output for the demux.
37 DMX_OUT_DECODER, /* Streaming directly to decoder. */ 37 *
38 DMX_OUT_TAP, /* Output going to a memory buffer */ 38 * @DMX_OUT_DECODER:
39 /* (to be retrieved via the read command).*/ 39 * Streaming directly to decoder.
40 DMX_OUT_TS_TAP, /* Output multiplexed into a new TS */ 40 * @DMX_OUT_TAP:
41 /* (to be retrieved by reading from the */ 41 * Output going to a memory buffer (to be retrieved via the read command).
42 /* logical DVR device). */ 42 * Delivers the stream output to the demux device on which the ioctl
43 DMX_OUT_TSDEMUX_TAP /* Like TS_TAP but retrieved from the DMX device */ 43 * is called.
44 * @DMX_OUT_TS_TAP:
45 * Output multiplexed into a new TS (to be retrieved by reading from the
46 * logical DVR device). Routes output to the logical DVR device
47 * ``/dev/dvb/adapter?/dvr?``, which delivers a TS multiplexed from all
48 * filters for which @DMX_OUT_TS_TAP was specified.
49 * @DMX_OUT_TSDEMUX_TAP:
50 * Like @DMX_OUT_TS_TAP but retrieved from the DMX device.
51 */
52enum dmx_output {
53 DMX_OUT_DECODER,
54 DMX_OUT_TAP,
55 DMX_OUT_TS_TAP,
56 DMX_OUT_TSDEMUX_TAP
44}; 57};
45 58
46typedef enum dmx_output dmx_output_t;
47 59
48typedef enum dmx_input 60/**
49{ 61 * enum dmx_input - Input from the demux.
50 DMX_IN_FRONTEND, /* Input from a front-end device. */ 62 *
51 DMX_IN_DVR /* Input from the logical DVR device. */ 63 * @DMX_IN_FRONTEND: Input from a front-end device.
52} dmx_input_t; 64 * @DMX_IN_DVR: Input from the logical DVR device.
65 */
66enum dmx_input {
67 DMX_IN_FRONTEND,
68 DMX_IN_DVR
69};
53 70
71/**
72 * enum dmx_ts_pes - type of the PES filter.
73 *
74 * @DMX_PES_AUDIO0: first audio PID. Also referred as @DMX_PES_AUDIO.
75 * @DMX_PES_VIDEO0: first video PID. Also referred as @DMX_PES_VIDEO.
76 * @DMX_PES_TELETEXT0: first teletext PID. Also referred as @DMX_PES_TELETEXT.
77 * @DMX_PES_SUBTITLE0: first subtitle PID. Also referred as @DMX_PES_SUBTITLE.
78 * @DMX_PES_PCR0: first Program Clock Reference PID.
79 * Also referred as @DMX_PES_PCR.
80 *
81 * @DMX_PES_AUDIO1: second audio PID.
82 * @DMX_PES_VIDEO1: second video PID.
83 * @DMX_PES_TELETEXT1: second teletext PID.
84 * @DMX_PES_SUBTITLE1: second subtitle PID.
85 * @DMX_PES_PCR1: second Program Clock Reference PID.
86 *
87 * @DMX_PES_AUDIO2: third audio PID.
88 * @DMX_PES_VIDEO2: third video PID.
89 * @DMX_PES_TELETEXT2: third teletext PID.
90 * @DMX_PES_SUBTITLE2: third subtitle PID.
91 * @DMX_PES_PCR2: third Program Clock Reference PID.
92 *
93 * @DMX_PES_AUDIO3: fourth audio PID.
94 * @DMX_PES_VIDEO3: fourth video PID.
95 * @DMX_PES_TELETEXT3: fourth teletext PID.
96 * @DMX_PES_SUBTITLE3: fourth subtitle PID.
97 * @DMX_PES_PCR3: fourth Program Clock Reference PID.
98 *
99 * @DMX_PES_OTHER: any other PID.
100 */
54 101
55typedef enum dmx_ts_pes 102enum dmx_ts_pes {
56{
57 DMX_PES_AUDIO0, 103 DMX_PES_AUDIO0,
58 DMX_PES_VIDEO0, 104 DMX_PES_VIDEO0,
59 DMX_PES_TELETEXT0, 105 DMX_PES_TELETEXT0,
@@ -79,7 +125,7 @@ typedef enum dmx_ts_pes
79 DMX_PES_PCR3, 125 DMX_PES_PCR3,
80 126
81 DMX_PES_OTHER 127 DMX_PES_OTHER
82} dmx_pes_type_t; 128};
83 129
84#define DMX_PES_AUDIO DMX_PES_AUDIO0 130#define DMX_PES_AUDIO DMX_PES_AUDIO0
85#define DMX_PES_VIDEO DMX_PES_VIDEO0 131#define DMX_PES_VIDEO DMX_PES_VIDEO0
@@ -88,56 +134,80 @@ typedef enum dmx_ts_pes
88#define DMX_PES_PCR DMX_PES_PCR0 134#define DMX_PES_PCR DMX_PES_PCR0
89 135
90 136
91typedef struct dmx_filter 137
92{ 138/**
139 * struct dmx_filter - Specifies a section header filter.
140 *
141 * @filter: bit array with bits to be matched at the section header.
142 * @mask: bits that are valid at the filter bit array.
143 * @mode: mode of match: if bit is zero, it will match if equal (positive
144 * match); if bit is one, it will match if the bit is negated.
145 *
146 * Note: All arrays in this struct have a size of DMX_FILTER_SIZE (16 bytes).
147 */
148struct dmx_filter {
93 __u8 filter[DMX_FILTER_SIZE]; 149 __u8 filter[DMX_FILTER_SIZE];
94 __u8 mask[DMX_FILTER_SIZE]; 150 __u8 mask[DMX_FILTER_SIZE];
95 __u8 mode[DMX_FILTER_SIZE]; 151 __u8 mode[DMX_FILTER_SIZE];
96} dmx_filter_t; 152};
97
98 153
99struct dmx_sct_filter_params 154/**
100{ 155 * struct dmx_sct_filter_params - Specifies a section filter.
101 __u16 pid; 156 *
102 dmx_filter_t filter; 157 * @pid: PID to be filtered.
103 __u32 timeout; 158 * @filter: section header filter, as defined by &struct dmx_filter.
104 __u32 flags; 159 * @timeout: maximum time to filter, in milliseconds.
160 * @flags: extra flags for the section filter.
161 *
162 * Carries the configuration for a MPEG-TS section filter.
163 *
164 * The @flags can be:
165 *
166 * - %DMX_CHECK_CRC - only deliver sections where the CRC check succeeded;
167 * - %DMX_ONESHOT - disable the section filter after one section
168 * has been delivered;
169 * - %DMX_IMMEDIATE_START - Start filter immediately without requiring a
170 * :ref:`DMX_START`.
171 */
172struct dmx_sct_filter_params {
173 __u16 pid;
174 struct dmx_filter filter;
175 __u32 timeout;
176 __u32 flags;
105#define DMX_CHECK_CRC 1 177#define DMX_CHECK_CRC 1
106#define DMX_ONESHOT 2 178#define DMX_ONESHOT 2
107#define DMX_IMMEDIATE_START 4 179#define DMX_IMMEDIATE_START 4
108#define DMX_KERNEL_CLIENT 0x8000
109}; 180};
110 181
111 182/**
112struct dmx_pes_filter_params 183 * struct dmx_pes_filter_params - Specifies Packetized Elementary Stream (PES)
113{ 184 * filter parameters.
114 __u16 pid; 185 *
115 dmx_input_t input; 186 * @pid: PID to be filtered.
116 dmx_output_t output; 187 * @input: Demux input, as specified by &enum dmx_input.
117 dmx_pes_type_t pes_type; 188 * @output: Demux output, as specified by &enum dmx_output.
118 __u32 flags; 189 * @pes_type: Type of the pes filter, as specified by &enum dmx_pes_type.
190 * @flags: Demux PES flags.
191 */
192struct dmx_pes_filter_params {
193 __u16 pid;
194 enum dmx_input input;
195 enum dmx_output output;
196 enum dmx_ts_pes pes_type;
197 __u32 flags;
119}; 198};
120 199
121typedef struct dmx_caps { 200/**
122 __u32 caps; 201 * struct dmx_stc - Stores System Time Counter (STC) information.
123 int num_decoders; 202 *
124} dmx_caps_t; 203 * @num: input data: number of the STC, from 0 to N.
125 204 * @base: output: divisor for STC to get 90 kHz clock.
126typedef enum dmx_source { 205 * @stc: output: stc in @base * 90 kHz units.
127 DMX_SOURCE_FRONT0 = 0, 206 */
128 DMX_SOURCE_FRONT1,
129 DMX_SOURCE_FRONT2,
130 DMX_SOURCE_FRONT3,
131 DMX_SOURCE_DVR0 = 16,
132 DMX_SOURCE_DVR1,
133 DMX_SOURCE_DVR2,
134 DMX_SOURCE_DVR3
135} dmx_source_t;
136
137struct dmx_stc { 207struct dmx_stc {
138 unsigned int num; /* input : which STC? 0..N */ 208 unsigned int num;
139 unsigned int base; /* output: divisor for stc to get 90 kHz clock */ 209 unsigned int base;
140 __u64 stc; /* output: stc in 'base'*90 kHz units */ 210 __u64 stc;
141}; 211};
142 212
143#define DMX_START _IO('o', 41) 213#define DMX_START _IO('o', 41)
@@ -146,10 +216,18 @@ struct dmx_stc {
146#define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params) 216#define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params)
147#define DMX_SET_BUFFER_SIZE _IO('o', 45) 217#define DMX_SET_BUFFER_SIZE _IO('o', 45)
148#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5]) 218#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5])
149#define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t)
150#define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t)
151#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc) 219#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc)
152#define DMX_ADD_PID _IOW('o', 51, __u16) 220#define DMX_ADD_PID _IOW('o', 51, __u16)
153#define DMX_REMOVE_PID _IOW('o', 52, __u16) 221#define DMX_REMOVE_PID _IOW('o', 52, __u16)
154 222
223#if !defined(__KERNEL__)
224
225/* This is needed for legacy userspace support */
226typedef enum dmx_output dmx_output_t;
227typedef enum dmx_input dmx_input_t;
228typedef enum dmx_ts_pes dmx_pes_type_t;
229typedef struct dmx_filter dmx_filter_t;
230
231#endif
232
155#endif /* _UAPI_DVBDMX_H_ */ 233#endif /* _UAPI_DVBDMX_H_ */
diff --git a/include/uapi/linux/dvb/frontend.h b/include/uapi/linux/dvb/frontend.h
index 00a20cd21ee2..861cacd5711f 100644
--- a/include/uapi/linux/dvb/frontend.h
+++ b/include/uapi/linux/dvb/frontend.h
@@ -28,13 +28,46 @@
28 28
29#include <linux/types.h> 29#include <linux/types.h>
30 30
31enum fe_type { 31/**
32 FE_QPSK, 32 * enum fe_caps - Frontend capabilities
33 FE_QAM, 33 *
34 FE_OFDM, 34 * @FE_IS_STUPID: There's something wrong at the
35 FE_ATSC 35 * frontend, and it can't report its
36}; 36 * capabilities.
37 37 * @FE_CAN_INVERSION_AUTO: Can auto-detect frequency spectral
38 * band inversion
39 * @FE_CAN_FEC_1_2: Supports FEC 1/2
40 * @FE_CAN_FEC_2_3: Supports FEC 2/3
41 * @FE_CAN_FEC_3_4: Supports FEC 3/4
42 * @FE_CAN_FEC_4_5: Supports FEC 4/5
43 * @FE_CAN_FEC_5_6: Supports FEC 5/6
44 * @FE_CAN_FEC_6_7: Supports FEC 6/7
45 * @FE_CAN_FEC_7_8: Supports FEC 7/8
46 * @FE_CAN_FEC_8_9: Supports FEC 8/9
47 * @FE_CAN_FEC_AUTO: Can auto-detect FEC
48 * @FE_CAN_QPSK: Supports QPSK modulation
49 * @FE_CAN_QAM_16: Supports 16-QAM modulation
50 * @FE_CAN_QAM_32: Supports 32-QAM modulation
51 * @FE_CAN_QAM_64: Supports 64-QAM modulation
52 * @FE_CAN_QAM_128: Supports 128-QAM modulation
53 * @FE_CAN_QAM_256: Supports 256-QAM modulation
54 * @FE_CAN_QAM_AUTO: Can auto-detect QAM modulation
55 * @FE_CAN_TRANSMISSION_MODE_AUTO: Can auto-detect transmission mode
56 * @FE_CAN_BANDWIDTH_AUTO: Can auto-detect bandwidth
57 * @FE_CAN_GUARD_INTERVAL_AUTO: Can auto-detect guard interval
58 * @FE_CAN_HIERARCHY_AUTO: Can auto-detect hierarchy
59 * @FE_CAN_8VSB: Supports 8-VSB modulation
60 * @FE_CAN_16VSB: Supporta 16-VSB modulation
61 * @FE_HAS_EXTENDED_CAPS: Unused
62 * @FE_CAN_MULTISTREAM: Supports multistream filtering
63 * @FE_CAN_TURBO_FEC: Supports "turbo FEC" modulation
64 * @FE_CAN_2G_MODULATION: Supports "2nd generation" modulation,
65 * e. g. DVB-S2, DVB-T2, DVB-C2
66 * @FE_NEEDS_BENDING: Unused
67 * @FE_CAN_RECOVER: Can recover from a cable unplug
68 * automatically
69 * @FE_CAN_MUTE_TS: Can stop spurious TS data output
70 */
38enum fe_caps { 71enum fe_caps {
39 FE_IS_STUPID = 0, 72 FE_IS_STUPID = 0,
40 FE_CAN_INVERSION_AUTO = 0x1, 73 FE_CAN_INVERSION_AUTO = 0x1,
@@ -60,15 +93,55 @@ enum fe_caps {
60 FE_CAN_HIERARCHY_AUTO = 0x100000, 93 FE_CAN_HIERARCHY_AUTO = 0x100000,
61 FE_CAN_8VSB = 0x200000, 94 FE_CAN_8VSB = 0x200000,
62 FE_CAN_16VSB = 0x400000, 95 FE_CAN_16VSB = 0x400000,
63 FE_HAS_EXTENDED_CAPS = 0x800000, /* We need more bitspace for newer APIs, indicate this. */ 96 FE_HAS_EXTENDED_CAPS = 0x800000,
64 FE_CAN_MULTISTREAM = 0x4000000, /* frontend supports multistream filtering */ 97 FE_CAN_MULTISTREAM = 0x4000000,
65 FE_CAN_TURBO_FEC = 0x8000000, /* frontend supports "turbo fec modulation" */ 98 FE_CAN_TURBO_FEC = 0x8000000,
66 FE_CAN_2G_MODULATION = 0x10000000, /* frontend supports "2nd generation modulation" (DVB-S2) */ 99 FE_CAN_2G_MODULATION = 0x10000000,
67 FE_NEEDS_BENDING = 0x20000000, /* not supported anymore, don't use (frontend requires frequency bending) */ 100 FE_NEEDS_BENDING = 0x20000000,
68 FE_CAN_RECOVER = 0x40000000, /* frontend can recover from a cable unplug automatically */ 101 FE_CAN_RECOVER = 0x40000000,
69 FE_CAN_MUTE_TS = 0x80000000 /* frontend can stop spurious TS data output */ 102 FE_CAN_MUTE_TS = 0x80000000
103};
104
105/*
106 * DEPRECATED: Should be kept just due to backward compatibility.
107 */
108enum fe_type {
109 FE_QPSK,
110 FE_QAM,
111 FE_OFDM,
112 FE_ATSC
70}; 113};
71 114
115/**
116 * struct dvb_frontend_info - Frontend properties and capabilities
117 *
118 * @name: Name of the frontend
119 * @type: **DEPRECATED**.
120 * Should not be used on modern programs,
121 * as a frontend may have more than one type.
122 * In order to get the support types of a given
123 * frontend, use :c:type:`DTV_ENUM_DELSYS`
124 * instead.
125 * @frequency_min: Minimal frequency supported by the frontend.
126 * @frequency_max: Minimal frequency supported by the frontend.
127 * @frequency_stepsize: All frequencies are multiple of this value.
128 * @frequency_tolerance: Frequency tolerance.
129 * @symbol_rate_min: Minimal symbol rate, in bauds
130 * (for Cable/Satellite systems).
131 * @symbol_rate_max: Maximal symbol rate, in bauds
132 * (for Cable/Satellite systems).
133 * @symbol_rate_tolerance: Maximal symbol rate tolerance, in ppm
134 * (for Cable/Satellite systems).
135 * @notifier_delay: **DEPRECATED**. Not used by any driver.
136 * @caps: Capabilities supported by the frontend,
137 * as specified in &enum fe_caps.
138 *
139 * .. note:
140 *
141 * #. The frequencies are specified in Hz for Terrestrial and Cable
142 * systems.
143 * #. The frequencies are specified in kHz for Satellite systems.
144 */
72struct dvb_frontend_info { 145struct dvb_frontend_info {
73 char name[128]; 146 char name[128];
74 enum fe_type type; /* DEPRECATED. Use DTV_ENUM_DELSYS instead */ 147 enum fe_type type; /* DEPRECATED. Use DTV_ENUM_DELSYS instead */
@@ -78,55 +151,105 @@ struct dvb_frontend_info {
78 __u32 frequency_tolerance; 151 __u32 frequency_tolerance;
79 __u32 symbol_rate_min; 152 __u32 symbol_rate_min;
80 __u32 symbol_rate_max; 153 __u32 symbol_rate_max;
81 __u32 symbol_rate_tolerance; /* ppm */ 154 __u32 symbol_rate_tolerance;
82 __u32 notifier_delay; /* DEPRECATED */ 155 __u32 notifier_delay; /* DEPRECATED */
83 enum fe_caps caps; 156 enum fe_caps caps;
84}; 157};
85 158
86
87/** 159/**
88 * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for 160 * struct dvb_diseqc_master_cmd - DiSEqC master command
89 * the meaning of this struct... 161 *
162 * @msg:
163 * DiSEqC message to be sent. It contains a 3 bytes header with:
164 * framing + address + command, and an optional argument
165 * of up to 3 bytes of data.
166 * @msg_len:
167 * Length of the DiSEqC message. Valid values are 3 to 6.
168 *
169 * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
170 * the possible messages that can be used.
90 */ 171 */
91struct dvb_diseqc_master_cmd { 172struct dvb_diseqc_master_cmd {
92 __u8 msg [6]; /* { framing, address, command, data [3] } */ 173 __u8 msg[6];
93 __u8 msg_len; /* valid values are 3...6 */ 174 __u8 msg_len;
94}; 175};
95 176
177/**
178 * struct dvb_diseqc_slave_reply - DiSEqC received data
179 *
180 * @msg:
181 * DiSEqC message buffer to store a message received via DiSEqC.
182 * It contains one byte header with: framing and
183 * an optional argument of up to 3 bytes of data.
184 * @msg_len:
185 * Length of the DiSEqC message. Valid values are 0 to 4,
186 * where 0 means no message.
187 * @timeout:
188 * Return from ioctl after timeout ms with errorcode when
189 * no message was received.
190 *
191 * Check out the DiSEqC bus spec available on http://www.eutelsat.org/ for
192 * the possible messages that can be used.
193 */
96struct dvb_diseqc_slave_reply { 194struct dvb_diseqc_slave_reply {
97 __u8 msg [4]; /* { framing, data [3] } */ 195 __u8 msg[4];
98 __u8 msg_len; /* valid values are 0...4, 0 means no msg */ 196 __u8 msg_len;
99 int timeout; /* return from ioctl after timeout ms with */ 197 int timeout;
100}; /* errorcode when no message was received */ 198};
101 199
200/**
201 * enum fe_sec_voltage - DC Voltage used to feed the LNBf
202 *
203 * @SEC_VOLTAGE_13: Output 13V to the LNBf
204 * @SEC_VOLTAGE_18: Output 18V to the LNBf
205 * @SEC_VOLTAGE_OFF: Don't feed the LNBf with a DC voltage
206 */
102enum fe_sec_voltage { 207enum fe_sec_voltage {
103 SEC_VOLTAGE_13, 208 SEC_VOLTAGE_13,
104 SEC_VOLTAGE_18, 209 SEC_VOLTAGE_18,
105 SEC_VOLTAGE_OFF 210 SEC_VOLTAGE_OFF
106}; 211};
107 212
213/**
214 * enum fe_sec_tone_mode - Type of tone to be send to the LNBf.
215 * @SEC_TONE_ON: Sends a 22kHz tone burst to the antenna.
216 * @SEC_TONE_OFF: Don't send a 22kHz tone to the antenna (except
217 * if the ``FE_DISEQC_*`` ioctls are called).
218 */
108enum fe_sec_tone_mode { 219enum fe_sec_tone_mode {
109 SEC_TONE_ON, 220 SEC_TONE_ON,
110 SEC_TONE_OFF 221 SEC_TONE_OFF
111}; 222};
112 223
224/**
225 * enum fe_sec_mini_cmd - Type of mini burst to be sent
226 *
227 * @SEC_MINI_A: Sends a mini-DiSEqC 22kHz '0' Tone Burst to select
228 * satellite-A
229 * @SEC_MINI_B: Sends a mini-DiSEqC 22kHz '1' Data Burst to select
230 * satellite-B
231 */
113enum fe_sec_mini_cmd { 232enum fe_sec_mini_cmd {
114 SEC_MINI_A, 233 SEC_MINI_A,
115 SEC_MINI_B 234 SEC_MINI_B
116}; 235};
117 236
118/** 237/**
119 * enum fe_status - enumerates the possible frontend status 238 * enum fe_status - Enumerates the possible frontend status.
120 * @FE_HAS_SIGNAL: found something above the noise level 239 * @FE_NONE: The frontend doesn't have any kind of lock.
121 * @FE_HAS_CARRIER: found a DVB signal 240 * That's the initial frontend status
122 * @FE_HAS_VITERBI: FEC is stable 241 * @FE_HAS_SIGNAL: Has found something above the noise level.
123 * @FE_HAS_SYNC: found sync bytes 242 * @FE_HAS_CARRIER: Has found a signal.
124 * @FE_HAS_LOCK: everything's working 243 * @FE_HAS_VITERBI: FEC inner coding (Viterbi, LDPC or other inner code).
125 * @FE_TIMEDOUT: no lock within the last ~2 seconds 244 * is stable.
126 * @FE_REINIT: frontend was reinitialized, application is recommended 245 * @FE_HAS_SYNC: Synchronization bytes was found.
127 * to reset DiSEqC, tone and parameters 246 * @FE_HAS_LOCK: Digital TV were locked and everything is working.
247 * @FE_TIMEDOUT: Fo lock within the last about 2 seconds.
248 * @FE_REINIT: Frontend was reinitialized, application is recommended
249 * to reset DiSEqC, tone and parameters.
128 */ 250 */
129enum fe_status { 251enum fe_status {
252 FE_NONE = 0x00,
130 FE_HAS_SIGNAL = 0x01, 253 FE_HAS_SIGNAL = 0x01,
131 FE_HAS_CARRIER = 0x02, 254 FE_HAS_CARRIER = 0x02,
132 FE_HAS_VITERBI = 0x04, 255 FE_HAS_VITERBI = 0x04,
@@ -136,12 +259,45 @@ enum fe_status {
136 FE_REINIT = 0x40, 259 FE_REINIT = 0x40,
137}; 260};
138 261
262/**
263 * enum fe_spectral_inversion - Type of inversion band
264 *
265 * @INVERSION_OFF: Don't do spectral band inversion.
266 * @INVERSION_ON: Do spectral band inversion.
267 * @INVERSION_AUTO: Autodetect spectral band inversion.
268 *
269 * This parameter indicates if spectral inversion should be presumed or
270 * not. In the automatic setting (``INVERSION_AUTO``) the hardware will try
271 * to figure out the correct setting by itself. If the hardware doesn't
272 * support, the %dvb_frontend will try to lock at the carrier first with
273 * inversion off. If it fails, it will try to enable inversion.
274 */
139enum fe_spectral_inversion { 275enum fe_spectral_inversion {
140 INVERSION_OFF, 276 INVERSION_OFF,
141 INVERSION_ON, 277 INVERSION_ON,
142 INVERSION_AUTO 278 INVERSION_AUTO
143}; 279};
144 280
281/**
282 * enum fe_code_rate - Type of Forward Error Correction (FEC)
283 *
284 *
285 * @FEC_NONE: No Forward Error Correction Code
286 * @FEC_1_2: Forward Error Correction Code 1/2
287 * @FEC_2_3: Forward Error Correction Code 2/3
288 * @FEC_3_4: Forward Error Correction Code 3/4
289 * @FEC_4_5: Forward Error Correction Code 4/5
290 * @FEC_5_6: Forward Error Correction Code 5/6
291 * @FEC_6_7: Forward Error Correction Code 6/7
292 * @FEC_7_8: Forward Error Correction Code 7/8
293 * @FEC_8_9: Forward Error Correction Code 8/9
294 * @FEC_AUTO: Autodetect Error Correction Code
295 * @FEC_3_5: Forward Error Correction Code 3/5
296 * @FEC_9_10: Forward Error Correction Code 9/10
297 * @FEC_2_5: Forward Error Correction Code 2/5
298 *
299 * Please note that not all FEC types are supported by a given standard.
300 */
145enum fe_code_rate { 301enum fe_code_rate {
146 FEC_NONE = 0, 302 FEC_NONE = 0,
147 FEC_1_2, 303 FEC_1_2,
@@ -158,6 +314,26 @@ enum fe_code_rate {
158 FEC_2_5, 314 FEC_2_5,
159}; 315};
160 316
317/**
318 * enum fe_modulation - Type of modulation/constellation
319 * @QPSK: QPSK modulation
320 * @QAM_16: 16-QAM modulation
321 * @QAM_32: 32-QAM modulation
322 * @QAM_64: 64-QAM modulation
323 * @QAM_128: 128-QAM modulation
324 * @QAM_256: 256-QAM modulation
325 * @QAM_AUTO: Autodetect QAM modulation
326 * @VSB_8: 8-VSB modulation
327 * @VSB_16: 16-VSB modulation
328 * @PSK_8: 8-PSK modulation
329 * @APSK_16: 16-APSK modulation
330 * @APSK_32: 32-APSK modulation
331 * @DQPSK: DQPSK modulation
332 * @QAM_4_NR: 4-QAM-NR modulation
333 *
334 * Please note that not all modulations are supported by a given standard.
335 *
336 */
161enum fe_modulation { 337enum fe_modulation {
162 QPSK, 338 QPSK,
163 QAM_16, 339 QAM_16,
@@ -175,6 +351,32 @@ enum fe_modulation {
175 QAM_4_NR, 351 QAM_4_NR,
176}; 352};
177 353
354/**
355 * enum fe_transmit_mode - Transmission mode
356 *
357 * @TRANSMISSION_MODE_AUTO:
358 * Autodetect transmission mode. The hardware will try to find the
359 * correct FFT-size (if capable) to fill in the missing parameters.
360 * @TRANSMISSION_MODE_1K:
361 * Transmission mode 1K
362 * @TRANSMISSION_MODE_2K:
363 * Transmission mode 2K
364 * @TRANSMISSION_MODE_8K:
365 * Transmission mode 8K
366 * @TRANSMISSION_MODE_4K:
367 * Transmission mode 4K
368 * @TRANSMISSION_MODE_16K:
369 * Transmission mode 16K
370 * @TRANSMISSION_MODE_32K:
371 * Transmission mode 32K
372 * @TRANSMISSION_MODE_C1:
373 * Single Carrier (C=1) transmission mode (DTMB only)
374 * @TRANSMISSION_MODE_C3780:
375 * Multi Carrier (C=3780) transmission mode (DTMB only)
376 *
377 * Please note that not all transmission modes are supported by a given
378 * standard.
379 */
178enum fe_transmit_mode { 380enum fe_transmit_mode {
179 TRANSMISSION_MODE_2K, 381 TRANSMISSION_MODE_2K,
180 TRANSMISSION_MODE_8K, 382 TRANSMISSION_MODE_8K,
@@ -187,6 +389,23 @@ enum fe_transmit_mode {
187 TRANSMISSION_MODE_C3780, 389 TRANSMISSION_MODE_C3780,
188}; 390};
189 391
392/**
393 * enum fe_guard_interval - Guard interval
394 *
395 * @GUARD_INTERVAL_AUTO: Autodetect the guard interval
396 * @GUARD_INTERVAL_1_128: Guard interval 1/128
397 * @GUARD_INTERVAL_1_32: Guard interval 1/32
398 * @GUARD_INTERVAL_1_16: Guard interval 1/16
399 * @GUARD_INTERVAL_1_8: Guard interval 1/8
400 * @GUARD_INTERVAL_1_4: Guard interval 1/4
401 * @GUARD_INTERVAL_19_128: Guard interval 19/128
402 * @GUARD_INTERVAL_19_256: Guard interval 19/256
403 * @GUARD_INTERVAL_PN420: PN length 420 (1/4)
404 * @GUARD_INTERVAL_PN595: PN length 595 (1/6)
405 * @GUARD_INTERVAL_PN945: PN length 945 (1/9)
406 *
407 * Please note that not all guard intervals are supported by a given standard.
408 */
190enum fe_guard_interval { 409enum fe_guard_interval {
191 GUARD_INTERVAL_1_32, 410 GUARD_INTERVAL_1_32,
192 GUARD_INTERVAL_1_16, 411 GUARD_INTERVAL_1_16,
@@ -201,6 +420,16 @@ enum fe_guard_interval {
201 GUARD_INTERVAL_PN945, 420 GUARD_INTERVAL_PN945,
202}; 421};
203 422
423/**
424 * enum fe_hierarchy - Hierarchy
425 * @HIERARCHY_NONE: No hierarchy
426 * @HIERARCHY_AUTO: Autodetect hierarchy (if supported)
427 * @HIERARCHY_1: Hierarchy 1
428 * @HIERARCHY_2: Hierarchy 2
429 * @HIERARCHY_4: Hierarchy 4
430 *
431 * Please note that not all hierarchy types are supported by a given standard.
432 */
204enum fe_hierarchy { 433enum fe_hierarchy {
205 HIERARCHY_NONE, 434 HIERARCHY_NONE,
206 HIERARCHY_1, 435 HIERARCHY_1,
@@ -209,6 +438,15 @@ enum fe_hierarchy {
209 HIERARCHY_AUTO 438 HIERARCHY_AUTO
210}; 439};
211 440
441/**
442 * enum fe_interleaving - Interleaving
443 * @INTERLEAVING_NONE: No interleaving.
444 * @INTERLEAVING_AUTO: Auto-detect interleaving.
445 * @INTERLEAVING_240: Interleaving of 240 symbols.
446 * @INTERLEAVING_720: Interleaving of 720 symbols.
447 *
448 * Please note that, currently, only DTMB uses it.
449 */
212enum fe_interleaving { 450enum fe_interleaving {
213 INTERLEAVING_NONE, 451 INTERLEAVING_NONE,
214 INTERLEAVING_AUTO, 452 INTERLEAVING_AUTO,
@@ -216,7 +454,8 @@ enum fe_interleaving {
216 INTERLEAVING_720, 454 INTERLEAVING_720,
217}; 455};
218 456
219/* S2API Commands */ 457/* DVBv5 property Commands */
458
220#define DTV_UNDEFINED 0 459#define DTV_UNDEFINED 0
221#define DTV_TUNE 1 460#define DTV_TUNE 1
222#define DTV_CLEAR 2 461#define DTV_CLEAR 2
@@ -309,19 +548,79 @@ enum fe_interleaving {
309 548
310#define DTV_MAX_COMMAND DTV_STAT_TOTAL_BLOCK_COUNT 549#define DTV_MAX_COMMAND DTV_STAT_TOTAL_BLOCK_COUNT
311 550
551/**
552 * enum fe_pilot - Type of pilot tone
553 *
554 * @PILOT_ON: Pilot tones enabled
555 * @PILOT_OFF: Pilot tones disabled
556 * @PILOT_AUTO: Autodetect pilot tones
557 */
312enum fe_pilot { 558enum fe_pilot {
313 PILOT_ON, 559 PILOT_ON,
314 PILOT_OFF, 560 PILOT_OFF,
315 PILOT_AUTO, 561 PILOT_AUTO,
316}; 562};
317 563
564/**
565 * enum fe_rolloff - Rolloff factor
566 * @ROLLOFF_35: Roloff factor: α=35%
567 * @ROLLOFF_20: Roloff factor: α=20%
568 * @ROLLOFF_25: Roloff factor: α=25%
569 * @ROLLOFF_AUTO: Auto-detect the roloff factor.
570 *
571 * .. note:
572 *
573 * Roloff factor of 35% is implied on DVB-S. On DVB-S2, it is default.
574 */
318enum fe_rolloff { 575enum fe_rolloff {
319 ROLLOFF_35, /* Implied value in DVB-S, default for DVB-S2 */ 576 ROLLOFF_35,
320 ROLLOFF_20, 577 ROLLOFF_20,
321 ROLLOFF_25, 578 ROLLOFF_25,
322 ROLLOFF_AUTO, 579 ROLLOFF_AUTO,
323}; 580};
324 581
582/**
583 * enum fe_delivery_system - Type of the delivery system
584 *
585 * @SYS_UNDEFINED:
586 * Undefined standard. Generally, indicates an error
587 * @SYS_DVBC_ANNEX_A:
588 * Cable TV: DVB-C following ITU-T J.83 Annex A spec
589 * @SYS_DVBC_ANNEX_B:
590 * Cable TV: DVB-C following ITU-T J.83 Annex B spec (ClearQAM)
591 * @SYS_DVBC_ANNEX_C:
592 * Cable TV: DVB-C following ITU-T J.83 Annex C spec
593 * @SYS_ISDBC:
594 * Cable TV: ISDB-C (no drivers yet)
595 * @SYS_DVBT:
596 * Terrestrial TV: DVB-T
597 * @SYS_DVBT2:
598 * Terrestrial TV: DVB-T2
599 * @SYS_ISDBT:
600 * Terrestrial TV: ISDB-T
601 * @SYS_ATSC:
602 * Terrestrial TV: ATSC
603 * @SYS_ATSCMH:
604 * Terrestrial TV (mobile): ATSC-M/H
605 * @SYS_DTMB:
606 * Terrestrial TV: DTMB
607 * @SYS_DVBS:
608 * Satellite TV: DVB-S
609 * @SYS_DVBS2:
610 * Satellite TV: DVB-S2
611 * @SYS_TURBO:
612 * Satellite TV: DVB-S Turbo
613 * @SYS_ISDBS:
614 * Satellite TV: ISDB-S
615 * @SYS_DAB:
616 * Digital audio: DAB (not fully supported)
617 * @SYS_DSS:
618 * Satellite TV: DSS (not fully supported)
619 * @SYS_CMMB:
620 * Terrestrial TV (mobile): CMMB (not fully supported)
621 * @SYS_DVBH:
622 * Terrestrial TV (mobile): DVB-H (standard deprecated)
623 */
325enum fe_delivery_system { 624enum fe_delivery_system {
326 SYS_UNDEFINED, 625 SYS_UNDEFINED,
327 SYS_DVBC_ANNEX_A, 626 SYS_DVBC_ANNEX_A,
@@ -344,35 +643,85 @@ enum fe_delivery_system {
344 SYS_DVBC_ANNEX_C, 643 SYS_DVBC_ANNEX_C,
345}; 644};
346 645
347/* backward compatibility */ 646/* backward compatibility definitions for delivery systems */
348#define SYS_DVBC_ANNEX_AC SYS_DVBC_ANNEX_A 647#define SYS_DVBC_ANNEX_AC SYS_DVBC_ANNEX_A
349#define SYS_DMBTH SYS_DTMB /* DMB-TH is legacy name, use DTMB instead */ 648#define SYS_DMBTH SYS_DTMB /* DMB-TH is legacy name, use DTMB */
350 649
351/* ATSC-MH */ 650/* ATSC-MH specific parameters */
352 651
652/**
653 * enum atscmh_sccc_block_mode - Type of Series Concatenated Convolutional
654 * Code Block Mode.
655 *
656 * @ATSCMH_SCCC_BLK_SEP:
657 * Separate SCCC: the SCCC outer code mode shall be set independently
658 * for each Group Region (A, B, C, D)
659 * @ATSCMH_SCCC_BLK_COMB:
660 * Combined SCCC: all four Regions shall have the same SCCC outer
661 * code mode.
662 * @ATSCMH_SCCC_BLK_RES:
663 * Reserved. Shouldn't be used.
664 */
353enum atscmh_sccc_block_mode { 665enum atscmh_sccc_block_mode {
354 ATSCMH_SCCC_BLK_SEP = 0, 666 ATSCMH_SCCC_BLK_SEP = 0,
355 ATSCMH_SCCC_BLK_COMB = 1, 667 ATSCMH_SCCC_BLK_COMB = 1,
356 ATSCMH_SCCC_BLK_RES = 2, 668 ATSCMH_SCCC_BLK_RES = 2,
357}; 669};
358 670
671/**
672 * enum atscmh_sccc_code_mode - Type of Series Concatenated Convolutional
673 * Code Rate.
674 *
675 * @ATSCMH_SCCC_CODE_HLF:
676 * The outer code rate of a SCCC Block is 1/2 rate.
677 * @ATSCMH_SCCC_CODE_QTR:
678 * The outer code rate of a SCCC Block is 1/4 rate.
679 * @ATSCMH_SCCC_CODE_RES:
680 * Reserved. Should not be used.
681 */
359enum atscmh_sccc_code_mode { 682enum atscmh_sccc_code_mode {
360 ATSCMH_SCCC_CODE_HLF = 0, 683 ATSCMH_SCCC_CODE_HLF = 0,
361 ATSCMH_SCCC_CODE_QTR = 1, 684 ATSCMH_SCCC_CODE_QTR = 1,
362 ATSCMH_SCCC_CODE_RES = 2, 685 ATSCMH_SCCC_CODE_RES = 2,
363}; 686};
364 687
688/**
689 * enum atscmh_rs_frame_ensemble - Reed Solomon(RS) frame ensemble.
690 *
691 * @ATSCMH_RSFRAME_ENS_PRI: Primary Ensemble.
692 * @ATSCMH_RSFRAME_ENS_SEC: Secondary Ensemble.
693 */
365enum atscmh_rs_frame_ensemble { 694enum atscmh_rs_frame_ensemble {
366 ATSCMH_RSFRAME_ENS_PRI = 0, 695 ATSCMH_RSFRAME_ENS_PRI = 0,
367 ATSCMH_RSFRAME_ENS_SEC = 1, 696 ATSCMH_RSFRAME_ENS_SEC = 1,
368}; 697};
369 698
699/**
700 * enum atscmh_rs_frame_mode - Reed Solomon (RS) frame mode.
701 *
702 * @ATSCMH_RSFRAME_PRI_ONLY:
703 * Single Frame: There is only a primary RS Frame for all Group
704 * Regions.
705 * @ATSCMH_RSFRAME_PRI_SEC:
706 * Dual Frame: There are two separate RS Frames: Primary RS Frame for
707 * Group Region A and B and Secondary RS Frame for Group Region C and
708 * D.
709 * @ATSCMH_RSFRAME_RES:
710 * Reserved. Shouldn't be used.
711 */
370enum atscmh_rs_frame_mode { 712enum atscmh_rs_frame_mode {
371 ATSCMH_RSFRAME_PRI_ONLY = 0, 713 ATSCMH_RSFRAME_PRI_ONLY = 0,
372 ATSCMH_RSFRAME_PRI_SEC = 1, 714 ATSCMH_RSFRAME_PRI_SEC = 1,
373 ATSCMH_RSFRAME_RES = 2, 715 ATSCMH_RSFRAME_RES = 2,
374}; 716};
375 717
718/**
719 * enum atscmh_rs_code_mode
720 * @ATSCMH_RSCODE_211_187: Reed Solomon code (211,187).
721 * @ATSCMH_RSCODE_223_187: Reed Solomon code (223,187).
722 * @ATSCMH_RSCODE_235_187: Reed Solomon code (235,187).
723 * @ATSCMH_RSCODE_RES: Reserved. Shouldn't be used.
724 */
376enum atscmh_rs_code_mode { 725enum atscmh_rs_code_mode {
377 ATSCMH_RSCODE_211_187 = 0, 726 ATSCMH_RSCODE_211_187 = 0,
378 ATSCMH_RSCODE_223_187 = 1, 727 ATSCMH_RSCODE_223_187 = 1,
@@ -383,28 +732,18 @@ enum atscmh_rs_code_mode {
383#define NO_STREAM_ID_FILTER (~0U) 732#define NO_STREAM_ID_FILTER (~0U)
384#define LNA_AUTO (~0U) 733#define LNA_AUTO (~0U)
385 734
386struct dtv_cmds_h {
387 char *name; /* A display name for debugging purposes */
388
389 __u32 cmd; /* A unique ID */
390
391 /* Flags */
392 __u32 set:1; /* Either a set or get property */
393 __u32 buffer:1; /* Does this property use the buffer? */
394 __u32 reserved:30; /* Align */
395};
396
397/** 735/**
398 * Scale types for the quality parameters. 736 * enum fecap_scale_params - scale types for the quality parameters.
737 *
399 * @FE_SCALE_NOT_AVAILABLE: That QoS measure is not available. That 738 * @FE_SCALE_NOT_AVAILABLE: That QoS measure is not available. That
400 * could indicate a temporary or a permanent 739 * could indicate a temporary or a permanent
401 * condition. 740 * condition.
402 * @FE_SCALE_DECIBEL: The scale is measured in 0.001 dB steps, typically 741 * @FE_SCALE_DECIBEL: The scale is measured in 0.001 dB steps, typically
403 * used on signal measures. 742 * used on signal measures.
404 * @FE_SCALE_RELATIVE: The scale is a relative percentual measure, 743 * @FE_SCALE_RELATIVE: The scale is a relative percentual measure,
405 * ranging from 0 (0%) to 0xffff (100%). 744 * ranging from 0 (0%) to 0xffff (100%).
406 * @FE_SCALE_COUNTER: The scale counts the occurrence of an event, like 745 * @FE_SCALE_COUNTER: The scale counts the occurrence of an event, like
407 * bit error, block error, lapsed time. 746 * bit error, block error, lapsed time.
408 */ 747 */
409enum fecap_scale_params { 748enum fecap_scale_params {
410 FE_SCALE_NOT_AVAILABLE = 0, 749 FE_SCALE_NOT_AVAILABLE = 0,
@@ -416,24 +755,38 @@ enum fecap_scale_params {
416/** 755/**
417 * struct dtv_stats - Used for reading a DTV status property 756 * struct dtv_stats - Used for reading a DTV status property
418 * 757 *
419 * @value: value of the measure. Should range from 0 to 0xffff;
420 * @scale: Filled with enum fecap_scale_params - the scale 758 * @scale: Filled with enum fecap_scale_params - the scale
421 * in usage for that parameter 759 * in usage for that parameter
422 * 760 *
761 * The ``{unnamed_union}`` may have either one of the values below:
762 *
763 * %svalue
764 * integer value of the measure, for %FE_SCALE_DECIBEL,
765 * used for dB measures. The unit is 0.001 dB.
766 *
767 * %uvalue
768 * unsigned integer value of the measure, used when @scale is
769 * either %FE_SCALE_RELATIVE or %FE_SCALE_COUNTER.
770 *
423 * For most delivery systems, this will return a single value for each 771 * For most delivery systems, this will return a single value for each
424 * parameter. 772 * parameter.
773 *
425 * It should be noticed, however, that new OFDM delivery systems like 774 * It should be noticed, however, that new OFDM delivery systems like
426 * ISDB can use different modulation types for each group of carriers. 775 * ISDB can use different modulation types for each group of carriers.
427 * On such standards, up to 8 groups of statistics can be provided, one 776 * On such standards, up to 8 groups of statistics can be provided, one
428 * for each carrier group (called "layer" on ISDB). 777 * for each carrier group (called "layer" on ISDB).
778 *
429 * In order to be consistent with other delivery systems, the first 779 * In order to be consistent with other delivery systems, the first
430 * value refers to the entire set of carriers ("global"). 780 * value refers to the entire set of carriers ("global").
431 * dtv_status:scale should use the value FE_SCALE_NOT_AVAILABLE when 781 *
782 * @scale should use the value %FE_SCALE_NOT_AVAILABLE when
432 * the value for the entire group of carriers or from one specific layer 783 * the value for the entire group of carriers or from one specific layer
433 * is not provided by the hardware. 784 * is not provided by the hardware.
434 * st.len should be filled with the latest filled status + 1.
435 * 785 *
436 * In other words, for ISDB, those values should be filled like: 786 * @len should be filled with the latest filled status + 1.
787 *
788 * In other words, for ISDB, those values should be filled like::
789 *
437 * u.st.stat.svalue[0] = global statistics; 790 * u.st.stat.svalue[0] = global statistics;
438 * u.st.stat.scale[0] = FE_SCALE_DECIBEL; 791 * u.st.stat.scale[0] = FE_SCALE_DECIBEL;
439 * u.st.stat.value[1] = layer A statistics; 792 * u.st.stat.value[1] = layer A statistics;
@@ -455,11 +808,39 @@ struct dtv_stats {
455 808
456#define MAX_DTV_STATS 4 809#define MAX_DTV_STATS 4
457 810
811/**
812 * struct dtv_fe_stats - store Digital TV frontend statistics
813 *
814 * @len: length of the statistics - if zero, stats is disabled.
815 * @stat: array with digital TV statistics.
816 *
817 * On most standards, @len can either be 0 or 1. However, for ISDB, each
818 * layer is modulated in separate. So, each layer may have its own set
819 * of statistics. If so, stat[0] carries on a global value for the property.
820 * Indexes 1 to 3 means layer A to B.
821 */
458struct dtv_fe_stats { 822struct dtv_fe_stats {
459 __u8 len; 823 __u8 len;
460 struct dtv_stats stat[MAX_DTV_STATS]; 824 struct dtv_stats stat[MAX_DTV_STATS];
461} __attribute__ ((packed)); 825} __attribute__ ((packed));
462 826
827/**
828 * struct dtv_property - store one of frontend command and its value
829 *
830 * @cmd: Digital TV command.
831 * @reserved: Not used.
832 * @u: Union with the values for the command.
833 * @result: Result of the command set (currently unused).
834 *
835 * The @u union may have either one of the values below:
836 *
837 * %data
838 * an unsigned 32-bits number.
839 * %st
840 * a &struct dtv_fe_stats array of statistics.
841 * %buffer
842 * a buffer of up to 32 characters (currently unused).
843 */
463struct dtv_property { 844struct dtv_property {
464 __u32 cmd; 845 __u32 cmd;
465 __u32 reserved[3]; 846 __u32 reserved[3];
@@ -479,17 +860,70 @@ struct dtv_property {
479/* num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl */ 860/* num of properties cannot exceed DTV_IOCTL_MAX_MSGS per ioctl */
480#define DTV_IOCTL_MAX_MSGS 64 861#define DTV_IOCTL_MAX_MSGS 64
481 862
863/**
864 * struct dtv_properties - a set of command/value pairs.
865 *
866 * @num: amount of commands stored at the struct.
867 * @props: a pointer to &struct dtv_property.
868 */
482struct dtv_properties { 869struct dtv_properties {
483 __u32 num; 870 __u32 num;
484 struct dtv_property *props; 871 struct dtv_property *props;
485}; 872};
486 873
487#if defined(__DVB_CORE__) || !defined (__KERNEL__) 874/*
875 * When set, this flag will disable any zigzagging or other "normal" tuning
876 * behavior. Additionally, there will be no automatic monitoring of the lock
877 * status, and hence no frontend events will be generated. If a frontend device
878 * is closed, this flag will be automatically turned off when the device is
879 * reopened read-write.
880 */
881#define FE_TUNE_MODE_ONESHOT 0x01
882
883/* Digital TV Frontend API calls */
884
885#define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info)
886
887#define FE_DISEQC_RESET_OVERLOAD _IO('o', 62)
888#define FE_DISEQC_SEND_MASTER_CMD _IOW('o', 63, struct dvb_diseqc_master_cmd)
889#define FE_DISEQC_RECV_SLAVE_REPLY _IOR('o', 64, struct dvb_diseqc_slave_reply)
890#define FE_DISEQC_SEND_BURST _IO('o', 65) /* fe_sec_mini_cmd_t */
891
892#define FE_SET_TONE _IO('o', 66) /* fe_sec_tone_mode_t */
893#define FE_SET_VOLTAGE _IO('o', 67) /* fe_sec_voltage_t */
894#define FE_ENABLE_HIGH_LNB_VOLTAGE _IO('o', 68) /* int */
895
896#define FE_READ_STATUS _IOR('o', 69, fe_status_t)
897#define FE_READ_BER _IOR('o', 70, __u32)
898#define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, __u16)
899#define FE_READ_SNR _IOR('o', 72, __u16)
900#define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32)
901
902#define FE_SET_FRONTEND_TUNE_MODE _IO('o', 81) /* unsigned int */
903#define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event)
904
905#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
906
907#define FE_SET_PROPERTY _IOW('o', 82, struct dtv_properties)
908#define FE_GET_PROPERTY _IOR('o', 83, struct dtv_properties)
909
910#if defined(__DVB_CORE__) || !defined(__KERNEL__)
911
912/*
913 * DEPRECATED: Everything below is deprecated in favor of DVBv5 API
914 *
915 * The DVBv3 only ioctls, structs and enums should not be used on
916 * newer programs, as it doesn't support the second generation of
917 * digital TV standards, nor supports newer delivery systems.
918 * They also don't support modern frontends with usually support multiple
919 * delivery systems.
920 *
921 * Drivers shouldn't use them.
922 *
923 * New applications should use DVBv5 delivery system instead
924 */
488 925
489/* 926/*
490 * DEPRECATED: The DVBv3 ioctls, structs and enums should not be used on
491 * newer programs, as it doesn't support the second generation of digital
492 * TV standards, nor supports newer delivery systems.
493 */ 927 */
494 928
495enum fe_bandwidth { 929enum fe_bandwidth {
@@ -502,7 +936,7 @@ enum fe_bandwidth {
502 BANDWIDTH_1_712_MHZ, 936 BANDWIDTH_1_712_MHZ,
503}; 937};
504 938
505/* This is needed for legacy userspace support */ 939/* This is kept for legacy userspace support */
506typedef enum fe_sec_voltage fe_sec_voltage_t; 940typedef enum fe_sec_voltage fe_sec_voltage_t;
507typedef enum fe_caps fe_caps_t; 941typedef enum fe_caps fe_caps_t;
508typedef enum fe_type fe_type_t; 942typedef enum fe_type fe_type_t;
@@ -520,6 +954,8 @@ typedef enum fe_pilot fe_pilot_t;
520typedef enum fe_rolloff fe_rolloff_t; 954typedef enum fe_rolloff fe_rolloff_t;
521typedef enum fe_delivery_system fe_delivery_system_t; 955typedef enum fe_delivery_system fe_delivery_system_t;
522 956
957/* DVBv3 structs */
958
523struct dvb_qpsk_parameters { 959struct dvb_qpsk_parameters {
524 __u32 symbol_rate; /* symbol rate in Symbols per second */ 960 __u32 symbol_rate; /* symbol rate in Symbols per second */
525 fe_code_rate_t fec_inner; /* forward error correction (see above) */ 961 fe_code_rate_t fec_inner; /* forward error correction (see above) */
@@ -546,8 +982,8 @@ struct dvb_ofdm_parameters {
546}; 982};
547 983
548struct dvb_frontend_parameters { 984struct dvb_frontend_parameters {
549 __u32 frequency; /* (absolute) frequency in Hz for DVB-C/DVB-T/ATSC */ 985 __u32 frequency; /* (absolute) frequency in Hz for DVB-C/DVB-T/ATSC */
550 /* intermediate frequency in kHz for DVB-S */ 986 /* intermediate frequency in kHz for DVB-S */
551 fe_spectral_inversion_t inversion; 987 fe_spectral_inversion_t inversion;
552 union { 988 union {
553 struct dvb_qpsk_parameters qpsk; /* DVB-S */ 989 struct dvb_qpsk_parameters qpsk; /* DVB-S */
@@ -561,42 +997,12 @@ struct dvb_frontend_event {
561 fe_status_t status; 997 fe_status_t status;
562 struct dvb_frontend_parameters parameters; 998 struct dvb_frontend_parameters parameters;
563}; 999};
564#endif
565 1000
566#define FE_SET_PROPERTY _IOW('o', 82, struct dtv_properties) 1001/* DVBv3 API calls */
567#define FE_GET_PROPERTY _IOR('o', 83, struct dtv_properties)
568
569/**
570 * When set, this flag will disable any zigzagging or other "normal" tuning
571 * behaviour. Additionally, there will be no automatic monitoring of the lock
572 * status, and hence no frontend events will be generated. If a frontend device
573 * is closed, this flag will be automatically turned off when the device is
574 * reopened read-write.
575 */
576#define FE_TUNE_MODE_ONESHOT 0x01
577
578#define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info)
579
580#define FE_DISEQC_RESET_OVERLOAD _IO('o', 62)
581#define FE_DISEQC_SEND_MASTER_CMD _IOW('o', 63, struct dvb_diseqc_master_cmd)
582#define FE_DISEQC_RECV_SLAVE_REPLY _IOR('o', 64, struct dvb_diseqc_slave_reply)
583#define FE_DISEQC_SEND_BURST _IO('o', 65) /* fe_sec_mini_cmd_t */
584
585#define FE_SET_TONE _IO('o', 66) /* fe_sec_tone_mode_t */
586#define FE_SET_VOLTAGE _IO('o', 67) /* fe_sec_voltage_t */
587#define FE_ENABLE_HIGH_LNB_VOLTAGE _IO('o', 68) /* int */
588
589#define FE_READ_STATUS _IOR('o', 69, fe_status_t)
590#define FE_READ_BER _IOR('o', 70, __u32)
591#define FE_READ_SIGNAL_STRENGTH _IOR('o', 71, __u16)
592#define FE_READ_SNR _IOR('o', 72, __u16)
593#define FE_READ_UNCORRECTED_BLOCKS _IOR('o', 73, __u32)
594 1002
595#define FE_SET_FRONTEND _IOW('o', 76, struct dvb_frontend_parameters) 1003#define FE_SET_FRONTEND _IOW('o', 76, struct dvb_frontend_parameters)
596#define FE_GET_FRONTEND _IOR('o', 77, struct dvb_frontend_parameters) 1004#define FE_GET_FRONTEND _IOR('o', 77, struct dvb_frontend_parameters)
597#define FE_SET_FRONTEND_TUNE_MODE _IO('o', 81) /* unsigned int */
598#define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event)
599 1005
600#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */ 1006#endif
601 1007
602#endif /*_DVBFRONTEND_H_*/ 1008#endif /*_DVBFRONTEND_H_*/
diff --git a/include/uapi/linux/dvb/net.h b/include/uapi/linux/dvb/net.h
index f451e7eb0b0b..89d805f9a5a6 100644
--- a/include/uapi/linux/dvb/net.h
+++ b/include/uapi/linux/dvb/net.h
@@ -26,6 +26,21 @@
26 26
27#include <linux/types.h> 27#include <linux/types.h>
28 28
29/**
30 * struct dvb_net_if - describes a DVB network interface
31 *
32 * @pid: Packet ID (PID) of the MPEG-TS that contains data
33 * @if_num: number of the Digital TV interface.
34 * @feedtype: Encapsulation type of the feed.
35 *
36 * A MPEG-TS stream may contain packet IDs with IP packages on it.
37 * This struct describes it, and the type of encoding.
38 *
39 * @feedtype can be:
40 *
41 * - %DVB_NET_FEEDTYPE_MPE for MPE encoding
42 * - %DVB_NET_FEEDTYPE_ULE for ULE encoding.
43 */
29struct dvb_net_if { 44struct dvb_net_if {
30 __u16 pid; 45 __u16 pid;
31 __u16 if_num; 46 __u16 if_num;
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index fac96c64fe51..4865f1e71339 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -30,8 +30,6 @@
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/version.h> 31#include <linux/version.h>
32 32
33#define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0)
34
35struct media_device_info { 33struct media_device_info {
36 char driver[16]; 34 char driver[16];
37 char model[32]; 35 char model[32];
@@ -187,6 +185,9 @@ struct media_device_info {
187#define MEDIA_ENT_T_V4L2_SUBDEV_LENS MEDIA_ENT_F_LENS 185#define MEDIA_ENT_T_V4L2_SUBDEV_LENS MEDIA_ENT_F_LENS
188#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER MEDIA_ENT_F_ATV_DECODER 186#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER MEDIA_ENT_F_ATV_DECODER
189#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER MEDIA_ENT_F_TUNER 187#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER MEDIA_ENT_F_TUNER
188
189/* Obsolete symbol for media_version, no longer used in the kernel */
190#define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0)
190#endif 191#endif
191 192
192/* Entity flags */ 193/* Entity flags */
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 45cf7359822c..185d6a0acc06 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -603,6 +603,11 @@ struct v4l2_pix_format {
603#define V4L2_PIX_FMT_SGBRG12 v4l2_fourcc('G', 'B', '1', '2') /* 12 GBGB.. RGRG.. */ 603#define V4L2_PIX_FMT_SGBRG12 v4l2_fourcc('G', 'B', '1', '2') /* 12 GBGB.. RGRG.. */
604#define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12 GRGR.. BGBG.. */ 604#define V4L2_PIX_FMT_SGRBG12 v4l2_fourcc('B', 'A', '1', '2') /* 12 GRGR.. BGBG.. */
605#define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2') /* 12 RGRG.. GBGB.. */ 605#define V4L2_PIX_FMT_SRGGB12 v4l2_fourcc('R', 'G', '1', '2') /* 12 RGRG.. GBGB.. */
606 /* 12bit raw bayer packed, 6 bytes for every 4 pixels */
607#define V4L2_PIX_FMT_SBGGR12P v4l2_fourcc('p', 'B', 'C', 'C')
608#define V4L2_PIX_FMT_SGBRG12P v4l2_fourcc('p', 'G', 'C', 'C')
609#define V4L2_PIX_FMT_SGRBG12P v4l2_fourcc('p', 'g', 'C', 'C')
610#define V4L2_PIX_FMT_SRGGB12P v4l2_fourcc('p', 'R', 'C', 'C')
606#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */ 611#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */
607#define V4L2_PIX_FMT_SGBRG16 v4l2_fourcc('G', 'B', '1', '6') /* 16 GBGB.. RGRG.. */ 612#define V4L2_PIX_FMT_SGBRG16 v4l2_fourcc('G', 'B', '1', '6') /* 16 GBGB.. RGRG.. */
608#define V4L2_PIX_FMT_SGRBG16 v4l2_fourcc('G', 'R', '1', '6') /* 16 GRGR.. BGBG.. */ 613#define V4L2_PIX_FMT_SGRBG16 v4l2_fourcc('G', 'R', '1', '6') /* 16 GRGR.. BGBG.. */
diff --git a/samples/v4l/v4l2-pci-skeleton.c b/samples/v4l/v4l2-pci-skeleton.c
index 93b76c3220fd..483e9bca9444 100644
--- a/samples/v4l/v4l2-pci-skeleton.c
+++ b/samples/v4l/v4l2-pci-skeleton.c
@@ -282,7 +282,7 @@ static void stop_streaming(struct vb2_queue *vq)
282 * vb2_ops_wait_prepare/finish helper functions. If q->lock would be NULL, 282 * vb2_ops_wait_prepare/finish helper functions. If q->lock would be NULL,
283 * then this driver would have to provide these ops. 283 * then this driver would have to provide these ops.
284 */ 284 */
285static struct vb2_ops skel_qops = { 285static const struct vb2_ops skel_qops = {
286 .queue_setup = queue_setup, 286 .queue_setup = queue_setup,
287 .buf_prepare = buffer_prepare, 287 .buf_prepare = buffer_prepare,
288 .buf_queue = buffer_queue, 288 .buf_queue = buffer_queue,