Skip to content

Commit

Permalink
V4L/DVB (3268): Move video std detection to top of set_tv_freq function
Browse files Browse the repository at this point in the history
- move video std detection to top of set_tv_freq function
- we must detect video std first, so that we can choose the correct
  tuner_params

Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Michael Krufky authored and Mauro Carvalho Chehab committed Feb 7, 2006
1 parent a78d0bf commit 5f59418
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions drivers/media/video/tuner-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,29 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
tun = &tuners[t->type];
j = TUNER_PARAM_ANALOG;

/* IFPCoff = Video Intermediate Frequency - Vif:
940 =16*58.75 NTSC/J (Japan)
732 =16*45.75 M/N STD
704 =16*44 ATSC (at DVB code)
632 =16*39.50 I U.K.
622.4=16*38.90 B/G D/K I, L STD
592 =16*37.00 D China
590 =16.36.875 B Australia
543.2=16*33.95 L' STD
171.2=16*10.70 FM Radio (at set_radio_freq)
*/

if (t->std == V4L2_STD_NTSC_M_JP) {
IFPCoff = 940;
} else if ((t->std & V4L2_STD_MN) &&
!(t->std & ~V4L2_STD_MN)) {
IFPCoff = 732;
} else if (t->std == V4L2_STD_SECAM_LC) {
IFPCoff = 543;
} else {
IFPCoff = 623;
}

for (i = 0; i < tun->params[j].count; i++) {
if (freq > tun->params[j].ranges[i].limit)
continue;
Expand All @@ -154,11 +177,19 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
}
config = tun->params[j].ranges[i].config;
cb = tun->params[j].ranges[i].cb;
/* i == 0 -> VHF_LO */
/* i == 1 -> VHF_HI */
/* i == 2 -> UHF */
/* i == 0 -> VHF_LO
* i == 1 -> VHF_HI
* i == 2 -> UHF */
tuner_dbg("tv: range %d\n",i);

div=freq + IFPCoff + offset;

tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, Offset=%d.%02d MHz, div=%0d\n",
freq / 16, freq % 16 * 100 / 16,
IFPCoff / 16, IFPCoff % 16 * 100 / 16,
offset / 16, offset % 16 * 100 / 16,
div);

/* tv norm specific stuff for multi-norm tuners */
switch (t->type) {
case TUNER_PHILIPS_SECAM: // FI1216MF
Expand Down Expand Up @@ -245,37 +276,6 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
break;
}

/* IFPCoff = Video Intermediate Frequency - Vif:
940 =16*58.75 NTSC/J (Japan)
732 =16*45.75 M/N STD
704 =16*44 ATSC (at DVB code)
632 =16*39.50 I U.K.
622.4=16*38.90 B/G D/K I, L STD
592 =16*37.00 D China
590 =16.36.875 B Australia
543.2=16*33.95 L' STD
171.2=16*10.70 FM Radio (at set_radio_freq)
*/

if (t->std == V4L2_STD_NTSC_M_JP) {
IFPCoff = 940;
} else if ((t->std & V4L2_STD_MN) &&
!(t->std & ~V4L2_STD_MN)) {
IFPCoff = 732;
} else if (t->std == V4L2_STD_SECAM_LC) {
IFPCoff = 543;
} else {
IFPCoff = 623;
}

div=freq + IFPCoff + offset;

tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, Offset=%d.%02d MHz, div=%0d\n",
freq / 16, freq % 16 * 100 / 16,
IFPCoff / 16, IFPCoff % 16 * 100 / 16,
offset / 16, offset % 16 * 100 / 16,
div);

if (tuners[t->type].params->cb_first_if_lower_freq && div < t->last_div) {
buffer[0] = config;
buffer[1] = cb;
Expand Down

0 comments on commit 5f59418

Please sign in to comment.