Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1836770ybt; Mon, 15 Jun 2020 10:37:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweDRW2xTxYEIBvmpwZoI40cjUCFzBKHx5d8gEqv6iqF4fhrEFtIRU6ql4v9MxLYeLONbgQ X-Received: by 2002:a17:906:7ac9:: with SMTP id k9mr6873866ejo.489.1592242635041; Mon, 15 Jun 2020 10:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592242635; cv=none; d=google.com; s=arc-20160816; b=KTElOEw9QTuWQu9/1TECMewYILE6nCDHvc7KSiS4e0grWakH/ScMfxRbcqF8WLbkn+ P5e61Ub+A755tufCVPR1uW7QXSD1Oprw2t8n4uso2h8/7VOEJ/8RtNg8Nre/tn4VFeO/ 569lvEWBpA8v0hKmX92aQ0b52xykbpYHPh3UsF9+oQqhLxAHB6TsZ/ReMD1fdwW1iJvv BeHNZxo0vEn4wCEOzxfED/U1jRAlAe+j3xMGr8zT2dafqb2DiJGGFG8W6tOxOkDJ+gph lcCS3JBbIOsA1mJfhIALahwmpegZS3oeXs1JT3G8BY6w8AMl5lIYtBoPNUsUDVj/+xgO kaIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:to:from:date:dkim-signature; bh=2ZLZlJpE9ABSNjpL4mZQFk3Irx9pVKzEY6qghcd2NoA=; b=FHSraQycoZIqklw837JF2pMbpxBsBcHDOyu95uZ2mu7RR6TW2KE4aQcuoaWjl3ZouR 8rIF0cpaQRyrCSoTbiXV+9VqPvcWnDXaLk5u1r2FUavTZ7rZGdLepU8O/4DXXEwQ7SPs 9haq07UHDxPaUJHLAbSjQOIyxoA+LnNgkpEgygtBoXEa+vFXJyaUOxFpmEBWfmmlwTn2 Wl3+UpkpO9XM7rlNOAr5wb6gA1GQdXT24K08MaCO4g3pJ59ORUGpvDG2giCx+x2I9Brd U91KgxAVojCXK+UWx0xEz9L5A/2DmTlJxj+WMJiiNPw3TeDg4IdCpTPEsw1upJilVuLS CBUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.s=20150623 header.b=MS7xahuA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=iitr.ac.in Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 17si10116976edw.300.2020.06.15.10.36.52; Mon, 15 Jun 2020 10:37:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.s=20150623 header.b=MS7xahuA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=iitr.ac.in Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731115AbgFORcV (ORCPT + 99 others); Mon, 15 Jun 2020 13:32:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728585AbgFORcU (ORCPT ); Mon, 15 Jun 2020 13:32:20 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2995C061A0E for ; Mon, 15 Jun 2020 10:32:20 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id m7so7073225plt.5 for ; Mon, 15 Jun 2020 10:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=2ZLZlJpE9ABSNjpL4mZQFk3Irx9pVKzEY6qghcd2NoA=; b=MS7xahuAXPifVMceikYAexMoBHjLCLpZjeeouIlKBwiHQU2ForT5LrpT8bdlC+hiLM nfqrqMm0qxuFBOQWGWLd6rjKWFcznPu41dwIAd59oyAAJzcVv4K9fAfXm8F2rZDc6FR6 wqXJMcTzwuWLkc4BdkPdOvBxqYI1jxphDUpEIhVUhW5oh9PkI6OIplFam40MOaajTX7+ pibStgBiwqHp2+od5g3I8EdaL5bipPngqcQDNxcA1Ago9jVmaDc0oP+KPVmDbneSz2dn NQh2ScecSde9JIZsUoOCkGl118dyauBVUcJFrBIOloPHFsr9UhcIXpm38az2hNCkHL3i xA0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=2ZLZlJpE9ABSNjpL4mZQFk3Irx9pVKzEY6qghcd2NoA=; b=N8sM8Jfgs7CHMW2KhOPZafmUmbfQeGp7AcB8iDPgpNGiA28jPiCfX2Z8Mqt81D/U3u wmjIbCYgpXNE0bGd511r2mh508sJQouc6cSyMy6nhrBmll55LuZujpo6q3dIrBp9hKw3 DAumeonIullz4tMDdp0sjre1VMsJt3sRWD6TL3D0/6Wzg4LmizZULLqOSepmA+fmijt7 9LkuEsG2O43vnwC2usTT0aIJIyLm3DoqdkiKW5NXOdl42/d5Eb4NVbqYU8fnkLtnWGVY B60lowi4Asol7abCnLktrK9JTEsINzsTerQ4uPseXW7zs2XnVcQmiE8Qx9CIqXu3abjM /CMA== X-Gm-Message-State: AOAM532hWNZNmEJ4HNpZ0WWhZKR1X13H6wyT7rWjDuk5jCO5AZScWoHA 44miXpTHDW2l9bU9QSl4Xt4w1FfYLkmM0g== X-Received: by 2002:a17:902:c404:: with SMTP id k4mr8373426plk.99.1592242340305; Mon, 15 Jun 2020 10:32:20 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([2401:4900:4175:6d71:950c:f8ee:90bc:902a]) by smtp.gmail.com with ESMTPSA id s1sm139323pjp.14.2020.06.15.10.32.13 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Jun 2020 10:32:19 -0700 (PDT) Date: Mon, 15 Jun 2020 23:01:54 +0530 From: Kaaira Gupta To: Helen Koike , Shuah Khan , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham , hverkuil@xs4all.nl Subject: [PATCH v3] media: tpg: Add function to return colors' order of test image Message-ID: <20200615173153.GA2404@kaaira-HP-Pavilion-Notebook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently there is no method to know the correct order of the colors for a test image generated by tpg. Write a function that returns a string of colors' order given a tpg. It returns a NULL pointer in case of test patterns which do not have a well defined colors' order. Hence add a NULL check for text in tpg_gen_text(). Signed-off-by: Kaaira Gupta Reviewed-by: Kieran Bingham --- Changes since v2: - Create a 'define' to prevent repetition of the common color sequence string. - Use 'fallthrough' on case statement to prevent repetition of code. Changes since v1: - Returned NULL for patterns whose color order cannot be defined. (Reported-by: kernel test robot ) - Made separate switch cases for separate test patterns (Reported-by: kernel test robot ) drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 32 +++++++++++++++++-- include/media/tpg/v4l2-tpg.h | 1 + 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c index 50f1e0b28b25..c96204cef155 100644 --- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c @@ -1959,12 +1959,14 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2], unsigned step = V4L2_FIELD_HAS_T_OR_B(tpg->field) ? 2 : 1; unsigned div = step; unsigned first = 0; - unsigned len = strlen(text); + unsigned len; unsigned p; - if (font8x16 == NULL || basep == NULL) + if (font8x16 == NULL || basep == NULL || text == NULL) return; + len = strlen(text); + /* Checks if it is possible to show string */ if (y + 16 >= tpg->compose.height || x + 8 >= tpg->compose.width) return; @@ -2006,6 +2008,32 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2], } EXPORT_SYMBOL_GPL(tpg_gen_text); +char *tpg_g_color_order(const struct tpg_data *tpg) +{ + #define COLORBAR(order) #order "white, yellow, cyan, green, magenta, red, blue, black" + + switch (tpg->pattern) { + case TPG_PAT_75_COLORBAR: + case TPG_PAT_100_COLORBAR: + case TPG_PAT_CSC_COLORBAR: + return COLORBAR("Left to right:"); + case TPG_PAT_100_HCOLORBAR: + return COLORBAR("Top to bottom:"); + case TPG_PAT_BLACK: + return "Black"; + case TPG_PAT_WHITE: + return "White"; + case TPG_PAT_RED: + return "Red"; + case TPG_PAT_GREEN: + return "Green"; + case TPG_PAT_BLUE: + return "Blue"; + default: + return NULL; + } +} + void tpg_update_mv_step(struct tpg_data *tpg) { int factor = tpg->mv_hor_mode > TPG_MOVE_NONE ? -1 : 1; diff --git a/include/media/tpg/v4l2-tpg.h b/include/media/tpg/v4l2-tpg.h index eb191e85d363..4f79cac87b85 100644 --- a/include/media/tpg/v4l2-tpg.h +++ b/include/media/tpg/v4l2-tpg.h @@ -252,6 +252,7 @@ void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc); void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop, const struct v4l2_rect *compose); +char *tpg_g_color_order(const struct tpg_data *tpg); static inline void tpg_s_pattern(struct tpg_data *tpg, enum tpg_pattern pattern) { -- 2.17.1