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>
24 static struct sms_board sms_boards
[] = {
25 [SMS_BOARD_UNKNOWN
] = {
26 .name
= "Unknown board",
27 .type
= SMS_UNKNOWN_TYPE
,
28 .default_mode
= DEVICE_MODE_NONE
,
30 [SMS1XXX_BOARD_SIANO_STELLAR
] = {
31 .name
= "Siano Stellar Digital Receiver",
33 .default_mode
= DEVICE_MODE_DVBT_BDA
,
35 [SMS1XXX_BOARD_SIANO_NOVA_A
] = {
36 .name
= "Siano Nova A Digital Receiver",
38 .default_mode
= DEVICE_MODE_DVBT_BDA
,
40 [SMS1XXX_BOARD_SIANO_NOVA_B
] = {
41 .name
= "Siano Nova B Digital Receiver",
43 .default_mode
= DEVICE_MODE_DVBT_BDA
,
45 [SMS1XXX_BOARD_SIANO_VEGA
] = {
46 .name
= "Siano Vega Digital Receiver",
48 .default_mode
= DEVICE_MODE_CMMB
,
50 [SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT
] = {
51 .name
= "Hauppauge Catamount",
53 .fw
[DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVBT_STELLAR
,
54 .default_mode
= DEVICE_MODE_DVBT_BDA
,
56 [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A
] = {
57 .name
= "Hauppauge Okemo-A",
59 .fw
[DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVBT_NOVA_A
,
60 .default_mode
= DEVICE_MODE_DVBT_BDA
,
62 [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B
] = {
63 .name
= "Hauppauge Okemo-B",
65 .fw
[DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVBT_NOVA_B
,
66 .default_mode
= DEVICE_MODE_DVBT_BDA
,
68 [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
] = {
69 .name
= "Hauppauge WinTV MiniStick",
71 .fw
[DEVICE_MODE_ISDBT_BDA
] = SMS_FW_ISDBT_HCW_55XXX
,
72 .fw
[DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVBT_HCW_55XXX
,
73 .default_mode
= DEVICE_MODE_DVBT_BDA
,
74 .rc_codes
= RC_MAP_HAUPPAUGE
,
75 .board_cfg
.leds_power
= 26,
83 [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
] = {
84 .name
= "Hauppauge WinTV MiniCard",
86 .fw
[DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVBT_HCW_55XXX
,
87 .default_mode
= DEVICE_MODE_DVBT_BDA
,
89 .board_cfg
.foreign_lna0_ctrl
= 29,
91 .board_cfg
.rf_switch_uhf
= 17,
93 [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
] = {
94 .name
= "Hauppauge WinTV MiniCard",
96 .fw
[DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVBT_HCW_55XXX
,
97 .default_mode
= DEVICE_MODE_DVBT_BDA
,
100 [SMS1XXX_BOARD_SIANO_NICE
] = {
101 .name
= "Siano Nice Digital Receiver",
103 .default_mode
= DEVICE_MODE_DVBT_BDA
,
105 [SMS1XXX_BOARD_SIANO_VENICE
] = {
106 .name
= "Siano Venice Digital Receiver",
108 .default_mode
= DEVICE_MODE_CMMB
,
110 [SMS1XXX_BOARD_SIANO_STELLAR_ROM
] = {
111 .name
= "Siano Stellar Digital Receiver ROM",
113 .default_mode
= DEVICE_MODE_DVBT_BDA
,
116 [SMS1XXX_BOARD_ZTE_DVB_DATA_CARD
] = {
117 .name
= "ZTE Data Card Digital Receiver",
119 .default_mode
= DEVICE_MODE_DVBT_BDA
,
123 [SMS1XXX_BOARD_ONDA_MDTV_DATA_CARD
] = {
124 .name
= "ONDA Data Card Digital Receiver",
126 .default_mode
= DEVICE_MODE_DVBT_BDA
,
130 [SMS1XXX_BOARD_SIANO_MING
] = {
131 .name
= "Siano Ming Digital Receiver",
133 .default_mode
= DEVICE_MODE_CMMB
,
135 [SMS1XXX_BOARD_SIANO_PELE
] = {
136 .name
= "Siano Pele Digital Receiver",
138 .default_mode
= DEVICE_MODE_ISDBT_BDA
,
140 [SMS1XXX_BOARD_SIANO_RIO
] = {
141 .name
= "Siano Rio Digital Receiver",
143 .default_mode
= DEVICE_MODE_ISDBT_BDA
,
145 [SMS1XXX_BOARD_SIANO_DENVER_1530
] = {
146 .name
= "Siano Denver (ATSC-M/H) Digital Receiver",
147 .type
= SMS_DENVER_1530
,
148 .default_mode
= DEVICE_MODE_ATSC
,
151 [SMS1XXX_BOARD_SIANO_DENVER_2160
] = {
152 .name
= "Siano Denver (TDMB) Digital Receiver",
153 .type
= SMS_DENVER_2160
,
154 .default_mode
= DEVICE_MODE_DAB_TDMB
,
156 [SMS1XXX_BOARD_PCTV_77E
] = {
157 .name
= "Hauppauge microStick 77e",
159 .fw
[DEVICE_MODE_DVBT_BDA
] = SMS_FW_DVB_NOVA_12MHZ_B0
,
160 .default_mode
= DEVICE_MODE_DVBT_BDA
,
164 struct sms_board
*sms_get_board(unsigned id
)
166 BUG_ON(id
>= ARRAY_SIZE(sms_boards
));
168 return &sms_boards
[id
];
170 EXPORT_SYMBOL_GPL(sms_get_board
);
171 static inline void sms_gpio_assign_11xx_default_led_config(
172 struct smscore_config_gpio
*p_gpio_config
) {
173 p_gpio_config
->direction
= SMS_GPIO_DIRECTION_OUTPUT
;
174 p_gpio_config
->inputcharacteristics
=
175 SMS_GPIO_INPUTCHARACTERISTICS_NORMAL
;
176 p_gpio_config
->outputdriving
= SMS_GPIO_OUTPUTDRIVING_4mA
;
177 p_gpio_config
->outputslewrate
= SMS_GPIO_OUTPUT_SLEW_RATE_0_45_V_NS
;
178 p_gpio_config
->pullupdown
= SMS_GPIO_PULLUPDOWN_NONE
;
181 int sms_board_event(struct smscore_device_t
*coredev
,
182 enum SMS_BOARD_EVENTS gevent
)
184 struct smscore_config_gpio my_gpio_config
;
186 sms_gpio_assign_11xx_default_led_config(&my_gpio_config
);
189 case BOARD_EVENT_POWER_INIT
: /* including hotplug */
190 break; /* BOARD_EVENT_BIND */
192 case BOARD_EVENT_POWER_SUSPEND
:
193 break; /* BOARD_EVENT_POWER_SUSPEND */
195 case BOARD_EVENT_POWER_RESUME
:
196 break; /* BOARD_EVENT_POWER_RESUME */
198 case BOARD_EVENT_BIND
:
199 break; /* BOARD_EVENT_BIND */
201 case BOARD_EVENT_SCAN_PROG
:
202 break; /* BOARD_EVENT_SCAN_PROG */
203 case BOARD_EVENT_SCAN_COMP
:
204 break; /* BOARD_EVENT_SCAN_COMP */
205 case BOARD_EVENT_EMERGENCY_WARNING_SIGNAL
:
206 break; /* BOARD_EVENT_EMERGENCY_WARNING_SIGNAL */
207 case BOARD_EVENT_FE_LOCK
:
208 break; /* BOARD_EVENT_FE_LOCK */
209 case BOARD_EVENT_FE_UNLOCK
:
210 break; /* BOARD_EVENT_FE_UNLOCK */
211 case BOARD_EVENT_DEMOD_LOCK
:
212 break; /* BOARD_EVENT_DEMOD_LOCK */
213 case BOARD_EVENT_DEMOD_UNLOCK
:
214 break; /* BOARD_EVENT_DEMOD_UNLOCK */
215 case BOARD_EVENT_RECEPTION_MAX_4
:
216 break; /* BOARD_EVENT_RECEPTION_MAX_4 */
217 case BOARD_EVENT_RECEPTION_3
:
218 break; /* BOARD_EVENT_RECEPTION_3 */
219 case BOARD_EVENT_RECEPTION_2
:
220 break; /* BOARD_EVENT_RECEPTION_2 */
221 case BOARD_EVENT_RECEPTION_1
:
222 break; /* BOARD_EVENT_RECEPTION_1 */
223 case BOARD_EVENT_RECEPTION_LOST_0
:
224 break; /* BOARD_EVENT_RECEPTION_LOST_0 */
225 case BOARD_EVENT_MULTIPLEX_OK
:
226 break; /* BOARD_EVENT_MULTIPLEX_OK */
227 case BOARD_EVENT_MULTIPLEX_ERRORS
:
228 break; /* BOARD_EVENT_MULTIPLEX_ERRORS */
231 pr_err("Unknown SMS board event\n");
236 EXPORT_SYMBOL_GPL(sms_board_event
);
238 static int sms_set_gpio(struct smscore_device_t
*coredev
, int pin
, int enable
)
242 struct smscore_config_gpio gpioconfig
= {
243 .direction
= SMS_GPIO_DIRECTION_OUTPUT
,
244 .pullupdown
= SMS_GPIO_PULLUPDOWN_NONE
,
245 .inputcharacteristics
= SMS_GPIO_INPUTCHARACTERISTICS_NORMAL
,
246 .outputslewrate
= SMS_GPIO_OUTPUT_SLEW_RATE_FAST
,
247 .outputdriving
= SMS_GPIO_OUTPUTDRIVING_S_4mA
,
256 lvl
= enable
? 0 : 1;
259 lvl
= enable
? 1 : 0;
262 ret
= smscore_configure_gpio(coredev
, gpio
, &gpioconfig
);
266 return smscore_set_gpio(coredev
, gpio
, lvl
);
269 int sms_board_setup(struct smscore_device_t
*coredev
)
271 int board_id
= smscore_get_board_id(coredev
);
272 struct sms_board
*board
= sms_get_board(board_id
);
275 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
276 /* turn off all LEDs */
277 sms_set_gpio(coredev
, board
->led_power
, 0);
278 sms_set_gpio(coredev
, board
->led_hi
, 0);
279 sms_set_gpio(coredev
, board
->led_lo
, 0);
281 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
282 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
284 sms_set_gpio(coredev
, board
->lna_ctrl
, 0);
289 EXPORT_SYMBOL_GPL(sms_board_setup
);
291 int sms_board_power(struct smscore_device_t
*coredev
, int onoff
)
293 int board_id
= smscore_get_board_id(coredev
);
294 struct sms_board
*board
= sms_get_board(board_id
);
297 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
299 sms_set_gpio(coredev
,
300 board
->led_power
, onoff
? 1 : 0);
302 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
303 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
306 sms_set_gpio(coredev
, board
->lna_ctrl
, 0);
311 EXPORT_SYMBOL_GPL(sms_board_power
);
313 int sms_board_led_feedback(struct smscore_device_t
*coredev
, int led
)
315 int board_id
= smscore_get_board_id(coredev
);
316 struct sms_board
*board
= sms_get_board(board_id
);
318 /* dont touch GPIO if LEDs are already set */
319 if (smscore_led_state(coredev
, -1) == led
)
323 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM
:
324 sms_set_gpio(coredev
,
325 board
->led_lo
, (led
& SMS_LED_LO
) ? 1 : 0);
326 sms_set_gpio(coredev
,
327 board
->led_hi
, (led
& SMS_LED_HI
) ? 1 : 0);
329 smscore_led_state(coredev
, led
);
334 EXPORT_SYMBOL_GPL(sms_board_led_feedback
);
336 int sms_board_lna_control(struct smscore_device_t
*coredev
, int onoff
)
338 int board_id
= smscore_get_board_id(coredev
);
339 struct sms_board
*board
= sms_get_board(board_id
);
341 pr_debug("%s: LNA %s\n", __func__
, onoff
? "enabled" : "disabled");
344 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2
:
345 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD
:
346 sms_set_gpio(coredev
,
347 board
->rf_switch
, onoff
? 1 : 0);
348 return sms_set_gpio(coredev
,
349 board
->lna_ctrl
, onoff
? 1 : 0);
353 EXPORT_SYMBOL_GPL(sms_board_lna_control
);
355 int sms_board_load_modules(int id
)
357 request_module("smsdvb");
360 EXPORT_SYMBOL_GPL(sms_board_load_modules
);