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"
24 module_param_named(cards_dbg
, sms_dbg
, int, 0644);
25 MODULE_PARM_DESC(cards_dbg
, "set debug level (info=1, adv=2 (or-able))");
27 static struct sms_board sms_boards
[] = {
28 [SMS_BOARD_UNKNOWN
] = {
29 .name
= "Unknown board",
31 [SMS1XXX_BOARD_SIANO_STELLAR
] = {
32 .name
= "Siano Stellar Digital Receiver",
35 [SMS1XXX_BOARD_SIANO_NOVA_A
] = {
36 .name
= "Siano Nova A Digital Receiver",
39 [SMS1XXX_BOARD_SIANO_NOVA_B
] = {
40 .name
= "Siano Nova B Digital Receiver",
43 [SMS1XXX_BOARD_SIANO_VEGA
] = {
44 .name
= "Siano Vega Digital Receiver",
47 [SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT
] = {
48 .name
= "Hauppauge Catamount",
50 .fw
[DEVICE_MODE_DVBT_BDA
] = "sms1xxx-stellar-dvbt-01.fw",
52 [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A
] = {
53 .name
= "Hauppauge Okemo-A",
55 .fw
[DEVICE_MODE_DVBT_BDA
] = "sms1xxx-nova-a-dvbt-01.fw",
57 [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B
] = {
58 .name
= "Hauppauge Okemo-B",
60 .fw
[DEVICE_MODE_DVBT_BDA
] = "sms1xxx-nova-b-dvbt-01.fw",
62 [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
] = {
63 .name
= "Hauppauge WinTV MiniStick",
65 .fw
[DEVICE_MODE_DVBT_BDA
] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
66 .board_cfg
.leds_power
= 26,
73 [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
] = {
74 .name
= "Hauppauge WinTV MiniCard",
76 .fw
[DEVICE_MODE_DVBT_BDA
] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
78 .board_cfg
.foreign_lna0_ctrl
= 29,
80 .board_cfg
.rf_switch_uhf
= 17,
82 [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
] = {
83 .name
= "Hauppauge WinTV MiniCard",
85 .fw
[DEVICE_MODE_DVBT_BDA
] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
88 [SMS1XXX_BOARD_SIANO_NICE
] = {
90 .name
= "Siano Nice Digital Receiver",
93 [SMS1XXX_BOARD_SIANO_VENICE
] = {
95 .name
= "Siano Venice Digital Receiver",
100 struct sms_board
*sms_get_board(int id
)
102 BUG_ON(id
>= ARRAY_SIZE(sms_boards
));
104 return &sms_boards
[id
];
106 EXPORT_SYMBOL_GPL(sms_get_board
);
107 static inline void sms_gpio_assign_11xx_default_led_config(
108 struct smscore_gpio_config
*pGpioConfig
) {
109 pGpioConfig
->Direction
= SMS_GPIO_DIRECTION_OUTPUT
;
110 pGpioConfig
->InputCharacteristics
=
111 SMS_GPIO_INPUT_CHARACTERISTICS_NORMAL
;
112 pGpioConfig
->OutputDriving
= SMS_GPIO_OUTPUT_DRIVING_4mA
;
113 pGpioConfig
->OutputSlewRate
= SMS_GPIO_OUTPUT_SLEW_RATE_0_45_V_NS
;
114 pGpioConfig
->PullUpDown
= SMS_GPIO_PULL_UP_DOWN_NONE
;
117 int sms_board_event(struct smscore_device_t
*coredev
,
118 enum SMS_BOARD_EVENTS gevent
) {
119 int board_id
= smscore_get_board_id(coredev
);
120 struct sms_board
*board
= sms_get_board(board_id
);
121 struct smscore_gpio_config MyGpioConfig
;
123 sms_gpio_assign_11xx_default_led_config(&MyGpioConfig
);
126 case BOARD_EVENT_POWER_INIT
: /* including hotplug */
128 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
129 /* set I/O and turn off all LEDs */
130 smscore_gpio_configure(coredev
,
131 board
->board_cfg
.leds_power
,
133 smscore_gpio_set_level(coredev
,
134 board
->board_cfg
.leds_power
, 0);
135 smscore_gpio_configure(coredev
, board
->board_cfg
.led0
,
137 smscore_gpio_set_level(coredev
,
138 board
->board_cfg
.led0
, 0);
139 smscore_gpio_configure(coredev
, board
->board_cfg
.led1
,
141 smscore_gpio_set_level(coredev
,
142 board
->board_cfg
.led1
, 0);
144 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
145 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
146 /* set I/O and turn off LNA */
147 smscore_gpio_configure(coredev
,
148 board
->board_cfg
.foreign_lna0_ctrl
,
150 smscore_gpio_set_level(coredev
,
151 board
->board_cfg
.foreign_lna0_ctrl
,
155 break; /* BOARD_EVENT_BIND */
157 case BOARD_EVENT_POWER_SUSPEND
:
159 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
160 smscore_gpio_set_level(coredev
,
161 board
->board_cfg
.leds_power
, 0);
162 smscore_gpio_set_level(coredev
,
163 board
->board_cfg
.led0
, 0);
164 smscore_gpio_set_level(coredev
,
165 board
->board_cfg
.led1
, 0);
167 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
168 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
169 smscore_gpio_set_level(coredev
,
170 board
->board_cfg
.foreign_lna0_ctrl
,
174 break; /* BOARD_EVENT_POWER_SUSPEND */
176 case BOARD_EVENT_POWER_RESUME
:
178 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
179 smscore_gpio_set_level(coredev
,
180 board
->board_cfg
.leds_power
, 1);
181 smscore_gpio_set_level(coredev
,
182 board
->board_cfg
.led0
, 1);
183 smscore_gpio_set_level(coredev
,
184 board
->board_cfg
.led1
, 0);
186 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
187 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
188 smscore_gpio_set_level(coredev
,
189 board
->board_cfg
.foreign_lna0_ctrl
,
193 break; /* BOARD_EVENT_POWER_RESUME */
195 case BOARD_EVENT_BIND
:
197 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
198 smscore_gpio_set_level(coredev
,
199 board
->board_cfg
.leds_power
, 1);
200 smscore_gpio_set_level(coredev
,
201 board
->board_cfg
.led0
, 1);
202 smscore_gpio_set_level(coredev
,
203 board
->board_cfg
.led1
, 0);
205 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
206 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
207 smscore_gpio_set_level(coredev
,
208 board
->board_cfg
.foreign_lna0_ctrl
,
212 break; /* BOARD_EVENT_BIND */
214 case BOARD_EVENT_SCAN_PROG
:
215 break; /* BOARD_EVENT_SCAN_PROG */
216 case BOARD_EVENT_SCAN_COMP
:
217 break; /* BOARD_EVENT_SCAN_COMP */
218 case BOARD_EVENT_EMERGENCY_WARNING_SIGNAL
:
219 break; /* BOARD_EVENT_EMERGENCY_WARNING_SIGNAL */
220 case BOARD_EVENT_FE_LOCK
:
222 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
223 smscore_gpio_set_level(coredev
,
224 board
->board_cfg
.led1
, 1);
227 break; /* BOARD_EVENT_FE_LOCK */
228 case BOARD_EVENT_FE_UNLOCK
:
230 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
231 smscore_gpio_set_level(coredev
,
232 board
->board_cfg
.led1
, 0);
235 break; /* BOARD_EVENT_FE_UNLOCK */
236 case BOARD_EVENT_DEMOD_LOCK
:
237 break; /* BOARD_EVENT_DEMOD_LOCK */
238 case BOARD_EVENT_DEMOD_UNLOCK
:
239 break; /* BOARD_EVENT_DEMOD_UNLOCK */
240 case BOARD_EVENT_RECEPTION_MAX_4
:
241 break; /* BOARD_EVENT_RECEPTION_MAX_4 */
242 case BOARD_EVENT_RECEPTION_3
:
243 break; /* BOARD_EVENT_RECEPTION_3 */
244 case BOARD_EVENT_RECEPTION_2
:
245 break; /* BOARD_EVENT_RECEPTION_2 */
246 case BOARD_EVENT_RECEPTION_1
:
247 break; /* BOARD_EVENT_RECEPTION_1 */
248 case BOARD_EVENT_RECEPTION_LOST_0
:
249 break; /* BOARD_EVENT_RECEPTION_LOST_0 */
250 case BOARD_EVENT_MULTIPLEX_OK
:
252 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
253 smscore_gpio_set_level(coredev
,
254 board
->board_cfg
.led1
, 1);
257 break; /* BOARD_EVENT_MULTIPLEX_OK */
258 case BOARD_EVENT_MULTIPLEX_ERRORS
:
260 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
261 smscore_gpio_set_level(coredev
,
262 board
->board_cfg
.led1
, 0);
265 break; /* BOARD_EVENT_MULTIPLEX_ERRORS */
268 sms_err("Unknown SMS board event");
273 EXPORT_SYMBOL_GPL(sms_board_event
);
275 static int sms_set_gpio(struct smscore_device_t
*coredev
, int pin
, int enable
)
279 struct smscore_config_gpio gpioconfig
= {
280 .direction
= SMS_GPIO_DIRECTION_OUTPUT
,
281 .pullupdown
= SMS_GPIO_PULLUPDOWN_NONE
,
282 .inputcharacteristics
= SMS_GPIO_INPUTCHARACTERISTICS_NORMAL
,
283 .outputslewrate
= SMS_GPIO_OUTPUTSLEWRATE_FAST
,
284 .outputdriving
= SMS_GPIO_OUTPUTDRIVING_4mA
,
293 lvl
= enable
? 0 : 1;
296 lvl
= enable
? 1 : 0;
299 ret
= smscore_configure_gpio(coredev
, gpio
, &gpioconfig
);
303 return smscore_set_gpio(coredev
, gpio
, lvl
);
306 int sms_board_setup(struct smscore_device_t
*coredev
)
308 int board_id
= smscore_get_board_id(coredev
);
309 struct sms_board
*board
= sms_get_board(board_id
);
312 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
313 /* turn off all LEDs */
314 sms_set_gpio(coredev
, board
->led_power
, 0);
315 sms_set_gpio(coredev
, board
->led_hi
, 0);
316 sms_set_gpio(coredev
, board
->led_lo
, 0);
318 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
319 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
321 sms_set_gpio(coredev
, board
->lna_ctrl
, 0);
326 EXPORT_SYMBOL_GPL(sms_board_setup
);
328 int sms_board_power(struct smscore_device_t
*coredev
, int onoff
)
330 int board_id
= smscore_get_board_id(coredev
);
331 struct sms_board
*board
= sms_get_board(board_id
);
334 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
336 sms_set_gpio(coredev
,
337 board
->led_power
, onoff
? 1 : 0);
339 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
340 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
343 sms_set_gpio(coredev
, board
->lna_ctrl
, 0);
348 EXPORT_SYMBOL_GPL(sms_board_power
);
350 int sms_board_led_feedback(struct smscore_device_t
*coredev
, int led
)
352 int board_id
= smscore_get_board_id(coredev
);
353 struct sms_board
*board
= sms_get_board(board_id
);
355 /* dont touch GPIO if LEDs are already set */
356 if (smscore_led_state(coredev
, -1) == led
)
360 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
361 sms_set_gpio(coredev
,
362 board
->led_lo
, (led
& SMS_LED_LO
) ? 1 : 0);
363 sms_set_gpio(coredev
,
364 board
->led_hi
, (led
& SMS_LED_HI
) ? 1 : 0);
366 smscore_led_state(coredev
, led
);
371 EXPORT_SYMBOL_GPL(sms_board_led_feedback
);
373 int sms_board_lna_control(struct smscore_device_t
*coredev
, int onoff
)
375 int board_id
= smscore_get_board_id(coredev
);
376 struct sms_board
*board
= sms_get_board(board_id
);
378 sms_debug("%s: LNA %s", __func__
, onoff
? "enabled" : "disabled");
381 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
382 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
383 sms_set_gpio(coredev
,
384 board
->rf_switch
, onoff
? 1 : 0);
385 return sms_set_gpio(coredev
,
386 board
->lna_ctrl
, onoff
? 1 : 0);
390 EXPORT_SYMBOL_GPL(sms_board_lna_control
);
392 int sms_board_load_modules(int id
)
395 case SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT
:
396 case SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A
:
397 case SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B
:
398 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
399 request_module("smsdvb");
407 EXPORT_SYMBOL_GPL(sms_board_load_modules
);