diff options
author | Patrick Boettcher <pb@linuxtv.org> | 2006-09-19 11:51:33 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-10-03 14:12:27 -0400 |
commit | 136cafbf4a024b52ba0a10627217f03cea9ff9f8 (patch) | |
tree | cf827cb4d792a82a9c7b30bccc0db71547607472 /drivers/media/dvb/frontends | |
parent | 6870ab576c86a496869fbd5bb339da7e442ee7f5 (diff) |
V4L/DVB (4646): Misc. changes, DiB3000MC, MT2060
Changed the attach-function of the dib3000mc-driver to return only one
frontend. In case of multiple dib3000-chips on one board, one has to call the
i2c-enumeration manually before.
Added a field to Microtune 2060 config to output the clock to other
tuners/device on a board.
Signed-off-by: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/frontends')
-rw-r--r-- | drivers/media/dvb/frontends/dib3000mc.c | 147 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/dib3000mc.h | 8 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/mt2060.c | 7 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/mt2060.h | 2 |
4 files changed, 66 insertions, 98 deletions
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c index cc28417fa33..d7c4a98da12 100644 --- a/drivers/media/dvb/frontends/dib3000mc.c +++ b/drivers/media/dvb/frontends/dib3000mc.c | |||
@@ -584,56 +584,6 @@ static int dib3000mc_tune(struct dvb_frontend *demod, struct dibx000_ofdm_channe | |||
584 | return 0; | 584 | return 0; |
585 | } | 585 | } |
586 | 586 | ||
587 | static int dib3000mc_demod_output_mode(struct dvb_frontend *demod, int mode) | ||
588 | { | ||
589 | struct dib3000mc_state *state = demod->demodulator_priv; | ||
590 | return dib3000mc_set_output_mode(state, mode); | ||
591 | } | ||
592 | |||
593 | static int dib3000mc_i2c_enumeration(struct dvb_frontend *demod[], int no_of_demods, u8 default_addr) | ||
594 | { | ||
595 | struct dib3000mc_state *st; | ||
596 | int k,ret=0; | ||
597 | u8 new_addr; | ||
598 | |||
599 | static u8 DIB3000MC_I2C_ADDRESS[] = {20,22,24,26}; | ||
600 | |||
601 | for (k = no_of_demods-1; k >= 0; k--) { | ||
602 | st = demod[k]->demodulator_priv; | ||
603 | |||
604 | /* designated i2c address */ | ||
605 | new_addr = DIB3000MC_I2C_ADDRESS[k]; | ||
606 | |||
607 | st->i2c_addr = new_addr; | ||
608 | if (dib3000mc_identify(st) != 0) { | ||
609 | st->i2c_addr = default_addr; | ||
610 | if (dib3000mc_identify(st) != 0) { | ||
611 | dprintk("-E- DiB3000P/MC #%d: not identified\n", k); | ||
612 | return -EINVAL; | ||
613 | } | ||
614 | } | ||
615 | |||
616 | /* turn on div_out */ | ||
617 | dib3000mc_demod_output_mode(demod[k], OUTMODE_MPEG2_PAR_CONT_CLK); | ||
618 | |||
619 | // set new i2c address and force divstr (Bit 1) to value 0 (Bit 0) | ||
620 | ret |= dib3000mc_write_word(st, 1024, (new_addr << 3) | 0x1); | ||
621 | st->i2c_addr = new_addr; | ||
622 | } | ||
623 | |||
624 | for (k = 0; k < no_of_demods; k++) { | ||
625 | st = demod[k]->demodulator_priv; | ||
626 | |||
627 | ret |= dib3000mc_write_word(st, 1024, st->i2c_addr << 3); | ||
628 | |||
629 | /* turn off data output */ | ||
630 | dib3000mc_demod_output_mode(demod[k],OUTMODE_HIGH_Z); | ||
631 | dib3000mc_write_word(st, 769, (1 << 7) ); | ||
632 | |||
633 | } | ||
634 | return 0; | ||
635 | } | ||
636 | |||
637 | struct i2c_adapter * dib3000mc_get_tuner_i2c_master(struct dvb_frontend *demod, int gating) | 587 | struct i2c_adapter * dib3000mc_get_tuner_i2c_master(struct dvb_frontend *demod, int gating) |
638 | { | 588 | { |
639 | struct dib3000mc_state *st = demod->demodulator_priv; | 589 | struct dib3000mc_state *st = demod->demodulator_priv; |
@@ -826,61 +776,76 @@ void dib3000mc_set_config(struct dvb_frontend *fe, struct dib3000mc_config *cfg) | |||
826 | } | 776 | } |
827 | EXPORT_SYMBOL(dib3000mc_set_config); | 777 | EXPORT_SYMBOL(dib3000mc_set_config); |
828 | 778 | ||
829 | static struct dvb_frontend_ops dib3000mc_ops; | 779 | int dib3000mc_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, struct dib3000mc_config cfg[]) |
830 | |||
831 | int dib3000mc_attach(struct i2c_adapter *i2c_adap, int no_of_demods, u8 default_addr, u8 do_i2c_enum, struct dib3000mc_config cfg[], struct dvb_frontend *demod[]) | ||
832 | { | 780 | { |
833 | struct dib3000mc_state *st; | 781 | struct dib3000mc_state st = { .i2c_adap = i2c }; |
834 | int k, num=0; | 782 | int k; |
835 | 783 | u8 new_addr; | |
836 | if (no_of_demods < 1) | ||
837 | return -EINVAL; | ||
838 | 784 | ||
839 | for (k = 0; k < no_of_demods; k++) { | 785 | static u8 DIB3000MC_I2C_ADDRESS[] = {20,22,24,26}; |
840 | st = kzalloc(sizeof(struct dib3000mc_state), GFP_KERNEL); | ||
841 | if (st == NULL) | ||
842 | goto error; | ||
843 | 786 | ||
844 | num++; | 787 | for (k = no_of_demods-1; k >= 0; k--) { |
788 | st.cfg = &cfg[k]; | ||
845 | 789 | ||
846 | st->cfg = &cfg[k]; | 790 | /* designated i2c address */ |
847 | // st->gpio_val = cfg[k].gpio_val; | 791 | new_addr = DIB3000MC_I2C_ADDRESS[k]; |
848 | // st->gpio_dir = cfg[k].gpio_dir; | 792 | st.i2c_addr = new_addr; |
849 | st->i2c_adap = i2c_adap; | 793 | if (dib3000mc_identify(&st) != 0) { |
794 | st.i2c_addr = default_addr; | ||
795 | if (dib3000mc_identify(&st) != 0) { | ||
796 | dprintk("-E- DiB3000P/MC #%d: not identified\n", k); | ||
797 | return -ENODEV; | ||
798 | } | ||
799 | } | ||
850 | 800 | ||
851 | demod[k] = &st->demod; | 801 | dib3000mc_set_output_mode(&st, OUTMODE_MPEG2_PAR_CONT_CLK); |
852 | demod[k]->demodulator_priv = st; | ||
853 | memcpy(&st->demod.ops, &dib3000mc_ops, sizeof(struct dvb_frontend_ops)); | ||
854 | 802 | ||
855 | // INIT_COMPONENT_REGISTER_ACCESS(&st->register_access, 12, 16, dib7000p_register_read, dib7000p_register_write, st); | 803 | // set new i2c address and force divstr (Bit 1) to value 0 (Bit 0) |
856 | // demod[k]->register_access = &st->register_access; | 804 | dib3000mc_write_word(&st, 1024, (new_addr << 3) | 0x1); |
805 | st.i2c_addr = new_addr; | ||
857 | } | 806 | } |
858 | 807 | ||
859 | if (do_i2c_enum) { | 808 | for (k = 0; k < no_of_demods; k++) { |
860 | if (dib3000mc_i2c_enumeration(demod,no_of_demods,default_addr) != 0) | 809 | st.cfg = &cfg[k]; |
861 | goto error; | 810 | st.i2c_addr = DIB3000MC_I2C_ADDRESS[k]; |
862 | } else { | ||
863 | st = demod[0]->demodulator_priv; | ||
864 | st->i2c_addr = default_addr; | ||
865 | if (dib3000mc_identify(st) != 0) | ||
866 | goto error; | ||
867 | } | ||
868 | 811 | ||
869 | for (k = 0; k < num; k++) { | 812 | dib3000mc_write_word(&st, 1024, st.i2c_addr << 3); |
870 | st = demod[k]->demodulator_priv; | ||
871 | dibx000_init_i2c_master(&st->i2c_master, DIB3000MC, st->i2c_adap, st->i2c_addr); | ||
872 | } | ||
873 | 813 | ||
814 | /* turn off data output */ | ||
815 | dib3000mc_set_output_mode(&st, OUTMODE_HIGH_Z); | ||
816 | } | ||
874 | return 0; | 817 | return 0; |
818 | } | ||
819 | EXPORT_SYMBOL(dib3000mc_i2c_enumeration); | ||
820 | |||
821 | static struct dvb_frontend_ops dib3000mc_ops; | ||
822 | |||
823 | struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg) | ||
824 | { | ||
825 | struct dvb_frontend *demod; | ||
826 | struct dib3000mc_state *st; | ||
827 | st = kzalloc(sizeof(struct dib3000mc_state), GFP_KERNEL); | ||
828 | if (st == NULL) | ||
829 | return NULL; | ||
830 | |||
831 | st->cfg = cfg; | ||
832 | st->i2c_adap = i2c_adap; | ||
833 | |||
834 | demod = &st->demod; | ||
835 | demod->demodulator_priv = st; | ||
836 | memcpy(&st->demod.ops, &dib3000mc_ops, sizeof(struct dvb_frontend_ops)); | ||
837 | |||
838 | if (dib3000mc_identify(st) != 0) | ||
839 | goto error; | ||
840 | |||
841 | dibx000_init_i2c_master(&st->i2c_master, DIB3000MC, st->i2c_adap, st->i2c_addr); | ||
842 | |||
843 | return demod; | ||
875 | 844 | ||
876 | error: | 845 | error: |
877 | for (k = 0; k < num; k++) { | 846 | kfree(st); |
878 | kfree(demod[k]->demodulator_priv); | 847 | return NULL; |
879 | demod[k] = NULL; | ||
880 | } | ||
881 | return -EINVAL; | ||
882 | } | 848 | } |
883 | |||
884 | EXPORT_SYMBOL(dib3000mc_attach); | 849 | EXPORT_SYMBOL(dib3000mc_attach); |
885 | 850 | ||
886 | static struct dvb_frontend_ops dib3000mc_ops = { | 851 | static struct dvb_frontend_ops dib3000mc_ops = { |
diff --git a/drivers/media/dvb/frontends/dib3000mc.h b/drivers/media/dvb/frontends/dib3000mc.h index fd0b2e75599..b198cd5b184 100644 --- a/drivers/media/dvb/frontends/dib3000mc.h +++ b/drivers/media/dvb/frontends/dib3000mc.h | |||
@@ -37,17 +37,17 @@ struct dib3000mc_config { | |||
37 | #define DEFAULT_DIB3000P_I2C_ADDRESS 24 | 37 | #define DEFAULT_DIB3000P_I2C_ADDRESS 24 |
38 | 38 | ||
39 | #if defined(CONFIG_DVB_DIB3000MC) || defined(CONFIG_DVB_DIB3000MC_MODULE) | 39 | #if defined(CONFIG_DVB_DIB3000MC) || defined(CONFIG_DVB_DIB3000MC_MODULE) |
40 | extern int dib3000mc_attach(struct i2c_adapter *i2c_adap, int no_of_demods, u8 default_addr, | 40 | extern struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg); |
41 | u8 do_i2c_enum, struct dib3000mc_config cfg[], struct dvb_frontend *demod[]); | ||
42 | #else | 41 | #else |
43 | static inline struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config, | 42 | static inline struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg) |
44 | struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops) | ||
45 | { | 43 | { |
46 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 44 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); |
47 | return NULL; | 45 | return NULL; |
48 | } | 46 | } |
49 | #endif // CONFIG_DVB_DIB3000MC | 47 | #endif // CONFIG_DVB_DIB3000MC |
50 | 48 | ||
49 | extern int dib3000mc_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, struct dib3000mc_config cfg[]); | ||
50 | |||
51 | extern struct i2c_adapter * dib3000mc_get_tuner_i2c_master(struct dvb_frontend *demod, int gating); | 51 | extern struct i2c_adapter * dib3000mc_get_tuner_i2c_master(struct dvb_frontend *demod, int gating); |
52 | 52 | ||
53 | extern int dib3000mc_pid_control(struct dvb_frontend *fe, int index, int pid,int onoff); | 53 | extern int dib3000mc_pid_control(struct dvb_frontend *fe, int index, int pid,int onoff); |
diff --git a/drivers/media/dvb/frontends/mt2060.c b/drivers/media/dvb/frontends/mt2060.c index 508ec1b6d1f..19bd66a1816 100644 --- a/drivers/media/dvb/frontends/mt2060.c +++ b/drivers/media/dvb/frontends/mt2060.c | |||
@@ -247,6 +247,9 @@ static void mt2060_calibrate(struct mt2060_priv *priv) | |||
247 | if (mt2060_writeregs(priv,mt2060_config2,sizeof(mt2060_config2))) | 247 | if (mt2060_writeregs(priv,mt2060_config2,sizeof(mt2060_config2))) |
248 | return; | 248 | return; |
249 | 249 | ||
250 | /* initialize the clock output */ | ||
251 | mt2060_writereg(priv, REG_VGAG, (priv->cfg->clock_out << 6) | 0x30); | ||
252 | |||
250 | do { | 253 | do { |
251 | b |= (1 << 6); // FM1SS; | 254 | b |= (1 << 6); // FM1SS; |
252 | mt2060_writereg(priv, REG_LO2C1,b); | 255 | mt2060_writereg(priv, REG_LO2C1,b); |
@@ -294,13 +297,13 @@ static int mt2060_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) | |||
294 | static int mt2060_init(struct dvb_frontend *fe) | 297 | static int mt2060_init(struct dvb_frontend *fe) |
295 | { | 298 | { |
296 | struct mt2060_priv *priv = fe->tuner_priv; | 299 | struct mt2060_priv *priv = fe->tuner_priv; |
297 | return mt2060_writereg(priv, REG_VGAG,0x33); | 300 | return mt2060_writereg(priv, REG_VGAG, (priv->cfg->clock_out << 6) | 0x33); |
298 | } | 301 | } |
299 | 302 | ||
300 | static int mt2060_sleep(struct dvb_frontend *fe) | 303 | static int mt2060_sleep(struct dvb_frontend *fe) |
301 | { | 304 | { |
302 | struct mt2060_priv *priv = fe->tuner_priv; | 305 | struct mt2060_priv *priv = fe->tuner_priv; |
303 | return mt2060_writereg(priv, REG_VGAG,0x30); | 306 | return mt2060_writereg(priv, REG_VGAG, (priv->cfg->clock_out << 6) | 0x30); |
304 | } | 307 | } |
305 | 308 | ||
306 | static int mt2060_release(struct dvb_frontend *fe) | 309 | static int mt2060_release(struct dvb_frontend *fe) |
diff --git a/drivers/media/dvb/frontends/mt2060.h b/drivers/media/dvb/frontends/mt2060.h index c58b03e8234..471d3326e29 100644 --- a/drivers/media/dvb/frontends/mt2060.h +++ b/drivers/media/dvb/frontends/mt2060.h | |||
@@ -27,7 +27,7 @@ struct i2c_adapter; | |||
27 | 27 | ||
28 | struct mt2060_config { | 28 | struct mt2060_config { |
29 | u8 i2c_address; | 29 | u8 i2c_address; |
30 | /* Shall we add settings for the discrete outputs ? */ | 30 | u8 clock_out; /* 0 = off, 1 = CLK/1, 2 = CLK/2, 3 = CLK/4 */ |
31 | }; | 31 | }; |
32 | 32 | ||
33 | extern int mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1); | 33 | extern int mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1); |