diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-04 13:38:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-04 13:38:08 -0400 |
commit | f63b759c44b0561c76a67894c734157df3313b42 (patch) | |
tree | 4e9638f6c1aa5c0faa62ad4213282cc7cb39772a /drivers/media/IR/ir-sony-decoder.c | |
parent | 4a35cee066df1b1958e25e71595b3845d06b192e (diff) | |
parent | 844a9e93d7fcd910cd94f6eb262e2cc43cacbe56 (diff) |
Merge branch 'v4l_for_2.6.35' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6
* 'v4l_for_2.6.35' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (243 commits)
V4L/DVB: sms: Convert IR support to use the Remote Controller core
V4L/DVB: sms: properly initialize IR phys and IR name
V4L/DVB: standardize names at rc-dib0700 tables
V4L/DVB: smsusb: enable IR port for Hauppauge WinTV MiniStick
V4L/DVB: dib0700: Fix RC protocol logic to properly handle NEC/NECx and RC-5
V4L/DVB: dib0700: properly implement IR change_protocol
V4L/DVB: dib0700: break keytable into NEC and RC-5 variants
V4L/DVB: dib0700: avoid bad repeat
V4L/DVB: Port dib0700 to rc-core
V4L/DVB: Add a keymap file with dib0700 table
V4L/DVB: dvb-usb: add support for rc-core mode
V4L/DVB: dvb-usb: prepare drivers for using rc-core
V4L/DVB: dvb-usb: get rid of struct dvb_usb_rc_key
V4L/DVB: rj54n1cb0c: fix a comment in the driver
V4L/DVB: V4L2: sh_vou: VOU does support the full PAL resolution too
V4L/DVB: V4L2: sh_mobile_camera_ceu: add support for CSI2
V4L/DVB: V4L2: soc-camera: add a MIPI CSI-2 driver for SH-Mobile platforms
V4L/DVB: V4L2: soc-camera: export soc-camera bus type for notifications
V4L/DVB: V4L2: mediabus: add 12-bit Bayer and YUV420 pixel formats
V4L/DVB: mediabus: fix ambiguous pixel code names
...
Diffstat (limited to 'drivers/media/IR/ir-sony-decoder.c')
-rw-r--r-- | drivers/media/IR/ir-sony-decoder.c | 155 |
1 files changed, 12 insertions, 143 deletions
diff --git a/drivers/media/IR/ir-sony-decoder.c b/drivers/media/IR/ir-sony-decoder.c index 9f440c5c060d..b9074f07c7a0 100644 --- a/drivers/media/IR/ir-sony-decoder.c +++ b/drivers/media/IR/ir-sony-decoder.c | |||
@@ -23,10 +23,6 @@ | |||
23 | #define SONY_BIT_SPACE (1 * SONY_UNIT) | 23 | #define SONY_BIT_SPACE (1 * SONY_UNIT) |
24 | #define SONY_TRAILER_SPACE (10 * SONY_UNIT) /* minimum */ | 24 | #define SONY_TRAILER_SPACE (10 * SONY_UNIT) /* minimum */ |
25 | 25 | ||
26 | /* Used to register sony_decoder clients */ | ||
27 | static LIST_HEAD(decoder_list); | ||
28 | static DEFINE_SPINLOCK(decoder_lock); | ||
29 | |||
30 | enum sony_state { | 26 | enum sony_state { |
31 | STATE_INACTIVE, | 27 | STATE_INACTIVE, |
32 | STATE_HEADER_SPACE, | 28 | STATE_HEADER_SPACE, |
@@ -35,84 +31,6 @@ enum sony_state { | |||
35 | STATE_FINISHED, | 31 | STATE_FINISHED, |
36 | }; | 32 | }; |
37 | 33 | ||
38 | struct decoder_data { | ||
39 | struct list_head list; | ||
40 | struct ir_input_dev *ir_dev; | ||
41 | int enabled:1; | ||
42 | |||
43 | /* State machine control */ | ||
44 | enum sony_state state; | ||
45 | u32 sony_bits; | ||
46 | unsigned count; | ||
47 | }; | ||
48 | |||
49 | |||
50 | /** | ||
51 | * get_decoder_data() - gets decoder data | ||
52 | * @input_dev: input device | ||
53 | * | ||
54 | * Returns the struct decoder_data that corresponds to a device | ||
55 | */ | ||
56 | static struct decoder_data *get_decoder_data(struct ir_input_dev *ir_dev) | ||
57 | { | ||
58 | struct decoder_data *data = NULL; | ||
59 | |||
60 | spin_lock(&decoder_lock); | ||
61 | list_for_each_entry(data, &decoder_list, list) { | ||
62 | if (data->ir_dev == ir_dev) | ||
63 | break; | ||
64 | } | ||
65 | spin_unlock(&decoder_lock); | ||
66 | return data; | ||
67 | } | ||
68 | |||
69 | static ssize_t store_enabled(struct device *d, | ||
70 | struct device_attribute *mattr, | ||
71 | const char *buf, | ||
72 | size_t len) | ||
73 | { | ||
74 | unsigned long value; | ||
75 | struct ir_input_dev *ir_dev = dev_get_drvdata(d); | ||
76 | struct decoder_data *data = get_decoder_data(ir_dev); | ||
77 | |||
78 | if (!data) | ||
79 | return -EINVAL; | ||
80 | |||
81 | if (strict_strtoul(buf, 10, &value) || value > 1) | ||
82 | return -EINVAL; | ||
83 | |||
84 | data->enabled = value; | ||
85 | |||
86 | return len; | ||
87 | } | ||
88 | |||
89 | static ssize_t show_enabled(struct device *d, | ||
90 | struct device_attribute *mattr, char *buf) | ||
91 | { | ||
92 | struct ir_input_dev *ir_dev = dev_get_drvdata(d); | ||
93 | struct decoder_data *data = get_decoder_data(ir_dev); | ||
94 | |||
95 | if (!data) | ||
96 | return -EINVAL; | ||
97 | |||
98 | if (data->enabled) | ||
99 | return sprintf(buf, "1\n"); | ||
100 | else | ||
101 | return sprintf(buf, "0\n"); | ||
102 | } | ||
103 | |||
104 | static DEVICE_ATTR(enabled, S_IRUGO | S_IWUSR, show_enabled, store_enabled); | ||
105 | |||
106 | static struct attribute *decoder_attributes[] = { | ||
107 | &dev_attr_enabled.attr, | ||
108 | NULL | ||
109 | }; | ||
110 | |||
111 | static struct attribute_group decoder_attribute_group = { | ||
112 | .name = "sony_decoder", | ||
113 | .attrs = decoder_attributes, | ||
114 | }; | ||
115 | |||
116 | /** | 34 | /** |
117 | * ir_sony_decode() - Decode one Sony pulse or space | 35 | * ir_sony_decode() - Decode one Sony pulse or space |
118 | * @input_dev: the struct input_dev descriptor of the device | 36 | * @input_dev: the struct input_dev descriptor of the device |
@@ -122,16 +40,12 @@ static struct attribute_group decoder_attribute_group = { | |||
122 | */ | 40 | */ |
123 | static int ir_sony_decode(struct input_dev *input_dev, struct ir_raw_event ev) | 41 | static int ir_sony_decode(struct input_dev *input_dev, struct ir_raw_event ev) |
124 | { | 42 | { |
125 | struct decoder_data *data; | ||
126 | struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); | 43 | struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); |
44 | struct sony_dec *data = &ir_dev->raw->sony; | ||
127 | u32 scancode; | 45 | u32 scancode; |
128 | u8 device, subdevice, function; | 46 | u8 device, subdevice, function; |
129 | 47 | ||
130 | data = get_decoder_data(ir_dev); | 48 | if (!(ir_dev->raw->enabled_protocols & IR_TYPE_SONY)) |
131 | if (!data) | ||
132 | return -EINVAL; | ||
133 | |||
134 | if (!data->enabled) | ||
135 | return 0; | 49 | return 0; |
136 | 50 | ||
137 | if (IS_RESET(ev)) { | 51 | if (IS_RESET(ev)) { |
@@ -172,9 +86,9 @@ static int ir_sony_decode(struct input_dev *input_dev, struct ir_raw_event ev) | |||
172 | if (!ev.pulse) | 86 | if (!ev.pulse) |
173 | break; | 87 | break; |
174 | 88 | ||
175 | data->sony_bits <<= 1; | 89 | data->bits <<= 1; |
176 | if (eq_margin(ev.duration, SONY_BIT_1_PULSE, SONY_UNIT / 2)) | 90 | if (eq_margin(ev.duration, SONY_BIT_1_PULSE, SONY_UNIT / 2)) |
177 | data->sony_bits |= 1; | 91 | data->bits |= 1; |
178 | else if (!eq_margin(ev.duration, SONY_BIT_0_PULSE, SONY_UNIT / 2)) | 92 | else if (!eq_margin(ev.duration, SONY_BIT_0_PULSE, SONY_UNIT / 2)) |
179 | break; | 93 | break; |
180 | 94 | ||
@@ -208,19 +122,19 @@ static int ir_sony_decode(struct input_dev *input_dev, struct ir_raw_event ev) | |||
208 | 122 | ||
209 | switch (data->count) { | 123 | switch (data->count) { |
210 | case 12: | 124 | case 12: |
211 | device = bitrev8((data->sony_bits << 3) & 0xF8); | 125 | device = bitrev8((data->bits << 3) & 0xF8); |
212 | subdevice = 0; | 126 | subdevice = 0; |
213 | function = bitrev8((data->sony_bits >> 4) & 0xFE); | 127 | function = bitrev8((data->bits >> 4) & 0xFE); |
214 | break; | 128 | break; |
215 | case 15: | 129 | case 15: |
216 | device = bitrev8((data->sony_bits >> 0) & 0xFF); | 130 | device = bitrev8((data->bits >> 0) & 0xFF); |
217 | subdevice = 0; | 131 | subdevice = 0; |
218 | function = bitrev8((data->sony_bits >> 7) & 0xFD); | 132 | function = bitrev8((data->bits >> 7) & 0xFD); |
219 | break; | 133 | break; |
220 | case 20: | 134 | case 20: |
221 | device = bitrev8((data->sony_bits >> 5) & 0xF8); | 135 | device = bitrev8((data->bits >> 5) & 0xF8); |
222 | subdevice = bitrev8((data->sony_bits >> 0) & 0xFF); | 136 | subdevice = bitrev8((data->bits >> 0) & 0xFF); |
223 | function = bitrev8((data->sony_bits >> 12) & 0xFE); | 137 | function = bitrev8((data->bits >> 12) & 0xFE); |
224 | break; | 138 | break; |
225 | default: | 139 | default: |
226 | IR_dprintk(1, "Sony invalid bitcount %u\n", data->count); | 140 | IR_dprintk(1, "Sony invalid bitcount %u\n", data->count); |
@@ -241,54 +155,9 @@ out: | |||
241 | return -EINVAL; | 155 | return -EINVAL; |
242 | } | 156 | } |
243 | 157 | ||
244 | static int ir_sony_register(struct input_dev *input_dev) | ||
245 | { | ||
246 | struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); | ||
247 | struct decoder_data *data; | ||
248 | int rc; | ||
249 | |||
250 | rc = sysfs_create_group(&ir_dev->dev.kobj, &decoder_attribute_group); | ||
251 | if (rc < 0) | ||
252 | return rc; | ||
253 | |||
254 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
255 | if (!data) { | ||
256 | sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group); | ||
257 | return -ENOMEM; | ||
258 | } | ||
259 | |||
260 | data->ir_dev = ir_dev; | ||
261 | data->enabled = 1; | ||
262 | |||
263 | spin_lock(&decoder_lock); | ||
264 | list_add_tail(&data->list, &decoder_list); | ||
265 | spin_unlock(&decoder_lock); | ||
266 | |||
267 | return 0; | ||
268 | } | ||
269 | |||
270 | static int ir_sony_unregister(struct input_dev *input_dev) | ||
271 | { | ||
272 | struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); | ||
273 | static struct decoder_data *data; | ||
274 | |||
275 | data = get_decoder_data(ir_dev); | ||
276 | if (!data) | ||
277 | return 0; | ||
278 | |||
279 | sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group); | ||
280 | |||
281 | spin_lock(&decoder_lock); | ||
282 | list_del(&data->list); | ||
283 | spin_unlock(&decoder_lock); | ||
284 | |||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | static struct ir_raw_handler sony_handler = { | 158 | static struct ir_raw_handler sony_handler = { |
159 | .protocols = IR_TYPE_SONY, | ||
289 | .decode = ir_sony_decode, | 160 | .decode = ir_sony_decode, |
290 | .raw_register = ir_sony_register, | ||
291 | .raw_unregister = ir_sony_unregister, | ||
292 | }; | 161 | }; |
293 | 162 | ||
294 | static int __init ir_sony_decode_init(void) | 163 | static int __init ir_sony_decode_init(void) |