PERFORCE change 125226 for review

Rui Paulo rpaulo at FreeBSD.org
Thu Aug 16 11:02:46 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=125226

Change 125226 by rpaulo at rpaulo_alpha on 2007/08/16 18:02:36

	Add some new comments, fix others.
	Do some kind of initialization routine that's likely to be
	needed for MacBook Pros.

Affected files ...

.. //depot/projects/soc2007/rpaulo-macbook/dev/backlight/backlight.c#13 edit

Differences ...

==== //depot/projects/soc2007/rpaulo-macbook/dev/backlight/backlight.c#13 (text+ko) ====

@@ -23,10 +23,19 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/backlight/backlight.c#12 $
+ * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/backlight/backlight.c#13 $
  *
  */
 
+/*
+ * Driver to control LCD backlight on the MacBook and MacBook Pro
+ * Apple laptops.
+ * 
+ * All the technical information regarding to register offsets and
+ * modus operadi (see the big MacBook comment) came from the
+ * userland utilities for Linux.
+ */
+
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
@@ -218,7 +227,7 @@
  * Apple's MacBook specific functions.
  * 
  * This code was inspired on the MacBook backlight control utility by
- * Ryan Lortie. The whole reverse engineering was done by him.
+ * Ryan Lortie.
  *
  * There's a register at BACKLIGHT_MB_OFFSET on PCI_BAR(0) that controls
  * the LCD backlight.
@@ -228,7 +237,6 @@
  *
  * The y bits are the maximum brightness level, the x bits are the
  * current brightness level.
- * Apple's firmware sets the x bits to BACKLIGHT_MB_DEF.
  * There are two thresholds: BACKLIGHT_MB_OFF and BACKLIGHT_MB_ON that
  * turn off and on the backlight respectively.
  *
@@ -396,6 +404,7 @@
 {
 	struct backlight_softc *sc = device_get_softc(dev);
 	int rid;
+	int32_t state;
 
 	rid = PCIR_BAR(0);
 	sc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
@@ -404,6 +413,14 @@
 	if (sc->sc_res == NULL)
 		return (ENOMEM);
 
+	/*
+	 * Magic values came from backlight.c written by Nicolas
+	 * Boichat.
+	 */
+	bus_write_4(sc->sc_res, 0x4dc, 0x00000005);
+	state = bus_read_4(sc->sc_res, 0x7ae4);
+	bus_write_4(sc->sc_res, 0x7ae4, state);
+
 	sc->sc_enable = macbookpro_get_current(sc) >= BACKLIGHT_MBP_MIN ?
 	    1 : 0;
 	sc->sc_level  = macbookpro_get_current(sc);


More information about the p4-projects mailing list