Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp26087ybt; Tue, 30 Jun 2020 14:04:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJdqZMoCDyGPyaTfTpBNbD308x71HCS2BZC6XDDOLoWs81d7FH+3B2UY3UEtYSIzsBtoEV X-Received: by 2002:a17:907:2105:: with SMTP id qn5mr13515694ejb.308.1593550622607; Tue, 30 Jun 2020 13:57:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593550622; cv=none; d=google.com; s=arc-20160816; b=qeK6uzTLEXbgb6YhfkT4tvNyl+oqdsNLPRazBgu5xKetrVNnByZpgTrGf5yTe5zFiQ jSXhMIZhvneUmzQiQo4jplZbUnesGGJN1MKrc3hjbqGjAa+Z/i2bBM/st9wjmDFF4YuD N2AM4nStmKfAPgfajT+w9l2w++d4PbHsVk/N429LgOUYBTdBTzBE1NweP7kcwuzLmWpw DUlWDXNjIOWUvk/Nfhq4p22uZYjU4Bx3ZALhJYgzFAYhZrBXqlE0bbnn1Fk4vqqyA+JR TjepFtUqZhYG7AbDj02Rls99FVAhB0Egi5/aKZc2L7v8lWO4MO+ediaP+FNESAwdTRLX zGGg== 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=kEGw+Ld53fEeQzSYWxI/eAV5rxMM7WpsebJhAFILRp6ir1exzUB5FsFfs87w0f2Xoj UARh6CC8/Z+kr/0xt/SVhR4A59WrJFLMTVo3F/qsq4bOJAVVwmPGya1IkxF6oG2AcM4L i5qK53DAwXOjBj+CSB6Y+FDNvoQbSIoG5TxliNQMivTMMozA6GcVZ512MTJFE6kxxEVc DSU3gCpVM60/nZy1WmH6eY4JBvH4H+c8smubCMlKd2FsoSTjxXhTlQvbNIcEIvLdRuz1 RwsKcU7iokHiw6ki2EAa25RfCEko4N8kvjbFtumC3ZmfyLnhDkDm4HKyw7GoTreAy02N gKNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.s=20150623 header.b=Z+mB0Q1F; 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 x94si2307507ede.416.2020.06.30.13.56.40; Tue, 30 Jun 2020 13:57: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=Z+mB0Q1F; 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 S1728752AbgF3TvL (ORCPT + 99 others); Tue, 30 Jun 2020 15:51:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728700AbgF3TvK (ORCPT ); Tue, 30 Jun 2020 15:51:10 -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 84CA9C03E979 for ; Tue, 30 Jun 2020 12:51:10 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id x8so8001951plm.10 for ; Tue, 30 Jun 2020 12:51:10 -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=Z+mB0Q1F0X/OGcwzH/rx1XM1xQHJiapG2y7Fh77n0MrdKeycMd6ovAHpoMkirrDjg1 40uBA60HSXqmBv75JHaK82z6nG8ggAL/NyJPIEY+qoEpl9qUEKIVFBMXM7k/uf5R57Lr Tiexvl8J7Y82wAOL3lvTHWb/kCBC7DTavuCuwe61SS4/q+h1oWs1Ui7q28rOog/Y4rj6 ijTPr7UTVh5ozVCtL4na9e/5kCulwXmUj3PaFqF/znEU3+dp+xbMYzwRhow//ibKeHxw YRZ1P9uLz3+CdbEvCrsJQZBpMm8YRkQRdCz0irUKuVVDFSOCDeCzz7X4pHCrpjUlF5kY FX9g== 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=R6voyQv0QQGrg2qW7FfoPIpxvIjCJXt2kXiCxJlMGwwzxBzOWlwfQHtYDFxTic3vLk SO5LTdu57q3Q7OpfFNu6HCQ+hyWgzCDvG/TF8Mq3Ie96qjgBWE1PUIn53oc9wO3o47be gyxVcicmJP3xuIN9mw5tQy9NACc2efKanr3sv+B80YuZ0TJyhWJtBN5x3FQ8hsXb1rEa hthgj8PyGNLyuk7qu/AsU132vtUwxZe4X1NM6IIiCKooDAVrKQ3JUERo5vQz9953cysh z6WwcvrNpk7lKiU2BIIz/rpPwjWGxaQb0wRZG5/Vc0rJpiyQvgHyFnMYBV7T/yYj229u 9w7Q== X-Gm-Message-State: AOAM531cmnBeZpvJM99rAJZ63HVuM8KsLONgbIEkn1cZ5oVclGyd1exM 0Gtl5Wii2cfVuid0SJB+7khi8w== X-Received: by 2002:a17:90a:db8a:: with SMTP id h10mr7868592pjv.197.1593546669603; Tue, 30 Jun 2020 12:51:09 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id t1sm3100649pje.55.2020.06.30.12.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 12:51:09 -0700 (PDT) From: Kaaira Gupta To: Helen Koike , Shuah Khan , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, hverkuil@xs4all.nl, Kieran Bingham Cc: Kaaira Gupta Subject: [PATCH v8 2/3] media: tpg: Add function to return colors' order of test image Date: Wed, 1 Jul 2020 01:20:51 +0530 Message-Id: <20200630195052.23880-3-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200630195052.23880-1-kgupta@es.iitr.ac.in> References: <20200630195052.23880-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