1 From 956fd55c1071c48f00285d82507698c501633e7a Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Fri, 13 Sep 2019 15:11:47 +0100
4 Subject: [PATCH] staging: bcm2835-codec: Correct g/s_selection API
7 The g_selection and s_selection API is messed up and requires
8 the driver to expect the non-MPLANE buffer types, not the MPLANE
9 ones even if they are supported. The V4L2 core will convert the
10 MPLANE ones to non-MPLANE should they be passed in
12 Fixes: 5e484a3 staging: bcm2835-codec: switch to multi-planar API
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
15 .../bcm2835-codec/bcm2835-v4l2-codec.c | 67 +++++++++++++------
16 1 file changed, 47 insertions(+), 20 deletions(-)
18 --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
19 +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
20 @@ -1260,17 +1260,30 @@ static int vidioc_g_selection(struct fil
22 struct bcm2835_codec_ctx *ctx = file2ctx(file);
23 struct bcm2835_codec_q_data *q_data;
24 - bool capture_queue = s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ?
27 - if ((ctx->dev->role == DECODE && !capture_queue) ||
28 - (ctx->dev->role == ENCODE && capture_queue))
29 - /* OUTPUT on decoder and CAPTURE on encoder are not valid. */
32 - q_data = get_q_data(ctx, s->type);
35 + * The selection API takes V4L2_BUF_TYPE_VIDEO_CAPTURE and
36 + * V4L2_BUF_TYPE_VIDEO_OUTPUT, even if the device implements the MPLANE
37 + * API. The V4L2 core will have converted the MPLANE variants to
39 + * Open code this instead of using get_q_data in this case.
42 + case V4L2_BUF_TYPE_VIDEO_CAPTURE:
43 + /* CAPTURE on encoder is not valid. */
44 + if (ctx->dev->role == ENCODE)
46 + q_data = &ctx->q_data[V4L2_M2M_DST];
48 + case V4L2_BUF_TYPE_VIDEO_OUTPUT:
49 + /* OUTPUT on deoder is not valid. */
50 + if (ctx->dev->role == DECODE)
52 + q_data = &ctx->q_data[V4L2_M2M_SRC];
58 switch (ctx->dev->role) {
60 @@ -1323,22 +1336,36 @@ static int vidioc_s_selection(struct fil
62 struct bcm2835_codec_ctx *ctx = file2ctx(file);
63 struct bcm2835_codec_q_data *q_data = NULL;
64 - bool capture_queue = s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ?
68 + * The selection API takes V4L2_BUF_TYPE_VIDEO_CAPTURE and
69 + * V4L2_BUF_TYPE_VIDEO_OUTPUT, even if the device implements the MPLANE
70 + * API. The V4L2 core will have converted the MPLANE variants to
73 + * Open code this instead of using get_q_data in this case.
76 + case V4L2_BUF_TYPE_VIDEO_CAPTURE:
77 + /* CAPTURE on encoder is not valid. */
78 + if (ctx->dev->role == ENCODE)
80 + q_data = &ctx->q_data[V4L2_M2M_DST];
82 + case V4L2_BUF_TYPE_VIDEO_OUTPUT:
83 + /* OUTPUT on deoder is not valid. */
84 + if (ctx->dev->role == DECODE)
86 + q_data = &ctx->q_data[V4L2_M2M_SRC];
92 v4l2_dbg(1, debug, &ctx->dev->v4l2_dev, "%s: ctx %p, type %d, q_data %p, target %d, rect x/y %d/%d, w/h %ux%u\n",
93 __func__, ctx, s->type, q_data, s->target, s->r.left, s->r.top,
94 s->r.width, s->r.height);
96 - if ((ctx->dev->role == DECODE && !capture_queue) ||
97 - (ctx->dev->role == ENCODE && capture_queue))
98 - /* OUTPUT on decoder and CAPTURE on encoder are not valid. */
101 - q_data = get_q_data(ctx, s->type);
105 switch (ctx->dev->role) {