forked from Minki/linux
media: rc: pwm-ir-tx: Switch to atomic PWM API
Remove legacy PWM interface (pwm_config, pwm_enable, pwm_disable) and replace it for the atomic PWM API. Signed-off-by: Maíra Canal <maira.canal@usp.br> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
220546727a
commit
8985696ad9
@ -53,22 +53,21 @@ static int pwm_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
|
|||||||
{
|
{
|
||||||
struct pwm_ir *pwm_ir = dev->priv;
|
struct pwm_ir *pwm_ir = dev->priv;
|
||||||
struct pwm_device *pwm = pwm_ir->pwm;
|
struct pwm_device *pwm = pwm_ir->pwm;
|
||||||
int i, duty, period;
|
struct pwm_state state;
|
||||||
|
int i;
|
||||||
ktime_t edge;
|
ktime_t edge;
|
||||||
long delta;
|
long delta;
|
||||||
|
|
||||||
period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier);
|
pwm_init_state(pwm, &state);
|
||||||
duty = DIV_ROUND_CLOSEST(pwm_ir->duty_cycle * period, 100);
|
|
||||||
|
|
||||||
pwm_config(pwm, duty, period);
|
state.period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier);
|
||||||
|
pwm_set_relative_duty_cycle(&state, pwm_ir->duty_cycle, 100);
|
||||||
|
|
||||||
edge = ktime_get();
|
edge = ktime_get();
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
if (i % 2) // space
|
state.enabled = !(i % 2);
|
||||||
pwm_disable(pwm);
|
pwm_apply_state(pwm, &state);
|
||||||
else
|
|
||||||
pwm_enable(pwm);
|
|
||||||
|
|
||||||
edge = ktime_add_us(edge, txbuf[i]);
|
edge = ktime_add_us(edge, txbuf[i]);
|
||||||
delta = ktime_us_delta(edge, ktime_get());
|
delta = ktime_us_delta(edge, ktime_get());
|
||||||
@ -76,7 +75,8 @@ static int pwm_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
|
|||||||
usleep_range(delta, delta + 10);
|
usleep_range(delta, delta + 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
pwm_disable(pwm);
|
state.enabled = false;
|
||||||
|
pwm_apply_state(pwm, &state);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user