]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Merge tag 'v5.3-rc4' into patchwork
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 12 Aug 2019 16:22:54 +0000 (13:22 -0300)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 12 Aug 2019 16:22:54 +0000 (13:22 -0300)
Linux 5.3-rc4

* tag 'v5.3-rc4': (750 commits)
  Linux 5.3-rc4
  Makefile: Convert -Wimplicit-fallthrough=3 to just -Wimplicit-fallthrough for clang
  ARM: ep93xx: Mark expected switch fall-through
  scsi: fas216: Mark expected switch fall-throughs
  pcmcia: db1xxx_ss: Mark expected switch fall-throughs
  video: fbdev: omapfb_main: Mark expected switch fall-throughs
  watchdog: riowd: Mark expected switch fall-through
  s390/net: Mark expected switch fall-throughs
  crypto: ux500/crypt: Mark expected switch fall-throughs
  watchdog: wdt977: Mark expected switch fall-through
  watchdog: scx200_wdt: Mark expected switch fall-through
  watchdog: Mark expected switch fall-throughs
  ARM: signal: Mark expected switch fall-through
  mfd: omap-usb-host: Mark expected switch fall-throughs
  mfd: db8500-prcmu: Mark expected switch fall-throughs
  ARM: OMAP: dma: Mark expected switch fall-throughs
  ARM: alignment: Mark expected switch fall-throughs
  ARM: tegra: Mark expected switch fall-through
  ARM/hw_breakpoint: Mark expected switch fall-throughs
  mm/memremap: Fix reuse of pgmap instances with internal references
  ...

266 files changed:
Documentation/devicetree/bindings/media/cdns,csi2tx.txt
Documentation/devicetree/bindings/media/meson-ao-cec.txt
Documentation/devicetree/bindings/media/nvidia,tegra-vde.txt
Documentation/devicetree/bindings/media/rockchip-vpu.txt
Documentation/devicetree/bindings/media/sunxi-ir.txt
Documentation/media/kapi/v4l2-dev.rst
Documentation/media/uapi/rc/lirc-dev-intro.rst
Documentation/media/uapi/rc/lirc-read.rst
Documentation/media/uapi/rc/lirc-write.rst
Documentation/media/uapi/rc/rc-protos.rst [new file with mode: 0644]
Documentation/media/uapi/rc/remote_controllers.rst
Documentation/media/uapi/v4l/biblio.rst
Documentation/media/uapi/v4l/ext-ctrls-codec.rst
Documentation/media/uapi/v4l/pixfmt-compressed.rst
Documentation/media/v4l-drivers/imx7.rst
Documentation/media/v4l-drivers/vimc.rst
Documentation/media/videodev2.h.rst.exceptions
arch/arm/mach-omap2/devices.c
drivers/input/touchscreen/sur40.c
drivers/media/Kconfig
drivers/media/common/saa7146/saa7146_video.c
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
drivers/media/common/videobuf2/videobuf2-dma-contig.c
drivers/media/common/videobuf2/videobuf2-v4l2.c
drivers/media/dvb-core/dvb_frontend.c
drivers/media/dvb-frontends/rtl2832_sdr.c
drivers/media/dvb-frontends/si2168.c
drivers/media/dvb-frontends/si2168.h
drivers/media/i2c/adv7511-v4l2.c
drivers/media/i2c/ir-kbd-i2c.c
drivers/media/i2c/mt9m111.c
drivers/media/i2c/ov2640.c
drivers/media/i2c/ov2659.c
drivers/media/i2c/ov2680.c
drivers/media/i2c/ov5640.c
drivers/media/i2c/ov5645.c
drivers/media/i2c/ov5695.c
drivers/media/i2c/ov7670.c
drivers/media/i2c/ov7740.c
drivers/media/pci/bt8xx/bttv-driver.c
drivers/media/pci/bt8xx/bttv-risc.c
drivers/media/pci/bt8xx/bttvp.h
drivers/media/pci/cobalt/cobalt-driver.c
drivers/media/pci/cobalt/cobalt-flash.c
drivers/media/pci/cobalt/cobalt-v4l2.c
drivers/media/pci/cx23885/cx23885-417.c
drivers/media/pci/cx23885/cx23885-video.c
drivers/media/pci/cx23885/cx23885.h
drivers/media/pci/cx25821/cx25821-video.c
drivers/media/pci/cx25821/cx25821.h
drivers/media/pci/cx88/cx88-blackbird.c
drivers/media/pci/cx88/cx88-video.c
drivers/media/pci/cx88/cx88.h
drivers/media/pci/dt3155/dt3155.c
drivers/media/pci/intel/ipu3/ipu3-cio2.c
drivers/media/pci/meye/meye.c
drivers/media/pci/pt1/pt1.c
drivers/media/pci/pt3/pt3.c
drivers/media/pci/saa7134/saa7134-empress.c
drivers/media/pci/saa7134/saa7134-tvaudio.c
drivers/media/pci/saa7134/saa7134-video.c
drivers/media/pci/saa7134/saa7134.h
drivers/media/pci/saa7164/saa7164-encoder.c
drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
drivers/media/pci/solo6x10/solo6x10-v4l2.c
drivers/media/pci/sta2x11/sta2x11_vip.c
drivers/media/pci/tw68/tw68-video.c
drivers/media/pci/tw68/tw68.h
drivers/media/platform/Kconfig
drivers/media/platform/am437x/am437x-vpfe.c
drivers/media/platform/am437x/am437x-vpfe.h
drivers/media/platform/atmel/atmel-sama5d2-isc.c
drivers/media/platform/cadence/cdns-csi2tx.c
drivers/media/platform/coda/coda-common.c
drivers/media/platform/cros-ec-cec/cros-ec-cec.c
drivers/media/platform/davinci/vpbe_display.c
drivers/media/platform/davinci/vpbe_osd.c
drivers/media/platform/davinci/vpbe_venc.c
drivers/media/platform/davinci/vpfe_capture.c
drivers/media/platform/davinci/vpif_capture.c
drivers/media/platform/davinci/vpif_display.c
drivers/media/platform/exynos-gsc/gsc-core.c
drivers/media/platform/exynos-gsc/gsc-core.h
drivers/media/platform/exynos4-is/fimc-capture.c
drivers/media/platform/exynos4-is/fimc-core.c
drivers/media/platform/exynos4-is/fimc-is.c
drivers/media/platform/exynos4-is/fimc-isp-video.c
drivers/media/platform/exynos4-is/fimc-isp.c
drivers/media/platform/exynos4-is/fimc-lite.c
drivers/media/platform/exynos4-is/fimc-m2m.c
drivers/media/platform/exynos4-is/media-dev.c
drivers/media/platform/exynos4-is/mipi-csis.c
drivers/media/platform/fsl-viu.c
drivers/media/platform/imx-pxp.c
drivers/media/platform/m2m-deinterlace.c
drivers/media/platform/marvell-ccic/mcam-core.c
drivers/media/platform/marvell-ccic/mmp-driver.c
drivers/media/platform/meson/ao-cec-g12a.c
drivers/media/platform/meson/ao-cec.c
drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
drivers/media/platform/mx2_emmaprp.c
drivers/media/platform/omap/omap_vout.c
drivers/media/platform/omap3isp/isp.c
drivers/media/platform/omap3isp/ispvideo.c
drivers/media/platform/pxa_camera.c
drivers/media/platform/qcom/camss/camss.c
drivers/media/platform/qcom/venus/core.h
drivers/media/platform/qcom/venus/helpers.c
drivers/media/platform/qcom/venus/helpers.h
drivers/media/platform/qcom/venus/hfi.c
drivers/media/platform/qcom/venus/hfi.h
drivers/media/platform/qcom/venus/vdec.c
drivers/media/platform/qcom/venus/vdec_ctrls.c
drivers/media/platform/qcom/venus/venc.c
drivers/media/platform/rcar-vin/rcar-core.c
drivers/media/platform/rcar-vin/rcar-dma.c
drivers/media/platform/rcar-vin/rcar-v4l2.c
drivers/media/platform/rcar-vin/rcar-vin.h
drivers/media/platform/renesas-ceu.c
drivers/media/platform/rockchip/rga/rga.c
drivers/media/platform/s3c-camif/camif-capture.c
drivers/media/platform/s3c-camif/camif-core.c
drivers/media/platform/s3c-camif/camif-core.h
drivers/media/platform/s5p-cec/s5p_cec.c
drivers/media/platform/s5p-g2d/g2d.c
drivers/media/platform/s5p-g2d/g2d.h
drivers/media/platform/s5p-jpeg/jpeg-core.c
drivers/media/platform/s5p-jpeg/jpeg-core.h
drivers/media/platform/s5p-mfc/s5p_mfc_common.h
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
drivers/media/platform/seco-cec/seco-cec.c
drivers/media/platform/sh_veu.c
drivers/media/platform/sh_vou.c
drivers/media/platform/sti/bdisp/bdisp-v4l2.c
drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
drivers/media/platform/sti/cec/stih-cec.c
drivers/media/platform/sti/hva/hva-hw.c
drivers/media/platform/stm32/stm32-dcmi.c
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
drivers/media/platform/tegra-cec/tegra_cec.c
drivers/media/platform/ti-vpe/cal.c
drivers/media/platform/ti-vpe/vpe.c
drivers/media/platform/via-camera.c
drivers/media/platform/vicodec/codec-v4l2-fwht.c
drivers/media/platform/vimc/vimc-streamer.c
drivers/media/platform/vimc/vimc-streamer.h
drivers/media/platform/vivid/vivid-core.c
drivers/media/platform/vivid/vivid-ctrls.c
drivers/media/platform/vivid/vivid-kthread-cap.c
drivers/media/platform/vivid/vivid-vid-common.c
drivers/media/platform/vsp1/vsp1_histo.c
drivers/media/platform/vsp1/vsp1_video.c
drivers/media/platform/xilinx/xilinx-dma.c
drivers/media/platform/xilinx/xilinx-vip.c
drivers/media/platform/xilinx/xilinx-vip.h
drivers/media/platform/xilinx/xilinx-vipp.c
drivers/media/rc/iguanair.c
drivers/media/rc/img-ir/img-ir-core.c
drivers/media/rc/ir-hix5hd2.c
drivers/media/rc/mceusb.c
drivers/media/rc/meson-ir.c
drivers/media/rc/mtk-cir.c
drivers/media/rc/sunxi-cir.c
drivers/media/usb/airspy/airspy.c
drivers/media/usb/au0828/au0828-video.c
drivers/media/usb/cpia2/cpia2_v4l.c
drivers/media/usb/cx231xx/cx231xx-417.c
drivers/media/usb/cx231xx/cx231xx-video.c
drivers/media/usb/cx231xx/cx231xx.h
drivers/media/usb/dvb-usb-v2/dvbsky.c
drivers/media/usb/dvb-usb/dib0700_devices.c
drivers/media/usb/dvb-usb/pctv452e.c
drivers/media/usb/dvb-usb/technisat-usb2.c
drivers/media/usb/em28xx/em28xx-video.c
drivers/media/usb/em28xx/em28xx.h
drivers/media/usb/go7007/go7007-v4l2.c
drivers/media/usb/go7007/snd-go7007.c
drivers/media/usb/gspca/gspca.c
drivers/media/usb/hdpvr/hdpvr-core.c
drivers/media/usb/hdpvr/hdpvr-video.c
drivers/media/usb/msi2500/msi2500.c
drivers/media/usb/pwc/pwc-v4l.c
drivers/media/usb/s2255/s2255drv.c
drivers/media/usb/stk1160/stk1160-v4l.c
drivers/media/usb/stk1160/stk1160.h
drivers/media/usb/stkwebcam/stk-webcam.c
drivers/media/usb/tm6000/tm6000-video.c
drivers/media/usb/tm6000/tm6000.h
drivers/media/usb/usbtv/usbtv-video.c
drivers/media/usb/usbvision/usbvision-video.c
drivers/media/usb/usbvision/usbvision.h
drivers/media/usb/uvc/uvc_v4l2.c
drivers/media/usb/zr364xx/zr364xx.c
drivers/media/v4l2-core/Makefile
drivers/media/v4l2-core/v4l2-async.c
drivers/media/v4l2-core/v4l2-common.c
drivers/media/v4l2-core/v4l2-ctrls.c
drivers/media/v4l2-core/v4l2-dev.c
drivers/media/v4l2-core/v4l2-fwnode.c
drivers/media/v4l2-core/v4l2-ioctl.c
drivers/media/v4l2-core/v4l2-mem2mem.c
drivers/media/v4l2-core/v4l2-subdev.c
drivers/staging/media/Kconfig
drivers/staging/media/Makefile
drivers/staging/media/bcm2048/Kconfig [deleted file]
drivers/staging/media/bcm2048/Makefile [deleted file]
drivers/staging/media/bcm2048/TODO [deleted file]
drivers/staging/media/bcm2048/radio-bcm2048.c [deleted file]
drivers/staging/media/bcm2048/radio-bcm2048.h [deleted file]
drivers/staging/media/davinci_vpfe/Kconfig [deleted file]
drivers/staging/media/davinci_vpfe/Makefile [deleted file]
drivers/staging/media/davinci_vpfe/TODO [deleted file]
drivers/staging/media/davinci_vpfe/davinci-vpfe-mc.txt [deleted file]
drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h [deleted file]
drivers/staging/media/davinci_vpfe/dm365_ipipe.c [deleted file]
drivers/staging/media/davinci_vpfe/dm365_ipipe.h [deleted file]
drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c [deleted file]
drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h [deleted file]
drivers/staging/media/davinci_vpfe/dm365_ipipeif.c [deleted file]
drivers/staging/media/davinci_vpfe/dm365_ipipeif.h [deleted file]
drivers/staging/media/davinci_vpfe/dm365_ipipeif_user.h [deleted file]
drivers/staging/media/davinci_vpfe/dm365_isif.c [deleted file]
drivers/staging/media/davinci_vpfe/dm365_isif.h [deleted file]
drivers/staging/media/davinci_vpfe/dm365_isif_regs.h [deleted file]
drivers/staging/media/davinci_vpfe/dm365_resizer.c [deleted file]
drivers/staging/media/davinci_vpfe/dm365_resizer.h [deleted file]
drivers/staging/media/davinci_vpfe/vpfe.h [deleted file]
drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c [deleted file]
drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h [deleted file]
drivers/staging/media/davinci_vpfe/vpfe_video.c [deleted file]
drivers/staging/media/davinci_vpfe/vpfe_video.h [deleted file]
drivers/staging/media/hantro/Kconfig
drivers/staging/media/hantro/Makefile
drivers/staging/media/hantro/hantro.h
drivers/staging/media/hantro/hantro_drv.c
drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c
drivers/staging/media/hantro/hantro_g1_vp8_dec.c [new file with mode: 0644]
drivers/staging/media/hantro/hantro_h1_jpeg_enc.c
drivers/staging/media/hantro/hantro_hw.h
drivers/staging/media/hantro/hantro_v4l2.c
drivers/staging/media/hantro/hantro_vp8.c [new file with mode: 0644]
drivers/staging/media/hantro/rk3288_vpu_hw.c
drivers/staging/media/hantro/rk3399_vpu_hw.c
drivers/staging/media/hantro/rk3399_vpu_hw_jpeg_enc.c
drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c
drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c [new file with mode: 0644]
drivers/staging/media/imx/imx-media-utils.c
drivers/staging/media/ipu3/ipu3.c
drivers/staging/media/omap4iss/iss_video.c
drivers/staging/media/omap4iss/iss_video.h
drivers/staging/media/soc_camera/soc_camera.c
drivers/staging/media/sunxi/cedrus/cedrus_regs.h
drivers/staging/media/tegra-vde/Kconfig
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
drivers/staging/vc04_services/bcm2835-camera/mmal-common.h
include/media/davinci/vpfe_capture.h
include/media/drv-intf/exynos-fimc.h
include/media/drv-intf/saa7146_vv.h
include/media/drv-intf/soc_mediabus.h
include/media/dvb-usb-ids.h
include/media/rc-map.h
include/media/v4l2-async.h
include/media/v4l2-ctrls.h
include/media/v4l2-ioctl.h
include/media/vp8-ctrls.h [new file with mode: 0644]

index 459c6e332f5290a9a746306041ab2a848286a0f3..751b9edf12471d86f3bfe899b541dc66e75c4e9f 100644 (file)
@@ -5,7 +5,8 @@ The Cadence MIPI-CSI2 TX controller is a CSI-2 bridge supporting up to
 4 CSI lanes in output, and up to 4 different pixel streams in input.
 
 Required properties:
-  - compatible: must be set to "cdns,csi2tx"
+  - compatible: must be set to "cdns,csi2tx" or "cdns,csi2tx-1.3"
+    for version 1.3 of the controller, "cdns,csi2tx-2.1" for v2.1
   - reg: base address and size of the memory mapped region
   - clocks: phandles to the clocks driving the controller
   - clock-names: must contain:
index c67fc41d4aa23bebd1c84107bd3fd27491b6c719..ad92ee41c0dd2de4a0a70054f27128f67d0deeaf 100644 (file)
@@ -5,10 +5,12 @@ to handle communication between HDMI connected devices over the CEC bus.
 
 Required properties:
   - compatible : value should be following depending on the SoC :
-       For GXBB, GXL, GXM and G12A (AO_CEC_A module) :
+       For GXBB, GXL, GXM, G12A and SM1 (AO_CEC_A module) :
        "amlogic,meson-gx-ao-cec"
        For G12A (AO_CEC_B module) :
        "amlogic,meson-g12a-ao-cec"
+       For SM1 (AO_CEC_B module) :
+       "amlogic,meson-sm1-ao-cec"
 
   - reg : Physical base address of the IP registers and length of memory
          mapped region.
@@ -16,9 +18,9 @@ Required properties:
   - interrupts : AO-CEC interrupt number to the CPU.
   - clocks : from common clock binding: handle to AO-CEC clock.
   - clock-names : from common clock binding, must contain :
-               For GXBB, GXL, GXM and G12A (AO_CEC_A module) :
+               For GXBB, GXL, GXM, G12A and SM1 (AO_CEC_A module) :
                - "core"
-               For G12A (AO_CEC_B module) :
+               For G12A, SM1 (AO_CEC_B module) :
                - "oscin"
                corresponding to entry in the clocks property.
   - hdmi-phandle: phandle to the HDMI controller
index 7302e949e662cb8070fb0a32b9f77d75bd249c62..602169b8aa1986a9d9c215c3ca764c16376e364f 100644 (file)
@@ -35,6 +35,7 @@ Optional properties:
 - resets : Must contain an entry for each entry in reset-names.
 - reset-names : Must include the following entries:
   - mc
+- iommus: Must contain phandle to the IOMMU device node.
 
 Example:
 
@@ -59,4 +60,5 @@ video-codec@6001a000 {
        clocks = <&tegra_car TEGRA20_CLK_VDE>;
        reset-names = "vde", "mc";
        resets = <&tegra_car 61>, <&mc TEGRA20_MC_RESET_VDE>;
+       iommus = <&mc TEGRA_SWGROUP_VDE>;
 };
index 35dc464ad7c8619297e840425e2ae7b4a92286ed..339252d9c5157fda507f49a8884adaf04957d9e6 100644 (file)
@@ -1,14 +1,17 @@
 device-tree bindings for rockchip VPU codec
 
 Rockchip (Video Processing Unit) present in various Rockchip platforms,
-such as RK3288 and RK3399.
+such as RK3288, RK3328 and RK3399.
 
 Required properties:
 - compatible: value should be one of the following
                "rockchip,rk3288-vpu";
+               "rockchip,rk3328-vpu";
                "rockchip,rk3399-vpu";
 - interrupts: encoding and decoding interrupt specifiers
-- interrupt-names: should be "vepu" and "vdpu"
+- interrupt-names: should be
+               "vepu", "vdpu" on RK3288 and RK3399,
+               "vdpu" on RK3328.
 - clocks: phandle to VPU aclk, hclk clocks
 - clock-names: should be "aclk" and "hclk"
 - power-domains: phandle to power domain node
@@ -27,3 +30,14 @@ SoC-specific DT entry:
                power-domains = <&power RK3288_PD_VIDEO>;
                iommus = <&vpu_mmu>;
        };
+
+       vpu: video-codec@ff350000 {
+               compatible = "rockchip,rk3328-vpu";
+               reg = <0x0 0xff350000 0x0 0x800>;
+               interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "vdpu";
+               clocks = <&cru ACLK_VPU>, <&cru HCLK_VPU>;
+               clock-names = "aclk", "hclk";
+               power-domains = <&power RK3328_PD_VPU>;
+               iommus = <&vpu_mmu>;
+       };
index 278098987edbd5990850d50e6992f7091dd0d392..81eaf95fb7648b625693eb7edebed67ec1803270 100644 (file)
@@ -1,16 +1,23 @@
 Device-Tree bindings for SUNXI IR controller found in sunXi SoC family
 
 Required properties:
-- compatible       : "allwinner,sun4i-a10-ir" or "allwinner,sun5i-a13-ir"
+- compatible       :
+       "allwinner,sun4i-a10-ir"
+       "allwinner,sun5i-a13-ir"
+       "allwinner,sun6i-a31-ir"
+       "allwinner,sun50i-a64-ir", "allwinner,sun6i-a31-ir"
+       "allwinner,sun50i-h6-ir", "allwinner,sun6i-a31-ir"
 - clocks           : list of clock specifiers, corresponding to
                      entries in clock-names property;
 - clock-names      : should contain "apb" and "ir" entries;
 - interrupts       : should contain IR IRQ number;
 - reg              : should contain IO map address for IR.
 
+Required properties since A31:
+- resets           : phandle + reset specifier pair
+
 Optional properties:
 - linux,rc-map-name: see rc.txt file in the same directory.
-- resets : phandle + reset specifier pair
 - clock-frequency  : IR Receiver clock frequency, in Hertz. Defaults to 8 MHz
                     if missing.
 
index b359f1804bbe26674ed274f98a65eb751384ac32..4c5a15c53dbfb01872d63ce5bd9126de0049a9b5 100644 (file)
@@ -288,6 +288,7 @@ Mask  Description
 0x08  Log the read and write file operations and the VIDIOC_QBUF and
       VIDIOC_DQBUF ioctls.
 0x10  Log the poll file operation.
+0x20  Log error and messages in the control operations.
 ===== ================================================================
 
 Video device cleanup
index 1a901d8e1797c764d312749f5828ee32bb23c5f6..b68c01693939a6348b3935cc283ef282794f1c22 100644 (file)
@@ -20,6 +20,9 @@ data between userspace and kernelspace. Fundamentally, it is just a chardev
 file_operations defined on it. With respect to transporting raw IR and
 decoded scancodes to and fro, the essential fops are read, write and ioctl.
 
+It is also possible to attach a BPF program to a LIRC device for decoding
+raw IR into scancodes.
+
 Example dmesg output upon a driver registering w/LIRC:
 
 .. code-block:: none
@@ -34,6 +37,16 @@ What you should see for a chardev:
     $ ls -l /dev/lirc*
     crw-rw---- 1 root root 248, 0 Jul 2 22:20 /dev/lirc0
 
+Note that the package `v4l-utils <https://git.linuxtv.org/v4l-utils.git/>`_
+contains tools for working with LIRC devices:
+
+ - ir-ctl: can receive raw IR and transmit IR, as well as query LIRC
+   device features.
+
+ - ir-keytable: can load keymaps; allows you to set IR kernel protocols; load
+   BPF IR decoders and test IR decoding. Some BPF IR decoders are also
+   provided.
+
 .. _lirc_modes:
 
 **********
@@ -53,11 +66,12 @@ on the following table.
 
     For transmitting (aka sending), create a ``struct lirc_scancode`` with
     the desired scancode set in the ``scancode`` member, :c:type:`rc_proto`
-    set the IR protocol, and all other members set to 0. Write this struct to
-    the lirc device.
+    set to the :ref:`IR protocol <Remote_controllers_Protocols>`, and all other
+    members set to 0. Write this struct to the lirc device.
 
-    For receiving, you read ``struct lirc_scancode`` from the lirc device,
-    with ``scancode`` set to the received scancode and the IR protocol
+    For receiving, you read ``struct lirc_scancode`` from the LIRC device.
+    The ``scancode`` field is set to the received scancode and the
+    :ref:`IR protocol <Remote_controllers_Protocols>` is set in
     :c:type:`rc_proto`. If the scancode maps to a valid key code, this is set
     in the ``keycode`` field, else it is set to ``KEY_RESERVED``.
 
@@ -129,12 +143,29 @@ on the following table.
 
     This mode is used only for IR send.
 
-
-**************************
-Remote Controller protocol
-**************************
-
-An enum :c:type:`rc_proto` in the :ref:`lirc_header` lists all the
-supported IR protocols:
-
-.. kernel-doc:: include/uapi/linux/lirc.h
+********************
+BPF based IR decoder
+********************
+
+The kernel has support for decoding the most common
+:ref:`IR protocols <Remote_controllers_Protocols>`, but there
+are many protocols which are not supported. To support these, it is possible
+to load an BPF program which does the decoding. This can only be done on
+LIRC devices which support reading raw IR.
+
+First, using the `bpf(2)`_ syscall with the ``BPF_LOAD_PROG`` argument,
+program must be loaded of type ``BPF_PROG_TYPE_LIRC_MODE2``. Once attached
+to the LIRC device, this program will be called for each pulse, space or
+timeout event on the LIRC device. The context for the BPF program is a
+pointer to a unsigned int, which is a :ref:`LIRC_MODE_MODE2 <lirc-mode-mode2>`
+value. When the program has decoded the scancode, it can be submitted using
+the BPF functions ``bpf_rc_keydown()`` or ``bpf_rc_repeat()``. Mouse or pointer
+movements can be reported using ``bpf_rc_pointer_rel()``.
+
+Once you have the file descriptor for the ``BPF_PROG_TYPE_LIRC_MODE2`` BPF
+program, it can be attached to the LIRC device using the `bpf(2)`_ syscall.
+The target must be the file descriptor for the LIRC device, and the
+attach type must be ``BPF_LIRC_MODE2``. No more than 64 BPF programs can be
+attached to a single LIRC device at a time.
+
+.. _bpf(2): http://man7.org/linux/man-pages/man2/bpf.2.html
index a8fedfaaf0ab303b5b5fc45945716c0a0b2da3b4..256e520bc27ee306022ce9e9ef98c867928796f7 100644 (file)
@@ -62,7 +62,8 @@ read from the chardev.
 Alternatively, :ref:`LIRC_MODE_SCANCODE <lirc-mode-scancode>` can be available,
 in this mode scancodes which are either decoded by software decoders, or
 by hardware decoders. The :c:type:`rc_proto` member is set to the
-protocol used for transmission, and ``scancode`` to the decoded scancode,
+:ref:`IR protocol <Remote_controllers_Protocols>`
+used for transmission, and ``scancode`` to the decoded scancode,
 and the ``keycode`` set to the keycode or ``KEY_RESERVED``.
 
 
index 6adf5ddbac9948c844962fb8e555e99c44b1f83b..eafe13203ea35e2772c06b7623f67d01864a0f86 100644 (file)
@@ -64,7 +64,8 @@ driver returns ``EINVAL``.
 When in :ref:`LIRC_MODE_SCANCODE <lirc-mode-scancode>` mode, one
 ``struct lirc_scancode`` must be written to the chardev at a time, else
 ``EINVAL`` is returned. Set the desired scancode in the ``scancode`` member,
-and the protocol in the :c:type:`rc_proto`: member. All other members must be
+and the :ref:`IR protocol <Remote_controllers_Protocols>` in the
+:c:type:`rc_proto`: member. All other members must be
 set to 0, else ``EINVAL`` is returned. If there is no protocol encoder
 for the protocol or the scancode is not valid for the specified protocol,
 ``EINVAL`` is returned. The write function blocks until the scancode
diff --git a/Documentation/media/uapi/rc/rc-protos.rst b/Documentation/media/uapi/rc/rc-protos.rst
new file mode 100644 (file)
index 0000000..b250ebe
--- /dev/null
@@ -0,0 +1,456 @@
+.. SPDX-License-Identifier: GPL-2.0
+..
+.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
+
+.. _Remote_controllers_Protocols:
+
+*****************************************
+Remote Controller Protocols and Scancodes
+*****************************************
+
+IR is encoded as a series of pulses and spaces, using a protocol. These
+protocols can encode e.g. an address (which device should respond) and a
+command: what it should do. The values for these are not always consistent
+across different devices for a given protocol.
+
+Therefore out the output of the IR decoder is a scancode; a single u32
+value. Using keymap tables this can be mapped to linux key codes.
+
+Other things can be encoded too. Some IR protocols encode a toggle bit; this
+is to distinguish whether the same button is being held down, or has been
+released and pressed again. If has been released and pressed again, the
+toggle bit will invert from one IR message to the next.
+
+Some remotes have a pointer-type device which can used to control the
+mouse; some air conditioning systems can have their target temperature
+target set in IR.
+
+The following are the protocols the kernel knows about and also lists
+how scancodes are encoded for each protocol.
+
+rc-5 (RC_PROTO_RC5)
+-------------------
+
+This IR protocol uses manchester encoding to encode 14 bits. There is a
+detailed description here https://www.sbprojects.net/knowledge/ir/rc5.php.
+
+The scancode encoding is *not* consistent with the lirc daemon (lircd) rc5
+protocol, or the manchester BPF decoder.
+
+.. flat-table:: rc5 bits scancode mapping
+   :widths:       1 1 2
+
+   * - rc-5 bit
+
+     - scancode bit
+
+     - description
+
+   * - 1
+
+     - none
+
+     - Start bit, always set
+
+   * - 1
+
+     - 6 (inverted)
+
+     - 2nd start bit in rc5,  re-used as 6th command bit
+
+   * - 1
+
+     - none
+
+     - Toggle bit
+
+   * - 5
+
+     - 8 to 13
+
+     - Address
+
+   * - 6
+
+     - 0 to 5
+
+     - Command
+
+There is a variant of rc5 called either rc5x or extended rc5
+where there the second stop bit is the 6th commmand bit, but inverted.
+This is done so it the scancodes and encoding is compatible with existing
+schemes. This bit is stored in bit 6 of the scancode, inverted. This is
+done to keep it compatible with plain rc-5 where there are two start bits.
+
+rc-5-sz (RC_PROTO_RC5_SZ)
+-------------------------
+This is much like rc-5 but one bit longer. The scancode is encoded
+differently.
+
+.. flat-table:: rc-5-sz bits scancode mapping
+   :widths:       1 1 2
+
+   * - rc-5-sz bits
+
+     - scancode bit
+
+     - description
+
+   * - 1
+
+     - none
+
+     - Start bit, always set
+
+   * - 1
+
+     - 13
+
+     - Address bit
+
+   * - 1
+
+     - none
+
+     - Toggle bit
+
+   * - 6
+
+     - 6 to 11
+
+     - Address
+
+   * - 6
+
+     - 0 to 5
+
+     - Command
+
+rc-5x-20 (RC_PROTO_RC5X_20)
+---------------------------
+
+This rc-5 extended to encoded 20 bits. The is a 3555 microseconds space
+after the 8th bit.
+
+.. flat-table:: rc-5x-20 bits scancode mapping
+   :widths:       1 1 2
+
+   * - rc-5-sz bits
+
+     - scancode bit
+
+     - description
+
+   * - 1
+
+     - none
+
+     - Start bit, always set
+
+   * - 1
+
+     - 14
+
+     - Address bit
+
+   * - 1
+
+     - none
+
+     - Toggle bit
+
+   * - 5
+
+     - 16 to 20
+
+     - Address
+
+   * - 6
+
+     - 8 to 13
+
+     - Address
+
+   * - 6
+
+     - 0 to 5
+
+     - Command
+
+
+jvc (RC_PROTO_JVC)
+------------------
+
+The jvc protocol is much like nec, without the inverted values. It is
+described here https://www.sbprojects.net/knowledge/ir/jvc.php.
+
+The scancode is a 16 bits value, where the address is the lower 8 bits
+and the command the higher 8 bits; this is reversed from IR order.
+
+sony-12 (RC_PROTO_SONY12)
+-------------------------
+
+The sony protocol is a pulse-width encoding. There are three variants,
+which just differ in number of bits and scancode encoding.
+
+.. flat-table:: sony-12 bits scancode mapping
+   :widths:       1 1 2
+
+   * - sony-12 bits
+
+     - scancode bit
+
+     - description
+
+   * - 5
+
+     - 16 to 20
+
+     - device
+
+   * - 7
+
+     - 0 to 6
+
+     - function
+
+sony-15 (RC_PROTO_SONY15)
+-------------------------
+
+The sony protocol is a pulse-width encoding. There are three variants,
+which just differ in number of bits and scancode encoding.
+
+.. flat-table:: sony-12 bits scancode mapping
+   :widths:       1 1 2
+
+   * - sony-12 bits
+
+     - scancode bit
+
+     - description
+
+   * - 8
+
+     - 16 to 23
+
+     - device
+
+   * - 7
+
+     - 0 to 6
+
+     - function
+
+sony-20 (RC_PROTO_SONY20)
+-------------------------
+
+The sony protocol is a pulse-width encoding. There are three variants,
+which just differ in number of bits and scancode encoding.
+
+.. flat-table:: sony-20 bits scancode mapping
+   :widths:       1 1 2
+
+   * - sony-20 bits
+
+     - scancode bit
+
+     - description
+
+   * - 5
+
+     - 16 to 20
+
+     - device
+
+   * - 7
+
+     - 0 to 7
+
+     - device
+
+   * - 8
+
+     - 8 to 15
+
+     - extended bits
+
+nec (RC_PROTO_NEC)
+------------------
+
+The nec protocol encodes an 8 bit address and an 8 bit command. It is
+described here https://www.sbprojects.net/knowledge/ir/nec.php. Note
+that the protocol sends least significant bit first.
+
+As a check, the nec protocol sends the address and command twice; the
+second time it is inverted. This is done for verification.
+
+A plain nec IR message has 16 bits; the high 8 bits are the address
+and the low 8 bits are the command.
+
+nec-x (RC_PROTO_NECX)
+---------------------
+
+Extended nec has a 16 bit address and a 8 bit command. This is encoded
+as a 24 bit value as you would expect, with the lower 8 bits the command
+and the upper 16 bits the address.
+
+nec-32 (RC_PROTO_NEC32)
+-----------------------
+
+nec-32 does not send an inverted address or an inverted command; the
+entire message, all 32 bits, are used.
+
+For this to be decoded correctly, the second 8 bits must not be the
+inverted value of the first, and also the last 8 bits must not be the
+inverted value of the third 8 bit value.
+
+The scancode has a somewhat unusual encoding.
+
+.. flat-table:: nec-32 bits scancode mapping
+
+   * - nec-32 bits
+
+     - scancode bit
+
+   * - First 8 bits
+
+     - 16 to 23
+
+   * - Second 8 bits
+
+     - 24 to 31
+
+   * - Third 8 bits
+
+     - 0 to 7
+
+   * - Fourth 8 bits
+
+     - 8 to 15
+
+sanyo (RC_PROTO_SANYO)
+----------------------
+
+The sanyo protocol is like the nec protocol, but with 13 bits address
+rather than 8 bits. Both the address and the command are followed by
+their inverted versions, but these are not present in the scancodes.
+
+Bis 8 to 20 of the scancode is the 13 bits address, and the lower 8
+bits are the command.
+
+mcir2-kbd (RC_PROTO_MCIR2_KBD)
+------------------------------
+
+This protocol is generated by the Microsoft MCE keyboard for keyboard
+events. Refer to the ir-mce_kbd-decoder.c to see how it is encoded.
+
+mcir2-mse (RC_PROTO_MCIR2_MSE)
+------------------------------
+
+This protocol is generated by the Microsoft MCE keyboard for pointer
+events. Refer to the ir-mce_kbd-decoder.c to see how it is encoded.
+
+rc-6-0 (RC_PROTO_RC6_0)
+-----------------------
+
+This is the rc-6 in mode 0. rc-6 is described here
+https://www.sbprojects.net/knowledge/ir/rc6.php.
+The scancode is the exact 16 bits as in the protocol. There is also a
+toggle bit.
+
+rc-6-6a-20 (RC_PROTO_RC6_6A_20)
+-------------------------------
+
+This is the rc-6 in mode 6a, 20 bits. rc-6 is described here
+https://www.sbprojects.net/knowledge/ir/rc6.php.
+The scancode is the exact 20 bits
+as in the protocol. There is also a toggle bit.
+
+rc-6-6a-24 (RC_PROTO_RC6_6A_24)
+-------------------------------
+
+This is the rc-6 in mode 6a, 24 bits. rc-6 is described here
+https://www.sbprojects.net/knowledge/ir/rc6.php.
+The scancode is the exact 24 bits
+as in the protocol. There is also a toggle bit.
+
+rc-6-6a-32 (RC_PROTO_RC6_6A_32)
+-------------------------------
+
+This is the rc-6 in mode 6a, 32 bits. rc-6 is described here
+https://www.sbprojects.net/knowledge/ir/rc6.php.
+The upper 16 bits are the vendor,
+and the lower 16 bits are the vendor-specific bits. This protocol is
+for the non-Microsoft MCE variant (vendor != 0x800f).
+
+
+rc-6-mce (RC_PROTO_RC6_MCE)
+---------------------------
+
+This is the rc-6 in mode 6a, 32 bits. The upper 16 bits are the vendor,
+and the lower 16 bits are the vendor-specific bits. This protocol is
+for the Microsoft MCE variant (vendor = 0x800f). The toggle bit in the
+protocol itself is ignored, and the 16th bit should be takes as the toggle
+bit.
+
+sharp (RC_PROTO_SHARP)
+----------------------
+
+This is a protocol used by Sharp VCRs, is described here
+https://www.sbprojects.net/knowledge/ir/sharp.php. There is a very long
+(40ms) space between the normal and inverted values, and some IR receivers
+cannot decode this.
+
+There is a 5 bit address and a 8 bit command. In the scancode the address is
+in bits 8 to 12, and the command in bits 0 to 7.
+
+xmp (RC_PROTO_XMP)
+------------------
+
+This protocol has several versions and only version 1 is supported. Refer
+to the decoder (ir-xmp-decoder.c) to see how it is encoded.
+
+
+cec (RC_PROTO_CEC)
+------------------
+
+This is not an IR protocol, this is a protocol over CEC. The CEC
+infrastructure uses rc-core for handling CEC commands, so that they
+can easily be remapped.
+
+imon (RC_PROTO_IMON)
+--------------------
+
+This protocol is used by Antec Veris/SoundGraph iMON remotes.
+
+The protocol
+describes both button presses and pointer movements. The protocol encodes
+31 bits, and the scancode is simply the 31 bits with the top bit always 0.
+
+rc-mm-12 (RC_PROTO_RCMM12)
+--------------------------
+
+The rc-mm protocol is described here
+https://www.sbprojects.net/knowledge/ir/rcmm.php. The scancode is simply
+the 12 bits.
+
+rc-mm-24 (RC_PROTO_RCMM24)
+--------------------------
+
+The rc-mm protocol is described here
+https://www.sbprojects.net/knowledge/ir/rcmm.php. The scancode is simply
+the 24 bits.
+
+rc-mm-32 (RC_PROTO_RCMM32)
+--------------------------
+
+The rc-mm protocol is described here
+https://www.sbprojects.net/knowledge/ir/rcmm.php. The scancode is simply
+the 32 bits.
+
+xbox-dvd (RC_PROTO_XBOX_DVD)
+----------------------------
+
+This protocol is used by XBox DVD Remote, which was made for the original
+XBox. There is no in-kernel decoder or encoder for this protocol. The usb
+device decodes the protocol. There is a BPF decoder available in v4l-utils.
index 3051f7abe11d3ca1f9422a1d3f45df0709f91d04..20e0f986df49ce2ab136bfaf07db62489dcb7b27 100644 (file)
@@ -27,6 +27,7 @@ Part III - Remote Controller API
 
     rc-intro
     rc-sysfs-nodes
+    rc-protos
     rc-tables
     rc-table-change
     lirc-dev
index 8f4eb8823d826b1897a44ba6b07dd24be7c4608f..ad2ff258afa89cd7e5ee3ec84027c2feac3e3069 100644 (file)
@@ -395,3 +395,13 @@ colimg
 :title:     Color Imaging: Fundamentals and Applications
 
 :author:    Erik Reinhard et al.
+
+.. _vp8:
+
+VP8
+===
+
+
+:title:     RFC 6386: "VP8 Data Format and Decoding Guide"
+
+:author:    J. Bankoski et al.
index d6ea2ffd65c5402ccdfd47b1299d56e23b4ca72b..c5f39dd5004398f60df366018de9802222cd1222 100644 (file)
@@ -2234,6 +2234,329 @@ enum v4l2_mpeg_video_h264_hierarchical_coding_type -
     Quantization parameter for a P frame for FWHT. Valid range: from 1
     to 31.
 
+.. _v4l2-mpeg-vp8:
+
+``V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER (struct)``
+    Specifies the frame parameters for the associated VP8 parsed frame data.
+    This includes the necessary parameters for
+    configuring a stateless hardware decoding pipeline for VP8.
+    The bitstream parameters are defined according to :ref:`vp8`.
+
+    .. note::
+
+       This compound control is not yet part of the public kernel API and
+       it is expected to change.
+
+.. c:type:: v4l2_ctrl_vp8_frame_header
+
+.. cssclass:: longtable
+
+.. tabularcolumns:: |p{5.8cm}|p{4.8cm}|p{6.6cm}|
+
+.. flat-table:: struct v4l2_ctrl_vp8_frame_header
+    :header-rows:  0
+    :stub-columns: 0
+    :widths:       1 1 2
+
+    * - struct :c:type:`v4l2_vp8_segment_header`
+      - ``segment_header``
+      - Structure with segment-based adjustments metadata.
+    * - struct :c:type:`v4l2_vp8_loopfilter_header`
+      - ``loopfilter_header``
+      - Structure with loop filter level adjustments metadata.
+    * - struct :c:type:`v4l2_vp8_quantization_header`
+      - ``quant_header``
+      - Structure with VP8 dequantization indices metadata.
+    * - struct :c:type:`v4l2_vp8_entropy_header`
+      - ``entropy_header``
+      - Structure with VP8 entropy coder probabilities metadata.
+    * - struct :c:type:`v4l2_vp8_entropy_coder_state`
+      - ``coder_state``
+      - Structure with VP8 entropy coder state.
+    * - __u16
+      - ``width``
+      - The width of the frame. Must be set for all frames.
+    * - __u16
+      - ``height``
+      - The height of the frame. Must be set for all frames.
+    * - __u8
+      - ``horizontal_scale``
+      - Horizontal scaling factor.
+    * - __u8
+      - ``vertical_scaling factor``
+      - Vertical scale.
+    * - __u8
+      - ``version``
+      - Bitstream version.
+    * - __u8
+      - ``prob_skip_false``
+      - Indicates the probability that the macroblock is not skipped.
+    * - __u8
+      - ``prob_intra``
+      - Indicates the probability that a macroblock is intra-predicted.
+    * - __u8
+      - ``prob_last``
+      - Indicates the probability that the last reference frame is used
+        for inter-prediction
+    * - __u8
+      - ``prob_gf``
+      - Indicates the probability that the golden reference frame is used
+        for inter-prediction
+    * - __u8
+      - ``num_dct_parts``
+      - Number of DCT coefficients partitions. Must be one of: 1, 2, 4, or 8.
+    * - __u32
+      - ``first_part_size``
+      - Size of the first partition, i.e. the control partition.
+    * - __u32
+      - ``first_part_header_bits``
+      - Size in bits of the first partition header portion.
+    * - __u32
+      - ``dct_part_sizes[8]``
+      - DCT coefficients sizes.
+    * - __u64
+      - ``last_frame_ts``
+      - Timestamp for the V4L2 capture buffer to use as last reference frame, used
+        with inter-coded frames. The timestamp refers to the ``timestamp`` field in
+       struct :c:type:`v4l2_buffer`. Use the :c:func:`v4l2_timeval_to_ns()`
+       function to convert the struct :c:type:`timeval` in struct
+       :c:type:`v4l2_buffer` to a __u64.
+    * - __u64
+      - ``golden_frame_ts``
+      - Timestamp for the V4L2 capture buffer to use as last reference frame, used
+        with inter-coded frames. The timestamp refers to the ``timestamp`` field in
+       struct :c:type:`v4l2_buffer`. Use the :c:func:`v4l2_timeval_to_ns()`
+       function to convert the struct :c:type:`timeval` in struct
+       :c:type:`v4l2_buffer` to a __u64.
+    * - __u64
+      - ``alt_frame_ts``
+      - Timestamp for the V4L2 capture buffer to use as alternate reference frame, used
+        with inter-coded frames. The timestamp refers to the ``timestamp`` field in
+       struct :c:type:`v4l2_buffer`. Use the :c:func:`v4l2_timeval_to_ns()`
+       function to convert the struct :c:type:`timeval` in struct
+       :c:type:`v4l2_buffer` to a __u64.
+    * - __u64
+      - ``flags``
+      - See :ref:`Frame Header Flags <vp8_frame_header_flags>`
+
+.. _vp8_frame_header_flags:
+
+``Frame Header Flags``
+
+.. cssclass:: longtable
+
+.. flat-table::
+    :header-rows:  0
+    :stub-columns: 0
+    :widths:       1 1 2
+
+    * - ``V4L2_VP8_FRAME_HEADER_FLAG_KEY_FRAME``
+      - 0x01
+      - Indicates if the frame is a key frame.
+    * - ``V4L2_VP8_FRAME_HEADER_FLAG_EXPERIMENTAL``
+      - 0x02
+      - Experimental bitstream.
+    * - ``V4L2_VP8_FRAME_HEADER_FLAG_SHOW_FRAME``
+      - 0x04
+      - Show frame flag, indicates if the frame is for display.
+    * - ``V4L2_VP8_FRAME_HEADER_FLAG_MB_NO_SKIP_COEFF``
+      - 0x08
+      - Enable/disable skipping of macroblocks with no non-zero coefficients.
+    * - ``V4L2_VP8_FRAME_HEADER_FLAG_SIGN_BIAS_GOLDEN``
+      - 0x10
+      - Sign of motion vectors when the golden frame is referenced.
+    * - ``V4L2_VP8_FRAME_HEADER_FLAG_SIGN_BIAS_ALT``
+      - 0x20
+      - Sign of motion vectors when the alt frame is referenced.
+
+.. c:type:: v4l2_vp8_entropy_coder_state
+
+.. cssclass:: longtable
+
+.. tabularcolumns:: |p{1.5cm}|p{6.3cm}|p{9.4cm}|
+
+.. flat-table:: struct v4l2_vp8_entropy_coder_state
+    :header-rows:  0
+    :stub-columns: 0
+    :widths:       1 1 2
+
+    * - __u8
+      - ``range``
+      -
+    * - __u8
+      - ``value``
+      -
+    * - __u8
+      - ``bit_count``
+      -
+    * - __u8
+      - ``padding``
+      - Applications and drivers must set this to zero.
+
+.. c:type:: v4l2_vp8_segment_header
+
+.. cssclass:: longtable
+
+.. tabularcolumns:: |p{1.5cm}|p{6.3cm}|p{9.4cm}|
+
+.. flat-table:: struct v4l2_vp8_segment_header
+    :header-rows:  0
+    :stub-columns: 0
+    :widths:       1 1 2
+
+    * - __s8
+      - ``quant_update[4]``
+      - Signed quantizer value update.
+    * - __s8
+      - ``lf_update[4]``
+      - Signed loop filter level value update.
+    * - __u8
+      - ``segment_probs[3]``
+      - Segment probabilities.
+    * - __u8
+      - ``padding``
+      - Applications and drivers must set this to zero.
+    * - __u32
+      - ``flags``
+      - See :ref:`Segment Header Flags <vp8_segment_header_flags>`
+
+.. _vp8_segment_header_flags:
+
+``Segment Header Flags``
+
+.. cssclass:: longtable
+
+.. flat-table::
+    :header-rows:  0
+    :stub-columns: 0
+    :widths:       1 1 2
+
+    * - ``V4L2_VP8_SEGMENT_HEADER_FLAG_ENABLED``
+      - 0x01
+      - Enable/disable segment-based adjustments.
+    * - ``V4L2_VP8_SEGMENT_HEADER_FLAG_UPDATE_MAP``
+      - 0x02
+      - Indicates if the macroblock segmentation map is updated in this frame.
+    * - ``V4L2_VP8_SEGMENT_HEADER_FLAG_UPDATE_FEATURE_DATA``
+      - 0x04
+      - Indicates if the segment feature data is updated in this frame.
+    * - ``V4L2_VP8_SEGMENT_HEADER_FLAG_DELTA_VALUE_MODE``
+      - 0x08
+      - If is set, the segment feature data mode is delta-value.
+        If cleared, it's absolute-value.
+
+.. c:type:: v4l2_vp8_loopfilter_header
+
+.. cssclass:: longtable
+
+.. tabularcolumns:: |p{1.5cm}|p{6.3cm}|p{9.4cm}|
+
+.. flat-table:: struct v4l2_vp8_loopfilter_header
+    :header-rows:  0
+    :stub-columns: 0
+    :widths:       1 1 2
+
+    * - __s8
+      - ``ref_frm_delta[4]``
+      - Reference adjustment (signed) delta value.
+    * - __s8
+      - ``mb_mode_delta[4]``
+      - Macroblock prediction mode adjustment (signed) delta value.
+    * - __u8
+      - ``sharpness_level``
+      - Sharpness level
+    * - __u8
+      - ``level``
+      - Filter level
+    * - __u16
+      - ``padding``
+      - Applications and drivers must set this to zero.
+    * - __u32
+      - ``flags``
+      - See :ref:`Loopfilter Header Flags <vp8_loopfilter_header_flags>`
+
+.. _vp8_loopfilter_header_flags:
+
+``Loopfilter Header Flags``
+
+.. cssclass:: longtable
+
+.. flat-table::
+    :header-rows:  0
+    :stub-columns: 0
+    :widths:       1 1 2
+
+    * - ``V4L2_VP8_LF_HEADER_ADJ_ENABLE``
+      - 0x01
+      - Enable/disable macroblock-level loop filter adjustment.
+    * - ``V4L2_VP8_LF_HEADER_DELTA_UPDATE``
+      - 0x02
+      - Indicates if the delta values used in an adjustment are updated.
+    * - ``V4L2_VP8_LF_FILTER_TYPE_SIMPLE``
+      - 0x04
+      - If set, indicates the filter type is simple.
+        If cleared, the filter type is normal.
+
+.. c:type:: v4l2_vp8_quantization_header
+
+.. cssclass:: longtable
+
+.. tabularcolumns:: |p{1.5cm}|p{6.3cm}|p{9.4cm}|
+
+.. flat-table:: struct v4l2_vp8_quantization_header
+    :header-rows:  0
+    :stub-columns: 0
+    :widths:       1 1 2
+
+    * - __u8
+      - ``y_ac_qi``
+      - Luma AC coefficient table index.
+    * - __s8
+      - ``y_dc_delta``
+      - Luma DC delta vaue.
+    * - __s8
+      - ``y2_dc_delta``
+      - Y2 block DC delta value.
+    * - __s8
+      - ``y2_ac_delta``
+      - Y2 block AC delta value.
+    * - __s8
+      - ``uv_dc_delta``
+      - Chroma DC delta value.
+    * - __s8
+      - ``uv_ac_delta``
+      - Chroma AC delta value.
+    * - __u16
+      - ``padding``
+      - Applications and drivers must set this to zero.
+
+.. c:type:: v4l2_vp8_entropy_header
+
+.. cssclass:: longtable
+
+.. tabularcolumns:: |p{1.5cm}|p{6.3cm}|p{9.4cm}|
+
+.. flat-table:: struct v4l2_vp8_entropy_header
+    :header-rows:  0
+    :stub-columns: 0
+    :widths:       1 1 2
+
+    * - __u8
+      - ``coeff_probs[4][8][3][11]``
+      - Coefficient update probabilities.
+    * - __u8
+      - ``y_mode_probs[4]``
+      - Luma mode update probabilities.
+    * - __u8
+      - ``uv_mode_probs[3]``
+      - Chroma mode update probabilities.
+    * - __u8
+      - ``mv_probs[2][19]``
+      - MV decoding update probabilities.
+    * - __u8
+      - ``padding[3]``
+      - Applications and drivers must set this to zero.
+
 .. raw:: latex
 
     \normalsize
index 4b701fc7653e7655937fc3e4722c5b09c9dd7338..f52a7b67023d93938a322d6d69ecbe99cb7c22b1 100644 (file)
@@ -133,6 +133,26 @@ Compressed Formats
       - ``V4L2_PIX_FMT_VP8``
       - 'VP80'
       - VP8 video elementary stream.
+    * .. _V4L2-PIX-FMT-VP8-FRAME:
+
+      - ``V4L2_PIX_FMT_VP8_FRAME``
+      - 'VP8F'
+      - VP8 parsed frame, as extracted from the container.
+       This format is adapted for stateless video decoders that implement a
+       VP8 pipeline (using the :ref:`mem2mem` and :ref:`media-request-api`).
+       Metadata associated with the frame to decode is required to be passed
+       through the ``V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER`` control.
+       See the :ref:`associated Codec Control IDs <v4l2-mpeg-vp8>`.
+       Exactly one output and one capture buffer must be provided for use with
+       this pixel format. The output buffer must contain the appropriate number
+       of macroblocks to decode a full corresponding frame to the matching
+       capture buffer.
+
+       .. note::
+
+          This format is not yet part of the public kernel API and it
+          is expected to change.
+
     * .. _V4L2-PIX-FMT-VP9:
 
       - ``V4L2_PIX_FMT_VP9``
index fe411f65c01cc03d2180c783736f20adc420ee41..1e442c97da477d5756f060d8b8f22ffb94c9c9ea 100644 (file)
@@ -41,7 +41,7 @@ data from MIPI CSI-2 camera sensor. It has one source pad, corresponding to the
 virtual channel 0. This module is compliant to previous version of Samsung
 D-phy, and supports two D-PHY Rx Data lanes.
 
-csi_mux
+csi-mux
 -------
 
 This is the video multiplexer. It has two sink pads to select from either camera
@@ -56,7 +56,7 @@ can interface directly with Parallel and MIPI CSI-2 buses. It has 256 x 64 FIFO
 to store received image pixel data and embedded DMA controllers to transfer data
 from the FIFO through AHB bus.
 
-This entity has one sink pad that receives from the csi_mux entity and a single
+This entity has one sink pad that receives from the csi-mux entity and a single
 source pad that routes video frames directly to memory buffers. This pad is
 routed to a capture device node.
 
@@ -81,14 +81,14 @@ an output of 800x600, and BGGR 10 bit bayer format:
 
    # Setup links
    media-ctl -l "'ov2680 1-0036':0 -> 'imx7-mipi-csis.0':0[1]"
-   media-ctl -l "'imx7-mipi-csis.0':1 -> 'csi_mux':1[1]"
-   media-ctl -l "'csi_mux':2 -> 'csi':0[1]"
+   media-ctl -l "'imx7-mipi-csis.0':1 -> 'csi-mux':1[1]"
+   media-ctl -l "'csi-mux':2 -> 'csi':0[1]"
    media-ctl -l "'csi':1 -> 'csi capture':0[1]"
 
    # Configure pads for pipeline
    media-ctl -V "'ov2680 1-0036':0 [fmt:SBGGR10_1X10/800x600 field:none]"
-   media-ctl -V "'csi_mux':1 [fmt:SBGGR10_1X10/800x600 field:none]"
-   media-ctl -V "'csi_mux':2 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi-mux':1 [fmt:SBGGR10_1X10/800x600 field:none]"
+   media-ctl -V "'csi-mux':2 [fmt:SBGGR10_1X10/800x600 field:none]"
    media-ctl -V "'imx7-mipi-csis.0':0 [fmt:SBGGR10_1X10/800x600 field:none]"
    media-ctl -V "'csi':0 [fmt:SBGGR10_1X10/800x600 field:none]"
 
@@ -97,64 +97,63 @@ the resolutions supported by the sensor.
 
 .. code-block:: none
 
-    root@imx7s-warp:~# media-ctl -p
-    Media controller API version 4.17.0
-
-    Media device information
-    ------------------------
-    driver          imx-media
-    model           imx-media
-    serial
-    bus info
-    hw revision     0x0
-    driver version  4.17.0
-
-    Device topology
-    - entity 1: csi (2 pads, 2 links)
-               type V4L2 subdev subtype Unknown flags 0
-               device node name /dev/v4l-subdev0
-           pad0: Sink
-                   [fmt:SBGGR10_1X10/800x600 field:none]
-                   <- "csi_mux":2 [ENABLED]
-           pad1: Source
-                   [fmt:SBGGR10_1X10/800x600 field:none]
-                   -> "csi capture":0 [ENABLED]
-
-    - entity 4: csi capture (1 pad, 1 link)
-               type Node subtype V4L flags 0
-               device node name /dev/video0
-           pad0: Sink
-                   <- "csi":1 [ENABLED]
-
-    - entity 10: csi_mux (3 pads, 2 links)
-               type V4L2 subdev subtype Unknown flags 0
-               device node name /dev/v4l-subdev1
-           pad0: Sink
-                   [fmt:unknown/0x0]
-           pad1: Sink
-                   [fmt:unknown/800x600 field:none]
-                   <- "imx7-mipi-csis.0":1 [ENABLED]
-           pad2: Source
-                   [fmt:unknown/800x600 field:none]
-                   -> "csi":0 [ENABLED]
-
-    - entity 14: imx7-mipi-csis.0 (2 pads, 2 links)
-               type V4L2 subdev subtype Unknown flags 0
-               device node name /dev/v4l-subdev2
-           pad0: Sink
-                   [fmt:SBGGR10_1X10/800x600 field:none]
-                   <- "ov2680 1-0036":0 [ENABLED]
-           pad1: Source
-                   [fmt:SBGGR10_1X10/800x600 field:none]
-                   -> "csi_mux":1 [ENABLED]
-
-    - entity 17: ov2680 1-0036 (1 pad, 1 link)
-               type V4L2 subdev subtype Sensor flags 0
-               device node name /dev/v4l-subdev3
-           pad0: Source
-                   [fmt:SBGGR10_1X10/800x600 field:none]
-                   -> "imx7-mipi-csis.0":0 [ENABLED]
-
+       # media-ctl -p
+       Media controller API version 5.2.0
+
+       Media device information
+       ------------------------
+       driver          imx7-csi
+       model           imx-media
+       serial
+       bus info
+       hw revision     0x0
+       driver version  5.2.0
+
+       Device topology
+       - entity 1: csi (2 pads, 2 links)
+                   type V4L2 subdev subtype Unknown flags 0
+                   device node name /dev/v4l-subdev0
+               pad0: Sink
+                       [fmt:SBGGR10_1X10/800x600 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:full-range]
+                       <- "csi-mux":2 [ENABLED]
+               pad1: Source
+                       [fmt:SBGGR10_1X10/800x600 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:full-range]
+                       -> "csi capture":0 [ENABLED]
+
+       - entity 4: csi capture (1 pad, 1 link)
+                   type Node subtype V4L flags 0
+                   device node name /dev/video0
+               pad0: Sink
+                       <- "csi":1 [ENABLED]
+
+       - entity 10: csi-mux (3 pads, 2 links)
+                    type V4L2 subdev subtype Unknown flags 0
+                    device node name /dev/v4l-subdev1
+               pad0: Sink
+                       [fmt:Y8_1X8/1x1 field:none]
+               pad1: Sink
+                      [fmt:SBGGR10_1X10/800x600 field:none]
+                       <- "imx7-mipi-csis.0":1 [ENABLED]
+               pad2: Source
+                       [fmt:SBGGR10_1X10/800x600 field:none]
+                       -> "csi":0 [ENABLED]
+
+       - entity 14: imx7-mipi-csis.0 (2 pads, 2 links)
+                    type V4L2 subdev subtype Unknown flags 0
+                    device node name /dev/v4l-subdev2
+               pad0: Sink
+                       [fmt:SBGGR10_1X10/800x600 field:none]
+                       <- "ov2680 1-0036":0 [ENABLED]
+               pad1: Source
+                       [fmt:SBGGR10_1X10/800x600 field:none]
+                       -> "csi-mux":1 [ENABLED]
+
+       - entity 17: ov2680 1-0036 (1 pad, 1 link)
+                    type V4L2 subdev subtype Sensor flags 0
+                    device node name /dev/v4l-subdev3
+               pad0: Source
+                       [fmt:SBGGR10_1X10/800x600@1/30 field:none colorspace:srgb]
+                       -> "imx7-mipi-csis.0":0 [ENABLED]
 
 References
 ----------
index 4628b12d417fc83d4c23ecbb5f45b0fe7e532e1b..406417680db557af626e1d92a1eb377246d74386 100644 (file)
@@ -15,7 +15,7 @@ recompile the driver to achieve your own topology. This is the default topology:
 .. _vimc_topology_graph:
 
 .. kernel-figure:: vimc.dot
-    :alt:   vimc.dot
+    :alt:   Diagram of the default media pipeline topology
     :align: center
 
     Media pipeline graph on vimc
@@ -96,3 +96,14 @@ those arguments to each subdevice, not to the vimc module. For example::
         Window size to calculate the mean. Note: the window size needs to be an
         odd number, as the main pixel stays in the center of the window,
         otherwise the next odd number is considered (the default value is 3).
+
+Source code documentation
+-------------------------
+
+vimc-streamer
+~~~~~~~~~~~~~
+
+.. kernel-doc:: drivers/media/platform/vimc/vimc-streamer.h
+   :internal:
+
+.. kernel-doc:: drivers/media/platform/vimc/vimc-streamer.c
index 55cbe324b9fc71cee89ad5a31456ea1ef47ace15..8e7d3492d24861388e06a04924461cedb21536fb 100644 (file)
@@ -181,14 +181,14 @@ replace define V4L2_PIX_FMT_FLAG_PREMUL_ALPHA reserved-formats
 replace define V4L2_FMT_FLAG_COMPRESSED fmtdesc-flags
 replace define V4L2_FMT_FLAG_EMULATED fmtdesc-flags
 
-# V4L2 tymecode types
+# V4L2 timecode types
 replace define V4L2_TC_TYPE_24FPS timecode-type
 replace define V4L2_TC_TYPE_25FPS timecode-type
 replace define V4L2_TC_TYPE_30FPS timecode-type
 replace define V4L2_TC_TYPE_50FPS timecode-type
 replace define V4L2_TC_TYPE_60FPS timecode-type
 
-# V4L2 tymecode flags
+# V4L2 timecode flags
 replace define V4L2_TC_FLAG_DROPFRAME timecode-flags
 replace define V4L2_TC_FLAG_COLORFRAME timecode-flags
 replace define V4L2_TC_USERBITS_field timecode-flags
index cc0d08dad1419978d0919baa1e1140be5c321644..5a2e198e7db103843b3fc159f14f7a1b160b587d 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/clk.h>
+#include <linux/dma-mapping.h>
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/of.h>
@@ -43,11 +44,17 @@ static struct resource omap_vout_resource[2] = {
 };
 #endif
 
+static u64 omap_vout_dma_mask = DMA_BIT_MASK(32);
+
 static struct platform_device omap_vout_device = {
        .name           = "omap_vout",
        .num_resources  = ARRAY_SIZE(omap_vout_resource),
        .resource       = &omap_vout_resource[0],
        .id             = -1,
+       .dev            = {
+               .dma_mask               = &omap_vout_dma_mask,
+               .coherent_dma_mask      = DMA_BIT_MASK(32),
+       },
 };
 
 int __init omap_init_vout(void)
index 00cb1ba2d364398551421878d74a06c92a168bc3..3fd3e862269bdc8010568ea9b24a04ab2b14c4f3 100644 (file)
@@ -186,7 +186,7 @@ static const struct v4l2_pix_format sur40_pix_format[] = {
                .width  = SENSOR_RES_X / 2,
                .height = SENSOR_RES_Y / 2,
                .field = V4L2_FIELD_NONE,
-               .colorspace = V4L2_COLORSPACE_SRGB,
+               .colorspace = V4L2_COLORSPACE_RAW,
                .bytesperline = SENSOR_RES_X / 2,
                .sizeimage = (SENSOR_RES_X/2) * (SENSOR_RES_Y/2),
        },
@@ -195,7 +195,7 @@ static const struct v4l2_pix_format sur40_pix_format[] = {
                .width  = SENSOR_RES_X / 2,
                .height = SENSOR_RES_Y / 2,
                .field = V4L2_FIELD_NONE,
-               .colorspace = V4L2_COLORSPACE_SRGB,
+               .colorspace = V4L2_COLORSPACE_RAW,
                .bytesperline = SENSOR_RES_X / 2,
                .sizeimage = (SENSOR_RES_X/2) * (SENSOR_RES_Y/2),
        }
index 21cd9c02960b8b96496b739159dac0c9a16a4e44..8404e80aa38eeab741e78bd7ef0cdbe4f1743fb9 100644 (file)
@@ -190,7 +190,7 @@ config MEDIA_SUBDRV_AUTOSELECT
        depends on HAS_IOMEM
        select I2C
        select I2C_MUX
-       default y
+       default y if !EMBEDDED
        help
          By default, a media driver auto-selects all possible ancillary
          devices such as tuners, sensors, video encoders/decoders and
index 4c399a42e874c2157975e89c3f95884d9597b9e2..d16122039b0c87b39388597d74baaad616289f8a 100644 (file)
@@ -20,62 +20,52 @@ MODULE_PARM_DESC(max_memory, "maximum memory usage for capture buffers (default:
 /* format descriptions for capture and preview */
 static struct saa7146_format formats[] = {
        {
-               .name           = "RGB-8 (3-3-2)",
                .pixelformat    = V4L2_PIX_FMT_RGB332,
                .trans          = RGB08_COMPOSED,
                .depth          = 8,
                .flags          = 0,
        }, {
-               .name           = "RGB-16 (5/B-6/G-5/R)",
                .pixelformat    = V4L2_PIX_FMT_RGB565,
                .trans          = RGB16_COMPOSED,
                .depth          = 16,
                .flags          = 0,
        }, {
-               .name           = "RGB-24 (B-G-R)",
                .pixelformat    = V4L2_PIX_FMT_BGR24,
                .trans          = RGB24_COMPOSED,
                .depth          = 24,
                .flags          = 0,
        }, {
-               .name           = "RGB-32 (B-G-R)",
                .pixelformat    = V4L2_PIX_FMT_BGR32,
                .trans          = RGB32_COMPOSED,
                .depth          = 32,
                .flags          = 0,
        }, {
-               .name           = "RGB-32 (R-G-B)",
                .pixelformat    = V4L2_PIX_FMT_RGB32,
                .trans          = RGB32_COMPOSED,
                .depth          = 32,
                .flags          = 0,
                .swap           = 0x2,
        }, {
-               .name           = "Greyscale-8",
                .pixelformat    = V4L2_PIX_FMT_GREY,
                .trans          = Y8,
                .depth          = 8,
                .flags          = 0,
        }, {
-               .name           = "YUV 4:2:2 planar (Y-Cb-Cr)",
                .pixelformat    = V4L2_PIX_FMT_YUV422P,
                .trans          = YUV422_DECOMPOSED,
                .depth          = 16,
                .flags          = FORMAT_BYTE_SWAP|FORMAT_IS_PLANAR,
        }, {
-               .name           = "YVU 4:2:0 planar (Y-Cb-Cr)",
                .pixelformat    = V4L2_PIX_FMT_YVU420,
                .trans          = YUV420_DECOMPOSED,
                .depth          = 12,
                .flags          = FORMAT_BYTE_SWAP|FORMAT_IS_PLANAR,
        }, {
-               .name           = "YUV 4:2:0 planar (Y-Cb-Cr)",
                .pixelformat    = V4L2_PIX_FMT_YUV420,
                .trans          = YUV420_DECOMPOSED,
                .depth          = 12,
                .flags          = FORMAT_IS_PLANAR,
        }, {
-               .name           = "YUV 4:2:2 (U-Y-V-Y)",
                .pixelformat    = V4L2_PIX_FMT_UYVY,
                .trans          = YUV422_COMPOSED,
                .depth          = 16,
@@ -147,10 +137,10 @@ int saa7146_start_preview(struct saa7146_fh *fh)
        }
        vv->ov.win = fmt.fmt.win;
 
-       DEB_D("%dx%d+%d+%d %s field=%s\n",
+       DEB_D("%dx%d+%d+%d 0x%08x field=%s\n",
              vv->ov.win.w.width, vv->ov.win.w.height,
              vv->ov.win.w.left, vv->ov.win.w.top,
-             vv->ov_fmt->name, v4l2_field_names[vv->ov.win.field]);
+             vv->ov_fmt->pixelformat, v4l2_field_names[vv->ov.win.field]);
 
        if (0 != (ret = saa7146_enable_overlay(fh))) {
                DEB_D("enabling overlay failed: %d\n", ret);
@@ -515,8 +505,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtd
 {
        if (f->index >= ARRAY_SIZE(formats))
                return -EINVAL;
-       strscpy((char *)f->description, formats[f->index].name,
-               sizeof(f->description));
        f->pixelformat = formats[f->index].pixelformat;
        return 0;
 }
index 07e0629af8ed2968d97c56ac63d7c43ca80c8235..50f1e0b28b250d8f20a1c689da5c7263b32117d8 100644 (file)
@@ -217,9 +217,21 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
        case V4L2_PIX_FMT_RGB444:
        case V4L2_PIX_FMT_XRGB444:
        case V4L2_PIX_FMT_ARGB444:
+       case V4L2_PIX_FMT_RGBX444:
+       case V4L2_PIX_FMT_RGBA444:
+       case V4L2_PIX_FMT_XBGR444:
+       case V4L2_PIX_FMT_ABGR444:
+       case V4L2_PIX_FMT_BGRX444:
+       case V4L2_PIX_FMT_BGRA444:
        case V4L2_PIX_FMT_RGB555:
        case V4L2_PIX_FMT_XRGB555:
        case V4L2_PIX_FMT_ARGB555:
+       case V4L2_PIX_FMT_RGBX555:
+       case V4L2_PIX_FMT_RGBA555:
+       case V4L2_PIX_FMT_XBGR555:
+       case V4L2_PIX_FMT_ABGR555:
+       case V4L2_PIX_FMT_BGRX555:
+       case V4L2_PIX_FMT_BGRA555:
        case V4L2_PIX_FMT_RGB555X:
        case V4L2_PIX_FMT_XRGB555X:
        case V4L2_PIX_FMT_ARGB555X:
@@ -232,6 +244,10 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
        case V4L2_PIX_FMT_XBGR32:
        case V4L2_PIX_FMT_ARGB32:
        case V4L2_PIX_FMT_ABGR32:
+       case V4L2_PIX_FMT_RGBX32:
+       case V4L2_PIX_FMT_BGRX32:
+       case V4L2_PIX_FMT_RGBA32:
+       case V4L2_PIX_FMT_BGRA32:
                tpg->color_enc = TGP_COLOR_ENC_RGB;
                break;
        case V4L2_PIX_FMT_GREY:
@@ -343,9 +359,21 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
        case V4L2_PIX_FMT_RGB444:
        case V4L2_PIX_FMT_XRGB444:
        case V4L2_PIX_FMT_ARGB444:
+       case V4L2_PIX_FMT_RGBX444:
+       case V4L2_PIX_FMT_RGBA444:
+       case V4L2_PIX_FMT_XBGR444:
+       case V4L2_PIX_FMT_ABGR444:
+       case V4L2_PIX_FMT_BGRX444:
+       case V4L2_PIX_FMT_BGRA444:
        case V4L2_PIX_FMT_RGB555:
        case V4L2_PIX_FMT_XRGB555:
        case V4L2_PIX_FMT_ARGB555:
+       case V4L2_PIX_FMT_RGBX555:
+       case V4L2_PIX_FMT_RGBA555:
+       case V4L2_PIX_FMT_XBGR555:
+       case V4L2_PIX_FMT_ABGR555:
+       case V4L2_PIX_FMT_BGRX555:
+       case V4L2_PIX_FMT_BGRA555:
        case V4L2_PIX_FMT_RGB555X:
        case V4L2_PIX_FMT_XRGB555X:
        case V4L2_PIX_FMT_ARGB555X:
@@ -375,6 +403,10 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
        case V4L2_PIX_FMT_XBGR32:
        case V4L2_PIX_FMT_ARGB32:
        case V4L2_PIX_FMT_ABGR32:
+       case V4L2_PIX_FMT_RGBX32:
+       case V4L2_PIX_FMT_BGRX32:
+       case V4L2_PIX_FMT_RGBA32:
+       case V4L2_PIX_FMT_BGRA32:
        case V4L2_PIX_FMT_YUV32:
        case V4L2_PIX_FMT_AYUV32:
        case V4L2_PIX_FMT_XYUV32:
@@ -1007,6 +1039,12 @@ static void precalculate_color(struct tpg_data *tpg, int k)
                case V4L2_PIX_FMT_RGB444:
                case V4L2_PIX_FMT_XRGB444:
                case V4L2_PIX_FMT_ARGB444:
+               case V4L2_PIX_FMT_RGBX444:
+               case V4L2_PIX_FMT_RGBA444:
+               case V4L2_PIX_FMT_XBGR444:
+               case V4L2_PIX_FMT_ABGR444:
+               case V4L2_PIX_FMT_BGRX444:
+               case V4L2_PIX_FMT_BGRA444:
                        r >>= 8;
                        g >>= 8;
                        b >>= 8;
@@ -1014,6 +1052,12 @@ static void precalculate_color(struct tpg_data *tpg, int k)
                case V4L2_PIX_FMT_RGB555:
                case V4L2_PIX_FMT_XRGB555:
                case V4L2_PIX_FMT_ARGB555:
+               case V4L2_PIX_FMT_RGBX555:
+               case V4L2_PIX_FMT_RGBA555:
+               case V4L2_PIX_FMT_XBGR555:
+               case V4L2_PIX_FMT_ABGR555:
+               case V4L2_PIX_FMT_BGRX555:
+               case V4L2_PIX_FMT_BGRA555:
                case V4L2_PIX_FMT_RGB555X:
                case V4L2_PIX_FMT_XRGB555X:
                case V4L2_PIX_FMT_ARGB555X:
@@ -1237,6 +1281,27 @@ static void gen_twopix(struct tpg_data *tpg,
                buf[0][offset] = (g_u_s << 4) | b_v;
                buf[0][offset + 1] = (alpha & 0xf0) | r_y_h;
                break;
+       case V4L2_PIX_FMT_RGBX444:
+               alpha = 0;
+               /* fall through */
+       case V4L2_PIX_FMT_RGBA444:
+               buf[0][offset] = (b_v << 4) | (alpha >> 4);
+               buf[0][offset + 1] = (r_y_h << 4) | g_u_s;
+               break;
+       case V4L2_PIX_FMT_XBGR444:
+               alpha = 0;
+               /* fall through */
+       case V4L2_PIX_FMT_ABGR444:
+               buf[0][offset] = (g_u_s << 4) | r_y_h;
+               buf[0][offset + 1] = (alpha & 0xf0) | b_v;
+               break;
+       case V4L2_PIX_FMT_BGRX444:
+               alpha = 0;
+               /* fall through */
+       case V4L2_PIX_FMT_BGRA444:
+               buf[0][offset] = (r_y_h << 4) | (alpha >> 4);
+               buf[0][offset + 1] = (b_v << 4) | g_u_s;
+               break;
        case V4L2_PIX_FMT_RGB555:
        case V4L2_PIX_FMT_XRGB555:
                alpha = 0;
@@ -1247,6 +1312,30 @@ static void gen_twopix(struct tpg_data *tpg,
                buf[0][offset + 1] = (alpha & 0x80) | (r_y_h << 2)
                                                    | (g_u_s >> 3);
                break;
+       case V4L2_PIX_FMT_RGBX555:
+               alpha = 0;
+               /* fall through */
+       case V4L2_PIX_FMT_RGBA555:
+               buf[0][offset] = (g_u_s << 6) | (b_v << 1) |
+                                ((alpha & 0x80) >> 7);
+               buf[0][offset + 1] = (r_y_h << 3) | (g_u_s >> 2);
+               break;
+       case V4L2_PIX_FMT_XBGR555:
+               alpha = 0;
+               /* fall through */
+       case V4L2_PIX_FMT_ABGR555:
+               buf[0][offset] = (g_u_s << 5) | r_y_h;
+               buf[0][offset + 1] = (alpha & 0x80) | (b_v << 2)
+                                                   | (g_u_s >> 3);
+               break;
+       case V4L2_PIX_FMT_BGRX555:
+               alpha = 0;
+               /* fall through */
+       case V4L2_PIX_FMT_BGRA555:
+               buf[0][offset] = (g_u_s << 6) | (r_y_h << 1) |
+                                ((alpha & 0x80) >> 7);
+               buf[0][offset + 1] = (b_v << 3) | (g_u_s >> 2);
+               break;
        case V4L2_PIX_FMT_RGB555X:
        case V4L2_PIX_FMT_XRGB555X:
                alpha = 0;
@@ -1286,6 +1375,15 @@ static void gen_twopix(struct tpg_data *tpg,
                buf[0][offset + 2] = g_u_s;
                buf[0][offset + 3] = b_v;
                break;
+       case V4L2_PIX_FMT_RGBX32:
+               alpha = 0;
+               /* fall through */
+       case V4L2_PIX_FMT_RGBA32:
+               buf[0][offset] = r_y_h;
+               buf[0][offset + 1] = g_u_s;
+               buf[0][offset + 2] = b_v;
+               buf[0][offset + 3] = alpha;
+               break;
        case V4L2_PIX_FMT_BGR32:
        case V4L2_PIX_FMT_XBGR32:
        case V4L2_PIX_FMT_VUYX32:
@@ -1298,6 +1396,15 @@ static void gen_twopix(struct tpg_data *tpg,
                buf[0][offset + 2] = r_y_h;
                buf[0][offset + 3] = alpha;
                break;
+       case V4L2_PIX_FMT_BGRX32:
+               alpha = 0;
+               /* fall through */
+       case V4L2_PIX_FMT_BGRA32:
+               buf[0][offset] = alpha;
+               buf[0][offset + 1] = b_v;
+               buf[0][offset + 2] = g_u_s;
+               buf[0][offset + 3] = r_y_h;
+               break;
        case V4L2_PIX_FMT_SBGGR8:
                buf[0][offset] = odd ? g_u_s : b_v;
                buf[1][offset] = odd ? r_y_h : g_u_s;
index 7d77e4d30c8ab987b6a35529968a2afb5505eabd..44cd0e530bbd3030b18dcf729406bad1a53b5a7e 100644 (file)
@@ -267,8 +267,14 @@ static void vb2_dc_dmabuf_ops_detach(struct dma_buf *dbuf,
 
        /* release the scatterlist cache */
        if (attach->dma_dir != DMA_NONE)
-               dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
-                       attach->dma_dir);
+               /*
+                * Cache sync can be skipped here, as the vb2_dc memory is
+                * allocated from device coherent memory, which means the
+                * memory locations do not require any explicit cache
+                * maintenance prior or after being used by the device.
+                */
+               dma_unmap_sg_attrs(db_attach->dev, sgt->sgl, sgt->orig_nents,
+                                  attach->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
        sg_free_table(sgt);
        kfree(attach);
        db_attach->priv = NULL;
@@ -293,14 +299,17 @@ static struct sg_table *vb2_dc_dmabuf_ops_map(
 
        /* release any previous cache */
        if (attach->dma_dir != DMA_NONE) {
-               dma_unmap_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
-                       attach->dma_dir);
+               dma_unmap_sg_attrs(db_attach->dev, sgt->sgl, sgt->orig_nents,
+                                  attach->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
                attach->dma_dir = DMA_NONE;
        }
 
-       /* mapping to the client with new direction */
-       sgt->nents = dma_map_sg(db_attach->dev, sgt->sgl, sgt->orig_nents,
-                               dma_dir);
+       /*
+        * mapping to the client with new direction, no cache sync
+        * required see comment in vb2_dc_dmabuf_ops_detach()
+        */
+       sgt->nents = dma_map_sg_attrs(db_attach->dev, sgt->sgl, sgt->orig_nents,
+                                     dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
        if (!sgt->nents) {
                pr_err("failed to map scatterlist\n");
                mutex_unlock(lock);
index 40d76eb4c2fe79b4ff8e46675284afcd7afa9e86..5a9ba3846f0a5a2630ddbe55e8dc1fa3ea75d078 100644 (file)
@@ -872,17 +872,19 @@ EXPORT_SYMBOL_GPL(vb2_queue_release);
 __poll_t vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
 {
        struct video_device *vfd = video_devdata(file);
-       __poll_t res = 0;
+       __poll_t res;
+
+       res = vb2_core_poll(q, file, wait);
 
        if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
                struct v4l2_fh *fh = file->private_data;
 
                poll_wait(file, &fh->wait, wait);
                if (v4l2_event_pending(fh))
-                       res = EPOLLPRI;
+                       res |= EPOLLPRI;
        }
 
-       return res | vb2_core_poll(q, file, wait);
+       return res;
 }
 EXPORT_SYMBOL_GPL(vb2_poll);
 
index 209186c5cd9b920efe79534290d6be00100436f4..06ea30a689d758e5888951817546ecccd689e5fa 100644 (file)
@@ -152,6 +152,9 @@ static void dvb_frontend_free(struct kref *ref)
 
 static void dvb_frontend_put(struct dvb_frontend *fe)
 {
+       /* call detach before dropping the reference count */
+       if (fe->ops.detach)
+               fe->ops.detach(fe);
        /*
         * Check if the frontend was registered, as otherwise
         * kref was not initialized yet.
@@ -3040,7 +3043,6 @@ void dvb_frontend_detach(struct dvb_frontend *fe)
        dvb_frontend_invoke_release(fe, fe->ops.release_sec);
        dvb_frontend_invoke_release(fe, fe->ops.tuner_ops.release);
        dvb_frontend_invoke_release(fe, fe->ops.analog_ops.release);
-       dvb_frontend_invoke_release(fe, fe->ops.detach);
        dvb_frontend_put(fe);
 }
 EXPORT_SYMBOL(dvb_frontend_detach);
index e05c21d35dc82179c730b24bbaadb1a427515eba..60d1e59d22921643bf1abdafc90a1e459656029b 100644 (file)
@@ -81,11 +81,9 @@ struct rtl2832_sdr_format {
 
 static struct rtl2832_sdr_format formats[] = {
        {
-               .name           = "Complex U8",
                .pixelformat    = V4L2_SDR_FMT_CU8,
                .buffersize     = BULK_BUFFER_SIZE,
        }, {
-               .name           = "Complex U16LE (emulated)",
                .pixelformat    = V4L2_SDR_FMT_CU16LE,
                .buffersize     = BULK_BUFFER_SIZE * 2,
        },
@@ -1116,7 +1114,6 @@ static int rtl2832_sdr_enum_fmt_sdr_cap(struct file *file, void *priv,
        if (f->index >= dev->num_formats)
                return -EINVAL;
 
-       strscpy(f->description, formats[f->index].name, sizeof(f->description));
        f->pixelformat = formats[f->index].pixelformat;
 
        return 0;
index 168c503e9154f97d41642562ffe3a93aea5561c0..a574f1d77c56451ed7eafc44775aefe2cbf9a177 100644 (file)
@@ -82,8 +82,19 @@ static int si2168_ts_bus_ctrl(struct dvb_frontend *fe, int acquire)
 
        dev_dbg(&client->dev, "%s acquire: %d\n", __func__, acquire);
 
+       /* set manual value */
+       if (dev->ts_mode & SI2168_TS_CLK_MANUAL) {
+               memcpy(cmd.args, "\x14\x00\x0d\x10\xe8\x03", 6);
+               cmd.wlen = 6;
+               cmd.rlen = 4;
+               ret = si2168_cmd_execute(client, &cmd);
+               if (ret)
+                       return ret;
+       }
        /* set TS_MODE property */
        memcpy(cmd.args, "\x14\x00\x01\x10\x10\x00", 6);
+       if (dev->ts_mode & SI2168_TS_CLK_MANUAL)
+               cmd.args[4] = SI2168_TS_CLK_MANUAL;
        if (acquire)
                cmd.args[4] |= dev->ts_mode;
        else
index 3b04f84272d9dcc28bf5803c00dbe2d8943c1e62..50dccb394efa646537ec2982ad10de1e2319e0a5 100644 (file)
@@ -30,6 +30,7 @@ struct si2168_config {
 #define SI2168_TS_PARALLEL     0x06
 #define SI2168_TS_SERIAL       0x03
 #define SI2168_TS_TRISTATE     0x00
+#define SI2168_TS_CLK_MANUAL   0x20
        u8 ts_mode;
 
        /* TS clock inverted */
index 2ad6bdf1a9fce5f1b28271efc175d400b61927f4..45cc5a4c2de56b6de23c5889a18f350586eba829 100644 (file)
@@ -1980,14 +1980,14 @@ static int adv7511_remove(struct i2c_client *client)
 /* ----------------------------------------------------------------------- */
 
 static const struct i2c_device_id adv7511_id[] = {
-       { "adv7511", 0 },
+       { "adv7511-v4l2", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, adv7511_id);
 
 static struct i2c_driver adv7511_driver = {
        .driver = {
-               .name = "adv7511",
+               .name = "adv7511-v4l2",
        },
        .probe = adv7511_probe,
        .remove = adv7511_remove,
index 876d7587a1daa8a6bf84d196637e0b7aa9f56ded..96932779ca3725c08e0a55b2e946ec5aa1f93b80 100644 (file)
@@ -916,16 +916,13 @@ static int ir_remove(struct i2c_client *client)
 {
        struct IR_i2c *ir = i2c_get_clientdata(client);
 
-       /* kill outstanding polls */
        cancel_delayed_work_sync(&ir->work);
 
        if (ir->tx_c)
                i2c_unregister_device(ir->tx_c);
 
-       /* unregister device */
        rc_unregister_device(ir->rc);
 
-       /* free memory */
        return 0;
 }
 
index 12cb012d91f71160c911d5dcc216dcfb8c3b3317..3e01d1b86a252ddec63bb8ca36cee0c86b7782a5 100644 (file)
@@ -533,7 +533,7 @@ static int mt9m111_get_fmt(struct v4l2_subdev *sd,
                format->format = *mf;
                return 0;
 #else
-               return -ENOTTY;
+               return -EINVAL;
 #endif
        }
 
index ecd167d7c4d265234292f395f4138f2c9e037a6d..8fd17661dd78c917560b9c043cbe41542d82b703 100644 (file)
@@ -929,7 +929,7 @@ static int ov2640_get_fmt(struct v4l2_subdev *sd,
                format->format = *mf;
                return 0;
 #else
-               return -ENOTTY;
+               return -EINVAL;
 #endif
        }
 
index 5ed2413eac8a1ebb817cf644f4a3008e7df1faf5..a71277e361ffd43baae82611b873feaa87f149c0 100644 (file)
@@ -1055,7 +1055,7 @@ static int ov2659_get_fmt(struct v4l2_subdev *sd,
                mutex_unlock(&ov2659->lock);
                return 0;
 #else
-       return -ENOTTY;
+               return -EINVAL;
 #endif
        }
 
@@ -1131,8 +1131,6 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
                mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
                *mf = fmt->format;
-#else
-               ret = -ENOTTY;
 #endif
        } else {
                s64 val;
index b10bcfabaeeb05a2bc21283408b4f00062b7d116..59cdbc33658ce69edd7b2cece66e9905730e8b97 100644 (file)
@@ -675,7 +675,7 @@ static int ov2680_get_fmt(struct v4l2_subdev *sd,
 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
                fmt = v4l2_subdev_get_try_format(&sensor->sd, cfg, format->pad);
 #else
-               ret = -ENOTTY;
+               ret = -EINVAL;
 #endif
        } else {
                fmt = &sensor->fmt;
@@ -723,10 +723,7 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd,
 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
                try_fmt = v4l2_subdev_get_try_format(sd, cfg, 0);
                format->format = *try_fmt;
-#else
-               ret = -ENOTTY;
 #endif
-
                goto unlock;
        }
 
@@ -1023,7 +1020,7 @@ static int ov2680_check_id(struct ov2680_dev *sensor)
        return 0;
 }
 
-static int ov2860_parse_dt(struct ov2680_dev *sensor)
+static int ov2680_parse_dt(struct ov2680_dev *sensor)
 {
        struct device *dev = ov2680_to_dev(sensor);
        int ret;
@@ -1064,7 +1061,7 @@ static int ov2680_probe(struct i2c_client *client)
 
        sensor->i2c_client = client;
 
-       ret = ov2860_parse_dt(sensor);
+       ret = ov2680_parse_dt(sensor);
        if (ret < 0)
                return -EINVAL;
 
index 759d60c6d6304b9e894c84839925efad7b3d56fc..4cd246812ae22cf599213b7d476b8cfc87e6e1a7 100644 (file)
@@ -158,8 +158,8 @@ static const int ov5640_framerates[] = {
 /* regulator supplies */
 static const char * const ov5640_supply_name[] = {
        "DOVDD", /* Digital I/O (1.8V) supply */
-       "DVDD",  /* Digital Core (1.5V) supply */
        "AVDD",  /* Analog (2.8V) supply */
+       "DVDD",  /* Digital Core (1.5V) supply */
 };
 
 #define OV5640_NUM_SUPPLIES ARRAY_SIZE(ov5640_supply_name)
@@ -3022,9 +3022,14 @@ static int ov5640_probe(struct i2c_client *client,
        /* request optional power down pin */
        sensor->pwdn_gpio = devm_gpiod_get_optional(dev, "powerdown",
                                                    GPIOD_OUT_HIGH);
+       if (IS_ERR(sensor->pwdn_gpio))
+               return PTR_ERR(sensor->pwdn_gpio);
+
        /* request optional reset pin */
        sensor->reset_gpio = devm_gpiod_get_optional(dev, "reset",
                                                     GPIOD_OUT_HIGH);
+       if (IS_ERR(sensor->reset_gpio))
+               return PTR_ERR(sensor->reset_gpio);
 
        v4l2_i2c_subdev_init(&sensor->sd, client, &ov5640_subdev_ops);
 
index 124c8df04633752fc951a7b99c54004b18236b35..9602b9201b3e9e8b622a6713793aff0b8ebbedf9 100644 (file)
 #include <media/v4l2-fwnode.h>
 #include <media/v4l2-subdev.h>
 
-#define OV5645_VOLTAGE_ANALOG               2800000
-#define OV5645_VOLTAGE_DIGITAL_CORE         1500000
-#define OV5645_VOLTAGE_DIGITAL_IO           1800000
-
 #define OV5645_SYSTEM_CTRL0            0x3008
 #define                OV5645_SYSTEM_CTRL0_START       0x02
 #define                OV5645_SYSTEM_CTRL0_STOP        0x42
 #define OV5645_SDE_SAT_U               0x5583
 #define OV5645_SDE_SAT_V               0x5584
 
+/* regulator supplies */
+static const char * const ov5645_supply_name[] = {
+       "vdddo", /* Digital I/O (1.8V) supply */
+       "vdda",  /* Analog (2.8V) supply */
+       "vddd",  /* Digital Core (1.5V) supply */
+};
+
+#define OV5645_NUM_SUPPLIES ARRAY_SIZE(ov5645_supply_name)
+
 struct reg_value {
        u16 reg;
        u8 val;
@@ -86,9 +91,7 @@ struct ov5645 {
        struct v4l2_rect crop;
        struct clk *xclk;
 
-       struct regulator *io_regulator;
-       struct regulator *core_regulator;
-       struct regulator *analog_regulator;
+       struct regulator_bulk_data supplies[OV5645_NUM_SUPPLIES];
 
        const struct ov5645_mode_info *current_mode;
 
@@ -533,55 +536,6 @@ static const struct ov5645_mode_info ov5645_mode_info_data[] = {
        },
 };
 
-static int ov5645_regulators_enable(struct ov5645 *ov5645)
-{
-       int ret;
-
-       ret = regulator_enable(ov5645->io_regulator);
-       if (ret < 0) {
-               dev_err(ov5645->dev, "set io voltage failed\n");
-               return ret;
-       }
-
-       ret = regulator_enable(ov5645->analog_regulator);
-       if (ret) {
-               dev_err(ov5645->dev, "set analog voltage failed\n");
-               goto err_disable_io;
-       }
-
-       ret = regulator_enable(ov5645->core_regulator);
-       if (ret) {
-               dev_err(ov5645->dev, "set core voltage failed\n");
-               goto err_disable_analog;
-       }
-
-       return 0;
-
-err_disable_analog:
-       regulator_disable(ov5645->analog_regulator);
-err_disable_io:
-       regulator_disable(ov5645->io_regulator);
-
-       return ret;
-}
-
-static void ov5645_regulators_disable(struct ov5645 *ov5645)
-{
-       int ret;
-
-       ret = regulator_disable(ov5645->core_regulator);
-       if (ret < 0)
-               dev_err(ov5645->dev, "core regulator disable failed\n");
-
-       ret = regulator_disable(ov5645->analog_regulator);
-       if (ret < 0)
-               dev_err(ov5645->dev, "analog regulator disable failed\n");
-
-       ret = regulator_disable(ov5645->io_regulator);
-       if (ret < 0)
-               dev_err(ov5645->dev, "io regulator disable failed\n");
-}
-
 static int ov5645_write_reg(struct ov5645 *ov5645, u16 reg, u8 val)
 {
        u8 regbuf[3];
@@ -680,15 +634,14 @@ static int ov5645_set_power_on(struct ov5645 *ov5645)
 {
        int ret;
 
-       ret = ov5645_regulators_enable(ov5645);
-       if (ret < 0) {
+       ret = regulator_bulk_enable(OV5645_NUM_SUPPLIES, ov5645->supplies);
+       if (ret < 0)
                return ret;
-       }
 
        ret = clk_prepare_enable(ov5645->xclk);
        if (ret < 0) {
                dev_err(ov5645->dev, "clk prepare enable failed\n");
-               ov5645_regulators_disable(ov5645);
+               regulator_bulk_disable(OV5645_NUM_SUPPLIES, ov5645->supplies);
                return ret;
        }
 
@@ -708,7 +661,7 @@ static void ov5645_set_power_off(struct ov5645 *ov5645)
        gpiod_set_value_cansleep(ov5645->rst_gpio, 1);
        gpiod_set_value_cansleep(ov5645->enable_gpio, 0);
        clk_disable_unprepare(ov5645->xclk);
-       ov5645_regulators_disable(ov5645);
+       regulator_bulk_disable(OV5645_NUM_SUPPLIES, ov5645->supplies);
 }
 
 static int ov5645_s_power(struct v4l2_subdev *sd, int on)
@@ -1093,6 +1046,7 @@ static int ov5645_probe(struct i2c_client *client,
        struct device_node *endpoint;
        struct ov5645 *ov5645;
        u8 chip_id_high, chip_id_low;
+       unsigned int i;
        u32 xclk_freq;
        int ret;
 
@@ -1150,47 +1104,13 @@ static int ov5645_probe(struct i2c_client *client,
                return ret;
        }
 
-       ov5645->io_regulator = devm_regulator_get(dev, "vdddo");
-       if (IS_ERR(ov5645->io_regulator)) {
-               dev_err(dev, "cannot get io regulator\n");
-               return PTR_ERR(ov5645->io_regulator);
-       }
-
-       ret = regulator_set_voltage(ov5645->io_regulator,
-                                   OV5645_VOLTAGE_DIGITAL_IO,
-                                   OV5645_VOLTAGE_DIGITAL_IO);
-       if (ret < 0) {
-               dev_err(dev, "cannot set io voltage\n");
-               return ret;
-       }
-
-       ov5645->core_regulator = devm_regulator_get(dev, "vddd");
-       if (IS_ERR(ov5645->core_regulator)) {
-               dev_err(dev, "cannot get core regulator\n");
-               return PTR_ERR(ov5645->core_regulator);
-       }
+       for (i = 0; i < OV5645_NUM_SUPPLIES; i++)
+               ov5645->supplies[i].supply = ov5645_supply_name[i];
 
-       ret = regulator_set_voltage(ov5645->core_regulator,
-                                   OV5645_VOLTAGE_DIGITAL_CORE,
-                                   OV5645_VOLTAGE_DIGITAL_CORE);
-       if (ret < 0) {
-               dev_err(dev, "cannot set core voltage\n");
-               return ret;
-       }
-
-       ov5645->analog_regulator = devm_regulator_get(dev, "vdda");
-       if (IS_ERR(ov5645->analog_regulator)) {
-               dev_err(dev, "cannot get analog regulator\n");
-               return PTR_ERR(ov5645->analog_regulator);
-       }
-
-       ret = regulator_set_voltage(ov5645->analog_regulator,
-                                   OV5645_VOLTAGE_ANALOG,
-                                   OV5645_VOLTAGE_ANALOG);
-       if (ret < 0) {
-               dev_err(dev, "cannot set analog voltage\n");
+       ret = devm_regulator_bulk_get(dev, OV5645_NUM_SUPPLIES,
+                                     ov5645->supplies);
+       if (ret < 0)
                return ret;
-       }
 
        ov5645->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH);
        if (IS_ERR(ov5645->enable_gpio)) {
index e65a94353175d26f06ee5f25702aa4274e1d74df..34b7046d970215b6242220e56a0cf38fd8eec8e8 100644 (file)
@@ -823,9 +823,6 @@ static int ov5695_set_fmt(struct v4l2_subdev *sd,
        if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
                *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format;
-#else
-               mutex_unlock(&ov5695->mutex);
-               return -ENOTTY;
 #endif
        } else {
                ov5695->cur_mode = mode;
@@ -856,7 +853,7 @@ static int ov5695_get_fmt(struct v4l2_subdev *sd,
                fmt->format = *v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
 #else
                mutex_unlock(&ov5695->mutex);
-               return -ENOTTY;
+               return -EINVAL;
 #endif
        } else {
                fmt->format.width = mode->width;
index 53385c2777923a6b2b71263732c0132ba05d330d..b42b289faaef4cfdd82b57a4db59316df61d2056 100644 (file)
@@ -1110,10 +1110,8 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
                mbus_fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
                *mbus_fmt = format->format;
-               return 0;
-#else
-               return -ENOTTY;
 #endif
+               return 0;
        }
 
        ret = ov7670_try_fmt_internal(sd, &format->format, &info->fmt, &info->wsize);
@@ -1146,7 +1144,7 @@ static int ov7670_get_fmt(struct v4l2_subdev *sd,
                format->format = *mbus_fmt;
                return 0;
 #else
-               return -ENOTTY;
+               return -EINVAL;
 #endif
        } else {
                format->format = info->format;
index 70bb870b1d08767f38af63c6948642a95f670586..a2f8f19bca7c472056f8b6753fc2edfed4f5d0d1 100644 (file)
@@ -827,13 +827,9 @@ static int ov7740_set_fmt(struct v4l2_subdev *sd,
 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
                mbus_fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
                *mbus_fmt = format->format;
-
+#endif
                mutex_unlock(&ov7740->mutex);
                return 0;
-#else
-               ret = -ENOTTY;
-               goto error;
-#endif
        }
 
        ret = ov7740_try_fmt_internal(sd, &format->format, &ovfmt, &fsize);
@@ -868,7 +864,7 @@ static int ov7740_get_fmt(struct v4l2_subdev *sd,
                format->format = *mbus_fmt;
                ret = 0;
 #else
-               ret = -ENOTTY;
+               ret = -EINVAL;
 #endif
        } else {
                format->format = ov7740->format;
index 612d1c0010c19a5047f2021eed45c2713f6c9549..a359da7773a9052e07da0c48fa727e58beb2a5c7 100644 (file)
@@ -503,77 +503,65 @@ static const unsigned int BTTV_TVNORMS = ARRAY_SIZE(bttv_tvnorms);
    packed pixel formats must come first */
 static const struct bttv_format formats[] = {
        {
-               .name     = "8 bpp, gray",
                .fourcc   = V4L2_PIX_FMT_GREY,
                .btformat = BT848_COLOR_FMT_Y8,
                .depth    = 8,
                .flags    = FORMAT_FLAGS_PACKED,
        },{
-               .name     = "8 bpp, dithered color",
                .fourcc   = V4L2_PIX_FMT_HI240,
                .btformat = BT848_COLOR_FMT_RGB8,
                .depth    = 8,
                .flags    = FORMAT_FLAGS_PACKED | FORMAT_FLAGS_DITHER,
        },{
-               .name     = "15 bpp RGB, le",
                .fourcc   = V4L2_PIX_FMT_RGB555,
                .btformat = BT848_COLOR_FMT_RGB15,
                .depth    = 16,
                .flags    = FORMAT_FLAGS_PACKED,
        },{
-               .name     = "15 bpp RGB, be",
                .fourcc   = V4L2_PIX_FMT_RGB555X,
                .btformat = BT848_COLOR_FMT_RGB15,
                .btswap   = 0x03, /* byteswap */
                .depth    = 16,
                .flags    = FORMAT_FLAGS_PACKED,
        },{
-               .name     = "16 bpp RGB, le",
                .fourcc   = V4L2_PIX_FMT_RGB565,
                .btformat = BT848_COLOR_FMT_RGB16,
                .depth    = 16,
                .flags    = FORMAT_FLAGS_PACKED,
        },{
-               .name     = "16 bpp RGB, be",
                .fourcc   = V4L2_PIX_FMT_RGB565X,
                .btformat = BT848_COLOR_FMT_RGB16,
                .btswap   = 0x03, /* byteswap */
                .depth    = 16,
                .flags    = FORMAT_FLAGS_PACKED,
        },{
-               .name     = "24 bpp RGB, le",
                .fourcc   = V4L2_PIX_FMT_BGR24,
                .btformat = BT848_COLOR_FMT_RGB24,
                .depth    = 24,
                .flags    = FORMAT_FLAGS_PACKED,
        },{
-               .name     = "32 bpp RGB, le",
                .fourcc   = V4L2_PIX_FMT_BGR32,
                .btformat = BT848_COLOR_FMT_RGB32,
                .depth    = 32,
                .flags    = FORMAT_FLAGS_PACKED,
        },{
-               .name     = "32 bpp RGB, be",
                .fourcc   = V4L2_PIX_FMT_RGB32,
                .btformat = BT848_COLOR_FMT_RGB32,
                .btswap   = 0x0f, /* byte+word swap */
                .depth    = 32,
                .flags    = FORMAT_FLAGS_PACKED,
        },{
-               .name     = "4:2:2, packed, YUYV",
                .fourcc   = V4L2_PIX_FMT_YUYV,
                .btformat = BT848_COLOR_FMT_YUY2,
                .depth    = 16,
                .flags    = FORMAT_FLAGS_PACKED,
        },{
-               .name     = "4:2:2, packed, UYVY",
                .fourcc   = V4L2_PIX_FMT_UYVY,
                .btformat = BT848_COLOR_FMT_YUY2,
                .btswap   = 0x03, /* byteswap */
                .depth    = 16,
                .flags    = FORMAT_FLAGS_PACKED,
        },{
-               .name     = "4:2:2, planar, Y-Cb-Cr",
                .fourcc   = V4L2_PIX_FMT_YUV422P,
                .btformat = BT848_COLOR_FMT_YCrCb422,
                .depth    = 16,
@@ -581,7 +569,6 @@ static const struct bttv_format formats[] = {
                .hshift   = 1,
                .vshift   = 0,
        },{
-               .name     = "4:2:0, planar, Y-Cb-Cr",
                .fourcc   = V4L2_PIX_FMT_YUV420,
                .btformat = BT848_COLOR_FMT_YCrCb422,
                .depth    = 12,
@@ -589,7 +576,6 @@ static const struct bttv_format formats[] = {
                .hshift   = 1,
                .vshift   = 1,
        },{
-               .name     = "4:2:0, planar, Y-Cr-Cb",
                .fourcc   = V4L2_PIX_FMT_YVU420,
                .btformat = BT848_COLOR_FMT_YCrCb422,
                .depth    = 12,
@@ -597,7 +583,6 @@ static const struct bttv_format formats[] = {
                .hshift   = 1,
                .vshift   = 1,
        },{
-               .name     = "4:1:1, planar, Y-Cb-Cr",
                .fourcc   = V4L2_PIX_FMT_YUV411P,
                .btformat = BT848_COLOR_FMT_YCrCb411,
                .depth    = 12,
@@ -605,7 +590,6 @@ static const struct bttv_format formats[] = {
                .hshift   = 2,
                .vshift   = 0,
        },{
-               .name     = "4:1:0, planar, Y-Cb-Cr",
                .fourcc   = V4L2_PIX_FMT_YUV410,
                .btformat = BT848_COLOR_FMT_YCrCb411,
                .depth    = 9,
@@ -613,7 +597,6 @@ static const struct bttv_format formats[] = {
                .hshift   = 2,
                .vshift   = 2,
        },{
-               .name     = "4:1:0, planar, Y-Cr-Cb",
                .fourcc   = V4L2_PIX_FMT_YVU410,
                .btformat = BT848_COLOR_FMT_YCrCb411,
                .depth    = 9,
@@ -621,7 +604,6 @@ static const struct bttv_format formats[] = {
                .hshift   = 2,
                .vshift   = 2,
        },{
-               .name     = "raw scanlines",
                .fourcc   = -1,
                .btformat = BT848_COLOR_FMT_RAW,
                .depth    = 8,
@@ -2500,7 +2482,6 @@ static int bttv_enum_fmt_cap_ovr(struct v4l2_fmtdesc *f)
                return -EINVAL;
 
        f->pixelformat = formats[i].fourcc;
-       strscpy(f->description, formats[i].name, sizeof(f->description));
 
        return i;
 }
index 6b59ca337c7f5da2c1593ec63a34df5907c2ca3c..fc8708047be8658e4f7b2f15bfb8173e175449e5 100644 (file)
@@ -699,9 +699,9 @@ bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf)
        const struct bttv_tvnorm *tvnorm = bttv_tvnorms + buf->tvnorm;
        struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
 
-       dprintk("%d: buffer field: %s  format: %s  size: %dx%d\n",
+       dprintk("%d: buffer field: %s  format: 0x%08x  size: %dx%d\n",
                btv->c.nr, v4l2_field_names[buf->vb.field],
-               buf->fmt->name, buf->vb.width, buf->vb.height);
+               buf->fmt->fourcc, buf->vb.width, buf->vb.height);
 
        /* packed pixel modes */
        if (buf->fmt->flags & FORMAT_FLAGS_PACKED) {
@@ -860,9 +860,9 @@ bttv_overlay_risc(struct bttv *btv,
                  struct bttv_buffer *buf)
 {
        /* check interleave, bottom+top fields */
-       dprintk("%d: overlay fields: %s format: %s  size: %dx%d\n",
+       dprintk("%d: overlay fields: %s format: 0x%08x  size: %dx%d\n",
                btv->c.nr, v4l2_field_names[buf->vb.field],
-               fmt->name, ov->w.width, ov->w.height);
+               fmt->fourcc, ov->w.width, ov->w.height);
 
        /* calculate geometry */
        bttv_calc_geo(btv,&buf->geo,ov->w.width,ov->w.height,
index b159d6ddbfcfd243c044f80fa57eae7e43684d48..4abf436578465fcd6194b9d59065989f53097ff7 100644 (file)
@@ -99,7 +99,6 @@ struct bttv_tvnorm {
 extern const struct bttv_tvnorm bttv_tvnorms[];
 
 struct bttv_format {
-       char *name;
        int  fourcc;          /* video4linux 2      */
        int  btformat;        /* BT848_COLOR_FMT_*  */
        int  btswap;          /* BT848_COLOR_CTL_*  */
index 4885e833c05227999cfcb00266c88917c765472b..0695078ef81252c37eb12fa966d1c91d627279b5 100644 (file)
@@ -186,20 +186,16 @@ void cobalt_pcie_status_show(struct cobalt *cobalt)
 {
        struct pci_dev *pci_dev = cobalt->pci_dev;
        struct pci_dev *pci_bus_dev = cobalt->pci_dev->bus->self;
-       int offset;
-       int bus_offset;
        u32 capa;
        u16 stat, ctrl;
 
-       offset = pci_find_capability(pci_dev, PCI_CAP_ID_EXP);
-       bus_offset = pci_find_capability(pci_bus_dev, PCI_CAP_ID_EXP);
-       if (!offset || !bus_offset)
+       if (!pci_is_pcie(pci_dev) || !pci_is_pcie(pci_bus_dev))
                return;
 
        /* Device */
-       pci_read_config_dword(pci_dev, offset + PCI_EXP_DEVCAP, &capa);
-       pci_read_config_word(pci_dev, offset + PCI_EXP_DEVCTL, &ctrl);
-       pci_read_config_word(pci_dev, offset + PCI_EXP_DEVSTA, &stat);
+       pcie_capability_read_dword(pci_dev, PCI_EXP_DEVCAP, &capa);
+       pcie_capability_read_word(pci_dev, PCI_EXP_DEVCTL, &ctrl);
+       pcie_capability_read_word(pci_dev, PCI_EXP_DEVSTA, &stat);
        cobalt_info("PCIe device capability 0x%08x: Max payload %d\n",
                    capa, get_payload_size(capa & PCI_EXP_DEVCAP_PAYLOAD));
        cobalt_info("PCIe device control 0x%04x: Max payload %d. Max read request %d\n",
@@ -209,9 +205,9 @@ void cobalt_pcie_status_show(struct cobalt *cobalt)
        cobalt_info("PCIe device status 0x%04x\n", stat);
 
        /* Link */
-       pci_read_config_dword(pci_dev, offset + PCI_EXP_LNKCAP, &capa);
-       pci_read_config_word(pci_dev, offset + PCI_EXP_LNKCTL, &ctrl);
-       pci_read_config_word(pci_dev, offset + PCI_EXP_LNKSTA, &stat);
+       pcie_capability_read_dword(pci_dev, PCI_EXP_LNKCAP, &capa);
+       pcie_capability_read_word(pci_dev, PCI_EXP_LNKCTL, &ctrl);
+       pcie_capability_read_word(pci_dev, PCI_EXP_LNKSTA, &stat);
        cobalt_info("PCIe link capability 0x%08x: %s per lane and %u lanes\n",
                        capa, get_link_speed(capa),
                        (capa & PCI_EXP_LNKCAP_MLW) >> 4);
@@ -221,15 +217,15 @@ void cobalt_pcie_status_show(struct cobalt *cobalt)
                    (stat & PCI_EXP_LNKSTA_NLW) >> 4);
 
        /* Bus */
-       pci_read_config_dword(pci_bus_dev, bus_offset + PCI_EXP_LNKCAP, &capa);
+       pcie_capability_read_dword(pci_bus_dev, PCI_EXP_LNKCAP, &capa);
        cobalt_info("PCIe bus link capability 0x%08x: %s per lane and %u lanes\n",
                        capa, get_link_speed(capa),
                        (capa & PCI_EXP_LNKCAP_MLW) >> 4);
 
        /* Slot */
-       pci_read_config_dword(pci_dev, offset + PCI_EXP_SLTCAP, &capa);
-       pci_read_config_word(pci_dev, offset + PCI_EXP_SLTCTL, &ctrl);
-       pci_read_config_word(pci_dev, offset + PCI_EXP_SLTSTA, &stat);
+       pcie_capability_read_dword(pci_dev, PCI_EXP_SLTCAP, &capa);
+       pcie_capability_read_word(pci_dev, PCI_EXP_SLTCTL, &ctrl);
+       pcie_capability_read_word(pci_dev, PCI_EXP_SLTSTA, &stat);
        cobalt_info("PCIe slot capability 0x%08x\n", capa);
        cobalt_info("PCIe slot control 0x%04x\n", ctrl);
        cobalt_info("PCIe slot status 0x%04x\n", stat);
@@ -238,26 +234,22 @@ void cobalt_pcie_status_show(struct cobalt *cobalt)
 static unsigned pcie_link_get_lanes(struct cobalt *cobalt)
 {
        struct pci_dev *pci_dev = cobalt->pci_dev;
-       unsigned offset;
        u16 link;
 
-       offset = pci_find_capability(pci_dev, PCI_CAP_ID_EXP);
-       if (!offset)
+       if (!pci_is_pcie(pci_dev))
                return 0;
-       pci_read_config_word(pci_dev, offset + PCI_EXP_LNKSTA, &link);
+       pcie_capability_read_word(pci_dev, PCI_EXP_LNKSTA, &link);
        return (link & PCI_EXP_LNKSTA_NLW) >> 4;
 }
 
 static unsigned pcie_bus_link_get_lanes(struct cobalt *cobalt)
 {
        struct pci_dev *pci_dev = cobalt->pci_dev->bus->self;
-       unsigned offset;
        u32 link;
 
-       offset = pci_find_capability(pci_dev, PCI_CAP_ID_EXP);
-       if (!offset)
+       if (!pci_is_pcie(pci_dev))
                return 0;
-       pci_read_config_dword(pci_dev, offset + PCI_EXP_LNKCAP, &link);
+       pcie_capability_read_dword(pci_dev, PCI_EXP_LNKCAP, &link);
        return (link & PCI_EXP_LNKCAP_MLW) >> 4;
 }
 
@@ -592,7 +584,7 @@ static int cobalt_subdevs_hsma_init(struct cobalt *cobalt)
                .cec_clk = 12000000,
        };
        static struct i2c_board_info adv7511_info = {
-               .type = "adv7511",
+               .type = "adv7511-v4l2",
                .addr = 0x39, /* 0x39 or 0x3d */
                .platform_data = &adv7511_pdata,
        };
index ef96e0f956d22fdb19b2ae0ae479e586d839070c..1d3c64b4cf6d0c2dfe4f8a75fb040ccee8ebebf3 100644 (file)
@@ -69,7 +69,7 @@ static void flash_copy_to(struct map_info *map, unsigned long to,
 
        pr_info("%s: offset 0x%x: length %zu\n", __func__, dest, len);
        while (len) {
-               u16 data = 0xffff;
+               u16 data;
 
                do {
                        data = *src << (8 * (dest & 1));
index 39dabd4da60fd2f9bac4f558846602a92380cb78..c5207501d5e03cf7ae1bf44309f8ffd74ef60f5e 100644 (file)
@@ -688,15 +688,12 @@ static int cobalt_enum_fmt_vid_cap(struct file *file, void *priv_fh,
 {
        switch (f->index) {
        case 0:
-               strscpy(f->description, "YUV 4:2:2", sizeof(f->description));
                f->pixelformat = V4L2_PIX_FMT_YUYV;
                break;
        case 1:
-               strscpy(f->description, "RGB24", sizeof(f->description));
                f->pixelformat = V4L2_PIX_FMT_RGB24;
                break;
        case 2:
-               strscpy(f->description, "RGB32", sizeof(f->description));
                f->pixelformat = V4L2_PIX_FMT_BGR32;
                break;
        default:
@@ -788,7 +785,6 @@ static int cobalt_try_fmt_vid_cap(struct file *file, void *priv_fh,
 
        pix->sizeimage = pix->bytesperline * pix->height;
        pix->field = V4L2_FIELD_NONE;
-       pix->priv = 0;
 
        return 0;
 }
@@ -893,11 +889,9 @@ static int cobalt_enum_fmt_vid_out(struct file *file, void *priv_fh,
 {
        switch (f->index) {
        case 0:
-               strscpy(f->description, "YUV 4:2:2", sizeof(f->description));
                f->pixelformat = V4L2_PIX_FMT_YUYV;
                break;
        case 1:
-               strscpy(f->description, "RGB32", sizeof(f->description));
                f->pixelformat = V4L2_PIX_FMT_BGR32;
                break;
        default:
index 82f96a4091aca56084d005a5e5d3b72a3dd1009a..2327fe6126102e2975a6b5ee87e582dadd1a34a1 100644 (file)
@@ -1339,7 +1339,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
        if (f->index != 0)
                return -EINVAL;
 
-       strscpy(f->description, "MPEG", sizeof(f->description));
        f->pixelformat = V4L2_PIX_FMT_MPEG;
 
        return 0;
index b254473db9a3849725bd31f69b947df5542ec277..8098b15493de92756d90e71c27f7d8a43d75c4a6 100644 (file)
@@ -67,7 +67,6 @@ MODULE_PARM_DESC(vid_limit, "capture memory limit in megabytes");
 #define FORMAT_FLAGS_PACKED       0x01
 static struct cx23885_fmt formats[] = {
        {
-               .name     = "4:2:2, packed, YUYV",
                .fourcc   = V4L2_PIX_FMT_YUYV,
                .depth    = 16,
                .flags    = FORMAT_FLAGS_PACKED,
@@ -411,9 +410,9 @@ static int buffer_prepare(struct vb2_buffer *vb)
        default:
                BUG();
        }
-       dprintk(2, "[%p/%d] buffer_init - %dx%d %dbpp \"%s\" - dma=0x%08lx\n",
+       dprintk(2, "[%p/%d] buffer_init - %dx%d %dbpp 0x%08x - dma=0x%08lx\n",
                buf, buf->vb.vb2_buf.index,
-               dev->width, dev->height, dev->fmt->depth, dev->fmt->name,
+               dev->width, dev->height, dev->fmt->depth, dev->fmt->fourcc,
                (unsigned long)buf->risc.dma);
        return 0;
 }
@@ -647,8 +646,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
        if (unlikely(f->index >= ARRAY_SIZE(formats)))
                return -EINVAL;
 
-       strscpy(f->description, formats[f->index].name,
-               sizeof(f->description));
        f->pixelformat = formats[f->index].fourcc;
 
        return 0;
index 9da66fdd5a0d3ee5c4ed59af20b8152a0389e50f..a95a2e4c6a0d3f6bb94b62fbcf40966c0745441b 100644 (file)
        V4L2_STD_PAL_60 |  V4L2_STD_SECAM_L   |  V4L2_STD_SECAM_DK)
 
 struct cx23885_fmt {
-       char  *name;
        u32   fourcc;          /* v4l2 format id */
        int   depth;
        int   flags;
index de76411704782f8b0630262bb887bfd710d0f775..a10261da0db6eec3ec734dee547cc4be987d99a7 100644 (file)
@@ -35,12 +35,10 @@ MODULE_PARM_DESC(irq_debug, "enable debug messages [IRQ handler]");
 
 static const struct cx25821_fmt formats[] = {
        {
-               .name = "4:1:1, packed, Y41P",
                .fourcc = V4L2_PIX_FMT_Y41P,
                .depth = 12,
                .flags = FORMAT_FLAGS_PACKED,
        }, {
-               .name = "4:2:2, packed, YUYV",
                .fourcc = V4L2_PIX_FMT_YUYV,
                .depth = 16,
                .flags = FORMAT_FLAGS_PACKED,
@@ -215,9 +213,9 @@ static int cx25821_buffer_prepare(struct vb2_buffer *vb)
                break;
        }
 
-       dprintk(2, "[%p/%d] buffer_prep - %dx%d %dbpp \"%s\" - dma=0x%08lx\n",
+       dprintk(2, "[%p/%d] buffer_prep - %dx%d %dbpp 0x%08x - dma=0x%08lx\n",
                buf, buf->vb.vb2_buf.index, chan->width, chan->height,
-               chan->fmt->depth, chan->fmt->name,
+               chan->fmt->depth, chan->fmt->fourcc,
                (unsigned long)buf->risc.dma);
 
        return ret;
@@ -311,7 +309,6 @@ static int cx25821_vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
        if (unlikely(f->index >= ARRAY_SIZE(formats)))
                return -EINVAL;
 
-       strscpy(f->description, formats[f->index].name, sizeof(f->description));
        f->pixelformat = formats[f->index].fourcc;
 
        return 0;
index 47dbaae78509d89a81a64d380b2a7ba4679cddf1..017307984094ef0469a7488053f4a6c69fe2bfef 100644 (file)
@@ -83,7 +83,6 @@
 #define VID_CHANNEL_NUM 8
 
 struct cx25821_fmt {
-       char *name;
        u32 fourcc;             /* v4l2 format id */
        int depth;
        int flags;
index 200d688270738d9f1f9954c86dcfbebc67d550ab..d3da7f4297af8220ba9703fda996b9be1e1823a6 100644 (file)
@@ -805,9 +805,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
        if (f->index != 0)
                return -EINVAL;
 
-       strscpy(f->description, "MPEG", sizeof(f->description));
        f->pixelformat = V4L2_PIX_FMT_MPEG;
-       f->flags = V4L2_FMT_FLAG_COMPRESSED;
        return 0;
 }
 
index e59a74514c7c8c26456776876ae99594076243a7..dcc0f02aeb70ca05b9b15031f86641896176285b 100644 (file)
@@ -69,62 +69,52 @@ MODULE_PARM_DESC(irq_debug, "enable debug messages [IRQ handler]");
 
 static const struct cx8800_fmt formats[] = {
        {
-               .name     = "8 bpp, gray",
                .fourcc   = V4L2_PIX_FMT_GREY,
                .cxformat = ColorFormatY8,
                .depth    = 8,
                .flags    = FORMAT_FLAGS_PACKED,
        }, {
-               .name     = "15 bpp RGB, le",
                .fourcc   = V4L2_PIX_FMT_RGB555,
                .cxformat = ColorFormatRGB15,
                .depth    = 16,
                .flags    = FORMAT_FLAGS_PACKED,
        }, {
-               .name     = "15 bpp RGB, be",
                .fourcc   = V4L2_PIX_FMT_RGB555X,
                .cxformat = ColorFormatRGB15 | ColorFormatBSWAP,
                .depth    = 16,
                .flags    = FORMAT_FLAGS_PACKED,
        }, {
-               .name     = "16 bpp RGB, le",
                .fourcc   = V4L2_PIX_FMT_RGB565,
                .cxformat = ColorFormatRGB16,
                .depth    = 16,
                .flags    = FORMAT_FLAGS_PACKED,
        }, {
-               .name     = "16 bpp RGB, be",
                .fourcc   = V4L2_PIX_FMT_RGB565X,
                .cxformat = ColorFormatRGB16 | ColorFormatBSWAP,
                .depth    = 16,
                .flags    = FORMAT_FLAGS_PACKED,
        }, {
-               .name     = "24 bpp RGB, le",
                .fourcc   = V4L2_PIX_FMT_BGR24,
                .cxformat = ColorFormatRGB24,
                .depth    = 24,
                .flags    = FORMAT_FLAGS_PACKED,
        }, {
-               .name     = "32 bpp RGB, le",
                .fourcc   = V4L2_PIX_FMT_BGR32,
                .cxformat = ColorFormatRGB32,
                .depth    = 32,
                .flags    = FORMAT_FLAGS_PACKED,
        }, {
-               .name     = "32 bpp RGB, be",
                .fourcc   = V4L2_PIX_FMT_RGB32,
                .cxformat = ColorFormatRGB32 | ColorFormatBSWAP |
                            ColorFormatWSWAP,
                .depth    = 32,
                .flags    = FORMAT_FLAGS_PACKED,
        }, {
-               .name     = "4:2:2, packed, YUYV",
                .fourcc   = V4L2_PIX_FMT_YUYV,
                .cxformat = ColorFormatYUY2,
                .depth    = 16,
                .flags    = FORMAT_FLAGS_PACKED,
        }, {
-               .name     = "4:2:2, packed, UYVY",
                .fourcc   = V4L2_PIX_FMT_UYVY,
                .cxformat = ColorFormatYUY2 | ColorFormatBSWAP,
                .depth    = 16,
@@ -489,9 +479,9 @@ static int buffer_prepare(struct vb2_buffer *vb)
                break;
        }
        dprintk(2,
-               "[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n",
-               buf, buf->vb.vb2_buf.index,
-               core->width, core->height, dev->fmt->depth, dev->fmt->name,
+               "[%p/%d] %s - %dx%d %dbpp 0x%08x - dma=0x%08lx\n",
+               buf, buf->vb.vb2_buf.index, __func__,
+               core->width, core->height, dev->fmt->depth, dev->fmt->fourcc,
                (unsigned long)buf->risc.dma);
        return 0;
 }
@@ -829,7 +819,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
        if (unlikely(f->index >= ARRAY_SIZE(formats)))
                return -EINVAL;
 
-       strscpy(f->description, formats[f->index].name, sizeof(f->description));
        f->pixelformat = formats[f->index].fourcc;
 
        return 0;
index a70a50dc3edf24ebb0efe7115e8c47fa1a0c9018..744a22328ebc9bd6f45863e9fc8551767aaaf2f6 100644 (file)
@@ -99,7 +99,6 @@ static inline unsigned int norm_maxh(v4l2_std_id norm)
 /* static data                                                 */
 
 struct cx8800_fmt {
-       const char  *name;
        u32   fourcc;          /* v4l2 format id */
        int   depth;
        int   flags;
index b4cdda50e742984d4d74093be751ea2121dc50da..7480f0d3ad0fa32b83700dc84d5b5cc895c2bbc7 100644 (file)
@@ -306,7 +306,6 @@ static int dt3155_enum_fmt_vid_cap(struct file *filp,
        if (f->index)
                return -EINVAL;
        f->pixelformat = V4L2_PIX_FMT_GREY;
-       strscpy(f->description, "8-bit Greyscale", sizeof(f->description));
        return 0;
 }
 
index c1d133e17e4b8bfc794784f1b828845f4ca154df..1adfdc7ab0dbb57760c9d5d5605346abf1fd50ca 100644 (file)
@@ -1475,57 +1475,66 @@ static const struct v4l2_async_notifier_operations cio2_async_ops = {
        .complete = cio2_notifier_complete,
 };
 
-static int cio2_fwnode_parse(struct device *dev,
-                            struct v4l2_fwnode_endpoint *vep,
-                            struct v4l2_async_subdev *asd)
+static int cio2_parse_firmware(struct cio2_device *cio2)
 {
-       struct sensor_async_subdev *s_asd =
-                       container_of(asd, struct sensor_async_subdev, asd);
+       unsigned int i;
+       int ret;
 
-       if (vep->bus_type != V4L2_MBUS_CSI2_DPHY) {
-               dev_err(dev, "Only CSI2 bus type is currently supported\n");
-               return -EINVAL;
-       }
+       for (i = 0; i < CIO2_NUM_PORTS; i++) {
+               struct v4l2_fwnode_endpoint vep = {
+                       .bus_type = V4L2_MBUS_CSI2_DPHY
+               };
+               struct sensor_async_subdev *s_asd = NULL;
+               struct fwnode_handle *ep;
 
-       s_asd->csi2.port = vep->base.port;
-       s_asd->csi2.lanes = vep->bus.mipi_csi2.num_data_lanes;
+               ep = fwnode_graph_get_endpoint_by_id(
+                       dev_fwnode(&cio2->pci_dev->dev), i, 0,
+                       FWNODE_GRAPH_ENDPOINT_NEXT);
 
-       return 0;
-}
+               if (!ep)
+                       continue;
 
-static int cio2_notifier_init(struct cio2_device *cio2)
-{
-       int ret;
+               ret = v4l2_fwnode_endpoint_parse(ep, &vep);
+               if (ret)
+                       goto err_parse;
 
-       v4l2_async_notifier_init(&cio2->notifier);
+               s_asd = kzalloc(sizeof(*s_asd), GFP_KERNEL);
+               if (!s_asd) {
+                       ret = -ENOMEM;
+                       goto err_parse;
+               }
 
-       ret = v4l2_async_notifier_parse_fwnode_endpoints(
-               &cio2->pci_dev->dev, &cio2->notifier,
-               sizeof(struct sensor_async_subdev),
-               cio2_fwnode_parse);
-       if (ret < 0)
-               return ret;
+               s_asd->csi2.port = vep.base.port;
+               s_asd->csi2.lanes = vep.bus.mipi_csi2.num_data_lanes;
 
-       if (list_empty(&cio2->notifier.asd_list))
-               return -ENODEV; /* no endpoint */
+               ret = v4l2_async_notifier_add_fwnode_remote_subdev(
+                       &cio2->notifier, ep, &s_asd->asd);
+               if (ret)
+                       goto err_parse;
+
+               fwnode_handle_put(ep);
+
+               continue;
 
+err_parse:
+               fwnode_handle_put(ep);
+               kfree(s_asd);
+               return ret;
+       }
+
+       /*
+        * Proceed even without sensors connected to allow the device to
+        * suspend.
+        */
        cio2->notifier.ops = &cio2_async_ops;
        ret = v4l2_async_notifier_register(&cio2->v4l2_dev, &cio2->notifier);
-       if (ret) {
+       if (ret)
                dev_err(&cio2->pci_dev->dev,
                        "failed to register async notifier : %d\n", ret);
-               v4l2_async_notifier_cleanup(&cio2->notifier);
-       }
 
        return ret;
 }
 
-static void cio2_notifier_exit(struct cio2_device *cio2)
-{
-       v4l2_async_notifier_unregister(&cio2->notifier);
-       v4l2_async_notifier_cleanup(&cio2->notifier);
-}
-
 /**************** Queue initialization ****************/
 static const struct media_entity_operations cio2_media_ops = {
        .link_validate = v4l2_subdev_link_validate,
@@ -1809,17 +1818,18 @@ static int cio2_pci_probe(struct pci_dev *pci_dev,
        if (r)
                goto fail_v4l2_device_unregister;
 
+       v4l2_async_notifier_init(&cio2->notifier);
+
        /* Register notifier for subdevices we care */
-       r = cio2_notifier_init(cio2);
-       /* Proceed without sensors connected to allow the device to suspend. */
-       if (r && r != -ENODEV)
-               goto fail_cio2_queue_exit;
+       r = cio2_parse_firmware(cio2);
+       if (r)
+               goto fail_clean_notifier;
 
        r = devm_request_irq(&pci_dev->dev, pci_dev->irq, cio2_irq,
                             IRQF_SHARED, CIO2_NAME, cio2);
        if (r) {
                dev_err(&pci_dev->dev, "failed to request IRQ (%d)\n", r);
-               goto fail;
+               goto fail_clean_notifier;
        }
 
        pm_runtime_put_noidle(&pci_dev->dev);
@@ -1827,9 +1837,9 @@ static int cio2_pci_probe(struct pci_dev *pci_dev,
 
        return 0;
 
-fail:
-       cio2_notifier_exit(cio2);
-fail_cio2_queue_exit:
+fail_clean_notifier:
+       v4l2_async_notifier_unregister(&cio2->notifier);
+       v4l2_async_notifier_cleanup(&cio2->notifier);
        cio2_queues_exit(cio2);
 fail_v4l2_device_unregister:
        v4l2_device_unregister(&cio2->v4l2_dev);
@@ -1848,7 +1858,8 @@ static void cio2_pci_remove(struct pci_dev *pci_dev)
        struct cio2_device *cio2 = pci_get_drvdata(pci_dev);
 
        media_device_unregister(&cio2->media_dev);
-       cio2_notifier_exit(cio2);
+       v4l2_async_notifier_unregister(&cio2->notifier);
+       v4l2_async_notifier_cleanup(&cio2->notifier);
        cio2_queues_exit(cio2);
        cio2_fbpt_exit_dummy(cio2);
        v4l2_device_unregister(&cio2->v4l2_dev);
@@ -2000,8 +2011,7 @@ static int __maybe_unused cio2_suspend(struct device *dev)
 
 static int __maybe_unused cio2_resume(struct device *dev)
 {
-       struct pci_dev *pci_dev = to_pci_dev(dev);
-       struct cio2_device *cio2 = pci_get_drvdata(pci_dev);
+       struct cio2_device *cio2 = dev_get_drvdata(dev);
        int r = 0;
        struct cio2_queue *q = cio2->cur_queue;
 
index 8218810c899eca193490c85fcd1ab458ea49618b..0e61c81356ef5b52c1945c24d8bdc4c1f6b54acd 100644 (file)
@@ -1104,12 +1104,9 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *fh,
        if (f->index == 0) {
                /* standard YUV 422 capture */
                f->flags = 0;
-               strscpy(f->description, "YUV422", sizeof(f->description));
                f->pixelformat = V4L2_PIX_FMT_YUYV;
        } else {
                /* compressed MJPEG capture */
-               f->flags = V4L2_FMT_FLAG_COMPRESSED;
-               strscpy(f->description, "MJPEG", sizeof(f->description));
                f->pixelformat = V4L2_PIX_FMT_MJPEG;
        }
 
index e51c80bc4646fca81080b8436219b8744b702687..72b191cfeb5483351d425f7ed68bb5763f0ea266 100644 (file)
@@ -1217,8 +1217,7 @@ static void pt1_i2c_init(struct pt1 *pt1)
 
 static int pt1_suspend(struct device *dev)
 {
-       struct pci_dev *pdev = to_pci_dev(dev);
-       struct pt1 *pt1 = pci_get_drvdata(pdev);
+       struct pt1 *pt1 = dev_get_drvdata(dev);
 
        pt1_init_streams(pt1);
        pt1_disable_ram(pt1);
@@ -1230,8 +1229,7 @@ static int pt1_suspend(struct device *dev)
 
 static int pt1_resume(struct device *dev)
 {
-       struct pci_dev *pdev = to_pci_dev(dev);
-       struct pt1 *pt1 = pci_get_drvdata(pdev);
+       struct pt1 *pt1 = dev_get_drvdata(dev);
        int ret;
        int i;
 
index 7a7afae4c84ce28dc557f551c776a366fdec1f9e..c0bc867933558e1818d61672831e693752d8719e 100644 (file)
@@ -626,8 +626,7 @@ static void pt3_cleanup_adapter(struct pt3_board *pt3, int index)
 
 static int pt3_suspend(struct device *dev)
 {
-       struct pci_dev *pdev = to_pci_dev(dev);
-       struct pt3_board *pt3 = pci_get_drvdata(pdev);
+       struct pt3_board *pt3 = dev_get_drvdata(dev);
        int i;
        struct pt3_adapter *adap;
 
@@ -646,8 +645,7 @@ static int pt3_suspend(struct device *dev)
 
 static int pt3_resume(struct device *dev)
 {
-       struct pci_dev *pdev = to_pci_dev(dev);
-       struct pt3_board *pt3 = pci_get_drvdata(pdev);
+       struct pt3_board *pt3 = dev_get_drvdata(dev);
        int i, ret;
        struct pt3_adapter *adap;
 
index 1a41a56afec6485ed41ceccf96507196e486c50d..cb65d345fd3e9756998c87a3f55f7e57d7e57368 100644 (file)
@@ -91,9 +91,7 @@ static int empress_enum_fmt_vid_cap(struct file *file, void  *priv,
        if (f->index != 0)
                return -EINVAL;
 
-       strscpy(f->description, "MPEG TS", sizeof(f->description));
        f->pixelformat = V4L2_PIX_FMT_MPEG;
-       f->flags = V4L2_FMT_FLAG_COMPRESSED;
        return 0;
 }
 
index 5beff534d5e10df91d741ce86f532a3a824f7434..79e1afb71075893fdfbdd8dcf6f0620b7d145a56 100644 (file)
@@ -319,7 +319,6 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan)
        __s32 left,right,value;
 
        if (!(dev->tvnorm->id & scan->std)) {
-               value = 0;
                audio_dbg(1, "skipping %d.%03d MHz [%4s]\n",
                          scan->carr / 1000, scan->carr % 1000, scan->name);
                return 0;
index 606df51bb636b00b392dda3ec4eff6d43678f983..342cabf48064611917268b9c3a3d7771df13da37 100644 (file)
@@ -90,70 +90,58 @@ static int video_out[][9] = {
 
 static struct saa7134_format formats[] = {
        {
-               .name     = "8 bpp gray",
                .fourcc   = V4L2_PIX_FMT_GREY,
                .depth    = 8,
                .pm       = 0x06,
        },{
-               .name     = "15 bpp RGB, le",
                .fourcc   = V4L2_PIX_FMT_RGB555,
                .depth    = 16,
                .pm       = 0x13 | 0x80,
        },{
-               .name     = "15 bpp RGB, be",
                .fourcc   = V4L2_PIX_FMT_RGB555X,
                .depth    = 16,
                .pm       = 0x13 | 0x80,
                .bswap    = 1,
        },{
-               .name     = "16 bpp RGB, le",
                .fourcc   = V4L2_PIX_FMT_RGB565,
                .depth    = 16,
                .pm       = 0x10 | 0x80,
        },{
-               .name     = "16 bpp RGB, be",
                .fourcc   = V4L2_PIX_FMT_RGB565X,
                .depth    = 16,
                .pm       = 0x10 | 0x80,
                .bswap    = 1,
        },{
-               .name     = "24 bpp RGB, le",
                .fourcc   = V4L2_PIX_FMT_BGR24,
                .depth    = 24,
                .pm       = 0x11,
        },{
-               .name     = "24 bpp RGB, be",
                .fourcc   = V4L2_PIX_FMT_RGB24,
                .depth    = 24,
                .pm       = 0x11,
                .bswap    = 1,
        },{
-               .name     = "32 bpp RGB, le",
                .fourcc   = V4L2_PIX_FMT_BGR32,
                .depth    = 32,
                .pm       = 0x12,
        },{
-               .name     = "32 bpp RGB, be",
                .fourcc   = V4L2_PIX_FMT_RGB32,
                .depth    = 32,
                .pm       = 0x12,
                .bswap    = 1,
                .wswap    = 1,
        },{
-               .name     = "4:2:2 packed, YUYV",
                .fourcc   = V4L2_PIX_FMT_YUYV,
                .depth    = 16,
                .pm       = 0x00,
                .bswap    = 1,
                .yuv      = 1,
        },{
-               .name     = "4:2:2 packed, UYVY",
                .fourcc   = V4L2_PIX_FMT_UYVY,
                .depth    = 16,
                .pm       = 0x00,
                .yuv      = 1,
        },{
-               .name     = "4:2:2 planar, Y-Cb-Cr",
                .fourcc   = V4L2_PIX_FMT_YUV422P,
                .depth    = 16,
                .pm       = 0x09,
@@ -162,7 +150,6 @@ static struct saa7134_format formats[] = {
                .hshift   = 1,
                .vshift   = 0,
        },{
-               .name     = "4:2:0 planar, Y-Cb-Cr",
                .fourcc   = V4L2_PIX_FMT_YUV420,
                .depth    = 12,
                .pm       = 0x0a,
@@ -171,7 +158,6 @@ static struct saa7134_format formats[] = {
                .hshift   = 1,
                .vshift   = 1,
        },{
-               .name     = "4:2:0 planar, Y-Cb-Cr",
                .fourcc   = V4L2_PIX_FMT_YVU420,
                .depth    = 12,
                .pm       = 0x0a,
@@ -720,10 +706,10 @@ static int start_preview(struct saa7134_dev *dev)
                return err;
 
        dev->ovfield = dev->win.field;
-       video_dbg("start_preview %dx%d+%d+%d %s field=%s\n",
-               dev->win.w.width, dev->win.w.height,
-               dev->win.w.left, dev->win.w.top,
-               dev->ovfmt->name, v4l2_field_names[dev->ovfield]);
+       video_dbg("%s %dx%d+%d+%d 0x%08x field=%s\n", __func__,
+                 dev->win.w.width, dev->win.w.height,
+                 dev->win.w.left, dev->win.w.top,
+                 dev->ovfmt->fourcc, v4l2_field_names[dev->ovfield]);
 
        /* setup window + clipping */
        set_size(dev, TASK_B, dev->win.w.width, dev->win.w.height,
@@ -1780,9 +1766,6 @@ static int saa7134_enum_fmt_vid_cap(struct file *file, void  *priv,
        if (f->index >= FORMATS)
                return -EINVAL;
 
-       strscpy(f->description, formats[f->index].name,
-               sizeof(f->description));
-
        f->pixelformat = formats[f->index].fourcc;
 
        return 0;
@@ -1799,9 +1782,6 @@ static int saa7134_enum_fmt_vid_overlay(struct file *file, void  *priv,
        if ((f->index >= FORMATS) || formats[f->index].planar)
                return -EINVAL;
 
-       strscpy(f->description, formats[f->index].name,
-               sizeof(f->description));
-
        f->pixelformat = formats[f->index].fourcc;
 
        return 0;
index 6324f174c6f97a5c238886bb3279750a62988e3e..77c325e64a978c5235ea6b59be4ae40f66b7f530 100644 (file)
@@ -98,7 +98,6 @@ struct saa7134_tvaudio {
 };
 
 struct saa7134_format {
-       char           *name;
        unsigned int   fourcc;
        unsigned int   depth;
        unsigned int   pm;
index 43fdaa2d32bd73d329deb792ecd6460935e6a103..3fca7257a72013883452bcfef28ed6651b19b627 100644 (file)
@@ -503,7 +503,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
        if (f->index != 0)
                return -EINVAL;
 
-       strscpy(f->description, "MPEG", sizeof(f->description));
        f->pixelformat = V4L2_PIX_FMT_MPEG;
 
        return 0;
index 609100a46ff842a1fec3ccf6e33a5bab0bf8f672..476d7f3b32d63a2e206f4db40301604f38d24c7a 100644 (file)
@@ -822,25 +822,18 @@ static int solo_enc_enum_fmt_cap(struct file *file, void *priv,
                switch (dev_type) {
                case SOLO_DEV_6010:
                        f->pixelformat = V4L2_PIX_FMT_MPEG4;
-                       strscpy(f->description, "MPEG-4 part 2",
-                               sizeof(f->description));
                        break;
                case SOLO_DEV_6110:
                        f->pixelformat = V4L2_PIX_FMT_H264;
-                       strscpy(f->description, "H.264", sizeof(f->description));
                        break;
                }
                break;
        case 1:
                f->pixelformat = V4L2_PIX_FMT_MJPEG;
-               strscpy(f->description, "MJPEG", sizeof(f->description));
                break;
        default:
                return -EINVAL;
        }
-
-       f->flags = V4L2_FMT_FLAG_COMPRESSED;
-
        return 0;
 }
 
@@ -886,7 +879,6 @@ static int solo_enc_try_fmt_cap(struct file *file, void *priv,
        pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
        pix->sizeimage = FRAME_BUF_SIZE;
        pix->bytesperline = 0;
-       pix->priv = 0;
 
        return 0;
 }
@@ -941,7 +933,6 @@ static int solo_enc_get_fmt_cap(struct file *file, void *priv,
                     V4L2_FIELD_NONE;
        pix->sizeimage = FRAME_BUF_SIZE;
        pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
-       pix->priv = 0;
 
        return 0;
 }
index a968f75920b522657662eb21ca4781a08d1fc086..78792067e920f37e19c20b04ad7adfb15836d3e2 100644 (file)
@@ -458,8 +458,6 @@ static int solo_enum_fmt_cap(struct file *file, void *priv,
                return -EINVAL;
 
        f->pixelformat = V4L2_PIX_FMT_UYVY;
-       strscpy(f->description, "UYUV 4:2:2 Packed", sizeof(f->description));
-
        return 0;
 }
 
@@ -479,7 +477,6 @@ static int solo_try_fmt_cap(struct file *file, void *priv,
        pix->field = V4L2_FIELD_INTERLACED;
        pix->pixelformat = V4L2_PIX_FMT_UYVY;
        pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
-       pix->priv = 0;
        return 0;
 }
 
@@ -509,7 +506,6 @@ static int solo_get_fmt_cap(struct file *file, void *priv,
        pix->sizeimage = solo_image_size(solo_dev);
        pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
        pix->bytesperline = solo_bytesperline(solo_dev);
-       pix->priv = 0;
 
        return 0;
 }
index e52e29814378cb1364e79de64ade1c4769afecd4..fd3de3bb0c89b621ba412ac8d11de4eaf62f2ec5 100644 (file)
@@ -560,9 +560,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
        if (f->index != 0)
                return -EINVAL;
 
-       strscpy(f->description, "4:2:2, packed, UYVY", sizeof(f->description));
        f->pixelformat = V4L2_PIX_FMT_UYVY;
-       f->flags = 0;
        return 0;
 }
 
index 8e0952d65ad4f9f8e19d53767de98b030b673849..2fb82d50c53e52786e8d1a951ee7dbb0dcd0305f 100644 (file)
  */
 static const struct tw68_format formats[] = {
        {
-               .name           = "15 bpp RGB, le",
                .fourcc         = V4L2_PIX_FMT_RGB555,
                .depth          = 16,
                .twformat       = ColorFormatRGB15,
        }, {
-               .name           = "15 bpp RGB, be",
                .fourcc         = V4L2_PIX_FMT_RGB555X,
                .depth          = 16,
                .twformat       = ColorFormatRGB15 | ColorFormatBSWAP,
        }, {
-               .name           = "16 bpp RGB, le",
                .fourcc         = V4L2_PIX_FMT_RGB565,
                .depth          = 16,
                .twformat       = ColorFormatRGB16,
        }, {
-               .name           = "16 bpp RGB, be",
                .fourcc         = V4L2_PIX_FMT_RGB565X,
                .depth          = 16,
                .twformat       = ColorFormatRGB16 | ColorFormatBSWAP,
        }, {
-               .name           = "24 bpp RGB, le",
                .fourcc         = V4L2_PIX_FMT_BGR24,
                .depth          = 24,
                .twformat       = ColorFormatRGB24,
        }, {
-               .name           = "24 bpp RGB, be",
                .fourcc         = V4L2_PIX_FMT_RGB24,
                .depth          = 24,
                .twformat       = ColorFormatRGB24 | ColorFormatBSWAP,
        }, {
-               .name           = "32 bpp RGB, le",
                .fourcc         = V4L2_PIX_FMT_BGR32,
                .depth          = 32,
                .twformat       = ColorFormatRGB32,
        }, {
-               .name           = "32 bpp RGB, be",
                .fourcc         = V4L2_PIX_FMT_RGB32,
                .depth          = 32,
                .twformat       = ColorFormatRGB32 | ColorFormatBSWAP |
                                  ColorFormatWSWAP,
        }, {
-               .name           = "4:2:2 packed, YUYV",
                .fourcc         = V4L2_PIX_FMT_YUYV,
                .depth          = 16,
                .twformat       = ColorFormatYUY2,
        }, {
-               .name           = "4:2:2 packed, UYVY",
                .fourcc         = V4L2_PIX_FMT_UYVY,
                .depth          = 16,
                .twformat       = ColorFormatYUY2 | ColorFormatBSWAP,
@@ -592,7 +582,6 @@ static int tw68_g_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.sizeimage =
                f->fmt.pix.height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace   = V4L2_COLORSPACE_SMPTE170M;
-       f->fmt.pix.priv = 0;
        return 0;
 }
 
@@ -774,9 +763,6 @@ static int tw68_enum_fmt_vid_cap(struct file *file, void  *priv,
        if (f->index >= FORMATS)
                return -EINVAL;
 
-       strscpy(f->description, formats[f->index].name,
-               sizeof(f->description));
-
        f->pixelformat = formats[f->index].fourcc;
 
        return 0;
index 7021290d726a070f0623b602b742b193956c406a..a1f422d6e600e0a961c7246b20bd7c944feb45ad 100644 (file)
@@ -85,7 +85,6 @@ struct tw68_tvnorm {
 };
 
 struct tw68_format {
-       char    *name;
        u32     fourcc;
        u32     depth;
        u32     twformat;
index 8a19654b393a92033fc746e06e4ef99687656551..89555f9a813f8c4fcec6c2f552ee5be81e9046ac 100644 (file)
@@ -16,7 +16,7 @@ source "drivers/media/platform/marvell-ccic/Kconfig"
 config VIDEO_VIA_CAMERA
        tristate "VIAFB camera controller support"
        depends on FB_VIA
-       select VIDEOBUF_DMA_SG
+       select VIDEOBUF2_DMA_SG
        select VIDEO_OV7670
        help
           Driver support for the integrated camera controller in VIA
index fe7b937eb5f2a418e860c2131e00e23f4ffa0489..2b42ba1f59494a1e4248e300329999dda629a671 100644 (file)
@@ -76,7 +76,6 @@ struct bus_format {
 
 /*
  * struct vpfe_fmt - VPFE media bus format information
- * @name: V4L2 format description
  * @code: V4L2 media bus format code
  * @shifted: V4L2 media bus format code for the same pixel layout but
  *     shifted to be 8 bits per pixel. =0 if format is not shiftable.
@@ -86,7 +85,6 @@ struct bus_format {
  * @supported: Indicates format supported by subdev
  */
 struct vpfe_fmt {
-       const char *name;
        u32 fourcc;
        u32 code;
        struct bus_format l;
@@ -97,7 +95,6 @@ struct vpfe_fmt {
 
 static struct vpfe_fmt formats[] = {
        {
-               .name           = "YUV 4:2:2 packed, YCbYCr",
                .fourcc         = V4L2_PIX_FMT_YUYV,
                .code           = MEDIA_BUS_FMT_YUYV8_2X8,
                .l.width        = 10,
@@ -106,7 +103,6 @@ static struct vpfe_fmt formats[] = {
                .s.bpp          = 2,
                .supported      = false,
        }, {
-               .name           = "YUV 4:2:2 packed, CbYCrY",
                .fourcc         = V4L2_PIX_FMT_UYVY,
                .code           = MEDIA_BUS_FMT_UYVY8_2X8,
                .l.width        = 10,
@@ -115,7 +111,6 @@ static struct vpfe_fmt formats[] = {
                .s.bpp          = 2,
                .supported      = false,
        }, {
-               .name           = "YUV 4:2:2 packed, YCrYCb",
                .fourcc         = V4L2_PIX_FMT_YVYU,
                .code           = MEDIA_BUS_FMT_YVYU8_2X8,
                .l.width        = 10,
@@ -124,7 +119,6 @@ static struct vpfe_fmt formats[] = {
                .s.bpp          = 2,
                .supported      = false,
        }, {
-               .name           = "YUV 4:2:2 packed, CrYCbY",
                .fourcc         = V4L2_PIX_FMT_VYUY,
                .code           = MEDIA_BUS_FMT_VYUY8_2X8,
                .l.width        = 10,
@@ -133,7 +127,6 @@ static struct vpfe_fmt formats[] = {
                .s.bpp          = 2,
                .supported      = false,
        }, {
-               .name           = "RAW8 BGGR",
                .fourcc         = V4L2_PIX_FMT_SBGGR8,
                .code           = MEDIA_BUS_FMT_SBGGR8_1X8,
                .l.width        = 10,
@@ -142,7 +135,6 @@ static struct vpfe_fmt formats[] = {
                .s.bpp          = 1,
                .supported      = false,
        }, {
-               .name           = "RAW8 GBRG",
                .fourcc         = V4L2_PIX_FMT_SGBRG8,
                .code           = MEDIA_BUS_FMT_SGBRG8_1X8,
                .l.width        = 10,
@@ -151,7 +143,6 @@ static struct vpfe_fmt formats[] = {
                .s.bpp          = 1,
                .supported      = false,
        }, {
-               .name           = "RAW8 GRBG",
                .fourcc         = V4L2_PIX_FMT_SGRBG8,
                .code           = MEDIA_BUS_FMT_SGRBG8_1X8,
                .l.width        = 10,
@@ -160,7 +151,6 @@ static struct vpfe_fmt formats[] = {
                .s.bpp          = 1,
                .supported      = false,
        }, {
-               .name           = "RAW8 RGGB",
                .fourcc         = V4L2_PIX_FMT_SRGGB8,
                .code           = MEDIA_BUS_FMT_SRGGB8_1X8,
                .l.width        = 10,
@@ -169,7 +159,6 @@ static struct vpfe_fmt formats[] = {
                .s.bpp          = 1,
                .supported      = false,
        }, {
-               .name           = "RGB565 (LE)",
                .fourcc         = V4L2_PIX_FMT_RGB565,
                .code           = MEDIA_BUS_FMT_RGB565_2X8_LE,
                .l.width        = 10,
@@ -178,7 +167,6 @@ static struct vpfe_fmt formats[] = {
                .s.bpp          = 2,
                .supported      = false,
        }, {
-               .name           = "RGB565 (BE)",
                .fourcc         = V4L2_PIX_FMT_RGB565X,
                .code           = MEDIA_BUS_FMT_RGB565_2X8_BE,
                .l.width        = 10,
@@ -1412,10 +1400,6 @@ static int vpfe_querycap(struct file *file, void  *priv,
        strscpy(cap->card, "TI AM437x VPFE", sizeof(cap->card));
        snprintf(cap->bus_info, sizeof(cap->bus_info),
                        "platform:%s", vpfe->v4l2_dev.name);
-       cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
-                           V4L2_CAP_READWRITE;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
-
        return 0;
 }
 
@@ -1540,12 +1524,10 @@ static int vpfe_enum_fmt(struct file *file, void  *priv,
        if (!fmt)
                return -EINVAL;
 
-       strscpy(f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->fourcc;
-       f->type = vpfe->fmt.type;
 
-       vpfe_dbg(1, vpfe, "vpfe_enum_format: mbus index: %d code: %x pixelformat: %s [%s]\n",
-               f->index, fmt->code, print_fourcc(fmt->fourcc), fmt->name);
+       vpfe_dbg(1, vpfe, "vpfe_enum_format: mbus index: %d code: %x pixelformat: %s\n",
+                f->index, fmt->code, print_fourcc(fmt->fourcc));
 
        return 0;
 }
@@ -2393,6 +2375,8 @@ static int vpfe_probe_complete(struct vpfe_device *vpfe)
        vdev->vfl_dir = VFL_DIR_RX;
        vdev->queue = q;
        vdev->lock = &vpfe->lock;
+       vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
+                           V4L2_CAP_READWRITE;
        video_set_drvdata(vdev, vpfe);
        err = video_register_device(&vpfe->video_dev, VFL_TYPE_GRABBER, -1);
        if (err) {
@@ -2505,10 +2489,9 @@ vpfe_get_pdata(struct vpfe_device *vpfe)
                pdata->asd[i] = v4l2_async_notifier_add_fwnode_subdev(
                        &vpfe->notifier, of_fwnode_handle(rem),
                        sizeof(struct v4l2_async_subdev));
-               if (IS_ERR(pdata->asd[i])) {
-                       of_node_put(rem);
+               of_node_put(rem);
+               if (IS_ERR(pdata->asd[i]))
                        goto cleanup;
-               }
        }
 
        of_node_put(endpoint);
@@ -2557,7 +2540,6 @@ static int vpfe_probe(struct platform_device *pdev)
 
        ret = platform_get_irq(pdev, 0);
        if (ret <= 0) {
-               dev_err(&pdev->dev, "No IRQ resource\n");
                ret = -ENODEV;
                goto probe_out_cleanup;
        }
index 17d7aa426788b77e7aaaa1da4c5df259dfd4b2d0..4678285f34c6b4218de6e87ab941b001c0e463f8 100644 (file)
@@ -65,12 +65,6 @@ struct vpfe_hw_if_param {
 #define VPFE_MAX_SUBDEV                1
 #define VPFE_MAX_INPUTS                1
 
-struct vpfe_pixel_format {
-       struct v4l2_fmtdesc fmtdesc;
-       /* bytes per pixel */
-       int bpp;
-};
-
 struct vpfe_std_info {
        int active_pixels;
        int active_lines;
index 266df14da2d5ee4dcc6a8fd0111382ed16cc036a..78381651238dd7410b5292809b71f332a7de6554 100644 (file)
@@ -160,11 +160,8 @@ static int atmel_isc_probe(struct platform_device *pdev)
        }
 
        irq = platform_get_irq(pdev, 0);
-       if (irq < 0) {
-               ret = irq;
-               dev_err(dev, "failed to get irq: %d\n", ret);
-               return ret;
-       }
+       if (irq < 0)
+               return irq;
 
        ret = devm_request_irq(dev, irq, isc_interrupt, 0,
                               ATMEL_ISC_NAME, isc);
index 5042d053b94e21c1f02ddb31e034b6d19de62a6d..e4d08acfbb49f095e0dbc079d0e80b679111b288 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * Driver for Cadence MIPI-CSI2 TX Controller
  *
- * Copyright (C) 2017-2018 Cadence Design Systems Inc.
+ * Copyright (C) 2017-2019 Cadence Design Systems Inc.
  */
 
 #include <linux/clk.h>
 #define CSI2TX_STREAM_IF_CFG_REG(n)    (0x100 + (n) * 4)
 #define CSI2TX_STREAM_IF_CFG_FILL_LEVEL(n)     ((n) & 0x1f)
 
+/* CSI2TX V2 Registers */
+#define CSI2TX_V2_DPHY_CFG_REG                 0x28
+#define CSI2TX_V2_DPHY_CFG_RESET               BIT(16)
+#define CSI2TX_V2_DPHY_CFG_CLOCK_MODE          BIT(10)
+#define CSI2TX_V2_DPHY_CFG_MODE_MASK           GENMASK(9, 8)
+#define CSI2TX_V2_DPHY_CFG_MODE_LPDT           (2 << 8)
+#define CSI2TX_V2_DPHY_CFG_MODE_HS             (1 << 8)
+#define CSI2TX_V2_DPHY_CFG_MODE_ULPS           (0 << 8)
+#define CSI2TX_V2_DPHY_CFG_CLK_ENABLE          BIT(4)
+#define CSI2TX_V2_DPHY_CFG_LANE_ENABLE(n)      BIT(n)
+
 #define CSI2TX_LANES_MAX       4
 #define CSI2TX_STREAMS_MAX     4
 
@@ -70,6 +81,13 @@ struct csi2tx_fmt {
        u32     bpp;
 };
 
+struct csi2tx_priv;
+
+/* CSI2TX Variant Operations */
+struct csi2tx_vops {
+       void (*dphy_setup)(struct csi2tx_priv *csi2tx);
+};
+
 struct csi2tx_priv {
        struct device                   *dev;
        unsigned int                    count;
@@ -82,6 +100,8 @@ struct csi2tx_priv {
 
        void __iomem                    *base;
 
+       struct csi2tx_vops              *vops;
+
        struct clk                      *esc_clk;
        struct clk                      *p_clk;
        struct clk                      *pixel_clk[CSI2TX_STREAMS_MAX];
@@ -209,53 +229,92 @@ static const struct v4l2_subdev_pad_ops csi2tx_pad_ops = {
        .set_fmt        = csi2tx_set_pad_format,
 };
 
-static void csi2tx_reset(struct csi2tx_priv *csi2tx)
+/* Set Wake Up value in the D-PHY */
+static void csi2tx_dphy_set_wakeup(struct csi2tx_priv *csi2tx)
 {
-       writel(CSI2TX_CONFIG_SRST_REQ, csi2tx->base + CSI2TX_CONFIG_REG);
-
-       udelay(10);
+       writel(CSI2TX_DPHY_CLK_WAKEUP_ULPS_CYCLES(32),
+              csi2tx->base + CSI2TX_DPHY_CLK_WAKEUP_REG);
 }
 
-static int csi2tx_start(struct csi2tx_priv *csi2tx)
+/*
+ * Finishes the D-PHY initialization
+ * reg dphy cfg value to be used
+ */
+static void csi2tx_dphy_init_finish(struct csi2tx_priv *csi2tx, u32 reg)
 {
-       struct media_entity *entity = &csi2tx->subdev.entity;
-       struct media_link *link;
        unsigned int i;
-       u32 reg;
 
-       csi2tx_reset(csi2tx);
+       udelay(10);
 
-       writel(CSI2TX_CONFIG_CFG_REQ, csi2tx->base + CSI2TX_CONFIG_REG);
+       /* Enable our (clock and data) lanes */
+       reg |= CSI2TX_DPHY_CFG_CLK_ENABLE;
+       for (i = 0; i < csi2tx->num_lanes; i++)
+               reg |= CSI2TX_DPHY_CFG_LANE_ENABLE(csi2tx->lanes[i] - 1);
+       writel(reg, csi2tx->base + CSI2TX_DPHY_CFG_REG);
 
        udelay(10);
 
-       /* Configure our PPI interface with the D-PHY */
-       writel(CSI2TX_DPHY_CLK_WAKEUP_ULPS_CYCLES(32),
-              csi2tx->base + CSI2TX_DPHY_CLK_WAKEUP_REG);
+       /* Switch to HS mode */
+       reg &= ~CSI2TX_DPHY_CFG_MODE_MASK;
+       writel(reg | CSI2TX_DPHY_CFG_MODE_HS,
+              csi2tx->base + CSI2TX_DPHY_CFG_REG);
+}
+
+/* Configures D-PHY in CSIv1.3 */
+static void csi2tx_dphy_setup(struct csi2tx_priv *csi2tx)
+{
+       u32 reg;
+       unsigned int i;
+
+       csi2tx_dphy_set_wakeup(csi2tx);
 
        /* Put our lanes (clock and data) out of reset */
        reg = CSI2TX_DPHY_CFG_CLK_RESET | CSI2TX_DPHY_CFG_MODE_LPDT;
        for (i = 0; i < csi2tx->num_lanes; i++)
-               reg |= CSI2TX_DPHY_CFG_LANE_RESET(csi2tx->lanes[i]);
+               reg |= CSI2TX_DPHY_CFG_LANE_RESET(csi2tx->lanes[i] - 1);
        writel(reg, csi2tx->base + CSI2TX_DPHY_CFG_REG);
 
-       udelay(10);
+       csi2tx_dphy_init_finish(csi2tx, reg);
+}
 
-       /* Enable our (clock and data) lanes */
-       reg |= CSI2TX_DPHY_CFG_CLK_ENABLE;
-       for (i = 0; i < csi2tx->num_lanes; i++)
-               reg |= CSI2TX_DPHY_CFG_LANE_ENABLE(csi2tx->lanes[i]);
-       writel(reg, csi2tx->base + CSI2TX_DPHY_CFG_REG);
+/* Configures D-PHY in CSIv2 */
+static void csi2tx_v2_dphy_setup(struct csi2tx_priv *csi2tx)
+{
+       u32 reg;
+
+       csi2tx_dphy_set_wakeup(csi2tx);
+
+       /* Put our lanes (clock and data) out of reset */
+       reg = CSI2TX_V2_DPHY_CFG_RESET | CSI2TX_V2_DPHY_CFG_MODE_LPDT;
+       writel(reg, csi2tx->base + CSI2TX_V2_DPHY_CFG_REG);
+
+       csi2tx_dphy_init_finish(csi2tx, reg);
+}
+
+static void csi2tx_reset(struct csi2tx_priv *csi2tx)
+{
+       writel(CSI2TX_CONFIG_SRST_REQ, csi2tx->base + CSI2TX_CONFIG_REG);
 
        udelay(10);
+}
 
-       /* Switch to HS mode */
-       reg &= ~CSI2TX_DPHY_CFG_MODE_MASK;
-       writel(reg | CSI2TX_DPHY_CFG_MODE_HS,
-              csi2tx->base + CSI2TX_DPHY_CFG_REG);
+static int csi2tx_start(struct csi2tx_priv *csi2tx)
+{
+       struct media_entity *entity = &csi2tx->subdev.entity;
+       struct media_link *link;
+       unsigned int i;
+
+       csi2tx_reset(csi2tx);
+
+       writel(CSI2TX_CONFIG_CFG_REQ, csi2tx->base + CSI2TX_CONFIG_REG);
 
        udelay(10);
 
+       if (csi2tx->vops && csi2tx->vops->dphy_setup) {
+               csi2tx->vops->dphy_setup(csi2tx);
+               udelay(10);
+       }
+
        /*
         * Create a static mapping between the CSI virtual channels
         * and the input streams.
@@ -434,7 +493,7 @@ static int csi2tx_check_lanes(struct csi2tx_priv *csi2tx)
 {
        struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 };
        struct device_node *ep;
-       int ret;
+       int ret, i;
 
        ep = of_graph_get_endpoint_by_regs(csi2tx->dev->of_node, 0, 0);
        if (!ep)
@@ -461,6 +520,15 @@ static int csi2tx_check_lanes(struct csi2tx_priv *csi2tx)
                goto out;
        }
 
+       for (i = 0; i < csi2tx->num_lanes; i++) {
+               if (v4l2_ep.bus.mipi_csi2.data_lanes[i] < 1) {
+                       dev_err(csi2tx->dev, "Invalid lane[%d] number: %u\n",
+                               i, v4l2_ep.bus.mipi_csi2.data_lanes[i]);
+                       ret = -EINVAL;
+                       goto out;
+               }
+       }
+
        memcpy(csi2tx->lanes, v4l2_ep.bus.mipi_csi2.data_lanes,
               sizeof(csi2tx->lanes));
 
@@ -469,9 +537,35 @@ static int csi2tx_check_lanes(struct csi2tx_priv *csi2tx)
        return ret;
 }
 
+static const struct csi2tx_vops csi2tx_vops = {
+       .dphy_setup = csi2tx_dphy_setup,
+};
+
+static const struct csi2tx_vops csi2tx_v2_vops = {
+       .dphy_setup = csi2tx_v2_dphy_setup,
+};
+
+static const struct of_device_id csi2tx_of_table[] = {
+       {
+               .compatible = "cdns,csi2tx",
+               .data = &csi2tx_vops
+       },
+       {
+               .compatible = "cdns,csi2tx-1.3",
+               .data = &csi2tx_vops
+       },
+       {
+               .compatible = "cdns,csi2tx-2.1",
+               .data = &csi2tx_v2_vops
+       },
+       { }
+};
+MODULE_DEVICE_TABLE(of, csi2tx_of_table);
+
 static int csi2tx_probe(struct platform_device *pdev)
 {
        struct csi2tx_priv *csi2tx;
+       const struct of_device_id *of_id;
        unsigned int i;
        int ret;
 
@@ -486,6 +580,9 @@ static int csi2tx_probe(struct platform_device *pdev)
        if (ret)
                goto err_free_priv;
 
+       of_id = of_match_node(csi2tx_of_table, pdev->dev.of_node);
+       csi2tx->vops = (struct csi2tx_vops *)of_id->data;
+
        v4l2_subdev_init(&csi2tx->subdev, &csi2tx_subdev_ops);
        csi2tx->subdev.owner = THIS_MODULE;
        csi2tx->subdev.dev = &pdev->dev;
@@ -543,12 +640,6 @@ static int csi2tx_remove(struct platform_device *pdev)
        return 0;
 }
 
-static const struct of_device_id csi2tx_of_table[] = {
-       { .compatible = "cdns,csi2tx" },
-       { },
-};
-MODULE_DEVICE_TABLE(of, csi2tx_of_table);
-
 static struct platform_driver csi2tx_driver = {
        .probe  = csi2tx_probe,
        .remove = csi2tx_remove,
index 01428de2596e694e756d9fc2e5e5788ee614b29e..73222c0615c0c1023b33f6837ed88835636c5ddb 100644 (file)
@@ -390,9 +390,6 @@ static int coda_querycap(struct file *file, void *priv,
        strscpy(cap->card, coda_product_name(ctx->dev->devtype->product),
                sizeof(cap->card));
        strscpy(cap->bus_info, "platform:" CODA_NAME, sizeof(cap->bus_info));
-       cap->device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
-
        return 0;
 }
 
@@ -2699,6 +2696,7 @@ static int coda_register_device(struct coda_dev *dev, int i)
        vfd->lock       = &dev->dev_mutex;
        vfd->v4l2_dev   = &dev->v4l2_dev;
        vfd->vfl_dir    = VFL_DIR_M2M;
+       vfd->device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING;
        video_set_drvdata(vfd, dev);
 
        /* Not applicable, use the selection API instead */
index 068df9888dbf03001af6e4b814819dd105cf7f3e..76ab83f55cc070a0648cf59806a69bb81c5b9fee 100644 (file)
@@ -206,10 +206,10 @@ static SIMPLE_DEV_PM_OPS(cros_ec_cec_pm_ops,
  */
 
 struct cec_dmi_match {
-       char *sys_vendor;
-       char *product_name;
-       char *devname;
-       char *conn;
+       const char *sys_vendor;
+       const char *product_name;
+       const char *devname;
+       const char *conn;
 };
 
 static const struct cec_dmi_match cec_dmi_match_table[] = {
@@ -217,8 +217,8 @@ static const struct cec_dmi_match cec_dmi_match_table[] = {
        { "Google", "Fizz", "0000:00:02.0", "Port B" },
 };
 
-static int cros_ec_cec_get_notifier(struct device *dev,
-                                   struct cec_notifier **notify)
+static struct device *cros_ec_cec_find_hdmi_dev(struct device *dev,
+                                               const char **conn)
 {
        int i;
 
@@ -233,26 +233,25 @@ static int cros_ec_cec_get_notifier(struct device *dev,
                        d = bus_find_device_by_name(&pci_bus_type, NULL,
                                                    m->devname);
                        if (!d)
-                               return -EPROBE_DEFER;
-
-                       *notify = cec_notifier_get_conn(d, m->conn);
+                               return ERR_PTR(-EPROBE_DEFER);
                        put_device(d);
-                       return 0;
+                       *conn = m->conn;
+                       return d;
                }
        }
 
        /* Hardware support must be added in the cec_dmi_match_table */
        dev_warn(dev, "CEC notifier not configured for this hardware\n");
 
-       return -ENODEV;
+       return ERR_PTR(-ENODEV);
 }
 
 #else
 
-static int cros_ec_cec_get_notifier(struct device *dev,
-                                   struct cec_notifier **notify)
+static struct device *cros_ec_cec_find_hdmi_dev(struct device *dev,
+                                               const char **conn)
 {
-       return -ENODEV;
+       return ERR_PTR(-ENODEV);
 }
 
 #endif
@@ -262,8 +261,14 @@ static int cros_ec_cec_probe(struct platform_device *pdev)
        struct cros_ec_dev *ec_dev = dev_get_drvdata(pdev->dev.parent);
        struct cros_ec_device *cros_ec = ec_dev->ec_dev;
        struct cros_ec_cec *cros_ec_cec;
+       struct device *hdmi_dev;
+       const char *conn = NULL;
        int ret;
 
+       hdmi_dev = cros_ec_cec_find_hdmi_dev(&pdev->dev, &conn);
+       if (IS_ERR(hdmi_dev))
+               return PTR_ERR(hdmi_dev);
+
        cros_ec_cec = devm_kzalloc(&pdev->dev, sizeof(*cros_ec_cec),
                                   GFP_KERNEL);
        if (!cros_ec_cec)
@@ -272,10 +277,6 @@ static int cros_ec_cec_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, cros_ec_cec);
        cros_ec_cec->cros_ec = cros_ec;
 
-       ret = cros_ec_cec_get_notifier(&pdev->dev, &cros_ec_cec->notify);
-       if (ret)
-               return ret;
-
        ret = device_init_wakeup(&pdev->dev, 1);
        if (ret) {
                dev_err(&pdev->dev, "failed to initialize wakeup\n");
@@ -283,29 +284,39 @@ static int cros_ec_cec_probe(struct platform_device *pdev)
        }
 
        cros_ec_cec->adap = cec_allocate_adapter(&cros_ec_cec_ops, cros_ec_cec,
-                                                DRV_NAME, CEC_CAP_DEFAULTS, 1);
+                                                DRV_NAME,
+                                                CEC_CAP_DEFAULTS |
+                                                CEC_CAP_CONNECTOR_INFO, 1);
        if (IS_ERR(cros_ec_cec->adap))
                return PTR_ERR(cros_ec_cec->adap);
 
+       cros_ec_cec->notify = cec_notifier_cec_adap_register(hdmi_dev, conn,
+                                                            cros_ec_cec->adap);
+       if (!cros_ec_cec->notify) {
+               ret = -ENOMEM;
+               goto out_probe_adapter;
+       }
+
        /* Get CEC events from the EC. */
        cros_ec_cec->notifier.notifier_call = cros_ec_cec_event;
        ret = blocking_notifier_chain_register(&cros_ec->event_notifier,
                                               &cros_ec_cec->notifier);
        if (ret) {
                dev_err(&pdev->dev, "failed to register notifier\n");
-               cec_delete_adapter(cros_ec_cec->adap);
-               return ret;
+               goto out_probe_notify;
        }
 
        ret = cec_register_adapter(cros_ec_cec->adap, &pdev->dev);
-       if (ret < 0) {
-               cec_delete_adapter(cros_ec_cec->adap);
-               return ret;
-       }
-
-       cec_register_cec_notifier(cros_ec_cec->adap, cros_ec_cec->notify);
+       if (ret < 0)
+               goto out_probe_notify;
 
        return 0;
+
+out_probe_notify:
+       cec_notifier_cec_adap_unregister(cros_ec_cec->notify);
+out_probe_adapter:
+       cec_delete_adapter(cros_ec_cec->adap);
+       return ret;
 }
 
 static int cros_ec_cec_remove(struct platform_device *pdev)
@@ -323,11 +334,9 @@ static int cros_ec_cec_remove(struct platform_device *pdev)
                return ret;
        }
 
+       cec_notifier_cec_adap_unregister(cros_ec_cec->notify);
        cec_unregister_adapter(cros_ec_cec->adap);
 
-       if (cros_ec_cec->notify)
-               cec_notifier_put(cros_ec_cec->notify);
-
        return 0;
 }
 
index 000b191c42d8ce0377cdebfa7b49a7ce4934473b..ae419958e4204d2749f090c4140ed2a265bb0e95 100644 (file)
 
 #include <asm/pgtable.h>
 
-#ifdef CONFIG_ARCH_DAVINCI
-#include <mach/cputype.h>
-#endif
-
 #include <media/v4l2-dev.h>
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
@@ -633,8 +629,6 @@ static int vpbe_display_querycap(struct file *file, void  *priv,
        struct vpbe_layer *layer = video_drvdata(file);
        struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
 
-       cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
        snprintf(cap->driver, sizeof(cap->driver), "%s",
                dev_name(vpbe_dev->pdev));
        snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
@@ -792,7 +786,6 @@ static int vpbe_display_enum_fmt(struct file *file, void  *priv,
 {
        struct vpbe_layer *layer = video_drvdata(file);
        struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
-       unsigned int index = 0;
 
        v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
                                "VIDIOC_ENUM_FMT, layer id = %d\n",
@@ -803,19 +796,10 @@ static int vpbe_display_enum_fmt(struct file *file, void  *priv,
        }
 
        /* Fill in the information about format */
-       index = fmt->index;
-       memset(fmt, 0, sizeof(*fmt));
-       fmt->index = index;
-       fmt->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-       if (index == 0) {
-               strscpy(fmt->description, "YUV 4:2:2 - UYVY",
-                       sizeof(fmt->description));
+       if (fmt->index == 0)
                fmt->pixelformat = V4L2_PIX_FMT_UYVY;
-       } else {
-               strscpy(fmt->description, "Y/CbCr 4:2:0",
-                       sizeof(fmt->description));
+       else
                fmt->pixelformat = V4L2_PIX_FMT_NV12;
-       }
 
        return 0;
 }
@@ -1319,6 +1303,7 @@ static int init_vpbe_layer(int i, struct vpbe_display *disp_dev,
        vbd->v4l2_dev   = &disp_dev->vpbe_dev->v4l2_dev;
        vbd->lock       = &vpbe_display_layer->opslock;
        vbd->vfl_dir    = VFL_DIR_TX;
+       vbd->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
 
        if (disp_dev->vpbe_dev->current_timings.timings_type &
                        VPBE_ENC_STD)
index 491842ef33c5004a481921060718303c7e43c9f7..91b571a0ac2c9be3d2339b74ffb1247f54a4a88f 100644 (file)
 #include <linux/clk.h>
 #include <linux/slab.h>
 
-#ifdef CONFIG_ARCH_DAVINCI
-#include <mach/cputype.h>
-#include <mach/hardware.h>
-#endif
-
 #include <media/davinci/vpss.h>
 #include <media/v4l2-device.h>
 #include <media/davinci/vpbe_types.h>
index 425f91f07165b578476f5ecec589ad302bfe7889..8caa084e570469c6fed105a02dd442be471b03b1 100644 (file)
 #include <linux/videodev2.h>
 #include <linux/slab.h>
 
-#ifdef CONFIG_ARCH_DAVINCI
-#include <mach/hardware.h>
-#include <mach/mux.h>
-#endif
-
 #include <linux/platform_data/i2c-davinci.h>
 
 #include <linux/io.h>
index 295fbf1a49cfa7cc94d6079903fa76a57ed5fac1..916ed743d716cfccd376a11f675fe08714fcbe47 100644 (file)
@@ -119,57 +119,27 @@ static const struct vpfe_standard vpfe_standards[] = {
 /* Used when raw Bayer image from ccdc is directly captured to SDRAM */
 static const struct vpfe_pixel_format vpfe_pix_fmts[] = {
        {
-               .fmtdesc = {
-                       .index = 0,
-                       .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
-                       .description = "Bayer GrRBGb 8bit A-Law compr.",
-                       .pixelformat = V4L2_PIX_FMT_SBGGR8,
-               },
+               .pixelformat = V4L2_PIX_FMT_SBGGR8,
                .bpp = 1,
        },
        {
-               .fmtdesc = {
-                       .index = 1,
-                       .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
-                       .description = "Bayer GrRBGb - 16bit",
-                       .pixelformat = V4L2_PIX_FMT_SBGGR16,
-               },
+               .pixelformat = V4L2_PIX_FMT_SBGGR16,
                .bpp = 2,
        },
        {
-               .fmtdesc = {
-                       .index = 2,
-                       .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
-                       .description = "Bayer GrRBGb 8bit DPCM compr.",
-                       .pixelformat = V4L2_PIX_FMT_SGRBG10DPCM8,
-               },
+               .pixelformat = V4L2_PIX_FMT_SGRBG10DPCM8,
                .bpp = 1,
        },
        {
-               .fmtdesc = {
-                       .index = 3,
-                       .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
-                       .description = "YCbCr 4:2:2 Interleaved UYVY",
-                       .pixelformat = V4L2_PIX_FMT_UYVY,
-               },
+               .pixelformat = V4L2_PIX_FMT_UYVY,
                .bpp = 2,
        },
        {
-               .fmtdesc = {
-                       .index = 4,
-                       .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
-                       .description = "YCbCr 4:2:2 Interleaved YUYV",
-                       .pixelformat = V4L2_PIX_FMT_YUYV,
-               },
+               .pixelformat = V4L2_PIX_FMT_YUYV,
                .bpp = 2,
        },
        {
-               .fmtdesc = {
-                       .index = 5,
-                       .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
-                       .description = "Y/CbCr 4:2:0 - Semi planar",
-                       .pixelformat = V4L2_PIX_FMT_NV12,
-               },
+               .pixelformat = V4L2_PIX_FMT_NV12,
                .bpp = 1,
        },
 };
@@ -183,7 +153,7 @@ static const struct vpfe_pixel_format *vpfe_lookup_pix_format(u32 pix_format)
        int i;
 
        for (i = 0; i < ARRAY_SIZE(vpfe_pix_fmts); i++) {
-               if (pix_format == vpfe_pix_fmts[i].fmtdesc.pixelformat)
+               if (pix_format == vpfe_pix_fmts[i].pixelformat)
                        return &vpfe_pix_fmts[i];
        }
        return NULL;
@@ -782,7 +752,7 @@ static const struct vpfe_pixel_format *
        temp = 0;
        found = 0;
        while (ccdc_dev->hw_ops.enum_pix(&pix, temp) >= 0) {
-               if (vpfe_pix_fmt->fmtdesc.pixelformat == pix) {
+               if (vpfe_pix_fmt->pixelformat == pix) {
                        found = 1;
                        break;
                }
@@ -877,8 +847,6 @@ static int vpfe_querycap(struct file *file, void  *priv,
 
        v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querycap\n");
 
-       cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
        strscpy(cap->driver, CAPTURE_DRV_NAME, sizeof(cap->driver));
        strscpy(cap->bus_info, "VPFE", sizeof(cap->bus_info));
        strscpy(cap->card, vpfe_dev->cfg->card_name, sizeof(cap->card));
@@ -901,7 +869,6 @@ static int vpfe_enum_fmt_vid_cap(struct file *file, void  *priv,
 {
        struct vpfe_device *vpfe_dev = video_drvdata(file);
        const struct vpfe_pixel_format *pix_fmt;
-       int temp_index;
        u32 pix;
 
        v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_enum_fmt_vid_cap\n");
@@ -912,9 +879,7 @@ static int vpfe_enum_fmt_vid_cap(struct file *file, void  *priv,
        /* Fill in the information about format */
        pix_fmt = vpfe_lookup_pix_format(pix);
        if (pix_fmt) {
-               temp_index = fmt->index;
-               *fmt = pix_fmt->fmtdesc;
-               fmt->index = temp_index;
+               fmt->pixelformat = fmt->pixelformat;
                return 0;
        }
        return -EINVAL;
@@ -1785,6 +1750,7 @@ static int vpfe_probe(struct platform_device *pdev)
        vfd->ioctl_ops          = &vpfe_ioctl_ops;
        vfd->tvnorms            = 0;
        vfd->v4l2_dev           = &vpfe_dev->v4l2_dev;
+       vfd->device_caps        = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
        snprintf(vfd->name, sizeof(vfd->name),
                 "%s_V%d.%d.%d",
                 CAPTURE_DRV_NAME,
index f0f7ef638c56c174d5ec09d3397cc9818191cb51..71f4fe882d138f4f69abd16309a221c8490f7de7 100644 (file)
@@ -938,17 +938,10 @@ static int vpif_enum_fmt_vid_cap(struct file *file, void  *priv,
        }
 
        /* Fill in the information about format */
-       if (ch->vpifparams.iface.if_type == VPIF_IF_RAW_BAYER) {
-               fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               strscpy(fmt->description, "Raw Mode -Bayer Pattern GrRBGb",
-                       sizeof(fmt->description));
+       if (ch->vpifparams.iface.if_type == VPIF_IF_RAW_BAYER)
                fmt->pixelformat = V4L2_PIX_FMT_SBGGR8;
-       } else {
-               fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               strscpy(fmt->description, "YCbCr4:2:2 Semi-Planar",
-                       sizeof(fmt->description));
+       else
                fmt->pixelformat = V4L2_PIX_FMT_NV16;
-       }
        return 0;
 }
 
@@ -979,7 +972,6 @@ static int vpif_try_fmt_vid_cap(struct file *file, void *priv,
                pixfmt->bytesperline = common->fmt.fmt.pix.width * 2;
                pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
        }
-       pixfmt->priv = 0;
 
        dev_dbg(vpif_dev, "%s: %d x %d; pitch=%d pixelformat=0x%08x, field=%d, size=%d\n", __func__,
                pixfmt->width, pixfmt->height,
@@ -1085,8 +1077,6 @@ static int vpif_querycap(struct file *file, void  *priv,
 {
        struct vpif_capture_config *config = vpif_dev->platform_data;
 
-       cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
        strscpy(cap->driver, VPIF_DRIVER_NAME, sizeof(cap->driver));
        snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
                 dev_name(vpif_dev));
@@ -1473,6 +1463,7 @@ static int vpif_probe_complete(void)
                vdev->vfl_dir = VFL_DIR_RX;
                vdev->queue = q;
                vdev->lock = &common->lock;
+               vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
                video_set_drvdata(&ch->video_dev, ch);
                err = video_register_device(vdev,
                                            VFL_TYPE_GRABBER, (j ? 1 : 0));
@@ -1511,6 +1502,7 @@ static struct vpif_capture_config *
 vpif_capture_get_pdata(struct platform_device *pdev)
 {
        struct device_node *endpoint = NULL;
+       struct device_node *rem = NULL;
        struct vpif_capture_config *pdata;
        struct vpif_subdev_info *sdinfo;
        struct vpif_capture_chan_config *chan;
@@ -1541,7 +1533,6 @@ vpif_capture_get_pdata(struct platform_device *pdev)
 
        for (i = 0; i < VPIF_CAPTURE_NUM_CHANNELS; i++) {
                struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
-               struct device_node *rem;
                unsigned int flags;
                int err;
 
@@ -1554,7 +1545,6 @@ vpif_capture_get_pdata(struct platform_device *pdev)
                if (!rem) {
                        dev_dbg(&pdev->dev, "Remote device at %pOF not found\n",
                                endpoint);
-                       of_node_put(endpoint);
                        goto done;
                }
 
@@ -1564,11 +1554,8 @@ vpif_capture_get_pdata(struct platform_device *pdev)
                                            VPIF_CAPTURE_NUM_CHANNELS,
                                            sizeof(*chan->inputs),
                                            GFP_KERNEL);
-               if (!chan->inputs) {
-                       of_node_put(rem);
-                       of_node_put(endpoint);
+               if (!chan->inputs)
                        goto err_cleanup;
-               }
 
                chan->input_count++;
                chan->inputs[i].input.type = V4L2_INPUT_TYPE_CAMERA;
@@ -1577,7 +1564,6 @@ vpif_capture_get_pdata(struct platform_device *pdev)
 
                err = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint),
                                                 &bus_cfg);
-               of_node_put(endpoint);
                if (err) {
                        dev_err(&pdev->dev, "Could not parse the endpoint\n");
                        of_node_put(rem);
@@ -1601,13 +1587,14 @@ vpif_capture_get_pdata(struct platform_device *pdev)
                pdata->asd[i] = v4l2_async_notifier_add_fwnode_subdev(
                        &vpif_obj.notifier, of_fwnode_handle(rem),
                        sizeof(struct v4l2_async_subdev));
-               if (IS_ERR(pdata->asd[i])) {
-                       of_node_put(rem);
+               if (IS_ERR(pdata->asd[i]))
                        goto err_cleanup;
-               }
+
+               of_node_put(rem);
        }
 
 done:
+       of_node_put(endpoint);
        pdata->asd_sizes[0] = i;
        pdata->subdev_count = i;
        pdata->card_name = "DA850/OMAP-L138 Video Capture";
@@ -1615,6 +1602,8 @@ vpif_capture_get_pdata(struct platform_device *pdev)
        return pdata;
 
 err_cleanup:
+       of_node_put(rem);
+       of_node_put(endpoint);
        v4l2_async_notifier_cleanup(&vpif_obj.notifier);
 
        return NULL;
index a69897c68a50f9031d942861bf1c58821f6c1b90..abbdbac08e6f4664feedd7f6144ffcab72d4c046 100644 (file)
@@ -584,8 +584,6 @@ static int vpif_querycap(struct file *file, void  *priv,
 {
        struct vpif_display_config *config = vpif_dev->platform_data;
 
-       cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
        strscpy(cap->driver, VPIF_DRIVER_NAME, sizeof(cap->driver));
        snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
                 dev_name(vpif_dev));
@@ -601,11 +599,7 @@ static int vpif_enum_fmt_vid_out(struct file *file, void  *priv,
                return -EINVAL;
 
        /* Fill in the information about format */
-       fmt->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-       strscpy(fmt->description, "YCbCr4:2:2 YC Planar",
-               sizeof(fmt->description));
        fmt->pixelformat = V4L2_PIX_FMT_YUV422P;
-       fmt->flags = 0;
        return 0;
 }
 
@@ -1218,6 +1212,7 @@ static int vpif_probe_complete(void)
                vdev->vfl_dir = VFL_DIR_TX;
                vdev->queue = q;
                vdev->lock = &common->lock;
+               vdev->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
                video_set_drvdata(&ch->video_dev, ch);
                err = video_register_device(vdev, VFL_TYPE_GRABBER,
                                            (j ? 3 : 2));
index 854869f0024e041717dbbba16f3d3048adde83f5..f6650b45bc3d2184898f4d1e8169827c8001f779 100644 (file)
 
 static const struct gsc_fmt gsc_formats[] = {
        {
-               .name           = "RGB565",
                .pixelformat    = V4L2_PIX_FMT_RGB565X,
                .depth          = { 16 },
                .color          = GSC_RGB,
                .num_planes     = 1,
                .num_comp       = 1,
        }, {
-               .name           = "BGRX-8-8-8-8, 32 bpp",
                .pixelformat    = V4L2_PIX_FMT_BGR32,
                .depth          = { 32 },
                .color          = GSC_RGB,
                .num_planes     = 1,
                .num_comp       = 1,
        }, {
-               .name           = "YUV 4:2:2 packed, YCbYCr",
                .pixelformat    = V4L2_PIX_FMT_YUYV,
                .depth          = { 16 },
                .color          = GSC_YUV422,
@@ -51,7 +48,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_comp       = 1,
                .mbus_code      = MEDIA_BUS_FMT_YUYV8_2X8,
        }, {
-               .name           = "YUV 4:2:2 packed, CbYCrY",
                .pixelformat    = V4L2_PIX_FMT_UYVY,
                .depth          = { 16 },
                .color          = GSC_YUV422,
@@ -61,7 +57,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_comp       = 1,
                .mbus_code      = MEDIA_BUS_FMT_UYVY8_2X8,
        }, {
-               .name           = "YUV 4:2:2 packed, CrYCbY",
                .pixelformat    = V4L2_PIX_FMT_VYUY,
                .depth          = { 16 },
                .color          = GSC_YUV422,
@@ -71,7 +66,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_comp       = 1,
                .mbus_code      = MEDIA_BUS_FMT_VYUY8_2X8,
        }, {
-               .name           = "YUV 4:2:2 packed, YCrYCb",
                .pixelformat    = V4L2_PIX_FMT_YVYU,
                .depth          = { 16 },
                .color          = GSC_YUV422,
@@ -81,7 +75,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_comp       = 1,
                .mbus_code      = MEDIA_BUS_FMT_YVYU8_2X8,
        }, {
-               .name           = "YUV 4:4:4 planar, YCbYCr",
                .pixelformat    = V4L2_PIX_FMT_YUV32,
                .depth          = { 32 },
                .color          = GSC_YUV444,
@@ -90,7 +83,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_planes     = 1,
                .num_comp       = 1,
        }, {
-               .name           = "YUV 4:2:2 planar, Y/Cb/Cr",
                .pixelformat    = V4L2_PIX_FMT_YUV422P,
                .depth          = { 16 },
                .color          = GSC_YUV422,
@@ -99,7 +91,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_planes     = 1,
                .num_comp       = 3,
        }, {
-               .name           = "YUV 4:2:2 planar, Y/CbCr",
                .pixelformat    = V4L2_PIX_FMT_NV16,
                .depth          = { 16 },
                .color          = GSC_YUV422,
@@ -108,7 +99,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_planes     = 1,
                .num_comp       = 2,
        }, {
-               .name           = "YUV 4:2:2 non-contig, Y/CbCr",
                .pixelformat    = V4L2_PIX_FMT_NV16M,
                .depth          = { 8, 8 },
                .color          = GSC_YUV422,
@@ -117,7 +107,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_planes     = 2,
                .num_comp       = 2,
        }, {
-               .name           = "YUV 4:2:2 planar, Y/CrCb",
                .pixelformat    = V4L2_PIX_FMT_NV61,
                .depth          = { 16 },
                .color          = GSC_YUV422,
@@ -126,7 +115,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_planes     = 1,
                .num_comp       = 2,
        }, {
-               .name           = "YUV 4:2:2 non-contig, Y/CrCb",
                .pixelformat    = V4L2_PIX_FMT_NV61M,
                .depth          = { 8, 8 },
                .color          = GSC_YUV422,
@@ -135,7 +123,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_planes     = 2,
                .num_comp       = 2,
        }, {
-               .name           = "YUV 4:2:0 planar, YCbCr",
                .pixelformat    = V4L2_PIX_FMT_YUV420,
                .depth          = { 12 },
                .color          = GSC_YUV420,
@@ -144,7 +131,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_planes     = 1,
                .num_comp       = 3,
        }, {
-               .name           = "YUV 4:2:0 planar, YCrCb",
                .pixelformat    = V4L2_PIX_FMT_YVU420,
                .depth          = { 12 },
                .color          = GSC_YUV420,
@@ -154,7 +140,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_comp       = 3,
 
        }, {
-               .name           = "YUV 4:2:0 planar, Y/CbCr",
                .pixelformat    = V4L2_PIX_FMT_NV12,
                .depth          = { 12 },
                .color          = GSC_YUV420,
@@ -163,7 +148,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_planes     = 1,
                .num_comp       = 2,
        }, {
-               .name           = "YUV 4:2:0 planar, Y/CrCb",
                .pixelformat    = V4L2_PIX_FMT_NV21,
                .depth          = { 12 },
                .color          = GSC_YUV420,
@@ -172,7 +156,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_planes     = 1,
                .num_comp       = 2,
        }, {
-               .name           = "YUV 4:2:0 non-contig. 2p, Y/CrCb",
                .pixelformat    = V4L2_PIX_FMT_NV21M,
                .depth          = { 8, 4 },
                .color          = GSC_YUV420,
@@ -181,7 +164,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_planes     = 2,
                .num_comp       = 2,
        }, {
-               .name           = "YUV 4:2:0 non-contig. 2p, Y/CbCr",
                .pixelformat    = V4L2_PIX_FMT_NV12M,
                .depth          = { 8, 4 },
                .color          = GSC_YUV420,
@@ -190,7 +172,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_planes     = 2,
                .num_comp       = 2,
        }, {
-               .name           = "YUV 4:2:0 non-contig. 3p, Y/Cb/Cr",
                .pixelformat    = V4L2_PIX_FMT_YUV420M,
                .depth          = { 8, 2, 2 },
                .color          = GSC_YUV420,
@@ -199,7 +180,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_planes     = 3,
                .num_comp       = 3,
        }, {
-               .name           = "YUV 4:2:0 non-contig. 3p, Y/Cr/Cb",
                .pixelformat    = V4L2_PIX_FMT_YVU420M,
                .depth          = { 8, 2, 2 },
                .color          = GSC_YUV420,
@@ -208,7 +188,6 @@ static const struct gsc_fmt gsc_formats[] = {
                .num_planes     = 3,
                .num_comp       = 3,
        }, {
-               .name           = "YUV 4:2:0 n.c. 2p, Y/CbCr tiled",
                .pixelformat    = V4L2_PIX_FMT_NV12MT_16X16,
                .depth          = { 8, 4 },
                .color          = GSC_YUV420,
@@ -335,7 +314,6 @@ int gsc_enum_fmt(struct v4l2_fmtdesc *f)
        if (!fmt)
                return -EINVAL;
 
-       strscpy(f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->pixelformat;
 
        return 0;
index 772183b090c26b09ab1780cde0b56c4eef22a643..8e5a9acb78aad4bc99f0423c73f3d0f6f1f11a67 100644 (file)
@@ -103,7 +103,6 @@ enum gsc_yuv_fmt {
 /**
  * struct gsc_fmt - the driver's internal color format data
  * @mbus_code: Media Bus pixel code, -1 if not applicable
- * @name: format description
  * @pixelformat: the fourcc code for this format, 0 if not applicable
  * @yorder: Y/C order
  * @corder: Chrominance order control
@@ -114,7 +113,6 @@ enum gsc_yuv_fmt {
  */
 struct gsc_fmt {
        u32 mbus_code;
-       char    *name;
        u32     pixelformat;
        u32     color;
        u32     yorder;
index 66510365dd5dd19f131eaeb4f90a5c06a55dcfd2..121d609ff85686035c2c81905bc43d7196ed24b5 100644 (file)
@@ -738,10 +738,7 @@ static int fimc_cap_enum_fmt(struct file *file, void *priv,
                               f->index);
        if (!fmt)
                return -EINVAL;
-       strscpy(f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->fourcc;
-       if (fmt->fourcc == MEDIA_BUS_FMT_JPEG_1X8)
-               f->flags |= V4L2_FMT_FLAG_COMPRESSED;
        return 0;
 }
 
index 7006f54bfee2456f3d2cd37bad43373fe5b80877..cde60fbb23a88d02493ab785e47db077be3ca50b 100644 (file)
@@ -36,7 +36,6 @@ static char *fimc_clocks[MAX_FIMC_CLOCKS] = {
 
 static struct fimc_fmt fimc_formats[] = {
        {
-               .name           = "RGB565",
                .fourcc         = V4L2_PIX_FMT_RGB565,
                .depth          = { 16 },
                .color          = FIMC_FMT_RGB565,
@@ -44,7 +43,6 @@ static struct fimc_fmt fimc_formats[] = {
                .colplanes      = 1,
                .flags          = FMT_FLAGS_M2M,
        }, {
-               .name           = "BGR666",
                .fourcc         = V4L2_PIX_FMT_BGR666,
                .depth          = { 32 },
                .color          = FIMC_FMT_RGB666,
@@ -52,7 +50,6 @@ static struct fimc_fmt fimc_formats[] = {
                .colplanes      = 1,
                .flags          = FMT_FLAGS_M2M,
        }, {
-               .name           = "BGRA8888, 32 bpp",
                .fourcc         = V4L2_PIX_FMT_BGR32,
                .depth          = { 32 },
                .color          = FIMC_FMT_RGB888,
@@ -60,7 +57,6 @@ static struct fimc_fmt fimc_formats[] = {
                .colplanes      = 1,
                .flags          = FMT_FLAGS_M2M | FMT_HAS_ALPHA,
        }, {
-               .name           = "ARGB1555",
                .fourcc         = V4L2_PIX_FMT_RGB555,
                .depth          = { 16 },
                .color          = FIMC_FMT_RGB555,
@@ -68,7 +64,6 @@ static struct fimc_fmt fimc_formats[] = {
                .colplanes      = 1,
                .flags          = FMT_FLAGS_M2M_OUT | FMT_HAS_ALPHA,
        }, {
-               .name           = "ARGB4444",
                .fourcc         = V4L2_PIX_FMT_RGB444,
                .depth          = { 16 },
                .color          = FIMC_FMT_RGB444,
@@ -76,11 +71,9 @@ static struct fimc_fmt fimc_formats[] = {
                .colplanes      = 1,
                .flags          = FMT_FLAGS_M2M_OUT | FMT_HAS_ALPHA,
        }, {
-               .name           = "YUV 4:4:4",
                .mbus_code      = MEDIA_BUS_FMT_YUV10_1X30,
                .flags          = FMT_FLAGS_WRITEBACK,
        }, {
-               .name           = "YUV 4:2:2 packed, YCbYCr",
                .fourcc         = V4L2_PIX_FMT_YUYV,
                .depth          = { 16 },
                .color          = FIMC_FMT_YCBYCR422,
@@ -89,7 +82,6 @@ static struct fimc_fmt fimc_formats[] = {
                .mbus_code      = MEDIA_BUS_FMT_YUYV8_2X8,
                .flags          = FMT_FLAGS_M2M | FMT_FLAGS_CAM,
        }, {
-               .name           = "YUV 4:2:2 packed, CbYCrY",
                .fourcc         = V4L2_PIX_FMT_UYVY,
                .depth          = { 16 },
                .color          = FIMC_FMT_CBYCRY422,
@@ -98,7 +90,6 @@ static struct fimc_fmt fimc_formats[] = {
                .mbus_code      = MEDIA_BUS_FMT_UYVY8_2X8,
                .flags          = FMT_FLAGS_M2M | FMT_FLAGS_CAM,
        }, {
-               .name           = "YUV 4:2:2 packed, CrYCbY",
                .fourcc         = V4L2_PIX_FMT_VYUY,
                .depth          = { 16 },
                .color          = FIMC_FMT_CRYCBY422,
@@ -107,7 +98,6 @@ static struct fimc_fmt fimc_formats[] = {
                .mbus_code      = MEDIA_BUS_FMT_VYUY8_2X8,
                .flags          = FMT_FLAGS_M2M | FMT_FLAGS_CAM,
        }, {
-               .name           = "YUV 4:2:2 packed, YCrYCb",
                .fourcc         = V4L2_PIX_FMT_YVYU,
                .depth          = { 16 },
                .color          = FIMC_FMT_YCRYCB422,
@@ -116,7 +106,6 @@ static struct fimc_fmt fimc_formats[] = {
                .mbus_code      = MEDIA_BUS_FMT_YVYU8_2X8,
                .flags          = FMT_FLAGS_M2M | FMT_FLAGS_CAM,
        }, {
-               .name           = "YUV 4:2:2 planar, Y/Cb/Cr",
                .fourcc         = V4L2_PIX_FMT_YUV422P,
                .depth          = { 16 },
                .color          = FIMC_FMT_YCBYCR422,
@@ -124,7 +113,6 @@ static struct fimc_fmt fimc_formats[] = {
                .colplanes      = 3,
                .flags          = FMT_FLAGS_M2M,
        }, {
-               .name           = "YUV 4:2:2 planar, Y/CbCr",
                .fourcc         = V4L2_PIX_FMT_NV16,
                .depth          = { 16 },
                .color          = FIMC_FMT_YCBYCR422,
@@ -132,7 +120,6 @@ static struct fimc_fmt fimc_formats[] = {
                .colplanes      = 2,
                .flags          = FMT_FLAGS_M2M,
        }, {
-               .name           = "YUV 4:2:2 planar, Y/CrCb",
                .fourcc         = V4L2_PIX_FMT_NV61,
                .depth          = { 16 },
                .color          = FIMC_FMT_YCRYCB422,
@@ -140,7 +127,6 @@ static struct fimc_fmt fimc_formats[] = {
                .colplanes      = 2,
                .flags          = FMT_FLAGS_M2M,
        }, {
-               .name           = "YUV 4:2:0 planar, YCbCr",
                .fourcc         = V4L2_PIX_FMT_YUV420,
                .depth          = { 12 },
                .color          = FIMC_FMT_YCBCR420,
@@ -148,7 +134,6 @@ static struct fimc_fmt fimc_formats[] = {
                .colplanes      = 3,
                .flags          = FMT_FLAGS_M2M,
        }, {
-               .name           = "YUV 4:2:0 planar, Y/CbCr",
                .fourcc         = V4L2_PIX_FMT_NV12,
                .depth          = { 12 },
                .color          = FIMC_FMT_YCBCR420,
@@ -156,7 +141,6 @@ static struct fimc_fmt fimc_formats[] = {
                .colplanes      = 2,
                .flags          = FMT_FLAGS_M2M,
        }, {
-               .name           = "YUV 4:2:0 non-contig. 2p, Y/CbCr",
                .fourcc         = V4L2_PIX_FMT_NV12M,
                .color          = FIMC_FMT_YCBCR420,
                .depth          = { 8, 4 },
@@ -164,7 +148,6 @@ static struct fimc_fmt fimc_formats[] = {
                .colplanes      = 2,
                .flags          = FMT_FLAGS_M2M,
        }, {
-               .name           = "YUV 4:2:0 non-contig. 3p, Y/Cb/Cr",
                .fourcc         = V4L2_PIX_FMT_YUV420M,
                .color          = FIMC_FMT_YCBCR420,
                .depth          = { 8, 2, 2 },
@@ -172,7 +155,6 @@ static struct fimc_fmt fimc_formats[] = {
                .colplanes      = 3,
                .flags          = FMT_FLAGS_M2M,
        }, {
-               .name           = "YUV 4:2:0 non-contig. 2p, tiled",
                .fourcc         = V4L2_PIX_FMT_NV12MT,
                .color          = FIMC_FMT_YCBCR420,
                .depth          = { 8, 4 },
@@ -180,7 +162,6 @@ static struct fimc_fmt fimc_formats[] = {
                .colplanes      = 2,
                .flags          = FMT_FLAGS_M2M,
        }, {
-               .name           = "JPEG encoded data",
                .fourcc         = V4L2_PIX_FMT_JPEG,
                .color          = FIMC_FMT_JPEG,
                .depth          = { 8 },
@@ -189,7 +170,6 @@ static struct fimc_fmt fimc_formats[] = {
                .mbus_code      = MEDIA_BUS_FMT_JPEG_1X8,
                .flags          = FMT_FLAGS_CAM | FMT_FLAGS_COMPRESSED,
        }, {
-               .name           = "S5C73MX interleaved UYVY/JPEG",
                .fourcc         = V4L2_PIX_FMT_S5C_UYVY_JPG,
                .color          = FIMC_FMT_YUYV_JPEG,
                .depth          = { 8 },
index e043d55133a315aa86fccbfe26f7e0cd114a9c08..b7cc8e651e327619a95781c5ca7d4d23c75e24b2 100644 (file)
@@ -806,6 +806,7 @@ static int fimc_is_probe(struct platform_device *pdev)
                return -ENODEV;
 
        is->pmu_regs = of_iomap(node, 0);
+       of_node_put(node);
        if (!is->pmu_regs)
                return -ENOMEM;
 
index a75f932a289a9cecb5e0b596b7cb74e43ed3fcf2..378cc302e1f8e32f8629a9c2b2f71caf2b59dd29 100644 (file)
@@ -362,7 +362,6 @@ static int isp_video_enum_fmt(struct file *file, void *priv,
        if (WARN_ON(fmt == NULL))
                return -EINVAL;
 
-       strscpy(f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->fourcc;
 
        return 0;
index 907b83e6649d859cef8ca105fd03b87adfc9b104..cde0d254ec1c4f9f5c0beb2ae7b89891cd60aa7c 100644 (file)
@@ -33,21 +33,18 @@ module_param_named(debug_isp, fimc_isp_debug, int, S_IRUGO | S_IWUSR);
 
 static const struct fimc_fmt fimc_isp_formats[FIMC_ISP_NUM_FORMATS] = {
        {
-               .name           = "RAW8 (GRBG)",
                .fourcc         = V4L2_PIX_FMT_SGRBG8,
                .depth          = { 8 },
                .color          = FIMC_FMT_RAW8,
                .memplanes      = 1,
                .mbus_code      = MEDIA_BUS_FMT_SGRBG8_1X8,
        }, {
-               .name           = "RAW10 (GRBG)",
                .fourcc         = V4L2_PIX_FMT_SGRBG10,
                .depth          = { 10 },
                .color          = FIMC_FMT_RAW10,
                .memplanes      = 1,
                .mbus_code      = MEDIA_BUS_FMT_SGRBG10_1X10,
        }, {
-               .name           = "RAW12 (GRBG)",
                .fourcc         = V4L2_PIX_FMT_SGRBG12,
                .depth          = { 12 },
                .color          = FIMC_FMT_RAW12,
index c1f0aee02e5e902de019948a97df6902b5320b81..e87c6a09205bda207bfc9900b95312bfaebbe92c 100644 (file)
@@ -39,7 +39,6 @@ module_param(debug, int, 0644);
 
 static const struct fimc_fmt fimc_lite_formats[] = {
        {
-               .name           = "YUV 4:2:2 packed, YCbYCr",
                .fourcc         = V4L2_PIX_FMT_YUYV,
                .colorspace     = V4L2_COLORSPACE_JPEG,
                .depth          = { 16 },
@@ -48,7 +47,6 @@ static const struct fimc_fmt fimc_lite_formats[] = {
                .mbus_code      = MEDIA_BUS_FMT_YUYV8_2X8,
                .flags          = FMT_FLAGS_YUV,
        }, {
-               .name           = "YUV 4:2:2 packed, CbYCrY",
                .fourcc         = V4L2_PIX_FMT_UYVY,
                .colorspace     = V4L2_COLORSPACE_JPEG,
                .depth          = { 16 },
@@ -57,7 +55,6 @@ static const struct fimc_fmt fimc_lite_formats[] = {
                .mbus_code      = MEDIA_BUS_FMT_UYVY8_2X8,
                .flags          = FMT_FLAGS_YUV,
        }, {
-               .name           = "YUV 4:2:2 packed, CrYCbY",
                .fourcc         = V4L2_PIX_FMT_VYUY,
                .colorspace     = V4L2_COLORSPACE_JPEG,
                .depth          = { 16 },
@@ -66,7 +63,6 @@ static const struct fimc_fmt fimc_lite_formats[] = {
                .mbus_code      = MEDIA_BUS_FMT_VYUY8_2X8,
                .flags          = FMT_FLAGS_YUV,
        }, {
-               .name           = "YUV 4:2:2 packed, YCrYCb",
                .fourcc         = V4L2_PIX_FMT_YVYU,
                .colorspace     = V4L2_COLORSPACE_JPEG,
                .depth          = { 16 },
@@ -75,7 +71,6 @@ static const struct fimc_fmt fimc_lite_formats[] = {
                .mbus_code      = MEDIA_BUS_FMT_YVYU8_2X8,
                .flags          = FMT_FLAGS_YUV,
        }, {
-               .name           = "RAW8 (GRBG)",
                .fourcc         = V4L2_PIX_FMT_SGRBG8,
                .colorspace     = V4L2_COLORSPACE_SRGB,
                .depth          = { 8 },
@@ -84,7 +79,6 @@ static const struct fimc_fmt fimc_lite_formats[] = {
                .mbus_code      = MEDIA_BUS_FMT_SGRBG8_1X8,
                .flags          = FMT_FLAGS_RAW_BAYER,
        }, {
-               .name           = "RAW10 (GRBG)",
                .fourcc         = V4L2_PIX_FMT_SGRBG10,
                .colorspace     = V4L2_COLORSPACE_SRGB,
                .depth          = { 16 },
@@ -93,7 +87,6 @@ static const struct fimc_fmt fimc_lite_formats[] = {
                .mbus_code      = MEDIA_BUS_FMT_SGRBG10_1X10,
                .flags          = FMT_FLAGS_RAW_BAYER,
        }, {
-               .name           = "RAW12 (GRBG)",
                .fourcc         = V4L2_PIX_FMT_SGRBG12,
                .colorspace     = V4L2_COLORSPACE_SRGB,
                .depth          = { 16 },
@@ -667,7 +660,6 @@ static int fimc_lite_enum_fmt(struct file *file, void *priv,
                return -EINVAL;
 
        fmt = &fimc_lite_formats[f->index];
-       strscpy(f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->fourcc;
 
        return 0;
index 62e876fc35554a804190b14bdf441b6168e46c72..c70c2cbe3eb1b38b5920584d273ae1fe1da72b0e 100644 (file)
@@ -247,7 +247,6 @@ static int fimc_m2m_enum_fmt(struct file *file, void *priv,
        if (!fmt)
                return -EINVAL;
 
-       strscpy(f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->fourcc;
        return 0;
 }
index d53427a8db11d180eb74c6881baa3ffd4170c9fb..a838189d449024d743139c94468ad47bd6794c10 100644 (file)
@@ -501,6 +501,7 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
                        continue;
 
                ret = fimc_md_parse_port_node(fmd, port, index);
+               of_node_put(port);
                if (ret < 0) {
                        of_node_put(node);
                        goto cleanup;
@@ -542,6 +543,7 @@ static int __of_get_csis_id(struct device_node *np)
        if (!np)
                return -EINVAL;
        of_property_read_u32(np, "reg", &reg);
+       of_node_put(np);
        return reg - FIMC_INPUT_MIPI_CSI2_0;
 }
 
index 3e9ac6066cf6e25a043ed5c383bb2c859846cb5d..b9f1cc42b0ab9729a1d416d77a25e632f3dfbf45 100644 (file)
@@ -803,10 +803,8 @@ static int s5pcsis_probe(struct platform_device *pdev)
                return PTR_ERR(state->regs);
 
        state->irq = platform_get_irq(pdev, 0);
-       if (state->irq < 0) {
-               dev_err(dev, "Failed to get irq\n");
+       if (state->irq < 0)
                return state->irq;
-       }
 
        for (i = 0; i < CSIS_NUM_SUPPLIES; i++)
                state->supplies[i].supply = csis_supply_name[i];
index 691be788e38b36574e5af88a71a711d6f53b092a..bb64152acf94245ed29624f3101c4bebd02bc01d 100644 (file)
@@ -32,7 +32,7 @@
 #define VIU_VERSION            "0.5.1"
 
 /* Allow building this driver with COMPILE_TEST */
-#ifndef CONFIG_PPC
+#if !defined(CONFIG_PPC) && !defined(CONFIG_MICROBLAZE)
 #define out_be32(v, a) iowrite32be(a, (void __iomem *)v)
 #define in_be32(a)     ioread32be((void __iomem *)a)
 #endif
@@ -563,11 +563,6 @@ static int vidioc_querycap(struct file *file, void *priv,
        strscpy(cap->driver, "viu", sizeof(cap->driver));
        strscpy(cap->card, "viu", sizeof(cap->card));
        strscpy(cap->bus_info, "platform:viu", sizeof(cap->bus_info));
-       cap->device_caps =      V4L2_CAP_VIDEO_CAPTURE |
-                               V4L2_CAP_STREAMING     |
-                               V4L2_CAP_VIDEO_OVERLAY |
-                               V4L2_CAP_READWRITE;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
        return 0;
 }
 
@@ -1380,6 +1375,8 @@ static const struct video_device viu_template = {
        .release        = video_device_release,
 
        .tvnorms        = V4L2_STD_NTSC_M | V4L2_STD_PAL,
+       .device_caps    = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
+                         V4L2_CAP_VIDEO_OVERLAY | V4L2_CAP_READWRITE,
 };
 
 static int viu_of_probe(struct platform_device *op)
index 8e7ef23b9a7edd74dd4b954d2b63d9d3748fa6c3..38d9423223025382d0e529dc82cc3229a8597765 100644 (file)
@@ -1661,10 +1661,8 @@ static int pxp_probe(struct platform_device *pdev)
        }
 
        irq = platform_get_irq(pdev, 0);
-       if (irq < 0) {
-               dev_err(&pdev->dev, "Failed to get irq resource: %d\n", irq);
+       if (irq < 0)
                return irq;
-       }
 
        ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, pxp_irq_handler,
                        IRQF_ONESHOT, dev_name(&pdev->dev), dev);
index beb7fd7442fb7e43d87bd24dd5493ebd59f45702..9ad24c86c5abc10f753cd5c0a61187908d53fd3f 100644 (file)
@@ -37,7 +37,6 @@ module_param(debug, bool, 0644);
        v4l2_dbg(1, debug, &dev->v4l2_dev, "%s: " fmt, __func__, ## arg)
 
 struct deinterlace_fmt {
-       char    *name;
        u32     fourcc;
        /* Types the format can be used for */
        u32     types;
@@ -45,12 +44,10 @@ struct deinterlace_fmt {
 
 static struct deinterlace_fmt formats[] = {
        {
-               .name   = "YUV 4:2:0 Planar",
                .fourcc = V4L2_PIX_FMT_YUV420,
                .types  = MEM2MEM_CAPTURE | MEM2MEM_OUTPUT,
        },
        {
-               .name   = "YUYV 4:2:2",
                .fourcc = V4L2_PIX_FMT_YUYV,
                .types  = MEM2MEM_CAPTURE | MEM2MEM_OUTPUT,
        },
@@ -135,13 +132,13 @@ struct deinterlace_dev {
 };
 
 struct deinterlace_ctx {
+       struct v4l2_fh          fh;
        struct deinterlace_dev  *dev;
 
        /* Abort requested by m2m */
        int                     aborting;
        enum v4l2_colorspace    colorspace;
        dma_cookie_t            cookie;
-       struct v4l2_m2m_ctx     *m2m_ctx;
        struct dma_interleaved_template *xt;
 };
 
@@ -153,9 +150,9 @@ static int deinterlace_job_ready(void *priv)
        struct deinterlace_ctx *ctx = priv;
        struct deinterlace_dev *pcdev = ctx->dev;
 
-       if ((v4l2_m2m_num_src_bufs_ready(ctx->m2m_ctx) > 0)
-           && (v4l2_m2m_num_dst_bufs_ready(ctx->m2m_ctx) > 0)
-           && (atomic_read(&ctx->dev->busy) == 0)) {
+       if (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) > 0 &&
+           v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx) > 0 &&
+           !atomic_read(&ctx->dev->busy)) {
                dprintk(pcdev, "Task ready\n");
                return 1;
        }
@@ -174,7 +171,7 @@ static void deinterlace_job_abort(void *priv)
 
        dprintk(pcdev, "Aborting task\n");
 
-       v4l2_m2m_job_finish(pcdev->m2m_dev, ctx->m2m_ctx);
+       v4l2_m2m_job_finish(pcdev->m2m_dev, ctx->fh.m2m_ctx);
 }
 
 static void dma_callback(void *data)
@@ -185,8 +182,8 @@ static void dma_callback(void *data)
 
        atomic_set(&pcdev->busy, 0);
 
-       src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
-       dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
+       src_vb = v4l2_m2m_src_buf_remove(curr_ctx->fh.m2m_ctx);
+       dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx);
 
        dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
        dst_vb->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
@@ -197,7 +194,7 @@ static void dma_callback(void *data)
        v4l2_m2m_buf_done(src_vb, VB2_BUF_STATE_DONE);
        v4l2_m2m_buf_done(dst_vb, VB2_BUF_STATE_DONE);
 
-       v4l2_m2m_job_finish(pcdev->m2m_dev, curr_ctx->m2m_ctx);
+       v4l2_m2m_job_finish(pcdev->m2m_dev, curr_ctx->fh.m2m_ctx);
 
        dprintk(pcdev, "dma transfers completed.\n");
 }
@@ -216,8 +213,8 @@ static void deinterlace_issue_dma(struct deinterlace_ctx *ctx, int op,
        dma_addr_t p_in, p_out;
        enum dma_ctrl_flags flags;
 
-       src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
-       dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
+       src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
+       dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
 
        s_q_data = get_q_data(V4L2_BUF_TYPE_VIDEO_OUTPUT);
        s_width = s_q_data->width;
@@ -436,16 +433,7 @@ static int vidioc_querycap(struct file *file, void *priv,
 {
        strscpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver));
        strscpy(cap->card, MEM2MEM_NAME, sizeof(cap->card));
-       strscpy(cap->bus_info, MEM2MEM_NAME, sizeof(cap->card));
-       /*
-        * This is only a mem-to-mem video device. The capture and output
-        * device capability flags are left only for backward compatibility
-        * and are scheduled for removal.
-        */
-       cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT |
-                          V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
-
+       strscpy(cap->bus_info, MEM2MEM_NAME, sizeof(cap->bus_info));
        return 0;
 }
 
@@ -470,7 +458,6 @@ static int enum_fmt(struct v4l2_fmtdesc *f, u32 type)
        if (i < NUM_FORMATS) {
                /* Format found */
                fmt = &formats[i];
-               strscpy(f->description, fmt->name, sizeof(f->description));
                f->pixelformat = fmt->fourcc;
                return 0;
        }
@@ -496,7 +483,7 @@ static int vidioc_g_fmt(struct deinterlace_ctx *ctx, struct v4l2_format *f)
        struct vb2_queue *vq;
        struct deinterlace_q_data *q_data;
 
-       vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
+       vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
        if (!vq)
                return -EINVAL;
 
@@ -593,7 +580,7 @@ static int vidioc_s_fmt(struct deinterlace_ctx *ctx, struct v4l2_format *f)
        struct deinterlace_q_data *q_data;
        struct vb2_queue *vq;
 
-       vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
+       vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
        if (!vq)
                return -EINVAL;
 
@@ -666,36 +653,6 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
        return ret;
 }
 
-static int vidioc_reqbufs(struct file *file, void *priv,
-                         struct v4l2_requestbuffers *reqbufs)
-{
-       struct deinterlace_ctx *ctx = priv;
-
-       return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
-}
-
-static int vidioc_querybuf(struct file *file, void *priv,
-                          struct v4l2_buffer *buf)
-{
-       struct deinterlace_ctx *ctx = priv;
-
-       return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
-}
-
-static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-       struct deinterlace_ctx *ctx = priv;
-
-       return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-       struct deinterlace_ctx *ctx = priv;
-
-       return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
-}
-
 static int vidioc_streamon(struct file *file, void *priv,
                           enum v4l2_buf_type type)
 {
@@ -736,15 +693,7 @@ static int vidioc_streamon(struct file *file, void *priv,
                return -EINVAL;
        }
 
-       return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
-}
-
-static int vidioc_streamoff(struct file *file, void *priv,
-                           enum v4l2_buf_type type)
-{
-       struct deinterlace_ctx *ctx = priv;
-
-       return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
+       return v4l2_m2m_streamon(file, ctx->fh.m2m_ctx, type);
 }
 
 static const struct v4l2_ioctl_ops deinterlace_ioctl_ops = {
@@ -760,14 +709,15 @@ static const struct v4l2_ioctl_ops deinterlace_ioctl_ops = {
        .vidioc_try_fmt_vid_out = vidioc_try_fmt_vid_out,
        .vidioc_s_fmt_vid_out   = vidioc_s_fmt_vid_out,
 
-       .vidioc_reqbufs         = vidioc_reqbufs,
-       .vidioc_querybuf        = vidioc_querybuf,
-
-       .vidioc_qbuf            = vidioc_qbuf,
-       .vidioc_dqbuf           = vidioc_dqbuf,
+       .vidioc_reqbufs         = v4l2_m2m_ioctl_reqbufs,
+       .vidioc_querybuf        = v4l2_m2m_ioctl_querybuf,
+       .vidioc_qbuf            = v4l2_m2m_ioctl_qbuf,
+       .vidioc_dqbuf           = v4l2_m2m_ioctl_dqbuf,
+       .vidioc_prepare_buf     = v4l2_m2m_ioctl_prepare_buf,
+       .vidioc_expbuf          = v4l2_m2m_ioctl_expbuf,
 
        .vidioc_streamon        = vidioc_streamon,
-       .vidioc_streamoff       = vidioc_streamoff,
+       .vidioc_streamoff       = v4l2_m2m_ioctl_streamoff,
 };
 
 
@@ -831,7 +781,7 @@ static void deinterlace_buf_queue(struct vb2_buffer *vb)
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct deinterlace_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
 
-       v4l2_m2m_buf_queue(ctx->m2m_ctx, vbuf);
+       v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
 }
 
 static const struct vb2_ops deinterlace_qops = {
@@ -849,7 +799,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
        int ret;
 
        src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-       src_vq->io_modes = VB2_MMAP | VB2_USERPTR;
+       src_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
        src_vq->drv_priv = ctx;
        src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
        src_vq->ops = &deinterlace_qops;
@@ -868,7 +818,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
                return ret;
 
        dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       dst_vq->io_modes = VB2_MMAP | VB2_USERPTR;
+       dst_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
        dst_vq->drv_priv = ctx;
        dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
        dst_vq->ops = &deinterlace_qops;
@@ -897,12 +847,13 @@ static int deinterlace_open(struct file *file)
        if (!ctx)
                return -ENOMEM;
 
-       file->private_data = ctx;
+       v4l2_fh_init(&ctx->fh, video_devdata(file));
+       file->private_data = &ctx->fh;
        ctx->dev = pcdev;
 
-       ctx->m2m_ctx = v4l2_m2m_ctx_init(pcdev->m2m_dev, ctx, &queue_init);
-       if (IS_ERR(ctx->m2m_ctx)) {
-               int ret = PTR_ERR(ctx->m2m_ctx);
+       ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(pcdev->m2m_dev, ctx, &queue_init);
+       if (IS_ERR(ctx->fh.m2m_ctx)) {
+               int ret = PTR_ERR(ctx->fh.m2m_ctx);
 
                kfree(ctx);
                return ret;
@@ -916,8 +867,10 @@ static int deinterlace_open(struct file *file)
        }
 
        ctx->colorspace = V4L2_COLORSPACE_REC709;
+       v4l2_fh_add(&ctx->fh);
 
-       dprintk(pcdev, "Created instance %p, m2m_ctx: %p\n", ctx, ctx->m2m_ctx);
+       dprintk(pcdev, "Created instance %p, m2m_ctx: %p\n",
+               ctx, ctx->fh.m2m_ctx);
 
        return 0;
 }
@@ -929,40 +882,22 @@ static int deinterlace_release(struct file *file)
 
        dprintk(pcdev, "Releasing instance %p\n", ctx);
 
-       v4l2_m2m_ctx_release(ctx->m2m_ctx);
+       v4l2_fh_del(&ctx->fh);
+       v4l2_fh_exit(&ctx->fh);
+       v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
        kfree(ctx->xt);
        kfree(ctx);
 
        return 0;
 }
 
-static __poll_t deinterlace_poll(struct file *file,
-                                struct poll_table_struct *wait)
-{
-       struct deinterlace_ctx *ctx = file->private_data;
-       __poll_t ret;
-
-       mutex_lock(&ctx->dev->dev_mutex);
-       ret = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
-       mutex_unlock(&ctx->dev->dev_mutex);
-
-       return ret;
-}
-
-static int deinterlace_mmap(struct file *file, struct vm_area_struct *vma)
-{
-       struct deinterlace_ctx *ctx = file->private_data;
-
-       return v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
-}
-
 static const struct v4l2_file_operations deinterlace_fops = {
        .owner          = THIS_MODULE,
        .open           = deinterlace_open,
        .release        = deinterlace_release,
-       .poll           = deinterlace_poll,
+       .poll           = v4l2_m2m_fop_poll,
        .unlocked_ioctl = video_ioctl2,
-       .mmap           = deinterlace_mmap,
+       .mmap           = v4l2_m2m_fop_mmap,
 };
 
 static const struct video_device deinterlace_videodev = {
@@ -972,6 +907,7 @@ static const struct video_device deinterlace_videodev = {
        .minor          = -1,
        .release        = video_device_release_empty,
        .vfl_dir        = VFL_DIR_M2M,
+       .device_caps    = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING,
 };
 
 static const struct v4l2_m2m_ops m2m_ops = {
index dc30c48d4671dcee1d21a96b51a0e729576f96f2..803baf97f06e4a4806831fb12f11de0668762e69 100644 (file)
@@ -98,56 +98,48 @@ MODULE_PARM_DESC(buffer_mode,
        container_of(notifier, struct mcam_camera, notifier)
 
 static struct mcam_format_struct {
-       __u8 *desc;
        __u32 pixelformat;
        int bpp;   /* Bytes per pixel */
        bool planar;
        u32 mbus_code;
 } mcam_formats[] = {
        {
-               .desc           = "YUYV 4:2:2",
                .pixelformat    = V4L2_PIX_FMT_YUYV,
                .mbus_code      = MEDIA_BUS_FMT_YUYV8_2X8,
                .bpp            = 2,
                .planar         = false,
        },
        {
-               .desc           = "YVYU 4:2:2",
                .pixelformat    = V4L2_PIX_FMT_YVYU,
                .mbus_code      = MEDIA_BUS_FMT_YUYV8_2X8,
                .bpp            = 2,
                .planar         = false,
        },
        {
-               .desc           = "YUV 4:2:0 PLANAR",
                .pixelformat    = V4L2_PIX_FMT_YUV420,
                .mbus_code      = MEDIA_BUS_FMT_YUYV8_2X8,
                .bpp            = 1,
                .planar         = true,
        },
        {
-               .desc           = "YVU 4:2:0 PLANAR",
                .pixelformat    = V4L2_PIX_FMT_YVU420,
                .mbus_code      = MEDIA_BUS_FMT_YUYV8_2X8,
                .bpp            = 1,
                .planar         = true,
        },
        {
-               .desc           = "XRGB 444",
                .pixelformat    = V4L2_PIX_FMT_XRGB444,
                .mbus_code      = MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE,
                .bpp            = 2,
                .planar         = false,
        },
        {
-               .desc           = "RGB 565",
                .pixelformat    = V4L2_PIX_FMT_RGB565,
                .mbus_code      = MEDIA_BUS_FMT_RGB565_2X8_LE,
                .bpp            = 2,
                .planar         = false,
        },
        {
-               .desc           = "Raw RGB Bayer",
                .pixelformat    = V4L2_PIX_FMT_SBGGR8,
                .mbus_code      = MEDIA_BUS_FMT_SBGGR8_1X8,
                .bpp            = 1,
@@ -1357,9 +1349,6 @@ static int mcam_vidioc_querycap(struct file *file, void *priv,
        strscpy(cap->driver, "marvell_ccic", sizeof(cap->driver));
        strscpy(cap->card, "marvell_ccic", sizeof(cap->card));
        strscpy(cap->bus_info, cam->bus_info, sizeof(cap->bus_info));
-       cap->device_caps = V4L2_CAP_VIDEO_CAPTURE |
-               V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
        return 0;
 }
 
@@ -1369,8 +1358,6 @@ static int mcam_vidioc_enum_fmt_vid_cap(struct file *filp,
 {
        if (fmt->index >= N_MCAM_FMTS)
                return -EINVAL;
-       strscpy(fmt->description, mcam_formats[fmt->index].desc,
-               sizeof(fmt->description));
        fmt->pixelformat = mcam_formats[fmt->index].pixelformat;
        return 0;
 }
@@ -1698,6 +1685,8 @@ static const struct video_device mcam_v4l_template = {
        .fops = &mcam_v4l_fops,
        .ioctl_ops = &mcam_v4l_ioctl_ops,
        .release = video_device_release_empty,
+       .device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
+                      V4L2_CAP_STREAMING,
 };
 
 /* ---------------------------------------------------------------------- */
index 10559492e09ed1d2720ded7cdf213ac3ac1c534d..92b92255dac66766398e10168b2026532ecf0e4d 100644 (file)
@@ -372,6 +372,7 @@ static const struct of_device_id mmpcam_of_match[] = {
        { .compatible = "marvell,mmp2-ccic", },
        {},
 };
+MODULE_DEVICE_TABLE(of, mmpcam_of_match);
 
 static struct platform_driver mmpcam_driver = {
        .probe          = mmpcam_probe,
index fb52e5dd044a33163e994c2b94a7413d4fbe4d8c..3b39e875292e46e485a7f9635f17fcc167ddfeac 100644 (file)
 #define CECB_CTRL_TYPE_NEXT    2
 
 #define CECB_CTRL2             0x01
+
+#define CECB_CTRL2_RISE_DEL_MAX        GENMASK(4, 0)
+
 #define CECB_INTR_MASK         0x02
 #define CECB_LADD_LOW          0x05
 #define CECB_LADD_HIGH         0x06
 
 #define CECB_WAKEUPCTRL                0x31
 
+struct meson_ao_cec_g12a_data {
+       /* Setup the internal CECB_CTRL2 register */
+       bool                            ctrl2_setup;
+};
+
 struct meson_ao_cec_g12a_device {
        struct platform_device          *pdev;
        struct regmap                   *regmap;
@@ -175,6 +183,7 @@ struct meson_ao_cec_g12a_device {
        struct cec_msg                  rx_msg;
        struct clk                      *oscin;
        struct clk                      *core;
+       const struct meson_ao_cec_g12a_data *data;
 };
 
 static const struct regmap_config meson_ao_cec_g12a_regmap_conf = {
@@ -605,6 +614,10 @@ static int meson_ao_cec_g12a_adap_enable(struct cec_adapter *adap, bool enable)
        regmap_update_bits(ao_cec->regmap, CECB_GEN_CNTL_REG,
                           CECB_GEN_CNTL_RESET, 0);
 
+       if (ao_cec->data->ctrl2_setup)
+               regmap_write(ao_cec->regmap_cec, CECB_CTRL2,
+                            FIELD_PREP(CECB_CTRL2_RISE_DEL_MAX, 2));
+
        meson_ao_cec_g12a_irq_setup(ao_cec, true);
 
        return 0;
@@ -632,20 +645,28 @@ static int meson_ao_cec_g12a_probe(struct platform_device *pdev)
        if (!ao_cec)
                return -ENOMEM;
 
+       ao_cec->data = of_device_get_match_data(&pdev->dev);
+       if (!ao_cec->data) {
+               dev_err(&pdev->dev, "failed to get match data\n");
+               return -ENODEV;
+       }
+
        spin_lock_init(&ao_cec->cec_reg_lock);
        ao_cec->pdev = pdev;
 
-       ao_cec->notify = cec_notifier_get(hdmi_dev);
-       if (!ao_cec->notify)
-               return -ENOMEM;
-
        ao_cec->adap = cec_allocate_adapter(&meson_ao_cec_g12a_ops, ao_cec,
                                            "meson_g12a_ao_cec",
-                                           CEC_CAP_DEFAULTS,
+                                           CEC_CAP_DEFAULTS |
+                                           CEC_CAP_CONNECTOR_INFO,
                                            CEC_MAX_LOG_ADDRS);
-       if (IS_ERR(ao_cec->adap)) {
-               ret = PTR_ERR(ao_cec->adap);
-               goto out_probe_notify;
+       if (IS_ERR(ao_cec->adap))
+               return PTR_ERR(ao_cec->adap);
+
+       ao_cec->notify = cec_notifier_cec_adap_register(hdmi_dev, NULL,
+                                                       ao_cec->adap);
+       if (!ao_cec->notify) {
+               ret = -ENOMEM;
+               goto out_probe_adapter;
        }
 
        ao_cec->adap->owner = THIS_MODULE;
@@ -654,21 +675,21 @@ static int meson_ao_cec_g12a_probe(struct platform_device *pdev)
        base = devm_ioremap_resource(&pdev->dev, res);
        if (IS_ERR(base)) {
                ret = PTR_ERR(base);
-               goto out_probe_adapter;
+               goto out_probe_notify;
        }
 
        ao_cec->regmap = devm_regmap_init_mmio(&pdev->dev, base,
                                               &meson_ao_cec_g12a_regmap_conf);
        if (IS_ERR(ao_cec->regmap)) {
                ret = PTR_ERR(ao_cec->regmap);
-               goto out_probe_adapter;
+               goto out_probe_notify;
        }
 
        ao_cec->regmap_cec = devm_regmap_init(&pdev->dev, NULL, ao_cec,
                                           &meson_ao_cec_g12a_cec_regmap_conf);
        if (IS_ERR(ao_cec->regmap_cec)) {
                ret = PTR_ERR(ao_cec->regmap_cec);
-               goto out_probe_adapter;
+               goto out_probe_notify;
        }
 
        irq = platform_get_irq(pdev, 0);
@@ -678,24 +699,24 @@ static int meson_ao_cec_g12a_probe(struct platform_device *pdev)
                                        0, NULL, ao_cec);
        if (ret) {
                dev_err(&pdev->dev, "irq request failed\n");
-               goto out_probe_adapter;
+               goto out_probe_notify;
        }
 
        ao_cec->oscin = devm_clk_get(&pdev->dev, "oscin");
        if (IS_ERR(ao_cec->oscin)) {
                dev_err(&pdev->dev, "oscin clock request failed\n");
                ret = PTR_ERR(ao_cec->oscin);
-               goto out_probe_adapter;
+               goto out_probe_notify;
        }
 
        ret = meson_ao_cec_g12a_setup_clk(ao_cec);
        if (ret)
-               goto out_probe_adapter;
+               goto out_probe_notify;
 
        ret = clk_prepare_enable(ao_cec->core);
        if (ret) {
                dev_err(&pdev->dev, "core clock enable failed\n");
-               goto out_probe_adapter;
+               goto out_probe_notify;
        }
 
        device_reset_optional(&pdev->dev);
@@ -703,27 +724,23 @@ static int meson_ao_cec_g12a_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, ao_cec);
 
        ret = cec_register_adapter(ao_cec->adap, &pdev->dev);
-       if (ret < 0) {
-               cec_notifier_put(ao_cec->notify);
+       if (ret < 0)
                goto out_probe_core_clk;
-       }
 
        /* Setup Hardware */
        regmap_write(ao_cec->regmap, CECB_GEN_CNTL_REG, CECB_GEN_CNTL_RESET);
 
-       cec_register_cec_notifier(ao_cec->adap, ao_cec->notify);
-
        return 0;
 
 out_probe_core_clk:
        clk_disable_unprepare(ao_cec->core);
 
+out_probe_notify:
+       cec_notifier_cec_adap_unregister(ao_cec->notify);
+
 out_probe_adapter:
        cec_delete_adapter(ao_cec->adap);
 
-out_probe_notify:
-       cec_notifier_put(ao_cec->notify);
-
        dev_err(&pdev->dev, "CEC controller registration failed\n");
 
        return ret;
@@ -735,15 +752,30 @@ static int meson_ao_cec_g12a_remove(struct platform_device *pdev)
 
        clk_disable_unprepare(ao_cec->core);
 
-       cec_unregister_adapter(ao_cec->adap);
+       cec_notifier_cec_adap_unregister(ao_cec->notify);
 
-       cec_notifier_put(ao_cec->notify);
+       cec_unregister_adapter(ao_cec->adap);
 
        return 0;
 }
 
+static const struct meson_ao_cec_g12a_data ao_cec_g12a_data = {
+       .ctrl2_setup = false,
+};
+
+static const struct meson_ao_cec_g12a_data ao_cec_sm1_data = {
+       .ctrl2_setup = true,
+};
+
 static const struct of_device_id meson_ao_cec_g12a_of_match[] = {
-       { .compatible = "amlogic,meson-g12a-ao-cec", },
+       {
+               .compatible = "amlogic,meson-g12a-ao-cec",
+               .data = &ao_cec_g12a_data,
+       },
+       {
+               .compatible = "amlogic,meson-sm1-ao-cec",
+               .data = &ao_cec_sm1_data,
+       },
        { /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, meson_ao_cec_g12a_of_match);
index facf9b029e7970ad3481d3b35f4cd812db24733b..64ed549bf0120bde4bd8868864e3f4d8730dce8b 100644 (file)
@@ -616,20 +616,19 @@ static int meson_ao_cec_probe(struct platform_device *pdev)
 
        spin_lock_init(&ao_cec->cec_reg_lock);
 
-       ao_cec->notify = cec_notifier_get(hdmi_dev);
-       if (!ao_cec->notify)
-               return -ENOMEM;
-
        ao_cec->adap = cec_allocate_adapter(&meson_ao_cec_ops, ao_cec,
                                            "meson_ao_cec",
-                                           CEC_CAP_LOG_ADDRS |
-                                           CEC_CAP_TRANSMIT |
-                                           CEC_CAP_RC |
-                                           CEC_CAP_PASSTHROUGH,
+                                           CEC_CAP_DEFAULTS |
+                                           CEC_CAP_CONNECTOR_INFO,
                                            1); /* Use 1 for now */
-       if (IS_ERR(ao_cec->adap)) {
-               ret = PTR_ERR(ao_cec->adap);
-               goto out_probe_notify;
+       if (IS_ERR(ao_cec->adap))
+               return PTR_ERR(ao_cec->adap);
+
+       ao_cec->notify = cec_notifier_cec_adap_register(hdmi_dev, NULL,
+                                                       ao_cec->adap);
+       if (!ao_cec->notify) {
+               ret = -ENOMEM;
+               goto out_probe_adapter;
        }
 
        ao_cec->adap->owner = THIS_MODULE;
@@ -638,7 +637,7 @@ static int meson_ao_cec_probe(struct platform_device *pdev)
        ao_cec->base = devm_ioremap_resource(&pdev->dev, res);
        if (IS_ERR(ao_cec->base)) {
                ret = PTR_ERR(ao_cec->base);
-               goto out_probe_adapter;
+               goto out_probe_notify;
        }
 
        irq = platform_get_irq(pdev, 0);
@@ -648,20 +647,20 @@ static int meson_ao_cec_probe(struct platform_device *pdev)
                                        0, NULL, ao_cec);
        if (ret) {
                dev_err(&pdev->dev, "irq request failed\n");
-               goto out_probe_adapter;
+               goto out_probe_notify;
        }
 
        ao_cec->core = devm_clk_get(&pdev->dev, "core");
        if (IS_ERR(ao_cec->core)) {
                dev_err(&pdev->dev, "core clock request failed\n");
                ret = PTR_ERR(ao_cec->core);
-               goto out_probe_adapter;
+               goto out_probe_notify;
        }
 
        ret = clk_prepare_enable(ao_cec->core);
        if (ret) {
                dev_err(&pdev->dev, "core clock enable failed\n");
-               goto out_probe_adapter;
+               goto out_probe_notify;
        }
 
        ret = clk_set_rate(ao_cec->core, CEC_CLK_RATE);
@@ -676,28 +675,24 @@ static int meson_ao_cec_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, ao_cec);
 
        ret = cec_register_adapter(ao_cec->adap, &pdev->dev);
-       if (ret < 0) {
-               cec_notifier_put(ao_cec->notify);
+       if (ret < 0)
                goto out_probe_clk;
-       }
 
        /* Setup Hardware */
        writel_relaxed(CEC_GEN_CNTL_RESET,
                       ao_cec->base + CEC_GEN_CNTL_REG);
 
-       cec_register_cec_notifier(ao_cec->adap, ao_cec->notify);
-
        return 0;
 
 out_probe_clk:
        clk_disable_unprepare(ao_cec->core);
 
+out_probe_notify:
+       cec_notifier_cec_adap_unregister(ao_cec->notify);
+
 out_probe_adapter:
        cec_delete_adapter(ao_cec->adap);
 
-out_probe_notify:
-       cec_notifier_put(ao_cec->notify);
-
        dev_err(&pdev->dev, "CEC controller registration failed\n");
 
        return ret;
@@ -709,10 +704,9 @@ static int meson_ao_cec_remove(struct platform_device *pdev)
 
        clk_disable_unprepare(ao_cec->core);
 
+       cec_notifier_cec_adap_unregister(ao_cec->notify);
        cec_unregister_adapter(ao_cec->adap);
 
-       cec_notifier_put(ao_cec->notify);
-
        return 0;
 }
 
index c5f8f1fca44c2912a8f2dbe6431d915f198c5043..49aa85a9bb5a7f5a649e1fd1ea4db55e9edb6b91 100644 (file)
@@ -29,6 +29,9 @@
 #define H264_MAX_FB_NUM                                17
 #define HDR_PARSING_BUF_SZ                     1024
 
+#define DEC_ERR_RET(ret)                       ((ret) >> 16)
+#define H264_ERR_NOT_VALID                     3
+
 /**
  * struct h264_fb - h264 decode frame buffer information
  * @vdec_fb_va  : virtual address of struct vdec_fb
@@ -357,8 +360,11 @@ static int vdec_h264_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
        buf = (unsigned char *)bs->va;
        buf_sz = bs->size;
        nal_start_idx = find_start_code(buf, buf_sz);
-       if (nal_start_idx < 0)
+       if (nal_start_idx < 0) {
+               mtk_vcodec_err(inst, "invalid nal start code");
+               err = -EIO;
                goto err_free_fb_out;
+       }
 
        nal_start = buf[nal_start_idx];
        nal_type = NAL_TYPE(buf[nal_start_idx]);
@@ -382,8 +388,14 @@ static int vdec_h264_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
        data[0] = buf_sz;
        data[1] = nal_start;
        err = vpu_dec_start(vpu, data, 2);
-       if (err)
+       if (err) {
+               if (err > 0 && (DEC_ERR_RET(err) == H264_ERR_NOT_VALID)) {
+                       mtk_vcodec_err(inst, "- error bitstream - err = %d -",
+                                      err);
+                       err = -EIO;
+               }
                goto err_free_fb_out;
+       }
 
        *res_chg = inst->vsi->dec.resolution_changed;
        if (*res_chg) {
index 333324c75027afa45c6485476caab72ed5e9fbdc..e6c7a616b599671f9a614fb80f72817269c9f4ba 100644 (file)
@@ -145,7 +145,6 @@ module_param(debug, bool, 0644);
 #define PRP_INTR_ST_CH2OVF     (1 << 8)
 
 struct emmaprp_fmt {
-       char    *name;
        u32     fourcc;
        /* Types the format can be used for */
        u32     types;
@@ -153,12 +152,10 @@ struct emmaprp_fmt {
 
 static struct emmaprp_fmt formats[] = {
        {
-               .name   = "YUV 4:2:0 Planar",
                .fourcc = V4L2_PIX_FMT_YUV420,
                .types  = MEM2MEM_CAPTURE,
        },
        {
-               .name   = "4:2:2, packed, YUYV",
                .fourcc = V4L2_PIX_FMT_YUYV,
                .types  = MEM2MEM_OUTPUT,
        },
@@ -210,11 +207,11 @@ struct emmaprp_dev {
 };
 
 struct emmaprp_ctx {
+       struct v4l2_fh          fh;
        struct emmaprp_dev      *dev;
        /* Abort requested by m2m */
        int                     aborting;
        struct emmaprp_q_data   q_data[2];
-       struct v4l2_m2m_ctx     *m2m_ctx;
 };
 
 static struct emmaprp_q_data *get_q_data(struct emmaprp_ctx *ctx,
@@ -243,7 +240,7 @@ static void emmaprp_job_abort(void *priv)
 
        dprintk(pcdev, "Aborting task\n");
 
-       v4l2_m2m_job_finish(pcdev->m2m_dev, ctx->m2m_ctx);
+       v4l2_m2m_job_finish(pcdev->m2m_dev, ctx->fh.m2m_ctx);
 }
 
 static inline void emmaprp_dump_regs(struct emmaprp_dev *pcdev)
@@ -278,8 +275,8 @@ static void emmaprp_device_run(void *priv)
        dma_addr_t p_in, p_out;
        u32 tmp;
 
-       src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
-       dst_buf = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
+       src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
+       dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
 
        s_q_data = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
        s_width = s_q_data->width;
@@ -353,8 +350,8 @@ static irqreturn_t emmaprp_irq(int irq_emma, void *data)
                        pr_err("PrP bus error occurred, this transfer is probably corrupted\n");
                        writel(PRP_CNTL_SWRST, pcdev->base_emma + PRP_CNTL);
                } else if (irqst & PRP_INTR_ST_CH2B1CI) { /* buffer ready */
-                       src_vb = v4l2_m2m_src_buf_remove(curr_ctx->m2m_ctx);
-                       dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->m2m_ctx);
+                       src_vb = v4l2_m2m_src_buf_remove(curr_ctx->fh.m2m_ctx);
+                       dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx);
 
                        dst_vb->vb2_buf.timestamp = src_vb->vb2_buf.timestamp;
                        dst_vb->flags &=
@@ -371,7 +368,7 @@ static irqreturn_t emmaprp_irq(int irq_emma, void *data)
                }
        }
 
-       v4l2_m2m_job_finish(pcdev->m2m_dev, curr_ctx->m2m_ctx);
+       v4l2_m2m_job_finish(pcdev->m2m_dev, curr_ctx->fh.m2m_ctx);
        return IRQ_HANDLED;
 }
 
@@ -383,8 +380,6 @@ static int vidioc_querycap(struct file *file, void *priv,
 {
        strscpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver));
        strscpy(cap->card, MEM2MEM_NAME, sizeof(cap->card));
-       cap->device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
        return 0;
 }
 
@@ -409,7 +404,6 @@ static int enum_fmt(struct v4l2_fmtdesc *f, u32 type)
        if (i < NUM_FORMATS) {
                /* Format found */
                fmt = &formats[i];
-               strscpy(f->description, fmt->name, sizeof(f->description) - 1);
                f->pixelformat = fmt->fourcc;
                return 0;
        }
@@ -435,7 +429,7 @@ static int vidioc_g_fmt(struct emmaprp_ctx *ctx, struct v4l2_format *f)
        struct vb2_queue *vq;
        struct emmaprp_q_data *q_data;
 
-       vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
+       vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
        if (!vq)
                return -EINVAL;
 
@@ -540,7 +534,7 @@ static int vidioc_s_fmt(struct emmaprp_ctx *ctx, struct v4l2_format *f)
        struct vb2_queue *vq;
        int ret;
 
-       vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
+       vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
        if (!vq)
                return -EINVAL;
 
@@ -596,52 +590,6 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
        return vidioc_s_fmt(priv, f);
 }
 
-static int vidioc_reqbufs(struct file *file, void *priv,
-                         struct v4l2_requestbuffers *reqbufs)
-{
-       struct emmaprp_ctx *ctx = priv;
-
-       return v4l2_m2m_reqbufs(file, ctx->m2m_ctx, reqbufs);
-}
-
-static int vidioc_querybuf(struct file *file, void *priv,
-                          struct v4l2_buffer *buf)
-{
-       struct emmaprp_ctx *ctx = priv;
-
-       return v4l2_m2m_querybuf(file, ctx->m2m_ctx, buf);
-}
-
-static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-       struct emmaprp_ctx *ctx = priv;
-
-       return v4l2_m2m_qbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
-{
-       struct emmaprp_ctx *ctx = priv;
-
-       return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf);
-}
-
-static int vidioc_streamon(struct file *file, void *priv,
-                          enum v4l2_buf_type type)
-{
-       struct emmaprp_ctx *ctx = priv;
-
-       return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
-}
-
-static int vidioc_streamoff(struct file *file, void *priv,
-                           enum v4l2_buf_type type)
-{
-       struct emmaprp_ctx *ctx = priv;
-
-       return v4l2_m2m_streamoff(file, ctx->m2m_ctx, type);
-}
-
 static const struct v4l2_ioctl_ops emmaprp_ioctl_ops = {
        .vidioc_querycap        = vidioc_querycap,
 
@@ -655,14 +603,14 @@ static const struct v4l2_ioctl_ops emmaprp_ioctl_ops = {
        .vidioc_try_fmt_vid_out = vidioc_try_fmt_vid_out,
        .vidioc_s_fmt_vid_out   = vidioc_s_fmt_vid_out,
 
-       .vidioc_reqbufs         = vidioc_reqbufs,
-       .vidioc_querybuf        = vidioc_querybuf,
-
-       .vidioc_qbuf            = vidioc_qbuf,
-       .vidioc_dqbuf           = vidioc_dqbuf,
-
-       .vidioc_streamon        = vidioc_streamon,
-       .vidioc_streamoff       = vidioc_streamoff,
+       .vidioc_reqbufs         = v4l2_m2m_ioctl_reqbufs,
+       .vidioc_querybuf        = v4l2_m2m_ioctl_querybuf,
+       .vidioc_qbuf            = v4l2_m2m_ioctl_qbuf,
+       .vidioc_dqbuf           = v4l2_m2m_ioctl_dqbuf,
+       .vidioc_prepare_buf     = v4l2_m2m_ioctl_prepare_buf,
+       .vidioc_expbuf          = v4l2_m2m_ioctl_expbuf,
+       .vidioc_streamon        = v4l2_m2m_ioctl_streamon,
+       .vidioc_streamoff       = v4l2_m2m_ioctl_streamoff,
 };
 
 
@@ -722,7 +670,7 @@ static void emmaprp_buf_queue(struct vb2_buffer *vb)
 {
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct emmaprp_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
-       v4l2_m2m_buf_queue(ctx->m2m_ctx, vbuf);
+       v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf);
 }
 
 static const struct vb2_ops emmaprp_qops = {
@@ -740,7 +688,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
        int ret;
 
        src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-       src_vq->io_modes = VB2_MMAP | VB2_USERPTR;
+       src_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
        src_vq->drv_priv = ctx;
        src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
        src_vq->ops = &emmaprp_qops;
@@ -754,7 +702,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq,
                return ret;
 
        dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       dst_vq->io_modes = VB2_MMAP | VB2_USERPTR;
+       dst_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
        dst_vq->drv_priv = ctx;
        dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer);
        dst_vq->ops = &emmaprp_qops;
@@ -778,7 +726,8 @@ static int emmaprp_open(struct file *file)
        if (!ctx)
                return -ENOMEM;
 
-       file->private_data = ctx;
+       v4l2_fh_init(&ctx->fh, video_devdata(file));
+       file->private_data = &ctx->fh;
        ctx->dev = pcdev;
 
        if (mutex_lock_interruptible(&pcdev->dev_mutex)) {
@@ -786,10 +735,10 @@ static int emmaprp_open(struct file *file)
                return -ERESTARTSYS;
        }
 
-       ctx->m2m_ctx = v4l2_m2m_ctx_init(pcdev->m2m_dev, ctx, &queue_init);
+       ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(pcdev->m2m_dev, ctx, &queue_init);
 
-       if (IS_ERR(ctx->m2m_ctx)) {
-               int ret = PTR_ERR(ctx->m2m_ctx);
+       if (IS_ERR(ctx->fh.m2m_ctx)) {
+               int ret = PTR_ERR(ctx->fh.m2m_ctx);
 
                mutex_unlock(&pcdev->dev_mutex);
                kfree(ctx);
@@ -800,9 +749,10 @@ static int emmaprp_open(struct file *file)
        clk_prepare_enable(pcdev->clk_emma_ahb);
        ctx->q_data[V4L2_M2M_SRC].fmt = &formats[1];
        ctx->q_data[V4L2_M2M_DST].fmt = &formats[0];
+       v4l2_fh_add(&ctx->fh);
        mutex_unlock(&pcdev->dev_mutex);
 
-       dprintk(pcdev, "Created instance %p, m2m_ctx: %p\n", ctx, ctx->m2m_ctx);
+       dprintk(pcdev, "Created instance %p, m2m_ctx: %p\n", ctx, ctx->fh.m2m_ctx);
 
        return 0;
 }
@@ -817,46 +767,22 @@ static int emmaprp_release(struct file *file)
        mutex_lock(&pcdev->dev_mutex);
        clk_disable_unprepare(pcdev->clk_emma_ahb);
        clk_disable_unprepare(pcdev->clk_emma_ipg);
-       v4l2_m2m_ctx_release(ctx->m2m_ctx);
+       v4l2_fh_del(&ctx->fh);
+       v4l2_fh_exit(&ctx->fh);
+       v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
        mutex_unlock(&pcdev->dev_mutex);
        kfree(ctx);
 
        return 0;
 }
 
-static __poll_t emmaprp_poll(struct file *file,
-                                struct poll_table_struct *wait)
-{
-       struct emmaprp_dev *pcdev = video_drvdata(file);
-       struct emmaprp_ctx *ctx = file->private_data;
-       __poll_t res;
-
-       mutex_lock(&pcdev->dev_mutex);
-       res = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
-       mutex_unlock(&pcdev->dev_mutex);
-       return res;
-}
-
-static int emmaprp_mmap(struct file *file, struct vm_area_struct *vma)
-{
-       struct emmaprp_dev *pcdev = video_drvdata(file);
-       struct emmaprp_ctx *ctx = file->private_data;
-       int ret;
-
-       if (mutex_lock_interruptible(&pcdev->dev_mutex))
-               return -ERESTARTSYS;
-       ret = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
-       mutex_unlock(&pcdev->dev_mutex);
-       return ret;
-}
-
 static const struct v4l2_file_operations emmaprp_fops = {
        .owner          = THIS_MODULE,
        .open           = emmaprp_open,
        .release        = emmaprp_release,
-       .poll           = emmaprp_poll,
+       .poll           = v4l2_m2m_fop_poll,
        .unlocked_ioctl = video_ioctl2,
-       .mmap           = emmaprp_mmap,
+       .mmap           = v4l2_m2m_fop_mmap,
 };
 
 static const struct video_device emmaprp_videodev = {
@@ -866,6 +792,7 @@ static const struct video_device emmaprp_videodev = {
        .minor          = -1,
        .release        = video_device_release,
        .vfl_dir        = VFL_DIR_M2M,
+       .device_caps    = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING,
 };
 
 static const struct v4l2_m2m_ops m2m_ops = {
index cb6a9e3946b6d8fcea499e8d8f5800700e26feae..b0f03c2ca65d97c903b0dbd07fa290aa1d279502 100644 (file)
@@ -114,14 +114,12 @@ static const struct v4l2_fmtdesc omap_formats[] = {
                 *      Byte 0                    Byte 1
                 *      g2 g1 g0 b4 b3 b2 b1 b0   r4 r3 r2 r1 r0 g5 g4 g3
                 */
-               .description = "RGB565, le",
                .pixelformat = V4L2_PIX_FMT_RGB565,
        },
        {
                /* Note:  V4L2 defines RGB32 as: RGB-8-8-8-8  we use
                 *  this for RGB24 unpack mode, the last 8 bits are ignored
                 * */
-               .description = "RGB32, le",
                .pixelformat = V4L2_PIX_FMT_RGB32,
        },
        {
@@ -129,15 +127,12 @@ static const struct v4l2_fmtdesc omap_formats[] = {
                 *        this for RGB24 packed mode
                 *
                 */
-               .description = "RGB24, le",
                .pixelformat = V4L2_PIX_FMT_RGB24,
        },
        {
-               .description = "YUYV (YUV 4:2:2), packed",
                .pixelformat = V4L2_PIX_FMT_YUYV,
        },
        {
-               .description = "UYVY, packed",
                .pixelformat = V4L2_PIX_FMT_UYVY,
        },
 };
@@ -841,7 +836,7 @@ static void omap_vout_buffer_release(struct videobuf_queue *q,
 static __poll_t omap_vout_poll(struct file *file,
                                   struct poll_table_struct *wait)
 {
-       struct omap_vout_device *vout = file->private_data;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct videobuf_queue *q = &vout->vbq;
 
        return videobuf_poll_stream(file, q, wait);
@@ -876,7 +871,7 @@ static int omap_vout_mmap(struct file *file, struct vm_area_struct *vma)
        void *pos;
        unsigned long start = vma->vm_start;
        unsigned long size = (vma->vm_end - vma->vm_start);
-       struct omap_vout_device *vout = file->private_data;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct videobuf_queue *q = &vout->vbq;
 
        v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev,
@@ -935,7 +930,7 @@ static int omap_vout_release(struct file *file)
        unsigned int ret, i;
        struct videobuf_queue *q;
        struct omapvideo_info *ovid;
-       struct omap_vout_device *vout = file->private_data;
+       struct omap_vout_device *vout = video_drvdata(file);
 
        v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
        ovid = &vout->vid_info;
@@ -988,7 +983,7 @@ static int omap_vout_release(struct file *file)
                vout->mmap_count = 0;
 
        vout->opened -= 1;
-       file->private_data = NULL;
+       v4l2_fh_release(file);
 
        if (vout->buffer_allocated)
                videobuf_mmap_free(q);
@@ -1000,9 +995,8 @@ static int omap_vout_release(struct file *file)
 static int omap_vout_open(struct file *file)
 {
        struct videobuf_queue *q;
-       struct omap_vout_device *vout = NULL;
-
-       vout = video_drvdata(file);
+       struct omap_vout_device *vout = video_drvdata(file);
+       int ret;
 
        if (vout == NULL)
                return -ENODEV;
@@ -1013,9 +1007,11 @@ static int omap_vout_open(struct file *file)
        if (vout->opened)
                return -EBUSY;
 
-       vout->opened += 1;
+       ret = v4l2_fh_open(file);
+       if (ret)
+               return ret;
 
-       file->private_data = vout;
+       vout->opened += 1;
        vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
 
        q = &vout->vbq;
@@ -1039,15 +1035,11 @@ static int omap_vout_open(struct file *file)
 static int vidioc_querycap(struct file *file, void *fh,
                struct v4l2_capability *cap)
 {
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
 
        strscpy(cap->driver, VOUT_NAME, sizeof(cap->driver));
        strscpy(cap->card, vout->vfd->name, sizeof(cap->card));
        cap->bus_info[0] = '\0';
-       cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_OUTPUT |
-               V4L2_CAP_VIDEO_OUTPUT_OVERLAY;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
-
        return 0;
 }
 
@@ -1060,8 +1052,6 @@ static int vidioc_enum_fmt_vid_out(struct file *file, void *fh,
                return -EINVAL;
 
        fmt->flags = omap_formats[index].flags;
-       strscpy(fmt->description, omap_formats[index].description,
-               sizeof(fmt->description));
        fmt->pixelformat = omap_formats[index].pixelformat;
 
        return 0;
@@ -1070,7 +1060,7 @@ static int vidioc_enum_fmt_vid_out(struct file *file, void *fh,
 static int vidioc_g_fmt_vid_out(struct file *file, void *fh,
                        struct v4l2_format *f)
 {
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
 
        f->fmt.pix = vout->pix;
        return 0;
@@ -1083,7 +1073,7 @@ static int vidioc_try_fmt_vid_out(struct file *file, void *fh,
        struct omap_overlay *ovl;
        struct omapvideo_info *ovid;
        struct omap_video_timings *timing;
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct omap_dss_device *dssdev;
 
        ovid = &vout->vid_info;
@@ -1110,7 +1100,7 @@ static int vidioc_s_fmt_vid_out(struct file *file, void *fh,
        struct omap_overlay *ovl;
        struct omapvideo_info *ovid;
        struct omap_video_timings *timing;
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct omap_dss_device *dssdev;
 
        if (vout->streaming)
@@ -1176,7 +1166,7 @@ static int vidioc_try_fmt_vid_overlay(struct file *file, void *fh,
                        struct v4l2_format *f)
 {
        int ret = 0;
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct omap_overlay *ovl;
        struct omapvideo_info *ovid;
        struct v4l2_window *win = &f->fmt.win;
@@ -1202,7 +1192,7 @@ static int vidioc_s_fmt_vid_overlay(struct file *file, void *fh,
        int ret = 0;
        struct omap_overlay *ovl;
        struct omapvideo_info *ovid;
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct v4l2_window *win = &f->fmt.win;
 
        mutex_lock(&vout->lock);
@@ -1229,7 +1219,7 @@ static int vidioc_g_fmt_vid_overlay(struct file *file, void *fh,
        u32 key_value =  0;
        struct omap_overlay *ovl;
        struct omapvideo_info *ovid;
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct omap_overlay_manager_info info;
        struct v4l2_window *win = &f->fmt.win;
 
@@ -1250,7 +1240,7 @@ static int vidioc_g_fmt_vid_overlay(struct file *file, void *fh,
 
 static int vidioc_g_selection(struct file *file, void *fh, struct v4l2_selection *sel)
 {
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct v4l2_pix_format *pix = &vout->pix;
 
        if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
@@ -1277,7 +1267,7 @@ static int vidioc_g_selection(struct file *file, void *fh, struct v4l2_selection
 static int vidioc_s_selection(struct file *file, void *fh, struct v4l2_selection *sel)
 {
        int ret = -EINVAL;
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct omapvideo_info *ovid;
        struct omap_overlay *ovl;
        struct omap_video_timings *timing;
@@ -1419,7 +1409,7 @@ static int vidioc_reqbufs(struct file *file, void *fh,
 {
        int ret = 0;
        unsigned int i, num_buffers = 0;
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct videobuf_queue *q = &vout->vbq;
 
        if (req->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
@@ -1484,7 +1474,7 @@ static int vidioc_reqbufs(struct file *file, void *fh,
 static int vidioc_querybuf(struct file *file, void *fh,
                        struct v4l2_buffer *b)
 {
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
 
        return videobuf_querybuf(&vout->vbq, b);
 }
@@ -1492,7 +1482,7 @@ static int vidioc_querybuf(struct file *file, void *fh,
 static int vidioc_qbuf(struct file *file, void *fh,
                        struct v4l2_buffer *buffer)
 {
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct videobuf_queue *q = &vout->vbq;
 
        if ((V4L2_BUF_TYPE_VIDEO_OUTPUT != buffer->type) ||
@@ -1519,7 +1509,7 @@ static int vidioc_qbuf(struct file *file, void *fh,
 
 static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b)
 {
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct videobuf_queue *q = &vout->vbq;
 
        int ret;
@@ -1547,7 +1537,7 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
 {
        int ret = 0, j;
        u32 addr = 0, mask = 0;
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct videobuf_queue *q = &vout->vbq;
        struct omapvideo_info *ovid = &vout->vid_info;
 
@@ -1632,7 +1622,7 @@ static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
 {
        u32 mask = 0;
        int ret = 0, j;
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct omapvideo_info *ovid = &vout->vid_info;
 
        if (!vout->streaming)
@@ -1670,7 +1660,7 @@ static int vidioc_s_fbuf(struct file *file, void *fh,
        int enable = 0;
        struct omap_overlay *ovl;
        struct omapvideo_info *ovid;
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct omap_overlay_manager_info info;
        enum omap_dss_trans_key_type key_type = OMAP_DSS_COLOR_KEY_GFX_DST;
 
@@ -1741,7 +1731,7 @@ static int vidioc_g_fbuf(struct file *file, void *fh,
 {
        struct omap_overlay *ovl;
        struct omapvideo_info *ovid;
-       struct omap_vout_device *vout = fh;
+       struct omap_vout_device *vout = video_drvdata(file);
        struct omap_overlay_manager_info info;
 
        ovid = &vout->vid_info;
@@ -1870,6 +1860,8 @@ static int __init omap_vout_setup_video_data(struct omap_vout_device *vout)
        vfd->fops = &omap_vout_fops;
        vfd->v4l2_dev = &vout->vid_dev->v4l2_dev;
        vfd->vfl_dir = VFL_DIR_TX;
+       vfd->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_OUTPUT |
+                          V4L2_CAP_VIDEO_OUTPUT_OVERLAY;
        mutex_init(&vout->lock);
 
        vfd->minor = -1;
index 83216fc7156b373fed3217896614d1f3c22675c6..36fb3bef7dbece28cc86ab5e72bd0096aadda677 100644 (file)
@@ -2014,136 +2014,6 @@ enum isp_of_phy {
        ISP_OF_PHY_CSIPHY2,
 };
 
-static int isp_fwnode_parse(struct device *dev,
-                           struct v4l2_fwnode_endpoint *vep,
-                           struct v4l2_async_subdev *asd)
-{
-       struct isp_async_subdev *isd =
-               container_of(asd, struct isp_async_subdev, asd);
-       struct isp_bus_cfg *buscfg = &isd->bus;
-       bool csi1 = false;
-       unsigned int i;
-
-       dev_dbg(dev, "parsing endpoint %pOF, interface %u\n",
-               to_of_node(vep->base.local_fwnode), vep->base.port);
-
-       switch (vep->base.port) {
-       case ISP_OF_PHY_PARALLEL:
-               buscfg->interface = ISP_INTERFACE_PARALLEL;
-               buscfg->bus.parallel.data_lane_shift =
-                       vep->bus.parallel.data_shift;
-               buscfg->bus.parallel.clk_pol =
-                       !!(vep->bus.parallel.flags
-                          & V4L2_MBUS_PCLK_SAMPLE_FALLING);
-               buscfg->bus.parallel.hs_pol =
-                       !!(vep->bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW);
-               buscfg->bus.parallel.vs_pol =
-                       !!(vep->bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW);
-               buscfg->bus.parallel.fld_pol =
-                       !!(vep->bus.parallel.flags & V4L2_MBUS_FIELD_EVEN_LOW);
-               buscfg->bus.parallel.data_pol =
-                       !!(vep->bus.parallel.flags & V4L2_MBUS_DATA_ACTIVE_LOW);
-               buscfg->bus.parallel.bt656 = vep->bus_type == V4L2_MBUS_BT656;
-               break;
-
-       case ISP_OF_PHY_CSIPHY1:
-       case ISP_OF_PHY_CSIPHY2:
-               switch (vep->bus_type) {
-               case V4L2_MBUS_CCP2:
-               case V4L2_MBUS_CSI1:
-                       dev_dbg(dev, "CSI-1/CCP-2 configuration\n");
-                       csi1 = true;
-                       break;
-               case V4L2_MBUS_CSI2_DPHY:
-                       dev_dbg(dev, "CSI-2 configuration\n");
-                       csi1 = false;
-                       break;
-               default:
-                       dev_err(dev, "unsupported bus type %u\n",
-                               vep->bus_type);
-                       return -EINVAL;
-               }
-
-               switch (vep->base.port) {
-               case ISP_OF_PHY_CSIPHY1:
-                       if (csi1)
-                               buscfg->interface = ISP_INTERFACE_CCP2B_PHY1;
-                       else
-                               buscfg->interface = ISP_INTERFACE_CSI2C_PHY1;
-                       break;
-               case ISP_OF_PHY_CSIPHY2:
-                       if (csi1)
-                               buscfg->interface = ISP_INTERFACE_CCP2B_PHY2;
-                       else
-                               buscfg->interface = ISP_INTERFACE_CSI2A_PHY2;
-                       break;
-               }
-               if (csi1) {
-                       buscfg->bus.ccp2.lanecfg.clk.pos =
-                               vep->bus.mipi_csi1.clock_lane;
-                       buscfg->bus.ccp2.lanecfg.clk.pol =
-                               vep->bus.mipi_csi1.lane_polarity[0];
-                       dev_dbg(dev, "clock lane polarity %u, pos %u\n",
-                               buscfg->bus.ccp2.lanecfg.clk.pol,
-                               buscfg->bus.ccp2.lanecfg.clk.pos);
-
-                       buscfg->bus.ccp2.lanecfg.data[0].pos =
-                               vep->bus.mipi_csi1.data_lane;
-                       buscfg->bus.ccp2.lanecfg.data[0].pol =
-                               vep->bus.mipi_csi1.lane_polarity[1];
-
-                       dev_dbg(dev, "data lane polarity %u, pos %u\n",
-                               buscfg->bus.ccp2.lanecfg.data[0].pol,
-                               buscfg->bus.ccp2.lanecfg.data[0].pos);
-
-                       buscfg->bus.ccp2.strobe_clk_pol =
-                               vep->bus.mipi_csi1.clock_inv;
-                       buscfg->bus.ccp2.phy_layer = vep->bus.mipi_csi1.strobe;
-                       buscfg->bus.ccp2.ccp2_mode =
-                               vep->bus_type == V4L2_MBUS_CCP2;
-                       buscfg->bus.ccp2.vp_clk_pol = 1;
-
-                       buscfg->bus.ccp2.crc = 1;
-               } else {
-                       buscfg->bus.csi2.lanecfg.clk.pos =
-                               vep->bus.mipi_csi2.clock_lane;
-                       buscfg->bus.csi2.lanecfg.clk.pol =
-                               vep->bus.mipi_csi2.lane_polarities[0];
-                       dev_dbg(dev, "clock lane polarity %u, pos %u\n",
-                               buscfg->bus.csi2.lanecfg.clk.pol,
-                               buscfg->bus.csi2.lanecfg.clk.pos);
-
-                       buscfg->bus.csi2.num_data_lanes =
-                               vep->bus.mipi_csi2.num_data_lanes;
-
-                       for (i = 0; i < buscfg->bus.csi2.num_data_lanes; i++) {
-                               buscfg->bus.csi2.lanecfg.data[i].pos =
-                                       vep->bus.mipi_csi2.data_lanes[i];
-                               buscfg->bus.csi2.lanecfg.data[i].pol =
-                                       vep->bus.mipi_csi2.lane_polarities[i + 1];
-                               dev_dbg(dev,
-                                       "data lane %u polarity %u, pos %u\n", i,
-                                       buscfg->bus.csi2.lanecfg.data[i].pol,
-                                       buscfg->bus.csi2.lanecfg.data[i].pos);
-                       }
-                       /*
-                        * FIXME: now we assume the CRC is always there.
-                        * Implement a way to obtain this information from the
-                        * sensor. Frame descriptors, perhaps?
-                        */
-                       buscfg->bus.csi2.crc = 1;
-               }
-               break;
-
-       default:
-               dev_warn(dev, "%pOF: invalid interface %u\n",
-                        to_of_node(vep->base.local_fwnode), vep->base.port);
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
 static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)
 {
        struct isp_device *isp = container_of(async, struct isp_device,
@@ -2173,6 +2043,201 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)
        return media_device_register(&isp->media_dev);
 }
 
+static void isp_parse_of_parallel_endpoint(struct device *dev,
+                                          struct v4l2_fwnode_endpoint *vep,
+                                          struct isp_bus_cfg *buscfg)
+{
+       buscfg->interface = ISP_INTERFACE_PARALLEL;
+       buscfg->bus.parallel.data_lane_shift = vep->bus.parallel.data_shift;
+       buscfg->bus.parallel.clk_pol =
+               !!(vep->bus.parallel.flags & V4L2_MBUS_PCLK_SAMPLE_FALLING);
+       buscfg->bus.parallel.hs_pol =
+               !!(vep->bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW);
+       buscfg->bus.parallel.vs_pol =
+               !!(vep->bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW);
+       buscfg->bus.parallel.fld_pol =
+               !!(vep->bus.parallel.flags & V4L2_MBUS_FIELD_EVEN_LOW);
+       buscfg->bus.parallel.data_pol =
+               !!(vep->bus.parallel.flags & V4L2_MBUS_DATA_ACTIVE_LOW);
+       buscfg->bus.parallel.bt656 = vep->bus_type == V4L2_MBUS_BT656;
+}
+
+static void isp_parse_of_csi2_endpoint(struct device *dev,
+                                      struct v4l2_fwnode_endpoint *vep,
+                                      struct isp_bus_cfg *buscfg)
+{
+       unsigned int i;
+
+       buscfg->bus.csi2.lanecfg.clk.pos = vep->bus.mipi_csi2.clock_lane;
+       buscfg->bus.csi2.lanecfg.clk.pol =
+               vep->bus.mipi_csi2.lane_polarities[0];
+       dev_dbg(dev, "clock lane polarity %u, pos %u\n",
+               buscfg->bus.csi2.lanecfg.clk.pol,
+               buscfg->bus.csi2.lanecfg.clk.pos);
+
+       buscfg->bus.csi2.num_data_lanes = vep->bus.mipi_csi2.num_data_lanes;
+
+       for (i = 0; i < buscfg->bus.csi2.num_data_lanes; i++) {
+               buscfg->bus.csi2.lanecfg.data[i].pos =
+                       vep->bus.mipi_csi2.data_lanes[i];
+               buscfg->bus.csi2.lanecfg.data[i].pol =
+                       vep->bus.mipi_csi2.lane_polarities[i + 1];
+               dev_dbg(dev,
+                       "data lane %u polarity %u, pos %u\n", i,
+                       buscfg->bus.csi2.lanecfg.data[i].pol,
+                       buscfg->bus.csi2.lanecfg.data[i].pos);
+       }
+       /*
+        * FIXME: now we assume the CRC is always there. Implement a way to
+        * obtain this information from the sensor. Frame descriptors, perhaps?
+        */
+       buscfg->bus.csi2.crc = 1;
+}
+
+static void isp_parse_of_csi1_endpoint(struct device *dev,
+                                      struct v4l2_fwnode_endpoint *vep,
+                                      struct isp_bus_cfg *buscfg)
+{
+       buscfg->bus.ccp2.lanecfg.clk.pos = vep->bus.mipi_csi1.clock_lane;
+       buscfg->bus.ccp2.lanecfg.clk.pol = vep->bus.mipi_csi1.lane_polarity[0];
+       dev_dbg(dev, "clock lane polarity %u, pos %u\n",
+               buscfg->bus.ccp2.lanecfg.clk.pol,
+       buscfg->bus.ccp2.lanecfg.clk.pos);
+
+       buscfg->bus.ccp2.lanecfg.data[0].pos = vep->bus.mipi_csi1.data_lane;
+       buscfg->bus.ccp2.lanecfg.data[0].pol =
+               vep->bus.mipi_csi1.lane_polarity[1];
+
+       dev_dbg(dev, "data lane polarity %u, pos %u\n",
+               buscfg->bus.ccp2.lanecfg.data[0].pol,
+               buscfg->bus.ccp2.lanecfg.data[0].pos);
+
+       buscfg->bus.ccp2.strobe_clk_pol = vep->bus.mipi_csi1.clock_inv;
+       buscfg->bus.ccp2.phy_layer = vep->bus.mipi_csi1.strobe;
+       buscfg->bus.ccp2.ccp2_mode = vep->bus_type == V4L2_MBUS_CCP2;
+       buscfg->bus.ccp2.vp_clk_pol = 1;
+
+       buscfg->bus.ccp2.crc = 1;
+}
+
+static int isp_alloc_isd(struct isp_async_subdev **isd,
+                        struct isp_bus_cfg **buscfg)
+{
+       struct isp_async_subdev *__isd;
+
+       __isd = kzalloc(sizeof(*__isd), GFP_KERNEL);
+       if (!__isd)
+               return -ENOMEM;
+
+       *isd = __isd;
+       *buscfg = &__isd->bus;
+
+       return 0;
+}
+
+static struct {
+       u32 phy;
+       u32 csi2_if;
+       u32 csi1_if;
+} isp_bus_interfaces[2] = {
+       { ISP_OF_PHY_CSIPHY1,
+         ISP_INTERFACE_CSI2C_PHY1, ISP_INTERFACE_CCP2B_PHY1 },
+       { ISP_OF_PHY_CSIPHY2,
+         ISP_INTERFACE_CSI2A_PHY2, ISP_INTERFACE_CCP2B_PHY2 },
+};
+
+static int isp_parse_of_endpoints(struct isp_device *isp)
+{
+       struct fwnode_handle *ep;
+       struct isp_async_subdev *isd = NULL;
+       struct isp_bus_cfg *buscfg;
+       unsigned int i;
+
+       ep = fwnode_graph_get_endpoint_by_id(
+               dev_fwnode(isp->dev), ISP_OF_PHY_PARALLEL, 0,
+               FWNODE_GRAPH_ENDPOINT_NEXT);
+
+       if (ep) {
+               struct v4l2_fwnode_endpoint vep = {
+                       .bus_type = V4L2_MBUS_PARALLEL
+               };
+               int ret;
+
+               dev_dbg(isp->dev, "parsing parallel interface\n");
+
+               ret = v4l2_fwnode_endpoint_parse(ep, &vep);
+
+               if (!ret) {
+                       ret = isp_alloc_isd(&isd, &buscfg);
+                       if (ret)
+                               return ret;
+               }
+
+               if (!ret) {
+                       isp_parse_of_parallel_endpoint(isp->dev, &vep, buscfg);
+                       ret = v4l2_async_notifier_add_fwnode_remote_subdev(
+                               &isp->notifier, ep, &isd->asd);
+               }
+
+               fwnode_handle_put(ep);
+               if (ret)
+                       kfree(isd);
+       }
+
+       for (i = 0; i < ARRAY_SIZE(isp_bus_interfaces); i++) {
+               struct v4l2_fwnode_endpoint vep = {
+                       .bus_type = V4L2_MBUS_CSI2_DPHY
+               };
+               int ret;
+
+               ep = fwnode_graph_get_endpoint_by_id(
+                       dev_fwnode(isp->dev), isp_bus_interfaces[i].phy, 0,
+                       FWNODE_GRAPH_ENDPOINT_NEXT);
+
+               if (!ep)
+                       continue;
+
+               dev_dbg(isp->dev, "parsing serial interface %u, node %pOF\n", i,
+                       to_of_node(ep));
+
+               ret = isp_alloc_isd(&isd, &buscfg);
+               if (ret)
+                       return ret;
+
+               ret = v4l2_fwnode_endpoint_parse(ep, &vep);
+               if (!ret) {
+                       buscfg->interface = isp_bus_interfaces[i].csi2_if;
+                       isp_parse_of_csi2_endpoint(isp->dev, &vep, buscfg);
+               } else if (ret == -ENXIO) {
+                       vep = (struct v4l2_fwnode_endpoint)
+                               { .bus_type = V4L2_MBUS_CSI1 };
+                       ret = v4l2_fwnode_endpoint_parse(ep, &vep);
+
+                       if (ret == -ENXIO) {
+                               vep = (struct v4l2_fwnode_endpoint)
+                                       { .bus_type = V4L2_MBUS_CCP2 };
+                               ret = v4l2_fwnode_endpoint_parse(ep, &vep);
+                       }
+                       if (!ret) {
+                               buscfg->interface =
+                                       isp_bus_interfaces[i].csi1_if;
+                               isp_parse_of_csi1_endpoint(isp->dev, &vep,
+                                                          buscfg);
+                       }
+               }
+
+               if (!ret)
+                       ret = v4l2_async_notifier_add_fwnode_remote_subdev(
+                               &isp->notifier, ep, &isd->asd);
+
+               fwnode_handle_put(ep);
+               if (ret)
+                       kfree(isd);
+       }
+
+       return 0;
+}
+
 static const struct v4l2_async_notifier_operations isp_subdev_notifier_ops = {
        .complete = isp_subdev_notifier_complete,
 };
@@ -2223,14 +2288,12 @@ static int isp_probe(struct platform_device *pdev)
        mutex_init(&isp->isp_mutex);
        spin_lock_init(&isp->stat_lock);
        v4l2_async_notifier_init(&isp->notifier);
+       isp->dev = &pdev->dev;
 
-       ret = v4l2_async_notifier_parse_fwnode_endpoints(
-               &pdev->dev, &isp->notifier, sizeof(struct isp_async_subdev),
-               isp_fwnode_parse);
+       ret = isp_parse_of_endpoints(isp);
        if (ret < 0)
                goto error;
 
-       isp->dev = &pdev->dev;
        isp->ref_count = 0;
 
        ret = dma_coerce_mask_and_coherent(isp->dev, DMA_BIT_MASK(32));
@@ -2324,7 +2387,6 @@ static int isp_probe(struct platform_device *pdev)
        /* Interrupt */
        ret = platform_get_irq(pdev, 0);
        if (ret <= 0) {
-               dev_err(isp->dev, "No IRQ resource\n");
                ret = -ENODEV;
                goto error_iommu;
        }
index 499a7284c5a8778bf2c350856851b3786226f3dd..ee183c35ff3b70fced97ee5bd901ffdbd931aec5 100644 (file)
@@ -658,10 +658,6 @@ isp_video_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
        cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT
                | V4L2_CAP_STREAMING | V4L2_CAP_DEVICE_CAPS;
 
-       if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
-       else
-               cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
 
        return 0;
 }
@@ -1024,8 +1020,8 @@ static int isp_video_check_external_subdevs(struct isp_video *video,
 
        ctrls.count = 1;
        ctrls.controls = &ctrl;
-
-       ret = v4l2_g_ext_ctrls(pipe->external->ctrl_handler, NULL, &ctrls);
+       ret = v4l2_g_ext_ctrls(pipe->external->ctrl_handler, &video->video,
+                              NULL, &ctrls);
        if (ret < 0) {
                dev_warn(isp->dev, "no pixel rate control in subdev %s\n",
                         pipe->external->name);
@@ -1460,6 +1456,13 @@ int omap3isp_video_init(struct isp_video *video, const char *name)
        video->video.vfl_type = VFL_TYPE_GRABBER;
        video->video.release = video_device_release_empty;
        video->video.ioctl_ops = &isp_video_ioctl_ops;
+       if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
+               video->video.device_caps = V4L2_CAP_VIDEO_CAPTURE
+                                        | V4L2_CAP_STREAMING;
+       else
+               video->video.device_caps = V4L2_CAP_VIDEO_OUTPUT
+                                        | V4L2_CAP_STREAMING;
+
        video->pipe.stream_state = ISP_PIPELINE_STREAM_STOPPED;
 
        video_set_drvdata(&video->video, video);
index 1c9bfaabc54cae6b6dd60eee1295d5640be68812..53682da099c59c092d6afa269fcbf7bad7d10f07 100644 (file)
@@ -1992,9 +1992,6 @@ static int pxac_vidioc_querycap(struct file *file, void *priv,
        strscpy(cap->bus_info, "platform:pxa-camera", sizeof(cap->bus_info));
        strscpy(cap->driver, PXA_CAM_DRV_NAME, sizeof(cap->driver));
        strscpy(cap->card, pxa_cam_driver_description, sizeof(cap->card));
-       cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
-
        return 0;
 }
 
index 63da18773d2459e4597ce6c49564d3456c5618f5..3fdc9f964a3c6bd84b29a7b257bab23d9c8b2ede 100644 (file)
@@ -486,9 +486,9 @@ static int camss_of_parse_ports(struct camss *camss)
                asd = v4l2_async_notifier_add_fwnode_subdev(
                        &camss->notifier, of_fwnode_handle(remote),
                        sizeof(*csd));
+               of_node_put(remote);
                if (IS_ERR(asd)) {
                        ret = PTR_ERR(asd);
-                       of_node_put(remote);
                        goto err_cleanup;
                }
 
index 9ab95fd577600b0da926df63e64de33ff4b2461c..959eaa550f4e45beee4ab2bd821f30485048d9f8 100644 (file)
@@ -209,6 +209,25 @@ struct venus_buffer {
 
 #define to_venus_buffer(ptr)   container_of(ptr, struct venus_buffer, vb)
 
+enum venus_dec_state {
+       VENUS_DEC_STATE_DEINIT          = 0,
+       VENUS_DEC_STATE_INIT            = 1,
+       VENUS_DEC_STATE_CAPTURE_SETUP   = 2,
+       VENUS_DEC_STATE_STOPPED         = 3,
+       VENUS_DEC_STATE_SEEK            = 4,
+       VENUS_DEC_STATE_DRAIN           = 5,
+       VENUS_DEC_STATE_DECODING        = 6,
+       VENUS_DEC_STATE_DRC             = 7
+};
+
+struct venus_ts_metadata {
+       bool used;
+       u64 ts_ns;
+       u64 ts_us;
+       u32 flags;
+       struct v4l2_timecode tc;
+};
+
 /**
  * struct venus_inst - holds per instance parameters
  *
@@ -232,6 +251,10 @@ struct venus_buffer {
  * @colorspace:        current color space
  * @quantization:      current quantization
  * @xfer_func: current xfer function
+ * @codec_state:       current codec API state (see DEC/ENC_STATE_)
+ * @reconf_wait:       wait queue for resolution change event
+ * @subscriptions:     used to hold current events subscriptions
+ * @buf_count:         used to count number of buffers (reqbuf(0))
  * @fps:               holds current FPS
  * @timeperframe:      holds current time per frame structure
  * @fmt_out:   a reference to output format structure
@@ -246,8 +269,6 @@ struct venus_buffer {
  * @opb_buftype:       output picture buffer type
  * @opb_fmt:           output picture buffer raw format
  * @reconfig:  a flag raised by decoder when the stream resolution changed
- * @reconfig_width:    holds the new width
- * @reconfig_height:   holds the new height
  * @hfi_codec:         current codec for this instance in HFI space
  * @sequence_cap:      a sequence counter for capture queue
  * @sequence_out:      a sequence counter for output queue
@@ -287,6 +308,11 @@ struct venus_inst {
        u8 ycbcr_enc;
        u8 quantization;
        u8 xfer_func;
+       enum venus_dec_state codec_state;
+       wait_queue_head_t reconf_wait;
+       unsigned int subscriptions;
+       int buf_count;
+       struct venus_ts_metadata tss[VIDEO_MAX_FRAME];
        u64 fps;
        struct v4l2_fract timeperframe;
        const struct venus_format *fmt_out;
@@ -301,8 +327,6 @@ struct venus_inst {
        u32 opb_buftype;
        u32 opb_fmt;
        bool reconfig;
-       u32 reconfig_width;
-       u32 reconfig_height;
        u32 hfi_codec;
        u32 sequence_cap;
        u32 sequence_out;
index 71b06dfc6dc40d70a4f16b363801fe6ce33e90a3..1ad96c25ab09a6243d958a1739e7184c52f5d33e 100644 (file)
@@ -79,7 +79,7 @@ bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt)
 }
 EXPORT_SYMBOL_GPL(venus_helper_check_codec);
 
-static int venus_helper_queue_dpb_bufs(struct venus_inst *inst)
+int venus_helper_queue_dpb_bufs(struct venus_inst *inst)
 {
        struct intbuf *buf;
        int ret = 0;
@@ -100,6 +100,7 @@ static int venus_helper_queue_dpb_bufs(struct venus_inst *inst)
 fail:
        return ret;
 }
+EXPORT_SYMBOL_GPL(venus_helper_queue_dpb_bufs);
 
 int venus_helper_free_dpb_bufs(struct venus_inst *inst)
 {
@@ -278,7 +279,7 @@ static const unsigned int intbuf_types_4xx[] = {
        HFI_BUFFER_INTERNAL_PERSIST_1,
 };
 
-static int intbufs_alloc(struct venus_inst *inst)
+int venus_helper_intbufs_alloc(struct venus_inst *inst)
 {
        const unsigned int *intbuf;
        size_t arr_sz, i;
@@ -304,11 +305,59 @@ static int intbufs_alloc(struct venus_inst *inst)
        intbufs_unset_buffers(inst);
        return ret;
 }
+EXPORT_SYMBOL_GPL(venus_helper_intbufs_alloc);
 
-static int intbufs_free(struct venus_inst *inst)
+int venus_helper_intbufs_free(struct venus_inst *inst)
 {
        return intbufs_unset_buffers(inst);
 }
+EXPORT_SYMBOL_GPL(venus_helper_intbufs_free);
+
+int venus_helper_intbufs_realloc(struct venus_inst *inst)
+{
+       enum hfi_version ver = inst->core->res->hfi_version;
+       struct hfi_buffer_desc bd;
+       struct intbuf *buf, *n;
+       int ret;
+
+       list_for_each_entry_safe(buf, n, &inst->internalbufs, list) {
+               if (buf->type == HFI_BUFFER_INTERNAL_PERSIST ||
+                   buf->type == HFI_BUFFER_INTERNAL_PERSIST_1)
+                       continue;
+
+               memset(&bd, 0, sizeof(bd));
+               bd.buffer_size = buf->size;
+               bd.buffer_type = buf->type;
+               bd.num_buffers = 1;
+               bd.device_addr = buf->da;
+               bd.response_required = true;
+
+               ret = hfi_session_unset_buffers(inst, &bd);
+
+               dma_free_attrs(inst->core->dev, buf->size, buf->va, buf->da,
+                              buf->attrs);
+
+               list_del_init(&buf->list);
+               kfree(buf);
+       }
+
+       ret = intbufs_set_buffer(inst, HFI_BUFFER_INTERNAL_SCRATCH(ver));
+       if (ret)
+               goto err;
+
+       ret = intbufs_set_buffer(inst, HFI_BUFFER_INTERNAL_SCRATCH_1(ver));
+       if (ret)
+               goto err;
+
+       ret = intbufs_set_buffer(inst, HFI_BUFFER_INTERNAL_SCRATCH_2(ver));
+       if (ret)
+               goto err;
+
+       return 0;
+err:
+       return ret;
+}
+EXPORT_SYMBOL_GPL(venus_helper_intbufs_realloc);
 
 static u32 load_per_instance(struct venus_inst *inst)
 {
@@ -339,7 +388,7 @@ static u32 load_per_type(struct venus_core *core, u32 session_type)
        return mbs_per_sec;
 }
 
-static int load_scale_clocks(struct venus_core *core)
+int venus_helper_load_scale_clocks(struct venus_core *core)
 {
        const struct freq_tbl *table = core->res->freq_tbl;
        unsigned int num_rows = core->res->freq_tbl_size;
@@ -388,6 +437,7 @@ static int load_scale_clocks(struct venus_core *core)
        dev_err(dev, "failed to set clock rate %lu (%d)\n", freq, ret);
        return ret;
 }
+EXPORT_SYMBOL_GPL(venus_helper_load_scale_clocks);
 
 static void fill_buffer_desc(const struct venus_buffer *buf,
                             struct hfi_buffer_desc *bd, bool response)
@@ -413,6 +463,57 @@ static void return_buf_error(struct venus_inst *inst,
        v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
 }
 
+static void
+put_ts_metadata(struct venus_inst *inst, struct vb2_v4l2_buffer *vbuf)
+{
+       struct vb2_buffer *vb = &vbuf->vb2_buf;
+       unsigned int i;
+       int slot = -1;
+       u64 ts_us = vb->timestamp;
+
+       for (i = 0; i < ARRAY_SIZE(inst->tss); i++) {
+               if (!inst->tss[i].used) {
+                       slot = i;
+                       break;
+               }
+       }
+
+       if (slot == -1) {
+               dev_dbg(inst->core->dev, "%s: no free slot\n", __func__);
+               return;
+       }
+
+       do_div(ts_us, NSEC_PER_USEC);
+
+       inst->tss[slot].used = true;
+       inst->tss[slot].flags = vbuf->flags;
+       inst->tss[slot].tc = vbuf->timecode;
+       inst->tss[slot].ts_us = ts_us;
+       inst->tss[slot].ts_ns = vb->timestamp;
+}
+
+void venus_helper_get_ts_metadata(struct venus_inst *inst, u64 timestamp_us,
+                                 struct vb2_v4l2_buffer *vbuf)
+{
+       struct vb2_buffer *vb = &vbuf->vb2_buf;
+       unsigned int i;
+
+       for (i = 0; i < ARRAY_SIZE(inst->tss); ++i) {
+               if (!inst->tss[i].used)
+                       continue;
+
+               if (inst->tss[i].ts_us != timestamp_us)
+                       continue;
+
+               inst->tss[i].used = false;
+               vbuf->flags |= inst->tss[i].flags;
+               vbuf->timecode = inst->tss[i].tc;
+               vb->timestamp = inst->tss[i].ts_ns;
+               break;
+       }
+}
+EXPORT_SYMBOL_GPL(venus_helper_get_ts_metadata);
+
 static int
 session_process_buf(struct venus_inst *inst, struct vb2_v4l2_buffer *vbuf)
 {
@@ -437,6 +538,9 @@ session_process_buf(struct venus_inst *inst, struct vb2_v4l2_buffer *vbuf)
 
                if (vbuf->flags & V4L2_BUF_FLAG_LAST || !fdata.filled_len)
                        fdata.flags |= HFI_BUFFERFLAG_EOS;
+
+               if (inst->session_type == VIDC_SESSION_TYPE_DEC)
+                       put_ts_metadata(inst, vbuf);
        } else if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
                if (inst->session_type == VIDC_SESSION_TYPE_ENC)
                        fdata.buffer_type = HFI_BUFFER_OUTPUT;
@@ -472,7 +576,7 @@ static bool is_dynamic_bufmode(struct venus_inst *inst)
        return caps->cap_bufs_mode_dynamic;
 }
 
-static int session_unregister_bufs(struct venus_inst *inst)
+int venus_helper_unregister_bufs(struct venus_inst *inst)
 {
        struct venus_buffer *buf, *n;
        struct hfi_buffer_desc bd;
@@ -489,6 +593,7 @@ static int session_unregister_bufs(struct venus_inst *inst)
 
        return ret;
 }
+EXPORT_SYMBOL_GPL(venus_helper_unregister_bufs);
 
 static int session_register_bufs(struct venus_inst *inst)
 {
@@ -947,6 +1052,17 @@ int venus_helper_vb2_buf_prepare(struct vb2_buffer *vb)
 {
        struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue);
        unsigned int out_buf_size = venus_helper_get_opb_size(inst);
+       struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
+
+       if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) {
+               if (vbuf->field == V4L2_FIELD_ANY)
+                       vbuf->field = V4L2_FIELD_NONE;
+               if (vbuf->field != V4L2_FIELD_NONE) {
+                       dev_err(inst->core->dev, "%s field isn't supported\n",
+                               __func__);
+                       return -EINVAL;
+               }
+       }
 
        if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
            vb2_plane_size(vb, 0) < out_buf_size)
@@ -970,16 +1086,19 @@ void venus_helper_vb2_buf_queue(struct vb2_buffer *vb)
 
        v4l2_m2m_buf_queue(m2m_ctx, vbuf);
 
-       if (!(inst->streamon_out & inst->streamon_cap))
+       if (inst->session_type == VIDC_SESSION_TYPE_ENC &&
+           !(inst->streamon_out && inst->streamon_cap))
                goto unlock;
 
-       ret = is_buf_refed(inst, vbuf);
-       if (ret)
-               goto unlock;
+       if (vb2_start_streaming_called(vb->vb2_queue)) {
+               ret = is_buf_refed(inst, vbuf);
+               if (ret)
+                       goto unlock;
 
-       ret = session_process_buf(inst, vbuf);
-       if (ret)
-               return_buf_error(inst, vbuf);
+               ret = session_process_buf(inst, vbuf);
+               if (ret)
+                       return_buf_error(inst, vbuf);
+       }
 
 unlock:
        mutex_unlock(&inst->lock);
@@ -1009,8 +1128,8 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q)
        if (inst->streamon_out & inst->streamon_cap) {
                ret = hfi_session_stop(inst);
                ret |= hfi_session_unload_res(inst);
-               ret |= session_unregister_bufs(inst);
-               ret |= intbufs_free(inst);
+               ret |= venus_helper_unregister_bufs(inst);
+               ret |= venus_helper_intbufs_free(inst);
                ret |= hfi_session_deinit(inst);
 
                if (inst->session_error || core->sys_error)
@@ -1021,7 +1140,7 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q)
 
                venus_helper_free_dpb_bufs(inst);
 
-               load_scale_clocks(core);
+               venus_helper_load_scale_clocks(core);
                INIT_LIST_HEAD(&inst->registeredbufs);
        }
 
@@ -1036,12 +1155,48 @@ void venus_helper_vb2_stop_streaming(struct vb2_queue *q)
 }
 EXPORT_SYMBOL_GPL(venus_helper_vb2_stop_streaming);
 
+int venus_helper_process_initial_cap_bufs(struct venus_inst *inst)
+{
+       struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx;
+       struct v4l2_m2m_buffer *buf, *n;
+       int ret;
+
+       v4l2_m2m_for_each_dst_buf_safe(m2m_ctx, buf, n) {
+               ret = session_process_buf(inst, &buf->vb);
+               if (ret) {
+                       return_buf_error(inst, &buf->vb);
+                       return ret;
+               }
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(venus_helper_process_initial_cap_bufs);
+
+int venus_helper_process_initial_out_bufs(struct venus_inst *inst)
+{
+       struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx;
+       struct v4l2_m2m_buffer *buf, *n;
+       int ret;
+
+       v4l2_m2m_for_each_src_buf_safe(m2m_ctx, buf, n) {
+               ret = session_process_buf(inst, &buf->vb);
+               if (ret) {
+                       return_buf_error(inst, &buf->vb);
+                       return ret;
+               }
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(venus_helper_process_initial_out_bufs);
+
 int venus_helper_vb2_start_streaming(struct venus_inst *inst)
 {
        struct venus_core *core = inst->core;
        int ret;
 
-       ret = intbufs_alloc(inst);
+       ret = venus_helper_intbufs_alloc(inst);
        if (ret)
                return ret;
 
@@ -1049,7 +1204,7 @@ int venus_helper_vb2_start_streaming(struct venus_inst *inst)
        if (ret)
                goto err_bufs_free;
 
-       load_scale_clocks(core);
+       venus_helper_load_scale_clocks(core);
 
        ret = hfi_session_load_res(inst);
        if (ret)
@@ -1059,20 +1214,14 @@ int venus_helper_vb2_start_streaming(struct venus_inst *inst)
        if (ret)
                goto err_unload_res;
 
-       ret = venus_helper_queue_dpb_bufs(inst);
-       if (ret)
-               goto err_session_stop;
-
        return 0;
 
-err_session_stop:
-       hfi_session_stop(inst);
 err_unload_res:
        hfi_session_unload_res(inst);
 err_unreg_bufs:
-       session_unregister_bufs(inst);
+       venus_helper_unregister_bufs(inst);
 err_bufs_free:
-       intbufs_free(inst);
+       venus_helper_intbufs_free(inst);
        return ret;
 }
 EXPORT_SYMBOL_GPL(venus_helper_vb2_start_streaming);
index 153783687a0cb77d612987f82564b1048748a746..01f411b12f813fc8d4ecacb6a75d1be92aabe081 100644 (file)
@@ -9,6 +9,7 @@
 #include <media/videobuf2-v4l2.h>
 
 struct venus_inst;
+struct venus_core;
 
 bool venus_helper_check_codec(struct venus_inst *inst, u32 v4l2_pixfmt);
 struct vb2_v4l2_buffer *venus_helper_find_buf(struct venus_inst *inst,
@@ -53,4 +54,14 @@ int venus_helper_alloc_dpb_bufs(struct venus_inst *inst);
 int venus_helper_free_dpb_bufs(struct venus_inst *inst);
 int venus_helper_power_enable(struct venus_core *core, u32 session_type,
                              bool enable);
+int venus_helper_intbufs_alloc(struct venus_inst *inst);
+int venus_helper_intbufs_free(struct venus_inst *inst);
+int venus_helper_intbufs_realloc(struct venus_inst *inst);
+int venus_helper_queue_dpb_bufs(struct venus_inst *inst);
+int venus_helper_unregister_bufs(struct venus_inst *inst);
+int venus_helper_load_scale_clocks(struct venus_core *core);
+int venus_helper_process_initial_cap_bufs(struct venus_inst *inst);
+int venus_helper_process_initial_out_bufs(struct venus_inst *inst);
+void venus_helper_get_ts_metadata(struct venus_inst *inst, u64 timestamp_us,
+                                 struct vb2_v4l2_buffer *vbuf);
 #endif
index 6ad0c1772ea7d6455c226c94a017b9f8f5b9c263..3d8b1284d1f35386b598f2c41deff1fd1e572b98 100644 (file)
@@ -198,6 +198,9 @@ int hfi_session_init(struct venus_inst *inst, u32 pixfmt)
        const struct hfi_ops *ops = core->ops;
        int ret;
 
+       if (inst->state != INST_UNINIT)
+               return -EINVAL;
+
        inst->hfi_codec = to_codec_type(pixfmt);
        reinit_completion(&inst->done);
 
@@ -276,6 +279,7 @@ int hfi_session_start(struct venus_inst *inst)
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(hfi_session_start);
 
 int hfi_session_stop(struct venus_inst *inst)
 {
@@ -299,6 +303,7 @@ int hfi_session_stop(struct venus_inst *inst)
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(hfi_session_stop);
 
 int hfi_session_continue(struct venus_inst *inst)
 {
@@ -328,6 +333,7 @@ int hfi_session_abort(struct venus_inst *inst)
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(hfi_session_abort);
 
 int hfi_session_load_res(struct venus_inst *inst)
 {
@@ -374,15 +380,16 @@ int hfi_session_unload_res(struct venus_inst *inst)
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(hfi_session_unload_res);
 
-int hfi_session_flush(struct venus_inst *inst)
+int hfi_session_flush(struct venus_inst *inst, u32 type)
 {
        const struct hfi_ops *ops = inst->core->ops;
        int ret;
 
        reinit_completion(&inst->done);
 
-       ret = ops->session_flush(inst, HFI_FLUSH_ALL);
+       ret = ops->session_flush(inst, type);
        if (ret)
                return ret;
 
index b121cb1427ac83c072e92d76ea99af2c32e000ad..855822c9f39b7923d7e2a56eed408a9353db22f4 100644 (file)
@@ -161,7 +161,7 @@ int hfi_session_continue(struct venus_inst *inst);
 int hfi_session_abort(struct venus_inst *inst);
 int hfi_session_load_res(struct venus_inst *inst);
 int hfi_session_unload_res(struct venus_inst *inst);
-int hfi_session_flush(struct venus_inst *inst);
+int hfi_session_flush(struct venus_inst *inst, u32 type);
 int hfi_session_set_buffers(struct venus_inst *inst,
                            struct hfi_buffer_desc *bd);
 int hfi_session_unset_buffers(struct venus_inst *inst,
index e1f998656c07f2b50e45b02023d08b43a3607f76..0b7d65db5cdc3da9d4e891680540232e01f18f65 100644 (file)
@@ -133,6 +133,7 @@ vdec_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
        struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp;
        struct v4l2_plane_pix_format *pfmt = pixmp->plane_fmt;
        const struct venus_format *fmt;
+       u32 szimage;
 
        memset(pfmt[0].reserved, 0, sizeof(pfmt[0].reserved));
        memset(pixmp->reserved, 0, sizeof(pixmp->reserved));
@@ -161,14 +162,17 @@ vdec_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
        pixmp->num_planes = fmt->num_planes;
        pixmp->flags = 0;
 
-       pfmt[0].sizeimage = venus_helper_get_framesz(pixmp->pixelformat,
-                                                    pixmp->width,
-                                                    pixmp->height);
+       szimage = venus_helper_get_framesz(pixmp->pixelformat, pixmp->width,
+                                          pixmp->height);
 
-       if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+       if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+               pfmt[0].sizeimage = szimage;
                pfmt[0].bytesperline = ALIGN(pixmp->width, 128);
-       else
+       } else {
+               pfmt[0].sizeimage = clamp_t(u32, pfmt[0].sizeimage, 0, SZ_8M);
+               pfmt[0].sizeimage = max(pfmt[0].sizeimage, szimage);
                pfmt[0].bytesperline = 0;
+       }
 
        return fmt;
 }
@@ -182,33 +186,56 @@ static int vdec_try_fmt(struct file *file, void *fh, struct v4l2_format *f)
        return 0;
 }
 
+static int vdec_check_src_change(struct venus_inst *inst)
+{
+       int ret;
+
+       if (inst->subscriptions & V4L2_EVENT_SOURCE_CHANGE &&
+           inst->codec_state == VENUS_DEC_STATE_INIT &&
+           !inst->reconfig)
+               return -EINVAL;
+
+       if (inst->subscriptions & V4L2_EVENT_SOURCE_CHANGE)
+               return 0;
+
+       /*
+        * The code snippet below is a workaround for backward compatibility
+        * with applications which doesn't support V4L2 events. It will be
+        * dropped in future once those applications are fixed.
+        */
+
+       if (inst->codec_state != VENUS_DEC_STATE_INIT)
+               goto done;
+
+       ret = wait_event_timeout(inst->reconf_wait, inst->reconfig,
+                                msecs_to_jiffies(100));
+       if (!ret)
+               return -EINVAL;
+
+       if (!(inst->codec_state == VENUS_DEC_STATE_CAPTURE_SETUP) ||
+           !inst->reconfig)
+               dev_dbg(inst->core->dev, "%s: wrong state\n", __func__);
+
+done:
+       return 0;
+}
+
 static int vdec_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
 {
        struct venus_inst *inst = to_inst(file);
        const struct venus_format *fmt = NULL;
        struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp;
+       int ret;
 
        if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
                fmt = inst->fmt_cap;
        else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
                fmt = inst->fmt_out;
 
-       if (inst->reconfig) {
-               struct v4l2_format format = {};
-
-               inst->out_width = inst->reconfig_width;
-               inst->out_height = inst->reconfig_height;
-               inst->reconfig = false;
-
-               format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
-               format.fmt.pix_mp.pixelformat = inst->fmt_cap->pixfmt;
-               format.fmt.pix_mp.width = inst->out_width;
-               format.fmt.pix_mp.height = inst->out_height;
-
-               vdec_try_fmt_common(inst, &format);
-
-               inst->width = format.fmt.pix_mp.width;
-               inst->height = format.fmt.pix_mp.height;
+       if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+               ret = vdec_check_src_change(inst);
+               if (ret)
+                       return ret;
        }
 
        pixmp->pixelformat = fmt->pixfmt;
@@ -266,6 +293,7 @@ static int vdec_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
                inst->ycbcr_enc = pixmp->ycbcr_enc;
                inst->quantization = pixmp->quantization;
                inst->xfer_func = pixmp->xfer_func;
+               inst->input_buf_size = pixmp->plane_fmt[0].sizeimage;
        }
 
        memset(&format, 0, sizeof(format));
@@ -422,11 +450,18 @@ static int vdec_enum_framesizes(struct file *file, void *fh,
 static int vdec_subscribe_event(struct v4l2_fh *fh,
                                const struct v4l2_event_subscription *sub)
 {
+       struct venus_inst *inst = container_of(fh, struct venus_inst, fh);
+       int ret;
+
        switch (sub->type) {
        case V4L2_EVENT_EOS:
                return v4l2_event_subscribe(fh, sub, 2, NULL);
        case V4L2_EVENT_SOURCE_CHANGE:
-               return v4l2_src_change_event_subscribe(fh, sub);
+               ret = v4l2_src_change_event_subscribe(fh, sub);
+               if (ret)
+                       return ret;
+               inst->subscriptions |= V4L2_EVENT_SOURCE_CHANGE;
+               return 0;
        case V4L2_EVENT_CTRL:
                return v4l2_ctrl_subscribe_event(fh, sub);
        default:
@@ -434,21 +469,6 @@ static int vdec_subscribe_event(struct v4l2_fh *fh,
        }
 }
 
-static int
-vdec_try_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd)
-{
-       switch (cmd->cmd) {
-       case V4L2_DEC_CMD_STOP:
-               if (cmd->flags & V4L2_DEC_CMD_STOP_TO_BLACK)
-                       return -EINVAL;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
 static int
 vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd)
 {
@@ -456,24 +476,29 @@ vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd)
        struct hfi_frame_data fdata = {0};
        int ret;
 
-       ret = vdec_try_decoder_cmd(file, fh, cmd);
+       ret = v4l2_m2m_ioctl_try_decoder_cmd(file, fh, cmd);
        if (ret)
                return ret;
 
        mutex_lock(&inst->lock);
 
-       /*
-        * Implement V4L2_DEC_CMD_STOP by enqueue an empty buffer on decoder
-        * input to signal EOS.
-        */
-       if (!(inst->streamon_out & inst->streamon_cap))
-               goto unlock;
+       if (cmd->cmd == V4L2_DEC_CMD_STOP) {
+               /*
+                * Implement V4L2_DEC_CMD_STOP by enqueue an empty buffer on
+                * decoder input to signal EOS.
+                */
+               if (!(inst->streamon_out && inst->streamon_cap))
+                       goto unlock;
 
-       fdata.buffer_type = HFI_BUFFER_INPUT;
-       fdata.flags |= HFI_BUFFERFLAG_EOS;
-       fdata.device_addr = 0xdeadbeef;
+               fdata.buffer_type = HFI_BUFFER_INPUT;
+               fdata.flags |= HFI_BUFFERFLAG_EOS;
+               fdata.device_addr = 0xdeadb000;
 
-       ret = hfi_session_process_buf(inst, &fdata);
+               ret = hfi_session_process_buf(inst, &fdata);
+
+               if (!ret && inst->codec_state == VENUS_DEC_STATE_DECODING)
+                       inst->codec_state = VENUS_DEC_STATE_DRAIN;
+       }
 
 unlock:
        mutex_unlock(&inst->lock);
@@ -504,7 +529,7 @@ static const struct v4l2_ioctl_ops vdec_ioctl_ops = {
        .vidioc_enum_framesizes = vdec_enum_framesizes,
        .vidioc_subscribe_event = vdec_subscribe_event,
        .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
-       .vidioc_try_decoder_cmd = vdec_try_decoder_cmd,
+       .vidioc_try_decoder_cmd = v4l2_m2m_ioctl_try_decoder_cmd,
        .vidioc_decoder_cmd = vdec_decoder_cmd,
 };
 
@@ -634,20 +659,18 @@ static int vdec_output_conf(struct venus_inst *inst)
        return 0;
 }
 
-static int vdec_init_session(struct venus_inst *inst)
+static int vdec_session_init(struct venus_inst *inst)
 {
        int ret;
 
        ret = hfi_session_init(inst, inst->fmt_out->pixfmt);
-       if (ret)
+       if (ret == -EINVAL)
+               return 0;
+       else if (ret)
                return ret;
 
-       ret = venus_helper_set_input_resolution(inst, inst->out_width,
-                                               inst->out_height);
-       if (ret)
-               goto deinit;
-
-       ret = venus_helper_set_color_format(inst, inst->fmt_cap->pixfmt);
+       ret = venus_helper_set_input_resolution(inst, frame_width_min(inst),
+                                               frame_height_min(inst));
        if (ret)
                goto deinit;
 
@@ -666,26 +689,19 @@ static int vdec_num_buffers(struct venus_inst *inst, unsigned int *in_num,
 
        *in_num = *out_num = 0;
 
-       ret = vdec_init_session(inst);
-       if (ret)
-               return ret;
-
        ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq);
        if (ret)
-               goto deinit;
+               return ret;
 
        *in_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
 
        ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq);
        if (ret)
-               goto deinit;
+               return ret;
 
        *out_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
 
-deinit:
-       hfi_session_deinit(inst);
-
-       return ret;
+       return 0;
 }
 
 static int vdec_queue_setup(struct vb2_queue *q,
@@ -718,6 +734,10 @@ static int vdec_queue_setup(struct vb2_queue *q,
                return 0;
        }
 
+       ret = vdec_session_init(inst);
+       if (ret)
+               return ret;
+
        ret = vdec_num_buffers(inst, &in_num, &out_num);
        if (ret)
                return ret;
@@ -728,6 +748,7 @@ static int vdec_queue_setup(struct vb2_queue *q,
                sizes[0] = venus_helper_get_framesz(inst->fmt_out->pixfmt,
                                                    inst->out_width,
                                                    inst->out_height);
+               sizes[0] = max(sizes[0], inst->input_buf_size);
                inst->input_buf_size = sizes[0];
                *num_buffers = max(*num_buffers, in_num);
                inst->num_input_bufs = *num_buffers;
@@ -741,6 +762,11 @@ static int vdec_queue_setup(struct vb2_queue *q,
                inst->output_buf_size = sizes[0];
                *num_buffers = max(*num_buffers, out_num);
                inst->num_output_bufs = *num_buffers;
+
+               mutex_lock(&inst->lock);
+               if (inst->codec_state == VENUS_DEC_STATE_CAPTURE_SETUP)
+                       inst->codec_state = VENUS_DEC_STATE_STOPPED;
+               mutex_unlock(&inst->lock);
                break;
        default:
                ret = -EINVAL;
@@ -777,80 +803,295 @@ static int vdec_verify_conf(struct venus_inst *inst)
        return 0;
 }
 
-static int vdec_start_streaming(struct vb2_queue *q, unsigned int count)
+static int vdec_start_capture(struct venus_inst *inst)
 {
-       struct venus_inst *inst = vb2_get_drv_priv(q);
        int ret;
 
-       mutex_lock(&inst->lock);
+       if (!inst->streamon_out)
+               return 0;
 
-       if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
-               inst->streamon_out = 1;
-       else
-               inst->streamon_cap = 1;
+       if (inst->codec_state == VENUS_DEC_STATE_DECODING) {
+               if (inst->reconfig)
+                       goto reconfigure;
 
-       if (!(inst->streamon_out & inst->streamon_cap)) {
-               mutex_unlock(&inst->lock);
+               venus_helper_queue_dpb_bufs(inst);
+               venus_helper_process_initial_cap_bufs(inst);
+               inst->streamon_cap = 1;
                return 0;
        }
 
-       venus_helper_init_instance(inst);
+       if (inst->codec_state != VENUS_DEC_STATE_STOPPED)
+               return 0;
 
-       inst->reconfig = false;
-       inst->sequence_cap = 0;
-       inst->sequence_out = 0;
+reconfigure:
+       ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT);
+       if (ret)
+               return ret;
 
-       ret = vdec_init_session(inst);
+       ret = vdec_output_conf(inst);
        if (ret)
-               goto bufs_done;
+               return ret;
+
+       ret = venus_helper_set_num_bufs(inst, inst->num_input_bufs,
+                                       VB2_MAX_FRAME, VB2_MAX_FRAME);
+       if (ret)
+               return ret;
+
+       ret = venus_helper_intbufs_realloc(inst);
+       if (ret)
+               goto err;
+
+       ret = venus_helper_alloc_dpb_bufs(inst);
+       if (ret)
+               goto err;
+
+       ret = venus_helper_queue_dpb_bufs(inst);
+       if (ret)
+               goto free_dpb_bufs;
+
+       ret = venus_helper_process_initial_cap_bufs(inst);
+       if (ret)
+               goto free_dpb_bufs;
+
+       venus_helper_load_scale_clocks(inst->core);
+
+       ret = hfi_session_continue(inst);
+       if (ret)
+               goto free_dpb_bufs;
+
+       inst->codec_state = VENUS_DEC_STATE_DECODING;
+
+       inst->streamon_cap = 1;
+       inst->sequence_cap = 0;
+       inst->reconfig = false;
+
+       return 0;
+
+free_dpb_bufs:
+       venus_helper_free_dpb_bufs(inst);
+err:
+       return ret;
+}
+
+static int vdec_start_output(struct venus_inst *inst)
+{
+       int ret;
+
+       if (inst->codec_state == VENUS_DEC_STATE_SEEK) {
+               ret = venus_helper_process_initial_out_bufs(inst);
+               inst->codec_state = VENUS_DEC_STATE_DECODING;
+               goto done;
+       }
+
+       if (inst->codec_state == VENUS_DEC_STATE_INIT ||
+           inst->codec_state == VENUS_DEC_STATE_CAPTURE_SETUP) {
+               ret = venus_helper_process_initial_out_bufs(inst);
+               goto done;
+       }
+
+       if (inst->codec_state != VENUS_DEC_STATE_DEINIT)
+               return -EINVAL;
+
+       venus_helper_init_instance(inst);
+       inst->sequence_out = 0;
+       inst->reconfig = false;
 
        ret = vdec_set_properties(inst);
        if (ret)
-               goto deinit_sess;
+               return ret;
 
        ret = vdec_output_conf(inst);
        if (ret)
-               goto deinit_sess;
+               return ret;
 
        ret = vdec_verify_conf(inst);
        if (ret)
-               goto deinit_sess;
+               return ret;
 
        ret = venus_helper_set_num_bufs(inst, inst->num_input_bufs,
                                        VB2_MAX_FRAME, VB2_MAX_FRAME);
        if (ret)
-               goto deinit_sess;
+               return ret;
 
-       ret = venus_helper_alloc_dpb_bufs(inst);
+       ret = venus_helper_vb2_start_streaming(inst);
        if (ret)
-               goto deinit_sess;
+               return ret;
 
-       ret = venus_helper_vb2_start_streaming(inst);
+       ret = venus_helper_process_initial_out_bufs(inst);
        if (ret)
-               goto deinit_sess;
+               return ret;
 
-       mutex_unlock(&inst->lock);
+       inst->codec_state = VENUS_DEC_STATE_INIT;
+
+done:
+       inst->streamon_out = 1;
+       return ret;
+}
+
+static int vdec_start_streaming(struct vb2_queue *q, unsigned int count)
+{
+       struct venus_inst *inst = vb2_get_drv_priv(q);
+       int ret;
+
+       mutex_lock(&inst->lock);
+
+       if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+               ret = vdec_start_capture(inst);
+       else
+               ret = vdec_start_output(inst);
 
+       if (ret)
+               goto error;
+
+       mutex_unlock(&inst->lock);
        return 0;
 
-deinit_sess:
-       hfi_session_deinit(inst);
-bufs_done:
+error:
        venus_helper_buffers_done(inst, VB2_BUF_STATE_QUEUED);
+       mutex_unlock(&inst->lock);
+       return ret;
+}
+
+static void vdec_cancel_dst_buffers(struct venus_inst *inst)
+{
+       struct vb2_v4l2_buffer *buf;
+
+       while ((buf = v4l2_m2m_dst_buf_remove(inst->m2m_ctx)))
+               v4l2_m2m_buf_done(buf, VB2_BUF_STATE_ERROR);
+}
+
+static int vdec_stop_capture(struct venus_inst *inst)
+{
+       int ret = 0;
+
+       switch (inst->codec_state) {
+       case VENUS_DEC_STATE_DECODING:
+               ret = hfi_session_flush(inst, HFI_FLUSH_ALL);
+               /* fallthrough */
+       case VENUS_DEC_STATE_DRAIN:
+               vdec_cancel_dst_buffers(inst);
+               inst->codec_state = VENUS_DEC_STATE_STOPPED;
+               break;
+       case VENUS_DEC_STATE_DRC:
+               ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT);
+               vdec_cancel_dst_buffers(inst);
+               inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP;
+               INIT_LIST_HEAD(&inst->registeredbufs);
+               venus_helper_free_dpb_bufs(inst);
+               break;
+       default:
+               return 0;
+       }
+
+       return ret;
+}
+
+static int vdec_stop_output(struct venus_inst *inst)
+{
+       int ret = 0;
+
+       switch (inst->codec_state) {
+       case VENUS_DEC_STATE_DECODING:
+       case VENUS_DEC_STATE_DRAIN:
+       case VENUS_DEC_STATE_STOPPED:
+               ret = hfi_session_flush(inst, HFI_FLUSH_ALL);
+               inst->codec_state = VENUS_DEC_STATE_SEEK;
+               break;
+       case VENUS_DEC_STATE_INIT:
+       case VENUS_DEC_STATE_CAPTURE_SETUP:
+               ret = hfi_session_flush(inst, HFI_FLUSH_INPUT);
+               break;
+       default:
+               break;
+       }
+
+       return ret;
+}
+
+static void vdec_stop_streaming(struct vb2_queue *q)
+{
+       struct venus_inst *inst = vb2_get_drv_priv(q);
+       int ret = -EINVAL;
+
+       mutex_lock(&inst->lock);
+
+       if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+               ret = vdec_stop_capture(inst);
+       else
+               ret = vdec_stop_output(inst);
+
+       venus_helper_buffers_done(inst, VB2_BUF_STATE_ERROR);
+
+       if (ret)
+               goto unlock;
+
        if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
                inst->streamon_out = 0;
        else
                inst->streamon_cap = 0;
+
+unlock:
        mutex_unlock(&inst->lock);
-       return ret;
+}
+
+static void vdec_session_release(struct venus_inst *inst)
+{
+       struct venus_core *core = inst->core;
+       int ret, abort = 0;
+
+       mutex_lock(&inst->lock);
+
+       inst->codec_state = VENUS_DEC_STATE_DEINIT;
+
+       ret = hfi_session_stop(inst);
+       abort = (ret && ret != -EINVAL) ? 1 : 0;
+       ret = hfi_session_unload_res(inst);
+       abort = (ret && ret != -EINVAL) ? 1 : 0;
+       ret = venus_helper_unregister_bufs(inst);
+       abort = (ret && ret != -EINVAL) ? 1 : 0;
+       ret = venus_helper_intbufs_free(inst);
+       abort = (ret && ret != -EINVAL) ? 1 : 0;
+       ret = hfi_session_deinit(inst);
+       abort = (ret && ret != -EINVAL) ? 1 : 0;
+
+       if (inst->session_error || core->sys_error)
+               abort = 1;
+
+       if (abort)
+               hfi_session_abort(inst);
+
+       venus_helper_free_dpb_bufs(inst);
+       venus_helper_load_scale_clocks(core);
+       INIT_LIST_HEAD(&inst->registeredbufs);
+
+       mutex_unlock(&inst->lock);
+}
+
+static int vdec_buf_init(struct vb2_buffer *vb)
+{
+       struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue);
+
+       inst->buf_count++;
+
+       return venus_helper_vb2_buf_init(vb);
+}
+
+static void vdec_buf_cleanup(struct vb2_buffer *vb)
+{
+       struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue);
+
+       inst->buf_count--;
+       if (!inst->buf_count)
+               vdec_session_release(inst);
 }
 
 static const struct vb2_ops vdec_vb2_ops = {
        .queue_setup = vdec_queue_setup,
-       .buf_init = venus_helper_vb2_buf_init,
+       .buf_init = vdec_buf_init,
+       .buf_cleanup = vdec_buf_cleanup,
        .buf_prepare = venus_helper_vb2_buf_prepare,
        .start_streaming = vdec_start_streaming,
-       .stop_streaming = venus_helper_vb2_stop_streaming,
+       .stop_streaming = vdec_stop_streaming,
        .buf_queue = venus_helper_vb2_buf_queue,
 };
 
@@ -874,9 +1115,9 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type,
 
        vbuf->flags = flags;
        vbuf->field = V4L2_FIELD_NONE;
+       vb = &vbuf->vb2_buf;
 
        if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-               vb = &vbuf->vb2_buf;
                vb2_set_plane_payload(vb, 0, bytesused);
                vb->planes[0].data_offset = data_offset;
                vb->timestamp = timestamp_us * NSEC_PER_USEC;
@@ -886,28 +1127,85 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type,
                        const struct v4l2_event ev = { .type = V4L2_EVENT_EOS };
 
                        v4l2_event_queue_fh(&inst->fh, &ev);
+
+                       if (inst->codec_state == VENUS_DEC_STATE_DRAIN)
+                               inst->codec_state = VENUS_DEC_STATE_STOPPED;
                }
        } else {
                vbuf->sequence = inst->sequence_out++;
        }
 
+       venus_helper_get_ts_metadata(inst, timestamp_us, vbuf);
+
        if (hfi_flags & HFI_BUFFERFLAG_READONLY)
                venus_helper_acquire_buf_ref(vbuf);
 
        if (hfi_flags & HFI_BUFFERFLAG_DATACORRUPT)
                state = VB2_BUF_STATE_ERROR;
 
+       if (hfi_flags & HFI_BUFFERFLAG_DROP_FRAME) {
+               state = VB2_BUF_STATE_ERROR;
+               vb2_set_plane_payload(vb, 0, 0);
+               vb->timestamp = 0;
+       }
+
        v4l2_m2m_buf_done(vbuf, state);
 }
 
+static void vdec_event_change(struct venus_inst *inst,
+                             struct hfi_event_data *ev_data, bool sufficient)
+{
+       static const struct v4l2_event ev = {
+               .type = V4L2_EVENT_SOURCE_CHANGE,
+               .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION };
+       struct device *dev = inst->core->dev_dec;
+       struct v4l2_format format = {};
+
+       mutex_lock(&inst->lock);
+
+       format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
+       format.fmt.pix_mp.pixelformat = inst->fmt_cap->pixfmt;
+       format.fmt.pix_mp.width = ev_data->width;
+       format.fmt.pix_mp.height = ev_data->height;
+
+       vdec_try_fmt_common(inst, &format);
+
+       inst->width = format.fmt.pix_mp.width;
+       inst->height = format.fmt.pix_mp.height;
+
+       inst->out_width = ev_data->width;
+       inst->out_height = ev_data->height;
+
+       dev_dbg(dev, "event %s sufficient resources (%ux%u)\n",
+               sufficient ? "" : "not", ev_data->width, ev_data->height);
+
+       if (sufficient) {
+               hfi_session_continue(inst);
+       } else {
+               switch (inst->codec_state) {
+               case VENUS_DEC_STATE_INIT:
+                       inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP;
+                       break;
+               case VENUS_DEC_STATE_DECODING:
+                       inst->codec_state = VENUS_DEC_STATE_DRC;
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       inst->reconfig = true;
+       v4l2_event_queue_fh(&inst->fh, &ev);
+       wake_up(&inst->reconf_wait);
+
+       mutex_unlock(&inst->lock);
+}
+
 static void vdec_event_notify(struct venus_inst *inst, u32 event,
                              struct hfi_event_data *data)
 {
        struct venus_core *core = inst->core;
        struct device *dev = core->dev_dec;
-       static const struct v4l2_event ev = {
-               .type = V4L2_EVENT_SOURCE_CHANGE,
-               .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION };
 
        switch (event) {
        case EVT_SESSION_ERROR:
@@ -917,18 +1215,10 @@ static void vdec_event_notify(struct venus_inst *inst, u32 event,
        case EVT_SYS_EVENT_CHANGE:
                switch (data->event_type) {
                case HFI_EVENT_DATA_SEQUENCE_CHANGED_SUFFICIENT_BUF_RESOURCES:
-                       hfi_session_continue(inst);
-                       dev_dbg(dev, "event sufficient resources\n");
+                       vdec_event_change(inst, data, true);
                        break;
                case HFI_EVENT_DATA_SEQUENCE_CHANGED_INSUFFICIENT_BUF_RESOURCES:
-                       inst->reconfig_height = data->height;
-                       inst->reconfig_width = data->width;
-                       inst->reconfig = true;
-
-                       v4l2_event_queue_fh(&inst->fh, &ev);
-
-                       dev_dbg(dev, "event not sufficient resources (%ux%u)\n",
-                               data->width, data->height);
+                       vdec_event_change(inst, data, false);
                        break;
                case HFI_EVENT_RELEASE_BUFFER_REFERENCE:
                        venus_helper_release_buf_ref(inst, data->tag);
@@ -949,20 +1239,25 @@ static const struct hfi_inst_ops vdec_hfi_ops = {
 
 static void vdec_inst_init(struct venus_inst *inst)
 {
+       inst->hfi_codec = HFI_VIDEO_CODEC_H264;
        inst->fmt_out = &vdec_formats[6];
        inst->fmt_cap = &vdec_formats[0];
-       inst->width = 1280;
-       inst->height = ALIGN(720, 32);
-       inst->out_width = 1280;
-       inst->out_height = 720;
+       inst->width = frame_width_min(inst);
+       inst->height = ALIGN(frame_height_min(inst), 32);
+       inst->out_width = frame_width_min(inst);
+       inst->out_height = frame_height_min(inst);
        inst->fps = 30;
        inst->timeperframe.numerator = 1;
        inst->timeperframe.denominator = 30;
-       inst->hfi_codec = HFI_VIDEO_CODEC_H264;
+       inst->opb_buftype = HFI_BUFFER_OUTPUT;
+}
+
+static void vdec_m2m_device_run(void *priv)
+{
 }
 
 static const struct v4l2_m2m_ops vdec_m2m_ops = {
-       .device_run = venus_helper_m2m_device_run,
+       .device_run = vdec_m2m_device_run,
        .job_abort = venus_helper_m2m_job_abort,
 };
 
@@ -980,7 +1275,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
        src_vq->drv_priv = inst;
        src_vq->buf_struct_size = sizeof(struct venus_buffer);
        src_vq->allow_zero_bytesused = 1;
-       src_vq->min_buffers_needed = 1;
+       src_vq->min_buffers_needed = 0;
        src_vq->dev = inst->core->dev;
        ret = vb2_queue_init(src_vq);
        if (ret)
@@ -994,7 +1289,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
        dst_vq->drv_priv = inst;
        dst_vq->buf_struct_size = sizeof(struct venus_buffer);
        dst_vq->allow_zero_bytesused = 1;
-       dst_vq->min_buffers_needed = 1;
+       dst_vq->min_buffers_needed = 0;
        dst_vq->dev = inst->core->dev;
        ret = vb2_queue_init(dst_vq);
        if (ret) {
@@ -1024,7 +1319,9 @@ static int vdec_open(struct file *file)
        inst->core = core;
        inst->session_type = VIDC_SESSION_TYPE_DEC;
        inst->num_output_bufs = 1;
-
+       inst->codec_state = VENUS_DEC_STATE_DEINIT;
+       inst->buf_count = 0;
+       init_waitqueue_head(&inst->reconf_wait);
        venus_helper_init_instance(inst);
 
        ret = pm_runtime_get_sync(core->dev_dec);
index 300350bfe8bd50c319eca9c5288972b2a9bdae30..3a963cbd342afc037a96804fadad8494dd6554c0 100644 (file)
@@ -7,6 +7,7 @@
 #include <media/v4l2-ctrls.h>
 
 #include "core.h"
+#include "helpers.h"
 #include "vdec.h"
 
 static int vdec_op_s_ctrl(struct v4l2_ctrl *ctrl)
@@ -38,7 +39,9 @@ static int vdec_op_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
 {
        struct venus_inst *inst = ctrl_to_inst(ctrl);
        struct vdec_controls *ctr = &inst->controls.dec;
+       struct hfi_buffer_requirements bufreq;
        union hfi_get_property hprop;
+       enum hfi_version ver = inst->core->res->hfi_version;
        u32 ptype = HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT;
        int ret;
 
@@ -62,7 +65,9 @@ static int vdec_op_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
                ctrl->val = ctr->post_loop_deb_mode;
                break;
        case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
-               ctrl->val = inst->num_output_bufs;
+               ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq);
+               if (!ret)
+                       ctrl->val = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
                break;
        default:
                return -EINVAL;
index a5f3d2c46bea6ba8456397ac2eeef4e578f66765..1b7fb2d5887c6a07fcb425c40ec7356dd011e0f5 100644 (file)
@@ -294,6 +294,7 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
        struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp;
        struct v4l2_plane_pix_format *pfmt = pixmp->plane_fmt;
        const struct venus_format *fmt;
+       u32 sizeimage;
 
        memset(pfmt[0].reserved, 0, sizeof(pfmt[0].reserved));
        memset(pixmp->reserved, 0, sizeof(pixmp->reserved));
@@ -325,9 +326,10 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
        pixmp->num_planes = fmt->num_planes;
        pixmp->flags = 0;
 
-       pfmt[0].sizeimage = venus_helper_get_framesz(pixmp->pixelformat,
-                                                    pixmp->width,
-                                                    pixmp->height);
+       sizeimage = venus_helper_get_framesz(pixmp->pixelformat,
+                                            pixmp->width,
+                                            pixmp->height);
+       pfmt[0].sizeimage = max(ALIGN(pfmt[0].sizeimage, SZ_4K), sizeimage);
 
        if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
                pfmt[0].bytesperline = ALIGN(pixmp->width, 128);
@@ -399,8 +401,10 @@ static int venc_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
 
        if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
                inst->fmt_out = fmt;
-       else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+       else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
                inst->fmt_cap = fmt;
+               inst->output_buf_size = pixmp->plane_fmt[0].sizeimage;
+       }
 
        return 0;
 }
@@ -918,6 +922,7 @@ static int venc_queue_setup(struct vb2_queue *q,
                sizes[0] = venus_helper_get_framesz(inst->fmt_cap->pixfmt,
                                                    inst->width,
                                                    inst->height);
+               sizes[0] = max(sizes[0], inst->output_buf_size);
                inst->output_buf_size = sizes[0];
                break;
        default:
index 64f9cf790445d14e63683fa60f010462899f43b5..6993484ff0f393ff1e144da06fb9ae73cf9c34fa 100644 (file)
@@ -389,6 +389,28 @@ static void rvin_group_put(struct rvin_dev *vin)
        kref_put(&group->refcount, rvin_group_release);
 }
 
+/* -----------------------------------------------------------------------------
+ * Controls
+ */
+
+static int rvin_s_ctrl(struct v4l2_ctrl *ctrl)
+{
+       struct rvin_dev *vin =
+               container_of(ctrl->handler, struct rvin_dev, ctrl_handler);
+
+       switch (ctrl->id) {
+       case V4L2_CID_ALPHA_COMPONENT:
+               rvin_set_alpha(vin, ctrl->val);
+               break;
+       }
+
+       return 0;
+}
+
+static const struct v4l2_ctrl_ops rvin_ctrl_ops = {
+       .s_ctrl = rvin_s_ctrl,
+};
+
 /* -----------------------------------------------------------------------------
  * Async notifier
  */
@@ -478,6 +500,15 @@ static int rvin_parallel_subdevice_attach(struct rvin_dev *vin,
        if (ret < 0)
                return ret;
 
+       v4l2_ctrl_new_std(&vin->ctrl_handler, &rvin_ctrl_ops,
+                         V4L2_CID_ALPHA_COMPONENT, 0, 255, 1, 255);
+
+       if (vin->ctrl_handler.error) {
+               ret = vin->ctrl_handler.error;
+               v4l2_ctrl_handler_free(&vin->ctrl_handler);
+               return ret;
+       }
+
        ret = v4l2_ctrl_add_handler(&vin->ctrl_handler, subdev->ctrl_handler,
                                    NULL, true);
        if (ret < 0) {
@@ -633,7 +664,7 @@ static int rvin_parallel_init(struct rvin_dev *vin)
        ret = v4l2_async_notifier_register(&vin->v4l2_dev, &vin->notifier);
        if (ret < 0) {
                vin_err(vin, "Notifier registration failed\n");
-               v4l2_async_notifier_cleanup(&vin->group->notifier);
+               v4l2_async_notifier_cleanup(&vin->notifier);
                return ret;
        }
 
@@ -870,6 +901,21 @@ static int rvin_mc_init(struct rvin_dev *vin)
        if (ret)
                rvin_group_put(vin);
 
+       ret = v4l2_ctrl_handler_init(&vin->ctrl_handler, 1);
+       if (ret < 0)
+               return ret;
+
+       v4l2_ctrl_new_std(&vin->ctrl_handler, &rvin_ctrl_ops,
+                         V4L2_CID_ALPHA_COMPONENT, 0, 255, 1, 255);
+
+       if (vin->ctrl_handler.error) {
+               ret = vin->ctrl_handler.error;
+               v4l2_ctrl_handler_free(&vin->ctrl_handler);
+               return ret;
+       }
+
+       vin->vdev.ctrl_handler = &vin->ctrl_handler;
+
        return ret;
 }
 
@@ -1245,6 +1291,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
 
        vin->dev = &pdev->dev;
        vin->info = of_device_get_match_data(&pdev->dev);
+       vin->alpha = 0xff;
 
        /*
         * Special care is needed on r8a7795 ES1.x since it
@@ -1288,6 +1335,8 @@ static int rcar_vin_probe(struct platform_device *pdev)
        return 0;
 
 error_group_unregister:
+       v4l2_ctrl_handler_free(&vin->ctrl_handler);
+
        if (vin->info->use_mc) {
                mutex_lock(&vin->group->lock);
                if (&vin->v4l2_dev == vin->group->notifier.v4l2_dev) {
@@ -1323,10 +1372,10 @@ static int rcar_vin_remove(struct platform_device *pdev)
                }
                mutex_unlock(&vin->group->lock);
                rvin_group_put(vin);
-       } else {
-               v4l2_ctrl_handler_free(&vin->ctrl_handler);
        }
 
+       v4l2_ctrl_handler_free(&vin->ctrl_handler);
+
        rvin_dma_unregister(vin);
 
        return 0;
index 91ab064404a185af9843a2b6009af2aee8c20027..f16f2966f9628b728c5145007f56269aec93d6a7 100644 (file)
 #define VNIE_EFE               (1 << 1)
 
 /* Video n Data Mode Register bits */
+#define VNDMR_A8BIT(n)         (((n) & 0xff) << 24)
+#define VNDMR_A8BIT_MASK       (0xff << 24)
 #define VNDMR_EXRGB            (1 << 8)
 #define VNDMR_BPSM             (1 << 4)
+#define VNDMR_ABIT             (1 << 2)
 #define VNDMR_DTMD_YCSEP       (1 << 1)
-#define VNDMR_DTMD_ARGB1555    (1 << 0)
+#define VNDMR_DTMD_ARGB                (1 << 0)
 
 /* Video n Data Mode Register 2 bits */
 #define VNDMR2_VPS             (1 << 30)
@@ -721,7 +724,7 @@ static int rvin_setup(struct rvin_dev *vin)
                output_is_yuv = true;
                break;
        case V4L2_PIX_FMT_XRGB555:
-               dmr = VNDMR_DTMD_ARGB1555;
+               dmr = VNDMR_DTMD_ARGB;
                break;
        case V4L2_PIX_FMT_RGB565:
                dmr = 0;
@@ -730,6 +733,12 @@ static int rvin_setup(struct rvin_dev *vin)
                /* Note: not supported on M1 */
                dmr = VNDMR_EXRGB;
                break;
+       case V4L2_PIX_FMT_ARGB555:
+               dmr = (vin->alpha ? VNDMR_ABIT : 0) | VNDMR_DTMD_ARGB;
+               break;
+       case V4L2_PIX_FMT_ABGR32:
+               dmr = VNDMR_A8BIT(vin->alpha) | VNDMR_EXRGB | VNDMR_DTMD_ARGB;
+               break;
        default:
                vin_err(vin, "Invalid pixelformat (0x%x)\n",
                        vin->format.pixelformat);
@@ -794,7 +803,7 @@ static void rvin_set_slot_addr(struct rvin_dev *vin, int slot, dma_addr_t addr)
        int offsetx, offsety;
        dma_addr_t offset;
 
-       fmt = rvin_format_from_pixel(vin->format.pixelformat);
+       fmt = rvin_format_from_pixel(vin, vin->format.pixelformat);
 
        /*
         * There is no HW support for composition do the beast we can
@@ -1343,3 +1352,34 @@ int rvin_set_channel_routing(struct rvin_dev *vin, u8 chsel)
 
        return 0;
 }
+
+void rvin_set_alpha(struct rvin_dev *vin, unsigned int alpha)
+{
+       unsigned long flags;
+       u32 dmr;
+
+       spin_lock_irqsave(&vin->qlock, flags);
+
+       vin->alpha = alpha;
+
+       if (vin->state == STOPPED)
+               goto out;
+
+       switch (vin->format.pixelformat) {
+       case V4L2_PIX_FMT_ARGB555:
+               dmr = rvin_read(vin, VNDMR_REG) & ~VNDMR_ABIT;
+               if (vin->alpha)
+                       dmr |= VNDMR_ABIT;
+               break;
+       case V4L2_PIX_FMT_ABGR32:
+               dmr = rvin_read(vin, VNDMR_REG) & ~VNDMR_A8BIT_MASK;
+               dmr |= VNDMR_A8BIT(vin->alpha);
+               break;
+       default:
+               goto out;
+       }
+
+       rvin_write(vin, dmr,  VNDMR_REG);
+out:
+       spin_unlock_irqrestore(&vin->qlock, flags);
+}
index 0936bcd98df1f75dfd8a8029fa8ef3e29fa93b5f..cfed0a2604133849132ae470b0324142d336228e 100644 (file)
@@ -54,12 +54,24 @@ static const struct rvin_video_format rvin_formats[] = {
                .fourcc                 = V4L2_PIX_FMT_XBGR32,
                .bpp                    = 4,
        },
+       {
+               .fourcc                 = V4L2_PIX_FMT_ARGB555,
+               .bpp                    = 2,
+       },
+       {
+               .fourcc                 = V4L2_PIX_FMT_ABGR32,
+               .bpp                    = 4,
+       },
 };
 
-const struct rvin_video_format *rvin_format_from_pixel(u32 pixelformat)
+const struct rvin_video_format *rvin_format_from_pixel(struct rvin_dev *vin,
+                                                      u32 pixelformat)
 {
        int i;
 
+       if (vin->info->model == RCAR_M1 && pixelformat == V4L2_PIX_FMT_XBGR32)
+               return NULL;
+
        for (i = 0; i < ARRAY_SIZE(rvin_formats); i++)
                if (rvin_formats[i].fourcc == pixelformat)
                        return rvin_formats + i;
@@ -67,11 +79,12 @@ const struct rvin_video_format *rvin_format_from_pixel(u32 pixelformat)
        return NULL;
 }
 
-static u32 rvin_format_bytesperline(struct v4l2_pix_format *pix)
+static u32 rvin_format_bytesperline(struct rvin_dev *vin,
+                                   struct v4l2_pix_format *pix)
 {
        const struct rvin_video_format *fmt;
 
-       fmt = rvin_format_from_pixel(pix->pixelformat);
+       fmt = rvin_format_from_pixel(vin, pix->pixelformat);
 
        if (WARN_ON(!fmt))
                return -EINVAL;
@@ -91,9 +104,7 @@ static void rvin_format_align(struct rvin_dev *vin, struct v4l2_pix_format *pix)
 {
        u32 walign;
 
-       if (!rvin_format_from_pixel(pix->pixelformat) ||
-           (vin->info->model == RCAR_M1 &&
-            pix->pixelformat == V4L2_PIX_FMT_XBGR32))
+       if (!rvin_format_from_pixel(vin, pix->pixelformat))
                pix->pixelformat = RVIN_DEFAULT_FORMAT;
 
        switch (pix->field) {
@@ -125,7 +136,7 @@ static void rvin_format_align(struct rvin_dev *vin, struct v4l2_pix_format *pix)
        v4l_bound_align_image(&pix->width, 2, vin->info->max_width, walign,
                              &pix->height, 4, vin->info->max_height, 2, 0);
 
-       pix->bytesperline = rvin_format_bytesperline(pix);
+       pix->bytesperline = rvin_format_bytesperline(vin, pix);
        pix->sizeimage = rvin_format_sizeimage(pix);
 
        vin_dbg(vin, "Format %ux%u bpl: %u size: %u\n",
@@ -181,9 +192,7 @@ static int rvin_try_format(struct rvin_dev *vin, u32 which,
        if (pad_cfg == NULL)
                return -ENOMEM;
 
-       if (!rvin_format_from_pixel(pix->pixelformat) ||
-           (vin->info->model == RCAR_M1 &&
-            pix->pixelformat == V4L2_PIX_FMT_XBGR32))
+       if (!rvin_format_from_pixel(vin, pix->pixelformat))
                pix->pixelformat = RVIN_DEFAULT_FORMAT;
 
        v4l2_fill_mbus_format(&format.format, pix, vin->mbus_code);
@@ -384,7 +393,7 @@ static int rvin_s_selection(struct file *file, void *fh,
                while ((r.top * vin->format.bytesperline) & HW_BUFFER_MASK)
                        r.top--;
 
-               fmt = rvin_format_from_pixel(vin->format.pixelformat);
+               fmt = rvin_format_from_pixel(vin, vin->format.pixelformat);
                while ((r.left * fmt->bpp) & HW_BUFFER_MASK)
                        r.left--;
 
@@ -781,26 +790,26 @@ static int rvin_open(struct file *file)
        if (ret)
                goto err_unlock;
 
-       if (vin->info->use_mc) {
+       if (vin->info->use_mc)
                ret = v4l2_pipeline_pm_use(&vin->vdev.entity, 1);
-               if (ret < 0)
-                       goto err_open;
-       } else {
-               if (v4l2_fh_is_singular_file(file)) {
-                       ret = rvin_power_parallel(vin, true);
-                       if (ret < 0)
-                               goto err_open;
-
-                       ret = v4l2_ctrl_handler_setup(&vin->ctrl_handler);
-                       if (ret)
-                               goto err_parallel;
-               }
-       }
+       else if (v4l2_fh_is_singular_file(file))
+               ret = rvin_power_parallel(vin, true);
+
+       if (ret < 0)
+               goto err_open;
+
+       ret = v4l2_ctrl_handler_setup(&vin->ctrl_handler);
+       if (ret)
+               goto err_power;
+
        mutex_unlock(&vin->lock);
 
        return 0;
-err_parallel:
-       rvin_power_parallel(vin, false);
+err_power:
+       if (vin->info->use_mc)
+               v4l2_pipeline_pm_use(&vin->vdev.entity, 0);
+       else if (v4l2_fh_is_singular_file(file))
+               rvin_power_parallel(vin, false);
 err_open:
        v4l2_fh_release(file);
 err_unlock:
index 0b13b34d03e3dce4f3ee6121a033e507352594aa..e562c2ff21ec7e7bb11a4490f157be4fafebd5db 100644 (file)
@@ -178,6 +178,8 @@ struct rvin_info {
  * @compose:           active composing
  * @source:            active size of the video source
  * @std:               active video standard of the video source
+ *
+ * @alpha:             Alpha component to fill in for supported pixel formats
  */
 struct rvin_dev {
        struct device *dev;
@@ -215,6 +217,8 @@ struct rvin_dev {
        struct v4l2_rect compose;
        struct v4l2_rect source;
        v4l2_std_id std;
+
+       unsigned int alpha;
 };
 
 #define vin_to_source(vin)             ((vin)->parallel->subdev)
@@ -260,11 +264,14 @@ void rvin_dma_unregister(struct rvin_dev *vin);
 int rvin_v4l2_register(struct rvin_dev *vin);
 void rvin_v4l2_unregister(struct rvin_dev *vin);
 
-const struct rvin_video_format *rvin_format_from_pixel(u32 pixelformat);
+const struct rvin_video_format *rvin_format_from_pixel(struct rvin_dev *vin,
+                                                      u32 pixelformat);
+
 
 /* Cropping, composing and scaling */
 void rvin_crop_scale_comp(struct rvin_dev *vin);
 
 int rvin_set_channel_routing(struct rvin_dev *vin, u8 chsel);
+void rvin_set_alpha(struct rvin_dev *vin, unsigned int alpha);
 
 #endif
index 57d0c0f9fa4be56483becdc43cd96d0f1ce9d1df..197b3991330d588118d4ef2f6012732d043468d7 100644 (file)
@@ -1659,10 +1659,8 @@ static int ceu_probe(struct platform_device *pdev)
        }
 
        ret = platform_get_irq(pdev, 0);
-       if (ret < 0) {
-               dev_err(dev, "Failed to get irq: %d\n", ret);
+       if (ret < 0)
                goto error_free_ceudev;
-       }
        irq = ret;
 
        ret = devm_request_irq(dev, irq, ceu_irq,
index 5283d4533fa029333b72352156a272c64449f401..e9ff12b6b5bb5ebe68e712cb241caa1b0f556dad 100644 (file)
@@ -831,7 +831,6 @@ static int rga_probe(struct platform_device *pdev)
 
        irq = platform_get_irq(pdev, 0);
        if (irq < 0) {
-               dev_err(rga->dev, "failed to get irq\n");
                ret = irq;
                goto err_put_clk;
        }
index a876d0873ebc5def3d8c7871e0cddbbbac840606..2fb45db8e4ba4736ea0750c7ec0c1d38185cce0e 100644 (file)
@@ -641,10 +641,6 @@ static int s3c_camif_vidioc_querycap(struct file *file, void *priv,
        strscpy(cap->card, S3C_CAMIF_DRIVER_NAME, sizeof(cap->card));
        snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s.%d",
                 dev_name(vp->camif->dev), vp->id);
-
-       cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_CAPTURE;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
-
        return 0;
 }
 
@@ -685,10 +681,7 @@ static int s3c_camif_vidioc_enum_fmt(struct file *file, void *priv,
        if (!fmt)
                return -EINVAL;
 
-       strscpy(f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->fourcc;
-
-       pr_debug("fmt(%d): %s\n", f->index, f->description);
        return 0;
 }
 
@@ -802,10 +795,10 @@ static int s3c_camif_vidioc_s_fmt(struct file *file, void *priv,
        if (vp->owner == NULL)
                vp->owner = priv;
 
-       pr_debug("%ux%u. payload: %u. fmt: %s. %d %d. sizeimage: %d. bpl: %d\n",
-               out_frame->f_width, out_frame->f_height, vp->payload, fmt->name,
-               pix->width * pix->height * fmt->depth, fmt->depth,
-               pix->sizeimage, pix->bytesperline);
+       pr_debug("%ux%u. payload: %u. fmt: 0x%08x. %d %d. sizeimage: %d. bpl: %d\n",
+                out_frame->f_width, out_frame->f_height, vp->payload,
+                fmt->fourcc, pix->width * pix->height * fmt->depth,
+                fmt->depth, pix->sizeimage, pix->bytesperline);
 
        return 0;
 }
@@ -1163,6 +1156,7 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx)
                goto err_me_cleanup;
 
        vfd->ctrl_handler = &vp->ctrl_handler;
+       vfd->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_CAPTURE;
 
        ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);
        if (ret)
index b05ce0149ca1b533e66ebadd35d51d1167cdb7ca..c6fbcd7036d6d6ab7042f0858dd34aa2de973d6e 100644 (file)
@@ -42,7 +42,6 @@ static char *camif_clocks[CLK_MAX_NUM] = {
 
 static const struct camif_fmt camif_formats[] = {
        {
-               .name           = "YUV 4:2:2 planar, Y/Cb/Cr",
                .fourcc         = V4L2_PIX_FMT_YUV422P,
                .depth          = 16,
                .ybpp           = 1,
@@ -51,7 +50,6 @@ static const struct camif_fmt camif_formats[] = {
                .flags          = FMT_FL_S3C24XX_CODEC |
                                  FMT_FL_S3C64XX,
        }, {
-               .name           = "YUV 4:2:0 planar, Y/Cb/Cr",
                .fourcc         = V4L2_PIX_FMT_YUV420,
                .depth          = 12,
                .ybpp           = 1,
@@ -60,7 +58,6 @@ static const struct camif_fmt camif_formats[] = {
                .flags          = FMT_FL_S3C24XX_CODEC |
                                  FMT_FL_S3C64XX,
        }, {
-               .name           = "YVU 4:2:0 planar, Y/Cr/Cb",
                .fourcc         = V4L2_PIX_FMT_YVU420,
                .depth          = 12,
                .ybpp           = 1,
@@ -69,7 +66,6 @@ static const struct camif_fmt camif_formats[] = {
                .flags          = FMT_FL_S3C24XX_CODEC |
                                  FMT_FL_S3C64XX,
        }, {
-               .name           = "RGB565, 16 bpp",
                .fourcc         = V4L2_PIX_FMT_RGB565X,
                .depth          = 16,
                .ybpp           = 2,
@@ -78,7 +74,6 @@ static const struct camif_fmt camif_formats[] = {
                .flags          = FMT_FL_S3C24XX_PREVIEW |
                                  FMT_FL_S3C64XX,
        }, {
-               .name           = "XRGB8888, 32 bpp",
                .fourcc         = V4L2_PIX_FMT_RGB32,
                .depth          = 32,
                .ybpp           = 4,
@@ -87,7 +82,6 @@ static const struct camif_fmt camif_formats[] = {
                .flags          = FMT_FL_S3C24XX_PREVIEW |
                                  FMT_FL_S3C64XX,
        }, {
-               .name           = "BGR666",
                .fourcc         = V4L2_PIX_FMT_BGR666,
                .depth          = 32,
                .ybpp           = 4,
@@ -386,10 +380,8 @@ static int camif_request_irqs(struct platform_device *pdev,
                init_waitqueue_head(&vp->irq_queue);
 
                irq = platform_get_irq(pdev, i);
-               if (irq <= 0) {
-                       dev_err(&pdev->dev, "failed to get IRQ %d\n", i);
+               if (irq <= 0)
                        return -ENXIO;
-               }
 
                ret = devm_request_irq(&pdev->dev, irq, s3c_camif_irq_handler,
                                       0, dev_name(&pdev->dev), vp);
index efdc00b4ec6fe2f76438ef840ed43ffb4d8b42df..f937e638490f887a3cad989ddd0b339c751505a0 100644 (file)
@@ -89,7 +89,6 @@ enum img_fmt {
  * @ybpp:      number of luminance bytes per pixel
  */
 struct camif_fmt {
-       char *name;
        u32 fourcc;
        u32 color;
        u16 colplanes;
index ea6231b387ed2ac24ea76bcc521e8ca0dc11b77d..6ddcc35b0bbda16e588066b3d94ed4f9ef0619a3 100644 (file)
@@ -214,21 +214,23 @@ static int s5p_cec_probe(struct platform_device *pdev)
        if (IS_ERR(cec->reg))
                return PTR_ERR(cec->reg);
 
-       cec->notifier = cec_notifier_get(hdmi_dev);
-       if (cec->notifier == NULL)
-               return -ENOMEM;
-
        cec->adap = cec_allocate_adapter(&s5p_cec_adap_ops, cec, CEC_NAME,
-               CEC_CAP_DEFAULTS | (needs_hpd ? CEC_CAP_NEEDS_HPD : 0), 1);
+               CEC_CAP_DEFAULTS | (needs_hpd ? CEC_CAP_NEEDS_HPD : 0) |
+               CEC_CAP_CONNECTOR_INFO, 1);
        ret = PTR_ERR_OR_ZERO(cec->adap);
        if (ret)
                return ret;
 
-       ret = cec_register_adapter(cec->adap, &pdev->dev);
-       if (ret)
+       cec->notifier = cec_notifier_cec_adap_register(hdmi_dev, NULL,
+                                                      cec->adap);
+       if (!cec->notifier) {
+               ret = -ENOMEM;
                goto err_delete_adapter;
+       }
 
-       cec_register_cec_notifier(cec->adap, cec->notifier);
+       ret = cec_register_adapter(cec->adap, &pdev->dev);
+       if (ret)
+               goto err_notifier;
 
        platform_set_drvdata(pdev, cec);
        pm_runtime_enable(dev);
@@ -236,6 +238,9 @@ static int s5p_cec_probe(struct platform_device *pdev)
        dev_dbg(dev, "successfully probed\n");
        return 0;
 
+err_notifier:
+       cec_notifier_cec_adap_unregister(cec->notifier);
+
 err_delete_adapter:
        cec_delete_adapter(cec->adap);
        return ret;
@@ -245,8 +250,8 @@ static int s5p_cec_remove(struct platform_device *pdev)
 {
        struct s5p_cec_dev *cec = platform_get_drvdata(pdev);
 
+       cec_notifier_cec_adap_unregister(cec->notifier);
        cec_unregister_adapter(cec->adap);
-       cec_notifier_put(cec->notifier);
        pm_runtime_disable(&pdev->dev);
        return 0;
 }
index 152d192d5c3f30f04cb240ff0cf400e0595975fa..f5f05ea9f5213172e387fdf02def9be199eb4597 100644 (file)
 
 static struct g2d_fmt formats[] = {
        {
-               .name   = "XRGB_8888",
                .fourcc = V4L2_PIX_FMT_RGB32,
                .depth  = 32,
                .hw     = COLOR_MODE(ORDER_XRGB, MODE_XRGB_8888),
        },
        {
-               .name   = "RGB_565",
                .fourcc = V4L2_PIX_FMT_RGB565X,
                .depth  = 16,
                .hw     = COLOR_MODE(ORDER_XRGB, MODE_RGB_565),
        },
        {
-               .name   = "XRGB_1555",
                .fourcc = V4L2_PIX_FMT_RGB555X,
                .depth  = 16,
                .hw     = COLOR_MODE(ORDER_XRGB, MODE_XRGB_1555),
        },
        {
-               .name   = "XRGB_4444",
                .fourcc = V4L2_PIX_FMT_RGB444,
                .depth  = 16,
                .hw     = COLOR_MODE(ORDER_XRGB, MODE_XRGB_4444),
        },
        {
-               .name   = "PACKED_RGB_888",
                .fourcc = V4L2_PIX_FMT_RGB24,
                .depth  = 24,
                .hw     = COLOR_MODE(ORDER_XRGB, MODE_PACKED_RGB_888),
@@ -296,19 +291,14 @@ static int vidioc_querycap(struct file *file, void *priv,
        strscpy(cap->driver, G2D_NAME, sizeof(cap->driver));
        strscpy(cap->card, G2D_NAME, sizeof(cap->card));
        cap->bus_info[0] = 0;
-       cap->device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
        return 0;
 }
 
 static int vidioc_enum_fmt(struct file *file, void *prv, struct v4l2_fmtdesc *f)
 {
-       struct g2d_fmt *fmt;
        if (f->index >= NUM_FORMATS)
                return -EINVAL;
-       fmt = &formats[f->index];
-       f->pixelformat = fmt->fourcc;
-       strscpy(f->description, fmt->name, sizeof(f->description));
+       f->pixelformat = formats[f->index].fourcc;
        return 0;
 }
 
@@ -704,6 +694,7 @@ static int g2d_probe(struct platform_device *pdev)
        set_bit(V4L2_FL_QUIRK_INVERTED_CROP, &vfd->flags);
        vfd->lock = &dev->mutex;
        vfd->v4l2_dev = &dev->v4l2_dev;
+       vfd->device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING;
        ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
        if (ret) {
                v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
index def0ec0dabeba0d1322c5dd3e93574ee399f23e3..c2309c1370daa6405985f17ead2cbaee32e3511d 100644 (file)
@@ -61,7 +61,6 @@ struct g2d_ctx {
 };
 
 struct g2d_fmt {
-       char    *name;
        u32     fourcc;
        int     depth;
        u32     hw;
index a3bc884b7df1088f183264b4d252effaab1c9286..8dbbd5f2a40a0f0a521dae79299eaa62ee7ba251 100644 (file)
@@ -35,7 +35,6 @@
 
 static struct s5p_jpeg_fmt sjpeg_formats[] = {
        {
-               .name           = "JPEG JFIF",
                .fourcc         = V4L2_PIX_FMT_JPEG,
                .flags          = SJPEG_FMT_FLAG_ENC_CAPTURE |
                                  SJPEG_FMT_FLAG_DEC_OUTPUT |
@@ -44,7 +43,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                                  SJPEG_FMT_FLAG_EXYNOS4,
        },
        {
-               .name           = "YUV 4:2:2 packed, YCbYCr",
                .fourcc         = V4L2_PIX_FMT_YUYV,
                .depth          = 16,
                .colplanes      = 1,
@@ -57,7 +55,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_422,
        },
        {
-               .name           = "YUV 4:2:2 packed, YCbYCr",
                .fourcc         = V4L2_PIX_FMT_YUYV,
                .depth          = 16,
                .colplanes      = 1,
@@ -70,7 +67,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_422,
        },
        {
-               .name           = "YUV 4:2:2 packed, YCbYCr",
                .fourcc         = V4L2_PIX_FMT_YUYV,
                .depth          = 16,
                .colplanes      = 1,
@@ -83,7 +79,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_422,
        },
        {
-               .name           = "YUV 4:2:2 packed, YCrYCb",
                .fourcc         = V4L2_PIX_FMT_YVYU,
                .depth          = 16,
                .colplanes      = 1,
@@ -96,7 +91,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_422,
        },
        {
-               .name           = "YUV 4:2:2 packed, YCrYCb",
                .fourcc         = V4L2_PIX_FMT_YVYU,
                .depth          = 16,
                .colplanes      = 1,
@@ -109,7 +103,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_422,
        },
        {
-               .name           = "YUV 4:2:2 packed, YCrYCb",
                .fourcc         = V4L2_PIX_FMT_UYVY,
                .depth          = 16,
                .colplanes      = 1,
@@ -122,7 +115,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_422,
        },
        {
-               .name           = "YUV 4:2:2 packed, YCrYCb",
                .fourcc         = V4L2_PIX_FMT_VYUY,
                .depth          = 16,
                .colplanes      = 1,
@@ -135,7 +127,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_422,
        },
        {
-               .name           = "RGB565",
                .fourcc         = V4L2_PIX_FMT_RGB565,
                .depth          = 16,
                .colplanes      = 1,
@@ -148,7 +139,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_444,
        },
        {
-               .name           = "RGB565",
                .fourcc         = V4L2_PIX_FMT_RGB565,
                .depth          = 16,
                .colplanes      = 1,
@@ -161,7 +151,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_444,
        },
        {
-               .name           = "RGB565X",
                .fourcc         = V4L2_PIX_FMT_RGB565X,
                .depth          = 16,
                .colplanes      = 1,
@@ -174,7 +163,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_444,
        },
        {
-               .name           = "RGB565",
                .fourcc         = V4L2_PIX_FMT_RGB565,
                .depth          = 16,
                .colplanes      = 1,
@@ -186,7 +174,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_444,
        },
        {
-               .name           = "ARGB8888, 32 bpp",
                .fourcc         = V4L2_PIX_FMT_RGB32,
                .depth          = 32,
                .colplanes      = 1,
@@ -199,7 +186,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_444,
        },
        {
-               .name           = "ARGB8888, 32 bpp",
                .fourcc         = V4L2_PIX_FMT_RGB32,
                .depth          = 32,
                .colplanes      = 1,
@@ -212,7 +198,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_444,
        },
        {
-               .name           = "YUV 4:4:4 planar, Y/CbCr",
                .fourcc         = V4L2_PIX_FMT_NV24,
                .depth          = 24,
                .colplanes      = 2,
@@ -225,7 +210,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_444,
        },
        {
-               .name           = "YUV 4:4:4 planar, Y/CrCb",
                .fourcc         = V4L2_PIX_FMT_NV42,
                .depth          = 24,
                .colplanes      = 2,
@@ -238,7 +222,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_444,
        },
        {
-               .name           = "YUV 4:2:2 planar, Y/CrCb",
                .fourcc         = V4L2_PIX_FMT_NV61,
                .depth          = 16,
                .colplanes      = 2,
@@ -251,7 +234,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_422,
        },
        {
-               .name           = "YUV 4:2:2 planar, Y/CbCr",
                .fourcc         = V4L2_PIX_FMT_NV16,
                .depth          = 16,
                .colplanes      = 2,
@@ -264,7 +246,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_422,
        },
        {
-               .name           = "YUV 4:2:0 planar, Y/CbCr",
                .fourcc         = V4L2_PIX_FMT_NV12,
                .depth          = 12,
                .colplanes      = 2,
@@ -277,7 +258,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_420,
        },
        {
-               .name           = "YUV 4:2:0 planar, Y/CbCr",
                .fourcc         = V4L2_PIX_FMT_NV12,
                .depth          = 12,
                .colplanes      = 2,
@@ -290,7 +270,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_420,
        },
        {
-               .name           = "YUV 4:2:0 planar, Y/CbCr",
                .fourcc         = V4L2_PIX_FMT_NV12,
                .depth          = 12,
                .colplanes      = 2,
@@ -303,7 +282,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_420,
        },
        {
-               .name           = "YUV 4:2:0 planar, Y/CrCb",
                .fourcc         = V4L2_PIX_FMT_NV21,
                .depth          = 12,
                .colplanes      = 2,
@@ -316,7 +294,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_420,
        },
        {
-               .name           = "YUV 4:2:0 planar, Y/CrCb",
                .fourcc         = V4L2_PIX_FMT_NV21,
                .depth          = 12,
                .colplanes      = 2,
@@ -330,7 +307,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_420,
        },
        {
-               .name           = "YUV 4:2:0 contiguous 3-planar, Y/Cb/Cr",
                .fourcc         = V4L2_PIX_FMT_YUV420,
                .depth          = 12,
                .colplanes      = 3,
@@ -343,7 +319,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_420,
        },
        {
-               .name           = "YUV 4:2:0 contiguous 3-planar, Y/Cb/Cr",
                .fourcc         = V4L2_PIX_FMT_YUV420,
                .depth          = 12,
                .colplanes      = 3,
@@ -356,7 +331,6 @@ static struct s5p_jpeg_fmt sjpeg_formats[] = {
                .subsampling    = V4L2_JPEG_CHROMA_SUBSAMPLING_420,
        },
        {
-               .name           = "Gray",
                .fourcc         = V4L2_PIX_FMT_GREY,
                .depth          = 8,
                .colplanes      = 1,
@@ -1285,8 +1259,6 @@ static int s5p_jpeg_querycap(struct file *file, void *priv,
        }
        snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
                 dev_name(ctx->jpeg->dev));
-       cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
        return 0;
 }
 
@@ -1314,7 +1286,6 @@ static int enum_fmt(struct s5p_jpeg_ctx *ctx,
        if (i >= n)
                return -EINVAL;
 
-       strscpy(f->description, sjpeg_formats[i].name, sizeof(f->description));
        f->pixelformat = sjpeg_formats[i].fourcc;
 
        return 0;
@@ -2974,6 +2945,7 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
        jpeg->vfd_encoder->lock         = &jpeg->lock;
        jpeg->vfd_encoder->v4l2_dev     = &jpeg->v4l2_dev;
        jpeg->vfd_encoder->vfl_dir      = VFL_DIR_M2M;
+       jpeg->vfd_encoder->device_caps  = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M;
 
        ret = video_register_device(jpeg->vfd_encoder, VFL_TYPE_GRABBER, -1);
        if (ret) {
@@ -3003,6 +2975,7 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
        jpeg->vfd_decoder->lock         = &jpeg->lock;
        jpeg->vfd_decoder->v4l2_dev     = &jpeg->v4l2_dev;
        jpeg->vfd_decoder->vfl_dir      = VFL_DIR_M2M;
+       jpeg->vfd_decoder->device_caps  = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M;
 
        ret = video_register_device(jpeg->vfd_decoder, VFL_TYPE_GRABBER, -1);
        if (ret) {
index 34f87f6c02f2fdc14769c37664dc9c3a0c7e5211..3bc52f83f5bcda71a02bb8426ede06c44a383d75 100644 (file)
@@ -150,7 +150,6 @@ struct s5p_jpeg_variant {
 
 /**
  * struct jpeg_fmt - driver's internal color format data
- * @name:      format description
  * @fourcc:    the fourcc code, 0 if not applicable
  * @depth:     number of bits per pixel
  * @colplanes: number of color planes (1 for packed formats)
@@ -159,7 +158,6 @@ struct s5p_jpeg_variant {
  * @flags:     flags describing format applicability
  */
 struct s5p_jpeg_fmt {
-       char    *name;
        u32     fourcc;
        int     depth;
        int     colplanes;
index 5dc086516360c39658f295af3eba85a3dae40173..96d1ecd1521b7099f9b02687c6775c95c1be090d 100644 (file)
@@ -718,7 +718,6 @@ struct s5p_mfc_ctx {
  *                     used by the MFC
  */
 struct s5p_mfc_fmt {
-       char *name;
        u32 fourcc;
        u32 codec_mode;
        enum s5p_mfc_fmt_type type;
index 4017c8b471f49ff15194c3063e9c0f2ffd0a9e8b..61e144a352010180664d1e37bc53ab16f5e2e825 100644 (file)
@@ -29,7 +29,6 @@
 
 static struct s5p_mfc_fmt formats[] = {
        {
-               .name           = "4:2:0 2 Planes 16x16 Tiles",
                .fourcc         = V4L2_PIX_FMT_NV12MT_16X16,
                .codec_mode     = S5P_MFC_CODEC_NONE,
                .type           = MFC_FMT_RAW,
@@ -37,7 +36,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V6_BIT | MFC_V7_BIT,
        },
        {
-               .name           = "4:2:0 2 Planes 64x32 Tiles",
                .fourcc         = V4L2_PIX_FMT_NV12MT,
                .codec_mode     = S5P_MFC_CODEC_NONE,
                .type           = MFC_FMT_RAW,
@@ -45,7 +43,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5_BIT,
        },
        {
-               .name           = "4:2:0 2 Planes Y/CbCr",
                .fourcc         = V4L2_PIX_FMT_NV12M,
                .codec_mode     = S5P_MFC_CODEC_NONE,
                .type           = MFC_FMT_RAW,
@@ -53,7 +50,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V6PLUS_BITS,
        },
        {
-               .name           = "4:2:0 2 Planes Y/CrCb",
                .fourcc         = V4L2_PIX_FMT_NV21M,
                .codec_mode     = S5P_MFC_CODEC_NONE,
                .type           = MFC_FMT_RAW,
@@ -61,7 +57,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V6PLUS_BITS,
        },
        {
-               .name           = "H264 Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_H264,
                .codec_mode     = S5P_MFC_CODEC_H264_DEC,
                .type           = MFC_FMT_DEC,
@@ -69,7 +64,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5PLUS_BITS,
        },
        {
-               .name           = "H264/MVC Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_H264_MVC,
                .codec_mode     = S5P_MFC_CODEC_H264_MVC_DEC,
                .type           = MFC_FMT_DEC,
@@ -77,7 +71,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V6PLUS_BITS,
        },
        {
-               .name           = "H263 Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_H263,
                .codec_mode     = S5P_MFC_CODEC_H263_DEC,
                .type           = MFC_FMT_DEC,
@@ -85,7 +78,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5PLUS_BITS,
        },
        {
-               .name           = "MPEG1 Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_MPEG1,
                .codec_mode     = S5P_MFC_CODEC_MPEG2_DEC,
                .type           = MFC_FMT_DEC,
@@ -93,7 +85,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5PLUS_BITS,
        },
        {
-               .name           = "MPEG2 Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_MPEG2,
                .codec_mode     = S5P_MFC_CODEC_MPEG2_DEC,
                .type           = MFC_FMT_DEC,
@@ -101,7 +92,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5PLUS_BITS,
        },
        {
-               .name           = "MPEG4 Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_MPEG4,
                .codec_mode     = S5P_MFC_CODEC_MPEG4_DEC,
                .type           = MFC_FMT_DEC,
@@ -109,7 +99,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5PLUS_BITS,
        },
        {
-               .name           = "XviD Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_XVID,
                .codec_mode     = S5P_MFC_CODEC_MPEG4_DEC,
                .type           = MFC_FMT_DEC,
@@ -117,7 +106,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5PLUS_BITS,
        },
        {
-               .name           = "VC1 Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_VC1_ANNEX_G,
                .codec_mode     = S5P_MFC_CODEC_VC1_DEC,
                .type           = MFC_FMT_DEC,
@@ -125,7 +113,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5PLUS_BITS,
        },
        {
-               .name           = "VC1 RCV Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_VC1_ANNEX_L,
                .codec_mode     = S5P_MFC_CODEC_VC1RCV_DEC,
                .type           = MFC_FMT_DEC,
@@ -133,7 +120,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5PLUS_BITS,
        },
        {
-               .name           = "VP8 Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_VP8,
                .codec_mode     = S5P_MFC_CODEC_VP8_DEC,
                .type           = MFC_FMT_DEC,
@@ -279,7 +265,6 @@ static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
                                                        bool out)
 {
        struct s5p_mfc_dev *dev = video_drvdata(file);
-       struct s5p_mfc_fmt *fmt;
        int i, j = 0;
 
        for (i = 0; i < ARRAY_SIZE(formats); ++i) {
@@ -296,9 +281,7 @@ static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
        }
        if (i == ARRAY_SIZE(formats))
                return -EINVAL;
-       fmt = &formats[i];
-       strscpy(f->description, fmt->name, sizeof(f->description));
-       f->pixelformat = fmt->fourcc;
+       f->pixelformat = formats[i].fourcc;
        return 0;
 }
 
index 97e76480e9426fe42c6d2e16cb5e383f60842116..912fe0c5ab184ecca059bd0395c53f34853e15a5 100644 (file)
@@ -32,7 +32,6 @@
 
 static struct s5p_mfc_fmt formats[] = {
        {
-               .name           = "4:2:0 2 Planes 16x16 Tiles",
                .fourcc         = V4L2_PIX_FMT_NV12MT_16X16,
                .codec_mode     = S5P_MFC_CODEC_NONE,
                .type           = MFC_FMT_RAW,
@@ -40,7 +39,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V6_BIT | MFC_V7_BIT,
        },
        {
-               .name           = "4:2:0 2 Planes 64x32 Tiles",
                .fourcc         = V4L2_PIX_FMT_NV12MT,
                .codec_mode     = S5P_MFC_CODEC_NONE,
                .type           = MFC_FMT_RAW,
@@ -48,7 +46,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5_BIT,
        },
        {
-               .name           = "4:2:0 2 Planes Y/CbCr",
                .fourcc         = V4L2_PIX_FMT_NV12M,
                .codec_mode     = S5P_MFC_CODEC_NONE,
                .type           = MFC_FMT_RAW,
@@ -56,7 +53,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5PLUS_BITS,
        },
        {
-               .name           = "4:2:0 2 Planes Y/CrCb",
                .fourcc         = V4L2_PIX_FMT_NV21M,
                .codec_mode     = S5P_MFC_CODEC_NONE,
                .type           = MFC_FMT_RAW,
@@ -64,7 +60,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V6PLUS_BITS,
        },
        {
-               .name           = "H264 Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_H264,
                .codec_mode     = S5P_MFC_CODEC_H264_ENC,
                .type           = MFC_FMT_ENC,
@@ -72,7 +67,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5PLUS_BITS,
        },
        {
-               .name           = "MPEG4 Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_MPEG4,
                .codec_mode     = S5P_MFC_CODEC_MPEG4_ENC,
                .type           = MFC_FMT_ENC,
@@ -80,7 +74,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5PLUS_BITS,
        },
        {
-               .name           = "H263 Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_H263,
                .codec_mode     = S5P_MFC_CODEC_H263_ENC,
                .type           = MFC_FMT_ENC,
@@ -88,7 +81,6 @@ static struct s5p_mfc_fmt formats[] = {
                .versions       = MFC_V5PLUS_BITS,
        },
        {
-               .name           = "VP8 Encoded Stream",
                .fourcc         = V4L2_PIX_FMT_VP8,
                .codec_mode     = S5P_MFC_CODEC_VP8_ENC,
                .type           = MFC_FMT_ENC,
@@ -1320,7 +1312,6 @@ static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
                                                        bool out)
 {
        struct s5p_mfc_dev *dev = video_drvdata(file);
-       struct s5p_mfc_fmt *fmt;
        int i, j = 0;
 
        for (i = 0; i < ARRAY_SIZE(formats); ++i) {
@@ -1332,10 +1323,7 @@ static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
                        continue;
 
                if (j == f->index) {
-                       fmt = &formats[i];
-                       strscpy(f->description, fmt->name,
-                               sizeof(f->description));
-                       f->pixelformat = fmt->fourcc;
+                       f->pixelformat = formats[i].fourcc;
                        return 0;
                }
                ++j;
index 1d0133f01e00762c9f111eff5093ea31f8ea8847..9cd60fe1867c9a1c368d9a465cbdbb7bf3f7090c 100644 (file)
@@ -507,10 +507,10 @@ static irqreturn_t secocec_irq_handler(int irq, void *priv)
 }
 
 struct cec_dmi_match {
-       char *sys_vendor;
-       char *product_name;
-       char *devname;
-       char *conn;
+       const char *sys_vendor;
+       const char *product_name;
+       const char *devname;
+       const char *conn;
 };
 
 static const struct cec_dmi_match secocec_dmi_match_table[] = {
@@ -518,7 +518,8 @@ static const struct cec_dmi_match secocec_dmi_match_table[] = {
        { "SECO", "UDOO x86", "0000:00:02.0", "Port B" },
 };
 
-static int secocec_cec_get_notifier(struct cec_notifier **notify)
+static struct device *secocec_cec_find_hdmi_dev(struct device *dev,
+                                               const char **conn)
 {
        int i;
 
@@ -533,16 +534,15 @@ static int secocec_cec_get_notifier(struct cec_notifier **notify)
                        d = bus_find_device_by_name(&pci_bus_type, NULL,
                                                    m->devname);
                        if (!d)
-                               return -EPROBE_DEFER;
+                               return ERR_PTR(-EPROBE_DEFER);
 
-                       *notify = cec_notifier_get_conn(d, m->conn);
                        put_device(d);
-
-                       return 0;
+                       *conn = m->conn;
+                       return d;
                }
        }
 
-       return -EINVAL;
+       return ERR_PTR(-EINVAL);
 }
 
 static int secocec_acpi_probe(struct secocec_data *sdev)
@@ -573,9 +573,15 @@ static int secocec_probe(struct platform_device *pdev)
 {
        struct secocec_data *secocec;
        struct device *dev = &pdev->dev;
+       struct device *hdmi_dev;
+       const char *conn = NULL;
        int ret;
        u16 val;
 
+       hdmi_dev = secocec_cec_find_hdmi_dev(&pdev->dev, &conn);
+       if (IS_ERR(hdmi_dev))
+               return PTR_ERR(hdmi_dev);
+
        secocec = devm_kzalloc(dev, sizeof(*secocec), GFP_KERNEL);
        if (!secocec)
                return -ENOMEM;
@@ -617,12 +623,6 @@ static int secocec_probe(struct platform_device *pdev)
                goto err;
        }
 
-       ret = secocec_cec_get_notifier(&secocec->notifier);
-       if (ret) {
-               dev_err(dev, "no CEC notifier available\n");
-               goto err;
-       }
-
        ret = devm_request_threaded_irq(dev,
                                        secocec->irq,
                                        NULL,
@@ -640,7 +640,8 @@ static int secocec_probe(struct platform_device *pdev)
        secocec->cec_adap = cec_allocate_adapter(&secocec_cec_adap_ops,
                                                 secocec,
                                                 dev_name(dev),
-                                                CEC_CAP_DEFAULTS,
+                                                CEC_CAP_DEFAULTS |
+                                                CEC_CAP_CONNECTOR_INFO,
                                                 SECOCEC_MAX_ADDRS);
 
        if (IS_ERR(secocec->cec_adap)) {
@@ -648,16 +649,20 @@ static int secocec_probe(struct platform_device *pdev)
                goto err;
        }
 
-       ret = cec_register_adapter(secocec->cec_adap, dev);
-       if (ret)
+       secocec->notifier = cec_notifier_cec_adap_register(hdmi_dev, conn,
+                                                          secocec->cec_adap);
+       if (!secocec->notifier) {
+               ret = -ENOMEM;
                goto err_delete_adapter;
+       }
 
-       if (secocec->notifier)
-               cec_register_cec_notifier(secocec->cec_adap, secocec->notifier);
+       ret = cec_register_adapter(secocec->cec_adap, dev);
+       if (ret)
+               goto err_notifier;
 
        ret = secocec_ir_probe(secocec);
        if (ret)
-               goto err_delete_adapter;
+               goto err_notifier;
 
        platform_set_drvdata(pdev, secocec);
 
@@ -665,6 +670,8 @@ static int secocec_probe(struct platform_device *pdev)
 
        return ret;
 
+err_notifier:
+       cec_notifier_cec_adap_unregister(secocec->notifier);
 err_delete_adapter:
        cec_delete_adapter(secocec->cec_adap);
 err:
@@ -685,11 +692,9 @@ static int secocec_remove(struct platform_device *pdev)
 
                dev_dbg(&pdev->dev, "IR disabled");
        }
+       cec_notifier_cec_adap_unregister(secocec->notifier);
        cec_unregister_adapter(secocec->cec_adap);
 
-       if (secocec->notifier)
-               cec_notifier_put(secocec->notifier);
-
        release_region(BRA_SMB_BASE_ADDR, 7);
 
        dev_dbg(&pdev->dev, "CEC device removed");
index 5a9ba05c996ea20dadd28a4b63c98d0f39749da2..2b4c0d9d6928870a4ea998fd33eecd1426a3e6a1 100644 (file)
 struct sh_veu_dev;
 
 struct sh_veu_file {
+       struct v4l2_fh fh;
        struct sh_veu_dev *veu_dev;
        bool cfg_needed;
 };
 
 struct sh_veu_format {
-       char *name;
        u32 fourcc;
        unsigned int depth;
        unsigned int ydepth;
@@ -144,14 +144,14 @@ enum sh_veu_fmt_idx {
  * aligned for NV24.
  */
 static const struct sh_veu_format sh_veu_fmt[] = {
-       [SH_VEU_FMT_NV12]   = { .ydepth = 8, .depth = 12, .name = "NV12", .fourcc = V4L2_PIX_FMT_NV12 },
-       [SH_VEU_FMT_NV16]   = { .ydepth = 8, .depth = 16, .name = "NV16", .fourcc = V4L2_PIX_FMT_NV16 },
-       [SH_VEU_FMT_NV24]   = { .ydepth = 8, .depth = 24, .name = "NV24", .fourcc = V4L2_PIX_FMT_NV24 },
-       [SH_VEU_FMT_RGB332] = { .ydepth = 8, .depth = 8, .name = "RGB332", .fourcc = V4L2_PIX_FMT_RGB332 },
-       [SH_VEU_FMT_RGB444] = { .ydepth = 16, .depth = 16, .name = "RGB444", .fourcc = V4L2_PIX_FMT_RGB444 },
-       [SH_VEU_FMT_RGB565] = { .ydepth = 16, .depth = 16, .name = "RGB565", .fourcc = V4L2_PIX_FMT_RGB565 },
-       [SH_VEU_FMT_RGB666] = { .ydepth = 32, .depth = 32, .name = "BGR666", .fourcc = V4L2_PIX_FMT_BGR666 },
-       [SH_VEU_FMT_RGB24]  = { .ydepth = 24, .depth = 24, .name = "RGB24", .fourcc = V4L2_PIX_FMT_RGB24 },
+       [SH_VEU_FMT_NV12]   = { .ydepth = 8, .depth = 12, .fourcc = V4L2_PIX_FMT_NV12 },
+       [SH_VEU_FMT_NV16]   = { .ydepth = 8, .depth = 16, .fourcc = V4L2_PIX_FMT_NV16 },
+       [SH_VEU_FMT_NV24]   = { .ydepth = 8, .depth = 24, .fourcc = V4L2_PIX_FMT_NV24 },
+       [SH_VEU_FMT_RGB332] = { .ydepth = 8, .depth = 8, .fourcc = V4L2_PIX_FMT_RGB332 },
+       [SH_VEU_FMT_RGB444] = { .ydepth = 16, .depth = 16, .fourcc = V4L2_PIX_FMT_RGB444 },
+       [SH_VEU_FMT_RGB565] = { .ydepth = 16, .depth = 16, .fourcc = V4L2_PIX_FMT_RGB565 },
+       [SH_VEU_FMT_RGB666] = { .ydepth = 32, .depth = 32, .fourcc = V4L2_PIX_FMT_BGR666 },
+       [SH_VEU_FMT_RGB24]  = { .ydepth = 24, .depth = 24, .fourcc = V4L2_PIX_FMT_RGB24 },
 };
 
 #define DEFAULT_IN_VFMT (struct sh_veu_vfmt){                                          \
@@ -348,9 +348,6 @@ static int sh_veu_querycap(struct file *file, void *priv,
        strscpy(cap->driver, "sh-veu", sizeof(cap->driver));
        strscpy(cap->card, "sh-mobile VEU", sizeof(cap->card));
        strscpy(cap->bus_info, "platform:sh-veu", sizeof(cap->bus_info));
-       cap->device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
-
        return 0;
 }
 
@@ -359,8 +356,6 @@ static int sh_veu_enum_fmt(struct v4l2_fmtdesc *f, const int *fmt, int fmt_num)
        if (f->index >= fmt_num)
                return -EINVAL;
 
-       strscpy(f->description, sh_veu_fmt[fmt[f->index]].name,
-               sizeof(f->description));
        f->pixelformat = sh_veu_fmt[fmt[f->index]].fourcc;
        return 0;
 }
@@ -967,12 +962,14 @@ static int sh_veu_open(struct file *file)
        if (!veu_file)
                return -ENOMEM;
 
+       v4l2_fh_init(&veu_file->fh, video_devdata(file));
        veu_file->veu_dev = veu;
        veu_file->cfg_needed = true;
 
        file->private_data = veu_file;
 
        pm_runtime_get_sync(veu->dev);
+       v4l2_fh_add(&veu_file->fh);
 
        dev_dbg(veu->dev, "Created instance %p\n", veu_file);
 
@@ -1002,6 +999,8 @@ static int sh_veu_release(struct file *file)
        }
 
        pm_runtime_put(veu->dev);
+       v4l2_fh_del(&veu_file->fh);
+       v4l2_fh_exit(&veu_file->fh);
 
        kfree(veu_file);
 
@@ -1039,6 +1038,7 @@ static const struct video_device sh_veu_videodev = {
        .minor          = -1,
        .release        = video_device_release_empty,
        .vfl_dir        = VFL_DIR_M2M,
+       .device_caps    = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING,
 };
 
 static const struct v4l2_m2m_ops sh_veu_m2m_ops = {
index 5799aa4b932318b85ed93cd18e20593840416416..2236702c21b43faab14f19cd73266aace37f13f7 100644 (file)
@@ -138,7 +138,6 @@ static void sh_vou_reg_ab_set(struct sh_vou_device *vou_dev, unsigned int reg,
 
 struct sh_vou_fmt {
        u32             pfmt;
-       char            *desc;
        unsigned char   bpp;
        unsigned char   bpl;
        unsigned char   rgb;
@@ -152,7 +151,6 @@ static struct sh_vou_fmt vou_fmt[] = {
                .pfmt   = V4L2_PIX_FMT_NV12,
                .bpp    = 12,
                .bpl    = 1,
-               .desc   = "YVU420 planar",
                .yf     = 0,
                .rgb    = 0,
        },
@@ -160,7 +158,6 @@ static struct sh_vou_fmt vou_fmt[] = {
                .pfmt   = V4L2_PIX_FMT_NV16,
                .bpp    = 16,
                .bpl    = 1,
-               .desc   = "YVYU planar",
                .yf     = 1,
                .rgb    = 0,
        },
@@ -168,7 +165,6 @@ static struct sh_vou_fmt vou_fmt[] = {
                .pfmt   = V4L2_PIX_FMT_RGB24,
                .bpp    = 24,
                .bpl    = 3,
-               .desc   = "RGB24",
                .pkf    = 2,
                .rgb    = 1,
        },
@@ -176,7 +172,6 @@ static struct sh_vou_fmt vou_fmt[] = {
                .pfmt   = V4L2_PIX_FMT_RGB565,
                .bpp    = 16,
                .bpl    = 2,
-               .desc   = "RGB565",
                .pkf    = 3,
                .rgb    = 1,
        },
@@ -184,7 +179,6 @@ static struct sh_vou_fmt vou_fmt[] = {
                .pfmt   = V4L2_PIX_FMT_RGB565X,
                .bpp    = 16,
                .bpl    = 2,
-               .desc   = "RGB565 byteswapped",
                .pkf    = 3,
                .rgb    = 1,
        },
@@ -381,9 +375,6 @@ static int sh_vou_querycap(struct file *file, void  *priv,
        strscpy(cap->card, "SuperH VOU", sizeof(cap->card));
        strscpy(cap->driver, "sh-vou", sizeof(cap->driver));
        strscpy(cap->bus_info, "platform:sh-vou", sizeof(cap->bus_info));
-       cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_READWRITE |
-                          V4L2_CAP_STREAMING;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
        return 0;
 }
 
@@ -398,9 +389,6 @@ static int sh_vou_enum_fmt_vid_out(struct file *file, void  *priv,
 
        dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__);
 
-       fmt->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-       strscpy(fmt->description, vou_fmt[fmt->index].desc,
-               sizeof(fmt->description));
        fmt->pixelformat = vou_fmt[fmt->index].pfmt;
 
        return 0;
@@ -494,7 +482,8 @@ static void sh_vou_configure_geometry(struct sh_vou_device *vou_dev,
        if (h_idx)
                vouvcr |= (1 << 14) | vou_scale_v_fld[h_idx - 1];
 
-       dev_dbg(vou_dev->v4l2_dev.dev, "%s: scaling 0x%x\n", fmt->desc, vouvcr);
+       dev_dbg(vou_dev->v4l2_dev.dev, "0x%08x: scaling 0x%x\n",
+               fmt->pfmt, vouvcr);
 
        /* To produce a colour bar for testing set bit 23 of VOUVCR */
        sh_vou_reg_ab_write(vou_dev, VOUVCR, vouvcr);
@@ -1218,6 +1207,8 @@ static const struct video_device sh_vou_video_template = {
        .ioctl_ops      = &sh_vou_ioctl_ops,
        .tvnorms        = V4L2_STD_525_60, /* PAL only supported in 8-bit non-bt656 mode */
        .vfl_dir        = VFL_DIR_TX,
+       .device_caps    = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_READWRITE |
+                         V4L2_CAP_STREAMING,
 };
 
 static int sh_vou_probe(struct platform_device *pdev)
index 79f7db1a9d1887dbcfa8d59fd30010611334eb5e..e90f1ba30574373a8774d2716a471dc3e70432e4 100644 (file)
@@ -692,11 +692,6 @@ static int bdisp_querycap(struct file *file, void *fh,
        strscpy(cap->card, bdisp->pdev->name, sizeof(cap->card));
        snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s%d",
                 BDISP_NAME, bdisp->id);
-
-       cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M;
-
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
-
        return 0;
 }
 
@@ -1059,6 +1054,7 @@ static int bdisp_register_device(struct bdisp_dev *bdisp)
        bdisp->vdev.lock        = &bdisp->lock;
        bdisp->vdev.vfl_dir     = VFL_DIR_M2M;
        bdisp->vdev.v4l2_dev    = &bdisp->v4l2_dev;
+       bdisp->vdev.device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M;
        snprintf(bdisp->vdev.name, sizeof(bdisp->vdev.name), "%s.%d",
                 BDISP_NAME, bdisp->id);
 
index 3c05b3dc49ec0878912074754d8d772e1a933101..5baada4f65e5d022bab83de5bacaa48be44fbfdb 100644 (file)
@@ -693,16 +693,12 @@ static int c8sectpfe_probe(struct platform_device *pdev)
        fei->sram_size = resource_size(res);
 
        fei->idle_irq = platform_get_irq_byname(pdev, "c8sectpfe-idle-irq");
-       if (fei->idle_irq < 0) {
-               dev_err(dev, "Can't get c8sectpfe-idle-irq\n");
+       if (fei->idle_irq < 0)
                return fei->idle_irq;
-       }
 
        fei->error_irq = platform_get_irq_byname(pdev, "c8sectpfe-error-irq");
-       if (fei->error_irq < 0) {
-               dev_err(dev, "Can't get c8sectpfe-error-irq\n");
+       if (fei->error_irq < 0)
                return fei->error_irq;
-       }
 
        platform_set_drvdata(pdev, fei);
 
index fc37efe1d5542b0c22c4181ebe10056d35f3a546..8118c7365d3f31879e8f9034d54687b1ed361c44 100644 (file)
@@ -313,10 +313,6 @@ static int stih_cec_probe(struct platform_device *pdev)
        if (!cec)
                return -ENOMEM;
 
-       cec->notifier = cec_notifier_get(hdmi_dev);
-       if (!cec->notifier)
-               return -ENOMEM;
-
        cec->dev = dev;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -340,30 +336,42 @@ static int stih_cec_probe(struct platform_device *pdev)
                return PTR_ERR(cec->clk);
        }
 
-       cec->adap = cec_allocate_adapter(&sti_cec_adap_ops, cec,
-                       CEC_NAME, CEC_CAP_DEFAULTS, CEC_MAX_LOG_ADDRS);
+       cec->adap = cec_allocate_adapter(&sti_cec_adap_ops, cec, CEC_NAME,
+                                        CEC_CAP_DEFAULTS |
+                                        CEC_CAP_CONNECTOR_INFO,
+                                        CEC_MAX_LOG_ADDRS);
        ret = PTR_ERR_OR_ZERO(cec->adap);
        if (ret)
                return ret;
 
-       ret = cec_register_adapter(cec->adap, &pdev->dev);
-       if (ret) {
-               cec_delete_adapter(cec->adap);
-               return ret;
+       cec->notifier = cec_notifier_cec_adap_register(hdmi_dev, NULL,
+                                                      cec->adap);
+       if (!cec->notifier) {
+               ret = -ENOMEM;
+               goto err_delete_adapter;
        }
 
-       cec_register_cec_notifier(cec->adap, cec->notifier);
+       ret = cec_register_adapter(cec->adap, &pdev->dev);
+       if (ret)
+               goto err_notifier;
 
        platform_set_drvdata(pdev, cec);
        return 0;
+
+err_notifier:
+       cec_notifier_cec_adap_unregister(cec->notifier);
+
+err_delete_adapter:
+       cec_delete_adapter(cec->adap);
+       return ret;
 }
 
 static int stih_cec_remove(struct platform_device *pdev)
 {
        struct stih_cec *cec = platform_get_drvdata(pdev);
 
+       cec_notifier_cec_adap_unregister(cec->notifier);
        cec_unregister_adapter(cec->adap);
-       cec_notifier_put(cec->notifier);
 
        return 0;
 }
index 7917fd2c4bd4b9bd2f5cb2da3ba0e787148c1521..401aaafa171096436c84e687f28400fc4bfa4619 100644 (file)
@@ -341,10 +341,8 @@ int hva_hw_probe(struct platform_device *pdev, struct hva_dev *hva)
 
        /* get status interruption resource */
        ret  = platform_get_irq(pdev, 0);
-       if (ret < 0) {
-               dev_err(dev, "%s     failed to get status IRQ\n", HVA_PREFIX);
+       if (ret < 0)
                goto err_clk;
-       }
        hva->irq_its = ret;
 
        ret = devm_request_threaded_irq(dev, hva->irq_its, hva_hw_its_interrupt,
@@ -360,10 +358,8 @@ int hva_hw_probe(struct platform_device *pdev, struct hva_dev *hva)
 
        /* get error interruption resource */
        ret = platform_get_irq(pdev, 1);
-       if (ret < 0) {
-               dev_err(dev, "%s     failed to get error IRQ\n", HVA_PREFIX);
+       if (ret < 0)
                goto err_clk;
-       }
        hva->irq_err = ret;
 
        ret = devm_request_threaded_irq(dev, hva->irq_err, hva_hw_err_interrupt,
index d855e9c09c08a600a1fbe0a0cf7cb65918e467f2..672a53195b569ec375c95f9a854bf9c6793cd190 100644 (file)
@@ -1699,11 +1699,8 @@ static int dcmi_probe(struct platform_device *pdev)
        dcmi->bus.data_shift = ep.bus.parallel.data_shift;
 
        irq = platform_get_irq(pdev, 0);
-       if (irq <= 0) {
-               if (irq != -EPROBE_DEFER)
-                       dev_err(&pdev->dev, "Could not get irq\n");
+       if (irq <= 0)
                return irq ? irq : -ENXIO;
-       }
 
        dcmi->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!dcmi->res) {
index 6e0e894154f42c9f56c7c374515aa29b5a788a26..055eb0b8e396924268a43f17f849d3cb8b5e03b6 100644 (file)
@@ -866,11 +866,8 @@ static int sun6i_csi_resource_request(struct sun6i_csi_dev *sdev,
        }
 
        irq = platform_get_irq(pdev, 0);
-       if (irq < 0) {
-               dev_err(&pdev->dev, "No csi IRQ specified\n");
-               ret = -ENXIO;
-               return ret;
-       }
+       if (irq < 0)
+               return -ENXIO;
 
        ret = devm_request_irq(&pdev->dev, irq, sun6i_csi_isr, 0, MODULE_NAME,
                               sdev);
index 6498b2d0492e034c65dccccce68672e2226803cc..a632602131f210f02a81163e66569cf6c559becf 100644 (file)
@@ -380,38 +380,39 @@ static int tegra_cec_probe(struct platform_device *pdev)
        if (ret) {
                dev_err(&pdev->dev,
                        "Unable to request interrupt for device\n");
-               goto clk_error;
-       }
-
-       cec->notifier = cec_notifier_get(hdmi_dev);
-       if (!cec->notifier) {
-               ret = -ENOMEM;
-               goto clk_error;
+               goto err_clk;
        }
 
        cec->adap = cec_allocate_adapter(&tegra_cec_ops, cec, TEGRA_CEC_NAME,
-                       CEC_CAP_DEFAULTS | CEC_CAP_MONITOR_ALL,
+                       CEC_CAP_DEFAULTS | CEC_CAP_MONITOR_ALL |
+                       CEC_CAP_CONNECTOR_INFO,
                        CEC_MAX_LOG_ADDRS);
        if (IS_ERR(cec->adap)) {
                ret = -ENOMEM;
                dev_err(&pdev->dev, "Couldn't create cec adapter\n");
-               goto cec_error;
+               goto err_clk;
+       }
+
+       cec->notifier = cec_notifier_cec_adap_register(hdmi_dev, NULL,
+                                                      cec->adap);
+       if (!cec->notifier) {
+               ret = -ENOMEM;
+               goto err_adapter;
        }
+
        ret = cec_register_adapter(cec->adap, &pdev->dev);
        if (ret) {
                dev_err(&pdev->dev, "Couldn't register device\n");
-               goto cec_error;
+               goto err_notifier;
        }
 
-       cec_register_cec_notifier(cec->adap, cec->notifier);
-
        return 0;
 
-cec_error:
-       if (cec->notifier)
-               cec_notifier_put(cec->notifier);
+err_notifier:
+       cec_notifier_cec_adap_unregister(cec->notifier);
+err_adapter:
        cec_delete_adapter(cec->adap);
-clk_error:
+err_clk:
        clk_disable_unprepare(cec->clk);
        return ret;
 }
@@ -422,8 +423,8 @@ static int tegra_cec_remove(struct platform_device *pdev)
 
        clk_disable_unprepare(cec->clk);
 
+       cec_notifier_cec_adap_unregister(cec->notifier);
        cec_unregister_adapter(cec->adap);
-       cec_notifier_put(cec->notifier);
 
        return 0;
 }
index 9e86d761546b734142fbffc27a91874939cf6ab8..223161f9c4036b2fd7d3dc7df3dd10913f7b83db 100644 (file)
@@ -913,9 +913,6 @@ static int cal_querycap(struct file *file, void *priv,
 
        snprintf(cap->bus_info, sizeof(cap->bus_info),
                 "platform:%s", ctx->v4l2_dev.name);
-       cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
-                           V4L2_CAP_READWRITE;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
        return 0;
 }
 
@@ -1419,6 +1416,8 @@ static const struct video_device cal_videodev = {
        .ioctl_ops      = &cal_ioctl_ops,
        .minor          = -1,
        .release        = video_device_release_empty,
+       .device_caps    = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
+                         V4L2_CAP_READWRITE,
 };
 
 /* -----------------------------------------------------------------
@@ -1613,6 +1612,7 @@ of_get_next_port(const struct device_node *parent,
                        }
                        prev = port;
                } while (!of_node_name_eq(port, "port"));
+               of_node_put(ports);
        }
 
        return port;
index dda04498ac567f2615fc76268a3cf808b8a7ca46..60b575bb44c46964e1908f89fb009fe6ebc5ea5d 100644 (file)
@@ -224,7 +224,6 @@ static const struct vpe_port_data port_data[11] = {
 
 /* driver info for each of the supported video formats */
 struct vpe_fmt {
-       char    *name;                  /* human-readable name */
        u32     fourcc;                 /* standard format identifier */
        u8      types;                  /* CAPTURE and/or OUTPUT */
        u8      coplanar;               /* set for unpacked Luma and Chroma */
@@ -234,7 +233,6 @@ struct vpe_fmt {
 
 static struct vpe_fmt vpe_formats[] = {
        {
-               .name           = "NV16 YUV 422 co-planar",
                .fourcc         = V4L2_PIX_FMT_NV16,
                .types          = VPE_FMT_TYPE_CAPTURE | VPE_FMT_TYPE_OUTPUT,
                .coplanar       = 1,
@@ -243,7 +241,6 @@ static struct vpe_fmt vpe_formats[] = {
                                  },
        },
        {
-               .name           = "NV12 YUV 420 co-planar",
                .fourcc         = V4L2_PIX_FMT_NV12,
                .types          = VPE_FMT_TYPE_CAPTURE | VPE_FMT_TYPE_OUTPUT,
                .coplanar       = 1,
@@ -252,7 +249,6 @@ static struct vpe_fmt vpe_formats[] = {
                                  },
        },
        {
-               .name           = "YUYV 422 packed",
                .fourcc         = V4L2_PIX_FMT_YUYV,
                .types          = VPE_FMT_TYPE_CAPTURE | VPE_FMT_TYPE_OUTPUT,
                .coplanar       = 0,
@@ -260,7 +256,6 @@ static struct vpe_fmt vpe_formats[] = {
                                  },
        },
        {
-               .name           = "UYVY 422 packed",
                .fourcc         = V4L2_PIX_FMT_UYVY,
                .types          = VPE_FMT_TYPE_CAPTURE | VPE_FMT_TYPE_OUTPUT,
                .coplanar       = 0,
@@ -268,7 +263,6 @@ static struct vpe_fmt vpe_formats[] = {
                                  },
        },
        {
-               .name           = "RGB888 packed",
                .fourcc         = V4L2_PIX_FMT_RGB24,
                .types          = VPE_FMT_TYPE_CAPTURE,
                .coplanar       = 0,
@@ -276,7 +270,6 @@ static struct vpe_fmt vpe_formats[] = {
                                  },
        },
        {
-               .name           = "ARGB32",
                .fourcc         = V4L2_PIX_FMT_RGB32,
                .types          = VPE_FMT_TYPE_CAPTURE,
                .coplanar       = 0,
@@ -284,7 +277,6 @@ static struct vpe_fmt vpe_formats[] = {
                                  },
        },
        {
-               .name           = "BGR888 packed",
                .fourcc         = V4L2_PIX_FMT_BGR24,
                .types          = VPE_FMT_TYPE_CAPTURE,
                .coplanar       = 0,
@@ -292,7 +284,6 @@ static struct vpe_fmt vpe_formats[] = {
                                  },
        },
        {
-               .name           = "ABGR32",
                .fourcc         = V4L2_PIX_FMT_BGR32,
                .types          = VPE_FMT_TYPE_CAPTURE,
                .coplanar       = 0,
@@ -300,7 +291,6 @@ static struct vpe_fmt vpe_formats[] = {
                                  },
        },
        {
-               .name           = "RGB565",
                .fourcc         = V4L2_PIX_FMT_RGB565,
                .types          = VPE_FMT_TYPE_CAPTURE,
                .coplanar       = 0,
@@ -308,7 +298,6 @@ static struct vpe_fmt vpe_formats[] = {
                                  },
        },
        {
-               .name           = "RGB5551",
                .fourcc         = V4L2_PIX_FMT_RGB555,
                .types          = VPE_FMT_TYPE_CAPTURE,
                .coplanar       = 0,
@@ -1514,7 +1503,6 @@ static int __enum_fmt(struct v4l2_fmtdesc *f, u32 type)
        if (!fmt)
                return -EINVAL;
 
-       strscpy(f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->fourcc;
        return 0;
 }
index 038de7a2027ab1c92ba2181e9bacc5bef0cdd0fe..78841b9015ce5ed1c9021ce24930b0559fdb5b55 100644 (file)
 #include <media/v4l2-device.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-ctrls.h>
+#include <media/v4l2-event.h>
 #include <media/v4l2-image-sizes.h>
 #include <media/i2c/ov7670.h>
-#include <media/videobuf-dma-sg.h>
+#include <media/videobuf2-dma-sg.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/pm_qos.h>
@@ -84,16 +85,11 @@ struct via_camera {
         * live in frame buffer memory, so we don't call them "DMA".
         */
        unsigned int cb_offsets[3];     /* offsets into fb mem */
-       u8 __iomem *cb_addrs[3];                /* Kernel-space addresses */
+       u8 __iomem *cb_addrs[3];        /* Kernel-space addresses */
        int n_cap_bufs;                 /* How many are we using? */
-       int next_buf;
-       struct videobuf_queue vb_queue;
-       struct list_head buffer_queue;  /* prot. by reg_lock */
-       /*
-        * User tracking.
-        */
-       int users;
-       struct file *owner;
+       struct vb2_queue vq;
+       struct list_head buffer_queue;
+       u32 sequence;
        /*
         * Video format information.  sensor_format is kept in a form
         * that we can use to pass to the sensor.  We always run the
@@ -106,6 +102,13 @@ struct via_camera {
        u32 mbus_code;
 };
 
+/* buffer for one video frame */
+struct via_buffer {
+       /* common v4l buffer stuff -- must be first */
+       struct vb2_v4l2_buffer          vbuf;
+       struct list_head                queue;
+};
+
 /*
  * Yes, this is a hack, but there's only going to be one of these
  * on any system we know of.
@@ -142,13 +145,11 @@ static struct via_camera *via_cam_info;
  * now this information must be managed at this level too.
  */
 static struct via_format {
-       __u8 *desc;
        __u32 pixelformat;
        int bpp;   /* Bytes per pixel */
        u32 mbus_code;
 } via_formats[] = {
        {
-               .desc           = "YUYV 4:2:2",
                .pixelformat    = V4L2_PIX_FMT_YUYV,
                .mbus_code      = MEDIA_BUS_FMT_YUYV8_2X8,
                .bpp            = 2,
@@ -324,28 +325,15 @@ static irqreturn_t viacam_quick_irq(int irq, void *data)
 }
 
 /*
- * Find the next videobuf buffer which has somebody waiting on it.
+ * Find the next buffer which has somebody waiting on it.
  */
-static struct videobuf_buffer *viacam_next_buffer(struct via_camera *cam)
+static struct via_buffer *viacam_next_buffer(struct via_camera *cam)
 {
-       unsigned long flags;
-       struct videobuf_buffer *buf = NULL;
-
-       spin_lock_irqsave(&cam->viadev->reg_lock, flags);
        if (cam->opstate != S_RUNNING)
-               goto out;
+               return NULL;
        if (list_empty(&cam->buffer_queue))
-               goto out;
-       buf = list_entry(cam->buffer_queue.next, struct videobuf_buffer, queue);
-       if (!waitqueue_active(&buf->done)) {/* Nobody waiting */
-               buf = NULL;
-               goto out;
-       }
-       list_del(&buf->queue);
-       buf->state = VIDEOBUF_ACTIVE;
-out:
-       spin_unlock_irqrestore(&cam->viadev->reg_lock, flags);
-       return buf;
+               return NULL;
+       return list_entry(cam->buffer_queue.next, struct via_buffer, queue);
 }
 
 /*
@@ -353,11 +341,12 @@ static struct videobuf_buffer *viacam_next_buffer(struct via_camera *cam)
  */
 static irqreturn_t viacam_irq(int irq, void *data)
 {
-       int bufn;
-       struct videobuf_buffer *vb;
        struct via_camera *cam = data;
-       struct videobuf_dmabuf *vdma;
+       struct via_buffer *vb;
+       int bufn;
+       struct sg_table *sgt;
 
+       mutex_lock(&cam->lock);
        /*
         * If there is no place to put the data frame, don't bother
         * with anything else.
@@ -375,12 +364,15 @@ static irqreturn_t viacam_irq(int irq, void *data)
        /*
         * Copy over the data and let any waiters know.
         */
-       vdma = videobuf_to_dma(vb);
-       viafb_dma_copy_out_sg(cam->cb_offsets[bufn], vdma->sglist, vdma->sglen);
-       vb->state = VIDEOBUF_DONE;
-       vb->size = cam->user_format.sizeimage;
-       wake_up(&vb->done);
+       sgt = vb2_dma_sg_plane_desc(&vb->vbuf.vb2_buf, 0);
+       vb->vbuf.vb2_buf.timestamp = ktime_get_ns();
+       viafb_dma_copy_out_sg(cam->cb_offsets[bufn], sgt->sgl, sgt->nents);
+       vb->vbuf.sequence = cam->sequence++;
+       vb->vbuf.field = V4L2_FIELD_NONE;
+       list_del(&vb->queue);
+       vb2_buffer_done(&vb->vbuf.vb2_buf, VB2_BUF_STATE_DONE);
 done:
+       mutex_unlock(&cam->lock);
        return IRQ_HANDLED;
 }
 
@@ -556,7 +548,6 @@ static int viacam_config_controller(struct via_camera *cam)
 static void viacam_start_engine(struct via_camera *cam)
 {
        spin_lock_irq(&cam->viadev->reg_lock);
-       cam->next_buf = 0;
        viacam_write_reg_mask(cam, VCR_CAPINTC, VCR_CI_ENABLE, VCR_CI_ENABLE);
        viacam_int_enable(cam);
        (void) viacam_read_reg(cam, VCR_CAPINTC); /* Force post */
@@ -577,81 +568,117 @@ static void viacam_stop_engine(struct via_camera *cam)
 
 
 /* --------------------------------------------------------------------------*/
-/* Videobuf callback ops */
+/* vb2 callback ops */
 
-/*
- * buffer_setup.  The purpose of this one would appear to be to tell
- * videobuf how big a single image is. It's also evidently up to us
- * to put some sort of limit on the maximum number of buffers allowed.
- */
-static int viacam_vb_buf_setup(struct videobuf_queue *q,
-               unsigned int *count, unsigned int *size)
+static struct via_buffer *vb2_to_via_buffer(struct vb2_buffer *vb)
 {
-       struct via_camera *cam = q->priv_data;
+       struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
 
-       *size = cam->user_format.sizeimage;
-       if (*count == 0 || *count > 6)  /* Arbitrary number */
-               *count = 6;
-       return 0;
+       return container_of(vbuf, struct via_buffer, vbuf);
 }
 
-/*
- * Prepare a buffer.
- */
-static int viacam_vb_buf_prepare(struct videobuf_queue *q,
-               struct videobuf_buffer *vb, enum v4l2_field field)
+static void viacam_vb2_queue(struct vb2_buffer *vb)
 {
-       struct via_camera *cam = q->priv_data;
-
-       vb->size = cam->user_format.sizeimage;
-       vb->width = cam->user_format.width; /* bytesperline???? */
-       vb->height = cam->user_format.height;
-       vb->field = field;
-       if (vb->state == VIDEOBUF_NEEDS_INIT) {
-               int ret = videobuf_iolock(q, vb, NULL);
-               if (ret)
-                       return ret;
+       struct via_camera *cam = vb2_get_drv_priv(vb->vb2_queue);
+       struct via_buffer *via = vb2_to_via_buffer(vb);
+
+       list_add_tail(&via->queue, &cam->buffer_queue);
+}
+
+static int viacam_vb2_prepare(struct vb2_buffer *vb)
+{
+       struct via_camera *cam = vb2_get_drv_priv(vb->vb2_queue);
+
+       if (vb2_plane_size(vb, 0) < cam->user_format.sizeimage) {
+               cam_dbg(cam,
+                       "Plane size too small (%lu < %u)\n",
+                       vb2_plane_size(vb, 0),
+                       cam->user_format.sizeimage);
+               return -EINVAL;
        }
-       vb->state = VIDEOBUF_PREPARED;
+
+       vb2_set_plane_payload(vb, 0, cam->user_format.sizeimage);
+
        return 0;
 }
 
-/*
- * We've got a buffer to put data into.
- *
- * FIXME: check for a running engine and valid buffers?
- */
-static void viacam_vb_buf_queue(struct videobuf_queue *q,
-               struct videobuf_buffer *vb)
+static int viacam_vb2_queue_setup(struct vb2_queue *vq,
+                                 unsigned int *nbufs,
+                                 unsigned int *num_planes, unsigned int sizes[],
+                                 struct device *alloc_devs[])
 {
-       struct via_camera *cam = q->priv_data;
+       struct via_camera *cam = vb2_get_drv_priv(vq);
+       int size = cam->user_format.sizeimage;
 
+       if (*num_planes)
+               return sizes[0] < size ? -EINVAL : 0;
+
+       *num_planes = 1;
+       sizes[0] = size;
+       return 0;
+}
+
+static int viacam_vb2_start_streaming(struct vb2_queue *vq, unsigned int count)
+{
+       struct via_camera *cam = vb2_get_drv_priv(vq);
+       struct via_buffer *buf, *tmp;
+       int ret = 0;
+
+       if (cam->opstate != S_IDLE) {
+               ret = -EBUSY;
+               goto out;
+       }
+       /*
+        * Configure things if need be.
+        */
+       if (test_bit(CF_CONFIG_NEEDED, &cam->flags)) {
+               ret = viacam_configure_sensor(cam);
+               if (ret)
+                       goto out;
+               ret = viacam_config_controller(cam);
+               if (ret)
+                       goto out;
+       }
+       cam->sequence = 0;
        /*
-        * Note that videobuf holds the lock when it calls
-        * us, so we need not (indeed, cannot) take it here.
+        * If the CPU goes into C3, the DMA transfer gets corrupted and
+        * users start filing unsightly bug reports.  Put in a "latency"
+        * requirement which will keep the CPU out of the deeper sleep
+        * states.
         */
-       vb->state = VIDEOBUF_QUEUED;
-       list_add_tail(&vb->queue, &cam->buffer_queue);
+       pm_qos_add_request(&cam->qos_request, PM_QOS_CPU_DMA_LATENCY, 50);
+       viacam_start_engine(cam);
+       return 0;
+out:
+       list_for_each_entry_safe(buf, tmp, &cam->buffer_queue, queue) {
+               list_del(&buf->queue);
+               vb2_buffer_done(&buf->vbuf.vb2_buf, VB2_BUF_STATE_QUEUED);
+       }
+       return ret;
 }
 
-/*
- * Free a buffer.
- */
-static void viacam_vb_buf_release(struct videobuf_queue *q,
-               struct videobuf_buffer *vb)
+static void viacam_vb2_stop_streaming(struct vb2_queue *vq)
 {
-       struct via_camera *cam = q->priv_data;
+       struct via_camera *cam = vb2_get_drv_priv(vq);
+       struct via_buffer *buf, *tmp;
 
-       videobuf_dma_unmap(&cam->platdev->dev, videobuf_to_dma(vb));
-       videobuf_dma_free(videobuf_to_dma(vb));
-       vb->state = VIDEOBUF_NEEDS_INIT;
+       pm_qos_remove_request(&cam->qos_request);
+       viacam_stop_engine(cam);
+
+       list_for_each_entry_safe(buf, tmp, &cam->buffer_queue, queue) {
+               list_del(&buf->queue);
+               vb2_buffer_done(&buf->vbuf.vb2_buf, VB2_BUF_STATE_ERROR);
+       }
 }
 
-static const struct videobuf_queue_ops viacam_vb_ops = {
-       .buf_setup      = viacam_vb_buf_setup,
-       .buf_prepare    = viacam_vb_buf_prepare,
-       .buf_queue      = viacam_vb_buf_queue,
-       .buf_release    = viacam_vb_buf_release,
+static const struct vb2_ops viacam_vb2_ops = {
+       .queue_setup            = viacam_vb2_queue_setup,
+       .buf_queue              = viacam_vb2_queue,
+       .buf_prepare            = viacam_vb2_prepare,
+       .start_streaming        = viacam_vb2_start_streaming,
+       .stop_streaming         = viacam_vb2_stop_streaming,
+       .wait_prepare           = vb2_ops_wait_prepare,
+       .wait_finish            = vb2_ops_wait_finish,
 };
 
 /* --------------------------------------------------------------------------*/
@@ -660,62 +687,43 @@ static const struct videobuf_queue_ops viacam_vb_ops = {
 static int viacam_open(struct file *filp)
 {
        struct via_camera *cam = video_drvdata(filp);
+       int ret;
 
-       filp->private_data = cam;
        /*
         * Note the new user.  If this is the first one, we'll also
         * need to power up the sensor.
         */
        mutex_lock(&cam->lock);
-       if (cam->users == 0) {
-               int ret = viafb_request_dma();
+       ret = v4l2_fh_open(filp);
+       if (ret)
+               goto out;
+       if (v4l2_fh_is_singular_file(filp)) {
+               ret = viafb_request_dma();
 
                if (ret) {
-                       mutex_unlock(&cam->lock);
-                       return ret;
+                       v4l2_fh_release(filp);
+                       goto out;
                }
                via_sensor_power_up(cam);
                set_bit(CF_CONFIG_NEEDED, &cam->flags);
-               /*
-                * Hook into videobuf.  Evidently this cannot fail.
-                */
-               videobuf_queue_sg_init(&cam->vb_queue, &viacam_vb_ops,
-                               &cam->platdev->dev, &cam->viadev->reg_lock,
-                               V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE,
-                               sizeof(struct videobuf_buffer), cam, NULL);
        }
-       (cam->users)++;
+out:
        mutex_unlock(&cam->lock);
-       return 0;
+       return ret;
 }
 
 static int viacam_release(struct file *filp)
 {
        struct via_camera *cam = video_drvdata(filp);
+       bool last_open;
 
        mutex_lock(&cam->lock);
-       (cam->users)--;
-       /*
-        * If the "owner" is closing, shut down any ongoing
-        * operations.
-        */
-       if (filp == cam->owner) {
-               videobuf_stop(&cam->vb_queue);
-               /*
-                * We don't hold the spinlock here, but, if release()
-                * is being called by the owner, nobody else will
-                * be changing the state.  And an extra stop would
-                * not hurt anyway.
-                */
-               if (cam->opstate != S_IDLE)
-                       viacam_stop_engine(cam);
-               cam->owner = NULL;
-       }
+       last_open = v4l2_fh_is_singular_file(filp);
+       _vb2_fop_release(filp, NULL);
        /*
         * Last one out needs to turn out the lights.
         */
-       if (cam->users == 0) {
-               videobuf_mmap_free(&cam->vb_queue);
+       if (last_open) {
                via_sensor_power_down(cam);
                viafb_release_dma();
        }
@@ -723,77 +731,14 @@ static int viacam_release(struct file *filp)
        return 0;
 }
 
-/*
- * Read a frame from the device.
- */
-static ssize_t viacam_read(struct file *filp, char __user *buffer,
-               size_t len, loff_t *pos)
-{
-       struct via_camera *cam = video_drvdata(filp);
-       int ret;
-
-       mutex_lock(&cam->lock);
-       /*
-        * Enforce the V4l2 "only one owner gets to read data" rule.
-        */
-       if (cam->owner && cam->owner != filp) {
-               ret = -EBUSY;
-               goto out_unlock;
-       }
-       cam->owner = filp;
-       /*
-        * Do we need to configure the hardware?
-        */
-       if (test_bit(CF_CONFIG_NEEDED, &cam->flags)) {
-               ret = viacam_configure_sensor(cam);
-               if (!ret)
-                       ret = viacam_config_controller(cam);
-               if (ret)
-                       goto out_unlock;
-       }
-       /*
-        * Fire up the capture engine, then have videobuf do
-        * the heavy lifting.  Someday it would be good to avoid
-        * stopping and restarting the engine each time.
-        */
-       INIT_LIST_HEAD(&cam->buffer_queue);
-       viacam_start_engine(cam);
-       ret = videobuf_read_stream(&cam->vb_queue, buffer, len, pos, 0,
-                       filp->f_flags & O_NONBLOCK);
-       viacam_stop_engine(cam);
-       /* videobuf_stop() ?? */
-
-out_unlock:
-       mutex_unlock(&cam->lock);
-       return ret;
-}
-
-
-static __poll_t viacam_poll(struct file *filp, struct poll_table_struct *pt)
-{
-       struct via_camera *cam = video_drvdata(filp);
-
-       return videobuf_poll_stream(filp, &cam->vb_queue, pt);
-}
-
-
-static int viacam_mmap(struct file *filp, struct vm_area_struct *vma)
-{
-       struct via_camera *cam = video_drvdata(filp);
-
-       return videobuf_mmap_mapper(&cam->vb_queue, vma);
-}
-
-
-
 static const struct v4l2_file_operations viacam_fops = {
        .owner          = THIS_MODULE,
        .open           = viacam_open,
        .release        = viacam_release,
-       .read           = viacam_read,
-       .poll           = viacam_poll,
-       .mmap           = viacam_mmap,
-       .unlocked_ioctl = video_ioctl2,
+       .read           = vb2_fop_read,
+       .poll           = vb2_fop_poll,
+       .mmap           = vb2_fop_mmap,
+       .unlocked_ioctl = video_ioctl2,
 };
 
 /*----------------------------------------------------------------------------*/
@@ -811,7 +756,6 @@ static int viacam_enum_input(struct file *filp, void *priv,
                return -EINVAL;
 
        input->type = V4L2_INPUT_TYPE_CAMERA;
-       input->std = V4L2_STD_ALL; /* Not sure what should go here */
        strscpy(input->name, "Camera", sizeof(input->name));
        return 0;
 }
@@ -829,17 +773,6 @@ static int viacam_s_input(struct file *filp, void *priv, unsigned int i)
        return 0;
 }
 
-static int viacam_s_std(struct file *filp, void *priv, v4l2_std_id std)
-{
-       return 0;
-}
-
-static int viacam_g_std(struct file *filp, void *priv, v4l2_std_id *std)
-{
-       *std = V4L2_STD_NTSC_M;
-       return 0;
-}
-
 /*
  * Video format stuff. Here is our default format until
  * user space messes with things.
@@ -851,6 +784,7 @@ static const struct v4l2_pix_format viacam_def_pix_format = {
        .field          = V4L2_FIELD_NONE,
        .bytesperline   = VGA_WIDTH * 2,
        .sizeimage      = VGA_WIDTH * VGA_HEIGHT * 2,
+       .colorspace     = V4L2_COLORSPACE_SRGB,
 };
 
 static const u32 via_def_mbus_code = MEDIA_BUS_FMT_YUYV8_2X8;
@@ -860,8 +794,6 @@ static int viacam_enum_fmt_vid_cap(struct file *filp, void *priv,
 {
        if (fmt->index >= N_VIA_FMTS)
                return -EINVAL;
-       strscpy(fmt->description, via_formats[fmt->index].desc,
-               sizeof(fmt->description));
        fmt->pixelformat = via_formats[fmt->index].pixelformat;
        return 0;
 }
@@ -897,6 +829,10 @@ static void viacam_fmt_post(struct v4l2_pix_format *userfmt,
        userfmt->field = sensorfmt->field;
        userfmt->bytesperline = 2 * userfmt->width;
        userfmt->sizeimage = userfmt->bytesperline * userfmt->height;
+       userfmt->colorspace = sensorfmt->colorspace;
+       userfmt->ycbcr_enc = sensorfmt->ycbcr_enc;
+       userfmt->quantization = sensorfmt->quantization;
+       userfmt->xfer_func = sensorfmt->xfer_func;
 }
 
 
@@ -927,32 +863,26 @@ static int viacam_do_try_fmt(struct via_camera *cam,
 static int viacam_try_fmt_vid_cap(struct file *filp, void *priv,
                struct v4l2_format *fmt)
 {
-       struct via_camera *cam = priv;
+       struct via_camera *cam = video_drvdata(filp);
        struct v4l2_format sfmt;
-       int ret;
 
-       mutex_lock(&cam->lock);
-       ret = viacam_do_try_fmt(cam, &fmt->fmt.pix, &sfmt.fmt.pix);
-       mutex_unlock(&cam->lock);
-       return ret;
+       return viacam_do_try_fmt(cam, &fmt->fmt.pix, &sfmt.fmt.pix);
 }
 
 
 static int viacam_g_fmt_vid_cap(struct file *filp, void *priv,
                struct v4l2_format *fmt)
 {
-       struct via_camera *cam = priv;
+       struct via_camera *cam = video_drvdata(filp);
 
-       mutex_lock(&cam->lock);
        fmt->fmt.pix = cam->user_format;
-       mutex_unlock(&cam->lock);
        return 0;
 }
 
 static int viacam_s_fmt_vid_cap(struct file *filp, void *priv,
                struct v4l2_format *fmt)
 {
-       struct via_camera *cam = priv;
+       struct via_camera *cam = video_drvdata(filp);
        int ret;
        struct v4l2_format sfmt;
        struct via_format *f = via_find_format(fmt->fmt.pix.pixelformat);
@@ -961,18 +891,15 @@ static int viacam_s_fmt_vid_cap(struct file *filp, void *priv,
         * Camera must be idle or we can't mess with the
         * video setup.
         */
-       mutex_lock(&cam->lock);
-       if (cam->opstate != S_IDLE) {
-               ret = -EBUSY;
-               goto out;
-       }
+       if (cam->opstate != S_IDLE)
+               return -EBUSY;
        /*
         * Let the sensor code look over and tweak the
         * requested formatting.
         */
        ret = viacam_do_try_fmt(cam, &fmt->fmt.pix, &sfmt.fmt.pix);
        if (ret)
-               goto out;
+               return ret;
        /*
         * OK, let's commit to the new format.
         */
@@ -982,8 +909,6 @@ static int viacam_s_fmt_vid_cap(struct file *filp, void *priv,
        ret = viacam_configure_sensor(cam);
        if (!ret)
                ret = viacam_config_controller(cam);
-out:
-       mutex_unlock(&cam->lock);
        return ret;
 }
 
@@ -992,155 +917,40 @@ static int viacam_querycap(struct file *filp, void *priv,
 {
        strscpy(cap->driver, "via-camera", sizeof(cap->driver));
        strscpy(cap->card, "via-camera", sizeof(cap->card));
-       cap->device_caps = V4L2_CAP_VIDEO_CAPTURE |
-               V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
+       strscpy(cap->bus_info, "platform:via-camera", sizeof(cap->bus_info));
        return 0;
 }
 
-/*
- * Streaming operations - pure videobuf stuff.
- */
-static int viacam_reqbufs(struct file *filp, void *priv,
-               struct v4l2_requestbuffers *rb)
-{
-       struct via_camera *cam = priv;
-
-       return videobuf_reqbufs(&cam->vb_queue, rb);
-}
-
-static int viacam_querybuf(struct file *filp, void *priv,
-               struct v4l2_buffer *buf)
-{
-       struct via_camera *cam = priv;
-
-       return videobuf_querybuf(&cam->vb_queue, buf);
-}
-
-static int viacam_qbuf(struct file *filp, void *priv, struct v4l2_buffer *buf)
-{
-       struct via_camera *cam = priv;
-
-       return videobuf_qbuf(&cam->vb_queue, buf);
-}
-
-static int viacam_dqbuf(struct file *filp, void *priv, struct v4l2_buffer *buf)
-{
-       struct via_camera *cam = priv;
-
-       return videobuf_dqbuf(&cam->vb_queue, buf, filp->f_flags & O_NONBLOCK);
-}
-
-static int viacam_streamon(struct file *filp, void *priv, enum v4l2_buf_type t)
-{
-       struct via_camera *cam = priv;
-       int ret = 0;
-
-       if (t != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
-       mutex_lock(&cam->lock);
-       if (cam->opstate != S_IDLE) {
-               ret = -EBUSY;
-               goto out;
-       }
-       /*
-        * Enforce the V4l2 "only one owner gets to read data" rule.
-        */
-       if (cam->owner && cam->owner != filp) {
-               ret = -EBUSY;
-               goto out;
-       }
-       cam->owner = filp;
-       /*
-        * Configure things if need be.
-        */
-       if (test_bit(CF_CONFIG_NEEDED, &cam->flags)) {
-               ret = viacam_configure_sensor(cam);
-               if (ret)
-                       goto out;
-               ret = viacam_config_controller(cam);
-               if (ret)
-                       goto out;
-       }
-       /*
-        * If the CPU goes into C3, the DMA transfer gets corrupted and
-        * users start filing unsightly bug reports.  Put in a "latency"
-        * requirement which will keep the CPU out of the deeper sleep
-        * states.
-        */
-       pm_qos_add_request(&cam->qos_request, PM_QOS_CPU_DMA_LATENCY, 50);
-       /*
-        * Fire things up.
-        */
-       INIT_LIST_HEAD(&cam->buffer_queue);
-       ret = videobuf_streamon(&cam->vb_queue);
-       if (!ret)
-               viacam_start_engine(cam);
-out:
-       mutex_unlock(&cam->lock);
-       return ret;
-}
-
-static int viacam_streamoff(struct file *filp, void *priv, enum v4l2_buf_type t)
-{
-       struct via_camera *cam = priv;
-       int ret;
-
-       if (t != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-       mutex_lock(&cam->lock);
-       if (cam->opstate != S_RUNNING) {
-               ret = -EINVAL;
-               goto out;
-       }
-       pm_qos_remove_request(&cam->qos_request);
-       viacam_stop_engine(cam);
-       /*
-        * Videobuf will recycle all of the outstanding buffers, but
-        * we should be sure we don't retain any references to
-        * any of them.
-        */
-       ret = videobuf_streamoff(&cam->vb_queue);
-       INIT_LIST_HEAD(&cam->buffer_queue);
-out:
-       mutex_unlock(&cam->lock);
-       return ret;
-}
-
 /* G/S_PARM */
 
 static int viacam_g_parm(struct file *filp, void *priv,
                struct v4l2_streamparm *parm)
 {
-       struct via_camera *cam = priv;
-       int ret;
+       struct via_camera *cam = video_drvdata(filp);
 
-       mutex_lock(&cam->lock);
-       ret = v4l2_g_parm_cap(video_devdata(filp), cam->sensor, parm);
-       mutex_unlock(&cam->lock);
-       parm->parm.capture.readbuffers = cam->n_cap_bufs;
-       return ret;
+       return v4l2_g_parm_cap(video_devdata(filp), cam->sensor, parm);
 }
 
 static int viacam_s_parm(struct file *filp, void *priv,
                struct v4l2_streamparm *parm)
 {
-       struct via_camera *cam = priv;
-       int ret;
+       struct via_camera *cam = video_drvdata(filp);
 
-       mutex_lock(&cam->lock);
-       ret = v4l2_s_parm_cap(video_devdata(filp), cam->sensor, parm);
-       mutex_unlock(&cam->lock);
-       parm->parm.capture.readbuffers = cam->n_cap_bufs;
-       return ret;
+       return v4l2_s_parm_cap(video_devdata(filp), cam->sensor, parm);
 }
 
 static int viacam_enum_framesizes(struct file *filp, void *priv,
                struct v4l2_frmsizeenum *sizes)
 {
+       unsigned int i;
+
        if (sizes->index != 0)
                return -EINVAL;
+       for (i = 0; i < N_VIA_FMTS; i++)
+               if (sizes->pixel_format == via_formats[i].pixelformat)
+                       break;
+       if (i >= N_VIA_FMTS)
+               return -EINVAL;
        sizes->type = V4L2_FRMSIZE_TYPE_CONTINUOUS;
        sizes->stepwise.min_width = QCIF_WIDTH;
        sizes->stepwise.min_height = QCIF_HEIGHT;
@@ -1153,7 +963,7 @@ static int viacam_enum_framesizes(struct file *filp, void *priv,
 static int viacam_enum_frameintervals(struct file *filp, void *priv,
                struct v4l2_frmivalenum *interval)
 {
-       struct via_camera *cam = priv;
+       struct via_camera *cam = video_drvdata(filp);
        struct v4l2_subdev_frame_interval_enum fie = {
                .index = interval->index,
                .code = cam->mbus_code,
@@ -1161,11 +971,18 @@ static int viacam_enum_frameintervals(struct file *filp, void *priv,
                .height = cam->sensor_format.height,
                .which = V4L2_SUBDEV_FORMAT_ACTIVE,
        };
+       unsigned int i;
        int ret;
 
-       mutex_lock(&cam->lock);
+       for (i = 0; i < N_VIA_FMTS; i++)
+               if (interval->pixel_format == via_formats[i].pixelformat)
+                       break;
+       if (i >= N_VIA_FMTS)
+               return -EINVAL;
+       if (interval->width < QCIF_WIDTH || interval->width > VGA_WIDTH ||
+           interval->height < QCIF_HEIGHT || interval->height > VGA_HEIGHT)
+               return -EINVAL;
        ret = sensor_call(cam, pad, enum_frame_interval, NULL, &fie);
-       mutex_unlock(&cam->lock);
        if (ret)
                return ret;
        interval->type = V4L2_FRMIVAL_TYPE_DISCRETE;
@@ -1173,29 +990,30 @@ static int viacam_enum_frameintervals(struct file *filp, void *priv,
        return 0;
 }
 
-
-
 static const struct v4l2_ioctl_ops viacam_ioctl_ops = {
        .vidioc_enum_input      = viacam_enum_input,
        .vidioc_g_input         = viacam_g_input,
        .vidioc_s_input         = viacam_s_input,
-       .vidioc_s_std           = viacam_s_std,
-       .vidioc_g_std           = viacam_g_std,
        .vidioc_enum_fmt_vid_cap = viacam_enum_fmt_vid_cap,
        .vidioc_try_fmt_vid_cap = viacam_try_fmt_vid_cap,
        .vidioc_g_fmt_vid_cap   = viacam_g_fmt_vid_cap,
        .vidioc_s_fmt_vid_cap   = viacam_s_fmt_vid_cap,
        .vidioc_querycap        = viacam_querycap,
-       .vidioc_reqbufs         = viacam_reqbufs,
-       .vidioc_querybuf        = viacam_querybuf,
-       .vidioc_qbuf            = viacam_qbuf,
-       .vidioc_dqbuf           = viacam_dqbuf,
-       .vidioc_streamon        = viacam_streamon,
-       .vidioc_streamoff       = viacam_streamoff,
+       .vidioc_reqbufs         = vb2_ioctl_reqbufs,
+       .vidioc_create_bufs     = vb2_ioctl_create_bufs,
+       .vidioc_querybuf        = vb2_ioctl_querybuf,
+       .vidioc_prepare_buf     = vb2_ioctl_prepare_buf,
+       .vidioc_qbuf            = vb2_ioctl_qbuf,
+       .vidioc_dqbuf           = vb2_ioctl_dqbuf,
+       .vidioc_expbuf          = vb2_ioctl_expbuf,
+       .vidioc_streamon        = vb2_ioctl_streamon,
+       .vidioc_streamoff       = vb2_ioctl_streamoff,
        .vidioc_g_parm          = viacam_g_parm,
        .vidioc_s_parm          = viacam_s_parm,
        .vidioc_enum_framesizes = viacam_enum_framesizes,
        .vidioc_enum_frameintervals = viacam_enum_frameintervals,
+       .vidioc_subscribe_event         = v4l2_ctrl_subscribe_event,
+       .vidioc_unsubscribe_event       = v4l2_event_unsubscribe,
 };
 
 /*----------------------------------------------------------------------------*/
@@ -1233,7 +1051,7 @@ static int viacam_resume(void *priv)
        /*
         * Make sure the sensor's power state is correct
         */
-       if (cam->users > 0)
+       if (!list_empty(&cam->vdev.fh_list))
                via_sensor_power_up(cam);
        else
                via_sensor_power_down(cam);
@@ -1267,10 +1085,11 @@ static struct viafb_pm_hooks viacam_pm_hooks = {
 static const struct video_device viacam_v4l_template = {
        .name           = "via-camera",
        .minor          = -1,
-       .tvnorms        = V4L2_STD_NTSC_M,
        .fops           = &viacam_fops,
        .ioctl_ops      = &viacam_ioctl_ops,
        .release        = video_device_release_empty, /* Check this */
+       .device_caps    = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
+                         V4L2_CAP_STREAMING,
 };
 
 /*
@@ -1317,6 +1136,7 @@ static int viacam_probe(struct platform_device *pdev)
        int ret;
        struct i2c_adapter *sensor_adapter;
        struct viafb_dev *viadev = pdev->dev.platform_data;
+       struct vb2_queue *vq;
        struct i2c_board_info ov7670_info = {
                .type = "ov7670",
                .addr = 0x42 >> 1,
@@ -1360,8 +1180,6 @@ static int viacam_probe(struct platform_device *pdev)
        via_cam_info = cam;
        cam->platdev = pdev;
        cam->viadev = viadev;
-       cam->users = 0;
-       cam->owner = NULL;
        cam->opstate = S_IDLE;
        cam->user_format = cam->sensor_format = viacam_def_pix_format;
        mutex_init(&cam->lock);
@@ -1422,15 +1240,31 @@ static int viacam_probe(struct platform_device *pdev)
                        viacam_irq, IRQF_SHARED, "via-camera", cam);
        if (ret)
                goto out_power_down;
+
+       vq = &cam->vq;
+       vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+       vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
+       vq->drv_priv = cam;
+       vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+       vq->buf_struct_size = sizeof(struct via_buffer);
+       vq->dev = cam->v4l2_dev.dev;
+
+       vq->ops = &viacam_vb2_ops;
+       vq->mem_ops = &vb2_dma_sg_memops;
+       vq->lock = &cam->lock;
+
+       ret = vb2_queue_init(vq);
        /*
         * Tell V4l2 that we exist.
         */
        cam->vdev = viacam_v4l_template;
        cam->vdev.v4l2_dev = &cam->v4l2_dev;
+       cam->vdev.lock = &cam->lock;
+       cam->vdev.queue = vq;
+       video_set_drvdata(&cam->vdev, cam);
        ret = video_register_device(&cam->vdev, VFL_TYPE_GRABBER, -1);
        if (ret)
                goto out_irq;
-       video_set_drvdata(&cam->vdev, cam);
 
 #ifdef CONFIG_PM
        /*
@@ -1464,6 +1298,9 @@ static int viacam_remove(struct platform_device *pdev)
 
        video_unregister_device(&cam->vdev);
        v4l2_device_unregister(&cam->v4l2_dev);
+#ifdef CONFIG_PM
+       viafb_pm_unregister(&viacam_pm_hooks);
+#endif
        free_irq(viadev->pdev->irq, cam);
        via_sensor_power_release(cam);
        v4l2_ctrl_handler_free(&cam->ctrl_handler);
index 01e7f09efc4e2ebc4d16dadf74c7c6170ef4824c..3c93d9232c3cf55e3bc52ae5284b8abd79fd4baa 100644 (file)
@@ -29,11 +29,15 @@ static const struct v4l2_fwht_pixfmt_info v4l2_fwht_pixfmts[] = {
        { V4L2_PIX_FMT_HSV24,   3, 3, 1, 3, 3, 1, 1, 3, 1, FWHT_FL_PIXENC_HSV},
        { V4L2_PIX_FMT_BGR32,   4, 4, 1, 4, 4, 1, 1, 3, 1, FWHT_FL_PIXENC_RGB},
        { V4L2_PIX_FMT_XBGR32,  4, 4, 1, 4, 4, 1, 1, 3, 1, FWHT_FL_PIXENC_RGB},
+       { V4L2_PIX_FMT_ABGR32,  4, 4, 1, 4, 4, 1, 1, 4, 1, FWHT_FL_PIXENC_RGB},
        { V4L2_PIX_FMT_RGB32,   4, 4, 1, 4, 4, 1, 1, 3, 1, FWHT_FL_PIXENC_RGB},
        { V4L2_PIX_FMT_XRGB32,  4, 4, 1, 4, 4, 1, 1, 3, 1, FWHT_FL_PIXENC_RGB},
-       { V4L2_PIX_FMT_HSV32,   4, 4, 1, 4, 4, 1, 1, 3, 1, FWHT_FL_PIXENC_HSV},
        { V4L2_PIX_FMT_ARGB32,  4, 4, 1, 4, 4, 1, 1, 4, 1, FWHT_FL_PIXENC_RGB},
-       { V4L2_PIX_FMT_ABGR32,  4, 4, 1, 4, 4, 1, 1, 4, 1, FWHT_FL_PIXENC_RGB},
+       { V4L2_PIX_FMT_BGRX32,  4, 4, 1, 4, 4, 1, 1, 3, 1, FWHT_FL_PIXENC_RGB},
+       { V4L2_PIX_FMT_BGRA32,  4, 4, 1, 4, 4, 1, 1, 4, 1, FWHT_FL_PIXENC_RGB},
+       { V4L2_PIX_FMT_RGBX32,  4, 4, 1, 4, 4, 1, 1, 3, 1, FWHT_FL_PIXENC_RGB},
+       { V4L2_PIX_FMT_RGBA32,  4, 4, 1, 4, 4, 1, 1, 4, 1, FWHT_FL_PIXENC_RGB},
+       { V4L2_PIX_FMT_HSV32,   4, 4, 1, 4, 4, 1, 1, 3, 1, FWHT_FL_PIXENC_HSV},
        { V4L2_PIX_FMT_GREY,    1, 1, 1, 1, 0, 1, 1, 1, 1, FWHT_FL_PIXENC_RGB},
 };
 
@@ -193,6 +197,28 @@ static int prepare_raw_frame(struct fwht_raw_frame *rf,
                rf->luma++;
                rf->alpha = rf->cr + 1;
                break;
+       case V4L2_PIX_FMT_BGRX32:
+               rf->cb = rf->luma + 1;
+               rf->cr = rf->cb + 2;
+               rf->luma += 2;
+               break;
+       case V4L2_PIX_FMT_BGRA32:
+               rf->alpha = rf->luma;
+               rf->cb = rf->luma + 1;
+               rf->cr = rf->cb + 2;
+               rf->luma += 2;
+               break;
+       case V4L2_PIX_FMT_RGBX32:
+               rf->cr = rf->luma;
+               rf->cb = rf->cr + 2;
+               rf->luma++;
+               break;
+       case V4L2_PIX_FMT_RGBA32:
+               rf->alpha = rf->luma + 3;
+               rf->cr = rf->luma;
+               rf->cb = rf->cr + 2;
+               rf->luma++;
+               break;
        default:
                return -EINVAL;
        }
index 3b3f36357a0e675cd904d991f43387105f91735d..62dde7d74c240df5c25e21cc418ef3e493e80b0f 100644 (file)
@@ -20,6 +20,8 @@
  *
  * Helper function that returns the media entity containing the source pad
  * linked with the first sink pad from the given media entity pad list.
+ *
+ * Return: The source pad or NULL, if it wasn't found.
  */
 static struct media_entity *vimc_get_source_entity(struct media_entity *ent)
 {
@@ -35,7 +37,7 @@ static struct media_entity *vimc_get_source_entity(struct media_entity *ent)
        return NULL;
 }
 
-/*
+/**
  * vimc_streamer_pipeline_terminate - Disable stream in all ved in stream
  *
  * @stream: the pointer to the stream structure with the pipeline to be
@@ -63,15 +65,18 @@ static void vimc_streamer_pipeline_terminate(struct vimc_stream *stream)
        }
 }
 
-/*
- * vimc_streamer_pipeline_init - initializes the stream structure
+/**
+ * vimc_streamer_pipeline_init - Initializes the stream structure
  *
  * @stream: the pointer to the stream structure to be initialized
  * @ved:    the pointer to the vimc entity initializing the stream
  *
  * Initializes the stream structure. Walks through the entity graph to
  * construct the pipeline used later on the streamer thread.
- * Calls s_stream to enable stream in all entities of the pipeline.
+ * Calls vimc_streamer_s_stream() to enable stream in all entities of
+ * the pipeline.
+ *
+ * Return: 0 if success, error code otherwise.
  */
 static int vimc_streamer_pipeline_init(struct vimc_stream *stream,
                                       struct vimc_ent_device *ved)
@@ -122,13 +127,17 @@ static int vimc_streamer_pipeline_init(struct vimc_stream *stream,
        return -EINVAL;
 }
 
-/*
- * vimc_streamer_thread - process frames through the pipeline
+/**
+ * vimc_streamer_thread - Process frames through the pipeline
  *
  * @data:      vimc_stream struct of the current stream
  *
  * From the source to the sink, gets a frame from each subdevice and send to
  * the next one of the pipeline at a fixed framerate.
+ *
+ * Return:
+ * Always zero (created as ``int`` instead of ``void`` to comply with
+ * kthread API).
  */
 static int vimc_streamer_thread(void *data)
 {
@@ -157,19 +166,20 @@ static int vimc_streamer_thread(void *data)
        return 0;
 }
 
-/*
- * vimc_streamer_s_stream - start/stop the streaming on the media pipeline
+/**
+ * vimc_streamer_s_stream - Start/stop the streaming on the media pipeline
  *
  * @stream:    the pointer to the stream structure of the current stream
  * @ved:       pointer to the vimc entity of the entity of the stream
  * @enable:    flag to determine if stream should start/stop
  *
- * When starting, check if there is no stream->kthread allocated. This should
- * indicate that a stream is already running. Then, it initializes
- * the pipeline, creates and runs a kthread to consume buffers through the
- * pipeline.
- * When stopping, analogously check if there is a stream running, stop
- * the thread and terminates the pipeline.
+ * When starting, check if there is no ``stream->kthread`` allocated. This
+ * should indicate that a stream is already running. Then, it initializes the
+ * pipeline, creates and runs a kthread to consume buffers through the pipeline.
+ * When stopping, analogously check if there is a stream running, stop the
+ * thread and terminates the pipeline.
+ *
+ * Return: 0 if success, error code otherwise.
  */
 int vimc_streamer_s_stream(struct vimc_stream *stream,
                           struct vimc_ent_device *ved,
index 2b36674087948a0acbe8f420cdc4975ac109a5bd..d744a787e0e7c58941b11f46c02316d0afd94c7e 100644 (file)
  * @pipe_size:         size of @ved_pipeline
  * @kthread:           thread that generates the frames of the stream.
  * @producer_pixfmt:   the pixel format requested from the pipeline. This must
- * be set just before calling vimc_streamer_s_stream(ent, 1). This value is
- * propagated up to the source of the base image (usually a sensor node) and
- * can be modified by entities during s_stream callback to request a different
- * format from rest of the pipeline.
+ *                     be set just before calling
+ *                     vimc_streamer_s_stream(ent, 1). This value is propagated
+ *                     up to the source of the base image (usually a sensor
+ *                     node) and can be modified by entities during s_stream
+ *                     callback to request a differentformat from rest of
+ *                     the pipeline.
  *
  * When the user call stream_on in a video device, struct vimc_stream is
  * used to keep track of all entities and subdevices that generates and
@@ -43,14 +45,6 @@ struct vimc_stream {
        u32 producer_pixfmt;
 };
 
-/**
- * vimc_streamer_s_streamer - start/stop the stream
- *
- * @stream:    the pointer to the stream to start or stop
- * @ved:       The last entity of the streamer pipeline
- * @enable:    any non-zero number start the stream, zero stop
- *
- */
 int vimc_streamer_s_stream(struct vimc_stream *stream,
                           struct vimc_ent_device *ved,
                           int enable);
index d535aac68ce168c37fb8542cbfa2599a056b3686..53315c8dd2bbcdae80bcc44174e7bd296cf6c393 100644 (file)
@@ -792,7 +792,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
        if (no_error_inj && ccs_cap == -1)
                ccs_cap = 7;
 
-       /* if ccs_cap == -1, then the use can select it using controls */
+       /* if ccs_cap == -1, then the user can select it using controls */
        if (ccs_cap != -1) {
                dev->has_crop_cap = ccs_cap & 1;
                dev->has_compose_cap = ccs_cap & 2;
@@ -807,7 +807,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
        if (no_error_inj && ccs_out == -1)
                ccs_out = 7;
 
-       /* if ccs_out == -1, then the use can select it using controls */
+       /* if ccs_out == -1, then the user can select it using controls */
        if (ccs_out != -1) {
                dev->has_crop_out = ccs_out & 1;
                dev->has_compose_out = ccs_out & 2;
index 3e916c8befb7170e7c247e3dffc364432e10254b..cb19a9a730920a3bfccb20fba153331c8bbc2cdb 100644 (file)
@@ -1473,7 +1473,7 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap,
        v4l2_ctrl_handler_init(hdl_vid_cap, 55);
        v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_class, NULL);
        v4l2_ctrl_handler_init(hdl_vid_out, 26);
-       if (!no_error_inj || dev->has_fb)
+       if (!no_error_inj || dev->has_fb || dev->num_hdmi_outputs)
                v4l2_ctrl_new_custom(hdl_vid_out, &vivid_ctrl_class, NULL);
        v4l2_ctrl_handler_init(hdl_vbi_cap, 21);
        v4l2_ctrl_new_custom(hdl_vbi_cap, &vivid_ctrl_class, NULL);
@@ -1613,6 +1613,8 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap,
        }
 
        if (dev->num_hdmi_inputs) {
+               s64 hdmi_input_mask = GENMASK(dev->num_hdmi_inputs - 1, 0);
+
                dev->ctrl_dv_timings_signal_mode = v4l2_ctrl_new_custom(hdl_vid_cap,
                                        &vivid_ctrl_dv_timings_signal_mode, NULL);
 
@@ -1633,12 +1635,13 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap,
                        V4L2_CID_DV_RX_RGB_RANGE, V4L2_DV_RGB_RANGE_FULL,
                        0, V4L2_DV_RGB_RANGE_AUTO);
                dev->ctrl_rx_power_present = v4l2_ctrl_new_std(hdl_vid_cap,
-                       NULL, V4L2_CID_DV_RX_POWER_PRESENT, 0,
-                       (2 << (dev->num_hdmi_inputs - 1)) - 1, 0,
-                       (2 << (dev->num_hdmi_inputs - 1)) - 1);
+                       NULL, V4L2_CID_DV_RX_POWER_PRESENT, 0, hdmi_input_mask,
+                       0, hdmi_input_mask);
 
        }
        if (dev->num_hdmi_outputs) {
+               s64 hdmi_output_mask = GENMASK(dev->num_hdmi_outputs - 1, 0);
+
                /*
                 * We aren't doing anything with this at the moment, but
                 * HDMI outputs typically have this controls.
@@ -1652,17 +1655,14 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap,
                dev->ctrl_display_present = v4l2_ctrl_new_custom(hdl_vid_out,
                        &vivid_ctrl_display_present, NULL);
                dev->ctrl_tx_hotplug = v4l2_ctrl_new_std(hdl_vid_out,
-                       NULL, V4L2_CID_DV_TX_HOTPLUG, 0,
-                       (2 << (dev->num_hdmi_outputs - 1)) - 1, 0,
-                       (2 << (dev->num_hdmi_outputs - 1)) - 1);
+                       NULL, V4L2_CID_DV_TX_HOTPLUG, 0, hdmi_output_mask,
+                       0, hdmi_output_mask);
                dev->ctrl_tx_rxsense = v4l2_ctrl_new_std(hdl_vid_out,
-                       NULL, V4L2_CID_DV_TX_RXSENSE, 0,
-                       (2 << (dev->num_hdmi_outputs - 1)) - 1, 0,
-                       (2 << (dev->num_hdmi_outputs - 1)) - 1);
+                       NULL, V4L2_CID_DV_TX_RXSENSE, 0, hdmi_output_mask,
+                       0, hdmi_output_mask);
                dev->ctrl_tx_edid_present = v4l2_ctrl_new_std(hdl_vid_out,
-                       NULL, V4L2_CID_DV_TX_EDID_PRESENT, 0,
-                       (2 << (dev->num_hdmi_outputs - 1)) - 1, 0,
-                       (2 << (dev->num_hdmi_outputs - 1)) - 1);
+                       NULL, V4L2_CID_DV_TX_EDID_PRESENT, 0, hdmi_output_mask,
+                       0, hdmi_output_mask);
        }
        if ((dev->has_vid_cap && dev->has_vid_out) ||
            (dev->has_vbi_cap && dev->has_vbi_out))
index 6cf495a7d5cc1f46b11611588f0e0ace7faa38e8..003319d7816d77f24883d9a2d6ce492339c0bb81 100644 (file)
@@ -232,8 +232,8 @@ static void *plane_vaddr(struct tpg_data *tpg, struct vivid_buffer *buf,
        return vbuf;
 }
 
-static int vivid_copy_buffer(struct vivid_dev *dev, unsigned p, u8 *vcapbuf,
-               struct vivid_buffer *vid_cap_buf)
+static noinline_for_stack int vivid_copy_buffer(struct vivid_dev *dev, unsigned p,
+               u8 *vcapbuf, struct vivid_buffer *vid_cap_buf)
 {
        bool blank = dev->must_blank[vid_cap_buf->vb.vb2_buf.index];
        struct tpg_data *tpg = &dev->tpg;
@@ -658,6 +658,8 @@ static void vivid_cap_update_frame_period(struct vivid_dev *dev)
        u64 f_period;
 
        f_period = (u64)dev->timeperframe_vid_cap.numerator * 1000000000;
+       if (WARN_ON(dev->timeperframe_vid_cap.denominator == 0))
+               dev->timeperframe_vid_cap.denominator = 1;
        do_div(f_period, dev->timeperframe_vid_cap.denominator);
        if (dev->field_cap == V4L2_FIELD_ALTERNATE)
                f_period >>= 1;
@@ -670,7 +672,8 @@ static void vivid_cap_update_frame_period(struct vivid_dev *dev)
        dev->cap_frame_period = f_period;
 }
 
-static void vivid_thread_vid_cap_tick(struct vivid_dev *dev, int dropped_bufs)
+static noinline_for_stack void vivid_thread_vid_cap_tick(struct vivid_dev *dev,
+                                                        int dropped_bufs)
 {
        struct vivid_buffer *vid_cap_buf = NULL;
        struct vivid_buffer *vbi_cap_buf = NULL;
index 1f33eb1a76b68ae8be26027ee9e1b2af7f0a10d9..8665dfd25eb47556eff0b8692d364ad33d6c0184 100644 (file)
@@ -262,21 +262,66 @@ struct vivid_fmt vivid_formats[] = {
                .can_do_overlay = true,
        },
        {
-               .fourcc   = V4L2_PIX_FMT_RGB444, /* xxxxrrrr ggggbbbb */
+               .fourcc   = V4L2_PIX_FMT_RGB444, /* ggggbbbb xxxxrrrr */
                .vdownsampling = { 1 },
                .bit_depth = { 16 },
                .planes   = 1,
                .buffers = 1,
        },
        {
-               .fourcc   = V4L2_PIX_FMT_XRGB444, /* xxxxrrrr ggggbbbb */
+               .fourcc   = V4L2_PIX_FMT_XRGB444, /* ggggbbbb xxxxrrrr */
                .vdownsampling = { 1 },
                .bit_depth = { 16 },
                .planes   = 1,
                .buffers = 1,
        },
        {
-               .fourcc   = V4L2_PIX_FMT_ARGB444, /* aaaarrrr ggggbbbb */
+               .fourcc   = V4L2_PIX_FMT_ARGB444, /* ggggbbbb aaaarrrr */
+               .vdownsampling = { 1 },
+               .bit_depth = { 16 },
+               .planes   = 1,
+               .buffers = 1,
+               .alpha_mask = 0x00f0,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_RGBX444, /* bbbbxxxx rrrrgggg */
+               .vdownsampling = { 1 },
+               .bit_depth = { 16 },
+               .planes   = 1,
+               .buffers = 1,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_RGBA444, /* bbbbaaaa rrrrgggg */
+               .vdownsampling = { 1 },
+               .bit_depth = { 16 },
+               .planes   = 1,
+               .buffers = 1,
+               .alpha_mask = 0x00f0,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_XBGR444, /* ggggrrrr xxxxbbbb */
+               .vdownsampling = { 1 },
+               .bit_depth = { 16 },
+               .planes   = 1,
+               .buffers = 1,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_ABGR444, /* ggggrrrr aaaabbbb */
+               .vdownsampling = { 1 },
+               .bit_depth = { 16 },
+               .planes   = 1,
+               .buffers = 1,
+               .alpha_mask = 0x00f0,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_BGRX444, /* rrrrxxxx bbbbgggg */
+               .vdownsampling = { 1 },
+               .bit_depth = { 16 },
+               .planes   = 1,
+               .buffers = 1,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_BGRA444, /* rrrraaaa bbbbgggg  */
                .vdownsampling = { 1 },
                .bit_depth = { 16 },
                .planes   = 1,
@@ -308,6 +353,57 @@ struct vivid_fmt vivid_formats[] = {
                .can_do_overlay = true,
                .alpha_mask = 0x8000,
        },
+       {
+               .fourcc   = V4L2_PIX_FMT_RGBX555, /* ggbbbbbx rrrrrggg */
+               .vdownsampling = { 1 },
+               .bit_depth = { 16 },
+               .planes   = 1,
+               .buffers = 1,
+               .can_do_overlay = true,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_RGBA555, /* ggbbbbba rrrrrggg */
+               .vdownsampling = { 1 },
+               .bit_depth = { 16 },
+               .planes   = 1,
+               .buffers = 1,
+               .can_do_overlay = true,
+               .alpha_mask = 0x8000,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_XBGR555, /* gggrrrrr xbbbbbgg */
+               .vdownsampling = { 1 },
+               .bit_depth = { 16 },
+               .planes   = 1,
+               .buffers = 1,
+               .can_do_overlay = true,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_ABGR555, /* gggrrrrr abbbbbgg */
+               .vdownsampling = { 1 },
+               .bit_depth = { 16 },
+               .planes   = 1,
+               .buffers = 1,
+               .can_do_overlay = true,
+               .alpha_mask = 0x8000,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_BGRX555, /* ggrrrrrx bbbbbggg */
+               .vdownsampling = { 1 },
+               .bit_depth = { 16 },
+               .planes   = 1,
+               .buffers = 1,
+               .can_do_overlay = true,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_BGRA555, /* ggrrrrra bbbbbggg */
+               .vdownsampling = { 1 },
+               .bit_depth = { 16 },
+               .planes   = 1,
+               .buffers = 1,
+               .can_do_overlay = true,
+               .alpha_mask = 0x8000,
+       },
        {
                .fourcc   = V4L2_PIX_FMT_RGB555X, /* xrrrrrgg gggbbbbb */
                .vdownsampling = { 1 },
@@ -395,6 +491,36 @@ struct vivid_fmt vivid_formats[] = {
                .buffers = 1,
                .alpha_mask = 0xff000000,
        },
+       {
+               .fourcc   = V4L2_PIX_FMT_RGBX32, /* rgbx */
+               .vdownsampling = { 1 },
+               .bit_depth = { 32 },
+               .planes   = 1,
+               .buffers = 1,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_BGRX32, /* xbgr */
+               .vdownsampling = { 1 },
+               .bit_depth = { 32 },
+               .planes   = 1,
+               .buffers = 1,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_RGBA32, /* rgba */
+               .vdownsampling = { 1 },
+               .bit_depth = { 32 },
+               .planes   = 1,
+               .buffers = 1,
+               .alpha_mask = 0x000000ff,
+       },
+       {
+               .fourcc   = V4L2_PIX_FMT_BGRA32, /* abgr */
+               .vdownsampling = { 1 },
+               .bit_depth = { 32 },
+               .planes   = 1,
+               .buffers = 1,
+               .alpha_mask = 0xff000000,
+       },
        {
                .fourcc   = V4L2_PIX_FMT_SBGGR8, /* Bayer BG/GR */
                .vdownsampling = { 1 },
index 8b01e99acd20ac0c66aeecb6503e1b1879ef392b..30d751f2cccf1b98faec4b2042ac647bb5b84270 100644 (file)
@@ -426,8 +426,6 @@ static int histo_v4l2_querycap(struct file *file, void *fh,
                          | V4L2_CAP_VIDEO_CAPTURE_MPLANE
                          | V4L2_CAP_VIDEO_OUTPUT_MPLANE
                          | V4L2_CAP_META_CAPTURE;
-       cap->device_caps = V4L2_CAP_META_CAPTURE
-                        | V4L2_CAP_STREAMING;
 
        strscpy(cap->driver, "vsp1", sizeof(cap->driver));
        strscpy(cap->card, histo->video.name, sizeof(cap->card));
@@ -556,6 +554,7 @@ int vsp1_histogram_init(struct vsp1_device *vsp1, struct vsp1_histogram *histo,
        histo->video.vfl_type = VFL_TYPE_GRABBER;
        histo->video.release = video_device_release_empty;
        histo->video.ioctl_ops = &histo_v4l2_ioctl_ops;
+       histo->video.device_caps = V4L2_CAP_META_CAPTURE | V4L2_CAP_STREAMING;
 
        video_set_drvdata(&histo->video, histo);
 
index fd98e483b2f4262f5a2bf0e23fb60bf3aee7d295..5e59ed2c3614af03c1f573ed245d6007a72d0fd7 100644 (file)
@@ -956,12 +956,6 @@ vsp1_video_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
                          | V4L2_CAP_VIDEO_CAPTURE_MPLANE
                          | V4L2_CAP_VIDEO_OUTPUT_MPLANE;
 
-       if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
-               cap->device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE
-                                | V4L2_CAP_STREAMING;
-       else
-               cap->device_caps = V4L2_CAP_VIDEO_OUTPUT_MPLANE
-                                | V4L2_CAP_STREAMING;
 
        strscpy(cap->driver, "vsp1", sizeof(cap->driver));
        strscpy(cap->card, video->video.name, sizeof(cap->card));
@@ -1268,11 +1262,15 @@ struct vsp1_video *vsp1_video_create(struct vsp1_device *vsp1,
                video->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
                video->pad.flags = MEDIA_PAD_FL_SOURCE;
                video->video.vfl_dir = VFL_DIR_TX;
+               video->video.device_caps = V4L2_CAP_VIDEO_OUTPUT_MPLANE |
+                                          V4L2_CAP_STREAMING;
        } else {
                direction = "output";
                video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
                video->pad.flags = MEDIA_PAD_FL_SINK;
                video->video.vfl_dir = VFL_DIR_RX;
+               video->video.device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE |
+                                          V4L2_CAP_STREAMING;
        }
 
        mutex_init(&video->lock);
index c9d5fdb2d407ed9f8babd406fc7159f5233cb343..b211380a11f2799fa108d5e4527dbc0ff5381eb6 100644 (file)
@@ -491,15 +491,8 @@ xvip_dma_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
        struct v4l2_fh *vfh = file->private_data;
        struct xvip_dma *dma = to_xvip_dma(vfh->vdev);
 
-       cap->device_caps = V4L2_CAP_STREAMING;
-
-       if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               cap->device_caps |= V4L2_CAP_VIDEO_CAPTURE;
-       else
-               cap->device_caps |= V4L2_CAP_VIDEO_OUTPUT;
-
-       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS
-                         | dma->xdev->v4l2_caps;
+       cap->capabilities = dma->xdev->v4l2_caps | V4L2_CAP_STREAMING |
+                           V4L2_CAP_DEVICE_CAPS;
 
        strscpy(cap->driver, "xilinx-vipp", sizeof(cap->driver));
        strscpy(cap->card, dma->video.name, sizeof(cap->card));
@@ -524,8 +517,6 @@ xvip_dma_enum_format(struct file *file, void *fh, struct v4l2_fmtdesc *f)
                return -EINVAL;
 
        f->pixelformat = dma->format.pixelformat;
-       strscpy(f->description, dma->fmtinfo->description,
-               sizeof(f->description));
 
        return 0;
 }
@@ -700,6 +691,11 @@ int xvip_dma_init(struct xvip_composite_device *xdev, struct xvip_dma *dma,
        dma->video.release = video_device_release_empty;
        dma->video.ioctl_ops = &xvip_dma_ioctl_ops;
        dma->video.lock = &dma->lock;
+       dma->video.device_caps = V4L2_CAP_STREAMING;
+       if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
+               dma->video.device_caps |= V4L2_CAP_VIDEO_CAPTURE;
+       else
+               dma->video.device_caps |= V4L2_CAP_VIDEO_OUTPUT;
 
        video_set_drvdata(&dma->video, dma);
 
index 08a825c3a3f605bd6c2ace5db568a4a4fd1a1887..6ad61b08a31abe6772db554133041ef14b48de77 100644 (file)
 
 static const struct xvip_video_format xvip_video_formats[] = {
        { XVIP_VF_YUV_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16,
-         2, V4L2_PIX_FMT_YUYV, "4:2:2, packed, YUYV" },
+         2, V4L2_PIX_FMT_YUYV },
        { XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24,
-         3, V4L2_PIX_FMT_YUV444, "4:4:4, packed, YUYV" },
+         3, V4L2_PIX_FMT_YUV444 },
        { XVIP_VF_RBG, 8, NULL, MEDIA_BUS_FMT_RBG888_1X24,
-         3, 0, NULL },
+         3, 0 },
        { XVIP_VF_MONO_SENSOR, 8, "mono", MEDIA_BUS_FMT_Y8_1X8,
-         1, V4L2_PIX_FMT_GREY, "Greyscale 8-bit" },
+         1, V4L2_PIX_FMT_GREY },
        { XVIP_VF_MONO_SENSOR, 8, "rggb", MEDIA_BUS_FMT_SRGGB8_1X8,
-         1, V4L2_PIX_FMT_SRGGB8, "Bayer 8-bit RGGB" },
+         1, V4L2_PIX_FMT_SRGGB8 },
        { XVIP_VF_MONO_SENSOR, 8, "grbg", MEDIA_BUS_FMT_SGRBG8_1X8,
-         1, V4L2_PIX_FMT_SGRBG8, "Bayer 8-bit GRBG" },
+         1, V4L2_PIX_FMT_SGRBG8 },
        { XVIP_VF_MONO_SENSOR, 8, "gbrg", MEDIA_BUS_FMT_SGBRG8_1X8,
-         1, V4L2_PIX_FMT_SGBRG8, "Bayer 8-bit GBRG" },
+         1, V4L2_PIX_FMT_SGBRG8 },
        { XVIP_VF_MONO_SENSOR, 8, "bggr", MEDIA_BUS_FMT_SBGGR8_1X8,
-         1, V4L2_PIX_FMT_SBGGR8, "Bayer 8-bit BGGR" },
+         1, V4L2_PIX_FMT_SBGGR8 },
 };
 
 /**
index ba939dd52818941bd9bc2bc5073209bfd3bef576..47da39211ae42dede6c14103daa2ce4d9c2c76e6 100644 (file)
@@ -108,7 +108,6 @@ struct xvip_device {
  * @code: media bus format code
  * @bpp: bytes per pixel (when stored in memory)
  * @fourcc: V4L2 pixel format FCC identifier
- * @description: format description, suitable for userspace
  */
 struct xvip_video_format {
        unsigned int vf_code;
@@ -117,7 +116,6 @@ struct xvip_video_format {
        unsigned int code;
        unsigned int bpp;
        u32 fourcc;
-       const char *description;
 };
 
 const struct xvip_video_format *xvip_get_format_by_code(unsigned int code);
index edce0402155dfb007b1b456f7456ecc6ccf218f5..cc2856efea5947cfd91f02f6cb18b9e9e01e15a7 100644 (file)
@@ -385,9 +385,9 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev,
                asd = v4l2_async_notifier_add_fwnode_subdev(
                        &xdev->notifier, remote,
                        sizeof(struct xvip_graph_entity));
+               fwnode_handle_put(remote);
                if (IS_ERR(asd)) {
                        ret = PTR_ERR(asd);
-                       fwnode_handle_put(remote);
                        goto err_notifier_cleanup;
                }
        }
index ea05e125016a741cf12bc63c1671131b802a2d5b..872d6441e512cda9bf940bcbf2dd5b6e8c9864a8 100644 (file)
@@ -413,6 +413,10 @@ static int iguanair_probe(struct usb_interface *intf,
        int ret, pipein, pipeout;
        struct usb_host_interface *idesc;
 
+       idesc = intf->altsetting;
+       if (idesc->desc.bNumEndpoints < 2)
+               return -ENODEV;
+
        ir = kzalloc(sizeof(*ir), GFP_KERNEL);
        rc = rc_allocate_device(RC_DRIVER_IR_RAW);
        if (!ir || !rc) {
@@ -427,18 +431,13 @@ static int iguanair_probe(struct usb_interface *intf,
        ir->urb_in = usb_alloc_urb(0, GFP_KERNEL);
        ir->urb_out = usb_alloc_urb(0, GFP_KERNEL);
 
-       if (!ir->buf_in || !ir->packet || !ir->urb_in || !ir->urb_out) {
+       if (!ir->buf_in || !ir->packet || !ir->urb_in || !ir->urb_out ||
+           !usb_endpoint_is_int_in(&idesc->endpoint[0].desc) ||
+           !usb_endpoint_is_int_out(&idesc->endpoint[1].desc)) {
                ret = -ENOMEM;
                goto out;
        }
 
-       idesc = intf->altsetting;
-
-       if (idesc->desc.bNumEndpoints < 2) {
-               ret = -ENODEV;
-               goto out;
-       }
-
        ir->rc = rc;
        ir->dev = &intf->dev;
        ir->udev = udev;
index 7e457f26a5959afab9a93281de122c4e88378747..094aa6a063156835ff5c8efbf863fc0e7026cbb0 100644 (file)
@@ -81,10 +81,8 @@ static int img_ir_probe(struct platform_device *pdev)
 
        /* Get resources from platform device */
        irq = platform_get_irq(pdev, 0);
-       if (irq < 0) {
-               dev_err(&pdev->dev, "cannot find IRQ resource\n");
+       if (irq < 0)
                return irq;
-       }
 
        /* Private driver data */
        priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
index 85561f6555a2261840fa558467afc9d5d9bfebdd..32ccefeff57d15c4de1e88791d3d2eed6a3cfb78 100644 (file)
@@ -232,10 +232,8 @@ static int hix5hd2_ir_probe(struct platform_device *pdev)
                return PTR_ERR(priv->base);
 
        priv->irq = platform_get_irq(pdev, 0);
-       if (priv->irq < 0) {
-               dev_err(dev, "irq can not get\n");
+       if (priv->irq < 0)
                return priv->irq;
-       }
 
        rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
        if (!rdev)
index 4d5351ebb9408b02a2f13fbacedb47f4c98c51cc..bc74c09ddeb6a49b320c6d8dec172cdfc4242721 100644 (file)
@@ -461,6 +461,7 @@ struct mceusb_dev {
 
        /* usb */
        struct usb_device *usbdev;
+       struct usb_interface *usbintf;
        struct urb *urb_in;
        unsigned int pipe_in;
        struct usb_endpoint_descriptor *usb_ep_out;
@@ -517,6 +518,7 @@ struct mceusb_dev {
        unsigned long kevent_flags;
 #              define EVENT_TX_HALT    0
 #              define EVENT_RX_HALT    1
+#              define EVENT_RST_PEND   31
 };
 
 /* MCE Device Command Strings, generally a port and command pair */
@@ -758,8 +760,15 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, u8 *buf, int buf_len,
 static void mceusb_defer_kevent(struct mceusb_dev *ir, int kevent)
 {
        set_bit(kevent, &ir->kevent_flags);
+
+       if (test_bit(EVENT_RST_PEND, &ir->kevent_flags)) {
+               dev_dbg(ir->dev, "kevent %d dropped pending USB Reset Device",
+                       kevent);
+               return;
+       }
+
        if (!schedule_work(&ir->kevent))
-               dev_err(ir->dev, "kevent %d may have been dropped", kevent);
+               dev_dbg(ir->dev, "kevent %d already scheduled", kevent);
        else
                dev_dbg(ir->dev, "kevent %d scheduled", kevent);
 }
@@ -1398,28 +1407,59 @@ static void mceusb_deferred_kevent(struct work_struct *work)
                container_of(work, struct mceusb_dev, kevent);
        int status;
 
+       dev_err(ir->dev, "kevent handler called (flags 0x%lx)",
+               ir->kevent_flags);
+
+       if (test_bit(EVENT_RST_PEND, &ir->kevent_flags)) {
+               dev_err(ir->dev, "kevent handler canceled pending USB Reset Device");
+               return;
+       }
+
        if (test_bit(EVENT_RX_HALT, &ir->kevent_flags)) {
                usb_unlink_urb(ir->urb_in);
                status = usb_clear_halt(ir->usbdev, ir->pipe_in);
+               dev_err(ir->dev, "rx clear halt status = %d", status);
                if (status < 0) {
-                       dev_err(ir->dev, "rx clear halt error %d",
-                               status);
+                       /*
+                        * Unable to clear RX halt/stall.
+                        * Will need to call usb_reset_device().
+                        */
+                       dev_err(ir->dev,
+                               "stuck RX HALT state requires USB Reset Device to clear");
+                       usb_queue_reset_device(ir->usbintf);
+                       set_bit(EVENT_RST_PEND, &ir->kevent_flags);
+                       clear_bit(EVENT_RX_HALT, &ir->kevent_flags);
+
+                       /* Cancel all other error events and handlers */
+                       clear_bit(EVENT_TX_HALT, &ir->kevent_flags);
+                       return;
                }
                clear_bit(EVENT_RX_HALT, &ir->kevent_flags);
-               if (status == 0) {
-                       status = usb_submit_urb(ir->urb_in, GFP_KERNEL);
-                       if (status < 0) {
-                               dev_err(ir->dev,
-                                       "rx unhalt submit urb error %d",
-                                       status);
-                       }
+               status = usb_submit_urb(ir->urb_in, GFP_KERNEL);
+               if (status < 0) {
+                       dev_err(ir->dev, "rx unhalt submit urb error = %d",
+                               status);
                }
        }
 
        if (test_bit(EVENT_TX_HALT, &ir->kevent_flags)) {
                status = usb_clear_halt(ir->usbdev, ir->pipe_out);
-               if (status < 0)
-                       dev_err(ir->dev, "tx clear halt error %d", status);
+               dev_err(ir->dev, "tx clear halt status = %d", status);
+               if (status < 0) {
+                       /*
+                        * Unable to clear TX halt/stall.
+                        * Will need to call usb_reset_device().
+                        */
+                       dev_err(ir->dev,
+                               "stuck TX HALT state requires USB Reset Device to clear");
+                       usb_queue_reset_device(ir->usbintf);
+                       set_bit(EVENT_RST_PEND, &ir->kevent_flags);
+                       clear_bit(EVENT_TX_HALT, &ir->kevent_flags);
+
+                       /* Cancel all other error events and handlers */
+                       clear_bit(EVENT_RX_HALT, &ir->kevent_flags);
+                       return;
+               }
                clear_bit(EVENT_TX_HALT, &ir->kevent_flags);
        }
 }
@@ -1581,6 +1621,7 @@ static int mceusb_dev_probe(struct usb_interface *intf,
        if (!ir->urb_in)
                goto urb_in_alloc_fail;
 
+       ir->usbintf = intf;
        ir->usbdev = usb_get_dev(dev);
        ir->dev = &intf->dev;
        ir->len_in = maxp;
@@ -1688,6 +1729,8 @@ static void mceusb_dev_disconnect(struct usb_interface *intf)
        struct usb_device *dev = interface_to_usbdev(intf);
        struct mceusb_dev *ir = usb_get_intfdata(intf);
 
+       dev_dbg(&intf->dev, "%s called", __func__);
+
        usb_set_intfdata(intf, NULL);
 
        if (!ir)
index 72a7bbbf6b1f03eb1393be9e8dd5dc53edb93856..51c6dd3406a0efb8b2012dbcc8d6c2714fcfca21 100644 (file)
@@ -117,10 +117,8 @@ static int meson_ir_probe(struct platform_device *pdev)
                return PTR_ERR(ir->reg);
 
        irq = platform_get_irq(pdev, 0);
-       if (irq < 0) {
-               dev_err(dev, "no irq resource\n");
+       if (irq < 0)
                return irq;
-       }
 
        ir->rc = devm_rc_allocate_device(dev, RC_DRIVER_IR_RAW);
        if (!ir->rc) {
index 50fb0aebb8d403ed247bf84ddedffbb51deb78f2..a0c94ab322c7d26190e5cdbb95f7ccd93b2e4638 100644 (file)
 /* Fields containing pulse width data */
 #define MTK_WIDTH_MASK           (GENMASK(7, 0))
 
+/* IR threshold */
+#define MTK_IRTHD               0x14
+#define MTK_DG_CNT_MASK                 (GENMASK(12, 8))
+#define MTK_DG_CNT(x)           ((x) << 8)
+
 /* Bit to enable interrupt */
 #define MTK_IRINT_EN             BIT(0)
 
@@ -340,7 +345,7 @@ static int mtk_ir_probe(struct platform_device *pdev)
        ir->rc->map_name = map_name ?: RC_MAP_EMPTY;
        ir->rc->dev.parent = dev;
        ir->rc->driver_name = MTK_IR_DEV;
-       ir->rc->allowed_protocols = RC_PROTO_BIT_ALL;
+       ir->rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
        ir->rc->rx_resolution = MTK_IR_SAMPLE;
        ir->rc->timeout = MTK_MAX_SAMPLES * (MTK_IR_SAMPLE + 1);
 
@@ -353,10 +358,8 @@ static int mtk_ir_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, ir);
 
        ir->irq = platform_get_irq(pdev, 0);
-       if (ir->irq < 0) {
-               dev_err(dev, "no irq resource\n");
+       if (ir->irq < 0)
                return -ENODEV;
-       }
 
        if (clk_prepare_enable(ir->clk)) {
                dev_err(dev, "try to enable ir_clk failed\n");
@@ -398,6 +401,9 @@ static int mtk_ir_probe(struct platform_device *pdev)
        mtk_w32_mask(ir, val, ir->data->fields[MTK_HW_PERIOD].mask,
                     ir->data->fields[MTK_HW_PERIOD].reg);
 
+       /* Set de-glitch counter */
+       mtk_w32_mask(ir, MTK_DG_CNT(1), MTK_DG_CNT_MASK, MTK_IRTHD);
+
        /* Enable IR and PWM */
        val = mtk_r32(ir, MTK_CONFIG_HIGH_REG);
        val |= MTK_OK_COUNT(ir->data->ok_count) |  MTK_PWM_EN | MTK_IR_EN;
index aa719d0ae6b016fa2057bc4f1498efc8fbf2d045..e222b4c98be42cff13b7b530278b626518182d37 100644 (file)
 
 /* Rx Interrupt Enable */
 #define SUNXI_IR_RXINT_REG    0x2C
-/* Rx FIFO Overflow */
+/* Rx FIFO Overflow Interrupt Enable */
 #define REG_RXINT_ROI_EN               BIT(0)
-/* Rx Packet End */
+/* Rx Packet End Interrupt Enable */
 #define REG_RXINT_RPEI_EN              BIT(1)
-/* Rx FIFO Data Available */
+/* Rx FIFO Data Available Interrupt Enable */
 #define REG_RXINT_RAI_EN               BIT(4)
 
 /* Rx FIFO available byte level */
 
 /* Rx Interrupt Status */
 #define SUNXI_IR_RXSTA_REG    0x30
+/* Rx FIFO Overflow */
+#define REG_RXSTA_ROI                  REG_RXINT_ROI_EN
+/* Rx Packet End */
+#define REG_RXSTA_RPE                  REG_RXINT_RPEI_EN
+/* Rx FIFO Data Available */
+#define REG_RXSTA_RA                   REG_RXINT_RAI_EN
 /* RX FIFO Get Available Counter */
 #define REG_RXSTA_GET_AC(val) (((val) >> 8) & (ir->fifo_size * 2 - 1))
 /* Clear all interrupt status value */
 /* Time after which device stops sending data in ms */
 #define SUNXI_IR_TIMEOUT      120
 
+/**
+ * struct sunxi_ir_quirks - Differences between SoC variants.
+ *
+ * @has_reset: SoC needs reset deasserted.
+ * @fifo_size: size of the fifo.
+ */
+struct sunxi_ir_quirks {
+       bool            has_reset;
+       int             fifo_size;
+};
+
 struct sunxi_ir {
        spinlock_t      ir_lock;
        struct rc_dev   *rc;
@@ -99,7 +116,7 @@ static irqreturn_t sunxi_ir_irq(int irqno, void *dev_id)
        /* clean all pending statuses */
        writel(status | REG_RXSTA_CLEARALL, ir->base + SUNXI_IR_RXSTA_REG);
 
-       if (status & (REG_RXINT_RAI_EN | REG_RXINT_RPEI_EN)) {
+       if (status & (REG_RXSTA_RA | REG_RXSTA_RPE)) {
                /* How many messages in fifo */
                rc  = REG_RXSTA_GET_AC(status);
                /* Sanity check */
@@ -115,9 +132,9 @@ static irqreturn_t sunxi_ir_irq(int irqno, void *dev_id)
                }
        }
 
-       if (status & REG_RXINT_ROI_EN) {
+       if (status & REG_RXSTA_ROI) {
                ir_raw_event_reset(ir->rc);
-       } else if (status & REG_RXINT_RPEI_EN) {
+       } else if (status & REG_RXSTA_RPE) {
                ir_raw_event_set_idle(ir->rc, true);
                ir_raw_event_handle(ir->rc);
        }
@@ -134,6 +151,7 @@ static int sunxi_ir_probe(struct platform_device *pdev)
 
        struct device *dev = &pdev->dev;
        struct device_node *dn = dev->of_node;
+       const struct sunxi_ir_quirks *quirks;
        struct resource *res;
        struct sunxi_ir *ir;
        u32 b_clk_freq = SUNXI_IR_BASE_CLK;
@@ -142,12 +160,15 @@ static int sunxi_ir_probe(struct platform_device *pdev)
        if (!ir)
                return -ENOMEM;
 
+       quirks = of_device_get_match_data(&pdev->dev);
+       if (!quirks) {
+               dev_err(&pdev->dev, "Failed to determine the quirks to use\n");
+               return -ENODEV;
+       }
+
        spin_lock_init(&ir->ir_lock);
 
-       if (of_device_is_compatible(dn, "allwinner,sun5i-a13-ir"))
-               ir->fifo_size = 64;
-       else
-               ir->fifo_size = 16;
+       ir->fifo_size = quirks->fifo_size;
 
        /* Clock */
        ir->apb_clk = devm_clk_get(dev, "apb");
@@ -164,13 +185,15 @@ static int sunxi_ir_probe(struct platform_device *pdev)
        /* Base clock frequency (optional) */
        of_property_read_u32(dn, "clock-frequency", &b_clk_freq);
 
-       /* Reset (optional) */
-       ir->rst = devm_reset_control_get_optional_exclusive(dev, NULL);
-       if (IS_ERR(ir->rst))
-               return PTR_ERR(ir->rst);
-       ret = reset_control_deassert(ir->rst);
-       if (ret)
-               return ret;
+       /* Reset */
+       if (quirks->has_reset) {
+               ir->rst = devm_reset_control_get_exclusive(dev, NULL);
+               if (IS_ERR(ir->rst))
+                       return PTR_ERR(ir->rst);
+               ret = reset_control_deassert(ir->rst);
+               if (ret)
+                       return ret;
+       }
 
        ret = clk_set_rate(ir->clk, b_clk_freq);
        if (ret) {
@@ -233,7 +256,6 @@ static int sunxi_ir_probe(struct platform_device *pdev)
        /* IRQ */
        ir->irq = platform_get_irq(pdev, 0);
        if (ir->irq < 0) {
-               dev_err(dev, "no irq resource\n");
                ret = ir->irq;
                goto exit_free_dev;
        }
@@ -306,10 +328,35 @@ static int sunxi_ir_remove(struct platform_device *pdev)
        return 0;
 }
 
+static const struct sunxi_ir_quirks sun4i_a10_ir_quirks = {
+       .has_reset = false,
+       .fifo_size = 16,
+};
+
+static const struct sunxi_ir_quirks sun5i_a13_ir_quirks = {
+       .has_reset = false,
+       .fifo_size = 64,
+};
+
+static const struct sunxi_ir_quirks sun6i_a31_ir_quirks = {
+       .has_reset = true,
+       .fifo_size = 64,
+};
+
 static const struct of_device_id sunxi_ir_match[] = {
-       { .compatible = "allwinner,sun4i-a10-ir", },
-       { .compatible = "allwinner,sun5i-a13-ir", },
-       {},
+       {
+               .compatible = "allwinner,sun4i-a10-ir",
+               .data = &sun4i_a10_ir_quirks,
+       },
+       {
+               .compatible = "allwinner,sun5i-a13-ir",
+               .data = &sun5i_a13_ir_quirks,
+       },
+       {
+               .compatible = "allwinner,sun6i-a31-ir",
+               .data = &sun6i_a31_ir_quirks,
+       },
+       {}
 };
 MODULE_DEVICE_TABLE(of, sunxi_ir_match);
 
index b35231ffe50316330238cc70a2909d837b990be2..751703db06f517ab727f4893c8a2e9a106b2bbe9 100644 (file)
@@ -71,7 +71,6 @@ static const struct v4l2_frequency_band bands_rf[] = {
 
 /* stream formats */
 struct airspy_format {
-       char    *name;
        u32     pixelformat;
        u32     buffersize;
 };
@@ -79,7 +78,6 @@ struct airspy_format {
 /* format descriptions for capture and preview */
 static struct airspy_format formats[] = {
        {
-               .name           = "Real U12LE",
                .pixelformat    = V4L2_SDR_FMT_RU12LE,
                .buffersize     = BULK_BUFFER_SIZE,
        },
@@ -622,7 +620,6 @@ static int airspy_enum_fmt_sdr_cap(struct file *file, void *priv,
        if (f->index >= NUM_FORMATS)
                return -EINVAL;
 
-       strscpy(f->description, formats[f->index].name, sizeof(f->description));
        f->pixelformat = formats[f->index].pixelformat;
 
        return 0;
index 5e00019bce8a6476f862ceeb8cf35b63837a69cd..d1895334cbbf7b6ea48093006dc7051adfbe6119 100644 (file)
@@ -1153,7 +1153,6 @@ static int au0828_set_format(struct au0828_dev *dev, unsigned int cmd,
        format->fmt.pix.sizeimage = width * height * 2;
        format->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
        format->fmt.pix.field = V4L2_FIELD_INTERLACED;
-       format->fmt.pix.priv = 0;
 
        if (cmd == VIDIOC_TRY_FMT)
                return 0;
@@ -1207,10 +1206,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
 
        dprintk(1, "%s called\n", __func__);
 
-       f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       strscpy(f->description, "Packed YUV2", sizeof(f->description));
-
-       f->flags = 0;
        f->pixelformat = V4L2_PIX_FMT_UYVY;
 
        return 0;
@@ -1231,7 +1226,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.sizeimage = dev->frame_size;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; /* NTSC/PAL */
        f->fmt.pix.field = V4L2_FIELD_INTERLACED;
-       f->fmt.pix.priv = 0;
        return 0;
 }
 
index 0feae825cebb4756c0ebd4815c4af54395a63d03..626264a56517f1966d13ee3af1479a0afa4d2436 100644 (file)
@@ -292,28 +292,13 @@ static int cpia2_s_input(struct file *file, void *fh, unsigned int i)
 static int cpia2_enum_fmt_vid_cap(struct file *file, void *fh,
                                            struct v4l2_fmtdesc *f)
 {
-       int index = f->index;
-
-       if (index < 0 || index > 1)
-              return -EINVAL;
+       if (f->index > 1)
+               return -EINVAL;
 
-       memset(f, 0, sizeof(*f));
-       f->index = index;
-       f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       f->flags = V4L2_FMT_FLAG_COMPRESSED;
-       switch(index) {
-       case 0:
-               strscpy(f->description, "MJPEG", sizeof(f->description));
+       if (f->index == 0)
                f->pixelformat = V4L2_PIX_FMT_MJPEG;
-               break;
-       case 1:
-               strscpy(f->description, "JPEG", sizeof(f->description));
+       else
                f->pixelformat = V4L2_PIX_FMT_JPEG;
-               break;
-       default:
-               return -EINVAL;
-       }
-
        return 0;
 }
 
@@ -338,7 +323,6 @@ static int cpia2_try_fmt_vid_cap(struct file *file, void *fh,
        f->fmt.pix.bytesperline = 0;
        f->fmt.pix.sizeimage = cam->frame_size;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG;
-       f->fmt.pix.priv = 0;
 
        switch (cpia2_match_video_size(f->fmt.pix.width, f->fmt.pix.height)) {
        case VIDEOSIZE_VGA:
@@ -449,7 +433,6 @@ static int cpia2_g_fmt_vid_cap(struct file *file, void *fh,
        f->fmt.pix.bytesperline = 0;
        f->fmt.pix.sizeimage = cam->frame_size;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
index 2475f69a2f1ce3b2f4fd451301cb2f1ac54e98b8..30624376679b20a85bdb9a8a2d635dd2e9238bf5 100644 (file)
@@ -1592,7 +1592,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
        if (f->index != 0)
                return -EINVAL;
 
-       strscpy(f->description, "MPEG", sizeof(f->description));
        f->pixelformat = V4L2_PIX_FMT_MPEG;
 
        return 0;
index b651ac7713ea88b2d5f8d0dd969499af50b3ba54..c77597917ca18e5488bf3a0171729cc5a4f94475 100644 (file)
@@ -80,7 +80,6 @@ MODULE_PARM_DESC(video_debug, "enable debug messages [video]");
 /* supported video standards */
 static struct cx231xx_fmt format[] = {
        {
-        .name = "16bpp YUY2, 4:2:2, packed",
         .fourcc = V4L2_PIX_FMT_YUYV,
         .depth = 16,
         .reg = 0,
@@ -1578,7 +1577,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
        if (unlikely(f->index >= ARRAY_SIZE(format)))
                return -EINVAL;
 
-       strscpy(f->description, format[f->index].name, sizeof(f->description));
        f->pixelformat = format[f->index].fourcc;
 
        return 0;
index 3efa8ff93c1cfaa9730fedf5cd2978eb4d99a7ef..b007611abc373b535b812688bd5646324e7bda81 100644 (file)
 #define CX23417_RESET    9
 
 struct cx23417_fmt {
-       char  *name;
        u32   fourcc;          /* v4l2 format id */
        int   depth;
        int   flags;
index 8610487f2d7272953b70e1a413a6f2cba7c60b67..bbfe1cfdc0134a0af12017a731e9b9ed8108d73a 100644 (file)
@@ -540,6 +540,8 @@ static int dvbsky_mygica_t230c_attach(struct dvb_usb_adapter *adap)
        si2168_config.i2c_adapter = &i2c_adapter;
        si2168_config.fe = &adap->fe[0];
        si2168_config.ts_mode = SI2168_TS_PARALLEL;
+       if (le16_to_cpu(d->udev->descriptor.idProduct) == USB_PID_MYGICA_T230C2)
+               si2168_config.ts_mode |= SI2168_TS_CLK_MANUAL;
        si2168_config.ts_clock_inv = 1;
 
        state->i2c_client_demod = dvb_module_probe("si2168", NULL,
@@ -779,6 +781,9 @@ static const struct usb_device_id dvbsky_id_table[] = {
        { DVB_USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230C,
                &mygica_t230c_props, "MyGica Mini DVB-T2 USB Stick T230C",
                RC_MAP_TOTAL_MEDIA_IN_HAND_02) },
+       { DVB_USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230C2,
+               &mygica_t230c_props, "MyGica Mini DVB-T2 USB Stick T230C v2",
+               RC_MAP_TOTAL_MEDIA_IN_HAND_02) },
        { }
 };
 MODULE_DEVICE_TABLE(usb, dvbsky_id_table);
index 66d685065e065ccb3901126c585fc4c0db371664..ab7a100ec84fee1fe4a6e8512b238c461cd29748 100644 (file)
@@ -2439,9 +2439,13 @@ static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
                8, 0x0486,
        };
 
+       if (!IS_ENABLED(CONFIG_DVB_DIB9000))
+               return -ENODEV;
        if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
                return -ENODEV;
        i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
+       if (!i2c)
+               return -ENODEV;
        if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
                return -ENODEV;
        dib0700_set_i2c_speed(adap->dev, 1500);
@@ -2517,10 +2521,14 @@ static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
                0, 0x00ef,
                8, 0x0406,
        };
+       if (!IS_ENABLED(CONFIG_DVB_DIB9000))
+               return -ENODEV;
        i2c = dib9000_get_tuner_interface(adap->fe_adap[0].fe);
        if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
                return -ENODEV;
        i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
+       if (!i2c)
+               return -ENODEV;
        if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
                return -ENODEV;
 
index d6b36e4f33d2e7d2f59d7418dd64e4315d2849cc..441d878fc22c11ec1a36ec77b1e0591924e0c1c8 100644 (file)
@@ -909,14 +909,6 @@ static int pctv452e_frontend_attach(struct dvb_usb_adapter *a)
                                                &a->dev->i2c_adap);
        if (!a->fe_adap[0].fe)
                return -ENODEV;
-
-       /*
-        * dvb_frontend will call dvb_detach for both stb0899_detach
-        * and stb0899_release but we only do dvb_attach(stb0899_attach).
-        * Increment the module refcount instead.
-        */
-       symbol_get(stb0899_attach);
-
        if ((dvb_attach(lnbp22_attach, a->fe_adap[0].fe,
                                        &a->dev->i2c_adap)) == NULL)
                err("Cannot attach lnbp22\n");
index c659e18b358b88db8b7ce31836bab9e784a4dfa4..676d233d46d535c610ff79affce5589a9f43870c 100644 (file)
@@ -608,10 +608,9 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)
 static int technisat_usb2_get_ir(struct dvb_usb_device *d)
 {
        struct technisat_usb2_state *state = d->priv;
-       u8 *buf = state->buf;
-       u8 *b;
-       int ret;
        struct ir_raw_event ev;
+       u8 *buf = state->buf;
+       int i, ret;
 
        buf[0] = GET_IR_DATA_VENDOR_REQUEST;
        buf[1] = 0x08;
@@ -647,26 +646,25 @@ static int technisat_usb2_get_ir(struct dvb_usb_device *d)
                return 0; /* no key pressed */
 
        /* decoding */
-       b = buf+1;
 
 #if 0
        deb_rc("RC: %d ", ret);
-       debug_dump(b, ret, deb_rc);
+       debug_dump(buf + 1, ret, deb_rc);
 #endif
 
        ev.pulse = 0;
-       while (1) {
-               ev.pulse = !ev.pulse;
-               ev.duration = (*b * FIRMWARE_CLOCK_DIVISOR * FIRMWARE_CLOCK_TICK) / 1000;
-               ir_raw_event_store(d->rc_dev, &ev);
-
-               b++;
-               if (*b == 0xff) {
+       for (i = 1; i < ARRAY_SIZE(state->buf); i++) {
+               if (buf[i] == 0xff) {
                        ev.pulse = 0;
                        ev.duration = 888888*2;
                        ir_raw_event_store(d->rc_dev, &ev);
                        break;
                }
+
+               ev.pulse = !ev.pulse;
+               ev.duration = (buf[i] * FIRMWARE_CLOCK_DIVISOR *
+                              FIRMWARE_CLOCK_TICK) / 1000;
+               ir_raw_event_store(d->rc_dev, &ev);
        }
 
        ir_raw_event_handle(d->rc_dev);
index 0512e19593945d04c2cc949a35ba6ca742e6ff87..fc6d37d76dc9282b0445d768332219df4b1dc7a4 100644 (file)
@@ -102,37 +102,30 @@ MODULE_PARM_DESC(video_debug, "enable debug messages [video]");
 /* supported video standards */
 static struct em28xx_fmt format[] = {
        {
-               .name     = "16 bpp YUY2, 4:2:2, packed",
                .fourcc   = V4L2_PIX_FMT_YUYV,
                .depth    = 16,
                .reg      = EM28XX_OUTFMT_YUV422_Y0UY1V,
        }, {
-               .name     = "16 bpp RGB 565, LE",
                .fourcc   = V4L2_PIX_FMT_RGB565,
                .depth    = 16,
                .reg      = EM28XX_OUTFMT_RGB_16_656,
        }, {
-               .name     = "8 bpp Bayer RGRG..GBGB",
                .fourcc   = V4L2_PIX_FMT_SRGGB8,
                .depth    = 8,
                .reg      = EM28XX_OUTFMT_RGB_8_RGRG,
        }, {
-               .name     = "8 bpp Bayer BGBG..GRGR",
                .fourcc   = V4L2_PIX_FMT_SBGGR8,
                .depth    = 8,
                .reg      = EM28XX_OUTFMT_RGB_8_BGBG,
        }, {
-               .name     = "8 bpp Bayer GRGR..BGBG",
                .fourcc   = V4L2_PIX_FMT_SGRBG8,
                .depth    = 8,
                .reg      = EM28XX_OUTFMT_RGB_8_GRGR,
        }, {
-               .name     = "8 bpp Bayer GBGB..RGRG",
                .fourcc   = V4L2_PIX_FMT_SGBRG8,
                .depth    = 8,
                .reg      = EM28XX_OUTFMT_RGB_8_GBGB,
        }, {
-               .name     = "12 bpp YUV411",
                .fourcc   = V4L2_PIX_FMT_YUV411P,
                .depth    = 12,
                .reg      = EM28XX_OUTFMT_YUV411,
@@ -1517,7 +1510,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
        else
                f->fmt.pix.field = v4l2->interlaced_fieldmode ?
                           V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
@@ -2011,7 +2003,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
        if (unlikely(f->index >= ARRAY_SIZE(format)))
                return -EINVAL;
 
-       strscpy(f->description, format[f->index].name, sizeof(f->description));
        f->pixelformat = format[f->index].fourcc;
 
        return 0;
index a551072e62ed1fb9a03293b389b8d4c6e27d9b30..c69e0bc46eb7d58be6d61caf21175e470cd35ab7 100644 (file)
@@ -251,13 +251,11 @@ struct em28xx_usb_ctl {
 /**
  * struct em28xx_fmt - Struct to enumberate video formats
  *
- * @name:      Name for the video standard
  * @fourcc:    v4l2 format id
  * @depth:     mean number of bits to represent a pixel
  * @reg:       em28xx register value to set it
  */
 struct em28xx_fmt {
-       char    *name;
        u32     fourcc;
        int     depth;
        int     reg;
index 88edfef80b40933df509fcfdee6ccbf4ee676ba2..0b3d185f3cb0aebe1d4643f5fe72ce9084dc435b 100644 (file)
@@ -285,33 +285,22 @@ static int vidioc_querycap(struct file *file, void  *priv,
 static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
                                        struct v4l2_fmtdesc *fmt)
 {
-       char *desc = NULL;
-
        switch (fmt->index) {
        case 0:
                fmt->pixelformat = V4L2_PIX_FMT_MJPEG;
-               desc = "Motion JPEG";
                break;
        case 1:
                fmt->pixelformat = V4L2_PIX_FMT_MPEG1;
-               desc = "MPEG-1 ES";
                break;
        case 2:
                fmt->pixelformat = V4L2_PIX_FMT_MPEG2;
-               desc = "MPEG-2 ES";
                break;
        case 3:
                fmt->pixelformat = V4L2_PIX_FMT_MPEG4;
-               desc = "MPEG-4 ES";
                break;
        default:
                return -EINVAL;
        }
-       fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       fmt->flags = V4L2_FMT_FLAG_COMPRESSED;
-
-       strscpy(fmt->description, desc, sizeof(fmt->description));
-
        return 0;
 }
 
index 4a449c62fc32ce4657cd7babce7e7025c6832793..b05fa227ffb21de236a8c6b8edf00f82815498f9 100644 (file)
@@ -253,7 +253,7 @@ int go7007_snd_init(struct go7007 *go)
                return ret;
        }
        strscpy(gosnd->card->driver, "go7007", sizeof(gosnd->card->driver));
-       strscpy(gosnd->card->shortname, go->name, sizeof(gosnd->card->driver));
+       strscpy(gosnd->card->shortname, go->name, sizeof(gosnd->card->shortname));
        strscpy(gosnd->card->longname, gosnd->card->shortname,
                sizeof(gosnd->card->longname));
 
index be11f7830bca25dcf8dc2ee979c8e3e42d09531b..4add2b12d33023d3f340ebc12204d205e3e7e010 100644 (file)
@@ -1024,27 +1024,18 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
                return -EINVAL;         /* no more format */
 
        fmtdesc->pixelformat = fmt_tb[index];
-       if (gspca_dev->cam.cam_mode[i].sizeimage <
-                       gspca_dev->cam.cam_mode[i].width *
-                               gspca_dev->cam.cam_mode[i].height)
-               fmtdesc->flags = V4L2_FMT_FLAG_COMPRESSED;
-       fmtdesc->description[0] = fmtdesc->pixelformat & 0xff;
-       fmtdesc->description[1] = (fmtdesc->pixelformat >> 8) & 0xff;
-       fmtdesc->description[2] = (fmtdesc->pixelformat >> 16) & 0xff;
-       fmtdesc->description[3] = fmtdesc->pixelformat >> 24;
-       fmtdesc->description[4] = '\0';
        return 0;
 }
 
-static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
-                           struct v4l2_format *fmt)
+static int vidioc_g_fmt_vid_cap(struct file *file, void *_priv,
+                               struct v4l2_format *fmt)
 {
        struct gspca_dev *gspca_dev = video_drvdata(file);
+       u32 priv = fmt->fmt.pix.priv;
 
        fmt->fmt.pix = gspca_dev->pixfmt;
-       /* some drivers use priv internally, zero it before giving it back to
-          the core */
-       fmt->fmt.pix.priv = 0;
+       /* some drivers use priv internally, so keep the original value */
+       fmt->fmt.pix.priv = priv;
        return 0;
 }
 
@@ -1079,27 +1070,27 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
                fmt->fmt.pix.height = h;
                gspca_dev->sd_desc->try_fmt(gspca_dev, fmt);
        }
-       /* some drivers use priv internally, zero it before giving it back to
-          the core */
-       fmt->fmt.pix.priv = 0;
        return mode;                    /* used when s_fmt */
 }
 
-static int vidioc_try_fmt_vid_cap(struct file *file,
-                             void *priv,
-                             struct v4l2_format *fmt)
+static int vidioc_try_fmt_vid_cap(struct file *file, void *_priv,
+                                 struct v4l2_format *fmt)
 {
        struct gspca_dev *gspca_dev = video_drvdata(file);
+       u32 priv = fmt->fmt.pix.priv;
 
        if (try_fmt_vid_cap(gspca_dev, fmt) < 0)
                return -EINVAL;
+       /* some drivers use priv internally, so keep the original value */
+       fmt->fmt.pix.priv = priv;
        return 0;
 }
 
-static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
-                           struct v4l2_format *fmt)
+static int vidioc_s_fmt_vid_cap(struct file *file, void *_priv,
+                               struct v4l2_format *fmt)
 {
        struct gspca_dev *gspca_dev = video_drvdata(file);
+       u32 priv = fmt->fmt.pix.priv;
        int mode;
 
        if (vb2_is_busy(&gspca_dev->queue))
@@ -1115,6 +1106,8 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
                gspca_dev->pixfmt = fmt->fmt.pix;
        else
                gspca_dev->pixfmt = gspca_dev->cam.cam_mode[mode];
+       /* some drivers use priv internally, so keep the original value */
+       fmt->fmt.pix.priv = priv;
        return 0;
 }
 
index 9b9d894d29bcbce562df83cf1f7f7fda0cefb7ef..a0905c81d2cb294b794efe56ad2b35788690ec1c 100644 (file)
@@ -271,6 +271,7 @@ static int hdpvr_probe(struct usb_interface *interface,
 #endif
        size_t buffer_size;
        int i;
+       int dev_num;
        int retval = -ENOMEM;
 
        /* allocate memory for our device state and initialize it */
@@ -368,8 +369,17 @@ static int hdpvr_probe(struct usb_interface *interface,
        }
 #endif
 
+       dev_num = atomic_inc_return(&dev_nr);
+       if (dev_num >= HDPVR_MAX) {
+               v4l2_err(&dev->v4l2_dev,
+                        "max device number reached, device register failed\n");
+               atomic_dec(&dev_nr);
+               retval = -ENODEV;
+               goto reg_fail;
+       }
+
        retval = hdpvr_register_videodev(dev, &interface->dev,
-                                   video_nr[atomic_inc_return(&dev_nr)]);
+                                   video_nr[dev_num]);
        if (retval < 0) {
                v4l2_err(&dev->v4l2_dev, "registering videodev failed\n");
                goto reg_fail;
index 5b3e67b80627cecb39e3b5b313e45de24c5b4799..bad71d863d395c8582004fd8480507f2fc44ed31 100644 (file)
@@ -987,9 +987,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *private_data,
        if (f->index != 0)
                return -EINVAL;
 
-       f->flags = V4L2_FMT_FLAG_COMPRESSED;
-       strscpy(f->description, "MPEG2-TS with AVC/AAC streams",
-               sizeof(f->description));
        f->pixelformat = V4L2_PIX_FMT_MPEG;
 
        return 0;
index 4c9b2a12acfb5dc2aa26090d41728f7245f2540b..65be6f140fe83622c6dbb62c2195b398092c2cc3 100644 (file)
@@ -66,7 +66,6 @@ static const struct v4l2_frequency_band bands[] = {
 
 /* stream formats */
 struct msi2500_format {
-       char    *name;
        u32     pixelformat;
        u32     buffersize;
 };
@@ -74,27 +73,21 @@ struct msi2500_format {
 /* format descriptions for capture and preview */
 static struct msi2500_format formats[] = {
        {
-               .name           = "Complex S8",
                .pixelformat    = V4L2_SDR_FMT_CS8,
                .buffersize     = 3 * 1008,
 #if 0
        }, {
-               .name           = "10+2-bit signed",
                .pixelformat    = MSI2500_PIX_FMT_SDR_MSI2500_384,
        }, {
-               .name           = "12-bit signed",
                .pixelformat    = MSI2500_PIX_FMT_SDR_S12,
 #endif
        }, {
-               .name           = "Complex S14LE",
                .pixelformat    = V4L2_SDR_FMT_CS14LE,
                .buffersize     = 3 * 1008,
        }, {
-               .name           = "Complex U8 (emulated)",
                .pixelformat    = V4L2_SDR_FMT_CU8,
                .buffersize     = 3 * 1008,
        }, {
-               .name           = "Complex U16LE (emulated)",
                .pixelformat    =  V4L2_SDR_FMT_CU16LE,
                .buffersize     = 3 * 1008,
        },
@@ -904,7 +897,6 @@ static int msi2500_enum_fmt_sdr_cap(struct file *file, void *priv,
        if (f->index >= dev->num_formats)
                return -EINVAL;
 
-       strscpy(f->description, formats[f->index].name, sizeof(f->description));
        f->pixelformat = formats[f->index].pixelformat;
 
        return 0;
index 76c498cccc496f3bd740d30f0bd2295ac1b162e0..2f135d533af6f666aefdc295262838d6c034b4b9 100644 (file)
@@ -873,14 +873,9 @@ static int pwc_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc
        case 0:
                /* RAW format */
                f->pixelformat = pdev->type <= 646 ? V4L2_PIX_FMT_PWC1 : V4L2_PIX_FMT_PWC2;
-               f->flags = V4L2_FMT_FLAG_COMPRESSED;
-               strscpy(f->description, "Raw Philips Webcam",
-                       sizeof(f->description));
                break;
        case 1:
                f->pixelformat = V4L2_PIX_FMT_YUV420;
-               strscpy(f->description, "4:2:0, planar, Y-Cb-Cr",
-                       sizeof(f->description));
                break;
        default:
                return -EINVAL;
index aa90558479f7e17306690636823056158a12dd85..329ec808959276dc0e224ae3cb044173cdb4437b 100644 (file)
@@ -273,7 +273,6 @@ static inline struct s2255_dev *to_s2255_dev(struct v4l2_device *v4l2_dev)
 }
 
 struct s2255_fmt {
-       char *name;
        u32 fourcc;
        int depth;
 };
@@ -385,29 +384,23 @@ MODULE_DEVICE_TABLE(usb, s2255_table);
 /* JPEG formats must be defined last to support jpeg_enable parameter */
 static const struct s2255_fmt formats[] = {
        {
-               .name = "4:2:2, packed, YUYV",
                .fourcc = V4L2_PIX_FMT_YUYV,
                .depth = 16
 
        }, {
-               .name = "4:2:2, packed, UYVY",
                .fourcc = V4L2_PIX_FMT_UYVY,
                .depth = 16
        }, {
-               .name = "4:2:2, planar, YUV422P",
                .fourcc = V4L2_PIX_FMT_YUV422P,
                .depth = 16
 
        }, {
-               .name = "8bpp GREY",
                .fourcc = V4L2_PIX_FMT_GREY,
                .depth = 8
        }, {
-               .name = "JPG",
                .fourcc = V4L2_PIX_FMT_JPEG,
                .depth = 24
        }, {
-               .name = "MJPG",
                .fourcc = V4L2_PIX_FMT_MJPEG,
                .depth = 24
        }
@@ -737,7 +730,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
        if (!jpeg_enable && ((formats[index].fourcc == V4L2_PIX_FMT_JPEG) ||
                        (formats[index].fourcc == V4L2_PIX_FMT_MJPEG)))
                return -EINVAL;
-       strscpy(f->description, formats[index].name, sizeof(f->description));
        f->pixelformat = formats[index].fourcc;
        return 0;
 }
@@ -759,7 +751,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.bytesperline = f->fmt.pix.width * (vc->fmt->depth >> 3);
        f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
-       f->fmt.pix.priv = 0;
        return 0;
 }
 
@@ -811,7 +802,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3;
        f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
-       f->fmt.pix.priv = 0;
        dprintk(vc->dev, 50, "%s: set width %d height %d field %d\n", __func__,
                f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field);
        return 0;
index b71a0f4b40b5a4cdc5eb00c4d57a407f78201b78..bcd14c66e8dfa5d51a2616127f5826dc8a543ee4 100644 (file)
@@ -46,7 +46,6 @@ struct stk1160_decimate_ctrl {
 /* supported video standards */
 static struct stk1160_fmt format[] = {
        {
-               .name     = "16 bpp YUY2, 4:2:2, packed",
                .fourcc   = V4L2_PIX_FMT_UYVY,
                .depth    = 16,
        }
@@ -346,7 +345,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
        if (f->index != 0)
                return -EINVAL;
 
-       strscpy(f->description, format[f->index].name, sizeof(f->description));
        f->pixelformat = format[f->index].fourcc;
        return 0;
 }
index 099ce2a2f021ec8a8a233cdc7b64db29c0c208f7..a31ea1c80f25569a9312e228601c3ac58665bd36 100644 (file)
@@ -102,7 +102,6 @@ struct stk1160_isoc_ctl {
 };
 
 struct stk1160_fmt {
-       char  *name;
        u32   fourcc;          /* v4l2 format id */
        int   depth;
 };
index be8041e3e6b86a2cff46e9bf8711ee43130c6448..cfca3c70599ba34fffa567c78a866c6116655781 100644 (file)
@@ -857,23 +857,18 @@ static int stk_vidioc_enum_fmt_vid_cap(struct file *filp,
        switch (fmtd->index) {
        case 0:
                fmtd->pixelformat = V4L2_PIX_FMT_RGB565;
-               strscpy(fmtd->description, "r5g6b5", sizeof(fmtd->description));
                break;
        case 1:
                fmtd->pixelformat = V4L2_PIX_FMT_RGB565X;
-               strscpy(fmtd->description, "r5g6b5BE", sizeof(fmtd->description));
                break;
        case 2:
                fmtd->pixelformat = V4L2_PIX_FMT_UYVY;
-               strscpy(fmtd->description, "yuv4:2:2", sizeof(fmtd->description));
                break;
        case 3:
                fmtd->pixelformat = V4L2_PIX_FMT_SBGGR8;
-               strscpy(fmtd->description, "Raw bayer", sizeof(fmtd->description));
                break;
        case 4:
                fmtd->pixelformat = V4L2_PIX_FMT_YUYV;
-               strscpy(fmtd->description, "yuv4:2:2", sizeof(fmtd->description));
                break;
        default:
                return -EINVAL;
index 85fcddfb02023efbf1f0298cd66615fb7fcb763a..c07a81a6cbe29d846c4e41768a51ef8c3f102f84 100644 (file)
@@ -52,15 +52,12 @@ EXPORT_SYMBOL_GPL(tm6000_debug);
 
 static struct tm6000_fmt format[] = {
        {
-               .name     = "4:2:2, packed, YVY2",
                .fourcc   = V4L2_PIX_FMT_YUYV,
                .depth    = 16,
        }, {
-               .name     = "4:2:2, packed, UYVY",
                .fourcc   = V4L2_PIX_FMT_UYVY,
                .depth    = 16,
        }, {
-               .name     = "A/V + VBI mux packet",
                .fourcc   = V4L2_PIX_FMT_TM6000,
                .depth    = 16,
        }
@@ -875,7 +872,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
        if (f->index >= ARRAY_SIZE(format))
                return -EINVAL;
 
-       strscpy(f->description, format[f->index].name, sizeof(f->description));
        f->pixelformat = format[f->index].fourcc;
        return 0;
 }
index 0864ed7314eb24c506d7ff586db731e5d4ab5b09..bf396544da9a8233964296771c4c8b1531bdeb94 100644 (file)
@@ -64,7 +64,6 @@ struct tm6000_input {
  */
 
 struct tm6000_fmt {
-       char  *name;
        u32   fourcc;          /* v4l2 format id */
        int   depth;
 };
index 51f784479e91a07bbdf3aba4fb945f1194e26c6f..3d9284a09ee59dd461339bc30a1f9e36aa19c5bb 100644 (file)
@@ -633,8 +633,6 @@ static int usbtv_enum_fmt_vid_cap(struct file *file, void  *priv,
        if (f->index > 0)
                return -EINVAL;
 
-       strscpy(f->description, "16 bpp YUY2, 4:2:2, packed",
-               sizeof(f->description));
        f->pixelformat = V4L2_PIX_FMT_YUYV;
        return 0;
 }
index 93750af82d98a01166d175961dd4bbecbfe5569e..0874526f599e629f1e240dbc1019f6d128c9b291 100644 (file)
 static int usbvision_nr;
 
 static struct usbvision_v4l2_format_st usbvision_v4l2_format[] = {
-       { 1, 1,  8, V4L2_PIX_FMT_GREY    , "GREY" },
-       { 1, 2, 16, V4L2_PIX_FMT_RGB565  , "RGB565" },
-       { 1, 3, 24, V4L2_PIX_FMT_RGB24   , "RGB24" },
-       { 1, 4, 32, V4L2_PIX_FMT_RGB32   , "RGB32" },
-       { 1, 2, 16, V4L2_PIX_FMT_RGB555  , "RGB555" },
-       { 1, 2, 16, V4L2_PIX_FMT_YUYV    , "YUV422" },
-       { 1, 2, 12, V4L2_PIX_FMT_YVU420  , "YUV420P" }, /* 1.5 ! */
-       { 1, 2, 16, V4L2_PIX_FMT_YUV422P , "YUV422P" }
+       { 1, 1,  8, V4L2_PIX_FMT_GREY },
+       { 1, 2, 16, V4L2_PIX_FMT_RGB565 },
+       { 1, 3, 24, V4L2_PIX_FMT_RGB24 },
+       { 1, 4, 32, V4L2_PIX_FMT_RGB32 },
+       { 1, 2, 16, V4L2_PIX_FMT_RGB555 },
+       { 1, 2, 16, V4L2_PIX_FMT_YUYV },
+       { 1, 2, 12, V4L2_PIX_FMT_YVU420 }, /* 1.5 ! */
+       { 1, 2, 16, V4L2_PIX_FMT_YUV422P }
 };
 
 /* Function prototypes */
@@ -796,8 +796,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void  *priv,
 {
        if (vfd->index >= USBVISION_SUPPORTED_PALETTES - 1)
                return -EINVAL;
-       strscpy(vfd->description, usbvision_v4l2_format[vfd->index].desc,
-               sizeof(vfd->description));
        vfd->pixelformat = usbvision_v4l2_format[vfd->index].format;
        return 0;
 }
index 4198f972a47b654e869c6bb378a934f1ec111f69..11539578e8d237e1f5ab0c45e96d51ec2fd1b00a 100644 (file)
@@ -264,7 +264,6 @@ struct usbvision_v4l2_format_st {
        int             bytes_per_pixel;
        int             depth;
        int             format;
-       char            *desc;
 };
 #define USBVISION_SUPPORTED_PALETTES ARRAY_SIZE(usbvision_v4l2_format)
 
index 203329cadbc4df4b44158d712af50be76dc7a192..0335e69b70abe7100b3fe8afb393b1a091fa7aef 100644 (file)
@@ -253,7 +253,6 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream,
        fmt->fmt.pix.bytesperline = uvc_v4l2_get_bytesperline(format, frame);
        fmt->fmt.pix.sizeimage = probe->dwMaxVideoFrameSize;
        fmt->fmt.pix.colorspace = format->colorspace;
-       fmt->fmt.pix.priv = 0;
 
        if (uvc_format != NULL)
                *uvc_format = format;
@@ -290,7 +289,6 @@ static int uvc_v4l2_get_format(struct uvc_streaming *stream,
        fmt->fmt.pix.bytesperline = uvc_v4l2_get_bytesperline(format, frame);
        fmt->fmt.pix.sizeimage = stream->ctrl.dwMaxVideoFrameSize;
        fmt->fmt.pix.colorspace = format->colorspace;
-       fmt->fmt.pix.priv = 0;
 
 done:
        mutex_unlock(&stream->mutex);
index a9bcba4fa9c6a999da9fdb345465cc29560a9dc8..b8e89d550d2951334174501b7a14b694f4100132 100644 (file)
@@ -141,7 +141,6 @@ struct zr364xx_pipeinfo {
 };
 
 struct zr364xx_fmt {
-       char *name;
        u32 fourcc;
        int depth;
 };
@@ -149,7 +148,6 @@ struct zr364xx_fmt {
 /* image formats.  */
 static const struct zr364xx_fmt formats[] = {
        {
-               .name = "JPG",
                .fourcc = V4L2_PIX_FMT_JPEG,
                .depth = 24
        }
@@ -376,8 +374,7 @@ static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
                                                  vb);
        int rc;
 
-       DBG("%s, field=%d, fmt name = %s\n", __func__, field,
-           cam->fmt ? cam->fmt->name : "");
+       DBG("%s, field=%d\n", __func__, field);
        if (!cam->fmt)
                return -EINVAL;
 
@@ -751,8 +748,6 @@ static int zr364xx_vidioc_enum_fmt_vid_cap(struct file *file,
 {
        if (f->index > 0)
                return -EINVAL;
-       f->flags = V4L2_FMT_FLAG_COMPRESSED;
-       strscpy(f->description, formats[0].name, sizeof(f->description));
        f->pixelformat = formats[0].fourcc;
        return 0;
 }
index 9ee57e1efefed177d04c0f5857dfa39812ae2d01..4d42418e603e97881d05c52186fda966623e7842 100644 (file)
@@ -8,15 +8,11 @@ tuner-objs    :=      tuner-core.o
 videodev-objs  :=      v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \
                        v4l2-event.o v4l2-ctrls.o v4l2-subdev.o v4l2-clk.o \
                        v4l2-async.o
-ifeq ($(CONFIG_COMPAT),y)
-  videodev-objs += v4l2-compat-ioctl32.o
-endif
-obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o
-ifeq ($(CONFIG_TRACEPOINTS),y)
-  videodev-objs += v4l2-trace.o
-endif
+videodev-$(CONFIG_COMPAT) += v4l2-compat-ioctl32.o
+videodev-$(CONFIG_TRACEPOINTS) += v4l2-trace.o
 videodev-$(CONFIG_MEDIA_CONTROLLER) += v4l2-mc.o
 
+obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o
 obj-$(CONFIG_VIDEO_V4L2) += videodev.o
 obj-$(CONFIG_VIDEO_V4L2) += v4l2-common.o
 obj-$(CONFIG_VIDEO_V4L2) += v4l2-dv-timings.o
index 8d307b538f52539833607d1218ef0cab5f3ac033..8bde33c21ce45f98ada68059362f97a98755ffab 100644 (file)
@@ -534,7 +534,7 @@ static void __v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)
 {
        struct v4l2_async_subdev *asd, *tmp;
 
-       if (!notifier)
+       if (!notifier || !notifier->asd_list.next)
                return;
 
        list_for_each_entry_safe(asd, tmp, &notifier->asd_list, asd_list) {
@@ -593,10 +593,11 @@ v4l2_async_notifier_add_fwnode_subdev(struct v4l2_async_notifier *notifier,
                return ERR_PTR(-ENOMEM);
 
        asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
-       asd->match.fwnode = fwnode;
+       asd->match.fwnode = fwnode_handle_get(fwnode);
 
        ret = v4l2_async_notifier_add_subdev(notifier, asd);
        if (ret) {
+               fwnode_handle_put(fwnode);
                kfree(asd);
                return ERR_PTR(ret);
        }
@@ -605,6 +606,29 @@ v4l2_async_notifier_add_fwnode_subdev(struct v4l2_async_notifier *notifier,
 }
 EXPORT_SYMBOL_GPL(v4l2_async_notifier_add_fwnode_subdev);
 
+int
+v4l2_async_notifier_add_fwnode_remote_subdev(struct v4l2_async_notifier *notif,
+                                            struct fwnode_handle *endpoint,
+                                            struct v4l2_async_subdev *asd)
+{
+       struct fwnode_handle *remote;
+       int ret;
+
+       remote = fwnode_graph_get_remote_port_parent(endpoint);
+       if (!remote)
+               return -ENOTCONN;
+
+       asd->match_type = V4L2_ASYNC_MATCH_FWNODE;
+       asd->match.fwnode = remote;
+
+       ret = v4l2_async_notifier_add_subdev(notif, asd);
+       if (ret)
+               fwnode_handle_put(remote);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(v4l2_async_notifier_add_fwnode_remote_subdev);
+
 struct v4l2_async_subdev *
 v4l2_async_notifier_add_i2c_subdev(struct v4l2_async_notifier *notifier,
                                   int adapter_id, unsigned short address,
index f8ad1c580a3e327c6f2defeb78c0b00aef660df9..ab4a792a3bc1642c5580b9f16281641d346b5082 100644 (file)
@@ -455,11 +455,15 @@ const struct v4l2_format_info *v4l2_format_info(u32 format)
                { .format = V4L2_PIX_FMT_HSV24,   .mem_planes = 1, .comp_planes = 1, .bpp = { 3, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 },
                { .format = V4L2_PIX_FMT_BGR32,   .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 },
                { .format = V4L2_PIX_FMT_XBGR32,  .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 },
+               { .format = V4L2_PIX_FMT_BGRX32,  .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 },
                { .format = V4L2_PIX_FMT_RGB32,   .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 },
                { .format = V4L2_PIX_FMT_XRGB32,  .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 },
+               { .format = V4L2_PIX_FMT_RGBX32,  .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 },
                { .format = V4L2_PIX_FMT_HSV32,   .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 },
                { .format = V4L2_PIX_FMT_ARGB32,  .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 },
+               { .format = V4L2_PIX_FMT_RGBA32,  .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 },
                { .format = V4L2_PIX_FMT_ABGR32,  .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 },
+               { .format = V4L2_PIX_FMT_BGRA32,  .mem_planes = 1, .comp_planes = 1, .bpp = { 4, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 },
                { .format = V4L2_PIX_FMT_GREY,    .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, 0 }, .hdiv = 1, .vdiv = 1 },
 
                /* YUV packed formats */
index 371537dd8cd345cb075814b427aa77cdc959dca5..cd1ae016706f6f8f3a35e96272851180da27cae3 100644 (file)
@@ -6,6 +6,8 @@
 
  */
 
+#define pr_fmt(fmt) "v4l2-ctrls: " fmt
+
 #include <linux/ctype.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <media/v4l2-event.h>
 #include <media/v4l2-dev.h>
 
+#define dprintk(vdev, fmt, arg...) do {                                        \
+       if (!WARN_ON(!(vdev)) && ((vdev)->dev_debug & V4L2_DEV_DEBUG_CTRL)) \
+               printk(KERN_DEBUG pr_fmt("%s: %s: " fmt),               \
+                      __func__, video_device_node_name(vdev), ##arg);  \
+} while (0)
+
 #define has_op(master, op) \
        (master->ops && master->ops->op)
 #define call_op(master, op) \
@@ -885,6 +893,7 @@ const char *v4l2_ctrl_get_name(u32 id)
        case V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP:                return "VPX P-Frame QP Value";
        case V4L2_CID_MPEG_VIDEO_VP8_PROFILE:                   return "VP8 Profile";
        case V4L2_CID_MPEG_VIDEO_VP9_PROFILE:                   return "VP9 Profile";
+       case V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER:              return "VP8 Frame Header";
 
        /* HEVC controls */
        case V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP:               return "HEVC I-Frame QP Value";
@@ -1345,6 +1354,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
        case V4L2_CID_MPEG_VIDEO_H264_DECODE_PARAMS:
                *type = V4L2_CTRL_TYPE_H264_DECODE_PARAMS;
                break;
+       case V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER:
+               *type = V4L2_CTRL_TYPE_VP8_FRAME_HEADER;
+               break;
        default:
                *type = V4L2_CTRL_TYPE_INTEGER;
                break;
@@ -1629,10 +1641,105 @@ static void std_log(const struct v4l2_ctrl *ctrl)
 })
 
 /* Validate a new control */
+
+#define zero_padding(s) \
+       memset(&(s).padding, 0, sizeof((s).padding))
+
+/*
+ * Compound controls validation requires setting unused fields/flags to zero
+ * in order to properly detect unchanged controls with std_equal's memcmp.
+ */
+static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
+                                union v4l2_ctrl_ptr ptr)
+{
+       struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params;
+       struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header;
+       void *p = ptr.p + idx * ctrl->elem_size;
+
+       switch ((u32)ctrl->type) {
+       case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS:
+               p_mpeg2_slice_params = p;
+
+               switch (p_mpeg2_slice_params->sequence.chroma_format) {
+               case 1: /* 4:2:0 */
+               case 2: /* 4:2:2 */
+               case 3: /* 4:4:4 */
+                       break;
+               default:
+                       return -EINVAL;
+               }
+
+               switch (p_mpeg2_slice_params->picture.intra_dc_precision) {
+               case 0: /* 8 bits */
+               case 1: /* 9 bits */
+               case 2: /* 10 bits */
+               case 3: /* 11 bits */
+                       break;
+               default:
+                       return -EINVAL;
+               }
+
+               switch (p_mpeg2_slice_params->picture.picture_structure) {
+               case 1: /* interlaced top field */
+               case 2: /* interlaced bottom field */
+               case 3: /* progressive */
+                       break;
+               default:
+                       return -EINVAL;
+               }
+
+               switch (p_mpeg2_slice_params->picture.picture_coding_type) {
+               case V4L2_MPEG2_PICTURE_CODING_TYPE_I:
+               case V4L2_MPEG2_PICTURE_CODING_TYPE_P:
+               case V4L2_MPEG2_PICTURE_CODING_TYPE_B:
+                       break;
+               default:
+                       return -EINVAL;
+               }
+
+               break;
+
+       case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION:
+               break;
+
+       case V4L2_CTRL_TYPE_FWHT_PARAMS:
+               break;
+
+       case V4L2_CTRL_TYPE_H264_SPS:
+       case V4L2_CTRL_TYPE_H264_PPS:
+       case V4L2_CTRL_TYPE_H264_SCALING_MATRIX:
+       case V4L2_CTRL_TYPE_H264_SLICE_PARAMS:
+       case V4L2_CTRL_TYPE_H264_DECODE_PARAMS:
+               break;
+
+       case V4L2_CTRL_TYPE_VP8_FRAME_HEADER:
+               p_vp8_frame_header = p;
+
+               switch (p_vp8_frame_header->num_dct_parts) {
+               case 1:
+               case 2:
+               case 4:
+               case 8:
+                       break;
+               default:
+                       return -EINVAL;
+               }
+               zero_padding(p_vp8_frame_header->segment_header);
+               zero_padding(p_vp8_frame_header->lf_header);
+               zero_padding(p_vp8_frame_header->quant_header);
+               zero_padding(p_vp8_frame_header->entropy_header);
+               zero_padding(p_vp8_frame_header->coder_state);
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,
                        union v4l2_ctrl_ptr ptr)
 {
-       struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params;
        size_t len;
        u64 offset;
        s64 val;
@@ -1695,63 +1802,8 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx,
                        return -ERANGE;
                return 0;
 
-       case V4L2_CTRL_TYPE_MPEG2_SLICE_PARAMS:
-               p_mpeg2_slice_params = ptr.p;
-
-               switch (p_mpeg2_slice_params->sequence.chroma_format) {
-               case 1: /* 4:2:0 */
-               case 2: /* 4:2:2 */
-               case 3: /* 4:4:4 */
-                       break;
-               default:
-                       return -EINVAL;
-               }
-
-               switch (p_mpeg2_slice_params->picture.intra_dc_precision) {
-               case 0: /* 8 bits */
-               case 1: /* 9 bits */
-               case 2: /* 10 bits */
-               case 3: /* 11 bits */
-                       break;
-               default:
-                       return -EINVAL;
-               }
-
-               switch (p_mpeg2_slice_params->picture.picture_structure) {
-               case 1: /* interlaced top field */
-               case 2: /* interlaced bottom field */
-               case 3: /* progressive */
-                       break;
-               default:
-                       return -EINVAL;
-               }
-
-               switch (p_mpeg2_slice_params->picture.picture_coding_type) {
-               case V4L2_MPEG2_PICTURE_CODING_TYPE_I:
-               case V4L2_MPEG2_PICTURE_CODING_TYPE_P:
-               case V4L2_MPEG2_PICTURE_CODING_TYPE_B:
-                       break;
-               default:
-                       return -EINVAL;
-               }
-
-               return 0;
-
-       case V4L2_CTRL_TYPE_MPEG2_QUANTIZATION:
-               return 0;
-
-       case V4L2_CTRL_TYPE_FWHT_PARAMS:
-               return 0;
-
-       case V4L2_CTRL_TYPE_H264_SPS:
-       case V4L2_CTRL_TYPE_H264_PPS:
-       case V4L2_CTRL_TYPE_H264_SCALING_MATRIX:
-       case V4L2_CTRL_TYPE_H264_SLICE_PARAMS:
-       case V4L2_CTRL_TYPE_H264_DECODE_PARAMS:
-               return 0;
-
        default:
-               return -EINVAL;
+               return std_validate_compound(ctrl, idx, ptr);
        }
 }
 
@@ -2348,6 +2400,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
        case V4L2_CTRL_TYPE_H264_DECODE_PARAMS:
                elem_size = sizeof(struct v4l2_ctrl_h264_decode_params);
                break;
+       case V4L2_CTRL_TYPE_VP8_FRAME_HEADER:
+               elem_size = sizeof(struct v4l2_ctrl_vp8_frame_header);
+               break;
        default:
                if (type < V4L2_CTRL_COMPOUND_TYPES)
                        elem_size = sizeof(s32);
@@ -3217,6 +3272,7 @@ static int v4l2_ctrl_request_bind(struct media_request *req,
 static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl,
                             struct v4l2_ext_controls *cs,
                             struct v4l2_ctrl_helper *helpers,
+                            struct video_device *vdev,
                             bool get)
 {
        struct v4l2_ctrl_helper *h;
@@ -3234,20 +3290,31 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl,
                if (cs->which &&
                    cs->which != V4L2_CTRL_WHICH_DEF_VAL &&
                    cs->which != V4L2_CTRL_WHICH_REQUEST_VAL &&
-                   V4L2_CTRL_ID2WHICH(id) != cs->which)
+                   V4L2_CTRL_ID2WHICH(id) != cs->which) {
+                       dprintk(vdev,
+                               "invalid which 0x%x or control id 0x%x\n",
+                               cs->which, id);
                        return -EINVAL;
+               }
 
                /* Old-style private controls are not allowed for
                   extended controls */
-               if (id >= V4L2_CID_PRIVATE_BASE)
+               if (id >= V4L2_CID_PRIVATE_BASE) {
+                       dprintk(vdev,
+                               "old-style private controls not allowed\n");
                        return -EINVAL;
+               }
                ref = find_ref_lock(hdl, id);
-               if (ref == NULL)
+               if (ref == NULL) {
+                       dprintk(vdev, "cannot find control id 0x%x\n", id);
                        return -EINVAL;
+               }
                h->ref = ref;
                ctrl = ref->ctrl;
-               if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED)
+               if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED) {
+                       dprintk(vdev, "control id 0x%x is disabled\n", id);
                        return -EINVAL;
+               }
 
                if (ctrl->cluster[0]->ncontrols > 1)
                        have_clusters = true;
@@ -3257,10 +3324,17 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl,
                        unsigned tot_size = ctrl->elems * ctrl->elem_size;
 
                        if (c->size < tot_size) {
+                               /*
+                                * In the get case the application first
+                                * queries to obtain the size of the control.
+                                */
                                if (get) {
                                        c->size = tot_size;
                                        return -ENOSPC;
                                }
+                               dprintk(vdev,
+                                       "pointer control id 0x%x size too small, %d bytes but %d bytes needed\n",
+                                       id, c->size, tot_size);
                                return -EFAULT;
                        }
                        c->size = tot_size;
@@ -3321,7 +3395,8 @@ static int class_check(struct v4l2_ctrl_handler *hdl, u32 which)
 
 /* Get extended controls. Allocates the helpers array if needed. */
 static int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler *hdl,
-                                  struct v4l2_ext_controls *cs)
+                                  struct v4l2_ext_controls *cs,
+                                  struct video_device *vdev)
 {
        struct v4l2_ctrl_helper helper[4];
        struct v4l2_ctrl_helper *helpers = helper;
@@ -3347,7 +3422,7 @@ static int v4l2_g_ext_ctrls_common(struct v4l2_ctrl_handler *hdl,
                        return -ENOMEM;
        }
 
-       ret = prepare_ext_ctrls(hdl, cs, helpers, true);
+       ret = prepare_ext_ctrls(hdl, cs, helpers, vdev, true);
        cs->error_idx = cs->count;
 
        for (i = 0; !ret && i < cs->count; i++)
@@ -3440,8 +3515,8 @@ v4l2_ctrls_find_req_obj(struct v4l2_ctrl_handler *hdl,
        return obj;
 }
 
-int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct media_device *mdev,
-                    struct v4l2_ext_controls *cs)
+int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct video_device *vdev,
+                    struct media_device *mdev, struct v4l2_ext_controls *cs)
 {
        struct media_request_object *obj = NULL;
        struct media_request *req = NULL;
@@ -3477,7 +3552,7 @@ int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct media_device *mdev,
                                   req_obj);
        }
 
-       ret = v4l2_g_ext_ctrls_common(hdl, cs);
+       ret = v4l2_g_ext_ctrls_common(hdl, cs, vdev);
 
        if (obj) {
                media_request_unlock_for_access(req);
@@ -3620,7 +3695,9 @@ static int try_or_set_cluster(struct v4l2_fh *fh, struct v4l2_ctrl *master,
 
 /* Validate controls. */
 static int validate_ctrls(struct v4l2_ext_controls *cs,
-                         struct v4l2_ctrl_helper *helpers, bool set)
+                         struct v4l2_ctrl_helper *helpers,
+                         struct video_device *vdev,
+                         bool set)
 {
        unsigned i;
        int ret = 0;
@@ -3632,16 +3709,24 @@ static int validate_ctrls(struct v4l2_ext_controls *cs,
 
                cs->error_idx = i;
 
-               if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)
+               if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) {
+                       dprintk(vdev,
+                               "control id 0x%x is read-only\n",
+                               ctrl->id);
                        return -EACCES;
+               }
                /* This test is also done in try_set_control_cluster() which
                   is called in atomic context, so that has the final say,
                   but it makes sense to do an up-front check as well. Once
                   an error occurs in try_set_control_cluster() some other
                   controls may have been set already and we want to do a
                   best-effort to avoid that. */
-               if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED))
+               if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) {
+                       dprintk(vdev,
+                               "control id 0x%x is grabbed, cannot set\n",
+                               ctrl->id);
                        return -EBUSY;
+               }
                /*
                 * Skip validation for now if the payload needs to be copied
                 * from userspace into kernelspace. We'll validate those later.
@@ -3676,7 +3761,8 @@ static void update_from_auto_cluster(struct v4l2_ctrl *master)
 /* Try or try-and-set controls */
 static int try_set_ext_ctrls_common(struct v4l2_fh *fh,
                                    struct v4l2_ctrl_handler *hdl,
-                                   struct v4l2_ext_controls *cs, bool set)
+                                   struct v4l2_ext_controls *cs,
+                                   struct video_device *vdev, bool set)
 {
        struct v4l2_ctrl_helper helper[4];
        struct v4l2_ctrl_helper *helpers = helper;
@@ -3686,13 +3772,19 @@ static int try_set_ext_ctrls_common(struct v4l2_fh *fh,
        cs->error_idx = cs->count;
 
        /* Default value cannot be changed */
-       if (cs->which == V4L2_CTRL_WHICH_DEF_VAL)
+       if (cs->which == V4L2_CTRL_WHICH_DEF_VAL) {
+               dprintk(vdev, "%s: cannot change default value\n",
+                       video_device_node_name(vdev));
                return -EINVAL;
+       }
 
        cs->which = V4L2_CTRL_ID2WHICH(cs->which);
 
-       if (hdl == NULL)
+       if (hdl == NULL) {
+               dprintk(vdev, "%s: invalid null control handler\n",
+                       video_device_node_name(vdev));
                return -EINVAL;
+       }
 
        if (cs->count == 0)
                return class_check(hdl, cs->which);
@@ -3703,9 +3795,9 @@ static int try_set_ext_ctrls_common(struct v4l2_fh *fh,
                if (!helpers)
                        return -ENOMEM;
        }
-       ret = prepare_ext_ctrls(hdl, cs, helpers, false);
+       ret = prepare_ext_ctrls(hdl, cs, helpers, vdev, false);
        if (!ret)
-               ret = validate_ctrls(cs, helpers, set);
+               ret = validate_ctrls(cs, helpers, vdev, set);
        if (ret && set)
                cs->error_idx = cs->count;
        for (i = 0; !ret && i < cs->count; i++) {
@@ -3790,7 +3882,9 @@ static int try_set_ext_ctrls_common(struct v4l2_fh *fh,
 }
 
 static int try_set_ext_ctrls(struct v4l2_fh *fh,
-                            struct v4l2_ctrl_handler *hdl, struct media_device *mdev,
+                            struct v4l2_ctrl_handler *hdl,
+                            struct video_device *vdev,
+                            struct media_device *mdev,
                             struct v4l2_ext_controls *cs, bool set)
 {
        struct media_request_object *obj = NULL;
@@ -3798,21 +3892,39 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh,
        int ret;
 
        if (cs->which == V4L2_CTRL_WHICH_REQUEST_VAL) {
-               if (!mdev || cs->request_fd < 0)
+               if (!mdev) {
+                       dprintk(vdev, "%s: missing media device\n",
+                               video_device_node_name(vdev));
                        return -EINVAL;
+               }
+
+               if (cs->request_fd < 0) {
+                       dprintk(vdev, "%s: invalid request fd %d\n",
+                               video_device_node_name(vdev), cs->request_fd);
+                       return -EINVAL;
+               }
 
                req = media_request_get_by_fd(mdev, cs->request_fd);
-               if (IS_ERR(req))
+               if (IS_ERR(req)) {
+                       dprintk(vdev, "%s: cannot find request fd %d\n",
+                               video_device_node_name(vdev), cs->request_fd);
                        return PTR_ERR(req);
+               }
 
                ret = media_request_lock_for_update(req);
                if (ret) {
+                       dprintk(vdev, "%s: cannot lock request fd %d\n",
+                               video_device_node_name(vdev), cs->request_fd);
                        media_request_put(req);
                        return ret;
                }
 
                obj = v4l2_ctrls_find_req_obj(hdl, req, set);
                if (IS_ERR(obj)) {
+                       dprintk(vdev,
+                               "%s: cannot find request object for request fd %d\n",
+                               video_device_node_name(vdev),
+                               cs->request_fd);
                        media_request_unlock_for_update(req);
                        media_request_put(req);
                        return PTR_ERR(obj);
@@ -3821,7 +3933,11 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh,
                                   req_obj);
        }
 
-       ret = try_set_ext_ctrls_common(fh, hdl, cs, set);
+       ret = try_set_ext_ctrls_common(fh, hdl, cs, vdev, set);
+       if (ret)
+               dprintk(vdev,
+                       "%s: try_set_ext_ctrls_common failed (%d)\n",
+                       video_device_node_name(vdev), ret);
 
        if (obj) {
                media_request_unlock_for_update(req);
@@ -3832,17 +3948,22 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh,
        return ret;
 }
 
-int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct media_device *mdev,
+int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl,
+                      struct video_device *vdev,
+                      struct media_device *mdev,
                       struct v4l2_ext_controls *cs)
 {
-       return try_set_ext_ctrls(NULL, hdl, mdev, cs, false);
+       return try_set_ext_ctrls(NULL, hdl, vdev, mdev, cs, false);
 }
 EXPORT_SYMBOL(v4l2_try_ext_ctrls);
 
-int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
-                    struct media_device *mdev, struct v4l2_ext_controls *cs)
+int v4l2_s_ext_ctrls(struct v4l2_fh *fh,
+                    struct v4l2_ctrl_handler *hdl,
+                    struct video_device *vdev,
+                    struct media_device *mdev,
+                    struct v4l2_ext_controls *cs)
 {
-       return try_set_ext_ctrls(fh, hdl, mdev, cs, true);
+       return try_set_ext_ctrls(fh, hdl, vdev, mdev, cs, true);
 }
 EXPORT_SYMBOL(v4l2_s_ext_ctrls);
 
index cbb74f7485554bbaaae90c60d053260bd1b956bc..a1c61d6f3b9b080d74f13d3c73f9e24b20acf8c3 100644 (file)
@@ -859,6 +859,9 @@ int __video_register_device(struct video_device *vdev,
        /* the v4l2_dev pointer MUST be present */
        if (WARN_ON(!vdev->v4l2_dev))
                return -EINVAL;
+       /* the device_caps field MUST be set for all but subdevs */
+       if (WARN_ON(type != VFL_TYPE_SUBDEV && !vdev->device_caps))
+               return -EINVAL;
 
        /* v4l2_fh support */
        spin_lock_init(&vdev->fh_lock);
index 7e740d332a54e2c6371d6e12e611da86309af53c..3bd1888787eb3c3728c7f60ea5c85dc11fada8a1 100644 (file)
@@ -163,7 +163,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
                        pr_debug("no lane mapping given, using defaults\n");
        }
 
-       rval = fwnode_property_read_u32_array(fwnode, "data-lanes", NULL, 0);
+       rval = fwnode_property_count_u32(fwnode, "data-lanes");
        if (rval > 0) {
                num_data_lanes =
                        min_t(int, V4L2_FWNODE_CSI2_MAX_DATA_LANES, rval);
@@ -191,8 +191,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
                        pr_debug("lane %u position %u\n", i, array[i]);
        }
 
-       rval = fwnode_property_read_u32_array(fwnode, "lane-polarities", NULL,
-                                             0);
+       rval = fwnode_property_count_u32(fwnode, "lane-polarities");
        if (rval > 0) {
                if (rval != 1 + num_data_lanes /* clock+data */) {
                        pr_warn("invalid number of lane-polarities entries (need %u, got %u)\n",
@@ -525,8 +524,7 @@ int v4l2_fwnode_endpoint_alloc_parse(struct fwnode_handle *fwnode,
        if (rval < 0)
                return rval;
 
-       rval = fwnode_property_read_u64_array(fwnode, "link-frequencies",
-                                             NULL, 0);
+       rval = fwnode_property_count_u64(fwnode, "link-frequencies");
        if (rval > 0) {
                unsigned int i;
 
@@ -777,23 +775,17 @@ static int v4l2_fwnode_reference_parse(struct device *dev,
                asd = v4l2_async_notifier_add_fwnode_subdev(notifier,
                                                            args.fwnode,
                                                            sizeof(*asd));
+               fwnode_handle_put(args.fwnode);
                if (IS_ERR(asd)) {
-                       ret = PTR_ERR(asd);
                        /* not an error if asd already exists */
-                       if (ret == -EEXIST) {
-                               fwnode_handle_put(args.fwnode);
+                       if (PTR_ERR(asd) == -EEXIST)
                                continue;
-                       }
 
-                       goto error;
+                       return PTR_ERR(asd);
                }
        }
 
        return 0;
-
-error:
-       fwnode_handle_put(args.fwnode);
-       return ret;
 }
 
 /*
@@ -1083,23 +1075,18 @@ v4l2_fwnode_reference_parse_int_props(struct device *dev,
 
                asd = v4l2_async_notifier_add_fwnode_subdev(notifier, fwnode,
                                                            sizeof(*asd));
+               fwnode_handle_put(fwnode);
                if (IS_ERR(asd)) {
                        ret = PTR_ERR(asd);
                        /* not an error if asd already exists */
-                       if (ret == -EEXIST) {
-                               fwnode_handle_put(fwnode);
+                       if (ret == -EEXIST)
                                continue;
-                       }
 
-                       goto error;
+                       return PTR_ERR(asd);
                }
        }
 
        return !fwnode || PTR_ERR(fwnode) == -ENOENT ? 0 : PTR_ERR(fwnode);
-
-error:
-       fwnode_handle_put(fwnode);
-       return ret;
 }
 
 int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev,
index b1f4b991dba633d0a953398e03a32dd59bb027b5..bb5b4926538abd6e79c848bf85ef96e54da88d8d 100644 (file)
@@ -1057,14 +1057,19 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
 
        ret = ops->vidioc_querycap(file, fh, cap);
 
-       cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
        /*
-        * Drivers MUST fill in device_caps, so check for this and
-        * warn if it was forgotten.
+        * Drivers must not change device_caps, so check for this and
+        * warn if this happened.
+        */
+       WARN_ON(cap->device_caps != vfd->device_caps);
+       /*
+        * Check that capabilities is a superset of
+        * vfd->device_caps | V4L2_CAP_DEVICE_CAPS
         */
-       WARN(!(cap->capabilities & V4L2_CAP_DEVICE_CAPS) ||
-               !cap->device_caps, "Bad caps for driver %s, %x %x",
-               cap->driver, cap->capabilities, cap->device_caps);
+       WARN_ON((cap->capabilities &
+                (vfd->device_caps | V4L2_CAP_DEVICE_CAPS)) !=
+               (vfd->device_caps | V4L2_CAP_DEVICE_CAPS));
+       cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
        cap->device_caps |= V4L2_CAP_EXT_PIX_FORMAT;
 
        return ret;
@@ -1169,9 +1174,21 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
        case V4L2_PIX_FMT_RGB444:       descr = "16-bit A/XRGB 4-4-4-4"; break;
        case V4L2_PIX_FMT_ARGB444:      descr = "16-bit ARGB 4-4-4-4"; break;
        case V4L2_PIX_FMT_XRGB444:      descr = "16-bit XRGB 4-4-4-4"; break;
+       case V4L2_PIX_FMT_RGBA444:      descr = "16-bit RGBA 4-4-4-4"; break;
+       case V4L2_PIX_FMT_RGBX444:      descr = "16-bit RGBX 4-4-4-4"; break;
+       case V4L2_PIX_FMT_ABGR444:      descr = "16-bit ABGR 4-4-4-4"; break;
+       case V4L2_PIX_FMT_XBGR444:      descr = "16-bit XBGR 4-4-4-4"; break;
+       case V4L2_PIX_FMT_BGRA444:      descr = "16-bit BGRA 4-4-4-4"; break;
+       case V4L2_PIX_FMT_BGRX444:      descr = "16-bit BGRX 4-4-4-4"; break;
        case V4L2_PIX_FMT_RGB555:       descr = "16-bit A/XRGB 1-5-5-5"; break;
        case V4L2_PIX_FMT_ARGB555:      descr = "16-bit ARGB 1-5-5-5"; break;
        case V4L2_PIX_FMT_XRGB555:      descr = "16-bit XRGB 1-5-5-5"; break;
+       case V4L2_PIX_FMT_ABGR555:      descr = "16-bit ABGR 1-5-5-5"; break;
+       case V4L2_PIX_FMT_XBGR555:      descr = "16-bit XBGR 1-5-5-5"; break;
+       case V4L2_PIX_FMT_RGBA555:      descr = "16-bit RGBA 5-5-5-1"; break;
+       case V4L2_PIX_FMT_RGBX555:      descr = "16-bit RGBX 5-5-5-1"; break;
+       case V4L2_PIX_FMT_BGRA555:      descr = "16-bit BGRA 5-5-5-1"; break;
+       case V4L2_PIX_FMT_BGRX555:      descr = "16-bit BGRX 5-5-5-1"; break;
        case V4L2_PIX_FMT_RGB565:       descr = "16-bit RGB 5-6-5"; break;
        case V4L2_PIX_FMT_RGB555X:      descr = "16-bit A/XRGB 1-5-5-5 BE"; break;
        case V4L2_PIX_FMT_ARGB555X:     descr = "16-bit ARGB 1-5-5-5 BE"; break;
@@ -1186,6 +1203,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
        case V4L2_PIX_FMT_RGB32:        descr = "32-bit A/XRGB 8-8-8-8"; break;
        case V4L2_PIX_FMT_ARGB32:       descr = "32-bit ARGB 8-8-8-8"; break;
        case V4L2_PIX_FMT_XRGB32:       descr = "32-bit XRGB 8-8-8-8"; break;
+       case V4L2_PIX_FMT_BGRA32:       descr = "32-bit ABGR 8-8-8-8"; break;
+       case V4L2_PIX_FMT_BGRX32:       descr = "32-bit XBGR 8-8-8-8"; break;
+       case V4L2_PIX_FMT_RGBA32:       descr = "32-bit RGBA 8-8-8-8"; break;
+       case V4L2_PIX_FMT_RGBX32:       descr = "32-bit RGBX 8-8-8-8"; break;
        case V4L2_PIX_FMT_GREY:         descr = "8-bit Greyscale"; break;
        case V4L2_PIX_FMT_Y4:           descr = "4-bit Greyscale"; break;
        case V4L2_PIX_FMT_Y6:           descr = "6-bit Greyscale"; break;
@@ -1301,13 +1322,14 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
        case V4L2_SDR_FMT_PCU16BE:      descr = "Planar Complex U16BE"; break;
        case V4L2_SDR_FMT_PCU18BE:      descr = "Planar Complex U18BE"; break;
        case V4L2_SDR_FMT_PCU20BE:      descr = "Planar Complex U20BE"; break;
-       case V4L2_TCH_FMT_DELTA_TD16:   descr = "16-bit signed deltas"; break;
-       case V4L2_TCH_FMT_DELTA_TD08:   descr = "8-bit signed deltas"; break;
-       case V4L2_TCH_FMT_TU16:         descr = "16-bit unsigned touch data"; break;
-       case V4L2_TCH_FMT_TU08:         descr = "8-bit unsigned touch data"; break;
+       case V4L2_TCH_FMT_DELTA_TD16:   descr = "16-bit Signed Deltas"; break;
+       case V4L2_TCH_FMT_DELTA_TD08:   descr = "8-bit Signed Deltas"; break;
+       case V4L2_TCH_FMT_TU16:         descr = "16-bit Unsigned Touch Data"; break;
+       case V4L2_TCH_FMT_TU08:         descr = "8-bit Unsigned Touch Data"; break;
        case V4L2_META_FMT_VSP1_HGO:    descr = "R-Car VSP1 1-D Histogram"; break;
        case V4L2_META_FMT_VSP1_HGT:    descr = "R-Car VSP1 2-D Histogram"; break;
-       case V4L2_META_FMT_UVC:         descr = "UVC payload header metadata"; break;
+       case V4L2_META_FMT_UVC:         descr = "UVC Payload Header Metadata"; break;
+       case V4L2_META_FMT_D4XX:        descr = "Intel D4xx UVC Metadata"; break;
 
        default:
                /* Compressed formats */
@@ -1326,11 +1348,12 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
                case V4L2_PIX_FMT_MPEG1:        descr = "MPEG-1 ES"; break;
                case V4L2_PIX_FMT_MPEG2:        descr = "MPEG-2 ES"; break;
                case V4L2_PIX_FMT_MPEG2_SLICE:  descr = "MPEG-2 Parsed Slice Data"; break;
-               case V4L2_PIX_FMT_MPEG4:        descr = "MPEG-4 part 2 ES"; break;
+               case V4L2_PIX_FMT_MPEG4:        descr = "MPEG-4 Part 2 ES"; break;
                case V4L2_PIX_FMT_XVID:         descr = "Xvid"; break;
                case V4L2_PIX_FMT_VC1_ANNEX_G:  descr = "VC-1 (SMPTE 412M Annex G)"; break;
                case V4L2_PIX_FMT_VC1_ANNEX_L:  descr = "VC-1 (SMPTE 412M Annex L)"; break;
                case V4L2_PIX_FMT_VP8:          descr = "VP8"; break;
+               case V4L2_PIX_FMT_VP8_FRAME:    descr = "VP8 Frame"; break;
                case V4L2_PIX_FMT_VP9:          descr = "VP9"; break;
                case V4L2_PIX_FMT_HEVC:         descr = "HEVC"; break; /* aka H.265 */
                case V4L2_PIX_FMT_FWHT:         descr = "FWHT"; break; /* used in vicodec */
@@ -1372,7 +1395,7 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
 
        if (descr)
                WARN_ON(strscpy(fmt->description, descr, sz) < 0);
-       fmt->flags = flags;
+       fmt->flags |= flags;
 }
 
 static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
@@ -1645,6 +1668,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
                                struct file *file, void *fh, void *arg)
 {
        struct v4l2_format *p = arg;
+       struct video_device *vfd = video_devdata(file);
        int ret = check_fmt(file, p->type);
        unsigned int i;
 
@@ -1661,6 +1685,8 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops,
                ret = ops->vidioc_try_fmt_vid_cap(file, fh, arg);
                /* just in case the driver zeroed it again */
                p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
+               if (vfd->vfl_type == VFL_TYPE_TOUCH)
+                       v4l_pix_format_touch(&p->fmt.pix);
                return ret;
        case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
                if (unlikely(!ops->vidioc_try_fmt_vid_cap_mplane))
@@ -2165,9 +2191,11 @@ static int v4l_g_ext_ctrls(const struct v4l2_ioctl_ops *ops,
 
        p->error_idx = p->count;
        if (vfh && vfh->ctrl_handler)
-               return v4l2_g_ext_ctrls(vfh->ctrl_handler, vfd->v4l2_dev->mdev, p);
+               return v4l2_g_ext_ctrls(vfh->ctrl_handler,
+                                       vfd, vfd->v4l2_dev->mdev, p);
        if (vfd->ctrl_handler)
-               return v4l2_g_ext_ctrls(vfd->ctrl_handler, vfd->v4l2_dev->mdev, p);
+               return v4l2_g_ext_ctrls(vfd->ctrl_handler,
+                                       vfd, vfd->v4l2_dev->mdev, p);
        if (ops->vidioc_g_ext_ctrls == NULL)
                return -ENOTTY;
        return check_ext_ctrls(p, 0) ? ops->vidioc_g_ext_ctrls(file, fh, p) :
@@ -2184,9 +2212,11 @@ static int v4l_s_ext_ctrls(const struct v4l2_ioctl_ops *ops,
 
        p->error_idx = p->count;
        if (vfh && vfh->ctrl_handler)
-               return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, vfd->v4l2_dev->mdev, p);
+               return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler,
+                                       vfd, vfd->v4l2_dev->mdev, p);
        if (vfd->ctrl_handler)
-               return v4l2_s_ext_ctrls(NULL, vfd->ctrl_handler, vfd->v4l2_dev->mdev, p);
+               return v4l2_s_ext_ctrls(NULL, vfd->ctrl_handler,
+                                       vfd, vfd->v4l2_dev->mdev, p);
        if (ops->vidioc_s_ext_ctrls == NULL)
                return -ENOTTY;
        return check_ext_ctrls(p, 0) ? ops->vidioc_s_ext_ctrls(file, fh, p) :
@@ -2203,9 +2233,11 @@ static int v4l_try_ext_ctrls(const struct v4l2_ioctl_ops *ops,
 
        p->error_idx = p->count;
        if (vfh && vfh->ctrl_handler)
-               return v4l2_try_ext_ctrls(vfh->ctrl_handler, vfd->v4l2_dev->mdev, p);
+               return v4l2_try_ext_ctrls(vfh->ctrl_handler,
+                                         vfd, vfd->v4l2_dev->mdev, p);
        if (vfd->ctrl_handler)
-               return v4l2_try_ext_ctrls(vfd->ctrl_handler, vfd->v4l2_dev->mdev, p);
+               return v4l2_try_ext_ctrls(vfd->ctrl_handler,
+                                         vfd, vfd->v4l2_dev->mdev, p);
        if (ops->vidioc_try_ext_ctrls == NULL)
                return -ENOTTY;
        return check_ext_ctrls(p, 0) ? ops->vidioc_try_ext_ctrls(file, fh, p) :
index 4f517670293771c9db268d2531ff4cf0851a3876..19937dd3c6f63980eb0f48700ba96cbc0b5cf77c 100644 (file)
@@ -603,11 +603,10 @@ int v4l2_m2m_streamoff(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
 }
 EXPORT_SYMBOL_GPL(v4l2_m2m_streamoff);
 
-__poll_t v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
-                          struct poll_table_struct *wait)
+static __poll_t v4l2_m2m_poll_for_data(struct file *file,
+                                      struct v4l2_m2m_ctx *m2m_ctx,
+                                      struct poll_table_struct *wait)
 {
-       struct video_device *vfd = video_devdata(file);
-       __poll_t req_events = poll_requested_events(wait);
        struct vb2_queue *src_q, *dst_q;
        struct vb2_buffer *src_vb = NULL, *dst_vb = NULL;
        __poll_t rc = 0;
@@ -619,16 +618,6 @@ __poll_t v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
        poll_wait(file, &src_q->done_wq, wait);
        poll_wait(file, &dst_q->done_wq, wait);
 
-       if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
-               struct v4l2_fh *fh = file->private_data;
-
-               poll_wait(file, &fh->wait, wait);
-               if (v4l2_event_pending(fh))
-                       rc = EPOLLPRI;
-               if (!(req_events & (EPOLLOUT | EPOLLWRNORM | EPOLLIN | EPOLLRDNORM)))
-                       return rc;
-       }
-
        /*
         * There has to be at least one buffer queued on each queued_list, which
         * means either in driver already or waiting for driver to claim it
@@ -637,10 +626,8 @@ __poll_t v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
        if ((!src_q->streaming || src_q->error ||
             list_empty(&src_q->queued_list)) &&
            (!dst_q->streaming || dst_q->error ||
-            list_empty(&dst_q->queued_list))) {
-               rc |= EPOLLERR;
-               goto end;
-       }
+            list_empty(&dst_q->queued_list)))
+               return EPOLLERR;
 
        spin_lock_irqsave(&dst_q->done_lock, flags);
        if (list_empty(&dst_q->done_list)) {
@@ -650,7 +637,7 @@ __poll_t v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
                 */
                if (dst_q->last_buffer_dequeued) {
                        spin_unlock_irqrestore(&dst_q->done_lock, flags);
-                       return rc | EPOLLIN | EPOLLRDNORM;
+                       return EPOLLIN | EPOLLRDNORM;
                }
        }
        spin_unlock_irqrestore(&dst_q->done_lock, flags);
@@ -673,7 +660,27 @@ __poll_t v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
                rc |= EPOLLIN | EPOLLRDNORM;
        spin_unlock_irqrestore(&dst_q->done_lock, flags);
 
-end:
+       return rc;
+}
+
+__poll_t v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
+                      struct poll_table_struct *wait)
+{
+       struct video_device *vfd = video_devdata(file);
+       __poll_t req_events = poll_requested_events(wait);
+       __poll_t rc = 0;
+
+       if (req_events & (EPOLLOUT | EPOLLWRNORM | EPOLLIN | EPOLLRDNORM))
+               rc = v4l2_m2m_poll_for_data(file, m2m_ctx, wait);
+
+       if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
+               struct v4l2_fh *fh = file->private_data;
+
+               poll_wait(file, &fh->wait, wait);
+               if (v4l2_event_pending(fh))
+                       rc |= EPOLLPRI;
+       }
+
        return rc;
 }
 EXPORT_SYMBOL_GPL(v4l2_m2m_poll);
index 25c73c13cc7ef830b72b70de39015bd8e48190d7..f725cd9b66b964b92c47b20a4aeaa7d0e9d13277 100644 (file)
@@ -372,19 +372,19 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
                if (!vfh->ctrl_handler)
                        return -ENOTTY;
                return v4l2_g_ext_ctrls(vfh->ctrl_handler,
-                                       sd->v4l2_dev->mdev, arg);
+                                       vdev, sd->v4l2_dev->mdev, arg);
 
        case VIDIOC_S_EXT_CTRLS:
                if (!vfh->ctrl_handler)
                        return -ENOTTY;
                return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler,
-                                       sd->v4l2_dev->mdev, arg);
+                                       vdev, sd->v4l2_dev->mdev, arg);
 
        case VIDIOC_TRY_EXT_CTRLS:
                if (!vfh->ctrl_handler)
                        return -ENOTTY;
                return v4l2_try_ext_ctrls(vfh->ctrl_handler,
-                                         sd->v4l2_dev->mdev, arg);
+                                         vdev, sd->v4l2_dev->mdev, arg);
 
        case VIDIOC_DQEVENT:
                if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))
index 534d85d6c5e3d01b5ce7287b54662e29870df2fd..642adc4c24d2ddfca946048b9757ab278d2a91e1 100644 (file)
@@ -22,10 +22,6 @@ if STAGING_MEDIA && MEDIA_SUPPORT
 # Please keep them in alphabetic order
 source "drivers/staging/media/allegro-dvt/Kconfig"
 
-source "drivers/staging/media/bcm2048/Kconfig"
-
-source "drivers/staging/media/davinci_vpfe/Kconfig"
-
 source "drivers/staging/media/hantro/Kconfig"
 
 source "drivers/staging/media/imx/Kconfig"
index c486298194da20b83bf9f67d57b5f0273d8b05be..2f1711a8aeed28edb131febe48e6e0707cbecd71 100644 (file)
@@ -1,8 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_VIDEO_ALLEGRO_DVT)        += allegro-dvt/
-obj-$(CONFIG_I2C_BCM2048)      += bcm2048/
 obj-$(CONFIG_VIDEO_IMX_MEDIA)  += imx/
-obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/
 obj-$(CONFIG_VIDEO_MESON_VDEC) += meson/vdec/
 obj-$(CONFIG_VIDEO_OMAP4)      += omap4iss/
 obj-$(CONFIG_VIDEO_SUNXI)      += sunxi/
diff --git a/drivers/staging/media/bcm2048/Kconfig b/drivers/staging/media/bcm2048/Kconfig
deleted file mode 100644 (file)
index ab2d50c..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Multimedia Video device configuration
-#
-
-config I2C_BCM2048
-       tristate "Broadcom BCM2048 FM Radio Receiver support"
-       depends on I2C && VIDEO_V4L2 && RADIO_ADAPTERS
-       help
-         Say Y here if you want support to BCM2048 FM Radio Receiver.
-         This device driver supports only i2c bus.
-
-         To compile this driver as a module, choose M here: the
-         module will be called radio-bcm2048.
diff --git a/drivers/staging/media/bcm2048/Makefile b/drivers/staging/media/bcm2048/Makefile
deleted file mode 100644 (file)
index f420568..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_I2C_BCM2048) += radio-bcm2048.o
diff --git a/drivers/staging/media/bcm2048/TODO b/drivers/staging/media/bcm2048/TODO
deleted file mode 100644 (file)
index 6bee2a2..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-TODO:
-
-From the initial code review:
-
-The main thing you need to do is to implement all the controls using the
-control framework (see Documentation/media/kapi/v4l2-controls.rst).
-Most drivers are by now converted to the control framework, so you will
-find many examples of how to do this in drivers/media/radio.
-
-The sysfs stuff should be replaced by controls as well. A lot of the RDS
-support is now available as controls (although there may well be some
-missing features, but that is easy enough to add). Since the RDS data is
-actually read() from the device I am not sure whether the RDS
-properties/controls should be there at all.
-
-Correct Coding Style, as this driver also violates several Style
-rules, and do evil tricks, like returning from a function inside a
-macro.
-
-Finally this driver should probably be split up into two parts: one
-v4l2_subdev-based core driver and one platform driver. See e.g.
-radio-si4713/si4713-i2c.c as a good example. But I would wait with that
-until the rest of the driver is cleaned up. Then I have a better idea of
-whether this is necessary or not.
diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c
deleted file mode 100644 (file)
index 2c60a1f..0000000
+++ /dev/null
@@ -1,2689 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * drivers/staging/media/radio-bcm2048.c
- *
- * Driver for I2C Broadcom BCM2048 FM Radio Receiver:
- *
- * Copyright (C) Nokia Corporation
- * Contact: Eero Nurkkala <ext-eero.nurkkala@nokia.com>
- *
- * Copyright (C) Nils Faerber <nils.faerber@kernelconcepts.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- */
-
-/*
- * History:
- *             Eero Nurkkala <ext-eero.nurkkala@nokia.com>
- *             Version 0.0.1
- *             - Initial implementation
- * 2010-02-21  Nils Faerber <nils.faerber@kernelconcepts.de>
- *             Version 0.0.2
- *             - Add support for interrupt driven rds data reading
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/version.h>
-#include <linux/interrupt.h>
-#include <linux/sysfs.h>
-#include <linux/completion.h>
-#include <linux/delay.h>
-#include <linux/i2c.h>
-#include <linux/videodev2.h>
-#include <linux/mutex.h>
-#include <linux/slab.h>
-#include <media/v4l2-common.h>
-#include <media/v4l2-ioctl.h>
-#include "radio-bcm2048.h"
-
-/* driver definitions */
-#define BCM2048_DRIVER_AUTHOR  "Eero Nurkkala <ext-eero.nurkkala@nokia.com>"
-#define BCM2048_DRIVER_NAME    BCM2048_NAME
-#define BCM2048_DRIVER_CARD    "Broadcom bcm2048 FM Radio Receiver"
-#define BCM2048_DRIVER_DESC    "I2C driver for BCM2048 FM Radio Receiver"
-
-/* I2C Control Registers */
-#define BCM2048_I2C_FM_RDS_SYSTEM      0x00
-#define BCM2048_I2C_FM_CTRL            0x01
-#define BCM2048_I2C_RDS_CTRL0          0x02
-#define BCM2048_I2C_RDS_CTRL1          0x03
-#define BCM2048_I2C_FM_AUDIO_PAUSE     0x04
-#define BCM2048_I2C_FM_AUDIO_CTRL0     0x05
-#define BCM2048_I2C_FM_AUDIO_CTRL1     0x06
-#define BCM2048_I2C_FM_SEARCH_CTRL0    0x07
-#define BCM2048_I2C_FM_SEARCH_CTRL1    0x08
-#define BCM2048_I2C_FM_SEARCH_TUNE_MODE        0x09
-#define BCM2048_I2C_FM_FREQ0           0x0a
-#define BCM2048_I2C_FM_FREQ1           0x0b
-#define BCM2048_I2C_FM_AF_FREQ0                0x0c
-#define BCM2048_I2C_FM_AF_FREQ1                0x0d
-#define BCM2048_I2C_FM_CARRIER         0x0e
-#define BCM2048_I2C_FM_RSSI            0x0f
-#define BCM2048_I2C_FM_RDS_MASK0       0x10
-#define BCM2048_I2C_FM_RDS_MASK1       0x11
-#define BCM2048_I2C_FM_RDS_FLAG0       0x12
-#define BCM2048_I2C_FM_RDS_FLAG1       0x13
-#define BCM2048_I2C_RDS_WLINE          0x14
-#define BCM2048_I2C_RDS_BLKB_MATCH0    0x16
-#define BCM2048_I2C_RDS_BLKB_MATCH1    0x17
-#define BCM2048_I2C_RDS_BLKB_MASK0     0x18
-#define BCM2048_I2C_RDS_BLKB_MASK1     0x19
-#define BCM2048_I2C_RDS_PI_MATCH0      0x1a
-#define BCM2048_I2C_RDS_PI_MATCH1      0x1b
-#define BCM2048_I2C_RDS_PI_MASK0       0x1c
-#define BCM2048_I2C_RDS_PI_MASK1       0x1d
-#define BCM2048_I2C_SPARE1             0x20
-#define BCM2048_I2C_SPARE2             0x21
-#define BCM2048_I2C_FM_RDS_REV         0x28
-#define BCM2048_I2C_SLAVE_CONFIGURATION        0x29
-#define BCM2048_I2C_RDS_DATA           0x80
-#define BCM2048_I2C_FM_BEST_TUNE_MODE  0x90
-
-/* BCM2048_I2C_FM_RDS_SYSTEM */
-#define BCM2048_FM_ON                  0x01
-#define BCM2048_RDS_ON                 0x02
-
-/* BCM2048_I2C_FM_CTRL */
-#define BCM2048_BAND_SELECT                    0x01
-#define BCM2048_STEREO_MONO_AUTO_SELECT                0x02
-#define BCM2048_STEREO_MONO_MANUAL_SELECT      0x04
-#define BCM2048_STEREO_MONO_BLEND_SWITCH       0x08
-#define BCM2048_HI_LO_INJECTION                        0x10
-
-/* BCM2048_I2C_RDS_CTRL0 */
-#define BCM2048_RBDS_RDS_SELECT                0x01
-#define BCM2048_FLUSH_FIFO             0x02
-
-/* BCM2048_I2C_FM_AUDIO_PAUSE */
-#define BCM2048_AUDIO_PAUSE_RSSI_TRESH 0x0f
-#define BCM2048_AUDIO_PAUSE_DURATION   0xf0
-
-/* BCM2048_I2C_FM_AUDIO_CTRL0 */
-#define BCM2048_RF_MUTE                        0x01
-#define BCM2048_MANUAL_MUTE            0x02
-#define BCM2048_DAC_OUTPUT_LEFT                0x04
-#define BCM2048_DAC_OUTPUT_RIGHT       0x08
-#define BCM2048_AUDIO_ROUTE_DAC                0x10
-#define BCM2048_AUDIO_ROUTE_I2S                0x20
-#define BCM2048_DE_EMPHASIS_SELECT     0x40
-#define BCM2048_AUDIO_BANDWIDTH_SELECT 0x80
-
-/* BCM2048_I2C_FM_SEARCH_CTRL0 */
-#define BCM2048_SEARCH_RSSI_THRESHOLD  0x7f
-#define BCM2048_SEARCH_DIRECTION       0x80
-
-/* BCM2048_I2C_FM_SEARCH_TUNE_MODE */
-#define BCM2048_FM_AUTO_SEARCH         0x03
-
-/* BCM2048_I2C_FM_RSSI */
-#define BCM2048_RSSI_VALUE             0xff
-
-/* BCM2048_I2C_FM_RDS_MASK0 */
-/* BCM2048_I2C_FM_RDS_MASK1 */
-#define BCM2048_FM_FLAG_SEARCH_TUNE_FINISHED   0x01
-#define BCM2048_FM_FLAG_SEARCH_TUNE_FAIL       0x02
-#define BCM2048_FM_FLAG_RSSI_LOW               0x04
-#define BCM2048_FM_FLAG_CARRIER_ERROR_HIGH     0x08
-#define BCM2048_FM_FLAG_AUDIO_PAUSE_INDICATION 0x10
-#define BCM2048_FLAG_STEREO_DETECTED           0x20
-#define BCM2048_FLAG_STEREO_ACTIVE             0x40
-
-/* BCM2048_I2C_RDS_DATA */
-#define BCM2048_SLAVE_ADDRESS                  0x3f
-#define BCM2048_SLAVE_ENABLE                   0x80
-
-/* BCM2048_I2C_FM_BEST_TUNE_MODE */
-#define BCM2048_BEST_TUNE_MODE                 0x80
-
-#define BCM2048_FM_FLAG_SEARCH_TUNE_FINISHED   0x01
-#define BCM2048_FM_FLAG_SEARCH_TUNE_FAIL       0x02
-#define BCM2048_FM_FLAG_RSSI_LOW               0x04
-#define BCM2048_FM_FLAG_CARRIER_ERROR_HIGH     0x08
-#define BCM2048_FM_FLAG_AUDIO_PAUSE_INDICATION 0x10
-#define BCM2048_FLAG_STEREO_DETECTED           0x20
-#define BCM2048_FLAG_STEREO_ACTIVE             0x40
-
-#define BCM2048_RDS_FLAG_FIFO_WLINE            0x02
-#define BCM2048_RDS_FLAG_B_BLOCK_MATCH         0x08
-#define BCM2048_RDS_FLAG_SYNC_LOST             0x10
-#define BCM2048_RDS_FLAG_PI_MATCH              0x20
-
-#define BCM2048_RDS_MARK_END_BYTE0             0x7C
-#define BCM2048_RDS_MARK_END_BYTEN             0xFF
-
-#define BCM2048_FM_FLAGS_ALL   (FM_FLAG_SEARCH_TUNE_FINISHED | \
-                                FM_FLAG_SEARCH_TUNE_FAIL | \
-                                FM_FLAG_RSSI_LOW | \
-                                FM_FLAG_CARRIER_ERROR_HIGH | \
-                                FM_FLAG_AUDIO_PAUSE_INDICATION | \
-                                FLAG_STEREO_DETECTED | FLAG_STEREO_ACTIVE)
-
-#define BCM2048_RDS_FLAGS_ALL  (RDS_FLAG_FIFO_WLINE | \
-                                RDS_FLAG_B_BLOCK_MATCH | \
-                                RDS_FLAG_SYNC_LOST | RDS_FLAG_PI_MATCH)
-
-#define BCM2048_DEFAULT_TIMEOUT                1500
-#define BCM2048_AUTO_SEARCH_TIMEOUT    3000
-
-#define BCM2048_FREQDEV_UNIT           10000
-#define BCM2048_FREQV4L2_MULTI         625
-#define dev_to_v4l2(f) (((f) * BCM2048_FREQDEV_UNIT) / BCM2048_FREQV4L2_MULTI)
-#define v4l2_to_dev(f) (((f) * BCM2048_FREQV4L2_MULTI) / BCM2048_FREQDEV_UNIT)
-
-#define msb(x)                  ((u8)((u16)(x) >> 8))
-#define lsb(x)                  ((u8)((u16)(x) &  0x00FF))
-#define compose_u16(msb, lsb)  (((u16)(msb) << 8) | (lsb))
-
-#define BCM2048_DEFAULT_POWERING_DELAY 20
-#define BCM2048_DEFAULT_REGION         0x02
-#define BCM2048_DEFAULT_MUTE           0x01
-#define BCM2048_DEFAULT_RSSI_THRESHOLD 0x64
-#define BCM2048_DEFAULT_RDS_WLINE      0x7E
-
-#define BCM2048_FM_SEARCH_INACTIVE     0x00
-#define BCM2048_FM_PRE_SET_MODE                0x01
-#define BCM2048_FM_AUTO_SEARCH_MODE    0x02
-#define BCM2048_FM_AF_JUMP_MODE                0x03
-
-#define BCM2048_FREQUENCY_BASE         64000
-
-#define BCM2048_POWER_ON               0x01
-#define BCM2048_POWER_OFF              0x00
-
-#define BCM2048_ITEM_ENABLED           0x01
-#define BCM2048_SEARCH_DIRECTION_UP    0x01
-
-#define BCM2048_DE_EMPHASIS_75us       75
-#define BCM2048_DE_EMPHASIS_50us       50
-
-#define BCM2048_SCAN_FAIL              0x00
-#define BCM2048_SCAN_OK                        0x01
-
-#define BCM2048_FREQ_ERROR_FLOOR       -20
-#define BCM2048_FREQ_ERROR_ROOF                20
-
-/* -60 dB is reported as full signal strength */
-#define BCM2048_RSSI_LEVEL_BASE                -60
-#define BCM2048_RSSI_LEVEL_ROOF                -100
-#define BCM2048_RSSI_LEVEL_ROOF_NEG    100
-#define BCM2048_SIGNAL_MULTIPLIER      (0xFFFF / \
-                                        (BCM2048_RSSI_LEVEL_ROOF_NEG + \
-                                         BCM2048_RSSI_LEVEL_BASE))
-
-#define BCM2048_RDS_FIFO_DUPLE_SIZE    0x03
-#define BCM2048_RDS_CRC_MASK           0x0F
-#define BCM2048_RDS_CRC_NONE           0x00
-#define BCM2048_RDS_CRC_MAX_2BITS      0x04
-#define BCM2048_RDS_CRC_LEAST_2BITS    0x08
-#define BCM2048_RDS_CRC_UNRECOVARABLE  0x0C
-
-#define BCM2048_RDS_BLOCK_MASK         0xF0
-#define BCM2048_RDS_BLOCK_A            0x00
-#define BCM2048_RDS_BLOCK_B            0x10
-#define BCM2048_RDS_BLOCK_C            0x20
-#define BCM2048_RDS_BLOCK_D            0x30
-#define BCM2048_RDS_BLOCK_C_SCORED     0x40
-#define BCM2048_RDS_BLOCK_E            0x60
-
-#define BCM2048_RDS_RT                 0x20
-#define BCM2048_RDS_PS                 0x00
-
-#define BCM2048_RDS_GROUP_AB_MASK      0x08
-#define BCM2048_RDS_GROUP_A            0x00
-#define BCM2048_RDS_GROUP_B            0x08
-
-#define BCM2048_RDS_RT_AB_MASK         0x10
-#define BCM2048_RDS_RT_A               0x00
-#define BCM2048_RDS_RT_B               0x10
-#define BCM2048_RDS_RT_INDEX           0x0F
-
-#define BCM2048_RDS_PS_INDEX           0x03
-
-struct rds_info {
-       u16 rds_pi;
-#define BCM2048_MAX_RDS_RT (64 + 1)
-       u8 rds_rt[BCM2048_MAX_RDS_RT];
-       u8 rds_rt_group_b;
-       u8 rds_rt_ab;
-#define BCM2048_MAX_RDS_PS (8 + 1)
-       u8 rds_ps[BCM2048_MAX_RDS_PS];
-       u8 rds_ps_group;
-       u8 rds_ps_group_cnt;
-#define BCM2048_MAX_RDS_RADIO_TEXT 255
-       u8 radio_text[BCM2048_MAX_RDS_RADIO_TEXT + 3];
-       u8 text_len;
-};
-
-struct region_info {
-       u32 bottom_frequency;
-       u32 top_frequency;
-       u8 deemphasis;
-       u8 channel_spacing;
-       u8 region;
-};
-
-struct bcm2048_device {
-       struct i2c_client *client;
-       struct video_device videodev;
-       struct work_struct work;
-       struct completion compl;
-       struct mutex mutex;
-       struct bcm2048_platform_data *platform_data;
-       struct rds_info rds_info;
-       struct region_info region_info;
-       u16 frequency;
-       u8 cache_fm_rds_system;
-       u8 cache_fm_ctrl;
-       u8 cache_fm_audio_ctrl0;
-       u8 cache_fm_search_ctrl0;
-       u8 power_state;
-       u8 rds_state;
-       u8 fifo_size;
-       u8 scan_state;
-       u8 mute_state;
-
-       /* for rds data device read */
-       wait_queue_head_t read_queue;
-       unsigned int users;
-       unsigned char rds_data_available;
-       unsigned int rd_index;
-};
-
-static int radio_nr = -1;      /* radio device minor (-1 ==> auto assign) */
-module_param(radio_nr, int, 0000);
-MODULE_PARM_DESC(radio_nr,
-                "Minor number for radio device (-1 ==> auto assign)");
-
-static const struct region_info region_configs[] = {
-       /* USA */
-       {
-               .channel_spacing        = 20,
-               .bottom_frequency       = 87500,
-               .top_frequency          = 108000,
-               .deemphasis             = 75,
-               .region                 = 0,
-       },
-       /* Australia */
-       {
-               .channel_spacing        = 20,
-               .bottom_frequency       = 87500,
-               .top_frequency          = 108000,
-               .deemphasis             = 50,
-               .region                 = 1,
-       },
-       /* Europe */
-       {
-               .channel_spacing        = 10,
-               .bottom_frequency       = 87500,
-               .top_frequency          = 108000,
-               .deemphasis             = 50,
-               .region                 = 2,
-       },
-       /* Japan */
-       {
-               .channel_spacing        = 10,
-               .bottom_frequency       = 76000,
-               .top_frequency          = 90000,
-               .deemphasis             = 50,
-               .region                 = 3,
-       },
-};
-
-/*
- *     I2C Interface read / write
- */
-static int bcm2048_send_command(struct bcm2048_device *bdev, unsigned int reg,
-                               unsigned int value)
-{
-       struct i2c_client *client = bdev->client;
-       u8 data[2];
-
-       if (!bdev->power_state) {
-               dev_err(&bdev->client->dev, "bcm2048: chip not powered!\n");
-               return -EIO;
-       }
-
-       data[0] = reg & 0xff;
-       data[1] = value & 0xff;
-
-       if (i2c_master_send(client, data, 2) == 2)
-               return 0;
-
-       dev_err(&bdev->client->dev, "BCM I2C error!\n");
-       dev_err(&bdev->client->dev, "Is Bluetooth up and running?\n");
-       return -EIO;
-}
-
-static int bcm2048_recv_command(struct bcm2048_device *bdev, unsigned int reg,
-                               u8 *value)
-{
-       struct i2c_client *client = bdev->client;
-
-       if (!bdev->power_state) {
-               dev_err(&bdev->client->dev, "bcm2048: chip not powered!\n");
-               return -EIO;
-       }
-
-       value[0] = i2c_smbus_read_byte_data(client, reg & 0xff);
-
-       return 0;
-}
-
-static int bcm2048_recv_duples(struct bcm2048_device *bdev, unsigned int reg,
-                              u8 *value, u8 duples)
-{
-       struct i2c_client *client = bdev->client;
-       struct i2c_adapter *adap = client->adapter;
-       struct i2c_msg msg[2];
-       u8 buf;
-
-       if (!bdev->power_state) {
-               dev_err(&bdev->client->dev, "bcm2048: chip not powered!\n");
-               return -EIO;
-       }
-
-       buf = reg & 0xff;
-
-       msg[0].addr = client->addr;
-       msg[0].flags = client->flags & I2C_M_TEN;
-       msg[0].len = 1;
-       msg[0].buf = &buf;
-
-       msg[1].addr = client->addr;
-       msg[1].flags = client->flags & I2C_M_TEN;
-       msg[1].flags |= I2C_M_RD;
-       msg[1].len = duples;
-       msg[1].buf = value;
-
-       return i2c_transfer(adap, msg, 2);
-}
-
-/*
- *     BCM2048 - I2C register programming helpers
- */
-static int bcm2048_set_power_state(struct bcm2048_device *bdev, u8 power)
-{
-       int err = 0;
-
-       mutex_lock(&bdev->mutex);
-
-       if (power) {
-               bdev->power_state = BCM2048_POWER_ON;
-               bdev->cache_fm_rds_system |= BCM2048_FM_ON;
-       } else {
-               bdev->cache_fm_rds_system &= ~BCM2048_FM_ON;
-       }
-
-       /*
-        * Warning! FM cannot be turned off because then
-        * the I2C communications get ruined!
-        * Comment off the "if (power)" when the chip works!
-        */
-       if (power)
-               err = bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_SYSTEM,
-                                          bdev->cache_fm_rds_system);
-       msleep(BCM2048_DEFAULT_POWERING_DELAY);
-
-       if (!power)
-               bdev->power_state = BCM2048_POWER_OFF;
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_power_state(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_RDS_SYSTEM, &value);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err && (value & BCM2048_FM_ON))
-               return BCM2048_POWER_ON;
-
-       return err;
-}
-
-static int bcm2048_set_rds_no_lock(struct bcm2048_device *bdev, u8 rds_on)
-{
-       int err;
-       u8 flags;
-
-       bdev->cache_fm_rds_system &= ~BCM2048_RDS_ON;
-
-       if (rds_on) {
-               bdev->cache_fm_rds_system |= BCM2048_RDS_ON;
-               bdev->rds_state = BCM2048_RDS_ON;
-               flags = BCM2048_RDS_FLAG_FIFO_WLINE;
-               err = bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_MASK1,
-                                          flags);
-       } else {
-               flags = 0;
-               bdev->rds_state = 0;
-               err = bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_MASK1,
-                                          flags);
-               memset(&bdev->rds_info, 0, sizeof(bdev->rds_info));
-       }
-       if (err)
-               return err;
-
-       return bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_SYSTEM,
-                                   bdev->cache_fm_rds_system);
-}
-
-static int bcm2048_get_rds_no_lock(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value;
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_RDS_SYSTEM, &value);
-
-       if (!err && (value & BCM2048_RDS_ON))
-               return BCM2048_ITEM_ENABLED;
-
-       return err;
-}
-
-static int bcm2048_set_rds(struct bcm2048_device *bdev, u8 rds_on)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_set_rds_no_lock(bdev, rds_on);
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_rds(struct bcm2048_device *bdev)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_get_rds_no_lock(bdev);
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_rds_pi(struct bcm2048_device *bdev)
-{
-       return bdev->rds_info.rds_pi;
-}
-
-static int bcm2048_set_fm_automatic_stereo_mono(struct bcm2048_device *bdev,
-                                               u8 enabled)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       bdev->cache_fm_ctrl &= ~BCM2048_STEREO_MONO_AUTO_SELECT;
-
-       if (enabled)
-               bdev->cache_fm_ctrl |= BCM2048_STEREO_MONO_AUTO_SELECT;
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_CTRL,
-                                  bdev->cache_fm_ctrl);
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_set_fm_hi_lo_injection(struct bcm2048_device *bdev,
-                                         u8 hi_lo)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       bdev->cache_fm_ctrl &= ~BCM2048_HI_LO_INJECTION;
-
-       if (hi_lo)
-               bdev->cache_fm_ctrl |= BCM2048_HI_LO_INJECTION;
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_CTRL,
-                                  bdev->cache_fm_ctrl);
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_fm_hi_lo_injection(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_CTRL, &value);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err && (value & BCM2048_HI_LO_INJECTION))
-               return BCM2048_ITEM_ENABLED;
-
-       return err;
-}
-
-static int bcm2048_set_fm_frequency(struct bcm2048_device *bdev, u32 frequency)
-{
-       int err;
-
-       if (frequency < bdev->region_info.bottom_frequency ||
-           frequency > bdev->region_info.top_frequency)
-               return -EDOM;
-
-       frequency -= BCM2048_FREQUENCY_BASE;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_FREQ0, lsb(frequency));
-       err |= bcm2048_send_command(bdev, BCM2048_I2C_FM_FREQ1,
-                                   msb(frequency));
-
-       if (!err)
-               bdev->frequency = frequency;
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_fm_frequency(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 lsb = 0, msb = 0;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_FREQ0, &lsb);
-       err |= bcm2048_recv_command(bdev, BCM2048_I2C_FM_FREQ1, &msb);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (err)
-               return err;
-
-       err = compose_u16(msb, lsb);
-       err += BCM2048_FREQUENCY_BASE;
-
-       return err;
-}
-
-static int bcm2048_set_fm_af_frequency(struct bcm2048_device *bdev,
-                                      u32 frequency)
-{
-       int err;
-
-       if (frequency < bdev->region_info.bottom_frequency ||
-           frequency > bdev->region_info.top_frequency)
-               return -EDOM;
-
-       frequency -= BCM2048_FREQUENCY_BASE;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_AF_FREQ0,
-                                  lsb(frequency));
-       err |= bcm2048_send_command(bdev, BCM2048_I2C_FM_AF_FREQ1,
-                                   msb(frequency));
-       if (!err)
-               bdev->frequency = frequency;
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_fm_af_frequency(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 lsb = 0, msb = 0;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_AF_FREQ0, &lsb);
-       err |= bcm2048_recv_command(bdev, BCM2048_I2C_FM_AF_FREQ1, &msb);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (err)
-               return err;
-
-       err = compose_u16(msb, lsb);
-       err += BCM2048_FREQUENCY_BASE;
-
-       return err;
-}
-
-static int bcm2048_set_fm_deemphasis(struct bcm2048_device *bdev, int d)
-{
-       int err;
-       u8 deemphasis;
-
-       if (d == BCM2048_DE_EMPHASIS_75us)
-               deemphasis = BCM2048_DE_EMPHASIS_SELECT;
-       else
-               deemphasis = 0;
-
-       mutex_lock(&bdev->mutex);
-
-       bdev->cache_fm_audio_ctrl0 &= ~BCM2048_DE_EMPHASIS_SELECT;
-       bdev->cache_fm_audio_ctrl0 |= deemphasis;
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0,
-                                  bdev->cache_fm_audio_ctrl0);
-
-       if (!err)
-               bdev->region_info.deemphasis = d;
-
-       mutex_unlock(&bdev->mutex);
-
-       return err;
-}
-
-static int bcm2048_get_fm_deemphasis(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0, &value);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err) {
-               if (value & BCM2048_DE_EMPHASIS_SELECT)
-                       return BCM2048_DE_EMPHASIS_75us;
-
-               return BCM2048_DE_EMPHASIS_50us;
-       }
-
-       return err;
-}
-
-static int bcm2048_set_region(struct bcm2048_device *bdev, u8 region)
-{
-       int err;
-       u32 new_frequency = 0;
-
-       if (region >= ARRAY_SIZE(region_configs))
-               return -EINVAL;
-
-       mutex_lock(&bdev->mutex);
-       bdev->region_info = region_configs[region];
-
-       if (region_configs[region].bottom_frequency < 87500)
-               bdev->cache_fm_ctrl |= BCM2048_BAND_SELECT;
-       else
-               bdev->cache_fm_ctrl &= ~BCM2048_BAND_SELECT;
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_CTRL,
-                                  bdev->cache_fm_ctrl);
-       if (err) {
-               mutex_unlock(&bdev->mutex);
-               goto done;
-       }
-       mutex_unlock(&bdev->mutex);
-
-       if (bdev->frequency < region_configs[region].bottom_frequency ||
-           bdev->frequency > region_configs[region].top_frequency)
-               new_frequency = region_configs[region].bottom_frequency;
-
-       if (new_frequency > 0) {
-               err = bcm2048_set_fm_frequency(bdev, new_frequency);
-
-               if (err)
-                       goto done;
-       }
-
-       err = bcm2048_set_fm_deemphasis(bdev,
-                                       region_configs[region].deemphasis);
-
-done:
-       return err;
-}
-
-static int bcm2048_get_region(struct bcm2048_device *bdev)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-       err = bdev->region_info.region;
-       mutex_unlock(&bdev->mutex);
-
-       return err;
-}
-
-static int bcm2048_set_mute(struct bcm2048_device *bdev, u16 mute)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       bdev->cache_fm_audio_ctrl0 &= ~(BCM2048_RF_MUTE | BCM2048_MANUAL_MUTE);
-
-       if (mute)
-               bdev->cache_fm_audio_ctrl0 |= (BCM2048_RF_MUTE |
-                                              BCM2048_MANUAL_MUTE);
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0,
-                                  bdev->cache_fm_audio_ctrl0);
-
-       if (!err)
-               bdev->mute_state = mute;
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_mute(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value;
-
-       mutex_lock(&bdev->mutex);
-
-       if (bdev->power_state) {
-               err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0,
-                                          &value);
-               if (!err)
-                       err = value & (BCM2048_RF_MUTE | BCM2048_MANUAL_MUTE);
-       } else {
-               err = bdev->mute_state;
-       }
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_set_audio_route(struct bcm2048_device *bdev, u8 route)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       route &= (BCM2048_AUDIO_ROUTE_DAC | BCM2048_AUDIO_ROUTE_I2S);
-       bdev->cache_fm_audio_ctrl0 &= ~(BCM2048_AUDIO_ROUTE_DAC |
-                                       BCM2048_AUDIO_ROUTE_I2S);
-       bdev->cache_fm_audio_ctrl0 |= route;
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0,
-                                  bdev->cache_fm_audio_ctrl0);
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_audio_route(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0, &value);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err)
-               return value & (BCM2048_AUDIO_ROUTE_DAC |
-                               BCM2048_AUDIO_ROUTE_I2S);
-
-       return err;
-}
-
-static int bcm2048_set_dac_output(struct bcm2048_device *bdev, u8 channels)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       bdev->cache_fm_audio_ctrl0 &= ~(BCM2048_DAC_OUTPUT_LEFT |
-                                       BCM2048_DAC_OUTPUT_RIGHT);
-       bdev->cache_fm_audio_ctrl0 |= channels;
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0,
-                                  bdev->cache_fm_audio_ctrl0);
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_dac_output(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_AUDIO_CTRL0, &value);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err)
-               return value & (BCM2048_DAC_OUTPUT_LEFT |
-                               BCM2048_DAC_OUTPUT_RIGHT);
-
-       return err;
-}
-
-static int bcm2048_set_fm_search_rssi_threshold(struct bcm2048_device *bdev,
-                                               u8 threshold)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       threshold &= BCM2048_SEARCH_RSSI_THRESHOLD;
-       bdev->cache_fm_search_ctrl0 &= ~BCM2048_SEARCH_RSSI_THRESHOLD;
-       bdev->cache_fm_search_ctrl0 |= threshold;
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_SEARCH_CTRL0,
-                                  bdev->cache_fm_search_ctrl0);
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_fm_search_rssi_threshold(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_SEARCH_CTRL0, &value);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err)
-               return value & BCM2048_SEARCH_RSSI_THRESHOLD;
-
-       return err;
-}
-
-static int bcm2048_set_fm_search_mode_direction(struct bcm2048_device *bdev,
-                                               u8 direction)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       bdev->cache_fm_search_ctrl0 &= ~BCM2048_SEARCH_DIRECTION;
-
-       if (direction)
-               bdev->cache_fm_search_ctrl0 |= BCM2048_SEARCH_DIRECTION;
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_SEARCH_CTRL0,
-                                  bdev->cache_fm_search_ctrl0);
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_fm_search_mode_direction(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_SEARCH_CTRL0, &value);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err && (value & BCM2048_SEARCH_DIRECTION))
-               return BCM2048_SEARCH_DIRECTION_UP;
-
-       return err;
-}
-
-static int bcm2048_set_fm_search_tune_mode(struct bcm2048_device *bdev,
-                                          u8 mode)
-{
-       int err, timeout, restart_rds = 0;
-       u8 value, flags;
-
-       value = mode & BCM2048_FM_AUTO_SEARCH;
-
-       flags = BCM2048_FM_FLAG_SEARCH_TUNE_FINISHED |
-               BCM2048_FM_FLAG_SEARCH_TUNE_FAIL;
-
-       mutex_lock(&bdev->mutex);
-
-       /*
-        * If RDS is enabled, and frequency is changed, RDS quits working.
-        * Thus, always restart RDS if it's enabled. Moreover, RDS must
-        * not be enabled while changing the frequency because it can
-        * provide a race to the mutex from the workqueue handler if RDS
-        * IRQ occurs while waiting for frequency changed IRQ.
-        */
-       if (bcm2048_get_rds_no_lock(bdev)) {
-               err = bcm2048_set_rds_no_lock(bdev, 0);
-               if (err)
-                       goto unlock;
-               restart_rds = 1;
-       }
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_MASK0, flags);
-
-       if (err)
-               goto unlock;
-
-       bcm2048_send_command(bdev, BCM2048_I2C_FM_SEARCH_TUNE_MODE, value);
-
-       if (mode != BCM2048_FM_AUTO_SEARCH_MODE)
-               timeout = BCM2048_DEFAULT_TIMEOUT;
-       else
-               timeout = BCM2048_AUTO_SEARCH_TIMEOUT;
-
-       if (!wait_for_completion_timeout(&bdev->compl,
-                                        msecs_to_jiffies(timeout)))
-               dev_err(&bdev->client->dev, "IRQ timeout.\n");
-
-       if (value)
-               if (!bdev->scan_state)
-                       err = -EIO;
-
-unlock:
-       if (restart_rds)
-               err |= bcm2048_set_rds_no_lock(bdev, 1);
-
-       mutex_unlock(&bdev->mutex);
-
-       return err;
-}
-
-static int bcm2048_get_fm_search_tune_mode(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_SEARCH_TUNE_MODE,
-                                  &value);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err)
-               return value & BCM2048_FM_AUTO_SEARCH;
-
-       return err;
-}
-
-static int bcm2048_set_rds_b_block_mask(struct bcm2048_device *bdev, u16 mask)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_RDS_BLKB_MASK0,
-                                  lsb(mask));
-       err |= bcm2048_send_command(bdev, BCM2048_I2C_RDS_BLKB_MASK1,
-                                   msb(mask));
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_rds_b_block_mask(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 lsb = 0, msb = 0;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_RDS_BLKB_MASK0, &lsb);
-       err |= bcm2048_recv_command(bdev, BCM2048_I2C_RDS_BLKB_MASK1, &msb);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err)
-               return compose_u16(msb, lsb);
-
-       return err;
-}
-
-static int bcm2048_set_rds_b_block_match(struct bcm2048_device *bdev,
-                                        u16 match)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_RDS_BLKB_MATCH0,
-                                  lsb(match));
-       err |= bcm2048_send_command(bdev, BCM2048_I2C_RDS_BLKB_MATCH1,
-                                   msb(match));
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_rds_b_block_match(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 lsb = 0, msb = 0;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_RDS_BLKB_MATCH0, &lsb);
-       err |= bcm2048_recv_command(bdev, BCM2048_I2C_RDS_BLKB_MATCH1, &msb);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err)
-               return compose_u16(msb, lsb);
-
-       return err;
-}
-
-static int bcm2048_set_rds_pi_mask(struct bcm2048_device *bdev, u16 mask)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_RDS_PI_MASK0, lsb(mask));
-       err |= bcm2048_send_command(bdev, BCM2048_I2C_RDS_PI_MASK1, msb(mask));
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_rds_pi_mask(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 lsb = 0, msb = 0;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_RDS_PI_MASK0, &lsb);
-       err |= bcm2048_recv_command(bdev, BCM2048_I2C_RDS_PI_MASK1, &msb);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err)
-               return compose_u16(msb, lsb);
-
-       return err;
-}
-
-static int bcm2048_set_rds_pi_match(struct bcm2048_device *bdev, u16 match)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_RDS_PI_MATCH0,
-                                  lsb(match));
-       err |= bcm2048_send_command(bdev, BCM2048_I2C_RDS_PI_MATCH1,
-                                   msb(match));
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_rds_pi_match(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 lsb = 0, msb = 0;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_RDS_PI_MATCH0, &lsb);
-       err |= bcm2048_recv_command(bdev, BCM2048_I2C_RDS_PI_MATCH1, &msb);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err)
-               return compose_u16(msb, lsb);
-
-       return err;
-}
-
-static int bcm2048_set_fm_rds_mask(struct bcm2048_device *bdev, u16 mask)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_MASK0, lsb(mask));
-       err |= bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_MASK1, msb(mask));
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_fm_rds_mask(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value0 = 0, value1 = 0;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_RDS_MASK0, &value0);
-       err |= bcm2048_recv_command(bdev, BCM2048_I2C_FM_RDS_MASK1, &value1);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err)
-               return compose_u16(value1, value0);
-
-       return err;
-}
-
-static int bcm2048_get_fm_rds_flags(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value0 = 0, value1 = 0;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_RDS_FLAG0, &value0);
-       err |= bcm2048_recv_command(bdev, BCM2048_I2C_FM_RDS_FLAG1, &value1);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err)
-               return compose_u16(value1, value0);
-
-       return err;
-}
-
-static int bcm2048_get_region_bottom_frequency(struct bcm2048_device *bdev)
-{
-       return bdev->region_info.bottom_frequency;
-}
-
-static int bcm2048_get_region_top_frequency(struct bcm2048_device *bdev)
-{
-       return bdev->region_info.top_frequency;
-}
-
-static int bcm2048_set_fm_best_tune_mode(struct bcm2048_device *bdev, u8 mode)
-{
-       int err;
-       u8 value = 0;
-
-       mutex_lock(&bdev->mutex);
-
-       /* Perform read as the manual indicates */
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_BEST_TUNE_MODE,
-                                  &value);
-       value &= ~BCM2048_BEST_TUNE_MODE;
-
-       if (mode)
-               value |= BCM2048_BEST_TUNE_MODE;
-       err |= bcm2048_send_command(bdev, BCM2048_I2C_FM_BEST_TUNE_MODE,
-                                   value);
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_fm_best_tune_mode(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_BEST_TUNE_MODE,
-                                  &value);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err && (value & BCM2048_BEST_TUNE_MODE))
-               return BCM2048_ITEM_ENABLED;
-
-       return err;
-}
-
-static int bcm2048_get_fm_carrier_error(struct bcm2048_device *bdev)
-{
-       int err = 0;
-       s8 value;
-
-       mutex_lock(&bdev->mutex);
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_CARRIER, &value);
-       mutex_unlock(&bdev->mutex);
-
-       if (!err)
-               return value;
-
-       return err;
-}
-
-static int bcm2048_get_fm_rssi(struct bcm2048_device *bdev)
-{
-       int err;
-       s8 value;
-
-       mutex_lock(&bdev->mutex);
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_RSSI, &value);
-       mutex_unlock(&bdev->mutex);
-
-       if (!err)
-               return value;
-
-       return err;
-}
-
-static int bcm2048_set_rds_wline(struct bcm2048_device *bdev, u8 wline)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_send_command(bdev, BCM2048_I2C_RDS_WLINE, wline);
-
-       if (!err)
-               bdev->fifo_size = wline;
-
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_rds_wline(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 value;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_RDS_WLINE, &value);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err) {
-               bdev->fifo_size = value;
-               return value;
-       }
-
-       return err;
-}
-
-static int bcm2048_checkrev(struct bcm2048_device *bdev)
-{
-       int err;
-       u8 version;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_command(bdev, BCM2048_I2C_FM_RDS_REV, &version);
-
-       mutex_unlock(&bdev->mutex);
-
-       if (!err) {
-               dev_info(&bdev->client->dev, "BCM2048 Version 0x%x\n",
-                        version);
-               return version;
-       }
-
-       return err;
-}
-
-static int bcm2048_get_rds_rt(struct bcm2048_device *bdev, char *data)
-{
-       int err = 0, i, j = 0, ce = 0, cr = 0;
-       char data_buffer[BCM2048_MAX_RDS_RT + 1];
-
-       mutex_lock(&bdev->mutex);
-
-       if (!bdev->rds_info.text_len) {
-               err = -EINVAL;
-               goto unlock;
-       }
-
-       for (i = 0; i < BCM2048_MAX_RDS_RT; i++) {
-               if (bdev->rds_info.rds_rt[i]) {
-                       ce = i;
-                       /* Skip the carriage return */
-                       if (bdev->rds_info.rds_rt[i] != 0x0d) {
-                               data_buffer[j++] = bdev->rds_info.rds_rt[i];
-                       } else {
-                               cr = i;
-                               break;
-                       }
-               }
-       }
-
-       if (j <= BCM2048_MAX_RDS_RT)
-               data_buffer[j] = 0;
-
-       for (i = 0; i < BCM2048_MAX_RDS_RT; i++) {
-               if (!bdev->rds_info.rds_rt[i]) {
-                       if (cr && (i < cr)) {
-                               err = -EBUSY;
-                               goto unlock;
-                       }
-                       if (i < ce) {
-                               if (cr && (i >= cr))
-                                       break;
-                               err = -EBUSY;
-                               goto unlock;
-                       }
-               }
-       }
-
-       memcpy(data, data_buffer, sizeof(data_buffer));
-
-unlock:
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static int bcm2048_get_rds_ps(struct bcm2048_device *bdev, char *data)
-{
-       int err = 0, i, j = 0;
-       char data_buffer[BCM2048_MAX_RDS_PS + 1];
-
-       mutex_lock(&bdev->mutex);
-
-       if (!bdev->rds_info.text_len) {
-               err = -EINVAL;
-               goto unlock;
-       }
-
-       for (i = 0; i < BCM2048_MAX_RDS_PS; i++) {
-               if (bdev->rds_info.rds_ps[i]) {
-                       data_buffer[j++] = bdev->rds_info.rds_ps[i];
-               } else {
-                       if (i < (BCM2048_MAX_RDS_PS - 1)) {
-                               err = -EBUSY;
-                               goto unlock;
-                       }
-               }
-       }
-
-       if (j <= BCM2048_MAX_RDS_PS)
-               data_buffer[j] = 0;
-
-       memcpy(data, data_buffer, sizeof(data_buffer));
-
-unlock:
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-static void bcm2048_parse_rds_pi(struct bcm2048_device *bdev)
-{
-       int i, cnt = 0;
-       u16 pi;
-
-       for (i = 0; i < bdev->fifo_size; i += BCM2048_RDS_FIFO_DUPLE_SIZE) {
-               /* Block A match, only data without crc errors taken */
-               if (bdev->rds_info.radio_text[i] == BCM2048_RDS_BLOCK_A) {
-                       pi = (bdev->rds_info.radio_text[i + 1] << 8) +
-                               bdev->rds_info.radio_text[i + 2];
-
-                       if (!bdev->rds_info.rds_pi) {
-                               bdev->rds_info.rds_pi = pi;
-                               return;
-                       }
-                       if (pi != bdev->rds_info.rds_pi) {
-                               cnt++;
-                               if (cnt > 3) {
-                                       bdev->rds_info.rds_pi = pi;
-                                       cnt = 0;
-                               }
-                       } else {
-                               cnt = 0;
-                       }
-               }
-       }
-}
-
-static int bcm2048_rds_block_crc(struct bcm2048_device *bdev, int i)
-{
-       return bdev->rds_info.radio_text[i] & BCM2048_RDS_CRC_MASK;
-}
-
-static void bcm2048_parse_rds_rt_block(struct bcm2048_device *bdev, int i,
-                                      int index, int crc)
-{
-       /* Good data will overwrite poor data */
-       if (crc) {
-               if (!bdev->rds_info.rds_rt[index])
-                       bdev->rds_info.rds_rt[index] =
-                               bdev->rds_info.radio_text[i + 1];
-               if (!bdev->rds_info.rds_rt[index + 1])
-                       bdev->rds_info.rds_rt[index + 1] =
-                               bdev->rds_info.radio_text[i + 2];
-       } else {
-               bdev->rds_info.rds_rt[index] =
-                       bdev->rds_info.radio_text[i + 1];
-               bdev->rds_info.rds_rt[index + 1] =
-                       bdev->rds_info.radio_text[i + 2];
-       }
-}
-
-static int bcm2048_parse_rt_match_b(struct bcm2048_device *bdev, int i)
-{
-       int crc, rt_id, rt_group_b, rt_ab, index = 0;
-
-       crc = bcm2048_rds_block_crc(bdev, i);
-
-       if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
-               return -EIO;
-
-       if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
-           BCM2048_RDS_BLOCK_B) {
-               rt_id = bdev->rds_info.radio_text[i + 1] &
-                       BCM2048_RDS_BLOCK_MASK;
-               rt_group_b = bdev->rds_info.radio_text[i + 1] &
-                       BCM2048_RDS_GROUP_AB_MASK;
-               rt_ab = bdev->rds_info.radio_text[i + 2] &
-                               BCM2048_RDS_RT_AB_MASK;
-
-               if (rt_group_b != bdev->rds_info.rds_rt_group_b) {
-                       memset(bdev->rds_info.rds_rt, 0,
-                              sizeof(bdev->rds_info.rds_rt));
-                       bdev->rds_info.rds_rt_group_b = rt_group_b;
-               }
-
-               if (rt_id == BCM2048_RDS_RT) {
-                       /* A to B or (vice versa), means: clear screen */
-                       if (rt_ab != bdev->rds_info.rds_rt_ab) {
-                               memset(bdev->rds_info.rds_rt, 0,
-                                      sizeof(bdev->rds_info.rds_rt));
-                               bdev->rds_info.rds_rt_ab = rt_ab;
-                       }
-
-                       index = bdev->rds_info.radio_text[i + 2] &
-                                       BCM2048_RDS_RT_INDEX;
-
-                       if (bdev->rds_info.rds_rt_group_b)
-                               index <<= 1;
-                       else
-                               index <<= 2;
-
-                       return index;
-               }
-       }
-
-       return -EIO;
-}
-
-static int bcm2048_parse_rt_match_c(struct bcm2048_device *bdev, int i,
-                                   int index)
-{
-       int crc;
-
-       crc = bcm2048_rds_block_crc(bdev, i);
-
-       if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
-               return 0;
-
-       if ((index + 2) >= BCM2048_MAX_RDS_RT) {
-               dev_err(&bdev->client->dev,
-                       "Incorrect index = %d\n", index);
-               return 0;
-       }
-
-       if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
-               BCM2048_RDS_BLOCK_C) {
-               if (bdev->rds_info.rds_rt_group_b)
-                       return 1;
-               bcm2048_parse_rds_rt_block(bdev, i, index, crc);
-               return 1;
-       }
-
-       return 0;
-}
-
-static void bcm2048_parse_rt_match_d(struct bcm2048_device *bdev, int i,
-                                    int index)
-{
-       int crc;
-
-       crc = bcm2048_rds_block_crc(bdev, i);
-
-       if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
-               return;
-
-       if ((index + 4) >= BCM2048_MAX_RDS_RT) {
-               dev_err(&bdev->client->dev,
-                       "Incorrect index = %d\n", index);
-               return;
-       }
-
-       if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
-           BCM2048_RDS_BLOCK_D)
-               bcm2048_parse_rds_rt_block(bdev, i, index + 2, crc);
-}
-
-static void bcm2048_parse_rds_rt(struct bcm2048_device *bdev)
-{
-       int i, index = 0, crc, match_b = 0, match_c = 0, match_d = 0;
-
-       for (i = 0; i < bdev->fifo_size; i += BCM2048_RDS_FIFO_DUPLE_SIZE) {
-               if (match_b) {
-                       match_b = 0;
-                       index = bcm2048_parse_rt_match_b(bdev, i);
-                       if (index >= 0 && index <= (BCM2048_MAX_RDS_RT - 5))
-                               match_c = 1;
-                       continue;
-               } else if (match_c) {
-                       match_c = 0;
-                       if (bcm2048_parse_rt_match_c(bdev, i, index))
-                               match_d = 1;
-                       continue;
-               } else if (match_d) {
-                       match_d = 0;
-                       bcm2048_parse_rt_match_d(bdev, i, index);
-                       continue;
-               }
-
-               /* Skip erroneous blocks due to messed up A block altogether */
-               if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
-                   BCM2048_RDS_BLOCK_A) {
-                       crc = bcm2048_rds_block_crc(bdev, i);
-                       if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
-                               continue;
-                       /* Synchronize to a good RDS PI */
-                       if (((bdev->rds_info.radio_text[i + 1] << 8) +
-                           bdev->rds_info.radio_text[i + 2]) ==
-                           bdev->rds_info.rds_pi)
-                               match_b = 1;
-               }
-       }
-}
-
-static void bcm2048_parse_rds_ps_block(struct bcm2048_device *bdev, int i,
-                                      int index, int crc)
-{
-       /* Good data will overwrite poor data */
-       if (crc) {
-               if (!bdev->rds_info.rds_ps[index])
-                       bdev->rds_info.rds_ps[index] =
-                               bdev->rds_info.radio_text[i + 1];
-               if (!bdev->rds_info.rds_ps[index + 1])
-                       bdev->rds_info.rds_ps[index + 1] =
-                               bdev->rds_info.radio_text[i + 2];
-       } else {
-               bdev->rds_info.rds_ps[index] =
-                       bdev->rds_info.radio_text[i + 1];
-               bdev->rds_info.rds_ps[index + 1] =
-                       bdev->rds_info.radio_text[i + 2];
-       }
-}
-
-static int bcm2048_parse_ps_match_c(struct bcm2048_device *bdev, int i,
-                                   int index)
-{
-       int crc;
-
-       crc = bcm2048_rds_block_crc(bdev, i);
-
-       if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
-               return 0;
-
-       if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
-           BCM2048_RDS_BLOCK_C)
-               return 1;
-
-       return 0;
-}
-
-static void bcm2048_parse_ps_match_d(struct bcm2048_device *bdev, int i,
-                                    int index)
-{
-       int crc;
-
-       crc = bcm2048_rds_block_crc(bdev, i);
-
-       if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
-               return;
-
-       if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
-           BCM2048_RDS_BLOCK_D)
-               bcm2048_parse_rds_ps_block(bdev, i, index, crc);
-}
-
-static int bcm2048_parse_ps_match_b(struct bcm2048_device *bdev, int i)
-{
-       int crc, index, ps_id, ps_group;
-
-       crc = bcm2048_rds_block_crc(bdev, i);
-
-       if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
-               return -EIO;
-
-       /* Block B Radio PS match */
-       if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
-           BCM2048_RDS_BLOCK_B) {
-               ps_id = bdev->rds_info.radio_text[i + 1] &
-                       BCM2048_RDS_BLOCK_MASK;
-               ps_group = bdev->rds_info.radio_text[i + 1] &
-                       BCM2048_RDS_GROUP_AB_MASK;
-
-               /*
-                * Poor RSSI will lead to RDS data corruption
-                * So using 3 (same) sequential values to justify major changes
-                */
-               if (ps_group != bdev->rds_info.rds_ps_group) {
-                       if (crc == BCM2048_RDS_CRC_NONE) {
-                               bdev->rds_info.rds_ps_group_cnt++;
-                               if (bdev->rds_info.rds_ps_group_cnt > 2) {
-                                       bdev->rds_info.rds_ps_group = ps_group;
-                                       bdev->rds_info.rds_ps_group_cnt = 0;
-                                       dev_err(&bdev->client->dev,
-                                               "RDS PS Group change!\n");
-                               } else {
-                                       return -EIO;
-                               }
-                       } else {
-                               bdev->rds_info.rds_ps_group_cnt = 0;
-                       }
-               }
-
-               if (ps_id == BCM2048_RDS_PS) {
-                       index = bdev->rds_info.radio_text[i + 2] &
-                               BCM2048_RDS_PS_INDEX;
-                       index <<= 1;
-                       return index;
-               }
-       }
-
-       return -EIO;
-}
-
-static void bcm2048_parse_rds_ps(struct bcm2048_device *bdev)
-{
-       int i, index = 0, crc, match_b = 0, match_c = 0, match_d = 0;
-
-       for (i = 0; i < bdev->fifo_size; i += BCM2048_RDS_FIFO_DUPLE_SIZE) {
-               if (match_b) {
-                       match_b = 0;
-                       index = bcm2048_parse_ps_match_b(bdev, i);
-                       if (index >= 0 && index < (BCM2048_MAX_RDS_PS - 1))
-                               match_c = 1;
-                       continue;
-               } else if (match_c) {
-                       match_c = 0;
-                       if (bcm2048_parse_ps_match_c(bdev, i, index))
-                               match_d = 1;
-                       continue;
-               } else if (match_d) {
-                       match_d = 0;
-                       bcm2048_parse_ps_match_d(bdev, i, index);
-                       continue;
-               }
-
-               /* Skip erroneous blocks due to messed up A block altogether */
-               if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
-                   BCM2048_RDS_BLOCK_A) {
-                       crc = bcm2048_rds_block_crc(bdev, i);
-                       if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
-                               continue;
-                       /* Synchronize to a good RDS PI */
-                       if (((bdev->rds_info.radio_text[i + 1] << 8) +
-                           bdev->rds_info.radio_text[i + 2]) ==
-                           bdev->rds_info.rds_pi)
-                               match_b = 1;
-               }
-       }
-}
-
-static void bcm2048_rds_fifo_receive(struct bcm2048_device *bdev)
-{
-       int err;
-
-       mutex_lock(&bdev->mutex);
-
-       err = bcm2048_recv_duples(bdev, BCM2048_I2C_RDS_DATA,
-                                 bdev->rds_info.radio_text, bdev->fifo_size);
-       if (err != 2) {
-               dev_err(&bdev->client->dev, "RDS Read problem\n");
-               mutex_unlock(&bdev->mutex);
-               return;
-       }
-
-       bdev->rds_info.text_len = bdev->fifo_size;
-
-       bcm2048_parse_rds_pi(bdev);
-       bcm2048_parse_rds_rt(bdev);
-       bcm2048_parse_rds_ps(bdev);
-
-       mutex_unlock(&bdev->mutex);
-
-       wake_up_interruptible(&bdev->read_queue);
-}
-
-static int bcm2048_get_rds_data(struct bcm2048_device *bdev, char *data)
-{
-       int err = 0, i, p = 0;
-       char *data_buffer;
-
-       mutex_lock(&bdev->mutex);
-
-       if (!bdev->rds_info.text_len) {
-               err = -EINVAL;
-               goto unlock;
-       }
-
-       data_buffer = kcalloc(BCM2048_MAX_RDS_RADIO_TEXT, 5, GFP_KERNEL);
-       if (!data_buffer) {
-               err = -ENOMEM;
-               goto unlock;
-       }
-
-       for (i = 0; i < bdev->rds_info.text_len; i++) {
-               p += sprintf(data_buffer + p, "%x ",
-                            bdev->rds_info.radio_text[i]);
-       }
-
-       memcpy(data, data_buffer, p);
-       kfree(data_buffer);
-
-unlock:
-       mutex_unlock(&bdev->mutex);
-       return err;
-}
-
-/*
- *     BCM2048 default initialization sequence
- */
-static int bcm2048_init(struct bcm2048_device *bdev)
-{
-       int err;
-
-       err = bcm2048_set_power_state(bdev, BCM2048_POWER_ON);
-       if (err < 0)
-               goto exit;
-
-       err = bcm2048_set_audio_route(bdev, BCM2048_AUDIO_ROUTE_DAC);
-       if (err < 0)
-               goto exit;
-
-       err = bcm2048_set_dac_output(bdev, BCM2048_DAC_OUTPUT_LEFT |
-                                    BCM2048_DAC_OUTPUT_RIGHT);
-
-exit:
-       return err;
-}
-
-/*
- *     BCM2048 default deinitialization sequence
- */
-static int bcm2048_deinit(struct bcm2048_device *bdev)
-{
-       int err;
-
-       err = bcm2048_set_audio_route(bdev, 0);
-       if (err < 0)
-               return err;
-
-       err = bcm2048_set_dac_output(bdev, 0);
-       if (err < 0)
-               return err;
-
-       return bcm2048_set_power_state(bdev, BCM2048_POWER_OFF);
-}
-
-/*
- *     BCM2048 probe sequence
- */
-static int bcm2048_probe(struct bcm2048_device *bdev)
-{
-       int err;
-
-       err = bcm2048_set_power_state(bdev, BCM2048_POWER_ON);
-       if (err < 0)
-               goto unlock;
-
-       err = bcm2048_checkrev(bdev);
-       if (err < 0)
-               goto unlock;
-
-       err = bcm2048_set_mute(bdev, BCM2048_DEFAULT_MUTE);
-       if (err < 0)
-               goto unlock;
-
-       err = bcm2048_set_region(bdev, BCM2048_DEFAULT_REGION);
-       if (err < 0)
-               goto unlock;
-
-       err = bcm2048_set_fm_search_rssi_threshold(bdev,
-                                       BCM2048_DEFAULT_RSSI_THRESHOLD);
-       if (err < 0)
-               goto unlock;
-
-       err = bcm2048_set_fm_automatic_stereo_mono(bdev, BCM2048_ITEM_ENABLED);
-       if (err < 0)
-               goto unlock;
-
-       err = bcm2048_get_rds_wline(bdev);
-       if (err < BCM2048_DEFAULT_RDS_WLINE)
-               err = bcm2048_set_rds_wline(bdev, BCM2048_DEFAULT_RDS_WLINE);
-       if (err < 0)
-               goto unlock;
-
-       err = bcm2048_set_power_state(bdev, BCM2048_POWER_OFF);
-
-       init_waitqueue_head(&bdev->read_queue);
-       bdev->rds_data_available = 0;
-       bdev->rd_index = 0;
-       bdev->users = 0;
-
-unlock:
-       return err;
-}
-
-/*
- *     BCM2048 workqueue handler
- */
-static void bcm2048_work(struct work_struct *work)
-{
-       struct bcm2048_device *bdev;
-       u8 flag_lsb = 0, flag_msb = 0, flags;
-
-       bdev = container_of(work, struct bcm2048_device, work);
-       bcm2048_recv_command(bdev, BCM2048_I2C_FM_RDS_FLAG0, &flag_lsb);
-       bcm2048_recv_command(bdev, BCM2048_I2C_FM_RDS_FLAG1, &flag_msb);
-
-       if (flag_lsb & (BCM2048_FM_FLAG_SEARCH_TUNE_FINISHED |
-                       BCM2048_FM_FLAG_SEARCH_TUNE_FAIL)) {
-               if (flag_lsb & BCM2048_FM_FLAG_SEARCH_TUNE_FAIL)
-                       bdev->scan_state = BCM2048_SCAN_FAIL;
-               else
-                       bdev->scan_state = BCM2048_SCAN_OK;
-
-               complete(&bdev->compl);
-       }
-
-       if (flag_msb & BCM2048_RDS_FLAG_FIFO_WLINE) {
-               bcm2048_rds_fifo_receive(bdev);
-               if (bdev->rds_state) {
-                       flags = BCM2048_RDS_FLAG_FIFO_WLINE;
-                       bcm2048_send_command(bdev, BCM2048_I2C_FM_RDS_MASK1,
-                                            flags);
-               }
-               bdev->rds_data_available = 1;
-               bdev->rd_index = 0; /* new data, new start */
-       }
-}
-
-/*
- *     BCM2048 interrupt handler
- */
-static irqreturn_t bcm2048_handler(int irq, void *dev)
-{
-       struct bcm2048_device *bdev = dev;
-
-       dev_dbg(&bdev->client->dev, "IRQ called, queuing work\n");
-       if (bdev->power_state)
-               schedule_work(&bdev->work);
-
-       return IRQ_HANDLED;
-}
-
-/*
- *     BCM2048 sysfs interface definitions
- */
-#define property_write(prop, type, mask, check)                                \
-static ssize_t bcm2048_##prop##_write(struct device *dev,              \
-                                       struct device_attribute *attr,  \
-                                       const char *buf,                \
-                                       size_t count)                   \
-{                                                                      \
-       struct bcm2048_device *bdev = dev_get_drvdata(dev);             \
-       type value;                                                     \
-       int err;                                                        \
-                                                                       \
-       if (!bdev)                                                      \
-               return -ENODEV;                                         \
-                                                                       \
-       if (sscanf(buf, mask, &value) != 1)                             \
-               return -EINVAL;                                         \
-                                                                       \
-       if (check)                                                      \
-               return -EDOM;                                           \
-                                                                       \
-       err = bcm2048_set_##prop(bdev, value);                          \
-                                                                       \
-       return err < 0 ? err : count;                                   \
-}
-
-#define property_read(prop, mask)                                      \
-static ssize_t bcm2048_##prop##_read(struct device *dev,               \
-                                       struct device_attribute *attr,  \
-                                       char *buf)                      \
-{                                                                      \
-       struct bcm2048_device *bdev = dev_get_drvdata(dev);             \
-       int value;                                                      \
-                                                                       \
-       if (!bdev)                                                      \
-               return -ENODEV;                                         \
-                                                                       \
-       value = bcm2048_get_##prop(bdev);                               \
-                                                                       \
-       if (value >= 0)                                                 \
-               value = sprintf(buf, mask "\n", value);                 \
-                                                                       \
-       return value;                                                   \
-}
-
-#define property_signed_read(prop, size, mask)                         \
-static ssize_t bcm2048_##prop##_read(struct device *dev,               \
-                                       struct device_attribute *attr,  \
-                                       char *buf)                      \
-{                                                                      \
-       struct bcm2048_device *bdev = dev_get_drvdata(dev);             \
-       size value;                                                     \
-                                                                       \
-       if (!bdev)                                                      \
-               return -ENODEV;                                         \
-                                                                       \
-       value = bcm2048_get_##prop(bdev);                               \
-                                                                       \
-       return sprintf(buf, mask "\n", value);                          \
-}
-
-#define DEFINE_SYSFS_PROPERTY(prop, prop_type, mask, check)            \
-property_write(prop, prop_type, mask, check)                           \
-property_read(prop, mask)                                              \
-
-#define property_str_read(prop, size)                                  \
-static ssize_t bcm2048_##prop##_read(struct device *dev,               \
-                                       struct device_attribute *attr,  \
-                                       char *buf)                      \
-{                                                                      \
-       struct bcm2048_device *bdev = dev_get_drvdata(dev);             \
-       int count;                                                      \
-       u8 *out;                                                        \
-                                                                       \
-       if (!bdev)                                                      \
-               return -ENODEV;                                         \
-                                                                       \
-       out = kzalloc((size) + 1, GFP_KERNEL);                          \
-       if (!out)                                                       \
-               return -ENOMEM;                                         \
-                                                                       \
-       bcm2048_get_##prop(bdev, out);                                  \
-       count = sprintf(buf, "%s\n", out);                              \
-                                                                       \
-       kfree(out);                                                     \
-                                                                       \
-       return count;                                                   \
-}
-
-DEFINE_SYSFS_PROPERTY(power_state, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(mute, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(audio_route, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(dac_output, unsigned int, "%u", 0)
-
-DEFINE_SYSFS_PROPERTY(fm_hi_lo_injection, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(fm_frequency, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(fm_af_frequency, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(fm_deemphasis, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(fm_rds_mask, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(fm_best_tune_mode, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(fm_search_rssi_threshold, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(fm_search_mode_direction, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(fm_search_tune_mode, unsigned int, "%u", value > 3)
-
-DEFINE_SYSFS_PROPERTY(rds, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(rds_b_block_mask, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(rds_b_block_match, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(rds_pi_mask, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(rds_pi_match, unsigned int, "%u", 0)
-DEFINE_SYSFS_PROPERTY(rds_wline, unsigned int, "%u", 0)
-property_read(rds_pi, "%x")
-property_str_read(rds_rt, (BCM2048_MAX_RDS_RT + 1))
-property_str_read(rds_ps, (BCM2048_MAX_RDS_PS + 1))
-
-property_read(fm_rds_flags, "%u")
-property_str_read(rds_data, BCM2048_MAX_RDS_RADIO_TEXT * 5)
-
-property_read(region_bottom_frequency, "%u")
-property_read(region_top_frequency, "%u")
-property_signed_read(fm_carrier_error, int, "%d")
-property_signed_read(fm_rssi, int, "%d")
-DEFINE_SYSFS_PROPERTY(region, unsigned int, "%u", 0)
-
-static struct device_attribute attrs[] = {
-       __ATTR(power_state, 0644, bcm2048_power_state_read,
-              bcm2048_power_state_write),
-       __ATTR(mute, 0644, bcm2048_mute_read,
-              bcm2048_mute_write),
-       __ATTR(audio_route, 0644, bcm2048_audio_route_read,
-              bcm2048_audio_route_write),
-       __ATTR(dac_output, 0644, bcm2048_dac_output_read,
-              bcm2048_dac_output_write),
-       __ATTR(fm_hi_lo_injection, 0644,
-              bcm2048_fm_hi_lo_injection_read,
-              bcm2048_fm_hi_lo_injection_write),
-       __ATTR(fm_frequency, 0644, bcm2048_fm_frequency_read,
-              bcm2048_fm_frequency_write),
-       __ATTR(fm_af_frequency, 0644,
-              bcm2048_fm_af_frequency_read,
-              bcm2048_fm_af_frequency_write),
-       __ATTR(fm_deemphasis, 0644, bcm2048_fm_deemphasis_read,
-              bcm2048_fm_deemphasis_write),
-       __ATTR(fm_rds_mask, 0644, bcm2048_fm_rds_mask_read,
-              bcm2048_fm_rds_mask_write),
-       __ATTR(fm_best_tune_mode, 0644,
-              bcm2048_fm_best_tune_mode_read,
-              bcm2048_fm_best_tune_mode_write),
-       __ATTR(fm_search_rssi_threshold, 0644,
-              bcm2048_fm_search_rssi_threshold_read,
-              bcm2048_fm_search_rssi_threshold_write),
-       __ATTR(fm_search_mode_direction, 0644,
-              bcm2048_fm_search_mode_direction_read,
-              bcm2048_fm_search_mode_direction_write),
-       __ATTR(fm_search_tune_mode, 0644,
-              bcm2048_fm_search_tune_mode_read,
-              bcm2048_fm_search_tune_mode_write),
-       __ATTR(rds, 0644, bcm2048_rds_read,
-              bcm2048_rds_write),
-       __ATTR(rds_b_block_mask, 0644,
-              bcm2048_rds_b_block_mask_read,
-              bcm2048_rds_b_block_mask_write),
-       __ATTR(rds_b_block_match, 0644,
-              bcm2048_rds_b_block_match_read,
-              bcm2048_rds_b_block_match_write),
-       __ATTR(rds_pi_mask, 0644, bcm2048_rds_pi_mask_read,
-              bcm2048_rds_pi_mask_write),
-       __ATTR(rds_pi_match, 0644, bcm2048_rds_pi_match_read,
-              bcm2048_rds_pi_match_write),
-       __ATTR(rds_wline, 0644, bcm2048_rds_wline_read,
-              bcm2048_rds_wline_write),
-       __ATTR(rds_pi, 0444, bcm2048_rds_pi_read, NULL),
-       __ATTR(rds_rt, 0444, bcm2048_rds_rt_read, NULL),
-       __ATTR(rds_ps, 0444, bcm2048_rds_ps_read, NULL),
-       __ATTR(fm_rds_flags, 0444, bcm2048_fm_rds_flags_read, NULL),
-       __ATTR(region_bottom_frequency, 0444,
-              bcm2048_region_bottom_frequency_read, NULL),
-       __ATTR(region_top_frequency, 0444,
-              bcm2048_region_top_frequency_read, NULL),
-       __ATTR(fm_carrier_error, 0444,
-              bcm2048_fm_carrier_error_read, NULL),
-       __ATTR(fm_rssi, 0444,
-              bcm2048_fm_rssi_read, NULL),
-       __ATTR(region, 0644, bcm2048_region_read,
-              bcm2048_region_write),
-       __ATTR(rds_data, 0444, bcm2048_rds_data_read, NULL),
-};
-
-static int bcm2048_sysfs_unregister_properties(struct bcm2048_device *bdev,
-                                              int size)
-{
-       int i;
-
-       for (i = 0; i < size; i++)
-               device_remove_file(&bdev->client->dev, &attrs[i]);
-
-       return 0;
-}
-
-static int bcm2048_sysfs_register_properties(struct bcm2048_device *bdev)
-{
-       int err = 0;
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(attrs); i++) {
-               if (device_create_file(&bdev->client->dev, &attrs[i]) != 0) {
-                       dev_err(&bdev->client->dev,
-                               "could not register sysfs entry\n");
-                       err = -EBUSY;
-                       bcm2048_sysfs_unregister_properties(bdev, i);
-                       break;
-               }
-       }
-
-       return err;
-}
-
-static int bcm2048_fops_open(struct file *file)
-{
-       struct bcm2048_device *bdev = video_drvdata(file);
-
-       bdev->users++;
-       bdev->rd_index = 0;
-       bdev->rds_data_available = 0;
-
-       return 0;
-}
-
-static int bcm2048_fops_release(struct file *file)
-{
-       struct bcm2048_device *bdev = video_drvdata(file);
-
-       bdev->users--;
-
-       return 0;
-}
-
-static __poll_t bcm2048_fops_poll(struct file *file,
-                                 struct poll_table_struct *pts)
-{
-       struct bcm2048_device *bdev = video_drvdata(file);
-       __poll_t retval = 0;
-
-       poll_wait(file, &bdev->read_queue, pts);
-
-       if (bdev->rds_data_available)
-               retval = EPOLLIN | EPOLLRDNORM;
-
-       return retval;
-}
-
-static ssize_t bcm2048_fops_read(struct file *file, char __user *buf,
-                                size_t count, loff_t *ppos)
-{
-       struct bcm2048_device *bdev = video_drvdata(file);
-       int i;
-       int retval = 0;
-
-       /* we return at least 3 bytes, one block */
-       count = (count / 3) * 3; /* only multiples of 3 */
-       if (count < 3)
-               return -ENOBUFS;
-
-       while (!bdev->rds_data_available) {
-               if (file->f_flags & O_NONBLOCK) {
-                       retval = -EWOULDBLOCK;
-                       goto done;
-               }
-               /* interruptible_sleep_on(&bdev->read_queue); */
-               if (wait_event_interruptible(bdev->read_queue,
-                                            bdev->rds_data_available) < 0) {
-                       retval = -EINTR;
-                       goto done;
-               }
-       }
-
-       mutex_lock(&bdev->mutex);
-       /* copy data to userspace */
-       i = bdev->fifo_size - bdev->rd_index;
-       if (count > i)
-               count = (i / 3) * 3;
-
-       i = 0;
-       while (i < count) {
-               unsigned char tmpbuf[3];
-
-               tmpbuf[i] = bdev->rds_info.radio_text[bdev->rd_index + i + 2];
-               tmpbuf[i + 1] =
-                       bdev->rds_info.radio_text[bdev->rd_index + i + 1];
-               tmpbuf[i + 2] =
-                       (bdev->rds_info.radio_text[bdev->rd_index + i] &
-                        0xf0) >> 4;
-               if ((bdev->rds_info.radio_text[bdev->rd_index + i] &
-                   BCM2048_RDS_CRC_MASK) == BCM2048_RDS_CRC_UNRECOVARABLE)
-                       tmpbuf[i + 2] |= 0x80;
-               if (copy_to_user(buf + i, tmpbuf, 3)) {
-                       retval = -EFAULT;
-                       break;
-               }
-               i += 3;
-       }
-
-       bdev->rd_index += i;
-       if (bdev->rd_index >= bdev->fifo_size)
-               bdev->rds_data_available = 0;
-
-       mutex_unlock(&bdev->mutex);
-       if (retval == 0)
-               retval = i;
-
-done:
-       return retval;
-}
-
-/*
- *     bcm2048_fops - file operations interface
- */
-static const struct v4l2_file_operations bcm2048_fops = {
-       .owner          = THIS_MODULE,
-       .unlocked_ioctl = video_ioctl2,
-       /* for RDS read support */
-       .open           = bcm2048_fops_open,
-       .release        = bcm2048_fops_release,
-       .read           = bcm2048_fops_read,
-       .poll           = bcm2048_fops_poll
-};
-
-/*
- *     Video4Linux Interface
- */
-static struct v4l2_queryctrl bcm2048_v4l2_queryctrl[] = {
-       {
-               .id             = V4L2_CID_AUDIO_VOLUME,
-               .flags          = V4L2_CTRL_FLAG_DISABLED,
-       },
-       {
-               .id             = V4L2_CID_AUDIO_BALANCE,
-               .flags          = V4L2_CTRL_FLAG_DISABLED,
-       },
-       {
-               .id             = V4L2_CID_AUDIO_BASS,
-               .flags          = V4L2_CTRL_FLAG_DISABLED,
-       },
-       {
-               .id             = V4L2_CID_AUDIO_TREBLE,
-               .flags          = V4L2_CTRL_FLAG_DISABLED,
-       },
-       {
-               .id             = V4L2_CID_AUDIO_MUTE,
-               .type           = V4L2_CTRL_TYPE_BOOLEAN,
-               .name           = "Mute",
-               .minimum        = 0,
-               .maximum        = 1,
-               .step           = 1,
-               .default_value  = 1,
-       },
-       {
-               .id             = V4L2_CID_AUDIO_LOUDNESS,
-               .flags          = V4L2_CTRL_FLAG_DISABLED,
-       },
-};
-
-static int bcm2048_vidioc_querycap(struct file *file, void *priv,
-                                  struct v4l2_capability *capability)
-{
-       struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file));
-
-       strscpy(capability->driver, BCM2048_DRIVER_NAME,
-               sizeof(capability->driver));
-       strscpy(capability->card, BCM2048_DRIVER_CARD,
-               sizeof(capability->card));
-       snprintf(capability->bus_info, 32, "I2C: 0x%X", bdev->client->addr);
-       return 0;
-}
-
-static int bcm2048_vidioc_g_input(struct file *filp, void *priv,
-                                 unsigned int *i)
-{
-       *i = 0;
-
-       return 0;
-}
-
-static int bcm2048_vidioc_s_input(struct file *filp, void *priv,
-                                 unsigned int i)
-{
-       if (i)
-               return -EINVAL;
-
-       return 0;
-}
-
-static int bcm2048_vidioc_queryctrl(struct file *file, void *priv,
-                                   struct v4l2_queryctrl *qc)
-{
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(bcm2048_v4l2_queryctrl); i++) {
-               if (qc->id && qc->id == bcm2048_v4l2_queryctrl[i].id) {
-                       *qc = bcm2048_v4l2_queryctrl[i];
-                       return 0;
-               }
-       }
-
-       return -EINVAL;
-}
-
-static int bcm2048_vidioc_g_ctrl(struct file *file, void *priv,
-                                struct v4l2_control *ctrl)
-{
-       struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file));
-       int err = 0;
-
-       if (!bdev)
-               return -ENODEV;
-
-       switch (ctrl->id) {
-       case V4L2_CID_AUDIO_MUTE:
-               err = bcm2048_get_mute(bdev);
-               if (err >= 0)
-                       ctrl->value = err;
-               break;
-       }
-
-       return err;
-}
-
-static int bcm2048_vidioc_s_ctrl(struct file *file, void *priv,
-                                struct v4l2_control *ctrl)
-{
-       struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file));
-       int err = 0;
-
-       if (!bdev)
-               return -ENODEV;
-
-       switch (ctrl->id) {
-       case V4L2_CID_AUDIO_MUTE:
-               if (ctrl->value) {
-                       if (bdev->power_state) {
-                               err = bcm2048_set_mute(bdev, ctrl->value);
-                               err |= bcm2048_deinit(bdev);
-                       }
-               } else {
-                       if (!bdev->power_state) {
-                               err = bcm2048_init(bdev);
-                               err |= bcm2048_set_mute(bdev, ctrl->value);
-                       }
-               }
-               break;
-       }
-
-       return err;
-}
-
-static int bcm2048_vidioc_g_audio(struct file *file, void *priv,
-                                 struct v4l2_audio *audio)
-{
-       if (audio->index > 1)
-               return -EINVAL;
-
-       strscpy(audio->name, "Radio", sizeof(audio->name));
-       audio->capability = V4L2_AUDCAP_STEREO;
-
-       return 0;
-}
-
-static int bcm2048_vidioc_s_audio(struct file *file, void *priv,
-                                 const struct v4l2_audio *audio)
-{
-       if (audio->index != 0)
-               return -EINVAL;
-
-       return 0;
-}
-
-static int bcm2048_vidioc_g_tuner(struct file *file, void *priv,
-                                 struct v4l2_tuner *tuner)
-{
-       struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file));
-       s8 f_error;
-       s8 rssi;
-
-       if (!bdev)
-               return -ENODEV;
-
-       if (tuner->index > 0)
-               return -EINVAL;
-
-       strscpy(tuner->name, "FM Receiver", sizeof(tuner->name));
-       tuner->type = V4L2_TUNER_RADIO;
-       tuner->rangelow =
-               dev_to_v4l2(bcm2048_get_region_bottom_frequency(bdev));
-       tuner->rangehigh =
-               dev_to_v4l2(bcm2048_get_region_top_frequency(bdev));
-       tuner->rxsubchans = V4L2_TUNER_SUB_STEREO;
-       tuner->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW;
-       tuner->audmode = V4L2_TUNER_MODE_STEREO;
-       tuner->afc = 0;
-       if (bdev->power_state) {
-               /*
-                * Report frequencies with high carrier errors to have zero
-                * signal level
-                */
-               f_error = bcm2048_get_fm_carrier_error(bdev);
-               if (f_error < BCM2048_FREQ_ERROR_FLOOR ||
-                   f_error > BCM2048_FREQ_ERROR_ROOF) {
-                       tuner->signal = 0;
-               } else {
-                       /*
-                        * RSSI level -60 dB is defined to report full
-                        * signal strength
-                        */
-                       rssi = bcm2048_get_fm_rssi(bdev);
-                       if (rssi >= BCM2048_RSSI_LEVEL_BASE) {
-                               tuner->signal = 0xFFFF;
-                       } else if (rssi > BCM2048_RSSI_LEVEL_ROOF) {
-                               tuner->signal = (rssi +
-                                                BCM2048_RSSI_LEVEL_ROOF_NEG)
-                                                * BCM2048_SIGNAL_MULTIPLIER;
-                       } else {
-                               tuner->signal = 0;
-                       }
-               }
-       } else {
-               tuner->signal = 0;
-       }
-
-       return 0;
-}
-
-static int bcm2048_vidioc_s_tuner(struct file *file, void *priv,
-                                 const struct v4l2_tuner *tuner)
-{
-       struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file));
-
-       if (!bdev)
-               return -ENODEV;
-
-       if (tuner->index > 0)
-               return -EINVAL;
-
-       return 0;
-}
-
-static int bcm2048_vidioc_g_frequency(struct file *file, void *priv,
-                                     struct v4l2_frequency *freq)
-{
-       struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file));
-       int err = 0;
-       int f;
-
-       if (!bdev->power_state)
-               return -ENODEV;
-
-       freq->type = V4L2_TUNER_RADIO;
-       f = bcm2048_get_fm_frequency(bdev);
-
-       if (f < 0)
-               err = f;
-       else
-               freq->frequency = dev_to_v4l2(f);
-
-       return err;
-}
-
-static int bcm2048_vidioc_s_frequency(struct file *file, void *priv,
-                                     const struct v4l2_frequency *freq)
-{
-       struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file));
-       int err;
-
-       if (freq->type != V4L2_TUNER_RADIO)
-               return -EINVAL;
-
-       if (!bdev->power_state)
-               return -ENODEV;
-
-       err = bcm2048_set_fm_frequency(bdev, v4l2_to_dev(freq->frequency));
-       err |= bcm2048_set_fm_search_tune_mode(bdev, BCM2048_FM_PRE_SET_MODE);
-
-       return err;
-}
-
-static int bcm2048_vidioc_s_hw_freq_seek(struct file *file, void *priv,
-                                        const struct v4l2_hw_freq_seek *seek)
-{
-       struct bcm2048_device *bdev = video_get_drvdata(video_devdata(file));
-       int err;
-
-       if (!bdev->power_state)
-               return -ENODEV;
-
-       if ((seek->tuner != 0) || (seek->type != V4L2_TUNER_RADIO))
-               return -EINVAL;
-
-       err = bcm2048_set_fm_search_mode_direction(bdev, seek->seek_upward);
-       err |= bcm2048_set_fm_search_tune_mode(bdev,
-                                              BCM2048_FM_AUTO_SEARCH_MODE);
-
-       return err;
-}
-
-static const struct v4l2_ioctl_ops bcm2048_ioctl_ops = {
-       .vidioc_querycap        = bcm2048_vidioc_querycap,
-       .vidioc_g_input         = bcm2048_vidioc_g_input,
-       .vidioc_s_input         = bcm2048_vidioc_s_input,
-       .vidioc_queryctrl       = bcm2048_vidioc_queryctrl,
-       .vidioc_g_ctrl          = bcm2048_vidioc_g_ctrl,
-       .vidioc_s_ctrl          = bcm2048_vidioc_s_ctrl,
-       .vidioc_g_audio         = bcm2048_vidioc_g_audio,
-       .vidioc_s_audio         = bcm2048_vidioc_s_audio,
-       .vidioc_g_tuner         = bcm2048_vidioc_g_tuner,
-       .vidioc_s_tuner         = bcm2048_vidioc_s_tuner,
-       .vidioc_g_frequency     = bcm2048_vidioc_g_frequency,
-       .vidioc_s_frequency     = bcm2048_vidioc_s_frequency,
-       .vidioc_s_hw_freq_seek  = bcm2048_vidioc_s_hw_freq_seek,
-};
-
-/*
- * bcm2048_viddev_template - video device interface
- */
-static const struct video_device bcm2048_viddev_template = {
-       .fops                   = &bcm2048_fops,
-       .name                   = BCM2048_DRIVER_NAME,
-       .release                = video_device_release_empty,
-       .ioctl_ops              = &bcm2048_ioctl_ops,
-       .device_caps            = V4L2_CAP_TUNER | V4L2_CAP_RADIO |
-                                 V4L2_CAP_HW_FREQ_SEEK,
-};
-
-/*
- *     I2C driver interface
- */
-static int bcm2048_i2c_driver_probe(struct i2c_client *client)
-{
-       struct bcm2048_device *bdev;
-       int err;
-
-       bdev = kzalloc(sizeof(*bdev), GFP_KERNEL);
-       if (!bdev) {
-               err = -ENOMEM;
-               goto exit;
-       }
-
-       bdev->client = client;
-       i2c_set_clientdata(client, bdev);
-       mutex_init(&bdev->mutex);
-       init_completion(&bdev->compl);
-       INIT_WORK(&bdev->work, bcm2048_work);
-
-       if (client->irq) {
-               err = request_irq(client->irq,
-                                 bcm2048_handler, IRQF_TRIGGER_FALLING,
-                                 client->name, bdev);
-               if (err < 0) {
-                       dev_err(&client->dev, "Could not request IRQ\n");
-                       goto free_bdev;
-               }
-               dev_dbg(&client->dev, "IRQ requested.\n");
-       } else {
-               dev_dbg(&client->dev, "IRQ not configured. Using timeouts.\n");
-       }
-
-       bdev->videodev = bcm2048_viddev_template;
-       video_set_drvdata(&bdev->videodev, bdev);
-       if (video_register_device(&bdev->videodev, VFL_TYPE_RADIO, radio_nr)) {
-               dev_dbg(&client->dev, "Could not register video device.\n");
-               err = -EIO;
-               goto free_irq;
-       }
-
-       err = bcm2048_sysfs_register_properties(bdev);
-       if (err < 0) {
-               dev_dbg(&client->dev, "Could not register sysfs interface.\n");
-               goto free_registration;
-       }
-
-       err = bcm2048_probe(bdev);
-       if (err < 0) {
-               dev_dbg(&client->dev, "Failed to probe device information.\n");
-               goto free_sysfs;
-       }
-
-       return 0;
-
-free_sysfs:
-       bcm2048_sysfs_unregister_properties(bdev, ARRAY_SIZE(attrs));
-free_registration:
-       video_unregister_device(&bdev->videodev);
-free_irq:
-       if (client->irq)
-               free_irq(client->irq, bdev);
-free_bdev:
-       i2c_set_clientdata(client, NULL);
-       kfree(bdev);
-exit:
-       return err;
-}
-
-static int bcm2048_i2c_driver_remove(struct i2c_client *client)
-{
-       struct bcm2048_device *bdev = i2c_get_clientdata(client);
-
-       if (!client->adapter)
-               return -ENODEV;
-
-       if (bdev) {
-               bcm2048_sysfs_unregister_properties(bdev, ARRAY_SIZE(attrs));
-               video_unregister_device(&bdev->videodev);
-
-               if (bdev->power_state)
-                       bcm2048_set_power_state(bdev, BCM2048_POWER_OFF);
-
-               if (client->irq > 0)
-                       free_irq(client->irq, bdev);
-
-               cancel_work_sync(&bdev->work);
-
-               kfree(bdev);
-       }
-
-       return 0;
-}
-
-/*
- *     bcm2048_i2c_driver - i2c driver interface
- */
-static const struct i2c_device_id bcm2048_id[] = {
-       { "bcm2048", 0 },
-       { },
-};
-MODULE_DEVICE_TABLE(i2c, bcm2048_id);
-
-static struct i2c_driver bcm2048_i2c_driver = {
-       .driver         = {
-               .name   = BCM2048_DRIVER_NAME,
-       },
-       .probe_new      = bcm2048_i2c_driver_probe,
-       .remove         = bcm2048_i2c_driver_remove,
-       .id_table       = bcm2048_id,
-};
-
-module_i2c_driver(bcm2048_i2c_driver);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR(BCM2048_DRIVER_AUTHOR);
-MODULE_DESCRIPTION(BCM2048_DRIVER_DESC);
-MODULE_VERSION("0.0.2");
diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.h b/drivers/staging/media/bcm2048/radio-bcm2048.h
deleted file mode 100644 (file)
index 22887a0..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * drivers/staging/media/radio-bcm2048.h
- *
- * Property and command definitions for bcm2048 radio receiver chip.
- *
- * Copyright (C) Nokia Corporation
- * Contact: Eero Nurkkala <ext-eero.nurkkala@nokia.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- */
-
-#ifndef BCM2048_H
-#define BCM2048_H
-
-#define BCM2048_NAME           "bcm2048"
-#define BCM2048_I2C_ADDR       0x22
-
-#endif /* ifndef BCM2048_H */
diff --git a/drivers/staging/media/davinci_vpfe/Kconfig b/drivers/staging/media/davinci_vpfe/Kconfig
deleted file mode 100644 (file)
index 94bf674..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-config VIDEO_DM365_VPFE
-       tristate "DM365 VPFE Media Controller Capture Driver"
-       depends on VIDEO_V4L2
-       depends on (ARCH_DAVINCI_DM365 && !VIDEO_DM365_ISIF) || (COMPILE_TEST && !ARCH_OMAP1)
-       depends on VIDEO_V4L2_SUBDEV_API
-       depends on VIDEO_DAVINCI_VPBE_DISPLAY
-       select VIDEOBUF2_DMA_CONTIG
-       help
-         Support for DM365 VPFE based Media Controller Capture driver.
-
-         To compile this driver as a module, choose M here: the
-         module will be called vpfe-mc-capture.
diff --git a/drivers/staging/media/davinci_vpfe/Makefile b/drivers/staging/media/davinci_vpfe/Makefile
deleted file mode 100644 (file)
index 0ae8c50..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci-vfpe.o
-
-davinci-vfpe-objs := \
-       dm365_isif.o dm365_ipipe_hw.o dm365_ipipe.o \
-       dm365_resizer.o dm365_ipipeif.o vpfe_mc_capture.o vpfe_video.o
-
-# Allow building it with COMPILE_TEST on other archs
-ifndef CONFIG_ARCH_DAVINCI
-ccflags-y += -I $(srctree)/arch/arm/mach-davinci/include/
-endif
diff --git a/drivers/staging/media/davinci_vpfe/TODO b/drivers/staging/media/davinci_vpfe/TODO
deleted file mode 100644 (file)
index cc8bd93..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-TODO (general):
-==================================
-
-- User space interface refinement
-       - Controls should be used when possible rather than private ioctl
-       - No enums should be used
-       - Use of MC and V4L2 subdev APIs when applicable
-       - Single interface header might suffice
-       - Current interface forces to configure everything at once
-- Get rid of the dm365_ipipe_hw.[ch] layer
-- Active external sub-devices defined by link configuration; no strcmp
-  needed
-- More generic platform data (i2c adapters)
-- The driver should have no knowledge of possible external subdevs; see
-  struct vpfe_subdev_id
-- Some of the hardware control should be refactorede
-- Check proper serialisation (through mutexes and spinlocks)
-- Names that are visible in kernel global namespace should have a common
-  prefix (or a few)
-- While replacing the older driver in media folder, provide a compatibility
-  layer and compatibility tests that warrants (using the libv4l's LD_PRELOAD
-  approach) there is no regression for the users using the older driver.
-- make it independent of arch-specific APIs (mach/mux.h).
-
-Building of uImage and Applications:
-==================================
-
-As of now since the interface will undergo few changes all the include
-files are present in staging itself, to build for dm365 follow below steps,
-
-- copy vpfe.h from drivers/staging/media/davinci_vpfe/ to
-  include/media/davinci/ folder for building the uImage.
-- copy davinci_vpfe_user.h from drivers/staging/media/davinci_vpfe/ to
-  include/uapi/linux/davinci_vpfe.h, and add a entry in Kbuild (required
-  for building application).
-- copy dm365_ipipeif_user.h from drivers/staging/media/davinci_vpfe/ to
-  include/uapi/linux/dm365_ipipeif.h and a entry in Kbuild (required
-  for building application).
diff --git a/drivers/staging/media/davinci_vpfe/davinci-vpfe-mc.txt b/drivers/staging/media/davinci_vpfe/davinci-vpfe-mc.txt
deleted file mode 100644 (file)
index a1e9177..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-Davinci Video processing Front End (VPFE) driver
-
-Copyright (C) 2012 Texas Instruments Inc
-
-Contacts: Manjunath Hadli <manjunath.hadli@ti.com>
-         Prabhakar Lad <prabhakar.lad@ti.com>
-
-
-Introduction
-============
-
-This file documents the Texas Instruments Davinci Video processing Front End
-(VPFE) driver located under drivers/media/platform/davinci. The original driver
-exists for Davinci VPFE, which is now being changed to Media Controller
-Framework.
-
-Currently the driver has been successfully used on the following
-version of Davinci:
-
-       DM365/DM368
-
-The driver implements V4L2, Media controller and v4l2_subdev interfaces. Sensor,
-lens and flash drivers using the v4l2_subdev interface in the kernel are
-supported.
-
-
-Split to subdevs
-================
-
-The Davinci VPFE is split into V4L2 subdevs, each of the blocks inside the VPFE
-having one subdev to represent it. Each of the subdevs provide a V4L2 subdev
-interface to userspace.
-
-       DAVINCI ISIF
-       DAVINCI IPIPEIF
-       DAVINCI IPIPE
-       DAVINCI CROP RESIZER
-       DAVINCI RESIZER A
-       DAVINCI RESIZER B
-
-Each possible link in the VPFE is modelled by a link in the Media controller
-interface. For an example program see [1].
-
-
-ISIF, IPIPE, and RESIZER block IOCTLs
-======================================
-
-The Davinci Video processing Front End (VPFE) driver supports standard V4L2
-IOCTLs and controls where possible and practical. Much of the functions provided
-by the VPFE, however, does not fall under the standard IOCTL's.
-
-In general, there is a private ioctl for configuring each of the blocks
-containing hardware-dependent functions.
-
-The following private IOCTLs are supported:
-
-       VIDIOC_VPFE_ISIF_[S/G]_RAW_PARAMS
-       VIDIOC_VPFE_IPIPE_[S/G]_CONFIG
-       VIDIOC_VPFE_RSZ_[S/G]_CONFIG
-
-The parameter structures used by these ioctl's are described in
-include/uapi/linux/davinci_vpfe.h.
-
-The VIDIOC_VPFE_ISIF_S_RAW_PARAMS, VIDIOC_VPFE_IPIPE_S_CONFIG and
-VIDIOC_VPFE_RSZ_S_CONFIG are used to configure, enable and disable functions in
-the isif, ipipe and resizer blocks respectively. These IOCTL's control several
-functions in the blocks they control. VIDIOC_VPFE_ISIF_S_RAW_PARAMS IOCTL
-accepts a pointer to struct vpfe_isif_raw_config as its argument. Similarly
-VIDIOC_VPFE_IPIPE_S_CONFIG accepts a pointer to struct vpfe_ipipe_config. And
-VIDIOC_VPFE_RSZ_S_CONFIG accepts a pointer to struct vpfe_rsz_config as its
-argument. Similarly VIDIOC_VPFE_ISIF_G_RAW_PARAMS, VIDIOC_VPFE_IPIPE_G_CONFIG
-and VIDIOC_VPFE_RSZ_G_CONFIG are used to get the current configuration set in
-the isif, ipipe and resizer blocks respectively.
-
-The detailed functions of the VPFE itself related to a given VPFE block is
-described in the Technical Reference Manuals (TRMs) --- see the end of the
-document for those.
-
-
-IPIPEIF block IOCTLs
-======================================
-
-The following private IOCTLs are supported:
-
-       VIDIOC_VPFE_IPIPEIF_[S/G]_CONFIG
-
-The parameter structures used by these ioctl's are described in
-include/uapi/linux/dm365_ipipeif.h
-
-The VIDIOC_VPFE_IPIPEIF_S_CONFIG is used to configure the ipipeif
-hardware block. The VIDIOC_VPFE_IPIPEIF_S_CONFIG and
-VIDIOC_VPFE_IPIPEIF_G_CONFIG accepts a pointer to struct ipipeif_params
-as its argument.
-
-
-VPFE Operating Modes
-==========================================
-
-a: Continuous Modes
-------------------------
-
-1: tvp514x/tvp7002/mt9p031---> DAVINCI ISIF---> SDRAM
-
-2: tvp514x/tvp7002/mt9p031---> DAVINCI ISIF---> DAVINCI IPIPEIF--->|
-                                                                   |
-   <--------------------<----------------<---------------------<---|
-   |
-   V
- DAVINCI CROP RESIZER--->DAVINCI RESIZER [A/B]---> SDRAM
-
-3: tvp514x/tvp7002/mt9p031---> DAVINCI ISIF---> DAVINCI IPIPEIF--->|
-                                                                   |
-   <--------------------<----------------<---------------------<---|
-   |
-   V
- DAVINCI IPIPE---> DAVINCI CROP RESIZER--->DAVINCI RESIZER [A/B]---> SDRAM
-
-a: Single Shot Modes
-------------------------
-
-1: SDRAM---> DAVINCI IPIPEIF---> DAVINCI IPIPE---> DAVINCI CROP RESIZER--->|
-                                                                           |
-   <----------------<----------------<------------------<---------------<--|
-   |
-   V
-DAVINCI RESIZER [A/B]---> SDRAM
-
-2: SDRAM---> DAVINCI IPIPEIF---> DAVINCI CROP RESIZER--->|
-                                                         |
-   <----------------<----------------<---------------<---|
-   |
-   V
-DAVINCI RESIZER [A/B]---> SDRAM
-
-
-Technical reference manuals (TRMs) and other documentation
-==========================================================
-
-Davinci DM365 TRM:
-<URL:http://www.ti.com/lit/ds/sprs457e/sprs457e.pdf>
-Referenced MARCH 2009-REVISED JUNE 2011
-
-Davinci DM368 TRM:
-<URL:http://www.ti.com/lit/ds/sprs668c/sprs668c.pdf>
-Referenced APRIL 2010-REVISED JUNE 2011
-
-Davinci Video Processing Front End (VPFE) DM36x
-<URL:http://www.ti.com/lit/ug/sprufg8c/sprufg8c.pdf>
-
-
-References
-==========
-
-[1] http://git.ideasonboard.org/?p=media-ctl.git;a=summary
diff --git a/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h b/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h
deleted file mode 100644 (file)
index 8d77202..0000000
+++ /dev/null
@@ -1,1287 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#ifndef _DAVINCI_VPFE_USER_H
-#define _DAVINCI_VPFE_USER_H
-
-#include <linux/types.h>
-#include <linux/videodev2.h>
-
-/*
- * Private IOCTL
- *
- * VIDIOC_VPFE_ISIF_S_RAW_PARAMS: Set raw params in isif
- * VIDIOC_VPFE_ISIF_G_RAW_PARAMS: Get raw params from isif
- * VIDIOC_VPFE_PRV_S_CONFIG: Set ipipe engine configuration
- * VIDIOC_VPFE_PRV_G_CONFIG: Get ipipe engine configuration
- * VIDIOC_VPFE_RSZ_S_CONFIG: Set resizer engine configuration
- * VIDIOC_VPFE_RSZ_G_CONFIG: Get resizer engine configuration
- */
-
-#define VIDIOC_VPFE_ISIF_S_RAW_PARAMS \
-       _IOW('V', BASE_VIDIOC_PRIVATE + 1,  struct vpfe_isif_raw_config)
-#define VIDIOC_VPFE_ISIF_G_RAW_PARAMS \
-       _IOR('V', BASE_VIDIOC_PRIVATE + 2, struct vpfe_isif_raw_config)
-#define VIDIOC_VPFE_IPIPE_S_CONFIG \
-       _IOWR('P', BASE_VIDIOC_PRIVATE + 3, struct vpfe_ipipe_config)
-#define VIDIOC_VPFE_IPIPE_G_CONFIG \
-       _IOWR('P', BASE_VIDIOC_PRIVATE + 4, struct vpfe_ipipe_config)
-#define VIDIOC_VPFE_RSZ_S_CONFIG \
-       _IOWR('R', BASE_VIDIOC_PRIVATE + 5, struct vpfe_rsz_config)
-#define VIDIOC_VPFE_RSZ_G_CONFIG \
-       _IOWR('R', BASE_VIDIOC_PRIVATE + 6, struct vpfe_rsz_config)
-
-/*
- * Private Control's for ISIF
- */
-#define VPFE_ISIF_CID_CRGAIN           (V4L2_CID_USER_BASE | 0xa001)
-#define VPFE_ISIF_CID_CGRGAIN          (V4L2_CID_USER_BASE | 0xa002)
-#define VPFE_ISIF_CID_CGBGAIN          (V4L2_CID_USER_BASE | 0xa003)
-#define VPFE_ISIF_CID_CBGAIN           (V4L2_CID_USER_BASE | 0xa004)
-#define VPFE_ISIF_CID_GAIN_OFFSET      (V4L2_CID_USER_BASE | 0xa005)
-
-/*
- * Private Control's for ISIF and IPIPEIF
- */
-#define VPFE_CID_DPCM_PREDICTOR                (V4L2_CID_USER_BASE | 0xa006)
-
-/************************************************************************
- *   Vertical Defect Correction parameters
- ***********************************************************************/
-
-/**
- * vertical defect correction methods
- */
-enum vpfe_isif_vdfc_corr_mode {
-       /* Defect level subtraction. Just fed through if saturating */
-       VPFE_ISIF_VDFC_NORMAL,
-       /**
-        * Defect level subtraction. Horizontal interpolation ((i-2)+(i+2))/2
-        * if data saturating
-        */
-       VPFE_ISIF_VDFC_HORZ_INTERPOL_IF_SAT,
-       /* Horizontal interpolation (((i-2)+(i+2))/2) */
-       VPFE_ISIF_VDFC_HORZ_INTERPOL
-};
-
-/**
- * Max Size of the Vertical Defect Correction table
- */
-#define VPFE_ISIF_VDFC_TABLE_SIZE      8
-
-/**
- * Values used for shifting up the vdfc defect level
- */
-enum vpfe_isif_vdfc_shift {
-       /* No Shift */
-       VPFE_ISIF_VDFC_NO_SHIFT,
-       /* Shift by 1 bit */
-       VPFE_ISIF_VDFC_SHIFT_1,
-       /* Shift by 2 bit */
-       VPFE_ISIF_VDFC_SHIFT_2,
-       /* Shift by 3 bit */
-       VPFE_ISIF_VDFC_SHIFT_3,
-       /* Shift by 4 bit */
-       VPFE_ISIF_VDFC_SHIFT_4
-};
-
-/**
- * Defect Correction (DFC) table entry
- */
-struct vpfe_isif_vdfc_entry {
-       /* vertical position of defect */
-       unsigned short pos_vert;
-       /* horizontal position of defect */
-       unsigned short pos_horz;
-       /**
-        * Defect level of Vertical line defect position. This is subtracted
-        * from the data at the defect position
-        */
-       unsigned char level_at_pos;
-       /**
-        * Defect level of the pixels upper than the vertical line defect.
-        * This is subtracted from the data
-        */
-       unsigned char level_up_pixels;
-       /**
-        * Defect level of the pixels lower than the vertical line defect.
-        * This is subtracted from the data
-        */
-       unsigned char level_low_pixels;
-};
-
-/**
- * Structure for Defect Correction (DFC) parameter
- */
-struct vpfe_isif_dfc {
-       /* enable vertical defect correction */
-       unsigned char en;
-       /* Correction methods */
-       enum vpfe_isif_vdfc_corr_mode corr_mode;
-       /**
-        * 0 - whole line corrected, 1 - not
-        * pixels upper than the defect
-        */
-       unsigned char corr_whole_line;
-       /**
-        * defect level shift value. level_at_pos, level_upper_pos,
-        * and level_lower_pos can be shifted up by this value
-        */
-       enum vpfe_isif_vdfc_shift def_level_shift;
-       /* defect saturation level */
-       unsigned short def_sat_level;
-       /* number of vertical defects. Max is VPFE_ISIF_VDFC_TABLE_SIZE */
-       short num_vdefects;
-       /* VDFC table ptr */
-       struct vpfe_isif_vdfc_entry table[VPFE_ISIF_VDFC_TABLE_SIZE];
-};
-
-/************************************************************************
- *   Digital/Black clamp or DC Subtract parameters
- ************************************************************************/
-/**
- * Horizontal Black Clamp modes
- */
-enum vpfe_isif_horz_bc_mode {
-       /**
-        * Horizontal clamp disabled. Only vertical clamp
-        * value is subtracted
-        */
-       VPFE_ISIF_HORZ_BC_DISABLE,
-       /**
-        * Horizontal clamp value is calculated and subtracted
-        * from image data along with vertical clamp value
-        */
-       VPFE_ISIF_HORZ_BC_CLAMP_CALC_ENABLED,
-       /**
-        * Horizontal clamp value calculated from previous image
-        * is subtracted from image data along with vertical clamp
-        * value. How the horizontal clamp value for the first image
-        * is calculated in this case ???
-        */
-       VPFE_ISIF_HORZ_BC_CLAMP_NOT_UPDATED
-};
-
-/**
- * Base window selection for Horizontal Black Clamp calculations
- */
-enum vpfe_isif_horz_bc_base_win_sel {
-       /* Select Most left window for bc calculation */
-       VPFE_ISIF_SEL_MOST_LEFT_WIN,
-
-       /* Select Most right window for bc calculation */
-       VPFE_ISIF_SEL_MOST_RIGHT_WIN,
-};
-
-/* Size of window in horizontal direction for horizontal bc */
-enum vpfe_isif_horz_bc_sz_h {
-       VPFE_ISIF_HORZ_BC_SZ_H_2PIXELS,
-       VPFE_ISIF_HORZ_BC_SZ_H_4PIXELS,
-       VPFE_ISIF_HORZ_BC_SZ_H_8PIXELS,
-       VPFE_ISIF_HORZ_BC_SZ_H_16PIXELS
-};
-
-/* Size of window in vertcal direction for vertical bc */
-enum vpfe_isif_horz_bc_sz_v {
-       VPFE_ISIF_HORZ_BC_SZ_H_32PIXELS,
-       VPFE_ISIF_HORZ_BC_SZ_H_64PIXELS,
-       VPFE_ISIF_HORZ_BC_SZ_H_128PIXELS,
-       VPFE_ISIF_HORZ_BC_SZ_H_256PIXELS
-};
-
-/**
- * Structure for Horizontal Black Clamp config params
- */
-struct vpfe_isif_horz_bclamp {
-       /* horizontal clamp mode */
-       enum vpfe_isif_horz_bc_mode mode;
-       /**
-        * pixel value limit enable.
-        *  0 - limit disabled
-        *  1 - pixel value limited to 1023
-        */
-       unsigned char clamp_pix_limit;
-       /**
-        * Select most left or right window for clamp val
-        * calculation
-        */
-       enum vpfe_isif_horz_bc_base_win_sel base_win_sel_calc;
-       /* Window count per color for calculation. range 1-32 */
-       unsigned char win_count_calc;
-       /* Window start position - horizontal for calculation. 0 - 8191 */
-       unsigned short win_start_h_calc;
-       /* Window start position - vertical for calculation 0 - 8191 */
-       unsigned short win_start_v_calc;
-       /* Width of the sample window in pixels for calculation */
-       enum vpfe_isif_horz_bc_sz_h win_h_sz_calc;
-       /* Height of the sample window in pixels for calculation */
-       enum vpfe_isif_horz_bc_sz_v win_v_sz_calc;
-};
-
-/**
- * Black Clamp vertical reset values
- */
-enum vpfe_isif_vert_bc_reset_val_sel {
-       /* Reset value used is the clamp value calculated */
-       VPFE_ISIF_VERT_BC_USE_HORZ_CLAMP_VAL,
-       /* Reset value used is reset_clamp_val configured */
-       VPFE_ISIF_VERT_BC_USE_CONFIG_CLAMP_VAL,
-       /* No update, previous image value is used */
-       VPFE_ISIF_VERT_BC_NO_UPDATE
-};
-
-enum vpfe_isif_vert_bc_sz_h {
-       VPFE_ISIF_VERT_BC_SZ_H_2PIXELS,
-       VPFE_ISIF_VERT_BC_SZ_H_4PIXELS,
-       VPFE_ISIF_VERT_BC_SZ_H_8PIXELS,
-       VPFE_ISIF_VERT_BC_SZ_H_16PIXELS,
-       VPFE_ISIF_VERT_BC_SZ_H_32PIXELS,
-       VPFE_ISIF_VERT_BC_SZ_H_64PIXELS
-};
-
-/**
- * Structure for Vertical Black Clamp configuration params
- */
-struct vpfe_isif_vert_bclamp {
-       /* Reset value selection for vertical clamp calculation */
-       enum vpfe_isif_vert_bc_reset_val_sel reset_val_sel;
-       /* U12 value if reset_sel = ISIF_BC_VERT_USE_CONFIG_CLAMP_VAL */
-       unsigned short reset_clamp_val;
-       /**
-        * U8Q8. Line average coefficient used in vertical clamp
-        * calculation
-        */
-       unsigned char line_ave_coef;
-       /* Width in pixels of the optical black region used for calculation. */
-       enum vpfe_isif_vert_bc_sz_h ob_h_sz_calc;
-       /* Height of the optical black region for calculation */
-       unsigned short ob_v_sz_calc;
-       /* Optical black region start position - horizontal. 0 - 8191 */
-       unsigned short ob_start_h;
-       /* Optical black region start position - vertical 0 - 8191 */
-       unsigned short ob_start_v;
-};
-
-/**
- * Structure for Black Clamp configuration params
- */
-struct vpfe_isif_black_clamp {
-       /**
-        * this offset value is added irrespective of the clamp
-        * enable status. S13
-        */
-       unsigned short dc_offset;
-       /**
-        * Enable black/digital clamp value to be subtracted
-        * from the image data
-        */
-       unsigned char en;
-       /**
-        * black clamp mode. same/separate clamp for 4 colors
-        * 0 - disable - same clamp value for all colors
-        * 1 - clamp value calculated separately for all colors
-        */
-       unsigned char bc_mode_color;
-       /* Vertical start position for bc subtraction */
-       unsigned short vert_start_sub;
-       /* Black clamp for horizontal direction */
-       struct vpfe_isif_horz_bclamp horz;
-       /* Black clamp for vertical direction */
-       struct vpfe_isif_vert_bclamp vert;
-};
-
-/*************************************************************************
- ** Color Space Conversion (CSC)
- *************************************************************************/
-/**
- * Number of Coefficient values used for CSC
- */
-#define VPFE_ISIF_CSC_NUM_COEFF 16
-
-struct float_8_bit {
-       /* 8 bit integer part */
-       __u8 integer;
-       /* 8 bit decimal part */
-       __u8 decimal;
-};
-
-struct float_16_bit {
-       /* 16 bit integer part */
-       __u16 integer;
-       /* 16 bit decimal part */
-       __u16 decimal;
-};
-
-/*************************************************************************
- **  Color Space Conversion parameters
- *************************************************************************/
-/**
- * Structure used for CSC config params
- */
-struct vpfe_isif_color_space_conv {
-       /* Enable color space conversion */
-       unsigned char en;
-       /**
-        * csc coefficient table. S8Q5, M00 at index 0, M01 at index 1, and
-        * so forth
-        */
-       struct float_8_bit coeff[VPFE_ISIF_CSC_NUM_COEFF];
-};
-
-enum vpfe_isif_datasft {
-       /* No Shift */
-       VPFE_ISIF_NO_SHIFT,
-       /* 1 bit Shift */
-       VPFE_ISIF_1BIT_SHIFT,
-       /* 2 bit Shift */
-       VPFE_ISIF_2BIT_SHIFT,
-       /* 3 bit Shift */
-       VPFE_ISIF_3BIT_SHIFT,
-       /* 4 bit Shift */
-       VPFE_ISIF_4BIT_SHIFT,
-       /* 5 bit Shift */
-       VPFE_ISIF_5BIT_SHIFT,
-       /* 6 bit Shift */
-       VPFE_ISIF_6BIT_SHIFT
-};
-
-#define VPFE_ISIF_LINEAR_TAB_SIZE              192
-/*************************************************************************
- **  Linearization parameters
- *************************************************************************/
-/**
- * Structure for Sensor data linearization
- */
-struct vpfe_isif_linearize {
-       /* Enable or Disable linearization of data */
-       unsigned char en;
-       /* Shift value applied */
-       enum vpfe_isif_datasft corr_shft;
-       /* scale factor applied U11Q10 */
-       struct float_16_bit scale_fact;
-       /* Size of the linear table */
-       unsigned short table[VPFE_ISIF_LINEAR_TAB_SIZE];
-};
-
-/*************************************************************************
- **  ISIF Raw configuration parameters
- *************************************************************************/
-enum vpfe_isif_fmt_mode {
-       VPFE_ISIF_SPLIT,
-       VPFE_ISIF_COMBINE
-};
-
-enum vpfe_isif_lnum {
-       VPFE_ISIF_1LINE,
-       VPFE_ISIF_2LINES,
-       VPFE_ISIF_3LINES,
-       VPFE_ISIF_4LINES
-};
-
-enum vpfe_isif_line {
-       VPFE_ISIF_1STLINE,
-       VPFE_ISIF_2NDLINE,
-       VPFE_ISIF_3RDLINE,
-       VPFE_ISIF_4THLINE
-};
-
-struct vpfe_isif_fmtplen {
-       /**
-        * number of program entries for SET0, range 1 - 16
-        * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
-        * ISIF_COMBINE
-        */
-       unsigned short plen0;
-       /**
-        * number of program entries for SET1, range 1 - 16
-        * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
-        * ISIF_COMBINE
-        */
-       unsigned short plen1;
-       /**
-        * number of program entries for SET2, range 1 - 16
-        * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
-        * ISIF_COMBINE
-        */
-       unsigned short plen2;
-       /**
-        * number of program entries for SET3, range 1 - 16
-        * when fmtmode is ISIF_SPLIT, 1 - 8 when fmtmode is
-        * ISIF_COMBINE
-        */
-       unsigned short plen3;
-};
-
-struct vpfe_isif_fmt_cfg {
-       /* Split or combine or line alternate */
-       enum vpfe_isif_fmt_mode fmtmode;
-       /* enable or disable line alternating mode */
-       unsigned char ln_alter_en;
-       /* Split/combine line number */
-       enum vpfe_isif_lnum lnum;
-       /* Address increment Range 1 - 16 */
-       unsigned int addrinc;
-};
-
-struct vpfe_isif_fmt_addr_ptr {
-       /* Initial address */
-       unsigned int init_addr;
-       /* output line number */
-       enum vpfe_isif_line out_line;
-};
-
-struct vpfe_isif_fmtpgm_ap {
-       /* program address pointer */
-       unsigned char pgm_aptr;
-       /* program address increment or decrement */
-       unsigned char pgmupdt;
-};
-
-struct vpfe_isif_data_formatter {
-       /* Enable/Disable data formatter */
-       unsigned char en;
-       /* data formatter configuration */
-       struct vpfe_isif_fmt_cfg cfg;
-       /* Formatter program entries length */
-       struct vpfe_isif_fmtplen plen;
-       /* first pixel in a line fed to formatter */
-       unsigned short fmtrlen;
-       /* HD interval for output line. Only valid when split line */
-       unsigned short fmthcnt;
-       /* formatter address pointers */
-       struct vpfe_isif_fmt_addr_ptr fmtaddr_ptr[16];
-       /* program enable/disable */
-       unsigned char pgm_en[32];
-       /* program address pointers */
-       struct vpfe_isif_fmtpgm_ap fmtpgm_ap[32];
-};
-
-struct vpfe_isif_df_csc {
-       /* Color Space Conversion configuration, 0 - csc, 1 - df */
-       unsigned int df_or_csc;
-       /* csc configuration valid if df_or_csc is 0 */
-       struct vpfe_isif_color_space_conv csc;
-       /* data formatter configuration valid if df_or_csc is 1 */
-       struct vpfe_isif_data_formatter df;
-       /* start pixel in a line at the input */
-       unsigned int start_pix;
-       /* number of pixels in input line */
-       unsigned int num_pixels;
-       /* start line at the input */
-       unsigned int start_line;
-       /* number of lines at the input */
-       unsigned int num_lines;
-};
-
-struct vpfe_isif_gain_offsets_adj {
-       /* Enable or Disable Gain adjustment for SDRAM data */
-       unsigned char gain_sdram_en;
-       /* Enable or Disable Gain adjustment for IPIPE data */
-       unsigned char gain_ipipe_en;
-       /* Enable or Disable Gain adjustment for H3A data */
-       unsigned char gain_h3a_en;
-       /* Enable or Disable Gain adjustment for SDRAM data */
-       unsigned char offset_sdram_en;
-       /* Enable or Disable Gain adjustment for IPIPE data */
-       unsigned char offset_ipipe_en;
-       /* Enable or Disable Gain adjustment for H3A data */
-       unsigned char offset_h3a_en;
-};
-
-struct vpfe_isif_cul {
-       /* Horizontal Cull pattern for odd lines */
-       unsigned char hcpat_odd;
-       /* Horizontal Cull pattern for even lines */
-       unsigned char hcpat_even;
-       /* Vertical Cull pattern */
-       unsigned char vcpat;
-       /* Enable or disable lpf. Apply when cull is enabled */
-       unsigned char en_lpf;
-};
-
-/* all the stuff in this struct will be provided by userland */
-struct vpfe_isif_raw_config {
-       /* Linearization parameters for image sensor data input */
-       struct vpfe_isif_linearize linearize;
-       /* Data formatter or CSC */
-       struct vpfe_isif_df_csc df_csc;
-       /* Defect Pixel Correction (DFC) confguration */
-       struct vpfe_isif_dfc dfc;
-       /* Black/Digital Clamp configuration */
-       struct vpfe_isif_black_clamp bclamp;
-       /* Gain, offset adjustments */
-       struct vpfe_isif_gain_offsets_adj gain_offset;
-       /* Culling */
-       struct vpfe_isif_cul culling;
-       /* horizontal offset for Gain/LSC/DFC */
-       unsigned short horz_offset;
-       /* vertical offset for Gain/LSC/DFC */
-       unsigned short vert_offset;
-};
-
-/**********************************************************************
- *     IPIPE API Structures
- **********************************************************************/
-
-/* IPIPE module configurations */
-
-/* IPIPE input configuration */
-#define VPFE_IPIPE_INPUT_CONFIG                BIT(0)
-/* LUT based Defect Pixel Correction */
-#define VPFE_IPIPE_LUTDPC              BIT(1)
-/* On the fly (OTF) Defect Pixel Correction */
-#define VPFE_IPIPE_OTFDPC              BIT(2)
-/* Noise Filter - 1 */
-#define VPFE_IPIPE_NF1                 BIT(3)
-/* Noise Filter - 2 */
-#define VPFE_IPIPE_NF2                 BIT(4)
-/* White Balance.  Also a control ID */
-#define VPFE_IPIPE_WB                  BIT(5)
-/* 1st RGB to RBG Blend module */
-#define VPFE_IPIPE_RGB2RGB_1           BIT(6)
-/* 2nd RGB to RBG Blend module */
-#define VPFE_IPIPE_RGB2RGB_2           BIT(7)
-/* Gamma Correction */
-#define VPFE_IPIPE_GAMMA               BIT(8)
-/* 3D LUT color conversion */
-#define VPFE_IPIPE_3D_LUT              BIT(9)
-/* RGB to YCbCr module */
-#define VPFE_IPIPE_RGB2YUV             BIT(10)
-/* YUV 422 conversion module */
-#define VPFE_IPIPE_YUV422_CONV         BIT(11)
-/* Edge Enhancement */
-#define VPFE_IPIPE_YEE                 BIT(12)
-/* Green Imbalance Correction */
-#define VPFE_IPIPE_GIC                 BIT(13)
-/* CFA Interpolation */
-#define VPFE_IPIPE_CFA                 BIT(14)
-/* Chroma Artifact Reduction */
-#define VPFE_IPIPE_CAR                 BIT(15)
-/* Chroma Gain Suppression */
-#define VPFE_IPIPE_CGS                 BIT(16)
-/* Global brightness and contrast control */
-#define VPFE_IPIPE_GBCE                        BIT(17)
-
-#define VPFE_IPIPE_MAX_MODULES         18
-
-struct ipipe_float_u16 {
-       unsigned short integer;
-       unsigned short decimal;
-};
-
-struct ipipe_float_s16 {
-       short integer;
-       unsigned short decimal;
-};
-
-struct ipipe_float_u8 {
-       unsigned char integer;
-       unsigned char decimal;
-};
-
-/* Copy method selection for vertical correction
- *  Used when ipipe_dfc_corr_meth is IPIPE_DPC_CTORB_AFTER_HINT
- */
-enum vpfe_ipipe_dpc_corr_meth {
-       /* replace by black or white dot specified by repl_white */
-       VPFE_IPIPE_DPC_REPL_BY_DOT = 0,
-       /* Copy from left */
-       VPFE_IPIPE_DPC_CL = 1,
-       /* Copy from right */
-       VPFE_IPIPE_DPC_CR = 2,
-       /* Horizontal interpolation */
-       VPFE_IPIPE_DPC_H_INTP = 3,
-       /* Vertical interpolation */
-       VPFE_IPIPE_DPC_V_INTP = 4,
-       /* Copy from top  */
-       VPFE_IPIPE_DPC_CT = 5,
-       /* Copy from bottom */
-       VPFE_IPIPE_DPC_CB = 6,
-       /* 2D interpolation */
-       VPFE_IPIPE_DPC_2D_INTP = 7,
-};
-
-struct vpfe_ipipe_lutdpc_entry {
-       /* Horizontal position */
-       unsigned short horz_pos;
-       /* vertical position */
-       unsigned short vert_pos;
-       enum vpfe_ipipe_dpc_corr_meth method;
-};
-
-#define VPFE_IPIPE_MAX_SIZE_DPC 256
-
-/* Structure for configuring DPC module */
-struct vpfe_ipipe_lutdpc {
-       /* 0 - disable, 1 - enable */
-       unsigned char en;
-       /* 0 - replace with black dot, 1 - white dot when correction
-        * method is  IPIPE_DFC_REPL_BY_DOT=0,
-        */
-       unsigned char repl_white;
-       /* number of entries in the correction table. Currently only
-        * support up-to 256 entries. infinite mode is not supported
-        */
-       unsigned short dpc_size;
-       struct vpfe_ipipe_lutdpc_entry table[VPFE_IPIPE_MAX_SIZE_DPC];
-};
-
-enum vpfe_ipipe_otfdpc_det_meth {
-       VPFE_IPIPE_DPC_OTF_MIN_MAX,
-       VPFE_IPIPE_DPC_OTF_MIN_MAX2
-};
-
-struct vpfe_ipipe_otfdpc_thr {
-       unsigned short r;
-       unsigned short gr;
-       unsigned short gb;
-       unsigned short b;
-};
-
-enum vpfe_ipipe_otfdpc_alg {
-       VPFE_IPIPE_OTFDPC_2_0,
-       VPFE_IPIPE_OTFDPC_3_0
-};
-
-struct vpfe_ipipe_otfdpc_2_0_cfg {
-       /* defect detection threshold for MIN_MAX2 method  (DPC 2.0 alg) */
-       struct vpfe_ipipe_otfdpc_thr det_thr;
-       /* defect correction threshold for MIN_MAX2 method (DPC 2.0 alg) or
-        * maximum value for MIN_MAX method
-        */
-       struct vpfe_ipipe_otfdpc_thr corr_thr;
-};
-
-struct vpfe_ipipe_otfdpc_3_0_cfg {
-       /* DPC3.0 activity adj shf. activity = (max2-min2) >> (6 -shf)
-        */
-       unsigned char act_adj_shf;
-       /* DPC3.0 detection threshold, THR */
-       unsigned short det_thr;
-       /* DPC3.0 detection threshold slope, SLP */
-       unsigned short det_slp;
-       /* DPC3.0 detection threshold min, MIN */
-       unsigned short det_thr_min;
-       /* DPC3.0 detection threshold max, MAX */
-       unsigned short det_thr_max;
-       /* DPC3.0 correction threshold, THR */
-       unsigned short corr_thr;
-       /* DPC3.0 correction threshold slope, SLP */
-       unsigned short corr_slp;
-       /* DPC3.0 correction threshold min, MIN */
-       unsigned short corr_thr_min;
-       /* DPC3.0 correction threshold max, MAX */
-       unsigned short corr_thr_max;
-};
-
-struct vpfe_ipipe_otfdpc {
-       /* 0 - disable, 1 - enable */
-       unsigned char en;
-       /* defect detection method */
-       enum vpfe_ipipe_otfdpc_det_meth det_method;
-       /* Algorithm used. Applicable only when IPIPE_DPC_OTF_MIN_MAX2 is
-        * used
-        */
-       enum vpfe_ipipe_otfdpc_alg alg;
-       union {
-               /* if alg is IPIPE_OTFDPC_2_0 */
-               struct vpfe_ipipe_otfdpc_2_0_cfg dpc_2_0;
-               /* if alg is IPIPE_OTFDPC_3_0 */
-               struct vpfe_ipipe_otfdpc_3_0_cfg dpc_3_0;
-       } alg_cfg;
-};
-
-/* Threshold values table size */
-#define VPFE_IPIPE_NF_THR_TABLE_SIZE           8
-/* Intensity values table size */
-#define VPFE_IPIPE_NF_STR_TABLE_SIZE           8
-
-/* NF, sampling method for green pixels */
-enum vpfe_ipipe_nf_sampl_meth {
-       /* Same as R or B */
-       VPFE_IPIPE_NF_BOX,
-       /* Diamond mode */
-       VPFE_IPIPE_NF_DIAMOND
-};
-
-/* Structure for configuring NF module */
-struct vpfe_ipipe_nf {
-       /* 0 - disable, 1 - enable */
-       unsigned char en;
-       /* Sampling method for green pixels */
-       enum vpfe_ipipe_nf_sampl_meth gr_sample_meth;
-       /* Down shift value in LUT reference address
-        */
-       unsigned char shft_val;
-       /* Spread value in NF algorithm
-        */
-       unsigned char spread_val;
-       /* Apply LSC gain to threshold. Enable this only if
-        * LSC is enabled in ISIF
-        */
-       unsigned char apply_lsc_gain;
-       /* Threshold values table */
-       unsigned short thr[VPFE_IPIPE_NF_THR_TABLE_SIZE];
-       /* intensity values table */
-       unsigned char str[VPFE_IPIPE_NF_STR_TABLE_SIZE];
-       /* Edge detection minimum threshold */
-       unsigned short edge_det_min_thr;
-       /* Edge detection maximum threshold */
-       unsigned short edge_det_max_thr;
-};
-
-enum vpfe_ipipe_gic_alg {
-       VPFE_IPIPE_GIC_ALG_CONST_GAIN,
-       VPFE_IPIPE_GIC_ALG_ADAPT_GAIN
-};
-
-enum vpfe_ipipe_gic_thr_sel {
-       VPFE_IPIPE_GIC_THR_REG,
-       VPFE_IPIPE_GIC_THR_NF
-};
-
-enum vpfe_ipipe_gic_wt_fn_type {
-       /* Use difference as index */
-       VPFE_IPIPE_GIC_WT_FN_TYP_DIF,
-       /* Use weight function as index */
-       VPFE_IPIPE_GIC_WT_FN_TYP_HP_VAL
-};
-
-/* structure for Green Imbalance Correction */
-struct vpfe_ipipe_gic {
-       /* 0 - disable, 1 - enable */
-       unsigned char en;
-       /* 0 - Constant gain , 1 - Adaptive gain algorithm */
-       enum vpfe_ipipe_gic_alg gic_alg;
-       /* GIC gain or weight. Used for Constant gain and Adaptive algorithms
-        */
-       unsigned short gain;
-       /* Threshold selection. GIC register values or NF2 thr table */
-       enum vpfe_ipipe_gic_thr_sel thr_sel;
-       /* thr1. Used when thr_sel is  IPIPE_GIC_THR_REG */
-       unsigned short thr;
-       /* this value is used for thr2-thr1, thr3-thr2 or
-        * thr4-thr3 when wt_fn_type is index. Otherwise it
-        * is the
-        */
-       unsigned short slope;
-       /* Apply LSC gain to threshold. Enable this only if
-        * LSC is enabled in ISIF & thr_sel is IPIPE_GIC_THR_REG
-        */
-       unsigned char apply_lsc_gain;
-       /* Multiply Nf2 threshold by this gain. Use this when thr_sel
-        * is IPIPE_GIC_THR_NF
-        */
-       struct ipipe_float_u8 nf2_thr_gain;
-       /* Weight function uses difference as index or high pass value.
-        * Used for adaptive gain algorithm
-        */
-       enum vpfe_ipipe_gic_wt_fn_type wt_fn_type;
-};
-
-/* Structure for configuring WB module */
-struct vpfe_ipipe_wb {
-       /* Offset (S12) for R */
-       short ofst_r;
-       /* Offset (S12) for Gr */
-       short ofst_gr;
-       /* Offset (S12) for Gb */
-       short ofst_gb;
-       /* Offset (S12) for B */
-       short ofst_b;
-       /* Gain (U13Q9) for Red */
-       struct ipipe_float_u16 gain_r;
-       /* Gain (U13Q9) for Gr */
-       struct ipipe_float_u16 gain_gr;
-       /* Gain (U13Q9) for Gb */
-       struct ipipe_float_u16 gain_gb;
-       /* Gain (U13Q9) for Blue */
-       struct ipipe_float_u16 gain_b;
-};
-
-enum vpfe_ipipe_cfa_alg {
-       /* Algorithm is 2DirAC */
-       VPFE_IPIPE_CFA_ALG_2DIRAC,
-       /* Algorithm is 2DirAC + Digital Antialiasing (DAA) */
-       VPFE_IPIPE_CFA_ALG_2DIRAC_DAA,
-       /* Algorithm is DAA */
-       VPFE_IPIPE_CFA_ALG_DAA
-};
-
-/* Structure for CFA Interpolation */
-struct vpfe_ipipe_cfa {
-       /* 2DirAC or 2DirAC + DAA */
-       enum vpfe_ipipe_cfa_alg alg;
-       /* 2Dir CFA HP value Low Threshold */
-       unsigned short hpf_thr_2dir;
-       /* 2Dir CFA HP value slope */
-       unsigned short hpf_slp_2dir;
-       /* 2Dir CFA HP mix threshold */
-       unsigned short hp_mix_thr_2dir;
-       /* 2Dir CFA HP mix slope */
-       unsigned short hp_mix_slope_2dir;
-       /* 2Dir Direction threshold */
-       unsigned short dir_thr_2dir;
-       /* 2Dir Direction slope */
-       unsigned short dir_slope_2dir;
-       /* 2Dir Non Directional Weight */
-       unsigned short nd_wt_2dir;
-       /* DAA Mono Hue Fraction */
-       unsigned short hue_fract_daa;
-       /* DAA Mono Edge threshold */
-       unsigned short edge_thr_daa;
-       /* DAA Mono threshold minimum */
-       unsigned short thr_min_daa;
-       /* DAA Mono threshold slope */
-       unsigned short thr_slope_daa;
-       /* DAA Mono slope minimum */
-       unsigned short slope_min_daa;
-       /* DAA Mono slope slope */
-       unsigned short slope_slope_daa;
-       /* DAA Mono LP wight */
-       unsigned short lp_wt_daa;
-};
-
-/* Struct for configuring RGB2RGB blending module */
-struct vpfe_ipipe_rgb2rgb {
-       /* Matrix coefficient for RR S12Q8 for ID = 1 and S11Q8 for ID = 2 */
-       struct ipipe_float_s16 coef_rr;
-       /* Matrix coefficient for GR S12Q8/S11Q8 */
-       struct ipipe_float_s16 coef_gr;
-       /* Matrix coefficient for BR S12Q8/S11Q8 */
-       struct ipipe_float_s16 coef_br;
-       /* Matrix coefficient for RG S12Q8/S11Q8 */
-       struct ipipe_float_s16 coef_rg;
-       /* Matrix coefficient for GG S12Q8/S11Q8 */
-       struct ipipe_float_s16 coef_gg;
-       /* Matrix coefficient for BG S12Q8/S11Q8 */
-       struct ipipe_float_s16 coef_bg;
-       /* Matrix coefficient for RB S12Q8/S11Q8 */
-       struct ipipe_float_s16 coef_rb;
-       /* Matrix coefficient for GB S12Q8/S11Q8 */
-       struct ipipe_float_s16 coef_gb;
-       /* Matrix coefficient for BB S12Q8/S11Q8 */
-       struct ipipe_float_s16 coef_bb;
-       /* Output offset for R S13/S11 */
-       int out_ofst_r;
-       /* Output offset for G S13/S11 */
-       int out_ofst_g;
-       /* Output offset for B S13/S11 */
-       int out_ofst_b;
-};
-
-#define VPFE_IPIPE_MAX_SIZE_GAMMA              512
-
-enum vpfe_ipipe_gamma_tbl_size {
-       VPFE_IPIPE_GAMMA_TBL_SZ_64 = 64,
-       VPFE_IPIPE_GAMMA_TBL_SZ_128 = 128,
-       VPFE_IPIPE_GAMMA_TBL_SZ_256 = 256,
-       VPFE_IPIPE_GAMMA_TBL_SZ_512 = 512,
-};
-
-enum vpfe_ipipe_gamma_tbl_sel {
-       VPFE_IPIPE_GAMMA_TBL_RAM = 0,
-       VPFE_IPIPE_GAMMA_TBL_ROM = 1,
-};
-
-struct vpfe_ipipe_gamma_entry {
-       /* 10 bit slope */
-       short slope;
-       /* 10 bit offset */
-       unsigned short offset;
-};
-
-/* Structure for configuring Gamma correction module */
-struct vpfe_ipipe_gamma {
-       /* 0 - Enable Gamma correction for Red
-        * 1 - bypass Gamma correction. Data is divided by 16
-        */
-       unsigned char bypass_r;
-       /* 0 - Enable Gamma correction for Blue
-        * 1 - bypass Gamma correction. Data is divided by 16
-        */
-       unsigned char bypass_b;
-       /* 0 - Enable Gamma correction for Green
-        * 1 - bypass Gamma correction. Data is divided by 16
-        */
-       unsigned char bypass_g;
-       /* IPIPE_GAMMA_TBL_RAM or IPIPE_GAMMA_TBL_ROM */
-       enum vpfe_ipipe_gamma_tbl_sel tbl_sel;
-       /* Table size for RAM gamma table.
-        */
-       enum vpfe_ipipe_gamma_tbl_size tbl_size;
-       /* R table */
-       struct vpfe_ipipe_gamma_entry table_r[VPFE_IPIPE_MAX_SIZE_GAMMA];
-       /* Blue table */
-       struct vpfe_ipipe_gamma_entry table_b[VPFE_IPIPE_MAX_SIZE_GAMMA];
-       /* Green table */
-       struct vpfe_ipipe_gamma_entry table_g[VPFE_IPIPE_MAX_SIZE_GAMMA];
-};
-
-#define VPFE_IPIPE_MAX_SIZE_3D_LUT             729
-
-struct vpfe_ipipe_3d_lut_entry {
-       /* 10 bit entry for red */
-       unsigned short r;
-       /* 10 bit entry for green */
-       unsigned short g;
-       /* 10 bit entry for blue */
-       unsigned short b;
-};
-
-/* structure for 3D-LUT */
-struct vpfe_ipipe_3d_lut {
-       /* enable/disable 3D lut */
-       unsigned char en;
-       /* 3D - LUT table entry */
-       struct vpfe_ipipe_3d_lut_entry table[VPFE_IPIPE_MAX_SIZE_3D_LUT];
-};
-
-/* Struct for configuring rgb2ycbcr module */
-struct vpfe_ipipe_rgb2yuv {
-       /* Matrix coefficient for RY S12Q8 */
-       struct ipipe_float_s16 coef_ry;
-       /* Matrix coefficient for GY S12Q8 */
-       struct ipipe_float_s16 coef_gy;
-       /* Matrix coefficient for BY S12Q8 */
-       struct ipipe_float_s16 coef_by;
-       /* Matrix coefficient for RCb S12Q8 */
-       struct ipipe_float_s16 coef_rcb;
-       /* Matrix coefficient for GCb S12Q8 */
-       struct ipipe_float_s16 coef_gcb;
-       /* Matrix coefficient for BCb S12Q8 */
-       struct ipipe_float_s16 coef_bcb;
-       /* Matrix coefficient for RCr S12Q8 */
-       struct ipipe_float_s16 coef_rcr;
-       /* Matrix coefficient for GCr S12Q8 */
-       struct ipipe_float_s16 coef_gcr;
-       /* Matrix coefficient for BCr S12Q8 */
-       struct ipipe_float_s16 coef_bcr;
-       /* Output offset for R S11 */
-       int out_ofst_y;
-       /* Output offset for Cb S11 */
-       int out_ofst_cb;
-       /* Output offset for Cr S11 */
-       int out_ofst_cr;
-};
-
-enum vpfe_ipipe_gbce_type {
-       VPFE_IPIPE_GBCE_Y_VAL_TBL = 0,
-       VPFE_IPIPE_GBCE_GAIN_TBL = 1,
-};
-
-#define VPFE_IPIPE_MAX_SIZE_GBCE_LUT           1024
-
-/* structure for Global brightness and Contrast */
-struct vpfe_ipipe_gbce {
-       /* enable/disable GBCE */
-       unsigned char en;
-       /* Y - value table or Gain table */
-       enum vpfe_ipipe_gbce_type type;
-       /* ptr to LUT for GBCE with 1024 entries */
-       unsigned short table[VPFE_IPIPE_MAX_SIZE_GBCE_LUT];
-};
-
-/* Chrominance position. Applicable only for YCbCr input
- * Applied after edge enhancement
- */
-enum vpfe_chr_pos {
-       /* Co-siting, same position with luminance */
-       VPFE_IPIPE_YUV422_CHR_POS_COSITE = 0,
-       /* Centering, In the middle of luminance */
-       VPFE_IPIPE_YUV422_CHR_POS_CENTRE = 1,
-};
-
-/* Structure for configuring yuv422 conversion module */
-struct vpfe_ipipe_yuv422_conv {
-       /* Max Chrominance value */
-       unsigned char en_chrom_lpf;
-       /* 1 - enable LPF for chrminance, 0 - disable */
-       enum vpfe_chr_pos chrom_pos;
-};
-
-#define VPFE_IPIPE_MAX_SIZE_YEE_LUT            1024
-
-enum vpfe_ipipe_yee_merge_meth {
-       VPFE_IPIPE_YEE_ABS_MAX = 0,
-       VPFE_IPIPE_YEE_EE_ES = 1,
-};
-
-/* Structure for configuring YUV Edge Enhancement module */
-struct vpfe_ipipe_yee {
-       /* 1 - enable enhancement, 0 - disable */
-       unsigned char en;
-       /* enable/disable halo reduction in edge sharpner */
-       unsigned char en_halo_red;
-       /* Merge method between Edge Enhancer and Edge sharpner */
-       enum vpfe_ipipe_yee_merge_meth merge_meth;
-       /* HPF Shift length */
-       unsigned char hpf_shft;
-       /* HPF Coefficient 00, S10 */
-       short hpf_coef_00;
-       /* HPF Coefficient 01, S10 */
-       short hpf_coef_01;
-       /* HPF Coefficient 02, S10 */
-       short hpf_coef_02;
-       /* HPF Coefficient 10, S10 */
-       short hpf_coef_10;
-       /* HPF Coefficient 11, S10 */
-       short hpf_coef_11;
-       /* HPF Coefficient 12, S10 */
-       short hpf_coef_12;
-       /* HPF Coefficient 20, S10 */
-       short hpf_coef_20;
-       /* HPF Coefficient 21, S10 */
-       short hpf_coef_21;
-       /* HPF Coefficient 22, S10 */
-       short hpf_coef_22;
-       /* Lower threshold before referring to LUT */
-       unsigned short yee_thr;
-       /* Edge sharpener Gain */
-       unsigned short es_gain;
-       /* Edge sharpener lower threshold */
-       unsigned short es_thr1;
-       /* Edge sharpener upper threshold */
-       unsigned short es_thr2;
-       /* Edge sharpener gain on gradient */
-       unsigned short es_gain_grad;
-       /* Edge sharpener offset on gradient */
-       unsigned short es_ofst_grad;
-       /* Ptr to EE table. Must have 1024 entries */
-       short table[VPFE_IPIPE_MAX_SIZE_YEE_LUT];
-};
-
-enum vpfe_ipipe_car_meth {
-       /* Chromatic Gain Control */
-       VPFE_IPIPE_CAR_CHR_GAIN_CTRL = 0,
-       /* Dynamic switching between CHR_GAIN_CTRL
-        * and MED_FLTR
-        */
-       VPFE_IPIPE_CAR_DYN_SWITCH = 1,
-       /* Median Filter */
-       VPFE_IPIPE_CAR_MED_FLTR = 2,
-};
-
-enum vpfe_ipipe_car_hpf_type {
-       VPFE_IPIPE_CAR_HPF_Y = 0,
-       VPFE_IPIPE_CAR_HPF_H = 1,
-       VPFE_IPIPE_CAR_HPF_V = 2,
-       VPFE_IPIPE_CAR_HPF_2D = 3,
-       /* 2D HPF from YUV Edge Enhancement */
-       VPFE_IPIPE_CAR_HPF_2D_YEE = 4,
-};
-
-struct vpfe_ipipe_car_gain {
-       /* csup_gain */
-       unsigned char gain;
-       /* csup_shf. */
-       unsigned char shft;
-       /* gain minimum */
-       unsigned short gain_min;
-};
-
-/* Structure for Chromatic Artifact Reduction */
-struct vpfe_ipipe_car {
-       /* enable/disable */
-       unsigned char en;
-       /* Gain control or Dynamic switching */
-       enum vpfe_ipipe_car_meth meth;
-       /* Gain1 function configuration for Gain control */
-       struct vpfe_ipipe_car_gain gain1;
-       /* Gain2 function configuration for Gain control */
-       struct vpfe_ipipe_car_gain gain2;
-       /* HPF type used for CAR */
-       enum vpfe_ipipe_car_hpf_type hpf;
-       /* csup_thr: HPF threshold for Gain control */
-       unsigned char hpf_thr;
-       /* Down shift value for hpf. 2 bits */
-       unsigned char hpf_shft;
-       /* switch limit for median filter */
-       unsigned char sw0;
-       /* switch coefficient for Gain control */
-       unsigned char sw1;
-};
-
-/* structure for Chromatic Gain Suppression */
-struct vpfe_ipipe_cgs {
-       /* enable/disable */
-       unsigned char en;
-       /* gain1 bright side threshold */
-       unsigned char h_thr;
-       /* gain1 bright side slope */
-       unsigned char h_slope;
-       /* gain1 down shift value for bright side */
-       unsigned char h_shft;
-       /* gain1 bright side minimum gain */
-       unsigned char h_min;
-};
-
-/* Max pixels allowed in the input. If above this either decimation
- * or frame division mode to be enabled
- */
-#define VPFE_IPIPE_MAX_INPUT_WIDTH     2600
-
-struct vpfe_ipipe_input_config {
-       unsigned int vst;
-       unsigned int hst;
-};
-
-/**
- * struct vpfe_ipipe_config - IPIPE engine configuration (user)
- * @input_config: Pointer to structure for ipipe configuration.
- * @flag: Specifies which ISP IPIPE functions should be enabled.
- * @lutdpc: Pointer to luma enhancement structure.
- * @otfdpc: Pointer to structure for defect correction.
- * @nf1: Pointer to structure for Noise Filter.
- * @nf2: Pointer to structure for Noise Filter.
- * @gic: Pointer to structure for Green Imbalance.
- * @wbal: Pointer to structure for White Balance.
- * @cfa: Pointer to structure containing the CFA interpolation.
- * @rgb2rgb1: Pointer to structure for RGB to RGB Blending.
- * @rgb2rgb2: Pointer to structure for RGB to RGB Blending.
- * @gamma: Pointer to gamma structure.
- * @lut: Pointer to structure for 3D LUT.
- * @rgb2yuv: Pointer to structure for RGB-YCbCr conversion.
- * @gbce: Pointer to structure for Global Brightness,Contrast Control.
- * @yuv422_conv: Pointer to structure for YUV 422 conversion.
- * @yee: Pointer to structure for Edge Enhancer.
- * @car: Pointer to structure for Chromatic Artifact Reduction.
- * @cgs: Pointer to structure for Chromatic Gain Suppression.
- */
-struct vpfe_ipipe_config {
-       __u32 flag;
-       struct vpfe_ipipe_input_config __user *input_config;
-       struct vpfe_ipipe_lutdpc __user *lutdpc;
-       struct vpfe_ipipe_otfdpc __user *otfdpc;
-       struct vpfe_ipipe_nf __user *nf1;
-       struct vpfe_ipipe_nf __user *nf2;
-       struct vpfe_ipipe_gic __user *gic;
-       struct vpfe_ipipe_wb __user *wbal;
-       struct vpfe_ipipe_cfa __user *cfa;
-       struct vpfe_ipipe_rgb2rgb __user *rgb2rgb1;
-       struct vpfe_ipipe_rgb2rgb __user *rgb2rgb2;
-       struct vpfe_ipipe_gamma __user *gamma;
-       struct vpfe_ipipe_3d_lut __user *lut;
-       struct vpfe_ipipe_rgb2yuv __user *rgb2yuv;
-       struct vpfe_ipipe_gbce __user *gbce;
-       struct vpfe_ipipe_yuv422_conv __user *yuv422_conv;
-       struct vpfe_ipipe_yee __user *yee;
-       struct vpfe_ipipe_car __user *car;
-       struct vpfe_ipipe_cgs __user *cgs;
-};
-
-/*******************************************************************
- **  Resizer API structures
- *******************************************************************/
-/* Interpolation types used for horizontal rescale */
-enum vpfe_rsz_intp_t {
-       VPFE_RSZ_INTP_CUBIC,
-       VPFE_RSZ_INTP_LINEAR
-};
-
-/* Horizontal LPF intensity selection */
-enum vpfe_rsz_h_lpf_lse_t {
-       VPFE_RSZ_H_LPF_LSE_INTERN,
-       VPFE_RSZ_H_LPF_LSE_USER_VAL
-};
-
-enum vpfe_rsz_down_scale_ave_sz {
-       VPFE_IPIPE_DWN_SCALE_1_OVER_2,
-       VPFE_IPIPE_DWN_SCALE_1_OVER_4,
-       VPFE_IPIPE_DWN_SCALE_1_OVER_8,
-       VPFE_IPIPE_DWN_SCALE_1_OVER_16,
-       VPFE_IPIPE_DWN_SCALE_1_OVER_32,
-       VPFE_IPIPE_DWN_SCALE_1_OVER_64,
-       VPFE_IPIPE_DWN_SCALE_1_OVER_128,
-       VPFE_IPIPE_DWN_SCALE_1_OVER_256
-};
-
-struct vpfe_rsz_output_spec {
-       /* enable horizontal flip */
-       unsigned char h_flip;
-       /* enable vertical flip */
-       unsigned char v_flip;
-       /* line start offset for y. */
-       unsigned int vst_y;
-       /* line start offset for c. Only for 420 */
-       unsigned int vst_c;
-       /* vertical rescale interpolation type, YCbCr or Luminance */
-       enum vpfe_rsz_intp_t v_typ_y;
-       /* vertical rescale interpolation type for Chrominance */
-       enum vpfe_rsz_intp_t v_typ_c;
-       /* vertical lpf intensity - Luminance */
-       unsigned char v_lpf_int_y;
-       /* vertical lpf intensity - Chrominance */
-       unsigned char v_lpf_int_c;
-       /* horizontal rescale interpolation types, YCbCr or Luminance  */
-       enum vpfe_rsz_intp_t h_typ_y;
-       /* horizontal rescale interpolation types, Chrominance */
-       enum vpfe_rsz_intp_t h_typ_c;
-       /* horizontal lpf intensity - Luminance */
-       unsigned char h_lpf_int_y;
-       /* horizontal lpf intensity - Chrominance */
-       unsigned char h_lpf_int_c;
-       /* Use down scale mode for scale down */
-       unsigned char en_down_scale;
-       /* if downscale, set the downscale more average size for horizontal
-        * direction. Used only if output width and height is less than
-        * input sizes
-        */
-       enum vpfe_rsz_down_scale_ave_sz h_dscale_ave_sz;
-       /* if downscale, set the downscale more average size for vertical
-        * direction. Used only if output width and height is less than
-        * input sizes
-        */
-       enum vpfe_rsz_down_scale_ave_sz v_dscale_ave_sz;
-       /* Y offset. If set, the offset would be added to the base address
-        */
-       unsigned int user_y_ofst;
-       /* C offset. If set, the offset would be added to the base address
-        */
-       unsigned int user_c_ofst;
-};
-
-struct vpfe_rsz_config_params {
-       unsigned int vst;
-       /* horizontal start position of the image
-        * data to IPIPE
-        */
-       unsigned int hst;
-       /* output spec of the image data coming out of resizer - 0(UYVY).
-        */
-       struct vpfe_rsz_output_spec output1;
-       /* output spec of the image data coming out of resizer - 1(UYVY).
-        */
-       struct vpfe_rsz_output_spec output2;
-       /* 0 , chroma sample at odd pixel, 1 - even pixel */
-       unsigned char chroma_sample_even;
-       unsigned char frame_div_mode_en;
-       unsigned char yuv_y_min;
-       unsigned char yuv_y_max;
-       unsigned char yuv_c_min;
-       unsigned char yuv_c_max;
-       enum vpfe_chr_pos out_chr_pos;
-       unsigned char bypass;
-};
-
-/* Structure for VIDIOC_VPFE_RSZ_[S/G]_CONFIG IOCTLs */
-struct vpfe_rsz_config {
-       struct vpfe_rsz_config_params *config;
-};
-
-#endif         /* _DAVINCI_VPFE_USER_H */
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
deleted file mode 100644 (file)
index 52397ad..0000000
+++ /dev/null
@@ -1,1852 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- *
- *
- * IPIPE allows fine tuning of the input image using different
- * tuning modules in IPIPE. Some examples :- Noise filter, Defect
- * pixel correction etc. It essentially operate on Bayer Raw data
- * or YUV raw data. To do image tuning, application call,
- *
- */
-
-#include <linux/slab.h>
-#include <linux/bitops.h>
-
-#include "dm365_ipipe.h"
-#include "dm365_ipipe_hw.h"
-#include "vpfe_mc_capture.h"
-
-#define MIN_OUT_WIDTH  32
-#define MIN_OUT_HEIGHT 32
-
-/* ipipe input format's */
-static const unsigned int ipipe_input_fmts[] = {
-       MEDIA_BUS_FMT_UYVY8_2X8,
-       MEDIA_BUS_FMT_SGRBG12_1X12,
-       MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
-       MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8,
-};
-
-/* ipipe output format's */
-static const unsigned int ipipe_output_fmts[] = {
-       MEDIA_BUS_FMT_UYVY8_2X8,
-};
-
-static int ipipe_validate_lutdpc_params(struct vpfe_ipipe_lutdpc *lutdpc)
-{
-       int i;
-
-       if (lutdpc->en > 1 || lutdpc->repl_white > 1 ||
-           lutdpc->dpc_size > LUT_DPC_MAX_SIZE)
-               return -EINVAL;
-
-       if (lutdpc->en)
-               return -EINVAL;
-
-       for (i = 0; i < lutdpc->dpc_size; i++)
-               if (lutdpc->table[i].horz_pos > LUT_DPC_H_POS_MASK ||
-                   lutdpc->table[i].vert_pos > LUT_DPC_V_POS_MASK)
-                       return -EINVAL;
-
-       return 0;
-}
-
-static int ipipe_set_lutdpc_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_lutdpc *lutdpc = &ipipe->config.lutdpc;
-       struct vpfe_ipipe_lutdpc *dpc_param;
-
-       if (!param) {
-               memset((void *)lutdpc, 0, sizeof(struct vpfe_ipipe_lutdpc));
-               goto success;
-       }
-
-       dpc_param = param;
-       lutdpc->en = dpc_param->en;
-       lutdpc->repl_white = dpc_param->repl_white;
-       lutdpc->dpc_size = dpc_param->dpc_size;
-       memcpy(&lutdpc->table, &dpc_param->table,
-              (dpc_param->dpc_size * sizeof(struct vpfe_ipipe_lutdpc_entry)));
-       if (ipipe_validate_lutdpc_params(lutdpc) < 0)
-               return -EINVAL;
-
-success:
-       ipipe_set_lutdpc_regs(ipipe->base_addr, ipipe->isp5_base_addr, lutdpc);
-
-       return 0;
-}
-
-static int ipipe_get_lutdpc_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_lutdpc *lut_param = param;
-       struct vpfe_ipipe_lutdpc *lutdpc = &ipipe->config.lutdpc;
-
-       lut_param->en = lutdpc->en;
-       lut_param->repl_white = lutdpc->repl_white;
-       lut_param->dpc_size = lutdpc->dpc_size;
-       memcpy(&lut_param->table, &lutdpc->table,
-              (lutdpc->dpc_size * sizeof(struct vpfe_ipipe_lutdpc_entry)));
-
-       return 0;
-}
-
-static int ipipe_set_input_config(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_input_config *config = &ipipe->config.input_config;
-
-       if (!param)
-               memset(config, 0, sizeof(struct vpfe_ipipe_input_config));
-       else
-               memcpy(config, param, sizeof(struct vpfe_ipipe_input_config));
-       return 0;
-}
-
-static int ipipe_get_input_config(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_input_config *config = &ipipe->config.input_config;
-
-       if (!param)
-               return -EINVAL;
-
-       memcpy(param, config, sizeof(struct vpfe_ipipe_input_config));
-
-       return 0;
-}
-
-static int ipipe_validate_otfdpc_params(struct vpfe_ipipe_otfdpc *dpc_param)
-{
-       struct vpfe_ipipe_otfdpc_2_0_cfg *dpc_2_0;
-       struct vpfe_ipipe_otfdpc_3_0_cfg *dpc_3_0;
-
-       if (dpc_param->en > 1)
-               return -EINVAL;
-
-       if (dpc_param->alg == VPFE_IPIPE_OTFDPC_2_0) {
-               dpc_2_0 = &dpc_param->alg_cfg.dpc_2_0;
-               if (dpc_2_0->det_thr.r > OTFDPC_DPC2_THR_MASK ||
-                   dpc_2_0->det_thr.gr > OTFDPC_DPC2_THR_MASK ||
-                   dpc_2_0->det_thr.gb > OTFDPC_DPC2_THR_MASK ||
-                   dpc_2_0->det_thr.b > OTFDPC_DPC2_THR_MASK ||
-                   dpc_2_0->corr_thr.r > OTFDPC_DPC2_THR_MASK ||
-                   dpc_2_0->corr_thr.gr > OTFDPC_DPC2_THR_MASK ||
-                   dpc_2_0->corr_thr.gb > OTFDPC_DPC2_THR_MASK ||
-                   dpc_2_0->corr_thr.b > OTFDPC_DPC2_THR_MASK)
-                       return -EINVAL;
-               return 0;
-       }
-
-       dpc_3_0 = &dpc_param->alg_cfg.dpc_3_0;
-
-       if (dpc_3_0->act_adj_shf > OTF_DPC3_0_SHF_MASK ||
-           dpc_3_0->det_thr > OTF_DPC3_0_DET_MASK ||
-           dpc_3_0->det_slp > OTF_DPC3_0_SLP_MASK ||
-           dpc_3_0->det_thr_min > OTF_DPC3_0_DET_MASK ||
-           dpc_3_0->det_thr_max > OTF_DPC3_0_DET_MASK ||
-           dpc_3_0->corr_thr > OTF_DPC3_0_CORR_MASK ||
-           dpc_3_0->corr_slp > OTF_DPC3_0_SLP_MASK ||
-           dpc_3_0->corr_thr_min > OTF_DPC3_0_CORR_MASK ||
-           dpc_3_0->corr_thr_max > OTF_DPC3_0_CORR_MASK)
-               return -EINVAL;
-
-       return 0;
-}
-
-static int ipipe_set_otfdpc_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_otfdpc *dpc_param = param;
-       struct vpfe_ipipe_otfdpc *otfdpc = &ipipe->config.otfdpc;
-       struct device *dev;
-
-       if (!param) {
-               memset((void *)otfdpc, 0, sizeof(struct ipipe_otfdpc_2_0));
-               goto success;
-       }
-       dev = ipipe->subdev.v4l2_dev->dev;
-       memcpy(otfdpc, dpc_param, sizeof(struct vpfe_ipipe_otfdpc));
-       if (ipipe_validate_otfdpc_params(otfdpc) < 0) {
-               dev_err(dev, "Invalid otfdpc params\n");
-               return -EINVAL;
-       }
-
-success:
-       ipipe_set_otfdpc_regs(ipipe->base_addr, otfdpc);
-
-       return 0;
-}
-
-static int ipipe_get_otfdpc_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_otfdpc *dpc_param = param;
-       struct vpfe_ipipe_otfdpc *otfdpc = &ipipe->config.otfdpc;
-
-       memcpy(dpc_param, otfdpc, sizeof(struct vpfe_ipipe_otfdpc));
-       return 0;
-}
-
-static int ipipe_validate_nf_params(struct vpfe_ipipe_nf *nf_param)
-{
-       int i;
-
-       if (nf_param->en > 1 || nf_param->shft_val > D2F_SHFT_VAL_MASK ||
-           nf_param->spread_val > D2F_SPR_VAL_MASK ||
-           nf_param->apply_lsc_gain > 1 ||
-           nf_param->edge_det_min_thr > D2F_EDGE_DET_THR_MASK ||
-           nf_param->edge_det_max_thr > D2F_EDGE_DET_THR_MASK)
-               return -EINVAL;
-
-       for (i = 0; i < VPFE_IPIPE_NF_THR_TABLE_SIZE; i++)
-               if (nf_param->thr[i] > D2F_THR_VAL_MASK)
-                       return -EINVAL;
-
-       for (i = 0; i < VPFE_IPIPE_NF_STR_TABLE_SIZE; i++)
-               if (nf_param->str[i] > D2F_STR_VAL_MASK)
-                       return -EINVAL;
-
-       return 0;
-}
-
-static int ipipe_set_nf_params(struct vpfe_ipipe_device *ipipe,
-                              unsigned int id, void *param)
-{
-       struct vpfe_ipipe_nf *nf_param = param;
-       struct vpfe_ipipe_nf *nf = &ipipe->config.nf1;
-       struct device *dev;
-
-       if (id == IPIPE_D2F_2ND)
-               nf = &ipipe->config.nf2;
-
-       if (!nf_param) {
-               memset((void *)nf, 0, sizeof(struct vpfe_ipipe_nf));
-               goto success;
-       }
-
-       dev = ipipe->subdev.v4l2_dev->dev;
-       memcpy(nf, nf_param, sizeof(struct vpfe_ipipe_nf));
-       if (ipipe_validate_nf_params(nf) < 0) {
-               dev_err(dev, "Invalid nf params\n");
-               return -EINVAL;
-       }
-
-success:
-       ipipe_set_d2f_regs(ipipe->base_addr, id, nf);
-
-       return 0;
-}
-
-static int ipipe_set_nf1_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       return ipipe_set_nf_params(ipipe, IPIPE_D2F_1ST, param);
-}
-
-static int ipipe_set_nf2_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       return ipipe_set_nf_params(ipipe, IPIPE_D2F_2ND, param);
-}
-
-static int ipipe_get_nf_params(struct vpfe_ipipe_device *ipipe,
-                              unsigned int id, void *param)
-{
-       struct vpfe_ipipe_nf *nf_param = param;
-       struct vpfe_ipipe_nf *nf = &ipipe->config.nf1;
-
-       if (id == IPIPE_D2F_2ND)
-               nf = &ipipe->config.nf2;
-
-       memcpy(nf_param, nf, sizeof(struct vpfe_ipipe_nf));
-
-       return 0;
-}
-
-static int ipipe_get_nf1_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       return ipipe_get_nf_params(ipipe, IPIPE_D2F_1ST, param);
-}
-
-static int ipipe_get_nf2_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       return ipipe_get_nf_params(ipipe, IPIPE_D2F_2ND, param);
-}
-
-static int ipipe_validate_gic_params(struct vpfe_ipipe_gic *gic)
-{
-       if (gic->en > 1 || gic->gain > GIC_GAIN_MASK ||
-           gic->thr > GIC_THR_MASK || gic->slope > GIC_SLOPE_MASK ||
-           gic->apply_lsc_gain > 1 ||
-           gic->nf2_thr_gain.integer > GIC_NFGAN_INT_MASK ||
-           gic->nf2_thr_gain.decimal > GIC_NFGAN_DECI_MASK)
-               return -EINVAL;
-
-       return 0;
-}
-
-static int ipipe_set_gic_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_gic *gic_param = param;
-       struct device *dev = ipipe->subdev.v4l2_dev->dev;
-       struct vpfe_ipipe_gic *gic = &ipipe->config.gic;
-
-       if (!gic_param) {
-               memset((void *)gic, 0, sizeof(struct vpfe_ipipe_gic));
-               goto success;
-       }
-
-       memcpy(gic, gic_param, sizeof(struct vpfe_ipipe_gic));
-       if (ipipe_validate_gic_params(gic) < 0) {
-               dev_err(dev, "Invalid gic params\n");
-               return -EINVAL;
-       }
-
-success:
-       ipipe_set_gic_regs(ipipe->base_addr, gic);
-
-       return 0;
-}
-
-static int ipipe_get_gic_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_gic *gic_param = param;
-       struct vpfe_ipipe_gic *gic = &ipipe->config.gic;
-
-       memcpy(gic_param, gic, sizeof(struct vpfe_ipipe_gic));
-
-       return 0;
-}
-
-static int ipipe_validate_wb_params(struct vpfe_ipipe_wb *wbal)
-{
-       if (wbal->ofst_r > WB_OFFSET_MASK ||
-           wbal->ofst_gr > WB_OFFSET_MASK ||
-           wbal->ofst_gb > WB_OFFSET_MASK ||
-           wbal->ofst_b > WB_OFFSET_MASK ||
-           wbal->gain_r.integer > WB_GAIN_INT_MASK ||
-           wbal->gain_r.decimal > WB_GAIN_DECI_MASK ||
-           wbal->gain_gr.integer > WB_GAIN_INT_MASK ||
-           wbal->gain_gr.decimal > WB_GAIN_DECI_MASK ||
-           wbal->gain_gb.integer > WB_GAIN_INT_MASK ||
-           wbal->gain_gb.decimal > WB_GAIN_DECI_MASK ||
-           wbal->gain_b.integer > WB_GAIN_INT_MASK ||
-           wbal->gain_b.decimal > WB_GAIN_DECI_MASK)
-               return -EINVAL;
-
-       return 0;
-}
-
-static int ipipe_set_wb_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_wb *wb_param = param;
-       struct vpfe_ipipe_wb *wbal = &ipipe->config.wbal;
-
-       if (!wb_param) {
-               const struct vpfe_ipipe_wb wb_defaults = {
-                       .gain_r  = {2, 0x0},
-                       .gain_gr = {2, 0x0},
-                       .gain_gb = {2, 0x0},
-                       .gain_b  = {2, 0x0}
-               };
-               memcpy(wbal, &wb_defaults, sizeof(struct vpfe_ipipe_wb));
-               goto success;
-       }
-
-       memcpy(wbal, wb_param, sizeof(struct vpfe_ipipe_wb));
-       if (ipipe_validate_wb_params(wbal) < 0)
-               return -EINVAL;
-
-success:
-       ipipe_set_wb_regs(ipipe->base_addr, wbal);
-
-       return 0;
-}
-
-static int ipipe_get_wb_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_wb *wb_param = param;
-       struct vpfe_ipipe_wb *wbal = &ipipe->config.wbal;
-
-       memcpy(wb_param, wbal, sizeof(struct vpfe_ipipe_wb));
-       return 0;
-}
-
-static int ipipe_validate_cfa_params(struct vpfe_ipipe_cfa *cfa)
-{
-       if (cfa->hpf_thr_2dir > CFA_HPF_THR_2DIR_MASK ||
-           cfa->hpf_slp_2dir > CFA_HPF_SLOPE_2DIR_MASK ||
-           cfa->hp_mix_thr_2dir > CFA_HPF_MIX_THR_2DIR_MASK ||
-           cfa->hp_mix_slope_2dir > CFA_HPF_MIX_SLP_2DIR_MASK ||
-           cfa->dir_thr_2dir > CFA_DIR_THR_2DIR_MASK ||
-           cfa->dir_slope_2dir > CFA_DIR_SLP_2DIR_MASK ||
-           cfa->nd_wt_2dir > CFA_ND_WT_2DIR_MASK ||
-           cfa->hue_fract_daa > CFA_DAA_HUE_FRA_MASK ||
-           cfa->edge_thr_daa > CFA_DAA_EDG_THR_MASK ||
-           cfa->thr_min_daa > CFA_DAA_THR_MIN_MASK ||
-           cfa->thr_slope_daa > CFA_DAA_THR_SLP_MASK ||
-           cfa->slope_min_daa > CFA_DAA_SLP_MIN_MASK ||
-           cfa->slope_slope_daa > CFA_DAA_SLP_SLP_MASK ||
-           cfa->lp_wt_daa > CFA_DAA_LP_WT_MASK)
-               return -EINVAL;
-
-       return 0;
-}
-
-static int ipipe_set_cfa_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_cfa *cfa_param = param;
-       struct vpfe_ipipe_cfa *cfa = &ipipe->config.cfa;
-
-       if (!cfa_param) {
-               memset(cfa, 0, sizeof(struct vpfe_ipipe_cfa));
-               cfa->alg = VPFE_IPIPE_CFA_ALG_2DIRAC;
-               goto success;
-       }
-
-       memcpy(cfa, cfa_param, sizeof(struct vpfe_ipipe_cfa));
-       if (ipipe_validate_cfa_params(cfa) < 0)
-               return -EINVAL;
-
-success:
-       ipipe_set_cfa_regs(ipipe->base_addr, cfa);
-
-       return 0;
-}
-
-static int ipipe_get_cfa_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_cfa *cfa_param = param;
-       struct vpfe_ipipe_cfa *cfa = &ipipe->config.cfa;
-
-       memcpy(cfa_param, cfa, sizeof(struct vpfe_ipipe_cfa));
-       return 0;
-}
-
-static int
-ipipe_validate_rgb2rgb_params(struct vpfe_ipipe_rgb2rgb *rgb2rgb,
-                             unsigned int id)
-{
-       u32 gain_int_upper = RGB2RGB_1_GAIN_INT_MASK;
-       u32 offset_upper = RGB2RGB_1_OFST_MASK;
-
-       if (id == IPIPE_RGB2RGB_2) {
-               offset_upper = RGB2RGB_2_OFST_MASK;
-               gain_int_upper = RGB2RGB_2_GAIN_INT_MASK;
-       }
-
-       if (rgb2rgb->coef_rr.decimal > RGB2RGB_GAIN_DECI_MASK ||
-           rgb2rgb->coef_rr.integer > gain_int_upper)
-               return -EINVAL;
-
-       if (rgb2rgb->coef_gr.decimal > RGB2RGB_GAIN_DECI_MASK ||
-           rgb2rgb->coef_gr.integer > gain_int_upper)
-               return -EINVAL;
-
-       if (rgb2rgb->coef_br.decimal > RGB2RGB_GAIN_DECI_MASK ||
-           rgb2rgb->coef_br.integer > gain_int_upper)
-               return -EINVAL;
-
-       if (rgb2rgb->coef_rg.decimal > RGB2RGB_GAIN_DECI_MASK ||
-           rgb2rgb->coef_rg.integer > gain_int_upper)
-               return -EINVAL;
-
-       if (rgb2rgb->coef_gg.decimal > RGB2RGB_GAIN_DECI_MASK ||
-           rgb2rgb->coef_gg.integer > gain_int_upper)
-               return -EINVAL;
-
-       if (rgb2rgb->coef_bg.decimal > RGB2RGB_GAIN_DECI_MASK ||
-           rgb2rgb->coef_bg.integer > gain_int_upper)
-               return -EINVAL;
-
-       if (rgb2rgb->coef_rb.decimal > RGB2RGB_GAIN_DECI_MASK ||
-           rgb2rgb->coef_rb.integer > gain_int_upper)
-               return -EINVAL;
-
-       if (rgb2rgb->coef_gb.decimal > RGB2RGB_GAIN_DECI_MASK ||
-           rgb2rgb->coef_gb.integer > gain_int_upper)
-               return -EINVAL;
-
-       if (rgb2rgb->coef_bb.decimal > RGB2RGB_GAIN_DECI_MASK ||
-           rgb2rgb->coef_bb.integer > gain_int_upper)
-               return -EINVAL;
-
-       if (rgb2rgb->out_ofst_r > offset_upper ||
-           rgb2rgb->out_ofst_g > offset_upper ||
-           rgb2rgb->out_ofst_b > offset_upper)
-               return -EINVAL;
-
-       return 0;
-}
-
-static int ipipe_set_rgb2rgb_params(struct vpfe_ipipe_device *ipipe,
-                                   unsigned int id, void *param)
-{
-       struct vpfe_ipipe_rgb2rgb *rgb2rgb = &ipipe->config.rgb2rgb1;
-       struct device *dev = ipipe->subdev.v4l2_dev->dev;
-       struct vpfe_ipipe_rgb2rgb *rgb2rgb_param;
-
-       rgb2rgb_param = param;
-
-       if (id == IPIPE_RGB2RGB_2)
-               rgb2rgb = &ipipe->config.rgb2rgb2;
-
-       if (!rgb2rgb_param) {
-               const struct vpfe_ipipe_rgb2rgb rgb2rgb_defaults = {
-                       .coef_rr = {1, 0},      /* 256 */
-                       .coef_gr = {0, 0},
-                       .coef_br = {0, 0},
-                       .coef_rg = {0, 0},
-                       .coef_gg = {1, 0},      /* 256 */
-                       .coef_bg = {0, 0},
-                       .coef_rb = {0, 0},
-                       .coef_gb = {0, 0},
-                       .coef_bb = {1, 0},      /* 256 */
-               };
-               /* Copy defaults for rgb2rgb conversion */
-               memcpy(rgb2rgb, &rgb2rgb_defaults,
-                      sizeof(struct vpfe_ipipe_rgb2rgb));
-               goto success;
-       }
-
-       memcpy(rgb2rgb, rgb2rgb_param, sizeof(struct vpfe_ipipe_rgb2rgb));
-       if (ipipe_validate_rgb2rgb_params(rgb2rgb, id) < 0) {
-               dev_err(dev, "Invalid rgb2rgb params\n");
-               return -EINVAL;
-       }
-
-success:
-       ipipe_set_rgb2rgb_regs(ipipe->base_addr, id, rgb2rgb);
-
-       return 0;
-}
-
-static int
-ipipe_set_rgb2rgb_1_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       return ipipe_set_rgb2rgb_params(ipipe, IPIPE_RGB2RGB_1, param);
-}
-
-static int
-ipipe_set_rgb2rgb_2_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       return ipipe_set_rgb2rgb_params(ipipe, IPIPE_RGB2RGB_2, param);
-}
-
-static int ipipe_get_rgb2rgb_params(struct vpfe_ipipe_device *ipipe,
-                                   unsigned int id, void *param)
-{
-       struct vpfe_ipipe_rgb2rgb *rgb2rgb = &ipipe->config.rgb2rgb1;
-       struct vpfe_ipipe_rgb2rgb *rgb2rgb_param;
-
-       rgb2rgb_param = param;
-
-       if (id == IPIPE_RGB2RGB_2)
-               rgb2rgb = &ipipe->config.rgb2rgb2;
-
-       memcpy(rgb2rgb_param, rgb2rgb, sizeof(struct vpfe_ipipe_rgb2rgb));
-
-       return 0;
-}
-
-static int
-ipipe_get_rgb2rgb_1_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       return ipipe_get_rgb2rgb_params(ipipe, IPIPE_RGB2RGB_1, param);
-}
-
-static int
-ipipe_get_rgb2rgb_2_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       return ipipe_get_rgb2rgb_params(ipipe, IPIPE_RGB2RGB_2, param);
-}
-
-static int
-ipipe_validate_gamma_entry(struct vpfe_ipipe_gamma_entry *table, int size)
-{
-       int i;
-
-       if (!table)
-               return -EINVAL;
-
-       for (i = 0; i < size; i++)
-               if (table[i].slope > GAMMA_MASK ||
-                   table[i].offset > GAMMA_MASK)
-                       return -EINVAL;
-
-       return 0;
-}
-
-static int
-ipipe_validate_gamma_params(struct vpfe_ipipe_gamma *gamma, struct device *dev)
-{
-       int table_size;
-       int err;
-
-       if (gamma->bypass_r > 1 ||
-           gamma->bypass_b > 1 ||
-           gamma->bypass_g > 1)
-               return -EINVAL;
-
-       if (gamma->tbl_sel != VPFE_IPIPE_GAMMA_TBL_RAM)
-               return 0;
-
-       table_size = gamma->tbl_size;
-       if (!gamma->bypass_r) {
-               err = ipipe_validate_gamma_entry(gamma->table_r, table_size);
-               if (err) {
-                       dev_err(dev, "GAMMA R - table entry invalid\n");
-                       return err;
-               }
-       }
-
-       if (!gamma->bypass_b) {
-               err = ipipe_validate_gamma_entry(gamma->table_b, table_size);
-               if (err) {
-                       dev_err(dev, "GAMMA B - table entry invalid\n");
-                       return err;
-               }
-       }
-
-       if (!gamma->bypass_g) {
-               err = ipipe_validate_gamma_entry(gamma->table_g, table_size);
-               if (err) {
-                       dev_err(dev, "GAMMA G - table entry invalid\n");
-                       return err;
-               }
-       }
-
-       return 0;
-}
-
-static int
-ipipe_set_gamma_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_gamma *gamma_param = param;
-       struct vpfe_ipipe_gamma *gamma = &ipipe->config.gamma;
-       struct device *dev = ipipe->subdev.v4l2_dev->dev;
-       int table_size;
-
-       if (!gamma_param) {
-               memset(gamma, 0, sizeof(struct vpfe_ipipe_gamma));
-               gamma->tbl_sel = VPFE_IPIPE_GAMMA_TBL_ROM;
-               goto success;
-       }
-
-       gamma->bypass_r = gamma_param->bypass_r;
-       gamma->bypass_b = gamma_param->bypass_b;
-       gamma->bypass_g = gamma_param->bypass_g;
-       gamma->tbl_sel = gamma_param->tbl_sel;
-       gamma->tbl_size = gamma_param->tbl_size;
-
-       if (ipipe_validate_gamma_params(gamma, dev) < 0)
-               return -EINVAL;
-
-       if (gamma_param->tbl_sel != VPFE_IPIPE_GAMMA_TBL_RAM)
-               goto success;
-
-       table_size = gamma->tbl_size;
-       if (!gamma_param->bypass_r)
-               memcpy(&gamma->table_r, &gamma_param->table_r,
-                      (table_size * sizeof(struct vpfe_ipipe_gamma_entry)));
-
-       if (!gamma_param->bypass_b)
-               memcpy(&gamma->table_b, &gamma_param->table_b,
-                      (table_size * sizeof(struct vpfe_ipipe_gamma_entry)));
-
-       if (!gamma_param->bypass_g)
-               memcpy(&gamma->table_g, &gamma_param->table_g,
-                      (table_size * sizeof(struct vpfe_ipipe_gamma_entry)));
-
-success:
-       ipipe_set_gamma_regs(ipipe->base_addr, ipipe->isp5_base_addr, gamma);
-
-       return 0;
-}
-
-static int ipipe_get_gamma_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_gamma *gamma_param = param;
-       struct vpfe_ipipe_gamma *gamma = &ipipe->config.gamma;
-       struct device *dev = ipipe->subdev.v4l2_dev->dev;
-       int table_size;
-
-       gamma_param->bypass_r = gamma->bypass_r;
-       gamma_param->bypass_g = gamma->bypass_g;
-       gamma_param->bypass_b = gamma->bypass_b;
-       gamma_param->tbl_sel = gamma->tbl_sel;
-       gamma_param->tbl_size = gamma->tbl_size;
-
-       if (gamma->tbl_sel != VPFE_IPIPE_GAMMA_TBL_RAM)
-               return 0;
-
-       table_size = gamma->tbl_size;
-
-       if (!gamma->bypass_r) {
-               dev_err(dev,
-                       "%s: table ptr empty for R\n", __func__);
-               return -EINVAL;
-       }
-       memcpy(gamma_param->table_r, gamma->table_r,
-              (table_size * sizeof(struct vpfe_ipipe_gamma_entry)));
-
-       if (!gamma->bypass_g) {
-               dev_err(dev, "%s: table ptr empty for G\n", __func__);
-               return -EINVAL;
-       }
-       memcpy(gamma_param->table_g, gamma->table_g,
-              (table_size * sizeof(struct vpfe_ipipe_gamma_entry)));
-
-       if (!gamma->bypass_b) {
-               dev_err(dev, "%s: table ptr empty for B\n", __func__);
-               return -EINVAL;
-       }
-       memcpy(gamma_param->table_b, gamma->table_b,
-              (table_size * sizeof(struct vpfe_ipipe_gamma_entry)));
-
-       return 0;
-}
-
-static int ipipe_validate_3d_lut_params(struct vpfe_ipipe_3d_lut *lut)
-{
-       int i;
-
-       if (!lut->en)
-               return 0;
-
-       for (i = 0; i < VPFE_IPIPE_MAX_SIZE_3D_LUT; i++)
-               if (lut->table[i].r > D3_LUT_ENTRY_MASK ||
-                   lut->table[i].g > D3_LUT_ENTRY_MASK ||
-                   lut->table[i].b > D3_LUT_ENTRY_MASK)
-                       return -EINVAL;
-
-       return 0;
-}
-
-static int ipipe_get_3d_lut_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_3d_lut *lut_param = param;
-       struct vpfe_ipipe_3d_lut *lut = &ipipe->config.lut;
-
-       lut_param->en = lut->en;
-
-       memcpy(lut_param->table, &lut->table,
-              (VPFE_IPIPE_MAX_SIZE_3D_LUT *
-              sizeof(struct vpfe_ipipe_3d_lut_entry)));
-
-       return 0;
-}
-
-static int
-ipipe_set_3d_lut_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_3d_lut *lut_param = param;
-       struct vpfe_ipipe_3d_lut *lut = &ipipe->config.lut;
-       struct device *dev = ipipe->subdev.v4l2_dev->dev;
-
-       if (!lut_param) {
-               memset(lut, 0, sizeof(struct vpfe_ipipe_3d_lut));
-               goto success;
-       }
-
-       memcpy(lut, lut_param, sizeof(struct vpfe_ipipe_3d_lut));
-       if (ipipe_validate_3d_lut_params(lut) < 0) {
-               dev_err(dev, "Invalid 3D-LUT Params\n");
-               return -EINVAL;
-       }
-
-success:
-       ipipe_set_3d_lut_regs(ipipe->base_addr, ipipe->isp5_base_addr, lut);
-
-       return 0;
-}
-
-static int ipipe_validate_rgb2yuv_params(struct vpfe_ipipe_rgb2yuv *rgb2yuv)
-{
-       if (rgb2yuv->coef_ry.decimal > RGB2YCBCR_COEF_DECI_MASK ||
-           rgb2yuv->coef_ry.integer > RGB2YCBCR_COEF_INT_MASK)
-               return -EINVAL;
-
-       if (rgb2yuv->coef_gy.decimal > RGB2YCBCR_COEF_DECI_MASK ||
-           rgb2yuv->coef_gy.integer > RGB2YCBCR_COEF_INT_MASK)
-               return -EINVAL;
-
-       if (rgb2yuv->coef_by.decimal > RGB2YCBCR_COEF_DECI_MASK ||
-           rgb2yuv->coef_by.integer > RGB2YCBCR_COEF_INT_MASK)
-               return -EINVAL;
-
-       if (rgb2yuv->coef_rcb.decimal > RGB2YCBCR_COEF_DECI_MASK ||
-           rgb2yuv->coef_rcb.integer > RGB2YCBCR_COEF_INT_MASK)
-               return -EINVAL;
-
-       if (rgb2yuv->coef_gcb.decimal > RGB2YCBCR_COEF_DECI_MASK ||
-           rgb2yuv->coef_gcb.integer > RGB2YCBCR_COEF_INT_MASK)
-               return -EINVAL;
-
-       if (rgb2yuv->coef_bcb.decimal > RGB2YCBCR_COEF_DECI_MASK ||
-           rgb2yuv->coef_bcb.integer > RGB2YCBCR_COEF_INT_MASK)
-               return -EINVAL;
-
-       if (rgb2yuv->coef_rcr.decimal > RGB2YCBCR_COEF_DECI_MASK ||
-           rgb2yuv->coef_rcr.integer > RGB2YCBCR_COEF_INT_MASK)
-               return -EINVAL;
-
-       if (rgb2yuv->coef_gcr.decimal > RGB2YCBCR_COEF_DECI_MASK ||
-           rgb2yuv->coef_gcr.integer > RGB2YCBCR_COEF_INT_MASK)
-               return -EINVAL;
-
-       if (rgb2yuv->coef_bcr.decimal > RGB2YCBCR_COEF_DECI_MASK ||
-           rgb2yuv->coef_bcr.integer > RGB2YCBCR_COEF_INT_MASK)
-               return -EINVAL;
-
-       if (rgb2yuv->out_ofst_y > RGB2YCBCR_OFST_MASK ||
-           rgb2yuv->out_ofst_cb > RGB2YCBCR_OFST_MASK ||
-           rgb2yuv->out_ofst_cr > RGB2YCBCR_OFST_MASK)
-               return -EINVAL;
-
-       return 0;
-}
-
-static int
-ipipe_set_rgb2yuv_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_rgb2yuv *rgb2yuv = &ipipe->config.rgb2yuv;
-       struct device *dev = ipipe->subdev.v4l2_dev->dev;
-       struct vpfe_ipipe_rgb2yuv *rgb2yuv_param;
-
-       rgb2yuv_param = param;
-       if (!rgb2yuv_param) {
-               /* Defaults for rgb2yuv conversion */
-               const struct vpfe_ipipe_rgb2yuv rgb2yuv_defaults = {
-                       .coef_ry  = {0, 0x4d},
-                       .coef_gy  = {0, 0x96},
-                       .coef_by  = {0, 0x1d},
-                       .coef_rcb = {0xf, 0xd5},
-                       .coef_gcb = {0xf, 0xab},
-                       .coef_bcb = {0, 0x80},
-                       .coef_rcr = {0, 0x80},
-                       .coef_gcr = {0xf, 0x95},
-                       .coef_bcr = {0xf, 0xeb},
-                       .out_ofst_cb = 0x80,
-                       .out_ofst_cr = 0x80,
-               };
-               /* Copy defaults for rgb2yuv conversion  */
-               memcpy(rgb2yuv, &rgb2yuv_defaults,
-                      sizeof(struct vpfe_ipipe_rgb2yuv));
-               goto success;
-       }
-
-       memcpy(rgb2yuv, rgb2yuv_param, sizeof(struct vpfe_ipipe_rgb2yuv));
-       if (ipipe_validate_rgb2yuv_params(rgb2yuv) < 0) {
-               dev_err(dev, "Invalid rgb2yuv params\n");
-               return -EINVAL;
-       }
-
-success:
-       ipipe_set_rgb2ycbcr_regs(ipipe->base_addr, rgb2yuv);
-
-       return 0;
-}
-
-static int
-ipipe_get_rgb2yuv_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_rgb2yuv *rgb2yuv = &ipipe->config.rgb2yuv;
-       struct vpfe_ipipe_rgb2yuv *rgb2yuv_param;
-
-       rgb2yuv_param = param;
-       memcpy(rgb2yuv_param, rgb2yuv, sizeof(struct vpfe_ipipe_rgb2yuv));
-       return 0;
-}
-
-static int ipipe_validate_gbce_params(struct vpfe_ipipe_gbce *gbce)
-{
-       u32 max = GBCE_Y_VAL_MASK;
-       int i;
-
-       if (!gbce->en)
-               return 0;
-
-       if (gbce->type == VPFE_IPIPE_GBCE_GAIN_TBL)
-               max = GBCE_GAIN_VAL_MASK;
-
-       for (i = 0; i < VPFE_IPIPE_MAX_SIZE_GBCE_LUT; i++)
-               if (gbce->table[i] > max)
-                       return -EINVAL;
-
-       return 0;
-}
-
-static int ipipe_set_gbce_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_gbce *gbce_param = param;
-       struct vpfe_ipipe_gbce *gbce = &ipipe->config.gbce;
-       struct device *dev = ipipe->subdev.v4l2_dev->dev;
-
-       if (!gbce_param) {
-               memset(gbce, 0, sizeof(struct vpfe_ipipe_gbce));
-       } else {
-               memcpy(gbce, gbce_param, sizeof(struct vpfe_ipipe_gbce));
-               if (ipipe_validate_gbce_params(gbce) < 0) {
-                       dev_err(dev, "Invalid gbce params\n");
-                       return -EINVAL;
-               }
-       }
-
-       ipipe_set_gbce_regs(ipipe->base_addr, ipipe->isp5_base_addr, gbce);
-
-       return 0;
-}
-
-static int ipipe_get_gbce_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_gbce *gbce_param = param;
-       struct vpfe_ipipe_gbce *gbce = &ipipe->config.gbce;
-
-       gbce_param->en = gbce->en;
-       gbce_param->type = gbce->type;
-
-       memcpy(gbce_param->table, gbce->table,
-              (VPFE_IPIPE_MAX_SIZE_GBCE_LUT * sizeof(unsigned short)));
-
-       return 0;
-}
-
-static int
-ipipe_validate_yuv422_conv_params(struct vpfe_ipipe_yuv422_conv *yuv422_conv)
-{
-       if (yuv422_conv->en_chrom_lpf > 1)
-               return -EINVAL;
-
-       return 0;
-}
-
-static int
-ipipe_set_yuv422_conv_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_yuv422_conv *yuv422_conv = &ipipe->config.yuv422_conv;
-       struct vpfe_ipipe_yuv422_conv *yuv422_conv_param;
-       struct device *dev = ipipe->subdev.v4l2_dev->dev;
-
-       yuv422_conv_param = param;
-       if (!yuv422_conv_param) {
-               memset(yuv422_conv, 0, sizeof(struct vpfe_ipipe_yuv422_conv));
-               yuv422_conv->chrom_pos = VPFE_IPIPE_YUV422_CHR_POS_COSITE;
-       } else {
-               memcpy(yuv422_conv, yuv422_conv_param,
-                      sizeof(struct vpfe_ipipe_yuv422_conv));
-               if (ipipe_validate_yuv422_conv_params(yuv422_conv) < 0) {
-                       dev_err(dev, "Invalid yuv422 params\n");
-                       return -EINVAL;
-               }
-       }
-
-       ipipe_set_yuv422_conv_regs(ipipe->base_addr, yuv422_conv);
-
-       return 0;
-}
-
-static int
-ipipe_get_yuv422_conv_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_yuv422_conv *yuv422_conv = &ipipe->config.yuv422_conv;
-       struct vpfe_ipipe_yuv422_conv *yuv422_conv_param;
-
-       yuv422_conv_param = param;
-       memcpy(yuv422_conv_param, yuv422_conv,
-              sizeof(struct vpfe_ipipe_yuv422_conv));
-
-       return 0;
-}
-
-static int ipipe_validate_yee_params(struct vpfe_ipipe_yee *yee)
-{
-       int i;
-
-       if (yee->en > 1 ||
-           yee->en_halo_red > 1 ||
-           yee->hpf_shft > YEE_HPF_SHIFT_MASK)
-               return -EINVAL;
-
-       if (yee->hpf_coef_00 > YEE_COEF_MASK ||
-           yee->hpf_coef_01 > YEE_COEF_MASK ||
-           yee->hpf_coef_02 > YEE_COEF_MASK ||
-           yee->hpf_coef_10 > YEE_COEF_MASK ||
-           yee->hpf_coef_11 > YEE_COEF_MASK ||
-           yee->hpf_coef_12 > YEE_COEF_MASK ||
-           yee->hpf_coef_20 > YEE_COEF_MASK ||
-           yee->hpf_coef_21 > YEE_COEF_MASK ||
-           yee->hpf_coef_22 > YEE_COEF_MASK)
-               return -EINVAL;
-
-       if (yee->yee_thr > YEE_THR_MASK ||
-           yee->es_gain > YEE_ES_GAIN_MASK ||
-           yee->es_thr1 > YEE_ES_THR1_MASK ||
-           yee->es_thr2 > YEE_THR_MASK ||
-           yee->es_gain_grad > YEE_THR_MASK ||
-           yee->es_ofst_grad > YEE_THR_MASK)
-               return -EINVAL;
-
-       for (i = 0; i < VPFE_IPIPE_MAX_SIZE_YEE_LUT; i++)
-               if (yee->table[i] > YEE_ENTRY_MASK)
-                       return -EINVAL;
-
-       return 0;
-}
-
-static int ipipe_set_yee_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_yee *yee_param = param;
-       struct device *dev = ipipe->subdev.v4l2_dev->dev;
-       struct vpfe_ipipe_yee *yee = &ipipe->config.yee;
-
-       if (!yee_param) {
-               memset(yee, 0, sizeof(struct vpfe_ipipe_yee));
-       } else {
-               memcpy(yee, yee_param, sizeof(struct vpfe_ipipe_yee));
-               if (ipipe_validate_yee_params(yee) < 0) {
-                       dev_err(dev, "Invalid yee params\n");
-                       return -EINVAL;
-               }
-       }
-
-       ipipe_set_ee_regs(ipipe->base_addr, ipipe->isp5_base_addr, yee);
-
-       return 0;
-}
-
-static int ipipe_get_yee_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_yee *yee_param = param;
-       struct vpfe_ipipe_yee *yee = &ipipe->config.yee;
-
-       yee_param->en = yee->en;
-       yee_param->en_halo_red = yee->en_halo_red;
-       yee_param->merge_meth = yee->merge_meth;
-       yee_param->hpf_shft = yee->hpf_shft;
-       yee_param->hpf_coef_00 = yee->hpf_coef_00;
-       yee_param->hpf_coef_01 = yee->hpf_coef_01;
-       yee_param->hpf_coef_02 = yee->hpf_coef_02;
-       yee_param->hpf_coef_10 = yee->hpf_coef_10;
-       yee_param->hpf_coef_11 = yee->hpf_coef_11;
-       yee_param->hpf_coef_12 = yee->hpf_coef_12;
-       yee_param->hpf_coef_20 = yee->hpf_coef_20;
-       yee_param->hpf_coef_21 = yee->hpf_coef_21;
-       yee_param->hpf_coef_22 = yee->hpf_coef_22;
-       yee_param->yee_thr = yee->yee_thr;
-       yee_param->es_gain = yee->es_gain;
-       yee_param->es_thr1 = yee->es_thr1;
-       yee_param->es_thr2 = yee->es_thr2;
-       yee_param->es_gain_grad = yee->es_gain_grad;
-       yee_param->es_ofst_grad = yee->es_ofst_grad;
-       memcpy(yee_param->table, &yee->table,
-              (VPFE_IPIPE_MAX_SIZE_YEE_LUT * sizeof(short)));
-
-       return 0;
-}
-
-static int ipipe_validate_car_params(struct vpfe_ipipe_car *car)
-{
-       if (car->en > 1 || car->hpf_shft > CAR_HPF_SHIFT_MASK ||
-           car->gain1.shft > CAR_GAIN1_SHFT_MASK ||
-           car->gain1.gain_min > CAR_GAIN_MIN_MASK ||
-           car->gain2.shft > CAR_GAIN2_SHFT_MASK ||
-           car->gain2.gain_min > CAR_GAIN_MIN_MASK)
-               return -EINVAL;
-
-       return 0;
-}
-
-static int ipipe_set_car_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_car *car_param = param;
-       struct device *dev = ipipe->subdev.v4l2_dev->dev;
-       struct vpfe_ipipe_car *car = &ipipe->config.car;
-
-       if (!car_param) {
-               memset(car, 0, sizeof(struct vpfe_ipipe_car));
-       } else {
-               memcpy(car, car_param, sizeof(struct vpfe_ipipe_car));
-               if (ipipe_validate_car_params(car) < 0) {
-                       dev_err(dev, "Invalid car params\n");
-                       return -EINVAL;
-               }
-       }
-
-       ipipe_set_car_regs(ipipe->base_addr, car);
-
-       return 0;
-}
-
-static int ipipe_get_car_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_car *car_param = param;
-       struct vpfe_ipipe_car *car = &ipipe->config.car;
-
-       memcpy(car_param, car, sizeof(struct vpfe_ipipe_car));
-       return 0;
-}
-
-static int ipipe_validate_cgs_params(struct vpfe_ipipe_cgs *cgs)
-{
-       if (cgs->en > 1 || cgs->h_shft > CAR_SHIFT_MASK)
-               return -EINVAL;
-
-       return 0;
-}
-
-static int ipipe_set_cgs_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_cgs *cgs_param = param;
-       struct device *dev = ipipe->subdev.v4l2_dev->dev;
-       struct vpfe_ipipe_cgs *cgs = &ipipe->config.cgs;
-
-       if (!cgs_param) {
-               memset(cgs, 0, sizeof(struct vpfe_ipipe_cgs));
-       } else {
-               memcpy(cgs, cgs_param, sizeof(struct vpfe_ipipe_cgs));
-               if (ipipe_validate_cgs_params(cgs) < 0) {
-                       dev_err(dev, "Invalid cgs params\n");
-                       return -EINVAL;
-               }
-       }
-
-       ipipe_set_cgs_regs(ipipe->base_addr, cgs);
-
-       return 0;
-}
-
-static int ipipe_get_cgs_params(struct vpfe_ipipe_device *ipipe, void *param)
-{
-       struct vpfe_ipipe_cgs *cgs_param = param;
-       struct vpfe_ipipe_cgs *cgs = &ipipe->config.cgs;
-
-       memcpy(cgs_param, cgs, sizeof(struct vpfe_ipipe_cgs));
-
-       return 0;
-}
-
-static const struct ipipe_module_if ipipe_modules[VPFE_IPIPE_MAX_MODULES] = {
-       /* VPFE_IPIPE_INPUT_CONFIG */ {
-               offsetof(struct ipipe_module_params, input_config),
-               FIELD_SIZEOF(struct ipipe_module_params, input_config),
-               offsetof(struct vpfe_ipipe_config, input_config),
-               ipipe_set_input_config,
-               ipipe_get_input_config,
-       }, /* VPFE_IPIPE_LUTDPC */ {
-               offsetof(struct ipipe_module_params, lutdpc),
-               FIELD_SIZEOF(struct ipipe_module_params, lutdpc),
-               offsetof(struct vpfe_ipipe_config, lutdpc),
-               ipipe_set_lutdpc_params,
-               ipipe_get_lutdpc_params,
-       }, /* VPFE_IPIPE_OTFDPC */ {
-               offsetof(struct ipipe_module_params, otfdpc),
-               FIELD_SIZEOF(struct ipipe_module_params, otfdpc),
-               offsetof(struct vpfe_ipipe_config, otfdpc),
-               ipipe_set_otfdpc_params,
-               ipipe_get_otfdpc_params,
-       }, /* VPFE_IPIPE_NF1 */ {
-               offsetof(struct ipipe_module_params, nf1),
-               FIELD_SIZEOF(struct ipipe_module_params, nf1),
-               offsetof(struct vpfe_ipipe_config, nf1),
-               ipipe_set_nf1_params,
-               ipipe_get_nf1_params,
-       }, /* VPFE_IPIPE_NF2 */ {
-               offsetof(struct ipipe_module_params, nf2),
-               FIELD_SIZEOF(struct ipipe_module_params, nf2),
-               offsetof(struct vpfe_ipipe_config, nf2),
-               ipipe_set_nf2_params,
-               ipipe_get_nf2_params,
-       }, /* VPFE_IPIPE_WB */ {
-               offsetof(struct ipipe_module_params, wbal),
-               FIELD_SIZEOF(struct ipipe_module_params, wbal),
-               offsetof(struct vpfe_ipipe_config, wbal),
-               ipipe_set_wb_params,
-               ipipe_get_wb_params,
-       }, /* VPFE_IPIPE_RGB2RGB_1 */ {
-               offsetof(struct ipipe_module_params, rgb2rgb1),
-               FIELD_SIZEOF(struct ipipe_module_params, rgb2rgb1),
-               offsetof(struct vpfe_ipipe_config, rgb2rgb1),
-               ipipe_set_rgb2rgb_1_params,
-               ipipe_get_rgb2rgb_1_params,
-       }, /* VPFE_IPIPE_RGB2RGB_2 */ {
-               offsetof(struct ipipe_module_params, rgb2rgb2),
-               FIELD_SIZEOF(struct ipipe_module_params, rgb2rgb2),
-               offsetof(struct vpfe_ipipe_config, rgb2rgb2),
-               ipipe_set_rgb2rgb_2_params,
-               ipipe_get_rgb2rgb_2_params,
-       }, /* VPFE_IPIPE_GAMMA */ {
-               offsetof(struct ipipe_module_params, gamma),
-               FIELD_SIZEOF(struct ipipe_module_params, gamma),
-               offsetof(struct vpfe_ipipe_config, gamma),
-               ipipe_set_gamma_params,
-               ipipe_get_gamma_params,
-       }, /* VPFE_IPIPE_3D_LUT */ {
-               offsetof(struct ipipe_module_params, lut),
-               FIELD_SIZEOF(struct ipipe_module_params, lut),
-               offsetof(struct vpfe_ipipe_config, lut),
-               ipipe_set_3d_lut_params,
-               ipipe_get_3d_lut_params,
-       }, /* VPFE_IPIPE_RGB2YUV */ {
-               offsetof(struct ipipe_module_params, rgb2yuv),
-               FIELD_SIZEOF(struct ipipe_module_params, rgb2yuv),
-               offsetof(struct vpfe_ipipe_config, rgb2yuv),
-               ipipe_set_rgb2yuv_params,
-               ipipe_get_rgb2yuv_params,
-       }, /* VPFE_IPIPE_YUV422_CONV */ {
-               offsetof(struct ipipe_module_params, yuv422_conv),
-               FIELD_SIZEOF(struct ipipe_module_params, yuv422_conv),
-               offsetof(struct vpfe_ipipe_config, yuv422_conv),
-               ipipe_set_yuv422_conv_params,
-               ipipe_get_yuv422_conv_params,
-       }, /* VPFE_IPIPE_YEE */ {
-               offsetof(struct ipipe_module_params, yee),
-               FIELD_SIZEOF(struct ipipe_module_params, yee),
-               offsetof(struct vpfe_ipipe_config, yee),
-               ipipe_set_yee_params,
-               ipipe_get_yee_params,
-       }, /* VPFE_IPIPE_GIC */ {
-               offsetof(struct ipipe_module_params, gic),
-               FIELD_SIZEOF(struct ipipe_module_params, gic),
-               offsetof(struct vpfe_ipipe_config, gic),
-               ipipe_set_gic_params,
-               ipipe_get_gic_params,
-       }, /* VPFE_IPIPE_CFA */ {
-               offsetof(struct ipipe_module_params, cfa),
-               FIELD_SIZEOF(struct ipipe_module_params, cfa),
-               offsetof(struct vpfe_ipipe_config, cfa),
-               ipipe_set_cfa_params,
-               ipipe_get_cfa_params,
-       }, /* VPFE_IPIPE_CAR */ {
-               offsetof(struct ipipe_module_params, car),
-               FIELD_SIZEOF(struct ipipe_module_params, car),
-               offsetof(struct vpfe_ipipe_config, car),
-               ipipe_set_car_params,
-               ipipe_get_car_params,
-       }, /* VPFE_IPIPE_CGS */ {
-               offsetof(struct ipipe_module_params, cgs),
-               FIELD_SIZEOF(struct ipipe_module_params, cgs),
-               offsetof(struct vpfe_ipipe_config, cgs),
-               ipipe_set_cgs_params,
-               ipipe_get_cgs_params,
-       }, /* VPFE_IPIPE_GBCE */ {
-               offsetof(struct ipipe_module_params, gbce),
-               FIELD_SIZEOF(struct ipipe_module_params, gbce),
-               offsetof(struct vpfe_ipipe_config, gbce),
-               ipipe_set_gbce_params,
-               ipipe_get_gbce_params,
-       },
-};
-
-static int ipipe_s_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg)
-{
-       struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
-       unsigned int i;
-       int rval = 0;
-       struct ipipe_module_params *params;
-
-       for (i = 0; i < ARRAY_SIZE(ipipe_modules); i++) {
-               const struct ipipe_module_if *module_if;
-               void *from, *to;
-               size_t size;
-
-               if (!(cfg->flag & BIT(i)))
-                       continue;
-
-               module_if = &ipipe_modules[i];
-               from = *(void **)((void *)cfg + module_if->config_offset);
-
-               params = kmalloc(sizeof(*params), GFP_KERNEL);
-               if (!params)
-                       return -ENOMEM;
-               to = (void *)params + module_if->param_offset;
-               size = module_if->param_size;
-
-               if (to && from && size) {
-                       if (copy_from_user(to, (void __user *)from, size)) {
-                               rval = -EFAULT;
-                               goto error_free;
-                       }
-                       rval = module_if->set(ipipe, to);
-                       if (rval)
-                               goto error_free;
-               } else if (to && !from && size) {
-                       rval = module_if->set(ipipe, NULL);
-                       if (rval)
-                               goto error_free;
-               }
-               kfree(params);
-       }
-       return rval;
-
-error_free:
-       kfree(params);
-       return rval;
-}
-
-static int ipipe_g_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg)
-{
-       struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
-       unsigned int i;
-       int rval = 0;
-
-       for (i = 1; i < ARRAY_SIZE(ipipe_modules); i++) {
-               const struct ipipe_module_if *module_if;
-               struct ipipe_module_params *params;
-               void *from, *to;
-               size_t size;
-
-               if (!(cfg->flag & BIT(i)))
-                       continue;
-
-               module_if = &ipipe_modules[i];
-               to = *(void **)((void *)cfg + module_if->config_offset);
-
-               params = kmalloc(sizeof(*params), GFP_KERNEL);
-               from = (void *)params + module_if->param_offset;
-               size = module_if->param_size;
-
-               if (to && from && size) {
-                       rval = module_if->get(ipipe, from);
-                       if (rval)
-                               goto error;
-                       if (copy_to_user((void __user *)to, from, size)) {
-                               rval = -EFAULT;
-                               break;
-                       }
-               }
-               kfree(params);
-       }
-error:
-       return rval;
-}
-
-/*
- * ipipe_ioctl() - Handle ipipe module private ioctl's
- * @sd: pointer to v4l2 subdev structure
- * @cmd: configuration command
- * @arg: configuration argument
- */
-static long ipipe_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
-{
-       switch (cmd) {
-       case VIDIOC_VPFE_IPIPE_S_CONFIG:
-               return ipipe_s_config(sd, arg);
-
-       case VIDIOC_VPFE_IPIPE_G_CONFIG:
-               return ipipe_g_config(sd, arg);
-
-       default:
-               return -ENOIOCTLCMD;
-       }
-}
-
-void vpfe_ipipe_enable(struct vpfe_device *vpfe_dev, int en)
-{
-       struct vpfe_ipipeif_device *ipipeif = &vpfe_dev->vpfe_ipipeif;
-       struct vpfe_ipipe_device *ipipe = &vpfe_dev->vpfe_ipipe;
-       unsigned char val;
-
-       if (ipipe->input == IPIPE_INPUT_NONE)
-               return;
-
-       /* ipipe is set to single shot */
-       if (ipipeif->input == IPIPEIF_INPUT_MEMORY && en) {
-               /* for single-shot mode, need to wait for h/w to
-                * reset many register bits
-                */
-               do {
-                       val = regr_ip(vpfe_dev->vpfe_ipipe.base_addr,
-                                     IPIPE_SRC_EN);
-               } while (val);
-       }
-       regw_ip(vpfe_dev->vpfe_ipipe.base_addr, en, IPIPE_SRC_EN);
-}
-
-/*
- * ipipe_set_stream() - Enable/Disable streaming on the ipipe subdevice
- * @sd: pointer to v4l2 subdev structure
- * @enable: 1 == Enable, 0 == Disable
- */
-static int ipipe_set_stream(struct v4l2_subdev *sd, int enable)
-{
-       struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
-       struct vpfe_device *vpfe_dev = to_vpfe_device(ipipe);
-
-       if (enable && ipipe->input != IPIPE_INPUT_NONE &&
-           ipipe->output != IPIPE_OUTPUT_NONE) {
-               if (config_ipipe_hw(ipipe) < 0)
-                       return -EINVAL;
-       }
-
-       vpfe_ipipe_enable(vpfe_dev, enable);
-
-       return 0;
-}
-
-/*
- * __ipipe_get_format() - helper function for getting ipipe format
- * @ipipe: pointer to ipipe private structure.
- * @pad: pad number.
- * @cfg: V4L2 subdev pad config
- * @which: wanted subdev format.
- *
- */
-static struct v4l2_mbus_framefmt *
-__ipipe_get_format(struct vpfe_ipipe_device *ipipe,
-                  struct v4l2_subdev_pad_config *cfg, unsigned int pad,
-                  enum v4l2_subdev_format_whence which)
-{
-       if (which == V4L2_SUBDEV_FORMAT_TRY)
-               return v4l2_subdev_get_try_format(&ipipe->subdev, cfg, pad);
-
-       return &ipipe->formats[pad];
-}
-
-/*
- * ipipe_try_format() - Handle try format by pad subdev method
- * @ipipe: VPFE ipipe device.
- * @cfg: V4L2 subdev pad config
- * @pad: pad num.
- * @fmt: pointer to v4l2 format structure.
- * @which : wanted subdev format
- */
-static void
-ipipe_try_format(struct vpfe_ipipe_device *ipipe,
-                struct v4l2_subdev_pad_config *cfg, unsigned int pad,
-                struct v4l2_mbus_framefmt *fmt,
-                enum v4l2_subdev_format_whence which)
-{
-       unsigned int max_out_height;
-       unsigned int max_out_width;
-       unsigned int i;
-
-       max_out_width = IPIPE_MAX_OUTPUT_WIDTH_A;
-       max_out_height = IPIPE_MAX_OUTPUT_HEIGHT_A;
-
-       if (pad == IPIPE_PAD_SINK) {
-               for (i = 0; i < ARRAY_SIZE(ipipe_input_fmts); i++)
-                       if (fmt->code == ipipe_input_fmts[i])
-                               break;
-
-               /* If not found, use SBGGR10 as default */
-               if (i >= ARRAY_SIZE(ipipe_input_fmts))
-                       fmt->code = MEDIA_BUS_FMT_SGRBG12_1X12;
-       } else if (pad == IPIPE_PAD_SOURCE) {
-               for (i = 0; i < ARRAY_SIZE(ipipe_output_fmts); i++)
-                       if (fmt->code == ipipe_output_fmts[i])
-                               break;
-
-               /* If not found, use UYVY as default */
-               if (i >= ARRAY_SIZE(ipipe_output_fmts))
-                       fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
-       }
-
-       fmt->width = clamp_t(u32, fmt->width, MIN_OUT_HEIGHT, max_out_width);
-       fmt->height = clamp_t(u32, fmt->height, MIN_OUT_WIDTH, max_out_height);
-}
-
-/*
- * ipipe_set_format() - Handle set format by pads subdev method
- * @sd: pointer to v4l2 subdev structure
- * @cfg: V4L2 subdev pad config
- * @fmt: pointer to v4l2 subdev format structure
- * return -EINVAL or zero on success
- */
-static int
-ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
-                struct v4l2_subdev_format *fmt)
-{
-       struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
-       struct v4l2_mbus_framefmt *format;
-
-       format = __ipipe_get_format(ipipe, cfg, fmt->pad, fmt->which);
-       if (!format)
-               return -EINVAL;
-
-       ipipe_try_format(ipipe, cfg, fmt->pad, &fmt->format, fmt->which);
-       *format = fmt->format;
-
-       if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
-               return 0;
-
-       if (fmt->pad == IPIPE_PAD_SINK &&
-           (ipipe->input == IPIPE_INPUT_CCDC ||
-           ipipe->input == IPIPE_INPUT_MEMORY))
-               ipipe->formats[fmt->pad] = fmt->format;
-       else if (fmt->pad == IPIPE_PAD_SOURCE &&
-                ipipe->output == IPIPE_OUTPUT_RESIZER)
-               ipipe->formats[fmt->pad] = fmt->format;
-       else
-               return -EINVAL;
-
-       return 0;
-}
-
-/*
- * ipipe_get_format() - Handle get format by pads subdev method.
- * @sd: pointer to v4l2 subdev structure.
- * @cfg: V4L2 subdev pad config
- * @fmt: pointer to v4l2 subdev format structure.
- */
-static int
-ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
-                struct v4l2_subdev_format *fmt)
-{
-       struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
-
-       if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE)
-               fmt->format = ipipe->formats[fmt->pad];
-       else
-               fmt->format = *(v4l2_subdev_get_try_format(sd, cfg, fmt->pad));
-
-       return 0;
-}
-
-/*
- * ipipe_enum_frame_size() - enum frame sizes on pads
- * @sd: pointer to v4l2 subdev structure.
- * @cfg: V4L2 subdev pad config
- * @fse: pointer to v4l2_subdev_frame_size_enum structure.
- */
-static int
-ipipe_enum_frame_size(struct v4l2_subdev *sd,
-                     struct v4l2_subdev_pad_config *cfg,
-                     struct v4l2_subdev_frame_size_enum *fse)
-{
-       struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
-       struct v4l2_mbus_framefmt format;
-
-       if (fse->index != 0)
-               return -EINVAL;
-
-       format.code = fse->code;
-       format.width = 1;
-       format.height = 1;
-       ipipe_try_format(ipipe, cfg, fse->pad, &format, fse->which);
-       fse->min_width = format.width;
-       fse->min_height = format.height;
-
-       if (format.code != fse->code)
-               return -EINVAL;
-
-       format.code = fse->code;
-       format.width = -1;
-       format.height = -1;
-       ipipe_try_format(ipipe, cfg, fse->pad, &format, fse->which);
-       fse->max_width = format.width;
-       fse->max_height = format.height;
-
-       return 0;
-}
-
-/*
- * ipipe_enum_mbus_code() - enum mbus codes for pads
- * @sd: pointer to v4l2 subdev structure.
- * @cfg: V4L2 subdev pad config
- * @code: pointer to v4l2_subdev_mbus_code_enum structure
- */
-static int
-ipipe_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
-                    struct v4l2_subdev_mbus_code_enum *code)
-{
-       switch (code->pad) {
-       case IPIPE_PAD_SINK:
-               if (code->index >= ARRAY_SIZE(ipipe_input_fmts))
-                       return -EINVAL;
-               code->code = ipipe_input_fmts[code->index];
-               break;
-
-       case IPIPE_PAD_SOURCE:
-               if (code->index >= ARRAY_SIZE(ipipe_output_fmts))
-                       return -EINVAL;
-               code->code = ipipe_output_fmts[code->index];
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-/*
- * ipipe_s_ctrl() - Handle set control subdev method
- * @ctrl: pointer to v4l2 control structure
- */
-static int ipipe_s_ctrl(struct v4l2_ctrl *ctrl)
-{
-       struct vpfe_ipipe_device *ipipe =
-            container_of(ctrl->handler, struct vpfe_ipipe_device, ctrls);
-       struct ipipe_lum_adj *lum_adj = &ipipe->config.lum_adj;
-
-       switch (ctrl->id) {
-       case V4L2_CID_BRIGHTNESS:
-               lum_adj->brightness = ctrl->val;
-               ipipe_set_lum_adj_regs(ipipe->base_addr, lum_adj);
-               break;
-
-       case V4L2_CID_CONTRAST:
-               lum_adj->contrast = ctrl->val;
-               ipipe_set_lum_adj_regs(ipipe->base_addr, lum_adj);
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-/*
- * ipipe_init_formats() - Initialize formats on all pads
- * @sd: pointer to v4l2 subdev structure.
- * @fh: V4L2 subdev file handle
- *
- * Initialize all pad formats with default values. Try formats are initialized
- * on the file handle.
- */
-static int
-ipipe_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-{
-       struct v4l2_subdev_format format;
-
-       memset(&format, 0, sizeof(format));
-       format.pad = IPIPE_PAD_SINK;
-       format.which = V4L2_SUBDEV_FORMAT_TRY;
-       format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
-       format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
-       format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
-       ipipe_set_format(sd, fh->pad, &format);
-
-       memset(&format, 0, sizeof(format));
-       format.pad = IPIPE_PAD_SOURCE;
-       format.which = V4L2_SUBDEV_FORMAT_TRY;
-       format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
-       format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
-       format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
-       ipipe_set_format(sd, fh->pad, &format);
-
-       return 0;
-}
-
-/* subdev core operations */
-static const struct v4l2_subdev_core_ops ipipe_v4l2_core_ops = {
-       .ioctl = ipipe_ioctl,
-};
-
-static const struct v4l2_ctrl_ops ipipe_ctrl_ops = {
-       .s_ctrl = ipipe_s_ctrl,
-};
-
-/* subdev file operations */
-static const struct  v4l2_subdev_internal_ops ipipe_v4l2_internal_ops = {
-       .open = ipipe_init_formats,
-};
-
-/* subdev video operations */
-static const struct v4l2_subdev_video_ops ipipe_v4l2_video_ops = {
-       .s_stream = ipipe_set_stream,
-};
-
-/* subdev pad operations */
-static const struct v4l2_subdev_pad_ops ipipe_v4l2_pad_ops = {
-       .enum_mbus_code = ipipe_enum_mbus_code,
-       .enum_frame_size = ipipe_enum_frame_size,
-       .get_fmt = ipipe_get_format,
-       .set_fmt = ipipe_set_format,
-};
-
-/* v4l2 subdev operation */
-static const struct v4l2_subdev_ops ipipe_v4l2_ops = {
-       .core = &ipipe_v4l2_core_ops,
-       .video = &ipipe_v4l2_video_ops,
-       .pad = &ipipe_v4l2_pad_ops,
-};
-
-/*
- * Media entity operations
- */
-
-/*
- * ipipe_link_setup() - Setup ipipe connections
- * @entity: ipipe media entity
- * @local: Pad at the local end of the link
- * @remote: Pad at the remote end of the link
- * @flags: Link flags
- *
- * return -EINVAL or zero on success
- */
-static int
-ipipe_link_setup(struct media_entity *entity, const struct media_pad *local,
-                const struct media_pad *remote, u32 flags)
-{
-       struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
-       struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd);
-       struct vpfe_device *vpfe_dev = to_vpfe_device(ipipe);
-       u16 ipipeif_sink = vpfe_dev->vpfe_ipipeif.input;
-
-       if (!is_media_entity_v4l2_subdev(remote->entity))
-               return -EINVAL;
-
-       switch (local->index) {
-       case IPIPE_PAD_SINK:
-               if (!(flags & MEDIA_LNK_FL_ENABLED)) {
-                       ipipe->input = IPIPE_INPUT_NONE;
-                       break;
-               }
-               if (ipipe->input != IPIPE_INPUT_NONE)
-                       return -EBUSY;
-               if (ipipeif_sink == IPIPEIF_INPUT_MEMORY)
-                       ipipe->input = IPIPE_INPUT_MEMORY;
-               else
-                       ipipe->input = IPIPE_INPUT_CCDC;
-               break;
-
-       case IPIPE_PAD_SOURCE:
-               /* out to RESIZER */
-               if (flags & MEDIA_LNK_FL_ENABLED)
-                       ipipe->output = IPIPE_OUTPUT_RESIZER;
-               else
-                       ipipe->output = IPIPE_OUTPUT_NONE;
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-static const struct media_entity_operations ipipe_media_ops = {
-       .link_setup = ipipe_link_setup,
-};
-
-/*
- * vpfe_ipipe_unregister_entities() - ipipe unregister entity
- * @vpfe_ipipe: pointer to ipipe subdevice structure.
- */
-void vpfe_ipipe_unregister_entities(struct vpfe_ipipe_device *vpfe_ipipe)
-{
-       /* unregister subdev */
-       v4l2_device_unregister_subdev(&vpfe_ipipe->subdev);
-       /* cleanup entity */
-       media_entity_cleanup(&vpfe_ipipe->subdev.entity);
-}
-
-/*
- * vpfe_ipipe_register_entities() - ipipe register entity
- * @ipipe: pointer to ipipe subdevice structure.
- * @vdev: pointer to v4l2 device structure.
- */
-int
-vpfe_ipipe_register_entities(struct vpfe_ipipe_device *ipipe,
-                            struct v4l2_device *vdev)
-{
-       int ret;
-
-       /* Register the subdev */
-       ret = v4l2_device_register_subdev(vdev, &ipipe->subdev);
-       if (ret) {
-               pr_err("Failed to register ipipe as v4l2 subdevice\n");
-               return ret;
-       }
-
-       return ret;
-}
-
-#define IPIPE_CONTRAST_HIGH            0xff
-#define IPIPE_BRIGHT_HIGH              0xff
-
-/*
- * vpfe_ipipe_init() - ipipe module initialization.
- * @ipipe: pointer to ipipe subdevice structure.
- * @pdev: platform device pointer.
- */
-int
-vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev)
-{
-       struct media_pad *pads = &ipipe->pads[0];
-       struct v4l2_subdev *sd = &ipipe->subdev;
-       struct media_entity *me = &sd->entity;
-       struct resource *res, *res2, *memres;
-
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 4);
-       if (!res)
-               return -ENOENT;
-
-       memres = request_mem_region(res->start, resource_size(res), res->name);
-       if (!memres)
-               return -EBUSY;
-       ipipe->base_addr = ioremap_nocache(memres->start,
-                                          resource_size(memres));
-       if (!ipipe->base_addr)
-               goto error_release;
-
-       res2 = platform_get_resource(pdev, IORESOURCE_MEM, 6);
-       if (!res2)
-               goto error_unmap;
-       ipipe->isp5_base_addr = ioremap_nocache(res2->start,
-                                               resource_size(res2));
-       if (!ipipe->isp5_base_addr)
-               goto error_unmap;
-
-       v4l2_subdev_init(sd, &ipipe_v4l2_ops);
-       sd->internal_ops = &ipipe_v4l2_internal_ops;
-       strscpy(sd->name, "DAVINCI IPIPE", sizeof(sd->name));
-       sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
-       v4l2_set_subdevdata(sd, ipipe);
-       sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-
-       pads[IPIPE_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
-       pads[IPIPE_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
-
-       ipipe->input = IPIPE_INPUT_NONE;
-       ipipe->output = IPIPE_OUTPUT_NONE;
-
-       me->ops = &ipipe_media_ops;
-       v4l2_ctrl_handler_init(&ipipe->ctrls, 2);
-       v4l2_ctrl_new_std(&ipipe->ctrls, &ipipe_ctrl_ops,
-                         V4L2_CID_BRIGHTNESS, 0,
-                         IPIPE_BRIGHT_HIGH, 1, 16);
-       v4l2_ctrl_new_std(&ipipe->ctrls, &ipipe_ctrl_ops,
-                         V4L2_CID_CONTRAST, 0,
-                         IPIPE_CONTRAST_HIGH, 1, 16);
-       v4l2_ctrl_handler_setup(&ipipe->ctrls);
-       sd->ctrl_handler = &ipipe->ctrls;
-
-       return media_entity_pads_init(me, IPIPE_PADS_NUM, pads);
-
-error_unmap:
-       iounmap(ipipe->base_addr);
-error_release:
-       release_mem_region(memres->start, resource_size(memres));
-       return -ENOMEM;
-}
-
-/*
- * vpfe_ipipe_cleanup() - ipipe subdevice cleanup.
- * @ipipe: pointer to ipipe subdevice
- * @dev: pointer to platform device
- */
-void vpfe_ipipe_cleanup(struct vpfe_ipipe_device *ipipe,
-                       struct platform_device *pdev)
-{
-       struct resource *res;
-
-       v4l2_ctrl_handler_free(&ipipe->ctrls);
-
-       iounmap(ipipe->base_addr);
-       iounmap(ipipe->isp5_base_addr);
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 4);
-       if (res)
-               release_mem_region(res->start, resource_size(res));
-}
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.h b/drivers/staging/media/davinci_vpfe/dm365_ipipe.h
deleted file mode 100644 (file)
index 866ae12..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#ifndef _DAVINCI_VPFE_DM365_IPIPE_H
-#define _DAVINCI_VPFE_DM365_IPIPE_H
-
-#include <linux/platform_device.h>
-
-#include <media/v4l2-ctrls.h>
-#include <media/v4l2-subdev.h>
-
-#include "davinci_vpfe_user.h"
-#include "vpfe_video.h"
-
-enum ipipe_noise_filter {
-       IPIPE_D2F_1ST = 0,
-       IPIPE_D2F_2ND = 1,
-};
-
-/* Used for driver storage */
-struct ipipe_otfdpc_2_0 {
-       /* 0 - disable, 1 - enable */
-       unsigned char en;
-       /* defect detection method */
-       enum vpfe_ipipe_otfdpc_det_meth det_method;
-       /* Algorithm used. Applicable only when IPIPE_DPC_OTF_MIN_MAX2 is
-        * used
-        */
-       enum vpfe_ipipe_otfdpc_alg alg;
-       struct vpfe_ipipe_otfdpc_2_0_cfg otfdpc_2_0;
-};
-
-struct ipipe_otfdpc_3_0 {
-       /* 0 - disable, 1 - enable */
-       unsigned char en;
-       /* defect detection method */
-       enum vpfe_ipipe_otfdpc_det_meth det_method;
-       /* Algorithm used. Applicable only when IPIPE_DPC_OTF_MIN_MAX2 is
-        * used
-        */
-       enum vpfe_ipipe_otfdpc_alg alg;
-       struct vpfe_ipipe_otfdpc_3_0_cfg otfdpc_3_0;
-};
-
-/* Structure for configuring Luminance Adjustment module */
-struct ipipe_lum_adj {
-       /* Brightness adjustments */
-       unsigned char brightness;
-       /* contrast adjustments */
-       unsigned char contrast;
-};
-
-enum ipipe_rgb2rgb {
-       IPIPE_RGB2RGB_1 = 0,
-       IPIPE_RGB2RGB_2 = 1,
-};
-
-struct ipipe_module_params {
-       __u32 flag;
-       struct vpfe_ipipe_input_config input_config;
-       struct vpfe_ipipe_lutdpc lutdpc;
-       struct vpfe_ipipe_otfdpc otfdpc;
-       struct vpfe_ipipe_nf nf1;
-       struct vpfe_ipipe_nf nf2;
-       struct vpfe_ipipe_gic gic;
-       struct vpfe_ipipe_wb wbal;
-       struct vpfe_ipipe_cfa cfa;
-       struct vpfe_ipipe_rgb2rgb rgb2rgb1;
-       struct vpfe_ipipe_rgb2rgb rgb2rgb2;
-       struct vpfe_ipipe_gamma gamma;
-       struct vpfe_ipipe_3d_lut lut;
-       struct vpfe_ipipe_rgb2yuv rgb2yuv;
-       struct vpfe_ipipe_gbce gbce;
-       struct vpfe_ipipe_yuv422_conv yuv422_conv;
-       struct vpfe_ipipe_yee yee;
-       struct vpfe_ipipe_car car;
-       struct vpfe_ipipe_cgs cgs;
-       struct ipipe_lum_adj lum_adj;
-};
-
-#define IPIPE_PAD_SINK                 0
-#define IPIPE_PAD_SOURCE               1
-
-#define IPIPE_PADS_NUM                 2
-
-#define IPIPE_OUTPUT_NONE              0
-#define IPIPE_OUTPUT_RESIZER           (1 << 0)
-
-enum ipipe_input_entity {
-       IPIPE_INPUT_NONE = 0,
-       IPIPE_INPUT_MEMORY = 1,
-       IPIPE_INPUT_CCDC = 2,
-};
-
-
-struct vpfe_ipipe_device {
-       struct v4l2_subdev subdev;
-       struct media_pad pads[IPIPE_PADS_NUM];
-       struct v4l2_mbus_framefmt formats[IPIPE_PADS_NUM];
-       enum ipipe_input_entity input;
-       unsigned int output;
-       struct v4l2_ctrl_handler ctrls;
-       void __iomem *base_addr;
-       void __iomem *isp5_base_addr;
-       struct ipipe_module_params config;
-};
-
-struct ipipe_module_if {
-       unsigned int param_offset;
-       unsigned int param_size;
-       unsigned int config_offset;
-       int (*set)(struct vpfe_ipipe_device *ipipe, void *param);
-       int (*get)(struct vpfe_ipipe_device *ipipe, void *param);
-};
-
-/* data paths */
-enum ipipe_data_paths {
-       IPIPE_RAW2YUV,
-       /* Bayer RAW input to YCbCr output */
-       IPIPE_RAW2RAW,
-       /* Bayer Raw to Bayer output */
-       IPIPE_RAW2BOX,
-       /* Bayer Raw to Boxcar output */
-       IPIPE_YUV2YUV
-       /* YUV Raw to YUV Raw output */
-};
-
-#define IPIPE_COLPTN_R_Ye      0x0
-#define IPIPE_COLPTN_Gr_Cy     0x1
-#define IPIPE_COLPTN_Gb_G      0x2
-#define IPIPE_COLPTN_B_Mg      0x3
-
-#define COLPAT_EE_SHIFT                0
-#define COLPAT_EO_SHIFT                2
-#define COLPAT_OE_SHIFT                4
-#define COLPAT_OO_SHIFT                6
-
-#define ipipe_sgrbg_pattern \
-       (IPIPE_COLPTN_Gr_Cy <<  COLPAT_EE_SHIFT | \
-       IPIPE_COLPTN_R_Ye  << COLPAT_EO_SHIFT | \
-       IPIPE_COLPTN_B_Mg  << COLPAT_OE_SHIFT | \
-       IPIPE_COLPTN_Gb_G  << COLPAT_OO_SHIFT)
-
-#define ipipe_srggb_pattern \
-       (IPIPE_COLPTN_R_Ye <<  COLPAT_EE_SHIFT | \
-       IPIPE_COLPTN_Gr_Cy  << COLPAT_EO_SHIFT | \
-       IPIPE_COLPTN_Gb_G  << COLPAT_OE_SHIFT | \
-       IPIPE_COLPTN_B_Mg  << COLPAT_OO_SHIFT)
-
-int vpfe_ipipe_register_entities(struct vpfe_ipipe_device *ipipe,
-               struct v4l2_device *v4l2_dev);
-int vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe,
-               struct platform_device *pdev);
-void vpfe_ipipe_unregister_entities(struct vpfe_ipipe_device *ipipe);
-void vpfe_ipipe_cleanup(struct vpfe_ipipe_device *ipipe,
-               struct platform_device *pdev);
-void vpfe_ipipe_enable(struct vpfe_device *vpfe_dev, int en);
-
-#endif         /* _DAVINCI_VPFE_DM365_IPIPE_H */
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c
deleted file mode 100644 (file)
index 110473c..0000000
+++ /dev/null
@@ -1,1038 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#include "dm365_ipipe_hw.h"
-
-#define IPIPE_MODE_CONTINUOUS          0
-#define IPIPE_MODE_SINGLE_SHOT         1
-
-static void ipipe_clock_enable(void __iomem *base_addr)
-{
-       /* enable IPIPE MMR for register write access */
-       regw_ip(base_addr, IPIPE_GCK_MMR_DEFAULT, IPIPE_GCK_MMR);
-
-       /* enable the clock wb,cfa,dfc,d2f,pre modules */
-       regw_ip(base_addr, IPIPE_GCK_PIX_DEFAULT, IPIPE_GCK_PIX);
-}
-
-static void
-rsz_set_common_params(void __iomem *rsz_base, struct resizer_params *params)
-{
-       struct rsz_common_params *rsz_common = &params->rsz_common;
-       u32 val;
-
-       /* Set mode */
-       regw_rsz(rsz_base, params->oper_mode, RSZ_SRC_MODE);
-
-       /* data source selection  and bypass */
-       val = (rsz_common->passthrough << RSZ_BYPASS_SHIFT) |
-             rsz_common->source;
-       regw_rsz(rsz_base, val, RSZ_SRC_FMT0);
-
-       /* src image selection */
-       val = (rsz_common->raw_flip & 1) |
-             (rsz_common->src_img_fmt << RSZ_SRC_IMG_FMT_SHIFT) |
-             ((rsz_common->y_c & 1) << RSZ_SRC_Y_C_SEL_SHIFT);
-       regw_rsz(rsz_base, val, RSZ_SRC_FMT1);
-
-       regw_rsz(rsz_base, rsz_common->vps & IPIPE_RSZ_VPS_MASK, RSZ_SRC_VPS);
-       regw_rsz(rsz_base, rsz_common->hps & IPIPE_RSZ_HPS_MASK, RSZ_SRC_HPS);
-       regw_rsz(rsz_base, rsz_common->vsz & IPIPE_RSZ_VSZ_MASK, RSZ_SRC_VSZ);
-       regw_rsz(rsz_base, rsz_common->hsz & IPIPE_RSZ_HSZ_MASK, RSZ_SRC_HSZ);
-       regw_rsz(rsz_base, rsz_common->yuv_y_min, RSZ_YUV_Y_MIN);
-       regw_rsz(rsz_base, rsz_common->yuv_y_max, RSZ_YUV_Y_MAX);
-       regw_rsz(rsz_base, rsz_common->yuv_c_min, RSZ_YUV_C_MIN);
-       regw_rsz(rsz_base, rsz_common->yuv_c_max, RSZ_YUV_C_MAX);
-       /* chromatic position */
-       regw_rsz(rsz_base, rsz_common->out_chr_pos, RSZ_YUV_PHS);
-}
-
-static void
-rsz_set_rsz_regs(void __iomem *rsz_base, unsigned int rsz_id,
-                struct resizer_params *params)
-{
-       struct resizer_scale_param *rsc_params;
-       struct rsz_ext_mem_param *ext_mem;
-       struct resizer_rgb *rgb;
-       u32 reg_base;
-       u32 val;
-
-       rsc_params = &params->rsz_rsc_param[rsz_id];
-       rgb = &params->rsz2rgb[rsz_id];
-       ext_mem = &params->ext_mem_param[rsz_id];
-
-       if (rsz_id == RSZ_A) {
-               val = rsc_params->h_flip << RSZA_H_FLIP_SHIFT;
-               val |= rsc_params->v_flip << RSZA_V_FLIP_SHIFT;
-               reg_base = RSZ_EN_A;
-       } else {
-               val = rsc_params->h_flip << RSZB_H_FLIP_SHIFT;
-               val |= rsc_params->v_flip << RSZB_V_FLIP_SHIFT;
-               reg_base = RSZ_EN_B;
-       }
-       /* update flip settings */
-       regw_rsz(rsz_base, val, RSZ_SEQ);
-
-       regw_rsz(rsz_base, params->oper_mode, reg_base + RSZ_MODE);
-
-       val = (rsc_params->cen << RSZ_CEN_SHIFT) | rsc_params->yen;
-       regw_rsz(rsz_base, val, reg_base + RSZ_420);
-
-       regw_rsz(rsz_base, rsc_params->i_vps & RSZ_VPS_MASK,
-                reg_base + RSZ_I_VPS);
-       regw_rsz(rsz_base, rsc_params->i_hps & RSZ_HPS_MASK,
-                reg_base + RSZ_I_HPS);
-       regw_rsz(rsz_base, rsc_params->o_vsz & RSZ_O_VSZ_MASK,
-                reg_base + RSZ_O_VSZ);
-       regw_rsz(rsz_base, rsc_params->o_hsz & RSZ_O_HSZ_MASK,
-                reg_base + RSZ_O_HSZ);
-       regw_rsz(rsz_base, rsc_params->v_phs_y & RSZ_V_PHS_MASK,
-                reg_base + RSZ_V_PHS_Y);
-       regw_rsz(rsz_base, rsc_params->v_phs_c & RSZ_V_PHS_MASK,
-                reg_base + RSZ_V_PHS_C);
-
-       /* keep this additional adjustment to zero for now */
-       regw_rsz(rsz_base, rsc_params->v_dif & RSZ_V_DIF_MASK,
-                reg_base + RSZ_V_DIF);
-
-       val = (rsc_params->v_typ_y & 1) |
-             ((rsc_params->v_typ_c & 1) << RSZ_TYP_C_SHIFT);
-       regw_rsz(rsz_base, val, reg_base + RSZ_V_TYP);
-
-       val = (rsc_params->v_lpf_int_y & RSZ_LPF_INT_MASK) |
-             ((rsc_params->v_lpf_int_c & RSZ_LPF_INT_MASK) <<
-             RSZ_LPF_INT_C_SHIFT);
-       regw_rsz(rsz_base, val, reg_base + RSZ_V_LPF);
-
-       regw_rsz(rsz_base, rsc_params->h_phs &
-               RSZ_H_PHS_MASK, reg_base + RSZ_H_PHS);
-
-       regw_rsz(rsz_base, 0, reg_base + RSZ_H_PHS_ADJ);
-       regw_rsz(rsz_base, rsc_params->h_dif &
-               RSZ_H_DIF_MASK, reg_base + RSZ_H_DIF);
-
-       val = (rsc_params->h_typ_y & 1) |
-             ((rsc_params->h_typ_c & 1) << RSZ_TYP_C_SHIFT);
-       regw_rsz(rsz_base, val, reg_base + RSZ_H_TYP);
-
-       val = (rsc_params->h_lpf_int_y & RSZ_LPF_INT_MASK) |
-                ((rsc_params->h_lpf_int_c & RSZ_LPF_INT_MASK) <<
-                RSZ_LPF_INT_C_SHIFT);
-       regw_rsz(rsz_base, val, reg_base + RSZ_H_LPF);
-
-       regw_rsz(rsz_base, rsc_params->dscale_en & 1, reg_base + RSZ_DWN_EN);
-
-       val = (rsc_params->h_dscale_ave_sz & RSZ_DWN_SCALE_AV_SZ_MASK) |
-             ((rsc_params->v_dscale_ave_sz & RSZ_DWN_SCALE_AV_SZ_MASK) <<
-             RSZ_DWN_SCALE_AV_SZ_V_SHIFT);
-       regw_rsz(rsz_base, val, reg_base + RSZ_DWN_AV);
-
-       /* setting rgb conversion parameters */
-       regw_rsz(rsz_base, rgb->rgb_en, reg_base + RSZ_RGB_EN);
-
-       val = (rgb->rgb_typ << RSZ_RGB_TYP_SHIFT) |
-             (rgb->rgb_msk0 << RSZ_RGB_MSK0_SHIFT) |
-             (rgb->rgb_msk1 << RSZ_RGB_MSK1_SHIFT);
-       regw_rsz(rsz_base, val, reg_base + RSZ_RGB_TYP);
-
-       regw_rsz(rsz_base, rgb->rgb_alpha_val & RSZ_RGB_ALPHA_MASK,
-               reg_base + RSZ_RGB_BLD);
-
-       /* setting external memory parameters */
-       regw_rsz(rsz_base, ext_mem->rsz_sdr_oft_y, reg_base + RSZ_SDR_Y_OFT);
-       regw_rsz(rsz_base, ext_mem->rsz_sdr_ptr_s_y,
-                reg_base + RSZ_SDR_Y_PTR_S);
-       regw_rsz(rsz_base, ext_mem->rsz_sdr_ptr_e_y,
-                reg_base + RSZ_SDR_Y_PTR_E);
-       regw_rsz(rsz_base, ext_mem->rsz_sdr_oft_c, reg_base + RSZ_SDR_C_OFT);
-       regw_rsz(rsz_base, ext_mem->rsz_sdr_ptr_s_c,
-                reg_base + RSZ_SDR_C_PTR_S);
-       regw_rsz(rsz_base, (ext_mem->rsz_sdr_ptr_e_c >> 1),
-                reg_base + RSZ_SDR_C_PTR_E);
-}
-
-/*set the registers of either RSZ0 or RSZ1 */
-static void
-ipipe_setup_resizer(void __iomem *rsz_base, struct resizer_params *params)
-{
-       /* enable MMR gate to write to Resizer */
-       regw_rsz(rsz_base, 1, RSZ_GCK_MMR);
-
-       /* Enable resizer if it is not in bypass mode */
-       if (params->rsz_common.passthrough)
-               regw_rsz(rsz_base, 0, RSZ_GCK_SDR);
-       else
-               regw_rsz(rsz_base, 1, RSZ_GCK_SDR);
-
-       rsz_set_common_params(rsz_base, params);
-
-       regw_rsz(rsz_base, params->rsz_en[RSZ_A], RSZ_EN_A);
-
-       if (params->rsz_en[RSZ_A])
-               /*setting rescale parameters */
-               rsz_set_rsz_regs(rsz_base, RSZ_A, params);
-
-       regw_rsz(rsz_base, params->rsz_en[RSZ_B], RSZ_EN_B);
-
-       if (params->rsz_en[RSZ_B])
-               rsz_set_rsz_regs(rsz_base, RSZ_B, params);
-}
-
-static u32 ipipe_get_color_pat(u32 pix)
-{
-       switch (pix) {
-       case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
-       case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
-       case MEDIA_BUS_FMT_SGRBG12_1X12:
-               return ipipe_sgrbg_pattern;
-
-       default:
-               return ipipe_srggb_pattern;
-       }
-}
-
-static int ipipe_get_data_path(struct vpfe_ipipe_device *ipipe)
-{
-       u32 temp_pix_fmt;
-
-       switch (ipipe->formats[IPIPE_PAD_SINK].code) {
-       case MEDIA_BUS_FMT_SBGGR8_1X8:
-       case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
-       case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
-       case MEDIA_BUS_FMT_SGRBG12_1X12:
-               temp_pix_fmt = MEDIA_BUS_FMT_SGRBG12_1X12;
-               break;
-
-       default:
-               temp_pix_fmt = MEDIA_BUS_FMT_UYVY8_2X8;
-       }
-
-       if (temp_pix_fmt == MEDIA_BUS_FMT_SGRBG12_1X12) {
-               if (ipipe->formats[IPIPE_PAD_SOURCE].code ==
-                       MEDIA_BUS_FMT_SGRBG12_1X12)
-                       return IPIPE_RAW2RAW;
-               return IPIPE_RAW2YUV;
-       }
-
-       return IPIPE_YUV2YUV;
-}
-
-static int get_ipipe_mode(struct vpfe_ipipe_device *ipipe)
-{
-       struct vpfe_device *vpfe_dev = to_vpfe_device(ipipe);
-       u16 ipipeif_sink = vpfe_dev->vpfe_ipipeif.input;
-
-       if (ipipeif_sink == IPIPEIF_INPUT_MEMORY)
-               return IPIPE_MODE_SINGLE_SHOT;
-       if (ipipeif_sink == IPIPEIF_INPUT_ISIF)
-               return IPIPE_MODE_CONTINUOUS;
-
-       return -EINVAL;
-}
-
-int config_ipipe_hw(struct vpfe_ipipe_device *ipipe)
-{
-       struct vpfe_ipipe_input_config *config = &ipipe->config.input_config;
-       void __iomem *ipipe_base = ipipe->base_addr;
-       struct v4l2_mbus_framefmt *outformat;
-       u32 color_pat;
-       int ipipe_mode;
-       u32 data_path;
-
-       /* enable clock to IPIPE */
-       vpss_enable_clock(VPSS_IPIPE_CLOCK, 1);
-       ipipe_clock_enable(ipipe_base);
-
-       if (ipipe->input == IPIPE_INPUT_NONE) {
-               regw_ip(ipipe_base, 0, IPIPE_SRC_EN);
-               return 0;
-       }
-
-       ipipe_mode = get_ipipe_mode(ipipe);
-       if (ipipe_mode < 0) {
-               pr_err("Failed to get ipipe mode");
-               return -EINVAL;
-       }
-       regw_ip(ipipe_base, ipipe_mode, IPIPE_SRC_MODE);
-
-       data_path = ipipe_get_data_path(ipipe);
-       regw_ip(ipipe_base, data_path, IPIPE_SRC_FMT);
-
-       regw_ip(ipipe_base, config->vst & IPIPE_RSZ_VPS_MASK, IPIPE_SRC_VPS);
-       regw_ip(ipipe_base, config->hst & IPIPE_RSZ_HPS_MASK, IPIPE_SRC_HPS);
-
-       outformat = &ipipe->formats[IPIPE_PAD_SOURCE];
-       regw_ip(ipipe_base, (outformat->height + 1) & IPIPE_RSZ_VSZ_MASK,
-               IPIPE_SRC_VSZ);
-       regw_ip(ipipe_base, (outformat->width + 1) & IPIPE_RSZ_HSZ_MASK,
-               IPIPE_SRC_HSZ);
-
-       if (data_path == IPIPE_RAW2YUV ||
-           data_path == IPIPE_RAW2RAW) {
-               color_pat =
-               ipipe_get_color_pat(ipipe->formats[IPIPE_PAD_SINK].code);
-               regw_ip(ipipe_base, color_pat, IPIPE_SRC_COL);
-       }
-
-       return 0;
-}
-
-/*
- * config_rsz_hw() - Performs hardware setup of resizer.
- */
-int config_rsz_hw(struct vpfe_resizer_device *resizer,
-                 struct resizer_params *config)
-{
-       struct vpfe_device *vpfe_dev = to_vpfe_device(resizer);
-       void __iomem *ipipe_base = vpfe_dev->vpfe_ipipe.base_addr;
-       void __iomem *rsz_base = vpfe_dev->vpfe_resizer.base_addr;
-
-       /* enable VPSS clock */
-       vpss_enable_clock(VPSS_IPIPE_CLOCK, 1);
-       ipipe_clock_enable(ipipe_base);
-
-       ipipe_setup_resizer(rsz_base, config);
-
-       return 0;
-}
-
-static void
-rsz_set_y_address(void __iomem *rsz_base, unsigned int address,
-                 unsigned int offset)
-{
-       u32 val;
-
-       val = address & SET_LOW_ADDR;
-       regw_rsz(rsz_base, val, offset + RSZ_SDR_Y_BAD_L);
-       regw_rsz(rsz_base, val, offset + RSZ_SDR_Y_SAD_L);
-
-       val = (address & SET_HIGH_ADDR) >> 16;
-       regw_rsz(rsz_base, val, offset + RSZ_SDR_Y_BAD_H);
-       regw_rsz(rsz_base, val, offset + RSZ_SDR_Y_SAD_H);
-}
-
-static void
-rsz_set_c_address(void __iomem *rsz_base, unsigned int address,
-                 unsigned int offset)
-{
-       u32 val;
-
-       val = address & SET_LOW_ADDR;
-       regw_rsz(rsz_base, val, offset + RSZ_SDR_C_BAD_L);
-       regw_rsz(rsz_base, val, offset + RSZ_SDR_C_SAD_L);
-
-       val = (address & SET_HIGH_ADDR) >> 16;
-       regw_rsz(rsz_base, val, offset + RSZ_SDR_C_BAD_H);
-       regw_rsz(rsz_base, val, offset + RSZ_SDR_C_SAD_H);
-}
-
-/*
- * resizer_set_outaddr() - set the address for given resize_no
- * @rsz_base: resizer base address
- * @params: pointer to ipipe_params structure
- * @resize_no: 0 - Resizer-A, 1 - Resizer B
- * @address: the address to set
- */
-int
-resizer_set_outaddr(void __iomem *rsz_base, struct resizer_params *params,
-                   int resize_no, unsigned int address)
-{
-       struct resizer_scale_param *rsc_param;
-       struct rsz_ext_mem_param *mem_param;
-       struct rsz_common_params *rsz_common;
-       unsigned int rsz_start_add;
-       unsigned int val;
-
-       if (resize_no != RSZ_A && resize_no != RSZ_B)
-               return -EINVAL;
-
-       mem_param = &params->ext_mem_param[resize_no];
-       rsc_param = &params->rsz_rsc_param[resize_no];
-       rsz_common = &params->rsz_common;
-
-       if (resize_no == RSZ_A)
-               rsz_start_add = RSZ_EN_A;
-       else
-               rsz_start_add = RSZ_EN_B;
-
-       /* y_c = 0 for y, = 1 for c */
-       if (rsz_common->src_img_fmt == RSZ_IMG_420) {
-               if (rsz_common->y_c) {
-                       /* C channel */
-                       val = address + mem_param->flip_ofst_c;
-                       rsz_set_c_address(rsz_base, val, rsz_start_add);
-               } else {
-                       val = address + mem_param->flip_ofst_y;
-                       rsz_set_y_address(rsz_base, val, rsz_start_add);
-               }
-       } else {
-               if (rsc_param->cen && rsc_param->yen) {
-                       /* 420 */
-                       val = address + mem_param->c_offset +
-                             mem_param->flip_ofst_c +
-                             mem_param->user_y_ofst +
-                             mem_param->user_c_ofst;
-                       if (resize_no == RSZ_B)
-                               val +=
-                               params->ext_mem_param[RSZ_A].user_y_ofst +
-                               params->ext_mem_param[RSZ_A].user_c_ofst;
-                       /* set C address */
-                       rsz_set_c_address(rsz_base, val, rsz_start_add);
-               }
-               val = address + mem_param->flip_ofst_y + mem_param->user_y_ofst;
-               if (resize_no == RSZ_B)
-                       val += params->ext_mem_param[RSZ_A].user_y_ofst +
-                               params->ext_mem_param[RSZ_A].user_c_ofst;
-               /* set Y address */
-               rsz_set_y_address(rsz_base, val, rsz_start_add);
-       }
-       /* resizer must be enabled */
-       regw_rsz(rsz_base, params->rsz_en[resize_no], rsz_start_add);
-
-       return 0;
-}
-
-void
-ipipe_set_lutdpc_regs(void __iomem *base_addr, void __iomem *isp5_base_addr,
-                     struct vpfe_ipipe_lutdpc *dpc)
-{
-       u32 max_tbl_size = LUT_DPC_MAX_SIZE >> 1;
-       u32 lut_start_addr = DPC_TB0_START_ADDR;
-       u32 val;
-       u32 count;
-
-       ipipe_clock_enable(base_addr);
-       regw_ip(base_addr, dpc->en, DPC_LUT_EN);
-
-       if (dpc->en != 1)
-               return;
-
-       val = LUTDPC_TBL_256_EN | (dpc->repl_white & 1);
-       regw_ip(base_addr, val, DPC_LUT_SEL);
-       regw_ip(base_addr, LUT_DPC_START_ADDR, DPC_LUT_ADR);
-       regw_ip(base_addr, dpc->dpc_size, DPC_LUT_SIZ & LUT_DPC_SIZE_MASK);
-
-       for (count = 0; count < dpc->dpc_size; count++) {
-               if (count >= max_tbl_size)
-                       lut_start_addr = DPC_TB1_START_ADDR;
-               val = (dpc->table[count].horz_pos & LUT_DPC_H_POS_MASK) |
-                     ((dpc->table[count].vert_pos & LUT_DPC_V_POS_MASK) <<
-                       LUT_DPC_V_POS_SHIFT) | (dpc->table[count].method <<
-                       LUT_DPC_CORR_METH_SHIFT);
-               w_ip_table(isp5_base_addr, val, (lut_start_addr +
-               ((count % max_tbl_size) << 2)));
-       }
-}
-
-static void
-set_dpc_thresholds(void __iomem *base_addr,
-                  struct vpfe_ipipe_otfdpc_2_0_cfg *dpc_thr)
-{
-       regw_ip(base_addr, dpc_thr->corr_thr.r & OTFDPC_DPC2_THR_MASK,
-               DPC_OTF_2C_THR_R);
-       regw_ip(base_addr, dpc_thr->corr_thr.gr & OTFDPC_DPC2_THR_MASK,
-               DPC_OTF_2C_THR_GR);
-       regw_ip(base_addr, dpc_thr->corr_thr.gb & OTFDPC_DPC2_THR_MASK,
-               DPC_OTF_2C_THR_GB);
-       regw_ip(base_addr, dpc_thr->corr_thr.b & OTFDPC_DPC2_THR_MASK,
-               DPC_OTF_2C_THR_B);
-       regw_ip(base_addr, dpc_thr->det_thr.r & OTFDPC_DPC2_THR_MASK,
-               DPC_OTF_2D_THR_R);
-       regw_ip(base_addr, dpc_thr->det_thr.gr & OTFDPC_DPC2_THR_MASK,
-               DPC_OTF_2D_THR_GR);
-       regw_ip(base_addr, dpc_thr->det_thr.gb & OTFDPC_DPC2_THR_MASK,
-               DPC_OTF_2D_THR_GB);
-       regw_ip(base_addr, dpc_thr->det_thr.b & OTFDPC_DPC2_THR_MASK,
-               DPC_OTF_2D_THR_B);
-}
-
-void ipipe_set_otfdpc_regs(void __iomem *base_addr,
-                          struct vpfe_ipipe_otfdpc *otfdpc)
-{
-       struct vpfe_ipipe_otfdpc_2_0_cfg *dpc_2_0 = &otfdpc->alg_cfg.dpc_2_0;
-       struct vpfe_ipipe_otfdpc_3_0_cfg *dpc_3_0 = &otfdpc->alg_cfg.dpc_3_0;
-       u32 val;
-
-       ipipe_clock_enable(base_addr);
-
-       regw_ip(base_addr, (otfdpc->en & 1), DPC_OTF_EN);
-       if (!otfdpc->en)
-               return;
-
-       /* dpc enabled */
-       val = (otfdpc->det_method << OTF_DET_METHOD_SHIFT) | otfdpc->alg;
-       regw_ip(base_addr, val, DPC_OTF_TYP);
-
-       if (otfdpc->det_method == VPFE_IPIPE_DPC_OTF_MIN_MAX) {
-               /* ALG= 0, TYP = 0, DPC_OTF_2D_THR_[x]=0
-                * DPC_OTF_2C_THR_[x] = Maximum thresohld
-                * MinMax method
-                */
-               dpc_2_0->det_thr.r = dpc_2_0->det_thr.gb =
-               dpc_2_0->det_thr.gr = dpc_2_0->det_thr.b = 0;
-               set_dpc_thresholds(base_addr, dpc_2_0);
-               return;
-       }
-       /* MinMax2 */
-       if (otfdpc->alg == VPFE_IPIPE_OTFDPC_2_0) {
-               set_dpc_thresholds(base_addr, dpc_2_0);
-               return;
-       }
-       regw_ip(base_addr, dpc_3_0->act_adj_shf &
-               OTF_DPC3_0_SHF_MASK, DPC_OTF_3_SHF);
-       /* Detection thresholds */
-       regw_ip(base_addr, ((dpc_3_0->det_thr & OTF_DPC3_0_THR_MASK) <<
-               OTF_DPC3_0_THR_SHIFT), DPC_OTF_3D_THR);
-       regw_ip(base_addr, dpc_3_0->det_slp &
-               OTF_DPC3_0_SLP_MASK, DPC_OTF_3D_SLP);
-       regw_ip(base_addr, dpc_3_0->det_thr_min &
-               OTF_DPC3_0_DET_MASK, DPC_OTF_3D_MIN);
-       regw_ip(base_addr, dpc_3_0->det_thr_max &
-               OTF_DPC3_0_DET_MASK, DPC_OTF_3D_MAX);
-       /* Correction thresholds */
-       regw_ip(base_addr, ((dpc_3_0->corr_thr & OTF_DPC3_0_THR_MASK) <<
-               OTF_DPC3_0_THR_SHIFT), DPC_OTF_3C_THR);
-       regw_ip(base_addr, dpc_3_0->corr_slp &
-               OTF_DPC3_0_SLP_MASK, DPC_OTF_3C_SLP);
-       regw_ip(base_addr, dpc_3_0->corr_thr_min &
-               OTF_DPC3_0_CORR_MASK, DPC_OTF_3C_MIN);
-       regw_ip(base_addr, dpc_3_0->corr_thr_max &
-               OTF_DPC3_0_CORR_MASK, DPC_OTF_3C_MAX);
-}
-
-/* 2D Noise filter */
-void
-ipipe_set_d2f_regs(void __iomem *base_addr, unsigned int id,
-                  struct vpfe_ipipe_nf *noise_filter)
-{
-
-       u32 offset = D2F_1ST;
-       int count;
-       u32 val;
-
-       if (id == IPIPE_D2F_2ND)
-               offset = D2F_2ND;
-
-       ipipe_clock_enable(base_addr);
-       regw_ip(base_addr, noise_filter->en & 1, offset + D2F_EN);
-       if (!noise_filter->en)
-               return;
-
-       /*noise filter enabled */
-       /* Combine all the fields to make D2F_CFG register of IPIPE */
-       val = ((noise_filter->spread_val & D2F_SPR_VAL_MASK) <<
-               D2F_SPR_VAL_SHIFT) | ((noise_filter->shft_val &
-               D2F_SHFT_VAL_MASK) << D2F_SHFT_VAL_SHIFT) |
-               (noise_filter->gr_sample_meth << D2F_SAMPLE_METH_SHIFT) |
-               ((noise_filter->apply_lsc_gain & 1) <<
-               D2F_APPLY_LSC_GAIN_SHIFT) | D2F_USE_SPR_REG_VAL;
-       regw_ip(base_addr, val, offset + D2F_TYP);
-
-       /* edge detection minimum */
-       regw_ip(base_addr, noise_filter->edge_det_min_thr &
-               D2F_EDGE_DET_THR_MASK, offset + D2F_EDG_MIN);
-
-       /* edge detection maximum */
-       regw_ip(base_addr, noise_filter->edge_det_max_thr &
-               D2F_EDGE_DET_THR_MASK, offset + D2F_EDG_MAX);
-
-       for (count = 0; count < VPFE_IPIPE_NF_STR_TABLE_SIZE; count++)
-               regw_ip(base_addr,
-                       (noise_filter->str[count] & D2F_STR_VAL_MASK),
-                       offset + D2F_STR + count * 4);
-
-       for (count = 0; count < VPFE_IPIPE_NF_THR_TABLE_SIZE; count++)
-               regw_ip(base_addr, noise_filter->thr[count] & D2F_THR_VAL_MASK,
-                       offset + D2F_THR + count * 4);
-}
-
-#define IPIPE_U8Q5(decimal, integer) \
-       (((decimal & 0x1f) | ((integer & 0x7) << 5)))
-
-/* Green Imbalance Correction */
-void ipipe_set_gic_regs(void __iomem *base_addr, struct vpfe_ipipe_gic *gic)
-{
-       u32 val;
-
-       ipipe_clock_enable(base_addr);
-       regw_ip(base_addr, gic->en & 1, GIC_EN);
-
-       if (!gic->en)
-               return;
-
-       /*gic enabled */
-       val = (gic->wt_fn_type << GIC_TYP_SHIFT) |
-             (gic->thr_sel << GIC_THR_SEL_SHIFT) |
-             ((gic->apply_lsc_gain & 1) << GIC_APPLY_LSC_GAIN_SHIFT);
-       regw_ip(base_addr, val, GIC_TYP);
-
-       regw_ip(base_addr, gic->gain & GIC_GAIN_MASK, GIC_GAN);
-
-       if (gic->gic_alg != VPFE_IPIPE_GIC_ALG_ADAPT_GAIN) {
-               /* Constant Gain. Set threshold to maximum */
-               regw_ip(base_addr, GIC_THR_MASK, GIC_THR);
-               return;
-       }
-
-       if (gic->thr_sel == VPFE_IPIPE_GIC_THR_REG) {
-               regw_ip(base_addr, gic->thr & GIC_THR_MASK, GIC_THR);
-               regw_ip(base_addr, gic->slope & GIC_SLOPE_MASK, GIC_SLP);
-       } else {
-               /* Use NF thresholds */
-               val = IPIPE_U8Q5(gic->nf2_thr_gain.decimal,
-                               gic->nf2_thr_gain.integer);
-               regw_ip(base_addr, val, GIC_NFGAN);
-       }
-}
-
-#define IPIPE_U13Q9(decimal, integer) \
-       (((decimal & 0x1ff) | ((integer & 0xf) << 9)))
-/* White balance */
-void ipipe_set_wb_regs(void __iomem *base_addr, struct vpfe_ipipe_wb *wb)
-{
-       u32 val;
-
-       ipipe_clock_enable(base_addr);
-       /* Ofsets. S12 */
-       regw_ip(base_addr, wb->ofst_r & WB_OFFSET_MASK, WB2_OFT_R);
-       regw_ip(base_addr, wb->ofst_gr & WB_OFFSET_MASK, WB2_OFT_GR);
-       regw_ip(base_addr, wb->ofst_gb & WB_OFFSET_MASK, WB2_OFT_GB);
-       regw_ip(base_addr, wb->ofst_b & WB_OFFSET_MASK, WB2_OFT_B);
-
-       /* Gains. U13Q9 */
-       val = IPIPE_U13Q9(wb->gain_r.decimal, wb->gain_r.integer);
-       regw_ip(base_addr, val, WB2_WGN_R);
-
-       val = IPIPE_U13Q9(wb->gain_gr.decimal, wb->gain_gr.integer);
-       regw_ip(base_addr, val, WB2_WGN_GR);
-
-       val = IPIPE_U13Q9(wb->gain_gb.decimal, wb->gain_gb.integer);
-       regw_ip(base_addr, val, WB2_WGN_GB);
-
-       val = IPIPE_U13Q9(wb->gain_b.decimal, wb->gain_b.integer);
-       regw_ip(base_addr, val, WB2_WGN_B);
-}
-
-/* CFA */
-void ipipe_set_cfa_regs(void __iomem *base_addr, struct vpfe_ipipe_cfa *cfa)
-{
-       ipipe_clock_enable(base_addr);
-
-       regw_ip(base_addr, cfa->alg, CFA_MODE);
-       regw_ip(base_addr, cfa->hpf_thr_2dir & CFA_HPF_THR_2DIR_MASK,
-               CFA_2DIR_HPF_THR);
-       regw_ip(base_addr, cfa->hpf_slp_2dir & CFA_HPF_SLOPE_2DIR_MASK,
-               CFA_2DIR_HPF_SLP);
-       regw_ip(base_addr, cfa->hp_mix_thr_2dir & CFA_HPF_MIX_THR_2DIR_MASK,
-               CFA_2DIR_MIX_THR);
-       regw_ip(base_addr, cfa->hp_mix_slope_2dir & CFA_HPF_MIX_SLP_2DIR_MASK,
-               CFA_2DIR_MIX_SLP);
-       regw_ip(base_addr, cfa->dir_thr_2dir & CFA_DIR_THR_2DIR_MASK,
-               CFA_2DIR_DIR_THR);
-       regw_ip(base_addr, cfa->dir_slope_2dir & CFA_DIR_SLP_2DIR_MASK,
-               CFA_2DIR_DIR_SLP);
-       regw_ip(base_addr, cfa->nd_wt_2dir & CFA_ND_WT_2DIR_MASK,
-               CFA_2DIR_NDWT);
-       regw_ip(base_addr, cfa->hue_fract_daa & CFA_DAA_HUE_FRA_MASK,
-               CFA_MONO_HUE_FRA);
-       regw_ip(base_addr, cfa->edge_thr_daa & CFA_DAA_EDG_THR_MASK,
-               CFA_MONO_EDG_THR);
-       regw_ip(base_addr, cfa->thr_min_daa & CFA_DAA_THR_MIN_MASK,
-               CFA_MONO_THR_MIN);
-       regw_ip(base_addr, cfa->thr_slope_daa & CFA_DAA_THR_SLP_MASK,
-               CFA_MONO_THR_SLP);
-       regw_ip(base_addr, cfa->slope_min_daa & CFA_DAA_SLP_MIN_MASK,
-               CFA_MONO_SLP_MIN);
-       regw_ip(base_addr, cfa->slope_slope_daa & CFA_DAA_SLP_SLP_MASK,
-               CFA_MONO_SLP_SLP);
-       regw_ip(base_addr, cfa->lp_wt_daa & CFA_DAA_LP_WT_MASK,
-               CFA_MONO_LPWT);
-}
-
-void
-ipipe_set_rgb2rgb_regs(void __iomem *base_addr, unsigned int id,
-                      struct vpfe_ipipe_rgb2rgb *rgb)
-{
-       u32 offset_mask = RGB2RGB_1_OFST_MASK;
-       u32 offset = RGB1_MUL_BASE;
-       u32 integ_mask = 0xf;
-       u32 val;
-
-       ipipe_clock_enable(base_addr);
-
-       if (id == IPIPE_RGB2RGB_2) {
-               /*
-                * For second RGB module, gain integer is 3 bits instead
-                * of 4, offset has 11 bits insread of 13
-                */
-               offset = RGB2_MUL_BASE;
-               integ_mask = 0x7;
-               offset_mask = RGB2RGB_2_OFST_MASK;
-       }
-       /* Gains */
-       val = (rgb->coef_rr.decimal & 0xff) |
-               ((rgb->coef_rr.integer & integ_mask) << 8);
-       regw_ip(base_addr, val, offset + RGB_MUL_RR);
-       val = (rgb->coef_gr.decimal & 0xff) |
-               ((rgb->coef_gr.integer & integ_mask) << 8);
-       regw_ip(base_addr, val, offset + RGB_MUL_GR);
-       val = (rgb->coef_br.decimal & 0xff) |
-               ((rgb->coef_br.integer & integ_mask) << 8);
-       regw_ip(base_addr, val, offset + RGB_MUL_BR);
-       val = (rgb->coef_rg.decimal & 0xff) |
-               ((rgb->coef_rg.integer & integ_mask) << 8);
-       regw_ip(base_addr, val, offset + RGB_MUL_RG);
-       val = (rgb->coef_gg.decimal & 0xff) |
-               ((rgb->coef_gg.integer & integ_mask) << 8);
-       regw_ip(base_addr, val, offset + RGB_MUL_GG);
-       val = (rgb->coef_bg.decimal & 0xff) |
-               ((rgb->coef_bg.integer & integ_mask) << 8);
-       regw_ip(base_addr, val, offset + RGB_MUL_BG);
-       val = (rgb->coef_rb.decimal & 0xff) |
-               ((rgb->coef_rb.integer & integ_mask) << 8);
-       regw_ip(base_addr, val, offset + RGB_MUL_RB);
-       val = (rgb->coef_gb.decimal & 0xff) |
-               ((rgb->coef_gb.integer & integ_mask) << 8);
-       regw_ip(base_addr, val, offset + RGB_MUL_GB);
-       val = (rgb->coef_bb.decimal & 0xff) |
-               ((rgb->coef_bb.integer & integ_mask) << 8);
-       regw_ip(base_addr, val, offset + RGB_MUL_BB);
-
-       /* Offsets */
-       regw_ip(base_addr, rgb->out_ofst_r & offset_mask, offset + RGB_OFT_OR);
-       regw_ip(base_addr, rgb->out_ofst_g & offset_mask, offset + RGB_OFT_OG);
-       regw_ip(base_addr, rgb->out_ofst_b & offset_mask, offset + RGB_OFT_OB);
-}
-
-static void
-ipipe_update_gamma_tbl(void __iomem *isp5_base_addr,
-       struct vpfe_ipipe_gamma_entry *table, int size, u32 addr)
-{
-       int count;
-       u32 val;
-
-       for (count = 0; count < size; count++) {
-               val = table[count].slope & GAMMA_MASK;
-               val |= (table[count].offset & GAMMA_MASK) << GAMMA_SHIFT;
-               w_ip_table(isp5_base_addr, val, (addr + (count * 4)));
-       }
-}
-
-void
-ipipe_set_gamma_regs(void __iomem *base_addr, void __iomem *isp5_base_addr,
-                         struct vpfe_ipipe_gamma *gamma)
-{
-       int table_size;
-       u32 val;
-
-       ipipe_clock_enable(base_addr);
-       val = (gamma->bypass_r << GAMMA_BYPR_SHIFT) |
-               (gamma->bypass_b << GAMMA_BYPG_SHIFT) |
-               (gamma->bypass_g << GAMMA_BYPB_SHIFT) |
-               (gamma->tbl_sel << GAMMA_TBL_SEL_SHIFT) |
-               (gamma->tbl_size << GAMMA_TBL_SIZE_SHIFT);
-
-       regw_ip(base_addr, val, GMM_CFG);
-
-       if (gamma->tbl_sel != VPFE_IPIPE_GAMMA_TBL_RAM)
-               return;
-
-       table_size = gamma->tbl_size;
-
-       if (!gamma->bypass_r)
-               ipipe_update_gamma_tbl(isp5_base_addr, gamma->table_r,
-                       table_size, GAMMA_R_START_ADDR);
-       if (!gamma->bypass_b)
-               ipipe_update_gamma_tbl(isp5_base_addr, gamma->table_b,
-                       table_size, GAMMA_B_START_ADDR);
-       if (!gamma->bypass_g)
-               ipipe_update_gamma_tbl(isp5_base_addr, gamma->table_g,
-                       table_size, GAMMA_G_START_ADDR);
-}
-
-void
-ipipe_set_3d_lut_regs(void __iomem *base_addr, void __iomem *isp5_base_addr,
-                          struct vpfe_ipipe_3d_lut *lut_3d)
-{
-       struct vpfe_ipipe_3d_lut_entry *tbl;
-       u32 bnk_index;
-       u32 tbl_index;
-       u32 val;
-       u32 i;
-
-       ipipe_clock_enable(base_addr);
-       regw_ip(base_addr, lut_3d->en, D3LUT_EN);
-
-       if (!lut_3d->en)
-               return;
-
-       /* valid table */
-       tbl = lut_3d->table;
-       for (i = 0; i < VPFE_IPIPE_MAX_SIZE_3D_LUT; i++) {
-               /*
-                * Each entry has 0-9 (B), 10-19 (G) and
-                * 20-29 R values
-                */
-               val = tbl[i].b & D3_LUT_ENTRY_MASK;
-               val |= (tbl[i].g & D3_LUT_ENTRY_MASK) <<
-                        D3_LUT_ENTRY_G_SHIFT;
-               val |= (tbl[i].r & D3_LUT_ENTRY_MASK) <<
-                        D3_LUT_ENTRY_R_SHIFT;
-               bnk_index = i % 4;
-               tbl_index = i >> 2;
-               tbl_index <<= 2;
-               if (bnk_index == 0)
-                       w_ip_table(isp5_base_addr, val,
-                                  tbl_index + D3L_TB0_START_ADDR);
-               else if (bnk_index == 1)
-                       w_ip_table(isp5_base_addr, val,
-                                  tbl_index + D3L_TB1_START_ADDR);
-               else if (bnk_index == 2)
-                       w_ip_table(isp5_base_addr, val,
-                                  tbl_index + D3L_TB2_START_ADDR);
-               else
-                       w_ip_table(isp5_base_addr, val,
-                                  tbl_index + D3L_TB3_START_ADDR);
-       }
-}
-
-/* Lumina adjustments */
-void
-ipipe_set_lum_adj_regs(void __iomem *base_addr, struct ipipe_lum_adj *lum_adj)
-{
-       u32 val;
-
-       ipipe_clock_enable(base_addr);
-
-       /* combine fields of YUV_ADJ to set brightness and contrast */
-       val = lum_adj->contrast << LUM_ADJ_CONTR_SHIFT |
-             lum_adj->brightness << LUM_ADJ_BRIGHT_SHIFT;
-       regw_ip(base_addr, val, YUV_ADJ);
-}
-
-inline u32 ipipe_s12q8(unsigned short decimal, short integer)
-{
-       return (decimal & 0xff) | ((integer & 0xf) << 8);
-}
-
-void ipipe_set_rgb2ycbcr_regs(void __iomem *base_addr,
-                             struct vpfe_ipipe_rgb2yuv *yuv)
-{
-       u32 val;
-
-       /* S10Q8 */
-       ipipe_clock_enable(base_addr);
-       val = ipipe_s12q8(yuv->coef_ry.decimal, yuv->coef_ry.integer);
-       regw_ip(base_addr, val, YUV_MUL_RY);
-       val = ipipe_s12q8(yuv->coef_gy.decimal, yuv->coef_gy.integer);
-       regw_ip(base_addr, val, YUV_MUL_GY);
-       val = ipipe_s12q8(yuv->coef_by.decimal, yuv->coef_by.integer);
-       regw_ip(base_addr, val, YUV_MUL_BY);
-       val = ipipe_s12q8(yuv->coef_rcb.decimal, yuv->coef_rcb.integer);
-       regw_ip(base_addr, val, YUV_MUL_RCB);
-       val = ipipe_s12q8(yuv->coef_gcb.decimal, yuv->coef_gcb.integer);
-       regw_ip(base_addr, val, YUV_MUL_GCB);
-       val = ipipe_s12q8(yuv->coef_bcb.decimal, yuv->coef_bcb.integer);
-       regw_ip(base_addr, val, YUV_MUL_BCB);
-       val = ipipe_s12q8(yuv->coef_rcr.decimal, yuv->coef_rcr.integer);
-       regw_ip(base_addr, val, YUV_MUL_RCR);
-       val = ipipe_s12q8(yuv->coef_gcr.decimal, yuv->coef_gcr.integer);
-       regw_ip(base_addr, val, YUV_MUL_GCR);
-       val = ipipe_s12q8(yuv->coef_bcr.decimal, yuv->coef_bcr.integer);
-       regw_ip(base_addr, val, YUV_MUL_BCR);
-       regw_ip(base_addr, yuv->out_ofst_y & RGB2YCBCR_OFST_MASK, YUV_OFT_Y);
-       regw_ip(base_addr, yuv->out_ofst_cb & RGB2YCBCR_OFST_MASK, YUV_OFT_CB);
-       regw_ip(base_addr, yuv->out_ofst_cr & RGB2YCBCR_OFST_MASK, YUV_OFT_CR);
-}
-
-/* YUV 422 conversion */
-void
-ipipe_set_yuv422_conv_regs(void __iomem *base_addr,
-                          struct vpfe_ipipe_yuv422_conv *conv)
-{
-       u32 val;
-
-       ipipe_clock_enable(base_addr);
-
-       /* Combine all the fields to make YUV_PHS register of IPIPE */
-       val = (conv->chrom_pos << 0) | (conv->en_chrom_lpf << 1);
-       regw_ip(base_addr, val, YUV_PHS);
-}
-
-void
-ipipe_set_gbce_regs(void __iomem *base_addr, void __iomem *isp5_base_addr,
-                   struct vpfe_ipipe_gbce *gbce)
-{
-       unsigned int count;
-       u32 mask = GBCE_Y_VAL_MASK;
-
-       if (gbce->type == VPFE_IPIPE_GBCE_GAIN_TBL)
-               mask = GBCE_GAIN_VAL_MASK;
-
-       ipipe_clock_enable(base_addr);
-       regw_ip(base_addr, gbce->en & 1, GBCE_EN);
-
-       if (!gbce->en)
-               return;
-
-       regw_ip(base_addr, gbce->type, GBCE_TYP);
-
-       for (count = 0; count < VPFE_IPIPE_MAX_SIZE_GBCE_LUT; count += 2)
-               w_ip_table(isp5_base_addr, ((gbce->table[count + 1] & mask) <<
-               GBCE_ENTRY_SHIFT) | (gbce->table[count] & mask),
-               ((count/2) << 2) + GBCE_TB_START_ADDR);
-}
-
-void
-ipipe_set_ee_regs(void __iomem *base_addr, void __iomem *isp5_base_addr,
-                 struct vpfe_ipipe_yee *ee)
-{
-       unsigned int count;
-       u32 val;
-
-       ipipe_clock_enable(base_addr);
-       regw_ip(base_addr, ee->en, YEE_EN);
-
-       if (!ee->en)
-               return;
-
-       val = ee->en_halo_red & 1;
-       val |= ee->merge_meth << YEE_HALO_RED_EN_SHIFT;
-       regw_ip(base_addr, val, YEE_TYP);
-
-       regw_ip(base_addr, ee->hpf_shft, YEE_SHF);
-       regw_ip(base_addr, ee->hpf_coef_00 & YEE_COEF_MASK, YEE_MUL_00);
-       regw_ip(base_addr, ee->hpf_coef_01 & YEE_COEF_MASK, YEE_MUL_01);
-       regw_ip(base_addr, ee->hpf_coef_02 & YEE_COEF_MASK, YEE_MUL_02);
-       regw_ip(base_addr, ee->hpf_coef_10 & YEE_COEF_MASK, YEE_MUL_10);
-       regw_ip(base_addr, ee->hpf_coef_11 & YEE_COEF_MASK, YEE_MUL_11);
-       regw_ip(base_addr, ee->hpf_coef_12 & YEE_COEF_MASK, YEE_MUL_12);
-       regw_ip(base_addr, ee->hpf_coef_20 & YEE_COEF_MASK, YEE_MUL_20);
-       regw_ip(base_addr, ee->hpf_coef_21 & YEE_COEF_MASK, YEE_MUL_21);
-       regw_ip(base_addr, ee->hpf_coef_22 & YEE_COEF_MASK, YEE_MUL_22);
-       regw_ip(base_addr, ee->yee_thr & YEE_THR_MASK, YEE_THR);
-       regw_ip(base_addr, ee->es_gain & YEE_ES_GAIN_MASK, YEE_E_GAN);
-       regw_ip(base_addr, ee->es_thr1 & YEE_ES_THR1_MASK, YEE_E_THR1);
-       regw_ip(base_addr, ee->es_thr2 & YEE_THR_MASK, YEE_E_THR2);
-       regw_ip(base_addr, ee->es_gain_grad & YEE_THR_MASK, YEE_G_GAN);
-       regw_ip(base_addr, ee->es_ofst_grad & YEE_THR_MASK, YEE_G_OFT);
-
-       for (count = 0; count < VPFE_IPIPE_MAX_SIZE_YEE_LUT; count += 2)
-               w_ip_table(isp5_base_addr, ((ee->table[count + 1] &
-               YEE_ENTRY_MASK) << YEE_ENTRY_SHIFT) |
-               (ee->table[count] & YEE_ENTRY_MASK),
-               ((count/2) << 2) + YEE_TB_START_ADDR);
-}
-
-/* Chromatic Artifact Correction. CAR */
-static void ipipe_set_mf(void __iomem *base_addr)
-{
-       /* typ to dynamic switch */
-       regw_ip(base_addr, VPFE_IPIPE_CAR_DYN_SWITCH, CAR_TYP);
-       /* Set SW0 to maximum */
-       regw_ip(base_addr, CAR_MF_THR, CAR_SW);
-}
-
-static void
-ipipe_set_gain_ctrl(void __iomem *base_addr, struct vpfe_ipipe_car *car)
-{
-       regw_ip(base_addr, VPFE_IPIPE_CAR_CHR_GAIN_CTRL, CAR_TYP);
-       regw_ip(base_addr, car->hpf, CAR_HPF_TYP);
-       regw_ip(base_addr, car->hpf_shft & CAR_HPF_SHIFT_MASK, CAR_HPF_SHF);
-       regw_ip(base_addr, car->hpf_thr, CAR_HPF_THR);
-       regw_ip(base_addr, car->gain1.gain, CAR_GN1_GAN);
-       regw_ip(base_addr, car->gain1.shft & CAR_GAIN1_SHFT_MASK, CAR_GN1_SHF);
-       regw_ip(base_addr, car->gain1.gain_min & CAR_GAIN_MIN_MASK,
-               CAR_GN1_MIN);
-       regw_ip(base_addr, car->gain2.gain, CAR_GN2_GAN);
-       regw_ip(base_addr, car->gain2.shft & CAR_GAIN2_SHFT_MASK, CAR_GN2_SHF);
-       regw_ip(base_addr, car->gain2.gain_min & CAR_GAIN_MIN_MASK,
-               CAR_GN2_MIN);
-}
-
-void ipipe_set_car_regs(void __iomem *base_addr, struct vpfe_ipipe_car *car)
-{
-       u32 val;
-
-       ipipe_clock_enable(base_addr);
-       regw_ip(base_addr, car->en, CAR_EN);
-
-       if (!car->en)
-               return;
-
-       switch (car->meth) {
-       case VPFE_IPIPE_CAR_MED_FLTR:
-               ipipe_set_mf(base_addr);
-               break;
-
-       case VPFE_IPIPE_CAR_CHR_GAIN_CTRL:
-               ipipe_set_gain_ctrl(base_addr, car);
-               break;
-
-       default:
-               /* Dynamic switch between MF and Gain Ctrl. */
-               ipipe_set_mf(base_addr);
-               ipipe_set_gain_ctrl(base_addr, car);
-               /* Set the threshold for switching between
-                * the two Here we overwrite the MF SW0 value
-                */
-               regw_ip(base_addr, VPFE_IPIPE_CAR_DYN_SWITCH, CAR_TYP);
-               val = car->sw1;
-               val <<= CAR_SW1_SHIFT;
-               val |= car->sw0;
-               regw_ip(base_addr, val, CAR_SW);
-       }
-}
-
-/* Chromatic Gain Suppression */
-void ipipe_set_cgs_regs(void __iomem *base_addr, struct vpfe_ipipe_cgs *cgs)
-{
-       ipipe_clock_enable(base_addr);
-       regw_ip(base_addr, cgs->en, CGS_EN);
-
-       if (!cgs->en)
-               return;
-
-       /* Set the bright side parameters */
-       regw_ip(base_addr, cgs->h_thr, CGS_GN1_H_THR);
-       regw_ip(base_addr, cgs->h_slope, CGS_GN1_H_GAN);
-       regw_ip(base_addr, cgs->h_shft & CAR_SHIFT_MASK, CGS_GN1_H_SHF);
-       regw_ip(base_addr, cgs->h_min, CGS_GN1_H_MIN);
-}
-
-void rsz_src_enable(void __iomem *rsz_base, int enable)
-{
-       regw_rsz(rsz_base, enable, RSZ_SRC_EN);
-}
-
-int rsz_enable(void __iomem *rsz_base, int rsz_id, int enable)
-{
-       if (rsz_id == RSZ_A) {
-               regw_rsz(rsz_base, enable, RSZ_EN_A);
-               /* We always enable RSZ_A. RSZ_B is enable upon request from
-                * application. So enable RSZ_SRC_EN along with RSZ_A
-                */
-               regw_rsz(rsz_base, enable, RSZ_SRC_EN);
-       } else if (rsz_id == RSZ_B) {
-               regw_rsz(rsz_base, enable, RSZ_EN_B);
-       } else {
-               BUG();
-       }
-
-       return 0;
-}
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h
deleted file mode 100644 (file)
index 16b6a14..0000000
+++ /dev/null
@@ -1,556 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#ifndef _DAVINCI_VPFE_DM365_IPIPE_HW_H
-#define _DAVINCI_VPFE_DM365_IPIPE_HW_H
-
-#include "vpfe_mc_capture.h"
-
-#define SET_LOW_ADDR     0x0000ffff
-#define SET_HIGH_ADDR    0xffff0000
-
-/* Below are the internal tables */
-#define DPC_TB0_START_ADDR     0x8000
-#define DPC_TB1_START_ADDR     0x8400
-
-#define GAMMA_R_START_ADDR     0xa800
-#define GAMMA_G_START_ADDR     0xb000
-#define GAMMA_B_START_ADDR     0xb800
-
-/* RAM table addresses for edge enhancement correction*/
-#define YEE_TB_START_ADDR      0x8800
-
-/* RAM table address for GBC LUT */
-#define GBCE_TB_START_ADDR     0x9000
-
-/* RAM table for 3D NF LUT */
-#define D3L_TB0_START_ADDR     0x9800
-#define D3L_TB1_START_ADDR     0x9c00
-#define D3L_TB2_START_ADDR     0xa000
-#define D3L_TB3_START_ADDR     0xa400
-
-/* IPIPE Register Offsets from the base address */
-#define IPIPE_SRC_EN           0x0000
-#define IPIPE_SRC_MODE         0x0004
-#define IPIPE_SRC_FMT          0x0008
-#define IPIPE_SRC_COL          0x000c
-#define IPIPE_SRC_VPS          0x0010
-#define IPIPE_SRC_VSZ          0x0014
-#define IPIPE_SRC_HPS          0x0018
-#define IPIPE_SRC_HSZ          0x001c
-
-#define IPIPE_SEL_SBU          0x0020
-
-#define IPIPE_DMA_STA          0x0024
-#define IPIPE_GCK_MMR          0x0028
-#define IPIPE_GCK_PIX          0x002c
-#define IPIPE_RESERVED0                0x0030
-
-/* Defect Correction */
-#define DPC_LUT_EN             0x0034
-#define DPC_LUT_SEL            0x0038
-#define DPC_LUT_ADR            0x003c
-#define DPC_LUT_SIZ            0x0040
-#define DPC_OTF_EN             0x0044
-#define DPC_OTF_TYP            0x0048
-#define DPC_OTF_2D_THR_R       0x004c
-#define DPC_OTF_2D_THR_GR      0x0050
-#define DPC_OTF_2D_THR_GB      0x0054
-#define DPC_OTF_2D_THR_B       0x0058
-#define DPC_OTF_2C_THR_R       0x005c
-#define DPC_OTF_2C_THR_GR      0x0060
-#define DPC_OTF_2C_THR_GB      0x0064
-#define DPC_OTF_2C_THR_B       0x0068
-#define DPC_OTF_3_SHF          0x006c
-#define DPC_OTF_3D_THR         0x0070
-#define DPC_OTF_3D_SLP         0x0074
-#define DPC_OTF_3D_MIN         0x0078
-#define DPC_OTF_3D_MAX         0x007c
-#define DPC_OTF_3C_THR         0x0080
-#define DPC_OTF_3C_SLP         0x0084
-#define DPC_OTF_3C_MIN         0x0088
-#define DPC_OTF_3C_MAX         0x008c
-
-/* Lense Shading Correction */
-#define LSC_VOFT               0x90
-#define LSC_VA2                        0x94
-#define LSC_VA1                        0x98
-#define LSC_VS                 0x9c
-#define LSC_HOFT               0xa0
-#define LSC_HA2                        0xa4
-#define LSC_HA1                        0xa8
-#define LSC_HS                 0xac
-#define LSC_GAIN_R             0xb0
-#define LSC_GAIN_GR            0xb4
-#define LSC_GAIN_GB            0xb8
-#define LSC_GAIN_B             0xbc
-#define LSC_OFT_R              0xc0
-#define LSC_OFT_GR             0xc4
-#define LSC_OFT_GB             0xc8
-#define LSC_OFT_B              0xcc
-#define LSC_SHF                        0xd0
-#define LSC_MAX                        0xd4
-
-/* Noise Filter 1. Ofsets from start address given */
-#define D2F_1ST                        0xd8
-#define D2F_EN                 0x0
-#define D2F_TYP                        0x4
-#define D2F_THR                        0x8
-#define D2F_STR                        0x28
-#define D2F_SPR                        0x48
-#define D2F_EDG_MIN            0x68
-#define D2F_EDG_MAX            0x6c
-
-/* Noise Filter 2 */
-#define D2F_2ND                        0x148
-
-/* GIC */
-#define GIC_EN                 0x1b8
-#define GIC_TYP                        0x1bc
-#define GIC_GAN                        0x1c0
-#define GIC_NFGAN              0x1c4
-#define GIC_THR                        0x1c8
-#define GIC_SLP                        0x1cc
-
-/* White Balance */
-#define WB2_OFT_R              0x1d0
-#define WB2_OFT_GR             0x1d4
-#define WB2_OFT_GB             0x1d8
-#define WB2_OFT_B              0x1dc
-#define WB2_WGN_R              0x1e0
-#define WB2_WGN_GR             0x1e4
-#define WB2_WGN_GB             0x1e8
-#define WB2_WGN_B              0x1ec
-
-/* CFA interpolation */
-#define CFA_MODE               0x1f0
-#define CFA_2DIR_HPF_THR       0x1f4
-#define CFA_2DIR_HPF_SLP       0x1f8
-#define CFA_2DIR_MIX_THR       0x1fc
-#define CFA_2DIR_MIX_SLP       0x200
-#define CFA_2DIR_DIR_THR       0x204
-#define CFA_2DIR_DIR_SLP       0x208
-#define CFA_2DIR_NDWT          0x20c
-#define CFA_MONO_HUE_FRA       0x210
-#define CFA_MONO_EDG_THR       0x214
-#define CFA_MONO_THR_MIN       0x218
-#define CFA_MONO_THR_SLP       0x21c
-#define CFA_MONO_SLP_MIN       0x220
-#define CFA_MONO_SLP_SLP       0x224
-#define CFA_MONO_LPWT          0x228
-
-/* RGB to RGB conversiona - 1st */
-#define RGB1_MUL_BASE          0x22c
-/* Offsets from base */
-#define RGB_MUL_RR             0x0
-#define RGB_MUL_GR             0x4
-#define RGB_MUL_BR             0x8
-#define RGB_MUL_RG             0xc
-#define RGB_MUL_GG             0x10
-#define RGB_MUL_BG             0x14
-#define RGB_MUL_RB             0x18
-#define RGB_MUL_GB             0x1c
-#define RGB_MUL_BB             0x20
-#define RGB_OFT_OR             0x24
-#define RGB_OFT_OG             0x28
-#define RGB_OFT_OB             0x2c
-
-/* Gamma */
-#define GMM_CFG                        0x25c
-
-/* RGB to RGB conversiona - 2nd */
-#define RGB2_MUL_BASE          0x260
-
-/* 3D LUT */
-#define D3LUT_EN               0x290
-
-/* RGB to YUV(YCbCr) conversion */
-#define YUV_ADJ                        0x294
-#define YUV_MUL_RY             0x298
-#define YUV_MUL_GY             0x29c
-#define YUV_MUL_BY             0x2a0
-#define YUV_MUL_RCB            0x2a4
-#define YUV_MUL_GCB            0x2a8
-#define YUV_MUL_BCB            0x2ac
-#define YUV_MUL_RCR            0x2b0
-#define YUV_MUL_GCR            0x2b4
-#define YUV_MUL_BCR            0x2b8
-#define YUV_OFT_Y              0x2bc
-#define YUV_OFT_CB             0x2c0
-#define YUV_OFT_CR             0x2c4
-#define YUV_PHS                        0x2c8
-
-/* Global Brightness and Contrast */
-#define GBCE_EN                        0x2cc
-#define GBCE_TYP               0x2d0
-
-/* Edge Enhancer */
-#define YEE_EN                 0x2d4
-#define YEE_TYP                        0x2d8
-#define YEE_SHF                        0x2dc
-#define YEE_MUL_00             0x2e0
-#define YEE_MUL_01             0x2e4
-#define YEE_MUL_02             0x2e8
-#define YEE_MUL_10             0x2ec
-#define YEE_MUL_11             0x2f0
-#define YEE_MUL_12             0x2f4
-#define YEE_MUL_20             0x2f8
-#define YEE_MUL_21             0x2fc
-#define YEE_MUL_22             0x300
-#define YEE_THR                        0x304
-#define YEE_E_GAN              0x308
-#define YEE_E_THR1             0x30c
-#define YEE_E_THR2             0x310
-#define YEE_G_GAN              0x314
-#define YEE_G_OFT              0x318
-
-/* Chroma Artifact Reduction */
-#define CAR_EN                 0x31c
-#define CAR_TYP                        0x320
-#define CAR_SW                 0x324
-#define CAR_HPF_TYP            0x328
-#define CAR_HPF_SHF            0x32c
-#define        CAR_HPF_THR             0x330
-#define CAR_GN1_GAN            0x334
-#define CAR_GN1_SHF            0x338
-#define CAR_GN1_MIN            0x33c
-#define CAR_GN2_GAN            0x340
-#define CAR_GN2_SHF            0x344
-#define CAR_GN2_MIN            0x348
-
-/* Chroma Gain Suppression */
-#define CGS_EN                 0x34c
-#define CGS_GN1_L_THR          0x350
-#define CGS_GN1_L_GAN          0x354
-#define CGS_GN1_L_SHF          0x358
-#define CGS_GN1_L_MIN          0x35c
-#define CGS_GN1_H_THR          0x360
-#define CGS_GN1_H_GAN          0x364
-#define CGS_GN1_H_SHF          0x368
-#define CGS_GN1_H_MIN          0x36c
-#define CGS_GN2_L_THR          0x370
-#define CGS_GN2_L_GAN          0x374
-#define CGS_GN2_L_SHF          0x378
-#define CGS_GN2_L_MIN          0x37c
-
-/* Resizer */
-#define RSZ_SRC_EN             0x0
-#define RSZ_SRC_MODE           0x4
-#define RSZ_SRC_FMT0           0x8
-#define RSZ_SRC_FMT1           0xc
-#define RSZ_SRC_VPS            0x10
-#define RSZ_SRC_VSZ            0x14
-#define RSZ_SRC_HPS            0x18
-#define RSZ_SRC_HSZ            0x1c
-#define RSZ_DMA_RZA            0x20
-#define RSZ_DMA_RZB            0x24
-#define RSZ_DMA_STA            0x28
-#define RSZ_GCK_MMR            0x2c
-#define RSZ_RESERVED0          0x30
-#define RSZ_GCK_SDR            0x34
-#define RSZ_IRQ_RZA            0x38
-#define RSZ_IRQ_RZB            0x3c
-#define RSZ_YUV_Y_MIN          0x40
-#define RSZ_YUV_Y_MAX          0x44
-#define RSZ_YUV_C_MIN          0x48
-#define RSZ_YUV_C_MAX          0x4c
-#define RSZ_YUV_PHS            0x50
-#define RSZ_SEQ                        0x54
-
-/* Resizer Rescale Parameters */
-#define RSZ_EN_A               0x58
-#define RSZ_EN_B               0xe8
-/*
- * offset of the registers to be added with base register of
- * either RSZ0 or RSZ1
- */
-#define RSZ_MODE               0x4
-#define RSZ_420                        0x8
-#define RSZ_I_VPS              0xc
-#define RSZ_I_HPS              0x10
-#define RSZ_O_VSZ              0x14
-#define RSZ_O_HSZ              0x18
-#define RSZ_V_PHS_Y            0x1c
-#define RSZ_V_PHS_C            0x20
-#define RSZ_V_DIF              0x24
-#define RSZ_V_TYP              0x28
-#define RSZ_V_LPF              0x2c
-#define RSZ_H_PHS              0x30
-#define RSZ_H_PHS_ADJ          0x34
-#define RSZ_H_DIF              0x38
-#define RSZ_H_TYP              0x3c
-#define RSZ_H_LPF              0x40
-#define RSZ_DWN_EN             0x44
-#define RSZ_DWN_AV             0x48
-
-/* Resizer RGB Conversion Parameters */
-#define RSZ_RGB_EN             0x4c
-#define RSZ_RGB_TYP            0x50
-#define RSZ_RGB_BLD            0x54
-
-/* Resizer External Memory Parameters */
-#define RSZ_SDR_Y_BAD_H                0x58
-#define RSZ_SDR_Y_BAD_L                0x5c
-#define RSZ_SDR_Y_SAD_H                0x60
-#define RSZ_SDR_Y_SAD_L                0x64
-#define RSZ_SDR_Y_OFT          0x68
-#define RSZ_SDR_Y_PTR_S                0x6c
-#define RSZ_SDR_Y_PTR_E                0x70
-#define RSZ_SDR_C_BAD_H                0x74
-#define RSZ_SDR_C_BAD_L                0x78
-#define RSZ_SDR_C_SAD_H                0x7c
-#define RSZ_SDR_C_SAD_L                0x80
-#define RSZ_SDR_C_OFT          0x84
-#define RSZ_SDR_C_PTR_S                0x88
-#define RSZ_SDR_C_PTR_E                0x8c
-
-/* Macro for resizer */
-#define RSZ_YUV_Y_MIN          0x40
-#define RSZ_YUV_Y_MAX          0x44
-#define RSZ_YUV_C_MIN          0x48
-#define RSZ_YUV_C_MAX          0x4c
-
-#define IPIPE_GCK_MMR_DEFAULT  1
-#define IPIPE_GCK_PIX_DEFAULT  0xe
-#define RSZ_GCK_MMR_DEFAULT    1
-#define RSZ_GCK_SDR_DEFAULT    1
-
-/* LUTDPC */
-#define LUTDPC_TBL_256_EN      0
-#define LUTDPC_INF_TBL_EN      1
-#define LUT_DPC_START_ADDR     0
-#define LUT_DPC_H_POS_MASK     0x1fff
-#define LUT_DPC_V_POS_MASK     0x1fff
-#define LUT_DPC_V_POS_SHIFT    13
-#define LUT_DPC_CORR_METH_SHIFT        26
-#define LUT_DPC_MAX_SIZE       256
-#define LUT_DPC_SIZE_MASK      0x3ff
-
-/* OTFDPC */
-#define OTFDPC_DPC2_THR_MASK   0xfff
-#define OTF_DET_METHOD_SHIFT   1
-#define OTF_DPC3_0_SHF_MASK    3
-#define OTF_DPC3_0_THR_SHIFT   6
-#define OTF_DPC3_0_THR_MASK    0x3f
-#define OTF_DPC3_0_SLP_MASK    0x3f
-#define OTF_DPC3_0_DET_MASK    0xfff
-#define OTF_DPC3_0_CORR_MASK   0xfff
-
-/* NF (D2F) */
-#define D2F_SPR_VAL_MASK               0x1f
-#define D2F_SPR_VAL_SHIFT              0
-#define D2F_SHFT_VAL_MASK              3
-#define D2F_SHFT_VAL_SHIFT             5
-#define D2F_SAMPLE_METH_SHIFT          7
-#define D2F_APPLY_LSC_GAIN_SHIFT       8
-#define D2F_USE_SPR_REG_VAL            0
-#define D2F_STR_VAL_MASK               0x1f
-#define D2F_THR_VAL_MASK               0x3ff
-#define D2F_EDGE_DET_THR_MASK          0x7ff
-
-/* Green Imbalance Correction */
-#define GIC_TYP_SHIFT                  0
-#define GIC_THR_SEL_SHIFT              1
-#define        GIC_APPLY_LSC_GAIN_SHIFT        2
-#define GIC_GAIN_MASK                  0xff
-#define GIC_THR_MASK                   0xfff
-#define GIC_SLOPE_MASK                 0xfff
-#define GIC_NFGAN_INT_MASK             7
-#define GIC_NFGAN_DECI_MASK            0x1f
-
-/* WB */
-#define WB_OFFSET_MASK                 0xfff
-#define WB_GAIN_INT_MASK               0xf
-#define WB_GAIN_DECI_MASK              0x1ff
-
-/* CFA */
-#define CFA_HPF_THR_2DIR_MASK          0x1fff
-#define CFA_HPF_SLOPE_2DIR_MASK                0x3ff
-#define CFA_HPF_MIX_THR_2DIR_MASK      0x1fff
-#define CFA_HPF_MIX_SLP_2DIR_MASK      0x3ff
-#define CFA_DIR_THR_2DIR_MASK          0x3ff
-#define CFA_DIR_SLP_2DIR_MASK          0x7f
-#define CFA_ND_WT_2DIR_MASK            0x3f
-#define CFA_DAA_HUE_FRA_MASK           0x3f
-#define CFA_DAA_EDG_THR_MASK           0xff
-#define CFA_DAA_THR_MIN_MASK           0x3ff
-#define CFA_DAA_THR_SLP_MASK           0x3ff
-#define CFA_DAA_SLP_MIN_MASK           0x3ff
-#define CFA_DAA_SLP_SLP_MASK           0x3ff
-#define CFA_DAA_LP_WT_MASK             0x3f
-
-/* RGB2RGB */
-#define RGB2RGB_1_OFST_MASK            0x1fff
-#define RGB2RGB_1_GAIN_INT_MASK                0xf
-#define RGB2RGB_GAIN_DECI_MASK         0xff
-#define RGB2RGB_2_OFST_MASK            0x7ff
-#define RGB2RGB_2_GAIN_INT_MASK                0x7
-
-/* Gamma */
-#define GAMMA_BYPR_SHIFT               0
-#define GAMMA_BYPG_SHIFT               1
-#define GAMMA_BYPB_SHIFT               2
-#define GAMMA_TBL_SEL_SHIFT            4
-#define GAMMA_TBL_SIZE_SHIFT           5
-#define GAMMA_MASK                     0x3ff
-#define GAMMA_SHIFT                    10
-
-/* 3D LUT */
-#define D3_LUT_ENTRY_MASK              0x3ff
-#define D3_LUT_ENTRY_R_SHIFT           20
-#define D3_LUT_ENTRY_G_SHIFT           10
-#define D3_LUT_ENTRY_B_SHIFT           0
-
-/* Lumina adj */
-#define        LUM_ADJ_CONTR_SHIFT             0
-#define        LUM_ADJ_BRIGHT_SHIFT            8
-
-/* RGB2YCbCr */
-#define RGB2YCBCR_OFST_MASK            0x7ff
-#define RGB2YCBCR_COEF_INT_MASK                0xf
-#define RGB2YCBCR_COEF_DECI_MASK       0xff
-
-/* GBCE */
-#define GBCE_Y_VAL_MASK                        0xff
-#define GBCE_GAIN_VAL_MASK             0x3ff
-#define GBCE_ENTRY_SHIFT               10
-
-/* Edge Enhancements */
-#define YEE_HALO_RED_EN_SHIFT          1
-#define YEE_HPF_SHIFT_MASK             0xf
-#define YEE_COEF_MASK                  0x3ff
-#define YEE_THR_MASK                   0x3f
-#define YEE_ES_GAIN_MASK               0xfff
-#define YEE_ES_THR1_MASK               0xfff
-#define YEE_ENTRY_SHIFT                        9
-#define YEE_ENTRY_MASK                 0x1ff
-
-/* CAR */
-#define CAR_MF_THR                     0xff
-#define CAR_SW1_SHIFT                  8
-#define CAR_GAIN1_SHFT_MASK            7
-#define CAR_GAIN_MIN_MASK              0x1ff
-#define CAR_GAIN2_SHFT_MASK            0xf
-#define CAR_HPF_SHIFT_MASK             3
-
-/* CGS */
-#define CAR_SHIFT_MASK                 3
-
-/* Resizer */
-#define RSZ_BYPASS_SHIFT               1
-#define RSZ_SRC_IMG_FMT_SHIFT          1
-#define RSZ_SRC_Y_C_SEL_SHIFT          2
-#define IPIPE_RSZ_VPS_MASK             0xffff
-#define IPIPE_RSZ_HPS_MASK             0xffff
-#define IPIPE_RSZ_VSZ_MASK             0x1fff
-#define IPIPE_RSZ_HSZ_MASK             0x1fff
-#define RSZ_HPS_MASK                   0x1fff
-#define RSZ_VPS_MASK                   0x1fff
-#define RSZ_O_HSZ_MASK                 0x1fff
-#define RSZ_O_VSZ_MASK                 0x1fff
-#define RSZ_V_PHS_MASK                 0x3fff
-#define RSZ_V_DIF_MASK                 0x3fff
-
-#define RSZA_H_FLIP_SHIFT              0
-#define RSZA_V_FLIP_SHIFT              1
-#define RSZB_H_FLIP_SHIFT              2
-#define RSZB_V_FLIP_SHIFT              3
-#define RSZ_A                          0
-#define RSZ_B                          1
-#define RSZ_CEN_SHIFT                  1
-#define RSZ_YEN_SHIFT                  0
-#define RSZ_TYP_Y_SHIFT                        0
-#define RSZ_TYP_C_SHIFT                        1
-#define RSZ_LPF_INT_MASK               0x3f
-#define RSZ_LPF_INT_C_SHIFT            6
-#define RSZ_H_PHS_MASK                 0x3fff
-#define RSZ_H_DIF_MASK                 0x3fff
-#define RSZ_DIFF_DOWN_THR              256
-#define RSZ_DWN_SCALE_AV_SZ_V_SHIFT    3
-#define RSZ_DWN_SCALE_AV_SZ_MASK       7
-#define RSZ_RGB_MSK1_SHIFT             2
-#define RSZ_RGB_MSK0_SHIFT             1
-#define RSZ_RGB_TYP_SHIFT              0
-#define RSZ_RGB_ALPHA_MASK             0xff
-
-static inline u32 regr_ip(void __iomem *addr, u32 offset)
-{
-       return readl(addr + offset);
-}
-
-static inline void regw_ip(void __iomem *addr, u32 val, u32 offset)
-{
-       writel(val, addr + offset);
-}
-
-static inline u32 w_ip_table(void __iomem *addr, u32 val, u32 offset)
-{
-       writel(val, addr + offset);
-
-       return val;
-}
-
-static inline u32 regr_rsz(void __iomem *addr, u32 offset)
-{
-       return readl(addr + offset);
-}
-
-static inline u32 regw_rsz(void __iomem *addr, u32 val, u32 offset)
-{
-       writel(val, addr + offset);
-
-       return val;
-}
-
-int config_ipipe_hw(struct vpfe_ipipe_device *ipipe);
-int resizer_set_outaddr(void __iomem *rsz_base, struct resizer_params *params,
-                       int resize_no, unsigned int address);
-int rsz_enable(void __iomem *rsz_base, int rsz_id, int enable);
-void rsz_src_enable(void __iomem *rsz_base, int enable);
-void rsz_set_in_pix_format(unsigned char y_c);
-int config_rsz_hw(struct vpfe_resizer_device *resizer,
-                 struct resizer_params *config);
-void ipipe_set_d2f_regs(void __iomem *base_addr, unsigned int id,
-       struct vpfe_ipipe_nf *noise_filter);
-void ipipe_set_rgb2rgb_regs(void __iomem *base_addr, unsigned int id,
-       struct vpfe_ipipe_rgb2rgb *rgb);
-void ipipe_set_yuv422_conv_regs(void __iomem *base_addr,
-       struct vpfe_ipipe_yuv422_conv *conv);
-void ipipe_set_lum_adj_regs(void __iomem *base_addr,
-       struct ipipe_lum_adj *lum_adj);
-void ipipe_set_rgb2ycbcr_regs(void __iomem *base_addr,
-       struct vpfe_ipipe_rgb2yuv *yuv);
-void ipipe_set_lutdpc_regs(void __iomem *base_addr,
-       void __iomem *isp5_base_addr, struct vpfe_ipipe_lutdpc *lutdpc);
-void ipipe_set_otfdpc_regs(void __iomem *base_addr,
-       struct vpfe_ipipe_otfdpc *otfdpc);
-void ipipe_set_3d_lut_regs(void __iomem *base_addr,
-       void __iomem *isp5_base_addr, struct vpfe_ipipe_3d_lut *lut_3d);
-void ipipe_set_gamma_regs(void __iomem *base_addr,
-       void __iomem *isp5_base_addr, struct vpfe_ipipe_gamma *gamma);
-void ipipe_set_ee_regs(void __iomem *base_addr,
-       void __iomem *isp5_base_addr, struct vpfe_ipipe_yee *ee);
-void ipipe_set_gbce_regs(void __iomem *base_addr,
-       void __iomem *isp5_base_addr, struct vpfe_ipipe_gbce *gbce);
-void ipipe_set_gic_regs(void __iomem *base_addr, struct vpfe_ipipe_gic *gic);
-void ipipe_set_cfa_regs(void __iomem *base_addr, struct vpfe_ipipe_cfa *cfa);
-void ipipe_set_car_regs(void __iomem *base_addr, struct vpfe_ipipe_car *car);
-void ipipe_set_cgs_regs(void __iomem *base_addr, struct vpfe_ipipe_cgs *cgs);
-void ipipe_set_wb_regs(void __iomem *base_addr, struct vpfe_ipipe_wb *wb);
-
-#endif         /* _DAVINCI_VPFE_DM365_IPIPE_HW_H */
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
deleted file mode 100644 (file)
index 51d4cd1..0000000
+++ /dev/null
@@ -1,1070 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#include "dm365_ipipeif.h"
-#include "vpfe_mc_capture.h"
-
-static const unsigned int ipipeif_input_fmts[] = {
-       MEDIA_BUS_FMT_UYVY8_2X8,
-       MEDIA_BUS_FMT_SGRBG12_1X12,
-       MEDIA_BUS_FMT_Y8_1X8,
-       MEDIA_BUS_FMT_UV8_1X8,
-       MEDIA_BUS_FMT_YDYUYDYV8_1X16,
-       MEDIA_BUS_FMT_SBGGR8_1X8,
-};
-
-static const unsigned int ipipeif_output_fmts[] = {
-       MEDIA_BUS_FMT_UYVY8_2X8,
-       MEDIA_BUS_FMT_SGRBG12_1X12,
-       MEDIA_BUS_FMT_Y8_1X8,
-       MEDIA_BUS_FMT_UV8_1X8,
-       MEDIA_BUS_FMT_YDYUYDYV8_1X16,
-       MEDIA_BUS_FMT_SBGGR8_1X8,
-       MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
-       MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8,
-};
-
-static int
-ipipeif_get_pack_mode(u32 in_pix_fmt)
-{
-       switch (in_pix_fmt) {
-       case MEDIA_BUS_FMT_SBGGR8_1X8:
-       case MEDIA_BUS_FMT_Y8_1X8:
-       case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
-       case MEDIA_BUS_FMT_UV8_1X8:
-               return IPIPEIF_5_1_PACK_8_BIT;
-
-       case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
-               return IPIPEIF_5_1_PACK_8_BIT_A_LAW;
-
-       case MEDIA_BUS_FMT_SGRBG12_1X12:
-               return IPIPEIF_5_1_PACK_16_BIT;
-
-       case MEDIA_BUS_FMT_SBGGR12_1X12:
-               return IPIPEIF_5_1_PACK_12_BIT;
-
-       default:
-               return IPIPEIF_5_1_PACK_16_BIT;
-       }
-}
-
-static inline u32 ipipeif_read(void __iomem *addr, u32 offset)
-{
-       return readl(addr + offset);
-}
-
-static inline void ipipeif_write(u32 val, void __iomem *addr, u32 offset)
-{
-       writel(val, addr + offset);
-}
-
-static void ipipeif_config_dpc(void __iomem *addr, struct ipipeif_dpc *dpc)
-{
-       u32 val = 0;
-
-       if (dpc->en) {
-               val = (dpc->en & 1) << IPIPEIF_DPC2_EN_SHIFT;
-               val |= dpc->thr & IPIPEIF_DPC2_THR_MASK;
-       }
-       ipipeif_write(val, addr, IPIPEIF_DPC2);
-}
-
-#define IPIPEIF_MODE_CONTINUOUS                        0
-#define IPIPEIF_MODE_ONE_SHOT                  1
-
-static int get_oneshot_mode(enum ipipeif_input_entity input)
-{
-       if (input == IPIPEIF_INPUT_MEMORY)
-               return IPIPEIF_MODE_ONE_SHOT;
-       if (input == IPIPEIF_INPUT_ISIF)
-               return IPIPEIF_MODE_CONTINUOUS;
-
-       return -EINVAL;
-}
-
-static int
-ipipeif_get_cfg_src1(struct vpfe_ipipeif_device *ipipeif)
-{
-       struct v4l2_mbus_framefmt *informat;
-
-       informat = &ipipeif->formats[IPIPEIF_PAD_SINK];
-       if (ipipeif->input == IPIPEIF_INPUT_MEMORY &&
-           (informat->code == MEDIA_BUS_FMT_Y8_1X8 ||
-           informat->code == MEDIA_BUS_FMT_UV8_1X8))
-               return IPIPEIF_CCDC;
-
-       return IPIPEIF_SRC1_PARALLEL_PORT;
-}
-
-static int
-ipipeif_get_data_shift(struct vpfe_ipipeif_device *ipipeif)
-{
-       struct v4l2_mbus_framefmt *informat;
-
-       informat = &ipipeif->formats[IPIPEIF_PAD_SINK];
-
-       switch (informat->code) {
-       case MEDIA_BUS_FMT_SGRBG12_1X12:
-               return IPIPEIF_5_1_BITS11_0;
-
-       case MEDIA_BUS_FMT_Y8_1X8:
-       case MEDIA_BUS_FMT_UV8_1X8:
-               return IPIPEIF_5_1_BITS11_0;
-
-       default:
-               return IPIPEIF_5_1_BITS7_0;
-       }
-}
-
-static enum ipipeif_input_source
-ipipeif_get_source(struct vpfe_ipipeif_device *ipipeif)
-{
-       struct v4l2_mbus_framefmt *informat;
-
-       informat = &ipipeif->formats[IPIPEIF_PAD_SINK];
-       if (ipipeif->input == IPIPEIF_INPUT_ISIF)
-               return IPIPEIF_CCDC;
-
-       if (informat->code == MEDIA_BUS_FMT_UYVY8_2X8)
-               return IPIPEIF_SDRAM_YUV;
-
-       return IPIPEIF_SDRAM_RAW;
-}
-
-void vpfe_ipipeif_ss_buffer_isr(struct vpfe_ipipeif_device *ipipeif)
-{
-       struct vpfe_video_device *video_in = &ipipeif->video_in;
-
-       if (ipipeif->input != IPIPEIF_INPUT_MEMORY)
-               return;
-
-       spin_lock(&video_in->dma_queue_lock);
-       vpfe_video_process_buffer_complete(video_in);
-       video_in->state = VPFE_VIDEO_BUFFER_NOT_QUEUED;
-       vpfe_video_schedule_next_buffer(video_in);
-       spin_unlock(&video_in->dma_queue_lock);
-}
-
-int vpfe_ipipeif_decimation_enabled(struct vpfe_device *vpfe_dev)
-{
-       struct vpfe_ipipeif_device *ipipeif = &vpfe_dev->vpfe_ipipeif;
-
-       return ipipeif->config.decimation;
-}
-
-int vpfe_ipipeif_get_rsz(struct vpfe_device *vpfe_dev)
-{
-       struct vpfe_ipipeif_device *ipipeif = &vpfe_dev->vpfe_ipipeif;
-
-       return ipipeif->config.rsz;
-}
-
-#define RD_DATA_15_2           0x7
-
-/*
- * ipipeif_hw_setup() - This function sets up IPIPEIF
- * @sd: pointer to v4l2 subdev structure
- * return -EINVAL or zero on success
- */
-static int ipipeif_hw_setup(struct v4l2_subdev *sd)
-{
-       struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
-       struct v4l2_mbus_framefmt *informat, *outformat;
-       struct ipipeif_params params = ipipeif->config;
-       enum ipipeif_input_source ipipeif_source;
-       u32 isif_port_if;
-       void __iomem *ipipeif_base_addr;
-       unsigned long val;
-       int data_shift;
-       int pack_mode;
-       int source1;
-       int tmp;
-
-       ipipeif_base_addr = ipipeif->ipipeif_base_addr;
-
-       /* Enable clock to IPIPEIF and IPIPE */
-       vpss_enable_clock(VPSS_IPIPEIF_CLOCK, 1);
-
-       informat = &ipipeif->formats[IPIPEIF_PAD_SINK];
-       outformat = &ipipeif->formats[IPIPEIF_PAD_SOURCE];
-
-       /* Combine all the fields to make CFG1 register of IPIPEIF */
-       tmp = val = get_oneshot_mode(ipipeif->input);
-       if (tmp < 0) {
-               dev_err(&sd->devnode->dev, "ipipeif: links setup required");
-               return -EINVAL;
-       }
-       val <<= ONESHOT_SHIFT;
-
-       ipipeif_source = ipipeif_get_source(ipipeif);
-       val |= ipipeif_source << INPSRC_SHIFT;
-
-       val |= params.clock_select << CLKSEL_SHIFT;
-       val |= params.avg_filter << AVGFILT_SHIFT;
-       val |= params.decimation << DECIM_SHIFT;
-
-       pack_mode = ipipeif_get_pack_mode(informat->code);
-       val |= pack_mode << PACK8IN_SHIFT;
-
-       source1 = ipipeif_get_cfg_src1(ipipeif);
-       val |= source1 << INPSRC1_SHIFT;
-
-       data_shift = ipipeif_get_data_shift(ipipeif);
-       if (ipipeif_source != IPIPEIF_SDRAM_YUV)
-               val |= data_shift << DATASFT_SHIFT;
-       else
-               val &= ~(RD_DATA_15_2 << DATASFT_SHIFT);
-
-       ipipeif_write(val, ipipeif_base_addr, IPIPEIF_CFG1);
-
-       switch (ipipeif_source) {
-       case IPIPEIF_CCDC:
-               ipipeif_write(ipipeif->gain, ipipeif_base_addr, IPIPEIF_GAIN);
-               break;
-
-       case IPIPEIF_SDRAM_RAW:
-       case IPIPEIF_CCDC_DARKFM:
-               ipipeif_write(ipipeif->gain, ipipeif_base_addr, IPIPEIF_GAIN);
-               /* fall through */
-       case IPIPEIF_SDRAM_YUV:
-               val |= data_shift << DATASFT_SHIFT;
-               ipipeif_write(params.ppln, ipipeif_base_addr, IPIPEIF_PPLN);
-               ipipeif_write(params.lpfr, ipipeif_base_addr, IPIPEIF_LPFR);
-               ipipeif_write(informat->width, ipipeif_base_addr, IPIPEIF_HNUM);
-               ipipeif_write(informat->height,
-                             ipipeif_base_addr, IPIPEIF_VNUM);
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       /*check if decimation is enable or not */
-       if (params.decimation)
-               ipipeif_write(params.rsz, ipipeif_base_addr, IPIPEIF_RSZ);
-
-       /* Setup sync alignment and initial rsz position */
-       val = params.if_5_1.align_sync & 1;
-       val <<= IPIPEIF_INIRSZ_ALNSYNC_SHIFT;
-       val |= params.if_5_1.rsz_start & IPIPEIF_INIRSZ_MASK;
-       ipipeif_write(val, ipipeif_base_addr, IPIPEIF_INIRSZ);
-       isif_port_if = informat->code;
-
-       if (isif_port_if == MEDIA_BUS_FMT_Y8_1X8)
-               isif_port_if = MEDIA_BUS_FMT_YUYV8_1X16;
-       else if (isif_port_if == MEDIA_BUS_FMT_UV8_1X8)
-               isif_port_if = MEDIA_BUS_FMT_SGRBG12_1X12;
-
-       /* Enable DPCM decompression */
-       switch (ipipeif_source) {
-       case IPIPEIF_SDRAM_RAW:
-               val = 0;
-               if (outformat->code == MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8) {
-                       val = 1;
-                       val |= (IPIPEIF_DPCM_8BIT_10BIT & 1) <<
-                               IPIPEIF_DPCM_BITS_SHIFT;
-                       val |= (ipipeif->dpcm_predictor & 1) <<
-                               IPIPEIF_DPCM_PRED_SHIFT;
-               }
-               ipipeif_write(val, ipipeif_base_addr, IPIPEIF_DPCM);
-
-               /* set DPC */
-               ipipeif_config_dpc(ipipeif_base_addr, &params.if_5_1.dpc);
-
-               ipipeif_write(params.if_5_1.clip,
-                             ipipeif_base_addr, IPIPEIF_OCLIP);
-
-               /* fall through for SDRAM YUV mode */
-               /* configure CFG2 */
-               val = ipipeif_read(ipipeif_base_addr, IPIPEIF_CFG2);
-               switch (isif_port_if) {
-               case MEDIA_BUS_FMT_YUYV8_1X16:
-               case MEDIA_BUS_FMT_UYVY8_2X8:
-               case MEDIA_BUS_FMT_Y8_1X8:
-                       clear_bit(IPIPEIF_CFG2_YUV8_SHIFT, &val);
-                       set_bit(IPIPEIF_CFG2_YUV16_SHIFT, &val);
-                       ipipeif_write(val, ipipeif_base_addr, IPIPEIF_CFG2);
-                       break;
-
-               default:
-                       clear_bit(IPIPEIF_CFG2_YUV8_SHIFT, &val);
-                       clear_bit(IPIPEIF_CFG2_YUV16_SHIFT, &val);
-                       ipipeif_write(val, ipipeif_base_addr, IPIPEIF_CFG2);
-                       break;
-               }
-               /* fall through */
-
-       case IPIPEIF_SDRAM_YUV:
-               /* Set clock divider */
-               if (params.clock_select == IPIPEIF_SDRAM_CLK) {
-                       val = ipipeif_read(ipipeif_base_addr, IPIPEIF_CLKDIV);
-                       val |= (params.if_5_1.clk_div.m - 1) <<
-                               IPIPEIF_CLKDIV_M_SHIFT;
-                       val |= (params.if_5_1.clk_div.n - 1);
-                       ipipeif_write(val, ipipeif_base_addr, IPIPEIF_CLKDIV);
-               }
-               break;
-
-       case IPIPEIF_CCDC:
-       case IPIPEIF_CCDC_DARKFM:
-               /* set DPC */
-               ipipeif_config_dpc(ipipeif_base_addr, &params.if_5_1.dpc);
-
-               /* Set DF gain & threshold control */
-               val = 0;
-               if (params.if_5_1.df_gain_en) {
-                       val = params.if_5_1.df_gain_thr &
-                               IPIPEIF_DF_GAIN_THR_MASK;
-                       ipipeif_write(val, ipipeif_base_addr, IPIPEIF_DFSGTH);
-                       val = (params.if_5_1.df_gain_en & 1) <<
-                               IPIPEIF_DF_GAIN_EN_SHIFT;
-                       val |= params.if_5_1.df_gain &
-                               IPIPEIF_DF_GAIN_MASK;
-               }
-               ipipeif_write(val, ipipeif_base_addr, IPIPEIF_DFSGVL);
-               /* configure CFG2 */
-               val = VPFE_PINPOL_POSITIVE << IPIPEIF_CFG2_HDPOL_SHIFT;
-               val |= VPFE_PINPOL_POSITIVE << IPIPEIF_CFG2_VDPOL_SHIFT;
-
-               switch (isif_port_if) {
-               case MEDIA_BUS_FMT_YUYV8_1X16:
-               case MEDIA_BUS_FMT_YUYV10_1X20:
-                       clear_bit(IPIPEIF_CFG2_YUV8_SHIFT, &val);
-                       set_bit(IPIPEIF_CFG2_YUV16_SHIFT, &val);
-                       break;
-
-               case MEDIA_BUS_FMT_YUYV8_2X8:
-               case MEDIA_BUS_FMT_UYVY8_2X8:
-               case MEDIA_BUS_FMT_Y8_1X8:
-               case MEDIA_BUS_FMT_YUYV10_2X10:
-                       set_bit(IPIPEIF_CFG2_YUV8_SHIFT, &val);
-                       set_bit(IPIPEIF_CFG2_YUV16_SHIFT, &val);
-                       val |= IPIPEIF_CBCR_Y << IPIPEIF_CFG2_YUV8P_SHIFT;
-                       break;
-
-               default:
-                       /* Bayer */
-                       ipipeif_write(params.if_5_1.clip, ipipeif_base_addr,
-                                     IPIPEIF_OCLIP);
-               }
-               ipipeif_write(val, ipipeif_base_addr, IPIPEIF_CFG2);
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-static int
-ipipeif_set_config(struct v4l2_subdev *sd, struct ipipeif_params *config)
-{
-       struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
-       struct device *dev = ipipeif->subdev.v4l2_dev->dev;
-
-       if (!config) {
-               dev_err(dev, "Invalid configuration pointer\n");
-               return -EINVAL;
-       }
-
-       ipipeif->config.clock_select = config->clock_select;
-       ipipeif->config.ppln = config->ppln;
-       ipipeif->config.lpfr = config->lpfr;
-       ipipeif->config.rsz = config->rsz;
-       ipipeif->config.decimation = config->decimation;
-       if (ipipeif->config.decimation &&
-           (ipipeif->config.rsz < IPIPEIF_RSZ_MIN ||
-           ipipeif->config.rsz > IPIPEIF_RSZ_MAX)) {
-               dev_err(dev, "rsz range is %d to %d\n",
-                       IPIPEIF_RSZ_MIN, IPIPEIF_RSZ_MAX);
-               return -EINVAL;
-       }
-
-       ipipeif->config.avg_filter = config->avg_filter;
-
-       ipipeif->config.if_5_1.df_gain_thr = config->if_5_1.df_gain_thr;
-       ipipeif->config.if_5_1.df_gain = config->if_5_1.df_gain;
-       ipipeif->config.if_5_1.df_gain_en = config->if_5_1.df_gain_en;
-
-       ipipeif->config.if_5_1.rsz_start = config->if_5_1.rsz_start;
-       ipipeif->config.if_5_1.align_sync = config->if_5_1.align_sync;
-       ipipeif->config.if_5_1.clip = config->if_5_1.clip;
-
-       ipipeif->config.if_5_1.dpc.en = config->if_5_1.dpc.en;
-       ipipeif->config.if_5_1.dpc.thr = config->if_5_1.dpc.thr;
-
-       ipipeif->config.if_5_1.clk_div.m = config->if_5_1.clk_div.m;
-       ipipeif->config.if_5_1.clk_div.n = config->if_5_1.clk_div.n;
-
-       return 0;
-}
-
-static int
-ipipeif_get_config(struct v4l2_subdev *sd, void *arg)
-{
-       struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
-       struct ipipeif_params *config = arg;
-       struct device *dev = ipipeif->subdev.v4l2_dev->dev;
-
-       if (!arg) {
-               dev_err(dev, "Invalid configuration pointer\n");
-               return -EINVAL;
-       }
-
-       config->clock_select = ipipeif->config.clock_select;
-       config->ppln = ipipeif->config.ppln;
-       config->lpfr = ipipeif->config.lpfr;
-       config->rsz = ipipeif->config.rsz;
-       config->decimation = ipipeif->config.decimation;
-       config->avg_filter = ipipeif->config.avg_filter;
-
-       config->if_5_1.df_gain_thr = ipipeif->config.if_5_1.df_gain_thr;
-       config->if_5_1.df_gain = ipipeif->config.if_5_1.df_gain;
-       config->if_5_1.df_gain_en = ipipeif->config.if_5_1.df_gain_en;
-
-       config->if_5_1.rsz_start = ipipeif->config.if_5_1.rsz_start;
-       config->if_5_1.align_sync = ipipeif->config.if_5_1.align_sync;
-       config->if_5_1.clip = ipipeif->config.if_5_1.clip;
-
-       config->if_5_1.dpc.en = ipipeif->config.if_5_1.dpc.en;
-       config->if_5_1.dpc.thr = ipipeif->config.if_5_1.dpc.thr;
-
-       config->if_5_1.clk_div.m = ipipeif->config.if_5_1.clk_div.m;
-       config->if_5_1.clk_div.n = ipipeif->config.if_5_1.clk_div.n;
-
-       return 0;
-}
-
-/*
- * ipipeif_ioctl() - Handle ipipeif module private ioctl's
- * @sd: pointer to v4l2 subdev structure
- * @cmd: configuration command
- * @arg: configuration argument
- */
-static long ipipeif_ioctl(struct v4l2_subdev *sd,
-                         unsigned int cmd, void *arg)
-{
-       struct ipipeif_params *config = arg;
-       int ret = -ENOIOCTLCMD;
-
-       switch (cmd) {
-       case VIDIOC_VPFE_IPIPEIF_S_CONFIG:
-               ret = ipipeif_set_config(sd, config);
-               break;
-
-       case VIDIOC_VPFE_IPIPEIF_G_CONFIG:
-               ret = ipipeif_get_config(sd, arg);
-               break;
-       }
-       return ret;
-}
-
-/*
- * ipipeif_s_ctrl() - Handle set control subdev method
- * @ctrl: pointer to v4l2 control structure
- */
-static int ipipeif_s_ctrl(struct v4l2_ctrl *ctrl)
-{
-       struct vpfe_ipipeif_device *ipipeif =
-               container_of(ctrl->handler, struct vpfe_ipipeif_device, ctrls);
-
-       switch (ctrl->id) {
-       case VPFE_CID_DPCM_PREDICTOR:
-               ipipeif->dpcm_predictor = ctrl->val;
-               break;
-
-       case V4L2_CID_GAIN:
-               ipipeif->gain = ctrl->val;
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-#define ENABLE_IPIPEIF         0x1
-
-void vpfe_ipipeif_enable(struct vpfe_device *vpfe_dev)
-{
-       struct vpfe_ipipeif_device *ipipeif = &vpfe_dev->vpfe_ipipeif;
-       void __iomem *ipipeif_base_addr = ipipeif->ipipeif_base_addr;
-       unsigned char val;
-
-       if (ipipeif->input != IPIPEIF_INPUT_MEMORY)
-               return;
-
-       do {
-               val = ipipeif_read(ipipeif_base_addr, IPIPEIF_ENABLE);
-       } while (val & 0x1);
-
-       ipipeif_write(ENABLE_IPIPEIF, ipipeif_base_addr, IPIPEIF_ENABLE);
-}
-
-/*
- * ipipeif_set_stream() - Enable/Disable streaming on ipipeif subdev
- * @sd: pointer to v4l2 subdev structure
- * @enable: 1 == Enable, 0 == Disable
- */
-static int ipipeif_set_stream(struct v4l2_subdev *sd, int enable)
-{
-       struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
-       struct vpfe_device *vpfe_dev = to_vpfe_device(ipipeif);
-       int ret = 0;
-
-       if (!enable)
-               return ret;
-
-       ret = ipipeif_hw_setup(sd);
-       if (!ret)
-               vpfe_ipipeif_enable(vpfe_dev);
-
-       return ret;
-}
-
-/*
- * ipipeif_enum_mbus_code() - Handle pixel format enumeration
- * @sd: pointer to v4l2 subdev structure
- * @cfg: V4L2 subdev pad config
- * @code: pointer to v4l2_subdev_mbus_code_enum structure
- * return -EINVAL or zero on success
- */
-static int ipipeif_enum_mbus_code(struct v4l2_subdev *sd,
-                                 struct v4l2_subdev_pad_config *cfg,
-                       struct v4l2_subdev_mbus_code_enum *code)
-{
-       switch (code->pad) {
-       case IPIPEIF_PAD_SINK:
-               if (code->index >= ARRAY_SIZE(ipipeif_input_fmts))
-                       return -EINVAL;
-
-               code->code = ipipeif_input_fmts[code->index];
-               break;
-
-       case IPIPEIF_PAD_SOURCE:
-               if (code->index >= ARRAY_SIZE(ipipeif_output_fmts))
-                       return -EINVAL;
-
-               code->code = ipipeif_output_fmts[code->index];
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-/*
- * ipipeif_get_format() - Handle get format by pads subdev method
- * @sd: pointer to v4l2 subdev structure
- * @cfg: V4L2 subdev pad config
- * @fmt: pointer to v4l2 subdev format structure
- */
-static int
-ipipeif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
-                  struct v4l2_subdev_format *fmt)
-{
-       struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
-
-       if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE)
-               fmt->format = ipipeif->formats[fmt->pad];
-       else
-               fmt->format = *(v4l2_subdev_get_try_format(sd, cfg, fmt->pad));
-
-       return 0;
-}
-
-#define MIN_OUT_WIDTH                  32
-#define MIN_OUT_HEIGHT                 32
-
-/*
- * ipipeif_try_format() - Handle try format by pad subdev method
- * @ipipeif: VPFE ipipeif device.
- * @cfg: V4L2 subdev pad config
- * @pad: pad num.
- * @fmt: pointer to v4l2 format structure.
- * @which : wanted subdev format
- */
-static void
-ipipeif_try_format(struct vpfe_ipipeif_device *ipipeif,
-                  struct v4l2_subdev_pad_config *cfg, unsigned int pad,
-                  struct v4l2_mbus_framefmt *fmt,
-                  enum v4l2_subdev_format_whence which)
-{
-       unsigned int max_out_height;
-       unsigned int max_out_width;
-       unsigned int i;
-
-       max_out_width = IPIPE_MAX_OUTPUT_WIDTH_A;
-       max_out_height = IPIPE_MAX_OUTPUT_HEIGHT_A;
-
-       if (pad == IPIPEIF_PAD_SINK) {
-               for (i = 0; i < ARRAY_SIZE(ipipeif_input_fmts); i++)
-                       if (fmt->code == ipipeif_input_fmts[i])
-                               break;
-
-               /* If not found, use SBGGR10 as default */
-               if (i >= ARRAY_SIZE(ipipeif_input_fmts))
-                       fmt->code = MEDIA_BUS_FMT_SGRBG12_1X12;
-       } else if (pad == IPIPEIF_PAD_SOURCE) {
-               for (i = 0; i < ARRAY_SIZE(ipipeif_output_fmts); i++)
-                       if (fmt->code == ipipeif_output_fmts[i])
-                               break;
-
-               /* If not found, use UYVY as default */
-               if (i >= ARRAY_SIZE(ipipeif_output_fmts))
-                       fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
-       }
-
-       fmt->width = clamp_t(u32, fmt->width, MIN_OUT_HEIGHT, max_out_width);
-       fmt->height = clamp_t(u32, fmt->height, MIN_OUT_WIDTH, max_out_height);
-}
-
-static int
-ipipeif_enum_frame_size(struct v4l2_subdev *sd,
-                       struct v4l2_subdev_pad_config *cfg,
-                       struct v4l2_subdev_frame_size_enum *fse)
-{
-       struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
-       struct v4l2_mbus_framefmt format;
-
-       if (fse->index != 0)
-               return -EINVAL;
-
-       format.code = fse->code;
-       format.width = 1;
-       format.height = 1;
-       ipipeif_try_format(ipipeif, cfg, fse->pad, &format, fse->which);
-       fse->min_width = format.width;
-       fse->min_height = format.height;
-
-       if (format.code != fse->code)
-               return -EINVAL;
-
-       format.code = fse->code;
-       format.width = -1;
-       format.height = -1;
-       ipipeif_try_format(ipipeif, cfg, fse->pad, &format, fse->which);
-       fse->max_width = format.width;
-       fse->max_height = format.height;
-
-       return 0;
-}
-
-/*
- * __ipipeif_get_format() - helper function for getting ipipeif format
- * @ipipeif: pointer to ipipeif private structure.
- * @cfg: V4L2 subdev pad config
- * @pad: pad number.
- * @which: wanted subdev format.
- *
- */
-static struct v4l2_mbus_framefmt *
-__ipipeif_get_format(struct vpfe_ipipeif_device *ipipeif,
-                    struct v4l2_subdev_pad_config *cfg, unsigned int pad,
-                    enum v4l2_subdev_format_whence which)
-{
-       if (which == V4L2_SUBDEV_FORMAT_TRY)
-               return v4l2_subdev_get_try_format(&ipipeif->subdev, cfg, pad);
-
-       return &ipipeif->formats[pad];
-}
-
-/*
- * ipipeif_set_format() - Handle set format by pads subdev method
- * @sd: pointer to v4l2 subdev structure
- * @cfg: V4L2 subdev pad config
- * @fmt: pointer to v4l2 subdev format structure
- * return -EINVAL or zero on success
- */
-static int
-ipipeif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
-                  struct v4l2_subdev_format *fmt)
-{
-       struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
-       struct v4l2_mbus_framefmt *format;
-
-       format = __ipipeif_get_format(ipipeif, cfg, fmt->pad, fmt->which);
-       if (!format)
-               return -EINVAL;
-
-       ipipeif_try_format(ipipeif, cfg, fmt->pad, &fmt->format, fmt->which);
-       *format = fmt->format;
-
-       if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
-               return 0;
-
-       if (fmt->pad == IPIPEIF_PAD_SINK &&
-           ipipeif->input != IPIPEIF_INPUT_NONE)
-               ipipeif->formats[fmt->pad] = fmt->format;
-       else if (fmt->pad == IPIPEIF_PAD_SOURCE &&
-                ipipeif->output != IPIPEIF_OUTPUT_NONE)
-               ipipeif->formats[fmt->pad] = fmt->format;
-       else
-               return -EINVAL;
-
-       return 0;
-}
-
-static void ipipeif_set_default_config(struct vpfe_ipipeif_device *ipipeif)
-{
-#define WIDTH_I                        640
-#define HEIGHT_I               480
-
-       const struct ipipeif_params ipipeif_defaults = {
-               .clock_select = IPIPEIF_SDRAM_CLK,
-               .ppln = WIDTH_I + 8,
-               .lpfr = HEIGHT_I + 10,
-               .rsz = 16,      /* resize ratio 16/rsz */
-               .decimation = IPIPEIF_DECIMATION_OFF,
-               .avg_filter = IPIPEIF_AVG_OFF,
-               .if_5_1 = {
-                       .clk_div = {
-                               .m = 1, /* clock = sdram clock * (m/n) */
-                               .n = 6
-                       },
-                       .clip = 4095,
-               },
-       };
-       memcpy(&ipipeif->config, &ipipeif_defaults,
-              sizeof(struct ipipeif_params));
-}
-
-/*
- * ipipeif_init_formats() - Initialize formats on all pads
- * @sd: VPFE ipipeif V4L2 subdevice
- * @fh: V4L2 subdev file handle
- *
- * Initialize all pad formats with default values. Try formats are initialized
- * on the file handle.
- */
-static int
-ipipeif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-{
-       struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
-       struct v4l2_subdev_format format;
-
-       memset(&format, 0, sizeof(format));
-       format.pad = IPIPEIF_PAD_SINK;
-       format.which = V4L2_SUBDEV_FORMAT_TRY;
-       format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
-       format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
-       format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
-       ipipeif_set_format(sd, fh->pad, &format);
-
-       memset(&format, 0, sizeof(format));
-       format.pad = IPIPEIF_PAD_SOURCE;
-       format.which = V4L2_SUBDEV_FORMAT_TRY;
-       format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
-       format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
-       format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
-       ipipeif_set_format(sd, fh->pad, &format);
-
-       ipipeif_set_default_config(ipipeif);
-
-       return 0;
-}
-
-/*
- * ipipeif_video_in_queue() - ipipeif video in queue
- * @vpfe_dev: vpfe device pointer
- * @addr: buffer address
- */
-static int
-ipipeif_video_in_queue(struct vpfe_device *vpfe_dev, unsigned long addr)
-{
-       struct vpfe_ipipeif_device *ipipeif = &vpfe_dev->vpfe_ipipeif;
-       void __iomem *ipipeif_base_addr = ipipeif->ipipeif_base_addr;
-       unsigned int adofs;
-       u32 val;
-
-       if (ipipeif->input != IPIPEIF_INPUT_MEMORY)
-               return -EINVAL;
-
-       switch (ipipeif->formats[IPIPEIF_PAD_SINK].code) {
-       case MEDIA_BUS_FMT_Y8_1X8:
-       case MEDIA_BUS_FMT_UV8_1X8:
-       case MEDIA_BUS_FMT_YDYUYDYV8_1X16:
-               adofs = ipipeif->formats[IPIPEIF_PAD_SINK].width;
-               break;
-
-       default:
-               adofs = ipipeif->formats[IPIPEIF_PAD_SINK].width << 1;
-               break;
-       }
-
-       /* adjust the line len to be a multiple of 32 */
-       adofs += 31;
-       adofs &= ~0x1f;
-       val = (adofs >> 5) & IPIPEIF_ADOFS_LSB_MASK;
-       ipipeif_write(val, ipipeif_base_addr, IPIPEIF_ADOFS);
-
-       /* lower sixteen bit */
-       val = (addr >> IPIPEIF_ADDRL_SHIFT) & IPIPEIF_ADDRL_MASK;
-       ipipeif_write(val, ipipeif_base_addr, IPIPEIF_ADDRL);
-
-       /* upper next seven bit */
-       val = (addr >> IPIPEIF_ADDRU_SHIFT) & IPIPEIF_ADDRU_MASK;
-       ipipeif_write(val, ipipeif_base_addr, IPIPEIF_ADDRU);
-
-       return 0;
-}
-
-/* subdev core operations */
-static const struct v4l2_subdev_core_ops ipipeif_v4l2_core_ops = {
-       .ioctl = ipipeif_ioctl,
-};
-
-static const struct v4l2_ctrl_ops ipipeif_ctrl_ops = {
-       .s_ctrl = ipipeif_s_ctrl,
-};
-
-static const struct v4l2_ctrl_config vpfe_ipipeif_dpcm_pred = {
-       .ops = &ipipeif_ctrl_ops,
-       .id = VPFE_CID_DPCM_PREDICTOR,
-       .name = "DPCM Predictor",
-       .type = V4L2_CTRL_TYPE_INTEGER,
-       .min = 0,
-       .max = 1,
-       .step = 1,
-       .def = 0,
-};
-
-/* subdev file operations */
-static const struct v4l2_subdev_internal_ops ipipeif_v4l2_internal_ops = {
-       .open = ipipeif_init_formats,
-};
-
-/* subdev video operations */
-static const struct v4l2_subdev_video_ops ipipeif_v4l2_video_ops = {
-       .s_stream = ipipeif_set_stream,
-};
-
-/* subdev pad operations */
-static const struct v4l2_subdev_pad_ops ipipeif_v4l2_pad_ops = {
-       .enum_mbus_code = ipipeif_enum_mbus_code,
-       .enum_frame_size = ipipeif_enum_frame_size,
-       .get_fmt = ipipeif_get_format,
-       .set_fmt = ipipeif_set_format,
-};
-
-/* subdev operations */
-static const struct v4l2_subdev_ops ipipeif_v4l2_ops = {
-       .core = &ipipeif_v4l2_core_ops,
-       .video = &ipipeif_v4l2_video_ops,
-       .pad = &ipipeif_v4l2_pad_ops,
-};
-
-static const struct vpfe_video_operations video_in_ops = {
-       .queue = ipipeif_video_in_queue,
-};
-
-static int
-ipipeif_link_setup(struct media_entity *entity, const struct media_pad *local,
-                  const struct media_pad *remote, u32 flags)
-{
-       struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
-       struct vpfe_ipipeif_device *ipipeif = v4l2_get_subdevdata(sd);
-       struct vpfe_device *vpfe = to_vpfe_device(ipipeif);
-       unsigned int index = local->index;
-
-       /* FIXME: this is actually a hack! */
-       if (is_media_entity_v4l2_subdev(remote->entity))
-               index |= 2 << 16;
-
-       switch (index) {
-       case IPIPEIF_PAD_SINK:
-               /* Single shot mode */
-               if (!(flags & MEDIA_LNK_FL_ENABLED)) {
-                       ipipeif->input = IPIPEIF_INPUT_NONE;
-                       break;
-               }
-               ipipeif->input = IPIPEIF_INPUT_MEMORY;
-               break;
-
-       case IPIPEIF_PAD_SINK | 2 << 16:
-               /* read from isif */
-               if (!(flags & MEDIA_LNK_FL_ENABLED)) {
-                       ipipeif->input = IPIPEIF_INPUT_NONE;
-                       break;
-               }
-               if (ipipeif->input != IPIPEIF_INPUT_NONE)
-                       return -EBUSY;
-
-               ipipeif->input = IPIPEIF_INPUT_ISIF;
-               break;
-
-       case IPIPEIF_PAD_SOURCE | 2 << 16:
-               if (!(flags & MEDIA_LNK_FL_ENABLED)) {
-                       ipipeif->output = IPIPEIF_OUTPUT_NONE;
-                       break;
-               }
-               if (remote->entity == &vpfe->vpfe_ipipe.subdev.entity)
-                       /* connencted to ipipe */
-                       ipipeif->output = IPIPEIF_OUTPUT_IPIPE;
-               else if (remote->entity == &vpfe->vpfe_resizer.crop_resizer.subdev.entity)
-                       /* connected to resizer */
-                       ipipeif->output = IPIPEIF_OUTPUT_RESIZER;
-               else
-                       return -EINVAL;
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-static const struct media_entity_operations ipipeif_media_ops = {
-       .link_setup = ipipeif_link_setup,
-};
-
-/*
- * vpfe_ipipeif_unregister_entities() - Unregister entity
- * @ipipeif - pointer to ipipeif subdevice structure.
- */
-void vpfe_ipipeif_unregister_entities(struct vpfe_ipipeif_device *ipipeif)
-{
-       /* unregister video device */
-       vpfe_video_unregister(&ipipeif->video_in);
-
-       /* unregister subdev */
-       v4l2_device_unregister_subdev(&ipipeif->subdev);
-       /* cleanup entity */
-       media_entity_cleanup(&ipipeif->subdev.entity);
-}
-
-int
-vpfe_ipipeif_register_entities(struct vpfe_ipipeif_device *ipipeif,
-                              struct v4l2_device *vdev)
-{
-       struct vpfe_device *vpfe_dev = to_vpfe_device(ipipeif);
-       unsigned int flags;
-       int ret;
-
-       /* Register the subdev */
-       ret = v4l2_device_register_subdev(vdev, &ipipeif->subdev);
-       if (ret < 0)
-               return ret;
-
-       ret = vpfe_video_register(&ipipeif->video_in, vdev);
-       if (ret) {
-               pr_err("Failed to register ipipeif video-in device\n");
-               goto fail;
-       }
-       ipipeif->video_in.vpfe_dev = vpfe_dev;
-
-       flags = 0;
-       ret = media_create_pad_link(&ipipeif->video_in.video_dev.entity, 0,
-                                   &ipipeif->subdev.entity, 0, flags);
-       if (ret < 0)
-               goto fail;
-
-       return 0;
-fail:
-       v4l2_device_unregister_subdev(&ipipeif->subdev);
-
-       return ret;
-}
-
-#define IPIPEIF_GAIN_HIGH              0x3ff
-#define IPIPEIF_DEFAULT_GAIN           0x200
-
-int vpfe_ipipeif_init(struct vpfe_ipipeif_device *ipipeif,
-                     struct platform_device *pdev)
-{
-       struct v4l2_subdev *sd = &ipipeif->subdev;
-       struct media_pad *pads = &ipipeif->pads[0];
-       struct media_entity *me = &sd->entity;
-       static resource_size_t  res_len;
-       struct resource *res;
-       int ret;
-
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
-       if (!res)
-               return -ENOENT;
-
-       res_len = resource_size(res);
-       res = request_mem_region(res->start, res_len, res->name);
-       if (!res)
-               return -EBUSY;
-
-       ipipeif->ipipeif_base_addr = ioremap_nocache(res->start, res_len);
-       if (!ipipeif->ipipeif_base_addr) {
-               ret =  -EBUSY;
-               goto fail;
-       }
-
-       v4l2_subdev_init(sd, &ipipeif_v4l2_ops);
-
-       sd->internal_ops = &ipipeif_v4l2_internal_ops;
-       strscpy(sd->name, "DAVINCI IPIPEIF", sizeof(sd->name));
-       sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
-
-       v4l2_set_subdevdata(sd, ipipeif);
-
-       sd->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE;
-       pads[IPIPEIF_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
-       pads[IPIPEIF_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
-       ipipeif->input = IPIPEIF_INPUT_NONE;
-       ipipeif->output = IPIPEIF_OUTPUT_NONE;
-       me->ops = &ipipeif_media_ops;
-
-       ret = media_entity_pads_init(me, IPIPEIF_NUM_PADS, pads);
-       if (ret)
-               goto fail;
-
-       v4l2_ctrl_handler_init(&ipipeif->ctrls, 2);
-       v4l2_ctrl_new_std(&ipipeif->ctrls, &ipipeif_ctrl_ops,
-                         V4L2_CID_GAIN, 0,
-                         IPIPEIF_GAIN_HIGH, 1, IPIPEIF_DEFAULT_GAIN);
-       v4l2_ctrl_new_custom(&ipipeif->ctrls, &vpfe_ipipeif_dpcm_pred, NULL);
-       v4l2_ctrl_handler_setup(&ipipeif->ctrls);
-       sd->ctrl_handler = &ipipeif->ctrls;
-
-       ipipeif->video_in.ops = &video_in_ops;
-       ipipeif->video_in.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-       ret = vpfe_video_init(&ipipeif->video_in, "IPIPEIF");
-       if (ret) {
-               pr_err("Failed to init IPIPEIF video-in device\n");
-               goto fail;
-       }
-       ipipeif_set_default_config(ipipeif);
-       return 0;
-fail:
-       release_mem_region(res->start, res_len);
-       return ret;
-}
-
-void
-vpfe_ipipeif_cleanup(struct vpfe_ipipeif_device *ipipeif,
-                    struct platform_device *pdev)
-{
-       struct resource *res;
-
-       v4l2_ctrl_handler_free(&ipipeif->ctrls);
-       iounmap(ipipeif->ipipeif_base_addr);
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
-       if (res)
-               release_mem_region(res->start, resource_size(res));
-
-}
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h
deleted file mode 100644 (file)
index 4d126fc..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#ifndef _DAVINCI_VPFE_DM365_IPIPEIF_H
-#define _DAVINCI_VPFE_DM365_IPIPEIF_H
-
-#include <linux/platform_device.h>
-
-#include <media/davinci/vpss.h>
-#include <media/v4l2-ctrls.h>
-#include <media/v4l2-subdev.h>
-
-#include "dm365_ipipeif_user.h"
-#include "vpfe_video.h"
-
-/* IPIPE base specific types */
-enum ipipeif_data_shift {
-       IPIPEIF_BITS15_2 = 0,
-       IPIPEIF_BITS14_1 = 1,
-       IPIPEIF_BITS13_0 = 2,
-       IPIPEIF_BITS12_0 = 3,
-       IPIPEIF_BITS11_0 = 4,
-       IPIPEIF_BITS10_0 = 5,
-       IPIPEIF_BITS9_0 = 6,
-};
-
-enum ipipeif_clkdiv {
-       IPIPEIF_DIVIDE_HALF = 0,
-       IPIPEIF_DIVIDE_THIRD = 1,
-       IPIPEIF_DIVIDE_FOURTH = 2,
-       IPIPEIF_DIVIDE_FIFTH = 3,
-       IPIPEIF_DIVIDE_SIXTH = 4,
-       IPIPEIF_DIVIDE_EIGHTH = 5,
-       IPIPEIF_DIVIDE_SIXTEENTH = 6,
-       IPIPEIF_DIVIDE_THIRTY = 7,
-};
-
-enum ipipeif_pack_mode  {
-       IPIPEIF_PACK_16_BIT = 0,
-       IPIPEIF_PACK_8_BIT = 1,
-};
-
-enum ipipeif_5_1_pack_mode  {
-       IPIPEIF_5_1_PACK_16_BIT = 0,
-       IPIPEIF_5_1_PACK_8_BIT = 1,
-       IPIPEIF_5_1_PACK_8_BIT_A_LAW = 2,
-       IPIPEIF_5_1_PACK_12_BIT = 3
-};
-
-enum  ipipeif_input_source {
-       IPIPEIF_CCDC = 0,
-       IPIPEIF_SDRAM_RAW = 1,
-       IPIPEIF_CCDC_DARKFM = 2,
-       IPIPEIF_SDRAM_YUV = 3,
-};
-
-enum ipipeif_ialaw {
-       IPIPEIF_ALAW_OFF = 0,
-       IPIPEIF_ALAW_ON = 1,
-};
-
-enum  ipipeif_input_src1 {
-       IPIPEIF_SRC1_PARALLEL_PORT = 0,
-       IPIPEIF_SRC1_SDRAM_RAW = 1,
-       IPIPEIF_SRC1_ISIF_DARKFM = 2,
-       IPIPEIF_SRC1_SDRAM_YUV = 3,
-};
-
-enum ipipeif_dfs_dir {
-       IPIPEIF_PORT_MINUS_SDRAM = 0,
-       IPIPEIF_SDRAM_MINUS_PORT = 1,
-};
-
-enum ipipeif_chroma_phase {
-       IPIPEIF_CBCR_Y = 0,
-       IPIPEIF_Y_CBCR = 1,
-};
-
-enum ipipeif_dpcm_type {
-       IPIPEIF_DPCM_8BIT_10BIT = 0,
-       IPIPEIF_DPCM_8BIT_12BIT = 1,
-};
-
-/* data shift for IPIPE 5.1 */
-enum ipipeif_5_1_data_shift {
-       IPIPEIF_5_1_BITS11_0 = 0,
-       IPIPEIF_5_1_BITS10_0 = 1,
-       IPIPEIF_5_1_BITS9_0 = 2,
-       IPIPEIF_5_1_BITS8_0 = 3,
-       IPIPEIF_5_1_BITS7_0 = 4,
-       IPIPEIF_5_1_BITS15_4 = 5,
-};
-
-#define IPIPEIF_PAD_SINK      0
-#define IPIPEIF_PAD_SOURCE    1
-
-#define IPIPEIF_NUM_PADS       2
-
-enum ipipeif_input_entity {
-       IPIPEIF_INPUT_NONE = 0,
-       IPIPEIF_INPUT_ISIF = 1,
-       IPIPEIF_INPUT_MEMORY = 2,
-};
-
-enum ipipeif_output_entity {
-       IPIPEIF_OUTPUT_NONE = 0,
-       IPIPEIF_OUTPUT_IPIPE = 1,
-       IPIPEIF_OUTPUT_RESIZER = 2,
-};
-
-struct vpfe_ipipeif_device {
-       struct v4l2_subdev subdev;
-       struct media_pad pads[IPIPEIF_NUM_PADS];
-       struct v4l2_mbus_framefmt formats[IPIPEIF_NUM_PADS];
-       enum ipipeif_input_entity input;
-       unsigned int output;
-       struct vpfe_video_device video_in;
-       struct v4l2_ctrl_handler ctrls;
-       void __iomem *ipipeif_base_addr;
-       struct ipipeif_params config;
-       int dpcm_predictor;
-       int gain;
-};
-
-/* IPIPEIF Register Offsets from the base address */
-#define IPIPEIF_ENABLE                 0x00
-#define IPIPEIF_CFG1                   0x04
-#define IPIPEIF_PPLN                   0x08
-#define IPIPEIF_LPFR                   0x0c
-#define IPIPEIF_HNUM                   0x10
-#define IPIPEIF_VNUM                   0x14
-#define IPIPEIF_ADDRU                  0x18
-#define IPIPEIF_ADDRL                  0x1c
-#define IPIPEIF_ADOFS                  0x20
-#define IPIPEIF_RSZ                    0x24
-#define IPIPEIF_GAIN                   0x28
-
-/* Below registers are available only on IPIPE 5.1 */
-#define IPIPEIF_DPCM                   0x2c
-#define IPIPEIF_CFG2                   0x30
-#define IPIPEIF_INIRSZ                 0x34
-#define IPIPEIF_OCLIP                  0x38
-#define IPIPEIF_DTUDF                  0x3c
-#define IPIPEIF_CLKDIV                 0x40
-#define IPIPEIF_DPC1                   0x44
-#define IPIPEIF_DPC2                   0x48
-#define IPIPEIF_DFSGVL                 0x4c
-#define IPIPEIF_DFSGTH                 0x50
-#define IPIPEIF_RSZ3A                  0x54
-#define IPIPEIF_INIRSZ3A               0x58
-#define IPIPEIF_RSZ_MIN                        16
-#define IPIPEIF_RSZ_MAX                        112
-#define IPIPEIF_RSZ_CONST              16
-
-#define IPIPEIF_ADOFS_LSB_MASK         0x1ff
-#define IPIPEIF_ADOFS_LSB_SHIFT                5
-#define IPIPEIF_ADOFS_MSB_MASK         0x200
-#define IPIPEIF_ADDRU_MASK             0x7ff
-#define IPIPEIF_ADDRL_SHIFT            5
-#define IPIPEIF_ADDRL_MASK             0xffff
-#define IPIPEIF_ADDRU_SHIFT            21
-#define IPIPEIF_ADDRMSB_SHIFT          31
-#define IPIPEIF_ADDRMSB_LEFT_SHIFT     10
-
-/* CFG1 Masks and shifts */
-#define ONESHOT_SHIFT                  0
-#define DECIM_SHIFT                    1
-#define INPSRC_SHIFT                   2
-#define CLKDIV_SHIFT                   4
-#define AVGFILT_SHIFT                  7
-#define PACK8IN_SHIFT                  8
-#define IALAW_SHIFT                    9
-#define CLKSEL_SHIFT                   10
-#define DATASFT_SHIFT                  11
-#define INPSRC1_SHIFT                  14
-
-/* DPC2 */
-#define IPIPEIF_DPC2_EN_SHIFT          12
-#define IPIPEIF_DPC2_THR_MASK          0xfff
-/* Applicable for IPIPE 5.1 */
-#define IPIPEIF_DF_GAIN_EN_SHIFT       10
-#define IPIPEIF_DF_GAIN_MASK           0x3ff
-#define IPIPEIF_DF_GAIN_THR_MASK       0xfff
-/* DPCM */
-#define IPIPEIF_DPCM_BITS_SHIFT                2
-#define IPIPEIF_DPCM_PRED_SHIFT                1
-/* CFG2 */
-#define IPIPEIF_CFG2_HDPOL_SHIFT       1
-#define IPIPEIF_CFG2_VDPOL_SHIFT       2
-#define IPIPEIF_CFG2_YUV8_SHIFT                6
-#define IPIPEIF_CFG2_YUV16_SHIFT       3
-#define IPIPEIF_CFG2_YUV8P_SHIFT       7
-
-/* INIRSZ */
-#define IPIPEIF_INIRSZ_ALNSYNC_SHIFT   13
-#define IPIPEIF_INIRSZ_MASK            0x1fff
-
-/* CLKDIV */
-#define IPIPEIF_CLKDIV_M_SHIFT         8
-
-void vpfe_ipipeif_enable(struct vpfe_device *vpfe_dev);
-void vpfe_ipipeif_ss_buffer_isr(struct vpfe_ipipeif_device *ipipeif);
-int vpfe_ipipeif_decimation_enabled(struct vpfe_device *vpfe_dev);
-int vpfe_ipipeif_get_rsz(struct vpfe_device *vpfe_dev);
-void vpfe_ipipeif_cleanup(struct vpfe_ipipeif_device *ipipeif,
-                         struct platform_device *pdev);
-int vpfe_ipipeif_init(struct vpfe_ipipeif_device *ipipeif,
-                     struct platform_device *pdev);
-int vpfe_ipipeif_register_entities(struct vpfe_ipipeif_device *ipipeif,
-                                  struct v4l2_device *vdev);
-void vpfe_ipipeif_unregister_entities(struct vpfe_ipipeif_device *ipipeif);
-
-#endif         /* _DAVINCI_VPFE_DM365_IPIPEIF_H */
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif_user.h b/drivers/staging/media/davinci_vpfe/dm365_ipipeif_user.h
deleted file mode 100644 (file)
index 046dbde..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#ifndef _DAVINCI_VPFE_DM365_IPIPEIF_USER_H
-#define _DAVINCI_VPFE_DM365_IPIPEIF_USER_H
-
-/* clockdiv for IPIPE 5.1 */
-struct ipipeif_5_1_clkdiv {
-       unsigned char m;
-       unsigned char n;
-};
-
-enum ipipeif_decimation {
-       IPIPEIF_DECIMATION_OFF,
-       IPIPEIF_DECIMATION_ON
-};
-
-/* DPC at the if for IPIPE 5.1 */
-struct ipipeif_dpc {
-       /* 0 - disable, 1 - enable */
-       unsigned char en;
-       /* threshold */
-       unsigned short thr;
-};
-
-enum ipipeif_clock {
-       IPIPEIF_PIXCEL_CLK,
-       IPIPEIF_SDRAM_CLK
-};
-
-enum  ipipeif_avg_filter {
-       IPIPEIF_AVG_OFF,
-       IPIPEIF_AVG_ON
-};
-
-struct ipipeif_5_1 {
-       struct ipipeif_5_1_clkdiv clk_div;
-       /* Defect pixel correction */
-       struct ipipeif_dpc dpc;
-       /* clipped to this value */
-       unsigned short clip;
-       /* Align HSync and VSync to rsz_start */
-       unsigned char align_sync;
-       /* resizer start position */
-       unsigned int rsz_start;
-       /* DF gain enable */
-       unsigned char df_gain_en;
-       /* DF gain value */
-       unsigned short df_gain;
-       /* DF gain threshold value */
-       unsigned short df_gain_thr;
-};
-
-struct ipipeif_params {
-       enum ipipeif_clock clock_select;
-       unsigned int ppln;
-       unsigned int lpfr;
-       unsigned char rsz;
-       enum ipipeif_decimation decimation;
-       enum ipipeif_avg_filter avg_filter;
-       /* IPIPE 5.1 */
-       struct ipipeif_5_1 if_5_1;
-};
-
-/*
- * Private IOCTL
- * VIDIOC_VPFE_IPIPEIF_S_CONFIG: Set IPIEIF configuration
- * VIDIOC_VPFE_IPIPEIF_G_CONFIG: Get IPIEIF configuration
- */
-#define VIDIOC_VPFE_IPIPEIF_S_CONFIG \
-       _IOWR('I', BASE_VIDIOC_PRIVATE + 1, struct ipipeif_params)
-#define VIDIOC_VPFE_IPIPEIF_G_CONFIG \
-       _IOWR('I', BASE_VIDIOC_PRIVATE + 2, struct ipipeif_params)
-
-#endif         /* _DAVINCI_VPFE_DM365_IPIPEIF_USER_H */
diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c
deleted file mode 100644 (file)
index 05a997f..0000000
+++ /dev/null
@@ -1,2097 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#include <linux/delay.h>
-#include "dm365_isif.h"
-#include "vpfe_mc_capture.h"
-
-#define MAX_WIDTH      4096
-#define MAX_HEIGHT     4096
-
-static const unsigned int isif_fmts[] = {
-       MEDIA_BUS_FMT_YUYV8_2X8,
-       MEDIA_BUS_FMT_UYVY8_2X8,
-       MEDIA_BUS_FMT_YUYV8_1X16,
-       MEDIA_BUS_FMT_YUYV10_1X20,
-       MEDIA_BUS_FMT_SGRBG12_1X12,
-       MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8,
-       MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
-};
-
-#define ISIF_COLPTN_R_Ye       0x0
-#define ISIF_COLPTN_Gr_Cy      0x1
-#define ISIF_COLPTN_Gb_G       0x2
-#define ISIF_COLPTN_B_Mg       0x3
-
-#define ISIF_CCOLP_CP01_0      0
-#define ISIF_CCOLP_CP03_2      2
-#define ISIF_CCOLP_CP05_4      4
-#define ISIF_CCOLP_CP07_6      6
-#define ISIF_CCOLP_CP11_0      8
-#define ISIF_CCOLP_CP13_2      10
-#define ISIF_CCOLP_CP15_4      12
-#define ISIF_CCOLP_CP17_6      14
-
-static const u32 isif_sgrbg_pattern =
-       ISIF_COLPTN_Gr_Cy <<  ISIF_CCOLP_CP01_0 |
-       ISIF_COLPTN_R_Ye  << ISIF_CCOLP_CP03_2 |
-       ISIF_COLPTN_B_Mg  << ISIF_CCOLP_CP05_4 |
-       ISIF_COLPTN_Gb_G  << ISIF_CCOLP_CP07_6 |
-       ISIF_COLPTN_Gr_Cy << ISIF_CCOLP_CP11_0 |
-       ISIF_COLPTN_R_Ye  << ISIF_CCOLP_CP13_2 |
-       ISIF_COLPTN_B_Mg  << ISIF_CCOLP_CP15_4 |
-       ISIF_COLPTN_Gb_G  << ISIF_CCOLP_CP17_6;
-
-static const u32 isif_srggb_pattern =
-       ISIF_COLPTN_R_Ye  << ISIF_CCOLP_CP01_0 |
-       ISIF_COLPTN_Gr_Cy << ISIF_CCOLP_CP03_2 |
-       ISIF_COLPTN_Gb_G  << ISIF_CCOLP_CP05_4 |
-       ISIF_COLPTN_B_Mg  << ISIF_CCOLP_CP07_6 |
-       ISIF_COLPTN_R_Ye  << ISIF_CCOLP_CP11_0 |
-       ISIF_COLPTN_Gr_Cy << ISIF_CCOLP_CP13_2 |
-       ISIF_COLPTN_Gb_G  << ISIF_CCOLP_CP15_4 |
-       ISIF_COLPTN_B_Mg  << ISIF_CCOLP_CP17_6;
-
-static inline u32 isif_read(void __iomem *base_addr, u32 offset)
-{
-       return readl(base_addr + offset);
-}
-
-static inline void isif_write(void __iomem *base_addr, u32 val, u32 offset)
-{
-       writel(val, base_addr + offset);
-}
-
-static inline u32 isif_merge(void __iomem *base_addr, u32 mask, u32 val,
-                            u32 offset)
-{
-       u32 new_val = (isif_read(base_addr, offset) & ~mask) | (val & mask);
-
-       isif_write(base_addr, new_val, offset);
-
-       return new_val;
-}
-
-static void isif_enable_output_to_sdram(struct vpfe_isif_device *isif, int en)
-{
-       isif_merge(isif->isif_cfg.base_addr, ISIF_SYNCEN_WEN_MASK,
-                  en << ISIF_SYNCEN_WEN_SHIFT, SYNCEN);
-}
-
-static inline void
-isif_regw_lin_tbl(struct vpfe_isif_device *isif, u32 val, u32 offset, int i)
-{
-       if (!i)
-               writel(val, isif->isif_cfg.linear_tbl0_addr + offset);
-       else
-               writel(val, isif->isif_cfg.linear_tbl1_addr + offset);
-}
-
-static void isif_disable_all_modules(struct vpfe_isif_device *isif)
-{
-       /* disable BC */
-       isif_write(isif->isif_cfg.base_addr, 0, CLAMPCFG);
-       /* disable vdfc */
-       isif_write(isif->isif_cfg.base_addr, 0, DFCCTL);
-       /* disable CSC */
-       isif_write(isif->isif_cfg.base_addr, 0, CSCCTL);
-       /* disable linearization */
-       isif_write(isif->isif_cfg.base_addr, 0, LINCFG0);
-}
-
-static void isif_enable(struct vpfe_isif_device *isif, int en)
-{
-       if (!en)
-               /* Before disable isif, disable all ISIF modules */
-               isif_disable_all_modules(isif);
-
-       /*
-        * wait for next VD. Assume lowest scan rate is 12 Hz. So
-        * 100 msec delay is good enough
-        */
-       msleep(100);
-       isif_merge(isif->isif_cfg.base_addr, ISIF_SYNCEN_VDHDEN_MASK,
-                  en, SYNCEN);
-}
-
-/*
- * ISIF helper functions
- */
-
-#define DM365_ISIF_MDFS_OFFSET         15
-#define DM365_ISIF_MDFS_MASK           0x1
-
-/* get field id in isif hardware */
-enum v4l2_field vpfe_isif_get_fid(struct vpfe_device *vpfe_dev)
-{
-       struct vpfe_isif_device *isif = &vpfe_dev->vpfe_isif;
-       u32 field_status;
-
-       field_status = isif_read(isif->isif_cfg.base_addr, MODESET);
-       return (field_status >> DM365_ISIF_MDFS_OFFSET) &
-               DM365_ISIF_MDFS_MASK;
-}
-
-static int
-isif_set_pixel_format(struct vpfe_isif_device *isif, unsigned int pixfmt)
-{
-       if (isif->formats[ISIF_PAD_SINK].code == MEDIA_BUS_FMT_SGRBG12_1X12) {
-               if (pixfmt == V4L2_PIX_FMT_SBGGR16)
-                       isif->isif_cfg.data_pack = ISIF_PACK_16BIT;
-               else if ((pixfmt == V4L2_PIX_FMT_SGRBG10DPCM8) ||
-                               (pixfmt == V4L2_PIX_FMT_SGRBG10ALAW8))
-                       isif->isif_cfg.data_pack = ISIF_PACK_8BIT;
-               else
-                       return -EINVAL;
-
-               isif->isif_cfg.bayer.pix_fmt = ISIF_PIXFMT_RAW;
-               isif->isif_cfg.bayer.v4l2_pix_fmt = pixfmt;
-       } else {
-               if (pixfmt == V4L2_PIX_FMT_YUYV)
-                       isif->isif_cfg.ycbcr.pix_order = ISIF_PIXORDER_YCBYCR;
-               else if (pixfmt == V4L2_PIX_FMT_UYVY)
-                       isif->isif_cfg.ycbcr.pix_order = ISIF_PIXORDER_CBYCRY;
-               else
-                       return -EINVAL;
-
-               isif->isif_cfg.data_pack = ISIF_PACK_8BIT;
-               isif->isif_cfg.ycbcr.v4l2_pix_fmt = pixfmt;
-       }
-
-       return 0;
-}
-
-static int
-isif_set_frame_format(struct vpfe_isif_device *isif,
-                     enum isif_frmfmt frm_fmt)
-{
-       if (isif->formats[ISIF_PAD_SINK].code == MEDIA_BUS_FMT_SGRBG12_1X12)
-               isif->isif_cfg.bayer.frm_fmt = frm_fmt;
-       else
-               isif->isif_cfg.ycbcr.frm_fmt = frm_fmt;
-
-       return 0;
-}
-
-static int isif_set_image_window(struct vpfe_isif_device *isif)
-{
-       struct v4l2_rect *win = &isif->crop;
-
-       if (isif->formats[ISIF_PAD_SINK].code == MEDIA_BUS_FMT_SGRBG12_1X12) {
-               isif->isif_cfg.bayer.win.top = win->top;
-               isif->isif_cfg.bayer.win.left = win->left;
-               isif->isif_cfg.bayer.win.width = win->width;
-               isif->isif_cfg.bayer.win.height = win->height;
-               return 0;
-       }
-       isif->isif_cfg.ycbcr.win.top = win->top;
-       isif->isif_cfg.ycbcr.win.left = win->left;
-       isif->isif_cfg.ycbcr.win.width = win->width;
-       isif->isif_cfg.ycbcr.win.height = win->height;
-
-       return 0;
-}
-
-static int
-isif_set_buftype(struct vpfe_isif_device *isif, enum isif_buftype buf_type)
-{
-       if (isif->formats[ISIF_PAD_SINK].code == MEDIA_BUS_FMT_SGRBG12_1X12)
-               isif->isif_cfg.bayer.buf_type = buf_type;
-       else
-               isif->isif_cfg.ycbcr.buf_type = buf_type;
-
-       return 0;
-}
-
-/* configure format in isif hardware */
-static int
-isif_config_format(struct vpfe_device *vpfe_dev, unsigned int pad)
-{
-       struct vpfe_isif_device *vpfe_isif = &vpfe_dev->vpfe_isif;
-       enum isif_frmfmt frm_fmt = ISIF_FRMFMT_INTERLACED;
-       struct v4l2_pix_format format;
-       int ret = 0;
-
-       v4l2_fill_pix_format(&format, &vpfe_dev->vpfe_isif.formats[pad]);
-       mbus_to_pix(&vpfe_dev->vpfe_isif.formats[pad], &format);
-
-       if (isif_set_pixel_format(vpfe_isif, format.pixelformat) < 0) {
-               v4l2_err(&vpfe_dev->v4l2_dev,
-                        "Failed to set pixel format in isif\n");
-               return -EINVAL;
-       }
-
-       /* call for s_crop will override these values */
-       vpfe_isif->crop.left = 0;
-       vpfe_isif->crop.top = 0;
-       vpfe_isif->crop.width = format.width;
-       vpfe_isif->crop.height = format.height;
-
-       /* configure the image window */
-       isif_set_image_window(vpfe_isif);
-
-       switch (vpfe_dev->vpfe_isif.formats[pad].field) {
-       case V4L2_FIELD_INTERLACED:
-               /* do nothing, since it is default */
-               ret = isif_set_buftype(vpfe_isif, ISIF_BUFTYPE_FLD_INTERLEAVED);
-               break;
-
-       case V4L2_FIELD_NONE:
-               frm_fmt = ISIF_FRMFMT_PROGRESSIVE;
-               /* buffer type only applicable for interlaced scan */
-               break;
-
-       case V4L2_FIELD_SEQ_TB:
-               ret = isif_set_buftype(vpfe_isif, ISIF_BUFTYPE_FLD_SEPARATED);
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       /* set the frame format */
-       if (!ret)
-               ret = isif_set_frame_format(vpfe_isif, frm_fmt);
-
-       return ret;
-}
-
-/*
- * isif_try_format() - Try video format on a pad
- * @isif: VPFE isif device
- * @cfg: V4L2 subdev pad config
- * @fmt: pointer to v4l2 subdev format structure
- */
-static void
-isif_try_format(struct vpfe_isif_device *isif,
-               struct v4l2_subdev_pad_config *cfg,
-               struct v4l2_subdev_format *fmt)
-{
-       unsigned int width = fmt->format.width;
-       unsigned int height = fmt->format.height;
-       unsigned int i;
-
-       for (i = 0; i < ARRAY_SIZE(isif_fmts); i++) {
-               if (fmt->format.code == isif_fmts[i])
-                       break;
-       }
-
-       /* If not found, use YUYV8_2x8 as default */
-       if (i >= ARRAY_SIZE(isif_fmts))
-               fmt->format.code = MEDIA_BUS_FMT_YUYV8_2X8;
-
-       /* Clamp the size. */
-       fmt->format.width = clamp_t(u32, width, 32, MAX_WIDTH);
-       fmt->format.height = clamp_t(u32, height, 32, MAX_HEIGHT);
-
-       /* The data formatter truncates the number of horizontal output
-        * pixels to a multiple of 16. To avoid clipping data, allow
-        * callers to request an output size bigger than the input size
-        * up to the nearest multiple of 16.
-        */
-       if (fmt->pad == ISIF_PAD_SOURCE)
-               fmt->format.width &= ~15;
-}
-
-/*
- * vpfe_isif_buffer_isr() - isif module non-progressive buffer scheduling isr
- * @isif: Pointer to isif subdevice.
- */
-void vpfe_isif_buffer_isr(struct vpfe_isif_device *isif)
-{
-       struct vpfe_device *vpfe_dev = to_vpfe_device(isif);
-       struct vpfe_video_device *video = &isif->video_out;
-       enum v4l2_field field;
-       int fid;
-
-       if (!video->started)
-               return;
-
-       field = video->fmt.fmt.pix.field;
-
-       if (field == V4L2_FIELD_NONE) {
-               /* handle progressive frame capture */
-               if (video->cur_frm != video->next_frm)
-                       vpfe_video_process_buffer_complete(video);
-               return;
-       }
-
-       /* interlaced or TB capture check which field we
-        * are in hardware
-        */
-       fid = vpfe_isif_get_fid(vpfe_dev);
-
-       /* switch the software maintained field id */
-       video->field_id ^= 1;
-       if (fid == video->field_id) {
-               /* we are in-sync here,continue */
-               if (fid == 0) {
-                       /*
-                        * One frame is just being captured. If the
-                        * next frame is available, release the current
-                        * frame and move on
-                        */
-                       if (video->cur_frm != video->next_frm)
-                               vpfe_video_process_buffer_complete(video);
-                       /*
-                        * based on whether the two fields are stored
-                        * interleavely or separately in memory,
-                        * reconfigure the ISIF memory address
-                        */
-                       if (field == V4L2_FIELD_SEQ_TB)
-                               vpfe_video_schedule_bottom_field(video);
-                       return;
-               }
-               /*
-                * if one field is just being captured configure
-                * the next frame get the next frame from the
-                * empty queue if no frame is available hold on
-                * to the current buffer
-                */
-               spin_lock(&video->dma_queue_lock);
-               if (!list_empty(&video->dma_queue) &&
-               video->cur_frm == video->next_frm)
-                       vpfe_video_schedule_next_buffer(video);
-               spin_unlock(&video->dma_queue_lock);
-       } else if (fid == 0) {
-               /*
-                * out of sync. Recover from any hardware out-of-sync.
-                * May loose one frame
-                */
-               video->field_id = fid;
-       }
-}
-
-/*
- * vpfe_isif_vidint1_isr() - ISIF module progressive buffer scheduling isr
- * @isif: Pointer to isif subdevice.
- */
-void vpfe_isif_vidint1_isr(struct vpfe_isif_device *isif)
-{
-       struct vpfe_video_device *video = &isif->video_out;
-
-       if (!video->started)
-               return;
-
-       spin_lock(&video->dma_queue_lock);
-       if (video->fmt.fmt.pix.field == V4L2_FIELD_NONE &&
-           !list_empty(&video->dma_queue) && video->cur_frm == video->next_frm)
-               vpfe_video_schedule_next_buffer(video);
-
-       spin_unlock(&video->dma_queue_lock);
-}
-
-/*
- * VPFE video operations
- */
-
-static int isif_video_queue(struct vpfe_device *vpfe_dev, unsigned long addr)
-{
-       struct vpfe_isif_device *isif = &vpfe_dev->vpfe_isif;
-
-       isif_write(isif->isif_cfg.base_addr, (addr >> 21) &
-               ISIF_CADU_BITS, CADU);
-       isif_write(isif->isif_cfg.base_addr, (addr >> 5) &
-               ISIF_CADL_BITS, CADL);
-
-       return 0;
-}
-
-static const struct vpfe_video_operations isif_video_ops = {
-       .queue = isif_video_queue,
-};
-
-/*
- * V4L2 subdev operations
- */
-
-/* Parameter operations */
-static int isif_get_params(struct v4l2_subdev *sd, void *params)
-{
-       struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd);
-
-       /* only raw module parameters can be set through the IOCTL */
-       if (isif->formats[ISIF_PAD_SINK].code != MEDIA_BUS_FMT_SGRBG12_1X12)
-               return -EINVAL;
-       memcpy(params, &isif->isif_cfg.bayer.config_params,
-                       sizeof(isif->isif_cfg.bayer.config_params));
-       return 0;
-}
-
-static int isif_validate_df_csc_params(const struct vpfe_isif_df_csc *df_csc)
-{
-       const struct vpfe_isif_color_space_conv *csc;
-       int err = -EINVAL;
-       int i;
-
-       if (!df_csc->df_or_csc) {
-               /* csc configuration */
-               csc = &df_csc->csc;
-               if (csc->en) {
-                       for (i = 0; i < VPFE_ISIF_CSC_NUM_COEFF; i++)
-                               if (csc->coeff[i].integer >
-                                   ISIF_CSC_COEF_INTEG_MASK ||
-                                   csc->coeff[i].decimal >
-                                   ISIF_CSC_COEF_DECIMAL_MASK) {
-                                       pr_err("Invalid CSC coefficients\n");
-                                       return err;
-                               }
-               }
-       }
-       if (df_csc->start_pix > ISIF_DF_CSC_SPH_MASK) {
-               pr_err("Invalid df_csc start pix value\n");
-               return err;
-       }
-
-       if (df_csc->num_pixels > ISIF_DF_NUMPIX) {
-               pr_err("Invalid df_csc num pixels value\n");
-               return err;
-       }
-
-       if (df_csc->start_line > ISIF_DF_CSC_LNH_MASK) {
-               pr_err("Invalid df_csc start_line value\n");
-               return err;
-       }
-
-       if (df_csc->num_lines > ISIF_DF_NUMLINES) {
-               pr_err("Invalid df_csc num_lines value\n");
-               return err;
-       }
-
-       return 0;
-}
-
-#define DM365_ISIF_MAX_VDFLSFT         4
-#define DM365_ISIF_MAX_VDFSLV          4095
-#define DM365_ISIF_MAX_DFCMEM0         0x1fff
-#define DM365_ISIF_MAX_DFCMEM1         0x1fff
-
-static int isif_validate_dfc_params(const struct vpfe_isif_dfc *dfc)
-{
-       int err = -EINVAL;
-       int i;
-
-       if (!dfc->en)
-               return 0;
-
-       if (dfc->corr_whole_line > 1) {
-               pr_err("Invalid corr_whole_line value\n");
-               return err;
-       }
-
-       if (dfc->def_level_shift > DM365_ISIF_MAX_VDFLSFT) {
-               pr_err("Invalid def_level_shift value\n");
-               return err;
-       }
-
-       if (dfc->def_sat_level > DM365_ISIF_MAX_VDFSLV) {
-               pr_err("Invalid def_sat_level value\n");
-               return err;
-       }
-
-       if (!dfc->num_vdefects ||
-           dfc->num_vdefects > VPFE_ISIF_VDFC_TABLE_SIZE) {
-               pr_err("Invalid num_vdefects value\n");
-               return err;
-       }
-
-       for (i = 0; i < VPFE_ISIF_VDFC_TABLE_SIZE; i++) {
-               if (dfc->table[i].pos_vert > DM365_ISIF_MAX_DFCMEM0) {
-                       pr_err("Invalid pos_vert value\n");
-                       return err;
-               }
-               if (dfc->table[i].pos_horz > DM365_ISIF_MAX_DFCMEM1) {
-                       pr_err("Invalid pos_horz value\n");
-                       return err;
-               }
-       }
-
-       return 0;
-}
-
-#define DM365_ISIF_MAX_CLVRV                   0xfff
-#define DM365_ISIF_MAX_CLDC                    0x1fff
-#define DM365_ISIF_MAX_CLHSH                   0x1fff
-#define DM365_ISIF_MAX_CLHSV                   0x1fff
-#define DM365_ISIF_MAX_CLVSH                   0x1fff
-#define DM365_ISIF_MAX_CLVSV                   0x1fff
-#define DM365_ISIF_MAX_HEIGHT_BLACK_REGION     0x1fff
-
-static int isif_validate_bclamp_params(const struct vpfe_isif_black_clamp *bclamp)
-{
-       int err = -EINVAL;
-
-       if (bclamp->dc_offset > DM365_ISIF_MAX_CLDC) {
-               pr_err("Invalid bclamp dc_offset value\n");
-               return err;
-       }
-       if (!bclamp->en)
-               return 0;
-       if (bclamp->horz.clamp_pix_limit > 1) {
-               pr_err("Invalid bclamp horz clamp_pix_limit value\n");
-               return err;
-       }
-       if (bclamp->horz.win_count_calc < 1 ||
-                       bclamp->horz.win_count_calc > 32) {
-               pr_err("Invalid bclamp horz win_count_calc value\n");
-               return err;
-       }
-       if (bclamp->horz.win_start_h_calc > DM365_ISIF_MAX_CLHSH) {
-               pr_err("Invalid bclamp win_start_v_calc value\n");
-               return err;
-       }
-
-       if (bclamp->horz.win_start_v_calc > DM365_ISIF_MAX_CLHSV) {
-               pr_err("Invalid bclamp win_start_v_calc value\n");
-               return err;
-       }
-       if (bclamp->vert.reset_clamp_val > DM365_ISIF_MAX_CLVRV) {
-               pr_err("Invalid bclamp reset_clamp_val value\n");
-               return err;
-       }
-       if (bclamp->vert.ob_v_sz_calc > DM365_ISIF_MAX_HEIGHT_BLACK_REGION) {
-               pr_err("Invalid bclamp ob_v_sz_calc value\n");
-               return err;
-       }
-       if (bclamp->vert.ob_start_h > DM365_ISIF_MAX_CLVSH) {
-               pr_err("Invalid bclamp ob_start_h value\n");
-               return err;
-       }
-       if (bclamp->vert.ob_start_v > DM365_ISIF_MAX_CLVSV) {
-               pr_err("Invalid bclamp ob_start_h value\n");
-               return err;
-       }
-       return 0;
-}
-
-static int
-isif_validate_raw_params(const struct vpfe_isif_raw_config *params)
-{
-       int ret;
-
-       ret = isif_validate_df_csc_params(&params->df_csc);
-       if (ret)
-               return ret;
-       ret = isif_validate_dfc_params(&params->dfc);
-       if (ret)
-               return ret;
-       return isif_validate_bclamp_params(&params->bclamp);
-}
-
-static int isif_set_params(struct v4l2_subdev *sd, const struct vpfe_isif_raw_config *params)
-{
-       struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd);
-       int ret = -EINVAL;
-
-       /* only raw module parameters can be set through the IOCTL */
-       if (isif->formats[ISIF_PAD_SINK].code != MEDIA_BUS_FMT_SGRBG12_1X12)
-               return ret;
-
-       if (!isif_validate_raw_params(params)) {
-               memcpy(&isif->isif_cfg.bayer.config_params, params,
-                       sizeof(*params));
-               ret = 0;
-       }
-       return ret;
-}
-/*
- * isif_ioctl() - isif module private ioctl's
- * @sd: VPFE isif V4L2 subdevice
- * @cmd: ioctl command
- * @arg: ioctl argument
- *
- * Return 0 on success or a negative error code otherwise.
- */
-static long isif_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
-{
-       switch (cmd) {
-       case VIDIOC_VPFE_ISIF_S_RAW_PARAMS:
-               return isif_set_params(sd, arg);
-
-       case VIDIOC_VPFE_ISIF_G_RAW_PARAMS:
-               return isif_get_params(sd, arg);
-
-       default:
-               return -ENOIOCTLCMD;
-       }
-}
-
-static void isif_config_gain_offset(struct vpfe_isif_device *isif)
-{
-       struct vpfe_isif_gain_offsets_adj *gain_off_ptr =
-               &isif->isif_cfg.bayer.config_params.gain_offset;
-       void __iomem *base = isif->isif_cfg.base_addr;
-       u32 val;
-
-       val = ((gain_off_ptr->gain_sdram_en & 1) << GAIN_SDRAM_EN_SHIFT) |
-             ((gain_off_ptr->gain_ipipe_en & 1) << GAIN_IPIPE_EN_SHIFT) |
-             ((gain_off_ptr->gain_h3a_en & 1) << GAIN_H3A_EN_SHIFT) |
-             ((gain_off_ptr->offset_sdram_en & 1) << OFST_SDRAM_EN_SHIFT) |
-             ((gain_off_ptr->offset_ipipe_en & 1) << OFST_IPIPE_EN_SHIFT) |
-             ((gain_off_ptr->offset_h3a_en & 1) << OFST_H3A_EN_SHIFT);
-       isif_merge(base, GAIN_OFFSET_EN_MASK, val, CGAMMAWD);
-
-       isif_write(base, isif->isif_cfg.isif_gain_params.cr_gain, CRGAIN);
-       isif_write(base, isif->isif_cfg.isif_gain_params.cgr_gain, CGRGAIN);
-       isif_write(base, isif->isif_cfg.isif_gain_params.cgb_gain, CGBGAIN);
-       isif_write(base, isif->isif_cfg.isif_gain_params.cb_gain, CBGAIN);
-       isif_write(base, isif->isif_cfg.isif_gain_params.offset & OFFSET_MASK,
-                  COFSTA);
-
-}
-
-static void isif_config_bclamp(struct vpfe_isif_device *isif,
-                  struct vpfe_isif_black_clamp *bc)
-{
-       u32 val;
-
-       /**
-        * DC Offset is always added to image data irrespective of bc enable
-        * status
-        */
-       val = bc->dc_offset & ISIF_BC_DCOFFSET_MASK;
-       isif_write(isif->isif_cfg.base_addr, val, CLDCOFST);
-
-       if (!bc->en)
-               return;
-
-       val = (bc->bc_mode_color & ISIF_BC_MODE_COLOR_MASK) <<
-               ISIF_BC_MODE_COLOR_SHIFT;
-
-       /* Enable BC and horizontal clamp calculation parameters */
-       val = val | 1 | ((bc->horz.mode & ISIF_HORZ_BC_MODE_MASK) <<
-             ISIF_HORZ_BC_MODE_SHIFT);
-
-       isif_write(isif->isif_cfg.base_addr, val, CLAMPCFG);
-
-       if (bc->horz.mode != VPFE_ISIF_HORZ_BC_DISABLE) {
-               /*
-                * Window count for calculation
-                * Base window selection
-                * pixel limit
-                * Horizontal size of window
-                * vertical size of the window
-                * Horizontal start position of the window
-                * Vertical start position of the window
-                */
-               val = (bc->horz.win_count_calc & ISIF_HORZ_BC_WIN_COUNT_MASK) |
-                     ((bc->horz.base_win_sel_calc & 1) <<
-                     ISIF_HORZ_BC_WIN_SEL_SHIFT) |
-                     ((bc->horz.clamp_pix_limit & 1) <<
-                     ISIF_HORZ_BC_PIX_LIMIT_SHIFT) |
-                     ((bc->horz.win_h_sz_calc &
-                     ISIF_HORZ_BC_WIN_H_SIZE_MASK) <<
-                     ISIF_HORZ_BC_WIN_H_SIZE_SHIFT) |
-                     ((bc->horz.win_v_sz_calc &
-                     ISIF_HORZ_BC_WIN_V_SIZE_MASK) <<
-                     ISIF_HORZ_BC_WIN_V_SIZE_SHIFT);
-
-               isif_write(isif->isif_cfg.base_addr, val, CLHWIN0);
-
-               val = bc->horz.win_start_h_calc & ISIF_HORZ_BC_WIN_START_H_MASK;
-               isif_write(isif->isif_cfg.base_addr, val, CLHWIN1);
-
-               val = bc->horz.win_start_v_calc & ISIF_HORZ_BC_WIN_START_V_MASK;
-               isif_write(isif->isif_cfg.base_addr, val, CLHWIN2);
-       }
-
-       /* vertical clamp calculation parameters */
-       /* OB H Valid */
-       val = bc->vert.ob_h_sz_calc & ISIF_VERT_BC_OB_H_SZ_MASK;
-
-       /* Reset clamp value sel for previous line */
-       val |= (bc->vert.reset_val_sel & ISIF_VERT_BC_RST_VAL_SEL_MASK) <<
-                               ISIF_VERT_BC_RST_VAL_SEL_SHIFT;
-
-       /* Line average coefficient */
-       val |= bc->vert.line_ave_coef << ISIF_VERT_BC_LINE_AVE_COEF_SHIFT;
-       isif_write(isif->isif_cfg.base_addr, val, CLVWIN0);
-
-       /* Configured reset value */
-       if (bc->vert.reset_val_sel == VPFE_ISIF_VERT_BC_USE_CONFIG_CLAMP_VAL) {
-               val = bc->vert.reset_clamp_val & ISIF_VERT_BC_RST_VAL_MASK;
-               isif_write(isif->isif_cfg.base_addr, val, CLVRV);
-       }
-
-       /* Optical Black horizontal start position */
-       val = bc->vert.ob_start_h & ISIF_VERT_BC_OB_START_HORZ_MASK;
-       isif_write(isif->isif_cfg.base_addr, val, CLVWIN1);
-
-       /* Optical Black vertical start position */
-       val = bc->vert.ob_start_v & ISIF_VERT_BC_OB_START_VERT_MASK;
-       isif_write(isif->isif_cfg.base_addr, val, CLVWIN2);
-
-       val = bc->vert.ob_v_sz_calc & ISIF_VERT_BC_OB_VERT_SZ_MASK;
-       isif_write(isif->isif_cfg.base_addr, val, CLVWIN3);
-
-       /* Vertical start position for BC subtraction */
-       val = bc->vert_start_sub & ISIF_BC_VERT_START_SUB_V_MASK;
-       isif_write(isif->isif_cfg.base_addr, val, CLSV);
-}
-
-/* This function will configure the window size to be capture in ISIF reg */
-static void
-isif_setwin(struct vpfe_isif_device *isif, struct v4l2_rect *image_win,
-           enum isif_frmfmt frm_fmt, int ppc, int mode)
-{
-       int horz_nr_pixels;
-       int vert_nr_lines;
-       int horz_start;
-       int vert_start;
-       int mid_img;
-
-       /*
-        * ppc - per pixel count. indicates how many pixels per cell
-        * output to SDRAM. example, for ycbcr, it is one y and one c, so 2.
-        * raw capture this is 1
-        */
-       horz_start = image_win->left << (ppc - 1);
-       horz_nr_pixels = (image_win->width << (ppc - 1)) - 1;
-
-       /* Writing the horizontal info into the registers */
-       isif_write(isif->isif_cfg.base_addr,
-                  horz_start & START_PX_HOR_MASK, SPH);
-       isif_write(isif->isif_cfg.base_addr,
-                  horz_nr_pixels & NUM_PX_HOR_MASK, LNH);
-       vert_start = image_win->top;
-
-       if (frm_fmt == ISIF_FRMFMT_INTERLACED) {
-               vert_nr_lines = (image_win->height >> 1) - 1;
-               vert_start >>= 1;
-               /* To account for VD since line 0 doesn't have any data */
-               vert_start += 1;
-       } else {
-               /* To account for VD since line 0 doesn't have any data */
-               vert_start += 1;
-               vert_nr_lines = image_win->height - 1;
-               /* configure VDINT0 and VDINT1 */
-               mid_img = vert_start + (image_win->height / 2);
-               isif_write(isif->isif_cfg.base_addr, mid_img, VDINT1);
-       }
-
-       if (!mode)
-               isif_write(isif->isif_cfg.base_addr, 0, VDINT0);
-       else
-               isif_write(isif->isif_cfg.base_addr, vert_nr_lines, VDINT0);
-       isif_write(isif->isif_cfg.base_addr,
-                  vert_start & START_VER_ONE_MASK, SLV0);
-       isif_write(isif->isif_cfg.base_addr,
-                  vert_start & START_VER_TWO_MASK, SLV1);
-       isif_write(isif->isif_cfg.base_addr,
-                  vert_nr_lines & NUM_LINES_VER, LNV);
-}
-
-#define DM365_ISIF_DFCMWR_MEMORY_WRITE         1
-#define DM365_ISIF_DFCMRD_MEMORY_READ          0x2
-
-static void
-isif_config_dfc(struct vpfe_isif_device *isif, struct vpfe_isif_dfc *vdfc)
-{
-#define DFC_WRITE_WAIT_COUNT   1000
-       u32 count = DFC_WRITE_WAIT_COUNT;
-       u32 val;
-       int i;
-
-       if (!vdfc->en)
-               return;
-
-       /* Correction mode */
-       val = (vdfc->corr_mode & ISIF_VDFC_CORR_MOD_MASK) <<
-              ISIF_VDFC_CORR_MOD_SHIFT;
-
-       /* Correct whole line or partial */
-       if (vdfc->corr_whole_line)
-               val |= BIT(ISIF_VDFC_CORR_WHOLE_LN_SHIFT);
-
-       /* level shift value */
-       val |= (vdfc->def_level_shift & ISIF_VDFC_LEVEL_SHFT_MASK) <<
-               ISIF_VDFC_LEVEL_SHFT_SHIFT;
-
-       isif_write(isif->isif_cfg.base_addr, val, DFCCTL);
-
-       /* Defect saturation level */
-       val = vdfc->def_sat_level & ISIF_VDFC_SAT_LEVEL_MASK;
-       isif_write(isif->isif_cfg.base_addr, val, VDFSATLV);
-
-       isif_write(isif->isif_cfg.base_addr, vdfc->table[0].pos_vert &
-                  ISIF_VDFC_POS_MASK, DFCMEM0);
-       isif_write(isif->isif_cfg.base_addr, vdfc->table[0].pos_horz &
-                  ISIF_VDFC_POS_MASK, DFCMEM1);
-       if (vdfc->corr_mode == VPFE_ISIF_VDFC_NORMAL ||
-           vdfc->corr_mode == VPFE_ISIF_VDFC_HORZ_INTERPOL_IF_SAT) {
-               isif_write(isif->isif_cfg.base_addr,
-                          vdfc->table[0].level_at_pos, DFCMEM2);
-               isif_write(isif->isif_cfg.base_addr,
-                          vdfc->table[0].level_up_pixels, DFCMEM3);
-               isif_write(isif->isif_cfg.base_addr,
-                          vdfc->table[0].level_low_pixels, DFCMEM4);
-       }
-
-       val = isif_read(isif->isif_cfg.base_addr, DFCMEMCTL);
-       /* set DFCMARST and set DFCMWR */
-       val |= BIT(ISIF_DFCMEMCTL_DFCMARST_SHIFT);
-       val |= 1;
-       isif_write(isif->isif_cfg.base_addr, val, DFCMEMCTL);
-
-       while (count && (isif_read(isif->isif_cfg.base_addr, DFCMEMCTL) & 0x01))
-               count--;
-
-       val = isif_read(isif->isif_cfg.base_addr, DFCMEMCTL);
-       if (!count) {
-               pr_debug("defect table write timeout !!\n");
-               return;
-       }
-
-       for (i = 1; i < vdfc->num_vdefects; i++) {
-               isif_write(isif->isif_cfg.base_addr, vdfc->table[i].pos_vert &
-                       ISIF_VDFC_POS_MASK, DFCMEM0);
-
-               isif_write(isif->isif_cfg.base_addr, vdfc->table[i].pos_horz &
-                       ISIF_VDFC_POS_MASK, DFCMEM1);
-
-               if (vdfc->corr_mode == VPFE_ISIF_VDFC_NORMAL ||
-                   vdfc->corr_mode == VPFE_ISIF_VDFC_HORZ_INTERPOL_IF_SAT) {
-                       isif_write(isif->isif_cfg.base_addr,
-                                  vdfc->table[i].level_at_pos, DFCMEM2);
-                       isif_write(isif->isif_cfg.base_addr,
-                                  vdfc->table[i].level_up_pixels, DFCMEM3);
-                       isif_write(isif->isif_cfg.base_addr,
-                                  vdfc->table[i].level_low_pixels, DFCMEM4);
-               }
-               val = isif_read(isif->isif_cfg.base_addr, DFCMEMCTL);
-               /* clear DFCMARST and set DFCMWR */
-               val &= ~BIT(ISIF_DFCMEMCTL_DFCMARST_SHIFT);
-               val |= 1;
-               isif_write(isif->isif_cfg.base_addr, val, DFCMEMCTL);
-
-               count = DFC_WRITE_WAIT_COUNT;
-               while (count && (isif_read(isif->isif_cfg.base_addr,
-                       DFCMEMCTL) & 0x01))
-                       count--;
-
-               val = isif_read(isif->isif_cfg.base_addr, DFCMEMCTL);
-               if (!count) {
-                       pr_debug("defect table write timeout !!\n");
-                       return;
-               }
-       }
-       if (vdfc->num_vdefects < VPFE_ISIF_VDFC_TABLE_SIZE) {
-               /* Extra cycle needed */
-               isif_write(isif->isif_cfg.base_addr, 0, DFCMEM0);
-               isif_write(isif->isif_cfg.base_addr,
-                          DM365_ISIF_MAX_DFCMEM1, DFCMEM1);
-               isif_write(isif->isif_cfg.base_addr,
-                          DM365_ISIF_DFCMWR_MEMORY_WRITE, DFCMEMCTL);
-       }
-       /* enable VDFC */
-       isif_merge(isif->isif_cfg.base_addr, (1 << ISIF_VDFC_EN_SHIFT),
-                  (1 << ISIF_VDFC_EN_SHIFT), DFCCTL);
-
-       isif_merge(isif->isif_cfg.base_addr, (1 << ISIF_VDFC_EN_SHIFT),
-                  (0 << ISIF_VDFC_EN_SHIFT), DFCCTL);
-
-       isif_write(isif->isif_cfg.base_addr, 0x6, DFCMEMCTL);
-       for (i = 0; i < vdfc->num_vdefects; i++) {
-               count = DFC_WRITE_WAIT_COUNT;
-               while (count &&
-                       (isif_read(isif->isif_cfg.base_addr, DFCMEMCTL) & 0x2))
-                       count--;
-               val = isif_read(isif->isif_cfg.base_addr, DFCMEMCTL);
-               if (!count) {
-                       pr_debug("defect table write timeout !!\n");
-                       return;
-               }
-               isif_write(isif->isif_cfg.base_addr,
-                          DM365_ISIF_DFCMRD_MEMORY_READ, DFCMEMCTL);
-       }
-}
-
-static void
-isif_config_csc(struct vpfe_isif_device *isif, struct vpfe_isif_df_csc *df_csc)
-{
-       u32 val1;
-       u32 val2;
-       u32 i;
-
-       if (!df_csc->csc.en) {
-               isif_write(isif->isif_cfg.base_addr, 0, CSCCTL);
-               return;
-       }
-       /* initialize all bits to 0 */
-       val1 = 0;
-       for (i = 0; i < VPFE_ISIF_CSC_NUM_COEFF; i++) {
-               if ((i % 2) == 0) {
-                       /* CSCM - LSB */
-                       val1 = ((df_csc->csc.coeff[i].integer &
-                               ISIF_CSC_COEF_INTEG_MASK) <<
-                               ISIF_CSC_COEF_INTEG_SHIFT) |
-                               ((df_csc->csc.coeff[i].decimal &
-                               ISIF_CSC_COEF_DECIMAL_MASK));
-               } else {
-
-                       /* CSCM - MSB */
-                       val2 = ((df_csc->csc.coeff[i].integer &
-                               ISIF_CSC_COEF_INTEG_MASK) <<
-                               ISIF_CSC_COEF_INTEG_SHIFT) |
-                               ((df_csc->csc.coeff[i].decimal &
-                               ISIF_CSC_COEF_DECIMAL_MASK));
-                       val2 <<= ISIF_CSCM_MSB_SHIFT;
-                       val2 |= val1;
-                       isif_write(isif->isif_cfg.base_addr, val2,
-                                  (CSCM0 + ((i-1) << 1)));
-               }
-       }
-       /* program the active area */
-       isif_write(isif->isif_cfg.base_addr, df_csc->start_pix &
-               ISIF_DF_CSC_SPH_MASK, FMTSPH);
-       /*
-        * one extra pixel as required for CSC. Actually number of
-        * pixel - 1 should be configured in this register. So we
-        * need to subtract 1 before writing to FMTSPH, but we will
-        * not do this since csc requires one extra pixel
-        */
-       isif_write(isif->isif_cfg.base_addr, df_csc->num_pixels &
-               ISIF_DF_CSC_SPH_MASK, FMTLNH);
-       isif_write(isif->isif_cfg.base_addr, df_csc->start_line &
-               ISIF_DF_CSC_SPH_MASK, FMTSLV);
-       /*
-        * one extra line as required for CSC. See reason documented for
-        * num_pixels
-        */
-       isif_write(isif->isif_cfg.base_addr, df_csc->num_lines &
-               ISIF_DF_CSC_SPH_MASK, FMTLNV);
-       /* Enable CSC */
-       isif_write(isif->isif_cfg.base_addr, 1, CSCCTL);
-}
-
-static void
-isif_config_linearization(struct vpfe_isif_device *isif,
-                         struct vpfe_isif_linearize *linearize)
-{
-       u32 val;
-       u32 i;
-
-       if (!linearize->en) {
-               isif_write(isif->isif_cfg.base_addr, 0, LINCFG0);
-               return;
-       }
-       /* shift value for correction */
-       val = (linearize->corr_shft & ISIF_LIN_CORRSFT_MASK) <<
-             ISIF_LIN_CORRSFT_SHIFT;
-       /* enable */
-       val |= 1;
-       isif_write(isif->isif_cfg.base_addr, val, LINCFG0);
-       /* Scale factor */
-       val = (linearize->scale_fact.integer & 1) <<
-             ISIF_LIN_SCALE_FACT_INTEG_SHIFT;
-       val |= linearize->scale_fact.decimal & ISIF_LIN_SCALE_FACT_DECIMAL_MASK;
-       isif_write(isif->isif_cfg.base_addr, val, LINCFG1);
-
-       for (i = 0; i < VPFE_ISIF_LINEAR_TAB_SIZE; i++) {
-               val = linearize->table[i] & ISIF_LIN_ENTRY_MASK;
-               if (i%2)
-                       isif_regw_lin_tbl(isif, val, ((i >> 1) << 2), 1);
-               else
-                       isif_regw_lin_tbl(isif, val, ((i >> 1) << 2), 0);
-       }
-}
-
-static void
-isif_config_culling(struct vpfe_isif_device *isif, struct vpfe_isif_cul *cul)
-{
-       u32 val;
-
-       /* Horizontal pattern */
-       val = cul->hcpat_even << CULL_PAT_EVEN_LINE_SHIFT;
-       val |= cul->hcpat_odd;
-       isif_write(isif->isif_cfg.base_addr, val, CULH);
-       /* vertical pattern */
-       isif_write(isif->isif_cfg.base_addr, cul->vcpat, CULV);
-       /* LPF */
-       isif_merge(isif->isif_cfg.base_addr, ISIF_LPF_MASK << ISIF_LPF_SHIFT,
-                  cul->en_lpf << ISIF_LPF_SHIFT, MODESET);
-}
-
-static int isif_get_pix_fmt(u32 mbus_code)
-{
-       switch (mbus_code) {
-       case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
-       case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
-       case MEDIA_BUS_FMT_SGRBG12_1X12:
-               return ISIF_PIXFMT_RAW;
-
-       case MEDIA_BUS_FMT_YUYV8_2X8:
-       case MEDIA_BUS_FMT_UYVY8_2X8:
-       case MEDIA_BUS_FMT_YUYV10_2X10:
-       case MEDIA_BUS_FMT_Y8_1X8:
-               return ISIF_PIXFMT_YCBCR_8BIT;
-
-       case MEDIA_BUS_FMT_YUYV8_1X16:
-       case MEDIA_BUS_FMT_YUYV10_1X20:
-               return ISIF_PIXFMT_YCBCR_16BIT;
-
-       default:
-               break;
-       }
-       return -EINVAL;
-}
-
-#define ISIF_INTERLACE_INVERSE_MODE            0x4b6d
-#define ISIF_INTERLACE_NON_INVERSE_MODE                0x0b6d
-#define ISIF_PROGRESSIVE_INVERSE_MODE          0x4000
-#define ISIF_PROGRESSIVE_NON_INVERSE_MODE      0x0000
-
-static int isif_config_raw(struct v4l2_subdev *sd, int mode)
-{
-       struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd);
-       struct isif_params_raw *params = &isif->isif_cfg.bayer;
-       struct vpfe_isif_raw_config *module_params =
-                               &isif->isif_cfg.bayer.config_params;
-       struct v4l2_mbus_framefmt *format;
-       int pix_fmt;
-       u32 val;
-
-       format = &isif->formats[ISIF_PAD_SINK];
-
-       /* In case of user has set BT656IF earlier, it should be reset
-        * when configuring for raw input.
-        */
-       isif_write(isif->isif_cfg.base_addr, 0, REC656IF);
-       /* Configure CCDCFG register
-        * Set CCD Not to swap input since input is RAW data
-        * Set FID detection function to Latch at V-Sync
-        * Set WENLOG - isif valid area
-        * Set TRGSEL
-        * Set EXTRG
-        * Packed to 8 or 16 bits
-        */
-       val = ISIF_YCINSWP_RAW | ISIF_CCDCFG_FIDMD_LATCH_VSYNC |
-             ISIF_CCDCFG_WENLOG_AND | ISIF_CCDCFG_TRGSEL_WEN |
-             ISIF_CCDCFG_EXTRG_DISABLE | (isif->isif_cfg.data_pack &
-             ISIF_DATA_PACK_MASK);
-       isif_write(isif->isif_cfg.base_addr, val, CCDCFG);
-
-       pix_fmt = isif_get_pix_fmt(format->code);
-       if (pix_fmt < 0) {
-               pr_debug("Invalid pix_fmt(input mode)\n");
-               return -EINVAL;
-       }
-       /*
-        * Configure the vertical sync polarity(MODESET.VDPOL)
-        * Configure the horizontal sync polarity (MODESET.HDPOL)
-        * Configure frame id polarity (MODESET.FLDPOL)
-        * Configure data polarity
-        * Configure External WEN Selection
-        * Configure frame format(progressive or interlace)
-        * Configure pixel format (Input mode)
-        * Configure the data shift
-        */
-       val = ISIF_VDHDOUT_INPUT | ((params->vd_pol & ISIF_VD_POL_MASK) <<
-             ISIF_VD_POL_SHIFT) | ((params->hd_pol & ISIF_HD_POL_MASK) <<
-             ISIF_HD_POL_SHIFT) | ((params->fid_pol & ISIF_FID_POL_MASK) <<
-             ISIF_FID_POL_SHIFT) | ((ISIF_DATAPOL_NORMAL &
-             ISIF_DATAPOL_MASK) << ISIF_DATAPOL_SHIFT) | ((ISIF_EXWEN_DISABLE &
-             ISIF_EXWEN_MASK) << ISIF_EXWEN_SHIFT) | ((params->frm_fmt &
-             ISIF_FRM_FMT_MASK) << ISIF_FRM_FMT_SHIFT) | ((pix_fmt &
-             ISIF_INPUT_MASK) << ISIF_INPUT_SHIFT);
-
-       /* currently only MEDIA_BUS_FMT_SGRBG12_1X12 is
-        * supported. shift appropriately depending on
-        * different MBUS fmt's added
-        */
-       if (format->code == MEDIA_BUS_FMT_SGRBG12_1X12)
-               val |= ((VPFE_ISIF_NO_SHIFT &
-                       ISIF_DATASFT_MASK) << ISIF_DATASFT_SHIFT);
-
-       isif_write(isif->isif_cfg.base_addr, val, MODESET);
-       /*
-        * Configure GAMMAWD register
-        * CFA pattern setting
-        */
-       val = (params->cfa_pat & ISIF_GAMMAWD_CFA_MASK) <<
-               ISIF_GAMMAWD_CFA_SHIFT;
-       /* Gamma msb */
-       if (params->v4l2_pix_fmt == V4L2_PIX_FMT_SGRBG10ALAW8)
-               val = val | ISIF_ALAW_ENABLE;
-
-       val = val | ((params->data_msb & ISIF_ALAW_GAMA_WD_MASK) <<
-                       ISIF_ALAW_GAMA_WD_SHIFT);
-
-       isif_write(isif->isif_cfg.base_addr, val, CGAMMAWD);
-       /* Configure DPCM compression settings */
-       if (params->v4l2_pix_fmt == V4L2_PIX_FMT_SGRBG10DPCM8) {
-               val =  BIT(ISIF_DPCM_EN_SHIFT);
-               val |= (params->dpcm_predictor &
-                       ISIF_DPCM_PREDICTOR_MASK) << ISIF_DPCM_PREDICTOR_SHIFT;
-       }
-       isif_write(isif->isif_cfg.base_addr, val, MISC);
-       /* Configure Gain & Offset */
-       isif_config_gain_offset(isif);
-       /* Configure Color pattern */
-       if (format->code == MEDIA_BUS_FMT_SGRBG12_1X12)
-               val = isif_sgrbg_pattern;
-       else
-               /* default set to rggb */
-               val = isif_srggb_pattern;
-
-       isif_write(isif->isif_cfg.base_addr, val, CCOLP);
-
-       /* Configure HSIZE register  */
-       val = (params->horz_flip_en & ISIF_HSIZE_FLIP_MASK) <<
-             ISIF_HSIZE_FLIP_SHIFT;
-
-       /* calculate line offset in 32 bytes based on pack value */
-       if (isif->isif_cfg.data_pack == ISIF_PACK_8BIT)
-               val |= ((params->win.width + 31) >> 5) & ISIF_LINEOFST_MASK;
-       else if (isif->isif_cfg.data_pack == ISIF_PACK_12BIT)
-               val |= ((((params->win.width + (params->win.width >> 2)) +
-                       31) >> 5) & ISIF_LINEOFST_MASK);
-       else
-               val |= (((params->win.width * 2) + 31) >> 5) &
-                       ISIF_LINEOFST_MASK;
-       isif_write(isif->isif_cfg.base_addr, val, HSIZE);
-       /* Configure SDOFST register  */
-       if (params->frm_fmt == ISIF_FRMFMT_INTERLACED) {
-               if (params->image_invert_en)
-                       /* For interlace inverse mode */
-                       isif_write(isif->isif_cfg.base_addr,
-                                  ISIF_INTERLACE_INVERSE_MODE, SDOFST);
-               else
-                       /* For interlace non inverse mode */
-                       isif_write(isif->isif_cfg.base_addr,
-                                  ISIF_INTERLACE_NON_INVERSE_MODE, SDOFST);
-       } else if (params->frm_fmt == ISIF_FRMFMT_PROGRESSIVE) {
-               if (params->image_invert_en)
-                       isif_write(isif->isif_cfg.base_addr,
-                                  ISIF_PROGRESSIVE_INVERSE_MODE, SDOFST);
-               else
-                       /* For progessive non inverse mode */
-                       isif_write(isif->isif_cfg.base_addr,
-                                  ISIF_PROGRESSIVE_NON_INVERSE_MODE, SDOFST);
-       }
-       /* Configure video window */
-       isif_setwin(isif, &params->win, params->frm_fmt, 1, mode);
-       /* Configure Black Clamp */
-       isif_config_bclamp(isif, &module_params->bclamp);
-       /* Configure Vertical Defection Pixel Correction */
-       isif_config_dfc(isif, &module_params->dfc);
-       if (!module_params->df_csc.df_or_csc)
-               /* Configure Color Space Conversion */
-               isif_config_csc(isif, &module_params->df_csc);
-
-       isif_config_linearization(isif, &module_params->linearize);
-       /* Configure Culling */
-       isif_config_culling(isif, &module_params->culling);
-       /* Configure Horizontal and vertical offsets(DFC,LSC,Gain) */
-       val = module_params->horz_offset & ISIF_DATA_H_OFFSET_MASK;
-       isif_write(isif->isif_cfg.base_addr, val, DATAHOFST);
-
-       val = module_params->vert_offset & ISIF_DATA_V_OFFSET_MASK;
-       isif_write(isif->isif_cfg.base_addr, val, DATAVOFST);
-
-       return 0;
-}
-
-#define DM365_ISIF_HSIZE_MASK          0xffffffe0
-#define DM365_ISIF_SDOFST_2_LINES      0x00000249
-
-/* This function will configure ISIF for YCbCr parameters. */
-static int isif_config_ycbcr(struct v4l2_subdev *sd, int mode)
-{
-       struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd);
-       struct isif_ycbcr_config *params = &isif->isif_cfg.ycbcr;
-       struct v4l2_mbus_framefmt *format;
-       int pix_fmt;
-       u32 modeset;
-       u32 ccdcfg;
-
-       format = &isif->formats[ISIF_PAD_SINK];
-       /*
-        * first reset the ISIF
-        * all registers have default values after reset
-        * This is important since we assume default values to be set in
-        * a lot of registers that we didn't touch
-        */
-       /* start with all bits zero */
-       ccdcfg = 0;
-       modeset = 0;
-       pix_fmt = isif_get_pix_fmt(format->code);
-       if (pix_fmt < 0) {
-               pr_debug("Invalid pix_fmt(input mode)\n");
-               return -EINVAL;
-       }
-       /* configure pixel format or input mode */
-       modeset = modeset | ((pix_fmt & ISIF_INPUT_MASK) <<
-                 ISIF_INPUT_SHIFT) | ((params->frm_fmt & ISIF_FRM_FMT_MASK) <<
-                 ISIF_FRM_FMT_SHIFT) | (((params->fid_pol &
-                 ISIF_FID_POL_MASK) << ISIF_FID_POL_SHIFT)) |
-                 (((params->hd_pol & ISIF_HD_POL_MASK) << ISIF_HD_POL_SHIFT)) |
-                 (((params->vd_pol & ISIF_VD_POL_MASK) << ISIF_VD_POL_SHIFT));
-       /* pack the data to 8-bit CCDCCFG */
-       switch (format->code) {
-       case MEDIA_BUS_FMT_YUYV8_2X8:
-       case MEDIA_BUS_FMT_UYVY8_2X8:
-               if (pix_fmt != ISIF_PIXFMT_YCBCR_8BIT) {
-                       pr_debug("Invalid pix_fmt(input mode)\n");
-                       return -EINVAL;
-               }
-               modeset |= ((VPFE_PINPOL_NEGATIVE & ISIF_VD_POL_MASK) <<
-                               ISIF_VD_POL_SHIFT);
-               isif_write(isif->isif_cfg.base_addr, 3, REC656IF);
-               ccdcfg = ccdcfg | ISIF_PACK_8BIT | ISIF_YCINSWP_YCBCR;
-               break;
-
-       case MEDIA_BUS_FMT_YUYV10_2X10:
-               if (pix_fmt != ISIF_PIXFMT_YCBCR_8BIT) {
-                       pr_debug("Invalid pix_fmt(input mode)\n");
-                       return -EINVAL;
-               }
-               /* setup BT.656, embedded sync  */
-               isif_write(isif->isif_cfg.base_addr, 3, REC656IF);
-               /* enable 10 bit mode in ccdcfg */
-               ccdcfg = ccdcfg | ISIF_PACK_8BIT | ISIF_YCINSWP_YCBCR |
-                       ISIF_BW656_ENABLE;
-               break;
-
-       case MEDIA_BUS_FMT_YUYV10_1X20:
-               if (pix_fmt != ISIF_PIXFMT_YCBCR_16BIT) {
-                       pr_debug("Invalid pix_fmt(input mode)\n");
-                       return -EINVAL;
-               }
-               isif_write(isif->isif_cfg.base_addr, 3, REC656IF);
-               break;
-
-       case MEDIA_BUS_FMT_Y8_1X8:
-               ccdcfg |= ISIF_PACK_8BIT;
-               ccdcfg |= ISIF_YCINSWP_YCBCR;
-               if (pix_fmt != ISIF_PIXFMT_YCBCR_8BIT) {
-                       pr_debug("Invalid pix_fmt(input mode)\n");
-                       return -EINVAL;
-               }
-               break;
-
-       case MEDIA_BUS_FMT_YUYV8_1X16:
-               if (pix_fmt != ISIF_PIXFMT_YCBCR_16BIT) {
-                       pr_debug("Invalid pix_fmt(input mode)\n");
-                       return -EINVAL;
-               }
-               break;
-
-       default:
-               /* should never come here */
-               pr_debug("Invalid interface type\n");
-               return -EINVAL;
-       }
-       isif_write(isif->isif_cfg.base_addr, modeset, MODESET);
-       /* Set up pix order */
-       ccdcfg |= (params->pix_order & ISIF_PIX_ORDER_MASK) <<
-               ISIF_PIX_ORDER_SHIFT;
-       isif_write(isif->isif_cfg.base_addr, ccdcfg, CCDCFG);
-       /* configure video window */
-       if (format->code == MEDIA_BUS_FMT_YUYV10_1X20 ||
-                       format->code == MEDIA_BUS_FMT_YUYV8_1X16)
-               isif_setwin(isif, &params->win, params->frm_fmt, 1, mode);
-       else
-               isif_setwin(isif, &params->win, params->frm_fmt, 2, mode);
-
-       /*
-        * configure the horizontal line offset
-        * this is done by rounding up width to a multiple of 16 pixels
-        * and multiply by two to account for y:cb:cr 4:2:2 data
-        */
-       isif_write(isif->isif_cfg.base_addr,
-                  ((((params->win.width * 2) + 31) &
-                  DM365_ISIF_HSIZE_MASK) >> 5), HSIZE);
-
-       /* configure the memory line offset */
-       if (params->frm_fmt == ISIF_FRMFMT_INTERLACED &&
-           params->buf_type == ISIF_BUFTYPE_FLD_INTERLEAVED)
-               /* two fields are interleaved in memory */
-               isif_write(isif->isif_cfg.base_addr,
-                          DM365_ISIF_SDOFST_2_LINES, SDOFST);
-       return 0;
-}
-
-static int isif_configure(struct v4l2_subdev *sd, int mode)
-{
-       struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd);
-       struct v4l2_mbus_framefmt *format;
-
-       format = &isif->formats[ISIF_PAD_SINK];
-
-       switch (format->code) {
-       case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
-       case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
-       case MEDIA_BUS_FMT_SGRBG12_1X12:
-               return isif_config_raw(sd, mode);
-
-       case MEDIA_BUS_FMT_YUYV8_2X8:
-       case MEDIA_BUS_FMT_UYVY8_2X8:
-       case MEDIA_BUS_FMT_YUYV10_2X10:
-       case MEDIA_BUS_FMT_Y8_1X8:
-       case MEDIA_BUS_FMT_YUYV8_1X16:
-       case MEDIA_BUS_FMT_YUYV10_1X20:
-               return isif_config_ycbcr(sd, mode);
-
-       default:
-               break;
-       }
-       return -EINVAL;
-}
-
-/*
- * isif_set_stream() - Enable/Disable streaming on the ISIF module
- * @sd: VPFE ISIF V4L2 subdevice
- * @enable: Enable/disable stream
- */
-static int isif_set_stream(struct v4l2_subdev *sd, int enable)
-{
-       struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd);
-       int ret;
-
-       if (enable) {
-               ret = isif_configure(sd,
-                       (isif->output == ISIF_OUTPUT_MEMORY) ? 0 : 1);
-               if (ret)
-                       return ret;
-               if (isif->output == ISIF_OUTPUT_MEMORY)
-                       isif_enable_output_to_sdram(isif, 1);
-               isif_enable(isif, 1);
-       } else {
-               isif_enable(isif, 0);
-               isif_enable_output_to_sdram(isif, 0);
-       }
-
-       return 0;
-}
-
-/*
- * __isif_get_format() - helper function for getting isif format
- * @isif: pointer to isif private structure.
- * @pad: pad number.
- * @cfg: V4L2 subdev pad config
- * @which: wanted subdev format.
- */
-static struct v4l2_mbus_framefmt *
-__isif_get_format(struct vpfe_isif_device *isif,
-                 struct v4l2_subdev_pad_config *cfg, unsigned int pad,
-                 enum v4l2_subdev_format_whence which)
-{
-       if (which == V4L2_SUBDEV_FORMAT_TRY)
-               return v4l2_subdev_get_try_format(&isif->subdev, cfg, pad);
-
-       return &isif->formats[pad];
-}
-
-/*
- * isif_set_format() - set format on pad
- * @sd    : VPFE ISIF device
- * @cfg   : V4L2 subdev pad config
- * @fmt   : pointer to v4l2 subdev format structure
- *
- * Return 0 on success or -EINVAL if format or pad is invalid
- */
-static int
-isif_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
-               struct v4l2_subdev_format *fmt)
-{
-       struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd);
-       struct vpfe_device *vpfe_dev = to_vpfe_device(isif);
-       struct v4l2_mbus_framefmt *format;
-
-       format = __isif_get_format(isif, cfg, fmt->pad, fmt->which);
-       if (format == NULL)
-               return -EINVAL;
-
-       isif_try_format(isif, cfg, fmt);
-       memcpy(format, &fmt->format, sizeof(*format));
-
-       if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
-               return 0;
-
-       if (fmt->pad == ISIF_PAD_SOURCE)
-               return isif_config_format(vpfe_dev, fmt->pad);
-
-       return 0;
-}
-
-/*
- * isif_get_format() - Retrieve the video format on a pad
- * @sd: VPFE ISIF V4L2 subdevice
- * @cfg: V4L2 subdev pad config
- * @fmt: pointer to v4l2 subdev format structure
- *
- * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
- * to the format type.
- */
-static int
-isif_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
-               struct v4l2_subdev_format *fmt)
-{
-       struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd);
-       struct v4l2_mbus_framefmt *format;
-
-       format = __isif_get_format(vpfe_isif, cfg, fmt->pad, fmt->which);
-       if (format == NULL)
-               return -EINVAL;
-
-       memcpy(&fmt->format, format, sizeof(fmt->format));
-
-       return 0;
-}
-
-/*
- * isif_enum_frame_size() - enum frame sizes on pads
- * @sd: VPFE isif V4L2 subdevice
- * @cfg: V4L2 subdev pad config
- * @code: pointer to v4l2_subdev_frame_size_enum structure
- */
-static int
-isif_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
-                    struct v4l2_subdev_frame_size_enum *fse)
-{
-       struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd);
-       struct v4l2_subdev_format format;
-
-       if (fse->index != 0)
-               return -EINVAL;
-
-       format.pad = fse->pad;
-       format.format.code = fse->code;
-       format.format.width = 1;
-       format.format.height = 1;
-       format.which = fse->which;
-       isif_try_format(isif, cfg, &format);
-       fse->min_width = format.format.width;
-       fse->min_height = format.format.height;
-
-       if (format.format.code != fse->code)
-               return -EINVAL;
-
-       format.pad = fse->pad;
-       format.format.code = fse->code;
-       format.format.width = -1;
-       format.format.height = -1;
-       format.which = fse->which;
-       isif_try_format(isif, cfg, &format);
-       fse->max_width = format.format.width;
-       fse->max_height = format.format.height;
-
-       return 0;
-}
-
-/*
- * isif_enum_mbus_code() - enum mbus codes for pads
- * @sd: VPFE isif V4L2 subdevice
- * @cfg: V4L2 subdev pad config
- * @code: pointer to v4l2_subdev_mbus_code_enum structure
- */
-static int
-isif_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
-                   struct v4l2_subdev_mbus_code_enum *code)
-{
-       switch (code->pad) {
-       case ISIF_PAD_SINK:
-       case ISIF_PAD_SOURCE:
-               if (code->index >= ARRAY_SIZE(isif_fmts))
-                       return -EINVAL;
-               code->code = isif_fmts[code->index];
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-/*
- * isif_pad_set_selection() - set crop rectangle on pad
- * @sd: VPFE isif V4L2 subdevice
- * @cfg: V4L2 subdev pad config
- * @code: pointer to v4l2_subdev_mbus_code_enum structure
- *
- * Return 0 on success, -EINVAL if pad is invalid
- */
-static int
-isif_pad_set_selection(struct v4l2_subdev *sd,
-                      struct v4l2_subdev_pad_config *cfg,
-                      struct v4l2_subdev_selection *sel)
-{
-       struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd);
-       struct v4l2_mbus_framefmt *format;
-
-       /* check whether it's a valid pad and target */
-       if (sel->pad != ISIF_PAD_SINK || sel->target != V4L2_SEL_TGT_CROP)
-               return -EINVAL;
-
-       format = __isif_get_format(vpfe_isif, cfg, sel->pad, sel->which);
-       if (format == NULL)
-               return -EINVAL;
-
-       /* check wether crop rect is within limits */
-       if (sel->r.top < 0 || sel->r.left < 0 ||
-               (sel->r.left + sel->r.width >
-               vpfe_isif->formats[ISIF_PAD_SINK].width) ||
-               (sel->r.top + sel->r.height >
-                       vpfe_isif->formats[ISIF_PAD_SINK].height)) {
-               sel->r.left = 0;
-               sel->r.top = 0;
-               sel->r.width = format->width;
-               sel->r.height = format->height;
-       }
-       /* adjust the width to 16 pixel boundary */
-       sel->r.width = (sel->r.width + 15) & ~0xf;
-       vpfe_isif->crop = sel->r;
-       if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
-               isif_set_image_window(vpfe_isif);
-       } else {
-               struct v4l2_rect *rect;
-
-               rect = v4l2_subdev_get_try_crop(sd, cfg, ISIF_PAD_SINK);
-               memcpy(rect, &vpfe_isif->crop, sizeof(*rect));
-       }
-       return 0;
-}
-
-/*
- * isif_pad_get_selection() - get crop rectangle on pad
- * @sd: VPFE isif V4L2 subdevice
- * @cfg: V4L2 subdev pad config
- * @code: pointer to v4l2_subdev_mbus_code_enum structure
- *
- * Return 0 on success, -EINVAL if pad is invalid
- */
-static int
-isif_pad_get_selection(struct v4l2_subdev *sd,
-                      struct v4l2_subdev_pad_config *cfg,
-                      struct v4l2_subdev_selection *sel)
-{
-       struct vpfe_isif_device *vpfe_isif = v4l2_get_subdevdata(sd);
-
-       /* check whether it's a valid pad and target */
-       if (sel->pad != ISIF_PAD_SINK || sel->target != V4L2_SEL_TGT_CROP)
-               return -EINVAL;
-
-       if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
-               struct v4l2_rect *rect;
-
-               rect = v4l2_subdev_get_try_crop(sd, cfg, ISIF_PAD_SINK);
-               memcpy(&sel->r, rect, sizeof(*rect));
-       } else {
-               sel->r = vpfe_isif->crop;
-       }
-
-       return 0;
-}
-
-/*
- * isif_init_formats() - Initialize formats on all pads
- * @sd: VPFE isif V4L2 subdevice
- * @fh: V4L2 subdev file handle
- *
- * Initialize all pad formats with default values. Try formats are initialized
- * on the file handle.
- */
-static int
-isif_init_formats(struct v4l2_subdev *sd,
-                 struct v4l2_subdev_fh *fh)
-{
-       struct v4l2_subdev_format format;
-       struct v4l2_subdev_selection sel;
-
-       memset(&format, 0, sizeof(format));
-       format.pad = ISIF_PAD_SINK;
-       format.which = V4L2_SUBDEV_FORMAT_TRY;
-       format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
-       format.format.width = MAX_WIDTH;
-       format.format.height = MAX_HEIGHT;
-       isif_set_format(sd, fh->pad, &format);
-
-       memset(&format, 0, sizeof(format));
-       format.pad = ISIF_PAD_SOURCE;
-       format.which = V4L2_SUBDEV_FORMAT_TRY;
-       format.format.code = MEDIA_BUS_FMT_SGRBG12_1X12;
-       format.format.width = MAX_WIDTH;
-       format.format.height = MAX_HEIGHT;
-       isif_set_format(sd, fh->pad, &format);
-
-       memset(&sel, 0, sizeof(sel));
-       sel.pad = ISIF_PAD_SINK;
-       sel.which = V4L2_SUBDEV_FORMAT_TRY;
-       sel.target = V4L2_SEL_TGT_CROP;
-       sel.r.width = MAX_WIDTH;
-       sel.r.height = MAX_HEIGHT;
-       isif_pad_set_selection(sd, fh->pad, &sel);
-
-       return 0;
-}
-
-/* subdev core operations */
-static const struct v4l2_subdev_core_ops isif_v4l2_core_ops = {
-       .ioctl = isif_ioctl,
-};
-
-/* subdev file operations */
-static const struct v4l2_subdev_internal_ops isif_v4l2_internal_ops = {
-       .open = isif_init_formats,
-};
-
-/* subdev video operations */
-static const struct v4l2_subdev_video_ops isif_v4l2_video_ops = {
-       .s_stream = isif_set_stream,
-};
-
-/* subdev pad operations */
-static const struct v4l2_subdev_pad_ops isif_v4l2_pad_ops = {
-       .enum_mbus_code = isif_enum_mbus_code,
-       .enum_frame_size = isif_enum_frame_size,
-       .get_fmt = isif_get_format,
-       .set_fmt = isif_set_format,
-       .set_selection = isif_pad_set_selection,
-       .get_selection = isif_pad_get_selection,
-};
-
-/* subdev operations */
-static const struct v4l2_subdev_ops isif_v4l2_ops = {
-       .core = &isif_v4l2_core_ops,
-       .video = &isif_v4l2_video_ops,
-       .pad = &isif_v4l2_pad_ops,
-};
-
-/*
- * Media entity operations
- */
-
-/*
- * isif_link_setup() - Setup isif connections
- * @entity: isif media entity
- * @local: Pad at the local end of the link
- * @remote: Pad at the remote end of the link
- * @flags: Link flags
- *
- * return -EINVAL or zero on success
- */
-static int
-isif_link_setup(struct media_entity *entity, const struct media_pad *local,
-               const struct media_pad *remote, u32 flags)
-{
-       struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
-       struct vpfe_isif_device *isif = v4l2_get_subdevdata(sd);
-       unsigned int index = local->index;
-
-       /* FIXME: this is actually a hack! */
-       if (is_media_entity_v4l2_subdev(remote->entity))
-               index |= 2 << 16;
-
-       switch (index) {
-       case ISIF_PAD_SINK | 2 << 16:
-               /* read from decoder/sensor */
-               if (!(flags & MEDIA_LNK_FL_ENABLED)) {
-                       isif->input = ISIF_INPUT_NONE;
-                       break;
-               }
-               if (isif->input != ISIF_INPUT_NONE)
-                       return -EBUSY;
-               isif->input = ISIF_INPUT_PARALLEL;
-               break;
-
-       case ISIF_PAD_SOURCE:
-               /* write to memory */
-               if (flags & MEDIA_LNK_FL_ENABLED)
-                       isif->output = ISIF_OUTPUT_MEMORY;
-               else
-                       isif->output = ISIF_OUTPUT_NONE;
-               break;
-
-       case ISIF_PAD_SOURCE | 2 << 16:
-               if (flags & MEDIA_LNK_FL_ENABLED)
-                       isif->output = ISIF_OUTPUT_IPIPEIF;
-               else
-                       isif->output = ISIF_OUTPUT_NONE;
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-static const struct media_entity_operations isif_media_ops = {
-       .link_setup = isif_link_setup,
-};
-
-/*
- * vpfe_isif_unregister_entities() - isif unregister entity
- * @isif - pointer to isif subdevice structure.
- */
-void vpfe_isif_unregister_entities(struct vpfe_isif_device *isif)
-{
-       vpfe_video_unregister(&isif->video_out);
-       /* unregister subdev */
-       v4l2_device_unregister_subdev(&isif->subdev);
-       /* cleanup entity */
-       media_entity_cleanup(&isif->subdev.entity);
-}
-
-static void isif_restore_defaults(struct vpfe_isif_device *isif)
-{
-       enum vpss_ccdc_source_sel source = VPSS_CCDCIN;
-       int i;
-
-       memset(&isif->isif_cfg.bayer.config_params, 0,
-              sizeof(struct vpfe_isif_raw_config));
-
-       isif->isif_cfg.bayer.config_params.linearize.corr_shft =
-                                       VPFE_ISIF_NO_SHIFT;
-       isif->isif_cfg.bayer.config_params.linearize.scale_fact.integer = 1;
-       isif->isif_cfg.bayer.config_params.culling.hcpat_odd =
-                       ISIF_CULLING_HCAPT_ODD;
-       isif->isif_cfg.bayer.config_params.culling.hcpat_even =
-                       ISIF_CULLING_HCAPT_EVEN;
-       isif->isif_cfg.bayer.config_params.culling.vcpat = ISIF_CULLING_VCAPT;
-       /* Enable clock to ISIF, IPIPEIF and BL */
-       vpss_enable_clock(VPSS_CCDC_CLOCK, 1);
-       vpss_enable_clock(VPSS_IPIPEIF_CLOCK, 1);
-       vpss_enable_clock(VPSS_BL_CLOCK, 1);
-
-       /* set all registers to default value */
-       for (i = 0; i <= 0x1f8; i += 4)
-               isif_write(isif->isif_cfg.base_addr, 0, i);
-       /* no culling support */
-       isif_write(isif->isif_cfg.base_addr, 0xffff, CULH);
-       isif_write(isif->isif_cfg.base_addr, 0xff, CULV);
-
-       /* Set default offset and gain */
-       isif_config_gain_offset(isif);
-       vpss_select_ccdc_source(source);
-}
-
-/*
- * vpfe_isif_register_entities() - isif register entity
- * @isif - pointer to isif subdevice structure.
- * @vdev: pointer to v4l2 device structure.
- */
-int vpfe_isif_register_entities(struct vpfe_isif_device *isif,
-                           struct v4l2_device *vdev)
-{
-       struct vpfe_device *vpfe_dev = to_vpfe_device(isif);
-       unsigned int flags;
-       int ret;
-
-       /* Register the subdev */
-       ret = v4l2_device_register_subdev(vdev, &isif->subdev);
-       if (ret < 0)
-               return ret;
-
-       isif_restore_defaults(isif);
-       ret = vpfe_video_register(&isif->video_out, vdev);
-       if (ret) {
-               pr_err("Failed to register isif video out device\n");
-               goto out_video_register;
-       }
-       isif->video_out.vpfe_dev = vpfe_dev;
-       flags = 0;
-       /* connect isif to video node */
-       ret = media_create_pad_link(&isif->subdev.entity, 1,
-                                      &isif->video_out.video_dev.entity,
-                                      0, flags);
-       if (ret < 0)
-               goto out_create_link;
-       return 0;
-out_create_link:
-       vpfe_video_unregister(&isif->video_out);
-out_video_register:
-       v4l2_device_unregister_subdev(&isif->subdev);
-       return ret;
-}
-
-/* -------------------------------------------------------------------
- * V4L2 subdev control operations
- */
-
-static int vpfe_isif_s_ctrl(struct v4l2_ctrl *ctrl)
-{
-       struct vpfe_isif_device *isif =
-            container_of(ctrl->handler, struct vpfe_isif_device, ctrls);
-       struct isif_oper_config *config = &isif->isif_cfg;
-
-       switch (ctrl->id) {
-       case VPFE_CID_DPCM_PREDICTOR:
-               config->bayer.dpcm_predictor = ctrl->val;
-               break;
-
-       case VPFE_ISIF_CID_CRGAIN:
-               config->isif_gain_params.cr_gain = ctrl->val;
-               break;
-
-       case VPFE_ISIF_CID_CGRGAIN:
-               config->isif_gain_params.cgr_gain = ctrl->val;
-               break;
-
-       case VPFE_ISIF_CID_CGBGAIN:
-               config->isif_gain_params.cgb_gain = ctrl->val;
-               break;
-
-       case VPFE_ISIF_CID_CBGAIN:
-               config->isif_gain_params.cb_gain = ctrl->val;
-               break;
-
-       case VPFE_ISIF_CID_GAIN_OFFSET:
-               config->isif_gain_params.offset = ctrl->val;
-               break;
-
-       default:
-               return -EINVAL;
-       }
-       return 0;
-}
-
-static const struct v4l2_ctrl_ops vpfe_isif_ctrl_ops = {
-       .s_ctrl = vpfe_isif_s_ctrl,
-};
-
-static const struct v4l2_ctrl_config vpfe_isif_dpcm_pred = {
-       .ops = &vpfe_isif_ctrl_ops,
-       .id = VPFE_CID_DPCM_PREDICTOR,
-       .name = "DPCM Predictor",
-       .type = V4L2_CTRL_TYPE_INTEGER,
-       .min = 0,
-       .max = 1,
-       .step = 1,
-       .def = 0,
-};
-
-static const struct v4l2_ctrl_config vpfe_isif_crgain = {
-       .ops = &vpfe_isif_ctrl_ops,
-       .id = VPFE_ISIF_CID_CRGAIN,
-       .name = "CRGAIN",
-       .type = V4L2_CTRL_TYPE_INTEGER,
-       .min = 0,
-       .max = (1 << 12) - 1,
-       .step = 1,
-       .def = 0,
-};
-
-static const struct v4l2_ctrl_config vpfe_isif_cgrgain = {
-       .ops = &vpfe_isif_ctrl_ops,
-       .id = VPFE_ISIF_CID_CGRGAIN,
-       .name = "CGRGAIN",
-       .type = V4L2_CTRL_TYPE_INTEGER,
-       .min = 0,
-       .max = (1 << 12) - 1,
-       .step = 1,
-       .def = 0,
-};
-
-static const struct v4l2_ctrl_config vpfe_isif_cgbgain = {
-       .ops = &vpfe_isif_ctrl_ops,
-       .id = VPFE_ISIF_CID_CGBGAIN,
-       .name = "CGBGAIN",
-       .type = V4L2_CTRL_TYPE_INTEGER,
-       .min = 0,
-       .max = (1 << 12) - 1,
-       .step = 1,
-       .def = 0,
-};
-
-static const struct v4l2_ctrl_config vpfe_isif_cbgain = {
-       .ops = &vpfe_isif_ctrl_ops,
-       .id = VPFE_ISIF_CID_CBGAIN,
-       .name = "CBGAIN",
-       .type = V4L2_CTRL_TYPE_INTEGER,
-       .min = 0,
-       .max = (1 << 12) - 1,
-       .step = 1,
-       .def = 0,
-};
-
-static const struct v4l2_ctrl_config vpfe_isif_gain_offset = {
-       .ops = &vpfe_isif_ctrl_ops,
-       .id = VPFE_ISIF_CID_GAIN_OFFSET,
-       .name = "Gain Offset",
-       .type = V4L2_CTRL_TYPE_INTEGER,
-       .min = 0,
-       .max = (1 << 12) - 1,
-       .step = 1,
-       .def = 0,
-};
-
-static void isif_remove(struct vpfe_isif_device *isif,
-                       struct platform_device *pdev)
-{
-       struct resource *res;
-       int i = 0;
-
-       iounmap(isif->isif_cfg.base_addr);
-       iounmap(isif->isif_cfg.linear_tbl0_addr);
-       iounmap(isif->isif_cfg.linear_tbl1_addr);
-
-       while (i < 3) {
-               res = platform_get_resource(pdev, IORESOURCE_MEM, i);
-               if (res)
-                       release_mem_region(res->start,
-                                          resource_size(res));
-               i++;
-       }
-}
-
-static void isif_config_defaults(struct vpfe_isif_device *isif)
-{
-       isif->isif_cfg.ycbcr.v4l2_pix_fmt = V4L2_PIX_FMT_UYVY;
-       isif->isif_cfg.ycbcr.pix_fmt = ISIF_PIXFMT_YCBCR_8BIT;
-       isif->isif_cfg.ycbcr.frm_fmt = ISIF_FRMFMT_INTERLACED;
-       isif->isif_cfg.ycbcr.fid_pol = VPFE_PINPOL_POSITIVE;
-       isif->isif_cfg.ycbcr.vd_pol = VPFE_PINPOL_POSITIVE;
-       isif->isif_cfg.ycbcr.hd_pol = VPFE_PINPOL_POSITIVE;
-       isif->isif_cfg.ycbcr.pix_order = ISIF_PIXORDER_CBYCRY;
-       isif->isif_cfg.ycbcr.buf_type = ISIF_BUFTYPE_FLD_INTERLEAVED;
-
-       isif->isif_cfg.bayer.v4l2_pix_fmt = V4L2_PIX_FMT_SGRBG10ALAW8;
-       isif->isif_cfg.bayer.pix_fmt = ISIF_PIXFMT_RAW;
-       isif->isif_cfg.bayer.frm_fmt = ISIF_FRMFMT_PROGRESSIVE;
-       isif->isif_cfg.bayer.fid_pol = VPFE_PINPOL_POSITIVE;
-       isif->isif_cfg.bayer.vd_pol = VPFE_PINPOL_POSITIVE;
-       isif->isif_cfg.bayer.hd_pol = VPFE_PINPOL_POSITIVE;
-       isif->isif_cfg.bayer.cfa_pat = ISIF_CFA_PAT_MOSAIC;
-       isif->isif_cfg.bayer.data_msb = ISIF_BIT_MSB_11;
-       isif->isif_cfg.data_pack = ISIF_PACK_8BIT;
-}
-/*
- * vpfe_isif_init() - Initialize V4L2 subdev and media entity
- * @isif: VPFE isif module
- * @pdev: Pointer to platform device structure.
- * Return 0 on success and a negative error code on failure.
- */
-int vpfe_isif_init(struct vpfe_isif_device *isif, struct platform_device *pdev)
-{
-       struct v4l2_subdev *sd = &isif->subdev;
-       struct media_pad *pads = &isif->pads[0];
-       struct media_entity *me = &sd->entity;
-       static resource_size_t res_len;
-       struct resource *res;
-       void __iomem *addr;
-       int status;
-       int i = 0;
-
-       /* Get the ISIF base address, linearization table0 and table1 addr. */
-       while (i < 3) {
-               res = platform_get_resource(pdev, IORESOURCE_MEM, i);
-               if (!res) {
-                       status = -ENOENT;
-                       goto fail_nobase_res;
-               }
-               res_len = resource_size(res);
-               res = request_mem_region(res->start, res_len, res->name);
-               if (!res) {
-                       status = -EBUSY;
-                       goto fail_nobase_res;
-               }
-               addr = ioremap_nocache(res->start, res_len);
-               if (!addr) {
-                       status = -EBUSY;
-                       goto fail_base_iomap;
-               }
-               switch (i) {
-               case 0:
-                       /* ISIF base address */
-                       isif->isif_cfg.base_addr = addr;
-                       break;
-               case 1:
-                       /* ISIF linear tbl0 address */
-                       isif->isif_cfg.linear_tbl0_addr = addr;
-                       break;
-               default:
-                       /* ISIF linear tbl0 address */
-                       isif->isif_cfg.linear_tbl1_addr = addr;
-                       break;
-               }
-               i++;
-       }
-       davinci_cfg_reg(DM365_VIN_CAM_WEN);
-       davinci_cfg_reg(DM365_VIN_CAM_VD);
-       davinci_cfg_reg(DM365_VIN_CAM_HD);
-       davinci_cfg_reg(DM365_VIN_YIN4_7_EN);
-       davinci_cfg_reg(DM365_VIN_YIN0_3_EN);
-
-       /* queue ops */
-       isif->video_out.ops = &isif_video_ops;
-       v4l2_subdev_init(sd, &isif_v4l2_ops);
-       sd->internal_ops = &isif_v4l2_internal_ops;
-       strscpy(sd->name, "DAVINCI ISIF", sizeof(sd->name));
-       sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
-       v4l2_set_subdevdata(sd, isif);
-       sd->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE;
-       pads[ISIF_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
-       pads[ISIF_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
-
-       isif->input = ISIF_INPUT_NONE;
-       isif->output = ISIF_OUTPUT_NONE;
-       me->ops = &isif_media_ops;
-       status = media_entity_pads_init(me, ISIF_PADS_NUM, pads);
-       if (status)
-               goto isif_fail;
-       isif->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       status = vpfe_video_init(&isif->video_out, "ISIF");
-       if (status) {
-               pr_err("Failed to init isif-out video device\n");
-               goto isif_fail;
-       }
-       v4l2_ctrl_handler_init(&isif->ctrls, 6);
-       v4l2_ctrl_new_custom(&isif->ctrls, &vpfe_isif_crgain, NULL);
-       v4l2_ctrl_new_custom(&isif->ctrls, &vpfe_isif_cgrgain, NULL);
-       v4l2_ctrl_new_custom(&isif->ctrls, &vpfe_isif_cgbgain, NULL);
-       v4l2_ctrl_new_custom(&isif->ctrls, &vpfe_isif_cbgain, NULL);
-       v4l2_ctrl_new_custom(&isif->ctrls, &vpfe_isif_gain_offset, NULL);
-       v4l2_ctrl_new_custom(&isif->ctrls, &vpfe_isif_dpcm_pred, NULL);
-
-       v4l2_ctrl_handler_setup(&isif->ctrls);
-       sd->ctrl_handler = &isif->ctrls;
-       isif_config_defaults(isif);
-       return 0;
-fail_base_iomap:
-       release_mem_region(res->start, res_len);
-       i--;
-fail_nobase_res:
-       if (isif->isif_cfg.base_addr)
-               iounmap(isif->isif_cfg.base_addr);
-       if (isif->isif_cfg.linear_tbl0_addr)
-               iounmap(isif->isif_cfg.linear_tbl0_addr);
-
-       while (i >= 0) {
-               res = platform_get_resource(pdev, IORESOURCE_MEM, i);
-               release_mem_region(res->start, res_len);
-               i--;
-       }
-       return status;
-isif_fail:
-       v4l2_ctrl_handler_free(&isif->ctrls);
-       isif_remove(isif, pdev);
-       return status;
-}
-
-/*
- * vpfe_isif_cleanup - isif module cleanup
- * @isif: pointer to isif subdevice
- * @dev: pointer to platform device structure
- */
-void
-vpfe_isif_cleanup(struct vpfe_isif_device *isif, struct platform_device *pdev)
-{
-       isif_remove(isif, pdev);
-}
diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.h b/drivers/staging/media/davinci_vpfe/dm365_isif.h
deleted file mode 100644 (file)
index 0e1fe47..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#ifndef _DAVINCI_VPFE_DM365_ISIF_H
-#define _DAVINCI_VPFE_DM365_ISIF_H
-
-#include <linux/platform_device.h>
-
-#include <mach/mux.h>
-
-#include <media/davinci/vpfe_types.h>
-#include <media/v4l2-ctrls.h>
-#include <media/v4l2-device.h>
-
-#include "davinci_vpfe_user.h"
-#include "dm365_isif_regs.h"
-#include "vpfe_video.h"
-
-#define ISIF_CULLING_HCAPT_ODD         0xff
-#define ISIF_CULLING_HCAPT_EVEN                0xff
-#define ISIF_CULLING_VCAPT             0xff
-
-#define ISIF_CADU_BITS                 0x07ff
-#define ISIF_CADL_BITS                 0x0ffff
-
-enum isif_pixfmt {
-       ISIF_PIXFMT_RAW = 0,
-       ISIF_PIXFMT_YCBCR_16BIT = 1,
-       ISIF_PIXFMT_YCBCR_8BIT = 2,
-};
-
-enum isif_frmfmt {
-       ISIF_FRMFMT_PROGRESSIVE = 0,
-       ISIF_FRMFMT_INTERLACED = 1,
-};
-
-/* PIXEL ORDER IN MEMORY from LSB to MSB */
-/* only applicable for 8-bit input mode  */
-enum isif_pixorder {
-       ISIF_PIXORDER_YCBYCR = 0,
-       ISIF_PIXORDER_CBYCRY = 1,
-};
-
-enum isif_buftype {
-       ISIF_BUFTYPE_FLD_INTERLEAVED = 0,
-       ISIF_BUFTYPE_FLD_SEPARATED = 1,
-};
-
-struct isif_ycbcr_config {
-       /* v4l2 pixel format */
-       unsigned long v4l2_pix_fmt;
-       /* isif pixel format */
-       enum isif_pixfmt pix_fmt;
-       /* isif frame format */
-       enum isif_frmfmt frm_fmt;
-       /* isif crop window */
-       struct v4l2_rect win;
-       /* field polarity */
-       enum vpfe_pin_pol fid_pol;
-       /* interface VD polarity */
-       enum vpfe_pin_pol vd_pol;
-       /* interface HD polarity */
-       enum vpfe_pin_pol hd_pol;
-       /* isif pix order. Only used for ycbcr capture */
-       enum isif_pixorder pix_order;
-       /* isif buffer type. Only used for ycbcr capture */
-       enum isif_buftype buf_type;
-};
-
-enum isif_cfa_pattern {
-       ISIF_CFA_PAT_MOSAIC = 0,
-       ISIF_CFA_PAT_STRIPE = 1,
-};
-
-enum isif_data_msb {
-       /* MSB b15 */
-       ISIF_BIT_MSB_15 = 0,
-       /* MSB b14 */
-       ISIF_BIT_MSB_14 = 1,
-       /* MSB b13 */
-       ISIF_BIT_MSB_13 = 2,
-       /* MSB b12 */
-       ISIF_BIT_MSB_12 = 3,
-       /* MSB b11 */
-       ISIF_BIT_MSB_11 = 4,
-       /* MSB b10 */
-       ISIF_BIT_MSB_10 = 5,
-       /* MSB b9 */
-       ISIF_BIT_MSB_9 = 6,
-       /* MSB b8 */
-       ISIF_BIT_MSB_8 = 7,
-       /* MSB b7 */
-       ISIF_BIT_MSB_7 = 8,
-};
-
-struct isif_params_raw {
-       /* v4l2 pixel format */
-       unsigned long v4l2_pix_fmt;
-       /* isif pixel format */
-       enum isif_pixfmt pix_fmt;
-       /* isif frame format */
-       enum isif_frmfmt frm_fmt;
-       /* video window */
-       struct v4l2_rect win;
-       /* field polarity */
-       enum vpfe_pin_pol fid_pol;
-       /* interface VD polarity */
-       enum vpfe_pin_pol vd_pol;
-       /* interface HD polarity */
-       enum vpfe_pin_pol hd_pol;
-       /* buffer type. Applicable for interlaced mode */
-       enum isif_buftype buf_type;
-       /* cfa pattern */
-       enum isif_cfa_pattern cfa_pat;
-       /* Data MSB position */
-       enum isif_data_msb data_msb;
-       /* Enable horizontal flip */
-       unsigned char horz_flip_en;
-       /* Enable image invert vertically */
-       unsigned char image_invert_en;
-       unsigned char dpcm_predictor;
-       struct vpfe_isif_raw_config config_params;
-};
-
-enum isif_data_pack {
-       ISIF_PACK_16BIT = 0,
-       ISIF_PACK_12BIT = 1,
-       ISIF_PACK_8BIT = 2,
-};
-
-struct isif_gain_values {
-       unsigned int cr_gain;
-       unsigned int cgr_gain;
-       unsigned int cgb_gain;
-       unsigned int cb_gain;
-       unsigned int offset;
-};
-
-struct isif_oper_config {
-       struct isif_ycbcr_config ycbcr;
-       struct isif_params_raw bayer;
-       enum isif_data_pack data_pack;
-       struct isif_gain_values isif_gain_params;
-       void __iomem *base_addr;
-       void __iomem *linear_tbl0_addr;
-       void __iomem *linear_tbl1_addr;
-};
-
-#define ISIF_PAD_SINK      0
-#define ISIF_PAD_SOURCE    1
-
-#define ISIF_PADS_NUM      2
-
-enum isif_input_entity {
-       ISIF_INPUT_NONE = 0,
-       ISIF_INPUT_PARALLEL = 1,
-};
-
-#define ISIF_OUTPUT_NONE       (0)
-#define ISIF_OUTPUT_MEMORY     (1 << 0)
-#define ISIF_OUTPUT_IPIPEIF    (1 << 1)
-
-struct vpfe_isif_device {
-       struct v4l2_subdev              subdev;
-       struct media_pad                pads[ISIF_PADS_NUM];
-       struct v4l2_mbus_framefmt       formats[ISIF_PADS_NUM];
-       enum isif_input_entity          input;
-       unsigned int                    output;
-       struct v4l2_ctrl_handler        ctrls;
-       struct v4l2_rect                crop;
-       struct isif_oper_config         isif_cfg;
-       struct vpfe_video_device        video_out;
-};
-
-enum v4l2_field vpfe_isif_get_fid(struct vpfe_device *vpfe_dev);
-void vpfe_isif_unregister_entities(struct vpfe_isif_device *isif);
-int vpfe_isif_register_entities(struct vpfe_isif_device *isif,
-                               struct v4l2_device *dev);
-int vpfe_isif_init(struct vpfe_isif_device *isif, struct platform_device *pdev);
-void vpfe_isif_cleanup(struct vpfe_isif_device *vpfe_isif,
-                      struct platform_device *pdev);
-void vpfe_isif_vidint1_isr(struct vpfe_isif_device *isif);
-void vpfe_isif_buffer_isr(struct vpfe_isif_device *isif);
-
-#endif         /* _DAVINCI_VPFE_DM365_ISIF_H */
diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif_regs.h b/drivers/staging/media/davinci_vpfe/dm365_isif_regs.h
deleted file mode 100644 (file)
index 6695680..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#ifndef _DAVINCI_VPFE_DM365_ISIF_REGS_H
-#define _DAVINCI_VPFE_DM365_ISIF_REGS_H
-
-/* ISIF registers relative offsets */
-#define SYNCEN                                 0x00
-#define MODESET                                        0x04
-#define HDW                                    0x08
-#define VDW                                    0x0c
-#define PPLN                                   0x10
-#define LPFR                                   0x14
-#define SPH                                    0x18
-#define LNH                                    0x1c
-#define SLV0                                   0x20
-#define SLV1                                   0x24
-#define LNV                                    0x28
-#define CULH                                   0x2c
-#define CULV                                   0x30
-#define HSIZE                                  0x34
-#define SDOFST                                 0x38
-#define CADU                                   0x3c
-#define CADL                                   0x40
-#define LINCFG0                                        0x44
-#define LINCFG1                                        0x48
-#define CCOLP                                  0x4c
-#define CRGAIN                                 0x50
-#define CGRGAIN                                        0x54
-#define CGBGAIN                                        0x58
-#define CBGAIN                                 0x5c
-#define COFSTA                                 0x60
-#define FLSHCFG0                               0x64
-#define FLSHCFG1                               0x68
-#define FLSHCFG2                               0x6c
-#define VDINT0                                 0x70
-#define VDINT1                                 0x74
-#define VDINT2                                 0x78
-#define MISC                                   0x7c
-#define CGAMMAWD                               0x80
-#define REC656IF                               0x84
-#define CCDCFG                                 0x88
-/*****************************************************
- * Defect Correction registers
- *****************************************************/
-#define DFCCTL                                 0x8c
-#define VDFSATLV                               0x90
-#define DFCMEMCTL                              0x94
-#define DFCMEM0                                        0x98
-#define DFCMEM1                                        0x9c
-#define DFCMEM2                                        0xa0
-#define DFCMEM3                                        0xa4
-#define DFCMEM4                                        0xa8
-/****************************************************
- * Black Clamp registers
- ****************************************************/
-#define CLAMPCFG                               0xac
-#define CLDCOFST                               0xb0
-#define CLSV                                   0xb4
-#define CLHWIN0                                        0xb8
-#define CLHWIN1                                        0xbc
-#define CLHWIN2                                        0xc0
-#define CLVRV                                  0xc4
-#define CLVWIN0                                        0xc8
-#define CLVWIN1                                        0xcc
-#define CLVWIN2                                        0xd0
-#define CLVWIN3                                        0xd4
-/****************************************************
- * Lense Shading Correction
- ****************************************************/
-#define DATAHOFST                              0xd8
-#define DATAVOFST                              0xdc
-#define LSCHVAL                                        0xe0
-#define LSCVVAL                                        0xe4
-#define TWODLSCCFG                             0xe8
-#define TWODLSCOFST                            0xec
-#define TWODLSCINI                             0xf0
-#define TWODLSCGRBU                            0xf4
-#define TWODLSCGRBL                            0xf8
-#define TWODLSCGROF                            0xfc
-#define TWODLSCORBU                            0x100
-#define TWODLSCORBL                            0x104
-#define TWODLSCOROF                            0x108
-#define TWODLSCIRQEN                           0x10c
-#define TWODLSCIRQST                           0x110
-/****************************************************
- * Data formatter
- ****************************************************/
-#define FMTCFG                                 0x114
-#define FMTPLEN                                        0x118
-#define FMTSPH                                 0x11c
-#define FMTLNH                                 0x120
-#define FMTSLV                                 0x124
-#define FMTLNV                                 0x128
-#define FMTRLEN                                        0x12c
-#define FMTHCNT                                        0x130
-#define FMTAPTR_BASE                           0x134
-/* Below macro for addresses FMTAPTR0 - FMTAPTR15 */
-#define FMTAPTR(i)                     (FMTAPTR_BASE + (i * 4))
-#define FMTPGMVF0                              0x174
-#define FMTPGMVF1                              0x178
-#define FMTPGMAPU0                             0x17c
-#define FMTPGMAPU1                             0x180
-#define FMTPGMAPS0                             0x184
-#define FMTPGMAPS1                             0x188
-#define FMTPGMAPS2                             0x18c
-#define FMTPGMAPS3                             0x190
-#define FMTPGMAPS4                             0x194
-#define FMTPGMAPS5                             0x198
-#define FMTPGMAPS6                             0x19c
-#define FMTPGMAPS7                             0x1a0
-/************************************************
- * Color Space Converter
- ************************************************/
-#define CSCCTL                                 0x1a4
-#define CSCM0                                  0x1a8
-#define CSCM1                                  0x1ac
-#define CSCM2                                  0x1b0
-#define CSCM3                                  0x1b4
-#define CSCM4                                  0x1b8
-#define CSCM5                                  0x1bc
-#define CSCM6                                  0x1c0
-#define CSCM7                                  0x1c4
-#define OBWIN0                                 0x1c8
-#define OBWIN1                                 0x1cc
-#define OBWIN2                                 0x1d0
-#define OBWIN3                                 0x1d4
-#define OBVAL0                                 0x1d8
-#define OBVAL1                                 0x1dc
-#define OBVAL2                                 0x1e0
-#define OBVAL3                                 0x1e4
-#define OBVAL4                                 0x1e8
-#define OBVAL5                                 0x1ec
-#define OBVAL6                                 0x1f0
-#define OBVAL7                                 0x1f4
-#define CLKCTL                                 0x1f8
-
-/* Masks & Shifts below */
-#define START_PX_HOR_MASK                      0x7fff
-#define NUM_PX_HOR_MASK                                0x7fff
-#define START_VER_ONE_MASK                     0x7fff
-#define START_VER_TWO_MASK                     0x7fff
-#define NUM_LINES_VER                          0x7fff
-
-/* gain - offset masks */
-#define OFFSET_MASK                            0xfff
-#define GAIN_SDRAM_EN_SHIFT                    12
-#define GAIN_IPIPE_EN_SHIFT                    13
-#define GAIN_H3A_EN_SHIFT                      14
-#define OFST_SDRAM_EN_SHIFT                    8
-#define OFST_IPIPE_EN_SHIFT                    9
-#define OFST_H3A_EN_SHIFT                      10
-#define GAIN_OFFSET_EN_MASK                    0x7700
-
-/* Culling */
-#define CULL_PAT_EVEN_LINE_SHIFT               8
-
-/* CCDCFG register */
-#define ISIF_YCINSWP_RAW                       (0x00 << 4)
-#define ISIF_YCINSWP_YCBCR                     (0x01 << 4)
-#define ISIF_CCDCFG_FIDMD_LATCH_VSYNC          (0x00 << 6)
-#define ISIF_CCDCFG_WENLOG_AND                 (0x00 << 8)
-#define ISIF_CCDCFG_TRGSEL_WEN                 (0x00 << 9)
-#define ISIF_CCDCFG_EXTRG_DISABLE              (0x00 << 10)
-#define ISIF_LATCH_ON_VSYNC_DISABLE            (0x01 << 15)
-#define ISIF_LATCH_ON_VSYNC_ENABLE             (0x00 << 15)
-#define ISIF_DATA_PACK_MASK                    0x03
-#define ISIF_PIX_ORDER_SHIFT                   11
-#define ISIF_PIX_ORDER_MASK                    0x01
-#define ISIF_BW656_ENABLE                      (0x01 << 5)
-
-/* MODESET registers */
-#define ISIF_VDHDOUT_INPUT                     (0x00 << 0)
-#define ISIF_INPUT_MASK                                0x03
-#define ISIF_INPUT_SHIFT                       12
-#define ISIF_FID_POL_MASK                      0x01
-#define ISIF_FID_POL_SHIFT                     4
-#define ISIF_HD_POL_MASK                       0x01
-#define ISIF_HD_POL_SHIFT                      3
-#define ISIF_VD_POL_MASK                       0x01
-#define ISIF_VD_POL_SHIFT                      2
-#define ISIF_DATAPOL_NORMAL                    0x00
-#define ISIF_DATAPOL_MASK                      0x01
-#define ISIF_DATAPOL_SHIFT                     6
-#define ISIF_EXWEN_DISABLE                     0x00
-#define ISIF_EXWEN_MASK                                0x01
-#define ISIF_EXWEN_SHIFT                       5
-#define ISIF_FRM_FMT_MASK                      0x01
-#define ISIF_FRM_FMT_SHIFT                     7
-#define ISIF_DATASFT_MASK                      0x07
-#define ISIF_DATASFT_SHIFT                     8
-#define ISIF_LPF_SHIFT                         14
-#define ISIF_LPF_MASK                          0x1
-
-/* GAMMAWD registers */
-#define ISIF_ALAW_GAMA_WD_MASK                 0xf
-#define ISIF_ALAW_GAMA_WD_SHIFT                        1
-#define ISIF_ALAW_ENABLE                       0x01
-#define ISIF_GAMMAWD_CFA_MASK                  0x01
-#define ISIF_GAMMAWD_CFA_SHIFT                 5
-
-/* HSIZE registers */
-#define ISIF_HSIZE_FLIP_MASK                   0x01
-#define ISIF_HSIZE_FLIP_SHIFT                  12
-#define ISIF_LINEOFST_MASK                     0xfff
-
-/* MISC registers */
-#define ISIF_DPCM_EN_SHIFT                     12
-#define ISIF_DPCM_PREDICTOR_SHIFT              13
-#define ISIF_DPCM_PREDICTOR_MASK               1
-
-/* Black clamp related */
-#define ISIF_BC_DCOFFSET_MASK                  0x1fff
-#define ISIF_BC_MODE_COLOR_MASK                        1
-#define ISIF_BC_MODE_COLOR_SHIFT               4
-#define ISIF_HORZ_BC_MODE_MASK                 3
-#define ISIF_HORZ_BC_MODE_SHIFT                        1
-#define ISIF_HORZ_BC_WIN_COUNT_MASK            0x1f
-#define ISIF_HORZ_BC_WIN_SEL_SHIFT             5
-#define ISIF_HORZ_BC_PIX_LIMIT_SHIFT           6
-#define ISIF_HORZ_BC_WIN_H_SIZE_MASK           3
-#define ISIF_HORZ_BC_WIN_H_SIZE_SHIFT          8
-#define ISIF_HORZ_BC_WIN_V_SIZE_MASK           3
-#define ISIF_HORZ_BC_WIN_V_SIZE_SHIFT          12
-#define ISIF_HORZ_BC_WIN_START_H_MASK          0x1fff
-#define ISIF_HORZ_BC_WIN_START_V_MASK          0x1fff
-#define ISIF_VERT_BC_OB_H_SZ_MASK              7
-#define ISIF_VERT_BC_RST_VAL_SEL_MASK          3
-#define ISIF_VERT_BC_RST_VAL_SEL_SHIFT         4
-#define ISIF_VERT_BC_LINE_AVE_COEF_SHIFT       8
-#define ISIF_VERT_BC_OB_START_HORZ_MASK                0x1fff
-#define ISIF_VERT_BC_OB_START_VERT_MASK                0x1fff
-#define ISIF_VERT_BC_OB_VERT_SZ_MASK           0x1fff
-#define ISIF_VERT_BC_RST_VAL_MASK              0xfff
-#define ISIF_BC_VERT_START_SUB_V_MASK          0x1fff
-
-/* VDFC registers */
-#define ISIF_VDFC_EN_SHIFT                     4
-#define ISIF_VDFC_CORR_MOD_MASK                        3
-#define ISIF_VDFC_CORR_MOD_SHIFT               5
-#define ISIF_VDFC_CORR_WHOLE_LN_SHIFT          7
-#define ISIF_VDFC_LEVEL_SHFT_MASK              7
-#define ISIF_VDFC_LEVEL_SHFT_SHIFT             8
-#define ISIF_VDFC_SAT_LEVEL_MASK               0xfff
-#define ISIF_VDFC_POS_MASK                     0x1fff
-#define ISIF_DFCMEMCTL_DFCMARST_SHIFT          2
-
-/* CSC registers */
-#define ISIF_CSC_COEF_INTEG_MASK               7
-#define ISIF_CSC_COEF_DECIMAL_MASK             0x1f
-#define ISIF_CSC_COEF_INTEG_SHIFT              5
-#define ISIF_CSCM_MSB_SHIFT                    8
-#define ISIF_DF_CSC_SPH_MASK                   0x1fff
-#define ISIF_DF_CSC_LNH_MASK                   0x1fff
-#define ISIF_DF_CSC_SLV_MASK                   0x1fff
-#define ISIF_DF_CSC_LNV_MASK                   0x1fff
-#define ISIF_DF_NUMLINES                       0x7fff
-#define ISIF_DF_NUMPIX                         0x1fff
-
-/* Offsets for LSC/DFC/Gain */
-#define ISIF_DATA_H_OFFSET_MASK                        0x1fff
-#define ISIF_DATA_V_OFFSET_MASK                        0x1fff
-
-/* Linearization */
-#define ISIF_LIN_CORRSFT_MASK                  7
-#define ISIF_LIN_CORRSFT_SHIFT                 4
-#define ISIF_LIN_SCALE_FACT_INTEG_SHIFT                10
-#define ISIF_LIN_SCALE_FACT_DECIMAL_MASK       0x3ff
-#define ISIF_LIN_ENTRY_MASK                    0x3ff
-
-/* masks and shifts*/
-#define ISIF_SYNCEN_VDHDEN_MASK                        (1 << 0)
-#define ISIF_SYNCEN_WEN_MASK                   (1 << 1)
-#define ISIF_SYNCEN_WEN_SHIFT                  1
-
-#endif         /* _DAVINCI_VPFE_DM365_ISIF_REGS_H */
diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
deleted file mode 100644 (file)
index 7adf1fa..0000000
+++ /dev/null
@@ -1,1995 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- *
- *
- * Resizer allows upscaling or downscaling a image to a desired
- * resolution. There are 2 resizer modules. both operating on the
- * same input image, but can have different output resolution.
- */
-
-#include "dm365_ipipe_hw.h"
-#include "dm365_resizer.h"
-
-#define MIN_IN_WIDTH           32
-#define MIN_IN_HEIGHT          32
-#define MAX_IN_WIDTH           4095
-#define MAX_IN_HEIGHT          4095
-#define MIN_OUT_WIDTH          16
-#define MIN_OUT_HEIGHT         2
-
-static const unsigned int resizer_input_formats[] = {
-       MEDIA_BUS_FMT_UYVY8_2X8,
-       MEDIA_BUS_FMT_Y8_1X8,
-       MEDIA_BUS_FMT_UV8_1X8,
-       MEDIA_BUS_FMT_SGRBG12_1X12,
-};
-
-static const unsigned int resizer_output_formats[] = {
-       MEDIA_BUS_FMT_UYVY8_2X8,
-       MEDIA_BUS_FMT_Y8_1X8,
-       MEDIA_BUS_FMT_UV8_1X8,
-       MEDIA_BUS_FMT_YDYUYDYV8_1X16,
-       MEDIA_BUS_FMT_SGRBG12_1X12,
-};
-
-/* resizer_calculate_line_length() - This function calculates the line length of
- *                                  various image planes at the input and
- *                                  output.
- */
-static void
-resizer_calculate_line_length(u32 pix, int width, int height,
-                             int *line_len, int *line_len_c)
-{
-       *line_len = 0;
-       *line_len_c = 0;
-
-       if (pix == MEDIA_BUS_FMT_UYVY8_2X8 ||
-           pix == MEDIA_BUS_FMT_SGRBG12_1X12) {
-               *line_len = width << 1;
-       } else {
-               *line_len = width;
-               *line_len_c = width;
-       }
-
-       /* adjust the line len to be a multiple of 32 */
-       *line_len += 31;
-       *line_len &= ~0x1f;
-       *line_len_c += 31;
-       *line_len_c &= ~0x1f;
-}
-
-static inline int
-resizer_validate_output_image_format(struct device *dev,
-                                    struct v4l2_mbus_framefmt *format,
-                                    int *in_line_len, int *in_line_len_c)
-{
-       if (format->code != MEDIA_BUS_FMT_UYVY8_2X8 &&
-           format->code != MEDIA_BUS_FMT_Y8_1X8 &&
-           format->code != MEDIA_BUS_FMT_UV8_1X8 &&
-           format->code != MEDIA_BUS_FMT_YDYUYDYV8_1X16 &&
-           format->code != MEDIA_BUS_FMT_SGRBG12_1X12) {
-               dev_err(dev, "Invalid Mbus format, %d\n", format->code);
-               return -EINVAL;
-       }
-       if (!format->width || !format->height) {
-               dev_err(dev, "invalid width or height\n");
-               return -EINVAL;
-       }
-       resizer_calculate_line_length(format->code, format->width,
-               format->height, in_line_len, in_line_len_c);
-       return 0;
-}
-
-static void
-resizer_configure_passthru(struct vpfe_resizer_device *resizer, int bypass)
-{
-       struct resizer_params *param = &resizer->config;
-
-       param->rsz_rsc_param[RSZ_A].cen = DISABLE;
-       param->rsz_rsc_param[RSZ_A].yen = DISABLE;
-       param->rsz_rsc_param[RSZ_A].v_phs_y = 0;
-       param->rsz_rsc_param[RSZ_A].v_phs_c = 0;
-       param->rsz_rsc_param[RSZ_A].v_dif = 256;
-       param->rsz_rsc_param[RSZ_A].v_lpf_int_y = 0;
-       param->rsz_rsc_param[RSZ_A].v_lpf_int_c = 0;
-       param->rsz_rsc_param[RSZ_A].h_phs = 0;
-       param->rsz_rsc_param[RSZ_A].h_dif = 256;
-       param->rsz_rsc_param[RSZ_A].h_lpf_int_y = 0;
-       param->rsz_rsc_param[RSZ_A].h_lpf_int_c = 0;
-       param->rsz_rsc_param[RSZ_A].dscale_en = DISABLE;
-       param->rsz2rgb[RSZ_A].rgb_en = DISABLE;
-       param->rsz_en[RSZ_A] = ENABLE;
-       param->rsz_en[RSZ_B] = DISABLE;
-       if (bypass) {
-               param->rsz_rsc_param[RSZ_A].i_vps = 0;
-               param->rsz_rsc_param[RSZ_A].i_hps = 0;
-               /* Raw Bypass */
-               param->rsz_common.passthrough = BYPASS_ON;
-       }
-}
-
-static void
-configure_resizer_out_params(struct vpfe_resizer_device *resizer, int index,
-                            void *output_spec, unsigned char partial,
-                            unsigned int flag)
-{
-       struct resizer_params *param = &resizer->config;
-       struct v4l2_mbus_framefmt *outformat;
-       struct vpfe_rsz_output_spec *output;
-
-       if (index == RSZ_A &&
-           resizer->resizer_a.output == RESIZER_OUTPUT_NONE) {
-               param->rsz_en[index] = DISABLE;
-               return;
-       }
-       if (index == RSZ_B &&
-           resizer->resizer_b.output == RESIZER_OUTPUT_NONE) {
-               param->rsz_en[index] = DISABLE;
-               return;
-       }
-       output = output_spec;
-       param->rsz_en[index] = ENABLE;
-       if (partial) {
-               param->rsz_rsc_param[index].h_flip = output->h_flip;
-               param->rsz_rsc_param[index].v_flip = output->v_flip;
-               param->rsz_rsc_param[index].v_typ_y = output->v_typ_y;
-               param->rsz_rsc_param[index].v_typ_c = output->v_typ_c;
-               param->rsz_rsc_param[index].v_lpf_int_y =
-                                               output->v_lpf_int_y;
-               param->rsz_rsc_param[index].v_lpf_int_c =
-                                               output->v_lpf_int_c;
-               param->rsz_rsc_param[index].h_typ_y = output->h_typ_y;
-               param->rsz_rsc_param[index].h_typ_c = output->h_typ_c;
-               param->rsz_rsc_param[index].h_lpf_int_y =
-                                               output->h_lpf_int_y;
-               param->rsz_rsc_param[index].h_lpf_int_c =
-                                               output->h_lpf_int_c;
-               param->rsz_rsc_param[index].dscale_en =
-                                               output->en_down_scale;
-               param->rsz_rsc_param[index].h_dscale_ave_sz =
-                                               output->h_dscale_ave_sz;
-               param->rsz_rsc_param[index].v_dscale_ave_sz =
-                                               output->v_dscale_ave_sz;
-               param->ext_mem_param[index].user_y_ofst =
-                                   (output->user_y_ofst + 31) & ~0x1f;
-               param->ext_mem_param[index].user_c_ofst =
-                                   (output->user_c_ofst + 31) & ~0x1f;
-               return;
-       }
-
-       if (index == RSZ_A)
-               outformat = &resizer->resizer_a.formats[RESIZER_PAD_SOURCE];
-       else
-               outformat = &resizer->resizer_b.formats[RESIZER_PAD_SOURCE];
-       param->rsz_rsc_param[index].o_vsz = outformat->height - 1;
-       param->rsz_rsc_param[index].o_hsz = outformat->width - 1;
-       param->ext_mem_param[index].rsz_sdr_ptr_s_y = output->vst_y;
-       param->ext_mem_param[index].rsz_sdr_ptr_e_y = outformat->height;
-       param->ext_mem_param[index].rsz_sdr_ptr_s_c = output->vst_c;
-       param->ext_mem_param[index].rsz_sdr_ptr_e_c = outformat->height;
-
-       if (!flag)
-               return;
-       /* update common parameters */
-       param->rsz_rsc_param[index].h_flip = output->h_flip;
-       param->rsz_rsc_param[index].v_flip = output->v_flip;
-       param->rsz_rsc_param[index].v_typ_y = output->v_typ_y;
-       param->rsz_rsc_param[index].v_typ_c = output->v_typ_c;
-       param->rsz_rsc_param[index].v_lpf_int_y = output->v_lpf_int_y;
-       param->rsz_rsc_param[index].v_lpf_int_c = output->v_lpf_int_c;
-       param->rsz_rsc_param[index].h_typ_y = output->h_typ_y;
-       param->rsz_rsc_param[index].h_typ_c = output->h_typ_c;
-       param->rsz_rsc_param[index].h_lpf_int_y = output->h_lpf_int_y;
-       param->rsz_rsc_param[index].h_lpf_int_c = output->h_lpf_int_c;
-       param->rsz_rsc_param[index].dscale_en = output->en_down_scale;
-       param->rsz_rsc_param[index].h_dscale_ave_sz = output->h_dscale_ave_sz;
-       param->rsz_rsc_param[index].v_dscale_ave_sz = output->h_dscale_ave_sz;
-       param->ext_mem_param[index].user_y_ofst =
-                                       (output->user_y_ofst + 31) & ~0x1f;
-       param->ext_mem_param[index].user_c_ofst =
-                                       (output->user_c_ofst + 31) & ~0x1f;
-}
-
-/*
- * resizer_calculate_resize_ratios() - Calculates resize ratio for resizer
- *                                   A or B. This is called after setting
- *                                  the input size or output size.
- * @resizer: Pointer to VPFE resizer subdevice.
- * @index: index RSZ_A-resizer-A RSZ_B-resizer-B.
- */
-static void
-resizer_calculate_resize_ratios(struct vpfe_resizer_device *resizer, int index)
-{
-       struct resizer_params *param = &resizer->config;
-       struct v4l2_mbus_framefmt *informat, *outformat;
-
-       informat = &resizer->crop_resizer.formats[RESIZER_CROP_PAD_SINK];
-
-       if (index == RSZ_A)
-               outformat = &resizer->resizer_a.formats[RESIZER_PAD_SOURCE];
-       else
-               outformat = &resizer->resizer_b.formats[RESIZER_PAD_SOURCE];
-
-       if (outformat->field != V4L2_FIELD_INTERLACED)
-               param->rsz_rsc_param[index].v_dif =
-                       ((informat->height) * 256) / (outformat->height);
-       else
-               param->rsz_rsc_param[index].v_dif =
-                       ((informat->height >> 1) * 256) / (outformat->height);
-       param->rsz_rsc_param[index].h_dif =
-                       ((informat->width) * 256) / (outformat->width);
-}
-
-static void resizer_enable_422_420_conversion(struct resizer_params *param,
-                                             int index, bool en)
-{
-       param->rsz_rsc_param[index].cen = en;
-       param->rsz_rsc_param[index].yen = en;
-}
-
-/* resizer_calculate_sdram_offsets() - This function calculates the offsets from
- *                                    start of buffer for the C plane when
- *                                    output format is YUV420SP. It also
- *                                    calculates the offsets from the start of
- *                                    the buffer when the image is flipped
- *                                    vertically or horizontally for ycbcr/y/c
- *                                    planes.
- * @resizer: Pointer to resizer subdevice.
- * @index: index RSZ_A-resizer-A RSZ_B-resizer-B.
- */
-static int
-resizer_calculate_sdram_offsets(struct vpfe_resizer_device *resizer, int index)
-{
-       struct resizer_params *param = &resizer->config;
-       struct v4l2_mbus_framefmt *outformat;
-       int bytesperpixel = 2;
-       int image_height;
-       int image_width;
-       int yuv_420 = 0;
-       int offset = 0;
-
-       if (index == RSZ_A)
-               outformat = &resizer->resizer_a.formats[RESIZER_PAD_SOURCE];
-       else
-               outformat = &resizer->resizer_b.formats[RESIZER_PAD_SOURCE];
-
-       image_height = outformat->height + 1;
-       image_width = outformat->width + 1;
-       param->ext_mem_param[index].c_offset = 0;
-       param->ext_mem_param[index].flip_ofst_y = 0;
-       param->ext_mem_param[index].flip_ofst_c = 0;
-       if (outformat->code == MEDIA_BUS_FMT_YDYUYDYV8_1X16) {
-               /* YUV 420 */
-               yuv_420 = 1;
-               bytesperpixel = 1;
-       }
-
-       if (param->rsz_rsc_param[index].h_flip)
-               /* width * bytesperpixel - 1 */
-               offset = (image_width * bytesperpixel) - 1;
-       if (param->rsz_rsc_param[index].v_flip)
-               offset += (image_height - 1) *
-                       param->ext_mem_param[index].rsz_sdr_oft_y;
-       param->ext_mem_param[index].flip_ofst_y = offset;
-       if (!yuv_420)
-               return 0;
-       offset = 0;
-       /* half height for c-plane */
-       if (param->rsz_rsc_param[index].h_flip)
-               /* width * bytesperpixel - 1 */
-               offset = image_width - 1;
-       if (param->rsz_rsc_param[index].v_flip)
-               offset += (((image_height >> 1) - 1) *
-                          param->ext_mem_param[index].rsz_sdr_oft_c);
-       param->ext_mem_param[index].flip_ofst_c = offset;
-       param->ext_mem_param[index].c_offset =
-                     param->ext_mem_param[index].rsz_sdr_oft_y * image_height;
-       return 0;
-}
-
-static int resizer_configure_output_win(struct vpfe_resizer_device *resizer)
-{
-       struct resizer_params *param = &resizer->config;
-       struct vpfe_rsz_output_spec output_specs;
-       struct v4l2_mbus_framefmt *outformat;
-       int line_len_c;
-       int line_len;
-       int ret;
-
-       outformat = &resizer->resizer_a.formats[RESIZER_PAD_SOURCE];
-
-       memset(&output_specs, 0x0, sizeof(struct vpfe_rsz_output_spec));
-       output_specs.vst_y = param->user_config.vst;
-       if (outformat->code == MEDIA_BUS_FMT_YDYUYDYV8_1X16)
-               output_specs.vst_c = param->user_config.vst;
-
-       configure_resizer_out_params(resizer, RSZ_A, &output_specs, 0, 0);
-       resizer_calculate_line_length(outformat->code,
-                                     param->rsz_rsc_param[0].o_hsz + 1,
-                                     param->rsz_rsc_param[0].o_vsz + 1,
-                                     &line_len, &line_len_c);
-       param->ext_mem_param[0].rsz_sdr_oft_y = line_len;
-       param->ext_mem_param[0].rsz_sdr_oft_c = line_len_c;
-       resizer_calculate_resize_ratios(resizer, RSZ_A);
-       if (param->rsz_en[RSZ_B])
-               resizer_calculate_resize_ratios(resizer, RSZ_B);
-
-       if (outformat->code == MEDIA_BUS_FMT_YDYUYDYV8_1X16)
-               resizer_enable_422_420_conversion(param, RSZ_A, ENABLE);
-       else
-               resizer_enable_422_420_conversion(param, RSZ_A, DISABLE);
-
-       ret = resizer_calculate_sdram_offsets(resizer, RSZ_A);
-       if (!ret && param->rsz_en[RSZ_B])
-               ret = resizer_calculate_sdram_offsets(resizer, RSZ_B);
-
-       if (ret)
-               pr_err("Error in calculating sdram offsets\n");
-       return ret;
-}
-
-static int
-resizer_calculate_down_scale_f_div_param(struct device *dev,
-                                        int input_width, int output_width,
-                                        struct resizer_scale_param *param)
-{
-       /* rsz = R, input_width = H, output width = h in the equation */
-       unsigned int two_power;
-       unsigned int upper_h1;
-       unsigned int upper_h2;
-       unsigned int val1;
-       unsigned int val;
-       unsigned int rsz;
-       unsigned int h1;
-       unsigned int h2;
-       unsigned int o;
-       unsigned int n;
-
-       upper_h1 = input_width >> 1;
-       n = param->h_dscale_ave_sz;
-       /* 2 ^ (scale+1) */
-       two_power = 1 << (n + 1);
-       upper_h1 = (upper_h1 >> (n + 1)) << (n + 1);
-       upper_h2 = input_width - upper_h1;
-       if (upper_h2 % two_power) {
-               dev_err(dev, "frame halves to be a multiple of 2 power n+1\n");
-               return -EINVAL;
-       }
-       two_power = 1 << n;
-       rsz = (input_width << 8) / output_width;
-       val = rsz * two_power;
-       val = ((upper_h1 << 8) / val) + 1;
-       if (!(val % 2)) {
-               h1 = val;
-       } else {
-               val = upper_h1 << 8;
-               val >>= n + 1;
-               val -= rsz >> 1;
-               val /= rsz << 1;
-               val <<= 1;
-               val += 2;
-               h1 = val;
-       }
-       o = 10 + (two_power << 2);
-       if (((input_width << 7) / rsz) % 2)
-               o += ((DIV_ROUND_UP(rsz, 1024) << 1) << n);
-       h2 = output_width - h1;
-       /* phi */
-       val = (h1 * rsz) - (((upper_h1 - (o - 10)) / two_power) << 8);
-       /* skip */
-       val1 = ((val - 1024) >> 9) << 1;
-       param->f_div.num_passes = MAX_PASSES;
-       param->f_div.pass[0].o_hsz = h1 - 1;
-       param->f_div.pass[0].i_hps = 0;
-       param->f_div.pass[0].h_phs = 0;
-       param->f_div.pass[0].src_hps = 0;
-       param->f_div.pass[0].src_hsz = upper_h1 + o;
-       param->f_div.pass[1].o_hsz = h2 - 1;
-       param->f_div.pass[1].i_hps = 10 + (val1 * two_power);
-       param->f_div.pass[1].h_phs = val - (val1 << 8);
-       param->f_div.pass[1].src_hps = upper_h1 - o;
-       param->f_div.pass[1].src_hsz = upper_h2 + o;
-
-       return 0;
-}
-
-static int
-resizer_configure_common_in_params(struct vpfe_resizer_device *resizer)
-{
-       struct vpfe_device *vpfe_dev = to_vpfe_device(resizer);
-       struct resizer_params *param = &resizer->config;
-       struct vpfe_rsz_config_params *user_config;
-       struct v4l2_mbus_framefmt *informat;
-
-       informat = &resizer->crop_resizer.formats[RESIZER_CROP_PAD_SINK];
-       user_config = &resizer->config.user_config;
-       param->rsz_common.vps = param->user_config.vst;
-       param->rsz_common.hps = param->user_config.hst;
-
-       if (vpfe_ipipeif_decimation_enabled(vpfe_dev))
-               param->rsz_common.hsz = ((informat->width - 1) *
-                       IPIPEIF_RSZ_CONST) / vpfe_ipipeif_get_rsz(vpfe_dev);
-       else
-               param->rsz_common.hsz = informat->width - 1;
-
-       if (informat->field == V4L2_FIELD_INTERLACED)
-               param->rsz_common.vsz  = (informat->height - 1) >> 1;
-       else
-               param->rsz_common.vsz  = informat->height - 1;
-
-       param->rsz_common.raw_flip = 0;
-
-       if (resizer->crop_resizer.input == RESIZER_CROP_INPUT_IPIPEIF)
-               param->rsz_common.source = IPIPEIF_DATA;
-       else
-               param->rsz_common.source = IPIPE_DATA;
-
-       switch (informat->code) {
-       case MEDIA_BUS_FMT_UYVY8_2X8:
-               param->rsz_common.src_img_fmt = RSZ_IMG_422;
-               param->rsz_common.raw_flip = 0;
-               break;
-
-       case MEDIA_BUS_FMT_Y8_1X8:
-               param->rsz_common.src_img_fmt = RSZ_IMG_420;
-               /* Select y */
-               param->rsz_common.y_c = 0;
-               param->rsz_common.raw_flip = 0;
-               break;
-
-       case MEDIA_BUS_FMT_UV8_1X8:
-               param->rsz_common.src_img_fmt = RSZ_IMG_420;
-               /* Select y */
-               param->rsz_common.y_c = 1;
-               param->rsz_common.raw_flip = 0;
-               break;
-
-       case MEDIA_BUS_FMT_SGRBG12_1X12:
-               param->rsz_common.raw_flip = 1;
-               break;
-
-       default:
-               param->rsz_common.src_img_fmt = RSZ_IMG_422;
-               param->rsz_common.source = IPIPE_DATA;
-       }
-
-       param->rsz_common.yuv_y_min = user_config->yuv_y_min;
-       param->rsz_common.yuv_y_max = user_config->yuv_y_max;
-       param->rsz_common.yuv_c_min = user_config->yuv_c_min;
-       param->rsz_common.yuv_c_max = user_config->yuv_c_max;
-       param->rsz_common.out_chr_pos = user_config->out_chr_pos;
-       param->rsz_common.rsz_seq_crv = user_config->chroma_sample_even;
-
-       return 0;
-}
-static int
-resizer_configure_in_continuous_mode(struct vpfe_resizer_device *resizer)
-{
-       struct device *dev = resizer->crop_resizer.subdev.v4l2_dev->dev;
-       struct resizer_params *param = &resizer->config;
-       struct vpfe_rsz_config_params *cont_config;
-       int line_len_c;
-       int line_len;
-       int ret;
-
-       if (resizer->resizer_a.output != RESIZER_OUTPUT_MEMORY) {
-               dev_err(dev, "enable resizer - Resizer-A\n");
-               return -EINVAL;
-       }
-
-       cont_config = &resizer->config.user_config;
-       param->rsz_en[RSZ_A] = ENABLE;
-       configure_resizer_out_params(resizer, RSZ_A,
-                                    &cont_config->output1, 1, 0);
-       param->rsz_en[RSZ_B] = DISABLE;
-       param->oper_mode = RESIZER_MODE_CONTINUOUS;
-
-       if (resizer->resizer_b.output == RESIZER_OUTPUT_MEMORY) {
-               struct v4l2_mbus_framefmt *outformat2;
-
-               param->rsz_en[RSZ_B] = ENABLE;
-               outformat2 = &resizer->resizer_b.formats[RESIZER_PAD_SOURCE];
-               ret = resizer_validate_output_image_format(dev, outformat2,
-                               &line_len, &line_len_c);
-               if (ret)
-                       return ret;
-               param->ext_mem_param[RSZ_B].rsz_sdr_oft_y = line_len;
-               param->ext_mem_param[RSZ_B].rsz_sdr_oft_c = line_len_c;
-               configure_resizer_out_params(resizer, RSZ_B,
-                                               &cont_config->output2, 0, 1);
-               if (outformat2->code == MEDIA_BUS_FMT_YDYUYDYV8_1X16)
-                       resizer_enable_422_420_conversion(param,
-                                                         RSZ_B, ENABLE);
-               else
-                       resizer_enable_422_420_conversion(param,
-                                                         RSZ_B, DISABLE);
-       }
-       resizer_configure_common_in_params(resizer);
-       ret = resizer_configure_output_win(resizer);
-       if (ret)
-               return ret;
-
-       param->rsz_common.passthrough = cont_config->bypass;
-       if (cont_config->bypass)
-               resizer_configure_passthru(resizer, 1);
-
-       return 0;
-}
-
-static inline int
-resizer_validate_input_image_format(struct device *dev,
-                                   u32 pix,
-                                   int width, int height, int *line_len)
-{
-       int val;
-
-       if (pix != MEDIA_BUS_FMT_UYVY8_2X8 &&
-           pix != MEDIA_BUS_FMT_Y8_1X8 &&
-           pix != MEDIA_BUS_FMT_UV8_1X8 &&
-           pix != MEDIA_BUS_FMT_SGRBG12_1X12) {
-               dev_err(dev,
-               "resizer validate output: pix format not supported, %d\n", pix);
-               return -EINVAL;
-       }
-
-       if (!width || !height) {
-               dev_err(dev,
-                       "resizer validate input: invalid width or height\n");
-               return -EINVAL;
-       }
-
-       if (pix == MEDIA_BUS_FMT_UV8_1X8)
-               resizer_calculate_line_length(pix, width,
-                                             height, &val, line_len);
-       else
-               resizer_calculate_line_length(pix, width,
-                                             height, line_len, &val);
-
-       return 0;
-}
-
-static int
-resizer_validate_decimation(struct device *dev, enum ipipeif_decimation dec_en,
-                           unsigned char rsz, unsigned char frame_div_mode_en,
-                           int width)
-{
-       if (dec_en && frame_div_mode_en) {
-               dev_err(dev,
-                "dec_en & frame_div_mode_en can not enabled simultaneously\n");
-               return -EINVAL;
-       }
-
-       if (frame_div_mode_en) {
-               dev_err(dev, "frame_div_mode mode not supported\n");
-               return -EINVAL;
-       }
-
-       if (!dec_en)
-               return 0;
-
-       if (width <= VPFE_IPIPE_MAX_INPUT_WIDTH) {
-               dev_err(dev,
-                       "image width to be more than %d for decimation\n",
-                       VPFE_IPIPE_MAX_INPUT_WIDTH);
-               return -EINVAL;
-       }
-
-       if (rsz < IPIPEIF_RSZ_MIN || rsz > IPIPEIF_RSZ_MAX) {
-               dev_err(dev, "rsz range is %d to %d\n",
-                       IPIPEIF_RSZ_MIN, IPIPEIF_RSZ_MAX);
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-/* resizer_calculate_normal_f_div_param() - Algorithm to calculate the frame
- *                                         division parameters for resizer.
- *                                         in normal mode.
- */
-static int
-resizer_calculate_normal_f_div_param(struct device *dev, int input_width,
-               int output_width, struct resizer_scale_param *param)
-{
-       /* rsz = R, input_width = H, output width = h in the equation */
-       unsigned int val1;
-       unsigned int rsz;
-       unsigned int val;
-       unsigned int h1;
-       unsigned int h2;
-       unsigned int o;
-
-       if (output_width > input_width) {
-               dev_err(dev, "frame div mode is used for scale down only\n");
-               return -EINVAL;
-       }
-
-       rsz = (input_width << 8) / output_width;
-       val = rsz << 1;
-       val = ((input_width << 8) / val) + 1;
-       o = 14;
-       if (!(val % 2)) {
-               h1 = val;
-       } else {
-               val = input_width << 7;
-               val -= rsz >> 1;
-               val /= rsz << 1;
-               val <<= 1;
-               val += 2;
-               o += (DIV_ROUND_UP(rsz, 1024) << 1);
-               h1 = val;
-       }
-       h2 = output_width - h1;
-       /* phi */
-       val = (h1 * rsz) - (((input_width >> 1) - o) << 8);
-       /* skip */
-       val1 = ((val - 1024) >> 9) << 1;
-       param->f_div.num_passes = MAX_PASSES;
-       param->f_div.pass[0].o_hsz = h1 - 1;
-       param->f_div.pass[0].i_hps = 0;
-       param->f_div.pass[0].h_phs = 0;
-       param->f_div.pass[0].src_hps = 0;
-       param->f_div.pass[0].src_hsz = (input_width >> 2) + o;
-       param->f_div.pass[1].o_hsz = h2 - 1;
-       param->f_div.pass[1].i_hps = val1;
-       param->f_div.pass[1].h_phs = val - (val1 << 8);
-       param->f_div.pass[1].src_hps = (input_width >> 2) - o;
-       param->f_div.pass[1].src_hsz = (input_width >> 2) + o;
-
-       return 0;
-}
-
-static int
-resizer_configure_in_single_shot_mode(struct vpfe_resizer_device *resizer)
-{
-       struct vpfe_rsz_config_params *config = &resizer->config.user_config;
-       struct device *dev = resizer->crop_resizer.subdev.v4l2_dev->dev;
-       struct vpfe_device *vpfe_dev = to_vpfe_device(resizer);
-       struct v4l2_mbus_framefmt *outformat1, *outformat2;
-       struct resizer_params *param = &resizer->config;
-       struct v4l2_mbus_framefmt *informat;
-       int decimation;
-       int line_len_c;
-       int line_len;
-       int rsz;
-       int ret;
-
-       informat = &resizer->crop_resizer.formats[RESIZER_CROP_PAD_SINK];
-       outformat1 = &resizer->resizer_a.formats[RESIZER_PAD_SOURCE];
-       outformat2 = &resizer->resizer_b.formats[RESIZER_PAD_SOURCE];
-
-       decimation = vpfe_ipipeif_decimation_enabled(vpfe_dev);
-       rsz = vpfe_ipipeif_get_rsz(vpfe_dev);
-       if (decimation && param->user_config.frame_div_mode_en) {
-               dev_err(dev,
-               "dec_en & frame_div_mode_en cannot enabled simultaneously\n");
-               return -EINVAL;
-       }
-
-       ret = resizer_validate_decimation(dev, decimation, rsz,
-             param->user_config.frame_div_mode_en, informat->width);
-       if (ret)
-               return -EINVAL;
-
-       ret = resizer_validate_input_image_format(dev, informat->code,
-               informat->width, informat->height, &line_len);
-       if (ret)
-               return -EINVAL;
-
-       if (resizer->resizer_a.output != RESIZER_OUTPUT_NONE) {
-               param->rsz_en[RSZ_A] = ENABLE;
-               ret = resizer_validate_output_image_format(dev, outformat1,
-                                       &line_len, &line_len_c);
-               if (ret)
-                       return ret;
-               param->ext_mem_param[RSZ_A].rsz_sdr_oft_y = line_len;
-               param->ext_mem_param[RSZ_A].rsz_sdr_oft_c = line_len_c;
-               configure_resizer_out_params(resizer, RSZ_A,
-                                       &param->user_config.output1, 0, 1);
-
-               if (outformat1->code == MEDIA_BUS_FMT_SGRBG12_1X12)
-                       param->rsz_common.raw_flip = 1;
-               else
-                       param->rsz_common.raw_flip = 0;
-
-               if (outformat1->code == MEDIA_BUS_FMT_YDYUYDYV8_1X16)
-                       resizer_enable_422_420_conversion(param,
-                                                         RSZ_A, ENABLE);
-               else
-                       resizer_enable_422_420_conversion(param,
-                                                         RSZ_A, DISABLE);
-       }
-
-       if (resizer->resizer_b.output != RESIZER_OUTPUT_NONE) {
-               param->rsz_en[RSZ_B] = ENABLE;
-               ret = resizer_validate_output_image_format(dev, outformat2,
-                               &line_len, &line_len_c);
-               if (ret)
-                       return ret;
-               param->ext_mem_param[RSZ_B].rsz_sdr_oft_y = line_len;
-               param->ext_mem_param[RSZ_B].rsz_sdr_oft_c = line_len_c;
-               configure_resizer_out_params(resizer, RSZ_B,
-                                       &param->user_config.output2, 0, 1);
-               if (outformat2->code == MEDIA_BUS_FMT_YDYUYDYV8_1X16)
-                       resizer_enable_422_420_conversion(param,
-                                                         RSZ_B, ENABLE);
-               else
-                       resizer_enable_422_420_conversion(param,
-                                                         RSZ_B, DISABLE);
-       }
-
-       resizer_configure_common_in_params(resizer);
-       if (resizer->resizer_a.output != RESIZER_OUTPUT_NONE) {
-               resizer_calculate_resize_ratios(resizer, RSZ_A);
-               resizer_calculate_sdram_offsets(resizer, RSZ_A);
-               /* Overriding resize ratio calculation */
-               if (informat->code == MEDIA_BUS_FMT_UV8_1X8) {
-                       param->rsz_rsc_param[RSZ_A].v_dif =
-                               (((informat->height + 1) * 2) * 256) /
-                               (param->rsz_rsc_param[RSZ_A].o_vsz + 1);
-               }
-       }
-
-       if (resizer->resizer_b.output != RESIZER_OUTPUT_NONE) {
-               resizer_calculate_resize_ratios(resizer, RSZ_B);
-               resizer_calculate_sdram_offsets(resizer, RSZ_B);
-               /* Overriding resize ratio calculation */
-               if (informat->code == MEDIA_BUS_FMT_UV8_1X8) {
-                       param->rsz_rsc_param[RSZ_B].v_dif =
-                               (((informat->height + 1) * 2) * 256) /
-                               (param->rsz_rsc_param[RSZ_B].o_vsz + 1);
-               }
-       }
-       if (param->user_config.frame_div_mode_en &&
-               param->rsz_en[RSZ_A]) {
-               if (!param->rsz_rsc_param[RSZ_A].dscale_en)
-                       ret = resizer_calculate_normal_f_div_param(dev,
-                             informat->width,
-                             param->rsz_rsc_param[RSZ_A].o_vsz + 1,
-                             &param->rsz_rsc_param[RSZ_A]);
-               else
-                       ret = resizer_calculate_down_scale_f_div_param(dev,
-                             informat->width,
-                             param->rsz_rsc_param[RSZ_A].o_vsz + 1,
-                             &param->rsz_rsc_param[RSZ_A]);
-               if (ret)
-                       return -EINVAL;
-       }
-       if (param->user_config.frame_div_mode_en &&
-               param->rsz_en[RSZ_B]) {
-               if (!param->rsz_rsc_param[RSZ_B].dscale_en)
-                       ret = resizer_calculate_normal_f_div_param(dev,
-                             informat->width,
-                             param->rsz_rsc_param[RSZ_B].o_vsz + 1,
-                             &param->rsz_rsc_param[RSZ_B]);
-               else
-                       ret = resizer_calculate_down_scale_f_div_param(dev,
-                             informat->width,
-                             param->rsz_rsc_param[RSZ_B].o_vsz + 1,
-                             &param->rsz_rsc_param[RSZ_B]);
-               if (ret)
-                       return -EINVAL;
-       }
-       param->rsz_common.passthrough = config->bypass;
-       if (config->bypass)
-               resizer_configure_passthru(resizer, 1);
-       return 0;
-}
-
-static void
-resizer_set_default_configuration(struct vpfe_resizer_device *resizer)
-{
-#define  WIDTH_I 640
-#define  HEIGHT_I 480
-#define  WIDTH_O 640
-#define  HEIGHT_O 480
-       const struct resizer_params rsz_default_config = {
-               .oper_mode = RESIZER_MODE_ONE_SHOT,
-               .rsz_common = {
-                       .vsz = HEIGHT_I - 1,
-                       .hsz = WIDTH_I - 1,
-                       .src_img_fmt = RSZ_IMG_422,
-                       .raw_flip = 1,  /* flip preserve Raw format */
-                       .source = IPIPE_DATA,
-                       .passthrough = BYPASS_OFF,
-                       .yuv_y_max = 255,
-                       .yuv_c_max = 255,
-                       .rsz_seq_crv = DISABLE,
-                       .out_chr_pos = VPFE_IPIPE_YUV422_CHR_POS_COSITE,
-               },
-               .rsz_rsc_param = {
-                       {
-                               .h_flip = DISABLE,
-                               .v_flip = DISABLE,
-                               .cen = DISABLE,
-                               .yen = DISABLE,
-                               .o_vsz = HEIGHT_O - 1,
-                               .o_hsz = WIDTH_O - 1,
-                               .v_dif = 256,
-                               .v_typ_y = VPFE_RSZ_INTP_CUBIC,
-                               .v_typ_c = VPFE_RSZ_INTP_CUBIC,
-                               .h_dif = 256,
-                               .h_typ_y = VPFE_RSZ_INTP_CUBIC,
-                               .h_typ_c = VPFE_RSZ_INTP_CUBIC,
-                               .h_dscale_ave_sz =
-                                       VPFE_IPIPE_DWN_SCALE_1_OVER_2,
-                               .v_dscale_ave_sz =
-                                       VPFE_IPIPE_DWN_SCALE_1_OVER_2,
-                       },
-                       {
-                               .h_flip = DISABLE,
-                               .v_flip = DISABLE,
-                               .cen = DISABLE,
-                               .yen = DISABLE,
-                               .o_vsz = HEIGHT_O - 1,
-                               .o_hsz = WIDTH_O - 1,
-                               .v_dif = 256,
-                               .v_typ_y = VPFE_RSZ_INTP_CUBIC,
-                               .v_typ_c = VPFE_RSZ_INTP_CUBIC,
-                               .h_dif = 256,
-                               .h_typ_y = VPFE_RSZ_INTP_CUBIC,
-                               .h_typ_c = VPFE_RSZ_INTP_CUBIC,
-                               .h_dscale_ave_sz =
-                                       VPFE_IPIPE_DWN_SCALE_1_OVER_2,
-                               .v_dscale_ave_sz =
-                                       VPFE_IPIPE_DWN_SCALE_1_OVER_2,
-                       },
-               },
-               .rsz2rgb = {
-                       {
-                               .rgb_en = DISABLE
-                       },
-                       {
-                               .rgb_en = DISABLE
-                       }
-               },
-               .ext_mem_param = {
-                       {
-                               .rsz_sdr_oft_y = WIDTH_O << 1,
-                               .rsz_sdr_ptr_e_y = HEIGHT_O,
-                               .rsz_sdr_oft_c = WIDTH_O,
-                               .rsz_sdr_ptr_e_c = HEIGHT_O >> 1,
-                       },
-                       {
-                               .rsz_sdr_oft_y = WIDTH_O << 1,
-                               .rsz_sdr_ptr_e_y = HEIGHT_O,
-                               .rsz_sdr_oft_c = WIDTH_O,
-                               .rsz_sdr_ptr_e_c = HEIGHT_O,
-                       },
-               },
-               .rsz_en[0] = ENABLE,
-               .rsz_en[1] = DISABLE,
-               .user_config = {
-                       .output1 = {
-                               .v_typ_y = VPFE_RSZ_INTP_CUBIC,
-                               .v_typ_c = VPFE_RSZ_INTP_CUBIC,
-                               .h_typ_y = VPFE_RSZ_INTP_CUBIC,
-                               .h_typ_c = VPFE_RSZ_INTP_CUBIC,
-                               .h_dscale_ave_sz =
-                                       VPFE_IPIPE_DWN_SCALE_1_OVER_2,
-                               .v_dscale_ave_sz =
-                                       VPFE_IPIPE_DWN_SCALE_1_OVER_2,
-                       },
-                       .output2 = {
-                               .v_typ_y = VPFE_RSZ_INTP_CUBIC,
-                               .v_typ_c = VPFE_RSZ_INTP_CUBIC,
-                               .h_typ_y = VPFE_RSZ_INTP_CUBIC,
-                               .h_typ_c = VPFE_RSZ_INTP_CUBIC,
-                               .h_dscale_ave_sz =
-                                       VPFE_IPIPE_DWN_SCALE_1_OVER_2,
-                               .v_dscale_ave_sz =
-                                       VPFE_IPIPE_DWN_SCALE_1_OVER_2,
-                       },
-                       .yuv_y_max = 255,
-                       .yuv_c_max = 255,
-                       .out_chr_pos = VPFE_IPIPE_YUV422_CHR_POS_COSITE,
-               },
-       };
-       memcpy(&resizer->config, &rsz_default_config,
-              sizeof(struct resizer_params));
-}
-
-/*
- * resizer_set_configuration() - set resizer config
- * @resizer: vpfe resizer device pointer.
- * @chan_config: resizer channel configuration.
- */
-static int
-resizer_set_configuration(struct vpfe_resizer_device *resizer,
-                         struct vpfe_rsz_config *chan_config)
-{
-       if (!chan_config->config)
-               resizer_set_default_configuration(resizer);
-       else
-               if (copy_from_user(&resizer->config.user_config,
-                                  (void __user *)chan_config->config,
-                                  sizeof(struct vpfe_rsz_config_params)))
-                       return -EFAULT;
-
-       return 0;
-}
-
-/*
- * resizer_get_configuration() - get resizer config
- * @resizer: vpfe resizer device pointer.
- * @channel: image processor logical channel.
- * @chan_config: resizer channel configuration.
- */
-static int
-resizer_get_configuration(struct vpfe_resizer_device *resizer,
-                  struct vpfe_rsz_config *chan_config)
-{
-       struct device *dev = resizer->crop_resizer.subdev.v4l2_dev->dev;
-
-       if (!chan_config->config) {
-               dev_err(dev, "Resizer channel invalid pointer\n");
-               return -EINVAL;
-       }
-
-       if (copy_to_user((void __user *)chan_config->config,
-                        (void *)&resizer->config.user_config,
-                        sizeof(struct vpfe_rsz_config_params))) {
-               dev_err(dev, "resizer_get_configuration: Error in copy to user\n");
-               return -EFAULT;
-       }
-
-       return 0;
-}
-
-/*
- * VPFE video operations
- */
-
-/*
- * resizer_a_video_out_queue() - RESIZER-A video out queue
- * @vpfe_dev: vpfe device pointer.
- * @addr: buffer address.
- */
-static int resizer_a_video_out_queue(struct vpfe_device *vpfe_dev,
-                                    unsigned long addr)
-{
-       struct vpfe_resizer_device *resizer = &vpfe_dev->vpfe_resizer;
-
-       return resizer_set_outaddr(resizer->base_addr,
-                                     &resizer->config, RSZ_A, addr);
-}
-
-/*
- * resizer_b_video_out_queue() - RESIZER-B video out queue
- * @vpfe_dev: vpfe device pointer.
- * @addr: buffer address.
- */
-static int resizer_b_video_out_queue(struct vpfe_device *vpfe_dev,
-                                    unsigned long addr)
-{
-       struct vpfe_resizer_device *resizer = &vpfe_dev->vpfe_resizer;
-
-       return resizer_set_outaddr(resizer->base_addr,
-                                  &resizer->config, RSZ_B, addr);
-}
-
-static const struct vpfe_video_operations resizer_a_video_ops = {
-       .queue = resizer_a_video_out_queue,
-};
-
-static const struct vpfe_video_operations resizer_b_video_ops = {
-       .queue = resizer_b_video_out_queue,
-};
-
-static void resizer_enable(struct vpfe_resizer_device *resizer, int en)
-{
-       struct vpfe_device *vpfe_dev = to_vpfe_device(resizer);
-       u16 ipipeif_sink = vpfe_dev->vpfe_ipipeif.input;
-       unsigned char val;
-
-       if (resizer->crop_resizer.input == RESIZER_CROP_INPUT_NONE)
-               return;
-
-       if (resizer->crop_resizer.input == RESIZER_CROP_INPUT_IPIPEIF &&
-          ipipeif_sink == IPIPEIF_INPUT_MEMORY) {
-               do {
-                       val = regr_rsz(resizer->base_addr, RSZ_SRC_EN);
-               } while (val);
-
-               if (resizer->resizer_a.output != RESIZER_OUTPUT_NONE) {
-                       do {
-                               val = regr_rsz(resizer->base_addr, RSZ_A);
-                       } while (val);
-               }
-               if (resizer->resizer_b.output != RESIZER_OUTPUT_NONE) {
-                       do {
-                               val = regr_rsz(resizer->base_addr, RSZ_B);
-                       } while (val);
-               }
-       }
-       if (resizer->resizer_a.output != RESIZER_OUTPUT_NONE)
-               rsz_enable(resizer->base_addr, RSZ_A, en);
-
-       if (resizer->resizer_b.output != RESIZER_OUTPUT_NONE)
-               rsz_enable(resizer->base_addr, RSZ_B, en);
-}
-
-
-/*
- * resizer_ss_isr() - resizer module single-shot buffer scheduling isr
- * @resizer: vpfe resizer device pointer.
- */
-static void resizer_ss_isr(struct vpfe_resizer_device *resizer)
-{
-       struct vpfe_video_device *video_out = &resizer->resizer_a.video_out;
-       struct vpfe_video_device *video_out2 = &resizer->resizer_b.video_out;
-       struct vpfe_device *vpfe_dev = to_vpfe_device(resizer);
-       struct vpfe_pipeline *pipe = &video_out->pipe;
-       u16 ipipeif_sink = vpfe_dev->vpfe_ipipeif.input;
-       u32 val;
-
-       if (ipipeif_sink != IPIPEIF_INPUT_MEMORY)
-               return;
-
-       if (resizer->resizer_a.output == RESIZER_OUTPUT_MEMORY) {
-               val = vpss_dma_complete_interrupt();
-               if (val != 0 && val != 2)
-                       return;
-       }
-
-       if (resizer->resizer_a.output == RESIZER_OUTPUT_MEMORY) {
-               spin_lock(&video_out->dma_queue_lock);
-               vpfe_video_process_buffer_complete(video_out);
-               video_out->state = VPFE_VIDEO_BUFFER_NOT_QUEUED;
-               vpfe_video_schedule_next_buffer(video_out);
-               spin_unlock(&video_out->dma_queue_lock);
-       }
-
-       /* If resizer B is enabled */
-       if (pipe->output_num > 1 && resizer->resizer_b.output ==
-           RESIZER_OUTPUT_MEMORY) {
-               spin_lock(&video_out2->dma_queue_lock);
-               vpfe_video_process_buffer_complete(video_out2);
-               video_out2->state = VPFE_VIDEO_BUFFER_NOT_QUEUED;
-               vpfe_video_schedule_next_buffer(video_out2);
-               spin_unlock(&video_out2->dma_queue_lock);
-       }
-
-       /* start HW if buffers are queued */
-       if (vpfe_video_is_pipe_ready(pipe) &&
-           resizer->resizer_a.output == RESIZER_OUTPUT_MEMORY) {
-               resizer_enable(resizer, 1);
-               vpfe_ipipe_enable(vpfe_dev, 1);
-               vpfe_ipipeif_enable(vpfe_dev);
-       }
-}
-
-/*
- * vpfe_resizer_buffer_isr() - resizer module buffer scheduling isr
- * @resizer: vpfe resizer device pointer.
- */
-void vpfe_resizer_buffer_isr(struct vpfe_resizer_device *resizer)
-{
-       struct vpfe_device *vpfe_dev = to_vpfe_device(resizer);
-       struct vpfe_video_device *video_out = &resizer->resizer_a.video_out;
-       struct vpfe_video_device *video_out2 = &resizer->resizer_b.video_out;
-       struct vpfe_pipeline *pipe = &resizer->resizer_a.video_out.pipe;
-       enum v4l2_field field;
-       int fid;
-
-       if (!video_out->started)
-               return;
-
-       if (resizer->crop_resizer.input == RESIZER_CROP_INPUT_NONE)
-               return;
-
-       field = video_out->fmt.fmt.pix.field;
-       if (field == V4L2_FIELD_NONE) {
-               /* handle progressive frame capture */
-               if (video_out->cur_frm != video_out->next_frm) {
-                       vpfe_video_process_buffer_complete(video_out);
-                       if (pipe->output_num > 1)
-                               vpfe_video_process_buffer_complete(video_out2);
-               }
-
-               video_out->skip_frame_count--;
-               if (!video_out->skip_frame_count) {
-                       video_out->skip_frame_count =
-                               video_out->skip_frame_count_init;
-                       rsz_src_enable(resizer->base_addr, 1);
-               } else {
-                       rsz_src_enable(resizer->base_addr, 0);
-               }
-               return;
-       }
-
-       /* handle interlaced frame capture */
-       fid = vpfe_isif_get_fid(vpfe_dev);
-
-       /* switch the software maintained field id */
-       video_out->field_id ^= 1;
-       if (fid == video_out->field_id) {
-               /*
-                * we are in-sync here,continue.
-                * One frame is just being captured. If the
-                * next frame is available, release the current
-                * frame and move on
-                */
-               if (fid == 0 && video_out->cur_frm != video_out->next_frm) {
-                       vpfe_video_process_buffer_complete(video_out);
-                       if (pipe->output_num > 1)
-                               vpfe_video_process_buffer_complete(video_out2);
-               }
-       } else if (fid == 0) {
-               /*
-                * out of sync. Recover from any hardware out-of-sync.
-                * May loose one frame
-                */
-               video_out->field_id = fid;
-       }
-}
-
-/*
- * vpfe_resizer_dma_isr() - resizer module dma isr
- * @resizer: vpfe resizer device pointer.
- */
-void vpfe_resizer_dma_isr(struct vpfe_resizer_device *resizer)
-{
-       struct vpfe_video_device *video_out2 = &resizer->resizer_b.video_out;
-       struct vpfe_video_device *video_out = &resizer->resizer_a.video_out;
-       struct vpfe_device *vpfe_dev = to_vpfe_device(resizer);
-       struct vpfe_pipeline *pipe = &video_out->pipe;
-       int schedule_capture = 0;
-       enum v4l2_field field;
-       int fid;
-
-       if (!video_out->started)
-               return;
-
-       if (pipe->state == VPFE_PIPELINE_STREAM_SINGLESHOT) {
-               resizer_ss_isr(resizer);
-               return;
-       }
-
-       field = video_out->fmt.fmt.pix.field;
-       if (field == V4L2_FIELD_NONE) {
-               if (!list_empty(&video_out->dma_queue) &&
-                       video_out->cur_frm == video_out->next_frm)
-                       schedule_capture = 1;
-       } else {
-               fid = vpfe_isif_get_fid(vpfe_dev);
-               if (fid == video_out->field_id) {
-                       /* we are in-sync here,continue */
-                       if (fid == 1 && !list_empty(&video_out->dma_queue) &&
-                           video_out->cur_frm == video_out->next_frm)
-                               schedule_capture = 1;
-               }
-       }
-
-       if (!schedule_capture)
-               return;
-
-       spin_lock(&video_out->dma_queue_lock);
-       vpfe_video_schedule_next_buffer(video_out);
-       spin_unlock(&video_out->dma_queue_lock);
-       if (pipe->output_num > 1) {
-               spin_lock(&video_out2->dma_queue_lock);
-               vpfe_video_schedule_next_buffer(video_out2);
-               spin_unlock(&video_out2->dma_queue_lock);
-       }
-}
-
-/*
- * V4L2 subdev operations
- */
-
-/*
- * resizer_ioctl() - Handle resizer module private ioctl's
- * @sd: pointer to v4l2 subdev structure
- * @cmd: configuration command
- * @arg: configuration argument
- */
-static long resizer_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
-{
-       struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd);
-       struct device *dev = resizer->crop_resizer.subdev.v4l2_dev->dev;
-       struct vpfe_rsz_config *user_config;
-       int ret = -ENOIOCTLCMD;
-
-       if (&resizer->crop_resizer.subdev != sd)
-               return ret;
-
-       switch (cmd) {
-       case VIDIOC_VPFE_RSZ_S_CONFIG:
-               user_config = arg;
-               ret = resizer_set_configuration(resizer, user_config);
-               break;
-
-       case VIDIOC_VPFE_RSZ_G_CONFIG:
-               user_config = arg;
-               if (!user_config->config) {
-                       dev_err(dev, "error in VIDIOC_VPFE_RSZ_G_CONFIG\n");
-                       return -EINVAL;
-               }
-               ret = resizer_get_configuration(resizer, user_config);
-               break;
-       }
-       return ret;
-}
-
-static int resizer_do_hw_setup(struct vpfe_resizer_device *resizer)
-{
-       struct vpfe_device *vpfe_dev = to_vpfe_device(resizer);
-       u16 ipipeif_sink = vpfe_dev->vpfe_ipipeif.input;
-       u16 ipipeif_source = vpfe_dev->vpfe_ipipeif.output;
-       struct resizer_params *param = &resizer->config;
-       int ret = 0;
-
-       if (resizer->resizer_a.output == RESIZER_OUTPUT_MEMORY ||
-           resizer->resizer_b.output == RESIZER_OUTPUT_MEMORY) {
-               if (ipipeif_sink == IPIPEIF_INPUT_MEMORY &&
-                   ipipeif_source == IPIPEIF_OUTPUT_RESIZER)
-                       ret = resizer_configure_in_single_shot_mode(resizer);
-               else
-                       ret =  resizer_configure_in_continuous_mode(resizer);
-               if (ret)
-                       return ret;
-               ret = config_rsz_hw(resizer, param);
-       }
-       return ret;
-}
-
-/*
- * resizer_set_stream() - Enable/Disable streaming on resizer subdev
- * @sd: pointer to v4l2 subdev structure
- * @enable: 1 == Enable, 0 == Disable
- */
-static int resizer_set_stream(struct v4l2_subdev *sd, int enable)
-{
-       struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd);
-
-       if (&resizer->crop_resizer.subdev != sd)
-               return 0;
-
-       if (resizer->resizer_a.output != RESIZER_OUTPUT_MEMORY)
-               return 0;
-
-       switch (enable) {
-       case 1:
-               if (resizer_do_hw_setup(resizer) < 0)
-                       return -EINVAL;
-               resizer_enable(resizer, enable);
-               break;
-
-       case 0:
-               resizer_enable(resizer, enable);
-               break;
-       }
-
-       return 0;
-}
-
-/*
- * __resizer_get_format() - helper function for getting resizer format
- * @sd: pointer to subdev.
- * @cfg: V4L2 subdev pad config
- * @pad: pad number.
- * @which: wanted subdev format.
- * Return wanted mbus frame format.
- */
-static struct v4l2_mbus_framefmt *
-__resizer_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
-                    unsigned int pad, enum v4l2_subdev_format_whence which)
-{
-       struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd);
-
-       if (which == V4L2_SUBDEV_FORMAT_TRY)
-               return v4l2_subdev_get_try_format(sd, cfg, pad);
-       if (&resizer->crop_resizer.subdev == sd)
-               return &resizer->crop_resizer.formats[pad];
-       if (&resizer->resizer_a.subdev == sd)
-               return &resizer->resizer_a.formats[pad];
-       if (&resizer->resizer_b.subdev == sd)
-               return &resizer->resizer_b.formats[pad];
-       return NULL;
-}
-
-/*
- * resizer_try_format() - Handle try format by pad subdev method
- * @sd: pointer to subdev.
- * @cfg: V4L2 subdev pad config
- * @pad: pad num.
- * @fmt: pointer to v4l2 format structure.
- * @which: wanted subdev format.
- */
-static void
-resizer_try_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
-       unsigned int pad, struct v4l2_mbus_framefmt *fmt,
-       enum v4l2_subdev_format_whence which)
-{
-       struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd);
-       unsigned int max_out_height;
-       unsigned int max_out_width;
-       unsigned int i;
-
-       if ((&resizer->resizer_a.subdev == sd && pad == RESIZER_PAD_SINK) ||
-           (&resizer->resizer_b.subdev == sd && pad == RESIZER_PAD_SINK) ||
-           (&resizer->crop_resizer.subdev == sd &&
-           (pad == RESIZER_CROP_PAD_SOURCE ||
-           pad == RESIZER_CROP_PAD_SOURCE2 || pad == RESIZER_CROP_PAD_SINK))) {
-               for (i = 0; i < ARRAY_SIZE(resizer_input_formats); i++) {
-                       if (fmt->code == resizer_input_formats[i])
-                               break;
-               }
-               /* If not found, use UYVY as default */
-               if (i >= ARRAY_SIZE(resizer_input_formats))
-                       fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
-
-               fmt->width = clamp_t(u32, fmt->width, MIN_IN_WIDTH,
-                                       MAX_IN_WIDTH);
-               fmt->height = clamp_t(u32, fmt->height, MIN_IN_HEIGHT,
-                               MAX_IN_HEIGHT);
-       } else if (&resizer->resizer_a.subdev == sd &&
-                  pad == RESIZER_PAD_SOURCE) {
-               max_out_width = IPIPE_MAX_OUTPUT_WIDTH_A;
-               max_out_height = IPIPE_MAX_OUTPUT_HEIGHT_A;
-
-               for (i = 0; i < ARRAY_SIZE(resizer_output_formats); i++) {
-                       if (fmt->code == resizer_output_formats[i])
-                               break;
-               }
-               /* If not found, use UYVY as default */
-               if (i >= ARRAY_SIZE(resizer_output_formats))
-                       fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
-
-               fmt->width = clamp_t(u32, fmt->width, MIN_OUT_WIDTH,
-                                       max_out_width);
-               fmt->width &= ~15;
-               fmt->height = clamp_t(u32, fmt->height, MIN_OUT_HEIGHT,
-                               max_out_height);
-       } else if (&resizer->resizer_b.subdev == sd &&
-                  pad == RESIZER_PAD_SOURCE) {
-               max_out_width = IPIPE_MAX_OUTPUT_WIDTH_B;
-               max_out_height = IPIPE_MAX_OUTPUT_HEIGHT_B;
-
-               for (i = 0; i < ARRAY_SIZE(resizer_output_formats); i++) {
-                       if (fmt->code == resizer_output_formats[i])
-                               break;
-               }
-               /* If not found, use UYVY as default */
-               if (i >= ARRAY_SIZE(resizer_output_formats))
-                       fmt->code = MEDIA_BUS_FMT_UYVY8_2X8;
-
-               fmt->width = clamp_t(u32, fmt->width, MIN_OUT_WIDTH,
-                                       max_out_width);
-               fmt->width &= ~15;
-               fmt->height = clamp_t(u32, fmt->height, MIN_OUT_HEIGHT,
-                               max_out_height);
-       }
-}
-
-/*
- * resizer_set_format() - Handle set format by pads subdev method
- * @sd: pointer to v4l2 subdev structure
- * @cfg: V4L2 subdev pad config
- * @fmt: pointer to v4l2 subdev format structure
- * return -EINVAL or zero on success
- */
-static int resizer_set_format(struct v4l2_subdev *sd,
-                             struct v4l2_subdev_pad_config *cfg,
-                             struct v4l2_subdev_format *fmt)
-{
-       struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd);
-       struct v4l2_mbus_framefmt *format;
-
-       format = __resizer_get_format(sd, cfg, fmt->pad, fmt->which);
-       if (format == NULL)
-               return -EINVAL;
-
-       resizer_try_format(sd, cfg, fmt->pad, &fmt->format, fmt->which);
-       *format = fmt->format;
-
-       if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
-               return 0;
-
-       if (&resizer->crop_resizer.subdev == sd) {
-               if (fmt->pad == RESIZER_CROP_PAD_SINK) {
-                       resizer->crop_resizer.formats[fmt->pad] = fmt->format;
-               } else if (fmt->pad == RESIZER_CROP_PAD_SOURCE &&
-                               resizer->crop_resizer.output == RESIZER_A) {
-                       resizer->crop_resizer.formats[fmt->pad] = fmt->format;
-                       resizer->crop_resizer.
-                       formats[RESIZER_CROP_PAD_SOURCE2] = fmt->format;
-               } else if (fmt->pad == RESIZER_CROP_PAD_SOURCE2 &&
-                       resizer->crop_resizer.output2 == RESIZER_B) {
-                       resizer->crop_resizer.formats[fmt->pad] = fmt->format;
-                       resizer->crop_resizer.
-                       formats[RESIZER_CROP_PAD_SOURCE] = fmt->format;
-               } else {
-                       return -EINVAL;
-               }
-       } else if (&resizer->resizer_a.subdev == sd) {
-               if (fmt->pad == RESIZER_PAD_SINK)
-                       resizer->resizer_a.formats[fmt->pad] = fmt->format;
-               else if (fmt->pad == RESIZER_PAD_SOURCE)
-                       resizer->resizer_a.formats[fmt->pad] = fmt->format;
-               else
-                       return -EINVAL;
-       } else if (&resizer->resizer_b.subdev == sd) {
-               if (fmt->pad == RESIZER_PAD_SINK)
-                       resizer->resizer_b.formats[fmt->pad] = fmt->format;
-               else if (fmt->pad == RESIZER_PAD_SOURCE)
-                       resizer->resizer_b.formats[fmt->pad] = fmt->format;
-               else
-                       return -EINVAL;
-       } else {
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-/*
- * resizer_get_format() - Retrieve the video format on a pad
- * @sd: pointer to v4l2 subdev structure.
- * @cfg: V4L2 subdev pad config
- * @fmt: pointer to v4l2 subdev format structure
- * return -EINVAL or zero on success
- */
-static int resizer_get_format(struct v4l2_subdev *sd,
-                             struct v4l2_subdev_pad_config *cfg,
-                             struct v4l2_subdev_format *fmt)
-{
-       struct v4l2_mbus_framefmt *format;
-
-       format = __resizer_get_format(sd, cfg, fmt->pad, fmt->which);
-       if (format == NULL)
-               return -EINVAL;
-
-       fmt->format = *format;
-
-       return 0;
-}
-
-/*
- * resizer_enum_frame_size() - enum frame sizes on pads
- * @sd: Pointer to subdevice.
- * @cfg: V4L2 subdev pad config
- * @code: pointer to v4l2_subdev_frame_size_enum structure.
- */
-static int resizer_enum_frame_size(struct v4l2_subdev *sd,
-                                  struct v4l2_subdev_pad_config *cfg,
-                                  struct v4l2_subdev_frame_size_enum *fse)
-{
-       struct v4l2_mbus_framefmt format;
-
-       if (fse->index != 0)
-               return -EINVAL;
-
-       format.code = fse->code;
-       format.width = 1;
-       format.height = 1;
-       resizer_try_format(sd, cfg, fse->pad, &format, fse->which);
-       fse->min_width = format.width;
-       fse->min_height = format.height;
-
-       if (format.code != fse->code)
-               return -EINVAL;
-
-       format.code = fse->code;
-       format.width = -1;
-       format.height = -1;
-       resizer_try_format(sd, cfg, fse->pad, &format, fse->which);
-       fse->max_width = format.width;
-       fse->max_height = format.height;
-
-       return 0;
-}
-
-/*
- * resizer_enum_mbus_code() - enum mbus codes for pads
- * @sd: Pointer to subdevice.
- * @cfg: V4L2 subdev pad config
- * @code: pointer to v4l2_subdev_mbus_code_enum structure
- */
-static int resizer_enum_mbus_code(struct v4l2_subdev *sd,
-                                 struct v4l2_subdev_pad_config *cfg,
-                                 struct v4l2_subdev_mbus_code_enum *code)
-{
-       if (code->pad == RESIZER_PAD_SINK) {
-               if (code->index >= ARRAY_SIZE(resizer_input_formats))
-                       return -EINVAL;
-
-               code->code = resizer_input_formats[code->index];
-       } else if (code->pad == RESIZER_PAD_SOURCE) {
-               if (code->index >= ARRAY_SIZE(resizer_output_formats))
-                       return -EINVAL;
-
-               code->code = resizer_output_formats[code->index];
-       }
-
-       return 0;
-}
-
-/*
- * resizer_init_formats() - Initialize formats on all pads
- * @sd: Pointer to subdevice.
- * @fh: V4L2 subdev file handle.
- *
- * Initialize all pad formats with default values. Try formats are
- * initialized on the file handle.
- */
-static int resizer_init_formats(struct v4l2_subdev *sd,
-                               struct v4l2_subdev_fh *fh)
-{
-       __u32 which = V4L2_SUBDEV_FORMAT_TRY;
-       struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd);
-       struct v4l2_subdev_format format;
-
-       if (&resizer->crop_resizer.subdev == sd) {
-               memset(&format, 0, sizeof(format));
-               format.pad = RESIZER_CROP_PAD_SINK;
-               format.which = which;
-               format.format.code = MEDIA_BUS_FMT_YUYV8_2X8;
-               format.format.width = MAX_IN_WIDTH;
-               format.format.height = MAX_IN_HEIGHT;
-               resizer_set_format(sd, fh->pad, &format);
-
-               memset(&format, 0, sizeof(format));
-               format.pad = RESIZER_CROP_PAD_SOURCE;
-               format.which = which;
-               format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
-               format.format.width = MAX_IN_WIDTH;
-               format.format.height = MAX_IN_WIDTH;
-               resizer_set_format(sd, fh->pad, &format);
-
-               memset(&format, 0, sizeof(format));
-               format.pad = RESIZER_CROP_PAD_SOURCE2;
-               format.which = which;
-               format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
-               format.format.width = MAX_IN_WIDTH;
-               format.format.height = MAX_IN_WIDTH;
-               resizer_set_format(sd, fh->pad, &format);
-       } else if (&resizer->resizer_a.subdev == sd) {
-               memset(&format, 0, sizeof(format));
-               format.pad = RESIZER_PAD_SINK;
-               format.which = which;
-               format.format.code = MEDIA_BUS_FMT_YUYV8_2X8;
-               format.format.width = MAX_IN_WIDTH;
-               format.format.height = MAX_IN_HEIGHT;
-               resizer_set_format(sd, fh->pad, &format);
-
-               memset(&format, 0, sizeof(format));
-               format.pad = RESIZER_PAD_SOURCE;
-               format.which = which;
-               format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
-               format.format.width = IPIPE_MAX_OUTPUT_WIDTH_A;
-               format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_A;
-               resizer_set_format(sd, fh->pad, &format);
-       } else if (&resizer->resizer_b.subdev == sd) {
-               memset(&format, 0, sizeof(format));
-               format.pad = RESIZER_PAD_SINK;
-               format.which = which;
-               format.format.code = MEDIA_BUS_FMT_YUYV8_2X8;
-               format.format.width = MAX_IN_WIDTH;
-               format.format.height = MAX_IN_HEIGHT;
-               resizer_set_format(sd, fh->pad, &format);
-
-               memset(&format, 0, sizeof(format));
-               format.pad = RESIZER_PAD_SOURCE;
-               format.which = which;
-               format.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
-               format.format.width = IPIPE_MAX_OUTPUT_WIDTH_B;
-               format.format.height = IPIPE_MAX_OUTPUT_HEIGHT_B;
-               resizer_set_format(sd, fh->pad, &format);
-       }
-
-       return 0;
-}
-
-/* subdev core operations */
-static const struct v4l2_subdev_core_ops resizer_v4l2_core_ops = {
-       .ioctl = resizer_ioctl,
-};
-
-/* subdev internal operations */
-static const struct v4l2_subdev_internal_ops resizer_v4l2_internal_ops = {
-       .open = resizer_init_formats,
-};
-
-/* subdev video operations */
-static const struct v4l2_subdev_video_ops resizer_v4l2_video_ops = {
-       .s_stream = resizer_set_stream,
-};
-
-/* subdev pad operations */
-static const struct v4l2_subdev_pad_ops resizer_v4l2_pad_ops = {
-       .enum_mbus_code = resizer_enum_mbus_code,
-       .enum_frame_size = resizer_enum_frame_size,
-       .get_fmt = resizer_get_format,
-       .set_fmt = resizer_set_format,
-};
-
-/* subdev operations */
-static const struct v4l2_subdev_ops resizer_v4l2_ops = {
-       .core = &resizer_v4l2_core_ops,
-       .video = &resizer_v4l2_video_ops,
-       .pad = &resizer_v4l2_pad_ops,
-};
-
-/*
- * Media entity operations
- */
-
-/*
- * resizer_link_setup() - Setup resizer connections
- * @entity: Pointer to media entity structure
- * @local: Pointer to local pad array
- * @remote: Pointer to remote pad array
- * @flags: Link flags
- * return -EINVAL or zero on success
- */
-static int resizer_link_setup(struct media_entity *entity,
-                          const struct media_pad *local,
-                          const struct media_pad *remote, u32 flags)
-{
-       struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
-       struct vpfe_resizer_device *resizer = v4l2_get_subdevdata(sd);
-       struct vpfe_device *vpfe_dev = to_vpfe_device(resizer);
-       u16 ipipeif_source = vpfe_dev->vpfe_ipipeif.output;
-       u16 ipipe_source = vpfe_dev->vpfe_ipipe.output;
-       unsigned int index = local->index;
-
-       /* FIXME: this is actually a hack! */
-       if (is_media_entity_v4l2_subdev(remote->entity))
-               index |= 2 << 16;
-
-       if (&resizer->crop_resizer.subdev == sd) {
-               switch (index) {
-               case RESIZER_CROP_PAD_SINK | 2 << 16:
-                       if (!(flags & MEDIA_LNK_FL_ENABLED)) {
-                               resizer->crop_resizer.input =
-                                       RESIZER_CROP_INPUT_NONE;
-                               break;
-                       }
-
-                       if (resizer->crop_resizer.input !=
-                          RESIZER_CROP_INPUT_NONE)
-                               return -EBUSY;
-                       if (ipipeif_source == IPIPEIF_OUTPUT_RESIZER)
-                               resizer->crop_resizer.input =
-                                               RESIZER_CROP_INPUT_IPIPEIF;
-                       else if (ipipe_source == IPIPE_OUTPUT_RESIZER)
-                               resizer->crop_resizer.input =
-                                               RESIZER_CROP_INPUT_IPIPE;
-                       else
-                               return -EINVAL;
-                       break;
-
-               case RESIZER_CROP_PAD_SOURCE | 2 << 16:
-                       if (!(flags & MEDIA_LNK_FL_ENABLED)) {
-                               resizer->crop_resizer.output =
-                               RESIZER_CROP_OUTPUT_NONE;
-                               break;
-                       }
-                       if (resizer->crop_resizer.output !=
-                           RESIZER_CROP_OUTPUT_NONE)
-                               return -EBUSY;
-                       resizer->crop_resizer.output = RESIZER_A;
-                       break;
-
-               case RESIZER_CROP_PAD_SOURCE2 | 2 << 16:
-                       if (!(flags & MEDIA_LNK_FL_ENABLED)) {
-                               resizer->crop_resizer.output2 =
-                                       RESIZER_CROP_OUTPUT_NONE;
-                               break;
-                       }
-                       if (resizer->crop_resizer.output2 !=
-                           RESIZER_CROP_OUTPUT_NONE)
-                               return -EBUSY;
-                       resizer->crop_resizer.output2 = RESIZER_B;
-                       break;
-
-               default:
-                       return -EINVAL;
-               }
-       } else if (&resizer->resizer_a.subdev == sd) {
-               switch (index) {
-               case RESIZER_PAD_SINK | 2 << 16:
-                       if (!(flags & MEDIA_LNK_FL_ENABLED)) {
-                               resizer->resizer_a.input = RESIZER_INPUT_NONE;
-                               break;
-                       }
-                       if (resizer->resizer_a.input != RESIZER_INPUT_NONE)
-                               return -EBUSY;
-                       resizer->resizer_a.input = RESIZER_INPUT_CROP_RESIZER;
-                       break;
-
-               case RESIZER_PAD_SOURCE:
-                       if (!(flags & MEDIA_LNK_FL_ENABLED)) {
-                               resizer->resizer_a.output = RESIZER_OUTPUT_NONE;
-                               break;
-                       }
-                       if (resizer->resizer_a.output != RESIZER_OUTPUT_NONE)
-                               return -EBUSY;
-                       resizer->resizer_a.output = RESIZER_OUTPUT_MEMORY;
-                       break;
-
-               default:
-                       return -EINVAL;
-               }
-       } else if (&resizer->resizer_b.subdev == sd) {
-               switch (index) {
-               case RESIZER_PAD_SINK | 2 << 16:
-                       if (!(flags & MEDIA_LNK_FL_ENABLED)) {
-                               resizer->resizer_b.input = RESIZER_INPUT_NONE;
-                               break;
-                       }
-                       if (resizer->resizer_b.input != RESIZER_INPUT_NONE)
-                               return -EBUSY;
-                       resizer->resizer_b.input = RESIZER_INPUT_CROP_RESIZER;
-                       break;
-
-               case RESIZER_PAD_SOURCE:
-                       if (!(flags & MEDIA_LNK_FL_ENABLED)) {
-                               resizer->resizer_b.output = RESIZER_OUTPUT_NONE;
-                               break;
-                       }
-                       if (resizer->resizer_b.output != RESIZER_OUTPUT_NONE)
-                               return -EBUSY;
-                       resizer->resizer_b.output = RESIZER_OUTPUT_MEMORY;
-                       break;
-
-               default:
-                       return -EINVAL;
-               }
-       } else {
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-static const struct media_entity_operations resizer_media_ops = {
-       .link_setup = resizer_link_setup,
-};
-
-/*
- * vpfe_resizer_unregister_entities() - Unregister entity
- * @vpfe_rsz - pointer to resizer subdevice structure.
- */
-void vpfe_resizer_unregister_entities(struct vpfe_resizer_device *vpfe_rsz)
-{
-       /* unregister video devices */
-       vpfe_video_unregister(&vpfe_rsz->resizer_a.video_out);
-       vpfe_video_unregister(&vpfe_rsz->resizer_b.video_out);
-
-       /* unregister subdev */
-       v4l2_device_unregister_subdev(&vpfe_rsz->crop_resizer.subdev);
-       v4l2_device_unregister_subdev(&vpfe_rsz->resizer_a.subdev);
-       v4l2_device_unregister_subdev(&vpfe_rsz->resizer_b.subdev);
-       /* cleanup entity */
-       media_entity_cleanup(&vpfe_rsz->crop_resizer.subdev.entity);
-       media_entity_cleanup(&vpfe_rsz->resizer_a.subdev.entity);
-       media_entity_cleanup(&vpfe_rsz->resizer_b.subdev.entity);
-}
-
-/*
- * vpfe_resizer_register_entities() - Register entity
- * @resizer - pointer to resizer device.
- * @vdev: pointer to v4l2 device structure.
- */
-int vpfe_resizer_register_entities(struct vpfe_resizer_device *resizer,
-                                  struct v4l2_device *vdev)
-{
-       struct vpfe_device *vpfe_dev = to_vpfe_device(resizer);
-       unsigned int flags = 0;
-       int ret;
-
-       /* Register the crop resizer subdev */
-       ret = v4l2_device_register_subdev(vdev, &resizer->crop_resizer.subdev);
-       if (ret < 0) {
-               pr_err("Failed to register crop resizer as v4l2-subdev\n");
-               return ret;
-       }
-       /* Register Resizer-A subdev */
-       ret = v4l2_device_register_subdev(vdev, &resizer->resizer_a.subdev);
-       if (ret < 0) {
-               pr_err("Failed to register resizer-a as v4l2-subdev\n");
-               return ret;
-       }
-       /* Register Resizer-B subdev */
-       ret = v4l2_device_register_subdev(vdev, &resizer->resizer_b.subdev);
-       if (ret < 0) {
-               pr_err("Failed to register resizer-b as v4l2-subdev\n");
-               return ret;
-       }
-       /* Register video-out device for resizer-a */
-       ret = vpfe_video_register(&resizer->resizer_a.video_out, vdev);
-       if (ret) {
-               pr_err("Failed to register RSZ-A video-out device\n");
-               goto out_video_out2_register;
-       }
-       resizer->resizer_a.video_out.vpfe_dev = vpfe_dev;
-
-       /* Register video-out device for resizer-b */
-       ret = vpfe_video_register(&resizer->resizer_b.video_out, vdev);
-       if (ret) {
-               pr_err("Failed to register RSZ-B video-out device\n");
-               goto out_video_out2_register;
-       }
-       resizer->resizer_b.video_out.vpfe_dev = vpfe_dev;
-
-       /* create link between Resizer Crop----> Resizer A*/
-       ret = media_create_pad_link(&resizer->crop_resizer.subdev.entity, 1,
-                               &resizer->resizer_a.subdev.entity,
-                               0, flags);
-       if (ret < 0)
-               goto out_create_link;
-
-       /* create link between Resizer Crop----> Resizer B*/
-       ret = media_create_pad_link(&resizer->crop_resizer.subdev.entity, 2,
-                               &resizer->resizer_b.subdev.entity,
-                               0, flags);
-       if (ret < 0)
-               goto out_create_link;
-
-       /* create link between Resizer A ----> video out */
-       ret = media_create_pad_link(&resizer->resizer_a.subdev.entity, 1,
-               &resizer->resizer_a.video_out.video_dev.entity, 0, flags);
-       if (ret < 0)
-               goto out_create_link;
-
-       /* create link between Resizer B ----> video out */
-       ret = media_create_pad_link(&resizer->resizer_b.subdev.entity, 1,
-               &resizer->resizer_b.video_out.video_dev.entity, 0, flags);
-       if (ret < 0)
-               goto out_create_link;
-
-       return 0;
-
-out_create_link:
-       vpfe_video_unregister(&resizer->resizer_b.video_out);
-out_video_out2_register:
-       vpfe_video_unregister(&resizer->resizer_a.video_out);
-       v4l2_device_unregister_subdev(&resizer->crop_resizer.subdev);
-       v4l2_device_unregister_subdev(&resizer->resizer_a.subdev);
-       v4l2_device_unregister_subdev(&resizer->resizer_b.subdev);
-       media_entity_cleanup(&resizer->crop_resizer.subdev.entity);
-       media_entity_cleanup(&resizer->resizer_a.subdev.entity);
-       media_entity_cleanup(&resizer->resizer_b.subdev.entity);
-       return ret;
-}
-
-/*
- * vpfe_resizer_init() - resizer device initialization.
- * @vpfe_rsz - pointer to resizer device
- * @pdev: platform device pointer.
- */
-int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz,
-                     struct platform_device *pdev)
-{
-       struct v4l2_subdev *sd = &vpfe_rsz->crop_resizer.subdev;
-       struct media_pad *pads = &vpfe_rsz->crop_resizer.pads[0];
-       struct media_entity *me = &sd->entity;
-       resource_size_t res_len;
-       struct resource *res;
-       int ret;
-
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 5);
-       if (!res)
-               return -ENOENT;
-
-       res_len = resource_size(res);
-       res = request_mem_region(res->start, res_len, res->name);
-       if (!res)
-               return -EBUSY;
-
-       vpfe_rsz->base_addr = ioremap_nocache(res->start, res_len);
-       if (!vpfe_rsz->base_addr)
-               return -EBUSY;
-
-       v4l2_subdev_init(sd, &resizer_v4l2_ops);
-       sd->internal_ops = &resizer_v4l2_internal_ops;
-       strscpy(sd->name, "DAVINCI RESIZER CROP", sizeof(sd->name));
-       sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
-       v4l2_set_subdevdata(sd, vpfe_rsz);
-       sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-
-       pads[RESIZER_CROP_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
-       pads[RESIZER_CROP_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
-       pads[RESIZER_CROP_PAD_SOURCE2].flags = MEDIA_PAD_FL_SOURCE;
-
-       vpfe_rsz->crop_resizer.input = RESIZER_CROP_INPUT_NONE;
-       vpfe_rsz->crop_resizer.output = RESIZER_CROP_OUTPUT_NONE;
-       vpfe_rsz->crop_resizer.output2 = RESIZER_CROP_OUTPUT_NONE;
-       vpfe_rsz->crop_resizer.rsz_device = vpfe_rsz;
-       me->ops = &resizer_media_ops;
-       ret = media_entity_pads_init(me, RESIZER_CROP_PADS_NUM, pads);
-       if (ret)
-               return ret;
-
-       sd = &vpfe_rsz->resizer_a.subdev;
-       pads = &vpfe_rsz->resizer_a.pads[0];
-       me = &sd->entity;
-
-       v4l2_subdev_init(sd, &resizer_v4l2_ops);
-       sd->internal_ops = &resizer_v4l2_internal_ops;
-       strscpy(sd->name, "DAVINCI RESIZER A", sizeof(sd->name));
-       sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
-       v4l2_set_subdevdata(sd, vpfe_rsz);
-       sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-
-       pads[RESIZER_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
-       pads[RESIZER_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
-
-       vpfe_rsz->resizer_a.input = RESIZER_INPUT_NONE;
-       vpfe_rsz->resizer_a.output = RESIZER_OUTPUT_NONE;
-       vpfe_rsz->resizer_a.rsz_device = vpfe_rsz;
-       me->ops = &resizer_media_ops;
-       ret = media_entity_pads_init(me, RESIZER_PADS_NUM, pads);
-       if (ret)
-               return ret;
-
-       sd = &vpfe_rsz->resizer_b.subdev;
-       pads = &vpfe_rsz->resizer_b.pads[0];
-       me = &sd->entity;
-
-       v4l2_subdev_init(sd, &resizer_v4l2_ops);
-       sd->internal_ops = &resizer_v4l2_internal_ops;
-       strscpy(sd->name, "DAVINCI RESIZER B", sizeof(sd->name));
-       sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
-       v4l2_set_subdevdata(sd, vpfe_rsz);
-       sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-
-       pads[RESIZER_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
-       pads[RESIZER_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
-
-       vpfe_rsz->resizer_b.input = RESIZER_INPUT_NONE;
-       vpfe_rsz->resizer_b.output = RESIZER_OUTPUT_NONE;
-       vpfe_rsz->resizer_b.rsz_device = vpfe_rsz;
-       me->ops = &resizer_media_ops;
-       ret = media_entity_pads_init(me, RESIZER_PADS_NUM, pads);
-       if (ret)
-               return ret;
-
-       vpfe_rsz->resizer_a.video_out.ops = &resizer_a_video_ops;
-       vpfe_rsz->resizer_a.video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       ret = vpfe_video_init(&vpfe_rsz->resizer_a.video_out, "RSZ-A");
-       if (ret) {
-               pr_err("Failed to init RSZ video-out device\n");
-               return ret;
-       }
-       vpfe_rsz->resizer_b.video_out.ops = &resizer_b_video_ops;
-       vpfe_rsz->resizer_b.video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       ret = vpfe_video_init(&vpfe_rsz->resizer_b.video_out, "RSZ-B");
-       if (ret) {
-               pr_err("Failed to init RSZ video-out2 device\n");
-               return ret;
-       }
-       memset(&vpfe_rsz->config, 0, sizeof(struct resizer_params));
-
-       return 0;
-}
-
-void
-vpfe_resizer_cleanup(struct vpfe_resizer_device *vpfe_rsz,
-                    struct platform_device *pdev)
-{
-       struct resource *res;
-
-       iounmap(vpfe_rsz->base_addr);
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 5);
-       if (res)
-               release_mem_region(res->start,
-                                       resource_size(res));
-}
diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.h b/drivers/staging/media/davinci_vpfe/dm365_resizer.h
deleted file mode 100644 (file)
index 5e31de9..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#ifndef _DAVINCI_VPFE_DM365_RESIZER_H
-#define _DAVINCI_VPFE_DM365_RESIZER_H
-
-enum resizer_oper_mode {
-       RESIZER_MODE_CONTINUOUS = 0,
-       RESIZER_MODE_ONE_SHOT = 1,
-};
-
-struct f_div_pass {
-       unsigned int o_hsz;
-       unsigned int i_hps;
-       unsigned int h_phs;
-       unsigned int src_hps;
-       unsigned int src_hsz;
-};
-
-#define MAX_PASSES             2
-
-struct f_div_param {
-       unsigned char en;
-       unsigned int num_passes;
-       struct f_div_pass pass[MAX_PASSES];
-};
-
-/* Resizer Rescale Parameters*/
-struct resizer_scale_param {
-       bool h_flip;
-       bool v_flip;
-       bool cen;
-       bool yen;
-       unsigned short i_vps;
-       unsigned short i_hps;
-       unsigned short o_vsz;
-       unsigned short o_hsz;
-       unsigned short v_phs_y;
-       unsigned short v_phs_c;
-       unsigned short v_dif;
-       /* resize method - Luminance */
-       enum vpfe_rsz_intp_t v_typ_y;
-       /* resize method - Chrominance */
-       enum vpfe_rsz_intp_t v_typ_c;
-       /* vertical lpf intensity - Luminance */
-       unsigned char v_lpf_int_y;
-       /* vertical lpf intensity - Chrominance */
-       unsigned char v_lpf_int_c;
-       unsigned short h_phs;
-       unsigned short h_dif;
-       /* resize method - Luminance */
-       enum vpfe_rsz_intp_t h_typ_y;
-       /* resize method - Chrominance */
-       enum vpfe_rsz_intp_t h_typ_c;
-       /* horizontal lpf intensity - Luminance */
-       unsigned char h_lpf_int_y;
-       /* horizontal lpf intensity - Chrominance */
-       unsigned char h_lpf_int_c;
-       bool dscale_en;
-       enum vpfe_rsz_down_scale_ave_sz h_dscale_ave_sz;
-       enum vpfe_rsz_down_scale_ave_sz v_dscale_ave_sz;
-       /* store the calculated frame division parameter */
-       struct f_div_param f_div;
-};
-
-enum resizer_rgb_t {
-       OUTPUT_32BIT,
-       OUTPUT_16BIT
-};
-
-enum resizer_rgb_msk_t {
-       NOMASK = 0,
-       MASKLAST2 = 1,
-};
-
-/* Resizer RGB Conversion Parameters */
-struct resizer_rgb {
-       bool rgb_en;
-       enum resizer_rgb_t rgb_typ;
-       enum resizer_rgb_msk_t rgb_msk0;
-       enum resizer_rgb_msk_t rgb_msk1;
-       unsigned int rgb_alpha_val;
-};
-
-/* Resizer External Memory Parameters */
-struct rsz_ext_mem_param {
-       unsigned int rsz_sdr_oft_y;
-       unsigned int rsz_sdr_ptr_s_y;
-       unsigned int rsz_sdr_ptr_e_y;
-       unsigned int rsz_sdr_oft_c;
-       unsigned int rsz_sdr_ptr_s_c;
-       unsigned int rsz_sdr_ptr_e_c;
-       /* offset to be added to buffer start when flipping for y/ycbcr */
-       unsigned int flip_ofst_y;
-       /* offset to be added to buffer start when flipping for c */
-       unsigned int flip_ofst_c;
-       /* c offset for YUV 420SP */
-       unsigned int c_offset;
-       /* User Defined Y offset for YUV 420SP or YUV420ILE data */
-       unsigned int user_y_ofst;
-       /* User Defined C offset for YUV 420SP data */
-       unsigned int user_c_ofst;
-};
-
-enum rsz_data_source {
-       IPIPE_DATA,
-       IPIPEIF_DATA
-};
-
-enum rsz_src_img_fmt {
-       RSZ_IMG_422,
-       RSZ_IMG_420
-};
-
-enum rsz_dpaths_bypass_t {
-       BYPASS_OFF = 0,
-       BYPASS_ON = 1,
-};
-
-struct rsz_common_params {
-       unsigned int vps;
-       unsigned int vsz;
-       unsigned int hps;
-       unsigned int hsz;
-       /* 420 or 422 */
-       enum rsz_src_img_fmt src_img_fmt;
-       /* Y or C when src_fmt is 420, 0 - y, 1 - c */
-       unsigned char y_c;
-       /* flip raw or ycbcr */
-       unsigned char raw_flip;
-       /* IPIPE or IPIPEIF data */
-       enum rsz_data_source source;
-       enum rsz_dpaths_bypass_t passthrough;
-       unsigned char yuv_y_min;
-       unsigned char yuv_y_max;
-       unsigned char yuv_c_min;
-       unsigned char yuv_c_max;
-       bool rsz_seq_crv;
-       enum vpfe_chr_pos out_chr_pos;
-};
-
-struct resizer_params {
-       enum resizer_oper_mode oper_mode;
-       struct rsz_common_params rsz_common;
-       struct resizer_scale_param rsz_rsc_param[2];
-       struct resizer_rgb rsz2rgb[2];
-       struct rsz_ext_mem_param ext_mem_param[2];
-       bool rsz_en[2];
-       struct vpfe_rsz_config_params user_config;
-};
-
-#define ENABLE                 1
-#define DISABLE                        (!ENABLE)
-
-#define RESIZER_CROP_PAD_SINK          0
-#define RESIZER_CROP_PAD_SOURCE                1
-#define RESIZER_CROP_PAD_SOURCE2       2
-
-#define RESIZER_CROP_PADS_NUM          3
-
-enum resizer_crop_input_entity {
-       RESIZER_CROP_INPUT_NONE = 0,
-       RESIZER_CROP_INPUT_IPIPEIF = 1,
-       RESIZER_CROP_INPUT_IPIPE = 2,
-};
-
-enum resizer_crop_output_entity {
-       RESIZER_CROP_OUTPUT_NONE,
-       RESIZER_A,
-       RESIZER_B,
-};
-
-struct dm365_crop_resizer_device {
-       struct v4l2_subdev                      subdev;
-       struct media_pad                        pads[RESIZER_CROP_PADS_NUM];
-       struct v4l2_mbus_framefmt               formats[RESIZER_CROP_PADS_NUM];
-       enum resizer_crop_input_entity          input;
-       enum resizer_crop_output_entity         output;
-       enum resizer_crop_output_entity         output2;
-       struct vpfe_resizer_device              *rsz_device;
-};
-
-#define RESIZER_PAD_SINK               0
-#define RESIZER_PAD_SOURCE             1
-
-#define RESIZER_PADS_NUM               2
-
-enum resizer_input_entity {
-       RESIZER_INPUT_NONE = 0,
-       RESIZER_INPUT_CROP_RESIZER = 1,
-};
-
-enum resizer_output_entity {
-       RESIZER_OUTPUT_NONE = 0,
-       RESIZER_OUTPUT_MEMORY = 1,
-};
-
-struct dm365_resizer_device {
-       struct v4l2_subdev              subdev;
-       struct media_pad                pads[RESIZER_PADS_NUM];
-       struct v4l2_mbus_framefmt       formats[RESIZER_PADS_NUM];
-       enum resizer_input_entity       input;
-       enum resizer_output_entity      output;
-       struct vpfe_video_device        video_out;
-       struct vpfe_resizer_device      *rsz_device;
-};
-
-struct vpfe_resizer_device {
-       struct dm365_crop_resizer_device        crop_resizer;
-       struct dm365_resizer_device             resizer_a;
-       struct dm365_resizer_device             resizer_b;
-       struct resizer_params                   config;
-       void __iomem *base_addr;
-};
-
-int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz,
-                     struct platform_device *pdev);
-int vpfe_resizer_register_entities(struct vpfe_resizer_device *vpfe_rsz,
-                                  struct v4l2_device *v4l2_dev);
-void vpfe_resizer_unregister_entities(struct vpfe_resizer_device *vpfe_rsz);
-void vpfe_resizer_cleanup(struct vpfe_resizer_device *vpfe_rsz,
-                         struct platform_device *pdev);
-void vpfe_resizer_buffer_isr(struct vpfe_resizer_device *resizer);
-void vpfe_resizer_dma_isr(struct vpfe_resizer_device *resizer);
-
-#endif         /* _DAVINCI_VPFE_DM365_RESIZER_H */
diff --git a/drivers/staging/media/davinci_vpfe/vpfe.h b/drivers/staging/media/davinci_vpfe/vpfe.h
deleted file mode 100644 (file)
index 1f8e011..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#ifndef _VPFE_H
-#define _VPFE_H
-
-#ifdef __KERNEL__
-#include <linux/v4l2-subdev.h>
-#include <linux/clk.h>
-#include <linux/i2c.h>
-
-#include <media/davinci/vpfe_types.h>
-
-#define CAPTURE_DRV_NAME       "vpfe-capture"
-
-struct vpfe_route {
-       __u32 input;
-       __u32 output;
-};
-
-enum vpfe_subdev_id {
-       VPFE_SUBDEV_TVP5146 = 1,
-       VPFE_SUBDEV_MT9T031 = 2,
-       VPFE_SUBDEV_TVP7002 = 3,
-       VPFE_SUBDEV_MT9P031 = 4,
-};
-
-struct vpfe_ext_subdev_info {
-       /* v4l2 subdev */
-       struct v4l2_subdev *subdev;
-       /* Sub device module name */
-       char module_name[32];
-       /* Sub device group id */
-       int grp_id;
-       /* Number of inputs supported */
-       int num_inputs;
-       /* inputs available at the sub device */
-       struct v4l2_input *inputs;
-       /* Sub dev routing information for each input */
-       struct vpfe_route *routes;
-       /* ccdc bus/interface configuration */
-       struct vpfe_hw_if_param ccdc_if_params;
-       /* i2c subdevice board info */
-       struct i2c_board_info board_info;
-       /* Is this a camera sub device ? */
-       unsigned is_camera:1;
-       /* check if sub dev supports routing */
-       unsigned can_route:1;
-       /* registered ? */
-       unsigned registered:1;
-};
-
-struct vpfe_config {
-       /* Number of sub devices connected to vpfe */
-       int num_subdevs;
-       /* information about each subdev */
-       struct vpfe_ext_subdev_info *sub_devs;
-       /* evm card info */
-       char *card_name;
-       /* setup function for the input path */
-       int (*setup_input)(enum vpfe_subdev_id id);
-       /* number of clocks */
-       int num_clocks;
-       /* clocks used for vpfe capture */
-       char *clocks[];
-};
-#endif
-#endif
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
deleted file mode 100644 (file)
index 9dc28ff..0000000
+++ /dev/null
@@ -1,716 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- *
- *
- * Driver name : VPFE Capture driver
- *    VPFE Capture driver allows applications to capture and stream video
- *    frames on DaVinci SoCs (DM6446, DM355 etc) from a YUV source such as
- *    TVP5146 or  Raw Bayer RGB image data from an image sensor
- *    such as Microns' MT9T001, MT9T031 etc.
- *
- *    These SoCs have, in common, a Video Processing Subsystem (VPSS) that
- *    consists of a Video Processing Front End (VPFE) for capturing
- *    video/raw image data and Video Processing Back End (VPBE) for displaying
- *    YUV data through an in-built analog encoder or Digital LCD port. This
- *    driver is for capture through VPFE. A typical EVM using these SoCs have
- *    following high level configuration.
- *
- *    decoder(TVP5146/         YUV/
- *     MT9T001)   -->  Raw Bayer RGB ---> MUX -> VPFE (CCDC/ISIF)
- *                     data input              |      |
- *                                                     V      |
- *                                                   SDRAM    |
- *                                                            V
- *                                                        Image Processor
- *                                                            |
- *                                                            V
- *                                                          SDRAM
- *    The data flow happens from a decoder connected to the VPFE over a
- *    YUV embedded (BT.656/BT.1120) or separate sync or raw bayer rgb interface
- *    and to the input of VPFE through an optional MUX (if more inputs are
- *    to be interfaced on the EVM). The input data is first passed through
- *    CCDC (CCD Controller, a.k.a Image Sensor Interface, ISIF). The CCDC
- *    does very little or no processing on YUV data and does pre-process Raw
- *    Bayer RGB data through modules such as Defect Pixel Correction (DFC)
- *    Color Space Conversion (CSC), data gain/offset etc. After this, data
- *    can be written to SDRAM or can be connected to the image processing
- *    block such as IPIPE (on DM355/DM365 only).
- *
- *    Features supported
- *             - MMAP IO
- *             - USERPTR IO
- *             - Capture using TVP5146 over BT.656
- *             - Support for interfacing decoders using sub device model
- *             - Work with DM365 or DM355 or DM6446 CCDC to do Raw Bayer
- *               RGB/YUV data capture to SDRAM.
- *             - Chaining of Image Processor
- *             - SINGLE-SHOT mode
- */
-
-#include <linux/interrupt.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-
-#include "vpfe.h"
-#include "vpfe_mc_capture.h"
-
-static bool debug;
-static bool interface;
-
-module_param(interface, bool, 0444);
-module_param(debug, bool, 0644);
-
-/*
- * VPFE capture can be used for capturing video such as from TVP5146 or TVP7002
- * and for capture raw bayer data from camera sensors such as mt9p031. At this
- * point there is problem in co-existence of mt9p031 and tvp5146 due to i2c
- * address collision. So set the variable below from bootargs to do either video
- * capture or camera capture.
- * interface = 0 - video capture (from TVP514x or such),
- * interface = 1 - Camera capture (from mt9p031 or such)
- * Re-visit this when we fix the co-existence issue
- */
-MODULE_PARM_DESC(interface, "interface 0-1 (default:0)");
-MODULE_PARM_DESC(debug, "Debug level 0-1");
-
-MODULE_DESCRIPTION("VPFE Video for Linux Capture Driver");
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Texas Instruments");
-
-/* map mbus_fmt to pixelformat */
-void mbus_to_pix(const struct v4l2_mbus_framefmt *mbus,
-                          struct v4l2_pix_format *pix)
-{
-       switch (mbus->code) {
-       case MEDIA_BUS_FMT_UYVY8_2X8:
-               pix->pixelformat = V4L2_PIX_FMT_UYVY;
-               pix->bytesperline = pix->width * 2;
-               break;
-
-       case MEDIA_BUS_FMT_YUYV8_2X8:
-               pix->pixelformat = V4L2_PIX_FMT_YUYV;
-               pix->bytesperline = pix->width * 2;
-               break;
-
-       case MEDIA_BUS_FMT_YUYV10_1X20:
-               pix->pixelformat = V4L2_PIX_FMT_UYVY;
-               pix->bytesperline = pix->width * 2;
-               break;
-
-       case MEDIA_BUS_FMT_SGRBG12_1X12:
-               pix->pixelformat = V4L2_PIX_FMT_SBGGR16;
-               pix->bytesperline = pix->width * 2;
-               break;
-
-       case MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8:
-               pix->pixelformat = V4L2_PIX_FMT_SGRBG10DPCM8;
-               pix->bytesperline = pix->width;
-               break;
-
-       case MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8:
-               pix->pixelformat = V4L2_PIX_FMT_SGRBG10ALAW8;
-               pix->bytesperline = pix->width;
-               break;
-
-       case MEDIA_BUS_FMT_YDYUYDYV8_1X16:
-               pix->pixelformat = V4L2_PIX_FMT_NV12;
-               pix->bytesperline = pix->width;
-               break;
-
-       case MEDIA_BUS_FMT_Y8_1X8:
-               pix->pixelformat = V4L2_PIX_FMT_GREY;
-               pix->bytesperline = pix->width;
-               break;
-
-       case MEDIA_BUS_FMT_UV8_1X8:
-               pix->pixelformat = V4L2_PIX_FMT_UV8;
-               pix->bytesperline = pix->width;
-               break;
-
-       default:
-               pr_err("Invalid mbus code set\n");
-       }
-       /* pitch should be 32 bytes aligned */
-       pix->bytesperline = ALIGN(pix->bytesperline, 32);
-       if (pix->pixelformat == V4L2_PIX_FMT_NV12)
-               pix->sizeimage = pix->bytesperline * pix->height +
-                               ((pix->bytesperline * pix->height) >> 1);
-       else
-               pix->sizeimage = pix->bytesperline * pix->height;
-}
-
-/* ISR for VINT0*/
-static irqreturn_t vpfe_isr(int irq, void *dev_id)
-{
-       struct vpfe_device *vpfe_dev = dev_id;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "%s\n", __func__);
-       vpfe_isif_buffer_isr(&vpfe_dev->vpfe_isif);
-       vpfe_resizer_buffer_isr(&vpfe_dev->vpfe_resizer);
-       return IRQ_HANDLED;
-}
-
-/* vpfe_vdint1_isr() - isr handler for VINT1 interrupt */
-static irqreturn_t vpfe_vdint1_isr(int irq, void *dev_id)
-{
-       struct vpfe_device *vpfe_dev = dev_id;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "%s\n", __func__);
-       vpfe_isif_vidint1_isr(&vpfe_dev->vpfe_isif);
-       return IRQ_HANDLED;
-}
-
-/* vpfe_imp_dma_isr() - ISR for ipipe dma completion */
-static irqreturn_t vpfe_imp_dma_isr(int irq, void *dev_id)
-{
-       struct vpfe_device *vpfe_dev = dev_id;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "%s\n", __func__);
-       vpfe_ipipeif_ss_buffer_isr(&vpfe_dev->vpfe_ipipeif);
-       vpfe_resizer_dma_isr(&vpfe_dev->vpfe_resizer);
-       return IRQ_HANDLED;
-}
-
-/*
- * vpfe_disable_clock() - Disable clocks for vpfe capture driver
- * @vpfe_dev - ptr to vpfe capture device
- *
- * Disables clocks defined in vpfe configuration. The function
- * assumes that at least one clock is to be defined which is
- * true as of now.
- */
-static void vpfe_disable_clock(struct vpfe_device *vpfe_dev)
-{
-       struct vpfe_config *vpfe_cfg = vpfe_dev->cfg;
-       int i;
-
-       for (i = 0; i < vpfe_cfg->num_clocks; i++) {
-               clk_disable_unprepare(vpfe_dev->clks[i]);
-               clk_put(vpfe_dev->clks[i]);
-       }
-       kzfree(vpfe_dev->clks);
-       v4l2_info(vpfe_dev->pdev->driver, "vpfe capture clocks disabled\n");
-}
-
-/*
- * vpfe_enable_clock() - Enable clocks for vpfe capture driver
- * @vpfe_dev - ptr to vpfe capture device
- *
- * Enables clocks defined in vpfe configuration. The function
- * assumes that at least one clock is to be defined which is
- * true as of now.
- */
-static int vpfe_enable_clock(struct vpfe_device *vpfe_dev)
-{
-       struct vpfe_config *vpfe_cfg = vpfe_dev->cfg;
-       int ret = -EFAULT;
-       int i;
-
-       if (!vpfe_cfg->num_clocks)
-               return 0;
-
-       vpfe_dev->clks = kcalloc(vpfe_cfg->num_clocks,
-                                sizeof(*vpfe_dev->clks), GFP_KERNEL);
-       if (!vpfe_dev->clks)
-               return -ENOMEM;
-
-       for (i = 0; i < vpfe_cfg->num_clocks; i++) {
-               if (vpfe_cfg->clocks[i] == NULL) {
-                       v4l2_err(vpfe_dev->pdev->driver,
-                               "clock %s is not defined in vpfe config\n",
-                               vpfe_cfg->clocks[i]);
-                       goto out;
-               }
-
-               vpfe_dev->clks[i] =
-                               clk_get(vpfe_dev->pdev, vpfe_cfg->clocks[i]);
-               if (IS_ERR(vpfe_dev->clks[i])) {
-                       v4l2_err(vpfe_dev->pdev->driver,
-                               "Failed to get clock %s\n",
-                               vpfe_cfg->clocks[i]);
-                       goto out;
-               }
-
-               if (clk_prepare_enable(vpfe_dev->clks[i])) {
-                       v4l2_err(vpfe_dev->pdev->driver,
-                               "vpfe clock %s not enabled\n",
-                               vpfe_cfg->clocks[i]);
-                       goto out;
-               }
-
-               v4l2_info(vpfe_dev->pdev->driver, "vpss clock %s enabled",
-                         vpfe_cfg->clocks[i]);
-       }
-
-       return 0;
-out:
-       for (i = 0; i < vpfe_cfg->num_clocks; i++)
-               if (!IS_ERR(vpfe_dev->clks[i])) {
-                       clk_disable_unprepare(vpfe_dev->clks[i]);
-                       clk_put(vpfe_dev->clks[i]);
-               }
-
-       v4l2_err(vpfe_dev->pdev->driver, "Failed to enable clocks\n");
-       kzfree(vpfe_dev->clks);
-
-       return ret;
-}
-
-/*
- * vpfe_detach_irq() - Detach IRQs for vpfe capture driver
- * @vpfe_dev - ptr to vpfe capture device
- *
- * Detach all IRQs defined in vpfe configuration.
- */
-static void vpfe_detach_irq(struct vpfe_device *vpfe_dev)
-{
-       free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
-       free_irq(vpfe_dev->ccdc_irq1, vpfe_dev);
-       free_irq(vpfe_dev->imp_dma_irq, vpfe_dev);
-}
-
-/*
- * vpfe_attach_irq() - Attach IRQs for vpfe capture driver
- * @vpfe_dev - ptr to vpfe capture device
- *
- * Attach all IRQs defined in vpfe configuration.
- */
-static int vpfe_attach_irq(struct vpfe_device *vpfe_dev)
-{
-       int ret;
-
-       ret = request_irq(vpfe_dev->ccdc_irq0, vpfe_isr, 0,
-                         "vpfe_capture0", vpfe_dev);
-       if (ret < 0) {
-               v4l2_err(&vpfe_dev->v4l2_dev,
-                       "Error: requesting VINT0 interrupt\n");
-               return ret;
-       }
-
-       ret = request_irq(vpfe_dev->ccdc_irq1, vpfe_vdint1_isr, 0,
-                         "vpfe_capture1", vpfe_dev);
-       if (ret < 0) {
-               v4l2_err(&vpfe_dev->v4l2_dev,
-                       "Error: requesting VINT1 interrupt\n");
-               free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
-               return ret;
-       }
-
-       ret = request_irq(vpfe_dev->imp_dma_irq, vpfe_imp_dma_isr,
-                         0, "Imp_Sdram_Irq", vpfe_dev);
-       if (ret < 0) {
-               v4l2_err(&vpfe_dev->v4l2_dev,
-                        "Error: requesting IMP IRQ interrupt\n");
-               free_irq(vpfe_dev->ccdc_irq1, vpfe_dev);
-               free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
-               return ret;
-       }
-
-       return 0;
-}
-
-/*
- * register_i2c_devices() - register all i2c v4l2 subdevs
- * @vpfe_dev - ptr to vpfe capture device
- *
- * register all i2c v4l2 subdevs
- */
-static int register_i2c_devices(struct vpfe_device *vpfe_dev)
-{
-       struct vpfe_ext_subdev_info *sdinfo;
-       struct vpfe_config *vpfe_cfg;
-       struct i2c_adapter *i2c_adap;
-       unsigned int num_subdevs;
-       int ret;
-       int i;
-       int k;
-
-       vpfe_cfg = vpfe_dev->cfg;
-       i2c_adap = i2c_get_adapter(1);
-       num_subdevs = vpfe_cfg->num_subdevs;
-       vpfe_dev->sd =
-                 kcalloc(num_subdevs, sizeof(struct v4l2_subdev *),
-                         GFP_KERNEL);
-       if (!vpfe_dev->sd)
-               return -ENOMEM;
-
-       for (i = 0, k = 0; i < num_subdevs; i++) {
-               sdinfo = &vpfe_cfg->sub_devs[i];
-               /*
-                * register subdevices based on interface setting. Currently
-                * tvp5146 and mt9p031 cannot co-exists due to i2c address
-                * conflicts. So only one of them is registered. Re-visit this
-                * once we have support for i2c switch handling in i2c driver
-                * framework
-                */
-               if (interface == sdinfo->is_camera) {
-                       /* setup input path */
-                       if (vpfe_cfg->setup_input &&
-                               vpfe_cfg->setup_input(sdinfo->grp_id) < 0) {
-                               ret = -EFAULT;
-                               v4l2_info(&vpfe_dev->v4l2_dev,
-                                         "could not setup input for %s\n",
-                                               sdinfo->module_name);
-                               goto probe_sd_out;
-                       }
-                       /* Load up the subdevice */
-                       vpfe_dev->sd[k] =
-                               v4l2_i2c_new_subdev_board(&vpfe_dev->v4l2_dev,
-                                                 i2c_adap, &sdinfo->board_info,
-                                                 NULL);
-                       if (vpfe_dev->sd[k]) {
-                               v4l2_info(&vpfe_dev->v4l2_dev,
-                                               "v4l2 sub device %s registered\n",
-                                               sdinfo->module_name);
-
-                               vpfe_dev->sd[k]->grp_id = sdinfo->grp_id;
-                               k++;
-
-                               sdinfo->registered = 1;
-                       }
-               } else {
-                       v4l2_info(&vpfe_dev->v4l2_dev,
-                                 "v4l2 sub device %s is not registered\n",
-                                 sdinfo->module_name);
-               }
-       }
-       vpfe_dev->num_ext_subdevs = k;
-
-       return 0;
-
-probe_sd_out:
-       kzfree(vpfe_dev->sd);
-
-       return ret;
-}
-
-/*
- * vpfe_register_entities() - register all v4l2 subdevs and media entities
- * @vpfe_dev - ptr to vpfe capture device
- *
- * register all v4l2 subdevs, media entities, and creates links
- * between entities
- */
-static int vpfe_register_entities(struct vpfe_device *vpfe_dev)
-{
-       unsigned int flags = 0;
-       int ret;
-       int i;
-
-       /* register i2c devices first */
-       ret = register_i2c_devices(vpfe_dev);
-       if (ret)
-               return ret;
-
-       /* register rest of the sub-devs */
-       ret = vpfe_isif_register_entities(&vpfe_dev->vpfe_isif,
-                                         &vpfe_dev->v4l2_dev);
-       if (ret)
-               return ret;
-
-       ret = vpfe_ipipeif_register_entities(&vpfe_dev->vpfe_ipipeif,
-                                            &vpfe_dev->v4l2_dev);
-       if (ret)
-               goto out_isif_register;
-
-       ret = vpfe_ipipe_register_entities(&vpfe_dev->vpfe_ipipe,
-                                          &vpfe_dev->v4l2_dev);
-       if (ret)
-               goto out_ipipeif_register;
-
-       ret = vpfe_resizer_register_entities(&vpfe_dev->vpfe_resizer,
-                                            &vpfe_dev->v4l2_dev);
-       if (ret)
-               goto out_ipipe_register;
-
-       /* create links now, starting with external(i2c) entities */
-       for (i = 0; i < vpfe_dev->num_ext_subdevs; i++)
-               /*
-                * if entity has no pads (ex: amplifier),
-                * can't establish link
-                */
-               if (vpfe_dev->sd[i]->entity.num_pads) {
-                       ret = media_create_pad_link(&vpfe_dev->sd[i]->entity,
-                               0, &vpfe_dev->vpfe_isif.subdev.entity,
-                               0, flags);
-                       if (ret < 0)
-                               goto out_resizer_register;
-               }
-
-       ret = media_create_pad_link(&vpfe_dev->vpfe_isif.subdev.entity, 1,
-                                      &vpfe_dev->vpfe_ipipeif.subdev.entity,
-                                      0, flags);
-       if (ret < 0)
-               goto out_resizer_register;
-
-       ret = media_create_pad_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1,
-                                      &vpfe_dev->vpfe_ipipe.subdev.entity,
-                                      0, flags);
-       if (ret < 0)
-               goto out_resizer_register;
-
-       ret = media_create_pad_link(&vpfe_dev->vpfe_ipipe.subdev.entity,
-                       1, &vpfe_dev->vpfe_resizer.crop_resizer.subdev.entity,
-                       0, flags);
-       if (ret < 0)
-               goto out_resizer_register;
-
-       ret = media_create_pad_link(&vpfe_dev->vpfe_ipipeif.subdev.entity, 1,
-                       &vpfe_dev->vpfe_resizer.crop_resizer.subdev.entity,
-                       0, flags);
-       if (ret < 0)
-               goto out_resizer_register;
-
-       ret = v4l2_device_register_subdev_nodes(&vpfe_dev->v4l2_dev);
-       if (ret < 0)
-               goto out_resizer_register;
-
-       return 0;
-
-out_resizer_register:
-       vpfe_resizer_unregister_entities(&vpfe_dev->vpfe_resizer);
-out_ipipe_register:
-       vpfe_ipipe_unregister_entities(&vpfe_dev->vpfe_ipipe);
-out_ipipeif_register:
-       vpfe_ipipeif_unregister_entities(&vpfe_dev->vpfe_ipipeif);
-out_isif_register:
-       vpfe_isif_unregister_entities(&vpfe_dev->vpfe_isif);
-
-       return ret;
-}
-
-/*
- * vpfe_unregister_entities() - unregister all v4l2 subdevs and media entities
- * @vpfe_dev - ptr to vpfe capture device
- *
- * unregister all v4l2 subdevs and media entities
- */
-static void vpfe_unregister_entities(struct vpfe_device *vpfe_dev)
-{
-       vpfe_isif_unregister_entities(&vpfe_dev->vpfe_isif);
-       vpfe_ipipeif_unregister_entities(&vpfe_dev->vpfe_ipipeif);
-       vpfe_ipipe_unregister_entities(&vpfe_dev->vpfe_ipipe);
-       vpfe_resizer_unregister_entities(&vpfe_dev->vpfe_resizer);
-}
-
-/*
- * vpfe_cleanup_modules() - cleanup all non-i2c v4l2 subdevs
- * @vpfe_dev - ptr to vpfe capture device
- * @pdev - pointer to platform device
- *
- * cleanup all v4l2 subdevs
- */
-static void vpfe_cleanup_modules(struct vpfe_device *vpfe_dev,
-                                struct platform_device *pdev)
-{
-       vpfe_isif_cleanup(&vpfe_dev->vpfe_isif, pdev);
-       vpfe_ipipeif_cleanup(&vpfe_dev->vpfe_ipipeif, pdev);
-       vpfe_ipipe_cleanup(&vpfe_dev->vpfe_ipipe, pdev);
-       vpfe_resizer_cleanup(&vpfe_dev->vpfe_resizer, pdev);
-}
-
-/*
- * vpfe_initialize_modules() - initialize all non-i2c v4l2 subdevs
- * @vpfe_dev - ptr to vpfe capture device
- * @pdev - pointer to platform device
- *
- * initialize all v4l2 subdevs and media entities
- */
-static int vpfe_initialize_modules(struct vpfe_device *vpfe_dev,
-                                  struct platform_device *pdev)
-{
-       int ret;
-
-       ret = vpfe_isif_init(&vpfe_dev->vpfe_isif, pdev);
-       if (ret)
-               return ret;
-
-       ret = vpfe_ipipeif_init(&vpfe_dev->vpfe_ipipeif, pdev);
-       if (ret)
-               goto out_isif_init;
-
-       ret = vpfe_ipipe_init(&vpfe_dev->vpfe_ipipe, pdev);
-       if (ret)
-               goto out_ipipeif_init;
-
-       ret = vpfe_resizer_init(&vpfe_dev->vpfe_resizer, pdev);
-       if (ret)
-               goto out_ipipe_init;
-
-       return 0;
-
-out_ipipe_init:
-       vpfe_ipipe_cleanup(&vpfe_dev->vpfe_ipipe, pdev);
-out_ipipeif_init:
-       vpfe_ipipeif_cleanup(&vpfe_dev->vpfe_ipipeif, pdev);
-out_isif_init:
-       vpfe_isif_cleanup(&vpfe_dev->vpfe_isif, pdev);
-
-       return ret;
-}
-
-/*
- * vpfe_probe() : vpfe probe function
- * @pdev: platform device pointer
- *
- * This function creates device entries by register itself to the V4L2 driver
- * and initializes fields of each device objects
- */
-static int vpfe_probe(struct platform_device *pdev)
-{
-       struct vpfe_device *vpfe_dev;
-       struct resource *res1;
-       int ret = -ENOMEM;
-
-       vpfe_dev = kzalloc(sizeof(*vpfe_dev), GFP_KERNEL);
-       if (!vpfe_dev)
-               return ret;
-
-       if (pdev->dev.platform_data == NULL) {
-               v4l2_err(pdev->dev.driver, "Unable to get vpfe config\n");
-               ret = -ENOENT;
-               goto probe_free_dev_mem;
-       }
-
-       vpfe_dev->cfg = pdev->dev.platform_data;
-       if (vpfe_dev->cfg->card_name == NULL ||
-                       vpfe_dev->cfg->sub_devs == NULL) {
-               v4l2_err(pdev->dev.driver, "null ptr in vpfe_cfg\n");
-               ret = -ENOENT;
-               goto probe_free_dev_mem;
-       }
-
-       /* Get VINT0 irq resource */
-       res1 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-       if (!res1) {
-               v4l2_err(pdev->dev.driver,
-                        "Unable to get interrupt for VINT0\n");
-               ret = -ENOENT;
-               goto probe_free_dev_mem;
-       }
-       vpfe_dev->ccdc_irq0 = res1->start;
-
-       /* Get VINT1 irq resource */
-       res1 = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
-       if (!res1) {
-               v4l2_err(pdev->dev.driver,
-                        "Unable to get interrupt for VINT1\n");
-               ret = -ENOENT;
-               goto probe_free_dev_mem;
-       }
-       vpfe_dev->ccdc_irq1 = res1->start;
-
-       /* Get DMA irq resource */
-       res1 = platform_get_resource(pdev, IORESOURCE_IRQ, 2);
-       if (!res1) {
-               v4l2_err(pdev->dev.driver,
-                        "Unable to get interrupt for DMA\n");
-               ret = -ENOENT;
-               goto probe_free_dev_mem;
-       }
-       vpfe_dev->imp_dma_irq = res1->start;
-
-       vpfe_dev->pdev = &pdev->dev;
-
-       /* enable vpss clocks */
-       ret = vpfe_enable_clock(vpfe_dev);
-       if (ret)
-               goto probe_free_dev_mem;
-
-       ret = vpfe_initialize_modules(vpfe_dev, pdev);
-       if (ret)
-               goto probe_disable_clock;
-
-       vpfe_dev->media_dev.dev = vpfe_dev->pdev;
-       strscpy((char *)&vpfe_dev->media_dev.model, "davinci-media",
-               sizeof(vpfe_dev->media_dev.model));
-
-       ret = media_device_register(&vpfe_dev->media_dev);
-       if (ret) {
-               v4l2_err(pdev->dev.driver,
-                       "Unable to register media device.\n");
-               goto probe_out_entities_cleanup;
-       }
-
-       vpfe_dev->v4l2_dev.mdev = &vpfe_dev->media_dev;
-       ret = v4l2_device_register(&pdev->dev, &vpfe_dev->v4l2_dev);
-       if (ret) {
-               v4l2_err(pdev->dev.driver, "Unable to register v4l2 device.\n");
-               goto probe_out_media_unregister;
-       }
-
-       v4l2_info(&vpfe_dev->v4l2_dev, "v4l2 device registered\n");
-       /* set the driver data in platform device */
-       platform_set_drvdata(pdev, vpfe_dev);
-       /* register subdevs/entities */
-       ret = vpfe_register_entities(vpfe_dev);
-       if (ret)
-               goto probe_out_v4l2_unregister;
-
-       ret = vpfe_attach_irq(vpfe_dev);
-       if (ret)
-               goto probe_out_entities_unregister;
-
-       return 0;
-
-probe_out_entities_unregister:
-       vpfe_unregister_entities(vpfe_dev);
-       kzfree(vpfe_dev->sd);
-probe_out_v4l2_unregister:
-       v4l2_device_unregister(&vpfe_dev->v4l2_dev);
-probe_out_media_unregister:
-       media_device_unregister(&vpfe_dev->media_dev);
-probe_out_entities_cleanup:
-       vpfe_cleanup_modules(vpfe_dev, pdev);
-probe_disable_clock:
-       vpfe_disable_clock(vpfe_dev);
-probe_free_dev_mem:
-       kzfree(vpfe_dev);
-
-       return ret;
-}
-
-/*
- * vpfe_remove : This function un-registers device from V4L2 driver
- */
-static int vpfe_remove(struct platform_device *pdev)
-{
-       struct vpfe_device *vpfe_dev = platform_get_drvdata(pdev);
-
-       v4l2_info(pdev->dev.driver, "%s\n", __func__);
-
-       kzfree(vpfe_dev->sd);
-       vpfe_detach_irq(vpfe_dev);
-       vpfe_unregister_entities(vpfe_dev);
-       vpfe_cleanup_modules(vpfe_dev, pdev);
-       v4l2_device_unregister(&vpfe_dev->v4l2_dev);
-       media_device_unregister(&vpfe_dev->media_dev);
-       vpfe_disable_clock(vpfe_dev);
-       kzfree(vpfe_dev);
-
-       return 0;
-}
-
-static struct platform_driver vpfe_driver = {
-       .driver = {
-               .name = CAPTURE_DRV_NAME,
-       },
-       .probe = vpfe_probe,
-       .remove = vpfe_remove,
-};
-
-module_platform_driver(vpfe_driver);
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h
deleted file mode 100644 (file)
index fe4a421..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#ifndef _DAVINCI_VPFE_MC_CAPTURE_H
-#define _DAVINCI_VPFE_MC_CAPTURE_H
-
-#include "dm365_ipipe.h"
-#include "dm365_ipipeif.h"
-#include "dm365_isif.h"
-#include "dm365_resizer.h"
-#include "vpfe_video.h"
-
-#define VPFE_MAJOR_RELEASE             0
-#define VPFE_MINOR_RELEASE             0
-#define VPFE_BUILD                     1
-#define VPFE_CAPTURE_VERSION_CODE       ((VPFE_MAJOR_RELEASE << 16) | \
-                                       (VPFE_MINOR_RELEASE << 8)  | \
-                                       VPFE_BUILD)
-
-/* IPIPE hardware limits */
-#define IPIPE_MAX_OUTPUT_WIDTH_A       2176
-#define IPIPE_MAX_OUTPUT_WIDTH_B       640
-
-/* Based on max resolution supported. QXGA */
-#define IPIPE_MAX_OUTPUT_HEIGHT_A      1536
-/* Based on max resolution supported. VGA */
-#define IPIPE_MAX_OUTPUT_HEIGHT_B      480
-
-#define to_vpfe_device(ptr_module)                             \
-       container_of(ptr_module, struct vpfe_device, vpfe_##ptr_module)
-#define to_device(ptr_module)                                          \
-       (to_vpfe_device(ptr_module)->dev)
-
-struct vpfe_device {
-       /* external registered sub devices */
-       struct v4l2_subdev              **sd;
-       /* number of registered external subdevs */
-       unsigned int                    num_ext_subdevs;
-       /* vpfe cfg */
-       struct vpfe_config              *cfg;
-       /* clock ptrs for vpfe capture */
-       struct clk                      **clks;
-       /* V4l2 device */
-       struct v4l2_device              v4l2_dev;
-       /* parent device */
-       struct device                   *pdev;
-       /* IRQ number for DMA transfer completion at the image processor */
-       unsigned int                    imp_dma_irq;
-       /* CCDC IRQs used when CCDC/ISIF output to SDRAM */
-       unsigned int                    ccdc_irq0;
-       unsigned int                    ccdc_irq1;
-       /* media device */
-       struct media_device             media_dev;
-       /* ccdc subdevice */
-       struct vpfe_isif_device         vpfe_isif;
-       /* ipipeif subdevice */
-       struct vpfe_ipipeif_device      vpfe_ipipeif;
-       /* ipipe subdevice */
-       struct vpfe_ipipe_device        vpfe_ipipe;
-       /* resizer subdevice */
-       struct vpfe_resizer_device      vpfe_resizer;
-};
-
-/* File handle structure */
-struct vpfe_fh {
-       struct v4l2_fh vfh;
-       struct vpfe_video_device *video;
-       /* Indicates whether this file handle is doing IO */
-       u8 io_allowed;
-};
-
-void mbus_to_pix(const struct v4l2_mbus_framefmt *mbus,
-                          struct v4l2_pix_format *pix);
-
-#endif         /* _DAVINCI_VPFE_MC_CAPTURE_H */
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c
deleted file mode 100644 (file)
index ab6bc45..0000000
+++ /dev/null
@@ -1,1646 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#include <linux/module.h>
-#include <linux/slab.h>
-
-#include <media/v4l2-ioctl.h>
-
-#include "vpfe.h"
-#include "vpfe_mc_capture.h"
-
-static int debug;
-
-/* get v4l2 subdev pointer to external subdev which is active */
-static struct media_entity *vpfe_get_input_entity
-                       (struct vpfe_video_device *video)
-{
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct media_pad *remote;
-
-       remote = media_entity_remote_pad(&vpfe_dev->vpfe_isif.pads[0]);
-       if (!remote) {
-               pr_err("Invalid media connection to isif/ccdc\n");
-               return NULL;
-       }
-       return remote->entity;
-}
-
-/* updates external subdev(sensor/decoder) which is active */
-static int vpfe_update_current_ext_subdev(struct vpfe_video_device *video)
-{
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct vpfe_config *vpfe_cfg;
-       struct v4l2_subdev *subdev;
-       struct media_pad *remote;
-       int i;
-
-       remote = media_entity_remote_pad(&vpfe_dev->vpfe_isif.pads[0]);
-       if (!remote) {
-               pr_err("Invalid media connection to isif/ccdc\n");
-               return -EINVAL;
-       }
-
-       subdev = media_entity_to_v4l2_subdev(remote->entity);
-       vpfe_cfg = vpfe_dev->pdev->platform_data;
-       for (i = 0; i < vpfe_cfg->num_subdevs; i++) {
-               if (!strcmp(vpfe_cfg->sub_devs[i].module_name, subdev->name)) {
-                       video->current_ext_subdev = &vpfe_cfg->sub_devs[i];
-                       break;
-               }
-       }
-
-       /* if user not linked decoder/sensor to isif/ccdc */
-       if (i == vpfe_cfg->num_subdevs) {
-               pr_err("Invalid media chain connection to isif/ccdc\n");
-               return -EINVAL;
-       }
-       /* find the v4l2 subdev pointer */
-       for (i = 0; i < vpfe_dev->num_ext_subdevs; i++) {
-               if (!strcmp(video->current_ext_subdev->module_name,
-                       vpfe_dev->sd[i]->name))
-                       video->current_ext_subdev->subdev = vpfe_dev->sd[i];
-       }
-       return 0;
-}
-
-/* get the subdev which is connected to the output video node */
-static struct v4l2_subdev *
-vpfe_video_remote_subdev(struct vpfe_video_device *video, u32 *pad)
-{
-       struct media_pad *remote = media_entity_remote_pad(&video->pad);
-
-       if (!remote || !is_media_entity_v4l2_subdev(remote->entity))
-               return NULL;
-       if (pad)
-               *pad = remote->index;
-       return media_entity_to_v4l2_subdev(remote->entity);
-}
-
-/* get the format set at output pad of the adjacent subdev */
-static int
-__vpfe_video_get_format(struct vpfe_video_device *video,
-                       struct v4l2_format *format)
-{
-       struct v4l2_subdev_format fmt;
-       struct v4l2_subdev *subdev;
-       struct media_pad *remote;
-       u32 pad;
-       int ret;
-
-       subdev = vpfe_video_remote_subdev(video, &pad);
-       if (!subdev)
-               return -EINVAL;
-
-       fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
-       remote = media_entity_remote_pad(&video->pad);
-       fmt.pad = remote->index;
-
-       ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
-       if (ret == -ENOIOCTLCMD)
-               return -EINVAL;
-
-       format->type = video->type;
-       /* convert mbus_format to v4l2_format */
-       v4l2_fill_pix_format(&format->fmt.pix, &fmt.format);
-       mbus_to_pix(&fmt.format, &format->fmt.pix);
-
-       return 0;
-}
-
-/* make a note of pipeline details */
-static int vpfe_prepare_pipeline(struct vpfe_video_device *video)
-{
-       struct media_graph graph;
-       struct media_entity *entity = &video->video_dev.entity;
-       struct media_device *mdev = entity->graph_obj.mdev;
-       struct vpfe_pipeline *pipe = &video->pipe;
-       struct vpfe_video_device *far_end = NULL;
-       int ret;
-
-       pipe->input_num = 0;
-       pipe->output_num = 0;
-
-       if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
-               pipe->inputs[pipe->input_num++] = video;
-       else
-               pipe->outputs[pipe->output_num++] = video;
-
-       mutex_lock(&mdev->graph_mutex);
-       ret = media_graph_walk_init(&graph, mdev);
-       if (ret) {
-               mutex_unlock(&mdev->graph_mutex);
-               return -ENOMEM;
-       }
-       media_graph_walk_start(&graph, entity);
-       while ((entity = media_graph_walk_next(&graph))) {
-               if (entity == &video->video_dev.entity)
-                       continue;
-               if (!is_media_entity_v4l2_video_device(entity))
-                       continue;
-               far_end = to_vpfe_video(media_entity_to_video_device(entity));
-               if (far_end->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
-                       pipe->inputs[pipe->input_num++] = far_end;
-               else
-                       pipe->outputs[pipe->output_num++] = far_end;
-       }
-       media_graph_walk_cleanup(&graph);
-       mutex_unlock(&mdev->graph_mutex);
-
-       return 0;
-}
-
-/* update pipe state selected by user */
-static int vpfe_update_pipe_state(struct vpfe_video_device *video)
-{
-       struct vpfe_pipeline *pipe = &video->pipe;
-       int ret;
-
-       ret = vpfe_prepare_pipeline(video);
-       if (ret)
-               return ret;
-
-       /*
-        * Find out if there is any input video
-        * if yes, it is single shot.
-        */
-       if (pipe->input_num == 0) {
-               pipe->state = VPFE_PIPELINE_STREAM_CONTINUOUS;
-               ret = vpfe_update_current_ext_subdev(video);
-               if (ret) {
-                       pr_err("Invalid external subdev\n");
-                       return ret;
-               }
-       } else {
-               pipe->state = VPFE_PIPELINE_STREAM_SINGLESHOT;
-       }
-       video->initialized = 1;
-       video->skip_frame_count = 1;
-       video->skip_frame_count_init = 1;
-       return 0;
-}
-
-/* checks whether pipeline is ready for enabling */
-int vpfe_video_is_pipe_ready(struct vpfe_pipeline *pipe)
-{
-       int i;
-
-       for (i = 0; i < pipe->input_num; i++)
-               if (!pipe->inputs[i]->started ||
-                       pipe->inputs[i]->state != VPFE_VIDEO_BUFFER_QUEUED)
-                       return 0;
-       for (i = 0; i < pipe->output_num; i++)
-               if (!pipe->outputs[i]->started ||
-                       pipe->outputs[i]->state != VPFE_VIDEO_BUFFER_QUEUED)
-                       return 0;
-       return 1;
-}
-
-/*
- * Validate a pipeline by checking both ends of all links for format
- * discrepancies.
- *
- * Return 0 if all formats match, or -EPIPE if at least one link is found with
- * different formats on its two ends.
- */
-static int vpfe_video_validate_pipeline(struct vpfe_pipeline *pipe)
-{
-       struct v4l2_subdev_format fmt_source;
-       struct v4l2_subdev_format fmt_sink;
-       struct v4l2_subdev *subdev;
-       struct media_pad *pad;
-       int ret;
-
-       /*
-        * Should not matter if it is output[0] or 1 as
-        * the general ideas is to traverse backwards and
-        * the fact that the out video node always has the
-        * format of the connected pad.
-        */
-       subdev = vpfe_video_remote_subdev(pipe->outputs[0], NULL);
-       if (!subdev)
-               return -EPIPE;
-
-       while (1) {
-               /* Retrieve the sink format */
-               pad = &subdev->entity.pads[0];
-               if (!(pad->flags & MEDIA_PAD_FL_SINK))
-                       break;
-
-               fmt_sink.which = V4L2_SUBDEV_FORMAT_ACTIVE;
-               fmt_sink.pad = pad->index;
-               ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL,
-                                      &fmt_sink);
-
-               if (ret < 0 && ret != -ENOIOCTLCMD)
-                       return -EPIPE;
-
-               /* Retrieve the source format */
-               pad = media_entity_remote_pad(pad);
-               if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
-                       break;
-
-               subdev = media_entity_to_v4l2_subdev(pad->entity);
-
-               fmt_source.which = V4L2_SUBDEV_FORMAT_ACTIVE;
-               fmt_source.pad = pad->index;
-               ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt_source);
-               if (ret < 0 && ret != -ENOIOCTLCMD)
-                       return -EPIPE;
-
-               /* Check if the two ends match */
-               if (fmt_source.format.code != fmt_sink.format.code ||
-                   fmt_source.format.width != fmt_sink.format.width ||
-                   fmt_source.format.height != fmt_sink.format.height)
-                       return -EPIPE;
-       }
-       return 0;
-}
-
-/*
- * vpfe_pipeline_enable() - Enable streaming on a pipeline
- * @vpfe_dev: vpfe device
- * @pipe: vpfe pipeline
- *
- * Walk the entities chain starting at the pipeline output video node and start
- * all modules in the chain in the given mode.
- *
- * Return 0 if successful, or the return value of the failed video::s_stream
- * operation otherwise.
- */
-static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
-{
-       struct media_entity *entity;
-       struct v4l2_subdev *subdev;
-       struct media_device *mdev;
-       int ret;
-
-       if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS)
-               entity = vpfe_get_input_entity(pipe->outputs[0]);
-       else
-               entity = &pipe->inputs[0]->video_dev.entity;
-
-       mdev = entity->graph_obj.mdev;
-       mutex_lock(&mdev->graph_mutex);
-       ret = media_graph_walk_init(&pipe->graph, mdev);
-       if (ret)
-               goto out;
-       media_graph_walk_start(&pipe->graph, entity);
-       while ((entity = media_graph_walk_next(&pipe->graph))) {
-
-               if (!is_media_entity_v4l2_subdev(entity))
-                       continue;
-               subdev = media_entity_to_v4l2_subdev(entity);
-               ret = v4l2_subdev_call(subdev, video, s_stream, 1);
-               if (ret < 0 && ret != -ENOIOCTLCMD)
-                       break;
-       }
-out:
-       if (ret)
-               media_graph_walk_cleanup(&pipe->graph);
-       mutex_unlock(&mdev->graph_mutex);
-       return ret;
-}
-
-/*
- * vpfe_pipeline_disable() - Disable streaming on a pipeline
- * @vpfe_dev: vpfe device
- * @pipe: VPFE pipeline
- *
- * Walk the entities chain starting at the pipeline output video node and stop
- * all modules in the chain.
- *
- * Return 0 if all modules have been properly stopped, or -ETIMEDOUT if a module
- * can't be stopped.
- */
-static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
-{
-       struct media_entity *entity;
-       struct v4l2_subdev *subdev;
-       struct media_device *mdev;
-       int ret = 0;
-
-       if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS)
-               entity = vpfe_get_input_entity(pipe->outputs[0]);
-       else
-               entity = &pipe->inputs[0]->video_dev.entity;
-
-       mdev = entity->graph_obj.mdev;
-       mutex_lock(&mdev->graph_mutex);
-       media_graph_walk_start(&pipe->graph, entity);
-
-       while ((entity = media_graph_walk_next(&pipe->graph))) {
-
-               if (!is_media_entity_v4l2_subdev(entity))
-                       continue;
-               subdev = media_entity_to_v4l2_subdev(entity);
-               ret = v4l2_subdev_call(subdev, video, s_stream, 0);
-               if (ret < 0 && ret != -ENOIOCTLCMD)
-                       break;
-       }
-       mutex_unlock(&mdev->graph_mutex);
-
-       media_graph_walk_cleanup(&pipe->graph);
-       return ret ? -ETIMEDOUT : 0;
-}
-
-/*
- * vpfe_pipeline_set_stream() - Enable/disable streaming on a pipeline
- * @vpfe_dev: VPFE device
- * @pipe: VPFE pipeline
- * @state: Stream state (stopped or active)
- *
- * Set the pipeline to the given stream state.
- *
- * Return 0 if successful, or the return value of the failed video::s_stream
- * operation otherwise.
- */
-static int vpfe_pipeline_set_stream(struct vpfe_pipeline *pipe,
-                           enum vpfe_pipeline_stream_state state)
-{
-       if (state == VPFE_PIPELINE_STREAM_STOPPED)
-               return vpfe_pipeline_disable(pipe);
-
-       return vpfe_pipeline_enable(pipe);
-}
-
-static int all_videos_stopped(struct vpfe_video_device *video)
-{
-       struct vpfe_pipeline *pipe = &video->pipe;
-       int i;
-
-       for (i = 0; i < pipe->input_num; i++)
-               if (pipe->inputs[i]->started)
-                       return 0;
-       for (i = 0; i < pipe->output_num; i++)
-               if (pipe->outputs[i]->started)
-                       return 0;
-       return 1;
-}
-
-/*
- * vpfe_open() - open video device
- * @file: file pointer
- *
- * initialize media pipeline state, allocate memory for file handle
- *
- * Return 0 if successful, or the return -ENODEV otherwise.
- */
-static int vpfe_open(struct file *file)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_fh *handle;
-
-       /* Allocate memory for the file handle object */
-       handle = kzalloc(sizeof(struct vpfe_fh), GFP_KERNEL);
-
-       if (!handle)
-               return -ENOMEM;
-
-       v4l2_fh_init(&handle->vfh, &video->video_dev);
-       v4l2_fh_add(&handle->vfh);
-
-       mutex_lock(&video->lock);
-       /* If decoder is not initialized. initialize it */
-       if (!video->initialized && vpfe_update_pipe_state(video)) {
-               mutex_unlock(&video->lock);
-               v4l2_fh_del(&handle->vfh);
-               v4l2_fh_exit(&handle->vfh);
-               kfree(handle);
-               return -ENODEV;
-       }
-       /* Increment device users counter */
-       video->usrs++;
-       /* Set io_allowed member to false */
-       handle->io_allowed = 0;
-       handle->video = video;
-       file->private_data = &handle->vfh;
-       mutex_unlock(&video->lock);
-
-       return 0;
-}
-
-/* get the next buffer available from dma queue */
-static unsigned long
-vpfe_video_get_next_buffer(struct vpfe_video_device *video)
-{
-       video->cur_frm = video->next_frm =
-               list_entry(video->dma_queue.next,
-                          struct vpfe_cap_buffer, list);
-
-       list_del(&video->next_frm->list);
-       video->next_frm->vb.vb2_buf.state = VB2_BUF_STATE_ACTIVE;
-       return vb2_dma_contig_plane_dma_addr(&video->next_frm->vb.vb2_buf, 0);
-}
-
-/* schedule the next buffer which is available on dma queue */
-void vpfe_video_schedule_next_buffer(struct vpfe_video_device *video)
-{
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       unsigned long addr;
-
-       if (list_empty(&video->dma_queue))
-               return;
-
-       video->next_frm = list_entry(video->dma_queue.next,
-                                       struct vpfe_cap_buffer, list);
-
-       if (video->pipe.state == VPFE_PIPELINE_STREAM_SINGLESHOT)
-               video->cur_frm = video->next_frm;
-
-       list_del(&video->next_frm->list);
-       video->next_frm->vb.vb2_buf.state = VB2_BUF_STATE_ACTIVE;
-       addr = vb2_dma_contig_plane_dma_addr(&video->next_frm->vb.vb2_buf, 0);
-       video->ops->queue(vpfe_dev, addr);
-       video->state = VPFE_VIDEO_BUFFER_QUEUED;
-}
-
-/* schedule the buffer for capturing bottom field */
-void vpfe_video_schedule_bottom_field(struct vpfe_video_device *video)
-{
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       unsigned long addr;
-
-       addr = vb2_dma_contig_plane_dma_addr(&video->cur_frm->vb.vb2_buf, 0);
-       addr += video->field_off;
-       video->ops->queue(vpfe_dev, addr);
-}
-
-/* make buffer available for dequeue */
-void vpfe_video_process_buffer_complete(struct vpfe_video_device *video)
-{
-       struct vpfe_pipeline *pipe = &video->pipe;
-
-       video->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
-       vb2_buffer_done(&video->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE);
-       if (pipe->state == VPFE_PIPELINE_STREAM_CONTINUOUS)
-               video->cur_frm = video->next_frm;
-}
-
-/* vpfe_stop_capture() - stop streaming */
-static void vpfe_stop_capture(struct vpfe_video_device *video)
-{
-       struct vpfe_pipeline *pipe = &video->pipe;
-
-       video->started = 0;
-
-       if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
-               return;
-       if (all_videos_stopped(video))
-               vpfe_pipeline_set_stream(pipe,
-                                        VPFE_PIPELINE_STREAM_STOPPED);
-}
-
-/*
- * vpfe_release() - release video device
- * @file: file pointer
- *
- * deletes buffer queue, frees the buffers and the vpfe file handle
- *
- * Return 0
- */
-static int vpfe_release(struct file *file)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct v4l2_fh *vfh = file->private_data;
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct vpfe_fh *fh = container_of(vfh, struct vpfe_fh, vfh);
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_release\n");
-
-       /* Get the device lock */
-       mutex_lock(&video->lock);
-       /* if this instance is doing IO */
-       if (fh->io_allowed) {
-               if (video->started) {
-                       vpfe_stop_capture(video);
-                       /*
-                        * mark pipe state as stopped in vpfe_release(),
-                        * as app might call streamon() after streamoff()
-                        * in which case driver has to start streaming.
-                        */
-                       video->pipe.state = VPFE_PIPELINE_STREAM_STOPPED;
-                       vb2_streamoff(&video->buffer_queue,
-                                     video->buffer_queue.type);
-               }
-               video->io_usrs = 0;
-               /* Free buffers allocated */
-               vb2_queue_release(&video->buffer_queue);
-       }
-       /* Decrement device users counter */
-       video->usrs--;
-       v4l2_fh_del(&fh->vfh);
-       v4l2_fh_exit(&fh->vfh);
-       /* If this is the last file handle */
-       if (!video->usrs)
-               video->initialized = 0;
-       mutex_unlock(&video->lock);
-       file->private_data = NULL;
-       /* Free memory allocated to file handle object */
-       v4l2_fh_del(vfh);
-       kzfree(fh);
-       return 0;
-}
-
-/*
- * vpfe_mmap() - It is used to map kernel space buffers
- * into user spaces
- */
-static int vpfe_mmap(struct file *file, struct vm_area_struct *vma)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_mmap\n");
-       return vb2_mmap(&video->buffer_queue, vma);
-}
-
-/*
- * vpfe_poll() - It is used for select/poll system call
- */
-static __poll_t vpfe_poll(struct file *file, poll_table *wait)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_poll\n");
-       if (video->started)
-               return vb2_poll(&video->buffer_queue, file, wait);
-       return 0;
-}
-
-/* vpfe capture driver file operations */
-static const struct v4l2_file_operations vpfe_fops = {
-       .owner = THIS_MODULE,
-       .open = vpfe_open,
-       .release = vpfe_release,
-       .unlocked_ioctl = video_ioctl2,
-       .mmap = vpfe_mmap,
-       .poll = vpfe_poll
-};
-
-/*
- * vpfe_querycap() - query capabilities of video device
- * @file: file pointer
- * @priv: void pointer
- * @cap: pointer to v4l2_capability structure
- *
- * fills v4l2 capabilities structure
- *
- * Return 0
- */
-static int vpfe_querycap(struct file *file, void  *priv,
-                              struct v4l2_capability *cap)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querycap\n");
-
-       cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT |
-                           V4L2_CAP_STREAMING | V4L2_CAP_DEVICE_CAPS;
-       strscpy(cap->driver, CAPTURE_DRV_NAME, sizeof(cap->driver));
-       strscpy(cap->bus_info, "VPFE", sizeof(cap->bus_info));
-       strscpy(cap->card, vpfe_dev->cfg->card_name, sizeof(cap->card));
-
-       return 0;
-}
-
-/*
- * vpfe_g_fmt() - get the format which is active on video device
- * @file: file pointer
- * @priv: void pointer
- * @fmt: pointer to v4l2_format structure
- *
- * fills v4l2 format structure with active format
- *
- * Return 0
- */
-static int vpfe_g_fmt(struct file *file, void *priv,
-                               struct v4l2_format *fmt)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_fmt\n");
-       /* Fill in the information about format */
-       *fmt = video->fmt;
-       return 0;
-}
-
-/*
- * vpfe_enum_fmt() - enum formats supported on media chain
- * @file: file pointer
- * @priv: void pointer
- * @fmt: pointer to v4l2_fmtdesc structure
- *
- * fills v4l2_fmtdesc structure with output format set on adjacent subdev,
- * only one format is enumearted as subdevs are already configured
- *
- * Return 0 if successful, error code otherwise
- */
-static int vpfe_enum_fmt(struct file *file, void  *priv,
-                                  struct v4l2_fmtdesc *fmt)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct v4l2_subdev_format sd_fmt;
-       struct v4l2_mbus_framefmt mbus;
-       struct v4l2_subdev *subdev;
-       struct v4l2_format format;
-       struct media_pad *remote;
-       int ret;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_enum_fmt\n");
-
-       /*
-        * since already subdev pad format is set,
-        * only one pixel format is available
-        */
-       if (fmt->index > 0) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "Invalid index\n");
-               return -EINVAL;
-       }
-       /* get the remote pad */
-       remote = media_entity_remote_pad(&video->pad);
-       if (!remote) {
-               v4l2_err(&vpfe_dev->v4l2_dev,
-                        "invalid remote pad for video node\n");
-               return -EINVAL;
-       }
-       /* get the remote subdev */
-       subdev = vpfe_video_remote_subdev(video, NULL);
-       if (!subdev) {
-               v4l2_err(&vpfe_dev->v4l2_dev,
-                        "invalid remote subdev for video node\n");
-               return -EINVAL;
-       }
-       sd_fmt.pad = remote->index;
-       sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
-       /* get output format of remote subdev */
-       ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &sd_fmt);
-       if (ret) {
-               v4l2_err(&vpfe_dev->v4l2_dev,
-                        "invalid remote subdev for video node\n");
-               return ret;
-       }
-       /* convert to pix format */
-       mbus.code = sd_fmt.format.code;
-       mbus_to_pix(&mbus, &format.fmt.pix);
-       /* copy the result */
-       fmt->pixelformat = format.fmt.pix.pixelformat;
-
-       return 0;
-}
-
-/*
- * vpfe_s_fmt() - set the format on video device
- * @file: file pointer
- * @priv: void pointer
- * @fmt: pointer to v4l2_format structure
- *
- * validate and set the format on video device
- *
- * Return 0 on success, error code otherwise
- */
-static int vpfe_s_fmt(struct file *file, void *priv,
-                               struct v4l2_format *fmt)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct v4l2_format format;
-       int ret;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_fmt\n");
-       /* If streaming is started, return error */
-       if (video->started) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "Streaming is started\n");
-               return -EBUSY;
-       }
-       /* get adjacent subdev's output pad format */
-       ret = __vpfe_video_get_format(video, &format);
-       if (ret)
-               return ret;
-       *fmt = format;
-       video->fmt = *fmt;
-       return 0;
-}
-
-/*
- * vpfe_try_fmt() - try the format on video device
- * @file: file pointer
- * @priv: void pointer
- * @fmt: pointer to v4l2_format structure
- *
- * validate the format, update with correct format
- * based on output format set on adjacent subdev
- *
- * Return 0 on success, error code otherwise
- */
-static int vpfe_try_fmt(struct file *file, void *priv,
-                                 struct v4l2_format *fmt)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct v4l2_format format;
-       int ret;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_try_fmt\n");
-       /* get adjacent subdev's output pad format */
-       ret = __vpfe_video_get_format(video, &format);
-       if (ret)
-               return ret;
-
-       *fmt = format;
-       return 0;
-}
-
-/*
- * vpfe_enum_input() - enum inputs supported on media chain
- * @file: file pointer
- * @priv: void pointer
- * @fmt: pointer to v4l2_fmtdesc structure
- *
- * fills v4l2_input structure with input available on media chain,
- * only one input is enumearted as media chain is setup by this time
- *
- * Return 0 if successful, -EINVAL is media chain is invalid
- */
-static int vpfe_enum_input(struct file *file, void *priv,
-                                struct v4l2_input *inp)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_ext_subdev_info *sdinfo = video->current_ext_subdev;
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_enum_input\n");
-       /* enumerate from the subdev user has chosen through mc */
-       if (inp->index < sdinfo->num_inputs) {
-               memcpy(inp, &sdinfo->inputs[inp->index],
-                      sizeof(struct v4l2_input));
-               return 0;
-       }
-       return -EINVAL;
-}
-
-/*
- * vpfe_g_input() - get index of the input which is active
- * @file: file pointer
- * @priv: void pointer
- * @index: pointer to unsigned int
- *
- * set index with input index which is active
- */
-static int vpfe_g_input(struct file *file, void *priv, unsigned int *index)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_input\n");
-
-       *index = video->current_input;
-       return 0;
-}
-
-/*
- * vpfe_s_input() - set input which is pointed by input index
- * @file: file pointer
- * @priv: void pointer
- * @index: pointer to unsigned int
- *
- * set input on external subdev
- *
- * Return 0 on success, error code otherwise
- */
-static int vpfe_s_input(struct file *file, void *priv, unsigned int index)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct vpfe_ext_subdev_info *sdinfo;
-       struct vpfe_route *route;
-       struct v4l2_input *inps;
-       u32 output;
-       u32 input;
-       int ret;
-       int i;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_input\n");
-
-       ret = mutex_lock_interruptible(&video->lock);
-       if (ret)
-               return ret;
-       /*
-        * If streaming is started return device busy
-        * error
-        */
-       if (video->started) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "Streaming is on\n");
-               ret = -EBUSY;
-               goto unlock_out;
-       }
-
-       sdinfo = video->current_ext_subdev;
-       if (!sdinfo->registered) {
-               ret = -EINVAL;
-               goto unlock_out;
-       }
-       if (vpfe_dev->cfg->setup_input &&
-               vpfe_dev->cfg->setup_input(sdinfo->grp_id) < 0) {
-               ret = -EFAULT;
-               v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
-                         "couldn't setup input for %s\n",
-                         sdinfo->module_name);
-               goto unlock_out;
-       }
-       route = &sdinfo->routes[index];
-       if (route && sdinfo->can_route) {
-               input = route->input;
-               output = route->output;
-               ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev,
-                                                sdinfo->grp_id, video,
-                                                s_routing, input, output, 0);
-               if (ret) {
-                       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
-                               "s_input:error in setting input in decoder\n");
-                       ret = -EINVAL;
-                       goto unlock_out;
-               }
-       }
-       /* set standards set by subdev in video device */
-       for (i = 0; i < sdinfo->num_inputs; i++) {
-               inps = &sdinfo->inputs[i];
-               video->video_dev.tvnorms |= inps->std;
-       }
-       video->current_input = index;
-unlock_out:
-       mutex_unlock(&video->lock);
-       return ret;
-}
-
-/*
- * vpfe_querystd() - query std which is being input on external subdev
- * @file: file pointer
- * @priv: void pointer
- * @std_id: pointer to v4l2_std_id structure
- *
- * call external subdev through v4l2_device_call_until_err to
- * get the std that is being active.
- *
- * Return 0 on success, error code otherwise
- */
-static int vpfe_querystd(struct file *file, void *priv, v4l2_std_id *std_id)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct vpfe_ext_subdev_info *sdinfo;
-       int ret;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querystd\n");
-
-       ret = mutex_lock_interruptible(&video->lock);
-       sdinfo = video->current_ext_subdev;
-       if (ret)
-               return ret;
-       /* Call querystd function of decoder device */
-       ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
-                                        video, querystd, std_id);
-       mutex_unlock(&video->lock);
-       return ret;
-}
-
-/*
- * vpfe_s_std() - set std on external subdev
- * @file: file pointer
- * @priv: void pointer
- * @std_id: pointer to v4l2_std_id structure
- *
- * set std pointed by std_id on external subdev by calling it using
- * v4l2_device_call_until_err
- *
- * Return 0 on success, error code otherwise
- */
-static int vpfe_s_std(struct file *file, void *priv, v4l2_std_id std_id)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct vpfe_ext_subdev_info *sdinfo;
-       int ret;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_std\n");
-
-       /* Call decoder driver function to set the standard */
-       ret = mutex_lock_interruptible(&video->lock);
-       if (ret)
-               return ret;
-       sdinfo = video->current_ext_subdev;
-       /* If streaming is started, return device busy error */
-       if (video->started) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "streaming is started\n");
-               ret = -EBUSY;
-               goto unlock_out;
-       }
-       ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
-                                        video, s_std, std_id);
-       if (ret < 0) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "Failed to set standard\n");
-               video->stdid = V4L2_STD_UNKNOWN;
-               goto unlock_out;
-       }
-       video->stdid = std_id;
-unlock_out:
-       mutex_unlock(&video->lock);
-       return ret;
-}
-
-static int vpfe_g_std(struct file *file, void *priv, v4l2_std_id *tvnorm)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_std\n");
-       *tvnorm = video->stdid;
-       return 0;
-}
-
-/*
- * vpfe_enum_dv_timings() - enumerate dv_timings which are supported by
- *                     to external subdev
- * @file: file pointer
- * @priv: void pointer
- * @timings: pointer to v4l2_enum_dv_timings structure
- *
- * enum dv_timings's which are supported by external subdev through
- * v4l2_subdev_call
- *
- * Return 0 on success, error code otherwise
- */
-static int
-vpfe_enum_dv_timings(struct file *file, void *fh,
-                 struct v4l2_enum_dv_timings *timings)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct v4l2_subdev *subdev = video->current_ext_subdev->subdev;
-
-       timings->pad = 0;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_enum_dv_timings\n");
-       return v4l2_subdev_call(subdev, pad, enum_dv_timings, timings);
-}
-
-/*
- * vpfe_query_dv_timings() - query the dv_timings which is being input
- *                     to external subdev
- * @file: file pointer
- * @priv: void pointer
- * @timings: pointer to v4l2_dv_timings structure
- *
- * get dv_timings which is being input on external subdev through
- * v4l2_subdev_call
- *
- * Return 0 on success, error code otherwise
- */
-static int
-vpfe_query_dv_timings(struct file *file, void *fh,
-                  struct v4l2_dv_timings *timings)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct v4l2_subdev *subdev = video->current_ext_subdev->subdev;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_query_dv_timings\n");
-       return v4l2_subdev_call(subdev, video, query_dv_timings, timings);
-}
-
-/*
- * vpfe_s_dv_timings() - set dv_timings on external subdev
- * @file: file pointer
- * @priv: void pointer
- * @timings: pointer to v4l2_dv_timings structure
- *
- * set dv_timings pointed by timings on external subdev through
- * v4l2_device_call_until_err, this configures amplifier also
- *
- * Return 0 on success, error code otherwise
- */
-static int
-vpfe_s_dv_timings(struct file *file, void *fh,
-                 struct v4l2_dv_timings *timings)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_dv_timings\n");
-
-       video->stdid = V4L2_STD_UNKNOWN;
-       return v4l2_device_call_until_err(&vpfe_dev->v4l2_dev,
-                                         video->current_ext_subdev->grp_id,
-                                         video, s_dv_timings, timings);
-}
-
-/*
- * vpfe_g_dv_timings() - get dv_timings which is set on external subdev
- * @file: file pointer
- * @priv: void pointer
- * @timings: pointer to v4l2_dv_timings structure
- *
- * get dv_timings which is set on external subdev through
- * v4l2_subdev_call
- *
- * Return 0 on success, error code otherwise
- */
-static int
-vpfe_g_dv_timings(struct file *file, void *fh,
-             struct v4l2_dv_timings *timings)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct v4l2_subdev *subdev = video->current_ext_subdev->subdev;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_dv_timings\n");
-       return v4l2_subdev_call(subdev, video, g_dv_timings, timings);
-}
-
-/*
- *  Videobuf operations
- */
-/*
- * vpfe_buffer_queue_setup : Callback function for buffer setup.
- * @vq: vb2_queue ptr
- * @fmt: v4l2 format
- * @nbuffers: ptr to number of buffers requested by application
- * @nplanes:: contains number of distinct video planes needed to hold a frame
- * @sizes[]: contains the size (in bytes) of each plane.
- * @alloc_devs: ptr to allocation context
- *
- * This callback function is called when reqbuf() is called to adjust
- * the buffer nbuffers and buffer size
- */
-static int
-vpfe_buffer_queue_setup(struct vb2_queue *vq,
-                       unsigned int *nbuffers, unsigned int *nplanes,
-                       unsigned int sizes[], struct device *alloc_devs[])
-{
-       struct vpfe_fh *fh = vb2_get_drv_priv(vq);
-       struct vpfe_video_device *video = fh->video;
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       unsigned long size;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_buffer_queue_setup\n");
-       size = video->fmt.fmt.pix.sizeimage;
-
-       if (vq->num_buffers + *nbuffers < 3)
-               *nbuffers = 3 - vq->num_buffers;
-
-       *nplanes = 1;
-       sizes[0] = size;
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
-                "nbuffers=%d, size=%lu\n", *nbuffers, size);
-       return 0;
-}
-
-/*
- * vpfe_buffer_prepare : callback function for buffer prepare
- * @vb: ptr to vb2_buffer
- *
- * This is the callback function for buffer prepare when vb2_qbuf()
- * function is called. The buffer is prepared and user space virtual address
- * or user address is converted into  physical address
- */
-static int vpfe_buffer_prepare(struct vb2_buffer *vb)
-{
-       struct vpfe_fh *fh = vb2_get_drv_priv(vb->vb2_queue);
-       struct vpfe_video_device *video = fh->video;
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       unsigned long addr;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_buffer_prepare\n");
-
-       /* Initialize buffer */
-       vb2_set_plane_payload(vb, 0, video->fmt.fmt.pix.sizeimage);
-       if (vb2_plane_vaddr(vb, 0) &&
-           vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0))
-               return -EINVAL;
-
-       addr = vb2_dma_contig_plane_dma_addr(vb, 0);
-       /* Make sure user addresses are aligned to 32 bytes */
-       if (!ALIGN(addr, 32))
-               return -EINVAL;
-
-       return 0;
-}
-
-static void vpfe_buffer_queue(struct vb2_buffer *vb)
-{
-       struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
-       /* Get the file handle object and device object */
-       struct vpfe_fh *fh = vb2_get_drv_priv(vb->vb2_queue);
-       struct vpfe_video_device *video = fh->video;
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct vpfe_pipeline *pipe = &video->pipe;
-       struct vpfe_cap_buffer *buf = container_of(vbuf,
-                               struct vpfe_cap_buffer, vb);
-       unsigned long flags;
-       unsigned long empty;
-       unsigned long addr;
-
-       spin_lock_irqsave(&video->dma_queue_lock, flags);
-       empty = list_empty(&video->dma_queue);
-       /* add the buffer to the DMA queue */
-       list_add_tail(&buf->list, &video->dma_queue);
-       spin_unlock_irqrestore(&video->dma_queue_lock, flags);
-       /* this case happens in case of single shot */
-       if (empty && video->started && pipe->state ==
-               VPFE_PIPELINE_STREAM_SINGLESHOT &&
-               video->state == VPFE_VIDEO_BUFFER_NOT_QUEUED) {
-               spin_lock(&video->dma_queue_lock);
-               addr = vpfe_video_get_next_buffer(video);
-               video->ops->queue(vpfe_dev, addr);
-
-               video->state = VPFE_VIDEO_BUFFER_QUEUED;
-               spin_unlock(&video->dma_queue_lock);
-
-               /* enable h/w each time in single shot */
-               if (vpfe_video_is_pipe_ready(pipe))
-                       vpfe_pipeline_set_stream(pipe,
-                                       VPFE_PIPELINE_STREAM_SINGLESHOT);
-       }
-}
-
-/* vpfe_start_capture() - start streaming on all the subdevs */
-static int vpfe_start_capture(struct vpfe_video_device *video)
-{
-       struct vpfe_pipeline *pipe = &video->pipe;
-       int ret = 0;
-
-       video->started = 1;
-       if (vpfe_video_is_pipe_ready(pipe))
-               ret = vpfe_pipeline_set_stream(pipe, pipe->state);
-
-       return ret;
-}
-
-static int vpfe_start_streaming(struct vb2_queue *vq, unsigned int count)
-{
-       struct vpfe_fh *fh = vb2_get_drv_priv(vq);
-       struct vpfe_video_device *video = fh->video;
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       unsigned long addr;
-       int ret;
-
-       ret = mutex_lock_interruptible(&video->lock);
-       if (ret)
-               goto streamoff;
-
-       /* Get the next frame from the buffer queue */
-       video->cur_frm = video->next_frm =
-               list_entry(video->dma_queue.next, struct vpfe_cap_buffer, list);
-       /* Remove buffer from the buffer queue */
-       list_del(&video->cur_frm->list);
-       /* Mark state of the current frame to active */
-       video->cur_frm->vb.vb2_buf.state = VB2_BUF_STATE_ACTIVE;
-       /* Initialize field_id and started member */
-       video->field_id = 0;
-       addr = vb2_dma_contig_plane_dma_addr(&video->cur_frm->vb.vb2_buf, 0);
-       video->ops->queue(vpfe_dev, addr);
-       video->state = VPFE_VIDEO_BUFFER_QUEUED;
-
-       ret = vpfe_start_capture(video);
-       if (ret) {
-               struct vpfe_cap_buffer *buf, *tmp;
-
-               vb2_buffer_done(&video->cur_frm->vb.vb2_buf,
-                               VB2_BUF_STATE_QUEUED);
-               list_for_each_entry_safe(buf, tmp, &video->dma_queue, list) {
-                       list_del(&buf->list);
-                       vb2_buffer_done(&buf->vb.vb2_buf,
-                                       VB2_BUF_STATE_QUEUED);
-               }
-               goto unlock_out;
-       }
-
-       mutex_unlock(&video->lock);
-
-       return ret;
-unlock_out:
-       mutex_unlock(&video->lock);
-streamoff:
-       ret = vb2_streamoff(&video->buffer_queue, video->buffer_queue.type);
-       return 0;
-}
-
-static int vpfe_buffer_init(struct vb2_buffer *vb)
-{
-       struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
-       struct vpfe_cap_buffer *buf = container_of(vbuf,
-                                                  struct vpfe_cap_buffer, vb);
-
-       INIT_LIST_HEAD(&buf->list);
-       return 0;
-}
-
-/* abort streaming and wait for last buffer */
-static void vpfe_stop_streaming(struct vb2_queue *vq)
-{
-       struct vpfe_fh *fh = vb2_get_drv_priv(vq);
-       struct vpfe_video_device *video = fh->video;
-
-       /* release all active buffers */
-       if (video->cur_frm == video->next_frm) {
-               vb2_buffer_done(&video->cur_frm->vb.vb2_buf,
-                               VB2_BUF_STATE_ERROR);
-       } else {
-               if (video->cur_frm != NULL)
-                       vb2_buffer_done(&video->cur_frm->vb.vb2_buf,
-                                       VB2_BUF_STATE_ERROR);
-               if (video->next_frm != NULL)
-                       vb2_buffer_done(&video->next_frm->vb.vb2_buf,
-                                       VB2_BUF_STATE_ERROR);
-       }
-
-       while (!list_empty(&video->dma_queue)) {
-               video->next_frm = list_entry(video->dma_queue.next,
-                                               struct vpfe_cap_buffer, list);
-               list_del(&video->next_frm->list);
-               vb2_buffer_done(&video->next_frm->vb.vb2_buf,
-                               VB2_BUF_STATE_ERROR);
-       }
-}
-
-static void vpfe_buf_cleanup(struct vb2_buffer *vb)
-{
-       struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
-       struct vpfe_fh *fh = vb2_get_drv_priv(vb->vb2_queue);
-       struct vpfe_video_device *video = fh->video;
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct vpfe_cap_buffer *buf = container_of(vbuf,
-                                       struct vpfe_cap_buffer, vb);
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_buf_cleanup\n");
-       if (vb->state == VB2_BUF_STATE_ACTIVE)
-               list_del_init(&buf->list);
-}
-
-static const struct vb2_ops video_qops = {
-       .queue_setup            = vpfe_buffer_queue_setup,
-       .buf_init               = vpfe_buffer_init,
-       .buf_prepare            = vpfe_buffer_prepare,
-       .start_streaming        = vpfe_start_streaming,
-       .stop_streaming         = vpfe_stop_streaming,
-       .buf_cleanup            = vpfe_buf_cleanup,
-       .buf_queue              = vpfe_buffer_queue,
-       .wait_prepare           = vb2_ops_wait_prepare,
-       .wait_finish            = vb2_ops_wait_finish,
-};
-
-/*
- * vpfe_reqbufs() - supported REQBUF only once opening
- * the device.
- */
-static int vpfe_reqbufs(struct file *file, void *priv,
-                       struct v4l2_requestbuffers *req_buf)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct vpfe_fh *fh = file->private_data;
-       struct vb2_queue *q;
-       int ret;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_reqbufs\n");
-
-       if (req_buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
-           req_buf->type != V4L2_BUF_TYPE_VIDEO_OUTPUT){
-               v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buffer type\n");
-               return -EINVAL;
-       }
-
-       ret = mutex_lock_interruptible(&video->lock);
-       if (ret)
-               return ret;
-
-       if (video->io_usrs != 0) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "Only one IO user allowed\n");
-               ret = -EBUSY;
-               goto unlock_out;
-       }
-       video->memory = req_buf->memory;
-
-       /* Initialize videobuf2 queue as per the buffer type */
-       q = &video->buffer_queue;
-       q->type = req_buf->type;
-       q->io_modes = VB2_MMAP | VB2_USERPTR;
-       q->drv_priv = fh;
-       q->min_buffers_needed = 1;
-       q->ops = &video_qops;
-       q->mem_ops = &vb2_dma_contig_memops;
-       q->buf_struct_size = sizeof(struct vpfe_cap_buffer);
-       q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
-       q->dev = vpfe_dev->pdev;
-       q->lock = &video->lock;
-
-       ret = vb2_queue_init(q);
-       if (ret) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "vb2_queue_init() failed\n");
-               goto unlock_out;
-       }
-
-       fh->io_allowed = 1;
-       video->io_usrs = 1;
-       INIT_LIST_HEAD(&video->dma_queue);
-       ret = vb2_reqbufs(&video->buffer_queue, req_buf);
-
-unlock_out:
-       mutex_unlock(&video->lock);
-       return ret;
-}
-
-/*
- * vpfe_querybuf() - query buffers for exchange
- */
-static int vpfe_querybuf(struct file *file, void *priv,
-                        struct v4l2_buffer *buf)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querybuf\n");
-
-       if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
-           buf->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
-               return  -EINVAL;
-       }
-
-       if (video->memory != V4L2_MEMORY_MMAP) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "Invalid memory\n");
-               return -EINVAL;
-       }
-
-       /* Call vb2_querybuf to get information */
-       return vb2_querybuf(&video->buffer_queue, buf);
-}
-
-/*
- * vpfe_qbuf() - queue buffers for capture or processing
- */
-static int vpfe_qbuf(struct file *file, void *priv,
-                    struct v4l2_buffer *p)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct vpfe_fh *fh = file->private_data;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_qbuf\n");
-
-       if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
-           p->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
-               return -EINVAL;
-       }
-       /*
-        * If this file handle is not allowed to do IO,
-        * return error
-        */
-       if (!fh->io_allowed) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "fh->io_allowed\n");
-               return -EACCES;
-       }
-
-       return vb2_qbuf(&video->buffer_queue,
-                       video->video_dev.v4l2_dev->mdev, p);
-}
-
-/*
- * vpfe_dqbuf() - deque buffer which is done with processing
- */
-static int vpfe_dqbuf(struct file *file, void *priv,
-                     struct v4l2_buffer *buf)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_dqbuf\n");
-
-       if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
-           buf->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
-               return -EINVAL;
-       }
-
-       return vb2_dqbuf(&video->buffer_queue,
-                        buf, (file->f_flags & O_NONBLOCK));
-}
-
-/*
- * vpfe_streamon() - start streaming
- * @file: file pointer
- * @priv: void pointer
- * @buf_type: enum v4l2_buf_type
- *
- * queue buffer onto hardware for capture/processing and
- * start all the subdevs which are in media chain
- *
- * Return 0 on success, error code otherwise
- */
-static int vpfe_streamon(struct file *file, void *priv,
-                        enum v4l2_buf_type buf_type)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct vpfe_pipeline *pipe = &video->pipe;
-       struct vpfe_fh *fh = file->private_data;
-       int ret = -EINVAL;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_streamon\n");
-
-       if (buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
-           buf_type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
-               return ret;
-       }
-       /* If file handle is not allowed IO, return error */
-       if (!fh->io_allowed) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "fh->io_allowed\n");
-               return -EACCES;
-       }
-       /* If buffer queue is empty, return error */
-       if (list_empty(&video->buffer_queue.queued_list)) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "buffer queue is empty\n");
-               return -EIO;
-       }
-       /* Validate the pipeline */
-       if (buf_type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-               ret = vpfe_video_validate_pipeline(pipe);
-               if (ret < 0)
-                       return ret;
-       }
-       /* Call vb2_streamon to start streaming */
-       return vb2_streamon(&video->buffer_queue, buf_type);
-}
-
-/*
- * vpfe_streamoff() - stop streaming
- * @file: file pointer
- * @priv: void pointer
- * @buf_type: enum v4l2_buf_type
- *
- * stop all the subdevs which are in media chain
- *
- * Return 0 on success, error code otherwise
- */
-static int vpfe_streamoff(struct file *file, void *priv,
-                         enum v4l2_buf_type buf_type)
-{
-       struct vpfe_video_device *video = video_drvdata(file);
-       struct vpfe_device *vpfe_dev = video->vpfe_dev;
-       struct vpfe_fh *fh = file->private_data;
-       int ret = 0;
-
-       v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_streamoff\n");
-
-       if (buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
-           buf_type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
-               v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "Invalid buf type\n");
-               return -EINVAL;
-       }
-
-       /* If io is allowed for this file handle, return error */
-       if (!fh->io_allowed) {
-               v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "fh->io_allowed\n");
-               return -EACCES;
-       }
-
-       /* If streaming is not started, return error */
-       if (!video->started) {
-               v4l2_err(&vpfe_dev->v4l2_dev, "device is not started\n");
-               return -EINVAL;
-       }
-
-       ret = mutex_lock_interruptible(&video->lock);
-       if (ret)
-               return ret;
-
-       vpfe_stop_capture(video);
-       ret = vb2_streamoff(&video->buffer_queue, buf_type);
-       mutex_unlock(&video->lock);
-
-       return ret;
-}
-
-/* vpfe capture ioctl operations */
-static const struct v4l2_ioctl_ops vpfe_ioctl_ops = {
-       .vidioc_querycap         = vpfe_querycap,
-       .vidioc_g_fmt_vid_cap    = vpfe_g_fmt,
-       .vidioc_s_fmt_vid_cap    = vpfe_s_fmt,
-       .vidioc_try_fmt_vid_cap  = vpfe_try_fmt,
-       .vidioc_enum_fmt_vid_cap = vpfe_enum_fmt,
-       .vidioc_g_fmt_vid_out    = vpfe_g_fmt,
-       .vidioc_s_fmt_vid_out    = vpfe_s_fmt,
-       .vidioc_try_fmt_vid_out  = vpfe_try_fmt,
-       .vidioc_enum_fmt_vid_out = vpfe_enum_fmt,
-       .vidioc_enum_input       = vpfe_enum_input,
-       .vidioc_g_input          = vpfe_g_input,
-       .vidioc_s_input          = vpfe_s_input,
-       .vidioc_querystd         = vpfe_querystd,
-       .vidioc_s_std            = vpfe_s_std,
-       .vidioc_g_std            = vpfe_g_std,
-       .vidioc_enum_dv_timings  = vpfe_enum_dv_timings,
-       .vidioc_query_dv_timings = vpfe_query_dv_timings,
-       .vidioc_s_dv_timings     = vpfe_s_dv_timings,
-       .vidioc_g_dv_timings     = vpfe_g_dv_timings,
-       .vidioc_reqbufs          = vpfe_reqbufs,
-       .vidioc_querybuf         = vpfe_querybuf,
-       .vidioc_qbuf             = vpfe_qbuf,
-       .vidioc_dqbuf            = vpfe_dqbuf,
-       .vidioc_streamon         = vpfe_streamon,
-       .vidioc_streamoff        = vpfe_streamoff,
-};
-
-/* VPFE video init function */
-int vpfe_video_init(struct vpfe_video_device *video, const char *name)
-{
-       const char *direction;
-       int ret;
-
-       switch (video->type) {
-       case V4L2_BUF_TYPE_VIDEO_CAPTURE:
-               direction = "output";
-               video->pad.flags = MEDIA_PAD_FL_SINK;
-               video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               break;
-
-       case V4L2_BUF_TYPE_VIDEO_OUTPUT:
-               direction = "input";
-               video->pad.flags = MEDIA_PAD_FL_SOURCE;
-               video->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-               break;
-
-       default:
-               return -EINVAL;
-       }
-       /* Initialize field of video device */
-       mutex_init(&video->lock);
-       video->video_dev.release = video_device_release;
-       video->video_dev.fops = &vpfe_fops;
-       video->video_dev.ioctl_ops = &vpfe_ioctl_ops;
-       video->video_dev.minor = -1;
-       video->video_dev.tvnorms = 0;
-       video->video_dev.lock = &video->lock;
-       snprintf(video->video_dev.name, sizeof(video->video_dev.name),
-                "DAVINCI VIDEO %s %s", name, direction);
-
-       spin_lock_init(&video->irqlock);
-       spin_lock_init(&video->dma_queue_lock);
-       ret = media_entity_pads_init(&video->video_dev.entity,
-                               1, &video->pad);
-       if (ret < 0)
-               return ret;
-
-       video_set_drvdata(&video->video_dev, video);
-
-       return 0;
-}
-
-/* vpfe video device register function */
-int vpfe_video_register(struct vpfe_video_device *video,
-                       struct v4l2_device *vdev)
-{
-       int ret;
-
-       video->video_dev.v4l2_dev = vdev;
-
-       if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               video->video_dev.device_caps = V4L2_CAP_VIDEO_CAPTURE;
-       else
-               video->video_dev.device_caps = V4L2_CAP_VIDEO_OUTPUT;
-       video->video_dev.device_caps |= V4L2_CAP_STREAMING;
-       ret = video_register_device(&video->video_dev, VFL_TYPE_GRABBER, -1);
-       if (ret < 0)
-               pr_err("%s: could not register video device (%d)\n",
-                      __func__, ret);
-       return ret;
-}
-
-/* vpfe video device unregister function */
-void vpfe_video_unregister(struct vpfe_video_device *video)
-{
-       if (video_is_registered(&video->video_dev)) {
-               video_unregister_device(&video->video_dev);
-               media_entity_cleanup(&video->video_dev.entity);
-       }
-}
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.h b/drivers/staging/media/davinci_vpfe/vpfe_video.h
deleted file mode 100644 (file)
index 5d01c48..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2012 Texas Instruments Inc
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * Contributors:
- *      Manjunath Hadli <manjunath.hadli@ti.com>
- *      Prabhakar Lad <prabhakar.lad@ti.com>
- */
-
-#ifndef _DAVINCI_VPFE_VIDEO_H
-#define _DAVINCI_VPFE_VIDEO_H
-
-#include <media/videobuf2-v4l2.h>
-#include <media/videobuf2-dma-contig.h>
-
-struct vpfe_device;
-
-/*
- * struct vpfe_video_operations - VPFE video operations
- * @queue:     Resume streaming when a buffer is queued. Called on VIDIOC_QBUF
- *             if there was no buffer previously queued.
- */
-struct vpfe_video_operations {
-       int (*queue)(struct vpfe_device *vpfe_dev, unsigned long addr);
-};
-
-enum vpfe_pipeline_stream_state {
-       VPFE_PIPELINE_STREAM_STOPPED = 0,
-       VPFE_PIPELINE_STREAM_CONTINUOUS = 1,
-       VPFE_PIPELINE_STREAM_SINGLESHOT = 2,
-};
-
-enum vpfe_video_state {
-       /* indicates that buffer is not queued */
-       VPFE_VIDEO_BUFFER_NOT_QUEUED = 0,
-       /* indicates that buffer is queued */
-       VPFE_VIDEO_BUFFER_QUEUED = 1,
-};
-
-struct vpfe_pipeline {
-       /* media pipeline */
-       struct media_pipeline           *pipe;
-       struct media_graph      graph;
-       /* state of the pipeline, continuous,
-        * single-shot or stopped
-        */
-       enum vpfe_pipeline_stream_state state;
-       /* number of active input video entities */
-       unsigned int                    input_num;
-       /* number of active output video entities */
-       unsigned int                    output_num;
-       /* input video nodes in case of single-shot mode */
-       struct vpfe_video_device        *inputs[10];
-       /* capturing video nodes */
-       struct vpfe_video_device        *outputs[10];
-};
-
-#define to_vpfe_pipeline(__e) \
-       container_of((__e)->pipe, struct vpfe_pipeline, pipe)
-
-#define to_vpfe_video(vdev) \
-       container_of(vdev, struct vpfe_video_device, video_dev)
-
-struct vpfe_cap_buffer {
-       struct vb2_v4l2_buffer vb;
-       struct list_head list;
-};
-
-struct vpfe_video_device {
-       /* vpfe device */
-       struct vpfe_device                      *vpfe_dev;
-       /* video dev */
-       struct video_device                     video_dev;
-       /* media pad of video entity */
-       struct media_pad                        pad;
-       /* video operations supported by video device */
-       const struct vpfe_video_operations      *ops;
-       /* type of the video buffers used by user */
-       enum v4l2_buf_type                      type;
-       /* Indicates id of the field which is being captured */
-       u32                                     field_id;
-       /* pipeline for which video device is part of */
-       struct vpfe_pipeline                    pipe;
-       /* Indicates whether streaming started */
-       u8                                      started;
-       /* Indicates state of the stream */
-       unsigned int                            state;
-       /* current input at the sub device */
-       int                                     current_input;
-       /*
-        * This field keeps track of type of buffer exchange mechanism
-        * user has selected
-        */
-       enum v4l2_memory                        memory;
-       /* number of open instances of the channel */
-       u32                                     usrs;
-       /* flag to indicate whether decoder is initialized */
-       u8                                      initialized;
-       /* skip frame count */
-       u8                                      skip_frame_count;
-       /* skip frame count init value */
-       u8                                      skip_frame_count_init;
-       /* time per frame for skipping */
-       struct v4l2_fract                       timeperframe;
-       /* ptr to currently selected sub device */
-       struct vpfe_ext_subdev_info             *current_ext_subdev;
-       /* Pointer pointing to current vpfe_cap_buffer */
-       struct vpfe_cap_buffer                  *cur_frm;
-       /* Pointer pointing to next vpfe_cap_buffer */
-       struct vpfe_cap_buffer                  *next_frm;
-       /* Used to store pixel format */
-       struct v4l2_format                      fmt;
-       struct vb2_queue                        buffer_queue;
-       /* Queue of filled frames */
-       struct list_head                        dma_queue;
-       spinlock_t                              irqlock;
-       /* IRQ lock for DMA queue */
-       spinlock_t                              dma_queue_lock;
-       /* lock used to serialize all video4linux ioctls */
-       struct mutex                            lock;
-       /* number of users performing IO */
-       u32                                     io_usrs;
-       /* Currently selected or default standard */
-       v4l2_std_id                             stdid;
-       /*
-        * offset where second field starts from the starting of the
-        * buffer for field separated YCbCr formats
-        */
-       u32                                     field_off;
-};
-
-int vpfe_video_is_pipe_ready(struct vpfe_pipeline *pipe);
-void vpfe_video_unregister(struct vpfe_video_device *video);
-int vpfe_video_register(struct vpfe_video_device *video,
-                       struct v4l2_device *vdev);
-int vpfe_video_init(struct vpfe_video_device *video, const char *name);
-void vpfe_video_process_buffer_complete(struct vpfe_video_device *video);
-void vpfe_video_schedule_bottom_field(struct vpfe_video_device *video);
-void vpfe_video_schedule_next_buffer(struct vpfe_video_device *video);
-
-#endif         /* _DAVINCI_VPFE_VIDEO_H */
index be133bbaa68ac787dcb330385aebaad6947a7980..de77fe6554e79fd120c40d72715f3befcfd73bac 100644 (file)
@@ -20,4 +20,4 @@ config VIDEO_HANTRO_ROCKCHIP
        depends on ARCH_ROCKCHIP || COMPILE_TEST
        default y
        help
-         Enable support for RK3288 and RK3399 SoCs.
+         Enable support for RK3288, RK3328, and RK3399 SoCs.
index 1584acdbf4a3773f1e778fec8e47b067c04528b2..f5ec597d9e080afdfacd8b0f5789957b53bd9953 100644 (file)
@@ -5,10 +5,13 @@ hantro-vpu-y += \
                hantro_v4l2.o \
                hantro_h1_jpeg_enc.o \
                hantro_g1_mpeg2_dec.o \
+               hantro_g1_vp8_dec.o \
                rk3399_vpu_hw_jpeg_enc.o \
                rk3399_vpu_hw_mpeg2_dec.o \
+               rk3399_vpu_hw_vp8_dec.o \
                hantro_jpeg.o \
-               hantro_mpeg2.o
+               hantro_mpeg2.o \
+               hantro_vp8.o
 
 hantro-vpu-$(CONFIG_VIDEO_HANTRO_ROCKCHIP) += \
                rk3288_vpu_hw.o \
index 62dcca9ff19c8f645b7f1ff6a077378e954c418d..c4c86c32ea2da8855f6f99d9c3928b12fa1e3b5b 100644 (file)
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ioctl.h>
+#include <media/v4l2-mem2mem.h>
 #include <media/videobuf2-core.h>
 #include <media/videobuf2-dma-contig.h>
 
 #include "hantro_hw.h"
 
+#define VP8_MB_DIM                     16
+#define VP8_MB_WIDTH(w)                        DIV_ROUND_UP(w, VP8_MB_DIM)
+#define VP8_MB_HEIGHT(h)               DIV_ROUND_UP(h, VP8_MB_DIM)
+
 #define MPEG2_MB_DIM                   16
 #define MPEG2_MB_WIDTH(w)              DIV_ROUND_UP(w, MPEG2_MB_DIM)
 #define MPEG2_MB_HEIGHT(h)             DIV_ROUND_UP(h, MPEG2_MB_DIM)
@@ -40,6 +45,7 @@ struct hantro_codec_ops;
 #define HANTRO_ENCODERS                0x0000ffff
 
 #define HANTRO_MPEG2_DECODER   BIT(16)
+#define HANTRO_VP8_DECODER     BIT(17)
 #define HANTRO_DECODERS                0xffff0000
 
 /**
@@ -97,21 +103,21 @@ struct hantro_variant {
  * @HANTRO_MODE_NONE:  No operating mode. Used for RAW video formats.
  * @HANTRO_MODE_JPEG_ENC: JPEG encoder.
  * @HANTRO_MODE_MPEG2_DEC: MPEG-2 decoder.
+ * @HANTRO_MODE_VP8_DEC: VP8 decoder.
  */
 enum hantro_codec_mode {
        HANTRO_MODE_NONE = -1,
        HANTRO_MODE_JPEG_ENC,
        HANTRO_MODE_MPEG2_DEC,
+       HANTRO_MODE_VP8_DEC,
 };
 
 /*
  * struct hantro_ctrl - helper type to declare supported controls
- * @id:                V4L2 control ID (V4L2_CID_xxx)
  * @codec:     codec id this control belong to (HANTRO_JPEG_ENCODER, etc.)
  * @cfg:       control configuration
  */
 struct hantro_ctrl {
-       unsigned int id;
        unsigned int codec;
        struct v4l2_ctrl_config cfg;
 };
@@ -215,6 +221,7 @@ struct hantro_dev {
  * @codec_ops:         Set of operations related to codec mode.
  * @jpeg_enc:          JPEG-encoding context.
  * @mpeg2_dec:         MPEG-2-decoding context.
+ * @vp8_dec:           VP8-decoding context.
  */
 struct hantro_ctx {
        struct hantro_dev *dev;
@@ -241,6 +248,7 @@ struct hantro_ctx {
        union {
                struct hantro_jpeg_enc_hw_ctx jpeg_enc;
                struct hantro_mpeg2_dec_hw_ctx mpeg2_dec;
+               struct hantro_vp8_dec_hw_ctx vp8_dec;
        };
 };
 
@@ -265,6 +273,12 @@ struct hantro_fmt {
        struct v4l2_frmsize_stepwise frmsize;
 };
 
+struct hantro_reg {
+       u32 base;
+       u32 shift;
+       u32 mask;
+};
+
 /* Logging helpers */
 
 /**
@@ -343,9 +357,33 @@ static inline u32 vdpu_read(struct hantro_dev *vpu, u32 reg)
        return val;
 }
 
+static inline void hantro_reg_write(struct hantro_dev *vpu,
+                                   const struct hantro_reg *reg,
+                                   u32 val)
+{
+       u32 v;
+
+       v = vdpu_read(vpu, reg->base);
+       v &= ~(reg->mask << reg->shift);
+       v |= ((val & reg->mask) << reg->shift);
+       vdpu_write_relaxed(vpu, v, reg->base);
+}
+
 bool hantro_is_encoder_ctx(const struct hantro_ctx *ctx);
 
 void *hantro_get_ctrl(struct hantro_ctx *ctx, u32 id);
 dma_addr_t hantro_get_ref(struct vb2_queue *q, u64 ts);
 
+static inline struct vb2_v4l2_buffer *
+hantro_get_src_buf(struct hantro_ctx *ctx)
+{
+       return v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
+}
+
+static inline struct vb2_v4l2_buffer *
+hantro_get_dst_buf(struct hantro_ctx *ctx)
+{
+       return v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
+}
+
 #endif /* HANTRO_H_ */
index c3665f0e87a275ee2100cb5a2b97867bb33f8a12..4af6ee80229e8f4884d73708a49933d940d4546f 100644 (file)
@@ -153,6 +153,28 @@ void hantro_watchdog(struct work_struct *work)
        }
 }
 
+void hantro_prepare_run(struct hantro_ctx *ctx)
+{
+       struct vb2_v4l2_buffer *src_buf;
+
+       src_buf = hantro_get_src_buf(ctx);
+       v4l2_ctrl_request_setup(src_buf->vb2_buf.req_obj.req,
+                               &ctx->ctrl_handler);
+}
+
+void hantro_finish_run(struct hantro_ctx *ctx)
+{
+       struct vb2_v4l2_buffer *src_buf;
+
+       src_buf = hantro_get_src_buf(ctx);
+       v4l2_ctrl_request_complete(src_buf->vb2_buf.req_obj.req,
+                                  &ctx->ctrl_handler);
+
+       /* Kick the watchdog. */
+       schedule_delayed_work(&ctx->dev->watchdog_work,
+                             msecs_to_jiffies(2000));
+}
+
 static void device_run(void *priv)
 {
        struct hantro_ctx *ctx = priv;
@@ -262,27 +284,31 @@ static const struct v4l2_ctrl_ops hantro_ctrl_ops = {
        .s_ctrl = hantro_s_ctrl,
 };
 
-static struct hantro_ctrl controls[] = {
+static const struct hantro_ctrl controls[] = {
        {
-               .id = V4L2_CID_JPEG_COMPRESSION_QUALITY,
                .codec = HANTRO_JPEG_ENCODER,
                .cfg = {
+                       .id = V4L2_CID_JPEG_COMPRESSION_QUALITY,
                        .min = 5,
                        .max = 100,
                        .step = 1,
                        .def = 50,
+                       .ops = &hantro_ctrl_ops,
                },
        }, {
-               .id = V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS,
                .codec = HANTRO_MPEG2_DECODER,
                .cfg = {
-                       .elem_size = sizeof(struct v4l2_ctrl_mpeg2_slice_params),
+                       .id = V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS,
                },
        }, {
-               .id = V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION,
                .codec = HANTRO_MPEG2_DECODER,
                .cfg = {
-                       .elem_size = sizeof(struct v4l2_ctrl_mpeg2_quantization),
+                       .id = V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION,
+               },
+       }, {
+               .codec = HANTRO_VP8_DECODER,
+               .cfg = {
+                       .id = V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER,
                },
        },
 };
@@ -298,22 +324,12 @@ static int hantro_ctrls_setup(struct hantro_dev *vpu,
        for (i = 0; i < num_ctrls; i++) {
                if (!(allowed_codecs & controls[i].codec))
                        continue;
-               if (!controls[i].cfg.elem_size) {
-                       v4l2_ctrl_new_std(&ctx->ctrl_handler,
-                                         &hantro_ctrl_ops,
-                                         controls[i].id, controls[i].cfg.min,
-                                         controls[i].cfg.max,
-                                         controls[i].cfg.step,
-                                         controls[i].cfg.def);
-               } else {
-                       controls[i].cfg.id = controls[i].id;
-                       v4l2_ctrl_new_custom(&ctx->ctrl_handler,
-                                            &controls[i].cfg, NULL);
-               }
 
+               v4l2_ctrl_new_custom(&ctx->ctrl_handler,
+                                    &controls[i].cfg, NULL);
                if (ctx->ctrl_handler.error) {
                        vpu_err("Adding control (%d) failed %d\n",
-                               controls[i].id,
+                               controls[i].cfg.id,
                                ctx->ctrl_handler.error);
                        v4l2_ctrl_handler_free(&ctx->ctrl_handler);
                        return ctx->ctrl_handler.error;
@@ -419,6 +435,7 @@ static const struct v4l2_file_operations hantro_fops = {
 static const struct of_device_id of_hantro_match[] = {
 #ifdef CONFIG_VIDEO_HANTRO_ROCKCHIP
        { .compatible = "rockchip,rk3399-vpu", .data = &rk3399_vpu_variant, },
+       { .compatible = "rockchip,rk3328-vpu", .data = &rk3328_vpu_variant, },
        { .compatible = "rockchip,rk3288-vpu", .data = &rk3288_vpu_variant, },
 #endif
        { /* sentinel */ }
@@ -724,6 +741,7 @@ static int hantro_probe(struct platform_device *pdev)
                dev_err(vpu->dev, "Could not set DMA coherent mask.\n");
                return ret;
        }
+       vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
 
        for (i = 0; i < vpu->variant->num_irqs; i++) {
                const char *irq_name = vpu->variant->irqs[i].name;
index e592c1b66375d57a171cfe2d23aac44596ca9ede..80f0e94f8afa7c04eb42bf91263a554a7a067640 100644 (file)
@@ -167,12 +167,11 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx)
        const struct v4l2_mpeg2_picture *picture;
        u32 reg;
 
-       src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
-       dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
+       src_buf = hantro_get_src_buf(ctx);
+       dst_buf = hantro_get_dst_buf(ctx);
 
        /* Apply request controls if any */
-       v4l2_ctrl_request_setup(src_buf->vb2_buf.req_obj.req,
-                               &ctx->ctrl_handler);
+       hantro_prepare_run(ctx);
 
        slice_params = hantro_get_ctrl(ctx,
                                       V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS);
@@ -248,12 +247,7 @@ void hantro_g1_mpeg2_dec_run(struct hantro_ctx *ctx)
                                        &dst_buf->vb2_buf,
                                        sequence, picture, slice_params);
 
-       /* Controls no longer in-use, we can complete them */
-       v4l2_ctrl_request_complete(src_buf->vb2_buf.req_obj.req,
-                                  &ctx->ctrl_handler);
-
-       /* Kick the watchdog and start decoding */
-       schedule_delayed_work(&vpu->watchdog_work, msecs_to_jiffies(2000));
+       hantro_finish_run(ctx);
 
        reg = G1_REG_DEC_E(1);
        vdpu_write(vpu, reg, G1_SWREG(1));
diff --git a/drivers/staging/media/hantro/hantro_g1_vp8_dec.c b/drivers/staging/media/hantro/hantro_g1_vp8_dec.c
new file mode 100644 (file)
index 0000000..6d99c2b
--- /dev/null
@@ -0,0 +1,503 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Hantro VP8 codec driver
+ *
+ * Copyright (C) 2019 Rockchip Electronics Co., Ltd.
+ *     ZhiChao Yu <zhichao.yu@rock-chips.com>
+ *
+ * Copyright (C) 2019 Google, Inc.
+ *     Tomasz Figa <tfiga@chromium.org>
+ */
+
+#include <media/v4l2-mem2mem.h>
+#include <media/vp8-ctrls.h>
+
+#include "hantro_hw.h"
+#include "hantro.h"
+#include "hantro_g1_regs.h"
+
+/* DCT partition base address regs */
+static const struct hantro_reg vp8_dec_dct_base[8] = {
+       { G1_REG_ADDR_STR, 0, 0xffffffff },
+       { G1_REG_ADDR_REF(8), 0, 0xffffffff },
+       { G1_REG_ADDR_REF(9), 0, 0xffffffff },
+       { G1_REG_ADDR_REF(10), 0, 0xffffffff },
+       { G1_REG_ADDR_REF(11), 0, 0xffffffff },
+       { G1_REG_ADDR_REF(12), 0, 0xffffffff },
+       { G1_REG_ADDR_REF(14), 0, 0xffffffff },
+       { G1_REG_ADDR_REF(15), 0, 0xffffffff },
+};
+
+/* Loop filter level regs */
+static const struct hantro_reg vp8_dec_lf_level[4] = {
+       { G1_REG_REF_PIC(2), 18, 0x3f },
+       { G1_REG_REF_PIC(2), 12, 0x3f },
+       { G1_REG_REF_PIC(2), 6, 0x3f },
+       { G1_REG_REF_PIC(2), 0, 0x3f },
+};
+
+/* Macroblock loop filter level adjustment regs */
+static const struct hantro_reg vp8_dec_mb_adj[4] = {
+       { G1_REG_REF_PIC(0), 21, 0x7f },
+       { G1_REG_REF_PIC(0), 14, 0x7f },
+       { G1_REG_REF_PIC(0), 7, 0x7f },
+       { G1_REG_REF_PIC(0), 0, 0x7f },
+};
+
+/* Reference frame adjustment regs */
+static const struct hantro_reg vp8_dec_ref_adj[4] = {
+       { G1_REG_REF_PIC(1), 21, 0x7f },
+       { G1_REG_REF_PIC(1), 14, 0x7f },
+       { G1_REG_REF_PIC(1), 7, 0x7f },
+       { G1_REG_REF_PIC(1), 0, 0x7f },
+};
+
+/* Quantizer */
+static const struct hantro_reg vp8_dec_quant[4] = {
+       { G1_REG_REF_PIC(3), 11, 0x7ff },
+       { G1_REG_REF_PIC(3), 0, 0x7ff },
+       { G1_REG_BD_REF_PIC(4), 11, 0x7ff },
+       { G1_REG_BD_REF_PIC(4), 0, 0x7ff },
+};
+
+/* Quantizer delta regs */
+static const struct hantro_reg vp8_dec_quant_delta[5] = {
+       { G1_REG_REF_PIC(3), 27, 0x1f },
+       { G1_REG_REF_PIC(3), 22, 0x1f },
+       { G1_REG_BD_REF_PIC(4), 27, 0x1f },
+       { G1_REG_BD_REF_PIC(4), 22, 0x1f },
+       { G1_REG_BD_P_REF_PIC, 27, 0x1f },
+};
+
+/* DCT partition start bits regs */
+static const struct hantro_reg vp8_dec_dct_start_bits[8] = {
+       { G1_REG_DEC_CTRL2, 26, 0x3f }, { G1_REG_DEC_CTRL4, 26, 0x3f },
+       { G1_REG_DEC_CTRL4, 20, 0x3f }, { G1_REG_DEC_CTRL7, 24, 0x3f },
+       { G1_REG_DEC_CTRL7, 18, 0x3f }, { G1_REG_DEC_CTRL7, 12, 0x3f },
+       { G1_REG_DEC_CTRL7, 6, 0x3f },  { G1_REG_DEC_CTRL7, 0, 0x3f },
+};
+
+/* Precision filter tap regs */
+static const struct hantro_reg vp8_dec_pred_bc_tap[8][4] = {
+       {
+               { G1_REG_PRED_FLT, 22, 0x3ff },
+               { G1_REG_PRED_FLT, 12, 0x3ff },
+               { G1_REG_PRED_FLT, 2, 0x3ff },
+               { G1_REG_REF_PIC(4), 22, 0x3ff },
+       },
+       {
+               { G1_REG_REF_PIC(4), 12, 0x3ff },
+               { G1_REG_REF_PIC(4), 2, 0x3ff },
+               { G1_REG_REF_PIC(5), 22, 0x3ff },
+               { G1_REG_REF_PIC(5), 12, 0x3ff },
+       },
+       {
+               { G1_REG_REF_PIC(5), 2, 0x3ff },
+               { G1_REG_REF_PIC(6), 22, 0x3ff },
+               { G1_REG_REF_PIC(6), 12, 0x3ff },
+               { G1_REG_REF_PIC(6), 2, 0x3ff },
+       },
+       {
+               { G1_REG_REF_PIC(7), 22, 0x3ff },
+               { G1_REG_REF_PIC(7), 12, 0x3ff },
+               { G1_REG_REF_PIC(7), 2, 0x3ff },
+               { G1_REG_LT_REF, 22, 0x3ff },
+       },
+       {
+               { G1_REG_LT_REF, 12, 0x3ff },
+               { G1_REG_LT_REF, 2, 0x3ff },
+               { G1_REG_VALID_REF, 22, 0x3ff },
+               { G1_REG_VALID_REF, 12, 0x3ff },
+       },
+       {
+               { G1_REG_VALID_REF, 2, 0x3ff },
+               { G1_REG_BD_REF_PIC(0), 22, 0x3ff },
+               { G1_REG_BD_REF_PIC(0), 12, 0x3ff },
+               { G1_REG_BD_REF_PIC(0), 2, 0x3ff },
+       },
+       {
+               { G1_REG_BD_REF_PIC(1), 22, 0x3ff },
+               { G1_REG_BD_REF_PIC(1), 12, 0x3ff },
+               { G1_REG_BD_REF_PIC(1), 2, 0x3ff },
+               { G1_REG_BD_REF_PIC(2), 22, 0x3ff },
+       },
+       {
+               { G1_REG_BD_REF_PIC(2), 12, 0x3ff },
+               { G1_REG_BD_REF_PIC(2), 2, 0x3ff },
+               { G1_REG_BD_REF_PIC(3), 22, 0x3ff },
+               { G1_REG_BD_REF_PIC(3), 12, 0x3ff },
+       },
+};
+
+/*
+ * Set loop filters
+ */
+static void cfg_lf(struct hantro_ctx *ctx,
+                  const struct v4l2_ctrl_vp8_frame_header *hdr)
+{
+       const struct v4l2_vp8_segment_header *seg = &hdr->segment_header;
+       const struct v4l2_vp8_loopfilter_header *lf = &hdr->lf_header;
+       struct hantro_dev *vpu = ctx->dev;
+       unsigned int i;
+       u32 reg;
+
+       if (!(seg->flags & V4L2_VP8_SEGMENT_HEADER_FLAG_ENABLED)) {
+               hantro_reg_write(vpu, &vp8_dec_lf_level[0], lf->level);
+       } else if (seg->flags & V4L2_VP8_SEGMENT_HEADER_FLAG_DELTA_VALUE_MODE) {
+               for (i = 0; i < 4; i++) {
+                       u32 lf_level = clamp(lf->level + seg->lf_update[i],
+                                            0, 63);
+
+                       hantro_reg_write(vpu, &vp8_dec_lf_level[i], lf_level);
+               }
+       } else {
+               for (i = 0; i < 4; i++)
+                       hantro_reg_write(vpu, &vp8_dec_lf_level[i],
+                                        seg->lf_update[i]);
+       }
+
+       reg = G1_REG_REF_PIC_FILT_SHARPNESS(lf->sharpness_level);
+       if (lf->flags & V4L2_VP8_LF_FILTER_TYPE_SIMPLE)
+               reg |= G1_REG_REF_PIC_FILT_TYPE_E;
+       vdpu_write_relaxed(vpu, reg, G1_REG_REF_PIC(0));
+
+       if (lf->flags & V4L2_VP8_LF_HEADER_ADJ_ENABLE) {
+               for (i = 0; i < 4; i++) {
+                       hantro_reg_write(vpu, &vp8_dec_mb_adj[i],
+                                        lf->mb_mode_delta[i]);
+                       hantro_reg_write(vpu, &vp8_dec_ref_adj[i],
+                                        lf->ref_frm_delta[i]);
+               }
+       }
+}
+
+/*
+ * Set quantization parameters
+ */
+static void cfg_qp(struct hantro_ctx *ctx,
+                  const struct v4l2_ctrl_vp8_frame_header *hdr)
+{
+       const struct v4l2_vp8_quantization_header *q = &hdr->quant_header;
+       const struct v4l2_vp8_segment_header *seg = &hdr->segment_header;
+       struct hantro_dev *vpu = ctx->dev;
+       unsigned int i;
+
+       if (!(seg->flags & V4L2_VP8_SEGMENT_HEADER_FLAG_ENABLED)) {
+               hantro_reg_write(vpu, &vp8_dec_quant[0], q->y_ac_qi);
+       } else if (seg->flags & V4L2_VP8_SEGMENT_HEADER_FLAG_DELTA_VALUE_MODE) {
+               for (i = 0; i < 4; i++) {
+                       u32 quant = clamp(q->y_ac_qi + seg->quant_update[i],
+                                         0, 127);
+
+                       hantro_reg_write(vpu, &vp8_dec_quant[i], quant);
+               }
+       } else {
+               for (i = 0; i < 4; i++)
+                       hantro_reg_write(vpu, &vp8_dec_quant[i],
+                                        seg->quant_update[i]);
+       }
+
+       hantro_reg_write(vpu, &vp8_dec_quant_delta[0], q->y_dc_delta);
+       hantro_reg_write(vpu, &vp8_dec_quant_delta[1], q->y2_dc_delta);
+       hantro_reg_write(vpu, &vp8_dec_quant_delta[2], q->y2_ac_delta);
+       hantro_reg_write(vpu, &vp8_dec_quant_delta[3], q->uv_dc_delta);
+       hantro_reg_write(vpu, &vp8_dec_quant_delta[4], q->uv_ac_delta);
+}
+
+/*
+ * set control partition and DCT partition regs
+ *
+ * VP8 frame stream data layout:
+ *
+ *                          first_part_size          parttion_sizes[0]
+ *                              ^                     ^
+ * src_dma                      |                     |
+ * ^                   +--------+------+        +-----+-----+
+ * |                   | control part  |        |           |
+ * +--------+----------------+------------------+-----------+-----+-----------+
+ * | tag 3B | extra 7B | hdr | mb_data | DCT sz | DCT part0 | ... | DCT partn |
+ * +--------+-----------------------------------+-----------+-----+-----------+
+ *                           |         |        |                             |
+ *                           v         +----+---+                             v
+ *                           mb_start       |                       src_dma_end
+ *                                          v
+ *                                       DCT size part
+ *                                      (num_dct-1)*3B
+ * Note:
+ *   1. only key-frames have extra 7-bytes
+ *   2. all offsets are base on src_dma
+ *   3. number of DCT parts is 1, 2, 4 or 8
+ *   4. the addresses set to the VPU must be 64-bits aligned
+ */
+static void cfg_parts(struct hantro_ctx *ctx,
+                     const struct v4l2_ctrl_vp8_frame_header *hdr)
+{
+       struct hantro_dev *vpu = ctx->dev;
+       struct vb2_v4l2_buffer *vb2_src;
+       u32 first_part_offset = VP8_FRAME_IS_KEY_FRAME(hdr) ? 10 : 3;
+       u32 mb_size, mb_offset_bytes, mb_offset_bits, mb_start_bits;
+       u32 dct_size_part_size, dct_part_offset;
+       struct hantro_reg reg;
+       dma_addr_t src_dma;
+       u32 dct_part_total_len = 0;
+       u32 count = 0;
+       unsigned int i;
+
+       vb2_src = hantro_get_src_buf(ctx);
+       src_dma = vb2_dma_contig_plane_dma_addr(&vb2_src->vb2_buf, 0);
+
+       /*
+        * Calculate control partition mb data info
+        * @first_part_header_bits:     bits offset of mb data from first
+        *                              part start pos
+        * @mb_offset_bits:             bits offset of mb data from src_dma
+        *                              base addr
+        * @mb_offset_byte:             bytes offset of mb data from src_dma
+        *                              base addr
+        * @mb_start_bits:              bits offset of mb data from mb data
+        *                              64bits alignment addr
+        */
+       mb_offset_bits = first_part_offset * 8 +
+                        hdr->first_part_header_bits + 8;
+       mb_offset_bytes = mb_offset_bits / 8;
+       mb_start_bits = mb_offset_bits -
+                       (mb_offset_bytes & (~DEC_8190_ALIGN_MASK)) * 8;
+       mb_size = hdr->first_part_size -
+                 (mb_offset_bytes - first_part_offset) +
+                 (mb_offset_bytes & DEC_8190_ALIGN_MASK);
+
+       /* Macroblock data aligned base addr */
+       vdpu_write_relaxed(vpu, (mb_offset_bytes & (~DEC_8190_ALIGN_MASK))
+                               + src_dma, G1_REG_ADDR_REF(13));
+
+       /* Macroblock data start bits */
+       reg.base = G1_REG_DEC_CTRL2;
+       reg.mask = 0x3f;
+       reg.shift = 18;
+       hantro_reg_write(vpu, &reg, mb_start_bits);
+
+       /* Macroblock aligned data length */
+       reg.base = G1_REG_DEC_CTRL6;
+       reg.mask = 0x3fffff;
+       reg.shift = 0;
+       hantro_reg_write(vpu, &reg, mb_size + 1);
+
+       /*
+        * Calculate DCT partition info
+        * @dct_size_part_size: Containing sizes of DCT part, every DCT part
+        *                      has 3 bytes to store its size, except the last
+        *                      DCT part
+        * @dct_part_offset:    bytes offset of DCT parts from src_dma base addr
+        * @dct_part_total_len: total size of all DCT parts
+        */
+       dct_size_part_size = (hdr->num_dct_parts - 1) * 3;
+       dct_part_offset = first_part_offset + hdr->first_part_size;
+       for (i = 0; i < hdr->num_dct_parts; i++)
+               dct_part_total_len += hdr->dct_part_sizes[i];
+       dct_part_total_len += dct_size_part_size;
+       dct_part_total_len += (dct_part_offset & DEC_8190_ALIGN_MASK);
+
+       /* Number of DCT partitions */
+       reg.base = G1_REG_DEC_CTRL6;
+       reg.mask = 0xf;
+       reg.shift = 24;
+       hantro_reg_write(vpu, &reg, hdr->num_dct_parts - 1);
+
+       /* DCT partition length */
+       vdpu_write_relaxed(vpu,
+                          G1_REG_DEC_CTRL3_STREAM_LEN(dct_part_total_len),
+                          G1_REG_DEC_CTRL3);
+
+       /* DCT partitions base address */
+       for (i = 0; i < hdr->num_dct_parts; i++) {
+               u32 byte_offset = dct_part_offset + dct_size_part_size + count;
+               u32 base_addr = byte_offset + src_dma;
+
+               hantro_reg_write(vpu, &vp8_dec_dct_base[i],
+                                base_addr & (~DEC_8190_ALIGN_MASK));
+
+               hantro_reg_write(vpu, &vp8_dec_dct_start_bits[i],
+                                (byte_offset & DEC_8190_ALIGN_MASK) * 8);
+
+               count += hdr->dct_part_sizes[i];
+       }
+}
+
+/*
+ * prediction filter taps
+ * normal 6-tap filters
+ */
+static void cfg_tap(struct hantro_ctx *ctx,
+                   const struct v4l2_ctrl_vp8_frame_header *hdr)
+{
+       struct hantro_dev *vpu = ctx->dev;
+       struct hantro_reg reg;
+       u32 val = 0;
+       int i, j;
+
+       reg.base = G1_REG_BD_REF_PIC(3);
+       reg.mask = 0xf;
+
+       if ((hdr->version & 0x03) != 0)
+               return; /* Tap filter not used. */
+
+       for (i = 0; i < 8; i++) {
+               val = (hantro_vp8_dec_mc_filter[i][0] << 2) |
+                      hantro_vp8_dec_mc_filter[i][5];
+
+               for (j = 0; j < 4; j++)
+                       hantro_reg_write(vpu, &vp8_dec_pred_bc_tap[i][j],
+                                        hantro_vp8_dec_mc_filter[i][j + 1]);
+
+               switch (i) {
+               case 2:
+                       reg.shift = 8;
+                       break;
+               case 4:
+                       reg.shift = 4;
+                       break;
+               case 6:
+                       reg.shift = 0;
+                       break;
+               default:
+                       continue;
+               }
+
+               hantro_reg_write(vpu, &reg, val);
+       }
+}
+
+static void cfg_ref(struct hantro_ctx *ctx,
+                   const struct v4l2_ctrl_vp8_frame_header *hdr)
+{
+       struct vb2_queue *cap_q = &ctx->fh.m2m_ctx->cap_q_ctx.q;
+       struct hantro_dev *vpu = ctx->dev;
+       struct vb2_v4l2_buffer *vb2_dst;
+       dma_addr_t ref;
+
+       vb2_dst = hantro_get_dst_buf(ctx);
+
+       ref = hantro_get_ref(cap_q, hdr->last_frame_ts);
+       if (!ref)
+               ref = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
+       vdpu_write_relaxed(vpu, ref, G1_REG_ADDR_REF(0));
+
+       ref = hantro_get_ref(cap_q, hdr->golden_frame_ts);
+       WARN_ON(!ref && hdr->golden_frame_ts);
+       if (!ref)
+               ref = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
+       if (hdr->flags & V4L2_VP8_FRAME_HEADER_FLAG_SIGN_BIAS_GOLDEN)
+               ref |= G1_REG_ADDR_REF_TOPC_E;
+       vdpu_write_relaxed(vpu, ref, G1_REG_ADDR_REF(4));
+
+       ref = hantro_get_ref(cap_q, hdr->alt_frame_ts);
+       WARN_ON(!ref && hdr->alt_frame_ts);
+       if (!ref)
+               ref = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
+       if (hdr->flags & V4L2_VP8_FRAME_HEADER_FLAG_SIGN_BIAS_ALT)
+               ref |= G1_REG_ADDR_REF_TOPC_E;
+       vdpu_write_relaxed(vpu, ref, G1_REG_ADDR_REF(5));
+}
+
+static void cfg_buffers(struct hantro_ctx *ctx,
+                       const struct v4l2_ctrl_vp8_frame_header *hdr)
+{
+       const struct v4l2_vp8_segment_header *seg = &hdr->segment_header;
+       struct hantro_dev *vpu = ctx->dev;
+       struct vb2_v4l2_buffer *vb2_dst;
+       dma_addr_t dst_dma;
+       u32 reg;
+
+       vb2_dst = hantro_get_dst_buf(ctx);
+
+       /* Set probability table buffer address */
+       vdpu_write_relaxed(vpu, ctx->vp8_dec.prob_tbl.dma,
+                          G1_REG_ADDR_QTABLE);
+
+       /* Set segment map address */
+       reg = G1_REG_FWD_PIC1_SEGMENT_BASE(ctx->vp8_dec.segment_map.dma);
+       if (seg->flags & V4L2_VP8_SEGMENT_HEADER_FLAG_ENABLED) {
+               reg |= G1_REG_FWD_PIC1_SEGMENT_E;
+               if (seg->flags & V4L2_VP8_SEGMENT_HEADER_FLAG_UPDATE_MAP)
+                       reg |= G1_REG_FWD_PIC1_SEGMENT_UPD_E;
+       }
+       vdpu_write_relaxed(vpu, reg, G1_REG_FWD_PIC(0));
+
+       dst_dma = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
+       vdpu_write_relaxed(vpu, dst_dma, G1_REG_ADDR_DST);
+}
+
+void hantro_g1_vp8_dec_run(struct hantro_ctx *ctx)
+{
+       const struct v4l2_ctrl_vp8_frame_header *hdr;
+       struct hantro_dev *vpu = ctx->dev;
+       size_t height = ctx->dst_fmt.height;
+       size_t width = ctx->dst_fmt.width;
+       u32 mb_width, mb_height;
+       u32 reg;
+
+       hantro_prepare_run(ctx);
+
+       hdr = hantro_get_ctrl(ctx, V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER);
+       if (WARN_ON(!hdr))
+               return;
+
+       /* Reset segment_map buffer in keyframe */
+       if (VP8_FRAME_IS_KEY_FRAME(hdr) && ctx->vp8_dec.segment_map.cpu)
+               memset(ctx->vp8_dec.segment_map.cpu, 0,
+                      ctx->vp8_dec.segment_map.size);
+
+       hantro_vp8_prob_update(ctx, hdr);
+
+       reg = G1_REG_CONFIG_DEC_TIMEOUT_E |
+             G1_REG_CONFIG_DEC_STRENDIAN_E |
+             G1_REG_CONFIG_DEC_INSWAP32_E |
+             G1_REG_CONFIG_DEC_STRSWAP32_E |
+             G1_REG_CONFIG_DEC_OUTSWAP32_E |
+             G1_REG_CONFIG_DEC_CLK_GATE_E |
+             G1_REG_CONFIG_DEC_IN_ENDIAN |
+             G1_REG_CONFIG_DEC_OUT_ENDIAN |
+             G1_REG_CONFIG_DEC_MAX_BURST(16);
+       vdpu_write_relaxed(vpu, reg, G1_REG_CONFIG);
+
+       reg = G1_REG_DEC_CTRL0_DEC_MODE(10);
+       if (!VP8_FRAME_IS_KEY_FRAME(hdr))
+               reg |= G1_REG_DEC_CTRL0_PIC_INTER_E;
+       if (!(hdr->flags & V4L2_VP8_FRAME_HEADER_FLAG_MB_NO_SKIP_COEFF))
+               reg |= G1_REG_DEC_CTRL0_SKIP_MODE;
+       if (hdr->lf_header.level == 0)
+               reg |= G1_REG_DEC_CTRL0_FILTERING_DIS;
+       vdpu_write_relaxed(vpu, reg, G1_REG_DEC_CTRL0);
+
+       /* Frame dimensions */
+       mb_width = VP8_MB_WIDTH(width);
+       mb_height = VP8_MB_HEIGHT(height);
+       reg = G1_REG_DEC_CTRL1_PIC_MB_WIDTH(mb_width) |
+             G1_REG_DEC_CTRL1_PIC_MB_HEIGHT_P(mb_height) |
+             G1_REG_DEC_CTRL1_PIC_MB_W_EXT(mb_width >> 9) |
+             G1_REG_DEC_CTRL1_PIC_MB_H_EXT(mb_height >> 8);
+       vdpu_write_relaxed(vpu, reg, G1_REG_DEC_CTRL1);
+
+       /* Boolean decoder */
+       reg = G1_REG_DEC_CTRL2_BOOLEAN_RANGE(hdr->coder_state.range)
+               | G1_REG_DEC_CTRL2_BOOLEAN_VALUE(hdr->coder_state.value);
+       vdpu_write_relaxed(vpu, reg, G1_REG_DEC_CTRL2);
+
+       reg = 0;
+       if (hdr->version != 3)
+               reg |= G1_REG_DEC_CTRL4_VC1_HEIGHT_EXT;
+       if (hdr->version & 0x3)
+               reg |= G1_REG_DEC_CTRL4_BILIN_MC_E;
+       vdpu_write_relaxed(vpu, reg, G1_REG_DEC_CTRL4);
+
+       cfg_lf(ctx, hdr);
+       cfg_qp(ctx, hdr);
+       cfg_parts(ctx, hdr);
+       cfg_tap(ctx, hdr);
+       cfg_ref(ctx, hdr);
+       cfg_buffers(ctx, hdr);
+
+       hantro_finish_run(ctx);
+
+       vdpu_write(vpu, G1_REG_INTERRUPT_DEC_E, G1_REG_INTERRUPT);
+}
index 0c1e3043dc7eef29ee4dfa074f26ece8012f40a3..ecd34a7db19036a42797252bda40aba804dc6f75 100644 (file)
@@ -84,8 +84,10 @@ void hantro_h1_jpeg_enc_run(struct hantro_ctx *ctx)
        struct hantro_jpeg_ctx jpeg_ctx;
        u32 reg;
 
-       src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
-       dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
+       src_buf = hantro_get_src_buf(ctx);
+       dst_buf = hantro_get_dst_buf(ctx);
+
+       hantro_prepare_run(ctx);
 
        memset(&jpeg_ctx, 0, sizeof(jpeg_ctx));
        jpeg_ctx.buffer = vb2_plane_vaddr(&dst_buf->vb2_buf, 0);
@@ -119,7 +121,8 @@ void hantro_h1_jpeg_enc_run(struct hantro_ctx *ctx)
                | H1_REG_ENC_CTRL_ENC_MODE_JPEG
                | H1_REG_ENC_PIC_INTRA
                | H1_REG_ENC_CTRL_EN_BIT;
-       /* Kick the watchdog and start encoding */
-       schedule_delayed_work(&vpu->watchdog_work, msecs_to_jiffies(2000));
+
+       hantro_finish_run(ctx);
+
        vepu_write(vpu, reg, H1_REG_ENC_CTRL);
 }
index 3c361c2e9b88ab77ab9c6ddf252d190fd0caf5b3..2b8029674a75066086d7ce2590c174f43460dc16 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/v4l2-controls.h>
 #include <media/mpeg2-ctrls.h>
+#include <media/vp8-ctrls.h>
 #include <media/videobuf2-core.h>
 
+#define DEC_8190_ALIGN_MASK    0x07U
+
 struct hantro_dev;
 struct hantro_ctx;
 struct hantro_buf;
@@ -47,6 +50,16 @@ struct hantro_mpeg2_dec_hw_ctx {
        struct hantro_aux_buf qtable;
 };
 
+/**
+ * struct hantro_vp8d_hw_ctx
+ * @segment_map:       Segment map buffer.
+ * @prob_tbl:          Probability table buffer.
+ */
+struct hantro_vp8_dec_hw_ctx {
+       struct hantro_aux_buf segment_map;
+       struct hantro_aux_buf prob_tbl;
+};
+
 /**
  * struct hantro_codec_ops - codec mode specific operations
  *
@@ -82,10 +95,14 @@ extern const struct hantro_variant rk3399_vpu_variant;
 extern const struct hantro_variant rk3328_vpu_variant;
 extern const struct hantro_variant rk3288_vpu_variant;
 
+extern const u32 hantro_vp8_dec_mc_filter[8][6];
+
 void hantro_watchdog(struct work_struct *work);
 void hantro_run(struct hantro_ctx *ctx);
 void hantro_irq_done(struct hantro_dev *vpu, unsigned int bytesused,
                     enum vb2_buffer_state result);
+void hantro_prepare_run(struct hantro_ctx *ctx);
+void hantro_finish_run(struct hantro_ctx *ctx);
 
 void hantro_h1_jpeg_enc_run(struct hantro_ctx *ctx);
 void rk3399_vpu_jpeg_enc_run(struct hantro_ctx *ctx);
@@ -99,4 +116,11 @@ void hantro_mpeg2_dec_copy_qtable(u8 *qtable,
 int hantro_mpeg2_dec_init(struct hantro_ctx *ctx);
 void hantro_mpeg2_dec_exit(struct hantro_ctx *ctx);
 
+void hantro_g1_vp8_dec_run(struct hantro_ctx *ctx);
+void rk3399_vpu_vp8_dec_run(struct hantro_ctx *ctx);
+int hantro_vp8_dec_init(struct hantro_ctx *ctx);
+void hantro_vp8_dec_exit(struct hantro_ctx *ctx);
+void hantro_vp8_prob_update(struct hantro_ctx *ctx,
+                           const struct v4l2_ctrl_vp8_frame_header *hdr);
+
 #endif /* HANTRO_HW_H_ */
index 68f45ee668211b17546f65960cf959de779e9aa4..cd4eaa256e8bef9a287afcb51fa20a5c4b8b05b6 100644 (file)
@@ -344,6 +344,7 @@ hantro_update_requires_request(struct hantro_ctx *ctx, u32 fourcc)
                ctx->fh.m2m_ctx->out_q_ctx.q.requires_requests = false;
                break;
        case V4L2_PIX_FMT_MPEG2_SLICE:
+       case V4L2_PIX_FMT_VP8_FRAME:
                ctx->fh.m2m_ctx->out_q_ctx.q.requires_requests = true;
                break;
        default:
diff --git a/drivers/staging/media/hantro/hantro_vp8.c b/drivers/staging/media/hantro/hantro_vp8.c
new file mode 100644 (file)
index 0000000..0e02d14
--- /dev/null
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Hantro VPU codec driver
+ *
+ * Copyright (C) 2018 Rockchip Electronics Co., Ltd.
+ */
+
+#include "hantro.h"
+
+/*
+ * probs table with packed
+ */
+struct vp8_prob_tbl_packed {
+       u8 prob_mb_skip_false;
+       u8 prob_intra;
+       u8 prob_ref_last;
+       u8 prob_ref_golden;
+       u8 prob_segment[3];
+       u8 padding0;
+
+       u8 prob_luma_16x16_pred_mode[4];
+       u8 prob_chroma_pred_mode[3];
+       u8 padding1;
+
+       /* mv prob */
+       u8 prob_mv_context[2][19];
+       u8 padding2[2];
+
+       /* coeff probs */
+       u8 prob_coeffs[4][8][3][11];
+       u8 padding3[96];
+};
+
+/*
+ * filter taps taken to 7-bit precision,
+ * reference RFC6386#Page-16, filters[8][6]
+ */
+const u32 hantro_vp8_dec_mc_filter[8][6] = {
+       { 0, 0, 128, 0, 0, 0 },
+       { 0, -6, 123, 12, -1, 0 },
+       { 2, -11, 108, 36, -8, 1 },
+       { 0, -9, 93, 50, -6, 0 },
+       { 3, -16, 77, 77, -16, 3 },
+       { 0, -6, 50, 93, -9, 0 },
+       { 1, -8, 36, 108, -11, 2 },
+       { 0, -1, 12, 123, -6, 0 }
+};
+
+void hantro_vp8_prob_update(struct hantro_ctx *ctx,
+                           const struct v4l2_ctrl_vp8_frame_header *hdr)
+{
+       const struct v4l2_vp8_entropy_header *entropy = &hdr->entropy_header;
+       u32 i, j, k;
+       u8 *dst;
+
+       /* first probs */
+       dst = ctx->vp8_dec.prob_tbl.cpu;
+
+       dst[0] = hdr->prob_skip_false;
+       dst[1] = hdr->prob_intra;
+       dst[2] = hdr->prob_last;
+       dst[3] = hdr->prob_gf;
+       dst[4] = hdr->segment_header.segment_probs[0];
+       dst[5] = hdr->segment_header.segment_probs[1];
+       dst[6] = hdr->segment_header.segment_probs[2];
+       dst[7] = 0;
+
+       dst += 8;
+       dst[0] = entropy->y_mode_probs[0];
+       dst[1] = entropy->y_mode_probs[1];
+       dst[2] = entropy->y_mode_probs[2];
+       dst[3] = entropy->y_mode_probs[3];
+       dst[4] = entropy->uv_mode_probs[0];
+       dst[5] = entropy->uv_mode_probs[1];
+       dst[6] = entropy->uv_mode_probs[2];
+       dst[7] = 0; /*unused */
+
+       /* mv probs */
+       dst += 8;
+       dst[0] = entropy->mv_probs[0][0]; /* is short */
+       dst[1] = entropy->mv_probs[1][0];
+       dst[2] = entropy->mv_probs[0][1]; /* sign */
+       dst[3] = entropy->mv_probs[1][1];
+       dst[4] = entropy->mv_probs[0][8 + 9];
+       dst[5] = entropy->mv_probs[0][9 + 9];
+       dst[6] = entropy->mv_probs[1][8 + 9];
+       dst[7] = entropy->mv_probs[1][9 + 9];
+       dst += 8;
+       for (i = 0; i < 2; ++i) {
+               for (j = 0; j < 8; j += 4) {
+                       dst[0] = entropy->mv_probs[i][j + 9 + 0];
+                       dst[1] = entropy->mv_probs[i][j + 9 + 1];
+                       dst[2] = entropy->mv_probs[i][j + 9 + 2];
+                       dst[3] = entropy->mv_probs[i][j + 9 + 3];
+                       dst += 4;
+               }
+       }
+       for (i = 0; i < 2; ++i) {
+               dst[0] = entropy->mv_probs[i][0 + 2];
+               dst[1] = entropy->mv_probs[i][1 + 2];
+               dst[2] = entropy->mv_probs[i][2 + 2];
+               dst[3] = entropy->mv_probs[i][3 + 2];
+               dst[4] = entropy->mv_probs[i][4 + 2];
+               dst[5] = entropy->mv_probs[i][5 + 2];
+               dst[6] = entropy->mv_probs[i][6 + 2];
+               dst[7] = 0;     /*unused */
+               dst += 8;
+       }
+
+       /* coeff probs (header part) */
+       dst = ctx->vp8_dec.prob_tbl.cpu;
+       dst += (8 * 7);
+       for (i = 0; i < 4; ++i) {
+               for (j = 0; j < 8; ++j) {
+                       for (k = 0; k < 3; ++k) {
+                               dst[0] = entropy->coeff_probs[i][j][k][0];
+                               dst[1] = entropy->coeff_probs[i][j][k][1];
+                               dst[2] = entropy->coeff_probs[i][j][k][2];
+                               dst[3] = entropy->coeff_probs[i][j][k][3];
+                               dst += 4;
+                       }
+               }
+       }
+
+       /* coeff probs (footer part) */
+       dst = ctx->vp8_dec.prob_tbl.cpu;
+       dst += (8 * 55);
+       for (i = 0; i < 4; ++i) {
+               for (j = 0; j < 8; ++j) {
+                       for (k = 0; k < 3; ++k) {
+                               dst[0] = entropy->coeff_probs[i][j][k][4];
+                               dst[1] = entropy->coeff_probs[i][j][k][5];
+                               dst[2] = entropy->coeff_probs[i][j][k][6];
+                               dst[3] = entropy->coeff_probs[i][j][k][7];
+                               dst[4] = entropy->coeff_probs[i][j][k][8];
+                               dst[5] = entropy->coeff_probs[i][j][k][9];
+                               dst[6] = entropy->coeff_probs[i][j][k][10];
+                               dst[7] = 0;     /*unused */
+                               dst += 8;
+                       }
+               }
+       }
+}
+
+int hantro_vp8_dec_init(struct hantro_ctx *ctx)
+{
+       struct hantro_dev *vpu = ctx->dev;
+       struct hantro_aux_buf *aux_buf;
+       unsigned int mb_width, mb_height;
+       size_t segment_map_size;
+       int ret;
+
+       /* segment map table size calculation */
+       mb_width = DIV_ROUND_UP(ctx->dst_fmt.width, 16);
+       mb_height = DIV_ROUND_UP(ctx->dst_fmt.height, 16);
+       segment_map_size = round_up(DIV_ROUND_UP(mb_width * mb_height, 4), 64);
+
+       /*
+        * In context init the dma buffer for segment map must be allocated.
+        * And the data in segment map buffer must be set to all zero.
+        */
+       aux_buf = &ctx->vp8_dec.segment_map;
+       aux_buf->size = segment_map_size;
+       aux_buf->cpu = dma_alloc_coherent(vpu->dev, aux_buf->size,
+                                         &aux_buf->dma, GFP_KERNEL);
+       if (!aux_buf->cpu)
+               return -ENOMEM;
+
+       /*
+        * Allocate probability table buffer,
+        * total 1208 bytes, 4K page is far enough.
+        */
+       aux_buf = &ctx->vp8_dec.prob_tbl;
+       aux_buf->size = sizeof(struct vp8_prob_tbl_packed);
+       aux_buf->cpu = dma_alloc_coherent(vpu->dev, aux_buf->size,
+                                         &aux_buf->dma, GFP_KERNEL);
+       if (!aux_buf->cpu) {
+               ret = -ENOMEM;
+               goto err_free_seg_map;
+       }
+
+       return 0;
+
+err_free_seg_map:
+       dma_free_coherent(vpu->dev, ctx->vp8_dec.segment_map.size,
+                         ctx->vp8_dec.segment_map.cpu,
+                         ctx->vp8_dec.segment_map.dma);
+
+       return ret;
+}
+
+void hantro_vp8_dec_exit(struct hantro_ctx *ctx)
+{
+       struct hantro_vp8_dec_hw_ctx *vp8_dec = &ctx->vp8_dec;
+       struct hantro_dev *vpu = ctx->dev;
+
+       dma_free_coherent(vpu->dev, vp8_dec->segment_map.size,
+                         vp8_dec->segment_map.cpu, vp8_dec->segment_map.dma);
+       dma_free_coherent(vpu->dev, vp8_dec->prob_tbl.size,
+                         vp8_dec->prob_tbl.cpu, vp8_dec->prob_tbl.dma);
+}
index bcacc4f510932dd4c335fefe2551a59dcda27809..f1b573a006aeb276f71fec78359636806df82031 100644 (file)
@@ -74,6 +74,19 @@ static const struct hantro_fmt rk3288_vpu_dec_fmts[] = {
                        .step_height = MPEG2_MB_DIM,
                },
        },
+       {
+               .fourcc = V4L2_PIX_FMT_VP8_FRAME,
+               .codec_mode = HANTRO_MODE_VP8_DEC,
+               .max_depth = 2,
+               .frmsize = {
+                       .min_width = 48,
+                       .max_width = 3840,
+                       .step_width = VP8_MB_DIM,
+                       .min_height = 48,
+                       .max_height = 2160,
+                       .step_height = VP8_MB_DIM,
+               },
+       },
 };
 
 static irqreturn_t rk3288_vepu_irq(int irq, void *dev_id)
@@ -155,6 +168,12 @@ static const struct hantro_codec_ops rk3288_vpu_codec_ops[] = {
                .init = hantro_mpeg2_dec_init,
                .exit = hantro_mpeg2_dec_exit,
        },
+       [HANTRO_MODE_VP8_DEC] = {
+               .run = hantro_g1_vp8_dec_run,
+               .reset = rk3288_vpu_dec_reset,
+               .init = hantro_vp8_dec_init,
+               .exit = hantro_vp8_dec_exit,
+       },
 };
 
 /*
@@ -177,7 +196,8 @@ const struct hantro_variant rk3288_vpu_variant = {
        .dec_offset = 0x400,
        .dec_fmts = rk3288_vpu_dec_fmts,
        .num_dec_fmts = ARRAY_SIZE(rk3288_vpu_dec_fmts),
-       .codec = HANTRO_JPEG_ENCODER | HANTRO_MPEG2_DECODER,
+       .codec = HANTRO_JPEG_ENCODER | HANTRO_MPEG2_DECODER |
+                HANTRO_VP8_DECODER,
        .codec_ops = rk3288_vpu_codec_ops,
        .irqs = rk3288_irqs,
        .num_irqs = ARRAY_SIZE(rk3288_irqs),
index 5718f8063542e30973c0f44081de56ecdfda5cde..414b1d3fbb1f17c7bd9fa6a4fec893ed082c0b43 100644 (file)
@@ -73,6 +73,19 @@ static const struct hantro_fmt rk3399_vpu_dec_fmts[] = {
                        .step_height = MPEG2_MB_DIM,
                },
        },
+       {
+               .fourcc = V4L2_PIX_FMT_VP8_FRAME,
+               .codec_mode = HANTRO_MODE_VP8_DEC,
+               .max_depth = 2,
+               .frmsize = {
+                       .min_width = 48,
+                       .max_width = 3840,
+                       .step_width = VP8_MB_DIM,
+                       .min_height = 48,
+                       .max_height = 2160,
+                       .step_height = VP8_MB_DIM,
+               },
+       },
 };
 
 static irqreturn_t rk3399_vepu_irq(int irq, void *dev_id)
@@ -154,6 +167,12 @@ static const struct hantro_codec_ops rk3399_vpu_codec_ops[] = {
                .init = hantro_mpeg2_dec_init,
                .exit = hantro_mpeg2_dec_exit,
        },
+       [HANTRO_MODE_VP8_DEC] = {
+               .run = rk3399_vpu_vp8_dec_run,
+               .reset = rk3399_vpu_dec_reset,
+               .init = hantro_vp8_dec_init,
+               .exit = hantro_vp8_dec_exit,
+       },
 };
 
 /*
@@ -176,7 +195,8 @@ const struct hantro_variant rk3399_vpu_variant = {
        .dec_offset = 0x400,
        .dec_fmts = rk3399_vpu_dec_fmts,
        .num_dec_fmts = ARRAY_SIZE(rk3399_vpu_dec_fmts),
-       .codec = HANTRO_JPEG_ENCODER | HANTRO_MPEG2_DECODER,
+       .codec = HANTRO_JPEG_ENCODER | HANTRO_MPEG2_DECODER |
+                HANTRO_VP8_DECODER,
        .codec_ops = rk3399_vpu_codec_ops,
        .irqs = rk3399_irqs,
        .num_irqs = ARRAY_SIZE(rk3399_irqs),
@@ -184,3 +204,20 @@ const struct hantro_variant rk3399_vpu_variant = {
        .clk_names = rk3399_clk_names,
        .num_clocks = ARRAY_SIZE(rk3399_clk_names)
 };
+
+static const struct hantro_irq rk3328_irqs[] = {
+       { "vdpu", rk3399_vdpu_irq },
+};
+
+const struct hantro_variant rk3328_vpu_variant = {
+       .dec_offset = 0x400,
+       .dec_fmts = rk3399_vpu_dec_fmts,
+       .num_dec_fmts = ARRAY_SIZE(rk3399_vpu_dec_fmts),
+       .codec = HANTRO_MPEG2_DECODER,
+       .codec_ops = rk3399_vpu_codec_ops,
+       .irqs = rk3328_irqs,
+       .num_irqs = ARRAY_SIZE(rk3328_irqs),
+       .init = rk3399_vpu_hw_init,
+       .clk_names = rk3399_clk_names,
+       .num_clocks = ARRAY_SIZE(rk3399_clk_names),
+};
index ae66354d2d9366449ee81e5a8bb72b2781cdad06..06162f569b5eb3a62558be1f6ff7d66a5ee2e665 100644 (file)
@@ -113,14 +113,12 @@ void rk3399_vpu_jpeg_enc_run(struct hantro_ctx *ctx)
        struct hantro_dev *vpu = ctx->dev;
        struct vb2_v4l2_buffer *src_buf, *dst_buf;
        struct hantro_jpeg_ctx jpeg_ctx;
-       struct media_request *src_req;
        u32 reg;
 
-       src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
-       dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
+       src_buf = hantro_get_src_buf(ctx);
+       dst_buf = hantro_get_dst_buf(ctx);
 
-       src_req = src_buf->vb2_buf.req_obj.req;
-       v4l2_ctrl_request_setup(src_req, &ctx->ctrl_handler);
+       hantro_prepare_run(ctx);
 
        memset(&jpeg_ctx, 0, sizeof(jpeg_ctx));
        jpeg_ctx.buffer = vb2_plane_vaddr(&dst_buf->vb2_buf, 0);
@@ -157,9 +155,7 @@ void rk3399_vpu_jpeg_enc_run(struct hantro_ctx *ctx)
                | VEPU_REG_ENCODE_FORMAT_JPEG
                | VEPU_REG_ENCODE_ENABLE;
 
-       v4l2_ctrl_request_complete(src_req, &ctx->ctrl_handler);
-
        /* Kick the watchdog and start encoding */
-       schedule_delayed_work(&vpu->watchdog_work, msecs_to_jiffies(2000));
+       hantro_finish_run(ctx);
        vepu_write(vpu, reg, VEPU_REG_ENCODE_START);
 }
index 8685bddfbcab40ab9e4efe139cc3a9e8b78e8e0a..e7ba5c0441cc6ae3cfa9933d865db2253c4b7e17 100644 (file)
@@ -169,12 +169,10 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx)
        const struct v4l2_mpeg2_picture *picture;
        u32 reg;
 
-       src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
-       dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
+       src_buf = hantro_get_src_buf(ctx);
+       dst_buf = hantro_get_dst_buf(ctx);
 
-       /* Apply request controls if any */
-       v4l2_ctrl_request_setup(src_buf->vb2_buf.req_obj.req,
-                               &ctx->ctrl_handler);
+       hantro_prepare_run(ctx);
 
        slice_params = hantro_get_ctrl(ctx,
                                       V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS);
@@ -254,12 +252,8 @@ void rk3399_vpu_mpeg2_dec_run(struct hantro_ctx *ctx)
                                         &dst_buf->vb2_buf,
                                         sequence, picture, slice_params);
 
-       /* Controls no longer in-use, we can complete them */
-       v4l2_ctrl_request_complete(src_buf->vb2_buf.req_obj.req,
-                                  &ctx->ctrl_handler);
-
        /* Kick the watchdog and start decoding */
-       schedule_delayed_work(&vpu->watchdog_work, msecs_to_jiffies(2000));
+       hantro_finish_run(ctx);
 
        reg = vdpu_read(vpu, VDPU_SWREG(57)) | VDPU_REG_DEC_E(1);
        vdpu_write(vpu, reg, VDPU_SWREG(57));
diff --git a/drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c b/drivers/staging/media/hantro/rk3399_vpu_hw_vp8_dec.c
new file mode 100644 (file)
index 0000000..f17e326
--- /dev/null
@@ -0,0 +1,595 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Rockchip VPU codec vp8 decode driver
+ *
+ * Copyright (C) 2014 Rockchip Electronics Co., Ltd.
+ *     ZhiChao Yu <zhichao.yu@rock-chips.com>
+ *
+ * Copyright (C) 2014 Google LLC.
+ *      Tomasz Figa <tfiga@chromium.org>
+ *
+ * Copyright (C) 2015 Rockchip Electronics Co., Ltd.
+ *      Alpha Lin <alpha.lin@rock-chips.com>
+ */
+
+#include <media/v4l2-mem2mem.h>
+#include <media/vp8-ctrls.h>
+
+#include "hantro_hw.h"
+#include "hantro.h"
+#include "hantro_g1_regs.h"
+
+#define VDPU_REG_DEC_CTRL0                     0x0c8
+#define VDPU_REG_STREAM_LEN                    0x0cc
+#define VDPU_REG_DEC_FORMAT                    0x0d4
+#define     VDPU_REG_DEC_CTRL0_DEC_MODE(x)             (((x) & 0xf) << 0)
+#define VDPU_REG_DATA_ENDIAN                   0x0d8
+#define     VDPU_REG_CONFIG_DEC_STRENDIAN_E            BIT(5)
+#define     VDPU_REG_CONFIG_DEC_STRSWAP32_E            BIT(4)
+#define     VDPU_REG_CONFIG_DEC_OUTSWAP32_E            BIT(3)
+#define     VDPU_REG_CONFIG_DEC_INSWAP32_E             BIT(2)
+#define     VDPU_REG_CONFIG_DEC_OUT_ENDIAN             BIT(1)
+#define     VDPU_REG_CONFIG_DEC_IN_ENDIAN              BIT(0)
+#define VDPU_REG_AXI_CTRL                      0x0e0
+#define     VDPU_REG_CONFIG_DEC_MAX_BURST(x)           (((x) & 0x1f) << 16)
+#define VDPU_REG_EN_FLAGS                      0x0e4
+#define     VDPU_REG_DEC_CTRL0_PIC_INTER_E             BIT(14)
+#define     VDPU_REG_CONFIG_DEC_TIMEOUT_E              BIT(5)
+#define     VDPU_REG_CONFIG_DEC_CLK_GATE_E             BIT(4)
+#define VDPU_REG_PRED_FLT                      0x0ec
+#define VDPU_REG_ADDR_QTABLE                   0x0f4
+#define VDPU_REG_ADDR_DST                      0x0fc
+#define VDPU_REG_ADDR_STR                      0x100
+#define VDPU_REG_VP8_PIC_MB_SIZE               0x1e0
+#define VDPU_REG_VP8_DCT_START_BIT             0x1e4
+#define     VDPU_REG_DEC_CTRL4_VC1_HEIGHT_EXT          BIT(13)
+#define     VDPU_REG_DEC_CTRL4_BILIN_MC_E              BIT(12)
+#define VDPU_REG_VP8_CTRL0                     0x1e8
+#define VDPU_REG_VP8_DATA_VAL                  0x1f0
+#define VDPU_REG_PRED_FLT7                     0x1f4
+#define VDPU_REG_PRED_FLT8                     0x1f8
+#define VDPU_REG_PRED_FLT9                     0x1fc
+#define VDPU_REG_PRED_FLT10                    0x200
+#define VDPU_REG_FILTER_LEVEL                  0x204
+#define VDPU_REG_VP8_QUANTER0                  0x208
+#define VDPU_REG_VP8_ADDR_REF0                 0x20c
+#define VDPU_REG_FILTER_MB_ADJ                 0x210
+#define     VDPU_REG_REF_PIC_FILT_TYPE_E               BIT(31)
+#define     VDPU_REG_REF_PIC_FILT_SHARPNESS(x)         (((x) & 0x7) << 28)
+#define VDPU_REG_FILTER_REF_ADJ                        0x214
+#define VDPU_REG_VP8_ADDR_REF2_5(i)            (0x218 + ((i) * 0x4))
+#define     VDPU_REG_VP8_GREF_SIGN_BIAS                        BIT(0)
+#define     VDPU_REG_VP8_AREF_SIGN_BIAS                        BIT(0)
+#define VDPU_REG_VP8_DCT_BASE(i)               \
+               (0x230 + ((((i) < 5) ? (i) : ((i) + 1)) * 0x4))
+#define VDPU_REG_VP8_ADDR_CTRL_PART            0x244
+#define VDPU_REG_VP8_SEGMENT_VAL               0x254
+#define     VDPU_REG_FWD_PIC1_SEGMENT_BASE(x)          ((x) << 0)
+#define     VDPU_REG_FWD_PIC1_SEGMENT_UPD_E            BIT(1)
+#define     VDPU_REG_FWD_PIC1_SEGMENT_E                        BIT(0)
+#define VDPU_REG_VP8_DCT_START_BIT2            0x258
+#define VDPU_REG_VP8_QUANTER1                  0x25c
+#define VDPU_REG_VP8_QUANTER2                  0x260
+#define VDPU_REG_PRED_FLT1                     0x264
+#define VDPU_REG_PRED_FLT2                     0x268
+#define VDPU_REG_PRED_FLT3                     0x26c
+#define VDPU_REG_PRED_FLT4                     0x270
+#define VDPU_REG_PRED_FLT5                     0x274
+#define VDPU_REG_PRED_FLT6                     0x278
+
+static const struct hantro_reg vp8_dec_dct_base[8] = {
+       { VDPU_REG_ADDR_STR, 0, 0xffffffff },
+       { VDPU_REG_VP8_DCT_BASE(0), 0, 0xffffffff },
+       { VDPU_REG_VP8_DCT_BASE(1), 0, 0xffffffff },
+       { VDPU_REG_VP8_DCT_BASE(2), 0, 0xffffffff },
+       { VDPU_REG_VP8_DCT_BASE(3), 0, 0xffffffff },
+       { VDPU_REG_VP8_DCT_BASE(4), 0, 0xffffffff },
+       { VDPU_REG_VP8_DCT_BASE(5), 0, 0xffffffff },
+       { VDPU_REG_VP8_DCT_BASE(6), 0, 0xffffffff },
+};
+
+static const struct hantro_reg vp8_dec_lf_level[4] = {
+       { VDPU_REG_FILTER_LEVEL, 18, 0x3f },
+       { VDPU_REG_FILTER_LEVEL, 12, 0x3f },
+       { VDPU_REG_FILTER_LEVEL, 6, 0x3f },
+       { VDPU_REG_FILTER_LEVEL, 0, 0x3f },
+};
+
+static const struct hantro_reg vp8_dec_mb_adj[4] = {
+       { VDPU_REG_FILTER_MB_ADJ, 21, 0x7f },
+       { VDPU_REG_FILTER_MB_ADJ, 14, 0x7f },
+       { VDPU_REG_FILTER_MB_ADJ, 7, 0x7f },
+       { VDPU_REG_FILTER_MB_ADJ, 0, 0x7f },
+};
+
+static const struct hantro_reg vp8_dec_ref_adj[4] = {
+       { VDPU_REG_FILTER_REF_ADJ, 21, 0x7f },
+       { VDPU_REG_FILTER_REF_ADJ, 14, 0x7f },
+       { VDPU_REG_FILTER_REF_ADJ, 7, 0x7f },
+       { VDPU_REG_FILTER_REF_ADJ, 0, 0x7f },
+};
+
+static const struct hantro_reg vp8_dec_quant[4] = {
+       { VDPU_REG_VP8_QUANTER0, 11, 0x7ff },
+       { VDPU_REG_VP8_QUANTER0, 0, 0x7ff },
+       { VDPU_REG_VP8_QUANTER1, 11, 0x7ff },
+       { VDPU_REG_VP8_QUANTER1, 0, 0x7ff },
+};
+
+static const struct hantro_reg vp8_dec_quant_delta[5] = {
+       { VDPU_REG_VP8_QUANTER0, 27, 0x1f },
+       { VDPU_REG_VP8_QUANTER0, 22, 0x1f },
+       { VDPU_REG_VP8_QUANTER1, 27, 0x1f },
+       { VDPU_REG_VP8_QUANTER1, 22, 0x1f },
+       { VDPU_REG_VP8_QUANTER2, 27, 0x1f },
+};
+
+static const struct hantro_reg vp8_dec_dct_start_bits[8] = {
+       { VDPU_REG_VP8_CTRL0, 26, 0x3f },
+       { VDPU_REG_VP8_DCT_START_BIT, 26, 0x3f },
+       { VDPU_REG_VP8_DCT_START_BIT, 20, 0x3f },
+       { VDPU_REG_VP8_DCT_START_BIT2, 24, 0x3f },
+       { VDPU_REG_VP8_DCT_START_BIT2, 18, 0x3f },
+       { VDPU_REG_VP8_DCT_START_BIT2, 12, 0x3f },
+       { VDPU_REG_VP8_DCT_START_BIT2, 6, 0x3f },
+       { VDPU_REG_VP8_DCT_START_BIT2, 0, 0x3f },
+};
+
+static const struct hantro_reg vp8_dec_pred_bc_tap[8][6] = {
+       {
+               { 0, 0, 0},
+               { VDPU_REG_PRED_FLT, 22, 0x3ff },
+               { VDPU_REG_PRED_FLT, 12, 0x3ff },
+               { VDPU_REG_PRED_FLT, 2, 0x3ff },
+               { VDPU_REG_PRED_FLT1, 22, 0x3ff },
+               { 0, 0, 0},
+       }, {
+               { 0, 0, 0},
+               { VDPU_REG_PRED_FLT1, 12, 0x3ff },
+               { VDPU_REG_PRED_FLT1, 2, 0x3ff },
+               { VDPU_REG_PRED_FLT2, 22, 0x3ff },
+               { VDPU_REG_PRED_FLT2, 12, 0x3ff },
+               { 0, 0, 0},
+       }, {
+               { VDPU_REG_PRED_FLT10, 10, 0x3 },
+               { VDPU_REG_PRED_FLT2, 2, 0x3ff },
+               { VDPU_REG_PRED_FLT3, 22, 0x3ff },
+               { VDPU_REG_PRED_FLT3, 12, 0x3ff },
+               { VDPU_REG_PRED_FLT3, 2, 0x3ff },
+               { VDPU_REG_PRED_FLT10, 8, 0x3},
+       }, {
+               { 0, 0, 0},
+               { VDPU_REG_PRED_FLT4, 22, 0x3ff },
+               { VDPU_REG_PRED_FLT4, 12, 0x3ff },
+               { VDPU_REG_PRED_FLT4, 2, 0x3ff },
+               { VDPU_REG_PRED_FLT5, 22, 0x3ff },
+               { 0, 0, 0},
+       }, {
+               { VDPU_REG_PRED_FLT10, 6, 0x3 },
+               { VDPU_REG_PRED_FLT5, 12, 0x3ff },
+               { VDPU_REG_PRED_FLT5, 2, 0x3ff },
+               { VDPU_REG_PRED_FLT6, 22, 0x3ff },
+               { VDPU_REG_PRED_FLT6, 12, 0x3ff },
+               { VDPU_REG_PRED_FLT10, 4, 0x3 },
+       }, {
+               { 0, 0, 0},
+               { VDPU_REG_PRED_FLT6, 2, 0x3ff },
+               { VDPU_REG_PRED_FLT7, 22, 0x3ff },
+               { VDPU_REG_PRED_FLT7, 12, 0x3ff },
+               { VDPU_REG_PRED_FLT7, 2, 0x3ff },
+               { 0, 0, 0},
+       }, {
+               { VDPU_REG_PRED_FLT10, 2, 0x3 },
+               { VDPU_REG_PRED_FLT8, 22, 0x3ff },
+               { VDPU_REG_PRED_FLT8, 12, 0x3ff },
+               { VDPU_REG_PRED_FLT8, 2, 0x3ff },
+               { VDPU_REG_PRED_FLT9, 22, 0x3ff },
+               { VDPU_REG_PRED_FLT10, 0, 0x3 },
+       }, {
+               { 0, 0, 0},
+               { VDPU_REG_PRED_FLT9, 12, 0x3ff },
+               { VDPU_REG_PRED_FLT9, 2, 0x3ff },
+               { VDPU_REG_PRED_FLT10, 22, 0x3ff },
+               { VDPU_REG_PRED_FLT10, 12, 0x3ff },
+               { 0, 0, 0},
+       },
+};
+
+static const struct hantro_reg vp8_dec_mb_start_bit = {
+       .base = VDPU_REG_VP8_CTRL0,
+       .shift = 18,
+       .mask = 0x3f
+};
+
+static const struct hantro_reg vp8_dec_mb_aligned_data_len = {
+       .base = VDPU_REG_VP8_DATA_VAL,
+       .shift = 0,
+       .mask = 0x3fffff
+};
+
+static const struct hantro_reg vp8_dec_num_dct_partitions = {
+       .base = VDPU_REG_VP8_DATA_VAL,
+       .shift = 24,
+       .mask = 0xf
+};
+
+static const struct hantro_reg vp8_dec_stream_len = {
+       .base = VDPU_REG_STREAM_LEN,
+       .shift = 0,
+       .mask = 0xffffff
+};
+
+static const struct hantro_reg vp8_dec_mb_width = {
+       .base = VDPU_REG_VP8_PIC_MB_SIZE,
+       .shift = 23,
+       .mask = 0x1ff
+};
+
+static const struct hantro_reg vp8_dec_mb_height = {
+       .base = VDPU_REG_VP8_PIC_MB_SIZE,
+       .shift = 11,
+       .mask = 0xff
+};
+
+static const struct hantro_reg vp8_dec_mb_width_ext = {
+       .base = VDPU_REG_VP8_PIC_MB_SIZE,
+       .shift = 3,
+       .mask = 0x7
+};
+
+static const struct hantro_reg vp8_dec_mb_height_ext = {
+       .base = VDPU_REG_VP8_PIC_MB_SIZE,
+       .shift = 0,
+       .mask = 0x7
+};
+
+static const struct hantro_reg vp8_dec_bool_range = {
+       .base = VDPU_REG_VP8_CTRL0,
+       .shift = 0,
+       .mask = 0xff
+};
+
+static const struct hantro_reg vp8_dec_bool_value = {
+       .base = VDPU_REG_VP8_CTRL0,
+       .shift = 8,
+       .mask = 0xff
+};
+
+static const struct hantro_reg vp8_dec_filter_disable = {
+       .base = VDPU_REG_DEC_CTRL0,
+       .shift = 8,
+       .mask = 1
+};
+
+static const struct hantro_reg vp8_dec_skip_mode = {
+       .base = VDPU_REG_DEC_CTRL0,
+       .shift = 9,
+       .mask = 1
+};
+
+static const struct hantro_reg vp8_dec_start_dec = {
+       .base = VDPU_REG_EN_FLAGS,
+       .shift = 0,
+       .mask = 1
+};
+
+static void cfg_lf(struct hantro_ctx *ctx,
+                  const struct v4l2_ctrl_vp8_frame_header *hdr)
+{
+       const struct v4l2_vp8_segment_header *seg = &hdr->segment_header;
+       const struct v4l2_vp8_loopfilter_header *lf = &hdr->lf_header;
+       struct hantro_dev *vpu = ctx->dev;
+       unsigned int i;
+       u32 reg;
+
+       if (!(seg->flags & V4L2_VP8_SEGMENT_HEADER_FLAG_ENABLED)) {
+               hantro_reg_write(vpu, &vp8_dec_lf_level[0], lf->level);
+       } else if (seg->flags & V4L2_VP8_SEGMENT_HEADER_FLAG_DELTA_VALUE_MODE) {
+               for (i = 0; i < 4; i++) {
+                       u32 lf_level = clamp(lf->level + seg->lf_update[i],
+                                            0, 63);
+
+                       hantro_reg_write(vpu, &vp8_dec_lf_level[i], lf_level);
+               }
+       } else {
+               for (i = 0; i < 4; i++)
+                       hantro_reg_write(vpu, &vp8_dec_lf_level[i],
+                                        seg->lf_update[i]);
+       }
+
+       reg = VDPU_REG_REF_PIC_FILT_SHARPNESS(lf->sharpness_level);
+       if (lf->flags & V4L2_VP8_LF_FILTER_TYPE_SIMPLE)
+               reg |= VDPU_REG_REF_PIC_FILT_TYPE_E;
+       vdpu_write_relaxed(vpu, reg, VDPU_REG_FILTER_MB_ADJ);
+
+       if (lf->flags & V4L2_VP8_LF_HEADER_ADJ_ENABLE) {
+               for (i = 0; i < 4; i++) {
+                       hantro_reg_write(vpu, &vp8_dec_mb_adj[i],
+                                        lf->mb_mode_delta[i]);
+                       hantro_reg_write(vpu, &vp8_dec_ref_adj[i],
+                                        lf->ref_frm_delta[i]);
+               }
+       }
+}
+
+static void cfg_qp(struct hantro_ctx *ctx,
+                  const struct v4l2_ctrl_vp8_frame_header *hdr)
+{
+       const struct v4l2_vp8_quantization_header *q = &hdr->quant_header;
+       const struct v4l2_vp8_segment_header *seg = &hdr->segment_header;
+       struct hantro_dev *vpu = ctx->dev;
+       unsigned int i;
+
+       if (!(seg->flags & V4L2_VP8_SEGMENT_HEADER_FLAG_ENABLED)) {
+               hantro_reg_write(vpu, &vp8_dec_quant[0], q->y_ac_qi);
+       } else if (seg->flags & V4L2_VP8_SEGMENT_HEADER_FLAG_DELTA_VALUE_MODE) {
+               for (i = 0; i < 4; i++) {
+                       u32 quant = clamp(q->y_ac_qi + seg->quant_update[i],
+                                         0, 127);
+
+                       hantro_reg_write(vpu, &vp8_dec_quant[i], quant);
+               }
+       } else {
+               for (i = 0; i < 4; i++)
+                       hantro_reg_write(vpu, &vp8_dec_quant[i],
+                                        seg->quant_update[i]);
+       }
+
+       hantro_reg_write(vpu, &vp8_dec_quant_delta[0], q->y_dc_delta);
+       hantro_reg_write(vpu, &vp8_dec_quant_delta[1], q->y2_dc_delta);
+       hantro_reg_write(vpu, &vp8_dec_quant_delta[2], q->y2_ac_delta);
+       hantro_reg_write(vpu, &vp8_dec_quant_delta[3], q->uv_dc_delta);
+       hantro_reg_write(vpu, &vp8_dec_quant_delta[4], q->uv_ac_delta);
+}
+
+static void cfg_parts(struct hantro_ctx *ctx,
+                     const struct v4l2_ctrl_vp8_frame_header *hdr)
+{
+       struct hantro_dev *vpu = ctx->dev;
+       struct vb2_v4l2_buffer *vb2_src;
+       u32 first_part_offset = VP8_FRAME_IS_KEY_FRAME(hdr) ? 10 : 3;
+       u32 mb_size, mb_offset_bytes, mb_offset_bits, mb_start_bits;
+       u32 dct_size_part_size, dct_part_offset;
+       dma_addr_t src_dma;
+       u32 dct_part_total_len = 0;
+       u32 count = 0;
+       unsigned int i;
+
+       vb2_src = hantro_get_src_buf(ctx);
+       src_dma = vb2_dma_contig_plane_dma_addr(&vb2_src->vb2_buf, 0);
+
+       /*
+        * Calculate control partition mb data info
+        * @first_part_header_bits:     bits offset of mb data from first
+        *                              part start pos
+        * @mb_offset_bits:             bits offset of mb data from src_dma
+        *                              base addr
+        * @mb_offset_byte:             bytes offset of mb data from src_dma
+        *                              base addr
+        * @mb_start_bits:              bits offset of mb data from mb data
+        *                              64bits alignment addr
+        */
+       mb_offset_bits = first_part_offset * 8 +
+                        hdr->first_part_header_bits + 8;
+       mb_offset_bytes = mb_offset_bits / 8;
+       mb_start_bits = mb_offset_bits -
+                       (mb_offset_bytes & (~DEC_8190_ALIGN_MASK)) * 8;
+       mb_size = hdr->first_part_size -
+                 (mb_offset_bytes - first_part_offset) +
+                 (mb_offset_bytes & DEC_8190_ALIGN_MASK);
+
+       /* Macroblock data aligned base addr */
+       vdpu_write_relaxed(vpu, (mb_offset_bytes & (~DEC_8190_ALIGN_MASK)) +
+                          src_dma, VDPU_REG_VP8_ADDR_CTRL_PART);
+       hantro_reg_write(vpu, &vp8_dec_mb_start_bit, mb_start_bits);
+       hantro_reg_write(vpu, &vp8_dec_mb_aligned_data_len, mb_size);
+
+       /*
+        * Calculate DCT partition info
+        * @dct_size_part_size: Containing sizes of DCT part, every DCT part
+        *                      has 3 bytes to store its size, except the last
+        *                      DCT part
+        * @dct_part_offset:    bytes offset of DCT parts from src_dma base addr
+        * @dct_part_total_len: total size of all DCT parts
+        */
+       dct_size_part_size = (hdr->num_dct_parts - 1) * 3;
+       dct_part_offset = first_part_offset + hdr->first_part_size;
+       for (i = 0; i < hdr->num_dct_parts; i++)
+               dct_part_total_len += hdr->dct_part_sizes[i];
+       dct_part_total_len += dct_size_part_size;
+       dct_part_total_len += (dct_part_offset & DEC_8190_ALIGN_MASK);
+
+       /* Number of DCT partitions */
+       hantro_reg_write(vpu, &vp8_dec_num_dct_partitions,
+                        hdr->num_dct_parts - 1);
+
+       /* DCT partition length */
+       hantro_reg_write(vpu, &vp8_dec_stream_len, dct_part_total_len);
+
+       /* DCT partitions base address */
+       for (i = 0; i < hdr->num_dct_parts; i++) {
+               u32 byte_offset = dct_part_offset + dct_size_part_size + count;
+               u32 base_addr = byte_offset + src_dma;
+
+               hantro_reg_write(vpu, &vp8_dec_dct_base[i],
+                                base_addr & (~DEC_8190_ALIGN_MASK));
+
+               hantro_reg_write(vpu, &vp8_dec_dct_start_bits[i],
+                                (byte_offset & DEC_8190_ALIGN_MASK) * 8);
+
+               count += hdr->dct_part_sizes[i];
+       }
+}
+
+/*
+ * prediction filter taps
+ * normal 6-tap filters
+ */
+static void cfg_tap(struct hantro_ctx *ctx,
+                   const struct v4l2_ctrl_vp8_frame_header *hdr)
+{
+       struct hantro_dev *vpu = ctx->dev;
+       int i, j;
+
+       if ((hdr->version & 0x03) != 0)
+               return; /* Tap filter not used. */
+
+       for (i = 0; i < 8; i++) {
+               for (j = 0; j < 6; j++) {
+                       if (vp8_dec_pred_bc_tap[i][j].base != 0)
+                               hantro_reg_write(vpu,
+                                                &vp8_dec_pred_bc_tap[i][j],
+                                                hantro_vp8_dec_mc_filter[i][j]);
+               }
+       }
+}
+
+static void cfg_ref(struct hantro_ctx *ctx,
+                   const struct v4l2_ctrl_vp8_frame_header *hdr)
+{
+       struct hantro_dev *vpu = ctx->dev;
+       struct vb2_v4l2_buffer *vb2_dst;
+       struct vb2_queue *cap_q;
+       dma_addr_t ref;
+
+       cap_q = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
+       vb2_dst = hantro_get_dst_buf(ctx);
+
+       ref = hantro_get_ref(cap_q, hdr->last_frame_ts);
+       if (!ref)
+               ref = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
+       vdpu_write_relaxed(vpu, ref, VDPU_REG_VP8_ADDR_REF0);
+
+       ref = hantro_get_ref(cap_q, hdr->golden_frame_ts);
+       WARN_ON(!ref && hdr->golden_frame_ts);
+       if (!ref)
+               ref = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
+       if (hdr->flags & V4L2_VP8_FRAME_HEADER_FLAG_SIGN_BIAS_GOLDEN)
+               ref |= VDPU_REG_VP8_GREF_SIGN_BIAS;
+       vdpu_write_relaxed(vpu, ref, VDPU_REG_VP8_ADDR_REF2_5(2));
+
+       ref = hantro_get_ref(cap_q, hdr->alt_frame_ts);
+       WARN_ON(!ref && hdr->alt_frame_ts);
+       if (!ref)
+               ref = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
+       if (hdr->flags & V4L2_VP8_FRAME_HEADER_FLAG_SIGN_BIAS_ALT)
+               ref |= VDPU_REG_VP8_AREF_SIGN_BIAS;
+       vdpu_write_relaxed(vpu, ref, VDPU_REG_VP8_ADDR_REF2_5(3));
+}
+
+static void cfg_buffers(struct hantro_ctx *ctx,
+                       const struct v4l2_ctrl_vp8_frame_header *hdr)
+{
+       const struct v4l2_vp8_segment_header *seg = &hdr->segment_header;
+       struct hantro_dev *vpu = ctx->dev;
+       struct vb2_v4l2_buffer *vb2_dst;
+       dma_addr_t dst_dma;
+       u32 reg;
+
+       vb2_dst = hantro_get_dst_buf(ctx);
+
+       /* Set probability table buffer address */
+       vdpu_write_relaxed(vpu, ctx->vp8_dec.prob_tbl.dma,
+                          VDPU_REG_ADDR_QTABLE);
+
+       /* Set segment map address */
+       reg = VDPU_REG_FWD_PIC1_SEGMENT_BASE(ctx->vp8_dec.segment_map.dma);
+       if (seg->flags & V4L2_VP8_SEGMENT_HEADER_FLAG_ENABLED) {
+               reg |= VDPU_REG_FWD_PIC1_SEGMENT_E;
+               if (seg->flags & V4L2_VP8_SEGMENT_HEADER_FLAG_UPDATE_MAP)
+                       reg |= VDPU_REG_FWD_PIC1_SEGMENT_UPD_E;
+       }
+       vdpu_write_relaxed(vpu, reg, VDPU_REG_VP8_SEGMENT_VAL);
+
+       /* set output frame buffer address */
+       dst_dma = vb2_dma_contig_plane_dma_addr(&vb2_dst->vb2_buf, 0);
+       vdpu_write_relaxed(vpu, dst_dma, VDPU_REG_ADDR_DST);
+}
+
+void rk3399_vpu_vp8_dec_run(struct hantro_ctx *ctx)
+{
+       const struct v4l2_ctrl_vp8_frame_header *hdr;
+       struct hantro_dev *vpu = ctx->dev;
+       size_t height = ctx->dst_fmt.height;
+       size_t width = ctx->dst_fmt.width;
+       u32 mb_width, mb_height;
+       u32 reg;
+
+       hantro_prepare_run(ctx);
+
+       hdr = hantro_get_ctrl(ctx, V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER);
+       if (WARN_ON(!hdr))
+               return;
+
+       /* Reset segment_map buffer in keyframe */
+       if (VP8_FRAME_IS_KEY_FRAME(hdr) && ctx->vp8_dec.segment_map.cpu)
+               memset(ctx->vp8_dec.segment_map.cpu, 0,
+                      ctx->vp8_dec.segment_map.size);
+
+       hantro_vp8_prob_update(ctx, hdr);
+
+       /*
+        * Extensive testing shows that the hardware does not properly
+        * clear the internal state from previous a decoding run. This
+        * causes corruption in decoded frames for multi-instance use cases.
+        * A soft reset before programming the registers has been found
+        * to resolve those problems.
+        */
+       ctx->codec_ops->reset(ctx);
+
+       reg = VDPU_REG_CONFIG_DEC_TIMEOUT_E
+               | VDPU_REG_CONFIG_DEC_CLK_GATE_E;
+       if (!VP8_FRAME_IS_KEY_FRAME(hdr))
+               reg |= VDPU_REG_DEC_CTRL0_PIC_INTER_E;
+       vdpu_write_relaxed(vpu, reg, VDPU_REG_EN_FLAGS);
+
+       reg = VDPU_REG_CONFIG_DEC_STRENDIAN_E
+               | VDPU_REG_CONFIG_DEC_INSWAP32_E
+               | VDPU_REG_CONFIG_DEC_STRSWAP32_E
+               | VDPU_REG_CONFIG_DEC_OUTSWAP32_E
+               | VDPU_REG_CONFIG_DEC_IN_ENDIAN
+               | VDPU_REG_CONFIG_DEC_OUT_ENDIAN;
+       vdpu_write_relaxed(vpu, reg, VDPU_REG_DATA_ENDIAN);
+
+       reg = VDPU_REG_CONFIG_DEC_MAX_BURST(16);
+       vdpu_write_relaxed(vpu, reg, VDPU_REG_AXI_CTRL);
+
+       reg = VDPU_REG_DEC_CTRL0_DEC_MODE(10);
+       vdpu_write_relaxed(vpu, reg, VDPU_REG_DEC_FORMAT);
+
+       if (!(hdr->flags & V4L2_VP8_FRAME_HEADER_FLAG_MB_NO_SKIP_COEFF))
+               hantro_reg_write(vpu, &vp8_dec_skip_mode, 1);
+       if (hdr->lf_header.level == 0)
+               hantro_reg_write(vpu, &vp8_dec_filter_disable, 1);
+
+       /* Frame dimensions */
+       mb_width = VP8_MB_WIDTH(width);
+       mb_height = VP8_MB_HEIGHT(height);
+
+       hantro_reg_write(vpu, &vp8_dec_mb_width, mb_width);
+       hantro_reg_write(vpu, &vp8_dec_mb_height, mb_height);
+       hantro_reg_write(vpu, &vp8_dec_mb_width_ext, mb_width >> 9);
+       hantro_reg_write(vpu, &vp8_dec_mb_height_ext, mb_height >> 8);
+
+       /* Boolean decoder */
+       hantro_reg_write(vpu, &vp8_dec_bool_range, hdr->coder_state.range);
+       hantro_reg_write(vpu, &vp8_dec_bool_value, hdr->coder_state.value);
+
+       reg = vdpu_read(vpu, VDPU_REG_VP8_DCT_START_BIT);
+       if (hdr->version != 3)
+               reg |= VDPU_REG_DEC_CTRL4_VC1_HEIGHT_EXT;
+       if (hdr->version & 0x3)
+               reg |= VDPU_REG_DEC_CTRL4_BILIN_MC_E;
+       vdpu_write_relaxed(vpu, reg, VDPU_REG_VP8_DCT_START_BIT);
+
+       cfg_lf(ctx, hdr);
+       cfg_qp(ctx, hdr);
+       cfg_parts(ctx, hdr);
+       cfg_tap(ctx, hdr);
+       cfg_ref(ctx, hdr);
+       cfg_buffers(ctx, hdr);
+
+       hantro_finish_run(ctx);
+
+       hantro_reg_write(vpu, &vp8_dec_start_dec, 1);
+}
index 9088c4b720a310cecceca7e8389585c84870e8d8..4cc6a7462ae2a132f578f816c12c084df977ccd5 100644 (file)
@@ -841,7 +841,7 @@ find_pipeline_entity(struct media_entity *start, u32 grp_id,
                if (sd->grp_id & grp_id)
                        return &sd->entity;
        } else if (buftype && is_media_entity_v4l2_video_device(start)) {
-               vfd = media_entity_to_video_device(pad->entity);
+               vfd = media_entity_to_video_device(start);
                if (buftype == vfd->queue->type)
                        return &vfd->entity;
        }
index a7372395a1014270b35e51de3ebddffaadc600e0..06a61f31ca50b2c17fbc5b35a2b8e08c5489627b 100644 (file)
@@ -778,8 +778,7 @@ static int __maybe_unused imgu_suspend(struct device *dev)
 
 static int __maybe_unused imgu_resume(struct device *dev)
 {
-       struct pci_dev *pci_dev = to_pci_dev(dev);
-       struct imgu_device *imgu = pci_get_drvdata(pci_dev);
+       struct imgu_device *imgu = dev_get_drvdata(dev);
        int r = 0;
        unsigned int pipe;
 
index c307707480f72655f9824e0f48e0c6421fc9b992..54144dc9f5093f0cd3f025df1e50f7ea43aa253b 100644 (file)
 static struct iss_format_info formats[] = {
        { MEDIA_BUS_FMT_Y8_1X8, MEDIA_BUS_FMT_Y8_1X8,
          MEDIA_BUS_FMT_Y8_1X8, MEDIA_BUS_FMT_Y8_1X8,
-         V4L2_PIX_FMT_GREY, 8, "Greyscale 8 bpp", },
+         V4L2_PIX_FMT_GREY, 8, },
        { MEDIA_BUS_FMT_Y10_1X10, MEDIA_BUS_FMT_Y10_1X10,
          MEDIA_BUS_FMT_Y10_1X10, MEDIA_BUS_FMT_Y8_1X8,
-         V4L2_PIX_FMT_Y10, 10, "Greyscale 10 bpp", },
+         V4L2_PIX_FMT_Y10, 10, },
        { MEDIA_BUS_FMT_Y12_1X12, MEDIA_BUS_FMT_Y10_1X10,
          MEDIA_BUS_FMT_Y12_1X12, MEDIA_BUS_FMT_Y8_1X8,
-         V4L2_PIX_FMT_Y12, 12, "Greyscale 12 bpp", },
+         V4L2_PIX_FMT_Y12, 12, },
        { MEDIA_BUS_FMT_SBGGR8_1X8, MEDIA_BUS_FMT_SBGGR8_1X8,
          MEDIA_BUS_FMT_SBGGR8_1X8, MEDIA_BUS_FMT_SBGGR8_1X8,
-         V4L2_PIX_FMT_SBGGR8, 8, "BGGR Bayer 8 bpp", },
+         V4L2_PIX_FMT_SBGGR8, 8, },
        { MEDIA_BUS_FMT_SGBRG8_1X8, MEDIA_BUS_FMT_SGBRG8_1X8,
          MEDIA_BUS_FMT_SGBRG8_1X8, MEDIA_BUS_FMT_SGBRG8_1X8,
-         V4L2_PIX_FMT_SGBRG8, 8, "GBRG Bayer 8 bpp", },
+         V4L2_PIX_FMT_SGBRG8, 8, },
        { MEDIA_BUS_FMT_SGRBG8_1X8, MEDIA_BUS_FMT_SGRBG8_1X8,
          MEDIA_BUS_FMT_SGRBG8_1X8, MEDIA_BUS_FMT_SGRBG8_1X8,
-         V4L2_PIX_FMT_SGRBG8, 8, "GRBG Bayer 8 bpp", },
+         V4L2_PIX_FMT_SGRBG8, 8, },
        { MEDIA_BUS_FMT_SRGGB8_1X8, MEDIA_BUS_FMT_SRGGB8_1X8,
          MEDIA_BUS_FMT_SRGGB8_1X8, MEDIA_BUS_FMT_SRGGB8_1X8,
-         V4L2_PIX_FMT_SRGGB8, 8, "RGGB Bayer 8 bpp", },
+         V4L2_PIX_FMT_SRGGB8, 8, },
        { MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
          MEDIA_BUS_FMT_SGRBG10_1X10, 0,
-         V4L2_PIX_FMT_SGRBG10DPCM8, 8, "GRBG Bayer 10 bpp DPCM8",  },
+         V4L2_PIX_FMT_SGRBG10DPCM8, 8, },
        { MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SBGGR10_1X10,
          MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SBGGR8_1X8,
-         V4L2_PIX_FMT_SBGGR10, 10, "BGGR Bayer 10 bpp", },
+         V4L2_PIX_FMT_SBGGR10, 10, },
        { MEDIA_BUS_FMT_SGBRG10_1X10, MEDIA_BUS_FMT_SGBRG10_1X10,
          MEDIA_BUS_FMT_SGBRG10_1X10, MEDIA_BUS_FMT_SGBRG8_1X8,
-         V4L2_PIX_FMT_SGBRG10, 10, "GBRG Bayer 10 bpp", },
+         V4L2_PIX_FMT_SGBRG10, 10, },
        { MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SGRBG10_1X10,
          MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SGRBG8_1X8,
-         V4L2_PIX_FMT_SGRBG10, 10, "GRBG Bayer 10 bpp", },
+         V4L2_PIX_FMT_SGRBG10, 10, },
        { MEDIA_BUS_FMT_SRGGB10_1X10, MEDIA_BUS_FMT_SRGGB10_1X10,
          MEDIA_BUS_FMT_SRGGB10_1X10, MEDIA_BUS_FMT_SRGGB8_1X8,
-         V4L2_PIX_FMT_SRGGB10, 10, "RGGB Bayer 10 bpp", },
+         V4L2_PIX_FMT_SRGGB10, 10, },
        { MEDIA_BUS_FMT_SBGGR12_1X12, MEDIA_BUS_FMT_SBGGR10_1X10,
          MEDIA_BUS_FMT_SBGGR12_1X12, MEDIA_BUS_FMT_SBGGR8_1X8,
-         V4L2_PIX_FMT_SBGGR12, 12, "BGGR Bayer 12 bpp", },
+         V4L2_PIX_FMT_SBGGR12, 12, },
        { MEDIA_BUS_FMT_SGBRG12_1X12, MEDIA_BUS_FMT_SGBRG10_1X10,
          MEDIA_BUS_FMT_SGBRG12_1X12, MEDIA_BUS_FMT_SGBRG8_1X8,
-         V4L2_PIX_FMT_SGBRG12, 12, "GBRG Bayer 12 bpp", },
+         V4L2_PIX_FMT_SGBRG12, 12, },
        { MEDIA_BUS_FMT_SGRBG12_1X12, MEDIA_BUS_FMT_SGRBG10_1X10,
          MEDIA_BUS_FMT_SGRBG12_1X12, MEDIA_BUS_FMT_SGRBG8_1X8,
-         V4L2_PIX_FMT_SGRBG12, 12, "GRBG Bayer 12 bpp", },
+         V4L2_PIX_FMT_SGRBG12, 12, },
        { MEDIA_BUS_FMT_SRGGB12_1X12, MEDIA_BUS_FMT_SRGGB10_1X10,
          MEDIA_BUS_FMT_SRGGB12_1X12, MEDIA_BUS_FMT_SRGGB8_1X8,
-         V4L2_PIX_FMT_SRGGB12, 12, "RGGB Bayer 12 bpp", },
+         V4L2_PIX_FMT_SRGGB12, 12, },
        { MEDIA_BUS_FMT_UYVY8_1X16, MEDIA_BUS_FMT_UYVY8_1X16,
          MEDIA_BUS_FMT_UYVY8_1X16, 0,
-         V4L2_PIX_FMT_UYVY, 16, "YUV 4:2:2 (UYVY)", },
+         V4L2_PIX_FMT_UYVY, 16, },
        { MEDIA_BUS_FMT_YUYV8_1X16, MEDIA_BUS_FMT_YUYV8_1X16,
          MEDIA_BUS_FMT_YUYV8_1X16, 0,
-         V4L2_PIX_FMT_YUYV, 16, "YUV 4:2:2 (YUYV)", },
+         V4L2_PIX_FMT_YUYV, 16, },
        { MEDIA_BUS_FMT_YUYV8_1_5X8, MEDIA_BUS_FMT_YUYV8_1_5X8,
          MEDIA_BUS_FMT_YUYV8_1_5X8, 0,
-         V4L2_PIX_FMT_NV12, 8, "YUV 4:2:0 (NV12)", },
+         V4L2_PIX_FMT_NV12, 8, },
 };
 
 const struct iss_format_info *
@@ -563,8 +563,6 @@ iss_video_enum_format(struct file *file, void *fh, struct v4l2_fmtdesc *f)
 
                if (index == 0) {
                        f->pixelformat = info->pixelformat;
-                       strscpy(f->description, info->description,
-                               sizeof(f->description));
                        return 0;
                }
 
index f22489edb5624af2c96624d43ae2da525d71bda6..8b3dd92021e11ce28ca365a4840ddaa64d64d101 100644 (file)
@@ -36,7 +36,6 @@ struct v4l2_pix_format;
  *     shifted to be 8 bits per pixel. =0 if format is not shiftable.
  * @pixelformat: V4L2 pixel format FCC identifier
  * @bpp: Bits per pixel
- * @description: Human-readable format description
  */
 struct iss_format_info {
        u32 code;
@@ -45,7 +44,6 @@ struct iss_format_info {
        u32 flavor;
        u32 pixelformat;
        unsigned int bpp;
-       const char *description;
 };
 
 enum iss_pipeline_stream_state {
index a6232dcd59bc2dd41b4622c4306602544bfdd034..7b9448e3c9ba504b71e44d617b3a9d81fba005dd 100644 (file)
@@ -869,8 +869,6 @@ static int soc_camera_enum_fmt_vid_cap(struct file *file, void  *priv,
 
        format = icd->user_formats[f->index].host_fmt;
 
-       if (format->name)
-               strscpy(f->description, format->name, sizeof(f->description));
        f->pixelformat = format->fourcc;
        return 0;
 }
index 3e9931416e4543054abcdc2969b35454e867f0f6..ddd29788d685bdb67d8b7934c26620668e9a43a5 100644 (file)
 #define VE_DEC_MPEG_MBADDR                     (VE_ENGINE_DEC_MPEG + 0x10)
 
 #define VE_DEC_MPEG_MBADDR_X(w)                        (((w) << 8) & GENMASK(15, 8))
-#define VE_DEC_MPEG_MBADDR_Y(h)                        (((h) << 0) & GENMASK(0, 7))
+#define VE_DEC_MPEG_MBADDR_Y(h)                        (((h) << 0) & GENMASK(7, 0))
 
 #define VE_DEC_MPEG_CTRL                       (VE_ENGINE_DEC_MPEG + 0x14)
 
index 2e7f644ae591166937402992231338f87b411725..ba49ea50b8c0b9b242ec6e9e2eb327c5e417cf57 100644 (file)
@@ -3,7 +3,7 @@ config TEGRA_VDE
        tristate "NVIDIA Tegra Video Decoder Engine driver"
        depends on ARCH_TEGRA || COMPILE_TEST
        select DMA_SHARED_BUFFER
-       select IOMMU_IOVA if IOMMU_SUPPORT
+       select IOMMU_IOVA if (IOMMU_SUPPORT || COMPILE_TEST)
        select SRAM
        help
            Say Y here to enable support for the NVIDIA Tegra video decoder
index ea54cc27e645c26848b5a5bfbf1423dd76796333..d4d1e44b16b2c8bf7197ec7bab82b60245db4769 100644 (file)
@@ -75,34 +75,27 @@ static const struct v4l2_fract
 /* video formats */
 static struct mmal_fmt formats[] = {
        {
-               .name = "4:2:0, planar, YUV",
                .fourcc = V4L2_PIX_FMT_YUV420,
-               .flags = 0,
                .mmal = MMAL_ENCODING_I420,
                .depth = 12,
                .mmal_component = COMP_CAMERA,
                .ybbp = 1,
                .remove_padding = 1,
        }, {
-               .name = "4:2:2, packed, YUYV",
                .fourcc = V4L2_PIX_FMT_YUYV,
-               .flags = 0,
                .mmal = MMAL_ENCODING_YUYV,
                .depth = 16,
                .mmal_component = COMP_CAMERA,
                .ybbp = 2,
                .remove_padding = 0,
        }, {
-               .name = "RGB24 (LE)",
                .fourcc = V4L2_PIX_FMT_RGB24,
-               .flags = 0,
                .mmal = MMAL_ENCODING_RGB24,
                .depth = 24,
                .mmal_component = COMP_CAMERA,
                .ybbp = 3,
                .remove_padding = 0,
        }, {
-               .name = "JPEG",
                .fourcc = V4L2_PIX_FMT_JPEG,
                .flags = V4L2_FMT_FLAG_COMPRESSED,
                .mmal = MMAL_ENCODING_JPEG,
@@ -111,7 +104,6 @@ static struct mmal_fmt formats[] = {
                .ybbp = 0,
                .remove_padding = 0,
        }, {
-               .name = "H264",
                .fourcc = V4L2_PIX_FMT_H264,
                .flags = V4L2_FMT_FLAG_COMPRESSED,
                .mmal = MMAL_ENCODING_H264,
@@ -120,7 +112,6 @@ static struct mmal_fmt formats[] = {
                .ybbp = 0,
                .remove_padding = 0,
        }, {
-               .name = "MJPEG",
                .fourcc = V4L2_PIX_FMT_MJPEG,
                .flags = V4L2_FMT_FLAG_COMPRESSED,
                .mmal = MMAL_ENCODING_MJPEG,
@@ -129,72 +120,56 @@ static struct mmal_fmt formats[] = {
                .ybbp = 0,
                .remove_padding = 0,
        }, {
-               .name = "4:2:2, packed, YVYU",
                .fourcc = V4L2_PIX_FMT_YVYU,
-               .flags = 0,
                .mmal = MMAL_ENCODING_YVYU,
                .depth = 16,
                .mmal_component = COMP_CAMERA,
                .ybbp = 2,
                .remove_padding = 0,
        }, {
-               .name = "4:2:2, packed, VYUY",
                .fourcc = V4L2_PIX_FMT_VYUY,
-               .flags = 0,
                .mmal = MMAL_ENCODING_VYUY,
                .depth = 16,
                .mmal_component = COMP_CAMERA,
                .ybbp = 2,
                .remove_padding = 0,
        }, {
-               .name = "4:2:2, packed, UYVY",
                .fourcc = V4L2_PIX_FMT_UYVY,
-               .flags = 0,
                .mmal = MMAL_ENCODING_UYVY,
                .depth = 16,
                .mmal_component = COMP_CAMERA,
                .ybbp = 2,
                .remove_padding = 0,
        }, {
-               .name = "4:2:0, planar, NV12",
                .fourcc = V4L2_PIX_FMT_NV12,
-               .flags = 0,
                .mmal = MMAL_ENCODING_NV12,
                .depth = 12,
                .mmal_component = COMP_CAMERA,
                .ybbp = 1,
                .remove_padding = 1,
        }, {
-               .name = "RGB24 (BE)",
                .fourcc = V4L2_PIX_FMT_BGR24,
-               .flags = 0,
                .mmal = MMAL_ENCODING_BGR24,
                .depth = 24,
                .mmal_component = COMP_CAMERA,
                .ybbp = 3,
                .remove_padding = 0,
        }, {
-               .name = "4:2:0, planar, YVU",
                .fourcc = V4L2_PIX_FMT_YVU420,
-               .flags = 0,
                .mmal = MMAL_ENCODING_YV12,
                .depth = 12,
                .mmal_component = COMP_CAMERA,
                .ybbp = 1,
                .remove_padding = 1,
        }, {
-               .name = "4:2:0, planar, NV21",
                .fourcc = V4L2_PIX_FMT_NV21,
-               .flags = 0,
                .mmal = MMAL_ENCODING_NV21,
                .depth = 12,
                .mmal_component = COMP_CAMERA,
                .ybbp = 1,
                .remove_padding = 1,
        }, {
-               .name = "RGB32 (BE)",
                .fourcc = V4L2_PIX_FMT_BGR32,
-               .flags = 0,
                .mmal = MMAL_ENCODING_BGRA,
                .depth = 32,
                .mmal_component = COMP_CAMERA,
@@ -716,9 +691,7 @@ static int vidioc_enum_fmt_vid_overlay(struct file *file, void *priv,
 
        fmt = &formats[f->index];
 
-       strlcpy((char *)f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->fourcc;
-       f->flags = fmt->flags;
 
        return 0;
 }
@@ -919,9 +892,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
 
        fmt = &formats[f->index];
 
-       strlcpy((char *)f->description, fmt->name, sizeof(f->description));
        f->pixelformat = fmt->fourcc;
-       f->flags = fmt->flags;
 
        return 0;
 }
index 6f56c517d850e332c64b32bbce513173c5e55168..ff5398737b4a2f02ee6cc58b14523e02129362a3 100644 (file)
@@ -26,7 +26,6 @@ struct mmal_msg_context;
 
 /* mapping between v4l and mmal video modes */
 struct mmal_fmt {
-       char  *name;
        u32   fourcc;          /* v4l2 format id */
        int   flags;           /* v4l2 flags field */
        u32   mmal;
index 2c5b3eacf5270206968af9238557f300ae7d7c9d..4ad53031e2f71a74bfbff32759ddb5962b73beb6 100644 (file)
@@ -32,7 +32,7 @@
 #define CAPTURE_DRV_NAME               "vpfe-capture"
 
 struct vpfe_pixel_format {
-       struct v4l2_fmtdesc fmtdesc;
+       u32 pixelformat;
        /* bytes per pixel */
        int bpp;
 };
index 59703439bb37471d6b648cd5dcc70ea1cb70029a..6b9ef631d6bbf80ee467e8628e33262c99672503 100644 (file)
@@ -87,7 +87,6 @@ struct fimc_source_info {
 /**
  * struct fimc_fmt - color format data structure
  * @mbus_code: media bus pixel code, -1 if not applicable
- * @name: format description
  * @fourcc: fourcc code for this format, 0 if not applicable
  * @color: the driver's private color format id
  * @memplanes: number of physically non-contiguous data planes
@@ -99,7 +98,6 @@ struct fimc_source_info {
  */
 struct fimc_fmt {
        u32 mbus_code;
-       char    *name;
        u32     fourcc;
        u32     color;
        u16     memplanes;
index b34d86bb0664c96cd7877efbd5b910587e707dd9..635805fb35e876e754bb02cc17770c8784453d48 100644 (file)
@@ -32,7 +32,6 @@ struct        saa7146_video_dma {
 #define FORMAT_IS_PLANAR       0x2
 
 struct saa7146_format {
-       char    *name;
        u32     pixelformat;
        u32     trans;
        u8      depth;
index 73de3bd0c605f413d443fc10a0c46a2a09934617..361f8852c9fcb3c9690640111bb256aabdea21b6 100644 (file)
@@ -66,7 +66,6 @@ enum soc_mbus_layout {
 
 /**
  * struct soc_mbus_pixelfmt - Data format on the media bus
- * @name:              Name of the format
  * @fourcc:            Fourcc code, that will be obtained if the data is
  *                     stored in memory in the following way:
  * @packing:           Type of sample-packing, that has to be used
@@ -74,7 +73,6 @@ enum soc_mbus_layout {
  * @bits_per_sample:   How many bits the bridge has to sample
  */
 struct soc_mbus_pixelfmt {
-       const char              *name;
        u32                     fourcc;
        enum soc_mbus_packing   packing;
        enum soc_mbus_order     order;
index 52875e3eee7196ff66fd1fb76195934c55f23969..7ce4e83324219b0b655b883f5ec99c42e385618b 100644 (file)
 #define USB_PID_MYGICA_D689                            0xd811
 #define USB_PID_MYGICA_T230                            0xc688
 #define USB_PID_MYGICA_T230C                           0xc689
+#define USB_PID_MYGICA_T230C2                          0xc68a
 #define USB_PID_ELGATO_EYETV_DIVERSITY                 0x0011
 #define USB_PID_ELGATO_EYETV_DTT                       0x0021
 #define USB_PID_ELGATO_EYETV_DTT_2                     0x003f
index bebd3c4c63382cc6173184b5105fa30abe578b3c..3a7f8728f6ec159f3d0e74d45abc5e94732f44e6 100644 (file)
 #define RC_PROTO_BIT_RCMM32            BIT_ULL(RC_PROTO_RCMM32)
 #define RC_PROTO_BIT_XBOX_DVD          BIT_ULL(RC_PROTO_XBOX_DVD)
 
-#define RC_PROTO_BIT_ALL \
-                       (RC_PROTO_BIT_UNKNOWN | RC_PROTO_BIT_OTHER | \
-                        RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC5X_20 | \
-                        RC_PROTO_BIT_RC5_SZ | RC_PROTO_BIT_JVC | \
-                        RC_PROTO_BIT_SONY12 | RC_PROTO_BIT_SONY15 | \
-                        RC_PROTO_BIT_SONY20 | RC_PROTO_BIT_NEC | \
-                        RC_PROTO_BIT_NECX | RC_PROTO_BIT_NEC32 | \
-                        RC_PROTO_BIT_SANYO | \
-                        RC_PROTO_BIT_MCIR2_KBD | RC_PROTO_BIT_MCIR2_MSE | \
-                        RC_PROTO_BIT_RC6_0 | RC_PROTO_BIT_RC6_6A_20 | \
-                        RC_PROTO_BIT_RC6_6A_24 | RC_PROTO_BIT_RC6_6A_32 | \
-                        RC_PROTO_BIT_RC6_MCE | RC_PROTO_BIT_SHARP | \
-                        RC_PROTO_BIT_XMP | RC_PROTO_BIT_CEC | \
-                        RC_PROTO_BIT_IMON | RC_PROTO_BIT_RCMM12 | \
-                        RC_PROTO_BIT_RCMM24 | RC_PROTO_BIT_RCMM32 | \
-                        RC_PROTO_BIT_XBOX_DVD)
 /* All rc protocols for which we have decoders */
 #define RC_PROTO_BIT_ALL_IR_DECODER \
                        (RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC5X_20 | \
index 2e3d93f742a3b64e35767f5a2fc08caa794b5489..8319284c93cb41d047f4bb0b99266457463e52f8 100644 (file)
@@ -172,14 +172,40 @@ int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier,
  *                  the driver's async sub-device struct, i.e. both
  *                  begin at the same memory address.
  *
- * Allocate a fwnode-matched asd of size asd_struct_size, and add it
- * to the notifiers @asd_list.
+ * Allocate a fwnode-matched asd of size asd_struct_size, and add it to the
+ * notifiers @asd_list. The function also gets a reference of the fwnode which
+ * is released later at notifier cleanup time.
  */
 struct v4l2_async_subdev *
 v4l2_async_notifier_add_fwnode_subdev(struct v4l2_async_notifier *notifier,
                                      struct fwnode_handle *fwnode,
                                      unsigned int asd_struct_size);
 
+/**
+ * v4l2_async_notifier_add_fwnode_remote_subdev - Allocate and add a fwnode
+ *                                               remote async subdev to the
+ *                                               notifier's master asd_list.
+ *
+ * @notif: pointer to &struct v4l2_async_notifier
+ * @endpoint: local endpoint pointing to the remote sub-device to be matched
+ * @asd: Async sub-device struct allocated by the caller. The &struct
+ *      v4l2_async_subdev shall be the first member of the driver's async
+ *      sub-device struct, i.e. both begin at the same memory address.
+ *
+ * Gets the remote endpoint of a given local endpoint, set it up for fwnode
+ * matching and adds the async sub-device to the notifier's @asd_list. The
+ * function also gets a reference of the fwnode which is released later at
+ * notifier cleanup time.
+ *
+ * This is just like @v4l2_async_notifier_add_fwnode_subdev, but with the
+ * exception that the fwnode refers to a local endpoint, not the remote one, and
+ * the function relies on the caller to allocate the async sub-device struct.
+ */
+int
+v4l2_async_notifier_add_fwnode_remote_subdev(struct v4l2_async_notifier *notif,
+                                            struct fwnode_handle *endpoint,
+                                            struct v4l2_async_subdev *asd);
+
 /**
  * v4l2_async_notifier_add_i2c_subdev - Allocate and add an i2c async
  *                             subdev to the notifier's master asd_list.
index b4433483af239293b8f1f5122ca540f47d1d11ef..570ff4b0205a9f25b882b3bc096f3c5dd145f216 100644 (file)
@@ -20,6 +20,7 @@
 #include <media/mpeg2-ctrls.h>
 #include <media/fwht-ctrls.h>
 #include <media/h264-ctrls.h>
+#include <media/vp8-ctrls.h>
 
 /* forward references */
 struct file;
@@ -48,6 +49,7 @@ struct poll_table_struct;
  * @p_h264_scaling_matrix:     Pointer to a struct v4l2_ctrl_h264_scaling_matrix.
  * @p_h264_slice_params:       Pointer to a struct v4l2_ctrl_h264_slice_params.
  * @p_h264_decode_params:      Pointer to a struct v4l2_ctrl_h264_decode_params.
+ * @p_vp8_frame_header:                Pointer to a VP8 frame header structure.
  * @p:                         Pointer to a compound value.
  */
 union v4l2_ctrl_ptr {
@@ -65,6 +67,7 @@ union v4l2_ctrl_ptr {
        struct v4l2_ctrl_h264_scaling_matrix *p_h264_scaling_matrix;
        struct v4l2_ctrl_h264_slice_params *p_h264_slice_params;
        struct v4l2_ctrl_h264_decode_params *p_h264_decode_params;
+       struct v4l2_ctrl_vp8_frame_header *p_vp8_frame_header;
        void *p;
 };
 
@@ -1265,25 +1268,28 @@ int v4l2_s_ctrl(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
  *     :ref:`VIDIOC_G_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
  *
  * @hdl: pointer to &struct v4l2_ctrl_handler
+ * @vdev: pointer to &struct video_device
  * @mdev: pointer to &struct media_device
  * @c: pointer to &struct v4l2_ext_controls
  *
  * If hdl == NULL then they will all return -EINVAL.
  */
-int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct media_device *mdev,
-                    struct v4l2_ext_controls *c);
+int v4l2_g_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct video_device *vdev,
+                    struct media_device *mdev, struct v4l2_ext_controls *c);
 
 /**
  * v4l2_try_ext_ctrls - Helper function to implement
  *     :ref:`VIDIOC_TRY_EXT_CTRLS <vidioc_g_ext_ctrls>` ioctl
  *
  * @hdl: pointer to &struct v4l2_ctrl_handler
+ * @vdev: pointer to &struct video_device
  * @mdev: pointer to &struct media_device
  * @c: pointer to &struct v4l2_ext_controls
  *
  * If hdl == NULL then they will all return -EINVAL.
  */
 int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl,
+                      struct video_device *vdev,
                       struct media_device *mdev,
                       struct v4l2_ext_controls *c);
 
@@ -1293,12 +1299,14 @@ int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl,
  *
  * @fh: pointer to &struct v4l2_fh
  * @hdl: pointer to &struct v4l2_ctrl_handler
+ * @vdev: pointer to &struct video_device
  * @mdev: pointer to &struct media_device
  * @c: pointer to &struct v4l2_ext_controls
  *
  * If hdl == NULL then they will all return -EINVAL.
  */
 int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl,
+                    struct video_device *vdev,
                     struct media_device *mdev,
                     struct v4l2_ext_controls *c);
 
index 400f2e46c1085824d4611fbb499405f62ac9b4f4..4bba65a59d466ff39b9b8d45b7000a1e1b162a71 100644 (file)
@@ -602,6 +602,8 @@ struct v4l2_ioctl_ops {
 #define V4L2_DEV_DEBUG_STREAMING       0x08
 /* Log poll() */
 #define V4L2_DEV_DEBUG_POLL            0x10
+/* Log controls */
+#define V4L2_DEV_DEBUG_CTRL            0x20
 
 /*  Video standard functions  */
 
diff --git a/include/media/vp8-ctrls.h b/include/media/vp8-ctrls.h
new file mode 100644 (file)
index 0000000..53cba82
--- /dev/null
@@ -0,0 +1,112 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * These are the VP8 state controls for use with stateless VP8
+ * codec drivers.
+ *
+ * It turns out that these structs are not stable yet and will undergo
+ * more changes. So keep them private until they are stable and ready to
+ * become part of the official public API.
+ */
+
+#ifndef _VP8_CTRLS_H_
+#define _VP8_CTRLS_H_
+
+#include <linux/types.h>
+
+#define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F')
+
+#define V4L2_CID_MPEG_VIDEO_VP8_FRAME_HEADER (V4L2_CID_MPEG_BASE + 2000)
+#define V4L2_CTRL_TYPE_VP8_FRAME_HEADER 0x301
+
+#define V4L2_VP8_SEGMENT_HEADER_FLAG_ENABLED              0x01
+#define V4L2_VP8_SEGMENT_HEADER_FLAG_UPDATE_MAP           0x02
+#define V4L2_VP8_SEGMENT_HEADER_FLAG_UPDATE_FEATURE_DATA  0x04
+#define V4L2_VP8_SEGMENT_HEADER_FLAG_DELTA_VALUE_MODE     0x08
+
+struct v4l2_vp8_segment_header {
+       __s8 quant_update[4];
+       __s8 lf_update[4];
+       __u8 segment_probs[3];
+       __u8 padding;
+       __u32 flags;
+};
+
+#define V4L2_VP8_LF_HEADER_ADJ_ENABLE  0x01
+#define V4L2_VP8_LF_HEADER_DELTA_UPDATE        0x02
+#define V4L2_VP8_LF_FILTER_TYPE_SIMPLE 0x04
+struct v4l2_vp8_loopfilter_header {
+       __s8 ref_frm_delta[4];
+       __s8 mb_mode_delta[4];
+       __u8 sharpness_level;
+       __u8 level;
+       __u16 padding;
+       __u32 flags;
+};
+
+struct v4l2_vp8_quantization_header {
+       __u8 y_ac_qi;
+       __s8 y_dc_delta;
+       __s8 y2_dc_delta;
+       __s8 y2_ac_delta;
+       __s8 uv_dc_delta;
+       __s8 uv_ac_delta;
+       __u16 padding;
+};
+
+struct v4l2_vp8_entropy_header {
+       __u8 coeff_probs[4][8][3][11];
+       __u8 y_mode_probs[4];
+       __u8 uv_mode_probs[3];
+       __u8 mv_probs[2][19];
+       __u8 padding[3];
+};
+
+struct v4l2_vp8_entropy_coder_state {
+       __u8 range;
+       __u8 value;
+       __u8 bit_count;
+       __u8 padding;
+};
+
+#define V4L2_VP8_FRAME_HEADER_FLAG_KEY_FRAME           0x01
+#define V4L2_VP8_FRAME_HEADER_FLAG_EXPERIMENTAL                0x02
+#define V4L2_VP8_FRAME_HEADER_FLAG_SHOW_FRAME          0x04
+#define V4L2_VP8_FRAME_HEADER_FLAG_MB_NO_SKIP_COEFF    0x08
+#define V4L2_VP8_FRAME_HEADER_FLAG_SIGN_BIAS_GOLDEN    0x10
+#define V4L2_VP8_FRAME_HEADER_FLAG_SIGN_BIAS_ALT       0x20
+
+#define VP8_FRAME_IS_KEY_FRAME(hdr) \
+       (!!((hdr)->flags & V4L2_VP8_FRAME_HEADER_FLAG_KEY_FRAME))
+
+struct v4l2_ctrl_vp8_frame_header {
+       struct v4l2_vp8_segment_header segment_header;
+       struct v4l2_vp8_loopfilter_header lf_header;
+       struct v4l2_vp8_quantization_header quant_header;
+       struct v4l2_vp8_entropy_header entropy_header;
+       struct v4l2_vp8_entropy_coder_state coder_state;
+
+       __u16 width;
+       __u16 height;
+
+       __u8 horizontal_scale;
+       __u8 vertical_scale;
+
+       __u8 version;
+       __u8 prob_skip_false;
+       __u8 prob_intra;
+       __u8 prob_last;
+       __u8 prob_gf;
+       __u8 num_dct_parts;
+
+       __u32 first_part_size;
+       __u32 first_part_header_bits;
+       __u32 dct_part_sizes[8];
+
+       __u64 last_frame_ts;
+       __u64 golden_frame_ts;
+       __u64 alt_frame_ts;
+
+       __u64 flags;
+};
+
+#endif