summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <anholt@FreeBSD.org>2006-03-24 11:55:01 -0800
committerEric Anholt <anholt@leguin.anholt.net>2006-04-06 15:59:26 -0700
commit64756e215016730b5cc2e174f08d47c0288c0ba4 (patch)
tree1630610774f0b59a4a00bc67f7bd3693f00fad8f
parentc2d554be671f5368bd98867b8ecf9428e4560a81 (diff)
Start interpreting VBT information with the goal of pulling out LVDS timings
for panel fitting.
-rw-r--r--src/Makefile.am2
-rw-r--r--src/i830.h2
-rw-r--r--src/i830_bios.c126
-rw-r--r--src/i830_bios.h50
-rw-r--r--src/i830_display.c7
5 files changed, 187 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 37682eb0..1b30c656 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -44,6 +44,8 @@ i810_drv_la_SOURCES = \
i810_video.c \
i810_wmark.c \
i830_accel.c \
+ i830_bios.c \
+ i830_bios.h \
i830_common.h \
i830_cursor.c \
i830_debug.c \
diff --git a/src/i830.h b/src/i830.h
index eb75f453..fb868879 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -430,6 +430,8 @@ typedef struct _I830Rec {
struct _I830OutputRec output[MAX_OUTPUTS];
I830SDVOPtr sdvo;
+ unsigned char *VBIOS;
+
CARD32 saveDSPACNTR;
CARD32 saveDSPBCNTR;
CARD32 savePIPEACONF;
diff --git a/src/i830_bios.c b/src/i830_bios.c
new file mode 100644
index 00000000..a5b7fcd7
--- /dev/null
+++ b/src/i830_bios.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright © 2006 Intel Corporation
+ *
+ * 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, sublicense,
+ * 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "xf86.h"
+#include "xf86_ansic.h"
+#include "i830.h"
+#include "i830_bios.h"
+
+#define INTEL_BIOS_8(_addr) (pI830->VBIOS[_addr])
+#define INTEL_BIOS_16(_addr) (pI830->VBIOS[_addr] | \
+ (pI830->VBIOS[_addr + 1] << 8))
+#define INTEL_BIOS_32(_addr) (pI830->VBIOS[_addr] | \
+ (pI830->VBIOS[_addr + 1] << 8) \
+ (pI830->VBIOS[_addr + 2] << 16) \
+ (pI830->VBIOS[_addr + 3] << 24))
+
+/* XXX */
+#define INTEL_VBIOS_SIZE (64 * 1024)
+
+/**
+ * Loads the Video BIOS and checks that the VBT exists.
+ *
+ * VBT existence is a sanity check that is relied on by other i830_bios.c code.
+ * Note that it would be better to use a BIOS call to get the VBT, as BIOSes may
+ * feed an updated VBT back through that, compared to what we'll fetch using
+ * this method of groping around in the BIOS data.
+ */
+static Bool
+i830GetBIOS(ScrnInfoPtr pScrn)
+{
+ I830Ptr pI830 = I830PTR(pScrn);
+ struct vbt_header *vbt;
+ int vbt_off;
+
+ if (pI830->VBIOS != NULL)
+ return TRUE;
+
+ pI830->VBIOS = xalloc(INTEL_VBIOS_SIZE);
+ if (pI830->VBIOS == NULL)
+ return FALSE;
+
+ if (pI830->pVbe != NULL) {
+ memcpy(pI830->VBIOS, (void *)(pI830->pVbe->pInt10->BIOSseg << 4),
+ INTEL_VBIOS_SIZE);
+ } else {
+ xf86ReadPciBIOS(0, pI830->PciTag, 0, pI830->VBIOS, INTEL_VBIOS_SIZE);
+ }
+
+ vbt_off = INTEL_BIOS_16(0x1a);
+ if (vbt_off >= INTEL_VBIOS_SIZE) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Bad VBT offset: 0x%x\n",
+ vbt_off);
+ xfree(pI830->VBIOS);
+ return FALSE;
+ }
+
+ vbt = (struct vbt_header *)(pI830->VBIOS + vbt_off);
+
+ if (memcmp(vbt->signature, "$VBT", 4) != 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Bad VBT signature\n");
+ xfree(pI830->VBIOS);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+i830GetLVDSInfoFromBIOS(ScrnInfoPtr pScrn)
+{
+ I830Ptr pI830 = I830PTR(pScrn);
+ struct vbt_header *vbt;
+ struct bdb_header *bdb;
+ int vbt_off, bdb_block_off, block_size;
+
+ if (!i830GetBIOS(pScrn))
+ return FALSE;
+
+ vbt_off = INTEL_BIOS_16(0x1a);
+ vbt = (struct vbt_header *)(pI830->VBIOS + vbt_off);
+ bdb = (struct bdb_header *)(pI830->VBIOS + vbt_off + vbt->bdb_offset);
+
+ if (memcmp(bdb->signature, "BIOS_DATA_BLOCK ", 16) != 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Bad BDB signature\n");
+ return FALSE;
+ }
+
+ for (bdb_block_off = bdb->header_size; bdb_block_off < bdb->bdb_size;
+ bdb_block_off += block_size)
+ {
+ int start = vbt_off + vbt->bdb_offset + bdb_block_off;
+ int id;
+
+ id = INTEL_BIOS_8(start);
+ block_size = INTEL_BIOS_16(start + 1) + 3;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Found BDB block type %d\n", id);
+ }
+ return TRUE;
+}
diff --git a/src/i830_bios.h b/src/i830_bios.h
new file mode 100644
index 00000000..ed3f1826
--- /dev/null
+++ b/src/i830_bios.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2006 Intel Corporation
+ *
+ * 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, sublicense,
+ * 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+struct vbt_header {
+ char signature[20]; /**< Always 'BIOS_DATA_BLOCK' */
+ CARD16 version; /**< decimal */
+ CARD16 header_size; /**< in bytes */
+ CARD16 vbt_size; /**< in bytes */
+ CARD8 vbt_checksum;
+ CARD8 reserved0;
+ CARD32 bdb_offset; /**< from beginning of VBT */
+ CARD32 aim1_offset; /**< from beginning of VBT */
+ CARD32 aim2_offset; /**< from beginning of VBT */
+ CARD32 aim3_offset; /**< from beginning of VBT */
+ CARD32 aim4_offset; /**< from beginning of VBT */
+};
+
+struct bdb_header {
+ char signature[16]; /**< Always 'BIOS_DATA_BLOCK' */
+ CARD16 version; /**< decimal */
+ CARD16 header_size; /**< in bytes */
+ CARD16 bdb_size; /**< in bytes */
+};
+
+Bool
+i830GetLVDSInfoFromBIOS(ScrnInfoPtr pScrn);
diff --git a/src/i830_display.c b/src/i830_display.c
index 5386ac8d..57038df1 100644
--- a/src/i830_display.c
+++ b/src/i830_display.c
@@ -340,6 +340,13 @@ i830PipeSetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode, int pipe)
vsync = (pMode->CrtcVSyncStart - 1) | ((pMode->CrtcVSyncEnd - 1) << 16);
pipesrc = ((pMode->HDisplay - 1) << 16) | (pMode->VDisplay - 1);
dspsize = ((pMode->VDisplay - 1) << 16) | (pMode->HDisplay - 1);
+ if (outputs & PIPE_LCD_ACTIVE) {
+ /* To enable panel fitting, we need to set the pipe timings to that of
+ * the screen at its full resolution. So, pull the timings out of the
+ * BIOS tables and drop them in here.
+ */
+ i830GetLVDSInfoFromBIOS(pScrn);
+ }
adpa = INREG(ADPA);
adpa &= ~(ADPA_HSYNC_ACTIVE_HIGH | ADPA_VSYNC_ACTIVE_HIGH);