Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2758307pxb; Thu, 10 Feb 2022 05:05:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4T35KOzuZF6iDuU+sN42gBi4vp0u342LDVfwxsG+A/MOMC7fGrNlAvLVxomcHUDz+ry2l X-Received: by 2002:a17:906:782:: with SMTP id l2mr6220272ejc.631.1644498330298; Thu, 10 Feb 2022 05:05:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644498330; cv=none; d=google.com; s=arc-20160816; b=cc6ThR22NSOsXp3NeIaR2x1IhG7rTGN7ZljwLcn4eo6YomBGmiPXyqKV76KilAb/7D h66wZ5YUHuSmXemWo1fvt25Nawg0tDGUslTI4L/u53IDXkkLYkU4ccILYWQDmHVXFZ95 E/MAWphUzfA+hTD2xRVyEqjkdX7HgZkUPFfri5O89eiMlHWdmbIURSKcQV2mQdLQmYir 5Av2vF3lJFmjsjoL5QE3U9hIqgsa5wVLnRm6OnrssVl368rfpWF7a4vYyEYLyFCXxWzZ ptAQXqnMl88yO2S++oQYb9NuEXRQ7sBa4qeMU0c+W2LKkgRk7ZRS3ZnZRgkzFFvvdLRc TlOg== 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 :message-id:date:subject:cc:to:from; bh=bK5x3UJB52K+bQb/1Z3fXQoV5wctiCwLMripJSIirTo=; b=l0qZlwOhksIwDgtNM5pkEoLix0thRJXTQ0N2bYHJSNd7fwOODxu5aVWT5+OXz7e3bH vAO+jqzGWMCJbefTjl8bQqTdxjLQyuvZ/H126lyhQLbhk4RRO3M7YUmmgmGmgDFtCWSE tDN8Ie5EMGHz6g+eCg/t0PXn237Mol/igomA1UWgUv1wEUELI+XwnhrTRUaTnjaWl3uP D6pFaGY+yOOsKYV/qwCOtMq9AlSfy4W6w9mHcxHqUJUFR+hEmL2D7XG/NWdxQpoR0mt2 0mzXKf9AElDQJe3lHX4akpgnE+levaReSbEFMmOUA8JZgjCvRmUMuY9GoC4euH059M4/ Mvug== ARC-Authentication-Results: i=1; mx.google.com; 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 l7si5163760ejk.860.2022.02.10.05.05.03; Thu, 10 Feb 2022 05:05:30 -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; 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 S238620AbiBJJaZ (ORCPT + 99 others); Thu, 10 Feb 2022 04:30:25 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238790AbiBJJaL (ORCPT ); Thu, 10 Feb 2022 04:30:11 -0500 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 893A710DF for ; Thu, 10 Feb 2022 01:29:51 -0800 (PST) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 21A9LU10015199; Thu, 10 Feb 2022 17:21:30 +0800 (GMT-8) (envelope-from jammy_huang@aspeedtech.com) Received: from JammyHuang-PC.aspeed.com (192.168.2.115) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Feb 2022 17:29:43 +0800 From: Jammy Huang To: , , , , , , , , CC: Paul Menzel Subject: [PATCH v3] media: aspeed: Use full swing as JFIF to fix incorrect color Date: Thu, 10 Feb 2022 17:29:45 +0800 Message-ID: <20220210092945.5027-1-jammy_huang@aspeedtech.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [192.168.2.115] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 21A9LU10015199 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Current settings for video capture rgb-2-yuv is BT.601(studio swing), but JFIF uses BT.601(full swing) to deocde. This mismatch will lead to incorrect color. For example, input RGB value, (0, 0, 255), will become (16, 16, 235) after jpg decoded. Add an enum, aspeed_video_capture_format, to define VR008[7:6] capture format and correct default settings for video capture to fix the problem. VR008[7:6] decides the data format for video capture as below: * 00: CCIR601 studio swing compliant YUV format * 01: CCIR601 full swing compliant YUV format * 10: RGB format * 11: Gray color mode Signed-off-by: Jammy Huang Reviewed-by: Paul Menzel --- v3: - update commit message - update enum's naming to append '_SWING' v2: - update subject from 'media: aspeed: Fix-incorrect-color' to 'media: aspeed: Use full swing as JFIF to fix incorrect' - update commit message - add enum, aspeed_video_capture_format, to define VR008[7:6] --- drivers/media/platform/aspeed-video.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c index eb9c17ac0e14..ee702f9b708b 100644 --- a/drivers/media/platform/aspeed-video.c +++ b/drivers/media/platform/aspeed-video.c @@ -86,8 +86,6 @@ #define VE_CTRL_SOURCE BIT(2) #define VE_CTRL_INT_DE BIT(4) #define VE_CTRL_DIRECT_FETCH BIT(5) -#define VE_CTRL_YUV BIT(6) -#define VE_CTRL_RGB BIT(7) #define VE_CTRL_CAPTURE_FMT GENMASK(7, 6) #define VE_CTRL_AUTO_OR_CURSOR BIT(8) #define VE_CTRL_CLK_INVERSE BIT(11) @@ -202,6 +200,15 @@ enum { VIDEO_CLOCKS_ON, }; +// for VE_CTRL_CAPTURE_FMT +enum aspeed_video_capture_format { + VIDEO_CAP_FMT_YUV_STUDIO_SWING = 0, + VIDEO_CAP_FMT_YUV_FULL_SWING, + VIDEO_CAP_FMT_RGB, + VIDEO_CAP_FMT_GRAY, + VIDEO_CAP_FMT_MAX +}; + struct aspeed_video_addr { unsigned int size; dma_addr_t dma; @@ -1089,7 +1096,8 @@ static void aspeed_video_init_regs(struct aspeed_video *video) u32 comp_ctrl = VE_COMP_CTRL_RSVD | FIELD_PREP(VE_COMP_CTRL_DCT_LUM, video->jpeg_quality) | FIELD_PREP(VE_COMP_CTRL_DCT_CHR, video->jpeg_quality | 0x10); - u32 ctrl = VE_CTRL_AUTO_OR_CURSOR; + u32 ctrl = VE_CTRL_AUTO_OR_CURSOR | + FIELD_PREP(VE_CTRL_CAPTURE_FMT, VIDEO_CAP_FMT_YUV_FULL_SWING); u32 seq_ctrl = video->jpeg_mode; if (video->frame_rate) -- 2.25.1