diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2008-06-18 21:09:55 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 06:22:27 -0400 |
commit | 1c11d546b6c31399ac60f42d3103227cc1164d80 (patch) | |
tree | 4998b2168547180e0cf2ed22b7d7279c485fe011 /drivers | |
parent | dd5b2a5c2a6c793d855910864593ad26dd844154 (diff) |
V4L/DVB (8292): sms1xxx: add code to allow device-specific functionality
Set board ID in the usb_device_id table's driver_info field.
Use board name when registering the dvb adapter.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/dvb/siano/Makefile | 2 | ||||
-rw-r--r-- | drivers/media/dvb/siano/sms-cards.c | 69 | ||||
-rw-r--r-- | drivers/media/dvb/siano/sms-cards.h | 42 | ||||
-rw-r--r-- | drivers/media/dvb/siano/smscoreapi.c | 12 | ||||
-rw-r--r-- | drivers/media/dvb/siano/smscoreapi.h | 3 | ||||
-rw-r--r-- | drivers/media/dvb/siano/smsdvb.c | 7 | ||||
-rw-r--r-- | drivers/media/dvb/siano/smsusb.c | 44 |
7 files changed, 150 insertions, 29 deletions
diff --git a/drivers/media/dvb/siano/Makefile b/drivers/media/dvb/siano/Makefile index e549c4e2bbe2..ee0737af98c0 100644 --- a/drivers/media/dvb/siano/Makefile +++ b/drivers/media/dvb/siano/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | sms1xxx-objs := smscoreapi.o smsusb.o smsdvb.o | 1 | sms1xxx-objs := smscoreapi.o smsusb.o smsdvb.o sms-cards.o |
2 | 2 | ||
3 | obj-$(CONFIG_DVB_SIANO_SMS1XXX) += sms1xxx.o | 3 | obj-$(CONFIG_DVB_SIANO_SMS1XXX) += sms1xxx.o |
4 | 4 | ||
diff --git a/drivers/media/dvb/siano/sms-cards.c b/drivers/media/dvb/siano/sms-cards.c new file mode 100644 index 000000000000..88fc2a4edc1e --- /dev/null +++ b/drivers/media/dvb/siano/sms-cards.c | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | * Card-specific functions for the Siano SMS1xxx USB dongle | ||
3 | * | ||
4 | * Copyright (c) 2008 Michael Krufky <mkrufky@linuxtv.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 3 as | ||
8 | * published by the Free Software Foundation; | ||
9 | * | ||
10 | * Software distributed under the License is distributed on an "AS IS" | ||
11 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | ||
12 | * | ||
13 | * See the GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
18 | */ | ||
19 | |||
20 | #include "sms-cards.h" | ||
21 | |||
22 | struct usb_device_id smsusb_id_table[] = { | ||
23 | { USB_DEVICE(0x187f, 0x0010), | ||
24 | .driver_info = SMS1XXX_BOARD_SIANO_STELLAR }, | ||
25 | { USB_DEVICE(0x187f, 0x0100), | ||
26 | .driver_info = SMS1XXX_BOARD_SIANO_STELLAR }, | ||
27 | { USB_DEVICE(0x187f, 0x0200), | ||
28 | .driver_info = SMS1XXX_BOARD_SIANO_NOVA_A }, | ||
29 | { USB_DEVICE(0x187f, 0x0201), | ||
30 | .driver_info = SMS1XXX_BOARD_SIANO_NOVA_B }, | ||
31 | { USB_DEVICE(0x187f, 0x0300), | ||
32 | .driver_info = SMS1XXX_BOARD_SIANO_VEGA }, | ||
33 | { } /* Terminating entry */ | ||
34 | }; | ||
35 | MODULE_DEVICE_TABLE(usb, smsusb_id_table); | ||
36 | |||
37 | static struct sms_board sms_boards[] = { | ||
38 | [SMS_BOARD_UNKNOWN] = { | ||
39 | .name = "Unknown board", | ||
40 | }, | ||
41 | [SMS1XXX_BOARD_SIANO_SMS1000] = { | ||
42 | .name = "Siano Digital Receiver", | ||
43 | .type = SMS_STELLAR, | ||
44 | }, | ||
45 | [SMS1XXX_BOARD_SIANO_STELLAR] = { | ||
46 | .name = "Siano Stellar reference board", | ||
47 | .type = SMS_STELLAR, | ||
48 | }, | ||
49 | [SMS1XXX_BOARD_SIANO_NOVA_A] = { | ||
50 | .name = "Siano Nova A reference board", | ||
51 | .type = SMS_NOVA_A0, | ||
52 | }, | ||
53 | [SMS1XXX_BOARD_SIANO_NOVA_B] = { | ||
54 | .name = "Siano Nova B reference board", | ||
55 | .type = SMS_NOVA_B0, | ||
56 | }, | ||
57 | [SMS1XXX_BOARD_SIANO_VEGA] = { | ||
58 | .name = "Siano Vega reference board", | ||
59 | .type = SMS_VEGA, | ||
60 | }, | ||
61 | }; | ||
62 | |||
63 | struct sms_board *sms_get_board(int id) | ||
64 | { | ||
65 | BUG_ON(id >= ARRAY_SIZE(sms_boards)); | ||
66 | |||
67 | return &sms_boards[id]; | ||
68 | } | ||
69 | |||
diff --git a/drivers/media/dvb/siano/sms-cards.h b/drivers/media/dvb/siano/sms-cards.h new file mode 100644 index 000000000000..7ba3df63dffe --- /dev/null +++ b/drivers/media/dvb/siano/sms-cards.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | * Card-specific functions for the Siano SMS1xxx USB dongle | ||
3 | * | ||
4 | * Copyright (c) 2008 Michael Krufky <mkrufky@linuxtv.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 3 as | ||
8 | * published by the Free Software Foundation; | ||
9 | * | ||
10 | * Software distributed under the License is distributed on an "AS IS" | ||
11 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | ||
12 | * | ||
13 | * See the GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
18 | */ | ||
19 | |||
20 | #ifndef __SMS_CARDS_H__ | ||
21 | #define __SMS_CARDS_H__ | ||
22 | |||
23 | #include <linux/usb.h> | ||
24 | #include "smscoreapi.h" | ||
25 | |||
26 | #define SMS_BOARD_UNKNOWN 0 | ||
27 | #define SMS1XXX_BOARD_SIANO_SMS1000 1 | ||
28 | #define SMS1XXX_BOARD_SIANO_STELLAR 2 | ||
29 | #define SMS1XXX_BOARD_SIANO_NOVA_A 3 | ||
30 | #define SMS1XXX_BOARD_SIANO_NOVA_B 4 | ||
31 | #define SMS1XXX_BOARD_SIANO_VEGA 5 | ||
32 | |||
33 | struct sms_board { | ||
34 | char *name; | ||
35 | enum sms_device_type_st type; | ||
36 | }; | ||
37 | |||
38 | struct sms_board *sms_get_board(int id); | ||
39 | |||
40 | extern struct usb_device_id smsusb_id_table[]; | ||
41 | |||
42 | #endif /* __SMS_CARDS_H__ */ | ||
diff --git a/drivers/media/dvb/siano/smscoreapi.c b/drivers/media/dvb/siano/smscoreapi.c index 32dbe2469639..a5a3cbf2ffd6 100644 --- a/drivers/media/dvb/siano/smscoreapi.c +++ b/drivers/media/dvb/siano/smscoreapi.c | |||
@@ -101,8 +101,20 @@ struct smscore_device_t { | |||
101 | 101 | ||
102 | struct completion version_ex_done, data_download_done, trigger_done; | 102 | struct completion version_ex_done, data_download_done, trigger_done; |
103 | struct completion init_device_done, reload_start_done, resume_done; | 103 | struct completion init_device_done, reload_start_done, resume_done; |
104 | |||
105 | int board_id; | ||
104 | }; | 106 | }; |
105 | 107 | ||
108 | void smscore_set_board_id(struct smscore_device_t *core, int id) | ||
109 | { | ||
110 | core->board_id = id; | ||
111 | } | ||
112 | |||
113 | int smscore_get_board_id(struct smscore_device_t *core) | ||
114 | { | ||
115 | return core->board_id; | ||
116 | } | ||
117 | |||
106 | struct smscore_registry_entry_t { | 118 | struct smscore_registry_entry_t { |
107 | struct list_head entry; | 119 | struct list_head entry; |
108 | char devpath[32]; | 120 | char devpath[32]; |
diff --git a/drivers/media/dvb/siano/smscoreapi.h b/drivers/media/dvb/siano/smscoreapi.h index 355c22b1d158..1962f016612b 100644 --- a/drivers/media/dvb/siano/smscoreapi.h +++ b/drivers/media/dvb/siano/smscoreapi.h | |||
@@ -403,6 +403,9 @@ extern struct smscore_buffer_t *smscore_getbuffer(struct smscore_device_t *cored | |||
403 | extern void smscore_putbuffer(struct smscore_device_t *coredev, | 403 | extern void smscore_putbuffer(struct smscore_device_t *coredev, |
404 | struct smscore_buffer_t *cb); | 404 | struct smscore_buffer_t *cb); |
405 | 405 | ||
406 | void smscore_set_board_id(struct smscore_device_t *core, int id); | ||
407 | int smscore_get_board_id(struct smscore_device_t *core); | ||
408 | |||
406 | /* smsdvb.c */ | 409 | /* smsdvb.c */ |
407 | int smsdvb_register(void); | 410 | int smsdvb_register(void); |
408 | void smsdvb_unregister(void); | 411 | void smsdvb_unregister(void); |
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c index b17696fcbbc6..88b2bd2821dc 100644 --- a/drivers/media/dvb/siano/smsdvb.c +++ b/drivers/media/dvb/siano/smsdvb.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | 24 | ||
25 | #include "smscoreapi.h" | 25 | #include "smscoreapi.h" |
26 | #include "sms-cards.h" | ||
26 | 27 | ||
27 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | 28 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
28 | 29 | ||
@@ -282,7 +283,7 @@ static void smsdvb_release(struct dvb_frontend *fe) | |||
282 | 283 | ||
283 | static struct dvb_frontend_ops smsdvb_fe_ops = { | 284 | static struct dvb_frontend_ops smsdvb_fe_ops = { |
284 | .info = { | 285 | .info = { |
285 | .name = "Siano Mobile Digital SMS10xx", | 286 | .name = "Siano Mobile Digital SMS1xxx", |
286 | .type = FE_OFDM, | 287 | .type = FE_OFDM, |
287 | .frequency_min = 44250000, | 288 | .frequency_min = 44250000, |
288 | .frequency_max = 867250000, | 289 | .frequency_max = 867250000, |
@@ -333,7 +334,9 @@ int smsdvb_hotplug(struct smscore_device_t *coredev, | |||
333 | } | 334 | } |
334 | 335 | ||
335 | /* register dvb adapter */ | 336 | /* register dvb adapter */ |
336 | rc = dvb_register_adapter(&client->adapter, "Siano Digital Receiver", | 337 | rc = dvb_register_adapter(&client->adapter, |
338 | sms_get_board( | ||
339 | smscore_get_board_id(coredev))->name, | ||
337 | THIS_MODULE, device, adapter_nr); | 340 | THIS_MODULE, device, adapter_nr); |
338 | if (rc < 0) { | 341 | if (rc < 0) { |
339 | printk(KERN_ERR "%s dvb_register_adapter() failed %d\n", | 342 | printk(KERN_ERR "%s dvb_register_adapter() failed %d\n", |
diff --git a/drivers/media/dvb/siano/smsusb.c b/drivers/media/dvb/siano/smsusb.c index 29183884d7ec..bb8a364477fb 100644 --- a/drivers/media/dvb/siano/smsusb.c +++ b/drivers/media/dvb/siano/smsusb.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/firmware.h> | 25 | #include <linux/firmware.h> |
26 | 26 | ||
27 | #include "smscoreapi.h" | 27 | #include "smscoreapi.h" |
28 | #include "sms-cards.h" | ||
28 | 29 | ||
29 | #define USB1_BUFFER_SIZE 0x1000 | 30 | #define USB1_BUFFER_SIZE 0x1000 |
30 | #define USB2_BUFFER_SIZE 0x4000 | 31 | #define USB2_BUFFER_SIZE 0x4000 |
@@ -32,14 +33,6 @@ | |||
32 | #define MAX_BUFFERS 50 | 33 | #define MAX_BUFFERS 50 |
33 | #define MAX_URBS 10 | 34 | #define MAX_URBS 10 |
34 | 35 | ||
35 | /* TO DO: move these to a header file */ | ||
36 | #define USB_VID_SIANO 0x187f | ||
37 | |||
38 | #define USB_PID_STELLAR 0x0100 | ||
39 | #define USB_PID_NOVA_A 0x0200 | ||
40 | #define USB_PID_NOVA_B 0x0201 | ||
41 | #define USB_PID_VEGA 0x0300 | ||
42 | |||
43 | struct smsusb_device_t; | 36 | struct smsusb_device_t; |
44 | 37 | ||
45 | struct smsusb_urb_t { | 38 | struct smsusb_urb_t { |
@@ -287,10 +280,11 @@ void smsusb_term_device(struct usb_interface *intf) | |||
287 | usb_set_intfdata(intf, NULL); | 280 | usb_set_intfdata(intf, NULL); |
288 | } | 281 | } |
289 | 282 | ||
290 | int smsusb_init_device(struct usb_interface *intf) | 283 | int smsusb_init_device(struct usb_interface *intf, int board_id) |
291 | { | 284 | { |
292 | struct smsdevice_params_t params; | 285 | struct smsdevice_params_t params; |
293 | struct smsusb_device_t *dev; | 286 | struct smsusb_device_t *dev; |
287 | struct sms_board *board; | ||
294 | int i, rc; | 288 | int i, rc; |
295 | 289 | ||
296 | /* create device object */ | 290 | /* create device object */ |
@@ -305,9 +299,11 @@ int smsusb_init_device(struct usb_interface *intf) | |||
305 | usb_set_intfdata(intf, dev); | 299 | usb_set_intfdata(intf, dev); |
306 | dev->udev = interface_to_usbdev(intf); | 300 | dev->udev = interface_to_usbdev(intf); |
307 | 301 | ||
308 | switch (dev->udev->descriptor.idProduct) { | 302 | board = sms_get_board(board_id); |
303 | |||
304 | switch (board->type) { | ||
309 | 305 | ||
310 | case USB_PID_STELLAR: | 306 | case SMS_STELLAR: |
311 | dev->buffer_size = USB1_BUFFER_SIZE; | 307 | dev->buffer_size = USB1_BUFFER_SIZE; |
312 | 308 | ||
313 | params.setmode_handler = smsusb1_setmode; | 309 | params.setmode_handler = smsusb1_setmode; |
@@ -316,19 +312,22 @@ int smsusb_init_device(struct usb_interface *intf) | |||
316 | printk(KERN_INFO "%s stellar device found\n", __func__); | 312 | printk(KERN_INFO "%s stellar device found\n", __func__); |
317 | break; | 313 | break; |
318 | default: | 314 | default: |
319 | switch (dev->udev->descriptor.idProduct) { | 315 | switch (board->type) { |
320 | case USB_PID_NOVA_A: | 316 | case SMS_NOVA_A0: |
321 | params.device_type = SMS_NOVA_A0; | 317 | params.device_type = SMS_NOVA_A0; |
322 | printk(KERN_INFO "%s nova A0 found\n", __func__); | 318 | printk(KERN_INFO "%s nova A0 found\n", __func__); |
323 | break; | 319 | break; |
324 | default: | 320 | case SMS_NOVA_B0: |
325 | case USB_PID_NOVA_B: | ||
326 | params.device_type = SMS_NOVA_B0; | 321 | params.device_type = SMS_NOVA_B0; |
327 | printk(KERN_INFO "%s nova B0 found\n", __func__); | 322 | printk(KERN_INFO "%s nova B0 found\n", __func__); |
328 | break; | 323 | break; |
329 | case USB_PID_VEGA: | 324 | case SMS_VEGA: |
330 | params.device_type = SMS_VEGA; | 325 | params.device_type = SMS_VEGA; |
331 | printk(KERN_INFO "%s Vega found\n", __func__); | 326 | printk(KERN_INFO "%s Vega found\n", __func__); |
327 | break; | ||
328 | default: | ||
329 | printk(KERN_ERR "%s Unspecified sms device type!\n", | ||
330 | __func__); | ||
332 | } | 331 | } |
333 | 332 | ||
334 | dev->buffer_size = USB2_BUFFER_SIZE; | 333 | dev->buffer_size = USB2_BUFFER_SIZE; |
@@ -357,6 +356,8 @@ int smsusb_init_device(struct usb_interface *intf) | |||
357 | return rc; | 356 | return rc; |
358 | } | 357 | } |
359 | 358 | ||
359 | smscore_set_board_id(dev->coredev, board_id); | ||
360 | |||
360 | /* initialize urbs */ | 361 | /* initialize urbs */ |
361 | for (i = 0; i < MAX_URBS; i++) { | 362 | for (i = 0; i < MAX_URBS; i++) { |
362 | dev->surbs[i].dev = dev; | 363 | dev->surbs[i].dev = dev; |
@@ -426,7 +427,7 @@ int smsusb_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
426 | udev, smscore_registry_getmode(devpath)); | 427 | udev, smscore_registry_getmode(devpath)); |
427 | } | 428 | } |
428 | 429 | ||
429 | rc = smsusb_init_device(intf); | 430 | rc = smsusb_init_device(intf, id->driver_info); |
430 | printk(KERN_INFO "%s rc %d\n", __func__, rc); | 431 | printk(KERN_INFO "%s rc %d\n", __func__, rc); |
431 | return rc; | 432 | return rc; |
432 | } | 433 | } |
@@ -436,15 +437,6 @@ void smsusb_disconnect(struct usb_interface *intf) | |||
436 | smsusb_term_device(intf); | 437 | smsusb_term_device(intf); |
437 | } | 438 | } |
438 | 439 | ||
439 | static struct usb_device_id smsusb_id_table [] = { | ||
440 | { USB_DEVICE(USB_VID_SIANO, USB_PID_STELLAR) }, | ||
441 | { USB_DEVICE(USB_VID_SIANO, USB_PID_NOVA_A) }, | ||
442 | { USB_DEVICE(USB_VID_SIANO, USB_PID_NOVA_B) }, | ||
443 | { USB_DEVICE(USB_VID_SIANO, USB_PID_VEGA) }, | ||
444 | { } /* Terminating entry */ | ||
445 | }; | ||
446 | MODULE_DEVICE_TABLE(usb, smsusb_id_table); | ||
447 | |||
448 | static struct usb_driver smsusb_driver = { | 440 | static struct usb_driver smsusb_driver = { |
449 | .name = "smsusb", | 441 | .name = "smsusb", |
450 | .probe = smsusb_probe, | 442 | .probe = smsusb_probe, |