mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
media: i2c: modify ov9281 driver for thunderboot.
Signed-off-by: Dongbo Yang <db.yang@rock-chips.com> Change-Id: I17defb2b02913de0a1e70479068cec244b554593
This commit is contained in:
@@ -152,6 +152,9 @@ struct ov9281 {
|
||||
struct mutex mutex;
|
||||
bool streaming;
|
||||
bool power_on;
|
||||
bool is_thunderboot;
|
||||
bool is_thunderboot_ng;
|
||||
bool is_first_streamoff;
|
||||
const struct ov9281_mode *cur_mode;
|
||||
u32 module_index;
|
||||
const char *module_facing;
|
||||
@@ -753,10 +756,11 @@ static int __ov9281_start_stream(struct ov9281 *ov9281)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ov9281_write_array(ov9281->client, ov9281->cur_mode->reg_list);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!ov9281->is_thunderboot) {
|
||||
ret = ov9281_write_array(ov9281->client, ov9281->cur_mode->reg_list);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
/* In case these controls are set before streaming */
|
||||
mutex_unlock(&ov9281->mutex);
|
||||
ret = v4l2_ctrl_handler_setup(&ov9281->ctrl_handler);
|
||||
@@ -770,6 +774,8 @@ static int __ov9281_start_stream(struct ov9281 *ov9281)
|
||||
|
||||
static int __ov9281_stop_stream(struct ov9281 *ov9281)
|
||||
{
|
||||
if (ov9281->is_thunderboot)
|
||||
ov9281->is_first_streamoff = true;
|
||||
return ov9281_write_reg(ov9281->client, OV9281_REG_CTRL_MODE,
|
||||
OV9281_REG_VALUE_08BIT, OV9281_MODE_SW_STANDBY);
|
||||
}
|
||||
@@ -859,6 +865,11 @@ static int __ov9281_power_on(struct ov9281 *ov9281)
|
||||
u32 delay_us;
|
||||
struct device *dev = &ov9281->client->dev;
|
||||
|
||||
/* No need when thunderboot. */
|
||||
if (ov9281->is_thunderboot) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!IS_ERR_OR_NULL(ov9281->pins_default)) {
|
||||
ret = pinctrl_select_state(ov9281->pinctrl,
|
||||
ov9281->pins_default);
|
||||
@@ -910,6 +921,15 @@ static void __ov9281_power_off(struct ov9281 *ov9281)
|
||||
int ret;
|
||||
struct device *dev = &ov9281->client->dev;
|
||||
|
||||
if (ov9281->is_thunderboot) {
|
||||
if (ov9281->is_first_streamoff) {
|
||||
ov9281->is_thunderboot = false;
|
||||
ov9281->is_first_streamoff = false;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!IS_ERR(ov9281->pwdn_gpio))
|
||||
gpiod_set_value_cansleep(ov9281->pwdn_gpio, 0);
|
||||
clk_disable_unprepare(ov9281->xvclk);
|
||||
@@ -1171,6 +1191,11 @@ static int ov9281_check_sensor_id(struct ov9281 *ov9281,
|
||||
u32 id = 0;
|
||||
int ret;
|
||||
|
||||
if (ov9281->is_thunderboot) {
|
||||
dev_info(dev, "Enable thunderboot mode, skip sensor id check\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = ov9281_read_reg(client, OV9281_REG_CHIP_ID,
|
||||
OV9281_REG_VALUE_16BIT, &id);
|
||||
if (id != CHIP_ID) {
|
||||
@@ -1229,6 +1254,7 @@ static int ov9281_probe(struct i2c_client *client,
|
||||
|
||||
ov9281->client = client;
|
||||
ov9281->cur_mode = &supported_modes[0];
|
||||
ov9281->is_thunderboot = IS_ENABLED(CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP);
|
||||
|
||||
ov9281->xvclk = devm_clk_get(dev, "xvclk");
|
||||
if (IS_ERR(ov9281->xvclk)) {
|
||||
@@ -1236,11 +1262,11 @@ static int ov9281_probe(struct i2c_client *client,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ov9281->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
|
||||
ov9281->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_ASIS);
|
||||
if (IS_ERR(ov9281->reset_gpio))
|
||||
dev_warn(dev, "Failed to get reset-gpios\n");
|
||||
|
||||
ov9281->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW);
|
||||
ov9281->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_ASIS);
|
||||
if (IS_ERR(ov9281->pwdn_gpio))
|
||||
dev_warn(dev, "Failed to get pwdn-gpios\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user