~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/media/dvb/frontends/stv090x.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
767
767
         * In case of any error, the lock is unlocked and exit within the
768
768
         * relevant operations themselves.
769
769
         */
770
 
        if (enable)
771
 
                mutex_lock(&state->internal->tuner_lock);
 
770
        if (enable) {
 
771
                if (state->config->tuner_i2c_lock)
 
772
                        state->config->tuner_i2c_lock(&state->frontend, 1);
 
773
                else
 
774
                        mutex_lock(&state->internal->tuner_lock);
 
775
        }
772
776
 
773
777
        reg = STV090x_READ_DEMOD(state, I2CRPT);
774
778
        if (enable) {
784
788
                        goto err;
785
789
        }
786
790
 
787
 
        if (!enable)
 
791
        if (!enable) {
 
792
                if (state->config->tuner_i2c_lock)
 
793
                        state->config->tuner_i2c_lock(&state->frontend, 0);
 
794
                else
 
795
                        mutex_unlock(&state->internal->tuner_lock);
 
796
        }
 
797
 
 
798
        return 0;
 
799
err:
 
800
        dprintk(FE_ERROR, 1, "I/O error");
 
801
        if (state->config->tuner_i2c_lock)
 
802
                state->config->tuner_i2c_lock(&state->frontend, 0);
 
803
        else
788
804
                mutex_unlock(&state->internal->tuner_lock);
789
 
 
790
 
        return 0;
791
 
err:
792
 
        dprintk(FE_ERROR, 1, "I/O error");
793
 
        mutex_unlock(&state->internal->tuner_lock);
794
805
        return -1;
795
806
}
796
807
 
1413
1424
                        if (STV090x_WRITE_DEMOD(state, CFRLOW0, 0x00) < 0)
1414
1425
                                goto err;
1415
1426
 
1416
 
                        /*enlarge the timing bandwith for Low SR*/
 
1427
                        /*enlarge the timing bandwidth for Low SR*/
1417
1428
                        if (STV090x_WRITE_DEMOD(state, RTCS2, 0x68) < 0)
1418
1429
                                goto err;
1419
1430
                } else {
1421
1432
                        Set The carrier search up and low to auto mode */
1422
1433
                        if (STV090x_WRITE_DEMOD(state, CARCFG, 0xc4) < 0)
1423
1434
                                goto err;
1424
 
                        /*reduce the timing bandwith for high SR*/
 
1435
                        /*reduce the timing bandwidth for high SR*/
1425
1436
                        if (STV090x_WRITE_DEMOD(state, RTCS2, 0x44) < 0)
1426
1437
                                goto err;
1427
1438
                }
1428
1439
        } else {
1429
1440
                /* >= Cut 3 */
1430
1441
                if (state->srate <= 5000000) {
1431
 
                        /* enlarge the timing bandwith for Low SR */
 
1442
                        /* enlarge the timing bandwidth for Low SR */
1432
1443
                        STV090x_WRITE_DEMOD(state, RTCS2, 0x68);
1433
1444
                } else {
1434
 
                        /* reduce timing bandwith for high SR */
 
1445
                        /* reduce timing bandwidth for high SR */
1435
1446
                        STV090x_WRITE_DEMOD(state, RTCS2, 0x44);
1436
1447
                }
1437
1448
 
2471
2482
                                        dvbs2_fly_wheel = STV090x_GETFIELD_Px(reg, FLYWHEEL_CPT_FIELD);
2472
2483
                                }
2473
2484
                                if (dvbs2_fly_wheel < 0xd) {
2474
 
                                        /*FALSE lock, The demod is loosing lock */
 
2485
                                        /*FALSE lock, The demod is losing lock */
2475
2486
                                        lock = 0;
2476
2487
                                        if (trials < 2) {
2477
2488
                                                if (state->internal->dev_ver >= 0x20) {
2883
2894
                STV090x_SETFIELD_Px(reg, DVBS2_ENABLE_FIELD, 1);
2884
2895
                if (STV090x_WRITE_DEMOD(state, DMDCFGMD, reg) < 0)
2885
2896
                        goto err;
2886
 
                if (STV090x_WRITE_DEMOD(state, ACLC, 0) < 0)
2887
 
                        goto err;
2888
 
                if (STV090x_WRITE_DEMOD(state, BCLC, 0) < 0)
2889
 
                        goto err;
 
2897
                if (state->internal->dev_ver >= 0x30) {
 
2898
                        if (STV090x_WRITE_DEMOD(state, ACLC, 0) < 0)
 
2899
                                goto err;
 
2900
                        if (STV090x_WRITE_DEMOD(state, BCLC, 0) < 0)
 
2901
                                goto err;
 
2902
                }
2890
2903
                if (state->frame_len == STV090x_LONG_FRAME) {
2891
2904
                        reg = STV090x_READ_DEMOD(state, DMDMODCOD);
2892
2905
                        modcod = STV090x_GETFIELD_Px(reg, DEMOD_MODCOD_FIELD);
3189
3202
                        goto err;
3190
3203
                if (STV090x_WRITE_DEMOD(state, CORRELMANT, 0x70) < 0)
3191
3204
                        goto err;
3192
 
                if (stv090x_set_srate(state, 1000000) < 0) /* inital srate = 1Msps */
 
3205
                if (stv090x_set_srate(state, 1000000) < 0) /* initial srate = 1Msps */
3193
3206
                        goto err;
3194
3207
        } else {
3195
3208
                /* known srate */
3846
3859
{
3847
3860
        struct stv090x_state *state = fe->demodulator_priv;
3848
3861
        u32 reg;
 
3862
        u8 full_standby = 0;
3849
3863
 
3850
3864
        if (stv090x_i2c_gate_ctrl(state, 1) < 0)
3851
3865
                goto err;
3858
3872
        if (stv090x_i2c_gate_ctrl(state, 0) < 0)
3859
3873
                goto err;
3860
3874
 
3861
 
        dprintk(FE_DEBUG, 1, "Set %s to sleep",
3862
 
                state->device == STV0900 ? "STV0900" : "STV0903");
3863
 
 
3864
 
        reg = stv090x_read_reg(state, STV090x_SYNTCTRL);
3865
 
        STV090x_SETFIELD(reg, STANDBY_FIELD, 0x01);
3866
 
        if (stv090x_write_reg(state, STV090x_SYNTCTRL, reg) < 0)
3867
 
                goto err;
3868
 
 
3869
 
        reg = stv090x_read_reg(state, STV090x_TSTTNR1);
3870
 
        STV090x_SETFIELD(reg, ADC1_PON_FIELD, 0);
3871
 
        if (stv090x_write_reg(state, STV090x_TSTTNR1, reg) < 0)
3872
 
                goto err;
3873
 
 
 
3875
        dprintk(FE_DEBUG, 1, "Set %s(%d) to sleep",
 
3876
                state->device == STV0900 ? "STV0900" : "STV0903",
 
3877
                state->demod);
 
3878
 
 
3879
        mutex_lock(&state->internal->demod_lock);
 
3880
 
 
3881
        switch (state->demod) {
 
3882
        case STV090x_DEMODULATOR_0:
 
3883
                /* power off ADC 1 */
 
3884
                reg = stv090x_read_reg(state, STV090x_TSTTNR1);
 
3885
                STV090x_SETFIELD(reg, ADC1_PON_FIELD, 0);
 
3886
                if (stv090x_write_reg(state, STV090x_TSTTNR1, reg) < 0)
 
3887
                        goto err;
 
3888
                /* power off DiSEqC 1 */
 
3889
                reg = stv090x_read_reg(state, STV090x_TSTTNR2);
 
3890
                STV090x_SETFIELD(reg, DISEQC1_PON_FIELD, 0);
 
3891
                if (stv090x_write_reg(state, STV090x_TSTTNR2, reg) < 0)
 
3892
                        goto err;
 
3893
 
 
3894
                /* check whether path 2 is already sleeping, that is when
 
3895
                   ADC2 is off */
 
3896
                reg = stv090x_read_reg(state, STV090x_TSTTNR3);
 
3897
                if (STV090x_GETFIELD(reg, ADC2_PON_FIELD) == 0)
 
3898
                        full_standby = 1;
 
3899
 
 
3900
                /* stop clocks */
 
3901
                reg = stv090x_read_reg(state, STV090x_STOPCLK1);
 
3902
                /* packet delineator 1 clock */
 
3903
                STV090x_SETFIELD(reg, STOP_CLKPKDT1_FIELD, 1);
 
3904
                /* ADC 1 clock */
 
3905
                STV090x_SETFIELD(reg, STOP_CLKADCI1_FIELD, 1);
 
3906
                /* FEC clock is shared between the two paths, only stop it
 
3907
                   when full standby is possible */
 
3908
                if (full_standby)
 
3909
                        STV090x_SETFIELD(reg, STOP_CLKFEC_FIELD, 1);
 
3910
                if (stv090x_write_reg(state, STV090x_STOPCLK1, reg) < 0)
 
3911
                        goto err;
 
3912
                reg = stv090x_read_reg(state, STV090x_STOPCLK2);
 
3913
                /* sampling 1 clock */
 
3914
                STV090x_SETFIELD(reg, STOP_CLKSAMP1_FIELD, 1);
 
3915
                /* viterbi 1 clock */
 
3916
                STV090x_SETFIELD(reg, STOP_CLKVIT1_FIELD, 1);
 
3917
                /* TS clock is shared between the two paths, only stop it
 
3918
                   when full standby is possible */
 
3919
                if (full_standby)
 
3920
                        STV090x_SETFIELD(reg, STOP_CLKTS_FIELD, 1);
 
3921
                if (stv090x_write_reg(state, STV090x_STOPCLK2, reg) < 0)
 
3922
                        goto err;
 
3923
                break;
 
3924
 
 
3925
        case STV090x_DEMODULATOR_1:
 
3926
                /* power off ADC 2 */
 
3927
                reg = stv090x_read_reg(state, STV090x_TSTTNR3);
 
3928
                STV090x_SETFIELD(reg, ADC2_PON_FIELD, 0);
 
3929
                if (stv090x_write_reg(state, STV090x_TSTTNR3, reg) < 0)
 
3930
                        goto err;
 
3931
                /* power off DiSEqC 2 */
 
3932
                reg = stv090x_read_reg(state, STV090x_TSTTNR4);
 
3933
                STV090x_SETFIELD(reg, DISEQC2_PON_FIELD, 0);
 
3934
                if (stv090x_write_reg(state, STV090x_TSTTNR4, reg) < 0)
 
3935
                        goto err;
 
3936
 
 
3937
                /* check whether path 1 is already sleeping, that is when
 
3938
                   ADC1 is off */
 
3939
                reg = stv090x_read_reg(state, STV090x_TSTTNR1);
 
3940
                if (STV090x_GETFIELD(reg, ADC1_PON_FIELD) == 0)
 
3941
                        full_standby = 1;
 
3942
 
 
3943
                /* stop clocks */
 
3944
                reg = stv090x_read_reg(state, STV090x_STOPCLK1);
 
3945
                /* packet delineator 2 clock */
 
3946
                STV090x_SETFIELD(reg, STOP_CLKPKDT2_FIELD, 1);
 
3947
                /* ADC 2 clock */
 
3948
                STV090x_SETFIELD(reg, STOP_CLKADCI2_FIELD, 1);
 
3949
                /* FEC clock is shared between the two paths, only stop it
 
3950
                   when full standby is possible */
 
3951
                if (full_standby)
 
3952
                        STV090x_SETFIELD(reg, STOP_CLKFEC_FIELD, 1);
 
3953
                if (stv090x_write_reg(state, STV090x_STOPCLK1, reg) < 0)
 
3954
                        goto err;
 
3955
                reg = stv090x_read_reg(state, STV090x_STOPCLK2);
 
3956
                /* sampling 2 clock */
 
3957
                STV090x_SETFIELD(reg, STOP_CLKSAMP2_FIELD, 1);
 
3958
                /* viterbi 2 clock */
 
3959
                STV090x_SETFIELD(reg, STOP_CLKVIT2_FIELD, 1);
 
3960
                /* TS clock is shared between the two paths, only stop it
 
3961
                   when full standby is possible */
 
3962
                if (full_standby)
 
3963
                        STV090x_SETFIELD(reg, STOP_CLKTS_FIELD, 1);
 
3964
                if (stv090x_write_reg(state, STV090x_STOPCLK2, reg) < 0)
 
3965
                        goto err;
 
3966
                break;
 
3967
 
 
3968
        default:
 
3969
                dprintk(FE_ERROR, 1, "Wrong demodulator!");
 
3970
                break;
 
3971
        }
 
3972
 
 
3973
        if (full_standby) {
 
3974
                /* general power off */
 
3975
                reg = stv090x_read_reg(state, STV090x_SYNTCTRL);
 
3976
                STV090x_SETFIELD(reg, STANDBY_FIELD, 0x01);
 
3977
                if (stv090x_write_reg(state, STV090x_SYNTCTRL, reg) < 0)
 
3978
                        goto err;
 
3979
        }
 
3980
 
 
3981
        mutex_unlock(&state->internal->demod_lock);
3874
3982
        return 0;
3875
3983
 
3876
3984
err_gateoff:
3877
3985
        stv090x_i2c_gate_ctrl(state, 0);
3878
3986
err:
 
3987
        mutex_unlock(&state->internal->demod_lock);
3879
3988
        dprintk(FE_ERROR, 1, "I/O error");
3880
3989
        return -1;
3881
3990
}
3885
3994
        struct stv090x_state *state = fe->demodulator_priv;
3886
3995
        u32 reg;
3887
3996
 
3888
 
        dprintk(FE_DEBUG, 1, "Wake %s from standby",
3889
 
                state->device == STV0900 ? "STV0900" : "STV0903");
3890
 
 
 
3997
        dprintk(FE_DEBUG, 1, "Wake %s(%d) from standby",
 
3998
                state->device == STV0900 ? "STV0900" : "STV0903",
 
3999
                state->demod);
 
4000
 
 
4001
        mutex_lock(&state->internal->demod_lock);
 
4002
 
 
4003
        /* general power on */
3891
4004
        reg = stv090x_read_reg(state, STV090x_SYNTCTRL);
3892
4005
        STV090x_SETFIELD(reg, STANDBY_FIELD, 0x00);
3893
4006
        if (stv090x_write_reg(state, STV090x_SYNTCTRL, reg) < 0)
3894
4007
                goto err;
3895
4008
 
3896
 
        reg = stv090x_read_reg(state, STV090x_TSTTNR1);
3897
 
        STV090x_SETFIELD(reg, ADC1_PON_FIELD, 1);
3898
 
        if (stv090x_write_reg(state, STV090x_TSTTNR1, reg) < 0)
3899
 
                goto err;
3900
 
 
 
4009
        switch (state->demod) {
 
4010
        case STV090x_DEMODULATOR_0:
 
4011
                /* power on ADC 1 */
 
4012
                reg = stv090x_read_reg(state, STV090x_TSTTNR1);
 
4013
                STV090x_SETFIELD(reg, ADC1_PON_FIELD, 1);
 
4014
                if (stv090x_write_reg(state, STV090x_TSTTNR1, reg) < 0)
 
4015
                        goto err;
 
4016
                /* power on DiSEqC 1 */
 
4017
                reg = stv090x_read_reg(state, STV090x_TSTTNR2);
 
4018
                STV090x_SETFIELD(reg, DISEQC1_PON_FIELD, 1);
 
4019
                if (stv090x_write_reg(state, STV090x_TSTTNR2, reg) < 0)
 
4020
                        goto err;
 
4021
 
 
4022
                /* activate clocks */
 
4023
                reg = stv090x_read_reg(state, STV090x_STOPCLK1);
 
4024
                /* packet delineator 1 clock */
 
4025
                STV090x_SETFIELD(reg, STOP_CLKPKDT1_FIELD, 0);
 
4026
                /* ADC 1 clock */
 
4027
                STV090x_SETFIELD(reg, STOP_CLKADCI1_FIELD, 0);
 
4028
                /* FEC clock */
 
4029
                STV090x_SETFIELD(reg, STOP_CLKFEC_FIELD, 0);
 
4030
                if (stv090x_write_reg(state, STV090x_STOPCLK1, reg) < 0)
 
4031
                        goto err;
 
4032
                reg = stv090x_read_reg(state, STV090x_STOPCLK2);
 
4033
                /* sampling 1 clock */
 
4034
                STV090x_SETFIELD(reg, STOP_CLKSAMP1_FIELD, 0);
 
4035
                /* viterbi 1 clock */
 
4036
                STV090x_SETFIELD(reg, STOP_CLKVIT1_FIELD, 0);
 
4037
                /* TS clock */
 
4038
                STV090x_SETFIELD(reg, STOP_CLKTS_FIELD, 0);
 
4039
                if (stv090x_write_reg(state, STV090x_STOPCLK2, reg) < 0)
 
4040
                        goto err;
 
4041
                break;
 
4042
 
 
4043
        case STV090x_DEMODULATOR_1:
 
4044
                /* power on ADC 2 */
 
4045
                reg = stv090x_read_reg(state, STV090x_TSTTNR3);
 
4046
                STV090x_SETFIELD(reg, ADC2_PON_FIELD, 1);
 
4047
                if (stv090x_write_reg(state, STV090x_TSTTNR3, reg) < 0)
 
4048
                        goto err;
 
4049
                /* power on DiSEqC 2 */
 
4050
                reg = stv090x_read_reg(state, STV090x_TSTTNR4);
 
4051
                STV090x_SETFIELD(reg, DISEQC2_PON_FIELD, 1);
 
4052
                if (stv090x_write_reg(state, STV090x_TSTTNR4, reg) < 0)
 
4053
                        goto err;
 
4054
 
 
4055
                /* activate clocks */
 
4056
                reg = stv090x_read_reg(state, STV090x_STOPCLK1);
 
4057
                /* packet delineator 2 clock */
 
4058
                STV090x_SETFIELD(reg, STOP_CLKPKDT2_FIELD, 0);
 
4059
                /* ADC 2 clock */
 
4060
                STV090x_SETFIELD(reg, STOP_CLKADCI2_FIELD, 0);
 
4061
                /* FEC clock */
 
4062
                STV090x_SETFIELD(reg, STOP_CLKFEC_FIELD, 0);
 
4063
                if (stv090x_write_reg(state, STV090x_STOPCLK1, reg) < 0)
 
4064
                        goto err;
 
4065
                reg = stv090x_read_reg(state, STV090x_STOPCLK2);
 
4066
                /* sampling 2 clock */
 
4067
                STV090x_SETFIELD(reg, STOP_CLKSAMP2_FIELD, 0);
 
4068
                /* viterbi 2 clock */
 
4069
                STV090x_SETFIELD(reg, STOP_CLKVIT2_FIELD, 0);
 
4070
                /* TS clock */
 
4071
                STV090x_SETFIELD(reg, STOP_CLKTS_FIELD, 0);
 
4072
                if (stv090x_write_reg(state, STV090x_STOPCLK2, reg) < 0)
 
4073
                        goto err;
 
4074
                break;
 
4075
 
 
4076
        default:
 
4077
                dprintk(FE_ERROR, 1, "Wrong demodulator!");
 
4078
                break;
 
4079
        }
 
4080
 
 
4081
        mutex_unlock(&state->internal->demod_lock);
3901
4082
        return 0;
3902
4083
err:
 
4084
        mutex_unlock(&state->internal->demod_lock);
3903
4085
        dprintk(FE_ERROR, 1, "I/O error");
3904
4086
        return -1;
3905
4087
}
4169
4351
        switch (state->config->ts1_mode) {
4170
4352
        case STV090x_TSMODE_PARALLEL_PUNCTURED:
4171
4353
                reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
 
4354
                STV090x_SETFIELD_Px(reg, TSFIFO_TEIUPDATE_FIELD, state->config->ts1_tei);
4172
4355
                STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x00);
4173
4356
                STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x00);
4174
4357
                if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg) < 0)
4177
4360
 
4178
4361
        case STV090x_TSMODE_DVBCI:
4179
4362
                reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
 
4363
                STV090x_SETFIELD_Px(reg, TSFIFO_TEIUPDATE_FIELD, state->config->ts1_tei);
4180
4364
                STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x00);
4181
4365
                STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x01);
4182
4366
                if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg) < 0)
4185
4369
 
4186
4370
        case STV090x_TSMODE_SERIAL_PUNCTURED:
4187
4371
                reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
 
4372
                STV090x_SETFIELD_Px(reg, TSFIFO_TEIUPDATE_FIELD, state->config->ts1_tei);
4188
4373
                STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x01);
4189
4374
                STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x00);
4190
4375
                if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg) < 0)
4193
4378
 
4194
4379
        case STV090x_TSMODE_SERIAL_CONTINUOUS:
4195
4380
                reg = stv090x_read_reg(state, STV090x_P1_TSCFGH);
 
4381
                STV090x_SETFIELD_Px(reg, TSFIFO_TEIUPDATE_FIELD, state->config->ts1_tei);
4196
4382
                STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x01);
4197
4383
                STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x01);
4198
4384
                if (stv090x_write_reg(state, STV090x_P1_TSCFGH, reg) < 0)
4206
4392
        switch (state->config->ts2_mode) {
4207
4393
        case STV090x_TSMODE_PARALLEL_PUNCTURED:
4208
4394
                reg = stv090x_read_reg(state, STV090x_P2_TSCFGH);
 
4395
                STV090x_SETFIELD_Px(reg, TSFIFO_TEIUPDATE_FIELD, state->config->ts2_tei);
4209
4396
                STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x00);
4210
4397
                STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x00);
4211
4398
                if (stv090x_write_reg(state, STV090x_P2_TSCFGH, reg) < 0)
4214
4401
 
4215
4402
        case STV090x_TSMODE_DVBCI:
4216
4403
                reg = stv090x_read_reg(state, STV090x_P2_TSCFGH);
 
4404
                STV090x_SETFIELD_Px(reg, TSFIFO_TEIUPDATE_FIELD, state->config->ts2_tei);
4217
4405
                STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x00);
4218
4406
                STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x01);
4219
4407
                if (stv090x_write_reg(state, STV090x_P2_TSCFGH, reg) < 0)
4222
4410
 
4223
4411
        case STV090x_TSMODE_SERIAL_PUNCTURED:
4224
4412
                reg = stv090x_read_reg(state, STV090x_P2_TSCFGH);
 
4413
                STV090x_SETFIELD_Px(reg, TSFIFO_TEIUPDATE_FIELD, state->config->ts2_tei);
4225
4414
                STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x01);
4226
4415
                STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x00);
4227
4416
                if (stv090x_write_reg(state, STV090x_P2_TSCFGH, reg) < 0)
4230
4419
 
4231
4420
        case STV090x_TSMODE_SERIAL_CONTINUOUS:
4232
4421
                reg = stv090x_read_reg(state, STV090x_P2_TSCFGH);
 
4422
                STV090x_SETFIELD_Px(reg, TSFIFO_TEIUPDATE_FIELD, state->config->ts2_tei);
4233
4423
                STV090x_SETFIELD_Px(reg, TSFIFO_SERIAL_FIELD, 0x01);
4234
4424
                STV090x_SETFIELD_Px(reg, TSFIFO_DVBCI_FIELD, 0x01);
4235
4425
                if (stv090x_write_reg(state, STV090x_P2_TSCFGH, reg) < 0)
4506
4696
        if (stv090x_write_reg(state, STV090x_TSTRES0, 0x00) < 0)
4507
4697
                goto err;
4508
4698
 
4509
 
        /* workaround for stuck DiSEqC output */
4510
 
        if (config->diseqc_envelope_mode)
4511
 
                stv090x_send_diseqc_burst(fe, SEC_MINI_A);
4512
 
 
4513
4699
        return 0;
4514
4700
err:
4515
4701
        dprintk(FE_ERROR, 1, "I/O error");
4516
4702
        return -1;
4517
4703
}
4518
4704
 
 
4705
int stv090x_set_gpio(struct dvb_frontend *fe, u8 gpio, u8 dir, u8 value,
 
4706
                u8 xor_value)
 
4707
{
 
4708
        struct stv090x_state *state = fe->demodulator_priv;
 
4709
        u8 reg = 0;
 
4710
 
 
4711
        STV090x_SETFIELD(reg, GPIOx_OPD_FIELD, dir);
 
4712
        STV090x_SETFIELD(reg, GPIOx_CONFIG_FIELD, value);
 
4713
        STV090x_SETFIELD(reg, GPIOx_XOR_FIELD, xor_value);
 
4714
 
 
4715
        return stv090x_write_reg(state, STV090x_GPIOxCFG(gpio), reg);
 
4716
}
 
4717
EXPORT_SYMBOL(stv090x_set_gpio);
 
4718
 
4519
4719
static struct dvb_frontend_ops stv090x_ops = {
4520
4720
 
4521
4721
        .info = {
4580
4780
                state->internal = temp_int->internal;
4581
4781
                state->internal->num_used++;
4582
4782
                dprintk(FE_INFO, 1, "Found Internal Structure!");
4583
 
                dprintk(FE_ERROR, 1, "Attaching %s demodulator(%d) Cut=0x%02x",
4584
 
                        state->device == STV0900 ? "STV0900" : "STV0903",
4585
 
                        demod,
4586
 
                        state->internal->dev_ver);
4587
 
                return &state->frontend;
4588
4783
        } else {
4589
4784
                state->internal = kmalloc(sizeof(struct stv090x_internal),
4590
4785
                                          GFP_KERNEL);
 
4786
                if (!state->internal)
 
4787
                        goto error;
4591
4788
                temp_int = append_internal(state->internal);
 
4789
                if (!temp_int) {
 
4790
                        kfree(state->internal);
 
4791
                        goto error;
 
4792
                }
4592
4793
                state->internal->num_used = 1;
4593
4794
                state->internal->mclk = 0;
4594
4795
                state->internal->dev_ver = 0;
4595
4796
                state->internal->i2c_adap = state->i2c;
4596
4797
                state->internal->i2c_addr = state->config->address;
4597
4798
                dprintk(FE_INFO, 1, "Create New Internal Structure!");
4598
 
        }
4599
 
 
4600
 
        mutex_init(&state->internal->demod_lock);
4601
 
        mutex_init(&state->internal->tuner_lock);
4602
 
 
4603
 
        if (stv090x_sleep(&state->frontend) < 0) {
4604
 
                dprintk(FE_ERROR, 1, "Error putting device to sleep");
4605
 
                goto error;
4606
 
        }
4607
 
 
4608
 
        if (stv090x_setup(&state->frontend) < 0) {
4609
 
                dprintk(FE_ERROR, 1, "Error setting up device");
4610
 
                goto error;
4611
 
        }
4612
 
        if (stv090x_wakeup(&state->frontend) < 0) {
4613
 
                dprintk(FE_ERROR, 1, "Error waking device");
4614
 
                goto error;
4615
 
        }
 
4799
 
 
4800
                mutex_init(&state->internal->demod_lock);
 
4801
                mutex_init(&state->internal->tuner_lock);
 
4802
 
 
4803
                if (stv090x_setup(&state->frontend) < 0) {
 
4804
                        dprintk(FE_ERROR, 1, "Error setting up device");
 
4805
                        goto err_remove;
 
4806
                }
 
4807
        }
 
4808
 
 
4809
        /* workaround for stuck DiSEqC output */
 
4810
        if (config->diseqc_envelope_mode)
 
4811
                stv090x_send_diseqc_burst(&state->frontend, SEC_MINI_A);
4616
4812
 
4617
4813
        dprintk(FE_ERROR, 1, "Attaching %s demodulator(%d) Cut=0x%02x",
4618
4814
               state->device == STV0900 ? "STV0900" : "STV0903",
4621
4817
 
4622
4818
        return &state->frontend;
4623
4819
 
 
4820
err_remove:
 
4821
        remove_dev(state->internal);
 
4822
        kfree(state->internal);
4624
4823
error:
4625
4824
        kfree(state);
4626
4825
        return NULL;