sunxi: Unbreak broken CedarX userland software (2GB phys->bus issue)

The commit 1e205f7 happened to
break broken CedarX media players on the systems with 2GB of RAM
(Cubietruck). The problem is that some CedarX userland code (used
in VLC and XBMC together with proprietary blobs) already feeds
bus addresses to the sunxi disp ioctls, while physical addresses
are expected there. The open source libvdpau-sunxi does not have
such bugs.

This patch avoids phys->bus conversion if the address passed to
the __phys_to_bus macro is already obviously a bus address.

While the right solution would be to hunt down and fix all the
userland offenders, this may be difficult in practice. For example
when dealing with Android images and trying to provide a drop-in
kernel replacement for them.

Signed-off-by: Siarhei Siamashka <siarhei.siamas...@gmail.com>
 sunxi: usb: fix disconnect threshold on sun7i

From c6f107d Mon Sep 17 00:00:00 2001
In-Reply-To: <fe5c5dd15b64672afb0987b55751ce1bc2331af6.1391455804.git.hramrach@gmail.com>

fix by Hans de Goede <hdegoede@redhat.com>

Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
 Add sun7i Linein pre-amp

Without the linein pre-amp mixer setting, it defaults to some value
which causes clipping. Also it's nice to have the actual knob for the
pre-amp.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
 sun7i: defconfig: enable USB_SW_SUNXI_USB

This gives some of our device drivers (realtek usb wifi for instance)
the ability to dynamically turn on/off USBCs. These config options match
sun4i and sun5i.

Signed-off-by: Luc Verhaegen <libv@skynet.be>
 sunxi: mali: Fix UMP on systems with 2 GiB of RAM (phys->bus issue)

The mali driver has some code for converting between physical addresses
and bus addresses (they call them "cpu physical addresses" and "physical
addresses" respectively). For OS memory allocation, this delta is configured
in the "cpu_usage_adjust" variable, as can be seen in the mali driver code.

But in addition to OS memory allocation, mali also handles external memory
wrapping and UMP memory wrapping. The physical/bus addresses translation
is done separately for each type of memory in the mali driver. The older
commit from Huang Benn updated the mali code to do physical->bus addresses
translation for OS memory and external memory, but did not address a
similar issue with UMP memory. Incorrectly working UMP results in black
windows for EGL/GLES applications (and also in memory corruption) on
the systems with 2 GiB of RAM when used with X11 mali drivers:
    ssvb/xf86-video-fbturbo#27

This patch tries to do the physical->bus addresses translation for
both external and UMP memory a bit lower in the call chain (in the
"mali_allocation_engine_map_physical" function). That's just because
the old "uk_args.phys_addr = __phys_to_bus(uk_args.phys_addr)" code
does not look nice (the "phys_addr" variable name becomes somewhat
misleading and ambiguous).

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
arm:sunxi:configs: set CMA size to 192MB, as recommended by ssvb

Signed-off-by: Alejandro Mery <amery@geeks.cl>
sunxi: disp: Fix VGA DAC mode

Currently the DAC is set to 35.7 Ohm mode for VGA output. This results
in a too bright screen image with lighter greys indistinguishable
from white.

Setting it to 75 Ohm fixes this, which is obvious as VGA lines are
75 Ohm terminated.

Signed-off-by: Jens Kuske <jenskuske@gmail.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Add to W1_SUNX1 depends from W1_MASTER_GPIO

Signed-off-by: Gerardo Di Iorio <arete74@gmail.com>
sunxi: cedar: Allow to use CMA for cedar memory allocation

In the case if the kernel supports CMA and has it enabled, now
the cedar module tries to allocate the 80MB memory buffer from CMA.
This memory block is kept in use as long as the cedar module is
loaded. When the module is unloaded, the allocated memory gets
released.

It is preferable to allocate cedar memory buffer from the first
256MB of physical memory to avoid bugs even though in theory
higher addresses might be supported:
    http://irclog.whitequark.org/linux-sunxi/2013-07-17#4409315;
In practice, both VLC (using the proprietary libve library) and
libvdpau-sunxi fail for the buffers allocated from above 256MB
(or partially crossing this boundary).

For the kernels without CMA, the old behaviour is preserved.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Add cedar file to
sunxi: cedar: Allow to use CMA for cedar memory allocation