Skip to contentSkip to conversation

media: vicodec: selection api should not care about signal/multiplanar

PATCH In review Dafna Hirschfeld 2 participants 2 messages Feb 19, 2019 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: vicodec: selection api should not care about signal/multiplanar

Change the selection api to always accept both signal and multiplanar buffer types.

---
 drivers/media/platform/vicodec/vicodec-core.c | 25 +++++++------------
 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/media/platform/vicodec/vicodec-core.c +9 -16
index d7636fe9e174..12692aa101fe 100644
@@ -945,16 +945,12 @@ static int vidioc_g_selection(struct file *file, void *priv,
 {
 	struct vicodec_ctx *ctx = file2ctx(file);
 	struct vicodec_q_data *q_data;
-	enum v4l2_buf_type valid_cap_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-	enum v4l2_buf_type valid_out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+	v4l2_buf_type sec_type = s->type;
 
-	if (multiplanar) {
-		valid_cap_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
-		valid_out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
-	}
-
-	if (s->type != valid_cap_type && s->type != valid_out_type)
-		return -EINVAL;
+	if (sec_type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+		sec_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+	if (sec_type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
+		sec_type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
 
 	q_data = get_q_data(ctx, s->type);
 	if (!q_data)
@@ -963,8 +959,8 @@ static int vidioc_g_selection(struct file *file, void *priv,
 	 * encoder supports only cropping on the OUTPUT buffer
 	 * decoder supports only composing on the CAPTURE buffer
 	 */
-	if ((ctx->is_enc && s->type == valid_out_type) ||
-	    (!ctx->is_enc && s->type == valid_cap_type)) {
+	if ((ctx->is_enc && sec_type == V4L2_BUF_TYPE_VIDEO_OUTPUT) ||
+	    (!ctx->is_enc && sec_type == V4L2_BUF_TYPE_VIDEO_CAPTURE)) {
 		switch (s->target) {
 		case V4L2_SEL_TGT_COMPOSE:
 		case V4L2_SEL_TGT_CROP:
@@ -992,12 +988,9 @@ static int vidioc_s_selection(struct file *file, void *priv,
 {
 	struct vicodec_ctx *ctx = file2ctx(file);
 	struct vicodec_q_data *q_data;
-	enum v4l2_buf_type out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-
-	if (multiplanar)
-		out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
 
-	if (s->type != out_type)
+	if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
+	    s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
 		return -EINVAL;
 
 	q_data = get_q_data(ctx, s->type);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 21 lines · Dafna Hirschfeld

Change the selection api to always accept both signal and multiplanar buffer types.

---
 drivers/media/platform/vicodec/vicodec-core.c | 25 +++++++------------
 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/media/platform/vicodec/vicodec-core.c +1 -3
index d7636fe9e174..12692aa101fe 100644
@@ -945,16 +945,12 @@ static int vidioc_g_selection(struct file *file, void *priv,
 {
 	struct vicodec_ctx *ctx = file2ctx(file);
 	struct vicodec_q_data *q_data;
-	enum v4l2_buf_type valid_cap_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-	enum v4l2_buf_type valid_out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+	v4l2_buf_type sec_type = s->type;
 
-	if (multiplanar) {

drivers/media/platform/vicodec/vicodec-core.c static int vidioc_g_selection(struct file *file, void *priv, · line 953

Quoted 10 lines
drivers/media/platform/vicodec/vicodec-core.c +4 -6
-		valid_cap_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
-		valid_out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
-	}
-
-	if (s->type != valid_cap_type && s->type != valid_out_type)
-		return -EINVAL;
+	if (sec_type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
+		sec_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+	if (sec_type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
+		sec_type = V4L2_BUF_TYPE_VIDEO_OUTPUT;

I don't think you'll ever get an _MPLANE type. See v4l_g_selection in drivers/media/v4l2-core/v4l2-ioctl.c.

So these four lines can be removed.

Quoted 16 lines
drivers/media/platform/vicodec/vicodec-core.c +2 -2
 	q_data = get_q_data(ctx, s->type);
 	if (!q_data)
@@ -963,8 +959,8 @@ static int vidioc_g_selection(struct file *file, void *priv,
 	 * encoder supports only cropping on the OUTPUT buffer
 	 * decoder supports only composing on the CAPTURE buffer
 	 */
-	if ((ctx->is_enc && s->type == valid_out_type) ||
-	    (!ctx->is_enc && s->type == valid_cap_type)) {
+	if ((ctx->is_enc && sec_type == V4L2_BUF_TYPE_VIDEO_OUTPUT) ||
+	    (!ctx->is_enc && sec_type == V4L2_BUF_TYPE_VIDEO_CAPTURE)) {
 		switch (s->target) {
 		case V4L2_SEL_TGT_COMPOSE:
 		case V4L2_SEL_TGT_CROP:
@@ -992,12 +988,9 @@ static int vidioc_s_selection(struct file *file, void *priv,
 {

drivers/media/platform/vicodec/vicodec-core.c static int vidioc_s_selection(struct file *file, void *priv, · line 993

Quoted 10 lines
drivers/media/platform/vicodec/vicodec-core.c +2 -5
 	struct vicodec_ctx *ctx = file2ctx(file);
 	struct vicodec_q_data *q_data;
-	enum v4l2_buf_type out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-
-	if (multiplanar)
-		out_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
 
-	if (s->type != out_type)
+	if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
+	    s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)

Same here, MPLANE is never used.

drivers/media/platform/vicodec/vicodec-core.c static int vidioc_s_selection(struct file *file, void *priv, · line 996

Quoted 4 lines
drivers/media/platform/vicodec/vicodec-core.c +0 -0
 		return -EINVAL;
 
 	q_data = get_q_data(ctx, s->type);

Regards,

Hans