Lines Matching +full:battery +full:- +full:driven
5 * Copyright (C) 2010-2012 Andreas Heider <andreas@meetr.de>
22 #include <linux/apple-gmux.h>
34 * A `Lattice XP2`_ on pre-retinas, a `Renesas R4F2113`_ on retinas.
37 * dual GPUs but no built-in display.)
41 * to access a pre-retina gmux are infixed ``_pio_``, those for a retina gmux
107 return inb(gmux_data->iostart + port); in gmux_pio_read8()
113 outb(val, gmux_data->iostart + port); in gmux_pio_write8()
118 return inl(gmux_data->iostart + port); in gmux_pio_read32()
129 outb(tmpval, gmux_data->iostart + port + i); in gmux_pio_write32()
136 u8 gwr = inb(gmux_data->iostart + GMUX_PORT_WRITE); in gmux_index_wait_ready()
139 inb(gmux_data->iostart + GMUX_PORT_READ); in gmux_index_wait_ready()
140 gwr = inb(gmux_data->iostart + GMUX_PORT_WRITE); in gmux_index_wait_ready()
142 i--; in gmux_index_wait_ready()
151 u8 gwr = inb(gmux_data->iostart + GMUX_PORT_WRITE); in gmux_index_wait_complete()
154 gwr = inb(gmux_data->iostart + GMUX_PORT_WRITE); in gmux_index_wait_complete()
156 i--; in gmux_index_wait_complete()
160 inb(gmux_data->iostart + GMUX_PORT_READ); in gmux_index_wait_complete()
169 mutex_lock(&gmux_data->index_lock); in gmux_index_read8()
171 outb((port & 0xff), gmux_data->iostart + GMUX_PORT_READ); in gmux_index_read8()
173 val = inb(gmux_data->iostart + GMUX_PORT_VALUE); in gmux_index_read8()
174 mutex_unlock(&gmux_data->index_lock); in gmux_index_read8()
182 mutex_lock(&gmux_data->index_lock); in gmux_index_write8()
183 outb(val, gmux_data->iostart + GMUX_PORT_VALUE); in gmux_index_write8()
185 outb(port & 0xff, gmux_data->iostart + GMUX_PORT_WRITE); in gmux_index_write8()
187 mutex_unlock(&gmux_data->index_lock); in gmux_index_write8()
194 mutex_lock(&gmux_data->index_lock); in gmux_index_read32()
196 outb((port & 0xff), gmux_data->iostart + GMUX_PORT_READ); in gmux_index_read32()
198 val = inl(gmux_data->iostart + GMUX_PORT_VALUE); in gmux_index_read32()
199 mutex_unlock(&gmux_data->index_lock); in gmux_index_read32()
210 mutex_lock(&gmux_data->index_lock); in gmux_index_write32()
214 outb(tmpval, gmux_data->iostart + GMUX_PORT_VALUE + i); in gmux_index_write32()
218 outb(port & 0xff, gmux_data->iostart + GMUX_PORT_WRITE); in gmux_index_write32()
220 mutex_unlock(&gmux_data->index_lock); in gmux_index_write32()
225 if (gmux_data->indexed) in gmux_read8()
233 if (gmux_data->indexed) in gmux_write8()
241 if (gmux_data->indexed) in gmux_read32()
250 if (gmux_data->indexed) in gmux_write32()
260 outb(0xaa, gmux_data->iostart + 0xcc); in gmux_is_indexed()
261 outb(0x55, gmux_data->iostart + 0xcd); in gmux_is_indexed()
262 outb(0x00, gmux_data->iostart + 0xce); in gmux_is_indexed()
264 val = inb(gmux_data->iostart + 0xcc) | in gmux_is_indexed()
265 (inb(gmux_data->iostart + 0xcd) << 8); in gmux_is_indexed()
297 u32 brightness = bd->props.brightness; in gmux_update_status()
299 if (bd->props.state & BL_CORE_SUSPENDED) in gmux_update_status()
316 * On pre-retinas, the LVDS outputs of both GPUs feed into gmux which muxes
319 * synchronize it with the GPU switched to. This allows for a flicker-free
325 * The panel is driven with eDP instead of LVDS since the pixel clock
328 * Pre-retinas are able to switch the panel's DDC pins separately.
336 * set up the output with link parameters pre-calibrated by the active GPU.
347 * are still switchable by way of an `NXP CBTL03062`_ (on pre-retinas
350 * external displays appear to it as phantoms which fail to link-train.
363 * possible to drive e.g. a beamer on battery power with the integrated GPU.
367 * On all newer generations, the external port can only be driven by the
374 * variable ``gpu-power-prefs-fa4ce28d-b62f-4c99-9cc3-6815686e30f9`` (5th byte,
379 * .. _US 8,687,007 B2: http://pimg-fpiw.uspto.gov/fdd/07/870/086/0.pdf
385 …* .. _NXP CBTL03062: http://pdf.datasheetarchive.com/indexerfiles/Datasheets-SW16/DSASW00308511.…
392 gmux_data->switch_state_ddc = VGA_SWITCHEROO_IGD; in gmux_read_switch_state()
394 gmux_data->switch_state_ddc = VGA_SWITCHEROO_DIS; in gmux_read_switch_state()
397 gmux_data->switch_state_display = VGA_SWITCHEROO_IGD; in gmux_read_switch_state()
399 gmux_data->switch_state_display = VGA_SWITCHEROO_DIS; in gmux_read_switch_state()
402 gmux_data->switch_state_external = VGA_SWITCHEROO_IGD; in gmux_read_switch_state()
404 gmux_data->switch_state_external = VGA_SWITCHEROO_DIS; in gmux_read_switch_state()
409 if (gmux_data->switch_state_ddc == VGA_SWITCHEROO_IGD) in gmux_write_switch_state()
414 if (gmux_data->switch_state_display == VGA_SWITCHEROO_IGD) in gmux_write_switch_state()
419 if (gmux_data->switch_state_external == VGA_SWITCHEROO_IGD) in gmux_write_switch_state()
427 apple_gmux_data->switch_state_ddc = id; in gmux_switchto()
428 apple_gmux_data->switch_state_display = id; in gmux_switchto()
429 if (apple_gmux_data->external_switchable) in gmux_switchto()
430 apple_gmux_data->switch_state_external = id; in gmux_switchto()
440 apple_gmux_data->switch_state_ddc; in gmux_switch_ddc()
446 apple_gmux_data->switch_state_ddc = id; in gmux_switch_ddc()
467 reinit_completion(&gmux_data->powerchange_done); in gmux_set_discrete_state()
479 gmux_data->power_state = state; in gmux_set_discrete_state()
481 if (gmux_data->gpe >= 0 && in gmux_set_discrete_state()
482 !wait_for_completion_interruptible_timeout(&gmux_data->powerchange_done, in gmux_set_discrete_state()
504 if (pdev->vendor == PCI_VENDOR_ID_INTEL) in gmux_get_client_id()
506 else if (pdev->vendor == PCI_VENDOR_ID_NVIDIA && in gmux_get_client_id()
507 pdev->device == 0x0863) in gmux_get_client_id()
576 complete(&gmux_data->powerchange_done); in gmux_notify_handler()
595 if (gmux_data->power_state == VGA_SWITCHEROO_OFF) in gmux_resume()
596 gmux_set_discrete_state(gmux_data, gmux_data->power_state); in gmux_resume()
602 return to_pci_dev(dev)->is_thunderbolt; in is_thunderbolt()
612 int ret = -ENXIO; in gmux_probe()
617 return -EBUSY; in gmux_probe()
621 return -ENOMEM; in gmux_probe()
630 gmux_data->iostart = res->start; in gmux_probe()
631 gmux_data->iolen = res->end - res->start; in gmux_probe()
633 if (gmux_data->iolen < GMUX_MIN_IO_LEN) { in gmux_probe()
635 gmux_data->iolen, GMUX_MIN_IO_LEN); in gmux_probe()
639 if (!request_region(gmux_data->iostart, gmux_data->iolen, in gmux_probe()
657 mutex_init(&gmux_data->index_lock); in gmux_probe()
658 gmux_data->indexed = true; in gmux_probe()
666 ret = -ENODEV; in gmux_probe()
671 ver_release, (gmux_data->indexed ? "indexed" : "classic")); in gmux_probe()
686 bdev = backlight_device_register("gmux_backlight", &pnp->dev, in gmux_probe()
693 gmux_data->bdev = bdev; in gmux_probe()
694 bdev->props.brightness = gmux_get_brightness(bdev); in gmux_probe()
706 gmux_data->power_state = VGA_SWITCHEROO_ON; in gmux_probe()
708 gmux_data->dhandle = ACPI_HANDLE(&pnp->dev); in gmux_probe()
709 if (!gmux_data->dhandle) { in gmux_probe()
711 dev_name(&pnp->dev)); in gmux_probe()
712 ret = -ENODEV; in gmux_probe()
716 status = acpi_evaluate_integer(gmux_data->dhandle, "GMGP", NULL, &gpe); in gmux_probe()
718 gmux_data->gpe = (int)gpe; in gmux_probe()
720 status = acpi_install_notify_handler(gmux_data->dhandle, in gmux_probe()
726 ret = -ENODEV; in gmux_probe()
730 status = acpi_enable_gpe(NULL, gmux_data->gpe); in gmux_probe()
738 gmux_data->gpe = -1; in gmux_probe()
745 gmux_data->external_switchable = in gmux_probe()
747 if (!gmux_data->external_switchable) in gmux_probe()
751 init_completion(&gmux_data->powerchange_done); in gmux_probe()
757 * and need eDP pre-calibration. They are distinguishable from in gmux_probe()
758 * pre-retinas by having an "indexed" gmux. in gmux_probe()
760 * Pre-retina MacBook Pros can switch the panel's DDC separately. in gmux_probe()
762 if (gmux_data->indexed) in gmux_probe()
778 if (gmux_data->gpe >= 0) in gmux_probe()
779 acpi_disable_gpe(NULL, gmux_data->gpe); in gmux_probe()
781 if (gmux_data->gpe >= 0) in gmux_probe()
782 acpi_remove_notify_handler(gmux_data->dhandle, in gmux_probe()
788 release_region(gmux_data->iostart, gmux_data->iolen); in gmux_probe()
800 if (gmux_data->gpe >= 0) { in gmux_remove()
801 acpi_disable_gpe(NULL, gmux_data->gpe); in gmux_remove()
802 acpi_remove_notify_handler(gmux_data->dhandle, in gmux_remove()
807 backlight_device_unregister(gmux_data->bdev); in gmux_remove()
809 release_region(gmux_data->iostart, gmux_data->iolen); in gmux_remove()
828 .name = "apple-gmux",