Lines Matching refs:pwm_ir
20 struct pwm_ir { struct
41 struct pwm_ir *pwm_ir = dev->priv; in pwm_ir_set_duty_cycle() argument
43 pwm_ir->duty_cycle = duty_cycle; in pwm_ir_set_duty_cycle()
50 struct pwm_ir *pwm_ir = dev->priv; in pwm_ir_set_carrier() local
55 pwm_ir->carrier = carrier; in pwm_ir_set_carrier()
63 struct pwm_ir *pwm_ir = dev->priv; in pwm_ir_tx_sleep() local
64 struct pwm_device *pwm = pwm_ir->pwm; in pwm_ir_tx_sleep()
72 state.period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier); in pwm_ir_tx_sleep()
73 pwm_set_relative_duty_cycle(&state, pwm_ir->duty_cycle, 100); in pwm_ir_tx_sleep()
96 struct pwm_ir *pwm_ir = dev->priv; in pwm_ir_tx_atomic() local
97 struct pwm_device *pwm = pwm_ir->pwm; in pwm_ir_tx_atomic()
102 state.period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier); in pwm_ir_tx_atomic()
103 pwm_set_relative_duty_cycle(&state, pwm_ir->duty_cycle, 100); in pwm_ir_tx_atomic()
105 pwm_ir->txbuf = txbuf; in pwm_ir_tx_atomic()
106 pwm_ir->txbuf_len = count; in pwm_ir_tx_atomic()
107 pwm_ir->txbuf_index = 0; in pwm_ir_tx_atomic()
108 pwm_ir->state = &state; in pwm_ir_tx_atomic()
110 hrtimer_start(&pwm_ir->timer, 0, HRTIMER_MODE_REL); in pwm_ir_tx_atomic()
112 wait_for_completion(&pwm_ir->tx_done); in pwm_ir_tx_atomic()
119 struct pwm_ir *pwm_ir = container_of(timer, struct pwm_ir, timer); in pwm_ir_timer() local
129 pwm_ir->state->enabled = !(pwm_ir->txbuf_index % 2); in pwm_ir_timer()
130 pwm_apply_atomic(pwm_ir->pwm, pwm_ir->state); in pwm_ir_timer()
132 if (pwm_ir->txbuf_index >= pwm_ir->txbuf_len) { in pwm_ir_timer()
133 complete(&pwm_ir->tx_done); in pwm_ir_timer()
138 ns = US_TO_NS(pwm_ir->txbuf[pwm_ir->txbuf_index]); in pwm_ir_timer()
141 pwm_ir->txbuf_index++; in pwm_ir_timer()
151 struct pwm_ir *pwm_ir; in pwm_ir_probe() local
155 pwm_ir = devm_kmalloc(&pdev->dev, sizeof(*pwm_ir), GFP_KERNEL); in pwm_ir_probe()
156 if (!pwm_ir) in pwm_ir_probe()
159 pwm_ir->pwm = devm_pwm_get(&pdev->dev, NULL); in pwm_ir_probe()
160 if (IS_ERR(pwm_ir->pwm)) in pwm_ir_probe()
161 return PTR_ERR(pwm_ir->pwm); in pwm_ir_probe()
163 pwm_ir->carrier = 38000; in pwm_ir_probe()
164 pwm_ir->duty_cycle = 50; in pwm_ir_probe()
170 if (pwm_might_sleep(pwm_ir->pwm)) { in pwm_ir_probe()
174 init_completion(&pwm_ir->tx_done); in pwm_ir_probe()
175 hrtimer_init(&pwm_ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in pwm_ir_probe()
176 pwm_ir->timer.function = pwm_ir_timer; in pwm_ir_probe()
180 rcdev->priv = pwm_ir; in pwm_ir_probe()