Hi JerryChang,
Thank you very much for reply!
I looked this file [NVIDIA Tegra Linux Driver Package]-> [Development Guide]-> [Camera Development]-> [Sensor Driver Programming Guide] before I writed my driver.
Has any problems with my dtsi files?
Here is my driver ar0135.c.
/*
* ar0135_v4l2.c - ar0135 sensor driver
*
* Copyright (c) 2013-2017, NVIDIA CORPORATION. All rights reserved.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define DEBUG 1 //enable dev_dbg
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/gpio.h>
#include <linux/module.h>
#include <linux/seq_file.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <media/camera_common.h>
#include <media/ar0135.h>
#include "../platform/tegra/camera/camera_gpio.h"
#include "ar0135_mode_tbls.h"
#define AR0135_MAX_COARSE_DIFF 6
#define AR0135_GAIN_SHIFT 8
#define AR0135_REAL_GAIN_SHIFT 4
#define AR0135_MIN_GAIN (1 << AR0135_GAIN_SHIFT)
#define AR0135_MAX_GAIN (16 << AR0135_GAIN_SHIFT)
#define AR0135_MAX_UNREAL_GAIN (0x0F80)
#define AR0135_MIN_FRAME_LENGTH (0x0)
#define AR0135_MAX_FRAME_LENGTH (0x7fff)
#define AR0135_MIN_EXPOSURE_COARSE (0x0002)
#define AR0135_MAX_EXPOSURE_COARSE \
(AR0135_MAX_FRAME_LENGTH-AR0135_MAX_COARSE_DIFF)
// #define AR0135_DEFAULT_LINE_LENGTH (0xA80)
// #define AR0135_DEFAULT_PIXEL_CLOCK (160)
#define AR0135_DEFAULT_LINE_LENGTH (0x672)
#define AR0135_DEFAULT_PIXEL_CLOCK (74)
#define AR0135_DEFAULT_GAIN AR0135_MIN_GAIN
//#define AR0135_DEFAULT_FRAME_LENGTH (0x07C0)
#define AR0135_DEFAULT_FRAME_LENGTH (0x03DE)
#define AR0135_DEFAULT_FRAME_LENGTH_CB (0x005A)
#define AR0135_DEFAULT_EXPOSURE_COARSE \
(AR0135_DEFAULT_FRAME_LENGTH-AR0135_MAX_COARSE_DIFF)
#define AR0135_DEFAULT_MODE AR0135_MODE_1280X728//AR0135_MODE_2592X1944
//#define AR0135_DEFAULT_HDR_MODE AR0135_MODE_1280X728_HDR//AR0135_MODE_2592X1944_HDR
#define AR0135_DEFAULT_WIDTH 1280 //2592
#define AR0135_DEFAULT_HEIGHT 728 //1944
#define AR0135_DEFAULT_DATAFMT MEDIA_BUS_FMT_Y12_1X12//MEDIA_BUS_FMT_SRGGB10_1X10
//#define AR0135_DEFAULT_CLK_FREQ 24000000
#define AR0135_DEFAULT_CLK_FREQ 25000000
struct ar0135 {
struct camera_common_power_rail power;
int numctrls;
struct v4l2_ctrl_handler ctrl_handler;
struct camera_common_eeprom_data eeprom[AR0135_EEPROM_NUM_BLOCKS];
struct camera_common_deserializer_data de_data;
struct camera_common_serializer_data se_data;
u8 eeprom_buf[AR0135_EEPROM_SIZE];
struct i2c_client *i2c_client;
struct v4l2_subdev *subdev;
struct media_pad pad;
int reg_offset;
s32 group_hold_prev;
u32 frame_length;
bool group_hold_en;
struct regmap *regmap;
struct camera_common_data *s_data;
struct camera_common_pdata *pdata;
struct v4l2_ctrl *ctrls[];
};
static struct regmap_config ar0135_regmap_config = {
.reg_bits = 16,
.val_bits = 16,
//.val_bits = 8,
};
// static int ar0135_g_volatile_ctrl(struct v4l2_ctrl *ctrl);
static int ar0135_s_ctrl(struct v4l2_ctrl *ctrl);
static void ar0135_update_ctrl_range(struct ar0135 *priv, s32 frame_length);
static const struct v4l2_ctrl_ops ar0135_ctrl_ops = {
//.g_volatile_ctrl = ar0135_g_volatile_ctrl,
.s_ctrl = ar0135_s_ctrl,
};
static struct v4l2_ctrl_config ctrl_config_list[] = {
/* Do not change the name field for the controls! */
{
.ops = &ar0135_ctrl_ops,
.id = V4L2_CID_GAIN,
.name = "Gain",
.type = V4L2_CTRL_TYPE_INTEGER,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = AR0135_MIN_GAIN,
.max = AR0135_MAX_GAIN,
.def = AR0135_DEFAULT_GAIN,
.step = 1,
},
{
.ops = &ar0135_ctrl_ops,
.id = V4L2_CID_FRAME_LENGTH,
.name = "Frame Length",
.type = V4L2_CTRL_TYPE_INTEGER,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = AR0135_MIN_FRAME_LENGTH,
.max = AR0135_MAX_FRAME_LENGTH,
.def = AR0135_DEFAULT_FRAME_LENGTH,
.step = 1,
},
{
.ops = &ar0135_ctrl_ops,
.id = V4L2_CID_COARSE_TIME,
.name = "Coarse Time",
.type = V4L2_CTRL_TYPE_INTEGER,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = AR0135_MIN_EXPOSURE_COARSE,
.max = AR0135_MAX_EXPOSURE_COARSE,
.def = AR0135_DEFAULT_EXPOSURE_COARSE,
.step = 1,
},
{
.ops = &ar0135_ctrl_ops,
.id = V4L2_CID_COARSE_TIME_SHORT,
.name = "Coarse Time Short",
.type = V4L2_CTRL_TYPE_INTEGER,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = AR0135_MIN_EXPOSURE_COARSE,
.max = AR0135_MAX_EXPOSURE_COARSE,
.def = AR0135_DEFAULT_EXPOSURE_COARSE,
.step = 1,
},
{
.ops = &ar0135_ctrl_ops,
.id = V4L2_CID_HDR_EN,
.name = "HDR enable",
.type = V4L2_CTRL_TYPE_INTEGER_MENU,
.min = 0,
.max = ARRAY_SIZE(switch_ctrl_qmenu) - 1,
.menu_skip_mask = 0,
.def = 0,
.qmenu_int = switch_ctrl_qmenu,
},
{
.ops = &ar0135_ctrl_ops,
.id = V4L2_CID_FRAME_LENGTH_CB,
.name = "Frame Length Cb",
.type = V4L2_CTRL_TYPE_INTEGER,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = AR0135_MIN_FRAME_LENGTH,
.max = AR0135_MAX_FRAME_LENGTH,
.def = AR0135_DEFAULT_FRAME_LENGTH_CB,
.step = 1,
},
};
static inline void ar0135_get_frame_length_regs(ar0135_reg *regs,
u32 frame_length)
{
regs->addr = AR0135_FRAME_LENGTH_ADDR_LSB;
regs->val = frame_length & 0xffff;
}
static inline void ar0135_get_frame_length_cb_regs(ar0135_reg *regs,
u32 frame_length)
{
regs->addr = AR0135_FRAME_LENGTH_ADDR_MSB;
regs->val = frame_length & 0xffff;
}
static inline void ar0135_get_coarse_time_regs(ar0135_reg *regs,
u32 coarse_time)
{
regs->addr = AR0135_COARSE_TIME_ADDR_1;
regs->val = coarse_time & 0xffff;
}
static inline void ar0135_get_coarse_time_short_regs(ar0135_reg *regs,
u32 coarse_time)
{
regs->addr = AR0135_COARSE_TIME_SHORT_ADDR_1;
regs->val = coarse_time & 0xffff;
}
static inline void ar0135_get_gain_regs(ar0135_reg *regs,
u16 gain)
{
regs->addr = AR0135_GAIN_ADDR_LSB;
regs->val = gain & 0xffff;
}
static int test_mode;
module_param(test_mode, int, 0644);
static inline int ar0135_read_reg(struct camera_common_data *s_data,
u16 addr, u16 *val)
{
struct ar0135 *priv = (struct ar0135 *)s_data->priv;
int err = 0;
u32 reg_val = 0;
err = regmap_read(priv->regmap, addr, ®_val);
if (err)
pr_err("%s:i2c read failed, %x\n",
__func__, addr);
*val = reg_val & 0xFFFF;
return err;
}
static int ar0135_write_reg(struct camera_common_data *s_data, u16 addr, u16 val)
{
int err;
struct ar0135 *priv = (struct ar0135 *)s_data->priv;
err = regmap_write(priv->regmap, addr, val);
if (err)
pr_err("%s:i2c write failed, %x = %x\n",
__func__, addr, val);
return err;
}
static int ar0135_write_table(struct ar0135 *priv,
const ar0135_reg table[])
{
const struct reg_16 *next;
int err;
for (next = table;; next++) {
/* Handle special address values */
if (next->addr == AR0135_TABLE_END)
break;
if (next->addr == AR0135_TABLE_WAIT_MS) {
msleep_range(next->val);
continue;
}
err = regmap_write(priv->regmap,next->addr,next->val);
if (err)
{
dev_err(&priv->i2c_client->dev,"%s: addr %04x val %04x faild\n", __func__,next->addr,next->val);
return err;
}
}
return 0;
}
static int ar0135_power_on(struct camera_common_data *s_data)
{
int err = 0;
struct ar0135 *priv = (struct ar0135 *)s_data->priv;
struct camera_common_power_rail *pw = &priv->power;
dev_dbg(&priv->i2c_client->dev, "%s: power on\n", __func__);
if (priv->pdata && priv->pdata->power_on) {
err = priv->pdata->power_on(pw);
if (err)
pr_err("%s failed.\n", __func__);
else
pw->state = SWITCH_ON;
dev_dbg(&priv->i2c_client->dev, "%s: power on test,err\n", __func__);
return err;
}
/* sleeps calls in the sequence below are for internal device
* signal propagation as specified by sensor vendor */
// if (pw->avdd)
// err = regulator_enable(pw->avdd);
// if (err)
// goto ar0135_avdd_fail;
// if (pw->iovdd)
// err = regulator_enable(pw->iovdd);
// if (err)
// goto ar0135_iovdd_fail;
// usleep_range(1, 2);
// if (pw->pwdn_gpio)
// ar0135_gpio_set(priv, pw->pwdn_gpio, 1);
// /*
// * datasheet 2.9: reset requires ~2ms settling time
// * a power on reset is generated after core power becomes stable
// */
// usleep_range(2000, 2010);
// if (pw->reset_gpio)
// ar0135_gpio_set(priv, pw->reset_gpio, 1);
pw->state = SWITCH_ON;
// ar0135_write_reg(s_data, 0x0100, 0x1);
// ar0135_write_reg(s_data, 0x0100, 0x0);
return 0;
// ar0135_iovdd_fail:
// regulator_disable(pw->avdd);
// ar0135_avdd_fail:
// pr_err("%s failed.\n", __func__);
// return -ENODEV;
}
static int ar0135_power_off(struct camera_common_data *s_data)
{
int err = 0;
struct ar0135 *priv = (struct ar0135 *)s_data->priv;
struct camera_common_power_rail *pw = &priv->power;
dev_dbg(&priv->i2c_client->dev, "%s: power off\n", __func__);
if (priv->pdata && priv->pdata->power_off) {
err = priv->pdata->power_off(pw);
if (!err) {
goto power_off_done;
} else {
pr_err("%s failed.\n", __func__);
return err;
}
}
/* sleeps calls in the sequence below are for internal device
* signal propagation as specified by sensor vendor */
// usleep_range(21, 25);
// if (pw->pwdn_gpio)
// ar0135_gpio_set(priv, pw->pwdn_gpio, 0);
// usleep_range(1, 2);
// if (pw->reset_gpio)
// ar0135_gpio_set(priv, pw->reset_gpio, 0);
// /* datasheet 2.9: reset requires ~2ms settling time*/
// usleep_range(2000, 2010);
// if (pw->iovdd)
// regulator_disable(pw->iovdd);
// if (pw->avdd)
// regulator_disable(pw->avdd);
power_off_done:
pw->state = SWITCH_OFF;
return 0;
}
static int ar0135_power_put(struct ar0135 *priv)
{
struct camera_common_power_rail *pw = &priv->power;
if (unlikely(!pw))
return -EFAULT;
if (likely(pw->avdd))
regulator_put(pw->avdd);
if (likely(pw->iovdd))
regulator_put(pw->iovdd);
pw->avdd = NULL;
pw->iovdd = NULL;
// if (priv->pdata && priv->pdata->use_cam_gpio)
// cam_gpio_deregister(priv->i2c_client, pw->pwdn_gpio);
// else {
// gpio_free(pw->pwdn_gpio);
// gpio_free(pw->reset_gpio);
// }
return 0;
}
static int ar0135_power_get(struct ar0135 *priv)
{
struct camera_common_power_rail *pw = &priv->power;
struct camera_common_pdata *pdata = priv->pdata;
const char *mclk_name;
const char *parentclk_name;
struct clk *parent;
//int err = 0, ret = 0;
int err = 0;
if (!pdata) {
dev_err(&priv->i2c_client->dev, "pdata missing\n");
return -EFAULT;
}
mclk_name = pdata->mclk_name ?
pdata->mclk_name : "cam_mclk1";
pw->mclk = devm_clk_get(&priv->i2c_client->dev, mclk_name);
if (IS_ERR(pw->mclk)) {
dev_err(&priv->i2c_client->dev,
"unable to get clock %s\n", mclk_name);
return PTR_ERR(pw->mclk);
}
else{
dev_dbg(&priv->i2c_client->dev,
"%s:success to get clock %s\n",__func__,mclk_name); //zhou
}
parentclk_name = pdata->parentclk_name;
if (parentclk_name) {
parent = devm_clk_get(&priv->i2c_client->dev, parentclk_name);
if (IS_ERR(parent)) {
dev_err(&priv->i2c_client->dev,
"unable to get parent clcok %s",
parentclk_name);
} else
clk_set_parent(pw->mclk, parent);
}
else{
dev_dbg(&priv->i2c_client->dev,
"%s:parentclk_name is NULL\n",__func__); //zhou
}
/* analog 2.8v */
err |= camera_common_regulator_get(priv->i2c_client,
&pw->avdd, pdata->regulators.avdd);
/* IO 1.8v */
err |= camera_common_regulator_get(priv->i2c_client,
&pw->iovdd, pdata->regulators.iovdd);
if (!err) {
// pw->reset_gpio = pdata->reset_gpio;
// pw->pwdn_gpio = pdata->pwdn_gpio;
dev_err(&priv->i2c_client->dev,
"%s:success to get avdd and iovdd",
__func__);
}
pw->state = SWITCH_OFF;
return err;
}
static int ar0135_set_gain(struct ar0135 *priv, s32 val);
static int ar0135_set_frame_length(struct ar0135 *priv, s32 val);
static int ar0135_set_frame_length_cb(struct ar0135 *priv, s32 val);
static int ar0135_set_coarse_time(struct ar0135 *priv, s32 val);
static int ar0135_set_coarse_time_short(struct ar0135 *priv, s32 val);
static int ar0135_s_stream(struct v4l2_subdev *sd, int enable)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct camera_common_data *s_data = to_camera_common_data(client);
struct ar0135 *priv = (struct ar0135 *)s_data->priv;
struct v4l2_control control;
int err;
u32 frame_time;
//u8 val;
dev_dbg(&client->dev, "%s++\n", __func__);
if (!enable) {
ar0135_update_ctrl_range(priv, AR0135_MAX_FRAME_LENGTH);
// err = ar0135_write_table(priv,
// mode_table[AR0135_MODE_STOP_STREAM]);
// if (err)
// return err;
/*
* Wait for one frame to make sure sensor is set to
* software standby in V-blank
*
* frame_time = frame length rows * Tline
* Tline = line length / pixel clock (in MHz)
*/
frame_time = priv->frame_length *
AR0135_DEFAULT_LINE_LENGTH / AR0135_DEFAULT_PIXEL_CLOCK;
usleep_range(frame_time, frame_time + 1000);
dev_dbg(&client->dev, "%s: parameter's enable is zero\n", __func__);
return 0;
}
err = ar0135_write_table(priv, mode_table[s_data->mode]);
if (err)
goto exit;
if (s_data->override_enable) {
/*
* write list of override regs for the asking frame length,
* coarse integration time, and gain. Failures to write
* overrides are non-fatal
*/
dev_dbg(&client->dev, "%s: s_data's override_enable\n", __func__);
control.id = V4L2_CID_GAIN;
err = v4l2_g_ctrl(&priv->ctrl_handler, &control);
err |= ar0135_set_gain(priv, control.value);
if (err)
dev_dbg(&client->dev, "%s: warning gain override failed\n",
__func__);
control.id = V4L2_CID_FRAME_LENGTH;
err = v4l2_g_ctrl(&priv->ctrl_handler, &control);
err |= ar0135_set_frame_length(priv, control.value);
if (err)
dev_dbg(&client->dev,
"%s: warning frame length override failed\n",
__func__);
control.id = V4L2_CID_FRAME_LENGTH_CB; //zhou
err = v4l2_g_ctrl(&priv->ctrl_handler, &control);
err |= ar0135_set_frame_length_cb(priv, control.value);
if (err)
dev_dbg(&client->dev,
"%s: warning frame length cb override failed\n",
__func__);
control.id = V4L2_CID_COARSE_TIME;
err = v4l2_g_ctrl(&priv->ctrl_handler, &control);
err |= ar0135_set_coarse_time(priv, control.value);
if (err)
dev_dbg(&client->dev,
"%s: warning coarse time override failed\n",
__func__);
control.id = V4L2_CID_COARSE_TIME_SHORT;
err = v4l2_g_ctrl(&priv->ctrl_handler, &control);
err |= ar0135_set_coarse_time_short(priv, control.value);
if (err)
dev_dbg(&client->dev,
"%s: warning coarse time short override failed\n",
__func__);
}
err = ar0135_write_table(priv, mode_table[AR0135_MODE_START_STREAM]);
if (err)
goto exit;
// if (priv->pdata->v_flip) {
// ar0135_read_reg(priv->s_data, AR0135_TIMING_REG20, &val);
// ar0135_write_reg(priv->s_data, AR0135_TIMING_REG20,
// val | VERTICAL_FLIP);
// }
// if (priv->pdata->h_mirror) {
// ar0135_read_reg(priv->s_data, AR0135_TIMING_REG21, &val);
// ar0135_write_reg(priv->s_data, AR0135_TIMING_REG21,
// val | HORIZONTAL_MIRROR_MASK);
// } else {
// ar0135_read_reg(priv->s_data, AR0135_TIMING_REG21, &val);
// ar0135_write_reg(priv->s_data, AR0135_TIMING_REG21,
// val & (~HORIZONTAL_MIRROR_MASK));
// }
if (test_mode)
err = ar0135_write_table(priv,
mode_table[AR0135_MODE_TEST_PATTERN]);
dev_dbg(&client->dev, "%s--\n", __func__);
return 0;
exit:
dev_dbg(&client->dev, "%s: error setting stream\n", __func__);
return err;
}
static int ar0135_g_input_status(struct v4l2_subdev *sd, u32 *status)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct camera_common_data *s_data = to_camera_common_data(client);
struct ar0135 *priv = (struct ar0135 *)s_data->priv;
struct camera_common_power_rail *pw = &priv->power;
*status = pw->state == SWITCH_ON;
return 0;
}
static struct v4l2_subdev_video_ops ar0135_subdev_video_ops = {
.s_stream = ar0135_s_stream,
.g_mbus_config = camera_common_g_mbus_config,
.g_input_status = ar0135_g_input_status,
};
static struct v4l2_subdev_core_ops ar0135_subdev_core_ops = {
.s_power = camera_common_s_power,
};
static int ar0135_get_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_format *format)
{
return camera_common_g_fmt(sd, &format->format);
}
static int ar0135_set_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_format *format)
{
int ret;
if (format->which == V4L2_SUBDEV_FORMAT_TRY)
{
ret = camera_common_try_fmt(sd, &format->format);
pr_err("%s: camera common try fmt ret is %d\n",__func__,ret);
}
else
{
ret = camera_common_s_fmt(sd, &format->format);
pr_err("%s: camera common s fmt ret is %d\n",__func__,ret);
}
return ret;
}
static struct v4l2_subdev_pad_ops ar0135_subdev_pad_ops = {
.set_fmt = ar0135_set_fmt,
.get_fmt = ar0135_get_fmt,
.enum_mbus_code = camera_common_enum_mbus_code,
.enum_frame_size = camera_common_enum_framesizes,
.enum_frame_interval = camera_common_enum_frameintervals,
};
static struct v4l2_subdev_ops ar0135_subdev_ops = {
.core = &ar0135_subdev_core_ops,
.video = &ar0135_subdev_video_ops,
.pad = &ar0135_subdev_pad_ops,
};
static struct of_device_id ar0135_of_match[] = {
{ .compatible = "nvidia,ar0135", },
{ },
};
static struct camera_common_sensor_ops_new ar0135_common_ops = {
.power_on = ar0135_power_on,
.power_off = ar0135_power_off,
.write_reg = ar0135_write_reg,
.read_reg = ar0135_read_reg,
};
static u16 ar0135_to_real_gain(u32 rep, int shift)
{
u16 gain;
int gain_int;
int gain_dec;
int min_int = (1 << shift);
if (rep < AR0135_MIN_GAIN)
rep = AR0135_MIN_GAIN;
else if (rep > AR0135_MAX_GAIN)
rep = AR0135_MAX_GAIN;
gain_int = (int)(rep >> shift);
gain_dec = (int)(rep & ~(0xffff << shift));
/* derived from formulat gain = (x * 16 + 0.5) */
gain = ((gain_int * min_int + gain_dec) * 32 + min_int) / (2 * min_int);
return gain;
}
static int ar0135_set_gain(struct ar0135 *priv, s32 val)
{
ar0135_reg reg_list[1];
int err;
u16 gain;
int i;
// if (!priv->group_hold_prev)
// ar0135_set_group_hold(priv);
/* translate value */
gain = ar0135_to_real_gain((u32)val, AR0135_GAIN_SHIFT);
ar0135_get_gain_regs(reg_list, gain);
dev_dbg(&priv->i2c_client->dev,
"%s: gain %04x val: %04x\n", __func__, val, gain);
for (i = 0; i < 1; i++) {
err = ar0135_write_reg(priv->s_data, reg_list[i].addr,
reg_list[i].val);
if (err)
goto fail;
}
return 0;
fail:
dev_dbg(&priv->i2c_client->dev,
"%s: GAIN control error\n", __func__);
return err;
}
static void ar0135_update_ctrl_range(struct ar0135 *priv, s32 frame_length)
{
struct v4l2_ctrl *ctrl = NULL;
int ctrl_ids[2] = {V4L2_CID_COARSE_TIME,
V4L2_CID_COARSE_TIME_SHORT};
s32 max, min, def;
int i, j;
for (i = 0; i < ARRAY_SIZE(ctrl_ids); i++) {
for (j = 0; j < priv->numctrls; j++) {
if (priv->ctrls[j]->id == ctrl_ids[i]) {
ctrl = priv->ctrls[j];
break;
}
}
if (j == priv->numctrls) {
dev_err(&priv->i2c_client->dev,
"could not find ctrl %x\n",
ctrl_ids[i]);
continue;
}
max = frame_length - AR0135_MAX_COARSE_DIFF;
/* clamp the value in case above is negative */
max = clamp_val(max, AR0135_MIN_EXPOSURE_COARSE,
AR0135_MAX_EXPOSURE_COARSE);
min = AR0135_MIN_EXPOSURE_COARSE;
def = clamp_val(AR0135_DEFAULT_EXPOSURE_COARSE, min, max);
if (__v4l2_ctrl_modify_range(ctrl, min, max, 1, def))
dev_err(&priv->i2c_client->dev,
"ctrl %x: range update failed\n",
ctrl_ids[i]);
}
}
static int ar0135_set_frame_length(struct ar0135 *priv, s32 val)
{
ar0135_reg reg_list[1];
int err;
u32 frame_length;
int i;
// if (!priv->group_hold_prev)
// ar0135_set_group_hold(priv);
frame_length = (u32)val;
ar0135_get_frame_length_regs(reg_list, frame_length);
dev_dbg(&priv->i2c_client->dev,
"%s: val: %d\n", __func__, frame_length);
for (i = 0; i < 1; i++) {
err = ar0135_write_reg(priv->s_data, reg_list[i].addr,
reg_list[i].val);
if (err)
goto fail;
}
priv->frame_length = frame_length;
ar0135_update_ctrl_range(priv, val);
return 0;
fail:
dev_dbg(&priv->i2c_client->dev,
"%s: FRAME_LENGTH control error\n", __func__);
return err;
}
static int ar0135_set_frame_length_cb(struct ar0135 *priv, s32 val)
{
ar0135_reg reg_list[1];
int err;
u32 frame_length;
int i;
// if (!priv->group_hold_prev)
// ar0135_set_group_hold(priv);
frame_length = (u32)val;
ar0135_get_frame_length_cb_regs(reg_list, frame_length);
dev_dbg(&priv->i2c_client->dev,
"%s: val: %d\n", __func__, frame_length);
for (i = 0; i < 1; i++) {
err = ar0135_write_reg(priv->s_data, reg_list[i].addr,
reg_list[i].val);
if (err)
goto fail;
}
priv->frame_length = frame_length;
ar0135_update_ctrl_range(priv, val);
return 0;
fail:
dev_dbg(&priv->i2c_client->dev,
"%s: FRAME_LENGTH control error\n", __func__);
return err;
}
static int ar0135_set_coarse_time(struct ar0135 *priv, s32 val)
{
ar0135_reg reg_list[1];
int err;
u32 coarse_time;
int i;
// if (!priv->group_hold_prev)
// ar0135_set_group_hold(priv);
coarse_time = (u32)val;
ar0135_get_coarse_time_regs(reg_list, coarse_time);
dev_dbg(&priv->i2c_client->dev,
"%s: val: %d\n", __func__, coarse_time);
for (i = 0; i < 1; i++) {
err = ar0135_write_reg(priv->s_data, reg_list[i].addr,
reg_list[i].val);
if (err)
goto fail;
}
return 0;
fail:
dev_dbg(&priv->i2c_client->dev,
"%s: COARSE_TIME control error\n", __func__);
return err;
}
static int ar0135_set_coarse_time_short(struct ar0135 *priv, s32 val)
{
ar0135_reg reg_list[1];
int err;
struct v4l2_control hdr_control;
int hdr_en;
u32 coarse_time_short;
int i;
// if (!priv->group_hold_prev)
// ar0135_set_group_hold(priv);
/* check hdr enable ctrl */
hdr_control.id = V4L2_CID_HDR_EN;
err = camera_common_g_ctrl(priv->s_data, &hdr_control);
if (err < 0) {
dev_err(&priv->i2c_client->dev,
"could not find device ctrl.\n");
return err;
}
hdr_en = switch_ctrl_qmenu[hdr_control.value];
if (hdr_en == SWITCH_OFF)
{
dev_err(&priv->i2c_client->dev,
"%s: hdr_en is switch off\n",__func__);
//return 0;
}
coarse_time_short = (u32)val;
ar0135_get_coarse_time_short_regs(reg_list, coarse_time_short);
dev_dbg(&priv->i2c_client->dev,
"%s: val: %d\n", __func__, coarse_time_short);
for (i = 0; i < 1; i++) {
err = ar0135_write_reg(priv->s_data, reg_list[i].addr,
reg_list[i].val);
if (err)
goto fail;
}
return 0;
fail:
dev_dbg(&priv->i2c_client->dev,
"%s: COARSE_TIME_SHORT control error\n", __func__);
return err;
}
static int ar0135_deserializer_device_release(struct ar0135 *priv)
{
if (priv->de_data.i2c_client != NULL) {
i2c_unregister_device(priv->de_data.i2c_client);
priv->de_data.i2c_client = NULL;
}
return 0;
}
static int ar0135_deserializer_device_init(struct ar0135 *priv)
{
char *dev_name = "deserializer_ar0135";
static struct regmap_config deserializer_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
};
int err;
priv->de_data.adap = i2c_get_adapter(priv->i2c_client->adapter->nr);
memset(&priv->de_data.brd, 0, sizeof(priv->de_data.brd));
strncpy(priv->de_data.brd.type, dev_name,sizeof(priv->de_data.brd.type));
priv->de_data.brd.addr = 0x3d;
priv->de_data.i2c_client = i2c_new_device(priv->de_data.adap, &priv->de_data.brd);
priv->de_data.regmap = devm_regmap_init_i2c(
priv->de_data.i2c_client, &deserializer_regmap_config);
if (IS_ERR(priv->de_data.regmap)) {
err = PTR_ERR(priv->de_data.regmap);
dev_err(&priv->de_data.i2c_client->dev,"%s regmap error is %d\n",__func__,err);
ar0135_deserializer_device_release(priv);
return err;
}
usleep_range(10000,11000);
err=regmap_write(priv->de_data.regmap, 0x32, 0x12);
if (err)
pr_err("%s:i2c write failed, 32 = 12\n",
__func__);
err=regmap_write(priv->de_data.regmap, 0x1f, 0x02);
if (err)
pr_err("%s:i2c write failed, 1f = 02\n",
__func__);
err=regmap_write(priv->de_data.regmap, 0x33, 0x23);
if (err)
pr_err("%s:i2c write failed, 33 = 21\n",
__func__);
usleep_range(100000,100100);
err=regmap_write(priv->de_data.regmap, 0x20, 0xf0);
if (err)
pr_err("%s:i2c write failed, 20 = f0\n",
__func__);
usleep_range(100000,100100);
err=regmap_write(priv->de_data.regmap, 0x20, 0xf2);
if (err)
pr_err("%s:i2c write failed, 20 = f2\n",
__func__);
usleep_range(100000,100100);
err=regmap_write(priv->de_data.regmap, 0x20, 0xd2);
if (err)
pr_err("%s:i2c write failed, 20 = d2\n",
__func__);
err=regmap_write(priv->de_data.regmap, 0x4c, 0x12);
if (err)
pr_err("%s:i2c write failed, 4c = 12\n",
__func__);
err=regmap_write(priv->de_data.regmap, 0x58, 0x58);
if (err)
pr_err("%s:i2c write failed, 58 = 58\n",
__func__);
usleep_range(100000,100100);
err=regmap_write(priv->de_data.regmap, 0x5c, 0x18);
if (err)
pr_err("%s:i2c write failed, 5c = 18\n",
__func__);
err=regmap_write(priv->de_data.regmap, 0x5d, 0x20);
if (err)
pr_err("%s:i2c write failed, 5d = 20\n",
__func__);
err=regmap_write(priv->de_data.regmap, 0x65, 0x20);
if (err)
pr_err("%s:i2c write failed, 65 = 20\n",
__func__);
usleep_range(100000,100100);
err=regmap_write(priv->de_data.regmap, 0x71, 0x2c);
if (err)
pr_err("%s:i2c write failed, 71 = 2c\n",
__func__);
usleep_range(100000,100100);
err=regmap_write(priv->de_data.regmap, 0x6d, 0x7e);
if (err)
pr_err("%s:i2c write failed, 6d = 7e\n",
__func__);
return err;
}
static int ar0135_serializer_device_release(struct ar0135 *priv)
{
if (priv->se_data.i2c_client != NULL) {
i2c_unregister_device(priv->se_data.i2c_client);
priv->se_data.i2c_client = NULL;
}
return 0;
}
static int ar0135_serializer_device_init(struct ar0135 *priv)
{
char *dev_name = "serializer_ar0135";
static struct regmap_config serializer_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
};
int err;
priv->se_data.adap = i2c_get_adapter(priv->i2c_client->adapter->nr);
memset(&priv->se_data.brd, 0, sizeof(priv->se_data.brd));
strncpy(priv->se_data.brd.type, dev_name,sizeof(priv->se_data.brd.type));
priv->se_data.brd.addr = 0x0c;
priv->se_data.i2c_client = i2c_new_device(priv->se_data.adap, &priv->se_data.brd);
priv->se_data.regmap = devm_regmap_init_i2c(
priv->se_data.i2c_client, &serializer_regmap_config);
if (IS_ERR(priv->se_data.regmap)) {
err = PTR_ERR(priv->se_data.regmap);
dev_err(&priv->se_data.i2c_client->dev,"%s regmap error is %d\n",__func__,err);
ar0135_serializer_device_release(priv);
return err;
}
usleep_range(10000,11000);
err=regmap_write(priv->se_data.regmap, 0x0d, 0x91);
if (err)
pr_err("%s:i2c write failed, 0d = 91\n",
__func__);
usleep_range(1000000,1000100);
err=regmap_write(priv->se_data.regmap, 0x0d, 0x11);
if (err)
pr_err("%s:i2c write failed, 0d = 11\n",
__func__);
usleep_range(500000,500010);
err=regmap_write(priv->se_data.regmap, 0x0d, 0x91);
if (err)
pr_err("%s:i2c write failed, 0d = 91\n",
__func__);
usleep_range(100000,100100);
return err;
}
static int ar0135_s_ctrl(struct v4l2_ctrl *ctrl)
{
struct ar0135 *priv =
container_of(ctrl->handler, struct ar0135, ctrl_handler);
int err = 0;
if (priv->power.state == SWITCH_OFF)
{
pr_err("%s: priv's power state is switch off\n", __func__);
return 0;
}
switch (ctrl->id) {
case V4L2_CID_GAIN:
err = ar0135_set_gain(priv, ctrl->val);
break;
case V4L2_CID_FRAME_LENGTH:
err = ar0135_set_frame_length(priv, ctrl->val);
break;
case V4L2_CID_COARSE_TIME:
err = ar0135_set_coarse_time(priv, ctrl->val);
break;
case V4L2_CID_COARSE_TIME_SHORT:
err = ar0135_set_coarse_time_short(priv, ctrl->val);
break;
case V4L2_CID_FRAME_LENGTH_CB:
err = ar0135_set_frame_length_cb(priv, ctrl->val);
break;
case V4L2_CID_HDR_EN:
break;
default:
pr_err("%s: unknown ctrl id.\n", __func__);
return -EINVAL;
}
return err;
}
static int ar0135_ctrls_init(struct ar0135 *priv, bool eeprom_ctrl)
{
struct i2c_client *client = priv->i2c_client;
//struct camera_common_data *common_data = priv->s_data;
struct v4l2_ctrl *ctrl;
int numctrls;
int err;
int i;
dev_dbg(&client->dev, "%s++\n", __func__);
numctrls = ARRAY_SIZE(ctrl_config_list);
v4l2_ctrl_handler_init(&priv->ctrl_handler, numctrls);
dev_dbg(&client->dev, "%s: numctrls is %d\n", __func__,numctrls);
for (i = 0; i < numctrls; i++) {
/* Skip control 'V4L2_CID_EEPROM_DATA' if eeprom inint err */
// if (ctrl_config_list[i].id == V4L2_CID_EEPROM_DATA) {
// // if (!eeprom_ctrl) {
// // common_data->numctrls -= 1;
// // continue;
// // }
// if (eeprom_ctrl) {
// common_data->numctrls -= 1;
// continue;
// }
// }
ctrl = v4l2_ctrl_new_custom(&priv->ctrl_handler,
&ctrl_config_list[i], NULL);
if (ctrl == NULL) {
dev_err(&client->dev, "Failed to init %s ctrl\n",
ctrl_config_list[i].name);
continue;
}
if (ctrl_config_list[i].type == V4L2_CTRL_TYPE_STRING &&
ctrl_config_list[i].flags & V4L2_CTRL_FLAG_READ_ONLY) {
ctrl->p_new.p_char = devm_kzalloc(&client->dev,
ctrl_config_list[i].max + 1, GFP_KERNEL);
if (!ctrl->p_new.p_char)
{
dev_dbg(&client->dev, "%s: ctrl p_new.p_char is 0\n", __func__);
return -ENOMEM;
}
}
priv->ctrls[i] = ctrl;
}
priv->numctrls = numctrls;
priv->subdev->ctrl_handler = &priv->ctrl_handler;
if (priv->ctrl_handler.error) {
dev_err(&client->dev, "Error %d adding controls\n",
priv->ctrl_handler.error);
err = priv->ctrl_handler.error;
goto error;
}
dev_dbg(&client->dev, "%s: v4l2 ctrl setup start\n", __func__);
err = v4l2_ctrl_handler_setup(&priv->ctrl_handler);
if (err) {
dev_err(&client->dev,
"Error %d setting default controls\n", err);
goto error;
}
dev_dbg(&client->dev, "%s: v4l2 ctrl setup finish\n", __func__);
err = camera_common_s_power(priv->subdev, true);
if (err)
{
dev_err(&client->dev,
"%s: Error %d camera s power\n", __func__,err);
return -ENODEV;
}
return 0;
error:
v4l2_ctrl_handler_free(&priv->ctrl_handler);
return err;
}
MODULE_DEVICE_TABLE(of, ar0135_of_match);
static struct camera_common_pdata *ar0135_parse_dt(struct i2c_client *client)
{
struct device_node *node = client->dev.of_node;
struct camera_common_pdata *board_priv_pdata;
const struct of_device_id *match;
//int gpio;
int err;
struct camera_common_pdata *ret = NULL;
if (!node)
{
dev_err(&client->dev, "%s there has no node\n",__func__);
return NULL;
}
match = of_match_device(ar0135_of_match, &client->dev);
if (!match) {
dev_err(&client->dev, "%s:Failed to find matching dt id\n",__func__);
return NULL;
}
board_priv_pdata = devm_kzalloc(&client->dev,
sizeof(*board_priv_pdata), GFP_KERNEL);
if (!board_priv_pdata)
{
dev_err(&client->dev, "%s: Failed to kzalloc borad_priv_data\n",__func__);
return NULL;
}
err = camera_common_parse_clocks(client, board_priv_pdata);
if (err) {
dev_err(&client->dev, "%s:Failed to find clocks\n",__func__);
goto error;
}
err = of_property_read_string(node, "avdd-reg",
&board_priv_pdata->regulators.avdd);
if (err) {
dev_err(&client->dev, "%s:avdd-reg not in DT\n",__func__);
goto error;
}
err = of_property_read_string(node, "iovdd-reg",
&board_priv_pdata->regulators.iovdd);
if (err) {
dev_err(&client->dev, "%s:iovdd-reg not in DT\n",__func__);
goto error;
}
// board_priv_pdata->has_eeprom =
// of_property_read_bool(node, "has-eeprom");
// board_priv_pdata->v_flip= of_property_read_bool(node, "vertical-flip");
// board_priv_pdata->h_mirror = of_property_read_bool(node,
// "horizontal-mirror");
return board_priv_pdata;
error:
devm_kfree(&client->dev, board_priv_pdata);
return ret;
}
static int ar0135_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
dev_dbg(&client->dev, "%s:\n", __func__);
return 0;
}
static const struct v4l2_subdev_internal_ops ar0135_subdev_internal_ops = {
.open = ar0135_open,
};
static const struct media_entity_operations ar0135_media_ops = {
.link_validate = v4l2_subdev_link_validate,
};
static int ar0135_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct camera_common_data *common_data;
struct device_node *node = client->dev.of_node;
struct ar0135 *priv;
char debugfs_name[10];
int err;
pr_info("[AR0135]: probing v4l2 sensor.\n");
if (!IS_ENABLED(CONFIG_OF) || !node)
return -EINVAL;
common_data = devm_kzalloc(&client->dev,
sizeof(struct camera_common_data), GFP_KERNEL);
if (!common_data)
return -ENOMEM;
priv = devm_kzalloc(&client->dev,
sizeof(struct ar0135) + sizeof(struct v4l2_ctrl *) *
ARRAY_SIZE(ctrl_config_list),
GFP_KERNEL);
if (!priv)
return -ENOMEM;
dev_dbg(&client->dev, "client addr is %d\n", client->addr);
priv->regmap = devm_regmap_init_i2c(client, &ar0135_regmap_config);
if (IS_ERR(priv->regmap)) {
dev_err(&client->dev,
"regmap init failed: %ld\n", PTR_ERR(priv->regmap));
return -ENODEV;
}
priv->pdata = ar0135_parse_dt(client);
if (PTR_ERR(priv->pdata) == -EPROBE_DEFER)
return -EPROBE_DEFER;
if (!priv->pdata) {
dev_err(&client->dev, "unable to get platform data\n");
return -EFAULT;
}
//common_data->ops = &ar0135_common_ops;
common_data->ops_new = &ar0135_common_ops;
common_data->ctrl_handler = &priv->ctrl_handler;
common_data->i2c_client = client;
common_data->frmfmt = ar0135_frmfmt;
common_data->colorfmt = camera_common_find_datafmt(
AR0135_DEFAULT_DATAFMT);
common_data->power = &priv->power;
common_data->ctrls = priv->ctrls;
common_data->priv = (void *)priv;
common_data->numctrls = ARRAY_SIZE(ctrl_config_list);
common_data->numfmts = ARRAY_SIZE(ar0135_frmfmt);
common_data->def_mode = AR0135_DEFAULT_MODE;
common_data->def_width = AR0135_DEFAULT_WIDTH;
common_data->def_height = AR0135_DEFAULT_HEIGHT;
common_data->fmt_width = common_data->def_width;
common_data->fmt_height = common_data->def_height;
common_data->def_clk_freq = AR0135_DEFAULT_CLK_FREQ;
priv->i2c_client = client;
priv->s_data = common_data;
priv->subdev = &common_data->subdev;
priv->subdev->dev = &client->dev;
priv->s_data->dev = &client->dev;
err = ar0135_power_get(priv);
// if (err)
// return err;
dev_dbg(&client->dev, "ar0135_power_get err is %d\n", err);
err = camera_common_parse_ports(client, common_data);
if (err) {
dev_err(&client->dev, "Failed to find port info\n");
//return err;
}
sprintf(debugfs_name, "ar0135_%c", common_data->csi_port + 'a');
dev_dbg(&client->dev, "%s: name %s\n", __func__, debugfs_name);
camera_common_create_debugfs(common_data, debugfs_name);
err = ar0135_deserializer_device_init(priv);
dev_dbg(&client->dev, "ar0135_deserializer_device_init err is %d\n", err);
usleep_range(100000,100100);
err = ar0135_serializer_device_init(priv);
dev_dbg(&client->dev, "ar0135_serializer_device_init err is %d\n", err);
usleep_range(100000,100100);
v4l2_i2c_subdev_init(priv->subdev, client, &ar0135_subdev_ops);
err = ar0135_ctrls_init(priv, !err);
// if (err)
// return err;
dev_dbg(&client->dev, "ar0135_ctrls_init err is %d\n", err);
usleep_range(100000,100100);
regmap_write(priv->regmap, 0x3028, 0x0010);
regmap_write(priv->regmap, 0x302A, 0x0008);
regmap_write(priv->regmap, 0x302C, 0x0001);
regmap_write(priv->regmap, 0x302E, 0x0008);
regmap_write(priv->regmap, 0x3030, 0x00C6);
regmap_write(priv->regmap, 0x3032, 0x0000);
regmap_write(priv->regmap, 0x30B0, 0x0080);
regmap_write(priv->regmap, 0x301A, 0x00D8);
regmap_write(priv->regmap, 0x301A, 0x10DC);
// regmap_write(priv->regmap, 0x3002, 0x0074);
// regmap_write(priv->regmap, 0x3004, 0x0000);
// regmap_write(priv->regmap, 0x3006, 0x034B);
// regmap_write(priv->regmap, 0x3008, 0x04FF);
// regmap_write(priv->regmap, 0x300A, 0x02F2);
// regmap_write(priv->regmap, 0x300C, 0x0672);
// regmap_write(priv->regmap, 0x3012, 0x02EB);
// regmap_write(priv->regmap, 0x3014, 0x0009);
// regmap_write(priv->regmap, 0x30A6, 0x0001);
// regmap_write(priv->regmap, 0x308C, 0x0000);
// regmap_write(priv->regmap, 0x308A, 0x0000);
// regmap_write(priv->regmap, 0x3090, 0x03BF);
// regmap_write(priv->regmap, 0x308E, 0x04FF);
// regmap_write(priv->regmap, 0x30AA, 0x03E5);
// regmap_write(priv->regmap, 0x3016, 0x01C2);
// regmap_write(priv->regmap, 0x3018, 0x0009);
// regmap_write(priv->regmap, 0x30A8, 0x0001);
// regmap_write(priv->regmap, 0x3040, 0x0000);
// regmap_write(priv->regmap, 0x3064, 0x1982);
// err = regmap_write(priv->regmap, 0x31C6, 0x8008);
// dev_err(&client->dev, "ar0135_regmap_write err is %d\n",err);
usleep_range(10000,10100);
priv->subdev->internal_ops = &ar0135_subdev_internal_ops;
priv->subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
V4L2_SUBDEV_FL_HAS_EVENTS;
#if defined(CONFIG_MEDIA_CONTROLLER)
priv->pad.flags = MEDIA_PAD_FL_SOURCE;
priv->subdev->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
priv->subdev->entity.ops = &ar0135_media_ops;
err = media_entity_init(&priv->subdev->entity, 1, &priv->pad, 0);
if (err < 0) {
dev_err(&client->dev, "unable to init media entity\n");
//return err;
}
else
{
dev_dbg(&client->dev, "%s:media_entity_init success %d\n",__func__,err); //zhou
}
#endif
err = v4l2_async_register_subdev(priv->subdev);
//if (err)
//return err;
dev_dbg(&client->dev, "v4l2_async_register_subdev err is %d\n", err);
if(client->dev.driver_data == NULL)
dev_err(&client->dev,"ar0135 client dev's drive data is null\n");
dev_dbg(&client->dev, "Detected AR0135 sensor\n");
return 0;
}
static int
ar0135_remove(struct i2c_client *client)
{
struct camera_common_data *s_data = to_camera_common_data(client);
struct ar0135 *priv = (struct ar0135 *)s_data->priv;
v4l2_async_unregister_subdev(priv->subdev);
#if defined(CONFIG_MEDIA_CONTROLLER)
media_entity_cleanup(&priv->subdev->entity);
#endif
v4l2_ctrl_handler_free(&priv->ctrl_handler);
ar0135_power_put(priv);
camera_common_remove_debugfs(s_data);
return 0;
}
static const struct i2c_device_id ar0135_id[] = {
{ "ar0135", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, ar0135_id);
static struct i2c_driver ar0135_i2c_driver = {
.driver = {
.name = "ar0135",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(ar0135_of_match),
},
.probe = ar0135_probe,
.remove = ar0135_remove,
.id_table = ar0135_id,
};
module_i2c_driver(ar0135_i2c_driver);
MODULE_DESCRIPTION("SoC Camera driver for Sony AR0135");
MODULE_AUTHOR("David Wang <davidw@nvidia.com>");
MODULE_LICENSE("GPL v2");
And dmesg is:
nvidia@tegra-ubuntu:~$ ls /dev/v*
/dev/v4l-subdev0 /dev/vcs1 /dev/vcs3 /dev/vcs5 /dev/vcs7 /dev/vcsa1 /dev/vcsa3 /dev/vcsa5 /dev/vcsa7
/dev/vcs /dev/vcs2 /dev/vcs4 /dev/vcs6 /dev/vcsa /dev/vcsa2 /dev/vcsa4 /dev/vcsa6
nvidia@tegra-ubuntu:~$ dmesg | grep ar0135
[ 2.818624] ar0135 2-0010: client addr is 16
[ 2.818648] ar0135 2-0010: mclk in DT extperiph1
[ 2.818652] ar0135 2-0010: parent-clk (null)
[ 2.819003] ar0135 2-0010: camera_common_regulator_get: vana
[ 2.819068] ar0135 2-0010: camera_common_regulator_get: vif
[ 2.819071] ar0135 2-0010: ar0135_power_get:success to get avdd and iovdd
[ 2.819074] ar0135 2-0010: ar0135_power_get err is 0
[ 2.819081] ar0135 2-0010: camera_common_parse_ports: csi port 2 num of lanes 2
[ 2.819084] ar0135 2-0010: ar0135_probe: name ar0135_c
[ 2.819086] ar0135 2-0010: camera_common_create_debugfs ar0135_c
[ 3.433418] ar0135 2-0010: ar0135_deserializer_device_init err is 0
[ 5.154182] ar0135 2-0010: ar0135_serializer_device_init err is 0
[ 5.254300] ar0135 2-0010: v4l2_i2c_subdev_init: ar0135 config i2c test ar0135 2-0010
[ 5.254303] ar0135 2-0010: ar0135_ctrls_init++
[ 5.254306] ar0135 2-0010: ar0135_ctrls_init: numctrls is 6
[ 5.254322] ar0135 2-0010: ar0135_ctrls_init: v4l2 ctrl setup start
[ 5.254325] ar0135_s_ctrl: priv's power state is switch off
[ 5.254326] ar0135_s_ctrl: priv's power state is switch off
[ 5.254327] ar0135_s_ctrl: priv's power state is switch off
[ 5.254328] ar0135_s_ctrl: priv's power state is switch off
[ 5.254329] ar0135_s_ctrl: priv's power state is switch off
[ 5.254330] ar0135_s_ctrl: priv's power state is switch off
[ 5.254333] ar0135 2-0010: ar0135_ctrls_init: v4l2 ctrl setup finish
[ 5.254337] ar0135 2-0010: camera_common_mclk_enable: enable MCLK with 25000000 Hz
[ 5.254611] ar0135 2-0010: camera_common_mclk_enable: clk_set_rate success
[ 5.254701] ar0135 2-0010: camera_common_mclk_enable: clk_prepare_enable err is 0
[ 5.254710] ar0135 2-0010: camera_common_dpd_disable: csi 2
[ 5.254712] ar0135 2-0010: ar0135_power_on: power on
[ 5.254715] ar0135 2-0010: ar0135_ctrls_init err is 0
[ 5.373180] ar0135 2-0010: ar0135_probe:media_entity_init success 0
[ 5.373183] v4l2_async_register_subdev: ar0135 register subdev test
[ 5.373186] ar0135 2-0010: v4l2_async_register_subdev err is 0
[ 5.373188] ar0135 2-0010: Detected AR0135 sensor
[ 5.570238] nvcsi 150c0000.nvcsi: csi_parse_dt:ar0135 node name is nvcsi
[ 5.570266] nvcsi 150c0000.nvcsi: csi_parse_dt:ar0135 csi test
[ 5.570276] v4l2_async_register_subdev: ar0135 register subdev test
[ 5.570282] nvcsi 150c0000.nvcsi: tegra_csi_media_controller_init:ar0135 success to init csi property,clks
[ 5.676739] tegra-vi4 15700000.vi: vi_parse_dt:ar0135 success to find num of channels is 1
[ 5.677697] tegra-vi4 15700000.vi: tegra_vi_media_controller_init:ar0135 Init channel success
[ 5.677810] tegra_channel_init_subdevices:ar0135 first add video name vi-output, 150c0000.nvcsi-0
[ 5.677889] tegra-vi4 15700000.vi: tegra_vi_media_controller_init:ar0135 tegra_vi_graph_init success
[ 5.677894] tegra-vi4 15700000.vi: tegra_vi_media_controller_init:ar0135 tegra_vi_channels_register success
Please Help me! I have no idea what problem is!!
Thanks a lot!