Commit 8d87cb9f authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

V4L/DVB (5097): Convert cx8800 driver to video_ioctl2 handler

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: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent fd694964
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
* *
* (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] * (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 * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
...@@ -631,22 +636,22 @@ int cx88_reset(struct cx88_core *core) ...@@ -631,22 +636,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; 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; 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; 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) if (norm->id & V4L2_STD_PAL_M)
return 28604892; // 3.575611 MHz return 28604892; // 3.575611 MHz
...@@ -666,7 +671,7 @@ static unsigned int inline norm_fsc8(struct cx88_tvnorm *norm) ...@@ -666,7 +671,7 @@ static unsigned int inline norm_fsc8(struct cx88_tvnorm *norm)
return 35468950; // 4.43361875 MHz +/- 5 Hz 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; unsigned int fsc4=norm_fsc8(norm)/2;
...@@ -677,7 +682,7 @@ static unsigned int inline norm_htotal(struct cx88_tvnorm *norm) ...@@ -677,7 +682,7 @@ static unsigned int inline norm_htotal(struct cx88_tvnorm *norm)
((fsc4+262)/525*1001+15000)/30000; ((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; return (norm->id & V4L2_STD_625_50) ? 511 : 400;
} }
...@@ -826,7 +831,7 @@ int cx88_stop_audio_dma(struct cx88_core *core) ...@@ -826,7 +831,7 @@ int cx88_stop_audio_dma(struct cx88_core *core)
static int set_tvaudio(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) if (CX88_VMUX_TELEVISION != INPUT(core->input)->type)
return 0; return 0;
...@@ -874,7 +879,7 @@ static int set_tvaudio(struct cx88_core *core) ...@@ -874,7 +879,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 fsc8;
u32 adc_clock; u32 adc_clock;
...@@ -882,6 +887,7 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm) ...@@ -882,6 +887,7 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
u32 step_db,step_dr; u32 step_db,step_dr;
u64 tmp64; u64 tmp64;
u32 bdelay,agcdelay,htotal; u32 bdelay,agcdelay,htotal;
u32 cxiformat, cxoformat;
core->tvnorm = norm; core->tvnorm = norm;
fsc8 = norm_fsc8(norm); fsc8 = norm_fsc8(norm);
...@@ -890,9 +896,32 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm) ...@@ -890,9 +896,32 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
step_db = fsc8; step_db = fsc8;
step_dr = 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_db = 4250000 * 8;
step_dr = 4406250 * 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", dprintk(1,"set_tvnorm: \"%s\" fsc8=%d adc=%d vdec=%d db/dr=%d/%d\n",
...@@ -900,13 +929,13 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm) ...@@ -900,13 +929,13 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
set_pll(core,2,vdec_clock); set_pll(core,2,vdec_clock);
dprintk(1,"set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n", dprintk(1,"set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n",
norm->cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f); cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f);
cx_andor(MO_INPUT_FORMAT, 0xf, norm->cxiformat); cx_andor(MO_INPUT_FORMAT, 0xf, cxiformat);
// FIXME: as-is from DScaler // FIXME: as-is from DScaler
dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n", dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n",
norm->cxoformat, cx_read(MO_OUTPUT_FORMAT)); cxoformat, cx_read(MO_OUTPUT_FORMAT));
cx_write(MO_OUTPUT_FORMAT, norm->cxoformat); cx_write(MO_OUTPUT_FORMAT, cxoformat);
// MO_SCONV_REG = adc clock / video dec clock * 2^17 // MO_SCONV_REG = adc clock / video dec clock * 2^17
tmp64 = adc_clock * (u64)(1 << 17); tmp64 = adc_clock * (u64)(1 << 17);
......
...@@ -21,9 +21,11 @@ MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]"); ...@@ -21,9 +21,11 @@ MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]");
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f) int cx8800_vbi_fmt (struct file *file, void *priv,
struct v4l2_format *f)
{ {
memset(&f->fmt.vbi,0,sizeof(f->fmt.vbi)); struct cx8800_fh *fh = priv;
struct cx8800_dev *dev = fh->dev;
f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH; f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH;
f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY;
...@@ -43,6 +45,7 @@ void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f) ...@@ -43,6 +45,7 @@ void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f)
f->fmt.vbi.start[0] = 7 -1; f->fmt.vbi.start[0] = 7 -1;
f->fmt.vbi.start[1] = 319 -1; f->fmt.vbi.start[1] = 319 -1;
} }
return 0;
} }
static int cx8800_start_vbi_dma(struct cx8800_dev *dev, static int cx8800_start_vbi_dma(struct cx8800_dev *dev,
......
/* /*
* *
* device driver for Conexant 2388x based TV cards * device driver for Conexant 2388x based TV cards
...@@ -5,6 +6,11 @@ ...@@ -5,6 +6,11 @@
* *
* (c) 2003-04 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] * (c) 2003-04 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 * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
...@@ -80,62 +86,47 @@ static LIST_HEAD(cx8800_devlist); ...@@ -80,62 +86,47 @@ static LIST_HEAD(cx8800_devlist);
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
/* static data */ /* static data */
static struct cx88_tvnorm tvnorms[] = { static struct v4l2_tvnorm tvnorms[] = {
{ {
.name = "NTSC-M", .name = "NTSC-M",
.id = V4L2_STD_NTSC_M, .id = V4L2_STD_NTSC_M,
.cxiformat = VideoFormatNTSC,
.cxoformat = 0x181f0008,
},{ },{
.name = "NTSC-JP", .name = "NTSC-JP",
.id = V4L2_STD_NTSC_M_JP, .id = V4L2_STD_NTSC_M_JP,
.cxiformat = VideoFormatNTSCJapan,
.cxoformat = 0x181f0008,
},{ },{
.name = "PAL-BG", .name = "PAL-BG",
.id = V4L2_STD_PAL_BG, .id = V4L2_STD_PAL_BG,
.cxiformat = VideoFormatPAL,
.cxoformat = 0x181f0008,
},{ },{
.name = "PAL-DK", .name = "PAL-DK",
.id = V4L2_STD_PAL_DK, .id = V4L2_STD_PAL_DK,
.cxiformat = VideoFormatPAL,
.cxoformat = 0x181f0008,
},{ },{
.name = "PAL-I", .name = "PAL-I",
.id = V4L2_STD_PAL_I, .id = V4L2_STD_PAL_I,
.cxiformat = VideoFormatPAL,
.cxoformat = 0x181f0008,
},{ },{
.name = "PAL-M", .name = "PAL-M",
.id = V4L2_STD_PAL_M, .id = V4L2_STD_PAL_M,
.cxiformat = VideoFormatPALM,
.cxoformat = 0x1c1f0008,
},{ },{
.name = "PAL-N", .name = "PAL-N",
.id = V4L2_STD_PAL_N, .id = V4L2_STD_PAL_N,
.cxiformat = VideoFormatPALN,
.cxoformat = 0x1c1f0008,
},{ },{
.name = "PAL-Nc", .name = "PAL-Nc",
.id = V4L2_STD_PAL_Nc, .id = V4L2_STD_PAL_Nc,
.cxiformat = VideoFormatPALNC,
.cxoformat = 0x1c1f0008,
},{ },{
.name = "PAL-60", .name = "PAL-60",
.id = V4L2_STD_PAL_60, .id = V4L2_STD_PAL_60,
.cxiformat = VideoFormatPAL60,
.cxoformat = 0x181f0008,
},{ },{
.name = "SECAM-L", .name = "SECAM-L",
.id = V4L2_STD_SECAM_L, .id = V4L2_STD_SECAM_L,
.cxiformat = VideoFormatSECAM,
.cxoformat = 0x181f0008,
},{ },{
.name = "SECAM-DK", .name = "SECAM-DK",
.id = V4L2_STD_SECAM_DK, .id = V4L2_STD_SECAM_DK,
.cxiformat = VideoFormatSECAM, }
.cxoformat = 0x181f0008, };
static struct v4l2_tvnorm radionorms[] = {
{
.name = "RADIO",
.id = 0,
} }
}; };
...@@ -364,14 +355,6 @@ int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl) ...@@ -364,14 +355,6 @@ int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl)
} }
EXPORT_SYMBOL(cx8800_ctrl_query); EXPORT_SYMBOL(cx8800_ctrl_query);
static int cx88_queryctrl(struct v4l2_queryctrl *qctrl)
{
qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
if (qctrl->id == 0)
return -EINVAL;
return cx8800_ctrl_query(qctrl);
}
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
/* resource management */ /* resource management */
...@@ -944,11 +927,12 @@ video_mmap(struct file *file, struct vm_area_struct * vma) ...@@ -944,11 +927,12 @@ video_mmap(struct file *file, struct vm_area_struct * vma)
} }
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* VIDEO CTRL IOCTLS */
/* static int get_control(struct cx8800_dev *dev, struct v4l2_control *ctl) */ static int vidioc_g_ctrl (struct file *file, void *priv,
static int get_control(struct cx88_core *core, struct v4l2_control *ctl) struct v4l2_control *ctl)
{ {
/* struct cx88_core *core = dev->core; */ struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
struct cx88_ctrl *c = NULL; struct cx88_ctrl *c = NULL;
u32 value; u32 value;
int i; int i;
...@@ -956,7 +940,7 @@ static int get_control(struct cx88_core *core, struct v4l2_control *ctl) ...@@ -956,7 +940,7 @@ static int get_control(struct cx88_core *core, struct v4l2_control *ctl)
for (i = 0; i < CX8800_CTLS; i++) for (i = 0; i < CX8800_CTLS; i++)
if (cx8800_ctls[i].v.id == ctl->id) if (cx8800_ctls[i].v.id == ctl->id)
c = &cx8800_ctls[i]; c = &cx8800_ctls[i];
if (NULL == c) if (unlikely(NULL == c))
return -EINVAL; return -EINVAL;
value = c->sreg ? cx_sread(c->sreg) : cx_read(c->reg); value = c->sreg ? cx_sread(c->sreg) : cx_read(c->reg);
...@@ -978,19 +962,18 @@ static int get_control(struct cx88_core *core, struct v4l2_control *ctl) ...@@ -978,19 +962,18 @@ static int get_control(struct cx88_core *core, struct v4l2_control *ctl)
return 0; return 0;
} }
/* static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) */
static int set_control(struct cx88_core *core, struct v4l2_control *ctl) static int set_control(struct cx88_core *core, struct v4l2_control *ctl)
{ {
/* struct cx88_core *core = dev->core; */
struct cx88_ctrl *c = NULL; struct cx88_ctrl *c = NULL;
u32 value,mask; u32 value,mask;
int i; int i;
for (i = 0; i < CX8800_CTLS; i++) { for (i = 0; i < CX8800_CTLS; i++) {
if (cx8800_ctls[i].v.id == ctl->id) { if (cx8800_ctls[i].v.id == ctl->id) {
c = &cx8800_ctls[i]; c = &cx8800_ctls[i];
} }
} }
if (NULL == c) if (unlikely(NULL == c))
return -EINVAL; return -EINVAL;
if (ctl->value < c->v.minimum) if (ctl->value < c->v.minimum)
...@@ -1042,18 +1025,19 @@ static void init_controls(struct cx88_core *core) ...@@ -1042,18 +1025,19 @@ static void init_controls(struct cx88_core *core)
for (i = 0; i < CX8800_CTLS; i++) { for (i = 0; i < CX8800_CTLS; i++) {
ctrl.id=cx8800_ctls[i].v.id; ctrl.id=cx8800_ctls[i].v.id;
ctrl.value=cx8800_ctls[i].v.default_value; ctrl.value=cx8800_ctls[i].v.default_value;
set_control(core, &ctrl); set_control(core, &ctrl);
} }
} }
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* VIDEO IOCTLS */
static int cx8800_g_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, static int vidioc_g_fmt_cap (struct file *file, void *priv,
struct v4l2_format *f) struct v4l2_format *f)
{ {
switch (f->type) { struct cx8800_fh *fh = priv;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
memset(&f->fmt.pix,0,sizeof(f->fmt.pix));
f->fmt.pix.width = fh->width; f->fmt.pix.width = fh->width;
f->fmt.pix.height = fh->height; f->fmt.pix.height = fh->height;
f->fmt.pix.field = fh->vidq.field; f->fmt.pix.field = fh->vidq.field;
...@@ -1063,22 +1047,12 @@ static int cx8800_g_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, ...@@ -1063,22 +1047,12 @@ static int cx8800_g_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh,
f->fmt.pix.sizeimage = f->fmt.pix.sizeimage =
f->fmt.pix.height * f->fmt.pix.bytesperline; f->fmt.pix.height * f->fmt.pix.bytesperline;
return 0; return 0;
case V4L2_BUF_TYPE_VBI_CAPTURE:
cx8800_vbi_fmt(dev, f);
return 0;
default:
return -EINVAL;
}
} }
static int cx8800_try_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, static int vidioc_try_fmt_cap (struct file *file, void *priv,
struct v4l2_format *f) struct v4l2_format *f)
{ {
struct cx88_core *core = dev->core; struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
switch (f->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
{
struct cx8800_fmt *fmt; struct cx8800_fmt *fmt;
enum v4l2_field field; enum v4l2_field field;
unsigned int maxw, maxh; unsigned int maxw, maxh;
...@@ -1124,62 +1098,29 @@ static int cx8800_try_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, ...@@ -1124,62 +1098,29 @@ static int cx8800_try_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh,
f->fmt.pix.height * f->fmt.pix.bytesperline; f->fmt.pix.height * f->fmt.pix.bytesperline;
return 0; return 0;
}
case V4L2_BUF_TYPE_VBI_CAPTURE:
cx8800_vbi_fmt(dev, f);
return 0;
default:
return -EINVAL;
}
} }
static int cx8800_s_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh, static int vidioc_s_fmt_cap (struct file *file, void *priv,
struct v4l2_format *f) struct v4l2_format *f)
{ {
int err; struct cx8800_fh *fh = priv;
int err = vidioc_try_fmt_cap (file,priv,f);
switch (f->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
err = cx8800_try_fmt(dev,fh,f);
if (0 != err) if (0 != err)
return err; return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->width = f->fmt.pix.width; fh->width = f->fmt.pix.width;
fh->height = f->fmt.pix.height; fh->height = f->fmt.pix.height;
fh->vidq.field = f->fmt.pix.field; fh->vidq.field = f->fmt.pix.field;
return 0; return 0;
case V4L2_BUF_TYPE_VBI_CAPTURE:
cx8800_vbi_fmt(dev, f);
return 0;
default:
return -EINVAL;
}
} }
/* static int vidioc_querycap (struct file *file, void *priv,
* This function is _not_ called directly, but from struct v4l2_capability *cap)
* video_generic_ioctl (and maybe others). userspace
* copying is done already, arg is a kernel pointer.
*/
static int video_do_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *arg)
{ {
struct cx8800_fh *fh = file->private_data; struct cx8800_dev *dev = ((struct cx8800_fh *)priv)->dev;
struct cx8800_dev *dev = fh->dev;
struct cx88_core *core = dev->core; struct cx88_core *core = dev->core;
int err;
if (video_debug > 1)
v4l_print_ioctl(core->name,cmd);
switch (cmd) {
/* --- capabilities ------------------------------------------ */
case VIDIOC_QUERYCAP:
{
struct v4l2_capability *cap = arg;
memset(cap,0,sizeof(*cap));
strcpy(cap->driver, "cx8800"); strcpy(cap->driver, "cx8800");
strlcpy(cap->card, cx88_boards[core->board].name, strlcpy(cap->card, cx88_boards[core->board].name,
sizeof(cap->card)); sizeof(cap->card));
...@@ -1189,60 +1130,32 @@ static int video_do_ioctl(struct inode *inode, struct file *file, ...@@ -1189,60 +1130,32 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE |
V4L2_CAP_READWRITE | V4L2_CAP_READWRITE |
V4L2_CAP_STREAMING | V4L2_CAP_STREAMING |
V4L2_CAP_VBI_CAPTURE | V4L2_CAP_VBI_CAPTURE;
0;
if (UNSET != core->tuner_type) if (UNSET != core->tuner_type)
cap->capabilities |= V4L2_CAP_TUNER; cap->capabilities |= V4L2_CAP_TUNER;
return 0; return 0;
} }
/* --- capture ioctls ---------------------------------------- */
case VIDIOC_ENUM_FMT:
{
struct v4l2_fmtdesc *f = arg;
enum v4l2_buf_type type;
unsigned int index;
index = f->index; static int vidioc_enum_fmt_cap (struct file *file, void *priv,
type = f->type; struct v4l2_fmtdesc *f)
switch (type) { {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: if (unlikely(f->index >= ARRAY_SIZE(formats)))
if (index >= ARRAY_SIZE(formats))
return -EINVAL;
memset(f,0,sizeof(*f));
f->index = index;
f->type = type;
strlcpy(f->description,formats[index].name,sizeof(f->description));
f->pixelformat = formats[index].fourcc;
break;
default:
return -EINVAL; return -EINVAL;
}
strlcpy(f->description,formats[f->index].name,sizeof(f->description));
f->pixelformat = formats[f->index].fourcc;
return 0; return 0;
} }
case VIDIOC_G_FMT:
{
struct v4l2_format *f = arg;
return cx8800_g_fmt(dev,fh,f);
}
case VIDIOC_S_FMT:
{
struct v4l2_format *f = arg;
return cx8800_s_fmt(dev,fh,f);
}
case VIDIOC_TRY_FMT:
{
struct v4l2_format *f = arg;
return cx8800_try_fmt(dev,fh,f);
}
#ifdef CONFIG_VIDEO_V4L1_COMPAT #ifdef CONFIG_VIDEO_V4L1_COMPAT
/* --- streaming capture ------------------------------------- */ static int vidiocgmbuf (struct file *file, void *priv, struct video_mbuf *mbuf)
case VIDIOCGMBUF: {
{ struct cx8800_fh *fh = priv;
struct video_mbuf *mbuf = arg;
struct videobuf_queue *q; struct videobuf_queue *q;
struct v4l2_requestbuffers req; struct v4l2_requestbuffers req;
unsigned int i; unsigned int i;
int err;
q = get_queue(fh); q = get_queue(fh);
memset(&req,0,sizeof(req)); memset(&req,0,sizeof(req));
...@@ -1252,7 +1165,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file, ...@@ -1252,7 +1165,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
err = videobuf_reqbufs(q,&req); err = videobuf_reqbufs(q,&req);
if (err < 0) if (err < 0)
return err; return err;
memset(mbuf,0,sizeof(*mbuf));
mbuf->frames = req.count; mbuf->frames = req.count;
mbuf->size = 0; mbuf->size = 0;
for (i = 0; i < mbuf->frames; i++) { for (i = 0; i < mbuf->frames; i++) {
...@@ -1260,106 +1173,85 @@ static int video_do_ioctl(struct inode *inode, struct file *file, ...@@ -1260,106 +1173,85 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
mbuf->size += q->bufs[i]->bsize; mbuf->size += q->bufs[i]->bsize;
} }
return 0; return 0;
} }
#endif #endif
case VIDIOC_REQBUFS:
return videobuf_reqbufs(get_queue(fh), arg);
case VIDIOC_QUERYBUF:
return videobuf_querybuf(get_queue(fh), arg);
case VIDIOC_QBUF:
return videobuf_qbuf(get_queue(fh), arg);
case VIDIOC_DQBUF: static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p)
return videobuf_dqbuf(get_queue(fh), arg, {
file->f_flags & O_NONBLOCK); struct cx8800_fh *fh = priv;
return (videobuf_reqbufs(get_queue(fh), p));
}
case VIDIOC_STREAMON: static int vidioc_querybuf (struct file *file, void *priv, struct v4l2_buffer *p)
{ {
int res = get_ressource(fh); struct cx8800_fh *fh = priv;
return (videobuf_querybuf(get_queue(fh), p));
}
if (!res_get(dev,fh,res)) static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *p)
return -EBUSY; {
return videobuf_streamon(get_queue(fh)); struct cx8800_fh *fh = priv;
} return (videobuf_qbuf(get_queue(fh), p));
case VIDIOC_STREAMOFF: }
{
int res = get_ressource(fh);
err = videobuf_streamoff(get_queue(fh)); static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p)
if (err < 0) {
return err; struct cx8800_fh *fh = priv;
res_free(dev,fh,res); return (videobuf_dqbuf(get_queue(fh), p,
return 0; file->f_flags & O_NONBLOCK));
}
default:
return cx88_do_ioctl( inode, file, fh->radio, core, cmd, arg, video_do_ioctl );
}
return 0;
} }
int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
struct cx88_core *core, unsigned int cmd, void *arg, v4l2_kioctl driver_ioctl)
{ {
int err; struct cx8800_fh *fh = priv;
struct cx8800_dev *dev = fh->dev;
if (video_debug) { if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
if (video_debug > 1) { return -EINVAL;
if (_IOC_DIR(cmd) & _IOC_WRITE) if (unlikely(i != fh->type))
v4l_printk_ioctl_arg("cx88(w)",cmd, arg); return -EINVAL;
else if (!_IOC_DIR(cmd) & _IOC_READ) {
v4l_print_ioctl("cx88", cmd);
}
} else
v4l_print_ioctl(core->name,cmd);
} if (unlikely(!res_get(dev,fh,get_ressource(fh))))
return -EBUSY;
return videobuf_streamon(get_queue(fh));
}
switch (cmd) { static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
/* ---------- tv norms ---------- */ {
case VIDIOC_ENUMSTD: struct cx8800_fh *fh = priv;
{ struct cx8800_dev *dev = fh->dev;
struct v4l2_standard *e = arg; int err, res;
unsigned int i;
i = e->index; if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
if (i >= ARRAY_SIZE(tvnorms))
return -EINVAL; return -EINVAL;
err = v4l2_video_std_construct(e, tvnorms[e->index].id, if (i != fh->type)
tvnorms[e->index].name); return -EINVAL;
e->index = i;
res = get_ressource(fh);
err = videobuf_streamoff(get_queue(fh));
if (err < 0) if (err < 0)
return err; return err;
res_free(dev,fh,res);
return 0; return 0;
} }
case VIDIOC_G_STD:
{
v4l2_std_id *id = arg;
*id = core->tvnorm->id;
return 0;
}
case VIDIOC_S_STD:
{
v4l2_std_id *id = arg;
unsigned int i;
for(i = 0; i < ARRAY_SIZE(tvnorms); i++) static int vidioc_s_std (struct file *file, void *priv, unsigned int i)
if (*id & tvnorms[i].id) {
break; struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
if (i == ARRAY_SIZE(tvnorms))
return -EINVAL;
mutex_lock(&core->lock); mutex_lock(&core->lock);
cx88_set_tvnorm(core,&tvnorms[i]); cx88_set_tvnorm(core,&tvnorms[i]);
mutex_unlock(&core->lock); mutex_unlock(&core->lock);
return 0; return 0;
} }
/* only one input in this sample driver */
static int vidioc_enum_input (struct file *file, void *priv,
struct v4l2_input *i)
{
struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
/* ------ input switching ---------- */
case VIDIOC_ENUMINPUT:
{
static const char *iname[] = { static const char *iname[] = {
[ CX88_VMUX_COMPOSITE1 ] = "Composite1", [ CX88_VMUX_COMPOSITE1 ] = "Composite1",
[ CX88_VMUX_COMPOSITE2 ] = "Composite2", [ CX88_VMUX_COMPOSITE2 ] = "Composite2",
...@@ -1371,7 +1263,6 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, ...@@ -1371,7 +1263,6 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
[ CX88_VMUX_DVB ] = "DVB", [ CX88_VMUX_DVB ] = "DVB",
[ CX88_VMUX_DEBUG ] = "for debug only", [ CX88_VMUX_DEBUG ] = "for debug only",
}; };
struct v4l2_input *i = arg;
unsigned int n; unsigned int n;
n = i->index; n = i->index;
...@@ -1389,53 +1280,59 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, ...@@ -1389,53 +1280,59 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
for (n = 0; n < ARRAY_SIZE(tvnorms); n++) for (n = 0; n < ARRAY_SIZE(tvnorms); n++)
i->std |= tvnorms[n].id; i->std |= tvnorms[n].id;
return 0; return 0;
} }
case VIDIOC_G_INPUT:
{ static int vidioc_g_input (struct file *file, void *priv, unsigned int *i)
unsigned int *i = arg; {
struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
*i = core->input; *i = core->input;
return 0; return 0;
} }
case VIDIOC_S_INPUT:
{
unsigned int *i = arg;
if (*i >= 4) static int vidioc_s_input (struct file *file, void *priv, unsigned int i)
{
struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
if (i >= 4)
return -EINVAL; return -EINVAL;
mutex_lock(&core->lock); mutex_lock(&core->lock);
cx88_newstation(core); cx88_newstation(core);
video_mux(core,*i); video_mux(core,i);
mutex_unlock(&core->lock); mutex_unlock(&core->lock);
return 0; return 0;
} }
/* --- controls ---------------------------------------------- */ static int vidioc_queryctrl (struct file *file, void *priv,
case VIDIOC_QUERYCTRL: struct v4l2_queryctrl *qctrl)
{ {
struct v4l2_queryctrl *c = arg; qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
if (unlikely(qctrl->id == 0))
return -EINVAL;
return cx8800_ctrl_query(qctrl);
}
return cx88_queryctrl(c); static int vidioc_s_ctrl (struct file *file, void *priv,
} struct v4l2_control *ctl)
case VIDIOC_G_CTRL: {
return get_control(core,arg); struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
case VIDIOC_S_CTRL:
return set_control(core,arg);
/* --- tuner ioctls ------------------------------------------ */ return
case VIDIOC_G_TUNER: set_control(core,ctl);
{ }
struct v4l2_tuner *t = arg;
static int vidioc_g_tuner (struct file *file, void *priv,
struct v4l2_tuner *t)
{
struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
u32 reg; u32 reg;
if (UNSET == core->tuner_type) if (unlikely(UNSET == core->tuner_type))
return -EINVAL;
if (0 != t->index)
return -EINVAL; return -EINVAL;
memset(t,0,sizeof(*t));
strcpy(t->name, "Television"); strcpy(t->name, "Television");
t->type = V4L2_TUNER_ANALOG_TV; t->type = V4L2_TUNER_ANALOG_TV;
t->capability = V4L2_TUNER_CAP_NORM; t->capability = V4L2_TUNER_CAP_NORM;
...@@ -1445,46 +1342,53 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, ...@@ -1445,46 +1342,53 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
reg = cx_read(MO_DEVICE_STATUS); reg = cx_read(MO_DEVICE_STATUS);
t->signal = (reg & (1<<5)) ? 0xffff : 0x0000; t->signal = (reg & (1<<5)) ? 0xffff : 0x0000;
return 0; return 0;
} }
case VIDIOC_S_TUNER:
{ static int vidioc_s_tuner (struct file *file, void *priv,
struct v4l2_tuner *t = arg; struct v4l2_tuner *t)
{
struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
if (UNSET == core->tuner_type) if (UNSET == core->tuner_type)
return -EINVAL; return -EINVAL;
if (0 != t->index) if (0 != t->index)
return -EINVAL; return -EINVAL;
cx88_set_stereo(core, t->audmode, 1); cx88_set_stereo(core, t->audmode, 1);
return 0; return 0;
} }
case VIDIOC_G_FREQUENCY:
{
struct v4l2_frequency *f = arg;
memset(f,0,sizeof(*f)); static int vidioc_g_frequency (struct file *file, void *priv,
struct v4l2_frequency *f)
{
struct cx8800_fh *fh = priv;
struct cx88_core *core = fh->dev->core;
if (UNSET == core->tuner_type) if (unlikely(UNSET == core->tuner_type))
return -EINVAL; return -EINVAL;
/* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */ /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */
f->type = radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
f->frequency = core->freq; f->frequency = core->freq;
cx88_call_i2c_clients(core,VIDIOC_G_FREQUENCY,f); cx88_call_i2c_clients(core,VIDIOC_G_FREQUENCY,f);
return 0; return 0;
} }
case VIDIOC_S_FREQUENCY:
{
struct v4l2_frequency *f = arg;
if (UNSET == core->tuner_type) static int vidioc_s_frequency (struct file *file, void *priv,
struct v4l2_frequency *f)
{
struct cx8800_fh *fh = priv;
struct cx88_core *core = fh->dev->core;
if (unlikely(UNSET == core->tuner_type))
return -EINVAL; return -EINVAL;
if (f->tuner != 0) if (unlikely(f->tuner != 0))
return -EINVAL; return -EINVAL;
if (0 == radio && f->type != V4L2_TUNER_ANALOG_TV) if (unlikely(0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV))
return -EINVAL; return -EINVAL;
if (1 == radio && f->type != V4L2_TUNER_RADIO) if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO))
return -EINVAL; return -EINVAL;
mutex_lock(&core->lock); mutex_lock(&core->lock);
core->freq = f->frequency; core->freq = f->frequency;
...@@ -1497,75 +1401,19 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, ...@@ -1497,75 +1401,19 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
mutex_unlock(&core->lock); mutex_unlock(&core->lock);
return 0; return 0;
}
#ifdef CONFIG_VIDEO_ADV_DEBUG
/* ioctls to allow direct acces to the cx2388x registers */
case VIDIOC_INT_G_REGISTER:
{
struct v4l2_register *reg = arg;
if (reg->i2c_id != 0)
return -EINVAL;
/* cx2388x has a 24-bit register space */
reg->val = cx_read(reg->reg&0xffffff);
return 0;
}
case VIDIOC_INT_S_REGISTER:
{
struct v4l2_register *reg = arg;
if (reg->i2c_id != 0)
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
cx_write(reg->reg&0xffffff, reg->val);
return 0;
}
#endif
default:
return v4l_compat_translate_ioctl(inode,file,cmd,arg,
driver_ioctl);
}
return 0;
} }
static int video_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
int retval;
retval=video_usercopy(inode, file, cmd, arg, video_do_ioctl);
if (video_debug > 1) {
if (retval < 0) {
v4l_print_ioctl("cx88(err)", cmd);
printk(KERN_DEBUG "cx88(err): errcode=%d\n",retval);
} else if (_IOC_DIR(cmd) & _IOC_READ)
v4l_printk_ioctl_arg("cx88(r)",cmd, (void *)arg);
}
return retval;
}
/* ----------------------------------------------------------- */
/* RADIO ESPECIFIC IOCTLS */
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
static int radio_do_ioctl(struct inode *inode, struct file *file, static int radio_querycap (struct file *file, void *priv,
unsigned int cmd, void *arg) struct v4l2_capability *cap)
{ {
struct cx8800_fh *fh = file->private_data; struct cx8800_dev *dev = ((struct cx8800_fh *)priv)->dev;
struct cx8800_dev *dev = fh->dev;
struct cx88_core *core = dev->core; struct cx88_core *core = dev->core;
if (video_debug > 1)
v4l_print_ioctl(core->name,cmd);
switch (cmd) {
case VIDIOC_QUERYCAP:
{
struct v4l2_capability *cap = arg;
memset(cap,0,sizeof(*cap));
strcpy(cap->driver, "cx8800"); strcpy(cap->driver, "cx8800");
strlcpy(cap->card, cx88_boards[core->board].name, strlcpy(cap->card, cx88_boards[core->board].name,
sizeof(cap->card)); sizeof(cap->card));
...@@ -1573,66 +1421,50 @@ static int radio_do_ioctl(struct inode *inode, struct file *file, ...@@ -1573,66 +1421,50 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
cap->version = CX88_VERSION_CODE; cap->version = CX88_VERSION_CODE;
cap->capabilities = V4L2_CAP_TUNER; cap->capabilities = V4L2_CAP_TUNER;
return 0; return 0;
} }
case VIDIOC_G_TUNER:
{
struct v4l2_tuner *t = arg;
if (t->index > 0) static int radio_g_tuner (struct file *file, void *priv,
struct v4l2_tuner *t)
{
struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
if (unlikely(t->index > 0))
return -EINVAL; return -EINVAL;
memset(t,0,sizeof(*t));
strcpy(t->name, "Radio"); strcpy(t->name, "Radio");
t->type = V4L2_TUNER_RADIO; t->type = V4L2_TUNER_RADIO;
cx88_call_i2c_clients(core,VIDIOC_G_TUNER,t); cx88_call_i2c_clients(core,VIDIOC_G_TUNER,t);
return 0; return 0;
} }
case VIDIOC_ENUMINPUT:
{
struct v4l2_input *i = arg;
static int radio_enum_input (struct file *file, void *priv,
struct v4l2_input *i)
{
if (i->index != 0) if (i->index != 0)
return -EINVAL; return -EINVAL;
strcpy(i->name,"Radio"); strcpy(i->name,"Radio");
i->type = V4L2_INPUT_TYPE_TUNER; i->type = V4L2_INPUT_TYPE_TUNER;
return 0; return 0;
} }
case VIDIOC_G_INPUT:
{ static int radio_g_audio (struct file *file, void *priv, struct v4l2_audio *a)
int *i = arg; {
*i = 0; if (unlikely(a->index))
return 0; return -EINVAL;
}
case VIDIOC_G_AUDIO:
{
struct v4l2_audio *a = arg;
memset(a,0,sizeof(*a)); memset(a,0,sizeof(*a));
strcpy(a->name,"Radio"); strcpy(a->name,"Radio");
return 0; return 0;
} }
case VIDIOC_G_STD:
{
v4l2_std_id *id = arg;
*id = 0;
return 0;
}
#ifdef CONFIG_VIDEO_V4L1_COMPAT
case VIDIOCSTUNER:
{
struct video_tuner *v = arg;
if (v->tuner) /* Only tuner 0 */ /* FIXME: Should add a standard for radio */
return -EINVAL;
cx88_call_i2c_clients(core,VIDIOCSTUNER,v); static int radio_s_tuner (struct file *file, void *priv,
return 0; struct v4l2_tuner *t)
} {
#endif struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
case VIDIOC_S_TUNER:
{
struct v4l2_tuner *t = arg;
if (0 != t->index) if (0 != t->index)
return -EINVAL; return -EINVAL;
...@@ -1640,16 +1472,22 @@ static int radio_do_ioctl(struct inode *inode, struct file *file, ...@@ -1640,16 +1472,22 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
cx88_call_i2c_clients(core,VIDIOC_S_TUNER,t); cx88_call_i2c_clients(core,VIDIOC_S_TUNER,t);
return 0; return 0;
} }
case VIDIOC_S_AUDIO: static int radio_s_audio (struct file *file, void *fh,
case VIDIOC_S_INPUT: struct v4l2_audio *a)
case VIDIOC_S_STD: {
return 0; return 0;
}
case VIDIOC_QUERYCTRL: static int radio_s_input (struct file *file, void *fh, unsigned int i)
{ {
struct v4l2_queryctrl *c = arg; return 0;
}
static int radio_queryctrl (struct file *file, void *priv,
struct v4l2_queryctrl *c)
{
int i; int i;
if (c->id < V4L2_CID_BASE || if (c->id < V4L2_CID_BASE ||
...@@ -1663,27 +1501,7 @@ static int radio_do_ioctl(struct inode *inode, struct file *file, ...@@ -1663,27 +1501,7 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
} else } else
*c = no_ctl; *c = no_ctl;
return 0; return 0;
} }
case VIDIOC_G_CTRL:
case VIDIOC_S_CTRL:
case VIDIOC_G_FREQUENCY:
case VIDIOC_S_FREQUENCY:
return video_do_ioctl(inode,file,cmd,arg);
default:
return v4l_compat_translate_ioctl(inode,file,cmd,arg,
radio_do_ioctl);
}
return 0;
};
static int radio_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
return video_usercopy(inode, file, cmd, arg, radio_do_ioctl);
};
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
...@@ -1816,27 +1634,48 @@ static const struct file_operations video_fops = ...@@ -1816,27 +1634,48 @@ static const struct file_operations video_fops =
.read = video_read, .read = video_read,
.poll = video_poll, .poll = video_poll,
.mmap = video_mmap, .mmap = video_mmap,
.ioctl = video_ioctl, .ioctl = video_ioctl2,
.compat_ioctl = v4l_compat_ioctl32, .compat_ioctl = v4l_compat_ioctl32,
.llseek = no_llseek, .llseek = no_llseek,
}; };
static struct video_device cx8800_vbi_template;
static struct video_device cx8800_video_template = static struct video_device cx8800_video_template =
{ {
.name = "cx8800-video", .name = "cx8800-video",
.type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES, .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES,
.hardware = 0,
.fops = &video_fops,
.minor = -1,
};
static struct video_device cx8800_vbi_template =
{
.name = "cx8800-vbi",
.type = VID_TYPE_TELETEXT|VID_TYPE_TUNER,
.hardware = 0,
.fops = &video_fops, .fops = &video_fops,
.minor = -1, .minor = -1,
.vidioc_querycap = vidioc_querycap,
.vidioc_enum_fmt_cap = vidioc_enum_fmt_cap,
.vidioc_g_fmt_cap = vidioc_g_fmt_cap,
.vidioc_try_fmt_cap = vidioc_try_fmt_cap,
.vidioc_s_fmt_cap = vidioc_s_fmt_cap,
.vidioc_g_fmt_vbi = cx8800_vbi_fmt,
.vidioc_try_fmt_vbi = cx8800_vbi_fmt,
.vidioc_s_fmt_vbi = cx8800_vbi_fmt,
.vidioc_reqbufs = vidioc_reqbufs,
.vidioc_querybuf = vidioc_querybuf,
.vidioc_qbuf = vidioc_qbuf,
.vidioc_dqbuf = vidioc_dqbuf,
.vidioc_s_std = vidioc_s_std,
.vidioc_enum_input = vidioc_enum_input,
.vidioc_g_input = vidioc_g_input,
.vidioc_s_input = vidioc_s_input,
.vidioc_queryctrl = vidioc_queryctrl,
.vidioc_g_ctrl = vidioc_g_ctrl,
.vidioc_s_ctrl = vidioc_s_ctrl,
.vidioc_streamon = vidioc_streamon,
.vidioc_streamoff = vidioc_streamoff,
#ifdef CONFIG_VIDEO_V4L1_COMPAT
.vidiocgmbuf = vidiocgmbuf,
#endif
.vidioc_g_tuner = vidioc_g_tuner,
.vidioc_s_tuner = vidioc_s_tuner,
.vidioc_g_frequency = vidioc_g_frequency,
.vidioc_s_frequency = vidioc_s_frequency,
.tvnorms = tvnorms,
.tvnormsize = ARRAY_SIZE(tvnorms),
}; };
static const struct file_operations radio_fops = static const struct file_operations radio_fops =
...@@ -1844,7 +1683,7 @@ static const struct file_operations radio_fops = ...@@ -1844,7 +1683,7 @@ static const struct file_operations radio_fops =
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = video_open, .open = video_open,
.release = video_release, .release = video_release,
.ioctl = radio_ioctl, .ioctl = video_ioctl2,
.compat_ioctl = v4l_compat_ioctl32, .compat_ioctl = v4l_compat_ioctl32,
.llseek = no_llseek, .llseek = no_llseek,
}; };
...@@ -1856,6 +1695,20 @@ static struct video_device cx8800_radio_template = ...@@ -1856,6 +1695,20 @@ static struct video_device cx8800_radio_template =
.hardware = 0, .hardware = 0,
.fops = &radio_fops, .fops = &radio_fops,
.minor = -1, .minor = -1,
.vidioc_querycap = radio_querycap,
.vidioc_g_tuner = radio_g_tuner,
.vidioc_enum_input = radio_enum_input,
.vidioc_g_audio = radio_g_audio,
.vidioc_s_tuner = radio_s_tuner,
.vidioc_s_audio = radio_s_audio,
.vidioc_s_input = radio_s_input,
.vidioc_queryctrl = radio_queryctrl,
.vidioc_g_ctrl = vidioc_g_ctrl,
.vidioc_s_ctrl = vidioc_s_ctrl,
.vidioc_g_frequency = vidioc_g_frequency,
.vidioc_s_frequency = vidioc_s_frequency,
.tvnorms = radionorms,
.tvnormsize = ARRAY_SIZE(radionorms),
}; };
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
...@@ -1890,6 +1743,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1890,6 +1743,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
{ {
struct cx8800_dev *dev; struct cx8800_dev *dev;
struct cx88_core *core; struct cx88_core *core;
int err; int err;
dev = kzalloc(sizeof(*dev),GFP_KERNEL); dev = kzalloc(sizeof(*dev),GFP_KERNEL);
...@@ -1924,6 +1778,12 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1924,6 +1778,12 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
goto fail_core; goto fail_core;
} }
/* Initialize VBI template */
memcpy( &cx8800_vbi_template, &cx8800_video_template,
sizeof(cx8800_vbi_template) );
strcpy(cx8800_vbi_template.name,"cx8800-vbi");
cx8800_vbi_template.type = VID_TYPE_TELETEXT|VID_TYPE_TUNER;
/* initialize driver struct */ /* initialize driver struct */
spin_lock_init(&dev->slock); spin_lock_init(&dev->slock);
core->tvnorm = tvnorms; core->tvnorm = tvnorms;
......
...@@ -82,20 +82,13 @@ enum cx8802_board_access { ...@@ -82,20 +82,13 @@ enum cx8802_board_access {
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* tv norms */ /* tv norms */
struct cx88_tvnorm { static unsigned int inline norm_maxw(struct v4l2_tvnorm *norm)
char *name;
v4l2_std_id id;
u32 cxiformat;
u32 cxoformat;
};
static unsigned int inline norm_maxw(struct cx88_tvnorm *norm)
{ {
return (norm->id & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 720 : 768; return (norm->id & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 720 : 768;
} }
static unsigned int inline norm_maxh(struct cx88_tvnorm *norm) static unsigned int inline norm_maxh(struct v4l2_tvnorm *norm)
{ {
return (norm->id & V4L2_STD_625_50) ? 576 : 480; return (norm->id & V4L2_STD_625_50) ? 576 : 480;
} }
...@@ -319,7 +312,7 @@ struct cx88_core { ...@@ -319,7 +312,7 @@ struct cx88_core {
/* state info */ /* state info */
struct task_struct *kthread; struct task_struct *kthread;
struct cx88_tvnorm *tvnorm; struct v4l2_tvnorm *tvnorm;
u32 tvaudio; u32 tvaudio;
u32 audiomode_manual; u32 audiomode_manual;
u32 audiomode_current; u32 audiomode_current;
...@@ -536,7 +529,7 @@ extern void cx88_sram_channel_dump(struct cx88_core *core, ...@@ -536,7 +529,7 @@ extern void cx88_sram_channel_dump(struct cx88_core *core,
extern int cx88_set_scale(struct cx88_core *core, unsigned int width, extern int cx88_set_scale(struct cx88_core *core, unsigned int width,
unsigned int height, enum v4l2_field field); unsigned int height, enum v4l2_field field);
extern int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm); extern int cx88_set_tvnorm(struct cx88_core *core, struct v4l2_tvnorm *norm);
extern struct video_device *cx88_vdev_init(struct cx88_core *core, extern struct video_device *cx88_vdev_init(struct cx88_core *core,
struct pci_dev *pci, struct pci_dev *pci,
...@@ -553,7 +546,10 @@ extern int cx88_stop_audio_dma(struct cx88_core *core); ...@@ -553,7 +546,10 @@ extern int cx88_stop_audio_dma(struct cx88_core *core);
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* cx88-vbi.c */ /* cx88-vbi.c */
void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f); /* Can be used as g_vbi_fmt, try_vbi_fmt and s_vbi_fmt */
int cx8800_vbi_fmt (struct file *file, void *priv,
struct v4l2_format *f);
/* /*
int cx8800_start_vbi_dma(struct cx8800_dev *dev, int cx8800_start_vbi_dma(struct cx8800_dev *dev,
struct cx88_dmaqueue *q, struct cx88_dmaqueue *q,
......
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