Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp627055ybt; Wed, 1 Jul 2020 06:32:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4YYGgXWvcPLlLxUnyXsB4M5CKn6zUBhryyNI/tS66VyBrFOZOlIRH5iRDnd2NMtbYtnxs X-Received: by 2002:aa7:c885:: with SMTP id p5mr14236229eds.100.1593610376318; Wed, 01 Jul 2020 06:32:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593610376; cv=none; d=google.com; s=arc-20160816; b=dDo6dpJpqgHao9pzbHjXCH9O69WEq8DKHwbx2zy8Ujf8u5KZCSHyLOCzncWJwFQtt6 +NwOYZDlzWRwv9EuS28xqq9PqkeYTQ2ZQ7K5UVi9ttRnk432Zm3aYFgyo+SiwXf2XMhi N6c+aweVQpuHK2NjG/dpSA/m+wJVVAPvRoderiNOyuxMuOqLkFOWEO/v+B+qb5yuyHIb 1BD9fyXfMCXvIJKfA47upl0RKcbK6nJSd58wIUCyeWscY9HJvGzsLNoM5XoCsdnFH0yW uiyUi2heMcEMOeIaXz6iQW9ElNE5Rjk4ZmnVvO2Bx5SpDAJ0lLR/35HiAwCHjUkAnoOa yaXw== 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=4HXkSJihp3Fc8dO1xehGtp3D9ixK4/XcOCc354oqDWM=; b=AjIULEZWk1ejHc3Q3DCoaIJJWiVEXN0MhRdkWZwYwThs5fN6cSqgmFEHe8c82n0uR5 mc0EKvuCG246hIZ47he1nXVBYCMhRbHtWYvetYXgOHr5huPdri3Ny5y3d1toYOF8lopE j31cSNCLcq7hmu5NFsPRnrI0UmcpE4m/D+T5CcT05a4s6pFJ1VbhMpPF/cxmYSXXQBOc xwPWo3sYQD9MX7fwICgyawd63nc7s3y0sysYQabJRErSulBxZLfQx3TeMHQILk1WunWd 0lLsRZM5Zu2b9oEdiLe1ykAMDXnNy1vXk2nMORz6LMtstVOZUIQs4PcuAp69TW8f+yCl qFRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.s=20150623 header.b=B4pEaSay; 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 l23si3756865ejb.322.2020.07.01.06.32.31; Wed, 01 Jul 2020 06:32:56 -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=B4pEaSay; 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 S1731072AbgGAN35 (ORCPT + 99 others); Wed, 1 Jul 2020 09:29:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731063AbgGAN3z (ORCPT ); Wed, 1 Jul 2020 09:29:55 -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 3CA8FC08C5C1 for ; Wed, 1 Jul 2020 06:29:55 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id g17so9913286plq.12 for ; Wed, 01 Jul 2020 06:29:55 -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=4HXkSJihp3Fc8dO1xehGtp3D9ixK4/XcOCc354oqDWM=; b=B4pEaSayd8mYWdN+od8lcucTv6XEOZMnM1CJ9CTdKxpRYtZ81//xZLs0WIE/ZipTTT 7ioDkVp299DfixguuLpn2jP2Zusx5f1lDACuGYIY2wV2RhU2Xnr851u07mqfWT1iEICt hpc2NtwUMmVVIJOOxYdvjuFVvGD70FiIZYpQEr7AAAuDkfdn7cZCT7xJwjUUL8lkvGNL i3LCKq5RMd5tv2Tt29TiMBOfOW57vOF7fysOo2XrWLKlMoKZY33EykF+5RyDPp6itc3m BB+cjvo/LQc4bo0L1NZhcakC5yCpF+Po3LC6pLLQhUOMHFd/cZ+BlkzVBJAurondzOl5 1z2A== 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=4HXkSJihp3Fc8dO1xehGtp3D9ixK4/XcOCc354oqDWM=; b=cPy/T9InQGXm0OgKGarwq7Cyz42oz5pzIHTbJMqxsZnR2xFIhbyNGxawFnWAGEMvwX czRNSDGQDbJhOIFyrWloaSF0dAZqueupvC8IQqnZ53HGJnuHm0EH1GoIwJZrCZOMi75/ O6bp1Vkxo1AkCszGnHud8xd6AMtjjQ/4+bviuZ2dTDdIKTq7kpqlOQVGIDyyWPG2Gqf8 66UeL3kJdEpM3uxz5qaFNgX6oh4wn4wO8OCuRSyk308W+sDuUFyw34AnA7GHf5se9Sot +EEtiQ7c33uZz0Drob4xq9ekci3bOmnYiWj95Pdu0xsE8G+FBzxJZvQRoq07QeZGJZCn tO3Q== X-Gm-Message-State: AOAM530WYaWbGkNZ3ezEaVzBD75BxHP6+C1iQBMieeu1OnNHUJ2K51AH xOI9AkglV366/NCuQWtAz+TRAA== X-Received: by 2002:a17:90b:120a:: with SMTP id gl10mr9638252pjb.44.1593610194650; Wed, 01 Jul 2020 06:29:54 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id o42sm5464435pje.10.2020.07.01.06.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2020 06:29:54 -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 v9 2/3] media: tpg: Add function to return colors' order of test image Date: Wed, 1 Jul 2020 18:59:39 +0530 Message-Id: <20200701132940.21257-3-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200701132940.21257-1-kgupta@es.iitr.ac.in> References: <20200701132940.21257-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 Reviewed-by: Helen Koike --- 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