1 // SPDX-License-Identifier: GPL-2.0
3 #define DSS_SUBSYS_NAME "HDMI"
5 #include <linux/kernel.h>
12 int hdmi_parse_lanes_of(struct platform_device *pdev, struct device_node *ep,
13 struct hdmi_phy_data *phy)
15 struct property *prop;
18 prop = of_find_property(ep, "lanes", &len);
22 if (len / sizeof(u32) != ARRAY_SIZE(lanes)) {
23 dev_err(&pdev->dev, "bad number of lanes\n");
27 r = of_property_read_u32_array(ep, "lanes", lanes,
30 dev_err(&pdev->dev, "failed to read lane data\n");
34 r = hdmi_phy_parse_lanes(phy, lanes);
36 dev_err(&pdev->dev, "failed to parse lane data\n");
40 static const u32 default_lanes[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
42 r = hdmi_phy_parse_lanes(phy, default_lanes);
44 dev_err(&pdev->dev, "failed to parse lane data\n");
52 int hdmi_compute_acr(u32 pclk, u32 sample_freq, u32 *n, u32 *cts)
55 bool deep_color_correct = false;
57 if (n == NULL || cts == NULL)
60 /* TODO: When implemented, query deep color mode here. */
64 * When using deep color, the default N value (as in the HDMI
65 * specification) yields to an non-integer CTS. Hence, we
66 * modify it while keeping the restrictions described in
67 * section 7.2.1 of the HDMI 1.4a specification.
69 switch (sample_freq) {
74 if (deep_color == 125)
75 if (pclk == 27027000 || pclk == 74250000)
76 deep_color_correct = true;
77 if (deep_color == 150)
79 deep_color_correct = true;
84 if (deep_color == 125)
86 deep_color_correct = true;
92 if (deep_color_correct) {
93 switch (sample_freq) {
119 switch (sample_freq) {
145 /* Calculate CTS. See HDMI 1.3a or 1.4a specifications */
146 *cts = (pclk/1000) * (*n / 128) * deep_color / (sample_freq / 10);