From patchwork Wed Feb 22 22:12:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13149624 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 836BEC6379F for ; Wed, 22 Feb 2023 22:14:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232664AbjBVWOv (ORCPT ); Wed, 22 Feb 2023 17:14:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232884AbjBVWOd (ORCPT ); Wed, 22 Feb 2023 17:14:33 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E43BD474F7 for ; Wed, 22 Feb 2023 14:14:04 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id da10so37612202edb.3 for ; Wed, 22 Feb 2023 14:14:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LTEndFXZ/l1vDOfzmYbg3ZufQ1osqUOSn+fpUklZzgo=; b=Iyuy6frOKBtwCAC0jTBbHeUubipxvnbXn6Pe9dNSehaH6IyV9WGI4TQCAT88rt+39G gsOAiL0HYz0uzzxkVB2dgH5UsqVUJ9lkQJjpSbbWXkGUXyAdvWcYBI2E96sYcY9SBTMS WEzDny6Bfy3Eox7VrhXNBGkpDATjkJEjGjq+x1mnz7dDPNBQ+DA+To77NoSOfPLPz8l1 mBp4mxaNKh3U9lmSFRTA8mkl7ZJEafDG5lvzAR5AQ4D3QzeLeJFiGDCxwjZHAFDLhreA u9QURia/t7eiGdlQJctXoFff6nBqA7M9JKUpYX1wyv9F7eWWICS+pbhKz6vGt8ag+ybX JFnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LTEndFXZ/l1vDOfzmYbg3ZufQ1osqUOSn+fpUklZzgo=; b=PucbPGN2D22IdHMq68MaA86K5zIHaorHDQlweDIpd29dLfBYpqp8MINbKc3y1v+LsN JsK1XIB9PXHW93dIgFCvn2oxQnMTdoii3f0fTyCD6VNOmE2NihkUi8MafZq8T5N2iIEA 4g5ON7jpo51gEmc+R5tS+5Kb76+YleLp2BvSbKnzGAI1sjzxXDYmq1RPJYHEbCAcE+an WMqr3K4d7fiIdK7pJezn9XQdUqI7bp3qc1oJa1gvFGj36iy86sXKHget3fuFsNtaVdlp BN3osQ+e821tO8SNzn1YM3Hy6CokK+PbkLC9h42NRMC7OfXQmcqf2ZLv+Dv39mDyjyLi TAyQ== X-Gm-Message-State: AO0yUKXVYEBHXrUfznQTbLIUxNqNX1eqJtELc71aPmA8qQsERZSEzP3A hdLQX8ZFG0iFpBoaz1mJc4QhwmjBIelpONGd X-Google-Smtp-Source: AK7set/TRpEFhpMT+/2HLh4qIz7Z+rHiLTXj+0HwclPVQW3m8WdkCp23shUFujeRnIwV6PEKm11bBA== X-Received: by 2002:a50:ed0c:0:b0:4af:601c:ea21 with SMTP id j12-20020a50ed0c000000b004af601cea21mr3921313eds.38.1677104040607; Wed, 22 Feb 2023 14:14:00 -0800 (PST) Received: from sleipner.berto.se (p54ac5802.dip0.t-ipconnect.de. [84.172.88.2]) by smtp.googlemail.com with ESMTPSA id a26-20020a170906685a00b008b1b86bf668sm7711893ejs.4.2023.02.22.14.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 14:14:00 -0800 (PST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Kieran Bingham , Hans Verkuil , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH 1/3] media: i2c: adv748x: Fix lookup of DV timings Date: Wed, 22 Feb 2023 23:12:47 +0100 Message-Id: <20230222221249.1324102-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230222221249.1324102-1-niklas.soderlund+renesas@ragnatech.se> References: <20230222221249.1324102-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The loop to match the requested timings with the ones supported by the driver is incorrect. It always iterates thru the whole array of supported modes. The bounds check after the loop always triggers resulting in adv748x_hdmi_set_video_timings() always returning -EINVAL. Fix this by correcting the lookup to break the loop when a match is found. Signed-off-by: Niklas Söderlund Reviewed-by: Geert Uytterhoeven --- drivers/media/i2c/adv748x/adv748x-hdmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/adv748x/adv748x-hdmi.c b/drivers/media/i2c/adv748x/adv748x-hdmi.c index 52fa7bd75660..1d62e05572cd 100644 --- a/drivers/media/i2c/adv748x/adv748x-hdmi.c +++ b/drivers/media/i2c/adv748x/adv748x-hdmi.c @@ -176,9 +176,9 @@ static int adv748x_hdmi_set_video_timings(struct adv748x_state *state, unsigned int i; for (i = 0; i < ARRAY_SIZE(adv748x_hdmi_video_standards); i++) { - if (!v4l2_match_dv_timings(timings, &stds[i].timings, 250000, - false)) - continue; + if (v4l2_match_dv_timings(timings, &stds[i].timings, 250000, + false)) + break; } if (i >= ARRAY_SIZE(adv748x_hdmi_video_standards)) From patchwork Wed Feb 22 22:12:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13149625 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 261B1C64EC7 for ; Wed, 22 Feb 2023 22:14:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232686AbjBVWOw (ORCPT ); Wed, 22 Feb 2023 17:14:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232896AbjBVWOf (ORCPT ); Wed, 22 Feb 2023 17:14:35 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D741C5B86 for ; Wed, 22 Feb 2023 14:14:06 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id cy6so30889534edb.5 for ; Wed, 22 Feb 2023 14:14:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qGUJrtnlz9Yo3S83G8V63+H0kWn768DHMiymUEO8oRc=; b=VxGB6sPzhAIZM/XP47p7RUWvv+v6HYDJk5eU+CCIqVYqkRzjaH/GWNvz3F2+KZ4JGz mYHNTdFq66G8rEKmRtY5IjyEVpiXJ6Z/0dIpkYbWs0m7X4hFWKpdA2HtVQixrxTz42WF L46WsTdiuRbGWo0akeCzeSXsQxnXB2wtViFjDrm1AwWZm6UjkvzKguLARL0eJai+RFCp sQnWio5sMclVv8E8ykN7nUsZv8nFMXt3+0LjVp7MzC2+vpJhJ3Pl4cH2NqTczkJ3dE+x x29h82Vwva1vS9g6u/pnB4zXINjqdZZc3qwy7sLruh4oc2XDLs9MQ91hR7sXAWJXeFL0 e2og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qGUJrtnlz9Yo3S83G8V63+H0kWn768DHMiymUEO8oRc=; b=qrk7w07BIcWfl3xAyZVbfccb8KP299++72Xrh76RXf3L4OMJLLBtqMfzI9YsPRBHjX 3SdbsDjddnVCGvUr+8o4iHc3PBXPNWlnbmL4zdaj9PDKpdwM2B1I2TSki6mGUvua05Eu B7yEgmdIDWxN3RmQj/nMFmzQBQNiVx0nhBzmKzpA5BCQHTJHYLE88sD8m1pAVOdwpWuO BvKAwiyefGRRRVHsWXPE+kgPmqtwpkur4M/PxrKbNgoRTLA6VrPteh12N6H84h98Nq6j XH4CXBGrzcLxY51VuohnRV/h0VVlAfZo0WS5PftVDSVBfht518r2xsvvbguF52jYu/9/ tJAg== X-Gm-Message-State: AO0yUKWNjnsoJ5FV8AtkUNxNe/5D2fWKOrG+IFzPJ7UT3usKOStpvC8g aaMhIP1cvitiJEXsq/Jo2VkJag== X-Google-Smtp-Source: AK7set9iKMN+331A78WOS0+283/LRLCQZcWvZJIXGOxwFzQXnHGwTGuTzqDRl1h2YTXjpvwyCnxIqw== X-Received: by 2002:a17:907:98b1:b0:8e4:96c4:94a with SMTP id ju17-20020a17090798b100b008e496c4094amr4858736ejc.56.1677104041367; Wed, 22 Feb 2023 14:14:01 -0800 (PST) Received: from sleipner.berto.se (p54ac5802.dip0.t-ipconnect.de. [84.172.88.2]) by smtp.googlemail.com with ESMTPSA id a26-20020a170906685a00b008b1b86bf668sm7711893ejs.4.2023.02.22.14.14.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 14:14:01 -0800 (PST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Kieran Bingham , Hans Verkuil , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH 2/3] media: i2c: adv748x: Write initial DV timings to device Date: Wed, 22 Feb 2023 23:12:48 +0100 Message-Id: <20230222221249.1324102-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230222221249.1324102-1-niklas.soderlund+renesas@ragnatech.se> References: <20230222221249.1324102-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org When initializing the HDMI block during probe an initial set of timings are selected. These timings are stored in the drivers private data, but not written to the device. This in itself is not bad, but in s_dv_timings() the timings stored in the drivers private data are compared to the new timings, if they match no action is taken. This creates the corner-case where the timing selected at initialization is the first timings a user want to use as the driver then never writes it to the device preventing proper operation. Fix this by writing the timings to the device at initialization in addition to storing them in the drivers private data. Signed-off-by: Niklas Söderlund --- drivers/media/i2c/adv748x/adv748x-hdmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/adv748x/adv748x-hdmi.c b/drivers/media/i2c/adv748x/adv748x-hdmi.c index 1d62e05572cd..47688d1b6833 100644 --- a/drivers/media/i2c/adv748x/adv748x-hdmi.c +++ b/drivers/media/i2c/adv748x/adv748x-hdmi.c @@ -721,11 +721,10 @@ static int adv748x_hdmi_init_controls(struct adv748x_hdmi *hdmi) int adv748x_hdmi_init(struct adv748x_hdmi *hdmi) { struct adv748x_state *state = adv748x_hdmi_to_state(hdmi); - static const struct v4l2_dv_timings cea1280x720 = - V4L2_DV_BT_CEA_1280X720P30; + struct v4l2_dv_timings cea1280x720 = V4L2_DV_BT_CEA_1280X720P30; int ret; - hdmi->timings = cea1280x720; + adv748x_hdmi_s_dv_timings(&hdmi->sd, &cea1280x720); /* Initialise a default 16:9 aspect ratio */ hdmi->aspect_ratio.numerator = 16; From patchwork Wed Feb 22 22:12:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 13149626 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 C26C9C64ED6 for ; Wed, 22 Feb 2023 22:14:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232817AbjBVWOx (ORCPT ); Wed, 22 Feb 2023 17:14:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232910AbjBVWOh (ORCPT ); Wed, 22 Feb 2023 17:14:37 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47C69474F9 for ; Wed, 22 Feb 2023 14:14:10 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id cq23so36097002edb.1 for ; Wed, 22 Feb 2023 14:14:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tEppd4OhzMYnVa+HKy8qqHzfPuUopXSp8sEG9Vdb4jM=; b=EYbRWsmMG++uhINyyeH8Zn2RewJQqhVUkAG2QqSYlgHoUF9HGkAGswoAPQAto2DPYr R9D+1rBmO2qgkg9vLq3g4hpo2S3D+WoUlA1vl/Lw6Xc1YTcQHv8n5FAXN7uVJt0+tNI3 vPcMhwI8KWQzq29ktsN1DkbU9oKF4aiN9syhvikd2mMhpfz9hTo3ENUymVSiua4H5wqQ FGNDIk4+jdwZwMJ2OAx5MaBsmWJLAPO9FjXMmBqwDUdvoxEs9GX+GR9vJIuoRSoY/HTU zaDH+H/soh4TX3y/JG/Tu3ahVPw8SFzhFSxfsHGk5JX5Z1tco5S/5j2bFqUCqRuhZyjW n/Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tEppd4OhzMYnVa+HKy8qqHzfPuUopXSp8sEG9Vdb4jM=; b=O8hZHU9L3jPNiGUvtnm5ebNRJO0Wn+XPFNBmG+qcnVor/fLxrM7i7/v963NhVV5ne8 gBzLPvaWznldkKVBEH/VF/CYIeubC9ggRolJmeoHyMNt5yWY0XJekWtuMbS3aVkckjGk TXwnDhzFP9QTBQatn7Zr/LC98rANlLKGCUfAOIjuOauighBWKVTCHOxzd1Ork81dGAKV vcIHTPaD3c4EFZHqIX9t0Z/PAaLYTOo6C9pV/Md3zHgYDMq77XNyWn5Iy3Gf2nhXG0wc xf+lIQs6FidJqUfRNHIRG5kYE/w2KYWzVsF9rLZ1pgMIBES/8sb3v/W/lo9wgSo6Arcp V62A== X-Gm-Message-State: AO0yUKVK1O7JE0xmT0+ljZfxQPDOnGy0bEIpugO7mZ1Mb4dxu/KWfiW/ S1zrBoxGMpyDs+/pJ+G3Q+O5qQWYsy4F/axviO0= X-Google-Smtp-Source: AK7set8AfoeIZeyoOYhpqhlggdvn4LUAj2j06/1mpD2pGHua9C13pVdBojL2xs9rQt0Vu+33IahfIA== X-Received: by 2002:a17:906:fe06:b0:8af:2fa1:619e with SMTP id wy6-20020a170906fe0600b008af2fa1619emr16755194ejb.18.1677104042279; Wed, 22 Feb 2023 14:14:02 -0800 (PST) Received: from sleipner.berto.se (p54ac5802.dip0.t-ipconnect.de. [84.172.88.2]) by smtp.googlemail.com with ESMTPSA id a26-20020a170906685a00b008b1b86bf668sm7711893ejs.4.2023.02.22.14.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 14:14:01 -0800 (PST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Kieran Bingham , Hans Verkuil , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH 3/3] media: i2c: adv748x: Report correct DV timings for pattern generator Date: Wed, 22 Feb 2023 23:12:49 +0100 Message-Id: <20230222221249.1324102-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230222221249.1324102-1-niklas.soderlund+renesas@ragnatech.se> References: <20230222221249.1324102-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org If the pattern generator is enabled the device shall not be queried for timings. Instead the timings programmed shall be reported as they are the ones being used to generate the pattern. Before this change an external HDMI source needed to be connected for the pattern generator to work. The driver would query this external HDMI source for timings and program the pattern generator using those. With this change the user can control the timings and have the pattern generator work without the need of an external HDMI source being connected. Signed-off-by: Niklas Söderlund --- drivers/media/i2c/adv748x/adv748x-hdmi.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/i2c/adv748x/adv748x-hdmi.c b/drivers/media/i2c/adv748x/adv748x-hdmi.c index 47688d1b6833..400d71c2745c 100644 --- a/drivers/media/i2c/adv748x/adv748x-hdmi.c +++ b/drivers/media/i2c/adv748x/adv748x-hdmi.c @@ -283,6 +283,16 @@ static int adv748x_hdmi_query_dv_timings(struct v4l2_subdev *sd, memset(timings, 0, sizeof(struct v4l2_dv_timings)); + /* + * If the pattern generator is enabled the device shall not be queried + * for timings. Instead the timings programmed shall be reported as they + * are the ones being used to generate the pattern. + */ + if (cp_read(state, ADV748X_CP_PAT_GEN) & ADV748X_CP_PAT_GEN_EN) { + *timings = hdmi->timings; + return 0; + } + if (!adv748x_hdmi_has_signal(state)) return -ENOLINK;