From patchwork Fri Jun 26 13:06:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 209262 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA960C433E0 for ; Fri, 26 Jun 2020 13:07:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 920782081A for ; Fri, 26 Jun 2020 13:07:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=es-iitr-ac-in.20150623.gappssmtp.com header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b="Nw2aOaTp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728504AbgFZNHX (ORCPT ); Fri, 26 Jun 2020 09:07:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbgFZNHW (ORCPT ); Fri, 26 Jun 2020 09:07:22 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A938C08C5DC for ; Fri, 26 Jun 2020 06:07:22 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id k71so1482269pje.0 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=Qc8F8881eHyY4hFMQokSV6QBcyA8Lr5HgKLrHlGhoiFqDGW+o9Mgv/SBniXcETYKHw W/cgwcqwBHThsnBpimzRxCKcKSAbBG96kQ2TfV1NskQL1FQ9DxZIhN5czPApy6RdmlzC xD1AiiDR065pROoHnAgZknOnHnntP0Nku2T7ZbqrvSDN6eGviV09Q/IzxaSlVhh/380Z 1LwpuUdeJjmHYud5MaOQJ4pxlPCYpI9f8Ejc/nfd0JrM74HO9bwzCoLGHpUth3U3mhSL diuqwqt3oPZ/uL8Q3LI9hw6EPT3yMWdsFUALh9X6apx9Q+hai5BeK73ZyOUmQM4/cIzu v0fA== X-Gm-Message-State: AOAM533xVK6KXKp0fA+1GGweCGkQKip+Sk0r+S/95/ffNDb6SNDbHDJD jVN84w4AE4cTpAfJVgk8y9JTOw== X-Google-Smtp-Source: ABdhPJzNTJy2Kd+NRn0bHfE8f8YU4s3LNezimcOqIj3veZ18CCVfe5QoepFfjgYitoBkScGcnEYcHQ== 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-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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) {