diff options
Diffstat (limited to 'drivers/staging/media/av7110/av7110_v4l.c')
-rw-r--r-- | drivers/staging/media/av7110/av7110_v4l.c | 148 |
1 files changed, 76 insertions, 72 deletions
diff --git a/drivers/staging/media/av7110/av7110_v4l.c b/drivers/staging/media/av7110/av7110_v4l.c index c89f536f699c..ed2c605808e8 100644 --- a/drivers/staging/media/av7110/av7110_v4l.c +++ b/drivers/staging/media/av7110/av7110_v4l.c @@ -213,25 +213,14 @@ static const struct v4l2_audio msp3400_v4l2_audio = { .capability = V4L2_AUDCAP_STEREO }; -static int av7110_dvb_c_switch(struct saa7146_fh *fh) +static int av7110_dvb_c_switch(struct saa7146_dev *dev) { - struct saa7146_dev *dev = fh->dev; - struct saa7146_vv *vv = dev->vv_data; struct av7110 *av7110 = (struct av7110*)dev->ext_priv; u16 adswitch; - int source, sync, err; + int source, sync; dprintk(4, "%p\n", av7110); - if ((vv->video_status & STATUS_OVERLAY) != 0) { - vv->ov_suspend = vv->video_fh; - err = saa7146_stop_preview(vv->video_fh); /* side effect: video_status is now 0, video_fh is NULL */ - if (err != 0) { - dprintk(2, "suspending video failed\n"); - vv->ov_suspend = NULL; - } - } - if (0 != av7110->current_input) { dprintk(1, "switching to analog TV:\n"); adswitch = 1; @@ -300,17 +289,12 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh) saa7146_set_hps_source_and_sync(dev, source, sync); - if (vv->ov_suspend != NULL) { - saa7146_start_preview(vv->ov_suspend); - vv->ov_suspend = NULL; - } - return 0; } static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *t) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; u16 stereo_det; s8 stereo; @@ -354,7 +338,7 @@ static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *t) static int vidioc_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *t) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; u16 fm_matrix, src; dprintk(2, "VIDIOC_S_TUNER: %d\n", t->index); @@ -398,7 +382,7 @@ static int vidioc_s_tuner(struct file *file, void *fh, const struct v4l2_tuner * static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency *f) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_G_FREQ: freq:0x%08x\n", f->frequency); @@ -414,7 +398,7 @@ static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency static int vidioc_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *f) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_S_FREQUENCY: freq:0x%08x\n", f->frequency); @@ -444,7 +428,7 @@ static int vidioc_s_frequency(struct file *file, void *fh, const struct v4l2_fre static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_ENUMINPUT: %d\n", i->index); @@ -464,7 +448,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) static int vidioc_g_input(struct file *file, void *fh, unsigned int *input) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; *input = av7110->current_input; @@ -474,7 +458,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *input) static int vidioc_s_input(struct file *file, void *fh, unsigned int input) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_S_INPUT: %d\n", input); @@ -486,7 +470,29 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) return -EINVAL; av7110->current_input = input; - return av7110_dvb_c_switch(fh); + return av7110_dvb_c_switch(dev); +} + +static int vidioc_enum_output(struct file *file, void *fh, struct v4l2_output *o) +{ + if (o->index) + return -EINVAL; + strscpy(o->name, "Video Output", sizeof(o->name)); + o->type = V4L2_OUTPUT_TYPE_ANALOG; + o->std = V4L2_STD_NTSC_M | V4L2_STD_PAL_BG; + o->capabilities = V4L2_OUT_CAP_STD; + return 0; +} + +static int vidioc_g_output(struct file *file, void *fh, unsigned int *output) +{ + *output = 0; + return 0; +} + +static int vidioc_s_output(struct file *file, void *fh, unsigned int output) +{ + return output ? -EINVAL : 0; } static int vidioc_enumaudio(struct file *file, void *fh, struct v4l2_audio *a) @@ -500,7 +506,7 @@ static int vidioc_enumaudio(struct file *file, void *fh, struct v4l2_audio *a) static int vidioc_g_audio(struct file *file, void *fh, struct v4l2_audio *a) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_G_AUDIO: %d\n", a->index); @@ -514,7 +520,7 @@ static int vidioc_g_audio(struct file *file, void *fh, struct v4l2_audio *a) static int vidioc_s_audio(struct file *file, void *fh, const struct v4l2_audio *a) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_S_AUDIO: %d\n", a->index); @@ -526,7 +532,7 @@ static int vidioc_s_audio(struct file *file, void *fh, const struct v4l2_audio * static int vidioc_g_sliced_vbi_cap(struct file *file, void *fh, struct v4l2_sliced_vbi_cap *cap) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_G_SLICED_VBI_CAP\n"); @@ -542,7 +548,7 @@ static int vidioc_g_sliced_vbi_cap(struct file *file, void *fh, static int vidioc_g_fmt_sliced_vbi_out(struct file *file, void *fh, struct v4l2_format *f) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_G_FMT:\n"); @@ -552,59 +558,58 @@ static int vidioc_g_fmt_sliced_vbi_out(struct file *file, void *fh, if (av7110->wssMode) { f->fmt.sliced.service_set = V4L2_SLICED_WSS_625; f->fmt.sliced.service_lines[0][23] = V4L2_SLICED_WSS_625; - f->fmt.sliced.io_size = sizeof(struct v4l2_sliced_vbi_data); } + f->fmt.sliced.io_size = sizeof(struct v4l2_sliced_vbi_data); + return 0; +} + +static int vidioc_try_fmt_sliced_vbi_out(struct file *file, void *fh, + struct v4l2_format *f) +{ + struct saa7146_dev *dev = video_drvdata(file); + struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; + bool want_wss = (f->fmt.sliced.service_set & V4L2_SLICED_WSS_625) || + (!f->fmt.sliced.service_set && + f->fmt.sliced.service_lines[0][23] == V4L2_SLICED_WSS_625); + + dprintk(2, "VIDIOC_G_FMT:\n"); + if (FW_VERSION(av7110->arm_app) < 0x2623) + return -EINVAL; + memset(&f->fmt.sliced, 0, sizeof(f->fmt.sliced)); + if (want_wss) { + f->fmt.sliced.service_set = V4L2_SLICED_WSS_625; + f->fmt.sliced.service_lines[0][23] = V4L2_SLICED_WSS_625; + } + f->fmt.sliced.io_size = sizeof(struct v4l2_sliced_vbi_data); return 0; } static int vidioc_s_fmt_sliced_vbi_out(struct file *file, void *fh, struct v4l2_format *f) { - struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; dprintk(2, "VIDIOC_S_FMT\n"); - if (FW_VERSION(av7110->arm_app) < 0x2623) + if (vidioc_try_fmt_sliced_vbi_out(file, fh, f)) return -EINVAL; - if (f->fmt.sliced.service_set != V4L2_SLICED_WSS_625 && - f->fmt.sliced.service_lines[0][23] != V4L2_SLICED_WSS_625) { - memset(&f->fmt.sliced, 0, sizeof(f->fmt.sliced)); + if (f->fmt.sliced.service_set & V4L2_SLICED_WSS_625) { + /* WSS controlled by userspace */ + av7110->wssMode = 1; + av7110->wssData = 0; + } else { /* WSS controlled by firmware */ av7110->wssMode = 0; av7110->wssData = 0; return av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 1, 0); - } else { - memset(&f->fmt.sliced, 0, sizeof(f->fmt.sliced)); - f->fmt.sliced.service_set = V4L2_SLICED_WSS_625; - f->fmt.sliced.service_lines[0][23] = V4L2_SLICED_WSS_625; - f->fmt.sliced.io_size = sizeof(struct v4l2_sliced_vbi_data); - /* WSS controlled by userspace */ - av7110->wssMode = 1; - av7110->wssData = 0; } return 0; } -static int av7110_vbi_reset(struct file *file) -{ - struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; - struct av7110 *av7110 = (struct av7110*) dev->ext_priv; - - dprintk(2, "%s\n", __func__); - av7110->wssMode = 0; - av7110->wssData = 0; - if (FW_VERSION(av7110->arm_app) < 0x2623) - return 0; - else - return av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 1, 0); -} - static ssize_t av7110_vbi_write(struct file *file, const char __user *data, size_t count, loff_t *ppos) { - struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; + struct saa7146_dev *dev = video_drvdata(file); struct av7110 *av7110 = (struct av7110*) dev->ext_priv; struct v4l2_sliced_vbi_data d; int rc; @@ -819,13 +824,16 @@ int av7110_init_v4l(struct av7110 *av7110) vv_data->vid_ops.vidioc_s_audio = vidioc_s_audio; vv_data->vid_ops.vidioc_g_fmt_vbi_cap = NULL; - vv_data->vbi_ops.vidioc_g_tuner = vidioc_g_tuner; - vv_data->vbi_ops.vidioc_s_tuner = vidioc_s_tuner; - vv_data->vbi_ops.vidioc_g_frequency = vidioc_g_frequency; - vv_data->vbi_ops.vidioc_s_frequency = vidioc_s_frequency; + vv_data->vbi_ops.vidioc_enum_output = vidioc_enum_output; + vv_data->vbi_ops.vidioc_g_output = vidioc_g_output; + vv_data->vbi_ops.vidioc_s_output = vidioc_s_output; + vv_data->vbi_ops.vidioc_g_parm = NULL; vv_data->vbi_ops.vidioc_g_fmt_vbi_cap = NULL; + vv_data->vbi_ops.vidioc_try_fmt_vbi_cap = NULL; + vv_data->vbi_ops.vidioc_s_fmt_vbi_cap = NULL; vv_data->vbi_ops.vidioc_g_sliced_vbi_cap = vidioc_g_sliced_vbi_cap; vv_data->vbi_ops.vidioc_g_fmt_sliced_vbi_out = vidioc_g_fmt_sliced_vbi_out; + vv_data->vbi_ops.vidioc_try_fmt_sliced_vbi_out = vidioc_try_fmt_sliced_vbi_out; vv_data->vbi_ops.vidioc_s_fmt_sliced_vbi_out = vidioc_s_fmt_sliced_vbi_out; if (FW_VERSION(av7110->arm_app) < 0x2623) @@ -866,7 +874,7 @@ static struct saa7146_standard standard[] = { .h_offset = 0x48, .h_pixels = 708, .v_max_out = 576, .h_max_out = 768, }, { - .name = "NTSC", .id = V4L2_STD_NTSC, + .name = "NTSC", .id = V4L2_STD_NTSC_M, .v_offset = 0x10, .v_field = 244, .h_offset = 0x40, .h_pixels = 708, .v_max_out = 480, .h_max_out = 640, @@ -880,7 +888,7 @@ static struct saa7146_standard analog_standard[] = { .h_offset = 0x08, .h_pixels = 708, .v_max_out = 576, .h_max_out = 768, }, { - .name = "NTSC", .id = V4L2_STD_NTSC, + .name = "NTSC", .id = V4L2_STD_NTSC_M, .v_offset = 0x10, .v_field = 244, .h_offset = 0x40, .h_pixels = 708, .v_max_out = 480, .h_max_out = 640, @@ -894,7 +902,7 @@ static struct saa7146_standard dvb_standard[] = { .h_offset = 0x48, .h_pixels = 708, .v_max_out = 576, .h_max_out = 768, }, { - .name = "NTSC", .id = V4L2_STD_NTSC, + .name = "NTSC", .id = V4L2_STD_NTSC_M, .v_offset = 0x10, .v_field = 244, .h_offset = 0x40, .h_pixels = 708, .v_max_out = 480, .h_max_out = 640, @@ -930,8 +938,6 @@ static struct saa7146_ext_vv av7110_vv_data_st = { .num_stds = ARRAY_SIZE(standard), .std_callback = &std_callback, - .vbi_fops.open = av7110_vbi_reset, - .vbi_fops.release = av7110_vbi_reset, .vbi_fops.write = av7110_vbi_write, }; @@ -945,8 +951,6 @@ static struct saa7146_ext_vv av7110_vv_data_c = { .num_stds = ARRAY_SIZE(standard), .std_callback = &std_callback, - .vbi_fops.open = av7110_vbi_reset, - .vbi_fops.release = av7110_vbi_reset, .vbi_fops.write = av7110_vbi_write, }; |