From 03c51d2af435f85542259f8be142de638c759e9e Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 6 May 2013 14:52:06 -0700 Subject: [PATCH] compat: backport soc_camera_power_[on|off] for 3.3 We are only backporting CONFIG_SOC_CAMERA for kernels >= 3.4 but there is an exported symbol from there that some media drivers that we do support on 3.3 need. Handle this special case. SOC_CAMERA is only enabled on 3.4 as it depends on some newer regulator functionality, however there are some SOC cameras that can rely on the 3.3 regulatory built-in core and the 3.3 SOC_CAMERA module however two routines are not exported in that version of SOC_CAMERA that newer SOC cameras do require. Backport that functionality. Technically this should go into given that is where its where its exported on linux-next but in practice only placing it on actually fixes linking errors for 3.3 for all SOC camera drivers we make available for 3.3: LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/imx074.ko LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/mt9m001.ko LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/mt9m111.ko LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/mt9t031.ko LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/mt9t112.ko LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/mt9v022.ko LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/ov2640.ko LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/ov5642.ko LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/ov6650.ko LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/ov772x.ko LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/ov9640.ko LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/ov9740.ko LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/rj54n1cb0c.ko LD [M] /home/mcgrof/build/drivers/media/i2c/soc_camera/tw9910.ko This fixes all pending linking errors on 3.3. $ time ckmake --check-exports --allyesconfig 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ LINK ] 22 3.5.7 [ LINK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] real 30m14.581s user 796m34.495s sys 126m46.807s Signed-off-by: Luis R. Rodriguez Signed-off-by: Johannes Berg --- backport/Makefile.kernel | 1 + .../uapi/linux/v4l2-mediabus.h | 39 ++++++++++ backport/compat/compat-3.4.c | 73 +++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 backport/backport-include/uapi/linux/v4l2-mediabus.h diff --git a/backport/Makefile.kernel b/backport/Makefile.kernel index 678153350bda..f3544da1a8af 100644 --- a/backport/Makefile.kernel +++ b/backport/Makefile.kernel @@ -5,6 +5,7 @@ backport-cc-disable-warning = $(call try-run,\ NOSTDINC_FLAGS := \ -I$(M)/backport-include/ \ + -I$(M)/backport-include/uapi \ -I$(M)/include/ \ -I$(M)/include/uapi \ -I$(M)/include/drm \ diff --git a/backport/backport-include/uapi/linux/v4l2-mediabus.h b/backport/backport-include/uapi/linux/v4l2-mediabus.h new file mode 100644 index 000000000000..9979c23f4e88 --- /dev/null +++ b/backport/backport-include/uapi/linux/v4l2-mediabus.h @@ -0,0 +1,39 @@ +#ifndef __BACKPORT_LINUX_V4L2_MEDIABUS_H +#define __BACKPORT_LINUX_V4L2_MEDIABUS_H +#include + +/* + * SOC_CAMERA is only enabled on 3.4 as it depends on some + * newer regulator functionality, however there are some SOC + * cameras that can rely on the 3.3 regulatory built-in core + * and the 3.3 SOC_CAMERA module however two routines are + * not exported in that version of SOC_CAMERA that newer + * SOC cameras do require. Backport that functionality. + * + * Technically this should go into + * given that is where its where its exported on linux-next + * but in practice only placing it here actually fixes linking + * errors for 3.3 for all SOC camera drivers we make available + * for 3.3. + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) +#if defined(CPTCFG_VIDEO_DEV_MODULE) + +struct soc_camera_subdev_desc; + +#define soc_camera_power_on LINUX_BACKPORT(soc_camera_power_on) +int soc_camera_power_on(struct device *dev, + struct soc_camera_subdev_desc *ssdd); + +#define soc_camera_power_off LINUX_BACKPORT(soc_camera_power_off) +int soc_camera_power_off(struct device *dev, + struct soc_camera_subdev_desc *ssdd); + +#endif /* defined(CPTCFG_VIDEO_DEV_MODULE) */ +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) */ +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) */ + +#include_next + +#endif /* __BACKPORT_LINUX_V4L2_MEDIABUS_H */ diff --git a/backport/compat/compat-3.4.c b/backport/compat/compat-3.4.c index eec311a4a212..1718cd2c25c3 100644 --- a/backport/compat/compat-3.4.c +++ b/backport/compat/compat-3.4.c @@ -16,9 +16,82 @@ #include #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) +#if defined(CPTCFG_VIDEO_DEV_MODULE) +#include +#include +#include +#include +#include +#include +#include +#include +#endif /* defined(CPTCFG_VIDEO_DEV_MODULE) */ +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) */ +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) */ #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) + +#if defined(CPTCFG_VIDEO_V4L2_MODULE) +int soc_camera_power_on(struct device *dev, + struct soc_camera_subdev_desc *ssdd) +{ + int ret = regulator_bulk_enable(ssdd->num_regulators, + ssdd->regulators); + if (ret < 0) { + dev_err(dev, "Cannot enable regulators\n"); + return ret; + } + + if (ssdd->power) { + ret = ssdd->power(dev, 1); + if (ret < 0) { + dev_err(dev, + "Platform failed to power-on the camera.\n"); + regulator_bulk_disable(ssdd->num_regulators, + ssdd->regulators); + } + } + + return ret; +} +EXPORT_SYMBOL_GPL(soc_camera_power_on); + +int soc_camera_power_off(struct device *dev, + struct soc_camera_subdev_desc *ssdd) +{ + int ret = 0; + int err; + + if (ssdd->power) { + err = ssdd->power(dev, 0); + if (err < 0) { + dev_err(dev, + "Platform failed to power-off the camera.\n"); + ret = err; + } + } + + err = regulator_bulk_disable(ssdd->num_regulators, + ssdd->regulators); + if (err < 0) { + dev_err(dev, "Cannot disable regulators\n"); + ret = ret ? : err; + } + + return ret; +} +EXPORT_SYMBOL_GPL(soc_camera_power_off); +#endif /* defined(CPTCFG_VIDEO_V4L2_MODULE) */ + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) */ +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) */ + #if defined(CONFIG_REGMAP) static void devm_regmap_release(struct device *dev, void *res) { -- 2.30.2