Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1849099pxb; Wed, 9 Feb 2022 05:56:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQ7A+TGiZ8qWJWIvZl0Ha39QIL1S+5B8EGWALQufBSh65zwlMwnb6gTtiuDnIzoDlRHUxf X-Received: by 2002:a17:902:8c87:: with SMTP id t7mr2240808plo.170.1644414985264; Wed, 09 Feb 2022 05:56:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644414985; cv=none; d=google.com; s=arc-20160816; b=aKytWSkafJWjo+dSUGegPNMBc4h6f7ZGtafJDb8FJ1MmUZvoqAw3qcKOAIetWbqRV3 vDyQLael1KxxWPITgg8pwad7usatmr5CWu4mRo2HlezEPnPk5f+Z1/6FLbyZ+BUY1t77 rQm/lV6zkszHT/R/jvgvtlGMafIIADeXQiCzM0PJCy545oZs12oJSttQsY9Te1hGyaID 0ndQWwlhx36xQMGuYk4ScWPgH3vbCcnq+pUtqAUdXLhGAh1XxkEy9HU1jcFpWFN9GHI7 K5sItAVqQxlCsZc2LZ5kt1XP+YRu+PQ1cAdJ2fGN6aqORTqwxVMkw9CqKwmd61vWPHLl ryNw== 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:to:from; bh=8MIYJPF1o5foL+udhOPXP8PtWoeUeKf1hSe0lgYOH5s=; b=VeNESbfOUUlr4PYRpXWGKkfiPIW3BqDzxfzBBO2bIqJGEu1YP+LZ3UwUmMZD0lwX7W WbwX5ZfpFoJWHf7D1jyBNXcVgQPUVVZgw4ozMqBmq4/PurGeq9s/lgUBWBvm0E/dzqGj BHn0KZ1Y1L9edfZJXoz+75FZ8Vypc3q3M1kPYzJQyuunNotd52reY3c08LkHxD4Ffucl 2RG2cGdr6lcL9ZkaPjpmd2aYYpkppUHglFI6B7Df1omq9/xBRhltSbU6qkJYnhnNpYrK DFZZO0P7g9TlpZYqGlXEDMu+2jUGPbnvyVDJ4Lpsi1/D04lh855zfYDI0TYa0NxAP0mo EAOw== 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:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id oc1si6030891pjb.183.2022.02.09.05.56.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 05:56:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1836BE1763DA; Wed, 9 Feb 2022 02:35:16 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234564AbiBIJjR (ORCPT + 99 others); Wed, 9 Feb 2022 04:39:17 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:53092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233595AbiBIJfF (ORCPT ); Wed, 9 Feb 2022 04:35:05 -0500 Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44CA6E011168 for ; Wed, 9 Feb 2022 01:34:55 -0800 (PST) Received: from twspam01.aspeedtech.com (localhost [127.0.0.2] (may be forged)) by twspam01.aspeedtech.com with ESMTP id 2198ZbGv073078 for ; Wed, 9 Feb 2022 16:35:37 +0800 (GMT-8) (envelope-from jammy_huang@aspeedtech.com) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 2198YGiU072902; Wed, 9 Feb 2022 16:34:16 +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; Wed, 9 Feb 2022 16:42:27 +0800 From: Jammy Huang To: , , , , , , , , Subject: [PATCH v2] media: aspeed: Use full swing as JFIF to fix incorrect color Date: Wed, 9 Feb 2022 16:42:25 +0800 Message-ID: <20220209084225.4456-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 2198YGiU072902 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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. Signed-off-by: Jammy Huang --- 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..5bcf60b4628b 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 = 0, + VIDEO_CAP_FMT_YUV_FULL, + 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); u32 seq_ctrl = video->jpeg_mode; if (video->frame_rate) -- 2.25.1