# Difference between revisions of "Quantek QT1010"

From LinuxTVWiki

(→Tuner registers) |
(→calculate_parameters) |
||

(3 intermediate revisions by one user not shown) | |||

Line 59: | Line 59: | ||

* write 0x80 to tuner register 1 | * write 0x80 to tuner register 1 | ||

* write 0x84 to tuner register 13 | * write 0x84 to tuner register 13 | ||

− | * write 0xB4 to tuner register 14* (or 0xB7 might work better on some older devices) | + | * write 0xB4 to tuner register 14* (or 0xB7 might work better on some older devices) |

* write 0x23 to tuner register 42 | * write 0x23 to tuner register 42 | ||

* write 0xDC to tuner register 44 | * write 0xDC to tuner register 44 | ||

Line 253: | Line 253: | ||

==== set_frequency ==== | ==== set_frequency ==== | ||

− | This method has the frequency argument, called freq and in | + | This method has the frequency argument, called freq and in Hz. |

− | * call set_parameters with freq and | + | * call set_parameters with freq and command equal to tune |

* if reg35 equal to 0xE0 | * if reg35 equal to 0xE0 | ||

− | ** call set_parameters with freq and | + | ** call set_parameters with freq and command equal to tune_next |

* if reg35 equal to 0xFF | * if reg35 equal to 0xFF | ||

− | ** call set_parameters with freq and | + | ** call set_parameters with freq and command equal to 3 |

* if reg34 equal to 0xFF | * if reg34 equal to 0xFF | ||

− | ** call set_parameters with freq and | + | ** call set_parameters with freq and command equal to 1 |

==== set_parameters ==== | ==== set_parameters ==== | ||

− | arguments freq and | + | arguments freq and command |

− | * call calculate_parameters with freq and | + | * call calculate_parameters with freq and command |

* write 0x80 to tuner register 1 | * write 0x80 to tuner register 1 | ||

* write 0x3F to tuner register 2 | * write 0x3F to tuner register 2 | ||

− | * if | + | * if command is equal to tune_next |

** if reg5 is less then 0x74 | ** if reg5 is less then 0x74 | ||

*** set reg5_1 to reg_5 plus 0x20 | *** set reg5_1 to reg_5 plus 0x20 | ||

Line 350: | Line 350: | ||

* write 0x7F to tuner register 21 | * write 0x7F to tuner register 21 | ||

− | * if | + | * if command is equal to tune_next |

** if reg5 is less equalt to 0x74 | ** if reg5 is less equalt to 0x74 | ||

*** write reg5 minus 4 into reg5_3 | *** write reg5 minus 4 into reg5_3 | ||

Line 374: | Line 374: | ||

* write 0x00 to tuner register 1 | * write 0x00 to tuner register 1 | ||

+ | ==== calculate_parameters ==== | ||

+ | Not complete yet* | ||

+ | |||

+ | arguments freq (in Hz) and command | ||

+ | |||

+ | * if freq is less then 60000000 or greater then 900000000 | ||

+ | ** return error | ||

+ | |||

+ | * if command is equal to tune_next | ||

+ | ** write g_prev_command to cmd_tmp | ||

+ | * else | ||

+ | ** write command to g_prev_command | ||

+ | |||

+ | * write 36125000 to IF | ||

+ | * write 1232000000 to X | ||

+ | * write 920000000 to Y | ||

+ | * write ((freq + X) divided by 4) plus 500000) to Z | ||

+ | * write (1000000 * Z) divided by 1000000 to T1 | ||

+ | * write (4000000* Z) divided by 1000000 - Y - freq to T2 | ||

+ | * write (4000000* Z) divided by 1000000 - Y - freq - IF to T3 | ||

+ | * write T3 divided by 4000000 to T4 | ||

+ | * write T3 divided by 4 to T5 | ||

+ | * write T1 modulus 8000000 divided by 1000000 to T6 | ||

+ | * write (((T5 plus 15777216 multiplied by T4) multiplied by 16) plus 500000) divided by 1000000 to T7 | ||

+ | |||

+ | * write T4 to freq_slot5 | ||

+ | * write T7 truncated to 8 bits to freq_slot7 | ||

+ | * write 2 multiplied by (T7 shifted left 8) + 137 to freq_slot8 | ||

===Tuner On/Off=== | ===Tuner On/Off=== |

## Latest revision as of 11:56, 2 March 2010

The Quantek QT1010 is a wideband tuner chip.

## Contents

## Features

- 48MHz-860MHz frequency range (bands I, II, III, IV).
- 30MHz-60MHz IF output range.
- NTSC, PAL, SECAM broadcast formats.
- DVB-C, DVB-T, ATSC and ISDB-T support.

## External Links

QT1010 Product page at qantek-inc.com

## Tuner registers

Indexed from 0.

Index | Name | Description |
---|---|---|

1 | OP | 0x00 = start tuner with programmed registers, 0x80 = set tuner to programming mode |

5 | VCOBAND | This controls the frequency operating range of the tuner. Low 4 bits can be 0 or 4, High 4 bits can be 1,3,5,7,9. |

17 | LNA | 0xF0 = disable LNA hardware power, used for sleep(), 0xF9 and 0xFD used to enable hardware with LNA on/off |

## Description of how to program the chip

### Tuner context

The tuner has a global context for some variables. They can be used anytime in the init and set methods.

- reg31
- reg32
- reg34
- reg34_1
- reg34_2
- reg34_3
- reg34_4
- reg34_5
- reg34_6
- reg34_7
- reg34_8
- reg37
- reg38

### Tuner Init

This method has no arguments.

- write 0x80 to tuner register 1
- write 0x84 to tuner register 13
- write 0xB4 to tuner register 14* (or 0xB7 might work better on some older devices)
- write 0x23 to tuner register 42
- write 0xDC to tuner register 44
- write 0x40 to tuner register 37
- write 0x00 to tuner register 30
- write 0x81 to tuner register 30

- loop 30 times
- read tuner register 37 into reg37
- if reg37 bit 8 is set
- break out of loop

- read tuner register 37 into reg37
- write 0x00 to tuner register 30
- write 0x23 to tuner register 42
- write 0x70 to tuner register 43
- write 0x08 to tuner register 38
- write 0x00 to tuner register 30
- write 0x82 to tuner register 30

- loop 30 times
- read tuner register 38 into reg38
- if reg38 bit 5 is set
- break out of loop

- read tuner register 38 into reg38
- write 0x00 to tuner register 30
- write 0x14 to tuner register 5
- write 0x44 to tuner register 6
- write 0x28 to tuner register 7
- write 0x0B to tuner register 8
- write 0xFD to tuner register 17* (this can be 0x0D in some cases)
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x0D to tuner register 34
- write 0x00 to tuner register 30
- write 0xD0 to tuner register 30

- loop 30 times
- read tuner register 34
- if register 34 bit 6 is set
- break out of loop

- write 0x00 to tuner register 30
- write 0x40 to tuner register 6
- write 0xF0 to tuner register 22
- write 0x38 to tuner register 2
- write 0x19 to tuner register 3
- write 0x20 to tuner register 31
- write 0xE0 to tuner register 32
- write 0x00 to tuner register 30
- write 0x84 to tuner register 30

- loop 30 times
- read tuner register 31 into reg31
- if register 31 bit 7 is set
- break out of loop

- read tuner register 31 into reg31
- read tuner register 32 into reg32
- write 0x00 to tuner register 30
- write 0x3F to tuner register 2
- write 0x53 to tuner register 33
- read tuner register 33 into reg33
- write 0xFD to tuner register 17* (this can be 0x0D in some cases)
- write 0x34 to tuner register 5
- write 0x44 to tuner register 6
- write 0x31 to tuner register 7
- write 0x08 to tuner register 8
- write 0xD0 to tuner register 34
- write 0x00 to tuner register 30
- write 0xD0 to tuner register 30

- loop 30 times
- read tuner register 34
- if register 34 bit 6 is set
- break out of loop

- write 0x00 to tuner register 30
- read tuner register 34 into reg34_1
- write 0x32 to tuner register 7
- write 0xD0 to tuner register 34
- write 0x00 to tuner register 30
- write 0xD0 to tuner register 30

- loop 30 times
- read tuner register 34
- if register 34 bit 6 is set
- break out of loop

- write 0x00 to tuner register 30
- read tuner register 34 into reg34_2
- write 0x33 to tuner register 7
- write 0xD0 to tuner register 34
- write 0x00 to tuner register 30
- write 0xD0 to tuner register 30

- loop 30 times
- read tuner register 34
- if register 34 bit 6 is set
- break out of loop

- write 0x00 to tuner register 30
- read tuner register 34 into reg34_3
- write 0x34 to tuner register 7
- write 0xD0 to tuner register 34
- write 0x00 to tuner register 30
- write 0xD0 to tuner register 30

- loop 30 times
- read tuner register 34
- if register 34 bit 6 is set
- break out of loop

- write 0x00 to tuner register 30
- read tuner register 34 into reg34_4
- write 0x35 to tuner register 7
- write 0xD0 to tuner register 34
- write 0x00 to tuner register 30
- write 0xD0 to tuner register 30

- loop 30 times
- read tuner register 34
- if register 34 bit 6 is set
- break out of loop

- write 0x00 to tuner register 30
- read tuner register 34 into reg34_5
- write 0x36 to tuner register 7
- write 0xD0 to tuner register 34
- write 0x00 to tuner register 30
- write 0xD0 to tuner register 30

- loop 30 times
- read tuner register 34
- if register 34 bit 6 is set
- break out of loop

- write 0x00 to tuner register 30
- read tuner register 34 into reg34_6
- write 0x37 to tuner register 7
- write 0xD0 to tuner register 34
- write 0x00 to tuner register 30
- write 0xD0 to tuner register 30

- loop 30 times
- read tuner register 34
- if register 34 bit 6 is set
- break out of loop

- write 0x00 to tuner register 30
- read tuner register 34 into reg34_7
- write 0x38 to tuner register 7
- write 0xD0 to tuner register 34
- write 0x00 to tuner register 30
- write 0xD0 to tuner register 30

- loop 30 times
- read tuner register 34
- if register 34 bit 6 is set
- break out of loop

- write 0x00 to tuner register 30
- read tuner register 34 into reg34_8
- write 0x39 to tuner register 7
- write 0xD0 to tuner register 34
- write 0x00 to tuner register 30
- write 0xD0 to tuner register 30

- loop 30 times
- read tuner register 34
- if register 34 bit 6 is set
- break out of loop

- write 0xD0 to tuner register 30
- read tuner register 34 into reg34

### Tuner set frequency

The frequency set method has one sub-method and one subsub-method.

#### set_frequency

This method has the frequency argument, called freq and in Hz.

- call set_parameters with freq and command equal to tune
- if reg35 equal to 0xE0
- call set_parameters with freq and command equal to tune_next

- if reg35 equal to 0xFF
- call set_parameters with freq and command equal to 3

- if reg34 equal to 0xFF
- call set_parameters with freq and command equal to 1

#### set_parameters

arguments freq and command

- call calculate_parameters with freq and command
- write 0x80 to tuner register 1
- write 0x3F to tuner register 2

- if command is equal to tune_next
- if reg5 is less then 0x74
- set reg5_1 to reg_5 plus 0x20

- if reg5 is less then 0x74

- write reg5_1 to tuner register 5
- write 0x44 to tuner register 6
- write freq_slot2 to tuner register 7
- write freq_slot1 to tuner register 8
- write freq_slot4 to tuner register 9
- write freq_slot5 to tuner register 10
- write freq_slot6 to tuner register 11
- write 0xE1 to tuner register 12
- write freq_slot7 to tuner register 26
- write 0x00 to tuner register 27
- write freq_slot8 to tuner register 28
- write 0xFD to tuner register 17*
- write 0x91 to tuner register 18*

- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1
- write 0x80 to tuner register 1

- if reg5_1 is equal to 0x34
- if freq_slot12 is larger equal to 0xF0
- if freq_slot12 is less equal to 0xFA
- write freq_slot12 minus 0x20 into freq_slot12

- else
- write 0xDA into freq_slot12

- if freq_slot12 is less equal to 0xFA
- else
- write 0xD0 into freq_slot12

- write freq_slot12 into tmp_var1

- if freq_slot12 is larger equal to 0xF0
- else
- write 0xD0 into tmp_var1

- write tmp_var1 to tuner register 34
- write 0x00 to tuner register 30
- write 0xD0 to tuner register 30

- loop 30 times
- read tuner register 34
- if register 34 bit 6 is set
- break out of loop

- write 0x00 to tuner register 30
- read tuner register 34 into reg34
- if reg34 is less equal to 0xFE
- write reg34 plus 1 to tuner register 34

- read tuner register 5 into reg5
- read tuner register 34 into reg34
- write 0xD0 to tuner register 35
- write 0x00 to tuner register 30
- write 0xE0 to tuner register 30

- loop 30 times
- read tuner register 35
- if register 35 bit 6 is set
- break out of loop

- read tuner register 35 into reg35
- write 0x00 to tuner register 30
- write 0xD0 to tuner register 36
- write 0x00 to tuner register 30
- write 0xF0 to tuner register 30

- loop 30 times
- read tuner register 36
- if register 36 bit 6 is set
- break out of loop

- write 0x00 to tuner register 30
- write 0x7F to tuner register 20
- write 0x7F to tuner register 21

- if command is equal to tune_next
- if reg5 is less equalt to 0x74
- write reg5 minus 4 into reg5_3

- if reg5 is less equalt to 0x74
- write reg5_3 to tuner register 5
- write 0x00 to tuner register 6
- write 0x1F to tuner register 21
- write 0xFF to tuner register 22
- write 0xFF to tuner register 24

- if reg31 is greater equal to 0x50
- write 0x50 into reg31

- if reg32 is greater equal to 0x12
- write 0x12 into reg32

- write reg31 plus freq_slot10 to tuner register 31
- write reg32 plus freq_slot11 to tuner register 32
- write reg33 to tuner register 33
- write reg37 to tuner register 37
- write reg38 to tuner register 38

- write 0x96 to tuner register 0
- write 0x00 to tuner register 2
- write 0x00 to tuner register 1

#### calculate_parameters

Not complete yet*

arguments freq (in Hz) and command

- if freq is less then 60000000 or greater then 900000000
- return error

- if command is equal to tune_next
- write g_prev_command to cmd_tmp

- else
- write command to g_prev_command

- write 36125000 to IF
- write 1232000000 to X
- write 920000000 to Y
- write ((freq + X) divided by 4) plus 500000) to Z
- write (1000000 * Z) divided by 1000000 to T1
- write (4000000* Z) divided by 1000000 - Y - freq to T2
- write (4000000* Z) divided by 1000000 - Y - freq - IF to T3
- write T3 divided by 4000000 to T4
- write T3 divided by 4 to T5
- write T1 modulus 8000000 divided by 1000000 to T6
- write (((T5 plus 15777216 multiplied by T4) multiplied by 16) plus 500000) divided by 1000000 to T7

- write T4 to freq_slot5
- write T7 truncated to 8 bits to freq_slot7
- write 2 multiplied by (T7 shifted left 8) + 137 to freq_slot8

### Tuner On/Off

This method has 1 argument, curr set to either 0 or 1

#### set_tuner_off

- write 0x80 to tuner register 1

- if curr is 1
- read tuner register 17 into tmp
- write tmp logical and 0xF0 into tmp
- write tmp to tuner register 17

- write 0x7F to tuner register 2
- read tuner register 5 into tmp
- write tmp logical or 0xF into tmp
- write tmp to tuner register 5
- write 0xFF to tuner register 6

- write 0x00 to tuner register 1

#### set_tuner_on

- write 0x80 to tuner register 1

- write 0x00 to tuner register 2
- read tuner register 5 into tmp
- write tmp logical and 0xF0 into tmp
- write tmp to tuner register 5
- write 0x00 to tuner register 6

- write 0x00 to tuner register 1