Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* ir-sharp-decoder.c - handle Sharp IR Pulse/Space protocol
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2013-2014 Imagination Technologies Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Based on NEC decoder:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright (C) 2010 by Mauro Carvalho Chehab
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/bitrev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "rc-core-priv.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #define SHARP_NBITS		15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define SHARP_UNIT		40  /* us */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define SHARP_BIT_PULSE		(8    * SHARP_UNIT) /* 320us */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define SHARP_BIT_0_PERIOD	(25   * SHARP_UNIT) /* 1ms (680us space) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define SHARP_BIT_1_PERIOD	(50   * SHARP_UNIT) /* 2ms (1680ms space) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define SHARP_ECHO_SPACE	(1000 * SHARP_UNIT) /* 40 ms */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define SHARP_TRAILER_SPACE	(125  * SHARP_UNIT) /* 5 ms (even longer) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) enum sharp_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	STATE_INACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	STATE_BIT_PULSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	STATE_BIT_SPACE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	STATE_TRAILER_PULSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	STATE_ECHO_SPACE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	STATE_TRAILER_SPACE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * ir_sharp_decode() - Decode one Sharp pulse or space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * @dev:	the struct rc_dev descriptor of the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * @ev:		the struct ir_raw_event descriptor of the pulse/space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * This function returns -EINVAL if the pulse violates the state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) static int ir_sharp_decode(struct rc_dev *dev, struct ir_raw_event ev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	struct sharp_dec *data = &dev->raw->sharp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	u32 msg, echo, address, command, scancode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	if (!is_timing_event(ev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		if (ev.reset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 			data->state = STATE_INACTIVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	dev_dbg(&dev->dev, "Sharp decode started at state %d (%uus %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		data->state, ev.duration, TO_STR(ev.pulse));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	switch (data->state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	case STATE_INACTIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		if (!ev.pulse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		if (!eq_margin(ev.duration, SHARP_BIT_PULSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 			       SHARP_BIT_PULSE / 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		data->count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		data->pulse_len = ev.duration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		data->state = STATE_BIT_SPACE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	case STATE_BIT_PULSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		if (!ev.pulse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		if (!eq_margin(ev.duration, SHARP_BIT_PULSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			       SHARP_BIT_PULSE / 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		data->pulse_len = ev.duration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		data->state = STATE_BIT_SPACE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	case STATE_BIT_SPACE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		if (ev.pulse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		data->bits <<= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		if (eq_margin(data->pulse_len + ev.duration, SHARP_BIT_1_PERIOD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 			      SHARP_BIT_PULSE * 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			data->bits |= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		else if (!eq_margin(data->pulse_len + ev.duration,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 				    SHARP_BIT_0_PERIOD, SHARP_BIT_PULSE * 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		data->count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		if (data->count == SHARP_NBITS ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		    data->count == SHARP_NBITS * 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			data->state = STATE_TRAILER_PULSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			data->state = STATE_BIT_PULSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	case STATE_TRAILER_PULSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		if (!ev.pulse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		if (!eq_margin(ev.duration, SHARP_BIT_PULSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 			       SHARP_BIT_PULSE / 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		if (data->count == SHARP_NBITS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			/* exp,chk bits should be 1,0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			if ((data->bits & 0x3) != 0x2 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			/* DENON variant, both chk bits 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			    (data->bits & 0x3) != 0x0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 			data->state = STATE_ECHO_SPACE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			data->state = STATE_TRAILER_SPACE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	case STATE_ECHO_SPACE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		if (ev.pulse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		if (!eq_margin(ev.duration, SHARP_ECHO_SPACE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			       SHARP_ECHO_SPACE / 4))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		data->state = STATE_BIT_PULSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	case STATE_TRAILER_SPACE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		if (ev.pulse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		if (!geq_margin(ev.duration, SHARP_TRAILER_SPACE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 				SHARP_BIT_PULSE / 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		/* Validate - command, ext, chk should be inverted in 2nd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		msg = (data->bits >> 15) & 0x7fff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		echo = data->bits & 0x7fff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		if ((msg ^ echo) != 0x3ff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			dev_dbg(&dev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 				"Sharp checksum error: received 0x%04x, 0x%04x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 				msg, echo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		address = bitrev8((msg >> 7) & 0xf8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		command = bitrev8((msg >> 2) & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		scancode = address << 8 | command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		dev_dbg(&dev->dev, "Sharp scancode 0x%04x\n", scancode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		rc_keydown(dev, RC_PROTO_SHARP, scancode, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		data->state = STATE_INACTIVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	dev_dbg(&dev->dev, "Sharp decode failed at count %d state %d (%uus %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		data->count, data->state, ev.duration, TO_STR(ev.pulse));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	data->state = STATE_INACTIVE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static const struct ir_raw_timings_pd ir_sharp_timings = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	.header_pulse  = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	.header_space  = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	.bit_pulse     = SHARP_BIT_PULSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	.bit_space[0]  = SHARP_BIT_0_PERIOD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	.bit_space[1]  = SHARP_BIT_1_PERIOD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	.trailer_pulse = SHARP_BIT_PULSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	.trailer_space = SHARP_ECHO_SPACE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	.msb_first     = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  * ir_sharp_encode() - Encode a scancode as a stream of raw events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  * @protocol:	protocol to encode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  * @scancode:	scancode to encode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  * @events:	array of raw ir events to write into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  * @max:	maximum size of @events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  * Returns:	The number of events written.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  *		-ENOBUFS if there isn't enough space in the array to fit the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  *		encoding. In this case all @max events will have been written.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static int ir_sharp_encode(enum rc_proto protocol, u32 scancode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 			   struct ir_raw_event *events, unsigned int max)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	struct ir_raw_event *e = events;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	u32 raw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	raw = (((bitrev8(scancode >> 8) >> 3) << 8) & 0x1f00) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		bitrev8(scancode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	ret = ir_raw_gen_pd(&e, max, &ir_sharp_timings, SHARP_NBITS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 			    (raw << 2) | 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	max -= ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	raw = (((bitrev8(scancode >> 8) >> 3) << 8) & 0x1f00) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		bitrev8(~scancode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	ret = ir_raw_gen_pd(&e, max, &ir_sharp_timings, SHARP_NBITS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 			    (raw << 2) | 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	return e - events;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) static struct ir_raw_handler sharp_handler = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	.protocols	= RC_PROTO_BIT_SHARP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	.decode		= ir_sharp_decode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	.encode		= ir_sharp_encode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	.carrier	= 38000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	.min_timeout	= SHARP_ECHO_SPACE + SHARP_ECHO_SPACE / 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) static int __init ir_sharp_decode_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	ir_raw_handler_register(&sharp_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	pr_info("IR Sharp protocol handler initialized\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) static void __exit ir_sharp_decode_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	ir_raw_handler_unregister(&sharp_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) module_init(ir_sharp_decode_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) module_exit(ir_sharp_decode_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) MODULE_AUTHOR("James Hogan <jhogan@kernel.org>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) MODULE_DESCRIPTION("Sharp IR protocol decoder");