aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2009-05-13 15:49:32 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-16 17:21:11 -0400
commit4d7a2d6721a6380d4ffc26d81d2c8232fd0d2dfc (patch)
tree5ccac1dc6084363abdea5a63fe5d305421bd894c /drivers/media/video/em28xx
parentc668f32dca105d876e51862a003a302fa61e4ae4 (diff)
V4L/DVB (11845): ir-kbd-i2c: Use initialization data
For specific boards, pass initialization data to ir-kbd-i2c instead of modifying the settings after the device is initialized. This is more efficient and easier to read. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/em28xx')
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c31
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c22
-rw-r--r--drivers/media/video/em28xx/em28xx.h1
3 files changed, 15 insertions, 39 deletions
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index edba71115a94..fe2a471e5f64 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -1915,6 +1915,7 @@ static int em28xx_hint_board(struct em28xx *dev)
1915void em28xx_register_i2c_ir(struct em28xx *dev) 1915void em28xx_register_i2c_ir(struct em28xx *dev)
1916{ 1916{
1917 struct i2c_board_info info; 1917 struct i2c_board_info info;
1918 struct IR_i2c_init_data init_data;
1918 const unsigned short addr_list[] = { 1919 const unsigned short addr_list[] = {
1919 0x30, 0x47, I2C_CLIENT_END 1920 0x30, 0x47, I2C_CLIENT_END
1920 }; 1921 };
@@ -1923,12 +1924,9 @@ void em28xx_register_i2c_ir(struct em28xx *dev)
1923 return; 1924 return;
1924 1925
1925 memset(&info, 0, sizeof(struct i2c_board_info)); 1926 memset(&info, 0, sizeof(struct i2c_board_info));
1927 memset(&init_data, 0, sizeof(struct IR_i2c_init_data));
1926 strlcpy(info.type, "ir_video", I2C_NAME_SIZE); 1928 strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
1927 i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
1928}
1929 1929
1930void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
1931{
1932 /* detect & configure */ 1930 /* detect & configure */
1933 switch (dev->model) { 1931 switch (dev->model) {
1934 case (EM2800_BOARD_UNKNOWN): 1932 case (EM2800_BOARD_UNKNOWN):
@@ -1937,22 +1935,19 @@ void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
1937 break; 1935 break;
1938 case (EM2800_BOARD_TERRATEC_CINERGY_200): 1936 case (EM2800_BOARD_TERRATEC_CINERGY_200):
1939 case (EM2820_BOARD_TERRATEC_CINERGY_250): 1937 case (EM2820_BOARD_TERRATEC_CINERGY_250):
1940 ir->ir_codes = ir_codes_em_terratec; 1938 init_data.ir_codes = ir_codes_em_terratec;
1941 ir->get_key = em28xx_get_key_terratec; 1939 init_data.get_key = em28xx_get_key_terratec;
1942 snprintf(ir->name, sizeof(ir->name), 1940 init_data.name = "i2c IR (EM28XX Terratec)";
1943 "i2c IR (EM28XX Terratec)");
1944 break; 1941 break;
1945 case (EM2820_BOARD_PINNACLE_USB_2): 1942 case (EM2820_BOARD_PINNACLE_USB_2):
1946 ir->ir_codes = ir_codes_pinnacle_grey; 1943 init_data.ir_codes = ir_codes_pinnacle_grey;
1947 ir->get_key = em28xx_get_key_pinnacle_usb_grey; 1944 init_data.get_key = em28xx_get_key_pinnacle_usb_grey;
1948 snprintf(ir->name, sizeof(ir->name), 1945 init_data.name = "i2c IR (EM28XX Pinnacle PCTV)";
1949 "i2c IR (EM28XX Pinnacle PCTV)");
1950 break; 1946 break;
1951 case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2): 1947 case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2):
1952 ir->ir_codes = ir_codes_hauppauge_new; 1948 init_data.ir_codes = ir_codes_hauppauge_new;
1953 ir->get_key = em28xx_get_key_em_haup; 1949 init_data.get_key = em28xx_get_key_em_haup;
1954 snprintf(ir->name, sizeof(ir->name), 1950 init_data.name = "i2c IR (EM2840 Hauppauge)";
1955 "i2c IR (EM2840 Hauppauge)");
1956 break; 1951 break;
1957 case (EM2820_BOARD_MSI_VOX_USB_2): 1952 case (EM2820_BOARD_MSI_VOX_USB_2):
1958 break; 1953 break;
@@ -1963,6 +1958,10 @@ void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
1963 case (EM2800_BOARD_GRABBEEX_USB2800): 1958 case (EM2800_BOARD_GRABBEEX_USB2800):
1964 break; 1959 break;
1965 } 1960 }
1961
1962 if (init_data.name)
1963 info.platform_data = &init_data;
1964 i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
1966} 1965}
1967 1966
1968void em28xx_card_setup(struct em28xx *dev) 1967void em28xx_card_setup(struct em28xx *dev)
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index d90294cbb70d..2c86fcf089f5 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -451,27 +451,6 @@ static u32 functionality(struct i2c_adapter *adap)
451 return I2C_FUNC_SMBUS_EMUL; 451 return I2C_FUNC_SMBUS_EMUL;
452} 452}
453 453
454/*
455 * attach_inform()
456 * gets called when a device attaches to the i2c bus
457 * does some basic configuration
458 */
459static int attach_inform(struct i2c_client *client)
460{
461 struct em28xx *dev = client->adapter->algo_data;
462 struct IR_i2c *ir = i2c_get_clientdata(client);
463
464 switch (client->addr << 1) {
465 case 0x60:
466 case 0x8e:
467 dprintk1(1, "attach_inform: IR detected (%s).\n", ir->phys);
468 em28xx_set_ir(dev, ir);
469 break;
470 }
471
472 return 0;
473}
474
475static struct i2c_algorithm em28xx_algo = { 454static struct i2c_algorithm em28xx_algo = {
476 .master_xfer = em28xx_i2c_xfer, 455 .master_xfer = em28xx_i2c_xfer,
477 .functionality = functionality, 456 .functionality = functionality,
@@ -482,7 +461,6 @@ static struct i2c_adapter em28xx_adap_template = {
482 .name = "em28xx", 461 .name = "em28xx",
483 .id = I2C_HW_B_EM28XX, 462 .id = I2C_HW_B_EM28XX,
484 .algo = &em28xx_algo, 463 .algo = &em28xx_algo,
485 .client_register = attach_inform,
486}; 464};
487 465
488static struct i2c_client em28xx_client_template = { 466static struct i2c_client em28xx_client_template = {
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 9c632541df10..8db797fedb7e 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -644,7 +644,6 @@ extern struct em28xx_board em28xx_boards[];
644extern struct usb_device_id em28xx_id_table[]; 644extern struct usb_device_id em28xx_id_table[];
645extern const unsigned int em28xx_bcount; 645extern const unsigned int em28xx_bcount;
646void em28xx_register_i2c_ir(struct em28xx *dev); 646void em28xx_register_i2c_ir(struct em28xx *dev);
647void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir);
648int em28xx_tuner_callback(void *ptr, int component, int command, int arg); 647int em28xx_tuner_callback(void *ptr, int component, int command, int arg);
649void em28xx_release_resources(struct em28xx *dev); 648void em28xx_release_resources(struct em28xx *dev);
650 649