Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp380151rwb; Fri, 18 Nov 2022 02:53:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf5lW27GbUM5wAGcFWsjhZvZ5RP1/5j1T2YhVHj/ROmH+vEkH6JmZqgwUF/+/ZXaP8PN+IAt X-Received: by 2002:a17:903:41c9:b0:186:5eab:8631 with SMTP id u9-20020a17090341c900b001865eab8631mr7189719ple.134.1668768788241; Fri, 18 Nov 2022 02:53:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668768788; cv=none; d=google.com; s=arc-20160816; b=MT7QK3h6jLPv9EISdI+CzBcnqedkTo8qkERn/EwduuJ3sxeYsLeN5QBT4vvEYVLDBO AsINpDyqLSKLP6gMpLK5rBjrdajEpo2YFd7BEoANBODyh/5oYjT729cntmz6o2IX/3T0 N6Ml+Fi78cIGoTNnmf2raQGNvvuM5CBqzPucLDcfUPkAqpTyyJGt1P5UZdynaGu5rhwO WpGfMhC4AfWwUtLjLB2z9gW/dE94O6tvsyw07Fqt1TlZ7lj3e4+aKhVql/ZtxBPdAnnq xuaTib3306YoU/f7mnBSkAbhsFOHn54bkXvxDSvcIyc7fjYEXHmdJ2lMp/4LruYnW2Gc dUCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TUOZR/kK3tv+eVRKPWxRMFEGDQFu2a+bVBCijuc1ZCA=; b=Je50mQbB5iS+4Koqdsam2CjeT0dAXXLPsnt3mbx3Kv8u1T+njHamwsrUMN9eN3Xwy6 Zu6q9ajjsgz7dMvAyV2KQ2+N3ZISq2zBJuD2JmZ1au4DeGSkI5djl/sWLBy+zNoeiI3b S3ZRB/Bbql6XWq4+Hl1tR/BHb97zYWbJuxmyuxK/fvOzhmnSWuhDtnad61OsixR91LVg VRasHp7MN4oYpljnjL47nx74Fqwwn1IrFPuo1yzEpCAOjWKPouqnIv+QiSVjH0WX+7Mu 7Q1LgPZbr+/LPtVL9BTYny5XbfaaAOb1jP3PTsGRB6bkwh8cgcbg9j6vjIyErhR0ndeE dj5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=BPWRwwZk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w6-20020a63f506000000b004700a4a4a29si3548467pgh.663.2022.11.18.02.52.53; Fri, 18 Nov 2022 02:53:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=BPWRwwZk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241505AbiKRJmV (ORCPT + 91 others); Fri, 18 Nov 2022 04:42:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241107AbiKRJl0 (ORCPT ); Fri, 18 Nov 2022 04:41:26 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83DB997089; Fri, 18 Nov 2022 01:40:40 -0800 (PST) Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B79A8CE1; Fri, 18 Nov 2022 10:40:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1668764439; bh=rsTVUhZ7ZI6UsQMfahLSuxDlhDEF5B7vCEr3t98B15M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BPWRwwZkjC9FzC+D3DSeZl54u6MeB1z2XeCJFsY2ndTK8H+9+X2beUZESLC/LkFiT z+G0NshynQOO6YZZQKpi6YgMG51M6YnN9ac94/xCHe3t5dmmnhhra/nsrDBrwxpHDd SX+nixP1/dIw/u9vGWRhmz7zlsyaaMXsK6+kVFKA= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , Dafna Hirschfeld , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Helen Koike , Laurent Pinchart , linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 14/14] media: rkisp1: Add UYVY as an output format Date: Fri, 18 Nov 2022 18:39:31 +0900 Message-Id: <20221118093931.1284465-15-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221118093931.1284465-1-paul.elder@ideasonboard.com> References: <20221118093931.1284465-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for UYVY as an output format. The uv_swap bit in the MI_XTD_FORMAT_CTRL register that is used for the NV formats does not work for packed YUV formats. Thus, UYVY support is implemented via byte-swapping. This method clearly does not work for implementing support for YVYU and VYUY. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-capture.c | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c index 29565440b6e7..8a6a5d25a3b8 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c @@ -97,6 +97,12 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_mp_fmts[] = { .uv_swap = 0, .write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT, .mbus = MEDIA_BUS_FMT_YUYV8_2X8, + }, { + .fourcc = V4L2_PIX_FMT_UYVY, + .uv_swap = 0, + .yc_swap = 1, + .write_format = RKISP1_MI_CTRL_MP_WRITE_YUVINT, + .mbus = MEDIA_BUS_FMT_YUYV8_2X8, }, { .fourcc = V4L2_PIX_FMT_YUV422P, .uv_swap = 0, @@ -221,6 +227,13 @@ static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] = { .write_format = RKISP1_MI_CTRL_SP_WRITE_INT, .output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422, .mbus = MEDIA_BUS_FMT_YUYV8_2X8, + }, { + .fourcc = V4L2_PIX_FMT_UYVY, + .uv_swap = 0, + .yc_swap = 1, + .write_format = RKISP1_MI_CTRL_SP_WRITE_INT, + .output_format = RKISP1_MI_CTRL_SP_OUTPUT_YUV422, + .mbus = MEDIA_BUS_FMT_YUYV8_2X8, }, { .fourcc = V4L2_PIX_FMT_YUV422P, .uv_swap = 0, @@ -442,6 +455,20 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap) rkisp1_write(rkisp1, RKISP1_CIF_MI_XTD_FORMAT_CTRL, reg); } + /* + * U/V swapping with the MI_XTD_FORMAT_CTRL register only works for + * NV12/NV21 and NV16/NV61, so instead use byte swap to support UYVY. + * YVYU and VYUY cannot be supported with this method. + */ + if (rkisp1->info->features & RKISP1_FEATURE_MI_OUTPUT_ALIGN) { + reg = rkisp1_read(rkisp1, RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT); + if (cap->pix.cfg->yc_swap) + reg |= RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_BYTE_SWAP_BYTES; + else + reg &= ~RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_BYTE_SWAP_BYTES; + rkisp1_write(rkisp1, RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT, reg); + } + rkisp1_mi_config_ctrl(cap); reg = rkisp1_read(rkisp1, RKISP1_CIF_MI_CTRL); @@ -483,6 +510,20 @@ static void rkisp1_sp_config(struct rkisp1_capture *cap) rkisp1_write(rkisp1, RKISP1_CIF_MI_XTD_FORMAT_CTRL, reg); } + /* + * U/V swapping with the MI_XTD_FORMAT_CTRL register only works for + * NV12/NV21 and NV16/NV61, so instead use byte swap to support UYVY. + * YVYU and VYUY cannot be supported with this method. + */ + if (rkisp1->info->features & RKISP1_FEATURE_MI_OUTPUT_ALIGN) { + reg = rkisp1_read(rkisp1, RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT); + if (cap->pix.cfg->yc_swap) + reg |= RKISP1_CIF_OUTPUT_ALIGN_FORMAT_SP_BYTE_SWAP_BYTES; + else + reg &= ~RKISP1_CIF_OUTPUT_ALIGN_FORMAT_SP_BYTE_SWAP_BYTES; + rkisp1_write(rkisp1, RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT, reg); + } + rkisp1_mi_config_ctrl(cap); mi_ctrl = rkisp1_read(rkisp1, RKISP1_CIF_MI_CTRL); -- 2.35.1