Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2650885ybt; Mon, 22 Jun 2020 03:48:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynLGoXtJ2E9XeCrCRHgFFlNkHZDXOk1yn7lYiWfzPEbdHkmaucyL8QTvG0oVA1t10B2b90 X-Received: by 2002:a17:906:7751:: with SMTP id o17mr15872870ejn.111.1592822898818; Mon, 22 Jun 2020 03:48:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592822898; cv=none; d=google.com; s=arc-20160816; b=CcNyiw1jV7foQHD01hsJOp3wx5+iB5WFVb5KRBPEpM+Z+b58KTIQN+Ti4/xrsGIiK2 V/SYA5CjmeMyJAITYNbiQNeErDIdqBIx8kfKSWXDlcXVKPbo9JyekxqV6z/+s4rzMUCT QMpVUYyCQDVj0wk3YyMIvYc6HtTMqaZxl/ZUIJDPxWfgypu721bvG1XRxvAEkgynR/Dh 9+RiOe4ZGuW4EkKrhRpJuZgldfOMHNinWgfsZmP/SzZERIYxMaloJeL6iXnOE5tDjck/ Otb8x9A1sB6wdo2Y0QrUglGobiApMI6x7pArw3I1Ucil3/jCI64prTLVeFDGB6WfQ2JV iXcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=K6dDGbPeZnB4V7J7X8liUUoj+zo4D+OAMLsTP5S9VG0=; b=ov57mBtJrNDdpJGffFd1Gx0e6xXGQTEN7Ml1YLH/RfJqQZe+vPqAXoRkSIc/Ox1JZ/ c1u4HwRRLkh9kdLeVITqHvq0MHeP7S1F2y+pQLeIHHW56xoljCs4JP6A/SYYzA1x6hx9 3MqM/PReAPKrygDQ2mKd1zMADRgEgQBzv5707gw5Dxx5Eb0QibBaG7+tz4MEZPpjf2MJ 4GYdivd1vKfR9+7LlPHbLNYjZMFziUyAqsyWUyfMOh66NJ18hGQV1uC2JCgatkhekT9B rggj+tqf6btho9YTiQHx4H7Atj6J89T+7/SZg/n3y+JGTBhpmT1iaSikxHT0i67F++U+ fCFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xs4all.nl header.s=s1 header.b=EUOcYlug; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si9327759edp.573.2020.06.22.03.47.56; Mon, 22 Jun 2020 03:48:18 -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=@xs4all.nl header.s=s1 header.b=EUOcYlug; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727863AbgFVKpi (ORCPT + 99 others); Mon, 22 Jun 2020 06:45:38 -0400 Received: from lb2-smtp-cloud8.xs4all.net ([194.109.24.25]:33345 "EHLO lb2-smtp-cloud8.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727040AbgFVKpi (ORCPT ); Mon, 22 Jun 2020 06:45:38 -0400 Received: from cust-b5b5937f ([IPv6:fc0c:c16d:66b8:757f:c639:739b:9d66:799d]) by smtp-cloud8.xs4all.net with ESMTPA id nJx5j1DAgn3JWnJx8jZqbi; Mon, 22 Jun 2020 12:45:35 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s1; t=1592822735; bh=K6dDGbPeZnB4V7J7X8liUUoj+zo4D+OAMLsTP5S9VG0=; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type:From: Subject; b=EUOcYlugfhEZH4PUDGfvhPmDuKTAX0LMpu1yII4FUeP5ReW9fbj6nhj8g50KzWa6h tyWOqo7RIdFWhMpc9vgY8YaNC3iGXBSNvCsZW75iINEGMJlcbpSLzMG1b4+V0QmKMB pr8exVkE7OkPDXjgcOgAykp6YhX6q8cOhMilf5oeeA/Fqc3XZvtwJrIoO/a8KEW8hQ 00csB9E0zZLk/kHJ34UsayMsGxUo6PwWDAjKKE6M9NBRPiiZDn8n+rJzjjDqYsWLwh FN/fB0W9hGIj+F+LHXIxuOG1E4dgANhp7zCsSgs5bQen1BRpt1dxlikbC9y41O6sVt NsfWtE/GObhrA== Subject: Re: [PATCH v3 1/2] media: tpg: Add function to return colors' order of test image To: Kaaira Gupta , Helen Koike , Shuah Khan , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham References: <20200618190506.11892-1-kgupta@es.iitr.ac.in> <20200618190506.11892-2-kgupta@es.iitr.ac.in> From: Hans Verkuil Message-ID: <8268357e-6b47-a11c-c00f-3c8fa0582a7d@xs4all.nl> Date: Mon, 22 Jun 2020 12:45:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200618190506.11892-2-kgupta@es.iitr.ac.in> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfBGEHq4TD8y/cZBxbGCbRynvE5tYPNrCmi3CFgjYWZW2cb8zM7Ou+MCIat4poGCWSWFl6elS+Af/3aeQTY9P+lUvLX9+TUAfW9YXZ01nct6ffdWi8LRB UbhOuFHQO+IqWJRoBVIvvvil2ees4It0CeOK+WSaP+77dMfqkUzIHzgxzibkLC+yr+S9Zd9J2pGskgxZDXOScDR7K2rIMsX23AWIEpScGs1qDYlOFsJtMqCg XTtOjD+tEDi9MHbYA0tq+Ho7g/TEoKJRqIurDboVEJH+jjKxbQXJFOuPQM4y069H48fkVoMC/vXkD6YAi6J8dpwrHWGFnya5jj7v/8PJLGTJ0AepS+9PMEeM xBGkSR/kQqoopQvTZuT0esUq5nymIjh+aCrkiu1Is4ztbpQmTA4= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/06/2020 21:05, Kaaira Gupta wrote: > 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 | 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..31e6044a4104 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) This returns a const char *. > +{ > + #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: Just combine this with the other and just return the sequence: return "White, Yellow, Cyan, Green, Magenta, Red, Blue, Black"; It's obvious from the pattern that three are from left to right and one is from top to bottom. No need to mention that here. Regards, Hans > + 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) > { >