sunxi-hdmi: Fix Hdmi_mode_support

Hdmi_mode_support translates the past in mode to a CEA-861-D VIC because
Device_Support_VIC should be indexed by a VIC. This patch makes it actually
use the looked up VIC to index Device_Support_VIC.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Add a Hdmi_tv_mode_to_hdmi_mode() helper function

Having the exact same switch-case twice is not really useful.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Simplify audio parameters calculation

All calculations are based on the pixelclock, so instead of this huge
if ... else if ... on the hdmi_mode, simply get the pixel clock from
the mode-table, and use that.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Add 1360x768 mode

Many HD ready but not Full HD LCD tvs have a 1360x768 panel, having this mode
available as hdmi output resolution allows running them at their native
resolution.

Note some tvs have a native resolution of 1366x768, I've tried adding a mode
for that too, and it works, but only with fbcon, X cannot handle the pitch
not being a multiple of 8, and I don't know how to add padding to the
framebuffer, so people should just use 1360x768 with those.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Allow disabling hdmi audio from the kernel cmdline

Disabling hdmi-audio makes things work a lot better with DVI monitors,
as some DVI monitors will mistakenly try to interpret the audio data
as video data.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-disp: Set output-type and output-mode from the kernel cmdline

Because editing uEnv.txt is much simpler / more userfriendly
then dealing with script.bin, and human readable text strings are
way easier to remember then the hardwired mode table.

Note that if the cmdline arguments are not given, or not valid the
fex values are used as a fallback.

Note about the simple_strtol checkpatch warnings, we really want to use
simple_strtol here, as we need the ep to continue parsing after the number.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-disp: Fb_Init: don't assume the lcd driver is always loaded first

Currently the sunxi-disp code depends on the lcd driver always being
loaded first, which is not a good idea. This fixes this. With this it
should be safe to simply build the disp, hdmi and lcd driver into the
kernel (worksforme).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-disp: Remove unused BSP_disp_get_frame_rate function

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-disp: Fix duplication of DISP_SUCCESS and other DISP_XXXX status codes

These were declared (the same) in 2 different header files, causing problems
when both files are included.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: s/plus/pulsw/

The "plus" variables store the V/Hsync pulsewidth, so lets give them a more
descriptive name.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Correctly get vsync pulse width from EDID

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Use pr_info instead of custom __inf macro for EDID

As we're going to be actually using EDID we want the EDID messagesto actually
end up in demsg for debugging any problems.

Also print the full info from detailed timing blocks, rather then just
a summary.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Speed up hdmi initialization

Before this patch we started in this useless "idle" state, from where we
would set the next state to be HDMI_State_Wait_Hpd and then return from
hdmi_main_task_loop to Hdmi_run_thread, which would then sleep 2 seconds
before checking if we've a link. So in essence the hdmi code would just
start with sleeping for 2 seconds for no good reason.

This patch gets rid of the idle state, shaving of 2 seconds of hdmi
init time. It also speeds up Hdmi_run_thread when we're not in a stable
state, so that if we're waiting for video-config (which we will get
pretty quickly after being brought up), the config arriving will get
noticed quickly.

This changes the hdmi init time from taking seconds to taking 10s of ms.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Move video-info struct declaration to sunxi_disp_ioctl.h

So that EDID gathered modes can be shared with the sunxi-disp core.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Add interlace and polarity info to video_mode table

Rather then hardcoding it, to allow properly getting this info from EDID
for EDID support.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Fix INPUTY and VT to not be a multiple of their real values

We want to use these values in other places too, so having the special
behavior of having them multiplied by certain factors hardcoded in the
video_timing table is no good.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Add a hdmi_get_video_timing function

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Re-use timings from hdmi-core when programming the lcd controller

There is little use in re-producing all the timings from the video_timing
tabel from hdmi_core.c in a large switch-case. Simply get the timings from
the hdmicore and use those when programming the lcd controller, note this is
esp. useful for programming the controller with timings read from EDID.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Dynamically determine pll frequency for hdmi modes

"Calculate" the pll frequency for hdmi modes, rather then looking it
up in a fixed table. This is necessary for EDID support.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Add a hdmi_wait_edid function

Signed-off-by: Hans de Goede <hdegoede@redhat.com>