mirror of
https://github.com/torvalds/linux.git
synced 2026-05-05 23:05:25 -04:00
media: Replace file->private_data access with custom functions
Accessing file->private_data manually to retrieve the v4l2_fh pointer is error-prone, as the field is a void * and will happily cast implicitly to any pointer type. Replace all remaining locations that read the v4l2_fh pointer directly from file->private_data and cast it to driver-specific file handle structures with driver-specific functions that use file_to_v4l2_fh() and perform the same cast. No functional change is intended, this only paves the way to remove direct accesses to file->private_data and make V4L2 drivers safer. Other accesses to the field will be addressed separately. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
committed by
Hans Verkuil
parent
72517d9f76
commit
4416df03dd
@@ -388,6 +388,11 @@ static inline struct ivtv_open_id *fh2id(struct v4l2_fh *fh)
|
||||
return container_of(fh, struct ivtv_open_id, fh);
|
||||
}
|
||||
|
||||
static inline struct ivtv_open_id *file2id(struct file *filp)
|
||||
{
|
||||
return fh2id(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
struct yuv_frame_info
|
||||
{
|
||||
u32 update;
|
||||
|
||||
@@ -502,7 +502,7 @@ int ivtv_start_capture(struct ivtv_open_id *id)
|
||||
|
||||
ssize_t ivtv_v4l2_read(struct file * filp, char __user *buf, size_t count, loff_t * pos)
|
||||
{
|
||||
struct ivtv_open_id *id = fh2id(filp->private_data);
|
||||
struct ivtv_open_id *id = file2id(filp);
|
||||
struct ivtv *itv = id->itv;
|
||||
struct ivtv_stream *s = &itv->streams[id->type];
|
||||
ssize_t rc;
|
||||
@@ -564,7 +564,7 @@ static int ivtv_schedule_dma(struct ivtv_stream *s)
|
||||
|
||||
static ssize_t ivtv_write(struct file *filp, const char __user *user_buf, size_t count, loff_t *pos)
|
||||
{
|
||||
struct ivtv_open_id *id = fh2id(filp->private_data);
|
||||
struct ivtv_open_id *id = file2id(filp);
|
||||
struct ivtv *itv = id->itv;
|
||||
struct ivtv_stream *s = &itv->streams[id->type];
|
||||
struct yuv_playback_info *yi = &itv->yuv_info;
|
||||
@@ -719,7 +719,7 @@ retry:
|
||||
|
||||
ssize_t ivtv_v4l2_write(struct file *filp, const char __user *user_buf, size_t count, loff_t *pos)
|
||||
{
|
||||
struct ivtv_open_id *id = fh2id(filp->private_data);
|
||||
struct ivtv_open_id *id = file2id(filp);
|
||||
struct ivtv *itv = id->itv;
|
||||
ssize_t res;
|
||||
|
||||
@@ -732,7 +732,7 @@ ssize_t ivtv_v4l2_write(struct file *filp, const char __user *user_buf, size_t c
|
||||
|
||||
__poll_t ivtv_v4l2_dec_poll(struct file *filp, poll_table *wait)
|
||||
{
|
||||
struct ivtv_open_id *id = fh2id(filp->private_data);
|
||||
struct ivtv_open_id *id = file2id(filp);
|
||||
struct ivtv *itv = id->itv;
|
||||
struct ivtv_stream *s = &itv->streams[id->type];
|
||||
__poll_t res = 0;
|
||||
@@ -767,7 +767,7 @@ __poll_t ivtv_v4l2_dec_poll(struct file *filp, poll_table *wait)
|
||||
__poll_t ivtv_v4l2_enc_poll(struct file *filp, poll_table *wait)
|
||||
{
|
||||
__poll_t req_events = poll_requested_events(wait);
|
||||
struct ivtv_open_id *id = fh2id(filp->private_data);
|
||||
struct ivtv_open_id *id = file2id(filp);
|
||||
struct ivtv *itv = id->itv;
|
||||
struct ivtv_stream *s = &itv->streams[id->type];
|
||||
int eof = test_bit(IVTV_F_S_STREAMOFF, &s->s_flags);
|
||||
|
||||
@@ -727,7 +727,7 @@ static int ivtv_s_register(struct file *file, void *fh, const struct v4l2_dbg_re
|
||||
|
||||
static int ivtv_querycap(struct file *file, void *fh, struct v4l2_capability *vcap)
|
||||
{
|
||||
struct ivtv_open_id *id = fh2id(file->private_data);
|
||||
struct ivtv_open_id *id = fh2id(file_to_v4l2_fh(file));
|
||||
struct ivtv *itv = id->itv;
|
||||
|
||||
strscpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver));
|
||||
@@ -1584,7 +1584,7 @@ static int ivtv_log_status(struct file *file, void *fh)
|
||||
|
||||
static int ivtv_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *dec)
|
||||
{
|
||||
struct ivtv_open_id *id = fh2id(file->private_data);
|
||||
struct ivtv_open_id *id = fh2id(file_to_v4l2_fh(file));
|
||||
struct ivtv *itv = id->itv;
|
||||
|
||||
IVTV_DEBUG_IOCTL("VIDIOC_DECODER_CMD %d\n", dec->cmd);
|
||||
@@ -1593,7 +1593,7 @@ static int ivtv_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd
|
||||
|
||||
static int ivtv_try_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *dec)
|
||||
{
|
||||
struct ivtv_open_id *id = fh2id(file->private_data);
|
||||
struct ivtv_open_id *id = fh2id(file_to_v4l2_fh(file));
|
||||
struct ivtv *itv = id->itv;
|
||||
|
||||
IVTV_DEBUG_IOCTL("VIDIOC_TRY_DECODER_CMD %d\n", dec->cmd);
|
||||
@@ -1602,7 +1602,7 @@ static int ivtv_try_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder
|
||||
|
||||
static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg)
|
||||
{
|
||||
struct ivtv_open_id *id = fh2id(filp->private_data);
|
||||
struct ivtv_open_id *id = fh2id(file_to_v4l2_fh(filp));
|
||||
struct ivtv *itv = id->itv;
|
||||
struct ivtv_stream *s = &itv->streams[id->type];
|
||||
|
||||
|
||||
@@ -302,6 +302,11 @@ struct allegro_channel {
|
||||
unsigned int error;
|
||||
};
|
||||
|
||||
static inline struct allegro_channel *file_to_channel(struct file *filp)
|
||||
{
|
||||
return container_of(file_to_v4l2_fh(filp), struct allegro_channel, fh);
|
||||
}
|
||||
|
||||
static inline int
|
||||
allegro_channel_get_i_frame_qp(struct allegro_channel *channel)
|
||||
{
|
||||
@@ -3229,7 +3234,7 @@ error:
|
||||
|
||||
static int allegro_release(struct file *file)
|
||||
{
|
||||
struct allegro_channel *channel = fh_to_channel(file->private_data);
|
||||
struct allegro_channel *channel = file_to_channel(file);
|
||||
|
||||
v4l2_m2m_ctx_release(channel->fh.m2m_ctx);
|
||||
|
||||
|
||||
@@ -82,6 +82,11 @@ struct ge2d_ctx {
|
||||
u32 xy_swap;
|
||||
};
|
||||
|
||||
static inline struct ge2d_ctx *file_to_ge2d_ctx(struct file *filp)
|
||||
{
|
||||
return container_of(file_to_v4l2_fh(filp), struct ge2d_ctx, fh);
|
||||
}
|
||||
|
||||
struct meson_ge2d {
|
||||
struct v4l2_device v4l2_dev;
|
||||
struct v4l2_m2m_dev *m2m_dev;
|
||||
@@ -871,8 +876,7 @@ static int ge2d_open(struct file *file)
|
||||
|
||||
static int ge2d_release(struct file *file)
|
||||
{
|
||||
struct ge2d_ctx *ctx =
|
||||
container_of(file->private_data, struct ge2d_ctx, fh);
|
||||
struct ge2d_ctx *ctx = file_to_ge2d_ctx(file);
|
||||
struct meson_ge2d *ge2d = ctx->ge2d;
|
||||
|
||||
mutex_lock(&ge2d->mutex);
|
||||
|
||||
@@ -56,6 +56,11 @@
|
||||
|
||||
#define fh_to_ctx(__fh) container_of(__fh, struct coda_ctx, fh)
|
||||
|
||||
static inline struct coda_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
int coda_debug;
|
||||
module_param(coda_debug, int, 0644);
|
||||
MODULE_PARM_DESC(coda_debug, "Debug level (0-2)");
|
||||
@@ -2733,7 +2738,7 @@ err_coda_max:
|
||||
static int coda_release(struct file *file)
|
||||
{
|
||||
struct coda_dev *dev = video_drvdata(file);
|
||||
struct coda_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct coda_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
coda_dbg(1, ctx, "release instance (%p)\n", ctx);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ int wave5_vpu_release_device(struct file *filp,
|
||||
int (*close_func)(struct vpu_instance *inst, u32 *fail_res),
|
||||
char *name)
|
||||
{
|
||||
struct vpu_instance *inst = wave5_to_vpu_inst(filp->private_data);
|
||||
struct vpu_instance *inst = file_to_vpu_inst(filp);
|
||||
int ret = 0;
|
||||
|
||||
v4l2_m2m_ctx_release(inst->v4l2_fh.m2m_ctx);
|
||||
|
||||
@@ -46,6 +46,11 @@ static inline struct vpu_instance *wave5_to_vpu_inst(struct v4l2_fh *vfh)
|
||||
return container_of(vfh, struct vpu_instance, v4l2_fh);
|
||||
}
|
||||
|
||||
static inline struct vpu_instance *file_to_vpu_inst(struct file *filp)
|
||||
{
|
||||
return wave5_to_vpu_inst(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
static inline struct vpu_instance *wave5_ctrl_to_vpu_inst(struct v4l2_ctrl *vctrl)
|
||||
{
|
||||
return container_of(vctrl->handler, struct vpu_instance, v4l2_ctrl_hdl);
|
||||
|
||||
@@ -142,6 +142,11 @@ struct deinterlace_ctx {
|
||||
struct dma_interleaved_template *xt;
|
||||
};
|
||||
|
||||
static inline struct deinterlace_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return container_of(file_to_v4l2_fh(filp), struct deinterlace_ctx, fh);
|
||||
}
|
||||
|
||||
/*
|
||||
* mem2mem callbacks
|
||||
*/
|
||||
@@ -872,7 +877,7 @@ static int deinterlace_open(struct file *file)
|
||||
static int deinterlace_release(struct file *file)
|
||||
{
|
||||
struct deinterlace_dev *pcdev = video_drvdata(file);
|
||||
struct deinterlace_ctx *ctx = file->private_data;
|
||||
struct deinterlace_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
dprintk(pcdev, "Releasing instance %p\n", ctx);
|
||||
|
||||
|
||||
@@ -124,6 +124,11 @@ static inline struct mtk_jpeg_ctx *mtk_jpeg_fh_to_ctx(struct v4l2_fh *fh)
|
||||
return container_of(fh, struct mtk_jpeg_ctx, fh);
|
||||
}
|
||||
|
||||
static inline struct mtk_jpeg_ctx *mtk_jpeg_file_to_ctx(struct file *filp)
|
||||
{
|
||||
return mtk_jpeg_fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
static inline struct mtk_jpeg_src_buf *mtk_jpeg_vb2_to_srcbuf(
|
||||
struct vb2_buffer *vb)
|
||||
{
|
||||
@@ -1208,7 +1213,7 @@ free:
|
||||
static int mtk_jpeg_release(struct file *file)
|
||||
{
|
||||
struct mtk_jpeg_dev *jpeg = video_drvdata(file);
|
||||
struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(file->private_data);
|
||||
struct mtk_jpeg_ctx *ctx = mtk_jpeg_file_to_ctx(file);
|
||||
|
||||
mutex_lock(&jpeg->lock);
|
||||
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
|
||||
|
||||
@@ -353,6 +353,11 @@ static inline struct mtk_mdp_ctx *fh_to_ctx(struct v4l2_fh *fh)
|
||||
return container_of(fh, struct mtk_mdp_ctx, fh);
|
||||
}
|
||||
|
||||
static inline struct mtk_mdp_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
static inline struct mtk_mdp_ctx *ctrl_to_ctx(struct v4l2_ctrl *ctrl)
|
||||
{
|
||||
return container_of(ctrl->handler, struct mtk_mdp_ctx, ctrl_handler);
|
||||
@@ -1137,7 +1142,7 @@ err_lock:
|
||||
|
||||
static int mtk_mdp_m2m_release(struct file *file)
|
||||
{
|
||||
struct mtk_mdp_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct mtk_mdp_ctx *ctx = file_to_ctx(file);
|
||||
struct mtk_mdp_dev *mdp = ctx->mdp_dev;
|
||||
|
||||
flush_workqueue(mdp->job_wq);
|
||||
|
||||
@@ -15,6 +15,11 @@ static inline struct mdp_m2m_ctx *fh_to_ctx(struct v4l2_fh *fh)
|
||||
return container_of(fh, struct mdp_m2m_ctx, fh);
|
||||
}
|
||||
|
||||
static inline struct mdp_m2m_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
static inline struct mdp_m2m_ctx *ctrl_to_ctx(struct v4l2_ctrl *ctrl)
|
||||
{
|
||||
return container_of(ctrl->handler, struct mdp_m2m_ctx, ctrl_handler);
|
||||
@@ -643,7 +648,7 @@ err_free_ctx:
|
||||
|
||||
static int mdp_m2m_release(struct file *file)
|
||||
{
|
||||
struct mdp_m2m_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct mdp_m2m_ctx *ctx = file_to_ctx(file);
|
||||
struct mdp_dev *mdp = video_drvdata(file);
|
||||
struct device *dev = &mdp->pdev->dev;
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ err_ctrls_setup:
|
||||
static int fops_vcodec_release(struct file *file)
|
||||
{
|
||||
struct mtk_vcodec_dec_dev *dev = video_drvdata(file);
|
||||
struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(file->private_data);
|
||||
struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
|
||||
|
||||
mtk_v4l2_vdec_dbg(0, ctx, "[%d] decoder", ctx->id);
|
||||
mutex_lock(&dev->dev_mutex);
|
||||
|
||||
@@ -314,6 +314,11 @@ static inline struct mtk_vcodec_dec_ctx *fh_to_dec_ctx(struct v4l2_fh *fh)
|
||||
return container_of(fh, struct mtk_vcodec_dec_ctx, fh);
|
||||
}
|
||||
|
||||
static inline struct mtk_vcodec_dec_ctx *file_to_dec_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_dec_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
static inline struct mtk_vcodec_dec_ctx *ctrl_to_dec_ctx(struct v4l2_ctrl *ctrl)
|
||||
{
|
||||
return container_of(ctrl->handler, struct mtk_vcodec_dec_ctx, ctrl_hdl);
|
||||
|
||||
@@ -203,7 +203,7 @@ err_ctrls_setup:
|
||||
static int fops_vcodec_release(struct file *file)
|
||||
{
|
||||
struct mtk_vcodec_enc_dev *dev = video_drvdata(file);
|
||||
struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(file->private_data);
|
||||
struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
|
||||
|
||||
mtk_v4l2_venc_dbg(1, ctx, "[%d] encoder", ctx->id);
|
||||
mutex_lock(&dev->dev_mutex);
|
||||
|
||||
@@ -222,6 +222,11 @@ static inline struct mtk_vcodec_enc_ctx *fh_to_enc_ctx(struct v4l2_fh *fh)
|
||||
return container_of(fh, struct mtk_vcodec_enc_ctx, fh);
|
||||
}
|
||||
|
||||
static inline struct mtk_vcodec_enc_ctx *file_to_enc_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_enc_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
static inline struct mtk_vcodec_enc_ctx *ctrl_to_enc_ctx(struct v4l2_ctrl *ctrl)
|
||||
{
|
||||
return container_of(ctrl->handler, struct mtk_vcodec_enc_ctx, ctrl_hdl);
|
||||
|
||||
@@ -649,6 +649,11 @@ static inline struct mxc_jpeg_ctx *mxc_jpeg_fh_to_ctx(struct v4l2_fh *fh)
|
||||
return container_of(fh, struct mxc_jpeg_ctx, fh);
|
||||
}
|
||||
|
||||
static inline struct mxc_jpeg_ctx *mxc_jpeg_file_to_ctx(struct file *filp)
|
||||
{
|
||||
return mxc_jpeg_fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
static int enum_fmt(const struct mxc_jpeg_fmt *mxc_formats, int n,
|
||||
struct v4l2_fmtdesc *f, u32 type)
|
||||
{
|
||||
@@ -2735,7 +2740,7 @@ static const struct v4l2_ioctl_ops mxc_jpeg_ioctl_ops = {
|
||||
static int mxc_jpeg_release(struct file *file)
|
||||
{
|
||||
struct mxc_jpeg_dev *mxc_jpeg = video_drvdata(file);
|
||||
struct mxc_jpeg_ctx *ctx = mxc_jpeg_fh_to_ctx(file->private_data);
|
||||
struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
|
||||
struct device *dev = mxc_jpeg->dev;
|
||||
|
||||
mutex_lock(&mxc_jpeg->lock);
|
||||
|
||||
@@ -79,6 +79,11 @@ static inline struct mxc_isi_m2m_ctx *to_isi_m2m_ctx(struct v4l2_fh *fh)
|
||||
return container_of(fh, struct mxc_isi_m2m_ctx, fh);
|
||||
}
|
||||
|
||||
static inline struct mxc_isi_m2m_ctx *file_to_isi_m2m_ctx(struct file *filp)
|
||||
{
|
||||
return to_isi_m2m_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
static inline struct mxc_isi_m2m_ctx_queue_data *
|
||||
mxc_isi_m2m_ctx_qdata(struct mxc_isi_m2m_ctx *ctx, enum v4l2_buf_type type)
|
||||
{
|
||||
@@ -707,7 +712,7 @@ err_fh:
|
||||
static int mxc_isi_m2m_release(struct file *file)
|
||||
{
|
||||
struct mxc_isi_m2m *m2m = video_drvdata(file);
|
||||
struct mxc_isi_m2m_ctx *ctx = to_isi_m2m_ctx(file->private_data);
|
||||
struct mxc_isi_m2m_ctx *ctx = file_to_isi_m2m_ctx(file);
|
||||
|
||||
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
|
||||
mxc_isi_m2m_ctx_ctrls_delete(ctx);
|
||||
|
||||
@@ -214,6 +214,11 @@ struct emmaprp_ctx {
|
||||
struct emmaprp_q_data q_data[2];
|
||||
};
|
||||
|
||||
static inline struct emmaprp_ctx *file_to_emmaprp_ctx(struct file *filp)
|
||||
{
|
||||
return container_of(file_to_v4l2_fh(filp), struct emmaprp_ctx, fh);
|
||||
}
|
||||
|
||||
static struct emmaprp_q_data *get_q_data(struct emmaprp_ctx *ctx,
|
||||
enum v4l2_buf_type type)
|
||||
{
|
||||
@@ -758,7 +763,7 @@ static int emmaprp_open(struct file *file)
|
||||
static int emmaprp_release(struct file *file)
|
||||
{
|
||||
struct emmaprp_dev *pcdev = video_drvdata(file);
|
||||
struct emmaprp_ctx *ctx = file->private_data;
|
||||
struct emmaprp_ctx *ctx = file_to_emmaprp_ctx(file);
|
||||
|
||||
dprintk(pcdev, "Releasing instance %p\n", ctx);
|
||||
|
||||
|
||||
@@ -635,6 +635,11 @@ static inline struct fdp1_ctx *fh_to_ctx(struct v4l2_fh *fh)
|
||||
return container_of(fh, struct fdp1_ctx, fh);
|
||||
}
|
||||
|
||||
static inline struct fdp1_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
static struct fdp1_q_data *get_q_data(struct fdp1_ctx *ctx,
|
||||
enum v4l2_buf_type type)
|
||||
{
|
||||
@@ -2158,7 +2163,7 @@ done:
|
||||
static int fdp1_release(struct file *file)
|
||||
{
|
||||
struct fdp1_dev *fdp1 = video_drvdata(file);
|
||||
struct fdp1_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct fdp1_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
dprintk(fdp1, "Releasing instance %p\n", ctx);
|
||||
|
||||
|
||||
@@ -485,6 +485,11 @@ static struct jpu_ctx *fh_to_ctx(struct v4l2_fh *fh)
|
||||
return container_of(fh, struct jpu_ctx, fh);
|
||||
}
|
||||
|
||||
static struct jpu_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
static void jpu_set_tbl(struct jpu *jpu, u32 reg, const unsigned int *tbl,
|
||||
unsigned int len) {
|
||||
unsigned int i;
|
||||
@@ -1281,7 +1286,7 @@ v4l_prepare_rollback:
|
||||
static int jpu_release(struct file *file)
|
||||
{
|
||||
struct jpu *jpu = video_drvdata(file);
|
||||
struct jpu_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct jpu_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
|
||||
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
|
||||
|
||||
@@ -411,8 +411,7 @@ static int rga_open(struct file *file)
|
||||
|
||||
static int rga_release(struct file *file)
|
||||
{
|
||||
struct rga_ctx *ctx =
|
||||
container_of(file->private_data, struct rga_ctx, fh);
|
||||
struct rga_ctx *ctx = file_to_rga_ctx(file);
|
||||
struct rockchip_rga *rga = ctx->rga;
|
||||
|
||||
mutex_lock(&rga->mutex);
|
||||
|
||||
@@ -68,6 +68,11 @@ struct rga_ctx {
|
||||
u32 fill_color;
|
||||
};
|
||||
|
||||
static inline struct rga_ctx *file_to_rga_ctx(struct file *filp)
|
||||
{
|
||||
return container_of(file_to_v4l2_fh(filp), struct rga_ctx, fh);
|
||||
}
|
||||
|
||||
struct rockchip_rga {
|
||||
struct v4l2_device v4l2_dev;
|
||||
struct v4l2_m2m_dev *m2m_dev;
|
||||
|
||||
@@ -953,7 +953,7 @@ err_free_ctx:
|
||||
|
||||
static int rkvdec_release(struct file *filp)
|
||||
{
|
||||
struct rkvdec_ctx *ctx = fh_to_rkvdec_ctx(filp->private_data);
|
||||
struct rkvdec_ctx *ctx = file_to_rkvdec_ctx(filp);
|
||||
|
||||
v4l2_fh_del(&ctx->fh);
|
||||
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
|
||||
|
||||
@@ -129,6 +129,11 @@ static inline struct rkvdec_ctx *fh_to_rkvdec_ctx(struct v4l2_fh *fh)
|
||||
return container_of(fh, struct rkvdec_ctx, fh);
|
||||
}
|
||||
|
||||
static inline struct rkvdec_ctx *file_to_rkvdec_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_rkvdec_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
struct rkvdec_aux_buf {
|
||||
void *cpu;
|
||||
dma_addr_t dma;
|
||||
|
||||
@@ -86,6 +86,7 @@ enum gsc_yuv_fmt {
|
||||
};
|
||||
|
||||
#define fh_to_ctx(__fh) container_of(__fh, struct gsc_ctx, fh)
|
||||
|
||||
#define is_rgb(x) (!!((x) & 0x1))
|
||||
#define is_yuv420(x) (!!((x) & 0x2))
|
||||
#define is_yuv422(x) (!!((x) & 0x4))
|
||||
@@ -381,6 +382,11 @@ struct gsc_ctx {
|
||||
enum v4l2_colorspace out_colorspace;
|
||||
};
|
||||
|
||||
static inline struct gsc_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
void gsc_set_prefbuf(struct gsc_dev *gsc, struct gsc_frame *frm);
|
||||
int gsc_register_m2m_device(struct gsc_dev *gsc);
|
||||
void gsc_unregister_m2m_device(struct gsc_dev *gsc);
|
||||
|
||||
@@ -666,7 +666,7 @@ unlock:
|
||||
|
||||
static int gsc_m2m_release(struct file *file)
|
||||
{
|
||||
struct gsc_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct gsc_ctx *ctx = file_to_ctx(file);
|
||||
struct gsc_dev *gsc = ctx->gsc_dev;
|
||||
|
||||
pr_debug("pid: %d, state: 0x%lx, refcnt= %d",
|
||||
@@ -690,7 +690,7 @@ static int gsc_m2m_release(struct file *file)
|
||||
static __poll_t gsc_m2m_poll(struct file *file,
|
||||
struct poll_table_struct *wait)
|
||||
{
|
||||
struct gsc_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct gsc_ctx *ctx = file_to_ctx(file);
|
||||
struct gsc_dev *gsc = ctx->gsc_dev;
|
||||
__poll_t ret;
|
||||
|
||||
@@ -705,7 +705,7 @@ static __poll_t gsc_m2m_poll(struct file *file,
|
||||
|
||||
static int gsc_m2m_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
{
|
||||
struct gsc_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct gsc_ctx *ctx = file_to_ctx(file);
|
||||
struct gsc_dev *gsc = ctx->gsc_dev;
|
||||
int ret;
|
||||
|
||||
|
||||
@@ -498,6 +498,11 @@ struct fimc_ctx {
|
||||
|
||||
#define fh_to_ctx(__fh) container_of(__fh, struct fimc_ctx, fh)
|
||||
|
||||
static inline struct fimc_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
static inline void set_frame_bounds(struct fimc_frame *f, u32 width, u32 height)
|
||||
{
|
||||
f->o_width = width;
|
||||
|
||||
@@ -675,7 +675,7 @@ unlock:
|
||||
|
||||
static int fimc_m2m_release(struct file *file)
|
||||
{
|
||||
struct fimc_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct fimc_ctx *ctx = file_to_ctx(file);
|
||||
struct fimc_dev *fimc = ctx->fimc_dev;
|
||||
|
||||
dbg("pid: %d, state: 0x%lx, refcnt= %d",
|
||||
|
||||
@@ -25,7 +25,10 @@
|
||||
#include "g2d.h"
|
||||
#include "g2d-regs.h"
|
||||
|
||||
#define fh2ctx(__fh) container_of(__fh, struct g2d_ctx, fh)
|
||||
static inline struct g2d_ctx *file2ctx(struct file *filp)
|
||||
{
|
||||
return container_of(file_to_v4l2_fh(filp), struct g2d_ctx, fh);
|
||||
}
|
||||
|
||||
static struct g2d_fmt formats[] = {
|
||||
{
|
||||
@@ -272,7 +275,7 @@ static int g2d_open(struct file *file)
|
||||
static int g2d_release(struct file *file)
|
||||
{
|
||||
struct g2d_dev *dev = video_drvdata(file);
|
||||
struct g2d_ctx *ctx = fh2ctx(file->private_data);
|
||||
struct g2d_ctx *ctx = file2ctx(file);
|
||||
|
||||
mutex_lock(&dev->mutex);
|
||||
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
|
||||
|
||||
@@ -585,6 +585,11 @@ static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh)
|
||||
return container_of(fh, struct s5p_jpeg_ctx, fh);
|
||||
}
|
||||
|
||||
static inline struct s5p_jpeg_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
static int s5p_jpeg_to_user_subsampling(struct s5p_jpeg_ctx *ctx)
|
||||
{
|
||||
switch (ctx->jpeg->variant->version) {
|
||||
@@ -1012,7 +1017,7 @@ free:
|
||||
static int s5p_jpeg_release(struct file *file)
|
||||
{
|
||||
struct s5p_jpeg *jpeg = video_drvdata(file);
|
||||
struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct s5p_jpeg_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
mutex_lock(&jpeg->lock);
|
||||
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
|
||||
@@ -1828,7 +1833,7 @@ static int s5p_jpeg_g_selection(struct file *file, void *priv,
|
||||
static int s5p_jpeg_s_selection(struct file *file, void *fh,
|
||||
struct v4l2_selection *s)
|
||||
{
|
||||
struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct s5p_jpeg_ctx *ctx = file_to_ctx(file);
|
||||
struct v4l2_rect *rect = &s->r;
|
||||
int ret = -EINVAL;
|
||||
|
||||
|
||||
@@ -970,7 +970,7 @@ err_enter:
|
||||
/* Release MFC context */
|
||||
static int s5p_mfc_release(struct file *file)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
struct s5p_mfc_dev *dev = ctx->dev;
|
||||
|
||||
/* if dev is null, do cleanup that doesn't need dev */
|
||||
@@ -1027,7 +1027,7 @@ static int s5p_mfc_release(struct file *file)
|
||||
static __poll_t s5p_mfc_poll(struct file *file,
|
||||
struct poll_table_struct *wait)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
struct s5p_mfc_dev *dev = ctx->dev;
|
||||
struct vb2_queue *src_q, *dst_q;
|
||||
struct vb2_buffer *src_vb = NULL, *dst_vb = NULL;
|
||||
@@ -1078,7 +1078,7 @@ end:
|
||||
/* Mmap */
|
||||
static int s5p_mfc_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
|
||||
int ret;
|
||||
|
||||
|
||||
@@ -768,6 +768,12 @@ struct mfc_control {
|
||||
((f && f->op) ? f->op(args) : (typeof(f->op(args)))(-ENODEV))
|
||||
|
||||
#define fh_to_ctx(__fh) container_of(__fh, struct s5p_mfc_ctx, fh)
|
||||
|
||||
static inline struct s5p_mfc_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
#define ctrl_to_ctx(__ctrl) \
|
||||
container_of((__ctrl)->handler, struct s5p_mfc_ctx, ctrl_handler)
|
||||
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
|
||||
#define fh_to_ctx(__fh) container_of(__fh, struct bdisp_ctx, fh)
|
||||
|
||||
static inline struct bdisp_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
enum bdisp_dev_flags {
|
||||
ST_M2M_OPEN, /* Driver opened */
|
||||
ST_M2M_RUNNING, /* HW device running */
|
||||
@@ -644,7 +649,7 @@ unlock:
|
||||
|
||||
static int bdisp_release(struct file *file)
|
||||
{
|
||||
struct bdisp_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct bdisp_ctx *ctx = file_to_ctx(file);
|
||||
struct bdisp_dev *bdisp = ctx->bdisp_dev;
|
||||
|
||||
dev_dbg(bdisp->dev, "%s\n", __func__);
|
||||
|
||||
@@ -25,6 +25,12 @@
|
||||
#define DELTA_PREFIX "[---:----]"
|
||||
|
||||
#define to_ctx(__fh) container_of(__fh, struct delta_ctx, fh)
|
||||
|
||||
static inline struct delta_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
#define to_au(__vbuf) container_of(__vbuf, struct delta_au, vbuf)
|
||||
#define to_frame(__vbuf) container_of(__vbuf, struct delta_frame, vbuf)
|
||||
|
||||
@@ -382,7 +388,7 @@ static int delta_open_decoder(struct delta_ctx *ctx, u32 streamformat,
|
||||
static int delta_querycap(struct file *file, void *priv,
|
||||
struct v4l2_capability *cap)
|
||||
{
|
||||
struct delta_ctx *ctx = to_ctx(file->private_data);
|
||||
struct delta_ctx *ctx = file_to_ctx(file);
|
||||
struct delta_dev *delta = ctx->dev;
|
||||
|
||||
strscpy(cap->driver, DELTA_NAME, sizeof(cap->driver));
|
||||
@@ -396,7 +402,7 @@ static int delta_querycap(struct file *file, void *priv,
|
||||
static int delta_enum_fmt_stream(struct file *file, void *priv,
|
||||
struct v4l2_fmtdesc *f)
|
||||
{
|
||||
struct delta_ctx *ctx = to_ctx(file->private_data);
|
||||
struct delta_ctx *ctx = file_to_ctx(file);
|
||||
struct delta_dev *delta = ctx->dev;
|
||||
|
||||
if (unlikely(f->index >= delta->nb_of_streamformats))
|
||||
@@ -410,7 +416,7 @@ static int delta_enum_fmt_stream(struct file *file, void *priv,
|
||||
static int delta_enum_fmt_frame(struct file *file, void *priv,
|
||||
struct v4l2_fmtdesc *f)
|
||||
{
|
||||
struct delta_ctx *ctx = to_ctx(file->private_data);
|
||||
struct delta_ctx *ctx = file_to_ctx(file);
|
||||
struct delta_dev *delta = ctx->dev;
|
||||
|
||||
if (unlikely(f->index >= delta->nb_of_pixelformats))
|
||||
@@ -424,7 +430,7 @@ static int delta_enum_fmt_frame(struct file *file, void *priv,
|
||||
static int delta_g_fmt_stream(struct file *file, void *fh,
|
||||
struct v4l2_format *f)
|
||||
{
|
||||
struct delta_ctx *ctx = to_ctx(file->private_data);
|
||||
struct delta_ctx *ctx = file_to_ctx(file);
|
||||
struct delta_dev *delta = ctx->dev;
|
||||
struct v4l2_pix_format *pix = &f->fmt.pix;
|
||||
struct delta_streaminfo *streaminfo = &ctx->streaminfo;
|
||||
@@ -452,7 +458,7 @@ static int delta_g_fmt_stream(struct file *file, void *fh,
|
||||
|
||||
static int delta_g_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
|
||||
{
|
||||
struct delta_ctx *ctx = to_ctx(file->private_data);
|
||||
struct delta_ctx *ctx = file_to_ctx(file);
|
||||
struct delta_dev *delta = ctx->dev;
|
||||
struct v4l2_pix_format *pix = &f->fmt.pix;
|
||||
struct delta_frameinfo *frameinfo = &ctx->frameinfo;
|
||||
@@ -491,7 +497,7 @@ static int delta_g_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
|
||||
static int delta_try_fmt_stream(struct file *file, void *priv,
|
||||
struct v4l2_format *f)
|
||||
{
|
||||
struct delta_ctx *ctx = to_ctx(file->private_data);
|
||||
struct delta_ctx *ctx = file_to_ctx(file);
|
||||
struct delta_dev *delta = ctx->dev;
|
||||
struct v4l2_pix_format *pix = &f->fmt.pix;
|
||||
u32 streamformat = pix->pixelformat;
|
||||
@@ -545,7 +551,7 @@ static int delta_try_fmt_stream(struct file *file, void *priv,
|
||||
static int delta_try_fmt_frame(struct file *file, void *priv,
|
||||
struct v4l2_format *f)
|
||||
{
|
||||
struct delta_ctx *ctx = to_ctx(file->private_data);
|
||||
struct delta_ctx *ctx = file_to_ctx(file);
|
||||
struct delta_dev *delta = ctx->dev;
|
||||
struct v4l2_pix_format *pix = &f->fmt.pix;
|
||||
u32 pixelformat = pix->pixelformat;
|
||||
@@ -605,7 +611,7 @@ static int delta_try_fmt_frame(struct file *file, void *priv,
|
||||
static int delta_s_fmt_stream(struct file *file, void *fh,
|
||||
struct v4l2_format *f)
|
||||
{
|
||||
struct delta_ctx *ctx = to_ctx(file->private_data);
|
||||
struct delta_ctx *ctx = file_to_ctx(file);
|
||||
struct delta_dev *delta = ctx->dev;
|
||||
struct vb2_queue *vq;
|
||||
struct v4l2_pix_format *pix = &f->fmt.pix;
|
||||
@@ -641,7 +647,7 @@ static int delta_s_fmt_stream(struct file *file, void *fh,
|
||||
|
||||
static int delta_s_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
|
||||
{
|
||||
struct delta_ctx *ctx = to_ctx(file->private_data);
|
||||
struct delta_ctx *ctx = file_to_ctx(file);
|
||||
struct delta_dev *delta = ctx->dev;
|
||||
const struct delta_dec *dec = ctx->dec;
|
||||
struct v4l2_pix_format *pix = &f->fmt.pix;
|
||||
@@ -1690,7 +1696,7 @@ err:
|
||||
|
||||
static int delta_release(struct file *file)
|
||||
{
|
||||
struct delta_ctx *ctx = to_ctx(file->private_data);
|
||||
struct delta_ctx *ctx = file_to_ctx(file);
|
||||
struct delta_dev *delta = ctx->dev;
|
||||
const struct delta_dec *dec = ctx->dec;
|
||||
|
||||
|
||||
@@ -36,7 +36,10 @@
|
||||
#define to_type_str(type) (type == V4L2_BUF_TYPE_VIDEO_OUTPUT ? \
|
||||
"frame" : "stream")
|
||||
|
||||
#define fh_to_ctx(f) (container_of(f, struct hva_ctx, fh))
|
||||
static inline struct hva_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return container_of(file_to_v4l2_fh(filp), struct hva_ctx, fh);
|
||||
}
|
||||
|
||||
/* registry of available encoders */
|
||||
static const struct hva_enc *hva_encoders[] = {
|
||||
@@ -254,7 +257,7 @@ static void hva_dbg_summary(struct hva_ctx *ctx)
|
||||
static int hva_querycap(struct file *file, void *priv,
|
||||
struct v4l2_capability *cap)
|
||||
{
|
||||
struct hva_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct hva_ctx *ctx = file_to_ctx(file);
|
||||
struct hva_dev *hva = ctx_to_hdev(ctx);
|
||||
|
||||
strscpy(cap->driver, HVA_NAME, sizeof(cap->driver));
|
||||
@@ -268,7 +271,7 @@ static int hva_querycap(struct file *file, void *priv,
|
||||
static int hva_enum_fmt_stream(struct file *file, void *priv,
|
||||
struct v4l2_fmtdesc *f)
|
||||
{
|
||||
struct hva_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct hva_ctx *ctx = file_to_ctx(file);
|
||||
struct hva_dev *hva = ctx_to_hdev(ctx);
|
||||
|
||||
if (unlikely(f->index >= hva->nb_of_streamformats))
|
||||
@@ -282,7 +285,7 @@ static int hva_enum_fmt_stream(struct file *file, void *priv,
|
||||
static int hva_enum_fmt_frame(struct file *file, void *priv,
|
||||
struct v4l2_fmtdesc *f)
|
||||
{
|
||||
struct hva_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct hva_ctx *ctx = file_to_ctx(file);
|
||||
struct hva_dev *hva = ctx_to_hdev(ctx);
|
||||
|
||||
if (unlikely(f->index >= hva->nb_of_pixelformats))
|
||||
@@ -295,7 +298,7 @@ static int hva_enum_fmt_frame(struct file *file, void *priv,
|
||||
|
||||
static int hva_g_fmt_stream(struct file *file, void *fh, struct v4l2_format *f)
|
||||
{
|
||||
struct hva_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct hva_ctx *ctx = file_to_ctx(file);
|
||||
struct hva_streaminfo *streaminfo = &ctx->streaminfo;
|
||||
|
||||
f->fmt.pix.width = streaminfo->width;
|
||||
@@ -314,7 +317,7 @@ static int hva_g_fmt_stream(struct file *file, void *fh, struct v4l2_format *f)
|
||||
|
||||
static int hva_g_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
|
||||
{
|
||||
struct hva_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct hva_ctx *ctx = file_to_ctx(file);
|
||||
struct hva_frameinfo *frameinfo = &ctx->frameinfo;
|
||||
|
||||
f->fmt.pix.width = frameinfo->width;
|
||||
@@ -335,7 +338,7 @@ static int hva_g_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
|
||||
static int hva_try_fmt_stream(struct file *file, void *priv,
|
||||
struct v4l2_format *f)
|
||||
{
|
||||
struct hva_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct hva_ctx *ctx = file_to_ctx(file);
|
||||
struct device *dev = ctx_to_dev(ctx);
|
||||
struct v4l2_pix_format *pix = &f->fmt.pix;
|
||||
u32 streamformat = pix->pixelformat;
|
||||
@@ -399,7 +402,7 @@ static int hva_try_fmt_stream(struct file *file, void *priv,
|
||||
static int hva_try_fmt_frame(struct file *file, void *priv,
|
||||
struct v4l2_format *f)
|
||||
{
|
||||
struct hva_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct hva_ctx *ctx = file_to_ctx(file);
|
||||
struct device *dev = ctx_to_dev(ctx);
|
||||
struct v4l2_pix_format *pix = &f->fmt.pix;
|
||||
u32 pixelformat = pix->pixelformat;
|
||||
@@ -449,7 +452,7 @@ static int hva_try_fmt_frame(struct file *file, void *priv,
|
||||
|
||||
static int hva_s_fmt_stream(struct file *file, void *fh, struct v4l2_format *f)
|
||||
{
|
||||
struct hva_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct hva_ctx *ctx = file_to_ctx(file);
|
||||
struct device *dev = ctx_to_dev(ctx);
|
||||
struct vb2_queue *vq;
|
||||
int ret;
|
||||
@@ -479,7 +482,7 @@ static int hva_s_fmt_stream(struct file *file, void *fh, struct v4l2_format *f)
|
||||
|
||||
static int hva_s_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
|
||||
{
|
||||
struct hva_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct hva_ctx *ctx = file_to_ctx(file);
|
||||
struct device *dev = ctx_to_dev(ctx);
|
||||
struct v4l2_pix_format *pix = &f->fmt.pix;
|
||||
struct vb2_queue *vq;
|
||||
@@ -517,7 +520,7 @@ static int hva_s_fmt_frame(struct file *file, void *fh, struct v4l2_format *f)
|
||||
|
||||
static int hva_g_parm(struct file *file, void *fh, struct v4l2_streamparm *sp)
|
||||
{
|
||||
struct hva_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct hva_ctx *ctx = file_to_ctx(file);
|
||||
struct v4l2_fract *time_per_frame = &ctx->ctrls.time_per_frame;
|
||||
|
||||
if (sp->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
|
||||
@@ -533,7 +536,7 @@ static int hva_g_parm(struct file *file, void *fh, struct v4l2_streamparm *sp)
|
||||
|
||||
static int hva_s_parm(struct file *file, void *fh, struct v4l2_streamparm *sp)
|
||||
{
|
||||
struct hva_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct hva_ctx *ctx = file_to_ctx(file);
|
||||
struct v4l2_fract *time_per_frame = &ctx->ctrls.time_per_frame;
|
||||
|
||||
if (sp->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
|
||||
@@ -553,7 +556,7 @@ static int hva_s_parm(struct file *file, void *fh, struct v4l2_streamparm *sp)
|
||||
|
||||
static int hva_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
|
||||
{
|
||||
struct hva_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct hva_ctx *ctx = file_to_ctx(file);
|
||||
struct device *dev = ctx_to_dev(ctx);
|
||||
|
||||
if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
|
||||
@@ -1225,7 +1228,7 @@ out:
|
||||
|
||||
static int hva_release(struct file *file)
|
||||
{
|
||||
struct hva_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct hva_ctx *ctx = file_to_ctx(file);
|
||||
struct hva_dev *hva = ctx_to_hdev(ctx);
|
||||
struct device *dev = ctx_to_dev(ctx);
|
||||
const struct hva_enc *enc = ctx->enc;
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#include <media/videobuf2-v4l2.h>
|
||||
#include <media/v4l2-mem2mem.h>
|
||||
|
||||
#define fh_to_ctx(f) (container_of(f, struct hva_ctx, fh))
|
||||
|
||||
#define hva_to_dev(h) (h->dev)
|
||||
|
||||
#define ctx_to_dev(c) (c->hva_dev->dev)
|
||||
|
||||
@@ -45,7 +45,10 @@
|
||||
* whole of a destination image with a pixel format conversion.
|
||||
*/
|
||||
|
||||
#define fh2ctx(__fh) container_of(__fh, struct dma2d_ctx, fh)
|
||||
static inline struct dma2d_ctx *file2ctx(struct file *filp)
|
||||
{
|
||||
return container_of(file_to_v4l2_fh(filp), struct dma2d_ctx, fh);
|
||||
}
|
||||
|
||||
static const struct dma2d_fmt formats[] = {
|
||||
{
|
||||
@@ -318,7 +321,7 @@ static int dma2d_open(struct file *file)
|
||||
static int dma2d_release(struct file *file)
|
||||
{
|
||||
struct dma2d_dev *dev = video_drvdata(file);
|
||||
struct dma2d_ctx *ctx = fh2ctx(file->private_data);
|
||||
struct dma2d_ctx *ctx = file2ctx(file);
|
||||
|
||||
mutex_lock(&dev->mutex);
|
||||
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
|
||||
|
||||
@@ -756,8 +756,7 @@ err_free:
|
||||
static int deinterlace_release(struct file *file)
|
||||
{
|
||||
struct deinterlace_dev *dev = video_drvdata(file);
|
||||
struct deinterlace_ctx *ctx = container_of(file->private_data,
|
||||
struct deinterlace_ctx, fh);
|
||||
struct deinterlace_ctx *ctx = deinterlace_file2ctx(file);
|
||||
|
||||
mutex_lock(&dev->dev_mutex);
|
||||
|
||||
|
||||
@@ -691,8 +691,7 @@ err_free:
|
||||
static int rotate_release(struct file *file)
|
||||
{
|
||||
struct rotate_dev *dev = video_drvdata(file);
|
||||
struct rotate_ctx *ctx = container_of(file->private_data,
|
||||
struct rotate_ctx, fh);
|
||||
struct rotate_ctx *ctx = rotate_file2ctx(file);
|
||||
|
||||
mutex_lock(&dev->dev_mutex);
|
||||
|
||||
|
||||
@@ -1373,7 +1373,7 @@ static int isp_video_release(struct file *file)
|
||||
|
||||
static __poll_t isp_video_poll(struct file *file, poll_table *wait)
|
||||
{
|
||||
struct isp_video_fh *vfh = to_isp_video_fh(file->private_data);
|
||||
struct isp_video_fh *vfh = file_to_isp_video_fh(file);
|
||||
struct isp_video *video = video_drvdata(file);
|
||||
__poll_t ret;
|
||||
|
||||
@@ -1386,7 +1386,7 @@ static __poll_t isp_video_poll(struct file *file, poll_table *wait)
|
||||
|
||||
static int isp_video_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
{
|
||||
struct isp_video_fh *vfh = to_isp_video_fh(file->private_data);
|
||||
struct isp_video_fh *vfh = file_to_isp_video_fh(file);
|
||||
|
||||
return vb2_mmap(&vfh->queue, vma);
|
||||
}
|
||||
|
||||
@@ -195,6 +195,12 @@ struct isp_video_fh {
|
||||
};
|
||||
|
||||
#define to_isp_video_fh(fh) container_of(fh, struct isp_video_fh, vfh)
|
||||
|
||||
static inline struct isp_video_fh *file_to_isp_video_fh(struct file *filp)
|
||||
{
|
||||
return to_isp_video_fh(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
#define isp_video_queue_to_isp_video_fh(q) \
|
||||
container_of(q, struct isp_video_fh, queue)
|
||||
|
||||
|
||||
@@ -387,6 +387,11 @@ static __always_inline struct hantro_ctx *fh_to_ctx(struct v4l2_fh *fh)
|
||||
return container_of(fh, struct hantro_ctx, fh);
|
||||
}
|
||||
|
||||
static __always_inline struct hantro_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
/* Register accessors. */
|
||||
static __always_inline void vepu_write_relaxed(struct hantro_dev *vpu,
|
||||
u32 val, u32 reg)
|
||||
|
||||
@@ -687,8 +687,7 @@ err_ctx_free:
|
||||
|
||||
static int hantro_release(struct file *filp)
|
||||
{
|
||||
struct hantro_ctx *ctx =
|
||||
container_of(filp->private_data, struct hantro_ctx, fh);
|
||||
struct hantro_ctx *ctx = file_to_ctx(filp);
|
||||
|
||||
/*
|
||||
* No need for extra locking because this was the last reference
|
||||
|
||||
@@ -66,6 +66,11 @@ struct ipu_csc_scaler_ctx {
|
||||
unsigned int sequence;
|
||||
};
|
||||
|
||||
static inline struct ipu_csc_scaler_ctx *file_to_ctx(struct file *filp)
|
||||
{
|
||||
return fh_to_ctx(file_to_v4l2_fh(filp));
|
||||
}
|
||||
|
||||
static struct ipu_csc_scaler_q_data *get_q_data(struct ipu_csc_scaler_ctx *ctx,
|
||||
enum v4l2_buf_type type)
|
||||
{
|
||||
@@ -797,7 +802,7 @@ err_ctx:
|
||||
static int ipu_csc_scaler_release(struct file *file)
|
||||
{
|
||||
struct ipu_csc_scaler_priv *priv = video_drvdata(file);
|
||||
struct ipu_csc_scaler_ctx *ctx = fh_to_ctx(file->private_data);
|
||||
struct ipu_csc_scaler_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
dev_dbg(priv->dev, "Releasing instance %p\n", ctx);
|
||||
|
||||
|
||||
@@ -558,8 +558,7 @@ vdec_try_fmt_common(struct amvdec_session *sess, u32 size,
|
||||
|
||||
static int vdec_try_fmt(struct file *file, void *fh, struct v4l2_format *f)
|
||||
{
|
||||
struct amvdec_session *sess =
|
||||
container_of(file->private_data, struct amvdec_session, fh);
|
||||
struct amvdec_session *sess = file_to_amvdec_session(file);
|
||||
|
||||
vdec_try_fmt_common(sess, sess->core->platform->num_formats, f);
|
||||
|
||||
@@ -568,8 +567,7 @@ static int vdec_try_fmt(struct file *file, void *fh, struct v4l2_format *f)
|
||||
|
||||
static int vdec_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
|
||||
{
|
||||
struct amvdec_session *sess =
|
||||
container_of(file->private_data, struct amvdec_session, fh);
|
||||
struct amvdec_session *sess = file_to_amvdec_session(file);
|
||||
struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp;
|
||||
|
||||
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
|
||||
@@ -596,8 +594,7 @@ static int vdec_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
|
||||
|
||||
static int vdec_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
|
||||
{
|
||||
struct amvdec_session *sess =
|
||||
container_of(file->private_data, struct amvdec_session, fh);
|
||||
struct amvdec_session *sess = file_to_amvdec_session(file);
|
||||
struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp;
|
||||
u32 num_formats = sess->core->platform->num_formats;
|
||||
const struct amvdec_format *fmt_out;
|
||||
@@ -658,8 +655,7 @@ static int vdec_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
|
||||
|
||||
static int vdec_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
|
||||
{
|
||||
struct amvdec_session *sess =
|
||||
container_of(file->private_data, struct amvdec_session, fh);
|
||||
struct amvdec_session *sess = file_to_amvdec_session(file);
|
||||
const struct vdec_platform *platform = sess->core->platform;
|
||||
const struct amvdec_format *fmt_out;
|
||||
|
||||
@@ -688,8 +684,7 @@ static int vdec_enum_fmt(struct file *file, void *fh, struct v4l2_fmtdesc *f)
|
||||
static int vdec_enum_framesizes(struct file *file, void *fh,
|
||||
struct v4l2_frmsizeenum *fsize)
|
||||
{
|
||||
struct amvdec_session *sess =
|
||||
container_of(file->private_data, struct amvdec_session, fh);
|
||||
struct amvdec_session *sess = file_to_amvdec_session(file);
|
||||
const struct amvdec_format *formats = sess->core->platform->formats;
|
||||
const struct amvdec_format *fmt;
|
||||
u32 num_formats = sess->core->platform->num_formats;
|
||||
@@ -713,8 +708,7 @@ static int vdec_enum_framesizes(struct file *file, void *fh,
|
||||
static int
|
||||
vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd)
|
||||
{
|
||||
struct amvdec_session *sess =
|
||||
container_of(file->private_data, struct amvdec_session, fh);
|
||||
struct amvdec_session *sess = file_to_amvdec_session(file);
|
||||
struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops;
|
||||
struct device *dev = sess->core->dev;
|
||||
int ret;
|
||||
@@ -773,8 +767,7 @@ static int vdec_subscribe_event(struct v4l2_fh *fh,
|
||||
static int vdec_g_pixelaspect(struct file *file, void *fh, int type,
|
||||
struct v4l2_fract *f)
|
||||
{
|
||||
struct amvdec_session *sess =
|
||||
container_of(file->private_data, struct amvdec_session, fh);
|
||||
struct amvdec_session *sess = file_to_amvdec_session(file);
|
||||
|
||||
if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
|
||||
return -EINVAL;
|
||||
@@ -930,8 +923,7 @@ err_free_sess:
|
||||
|
||||
static int vdec_close(struct file *file)
|
||||
{
|
||||
struct amvdec_session *sess =
|
||||
container_of(file->private_data, struct amvdec_session, fh);
|
||||
struct amvdec_session *sess = file_to_amvdec_session(file);
|
||||
|
||||
v4l2_m2m_ctx_release(sess->m2m_ctx);
|
||||
v4l2_m2m_release(sess->m2m_dev);
|
||||
|
||||
@@ -282,6 +282,11 @@ struct amvdec_session {
|
||||
void *priv;
|
||||
};
|
||||
|
||||
static inline struct amvdec_session *file_to_amvdec_session(struct file *filp)
|
||||
{
|
||||
return container_of(file_to_v4l2_fh(filp), struct amvdec_session, fh);
|
||||
}
|
||||
|
||||
u32 amvdec_get_output_size(struct amvdec_session *sess);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -401,8 +401,7 @@ err_free:
|
||||
static int cedrus_release(struct file *file)
|
||||
{
|
||||
struct cedrus_dev *dev = video_drvdata(file);
|
||||
struct cedrus_ctx *ctx = container_of(file->private_data,
|
||||
struct cedrus_ctx, fh);
|
||||
struct cedrus_ctx *ctx = cedrus_file2ctx(file);
|
||||
|
||||
mutex_lock(&dev->dev_mutex);
|
||||
|
||||
|
||||
@@ -155,6 +155,11 @@ struct cedrus_ctx {
|
||||
} codec;
|
||||
};
|
||||
|
||||
static inline struct cedrus_ctx *cedrus_file2ctx(struct file *file)
|
||||
{
|
||||
return container_of(file_to_v4l2_fh(file), struct cedrus_ctx, fh);
|
||||
}
|
||||
|
||||
struct cedrus_dec_ops {
|
||||
void (*irq_clear)(struct cedrus_ctx *ctx);
|
||||
void (*irq_disable)(struct cedrus_ctx *ctx);
|
||||
|
||||
@@ -83,11 +83,6 @@ static struct cedrus_format cedrus_formats[] = {
|
||||
|
||||
#define CEDRUS_FORMATS_COUNT ARRAY_SIZE(cedrus_formats)
|
||||
|
||||
static inline struct cedrus_ctx *cedrus_file2ctx(struct file *file)
|
||||
{
|
||||
return container_of(file->private_data, struct cedrus_ctx, fh);
|
||||
}
|
||||
|
||||
static struct cedrus_format *cedrus_find_format(struct cedrus_ctx *ctx,
|
||||
u32 pixelformat, u32 directions)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user