aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ir-kbd-i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/ir-kbd-i2c.c')
-rw-r--r--drivers/media/video/ir-kbd-i2c.c76
1 files changed, 50 insertions, 26 deletions
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index ce4a75375909..c87b6bc45555 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -46,7 +46,7 @@
46#include <linux/i2c.h> 46#include <linux/i2c.h>
47#include <linux/workqueue.h> 47#include <linux/workqueue.h>
48 48
49#include <media/ir-core.h> 49#include <media/rc-core.h>
50#include <media/ir-kbd-i2c.h> 50#include <media/ir-kbd-i2c.h>
51 51
52/* ----------------------------------------------------------------------- */ 52/* ----------------------------------------------------------------------- */
@@ -252,7 +252,7 @@ static void ir_key_poll(struct IR_i2c *ir)
252 } 252 }
253 253
254 if (rc) 254 if (rc)
255 ir_keydown(ir->input, ir_key, 0); 255 rc_keydown(ir->rc, ir_key, 0);
256} 256}
257 257
258static void ir_work(struct work_struct *work) 258static void ir_work(struct work_struct *work)
@@ -269,22 +269,18 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
269{ 269{
270 char *ir_codes = NULL; 270 char *ir_codes = NULL;
271 const char *name = NULL; 271 const char *name = NULL;
272 u64 ir_type = 0; 272 u64 rc_type = RC_TYPE_UNKNOWN;
273 struct IR_i2c *ir; 273 struct IR_i2c *ir;
274 struct input_dev *input_dev; 274 struct rc_dev *rc = NULL;
275 struct i2c_adapter *adap = client->adapter; 275 struct i2c_adapter *adap = client->adapter;
276 unsigned short addr = client->addr; 276 unsigned short addr = client->addr;
277 int err; 277 int err;
278 278
279 ir = kzalloc(sizeof(struct IR_i2c),GFP_KERNEL); 279 ir = kzalloc(sizeof(struct IR_i2c), GFP_KERNEL);
280 input_dev = input_allocate_device(); 280 if (!ir)
281 if (!ir || !input_dev) { 281 return -ENOMEM;
282 err = -ENOMEM;
283 goto err_out_free;
284 }
285 282
286 ir->c = client; 283 ir->c = client;
287 ir->input = input_dev;
288 ir->polling_interval = DEFAULT_POLLING_INTERVAL; 284 ir->polling_interval = DEFAULT_POLLING_INTERVAL;
289 i2c_set_clientdata(client, ir); 285 i2c_set_clientdata(client, ir);
290 286
@@ -292,7 +288,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
292 case 0x64: 288 case 0x64:
293 name = "Pixelview"; 289 name = "Pixelview";
294 ir->get_key = get_key_pixelview; 290 ir->get_key = get_key_pixelview;
295 ir_type = IR_TYPE_OTHER; 291 rc_type = RC_TYPE_OTHER;
296 ir_codes = RC_MAP_EMPTY; 292 ir_codes = RC_MAP_EMPTY;
297 break; 293 break;
298 case 0x18: 294 case 0x18:
@@ -300,7 +296,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
300 case 0x1a: 296 case 0x1a:
301 name = "Hauppauge"; 297 name = "Hauppauge";
302 ir->get_key = get_key_haup; 298 ir->get_key = get_key_haup;
303 ir_type = IR_TYPE_RC5; 299 rc_type = RC_TYPE_RC5;
304 if (hauppauge == 1) { 300 if (hauppauge == 1) {
305 ir_codes = RC_MAP_HAUPPAUGE_NEW; 301 ir_codes = RC_MAP_HAUPPAUGE_NEW;
306 } else { 302 } else {
@@ -310,19 +306,19 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
310 case 0x30: 306 case 0x30:
311 name = "KNC One"; 307 name = "KNC One";
312 ir->get_key = get_key_knc1; 308 ir->get_key = get_key_knc1;
313 ir_type = IR_TYPE_OTHER; 309 rc_type = RC_TYPE_OTHER;
314 ir_codes = RC_MAP_EMPTY; 310 ir_codes = RC_MAP_EMPTY;
315 break; 311 break;
316 case 0x6b: 312 case 0x6b:
317 name = "FusionHDTV"; 313 name = "FusionHDTV";
318 ir->get_key = get_key_fusionhdtv; 314 ir->get_key = get_key_fusionhdtv;
319 ir_type = IR_TYPE_RC5; 315 rc_type = RC_TYPE_RC5;
320 ir_codes = RC_MAP_FUSIONHDTV_MCE; 316 ir_codes = RC_MAP_FUSIONHDTV_MCE;
321 break; 317 break;
322 case 0x40: 318 case 0x40:
323 name = "AVerMedia Cardbus remote"; 319 name = "AVerMedia Cardbus remote";
324 ir->get_key = get_key_avermedia_cardbus; 320 ir->get_key = get_key_avermedia_cardbus;
325 ir_type = IR_TYPE_OTHER; 321 rc_type = RC_TYPE_OTHER;
326 ir_codes = RC_MAP_AVERMEDIA_CARDBUS; 322 ir_codes = RC_MAP_AVERMEDIA_CARDBUS;
327 break; 323 break;
328 } 324 }
@@ -333,9 +329,11 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
333 client->dev.platform_data; 329 client->dev.platform_data;
334 330
335 ir_codes = init_data->ir_codes; 331 ir_codes = init_data->ir_codes;
332 rc = init_data->rc_dev;
333
336 name = init_data->name; 334 name = init_data->name;
337 if (init_data->type) 335 if (init_data->type)
338 ir_type = init_data->type; 336 rc_type = init_data->type;
339 337
340 if (init_data->polling_interval) 338 if (init_data->polling_interval)
341 ir->polling_interval = init_data->polling_interval; 339 ir->polling_interval = init_data->polling_interval;
@@ -366,8 +364,21 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
366 } 364 }
367 } 365 }
368 366
367 if (!rc) {
368 /*
369 * If platform_data doesn't specify rc_dev, initilize it
370 * internally
371 */
372 rc = rc_allocate_device();
373 if (!rc) {
374 err = -ENOMEM;
375 goto err_out_free;
376 }
377 }
378 ir->rc = rc;
379
369 /* Make sure we are all setup before going on */ 380 /* Make sure we are all setup before going on */
370 if (!name || !ir->get_key || !ir_type || !ir_codes) { 381 if (!name || !ir->get_key || !rc_type || !ir_codes) {
371 dprintk(1, ": Unsupported device at address 0x%02x\n", 382 dprintk(1, ": Unsupported device at address 0x%02x\n",
372 addr); 383 addr);
373 err = -ENODEV; 384 err = -ENODEV;
@@ -382,18 +393,28 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
382 dev_name(&adap->dev), 393 dev_name(&adap->dev),
383 dev_name(&client->dev)); 394 dev_name(&client->dev));
384 395
385 /* init + register input device */ 396 /*
386 ir->ir_type = ir_type; 397 * Initialize input_dev fields
387 input_dev->id.bustype = BUS_I2C; 398 * It doesn't make sense to allow overriding them via platform_data
388 input_dev->name = ir->name; 399 */
389 input_dev->phys = ir->phys; 400 rc->input_id.bustype = BUS_I2C;
401 rc->input_phys = ir->phys;
402 rc->input_name = ir->name;
403
404 /*
405 * Initialize the other fields of rc_dev
406 */
407 rc->map_name = ir->ir_codes;
408 rc->allowed_protos = rc_type;
409 if (!rc->driver_name)
410 rc->driver_name = MODULE_NAME;
390 411
391 err = ir_input_register(ir->input, ir->ir_codes, NULL, MODULE_NAME); 412 err = rc_register_device(rc);
392 if (err) 413 if (err)
393 goto err_out_free; 414 goto err_out_free;
394 415
395 printk(MODULE_NAME ": %s detected at %s [%s]\n", 416 printk(MODULE_NAME ": %s detected at %s [%s]\n",
396 ir->input->name, ir->input->phys, adap->name); 417 ir->name, ir->phys, adap->name);
397 418
398 /* start polling via eventd */ 419 /* start polling via eventd */
399 INIT_DELAYED_WORK(&ir->work, ir_work); 420 INIT_DELAYED_WORK(&ir->work, ir_work);
@@ -402,6 +423,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
402 return 0; 423 return 0;
403 424
404 err_out_free: 425 err_out_free:
426 /* Only frees rc if it were allocated internally */
427 rc_free_device(rc);
405 kfree(ir); 428 kfree(ir);
406 return err; 429 return err;
407} 430}
@@ -414,7 +437,7 @@ static int ir_remove(struct i2c_client *client)
414 cancel_delayed_work_sync(&ir->work); 437 cancel_delayed_work_sync(&ir->work);
415 438
416 /* unregister device */ 439 /* unregister device */
417 ir_input_unregister(ir->input); 440 rc_unregister_device(ir->rc);
418 441
419 /* free memory */ 442 /* free memory */
420 kfree(ir); 443 kfree(ir);
@@ -426,6 +449,7 @@ static const struct i2c_device_id ir_kbd_id[] = {
426 { "ir_video", 0 }, 449 { "ir_video", 0 },
427 /* IR device specific entries should be added here */ 450 /* IR device specific entries should be added here */
428 { "ir_rx_z8f0811_haup", 0 }, 451 { "ir_rx_z8f0811_haup", 0 },
452 { "ir_rx_z8f0811_hdpvr", 0 },
429 { } 453 { }
430}; 454};
431 455