Full support for Ginger Console
[linux-ginger.git] / drivers / media / dvb / siano / sms-cards.c
blob0420e2885e752971fd4ef1dbc01ac2d4d46e000f
1 /*
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"
21 #include "smsir.h"
23 static int sms_dbg;
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",
33 .type = SMS_STELLAR,
35 [SMS1XXX_BOARD_SIANO_NOVA_A] = {
36 .name = "Siano Nova A Digital Receiver",
37 .type = SMS_NOVA_A0,
39 [SMS1XXX_BOARD_SIANO_NOVA_B] = {
40 .name = "Siano Nova B Digital Receiver",
41 .type = SMS_NOVA_B0,
43 [SMS1XXX_BOARD_SIANO_VEGA] = {
44 .name = "Siano Vega Digital Receiver",
45 .type = SMS_VEGA,
47 [SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT] = {
48 .name = "Hauppauge Catamount",
49 .type = SMS_STELLAR,
50 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-stellar-dvbt-01.fw",
52 [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A] = {
53 .name = "Hauppauge Okemo-A",
54 .type = SMS_NOVA_A0,
55 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-nova-a-dvbt-01.fw",
57 [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B] = {
58 .name = "Hauppauge Okemo-B",
59 .type = SMS_NOVA_B0,
60 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-nova-b-dvbt-01.fw",
62 [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM] = {
63 .name = "Hauppauge WinTV MiniStick",
64 .type = SMS_NOVA_B0,
65 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
66 .board_cfg.leds_power = 26,
67 .board_cfg.led0 = 27,
68 .board_cfg.led1 = 28,
69 .led_power = 26,
70 .led_lo = 27,
71 .led_hi = 28,
73 [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD] = {
74 .name = "Hauppauge WinTV MiniCard",
75 .type = SMS_NOVA_B0,
76 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
77 .lna_ctrl = 29,
78 .board_cfg.foreign_lna0_ctrl = 29,
79 .rf_switch = 17,
80 .board_cfg.rf_switch_uhf = 17,
82 [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2] = {
83 .name = "Hauppauge WinTV MiniCard",
84 .type = SMS_NOVA_B0,
85 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
86 .lna_ctrl = -1,
88 [SMS1XXX_BOARD_SIANO_NICE] = {
89 /* 11 */
90 .name = "Siano Nice Digital Receiver",
91 .type = SMS_NOVA_B0,
93 [SMS1XXX_BOARD_SIANO_VENICE] = {
94 /* 12 */
95 .name = "Siano Venice Digital Receiver",
96 .type = SMS_VEGA,
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 struct smscore_gpio_config MyGpioConfig;
121 sms_gpio_assign_11xx_default_led_config(&MyGpioConfig);
123 switch (gevent) {
124 case BOARD_EVENT_POWER_INIT: /* including hotplug */
125 break; /* BOARD_EVENT_BIND */
127 case BOARD_EVENT_POWER_SUSPEND:
128 break; /* BOARD_EVENT_POWER_SUSPEND */
130 case BOARD_EVENT_POWER_RESUME:
131 break; /* BOARD_EVENT_POWER_RESUME */
133 case BOARD_EVENT_BIND:
134 break; /* BOARD_EVENT_BIND */
136 case BOARD_EVENT_SCAN_PROG:
137 break; /* BOARD_EVENT_SCAN_PROG */
138 case BOARD_EVENT_SCAN_COMP:
139 break; /* BOARD_EVENT_SCAN_COMP */
140 case BOARD_EVENT_EMERGENCY_WARNING_SIGNAL:
141 break; /* BOARD_EVENT_EMERGENCY_WARNING_SIGNAL */
142 case BOARD_EVENT_FE_LOCK:
143 break; /* BOARD_EVENT_FE_LOCK */
144 case BOARD_EVENT_FE_UNLOCK:
145 break; /* BOARD_EVENT_FE_UNLOCK */
146 case BOARD_EVENT_DEMOD_LOCK:
147 break; /* BOARD_EVENT_DEMOD_LOCK */
148 case BOARD_EVENT_DEMOD_UNLOCK:
149 break; /* BOARD_EVENT_DEMOD_UNLOCK */
150 case BOARD_EVENT_RECEPTION_MAX_4:
151 break; /* BOARD_EVENT_RECEPTION_MAX_4 */
152 case BOARD_EVENT_RECEPTION_3:
153 break; /* BOARD_EVENT_RECEPTION_3 */
154 case BOARD_EVENT_RECEPTION_2:
155 break; /* BOARD_EVENT_RECEPTION_2 */
156 case BOARD_EVENT_RECEPTION_1:
157 break; /* BOARD_EVENT_RECEPTION_1 */
158 case BOARD_EVENT_RECEPTION_LOST_0:
159 break; /* BOARD_EVENT_RECEPTION_LOST_0 */
160 case BOARD_EVENT_MULTIPLEX_OK:
161 break; /* BOARD_EVENT_MULTIPLEX_OK */
162 case BOARD_EVENT_MULTIPLEX_ERRORS:
163 break; /* BOARD_EVENT_MULTIPLEX_ERRORS */
165 default:
166 sms_err("Unknown SMS board event");
167 break;
169 return 0;
171 EXPORT_SYMBOL_GPL(sms_board_event);
173 static int sms_set_gpio(struct smscore_device_t *coredev, int pin, int enable)
175 int lvl, ret;
176 u32 gpio;
177 struct smscore_config_gpio gpioconfig = {
178 .direction = SMS_GPIO_DIRECTION_OUTPUT,
179 .pullupdown = SMS_GPIO_PULLUPDOWN_NONE,
180 .inputcharacteristics = SMS_GPIO_INPUTCHARACTERISTICS_NORMAL,
181 .outputslewrate = SMS_GPIO_OUTPUTSLEWRATE_FAST,
182 .outputdriving = SMS_GPIO_OUTPUTDRIVING_4mA,
185 if (pin == 0)
186 return -EINVAL;
188 if (pin < 0) {
189 /* inverted gpio */
190 gpio = pin * -1;
191 lvl = enable ? 0 : 1;
192 } else {
193 gpio = pin;
194 lvl = enable ? 1 : 0;
197 ret = smscore_configure_gpio(coredev, gpio, &gpioconfig);
198 if (ret < 0)
199 return ret;
201 return smscore_set_gpio(coredev, gpio, lvl);
204 int sms_board_setup(struct smscore_device_t *coredev)
206 int board_id = smscore_get_board_id(coredev);
207 struct sms_board *board = sms_get_board(board_id);
209 switch (board_id) {
210 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
211 /* turn off all LEDs */
212 sms_set_gpio(coredev, board->led_power, 0);
213 sms_set_gpio(coredev, board->led_hi, 0);
214 sms_set_gpio(coredev, board->led_lo, 0);
215 break;
216 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
217 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD:
218 /* turn off LNA */
219 sms_set_gpio(coredev, board->lna_ctrl, 0);
220 break;
222 return 0;
224 EXPORT_SYMBOL_GPL(sms_board_setup);
226 int sms_board_power(struct smscore_device_t *coredev, int onoff)
228 int board_id = smscore_get_board_id(coredev);
229 struct sms_board *board = sms_get_board(board_id);
231 switch (board_id) {
232 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
233 /* power LED */
234 sms_set_gpio(coredev,
235 board->led_power, onoff ? 1 : 0);
236 break;
237 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
238 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD:
239 /* LNA */
240 if (!onoff)
241 sms_set_gpio(coredev, board->lna_ctrl, 0);
242 break;
244 return 0;
246 EXPORT_SYMBOL_GPL(sms_board_power);
248 int sms_board_led_feedback(struct smscore_device_t *coredev, int led)
250 int board_id = smscore_get_board_id(coredev);
251 struct sms_board *board = sms_get_board(board_id);
253 /* dont touch GPIO if LEDs are already set */
254 if (smscore_led_state(coredev, -1) == led)
255 return 0;
257 switch (board_id) {
258 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
259 sms_set_gpio(coredev,
260 board->led_lo, (led & SMS_LED_LO) ? 1 : 0);
261 sms_set_gpio(coredev,
262 board->led_hi, (led & SMS_LED_HI) ? 1 : 0);
264 smscore_led_state(coredev, led);
265 break;
267 return 0;
269 EXPORT_SYMBOL_GPL(sms_board_led_feedback);
271 int sms_board_lna_control(struct smscore_device_t *coredev, int onoff)
273 int board_id = smscore_get_board_id(coredev);
274 struct sms_board *board = sms_get_board(board_id);
276 sms_debug("%s: LNA %s", __func__, onoff ? "enabled" : "disabled");
278 switch (board_id) {
279 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
280 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD:
281 sms_set_gpio(coredev,
282 board->rf_switch, onoff ? 1 : 0);
283 return sms_set_gpio(coredev,
284 board->lna_ctrl, onoff ? 1 : 0);
286 return -EINVAL;
288 EXPORT_SYMBOL_GPL(sms_board_lna_control);
290 int sms_board_load_modules(int id)
292 switch (id) {
293 case SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT:
294 case SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A:
295 case SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B:
296 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
297 request_module("smsdvb");
298 break;
299 default:
300 /* do nothing */
301 break;
303 return 0;
305 EXPORT_SYMBOL_GPL(sms_board_load_modules);