5eb5068538796694291d09a17ff8d84758af9514
[openwrt/staging/blogic.git] /
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 801/806] staging: bcm2835-codec: Correct g/s_selection API
5 MPLANE support
6
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
11
12 Fixes: 5e484a3 staging: bcm2835-codec: switch to multi-planar API
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
14 ---
15 .../bcm2835-codec/bcm2835-v4l2-codec.c | 67 +++++++++++++------
16 1 file changed, 47 insertions(+), 20 deletions(-)
17
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
21 {
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 ?
25 - true : false;
26
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. */
30 - return -EINVAL;
31 -
32 - q_data = get_q_data(ctx, s->type);
33 - if (!q_data)
34 + /*
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
38 + * non-MPLANE.
39 + * Open code this instead of using get_q_data in this case.
40 + */
41 + switch (s->type) {
42 + case V4L2_BUF_TYPE_VIDEO_CAPTURE:
43 + /* CAPTURE on encoder is not valid. */
44 + if (ctx->dev->role == ENCODE)
45 + return -EINVAL;
46 + q_data = &ctx->q_data[V4L2_M2M_DST];
47 + break;
48 + case V4L2_BUF_TYPE_VIDEO_OUTPUT:
49 + /* OUTPUT on deoder is not valid. */
50 + if (ctx->dev->role == DECODE)
51 + return -EINVAL;
52 + q_data = &ctx->q_data[V4L2_M2M_SRC];
53 + break;
54 + default:
55 return -EINVAL;
56 + }
57
58 switch (ctx->dev->role) {
59 case DECODE:
60 @@ -1323,22 +1336,36 @@ static int vidioc_s_selection(struct fil
61 {
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 ?
65 - true : false;
66 +
67 + /*
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
71 + * non-MPLANE.
72 + *
73 + * Open code this instead of using get_q_data in this case.
74 + */
75 + switch (s->type) {
76 + case V4L2_BUF_TYPE_VIDEO_CAPTURE:
77 + /* CAPTURE on encoder is not valid. */
78 + if (ctx->dev->role == ENCODE)
79 + return -EINVAL;
80 + q_data = &ctx->q_data[V4L2_M2M_DST];
81 + break;
82 + case V4L2_BUF_TYPE_VIDEO_OUTPUT:
83 + /* OUTPUT on deoder is not valid. */
84 + if (ctx->dev->role == DECODE)
85 + return -EINVAL;
86 + q_data = &ctx->q_data[V4L2_M2M_SRC];
87 + break;
88 + default:
89 + return -EINVAL;
90 + }
91
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);
95
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. */
99 - return -EINVAL;
100 -
101 - q_data = get_q_data(ctx, s->type);
102 - if (!q_data)
103 - return -EINVAL;
104 -
105 switch (ctx->dev->role) {
106 case DECODE:
107 switch (s->target) {