Fitipower

From LinuxTVWiki
Jump to navigation Jump to search

Tuner used together with AF9035. http://www.fitipower.com.tw/main.htm?pid=9&ID=57

Specifications

Don't trust this blindly. Division is always integer division. Set means prepare a place holder with value. Write means actually transmit the value from the placeholder.

Tuner general info

I2C address is 0xC0. There are 18 8bit large tuner registers indexed from 0.

Index Name
1 FA
2 FP
3,4 XIN
5 VCO
6 VCO_SELECT
14 VCO_CALIBRATE

Init/Reset

Enable tuner:

  • write 1 to GPIO 0xD8EB
  • write 1 to GPIO 0xD8EC
  • write 1 to GPIO 0xD8ED

Enable led:

  • write 1 to GPIO 0xD8D1
  • write 1 to GPIO 0xD8D0

UnInit

Disable led:

  • write 0 to GPIO 0xD8D1
  • write 0 to GPIO 0xD8D0

Tune

Tuning is based on 2 parameters:

  • bandwidth in Hz, can be 6000,7000 or 8000
  • frequency in Hz, can be the regular DVB-T frequency's

Init tuning

  • write 0x0F to tuner register 7
  • write 0x3E to tuner register 8
  • write 0xB8 to tuner register 10
  • write 0x80 to tuner register 11
  • write 0x04 to tuner register 13

Generate the frequency of VCO and the VCO divider

fvco is a parameter

  • if frequency < 54000
    • set fvco to frequency * 64
    • set tuner registry 5 to 0x82
  • if 54000 =< frequency < 108000
    • set fvco to frequency * 32
    • set tuner registry 5 to 0x42
  • if 108000=< frequency < 216000
    • set fvco to frequency * 16
    • set tuner registry 5 to 0x22
  • if 216000=< frequency < 432000
    • set fvco to frequency * 8
    • set tuner registry 5 to 0x12
  • if frequency > 432000
    • set fvco to frequency * 4
    • set tuner registry 5 to 0x0A

Calculate XIN

fraction is a 16bit unsigned parameter, xin is a parameter, fvco is a pre-calculated parameter, xdiv is a parameter

  • set xdiv equal to fvco / 18000
  • set fraction equal to fvco minus xdiv multiplied by 18000
  • set fraction equal to fraction left shifted 15 times and then divided by 18000
  • if fraction is greater or equal to 16384
    • set fractional equal to fractional plus 32768
  • if fraction is equal to 0
    • set xin equal to 0
  • if 0 < fraction < 511
    • set xin equal to 0x200
  • if 511 < fraction <= 65025
    • set xin equal to fraction
  • if 65025 < fraction
    • set xin equal to 0xfe00
  • write xin right shifted 8 times to tuner register 3
  • write xin only 8 low bits to tuner register 4

Calculate FP and FA

fvco is a pre-calculated parameter, xdiv is a pre-calculated parameter, xdivr is a parameter, fp is a 8 bit wide parameter, fa is a parameter

  • set xdivr equal to xdiv
  • if fvco minus xdiv multiplied by 18000 is greater equal to 9000
    • set xdivr equal to xdiv + 1
  • set fp equal to xdivr / 8
  • set fa equal to xdivr minus fp left shifted 3 times
  • if fa is less then 2
    • set fp equal fp minus 1
    • set fa equal fa plus 8
  • write fa to tuner register 1
  • write fp to tuner register 2

Select bandwidth

  • if bandwidth = 8000
    • set tuner registry 6 to 0x0
  • if bandwidth = 7000
    • set tuner registry 6 to 0x40
  • if bandwidth = 6000
    • set tuner registry 6 to 0x80

Pre VCO selection

fvco is a pre-calculated parameter, vco_sel is a parameter

  • if fvco < 2320000
    • set vco_sel equal to 0
    • set tuner registry 6 equal to tuner registry 6 bitwise anded with the bitwise complement of 0x18
  • if 2320000 <= fvco < 3080000
    • set vco_sel equal to 1
    • set tuner registry 6 equal to tuner registry 6 bitwise or'ed with 0x10
  • if 3080000 <= fvco
    • set vco_sel equal to 1
    • set tuner registry 6 equal to tuner registry 6 bitwise or'ed with 0x08

Fix for low frequency's

  • if frequency < 45000
    • set tuner registry 1 to 0x06
    • set tuner registry 2 to 0x11

Fix clock out

  • set tuner registry 6 to the result of a bitwise OR between tuner registry 6 and 0x20

Write frequency parameters

  • write tuner registry 0-6


VCO calibration

vco_cali is a 8bit wide parameter, vco_sel is a pre-calculated parameter


Restart VCO calibration

  • write 0x80 to tuner register 14

Run VCO calibration

  • write 0x00 to tuner register 14

Read VCO calibration value

  • write 0x00 to tuner register 14

wait 10 milliseconds

  • read tuner register 14 into vco_cali

Select VCO

  • set vco_cali equal to vco_cali bitwise anded with 0x3f
  • if vco_sel is equal to 0
    • if vco_cali < 0x08
      • set tuner registry 6 equal to tuner registry 6 bitwise anded with the bitwise complement of 0x18
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x10
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x20
      • write tuner registry 6
      • write 0x80 to tuner register 14
      • write 0x00 to tuner register 14
    • if vco_cali >= 0x08
      • set tuner registry 6 equal to tuner registry 6 bitwise anded with the bitwise complement of 0x18
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x00
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x20
      • write tuner registry 6
  • if vco_sel is equal to 1
    • if vco_cali < 0x05
      • set tuner registry 6 equal to tuner registry 6 bitwise anded with the bitwise complement of 0x18
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x08
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x20
      • write tuner registry 6
      • write 0x80 to tuner register 14
      • write 0x00 to tuner register 14
    • if 0x05<= vco_cali <= 0x30
      • set tuner registry 6 equal to tuner registry 6 bitwise anded with the bitwise complement of 0x18
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x10
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x20
      • write tuner registry 6
    • if vco_cali > 0x30
      • set tuner registry 6 equal to tuner registry 6 bitwise anded with the bitwise complement of 0x18
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x00
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x20
      • write tuner registry 6
      • write 0x80 to tuner register 14
      • write 0x00 to tuner register 14
  • if vco_sel is greater then 1
    • if vco_cali > 0x35
      • set tuner registry 6 equal to tuner registry 6 bitwise anded with the bitwise complement of 0x18
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x10
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x20
      • write tuner registry 6
      • write 0x80 to tuner register 14
      • write 0x00 to tuner register 14
    • if vco_cali <= 0x35
      • set tuner registry 6 equal to tuner registry 6 bitwise anded with the bitwise complement of 0x18
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x08
      • set tuner registry 6 equal to tuner registry 6 bitwise ored with 0x20
      • write tuner registry 6
  • set tuner registry 16 equal to 0x0b

wait 10 milliseconds

  • read tuner registry 13
  • set registry 13 equal to registry 13 ored with 0x10
  • write tuner registry 13
  • write tuner registry 16