.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * pvrusb2-dvb.c - linux-dvb api interface to the pvrusb2 driver. |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2007, 2008 Michael Krufky <mkrufky@linuxtv.org> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; either version 2 of the License |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, |
---|
11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | | - * GNU General Public License for more details. |
---|
14 | | - * |
---|
15 | 6 | */ |
---|
16 | 7 | |
---|
17 | 8 | #include <linux/kthread.h> |
---|
.. | .. |
---|
343 | 334 | goto done; |
---|
344 | 335 | } |
---|
345 | 336 | |
---|
346 | | - if ((dvb_props->frontend_attach(adap) == 0) && (adap->fe)) { |
---|
347 | | - |
---|
348 | | - if (dvb_register_frontend(&adap->dvb_adap, adap->fe)) { |
---|
| 337 | + if (dvb_props->frontend_attach(adap) == 0 && adap->fe[0]) { |
---|
| 338 | + if (dvb_register_frontend(&adap->dvb_adap, adap->fe[0])) { |
---|
349 | 339 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
---|
350 | 340 | "frontend registration failed!"); |
---|
351 | | - dvb_frontend_detach(adap->fe); |
---|
352 | | - adap->fe = NULL; |
---|
353 | 341 | ret = -ENODEV; |
---|
354 | | - goto done; |
---|
| 342 | + goto fail_frontend0; |
---|
355 | 343 | } |
---|
| 344 | + if (adap->fe[0]->ops.analog_ops.standby) |
---|
| 345 | + adap->fe[0]->ops.analog_ops.standby(adap->fe[0]); |
---|
356 | 346 | |
---|
357 | | - if (dvb_props->tuner_attach) |
---|
358 | | - dvb_props->tuner_attach(adap); |
---|
359 | | - |
---|
360 | | - if (adap->fe->ops.analog_ops.standby) |
---|
361 | | - adap->fe->ops.analog_ops.standby(adap->fe); |
---|
362 | | - |
---|
363 | | - /* Ensure all frontends negotiate bus access */ |
---|
364 | | - adap->fe->ops.ts_bus_ctrl = pvr2_dvb_bus_ctrl; |
---|
365 | | - |
---|
| 347 | + pvr2_trace(PVR2_TRACE_INFO, "transferring fe[%d] ts_bus_ctrl() to pvr2_dvb_bus_ctrl()", |
---|
| 348 | + adap->fe[0]->id); |
---|
| 349 | + adap->fe[0]->ops.ts_bus_ctrl = pvr2_dvb_bus_ctrl; |
---|
366 | 350 | } else { |
---|
367 | 351 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
---|
368 | 352 | "no frontend was attached!"); |
---|
.. | .. |
---|
370 | 354 | return ret; |
---|
371 | 355 | } |
---|
372 | 356 | |
---|
373 | | - done: |
---|
| 357 | + if (dvb_props->tuner_attach && dvb_props->tuner_attach(adap)) { |
---|
| 358 | + pvr2_trace(PVR2_TRACE_ERROR_LEGS, "tuner attach failed"); |
---|
| 359 | + ret = -ENODEV; |
---|
| 360 | + goto fail_tuner; |
---|
| 361 | + } |
---|
| 362 | + |
---|
| 363 | + if (adap->fe[1]) { |
---|
| 364 | + adap->fe[1]->id = 1; |
---|
| 365 | + adap->fe[1]->tuner_priv = adap->fe[0]->tuner_priv; |
---|
| 366 | + memcpy(&adap->fe[1]->ops.tuner_ops, |
---|
| 367 | + &adap->fe[0]->ops.tuner_ops, |
---|
| 368 | + sizeof(struct dvb_tuner_ops)); |
---|
| 369 | + |
---|
| 370 | + if (dvb_register_frontend(&adap->dvb_adap, adap->fe[1])) { |
---|
| 371 | + pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
---|
| 372 | + "frontend registration failed!"); |
---|
| 373 | + ret = -ENODEV; |
---|
| 374 | + goto fail_frontend1; |
---|
| 375 | + } |
---|
| 376 | + /* MFE lock */ |
---|
| 377 | + adap->dvb_adap.mfe_shared = 1; |
---|
| 378 | + |
---|
| 379 | + if (adap->fe[1]->ops.analog_ops.standby) |
---|
| 380 | + adap->fe[1]->ops.analog_ops.standby(adap->fe[1]); |
---|
| 381 | + |
---|
| 382 | + pvr2_trace(PVR2_TRACE_INFO, "transferring fe[%d] ts_bus_ctrl() to pvr2_dvb_bus_ctrl()", |
---|
| 383 | + adap->fe[1]->id); |
---|
| 384 | + adap->fe[1]->ops.ts_bus_ctrl = pvr2_dvb_bus_ctrl; |
---|
| 385 | + } |
---|
| 386 | +done: |
---|
374 | 387 | pvr2_channel_limit_inputs(&adap->channel, 0); |
---|
| 388 | + return ret; |
---|
| 389 | + |
---|
| 390 | +fail_frontend1: |
---|
| 391 | + dvb_frontend_detach(adap->fe[1]); |
---|
| 392 | + adap->fe[1] = NULL; |
---|
| 393 | +fail_tuner: |
---|
| 394 | + dvb_unregister_frontend(adap->fe[0]); |
---|
| 395 | +fail_frontend0: |
---|
| 396 | + dvb_frontend_detach(adap->fe[0]); |
---|
| 397 | + adap->fe[0] = NULL; |
---|
| 398 | + dvb_module_release(adap->i2c_client_tuner); |
---|
| 399 | + dvb_module_release(adap->i2c_client_demod[1]); |
---|
| 400 | + dvb_module_release(adap->i2c_client_demod[0]); |
---|
| 401 | + |
---|
375 | 402 | return ret; |
---|
376 | 403 | } |
---|
377 | 404 | |
---|
378 | 405 | static int pvr2_dvb_frontend_exit(struct pvr2_dvb_adapter *adap) |
---|
379 | 406 | { |
---|
380 | | - if (adap->fe != NULL) { |
---|
381 | | - dvb_unregister_frontend(adap->fe); |
---|
382 | | - dvb_frontend_detach(adap->fe); |
---|
| 407 | + if (adap->fe[1]) { |
---|
| 408 | + dvb_unregister_frontend(adap->fe[1]); |
---|
| 409 | + dvb_frontend_detach(adap->fe[1]); |
---|
| 410 | + adap->fe[1] = NULL; |
---|
383 | 411 | } |
---|
| 412 | + if (adap->fe[0]) { |
---|
| 413 | + dvb_unregister_frontend(adap->fe[0]); |
---|
| 414 | + dvb_frontend_detach(adap->fe[0]); |
---|
| 415 | + adap->fe[0] = NULL; |
---|
| 416 | + } |
---|
| 417 | + |
---|
| 418 | + dvb_module_release(adap->i2c_client_tuner); |
---|
| 419 | + adap->i2c_client_tuner = NULL; |
---|
| 420 | + dvb_module_release(adap->i2c_client_demod[1]); |
---|
| 421 | + adap->i2c_client_demod[1] = NULL; |
---|
| 422 | + dvb_module_release(adap->i2c_client_demod[0]); |
---|
| 423 | + adap->i2c_client_demod[0] = NULL; |
---|
| 424 | + |
---|
384 | 425 | return 0; |
---|
385 | 426 | } |
---|
386 | 427 | |
---|