From: Nelson Costa <Nelson.Costa@synopsys.com>
To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Kishon Vijay Abraham I <kishon@ti.com>,
Vinod Koul <vkoul@kernel.org>, Rob Herring <robh+dt@kernel.org>,
Jose Abreu <Jose.Abreu@synopsys.com>,
Nelson Costa <Nelson.Costa@synopsys.com>
Subject: [RFC 7/8] media: dwc: dw-hdmi-rx: Add support for Aspect Ratio
Date: Wed, 28 Apr 2021 17:25:10 +0200 [thread overview]
Message-ID: <0acdcfbe29d2cbb2974377d79391e55f5b489851.1618937288.git.nelson.costa@synopsys.com> (raw)
In-Reply-To: <cover.1618937288.git.nelson.costa@synopsys.com>
In-Reply-To: <cover.1618937288.git.nelson.costa@synopsys.com>
This adds support to get aspect ratio for the current
video being received and provide the info through v4l2
API query_dv_timings.
Signed-off-by: Nelson Costa <nelson.costa@synopsys.com>
---
drivers/media/platform/dwc/dw-hdmi-rx.c | 54 +++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/dwc/dw-hdmi-rx.c b/drivers/media/platform/dwc/dw-hdmi-rx.c
index 07ac62f..78d9ef3 100644
--- a/drivers/media/platform/dwc/dw-hdmi-rx.c
+++ b/drivers/media/platform/dwc/dw-hdmi-rx.c
@@ -2252,13 +2252,31 @@ static u32 dw_hdmi_get_width(struct dw_hdmi_dev *dw_dev)
return width;
}
+static int dw_hdmi_vic_to_cea861(u8 hdmi_vic)
+{
+ switch (hdmi_vic) {
+ case 1:
+ return 95;
+ case 2:
+ return 94;
+ case 3:
+ return 93;
+ case 4:
+ return 98;
+ default:
+ return 0;
+ }
+}
+
static int dw_hdmi_query_dv_timings(struct v4l2_subdev *sd,
struct v4l2_dv_timings *timings)
{
struct dw_hdmi_dev *dw_dev = to_dw_dev(sd);
struct v4l2_bt_timings *bt = &timings->bt;
+ struct v4l2_dv_timings t = {0};
bool is_hdmi_vic;
u32 htot, hofs;
+ u8 cea861_vic;
u32 vtot;
u8 vic;
@@ -2353,8 +2371,40 @@ static int dw_hdmi_query_dv_timings(struct v4l2_subdev *sd,
}
}
- dev_dbg(dw_dev->dev, "%s: width=%u, height=%u, mbuscode=%u\n", __func__,
- bt->width, bt->height, dw_hdmi_get_mbus_code(dw_dev));
+ if (is_hdmi_vic)
+ cea861_vic = dw_hdmi_vic_to_cea861(bt->hdmi_vic);
+ else
+ cea861_vic = vic;
+
+ /* picture aspect ratio based on v4l2 dv timings array */
+ if (v4l2_find_dv_timings_cea861_vic(&t, cea861_vic)) {
+ /* when the numerator/denominator are zero means that the
+ * picture aspect ratio is the same of the active measures ratio
+ */
+ if (!t.bt.picture_aspect.numerator) {
+ unsigned long n, d;
+
+ rational_best_approximation(t.bt.width, t.bt.height,
+ t.bt.width, t.bt.height,
+ &n, &d);
+ t.bt.picture_aspect.numerator = n;
+ t.bt.picture_aspect.denominator = d;
+ }
+
+ bt->picture_aspect = t.bt.picture_aspect;
+ } else {
+ bt->picture_aspect.numerator = 0;
+ bt->picture_aspect.denominator = 0;
+ dev_dbg(dw_dev->dev,
+ "%s: cea861_vic=%d was not found in v4l2 dv timings",
+ __func__, cea861_vic);
+ }
+
+ dev_dbg(dw_dev->dev,
+ "%s: width=%u, height=%u, mbuscode=%u, cea861_vic=%d, ar={%d,%d}\n",
+ __func__, bt->width, bt->height, dw_hdmi_get_mbus_code(dw_dev),
+ cea861_vic, bt->picture_aspect.numerator,
+ bt->picture_aspect.denominator);
return 0;
}
--
2.7.4
next prev parent reply other threads:[~2021-04-28 15:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 15:25 [RFC 0/8] Add Synopsys DesignWare HDMI RX Controller and PHY drivers Nelson Costa
2021-04-28 15:25 ` [RFC 1/8] dt-bindings: media: Document Synopsys DesignWare HDMI RX Nelson Costa
2021-04-28 22:01 ` Laurent Pinchart
2021-04-29 18:03 ` Nelson Costa
2021-04-28 15:25 ` [RFC 2/8] MAINTAINERS: Add entry for Synopsys DesignWare HDMI drivers Nelson Costa
2021-04-28 15:25 ` [RFC 3/8] phy: Add PHY standard HDMI opts to the PHY API Nelson Costa
2021-04-28 15:25 ` [RFC 4/8] phy: dwc: Add Synopsys DesignWare HDMI RX PHYs e405 and e406 Driver Nelson Costa
2021-04-28 15:25 ` [RFC 5/8] media: platform: Add Synopsys DesignWare HDMI RX Controller Driver Nelson Costa
2021-04-28 15:25 ` [RFC 6/8] media: v4l2-dv-timings: Add more CEA/CTA-861 video format timings Nelson Costa
2021-04-28 15:25 ` Nelson Costa [this message]
2021-04-28 15:25 ` [RFC 8/8] media: dwc: dw-hdmi-rx: Add support for CEC Nelson Costa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0acdcfbe29d2cbb2974377d79391e55f5b489851.1618937288.git.nelson.costa@synopsys.com \
--to=nelson.costa@synopsys.com \
--cc=Jose.Abreu@synopsys.com \
--cc=devicetree@vger.kernel.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=kishon@ti.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=robh+dt@kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®