2 * Card-specific functions for the Siano SMS1xxx USB dongle
4 * Copyright (c) 2008 Michael Krufky <mkrufky@linuxtv.org>
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 2 as
8 * published by the Free Software Foundation;
10 * Software distributed under the License is distributed on an "AS IS"
11 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
13 * See the GNU General Public License for more details.
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.
20 #include "sms-cards.h"
22 #include <linux/module.h>
25 module_param_named(cards_dbg
, sms_dbg
, int, 0644);
26 MODULE_PARM_DESC(cards_dbg
, "set debug level (info=1, adv=2 (or-able))");
28 static struct sms_board sms_boards
[] = {
29 [SMS_BOARD_UNKNOWN
] = {
30 .name
= "Unknown board",
31 .type
= SMS_UNKNOWN_TYPE
,
32 .default_mode
= DEVICE_MODE_NONE
,
34 [SMS1XXX_BOARD_SIANO_STELLAR
] = {
35 .name
= "Siano Stellar Digital Receiver",
37 .default_mode
= DEVICE_MODE_DVBT_BDA
,
39 [SMS1XXX_BOARD_SIANO_NOVA_A
] = {
40 .name
= "Siano Nova A Digital Receiver",
42 .default_mode
= DEVICE_MODE_DVBT_BDA
,
44 [SMS1XXX_BOARD_SIANO_NOVA_B
] = {
45 .name
= "Siano Nova B Digital Receiver",
47 .default_mode
= DEVICE_MODE_DVBT_BDA
,
49 [SMS1XXX_BOARD_SIANO_VEGA
] = {
50 .name
= "Siano Vega Digital Receiver",
52 .default_mode
= DEVICE_MODE_CMMB
,
54 [SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT
] = {
55 .name
= "Hauppauge Catamount",
57 .fw
[DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVBT_STELLAR
,
58 .default_mode
= DEVICE_MODE_DVBT_BDA
,
60 [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A
] = {
61 .name
= "Hauppauge Okemo-A",
63 .fw
[DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVBT_NOVA_A
,
64 .default_mode
= DEVICE_MODE_DVBT_BDA
,
66 [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B
] = {
67 .name
= "Hauppauge Okemo-B",
69 .fw
[DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVBT_NOVA_B
,
70 .default_mode
= DEVICE_MODE_DVBT_BDA
,
72 [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
] = {
73 .name
= "Hauppauge WinTV MiniStick",
75 .fw
[DEVICE_MODE_ISDBT_BDA
] = SMS_FW_ISDBT_HCW_55XXX
,
76 .fw
[DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVBT_HCW_55XXX
,
77 .default_mode
= DEVICE_MODE_DVBT_BDA
,
78 .rc_codes
= RC_MAP_HAUPPAUGE
,
79 .board_cfg
.leds_power
= 26,
87 [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
] = {
88 .name
= "Hauppauge WinTV MiniCard",
90 .fw
[DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVBT_HCW_55XXX
,
91 .default_mode
= DEVICE_MODE_DVBT_BDA
,
93 .board_cfg
.foreign_lna0_ctrl
= 29,
95 .board_cfg
.rf_switch_uhf
= 17,
97 [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
] = {
98 .name
= "Hauppauge WinTV MiniCard",
100 .fw
[DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVBT_HCW_55XXX
,
101 .default_mode
= DEVICE_MODE_DVBT_BDA
,
104 [SMS1XXX_BOARD_SIANO_NICE
] = {
105 .name
= "Siano Nice Digital Receiver",
107 .default_mode
= DEVICE_MODE_DVBT_BDA
,
109 [SMS1XXX_BOARD_SIANO_VENICE
] = {
110 .name
= "Siano Venice Digital Receiver",
112 .default_mode
= DEVICE_MODE_CMMB
,
114 [SMS1XXX_BOARD_SIANO_STELLAR_ROM
] = {
115 .name
= "Siano Stellar Digital Receiver ROM",
117 .default_mode
= DEVICE_MODE_DVBT_BDA
,
120 [SMS1XXX_BOARD_ZTE_DVB_DATA_CARD
] = {
121 .name
= "ZTE Data Card Digital Receiver",
123 .default_mode
= DEVICE_MODE_DVBT_BDA
,
127 [SMS1XXX_BOARD_ONDA_MDTV_DATA_CARD
] = {
128 .name
= "ONDA Data Card Digital Receiver",
130 .default_mode
= DEVICE_MODE_DVBT_BDA
,
134 [SMS1XXX_BOARD_SIANO_MING
] = {
135 .name
= "Siano Ming Digital Receiver",
137 .default_mode
= DEVICE_MODE_CMMB
,
139 [SMS1XXX_BOARD_SIANO_PELE
] = {
140 .name
= "Siano Pele Digital Receiver",
142 .default_mode
= DEVICE_MODE_ISDBT_BDA
,
144 [SMS1XXX_BOARD_SIANO_RIO
] = {
145 .name
= "Siano Rio Digital Receiver",
147 .default_mode
= DEVICE_MODE_ISDBT_BDA
,
149 [SMS1XXX_BOARD_SIANO_DENVER_1530
] = {
150 .name
= "Siano Denver (ATSC-M/H) Digital Receiver",
151 .type
= SMS_DENVER_1530
,
152 .default_mode
= DEVICE_MODE_ATSC
,
155 [SMS1XXX_BOARD_SIANO_DENVER_2160
] = {
156 .name
= "Siano Denver (TDMB) Digital Receiver",
157 .type
= SMS_DENVER_2160
,
158 .default_mode
= DEVICE_MODE_DAB_TDMB
,
162 struct sms_board
*sms_get_board(unsigned id
)
164 BUG_ON(id
>= ARRAY_SIZE(sms_boards
));
166 return &sms_boards
[id
];
168 EXPORT_SYMBOL_GPL(sms_get_board
);
169 static inline void sms_gpio_assign_11xx_default_led_config(
170 struct smscore_config_gpio
*p_gpio_config
) {
171 p_gpio_config
->direction
= SMS_GPIO_DIRECTION_OUTPUT
;
172 p_gpio_config
->inputcharacteristics
=
173 SMS_GPIO_INPUTCHARACTERISTICS_NORMAL
;
174 p_gpio_config
->outputdriving
= SMS_GPIO_OUTPUTDRIVING_4mA
;
175 p_gpio_config
->outputslewrate
= SMS_GPIO_OUTPUT_SLEW_RATE_0_45_V_NS
;
176 p_gpio_config
->pullupdown
= SMS_GPIO_PULLUPDOWN_NONE
;
179 int sms_board_event(struct smscore_device_t
*coredev
,
180 enum SMS_BOARD_EVENTS gevent
)
182 struct smscore_config_gpio my_gpio_config
;
184 sms_gpio_assign_11xx_default_led_config(&my_gpio_config
);
187 case BOARD_EVENT_POWER_INIT
: /* including hotplug */
188 break; /* BOARD_EVENT_BIND */
190 case BOARD_EVENT_POWER_SUSPEND
:
191 break; /* BOARD_EVENT_POWER_SUSPEND */
193 case BOARD_EVENT_POWER_RESUME
:
194 break; /* BOARD_EVENT_POWER_RESUME */
196 case BOARD_EVENT_BIND
:
197 break; /* BOARD_EVENT_BIND */
199 case BOARD_EVENT_SCAN_PROG
:
200 break; /* BOARD_EVENT_SCAN_PROG */
201 case BOARD_EVENT_SCAN_COMP
:
202 break; /* BOARD_EVENT_SCAN_COMP */
203 case BOARD_EVENT_EMERGENCY_WARNING_SIGNAL
:
204 break; /* BOARD_EVENT_EMERGENCY_WARNING_SIGNAL */
205 case BOARD_EVENT_FE_LOCK
:
206 break; /* BOARD_EVENT_FE_LOCK */
207 case BOARD_EVENT_FE_UNLOCK
:
208 break; /* BOARD_EVENT_FE_UNLOCK */
209 case BOARD_EVENT_DEMOD_LOCK
:
210 break; /* BOARD_EVENT_DEMOD_LOCK */
211 case BOARD_EVENT_DEMOD_UNLOCK
:
212 break; /* BOARD_EVENT_DEMOD_UNLOCK */
213 case BOARD_EVENT_RECEPTION_MAX_4
:
214 break; /* BOARD_EVENT_RECEPTION_MAX_4 */
215 case BOARD_EVENT_RECEPTION_3
:
216 break; /* BOARD_EVENT_RECEPTION_3 */
217 case BOARD_EVENT_RECEPTION_2
:
218 break; /* BOARD_EVENT_RECEPTION_2 */
219 case BOARD_EVENT_RECEPTION_1
:
220 break; /* BOARD_EVENT_RECEPTION_1 */
221 case BOARD_EVENT_RECEPTION_LOST_0
:
222 break; /* BOARD_EVENT_RECEPTION_LOST_0 */
223 case BOARD_EVENT_MULTIPLEX_OK
:
224 break; /* BOARD_EVENT_MULTIPLEX_OK */
225 case BOARD_EVENT_MULTIPLEX_ERRORS
:
226 break; /* BOARD_EVENT_MULTIPLEX_ERRORS */
229 sms_err("Unknown SMS board event");
234 EXPORT_SYMBOL_GPL(sms_board_event
);
236 static int sms_set_gpio(struct smscore_device_t
*coredev
, int pin
, int enable
)
240 struct smscore_config_gpio gpioconfig
= {
241 .direction
= SMS_GPIO_DIRECTION_OUTPUT
,
242 .pullupdown
= SMS_GPIO_PULLUPDOWN_NONE
,
243 .inputcharacteristics
= SMS_GPIO_INPUTCHARACTERISTICS_NORMAL
,
244 .outputslewrate
= SMS_GPIO_OUTPUT_SLEW_RATE_FAST
,
245 .outputdriving
= SMS_GPIO_OUTPUTDRIVING_S_4mA
,
254 lvl
= enable
? 0 : 1;
257 lvl
= enable
? 1 : 0;
260 ret
= smscore_configure_gpio(coredev
, gpio
, &gpioconfig
);
264 return smscore_set_gpio(coredev
, gpio
, lvl
);
267 int sms_board_setup(struct smscore_device_t
*coredev
)
269 int board_id
= smscore_get_board_id(coredev
);
270 struct sms_board
*board
= sms_get_board(board_id
);
273 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
274 /* turn off all LEDs */
275 sms_set_gpio(coredev
, board
->led_power
, 0);
276 sms_set_gpio(coredev
, board
->led_hi
, 0);
277 sms_set_gpio(coredev
, board
->led_lo
, 0);
279 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
280 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
282 sms_set_gpio(coredev
, board
->lna_ctrl
, 0);
287 EXPORT_SYMBOL_GPL(sms_board_setup
);
289 int sms_board_power(struct smscore_device_t
*coredev
, int onoff
)
291 int board_id
= smscore_get_board_id(coredev
);
292 struct sms_board
*board
= sms_get_board(board_id
);
295 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
297 sms_set_gpio(coredev
,
298 board
->led_power
, onoff
? 1 : 0);
300 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
301 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
304 sms_set_gpio(coredev
, board
->lna_ctrl
, 0);
309 EXPORT_SYMBOL_GPL(sms_board_power
);
311 int sms_board_led_feedback(struct smscore_device_t
*coredev
, int led
)
313 int board_id
= smscore_get_board_id(coredev
);
314 struct sms_board
*board
= sms_get_board(board_id
);
316 /* dont touch GPIO if LEDs are already set */
317 if (smscore_led_state(coredev
, -1) == led
)
321 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
322 sms_set_gpio(coredev
,
323 board
->led_lo
, (led
& SMS_LED_LO
) ? 1 : 0);
324 sms_set_gpio(coredev
,
325 board
->led_hi
, (led
& SMS_LED_HI
) ? 1 : 0);
327 smscore_led_state(coredev
, led
);
332 EXPORT_SYMBOL_GPL(sms_board_led_feedback
);
334 int sms_board_lna_control(struct smscore_device_t
*coredev
, int onoff
)
336 int board_id
= smscore_get_board_id(coredev
);
337 struct sms_board
*board
= sms_get_board(board_id
);
339 sms_debug("%s: LNA %s", __func__
, onoff
? "enabled" : "disabled");
342 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
343 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
344 sms_set_gpio(coredev
,
345 board
->rf_switch
, onoff
? 1 : 0);
346 return sms_set_gpio(coredev
,
347 board
->lna_ctrl
, onoff
? 1 : 0);
351 EXPORT_SYMBOL_GPL(sms_board_lna_control
);
353 int sms_board_load_modules(int id
)
355 request_module("smsdvb");
358 EXPORT_SYMBOL_GPL(sms_board_load_modules
);