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",
32 [SMS1XXX_BOARD_SIANO_STELLAR
] = {
33 .name
= "Siano Stellar Digital Receiver",
36 [SMS1XXX_BOARD_SIANO_NOVA_A
] = {
37 .name
= "Siano Nova A Digital Receiver",
40 [SMS1XXX_BOARD_SIANO_NOVA_B
] = {
41 .name
= "Siano Nova B Digital Receiver",
44 [SMS1XXX_BOARD_SIANO_VEGA
] = {
45 .name
= "Siano Vega Digital Receiver",
48 [SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT
] = {
49 .name
= "Hauppauge Catamount",
51 .fw
[DEVICE_MODE_DVBT_BDA
] = "sms1xxx-stellar-dvbt-01.fw",
53 [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A
] = {
54 .name
= "Hauppauge Okemo-A",
56 .fw
[DEVICE_MODE_DVBT_BDA
] = "sms1xxx-nova-a-dvbt-01.fw",
58 [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B
] = {
59 .name
= "Hauppauge Okemo-B",
61 .fw
[DEVICE_MODE_DVBT_BDA
] = "sms1xxx-nova-b-dvbt-01.fw",
63 [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
] = {
64 .name
= "Hauppauge WinTV MiniStick",
66 .fw
[DEVICE_MODE_ISDBT_BDA
] = "sms1xxx-hcw-55xxx-isdbt-02.fw",
67 .fw
[DEVICE_MODE_DVBT_BDA
] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
68 .rc_codes
= RC_MAP_HAUPPAUGE
,
69 .board_cfg
.leds_power
= 26,
77 [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
] = {
78 .name
= "Hauppauge WinTV MiniCard",
80 .fw
[DEVICE_MODE_DVBT_BDA
] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
82 .board_cfg
.foreign_lna0_ctrl
= 29,
84 .board_cfg
.rf_switch_uhf
= 17,
86 [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
] = {
87 .name
= "Hauppauge WinTV MiniCard",
89 .fw
[DEVICE_MODE_DVBT_BDA
] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
92 [SMS1XXX_BOARD_SIANO_NICE
] = {
94 .name
= "Siano Nice Digital Receiver",
97 [SMS1XXX_BOARD_SIANO_VENICE
] = {
99 .name
= "Siano Venice Digital Receiver",
104 struct sms_board
*sms_get_board(unsigned id
)
106 BUG_ON(id
>= ARRAY_SIZE(sms_boards
));
108 return &sms_boards
[id
];
110 EXPORT_SYMBOL_GPL(sms_get_board
);
111 static inline void sms_gpio_assign_11xx_default_led_config(
112 struct smscore_gpio_config
*pGpioConfig
) {
113 pGpioConfig
->Direction
= SMS_GPIO_DIRECTION_OUTPUT
;
114 pGpioConfig
->InputCharacteristics
=
115 SMS_GPIO_INPUT_CHARACTERISTICS_NORMAL
;
116 pGpioConfig
->OutputDriving
= SMS_GPIO_OUTPUT_DRIVING_4mA
;
117 pGpioConfig
->OutputSlewRate
= SMS_GPIO_OUTPUT_SLEW_RATE_0_45_V_NS
;
118 pGpioConfig
->PullUpDown
= SMS_GPIO_PULL_UP_DOWN_NONE
;
121 int sms_board_event(struct smscore_device_t
*coredev
,
122 enum SMS_BOARD_EVENTS gevent
) {
123 struct smscore_gpio_config MyGpioConfig
;
125 sms_gpio_assign_11xx_default_led_config(&MyGpioConfig
);
128 case BOARD_EVENT_POWER_INIT
: /* including hotplug */
129 break; /* BOARD_EVENT_BIND */
131 case BOARD_EVENT_POWER_SUSPEND
:
132 break; /* BOARD_EVENT_POWER_SUSPEND */
134 case BOARD_EVENT_POWER_RESUME
:
135 break; /* BOARD_EVENT_POWER_RESUME */
137 case BOARD_EVENT_BIND
:
138 break; /* BOARD_EVENT_BIND */
140 case BOARD_EVENT_SCAN_PROG
:
141 break; /* BOARD_EVENT_SCAN_PROG */
142 case BOARD_EVENT_SCAN_COMP
:
143 break; /* BOARD_EVENT_SCAN_COMP */
144 case BOARD_EVENT_EMERGENCY_WARNING_SIGNAL
:
145 break; /* BOARD_EVENT_EMERGENCY_WARNING_SIGNAL */
146 case BOARD_EVENT_FE_LOCK
:
147 break; /* BOARD_EVENT_FE_LOCK */
148 case BOARD_EVENT_FE_UNLOCK
:
149 break; /* BOARD_EVENT_FE_UNLOCK */
150 case BOARD_EVENT_DEMOD_LOCK
:
151 break; /* BOARD_EVENT_DEMOD_LOCK */
152 case BOARD_EVENT_DEMOD_UNLOCK
:
153 break; /* BOARD_EVENT_DEMOD_UNLOCK */
154 case BOARD_EVENT_RECEPTION_MAX_4
:
155 break; /* BOARD_EVENT_RECEPTION_MAX_4 */
156 case BOARD_EVENT_RECEPTION_3
:
157 break; /* BOARD_EVENT_RECEPTION_3 */
158 case BOARD_EVENT_RECEPTION_2
:
159 break; /* BOARD_EVENT_RECEPTION_2 */
160 case BOARD_EVENT_RECEPTION_1
:
161 break; /* BOARD_EVENT_RECEPTION_1 */
162 case BOARD_EVENT_RECEPTION_LOST_0
:
163 break; /* BOARD_EVENT_RECEPTION_LOST_0 */
164 case BOARD_EVENT_MULTIPLEX_OK
:
165 break; /* BOARD_EVENT_MULTIPLEX_OK */
166 case BOARD_EVENT_MULTIPLEX_ERRORS
:
167 break; /* BOARD_EVENT_MULTIPLEX_ERRORS */
170 sms_err("Unknown SMS board event");
175 EXPORT_SYMBOL_GPL(sms_board_event
);
177 static int sms_set_gpio(struct smscore_device_t
*coredev
, int pin
, int enable
)
181 struct smscore_config_gpio gpioconfig
= {
182 .direction
= SMS_GPIO_DIRECTION_OUTPUT
,
183 .pullupdown
= SMS_GPIO_PULLUPDOWN_NONE
,
184 .inputcharacteristics
= SMS_GPIO_INPUTCHARACTERISTICS_NORMAL
,
185 .outputslewrate
= SMS_GPIO_OUTPUTSLEWRATE_FAST
,
186 .outputdriving
= SMS_GPIO_OUTPUTDRIVING_4mA
,
195 lvl
= enable
? 0 : 1;
198 lvl
= enable
? 1 : 0;
201 ret
= smscore_configure_gpio(coredev
, gpio
, &gpioconfig
);
205 return smscore_set_gpio(coredev
, gpio
, lvl
);
208 int sms_board_setup(struct smscore_device_t
*coredev
)
210 int board_id
= smscore_get_board_id(coredev
);
211 struct sms_board
*board
= sms_get_board(board_id
);
214 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
215 /* turn off all LEDs */
216 sms_set_gpio(coredev
, board
->led_power
, 0);
217 sms_set_gpio(coredev
, board
->led_hi
, 0);
218 sms_set_gpio(coredev
, board
->led_lo
, 0);
220 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
221 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
223 sms_set_gpio(coredev
, board
->lna_ctrl
, 0);
228 EXPORT_SYMBOL_GPL(sms_board_setup
);
230 int sms_board_power(struct smscore_device_t
*coredev
, int onoff
)
232 int board_id
= smscore_get_board_id(coredev
);
233 struct sms_board
*board
= sms_get_board(board_id
);
236 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
238 sms_set_gpio(coredev
,
239 board
->led_power
, onoff
? 1 : 0);
241 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
242 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
245 sms_set_gpio(coredev
, board
->lna_ctrl
, 0);
250 EXPORT_SYMBOL_GPL(sms_board_power
);
252 int sms_board_led_feedback(struct smscore_device_t
*coredev
, int led
)
254 int board_id
= smscore_get_board_id(coredev
);
255 struct sms_board
*board
= sms_get_board(board_id
);
257 /* dont touch GPIO if LEDs are already set */
258 if (smscore_led_state(coredev
, -1) == led
)
262 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
263 sms_set_gpio(coredev
,
264 board
->led_lo
, (led
& SMS_LED_LO
) ? 1 : 0);
265 sms_set_gpio(coredev
,
266 board
->led_hi
, (led
& SMS_LED_HI
) ? 1 : 0);
268 smscore_led_state(coredev
, led
);
273 EXPORT_SYMBOL_GPL(sms_board_led_feedback
);
275 int sms_board_lna_control(struct smscore_device_t
*coredev
, int onoff
)
277 int board_id
= smscore_get_board_id(coredev
);
278 struct sms_board
*board
= sms_get_board(board_id
);
280 sms_debug("%s: LNA %s", __func__
, onoff
? "enabled" : "disabled");
283 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
284 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
285 sms_set_gpio(coredev
,
286 board
->rf_switch
, onoff
? 1 : 0);
287 return sms_set_gpio(coredev
,
288 board
->lna_ctrl
, onoff
? 1 : 0);
292 EXPORT_SYMBOL_GPL(sms_board_lna_control
);
294 int sms_board_load_modules(int id
)
297 case SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT
:
298 case SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A
:
299 case SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B
:
300 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
301 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
302 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
303 request_module("smsdvb");
311 EXPORT_SYMBOL_GPL(sms_board_load_modules
);