mirror of
https://github.com/torvalds/linux.git
synced 2024-11-06 12:11:59 +00:00
V4L/DVB (8079): ivtv: Convert to video_ioctl2.
Based on an initial conversion patch from Douglas Landgraf. Signed-off-by: Douglas Schilling Landgraf <dougsland@gmail.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
parent
539a7555b3
commit
3f038d8003
@ -47,8 +47,10 @@ static const u32 *ctrl_classes[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int ivtv_queryctrl(struct ivtv *itv, struct v4l2_queryctrl *qctrl)
|
||||
|
||||
int ivtv_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *qctrl)
|
||||
{
|
||||
struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
|
||||
const char *name;
|
||||
|
||||
IVTV_DEBUG_IOCTL("VIDIOC_QUERYCTRL(%08x)\n", qctrl->id);
|
||||
@ -87,17 +89,20 @@ static int ivtv_queryctrl(struct ivtv *itv, struct v4l2_queryctrl *qctrl)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ivtv_querymenu(struct ivtv *itv, struct v4l2_querymenu *qmenu)
|
||||
int ivtv_querymenu(struct file *file, void *fh, struct v4l2_querymenu *qmenu)
|
||||
{
|
||||
struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
|
||||
struct v4l2_queryctrl qctrl;
|
||||
|
||||
IVTV_DEBUG_IOCTL("VIDIOC_QUERYMENU\n");
|
||||
qctrl.id = qmenu->id;
|
||||
ivtv_queryctrl(itv, &qctrl);
|
||||
ivtv_queryctrl(file, fh, &qctrl);
|
||||
return v4l2_ctrl_query_menu(qmenu, &qctrl, cx2341x_ctrl_get_menu(qmenu->id));
|
||||
}
|
||||
|
||||
static int ivtv_s_ctrl(struct ivtv *itv, struct v4l2_control *vctrl)
|
||||
int ivtv_s_ctrl(struct file *file, void *fh, struct v4l2_control *vctrl)
|
||||
{
|
||||
struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
|
||||
s32 v = vctrl->value;
|
||||
|
||||
IVTV_DEBUG_IOCTL("VIDIOC_S_CTRL(%08x, %x)\n", vctrl->id, v);
|
||||
@ -125,8 +130,10 @@ static int ivtv_s_ctrl(struct ivtv *itv, struct v4l2_control *vctrl)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ivtv_g_ctrl(struct ivtv *itv, struct v4l2_control *vctrl)
|
||||
int ivtv_g_ctrl(struct file *file, void *fh, struct v4l2_control *vctrl)
|
||||
{
|
||||
struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
|
||||
|
||||
IVTV_DEBUG_IOCTL("VIDIOC_G_CTRL(%08x)\n", vctrl->id);
|
||||
|
||||
switch (vctrl->id) {
|
||||
@ -191,119 +198,96 @@ static int ivtv_setup_vbi_fmt(struct ivtv *itv, enum v4l2_mpeg_stream_vbi_fmt fm
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ivtv_control_ioctls(struct ivtv *itv, unsigned int cmd, void *arg)
|
||||
int ivtv_g_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
|
||||
{
|
||||
struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
|
||||
struct v4l2_control ctrl;
|
||||
|
||||
switch (cmd) {
|
||||
case VIDIOC_QUERYMENU:
|
||||
IVTV_DEBUG_IOCTL("VIDIOC_QUERYMENU\n");
|
||||
return ivtv_querymenu(itv, arg);
|
||||
if (c->ctrl_class == V4L2_CTRL_CLASS_USER) {
|
||||
int i;
|
||||
int err = 0;
|
||||
|
||||
case VIDIOC_QUERYCTRL:
|
||||
return ivtv_queryctrl(itv, arg);
|
||||
|
||||
case VIDIOC_S_CTRL:
|
||||
return ivtv_s_ctrl(itv, arg);
|
||||
|
||||
case VIDIOC_G_CTRL:
|
||||
return ivtv_g_ctrl(itv, arg);
|
||||
|
||||
case VIDIOC_S_EXT_CTRLS:
|
||||
{
|
||||
struct v4l2_ext_controls *c = arg;
|
||||
|
||||
if (c->ctrl_class == V4L2_CTRL_CLASS_USER) {
|
||||
int i;
|
||||
int err = 0;
|
||||
|
||||
for (i = 0; i < c->count; i++) {
|
||||
ctrl.id = c->controls[i].id;
|
||||
ctrl.value = c->controls[i].value;
|
||||
err = ivtv_s_ctrl(itv, &ctrl);
|
||||
c->controls[i].value = ctrl.value;
|
||||
if (err) {
|
||||
c->error_idx = i;
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < c->count; i++) {
|
||||
ctrl.id = c->controls[i].id;
|
||||
ctrl.value = c->controls[i].value;
|
||||
err = ivtv_g_ctrl(file, fh, &ctrl);
|
||||
c->controls[i].value = ctrl.value;
|
||||
if (err) {
|
||||
c->error_idx = i;
|
||||
break;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
IVTV_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n");
|
||||
if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) {
|
||||
static u32 freqs[3] = { 44100, 48000, 32000 };
|
||||
struct cx2341x_mpeg_params p = itv->params;
|
||||
int err = cx2341x_ext_ctrls(&p, atomic_read(&itv->capturing), arg, cmd);
|
||||
unsigned idx;
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (p.video_encoding != itv->params.video_encoding) {
|
||||
int is_mpeg1 = p.video_encoding ==
|
||||
V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
|
||||
struct v4l2_format fmt;
|
||||
|
||||
/* fix videodecoder resolution */
|
||||
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
fmt.fmt.pix.width = itv->params.width / (is_mpeg1 ? 2 : 1);
|
||||
fmt.fmt.pix.height = itv->params.height;
|
||||
itv->video_dec_func(itv, VIDIOC_S_FMT, &fmt);
|
||||
}
|
||||
err = cx2341x_update(itv, ivtv_api_func, &itv->params, &p);
|
||||
if (!err && itv->params.stream_vbi_fmt != p.stream_vbi_fmt) {
|
||||
err = ivtv_setup_vbi_fmt(itv, p.stream_vbi_fmt);
|
||||
}
|
||||
itv->params = p;
|
||||
itv->dualwatch_stereo_mode = p.audio_properties & 0x0300;
|
||||
idx = p.audio_properties & 0x03;
|
||||
/* The audio clock of the digitizer must match the codec sample
|
||||
rate otherwise you get some very strange effects. */
|
||||
if (idx < sizeof(freqs))
|
||||
ivtv_call_i2c_clients(itv, VIDIOC_INT_AUDIO_CLOCK_FREQ, &freqs[idx]);
|
||||
return err;
|
||||
}
|
||||
return -EINVAL;
|
||||
return err;
|
||||
}
|
||||
|
||||
case VIDIOC_G_EXT_CTRLS:
|
||||
{
|
||||
struct v4l2_ext_controls *c = arg;
|
||||
|
||||
if (c->ctrl_class == V4L2_CTRL_CLASS_USER) {
|
||||
int i;
|
||||
int err = 0;
|
||||
|
||||
for (i = 0; i < c->count; i++) {
|
||||
ctrl.id = c->controls[i].id;
|
||||
ctrl.value = c->controls[i].value;
|
||||
err = ivtv_g_ctrl(itv, &ctrl);
|
||||
c->controls[i].value = ctrl.value;
|
||||
if (err) {
|
||||
c->error_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
IVTV_DEBUG_IOCTL("VIDIOC_G_EXT_CTRLS\n");
|
||||
if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG)
|
||||
return cx2341x_ext_ctrls(&itv->params, 0, arg, cmd);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
case VIDIOC_TRY_EXT_CTRLS:
|
||||
{
|
||||
struct v4l2_ext_controls *c = arg;
|
||||
|
||||
IVTV_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n");
|
||||
if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG)
|
||||
return cx2341x_ext_ctrls(&itv->params, atomic_read(&itv->capturing), arg, cmd);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
IVTV_DEBUG_IOCTL("VIDIOC_G_EXT_CTRLS\n");
|
||||
if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG)
|
||||
return cx2341x_ext_ctrls(&itv->params, 0, c, VIDIOC_G_EXT_CTRLS);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int ivtv_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
|
||||
{
|
||||
struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
|
||||
struct v4l2_control ctrl;
|
||||
|
||||
if (c->ctrl_class == V4L2_CTRL_CLASS_USER) {
|
||||
int i;
|
||||
int err = 0;
|
||||
|
||||
for (i = 0; i < c->count; i++) {
|
||||
ctrl.id = c->controls[i].id;
|
||||
ctrl.value = c->controls[i].value;
|
||||
err = ivtv_s_ctrl(file, fh, &ctrl);
|
||||
c->controls[i].value = ctrl.value;
|
||||
if (err) {
|
||||
c->error_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
IVTV_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n");
|
||||
if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) {
|
||||
static u32 freqs[3] = { 44100, 48000, 32000 };
|
||||
struct cx2341x_mpeg_params p = itv->params;
|
||||
int err = cx2341x_ext_ctrls(&p, atomic_read(&itv->capturing), c, VIDIOC_S_EXT_CTRLS);
|
||||
unsigned idx;
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (p.video_encoding != itv->params.video_encoding) {
|
||||
int is_mpeg1 = p.video_encoding ==
|
||||
V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
|
||||
struct v4l2_format fmt;
|
||||
|
||||
/* fix videodecoder resolution */
|
||||
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
fmt.fmt.pix.width = itv->params.width / (is_mpeg1 ? 2 : 1);
|
||||
fmt.fmt.pix.height = itv->params.height;
|
||||
itv->video_dec_func(itv, VIDIOC_S_FMT, &fmt);
|
||||
}
|
||||
err = cx2341x_update(itv, ivtv_api_func, &itv->params, &p);
|
||||
if (!err && itv->params.stream_vbi_fmt != p.stream_vbi_fmt)
|
||||
err = ivtv_setup_vbi_fmt(itv, p.stream_vbi_fmt);
|
||||
itv->params = p;
|
||||
itv->dualwatch_stereo_mode = p.audio_properties & 0x0300;
|
||||
idx = p.audio_properties & 0x03;
|
||||
/* The audio clock of the digitizer must match the codec sample
|
||||
rate otherwise you get some very strange effects. */
|
||||
if (idx < sizeof(freqs))
|
||||
ivtv_call_i2c_clients(itv, VIDIOC_INT_AUDIO_CLOCK_FREQ, &freqs[idx]);
|
||||
return err;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int ivtv_try_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
|
||||
{
|
||||
struct ivtv *itv = ((struct ivtv_open_id *)fh)->itv;
|
||||
|
||||
IVTV_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n");
|
||||
if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG)
|
||||
return cx2341x_ext_ctrls(&itv->params, atomic_read(&itv->capturing), c, VIDIOC_TRY_EXT_CTRLS);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -21,6 +21,12 @@
|
||||
#ifndef IVTV_CONTROLS_H
|
||||
#define IVTV_CONTROLS_H
|
||||
|
||||
int ivtv_control_ioctls(struct ivtv *itv, unsigned int cmd, void *arg);
|
||||
int ivtv_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *a);
|
||||
int ivtv_g_ctrl(struct file *file, void *fh, struct v4l2_control *a);
|
||||
int ivtv_s_ctrl(struct file *file, void *fh, struct v4l2_control *a);
|
||||
int ivtv_g_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *a);
|
||||
int ivtv_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *a);
|
||||
int ivtv_try_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *a);
|
||||
int ivtv_querymenu(struct file *file, void *fh, struct v4l2_querymenu *a);
|
||||
|
||||
#endif
|
||||
|
@ -1262,9 +1262,13 @@ err:
|
||||
int ivtv_init_on_first_open(struct ivtv *itv)
|
||||
{
|
||||
struct v4l2_frequency vf;
|
||||
/* Needed to call ioctls later */
|
||||
struct ivtv_open_id fh;
|
||||
int fw_retry_count = 3;
|
||||
int video_input;
|
||||
|
||||
fh.itv = itv;
|
||||
|
||||
if (test_bit(IVTV_F_I_FAILED, &itv->i_flags))
|
||||
return -ENXIO;
|
||||
|
||||
@ -1312,18 +1316,18 @@ int ivtv_init_on_first_open(struct ivtv *itv)
|
||||
|
||||
video_input = itv->active_input;
|
||||
itv->active_input++; /* Force update of input */
|
||||
ivtv_v4l2_ioctls(itv, NULL, VIDIOC_S_INPUT, &video_input);
|
||||
ivtv_s_input(NULL, &fh, video_input);
|
||||
|
||||
/* Let the VIDIOC_S_STD ioctl do all the work, keeps the code
|
||||
in one place. */
|
||||
itv->std++; /* Force full standard initialization */
|
||||
itv->std_out = itv->std;
|
||||
ivtv_v4l2_ioctls(itv, NULL, VIDIOC_S_FREQUENCY, &vf);
|
||||
ivtv_s_frequency(NULL, &fh, &vf);
|
||||
|
||||
if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) {
|
||||
ivtv_init_mpeg_decoder(itv);
|
||||
}
|
||||
ivtv_v4l2_ioctls(itv, NULL, VIDIOC_S_STD, &itv->tuner_std);
|
||||
ivtv_s_std(NULL, &fh, &itv->tuner_std);
|
||||
|
||||
/* On a cx23416 this seems to be able to enable DMA to the chip? */
|
||||
if (!itv->has_cx23415)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -24,10 +24,13 @@
|
||||
u16 ivtv_service2vbi(int type);
|
||||
void ivtv_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal);
|
||||
u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt);
|
||||
int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||
unsigned long arg);
|
||||
int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg);
|
||||
void ivtv_set_osd_alpha(struct ivtv *itv);
|
||||
int ivtv_set_speed(struct ivtv *itv, int speed);
|
||||
void ivtv_set_funcs(struct video_device *vdev);
|
||||
int ivtv_s_std(struct file *file, void *fh, v4l2_std_id *std);
|
||||
int ivtv_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf);
|
||||
int ivtv_s_input(struct file *file, void *fh, unsigned int inp);
|
||||
int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
|
||||
unsigned long arg);
|
||||
|
||||
#endif
|
||||
|
@ -220,7 +220,8 @@ static int ivtv_prep_dev(struct ivtv *itv, int type)
|
||||
s->v4l2dev->dev = &itv->dev->dev;
|
||||
s->v4l2dev->fops = ivtv_stream_info[type].fops;
|
||||
s->v4l2dev->release = video_device_release;
|
||||
|
||||
s->v4l2dev->tvnorms = V4L2_STD_ALL;
|
||||
ivtv_set_funcs(s->v4l2dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user