浏览代码

media: staging: atomisp: Remove driver

The atomisp driver has a long list of todo items and little has been done
to address these lately while more has been added. The driver is also not
functional. In other words, the driver would not be getting out of staging
in the foreseeable future. At the same time it consumes developer
resources in order to maintain the flaky code base. Remove it.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Sakari Ailus 7 年之前
父节点
当前提交
51b8dc5163
共有 100 个文件被更改,包括 0 次插入54205 次删除
  1. 0 7
      MAINTAINERS
  2. 0 2
      drivers/staging/media/Kconfig
  3. 0 1
      drivers/staging/media/Makefile
  4. 0 12
      drivers/staging/media/atomisp/Kconfig
  5. 0 6
      drivers/staging/media/atomisp/Makefile
  6. 0 74
      drivers/staging/media/atomisp/TODO
  7. 0 86
      drivers/staging/media/atomisp/i2c/Kconfig
  8. 0 18
      drivers/staging/media/atomisp/i2c/Makefile
  9. 0 1392
      drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
  10. 0 1124
      drivers/staging/media/atomisp/i2c/atomisp-gc2235.c
  11. 0 205
      drivers/staging/media/atomisp/i2c/atomisp-libmsrlisthelper.c
  12. 0 968
      drivers/staging/media/atomisp/i2c/atomisp-lm3554.c
  13. 0 1908
      drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c
  14. 0 1470
      drivers/staging/media/atomisp/i2c/atomisp-ov2680.c
  15. 0 1271
      drivers/staging/media/atomisp/i2c/atomisp-ov2722.c
  16. 0 404
      drivers/staging/media/atomisp/i2c/gc0310.h
  17. 0 677
      drivers/staging/media/atomisp/i2c/gc2235.h
  18. 0 1788
      drivers/staging/media/atomisp/i2c/mt9m114.h
  19. 0 858
      drivers/staging/media/atomisp/i2c/ov2680.h
  20. 0 1268
      drivers/staging/media/atomisp/i2c/ov2722.h
  21. 0 11
      drivers/staging/media/atomisp/i2c/ov5693/Kconfig
  22. 0 2
      drivers/staging/media/atomisp/i2c/ov5693/Makefile
  23. 0 63
      drivers/staging/media/atomisp/i2c/ov5693/ad5823.h
  24. 0 1993
      drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c
  25. 0 1392
      drivers/staging/media/atomisp/i2c/ov5693/ov5693.h
  26. 0 1359
      drivers/staging/media/atomisp/include/linux/atomisp.h
  27. 0 36
      drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h
  28. 0 249
      drivers/staging/media/atomisp/include/linux/atomisp_platform.h
  29. 0 28
      drivers/staging/media/atomisp/include/linux/libmsrlisthelper.h
  30. 0 131
      drivers/staging/media/atomisp/include/media/lm3554.h
  31. 0 14
      drivers/staging/media/atomisp/pci/Kconfig
  32. 0 5
      drivers/staging/media/atomisp/pci/Makefile
  33. 0 349
      drivers/staging/media/atomisp/pci/atomisp2/Makefile
  34. 0 205
      drivers/staging/media/atomisp/pci/atomisp2/atomisp-regs.h
  35. 0 604
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_acc.c
  36. 0 120
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_acc.h
  37. 0 6697
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
  38. 0 446
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h
  39. 0 75
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_common.h
  40. 0 662
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat.h
  41. 0 4704
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c
  42. 0 277
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.h
  43. 0 1225
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_ioctl32.c
  44. 0 365
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_ioctl32.h
  45. 0 442
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_csi2.c
  46. 0 57
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_csi2.h
  47. 0 408
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_dfs_tables.h
  48. 0 205
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c
  49. 0 24
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.h
  50. 0 225
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_file.c
  51. 0 43
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_file.h
  52. 0 1302
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c
  53. 0 50
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.h
  54. 0 29
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_helper.h
  55. 0 310
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h
  56. 0 3123
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c
  57. 0 69
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.h
  58. 0 1422
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_subdev.c
  59. 0 467
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_subdev.h
  60. 0 187
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_tables.h
  61. 0 164
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_tpg.c
  62. 0 38
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_tpg.h
  63. 0 129
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_trace_event.h
  64. 0 1562
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c
  65. 0 40
      drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.h
  66. 0 2
      drivers/staging/media/atomisp/pci/atomisp2/css2400/Makefile
  67. 0 376
      drivers/staging/media/atomisp/pci/atomisp2/css2400/base/circbuf/interface/ia_css_circbuf.h
  68. 0 56
      drivers/staging/media/atomisp/pci/atomisp2/css2400/base/circbuf/interface/ia_css_circbuf_comm.h
  69. 0 169
      drivers/staging/media/atomisp/pci/atomisp2/css2400/base/circbuf/interface/ia_css_circbuf_desc.h
  70. 0 321
      drivers/staging/media/atomisp/pci/atomisp2/css2400/base/circbuf/src/circbuf.c
  71. 0 83
      drivers/staging/media/atomisp/pci/atomisp2/css2400/base/refcount/interface/ia_css_refcount.h
  72. 0 281
      drivers/staging/media/atomisp/pci/atomisp2/css2400/base/refcount/src/refcount.c
  73. 0 297
      drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/interface/ia_css_pipe_binarydesc.h
  74. 0 52
      drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/interface/ia_css_pipe_stagedesc.h
  75. 0 39
      drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/interface/ia_css_pipe_util.h
  76. 0 880
      drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/src/pipe_binarydesc.c
  77. 0 115
      drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/src/pipe_stagedesc.c
  78. 0 51
      drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/src/pipe_util.c
  79. 0 141
      drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/util/interface/ia_css_util.h
  80. 0 227
      drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/util/src/util.c
  81. 0 360
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_configs.c
  82. 0 189
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_configs.h
  83. 0 3221
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_params.c
  84. 0 399
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_params.h
  85. 0 214
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_states.c
  86. 0 72
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_states.h
  87. 0 104
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/bits.h
  88. 0 42
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/cell_params.h
  89. 0 200
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/css_receiver_2400_common_defs.h
  90. 0 258
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/css_receiver_2400_defs.h
  91. 0 36
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/defs.h
  92. 0 199
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/dma_v2_defs.h
  93. 0 170
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/gdc_v2_defs.h
  94. 0 36
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/gp_timer_defs.h
  95. 0 42
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/gpio_block_defs.h
  96. 0 416
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/hive_isp_css_defs.h
  97. 0 84
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/hive_isp_css_host_ids_hrt.h
  98. 0 72
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/hive_isp_css_irq_types_hrt.h
  99. 0 26
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/hive_isp_css_streaming_to_mipi_types_hrt.h
  100. 0 128
      drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/hive_types.h

+ 0 - 7
MAINTAINERS

@@ -13272,13 +13272,6 @@ L:	stable@vger.kernel.org
 S:	Supported
 F:	Documentation/process/stable-kernel-rules.rst
 
-STAGING - ATOMISP DRIVER
-M:	Alan Cox <alan@linux.intel.com>
-M:	Sakari Ailus <sakari.ailus@linux.intel.com>
-L:	linux-media@vger.kernel.org
-S:	Maintained
-F:	drivers/staging/media/atomisp/
-
 STAGING - COMEDI
 M:	Ian Abbott <abbotti@mev.co.uk>
 M:	H Hartley Sweeten <hsweeten@visionengravers.com>

+ 0 - 2
drivers/staging/media/Kconfig

@@ -19,8 +19,6 @@ menuconfig STAGING_MEDIA
 if STAGING_MEDIA && MEDIA_SUPPORT
 
 # Please keep them in alphabetic order
-source "drivers/staging/media/atomisp/Kconfig"
-
 source "drivers/staging/media/bcm2048/Kconfig"
 
 source "drivers/staging/media/davinci_vpfe/Kconfig"

+ 0 - 1
drivers/staging/media/Makefile

@@ -5,5 +5,4 @@ obj-$(CONFIG_SOC_CAMERA_IMX074)	+= imx074/
 obj-$(CONFIG_SOC_CAMERA_MT9T031)	+= mt9t031/
 obj-$(CONFIG_VIDEO_DM365_VPFE)	+= davinci_vpfe/
 obj-$(CONFIG_VIDEO_OMAP4)	+= omap4iss/
-obj-$(CONFIG_INTEL_ATOMISP)     += atomisp/
 obj-$(CONFIG_TEGRA_VDE)		+= tegra-vde/

+ 0 - 12
drivers/staging/media/atomisp/Kconfig

@@ -1,12 +0,0 @@
-menuconfig INTEL_ATOMISP
-	bool "Enable support to Intel MIPI camera drivers"
-	depends on X86 && EFI && MEDIA_CONTROLLER && PCI && ACPI
-	select COMMON_CLK
-	help
-	  Enable support for the Intel ISP2 camera interfaces and MIPI
-	  sensor drivers.
-
-if INTEL_ATOMISP
-source "drivers/staging/media/atomisp/pci/Kconfig"
-source "drivers/staging/media/atomisp/i2c/Kconfig"
-endif

+ 0 - 6
drivers/staging/media/atomisp/Makefile

@@ -1,6 +0,0 @@
-#
-# Makefile for camera drivers.
-#
-obj-$(CONFIG_INTEL_ATOMISP) += pci/
-obj-$(CONFIG_INTEL_ATOMISP) += i2c/
-obj-$(CONFIG_INTEL_ATOMISP) += platform/

+ 0 - 74
drivers/staging/media/atomisp/TODO

@@ -1,74 +0,0 @@
-1. A single AtomISP driver needs to be implemented to support both BYT and
-   CHT platforms. The current driver is a mechanical and hand combined merge
-   of the two using an ifdef ISP2401 to select the CHT version, which at the
-   moment is not enabled. Eventually this should become a runtime if check,
-   but there are some quite tricky things that need sorting out before that
-   will be possible.
-
-2. The file structure needs to get tidied up to resemble a normal Linux
-   driver.
-
-3. Lots of the midlayer glue. unused code and abstraction needs removing.
-
-3. The sensor drivers read MIPI settings from EFI variables or default to the
-   settings hard-coded in the platform data file for different platforms.
-   This isn't ideal but may be hard to improve as this is how existing
-   platforms work.
-
-4. The sensor drivers use the regulator framework API. In the ideal world it
-   would be using ACPI but that's not how the existing devices work.
-
-5. The AtomISP driver includes some special IOCTLS (ATOMISP_IOC_XXXX_XXXX)
-   that may need some cleaning up.
-
-6. Correct Coding Style. Please don't send coding style patches for this
-   driver until the other work is done.
-
-7. The ISP code depends on the exact FW version. The version defined in
-   BYT: 
-   drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c
-   static const char *release_version = STR(irci_stable_candrpv_0415_20150521_0458);
-   CHT:
-   drivers/staging/media/atomisp/pci/atomisp2/css/sh_css_firmware.c
-   static const char *release_version = STR(irci_ecr-master_20150911_0724);
-
-   At some point we may need to round up a few driver versions and see if
-   there are any specific things that can be done to fold in support for
-   multiple firmware versions.
-
-8. Switch to V4L2 async API to set up sensor, lens and flash devices.
-   Control those devices using V4L2 sub-device API without custom
-   extensions.
-
-9. Switch to standard V4L2 sub-device API for sensor and lens. In
-   particular, the user space API needs to support V4L2 controls as
-   defined in the V4L2 spec and references to atomisp must be removed from
-   these drivers.
-
-10. Use LED flash API for flash LED drivers such as LM3554 (which already
-    has a LED class driver).
-
-11. Switch from videobuf1 to videobuf2. Videobuf1 is being removed!
-
-Limitations:
-
-1. To test the patches, you also need the ISP firmware
-
-   for BYT:/lib/firmware/shisp_2400b0_v21.bin
-   for CHT:/lib/firmware/shisp_2401a0_v21.bin
-
-   The firmware files will usually be found in /etc/firmware on an Android
-   device but can also be extracted from the upgrade kit if you've managed
-   to lose them somehow.
-
-2. Without a 3A libary the capture behaviour is not very good. To take a good
-   picture, you need tune ISP parameters by IOCTL functions or use a 3A libary
-   such as libxcam.
-
-3. The driver is intended to drive the PCI exposed versions of the device.
-   It will not detect those devices enumerated via ACPI as a field of the
-   i915 GPU driver.
-
-4. The driver supports only v2 of the IPU/Camera. It will not work with the
-   versions of the hardware in other SoCs.
-

+ 0 - 86
drivers/staging/media/atomisp/i2c/Kconfig

@@ -1,86 +0,0 @@
-#
-# Kconfig for sensor drivers
-#
-
-source "drivers/staging/media/atomisp/i2c/ov5693/Kconfig"
-
-config VIDEO_ATOMISP_OV2722
-       tristate "OVT ov2722 sensor support"
-	depends on ACPI
-       depends on I2C && VIDEO_V4L2
-       ---help---
-	 This is a Video4Linux2 sensor-level driver for the OVT
-	 OV2722 raw camera.
-
-	 OVT is a 2M raw sensor.
-
-	 It currently only works with the atomisp driver.
-
-config VIDEO_ATOMISP_GC2235
-       tristate "Galaxy gc2235 sensor support"
-	depends on ACPI
-       depends on I2C && VIDEO_V4L2
-       ---help---
-	 This is a Video4Linux2 sensor-level driver for the OVT
-	 GC2235 raw camera.
-
-	 GC2235 is a 2M raw sensor.
-
-	 It currently only works with the atomisp driver.
-
-config VIDEO_ATOMISP_MSRLIST_HELPER
-       tristate "Helper library to load, parse and apply large register lists."
-       depends on I2C
-       ---help---
-	 This is a helper library to be used from a sensor driver to load, parse
-	 and apply large register lists.
-
-	 To compile this driver as a module, choose M here: the
-	 module will be called libmsrlisthelper.
-
-config VIDEO_ATOMISP_MT9M114
-       tristate "Aptina mt9m114 sensor support"
-	depends on ACPI
-       depends on I2C && VIDEO_V4L2
-       ---help---
-	 This is a Video4Linux2 sensor-level driver for the Micron
-	 mt9m114 1.3 Mpixel camera.
-
-	 mt9m114 is video camera sensor.
-
-	 It currently only works with the atomisp driver.
-
-config VIDEO_ATOMISP_GC0310
-	tristate "GC0310 sensor support"
-	depends on ACPI
-	depends on I2C && VIDEO_V4L2
-	---help---
-	  This is a Video4Linux2 sensor-level driver for the Galaxycore
-	  GC0310 0.3MP sensor.
-	 
-config VIDEO_ATOMISP_OV2680
-       tristate "Omnivision OV2680 sensor support"
-	depends on ACPI
-       depends on I2C && VIDEO_V4L2
-       ---help---
-	 This is a Video4Linux2 sensor-level driver for the Omnivision
-	 OV2680 raw camera.
-
-	 ov2680 is a 2M raw sensor.
-
-	 It currently only works with the atomisp driver.
-
-#
-# Kconfig for flash drivers
-#
-
-config VIDEO_ATOMISP_LM3554
-       tristate "LM3554 flash light driver"
-	depends on ACPI
-       depends on VIDEO_V4L2 && I2C
-       ---help---
-	 This is a Video4Linux2 sub-dev driver for the LM3554
-	 flash light driver.
-
-	 To compile this driver as a module, choose M here: the
-	 module will be called lm3554

+ 0 - 18
drivers/staging/media/atomisp/i2c/Makefile

@@ -1,18 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile for sensor drivers
-#
-
-obj-$(CONFIG_VIDEO_ATOMISP_OV5693)     += ov5693/
-obj-$(CONFIG_VIDEO_ATOMISP_MT9M114)    += atomisp-mt9m114.o
-obj-$(CONFIG_VIDEO_ATOMISP_GC2235)     += atomisp-gc2235.o
-obj-$(CONFIG_VIDEO_ATOMISP_OV2722)     += atomisp-ov2722.o
-obj-$(CONFIG_VIDEO_ATOMISP_OV2680)     += atomisp-ov2680.o
-obj-$(CONFIG_VIDEO_ATOMISP_GC0310)     += atomisp-gc0310.o
-
-obj-$(CONFIG_VIDEO_ATOMISP_MSRLIST_HELPER) += atomisp-libmsrlisthelper.o
-
-# Makefile for flash drivers
-#
-
-obj-$(CONFIG_VIDEO_ATOMISP_LM3554) += atomisp-lm3554.o

+ 0 - 1392
drivers/staging/media/atomisp/i2c/atomisp-gc0310.c

@@ -1,1392 +0,0 @@
-/*
- * Support for GalaxyCore GC0310 VGA camera sensor.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/kmod.h>
-#include <linux/device.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/i2c.h>
-#include <linux/moduleparam.h>
-#include <media/v4l2-device.h>
-#include <linux/io.h>
-#include "../include/linux/atomisp_gmin_platform.h"
-
-#include "gc0310.h"
-
-/* i2c read/write stuff */
-static int gc0310_read_reg(struct i2c_client *client,
-			   u16 data_length, u8 reg, u8 *val)
-{
-	int err;
-	struct i2c_msg msg[2];
-	unsigned char data[1];
-
-	if (!client->adapter) {
-		dev_err(&client->dev, "%s error, no client->adapter\n",
-			__func__);
-		return -ENODEV;
-	}
-
-	if (data_length != GC0310_8BIT) {
-		dev_err(&client->dev, "%s error, invalid data length\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	memset(msg, 0, sizeof(msg));
-
-	msg[0].addr = client->addr;
-	msg[0].flags = 0;
-	msg[0].len = I2C_MSG_LENGTH;
-	msg[0].buf = data;
-
-	/* high byte goes out first */
-	data[0] = (u8)(reg & 0xff);
-
-	msg[1].addr = client->addr;
-	msg[1].len = data_length;
-	msg[1].flags = I2C_M_RD;
-	msg[1].buf = data;
-
-	err = i2c_transfer(client->adapter, msg, 2);
-	if (err != 2) {
-		if (err >= 0)
-			err = -EIO;
-		dev_err(&client->dev,
-			"read from offset 0x%x error %d", reg, err);
-		return err;
-	}
-
-	*val = 0;
-	/* high byte comes first */
-	if (data_length == GC0310_8BIT)
-		*val = (u8)data[0];
-
-	return 0;
-}
-
-static int gc0310_i2c_write(struct i2c_client *client, u16 len, u8 *data)
-{
-	struct i2c_msg msg;
-	const int num_msg = 1;
-	int ret;
-
-	msg.addr = client->addr;
-	msg.flags = 0;
-	msg.len = len;
-	msg.buf = data;
-	ret = i2c_transfer(client->adapter, &msg, 1);
-
-	return ret == num_msg ? 0 : -EIO;
-}
-
-static int gc0310_write_reg(struct i2c_client *client, u16 data_length,
-							u8 reg, u8 val)
-{
-	int ret;
-	unsigned char data[2] = {0};
-	u8 *wreg = (u8 *)data;
-	const u16 len = data_length + sizeof(u8); /* 8-bit address + data */
-
-	if (data_length != GC0310_8BIT) {
-		dev_err(&client->dev,
-			"%s error, invalid data_length\n", __func__);
-		return -EINVAL;
-	}
-
-	/* high byte goes out first */
-	*wreg = (u8)(reg & 0xff);
-
-	if (data_length == GC0310_8BIT)
-		data[1] = (u8)(val);
-
-	ret = gc0310_i2c_write(client, len, data);
-	if (ret)
-		dev_err(&client->dev,
-			"write error: wrote 0x%x to offset 0x%x error %d",
-			val, reg, ret);
-
-	return ret;
-}
-
-/*
- * gc0310_write_reg_array - Initializes a list of GC0310 registers
- * @client: i2c driver client structure
- * @reglist: list of registers to be written
- *
- * This function initializes a list of registers. When consecutive addresses
- * are found in a row on the list, this function creates a buffer and sends
- * consecutive data in a single i2c_transfer().
- *
- * __gc0310_flush_reg_array, __gc0310_buf_reg_array() and
- * __gc0310_write_reg_is_consecutive() are internal functions to
- * gc0310_write_reg_array_fast() and should be not used anywhere else.
- *
- */
-
-static int __gc0310_flush_reg_array(struct i2c_client *client,
-				    struct gc0310_write_ctrl *ctrl)
-{
-	u16 size;
-
-	if (ctrl->index == 0)
-		return 0;
-
-	size = sizeof(u8) + ctrl->index; /* 8-bit address + data */
-	ctrl->buffer.addr = (u8)(ctrl->buffer.addr);
-	ctrl->index = 0;
-
-	return gc0310_i2c_write(client, size, (u8 *)&ctrl->buffer);
-}
-
-static int __gc0310_buf_reg_array(struct i2c_client *client,
-				  struct gc0310_write_ctrl *ctrl,
-				  const struct gc0310_reg *next)
-{
-	int size;
-
-	switch (next->type) {
-	case GC0310_8BIT:
-		size = 1;
-		ctrl->buffer.data[ctrl->index] = (u8)next->val;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	/* When first item is added, we need to store its starting address */
-	if (ctrl->index == 0)
-		ctrl->buffer.addr = next->reg;
-
-	ctrl->index += size;
-
-	/*
-	 * Buffer cannot guarantee free space for u32? Better flush it to avoid
-	 * possible lack of memory for next item.
-	 */
-	if (ctrl->index + sizeof(u8) >= GC0310_MAX_WRITE_BUF_SIZE)
-		return __gc0310_flush_reg_array(client, ctrl);
-
-	return 0;
-}
-
-static int __gc0310_write_reg_is_consecutive(struct i2c_client *client,
-					     struct gc0310_write_ctrl *ctrl,
-					     const struct gc0310_reg *next)
-{
-	if (ctrl->index == 0)
-		return 1;
-
-	return ctrl->buffer.addr + ctrl->index == next->reg;
-}
-
-static int gc0310_write_reg_array(struct i2c_client *client,
-				  const struct gc0310_reg *reglist)
-{
-	const struct gc0310_reg *next = reglist;
-	struct gc0310_write_ctrl ctrl;
-	int err;
-
-	ctrl.index = 0;
-	for (; next->type != GC0310_TOK_TERM; next++) {
-		switch (next->type & GC0310_TOK_MASK) {
-		case GC0310_TOK_DELAY:
-			err = __gc0310_flush_reg_array(client, &ctrl);
-			if (err)
-				return err;
-			msleep(next->val);
-			break;
-		default:
-			/*
-			 * If next address is not consecutive, data needs to be
-			 * flushed before proceed.
-			 */
-			if (!__gc0310_write_reg_is_consecutive(client, &ctrl,
-								next)) {
-				err = __gc0310_flush_reg_array(client, &ctrl);
-				if (err)
-					return err;
-			}
-			err = __gc0310_buf_reg_array(client, &ctrl, next);
-			if (err) {
-				dev_err(&client->dev, "%s: write error, aborted\n",
-					 __func__);
-				return err;
-			}
-			break;
-		}
-	}
-
-	return __gc0310_flush_reg_array(client, &ctrl);
-}
-static int gc0310_g_focal(struct v4l2_subdev *sd, s32 *val)
-{
-	*val = (GC0310_FOCAL_LENGTH_NUM << 16) | GC0310_FOCAL_LENGTH_DEM;
-	return 0;
-}
-
-static int gc0310_g_fnumber(struct v4l2_subdev *sd, s32 *val)
-{
-	/*const f number for imx*/
-	*val = (GC0310_F_NUMBER_DEFAULT_NUM << 16) | GC0310_F_NUMBER_DEM;
-	return 0;
-}
-
-static int gc0310_g_fnumber_range(struct v4l2_subdev *sd, s32 *val)
-{
-	*val = (GC0310_F_NUMBER_DEFAULT_NUM << 24) |
-		(GC0310_F_NUMBER_DEM << 16) |
-		(GC0310_F_NUMBER_DEFAULT_NUM << 8) | GC0310_F_NUMBER_DEM;
-	return 0;
-}
-
-static int gc0310_g_bin_factor_x(struct v4l2_subdev *sd, s32 *val)
-{
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-
-	*val = gc0310_res[dev->fmt_idx].bin_factor_x;
-
-	return 0;
-}
-
-static int gc0310_g_bin_factor_y(struct v4l2_subdev *sd, s32 *val)
-{
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-
-	*val = gc0310_res[dev->fmt_idx].bin_factor_y;
-
-	return 0;
-}
-
-static int gc0310_get_intg_factor(struct i2c_client *client,
-				struct camera_mipi_info *info,
-				const struct gc0310_resolution *res)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-	struct atomisp_sensor_mode_data *buf = &info->data;
-	u16 val;
-	u8 reg_val;
-	int ret;
-	unsigned int hori_blanking;
-	unsigned int vert_blanking;
-	unsigned int sh_delay;
-
-	if (!info)
-		return -EINVAL;
-
-	/* pixel clock calculattion */
-	dev->vt_pix_clk_freq_mhz = 14400000; // 16.8MHz
-	buf->vt_pix_clk_freq_mhz = dev->vt_pix_clk_freq_mhz;
-	pr_info("vt_pix_clk_freq_mhz=%d\n", buf->vt_pix_clk_freq_mhz);
-
-	/* get integration time */
-	buf->coarse_integration_time_min = GC0310_COARSE_INTG_TIME_MIN;
-	buf->coarse_integration_time_max_margin =
-					GC0310_COARSE_INTG_TIME_MAX_MARGIN;
-
-	buf->fine_integration_time_min = GC0310_FINE_INTG_TIME_MIN;
-	buf->fine_integration_time_max_margin =
-					GC0310_FINE_INTG_TIME_MAX_MARGIN;
-
-	buf->fine_integration_time_def = GC0310_FINE_INTG_TIME_MIN;
-	buf->read_mode = res->bin_mode;
-
-	/* get the cropping and output resolution to ISP for this mode. */
-	/* Getting crop_horizontal_start */
-	ret =  gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_H_CROP_START_H, &reg_val);
-	if (ret)
-		return ret;
-	val = (reg_val & 0xFF) << 8;
-	ret =  gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_H_CROP_START_L, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_horizontal_start = val | (reg_val & 0xFF);
-	pr_info("crop_horizontal_start=%d\n", buf->crop_horizontal_start);
-
-	/* Getting crop_vertical_start */
-	ret =  gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_V_CROP_START_H, &reg_val);
-	if (ret)
-		return ret;
-	val = (reg_val & 0xFF) << 8;
-	ret =  gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_V_CROP_START_L, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_vertical_start = val | (reg_val & 0xFF);
-	pr_info("crop_vertical_start=%d\n", buf->crop_vertical_start);
-
-	/* Getting output_width */
-	ret = gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_H_OUTSIZE_H, &reg_val);
-	if (ret)
-		return ret;
-	val = (reg_val & 0xFF) << 8;
-	ret = gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_H_OUTSIZE_L, &reg_val);
-	if (ret)
-		return ret;
-	buf->output_width = val | (reg_val & 0xFF);
-	pr_info("output_width=%d\n", buf->output_width);
-
-	/* Getting output_height */
-	ret = gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_V_OUTSIZE_H, &reg_val);
-	if (ret)
-		return ret;
-	val = (reg_val & 0xFF) << 8;
-	ret = gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_V_OUTSIZE_L, &reg_val);
-	if (ret)
-		return ret;
-	buf->output_height = val | (reg_val & 0xFF);
-	pr_info("output_height=%d\n", buf->output_height);
-
-	buf->crop_horizontal_end = buf->crop_horizontal_start + buf->output_width - 1;
-	buf->crop_vertical_end = buf->crop_vertical_start + buf->output_height - 1;
-	pr_info("crop_horizontal_end=%d\n", buf->crop_horizontal_end);
-	pr_info("crop_vertical_end=%d\n", buf->crop_vertical_end);
-
-	/* Getting line_length_pck */
-	ret = gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_H_BLANKING_H, &reg_val);
-	if (ret)
-		return ret;
-	val = (reg_val & 0xFF) << 8;
-	ret = gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_H_BLANKING_L, &reg_val);
-	if (ret)
-		return ret;
-	hori_blanking = val | (reg_val & 0xFF);
-	ret = gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_SH_DELAY, &reg_val);
-	if (ret)
-		return ret;
-	sh_delay = reg_val;
-	buf->line_length_pck = buf->output_width + hori_blanking + sh_delay + 4;
-	pr_info("hori_blanking=%d sh_delay=%d line_length_pck=%d\n", hori_blanking, sh_delay, buf->line_length_pck);
-
-	/* Getting frame_length_lines */
-	ret = gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_V_BLANKING_H, &reg_val);
-	if (ret)
-		return ret;
-	val = (reg_val & 0xFF) << 8;
-	ret = gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_V_BLANKING_L, &reg_val);
-	if (ret)
-		return ret;
-	vert_blanking = val | (reg_val & 0xFF);
-	buf->frame_length_lines = buf->output_height + vert_blanking;
-	pr_info("vert_blanking=%d frame_length_lines=%d\n", vert_blanking, buf->frame_length_lines);
-
-	buf->binning_factor_x = res->bin_factor_x ?
-					res->bin_factor_x : 1;
-	buf->binning_factor_y = res->bin_factor_y ?
-					res->bin_factor_y : 1;
-	return 0;
-}
-
-static int gc0310_set_gain(struct v4l2_subdev *sd, int gain)
-
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-	u8 again, dgain;
-
-	if (gain < 0x20)
-		gain = 0x20;
-	if (gain > 0x80)
-		gain = 0x80;
-
-	if (gain >= 0x20 && gain < 0x40) {
-		again = 0x0; /* sqrt(2) */
-		dgain = gain;
-	} else {
-		again = 0x2; /* 2 * sqrt(2) */
-		dgain = gain / 2;
-	}
-
-	pr_info("gain=0x%x again=0x%x dgain=0x%x\n", gain, again, dgain);
-
-	/* set analog gain */
-	ret = gc0310_write_reg(client, GC0310_8BIT,
-					GC0310_AGC_ADJ, again);
-	if (ret)
-		return ret;
-
-	/* set digital gain */
-	ret = gc0310_write_reg(client, GC0310_8BIT,
-					GC0310_DGC_ADJ, dgain);
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
-static int __gc0310_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
-				 int gain, int digitgain)
-
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	pr_info("coarse_itg=%d gain=%d digitgain=%d\n", coarse_itg, gain, digitgain);
-
-	/* set exposure */
-	ret = gc0310_write_reg(client, GC0310_8BIT,
-					GC0310_AEC_PK_EXPO_L,
-					coarse_itg & 0xff);
-	if (ret)
-		return ret;
-
-	ret = gc0310_write_reg(client, GC0310_8BIT,
-					GC0310_AEC_PK_EXPO_H,
-					(coarse_itg >> 8) & 0x0f);
-	if (ret)
-		return ret;
-
-	ret = gc0310_set_gain(sd, gain);
-	if (ret)
-		return ret;
-
-	return ret;
-}
-
-static int gc0310_set_exposure(struct v4l2_subdev *sd, int exposure,
-	int gain, int digitgain)
-{
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-	int ret;
-
-	mutex_lock(&dev->input_lock);
-	ret = __gc0310_set_exposure(sd, exposure, gain, digitgain);
-	mutex_unlock(&dev->input_lock);
-
-	return ret;
-}
-
-static long gc0310_s_exposure(struct v4l2_subdev *sd,
-			       struct atomisp_exposure *exposure)
-{
-	int exp = exposure->integration_time[0];
-	int gain = exposure->gain[0];
-	int digitgain = exposure->gain[1];
-
-	/* we should not accept the invalid value below. */
-	if (gain == 0) {
-		struct i2c_client *client = v4l2_get_subdevdata(sd);
-		v4l2_err(client, "%s: invalid value\n", __func__);
-		return -EINVAL;
-	}
-
-	return gc0310_set_exposure(sd, exp, gain, digitgain);
-}
-
-/* TO DO */
-static int gc0310_v_flip(struct v4l2_subdev *sd, s32 value)
-{
-	return 0;
-}
-
-/* TO DO */
-static int gc0310_h_flip(struct v4l2_subdev *sd, s32 value)
-{
-	return 0;
-}
-
-static long gc0310_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
-{
-
-	switch (cmd) {
-	case ATOMISP_IOC_S_EXPOSURE:
-		return gc0310_s_exposure(sd, arg);
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
-
-/* This returns the exposure time being used. This should only be used
- * for filling in EXIF data, not for actual image processing.
- */
-static int gc0310_q_exposure(struct v4l2_subdev *sd, s32 *value)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	u8 reg_v;
-	int ret;
-
-	/* get exposure */
-	ret = gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_AEC_PK_EXPO_L,
-					&reg_v);
-	if (ret)
-		goto err;
-
-	*value = reg_v;
-	ret = gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_AEC_PK_EXPO_H,
-					&reg_v);
-	if (ret)
-		goto err;
-
-	*value = *value + (reg_v << 8);
-err:
-	return ret;
-}
-
-static int gc0310_s_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct gc0310_device *dev =
-	    container_of(ctrl->handler, struct gc0310_device, ctrl_handler);
-	struct i2c_client *client = v4l2_get_subdevdata(&dev->sd);
-	int ret = 0;
-
-	switch (ctrl->id) {
-	case V4L2_CID_VFLIP:
-		dev_dbg(&client->dev, "%s: CID_VFLIP:%d.\n",
-			__func__, ctrl->val);
-		ret = gc0310_v_flip(&dev->sd, ctrl->val);
-		break;
-	case V4L2_CID_HFLIP:
-		dev_dbg(&client->dev, "%s: CID_HFLIP:%d.\n",
-			__func__, ctrl->val);
-		ret = gc0310_h_flip(&dev->sd, ctrl->val);
-		break;
-	default:
-		ret = -EINVAL;
-	}
-	return ret;
-}
-
-static int gc0310_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct gc0310_device *dev =
-	    container_of(ctrl->handler, struct gc0310_device, ctrl_handler);
-	int ret = 0;
-
-	switch (ctrl->id) {
-	case V4L2_CID_EXPOSURE_ABSOLUTE:
-		ret = gc0310_q_exposure(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FOCAL_ABSOLUTE:
-		ret = gc0310_g_focal(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FNUMBER_ABSOLUTE:
-		ret = gc0310_g_fnumber(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FNUMBER_RANGE:
-		ret = gc0310_g_fnumber_range(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_BIN_FACTOR_HORZ:
-		ret = gc0310_g_bin_factor_x(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_BIN_FACTOR_VERT:
-		ret = gc0310_g_bin_factor_y(&dev->sd, &ctrl->val);
-		break;
-	default:
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static const struct v4l2_ctrl_ops ctrl_ops = {
-	.s_ctrl = gc0310_s_ctrl,
-	.g_volatile_ctrl = gc0310_g_volatile_ctrl
-};
-
-static const struct v4l2_ctrl_config gc0310_controls[] = {
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_EXPOSURE_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "exposure",
-	 .min = 0x0,
-	 .max = 0xffff,
-	 .step = 0x01,
-	 .def = 0x00,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_VFLIP,
-	 .type = V4L2_CTRL_TYPE_BOOLEAN,
-	 .name = "Flip",
-	 .min = 0,
-	 .max = 1,
-	 .step = 1,
-	 .def = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_HFLIP,
-	 .type = V4L2_CTRL_TYPE_BOOLEAN,
-	 .name = "Mirror",
-	 .min = 0,
-	 .max = 1,
-	 .step = 1,
-	 .def = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FOCAL_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "focal length",
-	 .min = GC0310_FOCAL_LENGTH_DEFAULT,
-	 .max = GC0310_FOCAL_LENGTH_DEFAULT,
-	 .step = 0x01,
-	 .def = GC0310_FOCAL_LENGTH_DEFAULT,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FNUMBER_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "f-number",
-	 .min = GC0310_F_NUMBER_DEFAULT,
-	 .max = GC0310_F_NUMBER_DEFAULT,
-	 .step = 0x01,
-	 .def = GC0310_F_NUMBER_DEFAULT,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FNUMBER_RANGE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "f-number range",
-	 .min = GC0310_F_NUMBER_RANGE,
-	 .max = GC0310_F_NUMBER_RANGE,
-	 .step = 0x01,
-	 .def = GC0310_F_NUMBER_RANGE,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_BIN_FACTOR_HORZ,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "horizontal binning factor",
-	 .min = 0,
-	 .max = GC0310_BIN_FACTOR_MAX,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_BIN_FACTOR_VERT,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "vertical binning factor",
-	 .min = 0,
-	 .max = GC0310_BIN_FACTOR_MAX,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-};
-
-static int gc0310_init(struct v4l2_subdev *sd)
-{
-	int ret;
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-
-	pr_info("%s S\n", __func__);
-	mutex_lock(&dev->input_lock);
-
-	/* set inital registers */
-	ret  = gc0310_write_reg_array(client, gc0310_reset_register);
-
-	/* restore settings */
-	gc0310_res = gc0310_res_preview;
-	N_RES = N_RES_PREVIEW;
-
-	mutex_unlock(&dev->input_lock);
-
-	pr_info("%s E\n", __func__);
-	return ret;
-}
-
-static int power_ctrl(struct v4l2_subdev *sd, bool flag)
-{
-	int ret = 0;
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-	if (!dev || !dev->platform_data)
-		return -ENODEV;
-
-	if (flag) {
-		/* The upstream module driver (written to Crystal
-		 * Cove) had this logic to pulse the rails low first.
-		 * This appears to break things on the MRD7 with the
-		 * X-Powers PMIC...
-		 *
-		 *     ret = dev->platform_data->v1p8_ctrl(sd, 0);
-		 *     ret |= dev->platform_data->v2p8_ctrl(sd, 0);
-		 *     mdelay(50);
-		 */
-		ret |= dev->platform_data->v1p8_ctrl(sd, 1);
-		ret |= dev->platform_data->v2p8_ctrl(sd, 1);
-		usleep_range(10000, 15000);
-	}
-
-	if (!flag || ret) {
-		ret |= dev->platform_data->v1p8_ctrl(sd, 0);
-		ret |= dev->platform_data->v2p8_ctrl(sd, 0);
-	}
-	return ret;
-}
-
-static int gpio_ctrl(struct v4l2_subdev *sd, bool flag)
-{
-	int ret;
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-
-	if (!dev || !dev->platform_data)
-		return -ENODEV;
-
-	/* GPIO0 == "reset" (active low), GPIO1 == "power down" */
-	if (flag) {
-		/* Pulse reset, then release power down */
-		ret = dev->platform_data->gpio0_ctrl(sd, 0);
-		usleep_range(5000, 10000);
-		ret |= dev->platform_data->gpio0_ctrl(sd, 1);
-		usleep_range(10000, 15000);
-		ret |= dev->platform_data->gpio1_ctrl(sd, 0);
-		usleep_range(10000, 15000);
-	} else {
-		ret = dev->platform_data->gpio1_ctrl(sd, 1);
-		ret |= dev->platform_data->gpio0_ctrl(sd, 0);
-	}
-	return ret;
-}
-
-
-static int power_down(struct v4l2_subdev *sd);
-
-static int power_up(struct v4l2_subdev *sd)
-{
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	pr_info("%s S\n", __func__);
-	if (!dev->platform_data) {
-		dev_err(&client->dev,
-			"no camera_sensor_platform_data");
-		return -ENODEV;
-	}
-
-	/* power control */
-	ret = power_ctrl(sd, 1);
-	if (ret)
-		goto fail_power;
-
-	/* flis clock control */
-	ret = dev->platform_data->flisclk_ctrl(sd, 1);
-	if (ret)
-		goto fail_clk;
-
-	/* gpio ctrl */
-	ret = gpio_ctrl(sd, 1);
-	if (ret) {
-		ret = gpio_ctrl(sd, 1);
-		if (ret)
-			goto fail_gpio;
-	}
-
-	msleep(100);
-
-	pr_info("%s E\n", __func__);
-	return 0;
-
-fail_gpio:
-	dev->platform_data->flisclk_ctrl(sd, 0);
-fail_clk:
-	power_ctrl(sd, 0);
-fail_power:
-	dev_err(&client->dev, "sensor power-up failed\n");
-
-	return ret;
-}
-
-static int power_down(struct v4l2_subdev *sd)
-{
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	if (!dev->platform_data) {
-		dev_err(&client->dev,
-			"no camera_sensor_platform_data");
-		return -ENODEV;
-	}
-
-	/* gpio ctrl */
-	ret = gpio_ctrl(sd, 0);
-	if (ret) {
-		ret = gpio_ctrl(sd, 0);
-		if (ret)
-			dev_err(&client->dev, "gpio failed 2\n");
-	}
-
-	ret = dev->platform_data->flisclk_ctrl(sd, 0);
-	if (ret)
-		dev_err(&client->dev, "flisclk failed\n");
-
-	/* power control */
-	ret = power_ctrl(sd, 0);
-	if (ret)
-		dev_err(&client->dev, "vprog failed.\n");
-
-	return ret;
-}
-
-static int gc0310_s_power(struct v4l2_subdev *sd, int on)
-{
-	int ret;
-	if (on == 0)
-		return power_down(sd);
-	else {
-		ret = power_up(sd);
-		if (!ret)
-			return gc0310_init(sd);
-	}
-	return ret;
-}
-
-/*
- * distance - calculate the distance
- * @res: resolution
- * @w: width
- * @h: height
- *
- * Get the gap between resolution and w/h.
- * res->width/height smaller than w/h wouldn't be considered.
- * Returns the value of gap or -1 if fail.
- */
-#define LARGEST_ALLOWED_RATIO_MISMATCH 800
-static int distance(struct gc0310_resolution *res, u32 w, u32 h)
-{
-	unsigned int w_ratio = (res->width << 13) / w;
-	unsigned int h_ratio;
-	int match;
-
-	if (h == 0)
-		return -1;
-	h_ratio = (res->height << 13) / h;
-	if (h_ratio == 0)
-		return -1;
-	match   = abs(((w_ratio << 13) / h_ratio) - ((int)8192));
-
-	if ((w_ratio < (int)8192) || (h_ratio < (int)8192)  ||
-		(match > LARGEST_ALLOWED_RATIO_MISMATCH))
-		return -1;
-
-	return w_ratio + h_ratio;
-}
-
-/* Return the nearest higher resolution index */
-static int nearest_resolution_index(int w, int h)
-{
-	int i;
-	int idx = -1;
-	int dist;
-	int min_dist = INT_MAX;
-	struct gc0310_resolution *tmp_res = NULL;
-
-	for (i = 0; i < N_RES; i++) {
-		tmp_res = &gc0310_res[i];
-		dist = distance(tmp_res, w, h);
-		if (dist == -1)
-			continue;
-		if (dist < min_dist) {
-			min_dist = dist;
-			idx = i;
-		}
-	}
-
-	return idx;
-}
-
-static int get_resolution_index(int w, int h)
-{
-	int i;
-
-	for (i = 0; i < N_RES; i++) {
-		if (w != gc0310_res[i].width)
-			continue;
-		if (h != gc0310_res[i].height)
-			continue;
-
-		return i;
-	}
-
-	return -1;
-}
-
-
-/* TODO: remove it. */
-static int startup(struct v4l2_subdev *sd)
-{
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	pr_info("%s S\n", __func__);
-
-	ret = gc0310_write_reg_array(client, gc0310_res[dev->fmt_idx].regs);
-	if (ret) {
-		dev_err(&client->dev, "gc0310 write register err.\n");
-		return ret;
-	}
-
-	pr_info("%s E\n", __func__);
-	return ret;
-}
-
-static int gc0310_set_fmt(struct v4l2_subdev *sd,
-			  struct v4l2_subdev_pad_config *cfg,
-			  struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct camera_mipi_info *gc0310_info = NULL;
-	int ret = 0;
-	int idx = 0;
-	pr_info("%s S\n", __func__);
-
-	if (format->pad)
-		return -EINVAL;
-
-	if (!fmt)
-		return -EINVAL;
-
-	gc0310_info = v4l2_get_subdev_hostdata(sd);
-	if (!gc0310_info)
-		return -EINVAL;
-
-	mutex_lock(&dev->input_lock);
-
-	idx = nearest_resolution_index(fmt->width, fmt->height);
-	if (idx == -1) {
-		/* return the largest resolution */
-		fmt->width = gc0310_res[N_RES - 1].width;
-		fmt->height = gc0310_res[N_RES - 1].height;
-	} else {
-		fmt->width = gc0310_res[idx].width;
-		fmt->height = gc0310_res[idx].height;
-	}
-	fmt->code = MEDIA_BUS_FMT_SGRBG8_1X8;
-
-	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-		cfg->try_fmt = *fmt;
-		mutex_unlock(&dev->input_lock);
-		return 0;
-	}
-
-	dev->fmt_idx = get_resolution_index(fmt->width, fmt->height);
-	if (dev->fmt_idx == -1) {
-		dev_err(&client->dev, "get resolution fail\n");
-		mutex_unlock(&dev->input_lock);
-		return -EINVAL;
-	}
-
-	printk("%s: before gc0310_write_reg_array %s\n", __FUNCTION__,
-	       gc0310_res[dev->fmt_idx].desc);
-	ret = startup(sd);
-	if (ret) {
-		dev_err(&client->dev, "gc0310 startup err\n");
-		goto err;
-	}
-
-	ret = gc0310_get_intg_factor(client, gc0310_info,
-				     &gc0310_res[dev->fmt_idx]);
-	if (ret) {
-		dev_err(&client->dev, "failed to get integration_factor\n");
-		goto err;
-	}
-
-	pr_info("%s E\n", __func__);
-err:
-	mutex_unlock(&dev->input_lock);
-	return ret;
-}
-
-static int gc0310_get_fmt(struct v4l2_subdev *sd,
-			  struct v4l2_subdev_pad_config *cfg,
-			  struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-
-	if (format->pad)
-		return -EINVAL;
-
-	if (!fmt)
-		return -EINVAL;
-
-	fmt->width = gc0310_res[dev->fmt_idx].width;
-	fmt->height = gc0310_res[dev->fmt_idx].height;
-	fmt->code = MEDIA_BUS_FMT_SGRBG8_1X8;
-
-	return 0;
-}
-
-static int gc0310_detect(struct i2c_client *client)
-{
-	struct i2c_adapter *adapter = client->adapter;
-	u8 high, low;
-	int ret;
-	u16 id;
-
-	pr_info("%s S\n", __func__);
-	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
-		return -ENODEV;
-
-	ret = gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_SC_CMMN_CHIP_ID_H, &high);
-	if (ret) {
-		dev_err(&client->dev, "read sensor_id_high failed\n");
-		return -ENODEV;
-	}
-	ret = gc0310_read_reg(client, GC0310_8BIT,
-					GC0310_SC_CMMN_CHIP_ID_L, &low);
-	if (ret) {
-		dev_err(&client->dev, "read sensor_id_low failed\n");
-		return -ENODEV;
-	}
-	id = ((((u16) high) << 8) | (u16) low);
-	pr_info("sensor ID = 0x%x\n", id);
-
-	if (id != GC0310_ID) {
-		dev_err(&client->dev, "sensor ID error, read id = 0x%x, target id = 0x%x\n", id, GC0310_ID);
-		return -ENODEV;
-	}
-
-	dev_dbg(&client->dev, "detect gc0310 success\n");
-
-	pr_info("%s E\n", __func__);
-
-	return 0;
-}
-
-static int gc0310_s_stream(struct v4l2_subdev *sd, int enable)
-{
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	pr_info("%s S enable=%d\n", __func__, enable);
-	mutex_lock(&dev->input_lock);
-
-	if (enable) {
-		/* enable per frame MIPI and sensor ctrl reset  */
-		ret = gc0310_write_reg(client, GC0310_8BIT,
-						0xFE, 0x30);
-		if (ret) {
-			mutex_unlock(&dev->input_lock);
-			return ret;
-		}
-	}
-
-	ret = gc0310_write_reg(client, GC0310_8BIT,
-				GC0310_RESET_RELATED, GC0310_REGISTER_PAGE_3);
-	if (ret) {
-		mutex_unlock(&dev->input_lock);
-		return ret;
-	}
-
-	ret = gc0310_write_reg(client, GC0310_8BIT, GC0310_SW_STREAM,
-				enable ? GC0310_START_STREAMING :
-				GC0310_STOP_STREAMING);
-	if (ret) {
-		mutex_unlock(&dev->input_lock);
-		return ret;
-	}
-
-	ret = gc0310_write_reg(client, GC0310_8BIT,
-				GC0310_RESET_RELATED, GC0310_REGISTER_PAGE_0);
-	if (ret) {
-		mutex_unlock(&dev->input_lock);
-		return ret;
-	}
-
-	mutex_unlock(&dev->input_lock);
-	pr_info("%s E\n", __func__);
-	return ret;
-}
-
-
-static int gc0310_s_config(struct v4l2_subdev *sd,
-			   int irq, void *platform_data)
-{
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	pr_info("%s S\n", __func__);
-	if (!platform_data)
-		return -ENODEV;
-
-	dev->platform_data =
-		(struct camera_sensor_platform_data *)platform_data;
-
-	mutex_lock(&dev->input_lock);
-	/* power off the module, then power on it in future
-	 * as first power on by board may not fulfill the
-	 * power on sequqence needed by the module
-	 */
-	ret = power_down(sd);
-	if (ret) {
-		dev_err(&client->dev, "gc0310 power-off err.\n");
-		goto fail_power_off;
-	}
-
-	ret = power_up(sd);
-	if (ret) {
-		dev_err(&client->dev, "gc0310 power-up err.\n");
-		goto fail_power_on;
-	}
-
-	ret = dev->platform_data->csi_cfg(sd, 1);
-	if (ret)
-		goto fail_csi_cfg;
-
-	/* config & detect sensor */
-	ret = gc0310_detect(client);
-	if (ret) {
-		dev_err(&client->dev, "gc0310_detect err s_config.\n");
-		goto fail_csi_cfg;
-	}
-
-	/* turn off sensor, after probed */
-	ret = power_down(sd);
-	if (ret) {
-		dev_err(&client->dev, "gc0310 power-off err.\n");
-		goto fail_csi_cfg;
-	}
-	mutex_unlock(&dev->input_lock);
-
-	pr_info("%s E\n", __func__);
-	return 0;
-
-fail_csi_cfg:
-	dev->platform_data->csi_cfg(sd, 0);
-fail_power_on:
-	power_down(sd);
-	dev_err(&client->dev, "sensor power-gating failed\n");
-fail_power_off:
-	mutex_unlock(&dev->input_lock);
-	return ret;
-}
-
-static int gc0310_g_frame_interval(struct v4l2_subdev *sd,
-				   struct v4l2_subdev_frame_interval *interval)
-{
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-
-	interval->interval.numerator = 1;
-	interval->interval.denominator = gc0310_res[dev->fmt_idx].fps;
-
-	return 0;
-}
-
-static int gc0310_enum_mbus_code(struct v4l2_subdev *sd,
-				 struct v4l2_subdev_pad_config *cfg,
-				 struct v4l2_subdev_mbus_code_enum *code)
-{
-	if (code->index >= MAX_FMTS)
-		return -EINVAL;
-
-	code->code = MEDIA_BUS_FMT_SGRBG8_1X8;
-	return 0;
-}
-
-static int gc0310_enum_frame_size(struct v4l2_subdev *sd,
-				  struct v4l2_subdev_pad_config *cfg,
-				  struct v4l2_subdev_frame_size_enum *fse)
-{
-	int index = fse->index;
-
-	if (index >= N_RES)
-		return -EINVAL;
-
-	fse->min_width = gc0310_res[index].width;
-	fse->min_height = gc0310_res[index].height;
-	fse->max_width = gc0310_res[index].width;
-	fse->max_height = gc0310_res[index].height;
-
-	return 0;
-
-}
-
-
-static int gc0310_g_skip_frames(struct v4l2_subdev *sd, u32 *frames)
-{
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-
-	mutex_lock(&dev->input_lock);
-	*frames = gc0310_res[dev->fmt_idx].skip_frames;
-	mutex_unlock(&dev->input_lock);
-
-	return 0;
-}
-
-static const struct v4l2_subdev_sensor_ops gc0310_sensor_ops = {
-	.g_skip_frames	= gc0310_g_skip_frames,
-};
-
-static const struct v4l2_subdev_video_ops gc0310_video_ops = {
-	.s_stream = gc0310_s_stream,
-	.g_frame_interval = gc0310_g_frame_interval,
-};
-
-static const struct v4l2_subdev_core_ops gc0310_core_ops = {
-	.s_power = gc0310_s_power,
-	.ioctl = gc0310_ioctl,
-};
-
-static const struct v4l2_subdev_pad_ops gc0310_pad_ops = {
-	.enum_mbus_code = gc0310_enum_mbus_code,
-	.enum_frame_size = gc0310_enum_frame_size,
-	.get_fmt = gc0310_get_fmt,
-	.set_fmt = gc0310_set_fmt,
-};
-
-static const struct v4l2_subdev_ops gc0310_ops = {
-	.core = &gc0310_core_ops,
-	.video = &gc0310_video_ops,
-	.pad = &gc0310_pad_ops,
-	.sensor = &gc0310_sensor_ops,
-};
-
-static int gc0310_remove(struct i2c_client *client)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct gc0310_device *dev = to_gc0310_sensor(sd);
-	dev_dbg(&client->dev, "gc0310_remove...\n");
-
-	dev->platform_data->csi_cfg(sd, 0);
-
-	v4l2_device_unregister_subdev(sd);
-	media_entity_cleanup(&dev->sd.entity);
-	v4l2_ctrl_handler_free(&dev->ctrl_handler);
-	kfree(dev);
-
-	return 0;
-}
-
-static int gc0310_probe(struct i2c_client *client)
-{
-	struct gc0310_device *dev;
-	int ret;
-	void *pdata;
-	unsigned int i;
-
-	pr_info("%s S\n", __func__);
-	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (!dev)
-		return -ENOMEM;
-
-	mutex_init(&dev->input_lock);
-
-	dev->fmt_idx = 0;
-	v4l2_i2c_subdev_init(&(dev->sd), client, &gc0310_ops);
-
-	pdata = gmin_camera_platform_data(&dev->sd,
-					  ATOMISP_INPUT_FORMAT_RAW_8,
-					  atomisp_bayer_order_grbg);
-	if (!pdata) {
-		ret = -EINVAL;
-		goto out_free;
-	}
-
-	ret = gc0310_s_config(&dev->sd, client->irq, pdata);
-	if (ret)
-		goto out_free;
-
-	ret = atomisp_register_i2c_module(&dev->sd, pdata, RAW_CAMERA);
-	if (ret)
-		goto out_free;
-
-	dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	dev->pad.flags = MEDIA_PAD_FL_SOURCE;
-	dev->format.code = MEDIA_BUS_FMT_SGRBG8_1X8;
-	dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
-	ret =
-	    v4l2_ctrl_handler_init(&dev->ctrl_handler,
-				   ARRAY_SIZE(gc0310_controls));
-	if (ret) {
-		gc0310_remove(client);
-		return ret;
-	}
-
-	for (i = 0; i < ARRAY_SIZE(gc0310_controls); i++)
-		v4l2_ctrl_new_custom(&dev->ctrl_handler, &gc0310_controls[i],
-				     NULL);
-
-	if (dev->ctrl_handler.error) {
-		gc0310_remove(client);
-		return dev->ctrl_handler.error;
-	}
-
-	/* Use same lock for controls as for everything else. */
-	dev->ctrl_handler.lock = &dev->input_lock;
-	dev->sd.ctrl_handler = &dev->ctrl_handler;
-
-	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
-	if (ret)
-		gc0310_remove(client);
-
-	pr_info("%s E\n", __func__);
-	return ret;
-out_free:
-	v4l2_device_unregister_subdev(&dev->sd);
-	kfree(dev);
-	return ret;
-}
-
-static const struct acpi_device_id gc0310_acpi_match[] = {
-	{"XXGC0310"},
-	{"INT0310"},
-	{},
-};
-MODULE_DEVICE_TABLE(acpi, gc0310_acpi_match);
-
-static struct i2c_driver gc0310_driver = {
-	.driver = {
-		.name = "gc0310",
-		.acpi_match_table = gc0310_acpi_match,
-	},
-	.probe_new = gc0310_probe,
-	.remove = gc0310_remove,
-};
-module_i2c_driver(gc0310_driver);
-
-MODULE_AUTHOR("Lai, Angie <angie.lai@intel.com>");
-MODULE_DESCRIPTION("A low-level driver for GalaxyCore GC0310 sensors");
-MODULE_LICENSE("GPL");

+ 0 - 1124
drivers/staging/media/atomisp/i2c/atomisp-gc2235.c

@@ -1,1124 +0,0 @@
-/*
- * Support for GalaxyCore GC2235 2M camera sensor.
- *
- * Copyright (c) 2014 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/kmod.h>
-#include <linux/device.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/i2c.h>
-#include <linux/moduleparam.h>
-#include <media/v4l2-device.h>
-#include "../include/linux/atomisp_gmin_platform.h"
-#include <linux/acpi.h>
-#include <linux/io.h>
-
-#include "gc2235.h"
-
-/* i2c read/write stuff */
-static int gc2235_read_reg(struct i2c_client *client,
-			   u16 data_length, u16 reg, u16 *val)
-{
-	int err;
-	struct i2c_msg msg[2];
-	unsigned char data[6];
-
-	if (!client->adapter) {
-		dev_err(&client->dev, "%s error, no client->adapter\n",
-			__func__);
-		return -ENODEV;
-	}
-
-	if (data_length != GC2235_8BIT) {
-		dev_err(&client->dev, "%s error, invalid data length\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	memset(msg, 0, sizeof(msg));
-
-	msg[0].addr = client->addr;
-	msg[0].flags = 0;
-	msg[0].len = 1;
-	msg[0].buf = data;
-
-	/* high byte goes out first */
-	data[0] = (u8)(reg & 0xff);
-
-	msg[1].addr = client->addr;
-	msg[1].len = data_length;
-	msg[1].flags = I2C_M_RD;
-	msg[1].buf = data;
-
-	err = i2c_transfer(client->adapter, msg, 2);
-	if (err != 2) {
-		if (err >= 0)
-			err = -EIO;
-		dev_err(&client->dev,
-			"read from offset 0x%x error %d", reg, err);
-		return err;
-	}
-
-	*val = 0;
-	/* high byte comes first */
-	if (data_length == GC2235_8BIT)
-		*val = (u8)data[0];
-
-	return 0;
-}
-
-static int gc2235_i2c_write(struct i2c_client *client, u16 len, u8 *data)
-{
-	struct i2c_msg msg;
-	const int num_msg = 1;
-	int ret;
-
-	msg.addr = client->addr;
-	msg.flags = 0;
-	msg.len = len;
-	msg.buf = data;
-	ret = i2c_transfer(client->adapter, &msg, 1);
-
-	return ret == num_msg ? 0 : -EIO;
-}
-
-static int gc2235_write_reg(struct i2c_client *client, u16 data_length,
-							u8 reg, u8 val)
-{
-	int ret;
-	unsigned char data[4] = {0};
-	const u16 len = data_length + sizeof(u8); /* 16-bit address + data */
-
-	if (data_length != GC2235_8BIT) {
-		dev_err(&client->dev,
-			"%s error, invalid data_length\n", __func__);
-		return -EINVAL;
-	}
-
-	/* high byte goes out first */
-	data[0] = reg;
-	data[1] = val;
-
-	ret = gc2235_i2c_write(client, len, data);
-	if (ret)
-		dev_err(&client->dev,
-			"write error: wrote 0x%x to offset 0x%x error %d",
-			val, reg, ret);
-
-	return ret;
-}
-
-static int __gc2235_flush_reg_array(struct i2c_client *client,
-				    struct gc2235_write_ctrl *ctrl)
-{
-	u16 size;
-
-	if (ctrl->index == 0)
-		return 0;
-
-	size = sizeof(u8) + ctrl->index; /* 8-bit address + data */
-	ctrl->index = 0;
-
-	return gc2235_i2c_write(client, size, (u8 *)&ctrl->buffer);
-}
-
-static int __gc2235_buf_reg_array(struct i2c_client *client,
-				  struct gc2235_write_ctrl *ctrl,
-				  const struct gc2235_reg *next)
-{
-	int size;
-
-	if (next->type != GC2235_8BIT)
-		return -EINVAL;
-
-	size = 1;
-	ctrl->buffer.data[ctrl->index] = (u8)next->val;
-
-	/* When first item is added, we need to store its starting address */
-	if (ctrl->index == 0)
-		ctrl->buffer.addr = next->reg;
-
-	ctrl->index += size;
-
-	/*
-	 * Buffer cannot guarantee free space for u32? Better flush it to avoid
-	 * possible lack of memory for next item.
-	 */
-	if (ctrl->index + sizeof(u8) >= GC2235_MAX_WRITE_BUF_SIZE)
-		return __gc2235_flush_reg_array(client, ctrl);
-
-	return 0;
-}
-static int __gc2235_write_reg_is_consecutive(struct i2c_client *client,
-					     struct gc2235_write_ctrl *ctrl,
-					     const struct gc2235_reg *next)
-{
-	if (ctrl->index == 0)
-		return 1;
-
-	return ctrl->buffer.addr + ctrl->index == next->reg;
-}
-static int gc2235_write_reg_array(struct i2c_client *client,
-				  const struct gc2235_reg *reglist)
-{
-	const struct gc2235_reg *next = reglist;
-	struct gc2235_write_ctrl ctrl;
-	int err;
-
-	ctrl.index = 0;
-	for (; next->type != GC2235_TOK_TERM; next++) {
-		switch (next->type & GC2235_TOK_MASK) {
-		case GC2235_TOK_DELAY:
-			err = __gc2235_flush_reg_array(client, &ctrl);
-			if (err)
-				return err;
-			msleep(next->val);
-			break;
-		default:
-			/*
-			 * If next address is not consecutive, data needs to be
-			 * flushed before proceed.
-			 */
-			if (!__gc2235_write_reg_is_consecutive(client, &ctrl,
-								next)) {
-				err = __gc2235_flush_reg_array(client, &ctrl);
-				if (err)
-					return err;
-			}
-			err = __gc2235_buf_reg_array(client, &ctrl, next);
-			if (err) {
-				dev_err(&client->dev, "%s: write error, aborted\n",
-					 __func__);
-				return err;
-			}
-			break;
-		}
-	}
-
-	return __gc2235_flush_reg_array(client, &ctrl);
-}
-
-static int gc2235_g_focal(struct v4l2_subdev *sd, s32 *val)
-{
-	*val = (GC2235_FOCAL_LENGTH_NUM << 16) | GC2235_FOCAL_LENGTH_DEM;
-	return 0;
-}
-
-static int gc2235_g_fnumber(struct v4l2_subdev *sd, s32 *val)
-{
-	/*const f number for imx*/
-	*val = (GC2235_F_NUMBER_DEFAULT_NUM << 16) | GC2235_F_NUMBER_DEM;
-	return 0;
-}
-
-static int gc2235_g_fnumber_range(struct v4l2_subdev *sd, s32 *val)
-{
-	*val = (GC2235_F_NUMBER_DEFAULT_NUM << 24) |
-		(GC2235_F_NUMBER_DEM << 16) |
-		(GC2235_F_NUMBER_DEFAULT_NUM << 8) | GC2235_F_NUMBER_DEM;
-	return 0;
-}
-
-
-static int gc2235_get_intg_factor(struct i2c_client *client,
-				struct camera_mipi_info *info,
-				const struct gc2235_resolution *res)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-	struct atomisp_sensor_mode_data *buf = &info->data;
-	u16 reg_val, reg_val_h;
-	int ret;
-
-	if (!info)
-		return -EINVAL;
-
-	/* pixel clock calculattion */
-	buf->vt_pix_clk_freq_mhz = dev->vt_pix_clk_freq_mhz = 30000000;
-
-	/* get integration time */
-	buf->coarse_integration_time_min = GC2235_COARSE_INTG_TIME_MIN;
-	buf->coarse_integration_time_max_margin =
-					GC2235_COARSE_INTG_TIME_MAX_MARGIN;
-
-	buf->fine_integration_time_min = GC2235_FINE_INTG_TIME_MIN;
-	buf->fine_integration_time_max_margin =
-					GC2235_FINE_INTG_TIME_MAX_MARGIN;
-
-	buf->fine_integration_time_def = GC2235_FINE_INTG_TIME_MIN;
-	buf->frame_length_lines = res->lines_per_frame;
-	buf->line_length_pck = res->pixels_per_line;
-	buf->read_mode = res->bin_mode;
-
-	/* get the cropping and output resolution to ISP for this mode. */
-	ret =  gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_H_CROP_START_H, &reg_val_h);
-	ret =  gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_H_CROP_START_L, &reg_val);
-	if (ret)
-		return ret;
-
-	buf->crop_horizontal_start = (reg_val_h << 8) | reg_val;
-
-	ret =  gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_V_CROP_START_H, &reg_val_h);
-	ret =  gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_V_CROP_START_L, &reg_val);
-	if (ret)
-		return ret;
-
-	buf->crop_vertical_start = (reg_val_h << 8) | reg_val;
-
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_H_OUTSIZE_H, &reg_val_h);
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_H_OUTSIZE_L, &reg_val);
-	if (ret)
-		return ret;
-	buf->output_width = (reg_val_h << 8) | reg_val;
-
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_V_OUTSIZE_H, &reg_val_h);
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_V_OUTSIZE_L, &reg_val);
-	if (ret)
-		return ret;
-	buf->output_height = (reg_val_h << 8) | reg_val;
-
-	buf->crop_horizontal_end = buf->crop_horizontal_start +
-						buf->output_width - 1;
-	buf->crop_vertical_end = buf->crop_vertical_start +
-						buf->output_height - 1;
-
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_HB_H, &reg_val_h);
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_HB_L, &reg_val);
-	if (ret)
-		return ret;
-
-#if 0
-	u16 dummy = (reg_val_h << 8) | reg_val;
-#endif
-
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_SH_DELAY_H, &reg_val_h);
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_SH_DELAY_L, &reg_val);
-
-#if 0
-	buf->line_length_pck = buf->output_width + 16 + dummy +
-				(((u16)reg_val_h << 8) | (u16)reg_val) + 4;
-#endif
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_VB_H, &reg_val_h);
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_VB_L, &reg_val);
-	if (ret)
-		return ret;
-
-#if 0
-	buf->frame_length_lines = buf->output_height + 32 +
-				(((u16)reg_val_h << 8) | (u16)reg_val);
-#endif
-	buf->binning_factor_x = res->bin_factor_x ?
-					res->bin_factor_x : 1;
-	buf->binning_factor_y = res->bin_factor_y ?
-					res->bin_factor_y : 1;
-	return 0;
-}
-
-static long __gc2235_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
-				 int gain, int digitgain)
-
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	u16 coarse_integration = (u16)coarse_itg;
-	int ret = 0;
-	u16 expo_coarse_h, expo_coarse_l, gain_val = 0xF0, gain_val2 = 0xF0;
-	expo_coarse_h = coarse_integration >> 8;
-	expo_coarse_l = coarse_integration & 0xff;
-
-	ret = gc2235_write_reg(client, GC2235_8BIT,
-					GC2235_EXPOSURE_H, expo_coarse_h);
-	ret = gc2235_write_reg(client, GC2235_8BIT,
-					GC2235_EXPOSURE_L, expo_coarse_l);
-
-	if (gain <= 0x58) {
-		gain_val = 0x40;
-		gain_val2 = 0x58;
-	} else if (gain < 256) {
-		gain_val = 0x40;
-		gain_val2 = gain;
-	} else {
-		gain_val2 = 64 * gain / 256;
-		gain_val = 0xff;
-	}
-
-	ret = gc2235_write_reg(client, GC2235_8BIT,
-					GC2235_GLOBAL_GAIN, (u8)gain_val);
-	ret = gc2235_write_reg(client, GC2235_8BIT,
-					GC2235_PRE_GAIN, (u8)gain_val2);
-
-	return ret;
-}
-
-
-static int gc2235_set_exposure(struct v4l2_subdev *sd, int exposure,
-	int gain, int digitgain)
-{
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-	int ret;
-
-	mutex_lock(&dev->input_lock);
-	ret = __gc2235_set_exposure(sd, exposure, gain, digitgain);
-	mutex_unlock(&dev->input_lock);
-
-	return ret;
-}
-
-static long gc2235_s_exposure(struct v4l2_subdev *sd,
-			       struct atomisp_exposure *exposure)
-{
-	int exp = exposure->integration_time[0];
-	int gain = exposure->gain[0];
-	int digitgain = exposure->gain[1];
-
-	/* we should not accept the invalid value below. */
-	if (gain == 0) {
-		struct i2c_client *client = v4l2_get_subdevdata(sd);
-		v4l2_err(client, "%s: invalid value\n", __func__);
-		return -EINVAL;
-	}
-
-	return gc2235_set_exposure(sd, exp, gain, digitgain);
-}
-static long gc2235_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
-{
-	switch (cmd) {
-	case ATOMISP_IOC_S_EXPOSURE:
-		return gc2235_s_exposure(sd, arg);
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
-/* This returns the exposure time being used. This should only be used
- * for filling in EXIF data, not for actual image processing.
- */
-static int gc2235_q_exposure(struct v4l2_subdev *sd, s32 *value)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	u16 reg_v, reg_v2;
-	int ret;
-
-	/* get exposure */
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_EXPOSURE_L,
-					&reg_v);
-	if (ret)
-		goto err;
-
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_EXPOSURE_H,
-					&reg_v2);
-	if (ret)
-		goto err;
-
-	reg_v += reg_v2 << 8;
-
-	*value = reg_v;
-err:
-	return ret;
-}
-
-static int gc2235_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct gc2235_device *dev =
-	    container_of(ctrl->handler, struct gc2235_device, ctrl_handler);
-	int ret = 0;
-
-	switch (ctrl->id) {
-	case V4L2_CID_EXPOSURE_ABSOLUTE:
-		ret = gc2235_q_exposure(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FOCAL_ABSOLUTE:
-		ret = gc2235_g_focal(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FNUMBER_ABSOLUTE:
-		ret = gc2235_g_fnumber(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FNUMBER_RANGE:
-		ret = gc2235_g_fnumber_range(&dev->sd, &ctrl->val);
-		break;
-	default:
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static const struct v4l2_ctrl_ops ctrl_ops = {
-	.g_volatile_ctrl = gc2235_g_volatile_ctrl
-};
-
-static struct v4l2_ctrl_config gc2235_controls[] = {
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_EXPOSURE_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "exposure",
-	 .min = 0x0,
-	 .max = 0xffff,
-	 .step = 0x01,
-	 .def = 0x00,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FOCAL_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "focal length",
-	 .min = GC2235_FOCAL_LENGTH_DEFAULT,
-	 .max = GC2235_FOCAL_LENGTH_DEFAULT,
-	 .step = 0x01,
-	 .def = GC2235_FOCAL_LENGTH_DEFAULT,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FNUMBER_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "f-number",
-	 .min = GC2235_F_NUMBER_DEFAULT,
-	 .max = GC2235_F_NUMBER_DEFAULT,
-	 .step = 0x01,
-	 .def = GC2235_F_NUMBER_DEFAULT,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FNUMBER_RANGE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "f-number range",
-	 .min = GC2235_F_NUMBER_RANGE,
-	 .max = GC2235_F_NUMBER_RANGE,
-	 .step = 0x01,
-	 .def = GC2235_F_NUMBER_RANGE,
-	 .flags = 0,
-	 },
-};
-
-static int __gc2235_init(struct v4l2_subdev *sd)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-
-	/* restore settings */
-	gc2235_res = gc2235_res_preview;
-	N_RES = N_RES_PREVIEW;
-
-	return gc2235_write_reg_array(client, gc2235_init_settings);
-}
-
-static int is_init;
-
-static int power_ctrl(struct v4l2_subdev *sd, bool flag)
-{
-	int ret = -1;
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-
-	if (!dev || !dev->platform_data)
-		return -ENODEV;
-
-	if (flag) {
-		ret = dev->platform_data->v1p8_ctrl(sd, 1);
-		usleep_range(60, 90);
-		if (ret == 0)
-			ret |= dev->platform_data->v2p8_ctrl(sd, 1);
-	} else {
-		ret = dev->platform_data->v1p8_ctrl(sd, 0);
-		ret |= dev->platform_data->v2p8_ctrl(sd, 0);
-	}
-	return ret;
-}
-
-static int gpio_ctrl(struct v4l2_subdev *sd, bool flag)
-{
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-	int ret = -1;
-
-	if (!dev || !dev->platform_data)
-		return -ENODEV;
-
-	ret |= dev->platform_data->gpio1_ctrl(sd, !flag);
-	usleep_range(60, 90);
-	return dev->platform_data->gpio0_ctrl(sd, flag);
-}
-
-static int power_up(struct v4l2_subdev *sd)
-{
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	if (!dev->platform_data) {
-		dev_err(&client->dev,
-			"no camera_sensor_platform_data");
-		return -ENODEV;
-	}
-	/* power control */
-	ret = power_ctrl(sd, 1);
-	if (ret)
-		goto fail_power;
-
-	/* according to DS, at least 5ms is needed between DOVDD and PWDN */
-	usleep_range(5000, 6000);
-
-	ret = dev->platform_data->flisclk_ctrl(sd, 1);
-	if (ret)
-		goto fail_clk;
-	usleep_range(5000, 6000);
-
-	/* gpio ctrl */
-	ret = gpio_ctrl(sd, 1);
-	if (ret) {
-		ret = gpio_ctrl(sd, 1);
-		if (ret)
-			goto fail_power;
-	}
-
-	msleep(5);
-	return 0;
-
-fail_clk:
-	gpio_ctrl(sd, 0);
-fail_power:
-	power_ctrl(sd, 0);
-	dev_err(&client->dev, "sensor power-up failed\n");
-
-	return ret;
-}
-
-static int power_down(struct v4l2_subdev *sd)
-{
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	if (!dev->platform_data) {
-		dev_err(&client->dev,
-			"no camera_sensor_platform_data");
-		return -ENODEV;
-	}
-	/* gpio ctrl */
-	ret = gpio_ctrl(sd, 0);
-	if (ret) {
-		ret = gpio_ctrl(sd, 0);
-		if (ret)
-			dev_err(&client->dev, "gpio failed 2\n");
-	}
-
-	ret = dev->platform_data->flisclk_ctrl(sd, 0);
-	if (ret)
-		dev_err(&client->dev, "flisclk failed\n");
-
-	/* power control */
-	ret = power_ctrl(sd, 0);
-	if (ret)
-		dev_err(&client->dev, "vprog failed.\n");
-
-	return ret;
-}
-
-static int gc2235_s_power(struct v4l2_subdev *sd, int on)
-{
-	int ret;
-
-	if (on == 0)
-		ret = power_down(sd);
-	else {
-		ret = power_up(sd);
-		if (!ret)
-			ret = __gc2235_init(sd);
-		is_init = 1;
-	}
-	return ret;
-}
-
-/*
- * distance - calculate the distance
- * @res: resolution
- * @w: width
- * @h: height
- *
- * Get the gap between resolution and w/h.
- * res->width/height smaller than w/h wouldn't be considered.
- * Returns the value of gap or -1 if fail.
- */
-#define LARGEST_ALLOWED_RATIO_MISMATCH 800
-static int distance(struct gc2235_resolution *res, u32 w, u32 h)
-{
-	unsigned int w_ratio = (res->width << 13) / w;
-	unsigned int h_ratio;
-	int match;
-
-	if (h == 0)
-		return -1;
-	h_ratio = (res->height << 13) / h;
-	if (h_ratio == 0)
-		return -1;
-	match   = abs(((w_ratio << 13) / h_ratio) - 8192);
-
-	if ((w_ratio < 8192) || (h_ratio < 8192) ||
-	    (match > LARGEST_ALLOWED_RATIO_MISMATCH))
-		return -1;
-
-	return w_ratio + h_ratio;
-}
-
-/* Return the nearest higher resolution index */
-static int nearest_resolution_index(int w, int h)
-{
-	int i;
-	int idx = -1;
-	int dist;
-	int min_dist = INT_MAX;
-	struct gc2235_resolution *tmp_res = NULL;
-
-	for (i = 0; i < N_RES; i++) {
-		tmp_res = &gc2235_res[i];
-		dist = distance(tmp_res, w, h);
-		if (dist == -1)
-			continue;
-		if (dist < min_dist) {
-			min_dist = dist;
-			idx = i;
-		}
-	}
-
-	return idx;
-}
-
-static int get_resolution_index(int w, int h)
-{
-	int i;
-
-	for (i = 0; i < N_RES; i++) {
-		if (w != gc2235_res[i].width)
-			continue;
-		if (h != gc2235_res[i].height)
-			continue;
-
-		return i;
-	}
-
-	return -1;
-}
-
-static int startup(struct v4l2_subdev *sd)
-{
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-	if (is_init == 0) {
-		/* force gc2235 to do a reset in res change, otherwise it
-		* can not output normal after switching res. and it is not
-		* necessary for first time run up after power on, for the sack
-		* of performance
-		*/
-		power_down(sd);
-		power_up(sd);
-		gc2235_write_reg_array(client, gc2235_init_settings);
-	}
-
-	ret = gc2235_write_reg_array(client, gc2235_res[dev->fmt_idx].regs);
-	if (ret) {
-		dev_err(&client->dev, "gc2235 write register err.\n");
-		return ret;
-	}
-	is_init = 0;
-
-	return ret;
-}
-
-static int gc2235_set_fmt(struct v4l2_subdev *sd,
-			  struct v4l2_subdev_pad_config *cfg,
-			  struct v4l2_subdev_format *format)
-{
-
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct camera_mipi_info *gc2235_info = NULL;
-	int ret = 0;
-	int idx;
-
-	gc2235_info = v4l2_get_subdev_hostdata(sd);
-	if (!gc2235_info)
-		return -EINVAL;
-	if (format->pad)
-		return -EINVAL;
-	if (!fmt)
-		return -EINVAL;
-	mutex_lock(&dev->input_lock);
-	idx = nearest_resolution_index(fmt->width, fmt->height);
-	if (idx == -1) {
-		/* return the largest resolution */
-		fmt->width = gc2235_res[N_RES - 1].width;
-		fmt->height = gc2235_res[N_RES - 1].height;
-	} else {
-		fmt->width = gc2235_res[idx].width;
-		fmt->height = gc2235_res[idx].height;
-	}
-	fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
-	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-		cfg->try_fmt = *fmt;
-		mutex_unlock(&dev->input_lock);
-		return 0;
-	}
-
-	dev->fmt_idx = get_resolution_index(fmt->width, fmt->height);
-	if (dev->fmt_idx == -1) {
-		dev_err(&client->dev, "get resolution fail\n");
-		mutex_unlock(&dev->input_lock);
-		return -EINVAL;
-	}
-
-	ret = startup(sd);
-	if (ret) {
-		dev_err(&client->dev, "gc2235 startup err\n");
-		goto err;
-	}
-
-	ret = gc2235_get_intg_factor(client, gc2235_info,
-				     &gc2235_res[dev->fmt_idx]);
-	if (ret)
-		dev_err(&client->dev, "failed to get integration_factor\n");
-
-err:
-	mutex_unlock(&dev->input_lock);
-	return ret;
-}
-
-static int gc2235_get_fmt(struct v4l2_subdev *sd,
-			  struct v4l2_subdev_pad_config *cfg,
-			  struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-
-	if (format->pad)
-		return -EINVAL;
-
-	if (!fmt)
-		return -EINVAL;
-
-	fmt->width = gc2235_res[dev->fmt_idx].width;
-	fmt->height = gc2235_res[dev->fmt_idx].height;
-	fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
-
-	return 0;
-}
-
-static int gc2235_detect(struct i2c_client *client)
-{
-	struct i2c_adapter *adapter = client->adapter;
-	u16 high, low;
-	int ret;
-	u16 id;
-
-	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
-		return -ENODEV;
-
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_SENSOR_ID_H, &high);
-	if (ret) {
-		dev_err(&client->dev, "sensor_id_high = 0x%x\n", high);
-		return -ENODEV;
-	}
-	ret = gc2235_read_reg(client, GC2235_8BIT,
-					GC2235_SENSOR_ID_L, &low);
-	id = ((high << 8) | low);
-
-	if (id != GC2235_ID) {
-		dev_err(&client->dev, "sensor ID error, 0x%x\n", id);
-		return -ENODEV;
-	}
-
-	dev_info(&client->dev, "detect gc2235 success\n");
-	return 0;
-}
-
-static int gc2235_s_stream(struct v4l2_subdev *sd, int enable)
-{
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-	mutex_lock(&dev->input_lock);
-
-	if (enable)
-		ret = gc2235_write_reg_array(client, gc2235_stream_on);
-	else
-		ret = gc2235_write_reg_array(client, gc2235_stream_off);
-
-	mutex_unlock(&dev->input_lock);
-	return ret;
-}
-
-
-static int gc2235_s_config(struct v4l2_subdev *sd,
-			   int irq, void *platform_data)
-{
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	if (!platform_data)
-		return -ENODEV;
-
-	dev->platform_data =
-		(struct camera_sensor_platform_data *)platform_data;
-
-	mutex_lock(&dev->input_lock);
-	/* power off the module, then power on it in future
-	 * as first power on by board may not fulfill the
-	 * power on sequqence needed by the module
-	 */
-	ret = power_down(sd);
-	if (ret) {
-		dev_err(&client->dev, "gc2235 power-off err.\n");
-		goto fail_power_off;
-	}
-
-	ret = power_up(sd);
-	if (ret) {
-		dev_err(&client->dev, "gc2235 power-up err.\n");
-		goto fail_power_on;
-	}
-
-	ret = dev->platform_data->csi_cfg(sd, 1);
-	if (ret)
-		goto fail_csi_cfg;
-
-	/* config & detect sensor */
-	ret = gc2235_detect(client);
-	if (ret) {
-		dev_err(&client->dev, "gc2235_detect err s_config.\n");
-		goto fail_csi_cfg;
-	}
-
-	/* turn off sensor, after probed */
-	ret = power_down(sd);
-	if (ret) {
-		dev_err(&client->dev, "gc2235 power-off err.\n");
-		goto fail_csi_cfg;
-	}
-	mutex_unlock(&dev->input_lock);
-
-	return 0;
-
-fail_csi_cfg:
-	dev->platform_data->csi_cfg(sd, 0);
-fail_power_on:
-	power_down(sd);
-	dev_err(&client->dev, "sensor power-gating failed\n");
-fail_power_off:
-	mutex_unlock(&dev->input_lock);
-	return ret;
-}
-
-static int gc2235_g_frame_interval(struct v4l2_subdev *sd,
-				   struct v4l2_subdev_frame_interval *interval)
-{
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-
-	interval->interval.numerator = 1;
-	interval->interval.denominator = gc2235_res[dev->fmt_idx].fps;
-
-	return 0;
-}
-
-static int gc2235_enum_mbus_code(struct v4l2_subdev *sd,
-				struct v4l2_subdev_pad_config *cfg,
-				struct v4l2_subdev_mbus_code_enum *code)
-{
-	if (code->index >= MAX_FMTS)
-		return -EINVAL;
-
-	code->code = MEDIA_BUS_FMT_SBGGR10_1X10;
-	return 0;
-}
-
-static int gc2235_enum_frame_size(struct v4l2_subdev *sd,
-				  struct v4l2_subdev_pad_config *cfg,
-				  struct v4l2_subdev_frame_size_enum *fse)
-{
-	int index = fse->index;
-
-	if (index >= N_RES)
-		return -EINVAL;
-
-	fse->min_width = gc2235_res[index].width;
-	fse->min_height = gc2235_res[index].height;
-	fse->max_width = gc2235_res[index].width;
-	fse->max_height = gc2235_res[index].height;
-
-	return 0;
-
-}
-
-static int gc2235_g_skip_frames(struct v4l2_subdev *sd, u32 *frames)
-{
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-
-	mutex_lock(&dev->input_lock);
-	*frames = gc2235_res[dev->fmt_idx].skip_frames;
-	mutex_unlock(&dev->input_lock);
-
-	return 0;
-}
-
-static const struct v4l2_subdev_sensor_ops gc2235_sensor_ops = {
-	.g_skip_frames	= gc2235_g_skip_frames,
-};
-
-static const struct v4l2_subdev_video_ops gc2235_video_ops = {
-	.s_stream = gc2235_s_stream,
-	.g_frame_interval = gc2235_g_frame_interval,
-};
-
-static const struct v4l2_subdev_core_ops gc2235_core_ops = {
-	.s_power = gc2235_s_power,
-	.ioctl = gc2235_ioctl,
-};
-
-static const struct v4l2_subdev_pad_ops gc2235_pad_ops = {
-	.enum_mbus_code = gc2235_enum_mbus_code,
-	.enum_frame_size = gc2235_enum_frame_size,
-	.get_fmt = gc2235_get_fmt,
-	.set_fmt = gc2235_set_fmt,
-};
-
-static const struct v4l2_subdev_ops gc2235_ops = {
-	.core = &gc2235_core_ops,
-	.video = &gc2235_video_ops,
-	.pad = &gc2235_pad_ops,
-	.sensor = &gc2235_sensor_ops,
-};
-
-static int gc2235_remove(struct i2c_client *client)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct gc2235_device *dev = to_gc2235_sensor(sd);
-	dev_dbg(&client->dev, "gc2235_remove...\n");
-
-	dev->platform_data->csi_cfg(sd, 0);
-
-	v4l2_device_unregister_subdev(sd);
-	media_entity_cleanup(&dev->sd.entity);
-	v4l2_ctrl_handler_free(&dev->ctrl_handler);
-	kfree(dev);
-
-	return 0;
-}
-
-static int gc2235_probe(struct i2c_client *client)
-{
-	struct gc2235_device *dev;
-	void *gcpdev;
-	int ret;
-	unsigned int i;
-
-	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (!dev)
-		return -ENOMEM;
-
-	mutex_init(&dev->input_lock);
-
-	dev->fmt_idx = 0;
-	v4l2_i2c_subdev_init(&(dev->sd), client, &gc2235_ops);
-
-	gcpdev = gmin_camera_platform_data(&dev->sd,
-				   ATOMISP_INPUT_FORMAT_RAW_10,
-				   atomisp_bayer_order_grbg);
-
-	ret = gc2235_s_config(&dev->sd, client->irq, gcpdev);
-	if (ret)
-		goto out_free;
-
-	dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	dev->pad.flags = MEDIA_PAD_FL_SOURCE;
-	dev->format.code = MEDIA_BUS_FMT_SBGGR10_1X10;
-	dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
-	ret =
-	    v4l2_ctrl_handler_init(&dev->ctrl_handler,
-				   ARRAY_SIZE(gc2235_controls));
-	if (ret) {
-		gc2235_remove(client);
-		return ret;
-	}
-
-	for (i = 0; i < ARRAY_SIZE(gc2235_controls); i++)
-		v4l2_ctrl_new_custom(&dev->ctrl_handler, &gc2235_controls[i],
-				     NULL);
-
-	if (dev->ctrl_handler.error) {
-		gc2235_remove(client);
-		return dev->ctrl_handler.error;
-	}
-
-	/* Use same lock for controls as for everything else. */
-	dev->ctrl_handler.lock = &dev->input_lock;
-	dev->sd.ctrl_handler = &dev->ctrl_handler;
-
-	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
-	if (ret)
-		gc2235_remove(client);
-
-	return atomisp_register_i2c_module(&dev->sd, gcpdev, RAW_CAMERA);
-
-out_free:
-	v4l2_device_unregister_subdev(&dev->sd);
-	kfree(dev);
-
-	return ret;
-}
-
-static const struct acpi_device_id gc2235_acpi_match[] = {
-	{ "INT33F8" },
-	{},
-};
-MODULE_DEVICE_TABLE(acpi, gc2235_acpi_match);
-
-static struct i2c_driver gc2235_driver = {
-	.driver = {
-		.name = "gc2235",
-		.acpi_match_table = gc2235_acpi_match,
-	},
-	.probe_new = gc2235_probe,
-	.remove = gc2235_remove,
-};
-module_i2c_driver(gc2235_driver);
-
-MODULE_AUTHOR("Shuguang Gong <Shuguang.Gong@intel.com>");
-MODULE_DESCRIPTION("A low-level driver for GC2235 sensors");
-MODULE_LICENSE("GPL");

+ 0 - 205
drivers/staging/media/atomisp/i2c/atomisp-libmsrlisthelper.c

@@ -1,205 +0,0 @@
-/*
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- *
- */
-#include <linux/i2c.h>
-#include <linux/firmware.h>
-#include <linux/device.h>
-#include <linux/export.h>
-#include "../include/linux/libmsrlisthelper.h"
-#include <linux/module.h>
-#include <linux/slab.h>
-
-/* Tagged binary data container structure definitions. */
-struct tbd_header {
-	uint32_t tag;          /*!< Tag identifier, also checks endianness */
-	uint32_t size;         /*!< Container size including this header */
-	uint32_t version;      /*!< Version, format 0xYYMMDDVV */
-	uint32_t revision;     /*!< Revision, format 0xYYMMDDVV */
-	uint32_t config_bits;  /*!< Configuration flag bits set */
-	uint32_t checksum;     /*!< Global checksum, header included */
-} __packed;
-
-struct tbd_record_header {
-	uint32_t size;        /*!< Size of record including header */
-	uint8_t format_id;    /*!< tbd_format_t enumeration values used */
-	uint8_t packing_key;  /*!< Packing method; 0 = no packing */
-	uint16_t class_id;    /*!< tbd_class_t enumeration values used */
-} __packed;
-
-struct tbd_data_record_header {
-	uint16_t next_offset;
-	uint16_t flags;
-	uint16_t data_offset;
-	uint16_t data_size;
-} __packed;
-
-#define TBD_CLASS_DRV_ID 2
-
-static int set_msr_configuration(struct i2c_client *client, uint8_t *bufptr,
-		unsigned int size)
-{
-	/* The configuration data contains any number of sequences where
-	 * the first byte (that is, uint8_t) that marks the number of bytes
-	 * in the sequence to follow, is indeed followed by the indicated
-	 * number of bytes of actual data to be written to sensor.
-	 * By convention, the first two bytes of actual data should be
-	 * understood as an address in the sensor address space (hibyte
-	 * followed by lobyte) where the remaining data in the sequence
-	 * will be written. */
-
-	uint8_t *ptr = bufptr;
-	while (ptr < bufptr + size) {
-		struct i2c_msg msg = {
-			.addr = client->addr,
-			.flags = 0,
-		};
-		int ret;
-
-		/* How many bytes */
-		msg.len = *ptr++;
-		/* Where the bytes are located */
-		msg.buf = ptr;
-		ptr += msg.len;
-
-		if (ptr > bufptr + size)
-			/* Accessing data beyond bounds is not tolerated */
-			return -EINVAL;
-
-		ret = i2c_transfer(client->adapter, &msg, 1);
-		if (ret < 0) {
-			dev_err(&client->dev, "i2c write error: %d", ret);
-			return ret;
-		}
-	}
-	return 0;
-}
-
-static int parse_and_apply(struct i2c_client *client, uint8_t *buffer,
-		unsigned int size)
-{
-	uint8_t *endptr8 = buffer + size;
-	struct tbd_data_record_header *header =
-		(struct tbd_data_record_header *)buffer;
-
-	/* There may be any number of datasets present */
-	unsigned int dataset = 0;
-
-	do {
-		/* In below, four variables are read from buffer */
-		if ((uint8_t *)header + sizeof(*header) > endptr8)
-			return -EINVAL;
-
-		/* All data should be located within given buffer */
-		if ((uint8_t *)header + header->data_offset +
-				header->data_size > endptr8)
-			return -EINVAL;
-
-		/* We have a new valid dataset */
-		dataset++;
-		/* See whether there is MSR data */
-		/* If yes, update the reg info */
-		if (header->data_size && (header->flags & 1)) {
-			int ret;
-
-			dev_info(&client->dev,
-				"New MSR data for sensor driver (dataset %02d) size:%d\n",
-				dataset, header->data_size);
-			ret = set_msr_configuration(client,
-						buffer + header->data_offset,
-						header->data_size);
-			if (ret)
-				return ret;
-		}
-		header = (struct tbd_data_record_header *)(buffer +
-			header->next_offset);
-	} while (header->next_offset);
-
-	return 0;
-}
-
-int apply_msr_data(struct i2c_client *client, const struct firmware *fw)
-{
-	struct tbd_header *header;
-	struct tbd_record_header *record;
-
-	if (!fw) {
-		dev_warn(&client->dev, "Drv data is not loaded.\n");
-		return -EINVAL;
-	}
-
-	if (sizeof(*header) > fw->size)
-		return -EINVAL;
-
-	header = (struct tbd_header *)fw->data;
-	/* Check that we have drvb block. */
-	if (memcmp(&header->tag, "DRVB", 4))
-		return -EINVAL;
-
-	/* Check the size */
-	if (header->size != fw->size)
-		return -EINVAL;
-
-	if (sizeof(*header) + sizeof(*record) > fw->size)
-		return -EINVAL;
-
-	record = (struct tbd_record_header *)(header + 1);
-	/* Check that class id mathes tbd's drv id. */
-	if (record->class_id != TBD_CLASS_DRV_ID)
-		return -EINVAL;
-
-	/* Size 0 shall not be treated as an error */
-	if (!record->size)
-		return 0;
-
-	return parse_and_apply(client, (uint8_t *)(record + 1), record->size);
-}
-EXPORT_SYMBOL_GPL(apply_msr_data);
-
-int load_msr_list(struct i2c_client *client, char *name,
-		const struct firmware **fw)
-{
-	int ret = request_firmware(fw, name, &client->dev);
-	if (ret) {
-		dev_err(&client->dev,
-			"Error %d while requesting firmware %s\n",
-			ret, name);
-		return ret;
-	}
-	dev_info(&client->dev, "Received %lu bytes drv data\n",
-			(unsigned long)(*fw)->size);
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(load_msr_list);
-
-void release_msr_list(struct i2c_client *client, const struct firmware *fw)
-{
-	release_firmware(fw);
-}
-EXPORT_SYMBOL_GPL(release_msr_list);
-
-static int init_msrlisthelper(void)
-{
-	return 0;
-}
-
-static void exit_msrlisthelper(void)
-{
-}
-
-module_init(init_msrlisthelper);
-module_exit(exit_msrlisthelper);
-
-MODULE_AUTHOR("Jukka Kaartinen <jukka.o.kaartinen@intel.com>");
-MODULE_LICENSE("GPL");

+ 0 - 968
drivers/staging/media/atomisp/i2c/atomisp-lm3554.c

@@ -1,968 +0,0 @@
-/*
- * LED flash driver for LM3554
- *
- * Copyright (c) 2010-2012 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- *
- */
-#include <linux/module.h>
-#include <linux/i2c.h>
-#include <linux/mutex.h>
-#include <linux/delay.h>
-#include <linux/gpio.h>
-#include <linux/slab.h>
-
-#include "../include/media/lm3554.h"
-#include <media/v4l2-ctrls.h>
-#include <media/v4l2-device.h>
-#include <linux/acpi.h>
-#include <linux/gpio/consumer.h>
-#include "../include/linux/atomisp_gmin_platform.h"
-#include "../include/linux/atomisp.h"
-
-/* Registers */
-
-#define LM3554_TORCH_BRIGHTNESS_REG	0xA0
-#define LM3554_TORCH_MODE_SHIFT		0
-#define LM3554_TORCH_CURRENT_SHIFT	3
-#define LM3554_INDICATOR_CURRENT_SHIFT	6
-
-#define LM3554_FLASH_BRIGHTNESS_REG	0xB0
-#define LM3554_FLASH_MODE_SHIFT		0
-#define LM3554_FLASH_CURRENT_SHIFT	3
-#define LM3554_STROBE_SENSITIVITY_SHIFT	7
-
-#define LM3554_FLASH_DURATION_REG	0xC0
-#define LM3554_FLASH_TIMEOUT_SHIFT	0
-#define LM3554_CURRENT_LIMIT_SHIFT	5
-
-#define LM3554_FLAGS_REG		0xD0
-#define LM3554_FLAG_TIMEOUT		(1 << 0)
-#define LM3554_FLAG_THERMAL_SHUTDOWN	(1 << 1)
-#define LM3554_FLAG_LED_FAULT		(1 << 2)
-#define LM3554_FLAG_TX1_INTERRUPT	(1 << 3)
-#define LM3554_FLAG_TX2_INTERRUPT	(1 << 4)
-#define LM3554_FLAG_LED_THERMAL_FAULT	(1 << 5)
-#define LM3554_FLAG_UNUSED		(1 << 6)
-#define LM3554_FLAG_INPUT_VOLTAGE_LOW	(1 << 7)
-
-#define LM3554_CONFIG_REG_1		0xE0
-#define LM3554_ENVM_TX2_SHIFT		5
-#define LM3554_TX2_POLARITY_SHIFT	6
-
-struct lm3554 {
-	struct v4l2_subdev sd;
-
-	struct mutex power_lock;
-	struct v4l2_ctrl_handler ctrl_handler;
-	int power_count;
-
-	unsigned int mode;
-	int timeout;
-	u8 torch_current;
-	u8 indicator_current;
-	u8 flash_current;
-
-	struct timer_list flash_off_delay;
-	struct lm3554_platform_data *pdata;
-};
-
-#define to_lm3554(p_sd)	container_of(p_sd, struct lm3554, sd)
-
-/* Return negative errno else zero on success */
-static int lm3554_write(struct lm3554 *flash, u8 addr, u8 val)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(&flash->sd);
-	int ret;
-
-	ret = i2c_smbus_write_byte_data(client, addr, val);
-
-	dev_dbg(&client->dev, "Write Addr:%02X Val:%02X %s\n", addr, val,
-		ret < 0 ? "fail" : "ok");
-
-	return ret;
-}
-
-/* Return negative errno else a data byte received from the device. */
-static int lm3554_read(struct lm3554 *flash, u8 addr)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(&flash->sd);
-	int ret;
-
-	ret = i2c_smbus_read_byte_data(client, addr);
-
-	dev_dbg(&client->dev, "Read Addr:%02X Val:%02X %s\n", addr, ret,
-		ret < 0 ? "fail" : "ok");
-
-	return ret;
-}
-
-/* -----------------------------------------------------------------------------
- * Hardware configuration
- */
-
-static int lm3554_set_mode(struct lm3554 *flash, unsigned int mode)
-{
-	u8 val;
-	int ret;
-
-	val = (mode << LM3554_FLASH_MODE_SHIFT) |
-	      (flash->flash_current << LM3554_FLASH_CURRENT_SHIFT);
-
-	ret = lm3554_write(flash, LM3554_FLASH_BRIGHTNESS_REG, val);
-	if (ret == 0)
-		flash->mode = mode;
-	return ret;
-}
-
-static int lm3554_set_torch(struct lm3554 *flash)
-{
-	u8 val;
-
-	val = (flash->mode << LM3554_TORCH_MODE_SHIFT) |
-	      (flash->torch_current << LM3554_TORCH_CURRENT_SHIFT) |
-	      (flash->indicator_current << LM3554_INDICATOR_CURRENT_SHIFT);
-
-	return lm3554_write(flash, LM3554_TORCH_BRIGHTNESS_REG, val);
-}
-
-static int lm3554_set_flash(struct lm3554 *flash)
-{
-	u8 val;
-
-	val = (flash->mode << LM3554_FLASH_MODE_SHIFT) |
-	      (flash->flash_current << LM3554_FLASH_CURRENT_SHIFT);
-
-	return lm3554_write(flash, LM3554_FLASH_BRIGHTNESS_REG, val);
-}
-
-static int lm3554_set_duration(struct lm3554 *flash)
-{
-	u8 val;
-
-	val = (flash->timeout << LM3554_FLASH_TIMEOUT_SHIFT) |
-	      (flash->pdata->current_limit << LM3554_CURRENT_LIMIT_SHIFT);
-
-	return lm3554_write(flash, LM3554_FLASH_DURATION_REG, val);
-}
-
-static int lm3554_set_config1(struct lm3554 *flash)
-{
-	u8 val;
-
-	val = (flash->pdata->envm_tx2 << LM3554_ENVM_TX2_SHIFT) |
-	      (flash->pdata->tx2_polarity << LM3554_TX2_POLARITY_SHIFT);
-	return lm3554_write(flash, LM3554_CONFIG_REG_1, val);
-}
-
-/* -----------------------------------------------------------------------------
- * Hardware trigger
- */
-static void lm3554_flash_off_delay(struct timer_list *t)
-{
-	struct lm3554 *flash = from_timer(flash, t, flash_off_delay);
-	struct lm3554_platform_data *pdata = flash->pdata;
-
-	gpio_set_value(pdata->gpio_strobe, 0);
-}
-
-static int lm3554_hw_strobe(struct i2c_client *client, bool strobe)
-{
-	int ret, timer_pending;
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct lm3554 *flash = to_lm3554(sd);
-	struct lm3554_platform_data *pdata = flash->pdata;
-
-	/*
-	 * An abnormal high flash current is observed when strobe off the
-	 * flash. Workaround here is firstly set flash current to lower level,
-	 * wait a short moment, and then strobe off the flash.
-	 */
-
-	timer_pending = del_timer_sync(&flash->flash_off_delay);
-
-	/* Flash off */
-	if (!strobe) {
-		/* set current to 70mA and wait a while */
-		ret = lm3554_write(flash, LM3554_FLASH_BRIGHTNESS_REG, 0);
-		if (ret < 0)
-			goto err;
-		mod_timer(&flash->flash_off_delay,
-			  jiffies + msecs_to_jiffies(LM3554_TIMER_DELAY));
-		return 0;
-	}
-
-	/* Flash on */
-
-	/*
-	 * If timer is killed before run, flash is not strobe off,
-	 * so must strobe off here
-	 */
-	if (timer_pending)
-		gpio_set_value(pdata->gpio_strobe, 0);
-
-	/* Restore flash current settings */
-	ret = lm3554_set_flash(flash);
-	if (ret < 0)
-		goto err;
-
-	/* Strobe on Flash */
-	gpio_set_value(pdata->gpio_strobe, 1);
-
-	return 0;
-err:
-	dev_err(&client->dev, "failed to %s flash strobe (%d)\n",
-		strobe ? "on" : "off", ret);
-	return ret;
-}
-
-/* -----------------------------------------------------------------------------
- * V4L2 controls
- */
-
-static int lm3554_read_status(struct lm3554 *flash)
-{
-	int ret;
-	struct i2c_client *client = v4l2_get_subdevdata(&flash->sd);
-
-	/* NOTE: reading register clear fault status */
-	ret = lm3554_read(flash, LM3554_FLAGS_REG);
-	if (ret < 0)
-		return ret;
-
-	/*
-	 * Accordingly to datasheet we read back '1' in bit 6.
-	 * Clear it first.
-	 */
-	ret &= ~LM3554_FLAG_UNUSED;
-
-	/*
-	 * Do not take TX1/TX2 signal as an error
-	 * because MSIC will not turn off flash, but turn to
-	 * torch mode according to gsm modem signal by hardware.
-	 */
-	ret &= ~(LM3554_FLAG_TX1_INTERRUPT | LM3554_FLAG_TX2_INTERRUPT);
-
-	if (ret > 0)
-		dev_dbg(&client->dev, "LM3554 flag status: %02x\n", ret);
-
-	return ret;
-}
-
-static int lm3554_s_flash_timeout(struct v4l2_subdev *sd, u32 val)
-{
-	struct lm3554 *flash = to_lm3554(sd);
-
-	val = clamp(val, LM3554_MIN_TIMEOUT, LM3554_MAX_TIMEOUT);
-	val = val / LM3554_TIMEOUT_STEPSIZE - 1;
-
-	flash->timeout = val;
-
-	return lm3554_set_duration(flash);
-}
-
-static int lm3554_g_flash_timeout(struct v4l2_subdev *sd, s32 *val)
-{
-	struct lm3554 *flash = to_lm3554(sd);
-
-	*val = (u32)(flash->timeout + 1) * LM3554_TIMEOUT_STEPSIZE;
-
-	return 0;
-}
-
-static int lm3554_s_flash_intensity(struct v4l2_subdev *sd, u32 intensity)
-{
-	struct lm3554 *flash = to_lm3554(sd);
-
-	intensity = LM3554_CLAMP_PERCENTAGE(intensity);
-	intensity = LM3554_PERCENT_TO_VALUE(intensity, LM3554_FLASH_STEP);
-
-	flash->flash_current = intensity;
-
-	return lm3554_set_flash(flash);
-}
-
-static int lm3554_g_flash_intensity(struct v4l2_subdev *sd, s32 *val)
-{
-	struct lm3554 *flash = to_lm3554(sd);
-
-	*val = LM3554_VALUE_TO_PERCENT((u32)flash->flash_current,
-			LM3554_FLASH_STEP);
-
-	return 0;
-}
-
-static int lm3554_s_torch_intensity(struct v4l2_subdev *sd, u32 intensity)
-{
-	struct lm3554 *flash = to_lm3554(sd);
-
-	intensity = LM3554_CLAMP_PERCENTAGE(intensity);
-	intensity = LM3554_PERCENT_TO_VALUE(intensity, LM3554_TORCH_STEP);
-
-	flash->torch_current = intensity;
-
-	return lm3554_set_torch(flash);
-}
-
-static int lm3554_g_torch_intensity(struct v4l2_subdev *sd, s32 *val)
-{
-	struct lm3554 *flash = to_lm3554(sd);
-
-	*val = LM3554_VALUE_TO_PERCENT((u32)flash->torch_current,
-			LM3554_TORCH_STEP);
-
-	return 0;
-}
-
-static int lm3554_s_indicator_intensity(struct v4l2_subdev *sd, u32 intensity)
-{
-	struct lm3554 *flash = to_lm3554(sd);
-
-	intensity = LM3554_CLAMP_PERCENTAGE(intensity);
-	intensity = LM3554_PERCENT_TO_VALUE(intensity, LM3554_INDICATOR_STEP);
-
-	flash->indicator_current = intensity;
-
-	return lm3554_set_torch(flash);
-}
-
-static int lm3554_g_indicator_intensity(struct v4l2_subdev *sd, s32 *val)
-{
-	struct lm3554 *flash = to_lm3554(sd);
-
-	*val = LM3554_VALUE_TO_PERCENT((u32)flash->indicator_current,
-			LM3554_INDICATOR_STEP);
-
-	return 0;
-}
-
-static int lm3554_s_flash_strobe(struct v4l2_subdev *sd, u32 val)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-
-	return lm3554_hw_strobe(client, val);
-}
-
-static int lm3554_s_flash_mode(struct v4l2_subdev *sd, u32 new_mode)
-{
-	struct lm3554 *flash = to_lm3554(sd);
-	unsigned int mode;
-
-	switch (new_mode) {
-	case ATOMISP_FLASH_MODE_OFF:
-		mode = LM3554_MODE_SHUTDOWN;
-		break;
-	case ATOMISP_FLASH_MODE_FLASH:
-		mode = LM3554_MODE_FLASH;
-		break;
-	case ATOMISP_FLASH_MODE_INDICATOR:
-		mode = LM3554_MODE_INDICATOR;
-		break;
-	case ATOMISP_FLASH_MODE_TORCH:
-		mode = LM3554_MODE_TORCH;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	return lm3554_set_mode(flash, mode);
-}
-
-static int lm3554_g_flash_mode(struct v4l2_subdev *sd, s32 *val)
-{
-	struct lm3554 *flash = to_lm3554(sd);
-	*val = flash->mode;
-	return 0;
-}
-
-static int lm3554_g_flash_status(struct v4l2_subdev *sd, s32 *val)
-{
-	struct lm3554 *flash = to_lm3554(sd);
-	int value;
-
-	value = lm3554_read_status(flash);
-	if (value < 0)
-		return value;
-
-	if (value & LM3554_FLAG_TIMEOUT)
-		*val = ATOMISP_FLASH_STATUS_TIMEOUT;
-	else if (value > 0)
-		*val = ATOMISP_FLASH_STATUS_HW_ERROR;
-	else
-		*val = ATOMISP_FLASH_STATUS_OK;
-
-	return 0;
-}
-
-#ifndef CSS15
-static int lm3554_g_flash_status_register(struct v4l2_subdev *sd, s32 *val)
-{
-	struct lm3554 *flash = to_lm3554(sd);
-	int ret;
-
-	ret = lm3554_read(flash, LM3554_FLAGS_REG);
-
-	if (ret < 0)
-		return ret;
-
-	*val = ret;
-	return 0;
-}
-#endif
-
-static int lm3554_s_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct lm3554 *dev =
-	    container_of(ctrl->handler, struct lm3554, ctrl_handler);
-	int ret = 0;
-
-	switch (ctrl->id) {
-	case V4L2_CID_FLASH_TIMEOUT:
-		ret = lm3554_s_flash_timeout(&dev->sd, ctrl->val);
-		break;
-	case V4L2_CID_FLASH_INTENSITY:
-		ret = lm3554_s_flash_intensity(&dev->sd, ctrl->val);
-		break;
-	case V4L2_CID_FLASH_TORCH_INTENSITY:
-		ret = lm3554_s_torch_intensity(&dev->sd, ctrl->val);
-		break;
-	case V4L2_CID_FLASH_INDICATOR_INTENSITY:
-		ret = lm3554_s_indicator_intensity(&dev->sd, ctrl->val);
-		break;
-	case V4L2_CID_FLASH_STROBE:
-		ret = lm3554_s_flash_strobe(&dev->sd, ctrl->val);
-		break;
-	case V4L2_CID_FLASH_MODE:
-		ret = lm3554_s_flash_mode(&dev->sd, ctrl->val);
-		break;
-	default:
-		ret = -EINVAL;
-	}
-	return ret;
-}
-
-static int lm3554_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct lm3554 *dev =
-	    container_of(ctrl->handler, struct lm3554, ctrl_handler);
-	int ret = 0;
-
-	switch (ctrl->id) {
-	case V4L2_CID_FLASH_TIMEOUT:
-		ret = lm3554_g_flash_timeout(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FLASH_INTENSITY:
-		ret = lm3554_g_flash_intensity(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FLASH_TORCH_INTENSITY:
-		ret = lm3554_g_torch_intensity(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FLASH_INDICATOR_INTENSITY:
-		ret = lm3554_g_indicator_intensity(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FLASH_MODE:
-		ret = lm3554_g_flash_mode(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FLASH_STATUS:
-		ret = lm3554_g_flash_status(&dev->sd, &ctrl->val);
-		break;
-#ifndef CSS15
-	case V4L2_CID_FLASH_STATUS_REGISTER:
-		ret = lm3554_g_flash_status_register(&dev->sd, &ctrl->val);
-		break;
-#endif
-	default:
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static const struct v4l2_ctrl_ops ctrl_ops = {
-	.s_ctrl = lm3554_s_ctrl,
-	.g_volatile_ctrl = lm3554_g_volatile_ctrl
-};
-
-static const struct v4l2_ctrl_config lm3554_controls[] = {
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FLASH_TIMEOUT,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "Flash Timeout",
-	 .min = 0x0,
-	 .max = LM3554_MAX_TIMEOUT,
-	 .step = 0x01,
-	 .def = LM3554_DEFAULT_TIMEOUT,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FLASH_INTENSITY,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "Flash Intensity",
-	 .min = LM3554_MIN_PERCENT,
-	 .max = LM3554_MAX_PERCENT,
-	 .step = 0x01,
-	 .def = LM3554_FLASH_DEFAULT_BRIGHTNESS,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FLASH_TORCH_INTENSITY,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "Torch Intensity",
-	 .min = LM3554_MIN_PERCENT,
-	 .max = LM3554_MAX_PERCENT,
-	 .step = 0x01,
-	 .def = LM3554_TORCH_DEFAULT_BRIGHTNESS,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FLASH_INDICATOR_INTENSITY,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "Indicator Intensity",
-	 .min = LM3554_MIN_PERCENT,
-	 .max = LM3554_MAX_PERCENT,
-	 .step = 0x01,
-	 .def = LM3554_INDICATOR_DEFAULT_BRIGHTNESS,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FLASH_STROBE,
-	 .type = V4L2_CTRL_TYPE_BOOLEAN,
-	 .name = "Flash Strobe",
-	 .min = 0,
-	 .max = 1,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FLASH_MODE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "Flash Mode",
-	 .min = 0,
-	 .max = 100,
-	 .step = 1,
-	 .def = ATOMISP_FLASH_MODE_OFF,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FLASH_STATUS,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "Flash Status",
-	 .min = ATOMISP_FLASH_STATUS_OK,
-	 .max = ATOMISP_FLASH_STATUS_TIMEOUT,
-	 .step = 1,
-	 .def = ATOMISP_FLASH_STATUS_OK,
-	 .flags = 0,
-	 },
-#ifndef CSS15
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FLASH_STATUS_REGISTER,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "Flash Status Register",
-	 .min = 0,
-	 .max = 255,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-#endif
-};
-
-/* -----------------------------------------------------------------------------
- * V4L2 subdev core operations
- */
-
-/* Put device into known state. */
-static int lm3554_setup(struct lm3554 *flash)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(&flash->sd);
-	int ret;
-
-	/* clear the flags register */
-	ret = lm3554_read(flash, LM3554_FLAGS_REG);
-	if (ret < 0)
-		return ret;
-
-	dev_dbg(&client->dev, "Fault info: %02x\n", ret);
-
-	ret = lm3554_set_config1(flash);
-	if (ret < 0)
-		return ret;
-
-	ret = lm3554_set_duration(flash);
-	if (ret < 0)
-		return ret;
-
-	ret = lm3554_set_torch(flash);
-	if (ret < 0)
-		return ret;
-
-	ret = lm3554_set_flash(flash);
-	if (ret < 0)
-		return ret;
-
-	/* read status */
-	ret = lm3554_read_status(flash);
-	if (ret < 0)
-		return ret;
-
-	return ret ? -EIO : 0;
-}
-
-static int __lm3554_s_power(struct lm3554 *flash, int power)
-{
-	struct lm3554_platform_data *pdata = flash->pdata;
-	int ret;
-
-	/*initialize flash driver*/
-	gpio_set_value(pdata->gpio_reset, power);
-	usleep_range(100, 100 + 1);
-
-	if (power) {
-		/* Setup default values. This makes sure that the chip
-		 * is in a known state.
-		 */
-		ret = lm3554_setup(flash);
-		if (ret < 0) {
-			__lm3554_s_power(flash, 0);
-			return ret;
-		}
-	}
-
-	return 0;
-}
-
-static int lm3554_s_power(struct v4l2_subdev *sd, int power)
-{
-	struct lm3554 *flash = to_lm3554(sd);
-	int ret = 0;
-
-	mutex_lock(&flash->power_lock);
-
-	if (flash->power_count == !power) {
-		ret = __lm3554_s_power(flash, !!power);
-		if (ret < 0)
-			goto done;
-	}
-
-	flash->power_count += power ? 1 : -1;
-	WARN_ON(flash->power_count < 0);
-
-done:
-	mutex_unlock(&flash->power_lock);
-	return ret;
-}
-
-static const struct v4l2_subdev_core_ops lm3554_core_ops = {
-	.s_power = lm3554_s_power,
-};
-
-static const struct v4l2_subdev_ops lm3554_ops = {
-	.core = &lm3554_core_ops,
-};
-
-static int lm3554_detect(struct v4l2_subdev *sd)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct i2c_adapter *adapter = client->adapter;
-	struct lm3554 *flash = to_lm3554(sd);
-	int ret;
-
-	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
-		dev_err(&client->dev, "lm3554_detect i2c error\n");
-		return -ENODEV;
-	}
-
-	/* Power up the flash driver and reset it */
-	ret = lm3554_s_power(&flash->sd, 1);
-	if (ret < 0) {
-		dev_err(&client->dev, "Failed to power on lm3554 LED flash\n");
-	} else {
-		dev_dbg(&client->dev, "Successfully detected lm3554 LED flash\n");
-		lm3554_s_power(&flash->sd, 0);
-	}
-
-	return ret;
-}
-
-static int lm3554_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-{
-	return lm3554_s_power(sd, 1);
-}
-
-static int lm3554_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-{
-	return lm3554_s_power(sd, 0);
-}
-
-static const struct v4l2_subdev_internal_ops lm3554_internal_ops = {
-	.registered = lm3554_detect,
-	.open = lm3554_open,
-	.close = lm3554_close,
-};
-
-/* -----------------------------------------------------------------------------
- *  I2C driver
- */
-#ifdef CONFIG_PM
-
-static int lm3554_suspend(struct device *dev)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
-	struct lm3554 *flash = to_lm3554(subdev);
-	int rval;
-
-	if (flash->power_count == 0)
-		return 0;
-
-	rval = __lm3554_s_power(flash, 0);
-
-	dev_dbg(&client->dev, "Suspend %s\n", rval < 0 ? "failed" : "ok");
-
-	return rval;
-}
-
-static int lm3554_resume(struct device *dev)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	struct v4l2_subdev *subdev = i2c_get_clientdata(client);
-	struct lm3554 *flash = to_lm3554(subdev);
-	int rval;
-
-	if (flash->power_count == 0)
-		return 0;
-
-	rval = __lm3554_s_power(flash, 1);
-
-	dev_dbg(&client->dev, "Resume %s\n", rval < 0 ? "fail" : "ok");
-
-	return rval;
-}
-
-#else
-
-#define lm3554_suspend NULL
-#define lm3554_resume  NULL
-
-#endif /* CONFIG_PM */
-
-static int lm3554_gpio_init(struct i2c_client *client)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct lm3554 *flash = to_lm3554(sd);
-	struct lm3554_platform_data *pdata = flash->pdata;
-	int ret;
-
-	if (!gpio_is_valid(pdata->gpio_reset))
-		return -EINVAL;
-
-	ret = gpio_direction_output(pdata->gpio_reset, 0);
-	if (ret < 0)
-		goto err_gpio_reset;
-	dev_info(&client->dev, "flash led reset successfully\n");
-
-	if (!gpio_is_valid(pdata->gpio_strobe)) {
-		ret = -EINVAL;
-		goto err_gpio_dir_reset;
-	}
-
-	ret = gpio_direction_output(pdata->gpio_strobe, 0);
-	if (ret < 0)
-		goto err_gpio_strobe;
-
-	return 0;
-
-err_gpio_strobe:
-	gpio_free(pdata->gpio_strobe);
-err_gpio_dir_reset:
-	gpio_direction_output(pdata->gpio_reset, 0);
-err_gpio_reset:
-	gpio_free(pdata->gpio_reset);
-
-	return ret;
-}
-
-static int lm3554_gpio_uninit(struct i2c_client *client)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct lm3554 *flash = to_lm3554(sd);
-	struct lm3554_platform_data *pdata = flash->pdata;
-	int ret;
-
-	ret = gpio_direction_output(pdata->gpio_strobe, 0);
-	if (ret < 0)
-		return ret;
-
-	ret = gpio_direction_output(pdata->gpio_reset, 0);
-	if (ret < 0)
-		return ret;
-
-	gpio_free(pdata->gpio_strobe);
-	gpio_free(pdata->gpio_reset);
-	return 0;
-}
-
-static void *lm3554_platform_data_func(struct i2c_client *client)
-{
-	static struct lm3554_platform_data platform_data;
-
-	platform_data.gpio_reset =
-		    desc_to_gpio(gpiod_get_index(&client->dev,
-						 NULL, 2, GPIOD_OUT_LOW));
-	platform_data.gpio_strobe =
-		    desc_to_gpio(gpiod_get_index(&client->dev,
-						 NULL, 0, GPIOD_OUT_LOW));
-	platform_data.gpio_torch =
-		    desc_to_gpio(gpiod_get_index(&client->dev,
-						 NULL, 1, GPIOD_OUT_LOW));
-	dev_info(&client->dev, "camera pdata: lm3554: reset: %d strobe %d torch %d\n",
-		platform_data.gpio_reset, platform_data.gpio_strobe,
-		platform_data.gpio_torch);
-
-	/* Set to TX2 mode, then ENVM/TX2 pin is a power amplifier sync input:
-	 * ENVM/TX pin asserted, flash forced into torch;
-	 * ENVM/TX pin desserted, flash set back;
-	 */
-	platform_data.envm_tx2 = 1;
-	platform_data.tx2_polarity = 0;
-
-	/* set peak current limit to be 1000mA */
-	platform_data.current_limit = 0;
-
-	return &platform_data;
-}
-
-static int lm3554_probe(struct i2c_client *client)
-{
-	int err = 0;
-	struct lm3554 *flash;
-	unsigned int i;
-	int ret;
-
-	flash = kzalloc(sizeof(*flash), GFP_KERNEL);
-	if (!flash)
-		return -ENOMEM;
-
-	flash->pdata = lm3554_platform_data_func(client);
-
-	v4l2_i2c_subdev_init(&flash->sd, client, &lm3554_ops);
-	flash->sd.internal_ops = &lm3554_internal_ops;
-	flash->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	flash->mode = ATOMISP_FLASH_MODE_OFF;
-	flash->timeout = LM3554_MAX_TIMEOUT / LM3554_TIMEOUT_STEPSIZE - 1;
-	ret =
-	    v4l2_ctrl_handler_init(&flash->ctrl_handler,
-				   ARRAY_SIZE(lm3554_controls));
-	if (ret) {
-		dev_err(&client->dev, "error initialize a ctrl_handler.\n");
-		goto fail2;
-	}
-
-	for (i = 0; i < ARRAY_SIZE(lm3554_controls); i++)
-		v4l2_ctrl_new_custom(&flash->ctrl_handler, &lm3554_controls[i],
-				     NULL);
-
-	if (flash->ctrl_handler.error) {
-
-		dev_err(&client->dev, "ctrl_handler error.\n");
-		goto fail2;
-	}
-
-	flash->sd.ctrl_handler = &flash->ctrl_handler;
-	err = media_entity_pads_init(&flash->sd.entity, 0, NULL);
-	if (err) {
-		dev_err(&client->dev, "error initialize a media entity.\n");
-		goto fail1;
-	}
-
-	flash->sd.entity.function = MEDIA_ENT_F_FLASH;
-
-	mutex_init(&flash->power_lock);
-
-	timer_setup(&flash->flash_off_delay, lm3554_flash_off_delay, 0);
-
-	err = lm3554_gpio_init(client);
-	if (err) {
-		dev_err(&client->dev, "gpio request/direction_output fail");
-		goto fail2;
-	}
-	return atomisp_register_i2c_module(&flash->sd, NULL, LED_FLASH);
-fail2:
-	media_entity_cleanup(&flash->sd.entity);
-	v4l2_ctrl_handler_free(&flash->ctrl_handler);
-fail1:
-	v4l2_device_unregister_subdev(&flash->sd);
-	kfree(flash);
-
-	return err;
-}
-
-static int lm3554_remove(struct i2c_client *client)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct lm3554 *flash = to_lm3554(sd);
-	int ret;
-
-	media_entity_cleanup(&flash->sd.entity);
-	v4l2_ctrl_handler_free(&flash->ctrl_handler);
-	v4l2_device_unregister_subdev(sd);
-
-	atomisp_gmin_remove_subdev(sd);
-
-	del_timer_sync(&flash->flash_off_delay);
-
-	ret = lm3554_gpio_uninit(client);
-	if (ret < 0)
-		goto fail;
-
-	kfree(flash);
-
-	return 0;
-fail:
-	dev_err(&client->dev, "gpio request/direction_output fail");
-	return ret;
-}
-
-static const struct dev_pm_ops lm3554_pm_ops = {
-	.suspend = lm3554_suspend,
-	.resume = lm3554_resume,
-};
-
-static const struct acpi_device_id lm3554_acpi_match[] = {
-	{ "INTCF1C" },
-	{},
-};
-MODULE_DEVICE_TABLE(acpi, lm3554_acpi_match);
-
-static struct i2c_driver lm3554_driver = {
-	.driver = {
-		.name = "lm3554",
-		.pm   = &lm3554_pm_ops,
-		.acpi_match_table = lm3554_acpi_match,
-	},
-	.probe_new = lm3554_probe,
-	.remove = lm3554_remove,
-};
-module_i2c_driver(lm3554_driver);
-
-MODULE_AUTHOR("Jing Tao <jing.tao@intel.com>");
-MODULE_DESCRIPTION("LED flash driver for LM3554");
-MODULE_LICENSE("GPL");

+ 0 - 1908
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c

@@ -1,1908 +0,0 @@
-/*
- * Support for mt9m114 Camera Sensor.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- *
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/kmod.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/i2c.h>
-#include <linux/acpi.h>
-#include "../include/linux/atomisp_gmin_platform.h"
-#include <media/v4l2-device.h>
-
-#include "mt9m114.h"
-
-#define to_mt9m114_sensor(sd) container_of(sd, struct mt9m114_device, sd)
-
-/*
- * TODO: use debug parameter to actually define when debug messages should
- * be printed.
- */
-static int debug;
-static int aaalock;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Debug level (0-1)");
-
-static int mt9m114_t_vflip(struct v4l2_subdev *sd, int value);
-static int mt9m114_t_hflip(struct v4l2_subdev *sd, int value);
-static int mt9m114_wait_state(struct i2c_client *client, int timeout);
-
-static int
-mt9m114_read_reg(struct i2c_client *client, u16 data_length, u32 reg, u32 *val)
-{
-	int err;
-	struct i2c_msg msg[2];
-	unsigned char data[4];
-
-	if (!client->adapter) {
-		v4l2_err(client, "%s error, no client->adapter\n", __func__);
-		return -ENODEV;
-	}
-
-	if (data_length != MISENSOR_8BIT && data_length != MISENSOR_16BIT
-					 && data_length != MISENSOR_32BIT) {
-		v4l2_err(client, "%s error, invalid data length\n", __func__);
-		return -EINVAL;
-	}
-
-	msg[0].addr = client->addr;
-	msg[0].flags = 0;
-	msg[0].len = MSG_LEN_OFFSET;
-	msg[0].buf = data;
-
-	/* high byte goes out first */
-	data[0] = (u16) (reg >> 8);
-	data[1] = (u16) (reg & 0xff);
-
-	msg[1].addr = client->addr;
-	msg[1].len = data_length;
-	msg[1].flags = I2C_M_RD;
-	msg[1].buf = data;
-
-	err = i2c_transfer(client->adapter, msg, 2);
-
-	if (err >= 0) {
-		*val = 0;
-		/* high byte comes first */
-		if (data_length == MISENSOR_8BIT)
-			*val = data[0];
-		else if (data_length == MISENSOR_16BIT)
-			*val = data[1] + (data[0] << 8);
-		else
-			*val = data[3] + (data[2] << 8) +
-			    (data[1] << 16) + (data[0] << 24);
-
-		return 0;
-	}
-
-	dev_err(&client->dev, "read from offset 0x%x error %d", reg, err);
-	return err;
-}
-
-static int
-mt9m114_write_reg(struct i2c_client *client, u16 data_length, u16 reg, u32 val)
-{
-	int num_msg;
-	struct i2c_msg msg;
-	unsigned char data[6] = {0};
-	__be16 *wreg;
-	int retry = 0;
-
-	if (!client->adapter) {
-		v4l2_err(client, "%s error, no client->adapter\n", __func__);
-		return -ENODEV;
-	}
-
-	if (data_length != MISENSOR_8BIT && data_length != MISENSOR_16BIT
-					 && data_length != MISENSOR_32BIT) {
-		v4l2_err(client, "%s error, invalid data_length\n", __func__);
-		return -EINVAL;
-	}
-
-	memset(&msg, 0, sizeof(msg));
-
-again:
-	msg.addr = client->addr;
-	msg.flags = 0;
-	msg.len = 2 + data_length;
-	msg.buf = data;
-
-	/* high byte goes out first */
-	wreg = (void *)data;
-	*wreg = cpu_to_be16(reg);
-
-	if (data_length == MISENSOR_8BIT) {
-		data[2] = (u8)(val);
-	} else if (data_length == MISENSOR_16BIT) {
-		u16 *wdata = (void *)&data[2];
-
-		*wdata = be16_to_cpu(*(__be16 *)&data[2]);
-	} else {
-		/* MISENSOR_32BIT */
-		u32 *wdata = (void *)&data[2];
-
-		*wdata = be32_to_cpu(*(__be32 *)&data[2]);
-	}
-
-	num_msg = i2c_transfer(client->adapter, &msg, 1);
-
-	/*
-	 * HACK: Need some delay here for Rev 2 sensors otherwise some
-	 * registers do not seem to load correctly.
-	 */
-	mdelay(1);
-
-	if (num_msg >= 0)
-		return 0;
-
-	dev_err(&client->dev, "write error: wrote 0x%x to offset 0x%x error %d",
-		val, reg, num_msg);
-	if (retry <= I2C_RETRY_COUNT) {
-		dev_dbg(&client->dev, "retrying... %d", retry);
-		retry++;
-		msleep(20);
-		goto again;
-	}
-
-	return num_msg;
-}
-
-/**
- * misensor_rmw_reg - Read/Modify/Write a value to a register in the sensor
- * device
- * @client: i2c driver client structure
- * @data_length: 8/16/32-bits length
- * @reg: register address
- * @mask: masked out bits
- * @set: bits set
- *
- * Read/modify/write a value to a register in the  sensor device.
- * Returns zero if successful, or non-zero otherwise.
- */
-static int
-misensor_rmw_reg(struct i2c_client *client, u16 data_length, u16 reg,
-		     u32 mask, u32 set)
-{
-	int err;
-	u32 val;
-
-	/* Exit when no mask */
-	if (mask == 0)
-		return 0;
-
-	/* @mask must not exceed data length */
-	switch (data_length) {
-	case MISENSOR_8BIT:
-		if (mask & ~0xff)
-			return -EINVAL;
-		break;
-	case MISENSOR_16BIT:
-		if (mask & ~0xffff)
-			return -EINVAL;
-		break;
-	case MISENSOR_32BIT:
-		break;
-	default:
-		/* Wrong @data_length */
-		return -EINVAL;
-	}
-
-	err = mt9m114_read_reg(client, data_length, reg, &val);
-	if (err) {
-		v4l2_err(client, "misensor_rmw_reg error exit, read failed\n");
-		return -EINVAL;
-	}
-
-	val &= ~mask;
-
-	/*
-	 * Perform the OR function if the @set exists.
-	 * Shift @set value to target bit location. @set should set only
-	 * bits included in @mask.
-	 *
-	 * REVISIT: This function expects @set to be non-shifted. Its shift
-	 * value is then defined to be equal to mask's LSB position.
-	 * How about to inform values in their right offset position and avoid
-	 * this unneeded shift operation?
-	 */
-	set <<= ffs(mask) - 1;
-	val |= set & mask;
-
-	err = mt9m114_write_reg(client, data_length, reg, val);
-	if (err) {
-		v4l2_err(client, "misensor_rmw_reg error exit, write failed\n");
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-
-static int __mt9m114_flush_reg_array(struct i2c_client *client,
-				     struct mt9m114_write_ctrl *ctrl)
-{
-	struct i2c_msg msg;
-	const int num_msg = 1;
-	int ret;
-	int retry = 0;
-	__be16 *data16 = (void *)&ctrl->buffer.addr;
-
-	if (ctrl->index == 0)
-		return 0;
-
-again:
-	msg.addr = client->addr;
-	msg.flags = 0;
-	msg.len = 2 + ctrl->index;
-	*data16 = cpu_to_be16(ctrl->buffer.addr);
-	msg.buf = (u8 *)&ctrl->buffer;
-
-	ret = i2c_transfer(client->adapter, &msg, num_msg);
-	if (ret != num_msg) {
-		if (++retry <= I2C_RETRY_COUNT) {
-			dev_dbg(&client->dev, "retrying... %d\n", retry);
-			msleep(20);
-			goto again;
-		}
-		dev_err(&client->dev, "%s: i2c transfer error\n", __func__);
-		return -EIO;
-	}
-
-	ctrl->index = 0;
-
-	/*
-	 * REVISIT: Previously we had a delay after writing data to sensor.
-	 * But it was removed as our tests have shown it is not necessary
-	 * anymore.
-	 */
-
-	return 0;
-}
-
-static int __mt9m114_buf_reg_array(struct i2c_client *client,
-				   struct mt9m114_write_ctrl *ctrl,
-				   const struct misensor_reg *next)
-{
-	__be16 *data16;
-	__be32 *data32;
-	int err;
-
-	/* Insufficient buffer? Let's flush and get more free space. */
-	if (ctrl->index + next->length >= MT9M114_MAX_WRITE_BUF_SIZE) {
-		err = __mt9m114_flush_reg_array(client, ctrl);
-		if (err)
-			return err;
-	}
-
-	switch (next->length) {
-	case MISENSOR_8BIT:
-		ctrl->buffer.data[ctrl->index] = (u8)next->val;
-		break;
-	case MISENSOR_16BIT:
-		data16 = (__be16 *)&ctrl->buffer.data[ctrl->index];
-		*data16 = cpu_to_be16((u16)next->val);
-		break;
-	case MISENSOR_32BIT:
-		data32 = (__be32 *)&ctrl->buffer.data[ctrl->index];
-		*data32 = cpu_to_be32(next->val);
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	/* When first item is added, we need to store its starting address */
-	if (ctrl->index == 0)
-		ctrl->buffer.addr = next->reg;
-
-	ctrl->index += next->length;
-
-	return 0;
-}
-
-static int
-__mt9m114_write_reg_is_consecutive(struct i2c_client *client,
-				   struct mt9m114_write_ctrl *ctrl,
-				   const struct misensor_reg *next)
-{
-	if (ctrl->index == 0)
-		return 1;
-
-	return ctrl->buffer.addr + ctrl->index == next->reg;
-}
-
-/*
- * mt9m114_write_reg_array - Initializes a list of mt9m114 registers
- * @client: i2c driver client structure
- * @reglist: list of registers to be written
- * @poll: completion polling requirement
- * This function initializes a list of registers. When consecutive addresses
- * are found in a row on the list, this function creates a buffer and sends
- * consecutive data in a single i2c_transfer().
- *
- * __mt9m114_flush_reg_array, __mt9m114_buf_reg_array() and
- * __mt9m114_write_reg_is_consecutive() are internal functions to
- * mt9m114_write_reg_array() and should be not used anywhere else.
- *
- */
-static int mt9m114_write_reg_array(struct i2c_client *client,
-				const struct misensor_reg *reglist,
-				int poll)
-{
-	const struct misensor_reg *next = reglist;
-	struct mt9m114_write_ctrl ctrl;
-	int err;
-
-	if (poll == PRE_POLLING) {
-		err = mt9m114_wait_state(client, MT9M114_WAIT_STAT_TIMEOUT);
-		if (err)
-			return err;
-	}
-
-	ctrl.index = 0;
-	for (; next->length != MISENSOR_TOK_TERM; next++) {
-		switch (next->length & MISENSOR_TOK_MASK) {
-		case MISENSOR_TOK_DELAY:
-			err = __mt9m114_flush_reg_array(client, &ctrl);
-			if (err)
-				return err;
-			msleep(next->val);
-			break;
-		case MISENSOR_TOK_RMW:
-			err = __mt9m114_flush_reg_array(client, &ctrl);
-			err |= misensor_rmw_reg(client,
-						next->length &
-							~MISENSOR_TOK_RMW,
-						next->reg, next->val,
-						next->val2);
-			if (err) {
-				dev_err(&client->dev, "%s read err. aborted\n",
-					__func__);
-				return -EINVAL;
-			}
-			break;
-		default:
-			/*
-			 * If next address is not consecutive, data needs to be
-			 * flushed before proceed.
-			 */
-			if (!__mt9m114_write_reg_is_consecutive(client, &ctrl,
-								next)) {
-				err = __mt9m114_flush_reg_array(client, &ctrl);
-				if (err)
-					return err;
-			}
-			err = __mt9m114_buf_reg_array(client, &ctrl, next);
-			if (err) {
-				v4l2_err(client, "%s: write error, aborted\n",
-					 __func__);
-				return err;
-			}
-			break;
-		}
-	}
-
-	err = __mt9m114_flush_reg_array(client, &ctrl);
-	if (err)
-		return err;
-
-	if (poll == POST_POLLING)
-		return mt9m114_wait_state(client, MT9M114_WAIT_STAT_TIMEOUT);
-
-	return 0;
-}
-
-static int mt9m114_wait_state(struct i2c_client *client, int timeout)
-{
-	int ret;
-	unsigned int val;
-
-	while (timeout-- > 0) {
-		ret = mt9m114_read_reg(client, MISENSOR_16BIT, 0x0080, &val);
-		if (ret)
-			return ret;
-		if ((val & 0x2) == 0)
-			return 0;
-		msleep(20);
-	}
-
-	return -EINVAL;
-
-}
-
-static int mt9m114_set_suspend(struct v4l2_subdev *sd)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	return mt9m114_write_reg_array(client,
-			mt9m114_standby_reg, POST_POLLING);
-}
-
-static int mt9m114_init_common(struct v4l2_subdev *sd)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-
-	return mt9m114_write_reg_array(client, mt9m114_common, PRE_POLLING);
-}
-
-static int power_ctrl(struct v4l2_subdev *sd, bool flag)
-{
-	int ret;
-	struct mt9m114_device *dev = to_mt9m114_sensor(sd);
-
-	if (!dev || !dev->platform_data)
-		return -ENODEV;
-
-	if (flag) {
-		ret = dev->platform_data->v2p8_ctrl(sd, 1);
-		if (ret == 0) {
-			ret = dev->platform_data->v1p8_ctrl(sd, 1);
-			if (ret)
-				ret = dev->platform_data->v2p8_ctrl(sd, 0);
-		}
-	} else {
-		ret = dev->platform_data->v2p8_ctrl(sd, 0);
-		ret = dev->platform_data->v1p8_ctrl(sd, 0);
-	}
-	return ret;
-}
-
-static int gpio_ctrl(struct v4l2_subdev *sd, bool flag)
-{
-	int ret;
-	struct mt9m114_device *dev = to_mt9m114_sensor(sd);
-
-	if (!dev || !dev->platform_data)
-		return -ENODEV;
-
-	/* Note: current modules wire only one GPIO signal (RESET#),
-	 * but the schematic wires up two to the connector.  BIOS
-	 * versions have been unfortunately inconsistent with which
-	 * ACPI index RESET# is on, so hit both */
-
-	if (flag) {
-		ret = dev->platform_data->gpio0_ctrl(sd, 0);
-		ret = dev->platform_data->gpio1_ctrl(sd, 0);
-		msleep(60);
-		ret |= dev->platform_data->gpio0_ctrl(sd, 1);
-		ret |= dev->platform_data->gpio1_ctrl(sd, 1);
-	} else {
-		ret = dev->platform_data->gpio0_ctrl(sd, 0);
-		ret = dev->platform_data->gpio1_ctrl(sd, 0);
-	}
-	return ret;
-}
-
-static int power_up(struct v4l2_subdev *sd)
-{
-	struct mt9m114_device *dev = to_mt9m114_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	if (NULL == dev->platform_data) {
-		dev_err(&client->dev, "no camera_sensor_platform_data");
-		return -ENODEV;
-	}
-
-	/* power control */
-	ret = power_ctrl(sd, 1);
-	if (ret)
-		goto fail_power;
-
-	/* flis clock control */
-	ret = dev->platform_data->flisclk_ctrl(sd, 1);
-	if (ret)
-		goto fail_clk;
-
-	/* gpio ctrl */
-	ret = gpio_ctrl(sd, 1);
-	if (ret)
-		dev_err(&client->dev, "gpio failed 1\n");
-	/*
-	 * according to DS, 44ms is needed between power up and first i2c
-	 * commend
-	 */
-	msleep(50);
-
-	return 0;
-
-fail_clk:
-	dev->platform_data->flisclk_ctrl(sd, 0);
-fail_power:
-	power_ctrl(sd, 0);
-	dev_err(&client->dev, "sensor power-up failed\n");
-
-	return ret;
-}
-
-static int power_down(struct v4l2_subdev *sd)
-{
-	struct mt9m114_device *dev = to_mt9m114_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	if (NULL == dev->platform_data) {
-		dev_err(&client->dev, "no camera_sensor_platform_data");
-		return -ENODEV;
-	}
-
-	ret = dev->platform_data->flisclk_ctrl(sd, 0);
-	if (ret)
-		dev_err(&client->dev, "flisclk failed\n");
-
-	/* gpio ctrl */
-	ret = gpio_ctrl(sd, 0);
-	if (ret)
-		dev_err(&client->dev, "gpio failed 1\n");
-
-	/* power control */
-	ret = power_ctrl(sd, 0);
-	if (ret)
-		dev_err(&client->dev, "vprog failed.\n");
-
-	/*according to DS, 20ms is needed after power down*/
-	msleep(20);
-
-	return ret;
-}
-
-static int mt9m114_s_power(struct v4l2_subdev *sd, int power)
-{
-	if (power == 0)
-		return power_down(sd);
-	else {
-		if (power_up(sd))
-			return -EINVAL;
-
-		return mt9m114_init_common(sd);
-	}
-}
-
-/*
- * distance - calculate the distance
- * @res: resolution
- * @w: width
- * @h: height
- *
- * Get the gap between resolution and w/h.
- * res->width/height smaller than w/h wouldn't be considered.
- * Returns the value of gap or -1 if fail.
- */
-#define LARGEST_ALLOWED_RATIO_MISMATCH 600
-static int distance(struct mt9m114_res_struct const *res, u32 w, u32 h)
-{
-	unsigned int w_ratio;
-	unsigned int h_ratio;
-	int match;
-
-	if (w == 0)
-		return -1;
-	w_ratio = (res->width << 13) / w;
-	if (h == 0)
-		return -1;
-	h_ratio = (res->height << 13) / h;
-	if (h_ratio == 0)
-		return -1;
-	match   = abs(((w_ratio << 13) / h_ratio) - 8192);
-
-	if ((w_ratio < 8192) || (h_ratio < 8192) ||
-	    (match > LARGEST_ALLOWED_RATIO_MISMATCH))
-		return -1;
-
-	return w_ratio + h_ratio;
-}
-
-/* Return the nearest higher resolution index */
-static int nearest_resolution_index(int w, int h)
-{
-	int i;
-	int idx = -1;
-	int dist;
-	int min_dist = INT_MAX;
-	const struct mt9m114_res_struct *tmp_res = NULL;
-
-	for (i = 0; i < ARRAY_SIZE(mt9m114_res); i++) {
-		tmp_res = &mt9m114_res[i];
-		dist = distance(tmp_res, w, h);
-		if (dist == -1)
-			continue;
-		if (dist < min_dist) {
-			min_dist = dist;
-			idx = i;
-		}
-	}
-
-	return idx;
-}
-
-static int mt9m114_try_res(u32 *w, u32 *h)
-{
-	int idx = 0;
-
-	if ((*w > MT9M114_RES_960P_SIZE_H)
-		|| (*h > MT9M114_RES_960P_SIZE_V)) {
-		*w = MT9M114_RES_960P_SIZE_H;
-		*h = MT9M114_RES_960P_SIZE_V;
-	} else {
-		idx = nearest_resolution_index(*w, *h);
-
-		/*
-		 * nearest_resolution_index() doesn't return smaller
-		 *  resolutions. If it fails, it means the requested
-		 *  resolution is higher than wecan support. Fallback
-		 *  to highest possible resolution in this case.
-		 */
-		if (idx == -1)
-			idx = ARRAY_SIZE(mt9m114_res) - 1;
-
-		*w = mt9m114_res[idx].width;
-		*h = mt9m114_res[idx].height;
-	}
-
-	return 0;
-}
-
-static struct mt9m114_res_struct *mt9m114_to_res(u32 w, u32 h)
-{
-	int  index;
-
-	for (index = 0; index < N_RES; index++) {
-		if ((mt9m114_res[index].width == w) &&
-		    (mt9m114_res[index].height == h))
-			break;
-	}
-
-	/* No mode found */
-	if (index >= N_RES)
-		return NULL;
-
-	return &mt9m114_res[index];
-}
-
-static int mt9m114_res2size(struct v4l2_subdev *sd, int *h_size, int *v_size)
-{
-	struct mt9m114_device *dev = to_mt9m114_sensor(sd);
-	unsigned short hsize;
-	unsigned short vsize;
-
-	switch (dev->res) {
-	case MT9M114_RES_736P:
-		hsize = MT9M114_RES_736P_SIZE_H;
-		vsize = MT9M114_RES_736P_SIZE_V;
-		break;
-	case MT9M114_RES_864P:
-		hsize = MT9M114_RES_864P_SIZE_H;
-		vsize = MT9M114_RES_864P_SIZE_V;
-		break;
-	case MT9M114_RES_960P:
-		hsize = MT9M114_RES_960P_SIZE_H;
-		vsize = MT9M114_RES_960P_SIZE_V;
-		break;
-	default:
-		v4l2_err(sd, "%s: Resolution 0x%08x unknown\n", __func__,
-			 dev->res);
-		return -EINVAL;
-	}
-
-	if (h_size != NULL)
-		*h_size = hsize;
-	if (v_size != NULL)
-		*v_size = vsize;
-
-	return 0;
-}
-
-static int mt9m114_get_intg_factor(struct i2c_client *client,
-				struct camera_mipi_info *info,
-				const struct mt9m114_res_struct *res)
-{
-	struct atomisp_sensor_mode_data *buf = &info->data;
-	u32 reg_val;
-	int ret;
-
-	if (info == NULL)
-		return -EINVAL;
-
-	ret =  mt9m114_read_reg(client, MISENSOR_32BIT,
-					REG_PIXEL_CLK, &reg_val);
-	if (ret)
-		return ret;
-	buf->vt_pix_clk_freq_mhz = reg_val;
-
-	/* get integration time */
-	buf->coarse_integration_time_min = MT9M114_COARSE_INTG_TIME_MIN;
-	buf->coarse_integration_time_max_margin =
-					MT9M114_COARSE_INTG_TIME_MAX_MARGIN;
-
-	buf->fine_integration_time_min = MT9M114_FINE_INTG_TIME_MIN;
-	buf->fine_integration_time_max_margin =
-					MT9M114_FINE_INTG_TIME_MAX_MARGIN;
-
-	buf->fine_integration_time_def = MT9M114_FINE_INTG_TIME_MIN;
-
-	buf->frame_length_lines = res->lines_per_frame;
-	buf->line_length_pck = res->pixels_per_line;
-	buf->read_mode = res->bin_mode;
-
-	/* get the cropping and output resolution to ISP for this mode. */
-	ret =  mt9m114_read_reg(client, MISENSOR_16BIT,
-					REG_H_START, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_horizontal_start = reg_val;
-
-	ret =  mt9m114_read_reg(client, MISENSOR_16BIT,
-					REG_V_START, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_vertical_start = reg_val;
-
-	ret = mt9m114_read_reg(client, MISENSOR_16BIT,
-					REG_H_END, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_horizontal_end = reg_val;
-
-	ret = mt9m114_read_reg(client, MISENSOR_16BIT,
-					REG_V_END, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_vertical_end = reg_val;
-
-	ret = mt9m114_read_reg(client, MISENSOR_16BIT,
-					REG_WIDTH, &reg_val);
-	if (ret)
-		return ret;
-	buf->output_width = reg_val;
-
-	ret = mt9m114_read_reg(client, MISENSOR_16BIT,
-					REG_HEIGHT, &reg_val);
-	if (ret)
-		return ret;
-	buf->output_height = reg_val;
-
-	ret = mt9m114_read_reg(client, MISENSOR_16BIT,
-					REG_TIMING_HTS, &reg_val);
-	if (ret)
-		return ret;
-	buf->line_length_pck = reg_val;
-
-	ret = mt9m114_read_reg(client, MISENSOR_16BIT,
-					REG_TIMING_VTS, &reg_val);
-	if (ret)
-		return ret;
-	buf->frame_length_lines = reg_val;
-
-	buf->binning_factor_x = res->bin_factor_x ?
-					res->bin_factor_x : 1;
-	buf->binning_factor_y = res->bin_factor_y ?
-					res->bin_factor_y : 1;
-	return 0;
-}
-
-static int mt9m114_get_fmt(struct v4l2_subdev *sd,
-				struct v4l2_subdev_pad_config *cfg,
-				struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	int width, height;
-	int ret;
-	if (format->pad)
-		return -EINVAL;
-	fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
-
-	ret = mt9m114_res2size(sd, &width, &height);
-	if (ret)
-		return ret;
-	fmt->width = width;
-	fmt->height = height;
-
-	return 0;
-}
-
-static int mt9m114_set_fmt(struct v4l2_subdev *sd,
-			   struct v4l2_subdev_pad_config *cfg,
-			   struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	struct i2c_client *c = v4l2_get_subdevdata(sd);
-	struct mt9m114_device *dev = to_mt9m114_sensor(sd);
-	struct mt9m114_res_struct *res_index;
-	u32 width = fmt->width;
-	u32 height = fmt->height;
-	struct camera_mipi_info *mt9m114_info = NULL;
-
-	int ret;
-	if (format->pad)
-		return -EINVAL;
-	dev->streamon = 0;
-	dev->first_exp = MT9M114_DEFAULT_FIRST_EXP;
-
-	mt9m114_info = v4l2_get_subdev_hostdata(sd);
-	if (mt9m114_info == NULL)
-		return -EINVAL;
-
-	mt9m114_try_res(&width, &height);
-	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-		cfg->try_fmt = *fmt;
-		return 0;
-	}
-	res_index = mt9m114_to_res(width, height);
-
-	/* Sanity check */
-	if (unlikely(!res_index)) {
-		WARN_ON(1);
-		return -EINVAL;
-	}
-
-	switch (res_index->res) {
-	case MT9M114_RES_736P:
-		ret = mt9m114_write_reg_array(c, mt9m114_736P_init, NO_POLLING);
-		ret += misensor_rmw_reg(c, MISENSOR_16BIT, MISENSOR_READ_MODE,
-				MISENSOR_R_MODE_MASK, MISENSOR_NORMAL_SET);
-		break;
-	case MT9M114_RES_864P:
-		ret = mt9m114_write_reg_array(c, mt9m114_864P_init, NO_POLLING);
-		ret += misensor_rmw_reg(c, MISENSOR_16BIT, MISENSOR_READ_MODE,
-				MISENSOR_R_MODE_MASK, MISENSOR_NORMAL_SET);
-		break;
-	case MT9M114_RES_960P:
-		ret = mt9m114_write_reg_array(c, mt9m114_976P_init, NO_POLLING);
-		/* set sensor read_mode to Normal */
-		ret += misensor_rmw_reg(c, MISENSOR_16BIT, MISENSOR_READ_MODE,
-				MISENSOR_R_MODE_MASK, MISENSOR_NORMAL_SET);
-		break;
-	default:
-		v4l2_err(sd, "set resolution: %d failed!\n", res_index->res);
-		return -EINVAL;
-	}
-
-	if (ret)
-		return -EINVAL;
-
-	ret = mt9m114_write_reg_array(c, mt9m114_chgstat_reg, POST_POLLING);
-	if (ret < 0)
-		return ret;
-
-	if (mt9m114_set_suspend(sd))
-		return -EINVAL;
-
-	if (dev->res != res_index->res) {
-		int index;
-
-		/* Switch to different size */
-		if (width <= 640) {
-			dev->nctx = 0x00; /* Set for context A */
-		} else {
-			/*
-			 * Context B is used for resolutions larger than 640x480
-			 * Using YUV for Context B.
-			 */
-			dev->nctx = 0x01; /* set for context B */
-		}
-
-		/*
-		 * Marked current sensor res as being "used"
-		 *
-		 * REVISIT: We don't need to use an "used" field on each mode
-		 * list entry to know which mode is selected. If this
-		 * information is really necessary, how about to use a single
-		 * variable on sensor dev struct?
-		 */
-		for (index = 0; index < N_RES; index++) {
-			if ((width == mt9m114_res[index].width) &&
-			    (height == mt9m114_res[index].height)) {
-				mt9m114_res[index].used = true;
-				continue;
-			}
-			mt9m114_res[index].used = false;
-		}
-	}
-	ret = mt9m114_get_intg_factor(c, mt9m114_info,
-					&mt9m114_res[res_index->res]);
-	if (ret) {
-		dev_err(&c->dev, "failed to get integration_factor\n");
-		return -EINVAL;
-	}
-	/*
-	 * mt9m114 - we don't poll for context switch
-	 * because it does not happen with streaming disabled.
-	 */
-	dev->res = res_index->res;
-
-	fmt->width = width;
-	fmt->height = height;
-	fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
-	return 0;
-}
-
-/* TODO: Update to SOC functions, remove exposure and gain */
-static int mt9m114_g_focal(struct v4l2_subdev *sd, s32 *val)
-{
-	*val = (MT9M114_FOCAL_LENGTH_NUM << 16) | MT9M114_FOCAL_LENGTH_DEM;
-	return 0;
-}
-
-static int mt9m114_g_fnumber(struct v4l2_subdev *sd, s32 *val)
-{
-	/*const f number for mt9m114*/
-	*val = (MT9M114_F_NUMBER_DEFAULT_NUM << 16) | MT9M114_F_NUMBER_DEM;
-	return 0;
-}
-
-static int mt9m114_g_fnumber_range(struct v4l2_subdev *sd, s32 *val)
-{
-	*val = (MT9M114_F_NUMBER_DEFAULT_NUM << 24) |
-		(MT9M114_F_NUMBER_DEM << 16) |
-		(MT9M114_F_NUMBER_DEFAULT_NUM << 8) | MT9M114_F_NUMBER_DEM;
-	return 0;
-}
-
-/* Horizontal flip the image. */
-static int mt9m114_g_hflip(struct v4l2_subdev *sd, s32 *val)
-{
-	struct i2c_client *c = v4l2_get_subdevdata(sd);
-	int ret;
-	u32 data;
-	ret = mt9m114_read_reg(c, MISENSOR_16BIT,
-			(u32)MISENSOR_READ_MODE, &data);
-	if (ret)
-		return ret;
-	*val = !!(data & MISENSOR_HFLIP_MASK);
-
-	return 0;
-}
-
-static int mt9m114_g_vflip(struct v4l2_subdev *sd, s32 *val)
-{
-	struct i2c_client *c = v4l2_get_subdevdata(sd);
-	int ret;
-	u32 data;
-
-	ret = mt9m114_read_reg(c, MISENSOR_16BIT,
-			(u32)MISENSOR_READ_MODE, &data);
-	if (ret)
-		return ret;
-	*val = !!(data & MISENSOR_VFLIP_MASK);
-
-	return 0;
-}
-
-static long mt9m114_s_exposure(struct v4l2_subdev *sd,
-			       struct atomisp_exposure *exposure)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct mt9m114_device *dev = to_mt9m114_sensor(sd);
-	int ret = 0;
-	unsigned int coarse_integration = 0;
-	unsigned int FLines = 0;
-	unsigned int FrameLengthLines = 0; /* ExposureTime.FrameLengthLines; */
-	unsigned int AnalogGain, DigitalGain;
-	u32 AnalogGainToWrite = 0;
-
-	dev_dbg(&client->dev, "%s(0x%X 0x%X 0x%X)\n", __func__,
-		    exposure->integration_time[0], exposure->gain[0],
-		    exposure->gain[1]);
-
-	coarse_integration = exposure->integration_time[0];
-	/* fine_integration = ExposureTime.FineIntegrationTime; */
-	/* FrameLengthLines = ExposureTime.FrameLengthLines; */
-	FLines = mt9m114_res[dev->res].lines_per_frame;
-	AnalogGain = exposure->gain[0];
-	DigitalGain = exposure->gain[1];
-	if (!dev->streamon) {
-		/*Save the first exposure values while stream is off*/
-		dev->first_exp = coarse_integration;
-		dev->first_gain = AnalogGain;
-		dev->first_diggain = DigitalGain;
-	}
-	/* DigitalGain = 0x400 * (((u16) DigitalGain) >> 8) +
-	((unsigned int)(0x400 * (((u16) DigitalGain) & 0xFF)) >>8); */
-
-	/* set frame length */
-	if (FLines < coarse_integration + 6)
-		FLines = coarse_integration + 6;
-	if (FLines < FrameLengthLines)
-		FLines = FrameLengthLines;
-	ret = mt9m114_write_reg(client, MISENSOR_16BIT, 0x300A, FLines);
-	if (ret) {
-		v4l2_err(client, "%s: fail to set FLines\n", __func__);
-		return -EINVAL;
-	}
-
-	/* set coarse integration */
-	/* 3A provide real exposure time.
-		should not translate to any value here. */
-	ret = mt9m114_write_reg(client, MISENSOR_16BIT,
-			REG_EXPO_COARSE, (u16)(coarse_integration));
-	if (ret) {
-		v4l2_err(client, "%s: fail to set exposure time\n", __func__);
-		return -EINVAL;
-	}
-
-	/*
-	// set analog/digital gain
-	switch(AnalogGain)
-	{
-	case 0:
-	  AnalogGainToWrite = 0x0;
-	  break;
-	case 1:
-	  AnalogGainToWrite = 0x20;
-	  break;
-	case 2:
-	  AnalogGainToWrite = 0x60;
-	  break;
-	case 4:
-	  AnalogGainToWrite = 0xA0;
-	  break;
-	case 8:
-	  AnalogGainToWrite = 0xE0;
-	  break;
-	default:
-	  AnalogGainToWrite = 0x20;
-	  break;
-	}
-	*/
-	if (DigitalGain >= 16 || DigitalGain <= 1)
-		DigitalGain = 1;
-	/* AnalogGainToWrite =
-		(u16)((DigitalGain << 12) | AnalogGainToWrite); */
-	AnalogGainToWrite = (u16)((DigitalGain << 12) | (u16)AnalogGain);
-	ret = mt9m114_write_reg(client, MISENSOR_16BIT,
-					REG_GAIN, AnalogGainToWrite);
-	if (ret) {
-		v4l2_err(client, "%s: fail to set AnalogGainToWrite\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	return ret;
-}
-
-static long mt9m114_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
-{
-
-	switch (cmd) {
-	case ATOMISP_IOC_S_EXPOSURE:
-		return mt9m114_s_exposure(sd, arg);
-	default:
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-/* This returns the exposure time being used. This should only be used
-   for filling in EXIF data, not for actual image processing. */
-static int mt9m114_g_exposure(struct v4l2_subdev *sd, s32 *value)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	u32 coarse;
-	int ret;
-
-	/* the fine integration time is currently not calculated */
-	ret = mt9m114_read_reg(client, MISENSOR_16BIT,
-			       REG_EXPO_COARSE, &coarse);
-	if (ret)
-		return ret;
-
-	*value = coarse;
-	return 0;
-}
-#ifndef CSS15
-/*
- * This function will return the sensor supported max exposure zone number.
- * the sensor which supports max exposure zone number is 1.
- */
-static int mt9m114_g_exposure_zone_num(struct v4l2_subdev *sd, s32 *val)
-{
-	*val = 1;
-
-	return 0;
-}
-
-/*
- * set exposure metering, average/center_weighted/spot/matrix.
- */
-static int mt9m114_s_exposure_metering(struct v4l2_subdev *sd, s32 val)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	switch (val) {
-	case V4L2_EXPOSURE_METERING_SPOT:
-		ret = mt9m114_write_reg_array(client, mt9m114_exp_average,
-						NO_POLLING);
-		if (ret) {
-			dev_err(&client->dev, "write exp_average reg err.\n");
-			return ret;
-		}
-		break;
-	case V4L2_EXPOSURE_METERING_CENTER_WEIGHTED:
-	default:
-		ret = mt9m114_write_reg_array(client, mt9m114_exp_center,
-						NO_POLLING);
-		if (ret) {
-			dev_err(&client->dev, "write exp_default reg err");
-			return ret;
-		}
-	}
-
-	return 0;
-}
-
-/*
- * This function is for touch exposure feature.
- */
-static int mt9m114_s_exposure_selection(struct v4l2_subdev *sd,
-					struct v4l2_subdev_pad_config *cfg,
-					struct v4l2_subdev_selection *sel)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct misensor_reg exp_reg;
-	int width, height;
-	int grid_width, grid_height;
-	int grid_left, grid_top, grid_right, grid_bottom;
-	int win_left, win_top, win_right, win_bottom;
-	int i, j;
-	int ret;
-
-	if (sel->which != V4L2_SUBDEV_FORMAT_TRY &&
-	    sel->which != V4L2_SUBDEV_FORMAT_ACTIVE)
-		return -EINVAL;
-
-	grid_left = sel->r.left;
-	grid_top = sel->r.top;
-	grid_right = sel->r.left + sel->r.width - 1;
-	grid_bottom = sel->r.top + sel->r.height - 1;
-
-	ret = mt9m114_res2size(sd, &width, &height);
-	if (ret)
-		return ret;
-
-	grid_width = width / 5;
-	grid_height = height / 5;
-
-	if (grid_width && grid_height) {
-		win_left = grid_left / grid_width;
-		win_top = grid_top / grid_height;
-		win_right = grid_right / grid_width;
-		win_bottom = grid_bottom / grid_height;
-	} else {
-		dev_err(&client->dev, "Incorrect exp grid.\n");
-		return -EINVAL;
-	}
-
-	win_left   = clamp_t(int, win_left, 0, 4);
-	win_top    = clamp_t(int, win_top, 0, 4);
-	win_right  = clamp_t(int, win_right, 0, 4);
-	win_bottom = clamp_t(int, win_bottom, 0, 4);
-
-	ret = mt9m114_write_reg_array(client, mt9m114_exp_average, NO_POLLING);
-	if (ret) {
-		dev_err(&client->dev, "write exp_average reg err.\n");
-		return ret;
-	}
-
-	for (i = win_top; i <= win_bottom; i++) {
-		for (j = win_left; j <= win_right; j++) {
-			exp_reg = mt9m114_exp_win[i][j];
-
-			ret = mt9m114_write_reg(client, exp_reg.length,
-						exp_reg.reg, exp_reg.val);
-			if (ret) {
-				dev_err(&client->dev, "write exp_reg err.\n");
-				return ret;
-			}
-		}
-	}
-
-	return 0;
-}
-#endif
-
-static int mt9m114_g_bin_factor_x(struct v4l2_subdev *sd, s32 *val)
-{
-	struct mt9m114_device *dev = to_mt9m114_sensor(sd);
-
-	*val = mt9m114_res[dev->res].bin_factor_x;
-
-	return 0;
-}
-
-static int mt9m114_g_bin_factor_y(struct v4l2_subdev *sd, s32 *val)
-{
-	struct mt9m114_device *dev = to_mt9m114_sensor(sd);
-
-	*val = mt9m114_res[dev->res].bin_factor_y;
-
-	return 0;
-}
-
-static int mt9m114_s_ev(struct v4l2_subdev *sd, s32 val)
-{
-	struct i2c_client *c = v4l2_get_subdevdata(sd);
-	s32 luma = 0x37;
-	int err;
-
-	/* EV value only support -2 to 2
-	 * 0: 0x37, 1:0x47, 2:0x57, -1:0x27, -2:0x17
-	 */
-	if (val < -2 || val > 2)
-		return -EINVAL;
-	luma += 0x10 * val;
-	dev_dbg(&c->dev, "%s val:%d luma:0x%x\n", __func__, val, luma);
-	err = mt9m114_write_reg(c, MISENSOR_16BIT, 0x098E, 0xC87A);
-	if (err) {
-		dev_err(&c->dev, "%s logic addr access error\n", __func__);
-		return err;
-	}
-	err = mt9m114_write_reg(c, MISENSOR_8BIT, 0xC87A, (u32)luma);
-	if (err) {
-		dev_err(&c->dev, "%s write target_average_luma failed\n",
-			__func__);
-		return err;
-	}
-	udelay(10);
-
-	return 0;
-}
-
-static int mt9m114_g_ev(struct v4l2_subdev *sd, s32 *val)
-{
-	struct i2c_client *c = v4l2_get_subdevdata(sd);
-	int err;
-	u32 luma;
-
-	err = mt9m114_write_reg(c, MISENSOR_16BIT, 0x098E, 0xC87A);
-	if (err) {
-		dev_err(&c->dev, "%s logic addr access error\n", __func__);
-		return err;
-	}
-	err = mt9m114_read_reg(c, MISENSOR_8BIT, 0xC87A, &luma);
-	if (err) {
-		dev_err(&c->dev, "%s read target_average_luma failed\n",
-			__func__);
-		return err;
-	}
-	luma -= 0x17;
-	luma /= 0x10;
-	*val = (s32)luma - 2;
-	dev_dbg(&c->dev, "%s val:%d\n", __func__, *val);
-
-	return 0;
-}
-
-/* Fake interface
- * mt9m114 now can not support 3a_lock
-*/
-static int mt9m114_s_3a_lock(struct v4l2_subdev *sd, s32 val)
-{
-	aaalock = val;
-	return 0;
-}
-
-static int mt9m114_g_3a_lock(struct v4l2_subdev *sd, s32 *val)
-{
-	if (aaalock)
-		return V4L2_LOCK_EXPOSURE | V4L2_LOCK_WHITE_BALANCE
-			| V4L2_LOCK_FOCUS;
-	return 0;
-}
-
-static int mt9m114_s_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct mt9m114_device *dev =
-	    container_of(ctrl->handler, struct mt9m114_device, ctrl_handler);
-	struct i2c_client *client = v4l2_get_subdevdata(&dev->sd);
-	int ret = 0;
-
-	switch (ctrl->id) {
-	case V4L2_CID_VFLIP:
-		dev_dbg(&client->dev, "%s: CID_VFLIP:%d.\n",
-			__func__, ctrl->val);
-		ret = mt9m114_t_vflip(&dev->sd, ctrl->val);
-		break;
-	case V4L2_CID_HFLIP:
-		dev_dbg(&client->dev, "%s: CID_HFLIP:%d.\n",
-			__func__, ctrl->val);
-		ret = mt9m114_t_hflip(&dev->sd, ctrl->val);
-		break;
-#ifndef CSS15
-	case V4L2_CID_EXPOSURE_METERING:
-		ret = mt9m114_s_exposure_metering(&dev->sd, ctrl->val);
-		break;
-#endif
-	case V4L2_CID_EXPOSURE:
-		ret = mt9m114_s_ev(&dev->sd, ctrl->val);
-		break;
-	case V4L2_CID_3A_LOCK:
-		ret = mt9m114_s_3a_lock(&dev->sd, ctrl->val);
-		break;
-	default:
-		ret = -EINVAL;
-	}
-	return ret;
-}
-
-static int mt9m114_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct mt9m114_device *dev =
-	    container_of(ctrl->handler, struct mt9m114_device, ctrl_handler);
-	int ret = 0;
-
-	switch (ctrl->id) {
-	case V4L2_CID_VFLIP:
-		ret = mt9m114_g_vflip(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_HFLIP:
-		ret = mt9m114_g_hflip(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FOCAL_ABSOLUTE:
-		ret = mt9m114_g_focal(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FNUMBER_ABSOLUTE:
-		ret = mt9m114_g_fnumber(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FNUMBER_RANGE:
-		ret = mt9m114_g_fnumber_range(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_EXPOSURE_ABSOLUTE:
-		ret = mt9m114_g_exposure(&dev->sd, &ctrl->val);
-		break;
-#ifndef CSS15
-	case V4L2_CID_EXPOSURE_ZONE_NUM:
-		ret = mt9m114_g_exposure_zone_num(&dev->sd, &ctrl->val);
-		break;
-#endif
-	case V4L2_CID_BIN_FACTOR_HORZ:
-		ret = mt9m114_g_bin_factor_x(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_BIN_FACTOR_VERT:
-		ret = mt9m114_g_bin_factor_y(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_EXPOSURE:
-		ret = mt9m114_g_ev(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_3A_LOCK:
-		ret = mt9m114_g_3a_lock(&dev->sd, &ctrl->val);
-		break;
-	default:
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static const struct v4l2_ctrl_ops ctrl_ops = {
-	.s_ctrl = mt9m114_s_ctrl,
-	.g_volatile_ctrl = mt9m114_g_volatile_ctrl
-};
-
-static struct v4l2_ctrl_config mt9m114_controls[] = {
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_VFLIP,
-	 .name = "Image v-Flip",
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .min = 0,
-	 .max = 1,
-	 .step = 1,
-	 .def = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_HFLIP,
-	 .name = "Image h-Flip",
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .min = 0,
-	 .max = 1,
-	 .step = 1,
-	 .def = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FOCAL_ABSOLUTE,
-	 .name = "focal length",
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .min = MT9M114_FOCAL_LENGTH_DEFAULT,
-	 .max = MT9M114_FOCAL_LENGTH_DEFAULT,
-	 .step = 1,
-	 .def = MT9M114_FOCAL_LENGTH_DEFAULT,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FNUMBER_ABSOLUTE,
-	 .name = "f-number",
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .min = MT9M114_F_NUMBER_DEFAULT,
-	 .max = MT9M114_F_NUMBER_DEFAULT,
-	 .step = 1,
-	 .def = MT9M114_F_NUMBER_DEFAULT,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FNUMBER_RANGE,
-	 .name = "f-number range",
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .min = MT9M114_F_NUMBER_RANGE,
-	 .max = MT9M114_F_NUMBER_RANGE,
-	 .step = 1,
-	 .def = MT9M114_F_NUMBER_RANGE,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_EXPOSURE_ABSOLUTE,
-	 .name = "exposure",
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .min = 0,
-	 .max = 0xffff,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-#ifndef CSS15
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_EXPOSURE_ZONE_NUM,
-	 .name = "one-time exposure zone number",
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .min = 0,
-	 .max = 0xffff,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_EXPOSURE_METERING,
-	 .name = "metering",
-	 .type = V4L2_CTRL_TYPE_MENU,
-	 .min = 0,
-	 .max = 3,
-	 .step = 0,
-	 .def = 1,
-	 .flags = 0,
-	 },
-#endif
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_BIN_FACTOR_HORZ,
-	 .name = "horizontal binning factor",
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .min = 0,
-	 .max = MT9M114_BIN_FACTOR_MAX,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_BIN_FACTOR_VERT,
-	 .name = "vertical binning factor",
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .min = 0,
-	 .max = MT9M114_BIN_FACTOR_MAX,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_EXPOSURE,
-	 .name = "exposure biasx",
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .min = -2,
-	 .max = 2,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_3A_LOCK,
-	 .name = "3a lock",
-	 .type = V4L2_CTRL_TYPE_BITMASK,
-	 .min = 0,
-	 .max = V4L2_LOCK_EXPOSURE | V4L2_LOCK_WHITE_BALANCE | V4L2_LOCK_FOCUS,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-};
-
-static int mt9m114_detect(struct mt9m114_device *dev, struct i2c_client *client)
-{
-	struct i2c_adapter *adapter = client->adapter;
-	u32 retvalue;
-
-	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
-		dev_err(&client->dev, "%s: i2c error", __func__);
-		return -ENODEV;
-	}
-	mt9m114_read_reg(client, MISENSOR_16BIT, (u32)MT9M114_PID, &retvalue);
-	dev->real_model_id = retvalue;
-
-	if (retvalue != MT9M114_MOD_ID) {
-		dev_err(&client->dev, "%s: failed: client->addr = %x\n",
-			__func__, client->addr);
-		return -ENODEV;
-	}
-
-	return 0;
-}
-
-static int
-mt9m114_s_config(struct v4l2_subdev *sd, int irq, void *platform_data)
-{
-	struct mt9m114_device *dev = to_mt9m114_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	if (NULL == platform_data)
-		return -ENODEV;
-
-	dev->platform_data =
-	    (struct camera_sensor_platform_data *)platform_data;
-
-	ret = power_up(sd);
-	if (ret) {
-		v4l2_err(client, "mt9m114 power-up err");
-		return ret;
-	}
-
-	/* config & detect sensor */
-	ret = mt9m114_detect(dev, client);
-	if (ret) {
-		v4l2_err(client, "mt9m114_detect err s_config.\n");
-		goto fail_detect;
-	}
-
-	ret = dev->platform_data->csi_cfg(sd, 1);
-	if (ret)
-		goto fail_csi_cfg;
-
-	ret = mt9m114_set_suspend(sd);
-	if (ret) {
-		v4l2_err(client, "mt9m114 suspend err");
-		return ret;
-	}
-
-	ret = power_down(sd);
-	if (ret) {
-		v4l2_err(client, "mt9m114 power down err");
-		return ret;
-	}
-
-	return ret;
-
-fail_csi_cfg:
-	dev->platform_data->csi_cfg(sd, 0);
-fail_detect:
-	power_down(sd);
-	dev_err(&client->dev, "sensor power-gating failed\n");
-	return ret;
-}
-
-/* Horizontal flip the image. */
-static int mt9m114_t_hflip(struct v4l2_subdev *sd, int value)
-{
-	struct i2c_client *c = v4l2_get_subdevdata(sd);
-	struct mt9m114_device *dev = to_mt9m114_sensor(sd);
-	int err;
-	/* set for direct mode */
-	err = mt9m114_write_reg(c, MISENSOR_16BIT, 0x098E, 0xC850);
-	if (value) {
-		/* enable H flip ctx A */
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC850, 0x01, 0x01);
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC851, 0x01, 0x01);
-		/* ctx B */
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC888, 0x01, 0x01);
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC889, 0x01, 0x01);
-
-		err += misensor_rmw_reg(c, MISENSOR_16BIT, MISENSOR_READ_MODE,
-					MISENSOR_HFLIP_MASK, MISENSOR_FLIP_EN);
-
-		dev->bpat = MT9M114_BPAT_GRGRBGBG;
-	} else {
-		/* disable H flip ctx A */
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC850, 0x01, 0x00);
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC851, 0x01, 0x00);
-		/* ctx B */
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC888, 0x01, 0x00);
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC889, 0x01, 0x00);
-
-		err += misensor_rmw_reg(c, MISENSOR_16BIT, MISENSOR_READ_MODE,
-					MISENSOR_HFLIP_MASK, MISENSOR_FLIP_DIS);
-
-		dev->bpat = MT9M114_BPAT_BGBGGRGR;
-	}
-
-	err += mt9m114_write_reg(c, MISENSOR_8BIT, 0x8404, 0x06);
-	udelay(10);
-
-	return !!err;
-}
-
-/* Vertically flip the image */
-static int mt9m114_t_vflip(struct v4l2_subdev *sd, int value)
-{
-	struct i2c_client *c = v4l2_get_subdevdata(sd);
-	int err;
-	/* set for direct mode */
-	err = mt9m114_write_reg(c, MISENSOR_16BIT, 0x098E, 0xC850);
-	if (value >= 1) {
-		/* enable H flip - ctx A */
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC850, 0x02, 0x01);
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC851, 0x02, 0x01);
-		/* ctx B */
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC888, 0x02, 0x01);
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC889, 0x02, 0x01);
-
-		err += misensor_rmw_reg(c, MISENSOR_16BIT, MISENSOR_READ_MODE,
-					MISENSOR_VFLIP_MASK, MISENSOR_FLIP_EN);
-	} else {
-		/* disable H flip - ctx A */
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC850, 0x02, 0x00);
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC851, 0x02, 0x00);
-		/* ctx B */
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC888, 0x02, 0x00);
-		err += misensor_rmw_reg(c, MISENSOR_8BIT, 0xC889, 0x02, 0x00);
-
-		err += misensor_rmw_reg(c, MISENSOR_16BIT, MISENSOR_READ_MODE,
-					MISENSOR_VFLIP_MASK, MISENSOR_FLIP_DIS);
-	}
-
-	err += mt9m114_write_reg(c, MISENSOR_8BIT, 0x8404, 0x06);
-	udelay(10);
-
-	return !!err;
-}
-
-static int mt9m114_g_frame_interval(struct v4l2_subdev *sd,
-				   struct v4l2_subdev_frame_interval *interval)
-{
-	struct mt9m114_device *dev = to_mt9m114_sensor(sd);
-
-	interval->interval.numerator = 1;
-	interval->interval.denominator = mt9m114_res[dev->res].fps;
-
-	return 0;
-}
-
-static int mt9m114_s_stream(struct v4l2_subdev *sd, int enable)
-{
-	int ret;
-	struct i2c_client *c = v4l2_get_subdevdata(sd);
-	struct mt9m114_device *dev = to_mt9m114_sensor(sd);
-	struct atomisp_exposure exposure;
-
-	if (enable) {
-		ret = mt9m114_write_reg_array(c, mt9m114_chgstat_reg,
-					POST_POLLING);
-		if (ret < 0)
-			return ret;
-
-		if (dev->first_exp > MT9M114_MAX_FIRST_EXP) {
-			exposure.integration_time[0] = dev->first_exp;
-			exposure.gain[0] = dev->first_gain;
-			exposure.gain[1] = dev->first_diggain;
-			mt9m114_s_exposure(sd, &exposure);
-		}
-		dev->streamon = 1;
-
-	} else {
-		dev->streamon = 0;
-		ret = mt9m114_set_suspend(sd);
-	}
-
-	return ret;
-}
-
-static int mt9m114_enum_mbus_code(struct v4l2_subdev *sd,
-				  struct v4l2_subdev_pad_config *cfg,
-				  struct v4l2_subdev_mbus_code_enum *code)
-{
-	if (code->index)
-		return -EINVAL;
-	code->code = MEDIA_BUS_FMT_SGRBG10_1X10;
-
-	return 0;
-}
-
-static int mt9m114_enum_frame_size(struct v4l2_subdev *sd,
-				   struct v4l2_subdev_pad_config *cfg,
-				   struct v4l2_subdev_frame_size_enum *fse)
-{
-
-	unsigned int index = fse->index;
-
-	if (index >= N_RES)
-		return -EINVAL;
-
-	fse->min_width = mt9m114_res[index].width;
-	fse->min_height = mt9m114_res[index].height;
-	fse->max_width = mt9m114_res[index].width;
-	fse->max_height = mt9m114_res[index].height;
-
-	return 0;
-}
-
-static int mt9m114_g_skip_frames(struct v4l2_subdev *sd, u32 *frames)
-{
-	int index;
-	struct mt9m114_device *snr = to_mt9m114_sensor(sd);
-
-	if (frames == NULL)
-		return -EINVAL;
-
-	for (index = 0; index < N_RES; index++) {
-		if (mt9m114_res[index].res == snr->res)
-			break;
-	}
-
-	if (index >= N_RES)
-		return -EINVAL;
-
-	*frames = mt9m114_res[index].skip_frames;
-
-	return 0;
-}
-
-static const struct v4l2_subdev_video_ops mt9m114_video_ops = {
-	.s_stream = mt9m114_s_stream,
-	.g_frame_interval = mt9m114_g_frame_interval,
-};
-
-static const struct v4l2_subdev_sensor_ops mt9m114_sensor_ops = {
-	.g_skip_frames	= mt9m114_g_skip_frames,
-};
-
-static const struct v4l2_subdev_core_ops mt9m114_core_ops = {
-	.s_power = mt9m114_s_power,
-	.ioctl = mt9m114_ioctl,
-};
-
-/* REVISIT: Do we need pad operations? */
-static const struct v4l2_subdev_pad_ops mt9m114_pad_ops = {
-	.enum_mbus_code = mt9m114_enum_mbus_code,
-	.enum_frame_size = mt9m114_enum_frame_size,
-	.get_fmt = mt9m114_get_fmt,
-	.set_fmt = mt9m114_set_fmt,
-#ifndef CSS15
-	.set_selection = mt9m114_s_exposure_selection,
-#endif
-};
-
-static const struct v4l2_subdev_ops mt9m114_ops = {
-	.core = &mt9m114_core_ops,
-	.video = &mt9m114_video_ops,
-	.pad = &mt9m114_pad_ops,
-	.sensor = &mt9m114_sensor_ops,
-};
-
-static int mt9m114_remove(struct i2c_client *client)
-{
-	struct mt9m114_device *dev;
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-
-	dev = container_of(sd, struct mt9m114_device, sd);
-	dev->platform_data->csi_cfg(sd, 0);
-	v4l2_device_unregister_subdev(sd);
-	media_entity_cleanup(&dev->sd.entity);
-	v4l2_ctrl_handler_free(&dev->ctrl_handler);
-	kfree(dev);
-	return 0;
-}
-
-static int mt9m114_probe(struct i2c_client *client)
-{
-	struct mt9m114_device *dev;
-	int ret = 0;
-	unsigned int i;
-	void *pdata;
-
-	/* Setup sensor configuration structure */
-	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (!dev)
-		return -ENOMEM;
-
-	v4l2_i2c_subdev_init(&dev->sd, client, &mt9m114_ops);
-	pdata = gmin_camera_platform_data(&dev->sd,
-					  ATOMISP_INPUT_FORMAT_RAW_10,
-					  atomisp_bayer_order_grbg);
-	if (pdata)
-		ret = mt9m114_s_config(&dev->sd, client->irq, pdata);
-	if (!pdata || ret) {
-		v4l2_device_unregister_subdev(&dev->sd);
-		kfree(dev);
-		return ret;
-	}
-
-	ret = atomisp_register_i2c_module(&dev->sd, pdata, RAW_CAMERA);
-	if (ret) {
-		v4l2_device_unregister_subdev(&dev->sd);
-		kfree(dev);
-		/* Coverity CID 298095 - return on error */
-		return ret;
-	}
-
-	/*TODO add format code here*/
-	dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	dev->pad.flags = MEDIA_PAD_FL_SOURCE;
-	dev->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
-	dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
-
-	ret =
-	    v4l2_ctrl_handler_init(&dev->ctrl_handler,
-				   ARRAY_SIZE(mt9m114_controls));
-	if (ret) {
-		mt9m114_remove(client);
-		return ret;
-	}
-
-	for (i = 0; i < ARRAY_SIZE(mt9m114_controls); i++)
-		v4l2_ctrl_new_custom(&dev->ctrl_handler, &mt9m114_controls[i],
-				     NULL);
-
-	if (dev->ctrl_handler.error) {
-		mt9m114_remove(client);
-		return dev->ctrl_handler.error;
-	}
-
-	/* Use same lock for controls as for everything else. */
-	dev->ctrl_handler.lock = &dev->input_lock;
-	dev->sd.ctrl_handler = &dev->ctrl_handler;
-
-	/* REVISIT: Do we need media controller? */
-	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
-	if (ret) {
-		mt9m114_remove(client);
-		return ret;
-	}
-	return 0;
-}
-
-static const struct acpi_device_id mt9m114_acpi_match[] = {
-	{ "INT33F0" },
-	{ "CRMT1040" },
-	{},
-};
-MODULE_DEVICE_TABLE(acpi, mt9m114_acpi_match);
-
-static struct i2c_driver mt9m114_driver = {
-	.driver = {
-		.name = "mt9m114",
-		.acpi_match_table = mt9m114_acpi_match,
-	},
-	.probe_new = mt9m114_probe,
-	.remove = mt9m114_remove,
-};
-module_i2c_driver(mt9m114_driver);
-
-MODULE_AUTHOR("Shuguang Gong <Shuguang.gong@intel.com>");
-MODULE_LICENSE("GPL");

+ 0 - 1470
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c

@@ -1,1470 +0,0 @@
-/*
- * Support for OmniVision OV2680 1080p HD camera sensor.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/kmod.h>
-#include <linux/device.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/i2c.h>
-#include <linux/moduleparam.h>
-#include <media/v4l2-device.h>
-#include <linux/io.h>
-#include <linux/acpi.h>
-#include "../include/linux/atomisp_gmin_platform.h"
-
-#include "ov2680.h"
-
-static int h_flag = 0;
-static int v_flag = 0;
-static enum atomisp_bayer_order ov2680_bayer_order_mapping[] = {
-	atomisp_bayer_order_bggr,
-	atomisp_bayer_order_grbg,
-	atomisp_bayer_order_gbrg,
-	atomisp_bayer_order_rggb,
-};
-
-/* i2c read/write stuff */
-static int ov2680_read_reg(struct i2c_client *client,
-			   u16 data_length, u16 reg, u16 *val)
-{
-	int err;
-	struct i2c_msg msg[2];
-	unsigned char data[6];
-
-	if (!client->adapter) {
-		dev_err(&client->dev, "%s error, no client->adapter\n",
-			__func__);
-		return -ENODEV;
-	}
-
-	if (data_length != OV2680_8BIT && data_length != OV2680_16BIT
-					&& data_length != OV2680_32BIT) {
-		dev_err(&client->dev, "%s error, invalid data length\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	memset(msg, 0 , sizeof(msg));
-
-	msg[0].addr = client->addr;
-	msg[0].flags = 0;
-	msg[0].len = I2C_MSG_LENGTH;
-	msg[0].buf = data;
-
-	/* high byte goes out first */
-	data[0] = (u8)(reg >> 8);
-	data[1] = (u8)(reg & 0xff);
-
-	msg[1].addr = client->addr;
-	msg[1].len = data_length;
-	msg[1].flags = I2C_M_RD;
-	msg[1].buf = data;
-
-	err = i2c_transfer(client->adapter, msg, 2);
-	if (err != 2) {
-		if (err >= 0)
-			err = -EIO;
-		dev_err(&client->dev,
-			"read from offset 0x%x error %d", reg, err);
-		return err;
-	}
-
-	*val = 0;
-	/* high byte comes first */
-	if (data_length == OV2680_8BIT)
-		*val = (u8)data[0];
-	else if (data_length == OV2680_16BIT)
-		*val = be16_to_cpu(*(__be16 *)&data[0]);
-	else
-		*val = be32_to_cpu(*(__be32 *)&data[0]);
-	//dev_dbg(&client->dev,  "++++i2c read adr%x = %x\n", reg,*val);
-	return 0;
-}
-
-static int ov2680_i2c_write(struct i2c_client *client, u16 len, u8 *data)
-{
-	struct i2c_msg msg;
-	const int num_msg = 1;
-	int ret;
-
-	msg.addr = client->addr;
-	msg.flags = 0;
-	msg.len = len;
-	msg.buf = data;
-	ret = i2c_transfer(client->adapter, &msg, 1);
-	//dev_dbg(&client->dev,  "+++i2c write reg=%x->%x\n", data[0]*256 +data[1],data[2]);
-	return ret == num_msg ? 0 : -EIO;
-}
-
-static int ov2680_write_reg(struct i2c_client *client, u16 data_length,
-							u16 reg, u16 val)
-{
-	int ret;
-	unsigned char data[4] = {0};
-	__be16 *wreg = (void *)data;
-	const u16 len = data_length + sizeof(u16); /* 16-bit address + data */
-
-	if (data_length != OV2680_8BIT && data_length != OV2680_16BIT) {
-		dev_err(&client->dev,
-			"%s error, invalid data_length\n", __func__);
-		return -EINVAL;
-	}
-
-	/* high byte goes out first */
-	*wreg = cpu_to_be16(reg);
-
-	if (data_length == OV2680_8BIT) {
-		data[2] = (u8)(val);
-	} else {
-		/* OV2680_16BIT */
-		__be16 *wdata = (void *)&data[2];
-
-		*wdata = cpu_to_be16(val);
-	}
-
-	ret = ov2680_i2c_write(client, len, data);
-	if (ret)
-		dev_err(&client->dev,
-			"write error: wrote 0x%x to offset 0x%x error %d",
-			val, reg, ret);
-
-	return ret;
-}
-
-/*
- * ov2680_write_reg_array - Initializes a list of OV2680 registers
- * @client: i2c driver client structure
- * @reglist: list of registers to be written
- *
- * This function initializes a list of registers. When consecutive addresses
- * are found in a row on the list, this function creates a buffer and sends
- * consecutive data in a single i2c_transfer().
- *
- * __ov2680_flush_reg_array, __ov2680_buf_reg_array() and
- * __ov2680_write_reg_is_consecutive() are internal functions to
- * ov2680_write_reg_array_fast() and should be not used anywhere else.
- *
- */
-
-static int __ov2680_flush_reg_array(struct i2c_client *client,
-				    struct ov2680_write_ctrl *ctrl)
-{
-	u16 size;
-	__be16 *data16 = (void *)&ctrl->buffer.addr;
-
-	if (ctrl->index == 0)
-		return 0;
-
-	size = sizeof(u16) + ctrl->index; /* 16-bit address + data */
-	*data16 = cpu_to_be16(ctrl->buffer.addr);
-	ctrl->index = 0;
-
-	return ov2680_i2c_write(client, size, (u8 *)&ctrl->buffer);
-}
-
-static int __ov2680_buf_reg_array(struct i2c_client *client,
-				  struct ov2680_write_ctrl *ctrl,
-				  const struct ov2680_reg *next)
-{
-	int size;
-	__be16 *data16;
-
-	switch (next->type) {
-	case OV2680_8BIT:
-		size = 1;
-		ctrl->buffer.data[ctrl->index] = (u8)next->val;
-		break;
-	case OV2680_16BIT:
-		size = 2;
-		data16 = (void *)&ctrl->buffer.data[ctrl->index];
-		*data16 = cpu_to_be16((u16)next->val);
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	/* When first item is added, we need to store its starting address */
-	if (ctrl->index == 0)
-		ctrl->buffer.addr = next->reg;
-
-	ctrl->index += size;
-
-	/*
-	 * Buffer cannot guarantee free space for u32? Better flush it to avoid
-	 * possible lack of memory for next item.
-	 */
-	if (ctrl->index + sizeof(u16) >= OV2680_MAX_WRITE_BUF_SIZE)
-		return __ov2680_flush_reg_array(client, ctrl);
-
-	return 0;
-}
-
-static int __ov2680_write_reg_is_consecutive(struct i2c_client *client,
-					     struct ov2680_write_ctrl *ctrl,
-					     const struct ov2680_reg *next)
-{
-	if (ctrl->index == 0)
-		return 1;
-
-	return ctrl->buffer.addr + ctrl->index == next->reg;
-}
-
-static int ov2680_write_reg_array(struct i2c_client *client,
-				  const struct ov2680_reg *reglist)
-{
-	const struct ov2680_reg *next = reglist;
-	struct ov2680_write_ctrl ctrl;
-	int err;
-	dev_dbg(&client->dev,  "++++write reg array\n");
-	ctrl.index = 0;
-	for (; next->type != OV2680_TOK_TERM; next++) {
-		switch (next->type & OV2680_TOK_MASK) {
-		case OV2680_TOK_DELAY:
-			err = __ov2680_flush_reg_array(client, &ctrl);
-			if (err)
-				return err;
-			msleep(next->val);
-			break;
-		default:
-			/*
-			 * If next address is not consecutive, data needs to be
-			 * flushed before proceed.
-			 */
-			 dev_dbg(&client->dev,  "+++ov2680_write_reg_array reg=%x->%x\n", next->reg,next->val);
-			if (!__ov2680_write_reg_is_consecutive(client, &ctrl,
-								next)) {
-				err = __ov2680_flush_reg_array(client, &ctrl);
-				if (err)
-					return err;
-			}
-			err = __ov2680_buf_reg_array(client, &ctrl, next);
-			if (err) {
-				dev_err(&client->dev, "%s: write error, aborted\n",
-					 __func__);
-				return err;
-			}
-			break;
-		}
-	}
-
-	return __ov2680_flush_reg_array(client, &ctrl);
-}
-static int ov2680_g_focal(struct v4l2_subdev *sd, s32 *val)
-{
-
-	*val = (OV2680_FOCAL_LENGTH_NUM << 16) | OV2680_FOCAL_LENGTH_DEM;
-	return 0;
-}
-
-static int ov2680_g_fnumber(struct v4l2_subdev *sd, s32 *val)
-{
-	/*const f number for ov2680*/
-
-	*val = (OV2680_F_NUMBER_DEFAULT_NUM << 16) | OV2680_F_NUMBER_DEM;
-	return 0;
-}
-
-static int ov2680_g_fnumber_range(struct v4l2_subdev *sd, s32 *val)
-{
-	*val = (OV2680_F_NUMBER_DEFAULT_NUM << 24) |
-		(OV2680_F_NUMBER_DEM << 16) |
-		(OV2680_F_NUMBER_DEFAULT_NUM << 8) | OV2680_F_NUMBER_DEM;
-	return 0;
-}
-
-static int ov2680_g_bin_factor_x(struct v4l2_subdev *sd, s32 *val)
-{
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	dev_dbg(&client->dev,  "++++ov2680_g_bin_factor_x\n");
-	*val = ov2680_res[dev->fmt_idx].bin_factor_x;
-
-	return 0;
-}
-
-static int ov2680_g_bin_factor_y(struct v4l2_subdev *sd, s32 *val)
-{
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-
-	*val = ov2680_res[dev->fmt_idx].bin_factor_y;
-	dev_dbg(&client->dev,  "++++ov2680_g_bin_factor_y\n");
-	return 0;
-}
-
-
-static int ov2680_get_intg_factor(struct i2c_client *client,
-				struct camera_mipi_info *info,
-				const struct ov2680_resolution *res)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	struct atomisp_sensor_mode_data *buf = &info->data;
-	unsigned int pix_clk_freq_hz;
-	u16 reg_val;
-	int ret;
-	dev_dbg(&client->dev,  "++++ov2680_get_intg_factor\n");
-	if (!info)
-		return -EINVAL;
-
-	/* pixel clock */
-	pix_clk_freq_hz = res->pix_clk_freq * 1000000;
-
-	dev->vt_pix_clk_freq_mhz = pix_clk_freq_hz;
-	buf->vt_pix_clk_freq_mhz = pix_clk_freq_hz;
-
-	/* get integration time */
-	buf->coarse_integration_time_min = OV2680_COARSE_INTG_TIME_MIN;
-	buf->coarse_integration_time_max_margin =
-					OV2680_COARSE_INTG_TIME_MAX_MARGIN;
-
-	buf->fine_integration_time_min = OV2680_FINE_INTG_TIME_MIN;
-	buf->fine_integration_time_max_margin =
-					OV2680_FINE_INTG_TIME_MAX_MARGIN;
-
-	buf->fine_integration_time_def = OV2680_FINE_INTG_TIME_MIN;
-	buf->frame_length_lines = res->lines_per_frame;
-	buf->line_length_pck = res->pixels_per_line;
-	buf->read_mode = res->bin_mode;
-
-	/* get the cropping and output resolution to ISP for this mode. */
-	ret =  ov2680_read_reg(client, OV2680_16BIT,
-					OV2680_HORIZONTAL_START_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_horizontal_start = reg_val;
-
-	ret =  ov2680_read_reg(client, OV2680_16BIT,
-					OV2680_VERTICAL_START_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_vertical_start = reg_val;
-
-	ret = ov2680_read_reg(client, OV2680_16BIT,
-					OV2680_HORIZONTAL_END_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_horizontal_end = reg_val;
-
-	ret = ov2680_read_reg(client, OV2680_16BIT,
-					OV2680_VERTICAL_END_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_vertical_end = reg_val;
-
-	ret = ov2680_read_reg(client, OV2680_16BIT,
-					OV2680_HORIZONTAL_OUTPUT_SIZE_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->output_width = reg_val;
-
-	ret = ov2680_read_reg(client, OV2680_16BIT,
-					OV2680_VERTICAL_OUTPUT_SIZE_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->output_height = reg_val;
-
-	buf->binning_factor_x = res->bin_factor_x ?
-					(res->bin_factor_x * 2) : 1;
-	buf->binning_factor_y = res->bin_factor_y ?
-					(res->bin_factor_y * 2) : 1;
-	return 0;
-}
-
-static long __ov2680_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
-				 int gain, int digitgain)
-
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	u16 vts;
-	int ret,exp_val;
-
-	dev_dbg(&client->dev,
-		"+++++++__ov2680_set_exposure coarse_itg %d, gain %d, digitgain %d++\n",
-		coarse_itg, gain, digitgain);
-
-	vts = ov2680_res[dev->fmt_idx].lines_per_frame;
-
-	/* group hold */
-	ret = ov2680_write_reg(client, OV2680_8BIT,
-                                       OV2680_GROUP_ACCESS, 0x00);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV2680_GROUP_ACCESS);
-		return ret;
-	}
-
-	/* Increase the VTS to match exposure + MARGIN */
-	if (coarse_itg > vts - OV2680_INTEGRATION_TIME_MARGIN)
-		vts = (u16) coarse_itg + OV2680_INTEGRATION_TIME_MARGIN;
-
-	ret = ov2680_write_reg(client, OV2680_16BIT, OV2680_TIMING_VTS_H, vts);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV2680_TIMING_VTS_H);
-		return ret;
-	}
-
-	/* set exposure */
-
-	/* Lower four bit should be 0*/
-	exp_val = coarse_itg << 4;
-	ret = ov2680_write_reg(client, OV2680_8BIT,
-			       OV2680_EXPOSURE_L, exp_val & 0xFF);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV2680_EXPOSURE_L);
-		return ret;
-	}
-
-	ret = ov2680_write_reg(client, OV2680_8BIT,
-			       OV2680_EXPOSURE_M, (exp_val >> 8) & 0xFF);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV2680_EXPOSURE_M);
-		return ret;
-	}
-
-	ret = ov2680_write_reg(client, OV2680_8BIT,
-			       OV2680_EXPOSURE_H, (exp_val >> 16) & 0x0F);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV2680_EXPOSURE_H);
-		return ret;
-	}
-
-	/* Analog gain */
-	ret = ov2680_write_reg(client, OV2680_16BIT, OV2680_AGC_H, gain);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV2680_AGC_H);
-		return ret;
-	}
-	/* Digital gain */
-	if (digitgain) {
-		ret = ov2680_write_reg(client, OV2680_16BIT,
-				OV2680_MWB_RED_GAIN_H, digitgain);
-		if (ret) {
-			dev_err(&client->dev, "%s: write %x error, aborted\n",
-				__func__, OV2680_MWB_RED_GAIN_H);
-			return ret;
-		}
-
-		ret = ov2680_write_reg(client, OV2680_16BIT,
-				OV2680_MWB_GREEN_GAIN_H, digitgain);
-		if (ret) {
-			dev_err(&client->dev, "%s: write %x error, aborted\n",
-				__func__, OV2680_MWB_RED_GAIN_H);
-			return ret;
-		}
-
-		ret = ov2680_write_reg(client, OV2680_16BIT,
-				OV2680_MWB_BLUE_GAIN_H, digitgain);
-		if (ret) {
-			dev_err(&client->dev, "%s: write %x error, aborted\n",
-				__func__, OV2680_MWB_RED_GAIN_H);
-			return ret;
-		}
-	}
-
-	/* End group */
-	ret = ov2680_write_reg(client, OV2680_8BIT,
-			       OV2680_GROUP_ACCESS, 0x10);
-	if (ret)
-		return ret;
-
-	/* Delay launch group */
-	ret = ov2680_write_reg(client, OV2680_8BIT,
-					   OV2680_GROUP_ACCESS, 0xa0);
-	if (ret)
-		return ret;
-	return ret;
-}
-
-static int ov2680_set_exposure(struct v4l2_subdev *sd, int exposure,
-	int gain, int digitgain)
-{
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	int ret;
-
-	mutex_lock(&dev->input_lock);
-	ret = __ov2680_set_exposure(sd, exposure, gain, digitgain);
-	mutex_unlock(&dev->input_lock);
-
-	return ret;
-}
-
-static long ov2680_s_exposure(struct v4l2_subdev *sd,
-			       struct atomisp_exposure *exposure)
-{
-	u16 coarse_itg = exposure->integration_time[0];
-	u16 analog_gain = exposure->gain[0];
-	u16 digital_gain = exposure->gain[1];
-
-	/* we should not accept the invalid value below */
-	if (analog_gain == 0) {
-		struct i2c_client *client = v4l2_get_subdevdata(sd);
-		v4l2_err(client, "%s: invalid value\n", __func__);
-		return -EINVAL;
-	}
-
-	// EXPOSURE CONTROL DISABLED FOR INITIAL CHECKIN, TUNING DOESN'T WORK
-	return ov2680_set_exposure(sd, coarse_itg, analog_gain, digital_gain);
-}
-
-
-
-
-
-static long ov2680_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
-{
-
-	switch (cmd) {
-	case ATOMISP_IOC_S_EXPOSURE:
-		return ov2680_s_exposure(sd, arg);
-
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
-
-/* This returns the exposure time being used. This should only be used
- * for filling in EXIF data, not for actual image processing.
- */
-static int ov2680_q_exposure(struct v4l2_subdev *sd, s32 *value)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	u16 reg_v, reg_v2;
-	int ret;
-
-	/* get exposure */
-	ret = ov2680_read_reg(client, OV2680_8BIT,
-					OV2680_EXPOSURE_L,
-					&reg_v);
-	if (ret)
-		goto err;
-
-	ret = ov2680_read_reg(client, OV2680_8BIT,
-					OV2680_EXPOSURE_M,
-					&reg_v2);
-	if (ret)
-		goto err;
-
-	reg_v += reg_v2 << 8;
-	ret = ov2680_read_reg(client, OV2680_8BIT,
-					OV2680_EXPOSURE_H,
-					&reg_v2);
-	if (ret)
-		goto err;
-
-	*value = reg_v + (((u32)reg_v2 << 16));
-err:
-	return ret;
-}
-
-static u32 ov2680_translate_bayer_order(enum atomisp_bayer_order code)
-{
-	switch (code) {
-	case atomisp_bayer_order_rggb:
-		return MEDIA_BUS_FMT_SRGGB10_1X10;
-	case atomisp_bayer_order_grbg:
-		return MEDIA_BUS_FMT_SGRBG10_1X10;
-	case atomisp_bayer_order_bggr:
-		return MEDIA_BUS_FMT_SBGGR10_1X10;
-	case atomisp_bayer_order_gbrg:
-		return MEDIA_BUS_FMT_SGBRG10_1X10;
-	}
-	return 0;
-}
-
-static int ov2680_v_flip(struct v4l2_subdev *sd, s32 value)
-{
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	struct camera_mipi_info *ov2680_info = NULL;
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-	u16 val;
-	u8 index;
-	dev_dbg(&client->dev, "@%s: value:%d\n", __func__, value);
-	ret = ov2680_read_reg(client, OV2680_8BIT, OV2680_FLIP_REG, &val);
-	if (ret)
-		return ret;
-	if (value) {
-		val |= OV2680_FLIP_MIRROR_BIT_ENABLE;
-	} else {
-		val &= ~OV2680_FLIP_MIRROR_BIT_ENABLE;
-	}
-	ret = ov2680_write_reg(client, OV2680_8BIT,
-			OV2680_FLIP_REG, val);
-	if (ret)
-		return ret;
-	index = (v_flag>0?OV2680_FLIP_BIT:0) | (h_flag>0?OV2680_MIRROR_BIT:0);
-	ov2680_info = v4l2_get_subdev_hostdata(sd);
-	if (ov2680_info) {
-		ov2680_info->raw_bayer_order = ov2680_bayer_order_mapping[index];
-		dev->format.code = ov2680_translate_bayer_order(
-			ov2680_info->raw_bayer_order);
-	}
-	return ret;
-}
-
-static int ov2680_h_flip(struct v4l2_subdev *sd, s32 value)
-{
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	struct camera_mipi_info *ov2680_info = NULL;
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-	u16 val;
-	u8 index;
-	dev_dbg(&client->dev, "@%s: value:%d\n", __func__, value);
-
-	ret = ov2680_read_reg(client, OV2680_8BIT, OV2680_MIRROR_REG, &val);
-	if (ret)
-		return ret;
-	if (value) {
-		val |= OV2680_FLIP_MIRROR_BIT_ENABLE;
-	} else {
-		val &= ~OV2680_FLIP_MIRROR_BIT_ENABLE;
-	}
-	ret = ov2680_write_reg(client, OV2680_8BIT,
-			OV2680_MIRROR_REG, val);
-	if (ret)
-		return ret;
-	index = (v_flag>0?OV2680_FLIP_BIT:0) | (h_flag>0?OV2680_MIRROR_BIT:0);
-	ov2680_info = v4l2_get_subdev_hostdata(sd);
-	if (ov2680_info) {
-		ov2680_info->raw_bayer_order = ov2680_bayer_order_mapping[index];
-		dev->format.code = ov2680_translate_bayer_order(
-			ov2680_info->raw_bayer_order);
-	}
-	return ret;
-}
-
-static int ov2680_s_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct ov2680_device *dev =
-	    container_of(ctrl->handler, struct ov2680_device, ctrl_handler);
-	struct i2c_client *client = v4l2_get_subdevdata(&dev->sd);
-	int ret = 0;
-
-	switch (ctrl->id) {
-	case V4L2_CID_VFLIP:
-		dev_dbg(&client->dev, "%s: CID_VFLIP:%d.\n",
-			__func__, ctrl->val);
-		ret = ov2680_v_flip(&dev->sd, ctrl->val);
-		break;
-	case V4L2_CID_HFLIP:
-		dev_dbg(&client->dev, "%s: CID_HFLIP:%d.\n",
-			__func__, ctrl->val);
-		ret = ov2680_h_flip(&dev->sd, ctrl->val);
-		break;
-	default:
-		ret = -EINVAL;
-	}
-	return ret;
-}
-
-static int ov2680_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct ov2680_device *dev =
-	    container_of(ctrl->handler, struct ov2680_device, ctrl_handler);
-	int ret = 0;
-
-	switch (ctrl->id) {
-	case V4L2_CID_EXPOSURE_ABSOLUTE:
-		ret = ov2680_q_exposure(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FOCAL_ABSOLUTE:
-		ret = ov2680_g_focal(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FNUMBER_ABSOLUTE:
-		ret = ov2680_g_fnumber(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FNUMBER_RANGE:
-		ret = ov2680_g_fnumber_range(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_BIN_FACTOR_HORZ:
-		ret = ov2680_g_bin_factor_x(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_BIN_FACTOR_VERT:
-		ret = ov2680_g_bin_factor_y(&dev->sd, &ctrl->val);
-		break;
-	default:
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static const struct v4l2_ctrl_ops ctrl_ops = {
-	.s_ctrl = ov2680_s_ctrl,
-	.g_volatile_ctrl = ov2680_g_volatile_ctrl
-};
-
-static const struct v4l2_ctrl_config ov2680_controls[] = {
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_EXPOSURE_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "exposure",
-	 .min = 0x0,
-	 .max = 0xffff,
-	 .step = 0x01,
-	 .def = 0x00,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FOCAL_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "focal length",
-	 .min = OV2680_FOCAL_LENGTH_DEFAULT,
-	 .max = OV2680_FOCAL_LENGTH_DEFAULT,
-	 .step = 0x01,
-	 .def = OV2680_FOCAL_LENGTH_DEFAULT,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FNUMBER_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "f-number",
-	 .min = OV2680_F_NUMBER_DEFAULT,
-	 .max = OV2680_F_NUMBER_DEFAULT,
-	 .step = 0x01,
-	 .def = OV2680_F_NUMBER_DEFAULT,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FNUMBER_RANGE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "f-number range",
-	 .min = OV2680_F_NUMBER_RANGE,
-	 .max = OV2680_F_NUMBER_RANGE,
-	 .step = 0x01,
-	 .def = OV2680_F_NUMBER_RANGE,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_BIN_FACTOR_HORZ,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "horizontal binning factor",
-	 .min = 0,
-	 .max = OV2680_BIN_FACTOR_MAX,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_BIN_FACTOR_VERT,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "vertical binning factor",
-	 .min = 0,
-	 .max = OV2680_BIN_FACTOR_MAX,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_VFLIP,
-	 .type = V4L2_CTRL_TYPE_BOOLEAN,
-	 .name = "Flip",
-	 .min = 0,
-	 .max = 1,
-	 .step = 1,
-	 .def = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_HFLIP,
-	 .type = V4L2_CTRL_TYPE_BOOLEAN,
-	 .name = "Mirror",
-	 .min = 0,
-	 .max = 1,
-	 .step = 1,
-	 .def = 0,
-	 },
-};
-
-static int ov2680_init_registers(struct v4l2_subdev *sd)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	ret = ov2680_write_reg(client, OV2680_8BIT, OV2680_SW_RESET, 0x01);
-	ret |= ov2680_write_reg_array(client, ov2680_global_setting);
-
-	return ret;
-}
-
-static int ov2680_init(struct v4l2_subdev *sd)
-{
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-
-	int ret;
-
-	mutex_lock(&dev->input_lock);
-
-	/* restore settings */
-	ov2680_res = ov2680_res_preview;
-	N_RES = N_RES_PREVIEW;
-
-	ret = ov2680_init_registers(sd);
-
-	mutex_unlock(&dev->input_lock);
-
-	return ret;
-}
-
-static int power_ctrl(struct v4l2_subdev *sd, bool flag)
-{
-	int ret = 0;
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	if (!dev || !dev->platform_data)
-		return -ENODEV;
-
-	if (flag) {
-		ret |= dev->platform_data->v1p8_ctrl(sd, 1);
-		ret |= dev->platform_data->v2p8_ctrl(sd, 1);
-		usleep_range(10000, 15000);
-	}
-
-	if (!flag || ret) {
-		ret |= dev->platform_data->v1p8_ctrl(sd, 0);
-		ret |= dev->platform_data->v2p8_ctrl(sd, 0);
-	}
-	return ret;
-}
-
-static int gpio_ctrl(struct v4l2_subdev *sd, bool flag)
-{
-	int ret;
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-
-	if (!dev || !dev->platform_data)
-		return -ENODEV;
-
-	/* The OV2680 documents only one GPIO input (#XSHUTDN), but
-	 * existing integrations often wire two (reset/power_down)
-	 * because that is the way other sensors work.  There is no
-	 * way to tell how it is wired internally, so existing
-	 * firmwares expose both and we drive them symmetrically. */
-	if (flag) {
-		ret = dev->platform_data->gpio0_ctrl(sd, 1);
-		usleep_range(10000, 15000);
-		/* Ignore return from second gpio, it may not be there */
-		dev->platform_data->gpio1_ctrl(sd, 1);
-		usleep_range(10000, 15000);
-	} else {
-		dev->platform_data->gpio1_ctrl(sd, 0);
-		ret = dev->platform_data->gpio0_ctrl(sd, 0);
-	}
-	return ret;
-}
-
-static int power_up(struct v4l2_subdev *sd)
-{
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	if (!dev->platform_data) {
-		dev_err(&client->dev,
-			"no camera_sensor_platform_data");
-		return -ENODEV;
-	}
-
-	/* power control */
-	ret = power_ctrl(sd, 1);
-	if (ret)
-		goto fail_power;
-
-	/* according to DS, at least 5ms is needed between DOVDD and PWDN */
-	usleep_range(5000, 6000);
-
-	/* gpio ctrl */
-	ret = gpio_ctrl(sd, 1);
-	if (ret) {
-		ret = gpio_ctrl(sd, 1);
-		if (ret)
-			goto fail_power;
-	}
-
-	/* flis clock control */
-	ret = dev->platform_data->flisclk_ctrl(sd, 1);
-	if (ret)
-		goto fail_clk;
-
-	/* according to DS, 20ms is needed between PWDN and i2c access */
-	msleep(20);
-
-	return 0;
-
-fail_clk:
-	gpio_ctrl(sd, 0);
-fail_power:
-	power_ctrl(sd, 0);
-	dev_err(&client->dev, "sensor power-up failed\n");
-
-	return ret;
-}
-
-static int power_down(struct v4l2_subdev *sd)
-{
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	h_flag = 0;
-	v_flag = 0;
-	if (!dev->platform_data) {
-		dev_err(&client->dev,
-			"no camera_sensor_platform_data");
-		return -ENODEV;
-	}
-
-	ret = dev->platform_data->flisclk_ctrl(sd, 0);
-	if (ret)
-		dev_err(&client->dev, "flisclk failed\n");
-
-	/* gpio ctrl */
-	ret = gpio_ctrl(sd, 0);
-	if (ret) {
-		ret = gpio_ctrl(sd, 0);
-		if (ret)
-			dev_err(&client->dev, "gpio failed 2\n");
-	}
-
-	/* power control */
-	ret = power_ctrl(sd, 0);
-	if (ret)
-		dev_err(&client->dev, "vprog failed.\n");
-
-	return ret;
-}
-
-static int ov2680_s_power(struct v4l2_subdev *sd, int on)
-{
-	int ret;
-
-	if (on == 0){
-		ret = power_down(sd);
-	} else {
-		ret = power_up(sd);
-		if (!ret)
-			return ov2680_init(sd);
-	}
-	return ret;
-}
-
-/*
- * distance - calculate the distance
- * @res: resolution
- * @w: width
- * @h: height
- *
- * Get the gap between resolution and w/h.
- * res->width/height smaller than w/h wouldn't be considered.
- * Returns the value of gap or -1 if fail.
- */
-#define LARGEST_ALLOWED_RATIO_MISMATCH 600
-static int distance(struct ov2680_resolution *res, u32 w, u32 h)
-{
-	unsigned int w_ratio = (res->width << 13) / w;
-	unsigned int h_ratio;
-	int match;
-
-	if (h == 0)
-		return -1;
-	h_ratio = (res->height << 13) / h;
-	if (h_ratio == 0)
-		return -1;
-	match   = abs(((w_ratio << 13) / h_ratio) - ((int)8192));
-
-
-	if ((w_ratio < (int)8192) || (h_ratio < (int)8192)  ||
-		(match > LARGEST_ALLOWED_RATIO_MISMATCH))
-		return -1;
-
-	return w_ratio + h_ratio;
-}
-
-/* Return the nearest higher resolution index */
-static int nearest_resolution_index(int w, int h)
-{
-	int i;
-	int idx = -1;
-	int dist;
-	int min_dist = INT_MAX;
-	struct ov2680_resolution *tmp_res = NULL;
-
-	for (i = 0; i < N_RES; i++) {
-		tmp_res = &ov2680_res[i];
-		dist = distance(tmp_res, w, h);
-		if (dist == -1)
-			continue;
-		if (dist < min_dist) {
-			min_dist = dist;
-			idx = i;
-		}
-	}
-
-	return idx;
-}
-
-static int get_resolution_index(int w, int h)
-{
-	int i;
-
-	for (i = 0; i < N_RES; i++) {
-		if (w != ov2680_res[i].width)
-			continue;
-		if (h != ov2680_res[i].height)
-			continue;
-
-		return i;
-	}
-
-	return -1;
-}
-
-static int ov2680_set_fmt(struct v4l2_subdev *sd,
-			  struct v4l2_subdev_pad_config *cfg,
-			  struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct camera_mipi_info *ov2680_info = NULL;
-	int ret = 0;
-	int idx = 0;
-	dev_dbg(&client->dev, "+++++ov2680_s_mbus_fmt+++++l\n");
-	if (format->pad)
-		return -EINVAL;
-
-	if (!fmt)
-		return -EINVAL;
-
-	ov2680_info = v4l2_get_subdev_hostdata(sd);
-	if (!ov2680_info)
-		return -EINVAL;
-
-	mutex_lock(&dev->input_lock);
-	idx = nearest_resolution_index(fmt->width, fmt->height);
-	if (idx == -1) {
-		/* return the largest resolution */
-		fmt->width = ov2680_res[N_RES - 1].width;
-		fmt->height = ov2680_res[N_RES - 1].height;
-	} else {
-		fmt->width = ov2680_res[idx].width;
-		fmt->height = ov2680_res[idx].height;
-	}
-	fmt->code = MEDIA_BUS_FMT_SBGGR10_1X10;
-	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-		cfg->try_fmt = *fmt;
-		mutex_unlock(&dev->input_lock);
-		return 0;
-		}
-	dev->fmt_idx = get_resolution_index(fmt->width, fmt->height);
-	dev_dbg(&client->dev, "+++++get_resolution_index=%d+++++l\n",
-		     dev->fmt_idx);
-	if (dev->fmt_idx == -1) {
-		dev_err(&client->dev, "get resolution fail\n");
-		mutex_unlock(&dev->input_lock);
-		return -EINVAL;
-	}
-	v4l2_info(client, "__s_mbus_fmt i=%d, w=%d, h=%d\n", dev->fmt_idx,
-		  fmt->width, fmt->height);
-	dev_dbg(&client->dev, "__s_mbus_fmt i=%d, w=%d, h=%d\n",
-		     dev->fmt_idx, fmt->width, fmt->height);
-
-	ret = ov2680_write_reg_array(client, ov2680_res[dev->fmt_idx].regs);
-	if (ret)
-		dev_err(&client->dev, "ov2680 write resolution register err\n");
-
-	ret = ov2680_get_intg_factor(client, ov2680_info,
-				     &ov2680_res[dev->fmt_idx]);
-	if (ret) {
-		dev_err(&client->dev, "failed to get integration_factor\n");
-		goto err;
-	}
-
-	/*recall flip functions to avoid flip registers
-	 * were overridden by default setting
-	 */
-	if (h_flag)
-		ov2680_h_flip(sd, h_flag);
-	if (v_flag)
-		ov2680_v_flip(sd, v_flag);
-
-	v4l2_info(client, "\n%s idx %d \n", __func__, dev->fmt_idx);
-
-	/*ret = startup(sd);
-	 * if (ret)
-	 * dev_err(&client->dev, "ov2680 startup err\n");
-	 */
-err:
-	mutex_unlock(&dev->input_lock);
-	return ret;
-}
-
-static int ov2680_get_fmt(struct v4l2_subdev *sd,
-			  struct v4l2_subdev_pad_config *cfg,
-			  struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-
-	if (format->pad)
-		return -EINVAL;
-
-	if (!fmt)
-		return -EINVAL;
-
-	fmt->width = ov2680_res[dev->fmt_idx].width;
-	fmt->height = ov2680_res[dev->fmt_idx].height;
-	fmt->code = MEDIA_BUS_FMT_SBGGR10_1X10;
-
-	return 0;
-}
-
-static int ov2680_detect(struct i2c_client *client)
-{
-	struct i2c_adapter *adapter = client->adapter;
-	u16 high, low;
-	int ret;
-	u16 id;
-	u8 revision;
-
-	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
-		return -ENODEV;
-
-	ret = ov2680_read_reg(client, OV2680_8BIT,
-					OV2680_SC_CMMN_CHIP_ID_H, &high);
-	if (ret) {
-		dev_err(&client->dev, "sensor_id_high = 0x%x\n", high);
-		return -ENODEV;
-	}
-	ret = ov2680_read_reg(client, OV2680_8BIT,
-					OV2680_SC_CMMN_CHIP_ID_L, &low);
-	id = ((((u16) high) << 8) | (u16) low);
-
-	if (id != OV2680_ID) {
-		dev_err(&client->dev, "sensor ID error 0x%x\n", id);
-		return -ENODEV;
-	}
-
-	ret = ov2680_read_reg(client, OV2680_8BIT,
-					OV2680_SC_CMMN_SUB_ID, &high);
-	revision = (u8) high & 0x0f;
-
-	dev_info(&client->dev, "sensor_revision id = 0x%x, rev= %d\n",
-		 id, revision);
-
-	return 0;
-}
-
-static int ov2680_s_stream(struct v4l2_subdev *sd, int enable)
-{
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	mutex_lock(&dev->input_lock);
-	if(enable )
-		dev_dbg(&client->dev, "ov2680_s_stream one \n");
-	else
-		dev_dbg(&client->dev, "ov2680_s_stream off \n");
-
-	ret = ov2680_write_reg(client, OV2680_8BIT, OV2680_SW_STREAM,
-				enable ? OV2680_START_STREAMING :
-				OV2680_STOP_STREAMING);
-#if 0
-	/* restore settings */
-	ov2680_res = ov2680_res_preview;
-	N_RES = N_RES_PREVIEW;
-#endif
-
-	//otp valid at stream on state
-	//if(!dev->otp_data)
-	//	dev->otp_data = ov2680_otp_read(sd);
-
-	mutex_unlock(&dev->input_lock);
-
-	return ret;
-}
-
-
-static int ov2680_s_config(struct v4l2_subdev *sd,
-			   int irq, void *platform_data)
-{
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	if (!platform_data)
-		return -ENODEV;
-
-	dev->platform_data =
-		(struct camera_sensor_platform_data *)platform_data;
-
-	mutex_lock(&dev->input_lock);
-	/* power off the module, then power on it in future
-	 * as first power on by board may not fulfill the
-	 * power on sequqence needed by the module
-	 */
-	ret = power_down(sd);
-	if (ret) {
-		dev_err(&client->dev, "ov2680 power-off err.\n");
-		goto fail_power_off;
-	}
-
-	ret = power_up(sd);
-	if (ret) {
-		dev_err(&client->dev, "ov2680 power-up err.\n");
-		goto fail_power_on;
-	}
-
-	ret = dev->platform_data->csi_cfg(sd, 1);
-	if (ret)
-		goto fail_csi_cfg;
-
-	/* config & detect sensor */
-	ret = ov2680_detect(client);
-	if (ret) {
-		dev_err(&client->dev, "ov2680_detect err s_config.\n");
-		goto fail_csi_cfg;
-	}
-
-	/* turn off sensor, after probed */
-	ret = power_down(sd);
-	if (ret) {
-		dev_err(&client->dev, "ov2680 power-off err.\n");
-		goto fail_csi_cfg;
-	}
-	mutex_unlock(&dev->input_lock);
-
-	return 0;
-
-fail_csi_cfg:
-	dev->platform_data->csi_cfg(sd, 0);
-fail_power_on:
-	power_down(sd);
-	dev_err(&client->dev, "sensor power-gating failed\n");
-fail_power_off:
-	mutex_unlock(&dev->input_lock);
-	return ret;
-}
-
-static int ov2680_g_frame_interval(struct v4l2_subdev *sd,
-				   struct v4l2_subdev_frame_interval *interval)
-{
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-
-	interval->interval.numerator = 1;
-	interval->interval.denominator = ov2680_res[dev->fmt_idx].fps;
-
-	return 0;
-}
-
-static int ov2680_enum_mbus_code(struct v4l2_subdev *sd,
-				 struct v4l2_subdev_pad_config *cfg,
-				 struct v4l2_subdev_mbus_code_enum *code)
-{
-	if (code->index >= MAX_FMTS)
-		return -EINVAL;
-
-	code->code = MEDIA_BUS_FMT_SBGGR10_1X10;
-	return 0;
-}
-
-static int ov2680_enum_frame_size(struct v4l2_subdev *sd,
-				  struct v4l2_subdev_pad_config *cfg,
-				  struct v4l2_subdev_frame_size_enum *fse)
-{
-	int index = fse->index;
-
-	if (index >= N_RES)
-		return -EINVAL;
-
-	fse->min_width = ov2680_res[index].width;
-	fse->min_height = ov2680_res[index].height;
-	fse->max_width = ov2680_res[index].width;
-	fse->max_height = ov2680_res[index].height;
-
-	return 0;
-
-}
-
-static int ov2680_g_skip_frames(struct v4l2_subdev *sd, u32 *frames)
-{
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-
-	mutex_lock(&dev->input_lock);
-	*frames = ov2680_res[dev->fmt_idx].skip_frames;
-	mutex_unlock(&dev->input_lock);
-
-	return 0;
-}
-
-static const struct v4l2_subdev_video_ops ov2680_video_ops = {
-	.s_stream = ov2680_s_stream,
-	.g_frame_interval = ov2680_g_frame_interval,
-};
-
-static const struct v4l2_subdev_sensor_ops ov2680_sensor_ops = {
-		.g_skip_frames	= ov2680_g_skip_frames,
-};
-
-static const struct v4l2_subdev_core_ops ov2680_core_ops = {
-	.s_power = ov2680_s_power,
-	.ioctl = ov2680_ioctl,
-};
-
-static const struct v4l2_subdev_pad_ops ov2680_pad_ops = {
-	.enum_mbus_code = ov2680_enum_mbus_code,
-	.enum_frame_size = ov2680_enum_frame_size,
-	.get_fmt = ov2680_get_fmt,
-	.set_fmt = ov2680_set_fmt,
-};
-
-static const struct v4l2_subdev_ops ov2680_ops = {
-	.core = &ov2680_core_ops,
-	.video = &ov2680_video_ops,
-	.pad = &ov2680_pad_ops,
-	.sensor = &ov2680_sensor_ops,
-};
-
-static int ov2680_remove(struct i2c_client *client)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct ov2680_device *dev = to_ov2680_sensor(sd);
-	dev_dbg(&client->dev, "ov2680_remove...\n");
-
-	dev->platform_data->csi_cfg(sd, 0);
-
-	v4l2_device_unregister_subdev(sd);
-	media_entity_cleanup(&dev->sd.entity);
-	v4l2_ctrl_handler_free(&dev->ctrl_handler);
-	kfree(dev);
-
-	return 0;
-}
-
-static int ov2680_probe(struct i2c_client *client)
-{
-	struct ov2680_device *dev;
-	int ret;
-	void *pdata;
-	unsigned int i;
-
-	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (!dev)
-		return -ENOMEM;
-
-	mutex_init(&dev->input_lock);
-
-	dev->fmt_idx = 0;
-	v4l2_i2c_subdev_init(&(dev->sd), client, &ov2680_ops);
-
-	pdata = gmin_camera_platform_data(&dev->sd,
-					  ATOMISP_INPUT_FORMAT_RAW_10,
-					  atomisp_bayer_order_bggr);
-	if (!pdata) {
-		ret = -EINVAL;
-		goto out_free;
-        }
-
-	ret = ov2680_s_config(&dev->sd, client->irq, pdata);
-	if (ret)
-		goto out_free;
-
-	ret = atomisp_register_i2c_module(&dev->sd, pdata, RAW_CAMERA);
-	if (ret)
-		goto out_free;
-
-	dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	dev->pad.flags = MEDIA_PAD_FL_SOURCE;
-	dev->format.code = MEDIA_BUS_FMT_SBGGR10_1X10;
-	dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
-	ret =
-	    v4l2_ctrl_handler_init(&dev->ctrl_handler,
-				   ARRAY_SIZE(ov2680_controls));
-	if (ret) {
-		ov2680_remove(client);
-		return ret;
-	}
-
-	for (i = 0; i < ARRAY_SIZE(ov2680_controls); i++)
-		v4l2_ctrl_new_custom(&dev->ctrl_handler, &ov2680_controls[i],
-				     NULL);
-
-	if (dev->ctrl_handler.error) {
-		ov2680_remove(client);
-		return dev->ctrl_handler.error;
-	}
-
-	/* Use same lock for controls as for everything else. */
-	dev->ctrl_handler.lock = &dev->input_lock;
-	dev->sd.ctrl_handler = &dev->ctrl_handler;
-
-	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
-	if (ret)
-	{
-		ov2680_remove(client);
-		dev_dbg(&client->dev, "+++ remove ov2680 \n");
-	}
-	return ret;
-out_free:
-	dev_dbg(&client->dev, "+++ out free \n");
-	v4l2_device_unregister_subdev(&dev->sd);
-	kfree(dev);
-	return ret;
-}
-
-static const struct acpi_device_id ov2680_acpi_match[] = {
-	{"XXOV2680"},
-	{"OVTI2680"},
-	{},
-};
-MODULE_DEVICE_TABLE(acpi, ov2680_acpi_match);
-
-static struct i2c_driver ov2680_driver = {
-	.driver = {
-		.name = "ov2680",
-		.acpi_match_table = ov2680_acpi_match,
-	},
-	.probe_new = ov2680_probe,
-	.remove = ov2680_remove,
-};
-module_i2c_driver(ov2680_driver);
-
-MODULE_AUTHOR("Jacky Wang <Jacky_wang@ovt.com>");
-MODULE_DESCRIPTION("A low-level driver for OmniVision 2680 sensors");
-MODULE_LICENSE("GPL");

+ 0 - 1271
drivers/staging/media/atomisp/i2c/atomisp-ov2722.c

@@ -1,1271 +0,0 @@
-/*
- * Support for OmniVision OV2722 1080p HD camera sensor.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/kmod.h>
-#include <linux/device.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/i2c.h>
-#include <linux/moduleparam.h>
-#include <media/v4l2-device.h>
-#include "../include/linux/atomisp_gmin_platform.h"
-#include <linux/acpi.h>
-#include <linux/io.h>
-
-#include "ov2722.h"
-
-/* i2c read/write stuff */
-static int ov2722_read_reg(struct i2c_client *client,
-			   u16 data_length, u16 reg, u16 *val)
-{
-	int err;
-	struct i2c_msg msg[2];
-	unsigned char data[6];
-
-	if (!client->adapter) {
-		dev_err(&client->dev, "%s error, no client->adapter\n",
-			__func__);
-		return -ENODEV;
-	}
-
-	if (data_length != OV2722_8BIT && data_length != OV2722_16BIT
-					&& data_length != OV2722_32BIT) {
-		dev_err(&client->dev, "%s error, invalid data length\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	memset(msg, 0 , sizeof(msg));
-
-	msg[0].addr = client->addr;
-	msg[0].flags = 0;
-	msg[0].len = I2C_MSG_LENGTH;
-	msg[0].buf = data;
-
-	/* high byte goes out first */
-	data[0] = (u8)(reg >> 8);
-	data[1] = (u8)(reg & 0xff);
-
-	msg[1].addr = client->addr;
-	msg[1].len = data_length;
-	msg[1].flags = I2C_M_RD;
-	msg[1].buf = data;
-
-	err = i2c_transfer(client->adapter, msg, 2);
-	if (err != 2) {
-		if (err >= 0)
-			err = -EIO;
-		dev_err(&client->dev,
-			"read from offset 0x%x error %d", reg, err);
-		return err;
-	}
-
-	*val = 0;
-	/* high byte comes first */
-	if (data_length == OV2722_8BIT)
-		*val = (u8)data[0];
-	else if (data_length == OV2722_16BIT)
-		*val = be16_to_cpu(*(__be16 *)&data[0]);
-	else
-		*val = be32_to_cpu(*(__be32 *)&data[0]);
-
-	return 0;
-}
-
-static int ov2722_i2c_write(struct i2c_client *client, u16 len, u8 *data)
-{
-	struct i2c_msg msg;
-	const int num_msg = 1;
-	int ret;
-
-	msg.addr = client->addr;
-	msg.flags = 0;
-	msg.len = len;
-	msg.buf = data;
-	ret = i2c_transfer(client->adapter, &msg, 1);
-
-	return ret == num_msg ? 0 : -EIO;
-}
-
-static int ov2722_write_reg(struct i2c_client *client, u16 data_length,
-							u16 reg, u16 val)
-{
-	int ret;
-	unsigned char data[4] = {0};
-	__be16 *wreg = (__be16 *)data;
-	const u16 len = data_length + sizeof(u16); /* 16-bit address + data */
-
-	if (data_length != OV2722_8BIT && data_length != OV2722_16BIT) {
-		dev_err(&client->dev,
-			"%s error, invalid data_length\n", __func__);
-		return -EINVAL;
-	}
-
-	/* high byte goes out first */
-	*wreg = cpu_to_be16(reg);
-
-	if (data_length == OV2722_8BIT) {
-		data[2] = (u8)(val);
-	} else {
-		/* OV2722_16BIT */
-		__be16 *wdata = (__be16 *)&data[2];
-
-		*wdata = cpu_to_be16(val);
-	}
-
-	ret = ov2722_i2c_write(client, len, data);
-	if (ret)
-		dev_err(&client->dev,
-			"write error: wrote 0x%x to offset 0x%x error %d",
-			val, reg, ret);
-
-	return ret;
-}
-
-/*
- * ov2722_write_reg_array - Initializes a list of OV2722 registers
- * @client: i2c driver client structure
- * @reglist: list of registers to be written
- *
- * This function initializes a list of registers. When consecutive addresses
- * are found in a row on the list, this function creates a buffer and sends
- * consecutive data in a single i2c_transfer().
- *
- * __ov2722_flush_reg_array, __ov2722_buf_reg_array() and
- * __ov2722_write_reg_is_consecutive() are internal functions to
- * ov2722_write_reg_array_fast() and should be not used anywhere else.
- *
- */
-
-static int __ov2722_flush_reg_array(struct i2c_client *client,
-				    struct ov2722_write_ctrl *ctrl)
-{
-	u16 size;
-	__be16 *data16 = (void *)&ctrl->buffer.addr;
-
-	if (ctrl->index == 0)
-		return 0;
-
-	size = sizeof(u16) + ctrl->index; /* 16-bit address + data */
-	*data16 = cpu_to_be16(ctrl->buffer.addr);
-	ctrl->index = 0;
-
-	return ov2722_i2c_write(client, size, (u8 *)&ctrl->buffer);
-}
-
-static int __ov2722_buf_reg_array(struct i2c_client *client,
-				  struct ov2722_write_ctrl *ctrl,
-				  const struct ov2722_reg *next)
-{
-	int size;
-	__be16 *data16;
-
-	switch (next->type) {
-	case OV2722_8BIT:
-		size = 1;
-		ctrl->buffer.data[ctrl->index] = (u8)next->val;
-		break;
-	case OV2722_16BIT:
-		size = 2;
-		data16 = (void *)&ctrl->buffer.data[ctrl->index];
-		*data16 = cpu_to_be16((u16)next->val);
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	/* When first item is added, we need to store its starting address */
-	if (ctrl->index == 0)
-		ctrl->buffer.addr = next->reg;
-
-	ctrl->index += size;
-
-	/*
-	 * Buffer cannot guarantee free space for u32? Better flush it to avoid
-	 * possible lack of memory for next item.
-	 */
-	if (ctrl->index + sizeof(u16) >= OV2722_MAX_WRITE_BUF_SIZE)
-		return __ov2722_flush_reg_array(client, ctrl);
-
-	return 0;
-}
-
-static int __ov2722_write_reg_is_consecutive(struct i2c_client *client,
-					     struct ov2722_write_ctrl *ctrl,
-					     const struct ov2722_reg *next)
-{
-	if (ctrl->index == 0)
-		return 1;
-
-	return ctrl->buffer.addr + ctrl->index == next->reg;
-}
-
-static int ov2722_write_reg_array(struct i2c_client *client,
-				  const struct ov2722_reg *reglist)
-{
-	const struct ov2722_reg *next = reglist;
-	struct ov2722_write_ctrl ctrl;
-	int err;
-
-	ctrl.index = 0;
-	for (; next->type != OV2722_TOK_TERM; next++) {
-		switch (next->type & OV2722_TOK_MASK) {
-		case OV2722_TOK_DELAY:
-			err = __ov2722_flush_reg_array(client, &ctrl);
-			if (err)
-				return err;
-			msleep(next->val);
-			break;
-		default:
-			/*
-			 * If next address is not consecutive, data needs to be
-			 * flushed before proceed.
-			 */
-			if (!__ov2722_write_reg_is_consecutive(client, &ctrl,
-								next)) {
-				err = __ov2722_flush_reg_array(client, &ctrl);
-				if (err)
-					return err;
-			}
-			err = __ov2722_buf_reg_array(client, &ctrl, next);
-			if (err) {
-				dev_err(&client->dev, "%s: write error, aborted\n",
-					 __func__);
-				return err;
-			}
-			break;
-		}
-	}
-
-	return __ov2722_flush_reg_array(client, &ctrl);
-}
-static int ov2722_g_focal(struct v4l2_subdev *sd, s32 *val)
-{
-	*val = (OV2722_FOCAL_LENGTH_NUM << 16) | OV2722_FOCAL_LENGTH_DEM;
-	return 0;
-}
-
-static int ov2722_g_fnumber(struct v4l2_subdev *sd, s32 *val)
-{
-	/*const f number for imx*/
-	*val = (OV2722_F_NUMBER_DEFAULT_NUM << 16) | OV2722_F_NUMBER_DEM;
-	return 0;
-}
-
-static int ov2722_g_fnumber_range(struct v4l2_subdev *sd, s32 *val)
-{
-	*val = (OV2722_F_NUMBER_DEFAULT_NUM << 24) |
-		(OV2722_F_NUMBER_DEM << 16) |
-		(OV2722_F_NUMBER_DEFAULT_NUM << 8) | OV2722_F_NUMBER_DEM;
-	return 0;
-}
-
-static int ov2722_get_intg_factor(struct i2c_client *client,
-				struct camera_mipi_info *info,
-				const struct ov2722_resolution *res)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct ov2722_device *dev = NULL;
-	struct atomisp_sensor_mode_data *buf = &info->data;
-	const unsigned int ext_clk_freq_hz = 19200000;
-	const unsigned int pll_invariant_div = 10;
-	unsigned int pix_clk_freq_hz;
-	u16 pre_pll_clk_div;
-	u16 pll_multiplier;
-	u16 op_pix_clk_div;
-	u16 reg_val;
-	int ret;
-
-	if (!info)
-		return -EINVAL;
-
-	dev = to_ov2722_sensor(sd);
-
-	/* pixel clock calculattion */
-	ret =  ov2722_read_reg(client, OV2722_8BIT,
-				OV2722_SC_CMMN_PLL_CTRL3, &pre_pll_clk_div);
-	if (ret)
-		return ret;
-
-	ret =  ov2722_read_reg(client, OV2722_8BIT,
-				OV2722_SC_CMMN_PLL_MULTIPLIER, &pll_multiplier);
-	if (ret)
-		return ret;
-
-	ret =  ov2722_read_reg(client, OV2722_8BIT,
-				OV2722_SC_CMMN_PLL_DEBUG_OPT, &op_pix_clk_div);
-	if (ret)
-		return ret;
-
-	pre_pll_clk_div = (pre_pll_clk_div & 0x70) >> 4;
-	if (0 == pre_pll_clk_div)
-		return -EINVAL;
-
-	pll_multiplier = pll_multiplier & 0x7f;
-	op_pix_clk_div = op_pix_clk_div & 0x03;
-	pix_clk_freq_hz = ext_clk_freq_hz / pre_pll_clk_div * pll_multiplier
-				* op_pix_clk_div / pll_invariant_div;
-
-	dev->vt_pix_clk_freq_mhz = pix_clk_freq_hz;
-	buf->vt_pix_clk_freq_mhz = pix_clk_freq_hz;
-
-	/* get integration time */
-	buf->coarse_integration_time_min = OV2722_COARSE_INTG_TIME_MIN;
-	buf->coarse_integration_time_max_margin =
-					OV2722_COARSE_INTG_TIME_MAX_MARGIN;
-
-	buf->fine_integration_time_min = OV2722_FINE_INTG_TIME_MIN;
-	buf->fine_integration_time_max_margin =
-					OV2722_FINE_INTG_TIME_MAX_MARGIN;
-
-	buf->fine_integration_time_def = OV2722_FINE_INTG_TIME_MIN;
-	buf->frame_length_lines = res->lines_per_frame;
-	buf->line_length_pck = res->pixels_per_line;
-	buf->read_mode = res->bin_mode;
-
-	/* get the cropping and output resolution to ISP for this mode. */
-	ret =  ov2722_read_reg(client, OV2722_16BIT,
-					OV2722_H_CROP_START_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_horizontal_start = reg_val;
-
-	ret =  ov2722_read_reg(client, OV2722_16BIT,
-					OV2722_V_CROP_START_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_vertical_start = reg_val;
-
-	ret = ov2722_read_reg(client, OV2722_16BIT,
-					OV2722_H_CROP_END_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_horizontal_end = reg_val;
-
-	ret = ov2722_read_reg(client, OV2722_16BIT,
-					OV2722_V_CROP_END_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_vertical_end = reg_val;
-
-	ret = ov2722_read_reg(client, OV2722_16BIT,
-					OV2722_H_OUTSIZE_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->output_width = reg_val;
-
-	ret = ov2722_read_reg(client, OV2722_16BIT,
-					OV2722_V_OUTSIZE_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->output_height = reg_val;
-
-	buf->binning_factor_x = res->bin_factor_x ?
-					res->bin_factor_x : 1;
-	buf->binning_factor_y = res->bin_factor_y ?
-					res->bin_factor_y : 1;
-	return 0;
-}
-
-static long __ov2722_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
-				 int gain, int digitgain)
-
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-	u16 hts, vts;
-	int ret;
-
-	dev_dbg(&client->dev, "set_exposure without group hold\n");
-
-	/* clear VTS_DIFF on manual mode */
-	ret = ov2722_write_reg(client, OV2722_16BIT, OV2722_VTS_DIFF_H, 0);
-	if (ret)
-		return ret;
-
-	hts = dev->pixels_per_line;
-	vts = dev->lines_per_frame;
-
-	if ((coarse_itg + OV2722_COARSE_INTG_TIME_MAX_MARGIN) > vts)
-		vts = coarse_itg + OV2722_COARSE_INTG_TIME_MAX_MARGIN;
-
-	coarse_itg <<= 4;
-	digitgain <<= 2;
-
-	ret = ov2722_write_reg(client, OV2722_16BIT,
-				OV2722_VTS_H, vts);
-	if (ret)
-		return ret;
-
-	ret = ov2722_write_reg(client, OV2722_16BIT,
-				OV2722_HTS_H, hts);
-	if (ret)
-		return ret;
-
-	/* set exposure */
-	ret = ov2722_write_reg(client, OV2722_8BIT,
-					OV2722_AEC_PK_EXPO_L,
-					coarse_itg & 0xff);
-	if (ret)
-		return ret;
-
-	ret = ov2722_write_reg(client, OV2722_16BIT,
-					OV2722_AEC_PK_EXPO_H,
-					(coarse_itg >> 8) & 0xfff);
-	if (ret)
-		return ret;
-
-	/* set analog gain */
-	ret = ov2722_write_reg(client, OV2722_16BIT,
-					OV2722_AGC_ADJ_H, gain);
-	if (ret)
-		return ret;
-
-	/* set digital gain */
-	ret = ov2722_write_reg(client, OV2722_16BIT,
-				OV2722_MWB_GAIN_R_H, digitgain);
-	if (ret)
-		return ret;
-
-	ret = ov2722_write_reg(client, OV2722_16BIT,
-				OV2722_MWB_GAIN_G_H, digitgain);
-	if (ret)
-		return ret;
-
-	ret = ov2722_write_reg(client, OV2722_16BIT,
-				OV2722_MWB_GAIN_B_H, digitgain);
-
-	return ret;
-}
-
-static int ov2722_set_exposure(struct v4l2_subdev *sd, int exposure,
-	int gain, int digitgain)
-{
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-	int ret;
-
-	mutex_lock(&dev->input_lock);
-	ret = __ov2722_set_exposure(sd, exposure, gain, digitgain);
-	mutex_unlock(&dev->input_lock);
-
-	return ret;
-}
-
-static long ov2722_s_exposure(struct v4l2_subdev *sd,
-			       struct atomisp_exposure *exposure)
-{
-	int exp = exposure->integration_time[0];
-	int gain = exposure->gain[0];
-	int digitgain = exposure->gain[1];
-
-	/* we should not accept the invalid value below. */
-	if (gain == 0) {
-		struct i2c_client *client = v4l2_get_subdevdata(sd);
-		v4l2_err(client, "%s: invalid value\n", __func__);
-		return -EINVAL;
-	}
-
-	return ov2722_set_exposure(sd, exp, gain, digitgain);
-}
-
-static long ov2722_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
-{
-
-	switch (cmd) {
-	case ATOMISP_IOC_S_EXPOSURE:
-		return ov2722_s_exposure(sd, arg);
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
-
-/* This returns the exposure time being used. This should only be used
- * for filling in EXIF data, not for actual image processing.
- */
-static int ov2722_q_exposure(struct v4l2_subdev *sd, s32 *value)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	u16 reg_v, reg_v2;
-	int ret;
-
-	/* get exposure */
-	ret = ov2722_read_reg(client, OV2722_8BIT,
-					OV2722_AEC_PK_EXPO_L,
-					&reg_v);
-	if (ret)
-		goto err;
-
-	ret = ov2722_read_reg(client, OV2722_8BIT,
-					OV2722_AEC_PK_EXPO_M,
-					&reg_v2);
-	if (ret)
-		goto err;
-
-	reg_v += reg_v2 << 8;
-	ret = ov2722_read_reg(client, OV2722_8BIT,
-					OV2722_AEC_PK_EXPO_H,
-					&reg_v2);
-	if (ret)
-		goto err;
-
-	*value = reg_v + (((u32)reg_v2 << 16));
-err:
-	return ret;
-}
-
-static int ov2722_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct ov2722_device *dev =
-	    container_of(ctrl->handler, struct ov2722_device, ctrl_handler);
-	int ret = 0;
-	unsigned int val;
-	switch (ctrl->id) {
-	case V4L2_CID_EXPOSURE_ABSOLUTE:
-		ret = ov2722_q_exposure(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FOCAL_ABSOLUTE:
-		ret = ov2722_g_focal(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FNUMBER_ABSOLUTE:
-		ret = ov2722_g_fnumber(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FNUMBER_RANGE:
-		ret = ov2722_g_fnumber_range(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_LINK_FREQ:
-		val = ov2722_res[dev->fmt_idx].mipi_freq;
-		if (val == 0)
-			return -EINVAL;
-
-		ctrl->val = val * 1000;	/* To Hz */
-		break;
-	default:
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static const struct v4l2_ctrl_ops ctrl_ops = {
-	.g_volatile_ctrl = ov2722_g_volatile_ctrl
-};
-
-static const struct v4l2_ctrl_config ov2722_controls[] = {
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_EXPOSURE_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "exposure",
-	 .min = 0x0,
-	 .max = 0xffff,
-	 .step = 0x01,
-	 .def = 0x00,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FOCAL_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "focal length",
-	 .min = OV2722_FOCAL_LENGTH_DEFAULT,
-	 .max = OV2722_FOCAL_LENGTH_DEFAULT,
-	 .step = 0x01,
-	 .def = OV2722_FOCAL_LENGTH_DEFAULT,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FNUMBER_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "f-number",
-	 .min = OV2722_F_NUMBER_DEFAULT,
-	 .max = OV2722_F_NUMBER_DEFAULT,
-	 .step = 0x01,
-	 .def = OV2722_F_NUMBER_DEFAULT,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FNUMBER_RANGE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "f-number range",
-	 .min = OV2722_F_NUMBER_RANGE,
-	 .max = OV2722_F_NUMBER_RANGE,
-	 .step = 0x01,
-	 .def = OV2722_F_NUMBER_RANGE,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_LINK_FREQ,
-	 .name = "Link Frequency",
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .min = 1,
-	 .max = 1500000 * 1000,
-	 .step = 1,
-	 .def = 1,
-	 .flags = V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY,
-	 },
-};
-
-static int ov2722_init(struct v4l2_subdev *sd)
-{
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-
-	mutex_lock(&dev->input_lock);
-
-	/* restore settings */
-	ov2722_res = ov2722_res_preview;
-	N_RES = N_RES_PREVIEW;
-
-	mutex_unlock(&dev->input_lock);
-
-	return 0;
-}
-
-static int power_ctrl(struct v4l2_subdev *sd, bool flag)
-{
-	int ret = -1;
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-
-	if (!dev || !dev->platform_data)
-		return -ENODEV;
-
-	if (flag) {
-		ret = dev->platform_data->v1p8_ctrl(sd, 1);
-		if (ret == 0) {
-			ret = dev->platform_data->v2p8_ctrl(sd, 1);
-			if (ret)
-				dev->platform_data->v1p8_ctrl(sd, 0);
-		}
-	} else {
-		ret = dev->platform_data->v1p8_ctrl(sd, 0);
-		ret |= dev->platform_data->v2p8_ctrl(sd, 0);
-	}
-
-	return ret;
-}
-
-static int gpio_ctrl(struct v4l2_subdev *sd, bool flag)
-{
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-	int ret = -1;
-
-	if (!dev || !dev->platform_data)
-		return -ENODEV;
-
-	/* Note: the GPIO order is asymmetric: always RESET#
-	 * before PWDN# when turning it on or off.
-	 */
-	ret = dev->platform_data->gpio0_ctrl(sd, flag);
-	/*
-	 *ov2722 PWDN# active high when pull down,opposite to the convention
-	 */
-	ret |= dev->platform_data->gpio1_ctrl(sd, !flag);
-	return ret;
-}
-
-static int power_up(struct v4l2_subdev *sd)
-{
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	if (!dev->platform_data) {
-		dev_err(&client->dev,
-			"no camera_sensor_platform_data");
-		return -ENODEV;
-	}
-
-	/* power control */
-	ret = power_ctrl(sd, 1);
-	if (ret)
-		goto fail_power;
-
-	/* according to DS, at least 5ms is needed between DOVDD and PWDN */
-	usleep_range(5000, 6000);
-
-	/* gpio ctrl */
-	ret = gpio_ctrl(sd, 1);
-	if (ret) {
-		ret = gpio_ctrl(sd, 0);
-		if (ret)
-			goto fail_power;
-	}
-
-	/* flis clock control */
-	ret = dev->platform_data->flisclk_ctrl(sd, 1);
-	if (ret)
-		goto fail_clk;
-
-	/* according to DS, 20ms is needed between PWDN and i2c access */
-	msleep(20);
-
-	return 0;
-
-fail_clk:
-	gpio_ctrl(sd, 0);
-fail_power:
-	power_ctrl(sd, 0);
-	dev_err(&client->dev, "sensor power-up failed\n");
-
-	return ret;
-}
-
-static int power_down(struct v4l2_subdev *sd)
-{
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	if (!dev->platform_data) {
-		dev_err(&client->dev,
-			"no camera_sensor_platform_data");
-		return -ENODEV;
-	}
-
-	ret = dev->platform_data->flisclk_ctrl(sd, 0);
-	if (ret)
-		dev_err(&client->dev, "flisclk failed\n");
-
-	/* gpio ctrl */
-	ret = gpio_ctrl(sd, 0);
-	if (ret) {
-		ret = gpio_ctrl(sd, 0);
-		if (ret)
-			dev_err(&client->dev, "gpio failed 2\n");
-	}
-
-	/* power control */
-	ret = power_ctrl(sd, 0);
-	if (ret)
-		dev_err(&client->dev, "vprog failed.\n");
-
-	return ret;
-}
-
-static int ov2722_s_power(struct v4l2_subdev *sd, int on)
-{
-	int ret;
-	if (on == 0)
-		return power_down(sd);
-	else {
-		ret = power_up(sd);
-		if (!ret)
-			return ov2722_init(sd);
-	}
-	return ret;
-}
-
-/*
- * distance - calculate the distance
- * @res: resolution
- * @w: width
- * @h: height
- *
- * Get the gap between resolution and w/h.
- * res->width/height smaller than w/h wouldn't be considered.
- * Returns the value of gap or -1 if fail.
- */
-#define LARGEST_ALLOWED_RATIO_MISMATCH 800
-static int distance(struct ov2722_resolution *res, u32 w, u32 h)
-{
-	unsigned int w_ratio = (res->width << 13) / w;
-	unsigned int h_ratio;
-	int match;
-
-	if (h == 0)
-		return -1;
-	h_ratio = (res->height << 13) / h;
-	if (h_ratio == 0)
-		return -1;
-	match   = abs(((w_ratio << 13) / h_ratio) - 8192);
-
-	if ((w_ratio < 8192) || (h_ratio < 8192) ||
-	    (match > LARGEST_ALLOWED_RATIO_MISMATCH))
-		return -1;
-
-	return w_ratio + h_ratio;
-}
-
-/* Return the nearest higher resolution index */
-static int nearest_resolution_index(int w, int h)
-{
-	int i;
-	int idx = -1;
-	int dist;
-	int min_dist = INT_MAX;
-	struct ov2722_resolution *tmp_res = NULL;
-
-	for (i = 0; i < N_RES; i++) {
-		tmp_res = &ov2722_res[i];
-		dist = distance(tmp_res, w, h);
-		if (dist == -1)
-			continue;
-		if (dist < min_dist) {
-			min_dist = dist;
-			idx = i;
-		}
-	}
-
-	return idx;
-}
-
-static int get_resolution_index(int w, int h)
-{
-	int i;
-
-	for (i = 0; i < N_RES; i++) {
-		if (w != ov2722_res[i].width)
-			continue;
-		if (h != ov2722_res[i].height)
-			continue;
-
-		return i;
-	}
-
-	return -1;
-}
-
-/* TODO: remove it. */
-static int startup(struct v4l2_subdev *sd)
-{
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	ret = ov2722_write_reg(client, OV2722_8BIT,
-					OV2722_SW_RESET, 0x01);
-	if (ret) {
-		dev_err(&client->dev, "ov2722 reset err.\n");
-		return ret;
-	}
-
-	ret = ov2722_write_reg_array(client, ov2722_res[dev->fmt_idx].regs);
-	if (ret) {
-		dev_err(&client->dev, "ov2722 write register err.\n");
-		return ret;
-	}
-
-	return ret;
-}
-
-static int ov2722_set_fmt(struct v4l2_subdev *sd,
-			  struct v4l2_subdev_pad_config *cfg,
-			  struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct camera_mipi_info *ov2722_info = NULL;
-	int ret = 0;
-	int idx;
-	if (format->pad)
-		return -EINVAL;
-	if (!fmt)
-		return -EINVAL;
-	ov2722_info = v4l2_get_subdev_hostdata(sd);
-	if (!ov2722_info)
-		return -EINVAL;
-
-	mutex_lock(&dev->input_lock);
-	idx = nearest_resolution_index(fmt->width, fmt->height);
-	if (idx == -1) {
-		/* return the largest resolution */
-		fmt->width = ov2722_res[N_RES - 1].width;
-		fmt->height = ov2722_res[N_RES - 1].height;
-	} else {
-		fmt->width = ov2722_res[idx].width;
-		fmt->height = ov2722_res[idx].height;
-	}
-	fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
-	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-		cfg->try_fmt = *fmt;
-		mutex_unlock(&dev->input_lock);
-		return 0;
-	}
-
-	dev->fmt_idx = get_resolution_index(fmt->width, fmt->height);
-	if (dev->fmt_idx == -1) {
-		dev_err(&client->dev, "get resolution fail\n");
-		mutex_unlock(&dev->input_lock);
-		return -EINVAL;
-	}
-
-	dev->pixels_per_line = ov2722_res[dev->fmt_idx].pixels_per_line;
-	dev->lines_per_frame = ov2722_res[dev->fmt_idx].lines_per_frame;
-
-	ret = startup(sd);
-	if (ret) {
-		int i = 0;
-		dev_err(&client->dev, "ov2722 startup err, retry to power up\n");
-		for (i = 0; i < OV2722_POWER_UP_RETRY_NUM; i++) {
-			dev_err(&client->dev,
-				"ov2722 retry to power up %d/%d times, result: ",
-				i + 1, OV2722_POWER_UP_RETRY_NUM);
-			power_down(sd);
-			ret = power_up(sd);
-			if (ret) {
-				dev_err(&client->dev, "power up failed, continue\n");
-				continue;
-			}
-			ret = startup(sd);
-			if (ret) {
-				dev_err(&client->dev, " startup FAILED!\n");
-			} else {
-				dev_err(&client->dev, " startup SUCCESS!\n");
-				break;
-			}
-		}
-		if (ret) {
-			dev_err(&client->dev, "ov2722 startup err\n");
-			goto err;
-		}
-	}
-
-	ret = ov2722_get_intg_factor(client, ov2722_info,
-					&ov2722_res[dev->fmt_idx]);
-	if (ret)
-		dev_err(&client->dev, "failed to get integration_factor\n");
-
-err:
-	mutex_unlock(&dev->input_lock);
-	return ret;
-}
-static int ov2722_get_fmt(struct v4l2_subdev *sd,
-			  struct v4l2_subdev_pad_config *cfg,
-			  struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-
-	if (format->pad)
-		return -EINVAL;
-	if (!fmt)
-		return -EINVAL;
-
-	fmt->width = ov2722_res[dev->fmt_idx].width;
-	fmt->height = ov2722_res[dev->fmt_idx].height;
-	fmt->code = MEDIA_BUS_FMT_SBGGR10_1X10;
-
-	return 0;
-}
-
-static int ov2722_detect(struct i2c_client *client)
-{
-	struct i2c_adapter *adapter = client->adapter;
-	u16 high, low;
-	int ret;
-	u16 id;
-	u8 revision;
-
-	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
-		return -ENODEV;
-
-	ret = ov2722_read_reg(client, OV2722_8BIT,
-					OV2722_SC_CMMN_CHIP_ID_H, &high);
-	if (ret) {
-		dev_err(&client->dev, "sensor_id_high = 0x%x\n", high);
-		return -ENODEV;
-	}
-	ret = ov2722_read_reg(client, OV2722_8BIT,
-					OV2722_SC_CMMN_CHIP_ID_L, &low);
-	id = (high << 8) | low;
-
-	if ((id != OV2722_ID) && (id != OV2720_ID)) {
-		dev_err(&client->dev, "sensor ID error\n");
-		return -ENODEV;
-	}
-
-	ret = ov2722_read_reg(client, OV2722_8BIT,
-					OV2722_SC_CMMN_SUB_ID, &high);
-	revision = (u8) high & 0x0f;
-
-	dev_dbg(&client->dev, "sensor_revision = 0x%x\n", revision);
-	dev_dbg(&client->dev, "detect ov2722 success\n");
-	return 0;
-}
-
-static int ov2722_s_stream(struct v4l2_subdev *sd, int enable)
-{
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	mutex_lock(&dev->input_lock);
-
-	ret = ov2722_write_reg(client, OV2722_8BIT, OV2722_SW_STREAM,
-				enable ? OV2722_START_STREAMING :
-				OV2722_STOP_STREAMING);
-
-	mutex_unlock(&dev->input_lock);
-	return ret;
-}
-
-static int ov2722_s_config(struct v4l2_subdev *sd,
-			   int irq, void *platform_data)
-{
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	if (!platform_data)
-		return -ENODEV;
-
-	dev->platform_data =
-		(struct camera_sensor_platform_data *)platform_data;
-
-	mutex_lock(&dev->input_lock);
-
-	/* power off the module, then power on it in future
-	 * as first power on by board may not fulfill the
-	 * power on sequqence needed by the module
-	 */
-	ret = power_down(sd);
-	if (ret) {
-		dev_err(&client->dev, "ov2722 power-off err.\n");
-		goto fail_power_off;
-	}
-
-	ret = power_up(sd);
-	if (ret) {
-		dev_err(&client->dev, "ov2722 power-up err.\n");
-		goto fail_power_on;
-	}
-
-	ret = dev->platform_data->csi_cfg(sd, 1);
-	if (ret)
-		goto fail_csi_cfg;
-
-	/* config & detect sensor */
-	ret = ov2722_detect(client);
-	if (ret) {
-		dev_err(&client->dev, "ov2722_detect err s_config.\n");
-		goto fail_csi_cfg;
-	}
-
-	/* turn off sensor, after probed */
-	ret = power_down(sd);
-	if (ret) {
-		dev_err(&client->dev, "ov2722 power-off err.\n");
-		goto fail_csi_cfg;
-	}
-	mutex_unlock(&dev->input_lock);
-
-	return 0;
-
-fail_csi_cfg:
-	dev->platform_data->csi_cfg(sd, 0);
-fail_power_on:
-	power_down(sd);
-	dev_err(&client->dev, "sensor power-gating failed\n");
-fail_power_off:
-	mutex_unlock(&dev->input_lock);
-	return ret;
-}
-
-static int ov2722_g_frame_interval(struct v4l2_subdev *sd,
-				   struct v4l2_subdev_frame_interval *interval)
-{
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-
-	interval->interval.numerator = 1;
-	interval->interval.denominator = ov2722_res[dev->fmt_idx].fps;
-
-	return 0;
-}
-
-static int ov2722_enum_mbus_code(struct v4l2_subdev *sd,
-				 struct v4l2_subdev_pad_config *cfg,
-				 struct v4l2_subdev_mbus_code_enum *code)
-{
-	if (code->index >= MAX_FMTS)
-		return -EINVAL;
-
-	code->code = MEDIA_BUS_FMT_SBGGR10_1X10;
-	return 0;
-}
-
-static int ov2722_enum_frame_size(struct v4l2_subdev *sd,
-				  struct v4l2_subdev_pad_config *cfg,
-				  struct v4l2_subdev_frame_size_enum *fse)
-{
-	int index = fse->index;
-
-	if (index >= N_RES)
-		return -EINVAL;
-
-	fse->min_width = ov2722_res[index].width;
-	fse->min_height = ov2722_res[index].height;
-	fse->max_width = ov2722_res[index].width;
-	fse->max_height = ov2722_res[index].height;
-
-	return 0;
-
-}
-
-
-static int ov2722_g_skip_frames(struct v4l2_subdev *sd, u32 *frames)
-{
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-
-	mutex_lock(&dev->input_lock);
-	*frames = ov2722_res[dev->fmt_idx].skip_frames;
-	mutex_unlock(&dev->input_lock);
-
-	return 0;
-}
-
-static const struct v4l2_subdev_sensor_ops ov2722_sensor_ops = {
-	.g_skip_frames	= ov2722_g_skip_frames,
-};
-
-static const struct v4l2_subdev_video_ops ov2722_video_ops = {
-	.s_stream = ov2722_s_stream,
-	.g_frame_interval = ov2722_g_frame_interval,
-};
-
-static const struct v4l2_subdev_core_ops ov2722_core_ops = {
-	.s_power = ov2722_s_power,
-	.ioctl = ov2722_ioctl,
-};
-
-static const struct v4l2_subdev_pad_ops ov2722_pad_ops = {
-	.enum_mbus_code = ov2722_enum_mbus_code,
-	.enum_frame_size = ov2722_enum_frame_size,
-	.get_fmt = ov2722_get_fmt,
-	.set_fmt = ov2722_set_fmt,
-};
-
-static const struct v4l2_subdev_ops ov2722_ops = {
-	.core = &ov2722_core_ops,
-	.video = &ov2722_video_ops,
-	.pad = &ov2722_pad_ops,
-	.sensor = &ov2722_sensor_ops,
-};
-
-static int ov2722_remove(struct i2c_client *client)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct ov2722_device *dev = to_ov2722_sensor(sd);
-	dev_dbg(&client->dev, "ov2722_remove...\n");
-
-	dev->platform_data->csi_cfg(sd, 0);
-	v4l2_ctrl_handler_free(&dev->ctrl_handler);
-	v4l2_device_unregister_subdev(sd);
-
-	atomisp_gmin_remove_subdev(sd);
-
-	media_entity_cleanup(&dev->sd.entity);
-	kfree(dev);
-
-	return 0;
-}
-
-static int __ov2722_init_ctrl_handler(struct ov2722_device *dev)
-{
-	struct v4l2_ctrl_handler *hdl;
-	unsigned int i;
-	hdl = &dev->ctrl_handler;
-	v4l2_ctrl_handler_init(&dev->ctrl_handler, ARRAY_SIZE(ov2722_controls));
-	for (i = 0; i < ARRAY_SIZE(ov2722_controls); i++)
-		v4l2_ctrl_new_custom(&dev->ctrl_handler, &ov2722_controls[i],
-				     NULL);
-
-	dev->link_freq = v4l2_ctrl_find(&dev->ctrl_handler, V4L2_CID_LINK_FREQ);
-
-	if (dev->ctrl_handler.error || !dev->link_freq)
-		return dev->ctrl_handler.error;
-
-	dev->sd.ctrl_handler = hdl;
-
-	return 0;
-}
-
-static int ov2722_probe(struct i2c_client *client)
-{
-	struct ov2722_device *dev;
-	void *ovpdev;
-	int ret;
-
-	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (!dev)
-		return -ENOMEM;
-
-	mutex_init(&dev->input_lock);
-
-	dev->fmt_idx = 0;
-	v4l2_i2c_subdev_init(&(dev->sd), client, &ov2722_ops);
-
-	ovpdev = gmin_camera_platform_data(&dev->sd,
-					   ATOMISP_INPUT_FORMAT_RAW_10,
-					   atomisp_bayer_order_grbg);
-
-	ret = ov2722_s_config(&dev->sd, client->irq, ovpdev);
-	if (ret)
-		goto out_free;
-
-	ret = __ov2722_init_ctrl_handler(dev);
-	if (ret)
-		goto out_ctrl_handler_free;
-
-	dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	dev->pad.flags = MEDIA_PAD_FL_SOURCE;
-	dev->format.code = MEDIA_BUS_FMT_SBGGR10_1X10;
-	dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
-
-	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
-	if (ret)
-		ov2722_remove(client);
-
-	return atomisp_register_i2c_module(&dev->sd, ovpdev, RAW_CAMERA);
-
-out_ctrl_handler_free:
-	v4l2_ctrl_handler_free(&dev->ctrl_handler);
-
-out_free:
-	v4l2_device_unregister_subdev(&dev->sd);
-	kfree(dev);
-	return ret;
-}
-
-static const struct acpi_device_id ov2722_acpi_match[] = {
-	{ "INT33FB" },
-	{},
-};
-MODULE_DEVICE_TABLE(acpi, ov2722_acpi_match);
-
-static struct i2c_driver ov2722_driver = {
-	.driver = {
-		.name = "ov2722",
-		.acpi_match_table = ov2722_acpi_match,
-	},
-	.probe_new = ov2722_probe,
-	.remove = ov2722_remove,
-};
-module_i2c_driver(ov2722_driver);
-
-MODULE_AUTHOR("Wei Liu <wei.liu@intel.com>");
-MODULE_DESCRIPTION("A low-level driver for OmniVision 2722 sensors");
-MODULE_LICENSE("GPL");

+ 0 - 404
drivers/staging/media/atomisp/i2c/gc0310.h

@@ -1,404 +0,0 @@
-/*
- * Support for GalaxyCore GC0310 VGA camera sensor.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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 __GC0310_H__
-#define __GC0310_H__
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/acpi.h>
-#include <linux/delay.h>
-#include <linux/videodev2.h>
-#include <linux/spinlock.h>
-#include <media/v4l2-subdev.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-ctrls.h>
-#include <linux/v4l2-mediabus.h>
-#include <media/media-entity.h>
-
-#include "../include/linux/atomisp_platform.h"
-
-/* Defines for register writes and register array processing */
-#define I2C_MSG_LENGTH		1
-#define I2C_RETRY_COUNT		5
-
-#define GC0310_FOCAL_LENGTH_NUM	278	/*2.78mm*/
-#define GC0310_FOCAL_LENGTH_DEM	100
-#define GC0310_F_NUMBER_DEFAULT_NUM	26
-#define GC0310_F_NUMBER_DEM	10
-
-#define MAX_FMTS		1
-
-/*
- * focal length bits definition:
- * bits 31-16: numerator, bits 15-0: denominator
- */
-#define GC0310_FOCAL_LENGTH_DEFAULT 0x1160064
-
-/*
- * current f-number bits definition:
- * bits 31-16: numerator, bits 15-0: denominator
- */
-#define GC0310_F_NUMBER_DEFAULT 0x1a000a
-
-/*
- * f-number range bits definition:
- * bits 31-24: max f-number numerator
- * bits 23-16: max f-number denominator
- * bits 15-8: min f-number numerator
- * bits 7-0: min f-number denominator
- */
-#define GC0310_F_NUMBER_RANGE 0x1a0a1a0a
-#define GC0310_ID	0xa310
-
-#define GC0310_RESET_RELATED		0xFE
-#define GC0310_REGISTER_PAGE_0		0x0
-#define GC0310_REGISTER_PAGE_3		0x3
-
-#define GC0310_FINE_INTG_TIME_MIN 0
-#define GC0310_FINE_INTG_TIME_MAX_MARGIN 0
-#define GC0310_COARSE_INTG_TIME_MIN 1
-#define GC0310_COARSE_INTG_TIME_MAX_MARGIN 6
-
-/*
- * GC0310 System control registers
- */
-#define GC0310_SW_STREAM			0x10
-
-#define GC0310_SC_CMMN_CHIP_ID_H		0xf0
-#define GC0310_SC_CMMN_CHIP_ID_L		0xf1
-
-#define GC0310_AEC_PK_EXPO_H			0x03
-#define GC0310_AEC_PK_EXPO_L			0x04
-#define GC0310_AGC_ADJ			0x48
-#define GC0310_DGC_ADJ			0x71
-#if 0
-#define GC0310_GROUP_ACCESS			0x3208
-#endif
-
-#define GC0310_H_CROP_START_H			0x09
-#define GC0310_H_CROP_START_L			0x0A
-#define GC0310_V_CROP_START_H			0x0B
-#define GC0310_V_CROP_START_L			0x0C
-#define GC0310_H_OUTSIZE_H			0x0F
-#define GC0310_H_OUTSIZE_L			0x10
-#define GC0310_V_OUTSIZE_H			0x0D
-#define GC0310_V_OUTSIZE_L			0x0E
-#define GC0310_H_BLANKING_H			0x05
-#define GC0310_H_BLANKING_L			0x06
-#define GC0310_V_BLANKING_H			0x07
-#define GC0310_V_BLANKING_L			0x08
-#define GC0310_SH_DELAY			0x11
-
-#define GC0310_START_STREAMING			0x94 /* 8-bit enable */
-#define GC0310_STOP_STREAMING			0x0 /* 8-bit disable */
-
-#define GC0310_BIN_FACTOR_MAX			3
-
-struct regval_list {
-	u16 reg_num;
-	u8 value;
-};
-
-struct gc0310_resolution {
-	u8 *desc;
-	const struct gc0310_reg *regs;
-	int res;
-	int width;
-	int height;
-	int fps;
-	int pix_clk_freq;
-	u32 skip_frames;
-	u16 pixels_per_line;
-	u16 lines_per_frame;
-	u8 bin_factor_x;
-	u8 bin_factor_y;
-	u8 bin_mode;
-	bool used;
-};
-
-struct gc0310_format {
-	u8 *desc;
-	u32 pixelformat;
-	struct gc0310_reg *regs;
-};
-
-/*
- * gc0310 device structure.
- */
-struct gc0310_device {
-	struct v4l2_subdev sd;
-	struct media_pad pad;
-	struct v4l2_mbus_framefmt format;
-	struct mutex input_lock;
-	struct v4l2_ctrl_handler ctrl_handler;
-
-	struct camera_sensor_platform_data *platform_data;
-	int vt_pix_clk_freq_mhz;
-	int fmt_idx;
-	u8 res;
-	u8 type;
-};
-
-enum gc0310_tok_type {
-	GC0310_8BIT  = 0x0001,
-	GC0310_TOK_TERM   = 0xf000,	/* terminating token for reg list */
-	GC0310_TOK_DELAY  = 0xfe00,	/* delay token for reg list */
-	GC0310_TOK_MASK = 0xfff0
-};
-
-/**
- * struct gc0310_reg - MI sensor  register format
- * @type: type of the register
- * @reg: 16-bit offset to register
- * @val: 8/16/32-bit register value
- *
- * Define a structure for sensor register initialization values
- */
-struct gc0310_reg {
-	enum gc0310_tok_type type;
-	u8 reg;
-	u8 val;	/* @set value for read/mod/write, @mask */
-};
-
-#define to_gc0310_sensor(x) container_of(x, struct gc0310_device, sd)
-
-#define GC0310_MAX_WRITE_BUF_SIZE	30
-
-struct gc0310_write_buffer {
-	u8 addr;
-	u8 data[GC0310_MAX_WRITE_BUF_SIZE];
-};
-
-struct gc0310_write_ctrl {
-	int index;
-	struct gc0310_write_buffer buffer;
-};
-
-/*
- * Register settings for various resolution
- */
-static const struct gc0310_reg gc0310_reset_register[] = {
-/////////////////////////////////////////////////
-/////////////////	system reg	/////////////////
-/////////////////////////////////////////////////
-	{GC0310_8BIT, 0xfe, 0xf0},
-	{GC0310_8BIT, 0xfe, 0xf0},
-	{GC0310_8BIT, 0xfe, 0x00},
-
-	{GC0310_8BIT, 0xfc, 0x0e}, //4e
-	{GC0310_8BIT, 0xfc, 0x0e}, //16//4e // [0]apwd [6]regf_clk_gate
-	{GC0310_8BIT, 0xf2, 0x80}, //sync output
-	{GC0310_8BIT, 0xf3, 0x00}, //1f//01 data output
-	{GC0310_8BIT, 0xf7, 0x33}, //f9
-	{GC0310_8BIT, 0xf8, 0x05}, //00
-	{GC0310_8BIT, 0xf9, 0x0e}, // 0x8e //0f
-	{GC0310_8BIT, 0xfa, 0x11},
-
-/////////////////////////////////////////////////
-///////////////////   MIPI	 ////////////////////
-/////////////////////////////////////////////////
-	{GC0310_8BIT, 0xfe, 0x03},
-	{GC0310_8BIT, 0x01, 0x03}, ///mipi 1lane
-	{GC0310_8BIT, 0x02, 0x22}, // 0x33
-	{GC0310_8BIT, 0x03, 0x94},
-	{GC0310_8BIT, 0x04, 0x01}, // fifo_prog
-	{GC0310_8BIT, 0x05, 0x00}, //fifo_prog
-	{GC0310_8BIT, 0x06, 0x80}, //b0  //YUV ISP data
-	{GC0310_8BIT, 0x11, 0x2a},//1e //LDI set YUV422
-	{GC0310_8BIT, 0x12, 0x90},//00 //04 //00 //04//00 //LWC[7:0]  //
-	{GC0310_8BIT, 0x13, 0x02},//05 //05 //LWC[15:8]
-	{GC0310_8BIT, 0x15, 0x12}, // 0x10 //DPHYY_MODE read_ready
-	{GC0310_8BIT, 0x17, 0x01},
-	{GC0310_8BIT, 0x40, 0x08},
-	{GC0310_8BIT, 0x41, 0x00},
-	{GC0310_8BIT, 0x42, 0x00},
-	{GC0310_8BIT, 0x43, 0x00},
-	{GC0310_8BIT, 0x21, 0x02}, // 0x01
-	{GC0310_8BIT, 0x22, 0x02}, // 0x01
-	{GC0310_8BIT, 0x23, 0x01}, // 0x05 //Nor:0x05 DOU:0x06
-	{GC0310_8BIT, 0x29, 0x00},
-	{GC0310_8BIT, 0x2A, 0x25}, // 0x05 //data zero 0x7a de
-	{GC0310_8BIT, 0x2B, 0x02},
-
-	{GC0310_8BIT, 0xfe, 0x00},
-
-/////////////////////////////////////////////////
-/////////////////	CISCTL reg	/////////////////
-/////////////////////////////////////////////////
-	{GC0310_8BIT, 0x00, 0x2f}, //2f//0f//02//01
-	{GC0310_8BIT, 0x01, 0x0f}, //06
-	{GC0310_8BIT, 0x02, 0x04},
-	{GC0310_8BIT, 0x4f, 0x00}, //AEC 0FF
-	{GC0310_8BIT, 0x03, 0x01}, // 0x03 //04
-	{GC0310_8BIT, 0x04, 0xc0}, // 0xe8 //58
-	{GC0310_8BIT, 0x05, 0x00},
-	{GC0310_8BIT, 0x06, 0xb2}, // 0x0a //HB
-	{GC0310_8BIT, 0x07, 0x00},
-	{GC0310_8BIT, 0x08, 0x0c}, // 0x89 //VB
-	{GC0310_8BIT, 0x09, 0x00}, //row start
-	{GC0310_8BIT, 0x0a, 0x00}, //
-	{GC0310_8BIT, 0x0b, 0x00}, //col start
-	{GC0310_8BIT, 0x0c, 0x00},
-	{GC0310_8BIT, 0x0d, 0x01}, //height
-	{GC0310_8BIT, 0x0e, 0xf2}, // 0xf7 //height
-	{GC0310_8BIT, 0x0f, 0x02}, //width
-	{GC0310_8BIT, 0x10, 0x94}, // 0xa0 //height
-	{GC0310_8BIT, 0x17, 0x14},
-	{GC0310_8BIT, 0x18, 0x1a}, //0a//[4]double reset
-	{GC0310_8BIT, 0x19, 0x14}, //AD pipeline
-	{GC0310_8BIT, 0x1b, 0x48},
-	{GC0310_8BIT, 0x1e, 0x6b}, //3b//col bias
-	{GC0310_8BIT, 0x1f, 0x28}, //20//00//08//txlow
-	{GC0310_8BIT, 0x20, 0x89}, //88//0c//[3:2]DA15
-	{GC0310_8BIT, 0x21, 0x49}, //48//[3] txhigh
-	{GC0310_8BIT, 0x22, 0xb0},
-	{GC0310_8BIT, 0x23, 0x04}, //[1:0]vcm_r
-	{GC0310_8BIT, 0x24, 0x16}, //15
-	{GC0310_8BIT, 0x34, 0x20}, //[6:4] rsg high//range
-
-/////////////////////////////////////////////////
-////////////////////   BLK	 ////////////////////
-/////////////////////////////////////////////////
-	{GC0310_8BIT, 0x26, 0x23}, //[1]dark_current_en [0]offset_en
-	{GC0310_8BIT, 0x28, 0xff}, //BLK_limie_value
-	{GC0310_8BIT, 0x29, 0x00}, //global offset
-	{GC0310_8BIT, 0x33, 0x18}, //offset_ratio
-	{GC0310_8BIT, 0x37, 0x20}, //dark_current_ratio
-	{GC0310_8BIT, 0x2a, 0x00},
-	{GC0310_8BIT, 0x2b, 0x00},
-	{GC0310_8BIT, 0x2c, 0x00},
-	{GC0310_8BIT, 0x2d, 0x00},
-	{GC0310_8BIT, 0x2e, 0x00},
-	{GC0310_8BIT, 0x2f, 0x00},
-	{GC0310_8BIT, 0x30, 0x00},
-	{GC0310_8BIT, 0x31, 0x00},
-	{GC0310_8BIT, 0x47, 0x80}, //a7
-	{GC0310_8BIT, 0x4e, 0x66}, //select_row
-	{GC0310_8BIT, 0xa8, 0x02}, //win_width_dark, same with crop_win_width
-	{GC0310_8BIT, 0xa9, 0x80},
-
-/////////////////////////////////////////////////
-//////////////////	 ISP reg  ///////////////////
-/////////////////////////////////////////////////
-	{GC0310_8BIT, 0x40, 0x06}, // 0xff //ff //48
-	{GC0310_8BIT, 0x41, 0x00}, // 0x21 //00//[0]curve_en
-	{GC0310_8BIT, 0x42, 0x04}, // 0xcf //0a//[1]awn_en
-	{GC0310_8BIT, 0x44, 0x18}, // 0x18 //02
-	{GC0310_8BIT, 0x46, 0x02}, // 0x03 //sync
-	{GC0310_8BIT, 0x49, 0x03},
-	{GC0310_8BIT, 0x4c, 0x20}, //00[5]pretect exp
-	{GC0310_8BIT, 0x50, 0x01}, //crop enable
-	{GC0310_8BIT, 0x51, 0x00},
-	{GC0310_8BIT, 0x52, 0x00},
-	{GC0310_8BIT, 0x53, 0x00},
-	{GC0310_8BIT, 0x54, 0x01},
-	{GC0310_8BIT, 0x55, 0x01}, //crop window height
-	{GC0310_8BIT, 0x56, 0xf0},
-	{GC0310_8BIT, 0x57, 0x02}, //crop window width
-	{GC0310_8BIT, 0x58, 0x90},
-
-/////////////////////////////////////////////////
-///////////////////   GAIN	 ////////////////////
-/////////////////////////////////////////////////
-	{GC0310_8BIT, 0x70, 0x70}, //70 //80//global gain
-	{GC0310_8BIT, 0x71, 0x20}, // pregain gain
-	{GC0310_8BIT, 0x72, 0x40}, // post gain
-	{GC0310_8BIT, 0x5a, 0x84}, //84//analog gain 0
-	{GC0310_8BIT, 0x5b, 0xc9}, //c9
-	{GC0310_8BIT, 0x5c, 0xed}, //ed//not use pga gain highest level
-	{GC0310_8BIT, 0x77, 0x40}, // R gain 0x74 //awb gain
-	{GC0310_8BIT, 0x78, 0x40}, // G gain
-	{GC0310_8BIT, 0x79, 0x40}, // B gain 0x5f
-
-	{GC0310_8BIT, 0x48, 0x00},
-	{GC0310_8BIT, 0xfe, 0x01},
-	{GC0310_8BIT, 0x0a, 0x45}, //[7]col gain mode
-
-	{GC0310_8BIT, 0x3e, 0x40},
-	{GC0310_8BIT, 0x3f, 0x5c},
-	{GC0310_8BIT, 0x40, 0x7b},
-	{GC0310_8BIT, 0x41, 0xbd},
-	{GC0310_8BIT, 0x42, 0xf6},
-	{GC0310_8BIT, 0x43, 0x63},
-	{GC0310_8BIT, 0x03, 0x60},
-	{GC0310_8BIT, 0x44, 0x03},
-
-/////////////////////////////////////////////////
-/////////////////	dark sun   //////////////////
-/////////////////////////////////////////////////
-	{GC0310_8BIT, 0xfe, 0x01},
-	{GC0310_8BIT, 0x45, 0xa4}, // 0xf7
-	{GC0310_8BIT, 0x46, 0xf0}, // 0xff //f0//sun vaule th
-	{GC0310_8BIT, 0x48, 0x03}, //sun mode
-	{GC0310_8BIT, 0x4f, 0x60}, //sun_clamp
-	{GC0310_8BIT, 0xfe, 0x00},
-
-	{GC0310_TOK_TERM, 0, 0},
-};
-
-static struct gc0310_reg const gc0310_VGA_30fps[] = {
-	{GC0310_8BIT, 0xfe, 0x00},
-	{GC0310_8BIT, 0x0d, 0x01}, //height
-	{GC0310_8BIT, 0x0e, 0xf2}, // 0xf7 //height
-	{GC0310_8BIT, 0x0f, 0x02}, //width
-	{GC0310_8BIT, 0x10, 0x94}, // 0xa0 //height
-
-	{GC0310_8BIT, 0x50, 0x01}, //crop enable
-	{GC0310_8BIT, 0x51, 0x00},
-	{GC0310_8BIT, 0x52, 0x00},
-	{GC0310_8BIT, 0x53, 0x00},
-	{GC0310_8BIT, 0x54, 0x01},
-	{GC0310_8BIT, 0x55, 0x01}, //crop window height
-	{GC0310_8BIT, 0x56, 0xf0},
-	{GC0310_8BIT, 0x57, 0x02}, //crop window width
-	{GC0310_8BIT, 0x58, 0x90},
-
-	{GC0310_8BIT, 0xfe, 0x03},
-	{GC0310_8BIT, 0x12, 0x90},//00 //04 //00 //04//00 //LWC[7:0]  //
-	{GC0310_8BIT, 0x13, 0x02},//05 //05 //LWC[15:8]
-
-	{GC0310_8BIT, 0xfe, 0x00},
-
-	{GC0310_TOK_TERM, 0, 0},
-};
-
-static struct gc0310_resolution gc0310_res_preview[] = {
-	{
-		.desc = "gc0310_VGA_30fps",
-		.width = 656, // 648,
-		.height = 496, // 488,
-		.fps = 30,
-		//.pix_clk_freq = 73,
-		.used = 0,
-#if 0
-		.pixels_per_line = 0x0314,
-		.lines_per_frame = 0x0213,
-#endif
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.skip_frames = 2,
-		.regs = gc0310_VGA_30fps,
-	},
-};
-#define N_RES_PREVIEW (ARRAY_SIZE(gc0310_res_preview))
-
-static struct gc0310_resolution *gc0310_res = gc0310_res_preview;
-static unsigned long N_RES = N_RES_PREVIEW;
-#endif
-

+ 0 - 677
drivers/staging/media/atomisp/i2c/gc2235.h

@@ -1,677 +0,0 @@
-/*
- * Support for GalaxyCore GC2235 2M camera sensor.
- *
- * Copyright (c) 2014 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.
- *
- */
-
-#ifndef __GC2235_H__
-#define __GC2235_H__
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/delay.h>
-#include <linux/videodev2.h>
-#include <linux/spinlock.h>
-#include <media/v4l2-subdev.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-ctrls.h>
-#include <linux/v4l2-mediabus.h>
-#include <media/media-entity.h>
-
-#include "../include/linux/atomisp_platform.h"
-
-/*
- * FIXME: non-preview resolutions are currently broken
- */
-#define ENABLE_NON_PREVIEW     0
-
-/* Defines for register writes and register array processing */
-#define I2C_MSG_LENGTH		0x2
-#define I2C_RETRY_COUNT		5
-
-#define GC2235_FOCAL_LENGTH_NUM	278	/*2.78mm*/
-#define GC2235_FOCAL_LENGTH_DEM	100
-#define GC2235_F_NUMBER_DEFAULT_NUM	26
-#define GC2235_F_NUMBER_DEM	10
-
-#define MAX_FMTS		1
-
-/*
- * focal length bits definition:
- * bits 31-16: numerator, bits 15-0: denominator
- */
-#define GC2235_FOCAL_LENGTH_DEFAULT 0x1160064
-
-/*
- * current f-number bits definition:
- * bits 31-16: numerator, bits 15-0: denominator
- */
-#define GC2235_F_NUMBER_DEFAULT 0x1a000a
-
-/*
- * f-number range bits definition:
- * bits 31-24: max f-number numerator
- * bits 23-16: max f-number denominator
- * bits 15-8: min f-number numerator
- * bits 7-0: min f-number denominator
- */
-#define GC2235_F_NUMBER_RANGE 0x1a0a1a0a
-#define GC2235_ID	0x2235
-
-#define GC2235_FINE_INTG_TIME_MIN 0
-#define GC2235_FINE_INTG_TIME_MAX_MARGIN 0
-#define GC2235_COARSE_INTG_TIME_MIN 1
-#define GC2235_COARSE_INTG_TIME_MAX_MARGIN 6
-
-/*
- * GC2235 System control registers
- */
-/*
- * GC2235 System control registers
- */
-#define GC2235_SENSOR_ID_H		0xF0
-#define GC2235_SENSOR_ID_L		0xF1
-#define GC2235_RESET_RELATED		0xFE
-#define GC2235_SW_RESET			0x8
-#define GC2235_MIPI_RESET		0x3
-#define GC2235_RESET_BIT		0x4
-#define GC2235_REGISTER_PAGE_0		0x0
-#define GC2235_REGISTER_PAGE_3		0x3
-
-#define GC2235_V_CROP_START_H		0x91
-#define GC2235_V_CROP_START_L		0x92
-#define GC2235_H_CROP_START_H		0x93
-#define GC2235_H_CROP_START_L		0x94
-#define GC2235_V_OUTSIZE_H		0x95
-#define GC2235_V_OUTSIZE_L		0x96
-#define GC2235_H_OUTSIZE_H		0x97
-#define GC2235_H_OUTSIZE_L		0x98
-
-#define GC2235_HB_H			0x5
-#define GC2235_HB_L			0x6
-#define GC2235_VB_H			0x7
-#define GC2235_VB_L			0x8
-#define GC2235_SH_DELAY_H		0x11
-#define GC2235_SH_DELAY_L		0x12
-
-#define GC2235_CSI2_MODE		0x10
-
-#define GC2235_EXPOSURE_H		0x3
-#define GC2235_EXPOSURE_L		0x4
-#define GC2235_GLOBAL_GAIN		0xB0
-#define GC2235_PRE_GAIN			0xB1
-#define GC2235_AWB_R_GAIN		0xB3
-#define GC2235_AWB_G_GAIN		0xB4
-#define GC2235_AWB_B_GAIN		0xB5
-
-#define GC2235_START_STREAMING		0x91
-#define GC2235_STOP_STREAMING		0x0
-
-struct regval_list {
-	u16 reg_num;
-	u8 value;
-};
-
-struct gc2235_resolution {
-	u8 *desc;
-	const struct gc2235_reg *regs;
-	int res;
-	int width;
-	int height;
-	int fps;
-	int pix_clk_freq;
-	u32 skip_frames;
-	u16 pixels_per_line;
-	u16 lines_per_frame;
-	u8 bin_factor_x;
-	u8 bin_factor_y;
-	u8 bin_mode;
-	bool used;
-};
-
-struct gc2235_format {
-	u8 *desc;
-	u32 pixelformat;
-	struct gc2235_reg *regs;
-};
-
-/*
- * gc2235 device structure.
- */
-struct gc2235_device {
-	struct v4l2_subdev sd;
-	struct media_pad pad;
-	struct v4l2_mbus_framefmt format;
-	struct mutex input_lock;
-	struct v4l2_ctrl_handler ctrl_handler;
-
-	struct camera_sensor_platform_data *platform_data;
-	int vt_pix_clk_freq_mhz;
-	int fmt_idx;
-	u8 res;
-	u8 type;
-};
-
-enum gc2235_tok_type {
-	GC2235_8BIT  = 0x0001,
-	GC2235_16BIT = 0x0002,
-	GC2235_32BIT = 0x0004,
-	GC2235_TOK_TERM   = 0xf000,	/* terminating token for reg list */
-	GC2235_TOK_DELAY  = 0xfe00,	/* delay token for reg list */
-	GC2235_TOK_MASK = 0xfff0
-};
-
-/**
- * struct gc2235_reg - MI sensor  register format
- * @type: type of the register
- * @reg: 8-bit offset to register
- * @val: 8/16/32-bit register value
- *
- * Define a structure for sensor register initialization values
- */
-struct gc2235_reg {
-	enum gc2235_tok_type type;
-	u8 reg;
-	u32 val;	/* @set value for read/mod/write, @mask */
-};
-
-#define to_gc2235_sensor(x) container_of(x, struct gc2235_device, sd)
-
-#define GC2235_MAX_WRITE_BUF_SIZE	30
-
-struct gc2235_write_buffer {
-	u8 addr;
-	u8 data[GC2235_MAX_WRITE_BUF_SIZE];
-};
-
-struct gc2235_write_ctrl {
-	int index;
-	struct gc2235_write_buffer buffer;
-};
-
-static struct gc2235_reg const gc2235_stream_on[] = {
-	{ GC2235_8BIT, 0xfe, 0x03}, /* switch to P3 */
-	{ GC2235_8BIT, 0x10, 0x91}, /* start mipi */
-	{ GC2235_8BIT, 0xfe, 0x00}, /* switch to P0 */
-	{ GC2235_TOK_TERM, 0, 0 }
-};
-
-static struct gc2235_reg const gc2235_stream_off[] = {
-	{ GC2235_8BIT, 0xfe, 0x03}, /* switch to P3 */
-	{ GC2235_8BIT, 0x10, 0x01}, /* stop mipi */
-	{ GC2235_8BIT, 0xfe, 0x00}, /* switch to P0 */
-	{ GC2235_TOK_TERM, 0, 0 }
-};
-
-static struct gc2235_reg const gc2235_init_settings[] = {
-	/* Sysytem */
-	{ GC2235_8BIT, 0xfe, 0x80 },
-	{ GC2235_8BIT, 0xfe, 0x80 },
-	{ GC2235_8BIT, 0xfe, 0x80 },
-	{ GC2235_8BIT, 0xf2, 0x00 },
-	{ GC2235_8BIT, 0xf6, 0x00 },
-	{ GC2235_8BIT, 0xfc, 0x06 },
-	{ GC2235_8BIT, 0xf7, 0x15 },
-	{ GC2235_8BIT, 0xf8, 0x84 },
-	{ GC2235_8BIT, 0xf9, 0xfe },
-	{ GC2235_8BIT, 0xfa, 0x00 },
-	{ GC2235_8BIT, 0xfe, 0x00 },
-	/* Analog & cisctl */
-	{ GC2235_8BIT, 0x03, 0x04 },
-	{ GC2235_8BIT, 0x04, 0x9E },
-	{ GC2235_8BIT, 0x05, 0x00 },
-	{ GC2235_8BIT, 0x06, 0xfd },
-	{ GC2235_8BIT, 0x07, 0x00 },
-	{ GC2235_8BIT, 0x08, 0x14 },
-	{ GC2235_8BIT, 0x0a, 0x02 }, /* row start */
-	{ GC2235_8BIT, 0x0c, 0x00 }, /* col start */
-	{ GC2235_8BIT, 0x0d, 0x04 }, /* win height 1232 */
-	{ GC2235_8BIT, 0x0e, 0xd0 },
-	{ GC2235_8BIT, 0x0f, 0x06 }, /* win width: 1616 */
-	{ GC2235_8BIT, 0x10, 0x60 },
-	{ GC2235_8BIT, 0x17, 0x15 }, /* mirror flip */
-	{ GC2235_8BIT, 0x18, 0x1a },
-	{ GC2235_8BIT, 0x19, 0x06 },
-	{ GC2235_8BIT, 0x1a, 0x01 },
-	{ GC2235_8BIT, 0x1b, 0x4d },
-	{ GC2235_8BIT, 0x1e, 0x88 },
-	{ GC2235_8BIT, 0x1f, 0x48 },
-	{ GC2235_8BIT, 0x20, 0x03 },
-	{ GC2235_8BIT, 0x21, 0x7f },
-	{ GC2235_8BIT, 0x22, 0x83 },
-	{ GC2235_8BIT, 0x23, 0x42 },
-	{ GC2235_8BIT, 0x24, 0x16 },
-	{ GC2235_8BIT, 0x26, 0x01 }, /*analog gain*/
-	{ GC2235_8BIT, 0x27, 0x30 },
-	{ GC2235_8BIT, 0x3f, 0x00 }, /* PRC */
-	/* blk */
-	{ GC2235_8BIT, 0x40, 0xa3 },
-	{ GC2235_8BIT, 0x41, 0x82 },
-	{ GC2235_8BIT, 0x43, 0x20 },
-	{ GC2235_8BIT, 0x5e, 0x18 },
-	{ GC2235_8BIT, 0x5f, 0x18 },
-	{ GC2235_8BIT, 0x60, 0x18 },
-	{ GC2235_8BIT, 0x61, 0x18 },
-	{ GC2235_8BIT, 0x62, 0x18 },
-	{ GC2235_8BIT, 0x63, 0x18 },
-	{ GC2235_8BIT, 0x64, 0x18 },
-	{ GC2235_8BIT, 0x65, 0x18 },
-	{ GC2235_8BIT, 0x66, 0x20 },
-	{ GC2235_8BIT, 0x67, 0x20 },
-	{ GC2235_8BIT, 0x68, 0x20 },
-	{ GC2235_8BIT, 0x69, 0x20 },
-	/* Gain */
-	{ GC2235_8BIT, 0xb2, 0x00 },
-	{ GC2235_8BIT, 0xb3, 0x40 },
-	{ GC2235_8BIT, 0xb4, 0x40 },
-	{ GC2235_8BIT, 0xb5, 0x40 },
-	/* Dark sun */
-	{ GC2235_8BIT, 0xbc, 0x00 },
-
-	{ GC2235_8BIT, 0xfe, 0x03 },
-	{ GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
-	{ GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
-	{ GC2235_TOK_TERM, 0, 0 }
-};
-/*
- * Register settings for various resolution
- */
-#if ENABLE_NON_PREVIEW
-static struct gc2235_reg const gc2235_1296_736_30fps[] = {
-	{ GC2235_8BIT, 0x8b, 0xa0 },
-	{ GC2235_8BIT, 0x8c, 0x02 },
-
-	{ GC2235_8BIT, 0x07, 0x01 }, /* VBI */
-	{ GC2235_8BIT, 0x08, 0x44 },
-	{ GC2235_8BIT, 0x09, 0x00 }, /* row start */
-	{ GC2235_8BIT, 0x0a, 0xf0 },
-	{ GC2235_8BIT, 0x0b, 0x00 }, /* col start */
-	{ GC2235_8BIT, 0x0c, 0xa0 },
-	{ GC2235_8BIT, 0x0d, 0x02 }, /* win height 736 */
-	{ GC2235_8BIT, 0x0e, 0xf0 },
-	{ GC2235_8BIT, 0x0f, 0x05 }, /* win width: 1296 */
-	{ GC2235_8BIT, 0x10, 0x20 },
-
-	{ GC2235_8BIT, 0x90, 0x01 },
-	{ GC2235_8BIT, 0x92, 0x08 },
-	{ GC2235_8BIT, 0x94, 0x08 },
-	{ GC2235_8BIT, 0x95, 0x02 }, /* crop win height 736 */
-	{ GC2235_8BIT, 0x96, 0xe0 },
-	{ GC2235_8BIT, 0x97, 0x05 }, /* crop win width 1296 */
-	{ GC2235_8BIT, 0x98, 0x10 },
-	/* mimi init */
-	{ GC2235_8BIT, 0xfe, 0x03 }, /* switch to P3 */
-	{ GC2235_8BIT, 0x01, 0x07 },
-	{ GC2235_8BIT, 0x02, 0x11 },
-	{ GC2235_8BIT, 0x03, 0x11 },
-	{ GC2235_8BIT, 0x06, 0x80 },
-	{ GC2235_8BIT, 0x11, 0x2b },
-	/* set mipi buffer */
-	{ GC2235_8BIT, 0x12, 0x54 }, /* val_low = (width * 10 / 8) & 0xFF */
-	{ GC2235_8BIT, 0x13, 0x06 }, /* val_high = (width * 10 / 8) >> 8 */
-
-	{ GC2235_8BIT, 0x15, 0x12 }, /* DPHY mode*/
-	{ GC2235_8BIT, 0x04, 0x10 },
-	{ GC2235_8BIT, 0x05, 0x00 },
-	{ GC2235_8BIT, 0x17, 0x01 },
-
-	{ GC2235_8BIT, 0x22, 0x01 },
-	{ GC2235_8BIT, 0x23, 0x05 },
-	{ GC2235_8BIT, 0x24, 0x10 },
-	{ GC2235_8BIT, 0x25, 0x10 },
-	{ GC2235_8BIT, 0x26, 0x02 },
-	{ GC2235_8BIT, 0x21, 0x10 },
-	{ GC2235_8BIT, 0x29, 0x01 },
-	{ GC2235_8BIT, 0x2a, 0x02 },
-	{ GC2235_8BIT, 0x2b, 0x02 },
-
-	{ GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
-	{ GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
-	{ GC2235_TOK_TERM, 0, 0 }
-};
-
-static struct gc2235_reg const gc2235_960_640_30fps[] = {
-	{ GC2235_8BIT, 0x8b, 0xa0 },
-	{ GC2235_8BIT, 0x8c, 0x02 },
-
-	{ GC2235_8BIT, 0x07, 0x02 }, /* VBI */
-	{ GC2235_8BIT, 0x08, 0xA4 },
-	{ GC2235_8BIT, 0x09, 0x01 }, /* row start */
-	{ GC2235_8BIT, 0x0a, 0x18 },
-	{ GC2235_8BIT, 0x0b, 0x01 }, /* col start */
-	{ GC2235_8BIT, 0x0c, 0x40 },
-	{ GC2235_8BIT, 0x0d, 0x02 }, /* win height 656 */
-	{ GC2235_8BIT, 0x0e, 0x90 },
-	{ GC2235_8BIT, 0x0f, 0x03 }, /* win width: 976 */
-	{ GC2235_8BIT, 0x10, 0xd0 },
-
-	{ GC2235_8BIT, 0x90, 0x01 },
-	{ GC2235_8BIT, 0x92, 0x02 },
-	{ GC2235_8BIT, 0x94, 0x06 },
-	{ GC2235_8BIT, 0x95, 0x02 }, /* crop win height 640 */
-	{ GC2235_8BIT, 0x96, 0x80 },
-	{ GC2235_8BIT, 0x97, 0x03 }, /* crop win width 960 */
-	{ GC2235_8BIT, 0x98, 0xc0 },
-	/* mimp init */
-	{ GC2235_8BIT, 0xfe, 0x03 }, /* switch to P3 */
-	{ GC2235_8BIT, 0x01, 0x07 },
-	{ GC2235_8BIT, 0x02, 0x11 },
-	{ GC2235_8BIT, 0x03, 0x11 },
-	{ GC2235_8BIT, 0x06, 0x80 },
-	{ GC2235_8BIT, 0x11, 0x2b },
-	/* set mipi buffer */
-	{ GC2235_8BIT, 0x12, 0xb0 }, /* val_low = (width * 10 / 8) & 0xFF */
-	{ GC2235_8BIT, 0x13, 0x04 }, /* val_high = (width * 10 / 8) >> 8 */
-
-	{ GC2235_8BIT, 0x15, 0x12 }, /* DPHY mode*/
-	{ GC2235_8BIT, 0x04, 0x10 },
-	{ GC2235_8BIT, 0x05, 0x00 },
-	{ GC2235_8BIT, 0x17, 0x01 },
-	{ GC2235_8BIT, 0x22, 0x01 },
-	{ GC2235_8BIT, 0x23, 0x05 },
-	{ GC2235_8BIT, 0x24, 0x10 },
-	{ GC2235_8BIT, 0x25, 0x10 },
-	{ GC2235_8BIT, 0x26, 0x02 },
-	{ GC2235_8BIT, 0x21, 0x10 },
-	{ GC2235_8BIT, 0x29, 0x01 },
-	{ GC2235_8BIT, 0x2a, 0x02 },
-	{ GC2235_8BIT, 0x2b, 0x02 },
-	{ GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
-	{ GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
-	{ GC2235_TOK_TERM, 0, 0 }
-};
-#endif
-
-static struct gc2235_reg const gc2235_1600_900_30fps[] = {
-	{ GC2235_8BIT, 0x8b, 0xa0 },
-	{ GC2235_8BIT, 0x8c, 0x02 },
-
-	{ GC2235_8BIT, 0x0d, 0x03 }, /* win height 932 */
-	{ GC2235_8BIT, 0x0e, 0xa4 },
-	{ GC2235_8BIT, 0x0f, 0x06 }, /* win width: 1632 */
-	{ GC2235_8BIT, 0x10, 0x50 },
-
-	{ GC2235_8BIT, 0x90, 0x01 },
-	{ GC2235_8BIT, 0x92, 0x02 },
-	{ GC2235_8BIT, 0x94, 0x06 },
-	{ GC2235_8BIT, 0x95, 0x03 }, /* crop win height 900 */
-	{ GC2235_8BIT, 0x96, 0x84 },
-	{ GC2235_8BIT, 0x97, 0x06 }, /* crop win width 1600 */
-	{ GC2235_8BIT, 0x98, 0x40 },
-	/* mimi init */
-	{ GC2235_8BIT, 0xfe, 0x03 }, /* switch to P3 */
-	{ GC2235_8BIT, 0x01, 0x07 },
-	{ GC2235_8BIT, 0x02, 0x11 },
-	{ GC2235_8BIT, 0x03, 0x11 },
-	{ GC2235_8BIT, 0x06, 0x80 },
-	{ GC2235_8BIT, 0x11, 0x2b },
-	/* set mipi buffer */
-	{ GC2235_8BIT, 0x12, 0xd0 }, /* val_low = (width * 10 / 8) & 0xFF */
-	{ GC2235_8BIT, 0x13, 0x07 }, /* val_high = (width * 10 / 8) >> 8 */
-
-	{ GC2235_8BIT, 0x15, 0x12 }, /* DPHY mode*/
-	{ GC2235_8BIT, 0x04, 0x10 },
-	{ GC2235_8BIT, 0x05, 0x00 },
-	{ GC2235_8BIT, 0x17, 0x01 },
-	{ GC2235_8BIT, 0x22, 0x01 },
-	{ GC2235_8BIT, 0x23, 0x05 },
-	{ GC2235_8BIT, 0x24, 0x10 },
-	{ GC2235_8BIT, 0x25, 0x10 },
-	{ GC2235_8BIT, 0x26, 0x02 },
-	{ GC2235_8BIT, 0x21, 0x10 },
-	{ GC2235_8BIT, 0x29, 0x01 },
-	{ GC2235_8BIT, 0x2a, 0x02 },
-	{ GC2235_8BIT, 0x2b, 0x02 },
-	{ GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
-	{ GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
-	{ GC2235_TOK_TERM, 0, 0 }
-};
-
-static struct gc2235_reg const gc2235_1616_1082_30fps[] = {
-	{ GC2235_8BIT, 0x8b, 0xa0 },
-	{ GC2235_8BIT, 0x8c, 0x02 },
-
-	{ GC2235_8BIT, 0x0d, 0x04 }, /* win height 1232 */
-	{ GC2235_8BIT, 0x0e, 0xd0 },
-	{ GC2235_8BIT, 0x0f, 0x06 }, /* win width: 1616 */
-	{ GC2235_8BIT, 0x10, 0x50 },
-
-	{ GC2235_8BIT, 0x90, 0x01 },
-	{ GC2235_8BIT, 0x92, 0x4a },
-	{ GC2235_8BIT, 0x94, 0x00 },
-	{ GC2235_8BIT, 0x95, 0x04 }, /* crop win height 1082 */
-	{ GC2235_8BIT, 0x96, 0x3a },
-	{ GC2235_8BIT, 0x97, 0x06 }, /* crop win width 1616 */
-	{ GC2235_8BIT, 0x98, 0x50 },
-	/* mimp init */
-	{ GC2235_8BIT, 0xfe, 0x03 }, /* switch to P3 */
-	{ GC2235_8BIT, 0x01, 0x07 },
-	{ GC2235_8BIT, 0x02, 0x11 },
-	{ GC2235_8BIT, 0x03, 0x11 },
-	{ GC2235_8BIT, 0x06, 0x80 },
-	{ GC2235_8BIT, 0x11, 0x2b },
-	/* set mipi buffer */
-	{ GC2235_8BIT, 0x12, 0xe4 }, /* val_low = (width * 10 / 8) & 0xFF */
-	{ GC2235_8BIT, 0x13, 0x07 }, /* val_high = (width * 10 / 8) >> 8 */
-
-	{ GC2235_8BIT, 0x15, 0x12 }, /* DPHY mode*/
-	{ GC2235_8BIT, 0x04, 0x10 },
-	{ GC2235_8BIT, 0x05, 0x00 },
-	{ GC2235_8BIT, 0x17, 0x01 },
-	{ GC2235_8BIT, 0x22, 0x01 },
-	{ GC2235_8BIT, 0x23, 0x05 },
-	{ GC2235_8BIT, 0x24, 0x10 },
-	{ GC2235_8BIT, 0x25, 0x10 },
-	{ GC2235_8BIT, 0x26, 0x02 },
-	{ GC2235_8BIT, 0x21, 0x10 },
-	{ GC2235_8BIT, 0x29, 0x01 },
-	{ GC2235_8BIT, 0x2a, 0x02 },
-	{ GC2235_8BIT, 0x2b, 0x02 },
-	{ GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
-	{ GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
-	{ GC2235_TOK_TERM, 0, 0 }
-};
-
-static struct gc2235_reg const gc2235_1616_1216_30fps[] = {
-	{ GC2235_8BIT, 0x8b, 0xa0 },
-	{ GC2235_8BIT, 0x8c, 0x02 },
-
-	{ GC2235_8BIT, 0x0d, 0x04 }, /* win height 1232 */
-	{ GC2235_8BIT, 0x0e, 0xd0 },
-	{ GC2235_8BIT, 0x0f, 0x06 }, /* win width: 1616 */
-	{ GC2235_8BIT, 0x10, 0x50 },
-
-	{ GC2235_8BIT, 0x90, 0x01 },
-	{ GC2235_8BIT, 0x92, 0x02 },
-	{ GC2235_8BIT, 0x94, 0x00 },
-	{ GC2235_8BIT, 0x95, 0x04 }, /* crop win height 1216 */
-	{ GC2235_8BIT, 0x96, 0xc0 },
-	{ GC2235_8BIT, 0x97, 0x06 }, /* crop win width 1616 */
-	{ GC2235_8BIT, 0x98, 0x50 },
-	/* mimi init */
-	{ GC2235_8BIT, 0xfe, 0x03 }, /* switch to P3 */
-	{ GC2235_8BIT, 0x01, 0x07 },
-	{ GC2235_8BIT, 0x02, 0x11 },
-	{ GC2235_8BIT, 0x03, 0x11 },
-	{ GC2235_8BIT, 0x06, 0x80 },
-	{ GC2235_8BIT, 0x11, 0x2b },
-	/* set mipi buffer */
-	{ GC2235_8BIT, 0x12, 0xe4 }, /* val_low = (width * 10 / 8) & 0xFF */
-	{ GC2235_8BIT, 0x13, 0x07 }, /* val_high = (width * 10 / 8) >> 8 */
-	{ GC2235_8BIT, 0x15, 0x12 }, /* DPHY mode*/
-	{ GC2235_8BIT, 0x04, 0x10 },
-	{ GC2235_8BIT, 0x05, 0x00 },
-	{ GC2235_8BIT, 0x17, 0x01 },
-	{ GC2235_8BIT, 0x22, 0x01 },
-	{ GC2235_8BIT, 0x23, 0x05 },
-	{ GC2235_8BIT, 0x24, 0x10 },
-	{ GC2235_8BIT, 0x25, 0x10 },
-	{ GC2235_8BIT, 0x26, 0x02 },
-	{ GC2235_8BIT, 0x21, 0x10 },
-	{ GC2235_8BIT, 0x29, 0x01 },
-	{ GC2235_8BIT, 0x2a, 0x02 },
-	{ GC2235_8BIT, 0x2b, 0x02 },
-	{ GC2235_8BIT, 0x10, 0x01 }, /* disable mipi */
-	{ GC2235_8BIT, 0xfe, 0x00 }, /* switch to P0 */
-	{ GC2235_TOK_TERM, 0, 0 }
-};
-
-static struct gc2235_resolution gc2235_res_preview[] = {
-
-	{
-		.desc = "gc2235_1600_900_30fps",
-		.width = 1600,
-		.height = 900,
-		.pix_clk_freq = 30,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2132,
-		.lines_per_frame = 1068,
-		.bin_factor_x = 0,
-		.bin_factor_y = 0,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = gc2235_1600_900_30fps,
-	},
-
-	{
-		.desc = "gc2235_1600_1066_30fps",
-		.width = 1616,
-		.height = 1082,
-		.pix_clk_freq = 30,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2132,
-		.lines_per_frame = 1368,
-		.bin_factor_x = 0,
-		.bin_factor_y = 0,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = gc2235_1616_1082_30fps,
-	},
-	{
-		.desc = "gc2235_1600_1200_30fps",
-		.width = 1616,
-		.height = 1216,
-		.pix_clk_freq = 30,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2132,
-		.lines_per_frame = 1368,
-		.bin_factor_x = 0,
-		.bin_factor_y = 0,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = gc2235_1616_1216_30fps,
-	},
-
-};
-#define N_RES_PREVIEW (ARRAY_SIZE(gc2235_res_preview))
-
-/*
- * Disable non-preview configurations until the configuration selection is
- * improved.
- */
-#if ENABLE_NON_PREVIEW
-static struct gc2235_resolution gc2235_res_still[] = {
-	{
-		.desc = "gc2235_1600_900_30fps",
-		.width = 1600,
-		.height = 900,
-		.pix_clk_freq = 30,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2132,
-		.lines_per_frame = 1068,
-		.bin_factor_x = 0,
-		.bin_factor_y = 0,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = gc2235_1600_900_30fps,
-	},
-	{
-		.desc = "gc2235_1600_1066_30fps",
-		.width = 1616,
-		.height = 1082,
-		.pix_clk_freq = 30,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2132,
-		.lines_per_frame = 1368,
-		.bin_factor_x = 0,
-		.bin_factor_y = 0,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = gc2235_1616_1082_30fps,
-	},
-	{
-		.desc = "gc2235_1600_1200_30fps",
-		.width = 1616,
-		.height = 1216,
-		.pix_clk_freq = 30,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2132,
-		.lines_per_frame = 1368,
-		.bin_factor_x = 0,
-		.bin_factor_y = 0,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = gc2235_1616_1216_30fps,
-	},
-
-};
-#define N_RES_STILL (ARRAY_SIZE(gc2235_res_still))
-
-static struct gc2235_resolution gc2235_res_video[] = {
-	{
-		.desc = "gc2235_1296_736_30fps",
-		.width = 1296,
-		.height = 736,
-		.pix_clk_freq = 30,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 1828,
-		.lines_per_frame = 888,
-		.bin_factor_x = 0,
-		.bin_factor_y = 0,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = gc2235_1296_736_30fps,
-	},
-	{
-		.desc = "gc2235_960_640_30fps",
-		.width = 960,
-		.height = 640,
-		.pix_clk_freq = 30,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 1492,
-		.lines_per_frame = 792,
-		.bin_factor_x = 0,
-		.bin_factor_y = 0,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = gc2235_960_640_30fps,
-	},
-
-};
-#define N_RES_VIDEO (ARRAY_SIZE(gc2235_res_video))
-#endif
-
-static struct gc2235_resolution *gc2235_res = gc2235_res_preview;
-static unsigned long N_RES = N_RES_PREVIEW;
-#endif

+ 0 - 1788
drivers/staging/media/atomisp/i2c/mt9m114.h

@@ -1,1788 +0,0 @@
-/*
- * Support for mt9m114 Camera Sensor.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * 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 __A1040_H__
-#define __A1040_H__
-
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/delay.h>
-#include <linux/videodev2.h>
-#include <linux/spinlock.h>
-#include <media/v4l2-subdev.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-ctrls.h>
-#include <linux/v4l2-mediabus.h>
-#include <media/media-entity.h>
-#include "../include/linux/atomisp_platform.h"
-#include "../include/linux/atomisp.h"
-
-#define V4L2_IDENT_MT9M114 8245
-
-#define MT9P111_REV3
-#define FULLINISUPPORT
-
-/* #defines for register writes and register array processing */
-#define MISENSOR_8BIT		1
-#define MISENSOR_16BIT		2
-#define MISENSOR_32BIT		4
-
-#define MISENSOR_FWBURST0	0x80
-#define MISENSOR_FWBURST1	0x81
-#define MISENSOR_FWBURST4	0x84
-#define MISENSOR_FWBURST	0x88
-
-#define MISENSOR_TOK_TERM	0xf000	/* terminating token for reg list */
-#define MISENSOR_TOK_DELAY	0xfe00	/* delay token for reg list */
-#define MISENSOR_TOK_FWLOAD	0xfd00	/* token indicating load FW */
-#define MISENSOR_TOK_POLL	0xfc00	/* token indicating poll instruction */
-#define MISENSOR_TOK_RMW	0x0010  /* RMW operation */
-#define MISENSOR_TOK_MASK	0xfff0
-#define MISENSOR_AWB_STEADY	(1<<0)	/* awb steady */
-#define MISENSOR_AE_READY	(1<<3)	/* ae status ready */
-
-/* mask to set sensor read_mode via misensor_rmw_reg */
-#define MISENSOR_R_MODE_MASK	0x0330
-/* mask to set sensor vert_flip and horz_mirror */
-#define MISENSOR_VFLIP_MASK	0x0002
-#define MISENSOR_HFLIP_MASK	0x0001
-#define MISENSOR_FLIP_EN	1
-#define MISENSOR_FLIP_DIS	0
-
-/* bits set to set sensor read_mode via misensor_rmw_reg */
-#define MISENSOR_SKIPPING_SET	0x0011
-#define MISENSOR_SUMMING_SET	0x0033
-#define MISENSOR_NORMAL_SET	0x0000
-
-/* sensor register that control sensor read-mode and mirror */
-#define MISENSOR_READ_MODE	0xC834
-/* sensor ae-track status register */
-#define MISENSOR_AE_TRACK_STATUS	0xA800
-/* sensor awb status register */
-#define MISENSOR_AWB_STATUS	0xAC00
-/* sensor coarse integration time register */
-#define MISENSOR_COARSE_INTEGRATION_TIME 0xC83C
-
-/* registers */
-#define REG_SW_RESET                    0x301A
-#define REG_SW_STREAM                   0xDC00
-#define REG_SCCB_CTRL                   0x3100
-#define REG_SC_CMMN_CHIP_ID             0x0000
-#define REG_V_START                     0xc800 /* 16bits */
-#define REG_H_START                     0xc802 /* 16bits */
-#define REG_V_END                       0xc804 /* 16bits */
-#define REG_H_END                       0xc806 /* 16bits */
-#define REG_PIXEL_CLK                   0xc808 /* 32bits */
-#define REG_TIMING_VTS                  0xc812 /* 16bits */
-#define REG_TIMING_HTS                  0xc814 /* 16bits */
-#define REG_WIDTH                       0xC868 /* 16bits */
-#define REG_HEIGHT                      0xC86A /* 16bits */
-#define REG_EXPO_COARSE                 0x3012 /* 16bits */
-#define REG_EXPO_FINE                   0x3014 /* 16bits */
-#define REG_GAIN                        0x305E
-#define REG_ANALOGGAIN                  0x305F
-#define REG_ADDR_ACESSS                 0x098E /* logical_address_access */
-#define REG_COMM_Register               0x0080 /* command_register */
-
-#define SENSOR_DETECTED		1
-#define SENSOR_NOT_DETECTED	0
-
-#define I2C_RETRY_COUNT		5
-#define MSG_LEN_OFFSET		2
-
-#ifndef MIPI_CONTROL
-#define MIPI_CONTROL		0x3400	/* MIPI_Control */
-#endif
-
-/* GPIO pin on Moorestown */
-#define GPIO_SCLK_25		44
-#define GPIO_STB_PIN		47
-
-#define GPIO_STDBY_PIN		49   /* ab:new */
-#define GPIO_RESET_PIN		50
-
-/* System control register for Aptina A-1040SOC*/
-#define MT9M114_PID		0x0
-
-/* MT9P111_DEVICE_ID */
-#define MT9M114_MOD_ID		0x2481
-
-#define MT9M114_FINE_INTG_TIME_MIN 0
-#define MT9M114_FINE_INTG_TIME_MAX_MARGIN 0
-#define MT9M114_COARSE_INTG_TIME_MIN 1
-#define MT9M114_COARSE_INTG_TIME_MAX_MARGIN 6
-
-
-/* ulBPat; */
-
-#define MT9M114_BPAT_RGRGGBGB	(1 << 0)
-#define MT9M114_BPAT_GRGRBGBG	(1 << 1)
-#define MT9M114_BPAT_GBGBRGRG	(1 << 2)
-#define MT9M114_BPAT_BGBGGRGR	(1 << 3)
-
-#define MT9M114_FOCAL_LENGTH_NUM	208	/*2.08mm*/
-#define MT9M114_FOCAL_LENGTH_DEM	100
-#define MT9M114_F_NUMBER_DEFAULT_NUM	24
-#define MT9M114_F_NUMBER_DEM	10
-#define MT9M114_WAIT_STAT_TIMEOUT	100
-#define MT9M114_FLICKER_MODE_50HZ	1
-#define MT9M114_FLICKER_MODE_60HZ	2
-/*
- * focal length bits definition:
- * bits 31-16: numerator, bits 15-0: denominator
- */
-#define MT9M114_FOCAL_LENGTH_DEFAULT 0xD00064
-
-/*
- * current f-number bits definition:
- * bits 31-16: numerator, bits 15-0: denominator
- */
-#define MT9M114_F_NUMBER_DEFAULT 0x18000a
-
-/*
- * f-number range bits definition:
- * bits 31-24: max f-number numerator
- * bits 23-16: max f-number denominator
- * bits 15-8: min f-number numerator
- * bits 7-0: min f-number denominator
- */
-#define MT9M114_F_NUMBER_RANGE 0x180a180a
-
-/* Supported resolutions */
-enum {
-	MT9M114_RES_736P,
-	MT9M114_RES_864P,
-	MT9M114_RES_960P,
-};
-#define MT9M114_RES_960P_SIZE_H		1296
-#define MT9M114_RES_960P_SIZE_V		976
-#define MT9M114_RES_720P_SIZE_H		1280
-#define MT9M114_RES_720P_SIZE_V		720
-#define MT9M114_RES_576P_SIZE_H		1024
-#define MT9M114_RES_576P_SIZE_V		576
-#define MT9M114_RES_480P_SIZE_H		768
-#define MT9M114_RES_480P_SIZE_V		480
-#define MT9M114_RES_VGA_SIZE_H		640
-#define MT9M114_RES_VGA_SIZE_V		480
-#define MT9M114_RES_QVGA_SIZE_H		320
-#define MT9M114_RES_QVGA_SIZE_V		240
-#define MT9M114_RES_QCIF_SIZE_H		176
-#define MT9M114_RES_QCIF_SIZE_V		144
-
-#define MT9M114_RES_720_480p_768_SIZE_H 736
-#define MT9M114_RES_720_480p_768_SIZE_V 496
-#define MT9M114_RES_736P_SIZE_H 1296
-#define MT9M114_RES_736P_SIZE_V 736
-#define MT9M114_RES_864P_SIZE_H 1296
-#define MT9M114_RES_864P_SIZE_V 864
-#define MT9M114_RES_976P_SIZE_H 1296
-#define MT9M114_RES_976P_SIZE_V 976
-
-#define MT9M114_BIN_FACTOR_MAX			3
-
-#define MT9M114_DEFAULT_FIRST_EXP 0x10
-#define MT9M114_MAX_FIRST_EXP 0x302
-
-/* completion status polling requirements, usage based on Aptina .INI Rev2 */
-enum poll_reg {
-	NO_POLLING,
-	PRE_POLLING,
-	POST_POLLING,
-};
-/*
- * struct misensor_reg - MI sensor  register format
- * @length: length of the register
- * @reg: 16-bit offset to register
- * @val: 8/16/32-bit register value
- * Define a structure for sensor register initialization values
- */
-struct misensor_reg {
-	u32 length;
-	u32 reg;
-	u32 val;	/* value or for read/mod/write, AND mask */
-	u32 val2;	/* optional; for rmw, OR mask */
-};
-
-/*
- * struct misensor_fwreg - Firmware burst command
- * @type: FW burst or 8/16 bit register
- * @addr: 16-bit offset to register or other values depending on type
- * @valx: data value for burst (or other commands)
- *
- * Define a structure for sensor register initialization values
- */
-struct misensor_fwreg {
-	u32	type;	/* type of value, register or FW burst string */
-	u32	addr;	/* target address */
-	u32	val0;
-	u32	val1;
-	u32	val2;
-	u32	val3;
-	u32	val4;
-	u32	val5;
-	u32	val6;
-	u32	val7;
-};
-
-struct regval_list {
-	u16 reg_num;
-	u8 value;
-};
-
-struct mt9m114_device {
-	struct v4l2_subdev sd;
-	struct media_pad pad;
-	struct v4l2_mbus_framefmt format;
-
-	struct camera_sensor_platform_data *platform_data;
-	struct mutex input_lock;	/* serialize sensor's ioctl */
-	struct v4l2_ctrl_handler ctrl_handler;
-	int real_model_id;
-	int nctx;
-	int power;
-
-	unsigned int bus_width;
-	unsigned int mode;
-	unsigned int field_inv;
-	unsigned int field_sel;
-	unsigned int ycseq;
-	unsigned int conv422;
-	unsigned int bpat;
-	unsigned int hpol;
-	unsigned int vpol;
-	unsigned int edge;
-	unsigned int bls;
-	unsigned int gamma;
-	unsigned int cconv;
-	unsigned int res;
-	unsigned int dwn_sz;
-	unsigned int blc;
-	unsigned int agc;
-	unsigned int awb;
-	unsigned int aec;
-	/* extention SENSOR version 2 */
-	unsigned int cie_profile;
-
-	/* extention SENSOR version 3 */
-	unsigned int flicker_freq;
-
-	/* extension SENSOR version 4 */
-	unsigned int smia_mode;
-	unsigned int mipi_mode;
-
-	/* Add name here to load shared library */
-	unsigned int type;
-
-	/*Number of MIPI lanes*/
-	unsigned int mipi_lanes;
-	/*WA for low light AE*/
-	unsigned int first_exp;
-	unsigned int first_gain;
-	unsigned int first_diggain;
-	char name[32];
-
-	u8 lightfreq;
-	u8 streamon;
-};
-
-struct mt9m114_format_struct {
-	u8 *desc;
-	u32 pixelformat;
-	struct regval_list *regs;
-};
-
-struct mt9m114_res_struct {
-	u8 *desc;
-	int res;
-	int width;
-	int height;
-	int fps;
-	int skip_frames;
-	bool used;
-	struct regval_list *regs;
-	u16 pixels_per_line;
-	u16 lines_per_frame;
-	u8 bin_factor_x;
-	u8 bin_factor_y;
-	u8 bin_mode;
-};
-
-/* 2 bytes used for address: 256 bytes total */
-#define MT9M114_MAX_WRITE_BUF_SIZE	254
-struct mt9m114_write_buffer {
-	u16 addr;
-	u8 data[MT9M114_MAX_WRITE_BUF_SIZE];
-};
-
-struct mt9m114_write_ctrl {
-	int index;
-	struct mt9m114_write_buffer buffer;
-};
-
-/*
- * Modes supported by the mt9m114 driver.
- * Please, keep them in ascending order.
- */
-static struct mt9m114_res_struct mt9m114_res[] = {
-	{
-	.desc	= "720P",
-	.res	= MT9M114_RES_736P,
-	.width	= 1296,
-	.height = 736,
-	.fps	= 30,
-	.used	= false,
-	.regs	= NULL,
-	.skip_frames = 1,
-
-	.pixels_per_line = 0x0640,
-	.lines_per_frame = 0x0307,
-	.bin_factor_x = 1,
-	.bin_factor_y = 1,
-	.bin_mode = 0,
-	},
-	{
-	.desc	= "848P",
-	.res	= MT9M114_RES_864P,
-	.width	= 1296,
-	.height = 864,
-	.fps	= 30,
-	.used	= false,
-	.regs	= NULL,
-	.skip_frames = 1,
-
-	.pixels_per_line = 0x0640,
-	.lines_per_frame = 0x03E8,
-	.bin_factor_x = 1,
-	.bin_factor_y = 1,
-	.bin_mode = 0,
-	},
-	{
-	.desc	= "960P",
-	.res	= MT9M114_RES_960P,
-	.width	= 1296,
-	.height	= 976,
-	.fps	= 30,
-	.used	= false,
-	.regs	= NULL,
-	.skip_frames = 1,
-
-	.pixels_per_line = 0x0644, /* consistent with regs arrays */
-	.lines_per_frame = 0x03E5, /* consistent with regs arrays */
-	.bin_factor_x = 1,
-	.bin_factor_y = 1,
-	.bin_mode = 0,
-	},
-};
-#define N_RES (ARRAY_SIZE(mt9m114_res))
-
-#if 0 /* Currently unused */
-static struct misensor_reg const mt9m114_exitstandby[] = {
-	{MISENSOR_16BIT,  0x098E, 0xDC00},
-	/* exit-standby */
-	{MISENSOR_8BIT,  0xDC00, 0x54},
-	{MISENSOR_16BIT,  0x0080, 0x8002},
-	{MISENSOR_TOK_TERM, 0, 0}
-};
-#endif
-
-static struct misensor_reg const mt9m114_exp_win[5][5] = {
-	{
-		{MISENSOR_8BIT,  0xA407, 0x64},
-		{MISENSOR_8BIT,  0xA408, 0x64},
-		{MISENSOR_8BIT,  0xA409, 0x64},
-		{MISENSOR_8BIT,  0xA40A, 0x64},
-		{MISENSOR_8BIT,  0xA40B, 0x64},
-	},
-	{
-		{MISENSOR_8BIT,  0xA40C, 0x64},
-		{MISENSOR_8BIT,  0xA40D, 0x64},
-		{MISENSOR_8BIT,  0xA40E, 0x64},
-		{MISENSOR_8BIT,  0xA40F, 0x64},
-		{MISENSOR_8BIT,  0xA410, 0x64},
-	},
-	{
-		{MISENSOR_8BIT,  0xA411, 0x64},
-		{MISENSOR_8BIT,  0xA412, 0x64},
-		{MISENSOR_8BIT,  0xA413, 0x64},
-		{MISENSOR_8BIT,  0xA414, 0x64},
-		{MISENSOR_8BIT,  0xA415, 0x64},
-	},
-	{
-		{MISENSOR_8BIT,  0xA416, 0x64},
-		{MISENSOR_8BIT,  0xA417, 0x64},
-		{MISENSOR_8BIT,  0xA418, 0x64},
-		{MISENSOR_8BIT,  0xA419, 0x64},
-		{MISENSOR_8BIT,  0xA41A, 0x64},
-	},
-	{
-		{MISENSOR_8BIT,  0xA41B, 0x64},
-		{MISENSOR_8BIT,  0xA41C, 0x64},
-		{MISENSOR_8BIT,  0xA41D, 0x64},
-		{MISENSOR_8BIT,  0xA41E, 0x64},
-		{MISENSOR_8BIT,  0xA41F, 0x64},
-	},
-};
-
-static struct misensor_reg const mt9m114_exp_average[] = {
-	{MISENSOR_8BIT,  0xA407, 0x00},
-	{MISENSOR_8BIT,  0xA408, 0x00},
-	{MISENSOR_8BIT,  0xA409, 0x00},
-	{MISENSOR_8BIT,  0xA40A, 0x00},
-	{MISENSOR_8BIT,  0xA40B, 0x00},
-	{MISENSOR_8BIT,  0xA40C, 0x00},
-	{MISENSOR_8BIT,  0xA40D, 0x00},
-	{MISENSOR_8BIT,  0xA40E, 0x00},
-	{MISENSOR_8BIT,  0xA40F, 0x00},
-	{MISENSOR_8BIT,  0xA410, 0x00},
-	{MISENSOR_8BIT,  0xA411, 0x00},
-	{MISENSOR_8BIT,  0xA412, 0x00},
-	{MISENSOR_8BIT,  0xA413, 0x00},
-	{MISENSOR_8BIT,  0xA414, 0x00},
-	{MISENSOR_8BIT,  0xA415, 0x00},
-	{MISENSOR_8BIT,  0xA416, 0x00},
-	{MISENSOR_8BIT,  0xA417, 0x00},
-	{MISENSOR_8BIT,  0xA418, 0x00},
-	{MISENSOR_8BIT,  0xA419, 0x00},
-	{MISENSOR_8BIT,  0xA41A, 0x00},
-	{MISENSOR_8BIT,  0xA41B, 0x00},
-	{MISENSOR_8BIT,  0xA41C, 0x00},
-	{MISENSOR_8BIT,  0xA41D, 0x00},
-	{MISENSOR_8BIT,  0xA41E, 0x00},
-	{MISENSOR_8BIT,  0xA41F, 0x00},
-	{MISENSOR_TOK_TERM, 0, 0}
-};
-
-static struct misensor_reg const mt9m114_exp_center[] = {
-	{MISENSOR_8BIT,  0xA407, 0x19},
-	{MISENSOR_8BIT,  0xA408, 0x19},
-	{MISENSOR_8BIT,  0xA409, 0x19},
-	{MISENSOR_8BIT,  0xA40A, 0x19},
-	{MISENSOR_8BIT,  0xA40B, 0x19},
-	{MISENSOR_8BIT,  0xA40C, 0x19},
-	{MISENSOR_8BIT,  0xA40D, 0x4B},
-	{MISENSOR_8BIT,  0xA40E, 0x4B},
-	{MISENSOR_8BIT,  0xA40F, 0x4B},
-	{MISENSOR_8BIT,  0xA410, 0x19},
-	{MISENSOR_8BIT,  0xA411, 0x19},
-	{MISENSOR_8BIT,  0xA412, 0x4B},
-	{MISENSOR_8BIT,  0xA413, 0x64},
-	{MISENSOR_8BIT,  0xA414, 0x4B},
-	{MISENSOR_8BIT,  0xA415, 0x19},
-	{MISENSOR_8BIT,  0xA416, 0x19},
-	{MISENSOR_8BIT,  0xA417, 0x4B},
-	{MISENSOR_8BIT,  0xA418, 0x4B},
-	{MISENSOR_8BIT,  0xA419, 0x4B},
-	{MISENSOR_8BIT,  0xA41A, 0x19},
-	{MISENSOR_8BIT,  0xA41B, 0x19},
-	{MISENSOR_8BIT,  0xA41C, 0x19},
-	{MISENSOR_8BIT,  0xA41D, 0x19},
-	{MISENSOR_8BIT,  0xA41E, 0x19},
-	{MISENSOR_8BIT,  0xA41F, 0x19},
-	{MISENSOR_TOK_TERM, 0, 0}
-};
-
-#if 0 /* Currently unused */
-static struct misensor_reg const mt9m114_suspend[] = {
-	 {MISENSOR_16BIT,  0x098E, 0xDC00},
-	 {MISENSOR_8BIT,  0xDC00, 0x40},
-	 {MISENSOR_16BIT,  0x0080, 0x8002},
-	 {MISENSOR_TOK_TERM, 0, 0}
-};
-
-static struct misensor_reg const mt9m114_streaming[] = {
-	 {MISENSOR_16BIT,  0x098E, 0xDC00},
-	 {MISENSOR_8BIT,  0xDC00, 0x34},
-	 {MISENSOR_16BIT,  0x0080, 0x8002},
-	 {MISENSOR_TOK_TERM, 0, 0}
-};
-#endif
-
-static struct misensor_reg const mt9m114_standby_reg[] = {
-	 {MISENSOR_16BIT,  0x098E, 0xDC00},
-	 {MISENSOR_8BIT,  0xDC00, 0x50},
-	 {MISENSOR_16BIT,  0x0080, 0x8002},
-	 {MISENSOR_TOK_TERM, 0, 0}
-};
-
-#if 0 /* Currently unused */
-static struct misensor_reg const mt9m114_wakeup_reg[] = {
-	 {MISENSOR_16BIT,  0x098E, 0xDC00},
-	 {MISENSOR_8BIT,  0xDC00, 0x54},
-	 {MISENSOR_16BIT,  0x0080, 0x8002},
-	 {MISENSOR_TOK_TERM, 0, 0}
-};
-#endif
-
-static struct misensor_reg const mt9m114_chgstat_reg[] = {
-	{MISENSOR_16BIT,  0x098E, 0xDC00},
-	{MISENSOR_8BIT,  0xDC00, 0x28},
-	{MISENSOR_16BIT,  0x0080, 0x8002},
-	{MISENSOR_TOK_TERM, 0, 0}
-};
-
-/* [1296x976_30fps] - Intel */
-#if 0
-static struct misensor_reg const mt9m114_960P_init[] = {
-	{MISENSOR_16BIT, 0x098E, 0x1000},
-	{MISENSOR_8BIT, 0xC97E, 0x01},	  /* cam_sysctl_pll_enable = 1 */
-	{MISENSOR_16BIT, 0xC980, 0x0128}, /* cam_sysctl_pll_divider_m_n = 276 */
-	{MISENSOR_16BIT, 0xC982, 0x0700}, /* cam_sysctl_pll_divider_p = 1792 */
-	{MISENSOR_16BIT, 0xC800, 0x0000}, /* cam_sensor_cfg_y_addr_start = 0 */
-	{MISENSOR_16BIT, 0xC802, 0x0000}, /* cam_sensor_cfg_x_addr_start = 0 */
-	{MISENSOR_16BIT, 0xC804, 0x03CF}, /* cam_sensor_cfg_y_addr_end = 971 */
-	{MISENSOR_16BIT, 0xC806, 0x050F}, /* cam_sensor_cfg_x_addr_end = 1291 */
-	{MISENSOR_16BIT, 0xC808, 0x02DC}, /* cam_sensor_cfg_pixclk = 48000000 */
-	{MISENSOR_16BIT, 0xC80A, 0x6C00},
-	{MISENSOR_16BIT, 0xC80C, 0x0001}, /* cam_sensor_cfg_row_speed = 1 */
-	/* cam_sensor_cfg_fine_integ_time_min = 219 */
-	{MISENSOR_16BIT, 0xC80E, 0x00DB},
-	/* cam_sensor_cfg_fine_integ_time_max = 1459 */
-	{MISENSOR_16BIT, 0xC810, 0x05B3},
-	/* cam_sensor_cfg_frame_length_lines = 1006 */
-	{MISENSOR_16BIT, 0xC812, 0x03F6},
-	/* cam_sensor_cfg_line_length_pck = 1590 */
-	{MISENSOR_16BIT, 0xC814, 0x063E},
-	/* cam_sensor_cfg_fine_correction = 96 */
-	{MISENSOR_16BIT, 0xC816, 0x0060},
-	/* cam_sensor_cfg_cpipe_last_row = 963 */
-	{MISENSOR_16BIT, 0xC818, 0x03C3},
-	{MISENSOR_16BIT, 0xC826, 0x0020}, /* cam_sensor_cfg_reg_0_data = 32 */
-	{MISENSOR_16BIT, 0xC834, 0x0000}, /* cam_sensor_control_read_mode = 0 */
-	{MISENSOR_16BIT, 0xC854, 0x0000}, /* cam_crop_window_xoffset = 0 */
-	{MISENSOR_16BIT, 0xC856, 0x0000}, /* cam_crop_window_yoffset = 0 */
-	{MISENSOR_16BIT, 0xC858, 0x0508}, /* cam_crop_window_width = 1280 */
-	{MISENSOR_16BIT, 0xC85A, 0x03C8}, /* cam_crop_window_height = 960 */
-	{MISENSOR_8BIT,  0xC85C, 0x03},   /* cam_crop_cropmode = 3 */
-	{MISENSOR_16BIT, 0xC868, 0x0508}, /* cam_output_width = 1280 */
-	{MISENSOR_16BIT, 0xC86A, 0x03C8}, /* cam_output_height = 960 */
-	{MISENSOR_TOK_TERM, 0, 0},
-};
-#endif
-
-/* [1296x976_30fps_768Mbps] */
-static struct misensor_reg const mt9m114_976P_init[] = {
-	{MISENSOR_16BIT, 0x98E, 0x1000},
-	{MISENSOR_8BIT, 0xC97E, 0x01},	  /* cam_sysctl_pll_enable = 1 */
-	{MISENSOR_16BIT, 0xC980, 0x0128}, /* cam_sysctl_pll_divider_m_n = 276 */
-	{MISENSOR_16BIT, 0xC982, 0x0700}, /* cam_sysctl_pll_divider_p = 1792 */
-	{MISENSOR_16BIT, 0xC800, 0x0000}, /* cam_sensor_cfg_y_addr_start = 0 */
-	{MISENSOR_16BIT, 0xC802, 0x0000}, /* cam_sensor_cfg_x_addr_start = 0 */
-	{MISENSOR_16BIT, 0xC804, 0x03CF}, /* cam_sensor_cfg_y_addr_end = 975 */
-	{MISENSOR_16BIT, 0xC806, 0x050F}, /* cam_sensor_cfg_x_addr_end = 1295 */
-	{MISENSOR_32BIT, 0xC808, 0x2DC6C00},/* cam_sensor_cfg_pixclk = 480000*/
-	{MISENSOR_16BIT, 0xC80C, 0x0001}, /* cam_sensor_cfg_row_speed = 1 */
-	/* cam_sensor_cfg_fine_integ_time_min = 219 */
-	{MISENSOR_16BIT, 0xC80E, 0x00DB},
-	 /* 0x062E //cam_sensor_cfg_fine_integ_time_max = 1459 */
-	{MISENSOR_16BIT, 0xC810, 0x05B3},
-	/* 0x074C //cam_sensor_cfg_frame_length_lines = 1006 */
-	{MISENSOR_16BIT, 0xC812, 0x03E5},
-	/* 0x06B1 /cam_sensor_cfg_line_length_pck = 1590 */
-	{MISENSOR_16BIT, 0xC814, 0x0644},
-	/* cam_sensor_cfg_fine_correction = 96 */
-	{MISENSOR_16BIT, 0xC816, 0x0060},
-	/* cam_sensor_cfg_cpipe_last_row = 963 */
-	{MISENSOR_16BIT, 0xC818, 0x03C3},
-	{MISENSOR_16BIT, 0xC826, 0x0020}, /* cam_sensor_cfg_reg_0_data = 32 */
-	{MISENSOR_16BIT, 0xC834, 0x0000}, /* cam_sensor_control_read_mode = 0 */
-	{MISENSOR_16BIT, 0xC854, 0x0000}, /* cam_crop_window_xoffset = 0 */
-	{MISENSOR_16BIT, 0xC856, 0x0000}, /* cam_crop_window_yoffset = 0 */
-	{MISENSOR_16BIT, 0xC858, 0x0508}, /* cam_crop_window_width = 1288 */
-	{MISENSOR_16BIT, 0xC85A, 0x03C8}, /* cam_crop_window_height = 968 */
-	{MISENSOR_8BIT, 0xC85C, 0x03}, /* cam_crop_cropmode = 3 */
-	{MISENSOR_16BIT, 0xC868, 0x0508}, /* cam_output_width = 1288 */
-	{MISENSOR_16BIT, 0xC86A, 0x03C8}, /* cam_output_height = 968 */
-	{MISENSOR_8BIT, 0xC878, 0x00}, /* 0x0E //cam_aet_aemode = 0 */
-	{MISENSOR_TOK_TERM, 0, 0}
-};
-
-/* [1296x864_30fps] */
-static struct misensor_reg const mt9m114_864P_init[] = {
-	{MISENSOR_16BIT, 0x98E, 0x1000},
-	{MISENSOR_8BIT, 0xC97E, 0x01},	  /* cam_sysctl_pll_enable = 1 */
-	{MISENSOR_16BIT, 0xC980, 0x0128}, /* cam_sysctl_pll_divider_m_n = 276 */
-	{MISENSOR_16BIT, 0xC982, 0x0700}, /* cam_sysctl_pll_divider_p = 1792 */
-	{MISENSOR_16BIT, 0xC800, 0x0038}, /* cam_sensor_cfg_y_addr_start = 56 */
-	{MISENSOR_16BIT, 0xC802, 0x0000}, /* cam_sensor_cfg_x_addr_start = 0 */
-	{MISENSOR_16BIT, 0xC804, 0x0397}, /* cam_sensor_cfg_y_addr_end = 919 */
-	{MISENSOR_16BIT, 0xC806, 0x050F}, /* cam_sensor_cfg_x_addr_end = 1295 */
-	/* cam_sensor_cfg_pixclk = 48000000 */
-	{MISENSOR_32BIT, 0xC808, 0x2DC6C00},
-	{MISENSOR_16BIT, 0xC80C, 0x0001}, /* cam_sensor_cfg_row_speed = 1 */
-	/* cam_sensor_cfg_fine_integ_time_min = 219 */
-	{MISENSOR_16BIT, 0xC80E, 0x00DB},
-	/* cam_sensor_cfg_fine_integ_time_max = 1469 */
-	{MISENSOR_16BIT, 0xC810, 0x05BD},
-	/* cam_sensor_cfg_frame_length_lines = 1000 */
-	{MISENSOR_16BIT, 0xC812, 0x03E8},
-	/* cam_sensor_cfg_line_length_pck = 1600 */
-	{MISENSOR_16BIT, 0xC814, 0x0640},
-	/* cam_sensor_cfg_fine_correction = 96 */
-	{MISENSOR_16BIT, 0xC816, 0x0060},
-	/* cam_sensor_cfg_cpipe_last_row = 859 */
-	{MISENSOR_16BIT, 0xC818, 0x035B},
-	{MISENSOR_16BIT, 0xC826, 0x0020}, /* cam_sensor_cfg_reg_0_data = 32 */
-	{MISENSOR_16BIT, 0xC834, 0x0000}, /* cam_sensor_control_read_mode = 0 */
-	{MISENSOR_16BIT, 0xC854, 0x0000}, /* cam_crop_window_xoffset = 0 */
-	{MISENSOR_16BIT, 0xC856, 0x0000}, /* cam_crop_window_yoffset = 0 */
-	{MISENSOR_16BIT, 0xC858, 0x0508}, /* cam_crop_window_width = 1288 */
-	{MISENSOR_16BIT, 0xC85A, 0x0358}, /* cam_crop_window_height = 856 */
-	{MISENSOR_8BIT, 0xC85C, 0x03}, /* cam_crop_cropmode = 3 */
-	{MISENSOR_16BIT, 0xC868, 0x0508}, /* cam_output_width = 1288 */
-	{MISENSOR_16BIT, 0xC86A, 0x0358}, /* cam_output_height = 856 */
-	{MISENSOR_8BIT, 0xC878, 0x00}, /* 0x0E //cam_aet_aemode = 0 */
-	{MISENSOR_TOK_TERM, 0, 0}
-};
-
-/* [1296x736_30fps] */
-static struct misensor_reg const mt9m114_736P_init[] = {
-	{MISENSOR_16BIT, 0x98E, 0x1000},
-	{MISENSOR_8BIT, 0xC97E, 0x01},	  /* cam_sysctl_pll_enable = 1 */
-	{MISENSOR_16BIT, 0xC980, 0x011F}, /* cam_sysctl_pll_divider_m_n = 287 */
-	{MISENSOR_16BIT, 0xC982, 0x0700}, /* cam_sysctl_pll_divider_p = 1792 */
-	{MISENSOR_16BIT, 0xC800, 0x0078}, /* cam_sensor_cfg_y_addr_start = 120*/
-	{MISENSOR_16BIT, 0xC802, 0x0000}, /* cam_sensor_cfg_x_addr_start = 0 */
-	{MISENSOR_16BIT, 0xC804, 0x0357}, /* cam_sensor_cfg_y_addr_end = 855 */
-	{MISENSOR_16BIT, 0xC806, 0x050F}, /* cam_sensor_cfg_x_addr_end = 1295 */
-	{MISENSOR_32BIT, 0xC808, 0x237A07F}, /* cam_sensor_cfg_pixclk=37199999*/
-	{MISENSOR_16BIT, 0xC80C, 0x0001}, /* cam_sensor_cfg_row_speed = 1 */
-	/* cam_sensor_cfg_fine_integ_time_min = 219 */
-	{MISENSOR_16BIT, 0xC80E, 0x00DB},
-	/* 0x062E //cam_sensor_cfg_fine_integ_time_max = 1469 */
-	{MISENSOR_16BIT, 0xC810, 0x05BD},
-	/* 0x074C //cam_sensor_cfg_frame_length_lines = 775 */
-	{MISENSOR_16BIT, 0xC812, 0x0307},
-	/* 0x06B1 /cam_sensor_cfg_line_length_pck = 1600 */
-	{MISENSOR_16BIT, 0xC814, 0x0640},
-	/* cam_sensor_cfg_fine_correction = 96 */
-	{MISENSOR_16BIT, 0xC816, 0x0060},
-	/* cam_sensor_cfg_cpipe_last_row = 731 */
-	{MISENSOR_16BIT, 0xC818, 0x02DB},
-	{MISENSOR_16BIT, 0xC826, 0x0020}, /* cam_sensor_cfg_reg_0_data = 32 */
-	{MISENSOR_16BIT, 0xC834, 0x0000}, /* cam_sensor_control_read_mode = 0 */
-	{MISENSOR_16BIT, 0xC854, 0x0000}, /* cam_crop_window_xoffset = 0 */
-	{MISENSOR_16BIT, 0xC856, 0x0000}, /* cam_crop_window_yoffset = 0 */
-	{MISENSOR_16BIT, 0xC858, 0x0508}, /* cam_crop_window_width = 1288 */
-	{MISENSOR_16BIT, 0xC85A, 0x02D8}, /* cam_crop_window_height = 728 */
-	{MISENSOR_8BIT, 0xC85C, 0x03}, /* cam_crop_cropmode = 3 */
-	{MISENSOR_16BIT, 0xC868, 0x0508}, /* cam_output_width = 1288 */
-	{MISENSOR_16BIT, 0xC86A, 0x02D8}, /* cam_output_height = 728 */
-	{MISENSOR_8BIT, 0xC878, 0x00}, /* 0x0E //cam_aet_aemode = 0 */
-	{MISENSOR_TOK_TERM, 0, 0}
-};
-
-/* [736x496_30fps_768Mbps] */
-#if 0 /* Currently unused */
-static struct misensor_reg const mt9m114_720_480P_init[] = {
-	{MISENSOR_16BIT, 0x98E, 0x1000},
-	{MISENSOR_8BIT, 0xC97E, 0x01},	  /* cam_sysctl_pll_enable = 1 */
-	{MISENSOR_16BIT, 0xC980, 0x0128}, /* cam_sysctl_pll_divider_m_n = 276 */
-	{MISENSOR_16BIT, 0xC982, 0x0700}, /* cam_sysctl_pll_divider_p = 1792 */
-	{MISENSOR_16BIT, 0xC800, 0x00F0}, /* cam_sensor_cfg_y_addr_start = 240*/
-	{MISENSOR_16BIT, 0xC802, 0x0118}, /* cam_sensor_cfg_x_addr_start = 280*/
-	{MISENSOR_16BIT, 0xC804, 0x02DF}, /* cam_sensor_cfg_y_addr_end = 735 */
-	{MISENSOR_16BIT, 0xC806, 0x03F7}, /* cam_sensor_cfg_x_addr_end = 1015 */
-	/* cam_sensor_cfg_pixclk = 48000000 */
-	{MISENSOR_32BIT, 0xC808, 0x2DC6C00},
-	{MISENSOR_16BIT, 0xC80C, 0x0001}, /* cam_sensor_cfg_row_speed = 1 */
-	/* cam_sensor_cfg_fine_integ_time_min = 219 */
-	{MISENSOR_16BIT, 0xC80E, 0x00DB},
-	/* 0x062E //cam_sensor_cfg_fine_integ_time_max = 1459 */
-	{MISENSOR_16BIT, 0xC810, 0x05B3},
-	/* 0x074C //cam_sensor_cfg_frame_length_lines = 997 */
-	{MISENSOR_16BIT, 0xC812, 0x03E5},
-	/* 0x06B1 /cam_sensor_cfg_line_length_pck = 1604 */
-	{MISENSOR_16BIT, 0xC814, 0x0644},
-	/* cam_sensor_cfg_fine_correction = 96 */
-	{MISENSOR_16BIT, 0xC816, 0x0060},
-	{MISENSOR_16BIT, 0xC818, 0x03C3}, /* cam_sensor_cfg_cpipe_last_row=963*/
-	{MISENSOR_16BIT, 0xC826, 0x0020}, /* cam_sensor_cfg_reg_0_data = 32 */
-	{MISENSOR_16BIT, 0xC834, 0x0000}, /* cam_sensor_control_read_mode = 0*/
-	{MISENSOR_16BIT, 0xC854, 0x0000}, /* cam_crop_window_xoffset = 0 */
-	{MISENSOR_16BIT, 0xC856, 0x0000}, /* cam_crop_window_yoffset = 0 */
-	{MISENSOR_16BIT, 0xC858, 0x02D8}, /* cam_crop_window_width = 728 */
-	{MISENSOR_16BIT, 0xC85A, 0x01E8}, /* cam_crop_window_height = 488 */
-	{MISENSOR_8BIT, 0xC85C, 0x03}, /* cam_crop_cropmode = 3 */
-	{MISENSOR_16BIT, 0xC868, 0x02D8}, /* cam_output_width = 728 */
-	{MISENSOR_16BIT, 0xC86A, 0x01E8}, /* cam_output_height = 488 */
-	{MISENSOR_8BIT, 0xC878, 0x00}, /* 0x0E //cam_aet_aemode = 0 */
-	{MISENSOR_TOK_TERM, 0, 0}
-};
-#endif
-
-static struct misensor_reg const mt9m114_common[] = {
-	/* reset */
-	{MISENSOR_16BIT,  0x301A, 0x0234},
-	/* LOAD = Step2-PLL_Timing      //PLL and Timing */
-	{MISENSOR_16BIT, 0x098E, 0x1000}, /* LOGICAL_ADDRESS_ACCESS */
-	{MISENSOR_8BIT, 0xC97E, 0x01},    /* cam_sysctl_pll_enable = 1 */
-	{MISENSOR_16BIT, 0xC980, 0x0128}, /* cam_sysctl_pll_divider_m_n = 276 */
-	{MISENSOR_16BIT, 0xC982, 0x0700}, /* cam_sysctl_pll_divider_p = 1792 */
-	{MISENSOR_16BIT, 0xC800, 0x0000}, /* cam_sensor_cfg_y_addr_start = 216*/
-	{MISENSOR_16BIT, 0xC802, 0x0000}, /* cam_sensor_cfg_x_addr_start = 168*/
-	{MISENSOR_16BIT, 0xC804, 0x03CD}, /* cam_sensor_cfg_y_addr_end = 761 */
-	{MISENSOR_16BIT, 0xC806, 0x050D}, /* cam_sensor_cfg_x_addr_end = 1127 */
-	{MISENSOR_16BIT, 0xC808, 0x02DC}, /* cam_sensor_cfg_pixclk = 24000000 */
-	{MISENSOR_16BIT, 0xC80A, 0x6C00},
-	{MISENSOR_16BIT, 0xC80C, 0x0001}, /* cam_sensor_cfg_row_speed = 1 */
-	/* cam_sensor_cfg_fine_integ_time_min = 219 */
-	{MISENSOR_16BIT, 0xC80E, 0x01C3},
-	/* cam_sensor_cfg_fine_integ_time_max = 1149 */
-	{MISENSOR_16BIT, 0xC810, 0x03F7},
-	/* cam_sensor_cfg_frame_length_lines = 625 */
-	{MISENSOR_16BIT, 0xC812, 0x0500},
-	/* cam_sensor_cfg_line_length_pck = 1280 */
-	{MISENSOR_16BIT, 0xC814, 0x04E2},
-	/* cam_sensor_cfg_fine_correction = 96 */
-	{MISENSOR_16BIT, 0xC816, 0x00E0},
-	/* cam_sensor_cfg_cpipe_last_row = 541 */
-	{MISENSOR_16BIT, 0xC818, 0x01E3},
-	{MISENSOR_16BIT, 0xC826, 0x0020}, /* cam_sensor_cfg_reg_0_data = 32 */
-	{MISENSOR_16BIT, 0xC834, 0x0330}, /* cam_sensor_control_read_mode = 0 */
-	{MISENSOR_16BIT, 0xC854, 0x0000}, /* cam_crop_window_xoffset = 0 */
-	{MISENSOR_16BIT, 0xC856, 0x0000}, /* cam_crop_window_yoffset = 0 */
-	{MISENSOR_16BIT, 0xC858, 0x0280}, /* cam_crop_window_width = 952 */
-	{MISENSOR_16BIT, 0xC85A, 0x01E0}, /* cam_crop_window_height = 538 */
-	{MISENSOR_8BIT, 0xC85C, 0x03},    /* cam_crop_cropmode = 3 */
-	{MISENSOR_16BIT, 0xC868, 0x0280}, /* cam_output_width = 952 */
-	{MISENSOR_16BIT, 0xC86A, 0x01E0}, /* cam_output_height = 538 */
-	/* LOAD = Step3-Recommended
-	 * Patch,Errata and Sensor optimization Setting */
-	{MISENSOR_16BIT, 0x316A, 0x8270}, /* DAC_TXLO_ROW */
-	{MISENSOR_16BIT, 0x316C, 0x8270}, /* DAC_TXLO */
-	{MISENSOR_16BIT, 0x3ED0, 0x2305}, /* DAC_LD_4_5 */
-	{MISENSOR_16BIT, 0x3ED2, 0x77CF}, /* DAC_LD_6_7 */
-	{MISENSOR_16BIT, 0x316E, 0x8202}, /* DAC_ECL */
-	{MISENSOR_16BIT, 0x3180, 0x87FF}, /* DELTA_DK_CONTROL */
-	{MISENSOR_16BIT, 0x30D4, 0x6080}, /* COLUMN_CORRECTION */
-	{MISENSOR_16BIT, 0xA802, 0x0008}, /* AE_TRACK_MODE */
-	{MISENSOR_16BIT, 0x3E14, 0xFF39}, /* SAMP_COL_PUP2 */
-	{MISENSOR_16BIT, 0x31E0, 0x0003}, /* PIX_DEF_ID */
-	/* LOAD = Step8-Features	//Ports, special features, etc. */
-	{MISENSOR_16BIT, 0x098E, 0x0000}, /* LOGICAL_ADDRESS_ACCESS */
-	{MISENSOR_16BIT, 0x001E, 0x0777}, /* PAD_SLEW */
-	{MISENSOR_16BIT, 0x098E, 0x0000}, /* LOGICAL_ADDRESS_ACCESS */
-	{MISENSOR_16BIT, 0xC984, 0x8001}, /* CAM_PORT_OUTPUT_CONTROL */
-	{MISENSOR_16BIT, 0xC988, 0x0F00}, /* CAM_PORT_MIPI_TIMING_T_HS_ZERO */
-	/* CAM_PORT_MIPI_TIMING_T_HS_EXIT_HS_TRAIL */
-	{MISENSOR_16BIT, 0xC98A, 0x0B07},
-	/* CAM_PORT_MIPI_TIMING_T_CLK_POST_CLK_PRE */
-	{MISENSOR_16BIT, 0xC98C, 0x0D01},
-	/* CAM_PORT_MIPI_TIMING_T_CLK_TRAIL_CLK_ZERO */
-	{MISENSOR_16BIT, 0xC98E, 0x071D},
-	{MISENSOR_16BIT, 0xC990, 0x0006}, /* CAM_PORT_MIPI_TIMING_T_LPX */
-	{MISENSOR_16BIT, 0xC992, 0x0A0C}, /* CAM_PORT_MIPI_TIMING_INIT_TIMING */
-	{MISENSOR_16BIT, 0x3C5A, 0x0009}, /* MIPI_DELAY_TRIM */
-	{MISENSOR_16BIT, 0xC86C, 0x0210}, /* CAM_OUTPUT_FORMAT */
-	{MISENSOR_16BIT, 0xA804, 0x0000}, /* AE_TRACK_ALGO */
-	/* default exposure */
-	{MISENSOR_16BIT, 0x3012, 0x0110}, /* COMMAND_REGISTER */
-	{MISENSOR_TOK_TERM, 0, 0},
-
-};
-#if 0 /* Currently unused */
-static struct misensor_reg const mt9m114_antiflicker_50hz[] = {
-	 {MISENSOR_16BIT,  0x098E, 0xC88B},
-	 {MISENSOR_8BIT,  0xC88B, 0x32},
-	 {MISENSOR_8BIT,  0xDC00, 0x28},
-	 {MISENSOR_16BIT,  0x0080, 0x8002},
-	 {MISENSOR_TOK_TERM, 0, 0}
-};
-
-static struct misensor_reg const mt9m114_antiflicker_60hz[] = {
-	 {MISENSOR_16BIT,  0x098E, 0xC88B},
-	 {MISENSOR_8BIT,  0xC88B, 0x3C},
-	 {MISENSOR_8BIT,  0xDC00, 0x28},
-	 {MISENSOR_16BIT,  0x0080, 0x8002},
-	 {MISENSOR_TOK_TERM, 0, 0}
-};
-
-static struct misensor_reg const mt9m114_iq[] = {
-	/* [Step3-Recommended] [Sensor optimization] */
-	{MISENSOR_16BIT,	0x316A, 0x8270},
-	{MISENSOR_16BIT,	0x316C, 0x8270},
-	{MISENSOR_16BIT,	0x3ED0, 0x2305},
-	{MISENSOR_16BIT,	0x3ED2, 0x77CF},
-	{MISENSOR_16BIT,	0x316E, 0x8202},
-	{MISENSOR_16BIT,	0x3180, 0x87FF},
-	{MISENSOR_16BIT,	0x30D4, 0x6080},
-	{MISENSOR_16BIT,	0xA802, 0x0008},
-
-	/* This register is from vender to avoid low light color noise */
-	{MISENSOR_16BIT,	0x31E0, 0x0001},
-
-	/* LOAD=Errata item 1 */
-	{MISENSOR_16BIT,	0x3E14, 0xFF39},
-
-	/* LOAD=Errata item 2 */
-	{MISENSOR_16BIT,	0x301A, 0x8234},
-
-	/*
-	 * LOAD=Errata item 3
-	 * LOAD=Patch 0202;
-	 * Feature Recommended; Black level correction fix
-	 */
-	{MISENSOR_16BIT,	0x0982, 0x0001},
-	{MISENSOR_16BIT,	0x098A, 0x5000},
-	{MISENSOR_16BIT,	0xD000, 0x70CF},
-	{MISENSOR_16BIT,	0xD002, 0xFFFF},
-	{MISENSOR_16BIT,	0xD004, 0xC5D4},
-	{MISENSOR_16BIT,	0xD006, 0x903A},
-	{MISENSOR_16BIT,	0xD008, 0x2144},
-	{MISENSOR_16BIT,	0xD00A, 0x0C00},
-	{MISENSOR_16BIT,	0xD00C, 0x2186},
-	{MISENSOR_16BIT,	0xD00E, 0x0FF3},
-	{MISENSOR_16BIT,	0xD010, 0xB844},
-	{MISENSOR_16BIT,	0xD012, 0xB948},
-	{MISENSOR_16BIT,	0xD014, 0xE082},
-	{MISENSOR_16BIT,	0xD016, 0x20CC},
-	{MISENSOR_16BIT,	0xD018, 0x80E2},
-	{MISENSOR_16BIT,	0xD01A, 0x21CC},
-	{MISENSOR_16BIT,	0xD01C, 0x80A2},
-	{MISENSOR_16BIT,	0xD01E, 0x21CC},
-	{MISENSOR_16BIT,	0xD020, 0x80E2},
-	{MISENSOR_16BIT,	0xD022, 0xF404},
-	{MISENSOR_16BIT,	0xD024, 0xD801},
-	{MISENSOR_16BIT,	0xD026, 0xF003},
-	{MISENSOR_16BIT,	0xD028, 0xD800},
-	{MISENSOR_16BIT,	0xD02A, 0x7EE0},
-	{MISENSOR_16BIT,	0xD02C, 0xC0F1},
-	{MISENSOR_16BIT,	0xD02E, 0x08BA},
-
-	{MISENSOR_16BIT,	0xD030, 0x0600},
-	{MISENSOR_16BIT,	0xD032, 0xC1A1},
-	{MISENSOR_16BIT,	0xD034, 0x76CF},
-	{MISENSOR_16BIT,	0xD036, 0xFFFF},
-	{MISENSOR_16BIT,	0xD038, 0xC130},
-	{MISENSOR_16BIT,	0xD03A, 0x6E04},
-	{MISENSOR_16BIT,	0xD03C, 0xC040},
-	{MISENSOR_16BIT,	0xD03E, 0x71CF},
-	{MISENSOR_16BIT,	0xD040, 0xFFFF},
-	{MISENSOR_16BIT,	0xD042, 0xC790},
-	{MISENSOR_16BIT,	0xD044, 0x8103},
-	{MISENSOR_16BIT,	0xD046, 0x77CF},
-	{MISENSOR_16BIT,	0xD048, 0xFFFF},
-	{MISENSOR_16BIT,	0xD04A, 0xC7C0},
-	{MISENSOR_16BIT,	0xD04C, 0xE001},
-	{MISENSOR_16BIT,	0xD04E, 0xA103},
-	{MISENSOR_16BIT,	0xD050, 0xD800},
-	{MISENSOR_16BIT,	0xD052, 0x0C6A},
-	{MISENSOR_16BIT,	0xD054, 0x04E0},
-	{MISENSOR_16BIT,	0xD056, 0xB89E},
-	{MISENSOR_16BIT,	0xD058, 0x7508},
-	{MISENSOR_16BIT,	0xD05A, 0x8E1C},
-	{MISENSOR_16BIT,	0xD05C, 0x0809},
-	{MISENSOR_16BIT,	0xD05E, 0x0191},
-
-	{MISENSOR_16BIT,	0xD060, 0xD801},
-	{MISENSOR_16BIT,	0xD062, 0xAE1D},
-	{MISENSOR_16BIT,	0xD064, 0xE580},
-	{MISENSOR_16BIT,	0xD066, 0x20CA},
-	{MISENSOR_16BIT,	0xD068, 0x0022},
-	{MISENSOR_16BIT,	0xD06A, 0x20CF},
-	{MISENSOR_16BIT,	0xD06C, 0x0522},
-	{MISENSOR_16BIT,	0xD06E, 0x0C5C},
-	{MISENSOR_16BIT,	0xD070, 0x04E2},
-	{MISENSOR_16BIT,	0xD072, 0x21CA},
-	{MISENSOR_16BIT,	0xD074, 0x0062},
-	{MISENSOR_16BIT,	0xD076, 0xE580},
-	{MISENSOR_16BIT,	0xD078, 0xD901},
-	{MISENSOR_16BIT,	0xD07A, 0x79C0},
-	{MISENSOR_16BIT,	0xD07C, 0xD800},
-	{MISENSOR_16BIT,	0xD07E, 0x0BE6},
-	{MISENSOR_16BIT,	0xD080, 0x04E0},
-	{MISENSOR_16BIT,	0xD082, 0xB89E},
-	{MISENSOR_16BIT,	0xD084, 0x70CF},
-	{MISENSOR_16BIT,	0xD086, 0xFFFF},
-	{MISENSOR_16BIT,	0xD088, 0xC8D4},
-	{MISENSOR_16BIT,	0xD08A, 0x9002},
-	{MISENSOR_16BIT,	0xD08C, 0x0857},
-	{MISENSOR_16BIT,	0xD08E, 0x025E},
-
-	{MISENSOR_16BIT,	0xD090, 0xFFDC},
-	{MISENSOR_16BIT,	0xD092, 0xE080},
-	{MISENSOR_16BIT,	0xD094, 0x25CC},
-	{MISENSOR_16BIT,	0xD096, 0x9022},
-	{MISENSOR_16BIT,	0xD098, 0xF225},
-	{MISENSOR_16BIT,	0xD09A, 0x1700},
-	{MISENSOR_16BIT,	0xD09C, 0x108A},
-	{MISENSOR_16BIT,	0xD09E, 0x73CF},
-	{MISENSOR_16BIT,	0xD0A0, 0xFF00},
-	{MISENSOR_16BIT,	0xD0A2, 0x3174},
-	{MISENSOR_16BIT,	0xD0A4, 0x9307},
-	{MISENSOR_16BIT,	0xD0A6, 0x2A04},
-	{MISENSOR_16BIT,	0xD0A8, 0x103E},
-	{MISENSOR_16BIT,	0xD0AA, 0x9328},
-	{MISENSOR_16BIT,	0xD0AC, 0x2942},
-	{MISENSOR_16BIT,	0xD0AE, 0x7140},
-	{MISENSOR_16BIT,	0xD0B0, 0x2A04},
-	{MISENSOR_16BIT,	0xD0B2, 0x107E},
-	{MISENSOR_16BIT,	0xD0B4, 0x9349},
-	{MISENSOR_16BIT,	0xD0B6, 0x2942},
-	{MISENSOR_16BIT,	0xD0B8, 0x7141},
-	{MISENSOR_16BIT,	0xD0BA, 0x2A04},
-	{MISENSOR_16BIT,	0xD0BC, 0x10BE},
-	{MISENSOR_16BIT,	0xD0BE, 0x934A},
-
-	{MISENSOR_16BIT,	0xD0C0, 0x2942},
-	{MISENSOR_16BIT,	0xD0C2, 0x714B},
-	{MISENSOR_16BIT,	0xD0C4, 0x2A04},
-	{MISENSOR_16BIT,	0xD0C6, 0x10BE},
-	{MISENSOR_16BIT,	0xD0C8, 0x130C},
-	{MISENSOR_16BIT,	0xD0CA, 0x010A},
-	{MISENSOR_16BIT,	0xD0CC, 0x2942},
-	{MISENSOR_16BIT,	0xD0CE, 0x7142},
-	{MISENSOR_16BIT,	0xD0D0, 0x2250},
-	{MISENSOR_16BIT,	0xD0D2, 0x13CA},
-	{MISENSOR_16BIT,	0xD0D4, 0x1B0C},
-	{MISENSOR_16BIT,	0xD0D6, 0x0284},
-	{MISENSOR_16BIT,	0xD0D8, 0xB307},
-	{MISENSOR_16BIT,	0xD0DA, 0xB328},
-	{MISENSOR_16BIT,	0xD0DC, 0x1B12},
-	{MISENSOR_16BIT,	0xD0DE, 0x02C4},
-	{MISENSOR_16BIT,	0xD0E0, 0xB34A},
-	{MISENSOR_16BIT,	0xD0E2, 0xED88},
-	{MISENSOR_16BIT,	0xD0E4, 0x71CF},
-	{MISENSOR_16BIT,	0xD0E6, 0xFF00},
-	{MISENSOR_16BIT,	0xD0E8, 0x3174},
-	{MISENSOR_16BIT,	0xD0EA, 0x9106},
-	{MISENSOR_16BIT,	0xD0EC, 0xB88F},
-	{MISENSOR_16BIT,	0xD0EE, 0xB106},
-
-	{MISENSOR_16BIT,	0xD0F0, 0x210A},
-	{MISENSOR_16BIT,	0xD0F2, 0x8340},
-	{MISENSOR_16BIT,	0xD0F4, 0xC000},
-	{MISENSOR_16BIT,	0xD0F6, 0x21CA},
-	{MISENSOR_16BIT,	0xD0F8, 0x0062},
-	{MISENSOR_16BIT,	0xD0FA, 0x20F0},
-	{MISENSOR_16BIT,	0xD0FC, 0x0040},
-	{MISENSOR_16BIT,	0xD0FE, 0x0B02},
-	{MISENSOR_16BIT,	0xD100, 0x0320},
-	{MISENSOR_16BIT,	0xD102, 0xD901},
-	{MISENSOR_16BIT,	0xD104, 0x07F1},
-	{MISENSOR_16BIT,	0xD106, 0x05E0},
-	{MISENSOR_16BIT,	0xD108, 0xC0A1},
-	{MISENSOR_16BIT,	0xD10A, 0x78E0},
-	{MISENSOR_16BIT,	0xD10C, 0xC0F1},
-	{MISENSOR_16BIT,	0xD10E, 0x71CF},
-	{MISENSOR_16BIT,	0xD110, 0xFFFF},
-	{MISENSOR_16BIT,	0xD112, 0xC7C0},
-	{MISENSOR_16BIT,	0xD114, 0xD840},
-	{MISENSOR_16BIT,	0xD116, 0xA900},
-	{MISENSOR_16BIT,	0xD118, 0x71CF},
-	{MISENSOR_16BIT,	0xD11A, 0xFFFF},
-	{MISENSOR_16BIT,	0xD11C, 0xD02C},
-	{MISENSOR_16BIT,	0xD11E, 0xD81E},
-
-	{MISENSOR_16BIT,	0xD120, 0x0A5A},
-	{MISENSOR_16BIT,	0xD122, 0x04E0},
-	{MISENSOR_16BIT,	0xD124, 0xDA00},
-	{MISENSOR_16BIT,	0xD126, 0xD800},
-	{MISENSOR_16BIT,	0xD128, 0xC0D1},
-	{MISENSOR_16BIT,	0xD12A, 0x7EE0},
-
-	{MISENSOR_16BIT,	0x098E, 0x0000},
-	{MISENSOR_16BIT,	0xE000, 0x010C},
-	{MISENSOR_16BIT,	0xE002, 0x0202},
-	{MISENSOR_16BIT,	0xE004, 0x4103},
-	{MISENSOR_16BIT,	0xE006, 0x0202},
-	{MISENSOR_16BIT,	0x0080, 0xFFF0},
-	{MISENSOR_16BIT,	0x0080, 0xFFF1},
-
-	/* LOAD=Patch 0302; Feature Recommended; Adaptive Sensitivity */
-	{MISENSOR_16BIT,	0x0982, 0x0001},
-	{MISENSOR_16BIT,	0x098A, 0x512C},
-	{MISENSOR_16BIT,	0xD12C, 0x70CF},
-	{MISENSOR_16BIT,	0xD12E, 0xFFFF},
-	{MISENSOR_16BIT,	0xD130, 0xC5D4},
-	{MISENSOR_16BIT,	0xD132, 0x903A},
-	{MISENSOR_16BIT,	0xD134, 0x2144},
-	{MISENSOR_16BIT,	0xD136, 0x0C00},
-	{MISENSOR_16BIT,	0xD138, 0x2186},
-	{MISENSOR_16BIT,	0xD13A, 0x0FF3},
-	{MISENSOR_16BIT,	0xD13C, 0xB844},
-	{MISENSOR_16BIT,	0xD13E, 0x262F},
-	{MISENSOR_16BIT,	0xD140, 0xF008},
-	{MISENSOR_16BIT,	0xD142, 0xB948},
-	{MISENSOR_16BIT,	0xD144, 0x21CC},
-	{MISENSOR_16BIT,	0xD146, 0x8021},
-	{MISENSOR_16BIT,	0xD148, 0xD801},
-	{MISENSOR_16BIT,	0xD14A, 0xF203},
-	{MISENSOR_16BIT,	0xD14C, 0xD800},
-	{MISENSOR_16BIT,	0xD14E, 0x7EE0},
-	{MISENSOR_16BIT,	0xD150, 0xC0F1},
-	{MISENSOR_16BIT,	0xD152, 0x71CF},
-	{MISENSOR_16BIT,	0xD154, 0xFFFF},
-	{MISENSOR_16BIT,	0xD156, 0xC610},
-	{MISENSOR_16BIT,	0xD158, 0x910E},
-	{MISENSOR_16BIT,	0xD15A, 0x208C},
-	{MISENSOR_16BIT,	0xD15C, 0x8014},
-	{MISENSOR_16BIT,	0xD15E, 0xF418},
-	{MISENSOR_16BIT,	0xD160, 0x910F},
-	{MISENSOR_16BIT,	0xD162, 0x208C},
-	{MISENSOR_16BIT,	0xD164, 0x800F},
-	{MISENSOR_16BIT,	0xD166, 0xF414},
-	{MISENSOR_16BIT,	0xD168, 0x9116},
-	{MISENSOR_16BIT,	0xD16A, 0x208C},
-	{MISENSOR_16BIT,	0xD16C, 0x800A},
-	{MISENSOR_16BIT,	0xD16E, 0xF410},
-	{MISENSOR_16BIT,	0xD170, 0x9117},
-	{MISENSOR_16BIT,	0xD172, 0x208C},
-	{MISENSOR_16BIT,	0xD174, 0x8807},
-	{MISENSOR_16BIT,	0xD176, 0xF40C},
-	{MISENSOR_16BIT,	0xD178, 0x9118},
-	{MISENSOR_16BIT,	0xD17A, 0x2086},
-	{MISENSOR_16BIT,	0xD17C, 0x0FF3},
-	{MISENSOR_16BIT,	0xD17E, 0xB848},
-	{MISENSOR_16BIT,	0xD180, 0x080D},
-	{MISENSOR_16BIT,	0xD182, 0x0090},
-	{MISENSOR_16BIT,	0xD184, 0xFFEA},
-	{MISENSOR_16BIT,	0xD186, 0xE081},
-	{MISENSOR_16BIT,	0xD188, 0xD801},
-	{MISENSOR_16BIT,	0xD18A, 0xF203},
-	{MISENSOR_16BIT,	0xD18C, 0xD800},
-	{MISENSOR_16BIT,	0xD18E, 0xC0D1},
-	{MISENSOR_16BIT,	0xD190, 0x7EE0},
-	{MISENSOR_16BIT,	0xD192, 0x78E0},
-	{MISENSOR_16BIT,	0xD194, 0xC0F1},
-	{MISENSOR_16BIT,	0xD196, 0x71CF},
-	{MISENSOR_16BIT,	0xD198, 0xFFFF},
-	{MISENSOR_16BIT,	0xD19A, 0xC610},
-	{MISENSOR_16BIT,	0xD19C, 0x910E},
-	{MISENSOR_16BIT,	0xD19E, 0x208C},
-	{MISENSOR_16BIT,	0xD1A0, 0x800A},
-	{MISENSOR_16BIT,	0xD1A2, 0xF418},
-	{MISENSOR_16BIT,	0xD1A4, 0x910F},
-	{MISENSOR_16BIT,	0xD1A6, 0x208C},
-	{MISENSOR_16BIT,	0xD1A8, 0x8807},
-	{MISENSOR_16BIT,	0xD1AA, 0xF414},
-	{MISENSOR_16BIT,	0xD1AC, 0x9116},
-	{MISENSOR_16BIT,	0xD1AE, 0x208C},
-	{MISENSOR_16BIT,	0xD1B0, 0x800A},
-	{MISENSOR_16BIT,	0xD1B2, 0xF410},
-	{MISENSOR_16BIT,	0xD1B4, 0x9117},
-	{MISENSOR_16BIT,	0xD1B6, 0x208C},
-	{MISENSOR_16BIT,	0xD1B8, 0x8807},
-	{MISENSOR_16BIT,	0xD1BA, 0xF40C},
-	{MISENSOR_16BIT,	0xD1BC, 0x9118},
-	{MISENSOR_16BIT,	0xD1BE, 0x2086},
-	{MISENSOR_16BIT,	0xD1C0, 0x0FF3},
-	{MISENSOR_16BIT,	0xD1C2, 0xB848},
-	{MISENSOR_16BIT,	0xD1C4, 0x080D},
-	{MISENSOR_16BIT,	0xD1C6, 0x0090},
-	{MISENSOR_16BIT,	0xD1C8, 0xFFD9},
-	{MISENSOR_16BIT,	0xD1CA, 0xE080},
-	{MISENSOR_16BIT,	0xD1CC, 0xD801},
-	{MISENSOR_16BIT,	0xD1CE, 0xF203},
-	{MISENSOR_16BIT,	0xD1D0, 0xD800},
-	{MISENSOR_16BIT,	0xD1D2, 0xF1DF},
-	{MISENSOR_16BIT,	0xD1D4, 0x9040},
-	{MISENSOR_16BIT,	0xD1D6, 0x71CF},
-	{MISENSOR_16BIT,	0xD1D8, 0xFFFF},
-	{MISENSOR_16BIT,	0xD1DA, 0xC5D4},
-	{MISENSOR_16BIT,	0xD1DC, 0xB15A},
-	{MISENSOR_16BIT,	0xD1DE, 0x9041},
-	{MISENSOR_16BIT,	0xD1E0, 0x73CF},
-	{MISENSOR_16BIT,	0xD1E2, 0xFFFF},
-	{MISENSOR_16BIT,	0xD1E4, 0xC7D0},
-	{MISENSOR_16BIT,	0xD1E6, 0xB140},
-	{MISENSOR_16BIT,	0xD1E8, 0x9042},
-	{MISENSOR_16BIT,	0xD1EA, 0xB141},
-	{MISENSOR_16BIT,	0xD1EC, 0x9043},
-	{MISENSOR_16BIT,	0xD1EE, 0xB142},
-	{MISENSOR_16BIT,	0xD1F0, 0x9044},
-	{MISENSOR_16BIT,	0xD1F2, 0xB143},
-	{MISENSOR_16BIT,	0xD1F4, 0x9045},
-	{MISENSOR_16BIT,	0xD1F6, 0xB147},
-	{MISENSOR_16BIT,	0xD1F8, 0x9046},
-	{MISENSOR_16BIT,	0xD1FA, 0xB148},
-	{MISENSOR_16BIT,	0xD1FC, 0x9047},
-	{MISENSOR_16BIT,	0xD1FE, 0xB14B},
-	{MISENSOR_16BIT,	0xD200, 0x9048},
-	{MISENSOR_16BIT,	0xD202, 0xB14C},
-	{MISENSOR_16BIT,	0xD204, 0x9049},
-	{MISENSOR_16BIT,	0xD206, 0x1958},
-	{MISENSOR_16BIT,	0xD208, 0x0084},
-	{MISENSOR_16BIT,	0xD20A, 0x904A},
-	{MISENSOR_16BIT,	0xD20C, 0x195A},
-	{MISENSOR_16BIT,	0xD20E, 0x0084},
-	{MISENSOR_16BIT,	0xD210, 0x8856},
-	{MISENSOR_16BIT,	0xD212, 0x1B36},
-	{MISENSOR_16BIT,	0xD214, 0x8082},
-	{MISENSOR_16BIT,	0xD216, 0x8857},
-	{MISENSOR_16BIT,	0xD218, 0x1B37},
-	{MISENSOR_16BIT,	0xD21A, 0x8082},
-	{MISENSOR_16BIT,	0xD21C, 0x904C},
-	{MISENSOR_16BIT,	0xD21E, 0x19A7},
-	{MISENSOR_16BIT,	0xD220, 0x009C},
-	{MISENSOR_16BIT,	0xD222, 0x881A},
-	{MISENSOR_16BIT,	0xD224, 0x7FE0},
-	{MISENSOR_16BIT,	0xD226, 0x1B54},
-	{MISENSOR_16BIT,	0xD228, 0x8002},
-	{MISENSOR_16BIT,	0xD22A, 0x78E0},
-	{MISENSOR_16BIT,	0xD22C, 0x71CF},
-	{MISENSOR_16BIT,	0xD22E, 0xFFFF},
-	{MISENSOR_16BIT,	0xD230, 0xC350},
-	{MISENSOR_16BIT,	0xD232, 0xD828},
-	{MISENSOR_16BIT,	0xD234, 0xA90B},
-	{MISENSOR_16BIT,	0xD236, 0x8100},
-	{MISENSOR_16BIT,	0xD238, 0x01C5},
-	{MISENSOR_16BIT,	0xD23A, 0x0320},
-	{MISENSOR_16BIT,	0xD23C, 0xD900},
-	{MISENSOR_16BIT,	0xD23E, 0x78E0},
-	{MISENSOR_16BIT,	0xD240, 0x220A},
-	{MISENSOR_16BIT,	0xD242, 0x1F80},
-	{MISENSOR_16BIT,	0xD244, 0xFFFF},
-	{MISENSOR_16BIT,	0xD246, 0xD4E0},
-	{MISENSOR_16BIT,	0xD248, 0xC0F1},
-	{MISENSOR_16BIT,	0xD24A, 0x0811},
-	{MISENSOR_16BIT,	0xD24C, 0x0051},
-	{MISENSOR_16BIT,	0xD24E, 0x2240},
-	{MISENSOR_16BIT,	0xD250, 0x1200},
-	{MISENSOR_16BIT,	0xD252, 0xFFE1},
-	{MISENSOR_16BIT,	0xD254, 0xD801},
-	{MISENSOR_16BIT,	0xD256, 0xF006},
-	{MISENSOR_16BIT,	0xD258, 0x2240},
-	{MISENSOR_16BIT,	0xD25A, 0x1900},
-	{MISENSOR_16BIT,	0xD25C, 0xFFDE},
-	{MISENSOR_16BIT,	0xD25E, 0xD802},
-	{MISENSOR_16BIT,	0xD260, 0x1A05},
-	{MISENSOR_16BIT,	0xD262, 0x1002},
-	{MISENSOR_16BIT,	0xD264, 0xFFF2},
-	{MISENSOR_16BIT,	0xD266, 0xF195},
-	{MISENSOR_16BIT,	0xD268, 0xC0F1},
-	{MISENSOR_16BIT,	0xD26A, 0x0E7E},
-	{MISENSOR_16BIT,	0xD26C, 0x05C0},
-	{MISENSOR_16BIT,	0xD26E, 0x75CF},
-	{MISENSOR_16BIT,	0xD270, 0xFFFF},
-	{MISENSOR_16BIT,	0xD272, 0xC84C},
-	{MISENSOR_16BIT,	0xD274, 0x9502},
-	{MISENSOR_16BIT,	0xD276, 0x77CF},
-	{MISENSOR_16BIT,	0xD278, 0xFFFF},
-	{MISENSOR_16BIT,	0xD27A, 0xC344},
-	{MISENSOR_16BIT,	0xD27C, 0x2044},
-	{MISENSOR_16BIT,	0xD27E, 0x008E},
-	{MISENSOR_16BIT,	0xD280, 0xB8A1},
-	{MISENSOR_16BIT,	0xD282, 0x0926},
-	{MISENSOR_16BIT,	0xD284, 0x03E0},
-	{MISENSOR_16BIT,	0xD286, 0xB502},
-	{MISENSOR_16BIT,	0xD288, 0x9502},
-	{MISENSOR_16BIT,	0xD28A, 0x952E},
-	{MISENSOR_16BIT,	0xD28C, 0x7E05},
-	{MISENSOR_16BIT,	0xD28E, 0xB5C2},
-	{MISENSOR_16BIT,	0xD290, 0x70CF},
-	{MISENSOR_16BIT,	0xD292, 0xFFFF},
-	{MISENSOR_16BIT,	0xD294, 0xC610},
-	{MISENSOR_16BIT,	0xD296, 0x099A},
-	{MISENSOR_16BIT,	0xD298, 0x04A0},
-	{MISENSOR_16BIT,	0xD29A, 0xB026},
-	{MISENSOR_16BIT,	0xD29C, 0x0E02},
-	{MISENSOR_16BIT,	0xD29E, 0x0560},
-	{MISENSOR_16BIT,	0xD2A0, 0xDE00},
-	{MISENSOR_16BIT,	0xD2A2, 0x0A12},
-	{MISENSOR_16BIT,	0xD2A4, 0x0320},
-	{MISENSOR_16BIT,	0xD2A6, 0xB7C4},
-	{MISENSOR_16BIT,	0xD2A8, 0x0B36},
-	{MISENSOR_16BIT,	0xD2AA, 0x03A0},
-	{MISENSOR_16BIT,	0xD2AC, 0x70C9},
-	{MISENSOR_16BIT,	0xD2AE, 0x9502},
-	{MISENSOR_16BIT,	0xD2B0, 0x7608},
-	{MISENSOR_16BIT,	0xD2B2, 0xB8A8},
-	{MISENSOR_16BIT,	0xD2B4, 0xB502},
-	{MISENSOR_16BIT,	0xD2B6, 0x70CF},
-	{MISENSOR_16BIT,	0xD2B8, 0x0000},
-	{MISENSOR_16BIT,	0xD2BA, 0x5536},
-	{MISENSOR_16BIT,	0xD2BC, 0x7860},
-	{MISENSOR_16BIT,	0xD2BE, 0x2686},
-	{MISENSOR_16BIT,	0xD2C0, 0x1FFB},
-	{MISENSOR_16BIT,	0xD2C2, 0x9502},
-	{MISENSOR_16BIT,	0xD2C4, 0x78C5},
-	{MISENSOR_16BIT,	0xD2C6, 0x0631},
-	{MISENSOR_16BIT,	0xD2C8, 0x05E0},
-	{MISENSOR_16BIT,	0xD2CA, 0xB502},
-	{MISENSOR_16BIT,	0xD2CC, 0x72CF},
-	{MISENSOR_16BIT,	0xD2CE, 0xFFFF},
-	{MISENSOR_16BIT,	0xD2D0, 0xC5D4},
-	{MISENSOR_16BIT,	0xD2D2, 0x923A},
-	{MISENSOR_16BIT,	0xD2D4, 0x73CF},
-	{MISENSOR_16BIT,	0xD2D6, 0xFFFF},
-	{MISENSOR_16BIT,	0xD2D8, 0xC7D0},
-	{MISENSOR_16BIT,	0xD2DA, 0xB020},
-	{MISENSOR_16BIT,	0xD2DC, 0x9220},
-	{MISENSOR_16BIT,	0xD2DE, 0xB021},
-	{MISENSOR_16BIT,	0xD2E0, 0x9221},
-	{MISENSOR_16BIT,	0xD2E2, 0xB022},
-	{MISENSOR_16BIT,	0xD2E4, 0x9222},
-	{MISENSOR_16BIT,	0xD2E6, 0xB023},
-	{MISENSOR_16BIT,	0xD2E8, 0x9223},
-	{MISENSOR_16BIT,	0xD2EA, 0xB024},
-	{MISENSOR_16BIT,	0xD2EC, 0x9227},
-	{MISENSOR_16BIT,	0xD2EE, 0xB025},
-	{MISENSOR_16BIT,	0xD2F0, 0x9228},
-	{MISENSOR_16BIT,	0xD2F2, 0xB026},
-	{MISENSOR_16BIT,	0xD2F4, 0x922B},
-	{MISENSOR_16BIT,	0xD2F6, 0xB027},
-	{MISENSOR_16BIT,	0xD2F8, 0x922C},
-	{MISENSOR_16BIT,	0xD2FA, 0xB028},
-	{MISENSOR_16BIT,	0xD2FC, 0x1258},
-	{MISENSOR_16BIT,	0xD2FE, 0x0101},
-	{MISENSOR_16BIT,	0xD300, 0xB029},
-	{MISENSOR_16BIT,	0xD302, 0x125A},
-	{MISENSOR_16BIT,	0xD304, 0x0101},
-	{MISENSOR_16BIT,	0xD306, 0xB02A},
-	{MISENSOR_16BIT,	0xD308, 0x1336},
-	{MISENSOR_16BIT,	0xD30A, 0x8081},
-	{MISENSOR_16BIT,	0xD30C, 0xA836},
-	{MISENSOR_16BIT,	0xD30E, 0x1337},
-	{MISENSOR_16BIT,	0xD310, 0x8081},
-	{MISENSOR_16BIT,	0xD312, 0xA837},
-	{MISENSOR_16BIT,	0xD314, 0x12A7},
-	{MISENSOR_16BIT,	0xD316, 0x0701},
-	{MISENSOR_16BIT,	0xD318, 0xB02C},
-	{MISENSOR_16BIT,	0xD31A, 0x1354},
-	{MISENSOR_16BIT,	0xD31C, 0x8081},
-	{MISENSOR_16BIT,	0xD31E, 0x7FE0},
-	{MISENSOR_16BIT,	0xD320, 0xA83A},
-	{MISENSOR_16BIT,	0xD322, 0x78E0},
-	{MISENSOR_16BIT,	0xD324, 0xC0F1},
-	{MISENSOR_16BIT,	0xD326, 0x0DC2},
-	{MISENSOR_16BIT,	0xD328, 0x05C0},
-	{MISENSOR_16BIT,	0xD32A, 0x7608},
-	{MISENSOR_16BIT,	0xD32C, 0x09BB},
-	{MISENSOR_16BIT,	0xD32E, 0x0010},
-	{MISENSOR_16BIT,	0xD330, 0x75CF},
-	{MISENSOR_16BIT,	0xD332, 0xFFFF},
-	{MISENSOR_16BIT,	0xD334, 0xD4E0},
-	{MISENSOR_16BIT,	0xD336, 0x8D21},
-	{MISENSOR_16BIT,	0xD338, 0x8D00},
-	{MISENSOR_16BIT,	0xD33A, 0x2153},
-	{MISENSOR_16BIT,	0xD33C, 0x0003},
-	{MISENSOR_16BIT,	0xD33E, 0xB8C0},
-	{MISENSOR_16BIT,	0xD340, 0x8D45},
-	{MISENSOR_16BIT,	0xD342, 0x0B23},
-	{MISENSOR_16BIT,	0xD344, 0x0000},
-	{MISENSOR_16BIT,	0xD346, 0xEA8F},
-	{MISENSOR_16BIT,	0xD348, 0x0915},
-	{MISENSOR_16BIT,	0xD34A, 0x001E},
-	{MISENSOR_16BIT,	0xD34C, 0xFF81},
-	{MISENSOR_16BIT,	0xD34E, 0xE808},
-	{MISENSOR_16BIT,	0xD350, 0x2540},
-	{MISENSOR_16BIT,	0xD352, 0x1900},
-	{MISENSOR_16BIT,	0xD354, 0xFFDE},
-	{MISENSOR_16BIT,	0xD356, 0x8D00},
-	{MISENSOR_16BIT,	0xD358, 0xB880},
-	{MISENSOR_16BIT,	0xD35A, 0xF004},
-	{MISENSOR_16BIT,	0xD35C, 0x8D00},
-	{MISENSOR_16BIT,	0xD35E, 0xB8A0},
-	{MISENSOR_16BIT,	0xD360, 0xAD00},
-	{MISENSOR_16BIT,	0xD362, 0x8D05},
-	{MISENSOR_16BIT,	0xD364, 0xE081},
-	{MISENSOR_16BIT,	0xD366, 0x20CC},
-	{MISENSOR_16BIT,	0xD368, 0x80A2},
-	{MISENSOR_16BIT,	0xD36A, 0xDF00},
-	{MISENSOR_16BIT,	0xD36C, 0xF40A},
-	{MISENSOR_16BIT,	0xD36E, 0x71CF},
-	{MISENSOR_16BIT,	0xD370, 0xFFFF},
-	{MISENSOR_16BIT,	0xD372, 0xC84C},
-	{MISENSOR_16BIT,	0xD374, 0x9102},
-	{MISENSOR_16BIT,	0xD376, 0x7708},
-	{MISENSOR_16BIT,	0xD378, 0xB8A6},
-	{MISENSOR_16BIT,	0xD37A, 0x2786},
-	{MISENSOR_16BIT,	0xD37C, 0x1FFE},
-	{MISENSOR_16BIT,	0xD37E, 0xB102},
-	{MISENSOR_16BIT,	0xD380, 0x0B42},
-	{MISENSOR_16BIT,	0xD382, 0x0180},
-	{MISENSOR_16BIT,	0xD384, 0x0E3E},
-	{MISENSOR_16BIT,	0xD386, 0x0180},
-	{MISENSOR_16BIT,	0xD388, 0x0F4A},
-	{MISENSOR_16BIT,	0xD38A, 0x0160},
-	{MISENSOR_16BIT,	0xD38C, 0x70C9},
-	{MISENSOR_16BIT,	0xD38E, 0x8D05},
-	{MISENSOR_16BIT,	0xD390, 0xE081},
-	{MISENSOR_16BIT,	0xD392, 0x20CC},
-	{MISENSOR_16BIT,	0xD394, 0x80A2},
-	{MISENSOR_16BIT,	0xD396, 0xF429},
-	{MISENSOR_16BIT,	0xD398, 0x76CF},
-	{MISENSOR_16BIT,	0xD39A, 0xFFFF},
-	{MISENSOR_16BIT,	0xD39C, 0xC84C},
-	{MISENSOR_16BIT,	0xD39E, 0x082D},
-	{MISENSOR_16BIT,	0xD3A0, 0x0051},
-	{MISENSOR_16BIT,	0xD3A2, 0x70CF},
-	{MISENSOR_16BIT,	0xD3A4, 0xFFFF},
-	{MISENSOR_16BIT,	0xD3A6, 0xC90C},
-	{MISENSOR_16BIT,	0xD3A8, 0x8805},
-	{MISENSOR_16BIT,	0xD3AA, 0x09B6},
-	{MISENSOR_16BIT,	0xD3AC, 0x0360},
-	{MISENSOR_16BIT,	0xD3AE, 0xD908},
-	{MISENSOR_16BIT,	0xD3B0, 0x2099},
-	{MISENSOR_16BIT,	0xD3B2, 0x0802},
-	{MISENSOR_16BIT,	0xD3B4, 0x9634},
-	{MISENSOR_16BIT,	0xD3B6, 0xB503},
-	{MISENSOR_16BIT,	0xD3B8, 0x7902},
-	{MISENSOR_16BIT,	0xD3BA, 0x1523},
-	{MISENSOR_16BIT,	0xD3BC, 0x1080},
-	{MISENSOR_16BIT,	0xD3BE, 0xB634},
-	{MISENSOR_16BIT,	0xD3C0, 0xE001},
-	{MISENSOR_16BIT,	0xD3C2, 0x1D23},
-	{MISENSOR_16BIT,	0xD3C4, 0x1002},
-	{MISENSOR_16BIT,	0xD3C6, 0xF00B},
-	{MISENSOR_16BIT,	0xD3C8, 0x9634},
-	{MISENSOR_16BIT,	0xD3CA, 0x9503},
-	{MISENSOR_16BIT,	0xD3CC, 0x6038},
-	{MISENSOR_16BIT,	0xD3CE, 0xB614},
-	{MISENSOR_16BIT,	0xD3D0, 0x153F},
-	{MISENSOR_16BIT,	0xD3D2, 0x1080},
-	{MISENSOR_16BIT,	0xD3D4, 0xE001},
-	{MISENSOR_16BIT,	0xD3D6, 0x1D3F},
-	{MISENSOR_16BIT,	0xD3D8, 0x1002},
-	{MISENSOR_16BIT,	0xD3DA, 0xFFA4},
-	{MISENSOR_16BIT,	0xD3DC, 0x9602},
-	{MISENSOR_16BIT,	0xD3DE, 0x7F05},
-	{MISENSOR_16BIT,	0xD3E0, 0xD800},
-	{MISENSOR_16BIT,	0xD3E2, 0xB6E2},
-	{MISENSOR_16BIT,	0xD3E4, 0xAD05},
-	{MISENSOR_16BIT,	0xD3E6, 0x0511},
-	{MISENSOR_16BIT,	0xD3E8, 0x05E0},
-	{MISENSOR_16BIT,	0xD3EA, 0xD800},
-	{MISENSOR_16BIT,	0xD3EC, 0xC0F1},
-	{MISENSOR_16BIT,	0xD3EE, 0x0CFE},
-	{MISENSOR_16BIT,	0xD3F0, 0x05C0},
-	{MISENSOR_16BIT,	0xD3F2, 0x0A96},
-	{MISENSOR_16BIT,	0xD3F4, 0x05A0},
-	{MISENSOR_16BIT,	0xD3F6, 0x7608},
-	{MISENSOR_16BIT,	0xD3F8, 0x0C22},
-	{MISENSOR_16BIT,	0xD3FA, 0x0240},
-	{MISENSOR_16BIT,	0xD3FC, 0xE080},
-	{MISENSOR_16BIT,	0xD3FE, 0x20CA},
-	{MISENSOR_16BIT,	0xD400, 0x0F82},
-	{MISENSOR_16BIT,	0xD402, 0x0000},
-	{MISENSOR_16BIT,	0xD404, 0x190B},
-	{MISENSOR_16BIT,	0xD406, 0x0C60},
-	{MISENSOR_16BIT,	0xD408, 0x05A2},
-	{MISENSOR_16BIT,	0xD40A, 0x21CA},
-	{MISENSOR_16BIT,	0xD40C, 0x0022},
-	{MISENSOR_16BIT,	0xD40E, 0x0C56},
-	{MISENSOR_16BIT,	0xD410, 0x0240},
-	{MISENSOR_16BIT,	0xD412, 0xE806},
-	{MISENSOR_16BIT,	0xD414, 0x0E0E},
-	{MISENSOR_16BIT,	0xD416, 0x0220},
-	{MISENSOR_16BIT,	0xD418, 0x70C9},
-	{MISENSOR_16BIT,	0xD41A, 0xF048},
-	{MISENSOR_16BIT,	0xD41C, 0x0896},
-	{MISENSOR_16BIT,	0xD41E, 0x0440},
-	{MISENSOR_16BIT,	0xD420, 0x0E96},
-	{MISENSOR_16BIT,	0xD422, 0x0400},
-	{MISENSOR_16BIT,	0xD424, 0x0966},
-	{MISENSOR_16BIT,	0xD426, 0x0380},
-	{MISENSOR_16BIT,	0xD428, 0x75CF},
-	{MISENSOR_16BIT,	0xD42A, 0xFFFF},
-	{MISENSOR_16BIT,	0xD42C, 0xD4E0},
-	{MISENSOR_16BIT,	0xD42E, 0x8D00},
-	{MISENSOR_16BIT,	0xD430, 0x084D},
-	{MISENSOR_16BIT,	0xD432, 0x001E},
-	{MISENSOR_16BIT,	0xD434, 0xFF47},
-	{MISENSOR_16BIT,	0xD436, 0x080D},
-	{MISENSOR_16BIT,	0xD438, 0x0050},
-	{MISENSOR_16BIT,	0xD43A, 0xFF57},
-	{MISENSOR_16BIT,	0xD43C, 0x0841},
-	{MISENSOR_16BIT,	0xD43E, 0x0051},
-	{MISENSOR_16BIT,	0xD440, 0x8D04},
-	{MISENSOR_16BIT,	0xD442, 0x9521},
-	{MISENSOR_16BIT,	0xD444, 0xE064},
-	{MISENSOR_16BIT,	0xD446, 0x790C},
-	{MISENSOR_16BIT,	0xD448, 0x702F},
-	{MISENSOR_16BIT,	0xD44A, 0x0CE2},
-	{MISENSOR_16BIT,	0xD44C, 0x05E0},
-	{MISENSOR_16BIT,	0xD44E, 0xD964},
-	{MISENSOR_16BIT,	0xD450, 0x72CF},
-	{MISENSOR_16BIT,	0xD452, 0xFFFF},
-	{MISENSOR_16BIT,	0xD454, 0xC700},
-	{MISENSOR_16BIT,	0xD456, 0x9235},
-	{MISENSOR_16BIT,	0xD458, 0x0811},
-	{MISENSOR_16BIT,	0xD45A, 0x0043},
-	{MISENSOR_16BIT,	0xD45C, 0xFF3D},
-	{MISENSOR_16BIT,	0xD45E, 0x080D},
-	{MISENSOR_16BIT,	0xD460, 0x0051},
-	{MISENSOR_16BIT,	0xD462, 0xD801},
-	{MISENSOR_16BIT,	0xD464, 0xFF77},
-	{MISENSOR_16BIT,	0xD466, 0xF025},
-	{MISENSOR_16BIT,	0xD468, 0x9501},
-	{MISENSOR_16BIT,	0xD46A, 0x9235},
-	{MISENSOR_16BIT,	0xD46C, 0x0911},
-	{MISENSOR_16BIT,	0xD46E, 0x0003},
-	{MISENSOR_16BIT,	0xD470, 0xFF49},
-	{MISENSOR_16BIT,	0xD472, 0x080D},
-	{MISENSOR_16BIT,	0xD474, 0x0051},
-	{MISENSOR_16BIT,	0xD476, 0xD800},
-	{MISENSOR_16BIT,	0xD478, 0xFF72},
-	{MISENSOR_16BIT,	0xD47A, 0xF01B},
-	{MISENSOR_16BIT,	0xD47C, 0x0886},
-	{MISENSOR_16BIT,	0xD47E, 0x03E0},
-	{MISENSOR_16BIT,	0xD480, 0xD801},
-	{MISENSOR_16BIT,	0xD482, 0x0EF6},
-	{MISENSOR_16BIT,	0xD484, 0x03C0},
-	{MISENSOR_16BIT,	0xD486, 0x0F52},
-	{MISENSOR_16BIT,	0xD488, 0x0340},
-	{MISENSOR_16BIT,	0xD48A, 0x0DBA},
-	{MISENSOR_16BIT,	0xD48C, 0x0200},
-	{MISENSOR_16BIT,	0xD48E, 0x0AF6},
-	{MISENSOR_16BIT,	0xD490, 0x0440},
-	{MISENSOR_16BIT,	0xD492, 0x0C22},
-	{MISENSOR_16BIT,	0xD494, 0x0400},
-	{MISENSOR_16BIT,	0xD496, 0x0D72},
-	{MISENSOR_16BIT,	0xD498, 0x0440},
-	{MISENSOR_16BIT,	0xD49A, 0x0DC2},
-	{MISENSOR_16BIT,	0xD49C, 0x0200},
-	{MISENSOR_16BIT,	0xD49E, 0x0972},
-	{MISENSOR_16BIT,	0xD4A0, 0x0440},
-	{MISENSOR_16BIT,	0xD4A2, 0x0D3A},
-	{MISENSOR_16BIT,	0xD4A4, 0x0220},
-	{MISENSOR_16BIT,	0xD4A6, 0xD820},
-	{MISENSOR_16BIT,	0xD4A8, 0x0BFA},
-	{MISENSOR_16BIT,	0xD4AA, 0x0260},
-	{MISENSOR_16BIT,	0xD4AC, 0x70C9},
-	{MISENSOR_16BIT,	0xD4AE, 0x0451},
-	{MISENSOR_16BIT,	0xD4B0, 0x05C0},
-	{MISENSOR_16BIT,	0xD4B2, 0x78E0},
-	{MISENSOR_16BIT,	0xD4B4, 0xD900},
-	{MISENSOR_16BIT,	0xD4B6, 0xF00A},
-	{MISENSOR_16BIT,	0xD4B8, 0x70CF},
-	{MISENSOR_16BIT,	0xD4BA, 0xFFFF},
-	{MISENSOR_16BIT,	0xD4BC, 0xD520},
-	{MISENSOR_16BIT,	0xD4BE, 0x7835},
-	{MISENSOR_16BIT,	0xD4C0, 0x8041},
-	{MISENSOR_16BIT,	0xD4C2, 0x8000},
-	{MISENSOR_16BIT,	0xD4C4, 0xE102},
-	{MISENSOR_16BIT,	0xD4C6, 0xA040},
-	{MISENSOR_16BIT,	0xD4C8, 0x09F1},
-	{MISENSOR_16BIT,	0xD4CA, 0x8114},
-	{MISENSOR_16BIT,	0xD4CC, 0x71CF},
-	{MISENSOR_16BIT,	0xD4CE, 0xFFFF},
-	{MISENSOR_16BIT,	0xD4D0, 0xD4E0},
-	{MISENSOR_16BIT,	0xD4D2, 0x70CF},
-	{MISENSOR_16BIT,	0xD4D4, 0xFFFF},
-	{MISENSOR_16BIT,	0xD4D6, 0xC594},
-	{MISENSOR_16BIT,	0xD4D8, 0xB03A},
-	{MISENSOR_16BIT,	0xD4DA, 0x7FE0},
-	{MISENSOR_16BIT,	0xD4DC, 0xD800},
-	{MISENSOR_16BIT,	0xD4DE, 0x0000},
-	{MISENSOR_16BIT,	0xD4E0, 0x0000},
-	{MISENSOR_16BIT,	0xD4E2, 0x0500},
-	{MISENSOR_16BIT,	0xD4E4, 0x0500},
-	{MISENSOR_16BIT,	0xD4E6, 0x0200},
-	{MISENSOR_16BIT,	0xD4E8, 0x0330},
-	{MISENSOR_16BIT,	0xD4EA, 0x0000},
-	{MISENSOR_16BIT,	0xD4EC, 0x0000},
-	{MISENSOR_16BIT,	0xD4EE, 0x03CD},
-	{MISENSOR_16BIT,	0xD4F0, 0x050D},
-	{MISENSOR_16BIT,	0xD4F2, 0x01C5},
-	{MISENSOR_16BIT,	0xD4F4, 0x03B3},
-	{MISENSOR_16BIT,	0xD4F6, 0x00E0},
-	{MISENSOR_16BIT,	0xD4F8, 0x01E3},
-	{MISENSOR_16BIT,	0xD4FA, 0x0280},
-	{MISENSOR_16BIT,	0xD4FC, 0x01E0},
-	{MISENSOR_16BIT,	0xD4FE, 0x0109},
-	{MISENSOR_16BIT,	0xD500, 0x0080},
-	{MISENSOR_16BIT,	0xD502, 0x0500},
-	{MISENSOR_16BIT,	0xD504, 0x0000},
-	{MISENSOR_16BIT,	0xD506, 0x0000},
-	{MISENSOR_16BIT,	0xD508, 0x0000},
-	{MISENSOR_16BIT,	0xD50A, 0x0000},
-	{MISENSOR_16BIT,	0xD50C, 0x0000},
-	{MISENSOR_16BIT,	0xD50E, 0x0000},
-	{MISENSOR_16BIT,	0xD510, 0x0000},
-	{MISENSOR_16BIT,	0xD512, 0x0000},
-	{MISENSOR_16BIT,	0xD514, 0x0000},
-	{MISENSOR_16BIT,	0xD516, 0x0000},
-	{MISENSOR_16BIT,	0xD518, 0x0000},
-	{MISENSOR_16BIT,	0xD51A, 0x0000},
-	{MISENSOR_16BIT,	0xD51C, 0x0000},
-	{MISENSOR_16BIT,	0xD51E, 0x0000},
-	{MISENSOR_16BIT,	0xD520, 0xFFFF},
-	{MISENSOR_16BIT,	0xD522, 0xC9B4},
-	{MISENSOR_16BIT,	0xD524, 0xFFFF},
-	{MISENSOR_16BIT,	0xD526, 0xD324},
-	{MISENSOR_16BIT,	0xD528, 0xFFFF},
-	{MISENSOR_16BIT,	0xD52A, 0xCA34},
-	{MISENSOR_16BIT,	0xD52C, 0xFFFF},
-	{MISENSOR_16BIT,	0xD52E, 0xD3EC},
-	{MISENSOR_16BIT,	0x098E, 0x0000},
-	{MISENSOR_16BIT,	0xE000, 0x04B4},
-	{MISENSOR_16BIT,	0xE002, 0x0302},
-	{MISENSOR_16BIT,	0xE004, 0x4103},
-	{MISENSOR_16BIT,	0xE006, 0x0202},
-	{MISENSOR_16BIT,	0x0080, 0xFFF0},
-	{MISENSOR_16BIT,	0x0080, 0xFFF1},
-
-	/* PGA parameter and APGA
-	 * [Step4-APGA] [TP101_MT9M114_APGA]
-	 */
-	{MISENSOR_16BIT,	0x098E, 0x495E},
-	{MISENSOR_16BIT,	0xC95E, 0x0000},
-	{MISENSOR_16BIT,	0x3640, 0x02B0},
-	{MISENSOR_16BIT,	0x3642, 0x8063},
-	{MISENSOR_16BIT,	0x3644, 0x78D0},
-	{MISENSOR_16BIT,	0x3646, 0x50CC},
-	{MISENSOR_16BIT,	0x3648, 0x3511},
-	{MISENSOR_16BIT,	0x364A, 0x0110},
-	{MISENSOR_16BIT,	0x364C, 0xBD8A},
-	{MISENSOR_16BIT,	0x364E, 0x0CD1},
-	{MISENSOR_16BIT,	0x3650, 0x24ED},
-	{MISENSOR_16BIT,	0x3652, 0x7C11},
-	{MISENSOR_16BIT,	0x3654, 0x0150},
-	{MISENSOR_16BIT,	0x3656, 0x124C},
-	{MISENSOR_16BIT,	0x3658, 0x3130},
-	{MISENSOR_16BIT,	0x365A, 0x508C},
-	{MISENSOR_16BIT,	0x365C, 0x21F1},
-	{MISENSOR_16BIT,	0x365E, 0x0090},
-	{MISENSOR_16BIT,	0x3660, 0xBFCA},
-	{MISENSOR_16BIT,	0x3662, 0x0A11},
-	{MISENSOR_16BIT,	0x3664, 0x4F4B},
-	{MISENSOR_16BIT,	0x3666, 0x28B1},
-	{MISENSOR_16BIT,	0x3680, 0x50A9},
-	{MISENSOR_16BIT,	0x3682, 0xA04B},
-	{MISENSOR_16BIT,	0x3684, 0x0E2D},
-	{MISENSOR_16BIT,	0x3686, 0x73EC},
-	{MISENSOR_16BIT,	0x3688, 0x164F},
-	{MISENSOR_16BIT,	0x368A, 0xF829},
-	{MISENSOR_16BIT,	0x368C, 0xC1A8},
-	{MISENSOR_16BIT,	0x368E, 0xB0EC},
-	{MISENSOR_16BIT,	0x3690, 0xE76A},
-	{MISENSOR_16BIT,	0x3692, 0x69AF},
-	{MISENSOR_16BIT,	0x3694, 0x378C},
-	{MISENSOR_16BIT,	0x3696, 0xA70D},
-	{MISENSOR_16BIT,	0x3698, 0x884F},
-	{MISENSOR_16BIT,	0x369A, 0xEE8B},
-	{MISENSOR_16BIT,	0x369C, 0x5DEF},
-	{MISENSOR_16BIT,	0x369E, 0x27CC},
-	{MISENSOR_16BIT,	0x36A0, 0xCAAC},
-	{MISENSOR_16BIT,	0x36A2, 0x840E},
-	{MISENSOR_16BIT,	0x36A4, 0xDAA9},
-	{MISENSOR_16BIT,	0x36A6, 0xF00C},
-	{MISENSOR_16BIT,	0x36C0, 0x1371},
-	{MISENSOR_16BIT,	0x36C2, 0x272F},
-	{MISENSOR_16BIT,	0x36C4, 0x2293},
-	{MISENSOR_16BIT,	0x36C6, 0xE6D0},
-	{MISENSOR_16BIT,	0x36C8, 0xEC32},
-	{MISENSOR_16BIT,	0x36CA, 0x11B1},
-	{MISENSOR_16BIT,	0x36CC, 0x7BAF},
-	{MISENSOR_16BIT,	0x36CE, 0x5813},
-	{MISENSOR_16BIT,	0x36D0, 0xB871},
-	{MISENSOR_16BIT,	0x36D2, 0x8913},
-	{MISENSOR_16BIT,	0x36D4, 0x4610},
-	{MISENSOR_16BIT,	0x36D6, 0x7EEE},
-	{MISENSOR_16BIT,	0x36D8, 0x0DF3},
-	{MISENSOR_16BIT,	0x36DA, 0xB84F},
-	{MISENSOR_16BIT,	0x36DC, 0xB532},
-	{MISENSOR_16BIT,	0x36DE, 0x1171},
-	{MISENSOR_16BIT,	0x36E0, 0x13CF},
-	{MISENSOR_16BIT,	0x36E2, 0x22F3},
-	{MISENSOR_16BIT,	0x36E4, 0xE090},
-	{MISENSOR_16BIT,	0x36E6, 0x8133},
-	{MISENSOR_16BIT,	0x3700, 0x88AE},
-	{MISENSOR_16BIT,	0x3702, 0x00EA},
-	{MISENSOR_16BIT,	0x3704, 0x344F},
-	{MISENSOR_16BIT,	0x3706, 0xEC88},
-	{MISENSOR_16BIT,	0x3708, 0x3E91},
-	{MISENSOR_16BIT,	0x370A, 0xF12D},
-	{MISENSOR_16BIT,	0x370C, 0xB0EF},
-	{MISENSOR_16BIT,	0x370E, 0x77CD},
-	{MISENSOR_16BIT,	0x3710, 0x7930},
-	{MISENSOR_16BIT,	0x3712, 0x5C12},
-	{MISENSOR_16BIT,	0x3714, 0x500C},
-	{MISENSOR_16BIT,	0x3716, 0x22CE},
-	{MISENSOR_16BIT,	0x3718, 0x2370},
-	{MISENSOR_16BIT,	0x371A, 0x258F},
-	{MISENSOR_16BIT,	0x371C, 0x3D30},
-	{MISENSOR_16BIT,	0x371E, 0x370C},
-	{MISENSOR_16BIT,	0x3720, 0x03ED},
-	{MISENSOR_16BIT,	0x3722, 0x9AD0},
-	{MISENSOR_16BIT,	0x3724, 0x7ECF},
-	{MISENSOR_16BIT,	0x3726, 0x1093},
-	{MISENSOR_16BIT,	0x3740, 0x2391},
-	{MISENSOR_16BIT,	0x3742, 0xAAD0},
-	{MISENSOR_16BIT,	0x3744, 0x28F2},
-	{MISENSOR_16BIT,	0x3746, 0xBA4F},
-	{MISENSOR_16BIT,	0x3748, 0xC536},
-	{MISENSOR_16BIT,	0x374A, 0x1472},
-	{MISENSOR_16BIT,	0x374C, 0xD110},
-	{MISENSOR_16BIT,	0x374E, 0x2933},
-	{MISENSOR_16BIT,	0x3750, 0xD0D1},
-	{MISENSOR_16BIT,	0x3752, 0x9F37},
-	{MISENSOR_16BIT,	0x3754, 0x34D1},
-	{MISENSOR_16BIT,	0x3756, 0x1C6C},
-	{MISENSOR_16BIT,	0x3758, 0x3FD2},
-	{MISENSOR_16BIT,	0x375A, 0xCB72},
-	{MISENSOR_16BIT,	0x375C, 0xBA96},
-	{MISENSOR_16BIT,	0x375E, 0x1551},
-	{MISENSOR_16BIT,	0x3760, 0xB74F},
-	{MISENSOR_16BIT,	0x3762, 0x1672},
-	{MISENSOR_16BIT,	0x3764, 0x84F1},
-	{MISENSOR_16BIT,	0x3766, 0xC2D6},
-	{MISENSOR_16BIT,	0x3782, 0x01E0},
-	{MISENSOR_16BIT,	0x3784, 0x0280},
-	{MISENSOR_16BIT,	0x37C0, 0xA6EA},
-	{MISENSOR_16BIT,	0x37C2, 0x874B},
-	{MISENSOR_16BIT,	0x37C4, 0x85CB},
-	{MISENSOR_16BIT,	0x37C6, 0x968A},
-	{MISENSOR_16BIT,	0x098E, 0x0000},
-	{MISENSOR_16BIT,	0xC960, 0x0AF0},
-	{MISENSOR_16BIT,	0xC962, 0x79E2},
-	{MISENSOR_16BIT,	0xC964, 0x5EC8},
-	{MISENSOR_16BIT,	0xC966, 0x791F},
-	{MISENSOR_16BIT,	0xC968, 0x76EE},
-	{MISENSOR_16BIT,	0xC96A, 0x0FA0},
-	{MISENSOR_16BIT,	0xC96C, 0x7DFA},
-	{MISENSOR_16BIT,	0xC96E, 0x7DAF},
-	{MISENSOR_16BIT,	0xC970, 0x7E02},
-	{MISENSOR_16BIT,	0xC972, 0x7E0A},
-	{MISENSOR_16BIT,	0xC974, 0x1964},
-	{MISENSOR_16BIT,	0xC976, 0x7CDC},
-	{MISENSOR_16BIT,	0xC978, 0x7838},
-	{MISENSOR_16BIT,	0xC97A, 0x7C2F},
-	{MISENSOR_16BIT,	0xC97C, 0x7792},
-	{MISENSOR_16BIT,	0xC95E, 0x0003},
-
-	/* [Step4-APGA] */
-	{MISENSOR_16BIT,	0x098E, 0x0000},
-	{MISENSOR_16BIT,	0xC95E, 0x0003},
-
-	/* [Step5-AWB_CCM]1: LOAD=CCM */
-	{MISENSOR_16BIT,	0xC892, 0x0267},
-	{MISENSOR_16BIT,	0xC894, 0xFF1A},
-	{MISENSOR_16BIT,	0xC896, 0xFFB3},
-	{MISENSOR_16BIT,	0xC898, 0xFF80},
-	{MISENSOR_16BIT,	0xC89A, 0x0166},
-	{MISENSOR_16BIT,	0xC89C, 0x0003},
-	{MISENSOR_16BIT,	0xC89E, 0xFF9A},
-	{MISENSOR_16BIT,	0xC8A0, 0xFEB4},
-	{MISENSOR_16BIT,	0xC8A2, 0x024D},
-	{MISENSOR_16BIT,	0xC8A4, 0x01BF},
-	{MISENSOR_16BIT,	0xC8A6, 0xFF01},
-	{MISENSOR_16BIT,	0xC8A8, 0xFFF3},
-	{MISENSOR_16BIT,	0xC8AA, 0xFF75},
-	{MISENSOR_16BIT,	0xC8AC, 0x0198},
-	{MISENSOR_16BIT,	0xC8AE, 0xFFFD},
-	{MISENSOR_16BIT,	0xC8B0, 0xFF9A},
-	{MISENSOR_16BIT,	0xC8B2, 0xFEE7},
-	{MISENSOR_16BIT,	0xC8B4, 0x02A8},
-	{MISENSOR_16BIT,	0xC8B6, 0x01D9},
-	{MISENSOR_16BIT,	0xC8B8, 0xFF26},
-	{MISENSOR_16BIT,	0xC8BA, 0xFFF3},
-	{MISENSOR_16BIT,	0xC8BC, 0xFFB3},
-	{MISENSOR_16BIT,	0xC8BE, 0x0132},
-	{MISENSOR_16BIT,	0xC8C0, 0xFFE8},
-	{MISENSOR_16BIT,	0xC8C2, 0xFFDA},
-	{MISENSOR_16BIT,	0xC8C4, 0xFECD},
-	{MISENSOR_16BIT,	0xC8C6, 0x02C2},
-	{MISENSOR_16BIT,	0xC8C8, 0x0075},
-	{MISENSOR_16BIT,	0xC8CA, 0x011C},
-	{MISENSOR_16BIT,	0xC8CC, 0x009A},
-	{MISENSOR_16BIT,	0xC8CE, 0x0105},
-	{MISENSOR_16BIT,	0xC8D0, 0x00A4},
-	{MISENSOR_16BIT,	0xC8D2, 0x00AC},
-	{MISENSOR_16BIT,	0xC8D4, 0x0A8C},
-	{MISENSOR_16BIT,	0xC8D6, 0x0F0A},
-	{MISENSOR_16BIT,	0xC8D8, 0x1964},
-
-	/* LOAD=AWB */
-	{MISENSOR_16BIT,	0xC914, 0x0000},
-	{MISENSOR_16BIT,	0xC916, 0x0000},
-	{MISENSOR_16BIT,	0xC918, 0x04FF},
-	{MISENSOR_16BIT,	0xC91A, 0x02CF},
-	{MISENSOR_16BIT,	0xC904, 0x0033},
-	{MISENSOR_16BIT,	0xC906, 0x0040},
-	{MISENSOR_8BIT,   0xC8F2, 0x03},
-	{MISENSOR_8BIT,   0xC8F3, 0x02},
-	{MISENSOR_16BIT,	0xC906, 0x003C},
-	{MISENSOR_16BIT,	0xC8F4, 0x0000},
-	{MISENSOR_16BIT,	0xC8F6, 0x0000},
-	{MISENSOR_16BIT,	0xC8F8, 0x0000},
-	{MISENSOR_16BIT,	0xC8FA, 0xE724},
-	{MISENSOR_16BIT,	0xC8FC, 0x1583},
-	{MISENSOR_16BIT,	0xC8FE, 0x2045},
-	{MISENSOR_16BIT,	0xC900, 0x05DC},
-	{MISENSOR_16BIT,	0xC902, 0x007C},
-	{MISENSOR_8BIT,   0xC90C, 0x80},
-	{MISENSOR_8BIT,   0xC90D, 0x80},
-	{MISENSOR_8BIT,   0xC90E, 0x80},
-	{MISENSOR_8BIT,   0xC90F, 0x88},
-	{MISENSOR_8BIT,   0xC910, 0x80},
-	{MISENSOR_8BIT,   0xC911, 0x80},
-
-	/* LOAD=Step7-CPIPE_Preference */
-	{MISENSOR_16BIT,	0xC926, 0x0020},
-	{MISENSOR_16BIT,	0xC928, 0x009A},
-	{MISENSOR_16BIT,	0xC946, 0x0070},
-	{MISENSOR_16BIT,	0xC948, 0x00F3},
-	{MISENSOR_16BIT,	0xC952, 0x0020},
-	{MISENSOR_16BIT,	0xC954, 0x009A},
-	{MISENSOR_8BIT,   0xC92A, 0x80},
-	{MISENSOR_8BIT,   0xC92B, 0x4B},
-	{MISENSOR_8BIT,   0xC92C, 0x00},
-	{MISENSOR_8BIT,   0xC92D, 0xFF},
-	{MISENSOR_8BIT,   0xC92E, 0x3C},
-	{MISENSOR_8BIT,   0xC92F, 0x02},
-	{MISENSOR_8BIT,   0xC930, 0x06},
-	{MISENSOR_8BIT,   0xC931, 0x64},
-	{MISENSOR_8BIT,   0xC932, 0x01},
-	{MISENSOR_8BIT,   0xC933, 0x0C},
-	{MISENSOR_8BIT,   0xC934, 0x3C},
-	{MISENSOR_8BIT,   0xC935, 0x3C},
-	{MISENSOR_8BIT,   0xC936, 0x3C},
-	{MISENSOR_8BIT,   0xC937, 0x0F},
-	{MISENSOR_8BIT,   0xC938, 0x64},
-	{MISENSOR_8BIT,   0xC939, 0x64},
-	{MISENSOR_8BIT,   0xC93A, 0x64},
-	{MISENSOR_8BIT,   0xC93B, 0x32},
-	{MISENSOR_16BIT,	0xC93C, 0x0020},
-	{MISENSOR_16BIT,	0xC93E, 0x009A},
-	{MISENSOR_16BIT,	0xC940, 0x00DC},
-	{MISENSOR_8BIT,   0xC942, 0x38},
-	{MISENSOR_8BIT,   0xC943, 0x30},
-	{MISENSOR_8BIT,   0xC944, 0x50},
-	{MISENSOR_8BIT,   0xC945, 0x19},
-	{MISENSOR_16BIT,	0xC94A, 0x0230},
-	{MISENSOR_16BIT,	0xC94C, 0x0010},
-	{MISENSOR_16BIT,	0xC94E, 0x01CD},
-	{MISENSOR_8BIT,   0xC950, 0x05},
-	{MISENSOR_8BIT,   0xC951, 0x40},
-	{MISENSOR_8BIT,   0xC87B, 0x1B},
-	{MISENSOR_8BIT,   0xC878, 0x0E},
-	{MISENSOR_16BIT,	0xC890, 0x0080},
-	{MISENSOR_16BIT,	0xC886, 0x0100},
-	{MISENSOR_16BIT,	0xC87C, 0x005A},
-	{MISENSOR_8BIT,   0xB42A, 0x05},
-	{MISENSOR_8BIT,   0xA80A, 0x20},
-
-	/* Speed up AE/AWB */
-	{MISENSOR_16BIT,	0x098E, 0x2802},
-	{MISENSOR_16BIT,	0xA802, 0x0008},
-	{MISENSOR_8BIT,   0xC908, 0x01},
-	{MISENSOR_8BIT,   0xC879, 0x01},
-	{MISENSOR_8BIT,   0xC909, 0x02},
-	{MISENSOR_8BIT,   0xA80A, 0x18},
-	{MISENSOR_8BIT,   0xA80B, 0x18},
-	{MISENSOR_8BIT,   0xAC16, 0x18},
-	{MISENSOR_8BIT,   0xC878, 0x0E},
-
-	{MISENSOR_TOK_TERM, 0, 0}
-};
-
-#endif
-#endif

+ 0 - 858
drivers/staging/media/atomisp/i2c/ov2680.h

@@ -1,858 +0,0 @@
-/*
- * Support for OmniVision OV2680 5M camera sensor.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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 __OV2680_H__
-#define __OV2680_H__
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/delay.h>
-#include <linux/videodev2.h>
-#include <linux/spinlock.h>
-#include <media/v4l2-subdev.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-ctrls.h>
-#include <linux/v4l2-mediabus.h>
-#include <media/media-entity.h>
-
-#include "../include/linux/atomisp_platform.h"
-
-/* Defines for register writes and register array processing */
-#define I2C_MSG_LENGTH		0x2
-#define I2C_RETRY_COUNT		5
-
-#define OV2680_FOCAL_LENGTH_NUM	334	/*3.34mm*/
-#define OV2680_FOCAL_LENGTH_DEM	100
-#define OV2680_F_NUMBER_DEFAULT_NUM	24
-#define OV2680_F_NUMBER_DEM	10
-
-#define OV2680_BIN_FACTOR_MAX 4
-
-#define MAX_FMTS		1
-
-/* sensor_mode_data read_mode adaptation */
-#define OV2680_READ_MODE_BINNING_ON	0x0400
-#define OV2680_READ_MODE_BINNING_OFF	0x00
-#define OV2680_INTEGRATION_TIME_MARGIN	8
-
-#define OV2680_MAX_EXPOSURE_VALUE	0xFFF1
-#define OV2680_MAX_GAIN_VALUE		0xFF
-
-/*
- * focal length bits definition:
- * bits 31-16: numerator, bits 15-0: denominator
- */
-#define OV2680_FOCAL_LENGTH_DEFAULT 0x1B70064
-
-/*
- * current f-number bits definition:
- * bits 31-16: numerator, bits 15-0: denominator
- */
-#define OV2680_F_NUMBER_DEFAULT 0x18000a
-
-/*
- * f-number range bits definition:
- * bits 31-24: max f-number numerator
- * bits 23-16: max f-number denominator
- * bits 15-8: min f-number numerator
- * bits 7-0: min f-number denominator
- */
-#define OV2680_F_NUMBER_RANGE 0x180a180a
-#define OV2680_ID	0x2680
-
-#define OV2680_FINE_INTG_TIME_MIN 0
-#define OV2680_FINE_INTG_TIME_MAX_MARGIN 0
-#define OV2680_COARSE_INTG_TIME_MIN 1
-#define OV2680_COARSE_INTG_TIME_MAX_MARGIN 6
-
-/*
- * OV2680 System control registers
- */
-#define OV2680_SW_SLEEP				0x0100
-#define OV2680_SW_RESET				0x0103
-#define OV2680_SW_STREAM			0x0100
-
-#define OV2680_SC_CMMN_CHIP_ID_H		0x300A
-#define OV2680_SC_CMMN_CHIP_ID_L		0x300B
-#define OV2680_SC_CMMN_SCCB_ID			0x302B /* 0x300C*/
-#define OV2680_SC_CMMN_SUB_ID			0x302A /* process, version*/
-
-#define OV2680_GROUP_ACCESS							0x3208 /*Bit[7:4] Group control, Bit[3:0] Group ID*/
-
-#define OV2680_EXPOSURE_H							0x3500 /*Bit[3:0] Bit[19:16] of exposure, remaining 16 bits lies in Reg0x3501&Reg0x3502*/
-#define OV2680_EXPOSURE_M							0x3501
-#define OV2680_EXPOSURE_L							0x3502
-#define OV2680_AGC_H								0x350A /*Bit[1:0] means Bit[9:8] of gain*/
-#define OV2680_AGC_L								0x350B /*Bit[7:0] of gain*/
-
-#define OV2680_HORIZONTAL_START_H					0x3800 /*Bit[11:8]*/
-#define OV2680_HORIZONTAL_START_L					0x3801 /*Bit[7:0]*/
-#define OV2680_VERTICAL_START_H						0x3802 /*Bit[11:8]*/
-#define OV2680_VERTICAL_START_L						0x3803 /*Bit[7:0]*/
-#define OV2680_HORIZONTAL_END_H						0x3804 /*Bit[11:8]*/
-#define OV2680_HORIZONTAL_END_L						0x3805 /*Bit[7:0]*/
-#define OV2680_VERTICAL_END_H						0x3806 /*Bit[11:8]*/
-#define OV2680_VERTICAL_END_L						0x3807 /*Bit[7:0]*/
-#define OV2680_HORIZONTAL_OUTPUT_SIZE_H				0x3808 /*Bit[3:0]*/
-#define OV2680_HORIZONTAL_OUTPUT_SIZE_L				0x3809 /*Bit[7:0]*/
-#define OV2680_VERTICAL_OUTPUT_SIZE_H				0x380a /*Bit[3:0]*/
-#define OV2680_VERTICAL_OUTPUT_SIZE_L				0x380b /*Bit[7:0]*/
-#define OV2680_TIMING_HTS_H							0x380C  /*High 8-bit, and low 8-bit HTS address is 0x380d*/
-#define OV2680_TIMING_HTS_L							0x380D  /*High 8-bit, and low 8-bit HTS address is 0x380d*/
-#define OV2680_TIMING_VTS_H							0x380e  /*High 8-bit, and low 8-bit HTS address is 0x380f*/
-#define OV2680_TIMING_VTS_L							0x380f  /*High 8-bit, and low 8-bit HTS address is 0x380f*/
-#define OV2680_FRAME_OFF_NUM						0x4202
-
-/*Flip/Mirror*/
-#define OV2680_FLIP_REG				0x3820
-#define OV2680_MIRROR_REG			0x3821
-#define OV2680_FLIP_BIT				1
-#define OV2680_MIRROR_BIT			2
-#define OV2680_FLIP_MIRROR_BIT_ENABLE		4
-
-#define OV2680_MWB_RED_GAIN_H			0x5004/*0x3400*/
-#define OV2680_MWB_GREEN_GAIN_H			0x5006/*0x3402*/
-#define OV2680_MWB_BLUE_GAIN_H			0x5008/*0x3404*/
-#define OV2680_MWB_GAIN_MAX				0x0fff
-
-#define OV2680_START_STREAMING			0x01
-#define OV2680_STOP_STREAMING			0x00
-
-
-#define OV2680_INVALID_CONFIG	0xffffffff
-
-
-struct regval_list {
-	u16 reg_num;
-	u8 value;
-};
-
-struct ov2680_resolution {
-	u8 *desc;
-	const struct ov2680_reg *regs;
-	int res;
-	int width;
-	int height;
-	int fps;
-	int pix_clk_freq;
-	u32 skip_frames;
-	u16 pixels_per_line;
-	u16 lines_per_frame;
-	u8 bin_factor_x;
-	u8 bin_factor_y;
-	u8 bin_mode;
-	bool used;
-};
-
-struct ov2680_format {
-	u8 *desc;
-	u32 pixelformat;
-	struct ov2680_reg *regs;
-};
-
-	/*
-	 * ov2680 device structure.
-	 */
-	struct ov2680_device {
-		struct v4l2_subdev sd;
-		struct media_pad pad;
-		struct v4l2_mbus_framefmt format;
-		struct mutex input_lock;
-	struct v4l2_ctrl_handler ctrl_handler;
-		struct camera_sensor_platform_data *platform_data;
-		int vt_pix_clk_freq_mhz;
-		int fmt_idx;
-		int run_mode;
-		u8 res;
-		u8 type;
-	};
-
-	enum ov2680_tok_type {
-		OV2680_8BIT  = 0x0001,
-		OV2680_16BIT = 0x0002,
-		OV2680_32BIT = 0x0004,
-		OV2680_TOK_TERM   = 0xf000,	/* terminating token for reg list */
-		OV2680_TOK_DELAY  = 0xfe00,	/* delay token for reg list */
-		OV2680_TOK_MASK = 0xfff0
-	};
-
-	/**
-	 * struct ov2680_reg - MI sensor  register format
-	 * @type: type of the register
-	 * @reg: 16-bit offset to register
-	 * @val: 8/16/32-bit register value
-	 *
-	 * Define a structure for sensor register initialization values
-	 */
-	struct ov2680_reg {
-		enum ov2680_tok_type type;
-		u16 reg;
-		u32 val;	/* @set value for read/mod/write, @mask */
-	};
-
-	#define to_ov2680_sensor(x) container_of(x, struct ov2680_device, sd)
-
-	#define OV2680_MAX_WRITE_BUF_SIZE	30
-
-	struct ov2680_write_buffer {
-		u16 addr;
-		u8 data[OV2680_MAX_WRITE_BUF_SIZE];
-	};
-
-	struct ov2680_write_ctrl {
-		int index;
-		struct ov2680_write_buffer buffer;
-	};
-
-	static struct ov2680_reg const ov2680_global_setting[] = {
-	    {OV2680_8BIT, 0x0103, 0x01},
-	    {OV2680_8BIT, 0x3002, 0x00},
-	    {OV2680_8BIT, 0x3016, 0x1c},
-	    {OV2680_8BIT, 0x3018, 0x44},
-	    {OV2680_8BIT, 0x3020, 0x00},
-	    {OV2680_8BIT, 0x3080, 0x02},
-	    {OV2680_8BIT, 0x3082, 0x45},
-	    {OV2680_8BIT, 0x3084, 0x09},
-	    {OV2680_8BIT, 0x3085, 0x04},
-	    {OV2680_8BIT, 0x3503, 0x03},
-	    {OV2680_8BIT, 0x350b, 0x36},
-	    {OV2680_8BIT, 0x3600, 0xb4},
-	    {OV2680_8BIT, 0x3603, 0x39},
-	    {OV2680_8BIT, 0x3604, 0x24},
-	    {OV2680_8BIT, 0x3605, 0x00},
-	    {OV2680_8BIT, 0x3620, 0x26},
-	    {OV2680_8BIT, 0x3621, 0x37},
-	    {OV2680_8BIT, 0x3622, 0x04},
-	    {OV2680_8BIT, 0x3628, 0x00},
-	    {OV2680_8BIT, 0x3705, 0x3c},
-	    {OV2680_8BIT, 0x370c, 0x50},
-	    {OV2680_8BIT, 0x370d, 0xc0},
-	    {OV2680_8BIT, 0x3718, 0x88},
-	    {OV2680_8BIT, 0x3720, 0x00},
-	    {OV2680_8BIT, 0x3721, 0x00},
-	    {OV2680_8BIT, 0x3722, 0x00},
-	    {OV2680_8BIT, 0x3723, 0x00},
-	    {OV2680_8BIT, 0x3738, 0x00},
-	    {OV2680_8BIT, 0x3717, 0x58},
-	    {OV2680_8BIT, 0x3781, 0x80},
-	    {OV2680_8BIT, 0x3789, 0x60},
-	    {OV2680_8BIT, 0x3800, 0x00},
-	    {OV2680_8BIT, 0x3819, 0x04},
-	    {OV2680_8BIT, 0x4000, 0x81},
-	    {OV2680_8BIT, 0x4001, 0x40},
-	    {OV2680_8BIT, 0x4602, 0x02},
-	    {OV2680_8BIT, 0x481f, 0x36},
-	    {OV2680_8BIT, 0x4825, 0x36},
-	    {OV2680_8BIT, 0x4837, 0x18},
-	    {OV2680_8BIT, 0x5002, 0x30},
-	    {OV2680_8BIT, 0x5004, 0x04},//manual awb 1x
-	    {OV2680_8BIT, 0x5005, 0x00},
-	    {OV2680_8BIT, 0x5006, 0x04},
-	    {OV2680_8BIT, 0x5007, 0x00},
-	    {OV2680_8BIT, 0x5008, 0x04},
-	    {OV2680_8BIT, 0x5009, 0x00},
-	    {OV2680_8BIT, 0x5080, 0x00},
-	    {OV2680_8BIT, 0x3701, 0x64},  //add on 14/05/13
-	    {OV2680_8BIT, 0x3784, 0x0c},  //based OV2680_R1A_AM10.ovt add on 14/06/13
-	    {OV2680_8BIT, 0x5780, 0x3e},  //based OV2680_R1A_AM10.ovt,Adjust DPC setting (57xx) on 14/06/13
-	    {OV2680_8BIT, 0x5781, 0x0f},
-	    {OV2680_8BIT, 0x5782, 0x04},
-	    {OV2680_8BIT, 0x5783, 0x02},
-	    {OV2680_8BIT, 0x5784, 0x01},
-	    {OV2680_8BIT, 0x5785, 0x01},
-	    {OV2680_8BIT, 0x5786, 0x00},
-	    {OV2680_8BIT, 0x5787, 0x04},
-	    {OV2680_8BIT, 0x5788, 0x02},
-	    {OV2680_8BIT, 0x5789, 0x00},
-	    {OV2680_8BIT, 0x578a, 0x01},
-	    {OV2680_8BIT, 0x578b, 0x02},
-	    {OV2680_8BIT, 0x578c, 0x03},
-	    {OV2680_8BIT, 0x578d, 0x03},
-	    {OV2680_8BIT, 0x578e, 0x08},
-	    {OV2680_8BIT, 0x578f, 0x0c},
-	    {OV2680_8BIT, 0x5790, 0x08},
-	    {OV2680_8BIT, 0x5791, 0x04},
-	    {OV2680_8BIT, 0x5792, 0x00},
-	    {OV2680_8BIT, 0x5793, 0x00},
-	    {OV2680_8BIT, 0x5794, 0x03}, //based OV2680_R1A_AM10.ovt,Adjust DPC setting (57xx) on 14/06/13
-		{OV2680_8BIT, 0x0100, 0x00},	//stream off
-
-		{OV2680_TOK_TERM, 0, 0}
-	};
-
-
-#if 0 /* None of the definitions below are used currently */
-	/*
-	 * 176x144 30fps  VBlanking 1lane 10Bit (binning)
-	 */
-	static struct ov2680_reg const ov2680_QCIF_30fps[] = {
-		{OV2680_8BIT, 0x3086, 0x01},
-		{OV2680_8BIT, 0x3501, 0x24},
-		{OV2680_8BIT, 0x3502, 0x40},
-		{OV2680_8BIT, 0x370a, 0x23},
-		{OV2680_8BIT, 0x3801, 0xa0},
-		{OV2680_8BIT, 0x3802, 0x00},
-		{OV2680_8BIT, 0x3803, 0x78},
-		{OV2680_8BIT, 0x3804, 0x05},
-		{OV2680_8BIT, 0x3805, 0xaf},
-		{OV2680_8BIT, 0x3806, 0x04},
-		{OV2680_8BIT, 0x3807, 0x47},
-		{OV2680_8BIT, 0x3808, 0x00},
-		{OV2680_8BIT, 0x3809, 0xC0},
-		{OV2680_8BIT, 0x380a, 0x00},
-		{OV2680_8BIT, 0x380b, 0xa0},
-		{OV2680_8BIT, 0x380c, 0x06},
-		{OV2680_8BIT, 0x380d, 0xb0},
-		{OV2680_8BIT, 0x380e, 0x02},
-		{OV2680_8BIT, 0x380f, 0x84},
-		{OV2680_8BIT, 0x3810, 0x00},
-		{OV2680_8BIT, 0x3811, 0x04},
-		{OV2680_8BIT, 0x3812, 0x00},
-		{OV2680_8BIT, 0x3813, 0x04},
-		{OV2680_8BIT, 0x3814, 0x31},
-		{OV2680_8BIT, 0x3815, 0x31},
-		{OV2680_8BIT, 0x4000, 0x81},
-		{OV2680_8BIT, 0x4001, 0x40},
-		{OV2680_8BIT, 0x4008, 0x00},
-		{OV2680_8BIT, 0x4009, 0x03},
-		{OV2680_8BIT, 0x5081, 0x41},
-		{OV2680_8BIT, 0x5708, 0x00}, //add for full size flip off and mirror off 2014/09/11
-		{OV2680_8BIT, 0x5704, 0x10},
-		{OV2680_8BIT, 0x5705, 0xa0},
-		{OV2680_8BIT, 0x5706, 0x0c},
-		{OV2680_8BIT, 0x5707, 0x78},
-		{OV2680_8BIT, 0x3820, 0xc2},
-		{OV2680_8BIT, 0x3821, 0x01},
-		// {OV2680_8BIT, 0x5090, 0x0c},
-		{OV2680_TOK_TERM, 0, 0}
-	};
-
-	/*
-	 * 352x288 30fps  VBlanking 1lane 10Bit (binning)
-	 */
-	static struct ov2680_reg const ov2680_CIF_30fps[] = {
-		{OV2680_8BIT, 0x3086, 0x01},
-		{OV2680_8BIT, 0x3501, 0x24},
-		{OV2680_8BIT, 0x3502, 0x40},
-		{OV2680_8BIT, 0x370a, 0x23},
-		{OV2680_8BIT, 0x3801, 0xa0},
-		{OV2680_8BIT, 0x3802, 0x00},
-		{OV2680_8BIT, 0x3803, 0x78},
-		{OV2680_8BIT, 0x3804, 0x03},
-		{OV2680_8BIT, 0x3805, 0x8f},
-		{OV2680_8BIT, 0x3806, 0x02},
-		{OV2680_8BIT, 0x3807, 0xe7},
-		{OV2680_8BIT, 0x3808, 0x01},
-		{OV2680_8BIT, 0x3809, 0x70},
-		{OV2680_8BIT, 0x380a, 0x01},
-		{OV2680_8BIT, 0x380b, 0x30},
-		{OV2680_8BIT, 0x380c, 0x06},
-		{OV2680_8BIT, 0x380d, 0xb0},
-		{OV2680_8BIT, 0x380e, 0x02},
-		{OV2680_8BIT, 0x380f, 0x84},
-		{OV2680_8BIT, 0x3810, 0x00},
-		{OV2680_8BIT, 0x3811, 0x04},
-		{OV2680_8BIT, 0x3812, 0x00},
-		{OV2680_8BIT, 0x3813, 0x04},
-		{OV2680_8BIT, 0x3814, 0x31},
-		{OV2680_8BIT, 0x3815, 0x31},
-		{OV2680_8BIT, 0x4008, 0x00},
-		{OV2680_8BIT, 0x4009, 0x03},
-		{OV2680_8BIT, 0x5081, 0x41},
-		{OV2680_8BIT, 0x5708, 0x00}, //add for full size flip off and mirror off 2014/09/11
-		{OV2680_8BIT, 0x5704, 0x10},
-		{OV2680_8BIT, 0x5705, 0xa0},
-		{OV2680_8BIT, 0x5706, 0x0c},
-		{OV2680_8BIT, 0x5707, 0x78},
-		{OV2680_8BIT, 0x3820, 0xc2},
-		{OV2680_8BIT, 0x3821, 0x01},
-		// {OV2680_8BIT, 0x5090, 0x0c},
-		{OV2680_TOK_TERM, 0, 0}
-	};
-
-	/*
-	 * 336x256 30fps  VBlanking 1lane 10Bit (binning)
-	 */
-	static struct ov2680_reg const ov2680_QVGA_30fps[] = {
-		{OV2680_8BIT, 0x3086, 0x01},
-		{OV2680_8BIT, 0x3501, 0x24},
-		{OV2680_8BIT, 0x3502, 0x40},
-		{OV2680_8BIT, 0x370a, 0x23},
-		{OV2680_8BIT, 0x3801, 0xa0},
-		{OV2680_8BIT, 0x3802, 0x00},
-		{OV2680_8BIT, 0x3803, 0x78},
-		{OV2680_8BIT, 0x3804, 0x03},
-		{OV2680_8BIT, 0x3805, 0x4f},
-		{OV2680_8BIT, 0x3806, 0x02},
-		{OV2680_8BIT, 0x3807, 0x87},
-		{OV2680_8BIT, 0x3808, 0x01},
-		{OV2680_8BIT, 0x3809, 0x50},
-		{OV2680_8BIT, 0x380a, 0x01},
-		{OV2680_8BIT, 0x380b, 0x00},
-		{OV2680_8BIT, 0x380c, 0x06},
-		{OV2680_8BIT, 0x380d, 0xb0},
-		{OV2680_8BIT, 0x380e, 0x02},
-		{OV2680_8BIT, 0x380f, 0x84},
-		{OV2680_8BIT, 0x3810, 0x00},
-		{OV2680_8BIT, 0x3811, 0x04},
-		{OV2680_8BIT, 0x3812, 0x00},
-		{OV2680_8BIT, 0x3813, 0x04},
-		{OV2680_8BIT, 0x3814, 0x31},
-		{OV2680_8BIT, 0x3815, 0x31},
-		{OV2680_8BIT, 0x4008, 0x00},
-		{OV2680_8BIT, 0x4009, 0x03},
-		{OV2680_8BIT, 0x5081, 0x41},
-		{OV2680_8BIT, 0x5708, 0x00}, //add for full size flip off and mirror off 2014/09/11
-		{OV2680_8BIT, 0x5704, 0x10},
-		{OV2680_8BIT, 0x5705, 0xa0},
-		{OV2680_8BIT, 0x5706, 0x0c},
-		{OV2680_8BIT, 0x5707, 0x78},
-		{OV2680_8BIT, 0x3820, 0xc2},
-		{OV2680_8BIT, 0x3821, 0x01},
-		// {OV2680_8BIT, 0x5090, 0x0c},
-		{OV2680_TOK_TERM, 0, 0}
-	};
-
-
-	/*
-	 * 656x496 30fps  VBlanking 1lane 10Bit (binning)
-	 */
-	static struct ov2680_reg const ov2680_656x496_30fps[] = {
-		{OV2680_8BIT, 0x3086, 0x01},
-		{OV2680_8BIT, 0x3501, 0x24},
-		{OV2680_8BIT, 0x3502, 0x40},
-		{OV2680_8BIT, 0x370a, 0x23},
-		{OV2680_8BIT, 0x3801, 0xa0},
-		{OV2680_8BIT, 0x3802, 0x00},
-		{OV2680_8BIT, 0x3803, 0x78},
-		{OV2680_8BIT, 0x3804, 0x05},
-		{OV2680_8BIT, 0x3805, 0xcf},
-		{OV2680_8BIT, 0x3806, 0x04},
-		{OV2680_8BIT, 0x3807, 0x67},
-		{OV2680_8BIT, 0x3808, 0x02},
-		{OV2680_8BIT, 0x3809, 0x90},
-		{OV2680_8BIT, 0x380a, 0x01},
-		{OV2680_8BIT, 0x380b, 0xf0},
-		{OV2680_8BIT, 0x380c, 0x06},
-		{OV2680_8BIT, 0x380d, 0xb0},
-		{OV2680_8BIT, 0x380e, 0x02},
-		{OV2680_8BIT, 0x380f, 0x84},
-		{OV2680_8BIT, 0x3810, 0x00},
-		{OV2680_8BIT, 0x3811, 0x04},
-		{OV2680_8BIT, 0x3812, 0x00},
-		{OV2680_8BIT, 0x3813, 0x04},
-		{OV2680_8BIT, 0x3814, 0x31},
-		{OV2680_8BIT, 0x3815, 0x31},
-		{OV2680_8BIT, 0x4008, 0x00},
-		{OV2680_8BIT, 0x4009, 0x03},
-		{OV2680_8BIT, 0x5081, 0x41},
-		{OV2680_8BIT, 0x5708, 0x00}, //add for full size flip off and mirror off 2014/09/11
-		{OV2680_8BIT, 0x5704, 0x10},
-		{OV2680_8BIT, 0x5705, 0xa0},
-		{OV2680_8BIT, 0x5706, 0x0c},
-		{OV2680_8BIT, 0x5707, 0x78},
-		{OV2680_8BIT, 0x3820, 0xc2},
-		{OV2680_8BIT, 0x3821, 0x01},
-		// {OV2680_8BIT, 0x5090, 0x0c},
-		{OV2680_TOK_TERM, 0, 0}
-	};
-	/*
-	* 800x600 30fps  VBlanking 1lane 10Bit (binning)
-	*/
-	static struct ov2680_reg const ov2680_720x592_30fps[] = {
-		{OV2680_8BIT, 0x3086, 0x01},
-		{OV2680_8BIT, 0x3501, 0x26},
-		{OV2680_8BIT, 0x3502, 0x40},
-		{OV2680_8BIT, 0x370a, 0x23},
-		{OV2680_8BIT, 0x3801, 0x00}, // X_ADDR_START;
-		{OV2680_8BIT, 0x3802, 0x00},
-		{OV2680_8BIT, 0x3803, 0x00}, // Y_ADDR_START;
-		{OV2680_8BIT, 0x3804, 0x05},
-		{OV2680_8BIT, 0x3805, 0xaf}, // X_ADDR_END;
-		{OV2680_8BIT, 0x3806, 0x04},
-		{OV2680_8BIT, 0x3807, 0xaf}, // Y_ADDR_END;
-		{OV2680_8BIT, 0x3808, 0x02},
-		{OV2680_8BIT, 0x3809, 0xd0}, // X_OUTPUT_SIZE;
-		{OV2680_8BIT, 0x380a, 0x02},
-		{OV2680_8BIT, 0x380b, 0x50}, // Y_OUTPUT_SIZE;
-		{OV2680_8BIT, 0x380c, 0x06},
-		{OV2680_8BIT, 0x380d, 0xac}, // HTS;
-		{OV2680_8BIT, 0x380e, 0x02},
-		{OV2680_8BIT, 0x380f, 0x84}, // VTS;
-		{OV2680_8BIT, 0x3810, 0x00},
-		{OV2680_8BIT, 0x3811, 0x00},
-		{OV2680_8BIT, 0x3812, 0x00},
-		{OV2680_8BIT, 0x3813, 0x00},
-		{OV2680_8BIT, 0x3814, 0x31},
-		{OV2680_8BIT, 0x3815, 0x31},
-		{OV2680_8BIT, 0x4008, 0x00},
-		{OV2680_8BIT, 0x4009, 0x03},
-		{OV2680_8BIT, 0x5708, 0x00},
-		{OV2680_8BIT, 0x5704, 0x02},
-		{OV2680_8BIT, 0x5705, 0xd0}, // X_WIN;
-		{OV2680_8BIT, 0x5706, 0x02},
-		{OV2680_8BIT, 0x5707, 0x50}, // Y_WIN;
-		{OV2680_8BIT, 0x3820, 0xc2}, // FLIP_FORMAT;
-		{OV2680_8BIT, 0x3821, 0x01}, // MIRROR_FORMAT;
-		{OV2680_8BIT, 0x5090, 0x00}, // PRE ISP CTRL16, default value is 0x0C;
-					     // BIT[3]: Mirror order, BG or GB;
-					     // BIT[2]: Flip order, BR or RB;
-		{OV2680_8BIT, 0x5081, 0x41},
-		{OV2680_TOK_TERM, 0, 0}
-	};
-	/*
-	* 800x600 30fps  VBlanking 1lane 10Bit (binning)
-	*/
-	static struct ov2680_reg const ov2680_800x600_30fps[] = {
-		{OV2680_8BIT, 0x3086, 0x01},
-		{OV2680_8BIT, 0x3501, 0x26},
-		{OV2680_8BIT, 0x3502, 0x40},
-		{OV2680_8BIT, 0x370a, 0x23},
-		{OV2680_8BIT, 0x3801, 0x00},
-		{OV2680_8BIT, 0x3802, 0x00},
-		{OV2680_8BIT, 0x3803, 0x00},
-		{OV2680_8BIT, 0x3804, 0x06},
-		{OV2680_8BIT, 0x3805, 0x4f},
-		{OV2680_8BIT, 0x3806, 0x04},
-		{OV2680_8BIT, 0x3807, 0xbf},
-		{OV2680_8BIT, 0x3808, 0x03},
-		{OV2680_8BIT, 0x3809, 0x20},
-		{OV2680_8BIT, 0x380a, 0x02},
-		{OV2680_8BIT, 0x380b, 0x58},
-		{OV2680_8BIT, 0x380c, 0x06},
-		{OV2680_8BIT, 0x380d, 0xac},
-		{OV2680_8BIT, 0x380e, 0x02},
-		{OV2680_8BIT, 0x380f, 0x84},
-		{OV2680_8BIT, 0x3810, 0x00},
-		{OV2680_8BIT, 0x3811, 0x00},
-		{OV2680_8BIT, 0x3812, 0x00},
-		{OV2680_8BIT, 0x3813, 0x00},
-		{OV2680_8BIT, 0x3814, 0x31},
-		{OV2680_8BIT, 0x3815, 0x31},
-		{OV2680_8BIT, 0x5708, 0x00},
-		{OV2680_8BIT, 0x5704, 0x03},
-		{OV2680_8BIT, 0x5705, 0x20},
-		{OV2680_8BIT, 0x5706, 0x02},
-		{OV2680_8BIT, 0x5707, 0x58},
-		{OV2680_8BIT, 0x3820, 0xc2},
-		{OV2680_8BIT, 0x3821, 0x01},
-		{OV2680_8BIT, 0x5090, 0x00},
-		{OV2680_8BIT, 0x4008, 0x00},
-		{OV2680_8BIT, 0x4009, 0x03},
-		{OV2680_8BIT, 0x5081, 0x41},
-		{OV2680_TOK_TERM, 0, 0}
-	};
-
-	/*
-	 * 720p=1280*720 30fps  VBlanking 1lane 10Bit (no-Scaling)
-	 */
-	static struct ov2680_reg const ov2680_720p_30fps[] = {
-		{OV2680_8BIT, 0x3086, 0x00},
-		{OV2680_8BIT, 0x3501, 0x48},
-		{OV2680_8BIT, 0x3502, 0xe0},
-		{OV2680_8BIT, 0x370a, 0x21},
-		{OV2680_8BIT, 0x3801, 0xa0},
-		{OV2680_8BIT, 0x3802, 0x00},
-		{OV2680_8BIT, 0x3803, 0xf2},
-		{OV2680_8BIT, 0x3804, 0x05},
-		{OV2680_8BIT, 0x3805, 0xbf},
-		{OV2680_8BIT, 0x3806, 0x03},
-		{OV2680_8BIT, 0x3807, 0xdd},
-		{OV2680_8BIT, 0x3808, 0x05},
-		{OV2680_8BIT, 0x3809, 0x10},
-		{OV2680_8BIT, 0x380a, 0x02},
-		{OV2680_8BIT, 0x380b, 0xe0},
-		{OV2680_8BIT, 0x380c, 0x06},
-		{OV2680_8BIT, 0x380d, 0xa8},
-		{OV2680_8BIT, 0x380e, 0x05},
-		{OV2680_8BIT, 0x380f, 0x0e},
-		{OV2680_8BIT, 0x3810, 0x00},
-		{OV2680_8BIT, 0x3811, 0x08},
-		{OV2680_8BIT, 0x3812, 0x00},
-		{OV2680_8BIT, 0x3813, 0x06},
-		{OV2680_8BIT, 0x3814, 0x11},
-		{OV2680_8BIT, 0x3815, 0x11},
-		{OV2680_8BIT, 0x4008, 0x02},
-		{OV2680_8BIT, 0x4009, 0x09},
-		{OV2680_8BIT, 0x5081, 0x41},
-		{OV2680_8BIT, 0x5708, 0x00}, //add for full size flip off and mirror off 2014/09/11
-		{OV2680_8BIT, 0x5704, 0x10},
-		{OV2680_8BIT, 0x5705, 0xa0},
-		{OV2680_8BIT, 0x5706, 0x0c},
-		{OV2680_8BIT, 0x5707, 0x78},
-		{OV2680_8BIT, 0x3820, 0xc0},
-		{OV2680_8BIT, 0x3821, 0x00},
-		// {OV2680_8BIT, 0x5090, 0x0c},
-		{OV2680_TOK_TERM, 0, 0}
-	};
-
-	/*
-	 * 1296x976 30fps  VBlanking 1lane 10Bit(no-scaling)
-	 */
-	static struct ov2680_reg const ov2680_1296x976_30fps[] = {
-		{OV2680_8BIT, 0x3086, 0x00},
-		{OV2680_8BIT, 0x3501, 0x48},
-		{OV2680_8BIT, 0x3502, 0xe0},
-		{OV2680_8BIT, 0x370a, 0x21},
-		{OV2680_8BIT, 0x3801, 0xa0},
-		{OV2680_8BIT, 0x3802, 0x00},
-		{OV2680_8BIT, 0x3803, 0x78},
-		{OV2680_8BIT, 0x3804, 0x05},
-		{OV2680_8BIT, 0x3805, 0xbf},
-		{OV2680_8BIT, 0x3806, 0x04},
-		{OV2680_8BIT, 0x3807, 0x57},
-		{OV2680_8BIT, 0x3808, 0x05},
-		{OV2680_8BIT, 0x3809, 0x10},
-		{OV2680_8BIT, 0x380a, 0x03},
-		{OV2680_8BIT, 0x380b, 0xd0},
-		{OV2680_8BIT, 0x380c, 0x06},
-		{OV2680_8BIT, 0x380d, 0xa8},
-		{OV2680_8BIT, 0x380e, 0x05},
-		{OV2680_8BIT, 0x380f, 0x0e},
-		{OV2680_8BIT, 0x3810, 0x00},
-		{OV2680_8BIT, 0x3811, 0x08},
-		{OV2680_8BIT, 0x3812, 0x00},
-		{OV2680_8BIT, 0x3813, 0x08},
-		{OV2680_8BIT, 0x3814, 0x11},
-		{OV2680_8BIT, 0x3815, 0x11},
-		{OV2680_8BIT, 0x4008, 0x02},
-		{OV2680_8BIT, 0x4009, 0x09},
-		{OV2680_8BIT, 0x5081, 0x41},
-		{OV2680_8BIT, 0x5708, 0x00}, //add for full size flip off and mirror off 2014/09/11
-		{OV2680_8BIT, 0x5704, 0x10},
-		{OV2680_8BIT, 0x5705, 0xa0},
-		{OV2680_8BIT, 0x5706, 0x0c},
-		{OV2680_8BIT, 0x5707, 0x78},
-		{OV2680_8BIT, 0x3820, 0xc0},
-		{OV2680_8BIT, 0x3821, 0x00}, //miror/flip
-		// {OV2680_8BIT, 0x5090, 0x0c},
-		{OV2680_TOK_TERM, 0, 0}
- 	};
-
-	/*
-	 *   1456*1096 30fps  VBlanking 1lane 10bit(no-scaling)
-	*/
-	static struct ov2680_reg const ov2680_1456x1096_30fps[]= {
-		{OV2680_8BIT, 0x3086, 0x00},
-		{OV2680_8BIT, 0x3501, 0x48},
-		{OV2680_8BIT, 0x3502, 0xe0},
-		{OV2680_8BIT, 0x370a, 0x21},
-		{OV2680_8BIT, 0x3801, 0x90},
-		{OV2680_8BIT, 0x3802, 0x00},
-		{OV2680_8BIT, 0x3803, 0x78},
-		{OV2680_8BIT, 0x3804, 0x06},
-		{OV2680_8BIT, 0x3805, 0x4f},
-		{OV2680_8BIT, 0x3806, 0x04},
-		{OV2680_8BIT, 0x3807, 0xC0},
-		{OV2680_8BIT, 0x3808, 0x05},
-		{OV2680_8BIT, 0x3809, 0xb0},
-		{OV2680_8BIT, 0x380a, 0x04},
-		{OV2680_8BIT, 0x380b, 0x48},
-		{OV2680_8BIT, 0x380c, 0x06},
-		{OV2680_8BIT, 0x380d, 0xa8},
-		{OV2680_8BIT, 0x380e, 0x05},
-		{OV2680_8BIT, 0x380f, 0x0e},
-		{OV2680_8BIT, 0x3810, 0x00},
-		{OV2680_8BIT, 0x3811, 0x08},
-		{OV2680_8BIT, 0x3812, 0x00},
-		{OV2680_8BIT, 0x3813, 0x00},
-		{OV2680_8BIT, 0x3814, 0x11},
-		{OV2680_8BIT, 0x3815, 0x11},
-		{OV2680_8BIT, 0x4008, 0x02},
-		{OV2680_8BIT, 0x4009, 0x09},
-		{OV2680_8BIT, 0x5081, 0x41},
-		{OV2680_8BIT, 0x5708, 0x00}, //add for full size flip off and mirror off 2014/09/11
-		{OV2680_8BIT, 0x5704, 0x10},
-		{OV2680_8BIT, 0x5705, 0xa0},
-		{OV2680_8BIT, 0x5706, 0x0c},
-		{OV2680_8BIT, 0x5707, 0x78},
-		{OV2680_8BIT, 0x3820, 0xc0},
-		{OV2680_8BIT, 0x3821, 0x00},
-		// {OV2680_8BIT, 0x5090, 0x0c},
-		{OV2680_TOK_TERM, 0, 0}
-	};
-#endif
-
-	/*
-	 *1616x916  30fps  VBlanking 1lane 10bit
-	 */
-
-	static struct ov2680_reg const ov2680_1616x916_30fps[] = {
-		{OV2680_8BIT, 0x3086, 0x00},
-		{OV2680_8BIT, 0x3501, 0x48},
-		{OV2680_8BIT, 0x3502, 0xe0},
-		{OV2680_8BIT, 0x370a, 0x21},
-		{OV2680_8BIT, 0x3801, 0x00},
-		{OV2680_8BIT, 0x3802, 0x00},
-		{OV2680_8BIT, 0x3803, 0x96},
-		{OV2680_8BIT, 0x3804, 0x06},
-		{OV2680_8BIT, 0x3805, 0x4f},
-		{OV2680_8BIT, 0x3806, 0x04},
-		{OV2680_8BIT, 0x3807, 0x39},
-		{OV2680_8BIT, 0x3808, 0x06},
-		{OV2680_8BIT, 0x3809, 0x50},
-		{OV2680_8BIT, 0x380a, 0x03},
-		{OV2680_8BIT, 0x380b, 0x94},
-		{OV2680_8BIT, 0x380c, 0x06},
-		{OV2680_8BIT, 0x380d, 0xa8},
-		{OV2680_8BIT, 0x380e, 0x05},
-		{OV2680_8BIT, 0x380f, 0x0e},
-		{OV2680_8BIT, 0x3810, 0x00},
-		{OV2680_8BIT, 0x3811, 0x00},
-		{OV2680_8BIT, 0x3812, 0x00},
-		{OV2680_8BIT, 0x3813, 0x08},
-		{OV2680_8BIT, 0x3814, 0x11},
-		{OV2680_8BIT, 0x3815, 0x11},
-		{OV2680_8BIT, 0x4008, 0x02},
-		{OV2680_8BIT, 0x4009, 0x09},
-		{OV2680_8BIT, 0x5081, 0x41},
-		{OV2680_8BIT, 0x5708, 0x01}, //add for full size flip off and mirror off 2014/09/11
-		{OV2680_8BIT, 0x5704, 0x06},
-		{OV2680_8BIT, 0x5705, 0x50},
-		{OV2680_8BIT, 0x5706, 0x03},
-		{OV2680_8BIT, 0x5707, 0x94},
-		{OV2680_8BIT, 0x3820, 0xc0},
-		{OV2680_8BIT, 0x3821, 0x00},
-		// {OV2680_8BIT, 0x5090, 0x0C},
-		{OV2680_TOK_TERM, 0, 0}
-	};
-
-	/*
-	 * 1612x1212 30fps VBlanking 1lane 10Bit
-	 */
-#if 0
-	static struct ov2680_reg const ov2680_1616x1082_30fps[] = {
-		{OV2680_8BIT, 0x3086, 0x00},
-		{OV2680_8BIT, 0x3501, 0x48},
-		{OV2680_8BIT, 0x3502, 0xe0},
-		{OV2680_8BIT, 0x370a, 0x21},
-		{OV2680_8BIT, 0x3801, 0x00},
-		{OV2680_8BIT, 0x3802, 0x00},
-		{OV2680_8BIT, 0x3803, 0x86},
-		{OV2680_8BIT, 0x3804, 0x06},
-		{OV2680_8BIT, 0x3805, 0x4f},
-		{OV2680_8BIT, 0x3806, 0x04},
-		{OV2680_8BIT, 0x3807, 0xbf},
-		{OV2680_8BIT, 0x3808, 0x06},
-		{OV2680_8BIT, 0x3809, 0x50},
-		{OV2680_8BIT, 0x380a, 0x04},
-		{OV2680_8BIT, 0x380b, 0x3a},
-		{OV2680_8BIT, 0x380c, 0x06},
-		{OV2680_8BIT, 0x380d, 0xa8},
-		{OV2680_8BIT, 0x380e, 0x05},
-		{OV2680_8BIT, 0x380f, 0x0e},
-		{OV2680_8BIT, 0x3810, 0x00},
-		{OV2680_8BIT, 0x3811, 0x00},
-		{OV2680_8BIT, 0x3812, 0x00},
-		{OV2680_8BIT, 0x3813, 0x00},
-		{OV2680_8BIT, 0x3814, 0x11},
-		{OV2680_8BIT, 0x3815, 0x11},
-		{OV2680_8BIT, 0x5708, 0x01}, //add for full size flip off and mirror off 2014/09/11
-		{OV2680_8BIT, 0x5704, 0x06},
-		{OV2680_8BIT, 0x5705, 0x50},
-		{OV2680_8BIT, 0x5706, 0x04},
-		{OV2680_8BIT, 0x5707, 0x3a},
-		{OV2680_8BIT, 0x3820, 0xc0},
-		{OV2680_8BIT, 0x3821, 0x00},
-		// {OV2680_8BIT, 0x5090, 0x0C},
-		{OV2680_8BIT, 0x4008, 0x02},
-		{OV2680_8BIT, 0x4009, 0x09},
-		{OV2680_8BIT, 0x5081, 0x41},
-		{OV2680_TOK_TERM, 0, 0}
-        };
-#endif
-	/*
-	 * 1616x1216 30fps VBlanking 1lane 10Bit
-	 */
-	static struct ov2680_reg const ov2680_1616x1216_30fps[] = {
-		{OV2680_8BIT, 0x3086, 0x00},
-		{OV2680_8BIT, 0x3501, 0x48},
-		{OV2680_8BIT, 0x3502, 0xe0},
-		{OV2680_8BIT, 0x370a, 0x21},
-		{OV2680_8BIT, 0x3801, 0x00},
-		{OV2680_8BIT, 0x3802, 0x00},
-		{OV2680_8BIT, 0x3803, 0x00},
-		{OV2680_8BIT, 0x3804, 0x06},
-		{OV2680_8BIT, 0x3805, 0x4f},
-		{OV2680_8BIT, 0x3806, 0x04},
-		{OV2680_8BIT, 0x3807, 0xbf},
-		{OV2680_8BIT, 0x3808, 0x06},
-		{OV2680_8BIT, 0x3809, 0x50},//50},//4line for mirror and flip
-		{OV2680_8BIT, 0x380a, 0x04},
-		{OV2680_8BIT, 0x380b, 0xc0},//c0},
-		{OV2680_8BIT, 0x380c, 0x06},
-		{OV2680_8BIT, 0x380d, 0xa8},
-		{OV2680_8BIT, 0x380e, 0x05},
-		{OV2680_8BIT, 0x380f, 0x0e},
-		{OV2680_8BIT, 0x3810, 0x00},
-		{OV2680_8BIT, 0x3811, 0x00},
-		{OV2680_8BIT, 0x3812, 0x00},
-		{OV2680_8BIT, 0x3813, 0x00},
-		{OV2680_8BIT, 0x3814, 0x11},
-		{OV2680_8BIT, 0x3815, 0x11},
-		{OV2680_8BIT, 0x4008, 0x00},
-		{OV2680_8BIT, 0x4009, 0x0b},
-		{OV2680_8BIT, 0x5081, 0x01},
-		{OV2680_8BIT, 0x5708, 0x01}, //add for full size flip off and mirror off 2014/09/11
-		{OV2680_8BIT, 0x5704, 0x06},
-		{OV2680_8BIT, 0x5705, 0x50},
-		{OV2680_8BIT, 0x5706, 0x04},
-		{OV2680_8BIT, 0x5707, 0xcc},
-		{OV2680_8BIT, 0x3820, 0xc0},
-		{OV2680_8BIT, 0x3821, 0x00},
-		// {OV2680_8BIT, 0x5090, 0x0C},
-		{OV2680_TOK_TERM, 0, 0}
-	};
-
-	static struct ov2680_resolution ov2680_res_preview[] = {
-	{
-		.desc = "ov2680_1616x1216_30fps",
- 	  	.width = 1616,
-		.height = 1216,
-		.pix_clk_freq = 66,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 1698,//1704,
-		.lines_per_frame = 1294,
-		.bin_factor_x = 0,
-		.bin_factor_y = 0,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = ov2680_1616x1216_30fps,
-	},
-   	{
-		.desc = "ov2680_1616x916_30fps",
-		.width = 1616,
-		.height = 916,
-		.fps = 30,
-		.pix_clk_freq = 66,
-		.used = 0,
-		.pixels_per_line = 1698,//1704,
-		.lines_per_frame = 1294,
-		.bin_factor_x = 0,
-		.bin_factor_y = 0,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = ov2680_1616x916_30fps,
-	},
-};
-#define N_RES_PREVIEW (ARRAY_SIZE(ov2680_res_preview))
-
-static struct ov2680_resolution *ov2680_res = ov2680_res_preview;
-static unsigned long N_RES = N_RES_PREVIEW;
-
-#endif

+ 0 - 1268
drivers/staging/media/atomisp/i2c/ov2722.h

@@ -1,1268 +0,0 @@
-/*
- * Support for OmniVision OV2722 1080p HD camera sensor.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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 __OV2722_H__
-#define __OV2722_H__
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/delay.h>
-#include <linux/videodev2.h>
-#include <linux/spinlock.h>
-#include <media/v4l2-subdev.h>
-#include <media/v4l2-device.h>
-#include <linux/v4l2-mediabus.h>
-#include <media/media-entity.h>
-#include <media/v4l2-ctrls.h>
-
-#include "../include/linux/atomisp_platform.h"
-
-#define OV2722_POWER_UP_RETRY_NUM 5
-
-/* Defines for register writes and register array processing */
-#define I2C_MSG_LENGTH		0x2
-#define I2C_RETRY_COUNT		5
-
-#define OV2722_FOCAL_LENGTH_NUM	278	/*2.78mm*/
-#define OV2722_FOCAL_LENGTH_DEM	100
-#define OV2722_F_NUMBER_DEFAULT_NUM	26
-#define OV2722_F_NUMBER_DEM	10
-
-#define MAX_FMTS		1
-
-/*
- * focal length bits definition:
- * bits 31-16: numerator, bits 15-0: denominator
- */
-#define OV2722_FOCAL_LENGTH_DEFAULT 0x1160064
-
-/*
- * current f-number bits definition:
- * bits 31-16: numerator, bits 15-0: denominator
- */
-#define OV2722_F_NUMBER_DEFAULT 0x1a000a
-
-/*
- * f-number range bits definition:
- * bits 31-24: max f-number numerator
- * bits 23-16: max f-number denominator
- * bits 15-8: min f-number numerator
- * bits 7-0: min f-number denominator
- */
-#define OV2722_F_NUMBER_RANGE 0x1a0a1a0a
-#define OV2720_ID	0x2720
-#define OV2722_ID	0x2722
-
-#define OV2722_FINE_INTG_TIME_MIN 0
-#define OV2722_FINE_INTG_TIME_MAX_MARGIN 0
-#define OV2722_COARSE_INTG_TIME_MIN 1
-#define OV2722_COARSE_INTG_TIME_MAX_MARGIN 4
-
-/*
- * OV2722 System control registers
- */
-#define OV2722_SW_SLEEP				0x0100
-#define OV2722_SW_RESET				0x0103
-#define OV2722_SW_STREAM			0x0100
-
-#define OV2722_SC_CMMN_CHIP_ID_H		0x300A
-#define OV2722_SC_CMMN_CHIP_ID_L		0x300B
-#define OV2722_SC_CMMN_SCCB_ID			0x300C
-#define OV2722_SC_CMMN_SUB_ID			0x302A /* process, version*/
-
-#define OV2722_SC_CMMN_PAD_OEN0			0x3000
-#define OV2722_SC_CMMN_PAD_OEN1			0x3001
-#define OV2722_SC_CMMN_PAD_OEN2			0x3002
-#define OV2722_SC_CMMN_PAD_OUT0			0x3008
-#define OV2722_SC_CMMN_PAD_OUT1			0x3009
-#define OV2722_SC_CMMN_PAD_OUT2			0x300D
-#define OV2722_SC_CMMN_PAD_SEL0			0x300E
-#define OV2722_SC_CMMN_PAD_SEL1			0x300F
-#define OV2722_SC_CMMN_PAD_SEL2			0x3010
-
-#define OV2722_SC_CMMN_PAD_PK			0x3011
-#define OV2722_SC_CMMN_A_PWC_PK_O_13		0x3013
-#define OV2722_SC_CMMN_A_PWC_PK_O_14		0x3014
-
-#define OV2722_SC_CMMN_CLKRST0			0x301A
-#define OV2722_SC_CMMN_CLKRST1			0x301B
-#define OV2722_SC_CMMN_CLKRST2			0x301C
-#define OV2722_SC_CMMN_CLKRST3			0x301D
-#define OV2722_SC_CMMN_CLKRST4			0x301E
-#define OV2722_SC_CMMN_CLKRST5			0x3005
-#define OV2722_SC_CMMN_PCLK_DIV_CTRL		0x3007
-#define OV2722_SC_CMMN_CLOCK_SEL		0x3020
-#define OV2722_SC_SOC_CLKRST5			0x3040
-
-#define OV2722_SC_CMMN_PLL_CTRL0		0x3034
-#define OV2722_SC_CMMN_PLL_CTRL1		0x3035
-#define OV2722_SC_CMMN_PLL_CTRL2		0x3039
-#define OV2722_SC_CMMN_PLL_CTRL3		0x3037
-#define OV2722_SC_CMMN_PLL_MULTIPLIER		0x3036
-#define OV2722_SC_CMMN_PLL_DEBUG_OPT		0x3038
-#define OV2722_SC_CMMN_PLLS_CTRL0		0x303A
-#define OV2722_SC_CMMN_PLLS_CTRL1		0x303B
-#define OV2722_SC_CMMN_PLLS_CTRL2		0x303C
-#define OV2722_SC_CMMN_PLLS_CTRL3		0x303D
-
-#define OV2722_SC_CMMN_MIPI_PHY_16		0x3016
-#define OV2722_SC_CMMN_MIPI_PHY_17		0x3017
-#define OV2722_SC_CMMN_MIPI_SC_CTRL_18		0x3018
-#define OV2722_SC_CMMN_MIPI_SC_CTRL_19		0x3019
-#define OV2722_SC_CMMN_MIPI_SC_CTRL_21		0x3021
-#define OV2722_SC_CMMN_MIPI_SC_CTRL_22		0x3022
-
-#define OV2722_AEC_PK_EXPO_H			0x3500
-#define OV2722_AEC_PK_EXPO_M			0x3501
-#define OV2722_AEC_PK_EXPO_L			0x3502
-#define OV2722_AEC_MANUAL_CTRL			0x3503
-#define OV2722_AGC_ADJ_H			0x3508
-#define OV2722_AGC_ADJ_L			0x3509
-#define OV2722_VTS_DIFF_H			0x350c
-#define OV2722_VTS_DIFF_L			0x350d
-#define OV2722_GROUP_ACCESS			0x3208
-#define OV2722_HTS_H				0x380c
-#define OV2722_HTS_L				0x380d
-#define OV2722_VTS_H				0x380e
-#define OV2722_VTS_L				0x380f
-
-#define OV2722_MWB_GAIN_R_H			0x5186
-#define OV2722_MWB_GAIN_R_L			0x5187
-#define OV2722_MWB_GAIN_G_H			0x5188
-#define OV2722_MWB_GAIN_G_L			0x5189
-#define OV2722_MWB_GAIN_B_H			0x518a
-#define OV2722_MWB_GAIN_B_L			0x518b
-
-#define OV2722_H_CROP_START_H			0x3800
-#define OV2722_H_CROP_START_L			0x3801
-#define OV2722_V_CROP_START_H			0x3802
-#define OV2722_V_CROP_START_L			0x3803
-#define OV2722_H_CROP_END_H			0x3804
-#define OV2722_H_CROP_END_L			0x3805
-#define OV2722_V_CROP_END_H			0x3806
-#define OV2722_V_CROP_END_L			0x3807
-#define OV2722_H_OUTSIZE_H			0x3808
-#define OV2722_H_OUTSIZE_L			0x3809
-#define OV2722_V_OUTSIZE_H			0x380a
-#define OV2722_V_OUTSIZE_L			0x380b
-
-#define OV2722_START_STREAMING			0x01
-#define OV2722_STOP_STREAMING			0x00
-
-struct regval_list {
-	u16 reg_num;
-	u8 value;
-};
-
-struct ov2722_resolution {
-	u8 *desc;
-	const struct ov2722_reg *regs;
-	int res;
-	int width;
-	int height;
-	int fps;
-	int pix_clk_freq;
-	u32 skip_frames;
-	u16 pixels_per_line;
-	u16 lines_per_frame;
-	u8 bin_factor_x;
-	u8 bin_factor_y;
-	u8 bin_mode;
-	bool used;
-	int mipi_freq;
-};
-
-struct ov2722_format {
-	u8 *desc;
-	u32 pixelformat;
-	struct ov2722_reg *regs;
-};
-
-/*
- * ov2722 device structure.
- */
-struct ov2722_device {
-	struct v4l2_subdev sd;
-	struct media_pad pad;
-	struct v4l2_mbus_framefmt format;
-	struct mutex input_lock;
-
-	struct camera_sensor_platform_data *platform_data;
-	int vt_pix_clk_freq_mhz;
-	int fmt_idx;
-	int run_mode;
-	u16 pixels_per_line;
-	u16 lines_per_frame;
-	u8 res;
-	u8 type;
-
-	struct v4l2_ctrl_handler ctrl_handler;
-	struct v4l2_ctrl *link_freq;
-};
-
-enum ov2722_tok_type {
-	OV2722_8BIT  = 0x0001,
-	OV2722_16BIT = 0x0002,
-	OV2722_32BIT = 0x0004,
-	OV2722_TOK_TERM   = 0xf000,	/* terminating token for reg list */
-	OV2722_TOK_DELAY  = 0xfe00,	/* delay token for reg list */
-	OV2722_TOK_MASK = 0xfff0
-};
-
-/**
- * struct ov2722_reg - MI sensor  register format
- * @type: type of the register
- * @reg: 16-bit offset to register
- * @val: 8/16/32-bit register value
- *
- * Define a structure for sensor register initialization values
- */
-struct ov2722_reg {
-	enum ov2722_tok_type type;
-	u16 reg;
-	u32 val;	/* @set value for read/mod/write, @mask */
-};
-
-#define to_ov2722_sensor(x) container_of(x, struct ov2722_device, sd)
-
-#define OV2722_MAX_WRITE_BUF_SIZE	30
-
-struct ov2722_write_buffer {
-	u16 addr;
-	u8 data[OV2722_MAX_WRITE_BUF_SIZE];
-};
-
-struct ov2722_write_ctrl {
-	int index;
-	struct ov2722_write_buffer buffer;
-};
-
-/*
- * Register settings for various resolution
- */
-#if 0
-static struct ov2722_reg const ov2722_QVGA_30fps[] = {
-	{OV2722_8BIT, 0x3718, 0x10},
-	{OV2722_8BIT, 0x3702, 0x0c},
-	{OV2722_8BIT, 0x373a, 0x1c},
-	{OV2722_8BIT, 0x3715, 0x01},
-	{OV2722_8BIT, 0x3703, 0x0c},
-	{OV2722_8BIT, 0x3705, 0x06},
-	{OV2722_8BIT, 0x3730, 0x0e},
-	{OV2722_8BIT, 0x3704, 0x1c},
-	{OV2722_8BIT, 0x3f06, 0x00},
-	{OV2722_8BIT, 0x371c, 0x00},
-	{OV2722_8BIT, 0x371d, 0x46},
-	{OV2722_8BIT, 0x371e, 0x00},
-	{OV2722_8BIT, 0x371f, 0x63},
-	{OV2722_8BIT, 0x3708, 0x61},
-	{OV2722_8BIT, 0x3709, 0x12},
-	{OV2722_8BIT, 0x3800, 0x01},
-	{OV2722_8BIT, 0x3801, 0x42}, /* H crop start: 322 */
-	{OV2722_8BIT, 0x3802, 0x00},
-	{OV2722_8BIT, 0x3803, 0x20}, /* V crop start: 32 */
-	{OV2722_8BIT, 0x3804, 0x06},
-	{OV2722_8BIT, 0x3805, 0x95}, /* H crop end:  1685 */
-	{OV2722_8BIT, 0x3806, 0x04},
-	{OV2722_8BIT, 0x3807, 0x27}, /* V crop end:  1063 */
-	{OV2722_8BIT, 0x3808, 0x01},
-	{OV2722_8BIT, 0x3809, 0x50}, /* H output size: 336 */
-	{OV2722_8BIT, 0x380a, 0x01},
-	{OV2722_8BIT, 0x380b, 0x00}, /* V output size: 256 */
-
-	/* H blank timing */
-	{OV2722_8BIT, 0x380c, 0x08},
-	{OV2722_8BIT, 0x380d, 0x00}, /* H total size: 2048 */
-	{OV2722_8BIT, 0x380e, 0x04},
-	{OV2722_8BIT, 0x380f, 0xa0}, /* V total size: 1184 */
-	{OV2722_8BIT, 0x3810, 0x00},
-	{OV2722_8BIT, 0x3811, 0x04}, /* H window offset: 5 */
-	{OV2722_8BIT, 0x3812, 0x00},
-	{OV2722_8BIT, 0x3813, 0x01}, /* V window offset: 2 */
-	{OV2722_8BIT, 0x3820, 0xc0},
-	{OV2722_8BIT, 0x3821, 0x06}, /* flip isp*/
-	{OV2722_8BIT, 0x3814, 0x71},
-	{OV2722_8BIT, 0x3815, 0x71},
-	{OV2722_8BIT, 0x3612, 0x49},
-	{OV2722_8BIT, 0x3618, 0x00},
-	{OV2722_8BIT, 0x3a08, 0x01},
-	{OV2722_8BIT, 0x3a09, 0xc3},
-	{OV2722_8BIT, 0x3a0a, 0x01},
-	{OV2722_8BIT, 0x3a0b, 0x77},
-	{OV2722_8BIT, 0x3a0d, 0x00},
-	{OV2722_8BIT, 0x3a0e, 0x00},
-	{OV2722_8BIT, 0x4520, 0x09},
-	{OV2722_8BIT, 0x4837, 0x1b},
-	{OV2722_8BIT, 0x3000, 0xff},
-	{OV2722_8BIT, 0x3001, 0xff},
-	{OV2722_8BIT, 0x3002, 0xf0},
-	{OV2722_8BIT, 0x3600, 0x08},
-	{OV2722_8BIT, 0x3621, 0xc0},
-	{OV2722_8BIT, 0x3632, 0x53}, /* added for power opt */
-	{OV2722_8BIT, 0x3633, 0x63},
-	{OV2722_8BIT, 0x3634, 0x24},
-	{OV2722_8BIT, 0x3f01, 0x0c},
-	{OV2722_8BIT, 0x5001, 0xc1}, /* v_en, h_en, blc_en */
-	{OV2722_8BIT, 0x3614, 0xf0},
-	{OV2722_8BIT, 0x3630, 0x2d},
-	{OV2722_8BIT, 0x370b, 0x62},
-	{OV2722_8BIT, 0x3706, 0x61},
-	{OV2722_8BIT, 0x4000, 0x02},
-	{OV2722_8BIT, 0x4002, 0xc5},
-	{OV2722_8BIT, 0x4005, 0x08},
-	{OV2722_8BIT, 0x404f, 0x84},
-	{OV2722_8BIT, 0x4051, 0x00},
-	{OV2722_8BIT, 0x5000, 0xff},
-	{OV2722_8BIT, 0x3a18, 0x00},
-	{OV2722_8BIT, 0x3a19, 0x80},
-	{OV2722_8BIT, 0x4521, 0x00},
-	{OV2722_8BIT, 0x5183, 0xb0}, /* AWB red */
-	{OV2722_8BIT, 0x5184, 0xb0}, /* AWB green */
-	{OV2722_8BIT, 0x5185, 0xb0}, /* AWB blue */
-	{OV2722_8BIT, 0x5180, 0x03}, /* AWB manual mode */
-	{OV2722_8BIT, 0x370c, 0x0c},
-	{OV2722_8BIT, 0x4800, 0x24}, /* clk lane gate enable */
-	{OV2722_8BIT, 0x3035, 0x00},
-	{OV2722_8BIT, 0x3036, 0x26},
-	{OV2722_8BIT, 0x3037, 0xa1},
-	{OV2722_8BIT, 0x303e, 0x19},
-	{OV2722_8BIT, 0x3038, 0x06},
-	{OV2722_8BIT, 0x3018, 0x04},
-
-	/* Added for power optimization */
-	{OV2722_8BIT, 0x3000, 0x00},
-	{OV2722_8BIT, 0x3001, 0x00},
-	{OV2722_8BIT, 0x3002, 0x00},
-	{OV2722_8BIT, 0x3a0f, 0x40},
-	{OV2722_8BIT, 0x3a10, 0x38},
-	{OV2722_8BIT, 0x3a1b, 0x48},
-	{OV2722_8BIT, 0x3a1e, 0x30},
-	{OV2722_8BIT, 0x3a11, 0x90},
-	{OV2722_8BIT, 0x3a1f, 0x10},
-	{OV2722_8BIT, 0x3011, 0x22},
-	{OV2722_8BIT, 0x3a00, 0x58},
-	{OV2722_8BIT, 0x3503, 0x17},
-	{OV2722_8BIT, 0x3500, 0x00},
-	{OV2722_8BIT, 0x3501, 0x46},
-	{OV2722_8BIT, 0x3502, 0x00},
-	{OV2722_8BIT, 0x3508, 0x00},
-	{OV2722_8BIT, 0x3509, 0x10},
-	{OV2722_TOK_TERM, 0, 0},
-
-};
-
-static struct ov2722_reg const ov2722_480P_30fps[] = {
-	{OV2722_8BIT, 0x3718, 0x10},
-	{OV2722_8BIT, 0x3702, 0x18},
-	{OV2722_8BIT, 0x373a, 0x3c},
-	{OV2722_8BIT, 0x3715, 0x01},
-	{OV2722_8BIT, 0x3703, 0x1d},
-	{OV2722_8BIT, 0x3705, 0x12},
-	{OV2722_8BIT, 0x3730, 0x1f},
-	{OV2722_8BIT, 0x3704, 0x3f},
-	{OV2722_8BIT, 0x3f06, 0x1d},
-	{OV2722_8BIT, 0x371c, 0x00},
-	{OV2722_8BIT, 0x371d, 0x83},
-	{OV2722_8BIT, 0x371e, 0x00},
-	{OV2722_8BIT, 0x371f, 0xbd},
-	{OV2722_8BIT, 0x3708, 0x63},
-	{OV2722_8BIT, 0x3709, 0x52},
-	{OV2722_8BIT, 0x3800, 0x00},
-	{OV2722_8BIT, 0x3801, 0xf2}, /* H crop start: 322 - 80 = 242*/
-	{OV2722_8BIT, 0x3802, 0x00},
-	{OV2722_8BIT, 0x3803, 0x20}, /* V crop start:  32*/
-	{OV2722_8BIT, 0x3804, 0x06},
-	{OV2722_8BIT, 0x3805, 0xBB}, /* H crop end:   1643 + 80 = 1723*/
-	{OV2722_8BIT, 0x3806, 0x04},
-	{OV2722_8BIT, 0x3807, 0x03}, /* V crop end:   1027*/
-	{OV2722_8BIT, 0x3808, 0x02},
-	{OV2722_8BIT, 0x3809, 0xE0}, /* H output size: 656 +80 = 736*/
-	{OV2722_8BIT, 0x380a, 0x01},
-	{OV2722_8BIT, 0x380b, 0xF0}, /* V output size: 496 */
-
-	/* H blank timing */
-	{OV2722_8BIT, 0x380c, 0x08},
-	{OV2722_8BIT, 0x380d, 0x00}, /* H total size: 2048 */
-	{OV2722_8BIT, 0x380e, 0x04},
-	{OV2722_8BIT, 0x380f, 0xa0}, /* V total size: 1184 */
-	{OV2722_8BIT, 0x3810, 0x00},
-	{OV2722_8BIT, 0x3811, 0x04}, /* H window offset: 5 */
-	{OV2722_8BIT, 0x3812, 0x00},
-	{OV2722_8BIT, 0x3813, 0x01}, /* V window offset: 2 */
-	{OV2722_8BIT, 0x3820, 0x80},
-	{OV2722_8BIT, 0x3821, 0x06}, /* flip isp*/
-	{OV2722_8BIT, 0x3814, 0x31},
-	{OV2722_8BIT, 0x3815, 0x31},
-	{OV2722_8BIT, 0x3612, 0x4b},
-	{OV2722_8BIT, 0x3618, 0x04},
-	{OV2722_8BIT, 0x3a08, 0x02},
-	{OV2722_8BIT, 0x3a09, 0x67},
-	{OV2722_8BIT, 0x3a0a, 0x02},
-	{OV2722_8BIT, 0x3a0b, 0x00},
-	{OV2722_8BIT, 0x3a0d, 0x00},
-	{OV2722_8BIT, 0x3a0e, 0x00},
-	{OV2722_8BIT, 0x4520, 0x0a},
-	{OV2722_8BIT, 0x4837, 0x1b},
-	{OV2722_8BIT, 0x3000, 0xff},
-	{OV2722_8BIT, 0x3001, 0xff},
-	{OV2722_8BIT, 0x3002, 0xf0},
-	{OV2722_8BIT, 0x3600, 0x08},
-	{OV2722_8BIT, 0x3621, 0xc0},
-	{OV2722_8BIT, 0x3632, 0x53}, /* added for power opt */
-	{OV2722_8BIT, 0x3633, 0x63},
-	{OV2722_8BIT, 0x3634, 0x24},
-	{OV2722_8BIT, 0x3f01, 0x0c},
-	{OV2722_8BIT, 0x5001, 0xc1}, /* v_en, h_en, blc_en */
-	{OV2722_8BIT, 0x3614, 0xf0},
-	{OV2722_8BIT, 0x3630, 0x2d},
-	{OV2722_8BIT, 0x370b, 0x62},
-	{OV2722_8BIT, 0x3706, 0x61},
-	{OV2722_8BIT, 0x4000, 0x02},
-	{OV2722_8BIT, 0x4002, 0xc5},
-	{OV2722_8BIT, 0x4005, 0x08},
-	{OV2722_8BIT, 0x404f, 0x84},
-	{OV2722_8BIT, 0x4051, 0x00},
-	{OV2722_8BIT, 0x5000, 0xff},
-	{OV2722_8BIT, 0x3a18, 0x00},
-	{OV2722_8BIT, 0x3a19, 0x80},
-	{OV2722_8BIT, 0x4521, 0x00},
-	{OV2722_8BIT, 0x5183, 0xb0}, /* AWB red */
-	{OV2722_8BIT, 0x5184, 0xb0}, /* AWB green */
-	{OV2722_8BIT, 0x5185, 0xb0}, /* AWB blue */
-	{OV2722_8BIT, 0x5180, 0x03}, /* AWB manual mode */
-	{OV2722_8BIT, 0x370c, 0x0c},
-	{OV2722_8BIT, 0x4800, 0x24}, /* clk lane gate enable */
-	{OV2722_8BIT, 0x3035, 0x00},
-	{OV2722_8BIT, 0x3036, 0x26},
-	{OV2722_8BIT, 0x3037, 0xa1},
-	{OV2722_8BIT, 0x303e, 0x19},
-	{OV2722_8BIT, 0x3038, 0x06},
-	{OV2722_8BIT, 0x3018, 0x04},
-
-	/* Added for power optimization */
-	{OV2722_8BIT, 0x3000, 0x00},
-	{OV2722_8BIT, 0x3001, 0x00},
-	{OV2722_8BIT, 0x3002, 0x00},
-	{OV2722_8BIT, 0x3a0f, 0x40},
-	{OV2722_8BIT, 0x3a10, 0x38},
-	{OV2722_8BIT, 0x3a1b, 0x48},
-	{OV2722_8BIT, 0x3a1e, 0x30},
-	{OV2722_8BIT, 0x3a11, 0x90},
-	{OV2722_8BIT, 0x3a1f, 0x10},
-	{OV2722_8BIT, 0x3011, 0x22},
-	{OV2722_8BIT, 0x3a00, 0x58},
-	{OV2722_8BIT, 0x3503, 0x17},
-	{OV2722_8BIT, 0x3500, 0x00},
-	{OV2722_8BIT, 0x3501, 0x46},
-	{OV2722_8BIT, 0x3502, 0x00},
-	{OV2722_8BIT, 0x3508, 0x00},
-	{OV2722_8BIT, 0x3509, 0x10},
-	{OV2722_TOK_TERM, 0, 0},
-};
-
-static struct ov2722_reg const ov2722_VGA_30fps[] = {
-	{OV2722_8BIT, 0x3718, 0x10},
-	{OV2722_8BIT, 0x3702, 0x18},
-	{OV2722_8BIT, 0x373a, 0x3c},
-	{OV2722_8BIT, 0x3715, 0x01},
-	{OV2722_8BIT, 0x3703, 0x1d},
-	{OV2722_8BIT, 0x3705, 0x12},
-	{OV2722_8BIT, 0x3730, 0x1f},
-	{OV2722_8BIT, 0x3704, 0x3f},
-	{OV2722_8BIT, 0x3f06, 0x1d},
-	{OV2722_8BIT, 0x371c, 0x00},
-	{OV2722_8BIT, 0x371d, 0x83},
-	{OV2722_8BIT, 0x371e, 0x00},
-	{OV2722_8BIT, 0x371f, 0xbd},
-	{OV2722_8BIT, 0x3708, 0x63},
-	{OV2722_8BIT, 0x3709, 0x52},
-	{OV2722_8BIT, 0x3800, 0x01},
-	{OV2722_8BIT, 0x3801, 0x42}, /* H crop start: 322 */
-	{OV2722_8BIT, 0x3802, 0x00},
-	{OV2722_8BIT, 0x3803, 0x20}, /* V crop start:  32*/
-	{OV2722_8BIT, 0x3804, 0x06},
-	{OV2722_8BIT, 0x3805, 0x6B}, /* H crop end:   1643*/
-	{OV2722_8BIT, 0x3806, 0x04},
-	{OV2722_8BIT, 0x3807, 0x03}, /* V crop end:   1027*/
-	{OV2722_8BIT, 0x3808, 0x02},
-	{OV2722_8BIT, 0x3809, 0x90}, /* H output size: 656 */
-	{OV2722_8BIT, 0x380a, 0x01},
-	{OV2722_8BIT, 0x380b, 0xF0}, /* V output size: 496 */
-
-	/* H blank timing */
-	{OV2722_8BIT, 0x380c, 0x08},
-	{OV2722_8BIT, 0x380d, 0x00}, /* H total size: 2048 */
-	{OV2722_8BIT, 0x380e, 0x04},
-	{OV2722_8BIT, 0x380f, 0xa0}, /* V total size: 1184 */
-	{OV2722_8BIT, 0x3810, 0x00},
-	{OV2722_8BIT, 0x3811, 0x04}, /* H window offset: 5 */
-	{OV2722_8BIT, 0x3812, 0x00},
-	{OV2722_8BIT, 0x3813, 0x01}, /* V window offset: 2 */
-	{OV2722_8BIT, 0x3820, 0x80},
-	{OV2722_8BIT, 0x3821, 0x06}, /* flip isp*/
-	{OV2722_8BIT, 0x3814, 0x31},
-	{OV2722_8BIT, 0x3815, 0x31},
-	{OV2722_8BIT, 0x3612, 0x4b},
-	{OV2722_8BIT, 0x3618, 0x04},
-	{OV2722_8BIT, 0x3a08, 0x02},
-	{OV2722_8BIT, 0x3a09, 0x67},
-	{OV2722_8BIT, 0x3a0a, 0x02},
-	{OV2722_8BIT, 0x3a0b, 0x00},
-	{OV2722_8BIT, 0x3a0d, 0x00},
-	{OV2722_8BIT, 0x3a0e, 0x00},
-	{OV2722_8BIT, 0x4520, 0x0a},
-	{OV2722_8BIT, 0x4837, 0x29},
-	{OV2722_8BIT, 0x3000, 0xff},
-	{OV2722_8BIT, 0x3001, 0xff},
-	{OV2722_8BIT, 0x3002, 0xf0},
-	{OV2722_8BIT, 0x3600, 0x08},
-	{OV2722_8BIT, 0x3621, 0xc0},
-	{OV2722_8BIT, 0x3632, 0x53}, /* added for power opt */
-	{OV2722_8BIT, 0x3633, 0x63},
-	{OV2722_8BIT, 0x3634, 0x24},
-	{OV2722_8BIT, 0x3f01, 0x0c},
-	{OV2722_8BIT, 0x5001, 0xc1}, /* v_en, h_en, blc_en */
-	{OV2722_8BIT, 0x3614, 0xf0},
-	{OV2722_8BIT, 0x3630, 0x2d},
-	{OV2722_8BIT, 0x370b, 0x62},
-	{OV2722_8BIT, 0x3706, 0x61},
-	{OV2722_8BIT, 0x4000, 0x02},
-	{OV2722_8BIT, 0x4002, 0xc5},
-	{OV2722_8BIT, 0x4005, 0x08},
-	{OV2722_8BIT, 0x404f, 0x84},
-	{OV2722_8BIT, 0x4051, 0x00},
-	{OV2722_8BIT, 0x5000, 0xff},
-	{OV2722_8BIT, 0x3a18, 0x00},
-	{OV2722_8BIT, 0x3a19, 0x80},
-	{OV2722_8BIT, 0x4521, 0x00},
-	{OV2722_8BIT, 0x5183, 0xb0}, /* AWB red */
-	{OV2722_8BIT, 0x5184, 0xb0}, /* AWB green */
-	{OV2722_8BIT, 0x5185, 0xb0}, /* AWB blue */
-	{OV2722_8BIT, 0x5180, 0x03}, /* AWB manual mode */
-	{OV2722_8BIT, 0x370c, 0x0c},
-	{OV2722_8BIT, 0x4800, 0x24}, /* clk lane gate enable */
-	{OV2722_8BIT, 0x3035, 0x00},
-	{OV2722_8BIT, 0x3036, 0x26},
-	{OV2722_8BIT, 0x3037, 0xa1},
-	{OV2722_8BIT, 0x303e, 0x19},
-	{OV2722_8BIT, 0x3038, 0x06},
-	{OV2722_8BIT, 0x3018, 0x04},
-
-	/* Added for power optimization */
-	{OV2722_8BIT, 0x3000, 0x00},
-	{OV2722_8BIT, 0x3001, 0x00},
-	{OV2722_8BIT, 0x3002, 0x00},
-	{OV2722_8BIT, 0x3a0f, 0x40},
-	{OV2722_8BIT, 0x3a10, 0x38},
-	{OV2722_8BIT, 0x3a1b, 0x48},
-	{OV2722_8BIT, 0x3a1e, 0x30},
-	{OV2722_8BIT, 0x3a11, 0x90},
-	{OV2722_8BIT, 0x3a1f, 0x10},
-	{OV2722_8BIT, 0x3011, 0x22},
-	{OV2722_8BIT, 0x3a00, 0x58},
-	{OV2722_8BIT, 0x3503, 0x17},
-	{OV2722_8BIT, 0x3500, 0x00},
-	{OV2722_8BIT, 0x3501, 0x46},
-	{OV2722_8BIT, 0x3502, 0x00},
-	{OV2722_8BIT, 0x3508, 0x00},
-	{OV2722_8BIT, 0x3509, 0x10},
-	{OV2722_TOK_TERM, 0, 0},
-};
-#endif
-
-static struct ov2722_reg const ov2722_1632_1092_30fps[] = {
-	{OV2722_8BIT, 0x3021, 0x03}, /* For stand wait for
-				a whole frame complete.(vblank) */
-	{OV2722_8BIT, 0x3718, 0x10},
-	{OV2722_8BIT, 0x3702, 0x24},
-	{OV2722_8BIT, 0x373a, 0x60},
-	{OV2722_8BIT, 0x3715, 0x01},
-	{OV2722_8BIT, 0x3703, 0x2e},
-	{OV2722_8BIT, 0x3705, 0x10},
-	{OV2722_8BIT, 0x3730, 0x30},
-	{OV2722_8BIT, 0x3704, 0x62},
-	{OV2722_8BIT, 0x3f06, 0x3a},
-	{OV2722_8BIT, 0x371c, 0x00},
-	{OV2722_8BIT, 0x371d, 0xc4},
-	{OV2722_8BIT, 0x371e, 0x01},
-	{OV2722_8BIT, 0x371f, 0x0d},
-	{OV2722_8BIT, 0x3708, 0x61},
-	{OV2722_8BIT, 0x3709, 0x12},
-	{OV2722_8BIT, 0x3800, 0x00},
-	{OV2722_8BIT, 0x3801, 0x9E}, /* H crop start: 158 */
-	{OV2722_8BIT, 0x3802, 0x00},
-	{OV2722_8BIT, 0x3803, 0x01}, /* V crop start: 1 */
-	{OV2722_8BIT, 0x3804, 0x07},
-	{OV2722_8BIT, 0x3805, 0x05}, /* H crop end: 1797 */
-	{OV2722_8BIT, 0x3806, 0x04},
-	{OV2722_8BIT, 0x3807, 0x45}, /* V crop end: 1093 */
-
-	{OV2722_8BIT, 0x3808, 0x06},
-	{OV2722_8BIT, 0x3809, 0x60}, /* H output size: 1632 */
-	{OV2722_8BIT, 0x380a, 0x04},
-	{OV2722_8BIT, 0x380b, 0x44}, /* V output size: 1092 */
-	{OV2722_8BIT, 0x380c, 0x08},
-	{OV2722_8BIT, 0x380d, 0xd4}, /* H timing: 2260 */
-	{OV2722_8BIT, 0x380e, 0x04},
-	{OV2722_8BIT, 0x380f, 0xdc}, /* V timing: 1244 */
-	{OV2722_8BIT, 0x3810, 0x00},
-	{OV2722_8BIT, 0x3811, 0x03}, /* H window offset: 3 */
-	{OV2722_8BIT, 0x3812, 0x00},
-	{OV2722_8BIT, 0x3813, 0x02}, /* V window offset: 2 */
-	{OV2722_8BIT, 0x3820, 0x80},
-	{OV2722_8BIT, 0x3821, 0x06}, /*  mirror */
-	{OV2722_8BIT, 0x3814, 0x11},
-	{OV2722_8BIT, 0x3815, 0x11},
-	{OV2722_8BIT, 0x3612, 0x0b},
-	{OV2722_8BIT, 0x3618, 0x04},
-	{OV2722_8BIT, 0x3a08, 0x01},
-	{OV2722_8BIT, 0x3a09, 0x50},
-	{OV2722_8BIT, 0x3a0a, 0x01},
-	{OV2722_8BIT, 0x3a0b, 0x18},
-	{OV2722_8BIT, 0x3a0d, 0x03},
-	{OV2722_8BIT, 0x3a0e, 0x03},
-	{OV2722_8BIT, 0x4520, 0x00},
-	{OV2722_8BIT, 0x4837, 0x1b},
-	{OV2722_8BIT, 0x3600, 0x08},
-	{OV2722_8BIT, 0x3621, 0xc0},
-	{OV2722_8BIT, 0x3632, 0xd2}, /* added for power opt */
-	{OV2722_8BIT, 0x3633, 0x23},
-	{OV2722_8BIT, 0x3634, 0x54},
-	{OV2722_8BIT, 0x3f01, 0x0c},
-	{OV2722_8BIT, 0x5001, 0xc1},
-	{OV2722_8BIT, 0x3614, 0xf0},
-	{OV2722_8BIT, 0x3630, 0x2d},
-	{OV2722_8BIT, 0x370b, 0x62},
-	{OV2722_8BIT, 0x3706, 0x61},
-	{OV2722_8BIT, 0x4000, 0x02},
-	{OV2722_8BIT, 0x4002, 0xc5},
-	{OV2722_8BIT, 0x4005, 0x08},
-	{OV2722_8BIT, 0x404f, 0x84},
-	{OV2722_8BIT, 0x4051, 0x00},
-	{OV2722_8BIT, 0x5000, 0xcf}, /* manual 3a */
-	{OV2722_8BIT, 0x301d, 0xf0}, /* enable group hold */
-	{OV2722_8BIT, 0x3a18, 0x00},
-	{OV2722_8BIT, 0x3a19, 0x80},
-	{OV2722_8BIT, 0x4521, 0x00},
-	{OV2722_8BIT, 0x5183, 0xb0},
-	{OV2722_8BIT, 0x5184, 0xb0},
-	{OV2722_8BIT, 0x5185, 0xb0},
-	{OV2722_8BIT, 0x370c, 0x0c},
-	{OV2722_8BIT, 0x3035, 0x00},
-	{OV2722_8BIT, 0x3036, 0x2c}, /* 422.4 MHz */
-	{OV2722_8BIT, 0x3037, 0xa1},
-	{OV2722_8BIT, 0x303e, 0x19},
-	{OV2722_8BIT, 0x3038, 0x06},
-	{OV2722_8BIT, 0x3018, 0x04},
-	{OV2722_8BIT, 0x3000, 0x00}, /* added for power optimization */
-	{OV2722_8BIT, 0x3001, 0x00},
-	{OV2722_8BIT, 0x3002, 0x00},
-	{OV2722_8BIT, 0x3a0f, 0x40},
-	{OV2722_8BIT, 0x3a10, 0x38},
-	{OV2722_8BIT, 0x3a1b, 0x48},
-	{OV2722_8BIT, 0x3a1e, 0x30},
-	{OV2722_8BIT, 0x3a11, 0x90},
-	{OV2722_8BIT, 0x3a1f, 0x10},
-	{OV2722_8BIT, 0x3503, 0x17}, /* manual 3a */
-	{OV2722_8BIT, 0x3500, 0x00},
-	{OV2722_8BIT, 0x3501, 0x3F},
-	{OV2722_8BIT, 0x3502, 0x00},
-	{OV2722_8BIT, 0x3508, 0x00},
-	{OV2722_8BIT, 0x3509, 0x00},
-	{OV2722_TOK_TERM, 0, 0}
-};
-
-static struct ov2722_reg const ov2722_1452_1092_30fps[] = {
-	{OV2722_8BIT, 0x3021, 0x03}, /* For stand wait for
-				a whole frame complete.(vblank) */
-	{OV2722_8BIT, 0x3718, 0x10},
-	{OV2722_8BIT, 0x3702, 0x24},
-	{OV2722_8BIT, 0x373a, 0x60},
-	{OV2722_8BIT, 0x3715, 0x01},
-	{OV2722_8BIT, 0x3703, 0x2e},
-	{OV2722_8BIT, 0x3705, 0x10},
-	{OV2722_8BIT, 0x3730, 0x30},
-	{OV2722_8BIT, 0x3704, 0x62},
-	{OV2722_8BIT, 0x3f06, 0x3a},
-	{OV2722_8BIT, 0x371c, 0x00},
-	{OV2722_8BIT, 0x371d, 0xc4},
-	{OV2722_8BIT, 0x371e, 0x01},
-	{OV2722_8BIT, 0x371f, 0x0d},
-	{OV2722_8BIT, 0x3708, 0x61},
-	{OV2722_8BIT, 0x3709, 0x12},
-	{OV2722_8BIT, 0x3800, 0x00},
-	{OV2722_8BIT, 0x3801, 0xF8}, /* H crop start: 248 */
-	{OV2722_8BIT, 0x3802, 0x00},
-	{OV2722_8BIT, 0x3803, 0x01}, /* V crop start: 1 */
-	{OV2722_8BIT, 0x3804, 0x06},
-	{OV2722_8BIT, 0x3805, 0xab}, /* H crop end: 1707 */
-	{OV2722_8BIT, 0x3806, 0x04},
-	{OV2722_8BIT, 0x3807, 0x45}, /* V crop end: 1093 */
-	{OV2722_8BIT, 0x3808, 0x05},
-	{OV2722_8BIT, 0x3809, 0xac}, /* H output size: 1452 */
-	{OV2722_8BIT, 0x380a, 0x04},
-	{OV2722_8BIT, 0x380b, 0x44}, /* V output size: 1092 */
-	{OV2722_8BIT, 0x380c, 0x08},
-	{OV2722_8BIT, 0x380d, 0xd4}, /* H timing: 2260 */
-	{OV2722_8BIT, 0x380e, 0x04},
-	{OV2722_8BIT, 0x380f, 0xdc}, /* V timing: 1244 */
-	{OV2722_8BIT, 0x3810, 0x00},
-	{OV2722_8BIT, 0x3811, 0x03}, /* H window offset: 3 */
-	{OV2722_8BIT, 0x3812, 0x00},
-	{OV2722_8BIT, 0x3813, 0x02}, /* V window offset: 2 */
-	{OV2722_8BIT, 0x3820, 0x80},
-	{OV2722_8BIT, 0x3821, 0x06}, /*  mirror */
-	{OV2722_8BIT, 0x3814, 0x11},
-	{OV2722_8BIT, 0x3815, 0x11},
-	{OV2722_8BIT, 0x3612, 0x0b},
-	{OV2722_8BIT, 0x3618, 0x04},
-	{OV2722_8BIT, 0x3a08, 0x01},
-	{OV2722_8BIT, 0x3a09, 0x50},
-	{OV2722_8BIT, 0x3a0a, 0x01},
-	{OV2722_8BIT, 0x3a0b, 0x18},
-	{OV2722_8BIT, 0x3a0d, 0x03},
-	{OV2722_8BIT, 0x3a0e, 0x03},
-	{OV2722_8BIT, 0x4520, 0x00},
-	{OV2722_8BIT, 0x4837, 0x1b},
-	{OV2722_8BIT, 0x3600, 0x08},
-	{OV2722_8BIT, 0x3621, 0xc0},
-	{OV2722_8BIT, 0x3632, 0xd2}, /* added for power opt */
-	{OV2722_8BIT, 0x3633, 0x23},
-	{OV2722_8BIT, 0x3634, 0x54},
-	{OV2722_8BIT, 0x3f01, 0x0c},
-	{OV2722_8BIT, 0x5001, 0xc1},
-	{OV2722_8BIT, 0x3614, 0xf0},
-	{OV2722_8BIT, 0x3630, 0x2d},
-	{OV2722_8BIT, 0x370b, 0x62},
-	{OV2722_8BIT, 0x3706, 0x61},
-	{OV2722_8BIT, 0x4000, 0x02},
-	{OV2722_8BIT, 0x4002, 0xc5},
-	{OV2722_8BIT, 0x4005, 0x08},
-	{OV2722_8BIT, 0x404f, 0x84},
-	{OV2722_8BIT, 0x4051, 0x00},
-	{OV2722_8BIT, 0x5000, 0xcf}, /* manual 3a */
-	{OV2722_8BIT, 0x301d, 0xf0}, /* enable group hold */
-	{OV2722_8BIT, 0x3a18, 0x00},
-	{OV2722_8BIT, 0x3a19, 0x80},
-	{OV2722_8BIT, 0x4521, 0x00},
-	{OV2722_8BIT, 0x5183, 0xb0},
-	{OV2722_8BIT, 0x5184, 0xb0},
-	{OV2722_8BIT, 0x5185, 0xb0},
-	{OV2722_8BIT, 0x370c, 0x0c},
-	{OV2722_8BIT, 0x3035, 0x00},
-	{OV2722_8BIT, 0x3036, 0x2c}, /* 422.4 MHz */
-	{OV2722_8BIT, 0x3037, 0xa1},
-	{OV2722_8BIT, 0x303e, 0x19},
-	{OV2722_8BIT, 0x3038, 0x06},
-	{OV2722_8BIT, 0x3018, 0x04},
-	{OV2722_8BIT, 0x3000, 0x00}, /* added for power optimization */
-	{OV2722_8BIT, 0x3001, 0x00},
-	{OV2722_8BIT, 0x3002, 0x00},
-	{OV2722_8BIT, 0x3a0f, 0x40},
-	{OV2722_8BIT, 0x3a10, 0x38},
-	{OV2722_8BIT, 0x3a1b, 0x48},
-	{OV2722_8BIT, 0x3a1e, 0x30},
-	{OV2722_8BIT, 0x3a11, 0x90},
-	{OV2722_8BIT, 0x3a1f, 0x10},
-	{OV2722_8BIT, 0x3503, 0x17}, /* manual 3a */
-	{OV2722_8BIT, 0x3500, 0x00},
-	{OV2722_8BIT, 0x3501, 0x3F},
-	{OV2722_8BIT, 0x3502, 0x00},
-	{OV2722_8BIT, 0x3508, 0x00},
-	{OV2722_8BIT, 0x3509, 0x00},
-	{OV2722_TOK_TERM, 0, 0}
-};
-#if 0
-static struct ov2722_reg const ov2722_1M3_30fps[] = {
-	{OV2722_8BIT, 0x3718, 0x10},
-	{OV2722_8BIT, 0x3702, 0x24},
-	{OV2722_8BIT, 0x373a, 0x60},
-	{OV2722_8BIT, 0x3715, 0x01},
-	{OV2722_8BIT, 0x3703, 0x2e},
-	{OV2722_8BIT, 0x3705, 0x10},
-	{OV2722_8BIT, 0x3730, 0x30},
-	{OV2722_8BIT, 0x3704, 0x62},
-	{OV2722_8BIT, 0x3f06, 0x3a},
-	{OV2722_8BIT, 0x371c, 0x00},
-	{OV2722_8BIT, 0x371d, 0xc4},
-	{OV2722_8BIT, 0x371e, 0x01},
-	{OV2722_8BIT, 0x371f, 0x0d},
-	{OV2722_8BIT, 0x3708, 0x61},
-	{OV2722_8BIT, 0x3709, 0x12},
-	{OV2722_8BIT, 0x3800, 0x01},
-	{OV2722_8BIT, 0x3801, 0x4a},	/* H crop start: 330 */
-	{OV2722_8BIT, 0x3802, 0x00},
-	{OV2722_8BIT, 0x3803, 0x03},	/* V crop start: 3 */
-	{OV2722_8BIT, 0x3804, 0x06},
-	{OV2722_8BIT, 0x3805, 0xe1},	/* H crop end:  1761 */
-	{OV2722_8BIT, 0x3806, 0x04},
-	{OV2722_8BIT, 0x3807, 0x47},	/* V crop end:  1095 */
-	{OV2722_8BIT, 0x3808, 0x05},
-	{OV2722_8BIT, 0x3809, 0x88},	/* H output size: 1416 */
-	{OV2722_8BIT, 0x380a, 0x04},
-	{OV2722_8BIT, 0x380b, 0x0a},	/* V output size: 1034 */
-
-	/* H blank timing */
-	{OV2722_8BIT, 0x380c, 0x08},
-	{OV2722_8BIT, 0x380d, 0x00},	/* H total size: 2048 */
-	{OV2722_8BIT, 0x380e, 0x04},
-	{OV2722_8BIT, 0x380f, 0xa0},	/* V total size: 1184 */
-	{OV2722_8BIT, 0x3810, 0x00},
-	{OV2722_8BIT, 0x3811, 0x05},	/* H window offset: 5 */
-	{OV2722_8BIT, 0x3812, 0x00},
-	{OV2722_8BIT, 0x3813, 0x02},	/* V window offset: 2 */
-	{OV2722_8BIT, 0x3820, 0x80},
-	{OV2722_8BIT, 0x3821, 0x06},	/* flip isp */
-	{OV2722_8BIT, 0x3814, 0x11},
-	{OV2722_8BIT, 0x3815, 0x11},
-	{OV2722_8BIT, 0x3612, 0x0b},
-	{OV2722_8BIT, 0x3618, 0x04},
-	{OV2722_8BIT, 0x3a08, 0x01},
-	{OV2722_8BIT, 0x3a09, 0x50},
-	{OV2722_8BIT, 0x3a0a, 0x01},
-	{OV2722_8BIT, 0x3a0b, 0x18},
-	{OV2722_8BIT, 0x3a0d, 0x03},
-	{OV2722_8BIT, 0x3a0e, 0x03},
-	{OV2722_8BIT, 0x4520, 0x00},
-	{OV2722_8BIT, 0x4837, 0x1b},
-	{OV2722_8BIT, 0x3000, 0xff},
-	{OV2722_8BIT, 0x3001, 0xff},
-	{OV2722_8BIT, 0x3002, 0xf0},
-	{OV2722_8BIT, 0x3600, 0x08},
-	{OV2722_8BIT, 0x3621, 0xc0},
-	{OV2722_8BIT, 0x3632, 0xd2},	/* added for power opt */
-	{OV2722_8BIT, 0x3633, 0x23},
-	{OV2722_8BIT, 0x3634, 0x54},
-	{OV2722_8BIT, 0x3f01, 0x0c},
-	{OV2722_8BIT, 0x5001, 0xc1},	/* v_en, h_en, blc_en */
-	{OV2722_8BIT, 0x3614, 0xf0},
-	{OV2722_8BIT, 0x3630, 0x2d},
-	{OV2722_8BIT, 0x370b, 0x62},
-	{OV2722_8BIT, 0x3706, 0x61},
-	{OV2722_8BIT, 0x4000, 0x02},
-	{OV2722_8BIT, 0x4002, 0xc5},
-	{OV2722_8BIT, 0x4005, 0x08},
-	{OV2722_8BIT, 0x404f, 0x84},
-	{OV2722_8BIT, 0x4051, 0x00},
-	{OV2722_8BIT, 0x5000, 0xcf},
-	{OV2722_8BIT, 0x3a18, 0x00},
-	{OV2722_8BIT, 0x3a19, 0x80},
-	{OV2722_8BIT, 0x4521, 0x00},
-	{OV2722_8BIT, 0x5183, 0xb0},	/* AWB red */
-	{OV2722_8BIT, 0x5184, 0xb0},	/* AWB green */
-	{OV2722_8BIT, 0x5185, 0xb0},	/* AWB blue */
-	{OV2722_8BIT, 0x5180, 0x03},	/* AWB manual mode */
-	{OV2722_8BIT, 0x370c, 0x0c},
-	{OV2722_8BIT, 0x4800, 0x24},	/* clk lane gate enable */
-	{OV2722_8BIT, 0x3035, 0x00},
-	{OV2722_8BIT, 0x3036, 0x26},
-	{OV2722_8BIT, 0x3037, 0xa1},
-	{OV2722_8BIT, 0x303e, 0x19},
-	{OV2722_8BIT, 0x3038, 0x06},
-	{OV2722_8BIT, 0x3018, 0x04},
-
-	/* Added for power optimization */
-	{OV2722_8BIT, 0x3000, 0x00},
-	{OV2722_8BIT, 0x3001, 0x00},
-	{OV2722_8BIT, 0x3002, 0x00},
-	{OV2722_8BIT, 0x3a0f, 0x40},
-	{OV2722_8BIT, 0x3a10, 0x38},
-	{OV2722_8BIT, 0x3a1b, 0x48},
-	{OV2722_8BIT, 0x3a1e, 0x30},
-	{OV2722_8BIT, 0x3a11, 0x90},
-	{OV2722_8BIT, 0x3a1f, 0x10},
-	{OV2722_8BIT, 0x3503, 0x17},
-	{OV2722_8BIT, 0x3500, 0x00},
-	{OV2722_8BIT, 0x3501, 0x46},
-	{OV2722_8BIT, 0x3502, 0x00},
-	{OV2722_8BIT, 0x3508, 0x00},
-	{OV2722_8BIT, 0x3509, 0x10},
-	{OV2722_TOK_TERM, 0, 0},
-};
-#endif
-
-static struct ov2722_reg const ov2722_1080p_30fps[] = {
-	{OV2722_8BIT, 0x3021, 0x03}, /* For stand wait for a whole
-					frame complete.(vblank) */
-	{OV2722_8BIT, 0x3718, 0x10},
-	{OV2722_8BIT, 0x3702, 0x24},
-	{OV2722_8BIT, 0x373a, 0x60},
-	{OV2722_8BIT, 0x3715, 0x01},
-	{OV2722_8BIT, 0x3703, 0x2e},
-	{OV2722_8BIT, 0x3705, 0x2b},
-	{OV2722_8BIT, 0x3730, 0x30},
-	{OV2722_8BIT, 0x3704, 0x62},
-	{OV2722_8BIT, 0x3f06, 0x3a},
-	{OV2722_8BIT, 0x371c, 0x00},
-	{OV2722_8BIT, 0x371d, 0xc4},
-	{OV2722_8BIT, 0x371e, 0x01},
-	{OV2722_8BIT, 0x371f, 0x28},
-	{OV2722_8BIT, 0x3708, 0x61},
-	{OV2722_8BIT, 0x3709, 0x12},
-	{OV2722_8BIT, 0x3800, 0x00},
-	{OV2722_8BIT, 0x3801, 0x08}, /* H crop start: 8 */
-	{OV2722_8BIT, 0x3802, 0x00},
-	{OV2722_8BIT, 0x3803, 0x01}, /* V crop start: 1 */
-	{OV2722_8BIT, 0x3804, 0x07},
-	{OV2722_8BIT, 0x3805, 0x9b}, /* H crop end: 1947 */
-	{OV2722_8BIT, 0x3806, 0x04},
-	{OV2722_8BIT, 0x3807, 0x45}, /* V crop end: 1093 */
-	{OV2722_8BIT, 0x3808, 0x07},
-	{OV2722_8BIT, 0x3809, 0x8c}, /* H output size: 1932 */
-	{OV2722_8BIT, 0x380a, 0x04},
-	{OV2722_8BIT, 0x380b, 0x44}, /* V output size: 1092 */
-	{OV2722_8BIT, 0x380c, 0x08},
-	{OV2722_8BIT, 0x380d, 0x14}, /* H timing: 2068 */
-	{OV2722_8BIT, 0x380e, 0x04},
-	{OV2722_8BIT, 0x380f, 0x5a}, /* V timing: 1114 */
-	{OV2722_8BIT, 0x3810, 0x00},
-	{OV2722_8BIT, 0x3811, 0x03}, /* H window offset: 3 */
-	{OV2722_8BIT, 0x3812, 0x00},
-	{OV2722_8BIT, 0x3813, 0x02}, /* V window offset: 2 */
-	{OV2722_8BIT, 0x3820, 0x80},
-	{OV2722_8BIT, 0x3821, 0x06}, /*  mirror */
-	{OV2722_8BIT, 0x3814, 0x11},
-	{OV2722_8BIT, 0x3815, 0x11},
-	{OV2722_8BIT, 0x3612, 0x4b},
-	{OV2722_8BIT, 0x3618, 0x04},
-	{OV2722_8BIT, 0x3a08, 0x01},
-	{OV2722_8BIT, 0x3a09, 0x50},
-	{OV2722_8BIT, 0x3a0a, 0x01},
-	{OV2722_8BIT, 0x3a0b, 0x18},
-	{OV2722_8BIT, 0x3a0d, 0x03},
-	{OV2722_8BIT, 0x3a0e, 0x03},
-	{OV2722_8BIT, 0x4520, 0x00},
-	{OV2722_8BIT, 0x4837, 0x1b},
-	{OV2722_8BIT, 0x3000, 0xff},
-	{OV2722_8BIT, 0x3001, 0xff},
-	{OV2722_8BIT, 0x3002, 0xf0},
-	{OV2722_8BIT, 0x3600, 0x08},
-	{OV2722_8BIT, 0x3621, 0xc0},
-	{OV2722_8BIT, 0x3632, 0x53}, /* added for power opt */
-	{OV2722_8BIT, 0x3633, 0x63},
-	{OV2722_8BIT, 0x3634, 0x24},
-	{OV2722_8BIT, 0x3f01, 0x0c},
-	{OV2722_8BIT, 0x5001, 0xc1},
-	{OV2722_8BIT, 0x3614, 0xf0},
-	{OV2722_8BIT, 0x3630, 0x2d},
-	{OV2722_8BIT, 0x370b, 0x62},
-	{OV2722_8BIT, 0x3706, 0x61},
-	{OV2722_8BIT, 0x4000, 0x02},
-	{OV2722_8BIT, 0x4002, 0xc5},
-	{OV2722_8BIT, 0x4005, 0x08},
-	{OV2722_8BIT, 0x404f, 0x84},
-	{OV2722_8BIT, 0x4051, 0x00},
-	{OV2722_8BIT, 0x5000, 0xcd}, /* manual 3a */
-	{OV2722_8BIT, 0x301d, 0xf0}, /* enable group hold */
-	{OV2722_8BIT, 0x3a18, 0x00},
-	{OV2722_8BIT, 0x3a19, 0x80},
-	{OV2722_8BIT, 0x3503, 0x17},
-	{OV2722_8BIT, 0x4521, 0x00},
-	{OV2722_8BIT, 0x5183, 0xb0},
-	{OV2722_8BIT, 0x5184, 0xb0},
-	{OV2722_8BIT, 0x5185, 0xb0},
-	{OV2722_8BIT, 0x370c, 0x0c},
-	{OV2722_8BIT, 0x3035, 0x00},
-	{OV2722_8BIT, 0x3036, 0x24}, /* 345.6 MHz */
-	{OV2722_8BIT, 0x3037, 0xa1},
-	{OV2722_8BIT, 0x303e, 0x19},
-	{OV2722_8BIT, 0x3038, 0x06},
-	{OV2722_8BIT, 0x3018, 0x04},
-	{OV2722_8BIT, 0x3000, 0x00}, /* added for power optimization */
-	{OV2722_8BIT, 0x3001, 0x00},
-	{OV2722_8BIT, 0x3002, 0x00},
-	{OV2722_8BIT, 0x3a0f, 0x40},
-	{OV2722_8BIT, 0x3a10, 0x38},
-	{OV2722_8BIT, 0x3a1b, 0x48},
-	{OV2722_8BIT, 0x3a1e, 0x30},
-	{OV2722_8BIT, 0x3a11, 0x90},
-	{OV2722_8BIT, 0x3a1f, 0x10},
-	{OV2722_8BIT, 0x3011, 0x22},
-	{OV2722_8BIT, 0x3500, 0x00},
-	{OV2722_8BIT, 0x3501, 0x3F},
-	{OV2722_8BIT, 0x3502, 0x00},
-	{OV2722_8BIT, 0x3508, 0x00},
-	{OV2722_8BIT, 0x3509, 0x00},
-	{OV2722_TOK_TERM, 0, 0}
-};
-
-#if 0 /* Currently unused */
-static struct ov2722_reg const ov2722_720p_30fps[] = {
-	{OV2722_8BIT, 0x3021, 0x03},
-	{OV2722_8BIT, 0x3718, 0x10},
-	{OV2722_8BIT, 0x3702, 0x24},
-	{OV2722_8BIT, 0x373a, 0x60},
-	{OV2722_8BIT, 0x3715, 0x01},
-	{OV2722_8BIT, 0x3703, 0x2e},
-	{OV2722_8BIT, 0x3705, 0x10},
-	{OV2722_8BIT, 0x3730, 0x30},
-	{OV2722_8BIT, 0x3704, 0x62},
-	{OV2722_8BIT, 0x3f06, 0x3a},
-	{OV2722_8BIT, 0x371c, 0x00},
-	{OV2722_8BIT, 0x371d, 0xc4},
-	{OV2722_8BIT, 0x371e, 0x01},
-	{OV2722_8BIT, 0x371f, 0x0d},
-	{OV2722_8BIT, 0x3708, 0x61},
-	{OV2722_8BIT, 0x3709, 0x12},
-	{OV2722_8BIT, 0x3800, 0x01},
-	{OV2722_8BIT, 0x3801, 0x40}, /* H crop start: 320 */
-	{OV2722_8BIT, 0x3802, 0x00},
-	{OV2722_8BIT, 0x3803, 0xb1}, /* V crop start: 177 */
-	{OV2722_8BIT, 0x3804, 0x06},
-	{OV2722_8BIT, 0x3805, 0x55}, /* H crop end: 1621 */
-	{OV2722_8BIT, 0x3806, 0x03},
-	{OV2722_8BIT, 0x3807, 0x95}, /* V crop end: 918 */
-	{OV2722_8BIT, 0x3808, 0x05},
-	{OV2722_8BIT, 0x3809, 0x10}, /* H output size: 0x0788==1928 */
-	{OV2722_8BIT, 0x380a, 0x02},
-	{OV2722_8BIT, 0x380b, 0xe0}, /* output size: 0x02DE==734 */
-	{OV2722_8BIT, 0x380c, 0x08},
-	{OV2722_8BIT, 0x380d, 0x00}, /* H timing: 2048 */
-	{OV2722_8BIT, 0x380e, 0x04},
-	{OV2722_8BIT, 0x380f, 0xa3}, /* V timing: 1187 */
-	{OV2722_8BIT, 0x3810, 0x00},
-	{OV2722_8BIT, 0x3811, 0x03}, /* H window offset: 3 */
-	{OV2722_8BIT, 0x3812, 0x00},
-	{OV2722_8BIT, 0x3813, 0x02}, /* V window offset: 2 */
-	{OV2722_8BIT, 0x3820, 0x80},
-	{OV2722_8BIT, 0x3821, 0x06}, /* mirror */
-	{OV2722_8BIT, 0x3814, 0x11},
-	{OV2722_8BIT, 0x3815, 0x11},
-	{OV2722_8BIT, 0x3612, 0x0b},
-	{OV2722_8BIT, 0x3618, 0x04},
-	{OV2722_8BIT, 0x3a08, 0x01},
-	{OV2722_8BIT, 0x3a09, 0x50},
-	{OV2722_8BIT, 0x3a0a, 0x01},
-	{OV2722_8BIT, 0x3a0b, 0x18},
-	{OV2722_8BIT, 0x3a0d, 0x03},
-	{OV2722_8BIT, 0x3a0e, 0x03},
-	{OV2722_8BIT, 0x4520, 0x00},
-	{OV2722_8BIT, 0x4837, 0x1b},
-	{OV2722_8BIT, 0x3600, 0x08},
-	{OV2722_8BIT, 0x3621, 0xc0},
-	{OV2722_8BIT, 0x3632, 0xd2}, /* added for power opt */
-	{OV2722_8BIT, 0x3633, 0x23},
-	{OV2722_8BIT, 0x3634, 0x54},
-	{OV2722_8BIT, 0x3f01, 0x0c},
-	{OV2722_8BIT, 0x5001, 0xc1},
-	{OV2722_8BIT, 0x3614, 0xf0},
-	{OV2722_8BIT, 0x3630, 0x2d},
-	{OV2722_8BIT, 0x370b, 0x62},
-	{OV2722_8BIT, 0x3706, 0x61},
-	{OV2722_8BIT, 0x4000, 0x02},
-	{OV2722_8BIT, 0x4002, 0xc5},
-	{OV2722_8BIT, 0x4005, 0x08},
-	{OV2722_8BIT, 0x404f, 0x84},
-	{OV2722_8BIT, 0x4051, 0x00},
-	{OV2722_8BIT, 0x5000, 0xcf}, /* manual 3a */
-	{OV2722_8BIT, 0x301d, 0xf0}, /* enable group hold */
-	{OV2722_8BIT, 0x3a18, 0x00},
-	{OV2722_8BIT, 0x3a19, 0x80},
-	{OV2722_8BIT, 0x4521, 0x00},
-	{OV2722_8BIT, 0x5183, 0xb0},
-	{OV2722_8BIT, 0x5184, 0xb0},
-	{OV2722_8BIT, 0x5185, 0xb0},
-	{OV2722_8BIT, 0x370c, 0x0c},
-	{OV2722_8BIT, 0x3035, 0x00},
-	{OV2722_8BIT, 0x3036, 0x26}, /* {0x3036, 0x2c}, //422.4 MHz */
-	{OV2722_8BIT, 0x3037, 0xa1},
-	{OV2722_8BIT, 0x303e, 0x19},
-	{OV2722_8BIT, 0x3038, 0x06},
-	{OV2722_8BIT, 0x3018, 0x04},
-	{OV2722_8BIT, 0x3000, 0x00}, /* added for power optimization */
-	{OV2722_8BIT, 0x3001, 0x00},
-	{OV2722_8BIT, 0x3002, 0x00},
-	{OV2722_8BIT, 0x3a0f, 0x40},
-	{OV2722_8BIT, 0x3a10, 0x38},
-	{OV2722_8BIT, 0x3a1b, 0x48},
-	{OV2722_8BIT, 0x3a1e, 0x30},
-	{OV2722_8BIT, 0x3a11, 0x90},
-	{OV2722_8BIT, 0x3a1f, 0x10},
-	{OV2722_8BIT, 0x3503, 0x17}, /* manual 3a */
-	{OV2722_8BIT, 0x3500, 0x00},
-	{OV2722_8BIT, 0x3501, 0x3F},
-	{OV2722_8BIT, 0x3502, 0x00},
-	{OV2722_8BIT, 0x3508, 0x00},
-	{OV2722_8BIT, 0x3509, 0x00},
-	{OV2722_TOK_TERM, 0, 0},
-};
-#endif
-
-static struct ov2722_resolution ov2722_res_preview[] = {
-	{
-		.desc = "ov2722_1632_1092_30fps",
-		.width = 1632,
-		.height = 1092,
-		.fps = 30,
-		.pix_clk_freq = 85,
-		.used = 0,
-		.pixels_per_line = 2260,
-		.lines_per_frame = 1244,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = ov2722_1632_1092_30fps,
-		.mipi_freq = 422400,
-	},
-	{
-		.desc = "ov2722_1452_1092_30fps",
-		.width = 1452,
-		.height = 1092,
-		.fps = 30,
-		.pix_clk_freq = 85,
-		.used = 0,
-		.pixels_per_line = 2260,
-		.lines_per_frame = 1244,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = ov2722_1452_1092_30fps,
-		.mipi_freq = 422400,
-	},
-	{
-		.desc = "ov2722_1080P_30fps",
-		.width = 1932,
-		.height = 1092,
-		.pix_clk_freq = 69,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2068,
-		.lines_per_frame = 1114,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = ov2722_1080p_30fps,
-		.mipi_freq = 345600,
-	},
-};
-#define N_RES_PREVIEW (ARRAY_SIZE(ov2722_res_preview))
-
-/*
- * Disable non-preview configurations until the configuration selection is
- * improved.
- */
-#if 0
-struct ov2722_resolution ov2722_res_still[] = {
-	{
-		.desc = "ov2722_480P_30fps",
-		.width = 1632,
-		.height = 1092,
-		.fps = 30,
-		.pix_clk_freq = 85,
-		.used = 0,
-		.pixels_per_line = 2260,
-		.lines_per_frame = 1244,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = ov2722_1632_1092_30fps,
-		.mipi_freq = 422400,
-	},
-	{
-		.desc = "ov2722_1452_1092_30fps",
-		.width = 1452,
-		.height = 1092,
-		.fps = 30,
-		.pix_clk_freq = 85,
-		.used = 0,
-		.pixels_per_line = 2260,
-		.lines_per_frame = 1244,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = ov2722_1452_1092_30fps,
-		.mipi_freq = 422400,
-	},
-	{
-		.desc = "ov2722_1080P_30fps",
-		.width = 1932,
-		.height = 1092,
-		.pix_clk_freq = 69,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2068,
-		.lines_per_frame = 1114,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = ov2722_1080p_30fps,
-		.mipi_freq = 345600,
-	},
-};
-#define N_RES_STILL (ARRAY_SIZE(ov2722_res_still))
-
-struct ov2722_resolution ov2722_res_video[] = {
-	{
-		.desc = "ov2722_QVGA_30fps",
-		.width = 336,
-		.height = 256,
-		.fps = 30,
-		.pix_clk_freq = 73,
-		.used = 0,
-		.pixels_per_line = 2048,
-		.lines_per_frame = 1184,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = ov2722_QVGA_30fps,
-		.mipi_freq = 364800,
-	},
-	{
-		.desc = "ov2722_480P_30fps",
-		.width = 736,
-		.height = 496,
-		.fps = 30,
-		.pix_clk_freq = 73,
-		.used = 0,
-		.pixels_per_line = 2048,
-		.lines_per_frame = 1184,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = ov2722_480P_30fps,
-	},
-	{
-		.desc = "ov2722_1080P_30fps",
-		.width = 1932,
-		.height = 1092,
-		.pix_clk_freq = 69,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2068,
-		.lines_per_frame = 1114,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.skip_frames = 3,
-		.regs = ov2722_1080p_30fps,
-		.mipi_freq = 345600,
-	},
-};
-#define N_RES_VIDEO (ARRAY_SIZE(ov2722_res_video))
-#endif
-
-static struct ov2722_resolution *ov2722_res = ov2722_res_preview;
-static unsigned long N_RES = N_RES_PREVIEW;
-#endif

+ 0 - 11
drivers/staging/media/atomisp/i2c/ov5693/Kconfig

@@ -1,11 +0,0 @@
-config VIDEO_ATOMISP_OV5693
-       tristate "Omnivision ov5693 sensor support"
-	depends on ACPI
-       depends on I2C && VIDEO_V4L2
-       ---help---
-	 This is a Video4Linux2 sensor-level driver for the Micron
-	 ov5693 5 Mpixel camera.
-
-	 ov5693 is video camera sensor.
-
-	 It currently only works with the atomisp driver.

+ 0 - 2
drivers/staging/media/atomisp/i2c/ov5693/Makefile

@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_VIDEO_ATOMISP_OV5693) += atomisp-ov5693.o

+ 0 - 63
drivers/staging/media/atomisp/i2c/ov5693/ad5823.h

@@ -1,63 +0,0 @@
-/*
- * Support for AD5823 VCM.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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 __AD5823_H__
-#define __AD5823_H__
-
-#include <linux/types.h>
-
-
-#define AD5823_VCM_ADDR	0x0c
-
-#define AD5823_REG_RESET		0x01
-#define AD5823_REG_MODE			0x02
-#define AD5823_REG_VCM_MOVE_TIME	0x03
-#define AD5823_REG_VCM_CODE_MSB		0x04
-#define AD5823_REG_VCM_CODE_LSB		0x05
-#define AD5823_REG_VCM_THRESHOLD_MSB	0x06
-#define AD5823_REG_VCM_THRESHOLD_LSB	0x07
-
-#define AD5823_REG_LENGTH		0x1
-
-#define AD5823_RING_CTRL_ENABLE		0x04
-#define AD5823_RING_CTRL_DISABLE	0x00
-
-#define AD5823_RESONANCE_PERIOD		100000
-#define AD5823_RESONANCE_COEF		512
-#define AD5823_HIGH_FREQ_RANGE		0x80
-
-#define VCM_CODE_MSB_MASK		0xfc
-#define AD5823_INIT_FOCUS_POS           350
-
-enum ad5823_tok_type {
-	AD5823_8BIT  = 0x1,
-	AD5823_16BIT = 0x2,
-};
-
-enum ad5823_vcm_mode {
-	AD5823_ARC_RES0 = 0x0,	/* Actuator response control RES1 */
-	AD5823_ARC_RES1 = 0x1,	/* Actuator response control RES0.5 */
-	AD5823_ARC_RES2 = 0x2,	/* Actuator response control RES2 */
-	AD5823_ESRC = 0x3,	/* Enhanced slew rate control */
-	AD5823_DIRECT = 0x4,	/* Direct control */
-};
-
-#define AD5823_INVALID_CONFIG	0xffffffff
-#define AD5823_MAX_FOCUS_POS	1023
-#define DELAY_PER_STEP_NS	1000000
-#define DELAY_MAX_PER_STEP_NS	(1000000 * 1023)
-#endif

+ 0 - 1993
drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c

@@ -1,1993 +0,0 @@
-/*
- * Support for OmniVision OV5693 1080p HD camera sensor.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- *
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/kmod.h>
-#include <linux/device.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/i2c.h>
-#include <linux/moduleparam.h>
-#include <media/v4l2-device.h>
-#include <linux/io.h>
-#include <linux/acpi.h>
-#include "../../include/linux/atomisp_gmin_platform.h"
-
-#include "ov5693.h"
-#include "ad5823.h"
-
-#define __cci_delay(t) \
-	do { \
-		if ((t) < 10) { \
-			usleep_range((t) * 1000, ((t) + 1) * 1000); \
-		} else { \
-			msleep((t)); \
-		} \
-	} while (0)
-
-/* Value 30ms reached through experimentation on byt ecs.
- * The DS specifies a much lower value but when using a smaller value
- * the I2C bus sometimes locks up permanently when starting the camera.
- * This issue could not be reproduced on cht, so we can reduce the
- * delay value to a lower value when insmod.
- */
-static uint up_delay = 30;
-module_param(up_delay, uint, 0644);
-MODULE_PARM_DESC(up_delay, "Delay prior to the first CCI transaction for ov5693");
-
-static int vcm_ad_i2c_wr8(struct i2c_client *client, u8 reg, u8 val)
-{
-	int err;
-	struct i2c_msg msg;
-	u8 buf[2];
-
-	buf[0] = reg;
-	buf[1] = val;
-
-	msg.addr = VCM_ADDR;
-	msg.flags = 0;
-	msg.len = 2;
-	msg.buf = &buf[0];
-
-	err = i2c_transfer(client->adapter, &msg, 1);
-	if (err != 1) {
-		dev_err(&client->dev, "%s: vcm i2c fail, err code = %d\n",
-			__func__, err);
-		return -EIO;
-	}
-	return 0;
-}
-
-static int ad5823_i2c_write(struct i2c_client *client, u8 reg, u8 val)
-{
-	struct i2c_msg msg;
-	u8 buf[2];
-
-	buf[0] = reg;
-	buf[1] = val;
-	msg.addr = AD5823_VCM_ADDR;
-	msg.flags = 0;
-	msg.len = 0x02;
-	msg.buf = &buf[0];
-
-	if (i2c_transfer(client->adapter, &msg, 1) != 1)
-		return -EIO;
-	return 0;
-}
-
-static int ad5823_i2c_read(struct i2c_client *client, u8 reg, u8 *val)
-{
-	struct i2c_msg msg[2];
-	u8 buf[2];
-
-	buf[0] = reg;
-	buf[1] = 0;
-
-	msg[0].addr = AD5823_VCM_ADDR;
-	msg[0].flags = 0;
-	msg[0].len = 0x01;
-	msg[0].buf = &buf[0];
-
-	msg[1].addr = 0x0c;
-	msg[1].flags = I2C_M_RD;
-	msg[1].len = 0x01;
-	msg[1].buf = &buf[1];
-	*val = 0;
-	if (i2c_transfer(client->adapter, msg, 2) != 2)
-		return -EIO;
-	*val = buf[1];
-	return 0;
-}
-
-
-static const uint32_t ov5693_embedded_effective_size = 28;
-
-/* i2c read/write stuff */
-static int ov5693_read_reg(struct i2c_client *client,
-			   u16 data_length, u16 reg, u16 *val)
-{
-	int err;
-	struct i2c_msg msg[2];
-	unsigned char data[6];
-
-	if (!client->adapter) {
-		dev_err(&client->dev, "%s error, no client->adapter\n",
-			__func__);
-		return -ENODEV;
-	}
-
-	if (data_length != OV5693_8BIT && data_length != OV5693_16BIT
-					&& data_length != OV5693_32BIT) {
-		dev_err(&client->dev, "%s error, invalid data length\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	memset(msg, 0, sizeof(msg));
-
-	msg[0].addr = client->addr;
-	msg[0].flags = 0;
-	msg[0].len = I2C_MSG_LENGTH;
-	msg[0].buf = data;
-
-	/* high byte goes out first */
-	data[0] = (u8)(reg >> 8);
-	data[1] = (u8)(reg & 0xff);
-
-	msg[1].addr = client->addr;
-	msg[1].len = data_length;
-	msg[1].flags = I2C_M_RD;
-	msg[1].buf = data;
-
-	err = i2c_transfer(client->adapter, msg, 2);
-	if (err != 2) {
-		if (err >= 0)
-			err = -EIO;
-		dev_err(&client->dev,
-			"read from offset 0x%x error %d", reg, err);
-		return err;
-	}
-
-	*val = 0;
-	/* high byte comes first */
-	if (data_length == OV5693_8BIT)
-		*val = (u8)data[0];
-	else if (data_length == OV5693_16BIT)
-		*val = be16_to_cpu(*(__be16 *)&data[0]);
-	else
-		*val = be32_to_cpu(*(__be32 *)&data[0]);
-
-	return 0;
-}
-
-static int ov5693_i2c_write(struct i2c_client *client, u16 len, u8 *data)
-{
-	struct i2c_msg msg;
-	const int num_msg = 1;
-	int ret;
-
-	msg.addr = client->addr;
-	msg.flags = 0;
-	msg.len = len;
-	msg.buf = data;
-	ret = i2c_transfer(client->adapter, &msg, 1);
-
-	return ret == num_msg ? 0 : -EIO;
-}
-
-static int vcm_dw_i2c_write(struct i2c_client *client, u16 data)
-{
-	struct i2c_msg msg;
-	const int num_msg = 1;
-	int ret;
-	__be16 val;
-
-	val = cpu_to_be16(data);
-	msg.addr = VCM_ADDR;
-	msg.flags = 0;
-	msg.len = OV5693_16BIT;
-	msg.buf = (void *)&val;
-
-	ret = i2c_transfer(client->adapter, &msg, 1);
-
-	return ret == num_msg ? 0 : -EIO;
-}
-
-/*
- * Theory: per datasheet, the two VCMs both allow for a 2-byte read.
- * The DW9714 doesn't actually specify what this does (it has a
- * two-byte write-only protocol, but specifies the read sequence as
- * legal), but it returns the same data (zeroes) always, after an
- * undocumented initial NAK.  The AD5823 has a one-byte address
- * register to which all writes go, and subsequent reads will cycle
- * through the 8 bytes of registers.  Notably, the default values (the
- * device is always power-cycled affirmatively, so we can rely on
- * these) in AD5823 are not pairwise repetitions of the same 16 bit
- * word.  So all we have to do is sequentially read two bytes at a
- * time and see if we detect a difference in any of the first four
- * pairs.
- */
-static int vcm_detect(struct i2c_client *client)
-{
-	int i, ret;
-	struct i2c_msg msg;
-	u16 data0 = 0, data;
-
-	for (i = 0; i < 4; i++) {
-		msg.addr = VCM_ADDR;
-		msg.flags = I2C_M_RD;
-		msg.len = sizeof(data);
-		msg.buf = (u8 *)&data;
-		ret = i2c_transfer(client->adapter, &msg, 1);
-
-		/*
-		 * DW9714 always fails the first read and returns
-		 * zeroes for subsequent ones
-		 */
-		if (i == 0 && ret == -EREMOTEIO) {
-			data0 = 0;
-			continue;
-		}
-
-		if (i == 0)
-			data0 = data;
-
-		if (data != data0)
-			return VCM_AD5823;
-	}
-	return ret == 1 ? VCM_DW9714 : ret;
-}
-
-static int ov5693_write_reg(struct i2c_client *client, u16 data_length,
-							u16 reg, u16 val)
-{
-	int ret;
-	unsigned char data[4] = {0};
-	__be16 *wreg = (void *)data;
-	const u16 len = data_length + sizeof(u16); /* 16-bit address + data */
-
-	if (data_length != OV5693_8BIT && data_length != OV5693_16BIT) {
-		dev_err(&client->dev,
-			"%s error, invalid data_length\n", __func__);
-		return -EINVAL;
-	}
-
-	/* high byte goes out first */
-	*wreg = cpu_to_be16(reg);
-
-	if (data_length == OV5693_8BIT) {
-		data[2] = (u8)(val);
-	} else {
-		/* OV5693_16BIT */
-		__be16 *wdata = (void *)&data[2];
-
-		*wdata = cpu_to_be16(val);
-	}
-
-	ret = ov5693_i2c_write(client, len, data);
-	if (ret)
-		dev_err(&client->dev,
-			"write error: wrote 0x%x to offset 0x%x error %d",
-			val, reg, ret);
-
-	return ret;
-}
-
-/*
- * ov5693_write_reg_array - Initializes a list of OV5693 registers
- * @client: i2c driver client structure
- * @reglist: list of registers to be written
- *
- * This function initializes a list of registers. When consecutive addresses
- * are found in a row on the list, this function creates a buffer and sends
- * consecutive data in a single i2c_transfer().
- *
- * __ov5693_flush_reg_array, __ov5693_buf_reg_array() and
- * __ov5693_write_reg_is_consecutive() are internal functions to
- * ov5693_write_reg_array_fast() and should be not used anywhere else.
- *
- */
-
-static int __ov5693_flush_reg_array(struct i2c_client *client,
-				    struct ov5693_write_ctrl *ctrl)
-{
-	u16 size;
-	__be16 *reg = (void *)&ctrl->buffer.addr;
-
-	if (ctrl->index == 0)
-		return 0;
-
-	size = sizeof(u16) + ctrl->index; /* 16-bit address + data */
-
-	*reg = cpu_to_be16(ctrl->buffer.addr);
-	ctrl->index = 0;
-
-	return ov5693_i2c_write(client, size, (u8 *)reg);
-}
-
-static int __ov5693_buf_reg_array(struct i2c_client *client,
-				  struct ov5693_write_ctrl *ctrl,
-				  const struct ov5693_reg *next)
-{
-	int size;
-	__be16 *data16;
-
-	switch (next->type) {
-	case OV5693_8BIT:
-		size = 1;
-		ctrl->buffer.data[ctrl->index] = (u8)next->val;
-		break;
-	case OV5693_16BIT:
-		size = 2;
-
-		data16 = (void *)&ctrl->buffer.data[ctrl->index];
-		*data16 = cpu_to_be16((u16)next->val);
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	/* When first item is added, we need to store its starting address */
-	if (ctrl->index == 0)
-		ctrl->buffer.addr = next->reg;
-
-	ctrl->index += size;
-
-	/*
-	 * Buffer cannot guarantee free space for u32? Better flush it to avoid
-	 * possible lack of memory for next item.
-	 */
-	if (ctrl->index + sizeof(u16) >= OV5693_MAX_WRITE_BUF_SIZE)
-		return __ov5693_flush_reg_array(client, ctrl);
-
-	return 0;
-}
-
-static int __ov5693_write_reg_is_consecutive(struct i2c_client *client,
-					     struct ov5693_write_ctrl *ctrl,
-					     const struct ov5693_reg *next)
-{
-	if (ctrl->index == 0)
-		return 1;
-
-	return ctrl->buffer.addr + ctrl->index == next->reg;
-}
-
-static int ov5693_write_reg_array(struct i2c_client *client,
-				  const struct ov5693_reg *reglist)
-{
-	const struct ov5693_reg *next = reglist;
-	struct ov5693_write_ctrl ctrl;
-	int err;
-
-	ctrl.index = 0;
-	for (; next->type != OV5693_TOK_TERM; next++) {
-		switch (next->type & OV5693_TOK_MASK) {
-		case OV5693_TOK_DELAY:
-			err = __ov5693_flush_reg_array(client, &ctrl);
-			if (err)
-				return err;
-			msleep(next->val);
-			break;
-		default:
-			/*
-			 * If next address is not consecutive, data needs to be
-			 * flushed before proceed.
-			 */
-			if (!__ov5693_write_reg_is_consecutive(client, &ctrl,
-								next)) {
-				err = __ov5693_flush_reg_array(client, &ctrl);
-				if (err)
-					return err;
-			}
-			err = __ov5693_buf_reg_array(client, &ctrl, next);
-			if (err) {
-				dev_err(&client->dev,
-					"%s: write error, aborted\n",
-					__func__);
-				return err;
-			}
-			break;
-		}
-	}
-
-	return __ov5693_flush_reg_array(client, &ctrl);
-}
-static int ov5693_g_focal(struct v4l2_subdev *sd, s32 *val)
-{
-	*val = (OV5693_FOCAL_LENGTH_NUM << 16) | OV5693_FOCAL_LENGTH_DEM;
-	return 0;
-}
-
-static int ov5693_g_fnumber(struct v4l2_subdev *sd, s32 *val)
-{
-	/*const f number for imx*/
-	*val = (OV5693_F_NUMBER_DEFAULT_NUM << 16) | OV5693_F_NUMBER_DEM;
-	return 0;
-}
-
-static int ov5693_g_fnumber_range(struct v4l2_subdev *sd, s32 *val)
-{
-	*val = (OV5693_F_NUMBER_DEFAULT_NUM << 24) |
-		(OV5693_F_NUMBER_DEM << 16) |
-		(OV5693_F_NUMBER_DEFAULT_NUM << 8) | OV5693_F_NUMBER_DEM;
-	return 0;
-}
-
-static int ov5693_g_bin_factor_x(struct v4l2_subdev *sd, s32 *val)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-
-	*val = ov5693_res[dev->fmt_idx].bin_factor_x;
-
-	return 0;
-}
-
-static int ov5693_g_bin_factor_y(struct v4l2_subdev *sd, s32 *val)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-
-	*val = ov5693_res[dev->fmt_idx].bin_factor_y;
-
-	return 0;
-}
-
-static int ov5693_get_intg_factor(struct i2c_client *client,
-				struct camera_mipi_info *info,
-				const struct ov5693_resolution *res)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	struct atomisp_sensor_mode_data *buf = &info->data;
-	unsigned int pix_clk_freq_hz;
-	u16 reg_val;
-	int ret;
-
-	if (info == NULL)
-		return -EINVAL;
-
-	/* pixel clock */
-	pix_clk_freq_hz = res->pix_clk_freq * 1000000;
-
-	dev->vt_pix_clk_freq_mhz = pix_clk_freq_hz;
-	buf->vt_pix_clk_freq_mhz = pix_clk_freq_hz;
-
-	/* get integration time */
-	buf->coarse_integration_time_min = OV5693_COARSE_INTG_TIME_MIN;
-	buf->coarse_integration_time_max_margin =
-					OV5693_COARSE_INTG_TIME_MAX_MARGIN;
-
-	buf->fine_integration_time_min = OV5693_FINE_INTG_TIME_MIN;
-	buf->fine_integration_time_max_margin =
-					OV5693_FINE_INTG_TIME_MAX_MARGIN;
-
-	buf->fine_integration_time_def = OV5693_FINE_INTG_TIME_MIN;
-	buf->frame_length_lines = res->lines_per_frame;
-	buf->line_length_pck = res->pixels_per_line;
-	buf->read_mode = res->bin_mode;
-
-	/* get the cropping and output resolution to ISP for this mode. */
-	ret =  ov5693_read_reg(client, OV5693_16BIT,
-					OV5693_HORIZONTAL_START_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_horizontal_start = reg_val;
-
-	ret =  ov5693_read_reg(client, OV5693_16BIT,
-					OV5693_VERTICAL_START_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_vertical_start = reg_val;
-
-	ret = ov5693_read_reg(client, OV5693_16BIT,
-					OV5693_HORIZONTAL_END_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_horizontal_end = reg_val;
-
-	ret = ov5693_read_reg(client, OV5693_16BIT,
-					OV5693_VERTICAL_END_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->crop_vertical_end = reg_val;
-
-	ret = ov5693_read_reg(client, OV5693_16BIT,
-				OV5693_HORIZONTAL_OUTPUT_SIZE_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->output_width = reg_val;
-
-	ret = ov5693_read_reg(client, OV5693_16BIT,
-				OV5693_VERTICAL_OUTPUT_SIZE_H, &reg_val);
-	if (ret)
-		return ret;
-	buf->output_height = reg_val;
-
-	buf->binning_factor_x = res->bin_factor_x ?
-					res->bin_factor_x : 1;
-	buf->binning_factor_y = res->bin_factor_y ?
-					res->bin_factor_y : 1;
-	return 0;
-}
-
-static long __ov5693_set_exposure(struct v4l2_subdev *sd, int coarse_itg,
-				 int gain, int digitgain)
-
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	u16 vts, hts;
-	int ret, exp_val;
-
-	hts = ov5693_res[dev->fmt_idx].pixels_per_line;
-	vts = ov5693_res[dev->fmt_idx].lines_per_frame;
-	/*
-	 * If coarse_itg is larger than 1<<15, can not write to reg directly.
-	 * The way is to write coarse_itg/2 to the reg, meanwhile write 2*hts
-	 * to the reg.
-	 */
-	if (coarse_itg > (1 << 15)) {
-		hts = hts * 2;
-		coarse_itg = (int)coarse_itg / 2;
-	}
-	/* group hold */
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-				OV5693_GROUP_ACCESS, 0x00);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV5693_GROUP_ACCESS);
-		return ret;
-	}
-
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-				OV5693_TIMING_HTS_H, (hts >> 8) & 0xFF);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV5693_TIMING_HTS_H);
-		return ret;
-	}
-
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-				OV5693_TIMING_HTS_L, hts & 0xFF);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV5693_TIMING_HTS_L);
-		return ret;
-	}
-	/* Increase the VTS to match exposure + MARGIN */
-	if (coarse_itg > vts - OV5693_INTEGRATION_TIME_MARGIN)
-		vts = (u16) coarse_itg + OV5693_INTEGRATION_TIME_MARGIN;
-
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-				OV5693_TIMING_VTS_H, (vts >> 8) & 0xFF);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV5693_TIMING_VTS_H);
-		return ret;
-	}
-
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-					OV5693_TIMING_VTS_L, vts & 0xFF);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV5693_TIMING_VTS_L);
-		return ret;
-	}
-
-	/* set exposure */
-
-	/* Lower four bit should be 0*/
-	exp_val = coarse_itg << 4;
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-			       OV5693_EXPOSURE_L, exp_val & 0xFF);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV5693_EXPOSURE_L);
-		return ret;
-	}
-
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-			       OV5693_EXPOSURE_M, (exp_val >> 8) & 0xFF);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV5693_EXPOSURE_M);
-		return ret;
-	}
-
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-			       OV5693_EXPOSURE_H, (exp_val >> 16) & 0x0F);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV5693_EXPOSURE_H);
-		return ret;
-	}
-
-	/* Analog gain */
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-				OV5693_AGC_L, gain & 0xff);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV5693_AGC_L);
-		return ret;
-	}
-
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-				OV5693_AGC_H, (gain >> 8) & 0xff);
-	if (ret) {
-		dev_err(&client->dev, "%s: write %x error, aborted\n",
-			__func__, OV5693_AGC_H);
-		return ret;
-	}
-
-	/* Digital gain */
-	if (digitgain) {
-		ret = ov5693_write_reg(client, OV5693_16BIT,
-				OV5693_MWB_RED_GAIN_H, digitgain);
-		if (ret) {
-			dev_err(&client->dev, "%s: write %x error, aborted\n",
-				__func__, OV5693_MWB_RED_GAIN_H);
-			return ret;
-		}
-
-		ret = ov5693_write_reg(client, OV5693_16BIT,
-				OV5693_MWB_GREEN_GAIN_H, digitgain);
-		if (ret) {
-			dev_err(&client->dev, "%s: write %x error, aborted\n",
-				__func__, OV5693_MWB_RED_GAIN_H);
-			return ret;
-		}
-
-		ret = ov5693_write_reg(client, OV5693_16BIT,
-				OV5693_MWB_BLUE_GAIN_H, digitgain);
-		if (ret) {
-			dev_err(&client->dev, "%s: write %x error, aborted\n",
-				__func__, OV5693_MWB_RED_GAIN_H);
-			return ret;
-		}
-	}
-
-	/* End group */
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-				OV5693_GROUP_ACCESS, 0x10);
-	if (ret)
-		return ret;
-
-	/* Delay launch group */
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-				OV5693_GROUP_ACCESS, 0xa0);
-	if (ret)
-		return ret;
-	return ret;
-}
-
-static int ov5693_set_exposure(struct v4l2_subdev *sd, int exposure,
-	int gain, int digitgain)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	int ret;
-
-	mutex_lock(&dev->input_lock);
-	ret = __ov5693_set_exposure(sd, exposure, gain, digitgain);
-	mutex_unlock(&dev->input_lock);
-
-	return ret;
-}
-
-static long ov5693_s_exposure(struct v4l2_subdev *sd,
-			       struct atomisp_exposure *exposure)
-{
-	u16 coarse_itg = exposure->integration_time[0];
-	u16 analog_gain = exposure->gain[0];
-	u16 digital_gain = exposure->gain[1];
-
-	/* we should not accept the invalid value below */
-	if (analog_gain == 0) {
-		struct i2c_client *client = v4l2_get_subdevdata(sd);
-
-		v4l2_err(client, "%s: invalid value\n", __func__);
-		return -EINVAL;
-	}
-	return ov5693_set_exposure(sd, coarse_itg, analog_gain, digital_gain);
-}
-
-static int ov5693_read_otp_reg_array(struct i2c_client *client, u16 size,
-				     u16 addr, u8 *buf)
-{
-	u16 index;
-	int ret;
-	u16 *pVal = NULL;
-
-	for (index = 0; index <= size; index++) {
-		pVal = (u16 *) (buf + index);
-		ret =
-			ov5693_read_reg(client, OV5693_8BIT, addr + index,
-				    pVal);
-		if (ret)
-			return ret;
-	}
-
-	return 0;
-}
-
-static int __ov5693_otp_read(struct v4l2_subdev *sd, u8 *buf)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	int ret;
-	int i;
-	u8 *b = buf;
-
-	dev->otp_size = 0;
-	for (i = 1; i < OV5693_OTP_BANK_MAX; i++) {
-		/*set bank NO and OTP read mode. */
-		ret = ov5693_write_reg(client, OV5693_8BIT, OV5693_OTP_BANK_REG, (i | 0xc0));	//[7:6] 2'b11 [5:0] bank no
-		if (ret) {
-			dev_err(&client->dev, "failed to prepare OTP page\n");
-			return ret;
-		}
-		//pr_debug("write 0x%x->0x%x\n",OV5693_OTP_BANK_REG,(i|0xc0));
-
-		/*enable read */
-		ret = ov5693_write_reg(client, OV5693_8BIT, OV5693_OTP_READ_REG, OV5693_OTP_MODE_READ);	// enable :1
-		if (ret) {
-			dev_err(&client->dev,
-				"failed to set OTP reading mode page");
-			return ret;
-		}
-		//pr_debug("write 0x%x->0x%x\n",OV5693_OTP_READ_REG,OV5693_OTP_MODE_READ);
-
-		/* Reading the OTP data array */
-		ret = ov5693_read_otp_reg_array(client, OV5693_OTP_BANK_SIZE,
-						OV5693_OTP_START_ADDR,
-						b);
-		if (ret) {
-			dev_err(&client->dev, "failed to read OTP data\n");
-			return ret;
-		}
-
-		//pr_debug("BANK[%2d] %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", i, *b, *(b+1), *(b+2), *(b+3), *(b+4), *(b+5), *(b+6), *(b+7), *(b+8), *(b+9), *(b+10), *(b+11), *(b+12), *(b+13), *(b+14), *(b+15));
-
-		//Intel OTP map, try to read 320byts first.
-		if (i == 21) {
-			if ((*b) == 0) {
-				dev->otp_size = 320;
-				break;
-			} else {
-				b = buf;
-				continue;
-			}
-		} else if (i == 24) {		//if the first 320bytes data doesn't not exist, try to read the next 32bytes data.
-			if ((*b) == 0) {
-				dev->otp_size = 32;
-				break;
-			} else {
-				b = buf;
-				continue;
-			}
-		} else if (i == 27) {		//if the prvious 32bytes data doesn't exist, try to read the next 32bytes data again.
-			if ((*b) == 0) {
-				dev->otp_size = 32;
-				break;
-			} else {
-				dev->otp_size = 0;	// no OTP data.
-				break;
-			}
-		}
-
-		b = b + OV5693_OTP_BANK_SIZE;
-	}
-	return 0;
-}
-
-/*
- * Read otp data and store it into a kmalloced buffer.
- * The caller must kfree the buffer when no more needed.
- * @size: set to the size of the returned otp data.
- */
-static void *ov5693_otp_read(struct v4l2_subdev *sd)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	u8 *buf;
-	int ret;
-
-	buf = devm_kzalloc(&client->dev, (OV5693_OTP_DATA_SIZE + 16), GFP_KERNEL);
-	if (!buf)
-		return ERR_PTR(-ENOMEM);
-
-	//otp valid after mipi on and sw stream on
-	ret = ov5693_write_reg(client, OV5693_8BIT, OV5693_FRAME_OFF_NUM, 0x00);
-
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-			       OV5693_SW_STREAM, OV5693_START_STREAMING);
-
-	ret = __ov5693_otp_read(sd, buf);
-
-	//mipi off and sw stream off after otp read
-	ret = ov5693_write_reg(client, OV5693_8BIT, OV5693_FRAME_OFF_NUM, 0x0f);
-
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-			       OV5693_SW_STREAM, OV5693_STOP_STREAMING);
-
-	/* Driver has failed to find valid data */
-	if (ret) {
-		dev_err(&client->dev, "sensor found no valid OTP data\n");
-		return ERR_PTR(ret);
-	}
-
-	return buf;
-}
-
-static int ov5693_g_priv_int_data(struct v4l2_subdev *sd,
-				  struct v4l2_private_int_data *priv)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	u8 __user *to = priv->data;
-	u32 read_size = priv->size;
-	int ret;
-
-	/* No need to copy data if size is 0 */
-	if (!read_size)
-		goto out;
-
-	if (IS_ERR(dev->otp_data)) {
-		dev_err(&client->dev, "OTP data not available");
-		return PTR_ERR(dev->otp_data);
-	}
-
-	/* Correct read_size value only if bigger than maximum */
-	if (read_size > OV5693_OTP_DATA_SIZE)
-		read_size = OV5693_OTP_DATA_SIZE;
-
-	ret = copy_to_user(to, dev->otp_data, read_size);
-	if (ret) {
-		dev_err(&client->dev, "%s: failed to copy OTP data to user\n",
-			__func__);
-		return -EFAULT;
-	}
-
-	pr_debug("%s read_size:%d\n", __func__, read_size);
-
-out:
-	/* Return correct size */
-	priv->size = dev->otp_size;
-
-	return 0;
-
-}
-
-static long ov5693_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
-{
-
-	switch (cmd) {
-	case ATOMISP_IOC_S_EXPOSURE:
-		return ov5693_s_exposure(sd, arg);
-	case ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA:
-		return ov5693_g_priv_int_data(sd, arg);
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
-
-/*
- * This returns the exposure time being used. This should only be used
- * for filling in EXIF data, not for actual image processing.
- */
-static int ov5693_q_exposure(struct v4l2_subdev *sd, s32 *value)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	u16 reg_v, reg_v2;
-	int ret;
-
-	/* get exposure */
-	ret = ov5693_read_reg(client, OV5693_8BIT,
-					OV5693_EXPOSURE_L,
-					&reg_v);
-	if (ret)
-		goto err;
-
-	ret = ov5693_read_reg(client, OV5693_8BIT,
-					OV5693_EXPOSURE_M,
-					&reg_v2);
-	if (ret)
-		goto err;
-
-	reg_v += reg_v2 << 8;
-	ret = ov5693_read_reg(client, OV5693_8BIT,
-					OV5693_EXPOSURE_H,
-					&reg_v2);
-	if (ret)
-		goto err;
-
-	*value = reg_v + (((u32)reg_v2 << 16));
-err:
-	return ret;
-}
-
-static int ad5823_t_focus_vcm(struct v4l2_subdev *sd, u16 val)
-{
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = -EINVAL;
-	u8 vcm_code;
-
-	ret = ad5823_i2c_read(client, AD5823_REG_VCM_CODE_MSB, &vcm_code);
-	if (ret)
-		return ret;
-
-	/* set reg VCM_CODE_MSB Bit[1:0] */
-	vcm_code = (vcm_code & VCM_CODE_MSB_MASK) |
-		((val >> 8) & ~VCM_CODE_MSB_MASK);
-	ret = ad5823_i2c_write(client, AD5823_REG_VCM_CODE_MSB, vcm_code);
-	if (ret)
-		return ret;
-
-	/* set reg VCM_CODE_LSB Bit[7:0] */
-	ret = ad5823_i2c_write(client, AD5823_REG_VCM_CODE_LSB, (val & 0xff));
-	if (ret)
-		return ret;
-
-	/* set required vcm move time */
-	vcm_code = AD5823_RESONANCE_PERIOD / AD5823_RESONANCE_COEF
-		- AD5823_HIGH_FREQ_RANGE;
-	ret = ad5823_i2c_write(client, AD5823_REG_VCM_MOVE_TIME, vcm_code);
-
-	return ret;
-}
-
-static int ad5823_t_focus_abs(struct v4l2_subdev *sd, s32 value)
-{
-	value = min(value, AD5823_MAX_FOCUS_POS);
-	return ad5823_t_focus_vcm(sd, value);
-}
-
-static int ov5693_t_focus_abs(struct v4l2_subdev *sd, s32 value)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	dev_dbg(&client->dev, "%s: FOCUS_POS: 0x%x\n", __func__, value);
-	value = clamp(value, 0, OV5693_VCM_MAX_FOCUS_POS);
-	if (dev->vcm == VCM_DW9714) {
-		if (dev->vcm_update) {
-			ret = vcm_dw_i2c_write(client, VCM_PROTECTION_OFF);
-			if (ret)
-				return ret;
-			ret = vcm_dw_i2c_write(client, DIRECT_VCM);
-			if (ret)
-				return ret;
-			ret = vcm_dw_i2c_write(client, VCM_PROTECTION_ON);
-			if (ret)
-				return ret;
-			dev->vcm_update = false;
-		}
-		ret = vcm_dw_i2c_write(client,
-				       vcm_val(value, VCM_DEFAULT_S));
-	} else if (dev->vcm == VCM_AD5823) {
-		ad5823_t_focus_abs(sd, value);
-	}
-	if (ret == 0) {
-		dev->number_of_steps = value - dev->focus;
-		dev->focus = value;
-		dev->timestamp_t_focus_abs = ktime_get();
-	} else
-		dev_err(&client->dev,
-			"%s: i2c failed. ret %d\n", __func__, ret);
-
-	return ret;
-}
-
-static int ov5693_t_focus_rel(struct v4l2_subdev *sd, s32 value)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-
-	return ov5693_t_focus_abs(sd, dev->focus + value);
-}
-
-#define DELAY_PER_STEP_NS	1000000
-#define DELAY_MAX_PER_STEP_NS	(1000000 * 1023)
-static int ov5693_q_focus_status(struct v4l2_subdev *sd, s32 *value)
-{
-	u32 status = 0;
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	ktime_t temptime;
-	ktime_t timedelay = ns_to_ktime(min_t(u32,
-			abs(dev->number_of_steps) * DELAY_PER_STEP_NS,
-			DELAY_MAX_PER_STEP_NS));
-
-	temptime = ktime_sub(ktime_get(), (dev->timestamp_t_focus_abs));
-	if (ktime_compare(temptime, timedelay) <= 0) {
-		status |= ATOMISP_FOCUS_STATUS_MOVING;
-		status |= ATOMISP_FOCUS_HP_IN_PROGRESS;
-	} else {
-		status |= ATOMISP_FOCUS_STATUS_ACCEPTS_NEW_MOVE;
-		status |= ATOMISP_FOCUS_HP_COMPLETE;
-	}
-
-	*value = status;
-
-	return 0;
-}
-
-static int ov5693_q_focus_abs(struct v4l2_subdev *sd, s32 *value)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	s32 val;
-
-	ov5693_q_focus_status(sd, &val);
-
-	if (val & ATOMISP_FOCUS_STATUS_MOVING)
-		*value  = dev->focus - dev->number_of_steps;
-	else
-		*value  = dev->focus;
-
-	return 0;
-}
-
-static int ov5693_t_vcm_slew(struct v4l2_subdev *sd, s32 value)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-
-	dev->number_of_steps = value;
-	dev->vcm_update = true;
-	return 0;
-}
-
-static int ov5693_t_vcm_timing(struct v4l2_subdev *sd, s32 value)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-
-	dev->number_of_steps = value;
-	dev->vcm_update = true;
-	return 0;
-}
-
-static int ov5693_s_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct ov5693_device *dev =
-	    container_of(ctrl->handler, struct ov5693_device, ctrl_handler);
-	struct i2c_client *client = v4l2_get_subdevdata(&dev->sd);
-	int ret = 0;
-
-	switch (ctrl->id) {
-	case V4L2_CID_FOCUS_ABSOLUTE:
-		dev_dbg(&client->dev, "%s: CID_FOCUS_ABSOLUTE:%d.\n",
-			__func__, ctrl->val);
-		ret = ov5693_t_focus_abs(&dev->sd, ctrl->val);
-		break;
-	case V4L2_CID_FOCUS_RELATIVE:
-		dev_dbg(&client->dev, "%s: CID_FOCUS_RELATIVE:%d.\n",
-			__func__, ctrl->val);
-		ret = ov5693_t_focus_rel(&dev->sd, ctrl->val);
-		break;
-	case V4L2_CID_VCM_SLEW:
-		ret = ov5693_t_vcm_slew(&dev->sd, ctrl->val);
-		break;
-	case V4L2_CID_VCM_TIMEING:
-		ret = ov5693_t_vcm_timing(&dev->sd, ctrl->val);
-		break;
-	default:
-		ret = -EINVAL;
-	}
-	return ret;
-}
-
-static int ov5693_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct ov5693_device *dev =
-	    container_of(ctrl->handler, struct ov5693_device, ctrl_handler);
-	int ret = 0;
-
-	switch (ctrl->id) {
-	case V4L2_CID_EXPOSURE_ABSOLUTE:
-		ret = ov5693_q_exposure(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FOCAL_ABSOLUTE:
-		ret = ov5693_g_focal(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FNUMBER_ABSOLUTE:
-		ret = ov5693_g_fnumber(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FNUMBER_RANGE:
-		ret = ov5693_g_fnumber_range(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FOCUS_ABSOLUTE:
-		ret = ov5693_q_focus_abs(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_FOCUS_STATUS:
-		ret = ov5693_q_focus_status(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_BIN_FACTOR_HORZ:
-		ret = ov5693_g_bin_factor_x(&dev->sd, &ctrl->val);
-		break;
-	case V4L2_CID_BIN_FACTOR_VERT:
-		ret = ov5693_g_bin_factor_y(&dev->sd, &ctrl->val);
-		break;
-	default:
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static const struct v4l2_ctrl_ops ctrl_ops = {
-	.s_ctrl = ov5693_s_ctrl,
-	.g_volatile_ctrl = ov5693_g_volatile_ctrl
-};
-
-static const struct v4l2_ctrl_config ov5693_controls[] = {
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_EXPOSURE_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "exposure",
-	 .min = 0x0,
-	 .max = 0xffff,
-	 .step = 0x01,
-	 .def = 0x00,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FOCAL_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "focal length",
-	 .min = OV5693_FOCAL_LENGTH_DEFAULT,
-	 .max = OV5693_FOCAL_LENGTH_DEFAULT,
-	 .step = 0x01,
-	 .def = OV5693_FOCAL_LENGTH_DEFAULT,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FNUMBER_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "f-number",
-	 .min = OV5693_F_NUMBER_DEFAULT,
-	 .max = OV5693_F_NUMBER_DEFAULT,
-	 .step = 0x01,
-	 .def = OV5693_F_NUMBER_DEFAULT,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FNUMBER_RANGE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "f-number range",
-	 .min = OV5693_F_NUMBER_RANGE,
-	 .max = OV5693_F_NUMBER_RANGE,
-	 .step = 0x01,
-	 .def = OV5693_F_NUMBER_RANGE,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FOCUS_ABSOLUTE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "focus move absolute",
-	 .min = 0,
-	 .max = OV5693_VCM_MAX_FOCUS_POS,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FOCUS_RELATIVE,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "focus move relative",
-	 .min = OV5693_VCM_MAX_FOCUS_NEG,
-	 .max = OV5693_VCM_MAX_FOCUS_POS,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_FOCUS_STATUS,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "focus status",
-	 .min = 0,
-	 .max = 100,		/* allow enum to grow in the future */
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_VCM_SLEW,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "vcm slew",
-	 .min = 0,
-	 .max = OV5693_VCM_SLEW_STEP_MAX,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_VCM_TIMEING,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "vcm step time",
-	 .min = 0,
-	 .max = OV5693_VCM_SLEW_TIME_MAX,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_BIN_FACTOR_HORZ,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "horizontal binning factor",
-	 .min = 0,
-	 .max = OV5693_BIN_FACTOR_MAX,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-	{
-	 .ops = &ctrl_ops,
-	 .id = V4L2_CID_BIN_FACTOR_VERT,
-	 .type = V4L2_CTRL_TYPE_INTEGER,
-	 .name = "vertical binning factor",
-	 .min = 0,
-	 .max = OV5693_BIN_FACTOR_MAX,
-	 .step = 1,
-	 .def = 0,
-	 .flags = 0,
-	 },
-};
-
-static int ov5693_init(struct v4l2_subdev *sd)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	pr_info("%s\n", __func__);
-	mutex_lock(&dev->input_lock);
-	dev->vcm_update = false;
-
-	if (dev->vcm == VCM_AD5823) {
-		ret = vcm_ad_i2c_wr8(client, 0x01, 0x01); /* vcm init test */
-		if (ret)
-			dev_err(&client->dev,
-				"vcm reset failed\n");
-		/*change the mode*/
-		ret = ad5823_i2c_write(client, AD5823_REG_VCM_CODE_MSB,
-				       AD5823_RING_CTRL_ENABLE);
-		if (ret)
-			dev_err(&client->dev,
-				"vcm enable ringing failed\n");
-		ret = ad5823_i2c_write(client, AD5823_REG_MODE,
-					AD5823_ARC_RES1);
-		if (ret)
-			dev_err(&client->dev,
-				"vcm change mode failed\n");
-	}
-
-	/*change initial focus value for ad5823*/
-	if (dev->vcm == VCM_AD5823) {
-		dev->focus = AD5823_INIT_FOCUS_POS;
-		ov5693_t_focus_abs(sd, AD5823_INIT_FOCUS_POS);
-	} else {
-		dev->focus = 0;
-		ov5693_t_focus_abs(sd, 0);
-	}
-
-	mutex_unlock(&dev->input_lock);
-
-	return 0;
-}
-
-static int power_ctrl(struct v4l2_subdev *sd, bool flag)
-{
-	int ret;
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-
-	if (!dev || !dev->platform_data)
-		return -ENODEV;
-
-	/*
-	 * This driver assumes "internal DVDD, PWDNB tied to DOVDD".
-	 * In this set up only gpio0 (XSHUTDN) should be available
-	 * but in some products (for example ECS) gpio1 (PWDNB) is
-	 * also available. If gpio1 is available we emulate it being
-	 * tied to DOVDD here.
-	 */
-	if (flag) {
-		ret = dev->platform_data->v2p8_ctrl(sd, 1);
-		dev->platform_data->gpio1_ctrl(sd, 1);
-		if (ret == 0) {
-			ret = dev->platform_data->v1p8_ctrl(sd, 1);
-			if (ret) {
-				dev->platform_data->gpio1_ctrl(sd, 0);
-				ret = dev->platform_data->v2p8_ctrl(sd, 0);
-			}
-		}
-	} else {
-		dev->platform_data->gpio1_ctrl(sd, 0);
-		ret = dev->platform_data->v1p8_ctrl(sd, 0);
-		ret |= dev->platform_data->v2p8_ctrl(sd, 0);
-	}
-
-	return ret;
-}
-
-static int gpio_ctrl(struct v4l2_subdev *sd, bool flag)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-
-	if (!dev || !dev->platform_data)
-		return -ENODEV;
-
-	return dev->platform_data->gpio0_ctrl(sd, flag);
-}
-
-static int __power_up(struct v4l2_subdev *sd)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	if (!dev->platform_data) {
-		dev_err(&client->dev,
-			"no camera_sensor_platform_data");
-		return -ENODEV;
-	}
-
-	/* power control */
-	ret = power_ctrl(sd, 1);
-	if (ret)
-		goto fail_power;
-
-	/* according to DS, at least 5ms is needed between DOVDD and PWDN */
-	/* add this delay time to 10~11ms*/
-	usleep_range(10000, 11000);
-
-	/* gpio ctrl */
-	ret = gpio_ctrl(sd, 1);
-	if (ret) {
-		ret = gpio_ctrl(sd, 1);
-		if (ret)
-			goto fail_power;
-	}
-
-	/* flis clock control */
-	ret = dev->platform_data->flisclk_ctrl(sd, 1);
-	if (ret)
-		goto fail_clk;
-
-	__cci_delay(up_delay);
-
-	return 0;
-
-fail_clk:
-	gpio_ctrl(sd, 0);
-fail_power:
-	power_ctrl(sd, 0);
-	dev_err(&client->dev, "sensor power-up failed\n");
-
-	return ret;
-}
-
-static int power_down(struct v4l2_subdev *sd)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	dev->focus = OV5693_INVALID_CONFIG;
-	if (!dev->platform_data) {
-		dev_err(&client->dev,
-			"no camera_sensor_platform_data");
-		return -ENODEV;
-	}
-
-	ret = dev->platform_data->flisclk_ctrl(sd, 0);
-	if (ret)
-		dev_err(&client->dev, "flisclk failed\n");
-
-	/* gpio ctrl */
-	ret = gpio_ctrl(sd, 0);
-	if (ret) {
-		ret = gpio_ctrl(sd, 0);
-		if (ret)
-			dev_err(&client->dev, "gpio failed 2\n");
-	}
-
-	/* power control */
-	ret = power_ctrl(sd, 0);
-	if (ret)
-		dev_err(&client->dev, "vprog failed.\n");
-
-	return ret;
-}
-
-static int power_up(struct v4l2_subdev *sd)
-{
-	static const int retry_count = 4;
-	int i, ret;
-
-	for (i = 0; i < retry_count; i++) {
-		ret = __power_up(sd);
-		if (!ret)
-			return 0;
-
-		power_down(sd);
-	}
-	return ret;
-}
-
-static int ov5693_s_power(struct v4l2_subdev *sd, int on)
-{
-	int ret;
-
-	pr_info("%s: on %d\n", __func__, on);
-	if (on == 0)
-		return power_down(sd);
-	else {
-		ret = power_up(sd);
-		if (!ret) {
-			ret = ov5693_init(sd);
-			/* restore settings */
-			ov5693_res = ov5693_res_preview;
-			N_RES = N_RES_PREVIEW;
-		}
-	}
-	return ret;
-}
-
-/*
- * distance - calculate the distance
- * @res: resolution
- * @w: width
- * @h: height
- *
- * Get the gap between res_w/res_h and w/h.
- * distance = (res_w/res_h - w/h) / (w/h) * 8192
- * res->width/height smaller than w/h wouldn't be considered.
- * The gap of ratio larger than 1/8 wouldn't be considered.
- * Returns the value of gap or -1 if fail.
- */
-#define LARGEST_ALLOWED_RATIO_MISMATCH 1024
-static int distance(struct ov5693_resolution *res, u32 w, u32 h)
-{
-	int ratio;
-	int distance;
-
-	if (w == 0 || h == 0 ||
-	    res->width < w || res->height < h)
-		return -1;
-
-	ratio = res->width << 13;
-	ratio /= w;
-	ratio *= h;
-	ratio /= res->height;
-
-	distance = abs(ratio - 8192);
-
-	if (distance > LARGEST_ALLOWED_RATIO_MISMATCH)
-		return -1;
-
-	return distance;
-}
-
-/* Return the nearest higher resolution index
- * Firstly try to find the approximate aspect ratio resolution
- * If we find multiple same AR resolutions, choose the
- * minimal size.
- */
-static int nearest_resolution_index(int w, int h)
-{
-	int i;
-	int idx = -1;
-	int dist;
-	int min_dist = INT_MAX;
-	int min_res_w = INT_MAX;
-	struct ov5693_resolution *tmp_res = NULL;
-
-	for (i = 0; i < N_RES; i++) {
-		tmp_res = &ov5693_res[i];
-		dist = distance(tmp_res, w, h);
-		if (dist == -1)
-			continue;
-		if (dist < min_dist) {
-			min_dist = dist;
-			idx = i;
-			min_res_w = ov5693_res[i].width;
-			continue;
-		}
-		if (dist == min_dist && ov5693_res[i].width < min_res_w)
-			idx = i;
-	}
-
-	return idx;
-}
-
-static int get_resolution_index(int w, int h)
-{
-	int i;
-
-	for (i = 0; i < N_RES; i++) {
-		if (w != ov5693_res[i].width)
-			continue;
-		if (h != ov5693_res[i].height)
-			continue;
-
-		return i;
-	}
-
-	return -1;
-}
-
-/* TODO: remove it. */
-static int startup(struct v4l2_subdev *sd)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	ret = ov5693_write_reg(client, OV5693_8BIT,
-					OV5693_SW_RESET, 0x01);
-	if (ret) {
-		dev_err(&client->dev, "ov5693 reset err.\n");
-		return ret;
-	}
-
-	ret = ov5693_write_reg_array(client, ov5693_global_setting);
-	if (ret) {
-		dev_err(&client->dev, "ov5693 write register err.\n");
-		return ret;
-	}
-
-	ret = ov5693_write_reg_array(client, ov5693_res[dev->fmt_idx].regs);
-	if (ret) {
-		dev_err(&client->dev, "ov5693 write register err.\n");
-		return ret;
-	}
-
-	return ret;
-}
-
-static int ov5693_set_fmt(struct v4l2_subdev *sd,
-			  struct v4l2_subdev_pad_config *cfg,
-			  struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	struct camera_mipi_info *ov5693_info = NULL;
-	int ret = 0;
-	int idx;
-
-	if (format->pad)
-		return -EINVAL;
-	if (!fmt)
-		return -EINVAL;
-	ov5693_info = v4l2_get_subdev_hostdata(sd);
-	if (ov5693_info == NULL)
-		return -EINVAL;
-
-	mutex_lock(&dev->input_lock);
-	idx = nearest_resolution_index(fmt->width, fmt->height);
-	if (idx == -1) {
-		/* return the largest resolution */
-		fmt->width = ov5693_res[N_RES - 1].width;
-		fmt->height = ov5693_res[N_RES - 1].height;
-	} else {
-		fmt->width = ov5693_res[idx].width;
-		fmt->height = ov5693_res[idx].height;
-	}
-
-	fmt->code = MEDIA_BUS_FMT_SBGGR10_1X10;
-	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-		cfg->try_fmt = *fmt;
-		mutex_unlock(&dev->input_lock);
-		return 0;
-	}
-
-	dev->fmt_idx = get_resolution_index(fmt->width, fmt->height);
-	if (dev->fmt_idx == -1) {
-		dev_err(&client->dev, "get resolution fail\n");
-		mutex_unlock(&dev->input_lock);
-		return -EINVAL;
-	}
-
-	ret = startup(sd);
-	if (ret) {
-		int i = 0;
-
-		dev_err(&client->dev, "ov5693 startup err, retry to power up\n");
-		for (i = 0; i < OV5693_POWER_UP_RETRY_NUM; i++) {
-			dev_err(&client->dev,
-				"ov5693 retry to power up %d/%d times, result: ",
-				i+1, OV5693_POWER_UP_RETRY_NUM);
-			power_down(sd);
-			ret = power_up(sd);
-			if (!ret) {
-				mutex_unlock(&dev->input_lock);
-				ov5693_init(sd);
-				mutex_lock(&dev->input_lock);
-			} else {
-				dev_err(&client->dev, "power up failed, continue\n");
-				continue;
-			}
-			ret = startup(sd);
-			if (ret) {
-				dev_err(&client->dev, " startup FAILED!\n");
-			} else {
-				dev_err(&client->dev, " startup SUCCESS!\n");
-				break;
-			}
-		}
-	}
-
-	/*
-	 * After sensor settings are set to HW, sometimes stream is started.
-	 * This would cause ISP timeout because ISP is not ready to receive
-	 * data yet. So add stop streaming here.
-	 */
-	ret = ov5693_write_reg(client, OV5693_8BIT, OV5693_SW_STREAM,
-				OV5693_STOP_STREAMING);
-	if (ret)
-		dev_warn(&client->dev, "ov5693 stream off err\n");
-
-	ret = ov5693_get_intg_factor(client, ov5693_info,
-					&ov5693_res[dev->fmt_idx]);
-	if (ret) {
-		dev_err(&client->dev, "failed to get integration_factor\n");
-		goto err;
-	}
-
-	ov5693_info->metadata_width = fmt->width * 10 / 8;
-	ov5693_info->metadata_height = 1;
-	ov5693_info->metadata_effective_width = &ov5693_embedded_effective_size;
-
-err:
-	mutex_unlock(&dev->input_lock);
-	return ret;
-}
-static int ov5693_get_fmt(struct v4l2_subdev *sd,
-			  struct v4l2_subdev_pad_config *cfg,
-			  struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-
-	if (format->pad)
-		return -EINVAL;
-
-	if (!fmt)
-		return -EINVAL;
-
-	fmt->width = ov5693_res[dev->fmt_idx].width;
-	fmt->height = ov5693_res[dev->fmt_idx].height;
-	fmt->code = MEDIA_BUS_FMT_SBGGR10_1X10;
-
-	return 0;
-}
-
-static int ov5693_detect(struct i2c_client *client)
-{
-	struct i2c_adapter *adapter = client->adapter;
-	u16 high, low;
-	int ret;
-	u16 id;
-	u8 revision;
-
-	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
-		return -ENODEV;
-
-	ret = ov5693_read_reg(client, OV5693_8BIT,
-					OV5693_SC_CMMN_CHIP_ID_H, &high);
-	if (ret) {
-		dev_err(&client->dev, "sensor_id_high = 0x%x\n", high);
-		return -ENODEV;
-	}
-	ret = ov5693_read_reg(client, OV5693_8BIT,
-					OV5693_SC_CMMN_CHIP_ID_L, &low);
-	id = ((((u16) high) << 8) | (u16) low);
-
-	if (id != OV5693_ID) {
-		dev_err(&client->dev, "sensor ID error 0x%x\n", id);
-		return -ENODEV;
-	}
-
-	ret = ov5693_read_reg(client, OV5693_8BIT,
-					OV5693_SC_CMMN_SUB_ID, &high);
-	revision = (u8) high & 0x0f;
-
-	dev_dbg(&client->dev, "sensor_revision = 0x%x\n", revision);
-	dev_dbg(&client->dev, "detect ov5693 success\n");
-	return 0;
-}
-
-static int ov5693_s_stream(struct v4l2_subdev *sd, int enable)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret;
-
-	mutex_lock(&dev->input_lock);
-
-	ret = ov5693_write_reg(client, OV5693_8BIT, OV5693_SW_STREAM,
-				enable ? OV5693_START_STREAMING :
-				OV5693_STOP_STREAMING);
-
-	mutex_unlock(&dev->input_lock);
-
-	return ret;
-}
-
-
-static int ov5693_s_config(struct v4l2_subdev *sd,
-			   int irq, void *platform_data)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-	struct i2c_client *client = v4l2_get_subdevdata(sd);
-	int ret = 0;
-
-	if (platform_data == NULL)
-		return -ENODEV;
-
-	dev->platform_data =
-		(struct camera_sensor_platform_data *)platform_data;
-
-	mutex_lock(&dev->input_lock);
-	/* power off the module, then power on it in future
-	 * as first power on by board may not fulfill the
-	 * power on sequqence needed by the module
-	 */
-	ret = power_down(sd);
-	if (ret) {
-		dev_err(&client->dev, "ov5693 power-off err.\n");
-		goto fail_power_off;
-	}
-
-	ret = power_up(sd);
-	if (ret) {
-		dev_err(&client->dev, "ov5693 power-up err.\n");
-		goto fail_power_on;
-	}
-
-	if (!dev->vcm)
-		dev->vcm = vcm_detect(client);
-
-	ret = dev->platform_data->csi_cfg(sd, 1);
-	if (ret)
-		goto fail_csi_cfg;
-
-	/* config & detect sensor */
-	ret = ov5693_detect(client);
-	if (ret) {
-		dev_err(&client->dev, "ov5693_detect err s_config.\n");
-		goto fail_csi_cfg;
-	}
-
-	dev->otp_data = ov5693_otp_read(sd);
-
-	/* turn off sensor, after probed */
-	ret = power_down(sd);
-	if (ret) {
-		dev_err(&client->dev, "ov5693 power-off err.\n");
-		goto fail_csi_cfg;
-	}
-	mutex_unlock(&dev->input_lock);
-
-	return ret;
-
-fail_csi_cfg:
-	dev->platform_data->csi_cfg(sd, 0);
-fail_power_on:
-	power_down(sd);
-	dev_err(&client->dev, "sensor power-gating failed\n");
-fail_power_off:
-	mutex_unlock(&dev->input_lock);
-	return ret;
-}
-
-static int ov5693_g_frame_interval(struct v4l2_subdev *sd,
-				   struct v4l2_subdev_frame_interval *interval)
-{
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-
-	interval->interval.numerator = 1;
-	interval->interval.denominator = ov5693_res[dev->fmt_idx].fps;
-
-	return 0;
-}
-
-static int ov5693_enum_mbus_code(struct v4l2_subdev *sd,
-				 struct v4l2_subdev_pad_config *cfg,
-				 struct v4l2_subdev_mbus_code_enum *code)
-{
-	if (code->index >= MAX_FMTS)
-		return -EINVAL;
-
-	code->code = MEDIA_BUS_FMT_SBGGR10_1X10;
-	return 0;
-}
-
-static int ov5693_enum_frame_size(struct v4l2_subdev *sd,
-				  struct v4l2_subdev_pad_config *cfg,
-				  struct v4l2_subdev_frame_size_enum *fse)
-{
-	int index = fse->index;
-
-	if (index >= N_RES)
-		return -EINVAL;
-
-	fse->min_width = ov5693_res[index].width;
-	fse->min_height = ov5693_res[index].height;
-	fse->max_width = ov5693_res[index].width;
-	fse->max_height = ov5693_res[index].height;
-
-	return 0;
-
-}
-
-static const struct v4l2_subdev_video_ops ov5693_video_ops = {
-	.s_stream = ov5693_s_stream,
-	.g_frame_interval = ov5693_g_frame_interval,
-};
-
-static const struct v4l2_subdev_core_ops ov5693_core_ops = {
-	.s_power = ov5693_s_power,
-	.ioctl = ov5693_ioctl,
-};
-
-static const struct v4l2_subdev_pad_ops ov5693_pad_ops = {
-	.enum_mbus_code = ov5693_enum_mbus_code,
-	.enum_frame_size = ov5693_enum_frame_size,
-	.get_fmt = ov5693_get_fmt,
-	.set_fmt = ov5693_set_fmt,
-};
-
-static const struct v4l2_subdev_ops ov5693_ops = {
-	.core = &ov5693_core_ops,
-	.video = &ov5693_video_ops,
-	.pad = &ov5693_pad_ops,
-};
-
-static int ov5693_remove(struct i2c_client *client)
-{
-	struct v4l2_subdev *sd = i2c_get_clientdata(client);
-	struct ov5693_device *dev = to_ov5693_sensor(sd);
-
-	dev_dbg(&client->dev, "ov5693_remove...\n");
-
-	dev->platform_data->csi_cfg(sd, 0);
-
-	v4l2_device_unregister_subdev(sd);
-
-	atomisp_gmin_remove_subdev(sd);
-
-	media_entity_cleanup(&dev->sd.entity);
-	v4l2_ctrl_handler_free(&dev->ctrl_handler);
-	kfree(dev);
-
-	return 0;
-}
-
-static int ov5693_probe(struct i2c_client *client)
-{
-	struct ov5693_device *dev;
-	int i2c;
-	int ret = 0;
-	void *pdata;
-	unsigned int i;
-
-	/*
-	 * Firmware workaround: Some modules use a "secondary default"
-	 * address of 0x10 which doesn't appear on schematics, and
-	 * some BIOS versions haven't gotten the memo.  Work around
-	 * via config.
-	 */
-	i2c = gmin_get_var_int(&client->dev, "I2CAddr", -1);
-	if (i2c != -1) {
-		dev_info(&client->dev,
-		"Overriding firmware-provided I2C address (0x%x) with 0x%x\n",
-			 client->addr, i2c);
-		client->addr = i2c;
-	}
-
-	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (!dev)
-		return -ENOMEM;
-
-	mutex_init(&dev->input_lock);
-
-	dev->fmt_idx = 0;
-	v4l2_i2c_subdev_init(&(dev->sd), client, &ov5693_ops);
-
-	pdata = gmin_camera_platform_data(&dev->sd,
-					  ATOMISP_INPUT_FORMAT_RAW_10,
-					  atomisp_bayer_order_bggr);
-	if (!pdata)
-		goto out_free;
-
-	ret = ov5693_s_config(&dev->sd, client->irq, pdata);
-	if (ret)
-		goto out_free;
-
-	ret = atomisp_register_i2c_module(&dev->sd, pdata, RAW_CAMERA);
-	if (ret)
-		goto out_free;
-
-	dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	dev->pad.flags = MEDIA_PAD_FL_SOURCE;
-	dev->format.code = MEDIA_BUS_FMT_SBGGR10_1X10;
-	dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
-	ret =
-	    v4l2_ctrl_handler_init(&dev->ctrl_handler,
-				   ARRAY_SIZE(ov5693_controls));
-	if (ret) {
-		ov5693_remove(client);
-		return ret;
-	}
-
-	for (i = 0; i < ARRAY_SIZE(ov5693_controls); i++)
-		v4l2_ctrl_new_custom(&dev->ctrl_handler, &ov5693_controls[i],
-				     NULL);
-
-	if (dev->ctrl_handler.error) {
-		ov5693_remove(client);
-		return dev->ctrl_handler.error;
-	}
-
-	/* Use same lock for controls as for everything else. */
-	dev->ctrl_handler.lock = &dev->input_lock;
-	dev->sd.ctrl_handler = &dev->ctrl_handler;
-
-	ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
-	if (ret)
-		ov5693_remove(client);
-
-	return ret;
-out_free:
-	v4l2_device_unregister_subdev(&dev->sd);
-	kfree(dev);
-	return ret;
-}
-
-static const struct acpi_device_id ov5693_acpi_match[] = {
-	{"INT33BE"},
-	{},
-};
-MODULE_DEVICE_TABLE(acpi, ov5693_acpi_match);
-
-static struct i2c_driver ov5693_driver = {
-	.driver = {
-		.name = "ov5693",
-		.acpi_match_table = ov5693_acpi_match,
-	},
-	.probe_new = ov5693_probe,
-	.remove = ov5693_remove,
-};
-module_i2c_driver(ov5693_driver);
-
-MODULE_DESCRIPTION("A low-level driver for OmniVision 5693 sensors");
-MODULE_LICENSE("GPL");

+ 0 - 1392
drivers/staging/media/atomisp/i2c/ov5693/ov5693.h

@@ -1,1392 +0,0 @@
-/*
- * Support for OmniVision OV5693 5M camera sensor.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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 __OV5693_H__
-#define __OV5693_H__
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/delay.h>
-#include <linux/videodev2.h>
-#include <linux/spinlock.h>
-#include <media/v4l2-subdev.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-ctrls.h>
-#include <linux/v4l2-mediabus.h>
-#include <media/media-entity.h>
-
-#include "../../include/linux/atomisp_platform.h"
-
-/*
- * FIXME: non-preview resolutions are currently broken
- */
-#define ENABLE_NON_PREVIEW	0
-
-
-#define OV5693_POWER_UP_RETRY_NUM 5
-
-/* Defines for register writes and register array processing */
-#define I2C_MSG_LENGTH		0x2
-#define I2C_RETRY_COUNT		5
-
-#define OV5693_FOCAL_LENGTH_NUM	334	/*3.34mm*/
-#define OV5693_FOCAL_LENGTH_DEM	100
-#define OV5693_F_NUMBER_DEFAULT_NUM	24
-#define OV5693_F_NUMBER_DEM	10
-
-#define MAX_FMTS		1
-
-/* sensor_mode_data read_mode adaptation */
-#define OV5693_READ_MODE_BINNING_ON	0x0400
-#define OV5693_READ_MODE_BINNING_OFF	0x00
-#define OV5693_INTEGRATION_TIME_MARGIN	8
-
-#define OV5693_MAX_EXPOSURE_VALUE	0xFFF1
-#define OV5693_MAX_GAIN_VALUE		0xFF
-
-/*
- * focal length bits definition:
- * bits 31-16: numerator, bits 15-0: denominator
- */
-#define OV5693_FOCAL_LENGTH_DEFAULT 0x1B70064
-
-/*
- * current f-number bits definition:
- * bits 31-16: numerator, bits 15-0: denominator
- */
-#define OV5693_F_NUMBER_DEFAULT 0x18000a
-
-/*
- * f-number range bits definition:
- * bits 31-24: max f-number numerator
- * bits 23-16: max f-number denominator
- * bits 15-8: min f-number numerator
- * bits 7-0: min f-number denominator
- */
-#define OV5693_F_NUMBER_RANGE 0x180a180a
-#define OV5693_ID	0x5690
-
-#define OV5693_FINE_INTG_TIME_MIN 0
-#define OV5693_FINE_INTG_TIME_MAX_MARGIN 0
-#define OV5693_COARSE_INTG_TIME_MIN 1
-#define OV5693_COARSE_INTG_TIME_MAX_MARGIN 6
-
-#define OV5693_BIN_FACTOR_MAX 4
-/*
- * OV5693 System control registers
- */
-#define OV5693_SW_SLEEP				0x0100
-#define OV5693_SW_RESET				0x0103
-#define OV5693_SW_STREAM			0x0100
-
-#define OV5693_SC_CMMN_CHIP_ID_H		0x300A
-#define OV5693_SC_CMMN_CHIP_ID_L		0x300B
-#define OV5693_SC_CMMN_SCCB_ID			0x300C
-#define OV5693_SC_CMMN_SUB_ID			0x302A /* process, version*/
-/*Bit[7:4] Group control, Bit[3:0] Group ID*/
-#define OV5693_GROUP_ACCESS			0x3208
-/*
-*Bit[3:0] Bit[19:16] of exposure,
-*remaining 16 bits lies in Reg0x3501&Reg0x3502
-*/
-#define OV5693_EXPOSURE_H			0x3500
-#define OV5693_EXPOSURE_M			0x3501
-#define OV5693_EXPOSURE_L			0x3502
-/*Bit[1:0] means Bit[9:8] of gain*/
-#define OV5693_AGC_H				0x350A
-#define OV5693_AGC_L				0x350B /*Bit[7:0] of gain*/
-
-#define OV5693_HORIZONTAL_START_H		0x3800 /*Bit[11:8]*/
-#define OV5693_HORIZONTAL_START_L		0x3801 /*Bit[7:0]*/
-#define OV5693_VERTICAL_START_H			0x3802 /*Bit[11:8]*/
-#define OV5693_VERTICAL_START_L			0x3803 /*Bit[7:0]*/
-#define OV5693_HORIZONTAL_END_H			0x3804 /*Bit[11:8]*/
-#define OV5693_HORIZONTAL_END_L			0x3805 /*Bit[7:0]*/
-#define OV5693_VERTICAL_END_H			0x3806 /*Bit[11:8]*/
-#define OV5693_VERTICAL_END_L			0x3807 /*Bit[7:0]*/
-#define OV5693_HORIZONTAL_OUTPUT_SIZE_H		0x3808 /*Bit[3:0]*/
-#define OV5693_HORIZONTAL_OUTPUT_SIZE_L		0x3809 /*Bit[7:0]*/
-#define OV5693_VERTICAL_OUTPUT_SIZE_H		0x380a /*Bit[3:0]*/
-#define OV5693_VERTICAL_OUTPUT_SIZE_L		0x380b /*Bit[7:0]*/
-/*High 8-bit, and low 8-bit HTS address is 0x380d*/
-#define OV5693_TIMING_HTS_H			0x380C
-/*High 8-bit, and low 8-bit HTS address is 0x380d*/
-#define OV5693_TIMING_HTS_L			0x380D
-/*High 8-bit, and low 8-bit HTS address is 0x380f*/
-#define OV5693_TIMING_VTS_H			0x380e
-/*High 8-bit, and low 8-bit HTS address is 0x380f*/
-#define OV5693_TIMING_VTS_L			0x380f
-
-#define OV5693_MWB_RED_GAIN_H			0x3400
-#define OV5693_MWB_GREEN_GAIN_H			0x3402
-#define OV5693_MWB_BLUE_GAIN_H			0x3404
-#define OV5693_MWB_GAIN_MAX			0x0fff
-
-#define OV5693_START_STREAMING			0x01
-#define OV5693_STOP_STREAMING			0x00
-
-#define VCM_ADDR           0x0c
-#define VCM_CODE_MSB       0x04
-
-#define OV5693_INVALID_CONFIG	0xffffffff
-
-#define OV5693_VCM_SLEW_STEP			0x30F0
-#define OV5693_VCM_SLEW_STEP_MAX		0x7
-#define OV5693_VCM_SLEW_STEP_MASK		0x7
-#define OV5693_VCM_CODE				0x30F2
-#define OV5693_VCM_SLEW_TIME			0x30F4
-#define OV5693_VCM_SLEW_TIME_MAX		0xffff
-#define OV5693_VCM_ENABLE			0x8000
-
-#define OV5693_VCM_MAX_FOCUS_NEG       -1023
-#define OV5693_VCM_MAX_FOCUS_POS       1023
-
-#define DLC_ENABLE 1
-#define DLC_DISABLE 0
-#define VCM_PROTECTION_OFF     0xeca3
-#define VCM_PROTECTION_ON      0xdc51
-#define VCM_DEFAULT_S 0x0
-#define vcm_step_s(a) (u8)(a & 0xf)
-#define vcm_step_mclk(a) (u8)((a >> 4) & 0x3)
-#define vcm_dlc_mclk(dlc, mclk) (u16)((dlc << 3) | mclk | 0xa104)
-#define vcm_tsrc(tsrc) (u16)(tsrc << 3 | 0xf200)
-#define vcm_val(data, s) (u16)(data << 4 | s)
-#define DIRECT_VCM vcm_dlc_mclk(0, 0)
-
-/* Defines for OTP Data Registers */
-#define OV5693_FRAME_OFF_NUM		0x4202
-#define OV5693_OTP_BYTE_MAX		32	//change to 32 as needed by otpdata
-#define OV5693_OTP_SHORT_MAX		16
-#define OV5693_OTP_START_ADDR		0x3D00
-#define OV5693_OTP_END_ADDR		0x3D0F
-#define OV5693_OTP_DATA_SIZE		320
-#define OV5693_OTP_PROGRAM_REG      	0x3D80
-#define OV5693_OTP_READ_REG		0x3D81	// 1:Enable 0:disable
-#define OV5693_OTP_BANK_REG		0x3D84	//otp bank and mode
-#define OV5693_OTP_READY_REG_DONE	1
-#define OV5693_OTP_BANK_MAX		28
-#define OV5693_OTP_BANK_SIZE		16	//16 bytes per bank
-#define OV5693_OTP_READ_ONETIME		16
-#define OV5693_OTP_MODE_READ		1
-
-struct regval_list {
-	u16 reg_num;
-	u8 value;
-};
-
-struct ov5693_resolution {
-	u8 *desc;
-	const struct ov5693_reg *regs;
-	int res;
-	int width;
-	int height;
-	int fps;
-	int pix_clk_freq;
-	u16 pixels_per_line;
-	u16 lines_per_frame;
-	u8 bin_factor_x;
-	u8 bin_factor_y;
-	u8 bin_mode;
-	bool used;
-};
-
-struct ov5693_format {
-	u8 *desc;
-	u32 pixelformat;
-	struct ov5693_reg *regs;
-};
-
-enum vcm_type {
-	VCM_UNKNOWN,
-	VCM_AD5823,
-	VCM_DW9714,
-};
-
-/*
- * ov5693 device structure.
- */
-struct ov5693_device {
-	struct v4l2_subdev sd;
-	struct media_pad pad;
-	struct v4l2_mbus_framefmt format;
-	struct mutex input_lock;
-	struct v4l2_ctrl_handler ctrl_handler;
-
-	struct camera_sensor_platform_data *platform_data;
-	ktime_t timestamp_t_focus_abs;
-	int vt_pix_clk_freq_mhz;
-	int fmt_idx;
-	int run_mode;
-	int otp_size;
-	u8 *otp_data;
-	u32 focus;
-	s16 number_of_steps;
-	u8 res;
-	u8 type;
-	bool vcm_update;
-	enum vcm_type vcm;
-};
-
-enum ov5693_tok_type {
-	OV5693_8BIT  = 0x0001,
-	OV5693_16BIT = 0x0002,
-	OV5693_32BIT = 0x0004,
-	OV5693_TOK_TERM   = 0xf000,	/* terminating token for reg list */
-	OV5693_TOK_DELAY  = 0xfe00,	/* delay token for reg list */
-	OV5693_TOK_MASK = 0xfff0
-};
-
-/**
- * struct ov5693_reg - MI sensor  register format
- * @type: type of the register
- * @reg: 16-bit offset to register
- * @val: 8/16/32-bit register value
- *
- * Define a structure for sensor register initialization values
- */
-struct ov5693_reg {
-	enum ov5693_tok_type type;
-	u16 reg;
-	u32 val;	/* @set value for read/mod/write, @mask */
-};
-
-#define to_ov5693_sensor(x) container_of(x, struct ov5693_device, sd)
-
-#define OV5693_MAX_WRITE_BUF_SIZE	30
-
-struct ov5693_write_buffer {
-	u16 addr;
-	u8 data[OV5693_MAX_WRITE_BUF_SIZE];
-};
-
-struct ov5693_write_ctrl {
-	int index;
-	struct ov5693_write_buffer buffer;
-};
-
-static struct ov5693_reg const ov5693_global_setting[] = {
-	{OV5693_8BIT, 0x0103, 0x01},
-	{OV5693_8BIT, 0x3001, 0x0a},
-	{OV5693_8BIT, 0x3002, 0x80},
-	{OV5693_8BIT, 0x3006, 0x00},
-	{OV5693_8BIT, 0x3011, 0x21},
-	{OV5693_8BIT, 0x3012, 0x09},
-	{OV5693_8BIT, 0x3013, 0x10},
-	{OV5693_8BIT, 0x3014, 0x00},
-	{OV5693_8BIT, 0x3015, 0x08},
-	{OV5693_8BIT, 0x3016, 0xf0},
-	{OV5693_8BIT, 0x3017, 0xf0},
-	{OV5693_8BIT, 0x3018, 0xf0},
-	{OV5693_8BIT, 0x301b, 0xb4},
-	{OV5693_8BIT, 0x301d, 0x02},
-	{OV5693_8BIT, 0x3021, 0x00},
-	{OV5693_8BIT, 0x3022, 0x01},
-	{OV5693_8BIT, 0x3028, 0x44},
-	{OV5693_8BIT, 0x3098, 0x02},
-	{OV5693_8BIT, 0x3099, 0x19},
-	{OV5693_8BIT, 0x309a, 0x02},
-	{OV5693_8BIT, 0x309b, 0x01},
-	{OV5693_8BIT, 0x309c, 0x00},
-	{OV5693_8BIT, 0x30a0, 0xd2},
-	{OV5693_8BIT, 0x30a2, 0x01},
-	{OV5693_8BIT, 0x30b2, 0x00},
-	{OV5693_8BIT, 0x30b3, 0x7d},
-	{OV5693_8BIT, 0x30b4, 0x03},
-	{OV5693_8BIT, 0x30b5, 0x04},
-	{OV5693_8BIT, 0x30b6, 0x01},
-	{OV5693_8BIT, 0x3104, 0x21},
-	{OV5693_8BIT, 0x3106, 0x00},
-	{OV5693_8BIT, 0x3400, 0x04},
-	{OV5693_8BIT, 0x3401, 0x00},
-	{OV5693_8BIT, 0x3402, 0x04},
-	{OV5693_8BIT, 0x3403, 0x00},
-	{OV5693_8BIT, 0x3404, 0x04},
-	{OV5693_8BIT, 0x3405, 0x00},
-	{OV5693_8BIT, 0x3406, 0x01},
-	{OV5693_8BIT, 0x3500, 0x00},
-	{OV5693_8BIT, 0x3503, 0x07},
-	{OV5693_8BIT, 0x3504, 0x00},
-	{OV5693_8BIT, 0x3505, 0x00},
-	{OV5693_8BIT, 0x3506, 0x00},
-	{OV5693_8BIT, 0x3507, 0x02},
-	{OV5693_8BIT, 0x3508, 0x00},
-	{OV5693_8BIT, 0x3509, 0x10},
-	{OV5693_8BIT, 0x350a, 0x00},
-	{OV5693_8BIT, 0x350b, 0x40},
-	{OV5693_8BIT, 0x3601, 0x0a},
-	{OV5693_8BIT, 0x3602, 0x38},
-	{OV5693_8BIT, 0x3612, 0x80},
-	{OV5693_8BIT, 0x3620, 0x54},
-	{OV5693_8BIT, 0x3621, 0xc7},
-	{OV5693_8BIT, 0x3622, 0x0f},
-	{OV5693_8BIT, 0x3625, 0x10},
-	{OV5693_8BIT, 0x3630, 0x55},
-	{OV5693_8BIT, 0x3631, 0xf4},
-	{OV5693_8BIT, 0x3632, 0x00},
-	{OV5693_8BIT, 0x3633, 0x34},
-	{OV5693_8BIT, 0x3634, 0x02},
-	{OV5693_8BIT, 0x364d, 0x0d},
-	{OV5693_8BIT, 0x364f, 0xdd},
-	{OV5693_8BIT, 0x3660, 0x04},
-	{OV5693_8BIT, 0x3662, 0x10},
-	{OV5693_8BIT, 0x3663, 0xf1},
-	{OV5693_8BIT, 0x3665, 0x00},
-	{OV5693_8BIT, 0x3666, 0x20},
-	{OV5693_8BIT, 0x3667, 0x00},
-	{OV5693_8BIT, 0x366a, 0x80},
-	{OV5693_8BIT, 0x3680, 0xe0},
-	{OV5693_8BIT, 0x3681, 0x00},
-	{OV5693_8BIT, 0x3700, 0x42},
-	{OV5693_8BIT, 0x3701, 0x14},
-	{OV5693_8BIT, 0x3702, 0xa0},
-	{OV5693_8BIT, 0x3703, 0xd8},
-	{OV5693_8BIT, 0x3704, 0x78},
-	{OV5693_8BIT, 0x3705, 0x02},
-	{OV5693_8BIT, 0x370a, 0x00},
-	{OV5693_8BIT, 0x370b, 0x20},
-	{OV5693_8BIT, 0x370c, 0x0c},
-	{OV5693_8BIT, 0x370d, 0x11},
-	{OV5693_8BIT, 0x370e, 0x00},
-	{OV5693_8BIT, 0x370f, 0x40},
-	{OV5693_8BIT, 0x3710, 0x00},
-	{OV5693_8BIT, 0x371a, 0x1c},
-	{OV5693_8BIT, 0x371b, 0x05},
-	{OV5693_8BIT, 0x371c, 0x01},
-	{OV5693_8BIT, 0x371e, 0xa1},
-	{OV5693_8BIT, 0x371f, 0x0c},
-	{OV5693_8BIT, 0x3721, 0x00},
-	{OV5693_8BIT, 0x3724, 0x10},
-	{OV5693_8BIT, 0x3726, 0x00},
-	{OV5693_8BIT, 0x372a, 0x01},
-	{OV5693_8BIT, 0x3730, 0x10},
-	{OV5693_8BIT, 0x3738, 0x22},
-	{OV5693_8BIT, 0x3739, 0xe5},
-	{OV5693_8BIT, 0x373a, 0x50},
-	{OV5693_8BIT, 0x373b, 0x02},
-	{OV5693_8BIT, 0x373c, 0x41},
-	{OV5693_8BIT, 0x373f, 0x02},
-	{OV5693_8BIT, 0x3740, 0x42},
-	{OV5693_8BIT, 0x3741, 0x02},
-	{OV5693_8BIT, 0x3742, 0x18},
-	{OV5693_8BIT, 0x3743, 0x01},
-	{OV5693_8BIT, 0x3744, 0x02},
-	{OV5693_8BIT, 0x3747, 0x10},
-	{OV5693_8BIT, 0x374c, 0x04},
-	{OV5693_8BIT, 0x3751, 0xf0},
-	{OV5693_8BIT, 0x3752, 0x00},
-	{OV5693_8BIT, 0x3753, 0x00},
-	{OV5693_8BIT, 0x3754, 0xc0},
-	{OV5693_8BIT, 0x3755, 0x00},
-	{OV5693_8BIT, 0x3756, 0x1a},
-	{OV5693_8BIT, 0x3758, 0x00},
-	{OV5693_8BIT, 0x3759, 0x0f},
-	{OV5693_8BIT, 0x376b, 0x44},
-	{OV5693_8BIT, 0x375c, 0x04},
-	{OV5693_8BIT, 0x3774, 0x10},
-	{OV5693_8BIT, 0x3776, 0x00},
-	{OV5693_8BIT, 0x377f, 0x08},
-	{OV5693_8BIT, 0x3780, 0x22},
-	{OV5693_8BIT, 0x3781, 0x0c},
-	{OV5693_8BIT, 0x3784, 0x2c},
-	{OV5693_8BIT, 0x3785, 0x1e},
-	{OV5693_8BIT, 0x378f, 0xf5},
-	{OV5693_8BIT, 0x3791, 0xb0},
-	{OV5693_8BIT, 0x3795, 0x00},
-	{OV5693_8BIT, 0x3796, 0x64},
-	{OV5693_8BIT, 0x3797, 0x11},
-	{OV5693_8BIT, 0x3798, 0x30},
-	{OV5693_8BIT, 0x3799, 0x41},
-	{OV5693_8BIT, 0x379a, 0x07},
-	{OV5693_8BIT, 0x379b, 0xb0},
-	{OV5693_8BIT, 0x379c, 0x0c},
-	{OV5693_8BIT, 0x37c5, 0x00},
-	{OV5693_8BIT, 0x37c6, 0x00},
-	{OV5693_8BIT, 0x37c7, 0x00},
-	{OV5693_8BIT, 0x37c9, 0x00},
-	{OV5693_8BIT, 0x37ca, 0x00},
-	{OV5693_8BIT, 0x37cb, 0x00},
-	{OV5693_8BIT, 0x37de, 0x00},
-	{OV5693_8BIT, 0x37df, 0x00},
-	{OV5693_8BIT, 0x3800, 0x00},
-	{OV5693_8BIT, 0x3801, 0x00},
-	{OV5693_8BIT, 0x3802, 0x00},
-	{OV5693_8BIT, 0x3804, 0x0a},
-	{OV5693_8BIT, 0x3805, 0x3f},
-	{OV5693_8BIT, 0x3810, 0x00},
-	{OV5693_8BIT, 0x3812, 0x00},
-	{OV5693_8BIT, 0x3823, 0x00},
-	{OV5693_8BIT, 0x3824, 0x00},
-	{OV5693_8BIT, 0x3825, 0x00},
-	{OV5693_8BIT, 0x3826, 0x00},
-	{OV5693_8BIT, 0x3827, 0x00},
-	{OV5693_8BIT, 0x382a, 0x04},
-	{OV5693_8BIT, 0x3a04, 0x06},
-	{OV5693_8BIT, 0x3a05, 0x14},
-	{OV5693_8BIT, 0x3a06, 0x00},
-	{OV5693_8BIT, 0x3a07, 0xfe},
-	{OV5693_8BIT, 0x3b00, 0x00},
-	{OV5693_8BIT, 0x3b02, 0x00},
-	{OV5693_8BIT, 0x3b03, 0x00},
-	{OV5693_8BIT, 0x3b04, 0x00},
-	{OV5693_8BIT, 0x3b05, 0x00},
-	{OV5693_8BIT, 0x3e07, 0x20},
-	{OV5693_8BIT, 0x4000, 0x08},
-	{OV5693_8BIT, 0x4001, 0x04},
-	{OV5693_8BIT, 0x4002, 0x45},
-	{OV5693_8BIT, 0x4004, 0x08},
-	{OV5693_8BIT, 0x4005, 0x18},
-	{OV5693_8BIT, 0x4006, 0x20},
-	{OV5693_8BIT, 0x4008, 0x24},
-	{OV5693_8BIT, 0x4009, 0x10},
-	{OV5693_8BIT, 0x400c, 0x00},
-	{OV5693_8BIT, 0x400d, 0x00},
-	{OV5693_8BIT, 0x4058, 0x00},
-	{OV5693_8BIT, 0x404e, 0x37},
-	{OV5693_8BIT, 0x404f, 0x8f},
-	{OV5693_8BIT, 0x4058, 0x00},
-	{OV5693_8BIT, 0x4101, 0xb2},
-	{OV5693_8BIT, 0x4303, 0x00},
-	{OV5693_8BIT, 0x4304, 0x08},
-	{OV5693_8BIT, 0x4307, 0x31},
-	{OV5693_8BIT, 0x4311, 0x04},
-	{OV5693_8BIT, 0x4315, 0x01},
-	{OV5693_8BIT, 0x4511, 0x05},
-	{OV5693_8BIT, 0x4512, 0x01},
-	{OV5693_8BIT, 0x4806, 0x00},
-	{OV5693_8BIT, 0x4816, 0x52},
-	{OV5693_8BIT, 0x481f, 0x30},
-	{OV5693_8BIT, 0x4826, 0x2c},
-	{OV5693_8BIT, 0x4831, 0x64},
-	{OV5693_8BIT, 0x4d00, 0x04},
-	{OV5693_8BIT, 0x4d01, 0x71},
-	{OV5693_8BIT, 0x4d02, 0xfd},
-	{OV5693_8BIT, 0x4d03, 0xf5},
-	{OV5693_8BIT, 0x4d04, 0x0c},
-	{OV5693_8BIT, 0x4d05, 0xcc},
-	{OV5693_8BIT, 0x4837, 0x0a},
-	{OV5693_8BIT, 0x5000, 0x06},
-	{OV5693_8BIT, 0x5001, 0x01},
-	{OV5693_8BIT, 0x5003, 0x20},
-	{OV5693_8BIT, 0x5046, 0x0a},
-	{OV5693_8BIT, 0x5013, 0x00},
-	{OV5693_8BIT, 0x5046, 0x0a},
-	{OV5693_8BIT, 0x5780, 0x1c},
-	{OV5693_8BIT, 0x5786, 0x20},
-	{OV5693_8BIT, 0x5787, 0x10},
-	{OV5693_8BIT, 0x5788, 0x18},
-	{OV5693_8BIT, 0x578a, 0x04},
-	{OV5693_8BIT, 0x578b, 0x02},
-	{OV5693_8BIT, 0x578c, 0x02},
-	{OV5693_8BIT, 0x578e, 0x06},
-	{OV5693_8BIT, 0x578f, 0x02},
-	{OV5693_8BIT, 0x5790, 0x02},
-	{OV5693_8BIT, 0x5791, 0xff},
-	{OV5693_8BIT, 0x5842, 0x01},
-	{OV5693_8BIT, 0x5843, 0x2b},
-	{OV5693_8BIT, 0x5844, 0x01},
-	{OV5693_8BIT, 0x5845, 0x92},
-	{OV5693_8BIT, 0x5846, 0x01},
-	{OV5693_8BIT, 0x5847, 0x8f},
-	{OV5693_8BIT, 0x5848, 0x01},
-	{OV5693_8BIT, 0x5849, 0x0c},
-	{OV5693_8BIT, 0x5e00, 0x00},
-	{OV5693_8BIT, 0x5e10, 0x0c},
-	{OV5693_8BIT, 0x0100, 0x00},
-	{OV5693_TOK_TERM, 0, 0}
-};
-
-#if ENABLE_NON_PREVIEW
-/*
- * 654x496 30fps 17ms VBlanking 2lane 10Bit (Scaling)
- */
-static struct ov5693_reg const ov5693_654x496[] = {
-	{OV5693_8BIT, 0x3501, 0x3d},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe6},
-	{OV5693_8BIT, 0x3709, 0xc7},
-	{OV5693_8BIT, 0x3803, 0x00},
-	{OV5693_8BIT, 0x3806, 0x07},
-	{OV5693_8BIT, 0x3807, 0xa3},
-	{OV5693_8BIT, 0x3808, 0x02},
-	{OV5693_8BIT, 0x3809, 0x90},
-	{OV5693_8BIT, 0x380a, 0x01},
-	{OV5693_8BIT, 0x380b, 0xf0},
-	{OV5693_8BIT, 0x380c, 0x0a},
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07},
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3811, 0x08},
-	{OV5693_8BIT, 0x3813, 0x02},
-	{OV5693_8BIT, 0x3814, 0x31},
-	{OV5693_8BIT, 0x3815, 0x31},
-	{OV5693_8BIT, 0x3820, 0x04},
-	{OV5693_8BIT, 0x3821, 0x1f},
-	{OV5693_8BIT, 0x5002, 0x80},
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-
-/*
- * 1296x976 30fps 17ms VBlanking 2lane 10Bit (Scaling)
-*DS from 2592x1952
-*/
-static struct ov5693_reg const ov5693_1296x976[] = {
-	{OV5693_8BIT, 0x3501, 0x7b},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe2},
-	{OV5693_8BIT, 0x3709, 0xc3},
-
-	{OV5693_8BIT, 0x3800, 0x00},
-	{OV5693_8BIT, 0x3801, 0x00},
-	{OV5693_8BIT, 0x3802, 0x00},
-	{OV5693_8BIT, 0x3803, 0x00},
-
-	{OV5693_8BIT, 0x3804, 0x0a},
-	{OV5693_8BIT, 0x3805, 0x3f},
-	{OV5693_8BIT, 0x3806, 0x07},
-	{OV5693_8BIT, 0x3807, 0xA3},
-
-	{OV5693_8BIT, 0x3808, 0x05},
-	{OV5693_8BIT, 0x3809, 0x10},
-	{OV5693_8BIT, 0x380a, 0x03},
-	{OV5693_8BIT, 0x380b, 0xD0},
-
-	{OV5693_8BIT, 0x380c, 0x0a},
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07},
-	{OV5693_8BIT, 0x380f, 0xc0},
-
-	{OV5693_8BIT, 0x3810, 0x00},
-	{OV5693_8BIT, 0x3811, 0x10},
-	{OV5693_8BIT, 0x3812, 0x00},
-	{OV5693_8BIT, 0x3813, 0x02},
-
-	{OV5693_8BIT, 0x3814, 0x11},	/*X subsample control*/
-	{OV5693_8BIT, 0x3815, 0x11},	/*Y subsample control*/
-	{OV5693_8BIT, 0x3820, 0x00},
-	{OV5693_8BIT, 0x3821, 0x1e},
-	{OV5693_8BIT, 0x5002, 0x00},
-	{OV5693_8BIT, 0x5041, 0x84}, /* scale is auto enabled */
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-
-};
-
-
-/*
- * 336x256 30fps 17ms VBlanking 2lane 10Bit (Scaling)
- DS from 2564x1956
- */
-static struct ov5693_reg const ov5693_336x256[] = {
-	{OV5693_8BIT, 0x3501, 0x3d},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe6},
-	{OV5693_8BIT, 0x3709, 0xc7},
-	{OV5693_8BIT, 0x3806, 0x07},
-	{OV5693_8BIT, 0x3807, 0xa3},
-	{OV5693_8BIT, 0x3808, 0x01},
-	{OV5693_8BIT, 0x3809, 0x50},
-	{OV5693_8BIT, 0x380a, 0x01},
-	{OV5693_8BIT, 0x380b, 0x00},
-	{OV5693_8BIT, 0x380c, 0x0a},
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07},
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3811, 0x1E},
-	{OV5693_8BIT, 0x3814, 0x31},
-	{OV5693_8BIT, 0x3815, 0x31},
-	{OV5693_8BIT, 0x3820, 0x04},
-	{OV5693_8BIT, 0x3821, 0x1f},
-	{OV5693_8BIT, 0x5002, 0x80},
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-
-/*
- * 336x256 30fps 17ms VBlanking 2lane 10Bit (Scaling)
- DS from 2368x1956
- */
-static struct ov5693_reg const ov5693_368x304[] = {
-	{OV5693_8BIT, 0x3501, 0x3d},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe6},
-	{OV5693_8BIT, 0x3709, 0xc7},
-	{OV5693_8BIT, 0x3808, 0x01},
-	{OV5693_8BIT, 0x3809, 0x70},
-	{OV5693_8BIT, 0x380a, 0x01},
-	{OV5693_8BIT, 0x380b, 0x30},
-	{OV5693_8BIT, 0x380c, 0x0a},
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07},
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3811, 0x80},
-	{OV5693_8BIT, 0x3814, 0x31},
-	{OV5693_8BIT, 0x3815, 0x31},
-	{OV5693_8BIT, 0x3820, 0x04},
-	{OV5693_8BIT, 0x3821, 0x1f},
-	{OV5693_8BIT, 0x5002, 0x80},
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-
-/*
- * ov5693_192x160 30fps 17ms VBlanking 2lane 10Bit (Scaling)
- DS from 2460x1956
- */
-static struct ov5693_reg const ov5693_192x160[] = {
-	{OV5693_8BIT, 0x3501, 0x7b},
-	{OV5693_8BIT, 0x3502, 0x80},
-	{OV5693_8BIT, 0x3708, 0xe2},
-	{OV5693_8BIT, 0x3709, 0xc3},
-	{OV5693_8BIT, 0x3804, 0x0a},
-	{OV5693_8BIT, 0x3805, 0x3f},
-	{OV5693_8BIT, 0x3806, 0x07},
-	{OV5693_8BIT, 0x3807, 0xA3},
-	{OV5693_8BIT, 0x3808, 0x00},
-	{OV5693_8BIT, 0x3809, 0xC0},
-	{OV5693_8BIT, 0x380a, 0x00},
-	{OV5693_8BIT, 0x380b, 0xA0},
-	{OV5693_8BIT, 0x380c, 0x0a},
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07},
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3811, 0x40},
-	{OV5693_8BIT, 0x3813, 0x00},
-	{OV5693_8BIT, 0x3814, 0x31},
-	{OV5693_8BIT, 0x3815, 0x31},
-	{OV5693_8BIT, 0x3820, 0x04},
-	{OV5693_8BIT, 0x3821, 0x1f},
-	{OV5693_8BIT, 0x5002, 0x80},
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-
-
-static struct ov5693_reg const ov5693_736x496[] = {
-	{OV5693_8BIT, 0x3501, 0x3d},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe6},
-	{OV5693_8BIT, 0x3709, 0xc7},
-	{OV5693_8BIT, 0x3803, 0x68},
-	{OV5693_8BIT, 0x3806, 0x07},
-	{OV5693_8BIT, 0x3807, 0x3b},
-	{OV5693_8BIT, 0x3808, 0x02},
-	{OV5693_8BIT, 0x3809, 0xe0},
-	{OV5693_8BIT, 0x380a, 0x01},
-	{OV5693_8BIT, 0x380b, 0xf0},
-	{OV5693_8BIT, 0x380c, 0x0a}, /*hts*/
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07}, /*vts*/
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3811, 0x08},
-	{OV5693_8BIT, 0x3813, 0x02},
-	{OV5693_8BIT, 0x3814, 0x31},
-	{OV5693_8BIT, 0x3815, 0x31},
-	{OV5693_8BIT, 0x3820, 0x04},
-	{OV5693_8BIT, 0x3821, 0x1f},
-	{OV5693_8BIT, 0x5002, 0x80},
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-#endif
-
-/*
-static struct ov5693_reg const ov5693_736x496[] = {
-	{OV5693_8BIT, 0x3501, 0x7b},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe6},
-	{OV5693_8BIT, 0x3709, 0xc3},
-	{OV5693_8BIT, 0x3803, 0x00},
-	{OV5693_8BIT, 0x3806, 0x07},
-	{OV5693_8BIT, 0x3807, 0xa3},
-	{OV5693_8BIT, 0x3808, 0x02},
-	{OV5693_8BIT, 0x3809, 0xe0},
-	{OV5693_8BIT, 0x380a, 0x01},
-	{OV5693_8BIT, 0x380b, 0xf0},
-	{OV5693_8BIT, 0x380c, 0x0d},
-	{OV5693_8BIT, 0x380d, 0xb0},
-	{OV5693_8BIT, 0x380e, 0x05},
-	{OV5693_8BIT, 0x380f, 0xf2},
-	{OV5693_8BIT, 0x3811, 0x08},
-	{OV5693_8BIT, 0x3813, 0x02},
-	{OV5693_8BIT, 0x3814, 0x31},
-	{OV5693_8BIT, 0x3815, 0x31},
-	{OV5693_8BIT, 0x3820, 0x01},
-	{OV5693_8BIT, 0x3821, 0x1f},
-	{OV5693_8BIT, 0x5002, 0x00},
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-*/
-/*
- * 976x556 30fps 8.8ms VBlanking 2lane 10Bit (Scaling)
- */
-#if ENABLE_NON_PREVIEW
-static struct ov5693_reg const ov5693_976x556[] = {
-	{OV5693_8BIT, 0x3501, 0x7b},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe2},
-	{OV5693_8BIT, 0x3709, 0xc3},
-	{OV5693_8BIT, 0x3803, 0xf0},
-	{OV5693_8BIT, 0x3806, 0x06},
-	{OV5693_8BIT, 0x3807, 0xa7},
-	{OV5693_8BIT, 0x3808, 0x03},
-	{OV5693_8BIT, 0x3809, 0xd0},
-	{OV5693_8BIT, 0x380a, 0x02},
-	{OV5693_8BIT, 0x380b, 0x2C},
-	{OV5693_8BIT, 0x380c, 0x0a},
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07},
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3811, 0x10},
-	{OV5693_8BIT, 0x3813, 0x02},
-	{OV5693_8BIT, 0x3814, 0x11},
-	{OV5693_8BIT, 0x3815, 0x11},
-	{OV5693_8BIT, 0x3820, 0x00},
-	{OV5693_8BIT, 0x3821, 0x1e},
-	{OV5693_8BIT, 0x5002, 0x80},
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-
-/*DS from 2624x1492*/
-static struct ov5693_reg const ov5693_1296x736[] = {
-	{OV5693_8BIT, 0x3501, 0x7b},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe2},
-	{OV5693_8BIT, 0x3709, 0xc3},
-
-	{OV5693_8BIT, 0x3800, 0x00},
-	{OV5693_8BIT, 0x3801, 0x00},
-	{OV5693_8BIT, 0x3802, 0x00},
-	{OV5693_8BIT, 0x3803, 0x00},
-
-	{OV5693_8BIT, 0x3804, 0x0a},
-	{OV5693_8BIT, 0x3805, 0x3f},
-	{OV5693_8BIT, 0x3806, 0x07},
-	{OV5693_8BIT, 0x3807, 0xA3},
-
-	{OV5693_8BIT, 0x3808, 0x05},
-	{OV5693_8BIT, 0x3809, 0x10},
-	{OV5693_8BIT, 0x380a, 0x02},
-	{OV5693_8BIT, 0x380b, 0xe0},
-
-	{OV5693_8BIT, 0x380c, 0x0a},
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07},
-	{OV5693_8BIT, 0x380f, 0xc0},
-
-	{OV5693_8BIT, 0x3813, 0xE8},
-
-	{OV5693_8BIT, 0x3814, 0x11},	/*X subsample control*/
-	{OV5693_8BIT, 0x3815, 0x11},	/*Y subsample control*/
-	{OV5693_8BIT, 0x3820, 0x00},
-	{OV5693_8BIT, 0x3821, 0x1e},
-	{OV5693_8BIT, 0x5002, 0x00},
-	{OV5693_8BIT, 0x5041, 0x84}, /* scale is auto enabled */
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-
-static struct ov5693_reg const ov5693_1636p_30fps[] = {
-	{OV5693_8BIT, 0x3501, 0x7b},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe2},
-	{OV5693_8BIT, 0x3709, 0xc3},
-	{OV5693_8BIT, 0x3803, 0xf0},
-	{OV5693_8BIT, 0x3806, 0x06},
-	{OV5693_8BIT, 0x3807, 0xa7},
-	{OV5693_8BIT, 0x3808, 0x06},
-	{OV5693_8BIT, 0x3809, 0x64},
-	{OV5693_8BIT, 0x380a, 0x04},
-	{OV5693_8BIT, 0x380b, 0x48},
-	{OV5693_8BIT, 0x380c, 0x0a}, /*hts*/
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07}, /*vts*/
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3811, 0x02},
-	{OV5693_8BIT, 0x3813, 0x02},
-	{OV5693_8BIT, 0x3814, 0x11},
-	{OV5693_8BIT, 0x3815, 0x11},
-	{OV5693_8BIT, 0x3820, 0x00},
-	{OV5693_8BIT, 0x3821, 0x1e},
-	{OV5693_8BIT, 0x5002, 0x80},
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-#endif
-
-static struct ov5693_reg const ov5693_1616x1216_30fps[] = {
-	{OV5693_8BIT, 0x3501, 0x7b},
-	{OV5693_8BIT, 0x3502, 0x80},
-	{OV5693_8BIT, 0x3708, 0xe2},
-	{OV5693_8BIT, 0x3709, 0xc3},
-	{OV5693_8BIT, 0x3800, 0x00},	/*{3800,3801} Array X start*/
-	{OV5693_8BIT, 0x3801, 0x08},	/* 04 //{3800,3801} Array X start*/
-	{OV5693_8BIT, 0x3802, 0x00},	/*{3802,3803} Array Y start*/
-	{OV5693_8BIT, 0x3803, 0x04},	/* 00  //{3802,3803} Array Y start*/
-	{OV5693_8BIT, 0x3804, 0x0a},	/*{3804,3805} Array X end*/
-	{OV5693_8BIT, 0x3805, 0x37},	/* 3b  //{3804,3805} Array X end*/
-	{OV5693_8BIT, 0x3806, 0x07},	/*{3806,3807} Array Y end*/
-	{OV5693_8BIT, 0x3807, 0x9f},	/* a3  //{3806,3807} Array Y end*/
-	{OV5693_8BIT, 0x3808, 0x06},	/*{3808,3809} Final output H size*/
-	{OV5693_8BIT, 0x3809, 0x50},	/*{3808,3809} Final output H size*/
-	{OV5693_8BIT, 0x380a, 0x04},	/*{380a,380b} Final output V size*/
-	{OV5693_8BIT, 0x380b, 0xc0},	/*{380a,380b} Final output V size*/
-	{OV5693_8BIT, 0x380c, 0x0a},	/*{380c,380d} HTS*/
-	{OV5693_8BIT, 0x380d, 0x80},	/*{380c,380d} HTS*/
-	{OV5693_8BIT, 0x380e, 0x07},	/*{380e,380f} VTS*/
-	{OV5693_8BIT, 0x380f, 0xc0},	/* bc	//{380e,380f} VTS*/
-	{OV5693_8BIT, 0x3810, 0x00},	/*{3810,3811} windowing X offset*/
-	{OV5693_8BIT, 0x3811, 0x10},	/*{3810,3811} windowing X offset*/
-	{OV5693_8BIT, 0x3812, 0x00},	/*{3812,3813} windowing Y offset*/
-	{OV5693_8BIT, 0x3813, 0x06},	/*{3812,3813} windowing Y offset*/
-	{OV5693_8BIT, 0x3814, 0x11},	/*X subsample control*/
-	{OV5693_8BIT, 0x3815, 0x11},	/*Y subsample control*/
-	{OV5693_8BIT, 0x3820, 0x00},	/*FLIP/Binnning control*/
-	{OV5693_8BIT, 0x3821, 0x1e},	/*MIRROR control*/
-	{OV5693_8BIT, 0x5002, 0x00},
-	{OV5693_8BIT, 0x5041, 0x84},
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-
-
-/*
- * 1940x1096 30fps 8.8ms VBlanking 2lane 10bit (Scaling)
- */
-#if ENABLE_NON_PREVIEW
-static struct ov5693_reg const ov5693_1940x1096[] = {
-	{OV5693_8BIT, 0x3501, 0x7b},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe2},
-	{OV5693_8BIT, 0x3709, 0xc3},
-	{OV5693_8BIT, 0x3803, 0xf0},
-	{OV5693_8BIT, 0x3806, 0x06},
-	{OV5693_8BIT, 0x3807, 0xa7},
-	{OV5693_8BIT, 0x3808, 0x07},
-	{OV5693_8BIT, 0x3809, 0x94},
-	{OV5693_8BIT, 0x380a, 0x04},
-	{OV5693_8BIT, 0x380b, 0x48},
-	{OV5693_8BIT, 0x380c, 0x0a},
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07},
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3811, 0x02},
-	{OV5693_8BIT, 0x3813, 0x02},
-	{OV5693_8BIT, 0x3814, 0x11},
-	{OV5693_8BIT, 0x3815, 0x11},
-	{OV5693_8BIT, 0x3820, 0x00},
-	{OV5693_8BIT, 0x3821, 0x1e},
-	{OV5693_8BIT, 0x5002, 0x80},
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-
-static struct ov5693_reg const ov5693_2592x1456_30fps[] = {
-	{OV5693_8BIT, 0x3501, 0x7b},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe2},
-	{OV5693_8BIT, 0x3709, 0xc3},
-	{OV5693_8BIT, 0x3800, 0x00},
-	{OV5693_8BIT, 0x3801, 0x00},
-	{OV5693_8BIT, 0x3802, 0x00},
-	{OV5693_8BIT, 0x3803, 0xf0},
-	{OV5693_8BIT, 0x3804, 0x0a},
-	{OV5693_8BIT, 0x3805, 0x3f},
-	{OV5693_8BIT, 0x3806, 0x06},
-	{OV5693_8BIT, 0x3807, 0xa4},
-	{OV5693_8BIT, 0x3808, 0x0a},
-	{OV5693_8BIT, 0x3809, 0x20},
-	{OV5693_8BIT, 0x380a, 0x05},
-	{OV5693_8BIT, 0x380b, 0xb0},
-	{OV5693_8BIT, 0x380c, 0x0a},
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07},
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3811, 0x10},
-	{OV5693_8BIT, 0x3813, 0x00},
-	{OV5693_8BIT, 0x3814, 0x11},
-	{OV5693_8BIT, 0x3815, 0x11},
-	{OV5693_8BIT, 0x3820, 0x00},
-	{OV5693_8BIT, 0x3821, 0x1e},
-	{OV5693_8BIT, 0x5002, 0x00},
-	{OV5693_TOK_TERM, 0, 0}
-};
-#endif
-
-static struct ov5693_reg const ov5693_2576x1456_30fps[] = {
-	{OV5693_8BIT, 0x3501, 0x7b},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe2},
-	{OV5693_8BIT, 0x3709, 0xc3},
-	{OV5693_8BIT, 0x3800, 0x00},
-	{OV5693_8BIT, 0x3801, 0x00},
-	{OV5693_8BIT, 0x3802, 0x00},
-	{OV5693_8BIT, 0x3803, 0xf0},
-	{OV5693_8BIT, 0x3804, 0x0a},
-	{OV5693_8BIT, 0x3805, 0x3f},
-	{OV5693_8BIT, 0x3806, 0x06},
-	{OV5693_8BIT, 0x3807, 0xa4},
-	{OV5693_8BIT, 0x3808, 0x0a},
-	{OV5693_8BIT, 0x3809, 0x10},
-	{OV5693_8BIT, 0x380a, 0x05},
-	{OV5693_8BIT, 0x380b, 0xb0},
-	{OV5693_8BIT, 0x380c, 0x0a},
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07},
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3811, 0x18},
-	{OV5693_8BIT, 0x3813, 0x00},
-	{OV5693_8BIT, 0x3814, 0x11},
-	{OV5693_8BIT, 0x3815, 0x11},
-	{OV5693_8BIT, 0x3820, 0x00},
-	{OV5693_8BIT, 0x3821, 0x1e},
-	{OV5693_8BIT, 0x5002, 0x00},
-	{OV5693_TOK_TERM, 0, 0}
-};
-
-/*
- * 2592x1944 30fps 0.6ms VBlanking 2lane 10Bit
- */
-#if ENABLE_NON_PREVIEW
-static struct ov5693_reg const ov5693_2592x1944_30fps[] = {
-	{OV5693_8BIT, 0x3501, 0x7b},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe2},
-	{OV5693_8BIT, 0x3709, 0xc3},
-	{OV5693_8BIT, 0x3803, 0x00},
-	{OV5693_8BIT, 0x3806, 0x07},
-	{OV5693_8BIT, 0x3807, 0xa3},
-	{OV5693_8BIT, 0x3808, 0x0a},
-	{OV5693_8BIT, 0x3809, 0x20},
-	{OV5693_8BIT, 0x380a, 0x07},
-	{OV5693_8BIT, 0x380b, 0x98},
-	{OV5693_8BIT, 0x380c, 0x0a},
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07},
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3811, 0x10},
-	{OV5693_8BIT, 0x3813, 0x00},
-	{OV5693_8BIT, 0x3814, 0x11},
-	{OV5693_8BIT, 0x3815, 0x11},
-	{OV5693_8BIT, 0x3820, 0x00},
-	{OV5693_8BIT, 0x3821, 0x1e},
-	{OV5693_8BIT, 0x5002, 0x00},
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-#endif
-
-/*
- * 11:9 Full FOV Output, expected FOV Res: 2346x1920
- * ISP Effect Res: 1408x1152
- * Sensor out: 1424x1168, DS From: 2380x1952
- *
- * WA: Left Offset: 8, Hor scal: 64
- */
-#if ENABLE_NON_PREVIEW
-static struct ov5693_reg const ov5693_1424x1168_30fps[] = {
-	{OV5693_8BIT, 0x3501, 0x3b}, /* long exposure[15:8] */
-	{OV5693_8BIT, 0x3502, 0x80}, /* long exposure[7:0] */
-	{OV5693_8BIT, 0x3708, 0xe2},
-	{OV5693_8BIT, 0x3709, 0xc3},
-	{OV5693_8BIT, 0x3800, 0x00}, /* TIMING_X_ADDR_START */
-	{OV5693_8BIT, 0x3801, 0x50}, /* 80 */
-	{OV5693_8BIT, 0x3802, 0x00}, /* TIMING_Y_ADDR_START */
-	{OV5693_8BIT, 0x3803, 0x02}, /* 2 */
-	{OV5693_8BIT, 0x3804, 0x09}, /* TIMING_X_ADDR_END */
-	{OV5693_8BIT, 0x3805, 0xdd}, /* 2525 */
-	{OV5693_8BIT, 0x3806, 0x07}, /* TIMING_Y_ADDR_END */
-	{OV5693_8BIT, 0x3807, 0xa1}, /* 1953 */
-	{OV5693_8BIT, 0x3808, 0x05}, /* TIMING_X_OUTPUT_SIZE */
-	{OV5693_8BIT, 0x3809, 0x90}, /* 1424 */
-	{OV5693_8BIT, 0x380a, 0x04}, /* TIMING_Y_OUTPUT_SIZE */
-	{OV5693_8BIT, 0x380b, 0x90}, /* 1168 */
-	{OV5693_8BIT, 0x380c, 0x0a}, /* TIMING_HTS */
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07}, /* TIMING_VTS */
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3810, 0x00}, /* TIMING_ISP_X_WIN */
-	{OV5693_8BIT, 0x3811, 0x02}, /* 2 */
-	{OV5693_8BIT, 0x3812, 0x00}, /* TIMING_ISP_Y_WIN */
-	{OV5693_8BIT, 0x3813, 0x00}, /* 0 */
-	{OV5693_8BIT, 0x3814, 0x11}, /* TIME_X_INC */
-	{OV5693_8BIT, 0x3815, 0x11}, /* TIME_Y_INC */
-	{OV5693_8BIT, 0x3820, 0x00},
-	{OV5693_8BIT, 0x3821, 0x1e},
-	{OV5693_8BIT, 0x5002, 0x00},
-	{OV5693_8BIT, 0x5041, 0x84}, /* scale is auto enabled */
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-#endif
-
-/*
- * 3:2 Full FOV Output, expected FOV Res: 2560x1706
- * ISP Effect Res: 720x480
- * Sensor out: 736x496, DS From 2616x1764
- */
-static struct ov5693_reg const ov5693_736x496_30fps[] = {
-	{OV5693_8BIT, 0x3501, 0x3b}, /* long exposure[15:8] */
-	{OV5693_8BIT, 0x3502, 0x80}, /* long exposure[7:0] */
-	{OV5693_8BIT, 0x3708, 0xe2},
-	{OV5693_8BIT, 0x3709, 0xc3},
-	{OV5693_8BIT, 0x3800, 0x00}, /* TIMING_X_ADDR_START */
-	{OV5693_8BIT, 0x3801, 0x02}, /* 2 */
-	{OV5693_8BIT, 0x3802, 0x00}, /* TIMING_Y_ADDR_START */
-	{OV5693_8BIT, 0x3803, 0x62}, /* 98 */
-	{OV5693_8BIT, 0x3804, 0x0a}, /* TIMING_X_ADDR_END */
-	{OV5693_8BIT, 0x3805, 0x3b}, /* 2619 */
-	{OV5693_8BIT, 0x3806, 0x07}, /* TIMING_Y_ADDR_END */
-	{OV5693_8BIT, 0x3807, 0x43}, /* 1859 */
-	{OV5693_8BIT, 0x3808, 0x02}, /* TIMING_X_OUTPUT_SIZE */
-	{OV5693_8BIT, 0x3809, 0xe0}, /* 736 */
-	{OV5693_8BIT, 0x380a, 0x01}, /* TIMING_Y_OUTPUT_SIZE */
-	{OV5693_8BIT, 0x380b, 0xf0}, /* 496 */
-	{OV5693_8BIT, 0x380c, 0x0a}, /* TIMING_HTS */
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07}, /* TIMING_VTS */
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3810, 0x00}, /* TIMING_ISP_X_WIN */
-	{OV5693_8BIT, 0x3811, 0x02}, /* 2 */
-	{OV5693_8BIT, 0x3812, 0x00}, /* TIMING_ISP_Y_WIN */
-	{OV5693_8BIT, 0x3813, 0x00}, /* 0 */
-	{OV5693_8BIT, 0x3814, 0x11}, /* TIME_X_INC */
-	{OV5693_8BIT, 0x3815, 0x11}, /* TIME_Y_INC */
-	{OV5693_8BIT, 0x3820, 0x00},
-	{OV5693_8BIT, 0x3821, 0x1e},
-	{OV5693_8BIT, 0x5002, 0x00},
-	{OV5693_8BIT, 0x5041, 0x84}, /* scale is auto enabled */
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-
-static struct ov5693_reg const ov5693_2576x1936_30fps[] = {
-	{OV5693_8BIT, 0x3501, 0x7b},
-	{OV5693_8BIT, 0x3502, 0x00},
-	{OV5693_8BIT, 0x3708, 0xe2},
-	{OV5693_8BIT, 0x3709, 0xc3},
-	{OV5693_8BIT, 0x3803, 0x00},
-	{OV5693_8BIT, 0x3806, 0x07},
-	{OV5693_8BIT, 0x3807, 0xa3},
-	{OV5693_8BIT, 0x3808, 0x0a},
-	{OV5693_8BIT, 0x3809, 0x10},
-	{OV5693_8BIT, 0x380a, 0x07},
-	{OV5693_8BIT, 0x380b, 0x90},
-	{OV5693_8BIT, 0x380c, 0x0a},
-	{OV5693_8BIT, 0x380d, 0x80},
-	{OV5693_8BIT, 0x380e, 0x07},
-	{OV5693_8BIT, 0x380f, 0xc0},
-	{OV5693_8BIT, 0x3811, 0x18},
-	{OV5693_8BIT, 0x3813, 0x00},
-	{OV5693_8BIT, 0x3814, 0x11},
-	{OV5693_8BIT, 0x3815, 0x11},
-	{OV5693_8BIT, 0x3820, 0x00},
-	{OV5693_8BIT, 0x3821, 0x1e},
-	{OV5693_8BIT, 0x5002, 0x00},
-	{OV5693_8BIT, 0x0100, 0x01},
-	{OV5693_TOK_TERM, 0, 0}
-};
-
-static struct ov5693_resolution ov5693_res_preview[] = {
-	{
-		.desc = "ov5693_736x496_30fps",
-		.width = 736,
-		.height = 496,
-		.pix_clk_freq = 160,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.regs = ov5693_736x496_30fps,
-	},
-	{
-		.desc = "ov5693_1616x1216_30fps",
-		.width = 1616,
-		.height = 1216,
-		.pix_clk_freq = 160,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.regs = ov5693_1616x1216_30fps,
-	},
-	{
-		.desc = "ov5693_5M_30fps",
-		.width = 2576,
-		.height = 1456,
-		.pix_clk_freq = 160,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.regs = ov5693_2576x1456_30fps,
-	},
-	{
-		.desc = "ov5693_5M_30fps",
-		.width = 2576,
-		.height = 1936,
-		.pix_clk_freq = 160,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.regs = ov5693_2576x1936_30fps,
-	},
-};
-#define N_RES_PREVIEW (ARRAY_SIZE(ov5693_res_preview))
-
-/*
- * Disable non-preview configurations until the configuration selection is
- * improved.
- */
-#if ENABLE_NON_PREVIEW
-struct ov5693_resolution ov5693_res_still[] = {
-	{
-		.desc = "ov5693_736x496_30fps",
-		.width = 736,
-		.height = 496,
-		.pix_clk_freq = 160,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.regs = ov5693_736x496_30fps,
-	},
-	{
-		.desc = "ov5693_1424x1168_30fps",
-		.width = 1424,
-		.height = 1168,
-		.pix_clk_freq = 160,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.regs = ov5693_1424x1168_30fps,
-	},
-	{
-		.desc = "ov5693_1616x1216_30fps",
-		.width = 1616,
-		.height = 1216,
-		.pix_clk_freq = 160,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.regs = ov5693_1616x1216_30fps,
-	},
-	{
-		.desc = "ov5693_5M_30fps",
-		.width = 2592,
-		.height = 1456,
-		.pix_clk_freq = 160,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.regs = ov5693_2592x1456_30fps,
-	},
-	{
-		.desc = "ov5693_5M_30fps",
-		.width = 2592,
-		.height = 1944,
-		.pix_clk_freq = 160,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.regs = ov5693_2592x1944_30fps,
-	},
-};
-#define N_RES_STILL (ARRAY_SIZE(ov5693_res_still))
-
-struct ov5693_resolution ov5693_res_video[] = {
-	{
-		.desc = "ov5693_736x496_30fps",
-		.width = 736,
-		.height = 496,
-		.fps = 30,
-		.pix_clk_freq = 160,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 2,
-		.bin_factor_y = 2,
-		.bin_mode = 1,
-		.regs = ov5693_736x496,
-	},
-	{
-		.desc = "ov5693_336x256_30fps",
-		.width = 336,
-		.height = 256,
-		.fps = 30,
-		.pix_clk_freq = 160,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 2,
-		.bin_factor_y = 2,
-		.bin_mode = 1,
-		.regs = ov5693_336x256,
-	},
-	{
-		.desc = "ov5693_368x304_30fps",
-		.width = 368,
-		.height = 304,
-		.fps = 30,
-		.pix_clk_freq = 160,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 2,
-		.bin_factor_y = 2,
-		.bin_mode = 1,
-		.regs = ov5693_368x304,
-	},
-	{
-		.desc = "ov5693_192x160_30fps",
-		.width = 192,
-		.height = 160,
-		.fps = 30,
-		.pix_clk_freq = 160,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 2,
-		.bin_factor_y = 2,
-		.bin_mode = 1,
-		.regs = ov5693_192x160,
-	},
-	{
-		.desc = "ov5693_1296x736_30fps",
-		.width = 1296,
-		.height = 736,
-		.fps = 30,
-		.pix_clk_freq = 160,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 2,
-		.bin_factor_y = 2,
-		.bin_mode = 0,
-		.regs = ov5693_1296x736,
-	},
-	{
-		.desc = "ov5693_1296x976_30fps",
-		.width = 1296,
-		.height = 976,
-		.fps = 30,
-		.pix_clk_freq = 160,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 2,
-		.bin_factor_y = 2,
-		.bin_mode = 0,
-		.regs = ov5693_1296x976,
-	},
-	{
-		.desc = "ov5693_1636P_30fps",
-		.width = 1636,
-		.height = 1096,
-		.fps = 30,
-		.pix_clk_freq = 160,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.regs = ov5693_1636p_30fps,
-	},
-	{
-		.desc = "ov5693_1080P_30fps",
-		.width = 1940,
-		.height = 1096,
-		.fps = 30,
-		.pix_clk_freq = 160,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.regs = ov5693_1940x1096,
-	},
-	{
-		.desc = "ov5693_5M_30fps",
-		.width = 2592,
-		.height = 1456,
-		.pix_clk_freq = 160,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.regs = ov5693_2592x1456_30fps,
-	},
-	{
-		.desc = "ov5693_5M_30fps",
-		.width = 2592,
-		.height = 1944,
-		.pix_clk_freq = 160,
-		.fps = 30,
-		.used = 0,
-		.pixels_per_line = 2688,
-		.lines_per_frame = 1984,
-		.bin_factor_x = 1,
-		.bin_factor_y = 1,
-		.bin_mode = 0,
-		.regs = ov5693_2592x1944_30fps,
-	},
-};
-#define N_RES_VIDEO (ARRAY_SIZE(ov5693_res_video))
-#endif
-
-static struct ov5693_resolution *ov5693_res = ov5693_res_preview;
-static unsigned long N_RES = N_RES_PREVIEW;
-#endif

+ 0 - 1359
drivers/staging/media/atomisp/include/linux/atomisp.h

@@ -1,1359 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- *
- */
-#ifdef CSS15
-#include <linux/atomisp_css15.h>
-#else
-
-#ifndef _ATOM_ISP_H
-#define _ATOM_ISP_H
-
-#include <linux/types.h>
-#include <linux/version.h>
-
-/* struct media_device_info.hw_revision */
-#define ATOMISP_HW_REVISION_MASK	0x0000ff00
-#define ATOMISP_HW_REVISION_SHIFT	8
-#define ATOMISP_HW_REVISION_ISP2300	0x00
-#define ATOMISP_HW_REVISION_ISP2400	0x10
-#define ATOMISP_HW_REVISION_ISP2401_LEGACY 0x11
-#define ATOMISP_HW_REVISION_ISP2401	0x20
-
-#define ATOMISP_HW_STEPPING_MASK	0x000000ff
-#define ATOMISP_HW_STEPPING_A0		0x00
-#define ATOMISP_HW_STEPPING_B0		0x10
-
-/*ISP binary running mode*/
-#define CI_MODE_PREVIEW		0x8000
-#define CI_MODE_VIDEO		0x4000
-#define CI_MODE_STILL_CAPTURE	0x2000
-#define CI_MODE_CONTINUOUS	0x1000
-#define CI_MODE_NONE		0x0000
-
-#define OUTPUT_MODE_FILE 0x0100
-#define OUTPUT_MODE_TEXT 0x0200
-
-/*
- * Camera HAL sets this flag in v4l2_buffer reserved2 to indicate this
- * buffer has a per-frame parameter.
- */
-#define ATOMISP_BUFFER_HAS_PER_FRAME_SETTING	0x80000000
-
-/* Custom format for RAW capture from M10MO 0x3130314d */
-#define V4L2_PIX_FMT_CUSTOM_M10MO_RAW	v4l2_fourcc('M', '1', '0', '1')
-
-/* Custom media bus formats being used in atomisp */
-#define V4L2_MBUS_FMT_CUSTOM_YUV420	0x8001
-#define V4L2_MBUS_FMT_CUSTOM_YVU420	0x8002
-#define V4L2_MBUS_FMT_CUSTOM_YUV422P	0x8003
-#define V4L2_MBUS_FMT_CUSTOM_YUV444	0x8004
-#define V4L2_MBUS_FMT_CUSTOM_NV12	0x8005
-#define V4L2_MBUS_FMT_CUSTOM_NV21	0x8006
-#define V4L2_MBUS_FMT_CUSTOM_NV16	0x8007
-#define V4L2_MBUS_FMT_CUSTOM_YUYV	0x8008
-#define V4L2_MBUS_FMT_CUSTOM_SBGGR16	0x8009
-#define V4L2_MBUS_FMT_CUSTOM_RGB32	0x800a
-
-/* Custom media bus format for M10MO RAW capture */
-#if 0
-#define V4L2_MBUS_FMT_CUSTOM_M10MO_RAW	0x800b
-#endif
-
-/* Configuration used by Bayer noise reduction and YCC noise reduction */
-struct atomisp_nr_config {
-	/* [gain] Strength of noise reduction for Bayer NR (Used by Bayer NR) */
-	unsigned int bnr_gain;
-	/* [gain] Strength of noise reduction for YCC NR (Used by YCC NR) */
-	unsigned int ynr_gain;
-	/* [intensity] Sensitivity of Edge (Used by Bayer NR) */
-	unsigned int direction;
-	/* [intensity] coring threshold for Cb (Used by YCC NR) */
-	unsigned int threshold_cb;
-	/* [intensity] coring threshold for Cr (Used by YCC NR) */
-	unsigned int threshold_cr;
-};
-
-/* Temporal noise reduction configuration */
-struct atomisp_tnr_config {
-	unsigned int gain;	 /* [gain] Strength of NR */
-	unsigned int threshold_y;/* [intensity] Motion sensitivity for Y */
-	unsigned int threshold_uv;/* [intensity] Motion sensitivity for U/V */
-};
-
-/* Histogram. This contains num_elements values of type unsigned int.
- * The data pointer is a DDR pointer (virtual address).
- */
-struct atomisp_histogram {
-	unsigned int num_elements;
-	void __user *data;
-};
-
-enum atomisp_ob_mode {
-	atomisp_ob_mode_none,
-	atomisp_ob_mode_fixed,
-	atomisp_ob_mode_raster
-};
-
-/* Optical black level configuration */
-struct atomisp_ob_config {
-	/* Obtical black level mode (Fixed / Raster) */
-	enum atomisp_ob_mode mode;
-	/* [intensity] optical black level for GR (relevant for fixed mode) */
-	unsigned int level_gr;
-	/* [intensity] optical black level for R (relevant for fixed mode) */
-	unsigned int level_r;
-	/* [intensity] optical black level for B (relevant for fixed mode) */
-	unsigned int level_b;
-	/* [intensity] optical black level for GB (relevant for fixed mode) */
-	unsigned int level_gb;
-	/* [BQ] 0..63 start position of OB area (relevant for raster mode) */
-	unsigned short start_position;
-	/* [BQ] start..63 end position of OB area (relevant for raster mode) */
-	unsigned short end_position;
-};
-
-/* Edge enhancement (sharpen) configuration */
-struct atomisp_ee_config {
-	/* [gain] The strength of sharpness. u5_11 */
-	unsigned int gain;
-	/* [intensity] The threshold that divides noises from edge. u8_8 */
-	unsigned int threshold;
-	/* [gain] The strength of sharpness in pell-mell area. u5_11 */
-	unsigned int detail_gain;
-};
-
-struct atomisp_3a_output {
-	int ae_y;
-	int awb_cnt;
-	int awb_gr;
-	int awb_r;
-	int awb_b;
-	int awb_gb;
-	int af_hpf1;
-	int af_hpf2;
-};
-
-enum atomisp_calibration_type {
-	calibration_type1,
-	calibration_type2,
-	calibration_type3
-};
-
-struct atomisp_calibration_group {
-	unsigned int size;
-	unsigned int type;
-	unsigned short *calb_grp_values;
-};
-
-struct atomisp_gc_config {
-	__u16 gain_k1;
-	__u16 gain_k2;
-};
-
-struct atomisp_3a_config {
-	unsigned int ae_y_coef_r;	/* [gain] Weight of R for Y */
-	unsigned int ae_y_coef_g;	/* [gain] Weight of G for Y */
-	unsigned int ae_y_coef_b;	/* [gain] Weight of B for Y */
-	unsigned int awb_lg_high_raw;	/* [intensity]
-					   AWB level gate high for raw */
-	unsigned int awb_lg_low;	/* [intensity] AWB level gate low */
-	unsigned int awb_lg_high;	/* [intensity] AWB level gate high */
-	int af_fir1_coef[7];	/* [factor] AF FIR coefficients of fir1 */
-	int af_fir2_coef[7];	/* [factor] AF FIR coefficients of fir2 */
-};
-
-struct atomisp_dvs_grid_info {
-	uint32_t enable;
-	uint32_t width;
-	uint32_t aligned_width;
-	uint32_t height;
-	uint32_t aligned_height;
-	uint32_t bqs_per_grid_cell;
-	uint32_t num_hor_coefs;
-	uint32_t num_ver_coefs;
-};
-
-struct atomisp_dvs_envelop {
-	unsigned int width;
-	unsigned int height;
-};
-
-struct atomisp_grid_info {
-	uint32_t enable;
-	uint32_t use_dmem;
-	uint32_t has_histogram;
-	uint32_t s3a_width;
-	uint32_t s3a_height;
-	uint32_t aligned_width;
-	uint32_t aligned_height;
-	uint32_t s3a_bqs_per_grid_cell;
-	uint32_t deci_factor_log2;
-	uint32_t elem_bit_depth;
-};
-
-struct atomisp_dis_vector {
-	int x;
-	int y;
-};
-
-
-/* DVS 2.0 Coefficient types. This structure contains 4 pointers to
- *  arrays that contain the coeffients for each type.
- */
-struct atomisp_dvs2_coef_types {
-	short __user *odd_real; /** real part of the odd coefficients*/
-	short __user *odd_imag; /** imaginary part of the odd coefficients*/
-	short __user *even_real;/** real part of the even coefficients*/
-	short __user *even_imag;/** imaginary part of the even coefficients*/
-};
-
-/*
- * DVS 2.0 Statistic types. This structure contains 4 pointers to
- * arrays that contain the statistics for each type.
- */
-struct atomisp_dvs2_stat_types {
-	int __user *odd_real; /** real part of the odd statistics*/
-	int __user *odd_imag; /** imaginary part of the odd statistics*/
-	int __user *even_real;/** real part of the even statistics*/
-	int __user *even_imag;/** imaginary part of the even statistics*/
-};
-
-struct atomisp_dis_coefficients {
-	struct atomisp_dvs_grid_info grid_info;
-	struct atomisp_dvs2_coef_types hor_coefs;
-	struct atomisp_dvs2_coef_types ver_coefs;
-};
-
-struct atomisp_dvs2_statistics {
-	struct atomisp_dvs_grid_info grid_info;
-	struct atomisp_dvs2_stat_types hor_prod;
-	struct atomisp_dvs2_stat_types ver_prod;
-};
-
-struct atomisp_dis_statistics {
-	struct atomisp_dvs2_statistics dvs2_stat;
-	uint32_t exp_id;
-};
-
-struct atomisp_3a_rgby_output {
-	uint32_t r;
-	uint32_t g;
-	uint32_t b;
-	uint32_t y;
-};
-
-/*
- * Because we have 2 pipes at max to output metadata, therefore driver will use
- * ATOMISP_MAIN_METADATA to specify the metadata from the pipe which keeps
- * streaming always and use ATOMISP_SEC_METADATA to specify the metadata from
- * the pipe which is streaming by request like capture pipe of ZSL or SDV mode
- * as secondary metadata. And for the use case which has only one pipe
- * streaming like online capture, ATOMISP_MAIN_METADATA will be used.
- */
-enum atomisp_metadata_type {
-	ATOMISP_MAIN_METADATA = 0,
-	ATOMISP_SEC_METADATA,
-	ATOMISP_METADATA_TYPE_NUM,
-};
-
-struct atomisp_metadata_with_type {
-	/* to specify which type of metadata to get */
-	enum atomisp_metadata_type type;
-	void __user *data;
-	uint32_t width;
-	uint32_t height;
-	uint32_t stride; /* in bytes */
-	uint32_t exp_id; /* exposure ID */
-	uint32_t *effective_width; /* mipi packets valid data size */
-};
-
-struct atomisp_metadata {
-	void __user *data;
-	uint32_t width;
-	uint32_t height;
-	uint32_t stride; /* in bytes */
-	uint32_t exp_id; /* exposure ID */
-	uint32_t *effective_width; /* mipi packets valid data size */
-};
-
-struct atomisp_ext_isp_ctrl {
-	uint32_t id;
-	uint32_t data;
-};
-
-struct atomisp_3a_statistics {
-	struct atomisp_grid_info  grid_info;
-	struct atomisp_3a_output __user *data;
-	struct atomisp_3a_rgby_output __user *rgby_data;
-	uint32_t exp_id; /* exposure ID */
-	uint32_t isp_config_id; /* isp config ID */
-};
-
-/**
- * struct atomisp_cont_capture_conf - continuous capture parameters
- * @num_captures: number of still images to capture
- * @skip_frames: number of frames to skip between 2 captures
- * @offset: offset in ring buffer to start capture
- *
- * For example, to capture 1 frame from past, current, and 1 from future
- * and skip one frame between each capture, parameters would be:
- * num_captures:3
- * skip_frames:1
- * offset:-2
- */
-
-struct atomisp_cont_capture_conf {
-	int num_captures;
-	unsigned int skip_frames;
-	int offset;
-	__u32 reserved[5];
-};
-
-struct atomisp_ae_window {
-	int x_left;
-	int x_right;
-	int y_top;
-	int y_bottom;
-	int weight;
-};
-
-/* White Balance (Gain Adjust) */
-struct atomisp_wb_config {
-	unsigned int integer_bits;
-	unsigned int gr;	/* unsigned <integer_bits>.<16-integer_bits> */
-	unsigned int r;		/* unsigned <integer_bits>.<16-integer_bits> */
-	unsigned int b;		/* unsigned <integer_bits>.<16-integer_bits> */
-	unsigned int gb;	/* unsigned <integer_bits>.<16-integer_bits> */
-};
-
-/* Color Space Conversion settings */
-struct atomisp_cc_config {
-	unsigned int fraction_bits;
-	int matrix[3 * 3];	/* RGB2YUV Color matrix, signed
-				   <13-fraction_bits>.<fraction_bits> */
-};
-
-/* De pixel noise configuration */
-struct atomisp_de_config {
-	unsigned int pixelnoise;
-	unsigned int c1_coring_threshold;
-	unsigned int c2_coring_threshold;
-};
-
-/* Chroma enhancement */
-struct atomisp_ce_config {
-	unsigned char uv_level_min;
-	unsigned char uv_level_max;
-};
-
-/* Defect pixel correction configuration */
-struct atomisp_dp_config {
-	/* [intensity] The threshold of defect Pixel Correction, representing
-	 * the permissible difference of intensity between one pixel and its
-	 * surrounding pixels. Smaller values result in more frequent pixel
-	 * corrections. u0_16
-	 */
-	unsigned int threshold;
-	/* [gain] The sensitivity of mis-correction. ISP will miss a lot of
-	 * defects if the value is set too large. u8_8
-	 */
-	unsigned int gain;
-	unsigned int gr;
-	unsigned int r;
-	unsigned int b;
-	unsigned int gb;
-};
-
-/* XNR threshold */
-struct atomisp_xnr_config {
-	__u16 threshold;
-};
-
-/* metadata config */
-struct atomisp_metadata_config {
-	uint32_t metadata_height;
-	uint32_t metadata_stride;
-};
-
-/*
- * Generic resolution structure.
- */
-struct atomisp_resolution {
-	uint32_t width;  /** Width */
-	uint32_t height; /** Height */
-};
-
-/*
- * This specifies the coordinates (x,y)
- */
-struct atomisp_zoom_point {
-	int32_t x; /** x coordinate */
-	int32_t y; /** y coordinate */
-};
-
-/*
- * This specifies the region
- */
-struct atomisp_zoom_region {
-	struct atomisp_zoom_point origin; /* Starting point coordinates for the region */
-	struct atomisp_resolution resolution; /* Region resolution */
-};
-
-struct atomisp_dz_config {
-	uint32_t dx; /** Horizontal zoom factor */
-	uint32_t dy; /** Vertical zoom factor */
-	struct atomisp_zoom_region zoom_region; /** region for zoom */
-};
-
-struct atomisp_parm {
-	struct atomisp_grid_info info;
-	struct atomisp_dvs_grid_info dvs_grid;
-	struct atomisp_dvs_envelop dvs_envelop;
-	struct atomisp_wb_config wb_config;
-	struct atomisp_cc_config cc_config;
-	struct atomisp_ob_config ob_config;
-	struct atomisp_de_config de_config;
-	struct atomisp_dz_config dz_config;
-	struct atomisp_ce_config ce_config;
-	struct atomisp_dp_config dp_config;
-	struct atomisp_nr_config nr_config;
-	struct atomisp_ee_config ee_config;
-	struct atomisp_tnr_config tnr_config;
-	struct atomisp_metadata_config metadata_config;
-};
-
-struct dvs2_bq_resolution {
-	int width_bq;         /* width [BQ] */
-	int height_bq;        /* height [BQ] */
-};
-
-struct atomisp_dvs2_bq_resolutions {
-	/* GDC source image size [BQ] */
-	struct dvs2_bq_resolution source_bq;
-	/* GDC output image size [BQ] */
-	struct dvs2_bq_resolution output_bq;
-	/* GDC effective envelope size [BQ] */
-	struct dvs2_bq_resolution envelope_bq;
-	/* isp pipe filter size [BQ] */
-	struct dvs2_bq_resolution ispfilter_bq;
-	/* GDC shit size [BQ] */
-	struct dvs2_bq_resolution gdc_shift_bq;
-};
-
-struct atomisp_dvs_6axis_config {
-	uint32_t exp_id;
-	uint32_t width_y;
-	uint32_t height_y;
-	uint32_t width_uv;
-	uint32_t height_uv;
-	uint32_t *xcoords_y;
-	uint32_t *ycoords_y;
-	uint32_t *xcoords_uv;
-	uint32_t *ycoords_uv;
-};
-
-struct atomisp_formats_config {
-	uint32_t video_full_range_flag;
-};
-
-struct atomisp_parameters {
-	struct atomisp_wb_config   *wb_config;  /* White Balance config */
-	struct atomisp_cc_config   *cc_config;  /* Color Correction config */
-	struct atomisp_tnr_config  *tnr_config; /* Temporal Noise Reduction */
-	struct atomisp_ecd_config  *ecd_config; /* Eigen Color Demosaicing */
-	struct atomisp_ynr_config  *ynr_config; /* Y(Luma) Noise Reduction */
-	struct atomisp_fc_config   *fc_config;  /* Fringe Control */
-	struct atomisp_formats_config *formats_config; /* Formats Control */
-	struct atomisp_cnr_config  *cnr_config; /* Chroma Noise Reduction */
-	struct atomisp_macc_config *macc_config;  /* MACC */
-	struct atomisp_ctc_config  *ctc_config; /* Chroma Tone Control */
-	struct atomisp_aa_config   *aa_config;  /* Anti-Aliasing */
-	struct atomisp_aa_config   *baa_config;  /* Anti-Aliasing */
-	struct atomisp_ce_config   *ce_config;
-	struct atomisp_dvs_6axis_config *dvs_6axis_config;
-	struct atomisp_ob_config   *ob_config;  /* Objective Black config */
-	struct atomisp_dp_config   *dp_config;  /* Dead Pixel config */
-	struct atomisp_nr_config   *nr_config;  /* Noise Reduction config */
-	struct atomisp_ee_config   *ee_config;  /* Edge Enhancement config */
-	struct atomisp_de_config   *de_config;  /* Demosaic config */
-	struct atomisp_gc_config   *gc_config;  /* Gamma Correction config */
-	struct atomisp_anr_config  *anr_config; /* Advanced Noise Reduction */
-	struct atomisp_3a_config   *a3a_config; /* 3A Statistics config */
-	struct atomisp_xnr_config  *xnr_config; /* eXtra Noise Reduction */
-	struct atomisp_dz_config   *dz_config;  /* Digital Zoom */
-	struct atomisp_cc_config *yuv2rgb_cc_config; /* Color
-							Correction config */
-	struct atomisp_cc_config *rgb2yuv_cc_config; /* Color
-							Correction config */
-	struct atomisp_macc_table  *macc_table;
-	struct atomisp_gamma_table *gamma_table;
-	struct atomisp_ctc_table   *ctc_table;
-	struct atomisp_xnr_table   *xnr_table;
-	struct atomisp_rgb_gamma_table *r_gamma_table;
-	struct atomisp_rgb_gamma_table *g_gamma_table;
-	struct atomisp_rgb_gamma_table *b_gamma_table;
-	struct atomisp_vector      *motion_vector; /* For 2-axis DVS */
-	struct atomisp_shading_table *shading_table;
-	struct atomisp_morph_table   *morph_table;
-	struct atomisp_dvs_coefficients *dvs_coefs; /* DVS 1.0 coefficients */
-	struct atomisp_dvs2_coefficients *dvs2_coefs; /* DVS 2.0 coefficients */
-	struct atomisp_capture_config   *capture_config;
-	struct atomisp_anr_thres   *anr_thres;
-
-	void	*lin_2500_config;       /* Skylake: Linearization config */
-	void	*obgrid_2500_config;    /* Skylake: OBGRID config */
-	void	*bnr_2500_config;       /* Skylake: bayer denoise config */
-	void	*shd_2500_config;       /* Skylake: shading config */
-	void	*dm_2500_config;        /* Skylake: demosaic config */
-	void	*rgbpp_2500_config;     /* Skylake: RGBPP config */
-	void	*dvs_stat_2500_config;  /* Skylake: DVS STAT config */
-	void	*lace_stat_2500_config; /* Skylake: LACE STAT config */
-	void	*yuvp1_2500_config;     /* Skylake: yuvp1 config */
-	void	*yuvp2_2500_config;     /* Skylake: yuvp2 config */
-	void	*tnr_2500_config;       /* Skylake: TNR config */
-	void	*dpc_2500_config;       /* Skylake: DPC config */
-	void	*awb_2500_config;       /* Skylake: auto white balance config */
-	void	*awb_fr_2500_config;    /* Skylake: auto white balance filter response config */
-	void	*anr_2500_config;       /* Skylake: ANR config */
-	void	*af_2500_config;        /* Skylake: auto focus config */
-	void	*ae_2500_config;        /* Skylake: auto exposure config */
-	void	*bds_2500_config;       /* Skylake: bayer downscaler config */
-	void	*dvs_2500_config;       /* Skylake: digital video stabilization config */
-	void	*res_mgr_2500_config;
-
-	/*
-	 * Output frame pointer the config is to be applied to (optional),
-	 * set to NULL to make this config is applied as global.
-	 */
-	void	*output_frame;
-	/*
-	 * Unique ID to track which config was actually applied to a particular
-	 * frame, driver will send this id back with output frame together.
-	 */
-	uint32_t	isp_config_id;
-
-	/*
-	 * Switch to control per_frame setting:
-	 * 0: this is a global setting
-	 * 1: this is a per_frame setting
-	 * PLEASE KEEP THIS AT THE END OF THE STRUCTURE!!
-	 */
-	uint32_t	per_frame_setting;
-};
-
-#define ATOMISP_GAMMA_TABLE_SIZE        1024
-struct atomisp_gamma_table {
-	unsigned short data[ATOMISP_GAMMA_TABLE_SIZE];
-};
-
-/* Morphing table for advanced ISP.
- * Each line of width elements takes up COORD_TABLE_EXT_WIDTH elements
- * in memory.
- */
-#define ATOMISP_MORPH_TABLE_NUM_PLANES  6
-struct atomisp_morph_table {
-	unsigned int enabled;
-
-	unsigned int height;
-	unsigned int width;	/* number of valid elements per line */
-	unsigned short __user *coordinates_x[ATOMISP_MORPH_TABLE_NUM_PLANES];
-	unsigned short __user *coordinates_y[ATOMISP_MORPH_TABLE_NUM_PLANES];
-};
-
-#define ATOMISP_NUM_SC_COLORS	4
-#define ATOMISP_SC_FLAG_QUERY	(1 << 0)
-
-struct atomisp_shading_table {
-	__u32 enable;
-
-	__u32 sensor_width;
-	__u32 sensor_height;
-	__u32 width;
-	__u32 height;
-	__u32 fraction_bits;
-
-	__u16 *data[ATOMISP_NUM_SC_COLORS];
-};
-
-struct atomisp_makernote_info {
-	/* bits 31-16: numerator, bits 15-0: denominator */
-	unsigned int focal_length;
-	/* bits 31-16: numerator, bits 15-0: denominator*/
-	unsigned int f_number_curr;
-	/*
-	* bits 31-24: max f-number numerator
-	* bits 23-16: max f-number denominator
-	* bits 15-8: min f-number numerator
-	* bits 7-0: min f-number denominator
-	*/
-	unsigned int f_number_range;
-};
-
-/* parameter for MACC */
-#define ATOMISP_NUM_MACC_AXES           16
-struct atomisp_macc_table {
-	short data[4 * ATOMISP_NUM_MACC_AXES];
-};
-
-struct atomisp_macc_config {
-	int color_effect;
-	struct atomisp_macc_table table;
-};
-
-/* Parameter for ctc parameter control */
-#define ATOMISP_CTC_TABLE_SIZE          1024
-struct atomisp_ctc_table {
-	unsigned short data[ATOMISP_CTC_TABLE_SIZE];
-};
-
-/* Parameter for overlay image loading */
-struct atomisp_overlay {
-	/* the frame containing the overlay data The overlay frame width should
-	 * be the multiples of 2*ISP_VEC_NELEMS. The overlay frame height
-	 * should be the multiples of 2.
-	 */
-	struct v4l2_framebuffer *frame;
-	/* Y value of overlay background */
-	unsigned char bg_y;
-	/* U value of overlay background */
-	char bg_u;
-	/* V value of overlay background */
-	char bg_v;
-	/* the blending percent of input data for Y subpixels */
-	unsigned char blend_input_perc_y;
-	/* the blending percent of input data for U subpixels */
-	unsigned char blend_input_perc_u;
-	/* the blending percent of input data for V subpixels */
-	unsigned char blend_input_perc_v;
-	/* the blending percent of overlay data for Y subpixels */
-	unsigned char blend_overlay_perc_y;
-	/* the blending percent of overlay data for U subpixels */
-	unsigned char blend_overlay_perc_u;
-	/* the blending percent of overlay data for V subpixels */
-	unsigned char blend_overlay_perc_v;
-	/* the overlay start x pixel position on output frame It should be the
-	   multiples of 2*ISP_VEC_NELEMS. */
-	unsigned int overlay_start_x;
-	/* the overlay start y pixel position on output frame It should be the
-	   multiples of 2. */
-	unsigned int overlay_start_y;
-};
-
-/* Sensor resolution specific data for AE calculation.*/
-struct atomisp_sensor_mode_data {
-	unsigned int coarse_integration_time_min;
-	unsigned int coarse_integration_time_max_margin;
-	unsigned int fine_integration_time_min;
-	unsigned int fine_integration_time_max_margin;
-	unsigned int fine_integration_time_def;
-	unsigned int frame_length_lines;
-	unsigned int line_length_pck;
-	unsigned int read_mode;
-	unsigned int vt_pix_clk_freq_mhz;
-	unsigned int crop_horizontal_start; /* Sensor crop start cord. (x0,y0)*/
-	unsigned int crop_vertical_start;
-	unsigned int crop_horizontal_end; /* Sensor crop end cord. (x1,y1)*/
-	unsigned int crop_vertical_end;
-	unsigned int output_width; /* input size to ISP after binning/scaling */
-	unsigned int output_height;
-	uint8_t binning_factor_x; /* horizontal binning factor used */
-	uint8_t binning_factor_y; /* vertical binning factor used */
-	uint16_t hts;
-};
-
-struct atomisp_exposure {
-	unsigned int integration_time[8];
-	unsigned int shutter_speed[8];
-	unsigned int gain[4];
-	unsigned int aperture;
-};
-
-/* For texture streaming. */
-struct atomisp_bc_video_package {
-	int ioctl_cmd;
-	int device_id;
-	int inputparam;
-	int outputparam;
-};
-
-enum atomisp_focus_hp {
-	ATOMISP_FOCUS_HP_IN_PROGRESS = (1U << 2),
-	ATOMISP_FOCUS_HP_COMPLETE    = (2U << 2),
-	ATOMISP_FOCUS_HP_FAILED      = (3U << 2)
-};
-
-/* Masks */
-#define ATOMISP_FOCUS_STATUS_MOVING           (1U << 0)
-#define ATOMISP_FOCUS_STATUS_ACCEPTS_NEW_MOVE (1U << 1)
-#define ATOMISP_FOCUS_STATUS_HOME_POSITION    (3U << 2)
-
-enum atomisp_camera_port {
-	ATOMISP_CAMERA_PORT_SECONDARY,
-	ATOMISP_CAMERA_PORT_PRIMARY,
-	ATOMISP_CAMERA_PORT_TERTIARY,
-	ATOMISP_CAMERA_NR_PORTS
-};
-
-/* Flash modes. Default is off.
- * Setting a flash to TORCH or INDICATOR mode will automatically
- * turn it on. Setting it to FLASH mode will not turn on the flash
- * until the FLASH_STROBE command is sent. */
-enum atomisp_flash_mode {
-	ATOMISP_FLASH_MODE_OFF,
-	ATOMISP_FLASH_MODE_FLASH,
-	ATOMISP_FLASH_MODE_TORCH,
-	ATOMISP_FLASH_MODE_INDICATOR,
-};
-
-/* Flash statuses, used by atomisp driver to check before starting
- * flash and after having started flash. */
-enum atomisp_flash_status {
-	ATOMISP_FLASH_STATUS_OK,
-	ATOMISP_FLASH_STATUS_HW_ERROR,
-	ATOMISP_FLASH_STATUS_INTERRUPTED,
-	ATOMISP_FLASH_STATUS_TIMEOUT,
-};
-
-/* Frame status. This is used to detect corrupted frames and flash
- * exposed frames. Usually, the first 2 frames coming out of the sensor
- * are corrupted. When using flash, the frame before and the frame after
- * the flash exposed frame may be partially exposed by flash. The ISP
- * statistics for these frames should not be used by the 3A library.
- * The frame status value can be found in the "reserved" field in the
- * v4l2_buffer struct. */
-enum atomisp_frame_status {
-	ATOMISP_FRAME_STATUS_OK,
-	ATOMISP_FRAME_STATUS_CORRUPTED,
-	ATOMISP_FRAME_STATUS_FLASH_EXPOSED,
-	ATOMISP_FRAME_STATUS_FLASH_PARTIAL,
-	ATOMISP_FRAME_STATUS_FLASH_FAILED,
-};
-
-enum atomisp_acc_type {
-	ATOMISP_ACC_STANDALONE,	/* Stand-alone acceleration */
-	ATOMISP_ACC_OUTPUT,	/* Accelerator stage on output frame */
-	ATOMISP_ACC_VIEWFINDER	/* Accelerator stage on viewfinder frame */
-};
-
-enum atomisp_acc_arg_type {
-	ATOMISP_ACC_ARG_SCALAR_IN,    /* Scalar input argument */
-	ATOMISP_ACC_ARG_SCALAR_OUT,   /* Scalar output argument */
-	ATOMISP_ACC_ARG_SCALAR_IO,    /* Scalar in/output argument */
-	ATOMISP_ACC_ARG_PTR_IN,	     /* Pointer input argument */
-	ATOMISP_ACC_ARG_PTR_OUT,	     /* Pointer output argument */
-	ATOMISP_ACC_ARG_PTR_IO,	     /* Pointer in/output argument */
-	ATOMISP_ARG_PTR_NOFLUSH,  /* Pointer argument will not be flushed */
-	ATOMISP_ARG_PTR_STABLE,   /* Pointer input argument that is stable */
-	ATOMISP_ACC_ARG_FRAME	     /* Frame argument */
-};
-
-/* ISP memories, isp2400 */
-enum atomisp_acc_memory {
-	ATOMISP_ACC_MEMORY_PMEM0 = 0,
-	ATOMISP_ACC_MEMORY_DMEM0,
-	/* for backward compatibility */
-	ATOMISP_ACC_MEMORY_DMEM = ATOMISP_ACC_MEMORY_DMEM0,
-	ATOMISP_ACC_MEMORY_VMEM0,
-	ATOMISP_ACC_MEMORY_VAMEM0,
-	ATOMISP_ACC_MEMORY_VAMEM1,
-	ATOMISP_ACC_MEMORY_VAMEM2,
-	ATOMISP_ACC_MEMORY_HMEM0,
-	ATOMISP_ACC_NR_MEMORY
-};
-
-enum atomisp_ext_isp_id {
-	EXT_ISP_CID_ISO = 0,
-	EXT_ISP_CID_CAPTURE_HDR,
-	EXT_ISP_CID_CAPTURE_LLS,
-	EXT_ISP_CID_FOCUS_MODE,
-	EXT_ISP_CID_FOCUS_EXECUTION,
-	EXT_ISP_CID_TOUCH_POSX,
-	EXT_ISP_CID_TOUCH_POSY,
-	EXT_ISP_CID_CAF_STATUS,
-	EXT_ISP_CID_AF_STATUS,
-	EXT_ISP_CID_GET_AF_MODE,
-	EXT_ISP_CID_CAPTURE_BURST,
-	EXT_ISP_CID_FLASH_MODE,
-	EXT_ISP_CID_ZOOM,
-	EXT_ISP_CID_SHOT_MODE
-};
-
-#define EXT_ISP_FOCUS_MODE_NORMAL	0
-#define EXT_ISP_FOCUS_MODE_MACRO	1
-#define EXT_ISP_FOCUS_MODE_TOUCH_AF	2
-#define EXT_ISP_FOCUS_MODE_PREVIEW_CAF	3
-#define EXT_ISP_FOCUS_MODE_MOVIE_CAF	4
-#define EXT_ISP_FOCUS_MODE_FACE_CAF	5
-#define EXT_ISP_FOCUS_MODE_TOUCH_MACRO	6
-#define EXT_ISP_FOCUS_MODE_TOUCH_CAF	7
-
-#define EXT_ISP_FOCUS_STOP		0
-#define EXT_ISP_FOCUS_SEARCH		1
-#define EXT_ISP_PAN_FOCUSING		2
-
-#define EXT_ISP_CAF_RESTART_CHECK	1
-#define EXT_ISP_CAF_STATUS_FOCUSING	2
-#define EXT_ISP_CAF_STATUS_SUCCESS	3
-#define EXT_ISP_CAF_STATUS_FAIL         4
-
-#define EXT_ISP_AF_STATUS_INVALID	1
-#define EXT_ISP_AF_STATUS_FOCUSING	2
-#define EXT_ISP_AF_STATUS_SUCCESS	3
-#define EXT_ISP_AF_STATUS_FAIL		4
-
-enum atomisp_burst_capture_options {
-	EXT_ISP_BURST_CAPTURE_CTRL_START = 0,
-	EXT_ISP_BURST_CAPTURE_CTRL_STOP
-};
-
-#define EXT_ISP_FLASH_MODE_OFF		0
-#define EXT_ISP_FLASH_MODE_ON		1
-#define EXT_ISP_FLASH_MODE_AUTO		2
-#define EXT_ISP_LED_TORCH_OFF		3
-#define EXT_ISP_LED_TORCH_ON		4
-
-#define EXT_ISP_SHOT_MODE_AUTO		0
-#define EXT_ISP_SHOT_MODE_BEAUTY_FACE	1
-#define EXT_ISP_SHOT_MODE_BEST_PHOTO	2
-#define EXT_ISP_SHOT_MODE_DRAMA		3
-#define EXT_ISP_SHOT_MODE_BEST_FACE	4
-#define EXT_ISP_SHOT_MODE_ERASER	5
-#define EXT_ISP_SHOT_MODE_PANORAMA	6
-#define EXT_ISP_SHOT_MODE_RICH_TONE_HDR	7
-#define EXT_ISP_SHOT_MODE_NIGHT		8
-#define EXT_ISP_SHOT_MODE_SOUND_SHOT	9
-#define EXT_ISP_SHOT_MODE_ANIMATED_PHOTO	10
-#define EXT_ISP_SHOT_MODE_SPORTS	11
-
-struct atomisp_sp_arg {
-	enum atomisp_acc_arg_type type;	/* Type  of SP argument */
-	void                    *value;	/* Value of SP argument */
-	unsigned int             size;	/* Size  of SP argument */
-};
-
-/* Acceleration API */
-
-/* For CSS 1.0 only */
-struct atomisp_acc_fw_arg {
-	unsigned int fw_handle;
-	unsigned int index;
-	void __user *value;
-	size_t size;
-};
-
-/*
- * Set arguments after first mapping with ATOMISP_IOC_ACC_S_MAPPED_ARG.
- */
-struct atomisp_acc_s_mapped_arg {
-	unsigned int fw_handle;
-	__u32 memory;			/* one of enum atomisp_acc_memory */
-	size_t length;
-	unsigned long css_ptr;
-};
-
-struct atomisp_acc_fw_abort {
-	unsigned int fw_handle;
-	/* Timeout in us */
-	unsigned int timeout;
-};
-
-struct atomisp_acc_fw_load {
-	unsigned int size;
-	unsigned int fw_handle;
-	void __user *data;
-};
-
-/*
- * Load firmware to specified pipeline.
- */
-struct atomisp_acc_fw_load_to_pipe {
-	__u32 flags;			/* Flags, see below for valid values */
-	unsigned int fw_handle;		/* Handle, filled by kernel. */
-	__u32 size;			/* Firmware binary size */
-	void __user *data;		/* Pointer to firmware */
-	__u32 type;			/* Binary type */
-	__u32 reserved[3];		/* Set to zero */
-};
-/*
- * Set Senor run mode
- */
-struct atomisp_s_runmode {
-	__u32 mode;
-};
-
-#define ATOMISP_ACC_FW_LOAD_FL_PREVIEW		(1 << 0)
-#define ATOMISP_ACC_FW_LOAD_FL_COPY		(1 << 1)
-#define ATOMISP_ACC_FW_LOAD_FL_VIDEO		(1 << 2)
-#define ATOMISP_ACC_FW_LOAD_FL_CAPTURE		(1 << 3)
-#define ATOMISP_ACC_FW_LOAD_FL_ACC		(1 << 4)
-#define ATOMISP_ACC_FW_LOAD_FL_ENABLE		(1 << 16)
-
-#define ATOMISP_ACC_FW_LOAD_TYPE_NONE		0 /* Normal binary: don't use */
-#define ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT		1 /* Stage on output */
-#define ATOMISP_ACC_FW_LOAD_TYPE_VIEWFINDER	2 /* Stage on viewfinder */
-#define ATOMISP_ACC_FW_LOAD_TYPE_STANDALONE	3 /* Stand-alone acceleration */
-
-struct atomisp_acc_map {
-	__u32 flags;			/* Flags, see list below */
-	__u32 length;			/* Length of data in bytes */
-	void __user *user_ptr;		/* Pointer into user space */
-	unsigned long css_ptr;		/* Pointer into CSS address space */
-	__u32 reserved[4];		/* Set to zero */
-};
-
-#define ATOMISP_MAP_FLAG_NOFLUSH	0x0001	/* Do not flush cache */
-#define ATOMISP_MAP_FLAG_CACHED		0x0002	/* Enable cache */
-
-struct atomisp_acc_state {
-	__u32 flags;			/* Flags, see list below */
-#define ATOMISP_STATE_FLAG_ENABLE	ATOMISP_ACC_FW_LOAD_FL_ENABLE
-	unsigned int fw_handle;
-};
-
-struct atomisp_update_exposure {
-	unsigned int gain;
-	unsigned int digi_gain;
-	unsigned int update_gain;
-	unsigned int update_digi_gain;
-};
-
-/*
- * V4L2 private internal data interface.
- * -----------------------------------------------------------------------------
- * struct v4l2_private_int_data - request private data stored in video device
- * internal memory.
- * @size: sanity check to ensure userspace's buffer fits whole private data.
- *	  If not, kernel will make partial copy (or nothing if @size == 0).
- *	  @size is always corrected for the minimum necessary if IOCTL returns
- *	  no error.
- * @data: pointer to userspace buffer.
- */
-struct v4l2_private_int_data {
-	__u32 size;
-	void __user *data;
-	__u32 reserved[2];
-};
-
-enum atomisp_sensor_ae_bracketing_mode {
-	SENSOR_AE_BRACKETING_MODE_OFF = 0,
-	SENSOR_AE_BRACKETING_MODE_SINGLE, /* back to SW standby after bracketing */
-	SENSOR_AE_BRACKETING_MODE_SINGLE_TO_STREAMING, /* back to normal streaming after bracketing */
-	SENSOR_AE_BRACKETING_MODE_LOOP, /* continue AE bracketing in loop mode */
-};
-
-struct atomisp_sensor_ae_bracketing_info {
-	unsigned int modes; /* bit mask to indicate supported modes  */
-	unsigned int lut_depth;
-};
-
-struct atomisp_sensor_ae_bracketing_lut_entry {
-	__u16 coarse_integration_time;
-	__u16 analog_gain;
-	__u16 digital_gain;
-};
-
-struct atomisp_sensor_ae_bracketing_lut {
-	struct atomisp_sensor_ae_bracketing_lut_entry *lut;
-	unsigned int lut_size;
-};
-
-/*Private IOCTLs for ISP */
-#define ATOMISP_IOC_G_XNR \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 0, int)
-#define ATOMISP_IOC_S_XNR \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 0, int)
-#define ATOMISP_IOC_G_NR \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 1, struct atomisp_nr_config)
-#define ATOMISP_IOC_S_NR \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 1, struct atomisp_nr_config)
-#define ATOMISP_IOC_G_TNR \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 2, struct atomisp_tnr_config)
-#define ATOMISP_IOC_S_TNR \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 2, struct atomisp_tnr_config)
-#define ATOMISP_IOC_G_HISTOGRAM \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 3, struct atomisp_histogram)
-#define ATOMISP_IOC_S_HISTOGRAM \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 3, struct atomisp_histogram)
-#define ATOMISP_IOC_G_BLACK_LEVEL_COMP \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 4, struct atomisp_ob_config)
-#define ATOMISP_IOC_S_BLACK_LEVEL_COMP \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 4, struct atomisp_ob_config)
-#define ATOMISP_IOC_G_EE \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 5, struct atomisp_ee_config)
-#define ATOMISP_IOC_S_EE \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 5, struct atomisp_ee_config)
-/* Digital Image Stabilization:
- * 1. get dis statistics: reads DIS statistics from ISP (every frame)
- * 2. set dis coefficients: set DIS filter coefficients (one time)
- * 3. set dis motion vecotr: set motion vector (result of DIS, every frame)
- */
-#define ATOMISP_IOC_G_DIS_STAT \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dis_statistics)
-
-#define ATOMISP_IOC_G_DVS2_BQ_RESOLUTIONS \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dvs2_bq_resolutions)
-
-#define ATOMISP_IOC_S_DIS_COEFS \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dis_coefficients)
-
-#define ATOMISP_IOC_S_DIS_VECTOR \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dvs_6axis_config)
-
-#define ATOMISP_IOC_G_3A_STAT \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 7, struct atomisp_3a_statistics)
-#define ATOMISP_IOC_G_ISP_PARM \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 8, struct atomisp_parm)
-#define ATOMISP_IOC_S_ISP_PARM \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 8, struct atomisp_parm)
-#define ATOMISP_IOC_G_ISP_GAMMA \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 9, struct atomisp_gamma_table)
-#define ATOMISP_IOC_S_ISP_GAMMA \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 9, struct atomisp_gamma_table)
-#define ATOMISP_IOC_G_ISP_GDC_TAB \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 10, struct atomisp_morph_table)
-#define ATOMISP_IOC_S_ISP_GDC_TAB \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 10, struct atomisp_morph_table)
-#define ATOMISP_IOC_ISP_MAKERNOTE \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 11, struct atomisp_makernote_info)
-
-/* macc parameter control*/
-#define ATOMISP_IOC_G_ISP_MACC \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 12, struct atomisp_macc_config)
-#define ATOMISP_IOC_S_ISP_MACC \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 12, struct atomisp_macc_config)
-
-/* Defect pixel detection & Correction */
-#define ATOMISP_IOC_G_ISP_BAD_PIXEL_DETECTION \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 13, struct atomisp_dp_config)
-#define ATOMISP_IOC_S_ISP_BAD_PIXEL_DETECTION \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 13, struct atomisp_dp_config)
-
-/* False Color Correction */
-#define ATOMISP_IOC_G_ISP_FALSE_COLOR_CORRECTION \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 14, struct atomisp_de_config)
-#define ATOMISP_IOC_S_ISP_FALSE_COLOR_CORRECTION \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 14, struct atomisp_de_config)
-
-/* ctc parameter control */
-#define ATOMISP_IOC_G_ISP_CTC \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 15, struct atomisp_ctc_table)
-#define ATOMISP_IOC_S_ISP_CTC \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 15, struct atomisp_ctc_table)
-
-/* white balance Correction */
-#define ATOMISP_IOC_G_ISP_WHITE_BALANCE \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 16, struct atomisp_wb_config)
-#define ATOMISP_IOC_S_ISP_WHITE_BALANCE \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 16, struct atomisp_wb_config)
-
-/* fpn table loading */
-#define ATOMISP_IOC_S_ISP_FPN_TABLE \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 17, struct v4l2_framebuffer)
-
-/* overlay image loading */
-#define ATOMISP_IOC_G_ISP_OVERLAY \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 18, struct atomisp_overlay)
-#define ATOMISP_IOC_S_ISP_OVERLAY \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 18, struct atomisp_overlay)
-
-/* bcd driver bridge */
-#define ATOMISP_IOC_CAMERA_BRIDGE \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 19, struct atomisp_bc_video_package)
-
-/* Sensor resolution specific info for AE */
-#define ATOMISP_IOC_G_SENSOR_MODE_DATA \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 20, struct atomisp_sensor_mode_data)
-
-#define ATOMISP_IOC_S_EXPOSURE \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 21, struct atomisp_exposure)
-
-/* sensor calibration registers group */
-#define ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 22, struct atomisp_calibration_group)
-
-/* white balance Correction */
-#define ATOMISP_IOC_G_3A_CONFIG \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 23, struct atomisp_3a_config)
-#define ATOMISP_IOC_S_3A_CONFIG \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 23, struct atomisp_3a_config)
-
-/* Accelerate ioctls */
-#define ATOMISP_IOC_ACC_LOAD \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 24, struct atomisp_acc_fw_load)
-
-#define ATOMISP_IOC_ACC_UNLOAD \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 24, unsigned int)
-
-/* For CSS 1.0 only */
-#define ATOMISP_IOC_ACC_S_ARG \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 24, struct atomisp_acc_fw_arg)
-
-#define ATOMISP_IOC_ACC_START \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 24, unsigned int)
-
-#define ATOMISP_IOC_ACC_WAIT \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 25, unsigned int)
-
-#define ATOMISP_IOC_ACC_ABORT \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 25, struct atomisp_acc_fw_abort)
-
-#define ATOMISP_IOC_ACC_DESTAB \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 25, struct atomisp_acc_fw_arg)
-
-/* sensor OTP memory read */
-#define ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 26, struct v4l2_private_int_data)
-
-/* LCS (shading) table write */
-#define ATOMISP_IOC_S_ISP_SHD_TAB \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 27, struct atomisp_shading_table)
-
-/* Gamma Correction */
-#define ATOMISP_IOC_G_ISP_GAMMA_CORRECTION \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 28, struct atomisp_gc_config)
-
-#define ATOMISP_IOC_S_ISP_GAMMA_CORRECTION \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 28, struct atomisp_gc_config)
-
-/* motor internal memory read */
-#define ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 29, struct v4l2_private_int_data)
-
-/*
- * Ioctls to map and unmap user buffers to CSS address space for acceleration.
- * User fills fields length and user_ptr and sets other fields to zero,
- * kernel may modify the flags and sets css_ptr.
- */
-#define ATOMISP_IOC_ACC_MAP \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 30, struct atomisp_acc_map)
-
-/* User fills fields length, user_ptr, and css_ptr and zeroes other fields. */
-#define ATOMISP_IOC_ACC_UNMAP \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 30, struct atomisp_acc_map)
-
-#define ATOMISP_IOC_ACC_S_MAPPED_ARG \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 30, struct atomisp_acc_s_mapped_arg)
-
-#define ATOMISP_IOC_ACC_LOAD_TO_PIPE \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 31, struct atomisp_acc_fw_load_to_pipe)
-
-#define ATOMISP_IOC_S_PARAMETERS \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 32, struct atomisp_parameters)
-
-#define ATOMISP_IOC_S_CONT_CAPTURE_CONFIG \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 33, struct atomisp_cont_capture_conf)
-
-#define ATOMISP_IOC_G_METADATA \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 34, struct atomisp_metadata)
-
-#define ATOMISP_IOC_G_METADATA_BY_TYPE \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 34, struct atomisp_metadata_with_type)
-
-#define ATOMISP_IOC_EXT_ISP_CTRL \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 35, struct atomisp_ext_isp_ctrl)
-
-#define ATOMISP_IOC_EXP_ID_UNLOCK \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 36, int)
-
-#define ATOMISP_IOC_EXP_ID_CAPTURE \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 37, int)
-
-#define ATOMISP_IOC_S_ENABLE_DZ_CAPT_PIPE \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 38, unsigned int)
-
-#define ATOMISP_IOC_G_FORMATS_CONFIG \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 39, struct atomisp_formats_config)
-
-#define ATOMISP_IOC_S_FORMATS_CONFIG \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 39, struct atomisp_formats_config)
-
-#define ATOMISP_IOC_S_EXPOSURE_WINDOW \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 40, struct atomisp_ae_window)
-
-#define ATOMISP_IOC_S_ACC_STATE \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 41, struct atomisp_acc_state)
-
-#define ATOMISP_IOC_G_ACC_STATE \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 41, struct atomisp_acc_state)
-
-#define ATOMISP_IOC_INJECT_A_FAKE_EVENT \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 42, int)
-
-#define ATOMISP_IOC_G_SENSOR_AE_BRACKETING_INFO \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 43, struct atomisp_sensor_ae_bracketing_info)
-
-#define ATOMISP_IOC_S_SENSOR_AE_BRACKETING_MODE \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 43, unsigned int)
-
-#define ATOMISP_IOC_G_SENSOR_AE_BRACKETING_MODE \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 43, unsigned int)
-
-#define ATOMISP_IOC_S_SENSOR_AE_BRACKETING_LUT \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 43, struct atomisp_sensor_ae_bracketing_lut)
-
-#define ATOMISP_IOC_G_INVALID_FRAME_NUM \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 44, unsigned int)
-
-#define ATOMISP_IOC_S_ARRAY_RESOLUTION \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 45, struct atomisp_resolution)
-
-/* for depth mode sensor frame sync compensation */
-#define ATOMISP_IOC_G_DEPTH_SYNC_COMP \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 46, unsigned int)
-
-#define ATOMISP_IOC_S_SENSOR_EE_CONFIG \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 47, unsigned int)
-
-#define ATOMISP_IOC_S_SENSOR_RUNMODE \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 48, struct atomisp_s_runmode)
-
-#define ATOMISP_IOC_G_UPDATE_EXPOSURE \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 49, struct atomisp_update_exposure)
-
-/*
- * Reserved ioctls. We have customer implementing it internally.
- * We can't use both numbers to not cause ABI conflict.
- * Anyway, those ioctls are hacks and not implemented by us:
- *
- * #define ATOMISP_IOC_G_SENSOR_REG \
- *	_IOW('v', BASE_VIDIOC_PRIVATE + 55, struct atomisp_sensor_regs)
- * #define ATOMISP_IOC_S_SENSOR_REG \
- *	_IOW('v', BASE_VIDIOC_PRIVATE + 56, struct atomisp_sensor_regs)
- */
-
-/*  ISP Private control IDs */
-#define V4L2_CID_ATOMISP_BAD_PIXEL_DETECTION \
-	(V4L2_CID_PRIVATE_BASE + 0)
-#define V4L2_CID_ATOMISP_POSTPROCESS_GDC_CAC \
-	(V4L2_CID_PRIVATE_BASE + 1)
-#define V4L2_CID_ATOMISP_VIDEO_STABLIZATION \
-	(V4L2_CID_PRIVATE_BASE + 2)
-#define V4L2_CID_ATOMISP_FIXED_PATTERN_NR \
-	(V4L2_CID_PRIVATE_BASE + 3)
-#define V4L2_CID_ATOMISP_FALSE_COLOR_CORRECTION \
-	(V4L2_CID_PRIVATE_BASE + 4)
-#define V4L2_CID_ATOMISP_LOW_LIGHT \
-	(V4L2_CID_PRIVATE_BASE + 5)
-
-/* Camera class:
- * Exposure, Flash and privacy (indicator) light controls, to be upstreamed */
-#define V4L2_CID_CAMERA_LASTP1             (V4L2_CID_CAMERA_CLASS_BASE + 1024)
-
-#define V4L2_CID_FOCAL_ABSOLUTE            (V4L2_CID_CAMERA_LASTP1 + 0)
-#define V4L2_CID_FNUMBER_ABSOLUTE          (V4L2_CID_CAMERA_LASTP1 + 1)
-#define V4L2_CID_FNUMBER_RANGE             (V4L2_CID_CAMERA_LASTP1 + 2)
-
-/* Flash related CIDs, see also:
- * http://linuxtv.org/downloads/v4l-dvb-apis/extended-controls.html\
- * #flash-controls */
-
-/* Request a number of flash-exposed frames. The frame status can be
- * found in the reserved field in the v4l2_buffer struct. */
-#define V4L2_CID_REQUEST_FLASH             (V4L2_CID_CAMERA_LASTP1 + 3)
-/* Query flash driver status. See enum atomisp_flash_status above. */
-#define V4L2_CID_FLASH_STATUS              (V4L2_CID_CAMERA_LASTP1 + 5)
-/* Set the flash mode (see enum atomisp_flash_mode) */
-#define V4L2_CID_FLASH_MODE                (V4L2_CID_CAMERA_LASTP1 + 10)
-
-/* VCM slew control */
-#define V4L2_CID_VCM_SLEW                  (V4L2_CID_CAMERA_LASTP1 + 11)
-/* VCM step time */
-#define V4L2_CID_VCM_TIMEING               (V4L2_CID_CAMERA_LASTP1 + 12)
-
-/* Query Focus Status */
-#define V4L2_CID_FOCUS_STATUS              (V4L2_CID_CAMERA_LASTP1 + 14)
-
-/* Query sensor's binning factor */
-#define V4L2_CID_BIN_FACTOR_HORZ	   (V4L2_CID_CAMERA_LASTP1 + 15)
-#define V4L2_CID_BIN_FACTOR_VERT	   (V4L2_CID_CAMERA_LASTP1 + 16)
-
-/* number of frames to skip at stream start */
-#define V4L2_CID_G_SKIP_FRAMES		   (V4L2_CID_CAMERA_LASTP1 + 17)
-
-/* Query sensor's 2A status */
-#define V4L2_CID_2A_STATUS                 (V4L2_CID_CAMERA_LASTP1 + 18)
-#define V4L2_2A_STATUS_AE_READY            (1 << 0)
-#define V4L2_2A_STATUS_AWB_READY           (1 << 1)
-
-#define V4L2_CID_FMT_AUTO			(V4L2_CID_CAMERA_LASTP1 + 19)
-
-#define V4L2_CID_RUN_MODE			(V4L2_CID_CAMERA_LASTP1 + 20)
-#define ATOMISP_RUN_MODE_VIDEO			1
-#define ATOMISP_RUN_MODE_STILL_CAPTURE		2
-#define ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE	3
-#define ATOMISP_RUN_MODE_PREVIEW		4
-#define ATOMISP_RUN_MODE_SDV			5
-
-#define V4L2_CID_ENABLE_VFPP			(V4L2_CID_CAMERA_LASTP1 + 21)
-#define V4L2_CID_ATOMISP_CONTINUOUS_MODE	(V4L2_CID_CAMERA_LASTP1 + 22)
-#define V4L2_CID_ATOMISP_CONTINUOUS_RAW_BUFFER_SIZE \
-						(V4L2_CID_CAMERA_LASTP1 + 23)
-#define V4L2_CID_ATOMISP_CONTINUOUS_VIEWFINDER \
-						(V4L2_CID_CAMERA_LASTP1 + 24)
-
-#define V4L2_CID_VFPP				(V4L2_CID_CAMERA_LASTP1 + 25)
-#define ATOMISP_VFPP_ENABLE			0
-#define ATOMISP_VFPP_DISABLE_SCALER		1
-#define ATOMISP_VFPP_DISABLE_LOWLAT		2
-
-/* Query real flash status register value */
-#define V4L2_CID_FLASH_STATUS_REGISTER  (V4L2_CID_CAMERA_LASTP1 + 26)
-
-#define V4L2_CID_START_ZSL_CAPTURE	(V4L2_CID_CAMERA_LASTP1 + 28)
-/* Lock and unlock raw buffer */
-#define V4L2_CID_ENABLE_RAW_BUFFER_LOCK (V4L2_CID_CAMERA_LASTP1 + 29)
-
-#define V4L2_CID_DEPTH_MODE		(V4L2_CID_CAMERA_LASTP1 + 30)
-
-#define V4L2_CID_EXPOSURE_ZONE_NUM	(V4L2_CID_CAMERA_LASTP1 + 31)
-/* Disable digital zoom */
-#define V4L2_CID_DISABLE_DZ		(V4L2_CID_CAMERA_LASTP1 + 32)
-
-#define V4L2_CID_TEST_PATTERN_COLOR_R	(V4L2_CID_CAMERA_LASTP1 + 33)
-#define V4L2_CID_TEST_PATTERN_COLOR_GR	(V4L2_CID_CAMERA_LASTP1 + 34)
-#define V4L2_CID_TEST_PATTERN_COLOR_GB	(V4L2_CID_CAMERA_LASTP1 + 35)
-#define V4L2_CID_TEST_PATTERN_COLOR_B	(V4L2_CID_CAMERA_LASTP1 + 36)
-
-#define V4L2_CID_ATOMISP_SELECT_ISP_VERSION	(V4L2_CID_CAMERA_LASTP1 + 38)
-
-#define V4L2_BUF_FLAG_BUFFER_INVALID       0x0400
-#define V4L2_BUF_FLAG_BUFFER_VALID         0x0800
-
-#define V4L2_BUF_TYPE_VIDEO_CAPTURE_ION  (V4L2_BUF_TYPE_PRIVATE + 1024)
-
-#define V4L2_EVENT_ATOMISP_3A_STATS_READY   (V4L2_EVENT_PRIVATE_START + 1)
-#define V4L2_EVENT_ATOMISP_METADATA_READY   (V4L2_EVENT_PRIVATE_START + 2)
-#define V4L2_EVENT_ATOMISP_RAW_BUFFERS_ALLOC_DONE   (V4L2_EVENT_PRIVATE_START + 3)
-#define V4L2_EVENT_ATOMISP_ACC_COMPLETE     (V4L2_EVENT_PRIVATE_START + 4)
-#define V4L2_EVENT_ATOMISP_PAUSE_BUFFER	    (V4L2_EVENT_PRIVATE_START + 5)
-#define V4L2_EVENT_ATOMISP_CSS_RESET	    (V4L2_EVENT_PRIVATE_START + 6)
-/* Nonstandard color effects for V4L2_CID_COLORFX */
-enum {
-	V4L2_COLORFX_SKIN_WHITEN_LOW = 1001,
-	V4L2_COLORFX_SKIN_WHITEN_HIGH = 1002,
-	V4L2_COLORFX_WARM = 1003,
-	V4L2_COLORFX_COLD = 1004,
-	V4L2_COLORFX_WASHED = 1005,
-	V4L2_COLORFX_RED = 1006,
-	V4L2_COLORFX_GREEN = 1007,
-	V4L2_COLORFX_BLUE = 1008,
-	V4L2_COLORFX_PINK = 1009,
-	V4L2_COLORFX_YELLOW = 1010,
-	V4L2_COLORFX_PURPLE = 1011,
-};
-
-#endif /* _ATOM_ISP_H */
-#endif /* CSS15*/

+ 0 - 36
drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h

@@ -1,36 +0,0 @@
-/*
- * Support for Intel MID SoC Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2014 Intel Corporation. All Rights Reserved.
- *
- * 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 ATOMISP_GMIN_PLATFORM_H_
-#define ATOMISP_GMIN_PLATFORM_H_
-
-#include "atomisp_platform.h"
-
-int atomisp_register_i2c_module(struct v4l2_subdev *subdev,
-                                struct camera_sensor_platform_data *plat_data,
-                                enum intel_v4l2_subdev_type type);
-struct v4l2_subdev *atomisp_gmin_find_subdev(struct i2c_adapter *adapter,
-					     struct i2c_board_info *board_info);
-int atomisp_gmin_remove_subdev(struct v4l2_subdev *sd);
-int gmin_get_var_int(struct device *dev, const char *var, int def);
-int camera_sensor_csi(struct v4l2_subdev *sd, u32 port,
-                      u32 lanes, u32 format, u32 bayer_order, int flag);
-struct camera_sensor_platform_data *gmin_camera_platform_data(
-		struct v4l2_subdev *subdev,
-		enum atomisp_input_format csi_format,
-		enum atomisp_bayer_order csi_bayer);
-
-int atomisp_gmin_register_vcm_control(struct camera_vcm_control *);
-
-#endif

+ 0 - 249
drivers/staging/media/atomisp/include/linux/atomisp_platform.h

@@ -1,249 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * 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 ATOMISP_PLATFORM_H_
-#define ATOMISP_PLATFORM_H_
-
-#include <linux/i2c.h>
-#include <linux/sfi.h>
-#include <media/v4l2-subdev.h>
-#include "atomisp.h"
-
-#define MAX_SENSORS_PER_PORT 4
-#define MAX_STREAMS_PER_CHANNEL 2
-
-#define CAMERA_MODULE_ID_LEN 64
-
-enum atomisp_bayer_order {
-	atomisp_bayer_order_grbg,
-	atomisp_bayer_order_rggb,
-	atomisp_bayer_order_bggr,
-	atomisp_bayer_order_gbrg
-};
-
-enum atomisp_input_stream_id {
-	ATOMISP_INPUT_STREAM_GENERAL = 0,
-	ATOMISP_INPUT_STREAM_CAPTURE = 0,
-	ATOMISP_INPUT_STREAM_POSTVIEW,
-	ATOMISP_INPUT_STREAM_PREVIEW,
-	ATOMISP_INPUT_STREAM_VIDEO,
-	ATOMISP_INPUT_STREAM_NUM
-};
-
-enum atomisp_input_format {
-	ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY,/* 8 bits per subpixel (legacy) */
-	ATOMISP_INPUT_FORMAT_YUV420_8, /* 8 bits per subpixel */
-	ATOMISP_INPUT_FORMAT_YUV420_10,/* 10 bits per subpixel */
-	ATOMISP_INPUT_FORMAT_YUV420_16,/* 16 bits per subpixel */
-	ATOMISP_INPUT_FORMAT_YUV422_8, /* UYVY..UVYV, 8 bits per subpixel */
-	ATOMISP_INPUT_FORMAT_YUV422_10,/* UYVY..UVYV, 10 bits per subpixel */
-	ATOMISP_INPUT_FORMAT_YUV422_16,/* UYVY..UVYV, 16 bits per subpixel */
-	ATOMISP_INPUT_FORMAT_RGB_444,  /* BGR..BGR, 4 bits per subpixel */
-	ATOMISP_INPUT_FORMAT_RGB_555,  /* BGR..BGR, 5 bits per subpixel */
-	ATOMISP_INPUT_FORMAT_RGB_565,  /* BGR..BGR, 5 bits B and R, 6 bits G */
-	ATOMISP_INPUT_FORMAT_RGB_666,  /* BGR..BGR, 6 bits per subpixel */
-	ATOMISP_INPUT_FORMAT_RGB_888,  /* BGR..BGR, 8 bits per subpixel */
-	ATOMISP_INPUT_FORMAT_RAW_6,    /* RAW data, 6 bits per pixel */
-	ATOMISP_INPUT_FORMAT_RAW_7,    /* RAW data, 7 bits per pixel */
-	ATOMISP_INPUT_FORMAT_RAW_8,    /* RAW data, 8 bits per pixel */
-	ATOMISP_INPUT_FORMAT_RAW_10,   /* RAW data, 10 bits per pixel */
-	ATOMISP_INPUT_FORMAT_RAW_12,   /* RAW data, 12 bits per pixel */
-	ATOMISP_INPUT_FORMAT_RAW_14,   /* RAW data, 14 bits per pixel */
-	ATOMISP_INPUT_FORMAT_RAW_16,   /* RAW data, 16 bits per pixel */
-	ATOMISP_INPUT_FORMAT_BINARY_8, /* Binary byte stream. */
-
-	/* CSI2-MIPI specific format: Generic short packet data. It is used to
-	 * keep the timing information for the opening/closing of shutters,
-	 * triggering of flashes and etc.
-	 */
-	ATOMISP_INPUT_FORMAT_GENERIC_SHORT1,  /* Generic Short Packet Code 1 */
-	ATOMISP_INPUT_FORMAT_GENERIC_SHORT2,  /* Generic Short Packet Code 2 */
-	ATOMISP_INPUT_FORMAT_GENERIC_SHORT3,  /* Generic Short Packet Code 3 */
-	ATOMISP_INPUT_FORMAT_GENERIC_SHORT4,  /* Generic Short Packet Code 4 */
-	ATOMISP_INPUT_FORMAT_GENERIC_SHORT5,  /* Generic Short Packet Code 5 */
-	ATOMISP_INPUT_FORMAT_GENERIC_SHORT6,  /* Generic Short Packet Code 6 */
-	ATOMISP_INPUT_FORMAT_GENERIC_SHORT7,  /* Generic Short Packet Code 7 */
-	ATOMISP_INPUT_FORMAT_GENERIC_SHORT8,  /* Generic Short Packet Code 8 */
-
-	/* CSI2-MIPI specific format: YUV data.
-	 */
-	ATOMISP_INPUT_FORMAT_YUV420_8_SHIFT,  /* YUV420 8-bit (Chroma Shifted
-						 Pixel Sampling) */
-	ATOMISP_INPUT_FORMAT_YUV420_10_SHIFT, /* YUV420 8-bit (Chroma Shifted
-						 Pixel Sampling) */
-
-	/* CSI2-MIPI specific format: Generic long packet data
-	 */
-	ATOMISP_INPUT_FORMAT_EMBEDDED, /* Embedded 8-bit non Image Data */
-
-	/* CSI2-MIPI specific format: User defined byte-based data. For example,
-	 * the data transmitter (e.g. the SoC sensor) can keep the JPEG data as
-	 * the User Defined Data Type 4 and the MPEG data as the
-	 * User Defined Data Type 7.
-	 */
-	ATOMISP_INPUT_FORMAT_USER_DEF1,  /* User defined 8-bit data type 1 */
-	ATOMISP_INPUT_FORMAT_USER_DEF2,  /* User defined 8-bit data type 2 */
-	ATOMISP_INPUT_FORMAT_USER_DEF3,  /* User defined 8-bit data type 3 */
-	ATOMISP_INPUT_FORMAT_USER_DEF4,  /* User defined 8-bit data type 4 */
-	ATOMISP_INPUT_FORMAT_USER_DEF5,  /* User defined 8-bit data type 5 */
-	ATOMISP_INPUT_FORMAT_USER_DEF6,  /* User defined 8-bit data type 6 */
-	ATOMISP_INPUT_FORMAT_USER_DEF7,  /* User defined 8-bit data type 7 */
-	ATOMISP_INPUT_FORMAT_USER_DEF8,  /* User defined 8-bit data type 8 */
-};
-
-#define N_ATOMISP_INPUT_FORMAT (ATOMISP_INPUT_FORMAT_USER_DEF8 + 1)
-
-
-
-enum intel_v4l2_subdev_type {
-	RAW_CAMERA = 1,
-	SOC_CAMERA = 2,
-	CAMERA_MOTOR = 3,
-	LED_FLASH = 4,
-	XENON_FLASH = 5,
-	FILE_INPUT = 6,
-	TEST_PATTERN = 7,
-};
-
-struct intel_v4l2_subdev_id {
-	char name[17];
-	enum intel_v4l2_subdev_type type;
-	enum atomisp_camera_port    port;
-};
-
-struct intel_v4l2_subdev_i2c_board_info {
-	struct i2c_board_info board_info;
-	int i2c_adapter_id;
-};
-
-struct intel_v4l2_subdev_table {
-	struct intel_v4l2_subdev_i2c_board_info v4l2_subdev;
-	enum intel_v4l2_subdev_type type;
-	enum atomisp_camera_port port;
-	struct v4l2_subdev *subdev;
-};
-
-struct atomisp_platform_data {
-	struct intel_v4l2_subdev_table *subdevs;
-};
-
-/* Describe the capacities of one single sensor. */
-struct atomisp_sensor_caps {
-	/* The number of streams this sensor can output. */
-	int stream_num;
-	bool is_slave;
-};
-
-/* Describe the capacities of sensors connected to one camera port. */
-struct atomisp_camera_caps {
-	/* The number of sensors connected to this camera port. */
-	int sensor_num;
-	/* The capacities of each sensor. */
-	struct atomisp_sensor_caps sensor[MAX_SENSORS_PER_PORT];
-	/* Define whether stream control is required for multiple streams. */
-	bool multi_stream_ctrl;
-};
-
-/*
- *  Sensor of external ISP can send multiple steams with different mipi data
- * type in the same virtual channel. This information needs to come from the
- * sensor or external ISP
- */
-struct atomisp_isys_config_info {
-	u8 input_format;
-	u16 width;
-	u16 height;
-};
-
-struct atomisp_input_stream_info {
-	enum atomisp_input_stream_id stream;
-	u8 enable;
-	/* Sensor driver fills ch_id with the id
-	   of the virtual channel. */
-	u8 ch_id;
-	/* Tells how many streams in this virtual channel. If 0 ignore rest
-	 * and the input format will be from mipi_info */
-	u8 isys_configs;
-	/*
-	 * if more isys_configs is more than 0, sensor needs to configure the
-	 * input format differently. width and height can be 0. If width and
-	 * height is not zero, then the corresponsing data needs to be set
-	 */
-	struct atomisp_isys_config_info isys_info[MAX_STREAMS_PER_CHANNEL];
-};
-
-struct camera_vcm_control;
-struct camera_vcm_ops {
-	int (*power_up)(struct v4l2_subdev *sd, struct camera_vcm_control *vcm);
-	int (*power_down)(struct v4l2_subdev *sd,
-			struct camera_vcm_control *vcm);
-	int (*queryctrl)(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc,
-			struct camera_vcm_control *vcm);
-	int (*g_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl,
-			struct camera_vcm_control *vcm);
-	int (*s_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl,
-			struct camera_vcm_control *vcm);
-};
-
-struct camera_vcm_control {
-	char camera_module[CAMERA_MODULE_ID_LEN];
-	struct camera_vcm_ops *ops;
-	struct list_head list;
-};
-
-struct camera_sensor_platform_data {
-	int (*flisclk_ctrl)(struct v4l2_subdev *subdev, int flag);
-	int (*csi_cfg)(struct v4l2_subdev *subdev, int flag);
-
-	/*
-	 * New G-Min power and GPIO interface to control individual
-	 * lines as implemented on all known camera modules.
-	 */
-	int (*gpio0_ctrl)(struct v4l2_subdev *subdev, int on);
-	int (*gpio1_ctrl)(struct v4l2_subdev *subdev, int on);
-	int (*v1p8_ctrl)(struct v4l2_subdev *subdev, int on);
-	int (*v2p8_ctrl)(struct v4l2_subdev *subdev, int on);
-	int (*v1p2_ctrl)(struct v4l2_subdev *subdev, int on);
-	struct camera_vcm_control * (*get_vcm_ctrl)(struct v4l2_subdev *subdev,
-						    char *module_id);
-};
-
-struct camera_mipi_info {
-	enum atomisp_camera_port        port;
-	unsigned int                    num_lanes;
-	enum atomisp_input_format       input_format;
-	enum atomisp_bayer_order        raw_bayer_order;
-	struct atomisp_sensor_mode_data data;
-	enum atomisp_input_format       metadata_format;
-	uint32_t                        metadata_width;
-	uint32_t                        metadata_height;
-	const uint32_t                  *metadata_effective_width;
-};
-
-extern const struct atomisp_platform_data *atomisp_get_platform_data(void);
-extern const struct atomisp_camera_caps *atomisp_get_default_camera_caps(void);
-
-/* API from old platform_camera.h, new CPUID implementation */
-#define __IS_SOC(x) (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && \
-		     boot_cpu_data.x86 == 6 &&                       \
-		     boot_cpu_data.x86_model == x)
-
-#define IS_MFLD	__IS_SOC(0x27)
-#define IS_BYT	__IS_SOC(0x37)
-#define IS_CHT	__IS_SOC(0x4C)
-#define IS_MOFD	__IS_SOC(0x5A)
-
-#endif /* ATOMISP_PLATFORM_H_ */

+ 0 - 28
drivers/staging/media/atomisp/include/linux/libmsrlisthelper.h

@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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 __LIBMSRLISTHELPER_H__
-#define __LIBMSRLISTHELPER_H__
-
-struct i2c_client;
-struct firmware;
-
-extern int load_msr_list(struct i2c_client *client, char *path,
-		const struct firmware **fw);
-extern int apply_msr_data(struct i2c_client *client, const struct firmware *fw);
-extern void release_msr_list(struct i2c_client *client,
-		const struct firmware *fw);
-
-
-#endif /* ifndef __LIBMSRLISTHELPER_H__ */

+ 0 - 131
drivers/staging/media/atomisp/include/media/lm3554.h

@@ -1,131 +0,0 @@
-/*
- * include/media/lm3554.h
- *
- * Copyright (c) 2010-2012 Intel Corporation. All Rights Reserved.
- *
- * 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 _LM3554_H_
-#define _LM3554_H_
-
-#include <linux/videodev2.h>
-#include <media/v4l2-subdev.h>
-
-#define LM3554_ID      3554
-
-#define	v4l2_queryctrl_entry_integer(_id, _name,\
-		_minimum, _maximum, _step, \
-		_default_value, _flags)	\
-	{\
-		.id = (_id), \
-		.type = V4L2_CTRL_TYPE_INTEGER, \
-		.name = _name, \
-		.minimum = (_minimum), \
-		.maximum = (_maximum), \
-		.step = (_step), \
-		.default_value = (_default_value),\
-		.flags = (_flags),\
-	}
-#define	v4l2_queryctrl_entry_boolean(_id, _name,\
-		_default_value, _flags)	\
-	{\
-		.id = (_id), \
-		.type = V4L2_CTRL_TYPE_BOOLEAN, \
-		.name = _name, \
-		.minimum = 0, \
-		.maximum = 1, \
-		.step = 1, \
-		.default_value = (_default_value),\
-		.flags = (_flags),\
-	}
-
-#define	s_ctrl_id_entry_integer(_id, _name, \
-		_minimum, _maximum, _step, \
-		_default_value, _flags, \
-		_s_ctrl, _g_ctrl)	\
-	{\
-		.qc = v4l2_queryctrl_entry_integer(_id, _name,\
-				_minimum, _maximum, _step,\
-				_default_value, _flags), \
-		.s_ctrl = _s_ctrl, \
-		.g_ctrl = _g_ctrl, \
-	}
-
-#define	s_ctrl_id_entry_boolean(_id, _name, \
-		_default_value, _flags, \
-		_s_ctrl, _g_ctrl)	\
-	{\
-		.qc = v4l2_queryctrl_entry_boolean(_id, _name,\
-				_default_value, _flags), \
-		.s_ctrl = _s_ctrl, \
-		.g_ctrl = _g_ctrl, \
-	}
-
-/* Value settings for Flash Time-out Duration*/
-#define LM3554_DEFAULT_TIMEOUT          512U
-#define LM3554_MIN_TIMEOUT              32U
-#define LM3554_MAX_TIMEOUT              1024U
-#define LM3554_TIMEOUT_STEPSIZE         32U
-
-/* Flash modes */
-#define LM3554_MODE_SHUTDOWN            0
-#define LM3554_MODE_INDICATOR           1
-#define LM3554_MODE_TORCH               2
-#define LM3554_MODE_FLASH               3
-
-/* timer delay time */
-#define LM3554_TIMER_DELAY		5
-
-/* Percentage <-> value macros */
-#define LM3554_MIN_PERCENT                   0U
-#define LM3554_MAX_PERCENT                   100U
-#define LM3554_CLAMP_PERCENTAGE(val) \
-	clamp(val, LM3554_MIN_PERCENT, LM3554_MAX_PERCENT)
-
-#define LM3554_VALUE_TO_PERCENT(v, step)     (((((unsigned long)(v))*(step))+50)/100)
-#define LM3554_PERCENT_TO_VALUE(p, step)     (((((unsigned long)(p))*100)+(step>>1))/(step))
-
-/* Product specific limits
- * TODO: get these from platform data */
-#define LM3554_FLASH_MAX_LVL   0x0F /* 1191mA */
-
-/* Flash brightness, input is percentage, output is [0..15] */
-#define LM3554_FLASH_STEP	\
-	((100ul*(LM3554_MAX_PERCENT)+((LM3554_FLASH_MAX_LVL)>>1))/((LM3554_FLASH_MAX_LVL)))
-#define LM3554_FLASH_DEFAULT_BRIGHTNESS \
-	LM3554_VALUE_TO_PERCENT(13, LM3554_FLASH_STEP)
-
-/* Torch brightness, input is percentage, output is [0..7] */
-#define LM3554_TORCH_STEP                    1250
-#define LM3554_TORCH_DEFAULT_BRIGHTNESS \
-	LM3554_VALUE_TO_PERCENT(2, LM3554_TORCH_STEP)
-
-/* Indicator brightness, input is percentage, output is [0..3] */
-#define LM3554_INDICATOR_STEP                2500
-#define LM3554_INDICATOR_DEFAULT_BRIGHTNESS \
-	LM3554_VALUE_TO_PERCENT(1, LM3554_INDICATOR_STEP)
-
-/*
- * lm3554_platform_data - Flash controller platform data
- */
-struct lm3554_platform_data {
-	int gpio_torch;
-	int gpio_strobe;
-	int gpio_reset;
-
-	unsigned int current_limit;
-	unsigned int envm_tx2;
-	unsigned int tx2_polarity;
-};
-
-#endif /* _LM3554_H_ */
-

+ 0 - 14
drivers/staging/media/atomisp/pci/Kconfig

@@ -1,14 +0,0 @@
-#
-# Kconfig for ISP driver
-#
-
-config VIDEO_ATOMISP
-	tristate "Intel Atom Image Signal Processor Driver"
-	depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
-	select IOSF_MBI
-	select VIDEOBUF_VMALLOC
-	---help---
-	  Say Y here if your platform supports Intel Atom SoC
-	  camera imaging subsystem.
-	  To compile this driver as a module, choose M here: the
-	  module will be called atomisp

+ 0 - 5
drivers/staging/media/atomisp/pci/Makefile

@@ -1,5 +0,0 @@
-#
-# Makefile for ISP driver
-#
-
-obj-$(CONFIG_VIDEO_ATOMISP) += atomisp2/

+ 0 - 349
drivers/staging/media/atomisp/pci/atomisp2/Makefile

@@ -1,349 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-atomisp-objs += \
-	atomisp_drvfs.o \
-	atomisp_file.o \
-	css2400/sh_css_mipi.o \
-	css2400/runtime/pipeline/src/pipeline.o \
-	css2400/runtime/spctrl/src/spctrl.o \
-	css2400/runtime/rmgr/src/rmgr.o \
-	css2400/runtime/rmgr/src/rmgr_vbuf.o \
-	css2400/runtime/isp_param/src/isp_param.o \
-	css2400/runtime/inputfifo/src/inputfifo.o \
-	css2400/runtime/queue/src/queue_access.o \
-	css2400/runtime/queue/src/queue.o \
-	css2400/runtime/frame/src/frame.o \
-	css2400/runtime/eventq/src/eventq.o \
-	css2400/runtime/binary/src/binary.o \
-	css2400/runtime/timer/src/timer.o \
-	css2400/runtime/isys/src/csi_rx_rmgr.o \
-	css2400/runtime/isys/src/isys_stream2mmio_rmgr.o \
-	css2400/runtime/isys/src/virtual_isys.o \
-	css2400/runtime/isys/src/rx.o \
-	css2400/runtime/isys/src/isys_dma_rmgr.o \
-	css2400/runtime/isys/src/ibuf_ctrl_rmgr.o \
-	css2400/runtime/isys/src/isys_init.o \
-	css2400/runtime/bufq/src/bufq.o \
-	css2400/runtime/ifmtr/src/ifmtr.o \
-	css2400/runtime/debug/src/ia_css_debug.o \
-	css2400/runtime/event/src/event.o \
-	css2400/sh_css_sp.o \
-	css2400/css_2400_system/spmem_dump.o \
-	css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_states.o \
-	css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_configs.o \
-	css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_params.o \
-	css2400/sh_css_stream_format.o \
-	css2400/sh_css_hrt.o \
-	css2400/sh_css_properties.o \
-	css2400/memory_realloc.o \
-	css2400/hive_isp_css_shared/host/tag.o \
-	css2400/sh_css_params.o \
-	css2400/sh_css.o \
-	css2400/isp/kernels/hdr/ia_css_hdr.host.o \
-	css2400/isp/kernels/ynr/ynr_2/ia_css_ynr2.host.o \
-	css2400/isp/kernels/ynr/ynr_1.0/ia_css_ynr.host.o \
-	css2400/isp/kernels/conversion/conversion_1.0/ia_css_conversion.host.o \
-	css2400/isp/kernels/fpn/fpn_1.0/ia_css_fpn.host.o \
-	css2400/isp/kernels/tnr/tnr_1.0/ia_css_tnr.host.o \
-	css2400/isp/kernels/vf/vf_1.0/ia_css_vf.host.o \
-	css2400/isp/kernels/raw/raw_1.0/ia_css_raw.host.o \
-	css2400/isp/kernels/ref/ref_1.0/ia_css_ref.host.o \
-	css2400/isp/kernels/qplane/qplane_2/ia_css_qplane.host.o \
-	css2400/isp/kernels/norm/norm_1.0/ia_css_norm.host.o \
-	css2400/isp/kernels/output/output_1.0/ia_css_output.host.o \
-	css2400/isp/kernels/raw_aa_binning/raw_aa_binning_1.0/ia_css_raa.host.o \
-	css2400/isp/kernels/macc/macc1_5/ia_css_macc1_5_table.host.o \
-	css2400/isp/kernels/macc/macc1_5/ia_css_macc1_5.host.o \
-	css2400/isp/kernels/macc/macc_1.0/ia_css_macc.host.o \
-	css2400/isp/kernels/macc/macc_1.0/ia_css_macc_table.host.o \
-	css2400/isp/kernels/csc/csc_1.0/ia_css_csc.host.o \
-	css2400/isp/kernels/bnr/bnr_1.0/ia_css_bnr.host.o \
-	css2400/isp/kernels/bnr/bnr2_2/ia_css_bnr2_2.host.o \
-	css2400/isp/kernels/dpc2/ia_css_dpc2.host.o \
-	css2400/isp/kernels/fc/fc_1.0/ia_css_formats.host.o \
-	css2400/isp/kernels/ctc/ctc_1.0/ia_css_ctc.host.o \
-	css2400/isp/kernels/ctc/ctc_1.0/ia_css_ctc_table.host.o \
-	css2400/isp/kernels/ctc/ctc2/ia_css_ctc2.host.o \
-	css2400/isp/kernels/ctc/ctc1_5/ia_css_ctc1_5.host.o \
-	css2400/isp/kernels/bh/bh_2/ia_css_bh.host.o \
-	css2400/isp/kernels/bnlm/ia_css_bnlm.host.o \
-	css2400/isp/kernels/tdf/tdf_1.0/ia_css_tdf.host.o \
-	css2400/isp/kernels/dvs/dvs_1.0/ia_css_dvs.host.o \
-	css2400/isp/kernels/anr/anr_1.0/ia_css_anr.host.o \
-	css2400/isp/kernels/anr/anr_2/ia_css_anr2_table.host.o \
-	css2400/isp/kernels/anr/anr_2/ia_css_anr2.host.o \
-	css2400/isp/kernels/dp/dp_1.0/ia_css_dp.host.o \
-	css2400/isp/kernels/sdis/sdis_1.0/ia_css_sdis.host.o \
-	css2400/isp/kernels/sdis/sdis_2/ia_css_sdis2.host.o \
-	css2400/isp/kernels/cnr/cnr_2/ia_css_cnr2.host.o \
-	css2400/isp/kernels/cnr/cnr_1.0/ia_css_cnr.host.o \
-	css2400/isp/kernels/xnr/xnr_1.0/ia_css_xnr.host.o \
-	css2400/isp/kernels/xnr/xnr_1.0/ia_css_xnr_table.host.o \
-	css2400/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.o \
-	css2400/isp/kernels/de/de_1.0/ia_css_de.host.o \
-	css2400/isp/kernels/de/de_2/ia_css_de2.host.o \
-	css2400/isp/kernels/gc/gc_2/ia_css_gc2.host.o \
-	css2400/isp/kernels/gc/gc_2/ia_css_gc2_table.host.o \
-	css2400/isp/kernels/gc/gc_1.0/ia_css_gc.host.o \
-	css2400/isp/kernels/gc/gc_1.0/ia_css_gc_table.host.o \
-	css2400/isp/kernels/crop/crop_1.0/ia_css_crop.host.o \
-	css2400/isp/kernels/io_ls/bayer_io_ls/ia_css_bayer_io.host.o \
-	css2400/isp/kernels/aa/aa_2/ia_css_aa2.host.o \
-	css2400/isp/kernels/copy_output/copy_output_1.0/ia_css_copy_output.host.o \
-	css2400/isp/kernels/ob/ob_1.0/ia_css_ob.host.o \
-	css2400/isp/kernels/ob/ob2/ia_css_ob2.host.o \
-	css2400/isp/kernels/iterator/iterator_1.0/ia_css_iterator.host.o \
-	css2400/isp/kernels/wb/wb_1.0/ia_css_wb.host.o \
-	css2400/isp/kernels/eed1_8/ia_css_eed1_8.host.o \
-	css2400/isp/kernels/sc/sc_1.0/ia_css_sc.host.o \
-	css2400/isp/kernels/ipu2_io_ls/bayer_io_ls/ia_css_bayer_io.host.o \
-	css2400/isp/kernels/ipu2_io_ls/yuv444_io_ls/ia_css_yuv444_io.host.o \
-	css2400/isp/kernels/s3a/s3a_1.0/ia_css_s3a.host.o \
-	css2400/sh_css_pipe.o \
-	css2400/ia_css_device_access.o \
-	css2400/sh_css_host_data.o \
-	css2400/sh_css_mmu.o \
-	css2400/sh_css_metadata.o \
-	css2400/base/refcount/src/refcount.o \
-	css2400/base/circbuf/src/circbuf.o \
-	css2400/camera/pipe/src/pipe_binarydesc.o \
-	css2400/camera/pipe/src/pipe_util.o \
-	css2400/camera/pipe/src/pipe_stagedesc.o \
-	css2400/camera/util/src/util.o \
-	css2400/sh_css_metrics.o \
-	css2400/sh_css_version.o \
-	css2400/ia_css_memory_access.o \
-	css2400/sh_css_param_shading.o \
-	css2400/sh_css_morph.o \
-	css2400/sh_css_firmware.o \
-	css2400/hive_isp_css_common/host/isp.o \
-	css2400/hive_isp_css_common/host/gdc.o \
-	css2400/hive_isp_css_common/host/sp.o \
-	css2400/hive_isp_css_common/host/vmem.o \
-	css2400/hive_isp_css_common/host/dma.o \
-	css2400/hive_isp_css_common/host/input_formatter.o \
-	css2400/hive_isp_css_common/host/debug.o \
-	css2400/hive_isp_css_common/host/hmem.o \
-	css2400/hive_isp_css_common/host/gp_device.o \
-	css2400/hive_isp_css_common/host/fifo_monitor.o \
-	css2400/hive_isp_css_common/host/gp_timer.o \
-	css2400/hive_isp_css_common/host/irq.o \
-	css2400/hive_isp_css_common/host/input_system.o \
-	css2400/hive_isp_css_common/host/timed_ctrl.o \
-	css2400/hive_isp_css_common/host/mmu.o \
-	css2400/hive_isp_css_common/host/event_fifo.o \
-	css2400/sh_css_param_dvs.o \
-	css2400/sh_css_shading.o \
-	css2400/sh_css_stream.o \
-	mmu/sh_mmu_mrfld.o \
-	mmu/isp_mmu.o \
-	atomisp_acc.o \
-	atomisp_compat_css20.o \
-	atomisp_fops.o \
-	atomisp_subdev.o \
-	atomisp_ioctl.o \
-	atomisp_compat_ioctl32.o \
-	atomisp_csi2.o \
-	atomisp_cmd.o \
-	atomisp_tpg.o \
-	hmm/hmm_vm.o \
-	hmm/hmm.o \
-	hmm/hmm_bo.o \
-	hmm/hmm_reserved_pool.o \
-	hmm/hmm_dynamic_pool.o \
-	hrt/hive_isp_css_mm_hrt.o \
-	atomisp_v4l2.o
-	
-# These will be needed when clean merge CHT support nicely into the driver
-# Keep them here handy for when we get to that point
-#
-
-obj-cht= \
-	css2400/css_2401_system/spmem_dump.o \
-	css2400/css_2401_system/hive_isp_css_2401_system_generated/ia_css_isp_states.o \
-	css2400/css_2401_system/hive_isp_css_2401_system_generated/ia_css_isp_configs.o \
-	css2400/css_2401_system/hive_isp_css_2401_system_generated/ia_css_isp_params.o \
-	css2400/css_2401_csi2p_system/spmem_dump.o \
-	css2400/css_2401_csi2p_system/host/isys_stream2mmio.o \
-	css2400/css_2401_csi2p_system/host/ibuf_ctrl.o \
-	css2400/css_2401_csi2p_system/host/isys_irq.o \
-	css2400/css_2401_csi2p_system/host/isys_dma.o \
-	css2400/css_2401_csi2p_system/host/csi_rx.o \
-	css2400/css_2401_csi2p_system/hive_isp_css_2401_system_csi2p_generated/ia_css_isp_states.o \
-	css2400/css_2401_csi2p_system/hive_isp_css_2401_system_csi2p_generated/ia_css_isp_configs.o \
-	css2400/css_2401_csi2p_system/hive_isp_css_2401_system_csi2p_generated/ia_css_isp_params.o \
-
-#	-I$(atomisp)/css2400/css_2401_csi2p_system/ \
-#	-I$(atomisp)/css2400/css_2401_csi2p_system/hive_isp_css_2401_system_csi2p_generated/ \
-#	-I$(atomisp)/css2400/css_2401_csi2p_system/host/ \
-#	-I$(atomisp)/css2400/css_2401_csi2p_system/hrt/ \
-#	-I$(atomisp)/css2400/css_2401_system/hive_isp_css_2401_system_generated/ \
-#	-I$(atomisp)/css2400/css_2401_system/hrt/ \
-
-
-
-obj-$(CONFIG_VIDEO_ATOMISP) += atomisp.o
-
-atomisp = $(srctree)/drivers/staging/media/atomisp/pci/atomisp2
-
-INCLUDES += \
-	-I$(atomisp)/ \
-	-I$(atomisp)/css2400/ \
-	-I$(atomisp)/hrt/ \
-	-I$(atomisp)/include/ \
-	-I$(atomisp)/include/hmm/ \
-	-I$(atomisp)/include/mmu/ \
-	-I$(atomisp)/css2400/base/circbuf/interface/ \
-	-I$(atomisp)/css2400/base/refcount/interface/ \
-	-I$(atomisp)/css2400/camera/pipe/interface/ \
-	-I$(atomisp)/css2400/camera/util/interface/ \
-	-I$(atomisp)/css2400/css_2400_system/ \
-	-I$(atomisp)/css2400/css_2400_system/hive_isp_css_2400_system_generated/ \
-	-I$(atomisp)/css2400/css_2400_system/hrt/ \
-	-I$(atomisp)/css2400/hive_isp_css_common/ \
-	-I$(atomisp)/css2400/hive_isp_css_common/host/ \
-	-I$(atomisp)/css2400/hive_isp_css_include/ \
-	-I$(atomisp)/css2400/hive_isp_css_include/device_access/ \
-	-I$(atomisp)/css2400/hive_isp_css_include/host/ \
-	-I$(atomisp)/css2400/hive_isp_css_include/memory_access/ \
-	-I$(atomisp)/css2400/hive_isp_css_shared/ \
-	-I$(atomisp)/css2400/hive_isp_css_shared/host/ \
-	-I$(atomisp)/css2400/isp/kernels/ \
-	-I$(atomisp)/css2400/isp/kernels/aa/aa_2/ \
-	-I$(atomisp)/css2400/isp/kernels/anr/anr_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/anr/anr_2/ \
-	-I$(atomisp)/css2400/isp/kernels/bh/bh_2/ \
-	-I$(atomisp)/css2400/isp/kernels/bnlm/ \
-	-I$(atomisp)/css2400/isp/kernels/bnr/ \
-	-I$(atomisp)/css2400/isp/kernels/bnr/bnr_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/bnr/bnr2_2/ \
-	-I$(atomisp)/css2400/isp/kernels/cnr/ \
-	-I$(atomisp)/css2400/isp/kernels/cnr/cnr_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/cnr/cnr_2/ \
-	-I$(atomisp)/css2400/isp/kernels/conversion/ \
-	-I$(atomisp)/css2400/isp/kernels/conversion/conversion_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/copy_output/ \
-	-I$(atomisp)/css2400/isp/kernels/copy_output/copy_output_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/crop/ \
-	-I$(atomisp)/css2400/isp/kernels/crop/crop_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/csc/ \
-	-I$(atomisp)/css2400/isp/kernels/csc/csc_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/ctc/ \
-	-I$(atomisp)/css2400/isp/kernels/ctc/ctc_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/ctc/ctc1_5/ \
-	-I$(atomisp)/css2400/isp/kernels/ctc/ctc2/ \
-	-I$(atomisp)/css2400/isp/kernels/de/ \
-	-I$(atomisp)/css2400/isp/kernels/de/de_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/de/de_2/ \
-	-I$(atomisp)/css2400/isp/kernels/dpc2/ \
-	-I$(atomisp)/css2400/isp/kernels/dp/ \
-	-I$(atomisp)/css2400/isp/kernels/dp/dp_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/dvs/ \
-	-I$(atomisp)/css2400/isp/kernels/dvs/dvs_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/eed1_8/ \
-	-I$(atomisp)/css2400/isp/kernels/fc/ \
-	-I$(atomisp)/css2400/isp/kernels/fc/fc_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/fixedbds/ \
-	-I$(atomisp)/css2400/isp/kernels/fixedbds/fixedbds_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/fpn/ \
-	-I$(atomisp)/css2400/isp/kernels/fpn/fpn_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/gc/ \
-	-I$(atomisp)/css2400/isp/kernels/gc/gc_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/gc/gc_2/ \
-	-I$(atomisp)/css2400/isp/kernels/hdr/ \
-	-I$(atomisp)/css2400/isp/kernels/io_ls/ \
-	-I$(atomisp)/css2400/isp/kernels/io_ls/bayer_io_ls/ \
-	-I$(atomisp)/css2400/isp/kernels/io_ls/common/ \
-	-I$(atomisp)/css2400/isp/kernels/io_ls/yuv444_io_ls/ \
-	-I$(atomisp)/css2400/isp/kernels/ipu2_io_ls/ \
-	-I$(atomisp)/css2400/isp/kernels/ipu2_io_ls/bayer_io_ls/ \
-	-I$(atomisp)/css2400/isp/kernels/ipu2_io_ls/common/ \
-	-I$(atomisp)/css2400/isp/kernels/ipu2_io_ls/yuv444_io_ls/ \
-	-I$(atomisp)/css2400/isp/kernels/iterator/ \
-	-I$(atomisp)/css2400/isp/kernels/iterator/iterator_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/macc/ \
-	-I$(atomisp)/css2400/isp/kernels/macc/macc_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/macc/macc1_5/ \
-	-I$(atomisp)/css2400/isp/kernels/norm/ \
-	-I$(atomisp)/css2400/isp/kernels/norm/norm_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/ob/ \
-	-I$(atomisp)/css2400/isp/kernels/ob/ob_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/ob/ob2/ \
-	-I$(atomisp)/css2400/isp/kernels/output/ \
-	-I$(atomisp)/css2400/isp/kernels/output/output_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/qplane/ \
-	-I$(atomisp)/css2400/isp/kernels/qplane/qplane_2/ \
-	-I$(atomisp)/css2400/isp/kernels/raw_aa_binning/ \
-	-I$(atomisp)/css2400/isp/kernels/raw_aa_binning/raw_aa_binning_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/raw/ \
-	-I$(atomisp)/css2400/isp/kernels/raw/raw_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/ref/ \
-	-I$(atomisp)/css2400/isp/kernels/ref/ref_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/s3a/ \
-	-I$(atomisp)/css2400/isp/kernels/s3a/s3a_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/sc/ \
-	-I$(atomisp)/css2400/isp/kernels/sc/sc_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/sdis/ \
-	-I$(atomisp)/css2400/isp/kernels/sdis/common/ \
-	-I$(atomisp)/css2400/isp/kernels/sdis/sdis_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/sdis/sdis_2/ \
-	-I$(atomisp)/css2400/isp/kernels/tdf/ \
-	-I$(atomisp)/css2400/isp/kernels/tdf/tdf_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/tnr/ \
-	-I$(atomisp)/css2400/isp/kernels/tnr/tnr_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/tnr/tnr3/ \
-	-I$(atomisp)/css2400/isp/kernels/uds/ \
-	-I$(atomisp)/css2400/isp/kernels/uds/uds_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/vf/ \
-	-I$(atomisp)/css2400/isp/kernels/vf/vf_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/wb/ \
-	-I$(atomisp)/css2400/isp/kernels/wb/wb_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/xnr/ \
-	-I$(atomisp)/css2400/isp/kernels/xnr/xnr_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/xnr/xnr_3.0/ \
-	-I$(atomisp)/css2400/isp/kernels/ynr/ \
-	-I$(atomisp)/css2400/isp/kernels/ynr/ynr_1.0/ \
-	-I$(atomisp)/css2400/isp/kernels/ynr/ynr_2/ \
-	-I$(atomisp)/css2400/isp/modes/interface/ \
-	-I$(atomisp)/css2400/runtime/binary/interface/ \
-	-I$(atomisp)/css2400/runtime/bufq/interface/ \
-	-I$(atomisp)/css2400/runtime/debug/interface/ \
-	-I$(atomisp)/css2400/runtime/event/interface/ \
-	-I$(atomisp)/css2400/runtime/eventq/interface/ \
-	-I$(atomisp)/css2400/runtime/frame/interface/ \
-	-I$(atomisp)/css2400/runtime/ifmtr/interface/ \
-	-I$(atomisp)/css2400/runtime/inputfifo/interface/ \
-	-I$(atomisp)/css2400/runtime/isp_param/interface/ \
-	-I$(atomisp)/css2400/runtime/isys/interface/ \
-	-I$(atomisp)/css2400/runtime/isys/src/ \
-	-I$(atomisp)/css2400/runtime/pipeline/interface/ \
-	-I$(atomisp)/css2400/runtime/queue/interface/ \
-	-I$(atomisp)/css2400/runtime/queue/src/ \
-	-I$(atomisp)/css2400/runtime/rmgr/interface/ \
-	-I$(atomisp)/css2400/runtime/spctrl/interface/ \
-	-I$(atomisp)/css2400/runtime/tagger/interface/
-
-ifeq ($(CONFIG_ION),y)
-INCLUDES += -I$(srctree)/drivers/staging/android/ion
-endif
-
-DEFINES := -DHRT_HW -DHRT_ISP_CSS_CUSTOM_HOST -DHRT_USE_VIR_ADDRS -D__HOST__
-#DEFINES += -DUSE_DYNAMIC_BIN
-#DEFINES += -DISP_POWER_GATING
-#DEFINES += -DUSE_INTERRUPTS
-#DEFINES += -DUSE_SSSE3
-#DEFINES += -DPUNIT_CAMERA_BUSY
-#DEFINES += -DUSE_KMEM_CACHE
-
-DEFINES += -DATOMISP_POSTFIX=\"css2400b0_v21\" -DISP2400B0
-DEFINES += -DSYSTEM_hive_isp_css_2400_system -DISP2400
-
-ccflags-y += $(INCLUDES) $(DEFINES) -fno-common
-
-# HACK! While this driver is in bad shape, don't enable several warnings
-#       that would be otherwise enabled with W=1
-ccflags-y += $(call cc-disable-warning, implicit-fallthrough)
-ccflags-y += $(call cc-disable-warning, missing-prototypes)
-ccflags-y += $(call cc-disable-warning, missing-declarations)
-ccflags-y += $(call cc-disable-warning, suggest-attribute=format)
-ccflags-y += $(call cc-disable-warning, unused-const-variable)
-ccflags-y += $(call cc-disable-warning, unused-but-set-variable)

+ 0 - 205
drivers/staging/media/atomisp/pci/atomisp2/atomisp-regs.h

@@ -1,205 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
- *
- * 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 ATOMISP_REGS_H
-#define ATOMISP_REGS_H
-
-/* common register definitions */
-#define PUNIT_PORT		0x04
-#define CCK_PORT		0x14
-
-#define PCICMDSTS		0x01
-#define INTR			0x0f
-#define MSI_CAPID		0x24
-#define MSI_ADDRESS		0x25
-#define MSI_DATA		0x26
-#define INTR_CTL		0x27
-
-#define PCI_MSI_CAPID		0x90
-#define PCI_MSI_ADDR		0x94
-#define PCI_MSI_DATA		0x98
-#define PCI_INTERRUPT_CTRL	0x9C
-#define PCI_I_CONTROL		0xfc
-
-/* MRFLD specific register definitions */
-#define MRFLD_CSI_AFE		0x39
-#define MRFLD_CSI_CONTROL	0x3a
-#define MRFLD_CSI_RCOMP		0x3d
-
-#define MRFLD_PCI_PMCS		0x84
-#define MRFLD_PCI_CSI_ACCESS_CTRL_VIOL	0xd4
-#define MRFLD_PCI_CSI_AFE_HS_CONTROL	0xdc
-#define MRFLD_PCI_CSI_AFE_RCOMP_CONTROL	0xe0
-#define MRFLD_PCI_CSI_CONTROL		0xe8
-#define MRFLD_PCI_CSI_AFE_TRIM_CONTROL	0xe4
-#define MRFLD_PCI_CSI_DEADLINE_CONTROL	0xec
-#define MRFLD_PCI_CSI_RCOMP_CONTROL	0xf4
-
-/* Select Arasan (legacy)/Intel input system */
-#define MRFLD_PCI_CSI_CONTROL_PARPATHEN	BIT(24)
-/* Enable CSI interface (ANN B0/K0) */
-#define MRFLD_PCI_CSI_CONTROL_CSI_READY	BIT(25)
-
-/*
- * Enables the combining of adjacent 32-byte read requests to the same
- * cache line. When cleared, each 32-byte read request is sent as a
- * separate request on the IB interface.
- */
-#define MRFLD_PCI_I_CONTROL_ENABLE_READ_COMBINING	0x1
-
-/*
- * Register: MRFLD_PCI_CSI_RCOMP_CONTROL
- * If cleared, the high speed clock going to the digital logic is gated when
- * RCOMP update is happening. The clock is gated for a minimum of 100 nsec.
- * If this bit is set, then the high speed clock is not gated during the
- * update cycle.
- */
-#define MRFLD_PCI_CSI_HS_OVR_CLK_GATE_ON_UPDATE		0x800000
-
-/*
- * Enables the combining of adjacent 32-byte write requests to the same
- * cache line. When cleared, each 32-byte write request is sent as a
- * separate request on the IB interface.
- */
-#define MRFLD_PCI_I_CONTROL_ENABLE_WRITE_COMBINING	0x2
-
-#define MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK		0xc
-
-#define MRFLD_PCI_CSI1_HSRXCLKTRIM		0x2
-#define MRFLD_PCI_CSI1_HSRXCLKTRIM_SHIFT	16
-#define MRFLD_PCI_CSI2_HSRXCLKTRIM		0x3
-#define MRFLD_PCI_CSI2_HSRXCLKTRIM_SHIFT	24
-#define MRFLD_PCI_CSI3_HSRXCLKTRIM		0x2
-#define MRFLD_PCI_CSI3_HSRXCLKTRIM_SHIFT	28
-#define MRFLD_PCI_CSI_HSRXCLKTRIM_MASK		0xf
-
-/*
- * This register is IUINT MMIO register, it is used to select the CSI
- * receiver backend.
- * 1: SH CSI backend
- * 0: Arasan CSI backend
- */
-#define MRFLD_CSI_RECEIVER_SELECTION_REG       0x8081c
-
-#define MRFLD_INTR_CLEAR_REG		       0x50c
-#define MRFLD_INTR_STATUS_REG		       0x508
-#define MRFLD_INTR_ENABLE_REG		       0x510
-
-#define MRFLD_MAX_ZOOM_FACTOR	1024
-
-/* MRFLD ISP POWER related */
-#define MRFLD_ISPSSPM0         0x39
-#define MRFLD_ISPSSPM0_ISPSSC_OFFSET   0
-#define MRFLD_ISPSSPM0_ISPSSS_OFFSET   24
-#define MRFLD_ISPSSPM0_ISPSSC_MASK     0x3
-#define MRFLD_ISPSSPM0_IUNIT_POWER_ON  0
-#define MRFLD_ISPSSPM0_IUNIT_POWER_OFF 0x3
-#define MRFLD_ISPSSDVFS			0x13F
-#define MRFLD_BIT0			0x0001
-#define MRFLD_BIT1			0x0002
-
-/* MRFLD CSI lane configuration related */
-#define MRFLD_PORT_CONFIG_NUM  8
-#define MRFLD_PORT_NUM         3
-#define MRFLD_PORT1_ENABLE_SHIFT       0
-#define MRFLD_PORT2_ENABLE_SHIFT       1
-#define MRFLD_PORT3_ENABLE_SHIFT       2
-#define MRFLD_PORT1_LANES_SHIFT        3
-#define MRFLD_PORT2_LANES_SHIFT        7
-#define MRFLD_PORT3_LANES_SHIFT        8
-#define MRFLD_PORT_CONFIG_MASK 0x000f03ff
-#define MRFLD_PORT_CONFIGCODE_SHIFT    16
-#define MRFLD_ALL_CSI_PORTS_OFF_MASK   0x7
-
-#define CHV_PORT3_LANES_SHIFT		9
-#define CHV_PORT_CONFIG_MASK		0x1f07ff
-
-#define ISPSSPM1				0x3a
-#define ISP_FREQ_STAT_MASK			(0x1f << ISP_FREQ_STAT_OFFSET)
-#define ISP_REQ_FREQ_MASK			0x1f
-#define ISP_FREQ_VALID_MASK			(0x1 << ISP_FREQ_VALID_OFFSET)
-#define ISP_FREQ_STAT_OFFSET			0x18
-#define ISP_REQ_GUAR_FREQ_OFFSET		0x8
-#define ISP_REQ_FREQ_OFFSET			0x0
-#define ISP_FREQ_VALID_OFFSET			0x7
-#define ISP_FREQ_RULE_ANY			0x0
-
-#define ISP_FREQ_457MHZ				0x1C9
-#define ISP_FREQ_400MHZ				0x190
-#define ISP_FREQ_356MHZ				0x164
-#define ISP_FREQ_320MHZ				0x140
-#define ISP_FREQ_266MHZ				0x10a
-#define ISP_FREQ_200MHZ				0xc8
-#define ISP_FREQ_100MHZ				0x64
-
-#define HPLL_FREQ_800MHZ			0x320
-#define HPLL_FREQ_1600MHZ			0x640
-#define HPLL_FREQ_2000MHZ			0x7D0
-
-#define CCK_FUSE_REG_0			0x08
-#define CCK_FUSE_HPLL_FREQ_MASK		0x03
-
-#if defined(ISP2401)
-#define ISP_FREQ_MAX	ISP_FREQ_320MHZ
-#else
-#define ISP_FREQ_MAX	ISP_FREQ_400MHZ
-#endif
-
-/* ISP2401 CSI2+ receiver delay settings */
-#define CSI2_PORT_A_BASE					0xC0000
-#define CSI2_PORT_B_BASE					0xC2000
-#define CSI2_PORT_C_BASE					0xC4000
-
-#define CSI2_LANE_CL_BASE					0x418
-#define CSI2_LANE_D0_BASE					0x420
-#define CSI2_LANE_D1_BASE					0x428
-#define CSI2_LANE_D2_BASE					0x430
-#define CSI2_LANE_D3_BASE					0x438
-
-#define CSI2_REG_RX_CSI_DLY_CNT_TERMEN				0
-#define CSI2_REG_RX_CSI_DLY_CNT_SETTLE				0x4
-
-#define CSI2_PORT_A_RX_CSI_DLY_CNT_TERMEN_CLANE			0xC0418
-#define CSI2_PORT_A_RX_CSI_DLY_CNT_SETTLE_CLANE			0xC041C
-#define CSI2_PORT_A_RX_CSI_DLY_CNT_TERMEN_DLANE0		0xC0420
-#define CSI2_PORT_A_RX_CSI_DLY_CNT_SETTLE_DLANE0		0xC0424
-#define CSI2_PORT_A_RX_CSI_DLY_CNT_TERMEN_DLANE1		0xC0428
-#define CSI2_PORT_A_RX_CSI_DLY_CNT_SETTLE_DLANE1		0xC042C
-#define CSI2_PORT_A_RX_CSI_DLY_CNT_TERMEN_DLANE2		0xC0430
-#define CSI2_PORT_A_RX_CSI_DLY_CNT_SETTLE_DLANE2		0xC0434
-#define CSI2_PORT_A_RX_CSI_DLY_CNT_TERMEN_DLANE3		0xC0438
-#define CSI2_PORT_A_RX_CSI_DLY_CNT_SETTLE_DLANE3		0xC043C
-
-#define CSI2_PORT_B_RX_CSI_DLY_CNT_TERMEN_CLANE			0xC2418
-#define CSI2_PORT_B_RX_CSI_DLY_CNT_SETTLE_CLANE			0xC241C
-#define CSI2_PORT_B_RX_CSI_DLY_CNT_TERMEN_DLANE0		0xC2420
-#define CSI2_PORT_B_RX_CSI_DLY_CNT_SETTLE_DLANE0		0xC2424
-#define CSI2_PORT_B_RX_CSI_DLY_CNT_TERMEN_DLANE1		0xC2428
-#define CSI2_PORT_B_RX_CSI_DLY_CNT_SETTLE_DLANE1		0xC242C
-
-#define CSI2_PORT_C_RX_CSI_DLY_CNT_TERMEN_CLANE			0xC4418
-#define CSI2_PORT_C_RX_CSI_DLY_CNT_SETTLE_CLANE			0xC441C
-#define CSI2_PORT_C_RX_CSI_DLY_CNT_TERMEN_DLANE0		0xC4420
-#define CSI2_PORT_C_RX_CSI_DLY_CNT_SETTLE_DLANE0		0xC4424
-#define CSI2_PORT_C_RX_CSI_DLY_CNT_TERMEN_DLANE1		0xC4428
-#define CSI2_PORT_C_RX_CSI_DLY_CNT_SETTLE_DLANE1		0xC442C
-
-#define DMA_BURST_SIZE_REG					0xCD408
-
-#define ISP_DFS_TRY_TIMES	2
-
-#endif /* ATOMISP_REGS_H */

+ 0 - 604
drivers/staging/media/atomisp/pci/atomisp2/atomisp_acc.c

@@ -1,604 +0,0 @@
-/*
- * Support for Clovertrail PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- *
- */
-
-/*
- * This file implements loadable acceleration firmware API,
- * including ioctls to map and unmap acceleration parameters and buffers.
- */
-
-#include <linux/init.h>
-#include <media/v4l2-event.h>
-
-#include "atomisp_acc.h"
-#include "atomisp_internal.h"
-#include "atomisp_compat.h"
-#include "atomisp_cmd.h"
-
-#include "hrt/hive_isp_css_mm_hrt.h"
-#include "memory_access/memory_access.h"
-#include "ia_css.h"
-
-static const struct {
-	unsigned int flag;
-	enum atomisp_css_pipe_id pipe_id;
-} acc_flag_to_pipe[] = {
-	{ ATOMISP_ACC_FW_LOAD_FL_PREVIEW, CSS_PIPE_ID_PREVIEW },
-	{ ATOMISP_ACC_FW_LOAD_FL_COPY, CSS_PIPE_ID_COPY },
-	{ ATOMISP_ACC_FW_LOAD_FL_VIDEO, CSS_PIPE_ID_VIDEO },
-	{ ATOMISP_ACC_FW_LOAD_FL_CAPTURE, CSS_PIPE_ID_CAPTURE },
-	{ ATOMISP_ACC_FW_LOAD_FL_ACC, CSS_PIPE_ID_ACC }
-};
-
-/*
- * Allocate struct atomisp_acc_fw along with space for firmware.
- * The returned struct atomisp_acc_fw is cleared (firmware region is not).
- */
-static struct atomisp_acc_fw *acc_alloc_fw(unsigned int fw_size)
-{
-	struct atomisp_acc_fw *acc_fw;
-
-	acc_fw = kzalloc(sizeof(*acc_fw), GFP_KERNEL);
-	if (!acc_fw)
-		return NULL;
-
-	acc_fw->fw = vmalloc(fw_size);
-	if (!acc_fw->fw) {
-		kfree(acc_fw);
-		return NULL;
-	}
-
-	return acc_fw;
-}
-
-static void acc_free_fw(struct atomisp_acc_fw *acc_fw)
-{
-	vfree(acc_fw->fw);
-	kfree(acc_fw);
-}
-
-static struct atomisp_acc_fw *
-acc_get_fw(struct atomisp_sub_device *asd, unsigned int handle)
-{
-	struct atomisp_acc_fw *acc_fw;
-
-	list_for_each_entry(acc_fw, &asd->acc.fw, list)
-		if (acc_fw->handle == handle)
-			return acc_fw;
-
-	return NULL;
-}
-
-static struct atomisp_map *acc_get_map(struct atomisp_sub_device *asd,
-				       unsigned long css_ptr, size_t length)
-{
-	struct atomisp_map *atomisp_map;
-
-	list_for_each_entry(atomisp_map, &asd->acc.memory_maps, list) {
-		if (atomisp_map->ptr == css_ptr &&
-		    atomisp_map->length == length)
-			return atomisp_map;
-	}
-	return NULL;
-}
-
-static int acc_stop_acceleration(struct atomisp_sub_device *asd)
-{
-	int ret;
-
-	ret = atomisp_css_stop_acc_pipe(asd);
-	atomisp_css_destroy_acc_pipe(asd);
-
-	return ret;
-}
-
-void atomisp_acc_cleanup(struct atomisp_device *isp)
-{
-	int i;
-
-	for (i = 0; i < isp->num_of_streams; i++)
-		ida_destroy(&isp->asd[i].acc.ida);
-}
-
-void atomisp_acc_release(struct atomisp_sub_device *asd)
-{
-	struct atomisp_acc_fw *acc_fw, *ta;
-	struct atomisp_map *atomisp_map, *tm;
-
-	/* Stop acceleration if already running */
-	if (asd->acc.pipeline)
-		acc_stop_acceleration(asd);
-
-	/* Unload all loaded acceleration binaries */
-	list_for_each_entry_safe(acc_fw, ta, &asd->acc.fw, list) {
-		list_del(&acc_fw->list);
-		ida_remove(&asd->acc.ida, acc_fw->handle);
-		acc_free_fw(acc_fw);
-	}
-
-	/* Free all mapped memory blocks */
-	list_for_each_entry_safe(atomisp_map, tm, &asd->acc.memory_maps, list) {
-		list_del(&atomisp_map->list);
-		hmm_free(atomisp_map->ptr);
-		kfree(atomisp_map);
-	}
-}
-
-int atomisp_acc_load_to_pipe(struct atomisp_sub_device *asd,
-			     struct atomisp_acc_fw_load_to_pipe *user_fw)
-{
-	static const unsigned int pipeline_flags =
-		ATOMISP_ACC_FW_LOAD_FL_PREVIEW | ATOMISP_ACC_FW_LOAD_FL_COPY |
-		ATOMISP_ACC_FW_LOAD_FL_VIDEO |
-		ATOMISP_ACC_FW_LOAD_FL_CAPTURE | ATOMISP_ACC_FW_LOAD_FL_ACC;
-
-	struct atomisp_acc_fw *acc_fw;
-	int handle;
-
-	if (!user_fw->data || user_fw->size < sizeof(*acc_fw->fw))
-		return -EINVAL;
-
-	/* Binary has to be enabled at least for one pipeline */
-	if (!(user_fw->flags & pipeline_flags))
-		return -EINVAL;
-
-	/* We do not support other flags yet */
-	if (user_fw->flags & ~pipeline_flags)
-		return -EINVAL;
-
-	if (user_fw->type < ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT ||
-	    user_fw->type > ATOMISP_ACC_FW_LOAD_TYPE_STANDALONE)
-		return -EINVAL;
-
-	if (asd->acc.pipeline || asd->acc.extension_mode)
-		return -EBUSY;
-
-	acc_fw = acc_alloc_fw(user_fw->size);
-	if (!acc_fw)
-		return -ENOMEM;
-
-	if (copy_from_user(acc_fw->fw, user_fw->data, user_fw->size)) {
-		acc_free_fw(acc_fw);
-		return -EFAULT;
-	}
-
-	if (!ida_pre_get(&asd->acc.ida, GFP_KERNEL) ||
-	    ida_get_new_above(&asd->acc.ida, 1, &handle)) {
-		acc_free_fw(acc_fw);
-		return -ENOSPC;
-	}
-
-	user_fw->fw_handle = handle;
-	acc_fw->handle = handle;
-	acc_fw->flags = user_fw->flags;
-	acc_fw->type = user_fw->type;
-	acc_fw->fw->handle = handle;
-
-	/*
-	 * correct isp firmware type in order ISP firmware can be appended
-	 * to correct pipe properly
-	 */
-	if (acc_fw->fw->type == ia_css_isp_firmware) {
-		static const int type_to_css[] = {
-			[ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT] =
-				IA_CSS_ACC_OUTPUT,
-			[ATOMISP_ACC_FW_LOAD_TYPE_VIEWFINDER] =
-				IA_CSS_ACC_VIEWFINDER,
-			[ATOMISP_ACC_FW_LOAD_TYPE_STANDALONE] =
-				IA_CSS_ACC_STANDALONE,
-		};
-		acc_fw->fw->info.isp.type = type_to_css[acc_fw->type];
-	}
-
-	list_add_tail(&acc_fw->list, &asd->acc.fw);
-	return 0;
-}
-
-int atomisp_acc_load(struct atomisp_sub_device *asd,
-		     struct atomisp_acc_fw_load *user_fw)
-{
-	struct atomisp_acc_fw_load_to_pipe ltp = {0};
-	int r;
-
-	ltp.flags = ATOMISP_ACC_FW_LOAD_FL_ACC;
-	ltp.type = ATOMISP_ACC_FW_LOAD_TYPE_STANDALONE;
-	ltp.size = user_fw->size;
-	ltp.data = user_fw->data;
-	r = atomisp_acc_load_to_pipe(asd, &ltp);
-	user_fw->fw_handle = ltp.fw_handle;
-	return r;
-}
-
-int atomisp_acc_unload(struct atomisp_sub_device *asd, unsigned int *handle)
-{
-	struct atomisp_acc_fw *acc_fw;
-
-	if (asd->acc.pipeline || asd->acc.extension_mode)
-		return -EBUSY;
-
-	acc_fw = acc_get_fw(asd, *handle);
-	if (!acc_fw)
-		return -EINVAL;
-
-	list_del(&acc_fw->list);
-	ida_remove(&asd->acc.ida, acc_fw->handle);
-	acc_free_fw(acc_fw);
-
-	return 0;
-}
-
-int atomisp_acc_start(struct atomisp_sub_device *asd, unsigned int *handle)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct atomisp_acc_fw *acc_fw;
-	int ret;
-	unsigned int nbin;
-
-	if (asd->acc.pipeline || asd->acc.extension_mode)
-		return -EBUSY;
-
-	/* Invalidate caches. FIXME: should flush only necessary buffers */
-	wbinvd();
-
-	ret = atomisp_css_create_acc_pipe(asd);
-	if (ret)
-		return ret;
-
-	nbin = 0;
-	list_for_each_entry(acc_fw, &asd->acc.fw, list) {
-		if (*handle != 0 && *handle != acc_fw->handle)
-			continue;
-
-		if (acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_STANDALONE)
-			continue;
-
-		/* Add the binary into the pipeline */
-		ret = atomisp_css_load_acc_binary(asd, acc_fw->fw, nbin);
-		if (ret < 0) {
-			dev_err(isp->dev, "acc_load_binary failed\n");
-			goto err_stage;
-		}
-
-		ret = atomisp_css_set_acc_parameters(acc_fw);
-		if (ret < 0) {
-			dev_err(isp->dev, "acc_set_parameters failed\n");
-			goto err_stage;
-		}
-		nbin++;
-	}
-	if (nbin < 1) {
-		/* Refuse creating pipelines with no binaries */
-		dev_err(isp->dev, "%s: no acc binary available\n", __func__);
-		ret = -EINVAL;
-		goto err_stage;
-	}
-
-	ret = atomisp_css_start_acc_pipe(asd);
-	if (ret) {
-		dev_err(isp->dev, "%s: atomisp_acc_start_acc_pipe failed\n",
-			__func__);
-		goto err_stage;
-	}
-
-	return 0;
-
-err_stage:
-	atomisp_css_destroy_acc_pipe(asd);
-	return ret;
-}
-
-int atomisp_acc_wait(struct atomisp_sub_device *asd, unsigned int *handle)
-{
-	struct atomisp_device *isp = asd->isp;
-	int ret;
-
-	if (!asd->acc.pipeline)
-		return -ENOENT;
-
-	if (*handle && !acc_get_fw(asd, *handle))
-		return -EINVAL;
-
-	ret = atomisp_css_wait_acc_finish(asd);
-	if (acc_stop_acceleration(asd) == -EIO) {
-		atomisp_reset(isp);
-		return -EINVAL;
-	}
-
-	return ret;
-}
-
-void atomisp_acc_done(struct atomisp_sub_device *asd, unsigned int handle)
-{
-	struct v4l2_event event = { 0 };
-
-	event.type = V4L2_EVENT_ATOMISP_ACC_COMPLETE;
-	event.u.frame_sync.frame_sequence = atomic_read(&asd->sequence);
-	event.id = handle;
-
-	v4l2_event_queue(asd->subdev.devnode, &event);
-}
-
-int atomisp_acc_map(struct atomisp_sub_device *asd, struct atomisp_acc_map *map)
-{
-	struct atomisp_map *atomisp_map;
-	ia_css_ptr cssptr;
-	int pgnr;
-
-	if (map->css_ptr)
-		return -EINVAL;
-
-	if (asd->acc.pipeline)
-		return -EBUSY;
-
-	if (map->user_ptr) {
-		/* Buffer to map must be page-aligned */
-		if ((unsigned long)map->user_ptr & ~PAGE_MASK) {
-			dev_err(asd->isp->dev,
-				"%s: mapped buffer address %p is not page aligned\n",
-				__func__, map->user_ptr);
-			return -EINVAL;
-		}
-
-		pgnr = DIV_ROUND_UP(map->length, PAGE_SIZE);
-		cssptr = hrt_isp_css_mm_alloc_user_ptr(map->length,
-						       map->user_ptr,
-						       pgnr, HRT_USR_PTR,
-						       (map->flags & ATOMISP_MAP_FLAG_CACHED));
-	} else {
-		/* Allocate private buffer. */
-		if (map->flags & ATOMISP_MAP_FLAG_CACHED)
-			cssptr = hrt_isp_css_mm_calloc_cached(map->length);
-		else
-			cssptr = hrt_isp_css_mm_calloc(map->length);
-	}
-
-	if (!cssptr)
-		return -ENOMEM;
-
-	atomisp_map = kmalloc(sizeof(*atomisp_map), GFP_KERNEL);
-	if (!atomisp_map) {
-		hmm_free(cssptr);
-		return -ENOMEM;
-	}
-	atomisp_map->ptr = cssptr;
-	atomisp_map->length = map->length;
-	list_add(&atomisp_map->list, &asd->acc.memory_maps);
-
-	dev_dbg(asd->isp->dev, "%s: userptr %p, css_address 0x%x, size %d\n",
-		__func__, map->user_ptr, cssptr, map->length);
-	map->css_ptr = cssptr;
-	return 0;
-}
-
-int atomisp_acc_unmap(struct atomisp_sub_device *asd, struct atomisp_acc_map *map)
-{
-	struct atomisp_map *atomisp_map;
-
-	if (asd->acc.pipeline)
-		return -EBUSY;
-
-	atomisp_map = acc_get_map(asd, map->css_ptr, map->length);
-	if (!atomisp_map)
-		return -EINVAL;
-
-	list_del(&atomisp_map->list);
-	hmm_free(atomisp_map->ptr);
-	kfree(atomisp_map);
-	return 0;
-}
-
-int atomisp_acc_s_mapped_arg(struct atomisp_sub_device *asd,
-			     struct atomisp_acc_s_mapped_arg *arg)
-{
-	struct atomisp_acc_fw *acc_fw;
-
-	if (arg->memory >= ATOMISP_ACC_NR_MEMORY)
-		return -EINVAL;
-
-	if (asd->acc.pipeline)
-		return -EBUSY;
-
-	acc_fw = acc_get_fw(asd, arg->fw_handle);
-	if (!acc_fw)
-		return -EINVAL;
-
-	if (arg->css_ptr != 0 || arg->length != 0) {
-		/* Unless the parameter is cleared, check that it exists */
-		if (!acc_get_map(asd, arg->css_ptr, arg->length))
-			return -EINVAL;
-	}
-
-	acc_fw->args[arg->memory].length = arg->length;
-	acc_fw->args[arg->memory].css_ptr = arg->css_ptr;
-
-	dev_dbg(asd->isp->dev, "%s: mem %d, address %p, size %ld\n",
-		__func__, arg->memory, (void *)arg->css_ptr,
-		(unsigned long)arg->length);
-	return 0;
-}
-
-/*
- * Appends the loaded acceleration binary extensions to the
- * current ISP mode. Must be called just before sh_css_start().
- */
-int atomisp_acc_load_extensions(struct atomisp_sub_device *asd)
-{
-	struct atomisp_acc_fw *acc_fw;
-	bool ext_loaded = false;
-	bool continuous = asd->continuous_mode->val &&
-			  asd->run_mode->val == ATOMISP_RUN_MODE_PREVIEW;
-	int ret = 0, i = -1;
-	struct atomisp_device *isp = asd->isp;
-
-	if (asd->acc.pipeline || asd->acc.extension_mode)
-		return -EBUSY;
-
-	/* Invalidate caches. FIXME: should flush only necessary buffers */
-	wbinvd();
-
-	list_for_each_entry(acc_fw, &asd->acc.fw, list) {
-		if (acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT &&
-		    acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_VIEWFINDER)
-			continue;
-
-		for (i = 0; i < ARRAY_SIZE(acc_flag_to_pipe); i++) {
-			/* QoS (ACC pipe) acceleration stages are currently
-			 * allowed only in continuous mode. Skip them for
-			 * all other modes. */
-			if (!continuous &&
-			    acc_flag_to_pipe[i].flag ==
-			    ATOMISP_ACC_FW_LOAD_FL_ACC)
-				continue;
-
-			if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
-				ret = atomisp_css_load_acc_extension(asd,
-					acc_fw->fw,
-					acc_flag_to_pipe[i].pipe_id,
-					acc_fw->type);
-				if (ret)
-					goto error;
-
-				ext_loaded = true;
-			}
-		}
-
-		ret = atomisp_css_set_acc_parameters(acc_fw);
-		if (ret < 0)
-			goto error;
-	}
-
-	if (!ext_loaded)
-		return ret;
-
-	ret = atomisp_css_update_stream(asd);
-	if (ret) {
-		dev_err(isp->dev, "%s: update stream failed.\n", __func__);
-		goto error;
-	}
-
-	asd->acc.extension_mode = true;
-	return 0;
-
-error:
-	while (--i >= 0) {
-		if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
-			atomisp_css_unload_acc_extension(asd, acc_fw->fw,
-					acc_flag_to_pipe[i].pipe_id);
-		}
-	}
-
-	list_for_each_entry_continue_reverse(acc_fw, &asd->acc.fw, list) {
-		if (acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT &&
-		    acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_VIEWFINDER)
-			continue;
-
-		for (i = ARRAY_SIZE(acc_flag_to_pipe) - 1; i >= 0; i--) {
-			if (!continuous &&
-			    acc_flag_to_pipe[i].flag ==
-			    ATOMISP_ACC_FW_LOAD_FL_ACC)
-				continue;
-			if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
-				atomisp_css_unload_acc_extension(asd,
-					acc_fw->fw,
-					acc_flag_to_pipe[i].pipe_id);
-			}
-		}
-	}
-	return ret;
-}
-
-void atomisp_acc_unload_extensions(struct atomisp_sub_device *asd)
-{
-	struct atomisp_acc_fw *acc_fw;
-	int i;
-
-	if (!asd->acc.extension_mode)
-		return;
-
-	list_for_each_entry_reverse(acc_fw, &asd->acc.fw, list) {
-		if (acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT &&
-		    acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_VIEWFINDER)
-			continue;
-
-		for (i = ARRAY_SIZE(acc_flag_to_pipe) - 1; i >= 0; i--) {
-			if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
-				atomisp_css_unload_acc_extension(asd,
-					acc_fw->fw,
-					acc_flag_to_pipe[i].pipe_id);
-			}
-		}
-	}
-
-	asd->acc.extension_mode = false;
-}
-
-int atomisp_acc_set_state(struct atomisp_sub_device *asd,
-			  struct atomisp_acc_state *arg)
-{
-	struct atomisp_acc_fw *acc_fw;
-	bool enable = (arg->flags & ATOMISP_STATE_FLAG_ENABLE) != 0;
-	struct ia_css_pipe *pipe;
-	enum ia_css_err r;
-	int i;
-
-	if (!asd->acc.extension_mode)
-		return -EBUSY;
-
-	if (arg->flags & ~ATOMISP_STATE_FLAG_ENABLE)
-		return -EINVAL;
-
-	acc_fw = acc_get_fw(asd, arg->fw_handle);
-	if (!acc_fw)
-		return -EINVAL;
-
-	if (enable)
-		wbinvd();
-
-	for (i = 0; i < ARRAY_SIZE(acc_flag_to_pipe); i++) {
-		if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
-			pipe = asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].
-				pipes[acc_flag_to_pipe[i].pipe_id];
-			r = ia_css_pipe_set_qos_ext_state(pipe, acc_fw->handle,
-							  enable);
-			if (r != IA_CSS_SUCCESS)
-				return -EBADRQC;
-		}
-	}
-
-	if (enable)
-		acc_fw->flags |= ATOMISP_ACC_FW_LOAD_FL_ENABLE;
-	else
-		acc_fw->flags &= ~ATOMISP_ACC_FW_LOAD_FL_ENABLE;
-
-	return 0;
-}
-
-int atomisp_acc_get_state(struct atomisp_sub_device *asd,
-			  struct atomisp_acc_state *arg)
-{
-	struct atomisp_acc_fw *acc_fw;
-
-	if (!asd->acc.extension_mode)
-		return -EBUSY;
-
-	acc_fw = acc_get_fw(asd, arg->fw_handle);
-	if (!acc_fw)
-		return -EINVAL;
-
-	arg->flags = acc_fw->flags;
-
-	return 0;
-}

+ 0 - 120
drivers/staging/media/atomisp/pci/atomisp2/atomisp_acc.h

@@ -1,120 +0,0 @@
-/*
- * Support for Clovertrail PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
- *
- * 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 __ATOMISP_ACC_H__
-#define __ATOMISP_ACC_H__
-
-#include "../../include/linux/atomisp.h"
-#include "atomisp_internal.h"
-
-#include "ia_css_types.h"
-
-/*
- * Interface functions for AtomISP driver acceleration API implementation.
- */
-
-struct atomisp_sub_device;
-
-void atomisp_acc_cleanup(struct atomisp_device *isp);
-
-/*
- * Free up any allocated resources.
- * Must be called each time when the device is closed.
- * Note that there isn't corresponding open() call;
- * this function may be called sequentially multiple times.
- * Must be called to free up resources before driver is unloaded.
- */
-void atomisp_acc_release(struct atomisp_sub_device *asd);
-
-/* Load acceleration binary. DEPRECATED. */
-int atomisp_acc_load(struct atomisp_sub_device *asd,
-		     struct atomisp_acc_fw_load *fw);
-
-/* Load acceleration binary with specified properties */
-int atomisp_acc_load_to_pipe(struct atomisp_sub_device *asd,
-			     struct atomisp_acc_fw_load_to_pipe *fw);
-
-/* Unload specified acceleration binary */
-int atomisp_acc_unload(struct atomisp_sub_device *asd,
-		       unsigned int *handle);
-
-/*
- * Map a memory region into ISP memory space.
- */
-int atomisp_acc_map(struct atomisp_sub_device *asd,
-		    struct atomisp_acc_map *map);
-
-/*
- * Unmap a mapped memory region.
- */
-int atomisp_acc_unmap(struct atomisp_sub_device *asd,
-		      struct atomisp_acc_map *map);
-
-/*
- * Set acceleration binary argument to a previously mapped memory region.
- */
-int atomisp_acc_s_mapped_arg(struct atomisp_sub_device *asd,
-			     struct atomisp_acc_s_mapped_arg *arg);
-
-
-/*
- * Start acceleration.
- * Return immediately, acceleration is left running in background.
- * Specify either acceleration binary or pipeline which to start.
- */
-int atomisp_acc_start(struct atomisp_sub_device *asd,
-		      unsigned int *handle);
-
-/*
- * Wait until acceleration finishes.
- * This MUST be called after each acceleration has been started.
- * Specify either acceleration binary or pipeline handle.
- */
-int atomisp_acc_wait(struct atomisp_sub_device *asd,
-		     unsigned int *handle);
-
-/*
- * Used by ISR to notify ACC stage finished.
- * This is internally used and does not export as IOCTL.
- */
-void atomisp_acc_done(struct atomisp_sub_device *asd, unsigned int handle);
-
-/*
- * Appends the loaded acceleration binary extensions to the
- * current ISP mode. Must be called just before atomisp_css_start().
- */
-int atomisp_acc_load_extensions(struct atomisp_sub_device *asd);
-
-/*
- * Must be called after streaming is stopped:
- * unloads any loaded acceleration extensions.
- */
-void atomisp_acc_unload_extensions(struct atomisp_sub_device *asd);
-
-/*
- * Set acceleration firmware flags.
- */
-int atomisp_acc_set_state(struct atomisp_sub_device *asd,
-			  struct atomisp_acc_state *arg);
-
-/*
- * Get acceleration firmware flags.
- */
-int atomisp_acc_get_state(struct atomisp_sub_device *asd,
-			  struct atomisp_acc_state *arg);
-
-#endif /* __ATOMISP_ACC_H__ */

+ 0 - 6697
drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c

@@ -1,6697 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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.
- *
- *
- */
-#include <linux/firmware.h>
-#include <linux/pci.h>
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/kfifo.h>
-#include <linux/pm_runtime.h>
-#include <linux/timer.h>
-
-#include <asm/iosf_mbi.h>
-
-#include <media/v4l2-event.h>
-#include <media/videobuf-vmalloc.h>
-
-#define CREATE_TRACE_POINTS
-#include "atomisp_trace_event.h"
-
-#include "atomisp_cmd.h"
-#include "atomisp_common.h"
-#include "atomisp_fops.h"
-#include "atomisp_internal.h"
-#include "atomisp_ioctl.h"
-#include "atomisp-regs.h"
-#include "atomisp_tables.h"
-#include "atomisp_acc.h"
-#include "atomisp_compat.h"
-#include "atomisp_subdev.h"
-#include "atomisp_dfs_tables.h"
-
-#include "hrt/hive_isp_css_mm_hrt.h"
-
-#include "sh_css_hrt.h"
-#include "sh_css_defs.h"
-#include "system_global.h"
-#include "sh_css_internal.h"
-#include "sh_css_sp.h"
-#include "gp_device.h"
-#include "device_access.h"
-#include "irq.h"
-
-#include "ia_css_types.h"
-#include "ia_css_stream.h"
-#include "error_support.h"
-#include "hrt/bits.h"
-
-
-/* We should never need to run the flash for more than 2 frames.
- * At 15fps this means 133ms. We set the timeout a bit longer.
- * Each flash driver is supposed to set its own timeout, but
- * just in case someone else changed the timeout, we set it
- * here to make sure we don't damage the flash hardware. */
-#define FLASH_TIMEOUT 800 /* ms */
-
-union host {
-	struct {
-		void *kernel_ptr;
-		void __user *user_ptr;
-		int size;
-	} scalar;
-	struct {
-		void *hmm_ptr;
-	} ptr;
-};
-
-/*
- * get sensor:dis71430/ov2720 related info from v4l2_subdev->priv data field.
- * subdev->priv is set in mrst.c
- */
-struct camera_mipi_info *atomisp_to_sensor_mipi_info(struct v4l2_subdev *sd)
-{
-	return (struct camera_mipi_info *)v4l2_get_subdev_hostdata(sd);
-}
-
-/*
- * get struct atomisp_video_pipe from v4l2 video_device
- */
-struct atomisp_video_pipe *atomisp_to_video_pipe(struct video_device *dev)
-{
-	return (struct atomisp_video_pipe *)
-	    container_of(dev, struct atomisp_video_pipe, vdev);
-}
-
-/*
- * get struct atomisp_acc_pipe from v4l2 video_device
- */
-struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct video_device *dev)
-{
-	return (struct atomisp_acc_pipe *)
-	    container_of(dev, struct atomisp_acc_pipe, vdev);
-}
-
-static unsigned short atomisp_get_sensor_fps(struct atomisp_sub_device *asd)
-{
-	struct v4l2_subdev_frame_interval fi;
-	struct atomisp_device *isp = asd->isp;
-
-	unsigned short fps = 0;
-	int ret;
-
-	ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-			       video, g_frame_interval, &fi);
-
-	if (!ret && fi.interval.numerator)
-		fps = fi.interval.denominator / fi.interval.numerator;
-
-	return fps;
-}
-
-/*
- * DFS progress is shown as follows:
- * 1. Target frequency is calculated according to FPS/Resolution/ISP running
- *    mode.
- * 2. Ratio is calculated using formula: 2 * HPLL / target frequency - 1
- *    with proper rounding.
- * 3. Set ratio to ISPFREQ40, 1 to FREQVALID and ISPFREQGUAR40
- *    to 200MHz in ISPSSPM1.
- * 4. Wait for FREQVALID to be cleared by P-Unit.
- * 5. Wait for field ISPFREQSTAT40 in ISPSSPM1 turn to ratio set in 3.
- */
-static int write_target_freq_to_hw(struct atomisp_device *isp,
-				   unsigned int new_freq)
-{
-	unsigned int ratio, timeout, guar_ratio;
-	u32 isp_sspm1 = 0;
-	int i;
-
-	if (!isp->hpll_freq) {
-		dev_err(isp->dev, "failed to get hpll_freq. no change to freq\n");
-		return -EINVAL;
-	}
-
-	iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM1, &isp_sspm1);
-	if (isp_sspm1 & ISP_FREQ_VALID_MASK) {
-		dev_dbg(isp->dev, "clearing ISPSSPM1 valid bit.\n");
-		iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, ISPSSPM1,
-				    isp_sspm1 & ~(1 << ISP_FREQ_VALID_OFFSET));
-	}
-
-	ratio = (2 * isp->hpll_freq + new_freq / 2) / new_freq - 1;
-	guar_ratio = (2 * isp->hpll_freq + 200 / 2) / 200 - 1;
-
-	iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM1, &isp_sspm1);
-	isp_sspm1 &= ~(0x1F << ISP_REQ_FREQ_OFFSET);
-
-	for (i = 0; i < ISP_DFS_TRY_TIMES; i++) {
-		iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, ISPSSPM1,
-				   isp_sspm1
-				   | ratio << ISP_REQ_FREQ_OFFSET
-				   | 1 << ISP_FREQ_VALID_OFFSET
-				   | guar_ratio << ISP_REQ_GUAR_FREQ_OFFSET);
-
-		iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM1, &isp_sspm1);
-		timeout = 20;
-		while ((isp_sspm1 & ISP_FREQ_VALID_MASK) && timeout) {
-			iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM1, &isp_sspm1);
-			dev_dbg(isp->dev, "waiting for ISPSSPM1 valid bit to be 0.\n");
-			udelay(100);
-			timeout--;
-		}
-
-		if (timeout != 0)
-			break;
-	}
-
-	if (timeout == 0) {
-		dev_err(isp->dev, "DFS failed due to HW error.\n");
-		return -EINVAL;
-	}
-
-	iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM1, &isp_sspm1);
-	timeout = 10;
-	while (((isp_sspm1 >> ISP_FREQ_STAT_OFFSET) != ratio) && timeout) {
-		iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM1, &isp_sspm1);
-		dev_dbg(isp->dev, "waiting for ISPSSPM1 status bit to be 0x%x.\n",
-			new_freq);
-		udelay(100);
-		timeout--;
-	}
-	if (timeout == 0) {
-		dev_err(isp->dev, "DFS target freq is rejected by HW.\n");
-		return -EINVAL;
-	}
-
-	return 0;
-}
-int atomisp_freq_scaling(struct atomisp_device *isp,
-			 enum atomisp_dfs_mode mode,
-			 bool force)
-{
-	/* FIXME! Only use subdev[0] status yet */
-	struct atomisp_sub_device *asd = &isp->asd[0];
-	const struct atomisp_dfs_config *dfs;
-	unsigned int new_freq;
-	struct atomisp_freq_scaling_rule curr_rules;
-	int i, ret;
-	unsigned short fps = 0;
-
-	if (isp->sw_contex.power_state != ATOM_ISP_POWER_UP) {
-		dev_err(isp->dev, "DFS cannot proceed due to no power.\n");
-		return -EINVAL;
-	}
-
-	if ((isp->pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) ==
-		ATOMISP_PCI_DEVICE_SOC_CHT && ATOMISP_USE_YUVPP(asd))
-		isp->dfs = &dfs_config_cht_soc;
-
-	dfs = isp->dfs;
-
-	if (dfs->lowest_freq == 0 || dfs->max_freq_at_vmin == 0 ||
-	    dfs->highest_freq == 0 || dfs->dfs_table_size == 0 ||
-	    !dfs->dfs_table) {
-		dev_err(isp->dev, "DFS configuration is invalid.\n");
-		return -EINVAL;
-	}
-
-	if (mode == ATOMISP_DFS_MODE_LOW) {
-		new_freq = dfs->lowest_freq;
-		goto done;
-	}
-
-	if (mode == ATOMISP_DFS_MODE_MAX) {
-		new_freq = dfs->highest_freq;
-		goto done;
-	}
-
-	fps = atomisp_get_sensor_fps(asd);
-	if (fps == 0)
-		return -EINVAL;
-
-	curr_rules.width = asd->fmt[asd->capture_pad].fmt.width;
-	curr_rules.height = asd->fmt[asd->capture_pad].fmt.height;
-	curr_rules.fps = fps;
-	curr_rules.run_mode = asd->run_mode->val;
-	/*
-	 * For continuous mode, we need to make the capture setting applied
-	 * since preview mode, because there is no chance to do this when
-	 * starting image capture.
-	 */
-	if (asd->continuous_mode->val) {
-		if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO)
-			curr_rules.run_mode = ATOMISP_RUN_MODE_SDV;
-		else
-			curr_rules.run_mode =
-				ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE;
-	}
-
-	/* search for the target frequency by looping freq rules*/
-	for (i = 0; i < dfs->dfs_table_size; i++) {
-		if (curr_rules.width != dfs->dfs_table[i].width &&
-		    dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
-			continue;
-		if (curr_rules.height != dfs->dfs_table[i].height &&
-		    dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
-			continue;
-		if (curr_rules.fps != dfs->dfs_table[i].fps &&
-		    dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
-			continue;
-		if (curr_rules.run_mode != dfs->dfs_table[i].run_mode &&
-		    dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
-			continue;
-		break;
-	}
-
-	if (i == dfs->dfs_table_size)
-		new_freq = dfs->max_freq_at_vmin;
-	else
-		new_freq = dfs->dfs_table[i].isp_freq;
-
-done:
-	dev_dbg(isp->dev, "DFS target frequency=%d.\n", new_freq);
-
-	if ((new_freq == isp->sw_contex.running_freq) && !force)
-		return 0;
-
-	dev_dbg(isp->dev, "Programming DFS frequency to %d\n", new_freq);
-
-	ret = write_target_freq_to_hw(isp, new_freq);
-	if (!ret) {
-		isp->sw_contex.running_freq = new_freq;
-		trace_ipu_pstate(new_freq, -1);
-	}
-	return ret;
-}
-
-/*
- * reset and restore ISP
- */
-int atomisp_reset(struct atomisp_device *isp)
-{
-	/* Reset ISP by power-cycling it */
-	int ret = 0;
-
-	dev_dbg(isp->dev, "%s\n", __func__);
-	atomisp_css_suspend(isp);
-	ret = atomisp_runtime_suspend(isp->dev);
-	if (ret < 0)
-		dev_err(isp->dev, "atomisp_runtime_suspend failed, %d\n", ret);
-	ret = atomisp_mrfld_power_down(isp);
-	if (ret < 0) {
-		dev_err(isp->dev, "can not disable ISP power\n");
-	} else {
-		ret = atomisp_mrfld_power_up(isp);
-		if (ret < 0)
-			dev_err(isp->dev, "can not enable ISP power\n");
-		ret = atomisp_runtime_resume(isp->dev);
-		if (ret < 0)
-			dev_err(isp->dev, "atomisp_runtime_resume failed, %d\n", ret);
-	}
-	ret = atomisp_css_resume(isp);
-	if (ret)
-		isp->isp_fatal_error = true;
-
-	return ret;
-}
-
-/*
- * interrupt disable functions
- */
-static void disable_isp_irq(enum hrt_isp_css_irq irq)
-{
-	irq_disable_channel(IRQ0_ID, irq);
-
-	if (irq != hrt_isp_css_irq_sp)
-		return;
-
-	cnd_sp_irq_enable(SP0_ID, false);
-}
-
-/*
- * interrupt clean function
- */
-static void clear_isp_irq(enum hrt_isp_css_irq irq)
-{
-	irq_clear_all(IRQ0_ID);
-}
-
-void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev)
-{
-	u32 msg32;
-	u16 msg16;
-
-	pci_read_config_dword(dev, PCI_MSI_CAPID, &msg32);
-	msg32 |= 1 << MSI_ENABLE_BIT;
-	pci_write_config_dword(dev, PCI_MSI_CAPID, msg32);
-
-	msg32 = (1 << INTR_IER) | (1 << INTR_IIR);
-	pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, msg32);
-
-	pci_read_config_word(dev, PCI_COMMAND, &msg16);
-	msg16 |= (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
-		  PCI_COMMAND_INTX_DISABLE);
-	pci_write_config_word(dev, PCI_COMMAND, msg16);
-}
-
-void atomisp_msi_irq_uninit(struct atomisp_device *isp, struct pci_dev *dev)
-{
-	u32 msg32;
-	u16 msg16;
-
-	pci_read_config_dword(dev, PCI_MSI_CAPID, &msg32);
-	msg32 &=  ~(1 << MSI_ENABLE_BIT);
-	pci_write_config_dword(dev, PCI_MSI_CAPID, msg32);
-
-	msg32 = 0x0;
-	pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, msg32);
-
-	pci_read_config_word(dev, PCI_COMMAND, &msg16);
-	msg16 &= ~(PCI_COMMAND_MASTER);
-	pci_write_config_word(dev, PCI_COMMAND, msg16);
-}
-
-static void atomisp_sof_event(struct atomisp_sub_device *asd)
-{
-	struct v4l2_event event = {0};
-
-	event.type = V4L2_EVENT_FRAME_SYNC;
-	event.u.frame_sync.frame_sequence = atomic_read(&asd->sof_count);
-
-	v4l2_event_queue(asd->subdev.devnode, &event);
-}
-
-void atomisp_eof_event(struct atomisp_sub_device *asd, uint8_t exp_id)
-{
-	struct v4l2_event event = {0};
-
-	event.type = V4L2_EVENT_FRAME_END;
-	event.u.frame_sync.frame_sequence = exp_id;
-
-	v4l2_event_queue(asd->subdev.devnode, &event);
-}
-
-static void atomisp_3a_stats_ready_event(struct atomisp_sub_device *asd, uint8_t exp_id)
-{
-	struct v4l2_event event = {0};
-
-	event.type = V4L2_EVENT_ATOMISP_3A_STATS_READY;
-	event.u.frame_sync.frame_sequence = exp_id;
-
-	v4l2_event_queue(asd->subdev.devnode, &event);
-}
-
-static void atomisp_metadata_ready_event(struct atomisp_sub_device *asd,
-					 enum atomisp_metadata_type md_type)
-{
-	struct v4l2_event event = {0};
-
-	event.type = V4L2_EVENT_ATOMISP_METADATA_READY;
-	event.u.data[0] = md_type;
-
-	v4l2_event_queue(asd->subdev.devnode, &event);
-}
-
-static void atomisp_reset_event(struct atomisp_sub_device *asd)
-{
-	struct v4l2_event event = {0};
-
-	event.type = V4L2_EVENT_ATOMISP_CSS_RESET;
-
-	v4l2_event_queue(asd->subdev.devnode, &event);
-}
-
-
-static void print_csi_rx_errors(enum mipi_port_id port,
-				struct atomisp_device *isp)
-{
-	u32 infos = 0;
-
-	atomisp_css_rx_get_irq_info(port, &infos);
-
-	dev_err(isp->dev, "CSI Receiver port %d errors:\n", port);
-	if (infos & CSS_RX_IRQ_INFO_BUFFER_OVERRUN)
-		dev_err(isp->dev, "  buffer overrun");
-	if (infos & CSS_RX_IRQ_INFO_ERR_SOT)
-		dev_err(isp->dev, "  start-of-transmission error");
-	if (infos & CSS_RX_IRQ_INFO_ERR_SOT_SYNC)
-		dev_err(isp->dev, "  start-of-transmission sync error");
-	if (infos & CSS_RX_IRQ_INFO_ERR_CONTROL)
-		dev_err(isp->dev, "  control error");
-	if (infos & CSS_RX_IRQ_INFO_ERR_ECC_DOUBLE)
-		dev_err(isp->dev, "  2 or more ECC errors");
-	if (infos & CSS_RX_IRQ_INFO_ERR_CRC)
-		dev_err(isp->dev, "  CRC mismatch");
-	if (infos & CSS_RX_IRQ_INFO_ERR_UNKNOWN_ID)
-		dev_err(isp->dev, "  unknown error");
-	if (infos & CSS_RX_IRQ_INFO_ERR_FRAME_SYNC)
-		dev_err(isp->dev, "  frame sync error");
-	if (infos & CSS_RX_IRQ_INFO_ERR_FRAME_DATA)
-		dev_err(isp->dev, "  frame data error");
-	if (infos & CSS_RX_IRQ_INFO_ERR_DATA_TIMEOUT)
-		dev_err(isp->dev, "  data timeout");
-	if (infos & CSS_RX_IRQ_INFO_ERR_UNKNOWN_ESC)
-		dev_err(isp->dev, "  unknown escape command entry");
-	if (infos & CSS_RX_IRQ_INFO_ERR_LINE_SYNC)
-		dev_err(isp->dev, "  line sync error");
-}
-
-/* Clear irq reg */
-static void clear_irq_reg(struct atomisp_device *isp)
-{
-	u32 msg_ret;
-	pci_read_config_dword(isp->pdev, PCI_INTERRUPT_CTRL, &msg_ret);
-	msg_ret |= 1 << INTR_IIR;
-	pci_write_config_dword(isp->pdev, PCI_INTERRUPT_CTRL, msg_ret);
-}
-
-static struct atomisp_sub_device *
-__get_asd_from_port(struct atomisp_device *isp, enum mipi_port_id port)
-{
-	int i;
-
-	/* Check which isp subdev to send eof */
-	for (i = 0; i < isp->num_of_streams; i++) {
-		struct atomisp_sub_device *asd = &isp->asd[i];
-		struct camera_mipi_info *mipi_info;
-
-		mipi_info = atomisp_to_sensor_mipi_info(
-				isp->inputs[asd->input_curr].camera);
-
-		if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED &&
-		    __get_mipi_port(isp, mipi_info->port) == port) {
-			return asd;
-		}
-	}
-
-	return NULL;
-}
-
-/* interrupt handling function*/
-irqreturn_t atomisp_isr(int irq, void *dev)
-{
-	struct atomisp_device *isp = (struct atomisp_device *)dev;
-	struct atomisp_sub_device *asd;
-	struct atomisp_css_event eof_event;
-	unsigned int irq_infos = 0;
-	unsigned long flags;
-	unsigned int i;
-	int err;
-
-	spin_lock_irqsave(&isp->lock, flags);
-	if (isp->sw_contex.power_state != ATOM_ISP_POWER_UP ||
-	    !isp->css_initialized) {
-		spin_unlock_irqrestore(&isp->lock, flags);
-		return IRQ_HANDLED;
-	}
-	err = atomisp_css_irq_translate(isp, &irq_infos);
-	if (err) {
-		spin_unlock_irqrestore(&isp->lock, flags);
-		return IRQ_NONE;
-	}
-
-	dev_dbg(isp->dev, "irq:0x%x\n", irq_infos);
-
-	clear_irq_reg(isp);
-
-	if (!atomisp_streaming_count(isp) && !atomisp_is_acc_enabled(isp))
-		goto out_nowake;
-
-	for (i = 0; i < isp->num_of_streams; i++) {
-		asd = &isp->asd[i];
-
-		if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
-			continue;
-		/*
-		 * Current SOF only support one stream, so the SOF only valid
-		 * either solely one stream is running
-		 */
-		if (irq_infos & CSS_IRQ_INFO_CSS_RECEIVER_SOF) {
-			atomic_inc(&asd->sof_count);
-			atomisp_sof_event(asd);
-
-			/* If sequence_temp and sequence are the same
-			 * there where no frames lost so we can increase
-			 * sequence_temp.
-			 * If not then processing of frame is still in progress
-			 * and driver needs to keep old sequence_temp value.
-			 * NOTE: There is assumption here that ISP will not
-			 * start processing next frame from sensor before old
-			 * one is completely done. */
-			if (atomic_read(&asd->sequence) == atomic_read(
-						&asd->sequence_temp))
-				atomic_set(&asd->sequence_temp,
-						atomic_read(&asd->sof_count));
-		}
-		if (irq_infos & CSS_IRQ_INFO_EVENTS_READY)
-			atomic_set(&asd->sequence,
-				   atomic_read(&asd->sequence_temp));
-	}
-
-	if (irq_infos & CSS_IRQ_INFO_CSS_RECEIVER_SOF)
-		irq_infos &= ~CSS_IRQ_INFO_CSS_RECEIVER_SOF;
-
-	if ((irq_infos & CSS_IRQ_INFO_INPUT_SYSTEM_ERROR) ||
-	    (irq_infos & CSS_IRQ_INFO_IF_ERROR)) {
-		/* handle mipi receiver error */
-		u32 rx_infos;
-		enum mipi_port_id port;
-
-		for (port = MIPI_PORT0_ID; port <= MIPI_PORT2_ID;
-		     port++) {
-			print_csi_rx_errors(port, isp);
-			atomisp_css_rx_get_irq_info(port, &rx_infos);
-			atomisp_css_rx_clear_irq_info(port, rx_infos);
-		}
-	}
-
-	if (irq_infos & IA_CSS_IRQ_INFO_ISYS_EVENTS_READY) {
-		while (ia_css_dequeue_isys_event(&(eof_event.event)) ==
-		       IA_CSS_SUCCESS) {
-			/* EOF Event does not have the css_pipe returned */
-			asd = __get_asd_from_port(isp, eof_event.event.port);
-			if (!asd) {
-				dev_err(isp->dev, "%s:no subdev.event:%d",  __func__,
-					eof_event.event.type);
-				continue;
-			}
-
-			atomisp_eof_event(asd, eof_event.event.exp_id);
-			dev_dbg(isp->dev, "%s EOF exp_id %d, asd %d\n",
-				__func__, eof_event.event.exp_id, asd->index);
-		}
-
-		irq_infos &= ~IA_CSS_IRQ_INFO_ISYS_EVENTS_READY;
-		if (irq_infos == 0)
-			goto out_nowake;
-	}
-
-	spin_unlock_irqrestore(&isp->lock, flags);
-
-	return IRQ_WAKE_THREAD;
-
-out_nowake:
-	spin_unlock_irqrestore(&isp->lock, flags);
-
-	return IRQ_HANDLED;
-}
-
-void atomisp_clear_css_buffer_counters(struct atomisp_sub_device *asd)
-{
-	int i;
-	memset(asd->s3a_bufs_in_css, 0, sizeof(asd->s3a_bufs_in_css));
-	for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++)
-		memset(asd->metadata_bufs_in_css[i], 0,
-		       sizeof(asd->metadata_bufs_in_css[i]));
-	asd->dis_bufs_in_css = 0;
-	asd->video_out_capture.buffers_in_css = 0;
-	asd->video_out_vf.buffers_in_css = 0;
-	asd->video_out_preview.buffers_in_css = 0;
-	asd->video_out_video_capture.buffers_in_css = 0;
-}
-
-#ifndef ISP2401
-bool atomisp_buffers_queued(struct atomisp_sub_device *asd)
-#else
-bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe)
-#endif
-{
-#ifndef ISP2401
-	return asd->video_out_capture.buffers_in_css ||
-		asd->video_out_vf.buffers_in_css ||
-		asd->video_out_preview.buffers_in_css ||
-		asd->video_out_video_capture.buffers_in_css ?
-		    true : false;
-#else
-	return pipe->buffers_in_css ? true : false;
-#endif
-}
-
-/* 0x100000 is the start of dmem inside SP */
-#define SP_DMEM_BASE	0x100000
-
-void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
-		  unsigned int size)
-{
-	unsigned int data = 0;
-	unsigned int size32 = DIV_ROUND_UP(size, sizeof(u32));
-
-	dev_dbg(isp->dev, "atomisp_io_base:%p\n", atomisp_io_base);
-	dev_dbg(isp->dev, "%s, addr:0x%x, size: %d, size32: %d\n", __func__,
-			addr, size, size32);
-	if (size32 * 4 + addr > 0x4000) {
-		dev_err(isp->dev, "illegal size (%d) or addr (0x%x)\n",
-				size32, addr);
-		return;
-	}
-	addr += SP_DMEM_BASE;
-	do {
-		data = _hrt_master_port_uload_32(addr);
-
-		dev_dbg(isp->dev, "%s, \t [0x%x]:0x%x\n", __func__, addr, data);
-		addr += sizeof(unsigned int);
-		size32 -= 1;
-	} while (size32 > 0);
-}
-
-static struct videobuf_buffer *atomisp_css_frame_to_vbuf(
-	struct atomisp_video_pipe *pipe, struct atomisp_css_frame *frame)
-{
-	struct videobuf_vmalloc_memory *vm_mem;
-	struct atomisp_css_frame *handle;
-	int i;
-
-	for (i = 0; pipe->capq.bufs[i]; i++) {
-		vm_mem = pipe->capq.bufs[i]->priv;
-		handle = vm_mem->vaddr;
-		if (handle && handle->data == frame->data)
-			return pipe->capq.bufs[i];
-	}
-
-	return NULL;
-}
-
-static void get_buf_timestamp(struct timeval *tv)
-{
-	struct timespec ts;
-	ktime_get_ts(&ts);
-	tv->tv_sec = ts.tv_sec;
-	tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
-}
-
-static void atomisp_flush_video_pipe(struct atomisp_sub_device *asd,
-				     struct atomisp_video_pipe *pipe)
-{
-	unsigned long irqflags;
-	int i;
-
-	if (!pipe->users)
-		return;
-
-	for (i = 0; pipe->capq.bufs[i]; i++) {
-		spin_lock_irqsave(&pipe->irq_lock, irqflags);
-		if (pipe->capq.bufs[i]->state == VIDEOBUF_ACTIVE ||
-		    pipe->capq.bufs[i]->state == VIDEOBUF_QUEUED) {
-			get_buf_timestamp(&pipe->capq.bufs[i]->ts);
-			pipe->capq.bufs[i]->field_count =
-				atomic_read(&asd->sequence) << 1;
-			dev_dbg(asd->isp->dev, "release buffers on device %s\n",
-				pipe->vdev.name);
-			if (pipe->capq.bufs[i]->state == VIDEOBUF_QUEUED)
-				list_del_init(&pipe->capq.bufs[i]->queue);
-			pipe->capq.bufs[i]->state = VIDEOBUF_ERROR;
-			wake_up(&pipe->capq.bufs[i]->done);
-		}
-		spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
-	}
-}
-
-/* Returns queued buffers back to video-core */
-void atomisp_flush_bufs_and_wakeup(struct atomisp_sub_device *asd)
-{
-	atomisp_flush_video_pipe(asd, &asd->video_out_capture);
-	atomisp_flush_video_pipe(asd, &asd->video_out_vf);
-	atomisp_flush_video_pipe(asd, &asd->video_out_preview);
-	atomisp_flush_video_pipe(asd, &asd->video_out_video_capture);
-}
-
-/* clean out the parameters that did not apply */
-void atomisp_flush_params_queue(struct atomisp_video_pipe *pipe)
-{
-	struct atomisp_css_params_with_list *param;
-
-	while (!list_empty(&pipe->per_frame_params)) {
-		param = list_entry(pipe->per_frame_params.next,
-				   struct atomisp_css_params_with_list, list);
-		list_del(&param->list);
-		atomisp_free_css_parameters(&param->params);
-		kvfree(param);
-	}
-}
-
-/* Re-queue per-frame parameters */
-static void atomisp_recover_params_queue(struct atomisp_video_pipe *pipe)
-{
-	struct atomisp_css_params_with_list *param;
-	int i;
-
-	for (i = 0; i < VIDEO_MAX_FRAME; i++) {
-		param = pipe->frame_params[i];
-		if (param)
-			list_add_tail(&param->list, &pipe->per_frame_params);
-		pipe->frame_params[i] = NULL;
-	}
-	atomisp_handle_parameter_and_buffer(pipe);
-}
-
-/* find atomisp_video_pipe with css pipe id, buffer type and atomisp run_mode */
-static struct atomisp_video_pipe *__atomisp_get_pipe(
-		struct atomisp_sub_device *asd,
-		enum atomisp_input_stream_id stream_id,
-		enum atomisp_css_pipe_id css_pipe_id,
-		enum atomisp_css_buffer_type buf_type)
-{
-	struct atomisp_device *isp = asd->isp;
-
-	if (css_pipe_id == CSS_PIPE_ID_COPY &&
-	    isp->inputs[asd->input_curr].camera_caps->
-		sensor[asd->sensor_curr].stream_num > 1) {
-		switch (stream_id) {
-		case ATOMISP_INPUT_STREAM_PREVIEW:
-			return &asd->video_out_preview;
-		case ATOMISP_INPUT_STREAM_POSTVIEW:
-			return &asd->video_out_vf;
-		case ATOMISP_INPUT_STREAM_VIDEO:
-			return &asd->video_out_video_capture;
-		case ATOMISP_INPUT_STREAM_CAPTURE:
-		default:
-			return &asd->video_out_capture;
-		}
-	}
-
-	/* video is same in online as in continuouscapture mode */
-	if (asd->vfpp->val == ATOMISP_VFPP_DISABLE_LOWLAT) {
-		/*
-		 * Disable vf_pp and run CSS in still capture mode. In this
-		 * mode, CSS does not cause extra latency with buffering, but
-		 * scaling is not available.
-		 */
-		return &asd->video_out_capture;
-	} else if (asd->vfpp->val == ATOMISP_VFPP_DISABLE_SCALER) {
-		/*
-		 * Disable vf_pp and run CSS in video mode. This allows using
-		 * ISP scaling but it has one frame delay due to CSS internal
-		 * buffering.
-		 */
-		return &asd->video_out_video_capture;
-	} else if (css_pipe_id == CSS_PIPE_ID_YUVPP) {
-		/*
-		 * to SOC camera, yuvpp pipe is run for capture/video/SDV/ZSL.
-		 */
-		if (asd->continuous_mode->val) {
-			if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) {
-				/* SDV case */
-				switch (buf_type) {
-				case CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME:
-					return &asd->video_out_video_capture;
-				case CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME:
-					return &asd->video_out_preview;
-				case CSS_BUFFER_TYPE_OUTPUT_FRAME:
-					return &asd->video_out_capture;
-				default:
-					return &asd->video_out_vf;
-				}
-			} else if (asd->run_mode->val == ATOMISP_RUN_MODE_PREVIEW) {
-				/* ZSL case */
-				switch (buf_type) {
-				case CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME:
-					return &asd->video_out_preview;
-				case CSS_BUFFER_TYPE_OUTPUT_FRAME:
-					return &asd->video_out_capture;
-				default:
-					return &asd->video_out_vf;
-				}
-			}
-		} else if (buf_type == CSS_BUFFER_TYPE_OUTPUT_FRAME) {
-			switch (asd->run_mode->val) {
-			case ATOMISP_RUN_MODE_VIDEO:
-				return &asd->video_out_video_capture;
-			case ATOMISP_RUN_MODE_PREVIEW:
-				return &asd->video_out_preview;
-			default:
-				return &asd->video_out_capture;
-			}
-		} else if (buf_type == CSS_BUFFER_TYPE_VF_OUTPUT_FRAME) {
-			if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO)
-				return &asd->video_out_preview;
-			else
-				return &asd->video_out_vf;
-		}
-	} else if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) {
-		/* For online video or SDV video pipe. */
-		if (css_pipe_id == CSS_PIPE_ID_VIDEO ||
-		    css_pipe_id == CSS_PIPE_ID_COPY) {
-			if (buf_type == CSS_BUFFER_TYPE_OUTPUT_FRAME)
-				return &asd->video_out_video_capture;
-			return &asd->video_out_preview;
-		}
-	} else if (asd->run_mode->val == ATOMISP_RUN_MODE_PREVIEW) {
-		/* For online preview or ZSL preview pipe. */
-		if (css_pipe_id == CSS_PIPE_ID_PREVIEW ||
-		    css_pipe_id == CSS_PIPE_ID_COPY)
-			return &asd->video_out_preview;
-	}
-	/* For capture pipe. */
-	if (buf_type == CSS_BUFFER_TYPE_VF_OUTPUT_FRAME)
-		return &asd->video_out_vf;
-	return &asd->video_out_capture;
-}
-
-enum atomisp_metadata_type
-atomisp_get_metadata_type(struct atomisp_sub_device *asd,
-			  enum ia_css_pipe_id pipe_id)
-{
-	if (!asd->continuous_mode->val)
-		return ATOMISP_MAIN_METADATA;
-
-	if (pipe_id == IA_CSS_PIPE_ID_CAPTURE) /* online capture pipe */
-		return ATOMISP_SEC_METADATA;
-	else
-		return ATOMISP_MAIN_METADATA;
-}
-
-void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
-		      enum atomisp_css_buffer_type buf_type,
-		      enum atomisp_css_pipe_id css_pipe_id,
-		      bool q_buffers, enum atomisp_input_stream_id stream_id)
-{
-	struct videobuf_buffer *vb = NULL;
-	struct atomisp_video_pipe *pipe = NULL;
-	struct atomisp_css_buffer buffer;
-	bool requeue = false;
-	int err;
-	unsigned long irqflags;
-	struct atomisp_css_frame *frame = NULL;
-	struct atomisp_s3a_buf *s3a_buf = NULL, *_s3a_buf_tmp;
-	struct atomisp_dis_buf *dis_buf = NULL, *_dis_buf_tmp;
-	struct atomisp_metadata_buf *md_buf = NULL, *_md_buf_tmp;
-	enum atomisp_metadata_type md_type;
-	struct atomisp_device *isp = asd->isp;
-	struct v4l2_control ctrl;
-#ifdef ISP2401
-	bool reset_wdt_timer = false;
-#endif
-
-	if (
-	    buf_type != CSS_BUFFER_TYPE_METADATA &&
-	    buf_type != CSS_BUFFER_TYPE_3A_STATISTICS &&
-	    buf_type != CSS_BUFFER_TYPE_DIS_STATISTICS &&
-	    buf_type != CSS_BUFFER_TYPE_OUTPUT_FRAME &&
-	    buf_type != CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME &&
-	    buf_type != CSS_BUFFER_TYPE_RAW_OUTPUT_FRAME &&
-	    buf_type != CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME &&
-	    buf_type != CSS_BUFFER_TYPE_VF_OUTPUT_FRAME) {
-		dev_err(isp->dev, "%s, unsupported buffer type: %d\n",
-			__func__, buf_type);
-		return;
-	}
-
-	memset(&buffer, 0, sizeof(struct atomisp_css_buffer));
-	buffer.css_buffer.type = buf_type;
-	err = atomisp_css_dequeue_buffer(asd, stream_id, css_pipe_id,
-					 buf_type, &buffer);
-	if (err) {
-		dev_err(isp->dev,
-			"atomisp_css_dequeue_buffer failed: 0x%x\n", err);
-		return;
-	}
-
-	/* need to know the atomisp pipe for frame buffers */
-	pipe = __atomisp_get_pipe(asd, stream_id, css_pipe_id, buf_type);
-	if (pipe == NULL) {
-		dev_err(isp->dev, "error getting atomisp pipe\n");
-		return;
-	}
-
-	switch (buf_type) {
-	case CSS_BUFFER_TYPE_3A_STATISTICS:
-		list_for_each_entry_safe(s3a_buf, _s3a_buf_tmp,
-					 &asd->s3a_stats_in_css, list) {
-			if (s3a_buf->s3a_data ==
-				buffer.css_buffer.data.stats_3a) {
-				list_del_init(&s3a_buf->list);
-				list_add_tail(&s3a_buf->list,
-					      &asd->s3a_stats_ready);
-				break;
-			}
-		}
-
-		asd->s3a_bufs_in_css[css_pipe_id]--;
-		atomisp_3a_stats_ready_event(asd, buffer.css_buffer.exp_id);
-		dev_dbg(isp->dev, "%s: s3a stat with exp_id %d is ready\n",
-			__func__, s3a_buf->s3a_data->exp_id);
-		break;
-	case CSS_BUFFER_TYPE_METADATA:
-		if (error)
-			break;
-
-		md_type = atomisp_get_metadata_type(asd, css_pipe_id);
-		list_for_each_entry_safe(md_buf, _md_buf_tmp,
-					 &asd->metadata_in_css[md_type], list) {
-			if (md_buf->metadata ==
-				buffer.css_buffer.data.metadata) {
-				list_del_init(&md_buf->list);
-				list_add_tail(&md_buf->list,
-					      &asd->metadata_ready[md_type]);
-				break;
-			}
-		}
-		asd->metadata_bufs_in_css[stream_id][css_pipe_id]--;
-		atomisp_metadata_ready_event(asd, md_type);
-		dev_dbg(isp->dev, "%s: metadata with exp_id %d is ready\n",
-			__func__, md_buf->metadata->exp_id);
-		break;
-	case CSS_BUFFER_TYPE_DIS_STATISTICS:
-		list_for_each_entry_safe(dis_buf, _dis_buf_tmp,
-						&asd->dis_stats_in_css, list) {
-			if (dis_buf->dis_data ==
-				buffer.css_buffer.data.stats_dvs) {
-				spin_lock_irqsave(&asd->dis_stats_lock,
-						  irqflags);
-				list_del_init(&dis_buf->list);
-				list_add(&dis_buf->list, &asd->dis_stats);
-				asd->params.dis_proj_data_valid = true;
-				spin_unlock_irqrestore(&asd->dis_stats_lock,
-						       irqflags);
-				break;
-			}
-		}
-		asd->dis_bufs_in_css--;
-		dev_dbg(isp->dev, "%s: dis stat with exp_id %d is ready\n",
-			__func__, dis_buf->dis_data->exp_id);
-		break;
-	case CSS_BUFFER_TYPE_VF_OUTPUT_FRAME:
-	case CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME:
-#ifdef ISP2401
-		reset_wdt_timer = true;
-#endif
-		pipe->buffers_in_css--;
-		frame = buffer.css_buffer.data.frame;
-		if (!frame) {
-			WARN_ON(1);
-			break;
-		}
-		if (!frame->valid)
-			error = true;
-
-		/* FIXME:
-		 * YUVPP doesn't set postview exp_id correctlly in SDV mode.
-		 * This is a WORKAROUND to set exp_id. see HSDES-1503911606.
-		 */
-		if (IS_BYT && buf_type == CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME &&
-		    asd->continuous_mode->val && ATOMISP_USE_YUVPP(asd))
-			frame->exp_id = (asd->postview_exp_id++) %
-						(ATOMISP_MAX_EXP_ID + 1);
-
-		dev_dbg(isp->dev, "%s: vf frame with exp_id %d is ready\n",
-			__func__, frame->exp_id);
-		if (asd->params.flash_state == ATOMISP_FLASH_ONGOING) {
-			if (frame->flash_state
-			    == CSS_FRAME_FLASH_STATE_PARTIAL)
-				dev_dbg(isp->dev, "%s thumb partially flashed\n",
-					__func__);
-			else if (frame->flash_state
-				 == CSS_FRAME_FLASH_STATE_FULL)
-				dev_dbg(isp->dev, "%s thumb completely flashed\n",
-					__func__);
-			else
-				dev_dbg(isp->dev, "%s thumb no flash in this frame\n",
-					__func__);
-		}
-		vb = atomisp_css_frame_to_vbuf(pipe, frame);
-		WARN_ON(!vb);
-		if (vb)
-			pipe->frame_config_id[vb->i] = frame->isp_config_id;
-		if (css_pipe_id == IA_CSS_PIPE_ID_CAPTURE &&
-		    asd->pending_capture_request > 0) {
-			err = atomisp_css_offline_capture_configure(asd,
-					asd->params.offline_parm.num_captures,
-					asd->params.offline_parm.skip_frames,
-					asd->params.offline_parm.offset);
-#ifndef ISP2401
-			asd->pending_capture_request--;
-			dev_dbg(isp->dev, "Trigger capture again for new buffer. err=%d\n",
-				err);
-#else
-				asd->pending_capture_request--;
-				asd->re_trigger_capture = false;
-				dev_dbg(isp->dev, "Trigger capture again for new buffer. err=%d\n",
-						err);
-			} else {
-				asd->re_trigger_capture = true;
-			}
-#endif
-		}
-		break;
-	case CSS_BUFFER_TYPE_OUTPUT_FRAME:
-	case CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME:
-#ifdef ISP2401
-		reset_wdt_timer = true;
-#endif
-		pipe->buffers_in_css--;
-		frame = buffer.css_buffer.data.frame;
-		if (!frame) {
-			WARN_ON(1);
-			break;
-		}
-
-		if (!frame->valid)
-			error = true;
-
-		/* FIXME:
-		 * YUVPP doesn't set preview exp_id correctlly in ZSL mode.
-		 * This is a WORKAROUND to set exp_id. see HSDES-1503911606.
-		 */
-		if (IS_BYT && buf_type == CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME &&
-		    asd->continuous_mode->val && ATOMISP_USE_YUVPP(asd))
-			frame->exp_id = (asd->preview_exp_id++) %
-						(ATOMISP_MAX_EXP_ID + 1);
-
-		dev_dbg(isp->dev, "%s: main frame with exp_id %d is ready\n",
-			__func__, frame->exp_id);
-		vb = atomisp_css_frame_to_vbuf(pipe, frame);
-		if (!vb) {
-			WARN_ON(1);
-			break;
-		}
-
-		/* free the parameters */
-		if (pipe->frame_params[vb->i]) {
-			if (asd->params.dvs_6axis ==
-			    pipe->frame_params[vb->i]->params.dvs_6axis)
-				asd->params.dvs_6axis = NULL;
-			atomisp_free_css_parameters(
-				&pipe->frame_params[vb->i]->params);
-			kvfree(pipe->frame_params[vb->i]);
-			pipe->frame_params[vb->i] = NULL;
-		}
-
-		pipe->frame_config_id[vb->i] = frame->isp_config_id;
-		ctrl.id = V4L2_CID_FLASH_MODE;
-		if (asd->params.flash_state == ATOMISP_FLASH_ONGOING) {
-			if (frame->flash_state
-			    == CSS_FRAME_FLASH_STATE_PARTIAL) {
-				asd->frame_status[vb->i] =
-					ATOMISP_FRAME_STATUS_FLASH_PARTIAL;
-				dev_dbg(isp->dev, "%s partially flashed\n",
-					 __func__);
-			} else if (frame->flash_state
-				   == CSS_FRAME_FLASH_STATE_FULL) {
-				asd->frame_status[vb->i] =
-					ATOMISP_FRAME_STATUS_FLASH_EXPOSED;
-				asd->params.num_flash_frames--;
-				dev_dbg(isp->dev, "%s completely flashed\n",
-					 __func__);
-			} else {
-				asd->frame_status[vb->i] =
-					ATOMISP_FRAME_STATUS_OK;
-				dev_dbg(isp->dev,
-					 "%s no flash in this frame\n",
-					 __func__);
-			}
-
-			/* Check if flashing sequence is done */
-			if (asd->frame_status[vb->i] ==
-				ATOMISP_FRAME_STATUS_FLASH_EXPOSED)
-				asd->params.flash_state = ATOMISP_FLASH_DONE;
-		} else if (isp->flash) {
-			if (v4l2_g_ctrl(isp->flash->ctrl_handler, &ctrl) ==
-			    0 && ctrl.value == ATOMISP_FLASH_MODE_TORCH) {
-				ctrl.id = V4L2_CID_FLASH_TORCH_INTENSITY;
-				if (v4l2_g_ctrl(isp->flash->ctrl_handler, &ctrl)
-				    == 0 && ctrl.value > 0) {
-					asd->frame_status[vb->i] =
-					    ATOMISP_FRAME_STATUS_FLASH_EXPOSED;
-				} else {
-					asd->frame_status[vb->i] =
-					    ATOMISP_FRAME_STATUS_OK;
-				}
-			} else
-				asd->frame_status[vb->i] =
-				    ATOMISP_FRAME_STATUS_OK;
-		} else {
-			asd->frame_status[vb->i] = ATOMISP_FRAME_STATUS_OK;
-		}
-
-		asd->params.last_frame_status = asd->frame_status[vb->i];
-
-		if (asd->continuous_mode->val) {
-			if (css_pipe_id == CSS_PIPE_ID_PREVIEW ||
-			    css_pipe_id == CSS_PIPE_ID_VIDEO) {
-				asd->latest_preview_exp_id = frame->exp_id;
-			} else if (css_pipe_id ==
-					CSS_PIPE_ID_CAPTURE) {
-				if (asd->run_mode->val ==
-					ATOMISP_RUN_MODE_VIDEO)
-					dev_dbg(isp->dev, "SDV capture raw buffer id: %u\n",
-					    frame->exp_id);
-				else
-					dev_dbg(isp->dev, "ZSL capture raw buffer id: %u\n",
-					    frame->exp_id);
-			}
-		}
-		/*
-		 * Only after enabled the raw buffer lock
-		 * and in continuous mode.
-		 * in preview/video pipe, each buffer will
-		 * be locked automatically, so record it here.
-		 */
-		if (((css_pipe_id == CSS_PIPE_ID_PREVIEW) ||
-		    (css_pipe_id == CSS_PIPE_ID_VIDEO)) &&
-		    asd->enable_raw_buffer_lock->val &&
-		    asd->continuous_mode->val) {
-			atomisp_set_raw_buffer_bitmap(asd, frame->exp_id);
-			WARN_ON(frame->exp_id > ATOMISP_MAX_EXP_ID);
-		}
-
-		if (asd->params.css_update_params_needed) {
-			atomisp_apply_css_parameters(asd,
-						     &asd->params.css_param);
-			if (asd->params.css_param.update_flag.dz_config)
-				atomisp_css_set_dz_config(asd,
-					&asd->params.css_param.dz_config);
-			/* New global dvs 6axis config should be blocked
-			 * here if there's a buffer with per-frame parameters
-			 * pending in CSS frame buffer queue.
-			 * This is to aviod zooming vibration since global
-			 * parameters take effect immediately while
-			 * per-frame parameters are taken after previous
-			 * buffers in CSS got processed.
-			 */
-			if (asd->params.dvs_6axis)
-				atomisp_css_set_dvs_6axis(asd,
-					asd->params.dvs_6axis);
-			else
-				asd->params.css_update_params_needed = false;
-			/* The update flag should not be cleaned here
-			 * since it is still going to be used to make up
-			 * following per-frame parameters.
-			 * This will introduce more copy work since each
-			 * time when updating global parameters, the whole
-			 * parameter set are applied.
-			 * FIXME: A new set of parameter copy functions can
-			 * be added to make up per-frame parameters based on
-			 * solid structures stored in asd->params.css_param
-			 * instead of using shadow pointers in update flag.
-			 */
-			atomisp_css_update_isp_params(asd);
-		}
-		break;
-	default:
-		break;
-	}
-	if (vb) {
-		get_buf_timestamp(&vb->ts);
-		vb->field_count = atomic_read(&asd->sequence) << 1;
-		/*mark videobuffer done for dequeue*/
-		spin_lock_irqsave(&pipe->irq_lock, irqflags);
-		vb->state = !error ? VIDEOBUF_DONE : VIDEOBUF_ERROR;
-		spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
-
-		/*
-		 * Frame capture done, wake up any process block on
-		 * current active buffer
-		 * possibly hold by videobuf_dqbuf()
-		 */
-		wake_up(&vb->done);
-	}
-#ifdef ISP2401
-	atomic_set(&pipe->wdt_count, 0);
-#endif
-	/*
-	 * Requeue should only be done for 3a and dis buffers.
-	 * Queue/dequeue order will change if driver recycles image buffers.
-	 */
-	if (requeue) {
-		err = atomisp_css_queue_buffer(asd,
-					       stream_id, css_pipe_id,
-					       buf_type, &buffer);
-		if (err)
-			dev_err(isp->dev, "%s, q to css fails: %d\n",
-					__func__, err);
-		return;
-	}
-	if (!error && q_buffers)
-		atomisp_qbuffers_to_css(asd);
-#ifdef ISP2401
-
-	/* If there are no buffers queued then
-	 * delete wdt timer. */
-	if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
-		return;
-	if (!atomisp_buffers_queued_pipe(pipe))
-		atomisp_wdt_stop_pipe(pipe, false);
-	else if (reset_wdt_timer)
-		/* SOF irq should not reset wdt timer. */
-		atomisp_wdt_refresh_pipe(pipe,
-					 ATOMISP_WDT_KEEP_CURRENT_DELAY);
-#endif
-}
-
-void atomisp_delayed_init_work(struct work_struct *work)
-{
-	struct atomisp_sub_device *asd = container_of(work,
-			struct atomisp_sub_device,
-			delayed_init_work);
-	/*
-	 * to SOC camera, use yuvpp pipe and no support continuous mode.
-	 */
-	if (!ATOMISP_USE_YUVPP(asd)) {
-		struct v4l2_event event = {0};
-
-		atomisp_css_allocate_continuous_frames(false, asd);
-		atomisp_css_update_continuous_frames(asd);
-
-		event.type = V4L2_EVENT_ATOMISP_RAW_BUFFERS_ALLOC_DONE;
-		v4l2_event_queue(asd->subdev.devnode, &event);
-	}
-
-	/* signal streamon after delayed init is done */
-	asd->delayed_init = ATOMISP_DELAYED_INIT_DONE;
-	complete(&asd->init_done);
-}
-
-static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout)
-{
-	enum atomisp_css_pipe_id css_pipe_id;
-	bool stream_restart[MAX_STREAM_NUM] = {0};
-	bool depth_mode = false;
-	int i, ret, depth_cnt = 0;
-
-	if (!isp->sw_contex.file_input)
-		atomisp_css_irq_enable(isp,
-				       CSS_IRQ_INFO_CSS_RECEIVER_SOF, false);
-
-	BUG_ON(isp->num_of_streams > MAX_STREAM_NUM);
-
-	for (i = 0; i < isp->num_of_streams; i++) {
-		struct atomisp_sub_device *asd = &isp->asd[i];
-		struct ia_css_pipeline *acc_pipeline;
-		struct ia_css_pipe *acc_pipe = NULL;
-
-		if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED &&
-		    !asd->stream_prepared)
-			continue;
-
-		/*
-		* AtomISP::waitStageUpdate is blocked when WDT happens.
-		* By calling acc_done() for all loaded fw_handles,
-		* HAL will be unblocked.
-		*/
-		acc_pipe = asd->stream_env[i].pipes[CSS_PIPE_ID_ACC];
-		if (acc_pipe != NULL) {
-			acc_pipeline = ia_css_pipe_get_pipeline(acc_pipe);
-			if (acc_pipeline) {
-				struct ia_css_pipeline_stage *stage;
-				for (stage = acc_pipeline->stages; stage;
-					stage = stage->next) {
-					const struct ia_css_fw_info *fw;
-					fw = stage->firmware;
-					atomisp_acc_done(asd, fw->handle);
-				}
-			}
-		}
-
-		depth_cnt++;
-
-		if (asd->delayed_init == ATOMISP_DELAYED_INIT_QUEUED)
-			cancel_work_sync(&asd->delayed_init_work);
-
-		complete(&asd->init_done);
-		asd->delayed_init = ATOMISP_DELAYED_INIT_NOT_QUEUED;
-
-		stream_restart[asd->index] = true;
-
-		asd->streaming = ATOMISP_DEVICE_STREAMING_STOPPING;
-
-		/* stream off sensor */
-		ret = v4l2_subdev_call(
-				isp->inputs[asd->input_curr].
-				camera, video, s_stream, 0);
-		if (ret)
-			dev_warn(isp->dev,
-					"can't stop streaming on sensor!\n");
-
-		atomisp_acc_unload_extensions(asd);
-
-		atomisp_clear_css_buffer_counters(asd);
-
-		css_pipe_id = atomisp_get_css_pipe_id(asd);
-		atomisp_css_stop(asd, css_pipe_id, true);
-
-		asd->streaming = ATOMISP_DEVICE_STREAMING_DISABLED;
-
-		asd->preview_exp_id = 1;
-		asd->postview_exp_id = 1;
-		/* notify HAL the CSS reset */
-		dev_dbg(isp->dev,
-			"send reset event to %s\n", asd->subdev.devnode->name);
-		atomisp_reset_event(asd);
-	}
-
-	/* clear irq */
-	disable_isp_irq(hrt_isp_css_irq_sp);
-	clear_isp_irq(hrt_isp_css_irq_sp);
-
-	/* Set the SRSE to 3 before resetting */
-	pci_write_config_dword(isp->pdev, PCI_I_CONTROL, isp->saved_regs.i_control |
-			       MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK);
-
-	/* reset ISP and restore its state */
-	isp->isp_timeout = true;
-	atomisp_reset(isp);
-	isp->isp_timeout = false;
-
-	if (!isp_timeout) {
-		for (i = 0; i < isp->num_of_streams; i++) {
-			if (isp->asd[i].depth_mode->val)
-				return;
-		}
-	}
-
-	for (i = 0; i < isp->num_of_streams; i++) {
-		struct atomisp_sub_device *asd = &isp->asd[i];
-
-		if (!stream_restart[i])
-			continue;
-
-		if (isp->inputs[asd->input_curr].type != FILE_INPUT)
-			atomisp_css_input_set_mode(asd,
-					CSS_INPUT_MODE_SENSOR);
-
-		css_pipe_id = atomisp_get_css_pipe_id(asd);
-		if (atomisp_css_start(asd, css_pipe_id, true))
-			dev_warn(isp->dev,
-				"start SP failed, so do not set streaming to be enable!\n");
-		else
-			asd->streaming = ATOMISP_DEVICE_STREAMING_ENABLED;
-
-		atomisp_csi2_configure(asd);
-	}
-
-	if (!isp->sw_contex.file_input) {
-		atomisp_css_irq_enable(isp, CSS_IRQ_INFO_CSS_RECEIVER_SOF,
-				atomisp_css_valid_sof(isp));
-
-		if (atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_AUTO, true) < 0)
-			dev_dbg(isp->dev, "dfs failed!\n");
-	} else {
-		if (atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_MAX, true) < 0)
-			dev_dbg(isp->dev, "dfs failed!\n");
-	}
-
-	for (i = 0; i < isp->num_of_streams; i++) {
-		struct atomisp_sub_device *asd;
-
-		asd = &isp->asd[i];
-
-		if (!stream_restart[i])
-			continue;
-
-		if (asd->continuous_mode->val &&
-		    asd->delayed_init == ATOMISP_DELAYED_INIT_NOT_QUEUED) {
-			reinit_completion(&asd->init_done);
-			asd->delayed_init = ATOMISP_DELAYED_INIT_QUEUED;
-			queue_work(asd->delayed_init_workq,
-					&asd->delayed_init_work);
-		}
-		/*
-		 * dequeueing buffers is not needed. CSS will recycle
-		 * buffers that it has.
-		 */
-		atomisp_flush_bufs_and_wakeup(asd);
-
-		/* Requeue unprocessed per-frame parameters. */
-		atomisp_recover_params_queue(&asd->video_out_capture);
-		atomisp_recover_params_queue(&asd->video_out_preview);
-		atomisp_recover_params_queue(&asd->video_out_video_capture);
-
-		if ((asd->depth_mode->val) &&
-		    (depth_cnt == ATOMISP_DEPTH_SENSOR_STREAMON_COUNT)) {
-			depth_mode = true;
-			continue;
-		}
-
-		ret = v4l2_subdev_call(
-				isp->inputs[asd->input_curr].camera, video,
-				s_stream, 1);
-		if (ret)
-			dev_warn(isp->dev,
-				 "can't start streaming on sensor!\n");
-
-	}
-
-	if (depth_mode) {
-		if (atomisp_stream_on_master_slave_sensor(isp, true))
-			dev_warn(isp->dev,
-				 "master slave sensor stream on failed!\n");
-	}
-}
-
-void atomisp_wdt_work(struct work_struct *work)
-{
-	struct atomisp_device *isp = container_of(work, struct atomisp_device,
-						  wdt_work);
-	int i;
-#ifdef ISP2401
-	unsigned int pipe_wdt_cnt[MAX_STREAM_NUM][4] = { {0} };
-	bool css_recover = true;
-#endif
-
-	rt_mutex_lock(&isp->mutex);
-	if (!atomisp_streaming_count(isp)) {
-		atomic_set(&isp->wdt_work_queued, 0);
-		rt_mutex_unlock(&isp->mutex);
-		return;
-	}
-
-#ifndef ISP2401
-	dev_err(isp->dev, "timeout %d of %d\n",
-		atomic_read(&isp->wdt_count) + 1,
-		ATOMISP_ISP_MAX_TIMEOUT_COUNT);
-#else
-	for (i = 0; i < isp->num_of_streams; i++) {
-		struct atomisp_sub_device *asd = &isp->asd[i];
-		pipe_wdt_cnt[i][0] +=
-			atomic_read(&asd->video_out_capture.wdt_count);
-		pipe_wdt_cnt[i][1] +=
-			atomic_read(&asd->video_out_vf.wdt_count);
-		pipe_wdt_cnt[i][2] +=
-			atomic_read(&asd->video_out_preview.wdt_count);
-		pipe_wdt_cnt[i][3] +=
-			atomic_read(&asd->video_out_video_capture.wdt_count);
-		css_recover =
-			(pipe_wdt_cnt[i][0] <= ATOMISP_ISP_MAX_TIMEOUT_COUNT &&
-			 pipe_wdt_cnt[i][1] <= ATOMISP_ISP_MAX_TIMEOUT_COUNT &&
-			 pipe_wdt_cnt[i][2] <= ATOMISP_ISP_MAX_TIMEOUT_COUNT &&
-			 pipe_wdt_cnt[i][3] <= ATOMISP_ISP_MAX_TIMEOUT_COUNT)
-			 ? true : false;
-		dev_err(isp->dev, "pipe on asd%d timeout cnt: (%d, %d, %d, %d) of %d, recover = %d\n",
-			asd->index, pipe_wdt_cnt[i][0], pipe_wdt_cnt[i][1],
-			pipe_wdt_cnt[i][2], pipe_wdt_cnt[i][3],
-			ATOMISP_ISP_MAX_TIMEOUT_COUNT, css_recover);
-	}
-#endif
-
-#ifndef ISP2401
-	if (atomic_inc_return(&isp->wdt_count) <
-	    ATOMISP_ISP_MAX_TIMEOUT_COUNT) {
-#else
-	if (css_recover) {
-#endif
-		unsigned int old_dbglevel = dbg_level;
-		atomisp_css_debug_dump_sp_sw_debug_info();
-		atomisp_css_debug_dump_debug_info(__func__);
-		dbg_level = old_dbglevel;
-		for (i = 0; i < isp->num_of_streams; i++) {
-			struct atomisp_sub_device *asd = &isp->asd[i];
-
-			if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
-				continue;
-			dev_err(isp->dev, "%s, vdev %s buffers in css: %d\n",
-				__func__,
-				asd->video_out_capture.vdev.name,
-				asd->video_out_capture.
-				buffers_in_css);
-			dev_err(isp->dev,
-				"%s, vdev %s buffers in css: %d\n",
-				__func__,
-				asd->video_out_vf.vdev.name,
-				asd->video_out_vf.
-				buffers_in_css);
-			dev_err(isp->dev,
-				"%s, vdev %s buffers in css: %d\n",
-				__func__,
-				asd->video_out_preview.vdev.name,
-				asd->video_out_preview.
-				buffers_in_css);
-			dev_err(isp->dev,
-				"%s, vdev %s buffers in css: %d\n",
-				__func__,
-				asd->video_out_video_capture.vdev.name,
-				asd->video_out_video_capture.
-				buffers_in_css);
-			dev_err(isp->dev,
-				"%s, s3a buffers in css preview pipe:%d\n",
-				__func__,
-				asd->s3a_bufs_in_css[CSS_PIPE_ID_PREVIEW]);
-			dev_err(isp->dev,
-				"%s, s3a buffers in css capture pipe:%d\n",
-				__func__,
-				asd->s3a_bufs_in_css[CSS_PIPE_ID_CAPTURE]);
-			dev_err(isp->dev,
-				"%s, s3a buffers in css video pipe:%d\n",
-				__func__,
-				asd->s3a_bufs_in_css[CSS_PIPE_ID_VIDEO]);
-			dev_err(isp->dev,
-				"%s, dis buffers in css: %d\n",
-				__func__, asd->dis_bufs_in_css);
-			dev_err(isp->dev,
-				"%s, metadata buffers in css preview pipe:%d\n",
-				__func__,
-				asd->metadata_bufs_in_css
-				[ATOMISP_INPUT_STREAM_GENERAL]
-				[CSS_PIPE_ID_PREVIEW]);
-			dev_err(isp->dev,
-				"%s, metadata buffers in css capture pipe:%d\n",
-				__func__,
-				asd->metadata_bufs_in_css
-				[ATOMISP_INPUT_STREAM_GENERAL]
-				[CSS_PIPE_ID_CAPTURE]);
-			dev_err(isp->dev,
-				"%s, metadata buffers in css video pipe:%d\n",
-				__func__,
-				asd->metadata_bufs_in_css
-				[ATOMISP_INPUT_STREAM_GENERAL]
-				[CSS_PIPE_ID_VIDEO]);
-			if (asd->enable_raw_buffer_lock->val) {
-				unsigned int j;
-
-				dev_err(isp->dev, "%s, raw_buffer_locked_count %d\n",
-					__func__, asd->raw_buffer_locked_count);
-				for (j = 0; j <= ATOMISP_MAX_EXP_ID/32; j++)
-					dev_err(isp->dev, "%s, raw_buffer_bitmap[%d]: 0x%x\n",
-						__func__, j,
-						asd->raw_buffer_bitmap[j]);
-			}
-		}
-
-		/*sh_css_dump_sp_state();*/
-		/*sh_css_dump_isp_state();*/
-	} else {
-		for (i = 0; i < isp->num_of_streams; i++) {
-			struct atomisp_sub_device *asd = &isp->asd[i];
-			if (asd->streaming ==
-			    ATOMISP_DEVICE_STREAMING_ENABLED) {
-				atomisp_clear_css_buffer_counters(asd);
-				atomisp_flush_bufs_and_wakeup(asd);
-				complete(&asd->init_done);
-			}
-#ifdef ISP2401
-			atomisp_wdt_stop(asd, false);
-#endif
-		}
-
-#ifndef ISP2401
-		atomic_set(&isp->wdt_count, 0);
-#endif
-		isp->isp_fatal_error = true;
-		atomic_set(&isp->wdt_work_queued, 0);
-
-		rt_mutex_unlock(&isp->mutex);
-		return;
-	}
-
-	__atomisp_css_recover(isp, true);
-#ifdef ISP2401
-	for (i = 0; i < isp->num_of_streams; i++) {
-		struct atomisp_sub_device *asd = &isp->asd[i];
-		if (asd->streaming ==
-			ATOMISP_DEVICE_STREAMING_ENABLED) {
-			atomisp_wdt_refresh(asd,
-				isp->sw_contex.file_input ?
-				ATOMISP_ISP_FILE_TIMEOUT_DURATION :
-				ATOMISP_ISP_TIMEOUT_DURATION);
-		}
-	}
-#endif
-	dev_err(isp->dev, "timeout recovery handling done\n");
-	atomic_set(&isp->wdt_work_queued, 0);
-
-	rt_mutex_unlock(&isp->mutex);
-}
-
-void atomisp_css_flush(struct atomisp_device *isp)
-{
-	int i;
-
-	if (!atomisp_streaming_count(isp))
-		return;
-
-	/* Disable wdt */
-	for (i = 0; i < isp->num_of_streams; i++) {
-		struct atomisp_sub_device *asd = &isp->asd[i];
-		atomisp_wdt_stop(asd, true);
-	}
-
-	/* Start recover */
-	__atomisp_css_recover(isp, false);
-	/* Restore wdt */
-	for (i = 0; i < isp->num_of_streams; i++) {
-		struct atomisp_sub_device *asd = &isp->asd[i];
-
-		if (asd->streaming !=
-				ATOMISP_DEVICE_STREAMING_ENABLED)
-			continue;
-
-		atomisp_wdt_refresh(asd,
-				    isp->sw_contex.file_input ?
-				    ATOMISP_ISP_FILE_TIMEOUT_DURATION :
-				    ATOMISP_ISP_TIMEOUT_DURATION);
-	}
-	dev_dbg(isp->dev, "atomisp css flush done\n");
-}
-
-void atomisp_wdt(struct timer_list *t)
-{
-#ifndef ISP2401
-	struct atomisp_sub_device *asd = from_timer(asd, t, wdt);
-#else
-	struct atomisp_video_pipe *pipe = from_timer(pipe, t, wdt);
-	struct atomisp_sub_device *asd = pipe->asd;
-#endif
-	struct atomisp_device *isp = asd->isp;
-
-#ifdef ISP2401
-	atomic_inc(&pipe->wdt_count);
-	dev_warn(isp->dev,
-		"[WARNING]asd %d pipe %s ISP timeout %d!\n",
-			asd->index, pipe->vdev.name,
-			atomic_read(&pipe->wdt_count));
-#endif
-	if (atomic_read(&isp->wdt_work_queued)) {
-		dev_dbg(isp->dev, "ISP watchdog was put into workqueue\n");
-		return;
-	}
-	atomic_set(&isp->wdt_work_queued, 1);
-	queue_work(isp->wdt_work_queue, &isp->wdt_work);
-}
-
-#ifndef ISP2401
-void atomisp_wdt_refresh(struct atomisp_sub_device *asd, unsigned int delay)
-#else
-void atomisp_wdt_refresh_pipe(struct atomisp_video_pipe *pipe,
-				unsigned int delay)
-#endif
-{
-	unsigned long next;
-
-	if (delay != ATOMISP_WDT_KEEP_CURRENT_DELAY)
-#ifndef ISP2401
-		asd->wdt_duration = delay;
-#else
-		pipe->wdt_duration = delay;
-#endif
-
-#ifndef ISP2401
-	next = jiffies + asd->wdt_duration;
-#else
-	next = jiffies + pipe->wdt_duration;
-#endif
-
-	/* Override next if it has been pushed beyon the "next" time */
-#ifndef ISP2401
-	if (atomisp_is_wdt_running(asd) && time_after(asd->wdt_expires, next))
-		next = asd->wdt_expires;
-#else
-	if (atomisp_is_wdt_running(pipe) && time_after(pipe->wdt_expires, next))
-		next = pipe->wdt_expires;
-#endif
-
-#ifndef ISP2401
-	asd->wdt_expires = next;
-#else
-	pipe->wdt_expires = next;
-#endif
-
-#ifndef ISP2401
-	if (atomisp_is_wdt_running(asd))
-		dev_dbg(asd->isp->dev, "WDT will hit after %d ms\n",
-			((int)(next - jiffies) * 1000 / HZ));
-#else
-	if (atomisp_is_wdt_running(pipe))
-		dev_dbg(pipe->asd->isp->dev, "WDT will hit after %d ms (%s)\n",
-			((int)(next - jiffies) * 1000 / HZ), pipe->vdev.name);
-#endif
-	else
-#ifndef ISP2401
-		dev_dbg(asd->isp->dev, "WDT starts with %d ms period\n",
-			((int)(next - jiffies) * 1000 / HZ));
-#else
-		dev_dbg(pipe->asd->isp->dev, "WDT starts with %d ms period (%s)\n",
-			((int)(next - jiffies) * 1000 / HZ), pipe->vdev.name);
-#endif
-
-#ifndef ISP2401
-	mod_timer(&asd->wdt, next);
-	atomic_set(&asd->isp->wdt_count, 0);
-#else
-	mod_timer(&pipe->wdt, next);
-#endif
-}
-
-#ifndef ISP2401
-void atomisp_wdt_stop(struct atomisp_sub_device *asd, bool sync)
-#else
-void atomisp_wdt_refresh(struct atomisp_sub_device *asd, unsigned int delay)
-{
-	dev_dbg(asd->isp->dev, "WDT refresh all:\n");
-	if (atomisp_is_wdt_running(&asd->video_out_capture))
-		atomisp_wdt_refresh_pipe(&asd->video_out_capture, delay);
-	if (atomisp_is_wdt_running(&asd->video_out_preview))
-		atomisp_wdt_refresh_pipe(&asd->video_out_preview, delay);
-	if (atomisp_is_wdt_running(&asd->video_out_vf))
-		atomisp_wdt_refresh_pipe(&asd->video_out_vf, delay);
-	if (atomisp_is_wdt_running(&asd->video_out_video_capture))
-		atomisp_wdt_refresh_pipe(&asd->video_out_video_capture, delay);
-}
-
-
-void atomisp_wdt_stop_pipe(struct atomisp_video_pipe *pipe, bool sync)
-#endif
-{
-#ifndef ISP2401
-	dev_dbg(asd->isp->dev, "WDT stop\n");
-#else
-	if (!atomisp_is_wdt_running(pipe))
-		return;
-
-	dev_dbg(pipe->asd->isp->dev,
-		"WDT stop asd %d (%s)\n", pipe->asd->index, pipe->vdev.name);
-
-#endif
-	if (sync) {
-#ifndef ISP2401
-		del_timer_sync(&asd->wdt);
-		cancel_work_sync(&asd->isp->wdt_work);
-#else
-		del_timer_sync(&pipe->wdt);
-		cancel_work_sync(&pipe->asd->isp->wdt_work);
-#endif
-	} else {
-#ifndef ISP2401
-		del_timer(&asd->wdt);
-#else
-		del_timer(&pipe->wdt);
-#endif
-	}
-}
-
-#ifndef ISP2401
-void atomisp_wdt_start(struct atomisp_sub_device *asd)
-#else
-void atomisp_wdt_stop(struct atomisp_sub_device *asd, bool sync)
-{
-	dev_dbg(asd->isp->dev, "WDT stop all:\n");
-	atomisp_wdt_stop_pipe(&asd->video_out_capture, sync);
-	atomisp_wdt_stop_pipe(&asd->video_out_preview, sync);
-	atomisp_wdt_stop_pipe(&asd->video_out_vf, sync);
-	atomisp_wdt_stop_pipe(&asd->video_out_video_capture, sync);
-}
-
-void atomisp_wdt_start(struct atomisp_video_pipe *pipe)
-#endif
-{
-#ifndef ISP2401
-	atomisp_wdt_refresh(asd, ATOMISP_ISP_TIMEOUT_DURATION);
-#else
-	atomisp_wdt_refresh_pipe(pipe, ATOMISP_ISP_TIMEOUT_DURATION);
-#endif
-}
-
-void atomisp_setup_flash(struct atomisp_sub_device *asd)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct v4l2_control ctrl;
-
-	if (isp->flash == NULL)
-		return;
-
-	if (asd->params.flash_state != ATOMISP_FLASH_REQUESTED &&
-	    asd->params.flash_state != ATOMISP_FLASH_DONE)
-		return;
-
-	if (asd->params.num_flash_frames) {
-		/* make sure the timeout is set before setting flash mode */
-		ctrl.id = V4L2_CID_FLASH_TIMEOUT;
-		ctrl.value = FLASH_TIMEOUT;
-
-		if (v4l2_s_ctrl(NULL, isp->flash->ctrl_handler, &ctrl)) {
-			dev_err(isp->dev, "flash timeout configure failed\n");
-			return;
-		}
-
-		atomisp_css_request_flash(asd);
-		asd->params.flash_state = ATOMISP_FLASH_ONGOING;
-	} else {
-		asd->params.flash_state = ATOMISP_FLASH_IDLE;
-	}
-}
-
-irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr)
-{
-	struct atomisp_device *isp = isp_ptr;
-	unsigned long flags;
-	bool frame_done_found[MAX_STREAM_NUM] = {0};
-	bool css_pipe_done[MAX_STREAM_NUM] = {0};
-	unsigned int i;
-	struct atomisp_sub_device *asd;
-
-	dev_dbg(isp->dev, ">%s\n", __func__);
-
-	spin_lock_irqsave(&isp->lock, flags);
-
-	if (!atomisp_streaming_count(isp) && !atomisp_is_acc_enabled(isp)) {
-		spin_unlock_irqrestore(&isp->lock, flags);
-		return IRQ_HANDLED;
-	}
-
-	spin_unlock_irqrestore(&isp->lock, flags);
-
-	/*
-	 * The standard CSS2.0 API tells the following calling sequence of
-	 * dequeue ready buffers:
-	 * while (ia_css_dequeue_event(...)) {
-	 *	switch (event.type) {
-	 *	...
-	 *	ia_css_pipe_dequeue_buffer()
-	 *	}
-	 * }
-	 * That is, dequeue event and buffer are one after another.
-	 *
-	 * But the following implementation is to first deuque all the event
-	 * to a FIFO, then process the event in the FIFO.
-	 * This will not have issue in single stream mode, but it do have some
-	 * issue in multiple stream case. The issue is that
-	 * ia_css_pipe_dequeue_buffer() will not return the corrent buffer in
-	 * a specific pipe.
-	 *
-	 * This is due to ia_css_pipe_dequeue_buffer() does not take the
-	 * ia_css_pipe parameter.
-	 *
-	 * So:
-	 * For CSS2.0: we change the way to not dequeue all the event at one
-	 * time, instead, dequue one and process one, then another
-	 */
-	rt_mutex_lock(&isp->mutex);
-	if (atomisp_css_isr_thread(isp, frame_done_found, css_pipe_done))
-		goto out;
-
-	for (i = 0; i < isp->num_of_streams; i++) {
-		asd = &isp->asd[i];
-		if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
-			continue;
-		atomisp_setup_flash(asd);
-
-	}
-out:
-	rt_mutex_unlock(&isp->mutex);
-	for (i = 0; i < isp->num_of_streams; i++) {
-		asd = &isp->asd[i];
-		if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED
-		    && css_pipe_done[asd->index]
-		    && isp->sw_contex.file_input)
-			v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-					 video, s_stream, 1);
-		/* FIXME! FIX ACC implementation */
-		if (asd->acc.pipeline && css_pipe_done[asd->index])
-			atomisp_css_acc_done(asd);
-	}
-	dev_dbg(isp->dev, "<%s\n", __func__);
-
-	return IRQ_HANDLED;
-}
-
-/*
- * utils for buffer allocation/free
- */
-
-int atomisp_get_frame_pgnr(struct atomisp_device *isp,
-			   const struct atomisp_css_frame *frame, u32 *p_pgnr)
-{
-	if (!frame) {
-		dev_err(isp->dev, "%s: NULL frame pointer ERROR.\n", __func__);
-		return -EINVAL;
-	}
-
-	*p_pgnr = DIV_ROUND_UP(frame->data_bytes, PAGE_SIZE);
-	return 0;
-}
-
-/*
- * Get internal fmt according to V4L2 fmt
- */
-static enum atomisp_css_frame_format
-v4l2_fmt_to_sh_fmt(u32 fmt)
-{
-	switch (fmt) {
-	case V4L2_PIX_FMT_YUV420:
-		return CSS_FRAME_FORMAT_YUV420;
-	case V4L2_PIX_FMT_YVU420:
-		return CSS_FRAME_FORMAT_YV12;
-	case V4L2_PIX_FMT_YUV422P:
-		return CSS_FRAME_FORMAT_YUV422;
-	case V4L2_PIX_FMT_YUV444:
-		return CSS_FRAME_FORMAT_YUV444;
-	case V4L2_PIX_FMT_NV12:
-		return CSS_FRAME_FORMAT_NV12;
-	case V4L2_PIX_FMT_NV21:
-		return CSS_FRAME_FORMAT_NV21;
-	case V4L2_PIX_FMT_NV16:
-		return CSS_FRAME_FORMAT_NV16;
-	case V4L2_PIX_FMT_NV61:
-		return CSS_FRAME_FORMAT_NV61;
-	case V4L2_PIX_FMT_UYVY:
-		return CSS_FRAME_FORMAT_UYVY;
-	case V4L2_PIX_FMT_YUYV:
-		return CSS_FRAME_FORMAT_YUYV;
-	case V4L2_PIX_FMT_RGB24:
-		return CSS_FRAME_FORMAT_PLANAR_RGB888;
-	case V4L2_PIX_FMT_RGB32:
-		return CSS_FRAME_FORMAT_RGBA888;
-	case V4L2_PIX_FMT_RGB565:
-		return CSS_FRAME_FORMAT_RGB565;
-	case V4L2_PIX_FMT_JPEG:
-	case V4L2_PIX_FMT_CUSTOM_M10MO_RAW:
-		return CSS_FRAME_FORMAT_BINARY_8;
-	case V4L2_PIX_FMT_SBGGR16:
-	case V4L2_PIX_FMT_SBGGR10:
-	case V4L2_PIX_FMT_SGBRG10:
-	case V4L2_PIX_FMT_SGRBG10:
-	case V4L2_PIX_FMT_SRGGB10:
-	case V4L2_PIX_FMT_SBGGR12:
-	case V4L2_PIX_FMT_SGBRG12:
-	case V4L2_PIX_FMT_SGRBG12:
-	case V4L2_PIX_FMT_SRGGB12:
-	case V4L2_PIX_FMT_SBGGR8:
-	case V4L2_PIX_FMT_SGBRG8:
-	case V4L2_PIX_FMT_SGRBG8:
-	case V4L2_PIX_FMT_SRGGB8:
-		return CSS_FRAME_FORMAT_RAW;
-	default:
-		return -EINVAL;
-	}
-}
-/*
- * raw format match between SH format and V4L2 format
- */
-static int raw_output_format_match_input(u32 input, u32 output)
-{
-	if ((input == CSS_FORMAT_RAW_12) &&
-	    ((output == V4L2_PIX_FMT_SRGGB12) ||
-	     (output == V4L2_PIX_FMT_SGRBG12) ||
-	     (output == V4L2_PIX_FMT_SBGGR12) ||
-	     (output == V4L2_PIX_FMT_SGBRG12)))
-		return 0;
-
-	if ((input == CSS_FORMAT_RAW_10) &&
-	    ((output == V4L2_PIX_FMT_SRGGB10) ||
-	     (output == V4L2_PIX_FMT_SGRBG10) ||
-	     (output == V4L2_PIX_FMT_SBGGR10) ||
-	     (output == V4L2_PIX_FMT_SGBRG10)))
-		return 0;
-
-	if ((input == CSS_FORMAT_RAW_8) &&
-	    ((output == V4L2_PIX_FMT_SRGGB8) ||
-	     (output == V4L2_PIX_FMT_SGRBG8) ||
-	     (output == V4L2_PIX_FMT_SBGGR8) ||
-	     (output == V4L2_PIX_FMT_SGBRG8)))
-		return 0;
-
-	if ((input == CSS_FORMAT_RAW_16) && (output == V4L2_PIX_FMT_SBGGR16))
-		return 0;
-
-	return -EINVAL;
-}
-
-static u32 get_pixel_depth(u32 pixelformat)
-{
-	switch (pixelformat) {
-	case V4L2_PIX_FMT_YUV420:
-	case V4L2_PIX_FMT_NV12:
-	case V4L2_PIX_FMT_NV21:
-	case V4L2_PIX_FMT_YVU420:
-		return 12;
-	case V4L2_PIX_FMT_YUV422P:
-	case V4L2_PIX_FMT_YUYV:
-	case V4L2_PIX_FMT_UYVY:
-	case V4L2_PIX_FMT_NV16:
-	case V4L2_PIX_FMT_NV61:
-	case V4L2_PIX_FMT_RGB565:
-	case V4L2_PIX_FMT_SBGGR16:
-	case V4L2_PIX_FMT_SBGGR12:
-	case V4L2_PIX_FMT_SGBRG12:
-	case V4L2_PIX_FMT_SGRBG12:
-	case V4L2_PIX_FMT_SRGGB12:
-	case V4L2_PIX_FMT_SBGGR10:
-	case V4L2_PIX_FMT_SGBRG10:
-	case V4L2_PIX_FMT_SGRBG10:
-	case V4L2_PIX_FMT_SRGGB10:
-		return 16;
-	case V4L2_PIX_FMT_RGB24:
-	case V4L2_PIX_FMT_YUV444:
-		return 24;
-	case V4L2_PIX_FMT_RGB32:
-		return 32;
-	case V4L2_PIX_FMT_JPEG:
-	case V4L2_PIX_FMT_CUSTOM_M10MO_RAW:
-	case V4L2_PIX_FMT_SBGGR8:
-	case V4L2_PIX_FMT_SGBRG8:
-	case V4L2_PIX_FMT_SGRBG8:
-	case V4L2_PIX_FMT_SRGGB8:
-		return 8;
-	default:
-		return 8 * 2;	/* raw type now */
-	}
-}
-
-bool atomisp_is_mbuscode_raw(uint32_t code)
-{
-	return code >= 0x3000 && code < 0x4000;
-}
-
-/*
- * ISP features control function
- */
-
-/*
- * Set ISP capture mode based on current settings
- */
-static void atomisp_update_capture_mode(struct atomisp_sub_device *asd)
-{
-	if (asd->params.gdc_cac_en)
-		atomisp_css_capture_set_mode(asd, CSS_CAPTURE_MODE_ADVANCED);
-	else if (asd->params.low_light)
-		atomisp_css_capture_set_mode(asd, CSS_CAPTURE_MODE_LOW_LIGHT);
-	else if (asd->video_out_capture.sh_fmt == CSS_FRAME_FORMAT_RAW)
-		atomisp_css_capture_set_mode(asd, CSS_CAPTURE_MODE_RAW);
-	else
-		atomisp_css_capture_set_mode(asd, CSS_CAPTURE_MODE_PRIMARY);
-}
-
-#ifdef ISP2401
-int atomisp_set_sensor_runmode(struct atomisp_sub_device *asd,
-		struct atomisp_s_runmode *runmode)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct v4l2_ctrl *c;
-	struct v4l2_streamparm p = {0};
-	int ret = 0;
-	int modes[] = { CI_MODE_NONE,
-			CI_MODE_VIDEO,
-			CI_MODE_STILL_CAPTURE,
-			CI_MODE_CONTINUOUS,
-			CI_MODE_PREVIEW };
-
-	if (!(runmode && (runmode->mode & RUNMODE_MASK)))
-		return -EINVAL;
-
-	mutex_lock(asd->ctrl_handler.lock);
-	c = v4l2_ctrl_find(isp->inputs[asd->input_curr].camera->ctrl_handler,
-			   V4L2_CID_RUN_MODE);
-
-	if (c)
-		ret = v4l2_ctrl_s_ctrl(c, runmode->mode);
-
-	mutex_unlock(asd->ctrl_handler.lock);
-	return ret;
-}
-
-#endif
-/*
- * Function to enable/disable lens geometry distortion correction (GDC) and
- * chromatic aberration correction (CAC)
- */
-int atomisp_gdc_cac(struct atomisp_sub_device *asd, int flag,
-		    __s32 *value)
-{
-	if (flag == 0) {
-		*value = asd->params.gdc_cac_en;
-		return 0;
-	}
-
-	asd->params.gdc_cac_en = !!*value;
-	if (asd->params.gdc_cac_en) {
-		atomisp_css_set_morph_table(asd,
-					    asd->params.css_param.morph_table);
-	} else {
-		atomisp_css_set_morph_table(asd, NULL);
-	}
-	asd->params.css_update_params_needed = true;
-	atomisp_update_capture_mode(asd);
-	return 0;
-}
-
-/*
- * Function to enable/disable low light mode including ANR
- */
-int atomisp_low_light(struct atomisp_sub_device *asd, int flag,
-		      __s32 *value)
-{
-	if (flag == 0) {
-		*value = asd->params.low_light;
-		return 0;
-	}
-
-	asd->params.low_light = (*value != 0);
-	atomisp_update_capture_mode(asd);
-	return 0;
-}
-
-/*
- * Function to enable/disable extra noise reduction (XNR) in low light
- * condition
- */
-int atomisp_xnr(struct atomisp_sub_device *asd, int flag,
-		int *xnr_enable)
-{
-	if (flag == 0) {
-		*xnr_enable = asd->params.xnr_en;
-		return 0;
-	}
-
-	atomisp_css_capture_enable_xnr(asd, !!*xnr_enable);
-
-	return 0;
-}
-
-/*
- * Function to configure bayer noise reduction
- */
-int atomisp_nr(struct atomisp_sub_device *asd, int flag,
-	       struct atomisp_nr_config *arg)
-{
-	if (flag == 0) {
-		/* Get nr config from current setup */
-		if (atomisp_css_get_nr_config(asd, arg))
-			return -EINVAL;
-	} else {
-		/* Set nr config to isp parameters */
-		memcpy(&asd->params.css_param.nr_config, arg,
-		       sizeof(struct atomisp_css_nr_config));
-		atomisp_css_set_nr_config(asd, &asd->params.css_param.nr_config);
-		asd->params.css_update_params_needed = true;
-	}
-	return 0;
-}
-
-/*
- * Function to configure temporal noise reduction (TNR)
- */
-int atomisp_tnr(struct atomisp_sub_device *asd, int flag,
-		struct atomisp_tnr_config *config)
-{
-	/* Get tnr config from current setup */
-	if (flag == 0) {
-		/* Get tnr config from current setup */
-		if (atomisp_css_get_tnr_config(asd, config))
-			return -EINVAL;
-	} else {
-		/* Set tnr config to isp parameters */
-		memcpy(&asd->params.css_param.tnr_config, config,
-			sizeof(struct atomisp_css_tnr_config));
-		atomisp_css_set_tnr_config(asd, &asd->params.css_param.tnr_config);
-		asd->params.css_update_params_needed = true;
-	}
-
-	return 0;
-}
-
-/*
- * Function to configure black level compensation
- */
-int atomisp_black_level(struct atomisp_sub_device *asd, int flag,
-			struct atomisp_ob_config *config)
-{
-	if (flag == 0) {
-		/* Get ob config from current setup */
-		if (atomisp_css_get_ob_config(asd, config))
-			return -EINVAL;
-	} else {
-		/* Set ob config to isp parameters */
-		memcpy(&asd->params.css_param.ob_config, config,
-		       sizeof(struct atomisp_css_ob_config));
-		atomisp_css_set_ob_config(asd, &asd->params.css_param.ob_config);
-		asd->params.css_update_params_needed = true;
-	}
-
-	return 0;
-}
-
-/*
- * Function to configure edge enhancement
- */
-int atomisp_ee(struct atomisp_sub_device *asd, int flag,
-	       struct atomisp_ee_config *config)
-{
-	if (flag == 0) {
-		/* Get ee config from current setup */
-		if (atomisp_css_get_ee_config(asd, config))
-			return -EINVAL;
-	} else {
-		/* Set ee config to isp parameters */
-		memcpy(&asd->params.css_param.ee_config, config,
-		       sizeof(asd->params.css_param.ee_config));
-		atomisp_css_set_ee_config(asd, &asd->params.css_param.ee_config);
-		asd->params.css_update_params_needed = true;
-	}
-
-	return 0;
-}
-
-/*
- * Function to update Gamma table for gamma, brightness and contrast config
- */
-int atomisp_gamma(struct atomisp_sub_device *asd, int flag,
-		  struct atomisp_gamma_table *config)
-{
-	if (flag == 0) {
-		/* Get gamma table from current setup */
-		if (atomisp_css_get_gamma_table(asd, config))
-			return -EINVAL;
-	} else {
-		/* Set gamma table to isp parameters */
-		memcpy(&asd->params.css_param.gamma_table, config,
-		       sizeof(asd->params.css_param.gamma_table));
-		atomisp_css_set_gamma_table(asd, &asd->params.css_param.gamma_table);
-	}
-
-	return 0;
-}
-
-/*
- * Function to update Ctc table for Chroma Enhancement
- */
-int atomisp_ctc(struct atomisp_sub_device *asd, int flag,
-		struct atomisp_ctc_table *config)
-{
-	if (flag == 0) {
-		/* Get ctc table from current setup */
-		if (atomisp_css_get_ctc_table(asd, config))
-			return -EINVAL;
-	} else {
-		/* Set ctc table to isp parameters */
-		memcpy(&asd->params.css_param.ctc_table, config,
-		       sizeof(asd->params.css_param.ctc_table));
-		atomisp_css_set_ctc_table(asd, &asd->params.css_param.ctc_table);
-	}
-
-	return 0;
-}
-
-/*
- * Function to update gamma correction parameters
- */
-int atomisp_gamma_correction(struct atomisp_sub_device *asd, int flag,
-	struct atomisp_gc_config *config)
-{
-	if (flag == 0) {
-		/* Get gamma correction params from current setup */
-		if (atomisp_css_get_gc_config(asd, config))
-			return -EINVAL;
-	} else {
-		/* Set gamma correction params to isp parameters */
-		memcpy(&asd->params.css_param.gc_config, config,
-		       sizeof(asd->params.css_param.gc_config));
-		atomisp_css_set_gc_config(asd, &asd->params.css_param.gc_config);
-		asd->params.css_update_params_needed = true;
-	}
-
-	return 0;
-}
-
-/*
- * Function to update narrow gamma flag
- */
-int atomisp_formats(struct atomisp_sub_device *asd, int flag,
-		    struct atomisp_formats_config *config)
-{
-	if (flag == 0) {
-		/* Get narrow gamma flag from current setup */
-		if (atomisp_css_get_formats_config(asd, config))
-			return -EINVAL;
-	} else {
-		/* Set narrow gamma flag to isp parameters */
-		memcpy(&asd->params.css_param.formats_config, config,
-		       sizeof(asd->params.css_param.formats_config));
-		atomisp_css_set_formats_config(asd, &asd->params.css_param.formats_config);
-	}
-
-	return 0;
-}
-
-void atomisp_free_internal_buffers(struct atomisp_sub_device *asd)
-{
-	atomisp_free_css_parameters(&asd->params.css_param);
-
-	if (asd->raw_output_frame) {
-		atomisp_css_frame_free(asd->raw_output_frame);
-		asd->raw_output_frame = NULL;
-	}
-}
-
-static void atomisp_update_grid_info(struct atomisp_sub_device *asd,
-				     enum atomisp_css_pipe_id pipe_id,
-				     int source_pad)
-{
-	struct atomisp_device *isp = asd->isp;
-	int err;
-	uint16_t stream_id = atomisp_source_pad_to_stream_id(asd, source_pad);
-
-	if (atomisp_css_get_grid_info(asd, pipe_id, source_pad))
-		return;
-
-	/* We must free all buffers because they no longer match
-	   the grid size. */
-	atomisp_css_free_stat_buffers(asd);
-
-	err = atomisp_alloc_css_stat_bufs(asd, stream_id);
-	if (err) {
-		dev_err(isp->dev, "stat_buf allocate error\n");
-		goto err;
-	}
-
-	if (atomisp_alloc_3a_output_buf(asd)) {
-		/* Failure for 3A buffers does not influence DIS buffers */
-		if (asd->params.s3a_output_bytes != 0) {
-			/* For SOC sensor happens s3a_output_bytes == 0,
-			 * using if condition to exclude false error log */
-			dev_err(isp->dev, "Failed to allocate memory for 3A statistics\n");
-		}
-		goto err;
-	}
-
-	if (atomisp_alloc_dis_coef_buf(asd)) {
-		dev_err(isp->dev,
-			"Failed to allocate memory for DIS statistics\n");
-		goto err;
-	}
-
-	if (atomisp_alloc_metadata_output_buf(asd)) {
-		dev_err(isp->dev, "Failed to allocate memory for metadata\n");
-		goto err;
-	}
-
-	return;
-
-err:
-	atomisp_css_free_stat_buffers(asd);
-	return;
-}
-
-static void atomisp_curr_user_grid_info(struct atomisp_sub_device *asd,
-					struct atomisp_grid_info *info)
-{
-	memcpy(info, &asd->params.curr_grid_info.s3a_grid,
-	       sizeof(struct atomisp_css_3a_grid_info));
-}
-
-int atomisp_compare_grid(struct atomisp_sub_device *asd,
-				struct atomisp_grid_info *atomgrid)
-{
-	struct atomisp_grid_info tmp = {0};
-
-	atomisp_curr_user_grid_info(asd, &tmp);
-	return memcmp(atomgrid, &tmp, sizeof(tmp));
-}
-
-/*
- * Function to update Gdc table for gdc
- */
-int atomisp_gdc_cac_table(struct atomisp_sub_device *asd, int flag,
-			  struct atomisp_morph_table *config)
-{
-	int ret;
-	int i;
-	struct atomisp_device *isp = asd->isp;
-
-	if (flag == 0) {
-		/* Get gdc table from current setup */
-		struct atomisp_css_morph_table tab = {0};
-		atomisp_css_get_morph_table(asd, &tab);
-
-		config->width = tab.width;
-		config->height = tab.height;
-
-		for (i = 0; i < CSS_MORPH_TABLE_NUM_PLANES; i++) {
-			ret = copy_to_user(config->coordinates_x[i],
-				tab.coordinates_x[i], tab.height *
-				tab.width * sizeof(*tab.coordinates_x[i]));
-			if (ret) {
-				dev_err(isp->dev,
-					"Failed to copy to User for x\n");
-				return -EFAULT;
-			}
-			ret = copy_to_user(config->coordinates_y[i],
-				tab.coordinates_y[i], tab.height *
-				tab.width * sizeof(*tab.coordinates_y[i]));
-			if (ret) {
-				dev_err(isp->dev,
-					"Failed to copy to User for y\n");
-				return -EFAULT;
-			}
-		}
-	} else {
-		struct atomisp_css_morph_table *tab =
-			asd->params.css_param.morph_table;
-
-		/* free first if we have one */
-		if (tab) {
-			atomisp_css_morph_table_free(tab);
-			asd->params.css_param.morph_table = NULL;
-		}
-
-		/* allocate new one */
-		tab = atomisp_css_morph_table_allocate(config->width,
-						       config->height);
-
-		if (!tab) {
-			dev_err(isp->dev, "out of memory\n");
-			return -EINVAL;
-		}
-
-		for (i = 0; i < CSS_MORPH_TABLE_NUM_PLANES; i++) {
-			ret = copy_from_user(tab->coordinates_x[i],
-				config->coordinates_x[i],
-				config->height * config->width *
-				sizeof(*config->coordinates_x[i]));
-			if (ret) {
-				dev_err(isp->dev,
-				"Failed to copy from User for x, ret %d\n",
-				ret);
-				atomisp_css_morph_table_free(tab);
-				return -EFAULT;
-			}
-			ret = copy_from_user(tab->coordinates_y[i],
-				config->coordinates_y[i],
-				config->height * config->width *
-				sizeof(*config->coordinates_y[i]));
-			if (ret) {
-				dev_err(isp->dev,
-				"Failed to copy from User for y, ret is %d\n",
-				ret);
-				atomisp_css_morph_table_free(tab);
-				return -EFAULT;
-			}
-		}
-		asd->params.css_param.morph_table = tab;
-		if (asd->params.gdc_cac_en)
-			atomisp_css_set_morph_table(asd, tab);
-	}
-
-	return 0;
-}
-
-int atomisp_macc_table(struct atomisp_sub_device *asd, int flag,
-		       struct atomisp_macc_config *config)
-{
-	struct atomisp_css_macc_table *macc_table;
-
-	switch (config->color_effect) {
-	case V4L2_COLORFX_NONE:
-		macc_table = &asd->params.css_param.macc_table;
-		break;
-	case V4L2_COLORFX_SKY_BLUE:
-		macc_table = &blue_macc_table;
-		break;
-	case V4L2_COLORFX_GRASS_GREEN:
-		macc_table = &green_macc_table;
-		break;
-	case V4L2_COLORFX_SKIN_WHITEN_LOW:
-		macc_table = &skin_low_macc_table;
-		break;
-	case V4L2_COLORFX_SKIN_WHITEN:
-		macc_table = &skin_medium_macc_table;
-		break;
-	case V4L2_COLORFX_SKIN_WHITEN_HIGH:
-		macc_table = &skin_high_macc_table;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	if (flag == 0) {
-		/* Get macc table from current setup */
-		memcpy(&config->table, macc_table,
-		       sizeof(struct atomisp_css_macc_table));
-	} else {
-		memcpy(macc_table, &config->table,
-		       sizeof(struct atomisp_css_macc_table));
-		if (config->color_effect == asd->params.color_effect)
-			atomisp_css_set_macc_table(asd, macc_table);
-	}
-
-	return 0;
-}
-
-int atomisp_set_dis_vector(struct atomisp_sub_device *asd,
-			   struct atomisp_dis_vector *vector)
-{
-	atomisp_css_video_set_dis_vector(asd, vector);
-
-	asd->params.dis_proj_data_valid = false;
-	asd->params.css_update_params_needed = true;
-	return 0;
-}
-
-/*
- * Function to set/get image stablization statistics
- */
-int atomisp_get_dis_stat(struct atomisp_sub_device *asd,
-			 struct atomisp_dis_statistics *stats)
-{
-	return atomisp_css_get_dis_stat(asd, stats);
-}
-
-/*
- * Function  set camrea_prefiles.xml current sensor pixel array size
- */
-int atomisp_set_array_res(struct atomisp_sub_device *asd,
-			 struct atomisp_resolution  *config)
-{
-	dev_dbg(asd->isp->dev, ">%s start\n", __func__);
-	if (!config) {
-		dev_err(asd->isp->dev, "Set sensor array size is not valid\n");
-		return -EINVAL;
-	}
-
-	asd->sensor_array_res.width = config->width;
-	asd->sensor_array_res.height = config->height;
-	return 0;
-}
-
-/*
- * Function to get DVS2 BQ resolution settings
- */
-int atomisp_get_dvs2_bq_resolutions(struct atomisp_sub_device *asd,
-			 struct atomisp_dvs2_bq_resolutions *bq_res)
-{
-	struct ia_css_pipe_config *pipe_cfg = NULL;
-	struct ia_css_stream_config *stream_cfg = NULL;
-	struct ia_css_stream_input_config *input_config = NULL;
-
-	struct ia_css_stream *stream =
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream;
-	if (!stream) {
-		dev_warn(asd->isp->dev, "stream is not created");
-		return -EAGAIN;
-	}
-
-	pipe_cfg = &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.pipe_configs[CSS_PIPE_ID_VIDEO];
-	stream_cfg = &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.stream_config;
-	input_config = &stream_cfg->input_config;
-
-	if (!bq_res)
-		return -EINVAL;
-
-	/* the GDC output resolution */
-	bq_res->output_bq.width_bq = pipe_cfg->output_info[0].res.width / 2;
-	bq_res->output_bq.height_bq = pipe_cfg->output_info[0].res.height / 2;
-
-	bq_res->envelope_bq.width_bq = 0;
-	bq_res->envelope_bq.height_bq = 0;
-	/* the GDC input resolution */
-	if (!asd->continuous_mode->val) {
-		bq_res->source_bq.width_bq = bq_res->output_bq.width_bq +
-				pipe_cfg->dvs_envelope.width / 2;
-		bq_res->source_bq.height_bq = bq_res->output_bq.height_bq +
-				pipe_cfg->dvs_envelope.height / 2;
-		/*
-		 * Bad pixels caused by spatial filter processing
-		 * ISP filter resolution should be given by CSS/FW, but for now
-		 * there is not such API to query, and it is fixed value, so
-		 * hardcoded here.
-		 */
-		bq_res->ispfilter_bq.width_bq = 12 / 2;
-		bq_res->ispfilter_bq.height_bq = 12 / 2;
-		/* spatial filter shift, always 4 pixels */
-		bq_res->gdc_shift_bq.width_bq = 4 / 2;
-		bq_res->gdc_shift_bq.height_bq = 4 / 2;
-
-		if (asd->params.video_dis_en) {
-			bq_res->envelope_bq.width_bq = pipe_cfg->dvs_envelope.width
-					/ 2 - bq_res->ispfilter_bq.width_bq;
-			bq_res->envelope_bq.height_bq = pipe_cfg->dvs_envelope.height
-					/ 2 - bq_res->ispfilter_bq.height_bq;
-		}
-	} else {
-		unsigned int w_padding;
-		unsigned int gdc_effective_input = 0;
-
-		/* For GDC:
-		 * gdc_effective_input = effective_input + envelope
-		 *
-		 * From the comment and formula in BZ1786,
-		 * we see the source_bq should be:
-		 * effective_input / bayer_ds_ratio
-		 */
-		bq_res->source_bq.width_bq =
-			(input_config->effective_res.width *
-			 pipe_cfg->bayer_ds_out_res.width /
-			 input_config->effective_res.width + 1) / 2;
-		bq_res->source_bq.height_bq =
-			(input_config->effective_res.height *
-			 pipe_cfg->bayer_ds_out_res.height /
-			 input_config->effective_res.height + 1) / 2;
-
-
-		if (!asd->params.video_dis_en) {
-			/*
-			 * We adjust the ispfilter_bq to:
-			 * ispfilter_bq = 128/BDS
-			 * we still need firmware team to provide an offical
-			 * formula for SDV.
-			 */
-			bq_res->ispfilter_bq.width_bq = 128 *
-				pipe_cfg->bayer_ds_out_res.width /
-				input_config->effective_res.width / 2;
-			bq_res->ispfilter_bq.height_bq = 128 *
-				pipe_cfg->bayer_ds_out_res.width /
-				input_config->effective_res.width / 2;
-
-			if (IS_HWREVISION(asd->isp, ATOMISP_HW_REVISION_ISP2401)) {
-				/* No additional left padding for ISYS2401 */
-				bq_res->gdc_shift_bq.width_bq = 4 / 2;
-				bq_res->gdc_shift_bq.height_bq = 4 / 2;
-			} else {
-				/*
-				 * For the w_padding and gdc_shift_bq cacluation
-				 * Please see the BZ 1786 and 4358 for more info.
-				 * Just test that this formula can work now,
-				 * but we still have no offical formula.
-				 *
-				 * w_padding = ceiling(gdc_effective_input
-				 *             /128, 1) * 128 - effective_width
-				 * gdc_shift_bq = w_padding/BDS/2 + ispfilter_bq/2
-				 */
-				gdc_effective_input =
-					input_config->effective_res.width +
-					pipe_cfg->dvs_envelope.width;
-				w_padding = roundup(gdc_effective_input, 128) -
-					input_config->effective_res.width;
-				w_padding = w_padding *
-					pipe_cfg->bayer_ds_out_res.width /
-					input_config->effective_res.width + 1;
-				w_padding = roundup(w_padding/2, 1);
-
-				bq_res->gdc_shift_bq.width_bq = bq_res->ispfilter_bq.width_bq / 2
-					+ w_padding;
-				bq_res->gdc_shift_bq.height_bq = 4 / 2;
-			}
-		} else {
-			unsigned int dvs_w, dvs_h, dvs_w_max, dvs_h_max;
-
-			bq_res->ispfilter_bq.width_bq = 8 / 2;
-			bq_res->ispfilter_bq.height_bq = 8 / 2;
-
-			if (IS_HWREVISION(asd->isp, ATOMISP_HW_REVISION_ISP2401)) {
-				/* No additional left padding for ISYS2401 */
-				bq_res->gdc_shift_bq.width_bq = 4 / 2;
-				bq_res->gdc_shift_bq.height_bq = 4 / 2;
-			} else {
-				w_padding =
-				    roundup(input_config->effective_res.width, 128) -
-				    input_config->effective_res.width;
-				if (w_padding < 12)
-					w_padding = 12;
-				bq_res->gdc_shift_bq.width_bq = 4 / 2 +
-				    ((w_padding - 12) *
-				     pipe_cfg->bayer_ds_out_res.width /
-				input_config->effective_res.width + 1) / 2;
-				bq_res->gdc_shift_bq.height_bq = 4 / 2;
-			}
-
-			dvs_w = pipe_cfg->bayer_ds_out_res.width -
-				pipe_cfg->output_info[0].res.width;
-			dvs_h = pipe_cfg->bayer_ds_out_res.height -
-				pipe_cfg->output_info[0].res.height;
-			dvs_w_max = rounddown(
-					pipe_cfg->output_info[0].res.width / 5,
-					ATOM_ISP_STEP_WIDTH);
-			dvs_h_max = rounddown(
-					pipe_cfg->output_info[0].res.height / 5,
-					ATOM_ISP_STEP_HEIGHT);
-			bq_res->envelope_bq.width_bq =
-				min((dvs_w / 2), (dvs_w_max / 2)) -
-				bq_res->ispfilter_bq.width_bq;
-			bq_res->envelope_bq.height_bq =
-				min((dvs_h / 2), (dvs_h_max / 2)) -
-				bq_res->ispfilter_bq.height_bq;
-		}
-	}
-
-	dev_dbg(asd->isp->dev, "source_bq.width_bq %d, source_bq.height_bq %d,\nispfilter_bq.width_bq %d, ispfilter_bq.height_bq %d,\ngdc_shift_bq.width_bq %d, gdc_shift_bq.height_bq %d,\nenvelope_bq.width_bq %d, envelope_bq.height_bq %d,\noutput_bq.width_bq %d, output_bq.height_bq %d\n",
-	      bq_res->source_bq.width_bq, bq_res->source_bq.height_bq,
-	      bq_res->ispfilter_bq.width_bq, bq_res->ispfilter_bq.height_bq,
-	      bq_res->gdc_shift_bq.width_bq, bq_res->gdc_shift_bq.height_bq,
-	      bq_res->envelope_bq.width_bq, bq_res->envelope_bq.height_bq,
-	      bq_res->output_bq.width_bq, bq_res->output_bq.height_bq);
-
-	return 0;
-}
-
-int atomisp_set_dis_coefs(struct atomisp_sub_device *asd,
-			  struct atomisp_dis_coefficients *coefs)
-{
-	return atomisp_css_set_dis_coefs(asd, coefs);
-}
-
-/*
- * Function to set/get 3A stat from isp
- */
-int atomisp_3a_stat(struct atomisp_sub_device *asd, int flag,
-		    struct atomisp_3a_statistics *config)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct atomisp_s3a_buf *s3a_buf;
-	unsigned long ret;
-
-	if (flag != 0)
-		return -EINVAL;
-
-	/* sanity check to avoid writing into unallocated memory. */
-	if (asd->params.s3a_output_bytes == 0)
-		return -EINVAL;
-
-	if (atomisp_compare_grid(asd, &config->grid_info) != 0) {
-		/* If the grid info in the argument differs from the current
-		   grid info, we tell the caller to reset the grid size and
-		   try again. */
-		return -EAGAIN;
-	}
-
-	if (list_empty(&asd->s3a_stats_ready)) {
-		dev_err(isp->dev, "3a statistics is not valid.\n");
-		return -EAGAIN;
-	}
-
-	s3a_buf = list_entry(asd->s3a_stats_ready.next,
-			struct atomisp_s3a_buf, list);
-	if (s3a_buf->s3a_map)
-		ia_css_translate_3a_statistics(
-			asd->params.s3a_user_stat, s3a_buf->s3a_map);
-	else
-		ia_css_get_3a_statistics(asd->params.s3a_user_stat,
-			s3a_buf->s3a_data);
-
-	config->exp_id = s3a_buf->s3a_data->exp_id;
-	config->isp_config_id = s3a_buf->s3a_data->isp_config_id;
-
-	ret = copy_to_user(config->data, asd->params.s3a_user_stat->data,
-			   asd->params.s3a_output_bytes);
-	if (ret) {
-		dev_err(isp->dev, "copy to user failed: copied %lu bytes\n",
-				ret);
-		return -EFAULT;
-	}
-
-	/* Move to free buffer list */
-	list_del_init(&s3a_buf->list);
-	list_add_tail(&s3a_buf->list, &asd->s3a_stats);
-	dev_dbg(isp->dev, "%s: finish getting exp_id %d 3a stat, isp_config_id %d\n", __func__,
-		config->exp_id, config->isp_config_id);
-	return 0;
-}
-
-int atomisp_get_metadata(struct atomisp_sub_device *asd, int flag,
-			 struct atomisp_metadata *md)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct ia_css_stream_config *stream_config;
-	struct ia_css_stream_info *stream_info;
-	struct camera_mipi_info *mipi_info;
-	struct atomisp_metadata_buf *md_buf;
-	enum atomisp_metadata_type md_type = ATOMISP_MAIN_METADATA;
-	int ret, i;
-
-	if (flag != 0)
-		return -EINVAL;
-
-	stream_config = &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].
-		stream_config;
-	stream_info = &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].
-		stream_info;
-
-	/* We always return the resolution and stride even if there is
-	 * no valid metadata. This allows the caller to get the information
-	 * needed to allocate user-space buffers. */
-	md->width  = stream_info->metadata_info.resolution.width;
-	md->height = stream_info->metadata_info.resolution.height;
-	md->stride = stream_info->metadata_info.stride;
-
-	/* sanity check to avoid writing into unallocated memory.
-	 * This does not return an error because it is a valid way
-	 * for applications to detect that metadata is not enabled. */
-	if (md->width == 0 || md->height == 0 || !md->data)
-		return 0;
-
-	/* This is done in the atomisp_buf_done() */
-	if (list_empty(&asd->metadata_ready[md_type])) {
-		dev_warn(isp->dev, "Metadata queue is empty now!\n");
-		return -EAGAIN;
-	}
-
-	mipi_info = atomisp_to_sensor_mipi_info(
-		isp->inputs[asd->input_curr].camera);
-	if (mipi_info == NULL)
-		return -EINVAL;
-
-	if (mipi_info->metadata_effective_width != NULL) {
-		for (i = 0; i < md->height; i++)
-			md->effective_width[i] =
-				mipi_info->metadata_effective_width[i];
-	}
-
-	md_buf = list_entry(asd->metadata_ready[md_type].next,
-			    struct atomisp_metadata_buf, list);
-	md->exp_id = md_buf->metadata->exp_id;
-	if (md_buf->md_vptr) {
-		ret = copy_to_user(md->data,
-				   md_buf->md_vptr,
-				   stream_info->metadata_info.size);
-	} else {
-		hmm_load(md_buf->metadata->address,
-				    asd->params.metadata_user[md_type],
-				    stream_info->metadata_info.size);
-
-		ret = copy_to_user(md->data,
-				   asd->params.metadata_user[md_type],
-				   stream_info->metadata_info.size);
-	}
-	if (ret) {
-		dev_err(isp->dev, "copy to user failed: copied %d bytes\n",
-			ret);
-		return -EFAULT;
-	}
-
-	list_del_init(&md_buf->list);
-	list_add_tail(&md_buf->list, &asd->metadata[md_type]);
-
-	dev_dbg(isp->dev, "%s: HAL de-queued metadata type %d with exp_id %d\n",
-		__func__, md_type, md->exp_id);
-	return 0;
-}
-
-int atomisp_get_metadata_by_type(struct atomisp_sub_device *asd, int flag,
-				 struct atomisp_metadata_with_type *md)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct ia_css_stream_config *stream_config;
-	struct ia_css_stream_info *stream_info;
-	struct camera_mipi_info *mipi_info;
-	struct atomisp_metadata_buf *md_buf;
-	enum atomisp_metadata_type md_type;
-	int ret, i;
-
-	if (flag != 0)
-		return -EINVAL;
-
-	stream_config = &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].
-		stream_config;
-	stream_info = &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].
-		stream_info;
-
-	/* We always return the resolution and stride even if there is
-	 * no valid metadata. This allows the caller to get the information
-	 * needed to allocate user-space buffers. */
-	md->width  = stream_info->metadata_info.resolution.width;
-	md->height = stream_info->metadata_info.resolution.height;
-	md->stride = stream_info->metadata_info.stride;
-
-	/* sanity check to avoid writing into unallocated memory.
-	 * This does not return an error because it is a valid way
-	 * for applications to detect that metadata is not enabled. */
-	if (md->width == 0 || md->height == 0 || !md->data)
-		return 0;
-
-	md_type = md->type;
-	if (md_type < 0 || md_type >= ATOMISP_METADATA_TYPE_NUM)
-		return -EINVAL;
-
-	/* This is done in the atomisp_buf_done() */
-	if (list_empty(&asd->metadata_ready[md_type])) {
-		dev_warn(isp->dev, "Metadata queue is empty now!\n");
-		return -EAGAIN;
-	}
-
-	mipi_info = atomisp_to_sensor_mipi_info(
-		isp->inputs[asd->input_curr].camera);
-	if (mipi_info == NULL)
-		return -EINVAL;
-
-	if (mipi_info->metadata_effective_width != NULL) {
-		for (i = 0; i < md->height; i++)
-			md->effective_width[i] =
-				mipi_info->metadata_effective_width[i];
-	}
-
-	md_buf = list_entry(asd->metadata_ready[md_type].next,
-			    struct atomisp_metadata_buf, list);
-	md->exp_id = md_buf->metadata->exp_id;
-	if (md_buf->md_vptr) {
-		ret = copy_to_user(md->data,
-				   md_buf->md_vptr,
-				   stream_info->metadata_info.size);
-	} else {
-		hmm_load(md_buf->metadata->address,
-				    asd->params.metadata_user[md_type],
-				    stream_info->metadata_info.size);
-
-		ret = copy_to_user(md->data,
-				   asd->params.metadata_user[md_type],
-				   stream_info->metadata_info.size);
-	}
-	if (ret) {
-		dev_err(isp->dev, "copy to user failed: copied %d bytes\n",
-			ret);
-		return -EFAULT;
-	} else {
-		list_del_init(&md_buf->list);
-		list_add_tail(&md_buf->list, &asd->metadata[md_type]);
-	}
-	dev_dbg(isp->dev, "%s: HAL de-queued metadata type %d with exp_id %d\n",
-		__func__, md_type, md->exp_id);
-	return 0;
-}
-
-/*
- * Function to calculate real zoom region for every pipe
- */
-int atomisp_calculate_real_zoom_region(struct atomisp_sub_device *asd,
-				       struct ia_css_dz_config   *dz_config,
-				       enum atomisp_css_pipe_id css_pipe_id)
-
-{
-	struct atomisp_stream_env *stream_env =
-			&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-	struct atomisp_resolution  eff_res, out_res;
-#ifdef ISP2401
-	int w_offset, h_offset;
-#endif
-
-	memset(&eff_res, 0, sizeof(eff_res));
-	memset(&out_res, 0, sizeof(out_res));
-
-	if (dz_config->dx || dz_config->dy)
-		return 0;
-
-	if (css_pipe_id != IA_CSS_PIPE_ID_PREVIEW
-		&& css_pipe_id != IA_CSS_PIPE_ID_CAPTURE) {
-		dev_err(asd->isp->dev, "%s the set pipe no support crop region"
-			, __func__);
-		return -EINVAL;
-	}
-
-	eff_res.width =
-		stream_env->stream_config.input_config.effective_res.width;
-	eff_res.height =
-		stream_env->stream_config.input_config.effective_res.height;
-	if (eff_res.width == 0 || eff_res.height == 0) {
-		dev_err(asd->isp->dev, "%s err effective resolution"
-				, __func__);
-		return -EINVAL;
-	}
-
-	if (dz_config->zoom_region.resolution.width
-		== asd->sensor_array_res.width
-		|| dz_config->zoom_region.resolution.height
-		== asd->sensor_array_res.height) {
-		/*no need crop region*/
-		dz_config->zoom_region.origin.x = 0;
-		dz_config->zoom_region.origin.y = 0;
-		dz_config->zoom_region.resolution.width = eff_res.width;
-		dz_config->zoom_region.resolution.height = eff_res.height;
-		return 0;
-	}
-
-	/* FIXME:
-	 * This is not the correct implementation with Google's definition, due
-	 * to firmware limitation.
-	 * map real crop region base on above calculating base max crop region.
-	 */
-#ifdef ISP2401
-	out_res.width =
-		stream_env->pipe_configs[css_pipe_id].output_info[0].res.width;
-	out_res.height =
-		stream_env->pipe_configs[css_pipe_id].output_info[0].res.height;
-	if (out_res.width == 0 || out_res.height == 0) {
-		dev_err(asd->isp->dev, "%s err current pipe output resolution"
-				, __func__);
-		return -EINVAL;
-	}
-
-	if (asd->sensor_array_res.width * out_res.height
-			< out_res.width * asd->sensor_array_res.height) {
-		h_offset = asd->sensor_array_res.height -
-				asd->sensor_array_res.width
-				* out_res.height / out_res.width;
-		h_offset = h_offset / 2;
-		if (dz_config->zoom_region.origin.y < h_offset)
-			dz_config->zoom_region.origin.y = 0;
-		else
-			dz_config->zoom_region.origin.y =
-				dz_config->zoom_region.origin.y - h_offset;
-		w_offset = 0;
-	} else {
-		w_offset = asd->sensor_array_res.width -
-				asd->sensor_array_res.height
-				* out_res.width / out_res.height;
-		w_offset = w_offset / 2;
-		if (dz_config->zoom_region.origin.x < w_offset)
-			dz_config->zoom_region.origin.x = 0;
-		else
-			dz_config->zoom_region.origin.x =
-				dz_config->zoom_region.origin.x - w_offset;
-		h_offset = 0;
-	}
-#endif
-	dz_config->zoom_region.origin.x =
-			dz_config->zoom_region.origin.x
-			* eff_res.width
-#ifndef ISP2401
-			/ asd->sensor_array_res.width;
-#else
-			/ (asd->sensor_array_res.width -
-			2 * w_offset);
-#endif
-	dz_config->zoom_region.origin.y =
-			dz_config->zoom_region.origin.y
-			* eff_res.height
-#ifndef ISP2401
-			/ asd->sensor_array_res.height;
-#else
-			/ (asd->sensor_array_res.height -
-			2 * h_offset);
-#endif
-	dz_config->zoom_region.resolution.width =
-			dz_config->zoom_region.resolution.width
-			* eff_res.width
-#ifndef ISP2401
-			/ asd->sensor_array_res.width;
-#else
-			/ (asd->sensor_array_res.width -
-			2 * w_offset);
-#endif
-	dz_config->zoom_region.resolution.height =
-			dz_config->zoom_region.resolution.height
-			* eff_res.height
-#ifndef ISP2401
-			/ asd->sensor_array_res.height;
-#else
-			/ (asd->sensor_array_res.height -
-			2 * h_offset);
-#endif
-
-	/*
-	  * Set same ratio of crop region resolution and current pipe output
-	  * resolution
-	  */
-#ifndef ISP2401
-	out_res.width =
-		stream_env->pipe_configs[css_pipe_id].output_info[0].res.width;
-	out_res.height =
-		stream_env->pipe_configs[css_pipe_id].output_info[0].res.height;
-	if (out_res.width == 0 || out_res.height == 0) {
-		dev_err(asd->isp->dev, "%s err current pipe output resolution"
-				, __func__);
-		return -EINVAL;
-	}
-
-#endif
-	if (out_res.width * dz_config->zoom_region.resolution.height
-		> dz_config->zoom_region.resolution.width * out_res.height) {
-		dz_config->zoom_region.resolution.height =
-				dz_config->zoom_region.resolution.width
-				* out_res.height / out_res.width;
-	} else {
-		dz_config->zoom_region.resolution.width =
-				dz_config->zoom_region.resolution.height
-				* out_res.width / out_res.height;
-	}
-	dev_dbg(asd->isp->dev, "%s crop region:(%d,%d),(%d,%d) eff_res(%d, %d) array_size(%d,%d) out_res(%d, %d)\n",
-			__func__, dz_config->zoom_region.origin.x,
-			dz_config->zoom_region.origin.y,
-			dz_config->zoom_region.resolution.width,
-			dz_config->zoom_region.resolution.height,
-			eff_res.width, eff_res.height,
-			asd->sensor_array_res.width,
-			asd->sensor_array_res.height,
-			out_res.width, out_res.height);
-
-
-	if ((dz_config->zoom_region.origin.x +
-		dz_config->zoom_region.resolution.width
-		> eff_res.width) ||
-		(dz_config->zoom_region.origin.y +
-		dz_config->zoom_region.resolution.height
-		> eff_res.height))
-		return -EINVAL;
-
-	return 0;
-}
-
-
-/*
- * Function to check the zoom region whether is effective
- */
-static bool atomisp_check_zoom_region(
-			struct atomisp_sub_device *asd,
-			struct ia_css_dz_config *dz_config)
-{
-	struct atomisp_resolution  config;
-	bool flag = false;
-	unsigned int w , h;
-
-	memset(&config, 0, sizeof(struct atomisp_resolution));
-
-	if (dz_config->dx && dz_config->dy)
-		return true;
-
-	config.width = asd->sensor_array_res.width;
-	config.height = asd->sensor_array_res.height;
-	w = dz_config->zoom_region.origin.x +
-		dz_config->zoom_region.resolution.width;
-	h = dz_config->zoom_region.origin.y +
-		dz_config->zoom_region.resolution.height;
-
-	if ((w <= config.width) && (h <= config.height) && w > 0 && h > 0)
-		flag = true;
-	else
-		/* setting error zoom region */
-		dev_err(asd->isp->dev, "%s zoom region ERROR:dz_config:(%d,%d),(%d,%d)array_res(%d, %d)\n",
-			__func__, dz_config->zoom_region.origin.x,
-			dz_config->zoom_region.origin.y,
-			dz_config->zoom_region.resolution.width,
-			dz_config->zoom_region.resolution.height,
-			config.width, config.height);
-
-	return flag;
-}
-
-void atomisp_apply_css_parameters(
-				struct atomisp_sub_device *asd,
-				struct atomisp_css_params *css_param)
-{
-	if (css_param->update_flag.wb_config)
-		atomisp_css_set_wb_config(asd, &css_param->wb_config);
-
-	if (css_param->update_flag.ob_config)
-		atomisp_css_set_ob_config(asd, &css_param->ob_config);
-
-	if (css_param->update_flag.dp_config)
-		atomisp_css_set_dp_config(asd, &css_param->dp_config);
-
-	if (css_param->update_flag.nr_config)
-		atomisp_css_set_nr_config(asd, &css_param->nr_config);
-
-	if (css_param->update_flag.ee_config)
-		atomisp_css_set_ee_config(asd, &css_param->ee_config);
-
-	if (css_param->update_flag.tnr_config)
-		atomisp_css_set_tnr_config(asd, &css_param->tnr_config);
-
-	if (css_param->update_flag.a3a_config)
-		atomisp_css_set_3a_config(asd, &css_param->s3a_config);
-
-	if (css_param->update_flag.ctc_config)
-		atomisp_css_set_ctc_config(asd, &css_param->ctc_config);
-
-	if (css_param->update_flag.cnr_config)
-		atomisp_css_set_cnr_config(asd, &css_param->cnr_config);
-
-	if (css_param->update_flag.ecd_config)
-		atomisp_css_set_ecd_config(asd, &css_param->ecd_config);
-
-	if (css_param->update_flag.ynr_config)
-		atomisp_css_set_ynr_config(asd, &css_param->ynr_config);
-
-	if (css_param->update_flag.fc_config)
-		atomisp_css_set_fc_config(asd, &css_param->fc_config);
-
-	if (css_param->update_flag.macc_config)
-		atomisp_css_set_macc_config(asd, &css_param->macc_config);
-
-	if (css_param->update_flag.aa_config)
-		atomisp_css_set_aa_config(asd, &css_param->aa_config);
-
-	if (css_param->update_flag.anr_config)
-		atomisp_css_set_anr_config(asd, &css_param->anr_config);
-
-	if (css_param->update_flag.xnr_config)
-		atomisp_css_set_xnr_config(asd, &css_param->xnr_config);
-
-	if (css_param->update_flag.yuv2rgb_cc_config)
-		atomisp_css_set_yuv2rgb_cc_config(asd,
-					&css_param->yuv2rgb_cc_config);
-
-	if (css_param->update_flag.rgb2yuv_cc_config)
-		atomisp_css_set_rgb2yuv_cc_config(asd,
-					&css_param->rgb2yuv_cc_config);
-
-	if (css_param->update_flag.macc_table)
-		atomisp_css_set_macc_table(asd, &css_param->macc_table);
-
-	if (css_param->update_flag.xnr_table)
-		atomisp_css_set_xnr_table(asd, &css_param->xnr_table);
-
-	if (css_param->update_flag.r_gamma_table)
-		atomisp_css_set_r_gamma_table(asd, &css_param->r_gamma_table);
-
-	if (css_param->update_flag.g_gamma_table)
-		atomisp_css_set_g_gamma_table(asd, &css_param->g_gamma_table);
-
-	if (css_param->update_flag.b_gamma_table)
-		atomisp_css_set_b_gamma_table(asd, &css_param->b_gamma_table);
-
-	if (css_param->update_flag.anr_thres)
-		atomisp_css_set_anr_thres(asd, &css_param->anr_thres);
-
-	if (css_param->update_flag.shading_table)
-		atomisp_css_set_shading_table(asd, css_param->shading_table);
-
-	if (css_param->update_flag.morph_table && asd->params.gdc_cac_en)
-		atomisp_css_set_morph_table(asd, css_param->morph_table);
-
-	if (css_param->update_flag.dvs2_coefs) {
-		struct atomisp_css_dvs_grid_info *dvs_grid_info =
-			atomisp_css_get_dvs_grid_info(
-				&asd->params.curr_grid_info);
-
-		if (dvs_grid_info && dvs_grid_info->enable)
-			atomisp_css_set_dvs2_coefs(asd, css_param->dvs2_coeff);
-	}
-
-	if (css_param->update_flag.dvs_6axis_config)
-		atomisp_css_set_dvs_6axis(asd, css_param->dvs_6axis);
-
-	atomisp_css_set_isp_config_id(asd, css_param->isp_config_id);
-	/*
-	 * These configurations are on used by ISP1.x, not for ISP2.x,
-	 * so do not handle them. see comments of ia_css_isp_config.
-	 * 1 cc_config
-	 * 2 ce_config
-	 * 3 de_config
-	 * 4 gc_config
-	 * 5 gamma_table
-	 * 6 ctc_table
-	 * 7 dvs_coefs
-	 */
-}
-
-static unsigned int long copy_from_compatible(void *to, const void *from,
-					      unsigned long n, bool from_user)
-{
-	if (from_user)
-		return copy_from_user(to, (void __user *)from, n);
-	else
-		memcpy(to, from, n);
-	return 0;
-}
-
-int atomisp_cp_general_isp_parameters(struct atomisp_sub_device *asd,
-				      struct atomisp_parameters *arg,
-				      struct atomisp_css_params *css_param,
-				      bool from_user)
-{
-	struct atomisp_parameters *cur_config = &css_param->update_flag;
-
-	if (!arg || !asd || !css_param)
-		return -EINVAL;
-
-	if (arg->wb_config && (from_user || !cur_config->wb_config)) {
-		if (copy_from_compatible(&css_param->wb_config, arg->wb_config,
-				sizeof(struct atomisp_css_wb_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.wb_config =
-			(struct atomisp_wb_config *) &css_param->wb_config;
-	}
-
-	if (arg->ob_config && (from_user || !cur_config->ob_config)) {
-		if (copy_from_compatible(&css_param->ob_config, arg->ob_config,
-				sizeof(struct atomisp_css_ob_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.ob_config =
-			(struct atomisp_ob_config *) &css_param->ob_config;
-	}
-
-	if (arg->dp_config && (from_user || !cur_config->dp_config)) {
-		if (copy_from_compatible(&css_param->dp_config, arg->dp_config,
-				sizeof(struct atomisp_css_dp_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.dp_config =
-			(struct atomisp_dp_config *) &css_param->dp_config;
-	}
-
-	if (asd->run_mode->val != ATOMISP_RUN_MODE_VIDEO) {
-		if (arg->dz_config && (from_user || !cur_config->dz_config)) {
-			if (copy_from_compatible(&css_param->dz_config,
-				arg->dz_config,
-				sizeof(struct atomisp_css_dz_config),
-				from_user))
-				return -EFAULT;
-			if (!atomisp_check_zoom_region(asd,
-						&css_param->dz_config)) {
-				dev_err(asd->isp->dev, "crop region error!");
-				return -EINVAL;
-			}
-			css_param->update_flag.dz_config =
-				(struct atomisp_dz_config *)
-				&css_param->dz_config;
-		}
-	}
-
-	if (arg->nr_config && (from_user || !cur_config->nr_config)) {
-		if (copy_from_compatible(&css_param->nr_config, arg->nr_config,
-				sizeof(struct atomisp_css_nr_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.nr_config =
-			(struct atomisp_nr_config *) &css_param->nr_config;
-	}
-
-	if (arg->ee_config && (from_user || !cur_config->ee_config)) {
-		if (copy_from_compatible(&css_param->ee_config, arg->ee_config,
-				sizeof(struct atomisp_css_ee_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.ee_config =
-			(struct atomisp_ee_config *) &css_param->ee_config;
-	}
-
-	if (arg->tnr_config && (from_user || !cur_config->tnr_config)) {
-		if (copy_from_compatible(&css_param->tnr_config,
-				arg->tnr_config,
-				sizeof(struct atomisp_css_tnr_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.tnr_config =
-			(struct atomisp_tnr_config *)
-			&css_param->tnr_config;
-	}
-
-	if (arg->a3a_config && (from_user || !cur_config->a3a_config)) {
-		if (copy_from_compatible(&css_param->s3a_config,
-				arg->a3a_config,
-				sizeof(struct atomisp_css_3a_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.a3a_config =
-			(struct atomisp_3a_config *) &css_param->s3a_config;
-	}
-
-	if (arg->ctc_config && (from_user || !cur_config->ctc_config)) {
-		if (copy_from_compatible(&css_param->ctc_config,
-				arg->ctc_config,
-				sizeof(struct atomisp_css_ctc_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.ctc_config =
-			(struct atomisp_ctc_config *)
-			&css_param->ctc_config;
-	}
-
-	if (arg->cnr_config && (from_user || !cur_config->cnr_config)) {
-		if (copy_from_compatible(&css_param->cnr_config,
-				arg->cnr_config,
-				sizeof(struct atomisp_css_cnr_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.cnr_config =
-			(struct atomisp_cnr_config *)
-			&css_param->cnr_config;
-	}
-
-	if (arg->ecd_config && (from_user || !cur_config->ecd_config)) {
-		if (copy_from_compatible(&css_param->ecd_config,
-				arg->ecd_config,
-				sizeof(struct atomisp_css_ecd_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.ecd_config =
-			(struct atomisp_ecd_config *)
-			&css_param->ecd_config;
-	}
-
-	if (arg->ynr_config && (from_user || !cur_config->ynr_config)) {
-		if (copy_from_compatible(&css_param->ynr_config,
-				arg->ynr_config,
-				sizeof(struct atomisp_css_ynr_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.ynr_config =
-			(struct atomisp_ynr_config *)
-			&css_param->ynr_config;
-	}
-
-	if (arg->fc_config && (from_user || !cur_config->fc_config)) {
-		if (copy_from_compatible(&css_param->fc_config,
-				arg->fc_config,
-				sizeof(struct atomisp_css_fc_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.fc_config =
-			(struct atomisp_fc_config *) &css_param->fc_config;
-	}
-
-	if (arg->macc_config && (from_user || !cur_config->macc_config)) {
-		if (copy_from_compatible(&css_param->macc_config,
-				arg->macc_config,
-				sizeof(struct atomisp_css_macc_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.macc_config =
-			(struct atomisp_macc_config *)
-			&css_param->macc_config;
-	}
-
-	if (arg->aa_config && (from_user || !cur_config->aa_config)) {
-		if (copy_from_compatible(&css_param->aa_config, arg->aa_config,
-				sizeof(struct atomisp_css_aa_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.aa_config =
-			(struct atomisp_aa_config *) &css_param->aa_config;
-	}
-
-	if (arg->anr_config && (from_user || !cur_config->anr_config)) {
-		if (copy_from_compatible(&css_param->anr_config,
-				arg->anr_config,
-				sizeof(struct atomisp_css_anr_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.anr_config =
-			(struct atomisp_anr_config *)
-			&css_param->anr_config;
-	}
-
-	if (arg->xnr_config && (from_user || !cur_config->xnr_config)) {
-		if (copy_from_compatible(&css_param->xnr_config,
-				arg->xnr_config,
-				sizeof(struct atomisp_css_xnr_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.xnr_config =
-			(struct atomisp_xnr_config *)
-			&css_param->xnr_config;
-	}
-
-	if (arg->yuv2rgb_cc_config &&
-	   (from_user || !cur_config->yuv2rgb_cc_config)) {
-		if (copy_from_compatible(&css_param->yuv2rgb_cc_config,
-				arg->yuv2rgb_cc_config,
-				sizeof(struct atomisp_css_cc_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.yuv2rgb_cc_config =
-			(struct atomisp_cc_config *)
-			&css_param->yuv2rgb_cc_config;
-	}
-
-	if (arg->rgb2yuv_cc_config &&
-	   (from_user || !cur_config->rgb2yuv_cc_config)) {
-		if (copy_from_compatible(&css_param->rgb2yuv_cc_config,
-				arg->rgb2yuv_cc_config,
-				sizeof(struct atomisp_css_cc_config),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.rgb2yuv_cc_config =
-			(struct atomisp_cc_config *)
-			&css_param->rgb2yuv_cc_config;
-	}
-
-	if (arg->macc_table && (from_user || !cur_config->macc_table)) {
-		if (copy_from_compatible(&css_param->macc_table,
-				arg->macc_table,
-				sizeof(struct atomisp_css_macc_table),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.macc_table =
-			(struct atomisp_macc_table *)
-			&css_param->macc_table;
-	}
-
-	if (arg->xnr_table && (from_user || !cur_config->xnr_table)) {
-		if (copy_from_compatible(&css_param->xnr_table,
-				arg->xnr_table,
-				sizeof(struct atomisp_css_xnr_table),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.xnr_table =
-			(struct atomisp_xnr_table *) &css_param->xnr_table;
-	}
-
-	if (arg->r_gamma_table && (from_user || !cur_config->r_gamma_table)) {
-		if (copy_from_compatible(&css_param->r_gamma_table,
-				arg->r_gamma_table,
-				sizeof(struct atomisp_css_rgb_gamma_table),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.r_gamma_table =
-			(struct atomisp_rgb_gamma_table *)
-			&css_param->r_gamma_table;
-	}
-
-	if (arg->g_gamma_table && (from_user || !cur_config->g_gamma_table)) {
-		if (copy_from_compatible(&css_param->g_gamma_table,
-				arg->g_gamma_table,
-				sizeof(struct atomisp_css_rgb_gamma_table),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.g_gamma_table =
-			(struct atomisp_rgb_gamma_table *)
-			&css_param->g_gamma_table;
-	}
-
-	if (arg->b_gamma_table && (from_user || !cur_config->b_gamma_table)) {
-		if (copy_from_compatible(&css_param->b_gamma_table,
-				arg->b_gamma_table,
-				sizeof(struct atomisp_css_rgb_gamma_table),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.b_gamma_table =
-			(struct atomisp_rgb_gamma_table *)
-			&css_param->b_gamma_table;
-	}
-
-	if (arg->anr_thres && (from_user || !cur_config->anr_thres)) {
-		if (copy_from_compatible(&css_param->anr_thres, arg->anr_thres,
-				sizeof(struct atomisp_css_anr_thres),
-				from_user))
-			return -EFAULT;
-		css_param->update_flag.anr_thres =
-			(struct atomisp_anr_thres *) &css_param->anr_thres;
-	}
-
-	if (from_user)
-		css_param->isp_config_id = arg->isp_config_id;
-	/*
-	 * These configurations are on used by ISP1.x, not for ISP2.x,
-	 * so do not handle them. see comments of ia_css_isp_config.
-	 * 1 cc_config
-	 * 2 ce_config
-	 * 3 de_config
-	 * 4 gc_config
-	 * 5 gamma_table
-	 * 6 ctc_table
-	 * 7 dvs_coefs
-	 */
-	return 0;
-}
-
-int atomisp_cp_lsc_table(struct atomisp_sub_device *asd,
-			 struct atomisp_shading_table *source_st,
-			 struct atomisp_css_params *css_param,
-			 bool from_user)
-{
-	unsigned int i;
-	unsigned int len_table;
-	struct atomisp_css_shading_table *shading_table;
-	struct atomisp_css_shading_table *old_table;
-#ifdef ISP2401
-	struct atomisp_shading_table st;
-#endif
-
-	if (!source_st)
-		return 0;
-
-	if (!css_param)
-		return -EINVAL;
-
-	if (!from_user && css_param->update_flag.shading_table)
-		return 0;
-
-#ifdef ISP2401
-	if (copy_from_compatible(&st, source_st,
-				 sizeof(struct atomisp_shading_table),
-				 from_user)) {
-		dev_err(asd->isp->dev, "copy shading table failed!");
-		return -EFAULT;
-	}
-
-#endif
-	old_table = css_param->shading_table;
-
-#ifdef ISP2401
-
-#endif
-	/* user config is to disable the shading table. */
-#ifndef ISP2401
-	if (!source_st->enable) {
-#else
-	if (!st.enable) {
-#endif
-		/* Generate a minimum table with enable = 0. */
-		shading_table = atomisp_css_shading_table_alloc(1, 1);
-		if (!shading_table)
-			return -ENOMEM;
-		shading_table->enable = 0;
-		goto set_lsc;
-	}
-
-	/* Setting a new table. Validate first - all tables must be set */
-	for (i = 0; i < ATOMISP_NUM_SC_COLORS; i++) {
-#ifndef ISP2401
-		if (!source_st->data[i])
-#else
-		if (!st.data[i]) {
-			dev_err(asd->isp->dev, "shading table validate failed");
-#endif
-			return -EINVAL;
-#ifdef ISP2401
-		}
-#endif
-	}
-
-	/* Shading table size per color */
-#ifndef ISP2401
-	if (source_st->width > SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR ||
-		source_st->height > SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR)
-#else
-	if (st.width > SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR ||
-	    st.height > SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR) {
-		dev_err(asd->isp->dev, "shading table w/h validate failed!");
-#endif
-		return -EINVAL;
-#ifdef ISP2401
-	}
-#endif
-
-#ifndef ISP2401
-	shading_table = atomisp_css_shading_table_alloc(source_st->width,
-							source_st->height);
-	if (!shading_table)
-			return -ENOMEM;
-#else
-	shading_table = atomisp_css_shading_table_alloc(st.width,
-							st.height);
-	if (!shading_table) {
-		dev_err(asd->isp->dev, "shading table alloc failed!");
-		return -ENOMEM;
-	}
-#endif
-
-#ifndef ISP2401
-	len_table = source_st->width * source_st->height * ATOMISP_SC_TYPE_SIZE;
-#else
-	len_table = st.width * st.height * ATOMISP_SC_TYPE_SIZE;
-#endif
-	for (i = 0; i < ATOMISP_NUM_SC_COLORS; i++) {
-		if (copy_from_compatible(shading_table->data[i],
-#ifndef ISP2401
-			source_st->data[i], len_table, from_user)) {
-#else
-			st.data[i], len_table, from_user)) {
-#endif
-			atomisp_css_shading_table_free(shading_table);
-			return -EFAULT;
-		}
-
-	}
-#ifndef ISP2401
-	shading_table->sensor_width = source_st->sensor_width;
-	shading_table->sensor_height = source_st->sensor_height;
-	shading_table->fraction_bits = source_st->fraction_bits;
-	shading_table->enable = source_st->enable;
-#else
-	shading_table->sensor_width = st.sensor_width;
-	shading_table->sensor_height = st.sensor_height;
-	shading_table->fraction_bits = st.fraction_bits;
-	shading_table->enable = st.enable;
-#endif
-
-	/* No need to update shading table if it is the same */
-	if (old_table != NULL &&
-		old_table->sensor_width == shading_table->sensor_width &&
-		old_table->sensor_height == shading_table->sensor_height &&
-		old_table->width == shading_table->width &&
-		old_table->height == shading_table->height &&
-		old_table->fraction_bits == shading_table->fraction_bits &&
-		old_table->enable == shading_table->enable) {
-		bool data_is_same = true;
-
-		for (i = 0; i < ATOMISP_NUM_SC_COLORS; i++) {
-			if (memcmp(shading_table->data[i], old_table->data[i],
-				   len_table) != 0) {
-				data_is_same = false;
-				break;
-			}
-		}
-
-		if (data_is_same) {
-			atomisp_css_shading_table_free(shading_table);
-			return 0;
-		}
-	}
-
-set_lsc:
-	/* set LSC to CSS */
-	css_param->shading_table = shading_table;
-	css_param->update_flag.shading_table =
-		(struct atomisp_shading_table *) shading_table;
-	asd->params.sc_en = shading_table != NULL;
-
-	if (old_table)
-		atomisp_css_shading_table_free(old_table);
-
-	return 0;
-}
-
-int atomisp_css_cp_dvs2_coefs(struct atomisp_sub_device *asd,
-			      struct ia_css_dvs2_coefficients *coefs,
-			      struct atomisp_css_params *css_param,
-			      bool from_user)
-{
-	struct atomisp_css_dvs_grid_info *cur =
-		atomisp_css_get_dvs_grid_info(&asd->params.curr_grid_info);
-	int dvs_hor_coef_bytes, dvs_ver_coef_bytes;
-#ifdef ISP2401
-	struct ia_css_dvs2_coefficients dvs2_coefs;
-#endif
-
-	if (!coefs || !cur)
-		return 0;
-
-	if (!from_user && css_param->update_flag.dvs2_coefs)
-		return 0;
-
-#ifndef ISP2401
-	if (sizeof(*cur) != sizeof(coefs->grid) ||
-	    memcmp(&coefs->grid, cur, sizeof(coefs->grid))) {
-#else
-	if (copy_from_compatible(&dvs2_coefs, coefs,
-				 sizeof(struct ia_css_dvs2_coefficients),
-				 from_user)) {
-		dev_err(asd->isp->dev, "copy dvs2 coef failed");
-		return -EFAULT;
-	}
-
-	if (sizeof(*cur) != sizeof(dvs2_coefs.grid) ||
-	    memcmp(&dvs2_coefs.grid, cur, sizeof(dvs2_coefs.grid))) {
-#endif
-		dev_err(asd->isp->dev, "dvs grid mis-match!\n");
-		/* If the grid info in the argument differs from the current
-		   grid info, we tell the caller to reset the grid size and
-		   try again. */
-		return -EAGAIN;
-	}
-
-#ifndef ISP2401
-	if (coefs->hor_coefs.odd_real == NULL ||
-	    coefs->hor_coefs.odd_imag == NULL ||
-	    coefs->hor_coefs.even_real == NULL ||
-	    coefs->hor_coefs.even_imag == NULL ||
-	    coefs->ver_coefs.odd_real == NULL ||
-	    coefs->ver_coefs.odd_imag == NULL ||
-	    coefs->ver_coefs.even_real == NULL ||
-	    coefs->ver_coefs.even_imag == NULL)
-#else
-	if (dvs2_coefs.hor_coefs.odd_real == NULL ||
-	    dvs2_coefs.hor_coefs.odd_imag == NULL ||
-	    dvs2_coefs.hor_coefs.even_real == NULL ||
-	    dvs2_coefs.hor_coefs.even_imag == NULL ||
-	    dvs2_coefs.ver_coefs.odd_real == NULL ||
-	    dvs2_coefs.ver_coefs.odd_imag == NULL ||
-	    dvs2_coefs.ver_coefs.even_real == NULL ||
-	    dvs2_coefs.ver_coefs.even_imag == NULL)
-#endif
-		return -EINVAL;
-
-	if (!css_param->dvs2_coeff) {
-		/* DIS coefficients. */
-		css_param->dvs2_coeff = ia_css_dvs2_coefficients_allocate(cur);
-		if (!css_param->dvs2_coeff)
-			return -ENOMEM;
-	}
-
-	dvs_hor_coef_bytes = asd->params.dvs_hor_coef_bytes;
-	dvs_ver_coef_bytes = asd->params.dvs_ver_coef_bytes;
-	if (copy_from_compatible(css_param->dvs2_coeff->hor_coefs.odd_real,
-#ifndef ISP2401
-	    coefs->hor_coefs.odd_real, dvs_hor_coef_bytes, from_user) ||
-#else
-	    dvs2_coefs.hor_coefs.odd_real, dvs_hor_coef_bytes, from_user) ||
-#endif
-	    copy_from_compatible(css_param->dvs2_coeff->hor_coefs.odd_imag,
-#ifndef ISP2401
-	    coefs->hor_coefs.odd_imag, dvs_hor_coef_bytes, from_user) ||
-#else
-	    dvs2_coefs.hor_coefs.odd_imag, dvs_hor_coef_bytes, from_user) ||
-#endif
-	    copy_from_compatible(css_param->dvs2_coeff->hor_coefs.even_real,
-#ifndef ISP2401
-	    coefs->hor_coefs.even_real, dvs_hor_coef_bytes, from_user) ||
-#else
-	    dvs2_coefs.hor_coefs.even_real, dvs_hor_coef_bytes, from_user) ||
-#endif
-	    copy_from_compatible(css_param->dvs2_coeff->hor_coefs.even_imag,
-#ifndef ISP2401
-	    coefs->hor_coefs.even_imag, dvs_hor_coef_bytes, from_user) ||
-#else
-	    dvs2_coefs.hor_coefs.even_imag, dvs_hor_coef_bytes, from_user) ||
-#endif
-	    copy_from_compatible(css_param->dvs2_coeff->ver_coefs.odd_real,
-#ifndef ISP2401
-	    coefs->ver_coefs.odd_real, dvs_ver_coef_bytes, from_user) ||
-#else
-	    dvs2_coefs.ver_coefs.odd_real, dvs_ver_coef_bytes, from_user) ||
-#endif
-	    copy_from_compatible(css_param->dvs2_coeff->ver_coefs.odd_imag,
-#ifndef ISP2401
-	    coefs->ver_coefs.odd_imag, dvs_ver_coef_bytes, from_user) ||
-#else
-	    dvs2_coefs.ver_coefs.odd_imag, dvs_ver_coef_bytes, from_user) ||
-#endif
-	    copy_from_compatible(css_param->dvs2_coeff->ver_coefs.even_real,
-#ifndef ISP2401
-	    coefs->ver_coefs.even_real, dvs_ver_coef_bytes, from_user) ||
-#else
-	    dvs2_coefs.ver_coefs.even_real, dvs_ver_coef_bytes, from_user) ||
-#endif
-	    copy_from_compatible(css_param->dvs2_coeff->ver_coefs.even_imag,
-#ifndef ISP2401
-	    coefs->ver_coefs.even_imag, dvs_ver_coef_bytes, from_user)) {
-#else
-	    dvs2_coefs.ver_coefs.even_imag, dvs_ver_coef_bytes, from_user)) {
-#endif
-		ia_css_dvs2_coefficients_free(css_param->dvs2_coeff);
-		css_param->dvs2_coeff = NULL;
-		return -EFAULT;
-	}
-
-	css_param->update_flag.dvs2_coefs =
-	    (struct atomisp_dvs2_coefficients *)css_param->dvs2_coeff;
-	return 0;
-}
-
-int atomisp_cp_dvs_6axis_config(struct atomisp_sub_device *asd,
-			struct atomisp_dvs_6axis_config *source_6axis_config,
-			struct atomisp_css_params *css_param,
-			bool from_user)
-{
-	struct atomisp_css_dvs_6axis_config *dvs_6axis_config;
-	struct atomisp_css_dvs_6axis_config *old_6axis_config;
-#ifdef ISP2401
-	struct atomisp_css_dvs_6axis_config t_6axis_config;
-#endif
-	struct ia_css_stream *stream =
-			asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream;
-	struct atomisp_css_dvs_grid_info *dvs_grid_info =
-		atomisp_css_get_dvs_grid_info(&asd->params.curr_grid_info);
-	int ret = -EFAULT;
-
-	if (stream == NULL) {
-		dev_err(asd->isp->dev, "%s: internal error!", __func__);
-		return -EINVAL;
-	}
-
-	if (!source_6axis_config || !dvs_grid_info)
-		return 0;
-
-	if (!dvs_grid_info->enable)
-		return 0;
-
-	if (!from_user && css_param->update_flag.dvs_6axis_config)
-		return 0;
-
-	/* check whether need to reallocate for 6 axis config */
-	old_6axis_config = css_param->dvs_6axis;
-	dvs_6axis_config = old_6axis_config;
-#ifdef ISP2401
-
-	if (copy_from_compatible(&t_6axis_config, source_6axis_config,
-			   sizeof(struct atomisp_dvs_6axis_config),
-			   from_user)) {
-		dev_err(asd->isp->dev, "copy morph table failed!");
-		return -EFAULT;
-	}
-
-#endif
-	if (old_6axis_config &&
-#ifndef ISP2401
-	    (old_6axis_config->width_y != source_6axis_config->width_y ||
-	     old_6axis_config->height_y != source_6axis_config->height_y ||
-	     old_6axis_config->width_uv != source_6axis_config->width_uv ||
-	     old_6axis_config->height_uv != source_6axis_config->height_uv)) {
-#else
-	    (old_6axis_config->width_y != t_6axis_config.width_y ||
-	     old_6axis_config->height_y != t_6axis_config.height_y ||
-	     old_6axis_config->width_uv != t_6axis_config.width_uv ||
-	     old_6axis_config->height_uv != t_6axis_config.height_uv)) {
-#endif
-		ia_css_dvs2_6axis_config_free(css_param->dvs_6axis);
-		css_param->dvs_6axis = NULL;
-
-		dvs_6axis_config = ia_css_dvs2_6axis_config_allocate(stream);
-		if (!dvs_6axis_config)
-			return -ENOMEM;
-	} else if (!dvs_6axis_config) {
-		dvs_6axis_config = ia_css_dvs2_6axis_config_allocate(stream);
-		if (!dvs_6axis_config)
-			return -ENOMEM;
-	}
-
-#ifndef ISP2401
-	dvs_6axis_config->exp_id = source_6axis_config->exp_id;
-#else
-	dvs_6axis_config->exp_id = t_6axis_config.exp_id;
-#endif
-
-	if (copy_from_compatible(dvs_6axis_config->xcoords_y,
-#ifndef ISP2401
-			   source_6axis_config->xcoords_y,
-			   source_6axis_config->width_y *
-			   source_6axis_config->height_y *
-			   sizeof(*source_6axis_config->xcoords_y),
-#else
-			   t_6axis_config.xcoords_y,
-			   t_6axis_config.width_y *
-			   t_6axis_config.height_y *
-			   sizeof(*dvs_6axis_config->xcoords_y),
-#endif
-			   from_user))
-		goto error;
-	if (copy_from_compatible(dvs_6axis_config->ycoords_y,
-#ifndef ISP2401
-			   source_6axis_config->ycoords_y,
-			   source_6axis_config->width_y *
-			   source_6axis_config->height_y *
-			   sizeof(*source_6axis_config->ycoords_y),
-#else
-			   t_6axis_config.ycoords_y,
-			   t_6axis_config.width_y *
-			   t_6axis_config.height_y *
-			   sizeof(*dvs_6axis_config->ycoords_y),
-#endif
-			   from_user))
-		goto error;
-	if (copy_from_compatible(dvs_6axis_config->xcoords_uv,
-#ifndef ISP2401
-			   source_6axis_config->xcoords_uv,
-			   source_6axis_config->width_uv *
-			   source_6axis_config->height_uv *
-			   sizeof(*source_6axis_config->xcoords_uv),
-#else
-			   t_6axis_config.xcoords_uv,
-			   t_6axis_config.width_uv *
-			   t_6axis_config.height_uv *
-			   sizeof(*dvs_6axis_config->xcoords_uv),
-#endif
-			   from_user))
-		goto error;
-	if (copy_from_compatible(dvs_6axis_config->ycoords_uv,
-#ifndef ISP2401
-			   source_6axis_config->ycoords_uv,
-			   source_6axis_config->width_uv *
-			   source_6axis_config->height_uv *
-			   sizeof(*source_6axis_config->ycoords_uv),
-#else
-			   t_6axis_config.ycoords_uv,
-			   t_6axis_config.width_uv *
-			   t_6axis_config.height_uv *
-			   sizeof(*dvs_6axis_config->ycoords_uv),
-#endif
-			   from_user))
-		goto error;
-
-	css_param->dvs_6axis = dvs_6axis_config;
-	css_param->update_flag.dvs_6axis_config =
-		(struct atomisp_dvs_6axis_config *) dvs_6axis_config;
-	return 0;
-
-error:
-	if (dvs_6axis_config)
-		ia_css_dvs2_6axis_config_free(dvs_6axis_config);
-	return ret;
-}
-
-int atomisp_cp_morph_table(struct atomisp_sub_device *asd,
-				struct atomisp_morph_table *source_morph_table,
-				struct atomisp_css_params *css_param,
-				bool from_user)
-{
-	int ret = -EFAULT;
-	unsigned int i;
-	struct atomisp_css_morph_table *morph_table;
-#ifdef ISP2401
-	struct atomisp_css_morph_table mtbl;
-#endif
-	struct atomisp_css_morph_table *old_morph_table;
-
-	if (!source_morph_table)
-		return 0;
-
-	if (!from_user && css_param->update_flag.morph_table)
-		return 0;
-
-	old_morph_table = css_param->morph_table;
-
-#ifdef ISP2401
-	if (copy_from_compatible(&mtbl, source_morph_table,
-				 sizeof(struct atomisp_morph_table),
-				 from_user)) {
-		dev_err(asd->isp->dev, "copy morph table failed!");
-		return -EFAULT;
-	}
-
-#endif
-	morph_table = atomisp_css_morph_table_allocate(
-#ifndef ISP2401
-		source_morph_table->width,
-		source_morph_table->height);
-#else
-		mtbl.width,
-		mtbl.height);
-#endif
-	if (!morph_table)
-		return -ENOMEM;
-
-	for (i = 0; i < CSS_MORPH_TABLE_NUM_PLANES; i++) {
-		if (copy_from_compatible(morph_table->coordinates_x[i],
-			(__force void *)source_morph_table->coordinates_x[i],
-#ifndef ISP2401
-			source_morph_table->height * source_morph_table->width *
-			sizeof(*source_morph_table->coordinates_x[i]),
-#else
-			mtbl.height * mtbl.width *
-			sizeof(*morph_table->coordinates_x[i]),
-#endif
-			from_user))
-			goto error;
-
-		if (copy_from_compatible(morph_table->coordinates_y[i],
-			(__force void *)source_morph_table->coordinates_y[i],
-#ifndef ISP2401
-			source_morph_table->height * source_morph_table->width *
-			sizeof(*source_morph_table->coordinates_y[i]),
-#else
-			mtbl.height * mtbl.width *
-			sizeof(*morph_table->coordinates_y[i]),
-#endif
-			from_user))
-			goto error;
-	}
-
-	css_param->morph_table = morph_table;
-	if (old_morph_table)
-		atomisp_css_morph_table_free(old_morph_table);
-	css_param->update_flag.morph_table =
-		(struct atomisp_morph_table *) morph_table;
-	return 0;
-
-error:
-	if (morph_table)
-		atomisp_css_morph_table_free(morph_table);
-	return ret;
-}
-
-int atomisp_makeup_css_parameters(struct atomisp_sub_device *asd,
-				  struct atomisp_parameters *arg,
-				  struct atomisp_css_params *css_param)
-{
-	int ret;
-
-	ret = atomisp_cp_general_isp_parameters(asd, arg, css_param, false);
-	if (ret)
-		return ret;
-	ret = atomisp_cp_lsc_table(asd, arg->shading_table, css_param, false);
-	if (ret)
-		return ret;
-	ret = atomisp_cp_morph_table(asd, arg->morph_table, css_param, false);
-	if (ret)
-		return ret;
-	ret = atomisp_css_cp_dvs2_coefs(asd,
-		(struct ia_css_dvs2_coefficients *) arg->dvs2_coefs,
-		css_param, false);
-	if (ret)
-		return ret;
-	ret = atomisp_cp_dvs_6axis_config(asd, arg->dvs_6axis_config,
-					  css_param, false);
-	return ret;
-}
-
-void atomisp_free_css_parameters(struct atomisp_css_params *css_param)
-{
-	if (css_param->dvs_6axis) {
-		ia_css_dvs2_6axis_config_free(css_param->dvs_6axis);
-		css_param->dvs_6axis = NULL;
-	}
-	if (css_param->dvs2_coeff) {
-		ia_css_dvs2_coefficients_free(css_param->dvs2_coeff);
-		css_param->dvs2_coeff = NULL;
-	}
-	if (css_param->shading_table) {
-		ia_css_shading_table_free(css_param->shading_table);
-		css_param->shading_table = NULL;
-	}
-	if (css_param->morph_table) {
-		ia_css_morph_table_free(css_param->morph_table);
-		css_param->morph_table = NULL;
-	}
-}
-
-/*
- * Check parameter queue list and buffer queue list to find out if matched items
- * and then set parameter to CSS and enqueue buffer to CSS.
- * Of course, if the buffer in buffer waiting list is not bound to a per-frame
- * parameter, it will be enqueued into CSS as long as the per-frame setting
- * buffers before it get enqueued.
- */
-void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe)
-{
-	struct atomisp_sub_device *asd = pipe->asd;
-	struct videobuf_buffer *vb = NULL, *vb_tmp;
-	struct atomisp_css_params_with_list *param = NULL, *param_tmp;
-	struct videobuf_vmalloc_memory *vm_mem = NULL;
-	unsigned long irqflags;
-	bool need_to_enqueue_buffer = false;
-
-	if (atomisp_is_vf_pipe(pipe))
-		return;
-
-	/*
-	 * CSS/FW requires set parameter and enqueue buffer happen after ISP
-	 * is streamon.
-	 */
-	if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
-		return;
-
-	if (list_empty(&pipe->per_frame_params) ||
-	    list_empty(&pipe->buffers_waiting_for_param))
-		return;
-
-	list_for_each_entry_safe(vb, vb_tmp,
-			&pipe->buffers_waiting_for_param, queue) {
-		if (pipe->frame_request_config_id[vb->i]) {
-			list_for_each_entry_safe(param, param_tmp,
-				&pipe->per_frame_params, list) {
-				if (pipe->frame_request_config_id[vb->i] !=
-				    param->params.isp_config_id)
-					continue;
-
-				list_del(&param->list);
-				list_del(&vb->queue);
-				/*
-				 * clear the request config id as the buffer
-				 * will be handled and enqueued into CSS soon
-				 */
-				pipe->frame_request_config_id[vb->i] = 0;
-				pipe->frame_params[vb->i] = param;
-				vm_mem = vb->priv;
-				BUG_ON(!vm_mem);
-				break;
-			}
-
-			if (vm_mem) {
-				spin_lock_irqsave(&pipe->irq_lock, irqflags);
-				list_add_tail(&vb->queue, &pipe->activeq);
-				spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
-				vm_mem = NULL;
-				need_to_enqueue_buffer = true;
-			} else {
-				/* The is the end, stop further loop */
-				break;
-			}
-		} else {
-			list_del(&vb->queue);
-			pipe->frame_params[vb->i] = NULL;
-			spin_lock_irqsave(&pipe->irq_lock, irqflags);
-			list_add_tail(&vb->queue, &pipe->activeq);
-			spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
-			need_to_enqueue_buffer = true;
-		}
-	}
-
-	if (need_to_enqueue_buffer) {
-		atomisp_qbuffers_to_css(asd);
-#ifndef ISP2401
-		if (!atomisp_is_wdt_running(asd) && atomisp_buffers_queued(asd))
-			atomisp_wdt_start(asd);
-#else
-		if (atomisp_buffers_queued_pipe(pipe)) {
-			if (!atomisp_is_wdt_running(pipe))
-				atomisp_wdt_start(pipe);
-			else
-				atomisp_wdt_refresh_pipe(pipe,
-					ATOMISP_WDT_KEEP_CURRENT_DELAY);
-		}
-#endif
-	}
-}
-
-/*
-* Function to configure ISP parameters
-*/
-int atomisp_set_parameters(struct video_device *vdev,
-			struct atomisp_parameters *arg)
-{
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-	struct atomisp_sub_device *asd = pipe->asd;
-	struct atomisp_css_params_with_list *param = NULL;
-	struct atomisp_css_params *css_param = &asd->params.css_param;
-	int ret;
-
-	if (asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream == NULL) {
-		dev_err(asd->isp->dev, "%s: internal error!\n", __func__);
-		return -EINVAL;
-	}
-
-	dev_dbg(asd->isp->dev, "%s: set parameter(per_frame_setting %d) for asd%d with isp_config_id %d of %s\n",
-		__func__, arg->per_frame_setting, asd->index,
-		arg->isp_config_id, vdev->name);
-#ifdef ISP2401
-
-	if (atomisp_is_vf_pipe(pipe) && arg->per_frame_setting) {
-		dev_err(asd->isp->dev, "%s: vf pipe not support per_frame_setting",
-			__func__);
-		return -EINVAL;
-	}
-
-#endif
-	if (arg->per_frame_setting && !atomisp_is_vf_pipe(pipe)) {
-		/*
-		 * Per-frame setting enabled, we allocate a new paramter
-		 * buffer to cache the parameters and only when frame buffers
-		 * are ready, the parameters will be set to CSS.
-		 * per-frame setting only works for the main output frame.
-		 */
-		param = kvzalloc(sizeof(*param), GFP_KERNEL);
-		if (!param) {
-			dev_err(asd->isp->dev, "%s: failed to alloc params buffer\n",
-				__func__);
-			return -ENOMEM;
-		}
-		css_param = &param->params;
-	}
-
-	ret = atomisp_cp_general_isp_parameters(asd, arg, css_param, true);
-	if (ret)
-		goto apply_parameter_failed;
-
-	ret = atomisp_cp_lsc_table(asd, arg->shading_table, css_param, true);
-	if (ret)
-		goto apply_parameter_failed;
-
-	ret = atomisp_cp_morph_table(asd, arg->morph_table, css_param, true);
-	if (ret)
-		goto apply_parameter_failed;
-
-	ret = atomisp_css_cp_dvs2_coefs(asd,
-		(struct ia_css_dvs2_coefficients *) arg->dvs2_coefs,
-		css_param, true);
-	if (ret)
-		goto apply_parameter_failed;
-
-	ret = atomisp_cp_dvs_6axis_config(asd, arg->dvs_6axis_config,
-					  css_param, true);
-	if (ret)
-		goto apply_parameter_failed;
-
-	if (!(arg->per_frame_setting && !atomisp_is_vf_pipe(pipe))) {
-		/* indicate to CSS that we have parameters to be updated */
-		asd->params.css_update_params_needed = true;
-	} else {
-		list_add_tail(&param->list, &pipe->per_frame_params);
-		atomisp_handle_parameter_and_buffer(pipe);
-	}
-
-	return 0;
-
-apply_parameter_failed:
-	if (css_param)
-		atomisp_free_css_parameters(css_param);
-	if (param)
-		kvfree(param);
-
-	return ret;
-}
-
-/*
- * Function to set/get isp parameters to isp
- */
-int atomisp_param(struct atomisp_sub_device *asd, int flag,
-		  struct atomisp_parm *config)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct ia_css_pipe_config *vp_cfg =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].
-		pipe_configs[IA_CSS_PIPE_ID_VIDEO];
-
-	/* Read parameter for 3A binary info */
-	if (flag == 0) {
-		struct atomisp_css_dvs_grid_info *dvs_grid_info =
-			atomisp_css_get_dvs_grid_info(
-				&asd->params.curr_grid_info);
-
-		if (&config->info == NULL) {
-			dev_err(isp->dev, "ERROR: NULL pointer in grid_info\n");
-			return -EINVAL;
-		}
-		atomisp_curr_user_grid_info(asd, &config->info);
-
-		/* We always return the resolution and stride even if there is
-		 * no valid metadata. This allows the caller to get the
-		 * information needed to allocate user-space buffers. */
-		config->metadata_config.metadata_height = asd->
-			stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream_info.
-			metadata_info.resolution.height;
-		config->metadata_config.metadata_stride = asd->
-			stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream_info.
-			metadata_info.stride;
-
-		/* update dvs grid info */
-		if (dvs_grid_info)
-			memcpy(&config->dvs_grid,
-				dvs_grid_info,
-				sizeof(struct atomisp_css_dvs_grid_info));
-
-		if (asd->run_mode->val != ATOMISP_RUN_MODE_VIDEO) {
-			config->dvs_envelop.width = 0;
-			config->dvs_envelop.height = 0;
-			return 0;
-		}
-
-		/* update dvs envelop info */
-		if (!asd->continuous_mode->val) {
-			config->dvs_envelop.width = vp_cfg->dvs_envelope.width;
-			config->dvs_envelop.height =
-					vp_cfg->dvs_envelope.height;
-		} else {
-			unsigned int dvs_w, dvs_h, dvs_w_max, dvs_h_max;
-
-			dvs_w = vp_cfg->bayer_ds_out_res.width -
-				vp_cfg->output_info[0].res.width;
-			dvs_h = vp_cfg->bayer_ds_out_res.height -
-				vp_cfg->output_info[0].res.height;
-			dvs_w_max = rounddown(
-					vp_cfg->output_info[0].res.width / 5,
-					ATOM_ISP_STEP_WIDTH);
-			dvs_h_max = rounddown(
-					vp_cfg->output_info[0].res.height / 5,
-					ATOM_ISP_STEP_HEIGHT);
-
-			config->dvs_envelop.width = min(dvs_w, dvs_w_max);
-			config->dvs_envelop.height = min(dvs_h, dvs_h_max);
-		}
-
-		return 0;
-	}
-
-	memcpy(&asd->params.css_param.wb_config, &config->wb_config,
-	       sizeof(struct atomisp_css_wb_config));
-	memcpy(&asd->params.css_param.ob_config, &config->ob_config,
-	       sizeof(struct atomisp_css_ob_config));
-	memcpy(&asd->params.css_param.dp_config, &config->dp_config,
-	       sizeof(struct atomisp_css_dp_config));
-	memcpy(&asd->params.css_param.de_config, &config->de_config,
-	       sizeof(struct atomisp_css_de_config));
-	memcpy(&asd->params.css_param.dz_config, &config->dz_config,
-	       sizeof(struct atomisp_css_dz_config));
-	memcpy(&asd->params.css_param.ce_config, &config->ce_config,
-	       sizeof(struct atomisp_css_ce_config));
-	memcpy(&asd->params.css_param.nr_config, &config->nr_config,
-	       sizeof(struct atomisp_css_nr_config));
-	memcpy(&asd->params.css_param.ee_config, &config->ee_config,
-	       sizeof(struct atomisp_css_ee_config));
-	memcpy(&asd->params.css_param.tnr_config, &config->tnr_config,
-	       sizeof(struct atomisp_css_tnr_config));
-
-	if (asd->params.color_effect == V4L2_COLORFX_NEGATIVE) {
-		asd->params.css_param.cc_config.matrix[3] = -config->cc_config.matrix[3];
-		asd->params.css_param.cc_config.matrix[4] = -config->cc_config.matrix[4];
-		asd->params.css_param.cc_config.matrix[5] = -config->cc_config.matrix[5];
-		asd->params.css_param.cc_config.matrix[6] = -config->cc_config.matrix[6];
-		asd->params.css_param.cc_config.matrix[7] = -config->cc_config.matrix[7];
-		asd->params.css_param.cc_config.matrix[8] = -config->cc_config.matrix[8];
-	}
-
-	if (asd->params.color_effect != V4L2_COLORFX_SEPIA &&
-	    asd->params.color_effect != V4L2_COLORFX_BW) {
-		memcpy(&asd->params.css_param.cc_config, &config->cc_config,
-		       sizeof(struct atomisp_css_cc_config));
-		atomisp_css_set_cc_config(asd, &asd->params.css_param.cc_config);
-	}
-
-	atomisp_css_set_wb_config(asd, &asd->params.css_param.wb_config);
-	atomisp_css_set_ob_config(asd, &asd->params.css_param.ob_config);
-	atomisp_css_set_de_config(asd, &asd->params.css_param.de_config);
-	atomisp_css_set_dz_config(asd, &asd->params.css_param.dz_config);
-	atomisp_css_set_ce_config(asd, &asd->params.css_param.ce_config);
-	atomisp_css_set_dp_config(asd, &asd->params.css_param.dp_config);
-	atomisp_css_set_nr_config(asd, &asd->params.css_param.nr_config);
-	atomisp_css_set_ee_config(asd, &asd->params.css_param.ee_config);
-	atomisp_css_set_tnr_config(asd, &asd->params.css_param.tnr_config);
-	asd->params.css_update_params_needed = true;
-
-	return 0;
-}
-
-/*
- * Function to configure color effect of the image
- */
-int atomisp_color_effect(struct atomisp_sub_device *asd, int flag,
-			 __s32 *effect)
-{
-	struct atomisp_css_cc_config *cc_config = NULL;
-	struct atomisp_css_macc_table *macc_table = NULL;
-	struct atomisp_css_ctc_table *ctc_table = NULL;
-	int ret = 0;
-	struct v4l2_control control;
-	struct atomisp_device *isp = asd->isp;
-
-	if (flag == 0) {
-		*effect = asd->params.color_effect;
-		return 0;
-	}
-
-
-	control.id = V4L2_CID_COLORFX;
-	control.value = *effect;
-	ret =
-	    v4l2_s_ctrl(NULL, isp->inputs[asd->input_curr].camera->ctrl_handler,
-			&control);
-	/*
-	 * if set color effect to sensor successfully, return
-	 * 0 directly.
-	 */
-	if (!ret) {
-		asd->params.color_effect = (u32)*effect;
-		return 0;
-	}
-
-	if (*effect == asd->params.color_effect)
-		return 0;
-
-	/*
-	 * isp_subdev->params.macc_en should be set to false.
-	 */
-	asd->params.macc_en = false;
-
-	switch (*effect) {
-	case V4L2_COLORFX_NONE:
-		macc_table = &asd->params.css_param.macc_table;
-		asd->params.macc_en = true;
-		break;
-	case V4L2_COLORFX_SEPIA:
-		cc_config = &sepia_cc_config;
-		break;
-	case V4L2_COLORFX_NEGATIVE:
-		cc_config = &nega_cc_config;
-		break;
-	case V4L2_COLORFX_BW:
-		cc_config = &mono_cc_config;
-		break;
-	case V4L2_COLORFX_SKY_BLUE:
-		macc_table = &blue_macc_table;
-		asd->params.macc_en = true;
-		break;
-	case V4L2_COLORFX_GRASS_GREEN:
-		macc_table = &green_macc_table;
-		asd->params.macc_en = true;
-		break;
-	case V4L2_COLORFX_SKIN_WHITEN_LOW:
-		macc_table = &skin_low_macc_table;
-		asd->params.macc_en = true;
-		break;
-	case V4L2_COLORFX_SKIN_WHITEN:
-		macc_table = &skin_medium_macc_table;
-		asd->params.macc_en = true;
-		break;
-	case V4L2_COLORFX_SKIN_WHITEN_HIGH:
-		macc_table = &skin_high_macc_table;
-		asd->params.macc_en = true;
-		break;
-	case V4L2_COLORFX_VIVID:
-		ctc_table = &vivid_ctc_table;
-		break;
-	default:
-		return -EINVAL;
-	}
-	atomisp_update_capture_mode(asd);
-
-	if (cc_config)
-		atomisp_css_set_cc_config(asd, cc_config);
-	if (macc_table)
-		atomisp_css_set_macc_table(asd, macc_table);
-	if (ctc_table)
-		atomisp_css_set_ctc_table(asd, ctc_table);
-	asd->params.color_effect = (u32)*effect;
-	asd->params.css_update_params_needed = true;
-	return 0;
-}
-
-/*
- * Function to configure bad pixel correction
- */
-int atomisp_bad_pixel(struct atomisp_sub_device *asd, int flag,
-		      __s32 *value)
-{
-
-	if (flag == 0) {
-		*value = asd->params.bad_pixel_en;
-		return 0;
-	}
-	asd->params.bad_pixel_en = !!*value;
-
-	return 0;
-}
-
-/*
- * Function to configure bad pixel correction params
- */
-int atomisp_bad_pixel_param(struct atomisp_sub_device *asd, int flag,
-			    struct atomisp_dp_config *config)
-{
-	if (flag == 0) {
-		/* Get bad pixel from current setup */
-		if (atomisp_css_get_dp_config(asd, config))
-			return -EINVAL;
-	} else {
-		/* Set bad pixel to isp parameters */
-		memcpy(&asd->params.css_param.dp_config, config,
-			sizeof(asd->params.css_param.dp_config));
-		atomisp_css_set_dp_config(asd, &asd->params.css_param.dp_config);
-		asd->params.css_update_params_needed = true;
-	}
-
-	return 0;
-}
-
-/*
- * Function to enable/disable video image stablization
- */
-int atomisp_video_stable(struct atomisp_sub_device *asd, int flag,
-			 __s32 *value)
-{
-	if (flag == 0)
-		*value = asd->params.video_dis_en;
-	else
-		asd->params.video_dis_en = !!*value;
-
-	return 0;
-}
-
-/*
- * Function to configure fixed pattern noise
- */
-int atomisp_fixed_pattern(struct atomisp_sub_device *asd, int flag,
-			  __s32 *value)
-{
-
-	if (flag == 0) {
-		*value = asd->params.fpn_en;
-		return 0;
-	}
-
-	if (*value == 0) {
-		asd->params.fpn_en = false;
-		return 0;
-	}
-
-	/* Add function to get black from from sensor with shutter off */
-	return 0;
-}
-
-static unsigned int
-atomisp_bytesperline_to_padded_width(unsigned int bytesperline,
-				     enum atomisp_css_frame_format format)
-{
-	switch (format) {
-	case CSS_FRAME_FORMAT_UYVY:
-	case CSS_FRAME_FORMAT_YUYV:
-	case CSS_FRAME_FORMAT_RAW:
-	case CSS_FRAME_FORMAT_RGB565:
-		return bytesperline/2;
-	case CSS_FRAME_FORMAT_RGBA888:
-		return bytesperline/4;
-	/* The following cases could be removed, but we leave them
-	   in to document the formats that are included. */
-	case CSS_FRAME_FORMAT_NV11:
-	case CSS_FRAME_FORMAT_NV12:
-	case CSS_FRAME_FORMAT_NV16:
-	case CSS_FRAME_FORMAT_NV21:
-	case CSS_FRAME_FORMAT_NV61:
-	case CSS_FRAME_FORMAT_YV12:
-	case CSS_FRAME_FORMAT_YV16:
-	case CSS_FRAME_FORMAT_YUV420:
-	case CSS_FRAME_FORMAT_YUV420_16:
-	case CSS_FRAME_FORMAT_YUV422:
-	case CSS_FRAME_FORMAT_YUV422_16:
-	case CSS_FRAME_FORMAT_YUV444:
-	case CSS_FRAME_FORMAT_YUV_LINE:
-	case CSS_FRAME_FORMAT_PLANAR_RGB888:
-	case CSS_FRAME_FORMAT_QPLANE6:
-	case CSS_FRAME_FORMAT_BINARY_8:
-	default:
-		return bytesperline;
-	}
-}
-
-static int
-atomisp_v4l2_framebuffer_to_css_frame(const struct v4l2_framebuffer *arg,
-					 struct atomisp_css_frame **result)
-{
-	struct atomisp_css_frame *res = NULL;
-	unsigned int padded_width;
-	enum atomisp_css_frame_format sh_format;
-	char *tmp_buf = NULL;
-	int ret = 0;
-
-	sh_format = v4l2_fmt_to_sh_fmt(arg->fmt.pixelformat);
-	padded_width = atomisp_bytesperline_to_padded_width(
-					arg->fmt.bytesperline, sh_format);
-
-	/* Note: the padded width on an atomisp_css_frame is in elements, not in
-	   bytes. The RAW frame we use here should always be a 16bit RAW
-	   frame. This is why we bytesperline/2 is equal to the padded with */
-	if (atomisp_css_frame_allocate(&res, arg->fmt.width, arg->fmt.height,
-				  sh_format, padded_width, 0)) {
-		ret = -ENOMEM;
-		goto err;
-	}
-
-	tmp_buf = vmalloc(arg->fmt.sizeimage);
-	if (!tmp_buf) {
-		ret = -ENOMEM;
-		goto err;
-	}
-	if (copy_from_user(tmp_buf, (void __user __force *)arg->base,
-			   arg->fmt.sizeimage)) {
-		ret = -EFAULT;
-		goto err;
-	}
-
-	if (hmm_store(res->data, tmp_buf, arg->fmt.sizeimage)) {
-		ret = -EINVAL;
-		goto err;
-	}
-
-err:
-	if (ret && res)
-		atomisp_css_frame_free(res);
-	if (tmp_buf)
-		vfree(tmp_buf);
-	if (ret == 0)
-		*result = res;
-	return ret;
-}
-
-/*
- * Function to configure fixed pattern noise table
- */
-int atomisp_fixed_pattern_table(struct atomisp_sub_device *asd,
-				struct v4l2_framebuffer *arg)
-{
-	struct atomisp_css_frame *raw_black_frame = NULL;
-	int ret;
-
-	if (arg == NULL)
-		return -EINVAL;
-
-	ret = atomisp_v4l2_framebuffer_to_css_frame(arg, &raw_black_frame);
-	if (ret)
-		return ret;
-	if (atomisp_css_set_black_frame(asd, raw_black_frame))
-		ret = -ENOMEM;
-
-	atomisp_css_frame_free(raw_black_frame);
-	return ret;
-}
-
-/*
- * Function to configure false color correction
- */
-int atomisp_false_color(struct atomisp_sub_device *asd, int flag,
-			__s32 *value)
-{
-	/* Get nr config from current setup */
-	if (flag == 0) {
-		*value = asd->params.false_color;
-		return 0;
-	}
-
-	/* Set nr config to isp parameters */
-	if (*value) {
-		atomisp_css_set_default_de_config(asd);
-	} else {
-		asd->params.css_param.de_config.pixelnoise = 0;
-		atomisp_css_set_de_config(asd, &asd->params.css_param.de_config);
-	}
-	asd->params.css_update_params_needed = true;
-	asd->params.false_color = *value;
-	return 0;
-}
-
-/*
- * Function to configure bad pixel correction params
- */
-int atomisp_false_color_param(struct atomisp_sub_device *asd, int flag,
-			      struct atomisp_de_config *config)
-{
-	if (flag == 0) {
-		/* Get false color from current setup */
-		if (atomisp_css_get_de_config(asd, config))
-			return -EINVAL;
-	} else {
-		/* Set false color to isp parameters */
-		memcpy(&asd->params.css_param.de_config, config,
-		       sizeof(asd->params.css_param.de_config));
-		atomisp_css_set_de_config(asd, &asd->params.css_param.de_config);
-		asd->params.css_update_params_needed = true;
-	}
-
-	return 0;
-}
-
-/*
- * Function to configure white balance params
- */
-int atomisp_white_balance_param(struct atomisp_sub_device *asd, int flag,
-	struct atomisp_wb_config *config)
-{
-	if (flag == 0) {
-		/* Get white balance from current setup */
-		if (atomisp_css_get_wb_config(asd, config))
-			return -EINVAL;
-	} else {
-		/* Set white balance to isp parameters */
-		memcpy(&asd->params.css_param.wb_config, config,
-		       sizeof(asd->params.css_param.wb_config));
-		atomisp_css_set_wb_config(asd, &asd->params.css_param.wb_config);
-		asd->params.css_update_params_needed = true;
-	}
-
-	return 0;
-}
-
-int atomisp_3a_config_param(struct atomisp_sub_device *asd, int flag,
-			    struct atomisp_3a_config *config)
-{
-	struct atomisp_device *isp = asd->isp;
-
-	dev_dbg(isp->dev, ">%s %d\n", __func__, flag);
-
-	if (flag == 0) {
-		/* Get white balance from current setup */
-		if (atomisp_css_get_3a_config(asd, config))
-			return -EINVAL;
-	} else {
-		/* Set white balance to isp parameters */
-		memcpy(&asd->params.css_param.s3a_config, config,
-		       sizeof(asd->params.css_param.s3a_config));
-		atomisp_css_set_3a_config(asd, &asd->params.css_param.s3a_config);
-		asd->params.css_update_params_needed = true;
-	}
-
-	dev_dbg(isp->dev, "<%s %d\n", __func__, flag);
-	return 0;
-}
-
-/*
- * Function to setup digital zoom
- */
-int atomisp_digital_zoom(struct atomisp_sub_device *asd, int flag,
-			 __s32 *value)
-{
-	u32 zoom;
-	struct atomisp_device *isp = asd->isp;
-
-	unsigned int max_zoom = MRFLD_MAX_ZOOM_FACTOR;
-
-	if (flag == 0) {
-		atomisp_css_get_zoom_factor(asd, &zoom);
-		*value = max_zoom - zoom;
-	} else {
-		if (*value < 0)
-			return -EINVAL;
-
-		zoom = max_zoom - min_t(u32, max_zoom - 1, *value);
-		atomisp_css_set_zoom_factor(asd, zoom);
-
-		dev_dbg(isp->dev, "%s, zoom: %d\n", __func__, zoom);
-		asd->params.css_update_params_needed = true;
-	}
-
-	return 0;
-}
-
-/*
- * Function to get sensor specific info for current resolution,
- * which will be used for auto exposure conversion.
- */
-int atomisp_get_sensor_mode_data(struct atomisp_sub_device *asd,
-				 struct atomisp_sensor_mode_data *config)
-{
-	struct camera_mipi_info *mipi_info;
-	struct atomisp_device *isp = asd->isp;
-
-	mipi_info = atomisp_to_sensor_mipi_info(
-		isp->inputs[asd->input_curr].camera);
-	if (mipi_info == NULL)
-		return -EINVAL;
-
-	memcpy(config, &mipi_info->data, sizeof(*config));
-	return 0;
-}
-
-int atomisp_get_fmt(struct video_device *vdev, struct v4l2_format *f)
-{
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-
-	f->fmt.pix = pipe->pix;
-
-	return 0;
-}
-
-static void __atomisp_update_stream_env(struct atomisp_sub_device *asd,
-	uint16_t stream_index, struct atomisp_input_stream_info *stream_info)
-{
-	int i;
-
-#if defined(ISP2401_NEW_INPUT_SYSTEM)
-	/* assign virtual channel id return from sensor driver query */
-	asd->stream_env[stream_index].ch_id = stream_info->ch_id;
-#endif
-	asd->stream_env[stream_index].isys_configs = stream_info->isys_configs;
-	for (i = 0; i < stream_info->isys_configs; i++) {
-		asd->stream_env[stream_index].isys_info[i].input_format =
-			stream_info->isys_info[i].input_format;
-		asd->stream_env[stream_index].isys_info[i].width =
-			stream_info->isys_info[i].width;
-		asd->stream_env[stream_index].isys_info[i].height =
-			stream_info->isys_info[i].height;
-	}
-}
-
-static void __atomisp_init_stream_info(uint16_t stream_index,
-		struct atomisp_input_stream_info *stream_info)
-{
-	int i;
-
-	stream_info->enable = 1;
-	stream_info->stream = stream_index;
-	stream_info->ch_id = 0;
-	stream_info->isys_configs = 0;
-	for (i = 0; i < MAX_STREAMS_PER_CHANNEL; i++) {
-		stream_info->isys_info[i].input_format = 0;
-		stream_info->isys_info[i].width = 0;
-		stream_info->isys_info[i].height = 0;
-	}
-}
-
-/* This function looks up the closest available resolution. */
-int atomisp_try_fmt(struct video_device *vdev, struct v4l2_format *f,
-						bool *res_overflow)
-{
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
-	struct v4l2_subdev_pad_config pad_cfg;
-	struct v4l2_subdev_format format = {
-		.which = V4L2_SUBDEV_FORMAT_TRY,
-	};
-
-	struct v4l2_mbus_framefmt *snr_mbus_fmt = &format.format;
-	const struct atomisp_format_bridge *fmt;
-	struct atomisp_input_stream_info *stream_info =
-	    (struct atomisp_input_stream_info *)snr_mbus_fmt->reserved;
-	uint16_t stream_index;
-	int source_pad = atomisp_subdev_source_pad(vdev);
-	int ret;
-
-	if (isp->inputs[asd->input_curr].camera == NULL)
-		return -EINVAL;
-
-	stream_index = atomisp_source_pad_to_stream_id(asd, source_pad);
-	fmt = atomisp_get_format_bridge(f->fmt.pix.pixelformat);
-	if (fmt == NULL) {
-		dev_err(isp->dev, "unsupported pixelformat!\n");
-		fmt = atomisp_output_fmts;
-	}
-
-#ifdef ISP2401
-	if (f->fmt.pix.width <= 0 || f->fmt.pix.height <= 0)
-		return -EINVAL;
-
-#endif
-	snr_mbus_fmt->code = fmt->mbus_code;
-	snr_mbus_fmt->width = f->fmt.pix.width;
-	snr_mbus_fmt->height = f->fmt.pix.height;
-
-	__atomisp_init_stream_info(stream_index, stream_info);
-
-	dev_dbg(isp->dev, "try_mbus_fmt: asking for %ux%u\n",
-		snr_mbus_fmt->width, snr_mbus_fmt->height);
-
-	ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-			       pad, set_fmt, &pad_cfg, &format);
-	if (ret)
-		return ret;
-
-	dev_dbg(isp->dev, "try_mbus_fmt: got %ux%u\n",
-		snr_mbus_fmt->width, snr_mbus_fmt->height);
-
-	fmt = atomisp_get_format_bridge_from_mbus(snr_mbus_fmt->code);
-	if (fmt == NULL) {
-		dev_err(isp->dev, "unknown sensor format 0x%8.8x\n",
-			snr_mbus_fmt->code);
-		return -EINVAL;
-	}
-
-	f->fmt.pix.pixelformat = fmt->pixelformat;
-
-	/*
-	 * If the format is jpeg or custom RAW, then the width and height will
-	 * not satisfy the normal atomisp requirements and no need to check
-	 * the below conditions. So just assign to what is being returned from
-	 * the sensor driver.
-	 */
-	if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_JPEG ||
-	    f->fmt.pix.pixelformat == V4L2_PIX_FMT_CUSTOM_M10MO_RAW) {
-		f->fmt.pix.width = snr_mbus_fmt->width;
-		f->fmt.pix.height = snr_mbus_fmt->height;
-		return 0;
-	}
-
-	if (snr_mbus_fmt->width < f->fmt.pix.width
-	    && snr_mbus_fmt->height < f->fmt.pix.height) {
-		f->fmt.pix.width = snr_mbus_fmt->width;
-		f->fmt.pix.height = snr_mbus_fmt->height;
-		/* Set the flag when resolution requested is
-		 * beyond the max value supported by sensor
-		 */
-		if (res_overflow != NULL)
-			*res_overflow = true;
-	}
-
-	/* app vs isp */
-	f->fmt.pix.width = rounddown(
-		clamp_t(u32, f->fmt.pix.width, ATOM_ISP_MIN_WIDTH,
-			ATOM_ISP_MAX_WIDTH), ATOM_ISP_STEP_WIDTH);
-	f->fmt.pix.height = rounddown(
-		clamp_t(u32, f->fmt.pix.height, ATOM_ISP_MIN_HEIGHT,
-			ATOM_ISP_MAX_HEIGHT), ATOM_ISP_STEP_HEIGHT);
-
-	return 0;
-}
-
-static int
-atomisp_try_fmt_file(struct atomisp_device *isp, struct v4l2_format *f)
-{
-	u32 width = f->fmt.pix.width;
-	u32 height = f->fmt.pix.height;
-	u32 pixelformat = f->fmt.pix.pixelformat;
-	enum v4l2_field field = f->fmt.pix.field;
-	u32 depth;
-
-	if (!atomisp_get_format_bridge(pixelformat)) {
-		dev_err(isp->dev, "Wrong output pixelformat\n");
-		return -EINVAL;
-	}
-
-	depth = get_pixel_depth(pixelformat);
-
-	if (field == V4L2_FIELD_ANY)
-		field = V4L2_FIELD_NONE;
-	else if (field != V4L2_FIELD_NONE) {
-		dev_err(isp->dev, "Wrong output field\n");
-		return -EINVAL;
-	}
-
-	f->fmt.pix.field = field;
-	f->fmt.pix.width = clamp_t(u32,
-				   rounddown(width, (u32)ATOM_ISP_STEP_WIDTH),
-				   ATOM_ISP_MIN_WIDTH, ATOM_ISP_MAX_WIDTH);
-	f->fmt.pix.height = clamp_t(u32, rounddown(height,
-				    (u32)ATOM_ISP_STEP_HEIGHT),
-				    ATOM_ISP_MIN_HEIGHT, ATOM_ISP_MAX_HEIGHT);
-	f->fmt.pix.bytesperline = (width * depth) >> 3;
-
-	return 0;
-}
-
-enum mipi_port_id __get_mipi_port(struct atomisp_device *isp,
-				enum atomisp_camera_port port)
-{
-	switch (port) {
-	case ATOMISP_CAMERA_PORT_PRIMARY:
-		return MIPI_PORT0_ID;
-	case ATOMISP_CAMERA_PORT_SECONDARY:
-		return MIPI_PORT1_ID;
-	case ATOMISP_CAMERA_PORT_TERTIARY:
-		if (MIPI_PORT1_ID + 1 != N_MIPI_PORT_ID)
-			return MIPI_PORT1_ID + 1;
-		/* go through down for else case */
-	default:
-		dev_err(isp->dev, "unsupported port: %d\n", port);
-		return MIPI_PORT0_ID;
-	}
-}
-
-static inline int atomisp_set_sensor_mipi_to_isp(
-				struct atomisp_sub_device *asd,
-				enum atomisp_input_stream_id stream_id,
-				struct camera_mipi_info *mipi_info)
-{
-	struct v4l2_control ctrl;
-	struct atomisp_device *isp = asd->isp;
-	const struct atomisp_in_fmt_conv *fc;
-	int mipi_freq = 0;
-	unsigned int input_format, bayer_order;
-
-	ctrl.id = V4L2_CID_LINK_FREQ;
-	if (v4l2_g_ctrl
-	    (isp->inputs[asd->input_curr].camera->ctrl_handler, &ctrl) == 0)
-		mipi_freq = ctrl.value;
-
-	if (asd->stream_env[stream_id].isys_configs == 1) {
-		input_format =
-			asd->stream_env[stream_id].isys_info[0].input_format;
-		atomisp_css_isys_set_format(asd, stream_id,
-				input_format, IA_CSS_STREAM_DEFAULT_ISYS_STREAM_IDX);
-	} else if (asd->stream_env[stream_id].isys_configs == 2) {
-		atomisp_css_isys_two_stream_cfg_update_stream1(
-				asd, stream_id,
-				asd->stream_env[stream_id].isys_info[0].input_format,
-				asd->stream_env[stream_id].isys_info[0].width,
-				asd->stream_env[stream_id].isys_info[0].height);
-
-		atomisp_css_isys_two_stream_cfg_update_stream2(
-				asd, stream_id,
-				asd->stream_env[stream_id].isys_info[1].input_format,
-				asd->stream_env[stream_id].isys_info[1].width,
-				asd->stream_env[stream_id].isys_info[1].height);
-	}
-
-	/* Compatibility for sensors which provide no media bus code
-	 * in s_mbus_framefmt() nor support pad formats. */
-	if (mipi_info->input_format != -1) {
-		bayer_order = mipi_info->raw_bayer_order;
-
-		/* Input stream config is still needs configured */
-		/* TODO: Check if this is necessary */
-		fc = atomisp_find_in_fmt_conv_by_atomisp_in_fmt(
-						mipi_info->input_format);
-		if (!fc)
-			return -EINVAL;
-		input_format = fc->css_stream_fmt;
-	} else {
-		struct v4l2_mbus_framefmt *sink;
-		sink = atomisp_subdev_get_ffmt(&asd->subdev, NULL,
-					       V4L2_SUBDEV_FORMAT_ACTIVE,
-					       ATOMISP_SUBDEV_PAD_SINK);
-		fc = atomisp_find_in_fmt_conv(sink->code);
-		if (!fc)
-			return -EINVAL;
-		input_format = fc->css_stream_fmt;
-		bayer_order = fc->bayer_order;
-	}
-
-	atomisp_css_input_set_format(asd, stream_id, input_format);
-	atomisp_css_input_set_bayer_order(asd, stream_id, bayer_order);
-
-	fc = atomisp_find_in_fmt_conv_by_atomisp_in_fmt(
-					mipi_info->metadata_format);
-	if (!fc)
-		return -EINVAL;
-	input_format = fc->css_stream_fmt;
-	atomisp_css_input_configure_port(asd,
-				__get_mipi_port(asd->isp, mipi_info->port),
-				mipi_info->num_lanes,
-				0xffff4, mipi_freq,
-				input_format,
-				mipi_info->metadata_width,
-				mipi_info->metadata_height);
-	return 0;
-}
-
-static int __enable_continuous_mode(struct atomisp_sub_device *asd,
-				    bool enable)
-{
-	struct atomisp_device *isp = asd->isp;
-
-	dev_dbg(isp->dev,
-		"continuous mode %d, raw buffers %d, stop preview %d\n",
-		enable, asd->continuous_raw_buffer_size->val,
-		!asd->continuous_viewfinder->val);
-#ifndef ISP2401
-	atomisp_css_capture_set_mode(asd, CSS_CAPTURE_MODE_PRIMARY);
-#else
-	atomisp_update_capture_mode(asd);
-#endif
-	/* in case of ANR, force capture pipe to offline mode */
-	atomisp_css_capture_enable_online(asd, ATOMISP_INPUT_STREAM_GENERAL,
-			asd->params.low_light ? false : !enable);
-	atomisp_css_preview_enable_online(asd, ATOMISP_INPUT_STREAM_GENERAL,
-			!enable);
-	atomisp_css_enable_continuous(asd, enable);
-	atomisp_css_enable_cvf(asd, asd->continuous_viewfinder->val);
-
-	if (atomisp_css_continuous_set_num_raw_frames(asd,
-			asd->continuous_raw_buffer_size->val)) {
-		dev_err(isp->dev, "css_continuous_set_num_raw_frames failed\n");
-		return -EINVAL;
-	}
-
-	if (!enable) {
-		atomisp_css_enable_raw_binning(asd, false);
-		atomisp_css_input_set_two_pixels_per_clock(asd, false);
-	}
-
-	if (isp->inputs[asd->input_curr].type != FILE_INPUT)
-		atomisp_css_input_set_mode(asd, CSS_INPUT_MODE_SENSOR);
-
-	return atomisp_update_run_mode(asd);
-}
-
-static int configure_pp_input_nop(struct atomisp_sub_device *asd,
-				  unsigned int width, unsigned int height)
-{
-	return 0;
-}
-
-static int configure_output_nop(struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height,
-				unsigned int min_width,
-				enum atomisp_css_frame_format sh_fmt)
-{
-	return 0;
-}
-
-static int get_frame_info_nop(struct atomisp_sub_device *asd,
-			      struct atomisp_css_frame_info *finfo)
-{
-	return 0;
-}
-
-/*
- * Resets CSS parameters that depend on input resolution.
- *
- * Update params like CSS RAW binning, 2ppc mode and pp_input
- * which depend on input size, but are not automatically
- * handled in CSS when the input resolution is changed.
- */
-static int css_input_resolution_changed(struct atomisp_sub_device *asd,
-		struct v4l2_mbus_framefmt *ffmt)
-{
-	struct atomisp_metadata_buf *md_buf = NULL, *_md_buf;
-	unsigned int i;
-
-	dev_dbg(asd->isp->dev, "css_input_resolution_changed to %ux%u\n",
-		ffmt->width, ffmt->height);
-
-#if defined(ISP2401_NEW_INPUT_SYSTEM)
-	atomisp_css_input_set_two_pixels_per_clock(asd, false);
-#else
-	atomisp_css_input_set_two_pixels_per_clock(asd, true);
-#endif
-	if (asd->continuous_mode->val) {
-		/* Note for all checks: ffmt includes pad_w+pad_h */
-		if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO ||
-		    (ffmt->width >= 2048 || ffmt->height >= 1536)) {
-			/*
-			 * For preview pipe, enable only if resolution
-			 * is >= 3M for ISP2400.
-			 */
-			atomisp_css_enable_raw_binning(asd, true);
-		}
-	}
-	/*
-	 * If sensor input changed, which means metadata resolution changed
-	 * together. Release all metadata buffers here to let it re-allocated
-	 * next time in reqbufs.
-	 */
-	for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
-		list_for_each_entry_safe(md_buf, _md_buf, &asd->metadata[i],
-					 list) {
-			atomisp_css_free_metadata_buffer(md_buf);
-			list_del(&md_buf->list);
-			kfree(md_buf);
-		}
-	}
-	return 0;
-
-	/*
-	 * TODO: atomisp_css_preview_configure_pp_input() not
-	 *       reset due to CSS bug tracked as PSI BZ 115124
-	 */
-}
-
-static int atomisp_set_fmt_to_isp(struct video_device *vdev,
-			struct atomisp_css_frame_info *output_info,
-			struct atomisp_css_frame_info *raw_output_info,
-			struct v4l2_pix_format *pix,
-			unsigned int source_pad)
-{
-	struct camera_mipi_info *mipi_info;
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
-	const struct atomisp_format_bridge *format;
-	struct v4l2_rect *isp_sink_crop;
-	enum atomisp_css_pipe_id pipe_id;
-	struct v4l2_subdev_fh fh;
-	int (*configure_output)(struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height,
-				unsigned int min_width,
-				enum atomisp_css_frame_format sh_fmt) =
-							configure_output_nop;
-	int (*get_frame_info)(struct atomisp_sub_device *asd,
-			      struct atomisp_css_frame_info *finfo) =
-							get_frame_info_nop;
-	int (*configure_pp_input)(struct atomisp_sub_device *asd,
-				  unsigned int width, unsigned int height) =
-							configure_pp_input_nop;
-	uint16_t stream_index = atomisp_source_pad_to_stream_id(asd, source_pad);
-	const struct atomisp_in_fmt_conv *fc;
-	int ret;
-
-	v4l2_fh_init(&fh.vfh, vdev);
-
-	isp_sink_crop = atomisp_subdev_get_rect(
-		&asd->subdev, NULL, V4L2_SUBDEV_FORMAT_ACTIVE,
-		ATOMISP_SUBDEV_PAD_SINK, V4L2_SEL_TGT_CROP);
-
-	format = atomisp_get_format_bridge(pix->pixelformat);
-	if (format == NULL)
-		return -EINVAL;
-
-	if (isp->inputs[asd->input_curr].type != TEST_PATTERN &&
-		isp->inputs[asd->input_curr].type != FILE_INPUT) {
-		mipi_info = atomisp_to_sensor_mipi_info(
-			isp->inputs[asd->input_curr].camera);
-		if (!mipi_info) {
-			dev_err(isp->dev, "mipi_info is NULL\n");
-			return -EINVAL;
-		}
-		if (atomisp_set_sensor_mipi_to_isp(asd, stream_index,
-					mipi_info))
-			return -EINVAL;
-		fc = atomisp_find_in_fmt_conv_by_atomisp_in_fmt(
-				mipi_info->input_format);
-		if (!fc)
-			fc = atomisp_find_in_fmt_conv(
-					atomisp_subdev_get_ffmt(&asd->subdev,
-					NULL, V4L2_SUBDEV_FORMAT_ACTIVE,
-					ATOMISP_SUBDEV_PAD_SINK)->code);
-		if (!fc)
-			return -EINVAL;
-		if (format->sh_fmt == CSS_FRAME_FORMAT_RAW &&
-		     raw_output_format_match_input(fc->css_stream_fmt,
-			pix->pixelformat))
-			return -EINVAL;
-	}
-
-	/*
-	 * Configure viewfinder also when vfpp is disabled: the
-	 * CSS still requires viewfinder configuration.
-	 */
-	if (asd->fmt_auto->val ||
-	    asd->vfpp->val != ATOMISP_VFPP_ENABLE) {
-		struct v4l2_rect vf_size = {0};
-		struct v4l2_mbus_framefmt vf_ffmt = {0};
-
-		if (pix->width < 640 || pix->height < 480) {
-			vf_size.width = pix->width;
-			vf_size.height = pix->height;
-		} else {
-			vf_size.width = 640;
-			vf_size.height = 480;
-		}
-
-		/* FIXME: proper format name for this one. See
-		   atomisp_output_fmts[] in atomisp_v4l2.c */
-		vf_ffmt.code = V4L2_MBUS_FMT_CUSTOM_YUV420;
-
-		atomisp_subdev_set_selection(&asd->subdev, fh.pad,
-					     V4L2_SUBDEV_FORMAT_ACTIVE,
-					     ATOMISP_SUBDEV_PAD_SOURCE_VF,
-					     V4L2_SEL_TGT_COMPOSE, 0, &vf_size);
-		atomisp_subdev_set_ffmt(&asd->subdev, fh.pad,
-					V4L2_SUBDEV_FORMAT_ACTIVE,
-					ATOMISP_SUBDEV_PAD_SOURCE_VF, &vf_ffmt);
-		asd->video_out_vf.sh_fmt = CSS_FRAME_FORMAT_NV12;
-
-		if (asd->vfpp->val == ATOMISP_VFPP_DISABLE_SCALER) {
-			atomisp_css_video_configure_viewfinder(asd,
-				vf_size.width, vf_size.height, 0,
-				asd->video_out_vf.sh_fmt);
-		} else if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) {
-			if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW ||
-			    source_pad == ATOMISP_SUBDEV_PAD_SOURCE_VIDEO)
-				atomisp_css_video_configure_viewfinder(asd,
-					vf_size.width, vf_size.height, 0,
-					asd->video_out_vf.sh_fmt);
-			else
-				atomisp_css_capture_configure_viewfinder(asd,
-					vf_size.width, vf_size.height, 0,
-					asd->video_out_vf.sh_fmt);
-		} else if (source_pad != ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW ||
-			 asd->vfpp->val == ATOMISP_VFPP_DISABLE_LOWLAT) {
-			atomisp_css_capture_configure_viewfinder(asd,
-				vf_size.width, vf_size.height, 0,
-				asd->video_out_vf.sh_fmt);
-		}
-	}
-
-	if (asd->continuous_mode->val) {
-		ret = __enable_continuous_mode(asd, true);
-		if (ret)
-			return -EINVAL;
-	}
-
-	atomisp_css_input_set_mode(asd, CSS_INPUT_MODE_SENSOR);
-	atomisp_css_disable_vf_pp(asd,
-			asd->vfpp->val != ATOMISP_VFPP_ENABLE);
-
-	/* ISP2401 new input system need to use copy pipe */
-	if (asd->copy_mode) {
-		pipe_id = CSS_PIPE_ID_COPY;
-		atomisp_css_capture_enable_online(asd, stream_index, false);
-	} else if (asd->vfpp->val == ATOMISP_VFPP_DISABLE_SCALER) {
-		/* video same in continuouscapture and online modes */
-		configure_output = atomisp_css_video_configure_output;
-		get_frame_info = atomisp_css_video_get_output_frame_info;
-		pipe_id = CSS_PIPE_ID_VIDEO;
-	} else if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) {
-		if (!asd->continuous_mode->val) {
-			configure_output = atomisp_css_video_configure_output;
-			get_frame_info =
-				atomisp_css_video_get_output_frame_info;
-			pipe_id = CSS_PIPE_ID_VIDEO;
-		} else {
-			if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW ||
-			    source_pad == ATOMISP_SUBDEV_PAD_SOURCE_VIDEO) {
-				configure_output =
-					atomisp_css_video_configure_output;
-				get_frame_info =
-					atomisp_css_video_get_output_frame_info;
-				configure_pp_input =
-					atomisp_css_video_configure_pp_input;
-				pipe_id = CSS_PIPE_ID_VIDEO;
-			} else {
-				configure_output =
-					atomisp_css_capture_configure_output;
-				get_frame_info =
-					atomisp_css_capture_get_output_frame_info;
-				configure_pp_input =
-					atomisp_css_capture_configure_pp_input;
-				pipe_id = CSS_PIPE_ID_CAPTURE;
-
-				atomisp_update_capture_mode(asd);
-				atomisp_css_capture_enable_online(asd, stream_index, false);
-			}
-		}
-	} else if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW) {
-		configure_output = atomisp_css_preview_configure_output;
-		get_frame_info = atomisp_css_preview_get_output_frame_info;
-		configure_pp_input = atomisp_css_preview_configure_pp_input;
-		pipe_id = CSS_PIPE_ID_PREVIEW;
-	} else {
-		/* CSS doesn't support low light mode on SOC cameras, so disable
-		 * it. FIXME: if this is done elsewhere, it gives corrupted
-		 * colors into thumbnail image.
-		 */
-		if (isp->inputs[asd->input_curr].type == SOC_CAMERA)
-			asd->params.low_light = false;
-
-		if (format->sh_fmt == CSS_FRAME_FORMAT_RAW) {
-			atomisp_css_capture_set_mode(asd, CSS_CAPTURE_MODE_RAW);
-			atomisp_css_enable_dz(asd, false);
-		} else {
-			atomisp_update_capture_mode(asd);
-		}
-
-		if (!asd->continuous_mode->val)
-			/* in case of ANR, force capture pipe to offline mode */
-			atomisp_css_capture_enable_online(asd, stream_index,
-					asd->params.low_light ?
-					false : asd->params.online_process);
-
-		configure_output = atomisp_css_capture_configure_output;
-		get_frame_info = atomisp_css_capture_get_output_frame_info;
-		configure_pp_input = atomisp_css_capture_configure_pp_input;
-		pipe_id = CSS_PIPE_ID_CAPTURE;
-
-		if (!asd->params.online_process &&
-		    !asd->continuous_mode->val) {
-			ret = atomisp_css_capture_get_output_raw_frame_info(asd,
-							raw_output_info);
-			if (ret)
-				return ret;
-		}
-		if (!asd->continuous_mode->val && asd->run_mode->val
-		    != ATOMISP_RUN_MODE_STILL_CAPTURE) {
-			dev_err(isp->dev,
-				    "Need to set the running mode first\n");
-			asd->run_mode->val = ATOMISP_RUN_MODE_STILL_CAPTURE;
-		}
-	}
-
-	/*
-	 * to SOC camera, use yuvpp pipe.
-	 */
-	if (ATOMISP_USE_YUVPP(asd))
-		pipe_id = CSS_PIPE_ID_YUVPP;
-
-	if (asd->copy_mode)
-		ret = atomisp_css_copy_configure_output(asd, stream_index,
-				pix->width, pix->height,
-				format->planar ? pix->bytesperline :
-					pix->bytesperline * 8 / format->depth,
-				format->sh_fmt);
-	else
-		ret = configure_output(asd, pix->width, pix->height,
-				       format->planar ? pix->bytesperline :
-				       pix->bytesperline * 8 / format->depth,
-				       format->sh_fmt);
-	if (ret) {
-		dev_err(isp->dev, "configure_output %ux%u, format %8.8x\n",
-			pix->width, pix->height, format->sh_fmt);
-		return -EINVAL;
-	}
-
-	if (asd->continuous_mode->val &&
-	    (configure_pp_input == atomisp_css_preview_configure_pp_input ||
-	     configure_pp_input == atomisp_css_video_configure_pp_input)) {
-		/* for isp 2.2, configure pp input is available for continuous
-		 * mode */
-		ret = configure_pp_input(asd, isp_sink_crop->width,
-					 isp_sink_crop->height);
-		if (ret) {
-			dev_err(isp->dev, "configure_pp_input %ux%u\n",
-				isp_sink_crop->width,
-				isp_sink_crop->height);
-			return -EINVAL;
-		}
-	} else {
-		ret = configure_pp_input(asd, isp_sink_crop->width,
-					 isp_sink_crop->height);
-		if (ret) {
-			dev_err(isp->dev, "configure_pp_input %ux%u\n",
-				isp_sink_crop->width, isp_sink_crop->height);
-			return -EINVAL;
-		}
-	}
-	if (asd->copy_mode)
-		ret = atomisp_css_copy_get_output_frame_info(asd, stream_index,
-				output_info);
-	else
-		ret = get_frame_info(asd, output_info);
-	if (ret) {
-		dev_err(isp->dev, "get_frame_info %ux%u (padded to %u)\n",
-			pix->width, pix->height, pix->bytesperline);
-		return -EINVAL;
-	}
-
-	atomisp_update_grid_info(asd, pipe_id, source_pad);
-
-	/* Free the raw_dump buffer first */
-	atomisp_css_frame_free(asd->raw_output_frame);
-	asd->raw_output_frame = NULL;
-
-	if (!asd->continuous_mode->val &&
-	    !asd->params.online_process && !isp->sw_contex.file_input &&
-		atomisp_css_frame_allocate_from_info(&asd->raw_output_frame,
-							raw_output_info))
-		return -ENOMEM;
-
-	return 0;
-}
-
-static void atomisp_get_dis_envelop(struct atomisp_sub_device *asd,
-			    unsigned int width, unsigned int height,
-			    unsigned int *dvs_env_w, unsigned int *dvs_env_h)
-{
-	struct atomisp_device *isp = asd->isp;
-
-	/* if subdev type is SOC camera,we do not need to set DVS */
-	if (isp->inputs[asd->input_curr].type == SOC_CAMERA)
-		asd->params.video_dis_en = false;
-
-	if (asd->params.video_dis_en &&
-	    asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) {
-		/* envelope is 20% of the output resolution */
-		/*
-		 * dvs envelope cannot be round up.
-		 * it would cause ISP timeout and color switch issue
-		 */
-		*dvs_env_w = rounddown(width / 5, ATOM_ISP_STEP_WIDTH);
-		*dvs_env_h = rounddown(height / 5, ATOM_ISP_STEP_HEIGHT);
-	}
-
-	asd->params.dis_proj_data_valid = false;
-	asd->params.css_update_params_needed = true;
-}
-
-static void atomisp_check_copy_mode(struct atomisp_sub_device *asd,
-		int source_pad, struct v4l2_format *f)
-{
-#if defined(ISP2401_NEW_INPUT_SYSTEM)
-	struct v4l2_mbus_framefmt *sink, *src;
-
-	sink = atomisp_subdev_get_ffmt(&asd->subdev, NULL,
-		V4L2_SUBDEV_FORMAT_ACTIVE, ATOMISP_SUBDEV_PAD_SINK);
-	src = atomisp_subdev_get_ffmt(&asd->subdev, NULL,
-		V4L2_SUBDEV_FORMAT_ACTIVE, source_pad);
-
-	if ((sink->code == src->code &&
-	    sink->width == f->fmt.pix.width &&
-	    sink->height == f->fmt.pix.height) ||
-	    ((asd->isp->inputs[asd->input_curr].type == SOC_CAMERA) &&
-	    (asd->isp->inputs[asd->input_curr].camera_caps->
-	    sensor[asd->sensor_curr].stream_num > 1)))
-		asd->copy_mode = true;
-	else
-#endif
-		/* Only used for the new input system */
-		asd->copy_mode = false;
-
-	dev_dbg(asd->isp->dev, "copy_mode: %d\n", asd->copy_mode);
-
-}
-
-static int atomisp_set_fmt_to_snr(struct video_device *vdev,
-		struct v4l2_format *f, unsigned int pixelformat,
-		unsigned int padding_w, unsigned int padding_h,
-		unsigned int dvs_env_w, unsigned int dvs_env_h)
-{
-	struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
-	const struct atomisp_format_bridge *format;
-	struct v4l2_subdev_pad_config pad_cfg;
-	struct v4l2_subdev_format vformat = {
-		.which = V4L2_SUBDEV_FORMAT_TRY,
-	};
-	struct v4l2_mbus_framefmt *ffmt = &vformat.format;
-	struct v4l2_mbus_framefmt *req_ffmt;
-	struct atomisp_device *isp = asd->isp;
-	struct atomisp_input_stream_info *stream_info =
-	    (struct atomisp_input_stream_info *)ffmt->reserved;
-	uint16_t stream_index = ATOMISP_INPUT_STREAM_GENERAL;
-	int source_pad = atomisp_subdev_source_pad(vdev);
-	struct v4l2_subdev_fh fh;
-	int ret;
-
-	v4l2_fh_init(&fh.vfh, vdev);
-
-	stream_index = atomisp_source_pad_to_stream_id(asd, source_pad);
-
-	format = atomisp_get_format_bridge(pixelformat);
-	if (format == NULL)
-		return -EINVAL;
-
-	v4l2_fill_mbus_format(ffmt, &f->fmt.pix, format->mbus_code);
-	ffmt->height += padding_h + dvs_env_h;
-	ffmt->width += padding_w + dvs_env_w;
-
-	dev_dbg(isp->dev, "s_mbus_fmt: ask %ux%u (padding %ux%u, dvs %ux%u)\n",
-		ffmt->width, ffmt->height, padding_w, padding_h,
-		dvs_env_w, dvs_env_h);
-
-	__atomisp_init_stream_info(stream_index, stream_info);
-
-	req_ffmt = ffmt;
-
-	/* Disable dvs if resolution can't be supported by sensor */
-	if (asd->params.video_dis_en &&
-	    source_pad == ATOMISP_SUBDEV_PAD_SOURCE_VIDEO) {
-		vformat.which = V4L2_SUBDEV_FORMAT_TRY;
-		ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-			pad, set_fmt, &pad_cfg, &vformat);
-		if (ret)
-			return ret;
-		if (ffmt->width < req_ffmt->width ||
-		    ffmt->height < req_ffmt->height) {
-			req_ffmt->height -= dvs_env_h;
-			req_ffmt->width -= dvs_env_w;
-			ffmt = req_ffmt;
-			dev_warn(isp->dev,
-			  "can not enable video dis due to sensor limitation.");
-			asd->params.video_dis_en = false;
-		}
-	}
-	dev_dbg(isp->dev, "sensor width: %d, height: %d\n",
-		ffmt->width, ffmt->height);
-	vformat.which = V4L2_SUBDEV_FORMAT_ACTIVE;
-	ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, pad,
-			       set_fmt, NULL, &vformat);
-	if (ret)
-		return ret;
-
-	__atomisp_update_stream_env(asd, stream_index, stream_info);
-
-	dev_dbg(isp->dev, "sensor width: %d, height: %d\n",
-		ffmt->width, ffmt->height);
-
-	if (ffmt->width < ATOM_ISP_STEP_WIDTH ||
-	    ffmt->height < ATOM_ISP_STEP_HEIGHT)
-			return -EINVAL;
-
-	if (asd->params.video_dis_en &&
-	    source_pad == ATOMISP_SUBDEV_PAD_SOURCE_VIDEO &&
-	    (ffmt->width < req_ffmt->width || ffmt->height < req_ffmt->height)) {
-		dev_warn(isp->dev,
-			 "can not enable video dis due to sensor limitation.");
-		asd->params.video_dis_en = false;
-	}
-
-	atomisp_subdev_set_ffmt(&asd->subdev, fh.pad,
-				V4L2_SUBDEV_FORMAT_ACTIVE,
-				ATOMISP_SUBDEV_PAD_SINK, ffmt);
-
-	return css_input_resolution_changed(asd, ffmt);
-}
-
-int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)
-{
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-	struct atomisp_sub_device *asd = pipe->asd;
-	const struct atomisp_format_bridge *format_bridge;
-	const struct atomisp_format_bridge *snr_format_bridge;
-	struct atomisp_css_frame_info output_info, raw_output_info;
-	struct v4l2_format snr_fmt = *f;
-	struct v4l2_format backup_fmt = *f, s_fmt = *f;
-	unsigned int dvs_env_w = 0, dvs_env_h = 0;
-	unsigned int padding_w = pad_w, padding_h = pad_h;
-	bool res_overflow = false, crop_needs_override = false;
-	struct v4l2_mbus_framefmt isp_sink_fmt;
-	struct v4l2_mbus_framefmt isp_source_fmt = {0};
-	struct v4l2_rect isp_sink_crop;
-	uint16_t source_pad = atomisp_subdev_source_pad(vdev);
-	struct v4l2_subdev_fh fh;
-	int ret;
-
-	dev_dbg(isp->dev,
-		"setting resolution %ux%u on pad %u for asd%d, bytesperline %u\n",
-		f->fmt.pix.width, f->fmt.pix.height, source_pad,
-		asd->index, f->fmt.pix.bytesperline);
-
-	if (source_pad >= ATOMISP_SUBDEV_PADS_NUM)
-		return -EINVAL;
-
-	if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED) {
-		dev_warn(isp->dev, "ISP does not support set format while at streaming!\n");
-		return -EBUSY;
-	}
-
-	v4l2_fh_init(&fh.vfh, vdev);
-
-	format_bridge = atomisp_get_format_bridge(f->fmt.pix.pixelformat);
-	if (format_bridge == NULL)
-		return -EINVAL;
-
-	pipe->sh_fmt = format_bridge->sh_fmt;
-	pipe->pix.pixelformat = f->fmt.pix.pixelformat;
-
-	if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_VF ||
-	    (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW
-		&& asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO)) {
-		if (asd->fmt_auto->val) {
-			struct v4l2_rect *capture_comp;
-			struct v4l2_rect r = {0};
-
-			r.width = f->fmt.pix.width;
-			r.height = f->fmt.pix.height;
-
-			if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW)
-				capture_comp = atomisp_subdev_get_rect(
-					&asd->subdev, NULL,
-					V4L2_SUBDEV_FORMAT_ACTIVE,
-					ATOMISP_SUBDEV_PAD_SOURCE_VIDEO,
-					V4L2_SEL_TGT_COMPOSE);
-			else
-				capture_comp = atomisp_subdev_get_rect(
-					&asd->subdev, NULL,
-					V4L2_SUBDEV_FORMAT_ACTIVE,
-					ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE,
-					V4L2_SEL_TGT_COMPOSE);
-
-			if (capture_comp->width < r.width
-			    || capture_comp->height < r.height) {
-				r.width = capture_comp->width;
-				r.height = capture_comp->height;
-			}
-
-			atomisp_subdev_set_selection(
-				&asd->subdev, fh.pad,
-				V4L2_SUBDEV_FORMAT_ACTIVE, source_pad,
-				V4L2_SEL_TGT_COMPOSE, 0, &r);
-
-			f->fmt.pix.width = r.width;
-			f->fmt.pix.height = r.height;
-		}
-
-		if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW &&
-		    (asd->isp->inputs[asd->input_curr].type == SOC_CAMERA) &&
-		    (asd->isp->inputs[asd->input_curr].camera_caps->
-		    sensor[asd->sensor_curr].stream_num > 1)) {
-			/* For M10MO outputing YUV preview images. */
-			uint16_t video_index =
-				atomisp_source_pad_to_stream_id(asd,
-					ATOMISP_SUBDEV_PAD_SOURCE_VIDEO);
-
-			ret = atomisp_css_copy_get_output_frame_info(asd,
-				video_index, &output_info);
-			if (ret) {
-				dev_err(isp->dev,
-				      "copy_get_output_frame_info ret %i", ret);
-				return -EINVAL;
-			}
-			if (!asd->yuvpp_mode) {
-				/*
-				 * If viewfinder was configured into copy_mode,
-				 * we switch to using yuvpp pipe instead.
-				 */
-				asd->yuvpp_mode = true;
-				ret = atomisp_css_copy_configure_output(
-					asd, video_index, 0, 0, 0, 0);
-				if (ret) {
-					dev_err(isp->dev,
-						"failed to disable copy pipe");
-					return -EINVAL;
-				}
-				ret = atomisp_css_yuvpp_configure_output(
-					asd, video_index,
-					output_info.res.width,
-					output_info.res.height,
-					output_info.padded_width,
-					output_info.format);
-				if (ret) {
-					dev_err(isp->dev,
-						"failed to set up yuvpp pipe\n");
-					return -EINVAL;
-				}
-				atomisp_css_video_enable_online(asd, false);
-				atomisp_css_preview_enable_online(asd,
-					ATOMISP_INPUT_STREAM_GENERAL, false);
-			}
-			atomisp_css_yuvpp_configure_viewfinder(asd, video_index,
-				f->fmt.pix.width, f->fmt.pix.height,
-				format_bridge->planar ? f->fmt.pix.bytesperline
-				: f->fmt.pix.bytesperline * 8
-				/ format_bridge->depth, format_bridge->sh_fmt);
-			atomisp_css_yuvpp_get_viewfinder_frame_info(
-				asd, video_index, &output_info);
-		} else if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW) {
-			atomisp_css_video_configure_viewfinder(asd,
-				f->fmt.pix.width, f->fmt.pix.height,
-				format_bridge->planar ? f->fmt.pix.bytesperline
-				: f->fmt.pix.bytesperline * 8
-				/ format_bridge->depth,	format_bridge->sh_fmt);
-			atomisp_css_video_get_viewfinder_frame_info(asd,
-								&output_info);
-			asd->copy_mode = false;
-		} else {
-			atomisp_css_capture_configure_viewfinder(asd,
-				f->fmt.pix.width, f->fmt.pix.height,
-				format_bridge->planar ? f->fmt.pix.bytesperline
-				: f->fmt.pix.bytesperline * 8
-				/ format_bridge->depth,	format_bridge->sh_fmt);
-			atomisp_css_capture_get_viewfinder_frame_info(asd,
-								&output_info);
-			asd->copy_mode = false;
-		}
-
-		goto done;
-	}
-	/*
-	 * Check whether main resolution configured smaller
-	 * than snapshot resolution. If so, force main resolution
-	 * to be the same as snapshot resolution
-	 */
-	if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE) {
-		struct v4l2_rect *r;
-
-		r = atomisp_subdev_get_rect(
-			&asd->subdev, NULL,
-			V4L2_SUBDEV_FORMAT_ACTIVE,
-			ATOMISP_SUBDEV_PAD_SOURCE_VF, V4L2_SEL_TGT_COMPOSE);
-
-		if (r->width && r->height
-		    && (r->width > f->fmt.pix.width
-			|| r->height > f->fmt.pix.height))
-			dev_warn(isp->dev,
-				 "Main Resolution config smaller then Vf Resolution. Force to be equal with Vf Resolution.");
-	}
-
-	/* Pipeline configuration done through subdevs. Bail out now. */
-	if (!asd->fmt_auto->val)
-		goto set_fmt_to_isp;
-
-	/* get sensor resolution and format */
-	ret = atomisp_try_fmt(vdev, &snr_fmt, &res_overflow);
-	if (ret)
-		return ret;
-	f->fmt.pix.width = snr_fmt.fmt.pix.width;
-	f->fmt.pix.height = snr_fmt.fmt.pix.height;
-
-	snr_format_bridge =
-		atomisp_get_format_bridge(snr_fmt.fmt.pix.pixelformat);
-	if (!snr_format_bridge)
-		return -EINVAL;
-
-	atomisp_subdev_get_ffmt(&asd->subdev, NULL,
-				V4L2_SUBDEV_FORMAT_ACTIVE,
-				ATOMISP_SUBDEV_PAD_SINK)->code =
-		snr_format_bridge->mbus_code;
-
-	isp_sink_fmt = *atomisp_subdev_get_ffmt(&asd->subdev, NULL,
-					    V4L2_SUBDEV_FORMAT_ACTIVE,
-					    ATOMISP_SUBDEV_PAD_SINK);
-
-	isp_source_fmt.code = format_bridge->mbus_code;
-	atomisp_subdev_set_ffmt(&asd->subdev, fh.pad,
-				V4L2_SUBDEV_FORMAT_ACTIVE,
-				source_pad, &isp_source_fmt);
-
-	if (!atomisp_subdev_format_conversion(asd, source_pad)) {
-		padding_w = 0;
-		padding_h = 0;
-	} else if (IS_BYT) {
-		padding_w = 12;
-		padding_h = 12;
-	}
-
-	/* construct resolution supported by isp */
-	if (res_overflow && !asd->continuous_mode->val) {
-		f->fmt.pix.width = rounddown(
-			clamp_t(u32, f->fmt.pix.width - padding_w,
-				ATOM_ISP_MIN_WIDTH,
-				ATOM_ISP_MAX_WIDTH), ATOM_ISP_STEP_WIDTH);
-		f->fmt.pix.height = rounddown(
-			clamp_t(u32, f->fmt.pix.height - padding_h,
-				ATOM_ISP_MIN_HEIGHT,
-				ATOM_ISP_MAX_HEIGHT), ATOM_ISP_STEP_HEIGHT);
-	}
-
-	atomisp_get_dis_envelop(asd, f->fmt.pix.width, f->fmt.pix.height,
-				&dvs_env_w, &dvs_env_h);
-
-	if (asd->continuous_mode->val) {
-		struct v4l2_rect *r;
-
-		r = atomisp_subdev_get_rect(
-			&asd->subdev, NULL,
-			V4L2_SUBDEV_FORMAT_ACTIVE,
-			ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE,
-			V4L2_SEL_TGT_COMPOSE);
-		/*
-		 * The ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE should get resolutions
-		 * properly set otherwise, it should not be the capture_pad.
-		 */
-		if (r->width && r->height)
-			asd->capture_pad = ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE;
-		else
-			asd->capture_pad = source_pad;
-	} else {
-		asd->capture_pad = source_pad;
-	}
-	/*
-	 * set format info to sensor
-	 * In continuous mode, resolution is set only if it is higher than
-	 * existing value. This because preview pipe will be configured after
-	 * capture pipe and usually has lower resolution than capture pipe.
-	 */
-	if (!asd->continuous_mode->val ||
-	    isp_sink_fmt.width < (f->fmt.pix.width + padding_w + dvs_env_w) ||
-	    isp_sink_fmt.height < (f->fmt.pix.height + padding_h +
-				    dvs_env_h)) {
-		/*
-		 * For jpeg or custom raw format the sensor will return constant
-		 * width and height. Because we already had quried try_mbus_fmt,
-		 * f->fmt.pix.width and f->fmt.pix.height has been changed to
-		 * this fixed width and height. So we cannot select the correct
-		 * resolution with that information. So use the original width
-		 * and height while set_mbus_fmt() so actual resolutions are
-		 * being used in while set media bus format.
-		 */
-		s_fmt = *f;
-		if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_JPEG ||
-		    f->fmt.pix.pixelformat == V4L2_PIX_FMT_CUSTOM_M10MO_RAW) {
-			s_fmt.fmt.pix.width = backup_fmt.fmt.pix.width;
-			s_fmt.fmt.pix.height = backup_fmt.fmt.pix.height;
-		}
-		ret = atomisp_set_fmt_to_snr(vdev, &s_fmt,
-					f->fmt.pix.pixelformat, padding_w,
-					padding_h, dvs_env_w, dvs_env_h);
-		if (ret)
-			return -EINVAL;
-
-		atomisp_csi_lane_config(isp);
-		crop_needs_override = true;
-	}
-
-	atomisp_check_copy_mode(asd, source_pad, &backup_fmt);
-	asd->yuvpp_mode = false;			/* Reset variable */
-
-	isp_sink_crop = *atomisp_subdev_get_rect(&asd->subdev, NULL,
-						 V4L2_SUBDEV_FORMAT_ACTIVE,
-						 ATOMISP_SUBDEV_PAD_SINK,
-						 V4L2_SEL_TGT_CROP);
-
-	/* Try to enable YUV downscaling if ISP input is 10 % (either
-	 * width or height) bigger than the desired result. */
-	if (isp_sink_crop.width * 9 / 10 < f->fmt.pix.width ||
-	    isp_sink_crop.height * 9 / 10 < f->fmt.pix.height ||
-	    (atomisp_subdev_format_conversion(asd, source_pad) &&
-	    ((asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO &&
-	       !asd->continuous_mode->val) ||
-	      asd->vfpp->val == ATOMISP_VFPP_DISABLE_SCALER))) {
-		/* for continuous mode, preview size might be smaller than
-		 * still capture size. if preview size still needs crop,
-		 * pick the larger one between crop size of preview and
-		 * still capture.
-		 */
-		if (asd->continuous_mode->val
-		    && source_pad == ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW
-		    && !crop_needs_override) {
-			isp_sink_crop.width =
-				max_t(unsigned int, f->fmt.pix.width,
-				      isp_sink_crop.width);
-			isp_sink_crop.height =
-				max_t(unsigned int, f->fmt.pix.height,
-				      isp_sink_crop.height);
-		} else {
-			isp_sink_crop.width = f->fmt.pix.width;
-			isp_sink_crop.height = f->fmt.pix.height;
-		}
-
-		atomisp_subdev_set_selection(&asd->subdev, fh.pad,
-					     V4L2_SUBDEV_FORMAT_ACTIVE,
-					     ATOMISP_SUBDEV_PAD_SINK,
-					     V4L2_SEL_TGT_CROP,
-					     V4L2_SEL_FLAG_KEEP_CONFIG,
-					     &isp_sink_crop);
-		atomisp_subdev_set_selection(&asd->subdev, fh.pad,
-					     V4L2_SUBDEV_FORMAT_ACTIVE,
-					     source_pad, V4L2_SEL_TGT_COMPOSE,
-					     0, &isp_sink_crop);
-	} else if (IS_MOFD) {
-		struct v4l2_rect main_compose = {0};
-
-		main_compose.width = isp_sink_crop.width;
-		main_compose.height =
-			DIV_ROUND_UP(main_compose.width * f->fmt.pix.height,
-				     f->fmt.pix.width);
-		if (main_compose.height > isp_sink_crop.height) {
-			main_compose.height = isp_sink_crop.height;
-			main_compose.width =
-				DIV_ROUND_UP(main_compose.height *
-					     f->fmt.pix.width,
-					     f->fmt.pix.height);
-		}
-
-		atomisp_subdev_set_selection(&asd->subdev, fh.pad,
-				V4L2_SUBDEV_FORMAT_ACTIVE,
-				source_pad,
-				V4L2_SEL_TGT_COMPOSE, 0,
-				&main_compose);
-	} else {
-		struct v4l2_rect sink_crop = {0};
-		struct v4l2_rect main_compose = {0};
-
-		main_compose.width = f->fmt.pix.width;
-		main_compose.height = f->fmt.pix.height;
-
-#ifndef ISP2401
-		/* WORKAROUND: this override is universally enabled in
-		 * GMIN to work around a CTS failures (GMINL-539)
-		 * which appears to be related by a hardware
-		 * performance limitation.  It's unclear why this
-		 * particular code triggers the issue. */
-		if (1 ||
-		    crop_needs_override) {
-#else
-		if (crop_needs_override) {
-#endif
-			if (isp_sink_crop.width * main_compose.height >
-			    isp_sink_crop.height * main_compose.width) {
-				sink_crop.height = isp_sink_crop.height;
-				sink_crop.width = DIV_NEAREST_STEP(
-						sink_crop.height *
-						f->fmt.pix.width,
-						f->fmt.pix.height,
-						ATOM_ISP_STEP_WIDTH);
-			} else {
-				sink_crop.width = isp_sink_crop.width;
-				sink_crop.height = DIV_NEAREST_STEP(
-						sink_crop.width *
-						f->fmt.pix.height,
-						f->fmt.pix.width,
-						ATOM_ISP_STEP_HEIGHT);
-			}
-			atomisp_subdev_set_selection(&asd->subdev, fh.pad,
-				V4L2_SUBDEV_FORMAT_ACTIVE,
-				ATOMISP_SUBDEV_PAD_SINK,
-				V4L2_SEL_TGT_CROP,
-				V4L2_SEL_FLAG_KEEP_CONFIG,
-				&sink_crop);
-		}
-		atomisp_subdev_set_selection(&asd->subdev, fh.pad,
-				V4L2_SUBDEV_FORMAT_ACTIVE,
-				source_pad,
-				V4L2_SEL_TGT_COMPOSE, 0,
-				&main_compose);
-	}
-
-set_fmt_to_isp:
-	ret = atomisp_set_fmt_to_isp(vdev, &output_info, &raw_output_info,
-				     &f->fmt.pix, source_pad);
-	if (ret)
-		return -EINVAL;
-done:
-	pipe->pix.width = f->fmt.pix.width;
-	pipe->pix.height = f->fmt.pix.height;
-	pipe->pix.pixelformat = f->fmt.pix.pixelformat;
-	if (format_bridge->planar) {
-		pipe->pix.bytesperline = output_info.padded_width;
-		pipe->pix.sizeimage = PAGE_ALIGN(f->fmt.pix.height *
-			DIV_ROUND_UP(format_bridge->depth *
-				     output_info.padded_width, 8));
-	} else {
-		pipe->pix.bytesperline =
-			DIV_ROUND_UP(format_bridge->depth *
-				     output_info.padded_width, 8);
-		pipe->pix.sizeimage =
-			PAGE_ALIGN(f->fmt.pix.height * pipe->pix.bytesperline);
-
-	}
-	if (f->fmt.pix.field == V4L2_FIELD_ANY)
-		f->fmt.pix.field = V4L2_FIELD_NONE;
-	pipe->pix.field = f->fmt.pix.field;
-
-	f->fmt.pix = pipe->pix;
-	f->fmt.pix.priv = PAGE_ALIGN(pipe->pix.width *
-				     pipe->pix.height * 2);
-
-	pipe->capq.field = f->fmt.pix.field;
-
-	/*
-	 * If in video 480P case, no GFX throttle
-	 */
-	if (asd->run_mode->val == ATOMISP_SUBDEV_PAD_SOURCE_VIDEO &&
-	    f->fmt.pix.width == 720 && f->fmt.pix.height == 480)
-		isp->need_gfx_throttle = false;
-	else
-		isp->need_gfx_throttle = true;
-
-	return 0;
-}
-
-int atomisp_set_fmt_file(struct video_device *vdev, struct v4l2_format *f)
-{
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-	struct atomisp_sub_device *asd = pipe->asd;
-	struct v4l2_mbus_framefmt ffmt = {0};
-	const struct atomisp_format_bridge *format_bridge;
-	struct v4l2_subdev_fh fh;
-	int ret;
-
-	v4l2_fh_init(&fh.vfh, vdev);
-
-	dev_dbg(isp->dev, "setting fmt %ux%u 0x%x for file inject\n",
-		f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.pixelformat);
-	ret = atomisp_try_fmt_file(isp, f);
-	if (ret) {
-		dev_err(isp->dev, "atomisp_try_fmt_file err: %d\n", ret);
-		return ret;
-	}
-
-	format_bridge = atomisp_get_format_bridge(f->fmt.pix.pixelformat);
-	if (format_bridge == NULL) {
-		dev_dbg(isp->dev, "atomisp_get_format_bridge err! fmt:0x%x\n",
-				f->fmt.pix.pixelformat);
-		return -EINVAL;
-	}
-
-	pipe->pix = f->fmt.pix;
-	atomisp_css_input_set_mode(asd, CSS_INPUT_MODE_FIFO);
-	atomisp_css_input_configure_port(asd,
-		__get_mipi_port(isp, ATOMISP_CAMERA_PORT_PRIMARY), 2, 0xffff4,
-		0, 0, 0, 0);
-	ffmt.width = f->fmt.pix.width;
-	ffmt.height = f->fmt.pix.height;
-	ffmt.code = format_bridge->mbus_code;
-
-	atomisp_subdev_set_ffmt(&asd->subdev, fh.pad, V4L2_SUBDEV_FORMAT_ACTIVE,
-				ATOMISP_SUBDEV_PAD_SINK, &ffmt);
-
-	return 0;
-}
-
-int atomisp_set_shading_table(struct atomisp_sub_device *asd,
-		struct atomisp_shading_table *user_shading_table)
-{
-	struct atomisp_css_shading_table *shading_table;
-	struct atomisp_css_shading_table *free_table;
-	unsigned int len_table;
-	int i;
-	int ret = 0;
-
-	if (!user_shading_table)
-		return -EINVAL;
-
-	if (!user_shading_table->enable) {
-		atomisp_css_set_shading_table(asd, NULL);
-		asd->params.sc_en = false;
-		return 0;
-	}
-
-	/* If enabling, all tables must be set */
-	for (i = 0; i < ATOMISP_NUM_SC_COLORS; i++) {
-		if (!user_shading_table->data[i])
-			return -EINVAL;
-	}
-
-	/* Shading table size per color */
-	if (user_shading_table->width > SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR ||
-	    user_shading_table->height > SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR)
-		return -EINVAL;
-
-	shading_table = atomisp_css_shading_table_alloc(
-			user_shading_table->width, user_shading_table->height);
-	if (!shading_table)
-		return -ENOMEM;
-
-	len_table = user_shading_table->width * user_shading_table->height *
-		    ATOMISP_SC_TYPE_SIZE;
-	for (i = 0; i < ATOMISP_NUM_SC_COLORS; i++) {
-		ret = copy_from_user(shading_table->data[i],
-				     (void __user *)user_shading_table->data[i],
-				     len_table);
-		if (ret) {
-			free_table = shading_table;
-			ret = -EFAULT;
-			goto out;
-		}
-	}
-	shading_table->sensor_width = user_shading_table->sensor_width;
-	shading_table->sensor_height = user_shading_table->sensor_height;
-	shading_table->fraction_bits = user_shading_table->fraction_bits;
-
-	free_table = asd->params.css_param.shading_table;
-	asd->params.css_param.shading_table = shading_table;
-	atomisp_css_set_shading_table(asd, shading_table);
-	asd->params.sc_en = true;
-
-out:
-	if (free_table != NULL)
-		atomisp_css_shading_table_free(free_table);
-
-	return ret;
-}
-
-/*Turn off ISP dphy */
-int atomisp_ospm_dphy_down(struct atomisp_device *isp)
-{
-	unsigned long flags;
-	u32 reg;
-
-	dev_dbg(isp->dev, "%s\n", __func__);
-
-	/* if ISP timeout, we can force powerdown */
-	if (isp->isp_timeout)
-		goto done;
-
-	if (!atomisp_dev_users(isp))
-		goto done;
-
-	spin_lock_irqsave(&isp->lock, flags);
-	isp->sw_contex.power_state = ATOM_ISP_POWER_DOWN;
-	spin_unlock_irqrestore(&isp->lock, flags);
-done:
-	/*
-	 * MRFLD IUNIT DPHY is located in an always-power-on island
-	 * MRFLD HW design need all CSI ports are disabled before
-	 * powering down the IUNIT.
-	 */
-	pci_read_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, &reg);
-	reg |= MRFLD_ALL_CSI_PORTS_OFF_MASK;
-	pci_write_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, reg);
-	return 0;
-}
-
-/*Turn on ISP dphy */
-int atomisp_ospm_dphy_up(struct atomisp_device *isp)
-{
-	unsigned long flags;
-	dev_dbg(isp->dev, "%s\n", __func__);
-
-	spin_lock_irqsave(&isp->lock, flags);
-	isp->sw_contex.power_state = ATOM_ISP_POWER_UP;
-	spin_unlock_irqrestore(&isp->lock, flags);
-
-	return 0;
-}
-
-
-int atomisp_exif_makernote(struct atomisp_sub_device *asd,
-			   struct atomisp_makernote_info *config)
-{
-	struct v4l2_control ctrl;
-	struct atomisp_device *isp = asd->isp;
-
-	ctrl.id = V4L2_CID_FOCAL_ABSOLUTE;
-	if (v4l2_g_ctrl
-	    (isp->inputs[asd->input_curr].camera->ctrl_handler, &ctrl)) {
-		dev_warn(isp->dev, "failed to g_ctrl for focal length\n");
-		return -EINVAL;
-	} else {
-		config->focal_length = ctrl.value;
-	}
-
-	ctrl.id = V4L2_CID_FNUMBER_ABSOLUTE;
-	if (v4l2_g_ctrl
-	    (isp->inputs[asd->input_curr].camera->ctrl_handler, &ctrl)) {
-		dev_warn(isp->dev, "failed to g_ctrl for f-number\n");
-		return -EINVAL;
-	} else {
-		config->f_number_curr = ctrl.value;
-	}
-
-	ctrl.id = V4L2_CID_FNUMBER_RANGE;
-	if (v4l2_g_ctrl
-	    (isp->inputs[asd->input_curr].camera->ctrl_handler, &ctrl)) {
-		dev_warn(isp->dev, "failed to g_ctrl for f number range\n");
-		return -EINVAL;
-	} else {
-		config->f_number_range = ctrl.value;
-	}
-
-	return 0;
-}
-
-int atomisp_offline_capture_configure(struct atomisp_sub_device *asd,
-			      struct atomisp_cont_capture_conf *cvf_config)
-{
-	struct v4l2_ctrl *c;
-
-	/*
-	* In case of M10MO ZSL capture case, we need to issue a separate
-	* capture request to M10MO which will output captured jpeg image
-	*/
-	c = v4l2_ctrl_find(
-		asd->isp->inputs[asd->input_curr].camera->ctrl_handler,
-		V4L2_CID_START_ZSL_CAPTURE);
-	if (c) {
-		int ret;
-		dev_dbg(asd->isp->dev, "%s trigger ZSL capture request\n",
-			__func__);
-		/* TODO: use the cvf_config */
-		ret = v4l2_ctrl_s_ctrl(c, 1);
-		if (ret)
-			return ret;
-
-		return v4l2_ctrl_s_ctrl(c, 0);
-	}
-
-	asd->params.offline_parm = *cvf_config;
-
-	if (asd->params.offline_parm.num_captures) {
-		if (asd->streaming == ATOMISP_DEVICE_STREAMING_DISABLED) {
-			unsigned int init_raw_num;
-
-			if (asd->enable_raw_buffer_lock->val) {
-				init_raw_num =
-					ATOMISP_CSS2_NUM_OFFLINE_INIT_CONTINUOUS_FRAMES_LOCK_EN;
-				if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO &&
-				    asd->params.video_dis_en)
-					init_raw_num +=
-					    ATOMISP_CSS2_NUM_DVS_FRAME_DELAY;
-			} else {
-				init_raw_num =
-					ATOMISP_CSS2_NUM_OFFLINE_INIT_CONTINUOUS_FRAMES;
-			}
-
-			/* TODO: this can be removed once user-space
-			 *       has been updated to use control API */
-			asd->continuous_raw_buffer_size->val =
-				max_t(int,
-				      asd->continuous_raw_buffer_size->val,
-				      asd->params.offline_parm.
-				      num_captures + init_raw_num);
-			asd->continuous_raw_buffer_size->val =
-				min_t(int, ATOMISP_CONT_RAW_FRAMES,
-				      asd->continuous_raw_buffer_size->val);
-		}
-		asd->continuous_mode->val = true;
-	} else {
-		asd->continuous_mode->val = false;
-		__enable_continuous_mode(asd, false);
-	}
-
-	return 0;
-}
-
-/*
- * set auto exposure metering window to camera sensor
- */
-int atomisp_s_ae_window(struct atomisp_sub_device *asd,
-			struct atomisp_ae_window *arg)
-{
-	struct atomisp_device *isp = asd->isp;
-	/* Coverity CID 298071 - initialzize struct */
-	struct v4l2_subdev_selection sel = { 0 };
-
-	sel.r.left = arg->x_left;
-	sel.r.top = arg->y_top;
-	sel.r.width = arg->x_right - arg->x_left + 1;
-	sel.r.height = arg->y_bottom - arg->y_top + 1;
-
-	if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-			     pad, set_selection, NULL, &sel)) {
-		dev_err(isp->dev, "failed to call sensor set_selection.\n");
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-int atomisp_flash_enable(struct atomisp_sub_device *asd, int num_frames)
-{
-	struct atomisp_device *isp = asd->isp;
-
-	if (num_frames < 0) {
-		dev_dbg(isp->dev, "%s ERROR: num_frames: %d\n", __func__,
-				num_frames);
-		return -EINVAL;
-	}
-	/* a requested flash is still in progress. */
-	if (num_frames && asd->params.flash_state != ATOMISP_FLASH_IDLE) {
-		dev_dbg(isp->dev, "%s flash busy: %d frames left: %d\n",
-				__func__, asd->params.flash_state,
-				asd->params.num_flash_frames);
-		return -EBUSY;
-	}
-
-	asd->params.num_flash_frames = num_frames;
-	asd->params.flash_state = ATOMISP_FLASH_REQUESTED;
-	return 0;
-}
-
-int atomisp_source_pad_to_stream_id(struct atomisp_sub_device *asd,
-					   uint16_t source_pad)
-{
-	int stream_id;
-	struct atomisp_device *isp = asd->isp;
-
-	if (isp->inputs[asd->input_curr].camera_caps->
-			sensor[asd->sensor_curr].stream_num == 1)
-		return ATOMISP_INPUT_STREAM_GENERAL;
-
-	switch (source_pad) {
-	case ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE:
-		stream_id = ATOMISP_INPUT_STREAM_CAPTURE;
-		break;
-	case ATOMISP_SUBDEV_PAD_SOURCE_VF:
-		stream_id = ATOMISP_INPUT_STREAM_POSTVIEW;
-		break;
-	case ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW:
-		stream_id = ATOMISP_INPUT_STREAM_PREVIEW;
-		break;
-	case ATOMISP_SUBDEV_PAD_SOURCE_VIDEO:
-		stream_id = ATOMISP_INPUT_STREAM_VIDEO;
-		break;
-	default:
-		stream_id = ATOMISP_INPUT_STREAM_GENERAL;
-	}
-
-	return stream_id;
-}
-
-bool atomisp_is_vf_pipe(struct atomisp_video_pipe *pipe)
-{
-	struct atomisp_sub_device *asd = pipe->asd;
-
-	if (pipe == &asd->video_out_vf)
-		return true;
-
-	if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO &&
-	    pipe == &asd->video_out_preview)
-		return true;
-
-	return false;
-}
-
-static int __checking_exp_id(struct atomisp_sub_device *asd, int exp_id)
-{
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->enable_raw_buffer_lock->val) {
-		dev_warn(isp->dev, "%s Raw Buffer Lock is disable.\n", __func__);
-		return -EINVAL;
-	}
-	if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED) {
-		dev_err(isp->dev, "%s streaming %d invalid exp_id %d.\n",
-			__func__, exp_id, asd->streaming);
-		return -EINVAL;
-	}
-	if ((exp_id > ATOMISP_MAX_EXP_ID) || (exp_id <= 0)) {
-		dev_err(isp->dev, "%s exp_id %d invalid.\n", __func__, exp_id);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-void atomisp_init_raw_buffer_bitmap(struct atomisp_sub_device *asd)
-{
-	unsigned long flags;
-	spin_lock_irqsave(&asd->raw_buffer_bitmap_lock, flags);
-	memset(asd->raw_buffer_bitmap, 0, sizeof(asd->raw_buffer_bitmap));
-	asd->raw_buffer_locked_count = 0;
-	spin_unlock_irqrestore(&asd->raw_buffer_bitmap_lock, flags);
-}
-
-int atomisp_set_raw_buffer_bitmap(struct atomisp_sub_device *asd, int exp_id)
-{
-	int *bitmap, bit;
-	unsigned long flags;
-
-	if (__checking_exp_id(asd, exp_id))
-		return -EINVAL;
-
-	bitmap = asd->raw_buffer_bitmap + exp_id / 32;
-	bit = exp_id % 32;
-	spin_lock_irqsave(&asd->raw_buffer_bitmap_lock, flags);
-	(*bitmap) |= (1 << bit);
-	asd->raw_buffer_locked_count++;
-	spin_unlock_irqrestore(&asd->raw_buffer_bitmap_lock, flags);
-
-	dev_dbg(asd->isp->dev, "%s: exp_id %d,  raw_buffer_locked_count %d\n",
-		__func__, exp_id, asd->raw_buffer_locked_count);
-
-	/* Check if the raw buffer after next is still locked!!! */
-	exp_id += 2;
-	if (exp_id > ATOMISP_MAX_EXP_ID)
-		exp_id -= ATOMISP_MAX_EXP_ID;
-	bitmap = asd->raw_buffer_bitmap + exp_id / 32;
-	bit = exp_id % 32;
-	if ((*bitmap) & (1 << bit)) {
-		int ret;
-
-		/* WORKAROUND unlock the raw buffer compulsively */
-		ret = atomisp_css_exp_id_unlock(asd, exp_id);
-		if (ret) {
-			dev_err(asd->isp->dev, "%s exp_id is wrapping back to %d but force unlock failed,, err %d.\n",
-				__func__, exp_id, ret);
-			return ret;
-		}
-
-		spin_lock_irqsave(&asd->raw_buffer_bitmap_lock, flags);
-		(*bitmap) &= ~(1 << bit);
-		asd->raw_buffer_locked_count--;
-		spin_unlock_irqrestore(&asd->raw_buffer_bitmap_lock, flags);
-		dev_warn(asd->isp->dev, "%s exp_id is wrapping back to %d but it is still locked so force unlock it, raw_buffer_locked_count %d\n",
-			__func__, exp_id, asd->raw_buffer_locked_count);
-	}
-	return 0;
-}
-
-static int __is_raw_buffer_locked(struct atomisp_sub_device *asd, int exp_id)
-{
-	int *bitmap, bit;
-	unsigned long flags;
-	int ret;
-
-	if (__checking_exp_id(asd, exp_id))
-		return -EINVAL;
-
-	bitmap = asd->raw_buffer_bitmap + exp_id / 32;
-	bit = exp_id % 32;
-	spin_lock_irqsave(&asd->raw_buffer_bitmap_lock, flags);
-	ret = ((*bitmap) & (1 << bit));
-	spin_unlock_irqrestore(&asd->raw_buffer_bitmap_lock, flags);
-	return !ret;
-}
-
-static int __clear_raw_buffer_bitmap(struct atomisp_sub_device *asd, int exp_id)
-{
-	int *bitmap, bit;
-	unsigned long flags;
-
-	if (__is_raw_buffer_locked(asd, exp_id))
-		return -EINVAL;
-
-	bitmap = asd->raw_buffer_bitmap + exp_id / 32;
-	bit = exp_id % 32;
-	spin_lock_irqsave(&asd->raw_buffer_bitmap_lock, flags);
-	(*bitmap) &= ~(1 << bit);
-	asd->raw_buffer_locked_count--;
-	spin_unlock_irqrestore(&asd->raw_buffer_bitmap_lock, flags);
-
-	dev_dbg(asd->isp->dev, "%s: exp_id %d,  raw_buffer_locked_count %d\n",
-		__func__, exp_id, asd->raw_buffer_locked_count);
-	return 0;
-}
-
-int atomisp_exp_id_capture(struct atomisp_sub_device *asd, int *exp_id)
-{
-	struct atomisp_device *isp = asd->isp;
-	int value = *exp_id;
-	int ret;
-
-	ret = __is_raw_buffer_locked(asd, value);
-	if (ret) {
-		dev_err(isp->dev, "%s exp_id %d invalid %d.\n", __func__, value, ret);
-		return -EINVAL;
-	}
-
-	dev_dbg(isp->dev, "%s exp_id %d\n", __func__, value);
-	ret = atomisp_css_exp_id_capture(asd, value);
-	if (ret) {
-		dev_err(isp->dev, "%s exp_id %d failed.\n", __func__, value);
-		return -EIO;
-	}
-	return 0;
-}
-
-int atomisp_exp_id_unlock(struct atomisp_sub_device *asd, int *exp_id)
-{
-	struct atomisp_device *isp = asd->isp;
-	int value = *exp_id;
-	int ret;
-
-	ret = __clear_raw_buffer_bitmap(asd, value);
-	if (ret) {
-		dev_err(isp->dev, "%s exp_id %d invalid %d.\n", __func__, value, ret);
-		return -EINVAL;
-	}
-
-	dev_dbg(isp->dev, "%s exp_id %d\n", __func__, value);
-	ret = atomisp_css_exp_id_unlock(asd, value);
-	if (ret)
-		dev_err(isp->dev, "%s exp_id %d failed, err %d.\n",
-			__func__, value, ret);
-
-	return ret;
-}
-
-int atomisp_enable_dz_capt_pipe(struct atomisp_sub_device *asd,
-					   unsigned int *enable)
-{
-	bool value;
-
-	if (enable == NULL)
-		return -EINVAL;
-
-	value = *enable > 0 ? true : false;
-
-	atomisp_en_dz_capt_pipe(asd, value);
-
-	return 0;
-}
-
-int atomisp_inject_a_fake_event(struct atomisp_sub_device *asd, int *event)
-{
-	if (!event || asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
-		return -EINVAL;
-
-	dev_dbg(asd->isp->dev, "%s: trying to inject a fake event 0x%x\n",
-		__func__, *event);
-
-	switch (*event) {
-	case V4L2_EVENT_FRAME_SYNC:
-		atomisp_sof_event(asd);
-		break;
-	case V4L2_EVENT_FRAME_END:
-		atomisp_eof_event(asd, 0);
-		break;
-	case V4L2_EVENT_ATOMISP_3A_STATS_READY:
-		atomisp_3a_stats_ready_event(asd, 0);
-		break;
-	case V4L2_EVENT_ATOMISP_METADATA_READY:
-		atomisp_metadata_ready_event(asd, 0);
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static int atomisp_get_pipe_id(struct atomisp_video_pipe *pipe)
-{
-	struct atomisp_sub_device *asd = pipe->asd;
-
-	if (ATOMISP_USE_YUVPP(asd))
-		return CSS_PIPE_ID_YUVPP;
-	else if (asd->vfpp->val == ATOMISP_VFPP_DISABLE_SCALER)
-		return CSS_PIPE_ID_VIDEO;
-	else if (asd->vfpp->val == ATOMISP_VFPP_DISABLE_LOWLAT)
-		return CSS_PIPE_ID_CAPTURE;
-	else if (pipe == &asd->video_out_video_capture)
-		return CSS_PIPE_ID_VIDEO;
-	else if (pipe == &asd->video_out_vf)
-		return CSS_PIPE_ID_CAPTURE;
-	else if (pipe == &asd->video_out_preview) {
-		if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO)
-			return CSS_PIPE_ID_VIDEO;
-		else
-			return CSS_PIPE_ID_PREVIEW;
-	} else if (pipe == &asd->video_out_capture) {
-		if (asd->copy_mode)
-			return IA_CSS_PIPE_ID_COPY;
-		else
-			return CSS_PIPE_ID_CAPTURE;
-	}
-
-	/* fail through */
-	dev_warn(asd->isp->dev, "%s failed to find proper pipe\n",
-		__func__);
-	return CSS_PIPE_ID_CAPTURE;
-}
-
-int atomisp_get_invalid_frame_num(struct video_device *vdev,
-					int *invalid_frame_num)
-{
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-	struct atomisp_sub_device *asd = pipe->asd;
-	enum atomisp_css_pipe_id pipe_id;
-	struct ia_css_pipe_info p_info;
-	int ret;
-
-	if (asd->isp->inputs[asd->input_curr].camera_caps->
-		sensor[asd->sensor_curr].stream_num > 1) {
-		/* External ISP */
-		*invalid_frame_num = 0;
-		return 0;
-	}
-
-	pipe_id = atomisp_get_pipe_id(pipe);
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].pipes[pipe_id]) {
-		dev_warn(asd->isp->dev, "%s pipe %d has not been created yet, do SET_FMT first!\n",
-			__func__, pipe_id);
-		return -EINVAL;
-	}
-
-	ret = ia_css_pipe_get_info(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.pipes[pipe_id], &p_info);
-	if (ret == IA_CSS_SUCCESS) {
-		*invalid_frame_num = p_info.num_invalid_frames;
-		return 0;
-	} else {
-		dev_warn(asd->isp->dev, "%s get pipe infor failed %d\n",
-			 __func__, ret);
-		return -EINVAL;
-	}
-}

+ 0 - 446
drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h

@@ -1,446 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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	__ATOMISP_CMD_H__
-#define	__ATOMISP_CMD_H__
-
-#include "../../include/linux/atomisp.h"
-#include <linux/interrupt.h>
-#include <linux/videodev2.h>
-
-#include <media/v4l2-subdev.h>
-
-#include "atomisp_internal.h"
-
-#include "ia_css_types.h"
-#include "ia_css.h"
-
-struct atomisp_device;
-struct atomisp_css_frame;
-
-#define MSI_ENABLE_BIT		16
-#define INTR_DISABLE_BIT	10
-#define BUS_MASTER_ENABLE	2
-#define MEMORY_SPACE_ENABLE	1
-#define INTR_IER		24
-#define INTR_IIR		16
-#ifdef ISP2401
-#define RUNMODE_MASK (ATOMISP_RUN_MODE_VIDEO | ATOMISP_RUN_MODE_STILL_CAPTURE \
-			| ATOMISP_RUN_MODE_PREVIEW)
-
-/* FIXME: check if can go */
-extern int atomisp_punit_hpll_freq;
-#endif
-
-/*
- * Helper function
- */
-void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
-		  unsigned int size);
-struct camera_mipi_info *atomisp_to_sensor_mipi_info(struct v4l2_subdev *sd);
-struct atomisp_video_pipe *atomisp_to_video_pipe(struct video_device *dev);
-struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct video_device *dev);
-int atomisp_reset(struct atomisp_device *isp);
-void atomisp_flush_bufs_and_wakeup(struct atomisp_sub_device *asd);
-void atomisp_clear_css_buffer_counters(struct atomisp_sub_device *asd);
-#ifndef ISP2401
-bool atomisp_buffers_queued(struct atomisp_sub_device *asd);
-#else
-bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe);
-#endif
-
-/* TODO:should be here instead of atomisp_helper.h
-extern void __iomem *atomisp_io_base;
-
-static inline void __iomem *atomisp_get_io_virt_addr(unsigned int address)
-{
-	void __iomem *ret = atomisp_io_base + (address & 0x003FFFFF);
-	return ret;
-}
-*/
-
-/*
- * Interrupt functions
- */
-void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev);
-void atomisp_msi_irq_uninit(struct atomisp_device *isp, struct pci_dev *dev);
-void atomisp_wdt_work(struct work_struct *work);
-void atomisp_wdt(struct timer_list *t);
-void atomisp_setup_flash(struct atomisp_sub_device *asd);
-irqreturn_t atomisp_isr(int irq, void *dev);
-irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr);
-const struct atomisp_format_bridge *get_atomisp_format_bridge_from_mbus(
-	u32 mbus_code);
-bool atomisp_is_mbuscode_raw(uint32_t code);
-int atomisp_get_frame_pgnr(struct atomisp_device *isp,
-			   const struct atomisp_css_frame *frame, u32 *p_pgnr);
-void atomisp_delayed_init_work(struct work_struct *work);
-
-/*
- * Get internal fmt according to V4L2 fmt
- */
-
-bool atomisp_is_viewfinder_support(struct atomisp_device *isp);
-
-/*
- * ISP features control function
- */
-
-/*
-#ifdef ISP2401
- * Function to set sensor runmode by user when
- * ATOMISP_IOC_S_SENSOR_RUNMODE ioctl was called
- */
-int atomisp_set_sensor_runmode(struct atomisp_sub_device *asd,
-		struct atomisp_s_runmode *runmode);
-/*
-#endif
- * Function to enable/disable lens geometry distortion correction (GDC) and
- * chromatic aberration correction (CAC)
- */
-int atomisp_gdc_cac(struct atomisp_sub_device *asd, int flag,
-		    __s32 *value);
-
-/*
- * Function to enable/disable low light mode (including ANR)
- */
-int atomisp_low_light(struct atomisp_sub_device *asd, int flag,
-		      __s32 *value);
-
-/*
- * Function to enable/disable extra noise reduction (XNR) in low light
- * condition
- */
-int atomisp_xnr(struct atomisp_sub_device *asd, int flag, int *arg);
-
-int atomisp_formats(struct atomisp_sub_device *asd, int flag,
-		struct atomisp_formats_config *config);
-
-/*
- * Function to configure noise reduction
- */
-int atomisp_nr(struct atomisp_sub_device *asd, int flag,
-	       struct atomisp_nr_config *config);
-
-/*
- * Function to configure temporal noise reduction (TNR)
- */
-int atomisp_tnr(struct atomisp_sub_device *asd, int flag,
-		struct atomisp_tnr_config *config);
-
-/*
- * Function to configure black level compensation
- */
-int atomisp_black_level(struct atomisp_sub_device *asd, int flag,
-			struct atomisp_ob_config *config);
-
-/*
- * Function to configure edge enhancement
- */
-int atomisp_ee(struct atomisp_sub_device *asd, int flag,
-	       struct atomisp_ee_config *config);
-
-/*
- * Function to update Gamma table for gamma, brightness and contrast config
- */
-int atomisp_gamma(struct atomisp_sub_device *asd, int flag,
-		  struct atomisp_gamma_table *config);
-/*
- * Function to update Ctc table for Chroma Enhancement
- */
-int atomisp_ctc(struct atomisp_sub_device *asd, int flag,
-		struct atomisp_ctc_table *config);
-
-/*
- * Function to update gamma correction parameters
- */
-int atomisp_gamma_correction(struct atomisp_sub_device *asd, int flag,
-	struct atomisp_gc_config *config);
-
-/*
- * Function to update Gdc table for gdc
- */
-int atomisp_gdc_cac_table(struct atomisp_sub_device *asd, int flag,
-			  struct atomisp_morph_table *config);
-
-/*
- * Function to update table for macc
- */
-int atomisp_macc_table(struct atomisp_sub_device *asd, int flag,
-		       struct atomisp_macc_config *config);
-/*
- * Function to get DIS statistics.
- */
-int atomisp_get_dis_stat(struct atomisp_sub_device *asd,
-			 struct atomisp_dis_statistics *stats);
-
-/*
- * Function to get DVS2 BQ resolution settings
- */
-int atomisp_get_dvs2_bq_resolutions(struct atomisp_sub_device *asd,
-			 struct atomisp_dvs2_bq_resolutions *bq_res);
-
-/*
- * Function to set the DIS coefficients.
- */
-int atomisp_set_dis_coefs(struct atomisp_sub_device *asd,
-			  struct atomisp_dis_coefficients *coefs);
-
-/*
- * Function to set the DIS motion vector.
- */
-int atomisp_set_dis_vector(struct atomisp_sub_device *asd,
-			   struct atomisp_dis_vector *vector);
-
-/*
- * Function to set/get 3A stat from isp
- */
-int atomisp_3a_stat(struct atomisp_sub_device *asd, int flag,
-		    struct atomisp_3a_statistics *config);
-
-/*
- * Function to get metadata from isp
- */
-int atomisp_get_metadata(struct atomisp_sub_device *asd, int flag,
-			 struct atomisp_metadata *config);
-
-int atomisp_get_metadata_by_type(struct atomisp_sub_device *asd, int flag,
-			 struct atomisp_metadata_with_type *config);
-
-int atomisp_set_parameters(struct video_device *vdev,
-			struct atomisp_parameters *arg);
-/*
- * Function to set/get isp parameters to isp
- */
-int atomisp_param(struct atomisp_sub_device *asd, int flag,
-		  struct atomisp_parm *config);
-
-/*
- * Function to configure color effect of the image
- */
-int atomisp_color_effect(struct atomisp_sub_device *asd, int flag,
-			 __s32 *effect);
-
-/*
- * Function to configure bad pixel correction
- */
-int atomisp_bad_pixel(struct atomisp_sub_device *asd, int flag,
-		      __s32 *value);
-
-/*
- * Function to configure bad pixel correction params
- */
-int atomisp_bad_pixel_param(struct atomisp_sub_device *asd, int flag,
-			    struct atomisp_dp_config *config);
-
-/*
- * Function to enable/disable video image stablization
- */
-int atomisp_video_stable(struct atomisp_sub_device *asd, int flag,
-			 __s32 *value);
-
-/*
- * Function to configure fixed pattern noise
- */
-int atomisp_fixed_pattern(struct atomisp_sub_device *asd, int flag,
-			  __s32 *value);
-
-/*
- * Function to configure fixed pattern noise table
- */
-int atomisp_fixed_pattern_table(struct atomisp_sub_device *asd,
-				struct v4l2_framebuffer *config);
-
-/*
- * Function to configure false color correction
- */
-int atomisp_false_color(struct atomisp_sub_device *asd, int flag,
-			__s32 *value);
-
-/*
- * Function to configure false color correction params
- */
-int atomisp_false_color_param(struct atomisp_sub_device *asd, int flag,
-			      struct atomisp_de_config *config);
-
-/*
- * Function to configure white balance params
- */
-int atomisp_white_balance_param(struct atomisp_sub_device *asd, int flag,
-				struct atomisp_wb_config *config);
-
-int atomisp_3a_config_param(struct atomisp_sub_device *asd, int flag,
-			    struct atomisp_3a_config *config);
-
-/*
- * Function to setup digital zoom
- */
-int atomisp_digital_zoom(struct atomisp_sub_device *asd, int flag,
-			 __s32 *value);
-
-/*
- * Function  set camera_prefiles.xml current sensor pixel array size
- */
-int atomisp_set_array_res(struct atomisp_sub_device *asd,
-			struct atomisp_resolution  *config);
-
-/*
- * Function to calculate real zoom region for every pipe
- */
-int atomisp_calculate_real_zoom_region(struct atomisp_sub_device *asd,
-			struct atomisp_css_dz_config   *dz_config,
-			enum atomisp_css_pipe_id css_pipe_id);
-
-int atomisp_cp_general_isp_parameters(struct atomisp_sub_device *asd,
-				      struct atomisp_parameters *arg,
-				      struct atomisp_css_params *css_param,
-				      bool from_user);
-
-int atomisp_cp_lsc_table(struct atomisp_sub_device *asd,
-			 struct atomisp_shading_table *source_st,
-			 struct atomisp_css_params *css_param,
-			 bool from_user);
-
-int atomisp_css_cp_dvs2_coefs(struct atomisp_sub_device *asd,
-			      struct ia_css_dvs2_coefficients *coefs,
-			      struct atomisp_css_params *css_param,
-			      bool from_user);
-
-int atomisp_cp_morph_table(struct atomisp_sub_device *asd,
-			   struct atomisp_morph_table *source_morph_table,
-			   struct atomisp_css_params *css_param,
-			   bool from_user);
-
-int atomisp_cp_dvs_6axis_config(struct atomisp_sub_device *asd,
-			struct atomisp_dvs_6axis_config *user_6axis_config,
-			struct atomisp_css_params *css_param,
-			bool from_user);
-
-int atomisp_makeup_css_parameters(struct atomisp_sub_device *asd,
-				  struct atomisp_parameters *arg,
-				  struct atomisp_css_params *css_param);
-
-int atomisp_compare_grid(struct atomisp_sub_device *asd,
-				struct atomisp_grid_info *atomgrid);
-
-int atomisp_get_sensor_mode_data(struct atomisp_sub_device *asd,
-				 struct atomisp_sensor_mode_data *config);
-
-int atomisp_get_fmt(struct video_device *vdev, struct v4l2_format *f);
-
-
-/* This function looks up the closest available resolution. */
-int atomisp_try_fmt(struct video_device *vdev, struct v4l2_format *f,
-						bool *res_overflow);
-
-int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f);
-int atomisp_set_fmt_file(struct video_device *vdev, struct v4l2_format *f);
-
-int atomisp_set_shading_table(struct atomisp_sub_device *asd,
-			      struct atomisp_shading_table *shading_table);
-
-int atomisp_offline_capture_configure(struct atomisp_sub_device *asd,
-				struct atomisp_cont_capture_conf *cvf_config);
-
-int atomisp_ospm_dphy_down(struct atomisp_device *isp);
-int atomisp_ospm_dphy_up(struct atomisp_device *isp);
-int atomisp_exif_makernote(struct atomisp_sub_device *asd,
-			   struct atomisp_makernote_info *config);
-
-void atomisp_free_internal_buffers(struct atomisp_sub_device *asd);
-
-int atomisp_s_ae_window(struct atomisp_sub_device *asd,
-			struct atomisp_ae_window *arg);
-
-int  atomisp_flash_enable(struct atomisp_sub_device *asd,
-			  int num_frames);
-
-int atomisp_freq_scaling(struct atomisp_device *vdev,
-			 enum atomisp_dfs_mode mode,
-			 bool force);
-
-void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
-		      enum atomisp_css_buffer_type buf_type,
-		      enum atomisp_css_pipe_id css_pipe_id,
-		      bool q_buffers, enum atomisp_input_stream_id stream_id);
-
-void atomisp_css_flush(struct atomisp_device *isp);
-int atomisp_source_pad_to_stream_id(struct atomisp_sub_device *asd,
-					   uint16_t source_pad);
-
-/*
- * Events. Only one event has to be exported for now.
- */
-void atomisp_eof_event(struct atomisp_sub_device *asd, uint8_t exp_id);
-
-enum mipi_port_id __get_mipi_port(struct atomisp_device *isp,
-				enum atomisp_camera_port port);
-
-bool atomisp_is_vf_pipe(struct atomisp_video_pipe *pipe);
-
-void atomisp_apply_css_parameters(
-				struct atomisp_sub_device *asd,
-				struct atomisp_css_params *css_param);
-void atomisp_free_css_parameters(struct atomisp_css_params *css_param);
-
-void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe);
-
-void atomisp_flush_params_queue(struct atomisp_video_pipe *asd);
-/*
- * Function to do Raw Buffer related operation, after enable Lock Unlock Raw Buffer
- */
-int atomisp_exp_id_unlock(struct atomisp_sub_device *asd, int *exp_id);
-int atomisp_exp_id_capture(struct atomisp_sub_device *asd, int *exp_id);
-
-/*
- * Function to update Raw Buffer bitmap
- */
-int atomisp_set_raw_buffer_bitmap(struct atomisp_sub_device *asd, int exp_id);
-void atomisp_init_raw_buffer_bitmap(struct atomisp_sub_device *asd);
-
-/*
- * Function to enable/disable zoom for capture pipe
- */
-int atomisp_enable_dz_capt_pipe(struct atomisp_sub_device *asd,
-					   unsigned int *enable);
-
-/*
- * Function to get metadata type bu pipe id
- */
-enum atomisp_metadata_type
-atomisp_get_metadata_type(struct atomisp_sub_device *asd,
-			  enum ia_css_pipe_id pipe_id);
-
-/*
- * Function for HAL to inject a fake event to wake up poll thread
- */
-int atomisp_inject_a_fake_event(struct atomisp_sub_device *asd, int *event);
-
-/*
- * Function for HAL to query how many invalid frames at the beginning of ISP
- * pipeline output
- */
-int atomisp_get_invalid_frame_num(struct video_device *vdev,
-			int *invalid_frame_num);
-
-int atomisp_mrfld_power_up(struct atomisp_device *isp);
-int atomisp_mrfld_power_down(struct atomisp_device *isp);
-int atomisp_runtime_suspend(struct device *dev);
-int atomisp_runtime_resume(struct device *dev);
-#endif /* __ATOMISP_CMD_H__ */

+ 0 - 75
drivers/staging/media/atomisp/pci/atomisp2/atomisp_common.h

@@ -1,75 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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	__ATOMISP_COMMON_H__
-#define	__ATOMISP_COMMON_H__
-
-#include "../../include/linux/atomisp.h"
-
-#include <linux/v4l2-mediabus.h>
-
-#include <media/videobuf-core.h>
-
-#include "atomisp_compat.h"
-
-#include "ia_css.h"
-
-extern int dbg_level;
-extern int dbg_func;
-extern int mipicsi_flag;
-extern int pad_w;
-extern int pad_h;
-
-#define CSS_DTRACE_VERBOSITY_LEVEL	5	/* Controls trace verbosity */
-#define CSS_DTRACE_VERBOSITY_TIMEOUT	9	/* Verbosity on ISP timeout */
-#define MRFLD_MAX_ZOOM_FACTOR	1024
-#ifdef ISP2401
-#define ATOMISP_CSS_ISP_PIPE_VERSION_2_2    0
-#define ATOMISP_CSS_ISP_PIPE_VERSION_2_7    1
-#endif
-
-#define IS_ISP2401(isp)							\
-	(((isp)->media_dev.hw_revision & ATOMISP_HW_REVISION_MASK)	\
-	 >= (ATOMISP_HW_REVISION_ISP2401_LEGACY << ATOMISP_HW_REVISION_SHIFT))
-
-struct atomisp_format_bridge {
-	unsigned int pixelformat;
-	unsigned int depth;
-	u32 mbus_code;
-	enum atomisp_css_frame_format sh_fmt;
-	unsigned char description[32];	/* the same as struct v4l2_fmtdesc */
-	bool planar;
-};
-
-struct atomisp_fmt {
-	u32 pixelformat;
-	u32 depth;
-	u32 bytesperline;
-	u32 framesize;
-	u32 imagesize;
-	u32 width;
-	u32 height;
-	u32 bayer_order;
-};
-
-struct atomisp_buffer {
-	struct videobuf_buffer	vb;
-};
-
-#endif

+ 0 - 662
drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat.h

@@ -1,662 +0,0 @@
-/*
- * Support for Clovertrail PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
- *
- * 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 __ATOMISP_COMPAT_H__
-#define __ATOMISP_COMPAT_H__
-
-#include "atomisp_compat_css20.h"
-
-#include "../../include/linux/atomisp.h"
-#include <media/videobuf-vmalloc.h>
-
-#define CSS_RX_IRQ_INFO_BUFFER_OVERRUN \
-	CSS_ID(CSS_RX_IRQ_INFO_BUFFER_OVERRUN)
-#define CSS_RX_IRQ_INFO_ENTER_SLEEP_MODE \
-	CSS_ID(CSS_RX_IRQ_INFO_ENTER_SLEEP_MODE)
-#define CSS_RX_IRQ_INFO_EXIT_SLEEP_MODE \
-	CSS_ID(CSS_RX_IRQ_INFO_EXIT_SLEEP_MODE)
-#define CSS_RX_IRQ_INFO_ECC_CORRECTED \
-	CSS_ID(CSS_RX_IRQ_INFO_ECC_CORRECTED)
-#define CSS_RX_IRQ_INFO_ERR_SOT \
-	CSS_ID(CSS_RX_IRQ_INFO_ERR_SOT)
-#define CSS_RX_IRQ_INFO_ERR_SOT_SYNC \
-	CSS_ID(CSS_RX_IRQ_INFO_ERR_SOT_SYNC)
-#define CSS_RX_IRQ_INFO_ERR_CONTROL \
-	CSS_ID(CSS_RX_IRQ_INFO_ERR_CONTROL)
-#define CSS_RX_IRQ_INFO_ERR_ECC_DOUBLE \
-	CSS_ID(CSS_RX_IRQ_INFO_ERR_ECC_DOUBLE)
-#define CSS_RX_IRQ_INFO_ERR_CRC \
-	CSS_ID(CSS_RX_IRQ_INFO_ERR_CRC)
-#define CSS_RX_IRQ_INFO_ERR_UNKNOWN_ID \
-	CSS_ID(CSS_RX_IRQ_INFO_ERR_UNKNOWN_ID)
-#define CSS_RX_IRQ_INFO_ERR_FRAME_SYNC \
-	CSS_ID(CSS_RX_IRQ_INFO_ERR_FRAME_SYNC)
-#define CSS_RX_IRQ_INFO_ERR_FRAME_DATA \
-	CSS_ID(CSS_RX_IRQ_INFO_ERR_FRAME_DATA)
-#define CSS_RX_IRQ_INFO_ERR_DATA_TIMEOUT \
-	CSS_ID(CSS_RX_IRQ_INFO_ERR_DATA_TIMEOUT)
-#define CSS_RX_IRQ_INFO_ERR_UNKNOWN_ESC \
-	CSS_ID(CSS_RX_IRQ_INFO_ERR_UNKNOWN_ESC)
-#define CSS_RX_IRQ_INFO_ERR_LINE_SYNC \
-	CSS_ID(CSS_RX_IRQ_INFO_ERR_LINE_SYNC)
-#define CSS_RX_IRQ_INFO_INIT_TIMEOUT \
-	CSS_ID(CSS_RX_IRQ_INFO_INIT_TIMEOUT)
-
-#define CSS_IRQ_INFO_CSS_RECEIVER_SOF	CSS_ID(CSS_IRQ_INFO_CSS_RECEIVER_SOF)
-#define CSS_IRQ_INFO_CSS_RECEIVER_EOF	CSS_ID(CSS_IRQ_INFO_CSS_RECEIVER_EOF)
-#define CSS_IRQ_INFO_CSS_RECEIVER_FIFO_OVERFLOW \
-	CSS_ID(CSS_IRQ_INFO_CSS_RECEIVER_FIFO_OVERFLOW)
-#define CSS_EVENT_OUTPUT_FRAME_DONE	CSS_EVENT(OUTPUT_FRAME_DONE)
-#define CSS_EVENT_SEC_OUTPUT_FRAME_DONE	CSS_EVENT(SECOND_OUTPUT_FRAME_DONE)
-#define CSS_EVENT_VF_OUTPUT_FRAME_DONE	CSS_EVENT(VF_OUTPUT_FRAME_DONE)
-#define CSS_EVENT_SEC_VF_OUTPUT_FRAME_DONE	CSS_EVENT(SECOND_VF_OUTPUT_FRAME_DONE)
-#define CSS_EVENT_3A_STATISTICS_DONE	CSS_EVENT(3A_STATISTICS_DONE)
-#define CSS_EVENT_DIS_STATISTICS_DONE	CSS_EVENT(DIS_STATISTICS_DONE)
-#define CSS_EVENT_PIPELINE_DONE		CSS_EVENT(PIPELINE_DONE)
-#define CSS_EVENT_METADATA_DONE		CSS_EVENT(METADATA_DONE)
-#define CSS_EVENT_ACC_STAGE_COMPLETE	CSS_EVENT(ACC_STAGE_COMPLETE)
-#define CSS_EVENT_TIMER			CSS_EVENT(TIMER)
-
-#define CSS_BUFFER_TYPE_METADATA	CSS_ID(CSS_BUFFER_TYPE_METADATA)
-#define CSS_BUFFER_TYPE_3A_STATISTICS	CSS_ID(CSS_BUFFER_TYPE_3A_STATISTICS)
-#define CSS_BUFFER_TYPE_DIS_STATISTICS	CSS_ID(CSS_BUFFER_TYPE_DIS_STATISTICS)
-#define CSS_BUFFER_TYPE_INPUT_FRAME	CSS_ID(CSS_BUFFER_TYPE_INPUT_FRAME)
-#define CSS_BUFFER_TYPE_OUTPUT_FRAME	CSS_ID(CSS_BUFFER_TYPE_OUTPUT_FRAME)
-#define CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME	CSS_ID(CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME)
-#define CSS_BUFFER_TYPE_VF_OUTPUT_FRAME	CSS_ID(CSS_BUFFER_TYPE_VF_OUTPUT_FRAME)
-#define CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME	CSS_ID(CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME)
-#define CSS_BUFFER_TYPE_RAW_OUTPUT_FRAME \
-	CSS_ID(CSS_BUFFER_TYPE_RAW_OUTPUT_FRAME)
-
-#define CSS_FORMAT_RAW_8	CSS_FORMAT(RAW_8)
-#define CSS_FORMAT_RAW_10	CSS_FORMAT(RAW_10)
-#define CSS_FORMAT_RAW_12	CSS_FORMAT(RAW_12)
-#define CSS_FORMAT_RAW_16	CSS_FORMAT(RAW_16)
-
-#define CSS_CAPTURE_MODE_RAW		CSS_ID(CSS_CAPTURE_MODE_RAW)
-#define CSS_CAPTURE_MODE_BAYER		CSS_ID(CSS_CAPTURE_MODE_BAYER)
-#define CSS_CAPTURE_MODE_PRIMARY	CSS_ID(CSS_CAPTURE_MODE_PRIMARY)
-#define CSS_CAPTURE_MODE_ADVANCED	CSS_ID(CSS_CAPTURE_MODE_ADVANCED)
-#define CSS_CAPTURE_MODE_LOW_LIGHT	CSS_ID(CSS_CAPTURE_MODE_LOW_LIGHT)
-
-#define CSS_MORPH_TABLE_NUM_PLANES	CSS_ID(CSS_MORPH_TABLE_NUM_PLANES)
-
-#define CSS_FRAME_FORMAT_NV11		CSS_ID(CSS_FRAME_FORMAT_NV11)
-#define CSS_FRAME_FORMAT_NV12		CSS_ID(CSS_FRAME_FORMAT_NV12)
-#define CSS_FRAME_FORMAT_NV16		CSS_ID(CSS_FRAME_FORMAT_NV16)
-#define CSS_FRAME_FORMAT_NV21		CSS_ID(CSS_FRAME_FORMAT_NV21)
-#define CSS_FRAME_FORMAT_NV61		CSS_ID(CSS_FRAME_FORMAT_NV61)
-#define CSS_FRAME_FORMAT_YV12		CSS_ID(CSS_FRAME_FORMAT_YV12)
-#define CSS_FRAME_FORMAT_YV16		CSS_ID(CSS_FRAME_FORMAT_YV16)
-#define CSS_FRAME_FORMAT_YUV420		CSS_ID(CSS_FRAME_FORMAT_YUV420)
-#define CSS_FRAME_FORMAT_YUV420_16	CSS_ID(CSS_FRAME_FORMAT_YUV420_16)
-#define CSS_FRAME_FORMAT_YUV422		CSS_ID(CSS_FRAME_FORMAT_YUV422)
-#define CSS_FRAME_FORMAT_YUV422_16	CSS_ID(CSS_FRAME_FORMAT_YUV422_16)
-#define CSS_FRAME_FORMAT_UYVY		CSS_ID(CSS_FRAME_FORMAT_UYVY)
-#define CSS_FRAME_FORMAT_YUYV		CSS_ID(CSS_FRAME_FORMAT_YUYV)
-#define CSS_FRAME_FORMAT_YUV444		CSS_ID(CSS_FRAME_FORMAT_YUV444)
-#define CSS_FRAME_FORMAT_YUV_LINE	CSS_ID(CSS_FRAME_FORMAT_YUV_LINE)
-#define CSS_FRAME_FORMAT_RAW		CSS_ID(CSS_FRAME_FORMAT_RAW)
-#define CSS_FRAME_FORMAT_RGB565		CSS_ID(CSS_FRAME_FORMAT_RGB565)
-#define CSS_FRAME_FORMAT_PLANAR_RGB888	CSS_ID(CSS_FRAME_FORMAT_PLANAR_RGB888)
-#define CSS_FRAME_FORMAT_RGBA888	CSS_ID(CSS_FRAME_FORMAT_RGBA888)
-#define CSS_FRAME_FORMAT_QPLANE6	CSS_ID(CSS_FRAME_FORMAT_QPLANE6)
-#define CSS_FRAME_FORMAT_BINARY_8	CSS_ID(CSS_FRAME_FORMAT_BINARY_8)
-
-struct atomisp_device;
-struct atomisp_sub_device;
-struct video_device;
-enum atomisp_input_stream_id;
-
-struct atomisp_metadata_buf {
-	struct ia_css_metadata *metadata;
-	void *md_vptr;
-	struct list_head list;
-};
-
-void atomisp_css_debug_dump_sp_sw_debug_info(void);
-void atomisp_css_debug_dump_debug_info(const char *context);
-void atomisp_css_debug_set_dtrace_level(const unsigned int trace_level);
-
-void atomisp_store_uint32(hrt_address addr, uint32_t data);
-void atomisp_load_uint32(hrt_address addr, uint32_t *data);
-
-int atomisp_css_init(struct atomisp_device *isp);
-
-void atomisp_css_uninit(struct atomisp_device *isp);
-
-void atomisp_css_suspend(struct atomisp_device *isp);
-
-int atomisp_css_resume(struct atomisp_device *isp);
-
-void atomisp_css_init_struct(struct atomisp_sub_device *asd);
-
-int atomisp_css_irq_translate(struct atomisp_device *isp,
-			      unsigned int *infos);
-
-void atomisp_css_rx_get_irq_info(enum mipi_port_id port,
-					unsigned int *infos);
-
-void atomisp_css_rx_clear_irq_info(enum mipi_port_id port,
-					unsigned int infos);
-
-int atomisp_css_irq_enable(struct atomisp_device *isp,
-			   enum atomisp_css_irq_info info, bool enable);
-
-int atomisp_q_video_buffer_to_css(struct atomisp_sub_device *asd,
-			struct videobuf_vmalloc_memory *vm_mem,
-			enum atomisp_input_stream_id stream_id,
-			enum atomisp_css_buffer_type css_buf_type,
-			enum atomisp_css_pipe_id css_pipe_id);
-
-int atomisp_q_s3a_buffer_to_css(struct atomisp_sub_device *asd,
-			struct atomisp_s3a_buf *s3a_buf,
-			enum atomisp_input_stream_id stream_id,
-			enum atomisp_css_pipe_id css_pipe_id);
-
-int atomisp_q_metadata_buffer_to_css(struct atomisp_sub_device *asd,
-			struct atomisp_metadata_buf *metadata_buf,
-			enum atomisp_input_stream_id stream_id,
-			enum atomisp_css_pipe_id css_pipe_id);
-
-int atomisp_q_dis_buffer_to_css(struct atomisp_sub_device *asd,
-			struct atomisp_dis_buf *dis_buf,
-			enum atomisp_input_stream_id stream_id,
-			enum atomisp_css_pipe_id css_pipe_id);
-
-void atomisp_css_mmu_invalidate_cache(void);
-
-void atomisp_css_mmu_invalidate_tlb(void);
-
-int atomisp_css_start(struct atomisp_sub_device *asd,
-		      enum atomisp_css_pipe_id pipe_id, bool in_reset);
-
-void atomisp_css_update_isp_params(struct atomisp_sub_device *asd);
-void atomisp_css_update_isp_params_on_pipe(struct atomisp_sub_device *asd,
-					struct ia_css_pipe *pipe);
-
-int atomisp_css_queue_buffer(struct atomisp_sub_device *asd,
-			     enum atomisp_input_stream_id stream_id,
-			     enum atomisp_css_pipe_id pipe_id,
-			     enum atomisp_css_buffer_type buf_type,
-			     struct atomisp_css_buffer *isp_css_buffer);
-
-int atomisp_css_dequeue_buffer(struct atomisp_sub_device *asd,
-				enum atomisp_input_stream_id stream_id,
-				enum atomisp_css_pipe_id pipe_id,
-				enum atomisp_css_buffer_type buf_type,
-				struct atomisp_css_buffer *isp_css_buffer);
-
-int atomisp_css_allocate_stat_buffers(struct atomisp_sub_device *asd,
-				      uint16_t stream_id,
-				      struct atomisp_s3a_buf *s3a_buf,
-				      struct atomisp_dis_buf *dis_buf,
-				      struct atomisp_metadata_buf *md_buf);
-
-void atomisp_css_free_stat_buffers(struct atomisp_sub_device *asd);
-
-void atomisp_css_free_3a_buffer(struct atomisp_s3a_buf *s3a_buf);
-
-void atomisp_css_free_dis_buffer(struct atomisp_dis_buf *dis_buf);
-
-void atomisp_css_free_metadata_buffer(struct atomisp_metadata_buf *metadata_buf);
-
-int atomisp_css_get_grid_info(struct atomisp_sub_device *asd,
-				enum atomisp_css_pipe_id pipe_id,
-				int source_pad);
-
-int atomisp_alloc_3a_output_buf(struct atomisp_sub_device *asd);
-
-int atomisp_alloc_dis_coef_buf(struct atomisp_sub_device *asd);
-
-int atomisp_alloc_metadata_output_buf(struct atomisp_sub_device *asd);
-
-void atomisp_free_metadata_output_buf(struct atomisp_sub_device *asd);
-
-void atomisp_css_get_dis_statistics(struct atomisp_sub_device *asd,
-				    struct atomisp_css_buffer *isp_css_buffer,
-				    struct ia_css_isp_dvs_statistics_map *dvs_map);
-
-int atomisp_css_dequeue_event(struct atomisp_css_event *current_event);
-
-void atomisp_css_temp_pipe_to_pipe_id(struct atomisp_sub_device *asd,
-				      struct atomisp_css_event *current_event);
-
-int atomisp_css_isys_set_resolution(struct atomisp_sub_device *asd,
-				    enum atomisp_input_stream_id stream_id,
-				    struct v4l2_mbus_framefmt *ffmt,
-				    int isys_stream);
-
-void atomisp_css_isys_set_link(struct atomisp_sub_device *asd,
-			       enum atomisp_input_stream_id stream_id,
-			       int link,
-			       int isys_stream);
-
-void atomisp_css_isys_set_valid(struct atomisp_sub_device *asd,
-				enum atomisp_input_stream_id stream_id,
-				bool valid,
-				int isys_stream);
-
-void atomisp_css_isys_set_format(struct atomisp_sub_device *asd,
-				 enum atomisp_input_stream_id stream_id,
-				 enum atomisp_input_format format,
-				 int isys_stream);
-
-int atomisp_css_set_default_isys_config(struct atomisp_sub_device *asd,
-					enum atomisp_input_stream_id stream_id,
-					struct v4l2_mbus_framefmt *ffmt);
-
-int atomisp_css_isys_two_stream_cfg(struct atomisp_sub_device *asd,
-				    enum atomisp_input_stream_id stream_id,
-				    enum atomisp_input_format input_format);
-
-void atomisp_css_isys_two_stream_cfg_update_stream1(
-				    struct atomisp_sub_device *asd,
-				    enum atomisp_input_stream_id stream_id,
-				    enum atomisp_input_format input_format,
-				    unsigned int width, unsigned int height);
-
-void atomisp_css_isys_two_stream_cfg_update_stream2(
-				    struct atomisp_sub_device *asd,
-				    enum atomisp_input_stream_id stream_id,
-				    enum atomisp_input_format input_format,
-				    unsigned int width, unsigned int height);
-
-int atomisp_css_input_set_resolution(struct atomisp_sub_device *asd,
-					enum atomisp_input_stream_id stream_id,
-					struct v4l2_mbus_framefmt *ffmt);
-
-void atomisp_css_input_set_binning_factor(struct atomisp_sub_device *asd,
-					enum atomisp_input_stream_id stream_id,
-					unsigned int bin_factor);
-
-void atomisp_css_input_set_bayer_order(struct atomisp_sub_device *asd,
-				enum atomisp_input_stream_id stream_id,
-				enum atomisp_css_bayer_order bayer_order);
-
-void atomisp_css_input_set_format(struct atomisp_sub_device *asd,
-				enum atomisp_input_stream_id stream_id,
-				enum atomisp_input_format format);
-
-int atomisp_css_input_set_effective_resolution(
-					struct atomisp_sub_device *asd,
-					enum atomisp_input_stream_id stream_id,
-					unsigned int width,
-					unsigned int height);
-
-void atomisp_css_video_set_dis_envelope(struct atomisp_sub_device *asd,
-					unsigned int dvs_w, unsigned int dvs_h);
-
-void atomisp_css_input_set_two_pixels_per_clock(
-					struct atomisp_sub_device *asd,
-					bool two_ppc);
-
-void atomisp_css_enable_raw_binning(struct atomisp_sub_device *asd,
-					bool enable);
-
-void atomisp_css_enable_dz(struct atomisp_sub_device *asd, bool enable);
-
-void atomisp_css_capture_set_mode(struct atomisp_sub_device *asd,
-				enum atomisp_css_capture_mode mode);
-
-void atomisp_css_input_set_mode(struct atomisp_sub_device *asd,
-				enum atomisp_css_input_mode mode);
-
-void atomisp_css_capture_enable_online(struct atomisp_sub_device *asd,
-				unsigned short stream_index, bool enable);
-
-void atomisp_css_preview_enable_online(struct atomisp_sub_device *asd,
-				unsigned short stream_index, bool enable);
-
-void atomisp_css_video_enable_online(struct atomisp_sub_device *asd,
-							bool enable);
-
-void atomisp_css_enable_continuous(struct atomisp_sub_device *asd,
-							bool enable);
-
-void atomisp_css_enable_cvf(struct atomisp_sub_device *asd,
-							bool enable);
-
-int atomisp_css_input_configure_port(struct atomisp_sub_device *asd,
-				enum mipi_port_id port,
-				unsigned int num_lanes,
-				unsigned int timeout,
-				unsigned int mipi_freq,
-				enum atomisp_input_format metadata_format,
-				unsigned int metadata_width,
-				unsigned int metadata_height);
-
-int atomisp_css_frame_allocate(struct atomisp_css_frame **frame,
-				unsigned int width, unsigned int height,
-				enum atomisp_css_frame_format format,
-				unsigned int padded_width,
-				unsigned int raw_bit_depth);
-
-int atomisp_css_frame_allocate_from_info(struct atomisp_css_frame **frame,
-				const struct atomisp_css_frame_info *info);
-
-void atomisp_css_frame_free(struct atomisp_css_frame *frame);
-
-int atomisp_css_frame_map(struct atomisp_css_frame **frame,
-				const struct atomisp_css_frame_info *info,
-				const void __user *data, uint16_t attribute,
-				void *context);
-
-int atomisp_css_set_black_frame(struct atomisp_sub_device *asd,
-			const struct atomisp_css_frame *raw_black_frame);
-
-int atomisp_css_allocate_continuous_frames(bool init_time,
-			struct atomisp_sub_device *asd);
-
-void atomisp_css_update_continuous_frames(struct atomisp_sub_device *asd);
-
-void atomisp_create_pipes_stream(struct atomisp_sub_device *asd);
-void atomisp_destroy_pipes_stream_force(struct atomisp_sub_device *asd);
-
-int atomisp_css_stop(struct atomisp_sub_device *asd,
-			enum atomisp_css_pipe_id pipe_id, bool in_reset);
-
-int atomisp_css_continuous_set_num_raw_frames(
-					struct atomisp_sub_device *asd,
-					int num_frames);
-
-void atomisp_css_disable_vf_pp(struct atomisp_sub_device *asd,
-			       bool disable);
-
-int atomisp_css_copy_configure_output(struct atomisp_sub_device *asd,
-				unsigned int stream_index,
-				unsigned int width, unsigned int height,
-				unsigned int padded_width,
-				enum atomisp_css_frame_format format);
-
-int atomisp_css_yuvpp_configure_output(struct atomisp_sub_device *asd,
-				unsigned int stream_index,
-				unsigned int width, unsigned int height,
-				unsigned int padded_width,
-				enum atomisp_css_frame_format format);
-
-int atomisp_css_yuvpp_configure_viewfinder(
-				struct atomisp_sub_device *asd,
-				unsigned int stream_index,
-				unsigned int width, unsigned int height,
-				unsigned int min_width,
-				enum atomisp_css_frame_format format);
-
-int atomisp_css_yuvpp_get_output_frame_info(
-					struct atomisp_sub_device *asd,
-					unsigned int stream_index,
-					struct atomisp_css_frame_info *info);
-
-int atomisp_css_yuvpp_get_viewfinder_frame_info(
-					struct atomisp_sub_device *asd,
-					unsigned int stream_index,
-					struct atomisp_css_frame_info *info);
-
-int atomisp_css_preview_configure_output(struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height,
-				unsigned int min_width,
-				enum atomisp_css_frame_format format);
-
-int atomisp_css_capture_configure_output(struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height,
-				unsigned int min_width,
-				enum atomisp_css_frame_format format);
-
-int atomisp_css_video_configure_output(struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height,
-				unsigned int min_width,
-				enum atomisp_css_frame_format format);
-
-int atomisp_get_css_frame_info(struct atomisp_sub_device *asd,
-				uint16_t source_pad,
-				struct atomisp_css_frame_info *frame_info);
-
-int atomisp_css_video_configure_viewfinder(struct atomisp_sub_device *asd,
-					unsigned int width, unsigned int height,
-					unsigned int min_width,
-					enum atomisp_css_frame_format format);
-
-int atomisp_css_capture_configure_viewfinder(
-					struct atomisp_sub_device *asd,
-					unsigned int width, unsigned int height,
-					unsigned int min_width,
-					enum atomisp_css_frame_format format);
-
-int atomisp_css_video_get_viewfinder_frame_info(
-					struct atomisp_sub_device *asd,
-					struct atomisp_css_frame_info *info);
-
-int atomisp_css_capture_get_viewfinder_frame_info(
-					struct atomisp_sub_device *asd,
-					struct atomisp_css_frame_info *info);
-
-int atomisp_css_copy_get_output_frame_info(
-					struct atomisp_sub_device *asd,
-					unsigned int stream_index,
-					struct atomisp_css_frame_info *info);
-
-int atomisp_css_capture_get_output_raw_frame_info(
-					struct atomisp_sub_device *asd,
-					struct atomisp_css_frame_info *info);
-
-int atomisp_css_preview_get_output_frame_info(
-					struct atomisp_sub_device *asd,
-					struct atomisp_css_frame_info *info);
-
-int atomisp_css_capture_get_output_frame_info(
-					struct atomisp_sub_device *asd,
-					struct atomisp_css_frame_info *info);
-
-int atomisp_css_video_get_output_frame_info(
-					struct atomisp_sub_device *asd,
-					struct atomisp_css_frame_info *info);
-
-int atomisp_css_preview_configure_pp_input(
-				struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height);
-
-int atomisp_css_capture_configure_pp_input(
-				struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height);
-
-int atomisp_css_video_configure_pp_input(
-				struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height);
-
-int atomisp_css_offline_capture_configure(struct atomisp_sub_device *asd,
-			int num_captures, unsigned int skip, int offset);
-int atomisp_css_exp_id_capture(struct atomisp_sub_device *asd, int exp_id);
-int atomisp_css_exp_id_unlock(struct atomisp_sub_device *asd, int exp_id);
-
-int atomisp_css_capture_enable_xnr(struct atomisp_sub_device *asd,
-				   bool enable);
-
-void atomisp_css_send_input_frame(struct atomisp_sub_device *asd,
-				  unsigned short *data, unsigned int width,
-				  unsigned int height);
-
-bool atomisp_css_isp_has_started(void);
-
-void atomisp_css_request_flash(struct atomisp_sub_device *asd);
-
-void atomisp_css_set_wb_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_wb_config *wb_config);
-
-void atomisp_css_set_ob_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_ob_config *ob_config);
-
-void atomisp_css_set_dp_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_dp_config *dp_config);
-
-void atomisp_css_set_de_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_de_config *de_config);
-
-void atomisp_css_set_dz_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_dz_config *dz_config);
-
-void atomisp_css_set_default_de_config(struct atomisp_sub_device *asd);
-
-void atomisp_css_set_ce_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_ce_config *ce_config);
-
-void atomisp_css_set_nr_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_nr_config *nr_config);
-
-void atomisp_css_set_ee_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_ee_config *ee_config);
-
-void atomisp_css_set_tnr_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_tnr_config *tnr_config);
-
-void atomisp_css_set_cc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_cc_config *cc_config);
-
-void atomisp_css_set_macc_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_macc_table *macc_table);
-
-void atomisp_css_set_gamma_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_gamma_table *gamma_table);
-
-void atomisp_css_set_ctc_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_ctc_table *ctc_table);
-
-void atomisp_css_set_gc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_gc_config *gc_config);
-
-void atomisp_css_set_3a_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_3a_config *s3a_config);
-
-void atomisp_css_video_set_dis_vector(struct atomisp_sub_device *asd,
-				struct atomisp_dis_vector *vector);
-
-void atomisp_css_set_dvs2_coefs(struct atomisp_sub_device *asd,
-				struct ia_css_dvs2_coefficients *coefs);
-
-int atomisp_css_set_dis_coefs(struct atomisp_sub_device *asd,
-			  struct atomisp_dis_coefficients *coefs);
-
-void atomisp_css_set_zoom_factor(struct atomisp_sub_device *asd,
-					unsigned int zoom);
-
-int atomisp_css_get_wb_config(struct atomisp_sub_device *asd,
-			struct atomisp_wb_config *config);
-
-int atomisp_css_get_ob_config(struct atomisp_sub_device *asd,
-			struct atomisp_ob_config *config);
-
-int atomisp_css_get_dp_config(struct atomisp_sub_device *asd,
-			struct atomisp_dp_config *config);
-
-int atomisp_css_get_de_config(struct atomisp_sub_device *asd,
-			struct atomisp_de_config *config);
-
-int atomisp_css_get_nr_config(struct atomisp_sub_device *asd,
-			struct atomisp_nr_config *config);
-
-int atomisp_css_get_ee_config(struct atomisp_sub_device *asd,
-			struct atomisp_ee_config *config);
-
-int atomisp_css_get_tnr_config(struct atomisp_sub_device *asd,
-			struct atomisp_tnr_config *config);
-
-int atomisp_css_get_ctc_table(struct atomisp_sub_device *asd,
-			struct atomisp_ctc_table *config);
-
-int atomisp_css_get_gamma_table(struct atomisp_sub_device *asd,
-			struct atomisp_gamma_table *config);
-
-int atomisp_css_get_gc_config(struct atomisp_sub_device *asd,
-			struct atomisp_gc_config *config);
-
-int atomisp_css_get_3a_config(struct atomisp_sub_device *asd,
-			struct atomisp_3a_config *config);
-
-int atomisp_css_get_formats_config(struct atomisp_sub_device *asd,
-			struct atomisp_formats_config *formats_config);
-
-void atomisp_css_set_formats_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_formats_config *formats_config);
-
-int atomisp_css_get_zoom_factor(struct atomisp_sub_device *asd,
-					unsigned int *zoom);
-
-struct atomisp_css_shading_table *atomisp_css_shading_table_alloc(
-				unsigned int width, unsigned int height);
-
-void atomisp_css_set_shading_table(struct atomisp_sub_device *asd,
-				struct atomisp_css_shading_table *table);
-
-void atomisp_css_shading_table_free(struct atomisp_css_shading_table *table);
-
-struct atomisp_css_morph_table *atomisp_css_morph_table_allocate(
-				unsigned int width, unsigned int height);
-
-void atomisp_css_set_morph_table(struct atomisp_sub_device *asd,
-				struct atomisp_css_morph_table *table);
-
-void atomisp_css_get_morph_table(struct atomisp_sub_device *asd,
-				struct atomisp_css_morph_table *table);
-
-void atomisp_css_morph_table_free(struct atomisp_css_morph_table *table);
-
-void atomisp_css_set_cont_prev_start_time(struct atomisp_device *isp,
-					unsigned int overlap);
-
-int atomisp_css_get_dis_stat(struct atomisp_sub_device *asd,
-			 struct atomisp_dis_statistics *stats);
-
-int atomisp_css_update_stream(struct atomisp_sub_device *asd);
-
-int atomisp_css_create_acc_pipe(struct atomisp_sub_device *asd);
-
-int atomisp_css_start_acc_pipe(struct atomisp_sub_device *asd);
-
-int atomisp_css_stop_acc_pipe(struct atomisp_sub_device *asd);
-
-void atomisp_css_destroy_acc_pipe(struct atomisp_sub_device *asd);
-
-int atomisp_css_load_acc_extension(struct atomisp_sub_device *asd,
-					struct atomisp_css_fw_info *fw,
-					enum atomisp_css_pipe_id pipe_id,
-					unsigned int type);
-
-void atomisp_css_unload_acc_extension(struct atomisp_sub_device *asd,
-					struct atomisp_css_fw_info *fw,
-					enum atomisp_css_pipe_id pipe_id);
-
-int atomisp_css_wait_acc_finish(struct atomisp_sub_device *asd);
-
-void atomisp_css_acc_done(struct atomisp_sub_device *asd);
-
-int atomisp_css_load_acc_binary(struct atomisp_sub_device *asd,
-					struct atomisp_css_fw_info *fw,
-					unsigned int index);
-
-void atomisp_css_unload_acc_binary(struct atomisp_sub_device *asd);
-
-struct atomisp_acc_fw;
-int atomisp_css_set_acc_parameters(struct atomisp_acc_fw *acc_fw);
-
-int atomisp_css_isr_thread(struct atomisp_device *isp,
-			   bool *frame_done_found,
-			   bool *css_pipe_done);
-
-bool atomisp_css_valid_sof(struct atomisp_device *isp);
-
-void atomisp_en_dz_capt_pipe(struct atomisp_sub_device *asd, bool enable);
-
-#endif

+ 0 - 4704
drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c

@@ -1,4704 +0,0 @@
-/*
- * Support for Clovertrail PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- *
- */
-
-#include <media/videobuf-vmalloc.h>
-#include <media/v4l2-dev.h>
-#include <media/v4l2-event.h>
-
-#include "mmu/isp_mmu.h"
-#include "mmu/sh_mmu_mrfld.h"
-#include "hmm/hmm_bo.h"
-#include "hmm/hmm.h"
-
-#include "atomisp_compat.h"
-#include "atomisp_internal.h"
-#include "atomisp_cmd.h"
-#include "atomisp-regs.h"
-#include "atomisp_fops.h"
-#include "atomisp_ioctl.h"
-#include "atomisp_acc.h"
-
-#include "hrt/hive_isp_css_mm_hrt.h"
-
-#include <asm/intel-mid.h>
-
-#include "ia_css_debug.h"
-#include "ia_css_isp_param.h"
-#include "sh_css_hrt.h"
-#include "ia_css_isys.h"
-
-#include <linux/pm_runtime.h>
-
-/* Assume max number of ACC stages */
-#define MAX_ACC_STAGES	20
-
-/* Ideally, this should come from CSS headers */
-#define NO_LINK -1
-
-/*
- * to serialize MMIO access , this is due to ISP2400 silicon issue Sighting
- * #4684168, if concurrency access happened, system may hard hang.
- */
-static DEFINE_SPINLOCK(mmio_lock);
-
-enum frame_info_type {
-	ATOMISP_CSS_VF_FRAME,
-	ATOMISP_CSS_SECOND_VF_FRAME,
-	ATOMISP_CSS_OUTPUT_FRAME,
-	ATOMISP_CSS_SECOND_OUTPUT_FRAME,
-	ATOMISP_CSS_RAW_FRAME,
-};
-
-struct bayer_ds_factor {
-	unsigned int numerator;
-	unsigned int denominator;
-};
-
-void atomisp_css_debug_dump_sp_sw_debug_info(void)
-{
-	ia_css_debug_dump_sp_sw_debug_info();
-}
-
-void atomisp_css_debug_dump_debug_info(const char *context)
-{
-	ia_css_debug_dump_debug_info(context);
-}
-
-void atomisp_css_debug_set_dtrace_level(const unsigned int trace_level)
-{
-	ia_css_debug_set_dtrace_level(trace_level);
-}
-
-unsigned int atomisp_css_debug_get_dtrace_level(void)
-{
-	return ia_css_debug_trace_level;
-}
-
-static void atomisp_css2_hw_store_8(hrt_address addr, uint8_t data)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&mmio_lock, flags);
-	_hrt_master_port_store_8(addr, data);
-	spin_unlock_irqrestore(&mmio_lock, flags);
-}
-
-static void atomisp_css2_hw_store_16(hrt_address addr, uint16_t data)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&mmio_lock, flags);
-	_hrt_master_port_store_16(addr, data);
-	spin_unlock_irqrestore(&mmio_lock, flags);
-}
-
-static void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&mmio_lock, flags);
-	_hrt_master_port_store_32(addr, data);
-	spin_unlock_irqrestore(&mmio_lock, flags);
-}
-
-static uint8_t atomisp_css2_hw_load_8(hrt_address addr)
-{
-	unsigned long flags;
-	uint8_t ret;
-
-	spin_lock_irqsave(&mmio_lock, flags);
-	ret = _hrt_master_port_load_8(addr);
-	spin_unlock_irqrestore(&mmio_lock, flags);
-	return ret;
-}
-
-static uint16_t atomisp_css2_hw_load_16(hrt_address addr)
-{
-	unsigned long flags;
-	uint16_t ret;
-
-	spin_lock_irqsave(&mmio_lock, flags);
-	ret = _hrt_master_port_load_16(addr);
-	spin_unlock_irqrestore(&mmio_lock, flags);
-	return ret;
-}
-
-static uint32_t atomisp_css2_hw_load_32(hrt_address addr)
-{
-	unsigned long flags;
-	uint32_t ret;
-
-	spin_lock_irqsave(&mmio_lock, flags);
-	ret = _hrt_master_port_load_32(addr);
-	spin_unlock_irqrestore(&mmio_lock, flags);
-	return ret;
-}
-
-static void atomisp_css2_hw_store(hrt_address addr,
-				  const void *from, uint32_t n)
-{
-	unsigned long flags;
-	unsigned int i;
-	unsigned int _to = (unsigned int)addr;
-	const char *_from = (const char *)from;
-
-	spin_lock_irqsave(&mmio_lock, flags);
-	for (i = 0; i < n; i++, _to++, _from++)
-		_hrt_master_port_store_8(_to , *_from);
-	spin_unlock_irqrestore(&mmio_lock, flags);
-}
-
-static void atomisp_css2_hw_load(hrt_address addr, void *to, uint32_t n)
-{
-	unsigned long flags;
-	unsigned int i;
-	char *_to = (char *)to;
-	unsigned int _from = (unsigned int)addr;
-
-	spin_lock_irqsave(&mmio_lock, flags);
-	for (i = 0; i < n; i++, _to++, _from++)
-		*_to = _hrt_master_port_load_8(_from);
-	spin_unlock_irqrestore(&mmio_lock, flags);
-}
-
-static int atomisp_css2_dbg_print(const char *fmt, va_list args)
-{
-	vprintk(fmt, args);
-	return 0;
-}
-
-static int atomisp_css2_dbg_ftrace_print(const char *fmt, va_list args)
-{
-	ftrace_vprintk(fmt, args);
-	return 0;
-}
-
-static int atomisp_css2_err_print(const char *fmt, va_list args)
-{
-	vprintk(fmt, args);
-	return 0;
-}
-
-void atomisp_store_uint32(hrt_address addr, uint32_t data)
-{
-	atomisp_css2_hw_store_32(addr, data);
-}
-
-void atomisp_load_uint32(hrt_address addr, uint32_t *data)
-{
-	*data = atomisp_css2_hw_load_32(addr);
-}
-static int hmm_get_mmu_base_addr(unsigned int *mmu_base_addr)
-{
-	if (sh_mmu_mrfld.get_pd_base == NULL) {
-		dev_err(atomisp_dev, "get mmu base address failed.\n");
-		return -EINVAL;
-	}
-
-	*mmu_base_addr = sh_mmu_mrfld.get_pd_base(&bo_device.mmu,
-					bo_device.mmu.base_address);
-	return 0;
-}
-
-static void atomisp_isp_parameters_clean_up(
-				struct atomisp_css_isp_config *config)
-{
-	/*
-	 * Set NULL to configs pointer to avoid they are set into isp again when
-	 * some configs are changed and need to be updated later.
-	 */
-	memset(config, 0, sizeof(*config));
-}
-
-static void __dump_pipe_config(struct atomisp_sub_device *asd,
-			       struct atomisp_stream_env *stream_env,
-			       unsigned int pipe_id)
-{
-	struct atomisp_device *isp = asd->isp;
-
-	if (stream_env->pipes[pipe_id]) {
-		struct ia_css_pipe_config *p_config;
-		struct ia_css_pipe_extra_config *pe_config;
-
-		p_config = &stream_env->pipe_configs[pipe_id];
-		pe_config = &stream_env->pipe_extra_configs[pipe_id];
-		dev_dbg(isp->dev, "dumping pipe[%d] config:\n", pipe_id);
-		dev_dbg(isp->dev,
-			 "pipe_config.pipe_mode:%d.\n", p_config->mode);
-		dev_dbg(isp->dev,
-			 "pipe_config.output_info[0] w=%d, h=%d.\n",
-			 p_config->output_info[0].res.width,
-			 p_config->output_info[0].res.height);
-		dev_dbg(isp->dev,
-			 "pipe_config.vf_pp_in_res w=%d, h=%d.\n",
-			 p_config->vf_pp_in_res.width,
-			 p_config->vf_pp_in_res.height);
-		dev_dbg(isp->dev,
-			 "pipe_config.capt_pp_in_res w=%d, h=%d.\n",
-			 p_config->capt_pp_in_res.width,
-			 p_config->capt_pp_in_res.height);
-		dev_dbg(isp->dev,
-			 "pipe_config.output.padded w=%d.\n",
-			 p_config->output_info[0].padded_width);
-		dev_dbg(isp->dev,
-			 "pipe_config.vf_output_info[0] w=%d, h=%d.\n",
-			 p_config->vf_output_info[0].res.width,
-			 p_config->vf_output_info[0].res.height);
-		dev_dbg(isp->dev,
-			 "pipe_config.bayer_ds_out_res w=%d, h=%d.\n",
-			 p_config->bayer_ds_out_res.width,
-			 p_config->bayer_ds_out_res.height);
-		dev_dbg(isp->dev,
-			 "pipe_config.envelope w=%d, h=%d.\n",
-			 p_config->dvs_envelope.width,
-			 p_config->dvs_envelope.height);
-		dev_dbg(isp->dev,
-			 "pipe_config.dvs_frame_delay=%d.\n",
-			 p_config->dvs_frame_delay);
-		dev_dbg(isp->dev,
-			 "pipe_config.isp_pipe_version:%d.\n",
-			p_config->isp_pipe_version);
-		dev_dbg(isp->dev,
-			 "pipe_config.acc_extension=%p.\n",
-			 p_config->acc_extension);
-		dev_dbg(isp->dev,
-			 "pipe_config.acc_stages=%p.\n",
-			 p_config->acc_stages);
-		dev_dbg(isp->dev,
-			 "pipe_config.num_acc_stages=%d.\n",
-			 p_config->num_acc_stages);
-		dev_dbg(isp->dev,
-			 "pipe_config.acc_num_execs=%d.\n",
-			 p_config->acc_num_execs);
-		dev_dbg(isp->dev,
-			 "pipe_config.default_capture_config.capture_mode=%d.\n",
-			 p_config->default_capture_config.mode);
-		dev_dbg(isp->dev,
-			 "pipe_config.enable_dz=%d.\n",
-			 p_config->enable_dz);
-		dev_dbg(isp->dev,
-			 "pipe_config.default_capture_config.enable_xnr=%d.\n",
-			 p_config->default_capture_config.enable_xnr);
-		dev_dbg(isp->dev,
-			 "dumping pipe[%d] extra config:\n", pipe_id);
-		dev_dbg(isp->dev,
-			 "pipe_extra_config.enable_raw_binning:%d.\n",
-			 pe_config->enable_raw_binning);
-		dev_dbg(isp->dev,
-			 "pipe_extra_config.enable_yuv_ds:%d.\n",
-			 pe_config->enable_yuv_ds);
-		dev_dbg(isp->dev,
-			 "pipe_extra_config.enable_high_speed:%d.\n",
-			 pe_config->enable_high_speed);
-		dev_dbg(isp->dev,
-			 "pipe_extra_config.enable_dvs_6axis:%d.\n",
-			 pe_config->enable_dvs_6axis);
-		dev_dbg(isp->dev,
-			 "pipe_extra_config.enable_reduced_pipe:%d.\n",
-			 pe_config->enable_reduced_pipe);
-		dev_dbg(isp->dev,
-			 "pipe_(extra_)config.enable_dz:%d.\n",
-			 p_config->enable_dz);
-		dev_dbg(isp->dev,
-			 "pipe_extra_config.disable_vf_pp:%d.\n",
-			 pe_config->disable_vf_pp);
-	}
-}
-
-static void __dump_stream_config(struct atomisp_sub_device *asd,
-				struct atomisp_stream_env *stream_env)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct ia_css_stream_config *s_config;
-	int j;
-	bool valid_stream = false;
-
-	for (j = 0; j < IA_CSS_PIPE_ID_NUM; j++) {
-		if (stream_env->pipes[j]) {
-			__dump_pipe_config(asd, stream_env, j);
-			valid_stream = true;
-		}
-	}
-	if (!valid_stream)
-		return;
-	s_config = &stream_env->stream_config;
-	dev_dbg(isp->dev, "stream_config.mode=%d.\n", s_config->mode);
-
-	if (s_config->mode == IA_CSS_INPUT_MODE_SENSOR ||
-	    s_config->mode == IA_CSS_INPUT_MODE_BUFFERED_SENSOR) {
-		dev_dbg(isp->dev, "stream_config.source.port.port=%d.\n",
-				s_config->source.port.port);
-		dev_dbg(isp->dev, "stream_config.source.port.num_lanes=%d.\n",
-				s_config->source.port.num_lanes);
-		dev_dbg(isp->dev, "stream_config.source.port.timeout=%d.\n",
-				s_config->source.port.timeout);
-		dev_dbg(isp->dev, "stream_config.source.port.rxcount=0x%x.\n",
-				s_config->source.port.rxcount);
-		dev_dbg(isp->dev, "stream_config.source.port.compression.type=%d.\n",
-				s_config->source.port.compression.type);
-		dev_dbg(isp->dev, "stream_config.source.port.compression.compressed_bits_per_pixel=%d.\n",
-				s_config->source.port.compression.
-				compressed_bits_per_pixel);
-		dev_dbg(isp->dev, "stream_config.source.port.compression.uncompressed_bits_per_pixel=%d.\n",
-				s_config->source.port.compression.
-				uncompressed_bits_per_pixel);
-	} else if (s_config->mode == IA_CSS_INPUT_MODE_TPG) {
-		dev_dbg(isp->dev, "stream_config.source.tpg.id=%d.\n",
-				s_config->source.tpg.id);
-		dev_dbg(isp->dev, "stream_config.source.tpg.mode=%d.\n",
-				s_config->source.tpg.mode);
-		dev_dbg(isp->dev, "stream_config.source.tpg.x_mask=%d.\n",
-				s_config->source.tpg.x_mask);
-		dev_dbg(isp->dev, "stream_config.source.tpg.x_delta=%d.\n",
-				s_config->source.tpg.x_delta);
-		dev_dbg(isp->dev, "stream_config.source.tpg.y_mask=%d.\n",
-				s_config->source.tpg.y_mask);
-		dev_dbg(isp->dev, "stream_config.source.tpg.y_delta=%d.\n",
-				s_config->source.tpg.y_delta);
-		dev_dbg(isp->dev, "stream_config.source.tpg.xy_mask=%d.\n",
-				s_config->source.tpg.xy_mask);
-	} else if (s_config->mode == IA_CSS_INPUT_MODE_PRBS) {
-		dev_dbg(isp->dev, "stream_config.source.prbs.id=%d.\n",
-				s_config->source.prbs.id);
-		dev_dbg(isp->dev, "stream_config.source.prbs.h_blank=%d.\n",
-				s_config->source.prbs.h_blank);
-		dev_dbg(isp->dev, "stream_config.source.prbs.v_blank=%d.\n",
-				s_config->source.prbs.v_blank);
-		dev_dbg(isp->dev, "stream_config.source.prbs.seed=%d.\n",
-				s_config->source.prbs.seed);
-		dev_dbg(isp->dev, "stream_config.source.prbs.seed1=%d.\n",
-				s_config->source.prbs.seed1);
-	}
-
-	for (j = 0; j < IA_CSS_STREAM_MAX_ISYS_STREAM_PER_CH; j++) {
-		dev_dbg(isp->dev, "stream_configisys_config[%d].input_res w=%d, h=%d.\n",
-			j,
-			s_config->isys_config[j].input_res.width,
-			s_config->isys_config[j].input_res.height);
-
-		dev_dbg(isp->dev, "stream_configisys_config[%d].linked_isys_stream_id=%d\n",
-			j,
-			s_config->isys_config[j].linked_isys_stream_id);
-
-		dev_dbg(isp->dev, "stream_configisys_config[%d].format=%d\n",
-			j,
-			s_config->isys_config[j].format);
-
-		dev_dbg(isp->dev, "stream_configisys_config[%d].valid=%d.\n",
-			j,
-			s_config->isys_config[j].valid);
-	}
-
-	dev_dbg(isp->dev, "stream_config.input_config.input_res w=%d, h=%d.\n",
-		s_config->input_config.input_res.width,
-		s_config->input_config.input_res.height);
-
-	dev_dbg(isp->dev, "stream_config.input_config.effective_res w=%d, h=%d.\n",
-		s_config->input_config.effective_res.width,
-		s_config->input_config.effective_res.height);
-
-	dev_dbg(isp->dev, "stream_config.input_config.format=%d\n",
-		s_config->input_config.format);
-
-	dev_dbg(isp->dev, "stream_config.input_config.bayer_order=%d.\n",
-		s_config->input_config.bayer_order);
-
-	dev_dbg(isp->dev, "stream_config.pixels_per_clock=%d.\n",
-			s_config->pixels_per_clock);
-	dev_dbg(isp->dev, "stream_config.online=%d.\n", s_config->online);
-	dev_dbg(isp->dev, "stream_config.continuous=%d.\n",
-			s_config->continuous);
-	dev_dbg(isp->dev, "stream_config.disable_cont_viewfinder=%d.\n",
-			s_config->disable_cont_viewfinder);
-	dev_dbg(isp->dev, "stream_config.channel_id=%d.\n",
-			s_config->channel_id);
-	dev_dbg(isp->dev, "stream_config.init_num_cont_raw_buf=%d.\n",
-			s_config->init_num_cont_raw_buf);
-	dev_dbg(isp->dev, "stream_config.target_num_cont_raw_buf=%d.\n",
-			s_config->target_num_cont_raw_buf);
-	dev_dbg(isp->dev, "stream_config.left_padding=%d.\n",
-			s_config->left_padding);
-	dev_dbg(isp->dev, "stream_config.sensor_binning_factor=%d.\n",
-			s_config->sensor_binning_factor);
-	dev_dbg(isp->dev, "stream_config.pixels_per_clock=%d.\n",
-			s_config->pixels_per_clock);
-	dev_dbg(isp->dev, "stream_config.pack_raw_pixels=%d.\n",
-			s_config->pack_raw_pixels);
-	dev_dbg(isp->dev, "stream_config.flash_gpio_pin=%d.\n",
-			s_config->flash_gpio_pin);
-	dev_dbg(isp->dev, "stream_config.mipi_buffer_config.size_mem_words=%d.\n",
-			s_config->mipi_buffer_config.size_mem_words);
-	dev_dbg(isp->dev, "stream_config.mipi_buffer_config.contiguous=%d.\n",
-			s_config->mipi_buffer_config.contiguous);
-	dev_dbg(isp->dev, "stream_config.metadata_config.data_type=%d.\n",
-			s_config->metadata_config.data_type);
-	dev_dbg(isp->dev, "stream_config.metadata_config.resolution w=%d, h=%d.\n",
-			s_config->metadata_config.resolution.width,
-			s_config->metadata_config.resolution.height);
-}
-
-static int __destroy_stream(struct atomisp_sub_device *asd,
-			struct atomisp_stream_env *stream_env, bool force)
-{
-	struct atomisp_device *isp = asd->isp;
-	int i;
-	unsigned long timeout;
-
-	if (!stream_env->stream)
-		return 0;
-
-	if (!force) {
-		for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++)
-			if (stream_env->update_pipe[i])
-				break;
-
-		if (i == IA_CSS_PIPE_ID_NUM)
-			return 0;
-	}
-
-	if (stream_env->stream_state == CSS_STREAM_STARTED
-	    && ia_css_stream_stop(stream_env->stream) != IA_CSS_SUCCESS) {
-		dev_err(isp->dev, "stop stream failed.\n");
-		return -EINVAL;
-	}
-
-	if (stream_env->stream_state == CSS_STREAM_STARTED) {
-		timeout = jiffies + msecs_to_jiffies(40);
-		while (1) {
-			if (ia_css_stream_has_stopped(stream_env->stream))
-				break;
-
-			if (time_after(jiffies, timeout)) {
-				dev_warn(isp->dev, "stop stream timeout.\n");
-				break;
-			}
-
-			usleep_range(100, 200);
-		}
-	}
-
-	stream_env->stream_state = CSS_STREAM_STOPPED;
-
-	if (ia_css_stream_destroy(stream_env->stream) != IA_CSS_SUCCESS) {
-		dev_err(isp->dev, "destroy stream failed.\n");
-		return -EINVAL;
-	}
-	stream_env->stream_state = CSS_STREAM_UNINIT;
-	stream_env->stream = NULL;
-
-	return 0;
-}
-
-static int __destroy_streams(struct atomisp_sub_device *asd, bool force)
-{
-	int ret, i;
-
-	for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
-		ret = __destroy_stream(asd, &asd->stream_env[i], force);
-		if (ret)
-			return ret;
-	}
-	asd->stream_prepared = false;
-	return 0;
-}
-static int __create_stream(struct atomisp_sub_device *asd,
-			   struct atomisp_stream_env *stream_env)
-{
-	int pipe_index = 0, i;
-	struct ia_css_pipe *multi_pipes[IA_CSS_PIPE_ID_NUM];
-
-	for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) {
-		if (stream_env->pipes[i])
-			multi_pipes[pipe_index++] = stream_env->pipes[i];
-	}
-	if (pipe_index == 0)
-		return 0;
-
-	stream_env->stream_config.target_num_cont_raw_buf =
-		asd->continuous_raw_buffer_size->val;
-	stream_env->stream_config.channel_id = stream_env->ch_id;
-	stream_env->stream_config.ia_css_enable_raw_buffer_locking =
-		asd->enable_raw_buffer_lock->val;
-
-	__dump_stream_config(asd, stream_env);
-	if (ia_css_stream_create(&stream_env->stream_config,
-	    pipe_index, multi_pipes, &stream_env->stream) != IA_CSS_SUCCESS)
-		return -EINVAL;
-	if (ia_css_stream_get_info(stream_env->stream,
-				&stream_env->stream_info) != IA_CSS_SUCCESS) {
-		ia_css_stream_destroy(stream_env->stream);
-		stream_env->stream = NULL;
-		return -EINVAL;
-	}
-
-	stream_env->stream_state = CSS_STREAM_CREATED;
-	return 0;
-}
-
-static int __create_streams(struct atomisp_sub_device *asd)
-{
-	int ret, i;
-
-	for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
-		ret = __create_stream(asd, &asd->stream_env[i]);
-		if (ret)
-			goto rollback;
-	}
-	asd->stream_prepared = true;
-	return 0;
-rollback:
-	for (i--; i >= 0; i--)
-		__destroy_stream(asd, &asd->stream_env[i], true);
-	return ret;
-}
-
-static int __destroy_stream_pipes(struct atomisp_sub_device *asd,
-				  struct atomisp_stream_env *stream_env,
-				  bool force)
-{
-	struct atomisp_device *isp = asd->isp;
-	int ret = 0;
-	int i;
-
-	for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) {
-		if (!stream_env->pipes[i] ||
-		    !(force || stream_env->update_pipe[i]))
-			continue;
-		if (ia_css_pipe_destroy(stream_env->pipes[i])
-		    != IA_CSS_SUCCESS) {
-			dev_err(isp->dev,
-				"destroy pipe[%d]failed.cannot recover.\n", i);
-			ret = -EINVAL;
-		}
-		stream_env->pipes[i] = NULL;
-		stream_env->update_pipe[i] = false;
-	}
-	return ret;
-}
-
-static int __destroy_pipes(struct atomisp_sub_device *asd, bool force)
-{
-	struct atomisp_device *isp = asd->isp;
-	int i;
-	int ret = 0;
-
-	for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
-		if (asd->stream_env[i].stream) {
-
-			dev_err(isp->dev,
-				"cannot destroy css pipes for stream[%d].\n",
-				i);
-			continue;
-		}
-
-		ret = __destroy_stream_pipes(asd, &asd->stream_env[i], force);
-		if (ret)
-			return ret;
-	}
-
-	return 0;
-}
-
-void atomisp_destroy_pipes_stream_force(struct atomisp_sub_device *asd)
-{
-	__destroy_streams(asd, true);
-	__destroy_pipes(asd, true);
-}
-
-static void __apply_additional_pipe_config(
-				struct atomisp_sub_device *asd,
-				struct atomisp_stream_env *stream_env,
-				enum ia_css_pipe_id pipe_id)
-{
-	struct atomisp_device *isp = asd->isp;
-
-	if (pipe_id < 0 || pipe_id >= IA_CSS_PIPE_ID_NUM) {
-		dev_err(isp->dev,
-			 "wrong pipe_id for additional pipe config.\n");
-		return;
-	}
-
-	/* apply default pipe config */
-	stream_env->pipe_configs[pipe_id].isp_pipe_version = 2;
-	stream_env->pipe_configs[pipe_id].enable_dz =
-				asd->disable_dz->val ? false : true;
-	/* apply isp 2.2 specific config for baytrail*/
-	switch (pipe_id) {
-	case IA_CSS_PIPE_ID_CAPTURE:
-		/* enable capture pp/dz manually or digital zoom would
-		 * fail*/
-		if (stream_env->pipe_configs[pipe_id].
-			default_capture_config.mode == CSS_CAPTURE_MODE_RAW)
-			stream_env->pipe_configs[pipe_id].enable_dz = false;
-#ifdef ISP2401
-
-		/* the isp default to use ISP2.2 and the camera hal will
-		 * control whether use isp2.7 */
-		if (asd->select_isp_version->val ==
-			ATOMISP_CSS_ISP_PIPE_VERSION_2_7)
-			stream_env->pipe_configs[pipe_id].isp_pipe_version =
-				SH_CSS_ISP_PIPE_VERSION_2_7;
-		else
-			stream_env->pipe_configs[pipe_id].isp_pipe_version =
-				SH_CSS_ISP_PIPE_VERSION_2_2;
-#endif
-		break;
-	case IA_CSS_PIPE_ID_VIDEO:
-		/* enable reduced pipe to have binary
-		 * video_dz_2_min selected*/
-		stream_env->pipe_extra_configs[pipe_id]
-		    .enable_reduced_pipe = true;
-		stream_env->pipe_configs[pipe_id]
-		    .enable_dz = false;
-		if (ATOMISP_SOC_CAMERA(asd))
-			stream_env->pipe_configs[pipe_id].enable_dz = true;
-
-		if (asd->params.video_dis_en) {
-			stream_env->pipe_extra_configs[pipe_id]
-				.enable_dvs_6axis = true;
-			stream_env->pipe_configs[pipe_id]
-				.dvs_frame_delay =
-					ATOMISP_CSS2_NUM_DVS_FRAME_DELAY;
-		}
-		break;
-	case IA_CSS_PIPE_ID_PREVIEW:
-		break;
-	case IA_CSS_PIPE_ID_YUVPP:
-	case IA_CSS_PIPE_ID_COPY:
-		if (ATOMISP_SOC_CAMERA(asd))
-			stream_env->pipe_configs[pipe_id].enable_dz = true;
-		else
-			stream_env->pipe_configs[pipe_id].enable_dz = false;
-		break;
-	case IA_CSS_PIPE_ID_ACC:
-		stream_env->pipe_configs[pipe_id].mode = IA_CSS_PIPE_MODE_ACC;
-		stream_env->pipe_configs[pipe_id].enable_dz = false;
-		break;
-	default:
-		break;
-	}
-}
-
-static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd,
-					enum ia_css_pipe_id pipe_id)
-{
-	if (!asd)
-		return false;
-
-	if (pipe_id == CSS_PIPE_ID_ACC || pipe_id == CSS_PIPE_ID_YUVPP)
-		return true;
-
-	if (asd->vfpp) {
-		if (asd->vfpp->val == ATOMISP_VFPP_DISABLE_SCALER) {
-			if (pipe_id == IA_CSS_PIPE_ID_VIDEO)
-				return true;
-			else
-				return false;
-		} else if (asd->vfpp->val == ATOMISP_VFPP_DISABLE_LOWLAT) {
-			if (pipe_id == IA_CSS_PIPE_ID_CAPTURE)
-				return true;
-			else
-				return false;
-		}
-	}
-
-	if (!asd->run_mode)
-		return false;
-
-	if (asd->copy_mode && pipe_id == IA_CSS_PIPE_ID_COPY)
-		return true;
-
-	switch (asd->run_mode->val) {
-	case ATOMISP_RUN_MODE_STILL_CAPTURE:
-		if (pipe_id == IA_CSS_PIPE_ID_CAPTURE)
-			return true;
-		else
-			return false;
-	case ATOMISP_RUN_MODE_PREVIEW:
-		if (!asd->continuous_mode->val) {
-			if (pipe_id == IA_CSS_PIPE_ID_PREVIEW)
-				return true;
-			else
-				return false;
-		}
-		/* fall through to ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE */
-	case ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE:
-		if (pipe_id == IA_CSS_PIPE_ID_CAPTURE ||
-		    pipe_id == IA_CSS_PIPE_ID_PREVIEW)
-			return true;
-		else
-			return false;
-	case ATOMISP_RUN_MODE_VIDEO:
-		if (!asd->continuous_mode->val) {
-			if (pipe_id == IA_CSS_PIPE_ID_VIDEO ||
-			    pipe_id == IA_CSS_PIPE_ID_YUVPP)
-				return true;
-			else
-				return false;
-		}
-		/* fall through to ATOMISP_RUN_MODE_SDV */
-	case ATOMISP_RUN_MODE_SDV:
-		if (pipe_id == IA_CSS_PIPE_ID_CAPTURE ||
-		    pipe_id == IA_CSS_PIPE_ID_VIDEO)
-			return true;
-		else
-			return false;
-	}
-
-	return false;
-}
-
-static int __create_pipe(struct atomisp_sub_device *asd,
-			 struct atomisp_stream_env *stream_env,
-			 enum ia_css_pipe_id pipe_id)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct ia_css_pipe_extra_config extra_config;
-	enum ia_css_err ret;
-
-	if (pipe_id >= IA_CSS_PIPE_ID_NUM)
-		return -EINVAL;
-
-	if (pipe_id != CSS_PIPE_ID_ACC &&
-	    !stream_env->pipe_configs[pipe_id].output_info[0].res.width)
-		return 0;
-
-	if (pipe_id == CSS_PIPE_ID_ACC &&
-	    !stream_env->pipe_configs[pipe_id].acc_extension)
-		return 0;
-
-	if (!is_pipe_valid_to_current_run_mode(asd, pipe_id))
-		return 0;
-
-	ia_css_pipe_extra_config_defaults(&extra_config);
-
-	__apply_additional_pipe_config(asd, stream_env, pipe_id);
-	if (!memcmp(&extra_config,
-		    &stream_env->pipe_extra_configs[pipe_id],
-		    sizeof(extra_config)))
-		ret = ia_css_pipe_create(
-			&stream_env->pipe_configs[pipe_id],
-			&stream_env->pipes[pipe_id]);
-	else
-		ret = ia_css_pipe_create_extra(
-			&stream_env->pipe_configs[pipe_id],
-			&stream_env->pipe_extra_configs[pipe_id],
-			&stream_env->pipes[pipe_id]);
-	if (ret != IA_CSS_SUCCESS)
-		dev_err(isp->dev, "create pipe[%d] error.\n", pipe_id);
-	return ret;
-}
-
-static int __create_pipes(struct atomisp_sub_device *asd)
-{
-	enum ia_css_err ret;
-	int i, j;
-
-	for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
-		for (j = 0; j < IA_CSS_PIPE_ID_NUM; j++) {
-			ret = __create_pipe(asd, &asd->stream_env[i], j);
-			if (ret != IA_CSS_SUCCESS)
-				break;
-		}
-		if (j < IA_CSS_PIPE_ID_NUM)
-			goto pipe_err;
-	}
-	return 0;
-pipe_err:
-	for (; i >= 0; i--) {
-		for (j--; j >= 0; j--) {
-			if (asd->stream_env[i].pipes[j]) {
-				ia_css_pipe_destroy(asd->stream_env[i].pipes[j]);
-				asd->stream_env[i].pipes[j] = NULL;
-			}
-		}
-		j = IA_CSS_PIPE_ID_NUM;
-	}
-	return -EINVAL;
-}
-
-void atomisp_create_pipes_stream(struct atomisp_sub_device *asd)
-{
-	__create_pipes(asd);
-	__create_streams(asd);
-}
-
-int atomisp_css_update_stream(struct atomisp_sub_device *asd)
-{
-	int ret;
-	struct atomisp_device *isp = asd->isp;
-
-	if (__destroy_streams(asd, true) != IA_CSS_SUCCESS)
-		dev_warn(isp->dev, "destroy stream failed.\n");
-
-	if (__destroy_pipes(asd, true) != IA_CSS_SUCCESS)
-		dev_warn(isp->dev, "destroy pipe failed.\n");
-
-	ret = __create_pipes(asd);
-	if (ret != IA_CSS_SUCCESS) {
-		dev_err(isp->dev, "create pipe failed %d.\n", ret);
-		return -EIO;
-	}
-
-	ret = __create_streams(asd);
-	if (ret != IA_CSS_SUCCESS) {
-		dev_warn(isp->dev, "create stream failed %d.\n", ret);
-		__destroy_pipes(asd, true);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-int atomisp_css_init(struct atomisp_device *isp)
-{
-	unsigned int mmu_base_addr;
-	int ret;
-	enum ia_css_err err;
-
-	ret = hmm_get_mmu_base_addr(&mmu_base_addr);
-	if (ret)
-		return ret;
-
-	/* Init ISP */
-	err = ia_css_init(&isp->css_env.isp_css_env, NULL,
-			  (uint32_t)mmu_base_addr, IA_CSS_IRQ_TYPE_PULSE);
-	if (err != IA_CSS_SUCCESS) {
-		dev_err(isp->dev, "css init failed --- bad firmware?\n");
-		return -EINVAL;
-	}
-	ia_css_enable_isys_event_queue(true);
-
-	isp->css_initialized = true;
-	dev_dbg(isp->dev, "sh_css_init success\n");
-
-	return 0;
-}
-
-static inline int __set_css_print_env(struct atomisp_device *isp, int opt)
-{
-	int ret = 0;
-
-	if (opt == 0)
-		isp->css_env.isp_css_env.print_env.debug_print = NULL;
-	else if (opt == 1)
-		isp->css_env.isp_css_env.print_env.debug_print =
-			atomisp_css2_dbg_ftrace_print;
-	else if (opt == 2)
-		isp->css_env.isp_css_env.print_env.debug_print =
-			atomisp_css2_dbg_print;
-	else
-		ret = -EINVAL;
-
-	return ret;
-}
-
-int atomisp_css_check_firmware_version(struct atomisp_device *isp)
-{
-	if (!sh_css_check_firmware_version((void *)isp->firmware->data)) {
-		dev_err(isp->dev, "Fw version check failed.\n");
-		return -EINVAL;
-	}
-	return 0;
-}
-
-int atomisp_css_load_firmware(struct atomisp_device *isp)
-{
-	enum ia_css_err err;
-
-	/* set css env */
-	isp->css_env.isp_css_fw.data = (void *)isp->firmware->data;
-	isp->css_env.isp_css_fw.bytes = isp->firmware->size;
-
-	isp->css_env.isp_css_env.hw_access_env.store_8 =
-							atomisp_css2_hw_store_8;
-	isp->css_env.isp_css_env.hw_access_env.store_16 =
-						atomisp_css2_hw_store_16;
-	isp->css_env.isp_css_env.hw_access_env.store_32 =
-						atomisp_css2_hw_store_32;
-
-	isp->css_env.isp_css_env.hw_access_env.load_8 = atomisp_css2_hw_load_8;
-	isp->css_env.isp_css_env.hw_access_env.load_16 =
-							atomisp_css2_hw_load_16;
-	isp->css_env.isp_css_env.hw_access_env.load_32 =
-							atomisp_css2_hw_load_32;
-
-	isp->css_env.isp_css_env.hw_access_env.load = atomisp_css2_hw_load;
-	isp->css_env.isp_css_env.hw_access_env.store = atomisp_css2_hw_store;
-
-	__set_css_print_env(isp, dbg_func);
-
-	isp->css_env.isp_css_env.print_env.error_print = atomisp_css2_err_print;
-
-	/* load isp fw into ISP memory */
-	err = ia_css_load_firmware(&isp->css_env.isp_css_env,
-				   &isp->css_env.isp_css_fw);
-	if (err != IA_CSS_SUCCESS) {
-		dev_err(isp->dev, "css load fw failed.\n");
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-void atomisp_css_unload_firmware(struct atomisp_device *isp)
-{
-	ia_css_unload_firmware();
-}
-
-void atomisp_css_uninit(struct atomisp_device *isp)
-{
-	struct atomisp_sub_device *asd;
-	unsigned int i;
-
-	for (i = 0; i < isp->num_of_streams; i++) {
-		asd = &isp->asd[i];
-		atomisp_isp_parameters_clean_up(&asd->params.config);
-		asd->params.css_update_params_needed = false;
-	}
-
-	isp->css_initialized = false;
-	ia_css_uninit();
-}
-
-void atomisp_css_suspend(struct atomisp_device *isp)
-{
-	isp->css_initialized = false;
-	ia_css_uninit();
-}
-
-int atomisp_css_resume(struct atomisp_device *isp)
-{
-	unsigned int mmu_base_addr;
-	int ret;
-
-	ret = hmm_get_mmu_base_addr(&mmu_base_addr);
-	if (ret) {
-		dev_err(isp->dev, "get base address error.\n");
-		return -EINVAL;
-	}
-
-	ret = ia_css_init(&isp->css_env.isp_css_env, NULL,
-			  mmu_base_addr, IA_CSS_IRQ_TYPE_PULSE);
-	if (ret) {
-		dev_err(isp->dev, "re-init css failed.\n");
-		return -EINVAL;
-	}
-	ia_css_enable_isys_event_queue(true);
-
-	isp->css_initialized = true;
-	return 0;
-}
-
-int atomisp_css_irq_translate(struct atomisp_device *isp,
-			      unsigned int *infos)
-{
-	int err;
-
-	err = ia_css_irq_translate(infos);
-	if (err != IA_CSS_SUCCESS) {
-		dev_warn(isp->dev,
-			  "%s:failed to translate irq (err = %d,infos = %d)\n",
-			  __func__, err, *infos);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-void atomisp_css_rx_get_irq_info(enum mipi_port_id port,
-					unsigned int *infos)
-{
-#ifndef ISP2401_NEW_INPUT_SYSTEM
-	ia_css_isys_rx_get_irq_info(port, infos);
-#else
-	*infos = 0;
-#endif
-}
-
-void atomisp_css_rx_clear_irq_info(enum mipi_port_id port,
-					unsigned int infos)
-{
-#ifndef ISP2401_NEW_INPUT_SYSTEM
-	ia_css_isys_rx_clear_irq_info(port, infos);
-#endif
-}
-
-int atomisp_css_irq_enable(struct atomisp_device *isp,
-			    enum atomisp_css_irq_info info, bool enable)
-{
-	if (ia_css_irq_enable(info, enable) != IA_CSS_SUCCESS) {
-		dev_warn(isp->dev, "%s:Invalid irq info.\n", __func__);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-void atomisp_css_init_struct(struct atomisp_sub_device *asd)
-{
-	int i, j;
-
-	for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
-		asd->stream_env[i].stream = NULL;
-		for (j = 0; j < IA_CSS_PIPE_MODE_NUM; j++) {
-			asd->stream_env[i].pipes[j] = NULL;
-			asd->stream_env[i].update_pipe[j] = false;
-			ia_css_pipe_config_defaults(
-				&asd->stream_env[i].pipe_configs[j]);
-			ia_css_pipe_extra_config_defaults(
-				&asd->stream_env[i].pipe_extra_configs[j]);
-		}
-		ia_css_stream_config_defaults(&asd->stream_env[i].stream_config);
-	}
-}
-
-int atomisp_q_video_buffer_to_css(struct atomisp_sub_device *asd,
-			struct videobuf_vmalloc_memory *vm_mem,
-			enum atomisp_input_stream_id stream_id,
-			enum atomisp_css_buffer_type css_buf_type,
-			enum atomisp_css_pipe_id css_pipe_id)
-{
-	struct atomisp_stream_env *stream_env = &asd->stream_env[stream_id];
-	struct ia_css_buffer css_buf = {0};
-	enum ia_css_err err;
-
-	css_buf.type = css_buf_type;
-	css_buf.data.frame = vm_mem->vaddr;
-
-	err = ia_css_pipe_enqueue_buffer(
-				stream_env->pipes[css_pipe_id], &css_buf);
-	if (err != IA_CSS_SUCCESS)
-		return -EINVAL;
-
-	return 0;
-}
-
-int atomisp_q_metadata_buffer_to_css(struct atomisp_sub_device *asd,
-			struct atomisp_metadata_buf *metadata_buf,
-			enum atomisp_input_stream_id stream_id,
-			enum atomisp_css_pipe_id css_pipe_id)
-{
-	struct atomisp_stream_env *stream_env = &asd->stream_env[stream_id];
-	struct ia_css_buffer buffer = {0};
-	struct atomisp_device *isp = asd->isp;
-
-	buffer.type = IA_CSS_BUFFER_TYPE_METADATA;
-	buffer.data.metadata = metadata_buf->metadata;
-	if (ia_css_pipe_enqueue_buffer(stream_env->pipes[css_pipe_id],
-				&buffer)) {
-		dev_err(isp->dev, "failed to q meta data buffer\n");
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-int atomisp_q_s3a_buffer_to_css(struct atomisp_sub_device *asd,
-			struct atomisp_s3a_buf *s3a_buf,
-			enum atomisp_input_stream_id stream_id,
-			enum atomisp_css_pipe_id css_pipe_id)
-{
-	struct atomisp_stream_env *stream_env = &asd->stream_env[stream_id];
-	struct ia_css_buffer buffer = {0};
-	struct atomisp_device *isp = asd->isp;
-
-	buffer.type = IA_CSS_BUFFER_TYPE_3A_STATISTICS;
-	buffer.data.stats_3a = s3a_buf->s3a_data;
-	if (ia_css_pipe_enqueue_buffer(
-				stream_env->pipes[css_pipe_id],
-				&buffer)) {
-		dev_dbg(isp->dev, "failed to q s3a stat buffer\n");
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-int atomisp_q_dis_buffer_to_css(struct atomisp_sub_device *asd,
-			struct atomisp_dis_buf *dis_buf,
-			enum atomisp_input_stream_id stream_id,
-			enum atomisp_css_pipe_id css_pipe_id)
-{
-	struct atomisp_stream_env *stream_env = &asd->stream_env[stream_id];
-	struct ia_css_buffer buffer = {0};
-	struct atomisp_device *isp = asd->isp;
-
-	buffer.type = IA_CSS_BUFFER_TYPE_DIS_STATISTICS;
-	buffer.data.stats_dvs = dis_buf->dis_data;
-	if (ia_css_pipe_enqueue_buffer(
-				stream_env->pipes[css_pipe_id],
-				&buffer)) {
-		dev_dbg(isp->dev, "failed to q dvs stat buffer\n");
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-void atomisp_css_mmu_invalidate_cache(void)
-{
-	ia_css_mmu_invalidate_cache();
-}
-
-void atomisp_css_mmu_invalidate_tlb(void)
-{
-	ia_css_mmu_invalidate_cache();
-}
-
-int atomisp_css_start(struct atomisp_sub_device *asd,
-			enum atomisp_css_pipe_id pipe_id, bool in_reset)
-{
-	struct atomisp_device *isp = asd->isp;
-	bool sp_is_started = false;
-	int ret = 0, i = 0;
-
-	if (in_reset) {
-		if (__destroy_streams(asd, true))
-			dev_warn(isp->dev, "destroy stream failed.\n");
-
-		if (__destroy_pipes(asd, true))
-			dev_warn(isp->dev, "destroy pipe failed.\n");
-
-		if (__create_pipes(asd)) {
-			dev_err(isp->dev, "create pipe error.\n");
-			return -EINVAL;
-		}
-		if (__create_streams(asd)) {
-			dev_err(isp->dev, "create stream error.\n");
-			ret = -EINVAL;
-			goto stream_err;
-		}
-		/* in_reset == true, extension firmwares are reloaded after the recovery */
-		atomisp_acc_load_extensions(asd);
-	}
-
-	/*
-	 * For dual steam case, it is possible that:
-	 * 1: for this stream, it is at the stage that:
-	 * - after set_fmt is called
-	 * - before stream on is called
-	 * 2: for the other stream, the stream off is called which css reset
-	 * has been done.
-	 *
-	 * Thus the stream created in set_fmt get destroyed and need to be
-	 * recreated in the next stream on.
-	 */
-	if (asd->stream_prepared == false) {
-		if (__create_pipes(asd)) {
-			dev_err(isp->dev, "create pipe error.\n");
-			return -EINVAL;
-		}
-		if (__create_streams(asd)) {
-			dev_err(isp->dev, "create stream error.\n");
-			ret = -EINVAL;
-			goto stream_err;
-		}
-	}
-	/*
-	 * SP can only be started one time
-	 * if atomisp_subdev_streaming_count() tell there already has some
-	 * subdev at streamming, then SP should already be started previously,
-	 * so need to skip start sp procedure
-	 */
-	if (atomisp_streaming_count(isp)) {
-		dev_dbg(isp->dev, "skip start sp\n");
-	} else {
-		if (!sh_css_hrt_system_is_idle())
-			dev_err(isp->dev, "CSS HW not idle before starting SP\n");
-		if (ia_css_start_sp() != IA_CSS_SUCCESS) {
-			dev_err(isp->dev, "start sp error.\n");
-			ret = -EINVAL;
-			goto start_err;
-		} else {
-			sp_is_started = true;
-		}
-	}
-
-	for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
-		if (asd->stream_env[i].stream) {
-			if (ia_css_stream_start(asd->stream_env[i]
-						.stream) != IA_CSS_SUCCESS) {
-				dev_err(isp->dev, "stream[%d] start error.\n", i);
-				ret = -EINVAL;
-				goto start_err;
-			} else {
-				asd->stream_env[i].stream_state = CSS_STREAM_STARTED;
-				dev_dbg(isp->dev, "stream[%d] started.\n", i);
-			}
-		}
-	}
-
-	return 0;
-
-start_err:
-	__destroy_streams(asd, true);
-stream_err:
-	__destroy_pipes(asd, true);
-
-	/* css 2.0 API limitation: ia_css_stop_sp() could be only called after
-	 * destroy all pipes
-	 */
-	/*
-	 * SP can not be stop if other streams are in use
-	 */
-	if ((atomisp_streaming_count(isp) == 0) && sp_is_started)
-		ia_css_stop_sp();
-
-	return ret;
-}
-
-void atomisp_css_update_isp_params(struct atomisp_sub_device *asd)
-{
-	/*
-	 * FIXME!
-	 * for ISP2401 new input system, this api is under development.
-	 * Calling it would cause kernel panic.
-	 *
-	 * VIED BZ: 1458
-	 *
-	 * Check if it is Cherry Trail and also new input system
-	 */
-	if (asd->copy_mode) {
-		dev_warn(asd->isp->dev,
-			 "%s: ia_css_stream_set_isp_config() not supported in copy mode!.\n",
-				__func__);
-		return;
-	}
-
-	ia_css_stream_set_isp_config(
-			asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-			&asd->params.config);
-	atomisp_isp_parameters_clean_up(&asd->params.config);
-}
-
-
-void atomisp_css_update_isp_params_on_pipe(struct atomisp_sub_device *asd,
-					struct ia_css_pipe *pipe)
-{
-	enum ia_css_err ret;
-
-	if (!pipe) {
-		atomisp_css_update_isp_params(asd);
-		return;
-	}
-
-	dev_dbg(asd->isp->dev, "%s: apply parameter for ia_css_frame %p with isp_config_id %d on pipe %p.\n",
-		__func__, asd->params.config.output_frame,
-		asd->params.config.isp_config_id, pipe);
-
-	ret = ia_css_stream_set_isp_config_on_pipe(
-			asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-			&asd->params.config, pipe);
-	if (ret != IA_CSS_SUCCESS)
-		dev_warn(asd->isp->dev, "%s: ia_css_stream_set_isp_config_on_pipe failed %d\n",
-			__func__, ret);
-	atomisp_isp_parameters_clean_up(&asd->params.config);
-}
-
-int atomisp_css_queue_buffer(struct atomisp_sub_device *asd,
-			     enum atomisp_input_stream_id stream_id,
-			     enum atomisp_css_pipe_id pipe_id,
-			     enum atomisp_css_buffer_type buf_type,
-			     struct atomisp_css_buffer *isp_css_buffer)
-{
-	if (ia_css_pipe_enqueue_buffer(
-		asd->stream_env[stream_id].pipes[pipe_id],
-					&isp_css_buffer->css_buffer)
-					!= IA_CSS_SUCCESS)
-		return -EINVAL;
-
-	return 0;
-}
-
-int atomisp_css_dequeue_buffer(struct atomisp_sub_device *asd,
-				enum atomisp_input_stream_id stream_id,
-				enum atomisp_css_pipe_id pipe_id,
-				enum atomisp_css_buffer_type buf_type,
-				struct atomisp_css_buffer *isp_css_buffer)
-{
-	struct atomisp_device *isp = asd->isp;
-	enum ia_css_err err;
-
-	err = ia_css_pipe_dequeue_buffer(
-		asd->stream_env[stream_id].pipes[pipe_id],
-					&isp_css_buffer->css_buffer);
-	if (err != IA_CSS_SUCCESS) {
-		dev_err(isp->dev,
-			"ia_css_pipe_dequeue_buffer failed: 0x%x\n", err);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-int atomisp_css_allocate_stat_buffers(struct atomisp_sub_device   *asd,
-				      uint16_t stream_id,
-				      struct atomisp_s3a_buf      *s3a_buf,
-				      struct atomisp_dis_buf      *dis_buf,
-				      struct atomisp_metadata_buf *md_buf)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct atomisp_css_dvs_grid_info *dvs_grid_info =
-		atomisp_css_get_dvs_grid_info(&asd->params.curr_grid_info);
-
-	if (s3a_buf && asd->params.curr_grid_info.s3a_grid.enable) {
-		void *s3a_ptr;
-
-		s3a_buf->s3a_data = ia_css_isp_3a_statistics_allocate(
-				&asd->params.curr_grid_info.s3a_grid);
-		if (!s3a_buf->s3a_data) {
-			dev_err(isp->dev, "3a buf allocation failed.\n");
-			return -EINVAL;
-		}
-
-		s3a_ptr = hmm_vmap(s3a_buf->s3a_data->data_ptr, true);
-		s3a_buf->s3a_map = ia_css_isp_3a_statistics_map_allocate(
-						s3a_buf->s3a_data, s3a_ptr);
-	}
-
-	if (dis_buf && dvs_grid_info && dvs_grid_info->enable) {
-		void *dvs_ptr;
-
-		dis_buf->dis_data = ia_css_isp_dvs2_statistics_allocate(
-					dvs_grid_info);
-		if (!dis_buf->dis_data) {
-			dev_err(isp->dev, "dvs buf allocation failed.\n");
-			if (s3a_buf)
-				ia_css_isp_3a_statistics_free(s3a_buf->s3a_data);
-			return -EINVAL;
-		}
-
-		dvs_ptr = hmm_vmap(dis_buf->dis_data->data_ptr, true);
-		dis_buf->dvs_map = ia_css_isp_dvs_statistics_map_allocate(
-						dis_buf->dis_data, dvs_ptr);
-	}
-
-	if (asd->stream_env[stream_id].stream_info.
-			metadata_info.size && md_buf) {
-		md_buf->metadata = ia_css_metadata_allocate(
-			&asd->stream_env[stream_id].stream_info.metadata_info);
-		if (!md_buf->metadata) {
-			if (s3a_buf)
-				ia_css_isp_3a_statistics_free(s3a_buf->s3a_data);
-			if (dis_buf)
-				ia_css_isp_dvs2_statistics_free(dis_buf->dis_data);
-			dev_err(isp->dev, "metadata buf allocation failed.\n");
-			return -EINVAL;
-		}
-		md_buf->md_vptr = hmm_vmap(md_buf->metadata->address, false);
-	}
-
-	return 0;
-}
-
-void atomisp_css_free_3a_buffer(struct atomisp_s3a_buf *s3a_buf)
-{
-	if (s3a_buf->s3a_data)
-		hmm_vunmap(s3a_buf->s3a_data->data_ptr);
-
-	ia_css_isp_3a_statistics_map_free(s3a_buf->s3a_map);
-	s3a_buf->s3a_map = NULL;
-	ia_css_isp_3a_statistics_free(s3a_buf->s3a_data);
-}
-
-void atomisp_css_free_dis_buffer(struct atomisp_dis_buf *dis_buf)
-{
-	if (dis_buf->dis_data)
-		hmm_vunmap(dis_buf->dis_data->data_ptr);
-
-	ia_css_isp_dvs_statistics_map_free(dis_buf->dvs_map);
-	dis_buf->dvs_map = NULL;
-	ia_css_isp_dvs2_statistics_free(dis_buf->dis_data);
-}
-
-void atomisp_css_free_metadata_buffer(struct atomisp_metadata_buf *metadata_buf)
-{
-	if (metadata_buf->md_vptr) {
-		hmm_vunmap(metadata_buf->metadata->address);
-		metadata_buf->md_vptr = NULL;
-	}
-	ia_css_metadata_free(metadata_buf->metadata);
-}
-
-void atomisp_css_free_stat_buffers(struct atomisp_sub_device *asd)
-{
-	struct atomisp_s3a_buf *s3a_buf, *_s3a_buf;
-	struct atomisp_dis_buf *dis_buf, *_dis_buf;
-	struct atomisp_metadata_buf *md_buf, *_md_buf;
-	struct atomisp_css_dvs_grid_info *dvs_grid_info =
-		atomisp_css_get_dvs_grid_info(&asd->params.curr_grid_info);
-	unsigned int i;
-
-	/* 3A statistics use vmalloc, DIS use kmalloc */
-	if (dvs_grid_info && dvs_grid_info->enable) {
-		ia_css_dvs2_coefficients_free(asd->params.css_param.dvs2_coeff);
-		ia_css_dvs2_statistics_free(asd->params.dvs_stat);
-		asd->params.css_param.dvs2_coeff = NULL;
-		asd->params.dvs_stat = NULL;
-		asd->params.dvs_hor_proj_bytes = 0;
-		asd->params.dvs_ver_proj_bytes = 0;
-		asd->params.dvs_hor_coef_bytes = 0;
-		asd->params.dvs_ver_coef_bytes = 0;
-		asd->params.dis_proj_data_valid = false;
-		list_for_each_entry_safe(dis_buf, _dis_buf,
-						&asd->dis_stats, list) {
-			atomisp_css_free_dis_buffer(dis_buf);
-			list_del(&dis_buf->list);
-			kfree(dis_buf);
-		}
-		list_for_each_entry_safe(dis_buf, _dis_buf,
-						&asd->dis_stats_in_css, list) {
-			atomisp_css_free_dis_buffer(dis_buf);
-			list_del(&dis_buf->list);
-			kfree(dis_buf);
-		}
-	}
-	if (asd->params.curr_grid_info.s3a_grid.enable) {
-		ia_css_3a_statistics_free(asd->params.s3a_user_stat);
-		asd->params.s3a_user_stat = NULL;
-		asd->params.s3a_output_bytes = 0;
-		list_for_each_entry_safe(s3a_buf, _s3a_buf,
-						&asd->s3a_stats, list) {
-			atomisp_css_free_3a_buffer(s3a_buf);
-			list_del(&s3a_buf->list);
-			kfree(s3a_buf);
-		}
-		list_for_each_entry_safe(s3a_buf, _s3a_buf,
-						&asd->s3a_stats_in_css, list) {
-			atomisp_css_free_3a_buffer(s3a_buf);
-			list_del(&s3a_buf->list);
-			kfree(s3a_buf);
-		}
-		list_for_each_entry_safe(s3a_buf, _s3a_buf,
-						&asd->s3a_stats_ready, list) {
-			atomisp_css_free_3a_buffer(s3a_buf);
-			list_del(&s3a_buf->list);
-			kfree(s3a_buf);
-		}
-	}
-
-	if (asd->params.css_param.dvs_6axis) {
-		ia_css_dvs2_6axis_config_free(asd->params.css_param.dvs_6axis);
-		asd->params.css_param.dvs_6axis = NULL;
-	}
-
-	for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
-		list_for_each_entry_safe(md_buf, _md_buf,
-					&asd->metadata[i], list) {
-			atomisp_css_free_metadata_buffer(md_buf);
-			list_del(&md_buf->list);
-			kfree(md_buf);
-		}
-		list_for_each_entry_safe(md_buf, _md_buf,
-					&asd->metadata_in_css[i], list) {
-			atomisp_css_free_metadata_buffer(md_buf);
-			list_del(&md_buf->list);
-			kfree(md_buf);
-		}
-		list_for_each_entry_safe(md_buf, _md_buf,
-					&asd->metadata_ready[i], list) {
-			atomisp_css_free_metadata_buffer(md_buf);
-			list_del(&md_buf->list);
-			kfree(md_buf);
-		}
-	}
-	asd->params.metadata_width_size = 0;
-	atomisp_free_metadata_output_buf(asd);
-}
-
-int atomisp_css_get_grid_info(struct atomisp_sub_device *asd,
-				enum atomisp_css_pipe_id pipe_id,
-				int source_pad)
-{
-	struct ia_css_pipe_info p_info;
-	struct ia_css_grid_info old_info;
-	struct atomisp_device *isp = asd->isp;
-	int stream_index = atomisp_source_pad_to_stream_id(asd, source_pad);
-	int md_width = asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].
-		stream_config.metadata_config.resolution.width;
-
-	memset(&p_info, 0, sizeof(struct ia_css_pipe_info));
-	memset(&old_info, 0, sizeof(struct ia_css_grid_info));
-
-	if (ia_css_pipe_get_info(
-		asd->stream_env[stream_index].pipes[pipe_id],
-		&p_info) != IA_CSS_SUCCESS) {
-		dev_err(isp->dev, "ia_css_pipe_get_info failed\n");
-		return -EINVAL;
-	}
-
-	memcpy(&old_info, &asd->params.curr_grid_info,
-					sizeof(struct ia_css_grid_info));
-	memcpy(&asd->params.curr_grid_info, &p_info.grid_info,
-					sizeof(struct ia_css_grid_info));
-	/*
-	 * Record which css pipe enables s3a_grid.
-	 * Currently would have one css pipe that need it
-	 */
-	if (asd->params.curr_grid_info.s3a_grid.enable) {
-		if (asd->params.s3a_enabled_pipe != CSS_PIPE_ID_NUM)
-			dev_dbg(isp->dev, "css pipe %d enabled s3a grid replaced by: %d.\n",
-					asd->params.s3a_enabled_pipe, pipe_id);
-		asd->params.s3a_enabled_pipe = pipe_id;
-	}
-
-	/* If the grid info has not changed and the buffers for 3A and
-	 * DIS statistics buffers are allocated or buffer size would be zero
-	 * then no need to do anything. */
-	if (((!memcmp(&old_info, &asd->params.curr_grid_info, sizeof(old_info))
-	    && asd->params.s3a_user_stat && asd->params.dvs_stat)
-	    || asd->params.curr_grid_info.s3a_grid.width == 0
-	    || asd->params.curr_grid_info.s3a_grid.height == 0)
-	    && asd->params.metadata_width_size == md_width) {
-		dev_dbg(isp->dev,
-			"grid info change escape. memcmp=%d, s3a_user_stat=%d,"
-			"dvs_stat=%d, s3a.width=%d, s3a.height=%d, metadata width =%d\n",
-			!memcmp(&old_info, &asd->params.curr_grid_info,
-				 sizeof(old_info)),
-			 !!asd->params.s3a_user_stat, !!asd->params.dvs_stat,
-			 asd->params.curr_grid_info.s3a_grid.width,
-			 asd->params.curr_grid_info.s3a_grid.height,
-			 asd->params.metadata_width_size);
-		return -EINVAL;
-	}
-	asd->params.metadata_width_size = md_width;
-
-	return 0;
-}
-
-int atomisp_alloc_3a_output_buf(struct atomisp_sub_device *asd)
-{
-	if (!asd->params.curr_grid_info.s3a_grid.width ||
-			!asd->params.curr_grid_info.s3a_grid.height)
-		return 0;
-
-	asd->params.s3a_user_stat = ia_css_3a_statistics_allocate(
-				&asd->params.curr_grid_info.s3a_grid);
-	if (!asd->params.s3a_user_stat)
-		return -ENOMEM;
-	/* 3A statistics. These can be big, so we use vmalloc. */
-	asd->params.s3a_output_bytes =
-	    asd->params.curr_grid_info.s3a_grid.width *
-	    asd->params.curr_grid_info.s3a_grid.height *
-	    sizeof(*asd->params.s3a_user_stat->data);
-
-	return 0;
-}
-
-int atomisp_alloc_dis_coef_buf(struct atomisp_sub_device *asd)
-{
-	struct atomisp_css_dvs_grid_info *dvs_grid =
-		atomisp_css_get_dvs_grid_info(&asd->params.curr_grid_info);
-
-	if (!dvs_grid)
-		return 0;
-
-	if (!dvs_grid->enable) {
-		dev_dbg(asd->isp->dev, "%s: dvs_grid not enabled.\n", __func__);
-		return 0;
-	}
-
-	/* DIS coefficients. */
-	asd->params.css_param.dvs2_coeff = ia_css_dvs2_coefficients_allocate(
-			dvs_grid);
-	if (!asd->params.css_param.dvs2_coeff)
-		return -ENOMEM;
-
-	asd->params.dvs_hor_coef_bytes = dvs_grid->num_hor_coefs *
-		sizeof(*asd->params.css_param.dvs2_coeff->hor_coefs.odd_real);
-
-	asd->params.dvs_ver_coef_bytes = dvs_grid->num_ver_coefs *
-		sizeof(*asd->params.css_param.dvs2_coeff->ver_coefs.odd_real);
-
-	/* DIS projections. */
-	asd->params.dis_proj_data_valid = false;
-	asd->params.dvs_stat = ia_css_dvs2_statistics_allocate(dvs_grid);
-	if (!asd->params.dvs_stat)
-		return -ENOMEM;
-
-	asd->params.dvs_hor_proj_bytes =
-		dvs_grid->aligned_height * dvs_grid->aligned_width *
-		sizeof(*asd->params.dvs_stat->hor_prod.odd_real);
-
-	asd->params.dvs_ver_proj_bytes =
-		dvs_grid->aligned_height * dvs_grid->aligned_width *
-		sizeof(*asd->params.dvs_stat->ver_prod.odd_real);
-
-	return 0;
-}
-
-int atomisp_alloc_metadata_output_buf(struct atomisp_sub_device *asd)
-{
-	int i;
-
-	/* We allocate the cpu-side buffer used for communication with user
-	 * space */
-	for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
-		asd->params.metadata_user[i] = kvmalloc(
-				asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].
-				stream_info.metadata_info.size, GFP_KERNEL);
-		if (!asd->params.metadata_user[i]) {
-			while (--i >= 0) {
-				kvfree(asd->params.metadata_user[i]);
-				asd->params.metadata_user[i] = NULL;
-			}
-			return -ENOMEM;
-		}
-	}
-
-	return 0;
-}
-
-void atomisp_free_metadata_output_buf(struct atomisp_sub_device *asd)
-{
-	unsigned int i;
-
-	for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
-		if (asd->params.metadata_user[i]) {
-			kvfree(asd->params.metadata_user[i]);
-			asd->params.metadata_user[i] = NULL;
-		}
-	}
-}
-
-void atomisp_css_get_dis_statistics(struct atomisp_sub_device *asd,
-				    struct atomisp_css_buffer *isp_css_buffer,
-				    struct ia_css_isp_dvs_statistics_map *dvs_map)
-{
-	if (asd->params.dvs_stat) {
-		if (dvs_map)
-			ia_css_translate_dvs2_statistics(
-				asd->params.dvs_stat, dvs_map);
-		else
-			ia_css_get_dvs2_statistics(asd->params.dvs_stat,
-				isp_css_buffer->css_buffer.data.stats_dvs);
-
-	}
-}
-
-int atomisp_css_dequeue_event(struct atomisp_css_event *current_event)
-{
-	if (ia_css_dequeue_event(&current_event->event) != IA_CSS_SUCCESS)
-		return -EINVAL;
-
-	return 0;
-}
-
-void atomisp_css_temp_pipe_to_pipe_id(struct atomisp_sub_device *asd,
-		struct atomisp_css_event *current_event)
-{
-	/*
-	 * FIXME!
-	 * Pipe ID reported in CSS event is not correct for new system's
-	 * copy pipe.
-	 * VIED BZ: 1463
-	 */
-	ia_css_temp_pipe_to_pipe_id(current_event->event.pipe,
-				    &current_event->pipe);
-	if (asd && asd->copy_mode &&
-	    current_event->pipe == IA_CSS_PIPE_ID_CAPTURE)
-		current_event->pipe = IA_CSS_PIPE_ID_COPY;
-}
-
-int atomisp_css_isys_set_resolution(struct atomisp_sub_device *asd,
-				    enum atomisp_input_stream_id stream_id,
-				    struct v4l2_mbus_framefmt *ffmt,
-				    int isys_stream)
-{
-	struct ia_css_stream_config *s_config =
-			&asd->stream_env[stream_id].stream_config;
-
-	if (isys_stream >= IA_CSS_STREAM_MAX_ISYS_STREAM_PER_CH)
-		return -EINVAL;
-
-	s_config->isys_config[isys_stream].input_res.width = ffmt->width;
-	s_config->isys_config[isys_stream].input_res.height = ffmt->height;
-	return 0;
-}
-
-int atomisp_css_input_set_resolution(struct atomisp_sub_device *asd,
-				enum atomisp_input_stream_id stream_id,
-				struct v4l2_mbus_framefmt *ffmt)
-{
-	struct ia_css_stream_config *s_config =
-			&asd->stream_env[stream_id].stream_config;
-
-	s_config->input_config.input_res.width = ffmt->width;
-	s_config->input_config.input_res.height = ffmt->height;
-	return 0;
-}
-
-void atomisp_css_input_set_binning_factor(struct atomisp_sub_device *asd,
-					enum atomisp_input_stream_id stream_id,
-					unsigned int bin_factor)
-{
-	asd->stream_env[stream_id]
-	    .stream_config.sensor_binning_factor = bin_factor;
-}
-
-void atomisp_css_input_set_bayer_order(struct atomisp_sub_device *asd,
-				enum atomisp_input_stream_id stream_id,
-				enum atomisp_css_bayer_order bayer_order)
-{
-	struct ia_css_stream_config *s_config =
-			&asd->stream_env[stream_id].stream_config;
-	s_config->input_config.bayer_order = bayer_order;
-}
-
-void atomisp_css_isys_set_link(struct atomisp_sub_device *asd,
-			       enum atomisp_input_stream_id stream_id,
-			       int link,
-			       int isys_stream)
-{
-	struct ia_css_stream_config *s_config =
-		&asd->stream_env[stream_id].stream_config;
-
-	s_config->isys_config[isys_stream].linked_isys_stream_id = link;
-}
-
-void atomisp_css_isys_set_valid(struct atomisp_sub_device *asd,
-				enum atomisp_input_stream_id stream_id,
-				bool valid,
-				int isys_stream)
-{
-	struct ia_css_stream_config *s_config =
-		&asd->stream_env[stream_id].stream_config;
-
-	s_config->isys_config[isys_stream].valid = valid;
-}
-
-void atomisp_css_isys_set_format(struct atomisp_sub_device *asd,
-				 enum atomisp_input_stream_id stream_id,
-				 enum atomisp_input_format format,
-				 int isys_stream)
-{
-
-	struct ia_css_stream_config *s_config =
-			&asd->stream_env[stream_id].stream_config;
-
-	s_config->isys_config[isys_stream].format = format;
-}
-
-void atomisp_css_input_set_format(struct atomisp_sub_device *asd,
-					enum atomisp_input_stream_id stream_id,
-					enum atomisp_input_format format)
-{
-
-	struct ia_css_stream_config *s_config =
-			&asd->stream_env[stream_id].stream_config;
-
-	s_config->input_config.format = format;
-}
-
-int atomisp_css_set_default_isys_config(struct atomisp_sub_device *asd,
-					enum atomisp_input_stream_id stream_id,
-					struct v4l2_mbus_framefmt *ffmt)
-{
-	int i;
-	struct ia_css_stream_config *s_config =
-			&asd->stream_env[stream_id].stream_config;
-	/*
-	 * Set all isys configs to not valid.
-	 * Currently we support only one stream per channel
-	 */
-	for (i = IA_CSS_STREAM_ISYS_STREAM_0;
-	     i < IA_CSS_STREAM_MAX_ISYS_STREAM_PER_CH; i++)
-		s_config->isys_config[i].valid = false;
-
-	atomisp_css_isys_set_resolution(asd, stream_id, ffmt,
-					IA_CSS_STREAM_DEFAULT_ISYS_STREAM_IDX);
-	atomisp_css_isys_set_format(asd, stream_id,
-				    s_config->input_config.format,
-				    IA_CSS_STREAM_DEFAULT_ISYS_STREAM_IDX);
-	atomisp_css_isys_set_link(asd, stream_id, NO_LINK,
-				  IA_CSS_STREAM_DEFAULT_ISYS_STREAM_IDX);
-	atomisp_css_isys_set_valid(asd, stream_id, true,
-				   IA_CSS_STREAM_DEFAULT_ISYS_STREAM_IDX);
-
-	return 0;
-}
-
-int atomisp_css_isys_two_stream_cfg(struct atomisp_sub_device *asd,
-				    enum atomisp_input_stream_id stream_id,
-				    enum atomisp_input_format input_format)
-{
-	struct ia_css_stream_config *s_config =
-		&asd->stream_env[stream_id].stream_config;
-
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].input_res.width =
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_0].input_res.width;
-
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].input_res.height =
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_0].input_res.height / 2;
-
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].linked_isys_stream_id
-		= IA_CSS_STREAM_ISYS_STREAM_0;
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_0].format =
-		ATOMISP_INPUT_FORMAT_USER_DEF1;
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].format =
-		ATOMISP_INPUT_FORMAT_USER_DEF2;
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].valid = true;
-	return 0;
-}
-
-void atomisp_css_isys_two_stream_cfg_update_stream1(
-				    struct atomisp_sub_device *asd,
-				    enum atomisp_input_stream_id stream_id,
-				    enum atomisp_input_format input_format,
-				    unsigned int width, unsigned int height)
-{
-	struct ia_css_stream_config *s_config =
-		&asd->stream_env[stream_id].stream_config;
-
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_0].input_res.width =
-		width;
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_0].input_res.height =
-		height;
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_0].format =
-		input_format;
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_0].valid = true;
-}
-
-void atomisp_css_isys_two_stream_cfg_update_stream2(
-				    struct atomisp_sub_device *asd,
-				    enum atomisp_input_stream_id stream_id,
-				    enum atomisp_input_format input_format,
-				    unsigned int width, unsigned int height)
-{
-	struct ia_css_stream_config *s_config =
-		&asd->stream_env[stream_id].stream_config;
-
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].input_res.width =
-		width;
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].input_res.height =
-	height;
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].linked_isys_stream_id
-		= IA_CSS_STREAM_ISYS_STREAM_0;
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].format =
-		input_format;
-	s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].valid = true;
-}
-
-int atomisp_css_input_set_effective_resolution(
-					struct atomisp_sub_device *asd,
-					enum atomisp_input_stream_id stream_id,
-					unsigned int width, unsigned int height)
-{
-	struct ia_css_stream_config *s_config =
-			&asd->stream_env[stream_id].stream_config;
-	s_config->input_config.effective_res.width = width;
-	s_config->input_config.effective_res.height = height;
-	return 0;
-}
-
-void atomisp_css_video_set_dis_envelope(struct atomisp_sub_device *asd,
-					unsigned int dvs_w, unsigned int dvs_h)
-{
-	asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.pipe_configs[IA_CSS_PIPE_ID_VIDEO].dvs_envelope.width = dvs_w;
-	asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.pipe_configs[IA_CSS_PIPE_ID_VIDEO].dvs_envelope.height = dvs_h;
-}
-
-void atomisp_css_input_set_two_pixels_per_clock(
-					struct atomisp_sub_device *asd,
-					bool two_ppc)
-{
-	int i;
-
-	if (asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.stream_config.pixels_per_clock == (two_ppc ? 2 : 1))
-		return;
-
-	asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.stream_config.pixels_per_clock = (two_ppc ? 2 : 1);
-	for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++)
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.update_pipe[i] = true;
-}
-
-void atomisp_css_enable_raw_binning(struct atomisp_sub_device *asd,
-					bool enable)
-{
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-	unsigned int pipe;
-
-	if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO)
-		pipe = IA_CSS_PIPE_ID_VIDEO;
-	else
-		pipe = IA_CSS_PIPE_ID_PREVIEW;
-
-	stream_env->pipe_extra_configs[pipe].enable_raw_binning = enable;
-	stream_env->update_pipe[pipe] = true;
-	if (enable)
-		stream_env->pipe_configs[pipe].output_info[0].padded_width =
-			stream_env->stream_config.input_config.effective_res.width;
-}
-
-void atomisp_css_enable_dz(struct atomisp_sub_device *asd, bool enable)
-{
-	int i;
-
-	for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++)
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-			.pipe_configs[i].enable_dz = enable;
-}
-
-void atomisp_css_capture_set_mode(struct atomisp_sub_device *asd,
-				enum atomisp_css_capture_mode mode)
-{
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-
-	if (stream_env->pipe_configs[IA_CSS_PIPE_ID_CAPTURE]
-		.default_capture_config.mode == mode)
-		return;
-
-	stream_env->pipe_configs[IA_CSS_PIPE_ID_CAPTURE].
-					default_capture_config.mode = mode;
-	stream_env->update_pipe[IA_CSS_PIPE_ID_CAPTURE] = true;
-}
-
-void atomisp_css_input_set_mode(struct atomisp_sub_device *asd,
-				enum atomisp_css_input_mode mode)
-{
-	int i;
-	struct atomisp_device *isp = asd->isp;
-	unsigned int size_mem_words;
-
-	for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++)
-		asd->stream_env[i].stream_config.mode = mode;
-
-	if (isp->inputs[asd->input_curr].type == TEST_PATTERN) {
-		struct ia_css_stream_config *s_config =
-		    &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream_config;
-		s_config->mode = IA_CSS_INPUT_MODE_TPG;
-		s_config->source.tpg.mode = IA_CSS_TPG_MODE_CHECKERBOARD;
-		s_config->source.tpg.x_mask = (1 << 4) - 1;
-		s_config->source.tpg.x_delta = -2;
-		s_config->source.tpg.y_mask = (1 << 4) - 1;
-		s_config->source.tpg.y_delta = 3;
-		s_config->source.tpg.xy_mask = (1 << 8) - 1;
-		return;
-	}
-
-	if (mode != IA_CSS_INPUT_MODE_BUFFERED_SENSOR)
-		return;
-
-	for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
-		/*
-		 * TODO: sensor needs to export the embedded_data_size_words
-		 * information to atomisp for each setting.
-		 * Here using a large safe value.
-		 */
-		struct ia_css_stream_config *s_config =
-			&asd->stream_env[i].stream_config;
-
-		if (s_config->input_config.input_res.width == 0)
-			continue;
-
-		if (ia_css_mipi_frame_calculate_size(
-					s_config->input_config.input_res.width,
-					s_config->input_config.input_res.height,
-					s_config->input_config.format,
-					true,
-					0x13000,
-					&size_mem_words) != IA_CSS_SUCCESS) {
-			if (intel_mid_identify_cpu() ==
-				INTEL_MID_CPU_CHIP_TANGIER)
-				size_mem_words = CSS_MIPI_FRAME_BUFFER_SIZE_2;
-			else
-				size_mem_words = CSS_MIPI_FRAME_BUFFER_SIZE_1;
-			dev_warn(asd->isp->dev,
-				"ia_css_mipi_frame_calculate_size failed,"
-				"applying pre-defined MIPI buffer size %u.\n",
-				size_mem_words);
-		}
-		s_config->mipi_buffer_config.size_mem_words = size_mem_words;
-		s_config->mipi_buffer_config.nof_mipi_buffers = 2;
-	}
-}
-
-void atomisp_css_capture_enable_online(struct atomisp_sub_device *asd,
-				unsigned short stream_index, bool enable)
-{
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[stream_index];
-
-	if (stream_env->stream_config.online == !!enable)
-		return;
-
-	stream_env->stream_config.online = !!enable;
-	stream_env->update_pipe[IA_CSS_PIPE_ID_CAPTURE] = true;
-}
-
-void atomisp_css_preview_enable_online(struct atomisp_sub_device *asd,
-				unsigned short stream_index, bool enable)
-{
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[stream_index];
-	int i;
-
-	if (stream_env->stream_config.online != !!enable) {
-		stream_env->stream_config.online = !!enable;
-		for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++)
-			stream_env->update_pipe[i] = true;
-	}
-}
-
-void atomisp_css_video_enable_online(struct atomisp_sub_device *asd,
-							bool enable)
-{
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_VIDEO];
-	int i;
-
-	if (stream_env->stream_config.online != enable) {
-		stream_env->stream_config.online = enable;
-		for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++)
-			stream_env->update_pipe[i] = true;
-	}
-}
-
-void atomisp_css_enable_continuous(struct atomisp_sub_device *asd,
-							bool enable)
-{
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-	int i;
-
-	/*
-	 * To SOC camera, there is only one YUVPP pipe in any case
-	 * including ZSL/SDV/continuous viewfinder, so always set
-	 * stream_config.continuous to 0.
-	 */
-	if (ATOMISP_USE_YUVPP(asd)) {
-		stream_env->stream_config.continuous = 0;
-		stream_env->stream_config.online = 1;
-		return;
-	}
-
-	if (stream_env->stream_config.continuous != !!enable) {
-		stream_env->stream_config.continuous = !!enable;
-		stream_env->stream_config.pack_raw_pixels = true;
-		for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++)
-			stream_env->update_pipe[i] = true;
-	}
-}
-
-void atomisp_css_enable_cvf(struct atomisp_sub_device *asd,
-				bool enable)
-{
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-	int i;
-
-	if (stream_env->stream_config.disable_cont_viewfinder != !enable) {
-		stream_env->stream_config.disable_cont_viewfinder = !enable;
-		for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++)
-			stream_env->update_pipe[i] = true;
-	}
-}
-
-int atomisp_css_input_configure_port(
-		struct atomisp_sub_device *asd,
-		enum mipi_port_id port,
-		unsigned int num_lanes,
-		unsigned int timeout,
-		unsigned int mipi_freq,
-		enum atomisp_input_format metadata_format,
-		unsigned int metadata_width,
-		unsigned int metadata_height)
-{
-	int i;
-	struct atomisp_stream_env *stream_env;
-	/*
-	 * Calculate rx_count as follows:
-	 * Input: mipi_freq                 : CSI-2 bus frequency in Hz
-	 * UI = 1 / (2 * mipi_freq)         : period of one bit on the bus
-	 * min = 85e-9 + 6 * UI             : Limits for rx_count in seconds
-	 * max = 145e-9 + 10 * UI
-	 * rxcount0 = min / (4 / mipi_freq) : convert seconds to byte clocks
-	 * rxcount = rxcount0 - 2           : adjust for better results
-	 * The formula below is simplified version of the above with
-	 * 10-bit fixed points for improved accuracy.
-	 */
-	const unsigned int rxcount =
-		min(((mipi_freq / 46000) - 1280) >> 10, 0xffU) * 0x01010101U;
-
-	for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
-		stream_env = &asd->stream_env[i];
-		stream_env->stream_config.source.port.port = port;
-		stream_env->stream_config.source.port.num_lanes = num_lanes;
-		stream_env->stream_config.source.port.timeout = timeout;
-		if (mipi_freq)
-			stream_env->stream_config.source.port.rxcount = rxcount;
-		stream_env->stream_config.
-			metadata_config.data_type = metadata_format;
-		stream_env->stream_config.
-			metadata_config.resolution.width = metadata_width;
-		stream_env->stream_config.
-			metadata_config.resolution.height = metadata_height;
-	}
-
-	return 0;
-}
-
-int atomisp_css_frame_allocate(struct atomisp_css_frame **frame,
-				unsigned int width, unsigned int height,
-				enum atomisp_css_frame_format format,
-				unsigned int padded_width,
-				unsigned int raw_bit_depth)
-{
-	if (ia_css_frame_allocate(frame, width, height, format,
-			padded_width, raw_bit_depth) != IA_CSS_SUCCESS)
-		return -ENOMEM;
-
-	return 0;
-}
-
-int atomisp_css_frame_allocate_from_info(struct atomisp_css_frame **frame,
-				const struct atomisp_css_frame_info *info)
-{
-	if (ia_css_frame_allocate_from_info(frame, info) != IA_CSS_SUCCESS)
-		return -ENOMEM;
-
-	return 0;
-}
-
-void atomisp_css_frame_free(struct atomisp_css_frame *frame)
-{
-	ia_css_frame_free(frame);
-}
-
-int atomisp_css_frame_map(struct atomisp_css_frame **frame,
-				const struct atomisp_css_frame_info *info,
-				const void __user *data, uint16_t attribute,
-				void *context)
-{
-	if (ia_css_frame_map(frame, info, data, attribute, context)
-	    != IA_CSS_SUCCESS)
-		return -ENOMEM;
-
-	return 0;
-}
-
-int atomisp_css_set_black_frame(struct atomisp_sub_device *asd,
-				const struct atomisp_css_frame *raw_black_frame)
-{
-	if (sh_css_set_black_frame(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		raw_black_frame) != IA_CSS_SUCCESS)
-		return -ENOMEM;
-
-	return 0;
-}
-
-int atomisp_css_allocate_continuous_frames(bool init_time,
-				struct atomisp_sub_device *asd)
-{
-	if (ia_css_alloc_continuous_frame_remain(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream)
-			!= IA_CSS_SUCCESS)
-		return -EINVAL;
-	return 0;
-}
-
-void atomisp_css_update_continuous_frames(struct atomisp_sub_device *asd)
-{
-	ia_css_update_continuous_frames(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream);
-}
-
-int atomisp_css_stop(struct atomisp_sub_device *asd,
-			enum atomisp_css_pipe_id pipe_id, bool in_reset)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct atomisp_s3a_buf *s3a_buf;
-	struct atomisp_dis_buf *dis_buf;
-	struct atomisp_metadata_buf *md_buf;
-	unsigned long irqflags;
-	unsigned int i;
-
-	/* if is called in atomisp_reset(), force destroy stream */
-	if (__destroy_streams(asd, true))
-		dev_err(isp->dev, "destroy stream failed.\n");
-
-	/* if is called in atomisp_reset(), force destroy all pipes */
-	if (__destroy_pipes(asd, true))
-		dev_err(isp->dev, "destroy pipes failed.\n");
-
-	atomisp_init_raw_buffer_bitmap(asd);
-
-	/*
-	 * SP can not be stop if other streams are in use
-	 */
-	if (atomisp_streaming_count(isp) == 0)
-		ia_css_stop_sp();
-
-	if (!in_reset) {
-		struct atomisp_stream_env *stream_env;
-		int i, j;
-
-		for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) {
-			stream_env = &asd->stream_env[i];
-			for (j = 0; j < IA_CSS_PIPE_ID_NUM; j++) {
-				ia_css_pipe_config_defaults(
-					&stream_env->pipe_configs[j]);
-				ia_css_pipe_extra_config_defaults(
-					&stream_env->pipe_extra_configs[j]);
-			}
-			ia_css_stream_config_defaults(
-				&stream_env->stream_config);
-		}
-		atomisp_isp_parameters_clean_up(&asd->params.config);
-		asd->params.css_update_params_needed = false;
-	}
-
-	/* move stats buffers to free queue list */
-	while (!list_empty(&asd->s3a_stats_in_css)) {
-		s3a_buf = list_entry(asd->s3a_stats_in_css.next,
-				struct atomisp_s3a_buf, list);
-		list_del(&s3a_buf->list);
-		list_add_tail(&s3a_buf->list, &asd->s3a_stats);
-	}
-	while (!list_empty(&asd->s3a_stats_ready)) {
-		s3a_buf = list_entry(asd->s3a_stats_ready.next,
-				struct atomisp_s3a_buf, list);
-		list_del(&s3a_buf->list);
-		list_add_tail(&s3a_buf->list, &asd->s3a_stats);
-	}
-
-	spin_lock_irqsave(&asd->dis_stats_lock, irqflags);
-	while (!list_empty(&asd->dis_stats_in_css)) {
-		dis_buf = list_entry(asd->dis_stats_in_css.next,
-				struct atomisp_dis_buf, list);
-		list_del(&dis_buf->list);
-		list_add_tail(&dis_buf->list, &asd->dis_stats);
-	}
-	asd->params.dis_proj_data_valid = false;
-	spin_unlock_irqrestore(&asd->dis_stats_lock, irqflags);
-
-	for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
-		while (!list_empty(&asd->metadata_in_css[i])) {
-			md_buf = list_entry(asd->metadata_in_css[i].next,
-					struct atomisp_metadata_buf, list);
-			list_del(&md_buf->list);
-			list_add_tail(&md_buf->list, &asd->metadata[i]);
-		}
-		while (!list_empty(&asd->metadata_ready[i])) {
-			md_buf = list_entry(asd->metadata_ready[i].next,
-					struct atomisp_metadata_buf, list);
-			list_del(&md_buf->list);
-			list_add_tail(&md_buf->list, &asd->metadata[i]);
-		}
-	}
-
-	atomisp_flush_params_queue(&asd->video_out_capture);
-	atomisp_flush_params_queue(&asd->video_out_vf);
-	atomisp_flush_params_queue(&asd->video_out_preview);
-	atomisp_flush_params_queue(&asd->video_out_video_capture);
-	atomisp_free_css_parameters(&asd->params.css_param);
-	memset(&asd->params.css_param, 0, sizeof(asd->params.css_param));
-	return 0;
-}
-
-int atomisp_css_continuous_set_num_raw_frames(
-					struct atomisp_sub_device *asd,
-					int num_frames)
-{
-	if (asd->enable_raw_buffer_lock->val) {
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.stream_config.init_num_cont_raw_buf =
-			ATOMISP_CSS2_NUM_OFFLINE_INIT_CONTINUOUS_FRAMES_LOCK_EN;
-		if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO &&
-		    asd->params.video_dis_en)
-			asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-			.stream_config.init_num_cont_raw_buf +=
-				ATOMISP_CSS2_NUM_DVS_FRAME_DELAY;
-	} else {
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.stream_config.init_num_cont_raw_buf =
-			ATOMISP_CSS2_NUM_OFFLINE_INIT_CONTINUOUS_FRAMES;
-	}
-
-	if (asd->params.video_dis_en)
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-			.stream_config.init_num_cont_raw_buf +=
-				ATOMISP_CSS2_NUM_DVS_FRAME_DELAY;
-
-	asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.stream_config.target_num_cont_raw_buf = num_frames;
-	return 0;
-}
-
-void atomisp_css_disable_vf_pp(struct atomisp_sub_device *asd,
-			       bool disable)
-{
-	int i;
-
-	for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++)
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.pipe_extra_configs[i].disable_vf_pp = !!disable;
-}
-
-static enum ia_css_pipe_mode __pipe_id_to_pipe_mode(
-					struct atomisp_sub_device *asd,
-					enum ia_css_pipe_id pipe_id)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct camera_mipi_info *mipi_info = atomisp_to_sensor_mipi_info(
-			isp->inputs[asd->input_curr].camera);
-
-	switch (pipe_id) {
-	case IA_CSS_PIPE_ID_COPY:
-		/* Currently only YUVPP mode supports YUV420_Legacy format.
-		 * Revert this when other pipe modes can support
-		 * YUV420_Legacy format.
-		 */
-		if (mipi_info && mipi_info->input_format ==
-			ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY)
-			return IA_CSS_PIPE_MODE_YUVPP;
-		return IA_CSS_PIPE_MODE_COPY;
-	case IA_CSS_PIPE_ID_PREVIEW:
-		return IA_CSS_PIPE_MODE_PREVIEW;
-	case IA_CSS_PIPE_ID_CAPTURE:
-		return IA_CSS_PIPE_MODE_CAPTURE;
-	case IA_CSS_PIPE_ID_VIDEO:
-		return IA_CSS_PIPE_MODE_VIDEO;
-	case IA_CSS_PIPE_ID_ACC:
-		return IA_CSS_PIPE_MODE_ACC;
-	case IA_CSS_PIPE_ID_YUVPP:
-		return IA_CSS_PIPE_MODE_YUVPP;
-	default:
-		WARN_ON(1);
-		return IA_CSS_PIPE_MODE_PREVIEW;
-	}
-
-}
-
-static void __configure_output(struct atomisp_sub_device *asd,
-			       unsigned int stream_index,
-			       unsigned int width, unsigned int height,
-			       unsigned int min_width,
-			       enum ia_css_frame_format format,
-			       enum ia_css_pipe_id pipe_id)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[stream_index];
-	struct ia_css_stream_config *s_config = &stream_env->stream_config;
-
-	stream_env->pipe_configs[pipe_id].mode =
-		__pipe_id_to_pipe_mode(asd, pipe_id);
-	stream_env->update_pipe[pipe_id] = true;
-
-	stream_env->pipe_configs[pipe_id].output_info[0].res.width = width;
-	stream_env->pipe_configs[pipe_id].output_info[0].res.height = height;
-	stream_env->pipe_configs[pipe_id].output_info[0].format = format;
-	stream_env->pipe_configs[pipe_id].output_info[0].padded_width = min_width;
-
-	/* isp binary 2.2 specific setting*/
-	if (width > s_config->input_config.effective_res.width ||
-	    height > s_config->input_config.effective_res.height) {
-		s_config->input_config.effective_res.width = width;
-		s_config->input_config.effective_res.height = height;
-	}
-
-	dev_dbg(isp->dev, "configuring pipe[%d] output info w=%d.h=%d.f=%d.\n",
-		pipe_id, width, height, format);
-}
-
-static void __configure_video_preview_output(struct atomisp_sub_device *asd,
-			       unsigned int stream_index,
-			       unsigned int width, unsigned int height,
-			       unsigned int min_width,
-			       enum ia_css_frame_format format,
-			       enum ia_css_pipe_id pipe_id)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[stream_index];
-	struct ia_css_frame_info *css_output_info;
-	struct ia_css_stream_config *stream_config = &stream_env->stream_config;
-
-	stream_env->pipe_configs[pipe_id].mode =
-		__pipe_id_to_pipe_mode(asd, pipe_id);
-	stream_env->update_pipe[pipe_id] = true;
-
-	/*
-	 * second_output will be as video main output in SDV mode
-	 * with SOC camera. output will be as video main output in
-	 * normal video mode.
-	 */
-	if (asd->continuous_mode->val)
-		css_output_info = &stream_env->pipe_configs[pipe_id].
-			output_info[ATOMISP_CSS_OUTPUT_SECOND_INDEX];
-	else
-		css_output_info = &stream_env->pipe_configs[pipe_id].
-			output_info[ATOMISP_CSS_OUTPUT_DEFAULT_INDEX];
-
-	css_output_info->res.width = width;
-	css_output_info->res.height = height;
-	css_output_info->format = format;
-	css_output_info->padded_width = min_width;
-
-	/* isp binary 2.2 specific setting*/
-	if (width > stream_config->input_config.effective_res.width ||
-	    height > stream_config->input_config.effective_res.height) {
-		stream_config->input_config.effective_res.width = width;
-		stream_config->input_config.effective_res.height = height;
-	}
-
-	dev_dbg(isp->dev, "configuring pipe[%d] output info w=%d.h=%d.f=%d.\n",
-		pipe_id, width, height, format);
-}
-
-/*
- * For CSS2.1, capture pipe uses capture_pp_in_res to configure yuv
- * downscaling input resolution.
- */
-static void __configure_capture_pp_input(struct atomisp_sub_device *asd,
-				 unsigned int width, unsigned int height,
-				 enum ia_css_pipe_id pipe_id)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-	struct ia_css_stream_config *stream_config = &stream_env->stream_config;
-	struct ia_css_pipe_config *pipe_configs =
-		&stream_env->pipe_configs[pipe_id];
-	struct ia_css_pipe_extra_config *pipe_extra_configs =
-		&stream_env->pipe_extra_configs[pipe_id];
-	unsigned int hor_ds_factor = 0, ver_ds_factor = 0;
-
-	if (width == 0 && height == 0)
-		return;
-
-	if (width * 9 / 10 < pipe_configs->output_info[0].res.width ||
-	    height * 9 / 10 < pipe_configs->output_info[0].res.height)
-		return;
-	/* here just copy the calculation in css */
-	hor_ds_factor = CEIL_DIV(width >> 1,
-			pipe_configs->output_info[0].res.width);
-	ver_ds_factor = CEIL_DIV(height >> 1,
-			pipe_configs->output_info[0].res.height);
-
-	if ((asd->isp->media_dev.hw_revision <
-	    (ATOMISP_HW_REVISION_ISP2401 << ATOMISP_HW_REVISION_SHIFT) ||
-	    IS_CHT) && hor_ds_factor != ver_ds_factor) {
-		dev_warn(asd->isp->dev,
-				"Cropping for capture due to FW limitation");
-		return;
-	}
-
-	pipe_configs->mode = __pipe_id_to_pipe_mode(asd, pipe_id);
-	stream_env->update_pipe[pipe_id] = true;
-
-	pipe_extra_configs->enable_yuv_ds = true;
-
-	pipe_configs->capt_pp_in_res.width =
-		stream_config->input_config.effective_res.width;
-	pipe_configs->capt_pp_in_res.height =
-		stream_config->input_config.effective_res.height;
-
-	dev_dbg(isp->dev, "configuring pipe[%d]capture pp input w=%d.h=%d.\n",
-		pipe_id, width, height);
-}
-
-/*
- * For CSS2.1, preview pipe could support bayer downscaling, yuv decimation and
- * yuv downscaling, which needs addtional configurations.
- */
-static void __configure_preview_pp_input(struct atomisp_sub_device *asd,
-				 unsigned int width, unsigned int height,
-				 enum ia_css_pipe_id pipe_id)
-{
-	struct atomisp_device *isp = asd->isp;
-	int out_width, out_height, yuv_ds_in_width, yuv_ds_in_height;
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-	struct ia_css_stream_config *stream_config = &stream_env->stream_config;
-	struct ia_css_pipe_config *pipe_configs =
-		&stream_env->pipe_configs[pipe_id];
-	struct ia_css_pipe_extra_config *pipe_extra_configs =
-		&stream_env->pipe_extra_configs[pipe_id];
-	struct ia_css_resolution *bayer_ds_out_res =
-		&pipe_configs->bayer_ds_out_res;
-	struct ia_css_resolution *vf_pp_in_res =
-		&pipe_configs->vf_pp_in_res;
-	struct ia_css_resolution  *effective_res =
-		&stream_config->input_config.effective_res;
-
-	const struct bayer_ds_factor bds_fct[] = {{2, 1}, {3, 2}, {5, 4} };
-	/*
-	 * BZ201033: YUV decimation factor of 4 causes couple of rightmost
-	 * columns to be shaded. Remove this factor to work around the CSS bug.
-	 * const unsigned int yuv_dec_fct[] = {4, 2};
-	 */
-	const unsigned int yuv_dec_fct[] = { 2 };
-	unsigned int i;
-
-	if (width == 0 && height == 0)
-		return;
-
-	pipe_configs->mode = __pipe_id_to_pipe_mode(asd, pipe_id);
-	stream_env->update_pipe[pipe_id] = true;
-
-	out_width = pipe_configs->output_info[0].res.width;
-	out_height = pipe_configs->output_info[0].res.height;
-
-	/*
-	 * The ISP could do bayer downscaling, yuv decimation and yuv
-	 * downscaling:
-	 * 1: Bayer Downscaling: between effective resolution and
-	 * bayer_ds_res_out;
-	 * 2: YUV Decimation: between bayer_ds_res_out and vf_pp_in_res;
-	 * 3: YUV Downscaling: between vf_pp_in_res and final vf output
-	 *
-	 * Rule for Bayer Downscaling: support factor 2, 1.5 and 1.25
-	 * Rule for YUV Decimation: support factor 2, 4
-	 * Rule for YUV Downscaling: arbitary value below 2
-	 *
-	 * General rule of factor distribution among these stages:
-	 * 1: try to do Bayer downscaling first if not in online mode.
-	 * 2: try to do maximum of 2 for YUV downscaling
-	 * 3: the remainling for YUV decimation
-	 *
-	 * Note:
-	 * Do not configure bayer_ds_out_res if:
-	 * online == 1 or continuous == 0 or raw_binning = 0
-	 */
-	if (stream_config->online || !stream_config->continuous ||
-			!pipe_extra_configs->enable_raw_binning) {
-		bayer_ds_out_res->width = 0;
-		bayer_ds_out_res->height = 0;
-	} else {
-		bayer_ds_out_res->width = effective_res->width;
-		bayer_ds_out_res->height = effective_res->height;
-
-		for (i = 0; i < ARRAY_SIZE(bds_fct); i++) {
-			if (effective_res->width >= out_width *
-			    bds_fct[i].numerator / bds_fct[i].denominator &&
-			    effective_res->height >= out_height *
-			    bds_fct[i].numerator / bds_fct[i].denominator) {
-				bayer_ds_out_res->width =
-				    effective_res->width *
-				    bds_fct[i].denominator /
-				    bds_fct[i].numerator;
-				bayer_ds_out_res->height =
-				    effective_res->height *
-				    bds_fct[i].denominator /
-				    bds_fct[i].numerator;
-				break;
-			}
-		}
-	}
-	/*
-	 * calculate YUV Decimation, YUV downscaling facor:
-	 * YUV Downscaling factor must not exceed 2.
-	 * YUV Decimation factor could be 2, 4.
-	 */
-	/* first decide the yuv_ds input resolution */
-	if (bayer_ds_out_res->width == 0) {
-		yuv_ds_in_width = effective_res->width;
-		yuv_ds_in_height = effective_res->height;
-	} else {
-		yuv_ds_in_width = bayer_ds_out_res->width;
-		yuv_ds_in_height = bayer_ds_out_res->height;
-	}
-
-	vf_pp_in_res->width = yuv_ds_in_width;
-	vf_pp_in_res->height = yuv_ds_in_height;
-
-	/* find out the yuv decimation factor */
-	for (i = 0; i < ARRAY_SIZE(yuv_dec_fct); i++) {
-		if (yuv_ds_in_width >= out_width * yuv_dec_fct[i] &&
-		    yuv_ds_in_height >= out_height * yuv_dec_fct[i]) {
-			vf_pp_in_res->width = yuv_ds_in_width / yuv_dec_fct[i];
-			vf_pp_in_res->height = yuv_ds_in_height / yuv_dec_fct[i];
-			break;
-		}
-	}
-
-	if (vf_pp_in_res->width == out_width &&
-		vf_pp_in_res->height == out_height) {
-		pipe_extra_configs->enable_yuv_ds = false;
-		vf_pp_in_res->width = 0;
-		vf_pp_in_res->height = 0;
-	} else {
-		pipe_extra_configs->enable_yuv_ds = true;
-	}
-
-	dev_dbg(isp->dev, "configuring pipe[%d]preview pp input w=%d.h=%d.\n",
-		pipe_id, width, height);
-}
-
-/*
- * For CSS2.1, offline video pipe could support bayer decimation, and
- * yuv downscaling, which needs addtional configurations.
- */
-static void __configure_video_pp_input(struct atomisp_sub_device *asd,
-				 unsigned int width, unsigned int height,
-				 enum ia_css_pipe_id pipe_id)
-{
-	struct atomisp_device *isp = asd->isp;
-	int out_width, out_height;
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-	struct ia_css_stream_config *stream_config = &stream_env->stream_config;
-	struct ia_css_pipe_config *pipe_configs =
-		&stream_env->pipe_configs[pipe_id];
-	struct ia_css_pipe_extra_config *pipe_extra_configs =
-		&stream_env->pipe_extra_configs[pipe_id];
-	struct ia_css_resolution *bayer_ds_out_res =
-		&pipe_configs->bayer_ds_out_res;
-	struct ia_css_resolution  *effective_res =
-		&stream_config->input_config.effective_res;
-
-	const struct bayer_ds_factor bds_factors[] = {
-		{8, 1}, {6, 1}, {4, 1}, {3, 1}, {2, 1}, {3, 2} };
-	unsigned int i;
-
-	if (width == 0 && height == 0)
-		return;
-
-	pipe_configs->mode = __pipe_id_to_pipe_mode(asd, pipe_id);
-	stream_env->update_pipe[pipe_id] = true;
-
-	pipe_extra_configs->enable_yuv_ds = false;
-
-	/*
-	 * If DVS is enabled,  video binary will take care the dvs envelope
-	 * and usually the bayer_ds_out_res should be larger than 120% of
-	 * destination resolution, the extra 20% will be cropped as DVS
-	 * envelope. But,  if the bayer_ds_out_res is less than 120% of the
-	 * destination. The ISP can still work,  but DVS quality is not good.
-	 */
-	/* taking at least 10% as envelope */
-	if (asd->params.video_dis_en) {
-		out_width = pipe_configs->output_info[0].res.width * 110 / 100;
-		out_height = pipe_configs->output_info[0].res.height * 110 / 100;
-	} else {
-		out_width = pipe_configs->output_info[0].res.width;
-		out_height = pipe_configs->output_info[0].res.height;
-	}
-
-	/*
-	 * calculate bayer decimate factor:
-	 * 1: only 1.5, 2, 4 and 8 get supported
-	 * 2: Do not configure bayer_ds_out_res if:
-	 *    online == 1 or continuous == 0 or raw_binning = 0
-	 */
-	if (stream_config->online || !stream_config->continuous) {
-		bayer_ds_out_res->width = 0;
-		bayer_ds_out_res->height = 0;
-		goto done;
-	}
-
-	pipe_extra_configs->enable_raw_binning = true;
-	bayer_ds_out_res->width = effective_res->width;
-	bayer_ds_out_res->height = effective_res->height;
-
-	for (i = 0; i < sizeof(bds_factors) / sizeof(struct bayer_ds_factor);
-	     i++) {
-		if (effective_res->width >= out_width *
-		    bds_factors[i].numerator / bds_factors[i].denominator &&
-		    effective_res->height >= out_height *
-		    bds_factors[i].numerator / bds_factors[i].denominator) {
-			bayer_ds_out_res->width = effective_res->width *
-			    bds_factors[i].denominator /
-			    bds_factors[i].numerator;
-			bayer_ds_out_res->height = effective_res->height *
-			    bds_factors[i].denominator /
-			    bds_factors[i].numerator;
-			break;
-		}
-	}
-
-	/*
-	 * DVS is cropped from BDS output, so we do not really need to set the
-	 * envelope to 20% of output resolution here. always set it to 12x12
-	 * per firmware requirement.
-	 */
-	pipe_configs->dvs_envelope.width = 12;
-	pipe_configs->dvs_envelope.height = 12;
-
-done:
-	if (pipe_id == IA_CSS_PIPE_ID_YUVPP)
-		stream_config->left_padding = -1;
-	else
-		stream_config->left_padding = 12;
-	dev_dbg(isp->dev, "configuring pipe[%d]video pp input w=%d.h=%d.\n",
-		pipe_id, width, height);
-}
-
-static void __configure_vf_output(struct atomisp_sub_device *asd,
-				  unsigned int width, unsigned int height,
-				  unsigned int min_width,
-				  enum atomisp_css_frame_format format,
-				  enum ia_css_pipe_id pipe_id)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-	stream_env->pipe_configs[pipe_id].mode =
-		__pipe_id_to_pipe_mode(asd, pipe_id);
-	stream_env->update_pipe[pipe_id] = true;
-
-	stream_env->pipe_configs[pipe_id].vf_output_info[0].res.width = width;
-	stream_env->pipe_configs[pipe_id].vf_output_info[0].res.height = height;
-	stream_env->pipe_configs[pipe_id].vf_output_info[0].format = format;
-	stream_env->pipe_configs[pipe_id].vf_output_info[0].padded_width =
-		min_width;
-	dev_dbg(isp->dev,
-		"configuring pipe[%d] vf output info w=%d.h=%d.f=%d.\n",
-		 pipe_id, width, height, format);
-}
-
-static void __configure_video_vf_output(struct atomisp_sub_device *asd,
-				  unsigned int width, unsigned int height,
-				  unsigned int min_width,
-				  enum atomisp_css_frame_format format,
-				  enum ia_css_pipe_id pipe_id)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-	struct ia_css_frame_info *css_output_info;
-
-	stream_env->pipe_configs[pipe_id].mode =
-					__pipe_id_to_pipe_mode(asd, pipe_id);
-	stream_env->update_pipe[pipe_id] = true;
-
-	/*
-	 * second_vf_output will be as video viewfinder in SDV mode
-	 * with SOC camera. vf_output will be as video viewfinder in
-	 * normal video mode.
-	 */
-	if (asd->continuous_mode->val)
-		css_output_info = &stream_env->pipe_configs[pipe_id].
-			vf_output_info[ATOMISP_CSS_OUTPUT_SECOND_INDEX];
-	else
-		css_output_info = &stream_env->pipe_configs[pipe_id].
-			vf_output_info[ATOMISP_CSS_OUTPUT_DEFAULT_INDEX];
-
-	css_output_info->res.width = width;
-	css_output_info->res.height = height;
-	css_output_info->format = format;
-	css_output_info->padded_width = min_width;
-	dev_dbg(isp->dev,
-		"configuring pipe[%d] vf output info w=%d.h=%d.f=%d.\n",
-		 pipe_id, width, height, format);
-}
-
-static int __get_frame_info(struct atomisp_sub_device *asd,
-				unsigned int stream_index,
-				struct atomisp_css_frame_info *info,
-				enum frame_info_type type,
-				enum ia_css_pipe_id pipe_id)
-{
-	struct atomisp_device *isp = asd->isp;
-	enum ia_css_err ret;
-	struct ia_css_pipe_info p_info;
-
-	/* FIXME! No need to destroy/recreate all streams */
-	if (__destroy_streams(asd, true))
-		dev_warn(isp->dev, "destroy stream failed.\n");
-
-	if (__destroy_pipes(asd, true))
-		dev_warn(isp->dev, "destroy pipe failed.\n");
-
-	if (__create_pipes(asd))
-		return -EINVAL;
-
-	if (__create_streams(asd))
-		goto stream_err;
-
-	ret = ia_css_pipe_get_info(
-		asd->stream_env[stream_index]
-		.pipes[pipe_id], &p_info);
-	if (ret == IA_CSS_SUCCESS) {
-		switch (type) {
-		case ATOMISP_CSS_VF_FRAME:
-			*info = p_info.vf_output_info[0];
-			dev_dbg(isp->dev, "getting vf frame info.\n");
-			break;
-		case ATOMISP_CSS_SECOND_VF_FRAME:
-			*info = p_info.vf_output_info[1];
-			dev_dbg(isp->dev, "getting second vf frame info.\n");
-			break;
-		case ATOMISP_CSS_OUTPUT_FRAME:
-			*info = p_info.output_info[0];
-			dev_dbg(isp->dev, "getting main frame info.\n");
-			break;
-		case ATOMISP_CSS_SECOND_OUTPUT_FRAME:
-			*info = p_info.output_info[1];
-			dev_dbg(isp->dev, "getting second main frame info.\n");
-			break;
-		case ATOMISP_CSS_RAW_FRAME:
-			*info = p_info.raw_output_info;
-			dev_dbg(isp->dev, "getting raw frame info.\n");
-		}
-		dev_dbg(isp->dev, "get frame info: w=%d, h=%d, num_invalid_frames %d.\n",
-			info->res.width, info->res.height, p_info.num_invalid_frames);
-		return 0;
-	}
-
-stream_err:
-	__destroy_pipes(asd, true);
-	return -EINVAL;
-}
-
-static unsigned int atomisp_get_pipe_index(struct atomisp_sub_device *asd,
-					   uint16_t source_pad)
-{
-	struct atomisp_device *isp = asd->isp;
-	/*
-	 * to SOC camera, use yuvpp pipe.
-	 */
-	if (ATOMISP_USE_YUVPP(asd))
-		return IA_CSS_PIPE_ID_YUVPP;
-
-	switch (source_pad) {
-	case ATOMISP_SUBDEV_PAD_SOURCE_VIDEO:
-		if (asd->yuvpp_mode)
-			return IA_CSS_PIPE_ID_YUVPP;
-		if (asd->copy_mode)
-			return IA_CSS_PIPE_ID_COPY;
-		if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO
-		    || asd->vfpp->val == ATOMISP_VFPP_DISABLE_SCALER)
-			return IA_CSS_PIPE_ID_VIDEO;
-		else
-			return IA_CSS_PIPE_ID_CAPTURE;
-	case ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE:
-		if (asd->copy_mode)
-			return IA_CSS_PIPE_ID_COPY;
-		return IA_CSS_PIPE_ID_CAPTURE;
-	case ATOMISP_SUBDEV_PAD_SOURCE_VF:
-		if (!atomisp_is_mbuscode_raw(
-		    asd->fmt[asd->capture_pad].fmt.code))
-			return IA_CSS_PIPE_ID_CAPTURE;
-	case ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW:
-		if (asd->yuvpp_mode)
-			return IA_CSS_PIPE_ID_YUVPP;
-		if (asd->copy_mode)
-			return IA_CSS_PIPE_ID_COPY;
-		if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO)
-			return IA_CSS_PIPE_ID_VIDEO;
-		else
-			return IA_CSS_PIPE_ID_PREVIEW;
-	}
-	dev_warn(isp->dev,
-		 "invalid source pad:%d, return default preview pipe index.\n",
-		 source_pad);
-	return IA_CSS_PIPE_ID_PREVIEW;
-}
-
-int atomisp_get_css_frame_info(struct atomisp_sub_device *asd,
-				uint16_t source_pad,
-				struct atomisp_css_frame_info *frame_info)
-{
-	struct ia_css_pipe_info info;
-	int pipe_index = atomisp_get_pipe_index(asd, source_pad);
-	int stream_index;
-	struct atomisp_device *isp = asd->isp;
-
-	if (ATOMISP_SOC_CAMERA(asd))
-		stream_index = atomisp_source_pad_to_stream_id(asd, source_pad);
-	else {
-		stream_index = (pipe_index == IA_CSS_PIPE_ID_YUVPP) ?
-			   ATOMISP_INPUT_STREAM_VIDEO :
-			   atomisp_source_pad_to_stream_id(asd, source_pad);
-	}
-
-	if (IA_CSS_SUCCESS != ia_css_pipe_get_info(asd->stream_env[stream_index]
-				 .pipes[pipe_index], &info)) {
-		dev_err(isp->dev, "ia_css_pipe_get_info FAILED");
-		return -EINVAL;
-	}
-
-	switch (source_pad) {
-	case ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE:
-		*frame_info = info.output_info[0];
-		break;
-	case ATOMISP_SUBDEV_PAD_SOURCE_VIDEO:
-		if (ATOMISP_USE_YUVPP(asd) && asd->continuous_mode->val)
-			*frame_info = info.
-				output_info[ATOMISP_CSS_OUTPUT_SECOND_INDEX];
-		else
-			*frame_info = info.
-				output_info[ATOMISP_CSS_OUTPUT_DEFAULT_INDEX];
-		break;
-	case ATOMISP_SUBDEV_PAD_SOURCE_VF:
-		if (stream_index == ATOMISP_INPUT_STREAM_POSTVIEW)
-			*frame_info = info.output_info[0];
-		else
-			*frame_info = info.vf_output_info[0];
-		break;
-	case ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW:
-		if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO &&
-		    (pipe_index == IA_CSS_PIPE_ID_VIDEO ||
-		     pipe_index == IA_CSS_PIPE_ID_YUVPP))
-			if (ATOMISP_USE_YUVPP(asd) && asd->continuous_mode->val)
-				*frame_info = info.
-					vf_output_info[ATOMISP_CSS_OUTPUT_SECOND_INDEX];
-			else
-				*frame_info = info.
-					vf_output_info[ATOMISP_CSS_OUTPUT_DEFAULT_INDEX];
-		else if (ATOMISP_USE_YUVPP(asd) && asd->continuous_mode->val)
-			*frame_info =
-				info.output_info[ATOMISP_CSS_OUTPUT_SECOND_INDEX];
-		else
-			*frame_info =
-				info.output_info[ATOMISP_CSS_OUTPUT_DEFAULT_INDEX];
-
-		break;
-	default:
-		frame_info = NULL;
-		break;
-	}
-	return frame_info ? 0 : -EINVAL;
-}
-
-int atomisp_css_copy_configure_output(struct atomisp_sub_device *asd,
-				unsigned int stream_index,
-				unsigned int width, unsigned int height,
-				unsigned int padded_width,
-				enum atomisp_css_frame_format format)
-{
-	asd->stream_env[stream_index].pipe_configs[IA_CSS_PIPE_ID_COPY].
-					default_capture_config.mode =
-					CSS_CAPTURE_MODE_RAW;
-
-	__configure_output(asd, stream_index, width, height, padded_width,
-			   format, IA_CSS_PIPE_ID_COPY);
-	return 0;
-}
-
-int atomisp_css_yuvpp_configure_output(struct atomisp_sub_device *asd,
-				unsigned int stream_index,
-				unsigned int width, unsigned int height,
-				unsigned int padded_width,
-				enum atomisp_css_frame_format format)
-{
-	asd->stream_env[stream_index].pipe_configs[IA_CSS_PIPE_ID_YUVPP].
-					default_capture_config.mode =
-					CSS_CAPTURE_MODE_RAW;
-
-	__configure_output(asd, stream_index, width, height, padded_width,
-			   format, IA_CSS_PIPE_ID_YUVPP);
-	return 0;
-}
-
-int atomisp_css_yuvpp_configure_viewfinder(
-				struct atomisp_sub_device *asd,
-				unsigned int stream_index,
-				unsigned int width, unsigned int height,
-				unsigned int min_width,
-				enum atomisp_css_frame_format format)
-{
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[stream_index];
-	enum ia_css_pipe_id pipe_id = IA_CSS_PIPE_ID_YUVPP;
-
-	stream_env->pipe_configs[pipe_id].mode =
-		__pipe_id_to_pipe_mode(asd, pipe_id);
-	stream_env->update_pipe[pipe_id] = true;
-
-	stream_env->pipe_configs[pipe_id].vf_output_info[0].res.width = width;
-	stream_env->pipe_configs[pipe_id].vf_output_info[0].res.height = height;
-	stream_env->pipe_configs[pipe_id].vf_output_info[0].format = format;
-	stream_env->pipe_configs[pipe_id].vf_output_info[0].padded_width =
-		min_width;
-	return 0;
-}
-
-int atomisp_css_yuvpp_get_output_frame_info(
-					struct atomisp_sub_device *asd,
-					unsigned int stream_index,
-					struct atomisp_css_frame_info *info)
-{
-	return __get_frame_info(asd, stream_index, info,
-			ATOMISP_CSS_OUTPUT_FRAME, IA_CSS_PIPE_ID_YUVPP);
-}
-
-int atomisp_css_yuvpp_get_viewfinder_frame_info(
-					struct atomisp_sub_device *asd,
-					unsigned int stream_index,
-					struct atomisp_css_frame_info *info)
-{
-	return __get_frame_info(asd, stream_index, info,
-			ATOMISP_CSS_VF_FRAME, IA_CSS_PIPE_ID_YUVPP);
-}
-
-int atomisp_css_preview_configure_output(struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height,
-				unsigned int min_width,
-				enum atomisp_css_frame_format format)
-{
-	/*
-	 * to SOC camera, use yuvpp pipe.
-	 */
-	if (ATOMISP_USE_YUVPP(asd))
-		__configure_video_preview_output(asd, ATOMISP_INPUT_STREAM_GENERAL, width, height,
-						min_width, format, IA_CSS_PIPE_ID_YUVPP);
-	else
-		__configure_output(asd, ATOMISP_INPUT_STREAM_GENERAL, width, height,
-					min_width, format, IA_CSS_PIPE_ID_PREVIEW);
-	return 0;
-}
-
-int atomisp_css_capture_configure_output(struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height,
-				unsigned int min_width,
-				enum atomisp_css_frame_format format)
-{
-	enum ia_css_pipe_id pipe_id;
-
-	/*
-	 * to SOC camera, use yuvpp pipe.
-	 */
-	if (ATOMISP_USE_YUVPP(asd))
-		pipe_id = IA_CSS_PIPE_ID_YUVPP;
-	else
-		pipe_id = IA_CSS_PIPE_ID_CAPTURE;
-
-	__configure_output(asd, ATOMISP_INPUT_STREAM_GENERAL, width, height,
-						min_width, format, pipe_id);
-	return 0;
-}
-
-int atomisp_css_video_configure_output(struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height,
-				unsigned int min_width,
-				enum atomisp_css_frame_format format)
-{
-	/*
-	 * to SOC camera, use yuvpp pipe.
-	 */
-	if (ATOMISP_USE_YUVPP(asd))
-		__configure_video_preview_output(asd, ATOMISP_INPUT_STREAM_GENERAL, width, height,
-					min_width, format, IA_CSS_PIPE_ID_YUVPP);
-	else
-		__configure_output(asd, ATOMISP_INPUT_STREAM_GENERAL, width, height,
-					min_width, format, IA_CSS_PIPE_ID_VIDEO);
-	return 0;
-}
-
-int atomisp_css_video_configure_viewfinder(
-				struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height,
-				unsigned int min_width,
-				enum atomisp_css_frame_format format)
-{
-	/*
-	 * to SOC camera, video will use yuvpp pipe.
-	 */
-	if (ATOMISP_USE_YUVPP(asd))
-		__configure_video_vf_output(asd, width, height, min_width, format,
-							IA_CSS_PIPE_ID_YUVPP);
-	else
-		__configure_vf_output(asd, width, height, min_width, format,
-							IA_CSS_PIPE_ID_VIDEO);
-	return 0;
-}
-
-int atomisp_css_capture_configure_viewfinder(
-				struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height,
-				unsigned int min_width,
-				enum atomisp_css_frame_format format)
-{
-	enum ia_css_pipe_id pipe_id;
-
-	/*
-	 * to SOC camera, video will use yuvpp pipe.
-	 */
-	if (ATOMISP_USE_YUVPP(asd))
-		pipe_id = IA_CSS_PIPE_ID_YUVPP;
-	else
-		pipe_id = IA_CSS_PIPE_ID_CAPTURE;
-
-	__configure_vf_output(asd, width, height, min_width, format,
-							pipe_id);
-	return 0;
-}
-
-int atomisp_css_video_get_viewfinder_frame_info(
-					struct atomisp_sub_device *asd,
-					struct atomisp_css_frame_info *info)
-{
-	enum ia_css_pipe_id pipe_id;
-	enum frame_info_type frame_type = ATOMISP_CSS_VF_FRAME;
-
-	if (ATOMISP_USE_YUVPP(asd)) {
-		pipe_id = IA_CSS_PIPE_ID_YUVPP;
-		if (asd->continuous_mode->val)
-			frame_type = ATOMISP_CSS_SECOND_VF_FRAME;
-	} else {
-		pipe_id = IA_CSS_PIPE_ID_VIDEO;
-	}
-
-	return __get_frame_info(asd, ATOMISP_INPUT_STREAM_GENERAL, info,
-						frame_type, pipe_id);
-}
-
-int atomisp_css_capture_get_viewfinder_frame_info(
-					struct atomisp_sub_device *asd,
-					struct atomisp_css_frame_info *info)
-{
-	enum ia_css_pipe_id pipe_id;
-
-	if (ATOMISP_USE_YUVPP(asd))
-		pipe_id = IA_CSS_PIPE_ID_YUVPP;
-	else
-		pipe_id = IA_CSS_PIPE_ID_CAPTURE;
-
-	return __get_frame_info(asd, ATOMISP_INPUT_STREAM_GENERAL, info,
-						ATOMISP_CSS_VF_FRAME, pipe_id);
-}
-
-int atomisp_css_capture_get_output_raw_frame_info(
-					struct atomisp_sub_device *asd,
-					struct atomisp_css_frame_info *info)
-{
-	if (ATOMISP_USE_YUVPP(asd))
-		return 0;
-
-	return __get_frame_info(asd, ATOMISP_INPUT_STREAM_GENERAL, info,
-			ATOMISP_CSS_RAW_FRAME, IA_CSS_PIPE_ID_CAPTURE);
-}
-
-int atomisp_css_copy_get_output_frame_info(
-					struct atomisp_sub_device *asd,
-					unsigned int stream_index,
-					struct atomisp_css_frame_info *info)
-{
-	return __get_frame_info(asd, stream_index, info,
-			ATOMISP_CSS_OUTPUT_FRAME, IA_CSS_PIPE_ID_COPY);
-}
-
-int atomisp_css_preview_get_output_frame_info(
-					struct atomisp_sub_device *asd,
-					struct atomisp_css_frame_info *info)
-{
-	enum ia_css_pipe_id pipe_id;
-	enum frame_info_type frame_type = ATOMISP_CSS_OUTPUT_FRAME;
-
-	if (ATOMISP_USE_YUVPP(asd)) {
-		pipe_id = IA_CSS_PIPE_ID_YUVPP;
-		if (asd->continuous_mode->val)
-			frame_type = ATOMISP_CSS_SECOND_OUTPUT_FRAME;
-	} else {
-		pipe_id = IA_CSS_PIPE_ID_PREVIEW;
-	}
-
-	return __get_frame_info(asd, ATOMISP_INPUT_STREAM_GENERAL, info,
-					frame_type, pipe_id);
-}
-
-int atomisp_css_capture_get_output_frame_info(
-					struct atomisp_sub_device *asd,
-					struct atomisp_css_frame_info *info)
-{
-	enum ia_css_pipe_id pipe_id;
-
-	if (ATOMISP_USE_YUVPP(asd))
-		pipe_id = IA_CSS_PIPE_ID_YUVPP;
-	else
-		pipe_id = IA_CSS_PIPE_ID_CAPTURE;
-
-	return __get_frame_info(asd, ATOMISP_INPUT_STREAM_GENERAL, info,
-					ATOMISP_CSS_OUTPUT_FRAME, pipe_id);
-}
-
-int atomisp_css_video_get_output_frame_info(
-					struct atomisp_sub_device *asd,
-					struct atomisp_css_frame_info *info)
-{
-	enum ia_css_pipe_id pipe_id;
-	enum frame_info_type frame_type = ATOMISP_CSS_OUTPUT_FRAME;
-
-	if (ATOMISP_USE_YUVPP(asd)) {
-		pipe_id = IA_CSS_PIPE_ID_YUVPP;
-		if (asd->continuous_mode->val)
-			frame_type = ATOMISP_CSS_SECOND_OUTPUT_FRAME;
-	} else {
-		pipe_id = IA_CSS_PIPE_ID_VIDEO;
-	}
-
-	return __get_frame_info(asd, ATOMISP_INPUT_STREAM_GENERAL, info,
-					frame_type, pipe_id);
-}
-
-int atomisp_css_preview_configure_pp_input(
-				struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height)
-{
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-	__configure_preview_pp_input(asd, width, height,
-		ATOMISP_USE_YUVPP(asd) ?
-		IA_CSS_PIPE_ID_YUVPP : IA_CSS_PIPE_ID_PREVIEW);
-
-	if (width > stream_env->pipe_configs[IA_CSS_PIPE_ID_CAPTURE].
-					capt_pp_in_res.width)
-		__configure_capture_pp_input(asd, width, height,
-			ATOMISP_USE_YUVPP(asd) ?
-		IA_CSS_PIPE_ID_YUVPP : IA_CSS_PIPE_ID_CAPTURE);
-	return 0;
-}
-
-int atomisp_css_capture_configure_pp_input(
-				struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height)
-{
-	__configure_capture_pp_input(asd, width, height,
-		ATOMISP_USE_YUVPP(asd) ?
-		IA_CSS_PIPE_ID_YUVPP : IA_CSS_PIPE_ID_CAPTURE);
-	return 0;
-}
-
-int atomisp_css_video_configure_pp_input(
-				struct atomisp_sub_device *asd,
-				unsigned int width, unsigned int height)
-{
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-
-	__configure_video_pp_input(asd, width, height,
-		ATOMISP_USE_YUVPP(asd) ?
-		IA_CSS_PIPE_ID_YUVPP : IA_CSS_PIPE_ID_VIDEO);
-
-	if (width > stream_env->pipe_configs[IA_CSS_PIPE_ID_CAPTURE].
-					capt_pp_in_res.width)
-		__configure_capture_pp_input(asd, width, height,
-			ATOMISP_USE_YUVPP(asd) ?
-			IA_CSS_PIPE_ID_YUVPP : IA_CSS_PIPE_ID_CAPTURE);
-	return 0;
-}
-
-int atomisp_css_offline_capture_configure(struct atomisp_sub_device *asd,
-			int num_captures, unsigned int skip, int offset)
-{
-	enum ia_css_err ret;
-
-#ifdef ISP2401
-	dev_dbg(asd->isp->dev, "%s num_capture:%d skip:%d offset:%d\n",
-			__func__, num_captures, skip, offset);
-#endif
-	ret = ia_css_stream_capture(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		num_captures, skip, offset);
-	if (ret != IA_CSS_SUCCESS)
-		return -EINVAL;
-
-	return 0;
-}
-
-int atomisp_css_exp_id_capture(struct atomisp_sub_device *asd, int exp_id)
-{
-	enum ia_css_err ret;
-
-	ret = ia_css_stream_capture_frame(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		exp_id);
-	if (ret == IA_CSS_ERR_QUEUE_IS_FULL) {
-		/* capture cmd queue is full */
-		return -EBUSY;
-	} else if (ret != IA_CSS_SUCCESS) {
-		return -EIO;
-	}
-
-	return 0;
-}
-
-int atomisp_css_exp_id_unlock(struct atomisp_sub_device *asd, int exp_id)
-{
-	enum ia_css_err ret;
-
-	ret = ia_css_unlock_raw_frame(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		exp_id);
-	if (ret == IA_CSS_ERR_QUEUE_IS_FULL)
-		return -EAGAIN;
-	else if (ret != IA_CSS_SUCCESS)
-		return -EIO;
-
-	return 0;
-}
-
-int atomisp_css_capture_enable_xnr(struct atomisp_sub_device *asd,
-				   bool enable)
-{
-	asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.pipe_configs[IA_CSS_PIPE_ID_CAPTURE]
-		.default_capture_config.enable_xnr = enable;
-	asd->params.capture_config.enable_xnr = enable;
-	asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.update_pipe[IA_CSS_PIPE_ID_CAPTURE] = true;
-
-	return 0;
-}
-
-void atomisp_css_send_input_frame(struct atomisp_sub_device *asd,
-				  unsigned short *data, unsigned int width,
-				  unsigned int height)
-{
-	ia_css_stream_send_input_frame(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		data, width, height);
-}
-
-bool atomisp_css_isp_has_started(void)
-{
-	return ia_css_isp_has_started();
-}
-
-void atomisp_css_request_flash(struct atomisp_sub_device *asd)
-{
-	ia_css_stream_request_flash(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream);
-}
-
-void atomisp_css_set_wb_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_wb_config *wb_config)
-{
-	asd->params.config.wb_config = wb_config;
-}
-
-void atomisp_css_set_ob_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_ob_config *ob_config)
-{
-	asd->params.config.ob_config = ob_config;
-}
-
-void atomisp_css_set_dp_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_dp_config *dp_config)
-{
-	asd->params.config.dp_config = dp_config;
-}
-
-void atomisp_css_set_de_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_de_config *de_config)
-{
-	asd->params.config.de_config = de_config;
-}
-
-void atomisp_css_set_dz_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_dz_config *dz_config)
-{
-	asd->params.config.dz_config = dz_config;
-}
-
-void atomisp_css_set_default_de_config(struct atomisp_sub_device *asd)
-{
-	asd->params.config.de_config = NULL;
-}
-
-void atomisp_css_set_ce_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_ce_config *ce_config)
-{
-	asd->params.config.ce_config = ce_config;
-}
-
-void atomisp_css_set_nr_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_nr_config *nr_config)
-{
-	asd->params.config.nr_config = nr_config;
-}
-
-void atomisp_css_set_ee_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_ee_config *ee_config)
-{
-	asd->params.config.ee_config = ee_config;
-}
-
-void atomisp_css_set_tnr_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_tnr_config *tnr_config)
-{
-	asd->params.config.tnr_config = tnr_config;
-}
-
-void atomisp_css_set_cc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_cc_config *cc_config)
-{
-	asd->params.config.cc_config = cc_config;
-}
-
-void atomisp_css_set_macc_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_macc_table *macc_table)
-{
-	asd->params.config.macc_table = macc_table;
-}
-
-void atomisp_css_set_macc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_macc_config *macc_config)
-{
-	asd->params.config.macc_config = macc_config;
-}
-
-void atomisp_css_set_ecd_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_ecd_config *ecd_config)
-{
-	asd->params.config.ecd_config = ecd_config;
-}
-
-void atomisp_css_set_ynr_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_ynr_config *ynr_config)
-{
-	asd->params.config.ynr_config = ynr_config;
-}
-
-void atomisp_css_set_fc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_fc_config *fc_config)
-{
-	asd->params.config.fc_config = fc_config;
-}
-
-void atomisp_css_set_ctc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_ctc_config *ctc_config)
-{
-	asd->params.config.ctc_config = ctc_config;
-}
-
-void atomisp_css_set_cnr_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_cnr_config *cnr_config)
-{
-	asd->params.config.cnr_config = cnr_config;
-}
-
-void atomisp_css_set_aa_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_aa_config *aa_config)
-{
-	asd->params.config.aa_config = aa_config;
-}
-
-void atomisp_css_set_baa_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_baa_config *baa_config)
-{
-	asd->params.config.baa_config = baa_config;
-}
-
-void atomisp_css_set_anr_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_anr_config *anr_config)
-{
-	asd->params.config.anr_config = anr_config;
-}
-
-void atomisp_css_set_xnr_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_xnr_config *xnr_config)
-{
-	asd->params.config.xnr_config = xnr_config;
-}
-
-void atomisp_css_set_yuv2rgb_cc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_cc_config *yuv2rgb_cc_config)
-{
-	asd->params.config.yuv2rgb_cc_config = yuv2rgb_cc_config;
-}
-
-void atomisp_css_set_rgb2yuv_cc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_cc_config *rgb2yuv_cc_config)
-{
-	asd->params.config.rgb2yuv_cc_config = rgb2yuv_cc_config;
-}
-
-void atomisp_css_set_xnr_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_xnr_table *xnr_table)
-{
-	asd->params.config.xnr_table = xnr_table;
-}
-
-void atomisp_css_set_r_gamma_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_rgb_gamma_table *r_gamma_table)
-{
-	asd->params.config.r_gamma_table = r_gamma_table;
-}
-
-void atomisp_css_set_g_gamma_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_rgb_gamma_table *g_gamma_table)
-{
-	asd->params.config.g_gamma_table = g_gamma_table;
-}
-
-void atomisp_css_set_b_gamma_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_rgb_gamma_table *b_gamma_table)
-{
-	asd->params.config.b_gamma_table = b_gamma_table;
-}
-
-void atomisp_css_set_gamma_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_gamma_table *gamma_table)
-{
-	asd->params.config.gamma_table = gamma_table;
-}
-
-void atomisp_css_set_ctc_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_ctc_table *ctc_table)
-{
-	int i;
-	uint16_t *vamem_ptr = ctc_table->data.vamem_1;
-	int data_size = IA_CSS_VAMEM_1_CTC_TABLE_SIZE;
-	bool valid = false;
-
-	/* workaround: if ctc_table is all 0, do not apply it */
-	if (ctc_table->vamem_type == IA_CSS_VAMEM_TYPE_2) {
-		vamem_ptr = ctc_table->data.vamem_2;
-		data_size = IA_CSS_VAMEM_2_CTC_TABLE_SIZE;
-	}
-
-	for (i = 0; i < data_size; i++) {
-		if (*(vamem_ptr + i)) {
-			valid = true;
-			break;
-		}
-	}
-
-	if (valid)
-		asd->params.config.ctc_table = ctc_table;
-	else
-		dev_warn(asd->isp->dev, "Bypass the invalid ctc_table.\n");
-}
-
-void atomisp_css_set_anr_thres(struct atomisp_sub_device *asd,
-			struct atomisp_css_anr_thres *anr_thres)
-{
-	asd->params.config.anr_thres = anr_thres;
-}
-
-void atomisp_css_set_dvs_6axis(struct atomisp_sub_device *asd,
-			struct atomisp_css_dvs_6axis *dvs_6axis)
-{
-	asd->params.config.dvs_6axis_config = dvs_6axis;
-}
-
-void atomisp_css_set_gc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_gc_config *gc_config)
-{
-	asd->params.config.gc_config = gc_config;
-}
-
-void atomisp_css_set_3a_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_3a_config *s3a_config)
-{
-	asd->params.config.s3a_config = s3a_config;
-}
-
-void atomisp_css_video_set_dis_vector(struct atomisp_sub_device *asd,
-				struct atomisp_dis_vector *vector)
-{
-	if (!asd->params.config.motion_vector)
-		asd->params.config.motion_vector = &asd->params.css_param.motion_vector;
-
-	memset(asd->params.config.motion_vector,
-			0, sizeof(struct ia_css_vector));
-	asd->params.css_param.motion_vector.x = vector->x;
-	asd->params.css_param.motion_vector.y = vector->y;
-}
-
-static int atomisp_compare_dvs_grid(struct atomisp_sub_device *asd,
-				struct atomisp_dvs_grid_info *atomgrid)
-{
-	struct atomisp_css_dvs_grid_info *cur =
-		atomisp_css_get_dvs_grid_info(&asd->params.curr_grid_info);
-
-	if (!cur) {
-		dev_err(asd->isp->dev, "dvs grid not available!\n");
-		return -EINVAL;
-	}
-
-	if (sizeof(*cur) != sizeof(*atomgrid)) {
-		dev_err(asd->isp->dev, "dvs grid mis-match!\n");
-		return -EINVAL;
-	}
-
-	if (!cur->enable) {
-		dev_err(asd->isp->dev, "dvs not enabled!\n");
-		return -EINVAL;
-	}
-
-	return memcmp(atomgrid, cur, sizeof(*cur));
-}
-
-void  atomisp_css_set_dvs2_coefs(struct atomisp_sub_device *asd,
-			       struct ia_css_dvs2_coefficients *coefs)
-{
-	asd->params.config.dvs2_coefs = coefs;
-}
-
-int atomisp_css_set_dis_coefs(struct atomisp_sub_device *asd,
-			  struct atomisp_dis_coefficients *coefs)
-{
-	if (atomisp_compare_dvs_grid(asd, &coefs->grid_info) != 0)
-		/* If the grid info in the argument differs from the current
-		   grid info, we tell the caller to reset the grid size and
-		   try again. */
-		return -EAGAIN;
-
-	if (coefs->hor_coefs.odd_real == NULL ||
-	    coefs->hor_coefs.odd_imag == NULL ||
-	    coefs->hor_coefs.even_real == NULL ||
-	    coefs->hor_coefs.even_imag == NULL ||
-	    coefs->ver_coefs.odd_real == NULL ||
-	    coefs->ver_coefs.odd_imag == NULL ||
-	    coefs->ver_coefs.even_real == NULL ||
-	    coefs->ver_coefs.even_imag == NULL ||
-	    asd->params.css_param.dvs2_coeff->hor_coefs.odd_real == NULL ||
-	    asd->params.css_param.dvs2_coeff->hor_coefs.odd_imag == NULL ||
-	    asd->params.css_param.dvs2_coeff->hor_coefs.even_real == NULL ||
-	    asd->params.css_param.dvs2_coeff->hor_coefs.even_imag == NULL ||
-	    asd->params.css_param.dvs2_coeff->ver_coefs.odd_real == NULL ||
-	    asd->params.css_param.dvs2_coeff->ver_coefs.odd_imag == NULL ||
-	    asd->params.css_param.dvs2_coeff->ver_coefs.even_real == NULL ||
-	    asd->params.css_param.dvs2_coeff->ver_coefs.even_imag == NULL)
-		return -EINVAL;
-
-	if (copy_from_user(asd->params.css_param.dvs2_coeff->hor_coefs.odd_real,
-	    coefs->hor_coefs.odd_real, asd->params.dvs_hor_coef_bytes))
-		return -EFAULT;
-	if (copy_from_user(asd->params.css_param.dvs2_coeff->hor_coefs.odd_imag,
-	    coefs->hor_coefs.odd_imag, asd->params.dvs_hor_coef_bytes))
-		return -EFAULT;
-	if (copy_from_user(asd->params.css_param.dvs2_coeff->hor_coefs.even_real,
-	    coefs->hor_coefs.even_real, asd->params.dvs_hor_coef_bytes))
-		return -EFAULT;
-	if (copy_from_user(asd->params.css_param.dvs2_coeff->hor_coefs.even_imag,
-	    coefs->hor_coefs.even_imag, asd->params.dvs_hor_coef_bytes))
-		return -EFAULT;
-
-	if (copy_from_user(asd->params.css_param.dvs2_coeff->ver_coefs.odd_real,
-	    coefs->ver_coefs.odd_real, asd->params.dvs_ver_coef_bytes))
-		return -EFAULT;
-	if (copy_from_user(asd->params.css_param.dvs2_coeff->ver_coefs.odd_imag,
-	    coefs->ver_coefs.odd_imag, asd->params.dvs_ver_coef_bytes))
-		return -EFAULT;
-	if (copy_from_user(asd->params.css_param.dvs2_coeff->ver_coefs.even_real,
-	    coefs->ver_coefs.even_real, asd->params.dvs_ver_coef_bytes))
-		return -EFAULT;
-	if (copy_from_user(asd->params.css_param.dvs2_coeff->ver_coefs.even_imag,
-	    coefs->ver_coefs.even_imag, asd->params.dvs_ver_coef_bytes))
-		return -EFAULT;
-
-	asd->params.css_param.update_flag.dvs2_coefs =
-		(struct atomisp_dvs2_coefficients *)
-		asd->params.css_param.dvs2_coeff;
-	/* FIXME! */
-/*	asd->params.dis_proj_data_valid = false; */
-	asd->params.css_update_params_needed = true;
-
-	return 0;
-}
-
-void atomisp_css_set_zoom_factor(struct atomisp_sub_device *asd,
-					unsigned int zoom)
-{
-	struct atomisp_device *isp = asd->isp;
-
-	if (zoom == asd->params.css_param.dz_config.dx &&
-		 zoom == asd->params.css_param.dz_config.dy) {
-		dev_dbg(isp->dev, "same zoom scale. skipped.\n");
-		return;
-	}
-
-	memset(&asd->params.css_param.dz_config, 0,
-		sizeof(struct ia_css_dz_config));
-	asd->params.css_param.dz_config.dx = zoom;
-	asd->params.css_param.dz_config.dy = zoom;
-
-	asd->params.css_param.update_flag.dz_config =
-		(struct atomisp_dz_config *) &asd->params.css_param.dz_config;
-	asd->params.css_update_params_needed = true;
-}
-
-void atomisp_css_set_formats_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_formats_config *formats_config)
-{
-	asd->params.config.formats_config = formats_config;
-}
-
-int atomisp_css_get_wb_config(struct atomisp_sub_device *asd,
-			struct atomisp_wb_config *config)
-{
-	struct atomisp_css_wb_config wb_config;
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev, "%s called after streamoff, skipping.\n",
-			__func__);
-		return -EINVAL;
-	}
-	memset(&wb_config, 0, sizeof(struct atomisp_css_wb_config));
-	memset(&isp_config, 0, sizeof(struct ia_css_isp_config));
-	isp_config.wb_config = &wb_config;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-	memcpy(config, &wb_config, sizeof(*config));
-
-	return 0;
-}
-
-int atomisp_css_get_ob_config(struct atomisp_sub_device *asd,
-			struct atomisp_ob_config *config)
-{
-	struct atomisp_css_ob_config ob_config;
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev, "%s called after streamoff, skipping.\n",
-			__func__);
-		return -EINVAL;
-	}
-	memset(&ob_config, 0, sizeof(struct atomisp_css_ob_config));
-	memset(&isp_config, 0, sizeof(struct ia_css_isp_config));
-	isp_config.ob_config = &ob_config;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-	memcpy(config, &ob_config, sizeof(*config));
-
-	return 0;
-}
-
-int atomisp_css_get_dp_config(struct atomisp_sub_device *asd,
-			struct atomisp_dp_config *config)
-{
-	struct atomisp_css_dp_config dp_config;
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev, "%s called after streamoff, skipping.\n",
-			__func__);
-		return -EINVAL;
-	}
-	memset(&dp_config, 0, sizeof(struct atomisp_css_dp_config));
-	memset(&isp_config, 0, sizeof(struct ia_css_isp_config));
-	isp_config.dp_config = &dp_config;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-	memcpy(config, &dp_config, sizeof(*config));
-
-	return 0;
-}
-
-int atomisp_css_get_de_config(struct atomisp_sub_device *asd,
-			struct atomisp_de_config *config)
-{
-	struct atomisp_css_de_config de_config;
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev, "%s called after streamoff, skipping.\n",
-			__func__);
-		return -EINVAL;
-	}
-	memset(&de_config, 0, sizeof(struct atomisp_css_de_config));
-	memset(&isp_config, 0, sizeof(struct ia_css_isp_config));
-	isp_config.de_config = &de_config;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-	memcpy(config, &de_config, sizeof(*config));
-
-	return 0;
-}
-
-int atomisp_css_get_nr_config(struct atomisp_sub_device *asd,
-			struct atomisp_nr_config *config)
-{
-	struct atomisp_css_nr_config nr_config;
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev, "%s called after streamoff, skipping.\n",
-			__func__);
-		return -EINVAL;
-	}
-	memset(&nr_config, 0, sizeof(struct atomisp_css_nr_config));
-	memset(&isp_config, 0, sizeof(struct ia_css_isp_config));
-
-	isp_config.nr_config = &nr_config;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-	memcpy(config, &nr_config, sizeof(*config));
-
-	return 0;
-}
-
-int atomisp_css_get_ee_config(struct atomisp_sub_device *asd,
-			struct atomisp_ee_config *config)
-{
-	struct atomisp_css_ee_config ee_config;
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev, "%s called after streamoff, skipping.\n",
-			 __func__);
-		return -EINVAL;
-	}
-	memset(&ee_config, 0, sizeof(struct atomisp_css_ee_config));
-	memset(&isp_config, 0, sizeof(struct ia_css_isp_config));
-	isp_config.ee_config = &ee_config;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-	memcpy(config, &ee_config, sizeof(*config));
-
-	return 0;
-}
-
-int atomisp_css_get_tnr_config(struct atomisp_sub_device *asd,
-			struct atomisp_tnr_config *config)
-{
-	struct atomisp_css_tnr_config tnr_config;
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev, "%s called after streamoff, skipping.\n",
-			__func__);
-		return -EINVAL;
-	}
-	memset(&tnr_config, 0, sizeof(struct atomisp_css_tnr_config));
-	memset(&isp_config, 0, sizeof(struct ia_css_isp_config));
-	isp_config.tnr_config = &tnr_config;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-	memcpy(config, &tnr_config, sizeof(*config));
-
-	return 0;
-}
-
-int atomisp_css_get_ctc_table(struct atomisp_sub_device *asd,
-			struct atomisp_ctc_table *config)
-{
-	struct atomisp_css_ctc_table *tab;
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev, "%s called after streamoff, skipping.\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	tab = vzalloc(sizeof(struct atomisp_css_ctc_table));
-	if (!tab)
-		return -ENOMEM;
-
-	memset(&isp_config, 0, sizeof(struct ia_css_isp_config));
-	isp_config.ctc_table = tab;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-	memcpy(config, tab, sizeof(*tab));
-	vfree(tab);
-
-	return 0;
-}
-
-int atomisp_css_get_gamma_table(struct atomisp_sub_device *asd,
-			struct atomisp_gamma_table *config)
-{
-	struct atomisp_css_gamma_table *tab;
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev, "%s called after streamoff, skipping.\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	tab = vzalloc(sizeof(struct atomisp_css_gamma_table));
-	if (!tab)
-		return -ENOMEM;
-
-	memset(&isp_config, 0, sizeof(struct ia_css_isp_config));
-	isp_config.gamma_table = tab;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-	memcpy(config, tab, sizeof(*tab));
-	vfree(tab);
-
-	return 0;
-}
-
-int atomisp_css_get_gc_config(struct atomisp_sub_device *asd,
-			struct atomisp_gc_config *config)
-{
-	struct atomisp_css_gc_config gc_config;
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev, "%s called after streamoff, skipping.\n",
-			__func__);
-		return -EINVAL;
-	}
-	memset(&gc_config, 0, sizeof(struct atomisp_css_gc_config));
-	memset(&isp_config, 0, sizeof(struct ia_css_isp_config));
-	isp_config.gc_config = &gc_config;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-	/* Get gamma correction params from current setup */
-	memcpy(config, &gc_config, sizeof(*config));
-
-	return 0;
-}
-
-int atomisp_css_get_3a_config(struct atomisp_sub_device *asd,
-			struct atomisp_3a_config *config)
-{
-	struct atomisp_css_3a_config s3a_config;
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev, "%s called after streamoff, skipping.\n",
-			__func__);
-		return -EINVAL;
-	}
-	memset(&s3a_config, 0, sizeof(struct atomisp_css_3a_config));
-	memset(&isp_config, 0, sizeof(struct ia_css_isp_config));
-	isp_config.s3a_config = &s3a_config;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-	/* Get white balance from current setup */
-	memcpy(config, &s3a_config, sizeof(*config));
-
-	return 0;
-}
-
-int atomisp_css_get_formats_config(struct atomisp_sub_device *asd,
-			struct atomisp_formats_config *config)
-{
-	struct atomisp_css_formats_config formats_config;
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev, "%s called after streamoff, skipping.\n",
-			__func__);
-		return -EINVAL;
-	}
-	memset(&formats_config, 0, sizeof(formats_config));
-	memset(&isp_config, 0, sizeof(isp_config));
-	isp_config.formats_config = &formats_config;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-	/* Get narrow gamma from current setup */
-	memcpy(config, &formats_config, sizeof(*config));
-
-	return 0;
-}
-
-int atomisp_css_get_zoom_factor(struct atomisp_sub_device *asd,
-					unsigned int *zoom)
-{
-	struct ia_css_dz_config dz_config;  /** Digital Zoom */
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev, "%s called after streamoff, skipping.\n",
-			__func__);
-		return -EINVAL;
-	}
-	memset(&dz_config, 0, sizeof(struct ia_css_dz_config));
-	memset(&isp_config, 0, sizeof(struct ia_css_isp_config));
-	isp_config.dz_config = &dz_config;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-	*zoom = dz_config.dx;
-
-	return 0;
-}
-
-
-/*
- * Function to set/get image stablization statistics
- */
-int atomisp_css_get_dis_stat(struct atomisp_sub_device *asd,
-			 struct atomisp_dis_statistics *stats)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct atomisp_dis_buf *dis_buf;
-	unsigned long flags;
-
-	if (asd->params.dvs_stat->hor_prod.odd_real == NULL ||
-	    asd->params.dvs_stat->hor_prod.odd_imag == NULL ||
-	    asd->params.dvs_stat->hor_prod.even_real == NULL ||
-	    asd->params.dvs_stat->hor_prod.even_imag == NULL ||
-	    asd->params.dvs_stat->ver_prod.odd_real == NULL ||
-	    asd->params.dvs_stat->ver_prod.odd_imag == NULL ||
-	    asd->params.dvs_stat->ver_prod.even_real == NULL ||
-	    asd->params.dvs_stat->ver_prod.even_imag == NULL)
-		return -EINVAL;
-
-	/* isp needs to be streaming to get DIS statistics */
-	spin_lock_irqsave(&isp->lock, flags);
-	if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED) {
-		spin_unlock_irqrestore(&isp->lock, flags);
-		return -EINVAL;
-	}
-	spin_unlock_irqrestore(&isp->lock, flags);
-
-	if (atomisp_compare_dvs_grid(asd, &stats->dvs2_stat.grid_info) != 0)
-		/* If the grid info in the argument differs from the current
-		   grid info, we tell the caller to reset the grid size and
-		   try again. */
-		return -EAGAIN;
-
-	spin_lock_irqsave(&asd->dis_stats_lock, flags);
-	if (!asd->params.dis_proj_data_valid || list_empty(&asd->dis_stats)) {
-		spin_unlock_irqrestore(&asd->dis_stats_lock, flags);
-		dev_err(isp->dev, "dis statistics is not valid.\n");
-		return -EAGAIN;
-	}
-
-	dis_buf = list_entry(asd->dis_stats.next,
-			struct atomisp_dis_buf, list);
-	list_del_init(&dis_buf->list);
-	spin_unlock_irqrestore(&asd->dis_stats_lock, flags);
-
-	if (dis_buf->dvs_map)
-		ia_css_translate_dvs2_statistics(
-			asd->params.dvs_stat, dis_buf->dvs_map);
-	else
-		ia_css_get_dvs2_statistics(asd->params.dvs_stat,
-			dis_buf->dis_data);
-	stats->exp_id = dis_buf->dis_data->exp_id;
-
-	spin_lock_irqsave(&asd->dis_stats_lock, flags);
-	list_add_tail(&dis_buf->list, &asd->dis_stats);
-	spin_unlock_irqrestore(&asd->dis_stats_lock, flags);
-
-	if (copy_to_user(stats->dvs2_stat.ver_prod.odd_real,
-			 asd->params.dvs_stat->ver_prod.odd_real,
-			 asd->params.dvs_ver_proj_bytes))
-		return -EFAULT;
-	if (copy_to_user(stats->dvs2_stat.ver_prod.odd_imag,
-			 asd->params.dvs_stat->ver_prod.odd_imag,
-			 asd->params.dvs_ver_proj_bytes))
-		return -EFAULT;
-	if (copy_to_user(stats->dvs2_stat.ver_prod.even_real,
-			 asd->params.dvs_stat->ver_prod.even_real,
-			 asd->params.dvs_ver_proj_bytes))
-		return -EFAULT;
-	if (copy_to_user(stats->dvs2_stat.ver_prod.even_imag,
-			 asd->params.dvs_stat->ver_prod.even_imag,
-			 asd->params.dvs_ver_proj_bytes))
-		return -EFAULT;
-	if (copy_to_user(stats->dvs2_stat.hor_prod.odd_real,
-			 asd->params.dvs_stat->hor_prod.odd_real,
-			 asd->params.dvs_hor_proj_bytes))
-		return -EFAULT;
-	if (copy_to_user(stats->dvs2_stat.hor_prod.odd_imag,
-			 asd->params.dvs_stat->hor_prod.odd_imag,
-			 asd->params.dvs_hor_proj_bytes))
-		return -EFAULT;
-	if (copy_to_user(stats->dvs2_stat.hor_prod.even_real,
-			 asd->params.dvs_stat->hor_prod.even_real,
-			 asd->params.dvs_hor_proj_bytes))
-		return -EFAULT;
-	if (copy_to_user(stats->dvs2_stat.hor_prod.even_imag,
-			 asd->params.dvs_stat->hor_prod.even_imag,
-			 asd->params.dvs_hor_proj_bytes))
-		return -EFAULT;
-
-	return 0;
-}
-
-struct atomisp_css_shading_table *atomisp_css_shading_table_alloc(
-				unsigned int width, unsigned int height)
-{
-	return ia_css_shading_table_alloc(width, height);
-}
-
-void atomisp_css_set_shading_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_shading_table *table)
-{
-	asd->params.config.shading_table = table;
-}
-
-void atomisp_css_shading_table_free(struct atomisp_css_shading_table *table)
-{
-	ia_css_shading_table_free(table);
-}
-
-struct atomisp_css_morph_table *atomisp_css_morph_table_allocate(
-				unsigned int width, unsigned int height)
-{
-	return ia_css_morph_table_allocate(width, height);
-}
-
-void atomisp_css_set_morph_table(struct atomisp_sub_device *asd,
-					struct atomisp_css_morph_table *table)
-{
-	asd->params.config.morph_table = table;
-}
-
-void atomisp_css_get_morph_table(struct atomisp_sub_device *asd,
-				struct atomisp_css_morph_table *table)
-{
-	struct ia_css_isp_config isp_config;
-	struct atomisp_device *isp = asd->isp;
-
-	if (!asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream) {
-		dev_err(isp->dev,
-			"%s called after streamoff, skipping.\n", __func__);
-		return;
-	}
-	memset(table, 0, sizeof(struct atomisp_css_morph_table));
-	memset(&isp_config, 0, sizeof(struct ia_css_isp_config));
-	isp_config.morph_table = table;
-	ia_css_stream_get_isp_config(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		&isp_config);
-}
-
-void atomisp_css_morph_table_free(struct atomisp_css_morph_table *table)
-{
-	ia_css_morph_table_free(table);
-}
-
-void atomisp_css_set_cont_prev_start_time(struct atomisp_device *isp,
-					unsigned int overlap)
-{
-	/* CSS 2.0 doesn't support this API. */
-	dev_dbg(isp->dev, "set cont prev start time is not supported.\n");
-	return;
-}
-
-void atomisp_css_acc_done(struct atomisp_sub_device *asd)
-{
-	complete(&asd->acc.acc_done);
-}
-
-int atomisp_css_wait_acc_finish(struct atomisp_sub_device *asd)
-{
-	int ret = 0;
-	struct atomisp_device *isp = asd->isp;
-
-	/* Unlock the isp mutex taken in IOCTL handler before sleeping! */
-	rt_mutex_unlock(&isp->mutex);
-	if (wait_for_completion_interruptible_timeout(&asd->acc.acc_done,
-					ATOMISP_ISP_TIMEOUT_DURATION) == 0) {
-		dev_err(isp->dev, "<%s: completion timeout\n", __func__);
-		atomisp_css_debug_dump_sp_sw_debug_info();
-		atomisp_css_debug_dump_debug_info(__func__);
-		ret = -EIO;
-	}
-	rt_mutex_lock(&isp->mutex);
-
-	return ret;
-}
-
-/* Set the ACC binary arguments */
-int atomisp_css_set_acc_parameters(struct atomisp_acc_fw *acc_fw)
-{
-	unsigned int mem;
-
-	for (mem = 0; mem < ATOMISP_ACC_NR_MEMORY; mem++) {
-		if (acc_fw->args[mem].length == 0)
-			continue;
-
-		ia_css_isp_param_set_css_mem_init(&acc_fw->fw->mem_initializers,
-						IA_CSS_PARAM_CLASS_PARAM, mem,
-						acc_fw->args[mem].css_ptr,
-						acc_fw->args[mem].length);
-	}
-
-	return 0;
-}
-
-/* Load acc binary extension */
-int atomisp_css_load_acc_extension(struct atomisp_sub_device *asd,
-				   struct atomisp_css_fw_info *fw,
-				   enum atomisp_css_pipe_id pipe_id,
-				   unsigned int type)
-{
-	struct atomisp_css_fw_info **hd;
-
-	fw->next = NULL;
-	hd = &(asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-			.pipe_configs[pipe_id].acc_extension);
-	while (*hd)
-		hd = &(*hd)->next;
-	*hd = fw;
-
-	asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.update_pipe[pipe_id] = true;
-	return 0;
-}
-
-/* Unload acc binary extension */
-void atomisp_css_unload_acc_extension(struct atomisp_sub_device *asd,
-					struct atomisp_css_fw_info *fw,
-					enum atomisp_css_pipe_id pipe_id)
-{
-	struct atomisp_css_fw_info **hd;
-
-	hd = &(asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-			.pipe_configs[pipe_id].acc_extension);
-	while (*hd && *hd != fw)
-		hd = &(*hd)->next;
-	if (!*hd) {
-		dev_err(asd->isp->dev, "did not find acc fw for removal\n");
-		return;
-	}
-	*hd = fw->next;
-	fw->next = NULL;
-
-	asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-		.update_pipe[pipe_id] = true;
-}
-
-int atomisp_css_create_acc_pipe(struct atomisp_sub_device *asd)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct ia_css_pipe_config *pipe_config;
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-
-	if (stream_env->acc_stream) {
-		if (stream_env->acc_stream_state == CSS_STREAM_STARTED) {
-			if (ia_css_stream_stop(stream_env->acc_stream)
-				!= IA_CSS_SUCCESS) {
-				dev_err(isp->dev, "stop acc_stream failed.\n");
-				return -EBUSY;
-			}
-		}
-
-		if (ia_css_stream_destroy(stream_env->acc_stream)
-			!= IA_CSS_SUCCESS) {
-			dev_err(isp->dev, "destroy acc_stream failed.\n");
-			return -EBUSY;
-		}
-		stream_env->acc_stream = NULL;
-	}
-
-	pipe_config = &stream_env->pipe_configs[CSS_PIPE_ID_ACC];
-	ia_css_pipe_config_defaults(pipe_config);
-	asd->acc.acc_stages = kzalloc(MAX_ACC_STAGES *
-				sizeof(void *), GFP_KERNEL);
-	if (!asd->acc.acc_stages)
-		return -ENOMEM;
-	pipe_config->acc_stages = asd->acc.acc_stages;
-	pipe_config->mode = IA_CSS_PIPE_MODE_ACC;
-	pipe_config->num_acc_stages = 0;
-
-	/*
-	 * We delay the ACC pipeline creation to atomisp_css_start_acc_pipe,
-	 * because pipe configuration will soon be changed by
-	 * atomisp_css_load_acc_binary()
-	 */
-	return 0;
-}
-
-int atomisp_css_start_acc_pipe(struct atomisp_sub_device *asd)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-	struct ia_css_pipe_config *pipe_config =
-			&stream_env->pipe_configs[IA_CSS_PIPE_ID_ACC];
-
-	if (ia_css_pipe_create(pipe_config,
-		&stream_env->pipes[IA_CSS_PIPE_ID_ACC]) != IA_CSS_SUCCESS) {
-		dev_err(isp->dev, "%s: ia_css_pipe_create failed\n",
-				__func__);
-		return -EBADE;
-	}
-
-	memset(&stream_env->acc_stream_config, 0,
-		sizeof(struct ia_css_stream_config));
-	if (ia_css_stream_create(&stream_env->acc_stream_config, 1,
-				&stream_env->pipes[IA_CSS_PIPE_ID_ACC],
-				&stream_env->acc_stream) != IA_CSS_SUCCESS) {
-		dev_err(isp->dev, "%s: create acc_stream error.\n", __func__);
-		return -EINVAL;
-	}
-	stream_env->acc_stream_state = CSS_STREAM_CREATED;
-
-	init_completion(&asd->acc.acc_done);
-	asd->acc.pipeline = stream_env->pipes[IA_CSS_PIPE_ID_ACC];
-
-	atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_MAX, false);
-
-	if (ia_css_start_sp() != IA_CSS_SUCCESS) {
-		dev_err(isp->dev, "start sp error.\n");
-		return -EIO;
-	}
-
-	if (ia_css_stream_start(stream_env->acc_stream)
-		!= IA_CSS_SUCCESS) {
-		dev_err(isp->dev, "acc_stream start error.\n");
-		return -EIO;
-	}
-
-	stream_env->acc_stream_state = CSS_STREAM_STARTED;
-	return 0;
-}
-
-int atomisp_css_stop_acc_pipe(struct atomisp_sub_device *asd)
-{
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-	if (stream_env->acc_stream_state == CSS_STREAM_STARTED) {
-		ia_css_stream_stop(stream_env->acc_stream);
-		stream_env->acc_stream_state = CSS_STREAM_STOPPED;
-	}
-	return 0;
-}
-
-void atomisp_css_destroy_acc_pipe(struct atomisp_sub_device *asd)
-{
-	struct atomisp_stream_env *stream_env =
-		&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-	if (stream_env->acc_stream) {
-		if (ia_css_stream_destroy(stream_env->acc_stream)
-		    != IA_CSS_SUCCESS)
-			dev_warn(asd->isp->dev,
-				"destroy acc_stream failed.\n");
-		stream_env->acc_stream = NULL;
-	}
-
-	if (stream_env->pipes[IA_CSS_PIPE_ID_ACC]) {
-		if (ia_css_pipe_destroy(stream_env->pipes[IA_CSS_PIPE_ID_ACC])
-			!= IA_CSS_SUCCESS)
-			dev_warn(asd->isp->dev,
-				"destroy ACC pipe failed.\n");
-		stream_env->pipes[IA_CSS_PIPE_ID_ACC] = NULL;
-		stream_env->update_pipe[IA_CSS_PIPE_ID_ACC] = false;
-		ia_css_pipe_config_defaults(
-			&stream_env->pipe_configs[IA_CSS_PIPE_ID_ACC]);
-		ia_css_pipe_extra_config_defaults(
-			&stream_env->pipe_extra_configs[IA_CSS_PIPE_ID_ACC]);
-	}
-	asd->acc.pipeline = NULL;
-
-	/* css 2.0 API limitation: ia_css_stop_sp() could be only called after
-	 * destroy all pipes
-	 */
-	ia_css_stop_sp();
-
-	kfree(asd->acc.acc_stages);
-	asd->acc.acc_stages = NULL;
-
-	atomisp_freq_scaling(asd->isp, ATOMISP_DFS_MODE_LOW, false);
-}
-
-int atomisp_css_load_acc_binary(struct atomisp_sub_device *asd,
-					struct atomisp_css_fw_info *fw,
-					unsigned int index)
-{
-	struct ia_css_pipe_config *pipe_config =
-			&asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]
-			.pipe_configs[IA_CSS_PIPE_ID_ACC];
-
-	if (index >= MAX_ACC_STAGES) {
-		dev_dbg(asd->isp->dev, "%s: index(%d) out of range\n",
-				__func__, index);
-		return -ENOMEM;
-	}
-
-	pipe_config->acc_stages[index] = fw;
-	pipe_config->num_acc_stages = index + 1;
-	pipe_config->acc_num_execs = 1;
-
-	return 0;
-}
-
-static struct atomisp_sub_device *__get_atomisp_subdev(
-					struct ia_css_pipe *css_pipe,
-					struct atomisp_device *isp,
-					enum atomisp_input_stream_id *stream_id)
-{
-	int i, j, k;
-	struct atomisp_sub_device *asd;
-	struct atomisp_stream_env *stream_env;
-
-	for (i = 0; i < isp->num_of_streams; i++) {
-		asd = &isp->asd[i];
-		if (asd->streaming == ATOMISP_DEVICE_STREAMING_DISABLED &&
-		    !asd->acc.pipeline)
-			continue;
-		for (j = 0; j < ATOMISP_INPUT_STREAM_NUM; j++) {
-			stream_env = &asd->stream_env[j];
-			for (k = 0; k < IA_CSS_PIPE_ID_NUM; k++) {
-				if (stream_env->pipes[k] &&
-					stream_env->pipes[k] == css_pipe) {
-						*stream_id = j;
-						return asd;
-					}
-				}
-		}
-	}
-
-	return NULL;
-}
-
-int atomisp_css_isr_thread(struct atomisp_device *isp,
-			   bool *frame_done_found,
-			   bool *css_pipe_done)
-{
-	enum atomisp_input_stream_id stream_id = 0;
-	struct atomisp_css_event current_event;
-	struct atomisp_sub_device *asd;
-#ifndef ISP2401
-	bool reset_wdt_timer[MAX_STREAM_NUM] = {false};
-#endif
-	int i;
-
-	while (!atomisp_css_dequeue_event(&current_event)) {
-		if (current_event.event.type ==
-			IA_CSS_EVENT_TYPE_FW_ASSERT) {
-			/*
-			 * Received FW assertion signal,
-			 * trigger WDT to recover
-			 */
-			dev_err(isp->dev, "%s: ISP reports FW_ASSERT event! fw_assert_module_id %d fw_assert_line_no %d\n",
-				__func__,
-				current_event.event.fw_assert_module_id,
-				current_event.event.fw_assert_line_no);
-			for (i = 0; i < isp->num_of_streams; i++)
-				atomisp_wdt_stop(&isp->asd[i], 0);
-#ifndef ISP2401
-			atomisp_wdt(&isp->asd[0].wdt);
-#else
-			queue_work(isp->wdt_work_queue, &isp->wdt_work);
-#endif
-			return -EINVAL;
-		} else if (current_event.event.type == IA_CSS_EVENT_TYPE_FW_WARNING) {
-			dev_warn(isp->dev, "%s: ISP reports warning, code is %d, exp_id %d\n",
-				__func__, current_event.event.fw_warning,
-				current_event.event.exp_id);
-			continue;
-		}
-
-		asd = __get_atomisp_subdev(current_event.event.pipe,
-					isp, &stream_id);
-		if (!asd) {
-			if (current_event.event.type == CSS_EVENT_TIMER)
-				dev_dbg(isp->dev,
-					"event: Timer event.");
-			else
-				dev_warn(isp->dev, "%s:no subdev.event:%d",
-						__func__,
-						current_event.event.type);
-			continue;
-		}
-
-		atomisp_css_temp_pipe_to_pipe_id(asd, &current_event);
-		switch (current_event.event.type) {
-		case CSS_EVENT_OUTPUT_FRAME_DONE:
-			frame_done_found[asd->index] = true;
-			atomisp_buf_done(asd, 0, CSS_BUFFER_TYPE_OUTPUT_FRAME,
-					 current_event.pipe, true, stream_id);
-#ifndef ISP2401
-			reset_wdt_timer[asd->index] = true; /* ISP running */
-#endif
-			break;
-		case CSS_EVENT_SEC_OUTPUT_FRAME_DONE:
-			frame_done_found[asd->index] = true;
-			atomisp_buf_done(asd, 0, CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME,
-					 current_event.pipe, true, stream_id);
-#ifndef ISP2401
-			reset_wdt_timer[asd->index] = true; /* ISP running */
-#endif
-			break;
-		case CSS_EVENT_3A_STATISTICS_DONE:
-			atomisp_buf_done(asd, 0,
-					 CSS_BUFFER_TYPE_3A_STATISTICS,
-					 current_event.pipe,
-					 false, stream_id);
-			break;
-		case CSS_EVENT_METADATA_DONE:
-			atomisp_buf_done(asd, 0,
-					 CSS_BUFFER_TYPE_METADATA,
-					 current_event.pipe,
-					 false, stream_id);
-			break;
-		case CSS_EVENT_VF_OUTPUT_FRAME_DONE:
-			atomisp_buf_done(asd, 0,
-					 CSS_BUFFER_TYPE_VF_OUTPUT_FRAME,
-					 current_event.pipe, true, stream_id);
-#ifndef ISP2401
-			reset_wdt_timer[asd->index] = true; /* ISP running */
-#endif
-			break;
-		case CSS_EVENT_SEC_VF_OUTPUT_FRAME_DONE:
-			atomisp_buf_done(asd, 0,
-					 CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME,
-					 current_event.pipe, true, stream_id);
-#ifndef ISP2401
-			reset_wdt_timer[asd->index] = true; /* ISP running */
-#endif
-			break;
-		case CSS_EVENT_DIS_STATISTICS_DONE:
-			atomisp_buf_done(asd, 0,
-					 CSS_BUFFER_TYPE_DIS_STATISTICS,
-					 current_event.pipe,
-					 false, stream_id);
-			break;
-		case CSS_EVENT_PIPELINE_DONE:
-			css_pipe_done[asd->index] = true;
-			break;
-		case CSS_EVENT_ACC_STAGE_COMPLETE:
-			atomisp_acc_done(asd, current_event.event.fw_handle);
-			break;
-		default:
-			dev_dbg(isp->dev, "unhandled css stored event: 0x%x\n",
-					current_event.event.type);
-			break;
-		}
-	}
-#ifndef ISP2401
-	/* If there are no buffers queued then
-	 * delete wdt timer. */
-	for (i = 0; i < isp->num_of_streams; i++) {
-		asd = &isp->asd[i];
-		if (!asd)
-			continue;
-		if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
-			continue;
-		if (!atomisp_buffers_queued(asd))
-			atomisp_wdt_stop(asd, false);
-		else if (reset_wdt_timer[i])
-		/* SOF irq should not reset wdt timer. */
-			atomisp_wdt_refresh(asd,
-					ATOMISP_WDT_KEEP_CURRENT_DELAY);
-	}
-#endif
-
-	return 0;
-}
-
-bool atomisp_css_valid_sof(struct atomisp_device *isp)
-{
-	unsigned int i, j;
-
-	/* Loop for each css stream */
-	for (i = 0; i < isp->num_of_streams; i++) {
-		struct atomisp_sub_device *asd = &isp->asd[i];
-		/* Loop for each css vc stream */
-		for (j = 0; j < ATOMISP_INPUT_STREAM_NUM; j++) {
-			if (asd->stream_env[j].stream &&
-				asd->stream_env[j].stream_config.mode ==
-				IA_CSS_INPUT_MODE_BUFFERED_SENSOR)
-				return false;
-		}
-	}
-
-	return true;
-}
-
-int atomisp_css_debug_dump_isp_binary(void)
-{
-	ia_css_debug_dump_isp_binary();
-	return 0;
-}
-
-int atomisp_css_dump_sp_raw_copy_linecount(bool reduced)
-{
-	sh_css_dump_sp_raw_copy_linecount(reduced);
-	return 0;
-}
-
-int atomisp_css_dump_blob_infor(void)
-{
-	struct ia_css_blob_descr *bd = sh_css_blob_info;
-	unsigned int i, nm = sh_css_num_binaries;
-
-	if (nm == 0)
-		return -EPERM;
-	if (bd == NULL)
-		return -EPERM;
-
-	for (i = 1; i < sh_css_num_binaries; i++)
-		dev_dbg(atomisp_dev, "Num%d binary id is %d, name is %s\n", i,
-			bd[i-1].header.info.isp.sp.id, bd[i-1].name);
-
-	return 0;
-}
-
-void atomisp_css_set_isp_config_id(struct atomisp_sub_device *asd,
-			uint32_t isp_config_id)
-{
-	asd->params.config.isp_config_id = isp_config_id;
-}
-
-void atomisp_css_set_isp_config_applied_frame(struct atomisp_sub_device *asd,
-			struct atomisp_css_frame *output_frame)
-{
-	asd->params.config.output_frame = output_frame;
-}
-
-int atomisp_get_css_dbgfunc(void)
-{
-	return dbg_func;
-}
-
-int atomisp_set_css_dbgfunc(struct atomisp_device *isp, int opt)
-{
-	int ret;
-
-	ret = __set_css_print_env(isp, opt);
-	if (ret == 0)
-		dbg_func = opt;
-
-	return ret;
-}
-void atomisp_en_dz_capt_pipe(struct atomisp_sub_device *asd, bool enable)
-{
-	ia_css_en_dz_capt_pipe(
-		asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
-		enable);
-}
-
-struct atomisp_css_dvs_grid_info *atomisp_css_get_dvs_grid_info(
-	struct atomisp_css_grid_info *grid_info)
-{
-	if (!grid_info)
-		return NULL;
-
-#ifdef IA_CSS_DVS_STAT_GRID_INFO_SUPPORTED
-	return &grid_info->dvs_grid.dvs_grid_info;
-#else
-	return &grid_info->dvs_grid;
-#endif
-}

+ 0 - 277
drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.h

@@ -1,277 +0,0 @@
-/*
- * Support for Clovertrail PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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 __ATOMISP_COMPAT_CSS20_H__
-#define __ATOMISP_COMPAT_CSS20_H__
-
-#include <media/v4l2-mediabus.h>
-
-#include "ia_css.h"
-#include "ia_css_types.h"
-#include "ia_css_acc_types.h"
-#include "sh_css_legacy.h"
-
-#define ATOMISP_CSS2_PIPE_MAX	2
-#define ATOMISP_CSS2_NUM_OFFLINE_INIT_CONTINUOUS_FRAMES     3
-#define ATOMISP_CSS2_NUM_OFFLINE_INIT_CONTINUOUS_FRAMES_LOCK_EN     4
-#define ATOMISP_CSS2_NUM_DVS_FRAME_DELAY     2
-
-#define atomisp_css_pipe_id ia_css_pipe_id
-#define atomisp_css_pipeline	ia_css_pipe
-#define atomisp_css_buffer_type ia_css_buffer_type
-#define atomisp_css_dis_data ia_css_isp_dvs_statistics
-#define atomisp_css_irq_info  ia_css_irq_info
-#define atomisp_css_isp_config ia_css_isp_config
-#define atomisp_css_bayer_order ia_css_bayer_order
-#define atomisp_css_capture_mode ia_css_capture_mode
-#define atomisp_css_input_mode ia_css_input_mode
-#define atomisp_css_frame ia_css_frame
-#define atomisp_css_frame_format ia_css_frame_format
-#define atomisp_css_frame_info ia_css_frame_info
-#define atomisp_css_dp_config	ia_css_dp_config
-#define atomisp_css_wb_config	ia_css_wb_config
-#define atomisp_css_cc_config	ia_css_cc_config
-#define atomisp_css_nr_config	ia_css_nr_config
-#define atomisp_css_ee_config	ia_css_ee_config
-#define atomisp_css_ob_config	ia_css_ob_config
-#define atomisp_css_de_config	ia_css_de_config
-#define atomisp_css_dz_config	ia_css_dz_config
-#define atomisp_css_ce_config	ia_css_ce_config
-#define atomisp_css_gc_config	ia_css_gc_config
-#define atomisp_css_tnr_config	ia_css_tnr_config
-#define atomisp_css_cnr_config	ia_css_cnr_config
-#define atomisp_css_ctc_config	ia_css_ctc_config
-#define atomisp_css_3a_config	ia_css_3a_config
-#define atomisp_css_ecd_config	ia_css_ecd_config
-#define atomisp_css_ynr_config	ia_css_ynr_config
-#define atomisp_css_fc_config	ia_css_fc_config
-#define atomisp_css_aa_config	ia_css_aa_config
-#define atomisp_css_baa_config	ia_css_aa_config
-#define atomisp_css_anr_config	ia_css_anr_config
-#define atomisp_css_xnr_config	ia_css_xnr_config
-#define atomisp_css_macc_config	ia_css_macc_config
-#define atomisp_css_gamma_table	ia_css_gamma_table
-#define atomisp_css_ctc_table	ia_css_ctc_table
-#define atomisp_css_macc_table	ia_css_macc_table
-#define atomisp_css_xnr_table	ia_css_xnr_table
-#define atomisp_css_rgb_gamma_table	ia_css_rgb_gamma_table
-#define atomisp_css_anr_thres	ia_css_anr_thres
-#define atomisp_css_dvs_6axis	ia_css_dvs_6axis_config
-#define atomisp_css_grid_info	ia_css_grid_info
-#define atomisp_css_3a_grid_info	ia_css_3a_grid_info
-#define atomisp_css_dvs_grid_info	ia_css_dvs_grid_info
-#define atomisp_css_shading_table	ia_css_shading_table
-#define atomisp_css_morph_table	ia_css_morph_table
-#define atomisp_css_dvs_6axis_config	ia_css_dvs_6axis_config
-#define atomisp_css_fw_info	ia_css_fw_info
-#define atomisp_css_formats_config	ia_css_formats_config
-
-#define CSS_PIPE_ID_PREVIEW	IA_CSS_PIPE_ID_PREVIEW
-#define CSS_PIPE_ID_COPY	IA_CSS_PIPE_ID_COPY
-#define CSS_PIPE_ID_VIDEO	IA_CSS_PIPE_ID_VIDEO
-#define CSS_PIPE_ID_CAPTURE	IA_CSS_PIPE_ID_CAPTURE
-#define CSS_PIPE_ID_ACC		IA_CSS_PIPE_ID_ACC
-#define CSS_PIPE_ID_YUVPP	IA_CSS_PIPE_ID_YUVPP
-#define CSS_PIPE_ID_NUM		IA_CSS_PIPE_ID_NUM
-
-#define CSS_INPUT_MODE_SENSOR	IA_CSS_INPUT_MODE_BUFFERED_SENSOR
-#define CSS_INPUT_MODE_FIFO	IA_CSS_INPUT_MODE_FIFO
-#define CSS_INPUT_MODE_TPG	IA_CSS_INPUT_MODE_TPG
-#define CSS_INPUT_MODE_PRBS	IA_CSS_INPUT_MODE_PRBS
-#define CSS_INPUT_MODE_MEMORY	IA_CSS_INPUT_MODE_MEMORY
-
-#define CSS_IRQ_INFO_CSS_RECEIVER_ERROR	IA_CSS_IRQ_INFO_CSS_RECEIVER_ERROR
-#define CSS_IRQ_INFO_EVENTS_READY	IA_CSS_IRQ_INFO_EVENTS_READY
-#define CSS_IRQ_INFO_INPUT_SYSTEM_ERROR \
-	IA_CSS_IRQ_INFO_INPUT_SYSTEM_ERROR
-#define CSS_IRQ_INFO_IF_ERROR	IA_CSS_IRQ_INFO_IF_ERROR
-
-#define CSS_BUFFER_TYPE_NUM	IA_CSS_BUFFER_TYPE_NUM
-
-#define CSS_FRAME_FLASH_STATE_NONE	IA_CSS_FRAME_FLASH_STATE_NONE
-#define CSS_FRAME_FLASH_STATE_PARTIAL	IA_CSS_FRAME_FLASH_STATE_PARTIAL
-#define CSS_FRAME_FLASH_STATE_FULL	IA_CSS_FRAME_FLASH_STATE_FULL
-
-#define CSS_BAYER_ORDER_GRBG	IA_CSS_BAYER_ORDER_GRBG
-#define CSS_BAYER_ORDER_RGGB	IA_CSS_BAYER_ORDER_RGGB
-#define CSS_BAYER_ORDER_BGGR	IA_CSS_BAYER_ORDER_BGGR
-#define CSS_BAYER_ORDER_GBRG	IA_CSS_BAYER_ORDER_GBRG
-
-/*
- * Hide IA_ naming difference in otherwise common CSS macros.
- */
-#define CSS_ID(val)	(IA_ ## val)
-#define CSS_EVENT(val)	(IA_CSS_EVENT_TYPE_ ## val)
-#define CSS_FORMAT(val)	(ATOMISP_INPUT_FORMAT_ ## val)
-
-#define CSS_EVENT_PORT_EOF	CSS_EVENT(PORT_EOF)
-#define CSS_EVENT_FRAME_TAGGED	CSS_EVENT(FRAME_TAGGED)
-
-#define CSS_MIPI_FRAME_BUFFER_SIZE_1	0x60000
-#define CSS_MIPI_FRAME_BUFFER_SIZE_2	0x80000
-
-struct atomisp_device;
-struct atomisp_sub_device;
-
-#define MAX_STREAMS_PER_CHANNEL	2
-
-/*
- * These are used to indicate the css stream state, corresponding
- * stream handling can be done via judging the different state.
- */
-enum atomisp_css_stream_state {
-	CSS_STREAM_UNINIT,
-	CSS_STREAM_CREATED,
-	CSS_STREAM_STARTED,
-	CSS_STREAM_STOPPED,
-};
-
-/*
- *  Sensor of external ISP can send multiple steams with different mipi data
- * type in the same virtual channel. This information needs to come from the
- * sensor or external ISP
- */
-struct atomisp_css_isys_config_info {
-	unsigned int input_format;
-	unsigned int width;
-	unsigned int height;
-};
-
-struct atomisp_stream_env {
-	struct ia_css_stream *stream;
-	struct ia_css_stream_config stream_config;
-	struct ia_css_stream_info stream_info;
-	struct ia_css_pipe *pipes[IA_CSS_PIPE_ID_NUM];
-	struct ia_css_pipe *multi_pipes[IA_CSS_PIPE_ID_NUM];
-	struct ia_css_pipe_config pipe_configs[IA_CSS_PIPE_ID_NUM];
-	struct ia_css_pipe_extra_config pipe_extra_configs[IA_CSS_PIPE_ID_NUM];
-	bool update_pipe[IA_CSS_PIPE_ID_NUM];
-	enum atomisp_css_stream_state stream_state;
-	struct ia_css_stream *acc_stream;
-	enum atomisp_css_stream_state acc_stream_state;
-	struct ia_css_stream_config acc_stream_config;
-	unsigned int ch_id; /* virtual channel ID */
-	unsigned int isys_configs;
-	struct atomisp_css_isys_config_info isys_info[MAX_STREAMS_PER_CHANNEL];
-};
-
-struct atomisp_css_env {
-	struct ia_css_env isp_css_env;
-	struct ia_css_fw isp_css_fw;
-};
-
-struct atomisp_s3a_buf {
-	struct ia_css_isp_3a_statistics *s3a_data;
-	struct ia_css_isp_3a_statistics_map *s3a_map;
-	struct list_head list;
-};
-
-struct atomisp_dis_buf {
-	struct atomisp_css_dis_data *dis_data;
-	struct ia_css_isp_dvs_statistics_map *dvs_map;
-	struct list_head list;
-};
-
-struct atomisp_css_buffer {
-	struct ia_css_buffer css_buffer;
-};
-
-struct atomisp_css_event {
-	enum atomisp_css_pipe_id pipe;
-	struct ia_css_event event;
-};
-
-void atomisp_css_set_macc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_macc_config *macc_config);
-
-void atomisp_css_set_ecd_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_ecd_config *ecd_config);
-
-void atomisp_css_set_ynr_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_ynr_config *ynr_config);
-
-void atomisp_css_set_fc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_fc_config *fc_config);
-
-void atomisp_css_set_aa_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_aa_config *aa_config);
-
-void atomisp_css_set_baa_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_baa_config *baa_config);
-
-void atomisp_css_set_anr_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_anr_config *anr_config);
-
-void atomisp_css_set_xnr_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_xnr_config *xnr_config);
-
-void atomisp_css_set_cnr_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_cnr_config *cnr_config);
-
-void atomisp_css_set_ctc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_ctc_config *ctc_config);
-
-void atomisp_css_set_yuv2rgb_cc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_cc_config *yuv2rgb_cc_config);
-
-void atomisp_css_set_rgb2yuv_cc_config(struct atomisp_sub_device *asd,
-			struct atomisp_css_cc_config *rgb2yuv_cc_config);
-
-void atomisp_css_set_xnr_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_xnr_table *xnr_table);
-
-void atomisp_css_set_r_gamma_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_rgb_gamma_table *r_gamma_table);
-
-void atomisp_css_set_g_gamma_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_rgb_gamma_table *g_gamma_table);
-
-void atomisp_css_set_b_gamma_table(struct atomisp_sub_device *asd,
-			struct atomisp_css_rgb_gamma_table *b_gamma_table);
-
-void atomisp_css_set_anr_thres(struct atomisp_sub_device *asd,
-			struct atomisp_css_anr_thres *anr_thres);
-
-int atomisp_css_check_firmware_version(struct atomisp_device *isp);
-
-int atomisp_css_load_firmware(struct atomisp_device *isp);
-
-void atomisp_css_unload_firmware(struct atomisp_device *isp);
-
-void atomisp_css_set_dvs_6axis(struct atomisp_sub_device *asd,
-			struct atomisp_css_dvs_6axis *dvs_6axis);
-
-unsigned int atomisp_css_debug_get_dtrace_level(void);
-
-int atomisp_css_debug_dump_isp_binary(void);
-
-int atomisp_css_dump_sp_raw_copy_linecount(bool reduced);
-
-int atomisp_css_dump_blob_infor(void);
-
-void atomisp_css_set_isp_config_id(struct atomisp_sub_device *asd,
-			uint32_t isp_config_id);
-
-void atomisp_css_set_isp_config_applied_frame(struct atomisp_sub_device *asd,
-			struct atomisp_css_frame *output_frame);
-
-int atomisp_get_css_dbgfunc(void);
-
-int atomisp_set_css_dbgfunc(struct atomisp_device *isp, int opt);
-struct atomisp_css_dvs_grid_info *atomisp_css_get_dvs_grid_info(
-	struct atomisp_css_grid_info *grid_info);
-#endif

+ 0 - 1225
drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_ioctl32.c

@@ -1,1225 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- *
- */
-#ifdef CONFIG_COMPAT
-#include <linux/compat.h>
-
-#include <linux/videodev2.h>
-
-#include "atomisp_internal.h"
-#include "atomisp_compat.h"
-#include "atomisp_ioctl.h"
-#include "atomisp_compat_ioctl32.h"
-
-static int get_atomisp_histogram32(struct atomisp_histogram *kp,
-					struct atomisp_histogram32 __user *up)
-{
-	compat_uptr_t tmp;
-
-	if (!access_ok(VERIFY_READ, up, sizeof(struct atomisp_histogram32)) ||
-		get_user(kp->num_elements, &up->num_elements) ||
-		get_user(tmp, &up->data))
-			return -EFAULT;
-
-	kp->data = compat_ptr(tmp);
-	return 0;
-}
-
-static int put_atomisp_histogram32(struct atomisp_histogram *kp,
-					struct atomisp_histogram32 __user *up)
-{
-	compat_uptr_t tmp = (compat_uptr_t)((uintptr_t)kp->data);
-
-	if (!access_ok(VERIFY_WRITE, up, sizeof(struct atomisp_histogram32)) ||
-		put_user(kp->num_elements, &up->num_elements) ||
-		put_user(tmp, &up->data))
-			return -EFAULT;
-
-	return 0;
-}
-
-static inline int get_v4l2_pix_format(struct v4l2_pix_format *kp,
-					struct v4l2_pix_format __user *up)
-{
-	if (copy_from_user(kp, up, sizeof(struct v4l2_pix_format)))
-		return -EFAULT;
-	return 0;
-}
-
-static inline int put_v4l2_pix_format(struct v4l2_pix_format *kp,
-					struct v4l2_pix_format __user *up)
-{
-	if (copy_to_user(up, kp, sizeof(struct v4l2_pix_format)))
-		return -EFAULT;
-	return 0;
-}
-
-static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp,
-					struct v4l2_framebuffer32 __user *up)
-{
-	compat_uptr_t tmp;
-
-	if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_framebuffer32)) ||
-		get_user(tmp, &up->base) ||
-		get_user(kp->capability, &up->capability) ||
-		get_user(kp->flags, &up->flags))
-			return -EFAULT;
-
-	kp->base = (void __force *)compat_ptr(tmp);
-	get_v4l2_pix_format((struct v4l2_pix_format *)&kp->fmt, &up->fmt);
-	return 0;
-}
-
-static int get_atomisp_dis_statistics32(struct atomisp_dis_statistics *kp,
-				struct atomisp_dis_statistics32 __user *up)
-{
-	compat_uptr_t hor_prod_odd_real;
-	compat_uptr_t hor_prod_odd_imag;
-	compat_uptr_t hor_prod_even_real;
-	compat_uptr_t hor_prod_even_imag;
-	compat_uptr_t ver_prod_odd_real;
-	compat_uptr_t ver_prod_odd_imag;
-	compat_uptr_t ver_prod_even_real;
-	compat_uptr_t ver_prod_even_imag;
-
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct atomisp_dis_statistics32)) ||
-		copy_from_user(kp, up, sizeof(struct atomisp_dvs_grid_info)) ||
-		get_user(hor_prod_odd_real,
-				&up->dvs2_stat.hor_prod.odd_real) ||
-		get_user(hor_prod_odd_imag,
-				&up->dvs2_stat.hor_prod.odd_imag) ||
-		get_user(hor_prod_even_real,
-				&up->dvs2_stat.hor_prod.even_real) ||
-		get_user(hor_prod_even_imag,
-				&up->dvs2_stat.hor_prod.even_imag) ||
-		get_user(ver_prod_odd_real,
-				&up->dvs2_stat.ver_prod.odd_real) ||
-		get_user(ver_prod_odd_imag,
-				&up->dvs2_stat.ver_prod.odd_imag) ||
-		get_user(ver_prod_even_real,
-				&up->dvs2_stat.ver_prod.even_real) ||
-		get_user(ver_prod_even_imag,
-				&up->dvs2_stat.ver_prod.even_imag) ||
-		get_user(kp->exp_id, &up->exp_id))
-			return -EFAULT;
-
-	kp->dvs2_stat.hor_prod.odd_real = compat_ptr(hor_prod_odd_real);
-	kp->dvs2_stat.hor_prod.odd_imag = compat_ptr(hor_prod_odd_imag);
-	kp->dvs2_stat.hor_prod.even_real = compat_ptr(hor_prod_even_real);
-	kp->dvs2_stat.hor_prod.even_imag = compat_ptr(hor_prod_even_imag);
-	kp->dvs2_stat.ver_prod.odd_real = compat_ptr(ver_prod_odd_real);
-	kp->dvs2_stat.ver_prod.odd_imag = compat_ptr(ver_prod_odd_imag);
-	kp->dvs2_stat.ver_prod.even_real = compat_ptr(ver_prod_even_real);
-	kp->dvs2_stat.ver_prod.even_imag = compat_ptr(ver_prod_even_imag);
-	return 0;
-}
-
-static int put_atomisp_dis_statistics32(struct atomisp_dis_statistics *kp,
-				struct atomisp_dis_statistics32 __user *up)
-{
-	compat_uptr_t hor_prod_odd_real =
-		(compat_uptr_t)((uintptr_t)kp->dvs2_stat.hor_prod.odd_real);
-	compat_uptr_t hor_prod_odd_imag =
-		(compat_uptr_t)((uintptr_t)kp->dvs2_stat.hor_prod.odd_imag);
-	compat_uptr_t hor_prod_even_real =
-		(compat_uptr_t)((uintptr_t)kp->dvs2_stat.hor_prod.even_real);
-	compat_uptr_t hor_prod_even_imag =
-		(compat_uptr_t)((uintptr_t)kp->dvs2_stat.hor_prod.even_imag);
-	compat_uptr_t ver_prod_odd_real =
-		(compat_uptr_t)((uintptr_t)kp->dvs2_stat.ver_prod.odd_real);
-	compat_uptr_t ver_prod_odd_imag =
-		(compat_uptr_t)((uintptr_t)kp->dvs2_stat.ver_prod.odd_imag);
-	compat_uptr_t ver_prod_even_real =
-		(compat_uptr_t)((uintptr_t)kp->dvs2_stat.ver_prod.even_real);
-	compat_uptr_t ver_prod_even_imag =
-		(compat_uptr_t)((uintptr_t)kp->dvs2_stat.ver_prod.even_imag);
-
-	if (!access_ok(VERIFY_WRITE, up,
-			sizeof(struct atomisp_dis_statistics32)) ||
-		copy_to_user(up, kp, sizeof(struct atomisp_dvs_grid_info)) ||
-		put_user(hor_prod_odd_real,
-				&up->dvs2_stat.hor_prod.odd_real) ||
-		put_user(hor_prod_odd_imag,
-				&up->dvs2_stat.hor_prod.odd_imag) ||
-		put_user(hor_prod_even_real,
-				&up->dvs2_stat.hor_prod.even_real) ||
-		put_user(hor_prod_even_imag,
-				&up->dvs2_stat.hor_prod.even_imag) ||
-		put_user(ver_prod_odd_real,
-				&up->dvs2_stat.ver_prod.odd_real) ||
-		put_user(ver_prod_odd_imag,
-				&up->dvs2_stat.ver_prod.odd_imag) ||
-		put_user(ver_prod_even_real,
-				&up->dvs2_stat.ver_prod.even_real) ||
-		put_user(ver_prod_even_imag,
-				&up->dvs2_stat.ver_prod.even_imag) ||
-		put_user(kp->exp_id, &up->exp_id))
-			return -EFAULT;
-
-	return 0;
-}
-
-static int get_atomisp_dis_coefficients32(struct atomisp_dis_coefficients *kp,
-				struct atomisp_dis_coefficients32 __user *up)
-{
-	compat_uptr_t hor_coefs_odd_real;
-	compat_uptr_t hor_coefs_odd_imag;
-	compat_uptr_t hor_coefs_even_real;
-	compat_uptr_t hor_coefs_even_imag;
-	compat_uptr_t ver_coefs_odd_real;
-	compat_uptr_t ver_coefs_odd_imag;
-	compat_uptr_t ver_coefs_even_real;
-	compat_uptr_t ver_coefs_even_imag;
-
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct atomisp_dis_coefficients32)) ||
-		copy_from_user(kp, up, sizeof(struct atomisp_dvs_grid_info)) ||
-		get_user(hor_coefs_odd_real, &up->hor_coefs.odd_real) ||
-		get_user(hor_coefs_odd_imag, &up->hor_coefs.odd_imag) ||
-		get_user(hor_coefs_even_real, &up->hor_coefs.even_real) ||
-		get_user(hor_coefs_even_imag, &up->hor_coefs.even_imag) ||
-		get_user(ver_coefs_odd_real, &up->ver_coefs.odd_real) ||
-		get_user(ver_coefs_odd_imag, &up->ver_coefs.odd_imag) ||
-		get_user(ver_coefs_even_real, &up->ver_coefs.even_real) ||
-		get_user(ver_coefs_even_imag, &up->ver_coefs.even_imag))
-			return -EFAULT;
-
-	kp->hor_coefs.odd_real = compat_ptr(hor_coefs_odd_real);
-	kp->hor_coefs.odd_imag = compat_ptr(hor_coefs_odd_imag);
-	kp->hor_coefs.even_real = compat_ptr(hor_coefs_even_real);
-	kp->hor_coefs.even_imag = compat_ptr(hor_coefs_even_imag);
-	kp->ver_coefs.odd_real = compat_ptr(ver_coefs_odd_real);
-	kp->ver_coefs.odd_imag = compat_ptr(ver_coefs_odd_imag);
-	kp->ver_coefs.even_real = compat_ptr(ver_coefs_even_real);
-	kp->ver_coefs.even_imag = compat_ptr(ver_coefs_even_imag);
-	return 0;
-}
-
-static int get_atomisp_dvs_6axis_config32(struct atomisp_dvs_6axis_config *kp,
-				struct atomisp_dvs_6axis_config32 __user *up)
-{	compat_uptr_t xcoords_y;
-	compat_uptr_t ycoords_y;
-	compat_uptr_t xcoords_uv;
-	compat_uptr_t ycoords_uv;
-
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct atomisp_dvs_6axis_config32)) ||
-		get_user(kp->exp_id, &up->exp_id) ||
-		get_user(kp->width_y, &up->width_y) ||
-		get_user(kp->height_y, &up->height_y) ||
-		get_user(kp->width_uv, &up->width_uv) ||
-		get_user(kp->height_uv, &up->height_uv) ||
-		get_user(xcoords_y, &up->xcoords_y) ||
-		get_user(ycoords_y, &up->ycoords_y) ||
-		get_user(xcoords_uv, &up->xcoords_uv) ||
-		get_user(ycoords_uv, &up->ycoords_uv))
-			return -EFAULT;
-
-	kp->xcoords_y = (void __force *)compat_ptr(xcoords_y);
-	kp->ycoords_y = (void __force *)compat_ptr(ycoords_y);
-	kp->xcoords_uv = (void __force *)compat_ptr(xcoords_uv);
-	kp->ycoords_uv = (void __force *)compat_ptr(ycoords_uv);
-	return 0;
-}
-
-static int get_atomisp_3a_statistics32(struct atomisp_3a_statistics *kp,
-				struct atomisp_3a_statistics32 __user *up)
-{
-	compat_uptr_t data;
-	compat_uptr_t rgby_data;
-
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct atomisp_3a_statistics32)) ||
-		copy_from_user(kp, up, sizeof(struct atomisp_grid_info)) ||
-		get_user(rgby_data, &up->rgby_data) ||
-		get_user(data, &up->data) ||
-		get_user(kp->exp_id, &up->exp_id) ||
-		get_user(kp->isp_config_id, &up->isp_config_id))
-			return -EFAULT;
-
-	kp->data = compat_ptr(data);
-	kp->rgby_data = compat_ptr(rgby_data);
-
-	return 0;
-}
-
-static int put_atomisp_3a_statistics32(struct atomisp_3a_statistics *kp,
-				struct atomisp_3a_statistics32 __user *up)
-{
-	compat_uptr_t data = (compat_uptr_t)((uintptr_t)kp->data);
-	compat_uptr_t rgby_data = (compat_uptr_t)((uintptr_t)kp->rgby_data);
-
-	if (!access_ok(VERIFY_WRITE, up,
-			sizeof(struct atomisp_3a_statistics32)) ||
-		copy_to_user(up, kp, sizeof(struct atomisp_grid_info)) ||
-		put_user(rgby_data, &up->rgby_data) ||
-		put_user(data, &up->data) ||
-		put_user(kp->exp_id, &up->exp_id) ||
-		put_user(kp->isp_config_id, &up->isp_config_id))
-			return -EFAULT;
-
-	return 0;
-}
-
-
-static int get_atomisp_metadata_stat32(struct atomisp_metadata *kp,
-				struct atomisp_metadata32 __user *up)
-{
-	compat_uptr_t data;
-	compat_uptr_t effective_width;
-
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct atomisp_metadata32)) ||
-		get_user(data, &up->data) ||
-		get_user(kp->width, &up->width) ||
-		get_user(kp->height, &up->height) ||
-		get_user(kp->stride, &up->stride) ||
-		get_user(kp->exp_id, &up->exp_id) ||
-		get_user(effective_width, &up->effective_width))
-			return -EFAULT;
-
-	kp->data = compat_ptr(data);
-	kp->effective_width = (void __force *)compat_ptr(effective_width);
-	return 0;
-}
-
-
-static int put_atomisp_metadata_stat32(struct atomisp_metadata *kp,
-				struct atomisp_metadata32 __user *up)
-{
-	compat_uptr_t data = (compat_uptr_t)((uintptr_t)kp->data);
-	compat_uptr_t effective_width =
-		(compat_uptr_t)((uintptr_t)kp->effective_width);
-	if (!access_ok(VERIFY_WRITE, up,
-			sizeof(struct atomisp_metadata32)) ||
-		put_user(data, &up->data) ||
-		put_user(kp->width, &up->width) ||
-		put_user(kp->height, &up->height) ||
-		put_user(kp->stride, &up->stride) ||
-		put_user(kp->exp_id, &up->exp_id) ||
-		put_user(effective_width, &up->effective_width))
-			return -EFAULT;
-
-	return 0;
-}
-
-static int put_atomisp_metadata_by_type_stat32(
-				struct atomisp_metadata_with_type *kp,
-				struct atomisp_metadata_with_type32 __user *up)
-{
-	compat_uptr_t data = (compat_uptr_t)((uintptr_t)kp->data);
-	compat_uptr_t effective_width =
-		(compat_uptr_t)((uintptr_t)kp->effective_width);
-	if (!access_ok(VERIFY_WRITE, up,
-			sizeof(struct atomisp_metadata_with_type32)) ||
-		put_user(data, &up->data) ||
-		put_user(kp->width, &up->width) ||
-		put_user(kp->height, &up->height) ||
-		put_user(kp->stride, &up->stride) ||
-		put_user(kp->exp_id, &up->exp_id) ||
-		put_user(effective_width, &up->effective_width) ||
-		put_user(kp->type, &up->type))
-			return -EFAULT;
-
-	return 0;
-}
-
-static int get_atomisp_metadata_by_type_stat32(
-				struct atomisp_metadata_with_type *kp,
-				struct atomisp_metadata_with_type32 __user *up)
-{
-	compat_uptr_t data;
-	compat_uptr_t effective_width;
-
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct atomisp_metadata_with_type32)) ||
-		get_user(data, &up->data) ||
-		get_user(kp->width, &up->width) ||
-		get_user(kp->height, &up->height) ||
-		get_user(kp->stride, &up->stride) ||
-		get_user(kp->exp_id, &up->exp_id) ||
-		get_user(effective_width, &up->effective_width) ||
-		get_user(kp->type, &up->type))
-			return -EFAULT;
-
-	kp->data = compat_ptr(data);
-	kp->effective_width = (void __force *)compat_ptr(effective_width);
-	return 0;
-}
-
-static int get_atomisp_morph_table32(struct atomisp_morph_table *kp,
-				struct atomisp_morph_table32 __user *up)
-{
-	unsigned int n = ATOMISP_MORPH_TABLE_NUM_PLANES;
-
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct atomisp_morph_table32)) ||
-		get_user(kp->enabled, &up->enabled) ||
-		get_user(kp->width, &up->width) ||
-		get_user(kp->height, &up->height))
-			return -EFAULT;
-
-	while (n-- > 0) {
-		uintptr_t *coord_kp = (uintptr_t *)&kp->coordinates_x[n];
-
-		if (get_user((*coord_kp), &up->coordinates_x[n]))
-			return -EFAULT;
-
-		coord_kp = (uintptr_t *)&kp->coordinates_y[n];
-		if (get_user((*coord_kp), &up->coordinates_y[n]))
-			return -EFAULT;
-	}
-	return 0;
-}
-
-static int put_atomisp_morph_table32(struct atomisp_morph_table *kp,
-				struct atomisp_morph_table32 __user *up)
-{
-	unsigned int n = ATOMISP_MORPH_TABLE_NUM_PLANES;
-
-	if (!access_ok(VERIFY_WRITE, up,
-			sizeof(struct atomisp_morph_table32)) ||
-		put_user(kp->enabled, &up->enabled) ||
-		put_user(kp->width, &up->width) ||
-		put_user(kp->height, &up->height))
-			return -EFAULT;
-
-	while (n-- > 0) {
-		uintptr_t *coord_kp = (uintptr_t *)&kp->coordinates_x[n];
-
-		if (put_user((*coord_kp), &up->coordinates_x[n]))
-			return -EFAULT;
-
-		coord_kp = (uintptr_t *)&kp->coordinates_y[n];
-		if (put_user((*coord_kp), &up->coordinates_y[n]))
-			return -EFAULT;
-	}
-	return 0;
-}
-
-static int get_atomisp_overlay32(struct atomisp_overlay *kp,
-					struct atomisp_overlay32 __user *up)
-{
-	compat_uptr_t frame;
-	if (!access_ok(VERIFY_READ, up, sizeof(struct atomisp_overlay32)) ||
-		get_user(frame, &up->frame) ||
-		get_user(kp->bg_y, &up->bg_y) ||
-		get_user(kp->bg_u, &up->bg_u) ||
-		get_user(kp->bg_v, &up->bg_v) ||
-		get_user(kp->blend_input_perc_y, &up->blend_input_perc_y) ||
-		get_user(kp->blend_input_perc_u, &up->blend_input_perc_u) ||
-		get_user(kp->blend_input_perc_v, &up->blend_input_perc_v) ||
-		get_user(kp->blend_overlay_perc_y,
-				&up->blend_overlay_perc_y) ||
-		get_user(kp->blend_overlay_perc_u,
-				&up->blend_overlay_perc_u) ||
-		get_user(kp->blend_overlay_perc_v,
-				&up->blend_overlay_perc_v) ||
-		get_user(kp->blend_overlay_perc_u,
-				&up->blend_overlay_perc_u) ||
-		get_user(kp->overlay_start_x, &up->overlay_start_y))
-			return -EFAULT;
-
-	kp->frame = (void __force *)compat_ptr(frame);
-	return 0;
-}
-
-static int put_atomisp_overlay32(struct atomisp_overlay *kp,
-					struct atomisp_overlay32 __user *up)
-{
-	compat_uptr_t frame = (compat_uptr_t)((uintptr_t)kp->frame);
-
-	if (!access_ok(VERIFY_WRITE, up, sizeof(struct atomisp_overlay32)) ||
-		put_user(frame, &up->frame) ||
-		put_user(kp->bg_y, &up->bg_y) ||
-		put_user(kp->bg_u, &up->bg_u) ||
-		put_user(kp->bg_v, &up->bg_v) ||
-		put_user(kp->blend_input_perc_y, &up->blend_input_perc_y) ||
-		put_user(kp->blend_input_perc_u, &up->blend_input_perc_u) ||
-		put_user(kp->blend_input_perc_v, &up->blend_input_perc_v) ||
-		put_user(kp->blend_overlay_perc_y,
-				&up->blend_overlay_perc_y) ||
-		put_user(kp->blend_overlay_perc_u,
-				&up->blend_overlay_perc_u) ||
-		put_user(kp->blend_overlay_perc_v,
-				&up->blend_overlay_perc_v) ||
-		put_user(kp->blend_overlay_perc_u,
-				&up->blend_overlay_perc_u) ||
-		put_user(kp->overlay_start_x, &up->overlay_start_y))
-			return -EFAULT;
-
-	return 0;
-}
-
-static int get_atomisp_calibration_group32(
-				struct atomisp_calibration_group *kp,
-				struct atomisp_calibration_group32 __user *up)
-{
-	compat_uptr_t calb_grp_values;
-
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct atomisp_calibration_group32)) ||
-		get_user(kp->size, &up->size) ||
-		get_user(kp->type, &up->type) ||
-		get_user(calb_grp_values, &up->calb_grp_values))
-			return -EFAULT;
-
-	kp->calb_grp_values = (void __force *)compat_ptr(calb_grp_values);
-	return 0;
-}
-
-static int put_atomisp_calibration_group32(
-				struct atomisp_calibration_group *kp,
-				struct atomisp_calibration_group32 __user *up)
-{
-	compat_uptr_t calb_grp_values =
-			(compat_uptr_t)((uintptr_t)kp->calb_grp_values);
-
-	if (!access_ok(VERIFY_WRITE, up,
-			sizeof(struct atomisp_calibration_group32)) ||
-		put_user(kp->size, &up->size) ||
-		put_user(kp->type, &up->type) ||
-		put_user(calb_grp_values, &up->calb_grp_values))
-			return -EFAULT;
-
-	return 0;
-}
-
-static int get_atomisp_acc_fw_load32(struct atomisp_acc_fw_load *kp,
-				struct atomisp_acc_fw_load32 __user *up)
-{
-	compat_uptr_t data;
-
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct atomisp_acc_fw_load32)) ||
-		get_user(kp->size, &up->size) ||
-		get_user(kp->fw_handle, &up->fw_handle) ||
-		get_user(data, &up->data))
-			return -EFAULT;
-
-	kp->data = compat_ptr(data);
-	return 0;
-}
-
-static int put_atomisp_acc_fw_load32(struct atomisp_acc_fw_load *kp,
-				struct atomisp_acc_fw_load32 __user *up)
-{
-	compat_uptr_t data = (compat_uptr_t)((uintptr_t)kp->data);
-
-	if (!access_ok(VERIFY_WRITE, up,
-			sizeof(struct atomisp_acc_fw_load32)) ||
-		put_user(kp->size, &up->size) ||
-		put_user(kp->fw_handle, &up->fw_handle) ||
-		put_user(data, &up->data))
-			return -EFAULT;
-
-	return 0;
-}
-
-static int get_atomisp_acc_fw_arg32(struct atomisp_acc_fw_arg *kp,
-					struct atomisp_acc_fw_arg32 __user *up)
-{
-	compat_uptr_t value;
-
-	if (!access_ok(VERIFY_READ, up, sizeof(struct atomisp_acc_fw_arg32)) ||
-		get_user(kp->fw_handle, &up->fw_handle) ||
-		get_user(kp->index, &up->index) ||
-		get_user(value, &up->value) ||
-		get_user(kp->size, &up->size))
-			return -EFAULT;
-
-	kp->value = compat_ptr(value);
-	return 0;
-}
-
-static int put_atomisp_acc_fw_arg32(struct atomisp_acc_fw_arg *kp,
-					struct atomisp_acc_fw_arg32 __user *up)
-{
-	compat_uptr_t value = (compat_uptr_t)((uintptr_t)kp->value);
-
-	if (!access_ok(VERIFY_WRITE, up, sizeof(struct atomisp_acc_fw_arg32)) ||
-		put_user(kp->fw_handle, &up->fw_handle) ||
-		put_user(kp->index, &up->index) ||
-		put_user(value, &up->value) ||
-		put_user(kp->size, &up->size))
-			return -EFAULT;
-
-	return 0;
-}
-
-static int get_v4l2_private_int_data32(struct v4l2_private_int_data *kp,
-					struct v4l2_private_int_data32 __user *up)
-{
-	compat_uptr_t data;
-
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct v4l2_private_int_data32)) ||
-		get_user(kp->size, &up->size) ||
-		get_user(data, &up->data) ||
-		get_user(kp->reserved[0], &up->reserved[0]) ||
-		get_user(kp->reserved[1], &up->reserved[1]))
-			return -EFAULT;
-
-	kp->data = compat_ptr(data);
-	return 0;
-}
-
-static int put_v4l2_private_int_data32(struct v4l2_private_int_data *kp,
-				struct v4l2_private_int_data32 __user *up)
-{
-	compat_uptr_t data = (compat_uptr_t)((uintptr_t)kp->data);
-
-	if (!access_ok(VERIFY_WRITE, up,
-			sizeof(struct v4l2_private_int_data32)) ||
-		put_user(kp->size, &up->size) ||
-		put_user(data, &up->data) ||
-		put_user(kp->reserved[0], &up->reserved[0]) ||
-		put_user(kp->reserved[1], &up->reserved[1]))
-			return -EFAULT;
-
-	return 0;
-}
-
-static int get_atomisp_shading_table32(struct atomisp_shading_table *kp,
-				struct atomisp_shading_table32 __user *up)
-{
-	unsigned int n = ATOMISP_NUM_SC_COLORS;
-
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct atomisp_shading_table32)) ||
-		get_user(kp->enable, &up->enable) ||
-		get_user(kp->sensor_width, &up->sensor_width) ||
-		get_user(kp->sensor_height, &up->sensor_height) ||
-		get_user(kp->width, &up->width) ||
-		get_user(kp->height, &up->height) ||
-		get_user(kp->fraction_bits, &up->fraction_bits))
-			return -EFAULT;
-
-	while (n-- > 0) {
-		uintptr_t *data_p = (uintptr_t *)&kp->data[n];
-
-		if (get_user((*data_p), &up->data[n]))
-			return -EFAULT;
-	}
-	return 0;
-}
-
-static int get_atomisp_acc_map32(struct atomisp_acc_map *kp,
-					struct atomisp_acc_map32 __user *up)
-{
-	compat_uptr_t user_ptr;
-
-	if (!access_ok(VERIFY_READ, up, sizeof(struct atomisp_acc_map32)) ||
-		get_user(kp->flags, &up->flags) ||
-		get_user(kp->length, &up->length) ||
-		get_user(user_ptr, &up->user_ptr) ||
-		get_user(kp->css_ptr, &up->css_ptr) ||
-		get_user(kp->reserved[0], &up->reserved[0]) ||
-		get_user(kp->reserved[1], &up->reserved[1]) ||
-		get_user(kp->reserved[2], &up->reserved[2]) ||
-		get_user(kp->reserved[3], &up->reserved[3]))
-			return -EFAULT;
-
-	kp->user_ptr = compat_ptr(user_ptr);
-	return 0;
-}
-
-static int put_atomisp_acc_map32(struct atomisp_acc_map *kp,
-					struct atomisp_acc_map32 __user *up)
-{
-	compat_uptr_t user_ptr = (compat_uptr_t)((uintptr_t)kp->user_ptr);
-
-	if (!access_ok(VERIFY_WRITE, up, sizeof(struct atomisp_acc_map32)) ||
-		put_user(kp->flags, &up->flags) ||
-		put_user(kp->length, &up->length) ||
-		put_user(user_ptr, &up->user_ptr) ||
-		put_user(kp->css_ptr, &up->css_ptr) ||
-		put_user(kp->reserved[0], &up->reserved[0]) ||
-		put_user(kp->reserved[1], &up->reserved[1]) ||
-		put_user(kp->reserved[2], &up->reserved[2]) ||
-		put_user(kp->reserved[3], &up->reserved[3]))
-			return -EFAULT;
-
-	return 0;
-}
-
-static int get_atomisp_acc_s_mapped_arg32(struct atomisp_acc_s_mapped_arg *kp,
-				struct atomisp_acc_s_mapped_arg32 __user *up)
-{
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct atomisp_acc_s_mapped_arg32)) ||
-		get_user(kp->fw_handle, &up->fw_handle) ||
-		get_user(kp->memory, &up->memory) ||
-		get_user(kp->length, &up->length) ||
-		get_user(kp->css_ptr, &up->css_ptr))
-			return -EFAULT;
-
-	return 0;
-}
-
-static int put_atomisp_acc_s_mapped_arg32(struct atomisp_acc_s_mapped_arg *kp,
-				struct atomisp_acc_s_mapped_arg32 __user *up)
-{
-	if (!access_ok(VERIFY_WRITE, up,
-			sizeof(struct atomisp_acc_s_mapped_arg32)) ||
-		put_user(kp->fw_handle, &up->fw_handle) ||
-		put_user(kp->memory, &up->memory) ||
-		put_user(kp->length, &up->length) ||
-		put_user(kp->css_ptr, &up->css_ptr))
-			return -EFAULT;
-
-	return 0;
-}
-
-static int get_atomisp_parameters32(struct atomisp_parameters *kp,
-					struct atomisp_parameters32 __user *up)
-{
-	int n = offsetof(struct atomisp_parameters32, output_frame) /
-				sizeof(compat_uptr_t);
-	unsigned int size, offset = 0;
-	void  __user *user_ptr;
-	unsigned int stp, mtp, dcp, dscp = 0;
-
-	if (!access_ok(VERIFY_READ, up, sizeof(struct atomisp_parameters32)))
-			return -EFAULT;
-
-	while (n >= 0) {
-		compat_uptr_t __user *src = ((compat_uptr_t __user *)up) + n;
-		uintptr_t *dst = ((uintptr_t *)kp) + n;
-
-		if (get_user((*dst), src))
-			return -EFAULT;
-		n--;
-	}
-	if (get_user(kp->isp_config_id, &up->isp_config_id) ||
-	    get_user(kp->per_frame_setting, &up->per_frame_setting) ||
-	    get_user(stp, &up->shading_table) ||
-	    get_user(mtp, &up->morph_table) ||
-	    get_user(dcp, &up->dvs2_coefs) ||
-	    get_user(dscp, &up->dvs_6axis_config))
-		return -EFAULT;
-
-	{
-		union {
-			struct atomisp_shading_table shading_table;
-			struct atomisp_morph_table   morph_table;
-			struct atomisp_dis_coefficients dvs2_coefs;
-			struct atomisp_dvs_6axis_config dvs_6axis_config;
-		} karg;
-
-		size = sizeof(struct atomisp_shading_table) +
-				sizeof(struct atomisp_morph_table) +
-				sizeof(struct atomisp_dis_coefficients) +
-				sizeof(struct atomisp_dvs_6axis_config);
-		user_ptr = compat_alloc_user_space(size);
-
-		/* handle shading table */
-		if (stp != 0) {
-			if (get_atomisp_shading_table32(&karg.shading_table,
-				(struct atomisp_shading_table32 __user *)
-						(uintptr_t)stp))
-				return -EFAULT;
-
-			kp->shading_table = (void __force *)user_ptr + offset;
-			offset = sizeof(struct atomisp_shading_table);
-			if (!kp->shading_table)
-				return -EFAULT;
-
-			if (copy_to_user((void __user *)kp->shading_table,
-					 &karg.shading_table,
-					 sizeof(struct atomisp_shading_table)))
-				return -EFAULT;
-		}
-
-		/* handle morph table */
-		if (mtp != 0) {
-			if (get_atomisp_morph_table32(&karg.morph_table,
-					(struct atomisp_morph_table32 __user *)
-						(uintptr_t)mtp))
-				return -EFAULT;
-
-			kp->morph_table = (void __force *)user_ptr + offset;
-			offset += sizeof(struct atomisp_morph_table);
-			if (!kp->morph_table)
-				return -EFAULT;
-
-			if (copy_to_user((void __user *)kp->morph_table,
-					 &karg.morph_table,
-					 sizeof(struct atomisp_morph_table)))
-				return -EFAULT;
-		}
-
-		/* handle dvs2 coefficients */
-		if (dcp != 0) {
-			if (get_atomisp_dis_coefficients32(&karg.dvs2_coefs,
-				(struct atomisp_dis_coefficients32 __user *)
-						(uintptr_t)dcp))
-				return -EFAULT;
-
-			kp->dvs2_coefs = (void __force *)user_ptr + offset;
-			offset += sizeof(struct atomisp_dis_coefficients);
-			if (!kp->dvs2_coefs)
-				return -EFAULT;
-
-			if (copy_to_user((void __user *)kp->dvs2_coefs,
-					 &karg.dvs2_coefs,
-					 sizeof(struct atomisp_dis_coefficients)))
-				return -EFAULT;
-		}
-		/* handle dvs 6axis configuration */
-		if (dscp != 0) {
-			if (get_atomisp_dvs_6axis_config32(&karg.dvs_6axis_config,
-				(struct atomisp_dvs_6axis_config32 __user *)
-						(uintptr_t)dscp))
-				return -EFAULT;
-
-			kp->dvs_6axis_config = (void __force *)user_ptr + offset;
-			offset += sizeof(struct atomisp_dvs_6axis_config);
-			if (!kp->dvs_6axis_config)
-				return -EFAULT;
-
-			if (copy_to_user((void __user *)kp->dvs_6axis_config,
-					 &karg.dvs_6axis_config,
-					 sizeof(struct atomisp_dvs_6axis_config)))
-				return -EFAULT;
-		}
-	}
-	return 0;
-}
-
-static int get_atomisp_acc_fw_load_to_pipe32(
-			struct atomisp_acc_fw_load_to_pipe *kp,
-			struct atomisp_acc_fw_load_to_pipe32 __user *up)
-{
-	compat_uptr_t data;
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct atomisp_acc_fw_load_to_pipe32)) ||
-		get_user(kp->flags, &up->flags) ||
-		get_user(kp->fw_handle, &up->fw_handle) ||
-		get_user(kp->size, &up->size) ||
-		get_user(kp->type, &up->type) ||
-		get_user(kp->reserved[0], &up->reserved[0]) ||
-		get_user(kp->reserved[1], &up->reserved[1]) ||
-		get_user(kp->reserved[2], &up->reserved[2]) ||
-		get_user(data, &up->data))
-			return -EFAULT;
-
-	kp->data = compat_ptr(data);
-	return 0;
-}
-
-static int put_atomisp_acc_fw_load_to_pipe32(
-			struct atomisp_acc_fw_load_to_pipe *kp,
-			struct atomisp_acc_fw_load_to_pipe32 __user *up)
-{
-	compat_uptr_t data = (compat_uptr_t)((uintptr_t)kp->data);
-	if (!access_ok(VERIFY_WRITE, up,
-			sizeof(struct atomisp_acc_fw_load_to_pipe32)) ||
-		put_user(kp->flags, &up->flags) ||
-		put_user(kp->fw_handle, &up->fw_handle) ||
-		put_user(kp->size, &up->size) ||
-		put_user(kp->type, &up->type) ||
-		put_user(kp->reserved[0], &up->reserved[0]) ||
-		put_user(kp->reserved[1], &up->reserved[1]) ||
-		put_user(kp->reserved[2], &up->reserved[2]) ||
-		put_user(data, &up->data))
-			return -EFAULT;
-
-	return 0;
-}
-
-static int get_atomisp_sensor_ae_bracketing_lut(
-			struct atomisp_sensor_ae_bracketing_lut *kp,
-			struct atomisp_sensor_ae_bracketing_lut32 __user *up)
-{
-	compat_uptr_t lut;
-	if (!access_ok(VERIFY_READ, up,
-			sizeof(struct atomisp_sensor_ae_bracketing_lut32)) ||
-		get_user(kp->lut_size, &up->lut_size) ||
-		get_user(lut, &up->lut))
-			return -EFAULT;
-
-	kp->lut = (void __force *)compat_ptr(lut);
-	return 0;
-}
-
-static long native_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	long ret = -ENOIOCTLCMD;
-
-	if (file->f_op->unlocked_ioctl)
-		ret = file->f_op->unlocked_ioctl(file, cmd, arg);
-
-	return ret;
-}
-
-static long atomisp_do_compat_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	union {
-		struct atomisp_histogram his;
-		struct atomisp_dis_statistics dis_s;
-		struct atomisp_dis_coefficients dis_c;
-		struct atomisp_dvs_6axis_config dvs_c;
-		struct atomisp_3a_statistics s3a_s;
-		struct atomisp_morph_table mor_t;
-		struct v4l2_framebuffer v4l2_buf;
-		struct atomisp_overlay overlay;
-		struct atomisp_calibration_group cal_grp;
-		struct atomisp_acc_fw_load acc_fw_load;
-		struct atomisp_acc_fw_arg acc_fw_arg;
-		struct v4l2_private_int_data v4l2_pri_data;
-		struct atomisp_shading_table shd_tbl;
-		struct atomisp_acc_map acc_map;
-		struct atomisp_acc_s_mapped_arg acc_map_arg;
-		struct atomisp_parameters param;
-		struct atomisp_acc_fw_load_to_pipe acc_fw_to_pipe;
-		struct atomisp_metadata md;
-		struct atomisp_metadata_with_type md_with_type;
-		struct atomisp_sensor_ae_bracketing_lut lut;
-	} karg;
-	mm_segment_t old_fs;
-	void __user *up = compat_ptr(arg);
-	long err = -ENOIOCTLCMD;
-
-	/* First, convert the command. */
-	switch (cmd) {
-	case ATOMISP_IOC_G_HISTOGRAM32:
-		cmd = ATOMISP_IOC_G_HISTOGRAM;
-		break;
-	case ATOMISP_IOC_S_HISTOGRAM32:
-		cmd = ATOMISP_IOC_S_HISTOGRAM;
-		break;
-	case ATOMISP_IOC_G_DIS_STAT32:
-		cmd = ATOMISP_IOC_G_DIS_STAT;
-		break;
-	case ATOMISP_IOC_S_DIS_COEFS32:
-		cmd = ATOMISP_IOC_S_DIS_COEFS;
-		break;
-	case ATOMISP_IOC_S_DIS_VECTOR32:
-		cmd = ATOMISP_IOC_S_DIS_VECTOR;
-		break;
-	case ATOMISP_IOC_G_3A_STAT32:
-		cmd = ATOMISP_IOC_G_3A_STAT;
-		break;
-	case ATOMISP_IOC_G_ISP_GDC_TAB32:
-		cmd = ATOMISP_IOC_G_ISP_GDC_TAB;
-		break;
-	case ATOMISP_IOC_S_ISP_GDC_TAB32:
-		cmd = ATOMISP_IOC_S_ISP_GDC_TAB;
-		break;
-	case ATOMISP_IOC_S_ISP_FPN_TABLE32:
-		cmd = ATOMISP_IOC_S_ISP_FPN_TABLE;
-		break;
-	case ATOMISP_IOC_G_ISP_OVERLAY32:
-		cmd = ATOMISP_IOC_G_ISP_OVERLAY;
-		break;
-	case ATOMISP_IOC_S_ISP_OVERLAY32:
-		cmd = ATOMISP_IOC_S_ISP_OVERLAY;
-		break;
-	case ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP32:
-		cmd = ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP;
-		break;
-	case ATOMISP_IOC_ACC_LOAD32:
-		cmd = ATOMISP_IOC_ACC_LOAD;
-		break;
-	case ATOMISP_IOC_ACC_S_ARG32:
-		cmd = ATOMISP_IOC_ACC_S_ARG;
-		break;
-	case ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA32:
-		cmd = ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA;
-		break;
-	case ATOMISP_IOC_S_ISP_SHD_TAB32:
-		cmd = ATOMISP_IOC_S_ISP_SHD_TAB;
-		break;
-	case ATOMISP_IOC_ACC_DESTAB32:
-		cmd = ATOMISP_IOC_ACC_DESTAB;
-		break;
-	case ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA32:
-		cmd = ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA;
-		break;
-	case ATOMISP_IOC_ACC_MAP32:
-		cmd = ATOMISP_IOC_ACC_MAP;
-		break;
-	case ATOMISP_IOC_ACC_UNMAP32:
-		cmd = ATOMISP_IOC_ACC_UNMAP;
-		break;
-	case ATOMISP_IOC_ACC_S_MAPPED_ARG32:
-		cmd = ATOMISP_IOC_ACC_S_MAPPED_ARG;
-		break;
-	case ATOMISP_IOC_S_PARAMETERS32:
-		cmd = ATOMISP_IOC_S_PARAMETERS;
-		break;
-	case ATOMISP_IOC_ACC_LOAD_TO_PIPE32:
-		cmd = ATOMISP_IOC_ACC_LOAD_TO_PIPE;
-		break;
-	case ATOMISP_IOC_G_METADATA32:
-		cmd = ATOMISP_IOC_G_METADATA;
-		break;
-	case ATOMISP_IOC_G_METADATA_BY_TYPE32:
-		cmd = ATOMISP_IOC_G_METADATA_BY_TYPE;
-		break;
-	case ATOMISP_IOC_S_SENSOR_AE_BRACKETING_LUT32:
-		cmd = ATOMISP_IOC_S_SENSOR_AE_BRACKETING_LUT;
-		break;
-	}
-
-	switch (cmd) {
-	case ATOMISP_IOC_G_HISTOGRAM:
-	case ATOMISP_IOC_S_HISTOGRAM:
-		err = get_atomisp_histogram32(&karg.his, up);
-		break;
-	case ATOMISP_IOC_G_DIS_STAT:
-		err = get_atomisp_dis_statistics32(&karg.dis_s, up);
-		break;
-	case ATOMISP_IOC_S_DIS_COEFS:
-		err = get_atomisp_dis_coefficients32(&karg.dis_c, up);
-		break;
-	case ATOMISP_IOC_S_DIS_VECTOR:
-		err = get_atomisp_dvs_6axis_config32(&karg.dvs_c, up);
-		break;
-	case ATOMISP_IOC_G_3A_STAT:
-		err = get_atomisp_3a_statistics32(&karg.s3a_s, up);
-		break;
-	case ATOMISP_IOC_G_ISP_GDC_TAB:
-	case ATOMISP_IOC_S_ISP_GDC_TAB:
-		err = get_atomisp_morph_table32(&karg.mor_t, up);
-		break;
-	case ATOMISP_IOC_S_ISP_FPN_TABLE:
-		err = get_v4l2_framebuffer32(&karg.v4l2_buf, up);
-		break;
-	case ATOMISP_IOC_G_ISP_OVERLAY:
-	case ATOMISP_IOC_S_ISP_OVERLAY:
-		err = get_atomisp_overlay32(&karg.overlay, up);
-		break;
-	case ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP:
-		err = get_atomisp_calibration_group32(&karg.cal_grp, up);
-		break;
-	case ATOMISP_IOC_ACC_LOAD:
-		err = get_atomisp_acc_fw_load32(&karg.acc_fw_load, up);
-		break;
-	case ATOMISP_IOC_ACC_S_ARG:
-	case ATOMISP_IOC_ACC_DESTAB:
-		err = get_atomisp_acc_fw_arg32(&karg.acc_fw_arg, up);
-		break;
-	case ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA:
-	case ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA:
-		err = get_v4l2_private_int_data32(&karg.v4l2_pri_data, up);
-		break;
-	case ATOMISP_IOC_S_ISP_SHD_TAB:
-		err = get_atomisp_shading_table32(&karg.shd_tbl, up);
-		break;
-	case ATOMISP_IOC_ACC_MAP:
-	case ATOMISP_IOC_ACC_UNMAP:
-		err = get_atomisp_acc_map32(&karg.acc_map, up);
-		break;
-	case ATOMISP_IOC_ACC_S_MAPPED_ARG:
-		err = get_atomisp_acc_s_mapped_arg32(&karg.acc_map_arg, up);
-		break;
-	case ATOMISP_IOC_S_PARAMETERS:
-		err = get_atomisp_parameters32(&karg.param, up);
-		break;
-	case ATOMISP_IOC_ACC_LOAD_TO_PIPE:
-		err = get_atomisp_acc_fw_load_to_pipe32(&karg.acc_fw_to_pipe,
-							up);
-		break;
-	case ATOMISP_IOC_G_METADATA:
-		err = get_atomisp_metadata_stat32(&karg.md, up);
-		break;
-	case ATOMISP_IOC_G_METADATA_BY_TYPE:
-		err = get_atomisp_metadata_by_type_stat32(&karg.md_with_type,
-							up);
-		break;
-	case ATOMISP_IOC_S_SENSOR_AE_BRACKETING_LUT:
-		err = get_atomisp_sensor_ae_bracketing_lut(&karg.lut, up);
-		break;
-	}
-	if (err)
-		return err;
-
-	old_fs = get_fs();
-	set_fs(KERNEL_DS);
-	err = native_ioctl(file, cmd, (unsigned long)&karg);
-	set_fs(old_fs);
-	if (err)
-		return err;
-
-	switch (cmd) {
-	case ATOMISP_IOC_G_HISTOGRAM:
-		err = put_atomisp_histogram32(&karg.his, up);
-		break;
-	case ATOMISP_IOC_G_DIS_STAT:
-		err = put_atomisp_dis_statistics32(&karg.dis_s, up);
-		break;
-	case ATOMISP_IOC_G_3A_STAT:
-		err = put_atomisp_3a_statistics32(&karg.s3a_s, up);
-		break;
-	case ATOMISP_IOC_G_ISP_GDC_TAB:
-		err = put_atomisp_morph_table32(&karg.mor_t, up);
-		break;
-	case ATOMISP_IOC_G_ISP_OVERLAY:
-		err = put_atomisp_overlay32(&karg.overlay, up);
-		break;
-	case ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP:
-		err = put_atomisp_calibration_group32(&karg.cal_grp, up);
-		break;
-	case ATOMISP_IOC_ACC_LOAD:
-		err = put_atomisp_acc_fw_load32(&karg.acc_fw_load, up);
-		break;
-	case ATOMISP_IOC_ACC_S_ARG:
-	case ATOMISP_IOC_ACC_DESTAB:
-		err = put_atomisp_acc_fw_arg32(&karg.acc_fw_arg, up);
-		break;
-	case ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA:
-	case ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA:
-		err = put_v4l2_private_int_data32(&karg.v4l2_pri_data, up);
-		break;
-	case ATOMISP_IOC_ACC_MAP:
-	case ATOMISP_IOC_ACC_UNMAP:
-		err = put_atomisp_acc_map32(&karg.acc_map, up);
-		break;
-	case ATOMISP_IOC_ACC_S_MAPPED_ARG:
-		err = put_atomisp_acc_s_mapped_arg32(&karg.acc_map_arg, up);
-		break;
-	case ATOMISP_IOC_ACC_LOAD_TO_PIPE:
-		err = put_atomisp_acc_fw_load_to_pipe32(&karg.acc_fw_to_pipe,
-							up);
-		break;
-	case ATOMISP_IOC_G_METADATA:
-		err = put_atomisp_metadata_stat32(&karg.md, up);
-		break;
-	case ATOMISP_IOC_G_METADATA_BY_TYPE:
-		err = put_atomisp_metadata_by_type_stat32(&karg.md_with_type,
-							up);
-		break;
-	}
-
-	return err;
-}
-
-long atomisp_compat_ioctl32(struct file *file,
-			    unsigned int cmd, unsigned long arg)
-{
-
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	long ret = -ENOIOCTLCMD;
-
-	if (!file->f_op->unlocked_ioctl)
-		return ret;
-
-	switch (cmd) {
-	case ATOMISP_IOC_G_XNR:
-	case ATOMISP_IOC_S_XNR:
-	case ATOMISP_IOC_G_NR:
-	case ATOMISP_IOC_S_NR:
-	case ATOMISP_IOC_G_TNR:
-	case ATOMISP_IOC_S_TNR:
-	case ATOMISP_IOC_G_BLACK_LEVEL_COMP:
-	case ATOMISP_IOC_S_BLACK_LEVEL_COMP:
-	case ATOMISP_IOC_G_EE:
-	case ATOMISP_IOC_S_EE:
-	case ATOMISP_IOC_S_DIS_VECTOR:
-	case ATOMISP_IOC_G_ISP_PARM:
-	case ATOMISP_IOC_S_ISP_PARM:
-	case ATOMISP_IOC_G_ISP_GAMMA:
-	case ATOMISP_IOC_S_ISP_GAMMA:
-	case ATOMISP_IOC_ISP_MAKERNOTE:
-	case ATOMISP_IOC_G_ISP_MACC:
-	case ATOMISP_IOC_S_ISP_MACC:
-	case ATOMISP_IOC_G_ISP_BAD_PIXEL_DETECTION:
-	case ATOMISP_IOC_S_ISP_BAD_PIXEL_DETECTION:
-	case ATOMISP_IOC_G_ISP_FALSE_COLOR_CORRECTION:
-	case ATOMISP_IOC_S_ISP_FALSE_COLOR_CORRECTION:
-	case ATOMISP_IOC_G_ISP_CTC:
-	case ATOMISP_IOC_S_ISP_CTC:
-	case ATOMISP_IOC_G_ISP_WHITE_BALANCE:
-	case ATOMISP_IOC_S_ISP_WHITE_BALANCE:
-	case ATOMISP_IOC_CAMERA_BRIDGE:
-	case ATOMISP_IOC_G_SENSOR_MODE_DATA:
-	case ATOMISP_IOC_S_EXPOSURE:
-	case ATOMISP_IOC_G_3A_CONFIG:
-	case ATOMISP_IOC_S_3A_CONFIG:
-	case ATOMISP_IOC_ACC_UNLOAD:
-	case ATOMISP_IOC_ACC_START:
-	case ATOMISP_IOC_ACC_WAIT:
-	case ATOMISP_IOC_ACC_ABORT:
-	case ATOMISP_IOC_G_ISP_GAMMA_CORRECTION:
-	case ATOMISP_IOC_S_ISP_GAMMA_CORRECTION:
-	case ATOMISP_IOC_S_CONT_CAPTURE_CONFIG:
-	case ATOMISP_IOC_G_DVS2_BQ_RESOLUTIONS:
-	case ATOMISP_IOC_EXT_ISP_CTRL:
-	case ATOMISP_IOC_EXP_ID_UNLOCK:
-	case ATOMISP_IOC_EXP_ID_CAPTURE:
-	case ATOMISP_IOC_S_ENABLE_DZ_CAPT_PIPE:
-	case ATOMISP_IOC_G_FORMATS_CONFIG:
-	case ATOMISP_IOC_S_FORMATS_CONFIG:
-	case ATOMISP_IOC_S_EXPOSURE_WINDOW:
-	case ATOMISP_IOC_S_ACC_STATE:
-	case ATOMISP_IOC_G_ACC_STATE:
-	case ATOMISP_IOC_INJECT_A_FAKE_EVENT:
-	case ATOMISP_IOC_G_SENSOR_AE_BRACKETING_INFO:
-	case ATOMISP_IOC_S_SENSOR_AE_BRACKETING_MODE:
-	case ATOMISP_IOC_G_SENSOR_AE_BRACKETING_MODE:
-	case ATOMISP_IOC_G_INVALID_FRAME_NUM:
-	case ATOMISP_IOC_S_ARRAY_RESOLUTION:
-#ifdef ISP2401
-	case ATOMISP_IOC_S_SENSOR_RUNMODE:
-	case ATOMISP_IOC_G_UPDATE_EXPOSURE:
-#endif
-		ret = native_ioctl(file, cmd, arg);
-		break;
-
-	case ATOMISP_IOC_G_HISTOGRAM32:
-	case ATOMISP_IOC_S_HISTOGRAM32:
-	case ATOMISP_IOC_G_DIS_STAT32:
-	case ATOMISP_IOC_S_DIS_COEFS32:
-	case ATOMISP_IOC_S_DIS_VECTOR32:
-	case ATOMISP_IOC_G_3A_STAT32:
-	case ATOMISP_IOC_G_ISP_GDC_TAB32:
-	case ATOMISP_IOC_S_ISP_GDC_TAB32:
-	case ATOMISP_IOC_S_ISP_FPN_TABLE32:
-	case ATOMISP_IOC_G_ISP_OVERLAY32:
-	case ATOMISP_IOC_S_ISP_OVERLAY32:
-	case ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP32:
-	case ATOMISP_IOC_ACC_LOAD32:
-	case ATOMISP_IOC_ACC_S_ARG32:
-	case ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA32:
-	case ATOMISP_IOC_S_ISP_SHD_TAB32:
-	case ATOMISP_IOC_ACC_DESTAB32:
-	case ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA32:
-	case ATOMISP_IOC_ACC_MAP32:
-	case ATOMISP_IOC_ACC_UNMAP32:
-	case ATOMISP_IOC_ACC_S_MAPPED_ARG32:
-	case ATOMISP_IOC_S_PARAMETERS32:
-	case ATOMISP_IOC_ACC_LOAD_TO_PIPE32:
-	case ATOMISP_IOC_G_METADATA32:
-	case ATOMISP_IOC_G_METADATA_BY_TYPE32:
-	case ATOMISP_IOC_S_SENSOR_AE_BRACKETING_LUT32:
-		ret = atomisp_do_compat_ioctl(file, cmd, arg);
-		break;
-
-	default:
-		dev_warn(isp->dev,
-			"%s: unknown ioctl '%c', dir=%d, #%d (0x%08x)\n",
-			__func__, _IOC_TYPE(cmd), _IOC_DIR(cmd), _IOC_NR(cmd),
-			cmd);
-		break;
-	}
-	return ret;
-}
-#endif /* CONFIG_COMPAT */

+ 0 - 365
drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_ioctl32.h

@@ -1,365 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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 __ATOMISP_COMPAT_IOCTL32_H__
-#define __ATOMISP_COMPAT_IOCTL32_H__
-
-#include <linux/compat.h>
-#include <linux/videodev2.h>
-
-#include "atomisp_compat.h"
-
-struct atomisp_histogram32 {
-	unsigned int num_elements;
-	compat_uptr_t data;
-};
-
-struct atomisp_dvs2_stat_types32 {
-	compat_uptr_t odd_real; /** real part of the odd statistics*/
-	compat_uptr_t odd_imag; /** imaginary part of the odd statistics*/
-	compat_uptr_t even_real;/** real part of the even statistics*/
-	compat_uptr_t even_imag;/** imaginary part of the even statistics*/
-};
-
-struct atomisp_dvs2_coef_types32 {
-	compat_uptr_t odd_real; /** real part of the odd coefficients*/
-	compat_uptr_t odd_imag; /** imaginary part of the odd coefficients*/
-	compat_uptr_t even_real;/** real part of the even coefficients*/
-	compat_uptr_t even_imag;/** imaginary part of the even coefficients*/
-};
-
-struct atomisp_dvs2_statistics32 {
-	struct atomisp_dvs_grid_info grid_info;
-	struct atomisp_dvs2_stat_types32 hor_prod;
-	struct atomisp_dvs2_stat_types32 ver_prod;
-};
-
-struct atomisp_dis_statistics32 {
-	struct atomisp_dvs2_statistics32 dvs2_stat;
-	uint32_t exp_id;
-};
-
-struct atomisp_dis_coefficients32 {
-	struct atomisp_dvs_grid_info grid_info;
-	struct atomisp_dvs2_coef_types32 hor_coefs;
-	struct atomisp_dvs2_coef_types32 ver_coefs;
-};
-
-struct atomisp_3a_statistics32 {
-	struct atomisp_grid_info  grid_info;
-	compat_uptr_t data;
-	compat_uptr_t rgby_data;
-	uint32_t exp_id;
-	uint32_t isp_config_id;
-};
-
-struct atomisp_metadata_with_type32 {
-	/* to specify which type of metadata to get */
-	enum atomisp_metadata_type type;
-	compat_uptr_t data;
-	uint32_t width;
-	uint32_t height;
-	uint32_t stride; /* in bytes */
-	uint32_t exp_id; /* exposure ID */
-	compat_uptr_t effective_width;
-};
-
-struct atomisp_metadata32 {
-	compat_uptr_t data;
-	uint32_t width;
-	uint32_t height;
-	uint32_t stride;
-	uint32_t exp_id;
-	compat_uptr_t effective_width;
-};
-
-struct atomisp_morph_table32 {
-	unsigned int enabled;
-	unsigned int height;
-	unsigned int width;	/* number of valid elements per line */
-	compat_uptr_t coordinates_x[ATOMISP_MORPH_TABLE_NUM_PLANES];
-	compat_uptr_t coordinates_y[ATOMISP_MORPH_TABLE_NUM_PLANES];
-};
-
-struct v4l2_framebuffer32 {
-	__u32			capability;
-	__u32			flags;
-	compat_uptr_t		base;
-	struct v4l2_pix_format	fmt;
-};
-
-struct atomisp_overlay32 {
-	/* the frame containing the overlay data The overlay frame width should
-	 * be the multiples of 2*ISP_VEC_NELEMS. The overlay frame height
-	 * should be the multiples of 2.
-	 */
-	compat_uptr_t frame;
-	/* Y value of overlay background */
-	unsigned char bg_y;
-	/* U value of overlay background */
-	char bg_u;
-	/* V value of overlay background */
-	char bg_v;
-	/* the blending percent of input data for Y subpixels */
-	unsigned char blend_input_perc_y;
-	/* the blending percent of input data for U subpixels */
-	unsigned char blend_input_perc_u;
-	/* the blending percent of input data for V subpixels */
-	unsigned char blend_input_perc_v;
-	/* the blending percent of overlay data for Y subpixels */
-	unsigned char blend_overlay_perc_y;
-	/* the blending percent of overlay data for U subpixels */
-	unsigned char blend_overlay_perc_u;
-	/* the blending percent of overlay data for V subpixels */
-	unsigned char blend_overlay_perc_v;
-	/* the overlay start x pixel position on output frame It should be the
-	   multiples of 2*ISP_VEC_NELEMS. */
-	unsigned int overlay_start_x;
-	/* the overlay start y pixel position on output frame It should be the
-	   multiples of 2. */
-	unsigned int overlay_start_y;
-};
-
-struct atomisp_calibration_group32 {
-	unsigned int size;
-	unsigned int type;
-	compat_uptr_t calb_grp_values;
-};
-
-struct atomisp_acc_fw_load32 {
-	unsigned int size;
-	unsigned int fw_handle;
-	compat_uptr_t data;
-};
-
-struct atomisp_acc_fw_arg32 {
-	unsigned int fw_handle;
-	unsigned int index;
-	compat_uptr_t value;
-	compat_size_t size;
-};
-
-struct v4l2_private_int_data32 {
-	__u32 size;
-	compat_uptr_t data;
-	__u32 reserved[2];
-};
-
-struct atomisp_shading_table32 {
-	__u32 enable;
-	__u32 sensor_width;
-	__u32 sensor_height;
-	__u32 width;
-	__u32 height;
-	__u32 fraction_bits;
-
-	compat_uptr_t data[ATOMISP_NUM_SC_COLORS];
-};
-
-struct atomisp_acc_map32 {
-	__u32 flags;			/* Flags, see list below */
-	__u32 length;			/* Length of data in bytes */
-	compat_uptr_t user_ptr;		/* Pointer into user space */
-	compat_ulong_t css_ptr;		/* Pointer into CSS address space */
-	__u32 reserved[4];		/* Set to zero */
-};
-
-struct atomisp_acc_s_mapped_arg32 {
-	unsigned int fw_handle;
-	__u32 memory;			/* one of enum atomisp_acc_memory */
-	compat_size_t length;
-	compat_ulong_t css_ptr;
-};
-
-struct atomisp_parameters32 {
-	compat_uptr_t wb_config;  /* White Balance config */
-	compat_uptr_t cc_config;  /* Color Correction config */
-	compat_uptr_t tnr_config; /* Temporal Noise Reduction */
-	compat_uptr_t ecd_config; /* Eigen Color Demosaicing */
-	compat_uptr_t ynr_config; /* Y(Luma) Noise Reduction */
-	compat_uptr_t fc_config;  /* Fringe Control */
-	compat_uptr_t formats_config;  /* Formats Control */
-	compat_uptr_t cnr_config; /* Chroma Noise Reduction */
-	compat_uptr_t macc_config;  /* MACC */
-	compat_uptr_t ctc_config; /* Chroma Tone Control */
-	compat_uptr_t aa_config;  /* Anti-Aliasing */
-	compat_uptr_t baa_config;  /* Anti-Aliasing */
-	compat_uptr_t ce_config;
-	compat_uptr_t dvs_6axis_config;
-	compat_uptr_t ob_config;  /* Objective Black config */
-	compat_uptr_t dp_config;  /* Dead Pixel config */
-	compat_uptr_t nr_config;  /* Noise Reduction config */
-	compat_uptr_t ee_config;  /* Edge Enhancement config */
-	compat_uptr_t de_config;  /* Demosaic config */
-	compat_uptr_t gc_config;  /* Gamma Correction config */
-	compat_uptr_t anr_config; /* Advanced Noise Reduction */
-	compat_uptr_t a3a_config; /* 3A Statistics config */
-	compat_uptr_t xnr_config; /* eXtra Noise Reduction */
-	compat_uptr_t dz_config;  /* Digital Zoom */
-	compat_uptr_t yuv2rgb_cc_config; /* Color
-							Correction config */
-	compat_uptr_t rgb2yuv_cc_config; /* Color
-							Correction config */
-	compat_uptr_t macc_table;
-	compat_uptr_t gamma_table;
-	compat_uptr_t ctc_table;
-	compat_uptr_t xnr_table;
-	compat_uptr_t r_gamma_table;
-	compat_uptr_t g_gamma_table;
-	compat_uptr_t b_gamma_table;
-	compat_uptr_t motion_vector; /* For 2-axis DVS */
-	compat_uptr_t shading_table;
-	compat_uptr_t morph_table;
-	compat_uptr_t dvs_coefs; /* DVS 1.0 coefficients */
-	compat_uptr_t dvs2_coefs; /* DVS 2.0 coefficients */
-	compat_uptr_t capture_config;
-	compat_uptr_t anr_thres;
-
-	compat_uptr_t	lin_2500_config;       /* Skylake: Linearization config */
-	compat_uptr_t	obgrid_2500_config;    /* Skylake: OBGRID config */
-	compat_uptr_t	bnr_2500_config;       /* Skylake: bayer denoise config */
-	compat_uptr_t	shd_2500_config;       /* Skylake: shading config */
-	compat_uptr_t	dm_2500_config;        /* Skylake: demosaic config */
-	compat_uptr_t	rgbpp_2500_config;     /* Skylake: RGBPP config */
-	compat_uptr_t	dvs_stat_2500_config;  /* Skylake: DVS STAT config */
-	compat_uptr_t	lace_stat_2500_config; /* Skylake: LACE STAT config */
-	compat_uptr_t	yuvp1_2500_config;     /* Skylake: yuvp1 config */
-	compat_uptr_t	yuvp2_2500_config;     /* Skylake: yuvp2 config */
-	compat_uptr_t	tnr_2500_config;       /* Skylake: TNR config */
-	compat_uptr_t	dpc_2500_config;       /* Skylake: DPC config */
-	compat_uptr_t	awb_2500_config;       /* Skylake: auto white balance config */
-	compat_uptr_t	awb_fr_2500_config;    /* Skylake: auto white balance filter response config */
-	compat_uptr_t	anr_2500_config;       /* Skylake: ANR config */
-	compat_uptr_t	af_2500_config;        /* Skylake: auto focus config */
-	compat_uptr_t	ae_2500_config;        /* Skylake: auto exposure config */
-	compat_uptr_t	bds_2500_config;       /* Skylake: bayer downscaler config */
-	compat_uptr_t	dvs_2500_config;       /* Skylake: digital video stabilization config */
-	compat_uptr_t	res_mgr_2500_config;
-
-	/*
-	 * Output frame pointer the config is to be applied to (optional),
-	 * set to NULL to make this config is applied as global.
-	 */
-	compat_uptr_t	output_frame;
-	/*
-	 * Unique ID to track which config was actually applied to a particular
-	 * frame, driver will send this id back with output frame together.
-	 */
-	uint32_t	isp_config_id;
-	uint32_t	per_frame_setting;
-};
-
-struct atomisp_acc_fw_load_to_pipe32 {
-	__u32 flags;			/* Flags, see below for valid values */
-	unsigned int fw_handle;		/* Handle, filled by kernel. */
-	__u32 size;			/* Firmware binary size */
-	compat_uptr_t data;		/* Pointer to firmware */
-	__u32 type;			/* Binary type */
-	__u32 reserved[3];		/* Set to zero */
-};
-
-struct atomisp_dvs_6axis_config32 {
-	uint32_t exp_id;
-	uint32_t width_y;
-	uint32_t height_y;
-	uint32_t width_uv;
-	uint32_t height_uv;
-	compat_uptr_t xcoords_y;
-	compat_uptr_t ycoords_y;
-	compat_uptr_t xcoords_uv;
-	compat_uptr_t ycoords_uv;
-};
-
-struct atomisp_sensor_ae_bracketing_lut32 {
-	compat_uptr_t lut;
-	unsigned int lut_size;
-};
-
-#define ATOMISP_IOC_G_HISTOGRAM32 \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 3, struct atomisp_histogram32)
-#define ATOMISP_IOC_S_HISTOGRAM32 \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 3, struct atomisp_histogram32)
-
-#define ATOMISP_IOC_G_DIS_STAT32 \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dis_statistics32)
-#define ATOMISP_IOC_S_DIS_COEFS32 \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dis_coefficients32)
-
-#define ATOMISP_IOC_S_DIS_VECTOR32 \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 6, struct atomisp_dvs_6axis_config32)
-
-#define ATOMISP_IOC_G_3A_STAT32 \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 7, struct atomisp_3a_statistics32)
-
-#define ATOMISP_IOC_G_ISP_GDC_TAB32 \
-	_IOR('v', BASE_VIDIOC_PRIVATE + 10, struct atomisp_morph_table32)
-#define ATOMISP_IOC_S_ISP_GDC_TAB32 \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 10, struct atomisp_morph_table32)
-
-#define ATOMISP_IOC_S_ISP_FPN_TABLE32 \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 17, struct v4l2_framebuffer32)
-
-#define ATOMISP_IOC_G_ISP_OVERLAY32 \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 18, struct atomisp_overlay32)
-#define ATOMISP_IOC_S_ISP_OVERLAY32 \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 18, struct atomisp_overlay32)
-
-#define ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP32 \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 22, struct atomisp_calibration_group32)
-
-#define ATOMISP_IOC_ACC_LOAD32 \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 24, struct atomisp_acc_fw_load32)
-
-#define ATOMISP_IOC_ACC_S_ARG32 \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 24, struct atomisp_acc_fw_arg32)
-
-#define ATOMISP_IOC_ACC_DESTAB32 \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 25, struct atomisp_acc_fw_arg32)
-
-#define ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA32 \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 26, struct v4l2_private_int_data32)
-
-#define ATOMISP_IOC_S_ISP_SHD_TAB32 \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 27, struct atomisp_shading_table32)
-
-#define ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA32 \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 29, struct v4l2_private_int_data32)
-
-#define ATOMISP_IOC_ACC_MAP32 \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 30, struct atomisp_acc_map32)
-
-#define ATOMISP_IOC_ACC_UNMAP32 \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 30, struct atomisp_acc_map32)
-
-#define ATOMISP_IOC_ACC_S_MAPPED_ARG32 \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 30, struct atomisp_acc_s_mapped_arg32)
-
-#define ATOMISP_IOC_ACC_LOAD_TO_PIPE32 \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 31, struct atomisp_acc_fw_load_to_pipe32)
-
-#define ATOMISP_IOC_S_PARAMETERS32 \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 32, struct atomisp_parameters32)
-
-#define ATOMISP_IOC_G_METADATA32 \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 34, struct atomisp_metadata32)
-
-#define ATOMISP_IOC_G_METADATA_BY_TYPE32 \
-	_IOWR('v', BASE_VIDIOC_PRIVATE + 34, struct atomisp_metadata_with_type32)
-
-#define ATOMISP_IOC_S_SENSOR_AE_BRACKETING_LUT32 \
-	_IOW('v', BASE_VIDIOC_PRIVATE + 43, struct atomisp_sensor_ae_bracketing_lut32)
-
-#endif /* __ATOMISP_COMPAT_IOCTL32_H__ */

+ 0 - 442
drivers/staging/media/atomisp/pci/atomisp2/atomisp_csi2.c

@@ -1,442 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- *
- */
-
-#include <media/v4l2-event.h>
-#include <media/v4l2-mediabus.h>
-#include "atomisp_cmd.h"
-#include "atomisp_internal.h"
-#include "atomisp-regs.h"
-
-static struct v4l2_mbus_framefmt *__csi2_get_format(struct
-						    atomisp_mipi_csi2_device
-						    *csi2,
-						    struct
-						    v4l2_subdev_pad_config *cfg,
-						    enum
-						    v4l2_subdev_format_whence
-						    which, unsigned int pad)
-{
-	if (which == V4L2_SUBDEV_FORMAT_TRY)
-		return v4l2_subdev_get_try_format(&csi2->subdev, cfg, pad);
-	else
-		return &csi2->formats[pad];
-}
-
-/*
- * csi2_enum_mbus_code - Handle pixel format enumeration
- * @sd     : pointer to v4l2 subdev structure
- * @fh     : V4L2 subdev file handle
- * @code   : pointer to v4l2_subdev_pad_mbus_code_enum structure
- * return -EINVAL or zero on success
-*/
-static int csi2_enum_mbus_code(struct v4l2_subdev *sd,
-			       struct v4l2_subdev_pad_config *cfg,
-			       struct v4l2_subdev_mbus_code_enum *code)
-{
-	const struct atomisp_in_fmt_conv *ic = atomisp_in_fmt_conv;
-	unsigned int i = 0;
-
-	while (ic->code) {
-		if (i == code->index) {
-			code->code = ic->code;
-			return 0;
-		}
-		i++, ic++;
-	}
-
-	return -EINVAL;
-}
-
-/*
- * csi2_get_format - Handle get format by pads subdev method
- * @sd : pointer to v4l2 subdev structure
- * @fh : V4L2 subdev file handle
- * @pad: pad num
- * @fmt: pointer to v4l2 format structure
- * return -EINVAL or zero on sucess
-*/
-static int csi2_get_format(struct v4l2_subdev *sd,
-			   struct v4l2_subdev_pad_config *cfg,
-			   struct v4l2_subdev_format *fmt)
-{
-	struct atomisp_mipi_csi2_device *csi2 = v4l2_get_subdevdata(sd);
-	struct v4l2_mbus_framefmt *format;
-
-	format = __csi2_get_format(csi2, cfg, fmt->which, fmt->pad);
-
-	fmt->format = *format;
-
-	return 0;
-}
-
-int atomisp_csi2_set_ffmt(struct v4l2_subdev *sd,
-			  struct v4l2_subdev_pad_config *cfg,
-			  unsigned int which, uint16_t pad,
-			  struct v4l2_mbus_framefmt *ffmt)
-{
-	struct atomisp_mipi_csi2_device *csi2 = v4l2_get_subdevdata(sd);
-	struct v4l2_mbus_framefmt *actual_ffmt =
-#ifndef ISP2401
-		__csi2_get_format(csi2, cfg, which, pad);
-#else
-	    __csi2_get_format(csi2, cfg, which, pad);
-#endif
-
-	if (pad == CSI2_PAD_SINK) {
-		const struct atomisp_in_fmt_conv *ic;
-		struct v4l2_mbus_framefmt tmp_ffmt;
-
-		ic = atomisp_find_in_fmt_conv(ffmt->code);
-		if (ic)
-			actual_ffmt->code = ic->code;
-		else
-			actual_ffmt->code = atomisp_in_fmt_conv[0].code;
-
-		actual_ffmt->width = clamp_t(
-			u32, ffmt->width, ATOM_ISP_MIN_WIDTH,
-			ATOM_ISP_MAX_WIDTH);
-		actual_ffmt->height = clamp_t(
-			u32, ffmt->height, ATOM_ISP_MIN_HEIGHT,
-			ATOM_ISP_MAX_HEIGHT);
-
-		tmp_ffmt = *ffmt = *actual_ffmt;
-
-		return atomisp_csi2_set_ffmt(sd, cfg, which, CSI2_PAD_SOURCE,
-					     &tmp_ffmt);
-	}
-
-	/* FIXME: DPCM decompression */
-	*actual_ffmt = *ffmt =
-#ifndef ISP2401
-		*__csi2_get_format(csi2, cfg, which, CSI2_PAD_SINK);
-#else
-	    *__csi2_get_format(csi2, cfg, which, CSI2_PAD_SINK);
-#endif
-
-	return 0;
-}
-
-/*
- * csi2_set_format - Handle set format by pads subdev method
- * @sd : pointer to v4l2 subdev structure
- * @fh : V4L2 subdev file handle
- * @pad: pad num
- * @fmt: pointer to v4l2 format structure
- * return -EINVAL or zero on success
-*/
-static int csi2_set_format(struct v4l2_subdev *sd,
-			   struct v4l2_subdev_pad_config *cfg,
-			   struct v4l2_subdev_format *fmt)
-{
-	return atomisp_csi2_set_ffmt(sd, cfg, fmt->which, fmt->pad,
-				     &fmt->format);
-}
-
-/*
- * csi2_set_stream - Enable/Disable streaming on the CSI2 module
- * @sd: ISP CSI2 V4L2 subdevice
- * @enable: Enable/disable stream (1/0)
- *
- * Return 0 on success or a negative error code otherwise.
-*/
-static int csi2_set_stream(struct v4l2_subdev *sd, int enable)
-{
-	 return 0;
-}
-
-/* subdev core operations */
-static const struct v4l2_subdev_core_ops csi2_core_ops = {
-};
-
-/* subdev video operations */
-static const struct v4l2_subdev_video_ops csi2_video_ops = {
-	.s_stream = csi2_set_stream,
-};
-
-/* subdev pad operations */
-static const struct v4l2_subdev_pad_ops csi2_pad_ops = {
-	.enum_mbus_code = csi2_enum_mbus_code,
-	.get_fmt = csi2_get_format,
-	.set_fmt = csi2_set_format,
-	.link_validate = v4l2_subdev_link_validate_default,
-};
-
-/* subdev operations */
-static const struct v4l2_subdev_ops csi2_ops = {
-	.core = &csi2_core_ops,
-	.video = &csi2_video_ops,
-	.pad = &csi2_pad_ops,
-};
-
-#ifndef ISP2401
-
-#endif
-/*
- * csi2_link_setup - Setup CSI2 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 csi2_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 atomisp_mipi_csi2_device *csi2 = v4l2_get_subdevdata(sd);
-	u32 result = local->index | is_media_entity_v4l2_subdev(remote->entity);
-
-	switch (result) {
-	case CSI2_PAD_SOURCE | MEDIA_ENT_F_OLD_BASE:
-		/* not supported yet */
-		return -EINVAL;
-
-	case CSI2_PAD_SOURCE | MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN:
-		if (flags & MEDIA_LNK_FL_ENABLED) {
-			if (csi2->output & ~CSI2_OUTPUT_ISP_SUBDEV)
-				return -EBUSY;
-			csi2->output |= CSI2_OUTPUT_ISP_SUBDEV;
-		} else {
-			csi2->output &= ~CSI2_OUTPUT_ISP_SUBDEV;
-		}
-		break;
-
-	default:
-		/* Link from camera to CSI2 is fixed... */
-		return -EINVAL;
-	}
-	return 0;
-}
-
-/* media operations */
-static const struct media_entity_operations csi2_media_ops = {
-	.link_setup = csi2_link_setup,
-	.link_validate = v4l2_subdev_link_validate,
-};
-
-/*
-* ispcsi2_init_entities - Initialize subdev and media entity.
-* @csi2: Pointer to ispcsi2 structure.
-* return -ENOMEM or zero on success
-*/
-static int mipi_csi2_init_entities(struct atomisp_mipi_csi2_device *csi2,
-					int port)
-{
-	struct v4l2_subdev *sd = &csi2->subdev;
-	struct media_pad *pads = csi2->pads;
-	struct media_entity *me = &sd->entity;
-	int ret;
-
-	v4l2_subdev_init(sd, &csi2_ops);
-	snprintf(sd->name, sizeof(sd->name), "ATOM ISP CSI2-port%d", port);
-
-	v4l2_set_subdevdata(sd, csi2);
-	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-
-	pads[CSI2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
-	pads[CSI2_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
-
-	me->ops = &csi2_media_ops;
-	me->function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
-	ret = media_entity_pads_init(me, CSI2_PADS_NUM, pads);
-	if (ret < 0)
-		return ret;
-
-	csi2->formats[CSI2_PAD_SINK].code =
-		csi2->formats[CSI2_PAD_SOURCE].code =
-		atomisp_in_fmt_conv[0].code;
-
-	return 0;
-}
-
-void
-atomisp_mipi_csi2_unregister_entities(struct atomisp_mipi_csi2_device *csi2)
-{
-	media_entity_cleanup(&csi2->subdev.entity);
-	v4l2_device_unregister_subdev(&csi2->subdev);
-}
-
-int atomisp_mipi_csi2_register_entities(struct atomisp_mipi_csi2_device *csi2,
-			struct v4l2_device *vdev)
-{
-	int ret;
-
-	/* Register the subdev and video nodes. */
-	ret = v4l2_device_register_subdev(vdev, &csi2->subdev);
-	if (ret < 0)
-		goto error;
-
-	return 0;
-
-error:
-	atomisp_mipi_csi2_unregister_entities(csi2);
-	return ret;
-}
-
-static const int LIMIT_SHIFT = 6;	/* Limit numeric range into 31 bits */
-
-static int
-atomisp_csi2_configure_calc(const short int coeffs[2], int mipi_freq, int def)
-{
-	/* Delay counter accuracy, 1/0.0625 for ANN/CHT, 1/0.125 for BXT */
-	static const int accinv = 16;		/* 1 / COUNT_ACC */
-	int r;
-
-	if (mipi_freq >> LIMIT_SHIFT <= 0)
-		return def;
-
-	r = accinv * coeffs[1] * (500000000 >> LIMIT_SHIFT);
-	r /= mipi_freq >> LIMIT_SHIFT;
-	r += accinv * coeffs[0];
-
-	return r;
-}
-
-static void atomisp_csi2_configure_isp2401(struct atomisp_sub_device *asd)
-{
-	/*
-	 * The ISP2401 new input system CSI2+ receiver has several
-	 * parameters affecting the receiver timings. These depend
-	 * on the MIPI bus frequency F in Hz (sensor transmitter rate)
-	 * as follows:
-	 *	register value = (A/1e9 + B * UI) / COUNT_ACC
-	 * where
-	 *	UI = 1 / (2 * F) in seconds
-	 *	COUNT_ACC = counter accuracy in seconds
-	 *	For ANN and CHV, COUNT_ACC = 0.0625 ns
-	 *	For BXT,  COUNT_ACC = 0.125 ns
-	 * A and B are coefficients from the table below,
-	 * depending whether the register minimum or maximum value is
-	 * calculated.
-	 *				       Minimum     Maximum
-	 * Clock lane			       A     B     A     B
-	 * reg_rx_csi_dly_cnt_termen_clane     0     0    38     0
-	 * reg_rx_csi_dly_cnt_settle_clane    95    -8   300   -16
-	 * Data lanes
-	 * reg_rx_csi_dly_cnt_termen_dlane0    0     0    35     4
-	 * reg_rx_csi_dly_cnt_settle_dlane0   85    -2   145    -6
-	 * reg_rx_csi_dly_cnt_termen_dlane1    0     0    35     4
-	 * reg_rx_csi_dly_cnt_settle_dlane1   85    -2   145    -6
-	 * reg_rx_csi_dly_cnt_termen_dlane2    0     0    35     4
-	 * reg_rx_csi_dly_cnt_settle_dlane2   85    -2   145    -6
-	 * reg_rx_csi_dly_cnt_termen_dlane3    0     0    35     4
-	 * reg_rx_csi_dly_cnt_settle_dlane3   85    -2   145    -6
-	 *
-	 * We use the minimum values in the calculations below.
-	 */
-	static const short int coeff_clk_termen[] = { 0, 0 };
-	static const short int coeff_clk_settle[] = { 95, -8 };
-	static const short int coeff_dat_termen[] = { 0, 0 };
-	static const short int coeff_dat_settle[] = { 85, -2 };
-	static const int TERMEN_DEFAULT		  = 0 * 0;
-	static const int SETTLE_DEFAULT		  = 0x480;
-	static const hrt_address csi2_port_base[] = {
-		[ATOMISP_CAMERA_PORT_PRIMARY]     = CSI2_PORT_A_BASE,
-		[ATOMISP_CAMERA_PORT_SECONDARY]   = CSI2_PORT_B_BASE,
-		[ATOMISP_CAMERA_PORT_TERTIARY]    = CSI2_PORT_C_BASE,
-	};
-	/* Number of lanes on each port, excluding clock lane */
-	static const unsigned char csi2_port_lanes[] = {
-		[ATOMISP_CAMERA_PORT_PRIMARY]     = 4,
-		[ATOMISP_CAMERA_PORT_SECONDARY]   = 2,
-		[ATOMISP_CAMERA_PORT_TERTIARY]    = 2,
-	};
-	static const hrt_address csi2_lane_base[] = {
-		CSI2_LANE_CL_BASE,
-		CSI2_LANE_D0_BASE,
-		CSI2_LANE_D1_BASE,
-		CSI2_LANE_D2_BASE,
-		CSI2_LANE_D3_BASE,
-	};
-
-	int clk_termen;
-	int clk_settle;
-	int dat_termen;
-	int dat_settle;
-
-	struct v4l2_control ctrl;
-	struct atomisp_device *isp = asd->isp;
-	struct camera_mipi_info *mipi_info;
-	int mipi_freq = 0;
-	enum atomisp_camera_port port;
-
-	int n;
-
-	mipi_info = atomisp_to_sensor_mipi_info(
-					isp->inputs[asd->input_curr].camera);
-	port = mipi_info->port;
-
-	ctrl.id = V4L2_CID_LINK_FREQ;
-	if (v4l2_g_ctrl
-	    (isp->inputs[asd->input_curr].camera->ctrl_handler, &ctrl) == 0)
-		mipi_freq = ctrl.value;
-
-	clk_termen = atomisp_csi2_configure_calc(coeff_clk_termen,
-						 mipi_freq, TERMEN_DEFAULT);
-	clk_settle = atomisp_csi2_configure_calc(coeff_clk_settle,
-						 mipi_freq, SETTLE_DEFAULT);
-	dat_termen = atomisp_csi2_configure_calc(coeff_dat_termen,
-						 mipi_freq, TERMEN_DEFAULT);
-	dat_settle = atomisp_csi2_configure_calc(coeff_dat_settle,
-						 mipi_freq, SETTLE_DEFAULT);
-	for (n = 0; n < csi2_port_lanes[port] + 1; n++) {
-		hrt_address base = csi2_port_base[port] + csi2_lane_base[n];
-		atomisp_store_uint32(base + CSI2_REG_RX_CSI_DLY_CNT_TERMEN,
-				     n == 0 ? clk_termen : dat_termen);
-		atomisp_store_uint32(base + CSI2_REG_RX_CSI_DLY_CNT_SETTLE,
-				     n == 0 ? clk_settle : dat_settle);
-	}
-}
-
-void atomisp_csi2_configure(struct atomisp_sub_device *asd)
-{
-	if (IS_HWREVISION(asd->isp, ATOMISP_HW_REVISION_ISP2401))
-		atomisp_csi2_configure_isp2401(asd);
-}
-
-/*
- * atomisp_mipi_csi2_cleanup - Routine for module driver cleanup
-*/
-void atomisp_mipi_csi2_cleanup(struct atomisp_device *isp)
-{
-}
-
-#ifndef ISP2401
-
-#endif
-int atomisp_mipi_csi2_init(struct atomisp_device *isp)
-{
-	struct atomisp_mipi_csi2_device *csi2_port;
-	unsigned int i;
-	int ret;
-
-	for (i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++) {
-		csi2_port = &isp->csi2_port[i];
-		csi2_port->isp = isp;
-		ret = mipi_csi2_init_entities(csi2_port, i);
-		if (ret < 0)
-			goto fail;
-	}
-
-	return 0;
-
-fail:
-	atomisp_mipi_csi2_cleanup(isp);
-	return ret;
-}
-

+ 0 - 57
drivers/staging/media/atomisp/pci/atomisp2/atomisp_csi2.h

@@ -1,57 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * 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 __ATOMISP_CSI2_H__
-#define __ATOMISP_CSI2_H__
-
-#include <media/v4l2-subdev.h>
-#include <media/v4l2-ctrls.h>
-
-#define CSI2_PAD_SINK		0
-#define CSI2_PAD_SOURCE		1
-#define CSI2_PADS_NUM		2
-
-#define CSI2_OUTPUT_ISP_SUBDEV	(1 << 0)
-#define CSI2_OUTPUT_MEMORY	(1 << 1)
-
-struct atomisp_device;
-struct v4l2_device;
-struct atomisp_sub_device;
-
-struct atomisp_mipi_csi2_device {
-	struct v4l2_subdev subdev;
-	struct media_pad pads[CSI2_PADS_NUM];
-	struct v4l2_mbus_framefmt formats[CSI2_PADS_NUM];
-
-	struct v4l2_ctrl_handler ctrls;
-	struct atomisp_device *isp;
-
-	u32 output; /* output direction */
-};
-
-int atomisp_csi2_set_ffmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg,
-			  unsigned int which, uint16_t pad,
-			  struct v4l2_mbus_framefmt *ffmt);
-int atomisp_mipi_csi2_init(struct atomisp_device *isp);
-void atomisp_mipi_csi2_cleanup(struct atomisp_device *isp);
-void atomisp_mipi_csi2_unregister_entities(
-					struct atomisp_mipi_csi2_device *csi2);
-int atomisp_mipi_csi2_register_entities(struct atomisp_mipi_csi2_device *csi2,
-			struct v4l2_device *vdev);
-
-void atomisp_csi2_configure(struct atomisp_sub_device *asd);
-
-#endif /* __ATOMISP_CSI2_H__ */

+ 0 - 408
drivers/staging/media/atomisp/pci/atomisp2/atomisp_dfs_tables.h

@@ -1,408 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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	__ATOMISP_DFS_TABLES_H__
-#define	__ATOMISP_DFS_TABLES_H__
-
-#include <linux/kernel.h>
-
-struct atomisp_freq_scaling_rule {
-	unsigned int width;
-	unsigned int height;
-	unsigned short fps;
-	unsigned int isp_freq;
-	unsigned int run_mode;
-};
-
-
-struct atomisp_dfs_config {
-	unsigned int lowest_freq;
-	unsigned int max_freq_at_vmin;
-	unsigned int highest_freq;
-	const struct atomisp_freq_scaling_rule *dfs_table;
-	unsigned int dfs_table_size;
-};
-
-static const struct atomisp_freq_scaling_rule dfs_rules_merr[] = {
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_VIDEO,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_STILL_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_PREVIEW,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_457MHZ,
-		.run_mode = ATOMISP_RUN_MODE_SDV,
-	},
-};
-
-/* Merrifield and Moorefield DFS rules */
-static const struct atomisp_dfs_config dfs_config_merr = {
-	.lowest_freq = ISP_FREQ_200MHZ,
-	.max_freq_at_vmin = ISP_FREQ_400MHZ,
-	.highest_freq = ISP_FREQ_457MHZ,
-	.dfs_table = dfs_rules_merr,
-	.dfs_table_size = ARRAY_SIZE(dfs_rules_merr),
-};
-
-static const struct atomisp_freq_scaling_rule dfs_rules_merr_1179[] = {
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_VIDEO,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_STILL_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_PREVIEW,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_SDV,
-	},
-};
-
-static const struct atomisp_dfs_config dfs_config_merr_1179 = {
-	.lowest_freq = ISP_FREQ_200MHZ,
-	.max_freq_at_vmin = ISP_FREQ_400MHZ,
-	.highest_freq = ISP_FREQ_400MHZ,
-	.dfs_table = dfs_rules_merr_1179,
-	.dfs_table_size = ARRAY_SIZE(dfs_rules_merr_1179),
-};
-
-static const struct atomisp_freq_scaling_rule dfs_rules_merr_117a[] = {
-	{
-		.width = 1920,
-		.height = 1080,
-		.fps = 30,
-		.isp_freq = ISP_FREQ_266MHZ,
-		.run_mode = ATOMISP_RUN_MODE_VIDEO,
-	},
-	{
-		.width = 1080,
-		.height = 1920,
-		.fps = 30,
-#ifndef ISP2401
-		.isp_freq = ISP_FREQ_266MHZ,
-#else
-		.isp_freq = ISP_FREQ_400MHZ,
-#endif
-		.run_mode = ATOMISP_RUN_MODE_VIDEO,
-	},
-	{
-		.width = 1920,
-		.height = 1080,
-		.fps = 45,
-		.isp_freq = ISP_FREQ_320MHZ,
-		.run_mode = ATOMISP_RUN_MODE_VIDEO,
-	},
-	{
-		.width = 1080,
-		.height = 1920,
-		.fps = 45,
-		.isp_freq = ISP_FREQ_320MHZ,
-		.run_mode = ATOMISP_RUN_MODE_VIDEO,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = 60,
-		.isp_freq = ISP_FREQ_356MHZ,
-		.run_mode = ATOMISP_RUN_MODE_VIDEO,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_200MHZ,
-		.run_mode = ATOMISP_RUN_MODE_VIDEO,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_STILL_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_200MHZ,
-		.run_mode = ATOMISP_RUN_MODE_PREVIEW,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_SDV,
-	},
-};
-
-static const struct atomisp_dfs_config dfs_config_merr_117a = {
-	.lowest_freq = ISP_FREQ_200MHZ,
-	.max_freq_at_vmin = ISP_FREQ_200MHZ,
-	.highest_freq = ISP_FREQ_400MHZ,
-	.dfs_table = dfs_rules_merr_117a,
-	.dfs_table_size = ARRAY_SIZE(dfs_rules_merr_117a),
-};
-
-static const struct atomisp_freq_scaling_rule dfs_rules_byt[] = {
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_VIDEO,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_STILL_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_PREVIEW,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_400MHZ,
-		.run_mode = ATOMISP_RUN_MODE_SDV,
-	},
-};
-
-static const struct atomisp_dfs_config dfs_config_byt = {
-	.lowest_freq = ISP_FREQ_200MHZ,
-	.max_freq_at_vmin = ISP_FREQ_400MHZ,
-	.highest_freq = ISP_FREQ_400MHZ,
-	.dfs_table = dfs_rules_byt,
-	.dfs_table_size = ARRAY_SIZE(dfs_rules_byt),
-};
-
-static const struct atomisp_freq_scaling_rule dfs_rules_byt_cr[] = {
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_320MHZ,
-		.run_mode = ATOMISP_RUN_MODE_VIDEO,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_320MHZ,
-		.run_mode = ATOMISP_RUN_MODE_STILL_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_320MHZ,
-		.run_mode = ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_320MHZ,
-		.run_mode = ATOMISP_RUN_MODE_PREVIEW,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_320MHZ,
-		.run_mode = ATOMISP_RUN_MODE_SDV,
-	},
-};
-
-static const struct atomisp_dfs_config dfs_config_byt_cr = {
-	.lowest_freq = ISP_FREQ_200MHZ,
-	.max_freq_at_vmin = ISP_FREQ_320MHZ,
-	.highest_freq = ISP_FREQ_320MHZ,
-	.dfs_table = dfs_rules_byt_cr,
-	.dfs_table_size = ARRAY_SIZE(dfs_rules_byt_cr),
-};
-
-static const struct atomisp_freq_scaling_rule dfs_rules_cht[] = {
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_320MHZ,
-		.run_mode = ATOMISP_RUN_MODE_VIDEO,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_356MHZ,
-		.run_mode = ATOMISP_RUN_MODE_STILL_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_320MHZ,
-		.run_mode = ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_320MHZ,
-		.run_mode = ATOMISP_RUN_MODE_PREVIEW,
-	},
-	{
-		.width = 1280,
-		.height = 720,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_320MHZ,
-		.run_mode = ATOMISP_RUN_MODE_SDV,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_356MHZ,
-		.run_mode = ATOMISP_RUN_MODE_SDV,
-	},
-};
-
-static const struct atomisp_freq_scaling_rule dfs_rules_cht_soc[] = {
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_356MHZ,
-		.run_mode = ATOMISP_RUN_MODE_VIDEO,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_356MHZ,
-		.run_mode = ATOMISP_RUN_MODE_STILL_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_320MHZ,
-		.run_mode = ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_320MHZ,
-		.run_mode = ATOMISP_RUN_MODE_PREVIEW,
-	},
-	{
-		.width = ISP_FREQ_RULE_ANY,
-		.height = ISP_FREQ_RULE_ANY,
-		.fps = ISP_FREQ_RULE_ANY,
-		.isp_freq = ISP_FREQ_356MHZ,
-		.run_mode = ATOMISP_RUN_MODE_SDV,
-	},
-};
-
-static const struct atomisp_dfs_config dfs_config_cht = {
-	.lowest_freq = ISP_FREQ_100MHZ,
-	.max_freq_at_vmin = ISP_FREQ_356MHZ,
-	.highest_freq = ISP_FREQ_356MHZ,
-	.dfs_table = dfs_rules_cht,
-	.dfs_table_size = ARRAY_SIZE(dfs_rules_cht),
-};
-
-static const struct atomisp_dfs_config dfs_config_cht_soc = {
-	.lowest_freq = ISP_FREQ_100MHZ,
-	.max_freq_at_vmin = ISP_FREQ_356MHZ,
-	.highest_freq = ISP_FREQ_356MHZ,
-	.dfs_table = dfs_rules_cht_soc,
-	.dfs_table_size = ARRAY_SIZE(dfs_rules_cht_soc),
-};
-
-#endif /* __ATOMISP_DFS_TABLES_H__ */

+ 0 - 205
drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c

@@ -1,205 +0,0 @@
-/*
- * Support for atomisp driver sysfs interface
- *
- * Copyright (c) 2014 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- *
- */
-
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/kernel.h>
-
-#include "atomisp_compat.h"
-#include "atomisp_internal.h"
-#include "atomisp_ioctl.h"
-#include "atomisp_drvfs.h"
-#include "hmm/hmm.h"
-
-/*
- * _iunit_debug:
- * dbglvl: iunit css driver trace level
- * dbgopt: iunit debug option:
- *        bit 0: binary list
- *        bit 1: running binary
- *        bit 2: memory statistic
-*/
-struct _iunit_debug {
-	struct device_driver	*drv;
-	struct atomisp_device	*isp;
-	unsigned int		dbglvl;
-	unsigned int		dbgfun;
-	unsigned int		dbgopt;
-};
-
-#define OPTION_BIN_LIST			(1<<0)
-#define OPTION_BIN_RUN			(1<<1)
-#define OPTION_MEM_STAT			(1<<2)
-#define OPTION_VALID			(OPTION_BIN_LIST \
-					| OPTION_BIN_RUN \
-					| OPTION_MEM_STAT)
-
-static struct _iunit_debug iunit_debug = {
-	.dbglvl = 0,
-	.dbgopt = OPTION_BIN_LIST,
-};
-
-static inline int iunit_dump_dbgopt(struct atomisp_device *isp,
-				unsigned int opt)
-{
-	int ret = 0;
-
-	if (opt & OPTION_VALID) {
-		if (opt & OPTION_BIN_LIST) {
-			ret = atomisp_css_dump_blob_infor();
-			if (ret) {
-				dev_err(atomisp_dev, "%s dump blob infor err[ret:%d]\n",
-					__func__, ret);
-				goto opt_err;
-			}
-		}
-
-		if (opt & OPTION_BIN_RUN) {
-			if (atomisp_streaming_count(isp)) {
-				atomisp_css_dump_sp_raw_copy_linecount(true);
-				atomisp_css_debug_dump_isp_binary();
-			} else {
-				ret = -EPERM;
-				dev_err(atomisp_dev, "%s dump running bin err[ret:%d]\n",
-					__func__, ret);
-				goto opt_err;
-			}
-		}
-
-		if (opt & OPTION_MEM_STAT)
-			hmm_show_mem_stat(__func__, __LINE__);
-	} else {
-		ret = -EINVAL;
-		dev_err(atomisp_dev, "%s dump nothing[ret=%d]\n", __func__,
-			ret);
-	}
-
-opt_err:
-	return ret;
-}
-
-static ssize_t iunit_dbglvl_show(struct device_driver *drv, char *buf)
-{
-	iunit_debug.dbglvl = atomisp_css_debug_get_dtrace_level();
-	return sprintf(buf, "dtrace level:%u\n", iunit_debug.dbglvl);
-}
-
-static ssize_t iunit_dbglvl_store(struct device_driver *drv, const char *buf,
-				size_t size)
-{
-	if (kstrtouint(buf, 10, &iunit_debug.dbglvl)
-		|| iunit_debug.dbglvl < 1
-		|| iunit_debug.dbglvl > 9) {
-		return -ERANGE;
-	}
-	atomisp_css_debug_set_dtrace_level(iunit_debug.dbglvl);
-
-	return size;
-}
-
-static ssize_t iunit_dbgfun_show(struct device_driver *drv, char *buf)
-{
-	iunit_debug.dbgfun = atomisp_get_css_dbgfunc();
-	return sprintf(buf, "dbgfun opt:%u\n", iunit_debug.dbgfun);
-}
-
-static ssize_t iunit_dbgfun_store(struct device_driver *drv, const char *buf,
-				size_t size)
-{
-	unsigned int opt;
-	int ret;
-
-	ret = kstrtouint(buf, 10, &opt);
-	if (ret)
-		return ret;
-
-	ret = atomisp_set_css_dbgfunc(iunit_debug.isp, opt);
-	if (ret)
-		return ret;
-
-	iunit_debug.dbgfun = opt;
-
-	return size;
-}
-
-static ssize_t iunit_dbgopt_show(struct device_driver *drv, char *buf)
-{
-	return sprintf(buf, "option:0x%x\n", iunit_debug.dbgopt);
-}
-
-static ssize_t iunit_dbgopt_store(struct device_driver *drv, const char *buf,
-				size_t size)
-{
-	unsigned int opt;
-	int ret;
-
-	ret = kstrtouint(buf, 10, &opt);
-	if (ret)
-		return ret;
-
-	iunit_debug.dbgopt = opt;
-	ret = iunit_dump_dbgopt(iunit_debug.isp, iunit_debug.dbgopt);
-	if (ret)
-		return ret;
-
-	return size;
-}
-
-static const struct driver_attribute iunit_drvfs_attrs[] = {
-	__ATTR(dbglvl, 0644, iunit_dbglvl_show, iunit_dbglvl_store),
-	__ATTR(dbgfun, 0644, iunit_dbgfun_show, iunit_dbgfun_store),
-	__ATTR(dbgopt, 0644, iunit_dbgopt_show, iunit_dbgopt_store),
-};
-
-static int iunit_drvfs_create_files(struct device_driver *drv)
-{
-	int i, ret = 0;
-
-	for (i = 0; i < ARRAY_SIZE(iunit_drvfs_attrs); i++)
-		ret |= driver_create_file(drv, &iunit_drvfs_attrs[i]);
-
-	return ret;
-}
-
-static void iunit_drvfs_remove_files(struct device_driver *drv)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(iunit_drvfs_attrs); i++)
-		driver_remove_file(drv, &iunit_drvfs_attrs[i]);
-}
-
-int atomisp_drvfs_init(struct device_driver *drv, struct atomisp_device *isp)
-{
-	int ret;
-
-	iunit_debug.isp = isp;
-	iunit_debug.drv = drv;
-
-	ret = iunit_drvfs_create_files(iunit_debug.drv);
-	if (ret) {
-		dev_err(atomisp_dev, "drvfs_create_files error: %d\n", ret);
-		iunit_drvfs_remove_files(iunit_debug.drv);
-	}
-
-	return ret;
-}
-
-void atomisp_drvfs_exit(void)
-{
-	iunit_drvfs_remove_files(iunit_debug.drv);
-}

+ 0 - 24
drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.h

@@ -1,24 +0,0 @@
-/*
- * Support for atomisp driver sysfs interface.
- *
- * Copyright (c) 2014 Intel Corporation. All Rights Reserved.
- *
- * 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	__ATOMISP_DRVFS_H__
-#define	__ATOMISP_DRVFS_H__
-
-int atomisp_drvfs_init(struct device_driver *drv, struct atomisp_device *isp);
-void atomisp_drvfs_exit(void);
-
-#endif /* __ATOMISP_DRVFS_H__ */

+ 0 - 225
drivers/staging/media/atomisp/pci/atomisp2/atomisp_file.c

@@ -1,225 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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.
- *
- *
- */
-
-#include <media/v4l2-event.h>
-#include <media/v4l2-mediabus.h>
-
-#include <media/videobuf-vmalloc.h>
-#include <linux/delay.h>
-
-#include "ia_css.h"
-
-#include "atomisp_cmd.h"
-#include "atomisp_common.h"
-#include "atomisp_file.h"
-#include "atomisp_internal.h"
-#include "atomisp_ioctl.h"
-
-static void file_work(struct work_struct *work)
-{
-	struct atomisp_file_device *file_dev =
-			container_of(work, struct atomisp_file_device, work);
-	struct atomisp_device *isp = file_dev->isp;
-	/* only support file injection on subdev0 */
-	struct atomisp_sub_device *asd = &isp->asd[0];
-	struct atomisp_video_pipe *out_pipe = &asd->video_in;
-	unsigned short *buf = videobuf_to_vmalloc(out_pipe->outq.bufs[0]);
-	struct v4l2_mbus_framefmt isp_sink_fmt;
-
-	if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
-		return;
-
-	dev_dbg(isp->dev, ">%s: ready to start streaming\n", __func__);
-	isp_sink_fmt = *atomisp_subdev_get_ffmt(&asd->subdev, NULL,
-						V4L2_SUBDEV_FORMAT_ACTIVE,
-						ATOMISP_SUBDEV_PAD_SINK);
-
-	while (!atomisp_css_isp_has_started())
-		usleep_range(1000, 1500);
-
-	atomisp_css_send_input_frame(asd, buf, isp_sink_fmt.width,
-				     isp_sink_fmt.height);
-	dev_dbg(isp->dev, "<%s: streaming done\n", __func__);
-}
-
-static int file_input_s_stream(struct v4l2_subdev *sd, int enable)
-{
-	struct atomisp_file_device *file_dev = v4l2_get_subdevdata(sd);
-	struct atomisp_device *isp = file_dev->isp;
-	/* only support file injection on subdev0 */
-	struct atomisp_sub_device *asd = &isp->asd[0];
-
-	dev_dbg(isp->dev, "%s: enable %d\n", __func__, enable);
-	if (enable) {
-		if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
-			return 0;
-
-		queue_work(file_dev->work_queue, &file_dev->work);
-		return 0;
-	}
-	cancel_work_sync(&file_dev->work);
-	return 0;
-}
-
-static int file_input_get_fmt(struct v4l2_subdev *sd,
-			      struct v4l2_subdev_pad_config *cfg,
-			      struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	struct atomisp_file_device *file_dev = v4l2_get_subdevdata(sd);
-	struct atomisp_device *isp = file_dev->isp;
-	/* only support file injection on subdev0 */
-	struct atomisp_sub_device *asd = &isp->asd[0];
-	struct v4l2_mbus_framefmt *isp_sink_fmt;
-	if (format->pad)
-		return -EINVAL;
-	isp_sink_fmt = atomisp_subdev_get_ffmt(&asd->subdev, NULL,
-					       V4L2_SUBDEV_FORMAT_ACTIVE,
-					       ATOMISP_SUBDEV_PAD_SINK);
-
-	fmt->width = isp_sink_fmt->width;
-	fmt->height = isp_sink_fmt->height;
-	fmt->code = isp_sink_fmt->code;
-
-	return 0;
-}
-
-static int file_input_set_fmt(struct v4l2_subdev *sd,
-			      struct v4l2_subdev_pad_config *cfg,
-			      struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-	if (format->pad)
-		return -EINVAL;
-	file_input_get_fmt(sd, cfg, format);
-	if (format->which == V4L2_SUBDEV_FORMAT_TRY)
-		cfg->try_fmt = *fmt;
-	return 0;
-}
-
-static int file_input_log_status(struct v4l2_subdev *sd)
-{
-	/*to fake*/
-	return 0;
-}
-
-static int file_input_s_power(struct v4l2_subdev *sd, int on)
-{
-	/* to fake */
-	return 0;
-}
-
-static int file_input_enum_mbus_code(struct v4l2_subdev *sd,
-				     struct v4l2_subdev_pad_config *cfg,
-				     struct v4l2_subdev_mbus_code_enum *code)
-{
-	/*to fake*/
-	return 0;
-}
-
-static int file_input_enum_frame_size(struct v4l2_subdev *sd,
-				      struct v4l2_subdev_pad_config *cfg,
-				      struct v4l2_subdev_frame_size_enum *fse)
-{
-	/*to fake*/
-	return 0;
-}
-
-static int file_input_enum_frame_ival(struct v4l2_subdev *sd,
-				      struct v4l2_subdev_pad_config *cfg,
-				      struct v4l2_subdev_frame_interval_enum
-				      *fie)
-{
-	/*to fake*/
-	return 0;
-}
-
-static const struct v4l2_subdev_video_ops file_input_video_ops = {
-	.s_stream = file_input_s_stream,
-};
-
-static const struct v4l2_subdev_core_ops file_input_core_ops = {
-	.log_status = file_input_log_status,
-	.s_power = file_input_s_power,
-};
-
-static const struct v4l2_subdev_pad_ops file_input_pad_ops = {
-	.enum_mbus_code = file_input_enum_mbus_code,
-	.enum_frame_size = file_input_enum_frame_size,
-	.enum_frame_interval = file_input_enum_frame_ival,
-	.get_fmt = file_input_get_fmt,
-	.set_fmt = file_input_set_fmt,
-};
-
-static const struct v4l2_subdev_ops file_input_ops = {
-	.core = &file_input_core_ops,
-	.video = &file_input_video_ops,
-	.pad = &file_input_pad_ops,
-};
-
-void
-atomisp_file_input_unregister_entities(struct atomisp_file_device *file_dev)
-{
-	media_entity_cleanup(&file_dev->sd.entity);
-	v4l2_device_unregister_subdev(&file_dev->sd);
-}
-
-int atomisp_file_input_register_entities(struct atomisp_file_device *file_dev,
-			struct v4l2_device *vdev)
-{
-	/* Register the subdev and video nodes. */
-	return  v4l2_device_register_subdev(vdev, &file_dev->sd);
-}
-
-void atomisp_file_input_cleanup(struct atomisp_device *isp)
-{
-	struct atomisp_file_device *file_dev = &isp->file_dev;
-
-	if (file_dev->work_queue) {
-		destroy_workqueue(file_dev->work_queue);
-		file_dev->work_queue = NULL;
-	}
-}
-
-int atomisp_file_input_init(struct atomisp_device *isp)
-{
-	struct atomisp_file_device *file_dev = &isp->file_dev;
-	struct v4l2_subdev *sd = &file_dev->sd;
-	struct media_pad *pads = file_dev->pads;
-	struct media_entity *me = &sd->entity;
-
-	file_dev->isp = isp;
-	file_dev->work_queue = alloc_workqueue(isp->v4l2_dev.name, 0, 1);
-	if (file_dev->work_queue == NULL) {
-		dev_err(isp->dev, "Failed to initialize file inject workq\n");
-		return -ENOMEM;
-	}
-
-	INIT_WORK(&file_dev->work, file_work);
-
-	v4l2_subdev_init(sd, &file_input_ops);
-	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	strcpy(sd->name, "file_input_subdev");
-	v4l2_set_subdevdata(sd, file_dev);
-
-	pads[0].flags = MEDIA_PAD_FL_SINK;
-	me->function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
-
-	return media_entity_pads_init(me, 1, pads);
-}

+ 0 - 43
drivers/staging/media/atomisp/pci/atomisp2/atomisp_file.h

@@ -1,43 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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 __ATOMISP_FILE_H__
-#define __ATOMISP_FILE_H__
-
-#include <media/media-entity.h>
-#include <media/v4l2-subdev.h>
-
-struct atomisp_device;
-
-struct atomisp_file_device {
-	struct v4l2_subdev sd;
-	struct atomisp_device *isp;
-	struct media_pad pads[1];
-
-	struct workqueue_struct *work_queue;
-	struct work_struct work;
-};
-
-void atomisp_file_input_cleanup(struct atomisp_device *isp);
-int atomisp_file_input_init(struct atomisp_device *isp);
-void atomisp_file_input_unregister_entities(
-				struct atomisp_file_device *file_dev);
-int atomisp_file_input_register_entities(struct atomisp_file_device *file_dev,
-			struct v4l2_device *vdev);
-#endif /* __ATOMISP_FILE_H__ */

+ 0 - 1302
drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c

@@ -1,1302 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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.
- *
- *
- */
-
-#include <linux/module.h>
-#include <linux/pm_runtime.h>
-
-#include <media/v4l2-ioctl.h>
-#include <media/videobuf-vmalloc.h>
-
-#include "atomisp_cmd.h"
-#include "atomisp_common.h"
-#include "atomisp_fops.h"
-#include "atomisp_internal.h"
-#include "atomisp_ioctl.h"
-#include "atomisp_compat.h"
-#include "atomisp_subdev.h"
-#include "atomisp_v4l2.h"
-#include "atomisp-regs.h"
-#include "hmm/hmm.h"
-
-#include "hrt/hive_isp_css_mm_hrt.h"
-
-#include "type_support.h"
-#include "device_access/device_access.h"
-#include "memory_access/memory_access.h"
-
-#include "atomisp_acc.h"
-
-#define ISP_LEFT_PAD			128	/* equal to 2*NWAY */
-
-/*
- * input image data, and current frame resolution for test
- */
-#define	ISP_PARAM_MMAP_OFFSET	0xfffff000
-
-#define MAGIC_CHECK(is, should)	\
-	do { \
-		if (unlikely((is) != (should))) { \
-			pr_err("magic mismatch: %x (expected %x)\n", \
-				is, should); \
-			BUG(); \
-		} \
-	} while (0)
-
-/*
- * Videobuf ops
- */
-static int atomisp_buf_setup(struct videobuf_queue *vq, unsigned int *count,
-			     unsigned int *size)
-{
-	struct atomisp_video_pipe *pipe = vq->priv_data;
-
-	*size = pipe->pix.sizeimage;
-
-	return 0;
-}
-
-static int atomisp_buf_prepare(struct videobuf_queue *vq,
-			       struct videobuf_buffer *vb,
-			       enum v4l2_field field)
-{
-	struct atomisp_video_pipe *pipe = vq->priv_data;
-
-	vb->size = pipe->pix.sizeimage;
-	vb->width = pipe->pix.width;
-	vb->height = pipe->pix.height;
-	vb->field = field;
-	vb->state = VIDEOBUF_PREPARED;
-
-	return 0;
-}
-
-static int atomisp_q_one_metadata_buffer(struct atomisp_sub_device *asd,
-		enum atomisp_input_stream_id stream_id,
-		enum atomisp_css_pipe_id css_pipe_id)
-{
-	struct atomisp_metadata_buf *metadata_buf;
-	enum atomisp_metadata_type md_type =
-			atomisp_get_metadata_type(asd, css_pipe_id);
-	struct list_head *metadata_list;
-
-	if (asd->metadata_bufs_in_css[stream_id][css_pipe_id] >=
-		ATOMISP_CSS_Q_DEPTH)
-		return 0; /* we have reached CSS queue depth */
-
-	if (!list_empty(&asd->metadata[md_type])) {
-		metadata_list = &asd->metadata[md_type];
-	} else if (!list_empty(&asd->metadata_ready[md_type])) {
-		metadata_list = &asd->metadata_ready[md_type];
-	} else {
-		dev_warn(asd->isp->dev, "%s: No metadata buffers available for type %d!\n",
-			__func__, md_type);
-		return -EINVAL;
-	}
-
-	metadata_buf = list_entry(metadata_list->next,
-				  struct atomisp_metadata_buf, list);
-	list_del_init(&metadata_buf->list);
-
-	if (atomisp_q_metadata_buffer_to_css(asd, metadata_buf,
-				stream_id, css_pipe_id)) {
-		list_add(&metadata_buf->list, metadata_list);
-		return -EINVAL;
-	} else {
-		list_add_tail(&metadata_buf->list,
-				&asd->metadata_in_css[md_type]);
-	}
-	asd->metadata_bufs_in_css[stream_id][css_pipe_id]++;
-
-	return 0;
-}
-
-static int atomisp_q_one_s3a_buffer(struct atomisp_sub_device *asd,
-				    enum atomisp_input_stream_id stream_id,
-				    enum atomisp_css_pipe_id css_pipe_id)
-{
-	struct atomisp_s3a_buf *s3a_buf;
-	struct list_head *s3a_list;
-	unsigned int exp_id;
-
-	if (asd->s3a_bufs_in_css[css_pipe_id] >= ATOMISP_CSS_Q_DEPTH)
-		return 0; /* we have reached CSS queue depth */
-
-	if (!list_empty(&asd->s3a_stats)) {
-		s3a_list = &asd->s3a_stats;
-	} else if (!list_empty(&asd->s3a_stats_ready)) {
-		s3a_list = &asd->s3a_stats_ready;
-	} else {
-		dev_warn(asd->isp->dev, "%s: No s3a buffers available!\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	s3a_buf = list_entry(s3a_list->next, struct atomisp_s3a_buf, list);
-	list_del_init(&s3a_buf->list);
-	exp_id = s3a_buf->s3a_data->exp_id;
-
-	hmm_flush_vmap(s3a_buf->s3a_data->data_ptr);
-	if (atomisp_q_s3a_buffer_to_css(asd, s3a_buf,
-					stream_id, css_pipe_id)) {
-		/* got from head, so return back to the head */
-		list_add(&s3a_buf->list, s3a_list);
-		return -EINVAL;
-	} else {
-		list_add_tail(&s3a_buf->list, &asd->s3a_stats_in_css);
-		if (s3a_list == &asd->s3a_stats_ready)
-			dev_warn(asd->isp->dev, "%s: drop one s3a stat which has exp_id %d!\n",
-				__func__, exp_id);
-	}
-
-	asd->s3a_bufs_in_css[css_pipe_id]++;
-	return 0;
-}
-
-static int atomisp_q_one_dis_buffer(struct atomisp_sub_device *asd,
-				    enum atomisp_input_stream_id stream_id,
-				    enum atomisp_css_pipe_id css_pipe_id)
-{
-	struct atomisp_dis_buf *dis_buf;
-	unsigned long irqflags;
-
-	if (asd->dis_bufs_in_css >=  ATOMISP_CSS_Q_DEPTH)
-		return 0; /* we have reached CSS queue depth */
-
-	spin_lock_irqsave(&asd->dis_stats_lock, irqflags);
-	if (list_empty(&asd->dis_stats)) {
-		spin_unlock_irqrestore(&asd->dis_stats_lock, irqflags);
-		dev_warn(asd->isp->dev, "%s: No dis buffers available!\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	dis_buf = list_entry(asd->dis_stats.prev,
-			struct atomisp_dis_buf, list);
-	list_del_init(&dis_buf->list);
-	spin_unlock_irqrestore(&asd->dis_stats_lock, irqflags);
-
-	hmm_flush_vmap(dis_buf->dis_data->data_ptr);
-	if (atomisp_q_dis_buffer_to_css(asd, dis_buf,
-					stream_id, css_pipe_id)) {
-		spin_lock_irqsave(&asd->dis_stats_lock, irqflags);
-		/* got from tail, so return back to the tail */
-		list_add_tail(&dis_buf->list, &asd->dis_stats);
-		spin_unlock_irqrestore(&asd->dis_stats_lock, irqflags);
-		return -EINVAL;
-	} else {
-		spin_lock_irqsave(&asd->dis_stats_lock, irqflags);
-		list_add_tail(&dis_buf->list, &asd->dis_stats_in_css);
-		spin_unlock_irqrestore(&asd->dis_stats_lock, irqflags);
-	}
-
-	asd->dis_bufs_in_css++;
-
-	return 0;
-}
-
-int atomisp_q_video_buffers_to_css(struct atomisp_sub_device *asd,
-			     struct atomisp_video_pipe *pipe,
-			     enum atomisp_input_stream_id stream_id,
-			     enum atomisp_css_buffer_type css_buf_type,
-			     enum atomisp_css_pipe_id css_pipe_id)
-{
-	struct videobuf_vmalloc_memory *vm_mem;
-	struct atomisp_css_params_with_list *param;
-	struct atomisp_css_dvs_grid_info *dvs_grid =
-		 atomisp_css_get_dvs_grid_info(&asd->params.curr_grid_info);
-	unsigned long irqflags;
-	int err = 0;
-
-	while (pipe->buffers_in_css < ATOMISP_CSS_Q_DEPTH) {
-		struct videobuf_buffer *vb;
-
-		spin_lock_irqsave(&pipe->irq_lock, irqflags);
-		if (list_empty(&pipe->activeq)) {
-			spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
-			return -EINVAL;
-		}
-		vb = list_entry(pipe->activeq.next,
-				struct videobuf_buffer, queue);
-		list_del_init(&vb->queue);
-		vb->state = VIDEOBUF_ACTIVE;
-		spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
-
-		/*
-		 * If there is a per_frame setting to apply on the buffer,
-		 * do it before buffer en-queueing.
-		 */
-		vm_mem = vb->priv;
-
-		param = pipe->frame_params[vb->i];
-		if (param) {
-			atomisp_makeup_css_parameters(asd,
-					&asd->params.css_param.update_flag,
-					&param->params);
-			atomisp_apply_css_parameters(asd, &param->params);
-
-			if (param->params.update_flag.dz_config &&
-				asd->run_mode->val != ATOMISP_RUN_MODE_VIDEO) {
-				err = atomisp_calculate_real_zoom_region(asd,
-					&param->params.dz_config, css_pipe_id);
-				if (!err)
-					atomisp_css_set_dz_config(asd,
-						&param->params.dz_config);
-			}
-			atomisp_css_set_isp_config_applied_frame(asd,
-						vm_mem->vaddr);
-			atomisp_css_update_isp_params_on_pipe(asd,
-				asd->stream_env[stream_id].pipes[css_pipe_id]);
-			asd->params.dvs_6axis = (struct atomisp_css_dvs_6axis *)
-				param->params.dvs_6axis;
-
-			/*
-			 * WORKAROUND:
-			 * Because the camera halv3 can't ensure to set zoom
-			 * region to per_frame setting and global setting at
-			 * same time and only set zoom region to pre_frame
-			 * setting now.so when the pre_frame setting inculde
-			 * zoom region,I will set it to global setting.
-			 */
-			if (param->params.update_flag.dz_config &&
-				asd->run_mode->val != ATOMISP_RUN_MODE_VIDEO
-				&& !err) {
-				memcpy(&asd->params.css_param.dz_config,
-					&param->params.dz_config,
-					sizeof(struct ia_css_dz_config));
-				asd->params.css_param.update_flag.dz_config =
-					(struct atomisp_dz_config *)
-					&asd->params.css_param.dz_config;
-				asd->params.css_update_params_needed = true;
-			}
-		}
-		/* Enqueue buffer */
-		err = atomisp_q_video_buffer_to_css(asd, vm_mem, stream_id,
-						css_buf_type, css_pipe_id);
-		if (err) {
-			spin_lock_irqsave(&pipe->irq_lock, irqflags);
-			list_add_tail(&vb->queue, &pipe->activeq);
-			vb->state = VIDEOBUF_QUEUED;
-			spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
-			dev_err(asd->isp->dev, "%s, css q fails: %d\n",
-					__func__, err);
-			return -EINVAL;
-		}
-		pipe->buffers_in_css++;
-
-		/* enqueue 3A/DIS/metadata buffers */
-		if (asd->params.curr_grid_info.s3a_grid.enable &&
-			css_pipe_id == asd->params.s3a_enabled_pipe &&
-			css_buf_type == CSS_BUFFER_TYPE_OUTPUT_FRAME)
-			atomisp_q_one_s3a_buffer(asd, stream_id,
-						css_pipe_id);
-
-		if (asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream_info.
-				metadata_info.size &&
-			css_buf_type == CSS_BUFFER_TYPE_OUTPUT_FRAME)
-			atomisp_q_one_metadata_buffer(asd, stream_id,
-						css_pipe_id);
-
-		if (dvs_grid && dvs_grid->enable &&
-			css_pipe_id == CSS_PIPE_ID_VIDEO &&
-			css_buf_type == CSS_BUFFER_TYPE_OUTPUT_FRAME)
-			atomisp_q_one_dis_buffer(asd, stream_id,
-						css_pipe_id);
-	}
-
-	return 0;
-}
-
-static int atomisp_get_css_buf_type(struct atomisp_sub_device *asd,
-				    enum atomisp_css_pipe_id pipe_id,
-				    uint16_t source_pad)
-{
-	if (ATOMISP_USE_YUVPP(asd)) {
-		/* when run ZSL case */
-		if (asd->continuous_mode->val &&
-			asd->run_mode->val == ATOMISP_RUN_MODE_PREVIEW) {
-			if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE)
-				return CSS_BUFFER_TYPE_OUTPUT_FRAME;
-			else if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW)
-				return CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME;
-			else
-				return CSS_BUFFER_TYPE_VF_OUTPUT_FRAME;
-		}
-
-		/*when run SDV case*/
-		if (asd->continuous_mode->val &&
-			asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) {
-			if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE)
-				return CSS_BUFFER_TYPE_OUTPUT_FRAME;
-			else if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW)
-				return CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME;
-			else if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_VIDEO)
-				return CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME;
-			else
-				return CSS_BUFFER_TYPE_VF_OUTPUT_FRAME;
-		}
-
-		/*other case: default setting*/
-		if (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE ||
-		    source_pad == ATOMISP_SUBDEV_PAD_SOURCE_VIDEO ||
-		    (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW &&
-		     asd->run_mode->val != ATOMISP_RUN_MODE_VIDEO))
-			return CSS_BUFFER_TYPE_OUTPUT_FRAME;
-		else
-			return CSS_BUFFER_TYPE_VF_OUTPUT_FRAME;
-	}
-
-	if (pipe_id == CSS_PIPE_ID_COPY ||
-	    source_pad == ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE ||
-	    source_pad == ATOMISP_SUBDEV_PAD_SOURCE_VIDEO ||
-	    (source_pad == ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW &&
-	     asd->run_mode->val != ATOMISP_RUN_MODE_VIDEO))
-		return CSS_BUFFER_TYPE_OUTPUT_FRAME;
-	else
-		return CSS_BUFFER_TYPE_VF_OUTPUT_FRAME;
-}
-
-static int atomisp_qbuffers_to_css_for_all_pipes(struct atomisp_sub_device *asd)
-{
-	enum atomisp_css_buffer_type buf_type;
-	enum atomisp_css_pipe_id css_capture_pipe_id = CSS_PIPE_ID_COPY;
-	enum atomisp_css_pipe_id css_preview_pipe_id = CSS_PIPE_ID_COPY;
-	enum atomisp_css_pipe_id css_video_pipe_id = CSS_PIPE_ID_COPY;
-	enum atomisp_input_stream_id input_stream_id;
-	struct atomisp_video_pipe *capture_pipe;
-	struct atomisp_video_pipe *preview_pipe;
-	struct atomisp_video_pipe *video_pipe;
-
-	capture_pipe = &asd->video_out_capture;
-	preview_pipe = &asd->video_out_preview;
-	video_pipe = &asd->video_out_video_capture;
-
-	buf_type = atomisp_get_css_buf_type(
-			asd, css_preview_pipe_id,
-			atomisp_subdev_source_pad(&preview_pipe->vdev));
-	input_stream_id = ATOMISP_INPUT_STREAM_PREVIEW;
-	atomisp_q_video_buffers_to_css(asd, preview_pipe,
-				       input_stream_id,
-				       buf_type, css_preview_pipe_id);
-
-	buf_type = atomisp_get_css_buf_type(asd, css_capture_pipe_id,
-			atomisp_subdev_source_pad(&capture_pipe->vdev));
-	input_stream_id = ATOMISP_INPUT_STREAM_GENERAL;
-	atomisp_q_video_buffers_to_css(asd, capture_pipe,
-					       input_stream_id,
-					       buf_type, css_capture_pipe_id);
-
-	buf_type = atomisp_get_css_buf_type(asd, css_video_pipe_id,
-			atomisp_subdev_source_pad(&video_pipe->vdev));
-	input_stream_id = ATOMISP_INPUT_STREAM_VIDEO;
-	atomisp_q_video_buffers_to_css(asd, video_pipe,
-					       input_stream_id,
-					       buf_type, css_video_pipe_id);
-	return 0;
-}
-
-
-/* queue all available buffers to css */
-int atomisp_qbuffers_to_css(struct atomisp_sub_device *asd)
-{
-	enum atomisp_css_buffer_type buf_type;
-	enum atomisp_css_pipe_id css_capture_pipe_id = CSS_PIPE_ID_NUM;
-	enum atomisp_css_pipe_id css_preview_pipe_id = CSS_PIPE_ID_NUM;
-	enum atomisp_css_pipe_id css_video_pipe_id = CSS_PIPE_ID_NUM;
-	enum atomisp_input_stream_id input_stream_id;
-	struct atomisp_video_pipe *capture_pipe = NULL;
-	struct atomisp_video_pipe *vf_pipe = NULL;
-	struct atomisp_video_pipe *preview_pipe = NULL;
-	struct atomisp_video_pipe *video_pipe = NULL;
-	bool raw_mode = atomisp_is_mbuscode_raw(
-			    asd->fmt[asd->capture_pad].fmt.code);
-
-	if (asd->isp->inputs[asd->input_curr].camera_caps->
-	    sensor[asd->sensor_curr].stream_num == 2 &&
-	    !asd->yuvpp_mode)
-		return atomisp_qbuffers_to_css_for_all_pipes(asd);
-
-	if (asd->vfpp->val == ATOMISP_VFPP_DISABLE_SCALER) {
-		video_pipe = &asd->video_out_video_capture;
-		css_video_pipe_id = CSS_PIPE_ID_VIDEO;
-	} else if (asd->vfpp->val == ATOMISP_VFPP_DISABLE_LOWLAT) {
-		preview_pipe = &asd->video_out_capture;
-		css_preview_pipe_id = CSS_PIPE_ID_CAPTURE;
-	} else if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) {
-		if (asd->continuous_mode->val) {
-			capture_pipe = &asd->video_out_capture;
-			vf_pipe = &asd->video_out_vf;
-			css_capture_pipe_id = CSS_PIPE_ID_CAPTURE;
-		}
-		video_pipe = &asd->video_out_video_capture;
-		preview_pipe = &asd->video_out_preview;
-		css_video_pipe_id = CSS_PIPE_ID_VIDEO;
-		css_preview_pipe_id = CSS_PIPE_ID_VIDEO;
-	} else if (asd->continuous_mode->val) {
-		capture_pipe = &asd->video_out_capture;
-		vf_pipe = &asd->video_out_vf;
-		preview_pipe = &asd->video_out_preview;
-
-		css_preview_pipe_id = CSS_PIPE_ID_PREVIEW;
-		css_capture_pipe_id = CSS_PIPE_ID_CAPTURE;
-	} else if (asd->run_mode->val == ATOMISP_RUN_MODE_PREVIEW) {
-		preview_pipe = &asd->video_out_preview;
-		css_preview_pipe_id = CSS_PIPE_ID_PREVIEW;
-	} else {
-		/* ATOMISP_RUN_MODE_STILL_CAPTURE */
-		capture_pipe = &asd->video_out_capture;
-		if (!raw_mode)
-			vf_pipe = &asd->video_out_vf;
-		css_capture_pipe_id = CSS_PIPE_ID_CAPTURE;
-	}
-
-#ifdef ISP2401_NEW_INPUT_SYSTEM
-	if (asd->copy_mode) {
-		css_capture_pipe_id = CSS_PIPE_ID_COPY;
-		css_preview_pipe_id = CSS_PIPE_ID_COPY;
-		css_video_pipe_id = CSS_PIPE_ID_COPY;
-	}
-#endif
-
-	if (asd->yuvpp_mode) {
-		capture_pipe = &asd->video_out_capture;
-		video_pipe   = &asd->video_out_video_capture;
-		preview_pipe = &asd->video_out_preview;
-		css_capture_pipe_id = CSS_PIPE_ID_COPY;
-		css_video_pipe_id   = CSS_PIPE_ID_YUVPP;
-		css_preview_pipe_id = CSS_PIPE_ID_YUVPP;
-	}
-
-	if (capture_pipe) {
-		buf_type = atomisp_get_css_buf_type(
-			asd, css_capture_pipe_id,
-			atomisp_subdev_source_pad(&capture_pipe->vdev));
-		input_stream_id = ATOMISP_INPUT_STREAM_GENERAL;
-
-		/*
-		 * use yuvpp pipe for SOC camera.
-		 */
-		if (ATOMISP_USE_YUVPP(asd))
-			css_capture_pipe_id = CSS_PIPE_ID_YUVPP;
-
-		atomisp_q_video_buffers_to_css(asd, capture_pipe,
-					       input_stream_id,
-					       buf_type, css_capture_pipe_id);
-	}
-
-	if (vf_pipe) {
-		buf_type = atomisp_get_css_buf_type(
-			asd, css_capture_pipe_id,
-			atomisp_subdev_source_pad(&vf_pipe->vdev));
-		if (asd->stream_env[ATOMISP_INPUT_STREAM_POSTVIEW].stream)
-			input_stream_id = ATOMISP_INPUT_STREAM_POSTVIEW;
-		else
-			input_stream_id = ATOMISP_INPUT_STREAM_GENERAL;
-
-		/*
-		 * use yuvpp pipe for SOC camera.
-		 */
-		if (ATOMISP_USE_YUVPP(asd))
-			css_capture_pipe_id = CSS_PIPE_ID_YUVPP;
-		atomisp_q_video_buffers_to_css(asd, vf_pipe,
-					       input_stream_id,
-					       buf_type, css_capture_pipe_id);
-	}
-
-	if (preview_pipe) {
-		buf_type = atomisp_get_css_buf_type(
-			asd, css_preview_pipe_id,
-			atomisp_subdev_source_pad(&preview_pipe->vdev));
-		if (ATOMISP_SOC_CAMERA(asd) && css_preview_pipe_id == CSS_PIPE_ID_YUVPP)
-			input_stream_id = ATOMISP_INPUT_STREAM_GENERAL;
-		 /* else for ext isp use case */
-		else if (css_preview_pipe_id == CSS_PIPE_ID_YUVPP)
-			input_stream_id = ATOMISP_INPUT_STREAM_VIDEO;
-		else if (asd->stream_env[ATOMISP_INPUT_STREAM_PREVIEW].stream)
-			input_stream_id = ATOMISP_INPUT_STREAM_PREVIEW;
-		else
-			input_stream_id = ATOMISP_INPUT_STREAM_GENERAL;
-
-		/*
-		 * use yuvpp pipe for SOC camera.
-		 */
-		if (ATOMISP_USE_YUVPP(asd))
-			css_preview_pipe_id = CSS_PIPE_ID_YUVPP;
-
-		atomisp_q_video_buffers_to_css(asd, preview_pipe,
-					       input_stream_id,
-					       buf_type, css_preview_pipe_id);
-	}
-
-	if (video_pipe) {
-		buf_type = atomisp_get_css_buf_type(
-			asd, css_video_pipe_id,
-			atomisp_subdev_source_pad(&video_pipe->vdev));
-		if (asd->stream_env[ATOMISP_INPUT_STREAM_VIDEO].stream)
-			input_stream_id = ATOMISP_INPUT_STREAM_VIDEO;
-		else
-			input_stream_id = ATOMISP_INPUT_STREAM_GENERAL;
-
-		/*
-		 * use yuvpp pipe for SOC camera.
-		 */
-		if (ATOMISP_USE_YUVPP(asd))
-			css_video_pipe_id = CSS_PIPE_ID_YUVPP;
-
-		atomisp_q_video_buffers_to_css(asd, video_pipe,
-					       input_stream_id,
-					       buf_type, css_video_pipe_id);
-	}
-
-	return 0;
-}
-
-static void atomisp_buf_queue(struct videobuf_queue *vq,
-			      struct videobuf_buffer *vb)
-{
-	struct atomisp_video_pipe *pipe = vq->priv_data;
-
-	/*
-	 * when a frame buffer meets following conditions, it should be put into
-	 * the waiting list:
-	 * 1.  It is not a main output frame, and it has a per-frame parameter
-	 *     to go with it.
-	 * 2.  It is not a main output frame, and the waiting buffer list is not
-	 *     empty, to keep the FIFO sequence of frame buffer processing, it
-	 *     is put to waiting list until previous per-frame parameter buffers
-	 *     get enqueued.
-	 */
-	if (!atomisp_is_vf_pipe(pipe) &&
-	    (pipe->frame_request_config_id[vb->i] ||
-	     !list_empty(&pipe->buffers_waiting_for_param)))
-		list_add_tail(&vb->queue, &pipe->buffers_waiting_for_param);
-	else
-		list_add_tail(&vb->queue, &pipe->activeq);
-
-	vb->state = VIDEOBUF_QUEUED;
-}
-
-static void atomisp_buf_release(struct videobuf_queue *vq,
-				struct videobuf_buffer *vb)
-{
-	vb->state = VIDEOBUF_NEEDS_INIT;
-	atomisp_videobuf_free_buf(vb);
-}
-
-static int atomisp_buf_setup_output(struct videobuf_queue *vq,
-				    unsigned int *count, unsigned int *size)
-{
-	struct atomisp_video_pipe *pipe = vq->priv_data;
-
-	*size = pipe->pix.sizeimage;
-
-	return 0;
-}
-
-static int atomisp_buf_prepare_output(struct videobuf_queue *vq,
-				      struct videobuf_buffer *vb,
-				      enum v4l2_field field)
-{
-	struct atomisp_video_pipe *pipe = vq->priv_data;
-
-	vb->size = pipe->pix.sizeimage;
-	vb->width = pipe->pix.width;
-	vb->height = pipe->pix.height;
-	vb->field = field;
-	vb->state = VIDEOBUF_PREPARED;
-
-	return 0;
-}
-
-static void atomisp_buf_queue_output(struct videobuf_queue *vq,
-				     struct videobuf_buffer *vb)
-{
-	struct atomisp_video_pipe *pipe = vq->priv_data;
-
-	list_add_tail(&vb->queue, &pipe->activeq_out);
-	vb->state = VIDEOBUF_QUEUED;
-}
-
-static void atomisp_buf_release_output(struct videobuf_queue *vq,
-				       struct videobuf_buffer *vb)
-{
-	videobuf_vmalloc_free(vb);
-	vb->state = VIDEOBUF_NEEDS_INIT;
-}
-
-static const struct videobuf_queue_ops videobuf_qops = {
-	.buf_setup	= atomisp_buf_setup,
-	.buf_prepare	= atomisp_buf_prepare,
-	.buf_queue	= atomisp_buf_queue,
-	.buf_release	= atomisp_buf_release,
-};
-
-static const struct videobuf_queue_ops videobuf_qops_output = {
-	.buf_setup	= atomisp_buf_setup_output,
-	.buf_prepare	= atomisp_buf_prepare_output,
-	.buf_queue	= atomisp_buf_queue_output,
-	.buf_release	= atomisp_buf_release_output,
-};
-
-static int atomisp_init_pipe(struct atomisp_video_pipe *pipe)
-{
-	/* init locks */
-	spin_lock_init(&pipe->irq_lock);
-
-	videobuf_queue_vmalloc_init(&pipe->capq, &videobuf_qops, NULL,
-				    &pipe->irq_lock,
-				    V4L2_BUF_TYPE_VIDEO_CAPTURE,
-				    V4L2_FIELD_NONE,
-				    sizeof(struct atomisp_buffer), pipe,
-				    NULL);	/* ext_lock: NULL */
-
-	videobuf_queue_vmalloc_init(&pipe->outq, &videobuf_qops_output, NULL,
-				    &pipe->irq_lock,
-				    V4L2_BUF_TYPE_VIDEO_OUTPUT,
-				    V4L2_FIELD_NONE,
-				    sizeof(struct atomisp_buffer), pipe,
-				    NULL);	/* ext_lock: NULL */
-
-	INIT_LIST_HEAD(&pipe->activeq);
-	INIT_LIST_HEAD(&pipe->activeq_out);
-	INIT_LIST_HEAD(&pipe->buffers_waiting_for_param);
-	INIT_LIST_HEAD(&pipe->per_frame_params);
-	memset(pipe->frame_request_config_id, 0,
-		VIDEO_MAX_FRAME * sizeof(unsigned int));
-	memset(pipe->frame_params, 0,
-		VIDEO_MAX_FRAME *
-		sizeof(struct atomisp_css_params_with_list *));
-
-	return 0;
-}
-
-static void atomisp_dev_init_struct(struct atomisp_device *isp)
-{
-	unsigned int i;
-
-	isp->sw_contex.file_input = false;
-	isp->need_gfx_throttle = true;
-	isp->isp_fatal_error = false;
-	isp->mipi_frame_size = 0;
-
-	for (i = 0; i < isp->input_cnt; i++)
-		isp->inputs[i].asd = NULL;
-	/*
-	 * For Merrifield, frequency is scalable.
-	 * After boot-up, the default frequency is 200MHz.
-	 */
-	isp->sw_contex.running_freq = ISP_FREQ_200MHZ;
-}
-
-static void atomisp_subdev_init_struct(struct atomisp_sub_device *asd)
-{
-	v4l2_ctrl_s_ctrl(asd->run_mode, ATOMISP_RUN_MODE_STILL_CAPTURE);
-	memset(&asd->params.css_param, 0, sizeof(asd->params.css_param));
-	asd->params.color_effect = V4L2_COLORFX_NONE;
-	asd->params.bad_pixel_en = true;
-	asd->params.gdc_cac_en = false;
-	asd->params.video_dis_en = false;
-	asd->params.sc_en = false;
-	asd->params.fpn_en = false;
-	asd->params.xnr_en = false;
-	asd->params.false_color = 0;
-	asd->params.online_process = 1;
-	asd->params.yuv_ds_en = 0;
-	/* s3a grid not enabled for any pipe */
-	asd->params.s3a_enabled_pipe = CSS_PIPE_ID_NUM;
-
-	asd->params.offline_parm.num_captures = 1;
-	asd->params.offline_parm.skip_frames = 0;
-	asd->params.offline_parm.offset = 0;
-	asd->delayed_init = ATOMISP_DELAYED_INIT_NOT_QUEUED;
-	/* Add for channel */
-	asd->input_curr = 0;
-
-	asd->mipi_frame_size = 0;
-	asd->copy_mode = false;
-	asd->yuvpp_mode = false;
-
-	asd->stream_prepared = false;
-	asd->high_speed_mode = false;
-	asd->sensor_array_res.height = 0;
-	asd->sensor_array_res.width = 0;
-	atomisp_css_init_struct(asd);
-}
-/*
- * file operation functions
- */
-static unsigned int atomisp_subdev_users(struct atomisp_sub_device *asd)
-{
-	return asd->video_out_preview.users +
-	       asd->video_out_vf.users +
-	       asd->video_out_capture.users +
-	       asd->video_out_video_capture.users +
-	       asd->video_acc.users +
-	       asd->video_in.users;
-}
-
-unsigned int atomisp_dev_users(struct atomisp_device *isp)
-{
-	unsigned int i, sum;
-	for (i = 0, sum = 0; i < isp->num_of_streams; i++)
-		sum += atomisp_subdev_users(&isp->asd[i]);
-
-	return sum;
-}
-
-static int atomisp_open(struct file *file)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_video_pipe *pipe = NULL;
-	struct atomisp_acc_pipe *acc_pipe = NULL;
-	struct atomisp_sub_device *asd;
-	bool acc_node = false;
-	int ret;
-
-	dev_dbg(isp->dev, "open device %s\n", vdev->name);
-
-	rt_mutex_lock(&isp->mutex);
-
-	acc_node = !strcmp(vdev->name, "ATOMISP ISP ACC");
-	if (acc_node) {
-		acc_pipe = atomisp_to_acc_pipe(vdev);
-		asd = acc_pipe->asd;
-	} else {
-		pipe = atomisp_to_video_pipe(vdev);
-		asd = pipe->asd;
-	}
-	asd->subdev.devnode = vdev;
-	/* Deferred firmware loading case. */
-	if (isp->css_env.isp_css_fw.bytes == 0) {
-		isp->firmware = atomisp_load_firmware(isp);
-		if (!isp->firmware) {
-			dev_err(isp->dev, "Failed to load ISP firmware.\n");
-			ret = -ENOENT;
-			goto error;
-		}
-		ret = atomisp_css_load_firmware(isp);
-		if (ret) {
-			dev_err(isp->dev, "Failed to init css.\n");
-			goto error;
-		}
-		/* No need to keep FW in memory anymore. */
-		release_firmware(isp->firmware);
-		isp->firmware = NULL;
-		isp->css_env.isp_css_fw.data = NULL;
-	}
-
-	if (acc_node && acc_pipe->users) {
-		dev_dbg(isp->dev, "acc node already opened\n");
-		rt_mutex_unlock(&isp->mutex);
-		return -EBUSY;
-	} else if (acc_node) {
-		goto dev_init;
-	}
-
-	if (!isp->input_cnt) {
-		dev_err(isp->dev, "no camera attached\n");
-		ret = -EINVAL;
-		goto error;
-	}
-
-	/*
-	 * atomisp does not allow multiple open
-	 */
-	if (pipe->users) {
-		dev_dbg(isp->dev, "video node already opened\n");
-		rt_mutex_unlock(&isp->mutex);
-		return -EBUSY;
-	}
-
-	ret = atomisp_init_pipe(pipe);
-	if (ret)
-		goto error;
-
-dev_init:
-	if (atomisp_dev_users(isp)) {
-		dev_dbg(isp->dev, "skip init isp in open\n");
-		goto init_subdev;
-	}
-
-	/* runtime power management, turn on ISP */
-	ret = pm_runtime_get_sync(vdev->v4l2_dev->dev);
-	if (ret < 0) {
-		dev_err(isp->dev, "Failed to power on device\n");
-		goto error;
-	}
-
-	if (dypool_enable) {
-		ret = hmm_pool_register(dypool_pgnr, HMM_POOL_TYPE_DYNAMIC);
-		if (ret)
-			dev_err(isp->dev, "Failed to register dynamic memory pool.\n");
-	}
-
-	/* Init ISP */
-	if (atomisp_css_init(isp)) {
-		ret = -EINVAL;
-		/* Need to clean up CSS init if it fails. */
-		goto css_error;
-	}
-
-	atomisp_dev_init_struct(isp);
-
-	ret = v4l2_subdev_call(isp->flash, core, s_power, 1);
-	if (ret < 0 && ret != -ENODEV && ret != -ENOIOCTLCMD) {
-		dev_err(isp->dev, "Failed to power-on flash\n");
-		goto css_error;
-	}
-
-init_subdev:
-	if (atomisp_subdev_users(asd))
-		goto done;
-
-	atomisp_subdev_init_struct(asd);
-
-done:
-
-	if (acc_node)
-		acc_pipe->users++;
-	else
-		pipe->users++;
-	rt_mutex_unlock(&isp->mutex);
-	return 0;
-
-css_error:
-	atomisp_css_uninit(isp);
-error:
-	hmm_pool_unregister(HMM_POOL_TYPE_DYNAMIC);
-	pm_runtime_put(vdev->v4l2_dev->dev);
-	rt_mutex_unlock(&isp->mutex);
-	return ret;
-}
-
-static int atomisp_release(struct file *file)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_video_pipe *pipe;
-	struct atomisp_acc_pipe *acc_pipe;
-	struct atomisp_sub_device *asd;
-	bool acc_node;
-	struct v4l2_requestbuffers req;
-	struct v4l2_subdev_fh fh;
-	struct v4l2_rect clear_compose = {0};
-	int ret = 0;
-
-	v4l2_fh_init(&fh.vfh, vdev);
-
-	req.count = 0;
-	if (isp == NULL)
-		return -EBADF;
-
-	mutex_lock(&isp->streamoff_mutex);
-	rt_mutex_lock(&isp->mutex);
-
-	dev_dbg(isp->dev, "release device %s\n", vdev->name);
-	acc_node = !strcmp(vdev->name, "ATOMISP ISP ACC");
-	if (acc_node) {
-		acc_pipe = atomisp_to_acc_pipe(vdev);
-		asd = acc_pipe->asd;
-	} else {
-		pipe = atomisp_to_video_pipe(vdev);
-		asd = pipe->asd;
-	}
-	asd->subdev.devnode = vdev;
-	if (acc_node) {
-		acc_pipe->users--;
-		goto subdev_uninit;
-	}
-	pipe->users--;
-
-	if (pipe->capq.streaming)
-		dev_warn(isp->dev,
-				"%s: ISP still streaming while closing!",
-				__func__);
-
-	if (pipe->capq.streaming &&
-	    __atomisp_streamoff(file, NULL, V4L2_BUF_TYPE_VIDEO_CAPTURE)) {
-		dev_err(isp->dev,
-			"atomisp_streamoff failed on release, driver bug");
-		goto done;
-	}
-
-	if (pipe->users)
-		goto done;
-
-	if (__atomisp_reqbufs(file, NULL, &req)) {
-		dev_err(isp->dev,
-			"atomisp_reqbufs failed on release, driver bug");
-		goto done;
-	}
-
-	if (pipe->outq.bufs[0]) {
-		mutex_lock(&pipe->outq.vb_lock);
-		videobuf_queue_cancel(&pipe->outq);
-		mutex_unlock(&pipe->outq.vb_lock);
-	}
-
-	/*
-	 * A little trick here:
-	 * file injection input resolution is recorded in the sink pad,
-	 * therefore can not be cleared when releaseing one device node.
-	 * The sink pad setting can only be cleared when all device nodes
-	 * get released.
-	 */
-	if (!isp->sw_contex.file_input && asd->fmt_auto->val) {
-		struct v4l2_mbus_framefmt isp_sink_fmt = { 0 };
-		atomisp_subdev_set_ffmt(&asd->subdev, fh.pad,
-					V4L2_SUBDEV_FORMAT_ACTIVE,
-					ATOMISP_SUBDEV_PAD_SINK, &isp_sink_fmt);
-	}
-subdev_uninit:
-	if (atomisp_subdev_users(asd))
-		goto done;
-
-	/* clear the sink pad for file input */
-	if (isp->sw_contex.file_input && asd->fmt_auto->val) {
-		struct v4l2_mbus_framefmt isp_sink_fmt = { 0 };
-		atomisp_subdev_set_ffmt(&asd->subdev, fh.pad,
-					V4L2_SUBDEV_FORMAT_ACTIVE,
-					ATOMISP_SUBDEV_PAD_SINK, &isp_sink_fmt);
-	}
-
-	atomisp_css_free_stat_buffers(asd);
-	atomisp_free_internal_buffers(asd);
-	ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-				       core, s_power, 0);
-	if (ret)
-		dev_warn(isp->dev, "Failed to power-off sensor\n");
-
-	/* clear the asd field to show this camera is not used */
-	isp->inputs[asd->input_curr].asd = NULL;
-	asd->streaming = ATOMISP_DEVICE_STREAMING_DISABLED;
-
-	if (atomisp_dev_users(isp))
-		goto done;
-
-	atomisp_acc_release(asd);
-
-	atomisp_destroy_pipes_stream_force(asd);
-	atomisp_css_uninit(isp);
-
-	if (defer_fw_load) {
-		atomisp_css_unload_firmware(isp);
-		isp->css_env.isp_css_fw.data = NULL;
-		isp->css_env.isp_css_fw.bytes = 0;
-	}
-
-	hmm_pool_unregister(HMM_POOL_TYPE_DYNAMIC);
-
-	ret = v4l2_subdev_call(isp->flash, core, s_power, 0);
-	if (ret < 0 && ret != -ENODEV && ret != -ENOIOCTLCMD)
-		dev_warn(isp->dev, "Failed to power-off flash\n");
-
-	if (pm_runtime_put_sync(vdev->v4l2_dev->dev) < 0)
-		dev_err(isp->dev, "Failed to power off device\n");
-
-done:
-	if (!acc_node) {
-		atomisp_subdev_set_selection(&asd->subdev, fh.pad,
-				V4L2_SUBDEV_FORMAT_ACTIVE,
-				atomisp_subdev_source_pad(vdev),
-				V4L2_SEL_TGT_COMPOSE, 0,
-				&clear_compose);
-	}
-	rt_mutex_unlock(&isp->mutex);
-	mutex_unlock(&isp->streamoff_mutex);
-
-	return 0;
-}
-
-/*
- * Memory help functions for image frame and private parameters
- */
-static int do_isp_mm_remap(struct atomisp_device *isp,
-			   struct vm_area_struct *vma,
-			   ia_css_ptr isp_virt, u32 host_virt, u32 pgnr)
-{
-	u32 pfn;
-
-	while (pgnr) {
-		pfn = hmm_virt_to_phys(isp_virt) >> PAGE_SHIFT;
-		if (remap_pfn_range(vma, host_virt, pfn,
-				    PAGE_SIZE, PAGE_SHARED)) {
-			dev_err(isp->dev, "remap_pfn_range err.\n");
-			return -EAGAIN;
-		}
-
-		isp_virt += PAGE_SIZE;
-		host_virt += PAGE_SIZE;
-		pgnr--;
-	}
-
-	return 0;
-}
-
-static int frame_mmap(struct atomisp_device *isp,
-	const struct atomisp_css_frame *frame, struct vm_area_struct *vma)
-{
-	ia_css_ptr isp_virt;
-	u32 host_virt;
-	u32 pgnr;
-
-	if (!frame) {
-		dev_err(isp->dev, "%s: NULL frame pointer.\n", __func__);
-		return -EINVAL;
-	}
-
-	host_virt = vma->vm_start;
-	isp_virt = frame->data;
-	atomisp_get_frame_pgnr(isp, frame, &pgnr);
-
-	if (do_isp_mm_remap(isp, vma, isp_virt, host_virt, pgnr))
-		return -EAGAIN;
-
-	return 0;
-}
-
-int atomisp_videobuf_mmap_mapper(struct videobuf_queue *q,
-	struct vm_area_struct *vma)
-{
-	u32 offset = vma->vm_pgoff << PAGE_SHIFT;
-	int ret = -EINVAL, i;
-	struct atomisp_device *isp =
-		((struct atomisp_video_pipe *)(q->priv_data))->isp;
-	struct videobuf_vmalloc_memory *vm_mem;
-	struct videobuf_mapping *map;
-
-	MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
-	if (!(vma->vm_flags & VM_WRITE) || !(vma->vm_flags & VM_SHARED)) {
-		dev_err(isp->dev, "map appl bug: PROT_WRITE and MAP_SHARED are required\n");
-		return -EINVAL;
-	}
-
-	mutex_lock(&q->vb_lock);
-	for (i = 0; i < VIDEO_MAX_FRAME; i++) {
-		struct videobuf_buffer *buf = q->bufs[i];
-		if (buf == NULL)
-			continue;
-
-		map = kzalloc(sizeof(struct videobuf_mapping), GFP_KERNEL);
-		if (!map) {
-			mutex_unlock(&q->vb_lock);
-			return -ENOMEM;
-		}
-
-		buf->map = map;
-		map->q = q;
-
-		buf->baddr = vma->vm_start;
-
-		if (buf && buf->memory == V4L2_MEMORY_MMAP &&
-		    buf->boff == offset) {
-			vm_mem = buf->priv;
-			ret = frame_mmap(isp, vm_mem->vaddr, vma);
-			vma->vm_flags |= VM_IO|VM_DONTEXPAND|VM_DONTDUMP;
-			break;
-		}
-	}
-	mutex_unlock(&q->vb_lock);
-
-	return ret;
-}
-
-/* The input frame contains left and right padding that need to be removed.
- * There is always ISP_LEFT_PAD padding on the left side.
- * There is also padding on the right (padded_width - width).
- */
-static int remove_pad_from_frame(struct atomisp_device *isp,
-		struct atomisp_css_frame *in_frame, __u32 width, __u32 height)
-{
-	unsigned int i;
-	unsigned short *buffer;
-	int ret = 0;
-	ia_css_ptr load = in_frame->data;
-	ia_css_ptr store = load;
-
-	buffer = kmalloc(width*sizeof(load), GFP_KERNEL);
-	if (!buffer)
-		return -ENOMEM;
-
-	load += ISP_LEFT_PAD;
-	for (i = 0; i < height; i++) {
-		ret = hmm_load(load, buffer, width*sizeof(load));
-		if (ret < 0)
-			goto remove_pad_error;
-
-		ret = hmm_store(store, buffer, width*sizeof(store));
-		if (ret < 0)
-			goto remove_pad_error;
-
-		load  += in_frame->info.padded_width;
-		store += width;
-	}
-
-remove_pad_error:
-	kfree(buffer);
-	return ret;
-}
-
-static int atomisp_mmap(struct file *file, struct vm_area_struct *vma)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-	struct atomisp_sub_device *asd = pipe->asd;
-	struct atomisp_css_frame *raw_virt_addr;
-	u32 start = vma->vm_start;
-	u32 end = vma->vm_end;
-	u32 size = end - start;
-	u32 origin_size, new_size;
-	int ret;
-
-	if (!(vma->vm_flags & (VM_WRITE | VM_READ)))
-		return -EACCES;
-
-	rt_mutex_lock(&isp->mutex);
-
-	if (!(vma->vm_flags & VM_SHARED)) {
-		/* Map private buffer.
-		 * Set VM_SHARED to the flags since we need
-		 * to map the buffer page by page.
-		 * Without VM_SHARED, remap_pfn_range() treats
-		 * this kind of mapping as invalid.
-		 */
-		vma->vm_flags |= VM_SHARED;
-		ret = hmm_mmap(vma, vma->vm_pgoff << PAGE_SHIFT);
-		rt_mutex_unlock(&isp->mutex);
-		return ret;
-	}
-
-	/* mmap for ISP offline raw data */
-	if (atomisp_subdev_source_pad(vdev)
-	    == ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE &&
-	    vma->vm_pgoff == (ISP_PARAM_MMAP_OFFSET >> PAGE_SHIFT)) {
-		new_size = pipe->pix.width * pipe->pix.height * 2;
-		if (asd->params.online_process != 0) {
-			ret = -EINVAL;
-			goto error;
-		}
-		raw_virt_addr = asd->raw_output_frame;
-		if (raw_virt_addr == NULL) {
-			dev_err(isp->dev, "Failed to request RAW frame\n");
-			ret = -EINVAL;
-			goto error;
-		}
-
-		ret = remove_pad_from_frame(isp, raw_virt_addr,
-				      pipe->pix.width, pipe->pix.height);
-		if (ret < 0) {
-			dev_err(isp->dev, "remove pad failed.\n");
-			goto error;
-		}
-		origin_size = raw_virt_addr->data_bytes;
-		raw_virt_addr->data_bytes = new_size;
-
-		if (size != PAGE_ALIGN(new_size)) {
-			dev_err(isp->dev, "incorrect size for mmap ISP  Raw Frame\n");
-			ret = -EINVAL;
-			goto error;
-		}
-
-		if (frame_mmap(isp, raw_virt_addr, vma)) {
-			dev_err(isp->dev, "frame_mmap failed.\n");
-			raw_virt_addr->data_bytes = origin_size;
-			ret = -EAGAIN;
-			goto error;
-		}
-		raw_virt_addr->data_bytes = origin_size;
-		vma->vm_flags |= VM_IO|VM_DONTEXPAND|VM_DONTDUMP;
-		rt_mutex_unlock(&isp->mutex);
-		return 0;
-	}
-
-	/*
-	 * mmap for normal frames
-	 */
-	if (size != pipe->pix.sizeimage) {
-		dev_err(isp->dev, "incorrect size for mmap ISP frames\n");
-		ret = -EINVAL;
-		goto error;
-	}
-	rt_mutex_unlock(&isp->mutex);
-
-	return atomisp_videobuf_mmap_mapper(&pipe->capq, vma);
-
-error:
-	rt_mutex_unlock(&isp->mutex);
-
-	return ret;
-}
-
-static int atomisp_file_mmap(struct file *file, struct vm_area_struct *vma)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-
-	return videobuf_mmap_mapper(&pipe->outq, vma);
-}
-
-static __poll_t atomisp_poll(struct file *file,
-				 struct poll_table_struct *pt)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-
-	rt_mutex_lock(&isp->mutex);
-	if (pipe->capq.streaming != 1) {
-		rt_mutex_unlock(&isp->mutex);
-		return EPOLLERR;
-	}
-	rt_mutex_unlock(&isp->mutex);
-
-	return videobuf_poll_stream(file, &pipe->capq, pt);
-}
-
-const struct v4l2_file_operations atomisp_fops = {
-	.owner = THIS_MODULE,
-	.open = atomisp_open,
-	.release = atomisp_release,
-	.mmap = atomisp_mmap,
-	.unlocked_ioctl = video_ioctl2,
-#ifdef CONFIG_COMPAT
-	/*
-	 * There are problems with this code. Disable this for now.
-	.compat_ioctl32 = atomisp_compat_ioctl32,
-	 */
-#endif
-	.poll = atomisp_poll,
-};
-
-const struct v4l2_file_operations atomisp_file_fops = {
-	.owner = THIS_MODULE,
-	.open = atomisp_open,
-	.release = atomisp_release,
-	.mmap = atomisp_file_mmap,
-	.unlocked_ioctl = video_ioctl2,
-#ifdef CONFIG_COMPAT
-	/*
-	 * There are problems with this code. Disable this for now.
-	.compat_ioctl32 = atomisp_compat_ioctl32,
-	 */
-#endif
-	.poll = atomisp_poll,
-};
-

+ 0 - 50
drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.h

@@ -1,50 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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	__ATOMISP_FOPS_H__
-#define	__ATOMISP_FOPS_H__
-#include "atomisp_subdev.h"
-
-int atomisp_q_video_buffers_to_css(struct atomisp_sub_device *asd,
-			     struct atomisp_video_pipe *pipe,
-			     enum atomisp_input_stream_id stream_id,
-			     enum atomisp_css_buffer_type css_buf_type,
-			     enum atomisp_css_pipe_id css_pipe_id);
-
-unsigned int atomisp_dev_users(struct atomisp_device *isp);
-unsigned int atomisp_sub_dev_users(struct atomisp_sub_device *asd);
-
-/*
- * Memory help functions for image frame and private parameters
- */
-
-int atomisp_videobuf_mmap_mapper(struct videobuf_queue *q,
-				     struct vm_area_struct *vma);
-
-int atomisp_qbuf_to_css(struct atomisp_device *isp,
-			struct atomisp_video_pipe *pipe,
-			struct videobuf_buffer *vb);
-
-int atomisp_qbuffers_to_css(struct atomisp_sub_device *asd);
-
-extern const struct v4l2_file_operations atomisp_fops;
-
-extern bool defer_fw_load;
-
-#endif /* __ATOMISP_FOPS_H__ */

+ 0 - 29
drivers/staging/media/atomisp/pci/atomisp2/atomisp_helper.h

@@ -1,29 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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 _atomisp_helper_h_
-#define _atomisp_helper_h_
-extern void __iomem *atomisp_io_base;
-
-static inline void __iomem *atomisp_get_io_virt_addr(unsigned int address)
-{
-	void __iomem *ret = atomisp_io_base + (address & 0x003FFFFF);
-	return ret;
-}
-#endif
-

+ 0 - 310
drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h

@@ -1,310 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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 __ATOMISP_INTERNAL_H__
-#define __ATOMISP_INTERNAL_H__
-
-#include "../../include/linux/atomisp_platform.h"
-#include <linux/firmware.h>
-#include <linux/kernel.h>
-#include <linux/pm_qos.h>
-#include <linux/idr.h>
-
-#include <media/media-device.h>
-#include <media/v4l2-subdev.h>
-
-#ifndef ISP2401
-#include "ia_css_types.h"
-#include "sh_css_legacy.h"
-#else
-/*#include "ia_css_types.h"*/
-/*#include "sh_css_legacy.h"*/
-#endif
-
-#include "atomisp_csi2.h"
-#include "atomisp_file.h"
-#include "atomisp_subdev.h"
-#include "atomisp_tpg.h"
-#include "atomisp_compat.h"
-
-#include "gp_device.h"
-#include "irq.h"
-#include <linux/vmalloc.h>
-
-#define V4L2_EVENT_FRAME_END          5
-
-#define IS_HWREVISION(isp, rev) \
-	(((isp)->media_dev.hw_revision & ATOMISP_HW_REVISION_MASK) == \
-	 ((rev) << ATOMISP_HW_REVISION_SHIFT))
-
-#define MAX_STREAM_NUM	2
-
-#define ATOMISP_PCI_DEVICE_SOC_MASK	0xfff8
-/* MRFLD with 0x1178: ISP freq can burst to 457MHz */
-#define ATOMISP_PCI_DEVICE_SOC_MRFLD	0x1178
-/* MRFLD with 0x1179: max ISP freq limited to 400MHz */
-#define ATOMISP_PCI_DEVICE_SOC_MRFLD_1179	0x1179
-/* MRFLD with 0x117a: max ISP freq is 400MHz and max freq at Vmin is 200MHz */
-#define ATOMISP_PCI_DEVICE_SOC_MRFLD_117A	0x117a
-#define ATOMISP_PCI_DEVICE_SOC_BYT	0x0f38
-#define ATOMISP_PCI_DEVICE_SOC_ANN	0x1478
-#define ATOMISP_PCI_DEVICE_SOC_CHT	0x22b8
-
-#define ATOMISP_PCI_REV_MRFLD_A0_MAX	0
-#define ATOMISP_PCI_REV_BYT_A0_MAX	4
-
-#define ATOM_ISP_STEP_WIDTH	2
-#define ATOM_ISP_STEP_HEIGHT	2
-
-#define ATOM_ISP_MIN_WIDTH	4
-#define ATOM_ISP_MIN_HEIGHT	4
-#define ATOM_ISP_MAX_WIDTH	UINT_MAX
-#define ATOM_ISP_MAX_HEIGHT	UINT_MAX
-
-/* sub-QCIF resolution */
-#define ATOM_RESOLUTION_SUBQCIF_WIDTH	128
-#define ATOM_RESOLUTION_SUBQCIF_HEIGHT	96
-
-#define ATOM_ISP_MAX_WIDTH_TMP	1280
-#define ATOM_ISP_MAX_HEIGHT_TMP	720
-
-#define ATOM_ISP_I2C_BUS_1	4
-#define ATOM_ISP_I2C_BUS_2	5
-
-#define ATOM_ISP_POWER_DOWN	0
-#define ATOM_ISP_POWER_UP	1
-
-#define ATOM_ISP_MAX_INPUTS	4
-
-#define ATOMISP_SC_TYPE_SIZE	2
-
-#define ATOMISP_ISP_TIMEOUT_DURATION		(2 * HZ)
-#define ATOMISP_EXT_ISP_TIMEOUT_DURATION        (6 * HZ)
-#define ATOMISP_ISP_FILE_TIMEOUT_DURATION	(60 * HZ)
-#define ATOMISP_WDT_KEEP_CURRENT_DELAY          0
-#define ATOMISP_ISP_MAX_TIMEOUT_COUNT	2
-#define ATOMISP_CSS_STOP_TIMEOUT_US	200000
-
-#define ATOMISP_CSS_Q_DEPTH	3
-#define ATOMISP_CSS_EVENTS_MAX  16
-#define ATOMISP_CONT_RAW_FRAMES 15
-#define ATOMISP_METADATA_QUEUE_DEPTH_FOR_HAL	8
-#define ATOMISP_S3A_BUF_QUEUE_DEPTH_FOR_HAL	8
-
-#define ATOMISP_DELAYED_INIT_NOT_QUEUED	0
-#define ATOMISP_DELAYED_INIT_QUEUED	1
-#define ATOMISP_DELAYED_INIT_DONE	2
-
-#define ATOMISP_CALC_CSS_PREV_OVERLAP(lines) \
-	((lines) * 38 / 100 & 0xfffffe)
-
-/*
- * Define how fast CPU should be able to serve ISP interrupts.
- * The bigger the value, the higher risk that the ISP is not
- * triggered sufficiently fast for it to process image during
- * vertical blanking time, increasing risk of dropped frames.
- * 1000 us is a reasonable value considering that the processing
- * time is typically ~2000 us.
- */
-#define ATOMISP_MAX_ISR_LATENCY	1000
-
-/* Add new YUVPP pipe for SOC sensor. */
-#define ATOMISP_CSS_SUPPORT_YUVPP     1
-
-#define ATOMISP_CSS_OUTPUT_SECOND_INDEX     1
-#define ATOMISP_CSS_OUTPUT_DEFAULT_INDEX    0
-
-/*
- * ATOMISP_SOC_CAMERA
- * This is to differentiate between ext-isp and soc camera in
- * Moorefield/Baytrail platform.
- */
-#define ATOMISP_SOC_CAMERA(asd)  \
-	(asd->isp->inputs[asd->input_curr].type == SOC_CAMERA \
-	&& asd->isp->inputs[asd->input_curr].camera_caps-> \
-	   sensor[asd->sensor_curr].stream_num == 1)
-
-#define ATOMISP_USE_YUVPP(asd)  \
-	(ATOMISP_SOC_CAMERA(asd) && ATOMISP_CSS_SUPPORT_YUVPP && \
-	!asd->copy_mode)
-
-#define ATOMISP_DEPTH_SENSOR_STREAMON_COUNT 2
-
-#define ATOMISP_DEPTH_DEFAULT_MASTER_SENSOR 0
-#define ATOMISP_DEPTH_DEFAULT_SLAVE_SENSOR 1
-
-#ifdef ISP2401
-#define ATOMISP_ION_DEVICE_FD_OFFSET   16
-#define ATOMISP_ION_SHARED_FD_MASK     (0xFFFF)
-#define ATOMISP_ION_DEVICE_FD_MASK     (~ATOMISP_ION_SHARED_FD_MASK)
-#define ION_FD_UNSET (-1)
-
-#endif
-#define DIV_NEAREST_STEP(n, d, step) \
-	round_down((2 * (n) + (d) * (step))/(2 * (d)), (step))
-
-struct atomisp_input_subdev {
-	unsigned int type;
-	enum atomisp_camera_port port;
-	struct v4l2_subdev *camera;
-	struct v4l2_subdev *motor;
-	struct v4l2_frmsizeenum frame_size;
-
-	/*
-	 * To show this resource is used by
-	 * which stream, in ISP multiple stream mode
-	 */
-	struct atomisp_sub_device *asd;
-
-	const struct atomisp_camera_caps *camera_caps;
-	int sensor_index;
-};
-
-enum atomisp_dfs_mode {
-	ATOMISP_DFS_MODE_AUTO = 0,
-	ATOMISP_DFS_MODE_LOW,
-	ATOMISP_DFS_MODE_MAX,
-};
-
-struct atomisp_regs {
-	/* PCI config space info */
-	u16 pcicmdsts;
-	u32 ispmmadr;
-	u32 msicap;
-	u32 msi_addr;
-	u16 msi_data;
-	u8 intr;
-	u32 interrupt_control;
-	u32 pmcs;
-	u32 cg_dis;
-	u32 i_control;
-
-	/* I-Unit PHY related info */
-	u32 csi_rcomp_config;
-	u32 csi_afe_dly;
-	u32 csi_control;
-
-	/* New for MRFLD */
-	u32 csi_afe_rcomp_config;
-	u32 csi_afe_hs_control;
-	u32 csi_deadline_control;
-	u32 csi_access_viol;
-};
-
-struct atomisp_sw_contex {
-	bool file_input;
-	int power_state;
-	int running_freq;
-};
-
-
-#define ATOMISP_DEVICE_STREAMING_DISABLED	0
-#define ATOMISP_DEVICE_STREAMING_ENABLED	1
-#define ATOMISP_DEVICE_STREAMING_STOPPING	2
-
-/*
- * ci device struct
- */
-struct atomisp_device {
-	struct pci_dev *pdev;
-	struct device *dev;
-	struct v4l2_device v4l2_dev;
-	struct media_device media_dev;
-	struct atomisp_platform_data *pdata;
-	void *mmu_l1_base;
-	const struct firmware *firmware;
-
-	struct pm_qos_request pm_qos;
-	s32 max_isr_latency;
-
-	/*
-	 * ISP modules
-	 * Multiple streams are represents by multiple
-	 * atomisp_sub_device instances
-	 */
-	struct atomisp_sub_device *asd;
-	/*
-	 * this will be assiged dyanamically.
-	 * For Merr/BTY(ISP2400), 2 streams are supported.
-	 */
-	unsigned int num_of_streams;
-
-	struct atomisp_mipi_csi2_device csi2_port[ATOMISP_CAMERA_NR_PORTS];
-	struct atomisp_tpg_device tpg;
-	struct atomisp_file_device file_dev;
-
-	/* Purpose of mutex is to protect and serialize use of isp data
-	 * structures and css API calls. */
-	struct rt_mutex mutex;
-	/*
-	 * Serialise streamoff: mutex is dropped during streamoff to
-	 * cancel the watchdog queue. MUST be acquired BEFORE
-	 * "mutex".
-	 */
-	struct mutex streamoff_mutex;
-
-	unsigned int input_cnt;
-	struct atomisp_input_subdev inputs[ATOM_ISP_MAX_INPUTS];
-	struct v4l2_subdev *flash;
-	struct v4l2_subdev *motor;
-
-	struct atomisp_regs saved_regs;
-	struct atomisp_sw_contex sw_contex;
-	struct atomisp_css_env css_env;
-
-	/* isp timeout status flag */
-	bool isp_timeout;
-	bool isp_fatal_error;
-	struct workqueue_struct *wdt_work_queue;
-	struct work_struct wdt_work;
-#ifndef ISP2401
-	atomic_t wdt_count;
-#endif
-	atomic_t wdt_work_queued;
-
-	spinlock_t lock; /* Just for streaming below */
-
-	bool need_gfx_throttle;
-
-	unsigned int mipi_frame_size;
-	const struct atomisp_dfs_config *dfs;
-	unsigned int hpll_freq;
-
-	bool css_initialized;
-};
-
-#define v4l2_dev_to_atomisp_device(dev) \
-	container_of(dev, struct atomisp_device, v4l2_dev)
-
-extern struct device *atomisp_dev;
-
-#define atomisp_is_wdt_running(a) timer_pending(&(a)->wdt)
-#ifdef ISP2401
-extern void atomisp_wdt_refresh_pipe(struct atomisp_video_pipe *pipe,
-					unsigned int delay);
-#endif
-extern void atomisp_wdt_refresh(struct atomisp_sub_device *asd, unsigned int delay);
-#ifndef ISP2401
-extern void atomisp_wdt_start(struct atomisp_sub_device *asd);
-#else
-extern void atomisp_wdt_start(struct atomisp_video_pipe *pipe);
-extern void atomisp_wdt_stop_pipe(struct atomisp_video_pipe *pipe, bool sync);
-#endif
-extern void atomisp_wdt_stop(struct atomisp_sub_device *asd, bool sync);
-
-#endif /* __ATOMISP_INTERNAL_H__ */

+ 0 - 3123
drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.c

@@ -1,3123 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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.
- *
- *
- */
-
-#include <linux/delay.h>
-#include <linux/pci.h>
-
-
-#include <media/v4l2-ioctl.h>
-#include <media/v4l2-event.h>
-#include <media/videobuf-vmalloc.h>
-
-#include "atomisp_acc.h"
-#include "atomisp_cmd.h"
-#include "atomisp_common.h"
-#include "atomisp_fops.h"
-#include "atomisp_internal.h"
-#include "atomisp_ioctl.h"
-#include "atomisp-regs.h"
-#include "atomisp_compat.h"
-
-#include "sh_css_hrt.h"
-
-#include "gp_device.h"
-#include "device_access.h"
-#include "irq.h"
-
-#include "hrt/hive_isp_css_mm_hrt.h"
-
-/* for v4l2_capability */
-static const char *DRIVER = "atomisp";	/* max size 15 */
-static const char *CARD = "ATOM ISP";	/* max size 31 */
-static const char *BUS_INFO = "PCI-3";	/* max size 31 */
-
-/*
- * FIXME: ISP should not know beforehand all CIDs supported by sensor.
- * Instead, it needs to propagate to sensor unkonwn CIDs.
- */
-static struct v4l2_queryctrl ci_v4l2_controls[] = {
-	{
-		.id = V4L2_CID_AUTO_WHITE_BALANCE,
-		.type = V4L2_CTRL_TYPE_BOOLEAN,
-		.name = "Automatic White Balance",
-		.minimum = 0,
-		.maximum = 1,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_RED_BALANCE,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Red Balance",
-		.minimum = 0x00,
-		.maximum = 0xff,
-		.step = 1,
-		.default_value = 0x00,
-	},
-	{
-		.id = V4L2_CID_BLUE_BALANCE,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Blue Balance",
-		.minimum = 0x00,
-		.maximum = 0xff,
-		.step = 1,
-		.default_value = 0x00,
-	},
-	{
-		.id = V4L2_CID_GAMMA,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Gamma",
-		.minimum = 0x00,
-		.maximum = 0xff,
-		.step = 1,
-		.default_value = 0x00,
-	},
-	{
-		.id = V4L2_CID_POWER_LINE_FREQUENCY,
-		.type = V4L2_CTRL_TYPE_MENU,
-		.name = "Light frequency filter",
-		.minimum = 1,
-		.maximum = 2,
-		.step = 1,
-		.default_value = 1,
-	},
-	{
-		.id = V4L2_CID_COLORFX,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Image Color Effect",
-		.minimum = 0,
-		.maximum = 9,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_COLORFX_CBCR,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Image Color Effect CbCr",
-		.minimum = 0,
-		.maximum = 0xffff,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_ATOMISP_BAD_PIXEL_DETECTION,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Bad Pixel Correction",
-		.minimum = 0,
-		.maximum = 1,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_ATOMISP_POSTPROCESS_GDC_CAC,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "GDC/CAC",
-		.minimum = 0,
-		.maximum = 1,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_ATOMISP_VIDEO_STABLIZATION,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Video Stablization",
-		.minimum = 0,
-		.maximum = 1,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_ATOMISP_FIXED_PATTERN_NR,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Fixed Pattern Noise Reduction",
-		.minimum = 0,
-		.maximum = 1,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_ATOMISP_FALSE_COLOR_CORRECTION,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "False Color Correction",
-		.minimum = 0,
-		.maximum = 1,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_REQUEST_FLASH,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Request flash frames",
-		.minimum = 0,
-		.maximum = 10,
-		.step = 1,
-		.default_value = 1,
-	},
-	{
-		.id = V4L2_CID_ATOMISP_LOW_LIGHT,
-		.type = V4L2_CTRL_TYPE_BOOLEAN,
-		.name = "Low light mode",
-		.minimum = 0,
-		.maximum = 1,
-		.step = 1,
-		.default_value = 1,
-	},
-	{
-		.id = V4L2_CID_BIN_FACTOR_HORZ,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Horizontal binning factor",
-		.minimum = 0,
-		.maximum = 10,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_BIN_FACTOR_VERT,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Vertical binning factor",
-		.minimum = 0,
-		.maximum = 10,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_2A_STATUS,
-		.type = V4L2_CTRL_TYPE_BITMASK,
-		.name = "AE and AWB status",
-		.minimum = 0,
-		.maximum = V4L2_2A_STATUS_AE_READY | V4L2_2A_STATUS_AWB_READY,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_EXPOSURE,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "exposure",
-		.minimum = -4,
-		.maximum = 4,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_EXPOSURE_ZONE_NUM,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "one-time exposure zone number",
-		.minimum = 0x0,
-		.maximum = 0xffff,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_EXPOSURE_AUTO_PRIORITY,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Exposure auto priority",
-		.minimum = V4L2_EXPOSURE_AUTO,
-		.maximum = V4L2_EXPOSURE_APERTURE_PRIORITY,
-		.step = 1,
-		.default_value = V4L2_EXPOSURE_AUTO,
-	},
-	{
-		.id = V4L2_CID_SCENE_MODE,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "scene mode",
-		.minimum = 0,
-		.maximum = 13,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_ISO_SENSITIVITY,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "iso",
-		.minimum = -4,
-		.maximum = 4,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_ISO_SENSITIVITY_AUTO,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "iso mode",
-		.minimum = V4L2_ISO_SENSITIVITY_MANUAL,
-		.maximum = V4L2_ISO_SENSITIVITY_AUTO,
-		.step = 1,
-		.default_value = V4L2_ISO_SENSITIVITY_AUTO,
-	},
-	{
-		.id = V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "white balance",
-		.minimum = 0,
-		.maximum = 9,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_EXPOSURE_METERING,
-		.type = V4L2_CTRL_TYPE_MENU,
-		.name = "metering",
-		.minimum = 0,
-		.maximum = 3,
-		.step = 1,
-		.default_value = 1,
-	},
-	{
-		.id = V4L2_CID_3A_LOCK,
-		.type = V4L2_CTRL_TYPE_BITMASK,
-		.name = "3a lock",
-		.minimum = 0,
-		.maximum = V4L2_LOCK_EXPOSURE | V4L2_LOCK_WHITE_BALANCE
-			 | V4L2_LOCK_FOCUS,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_TEST_PATTERN,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Test Pattern",
-		.minimum = 0,
-		.maximum = 0xffff,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_TEST_PATTERN_COLOR_R,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Test Pattern Solid Color R",
-		.minimum = INT_MIN,
-		.maximum = INT_MAX,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_TEST_PATTERN_COLOR_GR,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Test Pattern Solid Color GR",
-		.minimum = INT_MIN,
-		.maximum = INT_MAX,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_TEST_PATTERN_COLOR_GB,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Test Pattern Solid Color GB",
-		.minimum = INT_MIN,
-		.maximum = INT_MAX,
-		.step = 1,
-		.default_value = 0,
-	},
-	{
-		.id = V4L2_CID_TEST_PATTERN_COLOR_B,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Test Pattern Solid Color B",
-		.minimum = INT_MIN,
-		.maximum = INT_MAX,
-		.step = 1,
-		.default_value = 0,
-	},
-};
-static const u32 ctrls_num = ARRAY_SIZE(ci_v4l2_controls);
-
-/*
- * supported V4L2 fmts and resolutions
- */
-const struct atomisp_format_bridge atomisp_output_fmts[] = {
-	{
-		.pixelformat = V4L2_PIX_FMT_YUV420,
-		.depth = 12,
-		.mbus_code = V4L2_MBUS_FMT_CUSTOM_YUV420,
-		.sh_fmt = CSS_FRAME_FORMAT_YUV420,
-		.description = "YUV420, planar",
-		.planar = true
-	}, {
-		.pixelformat = V4L2_PIX_FMT_YVU420,
-		.depth = 12,
-		.mbus_code = V4L2_MBUS_FMT_CUSTOM_YVU420,
-		.sh_fmt = CSS_FRAME_FORMAT_YV12,
-		.description = "YVU420, planar",
-		.planar = true
-	}, {
-		.pixelformat = V4L2_PIX_FMT_YUV422P,
-		.depth = 16,
-		.mbus_code = V4L2_MBUS_FMT_CUSTOM_YUV422P,
-		.sh_fmt = CSS_FRAME_FORMAT_YUV422,
-		.description = "YUV422, planar",
-		.planar = true
-	}, {
-		.pixelformat = V4L2_PIX_FMT_YUV444,
-		.depth = 24,
-		.mbus_code = V4L2_MBUS_FMT_CUSTOM_YUV444,
-		.sh_fmt = CSS_FRAME_FORMAT_YUV444,
-		.description = "YUV444"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_NV12,
-		.depth = 12,
-		.mbus_code = V4L2_MBUS_FMT_CUSTOM_NV12,
-		.sh_fmt = CSS_FRAME_FORMAT_NV12,
-		.description = "NV12, Y-plane, CbCr interleaved",
-		.planar = true
-	}, {
-		.pixelformat = V4L2_PIX_FMT_NV21,
-		.depth = 12,
-		.mbus_code = V4L2_MBUS_FMT_CUSTOM_NV21,
-		.sh_fmt = CSS_FRAME_FORMAT_NV21,
-		.description = "NV21, Y-plane, CbCr interleaved",
-		.planar = true
-	}, {
-		.pixelformat = V4L2_PIX_FMT_NV16,
-		.depth = 16,
-		.mbus_code = V4L2_MBUS_FMT_CUSTOM_NV16,
-		.sh_fmt = CSS_FRAME_FORMAT_NV16,
-		.description = "NV16, Y-plane, CbCr interleaved",
-		.planar = true
-	}, {
-		.pixelformat = V4L2_PIX_FMT_YUYV,
-		.depth = 16,
-		.mbus_code = V4L2_MBUS_FMT_CUSTOM_YUYV,
-		.sh_fmt = CSS_FRAME_FORMAT_YUYV,
-		.description = "YUYV, interleaved"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_UYVY,
-		.depth = 16,
-		.mbus_code = MEDIA_BUS_FMT_UYVY8_1X16,
-		.sh_fmt = CSS_FRAME_FORMAT_UYVY,
-		.description = "UYVY, interleaved"
-	}, { /* This one is for parallel sensors! DO NOT USE! */
-		.pixelformat = V4L2_PIX_FMT_UYVY,
-		.depth = 16,
-		.mbus_code = MEDIA_BUS_FMT_UYVY8_2X8,
-		.sh_fmt = CSS_FRAME_FORMAT_UYVY,
-		.description = "UYVY, interleaved"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_SBGGR16,
-		.depth = 16,
-		.mbus_code = V4L2_MBUS_FMT_CUSTOM_SBGGR16,
-		.sh_fmt = CSS_FRAME_FORMAT_RAW,
-		.description = "Bayer 16"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_SBGGR8,
-		.depth = 8,
-		.mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8,
-		.sh_fmt = CSS_FRAME_FORMAT_RAW,
-		.description = "Bayer 8"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_SGBRG8,
-		.depth = 8,
-		.mbus_code = MEDIA_BUS_FMT_SGBRG8_1X8,
-		.sh_fmt = CSS_FRAME_FORMAT_RAW,
-		.description = "Bayer 8"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_SGRBG8,
-		.depth = 8,
-		.mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8,
-		.sh_fmt = CSS_FRAME_FORMAT_RAW,
-		.description = "Bayer 8"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_SRGGB8,
-		.depth = 8,
-		.mbus_code = MEDIA_BUS_FMT_SRGGB8_1X8,
-		.sh_fmt = CSS_FRAME_FORMAT_RAW,
-		.description = "Bayer 8"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_SBGGR10,
-		.depth = 16,
-		.mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10,
-		.sh_fmt = CSS_FRAME_FORMAT_RAW,
-		.description = "Bayer 10"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_SGBRG10,
-		.depth = 16,
-		.mbus_code = MEDIA_BUS_FMT_SGBRG10_1X10,
-		.sh_fmt = CSS_FRAME_FORMAT_RAW,
-		.description = "Bayer 10"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_SGRBG10,
-		.depth = 16,
-		.mbus_code = MEDIA_BUS_FMT_SGRBG10_1X10,
-		.sh_fmt = CSS_FRAME_FORMAT_RAW,
-		.description = "Bayer 10"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_SRGGB10,
-		.depth = 16,
-		.mbus_code = MEDIA_BUS_FMT_SRGGB10_1X10,
-		.sh_fmt = CSS_FRAME_FORMAT_RAW,
-		.description = "Bayer 10"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_SBGGR12,
-		.depth = 16,
-		.mbus_code = MEDIA_BUS_FMT_SBGGR12_1X12,
-		.sh_fmt = CSS_FRAME_FORMAT_RAW,
-		.description = "Bayer 12"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_SGBRG12,
-		.depth = 16,
-		.mbus_code = MEDIA_BUS_FMT_SGBRG12_1X12,
-		.sh_fmt = CSS_FRAME_FORMAT_RAW,
-		.description = "Bayer 12"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_SGRBG12,
-		.depth = 16,
-		.mbus_code = MEDIA_BUS_FMT_SGRBG12_1X12,
-		.sh_fmt = CSS_FRAME_FORMAT_RAW,
-		.description = "Bayer 12"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_SRGGB12,
-		.depth = 16,
-		.mbus_code = MEDIA_BUS_FMT_SRGGB12_1X12,
-		.sh_fmt = CSS_FRAME_FORMAT_RAW,
-		.description = "Bayer 12"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_RGB32,
-		.depth = 32,
-		.mbus_code = V4L2_MBUS_FMT_CUSTOM_RGB32,
-		.sh_fmt = CSS_FRAME_FORMAT_RGBA888,
-		.description = "32 RGB 8-8-8-8"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_RGB565,
-		.depth = 16,
-		.mbus_code = MEDIA_BUS_FMT_BGR565_2X8_LE,
-		.sh_fmt = CSS_FRAME_FORMAT_RGB565,
-		.description = "16 RGB 5-6-5"
-	}, {
-		.pixelformat = V4L2_PIX_FMT_JPEG,
-		.depth = 8,
-		.mbus_code = MEDIA_BUS_FMT_JPEG_1X8,
-		.sh_fmt = CSS_FRAME_FORMAT_BINARY_8,
-		.description = "JPEG"
-	},
-#if 0
-	{
-	/* This is a custom format being used by M10MO to send the RAW data */
-		.pixelformat = V4L2_PIX_FMT_CUSTOM_M10MO_RAW,
-		.depth = 8,
-		.mbus_code = V4L2_MBUS_FMT_CUSTOM_M10MO_RAW,
-		.sh_fmt = CSS_FRAME_FORMAT_BINARY_8,
-		.description = "Custom RAW for M10MO"
-	},
-#endif
-};
-
-const struct atomisp_format_bridge *atomisp_get_format_bridge(
-	unsigned int pixelformat)
-{
-	unsigned int i;
-
-	for (i = 0; i < ARRAY_SIZE(atomisp_output_fmts); i++) {
-		if (atomisp_output_fmts[i].pixelformat == pixelformat)
-			return &atomisp_output_fmts[i];
-	}
-
-	return NULL;
-}
-
-const struct atomisp_format_bridge *atomisp_get_format_bridge_from_mbus(
-	u32 mbus_code)
-{
-	unsigned int i;
-
-	for (i = 0; i < ARRAY_SIZE(atomisp_output_fmts); i++) {
-		if (mbus_code == atomisp_output_fmts[i].mbus_code)
-			return &atomisp_output_fmts[i];
-	}
-
-	return NULL;
-}
-
-/*
- * v4l2 ioctls
- * return ISP capabilities
- *
- * FIXME: capabilities should be different for video0/video2/video3
- */
-static int atomisp_querycap(struct file *file, void *fh,
-			    struct v4l2_capability *cap)
-{
-	memset(cap, 0, sizeof(struct v4l2_capability));
-
-	WARN_ON(sizeof(DRIVER) > sizeof(cap->driver) ||
-		sizeof(CARD) > sizeof(cap->card) ||
-		sizeof(BUS_INFO) > sizeof(cap->bus_info));
-
-	strncpy(cap->driver, DRIVER, sizeof(cap->driver) - 1);
-	strncpy(cap->card, CARD, sizeof(cap->card) - 1);
-	strncpy(cap->bus_info, BUS_INFO, sizeof(cap->card) - 1);
-
-	cap->device_caps = V4L2_CAP_VIDEO_CAPTURE |
-	    V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_OUTPUT;
-	cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
-	return 0;
-}
-
-/*
- * enum input are used to check primary/secondary camera
- */
-static int atomisp_enum_input(struct file *file, void *fh,
-	struct v4l2_input *input)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	int index = input->index;
-
-	if (index >= isp->input_cnt)
-		return -EINVAL;
-
-	if (!isp->inputs[index].camera)
-		return -EINVAL;
-
-	memset(input, 0, sizeof(struct v4l2_input));
-	strncpy(input->name, isp->inputs[index].camera->name,
-		sizeof(input->name) - 1);
-
-	/*
-	 * HACK: append actuator's name to sensor's
-	 * As currently userspace can't talk directly to subdev nodes, this
-	 * ioctl is the only way to enum inputs + possible external actuators
-	 * for 3A tuning purpose.
-	 */
-#ifndef ISP2401
-	if (isp->inputs[index].motor &&
-	    strlen(isp->inputs[index].motor->name) > 0) {
-#else
-	if (isp->motor &&
-	    strlen(isp->motor->name) > 0) {
-#endif
-		const int cur_len = strlen(input->name);
-		const int max_size = sizeof(input->name) - cur_len - 1;
-
-		if (max_size > 1) {
-			input->name[cur_len] = '+';
-			strncpy(&input->name[cur_len + 1],
-#ifndef ISP2401
-				isp->inputs[index].motor->name, max_size - 1);
-#else
-				isp->motor->name, max_size - 1);
-#endif
-		}
-	}
-
-	input->type = V4L2_INPUT_TYPE_CAMERA;
-	input->index = index;
-	input->reserved[0] = isp->inputs[index].type;
-	input->reserved[1] = isp->inputs[index].port;
-
-	return 0;
-}
-
-static unsigned int atomisp_subdev_streaming_count(
-					struct atomisp_sub_device *asd)
-{
-	return asd->video_out_preview.capq.streaming
-		+ asd->video_out_capture.capq.streaming
-		+ asd->video_out_video_capture.capq.streaming
-		+ asd->video_out_vf.capq.streaming
-		+ asd->video_in.capq.streaming;
-}
-
-unsigned int atomisp_streaming_count(struct atomisp_device *isp)
-{
-	unsigned int i, sum;
-
-	for (i = 0, sum = 0; i < isp->num_of_streams; i++)
-		sum += isp->asd[i].streaming ==
-		    ATOMISP_DEVICE_STREAMING_ENABLED;
-
-	return sum;
-}
-
-unsigned int atomisp_is_acc_enabled(struct atomisp_device *isp)
-{
-	unsigned int i;
-
-	for (i = 0; i < isp->num_of_streams; i++)
-		if (isp->asd[i].acc.pipeline)
-			return 1;
-
-	return 0;
-}
-/*
- * get input are used to get current primary/secondary camera
- */
-static int atomisp_g_input(struct file *file, void *fh, unsigned int *input)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
-
-	rt_mutex_lock(&isp->mutex);
-	*input = asd->input_curr;
-	rt_mutex_unlock(&isp->mutex);
-
-	return 0;
-}
-/*
- * set input are used to set current primary/secondary camera
- */
-static int atomisp_s_input(struct file *file, void *fh, unsigned int input)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
-	struct v4l2_subdev *camera = NULL;
-	int ret;
-
-	rt_mutex_lock(&isp->mutex);
-	if (input >= ATOM_ISP_MAX_INPUTS || input >= isp->input_cnt) {
-		dev_dbg(isp->dev, "input_cnt: %d\n", isp->input_cnt);
-		ret = -EINVAL;
-		goto error;
-	}
-
-	/*
-	 * check whether the request camera:
-	 * 1: already in use
-	 * 2: if in use, whether it is used by other streams
-	 */
-	if (isp->inputs[input].asd != NULL && isp->inputs[input].asd != asd) {
-		dev_err(isp->dev,
-			 "%s, camera is already used by stream: %d\n", __func__,
-			 isp->inputs[input].asd->index);
-		ret = -EBUSY;
-		goto error;
-	}
-
-	camera = isp->inputs[input].camera;
-	if (!camera) {
-		dev_err(isp->dev, "%s, no camera\n", __func__);
-		ret = -EINVAL;
-		goto error;
-	}
-
-	if (atomisp_subdev_streaming_count(asd)) {
-		dev_err(isp->dev,
-			 "ISP is still streaming, stop first\n");
-		ret = -EINVAL;
-		goto error;
-	}
-
-	/* power off the current owned sensor, as it is not used this time */
-	if (isp->inputs[asd->input_curr].asd == asd &&
-	    asd->input_curr != input) {
-		ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-				       core, s_power, 0);
-		if (ret)
-			dev_warn(isp->dev,
-				    "Failed to power-off sensor\n");
-		/* clear the asd field to show this camera is not used */
-		isp->inputs[asd->input_curr].asd = NULL;
-	}
-
-	/* powe on the new sensor */
-	ret = v4l2_subdev_call(isp->inputs[input].camera, core, s_power, 1);
-	if (ret) {
-		dev_err(isp->dev, "Failed to power-on sensor\n");
-		goto error;
-	}
-	/*
-	 * Some sensor driver resets the run mode during power-on, thus force
-	 * update the run mode to sensor after power-on.
-	 */
-	atomisp_update_run_mode(asd);
-
-	/* select operating sensor */
-	ret = v4l2_subdev_call(isp->inputs[input].camera, video, s_routing,
-		0, isp->inputs[input].sensor_index, 0);
-	if (ret && (ret != -ENOIOCTLCMD)) {
-		dev_err(isp->dev, "Failed to select sensor\n");
-		goto error;
-	}
-
-#ifndef ISP2401
-	if (!isp->sw_contex.file_input && isp->inputs[input].motor)
-		ret = v4l2_subdev_call(isp->inputs[input].motor, core,
-				       init, 1);
-#else
-	if (isp->motor)
-		ret = v4l2_subdev_call(isp->motor, core, s_power, 1);
-
-	if (!isp->sw_contex.file_input && isp->motor)
-		ret = v4l2_subdev_call(isp->motor, core, init, 1);
-#endif
-
-	asd->input_curr = input;
-	/* mark this camera is used by the current stream */
-	isp->inputs[input].asd = asd;
-	rt_mutex_unlock(&isp->mutex);
-
-	return 0;
-
-error:
-	rt_mutex_unlock(&isp->mutex);
-
-	return ret;
-}
-
-static int atomisp_enum_fmt_cap(struct file *file, void *fh,
-	struct v4l2_fmtdesc *f)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
-	struct v4l2_subdev_mbus_code_enum code = { 0 };
-	unsigned int i, fi = 0;
-	int rval;
-
-	rt_mutex_lock(&isp->mutex);
-	rval = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, pad,
-				enum_mbus_code, NULL, &code);
-	if (rval == -ENOIOCTLCMD) {
-		dev_warn(isp->dev, "enum_mbus_code pad op not supported. Please fix your sensor driver!\n");
-	//	rval = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-	//				video, enum_mbus_fmt, 0, &code.code);
-	}
-	rt_mutex_unlock(&isp->mutex);
-
-	if (rval)
-		return rval;
-
-	for (i = 0; i < ARRAY_SIZE(atomisp_output_fmts); i++) {
-		const struct atomisp_format_bridge *format =
-			&atomisp_output_fmts[i];
-
-		/*
-		 * Is the atomisp-supported format is valid for the
-		 * sensor (configuration)? If not, skip it.
-		 */
-		if (format->sh_fmt == CSS_FRAME_FORMAT_RAW
-		    && format->mbus_code != code.code)
-			continue;
-
-		/* Found a match. Now let's pick f->index'th one. */
-		if (fi < f->index) {
-			fi++;
-			continue;
-		}
-
-		strlcpy(f->description, format->description,
-			sizeof(f->description));
-		f->pixelformat = format->pixelformat;
-		return 0;
-	}
-
-	return -EINVAL;
-}
-
-static int atomisp_g_fmt_cap(struct file *file, void *fh,
-	struct v4l2_format *f)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-
-	int ret;
-
-	rt_mutex_lock(&isp->mutex);
-	ret = atomisp_get_fmt(vdev, f);
-	rt_mutex_unlock(&isp->mutex);
-	return ret;
-}
-
-static int atomisp_g_fmt_file(struct file *file, void *fh,
-		struct v4l2_format *f)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-
-	rt_mutex_lock(&isp->mutex);
-	f->fmt.pix = pipe->pix;
-	rt_mutex_unlock(&isp->mutex);
-
-	return 0;
-}
-
-/* This function looks up the closest available resolution. */
-static int atomisp_try_fmt_cap(struct file *file, void *fh,
-	struct v4l2_format *f)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	int ret;
-
-	rt_mutex_lock(&isp->mutex);
-	ret = atomisp_try_fmt(vdev, f, NULL);
-	rt_mutex_unlock(&isp->mutex);
-	return ret;
-}
-
-static int atomisp_s_fmt_cap(struct file *file, void *fh,
-	struct v4l2_format *f)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	int ret;
-
-	rt_mutex_lock(&isp->mutex);
-	if (isp->isp_fatal_error) {
-		ret = -EIO;
-		rt_mutex_unlock(&isp->mutex);
-		return ret;
-	}
-	ret = atomisp_set_fmt(vdev, f);
-	rt_mutex_unlock(&isp->mutex);
-	return ret;
-}
-
-static int atomisp_s_fmt_file(struct file *file, void *fh,
-				struct v4l2_format *f)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	int ret;
-
-	rt_mutex_lock(&isp->mutex);
-	ret = atomisp_set_fmt_file(vdev, f);
-	rt_mutex_unlock(&isp->mutex);
-	return ret;
-}
-
-/*
- * Free videobuffer buffer priv data
- */
-void atomisp_videobuf_free_buf(struct videobuf_buffer *vb)
-{
-	struct videobuf_vmalloc_memory *vm_mem;
-
-	if (vb == NULL)
-		return;
-
-	vm_mem = vb->priv;
-	if (vm_mem && vm_mem->vaddr) {
-		atomisp_css_frame_free(vm_mem->vaddr);
-		vm_mem->vaddr = NULL;
-	}
-}
-
-/*
- * this function is used to free video buffer queue
- */
-static void atomisp_videobuf_free_queue(struct videobuf_queue *q)
-{
-	int i;
-
-	for (i = 0; i < VIDEO_MAX_FRAME; i++) {
-		atomisp_videobuf_free_buf(q->bufs[i]);
-		kfree(q->bufs[i]);
-		q->bufs[i] = NULL;
-	}
-}
-
-int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd,
-	uint16_t stream_id)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct atomisp_s3a_buf *s3a_buf = NULL, *_s3a_buf;
-	struct atomisp_dis_buf *dis_buf = NULL, *_dis_buf;
-	struct atomisp_metadata_buf *md_buf = NULL, *_md_buf;
-	int count;
-	struct atomisp_css_dvs_grid_info *dvs_grid_info =
-		atomisp_css_get_dvs_grid_info(&asd->params.curr_grid_info);
-	unsigned int i;
-
-	if (list_empty(&asd->s3a_stats) &&
-		asd->params.curr_grid_info.s3a_grid.enable) {
-		count = ATOMISP_CSS_Q_DEPTH +
-			ATOMISP_S3A_BUF_QUEUE_DEPTH_FOR_HAL;
-		dev_dbg(isp->dev, "allocating %d 3a buffers\n", count);
-		while (count--) {
-			s3a_buf = kzalloc(sizeof(struct atomisp_s3a_buf), GFP_KERNEL);
-			if (!s3a_buf)
-				goto error;
-
-			if (atomisp_css_allocate_stat_buffers(
-					asd, stream_id, s3a_buf, NULL, NULL)) {
-				kfree(s3a_buf);
-				goto error;
-			}
-
-			list_add_tail(&s3a_buf->list, &asd->s3a_stats);
-		}
-	}
-
-	if (list_empty(&asd->dis_stats) && dvs_grid_info &&
-		dvs_grid_info->enable) {
-		count = ATOMISP_CSS_Q_DEPTH + 1;
-		dev_dbg(isp->dev, "allocating %d dis buffers\n", count);
-		while (count--) {
-			dis_buf = kzalloc(sizeof(struct atomisp_dis_buf), GFP_KERNEL);
-			if (!dis_buf) {
-				kfree(s3a_buf);
-				goto error;
-			}
-			if (atomisp_css_allocate_stat_buffers(
-					asd, stream_id, NULL, dis_buf, NULL)) {
-				kfree(dis_buf);
-				goto error;
-			}
-
-			list_add_tail(&dis_buf->list, &asd->dis_stats);
-		}
-	}
-
-	for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
-		if (list_empty(&asd->metadata[i]) &&
-		    list_empty(&asd->metadata_ready[i]) &&
-		    list_empty(&asd->metadata_in_css[i])) {
-			count = ATOMISP_CSS_Q_DEPTH +
-				ATOMISP_METADATA_QUEUE_DEPTH_FOR_HAL;
-			dev_dbg(isp->dev, "allocating %d metadata buffers for type %d\n",
-				count, i);
-			while (count--) {
-				md_buf = kzalloc(sizeof(struct atomisp_metadata_buf),
-						 GFP_KERNEL);
-				if (!md_buf)
-					goto error;
-
-				if (atomisp_css_allocate_stat_buffers(
-						asd, stream_id, NULL, NULL, md_buf)) {
-					kfree(md_buf);
-					goto error;
-				}
-				list_add_tail(&md_buf->list, &asd->metadata[i]);
-			}
-		}
-	}
-	return 0;
-
-error:
-	dev_err(isp->dev, "failed to allocate statistics buffers\n");
-
-	list_for_each_entry_safe(dis_buf, _dis_buf, &asd->dis_stats, list) {
-		atomisp_css_free_dis_buffer(dis_buf);
-		list_del(&dis_buf->list);
-		kfree(dis_buf);
-	}
-
-	list_for_each_entry_safe(s3a_buf, _s3a_buf, &asd->s3a_stats, list) {
-		atomisp_css_free_3a_buffer(s3a_buf);
-		list_del(&s3a_buf->list);
-		kfree(s3a_buf);
-	}
-
-	for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
-		list_for_each_entry_safe(md_buf, _md_buf, &asd->metadata[i],
-					list) {
-			atomisp_css_free_metadata_buffer(md_buf);
-			list_del(&md_buf->list);
-			kfree(md_buf);
-		}
-	}
-	return -ENOMEM;
-}
-
-/*
- * Initiate Memory Mapping or User Pointer I/O
- */
-int __atomisp_reqbufs(struct file *file, void *fh,
-	struct v4l2_requestbuffers *req)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-	struct atomisp_sub_device *asd = pipe->asd;
-	struct atomisp_css_frame_info frame_info;
-	struct atomisp_css_frame *frame;
-	struct videobuf_vmalloc_memory *vm_mem;
-	uint16_t source_pad = atomisp_subdev_source_pad(vdev);
-	uint16_t stream_id = atomisp_source_pad_to_stream_id(asd, source_pad);
-	int ret = 0, i = 0;
-
-	if (req->count == 0) {
-		mutex_lock(&pipe->capq.vb_lock);
-		if (!list_empty(&pipe->capq.stream))
-			videobuf_queue_cancel(&pipe->capq);
-
-		atomisp_videobuf_free_queue(&pipe->capq);
-		mutex_unlock(&pipe->capq.vb_lock);
-		/* clear request config id */
-		memset(pipe->frame_request_config_id, 0,
-			VIDEO_MAX_FRAME * sizeof(unsigned int));
-		memset(pipe->frame_params, 0,
-			VIDEO_MAX_FRAME *
-			sizeof(struct atomisp_css_params_with_list *));
-		return 0;
-	}
-
-	ret = videobuf_reqbufs(&pipe->capq, req);
-	if (ret)
-		return ret;
-
-	atomisp_alloc_css_stat_bufs(asd, stream_id);
-
-	/*
-	 * for user pointer type, buffers are not really allcated here,
-	 * buffers are setup in QBUF operation through v4l2_buffer structure
-	 */
-	if (req->memory == V4L2_MEMORY_USERPTR)
-		return 0;
-
-	ret = atomisp_get_css_frame_info(asd, source_pad, &frame_info);
-	if (ret)
-		return ret;
-
-	/*
-	 * Allocate the real frame here for selected node using our
-	 * memory management function
-	 */
-	for (i = 0; i < req->count; i++) {
-		if (atomisp_css_frame_allocate_from_info(&frame, &frame_info))
-			goto error;
-		vm_mem = pipe->capq.bufs[i]->priv;
-		vm_mem->vaddr = frame;
-	}
-
-	return ret;
-
-error:
-	while (i--) {
-		vm_mem = pipe->capq.bufs[i]->priv;
-		atomisp_css_frame_free(vm_mem->vaddr);
-	}
-
-	if (asd->vf_frame)
-		atomisp_css_frame_free(asd->vf_frame);
-
-	return -ENOMEM;
-}
-
-int atomisp_reqbufs(struct file *file, void *fh,
-	struct v4l2_requestbuffers *req)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	int ret;
-
-	rt_mutex_lock(&isp->mutex);
-	ret = __atomisp_reqbufs(file, fh, req);
-	rt_mutex_unlock(&isp->mutex);
-
-	return ret;
-}
-
-static int atomisp_reqbufs_file(struct file *file, void *fh,
-		struct v4l2_requestbuffers *req)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-
-	if (req->count == 0) {
-		mutex_lock(&pipe->outq.vb_lock);
-		atomisp_videobuf_free_queue(&pipe->outq);
-		mutex_unlock(&pipe->outq.vb_lock);
-		return 0;
-	}
-
-	return videobuf_reqbufs(&pipe->outq, req);
-}
-
-/* application query the status of a buffer */
-static int atomisp_querybuf(struct file *file, void *fh,
-	struct v4l2_buffer *buf)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-
-	return videobuf_querybuf(&pipe->capq, buf);
-}
-
-static int atomisp_querybuf_file(struct file *file, void *fh,
-				struct v4l2_buffer *buf)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-
-	return videobuf_querybuf(&pipe->outq, buf);
-}
-
-/*
- * Applications call the VIDIOC_QBUF ioctl to enqueue an empty (capturing) or
- * filled (output) buffer in the drivers incoming queue.
- */
-static int atomisp_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
-{
-	static const int NOFLUSH_FLAGS = V4L2_BUF_FLAG_NO_CACHE_INVALIDATE |
-					 V4L2_BUF_FLAG_NO_CACHE_CLEAN;
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-	struct atomisp_sub_device *asd = pipe->asd;
-	struct videobuf_buffer *vb;
-	struct videobuf_vmalloc_memory *vm_mem;
-	struct atomisp_css_frame_info frame_info;
-	struct atomisp_css_frame *handle = NULL;
-	u32 length;
-	u32 pgnr;
-	int ret = 0;
-
-	rt_mutex_lock(&isp->mutex);
-	if (isp->isp_fatal_error) {
-		ret = -EIO;
-		goto error;
-	}
-
-	if (asd->streaming == ATOMISP_DEVICE_STREAMING_STOPPING) {
-		dev_err(isp->dev, "%s: reject, as ISP at stopping.\n",
-				__func__);
-		ret = -EIO;
-		goto error;
-	}
-
-	if (!buf || buf->index >= VIDEO_MAX_FRAME ||
-		!pipe->capq.bufs[buf->index]) {
-		dev_err(isp->dev, "Invalid index for qbuf.\n");
-		ret = -EINVAL;
-		goto error;
-	}
-
-	/*
-	 * For userptr type frame, we convert user space address to physic
-	 * address and reprograme out page table properly
-	 */
-	if (buf->memory == V4L2_MEMORY_USERPTR) {
-		struct hrt_userbuffer_attr attributes;
-		vb = pipe->capq.bufs[buf->index];
-		vm_mem = vb->priv;
-		if (!vm_mem) {
-			ret = -EINVAL;
-			goto error;
-		}
-
-		length = vb->bsize;
-		pgnr = (length + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
-
-		if (vb->baddr == buf->m.userptr && vm_mem->vaddr)
-			goto done;
-
-		if (atomisp_get_css_frame_info(asd,
-				atomisp_subdev_source_pad(vdev), &frame_info)) {
-			ret = -EIO;
-			goto error;
-		}
-
-		attributes.pgnr = pgnr;
-#ifdef CONFIG_ION
-#ifndef ISP2401
-		attributes.type = buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_ION
-					? HRT_USR_ION : HRT_USR_PTR;
-#else
-		if (buf->reserved & ATOMISP_BUFFER_TYPE_IS_ION) {
-			attributes.type = HRT_USR_ION;
-			if (asd->ion_dev_fd->val !=  ION_FD_UNSET) {
-				dev_dbg(isp->dev, "ION buffer queued, share_fd=%lddev_fd=%d.\n",
-				buf->m.userptr, asd->ion_dev_fd->val);
-				/*
-				 * Make sure the shared fd we just got
-				 * from user space isn't larger than
-				 * the space we have for it.
-				 */
-				if ((buf->m.userptr &
-				(ATOMISP_ION_DEVICE_FD_MASK)) != 0) {
-					dev_err(isp->dev,
-							"Error: v4l2 buffer fd:0X%0lX > 0XFFFF.\n",
-							buf->m.userptr);
-					ret = -EINVAL;
-					goto error;
-				}
-				buf->m.userptr |= asd->ion_dev_fd->val <<
-					ATOMISP_ION_DEVICE_FD_OFFSET;
-			} else {
-				dev_err(isp->dev, "v4l2 buffer type is ION, \
-						but no dev fd set from userspace.\n");
-				ret = -EINVAL;
-				goto error;
-			}
-		} else {
-			attributes.type = HRT_USR_PTR;
-		}
-#endif
-#else
-		attributes.type = HRT_USR_PTR;
-#endif
-		ret = atomisp_css_frame_map(&handle, &frame_info,
-				       (void __user *)buf->m.userptr,
-				       0, &attributes);
-		if (ret) {
-			dev_err(isp->dev, "Failed to map user buffer\n");
-			goto error;
-		}
-
-		if (vm_mem->vaddr) {
-			mutex_lock(&pipe->capq.vb_lock);
-			atomisp_css_frame_free(vm_mem->vaddr);
-			vm_mem->vaddr = NULL;
-			vb->state = VIDEOBUF_NEEDS_INIT;
-			mutex_unlock(&pipe->capq.vb_lock);
-		}
-
-		vm_mem->vaddr = handle;
-
-		buf->flags &= ~V4L2_BUF_FLAG_MAPPED;
-		buf->flags |= V4L2_BUF_FLAG_QUEUED;
-		buf->flags &= ~V4L2_BUF_FLAG_DONE;
-	} else if (buf->memory == V4L2_MEMORY_MMAP) {
-		buf->flags |= V4L2_BUF_FLAG_MAPPED;
-		buf->flags |= V4L2_BUF_FLAG_QUEUED;
-		buf->flags &= ~V4L2_BUF_FLAG_DONE;
-	}
-
-done:
-	if (!((buf->flags & NOFLUSH_FLAGS) == NOFLUSH_FLAGS))
-		wbinvd();
-
-	if (!atomisp_is_vf_pipe(pipe) &&
-	    (buf->reserved2 & ATOMISP_BUFFER_HAS_PER_FRAME_SETTING)) {
-		/* this buffer will have a per-frame parameter */
-		pipe->frame_request_config_id[buf->index] = buf->reserved2 &
-					~ATOMISP_BUFFER_HAS_PER_FRAME_SETTING;
-		dev_dbg(isp->dev, "This buffer requires per_frame setting which has isp_config_id %d\n",
-			pipe->frame_request_config_id[buf->index]);
-	} else {
-		pipe->frame_request_config_id[buf->index] = 0;
-	}
-
-	pipe->frame_params[buf->index] = NULL;
-
-	rt_mutex_unlock(&isp->mutex);
-
-	ret = videobuf_qbuf(&pipe->capq, buf);
-	rt_mutex_lock(&isp->mutex);
-	if (ret)
-		goto error;
-
-	/* TODO: do this better, not best way to queue to css */
-	if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED) {
-		if (!list_empty(&pipe->buffers_waiting_for_param)) {
-			atomisp_handle_parameter_and_buffer(pipe);
-		} else {
-			atomisp_qbuffers_to_css(asd);
-
-#ifndef ISP2401
-			if (!atomisp_is_wdt_running(asd) && atomisp_buffers_queued(asd))
-				atomisp_wdt_start(asd);
-#else
-			if (!atomisp_is_wdt_running(pipe) &&
-				atomisp_buffers_queued_pipe(pipe))
-				atomisp_wdt_start(pipe);
-#endif
-		}
-	}
-
-	/* Workaround: Due to the design of HALv3,
-	 * sometimes in ZSL or SDV mode HAL needs to
-	 * capture multiple images within one streaming cycle.
-	 * But the capture number cannot be determined by HAL.
-	 * So HAL only sets the capture number to be 1 and queue multiple
-	 * buffers. Atomisp driver needs to check this case and re-trigger
-	 * CSS to do capture when new buffer is queued. */
-	if (asd->continuous_mode->val &&
-	    atomisp_subdev_source_pad(vdev)
-	    == ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE &&
-	    pipe->capq.streaming &&
-	    !asd->enable_raw_buffer_lock->val &&
-	    asd->params.offline_parm.num_captures == 1) {
-#ifndef ISP2401
-		asd->pending_capture_request++;
-		dev_dbg(isp->dev, "Add one pending capture request.\n");
-#else
-	    if (asd->re_trigger_capture) {
-			ret = atomisp_css_offline_capture_configure(asd,
-				asd->params.offline_parm.num_captures,
-				asd->params.offline_parm.skip_frames,
-				asd->params.offline_parm.offset);
-			asd->re_trigger_capture = false;
-			dev_dbg(isp->dev, "%s Trigger capture again ret=%d\n",
-				__func__, ret);
-
-	    } else {
-			asd->pending_capture_request++;
-			asd->re_trigger_capture = false;
-			dev_dbg(isp->dev, "Add one pending capture request.\n");
-	    }
-#endif
-	}
-	rt_mutex_unlock(&isp->mutex);
-
-	dev_dbg(isp->dev, "qbuf buffer %d (%s) for asd%d\n", buf->index,
-		vdev->name, asd->index);
-
-	return ret;
-
-error:
-	rt_mutex_unlock(&isp->mutex);
-	return ret;
-}
-
-static int atomisp_qbuf_file(struct file *file, void *fh,
-					struct v4l2_buffer *buf)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-	int ret;
-
-	rt_mutex_lock(&isp->mutex);
-	if (isp->isp_fatal_error) {
-		ret = -EIO;
-		goto error;
-	}
-
-	if (!buf || buf->index >= VIDEO_MAX_FRAME ||
-		!pipe->outq.bufs[buf->index]) {
-		dev_err(isp->dev, "Invalid index for qbuf.\n");
-		ret = -EINVAL;
-		goto error;
-	}
-
-	if (buf->memory != V4L2_MEMORY_MMAP) {
-		dev_err(isp->dev, "Unsupported memory method\n");
-		ret = -EINVAL;
-		goto error;
-	}
-
-	if (buf->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
-		dev_err(isp->dev, "Unsupported buffer type\n");
-		ret = -EINVAL;
-		goto error;
-	}
-	rt_mutex_unlock(&isp->mutex);
-
-	return videobuf_qbuf(&pipe->outq, buf);
-
-error:
-	rt_mutex_unlock(&isp->mutex);
-
-	return ret;
-}
-
-static int __get_frame_exp_id(struct atomisp_video_pipe *pipe,
-		struct v4l2_buffer *buf)
-{
-	struct videobuf_vmalloc_memory *vm_mem;
-	struct atomisp_css_frame *handle;
-	int i;
-
-	for (i = 0; pipe->capq.bufs[i]; i++) {
-		vm_mem = pipe->capq.bufs[i]->priv;
-		handle = vm_mem->vaddr;
-		if (buf->index == pipe->capq.bufs[i]->i && handle)
-			return handle->exp_id;
-	}
-	return -EINVAL;
-}
-
-/*
- * Applications call the VIDIOC_DQBUF ioctl to dequeue a filled (capturing) or
- * displayed (output buffer)from the driver's outgoing queue
- */
-static int atomisp_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-	struct atomisp_sub_device *asd = pipe->asd;
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	int ret = 0;
-
-	rt_mutex_lock(&isp->mutex);
-
-	if (isp->isp_fatal_error) {
-		rt_mutex_unlock(&isp->mutex);
-		return -EIO;
-	}
-
-	if (asd->streaming == ATOMISP_DEVICE_STREAMING_STOPPING) {
-		rt_mutex_unlock(&isp->mutex);
-		dev_err(isp->dev, "%s: reject, as ISP at stopping.\n",
-				__func__);
-		return -EIO;
-	}
-
-	rt_mutex_unlock(&isp->mutex);
-
-	ret = videobuf_dqbuf(&pipe->capq, buf, file->f_flags & O_NONBLOCK);
-	if (ret) {
-		dev_dbg(isp->dev, "<%s: %d\n", __func__, ret);
-		return ret;
-	}
-	rt_mutex_lock(&isp->mutex);
-	buf->bytesused = pipe->pix.sizeimage;
-	buf->reserved = asd->frame_status[buf->index];
-
-	/*
-	 * Hack:
-	 * Currently frame_status in the enum type which takes no more lower
-	 * 8 bit.
-	 * use bit[31:16] for exp_id as it is only in the range of 1~255
-	 */
-	buf->reserved &= 0x0000ffff;
-	if (!(buf->flags & V4L2_BUF_FLAG_ERROR))
-		buf->reserved |= __get_frame_exp_id(pipe, buf) << 16;
-	buf->reserved2 = pipe->frame_config_id[buf->index];
-	rt_mutex_unlock(&isp->mutex);
-
-	dev_dbg(isp->dev, "dqbuf buffer %d (%s) for asd%d with exp_id %d, isp_config_id %d\n",
-		buf->index, vdev->name, asd->index, buf->reserved >> 16,
-		buf->reserved2);
-	return 0;
-}
-
-enum atomisp_css_pipe_id atomisp_get_css_pipe_id(struct atomisp_sub_device *asd)
-{
-	if (ATOMISP_USE_YUVPP(asd))
-		return CSS_PIPE_ID_YUVPP;
-
-	if (asd->continuous_mode->val) {
-		if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO)
-			return CSS_PIPE_ID_VIDEO;
-		else
-			return CSS_PIPE_ID_PREVIEW;
-	}
-
-	/*
-	 * Disable vf_pp and run CSS in video mode. This allows using ISP
-	 * scaling but it has one frame delay due to CSS internal buffering.
-	 */
-	if (asd->vfpp->val == ATOMISP_VFPP_DISABLE_SCALER)
-		return CSS_PIPE_ID_VIDEO;
-
-	/*
-	 * Disable vf_pp and run CSS in still capture mode. In this mode
-	 * CSS does not cause extra latency with buffering, but scaling
-	 * is not available.
-	 */
-	if (asd->vfpp->val == ATOMISP_VFPP_DISABLE_LOWLAT)
-		return CSS_PIPE_ID_CAPTURE;
-
-	switch (asd->run_mode->val) {
-	case ATOMISP_RUN_MODE_PREVIEW:
-		return CSS_PIPE_ID_PREVIEW;
-	case ATOMISP_RUN_MODE_VIDEO:
-		return CSS_PIPE_ID_VIDEO;
-	case ATOMISP_RUN_MODE_STILL_CAPTURE:
-		/* fall through */
-	default:
-		return CSS_PIPE_ID_CAPTURE;
-	}
-}
-
-static unsigned int atomisp_sensor_start_stream(struct atomisp_sub_device *asd)
-{
-	struct atomisp_device *isp = asd->isp;
-
-	if (isp->inputs[asd->input_curr].camera_caps->
-	    sensor[asd->sensor_curr].stream_num > 1) {
-		if (asd->high_speed_mode)
-			return 1;
-		else
-			return 2;
-	}
-
-	if (asd->vfpp->val != ATOMISP_VFPP_ENABLE ||
-	    asd->copy_mode)
-		return 1;
-
-	if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO ||
-	    (asd->run_mode->val == ATOMISP_RUN_MODE_STILL_CAPTURE &&
-	     !atomisp_is_mbuscode_raw(
-		     asd->fmt[
-			     asd->capture_pad].fmt.code) &&
-	     !asd->continuous_mode->val))
-		return 2;
-	else
-		return 1;
-}
-
-int atomisp_stream_on_master_slave_sensor(struct atomisp_device *isp,
-	bool isp_timeout)
-{
-	unsigned int master = -1, slave = -1, delay_slave = 0;
-	int i, ret;
-
-	/*
-	 * ISP only support 2 streams now so ignore multiple master/slave
-	 * case to reduce the delay between 2 stream_on calls.
-	 */
-	for (i = 0; i < isp->num_of_streams; i++) {
-		int sensor_index = isp->asd[i].input_curr;
-		if (isp->inputs[sensor_index].camera_caps->
-				sensor[isp->asd[i].sensor_curr].is_slave)
-			slave = sensor_index;
-		else
-			master = sensor_index;
-	}
-
-	if (master == -1 || slave == -1) {
-		master = ATOMISP_DEPTH_DEFAULT_MASTER_SENSOR;
-		slave = ATOMISP_DEPTH_DEFAULT_SLAVE_SENSOR;
-		dev_warn(isp->dev,
-			 "depth mode use default master=%s.slave=%s.\n",
-			 isp->inputs[master].camera->name,
-			 isp->inputs[slave].camera->name);
-	}
-
-	ret = v4l2_subdev_call(isp->inputs[master].camera, core,
-			       ioctl, ATOMISP_IOC_G_DEPTH_SYNC_COMP,
-			       &delay_slave);
-	if (ret)
-		dev_warn(isp->dev,
-			 "get depth sensor %s compensation delay failed.\n",
-			 isp->inputs[master].camera->name);
-
-	ret = v4l2_subdev_call(isp->inputs[master].camera,
-			       video, s_stream, 1);
-	if (ret) {
-		dev_err(isp->dev, "depth mode master sensor %s stream-on failed.\n",
-			isp->inputs[master].camera->name);
-		return -EINVAL;
-	}
-
-	if (delay_slave != 0)
-		udelay(delay_slave);
-
-	ret = v4l2_subdev_call(isp->inputs[slave].camera,
-			       video, s_stream, 1);
-	if (ret) {
-		dev_err(isp->dev, "depth mode slave sensor %s stream-on failed.\n",
-			isp->inputs[slave].camera->name);
-		v4l2_subdev_call(isp->inputs[master].camera, video, s_stream, 0);
-
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-/* FIXME! */
-#ifndef ISP2401
-static void __wdt_on_master_slave_sensor(struct atomisp_device *isp,
-					 unsigned int wdt_duration)
-#else
-static void __wdt_on_master_slave_sensor(struct atomisp_video_pipe *pipe,
-					 unsigned int wdt_duration,
-					 bool enable)
-#endif
-{
-#ifndef ISP2401
-	if (atomisp_buffers_queued(&isp->asd[0]))
-		atomisp_wdt_refresh(&isp->asd[0], wdt_duration);
-	if (atomisp_buffers_queued(&isp->asd[1]))
-		atomisp_wdt_refresh(&isp->asd[1], wdt_duration);
-#else
-	static struct atomisp_video_pipe *pipe0;
-
-	if (enable) {
-		if (atomisp_buffers_queued_pipe(pipe0))
-			atomisp_wdt_refresh_pipe(pipe0, wdt_duration);
-		if (atomisp_buffers_queued_pipe(pipe))
-			atomisp_wdt_refresh_pipe(pipe, wdt_duration);
-	} else {
-		pipe0 = pipe;
-	}
-#endif
-}
-
-static void atomisp_pause_buffer_event(struct atomisp_device *isp)
-{
-	struct v4l2_event event = {0};
-	int i;
-
-	event.type = V4L2_EVENT_ATOMISP_PAUSE_BUFFER;
-
-	for (i = 0; i < isp->num_of_streams; i++) {
-		int sensor_index = isp->asd[i].input_curr;
-		if (isp->inputs[sensor_index].camera_caps->
-				sensor[isp->asd[i].sensor_curr].is_slave) {
-			v4l2_event_queue(isp->asd[i].subdev.devnode, &event);
-			break;
-		}
-	}
-}
-
-/* Input system HW workaround */
-/* Input system address translation corrupts burst during */
-/* invalidate. SW workaround for this is to set burst length */
-/* manually to 128 in case of 13MPx snapshot and to 1 otherwise. */
-static void atomisp_dma_burst_len_cfg(struct atomisp_sub_device *asd)
-{
-
-	struct v4l2_mbus_framefmt *sink;
-	sink = atomisp_subdev_get_ffmt(&asd->subdev, NULL,
-				       V4L2_SUBDEV_FORMAT_ACTIVE,
-				       ATOMISP_SUBDEV_PAD_SINK);
-
-	if (sink->width * sink->height >= 4096*3072)
-		atomisp_store_uint32(DMA_BURST_SIZE_REG, 0x7F);
-	else
-		atomisp_store_uint32(DMA_BURST_SIZE_REG, 0x00);
-}
-
-/*
- * This ioctl start the capture during streaming I/O.
- */
-static int atomisp_streamon(struct file *file, void *fh,
-	enum v4l2_buf_type type)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-	struct atomisp_sub_device *asd = pipe->asd;
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	enum atomisp_css_pipe_id css_pipe_id;
-	unsigned int sensor_start_stream;
-	unsigned int wdt_duration = ATOMISP_ISP_TIMEOUT_DURATION;
-	int ret = 0;
-	unsigned long irqflags;
-
-	dev_dbg(isp->dev, "Start stream on pad %d for asd%d\n",
-		atomisp_subdev_source_pad(vdev), asd->index);
-
-	if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-		dev_dbg(isp->dev, "unsupported v4l2 buf type\n");
-		return -EINVAL;
-	}
-
-	rt_mutex_lock(&isp->mutex);
-	if (isp->isp_fatal_error) {
-		ret = -EIO;
-		goto out;
-	}
-
-	if (asd->streaming == ATOMISP_DEVICE_STREAMING_STOPPING) {
-		ret = -EBUSY;
-		goto out;
-	}
-
-	if (pipe->capq.streaming)
-		goto out;
-
-	/* Input system HW workaround */
-	atomisp_dma_burst_len_cfg(asd);
-
-	/*
-	 * The number of streaming video nodes is based on which
-	 * binary is going to be run.
-	 */
-	sensor_start_stream = atomisp_sensor_start_stream(asd);
-
-	spin_lock_irqsave(&pipe->irq_lock, irqflags);
-	if (list_empty(&(pipe->capq.stream))) {
-		spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
-		dev_dbg(isp->dev, "no buffer in the queue\n");
-		ret = -EINVAL;
-		goto out;
-	}
-	spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
-
-	ret = videobuf_streamon(&pipe->capq);
-	if (ret)
-		goto out;
-
-	/* Reset pending capture request count. */
-	asd->pending_capture_request = 0;
-#ifdef ISP2401
-	asd->re_trigger_capture = false;
-#endif
-
-	if ((atomisp_subdev_streaming_count(asd) > sensor_start_stream) &&
-	    (!isp->inputs[asd->input_curr].camera_caps->multi_stream_ctrl)) {
-		/* trigger still capture */
-		if (asd->continuous_mode->val &&
-		    atomisp_subdev_source_pad(vdev)
-		    == ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE) {
-			if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO)
-				dev_dbg(isp->dev, "SDV last video raw buffer id: %u\n",
-					asd->latest_preview_exp_id);
-			else
-				dev_dbg(isp->dev, "ZSL last preview raw buffer id: %u\n",
-					asd->latest_preview_exp_id);
-
-			if (asd->delayed_init == ATOMISP_DELAYED_INIT_QUEUED) {
-				flush_work(&asd->delayed_init_work);
-				rt_mutex_unlock(&isp->mutex);
-				if (wait_for_completion_interruptible(
-						&asd->init_done) != 0)
-					return -ERESTARTSYS;
-				rt_mutex_lock(&isp->mutex);
-			}
-
-			/* handle per_frame_setting parameter and buffers */
-			atomisp_handle_parameter_and_buffer(pipe);
-
-			/*
-			 * only ZSL/SDV capture request will be here, raise
-			 * the ISP freq to the highest possible to minimize
-			 * the S2S latency.
-			 */
-			atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_MAX, false);
-			/*
-			 * When asd->enable_raw_buffer_lock->val is true,
-			 * An extra IOCTL is needed to call
-			 * atomisp_css_exp_id_capture and trigger real capture
-			 */
-			if (!asd->enable_raw_buffer_lock->val) {
-				ret = atomisp_css_offline_capture_configure(asd,
-					asd->params.offline_parm.num_captures,
-					asd->params.offline_parm.skip_frames,
-					asd->params.offline_parm.offset);
-				if (ret) {
-					ret = -EINVAL;
-					goto out;
-				}
-				if (asd->depth_mode->val)
-					atomisp_pause_buffer_event(isp);
-			}
-		}
-		atomisp_qbuffers_to_css(asd);
-		goto out;
-	}
-
-	if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED) {
-		atomisp_qbuffers_to_css(asd);
-		goto start_sensor;
-	}
-
-	css_pipe_id = atomisp_get_css_pipe_id(asd);
-
-	ret = atomisp_acc_load_extensions(asd);
-	if (ret < 0) {
-		dev_err(isp->dev, "acc extension failed to load\n");
-		goto out;
-	}
-
-	if (asd->params.css_update_params_needed) {
-		atomisp_apply_css_parameters(asd, &asd->params.css_param);
-		if (asd->params.css_param.update_flag.dz_config)
-			atomisp_css_set_dz_config(asd,
-				&asd->params.css_param.dz_config);
-		atomisp_css_update_isp_params(asd);
-		asd->params.css_update_params_needed = false;
-		memset(&asd->params.css_param.update_flag, 0,
-		       sizeof(struct atomisp_parameters));
-	}
-	asd->params.dvs_6axis = NULL;
-
-	ret = atomisp_css_start(asd, css_pipe_id, false);
-	if (ret)
-		goto out;
-
-	asd->streaming = ATOMISP_DEVICE_STREAMING_ENABLED;
-	atomic_set(&asd->sof_count, -1);
-	atomic_set(&asd->sequence, -1);
-	atomic_set(&asd->sequence_temp, -1);
-	if (isp->sw_contex.file_input)
-		wdt_duration = ATOMISP_ISP_FILE_TIMEOUT_DURATION;
-
-	asd->params.dis_proj_data_valid = false;
-	asd->latest_preview_exp_id = 0;
-	asd->postview_exp_id = 1;
-	asd->preview_exp_id = 1;
-
-	/* handle per_frame_setting parameter and buffers */
-	atomisp_handle_parameter_and_buffer(pipe);
-
-	atomisp_qbuffers_to_css(asd);
-
-	/* Only start sensor when the last streaming instance started */
-	if (atomisp_subdev_streaming_count(asd) < sensor_start_stream)
-		goto out;
-
-start_sensor:
-	if (isp->flash) {
-		asd->params.num_flash_frames = 0;
-		asd->params.flash_state = ATOMISP_FLASH_IDLE;
-		atomisp_setup_flash(asd);
-	}
-
-	if (!isp->sw_contex.file_input) {
-		atomisp_css_irq_enable(isp, CSS_IRQ_INFO_CSS_RECEIVER_SOF,
-				atomisp_css_valid_sof(isp));
-		atomisp_csi2_configure(asd);
-		/*
-		 * set freq to max when streaming count > 1 which indicate
-		 * dual camera would run
-		*/
-		if (atomisp_streaming_count(isp) > 1) {
-			if (atomisp_freq_scaling(isp,
-				ATOMISP_DFS_MODE_MAX, false) < 0)
-				dev_dbg(isp->dev, "dfs failed!\n");
-		} else {
-			if (atomisp_freq_scaling(isp,
-				ATOMISP_DFS_MODE_AUTO, false) < 0)
-				dev_dbg(isp->dev, "dfs failed!\n");
-		}
-	} else {
-		if (atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_MAX, false) < 0)
-			dev_dbg(isp->dev, "dfs failed!\n");
-	}
-
-	if (asd->depth_mode->val && atomisp_streaming_count(isp) ==
-			ATOMISP_DEPTH_SENSOR_STREAMON_COUNT) {
-		ret = atomisp_stream_on_master_slave_sensor(isp, false);
-		if (ret) {
-			dev_err(isp->dev, "master slave sensor stream on failed!\n");
-			goto out;
-		}
-#ifndef ISP2401
-		__wdt_on_master_slave_sensor(isp, wdt_duration);
-#else
-		__wdt_on_master_slave_sensor(pipe, wdt_duration, true);
-#endif
-		goto start_delay_wq;
-	} else if (asd->depth_mode->val && (atomisp_streaming_count(isp) <
-		   ATOMISP_DEPTH_SENSOR_STREAMON_COUNT)) {
-#ifdef ISP2401
-		__wdt_on_master_slave_sensor(pipe, wdt_duration, false);
-#endif
-		goto start_delay_wq;
-	}
-
-	/* Enable the CSI interface on ANN B0/K0 */
-	if (isp->media_dev.hw_revision >= ((ATOMISP_HW_REVISION_ISP2401 <<
-	    ATOMISP_HW_REVISION_SHIFT) | ATOMISP_HW_STEPPING_B0)) {
-		pci_write_config_word(isp->pdev, MRFLD_PCI_CSI_CONTROL,
-				      isp->saved_regs.csi_control |
-				      MRFLD_PCI_CSI_CONTROL_CSI_READY);
-	}
-
-	/* stream on the sensor */
-	ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-			       video, s_stream, 1);
-	if (ret) {
-		asd->streaming = ATOMISP_DEVICE_STREAMING_DISABLED;
-		ret = -EINVAL;
-		goto out;
-	}
-
-#ifndef ISP2401
-	if (atomisp_buffers_queued(asd))
-		atomisp_wdt_refresh(asd, wdt_duration);
-#else
-	if (atomisp_buffers_queued_pipe(pipe))
-		atomisp_wdt_refresh_pipe(pipe, wdt_duration);
-#endif
-
-start_delay_wq:
-	if (asd->continuous_mode->val) {
-		struct v4l2_mbus_framefmt *sink;
-
-		sink = atomisp_subdev_get_ffmt(&asd->subdev, NULL,
-				       V4L2_SUBDEV_FORMAT_ACTIVE,
-				       ATOMISP_SUBDEV_PAD_SINK);
-
-		reinit_completion(&asd->init_done);
-		asd->delayed_init = ATOMISP_DELAYED_INIT_QUEUED;
-		queue_work(asd->delayed_init_workq, &asd->delayed_init_work);
-		atomisp_css_set_cont_prev_start_time(isp,
-				ATOMISP_CALC_CSS_PREV_OVERLAP(sink->height));
-	} else {
-		asd->delayed_init = ATOMISP_DELAYED_INIT_NOT_QUEUED;
-	}
-out:
-	rt_mutex_unlock(&isp->mutex);
-	return ret;
-}
-
-int __atomisp_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
-	struct atomisp_sub_device *asd = pipe->asd;
-	struct atomisp_video_pipe *capture_pipe = NULL;
-	struct atomisp_video_pipe *vf_pipe = NULL;
-	struct atomisp_video_pipe *preview_pipe = NULL;
-	struct atomisp_video_pipe *video_pipe = NULL;
-	struct videobuf_buffer *vb, *_vb;
-	enum atomisp_css_pipe_id css_pipe_id;
-	int ret;
-	unsigned long flags;
-	bool first_streamoff = false;
-
-	dev_dbg(isp->dev, "Stop stream on pad %d for asd%d\n",
-		atomisp_subdev_source_pad(vdev), asd->index);
-
-	BUG_ON(!rt_mutex_is_locked(&isp->mutex));
-	BUG_ON(!mutex_is_locked(&isp->streamoff_mutex));
-
-	if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-		dev_dbg(isp->dev, "unsupported v4l2 buf type\n");
-		return -EINVAL;
-	}
-
-	/*
-	 * do only videobuf_streamoff for capture & vf pipes in
-	 * case of continuous capture
-	 */
-	if ((asd->continuous_mode->val ||
-	    isp->inputs[asd->input_curr].camera_caps->multi_stream_ctrl) &&
-	    atomisp_subdev_source_pad(vdev) !=
-		ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW &&
-	    atomisp_subdev_source_pad(vdev) !=
-		ATOMISP_SUBDEV_PAD_SOURCE_VIDEO) {
-
-		if (isp->inputs[asd->input_curr].camera_caps->multi_stream_ctrl) {
-			v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-				video, s_stream, 0);
-		} else if (atomisp_subdev_source_pad(vdev)
-		    == ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE) {
-			/* stop continuous still capture if needed */
-			if (asd->params.offline_parm.num_captures == -1)
-				atomisp_css_offline_capture_configure(asd,
-						0, 0, 0);
-			atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_AUTO, false);
-		}
-		/*
-		 * Currently there is no way to flush buffers queued to css.
-		 * When doing videobuf_streamoff, active buffers will be
-		 * marked as VIDEOBUF_NEEDS_INIT. HAL will be able to use
-		 * these buffers again, and these buffers might be queued to
-		 * css more than once! Warn here, if HAL has not dequeued all
-		 * buffers back before calling streamoff.
-		 */
-		if (pipe->buffers_in_css != 0) {
-			WARN(1, "%s: buffers of vdev %s still in CSS!\n",
-			     __func__, pipe->vdev.name);
-
-			/*
-			 * Buffers remained in css maybe dequeued out in the
-			 * next stream on, while this will causes serious
-			 * issues as buffers already get invalid after
-			 * previous stream off.
-			 *
-			 * No way to flush buffers but to reset the whole css
-			 */
-			dev_warn(isp->dev, "Reset CSS to clean up css buffers.\n");
-			atomisp_css_flush(isp);
-		}
-
-		return videobuf_streamoff(&pipe->capq);
-	}
-
-	if (!pipe->capq.streaming)
-		return 0;
-
-	spin_lock_irqsave(&isp->lock, flags);
-	if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED) {
-		asd->streaming = ATOMISP_DEVICE_STREAMING_STOPPING;
-		first_streamoff = true;
-	}
-	spin_unlock_irqrestore(&isp->lock, flags);
-
-	if (first_streamoff) {
-		/* if other streams are running, should not disable watch dog */
-		rt_mutex_unlock(&isp->mutex);
-		atomisp_wdt_stop(asd, true);
-
-		/*
-		 * must stop sending pixels into GP_FIFO before stop
-		 * the pipeline.
-		 */
-		if (isp->sw_contex.file_input)
-			v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-					video, s_stream, 0);
-
-		rt_mutex_lock(&isp->mutex);
-		atomisp_acc_unload_extensions(asd);
-	}
-
-	spin_lock_irqsave(&isp->lock, flags);
-	if (atomisp_subdev_streaming_count(asd) == 1)
-		asd->streaming = ATOMISP_DEVICE_STREAMING_DISABLED;
-	spin_unlock_irqrestore(&isp->lock, flags);
-
-	if (!first_streamoff) {
-		ret = videobuf_streamoff(&pipe->capq);
-		if (ret)
-			return ret;
-		goto stopsensor;
-	}
-
-	atomisp_clear_css_buffer_counters(asd);
-
-	if (!isp->sw_contex.file_input)
-		atomisp_css_irq_enable(isp, CSS_IRQ_INFO_CSS_RECEIVER_SOF,
-					false);
-
-	if (asd->delayed_init == ATOMISP_DELAYED_INIT_QUEUED) {
-		cancel_work_sync(&asd->delayed_init_work);
-		asd->delayed_init = ATOMISP_DELAYED_INIT_NOT_QUEUED;
-	}
-	if (first_streamoff) {
-		css_pipe_id = atomisp_get_css_pipe_id(asd);
-		ret = atomisp_css_stop(asd, css_pipe_id, false);
-	}
-	/* cancel work queue*/
-	if (asd->video_out_capture.users) {
-		capture_pipe = &asd->video_out_capture;
-		wake_up_interruptible(&capture_pipe->capq.wait);
-	}
-	if (asd->video_out_vf.users) {
-		vf_pipe = &asd->video_out_vf;
-		wake_up_interruptible(&vf_pipe->capq.wait);
-	}
-	if (asd->video_out_preview.users) {
-		preview_pipe = &asd->video_out_preview;
-		wake_up_interruptible(&preview_pipe->capq.wait);
-	}
-	if (asd->video_out_video_capture.users) {
-		video_pipe = &asd->video_out_video_capture;
-		wake_up_interruptible(&video_pipe->capq.wait);
-	}
-	ret = videobuf_streamoff(&pipe->capq);
-	if (ret)
-		return ret;
-
-	/* cleanup css here */
-	/* no need for this, as ISP will be reset anyway */
-	/*atomisp_flush_bufs_in_css(isp);*/
-
-	spin_lock_irqsave(&pipe->irq_lock, flags);
-	list_for_each_entry_safe(vb, _vb, &pipe->activeq, queue) {
-		vb->state = VIDEOBUF_PREPARED;
-		list_del(&vb->queue);
-	}
-	list_for_each_entry_safe(vb, _vb, &pipe->buffers_waiting_for_param, queue) {
-		vb->state = VIDEOBUF_PREPARED;
-		list_del(&vb->queue);
-		pipe->frame_request_config_id[vb->i] = 0;
-	}
-	spin_unlock_irqrestore(&pipe->irq_lock, flags);
-
-	atomisp_subdev_cleanup_pending_events(asd);
-stopsensor:
-	if (atomisp_subdev_streaming_count(asd) + 1
-	    != atomisp_sensor_start_stream(asd))
-		return 0;
-
-	if (!isp->sw_contex.file_input)
-		ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-				       video, s_stream, 0);
-
-	if (isp->flash) {
-		asd->params.num_flash_frames = 0;
-		asd->params.flash_state = ATOMISP_FLASH_IDLE;
-	}
-
-	/* if other streams are running, isp should not be powered off */
-	if (atomisp_streaming_count(isp)) {
-		atomisp_css_flush(isp);
-		return 0;
-	}
-
-	/* Disable the CSI interface on ANN B0/K0 */
-	if (isp->media_dev.hw_revision >= ((ATOMISP_HW_REVISION_ISP2401 <<
-	    ATOMISP_HW_REVISION_SHIFT) | ATOMISP_HW_STEPPING_B0)) {
-		pci_write_config_word(isp->pdev, MRFLD_PCI_CSI_CONTROL,
-				      isp->saved_regs.csi_control &
-				      ~MRFLD_PCI_CSI_CONTROL_CSI_READY);
-	}
-
-	if (atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, false))
-		dev_warn(isp->dev, "DFS failed.\n");
-	/*
-	 * ISP work around, need to reset isp
-	 * Is it correct time to reset ISP when first node does streamoff?
-	 */
-	if (isp->sw_contex.power_state == ATOM_ISP_POWER_UP) {
-		unsigned int i;
-		bool recreate_streams[MAX_STREAM_NUM] = {0};
-		if (isp->isp_timeout)
-			dev_err(isp->dev, "%s: Resetting with WA activated",
-				__func__);
-		/*
-		 * It is possible that the other asd stream is in the stage
-		 * that v4l2_setfmt is just get called on it, which will
-		 * create css stream on that stream. But at this point, there
-		 * is no way to destroy the css stream created on that stream.
-		 *
-		 * So force stream destroy here.
-		 */
-		for (i = 0; i < isp->num_of_streams; i++) {
-			if (isp->asd[i].stream_prepared) {
-				atomisp_destroy_pipes_stream_force(&isp->
-						asd[i]);
-				recreate_streams[i] = true;
-			}
-		}
-
-		/* disable  PUNIT/ISP acknowlede/handshake - SRSE=3 */
-		pci_write_config_dword(isp->pdev, PCI_I_CONTROL, isp->saved_regs.i_control |
-				MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK);
-		dev_err(isp->dev, "atomisp_reset");
-		atomisp_reset(isp);
-		for (i = 0; i < isp->num_of_streams; i++) {
-			if (recreate_streams[i])
-				atomisp_create_pipes_stream(&isp->asd[i]);
-		}
-		isp->isp_timeout = false;
-	}
-	return ret;
-}
-
-static int atomisp_streamoff(struct file *file, void *fh,
-			     enum v4l2_buf_type type)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	int rval;
-
-	mutex_lock(&isp->streamoff_mutex);
-	rt_mutex_lock(&isp->mutex);
-	rval = __atomisp_streamoff(file, fh, type);
-	rt_mutex_unlock(&isp->mutex);
-	mutex_unlock(&isp->streamoff_mutex);
-
-	return rval;
-}
-
-/*
- * To get the current value of a control.
- * applications initialize the id field of a struct v4l2_control and
- * call this ioctl with a pointer to this structure
- */
-static int atomisp_g_ctrl(struct file *file, void *fh,
-	struct v4l2_control *control)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	int i, ret = -EINVAL;
-
-	for (i = 0; i < ctrls_num; i++) {
-		if (ci_v4l2_controls[i].id == control->id) {
-			ret = 0;
-			break;
-		}
-	}
-
-	if (ret)
-		return ret;
-
-	rt_mutex_lock(&isp->mutex);
-
-	switch (control->id) {
-	case V4L2_CID_IRIS_ABSOLUTE:
-	case V4L2_CID_EXPOSURE_ABSOLUTE:
-	case V4L2_CID_FNUMBER_ABSOLUTE:
-	case V4L2_CID_2A_STATUS:
-	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
-	case V4L2_CID_EXPOSURE:
-	case V4L2_CID_EXPOSURE_AUTO:
-	case V4L2_CID_SCENE_MODE:
-	case V4L2_CID_ISO_SENSITIVITY:
-	case V4L2_CID_ISO_SENSITIVITY_AUTO:
-	case V4L2_CID_CONTRAST:
-	case V4L2_CID_SATURATION:
-	case V4L2_CID_SHARPNESS:
-	case V4L2_CID_3A_LOCK:
-	case V4L2_CID_EXPOSURE_ZONE_NUM:
-	case V4L2_CID_TEST_PATTERN:
-	case V4L2_CID_TEST_PATTERN_COLOR_R:
-	case V4L2_CID_TEST_PATTERN_COLOR_GR:
-	case V4L2_CID_TEST_PATTERN_COLOR_GB:
-	case V4L2_CID_TEST_PATTERN_COLOR_B:
-		rt_mutex_unlock(&isp->mutex);
-		return v4l2_g_ctrl(isp->inputs[asd->input_curr].camera->
-				   ctrl_handler, control);
-	case V4L2_CID_COLORFX:
-		ret = atomisp_color_effect(asd, 0, &control->value);
-		break;
-	case V4L2_CID_ATOMISP_BAD_PIXEL_DETECTION:
-		ret = atomisp_bad_pixel(asd, 0, &control->value);
-		break;
-	case V4L2_CID_ATOMISP_POSTPROCESS_GDC_CAC:
-		ret = atomisp_gdc_cac(asd, 0, &control->value);
-		break;
-	case V4L2_CID_ATOMISP_VIDEO_STABLIZATION:
-		ret = atomisp_video_stable(asd, 0, &control->value);
-		break;
-	case V4L2_CID_ATOMISP_FIXED_PATTERN_NR:
-		ret = atomisp_fixed_pattern(asd, 0, &control->value);
-		break;
-	case V4L2_CID_ATOMISP_FALSE_COLOR_CORRECTION:
-		ret = atomisp_false_color(asd, 0, &control->value);
-		break;
-	case V4L2_CID_ATOMISP_LOW_LIGHT:
-		ret = atomisp_low_light(asd, 0, &control->value);
-		break;
-	default:
-		ret = -EINVAL;
-		break;
-	}
-
-	rt_mutex_unlock(&isp->mutex);
-	return ret;
-}
-
-/*
- * To change the value of a control.
- * applications initialize the id and value fields of a struct v4l2_control
- * and call this ioctl.
- */
-static int atomisp_s_ctrl(struct file *file, void *fh,
-			  struct v4l2_control *control)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	int i, ret = -EINVAL;
-
-	for (i = 0; i < ctrls_num; i++) {
-		if (ci_v4l2_controls[i].id == control->id) {
-			ret = 0;
-			break;
-		}
-	}
-
-	if (ret)
-		return ret;
-
-	rt_mutex_lock(&isp->mutex);
-	switch (control->id) {
-	case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE:
-	case V4L2_CID_EXPOSURE:
-	case V4L2_CID_EXPOSURE_AUTO:
-	case V4L2_CID_EXPOSURE_AUTO_PRIORITY:
-	case V4L2_CID_SCENE_MODE:
-	case V4L2_CID_ISO_SENSITIVITY:
-	case V4L2_CID_ISO_SENSITIVITY_AUTO:
-	case V4L2_CID_POWER_LINE_FREQUENCY:
-	case V4L2_CID_EXPOSURE_METERING:
-	case V4L2_CID_CONTRAST:
-	case V4L2_CID_SATURATION:
-	case V4L2_CID_SHARPNESS:
-	case V4L2_CID_3A_LOCK:
-	case V4L2_CID_COLORFX_CBCR:
-	case V4L2_CID_TEST_PATTERN:
-	case V4L2_CID_TEST_PATTERN_COLOR_R:
-	case V4L2_CID_TEST_PATTERN_COLOR_GR:
-	case V4L2_CID_TEST_PATTERN_COLOR_GB:
-	case V4L2_CID_TEST_PATTERN_COLOR_B:
-		rt_mutex_unlock(&isp->mutex);
-		return v4l2_s_ctrl(NULL,
-				   isp->inputs[asd->input_curr].camera->
-				   ctrl_handler, control);
-	case V4L2_CID_COLORFX:
-		ret = atomisp_color_effect(asd, 1, &control->value);
-		break;
-	case V4L2_CID_ATOMISP_BAD_PIXEL_DETECTION:
-		ret = atomisp_bad_pixel(asd, 1, &control->value);
-		break;
-	case V4L2_CID_ATOMISP_POSTPROCESS_GDC_CAC:
-		ret = atomisp_gdc_cac(asd, 1, &control->value);
-		break;
-	case V4L2_CID_ATOMISP_VIDEO_STABLIZATION:
-		ret = atomisp_video_stable(asd, 1, &control->value);
-		break;
-	case V4L2_CID_ATOMISP_FIXED_PATTERN_NR:
-		ret = atomisp_fixed_pattern(asd, 1, &control->value);
-		break;
-	case V4L2_CID_ATOMISP_FALSE_COLOR_CORRECTION:
-		ret = atomisp_false_color(asd, 1, &control->value);
-		break;
-	case V4L2_CID_REQUEST_FLASH:
-		ret = atomisp_flash_enable(asd, control->value);
-		break;
-	case V4L2_CID_ATOMISP_LOW_LIGHT:
-		ret = atomisp_low_light(asd, 1, &control->value);
-		break;
-	default:
-		ret = -EINVAL;
-		break;
-	}
-	rt_mutex_unlock(&isp->mutex);
-	return ret;
-}
-/*
- * To query the attributes of a control.
- * applications set the id field of a struct v4l2_queryctrl and call the
- * this ioctl with a pointer to this structure. The driver fills
- * the rest of the structure.
- */
-static int atomisp_queryctl(struct file *file, void *fh,
-			    struct v4l2_queryctrl *qc)
-{
-	int i, ret = -EINVAL;
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-
-	switch (qc->id) {
-	case V4L2_CID_FOCUS_ABSOLUTE:
-	case V4L2_CID_FOCUS_RELATIVE:
-	case V4L2_CID_FOCUS_STATUS:
-#ifndef ISP2401
-		return v4l2_queryctrl(isp->inputs[asd->input_curr].camera->
-				      ctrl_handler, qc);
-#else
-		if (isp->motor)
-			return v4l2_queryctrl(isp->motor->ctrl_handler, qc);
-		else
-			return v4l2_queryctrl(isp->inputs[asd->input_curr].
-					      camera->ctrl_handler, qc);
-#endif
-	}
-
-	if (qc->id & V4L2_CTRL_FLAG_NEXT_CTRL)
-		return ret;
-
-	for (i = 0; i < ctrls_num; i++) {
-		if (ci_v4l2_controls[i].id == qc->id) {
-			memcpy(qc, &ci_v4l2_controls[i],
-			       sizeof(struct v4l2_queryctrl));
-			qc->reserved[0] = 0;
-			ret = 0;
-			break;
-		}
-	}
-	if (ret != 0)
-		qc->flags = V4L2_CTRL_FLAG_DISABLED;
-
-	return ret;
-}
-
-static int atomisp_camera_g_ext_ctrls(struct file *file, void *fh,
-	struct v4l2_ext_controls *c)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct v4l2_control ctrl;
-	int i;
-	int ret = 0;
-
-	for (i = 0; i < c->count; i++) {
-		ctrl.id = c->controls[i].id;
-		ctrl.value = c->controls[i].value;
-		switch (ctrl.id) {
-		case V4L2_CID_EXPOSURE_ABSOLUTE:
-		case V4L2_CID_EXPOSURE_AUTO:
-		case V4L2_CID_IRIS_ABSOLUTE:
-		case V4L2_CID_FNUMBER_ABSOLUTE:
-		case V4L2_CID_BIN_FACTOR_HORZ:
-		case V4L2_CID_BIN_FACTOR_VERT:
-		case V4L2_CID_3A_LOCK:
-		case V4L2_CID_TEST_PATTERN:
-		case V4L2_CID_TEST_PATTERN_COLOR_R:
-		case V4L2_CID_TEST_PATTERN_COLOR_GR:
-		case V4L2_CID_TEST_PATTERN_COLOR_GB:
-		case V4L2_CID_TEST_PATTERN_COLOR_B:
-			/*
-			 * Exposure related control will be handled by sensor
-			 * driver
-			 */
-			ret =
-			    v4l2_g_ctrl(isp->inputs[asd->input_curr].camera->
-					ctrl_handler, &ctrl);
-			break;
-		case V4L2_CID_FOCUS_ABSOLUTE:
-		case V4L2_CID_FOCUS_RELATIVE:
-		case V4L2_CID_FOCUS_STATUS:
-		case V4L2_CID_FOCUS_AUTO:
-#ifndef ISP2401
-			if (isp->inputs[asd->input_curr].motor)
-#else
-			if (isp->motor)
-#endif
-				ret =
-#ifndef ISP2401
-				    v4l2_g_ctrl(isp->inputs[asd->input_curr].
-						motor->ctrl_handler, &ctrl);
-#else
-				    v4l2_g_ctrl(isp->motor->ctrl_handler,
-						&ctrl);
-#endif
-			else
-				ret =
-				    v4l2_g_ctrl(isp->inputs[asd->input_curr].
-						camera->ctrl_handler, &ctrl);
-			break;
-		case V4L2_CID_FLASH_STATUS:
-		case V4L2_CID_FLASH_INTENSITY:
-		case V4L2_CID_FLASH_TORCH_INTENSITY:
-		case V4L2_CID_FLASH_INDICATOR_INTENSITY:
-		case V4L2_CID_FLASH_TIMEOUT:
-		case V4L2_CID_FLASH_STROBE:
-		case V4L2_CID_FLASH_MODE:
-		case V4L2_CID_FLASH_STATUS_REGISTER:
-			if (isp->flash)
-				ret =
-				    v4l2_g_ctrl(isp->flash->ctrl_handler,
-						&ctrl);
-			break;
-		case V4L2_CID_ZOOM_ABSOLUTE:
-			rt_mutex_lock(&isp->mutex);
-			ret = atomisp_digital_zoom(asd, 0, &ctrl.value);
-			rt_mutex_unlock(&isp->mutex);
-			break;
-		case V4L2_CID_G_SKIP_FRAMES:
-			ret = v4l2_subdev_call(
-				isp->inputs[asd->input_curr].camera,
-				sensor, g_skip_frames, (u32 *)&ctrl.value);
-			break;
-		default:
-			ret = -EINVAL;
-		}
-
-		if (ret) {
-			c->error_idx = i;
-			break;
-		}
-		c->controls[i].value = ctrl.value;
-	}
-	return ret;
-}
-
-/* This ioctl allows the application to get multiple controls by class */
-static int atomisp_g_ext_ctrls(struct file *file, void *fh,
-	struct v4l2_ext_controls *c)
-{
-	struct v4l2_control ctrl;
-	int i, ret = 0;
-
-	/* input_lock is not need for the Camera releated IOCTLs
-	 * The input_lock downgrade the FPS of 3A*/
-	ret = atomisp_camera_g_ext_ctrls(file, fh, c);
-	if (ret != -EINVAL)
-		return ret;
-
-	for (i = 0; i < c->count; i++) {
-		ctrl.id = c->controls[i].id;
-		ctrl.value = c->controls[i].value;
-		ret = atomisp_g_ctrl(file, fh, &ctrl);
-		c->controls[i].value = ctrl.value;
-		if (ret) {
-			c->error_idx = i;
-			break;
-		}
-	}
-	return ret;
-}
-
-static int atomisp_camera_s_ext_ctrls(struct file *file, void *fh,
-	struct v4l2_ext_controls *c)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct v4l2_control ctrl;
-	int i;
-	int ret = 0;
-
-	for (i = 0; i < c->count; i++) {
-		struct v4l2_ctrl *ctr;
-
-		ctrl.id = c->controls[i].id;
-		ctrl.value = c->controls[i].value;
-		switch (ctrl.id) {
-		case V4L2_CID_EXPOSURE_ABSOLUTE:
-		case V4L2_CID_EXPOSURE_AUTO:
-		case V4L2_CID_EXPOSURE_METERING:
-		case V4L2_CID_IRIS_ABSOLUTE:
-		case V4L2_CID_FNUMBER_ABSOLUTE:
-		case V4L2_CID_VCM_TIMEING:
-		case V4L2_CID_VCM_SLEW:
-		case V4L2_CID_3A_LOCK:
-		case V4L2_CID_TEST_PATTERN:
-		case V4L2_CID_TEST_PATTERN_COLOR_R:
-		case V4L2_CID_TEST_PATTERN_COLOR_GR:
-		case V4L2_CID_TEST_PATTERN_COLOR_GB:
-		case V4L2_CID_TEST_PATTERN_COLOR_B:
-			ret = v4l2_s_ctrl(NULL,
-					  isp->inputs[asd->input_curr].camera->
-					  ctrl_handler, &ctrl);
-			break;
-		case V4L2_CID_FOCUS_ABSOLUTE:
-		case V4L2_CID_FOCUS_RELATIVE:
-		case V4L2_CID_FOCUS_STATUS:
-		case V4L2_CID_FOCUS_AUTO:
-#ifndef ISP2401
-			if (isp->inputs[asd->input_curr].motor)
-#else
-			if (isp->motor)
-#endif
-				ret = v4l2_s_ctrl(NULL,
-#ifndef ISP2401
-						  isp->inputs[asd->input_curr].
-						  motor->ctrl_handler, &ctrl);
-#else
-						  isp->motor->ctrl_handler,
-						  &ctrl);
-#endif
-			else
-				ret = v4l2_s_ctrl(NULL,
-						  isp->inputs[asd->input_curr].
-						  camera->ctrl_handler, &ctrl);
-			break;
-		case V4L2_CID_FLASH_STATUS:
-		case V4L2_CID_FLASH_INTENSITY:
-		case V4L2_CID_FLASH_TORCH_INTENSITY:
-		case V4L2_CID_FLASH_INDICATOR_INTENSITY:
-		case V4L2_CID_FLASH_TIMEOUT:
-		case V4L2_CID_FLASH_STROBE:
-		case V4L2_CID_FLASH_MODE:
-		case V4L2_CID_FLASH_STATUS_REGISTER:
-			rt_mutex_lock(&isp->mutex);
-			if (isp->flash) {
-				ret =
-				    v4l2_s_ctrl(NULL, isp->flash->ctrl_handler,
-						&ctrl);
-				/* When flash mode is changed we need to reset
-				 * flash state */
-				if (ctrl.id == V4L2_CID_FLASH_MODE) {
-					asd->params.flash_state =
-						ATOMISP_FLASH_IDLE;
-					asd->params.num_flash_frames = 0;
-				}
-			}
-			rt_mutex_unlock(&isp->mutex);
-			break;
-		case V4L2_CID_ZOOM_ABSOLUTE:
-			rt_mutex_lock(&isp->mutex);
-			ret = atomisp_digital_zoom(asd, 1, &ctrl.value);
-			rt_mutex_unlock(&isp->mutex);
-			break;
-		default:
-			ctr = v4l2_ctrl_find(&asd->ctrl_handler, ctrl.id);
-			if (ctr)
-				ret = v4l2_ctrl_s_ctrl(ctr, ctrl.value);
-			else
-				ret = -EINVAL;
-		}
-
-		if (ret) {
-			c->error_idx = i;
-			break;
-		}
-		c->controls[i].value = ctrl.value;
-	}
-	return ret;
-}
-
-/* This ioctl allows the application to set multiple controls by class */
-static int atomisp_s_ext_ctrls(struct file *file, void *fh,
-	struct v4l2_ext_controls *c)
-{
-	struct v4l2_control ctrl;
-	int i, ret = 0;
-
-	/* input_lock is not need for the Camera releated IOCTLs
-	 * The input_lock downgrade the FPS of 3A*/
-	ret = atomisp_camera_s_ext_ctrls(file, fh, c);
-	if (ret != -EINVAL)
-		return ret;
-
-	for (i = 0; i < c->count; i++) {
-		ctrl.id = c->controls[i].id;
-		ctrl.value = c->controls[i].value;
-		ret = atomisp_s_ctrl(file, fh, &ctrl);
-		c->controls[i].value = ctrl.value;
-		if (ret) {
-			c->error_idx = i;
-			break;
-		}
-	}
-	return ret;
-}
-
-/*
- * vidioc_g/s_param are used to switch isp running mode
- */
-static int atomisp_g_parm(struct file *file, void *fh,
-	struct v4l2_streamparm *parm)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-
-	if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-		dev_err(isp->dev, "unsupport v4l2 buf type\n");
-		return -EINVAL;
-	}
-
-	rt_mutex_lock(&isp->mutex);
-	parm->parm.capture.capturemode = asd->run_mode->val;
-	rt_mutex_unlock(&isp->mutex);
-
-	return 0;
-}
-
-static int atomisp_s_parm(struct file *file, void *fh,
-	struct v4l2_streamparm *parm)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd;
-	int mode;
-	int rval;
-	int fps;
-
-	if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-		dev_err(isp->dev, "unsupport v4l2 buf type\n");
-		return -EINVAL;
-	}
-
-	rt_mutex_lock(&isp->mutex);
-
-	asd->high_speed_mode = false;
-	switch (parm->parm.capture.capturemode) {
-	case CI_MODE_NONE: {
-		struct v4l2_subdev_frame_interval fi = {0};
-
-		fi.interval = parm->parm.capture.timeperframe;
-
-		rval = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-					video, s_frame_interval, &fi);
-		if (!rval)
-			parm->parm.capture.timeperframe = fi.interval;
-
-		if (fi.interval.numerator != 0) {
-			fps = fi.interval.denominator / fi.interval.numerator;
-			if (fps > 30)
-				asd->high_speed_mode = true;
-		}
-
-		goto out;
-	}
-	case CI_MODE_VIDEO:
-		mode = ATOMISP_RUN_MODE_VIDEO;
-		break;
-	case CI_MODE_STILL_CAPTURE:
-		mode = ATOMISP_RUN_MODE_STILL_CAPTURE;
-		break;
-	case CI_MODE_CONTINUOUS:
-		mode = ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE;
-		break;
-	case CI_MODE_PREVIEW:
-		mode = ATOMISP_RUN_MODE_PREVIEW;
-		break;
-	default:
-		rval = -EINVAL;
-		goto out;
-	}
-
-	rval = v4l2_ctrl_s_ctrl(asd->run_mode, mode);
-
-out:
-	rt_mutex_unlock(&isp->mutex);
-
-	return rval == -ENOIOCTLCMD ? 0 : rval;
-}
-
-static int atomisp_s_parm_file(struct file *file, void *fh,
-				struct v4l2_streamparm *parm)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-
-	if (parm->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) {
-		dev_err(isp->dev, "unsupport v4l2 buf type for output\n");
-		return -EINVAL;
-	}
-
-	rt_mutex_lock(&isp->mutex);
-	isp->sw_contex.file_input = true;
-	rt_mutex_unlock(&isp->mutex);
-
-	return 0;
-}
-
-static long atomisp_vidioc_default(struct file *file, void *fh,
-	bool valid_prio, unsigned int cmd, void *arg)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct atomisp_device *isp = video_get_drvdata(vdev);
-	struct atomisp_sub_device *asd;
-	bool acc_node;
-	int err;
-
-	acc_node = !strcmp(vdev->name, "ATOMISP ISP ACC");
-	if (acc_node)
-		asd = atomisp_to_acc_pipe(vdev)->asd;
-	else
-		asd = atomisp_to_video_pipe(vdev)->asd;
-
-	switch (cmd) {
-	case ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA:
-	case ATOMISP_IOC_S_EXPOSURE:
-	case ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP:
-	case ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA:
-	case ATOMISP_IOC_EXT_ISP_CTRL:
-	case ATOMISP_IOC_G_SENSOR_AE_BRACKETING_INFO:
-	case ATOMISP_IOC_S_SENSOR_AE_BRACKETING_MODE:
-	case ATOMISP_IOC_G_SENSOR_AE_BRACKETING_MODE:
-	case ATOMISP_IOC_S_SENSOR_AE_BRACKETING_LUT:
-	case ATOMISP_IOC_S_SENSOR_EE_CONFIG:
-#ifdef ISP2401
-	case ATOMISP_IOC_G_UPDATE_EXPOSURE:
-#endif
-		/* we do not need take isp->mutex for these IOCTLs */
-		break;
-	default:
-		rt_mutex_lock(&isp->mutex);
-		break;
-	}
-	switch (cmd) {
-#ifdef ISP2401
-	case ATOMISP_IOC_S_SENSOR_RUNMODE:
-		err = atomisp_set_sensor_runmode(asd, arg);
-		break;
-
-#endif
-	case ATOMISP_IOC_G_XNR:
-		err = atomisp_xnr(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_XNR:
-		err = atomisp_xnr(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_G_NR:
-		err = atomisp_nr(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_NR:
-		err = atomisp_nr(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_G_TNR:
-		err = atomisp_tnr(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_TNR:
-		err = atomisp_tnr(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_G_BLACK_LEVEL_COMP:
-		err = atomisp_black_level(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_BLACK_LEVEL_COMP:
-		err = atomisp_black_level(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_G_EE:
-		err = atomisp_ee(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_EE:
-		err = atomisp_ee(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_G_DIS_STAT:
-		err = atomisp_get_dis_stat(asd, arg);
-		break;
-
-	case ATOMISP_IOC_G_DVS2_BQ_RESOLUTIONS:
-		err = atomisp_get_dvs2_bq_resolutions(asd, arg);
-		break;
-
-	case ATOMISP_IOC_S_DIS_COEFS:
-		err = atomisp_css_cp_dvs2_coefs(asd, arg,
-				&asd->params.css_param, true);
-		if (!err && arg)
-			asd->params.css_update_params_needed = true;
-		break;
-
-	case ATOMISP_IOC_S_DIS_VECTOR:
-		err = atomisp_cp_dvs_6axis_config(asd, arg,
-				&asd->params.css_param, true);
-		if (!err && arg)
-			asd->params.css_update_params_needed = true;
-		break;
-
-	case ATOMISP_IOC_G_ISP_PARM:
-		err = atomisp_param(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_ISP_PARM:
-		err = atomisp_param(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_G_3A_STAT:
-		err = atomisp_3a_stat(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_G_ISP_GAMMA:
-		err = atomisp_gamma(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_ISP_GAMMA:
-		err = atomisp_gamma(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_G_ISP_GDC_TAB:
-		err = atomisp_gdc_cac_table(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_ISP_GDC_TAB:
-		err = atomisp_gdc_cac_table(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_G_ISP_MACC:
-		err = atomisp_macc_table(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_ISP_MACC:
-		err = atomisp_macc_table(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_G_ISP_BAD_PIXEL_DETECTION:
-		err = atomisp_bad_pixel_param(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_ISP_BAD_PIXEL_DETECTION:
-		err = atomisp_bad_pixel_param(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_G_ISP_FALSE_COLOR_CORRECTION:
-		err = atomisp_false_color_param(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_ISP_FALSE_COLOR_CORRECTION:
-		err = atomisp_false_color_param(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_G_ISP_CTC:
-		err = atomisp_ctc(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_ISP_CTC:
-		err = atomisp_ctc(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_G_ISP_WHITE_BALANCE:
-		err = atomisp_white_balance_param(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_ISP_WHITE_BALANCE:
-		err = atomisp_white_balance_param(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_G_3A_CONFIG:
-		err = atomisp_3a_config_param(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_3A_CONFIG:
-		err = atomisp_3a_config_param(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_S_ISP_FPN_TABLE:
-		err = atomisp_fixed_pattern_table(asd, arg);
-		break;
-
-	case ATOMISP_IOC_ISP_MAKERNOTE:
-		err = atomisp_exif_makernote(asd, arg);
-		break;
-
-	case ATOMISP_IOC_G_SENSOR_MODE_DATA:
-		err = atomisp_get_sensor_mode_data(asd, arg);
-		break;
-
-	case ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA:
-#ifndef ISP2401
-		if (isp->inputs[asd->input_curr].motor)
-#else
-		if (isp->motor)
-#endif
-#ifndef ISP2401
-			err = v4l2_subdev_call(
-					isp->inputs[asd->input_curr].motor,
-					core, ioctl, cmd, arg);
-#else
-			err = v4l2_subdev_call(
-					isp->motor,
-					core, ioctl, cmd, arg);
-#endif
-		else
-			err = v4l2_subdev_call(
-					isp->inputs[asd->input_curr].camera,
-					core, ioctl, cmd, arg);
-		break;
-
-	case ATOMISP_IOC_S_EXPOSURE:
-	case ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP:
-	case ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA:
-	case ATOMISP_IOC_G_SENSOR_AE_BRACKETING_INFO:
-	case ATOMISP_IOC_S_SENSOR_AE_BRACKETING_MODE:
-	case ATOMISP_IOC_G_SENSOR_AE_BRACKETING_MODE:
-	case ATOMISP_IOC_S_SENSOR_AE_BRACKETING_LUT:
-#ifdef ISP2401
-	case ATOMISP_IOC_G_UPDATE_EXPOSURE:
-#endif
-		err = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-					core, ioctl, cmd, arg);
-		break;
-
-	case ATOMISP_IOC_ACC_LOAD:
-		err = atomisp_acc_load(asd, arg);
-		break;
-
-	case ATOMISP_IOC_ACC_LOAD_TO_PIPE:
-		err = atomisp_acc_load_to_pipe(asd, arg);
-		break;
-
-	case ATOMISP_IOC_ACC_UNLOAD:
-		err = atomisp_acc_unload(asd, arg);
-		break;
-
-	case ATOMISP_IOC_ACC_START:
-		err = atomisp_acc_start(asd, arg);
-		break;
-
-	case ATOMISP_IOC_ACC_WAIT:
-		err = atomisp_acc_wait(asd, arg);
-		break;
-
-	case ATOMISP_IOC_ACC_MAP:
-		err = atomisp_acc_map(asd, arg);
-		break;
-
-	case ATOMISP_IOC_ACC_UNMAP:
-		err = atomisp_acc_unmap(asd, arg);
-		break;
-
-	case ATOMISP_IOC_ACC_S_MAPPED_ARG:
-		err = atomisp_acc_s_mapped_arg(asd, arg);
-		break;
-
-	case ATOMISP_IOC_S_ISP_SHD_TAB:
-		err = atomisp_set_shading_table(asd, arg);
-		break;
-
-	case ATOMISP_IOC_G_ISP_GAMMA_CORRECTION:
-		err = atomisp_gamma_correction(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_ISP_GAMMA_CORRECTION:
-		err = atomisp_gamma_correction(asd, 1, arg);
-		break;
-
-	case ATOMISP_IOC_S_PARAMETERS:
-		err = atomisp_set_parameters(vdev, arg);
-		break;
-
-	case ATOMISP_IOC_S_CONT_CAPTURE_CONFIG:
-		err = atomisp_offline_capture_configure(asd, arg);
-		break;
-	case ATOMISP_IOC_G_METADATA:
-		err = atomisp_get_metadata(asd, 0, arg);
-		break;
-	case ATOMISP_IOC_G_METADATA_BY_TYPE:
-		err = atomisp_get_metadata_by_type(asd, 0, arg);
-		break;
-	case ATOMISP_IOC_EXT_ISP_CTRL:
-		err = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-					core, ioctl, cmd, arg);
-		break;
-	case ATOMISP_IOC_EXP_ID_UNLOCK:
-		err = atomisp_exp_id_unlock(asd, arg);
-		break;
-	case ATOMISP_IOC_EXP_ID_CAPTURE:
-		err = atomisp_exp_id_capture(asd, arg);
-		break;
-	case ATOMISP_IOC_S_ENABLE_DZ_CAPT_PIPE:
-		err = atomisp_enable_dz_capt_pipe(asd, arg);
-		break;
-	case ATOMISP_IOC_G_FORMATS_CONFIG:
-		err = atomisp_formats(asd, 0, arg);
-		break;
-
-	case ATOMISP_IOC_S_FORMATS_CONFIG:
-		err = atomisp_formats(asd, 1, arg);
-		break;
-	case ATOMISP_IOC_S_EXPOSURE_WINDOW:
-		err = atomisp_s_ae_window(asd, arg);
-		break;
-	case ATOMISP_IOC_S_ACC_STATE:
-		err = atomisp_acc_set_state(asd, arg);
-		break;
-	case ATOMISP_IOC_G_ACC_STATE:
-		err = atomisp_acc_get_state(asd, arg);
-		break;
-	case ATOMISP_IOC_INJECT_A_FAKE_EVENT:
-		err = atomisp_inject_a_fake_event(asd, arg);
-		break;
-	case ATOMISP_IOC_G_INVALID_FRAME_NUM:
-		err = atomisp_get_invalid_frame_num(vdev, arg);
-		break;
-	case ATOMISP_IOC_S_ARRAY_RESOLUTION:
-		err = atomisp_set_array_res(asd, arg);
-		break;
-	default:
-		err = -EINVAL;
-		break;
-	}
-
-	switch (cmd) {
-	case ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA:
-	case ATOMISP_IOC_S_EXPOSURE:
-	case ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP:
-	case ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA:
-	case ATOMISP_IOC_EXT_ISP_CTRL:
-	case ATOMISP_IOC_G_SENSOR_AE_BRACKETING_INFO:
-	case ATOMISP_IOC_S_SENSOR_AE_BRACKETING_MODE:
-	case ATOMISP_IOC_G_SENSOR_AE_BRACKETING_MODE:
-	case ATOMISP_IOC_S_SENSOR_AE_BRACKETING_LUT:
-#ifdef ISP2401
-	case ATOMISP_IOC_G_UPDATE_EXPOSURE:
-#endif
-		break;
-	default:
-		rt_mutex_unlock(&isp->mutex);
-		break;
-	}
-	return err;
-}
-
-const struct v4l2_ioctl_ops atomisp_ioctl_ops = {
-	.vidioc_querycap = atomisp_querycap,
-	.vidioc_enum_input = atomisp_enum_input,
-	.vidioc_g_input = atomisp_g_input,
-	.vidioc_s_input = atomisp_s_input,
-	.vidioc_queryctrl = atomisp_queryctl,
-	.vidioc_s_ctrl = atomisp_s_ctrl,
-	.vidioc_g_ctrl = atomisp_g_ctrl,
-	.vidioc_s_ext_ctrls = atomisp_s_ext_ctrls,
-	.vidioc_g_ext_ctrls = atomisp_g_ext_ctrls,
-	.vidioc_enum_fmt_vid_cap = atomisp_enum_fmt_cap,
-	.vidioc_try_fmt_vid_cap = atomisp_try_fmt_cap,
-	.vidioc_g_fmt_vid_cap = atomisp_g_fmt_cap,
-	.vidioc_s_fmt_vid_cap = atomisp_s_fmt_cap,
-	.vidioc_reqbufs = atomisp_reqbufs,
-	.vidioc_querybuf = atomisp_querybuf,
-	.vidioc_qbuf = atomisp_qbuf,
-	.vidioc_dqbuf = atomisp_dqbuf,
-	.vidioc_streamon = atomisp_streamon,
-	.vidioc_streamoff = atomisp_streamoff,
-	.vidioc_default = atomisp_vidioc_default,
-	.vidioc_s_parm = atomisp_s_parm,
-	.vidioc_g_parm = atomisp_g_parm,
-};
-
-const struct v4l2_ioctl_ops atomisp_file_ioctl_ops = {
-	.vidioc_querycap = atomisp_querycap,
-	.vidioc_g_fmt_vid_out = atomisp_g_fmt_file,
-	.vidioc_s_fmt_vid_out = atomisp_s_fmt_file,
-	.vidioc_s_parm = atomisp_s_parm_file,
-	.vidioc_reqbufs = atomisp_reqbufs_file,
-	.vidioc_querybuf = atomisp_querybuf_file,
-	.vidioc_qbuf = atomisp_qbuf_file,
-};

+ 0 - 69
drivers/staging/media/atomisp/pci/atomisp2/atomisp_ioctl.h

@@ -1,69 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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	__ATOMISP_IOCTL_H__
-#define	__ATOMISP_IOCTL_H__
-
-#include "ia_css.h"
-
-struct atomisp_device;
-struct atomisp_video_pipe;
-
-extern const struct atomisp_format_bridge atomisp_output_fmts[];
-
-const struct atomisp_format_bridge *atomisp_get_format_bridge(
-	unsigned int pixelformat);
-#ifndef ISP2401
-const struct atomisp_format_bridge *atomisp_get_format_bridge_from_mbus(
-	u32 mbus_code);
-#else
-const struct atomisp_format_bridge *atomisp_get_format_bridge_from_mbus(u32
-									mbus_code);
-#endif
-
-int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd,
-	uint16_t stream_id);
-
-int __atomisp_streamoff(struct file *file, void *fh, enum v4l2_buf_type type);
-int __atomisp_reqbufs(struct file *file, void *fh,
-		struct v4l2_requestbuffers *req);
-
-int atomisp_reqbufs(struct file *file, void *fh,
-			struct v4l2_requestbuffers *req);
-
-enum atomisp_css_pipe_id atomisp_get_css_pipe_id(struct atomisp_sub_device
-						 *asd);
-
-void atomisp_videobuf_free_buf(struct videobuf_buffer *vb);
-
-extern const struct v4l2_file_operations atomisp_file_fops;
-
-extern const struct v4l2_ioctl_ops atomisp_ioctl_ops;
-
-extern const struct v4l2_ioctl_ops atomisp_file_ioctl_ops;
-
-unsigned int atomisp_streaming_count(struct atomisp_device *isp);
-
-unsigned int atomisp_is_acc_enabled(struct atomisp_device *isp);
-/* compat_ioctl for 32bit userland app and 64bit kernel */
-long atomisp_compat_ioctl32(struct file *file,
-			    unsigned int cmd, unsigned long arg);
-
-int atomisp_stream_on_master_slave_sensor(struct atomisp_device *isp, bool isp_timeout);
-#endif /* __ATOMISP_IOCTL_H__ */

+ 0 - 1422
drivers/staging/media/atomisp/pci/atomisp2/atomisp_subdev.c

@@ -1,1422 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- *
- */
-#include <linux/module.h>
-#include <linux/uaccess.h>
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/mm.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-
-#include <media/v4l2-event.h>
-#include <media/v4l2-mediabus.h>
-#include "atomisp_cmd.h"
-#include "atomisp_common.h"
-#include "atomisp_compat.h"
-#include "atomisp_internal.h"
-
-const struct atomisp_in_fmt_conv atomisp_in_fmt_conv[] = {
-	{ MEDIA_BUS_FMT_SBGGR8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, CSS_BAYER_ORDER_BGGR, CSS_FORMAT_RAW_8 },
-	{ MEDIA_BUS_FMT_SGBRG8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, CSS_BAYER_ORDER_GBRG, CSS_FORMAT_RAW_8 },
-	{ MEDIA_BUS_FMT_SGRBG8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, CSS_BAYER_ORDER_GRBG, CSS_FORMAT_RAW_8 },
-	{ MEDIA_BUS_FMT_SRGGB8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, CSS_BAYER_ORDER_RGGB, CSS_FORMAT_RAW_8 },
-	{ MEDIA_BUS_FMT_SBGGR10_1X10, 10, 10, ATOMISP_INPUT_FORMAT_RAW_10, CSS_BAYER_ORDER_BGGR, CSS_FORMAT_RAW_10 },
-	{ MEDIA_BUS_FMT_SGBRG10_1X10, 10, 10, ATOMISP_INPUT_FORMAT_RAW_10, CSS_BAYER_ORDER_GBRG, CSS_FORMAT_RAW_10 },
-	{ MEDIA_BUS_FMT_SGRBG10_1X10, 10, 10, ATOMISP_INPUT_FORMAT_RAW_10, CSS_BAYER_ORDER_GRBG, CSS_FORMAT_RAW_10 },
-	{ MEDIA_BUS_FMT_SRGGB10_1X10, 10, 10, ATOMISP_INPUT_FORMAT_RAW_10, CSS_BAYER_ORDER_RGGB, CSS_FORMAT_RAW_10 },
-	{ MEDIA_BUS_FMT_SBGGR12_1X12, 12, 12, ATOMISP_INPUT_FORMAT_RAW_12, CSS_BAYER_ORDER_BGGR, CSS_FORMAT_RAW_12 },
-	{ MEDIA_BUS_FMT_SGBRG12_1X12, 12, 12, ATOMISP_INPUT_FORMAT_RAW_12, CSS_BAYER_ORDER_GBRG, CSS_FORMAT_RAW_12 },
-	{ MEDIA_BUS_FMT_SGRBG12_1X12, 12, 12, ATOMISP_INPUT_FORMAT_RAW_12, CSS_BAYER_ORDER_GRBG, CSS_FORMAT_RAW_12 },
-	{ MEDIA_BUS_FMT_SRGGB12_1X12, 12, 12, ATOMISP_INPUT_FORMAT_RAW_12, CSS_BAYER_ORDER_RGGB, CSS_FORMAT_RAW_12 },
-	{ MEDIA_BUS_FMT_UYVY8_1X16, 8, 8, ATOMISP_INPUT_FORMAT_YUV422_8, 0, ATOMISP_INPUT_FORMAT_YUV422_8 },
-	{ MEDIA_BUS_FMT_YUYV8_1X16, 8, 8, ATOMISP_INPUT_FORMAT_YUV422_8, 0, ATOMISP_INPUT_FORMAT_YUV422_8 },
-	{ MEDIA_BUS_FMT_JPEG_1X8, 8, 8, CSS_FRAME_FORMAT_BINARY_8, 0, ATOMISP_INPUT_FORMAT_BINARY_8 },
-	{ V4L2_MBUS_FMT_CUSTOM_NV12, 12, 12, CSS_FRAME_FORMAT_NV12, 0, CSS_FRAME_FORMAT_NV12 },
-	{ V4L2_MBUS_FMT_CUSTOM_NV21, 12, 12, CSS_FRAME_FORMAT_NV21, 0, CSS_FRAME_FORMAT_NV21 },
-	{ V4L2_MBUS_FMT_CUSTOM_YUV420, 12, 12, ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY, 0, ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY },
-#if 0
-	{ V4L2_MBUS_FMT_CUSTOM_M10MO_RAW, 8, 8, CSS_FRAME_FORMAT_BINARY_8, 0, ATOMISP_INPUT_FORMAT_BINARY_8 },
-#endif
-	/* no valid V4L2 MBUS code for metadata format, so leave it 0. */
-	{ 0, 0, 0, ATOMISP_INPUT_FORMAT_EMBEDDED, 0, ATOMISP_INPUT_FORMAT_EMBEDDED },
-	{}
-};
-
-static const struct {
-	u32 code;
-	u32 compressed;
-} compressed_codes[] = {
-	{ MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8 },
-	{ MEDIA_BUS_FMT_SGBRG10_1X10, MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8 },
-	{ MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8 },
-	{ MEDIA_BUS_FMT_SRGGB10_1X10, MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8 },
-};
-
-u32 atomisp_subdev_uncompressed_code(u32 code)
-{
-	unsigned int i;
-
-	for (i = 0; i < ARRAY_SIZE(compressed_codes); i++)
-		if (code == compressed_codes[i].compressed)
-			return compressed_codes[i].code;
-
-	return code;
-}
-
-bool atomisp_subdev_is_compressed(u32 code)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(atomisp_in_fmt_conv) - 1; i++)
-		if (code == atomisp_in_fmt_conv[i].code)
-			return atomisp_in_fmt_conv[i].bpp !=
-			       atomisp_in_fmt_conv[i].depth;
-
-	return false;
-}
-
-const struct atomisp_in_fmt_conv *atomisp_find_in_fmt_conv(u32 code)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(atomisp_in_fmt_conv) - 1; i++)
-		if (code == atomisp_in_fmt_conv[i].code)
-			return atomisp_in_fmt_conv + i;
-
-	return NULL;
-}
-
-const struct atomisp_in_fmt_conv *atomisp_find_in_fmt_conv_by_atomisp_in_fmt(
-	enum atomisp_input_format atomisp_in_fmt)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(atomisp_in_fmt_conv) - 1; i++)
-		if (atomisp_in_fmt_conv[i].atomisp_in_fmt == atomisp_in_fmt)
-			return atomisp_in_fmt_conv + i;
-
-	return NULL;
-}
-
-bool atomisp_subdev_format_conversion(struct atomisp_sub_device *asd,
-				      unsigned int source_pad)
-{
-	struct v4l2_mbus_framefmt *sink, *src;
-
-	sink = atomisp_subdev_get_ffmt(&asd->subdev, NULL,
-				       V4L2_SUBDEV_FORMAT_ACTIVE,
-				       ATOMISP_SUBDEV_PAD_SINK);
-	src = atomisp_subdev_get_ffmt(&asd->subdev, NULL,
-				      V4L2_SUBDEV_FORMAT_ACTIVE, source_pad);
-
-	return atomisp_is_mbuscode_raw(sink->code)
-		&& !atomisp_is_mbuscode_raw(src->code);
-}
-
-uint16_t atomisp_subdev_source_pad(struct video_device * vdev)
-{
-	struct media_link *link;
-	uint16_t ret = 0;
-	list_for_each_entry(link, &vdev->entity.links, list) {
-		if (link->source) {
-			ret = link->source->index;
-			break;
-		}
-	}
-	return ret;
-}
-
-/*
- * V4L2 subdev operations
- */
-
-/*
- * isp_subdev_ioctl - CCDC module private ioctl's
- * @sd: ISP V4L2 subdevice
- * @cmd: ioctl command
- * @arg: ioctl argument
- *
- * Return 0 on success or a negative error code otherwise.
- */
-static long isp_subdev_ioctl(struct v4l2_subdev *sd,
-	unsigned int cmd, void *arg)
-{
-	return 0;
-}
-
-/*
- * isp_subdev_set_power - Power on/off the CCDC module
- * @sd: ISP V4L2 subdevice
- * @on: power on/off
- *
- * Return 0 on success or a negative error code otherwise.
- */
-static int isp_subdev_set_power(struct v4l2_subdev *sd, int on)
-{
-	return 0;
-}
-
-static int isp_subdev_subscribe_event(struct v4l2_subdev *sd,
-				      struct v4l2_fh *fh,
-				      struct v4l2_event_subscription *sub)
-{
-	struct atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);
-	struct atomisp_device *isp = isp_sd->isp;
-
-	if (sub->type != V4L2_EVENT_FRAME_SYNC &&
-	    sub->type != V4L2_EVENT_FRAME_END &&
-	    sub->type != V4L2_EVENT_ATOMISP_3A_STATS_READY &&
-	    sub->type != V4L2_EVENT_ATOMISP_METADATA_READY &&
-	    sub->type != V4L2_EVENT_ATOMISP_PAUSE_BUFFER &&
-	    sub->type != V4L2_EVENT_ATOMISP_CSS_RESET &&
-	    sub->type != V4L2_EVENT_ATOMISP_RAW_BUFFERS_ALLOC_DONE &&
-	    sub->type != V4L2_EVENT_ATOMISP_ACC_COMPLETE)
-		return -EINVAL;
-
-	if (sub->type == V4L2_EVENT_FRAME_SYNC &&
-			!atomisp_css_valid_sof(isp))
-		return -EINVAL;
-
-	return v4l2_event_subscribe(fh, sub, 16, NULL);
-}
-
-static int isp_subdev_unsubscribe_event(struct v4l2_subdev *sd,
-					struct v4l2_fh *fh,
-					struct v4l2_event_subscription *sub)
-{
-	return v4l2_event_unsubscribe(fh, sub);
-}
-
-/*
- * isp_subdev_enum_mbus_code - Handle pixel format enumeration
- * @sd: pointer to v4l2 subdev structure
- * @fh : V4L2 subdev file handle
- * @code: pointer to v4l2_subdev_pad_mbus_code_enum structure
- * return -EINVAL or zero on success
- */
-static int isp_subdev_enum_mbus_code(struct v4l2_subdev *sd,
-				     struct v4l2_subdev_pad_config *cfg,
-				     struct v4l2_subdev_mbus_code_enum *code)
-{
-	if (code->index >= ARRAY_SIZE(atomisp_in_fmt_conv) - 1)
-		return -EINVAL;
-
-	code->code = atomisp_in_fmt_conv[code->index].code;
-
-	return 0;
-}
-
-static int isp_subdev_validate_rect(struct v4l2_subdev *sd, uint32_t pad,
-				    uint32_t target)
-{
-	switch (pad) {
-	case ATOMISP_SUBDEV_PAD_SINK:
-		switch (target) {
-		case V4L2_SEL_TGT_CROP:
-			return 0;
-		}
-		break;
-	default:
-		switch (target) {
-		case V4L2_SEL_TGT_COMPOSE:
-			return 0;
-		}
-		break;
-	}
-
-	return -EINVAL;
-}
-
-struct v4l2_rect *atomisp_subdev_get_rect(struct v4l2_subdev *sd,
-					  struct v4l2_subdev_pad_config *cfg,
-					  uint32_t which, uint32_t pad,
-					  uint32_t target)
-{
-	struct atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);
-
-	if (which == V4L2_SUBDEV_FORMAT_TRY) {
-		switch (target) {
-		case V4L2_SEL_TGT_CROP:
-			return v4l2_subdev_get_try_crop(sd, cfg, pad);
-		case V4L2_SEL_TGT_COMPOSE:
-			return v4l2_subdev_get_try_compose(sd, cfg, pad);
-		}
-	}
-
-	switch (target) {
-	case V4L2_SEL_TGT_CROP:
-		return &isp_sd->fmt[pad].crop;
-	case V4L2_SEL_TGT_COMPOSE:
-		return &isp_sd->fmt[pad].compose;
-	}
-
-	return NULL;
-}
-
-struct v4l2_mbus_framefmt
-*atomisp_subdev_get_ffmt(struct v4l2_subdev *sd,
-			 struct v4l2_subdev_pad_config *cfg, uint32_t which,
-			 uint32_t pad)
-{
-	struct atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);
-
-	if (which == V4L2_SUBDEV_FORMAT_TRY)
-		return v4l2_subdev_get_try_format(sd, cfg, pad);
-
-	return &isp_sd->fmt[pad].fmt;
-}
-
-static void isp_get_fmt_rect(struct v4l2_subdev *sd,
-			     struct v4l2_subdev_pad_config *cfg, uint32_t which,
-			     struct v4l2_mbus_framefmt **ffmt,
-			     struct v4l2_rect *crop[ATOMISP_SUBDEV_PADS_NUM],
-			     struct v4l2_rect *comp[ATOMISP_SUBDEV_PADS_NUM])
-{
-	unsigned int i;
-
-	for (i = 0; i < ATOMISP_SUBDEV_PADS_NUM; i++) {
-		ffmt[i] = atomisp_subdev_get_ffmt(sd, cfg, which, i);
-		crop[i] = atomisp_subdev_get_rect(sd, cfg, which, i,
-						  V4L2_SEL_TGT_CROP);
-		comp[i] = atomisp_subdev_get_rect(sd, cfg, which, i,
-						  V4L2_SEL_TGT_COMPOSE);
-	}
-}
-
-static void isp_subdev_propagate(struct v4l2_subdev *sd,
-				 struct v4l2_subdev_pad_config *cfg,
-				 uint32_t which, uint32_t pad, uint32_t target,
-				 uint32_t flags)
-{
-	struct v4l2_mbus_framefmt *ffmt[ATOMISP_SUBDEV_PADS_NUM];
-	struct v4l2_rect *crop[ATOMISP_SUBDEV_PADS_NUM],
-		*comp[ATOMISP_SUBDEV_PADS_NUM];
-
-	if (flags & V4L2_SEL_FLAG_KEEP_CONFIG)
-		return;
-
-	isp_get_fmt_rect(sd, cfg, which, ffmt, crop, comp);
-
-	switch (pad) {
-	case ATOMISP_SUBDEV_PAD_SINK: {
-		struct v4l2_rect r = {0};
-
-		/* Only crop target supported on sink pad. */
-		r.width = ffmt[pad]->width;
-		r.height = ffmt[pad]->height;
-
-		atomisp_subdev_set_selection(sd, cfg, which, pad,
-					     target, flags, &r);
-		break;
-	}
-	}
-}
-
-static int isp_subdev_get_selection(struct v4l2_subdev *sd,
-				    struct v4l2_subdev_pad_config *cfg,
-				    struct v4l2_subdev_selection *sel)
-{
-	struct v4l2_rect *rec;
-	int rval = isp_subdev_validate_rect(sd, sel->pad, sel->target);
-
-	if (rval)
-		return rval;
-
-	rec = atomisp_subdev_get_rect(sd, cfg, sel->which, sel->pad,
-					sel->target);
-	if (!rec)
-		return -EINVAL;
-
-	sel->r = *rec;
-	return 0;
-}
-
-static char *atomisp_pad_str[] = { "ATOMISP_SUBDEV_PAD_SINK",
-				   "ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE",
-				   "ATOMISP_SUBDEV_PAD_SOURCE_VF",
-				   "ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW",
-				   "ATOMISP_SUBDEV_PAD_SOURCE_VIDEO"};
-
-int atomisp_subdev_set_selection(struct v4l2_subdev *sd,
-				 struct v4l2_subdev_pad_config *cfg,
-				 uint32_t which, uint32_t pad, uint32_t target,
-				 uint32_t flags, struct v4l2_rect *r)
-{
-	struct atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);
-	struct atomisp_device *isp = isp_sd->isp;
-	struct v4l2_mbus_framefmt *ffmt[ATOMISP_SUBDEV_PADS_NUM];
-	uint16_t vdev_pad = atomisp_subdev_source_pad(sd->devnode);
-	struct v4l2_rect *crop[ATOMISP_SUBDEV_PADS_NUM],
-		*comp[ATOMISP_SUBDEV_PADS_NUM];
-	enum atomisp_input_stream_id stream_id;
-	unsigned int i;
-	unsigned int padding_w = pad_w;
-	unsigned int padding_h = pad_h;
-
-	stream_id = atomisp_source_pad_to_stream_id(isp_sd, vdev_pad);
-
-	isp_get_fmt_rect(sd, cfg, which, ffmt, crop, comp);
-
-	dev_dbg(isp->dev,
-		"sel: pad %s tgt %s l %d t %d w %d h %d which %s f 0x%8.8x\n",
-		atomisp_pad_str[pad], target == V4L2_SEL_TGT_CROP
-		? "V4L2_SEL_TGT_CROP" : "V4L2_SEL_TGT_COMPOSE",
-		r->left, r->top, r->width, r->height,
-		which == V4L2_SUBDEV_FORMAT_TRY ? "V4L2_SUBDEV_FORMAT_TRY"
-		: "V4L2_SUBDEV_FORMAT_ACTIVE", flags);
-
-	r->width = rounddown(r->width, ATOM_ISP_STEP_WIDTH);
-	r->height = rounddown(r->height, ATOM_ISP_STEP_HEIGHT);
-
-	switch (pad) {
-	case ATOMISP_SUBDEV_PAD_SINK: {
-		/* Only crop target supported on sink pad. */
-		unsigned int dvs_w, dvs_h;
-
-		crop[pad]->width = ffmt[pad]->width;
-		crop[pad]->height = ffmt[pad]->height;
-
-		/* Workaround for BYT 1080p perfectshot since the maxinum resolution of
-		 * front camera ov2722 is 1932x1092 and cannot use pad_w > 12*/
-		if (!strncmp(isp->inputs[isp_sd->input_curr].camera->name,
-				"ov2722", 6) && crop[pad]->height == 1092) {
-			padding_w = 12;
-			padding_h = 12;
-		}
-
-		if (isp->inputs[isp_sd->input_curr].type == SOC_CAMERA) {
-			padding_w = 0;
-			padding_h = 0;
-		}
-
-		if (atomisp_subdev_format_conversion(isp_sd,
-						     isp_sd->capture_pad)
-		    && crop[pad]->width && crop[pad]->height)
-			crop[pad]->width -= padding_w, crop[pad]->height -= padding_h;
-
-		/* if subdev type is SOC camera,we do not need to set DVS */
-		if (isp->inputs[isp_sd->input_curr].type == SOC_CAMERA)
-			isp_sd->params.video_dis_en = 0;
-
-		if (isp_sd->params.video_dis_en &&
-		    isp_sd->run_mode->val == ATOMISP_RUN_MODE_VIDEO &&
-		    !isp_sd->continuous_mode->val) {
-			/* This resolution contains 20 % of DVS slack
-			 * (of the desired captured image before
-			 * scaling, or 1 / 6 of what we get from the
-			 * sensor) in both width and height. Remove
-			 * it. */
-			crop[pad]->width = roundup(crop[pad]->width * 5 / 6,
-						   ATOM_ISP_STEP_WIDTH);
-			crop[pad]->height = roundup(crop[pad]->height * 5 / 6,
-						    ATOM_ISP_STEP_HEIGHT);
-		}
-
-		crop[pad]->width = min(crop[pad]->width, r->width);
-		crop[pad]->height = min(crop[pad]->height, r->height);
-
-		if (!(flags & V4L2_SEL_FLAG_KEEP_CONFIG)) {
-			for (i = ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE;
-			     i < ATOMISP_SUBDEV_PADS_NUM; i++) {
-				struct v4l2_rect tmp = *crop[pad];
-
-				atomisp_subdev_set_selection(
-					sd, cfg, which, i, V4L2_SEL_TGT_COMPOSE,
-					flags, &tmp);
-			}
-		}
-
-		if (which == V4L2_SUBDEV_FORMAT_TRY)
-			break;
-
-		if (isp_sd->params.video_dis_en &&
-		    isp_sd->run_mode->val == ATOMISP_RUN_MODE_VIDEO &&
-		    !isp_sd->continuous_mode->val) {
-			dvs_w = rounddown(crop[pad]->width / 5,
-					  ATOM_ISP_STEP_WIDTH);
-			dvs_h = rounddown(crop[pad]->height / 5,
-					  ATOM_ISP_STEP_HEIGHT);
-		} else if (!isp_sd->params.video_dis_en &&
-			   isp_sd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) {
-			/*
-			 * For CSS2.0, digital zoom needs to set dvs envelope to 12
-			 * when dvs is disabled.
-			 */
-			dvs_w = dvs_h = 12;
-		} else
-			dvs_w = dvs_h = 0;
-
-		atomisp_css_video_set_dis_envelope(isp_sd, dvs_w, dvs_h);
-		atomisp_css_input_set_effective_resolution(isp_sd, stream_id,
-					crop[pad]->width, crop[pad]->height);
-
-		break;
-	}
-	case ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE:
-	case ATOMISP_SUBDEV_PAD_SOURCE_VIDEO: {
-		/* Only compose target is supported on source pads. */
-
-		if (isp_sd->vfpp->val == ATOMISP_VFPP_DISABLE_LOWLAT) {
-			/* Scaling is disabled in this mode */
-			r->width = crop[ATOMISP_SUBDEV_PAD_SINK]->width;
-			r->height = crop[ATOMISP_SUBDEV_PAD_SINK]->height;
-		}
-
-		if (crop[ATOMISP_SUBDEV_PAD_SINK]->width == r->width
-		    && crop[ATOMISP_SUBDEV_PAD_SINK]->height == r->height)
-			isp_sd->params.yuv_ds_en = false;
-		else
-			isp_sd->params.yuv_ds_en = true;
-
-		comp[pad]->width = r->width;
-		comp[pad]->height = r->height;
-
-		if (r->width == 0 || r->height == 0 ||
-			crop[ATOMISP_SUBDEV_PAD_SINK]->width == 0 ||
-			crop[ATOMISP_SUBDEV_PAD_SINK]->height == 0)
-			break;
-		/*
-		 * do cropping on sensor input if ratio of required resolution
-		 * is different with sensor output resolution ratio:
-		 *
-		 * ratio = width / height
-		 *
-		 * if ratio_output < ratio_sensor:
-		 *	effect_width = sensor_height * out_width / out_height;
-		 *	effect_height = sensor_height;
-		 * else
-		 *	effect_width = sensor_width;
-		 *	effect_height = sensor_width * out_height / out_width;
-		 *
-		 */
-		if (r->width * crop[ATOMISP_SUBDEV_PAD_SINK]->height <
-			crop[ATOMISP_SUBDEV_PAD_SINK]->width * r->height)
-			atomisp_css_input_set_effective_resolution(isp_sd,
-				stream_id,
-				rounddown(crop[ATOMISP_SUBDEV_PAD_SINK]->
-					height * r->width / r->height,
-					ATOM_ISP_STEP_WIDTH),
-				crop[ATOMISP_SUBDEV_PAD_SINK]->height);
-		else
-			atomisp_css_input_set_effective_resolution(isp_sd,
-				stream_id,
-				crop[ATOMISP_SUBDEV_PAD_SINK]->width,
-				rounddown(crop[ATOMISP_SUBDEV_PAD_SINK]->
-					width * r->height / r->width,
-					ATOM_ISP_STEP_WIDTH));
-
-		break;
-	}
-	case ATOMISP_SUBDEV_PAD_SOURCE_VF:
-	case ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW:
-		comp[pad]->width = r->width;
-		comp[pad]->height = r->height;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	/* Set format dimensions on non-sink pads as well. */
-	if (pad != ATOMISP_SUBDEV_PAD_SINK) {
-		ffmt[pad]->width = comp[pad]->width;
-		ffmt[pad]->height = comp[pad]->height;
-	}
-
-	if (!atomisp_subdev_get_rect(sd, cfg, which, pad, target))
-		return -EINVAL;
-	*r = *atomisp_subdev_get_rect(sd, cfg, which, pad, target);
-
-	dev_dbg(isp->dev, "sel actual: l %d t %d w %d h %d\n",
-		r->left, r->top, r->width, r->height);
-
-	return 0;
-}
-
-static int isp_subdev_set_selection(struct v4l2_subdev *sd,
-				    struct v4l2_subdev_pad_config *cfg,
-				    struct v4l2_subdev_selection *sel)
-{
-	int rval = isp_subdev_validate_rect(sd, sel->pad, sel->target);
-	if (rval)
-		return rval;
-
-	return atomisp_subdev_set_selection(sd, cfg, sel->which, sel->pad,
-					    sel->target, sel->flags, &sel->r);
-}
-
-static int atomisp_get_sensor_bin_factor(struct atomisp_sub_device *asd)
-{
-	struct v4l2_control ctrl = {0};
-	struct atomisp_device *isp = asd->isp;
-	int hbin, vbin;
-	int ret;
-
-	if (isp->inputs[asd->input_curr].type == FILE_INPUT ||
-		isp->inputs[asd->input_curr].type == TEST_PATTERN)
-		return 0;
-
-	ctrl.id = V4L2_CID_BIN_FACTOR_HORZ;
-	ret =
-	    v4l2_g_ctrl(isp->inputs[asd->input_curr].camera->ctrl_handler,
-			&ctrl);
-	hbin = ctrl.value;
-	ctrl.id = V4L2_CID_BIN_FACTOR_VERT;
-	ret |=
-	    v4l2_g_ctrl(isp->inputs[asd->input_curr].camera->ctrl_handler,
-			&ctrl);
-	vbin = ctrl.value;
-
-	/*
-	 * ISP needs to know binning factor from sensor.
-	 * In case horizontal and vertical sensor's binning factors
-	 * are different or sensor does not support binning factor CID,
-	 * ISP will apply default 0 value.
-	 */
-	if (ret || hbin != vbin)
-		hbin = 0;
-
-	return hbin;
-}
-
-void atomisp_subdev_set_ffmt(struct v4l2_subdev *sd,
-			     struct v4l2_subdev_pad_config *cfg, uint32_t which,
-			     uint32_t pad, struct v4l2_mbus_framefmt *ffmt)
-{
-	struct atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);
-	struct atomisp_device *isp = isp_sd->isp;
-	struct v4l2_mbus_framefmt *__ffmt =
-		atomisp_subdev_get_ffmt(sd, cfg, which, pad);
-	uint16_t vdev_pad = atomisp_subdev_source_pad(sd->devnode);
-	enum atomisp_input_stream_id stream_id;
-
-	dev_dbg(isp->dev, "ffmt: pad %s w %d h %d code 0x%8.8x which %s\n",
-		atomisp_pad_str[pad], ffmt->width, ffmt->height, ffmt->code,
-		which == V4L2_SUBDEV_FORMAT_TRY ? "V4L2_SUBDEV_FORMAT_TRY"
-		: "V4L2_SUBDEV_FORMAT_ACTIVE");
-
-	stream_id = atomisp_source_pad_to_stream_id(isp_sd, vdev_pad);
-
-	switch (pad) {
-	case ATOMISP_SUBDEV_PAD_SINK: {
-		const struct atomisp_in_fmt_conv *fc =
-			atomisp_find_in_fmt_conv(ffmt->code);
-
-		if (!fc) {
-			fc = atomisp_in_fmt_conv;
-			ffmt->code = fc->code;
-			dev_dbg(isp->dev, "using 0x%8.8x instead\n",
-				ffmt->code);
-		}
-
-		*__ffmt = *ffmt;
-
-		isp_subdev_propagate(sd, cfg, which, pad,
-				     V4L2_SEL_TGT_CROP, 0);
-
-		if (which == V4L2_SUBDEV_FORMAT_ACTIVE) {
-			atomisp_css_input_set_resolution(isp_sd,
-				stream_id, ffmt);
-			atomisp_css_input_set_binning_factor(isp_sd,
-				stream_id,
-				atomisp_get_sensor_bin_factor(isp_sd));
-			atomisp_css_input_set_bayer_order(isp_sd, stream_id,
-							  fc->bayer_order);
-			atomisp_css_input_set_format(isp_sd, stream_id,
-						fc->css_stream_fmt);
-			atomisp_css_set_default_isys_config(isp_sd, stream_id,
-							    ffmt);
-		}
-
-		break;
-	}
-	case ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE:
-	case ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW:
-	case ATOMISP_SUBDEV_PAD_SOURCE_VF:
-	case ATOMISP_SUBDEV_PAD_SOURCE_VIDEO:
-		__ffmt->code = ffmt->code;
-		break;
-	}
-}
-
-/*
- * isp_subdev_get_format - Retrieve the video format on a pad
- * @sd : ISP V4L2 subdevice
- * @fh : V4L2 subdev file handle
- * @pad: Pad number
- * @fmt: Format
- *
- * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
- * to the format type.
- */
-static int isp_subdev_get_format(struct v4l2_subdev *sd,
-				 struct v4l2_subdev_pad_config *cfg,
-				 struct v4l2_subdev_format *fmt)
-{
-	fmt->format = *atomisp_subdev_get_ffmt(sd, cfg, fmt->which, fmt->pad);
-
-	return 0;
-}
-
-/*
- * isp_subdev_set_format - Set the video format on a pad
- * @sd : ISP subdev V4L2 subdevice
- * @fh : V4L2 subdev file handle
- * @pad: Pad number
- * @fmt: Format
- *
- * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
- * to the format type.
- */
-static int isp_subdev_set_format(struct v4l2_subdev *sd,
-				 struct v4l2_subdev_pad_config *cfg,
-				 struct v4l2_subdev_format *fmt)
-{
-	atomisp_subdev_set_ffmt(sd, cfg, fmt->which, fmt->pad, &fmt->format);
-
-	return 0;
-}
-
-/* V4L2 subdev core operations */
-static const struct v4l2_subdev_core_ops isp_subdev_v4l2_core_ops = {
-	 .ioctl = isp_subdev_ioctl, .s_power = isp_subdev_set_power,
-	 .subscribe_event = isp_subdev_subscribe_event,
-	 .unsubscribe_event = isp_subdev_unsubscribe_event,
-};
-
-/* V4L2 subdev pad operations */
-static const struct v4l2_subdev_pad_ops isp_subdev_v4l2_pad_ops = {
-	.enum_mbus_code = isp_subdev_enum_mbus_code,
-	.get_fmt = isp_subdev_get_format,
-	.set_fmt = isp_subdev_set_format,
-	.get_selection = isp_subdev_get_selection,
-	.set_selection = isp_subdev_set_selection,
-	.link_validate = v4l2_subdev_link_validate_default,
-};
-
-/* V4L2 subdev operations */
-static const struct v4l2_subdev_ops isp_subdev_v4l2_ops = {
-	.core = &isp_subdev_v4l2_core_ops,
-	.pad = &isp_subdev_v4l2_pad_ops,
-};
-
-static void isp_subdev_init_params(struct atomisp_sub_device *asd)
-{
-	unsigned int i;
-
-	/* parameters initialization */
-	INIT_LIST_HEAD(&asd->s3a_stats);
-	INIT_LIST_HEAD(&asd->s3a_stats_in_css);
-	INIT_LIST_HEAD(&asd->s3a_stats_ready);
-	INIT_LIST_HEAD(&asd->dis_stats);
-	INIT_LIST_HEAD(&asd->dis_stats_in_css);
-	spin_lock_init(&asd->dis_stats_lock);
-	for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
-		INIT_LIST_HEAD(&asd->metadata[i]);
-		INIT_LIST_HEAD(&asd->metadata_in_css[i]);
-		INIT_LIST_HEAD(&asd->metadata_ready[i]);
-	}
-}
-
-/*
-* isp_subdev_link_setup - Setup isp subdev connections
-* @entity: ispsubdev 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 isp_subdev_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 atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);
-	struct atomisp_device *isp = isp_sd->isp;
-	unsigned int i;
-
-	switch (local->index | is_media_entity_v4l2_subdev(remote->entity)) {
-	case ATOMISP_SUBDEV_PAD_SINK | MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN:
-		/* Read from the sensor CSI2-ports. */
-		if (!(flags & MEDIA_LNK_FL_ENABLED)) {
-			isp_sd->input = ATOMISP_SUBDEV_INPUT_NONE;
-			break;
-		}
-
-		if (isp_sd->input != ATOMISP_SUBDEV_INPUT_NONE)
-			return -EBUSY;
-
-		for (i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++) {
-			if (remote->entity != &isp->csi2_port[i].subdev.entity)
-				continue;
-
-			isp_sd->input = ATOMISP_SUBDEV_INPUT_CSI2_PORT1 + i;
-			return 0;
-		}
-
-		return -EINVAL;
-
-	case ATOMISP_SUBDEV_PAD_SINK | MEDIA_ENT_F_OLD_BASE:
-		/* read from memory */
-		if (flags & MEDIA_LNK_FL_ENABLED) {
-			if (isp_sd->input >= ATOMISP_SUBDEV_INPUT_CSI2_PORT1 &&
-				isp_sd->input < (ATOMISP_SUBDEV_INPUT_CSI2_PORT1
-						+ ATOMISP_CAMERA_NR_PORTS))
-				return -EBUSY;
-			isp_sd->input = ATOMISP_SUBDEV_INPUT_MEMORY;
-		} else {
-			if (isp_sd->input == ATOMISP_SUBDEV_INPUT_MEMORY)
-				isp_sd->input = ATOMISP_SUBDEV_INPUT_NONE;
-		}
-		break;
-
-	case ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW | MEDIA_ENT_F_OLD_BASE:
-		/* always write to memory */
-		break;
-
-	case ATOMISP_SUBDEV_PAD_SOURCE_VF | MEDIA_ENT_F_OLD_BASE:
-		/* always write to memory */
-		break;
-
-	case ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE | MEDIA_ENT_F_OLD_BASE:
-		/* always write to memory */
-		break;
-
-	case ATOMISP_SUBDEV_PAD_SOURCE_VIDEO | MEDIA_ENT_F_OLD_BASE:
-		/* always write to memory */
-		break;
-
-	default:
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-/* media operations */
-static const struct media_entity_operations isp_subdev_media_ops = {
-	 .link_setup = isp_subdev_link_setup,
-	 .link_validate = v4l2_subdev_link_validate,
-/*	 .set_power = v4l2_subdev_set_power,	*/
-};
-
-static int __atomisp_update_run_mode(struct atomisp_sub_device *asd)
-{
-	struct atomisp_device *isp = asd->isp;
-	struct v4l2_ctrl *ctrl = asd->run_mode;
-	struct v4l2_ctrl *c;
-	s32 mode;
-
-	if (ctrl->val != ATOMISP_RUN_MODE_VIDEO &&
-	    asd->continuous_mode->val)
-		mode = ATOMISP_RUN_MODE_PREVIEW;
-	else
-		mode = ctrl->val;
-
-	c = v4l2_ctrl_find(
-		isp->inputs[asd->input_curr].camera->ctrl_handler,
-		V4L2_CID_RUN_MODE);
-
-	if (c)
-		return v4l2_ctrl_s_ctrl(c, mode);
-
-	return 0;
-}
-
-int atomisp_update_run_mode(struct atomisp_sub_device *asd)
-{
-	int rval;
-
-	mutex_lock(asd->ctrl_handler.lock);
-	rval = __atomisp_update_run_mode(asd);
-	mutex_unlock(asd->ctrl_handler.lock);
-
-	return rval;
-}
-
-static int s_ctrl(struct v4l2_ctrl *ctrl)
-{
-	struct atomisp_sub_device *asd = container_of(
-		ctrl->handler, struct atomisp_sub_device, ctrl_handler);
-
-	switch (ctrl->id) {
-	case V4L2_CID_RUN_MODE:
-		return __atomisp_update_run_mode(asd);
-	case V4L2_CID_DEPTH_MODE:
-		if (asd->streaming != ATOMISP_DEVICE_STREAMING_DISABLED) {
-			dev_err(asd->isp->dev, "ISP is streaming, it is not supported to change the depth mode\n");
-			return -EINVAL;
-		}
-		break;
-	}
-
-	return 0;
-}
-
-static const struct v4l2_ctrl_ops ctrl_ops = {
-	.s_ctrl = &s_ctrl,
-};
-
-static const struct v4l2_ctrl_config ctrl_fmt_auto = {
-	.ops = &ctrl_ops,
-	.id = V4L2_CID_FMT_AUTO,
-	.name = "Automatic format guessing",
-	.type = V4L2_CTRL_TYPE_BOOLEAN,
-	.min = 0,
-	.max = 1,
-	.step = 1,
-	.def = 1,
-};
-
-static const char * const ctrl_run_mode_menu[] = {
-	NULL,
-	"Video",
-	"Still capture",
-	"Continuous capture",
-	"Preview",
-};
-
-static const struct v4l2_ctrl_config ctrl_run_mode = {
-	.ops = &ctrl_ops,
-	.id = V4L2_CID_RUN_MODE,
-	.name = "Atomisp run mode",
-	.type = V4L2_CTRL_TYPE_MENU,
-	.min = 1,
-	.def = 1,
-	.max = 4,
-	.qmenu = ctrl_run_mode_menu,
-};
-
-static const char * const ctrl_vfpp_mode_menu[] = {
-	"Enable",			/* vfpp always enabled */
-	"Disable to scaler mode",	/* CSS into video mode and disable */
-	"Disable to low latency mode",	/* CSS into still mode and disable */
-};
-
-static const struct v4l2_ctrl_config ctrl_vfpp = {
-	.id = V4L2_CID_VFPP,
-	.name = "Atomisp vf postprocess",
-	.type = V4L2_CTRL_TYPE_MENU,
-	.min = 0,
-	.def = 0,
-	.max = 2,
-	.qmenu = ctrl_vfpp_mode_menu,
-};
-
-/*
- * Control for ISP continuous mode
- *
- * When enabled, capture processing is possible without
- * stopping the preview pipeline. When disabled, ISP needs
- * to be restarted between preview and capture.
- */
-static const struct v4l2_ctrl_config ctrl_continuous_mode = {
-	.ops = &ctrl_ops,
-	.id = V4L2_CID_ATOMISP_CONTINUOUS_MODE,
-	.type = V4L2_CTRL_TYPE_BOOLEAN,
-	.name = "Continuous mode",
-	.min = 0,
-	.max = 1,
-	.step = 1,
-	.def = 0,
-};
-
-/*
- * Control for continuous mode raw buffer size
- *
- * The size of the RAW ringbuffer sets limit on how much
- * back in time application can go when requesting capture
- * frames to be rendered, and how many frames can be rendered
- * in a burst at full sensor rate.
- *
- * Note: this setting has a big impact on memory consumption of
- * the CSS subsystem.
- */
-static const struct v4l2_ctrl_config ctrl_continuous_raw_buffer_size = {
-	.ops = &ctrl_ops,
-	.id = V4L2_CID_ATOMISP_CONTINUOUS_RAW_BUFFER_SIZE,
-	.type = V4L2_CTRL_TYPE_INTEGER,
-	.name = "Continuous raw ringbuffer size",
-	.min = 1,
-	.max = 100, /* depends on CSS version, runtime checked */
-	.step = 1,
-	.def = 3,
-};
-
-/*
- * Control for enabling continuous viewfinder
- *
- * When enabled, and ISP is in continuous mode (see ctrl_continuous_mode ),
- * preview pipeline continues concurrently with capture
- * processing. When disabled, and continuous mode is used,
- * preview is paused while captures are processed, but
- * full pipeline restart is not needed.
- *
- * By setting this to disabled, capture processing is
- * essentially given priority over preview, and the effective
- * capture output rate may be higher than with continuous
- * viewfinder enabled.
- */
-static const struct v4l2_ctrl_config ctrl_continuous_viewfinder = {
-	.id = V4L2_CID_ATOMISP_CONTINUOUS_VIEWFINDER,
-	.type = V4L2_CTRL_TYPE_BOOLEAN,
-	.name = "Continuous viewfinder",
-	.min = 0,
-	.max = 1,
-	.step = 1,
-	.def = 0,
-};
-
-/*
- * Control for enabling Lock&Unlock Raw Buffer mechanism
- *
- * When enabled, Raw Buffer can be locked and unlocked.
- * Application can hold the exp_id of Raw Buffer
- * and unlock it when no longer needed.
- * Note: Make sure set this configuration before creating stream.
- */
-static const struct v4l2_ctrl_config ctrl_enable_raw_buffer_lock = {
-	.id = V4L2_CID_ENABLE_RAW_BUFFER_LOCK,
-	.type = V4L2_CTRL_TYPE_BOOLEAN,
-	.name = "Lock Unlock Raw Buffer",
-	.min = 0,
-	.max = 1,
-	.step = 1,
-	.def = 0,
-};
-
-/*
- * Control to disable digital zoom of the whole stream
- *
- * When it is true, pipe configuation enable_dz will be set to false.
- * This can help get a better performance by disabling pp binary.
- *
- * Note: Make sure set this configuration before creating stream.
- */
-static const struct v4l2_ctrl_config ctrl_disable_dz = {
-	.id = V4L2_CID_DISABLE_DZ,
-	.type = V4L2_CTRL_TYPE_BOOLEAN,
-	.name = "Disable digital zoom",
-	.min = 0,
-	.max = 1,
-	.step = 1,
-	.def = 0,
-};
-
-/*
- * Control for ISP depth mode
- *
- * When enabled, that means ISP will deal with dual streams and sensors will be
- * in slave/master mode.
- * slave sensor will have no output until master sensor is streamed on.
- */
-static const struct v4l2_ctrl_config ctrl_depth_mode = {
-	.ops = &ctrl_ops,
-	.id = V4L2_CID_DEPTH_MODE,
-	.type = V4L2_CTRL_TYPE_BOOLEAN,
-	.name = "Depth mode",
-	.min = 0,
-	.max = 1,
-	.step = 1,
-	.def = 0,
-};
-
-#ifdef ISP2401
-/*
- * Control for selectting ISP version
- *
- * When enabled, that means ISP version will be used ISP2.7. when disable, the
- * isp will default to use ISP2.2.
- * Note: Make sure set this configuration before creating stream.
- */
-static const struct v4l2_ctrl_config ctrl_select_isp_version = {
-	.ops = &ctrl_ops,
-	.id = V4L2_CID_ATOMISP_SELECT_ISP_VERSION,
-	.type = V4L2_CTRL_TYPE_BOOLEAN,
-	.name = "Select Isp version",
-	.min = 0,
-	.max = 1,
-	.step = 1,
-	.def = 0,
-};
-
-#ifdef CONFIG_ION
-/*
- * Control for ISP ion device fd
- *
- * userspace will open ion device and pass the fd to kernel.
- * this fd will be used to map shared fd to buffer.
- */
-static const struct v4l2_ctrl_config ctrl_ion_dev_fd = {
-		.ops = &ctrl_ops,
-		.id = V4L2_CID_ATOMISP_ION_DEVICE_FD,
-		.type = V4L2_CTRL_TYPE_INTEGER,
-		.name = "Ion Device Fd",
-		.min = -1,
-		.max = 1024,
-		.step = 1,
-		.def = ION_FD_UNSET
-};
-#endif
-
-#endif
-static void atomisp_init_subdev_pipe(struct atomisp_sub_device *asd,
-		struct atomisp_video_pipe *pipe, enum v4l2_buf_type buf_type)
-{
-	pipe->type = buf_type;
-	pipe->asd = asd;
-	pipe->isp = asd->isp;
-	spin_lock_init(&pipe->irq_lock);
-	INIT_LIST_HEAD(&pipe->activeq);
-	INIT_LIST_HEAD(&pipe->activeq_out);
-	INIT_LIST_HEAD(&pipe->buffers_waiting_for_param);
-	INIT_LIST_HEAD(&pipe->per_frame_params);
-	memset(pipe->frame_request_config_id,
-	       0, VIDEO_MAX_FRAME * sizeof(unsigned int));
-	memset(pipe->frame_params,
-	       0, VIDEO_MAX_FRAME *
-		sizeof(struct atomisp_css_params_with_list *));
-}
-
-static void atomisp_init_acc_pipe(struct atomisp_sub_device *asd,
-		struct atomisp_acc_pipe *pipe)
-{
-	pipe->asd = asd;
-	pipe->isp = asd->isp;
-	INIT_LIST_HEAD(&asd->acc.fw);
-	INIT_LIST_HEAD(&asd->acc.memory_maps);
-	ida_init(&asd->acc.ida);
-}
-
-/*
- * isp_subdev_init_entities - Initialize V4L2 subdev and media entity
- * @asd: ISP CCDC module
- *
- * Return 0 on success and a negative error code on failure.
- */
-static int isp_subdev_init_entities(struct atomisp_sub_device *asd)
-{
-	struct v4l2_subdev *sd = &asd->subdev;
-	struct media_pad *pads = asd->pads;
-	struct media_entity *me = &sd->entity;
-	int ret;
-
-	asd->input = ATOMISP_SUBDEV_INPUT_NONE;
-
-	v4l2_subdev_init(sd, &isp_subdev_v4l2_ops);
-	sprintf(sd->name, "ATOMISP_SUBDEV_%d", asd->index);
-	v4l2_set_subdevdata(sd, asd);
-	sd->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE;
-
-	pads[ATOMISP_SUBDEV_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
-	pads[ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW].flags = MEDIA_PAD_FL_SOURCE;
-	pads[ATOMISP_SUBDEV_PAD_SOURCE_VF].flags = MEDIA_PAD_FL_SOURCE;
-	pads[ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE].flags = MEDIA_PAD_FL_SOURCE;
-	pads[ATOMISP_SUBDEV_PAD_SOURCE_VIDEO].flags = MEDIA_PAD_FL_SOURCE;
-
-	asd->fmt[ATOMISP_SUBDEV_PAD_SINK].fmt.code =
-		MEDIA_BUS_FMT_SBGGR10_1X10;
-	asd->fmt[ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW].fmt.code =
-		MEDIA_BUS_FMT_SBGGR10_1X10;
-	asd->fmt[ATOMISP_SUBDEV_PAD_SOURCE_VF].fmt.code =
-		MEDIA_BUS_FMT_SBGGR10_1X10;
-	asd->fmt[ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE].fmt.code =
-		MEDIA_BUS_FMT_SBGGR10_1X10;
-	asd->fmt[ATOMISP_SUBDEV_PAD_SOURCE_VIDEO].fmt.code =
-		MEDIA_BUS_FMT_SBGGR10_1X10;
-
-	me->ops = &isp_subdev_media_ops;
-	me->function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
-	ret = media_entity_pads_init(me, ATOMISP_SUBDEV_PADS_NUM, pads);
-	if (ret < 0)
-		return ret;
-
-	atomisp_init_subdev_pipe(asd, &asd->video_in,
-				 V4L2_BUF_TYPE_VIDEO_OUTPUT);
-
-	atomisp_init_subdev_pipe(asd, &asd->video_out_preview,
-				 V4L2_BUF_TYPE_VIDEO_CAPTURE);
-
-	atomisp_init_subdev_pipe(asd, &asd->video_out_vf,
-				 V4L2_BUF_TYPE_VIDEO_CAPTURE);
-
-	atomisp_init_subdev_pipe(asd, &asd->video_out_capture,
-				 V4L2_BUF_TYPE_VIDEO_CAPTURE);
-
-	atomisp_init_subdev_pipe(asd, &asd->video_out_video_capture,
-				 V4L2_BUF_TYPE_VIDEO_CAPTURE);
-
-	atomisp_init_acc_pipe(asd, &asd->video_acc);
-
-	ret = atomisp_video_init(&asd->video_in, "MEMORY");
-	if (ret < 0)
-		return ret;
-
-	ret = atomisp_video_init(&asd->video_out_capture, "CAPTURE");
-	if (ret < 0)
-		return ret;
-
-	ret = atomisp_video_init(&asd->video_out_vf, "VIEWFINDER");
-	if (ret < 0)
-		return ret;
-
-	ret = atomisp_video_init(&asd->video_out_preview, "PREVIEW");
-	if (ret < 0)
-		return ret;
-
-	ret = atomisp_video_init(&asd->video_out_video_capture, "VIDEO");
-	if (ret < 0)
-		return ret;
-
-	atomisp_acc_init(&asd->video_acc, "ACC");
-
-	ret = v4l2_ctrl_handler_init(&asd->ctrl_handler, 1);
-	if (ret)
-		return ret;
-
-	asd->fmt_auto = v4l2_ctrl_new_custom(&asd->ctrl_handler,
-						    &ctrl_fmt_auto, NULL);
-	asd->run_mode = v4l2_ctrl_new_custom(&asd->ctrl_handler,
-						    &ctrl_run_mode, NULL);
-	asd->vfpp = v4l2_ctrl_new_custom(&asd->ctrl_handler,
-						&ctrl_vfpp, NULL);
-	asd->continuous_mode = v4l2_ctrl_new_custom(&asd->ctrl_handler,
-					     &ctrl_continuous_mode, NULL);
-	asd->continuous_viewfinder = v4l2_ctrl_new_custom(&asd->ctrl_handler,
-					     &ctrl_continuous_viewfinder,
-					     NULL);
-	asd->continuous_raw_buffer_size =
-			v4l2_ctrl_new_custom(&asd->ctrl_handler,
-					     &ctrl_continuous_raw_buffer_size,
-					     NULL);
-
-	asd->enable_raw_buffer_lock =
-			v4l2_ctrl_new_custom(&asd->ctrl_handler,
-					     &ctrl_enable_raw_buffer_lock,
-					     NULL);
-	asd->depth_mode =
-			v4l2_ctrl_new_custom(&asd->ctrl_handler,
-					     &ctrl_depth_mode,
-					     NULL);
-	asd->disable_dz =
-			v4l2_ctrl_new_custom(&asd->ctrl_handler,
-					     &ctrl_disable_dz,
-					     NULL);
-#ifdef ISP2401
-	asd->select_isp_version =
-			v4l2_ctrl_new_custom(&asd->ctrl_handler,
-					     &ctrl_select_isp_version,
-					     NULL);
-
-#ifdef CONFIG_ION
-	asd->ion_dev_fd =
-			v4l2_ctrl_new_custom(&asd->ctrl_handler,
-						&ctrl_ion_dev_fd,
-						 NULL);
-#endif
-#endif
-
-	/* Make controls visible on subdev as well. */
-	asd->subdev.ctrl_handler = &asd->ctrl_handler;
-	spin_lock_init(&asd->raw_buffer_bitmap_lock);
-	return asd->ctrl_handler.error;
-}
-
-int atomisp_create_pads_links(struct atomisp_device *isp)
-{
-	struct atomisp_sub_device *asd;
-	int i, j, ret = 0;
-	isp->num_of_streams = 2;
-	for (i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++) {
-		for (j = 0; j < isp->num_of_streams; j++) {
-			ret =
-			    media_create_pad_link(&isp->csi2_port[i].subdev.
-						  entity, CSI2_PAD_SOURCE,
-						  &isp->asd[j].subdev.entity,
-						  ATOMISP_SUBDEV_PAD_SINK, 0);
-			if (ret < 0)
-				return ret;
-		}
-	}
-	for (i = 0; i < isp->input_cnt - 2; i++) {
-		ret = media_create_pad_link(&isp->inputs[i].camera->entity, 0,
-					    &isp->csi2_port[isp->inputs[i].
-							    port].subdev.entity,
-					    CSI2_PAD_SINK,
-					    MEDIA_LNK_FL_ENABLED |
-					    MEDIA_LNK_FL_IMMUTABLE);
-		if (ret < 0)
-			return ret;
-	}
-	for (i = 0; i < isp->num_of_streams; i++) {
-		asd = &isp->asd[i];
-		ret = media_create_pad_link(&asd->subdev.entity,
-					    ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW,
-					    &asd->video_out_preview.vdev.entity,
-					    0, 0);
-		if (ret < 0)
-			return ret;
-		ret = media_create_pad_link(&asd->subdev.entity,
-					    ATOMISP_SUBDEV_PAD_SOURCE_VF,
-					    &asd->video_out_vf.vdev.entity, 0,
-					    0);
-		if (ret < 0)
-			return ret;
-		ret = media_create_pad_link(&asd->subdev.entity,
-					    ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE,
-					    &asd->video_out_capture.vdev.entity,
-					    0, 0);
-		if (ret < 0)
-			return ret;
-		ret = media_create_pad_link(&asd->subdev.entity,
-					    ATOMISP_SUBDEV_PAD_SOURCE_VIDEO,
-					    &asd->video_out_video_capture.vdev.
-					    entity, 0, 0);
-		if (ret < 0)
-			return ret;
-		/*
-		 * file input only supported on subdev0
-		 * so do not create pad link for subdevs other then subdev0
-		 */
-		if (asd->index)
-			return 0;
-		ret = media_create_pad_link(&asd->video_in.vdev.entity,
-					    0, &asd->subdev.entity,
-					    ATOMISP_SUBDEV_PAD_SINK, 0);
-		if (ret < 0)
-			return ret;
-	}
-	return 0;
-}
-
-static void atomisp_subdev_cleanup_entities(struct atomisp_sub_device *asd)
-{
-	v4l2_ctrl_handler_free(&asd->ctrl_handler);
-
-	media_entity_cleanup(&asd->subdev.entity);
-}
-
-void atomisp_subdev_cleanup_pending_events(struct atomisp_sub_device *asd)
-{
-	struct v4l2_fh *fh, *fh_tmp;
-	struct v4l2_event event;
-	unsigned int i, pending_event;
-
-	list_for_each_entry_safe(fh, fh_tmp,
-		&asd->subdev.devnode->fh_list, list) {
-		pending_event = v4l2_event_pending(fh);
-		for (i = 0; i < pending_event; i++)
-			v4l2_event_dequeue(fh, &event, 1);
-	}
-}
-
-void atomisp_subdev_unregister_entities(struct atomisp_sub_device *asd)
-{
-	atomisp_subdev_cleanup_entities(asd);
-	v4l2_device_unregister_subdev(&asd->subdev);
-	atomisp_video_unregister(&asd->video_in);
-	atomisp_video_unregister(&asd->video_out_preview);
-	atomisp_video_unregister(&asd->video_out_vf);
-	atomisp_video_unregister(&asd->video_out_capture);
-	atomisp_video_unregister(&asd->video_out_video_capture);
-	atomisp_acc_unregister(&asd->video_acc);
-}
-
-int atomisp_subdev_register_entities(struct atomisp_sub_device *asd,
-	struct v4l2_device *vdev)
-{
-	int ret;
-
-	/* Register the subdev and video node. */
-	ret = v4l2_device_register_subdev(vdev, &asd->subdev);
-	if (ret < 0)
-		goto error;
-
-	ret = atomisp_video_register(&asd->video_out_capture, vdev);
-	if (ret < 0)
-		goto error;
-
-	ret = atomisp_video_register(&asd->video_out_vf, vdev);
-	if (ret < 0)
-		goto error;
-
-	ret = atomisp_video_register(&asd->video_out_preview, vdev);
-	if (ret < 0)
-		goto error;
-
-	ret = atomisp_video_register(&asd->video_out_video_capture, vdev);
-	if (ret < 0)
-		goto error;
-
-	ret = atomisp_acc_register(&asd->video_acc, vdev);
-	if (ret < 0)
-		goto error;
-
-	/*
-	 * file input only supported on subdev0
-	 * so do not create video node for subdevs other then subdev0
-	 */
-	if (asd->index)
-		return 0;
-	ret = atomisp_video_register(&asd->video_in, vdev);
-	if (ret < 0)
-		goto error;
-
-	return 0;
-
-error:
-	atomisp_subdev_unregister_entities(asd);
-	return ret;
-}
-
-/*
- * atomisp_subdev_init - ISP Subdevice  initialization.
- * @dev: Device pointer specific to the ATOM ISP.
- *
- * TODO: Get the initialisation values from platform data.
- *
- * Return 0 on success or a negative error code otherwise.
- */
-int atomisp_subdev_init(struct atomisp_device *isp)
-{
-	struct atomisp_sub_device *asd;
-	int i, ret = 0;
-
-	/*
-	 * CSS2.0 running ISP2400 support
-	 * multiple streams
-	 */
-	isp->num_of_streams = 2;
-	isp->asd = devm_kzalloc(isp->dev, sizeof(struct atomisp_sub_device) *
-			       isp->num_of_streams, GFP_KERNEL);
-	if (!isp->asd)
-		return -ENOMEM;
-	for (i = 0; i < isp->num_of_streams; i++) {
-		asd = &isp->asd[i];
-		spin_lock_init(&asd->lock);
-		asd->isp = isp;
-		isp_subdev_init_params(asd);
-		asd->index = i;
-		ret = isp_subdev_init_entities(asd);
-		if (ret < 0) {
-			atomisp_subdev_cleanup_entities(asd);
-			break;
-		}
-	}
-
-	return ret;
-}

+ 0 - 467
drivers/staging/media/atomisp/pci/atomisp2/atomisp_subdev.h

@@ -1,467 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * 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 __ATOMISP_SUBDEV_H__
-#define __ATOMISP_SUBDEV_H__
-
-#include <media/v4l2-ctrls.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-subdev.h>
-#include <media/videobuf-core.h>
-
-#include "atomisp_common.h"
-#include "atomisp_compat.h"
-#include "atomisp_v4l2.h"
-
-#include "ia_css.h"
-
-/* EXP_ID's ranger is 1 ~ 250 */
-#define ATOMISP_MAX_EXP_ID     (250)
-enum atomisp_subdev_input_entity {
-	ATOMISP_SUBDEV_INPUT_NONE,
-	ATOMISP_SUBDEV_INPUT_MEMORY,
-	ATOMISP_SUBDEV_INPUT_CSI2,
-	/*
-	 * The following enum for CSI2 port must go together in one row.
-	 * Otherwise it breaks the code logic.
-	 */
-	ATOMISP_SUBDEV_INPUT_CSI2_PORT1,
-	ATOMISP_SUBDEV_INPUT_CSI2_PORT2,
-	ATOMISP_SUBDEV_INPUT_CSI2_PORT3,
-};
-
-#define ATOMISP_SUBDEV_PAD_SINK			0
-/* capture output for still frames */
-#define ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE	1
-/* viewfinder output for downscaled capture output */
-#define ATOMISP_SUBDEV_PAD_SOURCE_VF		2
-/* preview output for display */
-#define ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW	3
-/* main output for video pipeline */
-#define ATOMISP_SUBDEV_PAD_SOURCE_VIDEO	4
-#define ATOMISP_SUBDEV_PADS_NUM			5
-
-struct atomisp_in_fmt_conv {
-	u32     code;
-	uint8_t bpp; /* bits per pixel */
-	uint8_t depth; /* uncompressed */
-	enum atomisp_input_format atomisp_in_fmt;
-	enum atomisp_css_bayer_order bayer_order;
-	enum atomisp_input_format css_stream_fmt;
-};
-
-struct atomisp_sub_device;
-
-struct atomisp_video_pipe {
-	struct video_device vdev;
-	enum v4l2_buf_type type;
-	struct media_pad pad;
-	struct videobuf_queue capq;
-	struct videobuf_queue outq;
-	struct list_head activeq;
-	struct list_head activeq_out;
-	/*
-	 * the buffers waiting for per-frame parameters, this is only valid
-	 * in per-frame setting mode.
-	 */
-	struct list_head buffers_waiting_for_param;
-	/* the link list to store per_frame parameters */
-	struct list_head per_frame_params;
-
-	unsigned int buffers_in_css;
-
-	/* irq_lock is used to protect video buffer state change operations and
-	 * also to make activeq, activeq_out, capq and outq list
-	 * operations atomic. */
-	spinlock_t irq_lock;
-	unsigned int users;
-
-	struct atomisp_device *isp;
-	struct v4l2_pix_format pix;
-	uint32_t sh_fmt;
-
-	struct atomisp_sub_device *asd;
-
-	/*
-	 * This frame_config_id is got from CSS when dequueues buffers from CSS,
-	 * it is used to indicate which parameter it has applied.
-	 */
-	unsigned int frame_config_id[VIDEO_MAX_FRAME];
-	/*
-	 * This config id is set when camera HAL enqueues buffer, it has a
-	 * non-zero value to indicate which parameter it needs to applu
-	 */
-	unsigned int frame_request_config_id[VIDEO_MAX_FRAME];
-	struct atomisp_css_params_with_list *frame_params[VIDEO_MAX_FRAME];
-#ifdef ISP2401
-
-	/*
-	* move wdt from asd struct to create wdt for each pipe
-	*/
-	struct timer_list wdt;
-	unsigned int wdt_duration;	/* in jiffies */
-	unsigned long wdt_expires;
-	atomic_t wdt_count;
-#endif
-};
-
-struct atomisp_acc_pipe {
-	struct video_device vdev;
-	unsigned int users;
-	bool running;
-	struct atomisp_sub_device *asd;
-	struct atomisp_device *isp;
-};
-
-struct atomisp_pad_format {
-	struct v4l2_mbus_framefmt fmt;
-	struct v4l2_rect crop;
-	struct v4l2_rect compose;
-};
-
-/* Internal states for flash process */
-enum atomisp_flash_state {
-	ATOMISP_FLASH_IDLE,
-	ATOMISP_FLASH_REQUESTED,
-	ATOMISP_FLASH_ONGOING,
-	ATOMISP_FLASH_DONE
-};
-
-/*
- * This structure is used to cache the CSS parameters, it aligns to
- * struct ia_css_isp_config but without un-supported and deprecated parts.
- */
-struct atomisp_css_params {
-	struct ia_css_wb_config   wb_config;
-	struct ia_css_cc_config   cc_config;
-	struct ia_css_tnr_config  tnr_config;
-	struct ia_css_ecd_config  ecd_config;
-	struct ia_css_ynr_config  ynr_config;
-	struct ia_css_fc_config   fc_config;
-	struct ia_css_formats_config formats_config;
-	struct ia_css_cnr_config  cnr_config;
-	struct ia_css_macc_config macc_config;
-	struct ia_css_ctc_config  ctc_config;
-	struct ia_css_aa_config   aa_config;
-	struct ia_css_aa_config   baa_config;
-	struct ia_css_ce_config   ce_config;
-	struct ia_css_ob_config   ob_config;
-	struct ia_css_dp_config   dp_config;
-	struct ia_css_de_config   de_config;
-	struct ia_css_gc_config   gc_config;
-	struct ia_css_nr_config   nr_config;
-	struct ia_css_ee_config   ee_config;
-	struct ia_css_anr_config  anr_config;
-	struct ia_css_3a_config   s3a_config;
-	struct ia_css_xnr_config  xnr_config;
-	struct ia_css_dz_config   dz_config;
-	struct ia_css_cc_config yuv2rgb_cc_config;
-	struct ia_css_cc_config rgb2yuv_cc_config;
-	struct ia_css_macc_table  macc_table;
-	struct ia_css_gamma_table gamma_table;
-	struct ia_css_ctc_table   ctc_table;
-
-	struct ia_css_xnr_table   xnr_table;
-	struct ia_css_rgb_gamma_table r_gamma_table;
-	struct ia_css_rgb_gamma_table g_gamma_table;
-	struct ia_css_rgb_gamma_table b_gamma_table;
-
-	struct ia_css_vector      motion_vector;
-	struct ia_css_anr_thres   anr_thres;
-
-	struct ia_css_dvs_6axis_config *dvs_6axis;
-	struct ia_css_dvs2_coefficients *dvs2_coeff;
-	struct ia_css_shading_table *shading_table;
-	struct ia_css_morph_table   *morph_table;
-
-	/*
-	 * Used to store the user pointer address of the frame. driver needs to
-	 * translate to ia_css_frame * and then set to CSS.
-	 */
-	void		*output_frame;
-	uint32_t	isp_config_id;
-
-	/* Indicates which parameters need to be updated. */
-	struct atomisp_parameters update_flag;
-};
-
-struct atomisp_subdev_params {
-	/* FIXME: Determines whether raw capture buffer are being passed to
-	 * user space. Unimplemented for now. */
-	int online_process;
-	int yuv_ds_en;
-	unsigned int color_effect;
-	bool gdc_cac_en;
-	bool macc_en;
-	bool bad_pixel_en;
-	bool video_dis_en;
-	bool sc_en;
-	bool fpn_en;
-	bool xnr_en;
-	bool low_light;
-	int false_color;
-	unsigned int histogram_elenum;
-
-	/* Current grid info */
-	struct atomisp_css_grid_info curr_grid_info;
-	enum atomisp_css_pipe_id s3a_enabled_pipe;
-
-	int s3a_output_bytes;
-
-	bool dis_proj_data_valid;
-
-	struct ia_css_dz_config   dz_config;  /** Digital Zoom */
-	struct ia_css_capture_config   capture_config;
-
-	struct atomisp_css_isp_config config;
-
-	/* current configurations */
-	struct atomisp_css_params css_param;
-
-	/*
-	 * Intermediate buffers used to communicate data between
-	 * CSS and user space.
-	 */
-	struct ia_css_3a_statistics *s3a_user_stat;
-
-	void *metadata_user[ATOMISP_METADATA_TYPE_NUM];
-	uint32_t metadata_width_size;
-
-	struct ia_css_dvs2_statistics *dvs_stat;
-	struct atomisp_css_dvs_6axis *dvs_6axis;
-	uint32_t exp_id;
-	int  dvs_hor_coef_bytes;
-	int  dvs_ver_coef_bytes;
-	int  dvs_ver_proj_bytes;
-	int  dvs_hor_proj_bytes;
-
-	/* Flash */
-	int num_flash_frames;
-	enum atomisp_flash_state flash_state;
-	enum atomisp_frame_status last_frame_status;
-
-	/* continuous capture */
-	struct atomisp_cont_capture_conf offline_parm;
-	/* Flag to check if driver needs to update params to css */
-	bool css_update_params_needed;
-};
-
-struct atomisp_css_params_with_list {
-	/* parameters for CSS */
-	struct atomisp_css_params params;
-	struct list_head list;
-};
-
-struct atomisp_acc_fw {
-	struct atomisp_css_fw_info *fw;
-	unsigned int handle;
-	unsigned int flags;
-	unsigned int type;
-	struct {
-		size_t length;
-		unsigned long css_ptr;
-	} args[ATOMISP_ACC_NR_MEMORY];
-	struct list_head list;
-};
-
-struct atomisp_map {
-	ia_css_ptr ptr;
-	size_t length;
-	struct list_head list;
-	/* FIXME: should keep book which maps are currently used
-	 * by binaries and not allow releasing those
-	 * which are in use. Implement by reference counting.
-	 */
-};
-
-struct atomisp_sub_device {
-	struct v4l2_subdev subdev;
-	struct media_pad pads[ATOMISP_SUBDEV_PADS_NUM];
-	struct atomisp_pad_format fmt[ATOMISP_SUBDEV_PADS_NUM];
-	uint16_t capture_pad; /* main capture pad; defines much of isp config */
-
-	enum atomisp_subdev_input_entity input;
-	unsigned int output;
-	struct atomisp_video_pipe video_in;
-	struct atomisp_video_pipe video_out_capture; /* capture output */
-	struct atomisp_video_pipe video_out_vf;      /* viewfinder output */
-	struct atomisp_video_pipe video_out_preview; /* preview output */
-	struct atomisp_acc_pipe video_acc;
-	/* video pipe main output */
-	struct atomisp_video_pipe video_out_video_capture;
-	/* struct isp_subdev_params params; */
-	spinlock_t lock;
-	struct atomisp_device *isp;
-	struct v4l2_ctrl_handler ctrl_handler;
-	struct v4l2_ctrl *fmt_auto;
-	struct v4l2_ctrl *run_mode;
-	struct v4l2_ctrl *depth_mode;
-	struct v4l2_ctrl *vfpp;
-	struct v4l2_ctrl *continuous_mode;
-	struct v4l2_ctrl *continuous_raw_buffer_size;
-	struct v4l2_ctrl *continuous_viewfinder;
-	struct v4l2_ctrl *enable_raw_buffer_lock;
-#ifdef ISP2401
-	struct v4l2_ctrl *ion_dev_fd;
-#endif
-	struct v4l2_ctrl *disable_dz;
-#ifdef ISP2401
-	struct v4l2_ctrl *select_isp_version;
-#endif
-
-	struct {
-		struct list_head fw;
-		struct list_head memory_maps;
-		struct atomisp_css_pipeline *pipeline;
-		bool extension_mode;
-		struct ida ida;
-		struct completion acc_done;
-		void *acc_stages;
-	} acc;
-
-	struct atomisp_subdev_params params;
-
-	struct atomisp_stream_env stream_env[ATOMISP_INPUT_STREAM_NUM];
-
-	struct v4l2_pix_format dvs_envelop;
-	unsigned int s3a_bufs_in_css[CSS_PIPE_ID_NUM];
-	unsigned int dis_bufs_in_css;
-
-	unsigned int metadata_bufs_in_css
-		[ATOMISP_INPUT_STREAM_NUM][CSS_PIPE_ID_NUM];
-	/* The list of free and available metadata buffers for CSS */
-	struct list_head metadata[ATOMISP_METADATA_TYPE_NUM];
-	/* The list of metadata buffers which have been en-queued to CSS */
-	struct list_head metadata_in_css[ATOMISP_METADATA_TYPE_NUM];
-	/* The list of metadata buffers which are ready for userspace to get */
-	struct list_head metadata_ready[ATOMISP_METADATA_TYPE_NUM];
-
-	/* The list of free and available s3a stat buffers for CSS */
-	struct list_head s3a_stats;
-	/* The list of s3a stat buffers which have been en-queued to CSS */
-	struct list_head s3a_stats_in_css;
-	/* The list of s3a stat buffers which are ready for userspace to get */
-	struct list_head s3a_stats_ready;
-
-	struct list_head dis_stats;
-	struct list_head dis_stats_in_css;
-	spinlock_t dis_stats_lock;
-
-	struct atomisp_css_frame *vf_frame; /* TODO: needed? */
-	struct atomisp_css_frame *raw_output_frame;
-	enum atomisp_frame_status frame_status[VIDEO_MAX_FRAME];
-
-	/* This field specifies which camera (v4l2 input) is selected. */
-	int input_curr;
-	/* This field specifies which sensor is being selected when there
-	   are multiple sensors connected to the same MIPI port. */
-	int sensor_curr;
-
-	atomic_t sof_count;
-	atomic_t sequence;      /* Sequence value that is assigned to buffer. */
-	atomic_t sequence_temp;
-
-	unsigned int streaming; /* Hold both mutex and lock to change this */
-	bool stream_prepared; /* whether css stream is created */
-
-	/* subdev index: will be used to show which subdev is holding the
-	 * resource, like which camera is used by which subdev
-	 */
-	unsigned int index;
-
-	/* delayed memory allocation for css */
-	struct completion init_done;
-	struct workqueue_struct *delayed_init_workq;
-	unsigned int delayed_init;
-	struct work_struct delayed_init_work;
-
-	unsigned int latest_preview_exp_id; /* CSS ZSL/SDV raw buffer id */
-
-	unsigned int mipi_frame_size;
-
-	bool copy_mode; /* CSI2+ use copy mode */
-	bool yuvpp_mode;	/* CSI2+ yuvpp pipe */
-
-	int raw_buffer_bitmap[ATOMISP_MAX_EXP_ID/32 + 1]; /* Record each Raw Buffer lock status */
-	int raw_buffer_locked_count;
-	spinlock_t raw_buffer_bitmap_lock;
-
-#ifndef ISP2401
-	struct timer_list wdt;
-	unsigned int wdt_duration;	/* in jiffies */
-	unsigned long wdt_expires;
-
-#endif
-	struct atomisp_resolution sensor_array_res;
-	bool high_speed_mode; /* Indicate whether now is a high speed mode */
-	int pending_capture_request; /* Indicates the number of pending capture requests. */
-#ifndef ISP2401
-
-#else
-	bool re_trigger_capture;
-#endif
-	unsigned int preview_exp_id;
-	unsigned int postview_exp_id;
-};
-
-extern const struct atomisp_in_fmt_conv atomisp_in_fmt_conv[];
-
-u32 atomisp_subdev_uncompressed_code(u32 code);
-bool atomisp_subdev_is_compressed(u32 code);
-const struct atomisp_in_fmt_conv *atomisp_find_in_fmt_conv(u32 code);
-#ifndef ISP2401
-const struct atomisp_in_fmt_conv *atomisp_find_in_fmt_conv_by_atomisp_in_fmt(
-	enum atomisp_input_format atomisp_in_fmt);
-#else
-const struct atomisp_in_fmt_conv
-    *atomisp_find_in_fmt_conv_by_atomisp_in_fmt(enum atomisp_input_format
-						atomisp_in_fmt);
-#endif
-const struct atomisp_in_fmt_conv *atomisp_find_in_fmt_conv_compressed(u32 code);
-bool atomisp_subdev_format_conversion(struct atomisp_sub_device *asd,
-				      unsigned int source_pad);
-uint16_t atomisp_subdev_source_pad(struct video_device *vdev);
-
-/* Get pointer to appropriate format */
-struct v4l2_mbus_framefmt
-*atomisp_subdev_get_ffmt(struct v4l2_subdev *sd,
-			 struct v4l2_subdev_pad_config *cfg, uint32_t which,
-			 uint32_t pad);
-struct v4l2_rect *atomisp_subdev_get_rect(struct v4l2_subdev *sd,
-					  struct v4l2_subdev_pad_config *cfg,
-					  uint32_t which, uint32_t pad,
-					  uint32_t target);
-int atomisp_subdev_set_selection(struct v4l2_subdev *sd,
-				 struct v4l2_subdev_pad_config *cfg,
-				 uint32_t which, uint32_t pad, uint32_t target,
-				 uint32_t flags, struct v4l2_rect *r);
-/* Actually set the format */
-void atomisp_subdev_set_ffmt(struct v4l2_subdev *sd,
-			     struct v4l2_subdev_pad_config *cfg, uint32_t which,
-			     uint32_t pad, struct v4l2_mbus_framefmt *ffmt);
-
-int atomisp_update_run_mode(struct atomisp_sub_device *asd);
-
-void atomisp_subdev_cleanup_pending_events(struct atomisp_sub_device *asd);
-
-void atomisp_subdev_unregister_entities(struct atomisp_sub_device *asd);
-int atomisp_subdev_register_entities(struct atomisp_sub_device *asd,
-	struct v4l2_device *vdev);
-int atomisp_subdev_init(struct atomisp_device *isp);
-void atomisp_subdev_cleanup(struct atomisp_device *isp);
-int atomisp_create_pads_links(struct atomisp_device *isp);
-
-#endif /* __ATOMISP_SUBDEV_H__ */

+ 0 - 187
drivers/staging/media/atomisp/pci/atomisp2/atomisp_tables.h

@@ -1,187 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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	__ATOMISP_TABLES_H__
-#define	__ATOMISP_TABLES_H__
-
-#include "sh_css_params.h"
-
-/*Sepia image effect table*/
-static struct atomisp_css_cc_config sepia_cc_config = {
-	.fraction_bits  = 8,
-	.matrix	 = {141, 18, 68, -40, -5, -19, 35, 4, 16},
-};
-
-/*Negative image effect table*/
-static struct atomisp_css_cc_config nega_cc_config = {
-	.fraction_bits  = 8,
-	.matrix	 = {255, 29, 120, 0, 374, 342, 0, 672, -301},
-};
-
-/*Mono image effect table*/
-static struct atomisp_css_cc_config mono_cc_config = {
-	.fraction_bits  = 8,
-	.matrix	 = {255, 29, 120, 0, 0, 0, 0, 0, 0},
-};
-
-/*Skin whiten image effect table*/
-static struct atomisp_css_macc_table skin_low_macc_table = {
-	.data = {
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	7168, 0, 2048, 8192,
-	5120, -1024, 2048, 8192,
-	8192, 2048, -1024, 5120,
-	8192, 2048, 0, 7168,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192
-	}
-};
-
-static struct atomisp_css_macc_table skin_medium_macc_table = {
-	.data = {
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	5120, 0, 6144, 8192,
-	3072, -1024, 2048, 6144,
-	6144, 2048, -1024, 3072,
-	8192, 6144, 0, 5120,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192
-	}
-};
-
-static struct atomisp_css_macc_table skin_high_macc_table = {
-	.data = {
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	4096, 0, 8192, 8192,
-	0, -2048, 4096, 6144,
-	6144, 4096, -2048, 0,
-	8192, 8192, 0, 4096,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192
-	}
-};
-
-/*Blue enhencement image effect table*/
-static struct atomisp_css_macc_table blue_macc_table = {
-	.data = {
-	9728, -3072, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	9728, 0, -3072, 8192,
-	12800, 1536, -3072, 8192,
-	11264, 0, 0, 11264,
-	9728, -3072, 0, 11264
-	}
-};
-
-/*Green enhencement image effect table*/
-static struct atomisp_css_macc_table green_macc_table = {
-	.data = {
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	10240, 4096, 0, 8192,
-	10240, 4096, 0, 12288,
-	12288, 0, 0, 12288,
-	14336, -2048, 4096, 8192,
-	10240, 0, 4096, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192,
-	8192, 0, 0, 8192
-	}
-};
-
-static struct atomisp_css_ctc_table vivid_ctc_table = {
-	.data.vamem_2 = {
-	0,  384,  837,  957, 1011, 1062, 1083, 1080,
-	1078, 1077, 1053, 1039, 1012,  992,  969,  951,
-	929,  906,  886,  866,  845,  823,  809,  790,
-	772,  758,  741,  726,  711,  701,  688,  675,
-	666,  656,  648,  639,  633,  626,  618,  612,
-	603,  594,  582,  572,  557,  545,  529,  516,
-	504,  491,  480,  467,  459,  447,  438,  429,
-	419,  412,  404,  397,  389,  382,  376,  368,
-	363,  357,  351,  345,  340,  336,  330,  326,
-	321,  318,  312,  308,  304,  300,  297,  294,
-	291,  286,  284,  281,  278,  275,  271,  268,
-	261,  257,  251,  245,  240,  235,  232,  225,
-	223,  218,  213,  209,  206,  204,  199,  197,
-	193,  189,  186,  185,  183,  179,  177,  175,
-	172,  170,  169,  167,  164,  164,  162,  160,
-	158,  157,  156,  154,  154,  152,  151,  150,
-	149,  148,  146,  147,  146,  144,  143,  143,
-	142,  141,  140,  141,  139,  138,  138,  138,
-	137,  136,  136,  135,  134,  134,  134,  133,
-	132,  132,  131,  130,  131,  130,  129,  128,
-	129,  127,  127,  127,  127,  125,  125,  125,
-	123,  123,  122,  120,  118,  115,  114,  111,
-	110,  108,  106,  105,  103,  102,  100,   99,
-	97,   97,   96,   95,   94,   93,   93,   91,
-	91,   91,   90,   90,   89,   89,   88,   88,
-	89,   88,   88,   87,   87,   87,   87,   86,
-	87,   87,   86,   87,   86,   86,   84,   84,
-	82,   80,   78,   76,   74,   72,   70,   68,
-	67,   65,   62,   60,   58,   56,   55,   54,
-	53,   51,   49,   49,   47,   45,   45,   45,
-	41,   40,   39,   39,   34,   33,   34,   32,
-	25,   23,   24,   20,   13,    9,   12,    0,
-	0
-	}
-};
-#endif

+ 0 - 164
drivers/staging/media/atomisp/pci/atomisp2/atomisp_tpg.c

@@ -1,164 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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.
- *
- *
- */
-
-#include <media/v4l2-event.h>
-#include <media/v4l2-mediabus.h>
-#include "atomisp_internal.h"
-#include "atomisp_tpg.h"
-
-static int tpg_s_stream(struct v4l2_subdev *sd, int enable)
-{
-	return 0;
-}
-
-static int tpg_get_fmt(struct v4l2_subdev *sd,
-		       struct v4l2_subdev_pad_config *cfg,
-		       struct v4l2_subdev_format *format)
-{
-	/*to fake*/
-	return 0;
-}
-
-static int tpg_set_fmt(struct v4l2_subdev *sd,
-		       struct v4l2_subdev_pad_config *cfg,
-		       struct v4l2_subdev_format *format)
-{
-	struct v4l2_mbus_framefmt *fmt = &format->format;
-
-	if (format->pad)
-		return -EINVAL;
-	/* only raw8 grbg is supported by TPG */
-	fmt->code = MEDIA_BUS_FMT_SGRBG8_1X8;
-	if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-		cfg->try_fmt = *fmt;
-		return 0;
-	}
-	return 0;
-}
-
-static int tpg_log_status(struct v4l2_subdev *sd)
-{
-	/*to fake*/
-	return 0;
-}
-
-static int tpg_s_power(struct v4l2_subdev *sd, int on)
-{
-	return 0;
-}
-
-static int tpg_enum_mbus_code(struct v4l2_subdev *sd,
-			      struct v4l2_subdev_pad_config *cfg,
-			      struct v4l2_subdev_mbus_code_enum *code)
-{
-	/*to fake*/
-	return 0;
-}
-
-static int tpg_enum_frame_size(struct v4l2_subdev *sd,
-			       struct v4l2_subdev_pad_config *cfg,
-			       struct v4l2_subdev_frame_size_enum *fse)
-{
-	/*to fake*/
-	return 0;
-}
-
-static int tpg_enum_frame_ival(struct v4l2_subdev *sd,
-			       struct v4l2_subdev_pad_config *cfg,
-			       struct v4l2_subdev_frame_interval_enum *fie)
-{
-	/*to fake*/
-	return 0;
-}
-
-static const struct v4l2_subdev_video_ops tpg_video_ops = {
-	.s_stream = tpg_s_stream,
-};
-
-static const struct v4l2_subdev_core_ops tpg_core_ops = {
-	.log_status = tpg_log_status,
-	.s_power = tpg_s_power,
-};
-
-static const struct v4l2_subdev_pad_ops tpg_pad_ops = {
-	.enum_mbus_code = tpg_enum_mbus_code,
-	.enum_frame_size = tpg_enum_frame_size,
-	.enum_frame_interval = tpg_enum_frame_ival,
-	.get_fmt = tpg_get_fmt,
-	.set_fmt = tpg_set_fmt,
-};
-
-static const struct v4l2_subdev_ops tpg_ops = {
-	.core = &tpg_core_ops,
-	.video = &tpg_video_ops,
-	.pad = &tpg_pad_ops,
-};
-
-void atomisp_tpg_unregister_entities(struct atomisp_tpg_device *tpg)
-{
-	media_entity_cleanup(&tpg->sd.entity);
-	v4l2_device_unregister_subdev(&tpg->sd);
-}
-
-int atomisp_tpg_register_entities(struct atomisp_tpg_device *tpg,
-			struct v4l2_device *vdev)
-{
-	int ret;
-	/* Register the subdev and video nodes. */
-	ret = v4l2_device_register_subdev(vdev, &tpg->sd);
-	if (ret < 0)
-		goto error;
-
-	return 0;
-
-error:
-	atomisp_tpg_unregister_entities(tpg);
-	return ret;
-}
-
-void atomisp_tpg_cleanup(struct atomisp_device *isp)
-{
-
-}
-
-int atomisp_tpg_init(struct atomisp_device *isp)
-{
-	struct atomisp_tpg_device *tpg = &isp->tpg;
-	struct v4l2_subdev *sd = &tpg->sd;
-	struct media_pad *pads = tpg->pads;
-	struct media_entity *me = &sd->entity;
-	int ret;
-
-	tpg->isp = isp;
-	v4l2_subdev_init(sd, &tpg_ops);
-	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	strcpy(sd->name, "tpg_subdev");
-	v4l2_set_subdevdata(sd, tpg);
-
-	pads[0].flags = MEDIA_PAD_FL_SINK;
-	me->function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
-
-	ret = media_entity_pads_init(me, 1, pads);
-	if (ret < 0)
-		goto fail;
-	return 0;
-fail:
-	atomisp_tpg_cleanup(isp);
-	return ret;
-}

+ 0 - 38
drivers/staging/media/atomisp/pci/atomisp2/atomisp_tpg.h

@@ -1,38 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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 __ATOMISP_TPG_H__
-#define __ATOMISP_TPG_H__
-
-#include <media/media-entity.h>
-#include <media/v4l2-subdev.h>
-
-struct atomisp_tpg_device {
-	struct v4l2_subdev sd;
-	struct atomisp_device *isp;
-	struct media_pad pads[1];
-};
-
-void atomisp_tpg_cleanup(struct atomisp_device *isp);
-int atomisp_tpg_init(struct atomisp_device *isp);
-void atomisp_tpg_unregister_entities(struct atomisp_tpg_device *tpg);
-int atomisp_tpg_register_entities(struct atomisp_tpg_device *tpg,
-			struct v4l2_device *vdev);
-
-#endif /* __ATOMISP_TPG_H__ */

+ 0 - 129
drivers/staging/media/atomisp/pci/atomisp2/atomisp_trace_event.h

@@ -1,129 +0,0 @@
-/*
- * Support Camera Imaging tracer core.
- *
- * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
- *
- * 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.
- *
- *
- */
-#undef TRACE_SYSTEM
-#define TRACE_SYSTEM atomisp
-
-#if !defined(ATOMISP_TRACE_EVENT_H) || defined(TRACE_HEADER_MULTI_READ)
-#define ATOMISP_TRACE_EVENT_H
-
-#include <linux/tracepoint.h>
-#include <linux/string.h>
-TRACE_EVENT(camera_meminfo,
-
-	TP_PROTO(const char *name, int uptr_size, int counter, int sys_size,
-		int sys_res_size, int cam_sys_use, int cam_dyc_use,
-		int cam_res_use),
-
-	TP_ARGS(name, uptr_size, counter, sys_size, sys_res_size, cam_sys_use,
-		cam_dyc_use, cam_res_use),
-
-	TP_STRUCT__entry(
-		__array(char, name, 24)
-		__field(int, uptr_size)
-		__field(int, counter)
-		__field(int, sys_size)
-		__field(int, sys_res_size)
-		__field(int, cam_res_use)
-		__field(int, cam_dyc_use)
-		__field(int, cam_sys_use)
-	),
-
-	TP_fast_assign(
-		strlcpy(__entry->name, name, 24);
-		__entry->uptr_size = uptr_size;
-		__entry->counter = counter;
-		__entry->sys_size = sys_size;
-		__entry->sys_res_size = sys_res_size;
-		__entry->cam_res_use = cam_res_use;
-		__entry->cam_dyc_use = cam_dyc_use;
-		__entry->cam_sys_use = cam_sys_use;
-	),
-
-	TP_printk(
-		"<%s> User ptr memory:%d pages,\tISP private memory used:%d"
-		" pages:\tsysFP system size:%d,\treserved size:%d"
-		"\tcamFP sysUse:%d,\tdycUse:%d,\tresUse:%d.\n",
-		__entry->name, __entry->uptr_size, __entry->counter,
-		__entry->sys_size, __entry->sys_res_size, __entry->cam_sys_use,
-		__entry->cam_dyc_use, __entry->cam_res_use)
-);
-
-TRACE_EVENT(camera_debug,
-
-	TP_PROTO(const char *name, char *info, const int line),
-
-	TP_ARGS(name, info, line),
-
-	TP_STRUCT__entry(
-		__array(char, name, 24)
-		__array(char, info, 24)
-		__field(int, line)
-	),
-
-	TP_fast_assign(
-		strlcpy(__entry->name, name, 24);
-		strlcpy(__entry->info, info, 24);
-		__entry->line = line;
-	),
-
-	TP_printk("<%s>-<%d> %s\n", __entry->name, __entry->line,
-		__entry->info)
-);
-
-TRACE_EVENT(ipu_cstate,
-
-		TP_PROTO(int cstate),
-
-		TP_ARGS(cstate),
-
-		TP_STRUCT__entry(
-			__field(int, cstate)
-		),
-
-		TP_fast_assign(
-			__entry->cstate = cstate;
-		),
-
-		TP_printk("cstate=%d", __entry->cstate)
-);
-
-TRACE_EVENT(ipu_pstate,
-
-		TP_PROTO(int freq, int util),
-
-		TP_ARGS(freq, util),
-
-		TP_STRUCT__entry(
-			__field(int, freq)
-			__field(int, util)
-		),
-
-		TP_fast_assign(
-			__entry->freq = freq;
-			__entry->util = util;
-		),
-
-		TP_printk("freq=%d util=%d", __entry->freq, __entry->util)
-);
-#endif
-
-#undef TRACE_INCLUDE_PATH
-#undef TRACE_INCLUDE_FILE
-#define TRACE_INCLUDE_PATH .
-#define TRACE_INCLUDE_FILE   atomisp_trace_event
-/* This part must be outside protection */
-#include <trace/define_trace.h>

+ 0 - 1562
drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c

@@ -1,1562 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010-2017 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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.
- *
- *
- */
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/pm_runtime.h>
-#include <linux/pm_qos.h>
-#include <linux/timer.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-
-#include <asm/iosf_mbi.h>
-
-#include "../../include/linux/atomisp_gmin_platform.h"
-
-#include "atomisp_cmd.h"
-#include "atomisp_common.h"
-#include "atomisp_fops.h"
-#include "atomisp_file.h"
-#include "atomisp_ioctl.h"
-#include "atomisp_internal.h"
-#include "atomisp_acc.h"
-#include "atomisp-regs.h"
-#include "atomisp_dfs_tables.h"
-#include "atomisp_drvfs.h"
-#include "hmm/hmm.h"
-#include "atomisp_trace_event.h"
-
-#include "hrt/hive_isp_css_mm_hrt.h"
-
-#include "device_access.h"
-
-/* G-Min addition: pull this in from intel_mid_pm.h */
-#define CSTATE_EXIT_LATENCY_C1  1
-
-static uint skip_fwload;
-module_param(skip_fwload, uint, 0644);
-MODULE_PARM_DESC(skip_fwload, "Skip atomisp firmware load");
-
-/* set reserved memory pool size in page */
-static unsigned int repool_pgnr;
-module_param(repool_pgnr, uint, 0644);
-MODULE_PARM_DESC(repool_pgnr,
-		"Set the reserved memory pool size in page (default:0)");
-
-/* set dynamic memory pool size in page */
-unsigned int dypool_pgnr = UINT_MAX;
-module_param(dypool_pgnr, uint, 0644);
-MODULE_PARM_DESC(dypool_pgnr,
-		"Set the dynamic memory pool size in page (default:0)");
-
-bool dypool_enable;
-module_param(dypool_enable, bool, 0644);
-MODULE_PARM_DESC(dypool_enable,
-		"dynamic memory pool enable/disable (default:disable)");
-
-/* memory optimization: deferred firmware loading */
-bool defer_fw_load;
-module_param(defer_fw_load, bool, 0644);
-MODULE_PARM_DESC(defer_fw_load,
-		"Defer FW loading until device is opened (default:disable)");
-
-/* cross componnet debug message flag */
-int dbg_level;
-module_param(dbg_level, int, 0644);
-MODULE_PARM_DESC(dbg_level, "debug message on/off (default:off)");
-
-/* log function switch */
-int dbg_func = 2;
-module_param(dbg_func, int, 0644);
-MODULE_PARM_DESC(dbg_func,
-		"log function switch non/trace_printk/printk (default:printk)");
-
-int mipicsi_flag;
-module_param(mipicsi_flag, int, 0644);
-MODULE_PARM_DESC(mipicsi_flag, "mipi csi compression predictor algorithm");
-
-/*set to 16x16 since this is the amount of lines and pixels the sensor
-exports extra. If these are kept at the 10x8 that they were on, in yuv
-downscaling modes incorrect resolutions where requested to the sensor
-driver with strange outcomes as a result. The proper way tot do this
-would be to have a list of tables the specify the sensor res, mipi rec,
-output res, and isp output res. however since we do not have this yet,
-the chosen solution is the next best thing. */
-int pad_w = 16;
-module_param(pad_w, int, 0644);
-MODULE_PARM_DESC(pad_w, "extra data for ISP processing");
-
-int pad_h = 16;
-module_param(pad_h, int, 0644);
-MODULE_PARM_DESC(pad_h, "extra data for ISP processing");
-
-struct device *atomisp_dev;
-
-void __iomem *atomisp_io_base;
-
-int atomisp_video_init(struct atomisp_video_pipe *video, const char *name)
-{
-	int ret;
-	const char *direction;
-
-	switch (video->type) {
-	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
-		direction = "output";
-		video->pad.flags = MEDIA_PAD_FL_SINK;
-		video->vdev.fops = &atomisp_fops;
-		video->vdev.ioctl_ops = &atomisp_ioctl_ops;
-		break;
-	case V4L2_BUF_TYPE_VIDEO_OUTPUT:
-		direction = "input";
-		video->pad.flags = MEDIA_PAD_FL_SOURCE;
-		video->vdev.fops = &atomisp_file_fops;
-		video->vdev.ioctl_ops = &atomisp_file_ioctl_ops;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	ret = media_entity_pads_init(&video->vdev.entity, 1, &video->pad);
-	if (ret < 0)
-		return ret;
-
-	/* Initialize the video device. */
-	snprintf(video->vdev.name, sizeof(video->vdev.name),
-		 "ATOMISP ISP %s %s", name, direction);
-	video->vdev.release = video_device_release_empty;
-	video_set_drvdata(&video->vdev, video->isp);
-
-	return 0;
-}
-
-void atomisp_acc_init(struct atomisp_acc_pipe *video, const char *name)
-{
-	video->vdev.fops = &atomisp_fops;
-	video->vdev.ioctl_ops = &atomisp_ioctl_ops;
-
-	/* Initialize the video device. */
-	snprintf(video->vdev.name, sizeof(video->vdev.name),
-		 "ATOMISP ISP %s", name);
-	video->vdev.release = video_device_release_empty;
-	video_set_drvdata(&video->vdev, video->isp);
-}
-
-int atomisp_video_register(struct atomisp_video_pipe *video,
-	struct v4l2_device *vdev)
-{
-	int ret;
-
-	video->vdev.v4l2_dev = vdev;
-
-	ret = video_register_device(&video->vdev, VFL_TYPE_GRABBER, -1);
-	if (ret < 0)
-		dev_err(vdev->dev, "%s: could not register video device (%d)\n",
-			__func__, ret);
-
-	return ret;
-}
-
-int atomisp_acc_register(struct atomisp_acc_pipe *video,
-		struct v4l2_device *vdev)
-{
-	int ret;
-
-	video->vdev.v4l2_dev = vdev;
-
-	ret = video_register_device(&video->vdev, VFL_TYPE_GRABBER, -1);
-	if (ret < 0)
-		dev_err(vdev->dev, "%s: could not register video device (%d)\n",
-			__func__, ret);
-
-	return ret;
-}
-
-void atomisp_video_unregister(struct atomisp_video_pipe *video)
-{
-	if (video_is_registered(&video->vdev)) {
-		media_entity_cleanup(&video->vdev.entity);
-		video_unregister_device(&video->vdev);
-	}
-}
-
-void atomisp_acc_unregister(struct atomisp_acc_pipe *video)
-{
-	if (video_is_registered(&video->vdev))
-		video_unregister_device(&video->vdev);
-}
-
-static int atomisp_save_iunit_reg(struct atomisp_device *isp)
-{
-	struct pci_dev *dev = isp->pdev;
-
-	dev_dbg(isp->dev, "%s\n", __func__);
-
-	pci_read_config_word(dev, PCI_COMMAND, &isp->saved_regs.pcicmdsts);
-	/* isp->saved_regs.ispmmadr is set from the atomisp_pci_probe() */
-	pci_read_config_dword(dev, PCI_MSI_CAPID, &isp->saved_regs.msicap);
-	pci_read_config_dword(dev, PCI_MSI_ADDR, &isp->saved_regs.msi_addr);
-	pci_read_config_word(dev, PCI_MSI_DATA,  &isp->saved_regs.msi_data);
-	pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &isp->saved_regs.intr);
-	pci_read_config_dword(dev, PCI_INTERRUPT_CTRL,
-			      &isp->saved_regs.interrupt_control);
-
-	pci_read_config_dword(dev, MRFLD_PCI_PMCS,
-			      &isp->saved_regs.pmcs);
-	/* Ensure read/write combining is enabled. */
-	pci_read_config_dword(dev, PCI_I_CONTROL,
-			&isp->saved_regs.i_control);
-	isp->saved_regs.i_control |=
-			MRFLD_PCI_I_CONTROL_ENABLE_READ_COMBINING |
-			MRFLD_PCI_I_CONTROL_ENABLE_WRITE_COMBINING;
-	pci_read_config_dword(dev, MRFLD_PCI_CSI_ACCESS_CTRL_VIOL,
-			      &isp->saved_regs.csi_access_viol);
-	pci_read_config_dword(dev, MRFLD_PCI_CSI_RCOMP_CONTROL,
-			      &isp->saved_regs.csi_rcomp_config);
-	/*
-	 * Hardware bugs require setting CSI_HS_OVR_CLK_GATE_ON_UPDATE.
-	 * ANN/CHV: RCOMP updates do not happen when using CSI2+ path
-	 * and sensor sending "continuous clock".
-	 * TNG/ANN/CHV: MIPI packets are lost if the HS entry sequence
-	 * is missed, and IUNIT can hang.
-	 * For both issues, setting this bit is a workaround.
-	 */
-	isp->saved_regs.csi_rcomp_config |=
-		MRFLD_PCI_CSI_HS_OVR_CLK_GATE_ON_UPDATE;
-	pci_read_config_dword(dev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL,
-			      &isp->saved_regs.csi_afe_dly);
-	pci_read_config_dword(dev, MRFLD_PCI_CSI_CONTROL,
-			      &isp->saved_regs.csi_control);
-	if (isp->media_dev.hw_revision >=
-	    (ATOMISP_HW_REVISION_ISP2401 << ATOMISP_HW_REVISION_SHIFT))
-		isp->saved_regs.csi_control |=
-			MRFLD_PCI_CSI_CONTROL_PARPATHEN;
-	/*
-	 * On CHT CSI_READY bit should be enabled before stream on
-	 */
-	if (IS_CHT && (isp->media_dev.hw_revision >= ((ATOMISP_HW_REVISION_ISP2401 <<
-	    ATOMISP_HW_REVISION_SHIFT) | ATOMISP_HW_STEPPING_B0)))
-		isp->saved_regs.csi_control |=
-			MRFLD_PCI_CSI_CONTROL_CSI_READY;
-	pci_read_config_dword(dev, MRFLD_PCI_CSI_AFE_RCOMP_CONTROL,
-			      &isp->saved_regs.csi_afe_rcomp_config);
-	pci_read_config_dword(dev, MRFLD_PCI_CSI_AFE_HS_CONTROL,
-			      &isp->saved_regs.csi_afe_hs_control);
-	pci_read_config_dword(dev, MRFLD_PCI_CSI_DEADLINE_CONTROL,
-			      &isp->saved_regs.csi_deadline_control);
-	return 0;
-}
-
-static int __maybe_unused atomisp_restore_iunit_reg(struct atomisp_device *isp)
-{
-	struct pci_dev *dev = isp->pdev;
-
-	dev_dbg(isp->dev, "%s\n", __func__);
-
-	pci_write_config_word(dev, PCI_COMMAND, isp->saved_regs.pcicmdsts);
-	pci_write_config_dword(dev, PCI_BASE_ADDRESS_0,
-			       isp->saved_regs.ispmmadr);
-	pci_write_config_dword(dev, PCI_MSI_CAPID, isp->saved_regs.msicap);
-	pci_write_config_dword(dev, PCI_MSI_ADDR, isp->saved_regs.msi_addr);
-	pci_write_config_word(dev, PCI_MSI_DATA, isp->saved_regs.msi_data);
-	pci_write_config_byte(dev, PCI_INTERRUPT_LINE, isp->saved_regs.intr);
-	pci_write_config_dword(dev, PCI_INTERRUPT_CTRL,
-			       isp->saved_regs.interrupt_control);
-	pci_write_config_dword(dev, PCI_I_CONTROL,
-					isp->saved_regs.i_control);
-
-	pci_write_config_dword(dev, MRFLD_PCI_PMCS,
-					isp->saved_regs.pmcs);
-	pci_write_config_dword(dev, MRFLD_PCI_CSI_ACCESS_CTRL_VIOL,
-			      isp->saved_regs.csi_access_viol);
-	pci_write_config_dword(dev, MRFLD_PCI_CSI_RCOMP_CONTROL,
-			      isp->saved_regs.csi_rcomp_config);
-	pci_write_config_dword(dev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL,
-			      isp->saved_regs.csi_afe_dly);
-	pci_write_config_dword(dev, MRFLD_PCI_CSI_CONTROL,
-			      isp->saved_regs.csi_control);
-	pci_write_config_dword(dev, MRFLD_PCI_CSI_AFE_RCOMP_CONTROL,
-			      isp->saved_regs.csi_afe_rcomp_config);
-	pci_write_config_dword(dev, MRFLD_PCI_CSI_AFE_HS_CONTROL,
-			      isp->saved_regs.csi_afe_hs_control);
-	pci_write_config_dword(dev, MRFLD_PCI_CSI_DEADLINE_CONTROL,
-			      isp->saved_regs.csi_deadline_control);
-
-	/*
-	 * for MRFLD, Software/firmware needs to write a 1 to bit0
-	 * of the register at CSI_RECEIVER_SELECTION_REG to enable
-	 * SH CSI backend write 0 will enable Arasan CSI backend,
-	 * which has bugs(like sighting:4567697 and 4567699) and
-	 * will be removed in B0
-	 */
-	atomisp_store_uint32(MRFLD_CSI_RECEIVER_SELECTION_REG, 1);
-	return 0;
-}
-
-static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp)
-{
-	struct pci_dev *dev = isp->pdev;
-	u32 irq;
-	unsigned long flags;
-
-	spin_lock_irqsave(&isp->lock, flags);
-	if (isp->sw_contex.power_state == ATOM_ISP_POWER_DOWN) {
-		spin_unlock_irqrestore(&isp->lock, flags);
-		dev_dbg(isp->dev, "<%s %d.\n", __func__, __LINE__);
-		return 0;
-	}
-	/*
-	 * MRFLD HAS requirement: cannot power off i-unit if
-	 * ISP has IRQ not serviced.
-	 * So, here we need to check if there is any pending
-	 * IRQ, if so, waiting for it to be served
-	 */
-	pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq);
-	irq = irq & 1 << INTR_IIR;
-	pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq);
-
-	pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq);
-	if (!(irq & (1 << INTR_IIR)))
-		goto done;
-
-	atomisp_store_uint32(MRFLD_INTR_CLEAR_REG, 0xFFFFFFFF);
-	atomisp_load_uint32(MRFLD_INTR_STATUS_REG, &irq);
-	if (irq != 0) {
-		dev_err(isp->dev,
-			 "%s: fail to clear isp interrupt status reg=0x%x\n",
-			 __func__, irq);
-		spin_unlock_irqrestore(&isp->lock, flags);
-		return -EAGAIN;
-	} else {
-		pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq);
-		irq = irq & 1 << INTR_IIR;
-		pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq);
-
-		pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq);
-		if (!(irq & (1 << INTR_IIR))) {
-			atomisp_store_uint32(MRFLD_INTR_ENABLE_REG, 0x0);
-			goto done;
-		}
-		dev_err(isp->dev,
-			 "%s: error in iunit interrupt. status reg=0x%x\n",
-			 __func__, irq);
-		spin_unlock_irqrestore(&isp->lock, flags);
-		return -EAGAIN;
-	}
-done:
-	/*
-	* MRFLD WORKAROUND:
-	* before powering off IUNIT, clear the pending interrupts
-	* and disable the interrupt. driver should avoid writing 0
-	* to IIR. It could block subsequent interrupt messages.
-	* HW sighting:4568410.
-	*/
-	pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq);
-	irq &= ~(1 << INTR_IER);
-	pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq);
-
-	atomisp_msi_irq_uninit(isp, dev);
-	atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, true);
-	spin_unlock_irqrestore(&isp->lock, flags);
-
-	return 0;
-}
-
-
- /*
- * WA for DDR DVFS enable/disable
- * By default, ISP will force DDR DVFS 1600MHz before disable DVFS
- */
-static void punit_ddr_dvfs_enable(bool enable)
-{
-	int door_bell = 1 << 8;
-	int max_wait = 30;
-	int reg;
-
-	iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, MRFLD_ISPSSDVFS, &reg);
-	if (enable) {
-		reg &= ~(MRFLD_BIT0 | MRFLD_BIT1);
-	} else {
-		reg |= (MRFLD_BIT1 | door_bell);
-		reg &= ~(MRFLD_BIT0);
-	}
-	iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, MRFLD_ISPSSDVFS, reg);
-
-	/* Check Req_ACK to see freq status, wait until door_bell is cleared */
-	while ((reg & door_bell) && max_wait--) {
-		iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, MRFLD_ISPSSDVFS, &reg);
-		usleep_range(100, 500);
-	}
-
-	if (max_wait == -1)
-		pr_info("DDR DVFS, door bell is not cleared within 3ms\n");
-}
-
-/* Workaround for pmu_nc_set_power_state not ready in MRFLD */
-int atomisp_mrfld_power_down(struct atomisp_device *isp)
-{
-	unsigned long timeout;
-	u32 reg_value;
-
-	/* writing 0x3 to ISPSSPM0 bit[1:0] to power off the IUNIT */
-	iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, MRFLD_ISPSSPM0, &reg_value);
-	reg_value &= ~MRFLD_ISPSSPM0_ISPSSC_MASK;
-	reg_value |= MRFLD_ISPSSPM0_IUNIT_POWER_OFF;
-	iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, MRFLD_ISPSSPM0, reg_value);
-
-	/*WA:Enable DVFS*/
-	if (IS_CHT)
-		punit_ddr_dvfs_enable(true);
-
-	/*
-	 * There should be no iunit access while power-down is
-	 * in progress HW sighting: 4567865
-	 * FIXME: msecs_to_jiffies(50)- experienced value
-	 */
-	timeout = jiffies + msecs_to_jiffies(50);
-	while (1) {
-		iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, MRFLD_ISPSSPM0, &reg_value);
-		dev_dbg(isp->dev, "power-off in progress, ISPSSPM0: 0x%x\n",
-				reg_value);
-		/* wait until ISPSSPM0 bit[25:24] shows 0x3 */
-		if ((reg_value >> MRFLD_ISPSSPM0_ISPSSS_OFFSET) ==
-			MRFLD_ISPSSPM0_IUNIT_POWER_OFF) {
-			trace_ipu_cstate(0);
-			return 0;
-		}
-
-		if (time_after(jiffies, timeout)) {
-			dev_err(isp->dev, "power-off iunit timeout.\n");
-			return -EBUSY;
-		}
-		/* FIXME: experienced value for delay */
-		usleep_range(100, 150);
-	}
-}
-
-
-/* Workaround for pmu_nc_set_power_state not ready in MRFLD */
-int atomisp_mrfld_power_up(struct atomisp_device *isp)
-{
-	unsigned long timeout;
-	u32 reg_value;
-
-	/*WA for PUNIT, if DVFS enabled, ISP timeout observed*/
-	if (IS_CHT)
-		punit_ddr_dvfs_enable(false);
-
-	/*
-	 * FIXME:WA for ECS28A, with this sleep, CTS
-	 * android.hardware.camera2.cts.CameraDeviceTest#testCameraDeviceAbort
-	 * PASS, no impact on other platforms
-	*/
-	if (IS_BYT)
-		msleep(10);
-
-	/* writing 0x0 to ISPSSPM0 bit[1:0] to power off the IUNIT */
-	iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, MRFLD_ISPSSPM0, &reg_value);
-	reg_value &= ~MRFLD_ISPSSPM0_ISPSSC_MASK;
-	iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, MRFLD_ISPSSPM0, reg_value);
-
-	/* FIXME: experienced value for delay */
-	timeout = jiffies + msecs_to_jiffies(50);
-	while (1) {
-		iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, MRFLD_ISPSSPM0, &reg_value);
-		dev_dbg(isp->dev, "power-on in progress, ISPSSPM0: 0x%x\n",
-				reg_value);
-		/* wait until ISPSSPM0 bit[25:24] shows 0x0 */
-		if ((reg_value >> MRFLD_ISPSSPM0_ISPSSS_OFFSET) ==
-			MRFLD_ISPSSPM0_IUNIT_POWER_ON) {
-			trace_ipu_cstate(1);
-			return 0;
-		}
-
-		if (time_after(jiffies, timeout)) {
-			dev_err(isp->dev, "power-on iunit timeout.\n");
-			return -EBUSY;
-		}
-		/* FIXME: experienced value for delay */
-		usleep_range(100, 150);
-	}
-}
-
-int atomisp_runtime_suspend(struct device *dev)
-{
-	struct atomisp_device *isp = (struct atomisp_device *)
-		dev_get_drvdata(dev);
-	int ret;
-
-	ret = atomisp_mrfld_pre_power_down(isp);
-	if (ret)
-		return ret;
-
-	/*Turn off the ISP d-phy*/
-	ret = atomisp_ospm_dphy_down(isp);
-	if (ret)
-		return ret;
-	pm_qos_update_request(&isp->pm_qos, PM_QOS_DEFAULT_VALUE);
-	return atomisp_mrfld_power_down(isp);
-}
-
-int atomisp_runtime_resume(struct device *dev)
-{
-	struct atomisp_device *isp = (struct atomisp_device *)
-		dev_get_drvdata(dev);
-	int ret;
-
-	ret = atomisp_mrfld_power_up(isp);
-	if (ret)
-			return ret;
-
-	pm_qos_update_request(&isp->pm_qos, isp->max_isr_latency);
-	if (isp->sw_contex.power_state == ATOM_ISP_POWER_DOWN) {
-		/*Turn on ISP d-phy */
-		ret = atomisp_ospm_dphy_up(isp);
-		if (ret) {
-			dev_err(isp->dev, "Failed to power up ISP!.\n");
-			return -EINVAL;
-		}
-	}
-
-	/*restore register values for iUnit and iUnitPHY registers*/
-	if (isp->saved_regs.pcicmdsts)
-		atomisp_restore_iunit_reg(isp);
-
-	atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, true);
-	return 0;
-}
-
-static int __maybe_unused atomisp_suspend(struct device *dev)
-{
-	struct atomisp_device *isp = (struct atomisp_device *)
-		dev_get_drvdata(dev);
-	/* FIXME: only has one isp_subdev at present */
-	struct atomisp_sub_device *asd = &isp->asd[0];
-	unsigned long flags;
-	int ret;
-
-	/*
-	 * FIXME: Suspend is not supported by sensors. Abort if any video
-	 * node was opened.
-	 */
-	if (atomisp_dev_users(isp))
-		return -EBUSY;
-
-	spin_lock_irqsave(&isp->lock, flags);
-	if (asd->streaming != ATOMISP_DEVICE_STREAMING_DISABLED) {
-		spin_unlock_irqrestore(&isp->lock, flags);
-		dev_err(isp->dev, "atomisp cannot suspend at this time.\n");
-		return -EINVAL;
-	}
-	spin_unlock_irqrestore(&isp->lock, flags);
-
-	ret = atomisp_mrfld_pre_power_down(isp);
-	if (ret)
-		return ret;
-
-	/*Turn off the ISP d-phy */
-	ret = atomisp_ospm_dphy_down(isp);
-	if (ret) {
-		dev_err(isp->dev, "fail to power off ISP\n");
-		return ret;
-	}
-	pm_qos_update_request(&isp->pm_qos, PM_QOS_DEFAULT_VALUE);
-	return atomisp_mrfld_power_down(isp);
-}
-
-static int __maybe_unused atomisp_resume(struct device *dev)
-{
-	struct atomisp_device *isp = (struct atomisp_device *)
-		dev_get_drvdata(dev);
-	int ret;
-
-	ret = atomisp_mrfld_power_up(isp);
-	if (ret)
-		return ret;
-
-	pm_qos_update_request(&isp->pm_qos, isp->max_isr_latency);
-
-	/*Turn on ISP d-phy */
-	ret = atomisp_ospm_dphy_up(isp);
-	if (ret) {
-		dev_err(isp->dev, "Failed to power up ISP!.\n");
-		return -EINVAL;
-	}
-
-	/*restore register values for iUnit and iUnitPHY registers*/
-	if (isp->saved_regs.pcicmdsts)
-		atomisp_restore_iunit_reg(isp);
-
-	atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, true);
-	return 0;
-}
-
-int atomisp_csi_lane_config(struct atomisp_device *isp)
-{
-	static const struct {
-		u8 code;
-		u8 lanes[MRFLD_PORT_NUM];
-	} portconfigs[] = {
-		/* Tangier/Merrifield available lane configurations */
-		{ 0x00, { 4, 1, 0 } },		/* 00000 */
-		{ 0x01, { 3, 1, 0 } },		/* 00001 */
-		{ 0x02, { 2, 1, 0 } },		/* 00010 */
-		{ 0x03, { 1, 1, 0 } },		/* 00011 */
-		{ 0x04, { 2, 1, 2 } },		/* 00100 */
-		{ 0x08, { 3, 1, 1 } },		/* 01000 */
-		{ 0x09, { 2, 1, 1 } },		/* 01001 */
-		{ 0x0a, { 1, 1, 1 } },		/* 01010 */
-
-		/* Anniedale/Moorefield only configurations */
-		{ 0x10, { 4, 2, 0 } },		/* 10000 */
-		{ 0x11, { 3, 2, 0 } },		/* 10001 */
-		{ 0x12, { 2, 2, 0 } },		/* 10010 */
-		{ 0x13, { 1, 2, 0 } },		/* 10011 */
-		{ 0x14, { 2, 2, 2 } },		/* 10100 */
-		{ 0x18, { 3, 2, 1 } },		/* 11000 */
-		{ 0x19, { 2, 2, 1 } },		/* 11001 */
-		{ 0x1a, { 1, 2, 1 } },		/* 11010 */
-	};
-
-	unsigned int i, j;
-	u8 sensor_lanes[MRFLD_PORT_NUM] = { 0 };
-	u32 csi_control;
-	int nportconfigs;
-	u32 port_config_mask;
-	int port3_lanes_shift;
-
-	if (isp->media_dev.hw_revision <
-		ATOMISP_HW_REVISION_ISP2401_LEGACY <<
-		ATOMISP_HW_REVISION_SHIFT) {
-		/* Merrifield */
-		port_config_mask = MRFLD_PORT_CONFIG_MASK;
-		port3_lanes_shift = MRFLD_PORT3_LANES_SHIFT;
-	} else {
-		/* Moorefield / Cherryview */
-		port_config_mask = CHV_PORT_CONFIG_MASK;
-		port3_lanes_shift = CHV_PORT3_LANES_SHIFT;
-	}
-
-	if (isp->media_dev.hw_revision <
-		ATOMISP_HW_REVISION_ISP2401 <<
-		ATOMISP_HW_REVISION_SHIFT) {
-		/* Merrifield / Moorefield legacy input system */
-		nportconfigs = MRFLD_PORT_CONFIG_NUM;
-	} else {
-		/* Moorefield / Cherryview new input system */
-		nportconfigs = ARRAY_SIZE(portconfigs);
-	}
-
-	for (i = 0; i < isp->input_cnt; i++) {
-		struct camera_mipi_info *mipi_info;
-
-		if (isp->inputs[i].type != RAW_CAMERA &&
-		    isp->inputs[i].type != SOC_CAMERA)
-			continue;
-
-		mipi_info = atomisp_to_sensor_mipi_info(isp->inputs[i].camera);
-		if (!mipi_info)
-			continue;
-
-		switch (mipi_info->port) {
-		case ATOMISP_CAMERA_PORT_PRIMARY:
-			sensor_lanes[0] = mipi_info->num_lanes;
-			break;
-		case ATOMISP_CAMERA_PORT_SECONDARY:
-			sensor_lanes[1] = mipi_info->num_lanes;
-			break;
-		case ATOMISP_CAMERA_PORT_TERTIARY:
-			sensor_lanes[2] = mipi_info->num_lanes;
-			break;
-		default:
-			dev_err(isp->dev,
-				"%s: invalid port: %d for the %dth sensor\n",
-				__func__, mipi_info->port, i);
-			return -EINVAL;
-		}
-	}
-
-	for (i = 0; i < nportconfigs; i++) {
-		for (j = 0; j < MRFLD_PORT_NUM; j++)
-			if (sensor_lanes[j] &&
-			    sensor_lanes[j] != portconfigs[i].lanes[j])
-				break;
-
-		if (j == MRFLD_PORT_NUM)
-			break;			/* Found matching setting */
-	}
-
-	if (i >= nportconfigs) {
-		dev_err(isp->dev,
-			"%s: could not find the CSI port setting for %d-%d-%d\n",
-			__func__,
-			sensor_lanes[0], sensor_lanes[1], sensor_lanes[2]);
-		return -EINVAL;
-	}
-
-	pci_read_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, &csi_control);
-	csi_control &= ~port_config_mask;
-	csi_control |= (portconfigs[i].code << MRFLD_PORT_CONFIGCODE_SHIFT)
-		| (portconfigs[i].lanes[0] ? 0 : (1 << MRFLD_PORT1_ENABLE_SHIFT))
-		| (portconfigs[i].lanes[1] ? 0 : (1 << MRFLD_PORT2_ENABLE_SHIFT))
-		| (portconfigs[i].lanes[2] ? 0 : (1 << MRFLD_PORT3_ENABLE_SHIFT))
-		| (((1 << portconfigs[i].lanes[0]) - 1) << MRFLD_PORT1_LANES_SHIFT)
-		| (((1 << portconfigs[i].lanes[1]) - 1) << MRFLD_PORT2_LANES_SHIFT)
-		| (((1 << portconfigs[i].lanes[2]) - 1) << port3_lanes_shift);
-
-	pci_write_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, csi_control);
-
-	dev_dbg(isp->dev,
-		"%s: the portconfig is %d-%d-%d, CSI_CONTROL is 0x%08X\n",
-		__func__, portconfigs[i].lanes[0], portconfigs[i].lanes[1],
-		portconfigs[i].lanes[2], csi_control);
-
-	return 0;
-}
-
-static int atomisp_subdev_probe(struct atomisp_device *isp)
-{
-	const struct atomisp_platform_data *pdata;
-	struct intel_v4l2_subdev_table *subdevs;
-	int ret, raw_index = -1;
-
-	pdata = atomisp_get_platform_data();
-	if (pdata == NULL) {
-		dev_err(isp->dev, "no platform data available\n");
-		return 0;
-	}
-
-	for (subdevs = pdata->subdevs; subdevs->type; ++subdevs) {
-		struct v4l2_subdev *subdev;
-		struct i2c_board_info *board_info =
-			&subdevs->v4l2_subdev.board_info;
-		struct i2c_adapter *adapter =
-			i2c_get_adapter(subdevs->v4l2_subdev.i2c_adapter_id);
-		int sensor_num, i;
-
-		if (adapter == NULL) {
-			dev_err(isp->dev,
-				"Failed to find i2c adapter for subdev %s\n",
-				board_info->type);
-			break;
-		}
-
-		/* In G-Min, the sensor devices will already be probed
-		 * (via ACPI) and registered, do not create new
-		 * ones */
-		subdev = atomisp_gmin_find_subdev(adapter, board_info);
-		ret = v4l2_device_register_subdev(&isp->v4l2_dev, subdev);
-		if (ret) {
-			dev_warn(isp->dev, "Subdev %s detection fail\n",
-				 board_info->type);
-			continue;
-		}
-
-		if (subdev == NULL) {
-			dev_warn(isp->dev, "Subdev %s detection fail\n",
-				 board_info->type);
-			continue;
-		}
-
-		dev_info(isp->dev, "Subdev %s successfully register\n",
-			 board_info->type);
-
-		switch (subdevs->type) {
-		case RAW_CAMERA:
-			raw_index = isp->input_cnt;
-			dev_dbg(isp->dev, "raw_index: %d\n", raw_index);
-		case SOC_CAMERA:
-			dev_dbg(isp->dev, "SOC_INDEX: %d\n", isp->input_cnt);
-			if (isp->input_cnt >= ATOM_ISP_MAX_INPUTS) {
-				dev_warn(isp->dev,
-					 "too many atomisp inputs, ignored\n");
-				break;
-			}
-
-			isp->inputs[isp->input_cnt].type = subdevs->type;
-			isp->inputs[isp->input_cnt].port = subdevs->port;
-			isp->inputs[isp->input_cnt].camera = subdev;
-			isp->inputs[isp->input_cnt].sensor_index = 0;
-			/*
-			 * initialize the subdev frame size, then next we can
-			 * judge whether frame_size store effective value via
-			 * pixel_format.
-			 */
-			isp->inputs[isp->input_cnt].frame_size.pixel_format = 0;
-			isp->inputs[isp->input_cnt].camera_caps =
-					atomisp_get_default_camera_caps();
-			sensor_num = isp->inputs[isp->input_cnt]
-				.camera_caps->sensor_num;
-			isp->input_cnt++;
-			for (i = 1; i < sensor_num; i++) {
-				if (isp->input_cnt >= ATOM_ISP_MAX_INPUTS) {
-					dev_warn(isp->dev,
-						"atomisp inputs out of range\n");
-					break;
-				}
-				isp->inputs[isp->input_cnt] =
-					isp->inputs[isp->input_cnt - 1];
-				isp->inputs[isp->input_cnt].sensor_index = i;
-				isp->input_cnt++;
-			}
-			break;
-		case CAMERA_MOTOR:
-			isp->motor = subdev;
-			break;
-		case LED_FLASH:
-		case XENON_FLASH:
-			isp->flash = subdev;
-			break;
-		default:
-			dev_dbg(isp->dev, "unknown subdev probed\n");
-			break;
-		}
-
-	}
-
-	/*
-	 * HACK: Currently VCM belongs to primary sensor only, but correct
-	 * approach must be to acquire from platform code which sensor
-	 * owns it.
-	 */
-	if (isp->motor && raw_index >= 0)
-		isp->inputs[raw_index].motor = isp->motor;
-
-	/* Proceed even if no modules detected. For COS mode and no modules. */
-	if (!isp->inputs[0].camera)
-		dev_warn(isp->dev, "no camera attached or fail to detect\n");
-
-	return atomisp_csi_lane_config(isp);
-}
-
-static void atomisp_unregister_entities(struct atomisp_device *isp)
-{
-	unsigned int i;
-	struct v4l2_subdev *sd, *next;
-
-	for (i = 0; i < isp->num_of_streams; i++)
-		atomisp_subdev_unregister_entities(&isp->asd[i]);
-	atomisp_tpg_unregister_entities(&isp->tpg);
-	atomisp_file_input_unregister_entities(&isp->file_dev);
-	for (i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++)
-		atomisp_mipi_csi2_unregister_entities(&isp->csi2_port[i]);
-
-	list_for_each_entry_safe(sd, next, &isp->v4l2_dev.subdevs, list)
-		v4l2_device_unregister_subdev(sd);
-
-	v4l2_device_unregister(&isp->v4l2_dev);
-	media_device_unregister(&isp->media_dev);
-}
-
-static int atomisp_register_entities(struct atomisp_device *isp)
-{
-	int ret = 0;
-	unsigned int i;
-
-	isp->media_dev.dev = isp->dev;
-
-	strlcpy(isp->media_dev.model, "Intel Atom ISP",
-		sizeof(isp->media_dev.model));
-
-	media_device_init(&isp->media_dev);
-	isp->v4l2_dev.mdev = &isp->media_dev;
-	ret = v4l2_device_register(isp->dev, &isp->v4l2_dev);
-	if (ret < 0) {
-		dev_err(isp->dev, "%s: V4L2 device registration failed (%d)\n",
-			__func__, ret);
-		goto v4l2_device_failed;
-	}
-
-	ret = atomisp_subdev_probe(isp);
-	if (ret < 0)
-		goto csi_and_subdev_probe_failed;
-
-	/* Register internal entities */
-	for (i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++) {
-		ret = atomisp_mipi_csi2_register_entities(&isp->csi2_port[i],
-								&isp->v4l2_dev);
-		if (ret == 0)
-			continue;
-
-		/* error case */
-		dev_err(isp->dev, "failed to register the CSI port: %d\n", i);
-		/* deregister all registered CSI ports */
-		while (i--)
-			atomisp_mipi_csi2_unregister_entities(
-							&isp->csi2_port[i]);
-
-		goto csi_and_subdev_probe_failed;
-	}
-
-	ret =
-	atomisp_file_input_register_entities(&isp->file_dev, &isp->v4l2_dev);
-	if (ret < 0) {
-		dev_err(isp->dev, "atomisp_file_input_register_entities\n");
-		goto file_input_register_failed;
-	}
-
-	ret = atomisp_tpg_register_entities(&isp->tpg, &isp->v4l2_dev);
-	if (ret < 0) {
-		dev_err(isp->dev, "atomisp_tpg_register_entities\n");
-		goto tpg_register_failed;
-	}
-
-	for (i = 0; i < isp->num_of_streams; i++) {
-		struct atomisp_sub_device *asd = &isp->asd[i];
-
-		ret = atomisp_subdev_register_entities(asd, &isp->v4l2_dev);
-		if (ret < 0) {
-			dev_err(isp->dev,
-				"atomisp_subdev_register_entities fail\n");
-			for (; i > 0; i--)
-				atomisp_subdev_unregister_entities(
-						&isp->asd[i - 1]);
-			goto subdev_register_failed;
-		}
-	}
-
-	for (i = 0; i < isp->num_of_streams; i++) {
-		struct atomisp_sub_device *asd = &isp->asd[i];
-
-		init_completion(&asd->init_done);
-
-		asd->delayed_init_workq =
-			alloc_workqueue(isp->v4l2_dev.name, WQ_CPU_INTENSIVE,
-					1);
-		if (asd->delayed_init_workq == NULL) {
-			dev_err(isp->dev,
-					"Failed to initialize delayed init workq\n");
-			ret = -ENOMEM;
-
-			for (; i > 0; i--)
-				destroy_workqueue(isp->asd[i - 1].
-						delayed_init_workq);
-			goto wq_alloc_failed;
-		}
-		INIT_WORK(&asd->delayed_init_work, atomisp_delayed_init_work);
-	}
-
-	for (i = 0; i < isp->input_cnt; i++) {
-		if (isp->inputs[i].port >= ATOMISP_CAMERA_NR_PORTS) {
-			dev_err(isp->dev, "isp->inputs port %d not supported\n",
-					isp->inputs[i].port);
-			ret = -EINVAL;
-			goto link_failed;
-		}
-	}
-
-	dev_dbg(isp->dev,
-		"FILE_INPUT enable, camera_cnt: %d\n", isp->input_cnt);
-	isp->inputs[isp->input_cnt].type = FILE_INPUT;
-	isp->inputs[isp->input_cnt].port = -1;
-	isp->inputs[isp->input_cnt].camera_caps =
-		    atomisp_get_default_camera_caps();
-	isp->inputs[isp->input_cnt++].camera = &isp->file_dev.sd;
-
-	if (isp->input_cnt < ATOM_ISP_MAX_INPUTS) {
-		dev_dbg(isp->dev,
-			"TPG detected, camera_cnt: %d\n", isp->input_cnt);
-		isp->inputs[isp->input_cnt].type = TEST_PATTERN;
-		isp->inputs[isp->input_cnt].port = -1;
-		isp->inputs[isp->input_cnt].camera_caps =
-		    atomisp_get_default_camera_caps();
-		isp->inputs[isp->input_cnt++].camera = &isp->tpg.sd;
-	} else {
-		dev_warn(isp->dev, "too many atomisp inputs, TPG ignored.\n");
-	}
-
-	ret = v4l2_device_register_subdev_nodes(&isp->v4l2_dev);
-	if (ret < 0)
-		goto link_failed;
-
-	return media_device_register(&isp->media_dev);
-
-link_failed:
-	for (i = 0; i < isp->num_of_streams; i++)
-		destroy_workqueue(isp->asd[i].
-				delayed_init_workq);
-wq_alloc_failed:
-	for (i = 0; i < isp->num_of_streams; i++)
-		atomisp_subdev_unregister_entities(
-					&isp->asd[i]);
-subdev_register_failed:
-	atomisp_tpg_unregister_entities(&isp->tpg);
-tpg_register_failed:
-	atomisp_file_input_unregister_entities(&isp->file_dev);
-file_input_register_failed:
-	for (i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++)
-		atomisp_mipi_csi2_unregister_entities(&isp->csi2_port[i]);
-csi_and_subdev_probe_failed:
-	v4l2_device_unregister(&isp->v4l2_dev);
-v4l2_device_failed:
-	media_device_unregister(&isp->media_dev);
-	media_device_cleanup(&isp->media_dev);
-	return ret;
-}
-
-static int atomisp_initialize_modules(struct atomisp_device *isp)
-{
-	int ret;
-
-	ret = atomisp_mipi_csi2_init(isp);
-	if (ret < 0) {
-		dev_err(isp->dev, "mipi csi2 initialization failed\n");
-		goto error_mipi_csi2;
-	}
-
-	ret = atomisp_file_input_init(isp);
-	if (ret < 0) {
-		dev_err(isp->dev,
-			"file input device initialization failed\n");
-		goto error_file_input;
-	}
-
-	ret = atomisp_tpg_init(isp);
-	if (ret < 0) {
-		dev_err(isp->dev, "tpg initialization failed\n");
-		goto error_tpg;
-	}
-
-	ret = atomisp_subdev_init(isp);
-	if (ret < 0) {
-		dev_err(isp->dev, "ISP subdev initialization failed\n");
-		goto error_isp_subdev;
-	}
-
-
-	return 0;
-
-error_isp_subdev:
-error_tpg:
-	atomisp_tpg_cleanup(isp);
-error_file_input:
-	atomisp_file_input_cleanup(isp);
-error_mipi_csi2:
-	atomisp_mipi_csi2_cleanup(isp);
-	return ret;
-}
-
-static void atomisp_uninitialize_modules(struct atomisp_device *isp)
-{
-	atomisp_tpg_cleanup(isp);
-	atomisp_file_input_cleanup(isp);
-	atomisp_mipi_csi2_cleanup(isp);
-}
-
-const struct firmware *
-atomisp_load_firmware(struct atomisp_device *isp)
-{
-	const struct firmware *fw;
-	int rc;
-	char *fw_path = NULL;
-
-	if (skip_fwload)
-		return NULL;
-
-	if (isp->media_dev.hw_revision ==
-	    ((ATOMISP_HW_REVISION_ISP2401 << ATOMISP_HW_REVISION_SHIFT)
-	     | ATOMISP_HW_STEPPING_A0))
-		fw_path = "shisp_2401a0_v21.bin";
-
-	if (isp->media_dev.hw_revision ==
-	    ((ATOMISP_HW_REVISION_ISP2401_LEGACY << ATOMISP_HW_REVISION_SHIFT)
-	     | ATOMISP_HW_STEPPING_A0))
-		fw_path = "shisp_2401a0_legacy_v21.bin";
-
-	if (isp->media_dev.hw_revision ==
-	    ((ATOMISP_HW_REVISION_ISP2400 << ATOMISP_HW_REVISION_SHIFT)
-	     | ATOMISP_HW_STEPPING_B0))
-		fw_path = "shisp_2400b0_v21.bin";
-
-	if (!fw_path) {
-		dev_err(isp->dev, "Unsupported hw_revision 0x%x\n",
-			isp->media_dev.hw_revision);
-		return NULL;
-	}
-
-	rc = request_firmware(&fw, fw_path, isp->dev);
-	if (rc) {
-		dev_err(isp->dev,
-			"atomisp: Error %d while requesting firmware %s\n",
-			rc, fw_path);
-		return NULL;
-	}
-
-	return fw;
-}
-
-/*
- * Check for flags the driver was compiled with against the PCI
- * device. Always returns true on other than ISP 2400.
- */
-static bool is_valid_device(struct pci_dev *dev,
-			    const struct pci_device_id *id)
-{
-	unsigned int a0_max_id;
-
-	switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) {
-	case ATOMISP_PCI_DEVICE_SOC_MRFLD:
-		a0_max_id = ATOMISP_PCI_REV_MRFLD_A0_MAX;
-		break;
-	case ATOMISP_PCI_DEVICE_SOC_BYT:
-		a0_max_id = ATOMISP_PCI_REV_BYT_A0_MAX;
-		break;
-	default:
-		return true;
-	}
-
-	return dev->revision > a0_max_id;
-}
-
-static int init_atomisp_wdts(struct atomisp_device *isp)
-{
-	int i, err;
-
-	atomic_set(&isp->wdt_work_queued, 0);
-	isp->wdt_work_queue = alloc_workqueue(isp->v4l2_dev.name, 0, 1);
-	if (isp->wdt_work_queue == NULL) {
-		dev_err(isp->dev, "Failed to initialize wdt work queue\n");
-		err = -ENOMEM;
-		goto alloc_fail;
-	}
-	INIT_WORK(&isp->wdt_work, atomisp_wdt_work);
-
-	for (i = 0; i < isp->num_of_streams; i++) {
-		struct atomisp_sub_device *asd = &isp->asd[i];
-#ifndef ISP2401
-		timer_setup(&asd->wdt, atomisp_wdt, 0);
-#else
-		timer_setup(&asd->video_out_capture.wdt, atomisp_wdt, 0);
-		timer_setup(&asd->video_out_preview.wdt, atomisp_wdt, 0);
-		timer_setup(&asd->video_out_vf.wdt, atomisp_wdt, 0);
-		timer_setup(&asd->video_out_video_capture.wdt, atomisp_wdt, 0);
-#endif
-	}
-	return 0;
-alloc_fail:
-	return err;
-}
-
-#define ATOM_ISP_PCI_BAR	0
-
-static int atomisp_pci_probe(struct pci_dev *dev,
-				       const struct pci_device_id *id)
-{
-	const struct atomisp_platform_data *pdata;
-	struct atomisp_device *isp;
-	unsigned int start;
-	void __iomem *base;
-	int err, val;
-	u32 irq;
-
-	if (!dev) {
-		dev_err(&dev->dev, "atomisp: error device ptr\n");
-		return -EINVAL;
-	}
-
-	if (!is_valid_device(dev, id))
-		return -ENODEV;
-	/* Pointer to struct device. */
-	atomisp_dev = &dev->dev;
-
-	pdata = atomisp_get_platform_data();
-	if (pdata == NULL)
-		dev_warn(&dev->dev, "no platform data available\n");
-
-	err = pcim_enable_device(dev);
-	if (err) {
-		dev_err(&dev->dev, "Failed to enable CI ISP device (%d)\n",
-			err);
-		return err;
-	}
-
-	start = pci_resource_start(dev, ATOM_ISP_PCI_BAR);
-	dev_dbg(&dev->dev, "start: 0x%x\n", start);
-
-	err = pcim_iomap_regions(dev, 1 << ATOM_ISP_PCI_BAR, pci_name(dev));
-	if (err) {
-		dev_err(&dev->dev, "Failed to I/O memory remapping (%d)\n",
-			err);
-		return err;
-	}
-
-	base = pcim_iomap_table(dev)[ATOM_ISP_PCI_BAR];
-	dev_dbg(&dev->dev, "base: %p\n", base);
-
-	atomisp_io_base = base;
-
-	dev_dbg(&dev->dev, "atomisp_io_base: %p\n", atomisp_io_base);
-
-	isp = devm_kzalloc(&dev->dev, sizeof(struct atomisp_device), GFP_KERNEL);
-	if (!isp) {
-		dev_err(&dev->dev, "Failed to alloc CI ISP structure\n");
-		return -ENOMEM;
-	}
-	isp->pdev = dev;
-	isp->dev = &dev->dev;
-	isp->sw_contex.power_state = ATOM_ISP_POWER_UP;
-	isp->saved_regs.ispmmadr = start;
-
-	rt_mutex_init(&isp->mutex);
-	mutex_init(&isp->streamoff_mutex);
-	spin_lock_init(&isp->lock);
-
-	/* This is not a true PCI device on SoC, so the delay is not needed. */
-	isp->pdev->d3_delay = 0;
-
-	switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) {
-	case ATOMISP_PCI_DEVICE_SOC_MRFLD:
-		isp->media_dev.hw_revision =
-			(ATOMISP_HW_REVISION_ISP2400
-			 << ATOMISP_HW_REVISION_SHIFT) |
-			ATOMISP_HW_STEPPING_B0;
-
-		switch (id->device) {
-		case ATOMISP_PCI_DEVICE_SOC_MRFLD_1179:
-			isp->dfs = &dfs_config_merr_1179;
-			break;
-		case ATOMISP_PCI_DEVICE_SOC_MRFLD_117A:
-			isp->dfs = &dfs_config_merr_117a;
-			break;
-		default:
-			isp->dfs = &dfs_config_merr;
-			break;
-		}
-		isp->hpll_freq = HPLL_FREQ_1600MHZ;
-		break;
-	case ATOMISP_PCI_DEVICE_SOC_BYT:
-		isp->media_dev.hw_revision =
-			(ATOMISP_HW_REVISION_ISP2400
-			 << ATOMISP_HW_REVISION_SHIFT) |
-			ATOMISP_HW_STEPPING_B0;
-#ifdef FIXME			
-		if (INTEL_MID_BOARD(3, TABLET, BYT, BLK, PRO, CRV2) ||
-			INTEL_MID_BOARD(3, TABLET, BYT, BLK, ENG, CRV2)) {
-			isp->dfs = &dfs_config_byt_cr;
-			isp->hpll_freq = HPLL_FREQ_2000MHZ;
-		} else
-#endif		
-		{
-			isp->dfs = &dfs_config_byt;
-			isp->hpll_freq = HPLL_FREQ_1600MHZ;
-		}
-		/* HPLL frequency is known to be device-specific, but we don't
-		 * have specs yet for exactly how it varies.  Default to
-		 * BYT-CR but let provisioning set it via EFI variable */
-		isp->hpll_freq = gmin_get_var_int(&dev->dev, "HpllFreq",
-					HPLL_FREQ_2000MHZ);
-
-		/*
-		 * for BYT/CHT we are put isp into D3cold to avoid pci registers access
-		 * in power off. Set d3cold_delay to 0 since default 100ms is not
-		 * necessary.
-		 */
-		isp->pdev->d3cold_delay = 0;
-		break;
-	case ATOMISP_PCI_DEVICE_SOC_ANN:
-		isp->media_dev.hw_revision = (
-#ifdef ISP2401_NEW_INPUT_SYSTEM
-			 ATOMISP_HW_REVISION_ISP2401
-#else
-			 ATOMISP_HW_REVISION_ISP2401_LEGACY
-#endif
-			 << ATOMISP_HW_REVISION_SHIFT);
-		isp->media_dev.hw_revision |= isp->pdev->revision < 2 ?
-			ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0;
-		isp->dfs = &dfs_config_merr;
-		isp->hpll_freq = HPLL_FREQ_1600MHZ;
-		break;
-	case ATOMISP_PCI_DEVICE_SOC_CHT:
-		isp->media_dev.hw_revision = (
-#ifdef ISP2401_NEW_INPUT_SYSTEM
-			 ATOMISP_HW_REVISION_ISP2401
-#else
-			 ATOMISP_HW_REVISION_ISP2401_LEGACY
-#endif
-			<< ATOMISP_HW_REVISION_SHIFT);
-		isp->media_dev.hw_revision |= isp->pdev->revision < 2 ?
-			 ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0;
-
-		isp->dfs = &dfs_config_cht;
-		isp->pdev->d3cold_delay = 0;
-
-		iosf_mbi_read(CCK_PORT, MBI_REG_READ, CCK_FUSE_REG_0, &val);
-		switch (val & CCK_FUSE_HPLL_FREQ_MASK) {
-		case 0x00:
-			isp->hpll_freq = HPLL_FREQ_800MHZ;
-			break;
-		case 0x01:
-			isp->hpll_freq = HPLL_FREQ_1600MHZ;
-			break;
-		case 0x02:
-			isp->hpll_freq = HPLL_FREQ_2000MHZ;
-			break;
-		default:
-			isp->hpll_freq = HPLL_FREQ_1600MHZ;
-			dev_warn(isp->dev,
-				 "read HPLL from cck failed.default 1600MHz.\n");
-		}
-		break;
-	default:
-		dev_err(&dev->dev, "un-supported IUNIT device\n");
-		return -ENODEV;
-	}
-
-	dev_info(&dev->dev, "ISP HPLL frequency base = %d MHz\n",
-		 isp->hpll_freq);
-
-	isp->max_isr_latency = ATOMISP_MAX_ISR_LATENCY;
-
-	/* Load isp firmware from user space */
-	if (!defer_fw_load) {
-		isp->firmware = atomisp_load_firmware(isp);
-		if (!isp->firmware) {
-			err = -ENOENT;
-			goto load_fw_fail;
-		}
-
-		err = atomisp_css_check_firmware_version(isp);
-		if (err) {
-			dev_dbg(&dev->dev, "Firmware version check failed\n");
-			goto fw_validation_fail;
-		}
-	}
-
-	pci_set_master(dev);
-	pci_set_drvdata(dev, isp);
-
-	err = pci_enable_msi(dev);
-	if (err) {
-		dev_err(&dev->dev, "Failed to enable msi (%d)\n", err);
-		goto enable_msi_fail;
-	}
-
-	atomisp_msi_irq_init(isp, dev);
-
-	pm_qos_add_request(&isp->pm_qos, PM_QOS_CPU_DMA_LATENCY,
-			   PM_QOS_DEFAULT_VALUE);
-
-	/*
-	 * for MRFLD, Software/firmware needs to write a 1 to bit 0 of
-	 * the register at CSI_RECEIVER_SELECTION_REG to enable SH CSI
-	 * backend write 0 will enable Arasan CSI backend, which has
-	 * bugs(like sighting:4567697 and 4567699) and will be removed
-	 * in B0
-	 */
-	atomisp_store_uint32(MRFLD_CSI_RECEIVER_SELECTION_REG, 1);
-
-	if ((id->device & ATOMISP_PCI_DEVICE_SOC_MASK) ==
-			ATOMISP_PCI_DEVICE_SOC_MRFLD) {
-		u32 csi_afe_trim;
-
-		/*
-		 * Workaround for imbalance data eye issue which is observed
-		 * on TNG B0.
-		 */
-		pci_read_config_dword(dev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL,
-				      &csi_afe_trim);
-		csi_afe_trim &= ~((MRFLD_PCI_CSI_HSRXCLKTRIM_MASK <<
-					MRFLD_PCI_CSI1_HSRXCLKTRIM_SHIFT) |
-				  (MRFLD_PCI_CSI_HSRXCLKTRIM_MASK <<
-					MRFLD_PCI_CSI2_HSRXCLKTRIM_SHIFT) |
-				  (MRFLD_PCI_CSI_HSRXCLKTRIM_MASK <<
-					MRFLD_PCI_CSI3_HSRXCLKTRIM_SHIFT));
-		csi_afe_trim |= (MRFLD_PCI_CSI1_HSRXCLKTRIM <<
-					MRFLD_PCI_CSI1_HSRXCLKTRIM_SHIFT) |
-				(MRFLD_PCI_CSI2_HSRXCLKTRIM <<
-					MRFLD_PCI_CSI2_HSRXCLKTRIM_SHIFT) |
-				(MRFLD_PCI_CSI3_HSRXCLKTRIM <<
-					MRFLD_PCI_CSI3_HSRXCLKTRIM_SHIFT);
-		pci_write_config_dword(dev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL,
-				      csi_afe_trim);
-	}
-
-	err = atomisp_initialize_modules(isp);
-	if (err < 0) {
-		dev_err(&dev->dev, "atomisp_initialize_modules (%d)\n", err);
-		goto initialize_modules_fail;
-	}
-
-	err = atomisp_register_entities(isp);
-	if (err < 0) {
-		dev_err(&dev->dev, "atomisp_register_entities failed (%d)\n",
-			err);
-		goto register_entities_fail;
-	}
-	err = atomisp_create_pads_links(isp);
-	if (err < 0)
-		goto register_entities_fail;
-	/* init atomisp wdts */
-	if (init_atomisp_wdts(isp) != 0)
-		goto wdt_work_queue_fail;
-
-	/* save the iunit context only once after all the values are init'ed. */
-	atomisp_save_iunit_reg(isp);
-
-	pm_runtime_put_noidle(&dev->dev);
-	pm_runtime_allow(&dev->dev);
-
-	hmm_init_mem_stat(repool_pgnr, dypool_enable, dypool_pgnr);
-	err = hmm_pool_register(repool_pgnr, HMM_POOL_TYPE_RESERVED);
-	if (err) {
-		dev_err(&dev->dev, "Failed to register reserved memory pool.\n");
-		goto hmm_pool_fail;
-	}
-
-	/* Init ISP memory management */
-	hmm_init();
-
-	err = devm_request_threaded_irq(&dev->dev, dev->irq,
-					atomisp_isr, atomisp_isr_thread,
-					IRQF_SHARED, "isp_irq", isp);
-	if (err) {
-		dev_err(&dev->dev, "Failed to request irq (%d)\n", err);
-		goto request_irq_fail;
-	}
-
-	/* Load firmware into ISP memory */
-	if (!defer_fw_load) {
-		err = atomisp_css_load_firmware(isp);
-		if (err) {
-			dev_err(&dev->dev, "Failed to init css.\n");
-			goto css_init_fail;
-		}
-	} else {
-		dev_dbg(&dev->dev, "Skip css init.\n");
-	}
-	/* Clear FW image from memory */
-	release_firmware(isp->firmware);
-	isp->firmware = NULL;
-	isp->css_env.isp_css_fw.data = NULL;
-
-	atomisp_drvfs_init(&dev->driver->driver, isp);
-
-	return 0;
-
-css_init_fail:
-	devm_free_irq(&dev->dev, dev->irq, isp);
-request_irq_fail:
-	hmm_cleanup();
-	hmm_pool_unregister(HMM_POOL_TYPE_RESERVED);
-hmm_pool_fail:
-	destroy_workqueue(isp->wdt_work_queue);
-wdt_work_queue_fail:
-	atomisp_acc_cleanup(isp);
-	atomisp_unregister_entities(isp);
-register_entities_fail:
-	atomisp_uninitialize_modules(isp);
-initialize_modules_fail:
-	pm_qos_remove_request(&isp->pm_qos);
-	atomisp_msi_irq_uninit(isp, dev);
-enable_msi_fail:
-fw_validation_fail:
-	release_firmware(isp->firmware);
-load_fw_fail:
-	/*
-	 * Switch off ISP, as keeping it powered on would prevent
-	 * reaching S0ix states.
-	 *
-	 * The following lines have been copied from atomisp suspend path
-	 */
-
-	pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq);
-	irq = irq & 1 << INTR_IIR;
-	pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq);
-
-	pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, &irq);
-	irq &= ~(1 << INTR_IER);
-	pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq);
-
-	atomisp_msi_irq_uninit(isp, dev);
-
-	atomisp_ospm_dphy_down(isp);
-
-	/* Address later when we worry about the ...field chips */
-	if (IS_ENABLED(CONFIG_PM) && atomisp_mrfld_power_down(isp))
-		dev_err(&dev->dev, "Failed to switch off ISP\n");
-	return err;
-}
-
-static void atomisp_pci_remove(struct pci_dev *dev)
-{
-	struct atomisp_device *isp = (struct atomisp_device *)
-		pci_get_drvdata(dev);
-
-	atomisp_drvfs_exit();
-
-	atomisp_acc_cleanup(isp);
-
-	atomisp_css_unload_firmware(isp);
-	hmm_cleanup();
-
-	pm_runtime_forbid(&dev->dev);
-	pm_runtime_get_noresume(&dev->dev);
-	pm_qos_remove_request(&isp->pm_qos);
-
-	atomisp_msi_irq_uninit(isp, dev);
-	atomisp_unregister_entities(isp);
-
-	destroy_workqueue(isp->wdt_work_queue);
-	atomisp_file_input_cleanup(isp);
-
-	release_firmware(isp->firmware);
-
-	hmm_pool_unregister(HMM_POOL_TYPE_RESERVED);
-}
-
-static const struct pci_device_id atomisp_pci_tbl[] = {
-#if defined(ISP2400) || defined(ISP2400B0)
-	/* Merrifield */
-	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1178)},
-	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1179)},
-	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x117a)},
-	/* Baytrail */
-	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0f38)},
-#elif defined(ISP2401)
-	/* Anniedale (Merrifield+ / Moorefield) */
-	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x1478)},
-	/* Cherrytrail */
-	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x22b8)},
-#endif
-	{0,}
-};
-
-MODULE_DEVICE_TABLE(pci, atomisp_pci_tbl);
-
-static const struct dev_pm_ops atomisp_pm_ops = {
-	.runtime_suspend = atomisp_runtime_suspend,
-	.runtime_resume = atomisp_runtime_resume,
-	.suspend = atomisp_suspend,
-	.resume = atomisp_resume,
-};
-
-static struct pci_driver atomisp_pci_driver = {
-	.driver = {
-		.pm = &atomisp_pm_ops,
-	},
-	.name = "atomisp-isp2",
-	.id_table = atomisp_pci_tbl,
-	.probe = atomisp_pci_probe,
-	.remove = atomisp_pci_remove,
-};
-
-module_pci_driver(atomisp_pci_driver);
-
-MODULE_AUTHOR("Wen Wang <wen.w.wang@intel.com>");
-MODULE_AUTHOR("Xiaolin Zhang <xiaolin.zhang@intel.com>");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Intel ATOM Platform ISP Driver");

+ 0 - 40
drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.h

@@ -1,40 +0,0 @@
-/*
- * Support for Medifield PNW Camera Imaging ISP subsystem.
- *
- * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
- *
- * Copyright (c) 2010 Silicon Hive www.siliconhive.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 __ATOMISP_V4L2_H__
-#define __ATOMISP_V4L2_H__
-
-struct atomisp_video_pipe;
-struct atomisp_acc_pipe;
-struct v4l2_device;
-struct atomisp_device;
-struct firmware;
-
-int atomisp_video_init(struct atomisp_video_pipe *video, const char *name);
-void atomisp_acc_init(struct atomisp_acc_pipe *video, const char *name);
-void atomisp_video_unregister(struct atomisp_video_pipe *video);
-int atomisp_video_register(struct atomisp_video_pipe *video,
-	struct v4l2_device *vdev);
-void atomisp_acc_unregister(struct atomisp_acc_pipe *video);
-int atomisp_acc_register(struct atomisp_acc_pipe *video,
-	struct v4l2_device *vdev);
-const struct firmware *atomisp_load_firmware(struct atomisp_device *isp);
-int atomisp_csi_lane_config(struct atomisp_device *isp);
-
-#endif /* __ATOMISP_V4L2_H__ */

+ 0 - 2
drivers/staging/media/atomisp/pci/atomisp2/css2400/Makefile

@@ -1,2 +0,0 @@
-ccflags-y += -DISP2400B0
-ISP2400B0 := y

+ 0 - 376
drivers/staging/media/atomisp/pci/atomisp2/css2400/base/circbuf/interface/ia_css_circbuf.h

@@ -1,376 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _IA_CSS_CIRCBUF_H
-#define _IA_CSS_CIRCBUF_H
-
-#include <sp.h>
-#include <type_support.h>
-#include <math_support.h>
-#include <assert_support.h>
-#include <platform_support.h>
-#include "ia_css_circbuf_comm.h"
-#include "ia_css_circbuf_desc.h"
-
-/****************************************************************
- *
- * Data structures.
- *
- ****************************************************************/
-/**
- * @brief Data structure for the circular buffer.
- */
-typedef struct ia_css_circbuf_s ia_css_circbuf_t;
-struct ia_css_circbuf_s {
-	ia_css_circbuf_desc_t *desc;    /* Pointer to the descriptor of the circbuf */
-	ia_css_circbuf_elem_t *elems;	/* an array of elements    */
-};
-
-/**
- * @brief Create the circular buffer.
- *
- * @param cb	The pointer to the circular buffer.
- * @param elems	An array of elements.
- * @param desc	The descriptor set to the size using ia_css_circbuf_desc_init().
- */
-extern void ia_css_circbuf_create(
-	ia_css_circbuf_t *cb,
-	ia_css_circbuf_elem_t *elems,
-	ia_css_circbuf_desc_t *desc);
-
-/**
- * @brief Destroy the circular buffer.
- *
- * @param cb The pointer to the circular buffer.
- */
-extern void ia_css_circbuf_destroy(
-		ia_css_circbuf_t *cb);
-
-/**
- * @brief Pop a value out of the circular buffer.
- * Get a value at the head of the circular buffer.
- * The user should call "ia_css_circbuf_is_empty()"
- * to avoid accessing to an empty buffer.
- *
- * @param cb	The pointer to the circular buffer.
- *
- * @return the pop-out value.
- */
-extern uint32_t ia_css_circbuf_pop(
-		ia_css_circbuf_t *cb);
-
-/**
- * @brief Extract a value out of the circular buffer.
- * Get a value at an arbitrary poistion in the circular
- * buffer. The user should call "ia_css_circbuf_is_empty()"
- * to avoid accessing to an empty buffer.
- *
- * @param cb	 The pointer to the circular buffer.
- * @param offset The offset from "start" to the target position.
- *
- * @return the extracted value.
- */
-extern uint32_t ia_css_circbuf_extract(
-	ia_css_circbuf_t *cb,
-	int offset);
-
-/****************************************************************
- *
- * Inline functions.
- *
- ****************************************************************/
-/**
- * @brief Set the "val" field in the element.
- *
- * @param elem The pointer to the element.
- * @param val  The value to be set.
- */
-static inline void ia_css_circbuf_elem_set_val(
-	ia_css_circbuf_elem_t *elem,
-	uint32_t val)
-{
-	OP___assert(elem != NULL);
-
-	elem->val = val;
-}
-
-/**
- * @brief Initialize the element.
- *
- * @param elem The pointer to the element.
- */
-static inline void ia_css_circbuf_elem_init(
-		ia_css_circbuf_elem_t *elem)
-{
-	OP___assert(elem != NULL);
-	ia_css_circbuf_elem_set_val(elem, 0);
-}
-
-/**
- * @brief Copy an element.
- *
- * @param src  The element as the copy source.
- * @param dest The element as the copy destination.
- */
-static inline void ia_css_circbuf_elem_cpy(
-	ia_css_circbuf_elem_t *src,
-	ia_css_circbuf_elem_t *dest)
-{
-	OP___assert(src != NULL);
-	OP___assert(dest != NULL);
-
-	ia_css_circbuf_elem_set_val(dest, src->val);
-}
-
-/**
- * @brief Get position in the circular buffer.
- *
- * @param cb		The pointer to the circular buffer.
- * @param base		The base position.
- * @param offset	The offset.
- *
- * @return the position at offset.
- */
-static inline uint8_t ia_css_circbuf_get_pos_at_offset(
-	ia_css_circbuf_t *cb,
-	uint32_t base,
-	int offset)
-{
-	uint8_t dest;
-
-	OP___assert(cb != NULL);
-	OP___assert(cb->desc != NULL);
-	OP___assert(cb->desc->size > 0);
-
-	/* step 1: adjudst the offset  */
-	while (offset < 0) {
-		offset += cb->desc->size;
-	}
-
-	/* step 2: shift and round by the upper limit */
-	dest = OP_std_modadd(base, offset, cb->desc->size);
-
-	return dest;
-}
-
-/**
- * @brief Get the offset between two positions in the circular buffer.
- * Get the offset from the source position to the terminal position,
- * along the direction in which the new elements come in.
- *
- * @param cb		The pointer to the circular buffer.
- * @param src_pos	The source position.
- * @param dest_pos	The terminal position.
- *
- * @return the offset.
- */
-static inline int ia_css_circbuf_get_offset(
-	ia_css_circbuf_t *cb,
-	uint32_t src_pos,
-	uint32_t dest_pos)
-{
-	int offset;
-
-	OP___assert(cb != NULL);
-	OP___assert(cb->desc != NULL);
-
-	offset = (int)(dest_pos - src_pos);
-	offset += (offset < 0) ? cb->desc->size : 0;
-
-	return offset;
-}
-
-/**
- * @brief Get the maximum number of elements.
- *
- * @param cb The pointer to the circular buffer.
- *
- * @return the maximum number of elements.
- *
- * TODO: Test this API.
- */
-static inline uint32_t ia_css_circbuf_get_size(
-		ia_css_circbuf_t *cb)
-{
-	OP___assert(cb != NULL);
-	OP___assert(cb->desc != NULL);
-
-	return cb->desc->size;
-}
-
-/**
- * @brief Get the number of available elements.
- *
- * @param cb The pointer to the circular buffer.
- *
- * @return the number of available elements.
- */
-static inline uint32_t ia_css_circbuf_get_num_elems(
-		ia_css_circbuf_t *cb)
-{
-	int num;
-
-	OP___assert(cb != NULL);
-	OP___assert(cb->desc != NULL);
-
-	num = ia_css_circbuf_get_offset(cb, cb->desc->start, cb->desc->end);
-
-	return (uint32_t)num;
-}
-
-/**
- * @brief Test if the circular buffer is empty.
- *
- * @param cb	The pointer to the circular buffer.
- *
- * @return
- *	- true when it is empty.
- *	- false when it is not empty.
- */
-static inline bool ia_css_circbuf_is_empty(
-		ia_css_circbuf_t *cb)
-{
-	OP___assert(cb != NULL);
-	OP___assert(cb->desc != NULL);
-
-	return ia_css_circbuf_desc_is_empty(cb->desc);
-}
-
-/**
- * @brief Test if the circular buffer is full.
- *
- * @param cb	The pointer to the circular buffer.
- *
- * @return
- *	- true when it is full.
- *	- false when it is not full.
- */
-static inline bool ia_css_circbuf_is_full(ia_css_circbuf_t *cb)
-{
-	OP___assert(cb != NULL);
-	OP___assert(cb->desc != NULL);
-
-	return ia_css_circbuf_desc_is_full(cb->desc);
-}
-
-/**
- * @brief Write a new element into the circular buffer.
- * Write a new element WITHOUT checking whether the
- * circular buffer is full or not. So it also overwrites
- * the oldest element when the buffer is full.
- *
- * @param cb	The pointer to the circular buffer.
- * @param elem	The new element.
- */
-static inline void ia_css_circbuf_write(
-	ia_css_circbuf_t *cb,
-	ia_css_circbuf_elem_t elem)
-{
-	OP___assert(cb != NULL);
-	OP___assert(cb->desc != NULL);
-
-	/* Cannot continue as the queue is full*/
-	assert(!ia_css_circbuf_is_full(cb));
-
-	ia_css_circbuf_elem_cpy(&elem, &cb->elems[cb->desc->end]);
-
-	cb->desc->end = ia_css_circbuf_get_pos_at_offset(cb, cb->desc->end, 1);
-}
-
-/**
- * @brief Push a value in the circular buffer.
- * Put a new value at the tail of the circular buffer.
- * The user should call "ia_css_circbuf_is_full()"
- * to avoid accessing to a full buffer.
- *
- * @param cb	The pointer to the circular buffer.
- * @param val	The value to be pushed in.
- */
-static inline void ia_css_circbuf_push(
-	ia_css_circbuf_t *cb,
-	uint32_t val)
-{
-	ia_css_circbuf_elem_t elem;
-
-	OP___assert(cb != NULL);
-
-	/* set up an element */
-	ia_css_circbuf_elem_init(&elem);
-	ia_css_circbuf_elem_set_val(&elem, val);
-
-	/* write the element into the buffer */
-	ia_css_circbuf_write(cb, elem);
-}
-
-/**
- * @brief Get the number of free elements.
- *
- * @param cb The pointer to the circular buffer.
- *
- * @return: The number of free elements.
- */
-static inline uint32_t ia_css_circbuf_get_free_elems(
-		ia_css_circbuf_t *cb)
-{
-	OP___assert(cb != NULL);
-	OP___assert(cb->desc != NULL);
-
-	return ia_css_circbuf_desc_get_free_elems(cb->desc);
-}
-
-/**
- * @brief Peek an element in Circular Buffer.
- *
- * @param cb	 The pointer to the circular buffer.
- * @param offset Offset to the element.
- *
- * @return the elements value.
- */
-extern uint32_t ia_css_circbuf_peek(
-	ia_css_circbuf_t *cb,
-	int offset);
-
-/**
- * @brief Get an element in Circular Buffer.
- *
- * @param cb	 The pointer to the circular buffer.
- * @param offset Offset to the element.
- *
- * @return the elements value.
- */
-extern uint32_t ia_css_circbuf_peek_from_start(
-	ia_css_circbuf_t *cb,
-	int offset);
-
-/**
- * @brief Increase Size of a Circular Buffer.
- * Use 'CAUTION' before using this function, This was added to
- * support / fix issue with increasing size for tagger only
- *
- * @param cb The pointer to the circular buffer.
- * @param sz_delta delta increase for new size
- * @param elems (optional) pointers to new additional elements
- *		cb element array size will not be increased dynamically,
- * 		but new elements should be added at the end to existing
- * 		cb element array which if of max_size >= new size
- *
- * @return	true on succesfully increasing the size
- * 			false on failure
- */
-extern bool ia_css_circbuf_increase_size(
-		ia_css_circbuf_t *cb,
-		unsigned int sz_delta,
-		ia_css_circbuf_elem_t *elems);
-
-#endif /*_IA_CSS_CIRCBUF_H */

+ 0 - 56
drivers/staging/media/atomisp/pci/atomisp2/css2400/base/circbuf/interface/ia_css_circbuf_comm.h

@@ -1,56 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _IA_CSS_CIRCBUF_COMM_H
-#define _IA_CSS_CIRCBUF_COMM_H
-
-#include <type_support.h>  /* uint8_t, uint32_t */
-
-#define IA_CSS_CIRCBUF_PADDING 1 /* The circular buffer is implemented in lock-less manner, wherein
-				   * the head and tail can advance independently without any locks.
-				   * But to achieve this, an extra buffer element is required to detect
-				   * queue full & empty conditions, wherein the tail trails the head for
-				   * full and is equal to head for empty condition. This causes 1 buffer
-				   * not being available for use.
-				   */
-
-/****************************************************************
- *
- * Portable Data structures
- *
- ****************************************************************/
-/**
- * @brief Data structure for the circular descriptor.
- */
-typedef struct ia_css_circbuf_desc_s ia_css_circbuf_desc_t;
-struct ia_css_circbuf_desc_s {
-	uint8_t size;	/* the maximum number of elements*/
-	uint8_t step;   /* number of bytes per element */
-	uint8_t start;	/* index of the oldest element */
-	uint8_t end;	/* index at which to write the new element */
-};
-#define SIZE_OF_IA_CSS_CIRCBUF_DESC_S_STRUCT				\
-	(4 * sizeof(uint8_t))
-
-/**
- * @brief Data structure for the circular buffer element.
- */
-typedef struct ia_css_circbuf_elem_s ia_css_circbuf_elem_t;
-struct ia_css_circbuf_elem_s {
-	uint32_t val;	/* the value stored in the element */
-};
-#define SIZE_OF_IA_CSS_CIRCBUF_ELEM_S_STRUCT				\
-	(sizeof(uint32_t))
-
-#endif /*_IA_CSS_CIRCBUF_COMM_H*/

+ 0 - 169
drivers/staging/media/atomisp/pci/atomisp2/css2400/base/circbuf/interface/ia_css_circbuf_desc.h

@@ -1,169 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _IA_CSS_CIRCBUF_DESC_H_
-#define _IA_CSS_CIRCBUF_DESC_H_
-
-#include <type_support.h>
-#include <math_support.h>
-#include <platform_support.h>
-#include <sp.h>
-#include "ia_css_circbuf_comm.h"
-/****************************************************************
- *
- * Inline functions.
- *
- ****************************************************************/
-/**
- * @brief Test if the circular buffer is empty.
- *
- * @param cb_desc The pointer to the circular buffer descriptor.
- *
- * @return
- *	- true when it is empty.
- *	- false when it is not empty.
- */
-static inline bool ia_css_circbuf_desc_is_empty(
-		ia_css_circbuf_desc_t *cb_desc)
-{
-	OP___assert(cb_desc != NULL);
-	return (cb_desc->end == cb_desc->start);
-}
-
-/**
- * @brief Test if the circular buffer descriptor is full.
- *
- * @param cb_desc	The pointer to the circular buffer
- *			descriptor.
- *
- * @return
- *	- true when it is full.
- *	- false when it is not full.
- */
-static inline bool ia_css_circbuf_desc_is_full(
-		ia_css_circbuf_desc_t *cb_desc)
-{
-	OP___assert(cb_desc != NULL);
-	return (OP_std_modadd(cb_desc->end, 1, cb_desc->size) == cb_desc->start);
-}
-
-/**
- * @brief Initialize the circular buffer descriptor
- *
- * @param cb_desc	The pointer circular buffer descriptor
- * @param size		The size of the circular buffer
- */
-static inline void ia_css_circbuf_desc_init(
-	ia_css_circbuf_desc_t *cb_desc,
-	int8_t size)
-{
-	OP___assert(cb_desc != NULL);
-	cb_desc->size = size;
-}
-
-/**
- * @brief Get a position in the circular buffer descriptor.
- *
- * @param cb     The pointer to the circular buffer descriptor.
- * @param base   The base position.
- * @param offset The offset.
- *
- * @return the position in the circular buffer descriptor.
- */
-static inline uint8_t ia_css_circbuf_desc_get_pos_at_offset(
-	ia_css_circbuf_desc_t *cb_desc,
-	uint32_t base,
-	int offset)
-{
-	uint8_t dest;
-	OP___assert(cb_desc != NULL);
-	OP___assert(cb_desc->size > 0);
-
-	/* step 1: adjust the offset  */
-	while (offset < 0) {
-		offset += cb_desc->size;
-	}
-
-	/* step 2: shift and round by the upper limit */
-	dest = OP_std_modadd(base, offset, cb_desc->size);
-
-	return dest;
-}
-
-/**
- * @brief Get the offset between two positions in the circular buffer
- * descriptor.
- * Get the offset from the source position to the terminal position,
- * along the direction in which the new elements come in.
- *
- * @param cb_desc	The pointer to the circular buffer descriptor.
- * @param src_pos	The source position.
- * @param dest_pos	The terminal position.
- *
- * @return the offset.
- */
-static inline int ia_css_circbuf_desc_get_offset(
-	ia_css_circbuf_desc_t *cb_desc,
-	uint32_t src_pos,
-	uint32_t dest_pos)
-{
-	int offset;
-	OP___assert(cb_desc != NULL);
-
-	offset = (int)(dest_pos - src_pos);
-	offset += (offset < 0) ? cb_desc->size : 0;
-
-	return offset;
-}
-
-/**
- * @brief Get the number of available elements.
- *
- * @param cb_desc The pointer to the circular buffer.
- *
- * @return The number of available elements.
- */
-static inline uint32_t ia_css_circbuf_desc_get_num_elems(
-		ia_css_circbuf_desc_t *cb_desc)
-{
-	int num;
-	OP___assert(cb_desc != NULL);
-
-	num = ia_css_circbuf_desc_get_offset(cb_desc,
-				cb_desc->start,
-				cb_desc->end);
-
-	return (uint32_t)num;
-}
-
-/**
- * @brief Get the number of free elements.
- *
- * @param cb_desc The pointer to the circular buffer descriptor.
- *
- * @return: The number of free elements.
- */
-static inline uint32_t ia_css_circbuf_desc_get_free_elems(
-		ia_css_circbuf_desc_t *cb_desc)
-{
-	uint32_t num;
-	OP___assert(cb_desc != NULL);
-
-	num = ia_css_circbuf_desc_get_offset(cb_desc,
-				cb_desc->start,
-				cb_desc->end);
-
-	return (cb_desc->size - num);
-}
-#endif /*_IA_CSS_CIRCBUF_DESC_H_ */

+ 0 - 321
drivers/staging/media/atomisp/pci/atomisp2/css2400/base/circbuf/src/circbuf.c

@@ -1,321 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-
-#include "ia_css_circbuf.h"
-
-#include <assert_support.h>
-
-/**********************************************************************
- *
- * Forward declarations.
- *
- **********************************************************************/
-/*
- * @brief Read the oldest element from the circular buffer.
- * Read the oldest element WITHOUT checking whehter the
- * circular buffer is empty or not. The oldest element is
- * also removed out from the circular buffer.
- *
- * @param cb The pointer to the circular buffer.
- *
- * @return the oldest element.
- */
-static inline ia_css_circbuf_elem_t
-ia_css_circbuf_read(ia_css_circbuf_t *cb);
-
-/*
- * @brief Shift a chunk of elements in the circular buffer.
- * A chunk of elements (i.e. the ones from the "start" position
- * to the "chunk_src" position) are shifted in the circular buffer,
- * along the direction of new elements coming.
- *
- * @param cb	     The pointer to the circular buffer.
- * @param chunk_src  The position at which the first element in the chunk is.
- * @param chunk_dest The position to which the first element in the chunk would be shift.
- */
-static inline void ia_css_circbuf_shift_chunk(ia_css_circbuf_t *cb,
-						   uint32_t chunk_src,
-						   uint32_t chunk_dest);
-
-/*
- * @brief Get the "val" field in the element.
- *
- * @param elem The pointer to the element.
- *
- * @return the "val" field.
- */
-static inline uint32_t
-ia_css_circbuf_elem_get_val(ia_css_circbuf_elem_t *elem);
-
-/**********************************************************************
- *
- * Non-inline functions.
- *
- **********************************************************************/
-/*
- * @brief Create the circular buffer.
- * Refer to "ia_css_circbuf.h" for details.
- */
-void
-ia_css_circbuf_create(ia_css_circbuf_t *cb,
-			   ia_css_circbuf_elem_t *elems,
-			   ia_css_circbuf_desc_t *desc)
-{
-	uint32_t i;
-
-	OP___assert(desc);
-
-	cb->desc = desc;
-	/* Initialize to defaults */
-	cb->desc->start = 0;
-	cb->desc->end = 0;
-	cb->desc->step = 0;
-
-	for (i = 0; i < cb->desc->size; i++)
-		ia_css_circbuf_elem_init(&elems[i]);
-
-	cb->elems = elems;
-}
-
-/*
- * @brief Destroy the circular buffer.
- * Refer to "ia_css_circbuf.h" for details.
- */
-void ia_css_circbuf_destroy(ia_css_circbuf_t *cb)
-{
-	cb->desc = NULL;
-
-	cb->elems = NULL;
-}
-
-/*
- * @brief Pop a value out of the circular buffer.
- * Refer to "ia_css_circbuf.h" for details.
- */
-uint32_t ia_css_circbuf_pop(ia_css_circbuf_t *cb)
-{
-	uint32_t ret;
-	ia_css_circbuf_elem_t elem;
-
-	assert(!ia_css_circbuf_is_empty(cb));
-
-	/* read an element from the buffer */
-	elem = ia_css_circbuf_read(cb);
-	ret = ia_css_circbuf_elem_get_val(&elem);
-	return ret;
-}
-
-/*
- * @brief Extract a value out of the circular buffer.
- * Refer to "ia_css_circbuf.h" for details.
- */
-uint32_t ia_css_circbuf_extract(ia_css_circbuf_t *cb, int offset)
-{
-	int max_offset;
-	uint32_t val;
-	uint32_t pos;
-	uint32_t src_pos;
-	uint32_t dest_pos;
-
-	/* get the maximum offest */
-	max_offset = ia_css_circbuf_get_offset(cb, cb->desc->start, cb->desc->end);
-	max_offset--;
-
-	/*
-	 * Step 1: When the target element is at the "start" position.
-	 */
-	if (offset == 0) {
-		val = ia_css_circbuf_pop(cb);
-		return val;
-	}
-
-	/*
-	 * Step 2: When the target element is out of the range.
-	 */
-	if (offset > max_offset) {
-		val = 0;
-		return val;
-	}
-
-	/*
-	 * Step 3: When the target element is between the "start" and
-	 * "end" position.
-	 */
-	/* get the position of the target element */
-	pos = ia_css_circbuf_get_pos_at_offset(cb, cb->desc->start, offset);
-
-	/* get the value from the target element */
-	val = ia_css_circbuf_elem_get_val(&cb->elems[pos]);
-
-	/* shift the elements */
-	src_pos = ia_css_circbuf_get_pos_at_offset(cb, pos, -1);
-	dest_pos = pos;
-	ia_css_circbuf_shift_chunk(cb, src_pos, dest_pos);
-
-	return val;
-}
-
-/*
- * @brief Peek an element from the circular buffer.
- * Refer to "ia_css_circbuf.h" for details.
- */
-uint32_t ia_css_circbuf_peek(ia_css_circbuf_t *cb, int offset)
-{
-	int pos;
-
-	pos = ia_css_circbuf_get_pos_at_offset(cb, cb->desc->end, offset);
-
-	/* get the value at the position */
-	return cb->elems[pos].val;
-}
-
-/*
- * @brief Get the value of an element from the circular buffer.
- * Refer to "ia_css_circbuf.h" for details.
- */
-uint32_t ia_css_circbuf_peek_from_start(ia_css_circbuf_t *cb, int offset)
-{
-	int pos;
-
-	pos = ia_css_circbuf_get_pos_at_offset(cb, cb->desc->start, offset);
-
-	/* get the value at the position */
-	return cb->elems[pos].val;
-}
-
-/* @brief increase size of a circular buffer.
- * Use 'CAUTION' before using this function. This was added to
- * support / fix issue with increasing size for tagger only
- * Please refer to "ia_css_circbuf.h" for details.
- */
-bool ia_css_circbuf_increase_size(
-				ia_css_circbuf_t *cb,
-				unsigned int sz_delta,
-				ia_css_circbuf_elem_t *elems)
-{
-	uint8_t curr_size;
-	uint8_t curr_end;
-	unsigned int i = 0;
-
-	if (!cb || sz_delta == 0)
-		return false;
-
-	curr_size = cb->desc->size;
-	curr_end = cb->desc->end;
-	/* We assume cb was pre defined as global to allow
-	 * increase in size */
-	/* FM: are we sure this cannot cause size to become too big? */
-	if (((uint8_t)(cb->desc->size + (uint8_t)sz_delta) > cb->desc->size) && ((uint8_t)sz_delta == sz_delta))
-		cb->desc->size += (uint8_t)sz_delta;
-	else
-		return false; /* overflow in size */
-
-	/* If elems are passed update them else we assume its been taken
-	 * care before calling this function */
-	if (elems) {
-		/* cb element array size will not be increased dynamically,
-		 * but pointers to new elements can be added at the end
-		 * of existing pre defined cb element array of
-		 * size >= new size if not already added */
-		for (i = curr_size; i <  cb->desc->size; i++)
-			cb->elems[i] = elems[i - curr_size];
-	}
-	/* Fix Start / End */
-	if (curr_end < cb->desc->start) {
-		if (curr_end == 0) {
-			/* Easily fix End */
-			cb->desc->end = curr_size;
-		} else {
-			/* Move elements and fix Start*/
-			ia_css_circbuf_shift_chunk(cb,
-						curr_size - 1,
-						curr_size + sz_delta - 1);
-		}
-	}
-
-	return true;
-}
-
-/****************************************************************
- *
- * Inline functions.
- *
- ****************************************************************/
-/*
- * @brief Get the "val" field in the element.
- * Refer to "Forward declarations" for details.
- */
-static inline uint32_t
-ia_css_circbuf_elem_get_val(ia_css_circbuf_elem_t *elem)
-{
-	return elem->val;
-}
-
-/*
- * @brief Read the oldest element from the circular buffer.
- * Refer to "Forward declarations" for details.
- */
-static inline ia_css_circbuf_elem_t
-ia_css_circbuf_read(ia_css_circbuf_t *cb)
-{
-	ia_css_circbuf_elem_t elem;
-
-	/* get the element from the target position */
-	elem = cb->elems[cb->desc->start];
-
-	/* clear the target position */
-	ia_css_circbuf_elem_init(&cb->elems[cb->desc->start]);
-
-	/* adjust the "start" position */
-	cb->desc->start = ia_css_circbuf_get_pos_at_offset(cb, cb->desc->start, 1);
-	return elem;
-}
-
-/*
- * @brief Shift a chunk of elements in the circular buffer.
- * Refer to "Forward declarations" for details.
- */
-static inline void
-ia_css_circbuf_shift_chunk(ia_css_circbuf_t *cb,
-				uint32_t chunk_src, uint32_t chunk_dest)
-{
-	int chunk_offset;
-	int chunk_sz;
-	int i;
-
-	/* get the chunk offset and size */
-	chunk_offset = ia_css_circbuf_get_offset(cb,
-						      chunk_src, chunk_dest);
-	chunk_sz = ia_css_circbuf_get_offset(cb, cb->desc->start, chunk_src) + 1;
-
-	/* shift each element to its terminal position */
-	for (i = 0; i < chunk_sz; i++) {
-
-		/* copy the element from the source to the destination */
-		ia_css_circbuf_elem_cpy(&cb->elems[chunk_src],
-					     &cb->elems[chunk_dest]);
-
-		/* clear the source position */
-		ia_css_circbuf_elem_init(&cb->elems[chunk_src]);
-
-		/* adjust the source/terminal positions */
-		chunk_src = ia_css_circbuf_get_pos_at_offset(cb, chunk_src, -1);
-		chunk_dest = ia_css_circbuf_get_pos_at_offset(cb, chunk_dest, -1);
-
-	}
-
-	/* adjust the index "start" */
-	cb->desc->start = ia_css_circbuf_get_pos_at_offset(cb, cb->desc->start, chunk_offset);
-}
-

+ 0 - 83
drivers/staging/media/atomisp/pci/atomisp2/css2400/base/refcount/interface/ia_css_refcount.h

@@ -1,83 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _IA_CSS_REFCOUNT_H_
-#define _IA_CSS_REFCOUNT_H_
-
-#include <type_support.h>
-#include <system_types.h>
-#include <ia_css_err.h>
-
-typedef void (*clear_func)(hrt_vaddress ptr);
-
-/*! \brief Function for initializing refcount list
- *
- * \param[in]	size		Size of the refcount list.
- * \return				ia_css_err
- */
-extern enum ia_css_err ia_css_refcount_init(uint32_t size);
-
-/*! \brief Function for de-initializing refcount list
- *
- * \return				None
- */
-extern void ia_css_refcount_uninit(void);
-
-/*! \brief Function for increasing reference by 1.
- *
- * \param[in]	id		ID of the object.
- * \param[in]	ptr		Data of the object (ptr).
- * \return				hrt_vaddress (saved address)
- */
-extern hrt_vaddress ia_css_refcount_increment(int32_t id, hrt_vaddress ptr);
-
-/*! \brief Function for decrease reference by 1.
- *
- * \param[in]	id		ID of the object.
- * \param[in]	ptr		Data of the object (ptr).
- *
- *	- true, if it is successful.
- *	- false, otherwise.
- */
-extern bool ia_css_refcount_decrement(int32_t id, hrt_vaddress ptr);
-
-/*! \brief Function to check if reference count is 1.
- *
- * \param[in]	ptr		Data of the object (ptr).
- *
- *	- true, if it is successful.
- *	- false, otherwise.
- */
-extern bool ia_css_refcount_is_single(hrt_vaddress ptr);
-
-/*! \brief Function to clear reference list objects.
- *
- * \param[in]	id			ID of the object.
- * \param[in] clear_func	function to be run to free reference objects.
- *
- *  return				None
- */
-extern void ia_css_refcount_clear(int32_t id,
-				  clear_func clear_func_ptr);
-
-/*! \brief Function to verify if object is valid
- *
- * \param[in] ptr       Data of the object (ptr)
- *
- *      - true, if valid
- *      - false, if invalid
- */
-extern bool ia_css_refcount_is_valid(hrt_vaddress ptr);
-
-#endif /* _IA_CSS_REFCOUNT_H_ */

+ 0 - 281
drivers/staging/media/atomisp/pci/atomisp2/css2400/base/refcount/src/refcount.c

@@ -1,281 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-
-#include "ia_css_refcount.h"
-#include "memory_access/memory_access.h"
-#include "sh_css_defs.h"
-
-#include "platform_support.h"
-
-#include "assert_support.h"
-
-#include "ia_css_debug.h"
-
-/* TODO: enable for other memory aswell
-	 now only for hrt_vaddress */
-struct ia_css_refcount_entry {
-	uint32_t count;
-	hrt_vaddress data;
-	int32_t id;
-};
-
-struct ia_css_refcount_list {
-	uint32_t size;
-	struct ia_css_refcount_entry *items;
-};
-
-static struct ia_css_refcount_list myrefcount;
-
-static struct ia_css_refcount_entry *refcount_find_entry(hrt_vaddress ptr,
-							 bool firstfree)
-{
-	uint32_t i;
-
-	if (ptr == 0)
-		return NULL;
-	if (myrefcount.items == NULL) {
-		ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
-				    "refcount_find_entry(): Ref count not initiliazed!\n");
-		return NULL;
-	}
-
-	for (i = 0; i < myrefcount.size; i++) {
-
-		if ((&myrefcount.items[i])->data == 0) {
-			if (firstfree) {
-				/* for new entry */
-				return &myrefcount.items[i];
-			}
-		}
-		if ((&myrefcount.items[i])->data == ptr) {
-			/* found entry */
-			return &myrefcount.items[i];
-		}
-	}
-	return NULL;
-}
-
-enum ia_css_err ia_css_refcount_init(uint32_t size)
-{
-	enum ia_css_err err = IA_CSS_SUCCESS;
-
-	if (size == 0) {
-		ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
-				    "ia_css_refcount_init(): Size of 0 for Ref count init!\n");
-		return IA_CSS_ERR_INVALID_ARGUMENTS;
-	}
-	if (myrefcount.items != NULL) {
-		ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
-				    "ia_css_refcount_init(): Ref count is already initialized\n");
-		return IA_CSS_ERR_INTERNAL_ERROR;
-	}
-	myrefcount.items =
-	    sh_css_malloc(sizeof(struct ia_css_refcount_entry) * size);
-	if (!myrefcount.items)
-		err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
-	if (err == IA_CSS_SUCCESS) {
-		memset(myrefcount.items, 0,
-		       sizeof(struct ia_css_refcount_entry) * size);
-		myrefcount.size = size;
-	}
-	return err;
-}
-
-void ia_css_refcount_uninit(void)
-{
-	struct ia_css_refcount_entry *entry;
-	uint32_t i;
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
-			    "ia_css_refcount_uninit() entry\n");
-	for (i = 0; i < myrefcount.size; i++) {
-		/* driver verifier tool has issues with &arr[i]
-		   and prefers arr + i; as these are actually equivalent
-		   the line below uses + i
-		*/
-		entry = myrefcount.items + i;
-		if (entry->data != mmgr_NULL) {
-			/*	ia_css_debug_dtrace(IA_CSS_DBG_TRACE,
-				"ia_css_refcount_uninit: freeing (%x)\n",
-				entry->data);*/
-			hmm_free(entry->data);
-			entry->data = mmgr_NULL;
-			entry->count = 0;
-			entry->id = 0;
-		}
-	}
-	sh_css_free(myrefcount.items);
-	myrefcount.items = NULL;
-	myrefcount.size = 0;
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
-			    "ia_css_refcount_uninit() leave\n");
-}
-
-hrt_vaddress ia_css_refcount_increment(int32_t id, hrt_vaddress ptr)
-{
-	struct ia_css_refcount_entry *entry;
-
-	if (ptr == mmgr_NULL)
-		return ptr;
-
-	entry = refcount_find_entry(ptr, false);
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
-			    "ia_css_refcount_increment(%x) 0x%x\n", id, ptr);
-
-	if (!entry) {
-		entry = refcount_find_entry(ptr, true);
-		assert(entry != NULL);
-		if (entry == NULL)
-			return mmgr_NULL;
-		entry->id = id;
-	}
-
-	if (entry->id != id) {
-		ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
-			    "ia_css_refcount_increment(): Ref count IDS do not match!\n");
-		return mmgr_NULL;
-	}
-
-	if (entry->data == ptr)
-		entry->count += 1;
-	else if (entry->data == mmgr_NULL) {
-		entry->data = ptr;
-		entry->count = 1;
-	} else
-		return mmgr_NULL;
-
-	return ptr;
-}
-
-bool ia_css_refcount_decrement(int32_t id, hrt_vaddress ptr)
-{
-	struct ia_css_refcount_entry *entry;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
-			    "ia_css_refcount_decrement(%x) 0x%x\n", id, ptr);
-
-	if (ptr == mmgr_NULL)
-		return false;
-
-	entry = refcount_find_entry(ptr, false);
-
-	if (entry) {
-		if (entry->id != id) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_ERROR,
-					    "ia_css_refcount_decrement(): Ref count IDS do not match!\n");
-			return false;
-		}
-		if (entry->count > 0) {
-			entry->count -= 1;
-			if (entry->count == 0) {
-				/* ia_css_debug_dtrace(IA_CSS_DBEUG_TRACE,
-				   "ia_css_refcount_decrement: freeing\n");*/
-				hmm_free(ptr);
-				entry->data = mmgr_NULL;
-				entry->id = 0;
-			}
-			return true;
-		}
-	}
-
-	/* SHOULD NOT HAPPEN: ptr not managed by refcount, or not
-	   valid anymore */
-	if (entry)
-		IA_CSS_ERROR("id %x, ptr 0x%x entry %p entry->id %x entry->count %d\n",
-			id, ptr, entry, entry->id, entry->count);
-	else
-		IA_CSS_ERROR("entry NULL\n");
-#ifdef ISP2401
-	assert(false);
-#endif
-
-	return false;
-}
-
-bool ia_css_refcount_is_single(hrt_vaddress ptr)
-{
-	struct ia_css_refcount_entry *entry;
-
-	if (ptr == mmgr_NULL)
-		return false;
-
-	entry = refcount_find_entry(ptr, false);
-
-	if (entry)
-		return (entry->count == 1);
-
-	return true;
-}
-
-void ia_css_refcount_clear(int32_t id, clear_func clear_func_ptr)
-{
-	struct ia_css_refcount_entry *entry;
-	uint32_t i;
-	uint32_t count = 0;
-
-	assert(clear_func_ptr != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_refcount_clear(%x)\n",
-			    id);
-
-	for (i = 0; i < myrefcount.size; i++) {
-		/* driver verifier tool has issues with &arr[i]
-		   and prefers arr + i; as these are actually equivalent
-		   the line below uses + i
-		*/
-		entry = myrefcount.items + i;
-		if ((entry->data != mmgr_NULL) && (entry->id == id)) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
-					    "ia_css_refcount_clear:"
-					    " %x: 0x%x\n", id, entry->data);
-			if (clear_func_ptr) {
-				/* clear using provided function */
-				clear_func_ptr(entry->data);
-			} else {
-				ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
-						    "ia_css_refcount_clear: "
-						    "using hmm_free: "
-						    "no clear_func\n");
-				hmm_free(entry->data);
-			}
-#ifndef ISP2401
-
-#else
-			assert(entry->count == 0);
-#endif
-			if (entry->count != 0) {
-				IA_CSS_WARNING("Ref count for entry %x is not zero!", entry->id);
-			}
-			entry->data = mmgr_NULL;
-			entry->count = 0;
-			entry->id = 0;
-			count++;
-		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
-			    "ia_css_refcount_clear(%x): cleared %d\n", id,
-			    count);
-}
-
-bool ia_css_refcount_is_valid(hrt_vaddress ptr)
-{
-	struct ia_css_refcount_entry *entry;
-
-	if (ptr == mmgr_NULL)
-		return false;
-
-	entry = refcount_find_entry(ptr, false);
-
-	return entry != NULL;
-}
-

+ 0 - 297
drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/interface/ia_css_pipe_binarydesc.h

@@ -1,297 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 __IA_CSS_PIPE_BINARYDESC_H__
-#define __IA_CSS_PIPE_BINARYDESC_H__
-
-#include <ia_css_types.h>		/* ia_css_pipe */
-#include <ia_css_frame_public.h>	/* ia_css_frame_info */
-#include <ia_css_binary.h>		/* ia_css_binary_descr */
-
-/* @brief Get a binary descriptor for copy.
- *
- * @param[in] pipe
- * @param[out] copy_desc
- * @param[in/out] in_info
- * @param[in/out] out_info
- * @param[in/out] vf_info
- * @return    None
- *
- */
-extern void ia_css_pipe_get_copy_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *copy_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info);
-
-/* @brief Get a binary descriptor for vfpp.
- *
- * @param[in] pipe
- * @param[out] vfpp_descr
- * @param[in/out] in_info
- * @param[in/out] out_info
- * @return    None
- *
- */
-extern void ia_css_pipe_get_vfpp_binarydesc(
-		struct ia_css_pipe const * const pipe,
-		struct ia_css_binary_descr *vf_pp_descr,
-		struct ia_css_frame_info *in_info,
-		struct ia_css_frame_info *out_info);
-
-/* @brief Get numerator and denominator of bayer downscaling factor.
- *
- * @param[in] bds_factor: The bayer downscaling factor.
- *		(= The bds_factor member in the sh_css_bds_factor structure.)
- * @param[out] bds_factor_numerator: The numerator of the bayer downscaling factor.
- *		(= The numerator member in the sh_css_bds_factor structure.)
- * @param[out] bds_factor_denominator: The denominator of the bayer downscaling factor.
- *		(= The denominator member in the sh_css_bds_factor structure.)
- * @return	IA_CSS_SUCCESS or error code upon error.
- *
- */
-extern enum ia_css_err sh_css_bds_factor_get_numerator_denominator(
-	unsigned int bds_factor,
-	unsigned int *bds_factor_numerator,
-	unsigned int *bds_factor_denominator);
-
-/* @brief Get a binary descriptor for preview stage.
- *
- * @param[in] pipe
- * @param[out] preview_descr
- * @param[in/out] in_info
- * @param[in/out] bds_out_info
- * @param[in/out] out_info
- * @param[in/out] vf_info
- * @return	IA_CSS_SUCCESS or error code upon error.
- *
- */
-extern enum ia_css_err ia_css_pipe_get_preview_binarydesc(
-	struct ia_css_pipe * const pipe,
-	struct ia_css_binary_descr *preview_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *bds_out_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info);
-
-/* @brief Get a binary descriptor for video stage.
- *
- * @param[in/out] pipe
- * @param[out] video_descr
- * @param[in/out] in_info
- * @param[in/out] bds_out_info
- * @param[in/out] vf_info
- * @return	IA_CSS_SUCCESS or error code upon error.
- *
- */
-extern enum ia_css_err ia_css_pipe_get_video_binarydesc(
-	struct ia_css_pipe * const pipe,
-	struct ia_css_binary_descr *video_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *bds_out_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info,
-	int stream_config_left_padding);
-
-/* @brief Get a binary descriptor for yuv scaler stage.
- *
- * @param[in/out] pipe
- * @param[out] yuv_scaler_descr
- * @param[in/out] in_info
- * @param[in/out] out_info
- * @param[in/out] internal_out_info
- * @param[in/out] vf_info
- * @return    None
- *
- */
-void ia_css_pipe_get_yuvscaler_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *yuv_scaler_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *internal_out_info,
-	struct ia_css_frame_info *vf_info);
-
-/* @brief Get a binary descriptor for capture pp stage.
- *
- * @param[in/out] pipe
- * @param[out] capture_pp_descr
- * @param[in/out] in_info
- * @param[in/out] vf_info
- * @return    None
- *
- */
-extern void ia_css_pipe_get_capturepp_binarydesc(
-	struct ia_css_pipe * const pipe,
-	struct ia_css_binary_descr *capture_pp_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info);
-
-/* @brief Get a binary descriptor for primary capture.
- *
- * @param[in] pipe
- * @param[out] prim_descr
- * @param[in/out] in_info
- * @param[in/out] out_info
- * @param[in/out] vf_info
- * @return    None
- *
- */
-extern void ia_css_pipe_get_primary_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *prim_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info,
-	unsigned int stage_idx);
-
-/* @brief Get a binary descriptor for pre gdc stage.
- *
- * @param[in] pipe
- * @param[out] pre_gdc_descr
- * @param[in/out] in_info
- * @param[in/out] out_info
- * @return    None
- *
- */
-extern void ia_css_pipe_get_pre_gdc_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *gdc_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info);
-
-/* @brief Get a binary descriptor for gdc stage.
- *
- * @param[in] pipe
- * @param[out] gdc_descr
- * @param[in/out] in_info
- * @param[in/out] out_info
- * @return    None
- *
- */
-extern void ia_css_pipe_get_gdc_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *gdc_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info);
-
-/* @brief Get a binary descriptor for post gdc.
- *
- * @param[in] pipe
- * @param[out] post_gdc_descr
- * @param[in/out] in_info
- * @param[in/out] out_info
- * @param[in/out] vf_info
- * @return    None
- *
- */
-extern void ia_css_pipe_get_post_gdc_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *post_gdc_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info);
-
-/* @brief Get a binary descriptor for de.
- *
- * @param[in] pipe
- * @param[out] pre_de_descr
- * @param[in/out] in_info
- * @param[in/out] out_info
- * @return    None
- *
- */
-extern void ia_css_pipe_get_pre_de_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *pre_de_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info);
-
-/* @brief Get a binary descriptor for pre anr stage.
- *
- * @param[in] pipe
- * @param[out] pre_anr_descr
- * @param[in/out] in_info
- * @param[in/out] out_info
- * @return    None
- *
- */
-extern void ia_css_pipe_get_pre_anr_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *pre_anr_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info);
-
-/* @brief Get a binary descriptor for ANR stage.
- *
- * @param[in] pipe
- * @param[out] anr_descr
- * @param[in/out] in_info
- * @param[in/out] out_info
- * @return    None
- *
- */
-extern void ia_css_pipe_get_anr_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *anr_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info);
-
-/* @brief Get a binary descriptor for post anr stage.
- *
- * @param[in] pipe
- * @param[out] post_anr_descr
- * @param[in/out] in_info
- * @param[in/out] out_info
- * @param[in/out] vf_info
- * @return    None
- *
- */
-extern void ia_css_pipe_get_post_anr_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *post_anr_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info);
-
-/* @brief Get a binary descriptor for ldc stage.
- *
- * @param[in/out] pipe
- * @param[out] capture_pp_descr
- * @param[in/out] in_info
- * @param[in/out] vf_info
- * @return    None
- *
- */
-extern void ia_css_pipe_get_ldc_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *ldc_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info);
-
-/* @brief Calculates the required BDS factor
- *
- * @param[in] input_res
- * @param[in] output_res
- * @param[in/out] bds_factor
- * @return	IA_CSS_SUCCESS or error code upon error.
- */
-enum ia_css_err binarydesc_calculate_bds_factor(
-	struct ia_css_resolution input_res,
-	struct ia_css_resolution output_res,
-	unsigned int *bds_factor);
-
-#endif /* __IA_CSS_PIPE_BINARYDESC_H__ */

+ 0 - 52
drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/interface/ia_css_pipe_stagedesc.h

@@ -1,52 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 __IA_CSS_PIPE_STAGEDESC_H__
-#define __IA_CSS_PIPE_STAGEDESC_H__
-
-#include <ia_css_acc_types.h> /* ia_css_fw_info */
-#include <ia_css_frame_public.h>
-#include <ia_css_binary.h>
-#include "ia_css_pipeline.h"
-#include "ia_css_pipeline_common.h"
-
-extern void ia_css_pipe_get_generic_stage_desc(
-	struct ia_css_pipeline_stage_desc *stage_desc,
-	struct ia_css_binary *binary,
-	struct ia_css_frame *out_frame[],
-	struct ia_css_frame *in_frame,
-	struct ia_css_frame *vf_frame);
-
-extern void ia_css_pipe_get_firmwares_stage_desc(
-	struct ia_css_pipeline_stage_desc *stage_desc,
-	struct ia_css_binary *binary,
-	struct ia_css_frame *out_frame[],
-	struct ia_css_frame *in_frame,
-	struct ia_css_frame *vf_frame,
-	const struct ia_css_fw_info *fw,
-	unsigned int mode);
-
-extern void ia_css_pipe_get_acc_stage_desc(
-	struct ia_css_pipeline_stage_desc *stage_desc,
-	struct ia_css_binary *binary,
-	struct ia_css_fw_info *fw);
-
-extern void ia_css_pipe_get_sp_func_stage_desc(
-	struct ia_css_pipeline_stage_desc *stage_desc,
-	struct ia_css_frame *out_frame,
-	enum ia_css_pipeline_stage_sp_func sp_func,
-	unsigned max_input_width);
-
-#endif /*__IA_CSS_PIPE_STAGEDESC__H__ */
-

+ 0 - 39
drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/interface/ia_css_pipe_util.h

@@ -1,39 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 __IA_CSS_PIPE_UTIL_H__
-#define __IA_CSS_PIPE_UTIL_H__
-
-#include <ia_css_types.h>
-#include <ia_css_frame_public.h>
-
-/* @brief Get Input format bits per pixel based on stream configuration of this
- * pipe.
- *
- * @param[in] pipe
- * @return   bits per pixel for the underlying stream
- *
- */
-extern unsigned int ia_css_pipe_util_pipe_input_format_bpp(
-	const struct ia_css_pipe * const pipe);
-
-extern void ia_css_pipe_util_create_output_frames(
-	struct ia_css_frame *frames[]);
-
-extern void ia_css_pipe_util_set_output_frames(
-	struct ia_css_frame *frames[],
-	unsigned int idx,
-	struct ia_css_frame *frame);
-
-#endif /* __IA_CSS_PIPE_UTIL_H__ */

+ 0 - 880
drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/src/pipe_binarydesc.c

@@ -1,880 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-
-#include "ia_css_pipe_binarydesc.h"
-#include "ia_css_frame_format.h"
-#include "ia_css_pipe.h"
-#include "ia_css_pipe_util.h"
-#include "ia_css_util.h"
-#include "ia_css_debug.h"
-#include "sh_css_params.h"
-#include <assert_support.h>
-/* HRT_GDC_N */
-#include "gdc_device.h"
-#include <linux/kernel.h>
-
-/* This module provides a binary descriptions to used to find a binary. Since,
- * every stage is associated with a binary, it implicity helps stage
- * description. Apart from providing a binary description, this module also
- * populates the frame info's when required.*/
-
-/* Generic descriptor for offline binaries. Internal function. */
-static void pipe_binarydesc_get_offline(
-	struct ia_css_pipe const * const pipe,
-	const int mode,
-	struct ia_css_binary_descr *descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info[],
-	struct ia_css_frame_info *vf_info)
-{
-	unsigned int i;
-	/* in_info, out_info, vf_info can be NULL */
-	assert(pipe != NULL);
-	assert(descr != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
-			    "pipe_binarydesc_get_offline() enter:\n");
-
-	descr->mode = mode;
-	descr->online = false;
-	descr->continuous = pipe->stream->config.continuous;
-	descr->striped = false;
-	descr->two_ppc = false;
-	descr->enable_yuv_ds = false;
-	descr->enable_high_speed = false;
-	descr->enable_dvs_6axis = false;
-	descr->enable_reduced_pipe = false;
-	descr->enable_dz = true;
-	descr->enable_xnr = false;
-	descr->enable_dpc = false;
-#ifdef ISP2401
-	descr->enable_luma_only = false;
-	descr->enable_tnr = false;
-#endif
-	descr->enable_capture_pp_bli = false;
-	descr->enable_fractional_ds = false;
-	descr->dvs_env.width = 0;
-	descr->dvs_env.height = 0;
-	descr->stream_format = pipe->stream->config.input_config.format;
-	descr->in_info = in_info;
-	descr->bds_out_info = NULL;
-	for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		descr->out_info[i] = out_info[i];
-	descr->vf_info = vf_info;
-	descr->isp_pipe_version = pipe->config.isp_pipe_version;
-	descr->required_bds_factor = SH_CSS_BDS_FACTOR_1_00;
-	descr->stream_config_left_padding = -1;
-}
-
-void ia_css_pipe_get_copy_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *copy_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info)
-{
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-	unsigned int i;
-	/* out_info can be NULL */
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	IA_CSS_ENTER_PRIVATE("");
-
-	*in_info = *out_info;
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-	pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_COPY,
-				    copy_descr, in_info, out_infos, vf_info);
-	copy_descr->online = true;
-	copy_descr->continuous = false;
-	copy_descr->two_ppc = (pipe->stream->config.pixels_per_clock == 2);
-	copy_descr->enable_dz = false;
-	copy_descr->isp_pipe_version = IA_CSS_PIPE_VERSION_1;
-	IA_CSS_LEAVE_PRIVATE("");
-}
-void ia_css_pipe_get_vfpp_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *vf_pp_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info)
-{
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-	unsigned int i;
-	/* out_info can be NULL ??? */
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	IA_CSS_ENTER_PRIVATE("");
-
-	in_info->raw_bit_depth = 0;
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-
-	pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_VF_PP,
-			       vf_pp_descr, in_info, out_infos, NULL);
-	vf_pp_descr->enable_fractional_ds = true;
-	IA_CSS_LEAVE_PRIVATE("");
-}
-
-static struct sh_css_bds_factor bds_factors_list[] = {
-	{1, 1, SH_CSS_BDS_FACTOR_1_00},
-	{5, 4, SH_CSS_BDS_FACTOR_1_25},
-	{3, 2, SH_CSS_BDS_FACTOR_1_50},
-	{2, 1, SH_CSS_BDS_FACTOR_2_00},
-	{9, 4, SH_CSS_BDS_FACTOR_2_25},
-	{5, 2, SH_CSS_BDS_FACTOR_2_50},
-	{3, 1, SH_CSS_BDS_FACTOR_3_00},
-	{4, 1, SH_CSS_BDS_FACTOR_4_00},
-	{9, 2, SH_CSS_BDS_FACTOR_4_50},
-	{5, 1, SH_CSS_BDS_FACTOR_5_00},
-	{6, 1, SH_CSS_BDS_FACTOR_6_00},
-	{8, 1, SH_CSS_BDS_FACTOR_8_00}
-};
-
-enum ia_css_err sh_css_bds_factor_get_numerator_denominator(
-	unsigned int bds_factor,
-	unsigned int *bds_factor_numerator,
-	unsigned int *bds_factor_denominator)
-{
-	unsigned int i;
-
-	/* Loop over all bds factors until a match is found */
-	for (i = 0; i < ARRAY_SIZE(bds_factors_list); i++) {
-		if (bds_factors_list[i].bds_factor == bds_factor) {
-			*bds_factor_numerator = bds_factors_list[i].numerator;
-			*bds_factor_denominator = bds_factors_list[i].denominator;
-			return IA_CSS_SUCCESS;
-		}
-	}
-
-	/* Throw an error since bds_factor cannot be found
-	in bds_factors_list */
-	return IA_CSS_ERR_INVALID_ARGUMENTS;
-}
-
-enum ia_css_err binarydesc_calculate_bds_factor(
-	struct ia_css_resolution input_res,
-	struct ia_css_resolution output_res,
-	unsigned int *bds_factor)
-{
-	unsigned int i;
-	unsigned int in_w = input_res.width,
-	    in_h = input_res.height,
-	    out_w = output_res.width, out_h = output_res.height;
-
-	unsigned int max_bds_factor = 8;
-	unsigned int max_rounding_margin = 2;
-	/* delta in pixels to account for rounding margin in the calculation */
-	unsigned int delta = max_bds_factor * max_rounding_margin;
-
-	/* Assert if the resolutions are not set */
-	assert(in_w != 0 && in_h != 0);
-	assert(out_w != 0 && out_h != 0);
-
-	/* Loop over all bds factors until a match is found */
-	for (i = 0; i < ARRAY_SIZE(bds_factors_list); i++) {
-		unsigned num = bds_factors_list[i].numerator;
-		unsigned den = bds_factors_list[i].denominator;
-
-		/* See width-wise and height-wise if this bds_factor
-		 * satisfies the condition */
-		bool cond = (out_w * num / den + delta > in_w) &&
-		    (out_w * num / den <= in_w) &&
-		    (out_h * num / den + delta > in_h) &&
-		    (out_h * num / den <= in_h);
-
-		if (cond) {
-			*bds_factor = bds_factors_list[i].bds_factor;
-			return IA_CSS_SUCCESS;
-		}
-	}
-
-	/* Throw an error since a suitable bds_factor cannot be found */
-	return IA_CSS_ERR_INVALID_ARGUMENTS;
-}
-
-enum ia_css_err ia_css_pipe_get_preview_binarydesc(
-	struct ia_css_pipe * const pipe,
-	struct ia_css_binary_descr *preview_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *bds_out_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info)
-{
-	enum ia_css_err err;
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-	int mode = IA_CSS_BINARY_MODE_PREVIEW;
-	unsigned int i;
-
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	assert(out_info != NULL);
-	assert(vf_info != NULL);
-	IA_CSS_ENTER_PRIVATE("");
-
-	/*
-	 * Set up the info of the input frame with
-	 * the ISP required resolution
-	 */
-	in_info->res = pipe->config.input_effective_res;
-	in_info->padded_width = in_info->res.width;
-	in_info->raw_bit_depth = ia_css_pipe_util_pipe_input_format_bpp(pipe);
-
-	if (ia_css_util_is_input_format_yuv(pipe->stream->config.input_config.format))
-		mode = IA_CSS_BINARY_MODE_COPY;
-	else
-		in_info->format = IA_CSS_FRAME_FORMAT_RAW;
-
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-
-	pipe_binarydesc_get_offline(pipe, mode,
-			       preview_descr, in_info, out_infos, vf_info);
-	if (pipe->stream->config.online) {
-		preview_descr->online = pipe->stream->config.online;
-		preview_descr->two_ppc =
-		    (pipe->stream->config.pixels_per_clock == 2);
-	}
-	preview_descr->stream_format = pipe->stream->config.input_config.format;
-
-	/* TODO: Remove this when bds_out_info is available! */
-	*bds_out_info = *in_info;
-
-	if (pipe->extra_config.enable_raw_binning) {
-		if (pipe->config.bayer_ds_out_res.width != 0 &&
-		    pipe->config.bayer_ds_out_res.height != 0) {
-			bds_out_info->res.width =
-			    pipe->config.bayer_ds_out_res.width;
-			bds_out_info->res.height =
-			    pipe->config.bayer_ds_out_res.height;
-			bds_out_info->padded_width =
-			    pipe->config.bayer_ds_out_res.width;
-			err =
-			    binarydesc_calculate_bds_factor(in_info->res,
-				    bds_out_info->res,
-				    &preview_descr->required_bds_factor);
-			if (err != IA_CSS_SUCCESS)
-				return err;
-		} else {
-			bds_out_info->res.width = in_info->res.width / 2;
-			bds_out_info->res.height = in_info->res.height / 2;
-			bds_out_info->padded_width = in_info->padded_width / 2;
-			preview_descr->required_bds_factor =
-			    SH_CSS_BDS_FACTOR_2_00;
-		}
-	} else {
-		/* TODO: Remove this when bds_out_info->is available! */
-		bds_out_info->res.width = in_info->res.width;
-		bds_out_info->res.height = in_info->res.height;
-		bds_out_info->padded_width = in_info->padded_width;
-		preview_descr->required_bds_factor = SH_CSS_BDS_FACTOR_1_00;
-	}
-	pipe->required_bds_factor = preview_descr->required_bds_factor;
-
-	/* bayer ds and fractional ds cannot be enabled at the same time,
-	so we disable bds_out_info when fractional ds is used */
-	if (!pipe->extra_config.enable_fractional_ds)
-		preview_descr->bds_out_info = bds_out_info;
-	else
-		preview_descr->bds_out_info = NULL;
-	/*
-	   ----Preview binary-----
-	   --in-->|--out->|vf_veceven|--|--->vf
-	   -----------------------
-	   * Preview binary normally doesn't have a vf_port but
-	   * instead it has an output port. However, the output is
-	   * generated by vf_veceven module in which we might have
-	   * a downscaling (by 1x, 2x, or 4x). Because the resolution
-	   * might change, we need two different info, namely out_info
-	   * & vf_info. In fill_binary_info we use out&vf info to
-	   * calculate vf decimation factor.
-	 */
-	*out_info = *vf_info;
-
-	/* In case of preview_ds binary, we can do any fractional amount
-	 * of downscale, so there is no DS needed in vf_veceven. Therefore,
-	 * out and vf infos will be the same. Otherwise, we set out resolution
-	 * equal to in resolution. */
-	if (!pipe->extra_config.enable_fractional_ds) {
-		/* TODO: Change this when bds_out_info is available! */
-		out_info->res.width = bds_out_info->res.width;
-		out_info->res.height = bds_out_info->res.height;
-		out_info->padded_width = bds_out_info->padded_width;
-	}
-	preview_descr->enable_fractional_ds =
-	    pipe->extra_config.enable_fractional_ds;
-
-	preview_descr->enable_dpc = pipe->config.enable_dpc;
-
-	preview_descr->isp_pipe_version = pipe->config.isp_pipe_version;
-	IA_CSS_LEAVE_ERR_PRIVATE(IA_CSS_SUCCESS);
-	return IA_CSS_SUCCESS;
-}
-
-enum ia_css_err ia_css_pipe_get_video_binarydesc(
-	struct ia_css_pipe * const pipe,
-	struct ia_css_binary_descr *video_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *bds_out_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info,
-	int stream_config_left_padding)
-{
-	int mode = IA_CSS_BINARY_MODE_VIDEO;
-	unsigned int i;
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-	enum ia_css_err err = IA_CSS_SUCCESS;
-	bool stream_dz_config = false;
-
-	/* vf_info can be NULL */
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	/* assert(vf_info != NULL); */
-	IA_CSS_ENTER_PRIVATE("");
-
-	/* The solution below is not optimal; we should move to using ia_css_pipe_get_copy_binarydesc()
-	 * But for now this fixes things; this code used to be there but was removed
-	 * with gerrit 8908 as this was wrong for Skycam; however 240x still needs this
-	 */
-	if (ia_css_util_is_input_format_yuv(pipe->stream->config.input_config.format))
-		mode = IA_CSS_BINARY_MODE_COPY;
-
-	in_info->res = pipe->config.input_effective_res;
-	in_info->padded_width = in_info->res.width;
-	in_info->format = IA_CSS_FRAME_FORMAT_RAW;
-	in_info->raw_bit_depth = ia_css_pipe_util_pipe_input_format_bpp(pipe);
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-
-	pipe_binarydesc_get_offline(pipe, mode,
-	       video_descr, in_info, out_infos, vf_info);
-
-	if (pipe->stream->config.online) {
-		video_descr->online = pipe->stream->config.online;
-		video_descr->two_ppc =
-		    (pipe->stream->config.pixels_per_clock == 2);
-	}
-
-	if (mode == IA_CSS_BINARY_MODE_VIDEO) {
-		stream_dz_config =
-		    ((pipe->stream->isp_params_configs->dz_config.dx !=
-		      HRT_GDC_N)
-		     || (pipe->stream->isp_params_configs->dz_config.dy !=
-			 HRT_GDC_N));
-
-		video_descr->enable_dz = pipe->config.enable_dz
-		    || stream_dz_config;
-		video_descr->dvs_env = pipe->config.dvs_envelope;
-		video_descr->enable_yuv_ds = pipe->extra_config.enable_yuv_ds;
-		video_descr->enable_high_speed =
-		    pipe->extra_config.enable_high_speed;
-		video_descr->enable_dvs_6axis =
-		    pipe->extra_config.enable_dvs_6axis;
-		video_descr->enable_reduced_pipe =
-		    pipe->extra_config.enable_reduced_pipe;
-		video_descr->isp_pipe_version = pipe->config.isp_pipe_version;
-		video_descr->enable_fractional_ds =
-		    pipe->extra_config.enable_fractional_ds;
-		video_descr->enable_dpc =
-			pipe->config.enable_dpc;
-#ifdef ISP2401
-		video_descr->enable_luma_only =
-			pipe->config.enable_luma_only;
-		video_descr->enable_tnr =
-			pipe->config.enable_tnr;
-#endif
-
-		if (pipe->extra_config.enable_raw_binning) {
-			if (pipe->config.bayer_ds_out_res.width != 0 &&
-			    pipe->config.bayer_ds_out_res.height != 0) {
-				bds_out_info->res.width =
-				    pipe->config.bayer_ds_out_res.width;
-				bds_out_info->res.height =
-				    pipe->config.bayer_ds_out_res.height;
-				bds_out_info->padded_width =
-				    pipe->config.bayer_ds_out_res.width;
-				err =
-				binarydesc_calculate_bds_factor(
-					in_info->res, bds_out_info->res,
-					&video_descr->required_bds_factor);
-				if (err != IA_CSS_SUCCESS)
-					return err;
-			} else {
-				bds_out_info->res.width =
-				    in_info->res.width / 2;
-				bds_out_info->res.height =
-				    in_info->res.height / 2;
-				bds_out_info->padded_width =
-				    in_info->padded_width / 2;
-				video_descr->required_bds_factor =
-				    SH_CSS_BDS_FACTOR_2_00;
-			}
-		} else {
-			bds_out_info->res.width = in_info->res.width;
-			bds_out_info->res.height = in_info->res.height;
-			bds_out_info->padded_width = in_info->padded_width;
-			video_descr->required_bds_factor =
-			    SH_CSS_BDS_FACTOR_1_00;
-		}
-
-		pipe->required_bds_factor = video_descr->required_bds_factor;
-
-		/* bayer ds and fractional ds cannot be enabled
-		at the same time, so we disable bds_out_info when
-		fractional ds is used */
-		if (!pipe->extra_config.enable_fractional_ds)
-			video_descr->bds_out_info = bds_out_info;
-		else
-			video_descr->bds_out_info = NULL;
-
-		video_descr->enable_fractional_ds =
-		    pipe->extra_config.enable_fractional_ds;
-		video_descr->stream_config_left_padding = stream_config_left_padding;
-	}
-	IA_CSS_LEAVE_ERR_PRIVATE(err);
-	return err;
-}
-
-void ia_css_pipe_get_yuvscaler_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *yuv_scaler_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *internal_out_info,
-	struct ia_css_frame_info *vf_info)
-{
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-	struct ia_css_frame_info *this_vf_info = NULL;
-
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	/* Note: if the following assert fails, the number of ports has been
-	 * changed; in that case an additional initializer must be added
-	 * a few lines below after which this assert can be updated.
-	 */
-	assert(IA_CSS_BINARY_MAX_OUTPUT_PORTS == 2);
-	IA_CSS_ENTER_PRIVATE("");
-
-	in_info->padded_width = in_info->res.width;
-	in_info->raw_bit_depth = 0;
-	ia_css_frame_info_set_width(in_info, in_info->res.width, 0);
-	out_infos[0] = out_info;
-	out_infos[1] = internal_out_info;
-	/* add initializers here if
-	 * assert(IA_CSS_BINARY_MAX_OUTPUT_PORTS == ...);
-	 * fails
-	 */
-
-	if (vf_info) {
-		this_vf_info = (vf_info->res.width == 0 &&
-			vf_info->res.height == 0) ? NULL : vf_info;
-	}
-
-	pipe_binarydesc_get_offline(pipe,
-			       IA_CSS_BINARY_MODE_CAPTURE_PP,
-			       yuv_scaler_descr,
-			       in_info, out_infos, this_vf_info);
-
-	yuv_scaler_descr->enable_fractional_ds = true;
-	IA_CSS_LEAVE_PRIVATE("");
-}
-
-void ia_css_pipe_get_capturepp_binarydesc(
-	struct ia_css_pipe * const pipe,
-	struct ia_css_binary_descr *capture_pp_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info)
-{
-	unsigned int i;
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	assert(vf_info != NULL);
-	IA_CSS_ENTER_PRIVATE("");
-
-
-	/* the in_info is only used for resolution to enable
-	   bayer down scaling. */
-	if (pipe->out_yuv_ds_input_info.res.width)
-		*in_info = pipe->out_yuv_ds_input_info;
-	else
-		*in_info = *out_info;
-	in_info->format = IA_CSS_FRAME_FORMAT_YUV420;
-	in_info->raw_bit_depth = 0;
-	ia_css_frame_info_set_width(in_info, in_info->res.width, 0);
-
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-
-	pipe_binarydesc_get_offline(pipe,
-			       IA_CSS_BINARY_MODE_CAPTURE_PP,
-			       capture_pp_descr,
-			       in_info, out_infos, vf_info);
-
-	capture_pp_descr->enable_capture_pp_bli =
-		pipe->config.default_capture_config.enable_capture_pp_bli;
-	capture_pp_descr->enable_fractional_ds = true;
-	capture_pp_descr->enable_xnr =
-		pipe->config.default_capture_config.enable_xnr != 0;
-	IA_CSS_LEAVE_PRIVATE("");
-}
-
-/* lookup table for high quality primary binaries */
-static unsigned int primary_hq_binary_modes[NUM_PRIMARY_HQ_STAGES] =
-{
-	IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE0,
-	IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE1,
-	IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE2,
-	IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE3,
-	IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE4,
-	IA_CSS_BINARY_MODE_PRIMARY_HQ_STAGE5
-};
-
-void ia_css_pipe_get_primary_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *prim_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info,
-	unsigned int stage_idx)
-{
-	enum ia_css_pipe_version pipe_version = pipe->config.isp_pipe_version;
-	int mode;
-	unsigned int i;
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	assert(out_info != NULL);
-	assert(stage_idx < NUM_PRIMARY_HQ_STAGES);
-	/* vf_info can be NULL - example video_binarydescr */
-	/*assert(vf_info != NULL);*/
-	IA_CSS_ENTER_PRIVATE("");
-
-	if (pipe_version == IA_CSS_PIPE_VERSION_2_6_1)
-		mode = primary_hq_binary_modes[stage_idx];
-	else
-		mode = IA_CSS_BINARY_MODE_PRIMARY;
-
-	if (ia_css_util_is_input_format_yuv(pipe->stream->config.input_config.format))
-		mode = IA_CSS_BINARY_MODE_COPY;
-
-	in_info->res = pipe->config.input_effective_res;
-	in_info->padded_width = in_info->res.width;
-
-#if !defined(HAS_NO_PACKED_RAW_PIXELS)
-	if (pipe->stream->config.pack_raw_pixels)
-		in_info->format = IA_CSS_FRAME_FORMAT_RAW_PACKED;
-	else
-#endif
-		in_info->format = IA_CSS_FRAME_FORMAT_RAW;
-
-	in_info->raw_bit_depth = ia_css_pipe_util_pipe_input_format_bpp(pipe);
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-
-	pipe_binarydesc_get_offline(pipe, mode,
-			       prim_descr, in_info, out_infos, vf_info);
-
-	if (pipe->stream->config.online &&
-	    pipe->stream->config.mode != IA_CSS_INPUT_MODE_MEMORY) {
-		prim_descr->online = true;
-		prim_descr->two_ppc =
-		    (pipe->stream->config.pixels_per_clock == 2);
-		prim_descr->stream_format = pipe->stream->config.input_config.format;
-	}
-	if (mode == IA_CSS_BINARY_MODE_PRIMARY) {
-		prim_descr->isp_pipe_version = pipe->config.isp_pipe_version;
-		prim_descr->enable_fractional_ds =
-		    pipe->extra_config.enable_fractional_ds;
-#ifdef ISP2401
-		prim_descr->enable_luma_only =
-			pipe->config.enable_luma_only;
-#endif
-		/* We have both striped and non-striped primary binaries,
-		 * if continuous viewfinder is required, then we must select
-		 * a striped one. Otherwise we prefer to use a non-striped
-		 * since it has better performance. */
-		if (pipe_version == IA_CSS_PIPE_VERSION_2_6_1)
-			prim_descr->striped = false;
-		else
-#ifndef ISP2401
-			prim_descr->striped = prim_descr->continuous && (!pipe->stream->stop_copy_preview || !pipe->stream->disable_cont_vf);
-#else
-			prim_descr->striped = prim_descr->continuous && !pipe->stream->disable_cont_vf;
-
-		if ((pipe->config.default_capture_config.enable_xnr != 0) &&
-			(pipe->extra_config.enable_dvs_6axis == true))
-				prim_descr->enable_xnr = true;
-#endif
-	}
-	IA_CSS_LEAVE_PRIVATE("");
-}
-
-void ia_css_pipe_get_pre_gdc_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *pre_gdc_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info)
-{
-	unsigned int i;
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	assert(out_info != NULL);
-	IA_CSS_ENTER_PRIVATE("");
-
-	*in_info = *out_info;
-	in_info->format = IA_CSS_FRAME_FORMAT_RAW;
-	in_info->raw_bit_depth = ia_css_pipe_util_pipe_input_format_bpp(pipe);
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-
-	pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_PRE_ISP,
-			       pre_gdc_descr, in_info, out_infos, NULL);
-	pre_gdc_descr->isp_pipe_version = pipe->config.isp_pipe_version;
-	IA_CSS_LEAVE_PRIVATE("");
-}
-
-void ia_css_pipe_get_gdc_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *gdc_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info)
-{
-	unsigned int i;
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	assert(out_info != NULL);
-	IA_CSS_ENTER_PRIVATE("");
-
-	*in_info = *out_info;
-	in_info->format = IA_CSS_FRAME_FORMAT_QPLANE6;
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-
-	pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_GDC,
-			       gdc_descr, in_info, out_infos, NULL);
-	IA_CSS_LEAVE_PRIVATE("");
-}
-
-void ia_css_pipe_get_post_gdc_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *post_gdc_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info)
-{
-	unsigned int i;
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	assert(out_info != NULL);
-	assert(vf_info != NULL);
-	IA_CSS_ENTER_PRIVATE("");
-
-	*in_info = *out_info;
-	in_info->format = IA_CSS_FRAME_FORMAT_YUV420_16;
-	in_info->raw_bit_depth = 16;
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-
-	pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_POST_ISP,
-			       post_gdc_descr, in_info, out_infos, vf_info);
-
-	post_gdc_descr->isp_pipe_version = pipe->config.isp_pipe_version;
-	IA_CSS_LEAVE_PRIVATE("");
-}
-
-void ia_css_pipe_get_pre_de_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *pre_de_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info)
-{
-	unsigned int i;
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	assert(out_info != NULL);
-	IA_CSS_ENTER_PRIVATE("");
-
-	*in_info = *out_info;
-	in_info->format = IA_CSS_FRAME_FORMAT_RAW;
-	in_info->raw_bit_depth = ia_css_pipe_util_pipe_input_format_bpp(pipe);
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-
-	if (pipe->config.isp_pipe_version == IA_CSS_PIPE_VERSION_1)
-		pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_PRE_ISP,
-				       pre_de_descr, in_info, out_infos, NULL);
-	else if (pipe->config.isp_pipe_version == IA_CSS_PIPE_VERSION_2_2) {
-		pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_PRE_DE,
-				       pre_de_descr, in_info, out_infos, NULL);
-	}
-
-	if (pipe->stream->config.online) {
-		pre_de_descr->online = true;
-		pre_de_descr->two_ppc =
-		    (pipe->stream->config.pixels_per_clock == 2);
-		pre_de_descr->stream_format = pipe->stream->config.input_config.format;
-	}
-	pre_de_descr->isp_pipe_version = pipe->config.isp_pipe_version;
-	IA_CSS_LEAVE_PRIVATE("");
-}
-
-void ia_css_pipe_get_pre_anr_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *pre_anr_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info)
-{
-	unsigned int i;
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	assert(out_info != NULL);
-	IA_CSS_ENTER_PRIVATE("");
-
-	*in_info = *out_info;
-	in_info->format = IA_CSS_FRAME_FORMAT_RAW;
-	in_info->raw_bit_depth = ia_css_pipe_util_pipe_input_format_bpp(pipe);
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-
-	pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_PRE_ISP,
-			       pre_anr_descr, in_info, out_infos, NULL);
-
-	if (pipe->stream->config.online) {
-		pre_anr_descr->online = true;
-		pre_anr_descr->two_ppc =
-		    (pipe->stream->config.pixels_per_clock == 2);
-		pre_anr_descr->stream_format = pipe->stream->config.input_config.format;
-	}
-	pre_anr_descr->isp_pipe_version = pipe->config.isp_pipe_version;
-	IA_CSS_LEAVE_PRIVATE("");
-}
-
-void ia_css_pipe_get_anr_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *anr_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info)
-{
-	unsigned int i;
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	assert(out_info != NULL);
-	IA_CSS_ENTER_PRIVATE("");
-
-	*in_info = *out_info;
-	in_info->format = IA_CSS_FRAME_FORMAT_RAW;
-	in_info->raw_bit_depth = ANR_ELEMENT_BITS;
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-
-	pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_ANR,
-			       anr_descr, in_info, out_infos, NULL);
-
-	anr_descr->isp_pipe_version = pipe->config.isp_pipe_version;
-	IA_CSS_LEAVE_PRIVATE("");
-}
-
-
-void ia_css_pipe_get_post_anr_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *post_anr_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info,
-	struct ia_css_frame_info *vf_info)
-{
-	unsigned int i;
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	assert(out_info != NULL);
-	assert(vf_info != NULL);
-	IA_CSS_ENTER_PRIVATE("");
-
-	*in_info = *out_info;
-	in_info->format = IA_CSS_FRAME_FORMAT_RAW;
-	in_info->raw_bit_depth = ANR_ELEMENT_BITS;
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-
-	pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_POST_ISP,
-			       post_anr_descr, in_info, out_infos, vf_info);
-
-	post_anr_descr->isp_pipe_version = pipe->config.isp_pipe_version;
-	IA_CSS_LEAVE_PRIVATE("");
-}
-
-void ia_css_pipe_get_ldc_binarydesc(
-	struct ia_css_pipe const * const pipe,
-	struct ia_css_binary_descr *ldc_descr,
-	struct ia_css_frame_info *in_info,
-	struct ia_css_frame_info *out_info)
-{
-	unsigned int i;
-	struct ia_css_frame_info *out_infos[IA_CSS_BINARY_MAX_OUTPUT_PORTS];
-
-	assert(pipe != NULL);
-	assert(in_info != NULL);
-	assert(out_info != NULL);
-	IA_CSS_ENTER_PRIVATE("");
-
-#ifndef ISP2401
-	*in_info = *out_info;
-#else
-	if (pipe->out_yuv_ds_input_info.res.width)
-		*in_info = pipe->out_yuv_ds_input_info;
-	else
-		*in_info = *out_info;
-#endif
-	in_info->format = IA_CSS_FRAME_FORMAT_YUV420;
-	in_info->raw_bit_depth = 0;
-	ia_css_frame_info_set_width(in_info, in_info->res.width, 0);
-
-	out_infos[0] = out_info;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
-		out_infos[i] = NULL;
-
-	pipe_binarydesc_get_offline(pipe, IA_CSS_BINARY_MODE_CAPTURE_PP,
-			       ldc_descr, in_info, out_infos, NULL);
-	ldc_descr->enable_dvs_6axis =
-		    pipe->extra_config.enable_dvs_6axis;
-	IA_CSS_LEAVE_PRIVATE("");
-}

+ 0 - 115
drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/src/pipe_stagedesc.c

@@ -1,115 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-
-#include "ia_css_pipe_stagedesc.h"
-#include "assert_support.h"
-#include "ia_css_debug.h"
-
-void ia_css_pipe_get_generic_stage_desc(
-	struct ia_css_pipeline_stage_desc *stage_desc,
-	struct ia_css_binary *binary,
-	struct ia_css_frame *out_frame[],
-	struct ia_css_frame *in_frame,
-	struct ia_css_frame *vf_frame)
-{
-	unsigned int i;
-	IA_CSS_ENTER_PRIVATE("stage_desc = %p, binary = %p, out_frame = %p, in_frame = %p, vf_frame = %p",
-			     stage_desc, binary, out_frame, in_frame, vf_frame);
-
-	assert(stage_desc != NULL && binary != NULL && binary->info != NULL);
-	if (stage_desc == NULL || binary == NULL || binary->info == NULL) {
-		IA_CSS_ERROR("invalid arguments");
-		goto ERR;
-	}
-
-	stage_desc->binary = binary;
-	stage_desc->firmware = NULL;
-	stage_desc->sp_func = IA_CSS_PIPELINE_NO_FUNC;
-	stage_desc->max_input_width = 0;
-	stage_desc->mode = binary->info->sp.pipeline.mode;
-	stage_desc->in_frame = in_frame;
-	for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
-		stage_desc->out_frame[i] = out_frame[i];
-	}
-	stage_desc->vf_frame = vf_frame;
-ERR:
-	IA_CSS_LEAVE_PRIVATE("");
-}
-
-void ia_css_pipe_get_firmwares_stage_desc(
-	struct ia_css_pipeline_stage_desc *stage_desc,
-	struct ia_css_binary *binary,
-	struct ia_css_frame *out_frame[],
-	struct ia_css_frame *in_frame,
-	struct ia_css_frame *vf_frame,
-	const struct ia_css_fw_info *fw,
-	unsigned int mode)
-{
-	unsigned int i;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_pipe_get_firmwares_stage_desc() enter:\n");
-	stage_desc->binary = binary;
-	stage_desc->firmware = fw;
-	stage_desc->sp_func = IA_CSS_PIPELINE_NO_FUNC;
-	stage_desc->max_input_width = 0;
-	stage_desc->mode = mode;
-	stage_desc->in_frame = in_frame;
-	for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
-		stage_desc->out_frame[i] = out_frame[i];
-	}
-	stage_desc->vf_frame = vf_frame;
-}
-
-void ia_css_pipe_get_acc_stage_desc(
-	struct ia_css_pipeline_stage_desc *stage_desc,
-	struct ia_css_binary *binary,
-	struct ia_css_fw_info *fw)
-{
-	unsigned int i;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_pipe_get_acc_stage_desc() enter:\n");
-	stage_desc->binary = binary;
-	stage_desc->firmware = fw;
-	stage_desc->sp_func = IA_CSS_PIPELINE_NO_FUNC;
-	stage_desc->max_input_width = 0;
-	stage_desc->mode = IA_CSS_BINARY_MODE_VF_PP;
-	stage_desc->in_frame = NULL;
-	for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
-		stage_desc->out_frame[i] = NULL;
-	}
-	stage_desc->vf_frame = NULL;
-}
-
-void ia_css_pipe_get_sp_func_stage_desc(
-	struct ia_css_pipeline_stage_desc *stage_desc,
-	struct ia_css_frame *out_frame,
-	enum ia_css_pipeline_stage_sp_func sp_func,
-	unsigned max_input_width)
-{
-	unsigned int i;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_pipe_get_sp_func_stage_desc() enter:\n");
-	stage_desc->binary = NULL;
-	stage_desc->firmware = NULL;
-	stage_desc->sp_func = sp_func;
-	stage_desc->max_input_width = max_input_width;
-	stage_desc->mode = (unsigned int)-1;
-	stage_desc->in_frame = NULL;
-	stage_desc->out_frame[0] = out_frame;
-	for (i = 1; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
-		stage_desc->out_frame[i] = NULL;
-	}
-	stage_desc->vf_frame = NULL;
-}
-

+ 0 - 51
drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/pipe/src/pipe_util.c

@@ -1,51 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-
-#include "ia_css_pipe_util.h"
-#include "ia_css_frame_public.h"
-#include "ia_css_pipe.h"
-#include "ia_css_util.h"
-#include "assert_support.h"
-
-unsigned int ia_css_pipe_util_pipe_input_format_bpp(
-	const struct ia_css_pipe * const pipe)
-{
-	assert(pipe != NULL);
-	assert(pipe->stream != NULL);
-
-	return ia_css_util_input_format_bpp(pipe->stream->config.input_config.format,
-			  pipe->stream->config.pixels_per_clock == 2);
-}
-
-void ia_css_pipe_util_create_output_frames(
-	struct ia_css_frame *frames[])
-{
-	unsigned int i;
-
-	assert(frames != NULL);
-	for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
-		frames[i] = NULL;
-	}
-}
-
-void ia_css_pipe_util_set_output_frames(
-	struct ia_css_frame *frames[],
-	unsigned int idx,
-	struct ia_css_frame *frame)
-{
-	assert(idx < IA_CSS_BINARY_MAX_OUTPUT_PORTS);
-
-	frames[idx] = frame;
-}
-

+ 0 - 141
drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/util/interface/ia_css_util.h

@@ -1,141 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 __IA_CSS_UTIL_H__
-#define __IA_CSS_UTIL_H__
-
-#include <ia_css_err.h>
-#include <error_support.h>
-#include <type_support.h>
-#include <ia_css_frame_public.h>
-#include <ia_css_stream_public.h>
-#include <ia_css_stream_format.h>
-
-/* @brief convert "errno" error code to "ia_css_err" error code
- *
- * @param[in]	"errno" error code
- * @return	"ia_css_err" error code
- *
- */
-enum ia_css_err ia_css_convert_errno(
-	int in_err);
-
-/* @brief check vf frame info.
- *
- * @param[in] info
- * @return	IA_CSS_SUCCESS or error code upon error.
- *
- */
-extern enum ia_css_err ia_css_util_check_vf_info(
-	const struct ia_css_frame_info * const info);
-
-/* @brief check input configuration.
- *
- * @param[in] stream_config
- * @param[in] must_be_raw
- * @return	IA_CSS_SUCCESS or error code upon error.
- *
- */
-extern enum ia_css_err ia_css_util_check_input(
-	const struct ia_css_stream_config * const stream_config,
-	bool must_be_raw,
-	bool must_be_yuv);
-
-/* @brief check vf and out frame info.
- *
- * @param[in] out_info
- * @param[in] vf_info
- * @return	IA_CSS_SUCCESS or error code upon error.
- *
- */
-extern enum ia_css_err ia_css_util_check_vf_out_info(
-	const struct ia_css_frame_info * const out_info,
-	const struct ia_css_frame_info * const vf_info);
-
-/* @brief check width and height
- *
- * @param[in] width
- * @param[in] height
- * @return	IA_CSS_SUCCESS or error code upon error.
- *
- */
-extern enum ia_css_err ia_css_util_check_res(
-	unsigned int width,
-	unsigned int height);
-
-#ifdef ISP2401
-/* @brief compare resolutions (less or equal)
- *
- * @param[in] a resolution
- * @param[in] b resolution
- * @return    true if both dimensions of a are less or
- *            equal than those of b, false otherwise
- *
- */
-extern bool ia_css_util_res_leq(
-	struct ia_css_resolution a,
-	struct ia_css_resolution b);
-
-/**
- * @brief Check if resolution is zero
- *
- * @param[in] resolution The resolution to check
- *
- * @returns true if resolution is zero
- */
-extern bool ia_css_util_resolution_is_zero(
-		const struct ia_css_resolution resolution);
-
-/**
- * @brief Check if resolution is even
- *
- * @param[in] resolution The resolution to check
- *
- * @returns true if resolution is even
- */
-extern bool ia_css_util_resolution_is_even(
-		const struct ia_css_resolution resolution);
-
-#endif
-/* @brief check width and height
- *
- * @param[in] stream_format
- * @param[in] two_ppc
- * @return bits per pixel based on given parameters.
- *
- */
-extern unsigned int ia_css_util_input_format_bpp(
-	enum atomisp_input_format stream_format,
-	bool two_ppc);
-
-/* @brief check if input format it raw
- *
- * @param[in] stream_format
- * @return true if the input format is raw or false otherwise
- *
- */
-extern bool ia_css_util_is_input_format_raw(
-	enum atomisp_input_format stream_format);
-
-/* @brief check if input format it yuv
- *
- * @param[in] stream_format
- * @return true if the input format is yuv or false otherwise
- *
- */
-extern bool ia_css_util_is_input_format_yuv(
-	enum atomisp_input_format stream_format);
-
-#endif /* __IA_CSS_UTIL_H__ */
-

+ 0 - 227
drivers/staging/media/atomisp/pci/atomisp2/css2400/camera/util/src/util.c

@@ -1,227 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-
-#include "ia_css_util.h"
-#include <ia_css_frame.h>
-#include <assert_support.h>
-#include <math_support.h>
-
-/* for ia_css_binary_max_vf_width() */
-#include "ia_css_binary.h"
-
-
-enum ia_css_err ia_css_convert_errno(
-				int in_err)
-{
-	enum ia_css_err out_err;
-
-	switch (in_err) {
-		case 0:
-			out_err = IA_CSS_SUCCESS;
-			break;
-		case EINVAL:
-			out_err = IA_CSS_ERR_INVALID_ARGUMENTS;
-			break;
-		case ENODATA:
-			out_err = IA_CSS_ERR_QUEUE_IS_EMPTY;
-			break;
-		case ENOSYS:
-		case ENOTSUP:
-			out_err = IA_CSS_ERR_INTERNAL_ERROR;
-			break;
-		case ENOBUFS:
-			out_err = IA_CSS_ERR_QUEUE_IS_FULL;
-			break;
-		default:
-			out_err = IA_CSS_ERR_INTERNAL_ERROR;
-			break;
-	}
-	return out_err;
-}
-
-/* MW: Table look-up ??? */
-unsigned int ia_css_util_input_format_bpp(
-	enum atomisp_input_format format,
-	bool two_ppc)
-{
-	unsigned int rval = 0;
-	switch (format) {
-	case ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY:
-	case ATOMISP_INPUT_FORMAT_YUV420_8:
-	case ATOMISP_INPUT_FORMAT_YUV422_8:
-	case ATOMISP_INPUT_FORMAT_RGB_888:
-	case ATOMISP_INPUT_FORMAT_RAW_8:
-	case ATOMISP_INPUT_FORMAT_BINARY_8:
-	case ATOMISP_INPUT_FORMAT_EMBEDDED:
-		rval = 8;
-		break;
-	case ATOMISP_INPUT_FORMAT_YUV420_10:
-	case ATOMISP_INPUT_FORMAT_YUV422_10:
-	case ATOMISP_INPUT_FORMAT_RAW_10:
-		rval = 10;
-		break;
-	case ATOMISP_INPUT_FORMAT_YUV420_16:
-	case ATOMISP_INPUT_FORMAT_YUV422_16:
-		rval = 16;
-		break;
-	case ATOMISP_INPUT_FORMAT_RGB_444:
-		rval = 4;
-		break;
-	case ATOMISP_INPUT_FORMAT_RGB_555:
-		rval = 5;
-		break;
-	case ATOMISP_INPUT_FORMAT_RGB_565:
-		rval = 65;
-		break;
-	case ATOMISP_INPUT_FORMAT_RGB_666:
-	case ATOMISP_INPUT_FORMAT_RAW_6:
-		rval = 6;
-		break;
-	case ATOMISP_INPUT_FORMAT_RAW_7:
-		rval = 7;
-		break;
-	case ATOMISP_INPUT_FORMAT_RAW_12:
-		rval = 12;
-		break;
-	case ATOMISP_INPUT_FORMAT_RAW_14:
-		if (two_ppc)
-			rval = 14;
-		else
-			rval = 12;
-		break;
-	case ATOMISP_INPUT_FORMAT_RAW_16:
-		if (two_ppc)
-			rval = 16;
-		else
-			rval = 12;
-		break;
-	default:
-		rval = 0;
-		break;
-
-	}
-	return rval;
-}
-
-enum ia_css_err ia_css_util_check_vf_info(
-	const struct ia_css_frame_info * const info)
-{
-	enum ia_css_err err;
-	unsigned int max_vf_width;
-	assert(info != NULL);
-	err = ia_css_frame_check_info(info);
-	if (err != IA_CSS_SUCCESS)
-		return err;
-	max_vf_width = ia_css_binary_max_vf_width();
-	if (max_vf_width != 0 && info->res.width > max_vf_width*2)
-		return IA_CSS_ERR_INVALID_ARGUMENTS;
-	return IA_CSS_SUCCESS;
-}
-
-enum ia_css_err ia_css_util_check_vf_out_info(
-	const struct ia_css_frame_info * const out_info,
-	const struct ia_css_frame_info * const vf_info)
-{
-	enum ia_css_err err;
-
-	assert(out_info != NULL);
-	assert(vf_info != NULL);
-
-	err = ia_css_frame_check_info(out_info);
-	if (err != IA_CSS_SUCCESS)
-		return err;
-	err = ia_css_util_check_vf_info(vf_info);
-	if (err != IA_CSS_SUCCESS)
-		return err;
-	return IA_CSS_SUCCESS;
-}
-
-enum ia_css_err ia_css_util_check_res(unsigned int width, unsigned int height)
-{
-	/* height can be odd number for jpeg/embedded data from ISYS2401 */
-	if (((width  == 0)   ||
-	     (height == 0)   ||
-	     IS_ODD(width))) {
-		return IA_CSS_ERR_INVALID_ARGUMENTS;
-	}
-	return IA_CSS_SUCCESS;
-}
-
-#ifdef ISP2401
-bool ia_css_util_res_leq(struct ia_css_resolution a, struct ia_css_resolution b)
-{
-	return a.width <= b.width && a.height <= b.height;
-}
-
-bool ia_css_util_resolution_is_zero(const struct ia_css_resolution resolution)
-{
-	return (resolution.width == 0) || (resolution.height == 0);
-}
-
-bool ia_css_util_resolution_is_even(const struct ia_css_resolution resolution)
-{
-	return IS_EVEN(resolution.height) && IS_EVEN(resolution.width);
-}
-
-#endif
-bool ia_css_util_is_input_format_raw(enum atomisp_input_format format)
-{
-	return ((format == ATOMISP_INPUT_FORMAT_RAW_6) ||
-		(format == ATOMISP_INPUT_FORMAT_RAW_7) ||
-		(format == ATOMISP_INPUT_FORMAT_RAW_8) ||
-		(format == ATOMISP_INPUT_FORMAT_RAW_10) ||
-		(format == ATOMISP_INPUT_FORMAT_RAW_12));
-	/* raw_14 and raw_16 are not supported as input formats to the ISP.
-	 * They can only be copied to a frame in memory using the
-	 * copy binary.
-	 */
-}
-
-bool ia_css_util_is_input_format_yuv(enum atomisp_input_format format)
-{
-	return format == ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY ||
-	    format == ATOMISP_INPUT_FORMAT_YUV420_8  ||
-	    format == ATOMISP_INPUT_FORMAT_YUV420_10 ||
-	    format == ATOMISP_INPUT_FORMAT_YUV420_16 ||
-	    format == ATOMISP_INPUT_FORMAT_YUV422_8  ||
-	    format == ATOMISP_INPUT_FORMAT_YUV422_10 ||
-	    format == ATOMISP_INPUT_FORMAT_YUV422_16;
-}
-
-enum ia_css_err ia_css_util_check_input(
-	const struct ia_css_stream_config * const stream_config,
-	bool must_be_raw,
-	bool must_be_yuv)
-{
-	assert(stream_config != NULL);
-
-	if (stream_config == NULL)
-		return IA_CSS_ERR_INVALID_ARGUMENTS;
-
-#ifdef IS_ISP_2400_SYSTEM
-	if (stream_config->input_config.effective_res.width == 0 ||
-	    stream_config->input_config.effective_res.height == 0)
-		return IA_CSS_ERR_INVALID_ARGUMENTS;
-#endif
-	if (must_be_raw &&
-	    !ia_css_util_is_input_format_raw(stream_config->input_config.format))
-		return IA_CSS_ERR_INVALID_ARGUMENTS;
-
-	if (must_be_yuv &&
-	    !ia_css_util_is_input_format_yuv(stream_config->input_config.format))
-		return IA_CSS_ERR_INVALID_ARGUMENTS;
-
-	return IA_CSS_SUCCESS;
-}
-

+ 0 - 360
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_configs.c

@@ -1,360 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-
-/* Generated code: do not edit or commmit. */
-
-#define IA_CSS_INCLUDE_CONFIGURATIONS
-#include "ia_css_pipeline.h"
-#include "ia_css_isp_configs.h"
-#include "ia_css_debug.h"
-#include "assert_support.h"
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_iterator(
-	const struct ia_css_binary *binary,
-	const struct ia_css_iterator_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_iterator() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.iterator.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.iterator.offset;
-		}
-		if (size) {
-			ia_css_iterator_config((struct sh_css_isp_iterator_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_iterator() leave:\n");
-}
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_copy_output(
-	const struct ia_css_binary *binary,
-	const struct ia_css_copy_output_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_copy_output() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.copy_output.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.copy_output.offset;
-		}
-		if (size) {
-			ia_css_copy_output_config((struct sh_css_isp_copy_output_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_copy_output() leave:\n");
-}
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_crop(
-	const struct ia_css_binary *binary,
-	const struct ia_css_crop_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_crop() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.crop.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.crop.offset;
-		}
-		if (size) {
-			ia_css_crop_config((struct sh_css_isp_crop_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_crop() leave:\n");
-}
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_fpn(
-	const struct ia_css_binary *binary,
-	const struct ia_css_fpn_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_fpn() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.fpn.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.fpn.offset;
-		}
-		if (size) {
-			ia_css_fpn_config((struct sh_css_isp_fpn_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_fpn() leave:\n");
-}
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_dvs(
-	const struct ia_css_binary *binary,
-	const struct ia_css_dvs_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_dvs() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.dvs.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.dvs.offset;
-		}
-		if (size) {
-			ia_css_dvs_config((struct sh_css_isp_dvs_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_dvs() leave:\n");
-}
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_qplane(
-	const struct ia_css_binary *binary,
-	const struct ia_css_qplane_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_qplane() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.qplane.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.qplane.offset;
-		}
-		if (size) {
-			ia_css_qplane_config((struct sh_css_isp_qplane_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_qplane() leave:\n");
-}
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_output0(
-	const struct ia_css_binary *binary,
-	const struct ia_css_output0_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_output0() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.output0.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.output0.offset;
-		}
-		if (size) {
-			ia_css_output0_config((struct sh_css_isp_output_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_output0() leave:\n");
-}
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_output1(
-	const struct ia_css_binary *binary,
-	const struct ia_css_output1_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_output1() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.output1.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.output1.offset;
-		}
-		if (size) {
-			ia_css_output1_config((struct sh_css_isp_output_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_output1() leave:\n");
-}
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_output(
-	const struct ia_css_binary *binary,
-	const struct ia_css_output_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_output() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.output.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.output.offset;
-		}
-		if (size) {
-			ia_css_output_config((struct sh_css_isp_output_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_output() leave:\n");
-}
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-#ifdef ISP2401
-
-void
-ia_css_configure_sc(
-	const struct ia_css_binary *binary,
-	const struct ia_css_sc_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_sc() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.sc.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.sc.offset;
-		}
-		if (size) {
-			ia_css_sc_config((struct sh_css_isp_sc_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_sc() leave:\n");
-}
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-#endif
-
-void
-ia_css_configure_raw(
-	const struct ia_css_binary *binary,
-	const struct ia_css_raw_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_raw() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.raw.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.raw.offset;
-		}
-		if (size) {
-			ia_css_raw_config((struct sh_css_isp_raw_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_raw() leave:\n");
-}
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_tnr(
-	const struct ia_css_binary *binary,
-	const struct ia_css_tnr_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_tnr() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.tnr.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.tnr.offset;
-		}
-		if (size) {
-			ia_css_tnr_config((struct sh_css_isp_tnr_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_tnr() leave:\n");
-}
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_ref(
-	const struct ia_css_binary *binary,
-	const struct ia_css_ref_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_ref() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.ref.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.ref.offset;
-		}
-		if (size) {
-			ia_css_ref_config((struct sh_css_isp_ref_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_ref() leave:\n");
-}
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_vf(
-	const struct ia_css_binary *binary,
-	const struct ia_css_vf_configuration *config_dmem)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_vf() enter:\n");
-
-	{
-		unsigned offset = 0;
-		unsigned size   = 0;
-		if (binary->info->mem_offsets.offsets.config) {
-			size   = binary->info->mem_offsets.offsets.config->dmem.vf.size;
-			offset = binary->info->mem_offsets.offsets.config->dmem.vf.offset;
-		}
-		if (size) {
-			ia_css_vf_config((struct sh_css_isp_vf_isp_config *)
-					&binary->mem_params.params[IA_CSS_PARAM_CLASS_CONFIG][IA_CSS_ISP_DMEM].address[offset],
-					config_dmem, size);		}
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_configure_vf() leave:\n");
-}
-

+ 0 - 189
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_configs.h

@@ -1,189 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-
-#ifdef IA_CSS_INCLUDE_CONFIGURATIONS
-#include "isp/kernels/crop/crop_1.0/ia_css_crop.host.h"
-#include "isp/kernels/dvs/dvs_1.0/ia_css_dvs.host.h"
-#include "isp/kernels/fpn/fpn_1.0/ia_css_fpn.host.h"
-#include "isp/kernels/ob/ob_1.0/ia_css_ob.host.h"
-#include "isp/kernels/output/output_1.0/ia_css_output.host.h"
-#include "isp/kernels/qplane/qplane_2/ia_css_qplane.host.h"
-#include "isp/kernels/raw/raw_1.0/ia_css_raw.host.h"
-#include "isp/kernels/ref/ref_1.0/ia_css_ref.host.h"
-#include "isp/kernels/s3a/s3a_1.0/ia_css_s3a.host.h"
-#ifdef ISP2401
-#include "isp/kernels/sc/sc_1.0/ia_css_sc.host.h"
-#endif
-#include "isp/kernels/tnr/tnr_1.0/ia_css_tnr.host.h"
-#include "isp/kernels/vf/vf_1.0/ia_css_vf.host.h"
-#include "isp/kernels/iterator/iterator_1.0/ia_css_iterator.host.h"
-#include "isp/kernels/copy_output/copy_output_1.0/ia_css_copy_output.host.h"
-#endif /* IA_CSS_INCLUDE_CONFIGURATIONS */
-/* Generated code: do not edit or commmit. */
-
-#ifndef _IA_CSS_ISP_CONFIG_H
-#define _IA_CSS_ISP_CONFIG_H
-
-/* Code generated by genparam/gencode.c:gen_param_enum() */
-
-enum ia_css_configuration_ids {
-	IA_CSS_ITERATOR_CONFIG_ID,
-	IA_CSS_COPY_OUTPUT_CONFIG_ID,
-	IA_CSS_CROP_CONFIG_ID,
-	IA_CSS_FPN_CONFIG_ID,
-	IA_CSS_DVS_CONFIG_ID,
-	IA_CSS_QPLANE_CONFIG_ID,
-	IA_CSS_OUTPUT0_CONFIG_ID,
-	IA_CSS_OUTPUT1_CONFIG_ID,
-	IA_CSS_OUTPUT_CONFIG_ID,
-#ifdef ISP2401
-	IA_CSS_SC_CONFIG_ID,
-#endif
-	IA_CSS_RAW_CONFIG_ID,
-	IA_CSS_TNR_CONFIG_ID,
-	IA_CSS_REF_CONFIG_ID,
-	IA_CSS_VF_CONFIG_ID,
-	IA_CSS_NUM_CONFIGURATION_IDS
-};
-
-/* Code generated by genparam/gencode.c:gen_param_offsets() */
-
-struct ia_css_config_memory_offsets {
-	struct {
-		struct ia_css_isp_parameter iterator;
-		struct ia_css_isp_parameter copy_output;
-		struct ia_css_isp_parameter crop;
-		struct ia_css_isp_parameter fpn;
-		struct ia_css_isp_parameter dvs;
-		struct ia_css_isp_parameter qplane;
-		struct ia_css_isp_parameter output0;
-		struct ia_css_isp_parameter output1;
-		struct ia_css_isp_parameter output;
-#ifdef ISP2401
-		struct ia_css_isp_parameter sc;
-#endif
-		struct ia_css_isp_parameter raw;
-		struct ia_css_isp_parameter tnr;
-		struct ia_css_isp_parameter ref;
-		struct ia_css_isp_parameter vf;
-	} dmem;
-};
-
-#if defined(IA_CSS_INCLUDE_CONFIGURATIONS)
-
-#include "ia_css_stream.h"   /* struct ia_css_stream */
-#include "ia_css_binary.h"   /* struct ia_css_binary */
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_iterator(
-	const struct ia_css_binary *binary,
-	const struct ia_css_iterator_configuration *config_dmem);
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_copy_output(
-	const struct ia_css_binary *binary,
-	const struct ia_css_copy_output_configuration *config_dmem);
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_crop(
-	const struct ia_css_binary *binary,
-	const struct ia_css_crop_configuration *config_dmem);
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_fpn(
-	const struct ia_css_binary *binary,
-	const struct ia_css_fpn_configuration *config_dmem);
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_dvs(
-	const struct ia_css_binary *binary,
-	const struct ia_css_dvs_configuration *config_dmem);
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_qplane(
-	const struct ia_css_binary *binary,
-	const struct ia_css_qplane_configuration *config_dmem);
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_output0(
-	const struct ia_css_binary *binary,
-	const struct ia_css_output0_configuration *config_dmem);
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_output1(
-	const struct ia_css_binary *binary,
-	const struct ia_css_output1_configuration *config_dmem);
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_output(
-	const struct ia_css_binary *binary,
-	const struct ia_css_output_configuration *config_dmem);
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-#ifdef ISP2401
-void
-ia_css_configure_sc(
-	const struct ia_css_binary *binary,
-	const struct ia_css_sc_configuration *config_dmem);
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-#endif
-void
-ia_css_configure_raw(
-	const struct ia_css_binary *binary,
-	const struct ia_css_raw_configuration *config_dmem);
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_tnr(
-	const struct ia_css_binary *binary,
-	const struct ia_css_tnr_configuration *config_dmem);
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_ref(
-	const struct ia_css_binary *binary,
-	const struct ia_css_ref_configuration *config_dmem);
-
-/* Code generated by genparam/genconfig.c:gen_configure_function() */
-
-void
-ia_css_configure_vf(
-	const struct ia_css_binary *binary,
-	const struct ia_css_vf_configuration *config_dmem);
-
-#endif /* IA_CSS_INCLUDE_CONFIGURATION */
-
-#endif /* _IA_CSS_ISP_CONFIG_H */

+ 0 - 3221
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_params.c

@@ -1,3221 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-#define IA_CSS_INCLUDE_PARAMETERS
-#include "sh_css_params.h"
-#include "isp/kernels/aa/aa_2/ia_css_aa2.host.h"
-#include "isp/kernels/anr/anr_1.0/ia_css_anr.host.h"
-#include "isp/kernels/anr/anr_2/ia_css_anr2.host.h"
-#include "isp/kernels/bh/bh_2/ia_css_bh.host.h"
-#include "isp/kernels/bnr/bnr_1.0/ia_css_bnr.host.h"
-#include "isp/kernels/bnr/bnr2_2/ia_css_bnr2_2.host.h"
-#include "isp/kernels/cnr/cnr_2/ia_css_cnr2.host.h"
-#include "isp/kernels/crop/crop_1.0/ia_css_crop.host.h"
-#include "isp/kernels/csc/csc_1.0/ia_css_csc.host.h"
-#include "isp/kernels/ctc/ctc_1.0/ia_css_ctc.host.h"
-#include "isp/kernels/ctc/ctc1_5/ia_css_ctc1_5.host.h"
-#include "isp/kernels/ctc/ctc2/ia_css_ctc2.host.h"
-#include "isp/kernels/de/de_1.0/ia_css_de.host.h"
-#include "isp/kernels/de/de_2/ia_css_de2.host.h"
-#include "isp/kernels/dp/dp_1.0/ia_css_dp.host.h"
-#include "isp/kernels/fixedbds/fixedbds_1.0/ia_css_fixedbds_param.h"
-#include "isp/kernels/fpn/fpn_1.0/ia_css_fpn.host.h"
-#include "isp/kernels/gc/gc_1.0/ia_css_gc.host.h"
-#include "isp/kernels/gc/gc_2/ia_css_gc2.host.h"
-#include "isp/kernels/macc/macc_1.0/ia_css_macc.host.h"
-#include "isp/kernels/macc/macc1_5/ia_css_macc1_5.host.h"
-#include "isp/kernels/ob/ob_1.0/ia_css_ob.host.h"
-#include "isp/kernels/ob/ob2/ia_css_ob2.host.h"
-#include "isp/kernels/output/output_1.0/ia_css_output.host.h"
-#include "isp/kernels/raw_aa_binning/raw_aa_binning_1.0/ia_css_raa.host.h"
-#include "isp/kernels/s3a/s3a_1.0/ia_css_s3a.host.h"
-#include "isp/kernels/sc/sc_1.0/ia_css_sc.host.h"
-#include "isp/kernels/sdis/sdis_1.0/ia_css_sdis.host.h"
-#include "isp/kernels/sdis/sdis_2/ia_css_sdis2.host.h"
-#include "isp/kernels/tnr/tnr_1.0/ia_css_tnr.host.h"
-#include "isp/kernels/uds/uds_1.0/ia_css_uds_param.h"
-#include "isp/kernels/wb/wb_1.0/ia_css_wb.host.h"
-#include "isp/kernels/xnr/xnr_1.0/ia_css_xnr.host.h"
-#include "isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.h"
-#include "isp/kernels/ynr/ynr_1.0/ia_css_ynr.host.h"
-#include "isp/kernels/ynr/ynr_2/ia_css_ynr2.host.h"
-#include "isp/kernels/fc/fc_1.0/ia_css_formats.host.h"
-#include "isp/kernels/tdf/tdf_1.0/ia_css_tdf.host.h"
-#include "isp/kernels/dpc2/ia_css_dpc2.host.h"
-#include "isp/kernels/eed1_8/ia_css_eed1_8.host.h"
-#include "isp/kernels/bnlm/ia_css_bnlm.host.h"
-#include "isp/kernels/conversion/conversion_1.0/ia_css_conversion.host.h"
-/* Generated code: do not edit or commmit. */
-
-#include "ia_css_pipeline.h"
-#include "ia_css_isp_params.h"
-#include "ia_css_debug.h"
-#include "assert_support.h"
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_aa(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.aa.size;
-	unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.aa.offset;
-
-	if (size) {
-		struct sh_css_isp_aa_params *t =  (struct sh_css_isp_aa_params *)
-				&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset];
-		t->strength = params->aa_config.strength;
-	}
-	params->isp_params_changed = true;
-	params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_anr(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.anr.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.anr.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_anr() enter:\n");
-
-			ia_css_anr_encode((struct sh_css_isp_anr_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->anr_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_anr() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_anr2(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->vmem.anr2.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->vmem.anr2.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_anr2() enter:\n");
-
-			ia_css_anr2_vmem_encode((struct ia_css_isp_anr2_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_VMEM].address[offset],
-					&params->anr_thres,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_VMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_anr2() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_bh(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.bh.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.bh.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_bh() enter:\n");
-
-			ia_css_bh_encode((struct sh_css_isp_bh_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->s3a_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_bh() leave:\n");
-		}
-
-	}
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->hmem0.bh.size;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_bh() enter:\n");
-
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_HMEM0] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_bh() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_cnr(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.cnr.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.cnr.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_cnr() enter:\n");
-
-			ia_css_cnr_encode((struct sh_css_isp_cnr_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->cnr_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_cnr() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_crop(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.crop.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.crop.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_crop() enter:\n");
-
-			ia_css_crop_encode((struct sh_css_isp_crop_isp_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->crop_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_crop() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_csc(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.csc.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.csc.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_csc() enter:\n");
-
-			ia_css_csc_encode((struct sh_css_isp_csc_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->cc_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_csc() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_dp(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.dp.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.dp.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_dp() enter:\n");
-
-			ia_css_dp_encode((struct sh_css_isp_dp_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->dp_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_dp() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_bnr(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.bnr.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.bnr.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_bnr() enter:\n");
-
-			ia_css_bnr_encode((struct sh_css_isp_bnr_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->nr_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_bnr() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_de(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.de.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.de.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_de() enter:\n");
-
-			ia_css_de_encode((struct sh_css_isp_de_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->de_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_de() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_ecd(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.ecd.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.ecd.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ecd() enter:\n");
-
-			ia_css_ecd_encode((struct sh_css_isp_ecd_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->ecd_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ecd() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_formats(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.formats.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.formats.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_formats() enter:\n");
-
-			ia_css_formats_encode((struct sh_css_isp_formats_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->formats_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_formats() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_fpn(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.fpn.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.fpn.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_fpn() enter:\n");
-
-			ia_css_fpn_encode((struct sh_css_isp_fpn_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->fpn_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_fpn() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_gc(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.gc.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.gc.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_gc() enter:\n");
-
-			ia_css_gc_encode((struct sh_css_isp_gc_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->gc_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_gc() leave:\n");
-		}
-
-	}
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->vamem1.gc.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->vamem1.gc.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_gc() enter:\n");
-
-			ia_css_gc_vamem_encode((struct sh_css_isp_gc_vamem_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_VAMEM1].address[offset],
-					&params->gc_table,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_VAMEM1] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_gc() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_ce(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.ce.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.ce.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ce() enter:\n");
-
-			ia_css_ce_encode((struct sh_css_isp_ce_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->ce_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ce() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_yuv2rgb(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.yuv2rgb.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.yuv2rgb.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_yuv2rgb() enter:\n");
-
-			ia_css_yuv2rgb_encode((struct sh_css_isp_csc_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->yuv2rgb_cc_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_yuv2rgb() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_rgb2yuv(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.rgb2yuv.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.rgb2yuv.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_rgb2yuv() enter:\n");
-
-			ia_css_rgb2yuv_encode((struct sh_css_isp_csc_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->rgb2yuv_cc_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_rgb2yuv() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_r_gamma(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->vamem0.r_gamma.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->vamem0.r_gamma.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_r_gamma() enter:\n");
-
-			ia_css_r_gamma_vamem_encode((struct sh_css_isp_rgb_gamma_vamem_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_VAMEM0].address[offset],
-					&params->r_gamma_table,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_VAMEM0] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_r_gamma() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_g_gamma(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->vamem1.g_gamma.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->vamem1.g_gamma.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_g_gamma() enter:\n");
-
-			ia_css_g_gamma_vamem_encode((struct sh_css_isp_rgb_gamma_vamem_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_VAMEM1].address[offset],
-					&params->g_gamma_table,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_VAMEM1] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_g_gamma() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_b_gamma(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->vamem2.b_gamma.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->vamem2.b_gamma.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_b_gamma() enter:\n");
-
-			ia_css_b_gamma_vamem_encode((struct sh_css_isp_rgb_gamma_vamem_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_VAMEM2].address[offset],
-					&params->b_gamma_table,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_VAMEM2] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_b_gamma() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_uds(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.uds.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.uds.offset;
-
-		if (size) {
-			struct sh_css_sp_uds_params *p;
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_uds() enter:\n");
-
-			p = (struct sh_css_sp_uds_params *)
-				&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset];
-			p->crop_pos = params->uds_config.crop_pos;
-			p->uds = params->uds_config.uds;
-
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_uds() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_raa(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.raa.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.raa.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_raa() enter:\n");
-
-			ia_css_raa_encode((struct sh_css_isp_aa_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->raa_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_raa() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_s3a(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.s3a.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.s3a.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_s3a() enter:\n");
-
-			ia_css_s3a_encode((struct sh_css_isp_s3a_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->s3a_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_s3a() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_ob(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.ob.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.ob.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ob() enter:\n");
-
-			ia_css_ob_encode((struct sh_css_isp_ob_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->ob_config,
-&params->stream_configs.ob, size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ob() leave:\n");
-		}
-
-	}
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->vmem.ob.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->vmem.ob.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ob() enter:\n");
-
-			ia_css_ob_vmem_encode((struct sh_css_isp_ob_vmem_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_VMEM].address[offset],
-					&params->ob_config,
-&params->stream_configs.ob, size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_VMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ob() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_output(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.output.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.output.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_output() enter:\n");
-
-			ia_css_output_encode((struct sh_css_isp_output_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->output_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_output() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_sc(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.sc.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.sc.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sc() enter:\n");
-
-			ia_css_sc_encode((struct sh_css_isp_sc_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->sc_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sc() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_bds(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.bds.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.bds.offset;
-
-		if (size) {
-			struct sh_css_isp_bds_params *p;
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_bds() enter:\n");
-
-			p = (struct sh_css_isp_bds_params *)
-				&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset];
-			p->baf_strength = params->bds_config.strength;
-
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_bds() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_tnr(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.tnr.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.tnr.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_tnr() enter:\n");
-
-			ia_css_tnr_encode((struct sh_css_isp_tnr_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->tnr_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_tnr() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_macc(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.macc.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.macc.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_macc() enter:\n");
-
-			ia_css_macc_encode((struct sh_css_isp_macc_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->macc_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_macc() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_sdis_horicoef(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->vmem.sdis_horicoef.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->vmem.sdis_horicoef.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis_horicoef() enter:\n");
-
-			ia_css_sdis_horicoef_vmem_encode((struct sh_css_isp_sdis_hori_coef_tbl *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_VMEM].address[offset],
-					&params->dvs_coefs,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_VMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis_horicoef() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_sdis_vertcoef(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->vmem.sdis_vertcoef.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->vmem.sdis_vertcoef.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis_vertcoef() enter:\n");
-
-			ia_css_sdis_vertcoef_vmem_encode((struct sh_css_isp_sdis_vert_coef_tbl *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_VMEM].address[offset],
-					&params->dvs_coefs,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_VMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis_vertcoef() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_sdis_horiproj(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.sdis_horiproj.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.sdis_horiproj.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis_horiproj() enter:\n");
-
-			ia_css_sdis_horiproj_encode((struct sh_css_isp_sdis_hori_proj_tbl *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->dvs_coefs,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis_horiproj() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_sdis_vertproj(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.sdis_vertproj.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.sdis_vertproj.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis_vertproj() enter:\n");
-
-			ia_css_sdis_vertproj_encode((struct sh_css_isp_sdis_vert_proj_tbl *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->dvs_coefs,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis_vertproj() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_sdis2_horicoef(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->vmem.sdis2_horicoef.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->vmem.sdis2_horicoef.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis2_horicoef() enter:\n");
-
-			ia_css_sdis2_horicoef_vmem_encode((struct sh_css_isp_sdis_hori_coef_tbl *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_VMEM].address[offset],
-					&params->dvs2_coefs,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_VMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis2_horicoef() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_sdis2_vertcoef(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->vmem.sdis2_vertcoef.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->vmem.sdis2_vertcoef.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis2_vertcoef() enter:\n");
-
-			ia_css_sdis2_vertcoef_vmem_encode((struct sh_css_isp_sdis_vert_coef_tbl *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_VMEM].address[offset],
-					&params->dvs2_coefs,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_VMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis2_vertcoef() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_sdis2_horiproj(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.sdis2_horiproj.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.sdis2_horiproj.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis2_horiproj() enter:\n");
-
-			ia_css_sdis2_horiproj_encode((struct sh_css_isp_sdis_hori_proj_tbl *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->dvs2_coefs,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis2_horiproj() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_sdis2_vertproj(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.sdis2_vertproj.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.sdis2_vertproj.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis2_vertproj() enter:\n");
-
-			ia_css_sdis2_vertproj_encode((struct sh_css_isp_sdis_vert_proj_tbl *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->dvs2_coefs,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_sdis2_vertproj() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_wb(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.wb.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.wb.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_wb() enter:\n");
-
-			ia_css_wb_encode((struct sh_css_isp_wb_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->wb_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_wb() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_nr(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.nr.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.nr.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_nr() enter:\n");
-
-			ia_css_nr_encode((struct sh_css_isp_ynr_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->nr_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_nr() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_yee(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.yee.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.yee.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_yee() enter:\n");
-
-			ia_css_yee_encode((struct sh_css_isp_yee_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->yee_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_yee() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_ynr(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.ynr.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.ynr.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ynr() enter:\n");
-
-			ia_css_ynr_encode((struct sh_css_isp_yee2_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->ynr_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ynr() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_fc(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.fc.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.fc.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_fc() enter:\n");
-
-			ia_css_fc_encode((struct sh_css_isp_fc_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->fc_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_fc() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_ctc(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.ctc.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.ctc.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ctc() enter:\n");
-
-			ia_css_ctc_encode((struct sh_css_isp_ctc_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->ctc_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ctc() leave:\n");
-		}
-
-	}
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->vamem0.ctc.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->vamem0.ctc.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ctc() enter:\n");
-
-			ia_css_ctc_vamem_encode((struct sh_css_isp_ctc_vamem_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_VAMEM0].address[offset],
-					&params->ctc_table,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_VAMEM0] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_ctc() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_xnr_table(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->vamem1.xnr_table.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->vamem1.xnr_table.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_xnr_table() enter:\n");
-
-			ia_css_xnr_table_vamem_encode((struct sh_css_isp_xnr_vamem_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_VAMEM1].address[offset],
-					&params->xnr_table,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_VAMEM1] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_xnr_table() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_xnr(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.xnr.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.xnr.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_xnr() enter:\n");
-
-			ia_css_xnr_encode((struct sh_css_isp_xnr_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->xnr_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_xnr() leave:\n");
-		}
-
-	}
-}
-
-/* Code generated by genparam/gencode.c:gen_process_function() */
-
-static void
-ia_css_process_xnr3(
-	unsigned pipe_id,
-	const struct ia_css_pipeline_stage *stage,
-	struct ia_css_isp_parameters *params)
-{
-	assert(params != NULL);
-
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->dmem.xnr3.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->dmem.xnr3.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_xnr3() enter:\n");
-
-			ia_css_xnr3_encode((struct sh_css_isp_xnr3_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_DMEM].address[offset],
-					&params->xnr3_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_DMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_xnr3() leave:\n");
-		}
-
-	}
-#ifdef ISP2401
-	{
-		unsigned size   = stage->binary->info->mem_offsets.offsets.param->vmem.xnr3.size;
-
-		unsigned offset = stage->binary->info->mem_offsets.offsets.param->vmem.xnr3.offset;
-
-		if (size) {
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_xnr3() enter:\n");
-
-			ia_css_xnr3_vmem_encode((struct sh_css_isp_xnr3_vmem_params *)
-					&stage->binary->mem_params.params[IA_CSS_PARAM_CLASS_PARAM][IA_CSS_ISP_VMEM].address[offset],
-					&params->xnr3_config,
-size);
-			params->isp_params_changed = true;
-			params->isp_mem_params_changed[pipe_id][stage->stage_num][IA_CSS_ISP_VMEM] = true;
-
-			ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_process_xnr3() leave:\n");
-		}
-
-	}
-#endif
-}
-
-/* Code generated by genparam/gencode.c:gen_param_process_table() */
-
-void (* ia_css_kernel_process_param[IA_CSS_NUM_PARAMETER_IDS])(
-			unsigned pipe_id,
-			const struct ia_css_pipeline_stage *stage,
-			struct ia_css_isp_parameters *params) = {
-	ia_css_process_aa,
-	ia_css_process_anr,
-	ia_css_process_anr2,
-	ia_css_process_bh,
-	ia_css_process_cnr,
-	ia_css_process_crop,
-	ia_css_process_csc,
-	ia_css_process_dp,
-	ia_css_process_bnr,
-	ia_css_process_de,
-	ia_css_process_ecd,
-	ia_css_process_formats,
-	ia_css_process_fpn,
-	ia_css_process_gc,
-	ia_css_process_ce,
-	ia_css_process_yuv2rgb,
-	ia_css_process_rgb2yuv,
-	ia_css_process_r_gamma,
-	ia_css_process_g_gamma,
-	ia_css_process_b_gamma,
-	ia_css_process_uds,
-	ia_css_process_raa,
-	ia_css_process_s3a,
-	ia_css_process_ob,
-	ia_css_process_output,
-	ia_css_process_sc,
-	ia_css_process_bds,
-	ia_css_process_tnr,
-	ia_css_process_macc,
-	ia_css_process_sdis_horicoef,
-	ia_css_process_sdis_vertcoef,
-	ia_css_process_sdis_horiproj,
-	ia_css_process_sdis_vertproj,
-	ia_css_process_sdis2_horicoef,
-	ia_css_process_sdis2_vertcoef,
-	ia_css_process_sdis2_horiproj,
-	ia_css_process_sdis2_vertproj,
-	ia_css_process_wb,
-	ia_css_process_nr,
-	ia_css_process_yee,
-	ia_css_process_ynr,
-	ia_css_process_fc,
-	ia_css_process_ctc,
-	ia_css_process_xnr_table,
-	ia_css_process_xnr,
-	ia_css_process_xnr3,
-};
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_dp_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_dp_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_dp_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->dp_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_dp_config() leave\n");
-	ia_css_dp_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_dp_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dp_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_dp_config() enter:\n");
-	ia_css_dp_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->dp_config = *config;
-	params->config_changed[IA_CSS_DP_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_DP_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_dp_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_wb_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_wb_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_wb_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->wb_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_wb_config() leave\n");
-	ia_css_wb_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_wb_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_wb_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_wb_config() enter:\n");
-	ia_css_wb_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->wb_config = *config;
-	params->config_changed[IA_CSS_WB_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_WB_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_wb_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_tnr_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_tnr_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_tnr_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->tnr_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_tnr_config() leave\n");
-	ia_css_tnr_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_tnr_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_tnr_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_tnr_config() enter:\n");
-	ia_css_tnr_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->tnr_config = *config;
-	params->config_changed[IA_CSS_TNR_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_TNR_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_tnr_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_ob_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_ob_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_ob_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->ob_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_ob_config() leave\n");
-	ia_css_ob_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_ob_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_ob_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_ob_config() enter:\n");
-	ia_css_ob_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->ob_config = *config;
-	params->config_changed[IA_CSS_OB_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_OB_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_ob_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_de_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_de_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_de_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->de_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_de_config() leave\n");
-	ia_css_de_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_de_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_de_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_de_config() enter:\n");
-	ia_css_de_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->de_config = *config;
-	params->config_changed[IA_CSS_DE_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_DE_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_de_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_anr_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_anr_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_anr_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->anr_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_anr_config() leave\n");
-	ia_css_anr_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_anr_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_anr_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_anr_config() enter:\n");
-	ia_css_anr_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->anr_config = *config;
-	params->config_changed[IA_CSS_ANR_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_ANR_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_anr_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_anr2_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_anr_thres *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_anr2_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->anr_thres;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_anr2_config() leave\n");
-	ia_css_anr2_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_anr2_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_anr_thres *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_anr2_config() enter:\n");
-	ia_css_anr2_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->anr_thres = *config;
-	params->config_changed[IA_CSS_ANR2_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_ANR2_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_anr2_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_ce_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_ce_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_ce_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->ce_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_ce_config() leave\n");
-	ia_css_ce_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_ce_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_ce_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_ce_config() enter:\n");
-	ia_css_ce_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->ce_config = *config;
-	params->config_changed[IA_CSS_CE_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_CE_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_ce_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_ecd_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_ecd_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_ecd_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->ecd_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_ecd_config() leave\n");
-	ia_css_ecd_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_ecd_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_ecd_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_ecd_config() enter:\n");
-	ia_css_ecd_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->ecd_config = *config;
-	params->config_changed[IA_CSS_ECD_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_ECD_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_ecd_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_ynr_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_ynr_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_ynr_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->ynr_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_ynr_config() leave\n");
-	ia_css_ynr_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_ynr_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_ynr_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_ynr_config() enter:\n");
-	ia_css_ynr_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->ynr_config = *config;
-	params->config_changed[IA_CSS_YNR_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_YNR_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_ynr_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_fc_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_fc_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_fc_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->fc_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_fc_config() leave\n");
-	ia_css_fc_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_fc_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_fc_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_fc_config() enter:\n");
-	ia_css_fc_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->fc_config = *config;
-	params->config_changed[IA_CSS_FC_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_FC_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_fc_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_cnr_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_cnr_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_cnr_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->cnr_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_cnr_config() leave\n");
-	ia_css_cnr_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_cnr_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_cnr_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_cnr_config() enter:\n");
-	ia_css_cnr_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->cnr_config = *config;
-	params->config_changed[IA_CSS_CNR_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_CNR_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_cnr_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_macc_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_macc_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_macc_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->macc_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_macc_config() leave\n");
-	ia_css_macc_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_macc_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_macc_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_macc_config() enter:\n");
-	ia_css_macc_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->macc_config = *config;
-	params->config_changed[IA_CSS_MACC_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_MACC_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_macc_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_ctc_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_ctc_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_ctc_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->ctc_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_ctc_config() leave\n");
-	ia_css_ctc_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_ctc_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_ctc_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_ctc_config() enter:\n");
-	ia_css_ctc_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->ctc_config = *config;
-	params->config_changed[IA_CSS_CTC_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_CTC_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_ctc_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_aa_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_aa_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_aa_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->aa_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_aa_config() leave\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_aa_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_aa_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_aa_config() enter:\n");
-	params->aa_config = *config;
-	params->config_changed[IA_CSS_AA_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_AA_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_aa_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_yuv2rgb_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_cc_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_yuv2rgb_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->yuv2rgb_cc_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_yuv2rgb_config() leave\n");
-	ia_css_yuv2rgb_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_yuv2rgb_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_cc_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_yuv2rgb_config() enter:\n");
-	ia_css_yuv2rgb_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->yuv2rgb_cc_config = *config;
-	params->config_changed[IA_CSS_YUV2RGB_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_YUV2RGB_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_yuv2rgb_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_rgb2yuv_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_cc_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_rgb2yuv_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->rgb2yuv_cc_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_rgb2yuv_config() leave\n");
-	ia_css_rgb2yuv_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_rgb2yuv_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_cc_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_rgb2yuv_config() enter:\n");
-	ia_css_rgb2yuv_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->rgb2yuv_cc_config = *config;
-	params->config_changed[IA_CSS_RGB2YUV_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_RGB2YUV_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_rgb2yuv_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_csc_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_cc_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_csc_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->cc_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_csc_config() leave\n");
-	ia_css_csc_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_csc_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_cc_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_csc_config() enter:\n");
-	ia_css_csc_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->cc_config = *config;
-	params->config_changed[IA_CSS_CSC_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_CSC_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_csc_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_nr_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_nr_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_nr_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->nr_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_nr_config() leave\n");
-	ia_css_nr_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_nr_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_nr_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_nr_config() enter:\n");
-	ia_css_nr_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->nr_config = *config;
-	params->config_changed[IA_CSS_BNR_ID] = true;
-	params->config_changed[IA_CSS_NR_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_NR_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_nr_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_gc_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_gc_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_gc_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->gc_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_gc_config() leave\n");
-	ia_css_gc_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_gc_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_gc_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_gc_config() enter:\n");
-	ia_css_gc_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->gc_config = *config;
-	params->config_changed[IA_CSS_GC_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_GC_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_gc_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_sdis_horicoef_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_dvs_coefficients *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis_horicoef_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->dvs_coefs;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis_horicoef_config() leave\n");
-	ia_css_sdis_horicoef_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis_horicoef_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs_coefficients *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_sdis_horicoef_config() enter:\n");
-	ia_css_sdis_horicoef_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->dvs_coefs = *config;
-	params->config_changed[IA_CSS_SDIS_HORICOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS_VERTCOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS_HORIPROJ_ID] = true;
-	params->config_changed[IA_CSS_SDIS_VERTPROJ_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_SDIS_HORICOEF_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_sdis_horicoef_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_sdis_vertcoef_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_dvs_coefficients *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis_vertcoef_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->dvs_coefs;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis_vertcoef_config() leave\n");
-	ia_css_sdis_vertcoef_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis_vertcoef_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs_coefficients *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_sdis_vertcoef_config() enter:\n");
-	ia_css_sdis_vertcoef_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->dvs_coefs = *config;
-	params->config_changed[IA_CSS_SDIS_HORICOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS_VERTCOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS_HORIPROJ_ID] = true;
-	params->config_changed[IA_CSS_SDIS_VERTPROJ_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_SDIS_VERTCOEF_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_sdis_vertcoef_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_sdis_horiproj_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_dvs_coefficients *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis_horiproj_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->dvs_coefs;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis_horiproj_config() leave\n");
-	ia_css_sdis_horiproj_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis_horiproj_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs_coefficients *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_sdis_horiproj_config() enter:\n");
-	ia_css_sdis_horiproj_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->dvs_coefs = *config;
-	params->config_changed[IA_CSS_SDIS_HORICOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS_VERTCOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS_HORIPROJ_ID] = true;
-	params->config_changed[IA_CSS_SDIS_VERTPROJ_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_SDIS_HORIPROJ_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_sdis_horiproj_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_sdis_vertproj_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_dvs_coefficients *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis_vertproj_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->dvs_coefs;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis_vertproj_config() leave\n");
-	ia_css_sdis_vertproj_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis_vertproj_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs_coefficients *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_sdis_vertproj_config() enter:\n");
-	ia_css_sdis_vertproj_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->dvs_coefs = *config;
-	params->config_changed[IA_CSS_SDIS_HORICOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS_VERTCOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS_HORIPROJ_ID] = true;
-	params->config_changed[IA_CSS_SDIS_VERTPROJ_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_SDIS_VERTPROJ_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_sdis_vertproj_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_sdis2_horicoef_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_dvs2_coefficients *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis2_horicoef_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->dvs2_coefs;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis2_horicoef_config() leave\n");
-	ia_css_sdis2_horicoef_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis2_horicoef_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs2_coefficients *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_sdis2_horicoef_config() enter:\n");
-	ia_css_sdis2_horicoef_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->dvs2_coefs = *config;
-	params->config_changed[IA_CSS_SDIS2_HORICOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS2_VERTCOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS2_HORIPROJ_ID] = true;
-	params->config_changed[IA_CSS_SDIS2_VERTPROJ_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_SDIS2_HORICOEF_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_sdis2_horicoef_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_sdis2_vertcoef_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_dvs2_coefficients *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis2_vertcoef_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->dvs2_coefs;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis2_vertcoef_config() leave\n");
-	ia_css_sdis2_vertcoef_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis2_vertcoef_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs2_coefficients *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_sdis2_vertcoef_config() enter:\n");
-	ia_css_sdis2_vertcoef_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->dvs2_coefs = *config;
-	params->config_changed[IA_CSS_SDIS2_HORICOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS2_VERTCOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS2_HORIPROJ_ID] = true;
-	params->config_changed[IA_CSS_SDIS2_VERTPROJ_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_SDIS2_VERTCOEF_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_sdis2_vertcoef_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_sdis2_horiproj_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_dvs2_coefficients *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis2_horiproj_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->dvs2_coefs;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis2_horiproj_config() leave\n");
-	ia_css_sdis2_horiproj_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis2_horiproj_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs2_coefficients *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_sdis2_horiproj_config() enter:\n");
-	ia_css_sdis2_horiproj_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->dvs2_coefs = *config;
-	params->config_changed[IA_CSS_SDIS2_HORICOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS2_VERTCOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS2_HORIPROJ_ID] = true;
-	params->config_changed[IA_CSS_SDIS2_VERTPROJ_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_SDIS2_HORIPROJ_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_sdis2_horiproj_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_sdis2_vertproj_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_dvs2_coefficients *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis2_vertproj_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->dvs2_coefs;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_sdis2_vertproj_config() leave\n");
-	ia_css_sdis2_vertproj_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis2_vertproj_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs2_coefficients *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_sdis2_vertproj_config() enter:\n");
-	ia_css_sdis2_vertproj_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->dvs2_coefs = *config;
-	params->config_changed[IA_CSS_SDIS2_HORICOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS2_VERTCOEF_ID] = true;
-	params->config_changed[IA_CSS_SDIS2_HORIPROJ_ID] = true;
-	params->config_changed[IA_CSS_SDIS2_VERTPROJ_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_SDIS2_VERTPROJ_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_sdis2_vertproj_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_r_gamma_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_rgb_gamma_table *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_r_gamma_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->r_gamma_table;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_r_gamma_config() leave\n");
-	ia_css_r_gamma_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_r_gamma_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_rgb_gamma_table *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_r_gamma_config() enter:\n");
-	ia_css_r_gamma_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->r_gamma_table = *config;
-	params->config_changed[IA_CSS_R_GAMMA_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_R_GAMMA_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_r_gamma_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_g_gamma_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_rgb_gamma_table *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_g_gamma_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->g_gamma_table;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_g_gamma_config() leave\n");
-	ia_css_g_gamma_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_g_gamma_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_rgb_gamma_table *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_g_gamma_config() enter:\n");
-	ia_css_g_gamma_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->g_gamma_table = *config;
-	params->config_changed[IA_CSS_G_GAMMA_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_G_GAMMA_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_g_gamma_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_b_gamma_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_rgb_gamma_table *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_b_gamma_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->b_gamma_table;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_b_gamma_config() leave\n");
-	ia_css_b_gamma_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_b_gamma_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_rgb_gamma_table *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_b_gamma_config() enter:\n");
-	ia_css_b_gamma_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->b_gamma_table = *config;
-	params->config_changed[IA_CSS_B_GAMMA_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_B_GAMMA_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_b_gamma_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_xnr_table_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_xnr_table *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_xnr_table_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->xnr_table;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_xnr_table_config() leave\n");
-	ia_css_xnr_table_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_xnr_table_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_xnr_table *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_xnr_table_config() enter:\n");
-	ia_css_xnr_table_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->xnr_table = *config;
-	params->config_changed[IA_CSS_XNR_TABLE_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_XNR_TABLE_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_xnr_table_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_formats_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_formats_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_formats_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->formats_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_formats_config() leave\n");
-	ia_css_formats_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_formats_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_formats_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_formats_config() enter:\n");
-	ia_css_formats_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->formats_config = *config;
-	params->config_changed[IA_CSS_FORMATS_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_FORMATS_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_formats_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_xnr_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_xnr_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_xnr_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->xnr_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_xnr_config() leave\n");
-	ia_css_xnr_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_xnr_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_xnr_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_xnr_config() enter:\n");
-	ia_css_xnr_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->xnr_config = *config;
-	params->config_changed[IA_CSS_XNR_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_XNR_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_xnr_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_xnr3_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_xnr3_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_xnr3_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->xnr3_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_xnr3_config() leave\n");
-	ia_css_xnr3_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_xnr3_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_xnr3_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_xnr3_config() enter:\n");
-	ia_css_xnr3_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->xnr3_config = *config;
-	params->config_changed[IA_CSS_XNR3_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_XNR3_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_xnr3_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_s3a_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_3a_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_s3a_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->s3a_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_s3a_config() leave\n");
-	ia_css_s3a_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_s3a_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_3a_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_s3a_config() enter:\n");
-	ia_css_s3a_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->s3a_config = *config;
-	params->config_changed[IA_CSS_BH_ID] = true;
-	params->config_changed[IA_CSS_S3A_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_S3A_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_s3a_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_get_function() */
-
-static void
-ia_css_get_output_config(const struct ia_css_isp_parameters *params,
-			struct ia_css_output_config *config){
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_output_config() enter: "
-		"config=%p\n",config);
-
-	*config = params->output_config;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_get_output_config() leave\n");
-	ia_css_output_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-}
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_output_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_output_config *config)
-{
-	if (config == NULL)
-		return;
-
-	assert(params != NULL);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_set_output_config() enter:\n");
-	ia_css_output_debug_dtrace(config, IA_CSS_DEBUG_TRACE);
-	params->output_config = *config;
-	params->config_changed[IA_CSS_OUTPUT_ID] = true;
-#ifndef ISP2401
-	params->config_changed[IA_CSS_OUTPUT_ID] = true;
-
-#endif
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_set_output_config() leave: "
-		"return_void\n");
-}
-
-/* Code generated by genparam/gencode.c:gen_global_access_function() */
-
-void
-ia_css_get_configs(struct ia_css_isp_parameters *params,
-		const struct ia_css_isp_config *config)
-{
-	ia_css_get_dp_config(params, config->dp_config);
-	ia_css_get_wb_config(params, config->wb_config);
-	ia_css_get_tnr_config(params, config->tnr_config);
-	ia_css_get_ob_config(params, config->ob_config);
-	ia_css_get_de_config(params, config->de_config);
-	ia_css_get_anr_config(params, config->anr_config);
-	ia_css_get_anr2_config(params, config->anr_thres);
-	ia_css_get_ce_config(params, config->ce_config);
-	ia_css_get_ecd_config(params, config->ecd_config);
-	ia_css_get_ynr_config(params, config->ynr_config);
-	ia_css_get_fc_config(params, config->fc_config);
-	ia_css_get_cnr_config(params, config->cnr_config);
-	ia_css_get_macc_config(params, config->macc_config);
-	ia_css_get_ctc_config(params, config->ctc_config);
-	ia_css_get_aa_config(params, config->aa_config);
-	ia_css_get_yuv2rgb_config(params, config->yuv2rgb_cc_config);
-	ia_css_get_rgb2yuv_config(params, config->rgb2yuv_cc_config);
-	ia_css_get_csc_config(params, config->cc_config);
-	ia_css_get_nr_config(params, config->nr_config);
-	ia_css_get_gc_config(params, config->gc_config);
-	ia_css_get_sdis_horicoef_config(params, config->dvs_coefs);
-	ia_css_get_sdis_vertcoef_config(params, config->dvs_coefs);
-	ia_css_get_sdis_horiproj_config(params, config->dvs_coefs);
-	ia_css_get_sdis_vertproj_config(params, config->dvs_coefs);
-	ia_css_get_sdis2_horicoef_config(params, config->dvs2_coefs);
-	ia_css_get_sdis2_vertcoef_config(params, config->dvs2_coefs);
-	ia_css_get_sdis2_horiproj_config(params, config->dvs2_coefs);
-	ia_css_get_sdis2_vertproj_config(params, config->dvs2_coefs);
-	ia_css_get_r_gamma_config(params, config->r_gamma_table);
-	ia_css_get_g_gamma_config(params, config->g_gamma_table);
-	ia_css_get_b_gamma_config(params, config->b_gamma_table);
-	ia_css_get_xnr_table_config(params, config->xnr_table);
-	ia_css_get_formats_config(params, config->formats_config);
-	ia_css_get_xnr_config(params, config->xnr_config);
-	ia_css_get_xnr3_config(params, config->xnr3_config);
-	ia_css_get_s3a_config(params, config->s3a_config);
-	ia_css_get_output_config(params, config->output_config);
-}
-
-/* Code generated by genparam/gencode.c:gen_global_access_function() */
-
-void
-ia_css_set_configs(struct ia_css_isp_parameters *params,
-		const struct ia_css_isp_config *config)
-{
-	ia_css_set_dp_config(params, config->dp_config);
-	ia_css_set_wb_config(params, config->wb_config);
-	ia_css_set_tnr_config(params, config->tnr_config);
-	ia_css_set_ob_config(params, config->ob_config);
-	ia_css_set_de_config(params, config->de_config);
-	ia_css_set_anr_config(params, config->anr_config);
-	ia_css_set_anr2_config(params, config->anr_thres);
-	ia_css_set_ce_config(params, config->ce_config);
-	ia_css_set_ecd_config(params, config->ecd_config);
-	ia_css_set_ynr_config(params, config->ynr_config);
-	ia_css_set_fc_config(params, config->fc_config);
-	ia_css_set_cnr_config(params, config->cnr_config);
-	ia_css_set_macc_config(params, config->macc_config);
-	ia_css_set_ctc_config(params, config->ctc_config);
-	ia_css_set_aa_config(params, config->aa_config);
-	ia_css_set_yuv2rgb_config(params, config->yuv2rgb_cc_config);
-	ia_css_set_rgb2yuv_config(params, config->rgb2yuv_cc_config);
-	ia_css_set_csc_config(params, config->cc_config);
-	ia_css_set_nr_config(params, config->nr_config);
-	ia_css_set_gc_config(params, config->gc_config);
-	ia_css_set_sdis_horicoef_config(params, config->dvs_coefs);
-	ia_css_set_sdis_vertcoef_config(params, config->dvs_coefs);
-	ia_css_set_sdis_horiproj_config(params, config->dvs_coefs);
-	ia_css_set_sdis_vertproj_config(params, config->dvs_coefs);
-	ia_css_set_sdis2_horicoef_config(params, config->dvs2_coefs);
-	ia_css_set_sdis2_vertcoef_config(params, config->dvs2_coefs);
-	ia_css_set_sdis2_horiproj_config(params, config->dvs2_coefs);
-	ia_css_set_sdis2_vertproj_config(params, config->dvs2_coefs);
-	ia_css_set_r_gamma_config(params, config->r_gamma_table);
-	ia_css_set_g_gamma_config(params, config->g_gamma_table);
-	ia_css_set_b_gamma_config(params, config->b_gamma_table);
-	ia_css_set_xnr_table_config(params, config->xnr_table);
-	ia_css_set_formats_config(params, config->formats_config);
-	ia_css_set_xnr_config(params, config->xnr_config);
-	ia_css_set_xnr3_config(params, config->xnr3_config);
-	ia_css_set_s3a_config(params, config->s3a_config);
-	ia_css_set_output_config(params, config->output_config);
-}
-

+ 0 - 399
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_params.h

@@ -1,399 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-
-/* Generated code: do not edit or commmit. */
-
-#ifndef _IA_CSS_ISP_PARAM_H
-#define _IA_CSS_ISP_PARAM_H
-
-/* Code generated by genparam/gencode.c:gen_param_enum() */
-
-enum ia_css_parameter_ids {
-	IA_CSS_AA_ID,
-	IA_CSS_ANR_ID,
-	IA_CSS_ANR2_ID,
-	IA_CSS_BH_ID,
-	IA_CSS_CNR_ID,
-	IA_CSS_CROP_ID,
-	IA_CSS_CSC_ID,
-	IA_CSS_DP_ID,
-	IA_CSS_BNR_ID,
-	IA_CSS_DE_ID,
-	IA_CSS_ECD_ID,
-	IA_CSS_FORMATS_ID,
-	IA_CSS_FPN_ID,
-	IA_CSS_GC_ID,
-	IA_CSS_CE_ID,
-	IA_CSS_YUV2RGB_ID,
-	IA_CSS_RGB2YUV_ID,
-	IA_CSS_R_GAMMA_ID,
-	IA_CSS_G_GAMMA_ID,
-	IA_CSS_B_GAMMA_ID,
-	IA_CSS_UDS_ID,
-	IA_CSS_RAA_ID,
-	IA_CSS_S3A_ID,
-	IA_CSS_OB_ID,
-	IA_CSS_OUTPUT_ID,
-	IA_CSS_SC_ID,
-	IA_CSS_BDS_ID,
-	IA_CSS_TNR_ID,
-	IA_CSS_MACC_ID,
-	IA_CSS_SDIS_HORICOEF_ID,
-	IA_CSS_SDIS_VERTCOEF_ID,
-	IA_CSS_SDIS_HORIPROJ_ID,
-	IA_CSS_SDIS_VERTPROJ_ID,
-	IA_CSS_SDIS2_HORICOEF_ID,
-	IA_CSS_SDIS2_VERTCOEF_ID,
-	IA_CSS_SDIS2_HORIPROJ_ID,
-	IA_CSS_SDIS2_VERTPROJ_ID,
-	IA_CSS_WB_ID,
-	IA_CSS_NR_ID,
-	IA_CSS_YEE_ID,
-	IA_CSS_YNR_ID,
-	IA_CSS_FC_ID,
-	IA_CSS_CTC_ID,
-	IA_CSS_XNR_TABLE_ID,
-	IA_CSS_XNR_ID,
-	IA_CSS_XNR3_ID,
-	IA_CSS_NUM_PARAMETER_IDS
-};
-
-/* Code generated by genparam/gencode.c:gen_param_offsets() */
-
-struct ia_css_memory_offsets {
-	struct {
-		struct ia_css_isp_parameter aa;
-		struct ia_css_isp_parameter anr;
-		struct ia_css_isp_parameter bh;
-		struct ia_css_isp_parameter cnr;
-		struct ia_css_isp_parameter crop;
-		struct ia_css_isp_parameter csc;
-		struct ia_css_isp_parameter dp;
-		struct ia_css_isp_parameter bnr;
-		struct ia_css_isp_parameter de;
-		struct ia_css_isp_parameter ecd;
-		struct ia_css_isp_parameter formats;
-		struct ia_css_isp_parameter fpn;
-		struct ia_css_isp_parameter gc;
-		struct ia_css_isp_parameter ce;
-		struct ia_css_isp_parameter yuv2rgb;
-		struct ia_css_isp_parameter rgb2yuv;
-		struct ia_css_isp_parameter uds;
-		struct ia_css_isp_parameter raa;
-		struct ia_css_isp_parameter s3a;
-		struct ia_css_isp_parameter ob;
-		struct ia_css_isp_parameter output;
-		struct ia_css_isp_parameter sc;
-		struct ia_css_isp_parameter bds;
-		struct ia_css_isp_parameter tnr;
-		struct ia_css_isp_parameter macc;
-		struct ia_css_isp_parameter sdis_horiproj;
-		struct ia_css_isp_parameter sdis_vertproj;
-		struct ia_css_isp_parameter sdis2_horiproj;
-		struct ia_css_isp_parameter sdis2_vertproj;
-		struct ia_css_isp_parameter wb;
-		struct ia_css_isp_parameter nr;
-		struct ia_css_isp_parameter yee;
-		struct ia_css_isp_parameter ynr;
-		struct ia_css_isp_parameter fc;
-		struct ia_css_isp_parameter ctc;
-		struct ia_css_isp_parameter xnr;
-		struct ia_css_isp_parameter xnr3;
-		struct ia_css_isp_parameter get;
-		struct ia_css_isp_parameter put;
-	} dmem;
-	struct {
-		struct ia_css_isp_parameter anr2;
-		struct ia_css_isp_parameter ob;
-		struct ia_css_isp_parameter sdis_horicoef;
-		struct ia_css_isp_parameter sdis_vertcoef;
-		struct ia_css_isp_parameter sdis2_horicoef;
-		struct ia_css_isp_parameter sdis2_vertcoef;
-#ifdef ISP2401
-		struct ia_css_isp_parameter xnr3;
-#endif
-	} vmem;
-	struct {
-		struct ia_css_isp_parameter bh;
-	} hmem0;
-	struct {
-		struct ia_css_isp_parameter gc;
-		struct ia_css_isp_parameter g_gamma;
-		struct ia_css_isp_parameter xnr_table;
-	} vamem1;
-	struct {
-		struct ia_css_isp_parameter r_gamma;
-		struct ia_css_isp_parameter ctc;
-	} vamem0;
-	struct {
-		struct ia_css_isp_parameter b_gamma;
-	} vamem2;
-};
-
-#if defined(IA_CSS_INCLUDE_PARAMETERS)
-
-#include "ia_css_stream.h"   /* struct ia_css_stream */
-#include "ia_css_binary.h"   /* struct ia_css_binary */
-/* Code generated by genparam/gencode.c:gen_param_process_table() */
-
-struct ia_css_pipeline_stage; /* forward declaration */
-
-extern void (* ia_css_kernel_process_param[IA_CSS_NUM_PARAMETER_IDS])(
-			unsigned pipe_id,
-			const struct ia_css_pipeline_stage *stage,
-			struct ia_css_isp_parameters *params);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_dp_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dp_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_wb_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_wb_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_tnr_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_tnr_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_ob_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_ob_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_de_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_de_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_anr_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_anr_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_anr2_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_anr_thres *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_ce_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_ce_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_ecd_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_ecd_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_ynr_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_ynr_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_fc_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_fc_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_cnr_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_cnr_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_macc_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_macc_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_ctc_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_ctc_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_aa_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_aa_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_yuv2rgb_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_cc_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_rgb2yuv_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_cc_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_csc_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_cc_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_nr_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_nr_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_gc_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_gc_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis_horicoef_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs_coefficients *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis_vertcoef_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs_coefficients *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis_horiproj_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs_coefficients *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis_vertproj_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs_coefficients *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis2_horicoef_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs2_coefficients *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis2_vertcoef_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs2_coefficients *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis2_horiproj_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs2_coefficients *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_sdis2_vertproj_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_dvs2_coefficients *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_r_gamma_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_rgb_gamma_table *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_g_gamma_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_rgb_gamma_table *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_b_gamma_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_rgb_gamma_table *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_xnr_table_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_xnr_table *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_formats_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_formats_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_xnr_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_xnr_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_xnr3_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_xnr3_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_s3a_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_3a_config *config);
-
-/* Code generated by genparam/gencode.c:gen_set_function() */
-
-void
-ia_css_set_output_config(struct ia_css_isp_parameters *params,
-			const struct ia_css_output_config *config);
-
-/* Code generated by genparam/gencode.c:gen_global_access_function() */
-
-void
-ia_css_get_configs(struct ia_css_isp_parameters *params,
-		const struct ia_css_isp_config *config)
-;
-#ifdef ISP2401
-
-#endif
-/* Code generated by genparam/gencode.c:gen_global_access_function() */
-
-void
-ia_css_set_configs(struct ia_css_isp_parameters *params,
-		const struct ia_css_isp_config *config)
-;
-#ifdef ISP2401
-
-#endif
-#endif /* IA_CSS_INCLUDE_PARAMETER */
-
-#endif /* _IA_CSS_ISP_PARAM_H */

+ 0 - 214
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_states.c

@@ -1,214 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-/* Generated code: do not edit or commmit. */
-
-#include "ia_css_pipeline.h"
-#include "ia_css_isp_states.h"
-#include "ia_css_debug.h"
-#include "assert_support.h"
-
-/* Code generated by genparam/genstate.c:gen_init_function() */
-
-static void
-ia_css_initialize_aa_state(
-	const struct ia_css_binary *binary)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_aa_state() enter:\n");
-
-	{
-		unsigned size   = binary->info->mem_offsets.offsets.state->vmem.aa.size;
-
-		unsigned offset = binary->info->mem_offsets.offsets.state->vmem.aa.offset;
-
-		if (size)
-			memset(&binary->mem_params.params[IA_CSS_PARAM_CLASS_STATE][IA_CSS_ISP_VMEM].address[offset], 0, size);
-
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_aa_state() leave:\n");
-}
-
-/* Code generated by genparam/genstate.c:gen_init_function() */
-
-static void
-ia_css_initialize_cnr_state(
-	const struct ia_css_binary *binary)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_cnr_state() enter:\n");
-
-	{
-		unsigned size   = binary->info->mem_offsets.offsets.state->vmem.cnr.size;
-
-		unsigned offset = binary->info->mem_offsets.offsets.state->vmem.cnr.offset;
-
-		if (size) {
-			ia_css_init_cnr_state(
-				&binary->mem_params.params[IA_CSS_PARAM_CLASS_STATE][IA_CSS_ISP_VMEM].address[offset],
-				size);
-		}
-
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_cnr_state() leave:\n");
-}
-
-/* Code generated by genparam/genstate.c:gen_init_function() */
-
-static void
-ia_css_initialize_cnr2_state(
-	const struct ia_css_binary *binary)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_cnr2_state() enter:\n");
-
-	{
-		unsigned size   = binary->info->mem_offsets.offsets.state->vmem.cnr2.size;
-
-		unsigned offset = binary->info->mem_offsets.offsets.state->vmem.cnr2.offset;
-
-		if (size) {
-			ia_css_init_cnr2_state(
-				&binary->mem_params.params[IA_CSS_PARAM_CLASS_STATE][IA_CSS_ISP_VMEM].address[offset],
-				size);
-		}
-
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_cnr2_state() leave:\n");
-}
-
-/* Code generated by genparam/genstate.c:gen_init_function() */
-
-static void
-ia_css_initialize_dp_state(
-	const struct ia_css_binary *binary)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_dp_state() enter:\n");
-
-	{
-		unsigned size   = binary->info->mem_offsets.offsets.state->vmem.dp.size;
-
-		unsigned offset = binary->info->mem_offsets.offsets.state->vmem.dp.offset;
-
-		if (size) {
-			ia_css_init_dp_state(
-				&binary->mem_params.params[IA_CSS_PARAM_CLASS_STATE][IA_CSS_ISP_VMEM].address[offset],
-				size);
-		}
-
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_dp_state() leave:\n");
-}
-
-/* Code generated by genparam/genstate.c:gen_init_function() */
-
-static void
-ia_css_initialize_de_state(
-	const struct ia_css_binary *binary)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_de_state() enter:\n");
-
-	{
-		unsigned size   = binary->info->mem_offsets.offsets.state->vmem.de.size;
-
-		unsigned offset = binary->info->mem_offsets.offsets.state->vmem.de.offset;
-
-		if (size) {
-			ia_css_init_de_state(
-				&binary->mem_params.params[IA_CSS_PARAM_CLASS_STATE][IA_CSS_ISP_VMEM].address[offset],
-				size);
-		}
-
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_de_state() leave:\n");
-}
-
-/* Code generated by genparam/genstate.c:gen_init_function() */
-
-static void
-ia_css_initialize_tnr_state(
-	const struct ia_css_binary *binary)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_tnr_state() enter:\n");
-
-	{
-		unsigned size   = binary->info->mem_offsets.offsets.state->dmem.tnr.size;
-
-		unsigned offset = binary->info->mem_offsets.offsets.state->dmem.tnr.offset;
-
-		if (size) {
-			ia_css_init_tnr_state((struct sh_css_isp_tnr_dmem_state *)
-				&binary->mem_params.params[IA_CSS_PARAM_CLASS_STATE][IA_CSS_ISP_DMEM].address[offset],
-				size);
-		}
-
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_tnr_state() leave:\n");
-}
-
-/* Code generated by genparam/genstate.c:gen_init_function() */
-
-static void
-ia_css_initialize_ref_state(
-	const struct ia_css_binary *binary)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_ref_state() enter:\n");
-
-	{
-		unsigned size   = binary->info->mem_offsets.offsets.state->dmem.ref.size;
-
-		unsigned offset = binary->info->mem_offsets.offsets.state->dmem.ref.offset;
-
-		if (size) {
-			ia_css_init_ref_state((struct sh_css_isp_ref_dmem_state *)
-				&binary->mem_params.params[IA_CSS_PARAM_CLASS_STATE][IA_CSS_ISP_DMEM].address[offset],
-				size);
-		}
-
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_ref_state() leave:\n");
-}
-
-/* Code generated by genparam/genstate.c:gen_init_function() */
-
-static void
-ia_css_initialize_ynr_state(
-	const struct ia_css_binary *binary)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_ynr_state() enter:\n");
-
-	{
-		unsigned size   = binary->info->mem_offsets.offsets.state->vmem.ynr.size;
-
-		unsigned offset = binary->info->mem_offsets.offsets.state->vmem.ynr.offset;
-
-		if (size) {
-			ia_css_init_ynr_state(
-				&binary->mem_params.params[IA_CSS_PARAM_CLASS_STATE][IA_CSS_ISP_VMEM].address[offset],
-				size);
-		}
-
-	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "ia_css_initialize_ynr_state() leave:\n");
-}
-
-/* Code generated by genparam/genstate.c:gen_state_init_table() */
-
-void (* ia_css_kernel_init_state[IA_CSS_NUM_STATE_IDS])(const struct ia_css_binary *binary) = {
-	ia_css_initialize_aa_state,
-	ia_css_initialize_cnr_state,
-	ia_css_initialize_cnr2_state,
-	ia_css_initialize_dp_state,
-	ia_css_initialize_de_state,
-	ia_css_initialize_tnr_state,
-	ia_css_initialize_ref_state,
-	ia_css_initialize_ynr_state,
-};
-

+ 0 - 72
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hive_isp_css_2400_system_generated/ia_css_isp_states.h

@@ -1,72 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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.
- */
-
-#define IA_CSS_INCLUDE_STATES
-#include "isp/kernels/aa/aa_2/ia_css_aa2.host.h"
-#include "isp/kernels/cnr/cnr_1.0/ia_css_cnr.host.h"
-#include "isp/kernels/cnr/cnr_2/ia_css_cnr2.host.h"
-#include "isp/kernels/de/de_1.0/ia_css_de.host.h"
-#include "isp/kernels/dp/dp_1.0/ia_css_dp.host.h"
-#include "isp/kernels/ref/ref_1.0/ia_css_ref.host.h"
-#include "isp/kernels/tnr/tnr_1.0/ia_css_tnr.host.h"
-#include "isp/kernels/ynr/ynr_1.0/ia_css_ynr.host.h"
-#include "isp/kernels/dpc2/ia_css_dpc2.host.h"
-#include "isp/kernels/eed1_8/ia_css_eed1_8.host.h"
-/* Generated code: do not edit or commmit. */
-
-#ifndef _IA_CSS_ISP_STATE_H
-#define _IA_CSS_ISP_STATE_H
-
-/* Code generated by genparam/gencode.c:gen_param_enum() */
-
-enum ia_css_state_ids {
-	IA_CSS_AA_STATE_ID,
-	IA_CSS_CNR_STATE_ID,
-	IA_CSS_CNR2_STATE_ID,
-	IA_CSS_DP_STATE_ID,
-	IA_CSS_DE_STATE_ID,
-	IA_CSS_TNR_STATE_ID,
-	IA_CSS_REF_STATE_ID,
-	IA_CSS_YNR_STATE_ID,
-	IA_CSS_NUM_STATE_IDS
-};
-
-/* Code generated by genparam/gencode.c:gen_param_offsets() */
-
-struct ia_css_state_memory_offsets {
-	struct {
-		struct ia_css_isp_parameter aa;
-		struct ia_css_isp_parameter cnr;
-		struct ia_css_isp_parameter cnr2;
-		struct ia_css_isp_parameter dp;
-		struct ia_css_isp_parameter de;
-		struct ia_css_isp_parameter ynr;
-	} vmem;
-	struct {
-		struct ia_css_isp_parameter tnr;
-		struct ia_css_isp_parameter ref;
-	} dmem;
-};
-
-#if defined(IA_CSS_INCLUDE_STATES)
-
-#include "ia_css_stream.h"   /* struct ia_css_stream */
-#include "ia_css_binary.h"   /* struct ia_css_binary */
-/* Code generated by genparam/genstate.c:gen_state_init_table() */
-
-extern void (* ia_css_kernel_init_state[IA_CSS_NUM_STATE_IDS])(const struct ia_css_binary *binary);
-
-#endif /* IA_CSS_INCLUDE_STATE */
-
-#endif /* _IA_CSS_ISP_STATE_H */

+ 0 - 104
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/bits.h

@@ -1,104 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _HRT_BITS_H
-#define _HRT_BITS_H
-
-#include "defs.h"
-
-#define _hrt_ones(n) HRTCAT(_hrt_ones_, n)
-#define _hrt_ones_0x0  0x00000000U
-#define _hrt_ones_0x1  0x00000001U
-#define _hrt_ones_0x2  0x00000003U
-#define _hrt_ones_0x3  0x00000007U
-#define _hrt_ones_0x4  0x0000000FU
-#define _hrt_ones_0x5  0x0000001FU
-#define _hrt_ones_0x6  0x0000003FU
-#define _hrt_ones_0x7  0x0000007FU
-#define _hrt_ones_0x8  0x000000FFU
-#define _hrt_ones_0x9  0x000001FFU
-#define _hrt_ones_0xA  0x000003FFU
-#define _hrt_ones_0xB  0x000007FFU
-#define _hrt_ones_0xC  0x00000FFFU
-#define _hrt_ones_0xD  0x00001FFFU
-#define _hrt_ones_0xE  0x00003FFFU
-#define _hrt_ones_0xF  0x00007FFFU
-#define _hrt_ones_0x10 0x0000FFFFU
-#define _hrt_ones_0x11 0x0001FFFFU
-#define _hrt_ones_0x12 0x0003FFFFU
-#define _hrt_ones_0x13 0x0007FFFFU
-#define _hrt_ones_0x14 0x000FFFFFU
-#define _hrt_ones_0x15 0x001FFFFFU
-#define _hrt_ones_0x16 0x003FFFFFU
-#define _hrt_ones_0x17 0x007FFFFFU
-#define _hrt_ones_0x18 0x00FFFFFFU
-#define _hrt_ones_0x19 0x01FFFFFFU
-#define _hrt_ones_0x1A 0x03FFFFFFU
-#define _hrt_ones_0x1B 0x07FFFFFFU
-#define _hrt_ones_0x1C 0x0FFFFFFFU
-#define _hrt_ones_0x1D 0x1FFFFFFFU
-#define _hrt_ones_0x1E 0x3FFFFFFFU
-#define _hrt_ones_0x1F 0x7FFFFFFFU
-#define _hrt_ones_0x20 0xFFFFFFFFU
-
-#define _hrt_ones_0  _hrt_ones_0x0
-#define _hrt_ones_1  _hrt_ones_0x1
-#define _hrt_ones_2  _hrt_ones_0x2
-#define _hrt_ones_3  _hrt_ones_0x3
-#define _hrt_ones_4  _hrt_ones_0x4
-#define _hrt_ones_5  _hrt_ones_0x5
-#define _hrt_ones_6  _hrt_ones_0x6
-#define _hrt_ones_7  _hrt_ones_0x7
-#define _hrt_ones_8  _hrt_ones_0x8
-#define _hrt_ones_9  _hrt_ones_0x9
-#define _hrt_ones_10 _hrt_ones_0xA
-#define _hrt_ones_11 _hrt_ones_0xB
-#define _hrt_ones_12 _hrt_ones_0xC
-#define _hrt_ones_13 _hrt_ones_0xD
-#define _hrt_ones_14 _hrt_ones_0xE
-#define _hrt_ones_15 _hrt_ones_0xF
-#define _hrt_ones_16 _hrt_ones_0x10
-#define _hrt_ones_17 _hrt_ones_0x11
-#define _hrt_ones_18 _hrt_ones_0x12
-#define _hrt_ones_19 _hrt_ones_0x13
-#define _hrt_ones_20 _hrt_ones_0x14
-#define _hrt_ones_21 _hrt_ones_0x15
-#define _hrt_ones_22 _hrt_ones_0x16
-#define _hrt_ones_23 _hrt_ones_0x17
-#define _hrt_ones_24 _hrt_ones_0x18
-#define _hrt_ones_25 _hrt_ones_0x19
-#define _hrt_ones_26 _hrt_ones_0x1A
-#define _hrt_ones_27 _hrt_ones_0x1B
-#define _hrt_ones_28 _hrt_ones_0x1C
-#define _hrt_ones_29 _hrt_ones_0x1D
-#define _hrt_ones_30 _hrt_ones_0x1E
-#define _hrt_ones_31 _hrt_ones_0x1F
-#define _hrt_ones_32 _hrt_ones_0x20
-
-#define _hrt_mask(b, n) \
-  (_hrt_ones(n) << (b))
-#define _hrt_get_bits(w, b, n) \
-  (((w) >> (b)) & _hrt_ones(n))
-#define _hrt_set_bits(w, b, n, v) \
-  (((w) & ~_hrt_mask(b, n)) | (((v) & _hrt_ones(n)) << (b)))
-#define _hrt_get_bit(w, b) \
-  (((w) >> (b)) & 1)
-#define _hrt_set_bit(w, b, v) \
-  (((w) & (~(1 << (b)))) | (((v)&1) << (b)))
-#define _hrt_set_lower_half(w, v) \
-  _hrt_set_bits(w, 0, 16, v)
-#define _hrt_set_upper_half(w, v) \
-  _hrt_set_bits(w, 16, 16, v)
-
-#endif /* _HRT_BITS_H */

+ 0 - 42
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/cell_params.h

@@ -1,42 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _cell_params_h
-#define _cell_params_h
-
-#define SP_PMEM_LOG_WIDTH_BITS           6  /*Width of PC, 64 bits, 8 bytes*/
-#define SP_ICACHE_TAG_BITS               4  /*size of tag*/
-#define SP_ICACHE_SET_BITS               8  /* 256 sets*/
-#define SP_ICACHE_BLOCKS_PER_SET_BITS    1  /* 2 way associative*/
-#define SP_ICACHE_BLOCK_ADDRESS_BITS     11 /* 2048 lines capacity*/
-
-#define SP_ICACHE_ADDRESS_BITS \
-	                    (SP_ICACHE_TAG_BITS+SP_ICACHE_BLOCK_ADDRESS_BITS)
-
-#define SP_PMEM_DEPTH        (1<<SP_ICACHE_ADDRESS_BITS)
-
-#define SP_FIFO_0_DEPTH      0
-#define SP_FIFO_1_DEPTH      0
-#define SP_FIFO_2_DEPTH      0
-#define SP_FIFO_3_DEPTH      0
-#define SP_FIFO_4_DEPTH      0
-#define SP_FIFO_5_DEPTH      0
-#define SP_FIFO_6_DEPTH      0
-#define SP_FIFO_7_DEPTH      0
-
-
-#define SP_SLV_BUS_MAXBURSTSIZE        1
-
-#endif /* _cell_params_h */
-

+ 0 - 200
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/css_receiver_2400_common_defs.h

@@ -1,200 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _css_receiver_2400_common_defs_h_
-#define _css_receiver_2400_common_defs_h_
-#ifndef _mipi_backend_common_defs_h_
-#define _mipi_backend_common_defs_h_
-
-#define _HRT_CSS_RECEIVER_2400_GEN_SHORT_DATA_WIDTH     16
-#define _HRT_CSS_RECEIVER_2400_GEN_SHORT_CH_ID_WIDTH     2
-#define _HRT_CSS_RECEIVER_2400_GEN_SHORT_FMT_TYPE_WIDTH  3
-#define _HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_REAL_WIDTH (_HRT_CSS_RECEIVER_2400_GEN_SHORT_DATA_WIDTH + _HRT_CSS_RECEIVER_2400_GEN_SHORT_CH_ID_WIDTH + _HRT_CSS_RECEIVER_2400_GEN_SHORT_FMT_TYPE_WIDTH)
-#define _HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_WIDTH      32 /* use 32 to be compatibel with streaming monitor !, MSB's of interface are tied to '0' */ 
-
-/* Definition of data format ID at the interface CSS_receiver capture/acquisition units */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV420_8          24   /* 01 1000 YUV420 8-bit                                        */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV420_10         25   /* 01 1001  YUV420 10-bit                                      */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV420_8L         26   /* 01 1010   YUV420 8-bit legacy                               */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV422_8          30   /* 01 1110   YUV422 8-bit                                      */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV422_10         31   /* 01 1111   YUV422 10-bit                                     */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RGB444            32   /* 10 0000   RGB444                                            */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RGB555            33   /* 10 0001   RGB555                                            */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RGB565            34   /* 10 0010   RGB565                                            */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RGB666            35   /* 10 0011   RGB666                                            */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RGB888            36   /* 10 0100   RGB888                                            */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW6              40   /* 10 1000   RAW6                                              */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW7              41   /* 10 1001   RAW7                                              */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW8              42   /* 10 1010   RAW8                                              */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW10             43   /* 10 1011   RAW10                                             */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW12             44   /* 10 1100   RAW12                                             */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW14             45   /* 10 1101   RAW14                                             */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_1         48   /* 11 0000    JPEG [User Defined 8-bit Data Type 1]            */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_2         49   /* 11 0001    User Defined 8-bit Data Type 2                   */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_3         50   /* 11 0010    User Defined 8-bit Data Type 3                   */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_4         51   /* 11 0011    User Defined 8-bit Data Type 4                   */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_5         52   /* 11 0100    User Defined 8-bit Data Type 5                   */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_6         53   /* 11 0101    User Defined 8-bit Data Type 6                   */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_7         54   /* 11 0110    User Defined 8-bit Data Type 7                   */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_USR_DEF_8         55   /* 11 0111    User Defined 8-bit Data Type 8                   */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_Emb               18   /* 01 0010    embedded eight bit non image data                */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_SOF                0   /* 00 0000    frame start                                      */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_EOF                1   /* 00 0001    frame end                                        */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_SOL                2   /* 00 0010    line start                                       */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_EOL                3   /* 00 0011    line end                                         */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH1            8   /* 00 1000  Generic Short Packet Code 1                        */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH2            9   /* 00 1001    Generic Short Packet Code 2                      */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH3           10   /* 00 1010    Generic Short Packet Code 3                      */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH4           11   /* 00 1011    Generic Short Packet Code 4                      */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH5           12   /* 00 1100    Generic Short Packet Code 5                      */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH6           13   /* 00 1101    Generic Short Packet Code 6                      */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH7           14   /* 00 1110    Generic Short Packet Code 7                      */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_GEN_SH8           15   /* 00 1111    Generic Short Packet Code 8                      */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV420_8_CSPS     28   /* 01 1100   YUV420 8-bit (Chroma Shifted Pixel Sampling)      */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_YUV420_10_CSPS    29   /* 01 1101   YUV420 10-bit (Chroma Shifted Pixel Sampling)     */
-/* used reseved mipi positions for these */
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW16             46 
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW18             47 
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW18_2           37 
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_RAW18_3           38 
-
-#define _HRT_CSS_RECEIVER_2400_DATA_FORMAT_ID_WIDTH              6
-
-/* Definition of format_types at the interface CSS --> input_selector*/
-/* !! Changes here should be copied to systems/isp/isp_css/bin/conv_transmitter_cmd.tcl !! */
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RGB888           0  // 36 'h24
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RGB555           1  // 33 'h
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RGB444           2  // 32
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RGB565           3  // 34
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RGB666           4  // 35
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW8             5  // 42 
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW10            6  // 43
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW6             7  // 40
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW7             8  // 41
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW12            9  // 43
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW14           10  // 45
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV420_8        11  // 30
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV420_10       12  // 25
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV422_8        13  // 30
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV422_10       14  // 31
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_1       15  // 48
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV420_8L       16  // 26
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_Emb             17  // 18
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_2       18  // 49
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_3       19  // 50
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_4       20  // 51
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_5       21  // 52
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_6       22  // 53
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_7       23  // 54
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_USR_DEF_8       24  // 55
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV420_8_CSPS   25  // 28
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_YUV420_10_CSPS  26  // 29
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW16           27  // ?
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW18           28  // ?
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW18_2         29  // ? Option 2 for depacketiser
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_RAW18_3         30  // ? Option 3 for depacketiser
-#define _HRT_CSS_RECEIVER_2400_FMT_TYPE_CUSTOM          31  // to signal custom decoding 
-
-/* definition for state machine of data FIFO for decode different type of data */
-#define _HRT_CSS_RECEIVER_2400_YUV420_8_REPEAT_PTN                 1  
-#define _HRT_CSS_RECEIVER_2400_YUV420_10_REPEAT_PTN                5
-#define _HRT_CSS_RECEIVER_2400_YUV420_8L_REPEAT_PTN                1
-#define _HRT_CSS_RECEIVER_2400_YUV422_8_REPEAT_PTN                 1
-#define _HRT_CSS_RECEIVER_2400_YUV422_10_REPEAT_PTN                5
-#define _HRT_CSS_RECEIVER_2400_RGB444_REPEAT_PTN                   2 
-#define _HRT_CSS_RECEIVER_2400_RGB555_REPEAT_PTN                   2
-#define _HRT_CSS_RECEIVER_2400_RGB565_REPEAT_PTN                   2
-#define _HRT_CSS_RECEIVER_2400_RGB666_REPEAT_PTN                   9                       
-#define _HRT_CSS_RECEIVER_2400_RGB888_REPEAT_PTN                   3
-#define _HRT_CSS_RECEIVER_2400_RAW6_REPEAT_PTN                     3
-#define _HRT_CSS_RECEIVER_2400_RAW7_REPEAT_PTN                     7
-#define _HRT_CSS_RECEIVER_2400_RAW8_REPEAT_PTN                     1
-#define _HRT_CSS_RECEIVER_2400_RAW10_REPEAT_PTN                    5
-#define _HRT_CSS_RECEIVER_2400_RAW12_REPEAT_PTN                    3        
-#define _HRT_CSS_RECEIVER_2400_RAW14_REPEAT_PTN                    7
-
-#define _HRT_CSS_RECEIVER_2400_MAX_REPEAT_PTN                      _HRT_CSS_RECEIVER_2400_RGB666_REPEAT_PTN
-
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_FMT_IDX                     0
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_FMT_WIDTH                   3
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_PRED_IDX                    3
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_PRED_WIDTH                  1
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_USD_BITS                    4  /* bits per USD type */
-
-#define _HRT_CSS_RECEIVER_2400_BE_RAW16_DATAID_IDX                 0
-#define _HRT_CSS_RECEIVER_2400_BE_RAW16_EN_IDX                     6
-#define _HRT_CSS_RECEIVER_2400_BE_RAW18_DATAID_IDX                 0
-#define _HRT_CSS_RECEIVER_2400_BE_RAW18_OPTION_IDX                 6
-#define _HRT_CSS_RECEIVER_2400_BE_RAW18_EN_IDX                     8
-
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_NO_COMP                     0
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_10_6_10                     1
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_10_7_10                     2
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_10_8_10                     3
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_12_6_12                     4
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_12_7_12                     5
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_12_8_12                     6
-
-
-/* packet bit definition */
-#define _HRT_CSS_RECEIVER_2400_PKT_SOP_IDX                        32
-#define _HRT_CSS_RECEIVER_2400_PKT_SOP_BITS                        1
-#define _HRT_CSS_RECEIVER_2400_PKT_CH_ID_IDX                      22
-#define _HRT_CSS_RECEIVER_2400_PKT_CH_ID_BITS                      2
-#define _HRT_CSS_RECEIVER_2400_PKT_FMT_ID_IDX                     16
-#define _HRT_CSS_RECEIVER_2400_PKT_FMT_ID_BITS                     6
-#define _HRT_CSS_RECEIVER_2400_PH_DATA_FIELD_IDX                   0
-#define _HRT_CSS_RECEIVER_2400_PH_DATA_FIELD_BITS                 16
-#define _HRT_CSS_RECEIVER_2400_PKT_PAYLOAD_IDX                     0
-#define _HRT_CSS_RECEIVER_2400_PKT_PAYLOAD_BITS                   32
-
-
-/*************************************************************************************************/
-/* Custom Decoding                                                                               */
-/* These Custom Defs are defined based on design-time config in "csi_be_pixel_formatter.chdl" !! */
-/*************************************************************************************************/
-#define BE_CUST_EN_IDX                     0     /* 2bits */
-#define BE_CUST_EN_DATAID_IDX              2     /* 6bits MIPI DATA ID */ 
-#define BE_CUST_EN_WIDTH                   8     
-#define BE_CUST_MODE_ALL                   1     /* Enable Custom Decoding for all DATA IDs */
-#define BE_CUST_MODE_ONE                   3     /* Enable Custom Decoding for ONE DATA ID, programmed in CUST_EN_DATA_ID */
-
-/* Data State config = {get_bits(6bits), valid(1bit)}  */
-#define BE_CUST_DATA_STATE_S0_IDX          0     /* 7bits */ 
-#define BE_CUST_DATA_STATE_S1_IDX          7     /* 7bits */ 
-#define BE_CUST_DATA_STATE_S2_IDX          14    /* 7bits */
-#define BE_CUST_DATA_STATE_WIDTH           21    
-#define BE_CUST_DATA_STATE_VALID_IDX       0     /* 1bits */
-#define BE_CUST_DATA_STATE_GETBITS_IDX     1     /* 6bits */
-
-/* Pixel Extractor config */
-#define BE_CUST_PIX_EXT_DATA_ALIGN_IDX     0     /* 5bits */
-#define BE_CUST_PIX_EXT_PIX_ALIGN_IDX      5     /* 5bits */
-#define BE_CUST_PIX_EXT_PIX_MASK_IDX       10    /* 18bits */
-#define BE_CUST_PIX_EXT_PIX_EN_IDX         28    /* 1bits */
-#define BE_CUST_PIX_EXT_WIDTH              29    
-
-/* Pixel Valid & EoP config = {[eop,valid](especial), [eop,valid](normal)} */
-#define BE_CUST_PIX_VALID_EOP_P0_IDX        0    /* 4bits */
-#define BE_CUST_PIX_VALID_EOP_P1_IDX        4    /* 4bits */
-#define BE_CUST_PIX_VALID_EOP_P2_IDX        8    /* 4bits */
-#define BE_CUST_PIX_VALID_EOP_P3_IDX        12   /* 4bits */
-#define BE_CUST_PIX_VALID_EOP_WIDTH         16 
-#define BE_CUST_PIX_VALID_EOP_NOR_VALID_IDX 0    /* Normal (NO less get_bits case) Valid - 1bits */
-#define BE_CUST_PIX_VALID_EOP_NOR_EOP_IDX   1    /* Normal (NO less get_bits case) EoP - 1bits */
-#define BE_CUST_PIX_VALID_EOP_ESP_VALID_IDX 2    /* Especial (less get_bits case) Valid - 1bits */
-#define BE_CUST_PIX_VALID_EOP_ESP_EOP_IDX   3    /* Especial (less get_bits case) EoP - 1bits */
-
-#endif /* _mipi_backend_common_defs_h_ */
-#endif /* _css_receiver_2400_common_defs_h_ */ 

+ 0 - 258
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/css_receiver_2400_defs.h

@@ -1,258 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _css_receiver_2400_defs_h_
-#define _css_receiver_2400_defs_h_
-
-#include "css_receiver_2400_common_defs.h"
-
-#define CSS_RECEIVER_DATA_WIDTH                8
-#define CSS_RECEIVER_RX_TRIG                   4
-#define CSS_RECEIVER_RF_WORD                  32
-#define CSS_RECEIVER_IMG_PROC_RF_ADDR         10
-#define CSS_RECEIVER_CSI_RF_ADDR               4
-#define CSS_RECEIVER_DATA_OUT                 12
-#define CSS_RECEIVER_CHN_NO                    2
-#define CSS_RECEIVER_DWORD_CNT                11
-#define CSS_RECEIVER_FORMAT_TYP                5
-#define CSS_RECEIVER_HRESPONSE                 2
-#define CSS_RECEIVER_STATE_WIDTH               3
-#define CSS_RECEIVER_FIFO_DAT                 32
-#define CSS_RECEIVER_CNT_VAL                   2
-#define CSS_RECEIVER_PRED10_VAL               10
-#define CSS_RECEIVER_PRED12_VAL               12
-#define CSS_RECEIVER_CNT_WIDTH                 8
-#define CSS_RECEIVER_WORD_CNT                 16
-#define CSS_RECEIVER_PIXEL_LEN                 6
-#define CSS_RECEIVER_PIXEL_CNT                 5
-#define CSS_RECEIVER_COMP_8_BIT                8
-#define CSS_RECEIVER_COMP_7_BIT                7
-#define CSS_RECEIVER_COMP_6_BIT                6
-
-#define CSI_CONFIG_WIDTH                       4
-
-/* division of gen_short data, ch_id and fmt_type over streaming data interface */
-#define _HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_DATA_BIT_LSB     0
-#define _HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_FMT_TYPE_BIT_LSB (_HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_DATA_BIT_LSB     + _HRT_CSS_RECEIVER_2400_GEN_SHORT_DATA_WIDTH)
-#define _HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_CH_ID_BIT_LSB    (_HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_FMT_TYPE_BIT_LSB + _HRT_CSS_RECEIVER_2400_GEN_SHORT_FMT_TYPE_WIDTH)
-#define _HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_DATA_BIT_MSB     (_HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_FMT_TYPE_BIT_LSB - 1)
-#define _HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_FMT_TYPE_BIT_MSB (_HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_CH_ID_BIT_LSB    - 1)
-#define _HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_CH_ID_BIT_MSB    (_HRT_CSS_RECEIVER_2400_GEN_SHORT_STR_REAL_WIDTH       - 1)
-
-#define _HRT_CSS_RECEIVER_2400_REG_ALIGN 4
-#define _HRT_CSS_RECEIVER_2400_BYTES_PER_PKT             4
-
-#define hrt_css_receiver_2400_4_lane_port_offset  0x100
-#define hrt_css_receiver_2400_1_lane_port_offset  0x200
-#define hrt_css_receiver_2400_2_lane_port_offset  0x300
-#define hrt_css_receiver_2400_backend_port_offset 0x100
-
-#define _HRT_CSS_RECEIVER_2400_DEVICE_READY_REG_IDX      0
-#define _HRT_CSS_RECEIVER_2400_IRQ_STATUS_REG_IDX        1
-#define _HRT_CSS_RECEIVER_2400_IRQ_ENABLE_REG_IDX        2
-#define _HRT_CSS_RECEIVER_2400_CSI2_FUNC_PROG_REG_IDX    3
-#define _HRT_CSS_RECEIVER_2400_INIT_COUNT_REG_IDX        4
-#define _HRT_CSS_RECEIVER_2400_FS_TO_LS_DELAY_REG_IDX    7
-#define _HRT_CSS_RECEIVER_2400_LS_TO_DATA_DELAY_REG_IDX  8
-#define _HRT_CSS_RECEIVER_2400_DATA_TO_LE_DELAY_REG_IDX  9
-#define _HRT_CSS_RECEIVER_2400_LE_TO_FE_DELAY_REG_IDX   10
-#define _HRT_CSS_RECEIVER_2400_FE_TO_FS_DELAY_REG_IDX   11
-#define _HRT_CSS_RECEIVER_2400_LE_TO_LS_DELAY_REG_IDX   12
-#define _HRT_CSS_RECEIVER_2400_TWO_PIXEL_EN_REG_IDX     13
-#define _HRT_CSS_RECEIVER_2400_RAW16_18_DATAID_REG_IDX  14
-#define _HRT_CSS_RECEIVER_2400_SYNC_COUNT_REG_IDX       15
-#define _HRT_CSS_RECEIVER_2400_RX_COUNT_REG_IDX         16
-#define _HRT_CSS_RECEIVER_2400_BACKEND_RST_REG_IDX      17
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_VC0_REG0_IDX 18
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_VC0_REG1_IDX 19
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_VC1_REG0_IDX 20
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_VC1_REG1_IDX 21
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_VC2_REG0_IDX 22
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_VC2_REG1_IDX 23
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_VC3_REG0_IDX 24
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_VC3_REG1_IDX 25
-#define _HRT_CSS_RECEIVER_2400_RAW18_REG_IDX            26
-#define _HRT_CSS_RECEIVER_2400_FORCE_RAW8_REG_IDX       27
-#define _HRT_CSS_RECEIVER_2400_RAW16_REG_IDX            28
-
-/* Interrupt bits for IRQ_STATUS and IRQ_ENABLE registers */
-#define _HRT_CSS_RECEIVER_2400_IRQ_OVERRUN_BIT                0
-#define _HRT_CSS_RECEIVER_2400_IRQ_RESERVED_BIT               1
-#define _HRT_CSS_RECEIVER_2400_IRQ_SLEEP_MODE_ENTRY_BIT       2
-#define _HRT_CSS_RECEIVER_2400_IRQ_SLEEP_MODE_EXIT_BIT        3
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_SOT_HS_BIT             4
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_SOT_SYNC_HS_BIT        5
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_CONTROL_BIT            6
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_ECC_DOUBLE_BIT         7
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_ECC_CORRECTED_BIT      8
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_ECC_NO_CORRECTION_BIT  9
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_CRC_BIT               10
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_ID_BIT                11
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_FRAME_SYNC_BIT        12
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_FRAME_DATA_BIT        13
-#define _HRT_CSS_RECEIVER_2400_IRQ_DATA_TIMEOUT_BIT          14
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_ESCAPE_BIT            15
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_LINE_SYNC_BIT         16
-
-#define _HRT_CSS_RECEIVER_2400_IRQ_OVERRUN_CAUSE_                  "Fifo Overrun"
-#define _HRT_CSS_RECEIVER_2400_IRQ_RESERVED_CAUSE_                 "Reserved"
-#define _HRT_CSS_RECEIVER_2400_IRQ_SLEEP_MODE_ENTRY_CAUSE_         "Sleep mode entry"
-#define _HRT_CSS_RECEIVER_2400_IRQ_SLEEP_MODE_EXIT_CAUSE_          "Sleep mode exit"
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_SOT_HS_CAUSE_               "Error high speed SOT"
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_SOT_SYNC_HS_CAUSE_          "Error high speed sync SOT"
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_CONTROL_CAUSE_              "Error control"
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_ECC_DOUBLE_CAUSE_           "Error correction double bit"
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_ECC_CORRECTED_CAUSE_        "Error correction single bit"
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_ECC_NO_CORRECTION_CAUSE_    "No error"
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_CRC_CAUSE_                  "Error cyclic redundancy check"
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_ID_CAUSE_                   "Error id"
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_FRAME_SYNC_CAUSE_           "Error frame sync"
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_FRAME_DATA_CAUSE_           "Error frame data"
-#define _HRT_CSS_RECEIVER_2400_IRQ_DATA_TIMEOUT_CAUSE_             "Data time-out"
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_ESCAPE_CAUSE_               "Error escape"
-#define _HRT_CSS_RECEIVER_2400_IRQ_ERR_LINE_SYNC_CAUSE_            "Error line sync"
-
-/* Bits for CSI2_DEVICE_READY register */
-#define _HRT_CSS_RECEIVER_2400_CSI2_DEVICE_READY_IDX                          0
-#define _HRT_CSS_RECEIVER_2400_CSI2_MASK_INIT_TIME_OUT_ERR_IDX                2
-#define _HRT_CSS_RECEIVER_2400_CSI2_MASK_OVER_RUN_ERR_IDX                     3
-#define _HRT_CSS_RECEIVER_2400_CSI2_MASK_SOT_SYNC_ERR_IDX                     4
-#define _HRT_CSS_RECEIVER_2400_CSI2_MASK_RECEIVE_DATA_TIME_OUT_ERR_IDX        5
-#define _HRT_CSS_RECEIVER_2400_CSI2_MASK_ECC_TWO_BIT_ERR_IDX                  6
-#define _HRT_CSS_RECEIVER_2400_CSI2_MASK_DATA_ID_ERR_IDX                      7
-
-                                  
-/* Bits for CSI2_FUNC_PROG register */
-#define _HRT_CSS_RECEIVER_2400_CSI2_DATA_TIMEOUT_IDX    0
-#define _HRT_CSS_RECEIVER_2400_CSI2_DATA_TIMEOUT_BITS   19
-
-/* Bits for INIT_COUNT register */
-#define _HRT_CSS_RECEIVER_2400_INIT_TIMER_IDX  0
-#define _HRT_CSS_RECEIVER_2400_INIT_TIMER_BITS 16
-
-/* Bits for COUNT registers */
-#define _HRT_CSS_RECEIVER_2400_SYNC_COUNT_IDX     0
-#define _HRT_CSS_RECEIVER_2400_SYNC_COUNT_BITS    8
-#define _HRT_CSS_RECEIVER_2400_RX_COUNT_IDX       0
-#define _HRT_CSS_RECEIVER_2400_RX_COUNT_BITS      8
-
-/* Bits for RAW116_18_DATAID register */
-#define _HRT_CSS_RECEIVER_2400_RAW16_18_DATAID_RAW16_BITS_IDX   0
-#define _HRT_CSS_RECEIVER_2400_RAW16_18_DATAID_RAW16_BITS_BITS  6
-#define _HRT_CSS_RECEIVER_2400_RAW16_18_DATAID_RAW18_BITS_IDX   8
-#define _HRT_CSS_RECEIVER_2400_RAW16_18_DATAID_RAW18_BITS_BITS  6
-
-/* Bits for COMP_FORMAT register, this selects the compression data format */
-#define _HRT_CSS_RECEIVER_2400_COMP_RAW_BITS_IDX  0
-#define _HRT_CSS_RECEIVER_2400_COMP_RAW_BITS_BITS 8
-#define _HRT_CSS_RECEIVER_2400_COMP_NUM_BITS_IDX  (_HRT_CSS_RECEIVER_2400_COMP_RAW_BITS_IDX + _HRT_CSS_RECEIVER_2400_COMP_RAW_BITS_BITS)
-#define _HRT_CSS_RECEIVER_2400_COMP_NUM_BITS_BITS 8
-
-/* Bits for COMP_PREDICT register, this selects the predictor algorithm */
-#define _HRT_CSS_RECEIVER_2400_PREDICT_NO_COMP 0
-#define _HRT_CSS_RECEIVER_2400_PREDICT_1       1
-#define _HRT_CSS_RECEIVER_2400_PREDICT_2       2
-
-/* Number of bits used for the delay registers */
-#define _HRT_CSS_RECEIVER_2400_DELAY_BITS 8
-
-/* Bits for COMP_SCHEME register, this  selects the compression scheme for a VC */
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_USD1_BITS_IDX  0
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_USD2_BITS_IDX  5
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_USD3_BITS_IDX  10
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_USD4_BITS_IDX  15
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_USD5_BITS_IDX  20
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_USD6_BITS_IDX  25
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_USD7_BITS_IDX  0
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_USD8_BITS_IDX  5
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_USD_BITS_BITS  5
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_USD_FMT_BITS_IDX   0
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_USD_FMT_BITS_BITS  3
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_USD_PRED_BITS_IDX  3
-#define _HRT_CSS_RECEIVER_2400_COMP_SCHEME_USD_PRED_BITS_BITS 2
-
-
-/* BITS for backend RAW16 and RAW 18 registers */
-
-#define _HRT_CSS_RECEIVER_2400_RAW18_DATAID_IDX    0
-#define _HRT_CSS_RECEIVER_2400_RAW18_DATAID_BITS   6
-#define _HRT_CSS_RECEIVER_2400_RAW18_OPTION_IDX    6
-#define _HRT_CSS_RECEIVER_2400_RAW18_OPTION_BITS   2
-#define _HRT_CSS_RECEIVER_2400_RAW18_EN_IDX        8
-#define _HRT_CSS_RECEIVER_2400_RAW18_EN_BITS       1
-
-#define _HRT_CSS_RECEIVER_2400_RAW16_DATAID_IDX    0
-#define _HRT_CSS_RECEIVER_2400_RAW16_DATAID_BITS   6
-#define _HRT_CSS_RECEIVER_2400_RAW16_OPTION_IDX    6
-#define _HRT_CSS_RECEIVER_2400_RAW16_OPTION_BITS   2
-#define _HRT_CSS_RECEIVER_2400_RAW16_EN_IDX        8
-#define _HRT_CSS_RECEIVER_2400_RAW16_EN_BITS       1
-
-/* These hsync and vsync values are for HSS simulation only */
-#define _HRT_CSS_RECEIVER_2400_HSYNC_VAL (1<<16)
-#define _HRT_CSS_RECEIVER_2400_VSYNC_VAL (1<<17)
-
-#define _HRT_CSS_RECEIVER_2400_BE_STREAMING_WIDTH                 28
-#define _HRT_CSS_RECEIVER_2400_BE_STREAMING_PIX_A_LSB              0
-#define _HRT_CSS_RECEIVER_2400_BE_STREAMING_PIX_A_MSB             (_HRT_CSS_RECEIVER_2400_BE_STREAMING_PIX_A_LSB + CSS_RECEIVER_DATA_OUT - 1)
-#define _HRT_CSS_RECEIVER_2400_BE_STREAMING_PIX_A_VAL_BIT         (_HRT_CSS_RECEIVER_2400_BE_STREAMING_PIX_A_MSB + 1)
-#define _HRT_CSS_RECEIVER_2400_BE_STREAMING_PIX_B_LSB             (_HRT_CSS_RECEIVER_2400_BE_STREAMING_PIX_A_VAL_BIT + 1)
-#define _HRT_CSS_RECEIVER_2400_BE_STREAMING_PIX_B_MSB             (_HRT_CSS_RECEIVER_2400_BE_STREAMING_PIX_B_LSB + CSS_RECEIVER_DATA_OUT - 1)
-#define _HRT_CSS_RECEIVER_2400_BE_STREAMING_PIX_B_VAL_BIT         (_HRT_CSS_RECEIVER_2400_BE_STREAMING_PIX_B_MSB + 1)
-#define _HRT_CSS_RECEIVER_2400_BE_STREAMING_SOP_BIT               (_HRT_CSS_RECEIVER_2400_BE_STREAMING_PIX_B_VAL_BIT + 1)
-#define _HRT_CSS_RECEIVER_2400_BE_STREAMING_EOP_BIT               (_HRT_CSS_RECEIVER_2400_BE_STREAMING_SOP_BIT + 1)
-
-// SH Backend Register IDs
-#define _HRT_CSS_RECEIVER_2400_BE_GSP_ACC_OVL_REG_IDX              0
-#define _HRT_CSS_RECEIVER_2400_BE_SRST_REG_IDX                     1
-#define _HRT_CSS_RECEIVER_2400_BE_TWO_PPC_REG_IDX                  2
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_FORMAT_REG0_IDX             3
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_FORMAT_REG1_IDX             4
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_FORMAT_REG2_IDX             5
-#define _HRT_CSS_RECEIVER_2400_BE_COMP_FORMAT_REG3_IDX             6
-#define _HRT_CSS_RECEIVER_2400_BE_SEL_REG_IDX                      7
-#define _HRT_CSS_RECEIVER_2400_BE_RAW16_CONFIG_REG_IDX             8
-#define _HRT_CSS_RECEIVER_2400_BE_RAW18_CONFIG_REG_IDX             9
-#define _HRT_CSS_RECEIVER_2400_BE_FORCE_RAW8_REG_IDX              10
-#define _HRT_CSS_RECEIVER_2400_BE_IRQ_STATUS_REG_IDX              11
-#define _HRT_CSS_RECEIVER_2400_BE_IRQ_CLEAR_REG_IDX               12
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_EN_REG_IDX                 13
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_DATA_STATE_REG_IDX         14    /* Data State 0,1,2 config */
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_PIX_EXT_S0P0_REG_IDX       15    /* Pixel Extractor config for Data State 0 & Pix 0 */
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_PIX_EXT_S0P1_REG_IDX       16    /* Pixel Extractor config for Data State 0 & Pix 1 */
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_PIX_EXT_S0P2_REG_IDX       17    /* Pixel Extractor config for Data State 0 & Pix 2 */
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_PIX_EXT_S0P3_REG_IDX       18    /* Pixel Extractor config for Data State 0 & Pix 3 */
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_PIX_EXT_S1P0_REG_IDX       19    /* Pixel Extractor config for Data State 1 & Pix 0 */
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_PIX_EXT_S1P1_REG_IDX       20    /* Pixel Extractor config for Data State 1 & Pix 1 */
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_PIX_EXT_S1P2_REG_IDX       21    /* Pixel Extractor config for Data State 1 & Pix 2 */
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_PIX_EXT_S1P3_REG_IDX       22    /* Pixel Extractor config for Data State 1 & Pix 3 */
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_PIX_EXT_S2P0_REG_IDX       23    /* Pixel Extractor config for Data State 2 & Pix 0 */
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_PIX_EXT_S2P1_REG_IDX       24    /* Pixel Extractor config for Data State 2 & Pix 1 */
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_PIX_EXT_S2P2_REG_IDX       25    /* Pixel Extractor config for Data State 2 & Pix 2 */
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_PIX_EXT_S2P3_REG_IDX       26    /* Pixel Extractor config for Data State 2 & Pix 3 */
-#define _HRT_CSS_RECEIVER_2400_BE_CUST_PIX_VALID_EOP_REG_IDX      27    /* Pixel Valid & EoP config for Pix 0,1,2,3 */
-
-#define _HRT_CSS_RECEIVER_2400_BE_NOF_REGISTERS                   28
-
-#define _HRT_CSS_RECEIVER_2400_BE_SRST_HE                          0
-#define _HRT_CSS_RECEIVER_2400_BE_SRST_RCF                         1
-#define _HRT_CSS_RECEIVER_2400_BE_SRST_PF                          2
-#define _HRT_CSS_RECEIVER_2400_BE_SRST_SM                          3
-#define _HRT_CSS_RECEIVER_2400_BE_SRST_PD                          4
-#define _HRT_CSS_RECEIVER_2400_BE_SRST_SD                          5
-#define _HRT_CSS_RECEIVER_2400_BE_SRST_OT                          6
-#define _HRT_CSS_RECEIVER_2400_BE_SRST_BC                          7
-#define _HRT_CSS_RECEIVER_2400_BE_SRST_WIDTH                       8
-
-#endif /* _css_receiver_2400_defs_h_ */

+ 0 - 36
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/defs.h

@@ -1,36 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _HRT_DEFS_H_
-#define _HRT_DEFS_H_
-
-#ifndef HRTCAT
-#define _HRTCAT(m, n)     m##n
-#define HRTCAT(m, n)      _HRTCAT(m, n)
-#endif
-
-#ifndef HRTSTR
-#define _HRTSTR(x)   #x
-#define HRTSTR(x)    _HRTSTR(x)
-#endif
-
-#ifndef HRTMIN
-#define HRTMIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
-
-#ifndef HRTMAX
-#define HRTMAX(a, b) (((a) > (b)) ? (a) : (b))
-#endif
-
-#endif /* _HRT_DEFS_H_ */

+ 0 - 199
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/dma_v2_defs.h

@@ -1,199 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _dma_v2_defs_h
-#define _dma_v2_defs_h
-
-#define _DMA_V2_NUM_CHANNELS_ID               MaxNumChannels
-#define _DMA_V2_CONNECTIONS_ID                Connections
-#define _DMA_V2_DEV_ELEM_WIDTHS_ID            DevElemWidths
-#define _DMA_V2_DEV_FIFO_DEPTH_ID             DevFifoDepth
-#define _DMA_V2_DEV_FIFO_RD_LAT_ID            DevFifoRdLat
-#define _DMA_V2_DEV_FIFO_LAT_BYPASS_ID        DevFifoRdLatBypass
-#define _DMA_V2_DEV_NO_BURST_ID               DevNoBurst
-#define _DMA_V2_DEV_RD_ACCEPT_ID              DevRdAccept
-#define _DMA_V2_DEV_SRMD_ID                   DevSRMD
-#define _DMA_V2_DEV_HAS_CRUN_ID               CRunMasters
-#define _DMA_V2_CTRL_ACK_FIFO_DEPTH_ID        CtrlAckFifoDepth
-#define _DMA_V2_CMD_FIFO_DEPTH_ID             CommandFifoDepth
-#define _DMA_V2_CMD_FIFO_RD_LAT_ID            CommandFifoRdLat
-#define _DMA_V2_CMD_FIFO_LAT_BYPASS_ID        CommandFifoRdLatBypass
-#define _DMA_V2_NO_PACK_ID                    has_no_pack
-
-#define _DMA_V2_REG_ALIGN                4
-#define _DMA_V2_REG_ADDR_BITS            2
-
-/* Command word */
-#define _DMA_V2_CMD_IDX            0
-#define _DMA_V2_CMD_BITS           6
-#define _DMA_V2_CHANNEL_IDX        (_DMA_V2_CMD_IDX + _DMA_V2_CMD_BITS)
-#define _DMA_V2_CHANNEL_BITS       5
-
-/* The command to set a parameter contains the PARAM field next */
-#define _DMA_V2_PARAM_IDX          (_DMA_V2_CHANNEL_IDX + _DMA_V2_CHANNEL_BITS)
-#define _DMA_V2_PARAM_BITS         4
-
-/* Commands to read, write or init specific blocks contain these
-   three values */
-#define _DMA_V2_SPEC_DEV_A_XB_IDX  (_DMA_V2_CHANNEL_IDX + _DMA_V2_CHANNEL_BITS)
-#define _DMA_V2_SPEC_DEV_A_XB_BITS 8
-#define _DMA_V2_SPEC_DEV_B_XB_IDX  (_DMA_V2_SPEC_DEV_A_XB_IDX + _DMA_V2_SPEC_DEV_A_XB_BITS)
-#define _DMA_V2_SPEC_DEV_B_XB_BITS 8
-#define _DMA_V2_SPEC_YB_IDX        (_DMA_V2_SPEC_DEV_B_XB_IDX + _DMA_V2_SPEC_DEV_B_XB_BITS)
-#define _DMA_V2_SPEC_YB_BITS       (32-_DMA_V2_SPEC_DEV_B_XB_BITS-_DMA_V2_SPEC_DEV_A_XB_BITS-_DMA_V2_CMD_BITS-_DMA_V2_CHANNEL_BITS)
-
-/* */
-#define _DMA_V2_CMD_CTRL_IDX       4
-#define _DMA_V2_CMD_CTRL_BITS      4
-
-/* Packing setup word */
-#define _DMA_V2_CONNECTION_IDX     0
-#define _DMA_V2_CONNECTION_BITS    4
-#define _DMA_V2_EXTENSION_IDX      (_DMA_V2_CONNECTION_IDX + _DMA_V2_CONNECTION_BITS)
-#define _DMA_V2_EXTENSION_BITS     1
-
-/* Elements packing word */
-#define _DMA_V2_ELEMENTS_IDX        0
-#define _DMA_V2_ELEMENTS_BITS       8
-#define _DMA_V2_LEFT_CROPPING_IDX  (_DMA_V2_ELEMENTS_IDX + _DMA_V2_ELEMENTS_BITS)
-#define _DMA_V2_LEFT_CROPPING_BITS  8
-
-#define _DMA_V2_WIDTH_IDX           0
-#define _DMA_V2_WIDTH_BITS         16
-
-#define _DMA_V2_HEIGHT_IDX          0
-#define _DMA_V2_HEIGHT_BITS        16
-
-#define _DMA_V2_STRIDE_IDX          0
-#define _DMA_V2_STRIDE_BITS        32
-
-/* Command IDs */
-#define _DMA_V2_MOVE_B2A_COMMAND                             0      
-#define _DMA_V2_MOVE_B2A_BLOCK_COMMAND                       1      
-#define _DMA_V2_MOVE_B2A_NO_SYNC_CHK_COMMAND                 2      
-#define _DMA_V2_MOVE_B2A_BLOCK_NO_SYNC_CHK_COMMAND           3      
-#define _DMA_V2_MOVE_A2B_COMMAND                             4      
-#define _DMA_V2_MOVE_A2B_BLOCK_COMMAND                       5      
-#define _DMA_V2_MOVE_A2B_NO_SYNC_CHK_COMMAND                 6      
-#define _DMA_V2_MOVE_A2B_BLOCK_NO_SYNC_CHK_COMMAND           7      
-#define _DMA_V2_INIT_A_COMMAND                               8      
-#define _DMA_V2_INIT_A_BLOCK_COMMAND                         9      
-#define _DMA_V2_INIT_A_NO_SYNC_CHK_COMMAND                  10      
-#define _DMA_V2_INIT_A_BLOCK_NO_SYNC_CHK_COMMAND            11      
-#define _DMA_V2_INIT_B_COMMAND                              12      
-#define _DMA_V2_INIT_B_BLOCK_COMMAND                        13      
-#define _DMA_V2_INIT_B_NO_SYNC_CHK_COMMAND                  14      
-#define _DMA_V2_INIT_B_BLOCK_NO_SYNC_CHK_COMMAND            15      
-#define _DMA_V2_NO_ACK_MOVE_B2A_NO_SYNC_CHK_COMMAND         (_DMA_V2_MOVE_B2A_NO_SYNC_CHK_COMMAND       + 16) 
-#define _DMA_V2_NO_ACK_MOVE_B2A_BLOCK_NO_SYNC_CHK_COMMAND   (_DMA_V2_MOVE_B2A_BLOCK_NO_SYNC_CHK_COMMAND + 16) 
-#define _DMA_V2_NO_ACK_MOVE_A2B_NO_SYNC_CHK_COMMAND         (_DMA_V2_MOVE_A2B_NO_SYNC_CHK_COMMAND       + 16) 
-#define _DMA_V2_NO_ACK_MOVE_A2B_BLOCK_NO_SYNC_CHK_COMMAND   (_DMA_V2_MOVE_A2B_BLOCK_NO_SYNC_CHK_COMMAND + 16) 
-#define _DMA_V2_NO_ACK_INIT_A_NO_SYNC_CHK_COMMAND           (_DMA_V2_INIT_A_NO_SYNC_CHK_COMMAND         + 16) 
-#define _DMA_V2_NO_ACK_INIT_A_BLOCK_NO_SYNC_CHK_COMMAND     (_DMA_V2_INIT_A_BLOCK_NO_SYNC_CHK_COMMAND   + 16) 
-#define _DMA_V2_NO_ACK_INIT_B_NO_SYNC_CHK_COMMAND           (_DMA_V2_INIT_B_NO_SYNC_CHK_COMMAND         + 16) 
-#define _DMA_V2_NO_ACK_INIT_B_BLOCK_NO_SYNC_CHK_COMMAND     (_DMA_V2_INIT_B_BLOCK_NO_SYNC_CHK_COMMAND   + 16) 
-#define _DMA_V2_CONFIG_CHANNEL_COMMAND                      32   
-#define _DMA_V2_SET_CHANNEL_PARAM_COMMAND                   33   
-#define _DMA_V2_SET_CRUN_COMMAND                            62   
-
-/* Channel Parameter IDs */
-#define _DMA_V2_PACKING_SETUP_PARAM                     0  
-#define _DMA_V2_STRIDE_A_PARAM                          1  
-#define _DMA_V2_ELEM_CROPPING_A_PARAM                   2  
-#define _DMA_V2_WIDTH_A_PARAM                           3  
-#define _DMA_V2_STRIDE_B_PARAM                          4  
-#define _DMA_V2_ELEM_CROPPING_B_PARAM                   5  
-#define _DMA_V2_WIDTH_B_PARAM                           6  
-#define _DMA_V2_HEIGHT_PARAM                            7  
-#define _DMA_V2_QUEUED_CMDS                             8  
-
-/* Parameter Constants */
-#define _DMA_V2_ZERO_EXTEND                             0
-#define _DMA_V2_SIGN_EXTEND                             1
-
-  /* SLAVE address map */
-#define _DMA_V2_SEL_FSM_CMD                             0
-#define _DMA_V2_SEL_CH_REG                              1
-#define _DMA_V2_SEL_CONN_GROUP                          2
-#define _DMA_V2_SEL_DEV_INTERF                          3
-
-#define _DMA_V2_ADDR_SEL_COMP_IDX                      12
-#define _DMA_V2_ADDR_SEL_COMP_BITS                      4
-#define _DMA_V2_ADDR_SEL_CH_REG_IDX                     2
-#define _DMA_V2_ADDR_SEL_CH_REG_BITS                    6
-#define _DMA_V2_ADDR_SEL_PARAM_IDX                      (_DMA_V2_ADDR_SEL_CH_REG_BITS+_DMA_V2_ADDR_SEL_CH_REG_IDX)
-#define _DMA_V2_ADDR_SEL_PARAM_BITS                     4
-
-#define _DMA_V2_ADDR_SEL_GROUP_COMP_IDX                 2
-#define _DMA_V2_ADDR_SEL_GROUP_COMP_BITS                6
-#define _DMA_V2_ADDR_SEL_GROUP_COMP_INFO_IDX            (_DMA_V2_ADDR_SEL_GROUP_COMP_BITS + _DMA_V2_ADDR_SEL_GROUP_COMP_IDX)
-#define _DMA_V2_ADDR_SEL_GROUP_COMP_INFO_BITS           4
-
-#define _DMA_V2_ADDR_SEL_DEV_INTERF_IDX_IDX             2
-#define _DMA_V2_ADDR_SEL_DEV_INTERF_IDX_BITS            6
-#define _DMA_V2_ADDR_SEL_DEV_INTERF_INFO_IDX            (_DMA_V2_ADDR_SEL_DEV_INTERF_IDX_IDX+_DMA_V2_ADDR_SEL_DEV_INTERF_IDX_BITS)
-#define _DMA_V2_ADDR_SEL_DEV_INTERF_INFO_BITS           4
-
-#define _DMA_V2_FSM_GROUP_CMD_IDX                       0
-#define _DMA_V2_FSM_GROUP_ADDR_SRC_IDX                  1
-#define _DMA_V2_FSM_GROUP_ADDR_DEST_IDX                 2
-#define _DMA_V2_FSM_GROUP_CMD_CTRL_IDX                  3
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_IDX                  4
-#define _DMA_V2_FSM_GROUP_FSM_PACK_IDX                  5
-#define _DMA_V2_FSM_GROUP_FSM_REQ_IDX                   6
-#define _DMA_V2_FSM_GROUP_FSM_WR_IDX                    7
-  
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_STATE_IDX            0
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_REQ_DEV_IDX          1
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_REQ_ADDR_IDX         2
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_REQ_STRIDE_IDX       3
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_REQ_XB_IDX           4
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_REQ_YB_IDX           5
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_PACK_REQ_DEV_IDX     6
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_PACK_WR_DEV_IDX      7
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_WR_ADDR_IDX          8
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_WR_STRIDE_IDX        9
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_PACK_REQ_XB_IDX     10
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_PACK_WR_YB_IDX      11
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_PACK_WR_XB_IDX      12
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_PACK_ELEM_REQ_IDX   13
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_PACK_ELEM_WR_IDX    14
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_PACK_S_Z_IDX        15
-#define _DMA_V2_FSM_GROUP_FSM_CTRL_CMD_CTRL_IDX        15
-
-#define _DMA_V2_FSM_GROUP_FSM_PACK_STATE_IDX            0
-#define _DMA_V2_FSM_GROUP_FSM_PACK_CNT_YB_IDX           1
-#define _DMA_V2_FSM_GROUP_FSM_PACK_CNT_XB_REQ_IDX       2
-#define _DMA_V2_FSM_GROUP_FSM_PACK_CNT_XB_WR_IDX        3
-
-#define _DMA_V2_FSM_GROUP_FSM_REQ_STATE_IDX             0
-#define _DMA_V2_FSM_GROUP_FSM_REQ_CNT_YB_IDX            1
-#define _DMA_V2_FSM_GROUP_FSM_REQ_CNT_XB_IDX            2
-#define _DMA_V2_FSM_GROUP_FSM_REQ_XB_REMAINING_IDX      3
-#define _DMA_V2_FSM_GROUP_FSM_REQ_CNT_BURST_IDX         4
-
-#define _DMA_V2_FSM_GROUP_FSM_WR_STATE_IDX              0
-#define _DMA_V2_FSM_GROUP_FSM_WR_CNT_YB_IDX             1
-#define _DMA_V2_FSM_GROUP_FSM_WR_CNT_XB_IDX             2
-#define _DMA_V2_FSM_GROUP_FSM_WR_XB_REMAINING_IDX       3
-#define _DMA_V2_FSM_GROUP_FSM_WR_CNT_BURST_IDX          4
-
-#define _DMA_V2_DEV_INTERF_REQ_SIDE_STATUS_IDX          0
-#define _DMA_V2_DEV_INTERF_SEND_SIDE_STATUS_IDX         1
-#define _DMA_V2_DEV_INTERF_FIFO_STATUS_IDX              2
-#define _DMA_V2_DEV_INTERF_REQ_ONLY_COMPLETE_BURST_IDX  3
-#define _DMA_V2_DEV_INTERF_MAX_BURST_IDX                4
-#define _DMA_V2_DEV_INTERF_CHK_ADDR_ALIGN               5
-
-#endif /* _dma_v2_defs_h */

+ 0 - 170
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/gdc_v2_defs.h

@@ -1,170 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 HRT_GDC_v2_defs_h_
-#define HRT_GDC_v2_defs_h_
-
-#define HRT_GDC_IS_V2
-
-#define HRT_GDC_N                     1024 /* Top-level design constant, equal to the number of entries in the LUT      */
-#define HRT_GDC_FRAC_BITS               10 /* Number of fractional bits in the GDC block, driven by the size of the LUT */
-
-#define HRT_GDC_BLI_FRAC_BITS            4 /* Number of fractional bits for the bi-linear interpolation type            */
-#define HRT_GDC_BLI_COEF_ONE             (1 << HRT_GDC_BLI_FRAC_BITS)
-
-#define HRT_GDC_BCI_COEF_BITS           14 /* 14 bits per coefficient                                                   */
-#define HRT_GDC_BCI_COEF_ONE             (1 << (HRT_GDC_BCI_COEF_BITS-2))  /* We represent signed 10 bit coefficients.  */
-                                                                        /* The supported range is [-256, .., +256]      */
-                                                                        /* in 14-bit signed notation,                   */
-                                                                        /* We need all ten bits (MSB must be zero).     */
-                                                                        /* -s is inserted to solve this issue, and      */
-                                                                        /* therefore "1" is equal to +256.              */
-#define HRT_GDC_BCI_COEF_MASK            ((1 << HRT_GDC_BCI_COEF_BITS) - 1) 
-
-#define HRT_GDC_LUT_BYTES                (HRT_GDC_N*4*2)                /* 1024 addresses, 4 coefficients per address,  */
-                                                                        /* 2 bytes per coefficient                      */
-
-#define _HRT_GDC_REG_ALIGN               4                              
-
-  //     31  30  29    25 24                     0
-  //  |-----|---|--------|------------------------|
-  //  | CMD | C | Reg_ID |        Value           |
-
-
-  // There are just two commands possible for the GDC block:
-  // 1 - Configure reg 
-  // 0 - Data token    
-  
-  // C      - Reserved bit
-  //          Used in protocol to indicate whether it is C-run or other type of runs
-  //          In case of C-run, this bit has a value of 1, for all the other runs, it is 0.
-
-  // Reg_ID - Address of the register to be configured
-  
-  // Value  - Value to store to the addressed register, maximum of 24 bits
-
-  // Configure reg command is not followed by any other token. 
-  // The address of the register and the data to be filled in is contained in the same token 
-  
-  // When the first data token is received, it must be:
-  //   1. FRX and FRY (device configured in one of the  scaling modes) ***DEFAULT MODE***, or,
-  //   2. P0'X        (device configured in one of the tetragon modes)
-  // After the first data token is received, pre-defined number of tokens with the following meaning follow:
-  //   1. two  tokens: SRC address ; DST address
-  //   2. nine tokens: P0'Y, .., P3'Y ; SRC address ; DST address
-  
-#define HRT_GDC_CONFIG_CMD             1
-#define HRT_GDC_DATA_CMD               0
-
-
-#define HRT_GDC_CMD_POS               31
-#define HRT_GDC_CMD_BITS               1
-#define HRT_GDC_CRUN_POS              30
-#define HRT_GDC_REG_ID_POS            25
-#define HRT_GDC_REG_ID_BITS            5
-#define HRT_GDC_DATA_POS               0
-#define HRT_GDC_DATA_BITS             25
-
-#define HRT_GDC_FRYIPXFRX_BITS        26
-#define HRT_GDC_P0X_BITS              23
-
-
-#define HRT_GDC_MAX_OXDIM           (8192-64)
-#define HRT_GDC_MAX_OYDIM           4095
-#define HRT_GDC_MAX_IXDIM           (8192-64)
-#define HRT_GDC_MAX_IYDIM           4095
-#define HRT_GDC_MAX_DS_FAC            16
-#define HRT_GDC_MAX_DX                 (HRT_GDC_MAX_DS_FAC*HRT_GDC_N - 1)
-#define HRT_GDC_MAX_DY                 HRT_GDC_MAX_DX
-
-
-/* GDC lookup tables entries are 10 bits values, but they're
-   stored 2 by 2 as 32 bit values, yielding 16 bits per entry.
-   A GDC lookup table contains 64 * 4 elements */
-
-#define HRT_GDC_PERF_1_1_pix          0
-#define HRT_GDC_PERF_2_1_pix          1
-#define HRT_GDC_PERF_1_2_pix          2
-#define HRT_GDC_PERF_2_2_pix          3
-
-#define HRT_GDC_NND_MODE              0
-#define HRT_GDC_BLI_MODE              1
-#define HRT_GDC_BCI_MODE              2
-#define HRT_GDC_LUT_MODE              3
-
-#define HRT_GDC_SCAN_STB              0
-#define HRT_GDC_SCAN_STR              1
-
-#define HRT_GDC_MODE_SCALING          0
-#define HRT_GDC_MODE_TETRAGON         1
-
-#define HRT_GDC_LUT_COEFF_OFFSET     16 
-#define HRT_GDC_FRY_BIT_OFFSET       16 
-// FRYIPXFRX is the only register where we store two values in one field, 
-// to save one token in the scaling protocol. 
-// Like this, we have three tokens in the scaling protocol, 
-// Otherwise, we would have had four.
-// The register bit-map is:
-//   31  26 25      16 15  10 9        0
-//  |------|----------|------|----------|
-//  | XXXX |   FRY    |  IPX |   FRX    |
-
-
-#define HRT_GDC_CE_FSM0_POS           0
-#define HRT_GDC_CE_FSM0_LEN           2
-#define HRT_GDC_CE_OPY_POS            2
-#define HRT_GDC_CE_OPY_LEN           14
-#define HRT_GDC_CE_OPX_POS           16
-#define HRT_GDC_CE_OPX_LEN           16
-// CHK_ENGINE register bit-map:
-//   31            16 15        2 1  0
-//  |----------------|-----------|----|
-//  |      OPX       |    OPY    |FSM0|
-// However, for the time being at least, 
-// this implementation is meaningless in hss model,
-// So, we just return 0
-
-
-#define HRT_GDC_CHK_ENGINE_IDX        0
-#define HRT_GDC_WOIX_IDX              1
-#define HRT_GDC_WOIY_IDX              2
-#define HRT_GDC_BPP_IDX               3
-#define HRT_GDC_FRYIPXFRX_IDX         4
-#define HRT_GDC_OXDIM_IDX             5
-#define HRT_GDC_OYDIM_IDX             6
-#define HRT_GDC_SRC_ADDR_IDX          7
-#define HRT_GDC_SRC_END_ADDR_IDX      8
-#define HRT_GDC_SRC_WRAP_ADDR_IDX     9
-#define HRT_GDC_SRC_STRIDE_IDX       10
-#define HRT_GDC_DST_ADDR_IDX         11
-#define HRT_GDC_DST_STRIDE_IDX       12
-#define HRT_GDC_DX_IDX               13
-#define HRT_GDC_DY_IDX               14
-#define HRT_GDC_P0X_IDX              15
-#define HRT_GDC_P0Y_IDX              16
-#define HRT_GDC_P1X_IDX              17
-#define HRT_GDC_P1Y_IDX              18
-#define HRT_GDC_P2X_IDX              19
-#define HRT_GDC_P2Y_IDX              20
-#define HRT_GDC_P3X_IDX              21
-#define HRT_GDC_P3Y_IDX              22
-#define HRT_GDC_PERF_POINT_IDX       23  // 1x1 ; 1x2 ; 2x1 ; 2x2 pixels per cc
-#define HRT_GDC_INTERP_TYPE_IDX      24  // NND ; BLI ; BCI ; LUT
-#define HRT_GDC_SCAN_IDX             25  // 0 = STB (Slide To Bottom) ; 1 = STR (Slide To Right)
-#define HRT_GDC_PROC_MODE_IDX        26  // 0 = Scaling ; 1 = Tetragon
-
-#define HRT_GDC_LUT_IDX              32
-
-
-#endif /* HRT_GDC_v2_defs_h_ */

+ 0 - 36
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/gp_timer_defs.h

@@ -1,36 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _gp_timer_defs_h
-#define _gp_timer_defs_h
-
-#define _HRT_GP_TIMER_REG_ALIGN 4
-
-#define HIVE_GP_TIMER_RESET_REG_IDX                              0
-#define HIVE_GP_TIMER_OVERALL_ENABLE_REG_IDX                     1
-#define HIVE_GP_TIMER_ENABLE_REG_IDX(timer)                     (HIVE_GP_TIMER_OVERALL_ENABLE_REG_IDX + 1 + timer)
-#define HIVE_GP_TIMER_VALUE_REG_IDX(timer,timers)               (HIVE_GP_TIMER_ENABLE_REG_IDX(timers) + timer)
-#define HIVE_GP_TIMER_COUNT_TYPE_REG_IDX(timer,timers)          (HIVE_GP_TIMER_VALUE_REG_IDX(timers, timers) + timer)
-#define HIVE_GP_TIMER_SIGNAL_SELECT_REG_IDX(timer,timers)       (HIVE_GP_TIMER_COUNT_TYPE_REG_IDX(timers, timers) + timer)
-#define HIVE_GP_TIMER_IRQ_TRIGGER_VALUE_REG_IDX(irq,timers)     (HIVE_GP_TIMER_SIGNAL_SELECT_REG_IDX(timers, timers) + irq)
-#define HIVE_GP_TIMER_IRQ_TIMER_SELECT_REG_IDX(irq,timers,irqs) (HIVE_GP_TIMER_IRQ_TRIGGER_VALUE_REG_IDX(irqs, timers) + irq)
-#define HIVE_GP_TIMER_IRQ_ENABLE_REG_IDX(irq,timers,irqs)       (HIVE_GP_TIMER_IRQ_TIMER_SELECT_REG_IDX(irqs, timers, irqs) + irq)
-
-#define HIVE_GP_TIMER_COUNT_TYPE_HIGH                            0
-#define HIVE_GP_TIMER_COUNT_TYPE_LOW                             1
-#define HIVE_GP_TIMER_COUNT_TYPE_POSEDGE                         2
-#define HIVE_GP_TIMER_COUNT_TYPE_NEGEDGE                         3
-#define HIVE_GP_TIMER_COUNT_TYPES                                4
-
-#endif /* _gp_timer_defs_h */   

+ 0 - 42
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/gpio_block_defs.h

@@ -1,42 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _gpio_block_defs_h_
-#define _gpio_block_defs_h_
-
-#define _HRT_GPIO_BLOCK_REG_ALIGN 4
-
-/* R/W registers */
-#define _gpio_block_reg_do_e			         0
-#define _gpio_block_reg_do_select		       1
-#define _gpio_block_reg_do_0			         2
-#define _gpio_block_reg_do_1			         3
-#define _gpio_block_reg_do_pwm_cnt_0	     4
-#define _gpio_block_reg_do_pwm_cnt_1	     5
-#define _gpio_block_reg_do_pwm_cnt_2	     6
-#define _gpio_block_reg_do_pwm_cnt_3	     7
-#define _gpio_block_reg_do_pwm_main_cnt    8
-#define _gpio_block_reg_do_pwm_enable      9
-#define _gpio_block_reg_di_debounce_sel	  10
-#define _gpio_block_reg_di_debounce_cnt_0	11
-#define _gpio_block_reg_di_debounce_cnt_1	12
-#define _gpio_block_reg_di_debounce_cnt_2	13
-#define _gpio_block_reg_di_debounce_cnt_3	14
-#define _gpio_block_reg_di_active_level	  15
-
-
-/* read-only registers */
-#define _gpio_block_reg_di			          16
-
-#endif /* _gpio_block_defs_h_ */

+ 0 - 416
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/hive_isp_css_defs.h

@@ -1,416 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _hive_isp_css_defs_h__
-#define _hive_isp_css_defs_h__
-
-#define HIVE_ISP_CSS_IS_2400B0_SYSTEM
-
-#define HIVE_ISP_CTRL_DATA_WIDTH     32
-#define HIVE_ISP_CTRL_ADDRESS_WIDTH  32
-#define HIVE_ISP_CTRL_MAX_BURST_SIZE  1
-#define HIVE_ISP_DDR_ADDRESS_WIDTH   36
-
-#define HIVE_ISP_HOST_MAX_BURST_SIZE  8 /* host supports bursts in order to prevent repeating DDRAM accesses */
-#define HIVE_ISP_NUM_GPIO_PINS       12
-
-/* This list of vector num_elems/elem_bits pairs is valid both in C as initializer
-   and in the DMA parameter list */
-#define HIVE_ISP_DDR_DMA_SPECS {{32,  8}, {16, 16}, {18, 14}, {25, 10}, {21, 12}}
-#define HIVE_ISP_DDR_WORD_BITS 256
-#define HIVE_ISP_DDR_WORD_BYTES  (HIVE_ISP_DDR_WORD_BITS/8)
-#define HIVE_ISP_DDR_BYTES       (512 * 1024 * 1024) /* hss only */
-#define HIVE_ISP_DDR_BYTES_RTL   (127 * 1024 * 1024) /* RTL only */
-#define HIVE_ISP_DDR_SMALL_BYTES (128 * 256 / 8)
-#define HIVE_ISP_PAGE_SHIFT    12
-#define HIVE_ISP_PAGE_SIZE     (1<<HIVE_ISP_PAGE_SHIFT)
-
-#define CSS_DDR_WORD_BITS        HIVE_ISP_DDR_WORD_BITS
-#define CSS_DDR_WORD_BYTES       HIVE_ISP_DDR_WORD_BYTES
-
-/* If HIVE_ISP_DDR_BASE_OFFSET is set to a non-zero value, the wide bus just before the DDRAM gets an extra dummy port where         */
-/* address range 0 .. HIVE_ISP_DDR_BASE_OFFSET-1 maps onto. This effectively creates an offset for the DDRAM from system perspective */
-#define HIVE_ISP_DDR_BASE_OFFSET 0x120000000 /* 0x200000 */
-
-#define HIVE_DMA_ISP_BUS_CONN 0
-#define HIVE_DMA_ISP_DDR_CONN 1
-#define HIVE_DMA_BUS_DDR_CONN 2
-#define HIVE_DMA_ISP_MASTER master_port0
-#define HIVE_DMA_BUS_MASTER master_port1
-#define HIVE_DMA_DDR_MASTER master_port2
-
-#define HIVE_DMA_NUM_CHANNELS       32 /* old value was  8 */
-#define HIVE_DMA_CMD_FIFO_DEPTH     24 /* old value was 12 */
-
-#define HIVE_IF_PIXEL_WIDTH 12
-
-#define HIVE_MMU_TLB_SETS           8
-#define HIVE_MMU_TLB_SET_BLOCKS     8
-#define HIVE_MMU_TLB_BLOCK_ELEMENTS 8
-#define HIVE_MMU_PAGE_TABLE_LEVELS  2
-#define HIVE_MMU_PAGE_BYTES         HIVE_ISP_PAGE_SIZE
-
-#define HIVE_ISP_CH_ID_BITS    2
-#define HIVE_ISP_FMT_TYPE_BITS 5
-#define HIVE_ISP_ISEL_SEL_BITS 2
-
-#define HIVE_GP_REGS_SDRAM_WAKEUP_IDX                           0
-#define HIVE_GP_REGS_IDLE_IDX                                   1
-#define HIVE_GP_REGS_IRQ_0_IDX                                  2
-#define HIVE_GP_REGS_IRQ_1_IDX                                  3
-#define HIVE_GP_REGS_SP_STREAM_STAT_IDX                         4
-#define HIVE_GP_REGS_SP_STREAM_STAT_B_IDX                       5
-#define HIVE_GP_REGS_ISP_STREAM_STAT_IDX                        6
-#define HIVE_GP_REGS_MOD_STREAM_STAT_IDX                        7
-#define HIVE_GP_REGS_SP_STREAM_STAT_IRQ_COND_IDX                8
-#define HIVE_GP_REGS_SP_STREAM_STAT_B_IRQ_COND_IDX              9
-#define HIVE_GP_REGS_ISP_STREAM_STAT_IRQ_COND_IDX              10
-#define HIVE_GP_REGS_MOD_STREAM_STAT_IRQ_COND_IDX              11
-#define HIVE_GP_REGS_SP_STREAM_STAT_IRQ_ENABLE_IDX             12
-#define HIVE_GP_REGS_SP_STREAM_STAT_B_IRQ_ENABLE_IDX           13
-#define HIVE_GP_REGS_ISP_STREAM_STAT_IRQ_ENABLE_IDX            14
-#define HIVE_GP_REGS_MOD_STREAM_STAT_IRQ_ENABLE_IDX            15
-#define HIVE_GP_REGS_SWITCH_PRIM_IF_IDX                        16
-#define HIVE_GP_REGS_SWITCH_GDC1_IDX                           17
-#define HIVE_GP_REGS_SWITCH_GDC2_IDX                           18
-#define HIVE_GP_REGS_SRST_IDX                                  19
-#define HIVE_GP_REGS_SLV_REG_SRST_IDX                          20
-#define HIVE_GP_REGS_VISA_REG_IDX                              21
-
-/* Bit numbers of the soft reset register */
-#define HIVE_GP_REGS_SRST_ISYS_CBUS                             0
-#define HIVE_GP_REGS_SRST_ISEL_CBUS                             1
-#define HIVE_GP_REGS_SRST_IFMT_CBUS                             2
-#define HIVE_GP_REGS_SRST_GPDEV_CBUS                            3
-#define HIVE_GP_REGS_SRST_GPIO                                  4
-#define HIVE_GP_REGS_SRST_TC                                    5
-#define HIVE_GP_REGS_SRST_GPTIMER                               6
-#define HIVE_GP_REGS_SRST_FACELLFIFOS                           7
-#define HIVE_GP_REGS_SRST_D_OSYS                                8
-#define HIVE_GP_REGS_SRST_IFT_SEC_PIPE                          9
-#define HIVE_GP_REGS_SRST_GDC1                                 10
-#define HIVE_GP_REGS_SRST_GDC2                                 11
-#define HIVE_GP_REGS_SRST_VEC_BUS                              12
-#define HIVE_GP_REGS_SRST_ISP                                  13
-#define HIVE_GP_REGS_SRST_SLV_GRP_BUS                          14
-#define HIVE_GP_REGS_SRST_DMA                                  15
-#define HIVE_GP_REGS_SRST_SF_ISP_SP                            16
-#define HIVE_GP_REGS_SRST_SF_PIF_CELLS                         17
-#define HIVE_GP_REGS_SRST_SF_SIF_SP                            18
-#define HIVE_GP_REGS_SRST_SF_MC_SP                             19
-#define HIVE_GP_REGS_SRST_SF_ISYS_SP                           20
-#define HIVE_GP_REGS_SRST_SF_DMA_CELLS                         21
-#define HIVE_GP_REGS_SRST_SF_GDC1_CELLS                        22
-#define HIVE_GP_REGS_SRST_SF_GDC2_CELLS                        23
-#define HIVE_GP_REGS_SRST_SP                                   24
-#define HIVE_GP_REGS_SRST_OCP2CIO                              25
-#define HIVE_GP_REGS_SRST_NBUS                                 26
-#define HIVE_GP_REGS_SRST_HOST12BUS                            27
-#define HIVE_GP_REGS_SRST_WBUS                                 28
-#define HIVE_GP_REGS_SRST_IC_OSYS                              29
-#define HIVE_GP_REGS_SRST_WBUS_IC                              30
-
-/* Bit numbers of the slave register soft reset register */
-#define HIVE_GP_REGS_SLV_REG_SRST_DMA                           0
-#define HIVE_GP_REGS_SLV_REG_SRST_GDC1                          1
-#define HIVE_GP_REGS_SLV_REG_SRST_GDC2                          2
-
-/* order of the input bits for the irq controller */
-#define HIVE_GP_DEV_IRQ_GPIO_PIN_0_BIT_ID                       0
-#define HIVE_GP_DEV_IRQ_GPIO_PIN_1_BIT_ID                       1
-#define HIVE_GP_DEV_IRQ_GPIO_PIN_2_BIT_ID                       2
-#define HIVE_GP_DEV_IRQ_GPIO_PIN_3_BIT_ID                       3
-#define HIVE_GP_DEV_IRQ_GPIO_PIN_4_BIT_ID                       4
-#define HIVE_GP_DEV_IRQ_GPIO_PIN_5_BIT_ID                       5
-#define HIVE_GP_DEV_IRQ_GPIO_PIN_6_BIT_ID                       6
-#define HIVE_GP_DEV_IRQ_GPIO_PIN_7_BIT_ID                       7
-#define HIVE_GP_DEV_IRQ_GPIO_PIN_8_BIT_ID                       8
-#define HIVE_GP_DEV_IRQ_GPIO_PIN_9_BIT_ID                       9
-#define HIVE_GP_DEV_IRQ_GPIO_PIN_10_BIT_ID                     10
-#define HIVE_GP_DEV_IRQ_GPIO_PIN_11_BIT_ID                     11
-#define HIVE_GP_DEV_IRQ_SP_BIT_ID                              12
-#define HIVE_GP_DEV_IRQ_ISP_BIT_ID                             13
-#define HIVE_GP_DEV_IRQ_ISYS_BIT_ID                            14
-#define HIVE_GP_DEV_IRQ_ISEL_BIT_ID                            15
-#define HIVE_GP_DEV_IRQ_IFMT_BIT_ID                            16
-#define HIVE_GP_DEV_IRQ_SP_STREAM_MON_BIT_ID                   17
-#define HIVE_GP_DEV_IRQ_ISP_STREAM_MON_BIT_ID                  18
-#define HIVE_GP_DEV_IRQ_MOD_STREAM_MON_BIT_ID                  19
-#define HIVE_GP_DEV_IRQ_ISP_PMEM_ERROR_BIT_ID                  20
-#define HIVE_GP_DEV_IRQ_ISP_BAMEM_ERROR_BIT_ID                 21
-#define HIVE_GP_DEV_IRQ_ISP_DMEM_ERROR_BIT_ID                  22
-#define HIVE_GP_DEV_IRQ_SP_ICACHE_MEM_ERROR_BIT_ID             23
-#define HIVE_GP_DEV_IRQ_SP_DMEM_ERROR_BIT_ID                   24
-#define HIVE_GP_DEV_IRQ_MMU_CACHE_MEM_ERROR_BIT_ID             25
-#define HIVE_GP_DEV_IRQ_GP_TIMER_0_BIT_ID                      26
-#define HIVE_GP_DEV_IRQ_GP_TIMER_1_BIT_ID                      27
-#define HIVE_GP_DEV_IRQ_SW_PIN_0_BIT_ID                        28
-#define HIVE_GP_DEV_IRQ_SW_PIN_1_BIT_ID                        29
-#define HIVE_GP_DEV_IRQ_DMA_BIT_ID                             30
-#define HIVE_GP_DEV_IRQ_SP_STREAM_MON_B_BIT_ID                 31
-
-#define HIVE_GP_REGS_NUM_SW_IRQ_REGS                            2
-
-/* order of the input bits for the timed controller */
-#define HIVE_GP_DEV_TC_GPIO_PIN_0_BIT_ID                       0
-#define HIVE_GP_DEV_TC_GPIO_PIN_1_BIT_ID                       1
-#define HIVE_GP_DEV_TC_GPIO_PIN_2_BIT_ID                       2
-#define HIVE_GP_DEV_TC_GPIO_PIN_3_BIT_ID                       3
-#define HIVE_GP_DEV_TC_GPIO_PIN_4_BIT_ID                       4
-#define HIVE_GP_DEV_TC_GPIO_PIN_5_BIT_ID                       5
-#define HIVE_GP_DEV_TC_GPIO_PIN_6_BIT_ID                       6
-#define HIVE_GP_DEV_TC_GPIO_PIN_7_BIT_ID                       7
-#define HIVE_GP_DEV_TC_GPIO_PIN_8_BIT_ID                       8
-#define HIVE_GP_DEV_TC_GPIO_PIN_9_BIT_ID                       9
-#define HIVE_GP_DEV_TC_GPIO_PIN_10_BIT_ID                     10
-#define HIVE_GP_DEV_TC_GPIO_PIN_11_BIT_ID                     11
-#define HIVE_GP_DEV_TC_SP_BIT_ID                              12
-#define HIVE_GP_DEV_TC_ISP_BIT_ID                             13
-#define HIVE_GP_DEV_TC_ISYS_BIT_ID                            14
-#define HIVE_GP_DEV_TC_ISEL_BIT_ID                            15
-#define HIVE_GP_DEV_TC_IFMT_BIT_ID                            16
-#define HIVE_GP_DEV_TC_GP_TIMER_0_BIT_ID                      17
-#define HIVE_GP_DEV_TC_GP_TIMER_1_BIT_ID                      18
-#define HIVE_GP_DEV_TC_MIPI_SOL_BIT_ID                        19
-#define HIVE_GP_DEV_TC_MIPI_EOL_BIT_ID                        20
-#define HIVE_GP_DEV_TC_MIPI_SOF_BIT_ID                        21
-#define HIVE_GP_DEV_TC_MIPI_EOF_BIT_ID                        22
-#define HIVE_GP_DEV_TC_INPSYS_SM                              23
-
-/* definitions for the gp_timer block */
-#define HIVE_GP_TIMER_0                                         0
-#define HIVE_GP_TIMER_1                                         1
-#define HIVE_GP_TIMER_2                                         2
-#define HIVE_GP_TIMER_3                                         3
-#define HIVE_GP_TIMER_4                                         4
-#define HIVE_GP_TIMER_5                                         5
-#define HIVE_GP_TIMER_6                                         6
-#define HIVE_GP_TIMER_7                                         7
-#define HIVE_GP_TIMER_NUM_COUNTERS                              8
-
-#define HIVE_GP_TIMER_IRQ_0                                     0
-#define HIVE_GP_TIMER_IRQ_1                                     1
-#define HIVE_GP_TIMER_NUM_IRQS                                  2
-
-#define HIVE_GP_TIMER_GPIO_0_BIT_ID                             0
-#define HIVE_GP_TIMER_GPIO_1_BIT_ID                             1
-#define HIVE_GP_TIMER_GPIO_2_BIT_ID                             2
-#define HIVE_GP_TIMER_GPIO_3_BIT_ID                             3
-#define HIVE_GP_TIMER_GPIO_4_BIT_ID                             4
-#define HIVE_GP_TIMER_GPIO_5_BIT_ID                             5
-#define HIVE_GP_TIMER_GPIO_6_BIT_ID                             6
-#define HIVE_GP_TIMER_GPIO_7_BIT_ID                             7
-#define HIVE_GP_TIMER_GPIO_8_BIT_ID                             8
-#define HIVE_GP_TIMER_GPIO_9_BIT_ID                             9
-#define HIVE_GP_TIMER_GPIO_10_BIT_ID                           10
-#define HIVE_GP_TIMER_GPIO_11_BIT_ID                           11
-#define HIVE_GP_TIMER_INP_SYS_IRQ                              12
-#define HIVE_GP_TIMER_ISEL_IRQ                                 13
-#define HIVE_GP_TIMER_IFMT_IRQ                                 14
-#define HIVE_GP_TIMER_SP_STRMON_IRQ                            15
-#define HIVE_GP_TIMER_SP_B_STRMON_IRQ                          16
-#define HIVE_GP_TIMER_ISP_STRMON_IRQ                           17
-#define HIVE_GP_TIMER_MOD_STRMON_IRQ                           18
-#define HIVE_GP_TIMER_ISP_PMEM_ERROR_IRQ                       19
-#define HIVE_GP_TIMER_ISP_BAMEM_ERROR_IRQ                      20
-#define HIVE_GP_TIMER_ISP_DMEM_ERROR_IRQ                       21
-#define HIVE_GP_TIMER_SP_ICACHE_MEM_ERROR_IRQ                  22
-#define HIVE_GP_TIMER_SP_DMEM_ERROR_IRQ                        23
-#define HIVE_GP_TIMER_SP_OUT_RUN_DP                            24
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I0_I0         25
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I0_I1         26
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I0_I2         27
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I0_I3         28
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I0_I4         29
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I0_I5         30
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I0_I6         31
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I0_I7         32
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I0_I8         33
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I0_I9         34
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I0_I10        35
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I1_I0         36
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I2_I0         37
-#define HIVE_GP_TIMER_SP_WIRE_DEBUG_LM_MSINK_RUN_I3_I0         38
-#define HIVE_GP_TIMER_ISP_OUT_RUN_DP                           39
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I0_I0        40
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I0_I1        41
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I1_I0        42
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I2_I0        43
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I2_I1        44
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I2_I2        45
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I2_I3        46
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I2_I4        47
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I2_I5        48
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I2_I6        49
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I3_I0        50
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I4_I0        51
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I5_I0        52
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I6_I0        53
-#define HIVE_GP_TIMER_ISP_WIRE_DEBUG_LM_MSINK_RUN_I7_I0        54                                                         
-#define HIVE_GP_TIMER_MIPI_SOL_BIT_ID                          55
-#define HIVE_GP_TIMER_MIPI_EOL_BIT_ID                          56
-#define HIVE_GP_TIMER_MIPI_SOF_BIT_ID                          57
-#define HIVE_GP_TIMER_MIPI_EOF_BIT_ID                          58
-#define HIVE_GP_TIMER_INPSYS_SM                                59
-
-/* port definitions for the streaming monitors */
-/* port definititions SP streaming monitor, monitors the status of streaming ports at the SP side of the streaming FIFO's */
-#define SP_STR_MON_PORT_SP2SIF            0
-#define SP_STR_MON_PORT_SIF2SP            1
-#define SP_STR_MON_PORT_SP2MC             2 
-#define SP_STR_MON_PORT_MC2SP             3
-#define SP_STR_MON_PORT_SP2DMA            4 
-#define SP_STR_MON_PORT_DMA2SP            5
-#define SP_STR_MON_PORT_SP2ISP            6 
-#define SP_STR_MON_PORT_ISP2SP            7
-#define SP_STR_MON_PORT_SP2GPD            8
-#define SP_STR_MON_PORT_FA2SP             9
-#define SP_STR_MON_PORT_SP2ISYS          10 
-#define SP_STR_MON_PORT_ISYS2SP          11
-#define SP_STR_MON_PORT_SP2PIFA          12
-#define SP_STR_MON_PORT_PIFA2SP          13
-#define SP_STR_MON_PORT_SP2PIFB          14
-#define SP_STR_MON_PORT_PIFB2SP          15
-
-#define SP_STR_MON_PORT_B_SP2GDC1         0
-#define SP_STR_MON_PORT_B_GDC12SP         1
-#define SP_STR_MON_PORT_B_SP2GDC2         2
-#define SP_STR_MON_PORT_B_GDC22SP         3
-
-/* previously used SP streaming monitor port identifiers, kept for backward compatibility */
-#define SP_STR_MON_PORT_SND_SIF           SP_STR_MON_PORT_SP2SIF
-#define SP_STR_MON_PORT_RCV_SIF           SP_STR_MON_PORT_SIF2SP
-#define SP_STR_MON_PORT_SND_MC            SP_STR_MON_PORT_SP2MC
-#define SP_STR_MON_PORT_RCV_MC            SP_STR_MON_PORT_MC2SP
-#define SP_STR_MON_PORT_SND_DMA           SP_STR_MON_PORT_SP2DMA
-#define SP_STR_MON_PORT_RCV_DMA           SP_STR_MON_PORT_DMA2SP
-#define SP_STR_MON_PORT_SND_ISP           SP_STR_MON_PORT_SP2ISP
-#define SP_STR_MON_PORT_RCV_ISP           SP_STR_MON_PORT_ISP2SP
-#define SP_STR_MON_PORT_SND_GPD           SP_STR_MON_PORT_SP2GPD
-#define SP_STR_MON_PORT_RCV_GPD           SP_STR_MON_PORT_FA2SP
-/* Deprecated */
-#define SP_STR_MON_PORT_SND_PIF           SP_STR_MON_PORT_SP2PIFA
-#define SP_STR_MON_PORT_RCV_PIF           SP_STR_MON_PORT_PIFA2SP
-#define SP_STR_MON_PORT_SND_PIFB          SP_STR_MON_PORT_SP2PIFB
-#define SP_STR_MON_PORT_RCV_PIFB          SP_STR_MON_PORT_PIFB2SP
-
-#define SP_STR_MON_PORT_SND_PIF_A         SP_STR_MON_PORT_SP2PIFA
-#define SP_STR_MON_PORT_RCV_PIF_A         SP_STR_MON_PORT_PIFA2SP
-#define SP_STR_MON_PORT_SND_PIF_B         SP_STR_MON_PORT_SP2PIFB
-#define SP_STR_MON_PORT_RCV_PIF_B         SP_STR_MON_PORT_PIFB2SP
-
-/* port definititions ISP streaming monitor, monitors the status of streaming ports at the ISP side of the streaming FIFO's */
-#define ISP_STR_MON_PORT_ISP2PIFA         0
-#define ISP_STR_MON_PORT_PIFA2ISP         1
-#define ISP_STR_MON_PORT_ISP2PIFB         2 
-#define ISP_STR_MON_PORT_PIFB2ISP         3
-#define ISP_STR_MON_PORT_ISP2DMA          4 
-#define ISP_STR_MON_PORT_DMA2ISP          5
-#define ISP_STR_MON_PORT_ISP2GDC1         6 
-#define ISP_STR_MON_PORT_GDC12ISP         7
-#define ISP_STR_MON_PORT_ISP2GDC2         8 
-#define ISP_STR_MON_PORT_GDC22ISP         9
-#define ISP_STR_MON_PORT_ISP2GPD         10 
-#define ISP_STR_MON_PORT_FA2ISP          11
-#define ISP_STR_MON_PORT_ISP2SP          12 
-#define ISP_STR_MON_PORT_SP2ISP          13
-
-/* previously used ISP streaming monitor port identifiers, kept for backward compatibility */
-#define ISP_STR_MON_PORT_SND_PIF_A       ISP_STR_MON_PORT_ISP2PIFA
-#define ISP_STR_MON_PORT_RCV_PIF_A       ISP_STR_MON_PORT_PIFA2ISP
-#define ISP_STR_MON_PORT_SND_PIF_B       ISP_STR_MON_PORT_ISP2PIFB 
-#define ISP_STR_MON_PORT_RCV_PIF_B       ISP_STR_MON_PORT_PIFB2ISP
-#define ISP_STR_MON_PORT_SND_DMA         ISP_STR_MON_PORT_ISP2DMA  
-#define ISP_STR_MON_PORT_RCV_DMA         ISP_STR_MON_PORT_DMA2ISP 
-#define ISP_STR_MON_PORT_SND_GDC         ISP_STR_MON_PORT_ISP2GDC1 
-#define ISP_STR_MON_PORT_RCV_GDC         ISP_STR_MON_PORT_GDC12ISP
-#define ISP_STR_MON_PORT_SND_GPD         ISP_STR_MON_PORT_ISP2GPD 
-#define ISP_STR_MON_PORT_RCV_GPD         ISP_STR_MON_PORT_FA2ISP
-#define ISP_STR_MON_PORT_SND_SP          ISP_STR_MON_PORT_ISP2SP
-#define ISP_STR_MON_PORT_RCV_SP          ISP_STR_MON_PORT_SP2ISP
-                                           
-/* port definititions MOD streaming monitor, monitors the status of streaming ports at the module side of the streaming FIFO's */
-
-#define MOD_STR_MON_PORT_PIFA2CELLS       0
-#define MOD_STR_MON_PORT_CELLS2PIFA       1
-#define MOD_STR_MON_PORT_PIFB2CELLS       2
-#define MOD_STR_MON_PORT_CELLS2PIFB       3
-#define MOD_STR_MON_PORT_SIF2SP           4
-#define MOD_STR_MON_PORT_SP2SIF           5
-#define MOD_STR_MON_PORT_MC2SP            6
-#define MOD_STR_MON_PORT_SP2MC            7
-#define MOD_STR_MON_PORT_DMA2ISP          8
-#define MOD_STR_MON_PORT_ISP2DMA          9
-#define MOD_STR_MON_PORT_DMA2SP          10
-#define MOD_STR_MON_PORT_SP2DMA          11
-#define MOD_STR_MON_PORT_GDC12CELLS      12
-#define MOD_STR_MON_PORT_CELLS2GDC1      13
-#define MOD_STR_MON_PORT_GDC22CELLS      14
-#define MOD_STR_MON_PORT_CELLS2GDC2      15
-
-#define MOD_STR_MON_PORT_SND_PIF_A        0
-#define MOD_STR_MON_PORT_RCV_PIF_A        1
-#define MOD_STR_MON_PORT_SND_PIF_B        2
-#define MOD_STR_MON_PORT_RCV_PIF_B        3
-#define MOD_STR_MON_PORT_SND_SIF          4
-#define MOD_STR_MON_PORT_RCV_SIF          5
-#define MOD_STR_MON_PORT_SND_MC           6
-#define MOD_STR_MON_PORT_RCV_MC           7
-#define MOD_STR_MON_PORT_SND_DMA2ISP      8
-#define MOD_STR_MON_PORT_RCV_DMA_FR_ISP   9
-#define MOD_STR_MON_PORT_SND_DMA2SP      10
-#define MOD_STR_MON_PORT_RCV_DMA_FR_SP   11
-#define MOD_STR_MON_PORT_SND_GDC         12
-#define MOD_STR_MON_PORT_RCV_GDC         13
-
-
-/* testbench signals:       */
-
-/* testbench GP adapter register ids  */
-#define HIVE_TESTBENCH_GPIO_DATA_OUT_REG_IDX                    0
-#define HIVE_TESTBENCH_GPIO_DIR_OUT_REG_IDX                     1
-#define HIVE_TESTBENCH_IRQ_REG_IDX                              2
-#define HIVE_TESTBENCH_SDRAM_WAKEUP_REG_IDX                     3
-#define HIVE_TESTBENCH_IDLE_REG_IDX                             4
-#define HIVE_TESTBENCH_GPIO_DATA_IN_REG_IDX                     5
-#define HIVE_TESTBENCH_MIPI_BFM_EN_REG_IDX                      6
-#define HIVE_TESTBENCH_CSI_CONFIG_REG_IDX                       7 
-#define HIVE_TESTBENCH_DDR_STALL_EN_REG_IDX                     8
-
-#define HIVE_TESTBENCH_ISP_PMEM_ERROR_IRQ_REG_IDX               9
-#define HIVE_TESTBENCH_ISP_BAMEM_ERROR_IRQ_REG_IDX             10
-#define HIVE_TESTBENCH_ISP_DMEM_ERROR_IRQ_REG_IDX              11
-#define HIVE_TESTBENCH_SP_ICACHE_MEM_ERROR_IRQ_REG_IDX         12
-#define HIVE_TESTBENCH_SP_DMEM_ERROR_IRQ_REG_IDX               13
-
-/* Signal monitor input bit ids */
-#define HIVE_TESTBENCH_SIG_MON_GPIO_PIN_O_BIT_ID                0
-#define HIVE_TESTBENCH_SIG_MON_GPIO_PIN_1_BIT_ID                1
-#define HIVE_TESTBENCH_SIG_MON_GPIO_PIN_2_BIT_ID                2
-#define HIVE_TESTBENCH_SIG_MON_GPIO_PIN_3_BIT_ID                3
-#define HIVE_TESTBENCH_SIG_MON_GPIO_PIN_4_BIT_ID                4
-#define HIVE_TESTBENCH_SIG_MON_GPIO_PIN_5_BIT_ID                5
-#define HIVE_TESTBENCH_SIG_MON_GPIO_PIN_6_BIT_ID                6
-#define HIVE_TESTBENCH_SIG_MON_GPIO_PIN_7_BIT_ID                7
-#define HIVE_TESTBENCH_SIG_MON_GPIO_PIN_8_BIT_ID                8
-#define HIVE_TESTBENCH_SIG_MON_GPIO_PIN_9_BIT_ID                9
-#define HIVE_TESTBENCH_SIG_MON_GPIO_PIN_10_BIT_ID              10
-#define HIVE_TESTBENCH_SIG_MON_GPIO_PIN_11_BIT_ID              11
-#define HIVE_TESTBENCH_SIG_MON_IRQ_PIN_BIT_ID                  12
-#define HIVE_TESTBENCH_SIG_MON_SDRAM_WAKEUP_PIN_BIT_ID         13
-#define HIVE_TESTBENCH_SIG_MON_IDLE_PIN_BIT_ID                 14
-
-#define ISP2400_DEBUG_NETWORK    1
-
-#endif /* _hive_isp_css_defs_h__ */

+ 0 - 84
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/hive_isp_css_host_ids_hrt.h

@@ -1,84 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _hive_isp_css_host_ids_hrt_h_
-#define _hive_isp_css_host_ids_hrt_h_
-
-/* ISP_CSS identifiers */
-#define INP_SYS       testbench_isp_inp_sys
-#define ISYS_GP_REGS  testbench_isp_inp_sys_gpreg
-#define ISYS_IRQ_CTRL testbench_isp_inp_sys_irq_ctrl
-#define ISYS_CAP_A    testbench_isp_inp_sys_capt_unit_a
-#define ISYS_CAP_B    testbench_isp_inp_sys_capt_unit_b
-#define ISYS_CAP_C    testbench_isp_inp_sys_capt_unit_c
-#define ISYS_INP_BUF  testbench_isp_inp_sys_input_buffer
-#define ISYS_INP_CTRL testbench_isp_inp_sys_inp_ctrl
-#define ISYS_ACQ      testbench_isp_inp_sys_acq_unit
-
-#define ISP           testbench_isp_isp
-#define SP            testbench_isp_scp
-
-#define IF_PRIM       testbench_isp_ifmt_ift_prim  
-#define IF_PRIM_B     testbench_isp_ifmt_ift_prim_b
-#define IF_SEC        testbench_isp_ifmt_ift_sec
-#define IF_SEC_MASTER testbench_isp_ifmt_ift_sec_mt_out
-#define STR_TO_MEM    testbench_isp_ifmt_mem_cpy
-#define IFMT_GP_REGS  testbench_isp_ifmt_gp_reg
-#define IFMT_IRQ_CTRL testbench_isp_ifmt_irq_ctrl
-
-#define CSS_RECEIVER  testbench_isp_inp_sys_csi_receiver
-
-#define TC            testbench_isp_gpd_tc
-#define GPTIMER       testbench_isp_gpd_gptimer
-#define DMA           testbench_isp_isp_dma
-#define GDC           testbench_isp_gdc1
-#define GDC2          testbench_isp_gdc2
-#define IRQ_CTRL      testbench_isp_gpd_irq_ctrl
-#define GPIO          testbench_isp_gpd_c_gpio
-#define GP_REGS       testbench_isp_gpd_gp_reg
-#define ISEL_GP_REGS  testbench_isp_isel_gpr
-#define ISEL_IRQ_CTRL testbench_isp_isel_irq_ctrl
-#define DATA_MMU      testbench_isp_data_out_sys_c_mmu
-#define ICACHE_MMU    testbench_isp_icache_out_sys_c_mmu
-
-/* next is actually not FIFO but FIFO adapter, or slave to streaming adapter */
-#define ISP_SP_FIFO   testbench_isp_fa_sp_isp
-#define ISEL_FIFO     testbench_isp_isel_sf_fa_in
-
-#define FIFO_GPF_SP   testbench_isp_sf_fa2sp_in
-#define FIFO_GPF_ISP  testbench_isp_sf_fa2isp_in
-#define FIFO_SP_GPF   testbench_isp_sf_sp2fa_in
-#define FIFO_ISP_GPF  testbench_isp_sf_isp2fa_in
-
-#define DATA_OCP_MASTER    testbench_isp_data_out_sys_cio2ocp_wide_data_out_mt
-#define ICACHE_OCP_MASTER  testbench_isp_icache_out_sys_cio2ocp_wide_data_out_mt
-
-#define SP_IN_FIFO    testbench_isp_sf_fa2sp_in
-#define SP_OUT_FIFO   testbench_isp_sf_sp2fa_out
-#define ISP_IN_FIFO   testbench_isp_sf_fa2isp_in
-#define ISP_OUT_FIFO  testbench_isp_sf_isp2fa_out
-#define GEN_SHORT_PACK_PORT testbench_isp_inp_sys_csi_str_mon_fa_gensh_out
-#define ISYS_GP_REGS  testbench_isp_inp_sys_gpreg
-
-/* Testbench identifiers */
-#define DDR             testbench_ddram
-#define DDR_SMALL       testbench_ddram_small
-#define XMEM            DDR
-#define GPIO_ADAPTER    testbench_gp_adapter
-#define SIG_MONITOR     testbench_sig_mon
-#define DDR_SLAVE       testbench_ddram_ip0
-#define DDR_SMALL_SLAVE testbench_ddram_small_ip0
-#define HOST_MASTER     host_op0
-
-#endif /* _hive_isp_css_host_ids_hrt_h_ */

+ 0 - 72
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/hive_isp_css_irq_types_hrt.h

@@ -1,72 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _HIVE_ISP_CSS_IRQ_TYPES_HRT_H_
-#define _HIVE_ISP_CSS_IRQ_TYPES_HRT_H_
-
-/*
- * These are the indices of each interrupt in the interrupt
- * controller's registers. these can be used as the irq_id
- * argument to the hrt functions irq_controller.h.
- *
- * The definitions are taken from <system>_defs.h
- */
-typedef enum hrt_isp_css_irq {
-  hrt_isp_css_irq_gpio_pin_0           = HIVE_GP_DEV_IRQ_GPIO_PIN_0_BIT_ID          ,               
-  hrt_isp_css_irq_gpio_pin_1           = HIVE_GP_DEV_IRQ_GPIO_PIN_1_BIT_ID          ,               
-  hrt_isp_css_irq_gpio_pin_2           = HIVE_GP_DEV_IRQ_GPIO_PIN_2_BIT_ID          ,               
-  hrt_isp_css_irq_gpio_pin_3           = HIVE_GP_DEV_IRQ_GPIO_PIN_3_BIT_ID          ,               
-  hrt_isp_css_irq_gpio_pin_4           = HIVE_GP_DEV_IRQ_GPIO_PIN_4_BIT_ID          ,               
-  hrt_isp_css_irq_gpio_pin_5           = HIVE_GP_DEV_IRQ_GPIO_PIN_5_BIT_ID          ,               
-  hrt_isp_css_irq_gpio_pin_6           = HIVE_GP_DEV_IRQ_GPIO_PIN_6_BIT_ID          ,               
-  hrt_isp_css_irq_gpio_pin_7           = HIVE_GP_DEV_IRQ_GPIO_PIN_7_BIT_ID          ,               
-  hrt_isp_css_irq_gpio_pin_8           = HIVE_GP_DEV_IRQ_GPIO_PIN_8_BIT_ID          ,               
-  hrt_isp_css_irq_gpio_pin_9           = HIVE_GP_DEV_IRQ_GPIO_PIN_9_BIT_ID          ,               
-  hrt_isp_css_irq_gpio_pin_10          = HIVE_GP_DEV_IRQ_GPIO_PIN_10_BIT_ID         ,              
-  hrt_isp_css_irq_gpio_pin_11          = HIVE_GP_DEV_IRQ_GPIO_PIN_11_BIT_ID         ,              
-  hrt_isp_css_irq_sp                   = HIVE_GP_DEV_IRQ_SP_BIT_ID                  ,                       
-  hrt_isp_css_irq_isp                  = HIVE_GP_DEV_IRQ_ISP_BIT_ID                 ,                      
-  hrt_isp_css_irq_isys                 = HIVE_GP_DEV_IRQ_ISYS_BIT_ID                ,                     
-  hrt_isp_css_irq_isel                 = HIVE_GP_DEV_IRQ_ISEL_BIT_ID                ,                     
-  hrt_isp_css_irq_ifmt                 = HIVE_GP_DEV_IRQ_IFMT_BIT_ID                ,                     
-  hrt_isp_css_irq_sp_stream_mon        = HIVE_GP_DEV_IRQ_SP_STREAM_MON_BIT_ID       ,            
-  hrt_isp_css_irq_isp_stream_mon       = HIVE_GP_DEV_IRQ_ISP_STREAM_MON_BIT_ID      ,           
-  hrt_isp_css_irq_mod_stream_mon       = HIVE_GP_DEV_IRQ_MOD_STREAM_MON_BIT_ID      ,
-#ifdef _HIVE_ISP_CSS_2401_SYSTEM
-  hrt_isp_css_irq_is2401               = HIVE_GP_DEV_IRQ_IS2401_BIT_ID              ,           
-#else
-  hrt_isp_css_irq_isp_pmem_error       = HIVE_GP_DEV_IRQ_ISP_PMEM_ERROR_BIT_ID      ,           
-#endif
-  hrt_isp_css_irq_isp_bamem_error      = HIVE_GP_DEV_IRQ_ISP_BAMEM_ERROR_BIT_ID     ,          
-  hrt_isp_css_irq_isp_dmem_error       = HIVE_GP_DEV_IRQ_ISP_DMEM_ERROR_BIT_ID      ,           
-  hrt_isp_css_irq_sp_icache_mem_error  = HIVE_GP_DEV_IRQ_SP_ICACHE_MEM_ERROR_BIT_ID ,      
-  hrt_isp_css_irq_sp_dmem_error        = HIVE_GP_DEV_IRQ_SP_DMEM_ERROR_BIT_ID       ,            
-  hrt_isp_css_irq_mmu_cache_mem_error  = HIVE_GP_DEV_IRQ_MMU_CACHE_MEM_ERROR_BIT_ID ,      
-  hrt_isp_css_irq_gp_timer_0           = HIVE_GP_DEV_IRQ_GP_TIMER_0_BIT_ID          ,               
-  hrt_isp_css_irq_gp_timer_1           = HIVE_GP_DEV_IRQ_GP_TIMER_1_BIT_ID          ,               
-  hrt_isp_css_irq_sw_pin_0             = HIVE_GP_DEV_IRQ_SW_PIN_0_BIT_ID            ,                 
-  hrt_isp_css_irq_sw_pin_1             = HIVE_GP_DEV_IRQ_SW_PIN_1_BIT_ID            ,                 
-  hrt_isp_css_irq_dma                  = HIVE_GP_DEV_IRQ_DMA_BIT_ID                 ,
-  hrt_isp_css_irq_sp_stream_mon_b      = HIVE_GP_DEV_IRQ_SP_STREAM_MON_B_BIT_ID     ,
-  /* this must (obviously) be the last on in the enum */
-  hrt_isp_css_irq_num_irqs
-} hrt_isp_css_irq_t;
-
-typedef enum hrt_isp_css_irq_status {
-  hrt_isp_css_irq_status_error,
-  hrt_isp_css_irq_status_more_irqs,
-  hrt_isp_css_irq_status_success
-} hrt_isp_css_irq_status_t;
-
-#endif /* _HIVE_ISP_CSS_IRQ_TYPES_HRT_H_ */

+ 0 - 26
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/hive_isp_css_streaming_to_mipi_types_hrt.h

@@ -1,26 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _hive_isp_css_streaming_to_mipi_types_hrt_h_
-#define _hive_isp_css_streaming_to_mipi_types_hrt_h_
-
-#include <streaming_to_mipi_defs.h>
-
-#define _HIVE_ISP_CH_ID_MASK    ((1U << HIVE_ISP_CH_ID_BITS)-1)
-#define _HIVE_ISP_FMT_TYPE_MASK ((1U << HIVE_ISP_FMT_TYPE_BITS)-1)
-
-#define _HIVE_STR_TO_MIPI_FMT_TYPE_LSB (HIVE_STR_TO_MIPI_CH_ID_LSB + HIVE_ISP_CH_ID_BITS)
-#define _HIVE_STR_TO_MIPI_DATA_B_LSB   (HIVE_STR_TO_MIPI_DATA_A_LSB + HIVE_IF_PIXEL_WIDTH)
- 
-#endif /* _hive_isp_css_streaming_to_mipi_types_hrt_h_ */

+ 0 - 128
drivers/staging/media/atomisp/pci/atomisp2/css2400/css_2400_system/hrt/hive_types.h

@@ -1,128 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope 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 _HRT_HIVE_TYPES_H 
-#define _HRT_HIVE_TYPES_H 
-
-#include "version.h"
-#include "defs.h"
-
-#ifndef HRTCAT3
-#define _HRTCAT3(m,n,o)     m##n##o
-#define HRTCAT3(m,n,o)      _HRTCAT3(m,n,o)
-#endif
-
-#ifndef HRTCAT4
-#define _HRTCAT4(m,n,o,p)     m##n##o##p
-#define HRTCAT4(m,n,o,p)      _HRTCAT4(m,n,o,p)
-#endif
-
-#ifndef HRTMIN
-#define HRTMIN(a,b) (((a)<(b))?(a):(b))
-#endif
-                                 
-#ifndef HRTMAX
-#define HRTMAX(a,b) (((a)>(b))?(a):(b))
-#endif
-
-/* boolean data type */
-typedef unsigned int hive_bool;
-#define hive_false 0
-#define hive_true  1
-
-typedef char                 hive_int8;
-typedef short                hive_int16;
-typedef int                  hive_int32;
-typedef long long            hive_int64;
-
-typedef unsigned char        hive_uint8;
-typedef unsigned short       hive_uint16;
-typedef unsigned int         hive_uint32;
-typedef unsigned long long   hive_uint64;
-
-/* by default assume 32 bit master port (both data and address) */
-#ifndef HRT_DATA_WIDTH
-#define HRT_DATA_WIDTH 32
-#endif
-#ifndef HRT_ADDRESS_WIDTH
-#define HRT_ADDRESS_WIDTH 32
-#endif
-
-#define HRT_DATA_BYTES    (HRT_DATA_WIDTH/8)
-#define HRT_ADDRESS_BYTES (HRT_ADDRESS_WIDTH/8)
-
-#if HRT_DATA_WIDTH == 64
-typedef hive_uint64 hrt_data;
-#elif HRT_DATA_WIDTH == 32
-typedef hive_uint32 hrt_data;
-#else
-#error data width not supported
-#endif
-
-#if HRT_ADDRESS_WIDTH == 64
-typedef hive_uint64 hrt_address; 
-#elif HRT_ADDRESS_WIDTH == 32
-typedef hive_uint32 hrt_address;
-#else
-#error adddres width not supported
-#endif
-
-/* The SP side representation of an HMM virtual address */
-typedef hive_uint32 hrt_vaddress;
-
-/* use 64 bit addresses in simulation, where possible */
-typedef hive_uint64  hive_sim_address;
-
-/* below is for csim, not for hrt, rename and move this elsewhere */
-
-typedef unsigned int hive_uint;
-typedef hive_uint32  hive_address;
-typedef hive_address hive_slave_address;
-typedef hive_address hive_mem_address;
-
-/* MMIO devices */
-typedef hive_uint    hive_mmio_id;
-typedef hive_mmio_id hive_slave_id;
-typedef hive_mmio_id hive_port_id;
-typedef hive_mmio_id hive_master_id; 
-typedef hive_mmio_id hive_mem_id;
-typedef hive_mmio_id hive_dev_id;
-typedef hive_mmio_id hive_fifo_id;
-
-typedef hive_uint      hive_hier_id;
-typedef hive_hier_id   hive_device_id;
-typedef hive_device_id hive_proc_id;
-typedef hive_device_id hive_cell_id;
-typedef hive_device_id hive_host_id;
-typedef hive_device_id hive_bus_id;
-typedef hive_device_id hive_bridge_id;
-typedef hive_device_id hive_fifo_adapter_id;
-typedef hive_device_id hive_custom_device_id;
-
-typedef hive_uint hive_slot_id;
-typedef hive_uint hive_fu_id;
-typedef hive_uint hive_reg_file_id;
-typedef hive_uint hive_reg_id;
-
-/* Streaming devices */
-typedef hive_uint hive_outport_id;
-typedef hive_uint hive_inport_id;
-
-typedef hive_uint hive_msink_id;
-
-/* HRT specific */
-typedef char* hive_program;
-typedef char* hive_function;
-
-#endif /* _HRT_HIVE_TYPES_H */

部分文件因为文件数量过多而无法显示