aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/ttpci/av7110.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/ttpci/av7110.c')
-rw-r--r--drivers/media/dvb/ttpci/av7110.c133
1 files changed, 92 insertions, 41 deletions
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 7dae91e5863c..8ce4146f55f1 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -133,7 +133,13 @@ static void init_av7110_av(struct av7110 *av7110)
133 /* remaining inits according to card and frontend type */ 133 /* remaining inits according to card and frontend type */
134 av7110->analog_tuner_flags = 0; 134 av7110->analog_tuner_flags = 0;
135 av7110->current_input = 0; 135 av7110->current_input = 0;
136 if (i2c_writereg(av7110, 0x20, 0x00, 0x00) == 1) { 136 if (dev->pci->subsystem_vendor == 0x13c2 && dev->pci->subsystem_device == 0x000a) {
137 printk("dvb-ttpci: MSP3415 audio DAC @ card %d\n",
138 av7110->dvb_adapter.num);
139 av7110->adac_type = DVB_ADAC_MSP34x5;
140 av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 0); // SPDIF on
141 }
142 else if (i2c_writereg(av7110, 0x20, 0x00, 0x00) == 1) {
137 printk ("dvb-ttpci: Crystal audio DAC @ card %d detected\n", 143 printk ("dvb-ttpci: Crystal audio DAC @ card %d detected\n",
138 av7110->dvb_adapter.num); 144 av7110->dvb_adapter.num);
139 av7110->adac_type = DVB_ADAC_CRYSTAL; 145 av7110->adac_type = DVB_ADAC_CRYSTAL;
@@ -156,10 +162,10 @@ static void init_av7110_av(struct av7110 *av7110)
156 else { 162 else {
157 av7110->adac_type = adac; 163 av7110->adac_type = adac;
158 printk("dvb-ttpci: adac type set to %d @ card %d\n", 164 printk("dvb-ttpci: adac type set to %d @ card %d\n",
159 av7110->dvb_adapter.num, av7110->adac_type); 165 av7110->adac_type, av7110->dvb_adapter.num);
160 } 166 }
161 167
162 if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP) { 168 if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP34x0) {
163 // switch DVB SCART on 169 // switch DVB SCART on
164 ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0); 170 ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0);
165 if (ret < 0) 171 if (ret < 0)
@@ -190,17 +196,15 @@ static void recover_arm(struct av7110 *av7110)
190 196
191 av7110_bootarm(av7110); 197 av7110_bootarm(av7110);
192 msleep(100); 198 msleep(100);
193 restart_feeds(av7110);
194 av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, av7110->ir_config);
195}
196 199
197static void arm_error(struct av7110 *av7110) 200 init_av7110_av(av7110);
198{ 201
199 dprintk(4, "%p\n",av7110); 202 /* card-specific recovery */
203 if (av7110->recover)
204 av7110->recover(av7110);
200 205
201 av7110->arm_errors++; 206 restart_feeds(av7110);
202 av7110->arm_ready = 0; 207 av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, av7110->ir_config);
203 recover_arm(av7110);
204} 208}
205 209
206static void av7110_arm_sync(struct av7110 *av7110) 210static void av7110_arm_sync(struct av7110 *av7110)
@@ -240,26 +244,22 @@ static int arm_thread(void *data)
240 244
241 if (down_interruptible(&av7110->dcomlock)) 245 if (down_interruptible(&av7110->dcomlock))
242 break; 246 break;
243
244 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2); 247 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2);
245 up(&av7110->dcomlock); 248 up(&av7110->dcomlock);
246 249
247 if (newloops == av7110->arm_loops) { 250 if (newloops == av7110->arm_loops || av7110->arm_errors > 3) {
248 printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n", 251 printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n",
249 av7110->dvb_adapter.num); 252 av7110->dvb_adapter.num);
250 253
251 arm_error(av7110); 254 recover_arm(av7110);
252 av7710_set_video_mode(av7110, vidmode);
253
254 init_av7110_av(av7110);
255 255
256 if (down_interruptible(&av7110->dcomlock)) 256 if (down_interruptible(&av7110->dcomlock))
257 break; 257 break;
258
259 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2) - 1; 258 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2) - 1;
260 up(&av7110->dcomlock); 259 up(&av7110->dcomlock);
261 } 260 }
262 av7110->arm_loops = newloops; 261 av7110->arm_loops = newloops;
262 av7110->arm_errors = 0;
263 } 263 }
264 264
265 av7110->arm_thread = NULL; 265 av7110->arm_thread = NULL;
@@ -510,10 +510,6 @@ static void gpioirq(unsigned long data)
510 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); 510 iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
511 511
512 av7110->video_size.h = h_ar & 0xfff; 512 av7110->video_size.h = h_ar & 0xfff;
513 dprintk(8, "GPIO0 irq: DATA_MPEG_VIDEO_EVENT: w/h/ar = %u/%u/%u\n",
514 av7110->video_size.w,
515 av7110->video_size.h,
516 av7110->video_size.aspect_ratio);
517 513
518 event.type = VIDEO_EVENT_SIZE_CHANGED; 514 event.type = VIDEO_EVENT_SIZE_CHANGED;
519 event.u.size.w = av7110->video_size.w; 515 event.u.size.w = av7110->video_size.w;
@@ -535,6 +531,11 @@ static void gpioirq(unsigned long data)
535 event.u.size.aspect_ratio = VIDEO_FORMAT_4_3; 531 event.u.size.aspect_ratio = VIDEO_FORMAT_4_3;
536 av7110->videostate.video_format = VIDEO_FORMAT_4_3; 532 av7110->videostate.video_format = VIDEO_FORMAT_4_3;
537 } 533 }
534
535 dprintk(8, "GPIO0 irq: DATA_MPEG_VIDEO_EVENT: w/h/ar = %u/%u/%u\n",
536 av7110->video_size.w, av7110->video_size.h,
537 av7110->video_size.aspect_ratio);
538
538 dvb_video_add_event(av7110, &event); 539 dvb_video_add_event(av7110, &event);
539 break; 540 break;
540 } 541 }
@@ -714,6 +715,8 @@ static struct dvb_device dvbdev_osd = {
714static inline int SetPIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, 715static inline int SetPIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
715 u16 subpid, u16 pcrpid) 716 u16 subpid, u16 pcrpid)
716{ 717{
718 u16 aflags = 0;
719
717 dprintk(4, "%p\n", av7110); 720 dprintk(4, "%p\n", av7110);
718 721
719 if (vpid == 0x1fff || apid == 0x1fff || 722 if (vpid == 0x1fff || apid == 0x1fff ||
@@ -725,8 +728,11 @@ static inline int SetPIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
725 av7110->pids[DMX_PES_PCR] = 0; 728 av7110->pids[DMX_PES_PCR] = 0;
726 } 729 }
727 730
728 return av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, MultiPID, 5, 731 if (av7110->audiostate.bypass_mode)
729 pcrpid, vpid, apid, ttpid, subpid); 732 aflags |= 0x8000;
733
734 return av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, MultiPID, 6,
735 pcrpid, vpid, apid, ttpid, subpid, aflags);
730} 736}
731 737
732int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid, 738int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
@@ -1043,7 +1049,7 @@ static void restart_feeds(struct av7110 *av7110)
1043 struct dvb_demux *dvbdmx = &av7110->demux; 1049 struct dvb_demux *dvbdmx = &av7110->demux;
1044 struct dvb_demux_feed *feed; 1050 struct dvb_demux_feed *feed;
1045 int mode; 1051 int mode;
1046 int i; 1052 int i, j;
1047 1053
1048 dprintk(4, "%p\n", av7110); 1054 dprintk(4, "%p\n", av7110);
1049 1055
@@ -1051,10 +1057,21 @@ static void restart_feeds(struct av7110 *av7110)
1051 av7110->playing = 0; 1057 av7110->playing = 0;
1052 av7110->rec_mode = 0; 1058 av7110->rec_mode = 0;
1053 1059
1054 for (i = 0; i < dvbdmx->filternum; i++) { 1060 for (i = 0; i < dvbdmx->feednum; i++) {
1055 feed = &dvbdmx->feed[i]; 1061 feed = &dvbdmx->feed[i];
1056 if (feed->state == DMX_STATE_GO) 1062 if (feed->state == DMX_STATE_GO) {
1063 if (feed->type == DMX_TYPE_SEC) {
1064 for (j = 0; j < dvbdmx->filternum; j++) {
1065 if (dvbdmx->filter[j].type != DMX_TYPE_SEC)
1066 continue;
1067 if (dvbdmx->filter[j].filter.parent != &feed->feed.sec)
1068 continue;
1069 if (dvbdmx->filter[j].state == DMX_STATE_GO)
1070 dvbdmx->filter[j].state = DMX_STATE_READY;
1071 }
1072 }
1057 av7110_start_feed(feed); 1073 av7110_start_feed(feed);
1074 }
1058 } 1075 }
1059 1076
1060 if (mode) 1077 if (mode)
@@ -1483,9 +1500,9 @@ static int get_firmware(struct av7110* av7110)
1483 if (ret == -ENOENT) { 1500 if (ret == -ENOENT) {
1484 printk(KERN_ERR "dvb-ttpci: could not load firmware," 1501 printk(KERN_ERR "dvb-ttpci: could not load firmware,"
1485 " file not found: dvb-ttpci-01.fw\n"); 1502 " file not found: dvb-ttpci-01.fw\n");
1486 printk(KERN_ERR "dvb-ttpci: usually this should be in" 1503 printk(KERN_ERR "dvb-ttpci: usually this should be in "
1487 " /usr/lib/hotplug/firmware\n"); 1504 "/usr/lib/hotplug/firmware or /lib/firmware\n");
1488 printk(KERN_ERR "dvb-ttpci: and can be downloaded here" 1505 printk(KERN_ERR "dvb-ttpci: and can be downloaded from"
1489 " http://www.linuxtv.org/download/dvb/firmware/\n"); 1506 " http://www.linuxtv.org/download/dvb/firmware/\n");
1490 } else 1507 } else
1491 printk(KERN_ERR "dvb-ttpci: cannot request firmware" 1508 printk(KERN_ERR "dvb-ttpci: cannot request firmware"
@@ -2110,8 +2127,10 @@ static int av7110_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_p
2110 struct av7110* av7110 = fe->dvb->priv; 2127 struct av7110* av7110 = fe->dvb->priv;
2111 2128
2112 int ret = av7110_fe_lock_fix(av7110, 0); 2129 int ret = av7110_fe_lock_fix(av7110, 0);
2113 if (!ret) 2130 if (!ret) {
2131 av7110->saved_fe_params = *params;
2114 ret = av7110->fe_set_frontend(fe, params); 2132 ret = av7110->fe_set_frontend(fe, params);
2133 }
2115 return ret; 2134 return ret;
2116} 2135}
2117 2136
@@ -2153,8 +2172,10 @@ static int av7110_fe_diseqc_send_master_cmd(struct dvb_frontend* fe,
2153 struct av7110* av7110 = fe->dvb->priv; 2172 struct av7110* av7110 = fe->dvb->priv;
2154 2173
2155 int ret = av7110_fe_lock_fix(av7110, 0); 2174 int ret = av7110_fe_lock_fix(av7110, 0);
2156 if (!ret) 2175 if (!ret) {
2176 av7110->saved_master_cmd = *cmd;
2157 ret = av7110->fe_diseqc_send_master_cmd(fe, cmd); 2177 ret = av7110->fe_diseqc_send_master_cmd(fe, cmd);
2178 }
2158 return ret; 2179 return ret;
2159} 2180}
2160 2181
@@ -2163,8 +2184,10 @@ static int av7110_fe_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_
2163 struct av7110* av7110 = fe->dvb->priv; 2184 struct av7110* av7110 = fe->dvb->priv;
2164 2185
2165 int ret = av7110_fe_lock_fix(av7110, 0); 2186 int ret = av7110_fe_lock_fix(av7110, 0);
2166 if (!ret) 2187 if (!ret) {
2188 av7110->saved_minicmd = minicmd;
2167 ret = av7110->fe_diseqc_send_burst(fe, minicmd); 2189 ret = av7110->fe_diseqc_send_burst(fe, minicmd);
2190 }
2168 return ret; 2191 return ret;
2169} 2192}
2170 2193
@@ -2173,8 +2196,10 @@ static int av7110_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
2173 struct av7110* av7110 = fe->dvb->priv; 2196 struct av7110* av7110 = fe->dvb->priv;
2174 2197
2175 int ret = av7110_fe_lock_fix(av7110, 0); 2198 int ret = av7110_fe_lock_fix(av7110, 0);
2176 if (!ret) 2199 if (!ret) {
2200 av7110->saved_tone = tone;
2177 ret = av7110->fe_set_tone(fe, tone); 2201 ret = av7110->fe_set_tone(fe, tone);
2202 }
2178 return ret; 2203 return ret;
2179} 2204}
2180 2205
@@ -2183,12 +2208,14 @@ static int av7110_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t volta
2183 struct av7110* av7110 = fe->dvb->priv; 2208 struct av7110* av7110 = fe->dvb->priv;
2184 2209
2185 int ret = av7110_fe_lock_fix(av7110, 0); 2210 int ret = av7110_fe_lock_fix(av7110, 0);
2186 if (!ret) 2211 if (!ret) {
2212 av7110->saved_voltage = voltage;
2187 ret = av7110->fe_set_voltage(fe, voltage); 2213 ret = av7110->fe_set_voltage(fe, voltage);
2214 }
2188 return ret; 2215 return ret;
2189} 2216}
2190 2217
2191static int av7110_fe_dishnetwork_send_legacy_command(struct dvb_frontend* fe, unsigned int cmd) 2218static int av7110_fe_dishnetwork_send_legacy_command(struct dvb_frontend* fe, unsigned long cmd)
2192{ 2219{
2193 struct av7110* av7110 = fe->dvb->priv; 2220 struct av7110* av7110 = fe->dvb->priv;
2194 2221
@@ -2198,6 +2225,23 @@ static int av7110_fe_dishnetwork_send_legacy_command(struct dvb_frontend* fe, un
2198 return ret; 2225 return ret;
2199} 2226}
2200 2227
2228static void dvb_s_recover(struct av7110* av7110)
2229{
2230 av7110_fe_init(av7110->fe);
2231
2232 av7110_fe_set_voltage(av7110->fe, av7110->saved_voltage);
2233 if (av7110->saved_master_cmd.msg_len) {
2234 msleep(20);
2235 av7110_fe_diseqc_send_master_cmd(av7110->fe, &av7110->saved_master_cmd);
2236 }
2237 msleep(20);
2238 av7110_fe_diseqc_send_burst(av7110->fe, av7110->saved_minicmd);
2239 msleep(20);
2240 av7110_fe_set_tone(av7110->fe, av7110->saved_tone);
2241
2242 av7110_fe_set_frontend(av7110->fe, &av7110->saved_fe_params);
2243}
2244
2201static u8 read_pwm(struct av7110* av7110) 2245static u8 read_pwm(struct av7110* av7110)
2202{ 2246{
2203 u8 b = 0xff; 2247 u8 b = 0xff;
@@ -2235,6 +2279,7 @@ static int frontend_init(struct av7110 *av7110)
2235 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2279 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2236 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst; 2280 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst;
2237 av7110->fe->ops->set_tone = av7110_set_tone; 2281 av7110->fe->ops->set_tone = av7110_set_tone;
2282 av7110->recover = dvb_s_recover;
2238 break; 2283 break;
2239 } 2284 }
2240 2285
@@ -2244,15 +2289,17 @@ static int frontend_init(struct av7110 *av7110)
2244 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2289 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2245 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst; 2290 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst;
2246 av7110->fe->ops->set_tone = av7110_set_tone; 2291 av7110->fe->ops->set_tone = av7110_set_tone;
2292 av7110->recover = dvb_s_recover;
2247 break; 2293 break;
2248 } 2294 }
2249 2295
2250 // Try the grundig 29504-451 2296 // Try the grundig 29504-451
2251 av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap); 2297 av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap);
2252 if (av7110->fe) { 2298 if (av7110->fe) {
2253 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2299 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2254 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst; 2300 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst;
2255 av7110->fe->ops->set_tone = av7110_set_tone; 2301 av7110->fe->ops->set_tone = av7110_set_tone;
2302 av7110->recover = dvb_s_recover;
2256 break; 2303 break;
2257 } 2304 }
2258 2305
@@ -2274,12 +2321,12 @@ static int frontend_init(struct av7110 *av7110)
2274 case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X 2321 case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X
2275 2322
2276 // ALPS TDLB7 2323 // ALPS TDLB7
2277 av7110->fe = sp8870_attach(&alps_tdlb7_config, &av7110->i2c_adap); 2324 av7110->fe = sp8870_attach(&alps_tdlb7_config, &av7110->i2c_adap);
2278 break; 2325 break;
2279 2326
2280 case 0x0002: // Hauppauge/TT DVB-C premium rev2.X 2327 case 0x0002: // Hauppauge/TT DVB-C premium rev2.X
2281 2328
2282 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110)); 2329 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110));
2283 break; 2330 break;
2284 2331
2285 case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */ 2332 case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */
@@ -2289,6 +2336,7 @@ static int frontend_init(struct av7110 *av7110)
2289 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2336 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2290 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst; 2337 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst;
2291 av7110->fe->ops->set_tone = av7110_set_tone; 2338 av7110->fe->ops->set_tone = av7110_set_tone;
2339 av7110->recover = dvb_s_recover;
2292 } 2340 }
2293 break; 2341 break;
2294 2342
@@ -2314,8 +2362,11 @@ static int frontend_init(struct av7110 *av7110)
2314 case 0x000E: /* Hauppauge/TT Nexus-S rev 2.3 */ 2362 case 0x000E: /* Hauppauge/TT Nexus-S rev 2.3 */
2315 /* ALPS BSBE1 */ 2363 /* ALPS BSBE1 */
2316 av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap); 2364 av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap);
2317 if (av7110->fe) 2365 if (av7110->fe) {
2318 av7110->fe->ops->set_voltage = lnbp21_set_voltage; 2366 av7110->fe->ops->set_voltage = lnbp21_set_voltage;
2367 av7110->fe->ops->dishnetwork_send_legacy_command = NULL;
2368 av7110->recover = dvb_s_recover;
2369 }
2319 break; 2370 break;
2320 } 2371 }
2321 } 2372 }