Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp555648ybt; Fri, 26 Jun 2020 06:10:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHfuCnOmqTK+HToi2gpBOkdaHjR2nYebMrmDPyApFBtI2AyNsdudcdlNmdcc8q4iSO3n9P X-Received: by 2002:aa7:d7d0:: with SMTP id e16mr2701062eds.10.1593177002023; Fri, 26 Jun 2020 06:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593177002; cv=none; d=google.com; s=arc-20160816; b=ExEqXqbAutCwyv9Jcy4V6dO8+xDfQdvg4phcsSZiZzwVV+zvGKgQzmWz9bXWeWstsG 2jt6OY4OQuRPwu3fIf4MFunmVsh5iiUSL7+f4X2ZEe0On177BA+1tZetpm06CVXm1ClQ 0pf4UfirKDFT4vVijDMhJhx5JbbDmAn5oMuq7X1UvbWORfnSp2zP5REV8Xql7+fjVIBM rf3V8jaVJNWZhkEs2fwkD+tIo2LAdOq1IFei5HXAacS1kD7yUDLo050Bn2B16XJ2TWCf JH3VuDZIvqhoM1RuKeHnbuF34TrAvlsdBuwe4k06/qFVpjrSiHF1WZy/6bMQz1vU8SRv DMlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=p5f1RM1G3Lr7GaMJ5iGuAFQEEYFL5B+QSi2APysRKNI=; b=C+H8wZxVVU3QClyJZxec9+wROKboI5d0qk7VEzIhpmHygl7/ZpWc39IwV4rsEvCicQ TNEEArwpGtHlO3CU6HG9+sjjT04cdy+o8B8y779aA3mh0f9xSXnSnHqToDIBdSYoL8bp EoEq9m9bjPpACIxCHd19Yo+Ys93mC4ZjC6cYCExEuLWLd6fAPXKyIjASfQHV+/rFDpZY 7WdkN6kJN1q/G6SiRvCKXi3fb4JULsIifr28CW+WZa/ANqvDGoFsXBDdWYNNfqovnDc5 ZA8AYtE0LLFd+Uv3M6KCIx+KVce0dhCeJvVQNMGYRmMGICAlC2RPykr6G658/eZ337EQ Qhpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.s=20150623 header.b=Nw2aOaTp; 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 cf23si16811326ejb.540.2020.06.26.06.09.38; Fri, 26 Jun 2020 06:10:02 -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=Nw2aOaTp; 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 S1728517AbgFZNHZ (ORCPT + 99 others); Fri, 26 Jun 2020 09:07:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728506AbgFZNHX (ORCPT ); Fri, 26 Jun 2020 09:07:23 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52188C08C5DD for ; Fri, 26 Jun 2020 06:07:22 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id k1so4273337pls.2 for ; Fri, 26 Jun 2020 06:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p5f1RM1G3Lr7GaMJ5iGuAFQEEYFL5B+QSi2APysRKNI=; b=Nw2aOaTp7dntGwpDclpV8L5OpCadjxLkCZkxpm1nhXCPZC9G5AGDmuTA7hcYD+iCOC s1bV+JgCapJWgFcRVPMA8eNEnBfYlSWmsZ3+GqvENOiXU6pG4Tz7ncDd07igt/0ENU08 7Qnks9sVmCgEirnBlOvpxzU5bqg1a4XSY8LKEq35Diy/OybSBP4qhPiWfYUXAtddXpSa LYw53wptcsTXs9Q2+3TLVhjBa5qyz8CjtIMETDQax+G/cYwzK1pt1lU3inrTcGc1/yNX J9wDQHVZVY9C2r8O4NgN3tktaTbxAzdZYkSTZ36d2aGbVPL5n/p9K1Lva14MdBYA+wn4 71Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=p5f1RM1G3Lr7GaMJ5iGuAFQEEYFL5B+QSi2APysRKNI=; b=E39+Kb3gA9N/k46lfZgS27nAO/J0AO4Cta2ffPpLZuzL62oNz6/JDpiuStk3Dh6y48 bQJgRVEO0FfTbXDxFMMwrKEjZm9yb1Izv5jbiwzw1564hqeYU3yB7zB3jSARDqY5P7/0 K+iL8o20Cx/2SH9iMiEwd5qTKXYHHR65KdF8GSLjOHr+5DEZCLdSOWtq+hxxV7VJo6pv ZrwpMt++HIofVDhhMSK5P1tdZIQpl8d3c5T+SrTOrbAVW3fweFHllAgExdtxgNgPwfYf 69RwobzrjJVtowpezY44JJwSf/znwKrN1mC9pFMjVdmtk/knrvvLa4GooD7+UWZJfnhL wncg== X-Gm-Message-State: AOAM531N8fJnnjqu31zg3aMScmwwZfffAnwirLUjn5BbMdM5FZuNDU2I Hx4h0fjdmOiRpz6bYCDG8InIhA== X-Received: by 2002:a17:90a:ee95:: with SMTP id i21mr3526541pjz.77.1593176841782; Fri, 26 Jun 2020 06:07:21 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id s10sm7246718pjl.41.2020.06.26.06.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 06:07:21 -0700 (PDT) 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 Cc: Kaaira Gupta Subject: [PATCH v7 2/3] media: tpg: Add function to return colors' order of test image Date: Fri, 26 Jun 2020 18:36:59 +0530 Message-Id: <20200626130700.2453-3-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200626130700.2453-1-kgupta@es.iitr.ac.in> References: <20200626130700.2453-1-kgupta@es.iitr.ac.in> 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 --- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 30 +++++++++++++++++-- include/media/tpg/v4l2-tpg.h | 1 + 2 files changed, 29 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 dde22a4cbd6c..c46ddd902675 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,30 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2], } EXPORT_SYMBOL_GPL(tpg_gen_text); +const char *tpg_g_color_order(const struct tpg_data *tpg) +{ + switch (tpg->pattern) { + case TPG_PAT_75_COLORBAR: + case TPG_PAT_100_COLORBAR: + case TPG_PAT_CSC_COLORBAR: + case TPG_PAT_100_HCOLORBAR: + return "white, yellow, cyan, green, magenta, red, blue, black"; + 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; + } +} +EXPORT_SYMBOL_GPL(tpg_g_color_order); + 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 9749ed409856..0b0ddb87380e 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); +const 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