Commit a49d2536 authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman

staging/atomisp: Add support for the Intel IPU v2

This patch adds support for the Intel IPU v2 as found on Android and IoT
Baytrail-T and Baytrail-CR platforms (those with the IPU PCI mapped). You
will also need the firmware files from your device (Android usually puts
them into /etc) - or you can find them in the downloadable restore/upgrade
kits if you blew them away for some reason.

It may be possible to extend the driver to handle the BYT/T windows
platforms such as the ASUS T100TA. These platforms don't expose the IPU via
the PCI interface but via ACPI buried in the GPU description and with the
camera information somewhere unknown so would need a platform driver
interface adding to the codebase *IFF* the firmware works on such devices.

To get good results you also need a suitable support library such as
libxcam. The camera is intended to be driven from Android so it has a lot of
features that many desktop apps don't fully spport.

In theory all the pieces are there to build it with -DISP2401 and some
differing files to get CherryTrail/T support, but unifying the drivers
properlly is a work in progress.

The IPU driver represents the work of a lot of people within Intel over many
years. It's historical goal was portability rather than Linux upstream. Any
queries about the upstream aimed driver should be sent to me not to the
original authors.
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 372499b5
...@@ -34,4 +34,5 @@ source "drivers/staging/media/lirc/Kconfig" ...@@ -34,4 +34,5 @@ source "drivers/staging/media/lirc/Kconfig"
source "drivers/staging/media/st-cec/Kconfig" source "drivers/staging/media/st-cec/Kconfig"
source "drivers/staging/media/atomisp/Kconfig"
endif endif
...@@ -5,3 +5,4 @@ obj-$(CONFIG_LIRC_STAGING) += lirc/ ...@@ -5,3 +5,4 @@ obj-$(CONFIG_LIRC_STAGING) += lirc/
obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/ obj-$(CONFIG_VIDEO_DM365_VPFE) += davinci_vpfe/
obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/ obj-$(CONFIG_VIDEO_OMAP4) += omap4iss/
obj-$(CONFIG_VIDEO_STI_HDMI_CEC) += st-cec/ obj-$(CONFIG_VIDEO_STI_HDMI_CEC) += st-cec/
obj-$(CONFIG_INTEL_ATOMISP) += atomisp/
menuconfig INTEL_ATOMISP
bool "Enable support to Intel MIPI camera drivers"
depends on X86
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
#
# Makefile for camera drivers.
#
obj-$(CONFIG_INTEL_ATOMISP) += pci/
obj-$(CONFIG_INTEL_ATOMISP) += i2c/
obj-$(CONFIG_INTEL_ATOMISP) += platform/
LINUXINCLUDE += -I drivers/staging/media/atomisp/include/
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.
Limitations:
1. Currently the patch only support some camera sensors
gc2235/gc0310/0v2680/ov2722/ov5693/mt9m114...
2. 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.
3. 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.
4. 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.
5. The driver supports only v2 of the IPU/Camera. It will not work with the
versions of the hardware in other SoCs.
#
# Kconfig for sensor drivers
#
source "drivers/staging/media/atomisp/i2c/ov5693/Kconfig"
source "drivers/staging/media/atomisp/i2c/imx/Kconfig"
config VIDEO_OV2722
tristate "OVT ov2722 sensor support"
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_GC2235
tristate "Galaxy gc2235 sensor support"
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_OV8858
tristate "Omnivision ov8858 sensor support"
depends on I2C && VIDEO_V4L2 && VIDEO_ATOMISP
---help---
This is a Video4Linux2 sensor-level driver for the Omnivision
ov8858 RAW sensor.
OV8858 is a 8M raw sensor.
It currently only works with the atomisp driver.
config VIDEO_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_MT9M114
tristate "Aptina mt9m114 sensor support"
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_AP1302
tristate "AP1302 external ISP support"
depends on I2C && VIDEO_V4L2
---help---
This is a Video4Linux2 sensor-level driver for the external
ISP AP1302.
AP1302 is an exteral ISP.
It currently only works with the atomisp driver.
config VIDEO_GC0310
tristate "GC0310 sensor support"
depends on I2C && VIDEO_V4L2
---help---
This is a Video4Linux2 sensor-level driver for the Galaxycore
GC0310 0.3MP sensor.
config VIDEO_OV2680
tristate "Omnivision OV2680 sensor support"
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_LM3554
tristate "LM3554 flash light driver"
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
#
# Makefile for sensor drivers
#
obj-$(CONFIG_VIDEO_IMX) += imx/
obj-$(CONFIG_VIDEO_OV5693) += ov5693/
obj-$(CONFIG_VIDEO_MT9M114) += mt9m114.o
obj-$(CONFIG_VIDEO_GC2235) += gc2235.o
obj-$(CONFIG_VIDEO_OV2722) += ov2722.o
obj-$(CONFIG_VIDEO_OV2680) += ov2680.o
obj-$(CONFIG_VIDEO_GC0310) += gc0310.o
obj-$(CONFIG_VIDEO_MSRLIST_HELPER) += libmsrlisthelper.o
obj-$(CONFIG_VIDEO_AP1302) += ap1302.o
# Makefile for flash drivers
#
obj-$(CONFIG_VIDEO_LM3554) += lm3554.o
ccflags-y += -Werror
This diff is collapsed.
/*
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
*/
#ifndef __AP1302_H__
#define __AP1302_H__
#include <linux/atomisp_platform.h>
#include <linux/regmap.h>
#include <linux/types.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-subdev.h>
#define AP1302_NAME "ap1302"
#define AP1302_CHIP_ID 0x265
#define AP1302_I2C_MAX_LEN 65534
#define AP1302_FW_WINDOW_OFFSET 0x8000
#define AP1302_FW_WINDOW_SIZE 0x2000
#define AP1302_REG16 2
#define AP1302_REG32 4
#define REG_CHIP_VERSION 0x0000
#define REG_CHIP_REV 0x0050
#define REG_MF_ID 0x0004
#define REG_ERROR 0x0006
#define REG_CTRL 0x1000
#define REG_DZ_TGT_FCT 0x1010
#define REG_SFX_MODE 0x1016
#define REG_SS_HEAD_PT0 0x1174
#define REG_AE_BV_OFF 0x5014
#define REG_AE_BV_BIAS 0x5016
#define REG_AWB_CTRL 0x5100
#define REG_FLICK_CTRL 0x5440
#define REG_SCENE_CTRL 0x5454
#define REG_BOOTDATA_STAGE 0x6002
#define REG_SENSOR_SELECT 0x600C
#define REG_SYS_START 0x601A
#define REG_SIP_CRC 0xF052
#define REG_PREVIEW_BASE 0x2000
#define REG_SNAPSHOT_BASE 0x3000
#define REG_VIDEO_BASE 0x4000
#define CNTX_WIDTH 0x00
#define CNTX_HEIGHT 0x02
#define CNTX_ROI_X0 0x04
#define CNTX_ROI_Y0 0x06
#define CNTX_ROI_X1 0x08
#define CNTX_ROI_Y1 0x0A
#define CNTX_ASPECT 0x0C
#define CNTX_LOCK 0x0E
#define CNTX_ENABLE 0x10
#define CNTX_OUT_FMT 0x12
#define CNTX_SENSOR_MODE 0x14
#define CNTX_MIPI_CTRL 0x16
#define CNTX_MIPI_II_CTRL 0x18
#define CNTX_LINE_TIME 0x1C
#define CNTX_MAX_FPS 0x20
#define CNTX_AE_USG 0x22
#define CNTX_AE_UPPER_ET 0x24
#define CNTX_AE_MAX_ET 0x28
#define CNTX_SS 0x2C
#define CNTX_S1_SENSOR_MODE 0x2E
#define CNTX_HINF_CTRL 0x30
#define CTRL_CNTX_MASK 0x03
#define CTRL_CNTX_OFFSET 0x00
#define HINF_CTRL_LANE_MASK 0x07
#define HINF_CTRL_LANE_OFFSET 0x00
#define MIPI_CTRL_IMGVC_MASK 0xC0
#define MIPI_CTRL_IMGVC_OFFSET 0x06
#define MIPI_CTRL_IMGTYPE_AUTO 0x3F
#define MIPI_CTRL_SSVC_MASK 0xC000
#define MIPI_CTRL_SSVC_OFFSET 0x0E
#define MIPI_CTRL_SSTYPE_MASK 0x3F00
#define MIPI_CTRL_SSTYPE_OFFSET 0x08
#define OUT_FMT_IIS_MASK 0x30
#define OUT_FMT_IIS_OFFSET 0x08
#define OUT_FMT_SS_MASK 0x1000
#define OUT_FMT_SS_OFFSET 0x12
#define OUT_FMT_TYPE_MASK 0xFF
#define SENSOR_SELECT_MASK 0x03
#define SENSOR_SELECT_OFFSET 0x00
#define AWB_CTRL_MODE_MASK 0x0F
#define AWB_CTRL_MODE_OFFSET 0x00
#define AWB_CTRL_FLASH_MASK 0x100
#define AP1302_FMT_UYVY422 0x50
#define AP1302_SYS_ACTIVATE 0x8010
#define AP1302_SYS_SWITCH 0x8140
#define AP1302_SENSOR_PRI 0x01
#define AP1302_SENSOR_SEC 0x02
#define AP1302_SS_CTRL 0x31
#define AP1302_MAX_RATIO_MISMATCH 10 /* Unit in percentage */
#define AP1302_MAX_EV 2
#define AP1302_MIN_EV -2
enum ap1302_contexts {
CONTEXT_PREVIEW = 0,
CONTEXT_SNAPSHOT,
CONTEXT_VIDEO,
CONTEXT_NUM
};
/* The context registers are defined according to preview/video registers.
Preview and video context have the same register definition.
But snapshot context does not have register S1_SENSOR_MODE.
When setting snapshot registers, if the offset exceeds
S1_SENSOR_MODE, the actual offset needs to minus 2. */
struct ap1302_context_config {
u16 width;
u16 height;
u16 roi_x0;
u16 roi_y0;
u16 roi_x1;
u16 roi_y1;
u16 aspect_factor;
u16 lock;
u16 enable;
u16 out_fmt;
u16 sensor_mode;
u16 mipi_ctrl;
u16 mipi_ii_ctrl;
u16 padding;
u32 line_time;
u16 max_fps;
u16 ae_usg;
u32 ae_upper_et;
u32 ae_max_et;
u16 ss;
u16 s1_sensor_mode;
u16 hinf_ctrl;
u32 reserved;
};
struct ap1302_res_struct {
u16 width;
u16 height;
u16 fps;
};
struct ap1302_context_res {
s32 res_num;
s32 cur_res;
struct ap1302_res_struct *res_table;
};
struct ap1302_device {
struct v4l2_subdev sd;
struct media_pad pad;
struct camera_sensor_platform_data *platform_data;
const struct firmware *fw;
struct mutex input_lock; /* serialize sensor's ioctl */
struct v4l2_mbus_framefmt format;
struct v4l2_ctrl_handler ctrl_handler;
struct v4l2_ctrl *run_mode;
struct ap1302_context_config cntx_config[CONTEXT_NUM];
struct ap1302_context_res cntx_res[CONTEXT_NUM];
enum ap1302_contexts cur_context;
unsigned int num_lanes;
struct regmap *regmap16;
struct regmap *regmap32;
bool sys_activated;
bool power_on;
};
struct ap1302_firmware {
u32 crc;
u32 pll_init_size;
u32 total_size;
u32 reserved;
};
struct ap1302_context_info {
u16 offset;
u16 len;
char *name;
};
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
config VIDEO_IMX
tristate "sony imx sensor support"
depends on I2C && VIDEO_V4L2 && VIDEO_MSRLIST_HELPER && m
---help---
This is a Video4Linux2 sensor-level driver for the Sony
IMX RAW sensor.
It currently depends on internal V4L2 extensions defined in
atomisp driver.
obj-$(CONFIG_VIDEO_IMX) += imx1x5.o
imx1x5-objs := imx.o drv201.o ad5816g.o dw9714.o dw9719.o dw9718.o vcm.o otp.o otp_imx.o otp_brcc064_e2prom.o otp_e2prom.o
ov8858_driver-objs := ../ov8858.o dw9718.o vcm.o
obj-$(CONFIG_VIDEO_OV8858) += ov8858_driver.o
ccflags-y += -Werror
This diff is collapsed.
#ifndef __AD5816G_H__
#define __AD5816G_H__
#include <linux/atomisp_platform.h>
#include <linux/types.h>
#include <linux/time.h>
#define AD5816G_VCM_ADDR 0x0e
/* ad5816g device structure */
struct ad5816g_device {
const struct camera_af_platform_data *platform_data;
struct timespec timestamp_t_focus_abs;
struct timespec focus_time; /* Time when focus was last time set */
s32 focus; /* Current focus value */
s16 number_of_steps;
};
#define AD5816G_INVALID_CONFIG 0xffffffff
#define AD5816G_MAX_FOCUS_POS 1023
#define DELAY_PER_STEP_NS 1000000
#define DELAY_MAX_PER_STEP_NS (1000000 * 1023)
/* Register Definitions */
#define AD5816G_IC_INFO 0x00
#define AD5816G_IC_VERSION 0x01
#define AD5816G_CONTROL 0x02
#define AD5816G_VCM_CODE_MSB 0x03
#define AD5816G_VCM_CODE_LSB 0x04
#define AD5816G_STATUS 0x05
#define AD5816G_MODE 0x06
#define AD5816G_VCM_FREQ 0x07
#define AD5816G_VCM_THRESHOLD 0x08
/* ARC MODE ENABLE */
#define AD5816G_ARC_EN 0x02
/* ARC RES2 MODE */
#define AD5816G_ARC_RES2 0x01
/* ARC VCM FREQ - 78.1Hz */
#define AD5816G_DEF_FREQ 0x7a
/* ARC VCM THRESHOLD - 0x08 << 1 */
#define AD5816G_DEF_THRESHOLD 0x64
#define AD5816G_ID 0x24
#define VCM_CODE_MASK 0x03ff
#define AD5816G_MODE_2_5M_SWITCH_CLOCK 0x14
#endif
#ifndef __COMMON_H__
#define __COMMON_H__
#define MAX_FPS_OPTIONS_SUPPORTED 3
#define I2C_MSG_LENGTH 0x2
#define E2PROM_2ADDR 0x80000000
#define E2PROM_ADDR_MASK 0x7fffffff
/* Defines for register writes and register array processing */
#define IMX_BYTE_MAX 32
#define IMX_SHORT_MAX 16
#define I2C_RETRY_COUNT 5
#define IMX_TOK_MASK 0xfff0
enum imx_tok_type {
IMX_8BIT = 0x0001,
IMX_16BIT = 0x0002,
IMX_TOK_TERM = 0xf000, /* terminating token for reg list */
IMX_TOK_DELAY = 0xfe00 /* delay token for reg list */
};
/**
* struct imx_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 imx_reg {
enum imx_tok_type type;
u16 sreg;
u32 val; /* @set value for read/mod/write, @mask */
};
struct imx_fps_setting {
int fps;
unsigned short pixels_per_line;
unsigned short lines_per_frame;
int mipi_freq; /* MIPI lane frequency in kHz */
const struct imx_reg *regs; /* regs that the fps setting needs */
};
struct imx_resolution {
const struct imx_fps_setting fps_options[MAX_FPS_OPTIONS_SUPPORTED];
u8 *desc;
const struct imx_reg *regs;
int res;
int width;
int height;
int fps;
unsigned short pixels_per_line;
unsigned short lines_per_frame;
int mipi_freq; /* MIPI lane frequency in kHz */
unsigned short skip_frames;
u8 bin_factor_x;
u8 bin_factor_y;
bool used;
};
#define GROUPED_PARAMETER_HOLD_ENABLE {IMX_8BIT, 0x0104, 0x1}
#define GROUPED_PARAMETER_HOLD_DISABLE {IMX_8BIT, 0x0104, 0x0}
int imx_write_reg(struct i2c_client *client, u16 data_length, u16 reg, u16 val);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment