From patchwork Tue Feb 13 22:08:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 10217661 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 474AE6055C for ; Tue, 13 Feb 2018 22:09:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3131028B4D for ; Tue, 13 Feb 2018 22:09:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2591D28CB3; Tue, 13 Feb 2018 22:09:12 +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 autolearn=unavailable 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 CB57728B4D for ; Tue, 13 Feb 2018 22:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965944AbeBMWJK (ORCPT ); Tue, 13 Feb 2018 17:09:10 -0500 Received: from vsp-unauthed02.binero.net ([195.74.38.227]:29325 "EHLO bin-vsp-out-03.atm.binero.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965900AbeBMWJJ (ORCPT ); Tue, 13 Feb 2018 17:09:09 -0500 X-Halon-ID: 7c7e935a-110a-11e8-875e-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 7c7e935a-110a-11e8-875e-0050569116f7; Tue, 13 Feb 2018 23:09:05 +0100 (CET) From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: Mauro Carvalho Chehab , Laurent Pinchart , Hans Verkuil , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH] videodev2.h: add helper to validate colorspace Date: Tue, 13 Feb 2018 23:08:47 +0100 Message-Id: <20180213220847.10856-1-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.16.1 MIME-Version: 1.0 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 There is no way for drivers to validate a colorspace value, which could be provided by user-space by VIDIOC_S_FMT for example. Add a helper to validate that the colorspace value is part of enum v4l2_colorspace. Signed-off-by: Niklas Söderlund --- include/uapi/linux/videodev2.h | 5 +++++ 1 file changed, 5 insertions(+) Hi, I hope this is the correct header to add this helper to. I think it's since if it's in uapi not only can v4l2 drivers use it but tools like v4l-compliance gets access to it and can be updated to use this instead of the hard-coded check of just < 0xff as it was last time I checked. // Niklas diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 9827189651801e12..843afd7c5b000553 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -238,6 +238,11 @@ enum v4l2_colorspace { V4L2_COLORSPACE_DCI_P3 = 12, }; +/* Determine if a colorspace is defined in enum v4l2_colorspace */ +#define V4L2_COLORSPACE_IS_VALID(colorspace) \ + (((colorspace) >= V4L2_COLORSPACE_DEFAULT) && \ + ((colorspace) <= V4L2_COLORSPACE_DCI_P3)) + /* * Determine how COLORSPACE_DEFAULT should map to a proper colorspace. * This depends on whether this is a SDTV image (use SMPTE 170M), an