Re: Problem about mt2131 tuner

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yeah, I did this part of code already.
    I design mt2131_set_tv_freq(struct i2c_client *cli, unsigned int
freq) function and I compile this part of code into tuner.ko just like
mt20xx code has done,
++++++++++++++++++++++++++++++++++++++++++++++++
static void  mt2131_set_tv_freq(struct i2c_client *client, unsigned
int freqency)
{
    struct tuner *t = i2c_get_clientdata(client);
    struct mt2131_priv *priv = t->priv;
    int ret, i = 0;
    u32 freq;
    u8 if_band_center;
    u32 f_lo1, f_lo2;
    u32 div1, num1, div2, num2;
    u8 buf[12];
    u8 lockval = 0;
    u8 agcrst = 0;

    freq = (freqency * 16) / 1000;
    f_lo1 = freq + MT2131_IF1;
    f_lo1 = (f_lo1 / 250) * 250;
    f_lo2 = f_lo1 - freq - MT2131_IF2;

    priv->frequency = (f_lo1 - f_lo2 - MT2131_IF2) * 1000;

    num1 = f_lo1 * 64 / (MT2131_FREF / 128);
    div1 = num1 / 8192;
    num1 &= 0x1fff;

    num2 = f_lo2 * 64 / (MT2131_FREF / 128);
    div2 = num2 / 8192;
    num2 &= 0x1fff;

    if(freq <=  82500)  if_band_center = 0x00; else
    if(freq <=  137500) if_band_center = 0x01; else
    if(freq <=  192500) if_band_center = 0x02; else
    if(freq <=  247500) if_band_center = 0x03; else
    if(freq <=  302500) if_band_center = 0x04; else
    if(freq <=  357500) if_band_center = 0x05; else
    if(freq <=  412500) if_band_center = 0x06; else
    if(freq <=  467500) if_band_center = 0x07; else
    if(freq <=  522500) if_band_center = 0x08; else
    if(freq <=  577500) if_band_center = 0x09; else
    if(freq <=  632500) if_band_center = 0x0a; else
    if(freq <=  687500) if_band_center = 0x0b; else
    if(freq <=  742500) if_band_center = 0x0c; else
    if(freq <=  797500) if_band_center = 0x0d; else
    if(freq <=  852500) if_band_center = 0x0e; else
    if(freq <=  907500) if_band_center = 0x0f; else
    if(freq <=  962500) if_band_center = 0x10; else
    if(freq <=  1017500) if_band_center = 0x11; else
    if(freq <=  1072500) if_band_center = 0x12; else
        if_band_center = 0x13;

    buf[0] = 0x01;
    buf[1] = (num1 >> 5) & 0xff;
    buf[2] = 0x02;
    buf[3] = num1 & 0x1f;
    buf[4] = 0x03;
    buf[5] = div1;
    buf[6] = 0x04;
    buf[7] = (num2 >> 5) & 0xff;
    buf[8] = 0x05;
    buf[9] = num2 & 0x1f;
    buf[10] = 0x06;
    buf[11] = div2;

    ret = mt2131_regs_write(t, buf, 12);
    if(ret < 0){
        mt2131_debug("change mt2131 frequency failed!\n");
    }

    mt2131_reg_write(t, 0x0b, if_band_center | 0xe0);

    //reset mt2131 AGC
    mt2131_reg_read(t, 0x15, &agcrst);
    agcrst |= 0x40;
    mt2131_reg_write(t, 0x15, agcrst);

    while(i < 10){
        mt2131_reg_read(t, 0x08, &lockval);
        if((lockval & 0x88) == 0x88)
            break;

        mdelay(4);
        i++;
    }
    mt2131_debug("tuner lock the signal on the specified frequency!\n");
    if(i == 10)
        mt2131_debug("Mt2131 tuner can't lock the signal %d\n", freqency);
++++++++++++++++++++++++++++++++++++++++++++++
    For mt2131, I use the same init parameters as in ATSC, and the
same algorithm for frequency parameters setting.
    I can see the function correctly called when VIDIOC_S_FREQUENCY.
    But my tv card's demod just can't get a valid NTSC IF signal.
    So I suspect if mt2131 has different init params or different freq
set algorithm for NTSC.

On Nov 26, 2007 1:11 PM, Michael Krufky <mkrufky@xxxxxxxxxxx> wrote:
>
>
>
> kevin liu wrote:
> > Dear:
> >     In Linux DVB framework, mt2131 works for atsc tv mode.
> >     But the problem is that can I use the same module when I want to see any
> > NTSC tv program?
>
>
> mt2131 currently does not support analog television.  All we need is to fill .set_analog_params, and call it from tuner-core.c, and then it can work.
>
> -Mike Krufky
>

_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux