Lines Matching refs:ir_rx51
19 struct ir_rx51 { struct
34 static inline void ir_rx51_on(struct ir_rx51 *ir_rx51) in ir_rx51_on() argument
36 ir_rx51->state.enabled = true; in ir_rx51_on()
37 pwm_apply_might_sleep(ir_rx51->pwm, &ir_rx51->state); in ir_rx51_on()
40 static inline void ir_rx51_off(struct ir_rx51 *ir_rx51) in ir_rx51_off() argument
42 ir_rx51->state.enabled = false; in ir_rx51_off()
43 pwm_apply_might_sleep(ir_rx51->pwm, &ir_rx51->state); in ir_rx51_off()
46 static int init_timing_params(struct ir_rx51 *ir_rx51) in init_timing_params() argument
48 ir_rx51->state.period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, ir_rx51->freq); in init_timing_params()
49 pwm_set_relative_duty_cycle(&ir_rx51->state, ir_rx51->duty_cycle, 100); in init_timing_params()
56 struct ir_rx51 *ir_rx51 = container_of(timer, struct ir_rx51, timer); in ir_rx51_timer_cb() local
59 if (ir_rx51->wbuf_index < 0) { in ir_rx51_timer_cb()
60 dev_err_ratelimited(ir_rx51->dev, in ir_rx51_timer_cb()
62 ir_rx51->wbuf_index); in ir_rx51_timer_cb()
73 if (ir_rx51->wbuf_index >= WBUF_LEN) in ir_rx51_timer_cb()
75 if (ir_rx51->wbuf[ir_rx51->wbuf_index] == -1) in ir_rx51_timer_cb()
78 if (ir_rx51->wbuf_index % 2) in ir_rx51_timer_cb()
79 ir_rx51_off(ir_rx51); in ir_rx51_timer_cb()
81 ir_rx51_on(ir_rx51); in ir_rx51_timer_cb()
83 ns = US_TO_NS(ir_rx51->wbuf[ir_rx51->wbuf_index]); in ir_rx51_timer_cb()
86 ir_rx51->wbuf_index++; in ir_rx51_timer_cb()
95 ir_rx51_off(ir_rx51); in ir_rx51_timer_cb()
96 ir_rx51->wbuf_index = -1; in ir_rx51_timer_cb()
98 wake_up_interruptible(&ir_rx51->wqueue); in ir_rx51_timer_cb()
106 struct ir_rx51 *ir_rx51 = dev->priv; in ir_rx51_tx() local
111 memcpy(ir_rx51->wbuf, buffer, count * sizeof(unsigned int)); in ir_rx51_tx()
114 wait_event_interruptible(ir_rx51->wqueue, ir_rx51->wbuf_index < 0); in ir_rx51_tx()
116 init_timing_params(ir_rx51); in ir_rx51_tx()
118 ir_rx51->wbuf[count] = -1; /* Insert termination mark */ in ir_rx51_tx()
125 ir_rx51_on(ir_rx51); in ir_rx51_tx()
126 ir_rx51->wbuf_index = 1; in ir_rx51_tx()
127 hrtimer_start(&ir_rx51->timer, in ir_rx51_tx()
128 ns_to_ktime(US_TO_NS(ir_rx51->wbuf[0])), in ir_rx51_tx()
134 wait_event_interruptible(ir_rx51->wqueue, ir_rx51->wbuf_index < 0); in ir_rx51_tx()
143 struct ir_rx51 *ir_rx51 = dev->priv; in ir_rx51_open() local
145 if (test_and_set_bit(1, &ir_rx51->device_is_open)) in ir_rx51_open()
148 ir_rx51->pwm = pwm_get(ir_rx51->dev, NULL); in ir_rx51_open()
149 if (IS_ERR(ir_rx51->pwm)) { in ir_rx51_open()
150 int res = PTR_ERR(ir_rx51->pwm); in ir_rx51_open()
152 dev_err(ir_rx51->dev, "pwm_get failed: %d\n", res); in ir_rx51_open()
161 struct ir_rx51 *ir_rx51 = dev->priv; in ir_rx51_release() local
163 hrtimer_cancel(&ir_rx51->timer); in ir_rx51_release()
164 ir_rx51_off(ir_rx51); in ir_rx51_release()
165 pwm_put(ir_rx51->pwm); in ir_rx51_release()
167 clear_bit(1, &ir_rx51->device_is_open); in ir_rx51_release()
170 static struct ir_rx51 ir_rx51 = { variable
177 struct ir_rx51 *ir_rx51 = dev->priv; in ir_rx51_set_duty_cycle() local
179 ir_rx51->duty_cycle = duty; in ir_rx51_set_duty_cycle()
186 struct ir_rx51 *ir_rx51 = dev->priv; in ir_rx51_set_tx_carrier() local
191 ir_rx51->freq = carrier; in ir_rx51_set_tx_carrier()
208 if (test_and_set_bit(1, &ir_rx51.device_is_open)) in ir_rx51_suspend()
211 clear_bit(1, &ir_rx51.device_is_open); in ir_rx51_suspend()
238 ir_rx51.freq = DIV_ROUND_CLOSEST_ULL(pwm_get_period(pwm), NSEC_PER_SEC); in ir_rx51_probe()
239 pwm_init_state(pwm, &ir_rx51.state); in ir_rx51_probe()
242 hrtimer_init(&ir_rx51.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in ir_rx51_probe()
243 ir_rx51.timer.function = ir_rx51_timer_cb; in ir_rx51_probe()
245 ir_rx51.dev = &dev->dev; in ir_rx51_probe()
251 rcdev->priv = &ir_rx51; in ir_rx51_probe()
259 ir_rx51.rcdev = rcdev; in ir_rx51_probe()
261 return devm_rc_register_device(&dev->dev, ir_rx51.rcdev); in ir_rx51_probe()