drm/radeon: add new AMD ACPI header and update relevant code (v2)

BugLink: http://bugs.launchpad.net/bugs/1110219

Add a new header that defines the AMD ACPI interface used
for laptops, PowerXpress, and chipset specific functionality
and update the current code to use it.

Todo:
- properly verify the ACPI interfaces
- hook up and handle ACPI notifications
- make PX code more robust
- implement PCIe Gen and width switching using ACPI

v2: fix typo in header

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 9e05b2f49eb9484e857e9b6c70dea3bbbe564290)
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drm/radeon: add a license header to radeon_apci.c

BugLink: http://bugs.launchpad.net/bugs/1110219

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit efd4e418f2bb8a8b21f96fd44e775eaf6dd55905)
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drm/radeon: track whether the GPU controls the backlight (v2)

BugLink: http://bugs.launchpad.net/bugs/1110219

A table in the vbios tells us whether the GPU backlight controller
is used or not.  If the bit is set, the GPU backlight controller is
used; if it is not set, an off-chip backlight controller is used.

v2: store all the firmware flags, not just BL control

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit af7912e57316caa1b705f06b03592cec0737cb36)
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drm/radeon: rework legacy backlight control

BugLink: http://bugs.launchpad.net/bugs/1110219

To better enable sharing with atom backlight control.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 910308802c528f8afe864b694d5456fedd0bb18f)
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drm/radeon: add backlight control for atom devices (v2)

BugLink: http://bugs.launchpad.net/bugs/1110219

On systems that use the build in GPU backlight controller,
we can use atom tables to change the brightness level.

v2: use firmware flags

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit f3728734ba78310525bf4a361c7787c7c6fa5d40)
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drm/radeon: refactor radeon_atif_call

BugLink: http://bugs.launchpad.net/bugs/1110219

Don't hard-code function number, this will allow to reuse the function.
v2: add support for the 2nd parameter (from Lee, Chun-Yi
<jlee@suse.com>).

Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 86504672f7d79986a8ef618fb120044220e3d1eb)
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drm/radeon: implement radeon_atif_verify_interface

BugLink: http://bugs.launchpad.net/bugs/1110219

Wrap the call to VERIFY_INTERFACE and add the parsing of the support
vectors.
v2: use a packed struct for handling the output of ACPI calls, hides
ugly pointer arithmetics (Lee, Chun-Yi <jlee@suse.com>).
v3: fix radeon_atif_parse_functions handling (Alex Deucher)

Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(back ported from commit fd64ca8a9d9d7e92fc81fe0b23dcf324246fd356)

Conflicts:

	drivers/gpu/drm/radeon/radeon.h
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drm/radeon: implement wrapper for GET_SYSTEM_PARAMS

BugLink: http://bugs.launchpad.net/bugs/1110219

Use GET_SYSTEM_PARAMS for retrieving the configuration for the system
BIOS notifications.
v2: packed struct (Lee, Chun-Yi <jlee@suse.com>)
v3: fix enable with device specific command code

Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit ce3cf821a31f9824eda788cbd3e710d8047e82df)
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drm/radeon: implement handler for ACPI event

BugLink: http://bugs.launchpad.net/bugs/1110219

Set up an handler for ACPI events and respond to brightness change
requests from the system BIOS.
v2: fix notification when using device-specific command codes
(tested by Pali Rohár <pali.rohar@gmail.com>); cache the encoder
controlling the backlight during the initialization to avoid searching
it every time (suggested by Alex Deucher).
v3: whitespace fixes (Alex Deucher).

Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit fda4b25c55a59ba12378e4b9e4553f6ea57d802d)
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drm/radeon: re-organize the acpi notifier callback

BugLink: http://bugs.launchpad.net/bugs/1110219

Move it out of the radeon_pm.c and into radeon_acpi.c since
we use it for more than just pm now.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit c49170742d6928b16fb3839b47a94cc41630dbe0)
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
ACPI video: allow events handlers to veto the keypress

BugLink: http://bugs.launchpad.net/bugs/1110219

The standard video events may be overloaded for device specific
purposes. For example AMD ACPI interface overloads
ACPI_VIDEO_NOTIFY_PROBE (0x81) to signal AMD-specific events. In such
cases we don't want to send the keypress (KEY_SWITCHVIDEOMODE) to the
userspace because the user did not press the mode switch key (the
spurious keypress confuses the DE which usually changes the
display configuration and messes up a dual-screen setup).
This patch gives the handlers the chance to examine the event and
block the keypress if the event is device specific.
v2: refactor as suggested by Zhang Rui <rui.zhang@intel.com>

Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 8a37c65df9dcbd1c891df2b4a94157999b654841)
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drm/radeon: block the keypress on ATIF events

BugLink: http://bugs.launchpad.net/bugs/1110219

The AMD ACPI interface may use ACPI_VIDEO_NOTIFY_PROBE to signal SBIOS
requests; block the keypress in this case since the user did not
actually press the mode switch key.

Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 92fdf89aa95de32dba1cb44fe7f5c54824b4b2c4)
Signed-off-by: Alex Hung <alex.hung@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
UBUNTU: ubuntu: overlayfs -- fix missmerge of vfs_open changes

Quantal is based on v3.5 which sits at an unfortuanate juncture in the
evolution of the open code.  At this specific time there is an open coded
side effect (see below) on the success path for the calls do_dentry_open().
When injecting the vfs_open (again open coded) into the nameidata_to_filp()
routine to avoid the success path reference counting issues, this side
effect was lost.  Re-add this to avoid panics:

    nd->intent.open.file = NULL;

BugLink: http://bugs.launchpad.net/bugs/1122094
BugLink: http://bugs.launchpad.net/bugs/1147678
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Leann Ogasawara <leann.ogasawara@canonical.com>
Signed-off-by: Brad Figg <brad.figg@canonical.com>