diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-22 10:50:37 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-22 18:05:37 -0400 |
commit | 37dbd3a64ed6dd62ab5a49dbfcfae7e8ac0413a9 (patch) | |
tree | 7329dbbedfb18c4d5b7770a5fd5507388229d8d4 /drivers/media | |
parent | 39dc5c3adf65bf86115aeccd740993256e6a22d4 (diff) |
[media] mceusb: add a per-model structure
The previous logic needed duplicate USB table structs, one to store
the list of the devices, and 3 sets of other structs, to store the
quirks list.
With this change, devices that require expecial quirks just need to
have a .driver_info = <quirk entry>.
It also allows adding some extra quirks, like per-model RC tables.
As a bonus, this patch reduced in 10% the data segment size:
text data bss dec hex filename
15487 5008 4 20499 5013 old/mceusb.ko
15438 4496 4 19938 4de2 new/mceusb.ko
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/IR/mceusb.c | 126 |
1 files changed, 76 insertions, 50 deletions
diff --git a/drivers/media/IR/mceusb.c b/drivers/media/IR/mceusb.c index c890cd521b20..712f93f26093 100644 --- a/drivers/media/IR/mceusb.c +++ b/drivers/media/IR/mceusb.c | |||
@@ -108,13 +108,57 @@ static int debug; | |||
108 | #define VENDOR_TIVO 0x105a | 108 | #define VENDOR_TIVO 0x105a |
109 | #define VENDOR_CONEXANT 0x0572 | 109 | #define VENDOR_CONEXANT 0x0572 |
110 | 110 | ||
111 | enum mceusb_model_type { | ||
112 | MCE_GEN2 = 0, /* Most boards */ | ||
113 | MCE_GEN1, | ||
114 | MCE_GEN3, | ||
115 | MCE_GEN2_TX_INV, | ||
116 | POLARIS_EVK, | ||
117 | }; | ||
118 | |||
119 | struct mceusb_model { | ||
120 | u32 mce_gen1:1; | ||
121 | u32 mce_gen2:1; | ||
122 | u32 mce_gen3:1; | ||
123 | u32 tx_mask_inverted:1; | ||
124 | u32 is_polaris:1; | ||
125 | |||
126 | /* | ||
127 | * Allow specify a per-board extra data, like | ||
128 | * device names, and per-device rc_maps | ||
129 | */ | ||
130 | }; | ||
131 | |||
132 | static const struct mceusb_model mceusb_model[] = { | ||
133 | [MCE_GEN1] = { | ||
134 | .mce_gen1 = 1, | ||
135 | .tx_mask_inverted = 1, | ||
136 | }, | ||
137 | [MCE_GEN2] = { | ||
138 | .mce_gen2 = 1, | ||
139 | }, | ||
140 | [MCE_GEN2_TX_INV] = { | ||
141 | .mce_gen2 = 1, | ||
142 | .tx_mask_inverted = 1, | ||
143 | }, | ||
144 | [MCE_GEN3] = { | ||
145 | .mce_gen3 = 1, | ||
146 | .tx_mask_inverted = 1, | ||
147 | }, | ||
148 | [POLARIS_EVK] = { | ||
149 | .is_polaris = 1, | ||
150 | }, | ||
151 | }; | ||
152 | |||
111 | static struct usb_device_id mceusb_dev_table[] = { | 153 | static struct usb_device_id mceusb_dev_table[] = { |
112 | /* Original Microsoft MCE IR Transceiver (often HP-branded) */ | 154 | /* Original Microsoft MCE IR Transceiver (often HP-branded) */ |
113 | { USB_DEVICE(VENDOR_MICROSOFT, 0x006d) }, | 155 | { USB_DEVICE(VENDOR_MICROSOFT, 0x006d), |
156 | .driver_info = MCE_GEN1 }, | ||
114 | /* Philips Infrared Transceiver - Sahara branded */ | 157 | /* Philips Infrared Transceiver - Sahara branded */ |
115 | { USB_DEVICE(VENDOR_PHILIPS, 0x0608) }, | 158 | { USB_DEVICE(VENDOR_PHILIPS, 0x0608) }, |
116 | /* Philips Infrared Transceiver - HP branded */ | 159 | /* Philips Infrared Transceiver - HP branded */ |
117 | { USB_DEVICE(VENDOR_PHILIPS, 0x060c) }, | 160 | { USB_DEVICE(VENDOR_PHILIPS, 0x060c), |
161 | .driver_info = MCE_GEN2_TX_INV }, | ||
118 | /* Philips SRM5100 */ | 162 | /* Philips SRM5100 */ |
119 | { USB_DEVICE(VENDOR_PHILIPS, 0x060d) }, | 163 | { USB_DEVICE(VENDOR_PHILIPS, 0x060d) }, |
120 | /* Philips Infrared Transceiver - Omaura */ | 164 | /* Philips Infrared Transceiver - Omaura */ |
@@ -130,11 +174,14 @@ static struct usb_device_id mceusb_dev_table[] = { | |||
130 | /* Realtek MCE IR Receiver */ | 174 | /* Realtek MCE IR Receiver */ |
131 | { USB_DEVICE(VENDOR_REALTEK, 0x0161) }, | 175 | { USB_DEVICE(VENDOR_REALTEK, 0x0161) }, |
132 | /* SMK/Toshiba G83C0004D410 */ | 176 | /* SMK/Toshiba G83C0004D410 */ |
133 | { USB_DEVICE(VENDOR_SMK, 0x031d) }, | 177 | { USB_DEVICE(VENDOR_SMK, 0x031d), |
178 | .driver_info = MCE_GEN2_TX_INV }, | ||
134 | /* SMK eHome Infrared Transceiver (Sony VAIO) */ | 179 | /* SMK eHome Infrared Transceiver (Sony VAIO) */ |
135 | { USB_DEVICE(VENDOR_SMK, 0x0322) }, | 180 | { USB_DEVICE(VENDOR_SMK, 0x0322), |
181 | .driver_info = MCE_GEN2_TX_INV }, | ||
136 | /* bundled with Hauppauge PVR-150 */ | 182 | /* bundled with Hauppauge PVR-150 */ |
137 | { USB_DEVICE(VENDOR_SMK, 0x0334) }, | 183 | { USB_DEVICE(VENDOR_SMK, 0x0334), |
184 | .driver_info = MCE_GEN2_TX_INV }, | ||
138 | /* SMK eHome Infrared Transceiver */ | 185 | /* SMK eHome Infrared Transceiver */ |
139 | { USB_DEVICE(VENDOR_SMK, 0x0338) }, | 186 | { USB_DEVICE(VENDOR_SMK, 0x0338) }, |
140 | /* Tatung eHome Infrared Transceiver */ | 187 | /* Tatung eHome Infrared Transceiver */ |
@@ -148,17 +195,23 @@ static struct usb_device_id mceusb_dev_table[] = { | |||
148 | /* Mitsumi */ | 195 | /* Mitsumi */ |
149 | { USB_DEVICE(VENDOR_MITSUMI, 0x2501) }, | 196 | { USB_DEVICE(VENDOR_MITSUMI, 0x2501) }, |
150 | /* Topseed eHome Infrared Transceiver */ | 197 | /* Topseed eHome Infrared Transceiver */ |
151 | { USB_DEVICE(VENDOR_TOPSEED, 0x0001) }, | 198 | { USB_DEVICE(VENDOR_TOPSEED, 0x0001), |
199 | .driver_info = MCE_GEN2_TX_INV }, | ||
152 | /* Topseed HP eHome Infrared Transceiver */ | 200 | /* Topseed HP eHome Infrared Transceiver */ |
153 | { USB_DEVICE(VENDOR_TOPSEED, 0x0006) }, | 201 | { USB_DEVICE(VENDOR_TOPSEED, 0x0006), |
202 | .driver_info = MCE_GEN2_TX_INV }, | ||
154 | /* Topseed eHome Infrared Transceiver */ | 203 | /* Topseed eHome Infrared Transceiver */ |
155 | { USB_DEVICE(VENDOR_TOPSEED, 0x0007) }, | 204 | { USB_DEVICE(VENDOR_TOPSEED, 0x0007), |
205 | .driver_info = MCE_GEN2_TX_INV }, | ||
156 | /* Topseed eHome Infrared Transceiver */ | 206 | /* Topseed eHome Infrared Transceiver */ |
157 | { USB_DEVICE(VENDOR_TOPSEED, 0x0008) }, | 207 | { USB_DEVICE(VENDOR_TOPSEED, 0x0008), |
208 | .driver_info = MCE_GEN3 }, | ||
158 | /* Topseed eHome Infrared Transceiver */ | 209 | /* Topseed eHome Infrared Transceiver */ |
159 | { USB_DEVICE(VENDOR_TOPSEED, 0x000a) }, | 210 | { USB_DEVICE(VENDOR_TOPSEED, 0x000a), |
211 | .driver_info = MCE_GEN2_TX_INV }, | ||
160 | /* Topseed eHome Infrared Transceiver */ | 212 | /* Topseed eHome Infrared Transceiver */ |
161 | { USB_DEVICE(VENDOR_TOPSEED, 0x0011) }, | 213 | { USB_DEVICE(VENDOR_TOPSEED, 0x0011), |
214 | .driver_info = MCE_GEN2_TX_INV }, | ||
162 | /* Ricavision internal Infrared Transceiver */ | 215 | /* Ricavision internal Infrared Transceiver */ |
163 | { USB_DEVICE(VENDOR_RICAVISION, 0x0010) }, | 216 | { USB_DEVICE(VENDOR_RICAVISION, 0x0010) }, |
164 | /* Itron ione Libra Q-11 */ | 217 | /* Itron ione Libra Q-11 */ |
@@ -188,7 +241,8 @@ static struct usb_device_id mceusb_dev_table[] = { | |||
188 | /* Fintek eHome Infrared Transceiver (in the AOpen MP45) */ | 241 | /* Fintek eHome Infrared Transceiver (in the AOpen MP45) */ |
189 | { USB_DEVICE(VENDOR_FINTEK, 0x0702) }, | 242 | { USB_DEVICE(VENDOR_FINTEK, 0x0702) }, |
190 | /* Pinnacle Remote Kit */ | 243 | /* Pinnacle Remote Kit */ |
191 | { USB_DEVICE(VENDOR_PINNACLE, 0x0225) }, | 244 | { USB_DEVICE(VENDOR_PINNACLE, 0x0225), |
245 | .driver_info = MCE_GEN3 }, | ||
192 | /* Elitegroup Computer Systems IR */ | 246 | /* Elitegroup Computer Systems IR */ |
193 | { USB_DEVICE(VENDOR_ECS, 0x0f38) }, | 247 | { USB_DEVICE(VENDOR_ECS, 0x0f38) }, |
194 | /* Wistron Corp. eHome Infrared Receiver */ | 248 | /* Wistron Corp. eHome Infrared Receiver */ |
@@ -202,43 +256,12 @@ static struct usb_device_id mceusb_dev_table[] = { | |||
202 | /* TiVo PC IR Receiver */ | 256 | /* TiVo PC IR Receiver */ |
203 | { USB_DEVICE(VENDOR_TIVO, 0x2000) }, | 257 | { USB_DEVICE(VENDOR_TIVO, 0x2000) }, |
204 | /* Conexant SDK */ | 258 | /* Conexant SDK */ |
205 | { USB_DEVICE(VENDOR_CONEXANT, 0x58a1) }, | 259 | { USB_DEVICE(VENDOR_CONEXANT, 0x58a1), |
260 | .driver_info = POLARIS_EVK }, | ||
206 | /* Terminating entry */ | 261 | /* Terminating entry */ |
207 | { } | 262 | { } |
208 | }; | 263 | }; |
209 | 264 | ||
210 | static struct usb_device_id gen3_list[] = { | ||
211 | { USB_DEVICE(VENDOR_PINNACLE, 0x0225) }, | ||
212 | { USB_DEVICE(VENDOR_TOPSEED, 0x0008) }, | ||
213 | {} | ||
214 | }; | ||
215 | |||
216 | static struct usb_device_id microsoft_gen1_list[] = { | ||
217 | { USB_DEVICE(VENDOR_MICROSOFT, 0x006d) }, | ||
218 | {} | ||
219 | }; | ||
220 | |||
221 | static struct usb_device_id std_tx_mask_list[] = { | ||
222 | { USB_DEVICE(VENDOR_MICROSOFT, 0x006d) }, | ||
223 | { USB_DEVICE(VENDOR_PHILIPS, 0x060c) }, | ||
224 | { USB_DEVICE(VENDOR_SMK, 0x031d) }, | ||
225 | { USB_DEVICE(VENDOR_SMK, 0x0322) }, | ||
226 | { USB_DEVICE(VENDOR_SMK, 0x0334) }, | ||
227 | { USB_DEVICE(VENDOR_TOPSEED, 0x0001) }, | ||
228 | { USB_DEVICE(VENDOR_TOPSEED, 0x0006) }, | ||
229 | { USB_DEVICE(VENDOR_TOPSEED, 0x0007) }, | ||
230 | { USB_DEVICE(VENDOR_TOPSEED, 0x0008) }, | ||
231 | { USB_DEVICE(VENDOR_TOPSEED, 0x000a) }, | ||
232 | { USB_DEVICE(VENDOR_TOPSEED, 0x0011) }, | ||
233 | { USB_DEVICE(VENDOR_PINNACLE, 0x0225) }, | ||
234 | {} | ||
235 | }; | ||
236 | |||
237 | static struct usb_device_id cx_polaris_list[] = { | ||
238 | { USB_DEVICE(VENDOR_CONEXANT, 0x58a1) }, | ||
239 | {} | ||
240 | }; | ||
241 | |||
242 | /* data structure for each usb transceiver */ | 265 | /* data structure for each usb transceiver */ |
243 | struct mceusb_dev { | 266 | struct mceusb_dev { |
244 | /* ir-core bits */ | 267 | /* ir-core bits */ |
@@ -274,7 +297,6 @@ struct mceusb_dev { | |||
274 | u32 connected:1; | 297 | u32 connected:1; |
275 | u32 tx_mask_inverted:1; | 298 | u32 tx_mask_inverted:1; |
276 | u32 microsoft_gen1:1; | 299 | u32 microsoft_gen1:1; |
277 | u32 reserved:29; | ||
278 | } flags; | 300 | } flags; |
279 | 301 | ||
280 | /* transmit support */ | 302 | /* transmit support */ |
@@ -284,6 +306,7 @@ struct mceusb_dev { | |||
284 | 306 | ||
285 | char name[128]; | 307 | char name[128]; |
286 | char phys[64]; | 308 | char phys[64]; |
309 | enum mceusb_model_type model; | ||
287 | }; | 310 | }; |
288 | 311 | ||
289 | /* | 312 | /* |
@@ -989,6 +1012,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, | |||
989 | struct mceusb_dev *ir = NULL; | 1012 | struct mceusb_dev *ir = NULL; |
990 | int pipe, maxp, i; | 1013 | int pipe, maxp, i; |
991 | char buf[63], name[128] = ""; | 1014 | char buf[63], name[128] = ""; |
1015 | enum mceusb_model_type model = id->driver_info; | ||
992 | bool is_gen3; | 1016 | bool is_gen3; |
993 | bool is_microsoft_gen1; | 1017 | bool is_microsoft_gen1; |
994 | bool tx_mask_inverted; | 1018 | bool tx_mask_inverted; |
@@ -998,10 +1022,10 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, | |||
998 | 1022 | ||
999 | idesc = intf->cur_altsetting; | 1023 | idesc = intf->cur_altsetting; |
1000 | 1024 | ||
1001 | is_gen3 = usb_match_id(intf, gen3_list) ? 1 : 0; | 1025 | is_gen3 = mceusb_model[model].mce_gen3; |
1002 | is_microsoft_gen1 = usb_match_id(intf, microsoft_gen1_list) ? 1 : 0; | 1026 | is_microsoft_gen1 = mceusb_model[model].mce_gen1; |
1003 | tx_mask_inverted = usb_match_id(intf, std_tx_mask_list) ? 0 : 1; | 1027 | tx_mask_inverted = mceusb_model[model].tx_mask_inverted; |
1004 | is_polaris = usb_match_id(intf, cx_polaris_list) ? 1 : 0; | 1028 | is_polaris = mceusb_model[model].is_polaris; |
1005 | 1029 | ||
1006 | if (is_polaris) { | 1030 | if (is_polaris) { |
1007 | /* Interface 0 is IR */ | 1031 | /* Interface 0 is IR */ |
@@ -1068,6 +1092,8 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, | |||
1068 | ir->len_in = maxp; | 1092 | ir->len_in = maxp; |
1069 | ir->flags.microsoft_gen1 = is_microsoft_gen1; | 1093 | ir->flags.microsoft_gen1 = is_microsoft_gen1; |
1070 | ir->flags.tx_mask_inverted = tx_mask_inverted; | 1094 | ir->flags.tx_mask_inverted = tx_mask_inverted; |
1095 | ir->model = model; | ||
1096 | |||
1071 | init_ir_raw_event(&ir->rawir); | 1097 | init_ir_raw_event(&ir->rawir); |
1072 | 1098 | ||
1073 | /* Saving usb interface data for use by the transmitter routine */ | 1099 | /* Saving usb interface data for use by the transmitter routine */ |