diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-01-20 14:58:17 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-01-20 14:58:17 -0200 |
commit | d0eb1f909832fbb0959a05a7bb96d31f2c385515 (patch) | |
tree | 2f90105f0835176e651e0085bd3130401a6f8d99 /linux/drivers/media/video/cx88/cx88-core.c | |
parent | c0720857a3c9833755f75a795763004cf643a0ae (diff) | |
download | mediapointer-dvb-s2-d0eb1f909832fbb0959a05a7bb96d31f2c385515.tar.gz mediapointer-dvb-s2-d0eb1f909832fbb0959a05a7bb96d31f2c385515.tar.bz2 |
Convert cx8800 driver to video_ioctl2 handler
From: Mauro Carvalho Chehab <mchehab@infradead.org>
video_ioctl2 handler provides V4L2 API parsing.
Using it makes the driver simpler, and isolates API parsing.
This allows future reusage of driver controls using other ways, like sysfs
and/or procfs and increases isolation of driver-specific handling from the
generic common ioctl processing.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/video/cx88/cx88-core.c')
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-core.c | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-core.c b/linux/drivers/media/video/cx88/cx88-core.c index fc8dbebbc..ab557ca97 100644 --- a/linux/drivers/media/video/cx88/cx88-core.c +++ b/linux/drivers/media/video/cx88/cx88-core.c @@ -5,6 +5,11 @@ * * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] * + * (c) 2005-2006 Mauro Carvalho Chehab <mchehab@infradead.org> + * - Multituner support + * - video_ioctl2 conversion + * - PAL/M fixes + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -671,22 +676,22 @@ int cx88_reset(struct cx88_core *core) /* ------------------------------------------------------------------ */ -static unsigned int inline norm_swidth(struct cx88_tvnorm *norm) +static unsigned int inline norm_swidth(struct v4l2_tvnorm *norm) { 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 v4l2_tvnorm *norm) { 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 v4l2_tvnorm *norm) { return (norm->id & V4L2_STD_625_50) ? 0x24 : 0x18; } -static unsigned int inline norm_fsc8(struct cx88_tvnorm *norm) +static unsigned int inline norm_fsc8(struct v4l2_tvnorm *norm) { if (norm->id & V4L2_STD_PAL_M) return 28604892; // 3.575611 MHz @@ -706,7 +711,7 @@ static unsigned int inline norm_fsc8(struct cx88_tvnorm *norm) return 35468950; // 4.43361875 MHz +/- 5 Hz } -static unsigned int inline norm_htotal(struct cx88_tvnorm *norm) +static unsigned int inline norm_htotal(struct v4l2_tvnorm *norm) { unsigned int fsc4=norm_fsc8(norm)/2; @@ -717,7 +722,7 @@ static unsigned int inline norm_htotal(struct cx88_tvnorm *norm) ((fsc4+262)/525*1001+15000)/30000; } -static unsigned int inline norm_vbipack(struct cx88_tvnorm *norm) +static unsigned int inline norm_vbipack(struct v4l2_tvnorm *norm) { return (norm->id & V4L2_STD_625_50) ? 511 : 400; } @@ -866,7 +871,7 @@ int cx88_stop_audio_dma(struct cx88_core *core) static int set_tvaudio(struct cx88_core *core) { - struct cx88_tvnorm *norm = core->tvnorm; + struct v4l2_tvnorm *norm = core->tvnorm; if (CX88_VMUX_TELEVISION != INPUT(core->input)->type) return 0; @@ -916,7 +921,7 @@ static int set_tvaudio(struct cx88_core *core) -int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm) +int cx88_set_tvnorm(struct cx88_core *core, struct v4l2_tvnorm *norm) { u32 fsc8; u32 adc_clock; @@ -924,6 +929,7 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm) u32 step_db,step_dr; u64 tmp64; u32 bdelay,agcdelay,htotal; + u32 cxiformat, cxoformat; core->tvnorm = norm; fsc8 = norm_fsc8(norm); @@ -932,9 +938,32 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm) step_db = fsc8; step_dr = fsc8; - if (norm->id & V4L2_STD_SECAM) { + if (norm->id & V4L2_STD_NTSC_M_JP) { + cxiformat = VideoFormatNTSCJapan; + cxoformat = 0x181f0008; + } else if (norm->id & V4L2_STD_PAL_M) { + cxiformat = VideoFormatPALM; + cxoformat = 0x1c1f0008; + } else if (norm->id & V4L2_STD_PAL_N) { + cxiformat = VideoFormatPALN; + cxoformat = 0x1c1f0008; + } else if (norm->id & V4L2_STD_PAL_Nc) { + cxiformat = VideoFormatPALNC; + cxoformat = 0x1c1f0008; + } else if (norm->id & V4L2_STD_PAL_60) { + cxiformat = VideoFormatPAL60; + cxoformat = 0x181f0008; + } else if (norm->id & V4L2_STD_NTSC) { + cxiformat = VideoFormatNTSC; + cxoformat = 0x181f0008; + } else if (norm->id & V4L2_STD_SECAM) { + cxiformat = VideoFormatSECAM; + cxoformat = 0x181f0008; step_db = 4250000 * 8; step_dr = 4406250 * 8; + } else { /* PAL */ + cxiformat = VideoFormatPAL; + cxoformat = 0x181f0008; } dprintk(1,"set_tvnorm: \"%s\" fsc8=%d adc=%d vdec=%d db/dr=%d/%d\n", @@ -942,14 +971,14 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm) set_pll(core,2,vdec_clock); dprintk(1,"set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n", - norm->cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f); - cx_andor(MO_INPUT_FORMAT, 0xf, norm->cxiformat); + cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f); + cx_andor(MO_INPUT_FORMAT, 0xf, cxiformat); #if 1 // FIXME: as-is from DScaler dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n", - norm->cxoformat, cx_read(MO_OUTPUT_FORMAT)); - cx_write(MO_OUTPUT_FORMAT, norm->cxoformat); + cxoformat, cx_read(MO_OUTPUT_FORMAT)); + cx_write(MO_OUTPUT_FORMAT, cxoformat); #endif // MO_SCONV_REG = adc clock / video dec clock * 2^17 |