From patchwork Sat Mar 25 20:56:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13187889 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9364C6FD20 for ; Sat, 25 Mar 2023 20:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229446AbjCYU4I (ORCPT ); Sat, 25 Mar 2023 16:56:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbjCYU4H (ORCPT ); Sat, 25 Mar 2023 16:56:07 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7412FA5CB; Sat, 25 Mar 2023 13:56:06 -0700 (PDT) Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 04A519A8; Sat, 25 Mar 2023 21:56:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1679777765; bh=g4tzjIW8B+784pTs2VxFlpddIhr0cvUc79i3cDR9EOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IKKxHqEUt605ozw049O+6TjyA/VzahOsEIh3l5Hz8t0bdincMkaqs7589eWNbLz6E U3vJL1esBEYHbu7xhAZSB5vCaaILwO2MQUudxcevUfvdn/jQT2cN4tj+s24Q+YolLl oEw/zWnnhotTVCZBr05dcJQK2jOgFftuQRAHtRm8= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Hans Verkuil Subject: [PATCH v2 1/2] media: i2c: adv7604: Enable video adjustment Date: Sat, 25 Mar 2023 22:56:09 +0200 Message-Id: <20230325205610.22583-2-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230325205610.22583-1-laurent.pinchart+renesas@ideasonboard.com> References: <20230325205610.22583-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The video adjustments (contrast, brightness, saturation and hue) are ignored by default by the device when the VID_ADJ_EN bit is clear. The corresponding V4L2 controls exposed by the drivers have thus no effect. Fix this by setting the VID_ADJ_EN bit. Signed-off-by: Laurent Pinchart Reviewed-by: Hans Verkuil Tested-by: Hans Verkuil --- drivers/media/i2c/adv7604.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 9d218962d7c8..3af0e67f9edb 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -1805,6 +1805,9 @@ static void select_input(struct v4l2_subdev *sd) v4l2_dbg(2, debug, sd, "%s: Unknown port %d selected\n", __func__, state->selected_input); } + + /* Enable video adjustment (contrast, saturation, brightness and hue) */ + cp_write_clr_set(sd, 0x3e, 0x80, 0x80); } static int adv76xx_s_routing(struct v4l2_subdev *sd, From patchwork Sat Mar 25 20:56:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13187888 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A41EC761AF for ; Sat, 25 Mar 2023 20:56:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbjCYU4J (ORCPT ); Sat, 25 Mar 2023 16:56:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbjCYU4J (ORCPT ); Sat, 25 Mar 2023 16:56:09 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D40D7C67A; Sat, 25 Mar 2023 13:56:07 -0700 (PDT) Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 52B668BE; Sat, 25 Mar 2023 21:56:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1679777766; bh=K00sWT6G9YL80+EFBD9tP6tnYHB73AO58k5Tc+jOBG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A6DQXFOb1/LnlxmH9TcDoM4AchXGYFQAq3pZHBS/e9GkfGJ70rSS6tXhTIn8VTvnc G8jBNghlw8Jjy74NgQGX5u4BbAAZSSSQEjvRdW1yBcLH0FmRmwJq+rRTZcRj1Sry9c Obj3exspNDHQf9jiM4MXu5YHwCU7RX+iwP60HDU8= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Hans Verkuil Subject: [PATCH v2 2/2] media: i2c: adv7604: Fix range of hue control Date: Sat, 25 Mar 2023 22:56:10 +0200 Message-Id: <20230325205610.22583-3-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230325205610.22583-1-laurent.pinchart+renesas@ideasonboard.com> References: <20230325205610.22583-1-laurent.pinchart+renesas@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The ADV7604, ADV7611 and ADV7612 software manuals document the CP_HUE value differently: - For ADV7604 and ADV7611, the hue is specified as an unsigned 8-bit value, and calculated as (CP_HUE[7:0] * 180) / 256 - 90 with the range set to [-90°, 90°]. Additionally, the values 0x00, 0x0f and 0xff are documented as corresponding to -90°, 0° and 90° respectively. - For ADV7612, the hue is specified as a signed 8-bit value in the range [0°, 360°[ without any formula. Additionally, the value 0x00 is documented as corresponding to 0°. The ADV7604 and ADV7611 documentation is clearly wrong as the example values don't correspond to the formula. Furthermore, the [-90°, 90°] range seems incorrect as it would cover only half of the hue space. The ADV7612 documentation is better, although the range should likely be [-180°, 180°[ if the value is signed. Given that the values wrap around, this makes no difference in practice. The hue values have been verified on ADV7612 to follow the documentation. There is a high chance they do as well on ADV7604 and ADV7611. In any case, all software manuals document the register as 8-bit, so the current range of the V4L2 hue control [0, 128] is not correct. Expand it to cover the full 8-bit space, using unsigned values to avoid breaking any application that may rely on 128 being a valid value. Signed-off-by: Laurent Pinchart Reviewed-by: Hans Verkuil Tested-by: Hans Verkuil --- Changes since v1: - Fix typo in commit message --- drivers/media/i2c/adv7604.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 3af0e67f9edb..3d0898c4175e 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -3548,7 +3548,7 @@ static int adv76xx_probe(struct i2c_client *client) v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops, V4L2_CID_SATURATION, 0, 255, 1, 128); v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops, - V4L2_CID_HUE, 0, 128, 1, 0); + V4L2_CID_HUE, 0, 255, 1, 0); ctrl = v4l2_ctrl_new_std_menu(hdl, &adv76xx_ctrl_ops, V4L2_CID_DV_RX_IT_CONTENT_TYPE, V4L2_DV_IT_CONTENT_TYPE_NO_ITC, 0, V4L2_DV_IT_CONTENT_TYPE_NO_ITC);