]> www.infradead.org Git - users/hch/misc.git/commitdiff
media: s5p-mfc: Store s5p_mfc_ctx in vb2_queue.drv_priv
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Sun, 10 Aug 2025 01:30:39 +0000 (04:30 +0300)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 13 Aug 2025 06:33:53 +0000 (08:33 +0200)
The driver stores a pointer to a v4l2_fh in the vb2_queue.drv_priv,
which it then has to cast to a s5p_mfc_ctx pointer in all vb2 queue
operations. Store the pointer to the s5p_mfc_ctx instead to avoid the
cast. While at it, use the vb2_get_drv_priv() helper to access the
field.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c

index a5e756049620cdf35df4526b9a4cb55985f6476e..4948d734eb02c97a55526cddfa42844632b93bbd 100644 (file)
@@ -876,7 +876,7 @@ static int s5p_mfc_open(struct file *file)
        /* Init videobuf2 queue for CAPTURE */
        q = &ctx->vq_dst;
        q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
-       q->drv_priv = &ctx->fh;
+       q->drv_priv = ctx;
        q->lock = &dev->mfc_mutex;
        if (vdev == dev->vfd_dec) {
                q->io_modes = VB2_MMAP;
@@ -903,7 +903,7 @@ static int s5p_mfc_open(struct file *file)
        /* Init videobuf2 queue for OUTPUT */
        q = &ctx->vq_src;
        q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
-       q->drv_priv = &ctx->fh;
+       q->drv_priv = ctx;
        q->lock = &dev->mfc_mutex;
        if (vdev == dev->vfd_dec) {
                q->io_modes = VB2_MMAP;
index 3efbc336790629425c2a71e9feee8f073db55790..aefa6da5c609621c896f1fa14fd53b75ca60eabc 100644 (file)
@@ -937,7 +937,7 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
                        unsigned int *plane_count, unsigned int psize[],
                        struct device *alloc_devs[])
 {
-       struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+       struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
        struct s5p_mfc_dev *dev = ctx->dev;
        const struct v4l2_format_info *format;
 
@@ -1006,7 +1006,7 @@ static int s5p_mfc_buf_init(struct vb2_buffer *vb)
 {
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct vb2_queue *vq = vb->vb2_queue;
-       struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+       struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
        unsigned int i;
 
        if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
@@ -1068,7 +1068,7 @@ static int s5p_mfc_buf_init(struct vb2_buffer *vb)
 
 static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
 {
-       struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv);
+       struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(q);
        struct s5p_mfc_dev *dev = ctx->dev;
 
        v4l2_ctrl_handler_setup(&ctx->ctrl_handler);
@@ -1085,7 +1085,7 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
 static void s5p_mfc_stop_streaming(struct vb2_queue *q)
 {
        unsigned long flags;
-       struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv);
+       struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(q);
        struct s5p_mfc_dev *dev = ctx->dev;
        int aborted = 0;
 
@@ -1130,7 +1130,7 @@ static void s5p_mfc_stop_streaming(struct vb2_queue *q)
 static void s5p_mfc_buf_queue(struct vb2_buffer *vb)
 {
        struct vb2_queue *vq = vb->vb2_queue;
-       struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+       struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
        struct s5p_mfc_dev *dev = ctx->dev;
        unsigned long flags;
        struct s5p_mfc_buf *mfc_buf;
index 6c603dcd56649fcabe161173c64b9ea8bd055b93..9b77dbd856e7935c186f52ac21162e7d8bb2a215 100644 (file)
@@ -2418,7 +2418,7 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq,
                        unsigned int *buf_count, unsigned int *plane_count,
                        unsigned int psize[], struct device *alloc_devs[])
 {
-       struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+       struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
        struct s5p_mfc_dev *dev = ctx->dev;
 
        if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
@@ -2477,7 +2477,7 @@ static int s5p_mfc_buf_init(struct vb2_buffer *vb)
 {
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct vb2_queue *vq = vb->vb2_queue;
-       struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+       struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
        unsigned int i;
        int ret;
 
@@ -2516,7 +2516,7 @@ static int s5p_mfc_buf_init(struct vb2_buffer *vb)
 static int s5p_mfc_buf_prepare(struct vb2_buffer *vb)
 {
        struct vb2_queue *vq = vb->vb2_queue;
-       struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+       struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
        int ret;
 
        if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
@@ -2557,7 +2557,7 @@ static int s5p_mfc_buf_prepare(struct vb2_buffer *vb)
 
 static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
 {
-       struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv);
+       struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(q);
        struct s5p_mfc_dev *dev = ctx->dev;
 
        if (IS_MFCV6_PLUS(dev) &&
@@ -2588,7 +2588,7 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count)
 static void s5p_mfc_stop_streaming(struct vb2_queue *q)
 {
        unsigned long flags;
-       struct s5p_mfc_ctx *ctx = fh_to_ctx(q->drv_priv);
+       struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(q);
        struct s5p_mfc_dev *dev = ctx->dev;
 
        if ((ctx->state == MFCINST_FINISHING ||
@@ -2617,7 +2617,7 @@ static void s5p_mfc_stop_streaming(struct vb2_queue *q)
 static void s5p_mfc_buf_queue(struct vb2_buffer *vb)
 {
        struct vb2_queue *vq = vb->vb2_queue;
-       struct s5p_mfc_ctx *ctx = fh_to_ctx(vq->drv_priv);
+       struct s5p_mfc_ctx *ctx = vb2_get_drv_priv(vq);
        struct s5p_mfc_dev *dev = ctx->dev;
        unsigned long flags;
        struct s5p_mfc_buf *mfc_buf;