mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
media: spi: ms41908: support focus/zoom reinit run simultaneously
Signed-off-by: Hu Kejun <william.hu@rock-chips.com> Change-Id: Ic18db2b2b5ad7f9c12ad80276c4605695711a210
This commit is contained in:
@@ -172,6 +172,7 @@ struct motor_dev {
|
||||
struct dciris_dev *dciris;
|
||||
int id;
|
||||
int wait_cnt;
|
||||
int pi_gpio_usecnt;
|
||||
};
|
||||
|
||||
struct motor_work_s {
|
||||
@@ -1581,11 +1582,16 @@ static int motor_reinit_focus(struct motor_dev *motor)
|
||||
int ret = 0;
|
||||
|
||||
if (!IS_ERR(motor->focus->pic_gpio)) {
|
||||
if (!IS_ERR(motor->focus->pia_gpio))
|
||||
gpiod_set_value(motor->focus->pia_gpio, 1);
|
||||
if (!IS_ERR(motor->focus->pie_gpio))
|
||||
gpiod_set_value(motor->focus->pie_gpio, 0);
|
||||
msleep(250);
|
||||
mutex_lock(&motor->mutex);
|
||||
if (motor->pi_gpio_usecnt == 0) {
|
||||
if (!IS_ERR(motor->focus->pia_gpio))
|
||||
gpiod_set_value(motor->focus->pia_gpio, 1);
|
||||
if (!IS_ERR(motor->focus->pie_gpio))
|
||||
gpiod_set_value(motor->focus->pie_gpio, 0);
|
||||
msleep(250);
|
||||
}
|
||||
motor->pi_gpio_usecnt++;
|
||||
mutex_unlock(&motor->mutex);
|
||||
#ifdef PI_TEST
|
||||
motor->focus->last_pos = motor->focus->step_max;
|
||||
ret = set_motor_running_status(motor,
|
||||
@@ -1610,10 +1616,16 @@ static int motor_reinit_focus(struct motor_dev *motor)
|
||||
motor->focus->min_pos = min;
|
||||
motor->focus->max_pos = max;
|
||||
#endif
|
||||
if (!IS_ERR(motor->focus->pia_gpio))
|
||||
gpiod_set_value(motor->focus->pia_gpio, 0);
|
||||
if (!IS_ERR(motor->focus->pie_gpio))
|
||||
gpiod_set_value(motor->focus->pie_gpio, 0);
|
||||
|
||||
mutex_lock(&motor->mutex);
|
||||
if (motor->pi_gpio_usecnt == 1) {
|
||||
if (!IS_ERR(motor->focus->pia_gpio))
|
||||
gpiod_set_value(motor->focus->pia_gpio, 0);
|
||||
if (!IS_ERR(motor->focus->pie_gpio))
|
||||
gpiod_set_value(motor->focus->pie_gpio, 0);
|
||||
}
|
||||
motor->pi_gpio_usecnt--;
|
||||
mutex_unlock(&motor->mutex);
|
||||
} else {
|
||||
motor->focus->last_pos = motor->focus->step_max;
|
||||
ret = set_motor_running_status(motor,
|
||||
@@ -1646,11 +1658,17 @@ static int motor_reinit_zoom(struct motor_dev *motor)
|
||||
int ret = 0;
|
||||
|
||||
if (!IS_ERR(motor->zoom->pic_gpio)) {
|
||||
if (!IS_ERR(motor->focus->pia_gpio))
|
||||
gpiod_set_value(motor->focus->pia_gpio, 1);
|
||||
if (!IS_ERR(motor->focus->pie_gpio))
|
||||
gpiod_set_value(motor->focus->pie_gpio, 0);
|
||||
msleep(250);
|
||||
mutex_lock(&motor->mutex);
|
||||
if (motor->pi_gpio_usecnt == 0) {
|
||||
if (!IS_ERR(motor->focus->pia_gpio))
|
||||
gpiod_set_value(motor->focus->pia_gpio, 1);
|
||||
if (!IS_ERR(motor->focus->pie_gpio))
|
||||
gpiod_set_value(motor->focus->pie_gpio, 0);
|
||||
msleep(250);
|
||||
}
|
||||
motor->pi_gpio_usecnt++;
|
||||
mutex_unlock(&motor->mutex);
|
||||
|
||||
#ifdef PI_TEST
|
||||
motor->zoom->last_pos = motor->zoom->step_max;
|
||||
ret = set_motor_running_status(motor,
|
||||
@@ -1675,10 +1693,16 @@ static int motor_reinit_zoom(struct motor_dev *motor)
|
||||
motor->zoom->min_pos = min;
|
||||
motor->zoom->max_pos = max;
|
||||
#endif
|
||||
if (!IS_ERR(motor->focus->pia_gpio))
|
||||
gpiod_set_value(motor->focus->pia_gpio, 0);
|
||||
if (!IS_ERR(motor->focus->pie_gpio))
|
||||
gpiod_set_value(motor->focus->pie_gpio, 0);
|
||||
|
||||
mutex_lock(&motor->mutex);
|
||||
if (motor->pi_gpio_usecnt == 1) {
|
||||
if (!IS_ERR(motor->focus->pia_gpio))
|
||||
gpiod_set_value(motor->focus->pia_gpio, 0);
|
||||
if (!IS_ERR(motor->focus->pie_gpio))
|
||||
gpiod_set_value(motor->focus->pie_gpio, 0);
|
||||
}
|
||||
motor->pi_gpio_usecnt--;
|
||||
mutex_unlock(&motor->mutex);
|
||||
} else {
|
||||
motor->zoom->last_pos = motor->zoom->step_max;
|
||||
ret = set_motor_running_status(motor,
|
||||
@@ -2562,6 +2586,7 @@ static void dev_param_init(struct motor_dev *motor)
|
||||
motor->is_should_wait = false;
|
||||
motor->is_timer_restart = false;
|
||||
motor->wait_cnt = 0;
|
||||
motor->pi_gpio_usecnt = 0;
|
||||
}
|
||||
|
||||
static void dev_reg_init(struct motor_dev *motor)
|
||||
|
||||
Reference in New Issue
Block a user