From patchwork Fri Apr 3 20:58:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210310 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 2300CC2BA19 for ; Fri, 3 Apr 2020 20:58:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D526320719 for ; Fri, 3 Apr 2020 20:58:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fxBbfoL9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728416AbgDCU6t (ORCPT ); Fri, 3 Apr 2020 16:58:49 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37201 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726368AbgDCU6s (ORCPT ); Fri, 3 Apr 2020 16:58:48 -0400 Received: by mail-pf1-f196.google.com with SMTP id u65so4165087pfb.4 for ; Fri, 03 Apr 2020 13:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ryysd62XzKXqT6N7Bd+7N9GE4k/LSFv+zAgtQQw9MoU=; b=fxBbfoL9VcJcL4fhlk7CLVh4CQEHBcq5/TQnKWOGAi4uaMtpN6IELvtuDIJhK4ByyG 81fKQ0rrVZipeBsaUbLkoaKrIg1oOQ9+4f+BAujrCj1Gz/j4DxEhUUqju5l9U14b7s3s 7EStddrMxaRYzsXcpmIPIv1StUUWfqDeucEDB+aWtwuOFIMN1VWEVscAFz6qIMdMVxWz 0nGFQOr3SDMyb3siMZ7qtSjXIrYi+Lk+9CYB7Ik3LPcKca9SIergQ/IM1ARwPG0ChPxt 7awtqUfwleK7OcpIyJ/u5B/1muJyBVKRDxY+GhBLz3YfL+vsCqxvxfhwf9Yy+rMhDbGv z0Ww== 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=Ryysd62XzKXqT6N7Bd+7N9GE4k/LSFv+zAgtQQw9MoU=; b=OPqySAHkZrfkA4bBjhhTQpgySVpNrM1I7qAnTvN1DIqeExkhU2dULhJeikXRyO6EiG SI+FXNAdfDuzomMEfT4ZBA+rUKhJhPV3ShEWjZLvs7ix+Fi4Vdr9dDQqBYHz0/G2nDyT 6+PuZr5d+So6jM/RtW9wvsdvKiC5a/tfMT4DbukW7nmBHxkE9QFSZ5QAN+bYigkT275k Nhn8dgfOcbDsHnVUxvP9bmMvG1Xp3Oi8tA+629MBdr1uPS2CK+0f+Bin11N+1Gmpw5LS Z2aekIYvLpKQz8kLayn20HbTa8T+lhH9sNLsfVq8k+TAF3l15MjfiNTYFpIFZhRv+NPX m94Q== X-Gm-Message-State: AGi0PuZkeiPo9La1ZkLv7eOnVMHQWGcrTYwpYYdo5QGc/sTWj2oH+pJx 1Uni2hzdD83a+udLH+lT9mSFaLA6MYY= X-Google-Smtp-Source: APiQypLsAagVYjkYatJPvPKTIPtkg7bnzEt9fJBFXTH0rMBDRPpcUU0hDIIYJw/WxcOPHho7ezHylA== X-Received: by 2002:a65:6805:: with SMTP id l5mr9756669pgt.256.1585947526999; Fri, 03 Apr 2020 13:58:46 -0700 (PDT) Received: from mappy.world.mentorg.com (sjewanfw1-nat.mentorg.com. [139.181.7.34]) by smtp.gmail.com with ESMTPSA id s39sm6521266pjb.10.2020.04.03.13.58.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 13:58:46 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Laurent Pinchart , Philipp Zabel , Rui Miguel Silva , Steve Longerbeam Subject: [PATCH v5 01/12] media: imx: utils: fix and simplify pixel format enumeration Date: Fri, 3 Apr 2020 13:58:28 -0700 Message-Id: <20200403205839.4531-2-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403205839.4531-1-slongerbeam@gmail.com> References: <20200403205839.4531-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Philipp Zabel Merge yuv_formats and rgb_formats into a single array. Always loop over all entries, skipping those that do not match the requested search criteria. This simplifies the code, lets us get rid of the manual counting of array entries, and stops accidentally ignoring some non-mbus RGB formats. Before: $ v4l2-ctl -d /dev/video14 --list-formats-out ioctl: VIDIOC_ENUM_FMT Type: Video Output [0]: 'UYVY' (UYVY 4:2:2) [1]: 'YUYV' (YUYV 4:2:2) [2]: 'YU12' (Planar YUV 4:2:0) [3]: 'YV12' (Planar YVU 4:2:0) [4]: '422P' (Planar YUV 4:2:2) [5]: 'NV12' (Y/CbCr 4:2:0) [6]: 'NV16' (Y/CbCr 4:2:2) [7]: 'RGBP' (16-bit RGB 5-6-5) [8]: 'RGB3' (24-bit RGB 8-8-8) [9]: 'BX24' (32-bit XRGB 8-8-8-8) After: $ v4l2-ctl -d /dev/video14 --list-formats-out ioctl: VIDIOC_ENUM_FMT Type: Video Output [0]: 'UYVY' (UYVY 4:2:2) [1]: 'YUYV' (YUYV 4:2:2) [2]: 'YU12' (Planar YUV 4:2:0) [3]: 'YV12' (Planar YVU 4:2:0) [4]: '422P' (Planar YUV 4:2:2) [5]: 'NV12' (Y/CbCr 4:2:0) [6]: 'NV16' (Y/CbCr 4:2:2) [7]: 'RGBP' (16-bit RGB 5-6-5) [8]: 'RGB3' (24-bit RGB 8-8-8) [9]: 'BGR3' (24-bit BGR 8-8-8) [10]: 'BX24' (32-bit XRGB 8-8-8-8) [11]: 'XR24' (32-bit BGRX 8-8-8-8) [12]: 'RX24' (32-bit XBGR 8-8-8-8) [13]: 'XB24' (32-bit RGBX 8-8-8-8) Signed-off-by: Philipp Zabel [Make loop counters unsigned] [Decrement index instead of adding a counter] [Return directly from within loop instead of breaking] Signed-off-by: Laurent Pinchart [Fix colorspace comparison error] Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-utils.c | 193 ++++++-------------- 1 file changed, 59 insertions(+), 134 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index fae981698c49..39469031e510 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -9,12 +9,9 @@ /* * List of supported pixel formats for the subdevs. - * - * In all of these tables, the non-mbus formats (with no - * mbus codes) must all fall at the end of the table. */ - -static const struct imx_media_pixfmt yuv_formats[] = { +static const struct imx_media_pixfmt pixel_formats[] = { + /*** YUV formats start here ***/ { .fourcc = V4L2_PIX_FMT_UYVY, .codes = { @@ -31,12 +28,7 @@ static const struct imx_media_pixfmt yuv_formats[] = { }, .cs = IPUV3_COLORSPACE_YUV, .bpp = 16, - }, - /*** - * non-mbus YUV formats start here. NOTE! when adding non-mbus - * formats, NUM_NON_MBUS_YUV_FORMATS must be updated below. - ***/ - { + }, { .fourcc = V4L2_PIX_FMT_YUV420, .cs = IPUV3_COLORSPACE_YUV, .bpp = 12, @@ -62,13 +54,7 @@ static const struct imx_media_pixfmt yuv_formats[] = { .bpp = 16, .planar = true, }, -}; - -#define NUM_NON_MBUS_YUV_FORMATS 5 -#define NUM_YUV_FORMATS ARRAY_SIZE(yuv_formats) -#define NUM_MBUS_YUV_FORMATS (NUM_YUV_FORMATS - NUM_NON_MBUS_YUV_FORMATS) - -static const struct imx_media_pixfmt rgb_formats[] = { + /*** RGB formats start here ***/ { .fourcc = V4L2_PIX_FMT_RGB565, .codes = {MEDIA_BUS_FMT_RGB565_2X8_LE}, @@ -83,12 +69,28 @@ static const struct imx_media_pixfmt rgb_formats[] = { }, .cs = IPUV3_COLORSPACE_RGB, .bpp = 24, + }, { + .fourcc = V4L2_PIX_FMT_BGR24, + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 24, }, { .fourcc = V4L2_PIX_FMT_XRGB32, .codes = {MEDIA_BUS_FMT_ARGB8888_1X32}, .cs = IPUV3_COLORSPACE_RGB, .bpp = 32, .ipufmt = true, + }, { + .fourcc = V4L2_PIX_FMT_XBGR32, + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 32, + }, { + .fourcc = V4L2_PIX_FMT_BGRX32, + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 32, + }, { + .fourcc = V4L2_PIX_FMT_RGBX32, + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 32, }, /*** raw bayer and grayscale formats start here ***/ { @@ -182,33 +184,8 @@ static const struct imx_media_pixfmt rgb_formats[] = { .bpp = 16, .bayer = true, }, - /*** - * non-mbus RGB formats start here. NOTE! when adding non-mbus - * formats, NUM_NON_MBUS_RGB_FORMATS must be updated below. - ***/ - { - .fourcc = V4L2_PIX_FMT_BGR24, - .cs = IPUV3_COLORSPACE_RGB, - .bpp = 24, - }, { - .fourcc = V4L2_PIX_FMT_XBGR32, - .cs = IPUV3_COLORSPACE_RGB, - .bpp = 32, - }, { - .fourcc = V4L2_PIX_FMT_BGRX32, - .cs = IPUV3_COLORSPACE_RGB, - .bpp = 32, - }, { - .fourcc = V4L2_PIX_FMT_RGBX32, - .cs = IPUV3_COLORSPACE_RGB, - .bpp = 32, - }, }; -#define NUM_NON_MBUS_RGB_FORMATS 2 -#define NUM_RGB_FORMATS ARRAY_SIZE(rgb_formats) -#define NUM_MBUS_RGB_FORMATS (NUM_RGB_FORMATS - NUM_NON_MBUS_RGB_FORMATS) - static const struct imx_media_pixfmt ipu_yuv_formats[] = { { .fourcc = V4L2_PIX_FMT_YUV32, @@ -246,21 +223,24 @@ static void init_mbus_colorimetry(struct v4l2_mbus_framefmt *mbus, mbus->ycbcr_enc); } -static const -struct imx_media_pixfmt *__find_format(u32 fourcc, - u32 code, - bool allow_non_mbus, - bool allow_bayer, - const struct imx_media_pixfmt *array, - u32 array_size) +static const struct imx_media_pixfmt *find_format(u32 fourcc, + u32 code, + enum codespace_sel cs_sel, + bool allow_non_mbus, + bool allow_bayer) { - const struct imx_media_pixfmt *fmt; - int i, j; + unsigned int i; - for (i = 0; i < array_size; i++) { - fmt = &array[i]; + for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { + const struct imx_media_pixfmt *fmt = &pixel_formats[i]; + enum codespace_sel fmt_cs_sel; + unsigned int j; - if ((!allow_non_mbus && !fmt->codes[0]) || + fmt_cs_sel = (fmt->cs == IPUV3_COLORSPACE_YUV) ? + CS_SEL_YUV : CS_SEL_RGB; + + if ((cs_sel != CS_SEL_ANY && fmt_cs_sel != cs_sel) || + (!allow_non_mbus && !fmt->codes[0]) || (!allow_bayer && fmt->bayer)) continue; @@ -270,39 +250,13 @@ struct imx_media_pixfmt *__find_format(u32 fourcc, if (!code) continue; - for (j = 0; fmt->codes[j]; j++) { + for (j = 0; j < ARRAY_SIZE(fmt->codes) && fmt->codes[j]; j++) { if (code == fmt->codes[j]) return fmt; } } - return NULL; -} -static const struct imx_media_pixfmt *find_format(u32 fourcc, - u32 code, - enum codespace_sel cs_sel, - bool allow_non_mbus, - bool allow_bayer) -{ - const struct imx_media_pixfmt *ret; - - switch (cs_sel) { - case CS_SEL_YUV: - return __find_format(fourcc, code, allow_non_mbus, allow_bayer, - yuv_formats, NUM_YUV_FORMATS); - case CS_SEL_RGB: - return __find_format(fourcc, code, allow_non_mbus, allow_bayer, - rgb_formats, NUM_RGB_FORMATS); - case CS_SEL_ANY: - ret = __find_format(fourcc, code, allow_non_mbus, allow_bayer, - yuv_formats, NUM_YUV_FORMATS); - if (ret) - return ret; - return __find_format(fourcc, code, allow_non_mbus, allow_bayer, - rgb_formats, NUM_RGB_FORMATS); - default: - return NULL; - } + return NULL; } static int enum_format(u32 *fourcc, u32 *code, u32 index, @@ -310,61 +264,32 @@ static int enum_format(u32 *fourcc, u32 *code, u32 index, bool allow_non_mbus, bool allow_bayer) { - const struct imx_media_pixfmt *fmt; - u32 mbus_yuv_sz = NUM_MBUS_YUV_FORMATS; - u32 mbus_rgb_sz = NUM_MBUS_RGB_FORMATS; - u32 yuv_sz = NUM_YUV_FORMATS; - u32 rgb_sz = NUM_RGB_FORMATS; + unsigned int i; - switch (cs_sel) { - case CS_SEL_YUV: - if (index >= yuv_sz || - (!allow_non_mbus && index >= mbus_yuv_sz)) - return -EINVAL; - fmt = &yuv_formats[index]; - break; - case CS_SEL_RGB: - if (index >= rgb_sz || - (!allow_non_mbus && index >= mbus_rgb_sz)) - return -EINVAL; - fmt = &rgb_formats[index]; - if (!allow_bayer && fmt->bayer) - return -EINVAL; - break; - case CS_SEL_ANY: - if (!allow_non_mbus) { - if (index >= mbus_yuv_sz) { - index -= mbus_yuv_sz; - if (index >= mbus_rgb_sz) - return -EINVAL; - fmt = &rgb_formats[index]; - if (!allow_bayer && fmt->bayer) - return -EINVAL; - } else { - fmt = &yuv_formats[index]; - } - } else { - if (index >= yuv_sz + rgb_sz) - return -EINVAL; - if (index >= yuv_sz) { - fmt = &rgb_formats[index - yuv_sz]; - if (!allow_bayer && fmt->bayer) - return -EINVAL; - } else { - fmt = &yuv_formats[index]; - } + for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { + const struct imx_media_pixfmt *fmt = &pixel_formats[i]; + enum codespace_sel fmt_cs_sel; + + fmt_cs_sel = (fmt->cs == IPUV3_COLORSPACE_YUV) ? + CS_SEL_YUV : CS_SEL_RGB; + + if ((cs_sel != CS_SEL_ANY && fmt_cs_sel != cs_sel) || + (!allow_non_mbus && !fmt->codes[0]) || + (!allow_bayer && fmt->bayer)) + continue; + + if (index == 0) { + if (fourcc) + *fourcc = fmt->fourcc; + if (code) + *code = fmt->codes[0]; + return 0; } - break; - default: - return -EINVAL; - } - if (fourcc) - *fourcc = fmt->fourcc; - if (code) - *code = fmt->codes[0]; + index--; + } - return 0; + return -EINVAL; } const struct imx_media_pixfmt * From patchwork Fri Apr 3 20:58:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210309 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 57BF2C2BA12 for ; Fri, 3 Apr 2020 20:58:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2BCF4206F6 for ; Fri, 3 Apr 2020 20:58:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eIJTGbdK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728437AbgDCU6v (ORCPT ); Fri, 3 Apr 2020 16:58:51 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35069 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726368AbgDCU6v (ORCPT ); Fri, 3 Apr 2020 16:58:51 -0400 Received: by mail-pg1-f196.google.com with SMTP id k5so4145366pga.2 for ; Fri, 03 Apr 2020 13:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qYBkInbfk4Je9+caiy8b4edch0lbPftvhGVf+jVJIDU=; b=eIJTGbdKH+EGNHtz4kjqTSsJptDd7h1bf9VYEtFVsYY1oi45SChxcGO8CS04gSmv/K 0NNh4RMyjt/nXRMutVTGKknmE47whzjtk4Vsngxikhlna2RqvGHXFa41bNNL7SBHrRKj mF0RCK+WcNZT41s3RQlR0wM0J+LBRVkcFjzRzyOmdniAomM2Ba7BpnzQ8RY0JTILacq+ QJeRern+rJJPuoeimoU/JoM1AINpqQoaOn2cS0k+1uN1kEGfsFH0GwK6iJ08BbTPsFdf jGsNF7fa3hAmbYbSb4tjqCxQaqOH5TnYtVHkCGSUgFti5ySnY1gcLLSphED4OqpWcdhU JABA== 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=qYBkInbfk4Je9+caiy8b4edch0lbPftvhGVf+jVJIDU=; b=MJiI5R+LvPR2r5HTMMNghNdLZCDLxzOut5bK3lxD/hSNXRgV8f4bP0Y1BpeBSeHwWA DxOsC3koSrtRGm6M9aaQgu2TdB9ikYmYxp+fAfBnJA7bsM6cu13x/oRDEmSo2MAhYCaQ i1W2FO5Vi2Hz4i3kzRapE5LPMrsCkOXOW8Q3H5MW62uu5V9iMlpad8j6S6Z9sXZ5Dv96 aN9+F2wCjMIIYj1BAhbq+vxWgXmHeKB7JPvtQU6/HT9I+ShO+zzaxp6wNddgp9vX/3fG 5OoX8/dKbkNJiD/CsIQPrBK/BmaS8GwislVZ1uKIvKg8IB38kPb+c5+1pq49B3Gls+Z2 GJSg== X-Gm-Message-State: AGi0PuaFksNCr8VI/PF8HIVc5bo9y5/EoJTXN7T6dRNajF8Dv/fNeAGe 46ssfgfD7FdK/MtzFWtXlfnyQkSBToA= X-Google-Smtp-Source: APiQypI+dwpInxfdG/jGuRCsAI5Zy72Z3RnbXkjcXpCuX7aA/ezcQMT/BI//gWof+MKbEYN1yn++Og== X-Received: by 2002:a62:30c6:: with SMTP id w189mr10503260pfw.257.1585947528283; Fri, 03 Apr 2020 13:58:48 -0700 (PDT) Received: from mappy.world.mentorg.com (sjewanfw1-nat.mentorg.com. [139.181.7.34]) by smtp.gmail.com with ESMTPSA id s39sm6521266pjb.10.2020.04.03.13.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 13:58:47 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Laurent Pinchart , Philipp Zabel , Rui Miguel Silva , Steve Longerbeam Subject: [PATCH v5 02/12] media: imx: utils: fix media bus format enumeration Date: Fri, 3 Apr 2020 13:58:29 -0700 Message-Id: <20200403205839.4531-3-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403205839.4531-1-slongerbeam@gmail.com> References: <20200403205839.4531-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Philipp Zabel Iterate over all media bus formats, not just over the first format in each imx_media_pixfmt entry. Before: $ v4l2-ctl -d $(media-ctl -e ipu1_csi0) --list-subdev-mbus-codes 0 ioctl: VIDIOC_SUBDEV_ENUM_MBUS_CODE (pad=0) 0x2006: MEDIA_BUS_FMT_UYVY8_2X8 0x2008: MEDIA_BUS_FMT_YUYV8_2X8 0x1008: MEDIA_BUS_FMT_RGB565_2X8_LE 0x100a: MEDIA_BUS_FMT_RGB888_1X24 0x100d: MEDIA_BUS_FMT_ARGB8888_1X32 0x3001: MEDIA_BUS_FMT_SBGGR8_1X8 0x3013: MEDIA_BUS_FMT_SGBRG8_1X8 0x3002: MEDIA_BUS_FMT_SGRBG8_1X8 0x3014: MEDIA_BUS_FMT_SRGGB8_1X8 0x3007: MEDIA_BUS_FMT_SBGGR10_1X10 0x300e: MEDIA_BUS_FMT_SGBRG10_1X10 0x300a: MEDIA_BUS_FMT_SGRBG10_1X10 0x300f: MEDIA_BUS_FMT_SRGGB10_1X10 0x2001: MEDIA_BUS_FMT_Y8_1X8 0x200a: MEDIA_BUS_FMT_Y10_1X10 After: $ v4l2-ctl -d $(media-ctl -e ipu1_csi0) --list-subdev-mbus-codes 0 ioctl: VIDIOC_SUBDEV_ENUM_MBUS_CODE (pad=0) 0x2006: MEDIA_BUS_FMT_UYVY8_2X8 0x200f: MEDIA_BUS_FMT_UYVY8_1X16 0x2008: MEDIA_BUS_FMT_YUYV8_2X8 0x2011: MEDIA_BUS_FMT_YUYV8_1X16 0x1008: MEDIA_BUS_FMT_RGB565_2X8_LE 0x100a: MEDIA_BUS_FMT_RGB888_1X24 0x100c: MEDIA_BUS_FMT_RGB888_2X12_LE 0x100d: MEDIA_BUS_FMT_ARGB8888_1X32 0x3001: MEDIA_BUS_FMT_SBGGR8_1X8 0x3013: MEDIA_BUS_FMT_SGBRG8_1X8 0x3002: MEDIA_BUS_FMT_SGRBG8_1X8 0x3014: MEDIA_BUS_FMT_SRGGB8_1X8 0x3007: MEDIA_BUS_FMT_SBGGR10_1X10 0x3008: MEDIA_BUS_FMT_SBGGR12_1X12 0x3019: MEDIA_BUS_FMT_SBGGR14_1X14 0x301d: MEDIA_BUS_FMT_SBGGR16_1X16 0x300e: MEDIA_BUS_FMT_SGBRG10_1X10 0x3010: MEDIA_BUS_FMT_SGBRG12_1X12 0x301a: MEDIA_BUS_FMT_SGBRG14_1X14 0x301e: MEDIA_BUS_FMT_SGBRG16_1X16 0x300a: MEDIA_BUS_FMT_SGRBG10_1X10 0x3011: MEDIA_BUS_FMT_SGRBG12_1X12 0x301b: MEDIA_BUS_FMT_SGRBG14_1X14 0x301f: MEDIA_BUS_FMT_SGRBG16_1X16 0x300f: MEDIA_BUS_FMT_SRGGB10_1X10 0x3012: MEDIA_BUS_FMT_SRGGB12_1X12 0x301c: MEDIA_BUS_FMT_SRGGB14_1X14 0x3020: MEDIA_BUS_FMT_SRGGB16_1X16 0x2001: MEDIA_BUS_FMT_Y8_1X8 0x200a: MEDIA_BUS_FMT_Y10_1X10 0x2013: MEDIA_BUS_FMT_Y12_1X12 Signed-off-by: Philipp Zabel [Decrement index to replace loop counter k] [Return directly from within the loops] Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx-media-utils.c | 22 +++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index 39469031e510..00a71f01786c 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -269,6 +269,7 @@ static int enum_format(u32 *fourcc, u32 *code, u32 index, for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx_media_pixfmt *fmt = &pixel_formats[i]; enum codespace_sel fmt_cs_sel; + unsigned int j; fmt_cs_sel = (fmt->cs == IPUV3_COLORSPACE_YUV) ? CS_SEL_YUV : CS_SEL_RGB; @@ -278,15 +279,24 @@ static int enum_format(u32 *fourcc, u32 *code, u32 index, (!allow_bayer && fmt->bayer)) continue; - if (index == 0) { - if (fourcc) - *fourcc = fmt->fourcc; - if (code) - *code = fmt->codes[0]; + if (fourcc && index == 0) { + *fourcc = fmt->fourcc; return 0; } - index--; + if (!code) { + index--; + continue; + } + + for (j = 0; j < ARRAY_SIZE(fmt->codes) && fmt->codes[j]; j++) { + if (index == 0) { + *code = fmt->codes[j]; + return 0; + } + + index--; + } } return -EINVAL; From patchwork Fri Apr 3 20:58:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210308 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 7FF8BC2BA19 for ; Fri, 3 Apr 2020 20:58:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 526C4206F6 for ; Fri, 3 Apr 2020 20:58:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="idiyU2Dr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728464AbgDCU64 (ORCPT ); Fri, 3 Apr 2020 16:58:56 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:34889 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727907AbgDCU64 (ORCPT ); Fri, 3 Apr 2020 16:58:56 -0400 Received: by mail-pl1-f195.google.com with SMTP id c12so3244179plz.2 for ; Fri, 03 Apr 2020 13:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lTcgObL+/HQVhYVuwMyP7x81+0XA5GAvjv1OxS6I+/U=; b=idiyU2Dr87mei0ngAA/KZvfQCjK+eogYQC9fV4FddRpwtajIpC79p4BM11qj9Ru8+F 0oxlC2vnfitiPEt81gWSoJufpLmQSt38oREh+eUODqzzj5PhywDAePX4vUedbSnk/rp5 jswnz0UzE2LbfznLoUJnda8iMPrbHGMbjF0TBYMQHJpT88wbqIoFgMUL8yM16big2U4v DQO+6hDDAxQhv0EVZux8kvoDQkeK82Cy4DLrPjwhEp/z6sSS8Ucr950m/T31yZbpL3TM FwZF7UcIK9C3uliiYace5id+bbXNNcrmbWiCPH+2kvTVqXpfAVA8+kiy4ZlfgfOrgd8x Zy8Q== 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=lTcgObL+/HQVhYVuwMyP7x81+0XA5GAvjv1OxS6I+/U=; b=o/WMowmyKVD66MGjOnW8tJFGOL568mQNiFS8WXdzMfLfSmFoGklpmYZpYtG4jBNtyh CBWfTgnKuhl92pB2FcGM09BdoZgH4MVs3+TBxFgZw0ud6rDtTE/lbMje4+bfOyJ+4L3l TEVjFDw+TNFLtfjb+eFhs44Eyy/biF4PQpa1j2RMmBFtn4+l5DtSbvxZT69frRyxfqDI ukXmLUe80/ucGq81p1qRkYgzg6dUme3yJvwAycHM6Neuj2Yd9st/wwxtQ+4TluVY7KZE 9bK4u6Gjdkd9w0PmFOyTBf6UuJcS7RD4BeJ/9QWqdvBp92TvY1r/rGRS6Pz/p2G190tB vVxQ== X-Gm-Message-State: AGi0PuZpeFVYCdZ41aZ9UdR6v6ED14tgdxeIf+7OFtESmtjupkVjqbHu AfJUBpwsdHcVqVRtcPTIsaJg6HMeeyc= X-Google-Smtp-Source: APiQypJcdldZKd1FGKVWH59RG3rqlpAjjokLPW+HoeXtasysNQ/ZykRWlt73O0VIp/nBWG2me0oDnA== X-Received: by 2002:a17:90a:f30e:: with SMTP id ca14mr10282346pjb.134.1585947533983; Fri, 03 Apr 2020 13:58:53 -0700 (PDT) Received: from mappy.world.mentorg.com (sjewanfw1-nat.mentorg.com. [139.181.7.34]) by smtp.gmail.com with ESMTPSA id s39sm6521266pjb.10.2020.04.03.13.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 13:58:53 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Laurent Pinchart , Philipp Zabel , Rui Miguel Silva , Steve Longerbeam Subject: [PATCH v5 06/12] media: imx: utils: Introduce PIXFMT_SEL_IPU Date: Fri, 3 Apr 2020 13:58:33 -0700 Message-Id: <20200403205839.4531-7-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403205839.4531-1-slongerbeam@gmail.com> References: <20200403205839.4531-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a PIXFMT_SEL_IPU selection flag, to select only the IPU-internal pixel formats, and move the single-entry IPU-internal pixel format arrays into pixel_formats[]. imx_media_find_ipu_format() and imx_media_enum_ipu_format() can now simply call find_format() and enum_format(). The RGB32 format is both an IPU-internal format, and an in-memory format via idmac channels that is supported by the IPUv3 driver, so it appears twice in pixel_formats[], one with ipufmt=false for the in-memory format, and again with ipufmt=true for the IPU-internal format. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-utils.c | 118 +++++--------------- drivers/staging/media/imx/imx-media.h | 1 + 2 files changed, 27 insertions(+), 92 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index beaa920d7ac7..00a10bbd9a2d 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -53,7 +53,13 @@ static const struct imx_media_pixfmt pixel_formats[] = { .cs = IPUV3_COLORSPACE_YUV, .bpp = 16, .planar = true, - }, + }, { + .fourcc = V4L2_PIX_FMT_YUV32, + .codes = {MEDIA_BUS_FMT_AYUV8_1X32}, + .cs = IPUV3_COLORSPACE_YUV, + .bpp = 32, + .ipufmt = true, + }, /*** RGB formats start here ***/ { .fourcc = V4L2_PIX_FMT_RGB565, @@ -73,6 +79,11 @@ static const struct imx_media_pixfmt pixel_formats[] = { .fourcc = V4L2_PIX_FMT_BGR24, .cs = IPUV3_COLORSPACE_RGB, .bpp = 24, + }, { + .fourcc = V4L2_PIX_FMT_XRGB32, + .codes = {MEDIA_BUS_FMT_ARGB8888_1X32}, + .cs = IPUV3_COLORSPACE_RGB, + .bpp = 32, }, { .fourcc = V4L2_PIX_FMT_XRGB32, .codes = {MEDIA_BUS_FMT_ARGB8888_1X32}, @@ -186,42 +197,24 @@ static const struct imx_media_pixfmt pixel_formats[] = { }, }; -static const struct imx_media_pixfmt ipu_yuv_formats[] = { - { - .fourcc = V4L2_PIX_FMT_YUV32, - .codes = {MEDIA_BUS_FMT_AYUV8_1X32}, - .cs = IPUV3_COLORSPACE_YUV, - .bpp = 32, - .ipufmt = true, - }, -}; - -#define NUM_IPU_YUV_FORMATS ARRAY_SIZE(ipu_yuv_formats) - -static const struct imx_media_pixfmt ipu_rgb_formats[] = { - { - .fourcc = V4L2_PIX_FMT_XRGB32, - .codes = {MEDIA_BUS_FMT_ARGB8888_1X32}, - .cs = IPUV3_COLORSPACE_RGB, - .bpp = 32, - .ipufmt = true, - }, -}; - -#define NUM_IPU_RGB_FORMATS ARRAY_SIZE(ipu_rgb_formats) - static const struct imx_media_pixfmt *find_format(u32 fourcc, u32 code, enum imx_pixfmt_sel fmt_sel, bool allow_non_mbus) { + bool sel_ipu = fmt_sel & PIXFMT_SEL_IPU; unsigned int i; + fmt_sel &= ~PIXFMT_SEL_IPU; + for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx_media_pixfmt *fmt = &pixel_formats[i]; enum imx_pixfmt_sel sel; unsigned int j; + if (sel_ipu && !fmt->ipufmt) + continue; + sel = fmt->bayer ? PIXFMT_SEL_BAYER : ((fmt->cs == IPUV3_COLORSPACE_YUV) ? PIXFMT_SEL_YUV : PIXFMT_SEL_RGB); @@ -249,13 +242,19 @@ static int enum_format(u32 *fourcc, u32 *code, u32 index, enum imx_pixfmt_sel fmt_sel, bool allow_non_mbus) { + bool sel_ipu = fmt_sel & PIXFMT_SEL_IPU; unsigned int i; + fmt_sel &= ~PIXFMT_SEL_IPU; + for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx_media_pixfmt *fmt = &pixel_formats[i]; enum imx_pixfmt_sel sel; unsigned int j; + if (sel_ipu && !fmt->ipufmt) + continue; + sel = fmt->bayer ? PIXFMT_SEL_BAYER : ((fmt->cs == IPUV3_COLORSPACE_YUV) ? PIXFMT_SEL_YUV : PIXFMT_SEL_RGB); @@ -317,79 +316,14 @@ EXPORT_SYMBOL_GPL(imx_media_enum_mbus_format); const struct imx_media_pixfmt * imx_media_find_ipu_format(u32 code, enum imx_pixfmt_sel fmt_sel) { - const struct imx_media_pixfmt *array, *fmt, *ret = NULL; - u32 array_size; - int i, j; - - fmt_sel &= ~PIXFMT_SEL_BAYER; - - switch (fmt_sel) { - case PIXFMT_SEL_YUV: - array_size = NUM_IPU_YUV_FORMATS; - array = ipu_yuv_formats; - break; - case PIXFMT_SEL_RGB: - array_size = NUM_IPU_RGB_FORMATS; - array = ipu_rgb_formats; - break; - case PIXFMT_SEL_YUV_RGB: - array_size = NUM_IPU_YUV_FORMATS + NUM_IPU_RGB_FORMATS; - array = ipu_yuv_formats; - break; - default: - return NULL; - } - - for (i = 0; i < array_size; i++) { - if (fmt_sel == PIXFMT_SEL_YUV_RGB && i >= NUM_IPU_YUV_FORMATS) - fmt = &ipu_rgb_formats[i - NUM_IPU_YUV_FORMATS]; - else - fmt = &array[i]; - - for (j = 0; code && fmt->codes[j]; j++) { - if (code == fmt->codes[j]) { - ret = fmt; - goto out; - } - } - } - -out: - return ret; + return find_format(0, code, fmt_sel | PIXFMT_SEL_IPU, false); } EXPORT_SYMBOL_GPL(imx_media_find_ipu_format); int imx_media_enum_ipu_format(u32 *code, u32 index, enum imx_pixfmt_sel fmt_sel) { - fmt_sel &= ~PIXFMT_SEL_BAYER; - - switch (fmt_sel) { - case PIXFMT_SEL_YUV: - if (index >= NUM_IPU_YUV_FORMATS) - return -EINVAL; - *code = ipu_yuv_formats[index].codes[0]; - break; - case PIXFMT_SEL_RGB: - if (index >= NUM_IPU_RGB_FORMATS) - return -EINVAL; - *code = ipu_rgb_formats[index].codes[0]; - break; - case PIXFMT_SEL_YUV_RGB: - if (index >= NUM_IPU_YUV_FORMATS + NUM_IPU_RGB_FORMATS) - return -EINVAL; - if (index >= NUM_IPU_YUV_FORMATS) { - index -= NUM_IPU_YUV_FORMATS; - *code = ipu_rgb_formats[index].codes[0]; - } else { - *code = ipu_yuv_formats[index].codes[0]; - } - break; - default: - return -EINVAL; - } - - return 0; + return enum_format(NULL, code, index, fmt_sel | PIXFMT_SEL_IPU, false); } EXPORT_SYMBOL_GPL(imx_media_enum_ipu_format); diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index ac7c521d8148..c61592750729 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -83,6 +83,7 @@ enum imx_pixfmt_sel { PIXFMT_SEL_YUV = BIT(0), /* select YUV formats */ PIXFMT_SEL_RGB = BIT(1), /* select RGB formats */ PIXFMT_SEL_BAYER = BIT(2), /* select BAYER formats */ + PIXFMT_SEL_IPU = BIT(3), /* select IPU-internal formats */ PIXFMT_SEL_YUV_RGB = PIXFMT_SEL_YUV | PIXFMT_SEL_RGB, PIXFMT_SEL_ANY = PIXFMT_SEL_YUV | PIXFMT_SEL_RGB | PIXFMT_SEL_BAYER, }; From patchwork Fri Apr 3 20:58:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210307 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=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, 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 8ACA4C2BA16 for ; Fri, 3 Apr 2020 20:58:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F812206F6 for ; Fri, 3 Apr 2020 20:58:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vctdou8E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728519AbgDCU66 (ORCPT ); Fri, 3 Apr 2020 16:58:58 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:41905 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727907AbgDCU66 (ORCPT ); Fri, 3 Apr 2020 16:58:58 -0400 Received: by mail-pg1-f196.google.com with SMTP id m13so126032pgd.8 for ; Fri, 03 Apr 2020 13:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BtfnuwGPseVG343HF/U5U+lpKHM1kxpxIYySf7VcBv8=; b=Vctdou8E+QuoSa5NyMGRwk7ExbUMyV4kRR/jDrNeA3m9im4BIG+Ta0o1SaLbxhbMPf IizoXdJzgGTNtZQNXYq9dOasE0Ox8kuAUBfJJTz6Xpkf+gKDpSpXGdTEEO3wCFlai1Cu utk5xOc400HRoGieqN+8r2LVzXlkGhbXQl2PLpNHSZgAFwruRKLfxX6mgPmiIVmm5vUL TFqrYZO8xfDsDTmiwK/+RwkjEuqY3vBoEF/GbEXz6npNtz+kzWHU9FIBdH0UpexvM0sS 229kHncAQLYtJ5O7D9s6uxwtz2LnjUgJYYpstzcnYAe1V4pWZWsHItl+TwhZKSNfEa7W ZWpw== 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=BtfnuwGPseVG343HF/U5U+lpKHM1kxpxIYySf7VcBv8=; b=g3Y7RZXbR4MGh4N9PXm4rxlKRAyyH/0Dfj8envzR0ruj8fPQe6RUI75ptJrOiqjoNx E5gQZ6Ni6aIXA4qLpTLPsK7HctPci3crzyp5nbD81fBnDDjHfNRfrjsM+dHvSnpLvu6W 13d0k88c3No14sq9N3dl3B5ATotbnjnHTGysxntSp79H6sbNoLOl781p09V2q5YHwTv1 5a173zqXEAMqUysOZvYtJT1hD+xgIiA9wXGOBh0Xfnrs3HYeTOXK02Dtp/xImMdY48X5 Ezdv5Pcw4e12HINIanD7+WEAYUAcIv54RRh9v+qQzqRbDJ84YQAqqctVKxEX96gVhbfK 1VXQ== X-Gm-Message-State: AGi0PuaSpXxu4FySsTMrQyZXclxFXAWIXbv387sBEuu/QhfP3b1RTo8o 5ClkprRk6LWQbGOdkUsEe6aq4TvVj9s= X-Google-Smtp-Source: APiQypJHni+6w6MVyUPgGyt5BQuqMmYxr86ky5V+EvJn8RoxMAEuRc9MC4d/NkBFy2+Hxv31LInYpQ== X-Received: by 2002:a63:b557:: with SMTP id u23mr9964954pgo.160.1585947536651; Fri, 03 Apr 2020 13:58:56 -0700 (PDT) Received: from mappy.world.mentorg.com (sjewanfw1-nat.mentorg.com. [139.181.7.34]) by smtp.gmail.com with ESMTPSA id s39sm6521266pjb.10.2020.04.03.13.58.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 13:58:56 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Laurent Pinchart , Philipp Zabel , Rui Miguel Silva , Steve Longerbeam Subject: [PATCH v5 08/12] media: imx: utils: Remove unneeded argument to (find|enum)_format() Date: Fri, 3 Apr 2020 13:58:35 -0700 Message-Id: <20200403205839.4531-9-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403205839.4531-1-slongerbeam@gmail.com> References: <20200403205839.4531-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The find_format() and enum_format() functions take an argument that tells whether to take into account formats that don't have associated media bus codes. The same information can be deduced from the fourcc argument passed to these functions. Remove the allow_non_mbus argument and use fourcc instead internally. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx-media-utils.c | 24 +++++++++------------ 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index 95913ab6d5b6..d9be04c68cc4 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -201,8 +201,7 @@ static const struct imx_media_pixfmt pixel_formats[] = { static const struct imx_media_pixfmt *find_format(u32 fourcc, u32 code, - enum imx_pixfmt_sel fmt_sel, - bool allow_non_mbus) + enum imx_pixfmt_sel fmt_sel) { bool sel_ipu = fmt_sel & PIXFMT_SEL_IPU; unsigned int i; @@ -221,8 +220,7 @@ static const struct imx_media_pixfmt *find_format(u32 fourcc, ((fmt->cs == IPUV3_COLORSPACE_YUV) ? PIXFMT_SEL_YUV : PIXFMT_SEL_RGB); - if (!(fmt_sel & sel) || - (!allow_non_mbus && !fmt->codes)) + if (!(fmt_sel & sel) || (!fourcc && !fmt->codes)) continue; if (fourcc && fmt->fourcc == fourcc) @@ -241,8 +239,7 @@ static const struct imx_media_pixfmt *find_format(u32 fourcc, } static int enum_format(u32 *fourcc, u32 *code, u32 index, - enum imx_pixfmt_sel fmt_sel, - bool allow_non_mbus) + enum imx_pixfmt_sel fmt_sel) { bool sel_ipu = fmt_sel & PIXFMT_SEL_IPU; unsigned int i; @@ -261,8 +258,7 @@ static int enum_format(u32 *fourcc, u32 *code, u32 index, ((fmt->cs == IPUV3_COLORSPACE_YUV) ? PIXFMT_SEL_YUV : PIXFMT_SEL_RGB); - if (!(fmt_sel & sel) || - (!allow_non_mbus && !fmt->codes)) + if (!(fmt_sel & sel) || (!fourcc && !fmt->codes)) continue; if (fourcc && index == 0) { @@ -291,41 +287,41 @@ static int enum_format(u32 *fourcc, u32 *code, u32 index, const struct imx_media_pixfmt * imx_media_find_format(u32 fourcc, enum imx_pixfmt_sel fmt_sel) { - return find_format(fourcc, 0, fmt_sel, true); + return find_format(fourcc, 0, fmt_sel); } EXPORT_SYMBOL_GPL(imx_media_find_format); int imx_media_enum_format(u32 *fourcc, u32 index, enum imx_pixfmt_sel fmt_sel) { - return enum_format(fourcc, NULL, index, fmt_sel, true); + return enum_format(fourcc, NULL, index, fmt_sel); } EXPORT_SYMBOL_GPL(imx_media_enum_format); const struct imx_media_pixfmt * imx_media_find_mbus_format(u32 code, enum imx_pixfmt_sel fmt_sel) { - return find_format(0, code, fmt_sel, false); + return find_format(0, code, fmt_sel); } EXPORT_SYMBOL_GPL(imx_media_find_mbus_format); int imx_media_enum_mbus_format(u32 *code, u32 index, enum imx_pixfmt_sel fmt_sel) { - return enum_format(NULL, code, index, fmt_sel, false); + return enum_format(NULL, code, index, fmt_sel); } EXPORT_SYMBOL_GPL(imx_media_enum_mbus_format); const struct imx_media_pixfmt * imx_media_find_ipu_format(u32 code, enum imx_pixfmt_sel fmt_sel) { - return find_format(0, code, fmt_sel | PIXFMT_SEL_IPU, false); + return find_format(0, code, fmt_sel | PIXFMT_SEL_IPU); } EXPORT_SYMBOL_GPL(imx_media_find_ipu_format); int imx_media_enum_ipu_format(u32 *code, u32 index, enum imx_pixfmt_sel fmt_sel) { - return enum_format(NULL, code, index, fmt_sel | PIXFMT_SEL_IPU, false); + return enum_format(NULL, code, index, fmt_sel | PIXFMT_SEL_IPU); } EXPORT_SYMBOL_GPL(imx_media_enum_ipu_format); From patchwork Fri Apr 3 20:58:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210306 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 70EE3C2BA12 for ; Fri, 3 Apr 2020 20:59:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 461B8206F6 for ; Fri, 3 Apr 2020 20:59:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SzOmBkBd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728535AbgDCU7A (ORCPT ); Fri, 3 Apr 2020 16:59:00 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33587 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727842AbgDCU7A (ORCPT ); Fri, 3 Apr 2020 16:59:00 -0400 Received: by mail-pf1-f195.google.com with SMTP id c138so4173529pfc.0 for ; Fri, 03 Apr 2020 13:58:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=22SfKmXY8y8+HRYeceGUgnGwyzx3xP3vR7j8AXHSr+8=; b=SzOmBkBdU4oSwRLH118b9JWWifu6jHTToUYxAZNgJvLBCIOZ/hkOGICOTvsz3YowMG gqxSpjrXQHBT1U/8DNXDVpmiU7wSvF+gTO06YbCcFwzFnWLP1RAhQ5PRRBcIofFfQO2t uSG91z+8RbsmOmM3WksbKubDkADL76SmHdtficXAAPiXWcDWK8NMNyKOSXNuoFpbwDj+ vdb9QNH4pv8h2UGA6Y/JFkZPfVNxW2A+Da9qNuB6xdGRzDU1rdcf1qomgeSSQzth1u3n OL1B99S/+DZ7vURgDZZPha5W28PyO2ai4Tces2edC/aebUns2ePUWyWUKc4zpx3oF4D+ 1ZHg== 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=22SfKmXY8y8+HRYeceGUgnGwyzx3xP3vR7j8AXHSr+8=; b=IYgS3Qp5N8cDHh4Q1r+YghMKB834I1OKeMh44ZDGXNEkfi21U2YTlHSbgwp+wpuskf Roy7uaE0jTQPkvLrg5i+ivRXQmzI8712seTqlTSP2rE+7t9IMwQ0H07xbxcopQu8atzh 6Q/q79vY2EubYYdk9DqCgKFTaxxsw1Pl5S0ru7Gm8nYcD4xzD3YAeat/hVHxtSSMAip0 np+2lRozvgm1tKbjpD9WMmL1HppNtqTic5ejCo1aDMqFy8reWuwTgfVV+VcKRB07cz9i 8meQsLFV31bBwIsPLyypdEZoDUmVvgVwx3zLgJazzzPVBH/fSA9gcYmtxHxPo+Vsh5tm cS7Q== X-Gm-Message-State: AGi0PuYGWxjAkwCuCVOpF/FRi89EnGdKHE7Uy8thTqXortWPAyBPXn09 KBVc8ILoAfQ+8M+8B9FkMHPxqye1pts= X-Google-Smtp-Source: APiQypKzQ6A5sRscZ+B2zsAcvLsN6MCdx89J4xP/DKl7NNLR8lgxviodeR00E1QoKaNbU6JWf+NddQ== X-Received: by 2002:a63:2a88:: with SMTP id q130mr9646321pgq.102.1585947539125; Fri, 03 Apr 2020 13:58:59 -0700 (PDT) Received: from mappy.world.mentorg.com (sjewanfw1-nat.mentorg.com. [139.181.7.34]) by smtp.gmail.com with ESMTPSA id s39sm6521266pjb.10.2020.04.03.13.58.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 13:58:58 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Laurent Pinchart , Philipp Zabel , Rui Miguel Silva , Steve Longerbeam Subject: [PATCH v5 10/12] media: imx: utils: Constify mbus argument to imx_media_mbus_fmt_to_* Date: Fri, 3 Apr 2020 13:58:37 -0700 Message-Id: <20200403205839.4531-11-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403205839.4531-1-slongerbeam@gmail.com> References: <20200403205839.4531-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The imx_media_mbus_fmt_to_pix_fmt() and imx_media_mbus_fmt_to_ipu_image() functions do not need to modify their mbus argument. Make them const. Signed-off-by: Laurent Pinchart [Constified mbus arg to imx_media_mbus_fmt_to_ipu_image() as well] Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-utils.c | 4 ++-- drivers/staging/media/imx/imx-media.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index b8481b286ebb..7a8d7212d9e2 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -455,7 +455,7 @@ void imx_media_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt, EXPORT_SYMBOL_GPL(imx_media_try_colorimetry); int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, - struct v4l2_mbus_framefmt *mbus, + const struct v4l2_mbus_framefmt *mbus, const struct imx_media_pixfmt *cc) { u32 width; @@ -507,7 +507,7 @@ int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, EXPORT_SYMBOL_GPL(imx_media_mbus_fmt_to_pix_fmt); int imx_media_mbus_fmt_to_ipu_image(struct ipu_image *image, - struct v4l2_mbus_framefmt *mbus) + const struct v4l2_mbus_framefmt *mbus) { int ret; diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index 24a993b3216b..c03114a6f6c8 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -184,10 +184,10 @@ int imx_media_init_cfg(struct v4l2_subdev *sd, void imx_media_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt, bool ic_route); int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, - struct v4l2_mbus_framefmt *mbus, + const struct v4l2_mbus_framefmt *mbus, const struct imx_media_pixfmt *cc); int imx_media_mbus_fmt_to_ipu_image(struct ipu_image *image, - struct v4l2_mbus_framefmt *mbus); + const struct v4l2_mbus_framefmt *mbus); int imx_media_ipu_image_to_mbus_fmt(struct v4l2_mbus_framefmt *mbus, struct ipu_image *image); void imx_media_grp_id_to_sd_name(char *sd_name, int sz, From patchwork Fri Apr 3 20:58:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210305 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 EB84AC2BA19 for ; Fri, 3 Apr 2020 20:59:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BAFF1206F6 for ; Fri, 3 Apr 2020 20:59:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nDLd2Yma" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728536AbgDCU7C (ORCPT ); Fri, 3 Apr 2020 16:59:02 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:41110 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727842AbgDCU7B (ORCPT ); Fri, 3 Apr 2020 16:59:01 -0400 Received: by mail-pf1-f193.google.com with SMTP id a24so4149668pfc.8 for ; Fri, 03 Apr 2020 13:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4oLLDK4+SS1hLQO0L6gmLzpjq2x1arrGpoAygELn+fc=; b=nDLd2YmaJzNZ+zWAc08DFUfNokRDka4h5ZZPv4iNmcSpJlo9W8IH/AaHFAfHBB1IbY io8PtgiZCVmBUOe2KcwyB7Hw98j+IfbDLorUu80b4irx3lN8rQNDqpaI+smeWjhKdml9 jGLODwZFTCSxH/66Iy9pIcTeDywCO3kf2y018wsBCmKlqj6d3XZficEaKxdTPWVZL5Lk JDUx8icaFnWKnCk/24HVHBwfX0GEP1OkJz0c//wd0X/Z1FPNaN2gSqEscJDtPl7mHnpw VqyPEG/0F240NQ+vCkecylJEp8ZGFLpgPcn3gZaZNzN/Djreo9UJqhG3NlZrX9e+qUjP D9Fw== 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=4oLLDK4+SS1hLQO0L6gmLzpjq2x1arrGpoAygELn+fc=; b=VEdX8EyUvrpWTUobiKL5dcBV7O1MoucqkvOoYrLVXqtcVywbMnwRrp7AISpWjZxqKc ZoccPBOx4vyI2Apv8az/okpiSa7nms/F7HCcpAjwuiAh5w7zSVhPnsQ224/R50rmpf5B Vhih/vj+Lc0pLBENhJ2eeMzt9iFDEVBUeM/uMd/7RU+frO7yrVWE9XXEM+/+GJkKdN7h Oq1ZmEu1ik6kFURTssIBYYLp5AB3srHM4hfOP4DCHwx+TjJ5TQgKdpgDrmrlW1gfGfK0 WdqupuN4+K+UUQUtwjiE44gVt+4YFvvxi1+kUNVrRQ7q+7RDQ3cpzNopk2qAk7AW+VCz CA2w== X-Gm-Message-State: AGi0PuZeZJIYMQT1ku+7aZ31Djuhsg6e1ZHniSrvjIndo17POHTVrHOl 1ynCeDZhICKxjZkXIb/lw6Yinibf2kk= X-Google-Smtp-Source: APiQypKPg/8+LTI1Qp1iQCPv7uZ3l/iR60CZ6Aezpex0ZNkFajtSPpk1CKe4CbG7KOqYppOmyV6Mtg== X-Received: by 2002:a63:f849:: with SMTP id v9mr9844424pgj.116.1585947540308; Fri, 03 Apr 2020 13:59:00 -0700 (PDT) Received: from mappy.world.mentorg.com (sjewanfw1-nat.mentorg.com. [139.181.7.34]) by smtp.gmail.com with ESMTPSA id s39sm6521266pjb.10.2020.04.03.13.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2020 13:58:59 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Laurent Pinchart , Philipp Zabel , Rui Miguel Silva , Steve Longerbeam Subject: [PATCH v5 11/12] media: imx: utils: Constify ipu_image argument to imx_media_ipu_image_to_mbus_fmt() Date: Fri, 3 Apr 2020 13:58:38 -0700 Message-Id: <20200403205839.4531-12-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200403205839.4531-1-slongerbeam@gmail.com> References: <20200403205839.4531-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The imx_media_ipu_image_to_mbus_fmt() function doesn't need to modify its ipu_image argument. Make it const. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-utils.c | 2 +- drivers/staging/media/imx/imx-media.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index 7a8d7212d9e2..f8bd0ff32049 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -525,7 +525,7 @@ int imx_media_mbus_fmt_to_ipu_image(struct ipu_image *image, EXPORT_SYMBOL_GPL(imx_media_mbus_fmt_to_ipu_image); int imx_media_ipu_image_to_mbus_fmt(struct v4l2_mbus_framefmt *mbus, - struct ipu_image *image) + const struct ipu_image *image) { const struct imx_media_pixfmt *fmt; diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index c03114a6f6c8..af806ecc67a9 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -189,7 +189,7 @@ int imx_media_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, int imx_media_mbus_fmt_to_ipu_image(struct ipu_image *image, const struct v4l2_mbus_framefmt *mbus); int imx_media_ipu_image_to_mbus_fmt(struct v4l2_mbus_framefmt *mbus, - struct ipu_image *image); + const struct ipu_image *image); void imx_media_grp_id_to_sd_name(char *sd_name, int sz, u32 grp_id, int ipu_id); struct v4l2_subdev *