ASoC: tlv312aic23: unbreak resume
[zen-stable.git] / drivers / media / dvb / siano / sms-cards.c
blob680c781c8dd61edae199e3bbf572a0f2c97d90ef
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"
22 #include <linux/module.h>
24 static int sms_dbg;
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",
34 .type = SMS_STELLAR,
36 [SMS1XXX_BOARD_SIANO_NOVA_A] = {
37 .name = "Siano Nova A Digital Receiver",
38 .type = SMS_NOVA_A0,
40 [SMS1XXX_BOARD_SIANO_NOVA_B] = {
41 .name = "Siano Nova B Digital Receiver",
42 .type = SMS_NOVA_B0,
44 [SMS1XXX_BOARD_SIANO_VEGA] = {
45 .name = "Siano Vega Digital Receiver",
46 .type = SMS_VEGA,
48 [SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT] = {
49 .name = "Hauppauge Catamount",
50 .type = SMS_STELLAR,
51 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-stellar-dvbt-01.fw",
53 [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A] = {
54 .name = "Hauppauge Okemo-A",
55 .type = SMS_NOVA_A0,
56 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-nova-a-dvbt-01.fw",
58 [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B] = {
59 .name = "Hauppauge Okemo-B",
60 .type = SMS_NOVA_B0,
61 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-nova-b-dvbt-01.fw",
63 [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM] = {
64 .name = "Hauppauge WinTV MiniStick",
65 .type = SMS_NOVA_B0,
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,
70 .board_cfg.led0 = 27,
71 .board_cfg.led1 = 28,
72 .board_cfg.ir = 9,
73 .led_power = 26,
74 .led_lo = 27,
75 .led_hi = 28,
77 [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD] = {
78 .name = "Hauppauge WinTV MiniCard",
79 .type = SMS_NOVA_B0,
80 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
81 .lna_ctrl = 29,
82 .board_cfg.foreign_lna0_ctrl = 29,
83 .rf_switch = 17,
84 .board_cfg.rf_switch_uhf = 17,
86 [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2] = {
87 .name = "Hauppauge WinTV MiniCard",
88 .type = SMS_NOVA_B0,
89 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-02.fw",
90 .lna_ctrl = -1,
92 [SMS1XXX_BOARD_SIANO_NICE] = {
93 /* 11 */
94 .name = "Siano Nice Digital Receiver",
95 .type = SMS_NOVA_B0,
97 [SMS1XXX_BOARD_SIANO_VENICE] = {
98 /* 12 */
99 .name = "Siano Venice Digital Receiver",
100 .type = SMS_VEGA,
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);
127 switch (gevent) {
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 */
169 default:
170 sms_err("Unknown SMS board event");
171 break;
173 return 0;
175 EXPORT_SYMBOL_GPL(sms_board_event);
177 static int sms_set_gpio(struct smscore_device_t *coredev, int pin, int enable)
179 int lvl, ret;
180 u32 gpio;
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,
189 if (pin == 0)
190 return -EINVAL;
192 if (pin < 0) {
193 /* inverted gpio */
194 gpio = pin * -1;
195 lvl = enable ? 0 : 1;
196 } else {
197 gpio = pin;
198 lvl = enable ? 1 : 0;
201 ret = smscore_configure_gpio(coredev, gpio, &gpioconfig);
202 if (ret < 0)
203 return ret;
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);
213 switch (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);
219 break;
220 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
221 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD:
222 /* turn off LNA */
223 sms_set_gpio(coredev, board->lna_ctrl, 0);
224 break;
226 return 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);
235 switch (board_id) {
236 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
237 /* power LED */
238 sms_set_gpio(coredev,
239 board->led_power, onoff ? 1 : 0);
240 break;
241 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
242 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD:
243 /* LNA */
244 if (!onoff)
245 sms_set_gpio(coredev, board->lna_ctrl, 0);
246 break;
248 return 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)
259 return 0;
261 switch (board_id) {
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);
269 break;
271 return 0;
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");
282 switch (board_id) {
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);
290 return -EINVAL;
292 EXPORT_SYMBOL_GPL(sms_board_lna_control);
294 int sms_board_load_modules(int id)
296 switch (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");
304 break;
305 default:
306 /* do nothing */
307 break;
309 return 0;
311 EXPORT_SYMBOL_GPL(sms_board_load_modules);