Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ia ipu6 #290

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 33 additions & 28 deletions drivers/media/i2c/imx390.c
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,29 @@ static int imx390_write_reg_list(struct imx390 *imx390,
return 0;
}

static int imx390_identify_module(struct imx390 *imx390)
{
struct i2c_client *client = v4l2_get_subdevdata(&imx390->sd);
int ret;
int retry = 50;
u32 val;

while (retry--) {
ret = imx390_read_reg(imx390, IMX390_REG_CHIP_ID,
IMX390_REG_VALUE_16BIT, &val);
if (ret == 0)
break;
usleep_range(100000, 100500);
}

if (ret)
return ret;

dev_info(&client->dev, "chip id: %04x", val);

return 0;
}

static int imx390_is_hdr(struct imx390 *imx390)
{
// int mode_ix = self->s_data->sensor_mode_id;
Expand Down Expand Up @@ -1683,11 +1706,16 @@ static int __maybe_unused imx390_resume(struct device *dev)
struct imx390 *imx390 = to_imx390(sd);
const struct imx390_reg_list *reg_list;
int ret;

reg_list = &imx390->cur_mode->reg_list;
ret = imx390_write_reg_list(imx390, reg_list);
if (ret) {
dev_err(&client->dev, "resume: failed to apply cur mode");
ret = imx390_identify_module(imx390);
if (ret == 0) {
reg_list = &imx390->cur_mode->reg_list;
ret = imx390_write_reg_list(imx390, reg_list);
if (ret) {
dev_err(&client->dev, "resume: failed to apply cur mode");
return ret;
}
} else {
dev_err(&client->dev, "imx390 resume failed");
return ret;
}

Expand Down Expand Up @@ -1894,29 +1922,6 @@ static const struct v4l2_subdev_internal_ops imx390_internal_ops = {
.open = imx390_open,
};

static int imx390_identify_module(struct imx390 *imx390)
{
struct i2c_client *client = v4l2_get_subdevdata(&imx390->sd);
int ret;
int retry = 50;
u32 val;

while (retry--) {
ret = imx390_read_reg(imx390, IMX390_REG_CHIP_ID,
IMX390_REG_VALUE_16BIT, &val);
if (ret == 0)
break;
usleep_range(10000, 10500);
}

if (ret)
return ret;

dev_info(&client->dev, "chip id: %04x", val);

return 0;
}

static void imx390_remove(struct i2c_client *client)
{
struct v4l2_subdev *sd = i2c_get_clientdata(client);
Expand Down
73 changes: 48 additions & 25 deletions drivers/media/i2c/isx031.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ static const struct isx031_reg isx031_init_reg[] = {
{ISX031_REG_LEN_08BIT, 0x0172, 0x00}, // close R_EBD
{ISX031_REG_LEN_08BIT, 0x8A01, 0x00}, // mode transition to start-up state
{ISX031_REG_LEN_DELAY, 0x0000, 0x64}, // delay 100 ms
/* External sync */
{ISX031_REG_LEN_08BIT, 0xBF14, 0x01}, /* SG_MODE_APL */
{ISX031_REG_LEN_08BIT, 0x8AFF, 0x0c}, /* Hi-Z (input setting or output disabled) */
{ISX031_REG_LEN_08BIT, 0x0153, 0x00},
{ISX031_REG_LEN_08BIT, 0x8AF0, 0x01}, /* external pulse-based sync */
{ISX031_REG_LEN_08BIT, 0x0144, 0x00},
{ISX031_REG_LEN_08BIT, 0x8AF1, 0x00},

};

static const struct isx031_reg isx031_1920_1536_30fps_reg[] = {
Expand Down Expand Up @@ -132,6 +140,7 @@ static const struct isx031_reg isx031_1920_1080_30fps_reg[] = {
{ISX031_REG_LEN_08BIT, 0xBF0B, 0x04},
{ISX031_REG_LEN_08BIT, 0xBF0C, 0xE4},
{ISX031_REG_LEN_08BIT, 0xBF0D, 0x00},

};

static const struct isx031_reg isx031_1280_720_30fps_reg[] = {
Expand Down Expand Up @@ -273,6 +282,34 @@ static int isx031_write_reg_list(struct isx031 *isx031,
return 0;
}

static int isx031_identify_module(struct isx031 *isx031)
{
struct i2c_client *client = isx031->client;
int ret;
int retry = 50;
u32 val;

while (retry--) {
ret = isx031_read_reg(isx031, ISX031_REG_CHIP_ID,
ISX031_REG_LEN_08BIT, &val);
if (ret == 0)
break;
usleep_range(100000, 100500);
}

if (ret)
return ret;

/* chip id not known yet */
if (val != ISX031_CHIP_ID) {
dev_err(&client->dev, "read chip id: %x != %x",
val, ISX031_CHIP_ID);
return -ENXIO;
}

return isx031_write_reg_list(isx031, &isx031_init_reg_list);
}

static void isx031_update_pad_format(const struct isx031_mode *mode,
struct v4l2_mbus_framefmt *fmt)
{
Expand Down Expand Up @@ -379,13 +416,19 @@ static int __maybe_unused isx031_resume(struct device *dev)
struct isx031 *isx031 = to_isx031(sd);
const struct isx031_reg_list *reg_list;
int ret;

reg_list = &isx031->cur_mode->reg_list;
ret = isx031_write_reg_list(isx031, reg_list);
if (ret) {
dev_err(&client->dev, "resume: failed to apply cur mode");
ret = isx031_identify_module(isx031);
if (ret == 0) {
reg_list = &isx031->cur_mode->reg_list;
ret = isx031_write_reg_list(isx031, reg_list);
if (ret) {
dev_err(&client->dev, "resume: failed to apply cur mode");
return ret;
}
} else {
dev_err(&client->dev, "isx031 resume failed");
return ret;
}

mutex_lock(&isx031->mutex);
if (isx031->streaming) {
ret = isx031_start_streaming(isx031);
Expand Down Expand Up @@ -496,26 +539,6 @@ static const struct v4l2_subdev_internal_ops isx031_internal_ops = {
.open = isx031_open,
};

static int isx031_identify_module(struct isx031 *isx031)
{
struct i2c_client *client = isx031->client;
int ret;
u32 val;

ret = isx031_read_reg(isx031, ISX031_REG_CHIP_ID,
ISX031_REG_LEN_08BIT, &val);
if (ret)
return ret;
/* chip id not known yet */
if (val != ISX031_CHIP_ID) {
dev_err(&client->dev, "read chip id: %x != %x",
val, ISX031_CHIP_ID);
return -ENXIO;
}

return isx031_write_reg_list(isx031, &isx031_init_reg_list);
}

static void isx031_remove(struct i2c_client *client)
{
struct v4l2_subdev *sd = i2c_get_clientdata(client);
Expand Down
Loading
Loading