Commit 0b5f265a authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] cx18: use v4l2_fh as preparation for adding core priority support

Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 6e29ad50
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h> #include <media/v4l2-ioctl.h>
#include <media/v4l2-device.h> #include <media/v4l2-device.h>
#include <media/v4l2-fh.h>
#include <media/tuner.h> #include <media/tuner.h>
#include <media/ir-kbd-i2c.h> #include <media/ir-kbd-i2c.h>
#include "cx18-mailbox.h" #include "cx18-mailbox.h"
...@@ -405,12 +406,23 @@ struct cx18_stream { ...@@ -405,12 +406,23 @@ struct cx18_stream {
}; };
struct cx18_open_id { struct cx18_open_id {
struct v4l2_fh fh;
u32 open_id; u32 open_id;
int type; int type;
enum v4l2_priority prio; enum v4l2_priority prio;
struct cx18 *cx; struct cx18 *cx;
}; };
static inline struct cx18_open_id *fh2id(struct v4l2_fh *fh)
{
return container_of(fh, struct cx18_open_id, fh);
}
static inline struct cx18_open_id *file2id(struct file *file)
{
return fh2id(file->private_data);
}
/* forward declaration of struct defined in cx18-cards.h */ /* forward declaration of struct defined in cx18-cards.h */
struct cx18_card; struct cx18_card;
......
...@@ -585,7 +585,7 @@ int cx18_start_capture(struct cx18_open_id *id) ...@@ -585,7 +585,7 @@ int cx18_start_capture(struct cx18_open_id *id)
ssize_t cx18_v4l2_read(struct file *filp, char __user *buf, size_t count, ssize_t cx18_v4l2_read(struct file *filp, char __user *buf, size_t count,
loff_t *pos) loff_t *pos)
{ {
struct cx18_open_id *id = filp->private_data; struct cx18_open_id *id = file2id(filp);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
struct cx18_stream *s = &cx->streams[id->type]; struct cx18_stream *s = &cx->streams[id->type];
int rc; int rc;
...@@ -602,7 +602,7 @@ ssize_t cx18_v4l2_read(struct file *filp, char __user *buf, size_t count, ...@@ -602,7 +602,7 @@ ssize_t cx18_v4l2_read(struct file *filp, char __user *buf, size_t count,
unsigned int cx18_v4l2_enc_poll(struct file *filp, poll_table *wait) unsigned int cx18_v4l2_enc_poll(struct file *filp, poll_table *wait)
{ {
struct cx18_open_id *id = filp->private_data; struct cx18_open_id *id = file2id(filp);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
struct cx18_stream *s = &cx->streams[id->type]; struct cx18_stream *s = &cx->streams[id->type];
int eof = test_bit(CX18_F_S_STREAMOFF, &s->s_flags); int eof = test_bit(CX18_F_S_STREAMOFF, &s->s_flags);
...@@ -676,13 +676,16 @@ void cx18_stop_capture(struct cx18_open_id *id, int gop_end) ...@@ -676,13 +676,16 @@ void cx18_stop_capture(struct cx18_open_id *id, int gop_end)
int cx18_v4l2_close(struct file *filp) int cx18_v4l2_close(struct file *filp)
{ {
struct cx18_open_id *id = filp->private_data; struct v4l2_fh *fh = filp->private_data;
struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
struct cx18_stream *s = &cx->streams[id->type]; struct cx18_stream *s = &cx->streams[id->type];
CX18_DEBUG_IOCTL("close() of %s\n", s->name); CX18_DEBUG_IOCTL("close() of %s\n", s->name);
v4l2_prio_close(&cx->prio, id->prio); v4l2_prio_close(&cx->prio, id->prio);
v4l2_fh_del(fh);
v4l2_fh_exit(fh);
/* Easy case first: this stream was never claimed by us */ /* Easy case first: this stream was never claimed by us */
if (s->id != id->open_id) { if (s->id != id->open_id) {
...@@ -728,22 +731,25 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp) ...@@ -728,22 +731,25 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp)
CX18_DEBUG_FILE("open %s\n", s->name); CX18_DEBUG_FILE("open %s\n", s->name);
/* Allocate memory */ /* Allocate memory */
item = kmalloc(sizeof(struct cx18_open_id), GFP_KERNEL); item = kzalloc(sizeof(struct cx18_open_id), GFP_KERNEL);
if (NULL == item) { if (NULL == item) {
CX18_DEBUG_WARN("nomem on v4l2 open\n"); CX18_DEBUG_WARN("nomem on v4l2 open\n");
return -ENOMEM; return -ENOMEM;
} }
v4l2_fh_init(&item->fh, s->video_dev);
item->cx = cx; item->cx = cx;
item->type = s->type; item->type = s->type;
v4l2_prio_open(&cx->prio, &item->prio); v4l2_prio_open(&cx->prio, &item->prio);
item->open_id = cx->open_id++; item->open_id = cx->open_id++;
filp->private_data = item; filp->private_data = &item->fh;
if (item->type == CX18_ENC_STREAM_TYPE_RAD) { if (item->type == CX18_ENC_STREAM_TYPE_RAD) {
/* Try to claim this stream */ /* Try to claim this stream */
if (cx18_claim_stream(item, item->type)) { if (cx18_claim_stream(item, item->type)) {
/* No, it's already in use */ /* No, it's already in use */
v4l2_fh_exit(&item->fh);
kfree(item); kfree(item);
return -EBUSY; return -EBUSY;
} }
...@@ -753,6 +759,7 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp) ...@@ -753,6 +759,7 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp)
/* switching to radio while capture is /* switching to radio while capture is
in progress is not polite */ in progress is not polite */
cx18_release_stream(s); cx18_release_stream(s);
v4l2_fh_exit(&item->fh);
kfree(item); kfree(item);
return -EBUSY; return -EBUSY;
} }
...@@ -769,6 +776,7 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp) ...@@ -769,6 +776,7 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp)
/* Done! Unmute and continue. */ /* Done! Unmute and continue. */
cx18_unmute(cx); cx18_unmute(cx);
} }
v4l2_fh_add(&item->fh);
return 0; return 0;
} }
......
...@@ -148,7 +148,7 @@ u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt) ...@@ -148,7 +148,7 @@ u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt)
static int cx18_g_fmt_vid_cap(struct file *file, void *fh, static int cx18_g_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_format *fmt) struct v4l2_format *fmt)
{ {
struct cx18_open_id *id = fh; struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
struct v4l2_pix_format *pixfmt = &fmt->fmt.pix; struct v4l2_pix_format *pixfmt = &fmt->fmt.pix;
...@@ -173,7 +173,7 @@ static int cx18_g_fmt_vid_cap(struct file *file, void *fh, ...@@ -173,7 +173,7 @@ static int cx18_g_fmt_vid_cap(struct file *file, void *fh,
static int cx18_g_fmt_vbi_cap(struct file *file, void *fh, static int cx18_g_fmt_vbi_cap(struct file *file, void *fh,
struct v4l2_format *fmt) struct v4l2_format *fmt)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
struct v4l2_vbi_format *vbifmt = &fmt->fmt.vbi; struct v4l2_vbi_format *vbifmt = &fmt->fmt.vbi;
vbifmt->sampling_rate = 27000000; vbifmt->sampling_rate = 27000000;
...@@ -192,7 +192,7 @@ static int cx18_g_fmt_vbi_cap(struct file *file, void *fh, ...@@ -192,7 +192,7 @@ static int cx18_g_fmt_vbi_cap(struct file *file, void *fh,
static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh, static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh,
struct v4l2_format *fmt) struct v4l2_format *fmt)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
/* sane, V4L2 spec compliant, defaults */ /* sane, V4L2 spec compliant, defaults */
...@@ -221,7 +221,7 @@ static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh, ...@@ -221,7 +221,7 @@ static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh,
static int cx18_try_fmt_vid_cap(struct file *file, void *fh, static int cx18_try_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_format *fmt) struct v4l2_format *fmt)
{ {
struct cx18_open_id *id = fh; struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int w = fmt->fmt.pix.width; int w = fmt->fmt.pix.width;
int h = fmt->fmt.pix.height; int h = fmt->fmt.pix.height;
...@@ -252,7 +252,7 @@ static int cx18_try_fmt_vbi_cap(struct file *file, void *fh, ...@@ -252,7 +252,7 @@ static int cx18_try_fmt_vbi_cap(struct file *file, void *fh,
static int cx18_try_fmt_sliced_vbi_cap(struct file *file, void *fh, static int cx18_try_fmt_sliced_vbi_cap(struct file *file, void *fh,
struct v4l2_format *fmt) struct v4l2_format *fmt)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36;
...@@ -271,7 +271,7 @@ static int cx18_try_fmt_sliced_vbi_cap(struct file *file, void *fh, ...@@ -271,7 +271,7 @@ static int cx18_try_fmt_sliced_vbi_cap(struct file *file, void *fh,
static int cx18_s_fmt_vid_cap(struct file *file, void *fh, static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
struct v4l2_format *fmt) struct v4l2_format *fmt)
{ {
struct cx18_open_id *id = fh; struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
struct v4l2_mbus_framefmt mbus_fmt; struct v4l2_mbus_framefmt mbus_fmt;
int ret; int ret;
...@@ -303,7 +303,7 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh, ...@@ -303,7 +303,7 @@ static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
static int cx18_s_fmt_vbi_cap(struct file *file, void *fh, static int cx18_s_fmt_vbi_cap(struct file *file, void *fh,
struct v4l2_format *fmt) struct v4l2_format *fmt)
{ {
struct cx18_open_id *id = fh; struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int ret; int ret;
...@@ -337,7 +337,7 @@ static int cx18_s_fmt_vbi_cap(struct file *file, void *fh, ...@@ -337,7 +337,7 @@ static int cx18_s_fmt_vbi_cap(struct file *file, void *fh,
static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh, static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh,
struct v4l2_format *fmt) struct v4l2_format *fmt)
{ {
struct cx18_open_id *id = fh; struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int ret; int ret;
struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
...@@ -372,7 +372,7 @@ static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh, ...@@ -372,7 +372,7 @@ static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh,
static int cx18_g_chip_ident(struct file *file, void *fh, static int cx18_g_chip_ident(struct file *file, void *fh,
struct v4l2_dbg_chip_ident *chip) struct v4l2_dbg_chip_ident *chip)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
int err = 0; int err = 0;
chip->ident = V4L2_IDENT_NONE; chip->ident = V4L2_IDENT_NONE;
...@@ -442,7 +442,7 @@ static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg) ...@@ -442,7 +442,7 @@ static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg)
static int cx18_g_register(struct file *file, void *fh, static int cx18_g_register(struct file *file, void *fh,
struct v4l2_dbg_register *reg) struct v4l2_dbg_register *reg)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
if (v4l2_chip_match_host(&reg->match)) if (v4l2_chip_match_host(&reg->match))
return cx18_cxc(cx, VIDIOC_DBG_G_REGISTER, reg); return cx18_cxc(cx, VIDIOC_DBG_G_REGISTER, reg);
...@@ -454,7 +454,7 @@ static int cx18_g_register(struct file *file, void *fh, ...@@ -454,7 +454,7 @@ static int cx18_g_register(struct file *file, void *fh,
static int cx18_s_register(struct file *file, void *fh, static int cx18_s_register(struct file *file, void *fh,
struct v4l2_dbg_register *reg) struct v4l2_dbg_register *reg)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
if (v4l2_chip_match_host(&reg->match)) if (v4l2_chip_match_host(&reg->match))
return cx18_cxc(cx, VIDIOC_DBG_S_REGISTER, reg); return cx18_cxc(cx, VIDIOC_DBG_S_REGISTER, reg);
...@@ -466,7 +466,7 @@ static int cx18_s_register(struct file *file, void *fh, ...@@ -466,7 +466,7 @@ static int cx18_s_register(struct file *file, void *fh,
static int cx18_g_priority(struct file *file, void *fh, enum v4l2_priority *p) static int cx18_g_priority(struct file *file, void *fh, enum v4l2_priority *p)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = file2id(file)->cx;
*p = v4l2_prio_max(&cx->prio); *p = v4l2_prio_max(&cx->prio);
return 0; return 0;
...@@ -474,7 +474,7 @@ static int cx18_g_priority(struct file *file, void *fh, enum v4l2_priority *p) ...@@ -474,7 +474,7 @@ static int cx18_g_priority(struct file *file, void *fh, enum v4l2_priority *p)
static int cx18_s_priority(struct file *file, void *fh, enum v4l2_priority prio) static int cx18_s_priority(struct file *file, void *fh, enum v4l2_priority prio)
{ {
struct cx18_open_id *id = fh; struct cx18_open_id *id = file2id(file);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
return v4l2_prio_change(&cx->prio, &id->prio, prio); return v4l2_prio_change(&cx->prio, &id->prio, prio);
...@@ -483,7 +483,7 @@ static int cx18_s_priority(struct file *file, void *fh, enum v4l2_priority prio) ...@@ -483,7 +483,7 @@ static int cx18_s_priority(struct file *file, void *fh, enum v4l2_priority prio)
static int cx18_querycap(struct file *file, void *fh, static int cx18_querycap(struct file *file, void *fh,
struct v4l2_capability *vcap) struct v4l2_capability *vcap)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
strlcpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver)); strlcpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver));
strlcpy(vcap->card, cx->card_name, sizeof(vcap->card)); strlcpy(vcap->card, cx->card_name, sizeof(vcap->card));
...@@ -496,14 +496,14 @@ static int cx18_querycap(struct file *file, void *fh, ...@@ -496,14 +496,14 @@ static int cx18_querycap(struct file *file, void *fh,
static int cx18_enumaudio(struct file *file, void *fh, struct v4l2_audio *vin) static int cx18_enumaudio(struct file *file, void *fh, struct v4l2_audio *vin)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
return cx18_get_audio_input(cx, vin->index, vin); return cx18_get_audio_input(cx, vin->index, vin);
} }
static int cx18_g_audio(struct file *file, void *fh, struct v4l2_audio *vin) static int cx18_g_audio(struct file *file, void *fh, struct v4l2_audio *vin)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
vin->index = cx->audio_input; vin->index = cx->audio_input;
return cx18_get_audio_input(cx, vin->index, vin); return cx18_get_audio_input(cx, vin->index, vin);
...@@ -511,7 +511,7 @@ static int cx18_g_audio(struct file *file, void *fh, struct v4l2_audio *vin) ...@@ -511,7 +511,7 @@ static int cx18_g_audio(struct file *file, void *fh, struct v4l2_audio *vin)
static int cx18_s_audio(struct file *file, void *fh, struct v4l2_audio *vout) static int cx18_s_audio(struct file *file, void *fh, struct v4l2_audio *vout)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
if (vout->index >= cx->nof_audio_inputs) if (vout->index >= cx->nof_audio_inputs)
return -EINVAL; return -EINVAL;
...@@ -522,7 +522,7 @@ static int cx18_s_audio(struct file *file, void *fh, struct v4l2_audio *vout) ...@@ -522,7 +522,7 @@ static int cx18_s_audio(struct file *file, void *fh, struct v4l2_audio *vout)
static int cx18_enum_input(struct file *file, void *fh, struct v4l2_input *vin) static int cx18_enum_input(struct file *file, void *fh, struct v4l2_input *vin)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
/* set it to defaults from our table */ /* set it to defaults from our table */
return cx18_get_input(cx, vin->index, vin); return cx18_get_input(cx, vin->index, vin);
...@@ -531,7 +531,7 @@ static int cx18_enum_input(struct file *file, void *fh, struct v4l2_input *vin) ...@@ -531,7 +531,7 @@ static int cx18_enum_input(struct file *file, void *fh, struct v4l2_input *vin)
static int cx18_cropcap(struct file *file, void *fh, static int cx18_cropcap(struct file *file, void *fh,
struct v4l2_cropcap *cropcap) struct v4l2_cropcap *cropcap)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
...@@ -546,7 +546,7 @@ static int cx18_cropcap(struct file *file, void *fh, ...@@ -546,7 +546,7 @@ static int cx18_cropcap(struct file *file, void *fh,
static int cx18_s_crop(struct file *file, void *fh, struct v4l2_crop *crop) static int cx18_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
{ {
struct cx18_open_id *id = fh; struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int ret; int ret;
...@@ -562,7 +562,7 @@ static int cx18_s_crop(struct file *file, void *fh, struct v4l2_crop *crop) ...@@ -562,7 +562,7 @@ static int cx18_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
static int cx18_g_crop(struct file *file, void *fh, struct v4l2_crop *crop) static int cx18_g_crop(struct file *file, void *fh, struct v4l2_crop *crop)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
...@@ -590,7 +590,7 @@ static int cx18_enum_fmt_vid_cap(struct file *file, void *fh, ...@@ -590,7 +590,7 @@ static int cx18_enum_fmt_vid_cap(struct file *file, void *fh,
static int cx18_g_input(struct file *file, void *fh, unsigned int *i) static int cx18_g_input(struct file *file, void *fh, unsigned int *i)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
*i = cx->active_input; *i = cx->active_input;
return 0; return 0;
...@@ -598,7 +598,7 @@ static int cx18_g_input(struct file *file, void *fh, unsigned int *i) ...@@ -598,7 +598,7 @@ static int cx18_g_input(struct file *file, void *fh, unsigned int *i)
int cx18_s_input(struct file *file, void *fh, unsigned int inp) int cx18_s_input(struct file *file, void *fh, unsigned int inp)
{ {
struct cx18_open_id *id = fh; struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int ret; int ret;
...@@ -633,7 +633,7 @@ int cx18_s_input(struct file *file, void *fh, unsigned int inp) ...@@ -633,7 +633,7 @@ int cx18_s_input(struct file *file, void *fh, unsigned int inp)
static int cx18_g_frequency(struct file *file, void *fh, static int cx18_g_frequency(struct file *file, void *fh,
struct v4l2_frequency *vf) struct v4l2_frequency *vf)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
if (vf->tuner != 0) if (vf->tuner != 0)
return -EINVAL; return -EINVAL;
...@@ -644,7 +644,7 @@ static int cx18_g_frequency(struct file *file, void *fh, ...@@ -644,7 +644,7 @@ static int cx18_g_frequency(struct file *file, void *fh,
int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf) int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf)
{ {
struct cx18_open_id *id = fh; struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int ret; int ret;
...@@ -664,7 +664,7 @@ int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf) ...@@ -664,7 +664,7 @@ int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf)
static int cx18_g_std(struct file *file, void *fh, v4l2_std_id *std) static int cx18_g_std(struct file *file, void *fh, v4l2_std_id *std)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
*std = cx->std; *std = cx->std;
return 0; return 0;
...@@ -672,7 +672,7 @@ static int cx18_g_std(struct file *file, void *fh, v4l2_std_id *std) ...@@ -672,7 +672,7 @@ static int cx18_g_std(struct file *file, void *fh, v4l2_std_id *std)
int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std) int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std)
{ {
struct cx18_open_id *id = fh; struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int ret; int ret;
...@@ -713,7 +713,7 @@ int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std) ...@@ -713,7 +713,7 @@ int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std)
static int cx18_s_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) static int cx18_s_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
{ {
struct cx18_open_id *id = fh; struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
int ret; int ret;
...@@ -730,7 +730,7 @@ static int cx18_s_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) ...@@ -730,7 +730,7 @@ static int cx18_s_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
if (vt->index != 0) if (vt->index != 0)
return -EINVAL; return -EINVAL;
...@@ -751,7 +751,7 @@ static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) ...@@ -751,7 +751,7 @@ static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
static int cx18_g_sliced_vbi_cap(struct file *file, void *fh, static int cx18_g_sliced_vbi_cap(struct file *file, void *fh,
struct v4l2_sliced_vbi_cap *cap) struct v4l2_sliced_vbi_cap *cap)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
int set = cx->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525; int set = cx->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525;
int f, l; int f, l;
...@@ -872,7 +872,7 @@ static int cx18_process_idx_data(struct cx18_stream *s, struct cx18_mdl *mdl, ...@@ -872,7 +872,7 @@ static int cx18_process_idx_data(struct cx18_stream *s, struct cx18_mdl *mdl,
static int cx18_g_enc_index(struct file *file, void *fh, static int cx18_g_enc_index(struct file *file, void *fh,
struct v4l2_enc_idx *idx) struct v4l2_enc_idx *idx)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_IDX]; struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_IDX];
s32 tmp; s32 tmp;
struct cx18_mdl *mdl; struct cx18_mdl *mdl;
...@@ -919,7 +919,7 @@ static int cx18_g_enc_index(struct file *file, void *fh, ...@@ -919,7 +919,7 @@ static int cx18_g_enc_index(struct file *file, void *fh,
static int cx18_encoder_cmd(struct file *file, void *fh, static int cx18_encoder_cmd(struct file *file, void *fh,
struct v4l2_encoder_cmd *enc) struct v4l2_encoder_cmd *enc)
{ {
struct cx18_open_id *id = fh; struct cx18_open_id *id = fh2id(fh);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
u32 h; u32 h;
...@@ -980,7 +980,7 @@ static int cx18_encoder_cmd(struct file *file, void *fh, ...@@ -980,7 +980,7 @@ static int cx18_encoder_cmd(struct file *file, void *fh,
static int cx18_try_encoder_cmd(struct file *file, void *fh, static int cx18_try_encoder_cmd(struct file *file, void *fh,
struct v4l2_encoder_cmd *enc) struct v4l2_encoder_cmd *enc)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
switch (enc->cmd) { switch (enc->cmd) {
case V4L2_ENC_CMD_START: case V4L2_ENC_CMD_START:
...@@ -1012,7 +1012,7 @@ static int cx18_try_encoder_cmd(struct file *file, void *fh, ...@@ -1012,7 +1012,7 @@ static int cx18_try_encoder_cmd(struct file *file, void *fh,
static int cx18_log_status(struct file *file, void *fh) static int cx18_log_status(struct file *file, void *fh)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
struct v4l2_input vidin; struct v4l2_input vidin;
struct v4l2_audio audin; struct v4l2_audio audin;
int i; int i;
...@@ -1060,7 +1060,7 @@ static int cx18_log_status(struct file *file, void *fh) ...@@ -1060,7 +1060,7 @@ static int cx18_log_status(struct file *file, void *fh)
static long cx18_default(struct file *file, void *fh, bool valid_prio, static long cx18_default(struct file *file, void *fh, bool valid_prio,
int cmd, void *arg) int cmd, void *arg)
{ {
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx; struct cx18 *cx = fh2id(fh)->cx;
switch (cmd) { switch (cmd) {
case VIDIOC_INT_RESET: { case VIDIOC_INT_RESET: {
...@@ -1082,7 +1082,7 @@ long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd, ...@@ -1082,7 +1082,7 @@ long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
struct video_device *vfd = video_devdata(filp); struct video_device *vfd = video_devdata(filp);
struct cx18_open_id *id = filp->private_data; struct cx18_open_id *id = file2id(filp);
struct cx18 *cx = id->cx; struct cx18 *cx = id->cx;
long res; long res;
......
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