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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include "lgdt3306a.h"
31 #define DRIVER_NAME "saa7164"
33 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
35 /* addr is in the card struct, get it from there */
36 static struct tda10048_config hauppauge_hvr2200_1_config
= {
37 .demod_address
= 0x10 >> 1,
38 .output_mode
= TDA10048_SERIAL_OUTPUT
,
39 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
40 .inversion
= TDA10048_INVERSION_ON
,
41 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
42 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
43 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
44 .clk_freq_khz
= TDA10048_CLK_16000
,
46 static struct tda10048_config hauppauge_hvr2200_2_config
= {
47 .demod_address
= 0x12 >> 1,
48 .output_mode
= TDA10048_SERIAL_OUTPUT
,
49 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
50 .inversion
= TDA10048_INVERSION_ON
,
51 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
52 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
53 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
54 .clk_freq_khz
= TDA10048_CLK_16000
,
57 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
58 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 3,
59 .if_lvl
= 6, .rfagc_top
= 0x37 },
60 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
61 .if_lvl
= 6, .rfagc_top
= 0x37 },
64 static struct tda18271_config hauppauge_hvr22x0_tuner_config
= {
65 .std_map
= &hauppauge_tda18271_std_map
,
66 .gate
= TDA18271_GATE_ANALOG
,
67 .role
= TDA18271_MASTER
,
70 static struct tda18271_config hauppauge_hvr22x0s_tuner_config
= {
71 .std_map
= &hauppauge_tda18271_std_map
,
72 .gate
= TDA18271_GATE_ANALOG
,
73 .role
= TDA18271_SLAVE
,
74 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
75 .rf_cal_on_startup
= 1
78 static struct s5h1411_config hauppauge_s5h1411_config
= {
79 .output_mode
= S5H1411_SERIAL_OUTPUT
,
80 .gpio
= S5H1411_GPIO_ON
,
81 .qam_if
= S5H1411_IF_4000
,
82 .vsb_if
= S5H1411_IF_3250
,
83 .inversion
= S5H1411_INVERSION_ON
,
84 .status_mode
= S5H1411_DEMODLOCKING
,
85 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
88 static struct lgdt3306a_config hauppauge_hvr2255a_config
= {
89 .i2c_addr
= 0xb2 >> 1,
92 .deny_i2c_rptr
= 1, /* Disabled */
93 .spectral_inversion
= 0, /* Disabled */
94 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
95 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
96 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
97 .xtalMHz
= 25, /* 24 or 25 */
100 static struct lgdt3306a_config hauppauge_hvr2255b_config
= {
101 .i2c_addr
= 0x1c >> 1,
104 .deny_i2c_rptr
= 1, /* Disabled */
105 .spectral_inversion
= 0, /* Disabled */
106 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
107 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
108 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
109 .xtalMHz
= 25, /* 24 or 25 */
112 static struct si2157_config hauppauge_hvr2255_tuner_config
= {
117 static int si2157_attach(struct saa7164_port
*port
, struct i2c_adapter
*adapter
,
118 struct dvb_frontend
*fe
, u8 addr8bit
, struct si2157_config
*cfg
)
120 struct i2c_board_info bi
;
121 struct i2c_client
*tuner
;
125 memset(&bi
, 0, sizeof(bi
));
127 strlcpy(bi
.type
, "si2157", I2C_NAME_SIZE
);
128 bi
.platform_data
= cfg
;
129 bi
.addr
= addr8bit
>> 1;
131 request_module(bi
.type
);
133 tuner
= i2c_new_device(adapter
, &bi
);
134 if (tuner
== NULL
|| tuner
->dev
.driver
== NULL
)
137 if (!try_module_get(tuner
->dev
.driver
->owner
)) {
138 i2c_unregister_device(tuner
);
142 port
->i2c_client_tuner
= tuner
;
147 static int saa7164_dvb_stop_port(struct saa7164_port
*port
)
149 struct saa7164_dev
*dev
= port
->dev
;
152 ret
= saa7164_api_transition_port(port
, SAA_DMASTATE_STOP
);
153 if ((ret
!= SAA_OK
) && (ret
!= SAA_ERR_ALREADY_STOPPED
)) {
154 printk(KERN_ERR
"%s() stop transition failed, ret = 0x%x\n",
158 dprintk(DBGLVL_DVB
, "%s() Stopped\n", __func__
);
165 static int saa7164_dvb_acquire_port(struct saa7164_port
*port
)
167 struct saa7164_dev
*dev
= port
->dev
;
170 ret
= saa7164_api_transition_port(port
, SAA_DMASTATE_ACQUIRE
);
171 if ((ret
!= SAA_OK
) && (ret
!= SAA_ERR_ALREADY_STOPPED
)) {
172 printk(KERN_ERR
"%s() acquire transition failed, ret = 0x%x\n",
176 dprintk(DBGLVL_DVB
, "%s() Acquired\n", __func__
);
183 static int saa7164_dvb_pause_port(struct saa7164_port
*port
)
185 struct saa7164_dev
*dev
= port
->dev
;
188 ret
= saa7164_api_transition_port(port
, SAA_DMASTATE_PAUSE
);
189 if ((ret
!= SAA_OK
) && (ret
!= SAA_ERR_ALREADY_STOPPED
)) {
190 printk(KERN_ERR
"%s() pause transition failed, ret = 0x%x\n",
194 dprintk(DBGLVL_DVB
, "%s() Paused\n", __func__
);
201 /* Firmware is very windows centric, meaning you have to transition
202 * the part through AVStream / KS Windows stages, forwards or backwards.
203 * States are: stopped, acquired (h/w), paused, started.
205 static int saa7164_dvb_stop_streaming(struct saa7164_port
*port
)
207 struct saa7164_dev
*dev
= port
->dev
;
208 struct saa7164_buffer
*buf
;
209 struct list_head
*p
, *q
;
212 dprintk(DBGLVL_DVB
, "%s(port=%d)\n", __func__
, port
->nr
);
214 ret
= saa7164_dvb_pause_port(port
);
215 ret
= saa7164_dvb_acquire_port(port
);
216 ret
= saa7164_dvb_stop_port(port
);
218 /* Mark the hardware buffers as free */
219 mutex_lock(&port
->dmaqueue_lock
);
220 list_for_each_safe(p
, q
, &port
->dmaqueue
.list
) {
221 buf
= list_entry(p
, struct saa7164_buffer
, list
);
222 buf
->flags
= SAA7164_BUFFER_FREE
;
224 mutex_unlock(&port
->dmaqueue_lock
);
229 static int saa7164_dvb_start_port(struct saa7164_port
*port
)
231 struct saa7164_dev
*dev
= port
->dev
;
234 dprintk(DBGLVL_DVB
, "%s(port=%d)\n", __func__
, port
->nr
);
236 saa7164_buffer_cfg_port(port
);
238 /* Acquire the hardware */
239 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_ACQUIRE
);
240 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
241 printk(KERN_ERR
"%s() acquire transition failed, res = 0x%x\n",
244 /* Stop the hardware, regardless */
245 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_STOP
);
246 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
247 printk(KERN_ERR
"%s() acquire/forced stop transition "
248 "failed, res = 0x%x\n", __func__
, result
);
253 dprintk(DBGLVL_DVB
, "%s() Acquired\n", __func__
);
255 /* Pause the hardware */
256 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_PAUSE
);
257 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
258 printk(KERN_ERR
"%s() pause transition failed, res = 0x%x\n",
261 /* Stop the hardware, regardless */
262 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_STOP
);
263 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
264 printk(KERN_ERR
"%s() pause/forced stop transition "
265 "failed, res = 0x%x\n", __func__
, result
);
271 dprintk(DBGLVL_DVB
, "%s() Paused\n", __func__
);
273 /* Start the hardware */
274 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_RUN
);
275 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
276 printk(KERN_ERR
"%s() run transition failed, result = 0x%x\n",
279 /* Stop the hardware, regardless */
280 result
= saa7164_api_transition_port(port
, SAA_DMASTATE_STOP
);
281 if ((result
!= SAA_OK
) && (result
!= SAA_ERR_ALREADY_STOPPED
)) {
282 printk(KERN_ERR
"%s() run/forced stop transition "
283 "failed, res = 0x%x\n", __func__
, result
);
288 dprintk(DBGLVL_DVB
, "%s() Running\n", __func__
);
294 static int saa7164_dvb_start_feed(struct dvb_demux_feed
*feed
)
296 struct dvb_demux
*demux
= feed
->demux
;
297 struct saa7164_port
*port
= (struct saa7164_port
*) demux
->priv
;
298 struct saa7164_dvb
*dvb
= &port
->dvb
;
299 struct saa7164_dev
*dev
= port
->dev
;
302 dprintk(DBGLVL_DVB
, "%s(port=%d)\n", __func__
, port
->nr
);
304 if (!demux
->dmx
.frontend
)
308 mutex_lock(&dvb
->lock
);
309 if (dvb
->feeding
++ == 0) {
310 /* Start transport */
311 ret
= saa7164_dvb_start_port(port
);
313 mutex_unlock(&dvb
->lock
);
314 dprintk(DBGLVL_DVB
, "%s(port=%d) now feeding = %d\n",
315 __func__
, port
->nr
, dvb
->feeding
);
321 static int saa7164_dvb_stop_feed(struct dvb_demux_feed
*feed
)
323 struct dvb_demux
*demux
= feed
->demux
;
324 struct saa7164_port
*port
= (struct saa7164_port
*) demux
->priv
;
325 struct saa7164_dvb
*dvb
= &port
->dvb
;
326 struct saa7164_dev
*dev
= port
->dev
;
329 dprintk(DBGLVL_DVB
, "%s(port=%d)\n", __func__
, port
->nr
);
332 mutex_lock(&dvb
->lock
);
333 if (--dvb
->feeding
== 0) {
335 ret
= saa7164_dvb_stop_streaming(port
);
337 mutex_unlock(&dvb
->lock
);
338 dprintk(DBGLVL_DVB
, "%s(port=%d) now feeding = %d\n",
339 __func__
, port
->nr
, dvb
->feeding
);
345 static int dvb_register(struct saa7164_port
*port
)
347 struct saa7164_dvb
*dvb
= &port
->dvb
;
348 struct saa7164_dev
*dev
= port
->dev
;
349 struct saa7164_buffer
*buf
;
352 dprintk(DBGLVL_DVB
, "%s(port=%d)\n", __func__
, port
->nr
);
354 if (port
->type
!= SAA7164_MPEG_DVB
)
357 /* Sanity check that the PCI configuration space is active */
358 if (port
->hwcfg
.BARLocation
== 0) {
360 printk(KERN_ERR
"%s: dvb_register_adapter failed "
361 "(errno = %d), NO PCI configuration\n",
362 DRIVER_NAME
, result
);
366 /* Init and establish defaults */
367 port
->hw_streamingparams
.bitspersample
= 8;
368 port
->hw_streamingparams
.samplesperline
= 188;
369 port
->hw_streamingparams
.numberoflines
=
370 (SAA7164_TS_NUMBER_OF_LINES
* 188) / 188;
372 port
->hw_streamingparams
.pitch
= 188;
373 port
->hw_streamingparams
.linethreshold
= 0;
374 port
->hw_streamingparams
.pagetablelistvirt
= NULL
;
375 port
->hw_streamingparams
.pagetablelistphys
= NULL
;
376 port
->hw_streamingparams
.numpagetables
= 2 +
377 ((SAA7164_TS_NUMBER_OF_LINES
* 188) / PAGE_SIZE
);
379 port
->hw_streamingparams
.numpagetableentries
= port
->hwcfg
.buffercount
;
381 /* Allocate the PCI resources */
382 for (i
= 0; i
< port
->hwcfg
.buffercount
; i
++) {
383 buf
= saa7164_buffer_alloc(port
,
384 port
->hw_streamingparams
.numberoflines
*
385 port
->hw_streamingparams
.pitch
);
389 printk(KERN_ERR
"%s: dvb_register_adapter failed "
390 "(errno = %d), unable to allocate buffers\n",
391 DRIVER_NAME
, result
);
395 mutex_lock(&port
->dmaqueue_lock
);
396 list_add_tail(&buf
->list
, &port
->dmaqueue
.list
);
397 mutex_unlock(&port
->dmaqueue_lock
);
400 /* register adapter */
401 result
= dvb_register_adapter(&dvb
->adapter
, DRIVER_NAME
, THIS_MODULE
,
402 &dev
->pci
->dev
, adapter_nr
);
404 printk(KERN_ERR
"%s: dvb_register_adapter failed "
405 "(errno = %d)\n", DRIVER_NAME
, result
);
408 dvb
->adapter
.priv
= port
;
410 /* register frontend */
411 result
= dvb_register_frontend(&dvb
->adapter
, dvb
->frontend
);
413 printk(KERN_ERR
"%s: dvb_register_frontend failed "
414 "(errno = %d)\n", DRIVER_NAME
, result
);
418 /* register demux stuff */
419 dvb
->demux
.dmx
.capabilities
=
420 DMX_TS_FILTERING
| DMX_SECTION_FILTERING
|
421 DMX_MEMORY_BASED_FILTERING
;
422 dvb
->demux
.priv
= port
;
423 dvb
->demux
.filternum
= 256;
424 dvb
->demux
.feednum
= 256;
425 dvb
->demux
.start_feed
= saa7164_dvb_start_feed
;
426 dvb
->demux
.stop_feed
= saa7164_dvb_stop_feed
;
427 result
= dvb_dmx_init(&dvb
->demux
);
429 printk(KERN_ERR
"%s: dvb_dmx_init failed (errno = %d)\n",
430 DRIVER_NAME
, result
);
434 dvb
->dmxdev
.filternum
= 256;
435 dvb
->dmxdev
.demux
= &dvb
->demux
.dmx
;
436 dvb
->dmxdev
.capabilities
= 0;
437 result
= dvb_dmxdev_init(&dvb
->dmxdev
, &dvb
->adapter
);
439 printk(KERN_ERR
"%s: dvb_dmxdev_init failed (errno = %d)\n",
440 DRIVER_NAME
, result
);
444 dvb
->fe_hw
.source
= DMX_FRONTEND_0
;
445 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
447 printk(KERN_ERR
"%s: add_frontend failed "
448 "(DMX_FRONTEND_0, errno = %d)\n", DRIVER_NAME
, result
);
452 dvb
->fe_mem
.source
= DMX_MEMORY_FE
;
453 result
= dvb
->demux
.dmx
.add_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
455 printk(KERN_ERR
"%s: add_frontend failed "
456 "(DMX_MEMORY_FE, errno = %d)\n", DRIVER_NAME
, result
);
460 result
= dvb
->demux
.dmx
.connect_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
462 printk(KERN_ERR
"%s: connect_frontend failed (errno = %d)\n",
463 DRIVER_NAME
, result
);
467 /* register network adapter */
468 dvb_net_init(&dvb
->adapter
, &dvb
->net
, &dvb
->demux
.dmx
);
472 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
474 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
476 dvb_dmxdev_release(&dvb
->dmxdev
);
478 dvb_dmx_release(&dvb
->demux
);
480 dvb_unregister_frontend(dvb
->frontend
);
482 dvb_frontend_detach(dvb
->frontend
);
483 dvb_unregister_adapter(&dvb
->adapter
);
488 int saa7164_dvb_unregister(struct saa7164_port
*port
)
490 struct saa7164_dvb
*dvb
= &port
->dvb
;
491 struct saa7164_dev
*dev
= port
->dev
;
492 struct saa7164_buffer
*b
;
493 struct list_head
*c
, *n
;
494 struct i2c_client
*client
;
496 dprintk(DBGLVL_DVB
, "%s()\n", __func__
);
498 if (port
->type
!= SAA7164_MPEG_DVB
)
501 /* Remove any allocated buffers */
502 mutex_lock(&port
->dmaqueue_lock
);
503 list_for_each_safe(c
, n
, &port
->dmaqueue
.list
) {
504 b
= list_entry(c
, struct saa7164_buffer
, list
);
506 saa7164_buffer_dealloc(b
);
508 mutex_unlock(&port
->dmaqueue_lock
);
510 if (dvb
->frontend
== NULL
)
513 /* remove I2C client for tuner */
514 client
= port
->i2c_client_tuner
;
516 module_put(client
->dev
.driver
->owner
);
517 i2c_unregister_device(client
);
520 /* remove I2C client for demodulator */
521 client
= port
->i2c_client_demod
;
523 module_put(client
->dev
.driver
->owner
);
524 i2c_unregister_device(client
);
527 dvb_net_release(&dvb
->net
);
528 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_mem
);
529 dvb
->demux
.dmx
.remove_frontend(&dvb
->demux
.dmx
, &dvb
->fe_hw
);
530 dvb_dmxdev_release(&dvb
->dmxdev
);
531 dvb_dmx_release(&dvb
->demux
);
532 dvb_unregister_frontend(dvb
->frontend
);
533 dvb_frontend_detach(dvb
->frontend
);
534 dvb_unregister_adapter(&dvb
->adapter
);
538 /* All the DVB attach calls go here, this function get's modified
541 int saa7164_dvb_register(struct saa7164_port
*port
)
543 struct saa7164_dev
*dev
= port
->dev
;
544 struct saa7164_dvb
*dvb
= &port
->dvb
;
545 struct saa7164_i2c
*i2c_bus
= NULL
;
546 struct si2168_config si2168_config
;
547 struct si2157_config si2157_config
;
548 struct i2c_adapter
*adapter
;
549 struct i2c_board_info info
;
550 struct i2c_client
*client_demod
;
551 struct i2c_client
*client_tuner
;
554 dprintk(DBGLVL_DVB
, "%s()\n", __func__
);
557 switch (dev
->board
) {
558 case SAA7164_BOARD_HAUPPAUGE_HVR2200
:
559 case SAA7164_BOARD_HAUPPAUGE_HVR2200_2
:
560 case SAA7164_BOARD_HAUPPAUGE_HVR2200_3
:
561 case SAA7164_BOARD_HAUPPAUGE_HVR2200_4
:
562 case SAA7164_BOARD_HAUPPAUGE_HVR2200_5
:
563 i2c_bus
= &dev
->i2c_bus
[port
->nr
+ 1];
566 port
->dvb
.frontend
= dvb_attach(tda10048_attach
,
567 &hauppauge_hvr2200_1_config
,
570 if (port
->dvb
.frontend
!= NULL
) {
571 /* TODO: addr is in the card struct */
572 dvb_attach(tda18271_attach
, port
->dvb
.frontend
,
573 0xc0 >> 1, &i2c_bus
->i2c_adap
,
574 &hauppauge_hvr22x0_tuner_config
);
579 port
->dvb
.frontend
= dvb_attach(tda10048_attach
,
580 &hauppauge_hvr2200_2_config
,
583 if (port
->dvb
.frontend
!= NULL
) {
584 /* TODO: addr is in the card struct */
585 dvb_attach(tda18271_attach
, port
->dvb
.frontend
,
586 0xc0 >> 1, &i2c_bus
->i2c_adap
,
587 &hauppauge_hvr22x0s_tuner_config
);
593 case SAA7164_BOARD_HAUPPAUGE_HVR2250
:
594 case SAA7164_BOARD_HAUPPAUGE_HVR2250_2
:
595 case SAA7164_BOARD_HAUPPAUGE_HVR2250_3
:
596 i2c_bus
= &dev
->i2c_bus
[port
->nr
+ 1];
598 port
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
599 &hauppauge_s5h1411_config
,
602 if (port
->dvb
.frontend
!= NULL
) {
604 /* Master TDA18271 */
605 /* TODO: addr is in the card struct */
606 dvb_attach(tda18271_attach
, port
->dvb
.frontend
,
607 0xc0 >> 1, &i2c_bus
->i2c_adap
,
608 &hauppauge_hvr22x0_tuner_config
);
611 dvb_attach(tda18271_attach
, port
->dvb
.frontend
,
612 0xc0 >> 1, &i2c_bus
->i2c_adap
,
613 &hauppauge_hvr22x0s_tuner_config
);
618 case SAA7164_BOARD_HAUPPAUGE_HVR2255proto
:
619 case SAA7164_BOARD_HAUPPAUGE_HVR2255
:
620 i2c_bus
= &dev
->i2c_bus
[2];
623 port
->dvb
.frontend
= dvb_attach(lgdt3306a_attach
,
624 &hauppauge_hvr2255a_config
, &i2c_bus
->i2c_adap
);
626 port
->dvb
.frontend
= dvb_attach(lgdt3306a_attach
,
627 &hauppauge_hvr2255b_config
, &i2c_bus
->i2c_adap
);
630 if (port
->dvb
.frontend
!= NULL
) {
633 si2157_attach(port
, &dev
->i2c_bus
[0].i2c_adap
,
634 port
->dvb
.frontend
, 0xc0,
635 &hauppauge_hvr2255_tuner_config
);
637 si2157_attach(port
, &dev
->i2c_bus
[1].i2c_adap
,
638 port
->dvb
.frontend
, 0xc0,
639 &hauppauge_hvr2255_tuner_config
);
643 case SAA7164_BOARD_HAUPPAUGE_HVR2205
:
646 /* attach frontend */
647 memset(&si2168_config
, 0, sizeof(si2168_config
));
648 si2168_config
.i2c_adapter
= &adapter
;
649 si2168_config
.fe
= &port
->dvb
.frontend
;
650 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
651 memset(&info
, 0, sizeof(struct i2c_board_info
));
652 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
653 info
.addr
= 0xc8 >> 1;
654 info
.platform_data
= &si2168_config
;
655 request_module(info
.type
);
656 client_demod
= i2c_new_device(&dev
->i2c_bus
[2].i2c_adap
,
658 if (!client_demod
|| !client_demod
->dev
.driver
)
659 goto frontend_detach
;
661 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
662 i2c_unregister_device(client_demod
);
663 goto frontend_detach
;
665 port
->i2c_client_demod
= client_demod
;
668 memset(&si2157_config
, 0, sizeof(si2157_config
));
669 si2157_config
.if_port
= 1;
670 si2157_config
.fe
= port
->dvb
.frontend
;
671 memset(&info
, 0, sizeof(struct i2c_board_info
));
672 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
673 info
.addr
= 0xc0 >> 1;
674 info
.platform_data
= &si2157_config
;
675 request_module(info
.type
);
676 client_tuner
= i2c_new_device(&dev
->i2c_bus
[0].i2c_adap
,
678 if (!client_tuner
|| !client_tuner
->dev
.driver
) {
679 module_put(client_demod
->dev
.driver
->owner
);
680 i2c_unregister_device(client_demod
);
681 goto frontend_detach
;
683 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
684 i2c_unregister_device(client_tuner
);
685 module_put(client_demod
->dev
.driver
->owner
);
686 i2c_unregister_device(client_demod
);
687 goto frontend_detach
;
689 port
->i2c_client_tuner
= client_tuner
;
691 /* attach frontend */
692 memset(&si2168_config
, 0, sizeof(si2168_config
));
693 si2168_config
.i2c_adapter
= &adapter
;
694 si2168_config
.fe
= &port
->dvb
.frontend
;
695 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
696 memset(&info
, 0, sizeof(struct i2c_board_info
));
697 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
698 info
.addr
= 0xcc >> 1;
699 info
.platform_data
= &si2168_config
;
700 request_module(info
.type
);
701 client_demod
= i2c_new_device(&dev
->i2c_bus
[2].i2c_adap
,
703 if (!client_demod
|| !client_demod
->dev
.driver
)
704 goto frontend_detach
;
706 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
707 i2c_unregister_device(client_demod
);
708 goto frontend_detach
;
710 port
->i2c_client_demod
= client_demod
;
713 memset(&si2157_config
, 0, sizeof(si2157_config
));
714 si2157_config
.fe
= port
->dvb
.frontend
;
715 si2157_config
.if_port
= 1;
716 memset(&info
, 0, sizeof(struct i2c_board_info
));
717 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
718 info
.addr
= 0xc0 >> 1;
719 info
.platform_data
= &si2157_config
;
720 request_module(info
.type
);
721 client_tuner
= i2c_new_device(&dev
->i2c_bus
[1].i2c_adap
,
723 if (!client_tuner
|| !client_tuner
->dev
.driver
) {
724 module_put(client_demod
->dev
.driver
->owner
);
725 i2c_unregister_device(client_demod
);
726 goto frontend_detach
;
728 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
729 i2c_unregister_device(client_tuner
);
730 module_put(client_demod
->dev
.driver
->owner
);
731 i2c_unregister_device(client_demod
);
732 goto frontend_detach
;
734 port
->i2c_client_tuner
= client_tuner
;
739 printk(KERN_ERR
"%s: The frontend isn't supported\n",
743 if (NULL
== dvb
->frontend
) {
744 printk(KERN_ERR
"%s() Frontend initialization failed\n",
749 /* register everything */
750 ret
= dvb_register(port
);
752 if (dvb
->frontend
->ops
.release
)
753 dvb
->frontend
->ops
.release(dvb
->frontend
);
760 printk(KERN_ERR
"%s() Frontend/I2C initialization failed\n", __func__
);