M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions

View File

@ -0,0 +1,5 @@
GCC_VERSION := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/io
obj-$(CONFIG_MSM_EEPROM) += msm_camera_eeprom.o
obj-$(CONFIG_IMX074_EEPROM) += imx074_eeprom.o
obj-$(CONFIG_IMX091_EEPROM) += imx091_eeprom.o

View File

@ -0,0 +1,113 @@
/* Copyright (c) 2011-2012, The Linux Foundation. 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 and
* only 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 "msm_camera_eeprom.h"
#include "msm_camera_i2c.h"
DEFINE_MUTEX(imx074_eeprom_mutex);
static struct msm_eeprom_ctrl_t imx074_eeprom_t;
static const struct i2c_device_id imx074_eeprom_i2c_id[] = {
{"imx074_eeprom", (kernel_ulong_t)&imx074_eeprom_t},
{ }
};
static struct i2c_driver imx074_eeprom_i2c_driver = {
.id_table = imx074_eeprom_i2c_id,
.probe = msm_eeprom_i2c_probe,
.remove = __exit_p(imx074_eeprom_i2c_remove),
.driver = {
.name = "imx074_eeprom",
},
};
static int __init imx074_eeprom_i2c_add_driver(void)
{
int rc = 0;
rc = i2c_add_driver(imx074_eeprom_t.i2c_driver);
return rc;
}
static struct v4l2_subdev_core_ops imx074_eeprom_subdev_core_ops = {
.ioctl = msm_eeprom_subdev_ioctl,
};
static struct v4l2_subdev_ops imx074_eeprom_subdev_ops = {
.core = &imx074_eeprom_subdev_core_ops,
};
static uint8_t imx074_wbcalib_data[6];
static struct msm_calib_wb imx074_wb_data;
static struct msm_camera_eeprom_info_t imx074_calib_supp_info = {
{FALSE, 0, 0, 1},
{TRUE, 6, 0, 1024},
{FALSE, 0, 0, 1},
{FALSE, 0, 0, 1},
{FALSE, 0, 0, 1},
};
static struct msm_camera_eeprom_read_t imx074_eeprom_read_tbl[] = {
{0x10, &imx074_wbcalib_data[0], 6, 0},
};
static struct msm_camera_eeprom_data_t imx074_eeprom_data_tbl[] = {
{&imx074_wb_data, sizeof(struct msm_calib_wb)},
};
static void imx074_format_wbdata(void)
{
imx074_wb_data.r_over_g = (uint16_t)(imx074_wbcalib_data[0] << 8) |
imx074_wbcalib_data[1];
imx074_wb_data.b_over_g = (uint16_t)(imx074_wbcalib_data[2] << 8) |
imx074_wbcalib_data[3];
imx074_wb_data.gr_over_gb = (uint16_t)(imx074_wbcalib_data[4] << 8) |
imx074_wbcalib_data[5];
}
void imx074_format_calibrationdata(void)
{
imx074_format_wbdata();
}
static struct msm_eeprom_ctrl_t imx074_eeprom_t = {
.i2c_driver = &imx074_eeprom_i2c_driver,
.i2c_addr = 0xA4,
.eeprom_v4l2_subdev_ops = &imx074_eeprom_subdev_ops,
.i2c_client = {
.addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
},
.eeprom_mutex = &imx074_eeprom_mutex,
.func_tbl = {
.eeprom_init = NULL,
.eeprom_release = NULL,
.eeprom_get_info = msm_camera_eeprom_get_info,
.eeprom_get_data = msm_camera_eeprom_get_data,
.eeprom_set_dev_addr = NULL,
.eeprom_format_data = imx074_format_calibrationdata,
},
.info = &imx074_calib_supp_info,
.info_size = sizeof(struct msm_camera_eeprom_info_t),
.read_tbl = imx074_eeprom_read_tbl,
.read_tbl_size = ARRAY_SIZE(imx074_eeprom_read_tbl),
.data_tbl = imx074_eeprom_data_tbl,
.data_tbl_size = ARRAY_SIZE(imx074_eeprom_data_tbl),
};
subsys_initcall(imx074_eeprom_i2c_add_driver);
MODULE_DESCRIPTION("IMX074 EEPROM");
MODULE_LICENSE("GPL v2");

View File

@ -0,0 +1,128 @@
/* Copyright (c) 2012, The Linux Foundation. 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 and
* only 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 "msm_camera_eeprom.h"
#include "msm_camera_i2c.h"
DEFINE_MUTEX(imx091_eeprom_mutex);
static struct msm_eeprom_ctrl_t imx091_eeprom_t;
static const struct i2c_device_id imx091_eeprom_i2c_id[] = {
{"imx091_eeprom", (kernel_ulong_t)&imx091_eeprom_t},
{ }
};
static struct i2c_driver imx091_eeprom_i2c_driver = {
.id_table = imx091_eeprom_i2c_id,
.probe = msm_eeprom_i2c_probe,
.remove = __exit_p(imx091_eeprom_i2c_remove),
.driver = {
.name = "imx091_eeprom",
},
};
static int __init imx091_eeprom_i2c_add_driver(void)
{
int rc = 0;
rc = i2c_add_driver(imx091_eeprom_t.i2c_driver);
return rc;
}
static struct v4l2_subdev_core_ops imx091_eeprom_subdev_core_ops = {
.ioctl = msm_eeprom_subdev_ioctl,
};
static struct v4l2_subdev_ops imx091_eeprom_subdev_ops = {
.core = &imx091_eeprom_subdev_core_ops,
};
static uint8_t imx091_wbcalib_data[6];
static uint8_t imx091_afcalib_data[6];
static struct msm_calib_wb imx091_wb_data;
static struct msm_calib_af imx091_af_data;
static struct msm_camera_eeprom_info_t imx091_calib_supp_info = {
{TRUE, 6, 1, 1},
{TRUE, 6, 0, 32768},
{FALSE, 0, 0, 1},
{FALSE, 0, 0, 1},
{FALSE, 0, 0, 1},
};
static struct msm_camera_eeprom_read_t imx091_eeprom_read_tbl[] = {
{0x05, &imx091_wbcalib_data[0], 6, 0},
{0x0B, &imx091_afcalib_data[0], 6, 0},
};
static struct msm_camera_eeprom_data_t imx091_eeprom_data_tbl[] = {
{&imx091_wb_data, sizeof(struct msm_calib_wb)},
{&imx091_af_data, sizeof(struct msm_calib_af)},
};
static void imx091_format_wbdata(void)
{
imx091_wb_data.r_over_g = (uint16_t)(imx091_wbcalib_data[1] << 8) |
(imx091_wbcalib_data[0] - 0x32);
imx091_wb_data.b_over_g = (uint16_t)(imx091_wbcalib_data[3] << 8) |
(imx091_wbcalib_data[2] - 0x32);
imx091_wb_data.gr_over_gb = (uint16_t)(imx091_wbcalib_data[5] << 8) |
(imx091_wbcalib_data[4] - 0x32);
}
static void imx091_format_afdata(void)
{
imx091_af_data.inf_dac = (uint16_t)(imx091_afcalib_data[1] << 8) |
imx091_afcalib_data[0];
imx091_af_data.macro_dac = (uint16_t)(imx091_afcalib_data[3] << 8) |
imx091_afcalib_data[2];
imx091_af_data.start_dac = (uint16_t)(imx091_afcalib_data[5] << 8) |
imx091_afcalib_data[4];
}
void imx091_format_calibrationdata(void)
{
imx091_format_wbdata();
imx091_format_afdata();
}
static struct msm_eeprom_ctrl_t imx091_eeprom_t = {
.i2c_driver = &imx091_eeprom_i2c_driver,
.i2c_addr = 0xA1,
.eeprom_v4l2_subdev_ops = &imx091_eeprom_subdev_ops,
.i2c_client = {
.addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
},
.eeprom_mutex = &imx091_eeprom_mutex,
.func_tbl = {
.eeprom_init = NULL,
.eeprom_release = NULL,
.eeprom_get_info = msm_camera_eeprom_get_info,
.eeprom_get_data = msm_camera_eeprom_get_data,
.eeprom_set_dev_addr = NULL,
.eeprom_format_data = imx091_format_calibrationdata,
},
.info = &imx091_calib_supp_info,
.info_size = sizeof(struct msm_camera_eeprom_info_t),
.read_tbl = imx091_eeprom_read_tbl,
.read_tbl_size = ARRAY_SIZE(imx091_eeprom_read_tbl),
.data_tbl = imx091_eeprom_data_tbl,
.data_tbl_size = ARRAY_SIZE(imx091_eeprom_data_tbl),
};
subsys_initcall(imx091_eeprom_i2c_add_driver);
MODULE_DESCRIPTION("imx091 EEPROM");
MODULE_LICENSE("GPL v2");

View File

@ -0,0 +1,196 @@
/* Copyright (c) 2011-2012, The Linux Foundation. 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 and
* only 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 "msm_camera_eeprom.h"
int32_t msm_camera_eeprom_read(struct msm_eeprom_ctrl_t *ectrl,
uint32_t reg_addr, void *data, uint32_t num_byte,
uint16_t convert_endian)
{
int rc = 0;
if (ectrl->func_tbl.eeprom_set_dev_addr != NULL)
ectrl->func_tbl.eeprom_set_dev_addr(ectrl, &reg_addr);
if (!convert_endian) {
rc = msm_camera_i2c_read_seq(
&ectrl->i2c_client, reg_addr, data, num_byte);
} else {
unsigned char buf[num_byte];
uint8_t *data_ptr = (uint8_t *) data;
int i;
rc = msm_camera_i2c_read_seq(
&ectrl->i2c_client, reg_addr, buf, num_byte);
for (i = 0; i < num_byte; i += 2) {
data_ptr[i] = buf[i+1];
data_ptr[i+1] = buf[i];
}
}
return rc;
}
int32_t msm_camera_eeprom_read_tbl(struct msm_eeprom_ctrl_t *ectrl,
struct msm_camera_eeprom_read_t *read_tbl, uint16_t tbl_size)
{
int i, rc = 0;
CDBG("%s: open\n", __func__);
if (read_tbl == NULL)
return rc;
for (i = 0; i < tbl_size; i++) {
rc = msm_camera_eeprom_read
(ectrl, read_tbl[i].reg_addr,
read_tbl[i].dest_ptr, read_tbl[i].num_byte,
read_tbl[i].convert_endian);
if (rc < 0) {
pr_err("%s: read failed\n", __func__);
return rc;
}
}
CDBG("%s: done\n", __func__);
return rc;
}
int32_t msm_camera_eeprom_get_info(struct msm_eeprom_ctrl_t *ectrl,
struct msm_camera_eeprom_info_t *einfo)
{
int rc = 0;
CDBG("%s: open\n", __func__);
memcpy(einfo, ectrl->info, ectrl->info_size);
CDBG("%s: done =%d\n", __func__, rc);
return rc;
}
int32_t msm_camera_eeprom_get_data(struct msm_eeprom_ctrl_t *ectrl,
struct msm_eeprom_data_t *edata)
{
int rc = 0;
if (edata->index >= ectrl->data_tbl_size)
return -EFAULT;
if (copy_to_user(edata->eeprom_data,
ectrl->data_tbl[edata->index].data,
ectrl->data_tbl[edata->index].size))
rc = -EFAULT;
return rc;
}
int32_t msm_eeprom_config(struct msm_eeprom_ctrl_t *e_ctrl,
void __user *argp)
{
struct msm_eeprom_cfg_data cdata;
int32_t rc = 0;
if (copy_from_user(&cdata,
(void *)argp,
sizeof(struct msm_eeprom_cfg_data)))
return -EFAULT;
mutex_lock(e_ctrl->eeprom_mutex);
switch (cdata.cfgtype) {
case CFG_GET_EEPROM_INFO:
if (e_ctrl->func_tbl.eeprom_get_info == NULL) {
rc = -EFAULT;
break;
}
rc = e_ctrl->func_tbl.eeprom_get_info(e_ctrl,
&cdata.cfg.get_info);
cdata.is_eeprom_supported = 1;
if (copy_to_user((void *)argp,
&cdata,
sizeof(struct msm_eeprom_cfg_data)))
rc = -EFAULT;
break;
case CFG_GET_EEPROM_DATA:
if (e_ctrl->func_tbl.eeprom_get_data == NULL) {
rc = -EFAULT;
break;
}
rc = e_ctrl->func_tbl.eeprom_get_data(e_ctrl,
&cdata.cfg.get_data);
if (copy_to_user((void *)argp,
&cdata,
sizeof(struct msm_eeprom_cfg_data)))
rc = -EFAULT;
break;
default:
break;
}
mutex_unlock(e_ctrl->eeprom_mutex);
return rc;
}
struct msm_eeprom_ctrl_t *get_ectrl(struct v4l2_subdev *sd)
{
return container_of(sd, struct msm_eeprom_ctrl_t, sdev);
}
long msm_eeprom_subdev_ioctl(struct v4l2_subdev *sd,
unsigned int cmd, void *arg)
{
struct msm_eeprom_ctrl_t *e_ctrl = get_ectrl(sd);
void __user *argp = (void __user *)arg;
switch (cmd) {
case VIDIOC_MSM_EEPROM_CFG:
return msm_eeprom_config(e_ctrl, argp);
default:
return -ENOIOCTLCMD;
}
}
int32_t msm_eeprom_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int rc = 0;
struct msm_eeprom_ctrl_t *e_ctrl_t = NULL;
CDBG("%s called\n", __func__);
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
pr_err("i2c_check_functionality failed\n");
goto probe_failure;
}
e_ctrl_t = (struct msm_eeprom_ctrl_t *)(id->driver_data);
e_ctrl_t->i2c_client.client = client;
if (e_ctrl_t->i2c_addr != 0)
e_ctrl_t->i2c_client.client->addr = e_ctrl_t->i2c_addr;
CDBG("%s client = %x\n", __func__, (unsigned int) client);
/* Assign name for sub device */
snprintf(e_ctrl_t->sdev.name, sizeof(e_ctrl_t->sdev.name),
"%s", e_ctrl_t->i2c_driver->driver.name);
if (e_ctrl_t->func_tbl.eeprom_init != NULL) {
rc = e_ctrl_t->func_tbl.eeprom_init(e_ctrl_t,
e_ctrl_t->i2c_client.client->adapter);
}
msm_camera_eeprom_read_tbl(e_ctrl_t,
e_ctrl_t->read_tbl,
e_ctrl_t->read_tbl_size);
if (e_ctrl_t->func_tbl.eeprom_format_data != NULL)
e_ctrl_t->func_tbl.eeprom_format_data();
if (e_ctrl_t->func_tbl.eeprom_release != NULL)
rc = e_ctrl_t->func_tbl.eeprom_release(e_ctrl_t);
/* Initialize sub device */
v4l2_i2c_subdev_init(&e_ctrl_t->sdev,
e_ctrl_t->i2c_client.client,
e_ctrl_t->eeprom_v4l2_subdev_ops);
CDBG("%s success resut=%d\n", __func__, rc);
return rc;
probe_failure:
pr_err("%s failed! rc = %d\n", __func__, rc);
return rc;
}

View File

@ -0,0 +1,82 @@
/* Copyright (c) 2011-2012, The Linux Foundation. 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 and
* only 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 MSM_CAMERA_EEPROM_H
#define MSM_CAMERA_EEPROM_H
#include <linux/delay.h>
#include <mach/camera.h>
#include <media/v4l2-subdev.h>
#include "msm_camera_i2c.h"
#define TRUE 1
#define FALSE 0
struct msm_eeprom_ctrl_t;
struct msm_camera_eeprom_fn_t {
int32_t (*eeprom_init)
(struct msm_eeprom_ctrl_t *ectrl,
struct i2c_adapter *adapter);
int32_t (*eeprom_release)
(struct msm_eeprom_ctrl_t *ectrl);
int32_t (*eeprom_get_info)
(struct msm_eeprom_ctrl_t *ectrl,
struct msm_camera_eeprom_info_t *einfo);
int32_t (*eeprom_get_data)
(struct msm_eeprom_ctrl_t *ectrl,
struct msm_eeprom_data_t *edata);
void (*eeprom_set_dev_addr)
(struct msm_eeprom_ctrl_t*, uint32_t*);
void (*eeprom_format_data)
(void);
};
struct msm_camera_eeprom_read_t {
uint32_t reg_addr;
void *dest_ptr;
uint32_t num_byte;
uint16_t convert_endian;
};
struct msm_camera_eeprom_data_t {
void *data;
uint16_t size;
};
struct msm_eeprom_ctrl_t {
struct msm_camera_i2c_client i2c_client;
uint16_t i2c_addr;
struct i2c_driver *i2c_driver;
struct mutex *eeprom_mutex;
struct v4l2_subdev sdev;
struct v4l2_subdev_ops *eeprom_v4l2_subdev_ops;
struct msm_camera_eeprom_fn_t func_tbl;
struct msm_camera_eeprom_info_t *info;
uint16_t info_size;
struct msm_camera_eeprom_read_t *read_tbl;
uint16_t read_tbl_size;
struct msm_camera_eeprom_data_t *data_tbl;
uint16_t data_tbl_size;
};
int32_t msm_camera_eeprom_get_data(struct msm_eeprom_ctrl_t *ectrl,
struct msm_eeprom_data_t *edata);
int32_t msm_camera_eeprom_get_info(struct msm_eeprom_ctrl_t *ectrl,
struct msm_camera_eeprom_info_t *einfo);
int32_t msm_eeprom_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id);
long msm_eeprom_subdev_ioctl(struct v4l2_subdev *sd,
unsigned int cmd, void *arg);
#define VIDIOC_MSM_EEPROM_CFG \
_IOWR('V', BASE_VIDIOC_PRIVATE + 12, void __user *)
#endif