static int stateful_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
struct vb2_queue *src_vq, *dst_vq;
int ret;
static int stateless_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
int ret;
ret = v4l2_m2m_ioctl_stateless_try_decoder_cmd(file, priv, cmd);
static int vidioc_try_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
if (ctx->dev->vdec_pdata->uses_stateless_api)
return stateless_try_decoder_cmd(file, priv, cmd);
static int vidioc_decoder_cmd(struct file *file, void *priv, struct v4l2_decoder_cmd *cmd)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
if (ctx->dev->vdec_pdata->uses_stateless_api)
return stateless_decoder_cmd(file, priv, cmd);
static int vidioc_vdec_qbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
if (ctx->state == MTK_STATE_ABORT) {
mtk_v4l2_vdec_err(ctx, "[%d] Call on QBUF after unrecoverable error", ctx->id);
static int vidioc_vdec_dqbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
if (ctx->state == MTK_STATE_ABORT) {
mtk_v4l2_vdec_err(ctx, "[%d] Call on DQBUF after unrecoverable error", ctx->id);
static int vidioc_vdec_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
struct device *dev = &ctx->dev->plat_dev->dev;
strscpy(cap->driver, dev->driver->name, sizeof(cap->driver));
struct v4l2_format *f)
{
const struct mtk_video_fmt *fmt;
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata;
fmt = mtk_vdec_find_format(f, dec_pdata);
{
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
const struct mtk_video_fmt *fmt;
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata;
fmt = mtk_vdec_find_format(f, dec_pdata);
static int vidioc_vdec_g_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
struct mtk_q_data *q_data;
if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
static int vidioc_vdec_s_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
static int vidioc_vdec_s_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
struct v4l2_pix_format_mplane *pix_mp;
struct mtk_q_data *q_data;
int ret = 0;
struct v4l2_frmsizeenum *fsize)
{
int i = 0;
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata;
if (fsize->index != 0)
return -EINVAL;
}
-static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, void *priv,
+static int vidioc_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
bool output_queue)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata;
const struct mtk_video_fmt *fmt;
int i, j = 0;
static int vidioc_vdec_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- return vidioc_enum_fmt(f, priv, false);
+ return vidioc_enum_fmt(file, f, false);
}
static int vidioc_vdec_enum_fmt_vid_out(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
- return vidioc_enum_fmt(f, priv, true);
+ return vidioc_enum_fmt(file, f, true);
}
static int vidioc_vdec_g_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct mtk_vcodec_dec_ctx *ctx = fh_to_dec_ctx(priv);
+ struct mtk_vcodec_dec_ctx *ctx = file_to_dec_ctx(file);
struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp;
struct vb2_queue *vq;
struct mtk_q_data *q_data;
struct v4l2_frmsizeenum *fsize)
{
const struct mtk_video_fmt *fmt;
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(fh);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
if (fsize->index != 0)
return -EINVAL;
struct v4l2_fmtdesc *f)
{
const struct mtk_vcodec_enc_pdata *pdata =
- fh_to_enc_ctx(priv)->dev->venc_pdata;
+ file_to_enc_ctx(file)->dev->venc_pdata;
return vidioc_enum_fmt(f, pdata->capture_formats,
pdata->num_capture_formats);
struct v4l2_fmtdesc *f)
{
const struct mtk_vcodec_enc_pdata *pdata =
- fh_to_enc_ctx(priv)->dev->venc_pdata;
+ file_to_enc_ctx(file)->dev->venc_pdata;
return vidioc_enum_fmt(f, pdata->output_formats,
pdata->num_output_formats);
}
-static int mtk_vcodec_enc_get_chip_name(void *priv)
+static int mtk_vcodec_enc_get_chip_name(struct mtk_vcodec_enc_ctx *ctx)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
struct device *dev = &ctx->dev->plat_dev->dev;
if (of_device_is_compatible(dev->of_node, "mediatek,mt8173-vcodec-enc"))
static int vidioc_venc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
struct device *dev = &ctx->dev->plat_dev->dev;
- int platform_name = mtk_vcodec_enc_get_chip_name(priv);
+ int platform_name = mtk_vcodec_enc_get_chip_name(ctx);
strscpy(cap->driver, dev->driver->name, sizeof(cap->driver));
snprintf(cap->card, sizeof(cap->card), "MT%d video encoder", platform_name);
static int vidioc_venc_s_parm(struct file *file, void *priv,
struct v4l2_streamparm *a)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
struct v4l2_fract *timeperframe = &a->parm.output.timeperframe;
if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
static int vidioc_venc_g_parm(struct file *file, void *priv,
struct v4l2_streamparm *a)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
return -EINVAL;
static int vidioc_venc_s_fmt_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
const struct mtk_vcodec_enc_pdata *pdata = ctx->dev->venc_pdata;
struct vb2_queue *vq;
struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, f->type);
static int vidioc_venc_s_fmt_out(struct file *file, void *priv,
struct v4l2_format *f)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
const struct mtk_vcodec_enc_pdata *pdata = ctx->dev->venc_pdata;
struct vb2_queue *vq;
struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, f->type);
struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp;
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
struct vb2_queue *vq;
struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, f->type);
int i;
struct v4l2_format *f)
{
const struct mtk_video_fmt *fmt;
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
const struct mtk_vcodec_enc_pdata *pdata = ctx->dev->venc_pdata;
fmt = mtk_venc_find_format(f->fmt.pix.pixelformat, pdata);
struct v4l2_format *f)
{
const struct mtk_video_fmt *fmt;
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
const struct mtk_vcodec_enc_pdata *pdata = ctx->dev->venc_pdata;
fmt = mtk_venc_find_format(f->fmt.pix.pixelformat, pdata);
static int vidioc_venc_g_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, s->type);
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
static int vidioc_venc_s_selection(struct file *file, void *priv,
struct v4l2_selection *s)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
struct mtk_q_data *q_data = mtk_venc_get_q_data(ctx, s->type);
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
static int vidioc_venc_qbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
if (ctx->state == MTK_STATE_ABORT) {
mtk_v4l2_venc_err(ctx, "[%d] Call on QBUF after unrecoverable error",
static int vidioc_venc_dqbuf(struct file *file, void *priv,
struct v4l2_buffer *buf)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
int ret;
if (ctx->state == MTK_STATE_ABORT) {
static int vidioc_encoder_cmd(struct file *file, void *priv,
struct v4l2_encoder_cmd *cmd)
{
- struct mtk_vcodec_enc_ctx *ctx = fh_to_enc_ctx(priv);
+ struct mtk_vcodec_enc_ctx *ctx = file_to_enc_ctx(file);
struct vb2_queue *src_vq, *dst_vq;
int ret;
struct mtk_vcodec_dbgfs dbgfs;
};
-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));
+ return container_of(file_to_v4l2_fh(filp), struct mtk_vcodec_enc_ctx, fh);
}
static inline struct mtk_vcodec_enc_ctx *ctrl_to_enc_ctx(struct v4l2_ctrl *ctrl)