Commit 315eb962 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

V4L/DVB (4980): Fixes bug 7267: PAL/60 is not working

On cx88 driver, sampling rate should be at chroma subcarrier freq (FSC).
However, driver were programming wrong values for PAL/60, PAL/Nc and
NTSC 4.43. This patch do the proper calculation. It also calculates
htotal, hdelay and hactive constants, according with the sampling
rate.
It is tested with PAL/60 by Piotr Maksymuk and Olivier. Also tested with
the already-supported standards.

Test is still required for PAL/Nc.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent ed00b41d
...@@ -633,12 +633,12 @@ int cx88_reset(struct cx88_core *core) ...@@ -633,12 +633,12 @@ int cx88_reset(struct cx88_core *core)
static unsigned int inline norm_swidth(struct cx88_tvnorm *norm) static unsigned int inline norm_swidth(struct cx88_tvnorm *norm)
{ {
return (norm->id & V4L2_STD_625_50) ? 922 : 754; return (norm->id & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 754 : 922;
} }
static unsigned int inline norm_hdelay(struct cx88_tvnorm *norm) static unsigned int inline norm_hdelay(struct cx88_tvnorm *norm)
{ {
return (norm->id & V4L2_STD_625_50) ? 186 : 135; return (norm->id & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 135 : 186;
} }
static unsigned int inline norm_vdelay(struct cx88_tvnorm *norm) static unsigned int inline norm_vdelay(struct cx88_tvnorm *norm)
...@@ -648,24 +648,33 @@ static unsigned int inline norm_vdelay(struct cx88_tvnorm *norm) ...@@ -648,24 +648,33 @@ static unsigned int inline norm_vdelay(struct cx88_tvnorm *norm)
static unsigned int inline norm_fsc8(struct cx88_tvnorm *norm) static unsigned int inline norm_fsc8(struct cx88_tvnorm *norm)
{ {
static const unsigned int ntsc = 28636360;
static const unsigned int pal = 35468950;
static const unsigned int palm = 28604892;
if (norm->id & V4L2_STD_PAL_M) if (norm->id & V4L2_STD_PAL_M)
return palm; return 28604892; // 3.575611 MHz
if (norm->id & (V4L2_STD_PAL_Nc))
return 28656448; // 3.582056 MHz
if (norm->id & V4L2_STD_NTSC) // All NTSC/M and variants
return 28636360; // 3.57954545 MHz +/- 10 Hz
return (norm->id & V4L2_STD_625_50) ? pal : ntsc; /* SECAM have also different sub carrier for chroma,
but step_db and step_dr, at cx88_set_tvnorm already handles that.
The same FSC applies to PAL/BGDKIH, PAL/60, NTSC/4.43 and PAL/N
*/
return 35468950; // 4.43361875 MHz +/- 5 Hz
} }
static unsigned int inline norm_htotal(struct cx88_tvnorm *norm) static unsigned int inline norm_htotal(struct cx88_tvnorm *norm)
{ {
/* Should always be Line Draw Time / (4*FSC) */
if (norm->id & V4L2_STD_PAL_M) unsigned int fsc4=norm_fsc8(norm)/2;
return 909;
return (norm->id & V4L2_STD_625_50) ? 1135 : 910; /* returns 4*FSC / vtotal / frames per seconds */
return (norm->id & V4L2_STD_625_50) ?
((fsc4+312)/625+12)/25 :
((fsc4+262)/525*1001+15000)/30000;
} }
static unsigned int inline norm_vbipack(struct cx88_tvnorm *norm) static unsigned int inline norm_vbipack(struct cx88_tvnorm *norm)
...@@ -692,7 +701,7 @@ int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int heig ...@@ -692,7 +701,7 @@ int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int heig
value &= 0x3fe; value &= 0x3fe;
cx_write(MO_HDELAY_EVEN, value); cx_write(MO_HDELAY_EVEN, value);
cx_write(MO_HDELAY_ODD, value); cx_write(MO_HDELAY_ODD, value);
dprintk(1,"set_scale: hdelay 0x%04x\n", value); dprintk(1,"set_scale: hdelay 0x%04x (width %d)\n", value,swidth);
value = (swidth * 4096 / width) - 4096; value = (swidth * 4096 / width) - 4096;
cx_write(MO_HSCALE_EVEN, value); cx_write(MO_HSCALE_EVEN, value);
......
...@@ -91,7 +91,7 @@ struct cx88_tvnorm { ...@@ -91,7 +91,7 @@ struct cx88_tvnorm {
static unsigned int inline norm_maxw(struct cx88_tvnorm *norm) static unsigned int inline norm_maxw(struct cx88_tvnorm *norm)
{ {
return (norm->id & V4L2_STD_625_50) ? 768 : 640; return (norm->id & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 720 : 768;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment