mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 09:20:13 -04:00
media: s5p-mfc: Access v4l2_fh from file
The v4l2_fh associated with an open file handle is now guaranteed to be available in file->private_data, initialised by v4l2_fh_add(). Access the v4l2_fh, and from there the driver-specific structure, from the file * in all ioctl handlers. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
committed by
Hans Verkuil
parent
4df43d4997
commit
fede1dac71
@@ -767,11 +767,9 @@ struct mfc_control {
|
||||
#define s5p_mfc_hw_call(f, op, args...) \
|
||||
((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));
|
||||
return container_of(file_to_v4l2_fh(filp), struct s5p_mfc_ctx, fh);
|
||||
}
|
||||
|
||||
#define ctrl_to_ctx(__ctrl) \
|
||||
|
||||
@@ -345,7 +345,7 @@ static int vidioc_enum_fmt_vid_out(struct file *file, void *priv,
|
||||
/* Get format */
|
||||
static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
struct v4l2_pix_format_mplane *pix_mp;
|
||||
|
||||
mfc_debug_enter();
|
||||
@@ -442,7 +442,7 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
|
||||
static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
|
||||
{
|
||||
struct s5p_mfc_dev *dev = video_drvdata(file);
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
int ret = 0;
|
||||
struct v4l2_pix_format_mplane *pix_mp;
|
||||
const struct s5p_mfc_buf_size *buf_size = dev->variant->buf_size;
|
||||
@@ -598,7 +598,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
|
||||
struct v4l2_requestbuffers *reqbufs)
|
||||
{
|
||||
struct s5p_mfc_dev *dev = video_drvdata(file);
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
if (reqbufs->memory != V4L2_MEMORY_MMAP) {
|
||||
mfc_debug(2, "Only V4L2_MEMORY_MMAP is supported\n");
|
||||
@@ -619,7 +619,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
|
||||
static int vidioc_querybuf(struct file *file, void *priv,
|
||||
struct v4l2_buffer *buf)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
@@ -647,7 +647,7 @@ static int vidioc_querybuf(struct file *file, void *priv,
|
||||
/* Queue a buffer */
|
||||
static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
if (ctx->state == MFCINST_ERROR) {
|
||||
mfc_err("Call on QBUF after unrecoverable error\n");
|
||||
@@ -666,7 +666,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
|
||||
const struct v4l2_event ev = {
|
||||
.type = V4L2_EVENT_EOS
|
||||
};
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
int ret;
|
||||
|
||||
if (ctx->state == MFCINST_ERROR) {
|
||||
@@ -695,7 +695,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
|
||||
static int vidioc_expbuf(struct file *file, void *priv,
|
||||
struct v4l2_exportbuffer *eb)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
if (eb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
|
||||
return vb2_expbuf(&ctx->vq_src, eb);
|
||||
@@ -708,7 +708,7 @@ static int vidioc_expbuf(struct file *file, void *priv,
|
||||
static int vidioc_streamon(struct file *file, void *priv,
|
||||
enum v4l2_buf_type type)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
int ret = -EINVAL;
|
||||
|
||||
mfc_debug_enter();
|
||||
@@ -724,7 +724,7 @@ static int vidioc_streamon(struct file *file, void *priv,
|
||||
static int vidioc_streamoff(struct file *file, void *priv,
|
||||
enum v4l2_buf_type type)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
|
||||
return vb2_streamoff(&ctx->vq_src, type);
|
||||
@@ -801,7 +801,7 @@ static const struct v4l2_ctrl_ops s5p_mfc_dec_ctrl_ops = {
|
||||
static int vidioc_g_selection(struct file *file, void *priv,
|
||||
struct v4l2_selection *s)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
struct s5p_mfc_dev *dev = ctx->dev;
|
||||
u32 left, right, top, bottom;
|
||||
u32 width, height;
|
||||
@@ -856,7 +856,7 @@ static int vidioc_g_selection(struct file *file, void *priv,
|
||||
static int vidioc_decoder_cmd(struct file *file, void *priv,
|
||||
struct v4l2_decoder_cmd *cmd)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
struct s5p_mfc_dev *dev = ctx->dev;
|
||||
struct s5p_mfc_buf *buf;
|
||||
unsigned long flags;
|
||||
|
||||
@@ -1389,8 +1389,8 @@ static int vidioc_enum_fmt_vid_out(struct file *file, void *priv,
|
||||
|
||||
static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
mfc_debug(2, "f->type = %d ctx->state = %d\n", f->type, ctx->state);
|
||||
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
|
||||
@@ -1472,8 +1472,8 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
|
||||
|
||||
static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
struct s5p_mfc_dev *dev = video_drvdata(file);
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
|
||||
int ret = 0;
|
||||
|
||||
@@ -1531,7 +1531,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
|
||||
struct v4l2_requestbuffers *reqbufs)
|
||||
{
|
||||
struct s5p_mfc_dev *dev = video_drvdata(file);
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
int ret = 0;
|
||||
|
||||
/* if memory is not mmp or userptr or dmabuf return error */
|
||||
@@ -1601,7 +1601,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
|
||||
static int vidioc_querybuf(struct file *file, void *priv,
|
||||
struct v4l2_buffer *buf)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
int ret = 0;
|
||||
|
||||
/* if memory is not mmp or userptr or dmabuf return error */
|
||||
@@ -1636,7 +1636,7 @@ static int vidioc_querybuf(struct file *file, void *priv,
|
||||
/* Queue a buffer */
|
||||
static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
if (ctx->state == MFCINST_ERROR) {
|
||||
mfc_err("Call on QBUF after unrecoverable error\n");
|
||||
@@ -1657,10 +1657,10 @@ static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
|
||||
/* Dequeue a buffer */
|
||||
static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
const struct v4l2_event ev = {
|
||||
.type = V4L2_EVENT_EOS
|
||||
};
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
int ret;
|
||||
|
||||
if (ctx->state == MFCINST_ERROR) {
|
||||
@@ -1685,7 +1685,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
|
||||
static int vidioc_expbuf(struct file *file, void *priv,
|
||||
struct v4l2_exportbuffer *eb)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
if (eb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
|
||||
return vb2_expbuf(&ctx->vq_src, eb);
|
||||
@@ -1698,7 +1698,7 @@ static int vidioc_expbuf(struct file *file, void *priv,
|
||||
static int vidioc_streamon(struct file *file, void *priv,
|
||||
enum v4l2_buf_type type)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
|
||||
return vb2_streamon(&ctx->vq_src, type);
|
||||
@@ -1711,7 +1711,7 @@ static int vidioc_streamon(struct file *file, void *priv,
|
||||
static int vidioc_streamoff(struct file *file, void *priv,
|
||||
enum v4l2_buf_type type)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
|
||||
return vb2_streamoff(&ctx->vq_src, type);
|
||||
@@ -2284,7 +2284,7 @@ static const struct v4l2_ctrl_ops s5p_mfc_enc_ctrl_ops = {
|
||||
static int vidioc_s_parm(struct file *file, void *priv,
|
||||
struct v4l2_streamparm *a)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
if (a->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
|
||||
ctx->enc_params.rc_framerate_num =
|
||||
@@ -2301,7 +2301,7 @@ static int vidioc_s_parm(struct file *file, void *priv,
|
||||
static int vidioc_g_parm(struct file *file, void *priv,
|
||||
struct v4l2_streamparm *a)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
|
||||
if (a->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
|
||||
a->parm.output.timeperframe.denominator =
|
||||
@@ -2318,7 +2318,7 @@ static int vidioc_g_parm(struct file *file, void *priv,
|
||||
static int vidioc_encoder_cmd(struct file *file, void *priv,
|
||||
struct v4l2_encoder_cmd *cmd)
|
||||
{
|
||||
struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
|
||||
struct s5p_mfc_ctx *ctx = file_to_ctx(file);
|
||||
struct s5p_mfc_dev *dev = ctx->dev;
|
||||
struct s5p_mfc_buf *buf;
|
||||
unsigned long flags;
|
||||
|
||||
Reference in New Issue
Block a user