/* * Copyright 2008 Intel Corporation <hong.liu@intel.com> * Copyright 2008 Red Hat <mjg@redhat.com> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial * portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NON-INFRINGEMENT. IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. *
*/
/* Check if we can call the function. See swsci_setup for details. */ if (main_function == SWSCI_SBCB) { if ((opregion->swsci_sbcb_sub_functions &
(1 << sub_function)) == 0) return -EINVAL;
} elseif (main_function == SWSCI_GBDA) { if ((opregion->swsci_gbda_sub_functions &
(1 << sub_function)) == 0) return -EINVAL;
}
ret = check_swsci_function(display, function); if (ret) return ret;
swsci = display->opregion->swsci;
/* Driver sleep timeout in ms. */
dslp = swsci->dslp; if (!dslp) { /* The spec says 2ms should be the default, but it's too small
* for some machines. */
dslp = 50;
} elseif (dslp > MAX_DSLP) { /* Hey bios, trust must be earned. */
DRM_INFO_ONCE("ACPI BIOS requests an excessive sleep of %u ms, " "using %u ms instead\n", dslp, MAX_DSLP);
dslp = MAX_DSLP;
}
/* The spec tells us to do this, but we are the only user... */
scic = swsci->scic; if (scic & SWSCI_SCIC_INDICATOR) {
drm_dbg(display->drm, "SWSCI request already in progress\n"); return -EBUSY;
}
scic = function | SWSCI_SCIC_INDICATOR;
swsci->parm = parm;
swsci->scic = scic;
/* Ensure SCI event is selected and event trigger is cleared. */
pci_read_config_word(pdev, SWSCI, &swsci_val); if (!(swsci_val & SWSCI_SCISEL) || (swsci_val & SWSCI_GSSCIE)) {
swsci_val |= SWSCI_SCISEL;
swsci_val &= ~SWSCI_GSSCIE;
pci_write_config_word(pdev, SWSCI, swsci_val);
}
/* Use event trigger to tell bios to check the mail. */
swsci_val |= SWSCI_GSSCIE;
pci_write_config_word(pdev, SWSCI, swsci_val);
/* Poll for the result. */ #define C (((scic = swsci->scic) & SWSCI_SCIC_INDICATOR) == 0) if (wait_for(C, dslp)) {
drm_dbg(display->drm, "SWSCI request timed out\n"); return -ETIMEDOUT;
}
int intel_opregion_notify_encoder(struct intel_encoder *encoder, bool enable)
{ struct intel_display *display = to_intel_display(encoder);
u32 parm = 0;
u32 type = 0;
u32 port; int ret;
/* don't care about old stuff for now */ if (!HAS_DDI(display)) return 0;
/* Avoid port out of bounds checks if SWSCI isn't there. */
ret = check_swsci_function(display, SWSCI_SBCB_DISPLAY_POWER_STATE); if (ret) return ret;
if (encoder->type == INTEL_OUTPUT_DSI)
port = 0; else
port = encoder->port;
if (port == PORT_E) {
port = 0;
} else {
parm |= 1 << port;
port++;
}
/* * The port numbering and mapping here is bizarre. The now-obsolete * swsci spec supports ports numbered [0..4]. Port E is handled as a * special case, but port F and beyond are not. The functionality is * supposed to be obsolete for new platforms. Just bail out if the port * number is out of bounds after mapping.
*/ if (port > 4) {
drm_dbg_kms(display->drm, "[ENCODER:%d:%s] port %c (index %u) out of bounds for display power state notification\n",
encoder->base.base.id, encoder->base.name,
port_name(encoder->port), port); return -EINVAL;
}
if (!enable)
parm |= 4 << 8;
switch (encoder->type) { case INTEL_OUTPUT_ANALOG:
type = DISPLAY_TYPE_CRT; break; case INTEL_OUTPUT_DDI: case INTEL_OUTPUT_DP: case INTEL_OUTPUT_HDMI: case INTEL_OUTPUT_DP_MST:
type = DISPLAY_TYPE_EXTERNAL_FLAT_PANEL; break; case INTEL_OUTPUT_EDP: case INTEL_OUTPUT_DSI:
type = DISPLAY_TYPE_INTERNAL_FLAT_PANEL; break; default:
drm_WARN_ONCE(display->drm, 1, "unsupported intel_encoder type %d\n",
encoder->type); return -EINVAL;
}
int intel_opregion_notify_adapter(struct intel_display *display,
pci_power_t state)
{ int i;
if (!HAS_DDI(display)) return 0;
for (i = 0; i < ARRAY_SIZE(power_state_map); i++) { if (state == power_state_map[i].pci_power_state) return swsci(display, SWSCI_SBCB_ADAPTER_POWER_STATE,
power_state_map[i].parm, NULL);
}
static u32 asle_set_als_illum(struct intel_display *display, u32 alsi)
{ /* alsi is the current ALS reading in lux. 0 indicates below sensor
range, 0xffff indicates above sensor range. 1-0xfffe are valid */
drm_dbg(display->drm, "Illum is not supported\n"); return ASLC_ALS_ILLUM_FAILED;
}
static u32 asle_set_pwm_freq(struct intel_display *display, u32 pfmb)
{
drm_dbg(display->drm, "PWM freq is not supported\n"); return ASLC_PWM_FREQ_FAILED;
}
static u32 asle_set_pfit(struct intel_display *display, u32 pfit)
{ /* Panel fitting is currently controlled by the X code, so this is a
noop until modesetting support works fully */
drm_dbg(display->drm, "Pfit is not supported\n"); return ASLC_PFIT_FAILED;
}
static u32 asle_set_supported_rotation_angles(struct intel_display *display, u32 srot)
{
drm_dbg(display->drm, "SROT is not supported\n"); return ASLC_ROTATION_ANGLES_FAILED;
}
static u32 asle_set_button_array(struct intel_display *display, u32 iuer)
{ if (!iuer)
drm_dbg(display->drm, "Button array event is not supported (nothing)\n"); if (iuer & ASLE_IUER_ROTATION_LOCK_BTN)
drm_dbg(display->drm, "Button array event is not supported (rotation lock)\n"); if (iuer & ASLE_IUER_VOLUME_DOWN_BTN)
drm_dbg(display->drm, "Button array event is not supported (volume down)\n"); if (iuer & ASLE_IUER_VOLUME_UP_BTN)
drm_dbg(display->drm, "Button array event is not supported (volume up)\n"); if (iuer & ASLE_IUER_WINDOWS_BTN)
drm_dbg(display->drm, "Button array event is not supported (windows)\n"); if (iuer & ASLE_IUER_POWER_BTN)
drm_dbg(display->drm, "Button array event is not supported (power)\n");
return ASLC_BUTTON_ARRAY_FAILED;
}
static u32 asle_set_convertible(struct intel_display *display, u32 iuer)
{ if (iuer & ASLE_IUER_CONVERTIBLE)
drm_dbg(display->drm, "Convertible is not supported (clamshell)\n"); else
drm_dbg(display->drm, "Convertible is not supported (slate)\n");
return ASLC_CONVERTIBLE_FAILED;
}
static u32 asle_set_docking(struct intel_display *display, u32 iuer)
{ if (iuer & ASLE_IUER_DOCKING)
drm_dbg(display->drm, "Docking is not supported (docked)\n"); else
drm_dbg(display->drm, "Docking is not supported (undocked)\n");
return ASLC_DOCKING_FAILED;
}
static u32 asle_isct_state(struct intel_display *display)
{
drm_dbg(display->drm, "ISCT is not supported\n"); return ASLC_ISCT_STATE_FAILED;
}
/* * The only video events relevant to opregion are 0x80. These indicate either a * docking event, lid switch or display switch request. In Linux, these are * handled by the dock, button and video drivers.
*/ staticint intel_opregion_video_event(struct notifier_block *nb, unsignedlong val, void *data)
{ struct intel_opregion *opregion = container_of(nb, struct intel_opregion,
acpi_notifier); struct acpi_bus_event *event = data; struct opregion_acpi *acpi; int ret = NOTIFY_OK;
if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0) return NOTIFY_DONE;
acpi = opregion->acpi;
if (event->type == 0x80 && ((acpi->cevt & 1) == 0))
ret = NOTIFY_BAD;
acpi->csts = 0;
return ret;
}
/* * Initialise the DIDL field in opregion. This passes a list of devices to * the firmware. Values are defined by section B.4.2 of the ACPI specification * (version 3)
*/
staticvoid set_did(struct intel_opregion *opregion, int i, u32 val)
{ if (i < ARRAY_SIZE(opregion->acpi->didl)) {
opregion->acpi->didl[i] = val;
} else {
i -= ARRAY_SIZE(opregion->acpi->didl);
if (WARN_ON(i >= ARRAY_SIZE(opregion->acpi->did2))) return;
/* * In theory, did2, the extended didl, gets added at opregion version * 3.0. In practice, however, we're supposed to set it for earlier * versions as well, since a BIOS that doesn't understand did2 should * not look at it anyway. Use a variable so we can tweak this if a need * arises later.
*/
max_outputs = ARRAY_SIZE(opregion->acpi->didl) +
ARRAY_SIZE(opregion->acpi->did2);
intel_acpi_device_id_update(display);
drm_connector_list_iter_begin(display->drm, &conn_iter);
for_each_intel_connector_iter(connector, &conn_iter) { if (i < max_outputs)
set_did(opregion, i, connector->acpi_device_id);
i++;
}
drm_connector_list_iter_end(&conn_iter);
if (i > max_outputs)
drm_err(display->drm, "More than %d outputs in connector list\n",
max_outputs);
/* If fewer than max outputs, the list must be null terminated */ if (i < max_outputs)
set_did(opregion, i, 0);
}
staticvoid intel_setup_cadls(struct intel_display *display)
{ struct intel_opregion *opregion = display->opregion; struct intel_connector *connector; struct drm_connector_list_iter conn_iter; int i = 0;
/* * Initialize the CADL field from the connector device ids. This is * essentially the same as copying from the DIDL. Technically, this is * not always correct as display outputs may exist, but not active. This * initialization is necessary for some Clevo laptops that check this * field before processing the brightness and display switching hotkeys. * * Note that internal panels should be at the front of the connector * list already, ensuring they're not left out.
*/
drm_connector_list_iter_begin(display->drm, &conn_iter);
for_each_intel_connector_iter(connector, &conn_iter) { if (i >= ARRAY_SIZE(opregion->acpi->cadl)) break;
opregion->acpi->cadl[i++] = connector->acpi_device_id;
}
drm_connector_list_iter_end(&conn_iter);
/* If fewer than 8 active devices, the list must be null terminated */ if (i < ARRAY_SIZE(opregion->acpi->cadl))
opregion->acpi->cadl[i] = 0;
}
/* We use GBDA to ask for supported GBDA calls. */ if (swsci(display, SWSCI_GBDA_SUPPORTED_CALLS, 0, &tmp) == 0) { /* make the bits match the sub-function codes */
tmp <<= 1;
opregion->swsci_gbda_sub_functions |= tmp;
}
/* * We also use GBDA to ask for _requested_ SBCB callbacks. The driver * must not call interfaces that are not specifically requested by the * bios.
*/ if (swsci(display, SWSCI_GBDA_REQUESTED_CALLBACKS, 0, &tmp) == 0) { /* here, the bits already match sub-function codes */
opregion->swsci_sbcb_sub_functions |= tmp;
requested_callbacks = true;
}
/* * But we use SBCB to ask for _supported_ SBCB calls. This does not mean * the callback is _requested_. But we still can't call interfaces that * are not requested.
*/ if (swsci(display, SWSCI_SBCB_SUPPORTED_CALLBACKS, 0, &tmp) == 0) { /* make the bits match the sub-function codes */
u32 low = tmp & 0x7ff;
u32 high = tmp & ~0xfff; /* bit 11 is reserved */
tmp = (high << 4) | (low << 1) | 1;
/* best guess what to do with supported wrt requested */ if (requested_callbacks) {
u32 req = opregion->swsci_sbcb_sub_functions; if ((req & tmp) != req)
drm_dbg(display->drm, "SWSCI BIOS requested (%08x) SBCB callbacks that are not supported (%08x)\n",
req, tmp); /* XXX: for now, trust the requested callbacks */ /* opregion->swsci_sbcb_sub_functions &= tmp; */
} else {
opregion->swsci_sbcb_sub_functions |= tmp;
}
}
staticint intel_no_opregion_vbt_callback(conststruct dmi_system_id *id)
{
DRM_DEBUG_KMS("Falling back to manually reading VBT from " "VBIOS ROM for %s\n", id->ident); return 1;
}
drm_dbg(display->drm, "ACPI OpRegion version %u.%u.%u\n",
opregion->header->over.major,
opregion->header->over.minor,
opregion->header->over.revision);
mboxes = opregion->header->mboxes; if (mboxes & MBOX_ACPI) {
drm_dbg(display->drm, "Public ACPI methods supported\n");
opregion->acpi = base + OPREGION_ACPI_OFFSET; /* * Indicate we handle monitor hotplug events ourselves so we do * not need ACPI notifications for them. Disabling these avoids * triggering the AML code doing the notifation, which may be * broken as Windows also seems to disable these.
*/
opregion->acpi->chpd = 1;
}
if (mboxes & MBOX_SWSCI) {
u8 major = opregion->header->over.major;
if (major >= 3) {
drm_err(display->drm, "SWSCI Mailbox #2 present for opregion v3.x, ignoring\n");
} else { if (major >= 2)
drm_dbg(display->drm, "SWSCI Mailbox #2 present for opregion v2.x\n");
drm_dbg(display->drm, "SWSCI supported\n");
opregion->swsci = base + OPREGION_SWSCI_OFFSET;
swsci_setup(display);
}
}
if (mboxes & MBOX_ASLE) {
drm_dbg(display->drm, "ASLE supported\n");
opregion->asle = base + OPREGION_ASLE_OFFSET;
opregion->asle->ardy = ASLE_ARDY_NOT_READY;
}
if (mboxes & MBOX_ASLE_EXT) {
drm_dbg(display->drm, "ASLE extension supported\n");
opregion->asle_ext = base + OPREGION_ASLE_EXT_OFFSET;
}
if (mboxes & MBOX_BACKLIGHT) {
drm_dbg(display->drm, "Mailbox #2 for backlight present\n");
}
if (dmi_check_system(intel_no_opregion_vbt)) goto out;
/* * opregion 2.0: rvda is the physical VBT address. * * opregion 2.1+: rvda is unsigned, relative offset from * opregion base, and should never point within opregion.
*/ if (opregion->header->over.major > 2 ||
opregion->header->over.minor >= 1) {
drm_WARN_ON(display->drm, rvda < OPREGION_SIZE);
vbt = base + OPREGION_VBT_OFFSET; /* * The VBT specification says that if the ASLE ext mailbox is not used * its area is reserved, but on some CHT boards the VBT extends into the * ASLE ext area. Allow this even though it is against the spec, so we * do not end up rejecting the VBT on those boards (and end up not * finding the LCD panel because of this).
*/
vbt_size = (mboxes & MBOX_ASLE_EXT) ?
OPREGION_ASLE_EXT_OFFSET : OPREGION_SIZE;
vbt_size -= OPREGION_VBT_OFFSET; if (intel_bios_is_valid_vbt(display, vbt, vbt_size)) {
drm_dbg_kms(display->drm, "Found valid VBT in ACPI OpRegion (Mailbox #4)\n");
opregion->vbt = vbt;
opregion->vbt_size = vbt_size;
} else {
drm_dbg_kms(display->drm, "Invalid VBT in ACPI OpRegion (Mailbox #4)\n");
}
int
intel_opregion_get_panel_type(struct intel_display *display)
{
u32 panel_details; int ret;
ret = swsci(display, SWSCI_GBDA_PANEL_DETAILS, 0x0, &panel_details); if (ret) return ret;
ret = (panel_details >> 8) & 0xff; if (ret > 0x10) {
drm_dbg_kms(display->drm, "Invalid OpRegion panel type 0x%x\n", ret); return -EINVAL;
}
/* fall back to VBT panel type? */ if (ret == 0x0) {
drm_dbg_kms(display->drm, "No panel type in OpRegion\n"); return -ENODEV;
}
/* * So far we know that some machined must use it, others must not use it. * There doesn't seem to be any way to determine which way to go, except * via a quirk list :(
*/ if (!dmi_check_system(intel_use_opregion_panel_type)) {
drm_dbg_kms(display->drm, "Ignoring OpRegion panel type (%d)\n", ret - 1); return -ENODEV;
}
return ret - 1;
}
/** * intel_opregion_get_edid - Fetch EDID from ACPI OpRegion mailbox #5 * @connector: eDP connector * * This reads the ACPI Opregion mailbox #5 to extract the EDID that is passed * to it. * * Returns: * The EDID in the OpRegion, or NULL if there is none or it's invalid. *
*/ conststruct drm_edid *intel_opregion_get_edid(struct intel_connector *connector)
{ struct intel_display *display = to_intel_display(connector); struct intel_opregion *opregion = display->opregion; conststruct drm_edid *drm_edid; constvoid *edid; int len;
if (!opregion || !opregion->asle_ext) return NULL;
edid = opregion->asle_ext->bddc;
/* Validity corresponds to number of 128-byte blocks */
len = (opregion->asle_ext->phed & ASLE_PHED_EDID_VALID_MASK) * 128; if (!len || mem_is_zero(edid, len)) return NULL;
drm_edid = drm_edid_alloc(edid, len);
if (!drm_edid_valid(drm_edid)) {
drm_dbg_kms(display->drm, "Invalid EDID in ACPI OpRegion (Mailbox #5)\n");
drm_edid_free(drm_edid);
drm_edid = NULL;
}
if (opregion->acpi) {
intel_didl_outputs(display);
intel_setup_cadls(display);
/* * Notify BIOS we are ready to handle ACPI video ext notifs. * Right now, all the events are handled by the ACPI video * module. We don't actually need to do anything with them.
*/
opregion->acpi->csts = 0;
opregion->acpi->drdy = 1;
}
if (opregion->asle) {
opregion->asle->tche = ASLE_TCHE_BLC_EN;
opregion->asle->ardy = ASLE_ARDY_READY;
}
/* Some platforms abuse the _DSM to enable MUX */
intel_dsm_get_bios_data_funcs_supported(display);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.