Skip to content

Commit ab5222e

Browse files
seanyoungmchehab
authored andcommitted
media: merge ir_tx_z8f0811_haup and ir_rx_z8f0811_haup i2c devices
These two devices ids are really just one device with multiple addresses. Probing becomes much simpler if we simply fold this into one i2c device with two address. Note that this breaks the lirc_zilog driver, however we will teach ir-kbd-i2c to do what lirc_zilog does in a later commit. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
1 parent a6927d8 commit ab5222e

File tree

9 files changed

+30
-87
lines changed

9 files changed

+30
-87
lines changed

drivers/media/i2c/ir-kbd-i2c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,8 @@ static const struct i2c_device_id ir_kbd_id[] = {
501501
/* Generic entry for any IR receiver */
502502
{ "ir_video", 0 },
503503
/* IR device specific entries should be added here */
504-
{ "ir_rx_z8f0811_haup", 0 },
505-
{ "ir_rx_z8f0811_hdpvr", 0 },
504+
{ "ir_z8f0811_haup", 0 },
505+
{ "ir_z8f0811_hdpvr", 0 },
506506
{ }
507507
};
508508

drivers/media/pci/cx18/cx18-cards.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,7 @@
2525
#define CX18_HW_418_AV (1 << 4)
2626
#define CX18_HW_GPIO_MUX (1 << 5)
2727
#define CX18_HW_GPIO_RESET_CTRL (1 << 6)
28-
#define CX18_HW_Z8F0811_IR_TX_HAUP (1 << 7)
29-
#define CX18_HW_Z8F0811_IR_RX_HAUP (1 << 8)
30-
#define CX18_HW_Z8F0811_IR_HAUP (CX18_HW_Z8F0811_IR_RX_HAUP | \
31-
CX18_HW_Z8F0811_IR_TX_HAUP)
32-
33-
#define CX18_HW_IR_ANY (CX18_HW_Z8F0811_IR_RX_HAUP | \
34-
CX18_HW_Z8F0811_IR_TX_HAUP)
28+
#define CX18_HW_Z8F0811_IR_HAUP (1 << 7)
3529

3630
/* video inputs */
3731
#define CX18_CARD_INPUT_VID_TUNER 1

drivers/media/pci/cx18/cx18-i2c.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ static const u8 hw_addrs[] = {
4747
0, /* CX18_HW_418_AV */
4848
0, /* CX18_HW_GPIO_MUX */
4949
0, /* CX18_HW_GPIO_RESET_CTRL */
50-
CX18_Z8F0811_IR_TX_I2C_ADDR, /* CX18_HW_Z8F0811_IR_TX_HAUP */
51-
CX18_Z8F0811_IR_RX_I2C_ADDR, /* CX18_HW_Z8F0811_IR_RX_HAUP */
50+
CX18_Z8F0811_IR_RX_I2C_ADDR, /* CX18_HW_Z8F0811_IR_HAUP */
5251
};
5352

5453
/* This array should match the CX18_HW_ defines */
@@ -61,8 +60,7 @@ static const u8 hw_bus[] = {
6160
0, /* CX18_HW_418_AV */
6261
0, /* CX18_HW_GPIO_MUX */
6362
0, /* CX18_HW_GPIO_RESET_CTRL */
64-
0, /* CX18_HW_Z8F0811_IR_TX_HAUP */
65-
0, /* CX18_HW_Z8F0811_IR_RX_HAUP */
63+
0, /* CX18_HW_Z8F0811_IR_HAUP */
6664
};
6765

6866
/* This array should match the CX18_HW_ defines */
@@ -74,8 +72,7 @@ static const char * const hw_devicenames[] = {
7472
"cx23418_AV",
7573
"gpio_mux",
7674
"gpio_reset_ctrl",
77-
"ir_tx_z8f0811_haup",
78-
"ir_rx_z8f0811_haup",
75+
"ir_z8f0811_haup",
7976
};
8077

8178
static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw,
@@ -90,7 +87,7 @@ static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw,
9087

9188
/* Our default information for ir-kbd-i2c.c to use */
9289
switch (hw) {
93-
case CX18_HW_Z8F0811_IR_RX_HAUP:
90+
case CX18_HW_Z8F0811_IR_HAUP:
9491
init_data->ir_codes = RC_MAP_HAUPPAUGE;
9592
init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
9693
init_data->type = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC6_MCE |
@@ -129,7 +126,7 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx)
129126
return sd != NULL ? 0 : -1;
130127
}
131128

132-
if (hw & CX18_HW_IR_ANY)
129+
if (hw == CX18_HW_Z8F0811_IR_HAUP)
133130
return cx18_i2c_new_ir(cx, adap, hw, type, hw_addrs[idx]);
134131

135132
/* Is it not an I2C device or one we do not wish to register? */

drivers/media/pci/ivtv/ivtv-cards.h

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,16 @@
109109
#define IVTV_HW_I2C_IR_RX_AVER (1 << 16)
110110
#define IVTV_HW_I2C_IR_RX_HAUP_EXT (1 << 17) /* External before internal */
111111
#define IVTV_HW_I2C_IR_RX_HAUP_INT (1 << 18)
112-
#define IVTV_HW_Z8F0811_IR_TX_HAUP (1 << 19)
113-
#define IVTV_HW_Z8F0811_IR_RX_HAUP (1 << 20)
114-
#define IVTV_HW_I2C_IR_RX_ADAPTEC (1 << 21)
115-
116-
#define IVTV_HW_Z8F0811_IR_HAUP (IVTV_HW_Z8F0811_IR_RX_HAUP | \
117-
IVTV_HW_Z8F0811_IR_TX_HAUP)
112+
#define IVTV_HW_Z8F0811_IR_HAUP (1 << 19)
113+
#define IVTV_HW_I2C_IR_RX_ADAPTEC (1 << 20)
118114

119115
#define IVTV_HW_SAA711X (IVTV_HW_SAA7115 | IVTV_HW_SAA7114)
120116

121-
#define IVTV_HW_IR_RX_ANY (IVTV_HW_I2C_IR_RX_AVER | \
122-
IVTV_HW_I2C_IR_RX_HAUP_EXT | \
123-
IVTV_HW_I2C_IR_RX_HAUP_INT | \
124-
IVTV_HW_Z8F0811_IR_RX_HAUP | \
125-
IVTV_HW_I2C_IR_RX_ADAPTEC)
126-
127-
#define IVTV_HW_IR_TX_ANY (IVTV_HW_Z8F0811_IR_TX_HAUP)
128-
129-
#define IVTV_HW_IR_ANY (IVTV_HW_IR_RX_ANY | IVTV_HW_IR_TX_ANY)
117+
#define IVTV_HW_IR_ANY (IVTV_HW_I2C_IR_RX_AVER | \
118+
IVTV_HW_I2C_IR_RX_HAUP_EXT | \
119+
IVTV_HW_I2C_IR_RX_HAUP_INT | \
120+
IVTV_HW_Z8F0811_IR_HAUP | \
121+
IVTV_HW_I2C_IR_RX_ADAPTEC)
130122

131123
/* video inputs */
132124
#define IVTV_CARD_INPUT_VID_TUNER 1

drivers/media/pci/ivtv/ivtv-i2c.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ static const u8 hw_addrs[] = {
117117
IVTV_AVERMEDIA_IR_RX_I2C_ADDR, /* IVTV_HW_I2C_IR_RX_AVER */
118118
IVTV_HAUP_EXT_IR_RX_I2C_ADDR, /* IVTV_HW_I2C_IR_RX_HAUP_EXT */
119119
IVTV_HAUP_INT_IR_RX_I2C_ADDR, /* IVTV_HW_I2C_IR_RX_HAUP_INT */
120-
IVTV_Z8F0811_IR_TX_I2C_ADDR, /* IVTV_HW_Z8F0811_IR_TX_HAUP */
121-
IVTV_Z8F0811_IR_RX_I2C_ADDR, /* IVTV_HW_Z8F0811_IR_RX_HAUP */
120+
IVTV_Z8F0811_IR_RX_I2C_ADDR, /* IVTV_HW_Z8F0811_IR_HAUP */
122121
IVTV_ADAPTEC_IR_ADDR, /* IVTV_HW_I2C_IR_RX_ADAPTEC */
123122
};
124123

@@ -143,8 +142,7 @@ static const char * const hw_devicenames[] = {
143142
"ir_video", /* IVTV_HW_I2C_IR_RX_AVER */
144143
"ir_video", /* IVTV_HW_I2C_IR_RX_HAUP_EXT */
145144
"ir_video", /* IVTV_HW_I2C_IR_RX_HAUP_INT */
146-
"ir_tx_z8f0811_haup", /* IVTV_HW_Z8F0811_IR_TX_HAUP */
147-
"ir_rx_z8f0811_haup", /* IVTV_HW_Z8F0811_IR_RX_HAUP */
145+
"ir_z8f0811_haup", /* IVTV_HW_Z8F0811_IR_HAUP */
148146
"ir_video", /* IVTV_HW_I2C_IR_RX_ADAPTEC */
149147
};
150148

@@ -181,18 +179,8 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
181179
struct IR_i2c_init_data *init_data = &itv->ir_i2c_init_data;
182180
unsigned short addr_list[2] = { addr, I2C_CLIENT_END };
183181

184-
/* Only allow one IR transmitter to be registered per board */
185-
if (hw & IVTV_HW_IR_TX_ANY) {
186-
if (itv->hw_flags & IVTV_HW_IR_TX_ANY)
187-
return -1;
188-
memset(&info, 0, sizeof(struct i2c_board_info));
189-
strlcpy(info.type, type, I2C_NAME_SIZE);
190-
return i2c_new_probed_device(adap, &info, addr_list, NULL)
191-
== NULL ? -1 : 0;
192-
}
193-
194182
/* Only allow one IR receiver to be registered per board */
195-
if (itv->hw_flags & IVTV_HW_IR_RX_ANY)
183+
if (itv->hw_flags & IVTV_HW_IR_ANY)
196184
return -1;
197185

198186
/* Our default information for ir-kbd-i2c.c to use */
@@ -211,7 +199,7 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
211199
init_data->type = RC_PROTO_BIT_RC5;
212200
init_data->name = itv->card_name;
213201
break;
214-
case IVTV_HW_Z8F0811_IR_RX_HAUP:
202+
case IVTV_HW_Z8F0811_IR_HAUP:
215203
/* Default to grey remote */
216204
init_data->ir_codes = RC_MAP_HAUPPAUGE;
217205
init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;

drivers/media/usb/hdpvr/hdpvr-core.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,9 @@ static int hdpvr_probe(struct usb_interface *interface,
364364
goto error_free_buffers;
365365
}
366366

367-
client = hdpvr_register_ir_rx_i2c(dev);
367+
client = hdpvr_register_ir_i2c(dev);
368368
if (!client) {
369-
v4l2_err(&dev->v4l2_dev, "i2c IR RX device register failed\n");
370-
retval = -ENODEV;
371-
goto reg_fail;
372-
}
373-
374-
client = hdpvr_register_ir_tx_i2c(dev);
375-
if (!client) {
376-
v4l2_err(&dev->v4l2_dev, "i2c IR TX device register failed\n");
369+
v4l2_err(&dev->v4l2_dev, "i2c IR device register failed\n");
377370
retval = -ENODEV;
378371
goto reg_fail;
379372
}

drivers/media/usb/hdpvr/hdpvr-i2c.c

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,11 @@
3232
#define Z8F0811_IR_RX_I2C_ADDR 0x71
3333

3434

35-
struct i2c_client *hdpvr_register_ir_tx_i2c(struct hdpvr_device *dev)
35+
struct i2c_client *hdpvr_register_ir_i2c(struct hdpvr_device *dev)
3636
{
3737
struct IR_i2c_init_data *init_data = &dev->ir_i2c_init_data;
38-
struct i2c_board_info hdpvr_ir_tx_i2c_board_info = {
39-
I2C_BOARD_INFO("ir_tx_z8f0811_hdpvr", Z8F0811_IR_TX_I2C_ADDR),
40-
};
41-
42-
init_data->name = "HD-PVR";
43-
hdpvr_ir_tx_i2c_board_info.platform_data = init_data;
44-
45-
return i2c_new_device(&dev->i2c_adapter, &hdpvr_ir_tx_i2c_board_info);
46-
}
47-
48-
struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev)
49-
{
50-
struct IR_i2c_init_data *init_data = &dev->ir_i2c_init_data;
51-
struct i2c_board_info hdpvr_ir_rx_i2c_board_info = {
52-
I2C_BOARD_INFO("ir_rx_z8f0811_hdpvr", Z8F0811_IR_RX_I2C_ADDR),
38+
struct i2c_board_info info = {
39+
I2C_BOARD_INFO("ir_z8f0811_hdpvr", Z8F0811_IR_RX_I2C_ADDR),
5340
};
5441

5542
/* Our default information for ir-kbd-i2c.c to use */
@@ -59,9 +46,9 @@ struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev)
5946
RC_PROTO_BIT_RC6_6A_32;
6047
init_data->name = "HD-PVR";
6148
init_data->polling_interval = 405; /* ms, duplicated from Windows */
62-
hdpvr_ir_rx_i2c_board_info.platform_data = init_data;
49+
info.platform_data = init_data;
6350

64-
return i2c_new_device(&dev->i2c_adapter, &hdpvr_ir_rx_i2c_board_info);
51+
return i2c_new_device(&dev->i2c_adapter, &info);
6552
}
6653

6754
static int hdpvr_i2c_read(struct hdpvr_device *dev, int bus,

drivers/media/usb/hdpvr/hdpvr.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ int hdpvr_cancel_queue(struct hdpvr_device *dev);
320320
/* i2c adapter registration */
321321
int hdpvr_register_i2c_adapter(struct hdpvr_device *dev);
322322

323-
struct i2c_client *hdpvr_register_ir_rx_i2c(struct hdpvr_device *dev);
324-
struct i2c_client *hdpvr_register_ir_tx_i2c(struct hdpvr_device *dev);
323+
struct i2c_client *hdpvr_register_ir_i2c(struct hdpvr_device *dev);
325324

326325
/*========================================================================*/
327326
/* buffer management */

drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -585,17 +585,10 @@ static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw)
585585
init_data->type = RC_PROTO_BIT_RC5 | RC_PROTO_BIT_RC6_MCE |
586586
RC_PROTO_BIT_RC6_6A_32;
587587
init_data->name = hdw->hdw_desc->description;
588-
/* IR Receiver */
589-
info.addr = 0x71;
590-
info.platform_data = init_data;
591-
strlcpy(info.type, "ir_rx_z8f0811_haup", I2C_NAME_SIZE);
592-
pvr2_trace(PVR2_TRACE_INFO, "Binding %s to i2c address 0x%02x.",
593-
info.type, info.addr);
594-
i2c_new_device(&hdw->i2c_adap, &info);
595-
/* IR Trasmitter */
596-
info.addr = 0x70;
588+
/* IR Transceiver */
589+
info.addr = 0x71;
597590
info.platform_data = init_data;
598-
strlcpy(info.type, "ir_tx_z8f0811_haup", I2C_NAME_SIZE);
591+
strlcpy(info.type, "ir_z8f0811_haup", I2C_NAME_SIZE);
599592
pvr2_trace(PVR2_TRACE_INFO, "Binding %s to i2c address 0x%02x.",
600593
info.type, info.addr);
601594
i2c_new_device(&hdw->i2c_adap, &info);

0 commit comments

Comments
 (0)