Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp653241ybg; Fri, 12 Jun 2020 10:58:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrJ06JjHOfBWiFz/FZrMP+cBc37Uk3QkJQ7LlakwSeiuJ9fEcF9rt1fXGWPrI/MuFH/0ts X-Received: by 2002:a17:906:af62:: with SMTP id os2mr14163264ejb.345.1591984700346; Fri, 12 Jun 2020 10:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591984700; cv=none; d=google.com; s=arc-20160816; b=z0am7QKDZH36haUUrhZ0ppgIchxD1H3rhR6nnmXPuBzMbzPMLyiP6sspzc4C+miZXq CMYzj6/8Adk8ZP5iltIX7mSuZ+AhDfa3lTkw0WJ8ifanpj2jukwlQPaqJ/yQQ2HRMbGw yfKWtaLiYyl40Ws+5xPmgBH6RY/TmXdSd/9WKiHsAF2vdtnbqceLO7Ffqla7EEYaj+fN owNJF4GR+C9fe83vgZBPU282+omOWIz7cdxqdlbkzxkPCpAL2DwMZKF5BMVM1DaFaao+ Th0DDJ4t1fSwJ6RKES2cGmNsRZz4rissMnl2mqOo0G9Ey/8x8OXSWHGN5COuHI4NrSZT w9xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:to:from:date:dkim-signature; bh=MaAieVTop1wR3hLn5aMF4hBciiYGPZ3mmgoQxGR0ne0=; b=cWu5nLg12RIbP9CZgZIgn2TspzE70AWX6EEKZBsV4mSmg8/dvmQ2FufGRglvDkFq29 JmaDeoF6MKPOmFid09RRcRRDPwpYL3XDWKXQoP8/MV25OBTg3R6fNwU9Q5lUAzb2krdD 4oM63LNeIhbjIQuvUMMrT8KkHN5HZFRHoAEs6kOp1KlNd89l9FuvsivX6oi7ro3qWhM4 JIJaVs2AEAw0830l1ImY6Rtu3kHtQTl2wWcNNsbgWI6WKesLmf/LN5Kn4Ovwq1D3d6i8 Y8628zEObLPfk/uXafd545uMfg2dGuKi4rKg92lKorSR4TwURrmga6s0tzTkPb2Y4LOI 3CtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.s=20150623 header.b=P0QBFaNP; 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 v21si4028311eda.307.2020.06.12.10.57.56; Fri, 12 Jun 2020 10:58:20 -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=P0QBFaNP; 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 S1726290AbgFLR4E (ORCPT + 99 others); Fri, 12 Jun 2020 13:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbgFLR4D (ORCPT ); Fri, 12 Jun 2020 13:56:03 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC20FC08C5C1 for ; Fri, 12 Jun 2020 10:55:59 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id d8so4031803plo.12 for ; Fri, 12 Jun 2020 10:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=MaAieVTop1wR3hLn5aMF4hBciiYGPZ3mmgoQxGR0ne0=; b=P0QBFaNP0zIuJ3uLz4arPkeLR8Uvwl/8E2eLU/tQUS0Lc3SVSyWwszvFumzijOztlt fQFUA8AVrMOJAcAMnlxZivOqzNkHZ4/j9yEdHgtnuWNu82cSZ0Vv0nnQ4VLFnt58tSXm xZBgD/4ZQPod0aZ33iSCHverNzRMzIom5G78tPhY+kkL2avTb4dUVlWIyro8XzPCDpZr mPUagCc1OKak6Ao4uOKWZrb5/MUUXcLKpuW0TRhQOsCJh1mYtosZxyCvi3+H9RUuzXBS 4A+x0argkZBpyUkgAJqh2HYF1UXrwJBLuSVNfHMxAQQ0LfgPVmoncLnFWFy5vLbKQbbD Hk2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=MaAieVTop1wR3hLn5aMF4hBciiYGPZ3mmgoQxGR0ne0=; b=GLtEAucWSHa50z3GPhZmixSHEikmFz+eOTlIvSZ2KFNwOj2H7JRX0Nr8/T19A5M0HQ qJOus/jcL0W4F/kYaJlMXF3j+tuOdsdGxkdoR15lZQcech09bcEvQIiTtJ3N9J0axisF QbA3fCRYhnPLX7TPGYVvk+uAQh7KtxTdzX7kzFmY4kJ+Q4+CVrTkxoPJqU608tcc8ZLH 7r1nOMkRjYmOzRlmaHAUgoyaNeVbv3dqvmaxDLynD6hJiY7PKqzm7u9larJKMaYTz+e2 GnPLF1pcdJQ/oBu0rOehNfnEKOK16UGsNytcRinDi75m4nuWaLBihgyWxigf0UMFvobN ogzA== X-Gm-Message-State: AOAM532ffpOptoc7n37VK91h8an3p58WAIXgGaDuSvHpVyPi9jObjH/N b64BrXzZmIViVLPnaVA7Zr3mvwhYJtwnJQ== X-Received: by 2002:a17:90b:1009:: with SMTP id gm9mr60426pjb.213.1591984559192; Fri, 12 Jun 2020 10:55:59 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id o18sm7575370pfu.138.2020.06.12.10.55.55 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jun 2020 10:55:58 -0700 (PDT) Date: Fri, 12 Jun 2020 23:25:50 +0530 From: Kaaira Gupta To: hverkuil@xs4all.nl, Helen Koike , Shuah Khan , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham Subject: [PATCH] vimc: Add colors' order over test image Message-ID: <20200612175550.GA13676@kaaira-HP-Pavilion-Notebook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) 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 if the test image generated by vimc is correct (except for comparing it with a known 'correct' image). Add a function which returns the correct order of the colors in test pattern. And hence, add that text over the test image. Add a null check in tpg_gen_text() for patterns for which color order does not exist/make sense to print. Make a separate control for the same in vimc to make displaying the text optional. Signed-off-by: Kaaira Gupta --- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 24 ++++++++++++- drivers/media/test-drivers/vimc/Kconfig | 2 ++ drivers/media/test-drivers/vimc/vimc-common.h | 1 + drivers/media/test-drivers/vimc/vimc-sensor.c | 34 +++++++++++++++++++ include/media/tpg/v4l2-tpg.h | 1 + 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c index 50f1e0b28b25..e32586aaae5c 100644 --- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c @@ -1962,7 +1962,7 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2], unsigned len = strlen(text); unsigned p; - if (font8x16 == NULL || basep == NULL) + if (font8x16 == NULL || basep == NULL || text == NULL) return; /* Checks if it is possible to show string */ @@ -2006,6 +2006,28 @@ 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 || TPG_PAT_100_COLORBAR || TPG_PAT_CSC_COLORBAR): + return "Left to right: white, yellow, cyan, green, magenta, red, blue, black"; + case TPG_PAT_100_HCOLORBAR: + return "Top to bottom: 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; + } +} + void tpg_update_mv_step(struct tpg_data *tpg) { int factor = tpg->mv_hor_mode > TPG_MOVE_NONE ? -1 : 1; diff --git a/drivers/media/test-drivers/vimc/Kconfig b/drivers/media/test-drivers/vimc/Kconfig index 4068a67585f9..da4b2ad6e40c 100644 --- a/drivers/media/test-drivers/vimc/Kconfig +++ b/drivers/media/test-drivers/vimc/Kconfig @@ -2,6 +2,8 @@ config VIDEO_VIMC tristate "Virtual Media Controller Driver (VIMC)" depends on VIDEO_DEV && VIDEO_V4L2 + select FONT_SUPPORT + select FONT_8x16 select MEDIA_CONTROLLER select VIDEO_V4L2_SUBDEV_API select VIDEOBUF2_VMALLOC diff --git a/drivers/media/test-drivers/vimc/vimc-common.h b/drivers/media/test-drivers/vimc/vimc-common.h index ae163dec2459..52376ba6146b 100644 --- a/drivers/media/test-drivers/vimc/vimc-common.h +++ b/drivers/media/test-drivers/vimc/vimc-common.h @@ -20,6 +20,7 @@ #define VIMC_CID_VIMC_CLASS (0x00f00000 | 1) #define VIMC_CID_TEST_PATTERN (VIMC_CID_VIMC_BASE + 0) #define VIMC_CID_MEAN_WIN_SIZE (VIMC_CID_VIMC_BASE + 1) +#define VIMC_TEST_PATTERN_ORDER (VIMC_CID_VIMC_BASE + 2) #define VIMC_FRAME_MAX_WIDTH 4096 #define VIMC_FRAME_MAX_HEIGHT 2160 diff --git a/drivers/media/test-drivers/vimc/vimc-sensor.c b/drivers/media/test-drivers/vimc/vimc-sensor.c index a2f09ac9a360..236eae9f2f8d 100644 --- a/drivers/media/test-drivers/vimc/vimc-sensor.c +++ b/drivers/media/test-drivers/vimc/vimc-sensor.c @@ -5,6 +5,7 @@ * Copyright (C) 2015-2017 Helen Koike */ +#include #include #include #include @@ -19,6 +20,7 @@ struct vimc_sen_device { struct v4l2_subdev sd; struct tpg_data tpg; u8 *frame; + bool showOrder; /* The active format */ struct v4l2_mbus_framefmt mbus_format; struct v4l2_ctrl_handler hdl; @@ -185,10 +187,18 @@ static const struct v4l2_subdev_pad_ops vimc_sen_pad_ops = { static void *vimc_sen_process_frame(struct vimc_ent_device *ved, const void *sink_frame) { + u8 *basep[TPG_MAX_PLANES][2]; + char str[100]; struct vimc_sen_device *vsen = container_of(ved, struct vimc_sen_device, ved); tpg_fill_plane_buffer(&vsen->tpg, 0, 0, vsen->frame); + if (vsen->showOrder == 1) { + tpg_calc_text_basep(&vsen->tpg, basep, 0, vsen->frame); + snprintf(str, sizeof(str), tpg_g_color_order(&vsen->tpg)); + tpg_gen_text(&vsen->tpg, basep, 1, 1, str); + } + return vsen->frame; } @@ -200,6 +210,14 @@ static int vimc_sen_s_stream(struct v4l2_subdev *sd, int enable) if (enable) { const struct vimc_pix_map *vpix; unsigned int frame_size; + const struct font_desc *font = find_font("VGA8x16"); + + if (font == NULL) { + pr_err("vimc: could not find font\n"); + return -ENODEV; + } + + tpg_set_font(font->data); /* Calculate the frame size */ vpix = vimc_pix_map_by_code(vsen->mbus_format.code); @@ -269,6 +287,9 @@ static int vimc_sen_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_SATURATION: tpg_s_saturation(&vsen->tpg, ctrl->val); break; + case VIMC_TEST_PATTERN_ORDER: + vsen->showOrder = ctrl->val; + break; default: return -EINVAL; } @@ -307,6 +328,17 @@ static const struct v4l2_ctrl_config vimc_sen_ctrl_test_pattern = { .qmenu = tpg_pattern_strings, }; +static const struct v4l2_ctrl_config vimc_sen_ctrl_order = { + .ops = &vimc_sen_ctrl_ops, + .id = VIMC_TEST_PATTERN_ORDER, + .name = "Show Order", + .type = V4L2_CTRL_TYPE_BOOLEAN, + .min = 0, + .max = 1, + .step = 1, + .def = 1, +}; + static struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc, const char *vcfg_name) { @@ -323,6 +355,7 @@ static struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc, v4l2_ctrl_new_custom(&vsen->hdl, &vimc_sen_ctrl_class, NULL); v4l2_ctrl_new_custom(&vsen->hdl, &vimc_sen_ctrl_test_pattern, NULL); + v4l2_ctrl_new_custom(&vsen->hdl, &vimc_sen_ctrl_order, NULL); v4l2_ctrl_new_std(&vsen->hdl, &vimc_sen_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); v4l2_ctrl_new_std(&vsen->hdl, &vimc_sen_ctrl_ops, @@ -362,6 +395,7 @@ static struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc, /* Initialize the frame format */ vsen->mbus_format = fmt_default; + vsen->showOrder = vimc_sen_ctrl_order.def; return &vsen->ved; diff --git a/include/media/tpg/v4l2-tpg.h b/include/media/tpg/v4l2-tpg.h index eb191e85d363..2b404744322e 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