Skip to content

Commit 54bec07

Browse files
6by9popcornmix
authored andcommitted
staging: bcm2835-codec: Correct g/s_selection API MPLANE support
The g_selection and s_selection API is messed up and requires the driver to expect the non-MPLANE buffer types, not the MPLANE ones even if they are supported. The V4L2 core will convert the MPLANE ones to non-MPLANE should they be passed in Fixes: 5e484a3 staging: bcm2835-codec: switch to multi-planar API Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
1 parent 601e6db commit 54bec07

1 file changed

Lines changed: 47 additions & 20 deletions

File tree

‎drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c‎

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,17 +1260,30 @@ static int vidioc_g_selection(struct file *file, void *priv,
12601260
{
12611261
struct bcm2835_codec_ctx *ctx = file2ctx(file);
12621262
struct bcm2835_codec_q_data *q_data;
1263-
bool capture_queue = s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ?
1264-
true : false;
12651263

1266-
if ((ctx->dev->role == DECODE && !capture_queue) ||
1267-
(ctx->dev->role == ENCODE && capture_queue))
1268-
/* OUTPUT on decoder and CAPTURE on encoder are not valid. */
1269-
return -EINVAL;
1270-
1271-
q_data = get_q_data(ctx, s->type);
1272-
if (!q_data)
1264+
/*
1265+
* The selection API takes V4L2_BUF_TYPE_VIDEO_CAPTURE and
1266+
* V4L2_BUF_TYPE_VIDEO_OUTPUT, even if the device implements the MPLANE
1267+
* API. The V4L2 core will have converted the MPLANE variants to
1268+
* non-MPLANE.
1269+
* Open code this instead of using get_q_data in this case.
1270+
*/
1271+
switch (s->type) {
1272+
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1273+
/* CAPTURE on encoder is not valid. */
1274+
if (ctx->dev->role == ENCODE)
1275+
return -EINVAL;
1276+
q_data = &ctx->q_data[V4L2_M2M_DST];
1277+
break;
1278+
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
1279+
/* OUTPUT on deoder is not valid. */
1280+
if (ctx->dev->role == DECODE)
1281+
return -EINVAL;
1282+
q_data = &ctx->q_data[V4L2_M2M_SRC];
1283+
break;
1284+
default:
12731285
return -EINVAL;
1286+
}
12741287

12751288
switch (ctx->dev->role) {
12761289
case DECODE:
@@ -1323,22 +1336,36 @@ static int vidioc_s_selection(struct file *file, void *priv,
13231336
{
13241337
struct bcm2835_codec_ctx *ctx = file2ctx(file);
13251338
struct bcm2835_codec_q_data *q_data = NULL;
1326-
bool capture_queue = s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ?
1327-
true : false;
1339+
1340+
/*
1341+
* The selection API takes V4L2_BUF_TYPE_VIDEO_CAPTURE and
1342+
* V4L2_BUF_TYPE_VIDEO_OUTPUT, even if the device implements the MPLANE
1343+
* API. The V4L2 core will have converted the MPLANE variants to
1344+
* non-MPLANE.
1345+
*
1346+
* Open code this instead of using get_q_data in this case.
1347+
*/
1348+
switch (s->type) {
1349+
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1350+
/* CAPTURE on encoder is not valid. */
1351+
if (ctx->dev->role == ENCODE)
1352+
return -EINVAL;
1353+
q_data = &ctx->q_data[V4L2_M2M_DST];
1354+
break;
1355+
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
1356+
/* OUTPUT on deoder is not valid. */
1357+
if (ctx->dev->role == DECODE)
1358+
return -EINVAL;
1359+
q_data = &ctx->q_data[V4L2_M2M_SRC];
1360+
break;
1361+
default:
1362+
return -EINVAL;
1363+
}
13281364

13291365
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",
13301366
__func__, ctx, s->type, q_data, s->target, s->r.left, s->r.top,
13311367
s->r.width, s->r.height);
13321368

1333-
if ((ctx->dev->role == DECODE && !capture_queue) ||
1334-
(ctx->dev->role == ENCODE && capture_queue))
1335-
/* OUTPUT on decoder and CAPTURE on encoder are not valid. */
1336-
return -EINVAL;
1337-
1338-
q_data = get_q_data(ctx, s->type);
1339-
if (!q_data)
1340-
return -EINVAL;
1341-
13421369
switch (ctx->dev->role) {
13431370
case DECODE:
13441371
switch (s->target) {

0 commit comments

Comments
 (0)