diff options
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/rc/rc-main.c | 212 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx.h | 2 |
2 files changed, 107 insertions, 107 deletions
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index f3244eba66c6..caa8d70de726 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c | |||
@@ -47,7 +47,7 @@ static struct rc_keymap *seek_rc_map(const char *name) | |||
47 | return NULL; | 47 | return NULL; |
48 | } | 48 | } |
49 | 49 | ||
50 | struct ir_scancode_table *get_rc_map(const char *name) | 50 | struct rc_map *get_rc_map(const char *name) |
51 | { | 51 | { |
52 | 52 | ||
53 | struct rc_keymap *map; | 53 | struct rc_keymap *map; |
@@ -109,71 +109,71 @@ static struct rc_keymap empty_map = { | |||
109 | 109 | ||
110 | /** | 110 | /** |
111 | * ir_create_table() - initializes a scancode table | 111 | * ir_create_table() - initializes a scancode table |
112 | * @rc_tab: the ir_scancode_table to initialize | 112 | * @rc_map: the rc_map to initialize |
113 | * @name: name to assign to the table | 113 | * @name: name to assign to the table |
114 | * @rc_type: ir type to assign to the new table | 114 | * @rc_type: ir type to assign to the new table |
115 | * @size: initial size of the table | 115 | * @size: initial size of the table |
116 | * @return: zero on success or a negative error code | 116 | * @return: zero on success or a negative error code |
117 | * | 117 | * |
118 | * This routine will initialize the ir_scancode_table and will allocate | 118 | * This routine will initialize the rc_map and will allocate |
119 | * memory to hold at least the specified number of elements. | 119 | * memory to hold at least the specified number of elements. |
120 | */ | 120 | */ |
121 | static int ir_create_table(struct ir_scancode_table *rc_tab, | 121 | static int ir_create_table(struct rc_map *rc_map, |
122 | const char *name, u64 rc_type, size_t size) | 122 | const char *name, u64 rc_type, size_t size) |
123 | { | 123 | { |
124 | rc_tab->name = name; | 124 | rc_map->name = name; |
125 | rc_tab->rc_type = rc_type; | 125 | rc_map->rc_type = rc_type; |
126 | rc_tab->alloc = roundup_pow_of_two(size * sizeof(struct ir_scancode)); | 126 | rc_map->alloc = roundup_pow_of_two(size * sizeof(struct ir_scancode)); |
127 | rc_tab->size = rc_tab->alloc / sizeof(struct ir_scancode); | 127 | rc_map->size = rc_map->alloc / sizeof(struct ir_scancode); |
128 | rc_tab->scan = kmalloc(rc_tab->alloc, GFP_KERNEL); | 128 | rc_map->scan = kmalloc(rc_map->alloc, GFP_KERNEL); |
129 | if (!rc_tab->scan) | 129 | if (!rc_map->scan) |
130 | return -ENOMEM; | 130 | return -ENOMEM; |
131 | 131 | ||
132 | IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n", | 132 | IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n", |
133 | rc_tab->size, rc_tab->alloc); | 133 | rc_map->size, rc_map->alloc); |
134 | return 0; | 134 | return 0; |
135 | } | 135 | } |
136 | 136 | ||
137 | /** | 137 | /** |
138 | * ir_free_table() - frees memory allocated by a scancode table | 138 | * ir_free_table() - frees memory allocated by a scancode table |
139 | * @rc_tab: the table whose mappings need to be freed | 139 | * @rc_map: the table whose mappings need to be freed |
140 | * | 140 | * |
141 | * This routine will free memory alloctaed for key mappings used by given | 141 | * This routine will free memory alloctaed for key mappings used by given |
142 | * scancode table. | 142 | * scancode table. |
143 | */ | 143 | */ |
144 | static void ir_free_table(struct ir_scancode_table *rc_tab) | 144 | static void ir_free_table(struct rc_map *rc_map) |
145 | { | 145 | { |
146 | rc_tab->size = 0; | 146 | rc_map->size = 0; |
147 | kfree(rc_tab->scan); | 147 | kfree(rc_map->scan); |
148 | rc_tab->scan = NULL; | 148 | rc_map->scan = NULL; |
149 | } | 149 | } |
150 | 150 | ||
151 | /** | 151 | /** |
152 | * ir_resize_table() - resizes a scancode table if necessary | 152 | * ir_resize_table() - resizes a scancode table if necessary |
153 | * @rc_tab: the ir_scancode_table to resize | 153 | * @rc_map: the rc_map to resize |
154 | * @gfp_flags: gfp flags to use when allocating memory | 154 | * @gfp_flags: gfp flags to use when allocating memory |
155 | * @return: zero on success or a negative error code | 155 | * @return: zero on success or a negative error code |
156 | * | 156 | * |
157 | * This routine will shrink the ir_scancode_table if it has lots of | 157 | * This routine will shrink the rc_map if it has lots of |
158 | * unused entries and grow it if it is full. | 158 | * unused entries and grow it if it is full. |
159 | */ | 159 | */ |
160 | static int ir_resize_table(struct ir_scancode_table *rc_tab, gfp_t gfp_flags) | 160 | static int ir_resize_table(struct rc_map *rc_map, gfp_t gfp_flags) |
161 | { | 161 | { |
162 | unsigned int oldalloc = rc_tab->alloc; | 162 | unsigned int oldalloc = rc_map->alloc; |
163 | unsigned int newalloc = oldalloc; | 163 | unsigned int newalloc = oldalloc; |
164 | struct ir_scancode *oldscan = rc_tab->scan; | 164 | struct ir_scancode *oldscan = rc_map->scan; |
165 | struct ir_scancode *newscan; | 165 | struct ir_scancode *newscan; |
166 | 166 | ||
167 | if (rc_tab->size == rc_tab->len) { | 167 | if (rc_map->size == rc_map->len) { |
168 | /* All entries in use -> grow keytable */ | 168 | /* All entries in use -> grow keytable */ |
169 | if (rc_tab->alloc >= IR_TAB_MAX_SIZE) | 169 | if (rc_map->alloc >= IR_TAB_MAX_SIZE) |
170 | return -ENOMEM; | 170 | return -ENOMEM; |
171 | 171 | ||
172 | newalloc *= 2; | 172 | newalloc *= 2; |
173 | IR_dprintk(1, "Growing table to %u bytes\n", newalloc); | 173 | IR_dprintk(1, "Growing table to %u bytes\n", newalloc); |
174 | } | 174 | } |
175 | 175 | ||
176 | if ((rc_tab->len * 3 < rc_tab->size) && (oldalloc > IR_TAB_MIN_SIZE)) { | 176 | if ((rc_map->len * 3 < rc_map->size) && (oldalloc > IR_TAB_MIN_SIZE)) { |
177 | /* Less than 1/3 of entries in use -> shrink keytable */ | 177 | /* Less than 1/3 of entries in use -> shrink keytable */ |
178 | newalloc /= 2; | 178 | newalloc /= 2; |
179 | IR_dprintk(1, "Shrinking table to %u bytes\n", newalloc); | 179 | IR_dprintk(1, "Shrinking table to %u bytes\n", newalloc); |
@@ -188,10 +188,10 @@ static int ir_resize_table(struct ir_scancode_table *rc_tab, gfp_t gfp_flags) | |||
188 | return -ENOMEM; | 188 | return -ENOMEM; |
189 | } | 189 | } |
190 | 190 | ||
191 | memcpy(newscan, rc_tab->scan, rc_tab->len * sizeof(struct ir_scancode)); | 191 | memcpy(newscan, rc_map->scan, rc_map->len * sizeof(struct ir_scancode)); |
192 | rc_tab->scan = newscan; | 192 | rc_map->scan = newscan; |
193 | rc_tab->alloc = newalloc; | 193 | rc_map->alloc = newalloc; |
194 | rc_tab->size = rc_tab->alloc / sizeof(struct ir_scancode); | 194 | rc_map->size = rc_map->alloc / sizeof(struct ir_scancode); |
195 | kfree(oldscan); | 195 | kfree(oldscan); |
196 | return 0; | 196 | return 0; |
197 | } | 197 | } |
@@ -199,7 +199,7 @@ static int ir_resize_table(struct ir_scancode_table *rc_tab, gfp_t gfp_flags) | |||
199 | /** | 199 | /** |
200 | * ir_update_mapping() - set a keycode in the scancode->keycode table | 200 | * ir_update_mapping() - set a keycode in the scancode->keycode table |
201 | * @dev: the struct rc_dev device descriptor | 201 | * @dev: the struct rc_dev device descriptor |
202 | * @rc_tab: scancode table to be adjusted | 202 | * @rc_map: scancode table to be adjusted |
203 | * @index: index of the mapping that needs to be updated | 203 | * @index: index of the mapping that needs to be updated |
204 | * @keycode: the desired keycode | 204 | * @keycode: the desired keycode |
205 | * @return: previous keycode assigned to the mapping | 205 | * @return: previous keycode assigned to the mapping |
@@ -208,26 +208,26 @@ static int ir_resize_table(struct ir_scancode_table *rc_tab, gfp_t gfp_flags) | |||
208 | * position. | 208 | * position. |
209 | */ | 209 | */ |
210 | static unsigned int ir_update_mapping(struct rc_dev *dev, | 210 | static unsigned int ir_update_mapping(struct rc_dev *dev, |
211 | struct ir_scancode_table *rc_tab, | 211 | struct rc_map *rc_map, |
212 | unsigned int index, | 212 | unsigned int index, |
213 | unsigned int new_keycode) | 213 | unsigned int new_keycode) |
214 | { | 214 | { |
215 | int old_keycode = rc_tab->scan[index].keycode; | 215 | int old_keycode = rc_map->scan[index].keycode; |
216 | int i; | 216 | int i; |
217 | 217 | ||
218 | /* Did the user wish to remove the mapping? */ | 218 | /* Did the user wish to remove the mapping? */ |
219 | if (new_keycode == KEY_RESERVED || new_keycode == KEY_UNKNOWN) { | 219 | if (new_keycode == KEY_RESERVED || new_keycode == KEY_UNKNOWN) { |
220 | IR_dprintk(1, "#%d: Deleting scan 0x%04x\n", | 220 | IR_dprintk(1, "#%d: Deleting scan 0x%04x\n", |
221 | index, rc_tab->scan[index].scancode); | 221 | index, rc_map->scan[index].scancode); |
222 | rc_tab->len--; | 222 | rc_map->len--; |
223 | memmove(&rc_tab->scan[index], &rc_tab->scan[index+ 1], | 223 | memmove(&rc_map->scan[index], &rc_map->scan[index+ 1], |
224 | (rc_tab->len - index) * sizeof(struct ir_scancode)); | 224 | (rc_map->len - index) * sizeof(struct ir_scancode)); |
225 | } else { | 225 | } else { |
226 | IR_dprintk(1, "#%d: %s scan 0x%04x with key 0x%04x\n", | 226 | IR_dprintk(1, "#%d: %s scan 0x%04x with key 0x%04x\n", |
227 | index, | 227 | index, |
228 | old_keycode == KEY_RESERVED ? "New" : "Replacing", | 228 | old_keycode == KEY_RESERVED ? "New" : "Replacing", |
229 | rc_tab->scan[index].scancode, new_keycode); | 229 | rc_map->scan[index].scancode, new_keycode); |
230 | rc_tab->scan[index].keycode = new_keycode; | 230 | rc_map->scan[index].keycode = new_keycode; |
231 | __set_bit(new_keycode, dev->input_dev->keybit); | 231 | __set_bit(new_keycode, dev->input_dev->keybit); |
232 | } | 232 | } |
233 | 233 | ||
@@ -235,15 +235,15 @@ static unsigned int ir_update_mapping(struct rc_dev *dev, | |||
235 | /* A previous mapping was updated... */ | 235 | /* A previous mapping was updated... */ |
236 | __clear_bit(old_keycode, dev->input_dev->keybit); | 236 | __clear_bit(old_keycode, dev->input_dev->keybit); |
237 | /* ... but another scancode might use the same keycode */ | 237 | /* ... but another scancode might use the same keycode */ |
238 | for (i = 0; i < rc_tab->len; i++) { | 238 | for (i = 0; i < rc_map->len; i++) { |
239 | if (rc_tab->scan[i].keycode == old_keycode) { | 239 | if (rc_map->scan[i].keycode == old_keycode) { |
240 | __set_bit(old_keycode, dev->input_dev->keybit); | 240 | __set_bit(old_keycode, dev->input_dev->keybit); |
241 | break; | 241 | break; |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | /* Possibly shrink the keytable, failure is not a problem */ | 245 | /* Possibly shrink the keytable, failure is not a problem */ |
246 | ir_resize_table(rc_tab, GFP_ATOMIC); | 246 | ir_resize_table(rc_map, GFP_ATOMIC); |
247 | } | 247 | } |
248 | 248 | ||
249 | return old_keycode; | 249 | return old_keycode; |
@@ -252,19 +252,19 @@ static unsigned int ir_update_mapping(struct rc_dev *dev, | |||
252 | /** | 252 | /** |
253 | * ir_establish_scancode() - set a keycode in the scancode->keycode table | 253 | * ir_establish_scancode() - set a keycode in the scancode->keycode table |
254 | * @dev: the struct rc_dev device descriptor | 254 | * @dev: the struct rc_dev device descriptor |
255 | * @rc_tab: scancode table to be searched | 255 | * @rc_map: scancode table to be searched |
256 | * @scancode: the desired scancode | 256 | * @scancode: the desired scancode |
257 | * @resize: controls whether we allowed to resize the table to | 257 | * @resize: controls whether we allowed to resize the table to |
258 | * accomodate not yet present scancodes | 258 | * accomodate not yet present scancodes |
259 | * @return: index of the mapping containing scancode in question | 259 | * @return: index of the mapping containing scancode in question |
260 | * or -1U in case of failure. | 260 | * or -1U in case of failure. |
261 | * | 261 | * |
262 | * This routine is used to locate given scancode in ir_scancode_table. | 262 | * This routine is used to locate given scancode in rc_map. |
263 | * If scancode is not yet present the routine will allocate a new slot | 263 | * If scancode is not yet present the routine will allocate a new slot |
264 | * for it. | 264 | * for it. |
265 | */ | 265 | */ |
266 | static unsigned int ir_establish_scancode(struct rc_dev *dev, | 266 | static unsigned int ir_establish_scancode(struct rc_dev *dev, |
267 | struct ir_scancode_table *rc_tab, | 267 | struct rc_map *rc_map, |
268 | unsigned int scancode, | 268 | unsigned int scancode, |
269 | bool resize) | 269 | bool resize) |
270 | { | 270 | { |
@@ -282,28 +282,28 @@ static unsigned int ir_establish_scancode(struct rc_dev *dev, | |||
282 | scancode &= dev->scanmask; | 282 | scancode &= dev->scanmask; |
283 | 283 | ||
284 | /* First check if we already have a mapping for this ir command */ | 284 | /* First check if we already have a mapping for this ir command */ |
285 | for (i = 0; i < rc_tab->len; i++) { | 285 | for (i = 0; i < rc_map->len; i++) { |
286 | if (rc_tab->scan[i].scancode == scancode) | 286 | if (rc_map->scan[i].scancode == scancode) |
287 | return i; | 287 | return i; |
288 | 288 | ||
289 | /* Keytable is sorted from lowest to highest scancode */ | 289 | /* Keytable is sorted from lowest to highest scancode */ |
290 | if (rc_tab->scan[i].scancode >= scancode) | 290 | if (rc_map->scan[i].scancode >= scancode) |
291 | break; | 291 | break; |
292 | } | 292 | } |
293 | 293 | ||
294 | /* No previous mapping found, we might need to grow the table */ | 294 | /* No previous mapping found, we might need to grow the table */ |
295 | if (rc_tab->size == rc_tab->len) { | 295 | if (rc_map->size == rc_map->len) { |
296 | if (!resize || ir_resize_table(rc_tab, GFP_ATOMIC)) | 296 | if (!resize || ir_resize_table(rc_map, GFP_ATOMIC)) |
297 | return -1U; | 297 | return -1U; |
298 | } | 298 | } |
299 | 299 | ||
300 | /* i is the proper index to insert our new keycode */ | 300 | /* i is the proper index to insert our new keycode */ |
301 | if (i < rc_tab->len) | 301 | if (i < rc_map->len) |
302 | memmove(&rc_tab->scan[i + 1], &rc_tab->scan[i], | 302 | memmove(&rc_map->scan[i + 1], &rc_map->scan[i], |
303 | (rc_tab->len - i) * sizeof(struct ir_scancode)); | 303 | (rc_map->len - i) * sizeof(struct ir_scancode)); |
304 | rc_tab->scan[i].scancode = scancode; | 304 | rc_map->scan[i].scancode = scancode; |
305 | rc_tab->scan[i].keycode = KEY_RESERVED; | 305 | rc_map->scan[i].keycode = KEY_RESERVED; |
306 | rc_tab->len++; | 306 | rc_map->len++; |
307 | 307 | ||
308 | return i; | 308 | return i; |
309 | } | 309 | } |
@@ -322,17 +322,17 @@ static int ir_setkeycode(struct input_dev *idev, | |||
322 | unsigned int *old_keycode) | 322 | unsigned int *old_keycode) |
323 | { | 323 | { |
324 | struct rc_dev *rdev = input_get_drvdata(idev); | 324 | struct rc_dev *rdev = input_get_drvdata(idev); |
325 | struct ir_scancode_table *rc_tab = &rdev->rc_tab; | 325 | struct rc_map *rc_map = &rdev->rc_map; |
326 | unsigned int index; | 326 | unsigned int index; |
327 | unsigned int scancode; | 327 | unsigned int scancode; |
328 | int retval; | 328 | int retval; |
329 | unsigned long flags; | 329 | unsigned long flags; |
330 | 330 | ||
331 | spin_lock_irqsave(&rc_tab->lock, flags); | 331 | spin_lock_irqsave(&rc_map->lock, flags); |
332 | 332 | ||
333 | if (ke->flags & INPUT_KEYMAP_BY_INDEX) { | 333 | if (ke->flags & INPUT_KEYMAP_BY_INDEX) { |
334 | index = ke->index; | 334 | index = ke->index; |
335 | if (index >= rc_tab->len) { | 335 | if (index >= rc_map->len) { |
336 | retval = -EINVAL; | 336 | retval = -EINVAL; |
337 | goto out; | 337 | goto out; |
338 | } | 338 | } |
@@ -341,83 +341,83 @@ static int ir_setkeycode(struct input_dev *idev, | |||
341 | if (retval) | 341 | if (retval) |
342 | goto out; | 342 | goto out; |
343 | 343 | ||
344 | index = ir_establish_scancode(rdev, rc_tab, scancode, true); | 344 | index = ir_establish_scancode(rdev, rc_map, scancode, true); |
345 | if (index >= rc_tab->len) { | 345 | if (index >= rc_map->len) { |
346 | retval = -ENOMEM; | 346 | retval = -ENOMEM; |
347 | goto out; | 347 | goto out; |
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | *old_keycode = ir_update_mapping(rdev, rc_tab, index, ke->keycode); | 351 | *old_keycode = ir_update_mapping(rdev, rc_map, index, ke->keycode); |
352 | 352 | ||
353 | out: | 353 | out: |
354 | spin_unlock_irqrestore(&rc_tab->lock, flags); | 354 | spin_unlock_irqrestore(&rc_map->lock, flags); |
355 | return retval; | 355 | return retval; |
356 | } | 356 | } |
357 | 357 | ||
358 | /** | 358 | /** |
359 | * ir_setkeytable() - sets several entries in the scancode->keycode table | 359 | * ir_setkeytable() - sets several entries in the scancode->keycode table |
360 | * @dev: the struct rc_dev device descriptor | 360 | * @dev: the struct rc_dev device descriptor |
361 | * @to: the struct ir_scancode_table to copy entries to | 361 | * @to: the struct rc_map to copy entries to |
362 | * @from: the struct ir_scancode_table to copy entries from | 362 | * @from: the struct rc_map to copy entries from |
363 | * @return: -ENOMEM if all keycodes could not be inserted, otherwise zero. | 363 | * @return: -ENOMEM if all keycodes could not be inserted, otherwise zero. |
364 | * | 364 | * |
365 | * This routine is used to handle table initialization. | 365 | * This routine is used to handle table initialization. |
366 | */ | 366 | */ |
367 | static int ir_setkeytable(struct rc_dev *dev, | 367 | static int ir_setkeytable(struct rc_dev *dev, |
368 | const struct ir_scancode_table *from) | 368 | const struct rc_map *from) |
369 | { | 369 | { |
370 | struct ir_scancode_table *rc_tab = &dev->rc_tab; | 370 | struct rc_map *rc_map = &dev->rc_map; |
371 | unsigned int i, index; | 371 | unsigned int i, index; |
372 | int rc; | 372 | int rc; |
373 | 373 | ||
374 | rc = ir_create_table(rc_tab, from->name, | 374 | rc = ir_create_table(rc_map, from->name, |
375 | from->rc_type, from->size); | 375 | from->rc_type, from->size); |
376 | if (rc) | 376 | if (rc) |
377 | return rc; | 377 | return rc; |
378 | 378 | ||
379 | IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n", | 379 | IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n", |
380 | rc_tab->size, rc_tab->alloc); | 380 | rc_map->size, rc_map->alloc); |
381 | 381 | ||
382 | for (i = 0; i < from->size; i++) { | 382 | for (i = 0; i < from->size; i++) { |
383 | index = ir_establish_scancode(dev, rc_tab, | 383 | index = ir_establish_scancode(dev, rc_map, |
384 | from->scan[i].scancode, false); | 384 | from->scan[i].scancode, false); |
385 | if (index >= rc_tab->len) { | 385 | if (index >= rc_map->len) { |
386 | rc = -ENOMEM; | 386 | rc = -ENOMEM; |
387 | break; | 387 | break; |
388 | } | 388 | } |
389 | 389 | ||
390 | ir_update_mapping(dev, rc_tab, index, | 390 | ir_update_mapping(dev, rc_map, index, |
391 | from->scan[i].keycode); | 391 | from->scan[i].keycode); |
392 | } | 392 | } |
393 | 393 | ||
394 | if (rc) | 394 | if (rc) |
395 | ir_free_table(rc_tab); | 395 | ir_free_table(rc_map); |
396 | 396 | ||
397 | return rc; | 397 | return rc; |
398 | } | 398 | } |
399 | 399 | ||
400 | /** | 400 | /** |
401 | * ir_lookup_by_scancode() - locate mapping by scancode | 401 | * ir_lookup_by_scancode() - locate mapping by scancode |
402 | * @rc_tab: the struct ir_scancode_table to search | 402 | * @rc_map: the struct rc_map to search |
403 | * @scancode: scancode to look for in the table | 403 | * @scancode: scancode to look for in the table |
404 | * @return: index in the table, -1U if not found | 404 | * @return: index in the table, -1U if not found |
405 | * | 405 | * |
406 | * This routine performs binary search in RC keykeymap table for | 406 | * This routine performs binary search in RC keykeymap table for |
407 | * given scancode. | 407 | * given scancode. |
408 | */ | 408 | */ |
409 | static unsigned int ir_lookup_by_scancode(const struct ir_scancode_table *rc_tab, | 409 | static unsigned int ir_lookup_by_scancode(const struct rc_map *rc_map, |
410 | unsigned int scancode) | 410 | unsigned int scancode) |
411 | { | 411 | { |
412 | int start = 0; | 412 | int start = 0; |
413 | int end = rc_tab->len - 1; | 413 | int end = rc_map->len - 1; |
414 | int mid; | 414 | int mid; |
415 | 415 | ||
416 | while (start <= end) { | 416 | while (start <= end) { |
417 | mid = (start + end) / 2; | 417 | mid = (start + end) / 2; |
418 | if (rc_tab->scan[mid].scancode < scancode) | 418 | if (rc_map->scan[mid].scancode < scancode) |
419 | start = mid + 1; | 419 | start = mid + 1; |
420 | else if (rc_tab->scan[mid].scancode > scancode) | 420 | else if (rc_map->scan[mid].scancode > scancode) |
421 | end = mid - 1; | 421 | end = mid - 1; |
422 | else | 422 | else |
423 | return mid; | 423 | return mid; |
@@ -439,14 +439,14 @@ static int ir_getkeycode(struct input_dev *idev, | |||
439 | struct input_keymap_entry *ke) | 439 | struct input_keymap_entry *ke) |
440 | { | 440 | { |
441 | struct rc_dev *rdev = input_get_drvdata(idev); | 441 | struct rc_dev *rdev = input_get_drvdata(idev); |
442 | struct ir_scancode_table *rc_tab = &rdev->rc_tab; | 442 | struct rc_map *rc_map = &rdev->rc_map; |
443 | struct ir_scancode *entry; | 443 | struct ir_scancode *entry; |
444 | unsigned long flags; | 444 | unsigned long flags; |
445 | unsigned int index; | 445 | unsigned int index; |
446 | unsigned int scancode; | 446 | unsigned int scancode; |
447 | int retval; | 447 | int retval; |
448 | 448 | ||
449 | spin_lock_irqsave(&rc_tab->lock, flags); | 449 | spin_lock_irqsave(&rc_map->lock, flags); |
450 | 450 | ||
451 | if (ke->flags & INPUT_KEYMAP_BY_INDEX) { | 451 | if (ke->flags & INPUT_KEYMAP_BY_INDEX) { |
452 | index = ke->index; | 452 | index = ke->index; |
@@ -455,10 +455,10 @@ static int ir_getkeycode(struct input_dev *idev, | |||
455 | if (retval) | 455 | if (retval) |
456 | goto out; | 456 | goto out; |
457 | 457 | ||
458 | index = ir_lookup_by_scancode(rc_tab, scancode); | 458 | index = ir_lookup_by_scancode(rc_map, scancode); |
459 | } | 459 | } |
460 | 460 | ||
461 | if (index >= rc_tab->len) { | 461 | if (index >= rc_map->len) { |
462 | if (!(ke->flags & INPUT_KEYMAP_BY_INDEX)) | 462 | if (!(ke->flags & INPUT_KEYMAP_BY_INDEX)) |
463 | IR_dprintk(1, "unknown key for scancode 0x%04x\n", | 463 | IR_dprintk(1, "unknown key for scancode 0x%04x\n", |
464 | scancode); | 464 | scancode); |
@@ -466,7 +466,7 @@ static int ir_getkeycode(struct input_dev *idev, | |||
466 | goto out; | 466 | goto out; |
467 | } | 467 | } |
468 | 468 | ||
469 | entry = &rc_tab->scan[index]; | 469 | entry = &rc_map->scan[index]; |
470 | 470 | ||
471 | ke->index = index; | 471 | ke->index = index; |
472 | ke->keycode = entry->keycode; | 472 | ke->keycode = entry->keycode; |
@@ -476,7 +476,7 @@ static int ir_getkeycode(struct input_dev *idev, | |||
476 | retval = 0; | 476 | retval = 0; |
477 | 477 | ||
478 | out: | 478 | out: |
479 | spin_unlock_irqrestore(&rc_tab->lock, flags); | 479 | spin_unlock_irqrestore(&rc_map->lock, flags); |
480 | return retval; | 480 | return retval; |
481 | } | 481 | } |
482 | 482 | ||
@@ -492,18 +492,18 @@ out: | |||
492 | */ | 492 | */ |
493 | u32 rc_g_keycode_from_table(struct rc_dev *dev, u32 scancode) | 493 | u32 rc_g_keycode_from_table(struct rc_dev *dev, u32 scancode) |
494 | { | 494 | { |
495 | struct ir_scancode_table *rc_tab = &dev->rc_tab; | 495 | struct rc_map *rc_map = &dev->rc_map; |
496 | unsigned int keycode; | 496 | unsigned int keycode; |
497 | unsigned int index; | 497 | unsigned int index; |
498 | unsigned long flags; | 498 | unsigned long flags; |
499 | 499 | ||
500 | spin_lock_irqsave(&rc_tab->lock, flags); | 500 | spin_lock_irqsave(&rc_map->lock, flags); |
501 | 501 | ||
502 | index = ir_lookup_by_scancode(rc_tab, scancode); | 502 | index = ir_lookup_by_scancode(rc_map, scancode); |
503 | keycode = index < rc_tab->len ? | 503 | keycode = index < rc_map->len ? |
504 | rc_tab->scan[index].keycode : KEY_RESERVED; | 504 | rc_map->scan[index].keycode : KEY_RESERVED; |
505 | 505 | ||
506 | spin_unlock_irqrestore(&rc_tab->lock, flags); | 506 | spin_unlock_irqrestore(&rc_map->lock, flags); |
507 | 507 | ||
508 | if (keycode != KEY_RESERVED) | 508 | if (keycode != KEY_RESERVED) |
509 | IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n", | 509 | IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n", |
@@ -755,7 +755,7 @@ static ssize_t show_protocols(struct device *device, | |||
755 | return -EINVAL; | 755 | return -EINVAL; |
756 | 756 | ||
757 | if (dev->driver_type == RC_DRIVER_SCANCODE) { | 757 | if (dev->driver_type == RC_DRIVER_SCANCODE) { |
758 | enabled = dev->rc_tab.rc_type; | 758 | enabled = dev->rc_map.rc_type; |
759 | allowed = dev->allowed_protos; | 759 | allowed = dev->allowed_protos; |
760 | } else { | 760 | } else { |
761 | enabled = dev->raw->enabled_protocols; | 761 | enabled = dev->raw->enabled_protocols; |
@@ -813,7 +813,7 @@ static ssize_t store_protocols(struct device *device, | |||
813 | return -EINVAL; | 813 | return -EINVAL; |
814 | 814 | ||
815 | if (dev->driver_type == RC_DRIVER_SCANCODE) | 815 | if (dev->driver_type == RC_DRIVER_SCANCODE) |
816 | type = dev->rc_tab.rc_type; | 816 | type = dev->rc_map.rc_type; |
817 | else if (dev->raw) | 817 | else if (dev->raw) |
818 | type = dev->raw->enabled_protocols; | 818 | type = dev->raw->enabled_protocols; |
819 | else { | 819 | else { |
@@ -880,9 +880,9 @@ static ssize_t store_protocols(struct device *device, | |||
880 | } | 880 | } |
881 | 881 | ||
882 | if (dev->driver_type == RC_DRIVER_SCANCODE) { | 882 | if (dev->driver_type == RC_DRIVER_SCANCODE) { |
883 | spin_lock_irqsave(&dev->rc_tab.lock, flags); | 883 | spin_lock_irqsave(&dev->rc_map.lock, flags); |
884 | dev->rc_tab.rc_type = type; | 884 | dev->rc_map.rc_type = type; |
885 | spin_unlock_irqrestore(&dev->rc_tab.lock, flags); | 885 | spin_unlock_irqrestore(&dev->rc_map.lock, flags); |
886 | } else { | 886 | } else { |
887 | dev->raw->enabled_protocols = type; | 887 | dev->raw->enabled_protocols = type; |
888 | } | 888 | } |
@@ -912,8 +912,8 @@ static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env) | |||
912 | { | 912 | { |
913 | struct rc_dev *dev = to_rc_dev(device); | 913 | struct rc_dev *dev = to_rc_dev(device); |
914 | 914 | ||
915 | if (dev->rc_tab.name) | 915 | if (dev->rc_map.name) |
916 | ADD_HOTPLUG_VAR("NAME=%s", dev->rc_tab.name); | 916 | ADD_HOTPLUG_VAR("NAME=%s", dev->rc_map.name); |
917 | if (dev->driver_name) | 917 | if (dev->driver_name) |
918 | ADD_HOTPLUG_VAR("DRV_NAME=%s", dev->driver_name); | 918 | ADD_HOTPLUG_VAR("DRV_NAME=%s", dev->driver_name); |
919 | 919 | ||
@@ -964,7 +964,7 @@ struct rc_dev *rc_allocate_device(void) | |||
964 | dev->input_dev->setkeycode_new = ir_setkeycode; | 964 | dev->input_dev->setkeycode_new = ir_setkeycode; |
965 | input_set_drvdata(dev->input_dev, dev); | 965 | input_set_drvdata(dev->input_dev, dev); |
966 | 966 | ||
967 | spin_lock_init(&dev->rc_tab.lock); | 967 | spin_lock_init(&dev->rc_map.lock); |
968 | spin_lock_init(&dev->keylock); | 968 | spin_lock_init(&dev->keylock); |
969 | setup_timer(&dev->timer_keyup, ir_timer_keyup, (unsigned long)dev); | 969 | setup_timer(&dev->timer_keyup, ir_timer_keyup, (unsigned long)dev); |
970 | 970 | ||
@@ -989,17 +989,17 @@ EXPORT_SYMBOL_GPL(rc_free_device); | |||
989 | int rc_register_device(struct rc_dev *dev) | 989 | int rc_register_device(struct rc_dev *dev) |
990 | { | 990 | { |
991 | static atomic_t devno = ATOMIC_INIT(0); | 991 | static atomic_t devno = ATOMIC_INIT(0); |
992 | struct ir_scancode_table *rc_tab; | 992 | struct rc_map *rc_map; |
993 | const char *path; | 993 | const char *path; |
994 | int rc; | 994 | int rc; |
995 | 995 | ||
996 | if (!dev || !dev->map_name) | 996 | if (!dev || !dev->map_name) |
997 | return -EINVAL; | 997 | return -EINVAL; |
998 | 998 | ||
999 | rc_tab = get_rc_map(dev->map_name); | 999 | rc_map = get_rc_map(dev->map_name); |
1000 | if (!rc_tab) | 1000 | if (!rc_map) |
1001 | rc_tab = get_rc_map(RC_MAP_EMPTY); | 1001 | rc_map = get_rc_map(RC_MAP_EMPTY); |
1002 | if (!rc_tab || !rc_tab->scan || rc_tab->size == 0) | 1002 | if (!rc_map || !rc_map->scan || rc_map->size == 0) |
1003 | return -EINVAL; | 1003 | return -EINVAL; |
1004 | 1004 | ||
1005 | set_bit(EV_KEY, dev->input_dev->evbit); | 1005 | set_bit(EV_KEY, dev->input_dev->evbit); |
@@ -1018,7 +1018,7 @@ int rc_register_device(struct rc_dev *dev) | |||
1018 | if (rc) | 1018 | if (rc) |
1019 | return rc; | 1019 | return rc; |
1020 | 1020 | ||
1021 | rc = ir_setkeytable(dev, rc_tab); | 1021 | rc = ir_setkeytable(dev, rc_map); |
1022 | if (rc) | 1022 | if (rc) |
1023 | goto out_dev; | 1023 | goto out_dev; |
1024 | 1024 | ||
@@ -1052,7 +1052,7 @@ int rc_register_device(struct rc_dev *dev) | |||
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | if (dev->change_protocol) { | 1054 | if (dev->change_protocol) { |
1055 | rc = dev->change_protocol(dev, rc_tab->rc_type); | 1055 | rc = dev->change_protocol(dev, rc_map->rc_type); |
1056 | if (rc < 0) | 1056 | if (rc < 0) |
1057 | goto out_raw; | 1057 | goto out_raw; |
1058 | } | 1058 | } |
@@ -1060,7 +1060,7 @@ int rc_register_device(struct rc_dev *dev) | |||
1060 | IR_dprintk(1, "Registered rc%ld (driver: %s, remote: %s, mode %s)\n", | 1060 | IR_dprintk(1, "Registered rc%ld (driver: %s, remote: %s, mode %s)\n", |
1061 | dev->devno, | 1061 | dev->devno, |
1062 | dev->driver_name ? dev->driver_name : "unknown", | 1062 | dev->driver_name ? dev->driver_name : "unknown", |
1063 | rc_tab->name ? rc_tab->name : "unknown", | 1063 | rc_map->name ? rc_map->name : "unknown", |
1064 | dev->driver_type == RC_DRIVER_IR_RAW ? "raw" : "cooked"); | 1064 | dev->driver_type == RC_DRIVER_IR_RAW ? "raw" : "cooked"); |
1065 | 1065 | ||
1066 | return 0; | 1066 | return 0; |
@@ -1072,7 +1072,7 @@ out_input: | |||
1072 | input_unregister_device(dev->input_dev); | 1072 | input_unregister_device(dev->input_dev); |
1073 | dev->input_dev = NULL; | 1073 | dev->input_dev = NULL; |
1074 | out_table: | 1074 | out_table: |
1075 | ir_free_table(&dev->rc_tab); | 1075 | ir_free_table(&dev->rc_map); |
1076 | out_dev: | 1076 | out_dev: |
1077 | device_del(&dev->dev); | 1077 | device_del(&dev->dev); |
1078 | return rc; | 1078 | return rc; |
@@ -1092,7 +1092,7 @@ void rc_unregister_device(struct rc_dev *dev) | |||
1092 | input_unregister_device(dev->input_dev); | 1092 | input_unregister_device(dev->input_dev); |
1093 | dev->input_dev = NULL; | 1093 | dev->input_dev = NULL; |
1094 | 1094 | ||
1095 | ir_free_table(&dev->rc_tab); | 1095 | ir_free_table(&dev->rc_map); |
1096 | IR_dprintk(1, "Freed keycode table\n"); | 1096 | IR_dprintk(1, "Freed keycode table\n"); |
1097 | 1097 | ||
1098 | device_unregister(&dev->dev); | 1098 | device_unregister(&dev->dev); |
diff --git a/drivers/media/video/cx231xx/cx231xx.h b/drivers/media/video/cx231xx/cx231xx.h index 709cb87a7762..72bbea2bcd56 100644 --- a/drivers/media/video/cx231xx/cx231xx.h +++ b/drivers/media/video/cx231xx/cx231xx.h | |||
@@ -362,7 +362,7 @@ struct cx231xx_board { | |||
362 | 362 | ||
363 | struct cx231xx_input input[MAX_CX231XX_INPUT]; | 363 | struct cx231xx_input input[MAX_CX231XX_INPUT]; |
364 | struct cx231xx_input radio; | 364 | struct cx231xx_input radio; |
365 | struct ir_scancode_table *ir_codes; | 365 | struct rc_map *ir_codes; |
366 | }; | 366 | }; |
367 | 367 | ||
368 | /* device states */ | 368 | /* device states */ |