Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 8627e118 authored by derfelot's avatar derfelot
Browse files

msm: camera: Add support for Sony camera

Taken from Sony 47.2.A.10.107 stock kernel
parent 6a5079e8
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -9,6 +9,11 @@
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
/*
 * NOTE: This file has been modified by Sony Mobile Communications Inc.
 * Modifications are Copyright (c) 2016 Sony Mobile Communications Inc,
 * and licensed under the license of the file.
 */

#include <linux/kernel.h>
#include <linux/init.h>
@@ -399,6 +404,9 @@ static struct rcg_clk maxi_clk_src = {
static struct clk_freq_tbl ftbl_cpp_clk_src[] = {
	F_MM( 100000000,    mmsscc_gpll0,    6,    0,     0),
	F_MM( 200000000,    mmsscc_gpll0,    3,    0,     0),
#if defined(CONFIG_SONY_CAM_V4L2)
	F_MM( 384000000,  mmpll4_pll_out,    2,    0,     0),
#endif
	F_MM( 576000000, mmpll10_pll_out,    1,    0,     0),
	F_MM( 600000000,    mmsscc_gpll0,    1,    0,     0),
	F_END
+17 −0
Original line number Diff line number Diff line
@@ -203,6 +203,23 @@ config OV12830
		snapshot config = 4224 * 3000 at 15 fps.
		2 lanes max fps is 18, 4 lanes max fps is 24.

config SONY_CAM_V4L2
	bool "SONY specific camera"
	depends on MSMB_CAMERA
	default n
	---help---
	  SONY specific camera module

config FRONT_CAMERA_LED_SCALE
	int "Reduce RGB LED brightness when front camera is active"
	depends on SONY_CAM_V4L2 && LEDS_QPNP_RGB_SCALE
	range 0 99
	default 0
	---help---
	  Reduce the brightness of front RGB LED by specified percentage
	  when front camera sensor is powered on. Set it to zero to disable
	  the feature.

config MSM_V4L2_VIDEO_OVERLAY_DEVICE
	tristate "QTI MSM V4l2 video overlay device"
	---help---
+31 −0
Original line number Diff line number Diff line
@@ -10,6 +10,11 @@
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
/*
 * NOTE: This file has been modified by Sony Mobile Communications Inc.
 * Modifications are Copyright (c) 2016 Sony Mobile Communications Inc,
 * and licensed under the license of the file.
 */

#include <linux/delay.h>
#include <linux/clk.h>
@@ -24,6 +29,9 @@
#define BUFF_SIZE_128 128

#undef CDBG
#if defined(CONFIG_SONY_CAM_V4L2)
#define CDBG(fmt, args...)
#else
#define CDBG(fmt, args...) pr_debug(fmt, ##args)

void msm_camera_io_w(u32 data, void __iomem *addr)
@@ -31,6 +39,7 @@ void msm_camera_io_w(u32 data, void __iomem *addr)
	CDBG("%s: 0x%pK %08x\n", __func__,  (addr), (data));
	writel_relaxed((data), (addr));
}
#endif

/* This API is to write a block of data
* to same address
@@ -46,7 +55,11 @@ int32_t msm_camera_io_w_block(const u32 *addr, void __iomem *base,
	for (i = 0; i < len; i++) {
		CDBG("%s: len =%d val=%x base =%pK\n", __func__,
			len, addr[i], base);
#if defined(CONFIG_SONY_CAM_V4L2)
		writel_relaxed_no_log(addr[i], base);
#else
		writel_relaxed(addr[i], base);
#endif
	}
	return 0;
}
@@ -65,7 +78,11 @@ int32_t msm_camera_io_w_reg_block(const u32 *addr, void __iomem *base,
	for (i = 0; i < len; i = i + 2) {
		CDBG("%s: len =%d val=%x base =%pK reg=%x\n", __func__,
			len, addr[i + 1], base,  addr[i]);
#if defined(CONFIG_SONY_CAM_V4L2)
		writel_relaxed_no_log(addr[i + 1], base + addr[i]);
#else
		writel_relaxed(addr[i + 1], base + addr[i]);
#endif
	}
	return 0;
}
@@ -75,7 +92,11 @@ void msm_camera_io_w_mb(u32 data, void __iomem *addr)
	CDBG("%s: 0x%pK %08x\n", __func__,  (addr), (data));
	/* ensure write is done */
	wmb();
#if defined(CONFIG_SONY_CAM_V4L2)
	writel_relaxed_no_log((data), (addr));
#else
	writel_relaxed((data), (addr));
#endif
	/* ensure write is done */
	wmb();
}
@@ -92,13 +113,18 @@ int32_t msm_camera_io_w_mb_block(const u32 *addr, void __iomem *base, u32 len)
		wmb();
		CDBG("%s: len =%d val=%x base =%pK\n", __func__,
			len, addr[i], base);
#if defined(CONFIG_SONY_CAM_V4L2)
		writel_relaxed_no_log(addr[i], base);
#else
		writel_relaxed(addr[i], base);
#endif
	}
	/* ensure last write is done */
	wmb();
	return 0;
}

#if !defined(CONFIG_SONY_CAM_V4L2)
u32 msm_camera_io_r(void __iomem *addr)
{
	uint32_t data = readl_relaxed(addr);
@@ -106,6 +132,7 @@ u32 msm_camera_io_r(void __iomem *addr)
	CDBG("%s: 0x%pK %08x\n", __func__,  (addr), (data));
	return data;
}
#endif

u32 msm_camera_io_r_mb(void __iomem *addr)
{
@@ -127,7 +154,11 @@ void msm_camera_io_memcpy_toio(void __iomem *dest_addr,
	u32 *s = (u32 *) src_addr;

	for (i = 0; i < len; i++)
#if defined(CONFIG_SONY_CAM_V4L2)
		writel_relaxed_no_log(*s++, d++);
#else
		writel_relaxed(*s++, d++);
#endif
}

int32_t msm_camera_io_poll_value(void __iomem *addr, u32 wait_data, u32 retry,
+24 −0
Original line number Diff line number Diff line
@@ -9,6 +9,11 @@
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
/*
 * NOTE: This file has been modified by Sony Mobile Communications Inc.
 * Modifications are Copyright (c) 2016 Sony Mobile Communications Inc,
 * and licensed under the license of the file.
 */

#ifndef __MSM_CAMERA_IO_UTIL_H
#define __MSM_CAMERA_IO_UTIL_H
@@ -16,6 +21,9 @@
#include <linux/regulator/consumer.h>
#include <linux/gpio.h>
#include <linux/clk.h>
#if defined(CONFIG_SONY_CAM_V4L2)
#include <linux/io.h>
#endif
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <soc/qcom/camera2.h>
@@ -36,9 +44,25 @@ struct msm_cam_dump_string_info {
	uint32_t offset;
};

#if defined(CONFIG_SONY_CAM_V4L2)
static inline void msm_camera_io_w(u32 data, void __iomem *addr)
{
	writel_relaxed_no_log((data), (addr));
}
#else
void msm_camera_io_w(u32 data, void __iomem *addr);
#endif
void msm_camera_io_w_mb(u32 data, void __iomem *addr);
#if defined(CONFIG_SONY_CAM_V4L2)
static inline u32 msm_camera_io_r(void __iomem *addr)
{
	uint32_t data = readl_relaxed_no_log(addr);

	return data;
}
#else
u32 msm_camera_io_r(void __iomem *addr);
#endif
u32 msm_camera_io_r_mb(void __iomem *addr);
void msm_camera_io_dump(void __iomem *addr, int size, int enable);
void msm_camera_io_memcpy(void __iomem *dest_addr,
+14 −0
Original line number Diff line number Diff line
@@ -9,6 +9,11 @@
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
/*
 * NOTE: This file has been modified by Sony Mobile Communications Inc.
 * Modifications are Copyright (c) 2016 Sony Mobile Communications Inc,
 * and licensed under the license of the file.
 */
#include <linux/io.h>
#include <media/v4l2-subdev.h>
#include <asm/div64.h>
@@ -3463,6 +3468,10 @@ int msm_isp_cfg_axi_stream(struct vfe_device *vfe_dev, void *arg)

		rc = msm_isp_start_axi_stream(
			vfe_dev, stream_cfg_cmd);
#if defined(CONFIG_SONY_CAM_V4L2)
		pr_info("%s: msm_isp_start_axi_stream: rc %d\n",
			__func__, rc);
#endif
	} else {
		rc = msm_isp_stop_axi_stream(
			vfe_dev, stream_cfg_cmd);
@@ -3485,8 +3494,13 @@ int msm_isp_cfg_axi_stream(struct vfe_device *vfe_dev, void *arg)
	}

	if (rc < 0)
#if defined(CONFIG_SONY_CAM_V4L2)
		pr_err("%s: start/stop %d stream failed: rc %d\n", __func__,
			stream_cfg_cmd->cmd, rc);
#else
		pr_err("%s: start/stop %d stream failed\n", __func__,
			stream_cfg_cmd->cmd);
#endif
	return rc;
}

Loading