From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 1B264C433E5 for ; Tue, 30 Jun 2020 20:45:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 015C720772 for ; Tue, 30 Jun 2020 20:45:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730158AbgF3Upc (ORCPT ); Tue, 30 Jun 2020 16:45:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729988AbgF3UpL (ORCPT ); Tue, 30 Jun 2020 16:45:11 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB303C061755; Tue, 30 Jun 2020 13:45:10 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: koike) with ESMTPSA id 244402A4ACE Subject: Re: [PATCH v8 2/3] media: tpg: Add function to return colors' order of test image To: Kaaira Gupta , Shuah Khan , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, hverkuil@xs4all.nl, Kieran Bingham References: <20200630195052.23880-1-kgupta@es.iitr.ac.in> <20200630195052.23880-3-kgupta@es.iitr.ac.in> From: Helen Koike Message-ID: <1ebdc438-2e8e-3e5a-59c2-53e3bc97ab8e@collabora.com> Date: Tue, 30 Jun 2020 17:45:02 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200630195052.23880-3-kgupta@es.iitr.ac.in> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/30/20 4:50 PM, 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 | 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); > + This part of the code fixes another problem a bit unrelated to the commit message, but I understand it's required to safely chain tpg_g_color_order() with tpg_gen_text(), so I guess it's fine. Reviewed-by: Helen Koike Thanks Helen > /* 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) > { >