2 * Driver for the NXP SAA7164 PCIe bridge
4 * Copyright (c) 2010-2015 Steven Toth <stoth@kernellabs.com>
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, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
25 #include "lgdt3306a.h"
27 #define DRIVER_NAME "saa7164"
29 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
31 /* addr is in the card struct, get it from there */
32 static struct tda10048_config hauppauge_hvr2200_1_config
= {
33 .demod_address
= 0x10 >> 1,
34 .output_mode
= TDA10048_SERIAL_OUTPUT
,
35 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
36 .inversion
= TDA10048_INVERSION_ON
,
37 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
38 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
39 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
40 .clk_freq_khz
= TDA10048_CLK_16000
,
42 static struct tda10048_config hauppauge_hvr2200_2_config
= {
43 .demod_address
= 0x12 >> 1,
44 .output_mode
= TDA10048_SERIAL_OUTPUT
,
45 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
46 .inversion
= TDA10048_INVERSION_ON
,
47 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
48 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
49 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
50 .clk_freq_khz
= TDA10048_CLK_16000
,
53 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
54 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 3,
55 .if_lvl
= 6, .rfagc_top
= 0x37 },
56 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
57 .if_lvl
= 6, .rfagc_top
= 0x37 },
60 static struct tda18271_config hauppauge_hvr22x0_tuner_config
= {
61 .std_map
= &hauppauge_tda18271_std_map
,
62 .gate
= TDA18271_GATE_ANALOG
,
63 .role
= TDA18271_MASTER
,
66 static struct tda18271_config hauppauge_hvr22x0s_tuner_config
= {
67 .std_map
= &hauppauge_tda18271_std_map
,
68 .gate
= TDA18271_GATE_ANALOG
,
69 .role
= TDA18271_SLAVE
,
70 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
71 .rf_cal_on_startup
= 1
74 static struct s5h1411_config hauppauge_s5h1411_config
= {
75 .output_mode
= S5H1411_SERIAL_OUTPUT
,
76 .gpio
= S5H1411_GPIO_ON
,
77 .qam_if
= S5H1411_IF_4000
,
78 .vsb_if
= S5H1411_IF_3250
,
79 .inversion
= S5H1411_INVERSION_ON
,
80 .status_mode
= S5H1411_DEMODLOCKING
,
81 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
84 static struct lgdt3306a_config hauppauge_hvr2255a_config
= {
85 .i2c_addr
= 0xb2 >> 1,
88 .deny_i2c_rptr
= 1, /* Disabled */
89 .spectral_inversion
= 0, /* Disabled */
90 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
91 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
92 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
93 .xtalMHz
= 25, /* 24 or 25 */
96 static struct lgdt3306a_config hauppauge_hvr2255b_config
= {
97 .i2c_addr
= 0x1c >> 1,
100 .deny_i2c_rptr
= 1, /* Disabled */
101 .spectral_inversion
= 0, /* Disabled */
102 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
103 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
104 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
105 .xtalMHz
= 25, /* 24 or 25 */
108 static struct si2157_config hauppauge_hvr2255_tuner_config
= {
113 static int si2157_attach(struct saa7164_port
*port
, struct i2c_adapter
*adapter
,
114 struct dvb_frontend
*fe
, u8 addr8bit
, struct si2157_config
*cfg
)
116 struct i2c_board_info bi
;
117 struct i2c_client
*tuner
;
121 memset(&bi
, 0, sizeof(bi
));
123 strlcpy(bi
.type
, "si2157", I2C_NAME_SIZE
);
124 bi
.platform_data
= cfg
;
125 bi
.addr
= addr8bit
>> 1;
127 request_module(bi
.type
);
129 tuner
= i2c_new_device(adapter
, &bi
);
130 if (tuner
== NULL
|| tuner
->dev
.driver
== NULL
)
133 if (!try_module_get(tuner
->dev
.driver
->owner
)) {
134 i2c_unregister_device(tuner
);
138 port
->i2c_client_tuner
= tuner
;
143 static int saa7164_dvb_stop_port(struct saa7164_port
*port
)
145 struct saa7164_dev
*dev
= port
->dev
;
148 ret
= saa7164_api_transition_port(port
, SAA_DMASTATE_STOP
);
149 if ((ret
!= SAA_OK
) && (ret
!= SAA_ERR_ALREADY_STOPPED
)) {
150 printk(KERN_ERR
"%s() stop transition failed, ret = 0x%x\n",
154 dprintk(DBGLVL_DVB
, "%s() Stopped\n", __func__
);
161 static int saa7164_dvb_acquire_port(struct saa7164_port
*port
)
163 struct saa7164_dev
*dev
= port
->dev
;
166 ret
= saa7164_api_transition_port(port
, SAA_DMASTATE_ACQUIRE
);
167 if ((ret
!= SAA_OK
) && (ret
!= SAA_ERR_ALREADY_STOPPED
)) {
168 printk(KERN_ERR
"%s() acquire transition failed, ret = 0x%x\n",
172 dprintk(DBGLVL_DVB
, "%s() Acquired\n", __func__
);
179 static int saa7164_dvb_pause_port(struct saa7164_port
*port
)
181 struct saa7164_dev
*dev
= port
->dev
;
184 ret
= saa7164_api_transition_port(port
, SAA_DMASTATE_PAUSE
);
185 if ((ret
!= SAA_OK
) && (ret
!= SAA_ERR_ALREADY_STOPPED
)) {
186 printk(KERN_ERR
"%s() pause transition failed, ret = 0x%x\n",
190 dprintk(DBGLVL_DVB
, "%s() Paused\n", __func__
);
197 /* Firmware is very windows centric, meaning you have to transition
198 * the part through AVStream / KS Windows stages, forwards or backwards.
199 * States are: stopped, acquired (h/w), paused, started.
201 static int saa7164_dvb_stop_streaming(struct saa7164_port
*port
)
203 struct saa7164_dev
*dev
= port
->dev
;
204 struct saa7164_buffer
*buf
;
205 struct list_head
*p
, *q
;
208 dprintk(DBGLVL_DVB
, "%s(port=%d)\n", __func__
, port
->nr
);
210 ret
= saa7164_dvb_pause_port(port
);
211 ret
= saa7164_dvb_acquire_port(port
);
212 ret
= saa7164_dvb_stop_port(port
);
214 /* Mark the hardware buffers as free */
215 mutex_lock(&port
->dmaqueue_lock
);
216 list_for_each_safe(p
, q
, &port
->dmaqueue
.list
) {
217 buf
= list_entry(p
, struct saa7164_buffer
, list
);
218 buf
->flags
= SAA7164_BUFFER_FREE
;
220 mutex_unlock(&port
->dmaqueue_lock
);
225 static int saa7164_dvb_start_port(struct saa7164_port
*port
)
227 struct saa7164_dev
*dev
= port
->dev
;
230 dprintk(DBGLVL_DVB
, "%s(port=%d)\n", __func__
, port
->nr
);
232 saa7164_buffer_cfg_port(port
);
234 /* Acquire the hardware */
235 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_ACQUIRE
);
236 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
237 printk(KERN_ERR
"%s() acquire transition failed, res = 0x%x\n",
240 /* Stop the hardware, regardless */
241 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_STOP
);
242 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
243 printk(KERN_ERR
"%s() acquire/forced stop transition failed, res = 0x%x\n",
249 dprintk(DBGLVL_DVB
, "%s() Acquired\n", __func__
);
251 /* Pause the hardware */
252 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_PAUSE
);
253 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
254 printk(KERN_ERR
"%s() pause transition failed, res = 0x%x\n",
257 /* Stop the hardware, regardless */
258 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_STOP
);
259 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
260 printk(KERN_ERR
"%s() pause/forced stop transition failed, res = 0x%x\n",
267 dprintk(DBGLVL_DVB
, "%s() Paused\n", __func__
);
269 /* Start the hardware */
270 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_RUN
);
271 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
272 printk(KERN_ERR
"%s() run transition failed, result = 0x%x\n",
275 /* Stop the hardware, regardless */
276 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_STOP
);
277 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
278 printk(KERN_ERR
"%s() run/forced stop transition failed, res = 0x%x\n",
284 dprintk(DBGLVL_DVB
, "%s() Running\n", __func__
);
290 static int saa7164_dvb_start_feed(struct dvb_demux_feed
*feed
)
292 struct dvb_demux
*demux
= feed
->demux
;
293 struct saa7164_port
*port
= (struct saa7164_port
*) demux
->priv
;
294 struct saa7164_dvb
*dvb
= &port
->dvb
;
295 struct saa7164_dev
*dev
= port
->dev
;
298 dprintk(DBGLVL_DVB
, "%s(port=%d)\n", __func__
, port
->nr
);
300 if (!demux
->dmx
.frontend
)
304 mutex_lock(&dvb
->lock
);
305 if (dvb
->feeding
++ == 0) {
306 /* Start transport */
307 ret
= saa7164_dvb_start_port(port
);
309 mutex_unlock(&dvb
->lock
);
310 dprintk(DBGLVL_DVB
, "%s(port=%d) now feeding = %d\n",
311 __func__
, port
->nr
, dvb
->feeding
);
317 static int saa7164_dvb_stop_feed(struct dvb_demux_feed
*feed
)
319 struct dvb_demux
*demux
= feed
->demux
;
320 struct saa7164_port
*port
= (struct saa7164_port
*) demux
->priv
;
321 struct saa7164_dvb
*dvb
= &port
->dvb
;
322 struct saa7164_dev
*dev
= port
->dev
;
325 dprintk(DBGLVL_DVB
, "%s(port=%d)\n", __func__
, port
->nr
);
328 mutex_lock(&dvb
->lock
);
329 if (--dvb
->feeding
== 0) {
331 ret
= saa7164_dvb_stop_streaming(port
);
333 mutex_unlock(&dvb
->lock
);
334 dprintk(DBGLVL_DVB
, "%s(port=%d) now feeding = %d\n",
335 __func__
, port
->nr
, dvb
->feeding
);
341 static int dvb_register(struct saa7164_port
*port
)
343 struct saa7164_dvb
*dvb
= &port
->dvb
;
344 struct saa7164_dev
*dev
= port
->dev
;
345 struct saa7164_buffer
*buf
;
348 dprintk(DBGLVL_DVB
, "%s(port=%d)\n", __func__
, port
->nr
);
350 if (port
->type
!= SAA7164_MPEG_DVB
)
353 /* Sanity check that the PCI configuration space is active */
354 if (port
->hwcfg
.BARLocation
== 0) {
356 printk(KERN_ERR
"%s: dvb_register_adapter failed (errno = %d), NO PCI configuration\n",
357 DRIVER_NAME
, result
);
361 /* Init and establish defaults */
362 port
->hw_streamingparams
.bitspersample
= 8;
363 port
->hw_streamingparams
.samplesperline
= 188;
364 port
->hw_streamingparams
.numberoflines
=
365 (SAA7164_TS_NUMBER_OF_LINES
* 188) / 188;
367 port
->hw_streamingparams
.pitch
= 188;
368 port
->hw_streamingparams
.linethreshold
= 0;
369 port
->hw_streamingparams
.pagetablelistvirt
= NULL
;
370 port
->hw_streamingparams
.pagetablelistphys
= NULL
;
371 port
->hw_streamingparams
.numpagetables
= 2 +
372 ((SAA7164_TS_NUMBER_OF_LINES
* 188) / PAGE_SIZE
);
374 port
->hw_streamingparams
.numpagetableentries
= port
->hwcfg
.buffercount
;
376 /* Allocate the PCI resources */
377 for (i
= 0; i
< port
->hwcfg
.buffercount
; i
++) {
378 buf
= saa7164_buffer_alloc(port
,
379 port
->hw_streamingparams
.numberoflines
*
380 port
->hw_streamingparams
.pitch
);
384 printk(KERN_ERR
"%s: dvb_register_adapter failed (errno = %d), unable to allocate buffers\n",
385 DRIVER_NAME
, result
);
389 mutex_lock(&port
->dmaqueue_lock
);
390 list_add_tail(&buf
->list
, &port
->dmaqueue
.list
);
391 mutex_unlock(&port
->dmaqueue_lock
);
394 /* register adapter */
395 result
= dvb_register_adapter(&dvb
->adapter
, DRIVER_NAME
, THIS_MODULE
,
396 &dev
->pci
->dev
, adapter_nr
);
398 printk(KERN_ERR
"%s: dvb_register_adapter failed (errno = %d)\n",
399 DRIVER_NAME
, result
);
402 dvb
->adapter
.priv
= port
;
404 /* register frontend */
405 result
= dvb_register_frontend(&dvb
->adapter
, dvb
->frontend
);
407 printk(KERN_ERR
"%s: dvb_register_frontend failed (errno = %d)\n",
408 DRIVER_NAME
, result
);
412 /* register demux stuff */
413 dvb
->demux
.dmx
.capabilities
=
414 DMX_TS_FILTERING
| DMX_SECTION_FILTERING
|
415 DMX_MEMORY_BASED_FILTERING
;
416 dvb
->demux
.priv
= port
;
417 dvb
->demux
.filternum
= 256;
418 dvb
->demux
.feednum
= 256;
419 dvb
->demux
.start_feed
= saa7164_dvb_start_feed
;
420 dvb
->demux
.stop_feed
= saa7164_dvb_stop_feed
;
421 result
= dvb_dmx_init(&dvb
->demux
);
423 printk(KERN_ERR
"%s: dvb_dmx_init failed (errno = %d)\n",
424 DRIVER_NAME
, result
);
428 dvb
->dmxdev
.filternum
= 256;
429 dvb
->dmxdev
.demux
= &dvb
->demux
.dmx
;
430 dvb
->dmxdev
.capabilities
= 0;
431 result
= dvb_dmxdev_init(&dvb
->dmxdev
, &dvb
->adapter
);
433 printk(KERN_ERR
"%s: dvb_dmxdev_init failed (errno = %d)\n",
434 DRIVER_NAME
, result
);
438 dvb
->fe_hw
.source
= DMX_FRONTEND_0
;
439 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
441 printk(KERN_ERR
"%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n",
442 DRIVER_NAME
, result
);
446 dvb
->fe_mem
.source
= DMX_MEMORY_FE
;
447 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
449 printk(KERN_ERR
"%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n",
450 DRIVER_NAME
, result
);
454 result
= dvb
->demux
.dmx
.connect_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
456 printk(KERN_ERR
"%s: connect_frontend failed (errno = %d)\n",
457 DRIVER_NAME
, result
);
461 /* register network adapter */
462 dvb_net_init(&dvb
->adapter
, &dvb
->net
, &dvb
->demux
.dmx
);
466 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
468 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
470 dvb_dmxdev_release(&dvb
->dmxdev
);
472 dvb_dmx_release(&dvb
->demux
);
474 dvb_unregister_frontend(dvb
->frontend
);
476 dvb_frontend_detach(dvb
->frontend
);
477 dvb_unregister_adapter(&dvb
->adapter
);
482 int saa7164_dvb_unregister(struct saa7164_port
*port
)
484 struct saa7164_dvb
*dvb
= &port
->dvb
;
485 struct saa7164_dev
*dev
= port
->dev
;
486 struct saa7164_buffer
*b
;
487 struct list_head
*c
, *n
;
488 struct i2c_client
*client
;
490 dprintk(DBGLVL_DVB
, "%s()\n", __func__
);
492 if (port
->type
!= SAA7164_MPEG_DVB
)
495 /* Remove any allocated buffers */
496 mutex_lock(&port
->dmaqueue_lock
);
497 list_for_each_safe(c
, n
, &port
->dmaqueue
.list
) {
498 b
= list_entry(c
, struct saa7164_buffer
, list
);
500 saa7164_buffer_dealloc(b
);
502 mutex_unlock(&port
->dmaqueue_lock
);
504 if (dvb
->frontend
== NULL
)
507 /* remove I2C client for tuner */
508 client
= port
->i2c_client_tuner
;
510 module_put(client
->dev
.driver
->owner
);
511 i2c_unregister_device(client
);
514 /* remove I2C client for demodulator */
515 client
= port
->i2c_client_demod
;
517 module_put(client
->dev
.driver
->owner
);
518 i2c_unregister_device(client
);
521 dvb_net_release(&dvb
->net
);
522 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
523 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
524 dvb_dmxdev_release(&dvb
->dmxdev
);
525 dvb_dmx_release(&dvb
->demux
);
526 dvb_unregister_frontend(dvb
->frontend
);
527 dvb_frontend_detach(dvb
->frontend
);
528 dvb_unregister_adapter(&dvb
->adapter
);
532 /* All the DVB attach calls go here, this function get's modified
535 int saa7164_dvb_register(struct saa7164_port
*port
)
537 struct saa7164_dev
*dev
= port
->dev
;
538 struct saa7164_dvb
*dvb
= &port
->dvb
;
539 struct saa7164_i2c
*i2c_bus
= NULL
;
540 struct si2168_config si2168_config
;
541 struct si2157_config si2157_config
;
542 struct i2c_adapter
*adapter
;
543 struct i2c_board_info info
;
544 struct i2c_client
*client_demod
;
545 struct i2c_client
*client_tuner
;
548 dprintk(DBGLVL_DVB
, "%s()\n", __func__
);
551 switch (dev
->board
) {
552 case SAA7164_BOARD_HAUPPAUGE_HVR2200
:
553 case SAA7164_BOARD_HAUPPAUGE_HVR2200_2
:
554 case SAA7164_BOARD_HAUPPAUGE_HVR2200_3
:
555 case SAA7164_BOARD_HAUPPAUGE_HVR2200_4
:
556 case SAA7164_BOARD_HAUPPAUGE_HVR2200_5
:
557 i2c_bus
= &dev
->i2c_bus
[port
->nr
+ 1];
560 port
->dvb
.frontend
= dvb_attach(tda10048_attach
,
561 &hauppauge_hvr2200_1_config
,
564 if (port
->dvb
.frontend
!= NULL
) {
565 /* TODO: addr is in the card struct */
566 dvb_attach(tda18271_attach
, port
->dvb
.frontend
,
567 0xc0 >> 1, &i2c_bus
->i2c_adap
,
568 &hauppauge_hvr22x0_tuner_config
);
573 port
->dvb
.frontend
= dvb_attach(tda10048_attach
,
574 &hauppauge_hvr2200_2_config
,
577 if (port
->dvb
.frontend
!= NULL
) {
578 /* TODO: addr is in the card struct */
579 dvb_attach(tda18271_attach
, port
->dvb
.frontend
,
580 0xc0 >> 1, &i2c_bus
->i2c_adap
,
581 &hauppauge_hvr22x0s_tuner_config
);
587 case SAA7164_BOARD_HAUPPAUGE_HVR2250
:
588 case SAA7164_BOARD_HAUPPAUGE_HVR2250_2
:
589 case SAA7164_BOARD_HAUPPAUGE_HVR2250_3
:
590 i2c_bus
= &dev
->i2c_bus
[port
->nr
+ 1];
592 port
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
593 &hauppauge_s5h1411_config
,
596 if (port
->dvb
.frontend
!= NULL
) {
598 /* Master TDA18271 */
599 /* TODO: addr is in the card struct */
600 dvb_attach(tda18271_attach
, port
->dvb
.frontend
,
601 0xc0 >> 1, &i2c_bus
->i2c_adap
,
602 &hauppauge_hvr22x0_tuner_config
);
605 dvb_attach(tda18271_attach
, port
->dvb
.frontend
,
606 0xc0 >> 1, &i2c_bus
->i2c_adap
,
607 &hauppauge_hvr22x0s_tuner_config
);
612 case SAA7164_BOARD_HAUPPAUGE_HVR2255proto
:
613 case SAA7164_BOARD_HAUPPAUGE_HVR2255
:
614 i2c_bus
= &dev
->i2c_bus
[2];
617 port
->dvb
.frontend
= dvb_attach(lgdt3306a_attach
,
618 &hauppauge_hvr2255a_config
, &i2c_bus
->i2c_adap
);
620 port
->dvb
.frontend
= dvb_attach(lgdt3306a_attach
,
621 &hauppauge_hvr2255b_config
, &i2c_bus
->i2c_adap
);
624 if (port
->dvb
.frontend
!= NULL
) {
627 si2157_attach(port
, &dev
->i2c_bus
[0].i2c_adap
,
628 port
->dvb
.frontend
, 0xc0,
629 &hauppauge_hvr2255_tuner_config
);
631 si2157_attach(port
, &dev
->i2c_bus
[1].i2c_adap
,
632 port
->dvb
.frontend
, 0xc0,
633 &hauppauge_hvr2255_tuner_config
);
637 case SAA7164_BOARD_HAUPPAUGE_HVR2205
:
640 /* attach frontend */
641 memset(&si2168_config
, 0, sizeof(si2168_config
));
642 si2168_config
.i2c_adapter
= &adapter
;
643 si2168_config
.fe
= &port
->dvb
.frontend
;
644 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
645 memset(&info
, 0, sizeof(struct i2c_board_info
));
646 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
647 info
.addr
= 0xc8 >> 1;
648 info
.platform_data
= &si2168_config
;
649 request_module(info
.type
);
650 client_demod
= i2c_new_device(&dev
->i2c_bus
[2].i2c_adap
,
652 if (!client_demod
|| !client_demod
->dev
.driver
)
653 goto frontend_detach
;
655 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
656 i2c_unregister_device(client_demod
);
657 goto frontend_detach
;
659 port
->i2c_client_demod
= client_demod
;
662 memset(&si2157_config
, 0, sizeof(si2157_config
));
663 si2157_config
.if_port
= 1;
664 si2157_config
.fe
= port
->dvb
.frontend
;
665 memset(&info
, 0, sizeof(struct i2c_board_info
));
666 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
667 info
.addr
= 0xc0 >> 1;
668 info
.platform_data
= &si2157_config
;
669 request_module(info
.type
);
670 client_tuner
= i2c_new_device(&dev
->i2c_bus
[0].i2c_adap
,
672 if (!client_tuner
|| !client_tuner
->dev
.driver
) {
673 module_put(client_demod
->dev
.driver
->owner
);
674 i2c_unregister_device(client_demod
);
675 goto frontend_detach
;
677 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
678 i2c_unregister_device(client_tuner
);
679 module_put(client_demod
->dev
.driver
->owner
);
680 i2c_unregister_device(client_demod
);
681 goto frontend_detach
;
683 port
->i2c_client_tuner
= client_tuner
;
685 /* attach frontend */
686 memset(&si2168_config
, 0, sizeof(si2168_config
));
687 si2168_config
.i2c_adapter
= &adapter
;
688 si2168_config
.fe
= &port
->dvb
.frontend
;
689 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
690 memset(&info
, 0, sizeof(struct i2c_board_info
));
691 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
692 info
.addr
= 0xcc >> 1;
693 info
.platform_data
= &si2168_config
;
694 request_module(info
.type
);
695 client_demod
= i2c_new_device(&dev
->i2c_bus
[2].i2c_adap
,
697 if (!client_demod
|| !client_demod
->dev
.driver
)
698 goto frontend_detach
;
700 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
701 i2c_unregister_device(client_demod
);
702 goto frontend_detach
;
704 port
->i2c_client_demod
= client_demod
;
707 memset(&si2157_config
, 0, sizeof(si2157_config
));
708 si2157_config
.fe
= port
->dvb
.frontend
;
709 si2157_config
.if_port
= 1;
710 memset(&info
, 0, sizeof(struct i2c_board_info
));
711 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
712 info
.addr
= 0xc0 >> 1;
713 info
.platform_data
= &si2157_config
;
714 request_module(info
.type
);
715 client_tuner
= i2c_new_device(&dev
->i2c_bus
[1].i2c_adap
,
717 if (!client_tuner
|| !client_tuner
->dev
.driver
) {
718 module_put(client_demod
->dev
.driver
->owner
);
719 i2c_unregister_device(client_demod
);
720 goto frontend_detach
;
722 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
723 i2c_unregister_device(client_tuner
);
724 module_put(client_demod
->dev
.driver
->owner
);
725 i2c_unregister_device(client_demod
);
726 goto frontend_detach
;
728 port
->i2c_client_tuner
= client_tuner
;
733 printk(KERN_ERR
"%s: The frontend isn't supported\n",
737 if (NULL
== dvb
->frontend
) {
738 printk(KERN_ERR
"%s() Frontend initialization failed\n",
743 /* register everything */
744 ret
= dvb_register(port
);
746 if (dvb
->frontend
->ops
.release
)
747 dvb
->frontend
->ops
.release(dvb
->frontend
);
754 printk(KERN_ERR
"%s() Frontend/I2C initialization failed\n", __func__
);