linux/drivers/video/fbdev/omap2/dss/hdmi_common.c
<<
>>
Prefs
   1
   2#define DSS_SUBSYS_NAME "HDMI"
   3
   4#include <linux/kernel.h>
   5#include <linux/err.h>
   6#include <linux/of.h>
   7#include <video/omapdss.h>
   8
   9#include "hdmi.h"
  10
  11int hdmi_parse_lanes_of(struct platform_device *pdev, struct device_node *ep,
  12        struct hdmi_phy_data *phy)
  13{
  14        struct property *prop;
  15        int r, len;
  16
  17        prop = of_find_property(ep, "lanes", &len);
  18        if (prop) {
  19                u32 lanes[8];
  20
  21                if (len / sizeof(u32) != ARRAY_SIZE(lanes)) {
  22                        dev_err(&pdev->dev, "bad number of lanes\n");
  23                        return -EINVAL;
  24                }
  25
  26                r = of_property_read_u32_array(ep, "lanes", lanes,
  27                        ARRAY_SIZE(lanes));
  28                if (r) {
  29                        dev_err(&pdev->dev, "failed to read lane data\n");
  30                        return r;
  31                }
  32
  33                r = hdmi_phy_parse_lanes(phy, lanes);
  34                if (r) {
  35                        dev_err(&pdev->dev, "failed to parse lane data\n");
  36                        return r;
  37                }
  38        } else {
  39                static const u32 default_lanes[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
  40
  41                r = hdmi_phy_parse_lanes(phy, default_lanes);
  42                if (WARN_ON(r)) {
  43                        dev_err(&pdev->dev, "failed to parse lane data\n");
  44                        return r;
  45                }
  46        }
  47
  48        return 0;
  49}
  50
  51#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
  52int hdmi_compute_acr(u32 pclk, u32 sample_freq, u32 *n, u32 *cts)
  53{
  54        u32 deep_color;
  55        bool deep_color_correct = false;
  56
  57        if (n == NULL || cts == NULL)
  58                return -EINVAL;
  59
  60        /* TODO: When implemented, query deep color mode here. */
  61        deep_color = 100;
  62
  63        /*
  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.
  68         */
  69        switch (sample_freq) {
  70        case 32000:
  71        case 48000:
  72        case 96000:
  73        case 192000:
  74                if (deep_color == 125)
  75                        if (pclk == 27027000 || pclk == 74250000)
  76                                deep_color_correct = true;
  77                if (deep_color == 150)
  78                        if (pclk == 27027000)
  79                                deep_color_correct = true;
  80                break;
  81        case 44100:
  82        case 88200:
  83        case 176400:
  84                if (deep_color == 125)
  85                        if (pclk == 27027000)
  86                                deep_color_correct = true;
  87                break;
  88        default:
  89                return -EINVAL;
  90        }
  91
  92        if (deep_color_correct) {
  93                switch (sample_freq) {
  94                case 32000:
  95                        *n = 8192;
  96                        break;
  97                case 44100:
  98                        *n = 12544;
  99                        break;
 100                case 48000:
 101                        *n = 8192;
 102                        break;
 103                case 88200:
 104                        *n = 25088;
 105                        break;
 106                case 96000:
 107                        *n = 16384;
 108                        break;
 109                case 176400:
 110                        *n = 50176;
 111                        break;
 112                case 192000:
 113                        *n = 32768;
 114                        break;
 115                default:
 116                        return -EINVAL;
 117                }
 118        } else {
 119                switch (sample_freq) {
 120                case 32000:
 121                        *n = 4096;
 122                        break;
 123                case 44100:
 124                        *n = 6272;
 125                        break;
 126                case 48000:
 127                        *n = 6144;
 128                        break;
 129                case 88200:
 130                        *n = 12544;
 131                        break;
 132                case 96000:
 133                        *n = 12288;
 134                        break;
 135                case 176400:
 136                        *n = 25088;
 137                        break;
 138                case 192000:
 139                        *n = 24576;
 140                        break;
 141                default:
 142                        return -EINVAL;
 143                }
 144        }
 145        /* Calculate CTS. See HDMI 1.3a or 1.4a specifications */
 146        *cts = (pclk/1000) * (*n / 128) * deep_color / (sample_freq / 10);
 147
 148        return 0;
 149}
 150#endif
 151