From patchwork Tue May 30 19:08:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helen Mae Koike Fornazier X-Patchwork-Id: 9755161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0CDBF601D2 for ; Tue, 30 May 2017 19:08:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E930827CEA for ; Tue, 30 May 2017 19:08:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA83928294; Tue, 30 May 2017 19:08:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D86827CEA for ; Tue, 30 May 2017 19:08:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750871AbdE3TIh (ORCPT ); Tue, 30 May 2017 15:08:37 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:49935 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750821AbdE3TIg (ORCPT ); Tue, 30 May 2017 15:08:36 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: koike) with ESMTPSA id C2E27260387 From: Helen Koike To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [RFC PATCH] [media] v4l2-subdev: check colorimetry in link validate Date: Tue, 30 May 2017 16:08:08 -0300 Message-Id: <1496171288-28656-1-git-send-email-helen.koike@collabora.com> X-Mailer: git-send-email 2.7.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP colorspace, ycbcr_enc, quantization and xfer_func must match across the link. Check if they match in v4l2_subdev_link_validate_default unless they are set as _DEFAULT. Signed-off-by: Helen Koike --- Hi, I think we should validate colorimetry as having different colorimetry across a link doesn't make sense. But I am confused about what to do when they are set to _DEFAULT, what do you think? Thanks --- drivers/media/v4l2-core/v4l2-subdev.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index da78497..784ae92 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -502,10 +502,27 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd, struct v4l2_subdev_format *source_fmt, struct v4l2_subdev_format *sink_fmt) { - /* The width, height and code must match. */ + /* The width, height, code and colorspace must match. */ if (source_fmt->format.width != sink_fmt->format.width || source_fmt->format.height != sink_fmt->format.height - || source_fmt->format.code != sink_fmt->format.code) + || source_fmt->format.code != sink_fmt->format.code + || source_fmt->format.colorspace != sink_fmt->format.colorspace) + return -EPIPE; + + /* Colorimetry must match if they are not set to DEFAULT */ + if (source_fmt->format.ycbcr_enc != V4L2_YCBCR_ENC_DEFAULT + && sink_fmt->format.ycbcr_enc != V4L2_YCBCR_ENC_DEFAULT + && source_fmt->format.ycbcr_enc != sink_fmt->format.ycbcr_enc) + return -EPIPE; + + if (source_fmt->format.quantization != V4L2_QUANTIZATION_DEFAULT + && sink_fmt->format.quantization != V4L2_QUANTIZATION_DEFAULT + && source_fmt->format.quantization != sink_fmt->format.quantization) + return -EPIPE; + + if (source_fmt->format.xfer_func != V4L2_XFER_FUNC_DEFAULT + && sink_fmt->format.xfer_func != V4L2_XFER_FUNC_DEFAULT + && source_fmt->format.xfer_func != sink_fmt->format.xfer_func) return -EPIPE; /* The field order must match, or the sink field order must be NONE